chirag-appwrite-cli 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/build-verify.yml +71 -0
- package/.github/workflows/npm-publish.yml +41 -22
- package/CHANGELOG.md +190 -1
- package/LICENSE.md +12 -1
- package/README.md +182 -15
- package/bun.lock +627 -0
- package/dist/bundle.cjs +108228 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +149 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/client.d.ts +88 -0
- package/dist/lib/client.d.ts.map +1 -0
- package/dist/lib/client.js +238 -0
- package/dist/lib/client.js.map +1 -0
- package/dist/lib/commands/config.d.ts +557 -0
- package/dist/lib/commands/config.d.ts.map +1 -0
- package/dist/lib/commands/config.js +415 -0
- package/dist/lib/commands/config.js.map +1 -0
- package/dist/lib/commands/db.d.ts +34 -0
- package/dist/lib/commands/db.d.ts.map +1 -0
- package/dist/lib/commands/db.js +247 -0
- package/dist/lib/commands/db.js.map +1 -0
- package/dist/lib/commands/errors.d.ts +68 -0
- package/dist/lib/commands/errors.d.ts.map +1 -0
- package/dist/lib/commands/errors.js +72 -0
- package/dist/lib/commands/errors.js.map +1 -0
- package/dist/lib/commands/generic.d.ts +17 -0
- package/dist/lib/commands/generic.d.ts.map +1 -0
- package/dist/lib/commands/generic.js +292 -0
- package/dist/lib/commands/generic.js.map +1 -0
- package/dist/lib/commands/init.d.ts +3 -0
- package/dist/lib/commands/init.d.ts.map +1 -0
- package/dist/lib/commands/init.js +526 -0
- package/dist/lib/commands/init.js.map +1 -0
- package/dist/lib/commands/pull.d.ts +110 -0
- package/dist/lib/commands/pull.d.ts.map +1 -0
- package/dist/lib/commands/pull.js +626 -0
- package/dist/lib/commands/pull.js.map +1 -0
- package/dist/lib/commands/push.d.ts +82 -0
- package/dist/lib/commands/push.d.ts.map +1 -0
- package/dist/lib/commands/push.js +1666 -0
- package/dist/lib/commands/push.js.map +1 -0
- package/dist/lib/commands/run.d.ts +3 -0
- package/dist/lib/commands/run.d.ts.map +1 -0
- package/dist/lib/commands/run.js +289 -0
- package/dist/lib/commands/run.js.map +1 -0
- package/dist/lib/commands/schema.d.ts +57 -0
- package/dist/lib/commands/schema.d.ts.map +1 -0
- package/dist/lib/commands/schema.js +75 -0
- package/dist/lib/commands/schema.js.map +1 -0
- package/dist/lib/commands/services/account.d.ts +3 -0
- package/dist/lib/commands/services/account.d.ts.map +1 -0
- package/dist/lib/commands/services/account.js +306 -0
- package/dist/lib/commands/services/account.js.map +1 -0
- package/dist/lib/commands/services/avatars.d.ts +3 -0
- package/dist/lib/commands/services/avatars.d.ts.map +1 -0
- package/dist/lib/commands/services/avatars.js +118 -0
- package/dist/lib/commands/services/avatars.js.map +1 -0
- package/dist/lib/commands/services/console.d.ts +3 -0
- package/dist/lib/commands/services/console.d.ts.map +1 -0
- package/dist/lib/commands/services/console.js +41 -0
- package/dist/lib/commands/services/console.js.map +1 -0
- package/dist/lib/commands/services/databases.d.ts +3 -0
- package/dist/lib/commands/services/databases.d.ts.map +1 -0
- package/dist/lib/commands/services/databases.js +612 -0
- package/dist/lib/commands/services/databases.js.map +1 -0
- package/dist/lib/commands/services/functions.d.ts +3 -0
- package/dist/lib/commands/services/functions.d.ts.map +1 -0
- package/dist/lib/commands/services/functions.js +258 -0
- package/dist/lib/commands/services/functions.js.map +1 -0
- package/dist/lib/commands/services/graphql.d.ts +3 -0
- package/dist/lib/commands/services/graphql.d.ts.map +1 -0
- package/dist/lib/commands/services/graphql.js +28 -0
- package/dist/lib/commands/services/graphql.js.map +1 -0
- package/dist/lib/commands/services/health.d.ts +3 -0
- package/dist/lib/commands/services/health.d.ts.map +1 -0
- package/dist/lib/commands/services/health.js +123 -0
- package/dist/lib/commands/services/health.js.map +1 -0
- package/dist/lib/commands/services/locale.d.ts +3 -0
- package/dist/lib/commands/services/locale.d.ts.map +1 -0
- package/dist/lib/commands/services/locale.js +52 -0
- package/dist/lib/commands/services/locale.js.map +1 -0
- package/dist/lib/commands/services/messaging.d.ts +3 -0
- package/dist/lib/commands/services/messaging.d.ts.map +1 -0
- package/dist/lib/commands/services/messaging.js +505 -0
- package/dist/lib/commands/services/messaging.js.map +1 -0
- package/dist/lib/commands/services/migrations.d.ts +3 -0
- package/dist/lib/commands/services/migrations.d.ts.map +1 -0
- package/dist/lib/commands/services/migrations.js +135 -0
- package/dist/lib/commands/services/migrations.js.map +1 -0
- package/dist/lib/commands/services/project.d.ts +3 -0
- package/dist/lib/commands/services/project.d.ts.map +1 -0
- package/dist/lib/commands/services/project.js +54 -0
- package/dist/lib/commands/services/project.js.map +1 -0
- package/dist/lib/commands/services/projects.d.ts +3 -0
- package/dist/lib/commands/services/projects.d.ts.map +1 -0
- package/dist/lib/commands/services/projects.js +415 -0
- package/dist/lib/commands/services/projects.js.map +1 -0
- package/dist/lib/commands/services/proxy.d.ts +3 -0
- package/dist/lib/commands/services/proxy.d.ts.map +1 -0
- package/dist/lib/commands/services/proxy.js +68 -0
- package/dist/lib/commands/services/proxy.js.map +1 -0
- package/dist/lib/commands/services/sites.d.ts +3 -0
- package/dist/lib/commands/services/sites.d.ts.map +1 -0
- package/dist/lib/commands/services/sites.js +242 -0
- package/dist/lib/commands/services/sites.js.map +1 -0
- package/dist/lib/commands/services/storage.d.ts +3 -0
- package/dist/lib/commands/services/storage.d.ts.map +1 -0
- package/dist/lib/commands/services/storage.js +153 -0
- package/dist/lib/commands/services/storage.js.map +1 -0
- package/dist/lib/commands/services/tablesdb.d.ts +3 -0
- package/dist/lib/commands/services/tablesdb.d.ts.map +1 -0
- package/dist/lib/commands/services/tablesdb.js +605 -0
- package/dist/lib/commands/services/tablesdb.js.map +1 -0
- package/dist/lib/commands/services/teams.d.ts +3 -0
- package/dist/lib/commands/services/teams.d.ts.map +1 -0
- package/dist/lib/commands/services/teams.js +123 -0
- package/dist/lib/commands/services/teams.js.map +1 -0
- package/dist/lib/commands/services/tokens.d.ts +3 -0
- package/dist/lib/commands/services/tokens.d.ts.map +1 -0
- package/dist/lib/commands/services/tokens.js +49 -0
- package/dist/lib/commands/services/tokens.js.map +1 -0
- package/dist/lib/commands/services/users.d.ts +3 -0
- package/dist/lib/commands/services/users.d.ts.map +1 -0
- package/dist/lib/commands/services/users.js +312 -0
- package/dist/lib/commands/services/users.js.map +1 -0
- package/dist/lib/commands/services/vcs.d.ts +3 -0
- package/dist/lib/commands/services/vcs.d.ts.map +1 -0
- package/dist/lib/commands/services/vcs.js +87 -0
- package/dist/lib/commands/services/vcs.js.map +1 -0
- package/dist/lib/commands/types.d.ts +3 -0
- package/dist/lib/commands/types.d.ts.map +1 -0
- package/dist/lib/commands/types.js +151 -0
- package/dist/lib/commands/types.js.map +1 -0
- package/dist/lib/commands/update.d.ts +3 -0
- package/dist/lib/commands/update.d.ts.map +1 -0
- package/dist/lib/commands/update.js +201 -0
- package/dist/lib/commands/update.js.map +1 -0
- package/dist/lib/commands/utils/attributes.d.ts +46 -0
- package/dist/lib/commands/utils/attributes.d.ts.map +1 -0
- package/dist/lib/commands/utils/attributes.js +521 -0
- package/dist/lib/commands/utils/attributes.js.map +1 -0
- package/dist/lib/commands/utils/change-approval.d.ts +25 -0
- package/dist/lib/commands/utils/change-approval.d.ts.map +1 -0
- package/dist/lib/commands/utils/change-approval.js +129 -0
- package/dist/lib/commands/utils/change-approval.js.map +1 -0
- package/dist/lib/commands/utils/database-sync.d.ts +10 -0
- package/dist/lib/commands/utils/database-sync.d.ts.map +1 -0
- package/dist/lib/commands/utils/database-sync.js +136 -0
- package/dist/lib/commands/utils/database-sync.js.map +1 -0
- package/dist/lib/commands/utils/deployment.d.ts +34 -0
- package/dist/lib/commands/utils/deployment.d.ts.map +1 -0
- package/dist/lib/commands/utils/deployment.js +108 -0
- package/dist/lib/commands/utils/deployment.js.map +1 -0
- package/dist/lib/commands/utils/error-formatter.d.ts +19 -0
- package/dist/lib/commands/utils/error-formatter.d.ts.map +1 -0
- package/dist/lib/commands/utils/error-formatter.js +333 -0
- package/dist/lib/commands/utils/error-formatter.js.map +1 -0
- package/dist/lib/commands/utils/pools.d.ts +16 -0
- package/dist/lib/commands/utils/pools.d.ts.map +1 -0
- package/dist/lib/commands/utils/pools.js +197 -0
- package/dist/lib/commands/utils/pools.js.map +1 -0
- package/dist/lib/config.d.ts +119 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +728 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/emulation/docker.d.ts +7 -0
- package/dist/lib/emulation/docker.d.ts.map +1 -0
- package/dist/lib/emulation/docker.js +224 -0
- package/dist/lib/emulation/docker.js.map +1 -0
- package/dist/lib/emulation/utils.d.ts +29 -0
- package/dist/lib/emulation/utils.d.ts.map +1 -0
- package/dist/lib/emulation/utils.js +165 -0
- package/dist/lib/emulation/utils.js.map +1 -0
- package/dist/lib/id.d.ts +7 -0
- package/dist/lib/id.d.ts.map +1 -0
- package/dist/lib/id.js +27 -0
- package/dist/lib/id.js.map +1 -0
- package/dist/lib/paginate.d.ts +9 -0
- package/dist/lib/paginate.d.ts.map +1 -0
- package/dist/lib/paginate.js +43 -0
- package/dist/lib/paginate.js.map +1 -0
- package/dist/lib/parser.d.ts +18 -0
- package/dist/lib/parser.d.ts.map +1 -0
- package/dist/lib/parser.js +225 -0
- package/dist/lib/parser.js.map +1 -0
- package/dist/lib/questions.d.ts +59 -0
- package/dist/lib/questions.d.ts.map +1 -0
- package/dist/lib/questions.js +991 -0
- package/dist/lib/questions.js.map +1 -0
- package/dist/lib/sdks.d.ts +4 -0
- package/dist/lib/sdks.d.ts.map +1 -0
- package/dist/lib/sdks.js +61 -0
- package/dist/lib/sdks.js.map +1 -0
- package/dist/lib/services.d.ts +13 -0
- package/dist/lib/services.d.ts.map +1 -0
- package/dist/lib/services.js +47 -0
- package/dist/lib/services.js.map +1 -0
- package/dist/lib/spinner.d.ts +28 -0
- package/dist/lib/spinner.d.ts.map +1 -0
- package/dist/lib/spinner.js +91 -0
- package/dist/lib/spinner.js.map +1 -0
- package/dist/lib/type-generation/attribute.d.ts +17 -0
- package/dist/lib/type-generation/attribute.d.ts.map +1 -0
- package/dist/lib/type-generation/attribute.js +16 -0
- package/dist/lib/type-generation/attribute.js.map +1 -0
- package/dist/lib/type-generation/languages/csharp.d.ts +7 -0
- package/dist/lib/type-generation/languages/csharp.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/csharp.js +180 -0
- package/dist/lib/type-generation/languages/csharp.js.map +1 -0
- package/dist/lib/type-generation/languages/dart.d.ts +8 -0
- package/dist/lib/type-generation/languages/dart.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/dart.js +197 -0
- package/dist/lib/type-generation/languages/dart.js.map +1 -0
- package/dist/lib/type-generation/languages/java.d.ts +7 -0
- package/dist/lib/type-generation/languages/java.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/java.js +140 -0
- package/dist/lib/type-generation/languages/java.js.map +1 -0
- package/dist/lib/type-generation/languages/javascript.d.ts +9 -0
- package/dist/lib/type-generation/languages/javascript.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/javascript.js +109 -0
- package/dist/lib/type-generation/languages/javascript.js.map +1 -0
- package/dist/lib/type-generation/languages/kotlin.d.ts +7 -0
- package/dist/lib/type-generation/languages/kotlin.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/kotlin.js +95 -0
- package/dist/lib/type-generation/languages/kotlin.js.map +1 -0
- package/dist/lib/type-generation/languages/language.d.ts +43 -0
- package/dist/lib/type-generation/languages/language.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/language.js +77 -0
- package/dist/lib/type-generation/languages/language.js.map +1 -0
- package/dist/lib/type-generation/languages/php.d.ts +7 -0
- package/dist/lib/type-generation/languages/php.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/php.js +116 -0
- package/dist/lib/type-generation/languages/php.js.map +1 -0
- package/dist/lib/type-generation/languages/swift.d.ts +7 -0
- package/dist/lib/type-generation/languages/swift.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/swift.js +179 -0
- package/dist/lib/type-generation/languages/swift.js.map +1 -0
- package/dist/lib/type-generation/languages/typescript.d.ts +9 -0
- package/dist/lib/type-generation/languages/typescript.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/typescript.js +115 -0
- package/dist/lib/type-generation/languages/typescript.js.map +1 -0
- package/dist/lib/types.d.ts +63 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utils.d.ts +18 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +323 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/validations.d.ts +2 -0
- package/dist/lib/validations.d.ts.map +1 -0
- package/dist/lib/validations.js +16 -0
- package/dist/lib/validations.js.map +1 -0
- package/dist/package.json +68 -0
- package/dist/scripts/generate-commands.d.ts +2 -0
- package/dist/scripts/generate-commands.d.ts.map +1 -0
- package/dist/scripts/generate-commands.js +398 -0
- package/dist/scripts/generate-commands.js.map +1 -0
- package/dist/sites/profile-website/src/lib/utils.d.ts +4 -0
- package/dist/sites/profile-website/src/lib/utils.d.ts.map +1 -0
- package/dist/sites/profile-website/src/lib/utils.js +32 -0
- package/dist/sites/profile-website/src/lib/utils.js.map +1 -0
- package/dist/sites/profile-website/tailwind.config.d.ts +3 -0
- package/dist/sites/profile-website/tailwind.config.d.ts.map +1 -0
- package/dist/sites/profile-website/tailwind.config.js +110 -0
- package/dist/sites/profile-website/tailwind.config.js.map +1 -0
- package/dist/test.d.ts +2 -0
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +38 -0
- package/dist/test.js.map +1 -0
- package/index.ts +190 -0
- package/install.ps1 +5 -8
- package/install.sh +4 -5
- package/lib/client.ts +292 -0
- package/lib/commands/config.ts +493 -0
- package/lib/commands/db.ts +324 -0
- package/lib/commands/errors.ts +93 -0
- package/lib/commands/generic.ts +440 -0
- package/lib/commands/init.ts +713 -0
- package/lib/commands/pull.ts +944 -0
- package/lib/commands/push.ts +2355 -0
- package/lib/commands/run.ts +416 -0
- package/lib/commands/schema.ts +103 -0
- package/lib/commands/services/account.ts +832 -0
- package/lib/commands/services/avatars.ts +400 -0
- package/lib/commands/services/console.ts +73 -0
- package/lib/commands/services/databases.ts +2080 -0
- package/lib/commands/services/functions.ts +855 -0
- package/lib/commands/services/graphql.ts +47 -0
- package/lib/commands/services/health.ts +322 -0
- package/lib/commands/services/locale.ts +99 -0
- package/lib/commands/services/messaging.ts +1871 -0
- package/lib/commands/services/migrations.ts +421 -0
- package/lib/commands/services/project.ts +116 -0
- package/lib/commands/services/projects.ts +1317 -0
- package/lib/commands/services/proxy.ts +163 -0
- package/lib/commands/services/sites.ts +777 -0
- package/lib/commands/services/storage.ts +547 -0
- package/lib/commands/services/tablesdb.ts +1928 -0
- package/lib/commands/services/teams.ts +294 -0
- package/lib/commands/services/tokens.ts +106 -0
- package/lib/commands/services/users.ts +886 -0
- package/lib/commands/services/vcs.ts +268 -0
- package/lib/commands/types.ts +220 -0
- package/lib/commands/update.ts +245 -0
- package/lib/commands/utils/attributes.ts +734 -0
- package/lib/commands/utils/change-approval.ts +186 -0
- package/lib/commands/utils/database-sync.ts +180 -0
- package/lib/commands/utils/deployment.ts +180 -0
- package/lib/commands/utils/error-formatter.ts +417 -0
- package/lib/commands/utils/pools.ts +354 -0
- package/lib/config.ts +932 -0
- package/lib/emulation/docker.ts +312 -0
- package/lib/emulation/utils.ts +207 -0
- package/lib/id.ts +30 -0
- package/lib/paginate.ts +77 -0
- package/lib/parser.ts +264 -0
- package/lib/questions.ts +1167 -0
- package/lib/sdks.ts +84 -0
- package/lib/services.ts +72 -0
- package/lib/spinner.ts +131 -0
- package/lib/type-generation/attribute.ts +18 -0
- package/lib/type-generation/languages/csharp.ts +192 -0
- package/lib/type-generation/languages/dart.ts +217 -0
- package/lib/type-generation/languages/java.ts +152 -0
- package/lib/type-generation/languages/javascript.ts +122 -0
- package/lib/type-generation/languages/kotlin.ts +107 -0
- package/lib/type-generation/languages/language.ts +127 -0
- package/lib/type-generation/languages/php.ts +128 -0
- package/lib/type-generation/languages/swift.ts +191 -0
- package/lib/type-generation/languages/typescript.ts +133 -0
- package/lib/types.ts +75 -0
- package/lib/utils.ts +394 -0
- package/lib/validations.ts +20 -0
- package/package.json +39 -21
- package/scoop/appwrite.config.json +20 -0
- package/scripts/generate-commands.ts +539 -0
- package/tsconfig.json +24 -0
- package/appwrite.json +0 -164
- package/docs/examples/account/create-anonymous-session.md +0 -1
- package/docs/examples/account/create-email-password-session.md +0 -3
- package/docs/examples/account/create-email-token.md +0 -4
- package/docs/examples/account/create-j-w-t.md +0 -1
- package/docs/examples/account/create-magic-u-r-l-token.md +0 -5
- package/docs/examples/account/create-mfa-authenticator.md +0 -2
- package/docs/examples/account/create-mfa-challenge.md +0 -2
- package/docs/examples/account/create-mfa-recovery-codes.md +0 -1
- package/docs/examples/account/create-o-auth2session.md +0 -5
- package/docs/examples/account/create-o-auth2token.md +0 -5
- package/docs/examples/account/create-phone-token.md +0 -3
- package/docs/examples/account/create-phone-verification.md +0 -1
- package/docs/examples/account/create-push-target.md +0 -4
- package/docs/examples/account/create-recovery.md +0 -3
- package/docs/examples/account/create-session.md +0 -3
- package/docs/examples/account/create-verification.md +0 -2
- package/docs/examples/account/create.md +0 -5
- package/docs/examples/account/delete-identity.md +0 -2
- package/docs/examples/account/delete-mfa-authenticator.md +0 -2
- package/docs/examples/account/delete-push-target.md +0 -2
- package/docs/examples/account/delete-session.md +0 -2
- package/docs/examples/account/delete-sessions.md +0 -1
- package/docs/examples/account/delete.md +0 -1
- package/docs/examples/account/get-mfa-recovery-codes.md +0 -1
- package/docs/examples/account/get-prefs.md +0 -1
- package/docs/examples/account/get-session.md +0 -2
- package/docs/examples/account/get.md +0 -1
- package/docs/examples/account/list-identities.md +0 -2
- package/docs/examples/account/list-logs.md +0 -2
- package/docs/examples/account/list-mfa-factors.md +0 -1
- package/docs/examples/account/list-sessions.md +0 -1
- package/docs/examples/account/update-email.md +0 -3
- package/docs/examples/account/update-m-f-a.md +0 -2
- package/docs/examples/account/update-magic-u-r-l-session.md +0 -3
- package/docs/examples/account/update-mfa-authenticator.md +0 -3
- package/docs/examples/account/update-mfa-challenge.md +0 -3
- package/docs/examples/account/update-mfa-recovery-codes.md +0 -1
- package/docs/examples/account/update-name.md +0 -2
- package/docs/examples/account/update-password.md +0 -3
- package/docs/examples/account/update-phone-session.md +0 -3
- package/docs/examples/account/update-phone-verification.md +0 -3
- package/docs/examples/account/update-phone.md +0 -3
- package/docs/examples/account/update-prefs.md +0 -2
- package/docs/examples/account/update-push-target.md +0 -3
- package/docs/examples/account/update-recovery.md +0 -4
- package/docs/examples/account/update-session.md +0 -2
- package/docs/examples/account/update-status.md +0 -1
- package/docs/examples/account/update-verification.md +0 -3
- package/docs/examples/avatars/get-browser.md +0 -5
- package/docs/examples/avatars/get-credit-card.md +0 -5
- package/docs/examples/avatars/get-favicon.md +0 -2
- package/docs/examples/avatars/get-flag.md +0 -5
- package/docs/examples/avatars/get-image.md +0 -4
- package/docs/examples/avatars/get-initials.md +0 -5
- package/docs/examples/avatars/get-q-r.md +0 -5
- package/docs/examples/console/get-resource.md +0 -3
- package/docs/examples/console/variables.md +0 -1
- package/docs/examples/databases/create-boolean-attribute.md +0 -7
- package/docs/examples/databases/create-collection.md +0 -7
- package/docs/examples/databases/create-datetime-attribute.md +0 -7
- package/docs/examples/databases/create-document.md +0 -6
- package/docs/examples/databases/create-documents.md +0 -4
- package/docs/examples/databases/create-email-attribute.md +0 -7
- package/docs/examples/databases/create-enum-attribute.md +0 -8
- package/docs/examples/databases/create-float-attribute.md +0 -9
- package/docs/examples/databases/create-index.md +0 -8
- package/docs/examples/databases/create-integer-attribute.md +0 -9
- package/docs/examples/databases/create-ip-attribute.md +0 -7
- package/docs/examples/databases/create-relationship-attribute.md +0 -9
- package/docs/examples/databases/create-string-attribute.md +0 -9
- package/docs/examples/databases/create-url-attribute.md +0 -7
- package/docs/examples/databases/create.md +0 -4
- package/docs/examples/databases/decrement-document-attribute.md +0 -7
- package/docs/examples/databases/delete-attribute.md +0 -4
- package/docs/examples/databases/delete-collection.md +0 -3
- package/docs/examples/databases/delete-document.md +0 -4
- package/docs/examples/databases/delete-documents.md +0 -4
- package/docs/examples/databases/delete-index.md +0 -4
- package/docs/examples/databases/delete.md +0 -2
- package/docs/examples/databases/get-attribute.md +0 -4
- package/docs/examples/databases/get-collection-usage.md +0 -4
- package/docs/examples/databases/get-collection.md +0 -3
- package/docs/examples/databases/get-database-usage.md +0 -3
- package/docs/examples/databases/get-document.md +0 -5
- package/docs/examples/databases/get-index.md +0 -4
- package/docs/examples/databases/get-usage.md +0 -2
- package/docs/examples/databases/get.md +0 -2
- package/docs/examples/databases/increment-document-attribute.md +0 -7
- package/docs/examples/databases/list-attributes.md +0 -4
- package/docs/examples/databases/list-collection-logs.md +0 -4
- package/docs/examples/databases/list-collections.md +0 -4
- package/docs/examples/databases/list-document-logs.md +0 -5
- package/docs/examples/databases/list-documents.md +0 -4
- package/docs/examples/databases/list-indexes.md +0 -4
- package/docs/examples/databases/list-logs.md +0 -3
- package/docs/examples/databases/list.md +0 -3
- package/docs/examples/databases/update-boolean-attribute.md +0 -7
- package/docs/examples/databases/update-collection.md +0 -7
- package/docs/examples/databases/update-datetime-attribute.md +0 -7
- package/docs/examples/databases/update-document.md +0 -6
- package/docs/examples/databases/update-documents.md +0 -5
- package/docs/examples/databases/update-email-attribute.md +0 -7
- package/docs/examples/databases/update-enum-attribute.md +0 -8
- package/docs/examples/databases/update-float-attribute.md +0 -9
- package/docs/examples/databases/update-integer-attribute.md +0 -9
- package/docs/examples/databases/update-ip-attribute.md +0 -7
- package/docs/examples/databases/update-relationship-attribute.md +0 -6
- package/docs/examples/databases/update-string-attribute.md +0 -8
- package/docs/examples/databases/update-url-attribute.md +0 -7
- package/docs/examples/databases/update.md +0 -4
- package/docs/examples/databases/upsert-document.md +0 -6
- package/docs/examples/databases/upsert-documents.md +0 -4
- package/docs/examples/functions/create-deployment.md +0 -6
- package/docs/examples/functions/create-duplicate-deployment.md +0 -4
- package/docs/examples/functions/create-execution.md +0 -8
- package/docs/examples/functions/create-template-deployment.md +0 -7
- package/docs/examples/functions/create-variable.md +0 -5
- package/docs/examples/functions/create-vcs-deployment.md +0 -5
- package/docs/examples/functions/create.md +0 -19
- package/docs/examples/functions/delete-deployment.md +0 -3
- package/docs/examples/functions/delete-execution.md +0 -3
- package/docs/examples/functions/delete-variable.md +0 -3
- package/docs/examples/functions/delete.md +0 -2
- package/docs/examples/functions/get-deployment-download.md +0 -4
- package/docs/examples/functions/get-deployment.md +0 -3
- package/docs/examples/functions/get-execution.md +0 -3
- package/docs/examples/functions/get-template.md +0 -2
- package/docs/examples/functions/get-usage.md +0 -3
- package/docs/examples/functions/get-variable.md +0 -3
- package/docs/examples/functions/get.md +0 -2
- package/docs/examples/functions/list-deployments.md +0 -4
- package/docs/examples/functions/list-executions.md +0 -3
- package/docs/examples/functions/list-runtimes.md +0 -1
- package/docs/examples/functions/list-specifications.md +0 -1
- package/docs/examples/functions/list-templates.md +0 -5
- package/docs/examples/functions/list-usage.md +0 -2
- package/docs/examples/functions/list-variables.md +0 -2
- package/docs/examples/functions/list.md +0 -3
- package/docs/examples/functions/update-deployment-status.md +0 -3
- package/docs/examples/functions/update-function-deployment.md +0 -3
- package/docs/examples/functions/update-variable.md +0 -6
- package/docs/examples/functions/update.md +0 -19
- package/docs/examples/graphql/mutation.md +0 -2
- package/docs/examples/graphql/query.md +0 -2
- package/docs/examples/health/get-antivirus.md +0 -1
- package/docs/examples/health/get-cache.md +0 -1
- package/docs/examples/health/get-certificate.md +0 -2
- package/docs/examples/health/get-d-b.md +0 -1
- package/docs/examples/health/get-failed-jobs.md +0 -3
- package/docs/examples/health/get-pub-sub.md +0 -1
- package/docs/examples/health/get-queue-builds.md +0 -2
- package/docs/examples/health/get-queue-certificates.md +0 -2
- package/docs/examples/health/get-queue-databases.md +0 -3
- package/docs/examples/health/get-queue-deletes.md +0 -2
- package/docs/examples/health/get-queue-functions.md +0 -2
- package/docs/examples/health/get-queue-logs.md +0 -2
- package/docs/examples/health/get-queue-mails.md +0 -2
- package/docs/examples/health/get-queue-messaging.md +0 -2
- package/docs/examples/health/get-queue-migrations.md +0 -2
- package/docs/examples/health/get-queue-stats-resources.md +0 -2
- package/docs/examples/health/get-queue-usage.md +0 -2
- package/docs/examples/health/get-queue-webhooks.md +0 -2
- package/docs/examples/health/get-storage-local.md +0 -1
- package/docs/examples/health/get-storage.md +0 -1
- package/docs/examples/health/get-time.md +0 -1
- package/docs/examples/health/get.md +0 -1
- package/docs/examples/locale/get.md +0 -1
- package/docs/examples/locale/list-codes.md +0 -1
- package/docs/examples/locale/list-continents.md +0 -1
- package/docs/examples/locale/list-countries-e-u.md +0 -1
- package/docs/examples/locale/list-countries-phones.md +0 -1
- package/docs/examples/locale/list-countries.md +0 -1
- package/docs/examples/locale/list-currencies.md +0 -1
- package/docs/examples/locale/list-languages.md +0 -1
- package/docs/examples/messaging/create-apns-provider.md +0 -9
- package/docs/examples/messaging/create-email.md +0 -13
- package/docs/examples/messaging/create-fcm-provider.md +0 -5
- package/docs/examples/messaging/create-mailgun-provider.md +0 -11
- package/docs/examples/messaging/create-msg91provider.md +0 -7
- package/docs/examples/messaging/create-push.md +0 -20
- package/docs/examples/messaging/create-sendgrid-provider.md +0 -9
- package/docs/examples/messaging/create-sms.md +0 -8
- package/docs/examples/messaging/create-smtp-provider.md +0 -15
- package/docs/examples/messaging/create-subscriber.md +0 -4
- package/docs/examples/messaging/create-telesign-provider.md +0 -7
- package/docs/examples/messaging/create-textmagic-provider.md +0 -7
- package/docs/examples/messaging/create-topic.md +0 -4
- package/docs/examples/messaging/create-twilio-provider.md +0 -7
- package/docs/examples/messaging/create-vonage-provider.md +0 -7
- package/docs/examples/messaging/delete-provider.md +0 -2
- package/docs/examples/messaging/delete-subscriber.md +0 -3
- package/docs/examples/messaging/delete-topic.md +0 -2
- package/docs/examples/messaging/delete.md +0 -2
- package/docs/examples/messaging/get-message.md +0 -2
- package/docs/examples/messaging/get-provider.md +0 -2
- package/docs/examples/messaging/get-subscriber.md +0 -3
- package/docs/examples/messaging/get-topic.md +0 -2
- package/docs/examples/messaging/list-message-logs.md +0 -3
- package/docs/examples/messaging/list-messages.md +0 -3
- package/docs/examples/messaging/list-provider-logs.md +0 -3
- package/docs/examples/messaging/list-providers.md +0 -3
- package/docs/examples/messaging/list-subscriber-logs.md +0 -3
- package/docs/examples/messaging/list-subscribers.md +0 -4
- package/docs/examples/messaging/list-targets.md +0 -3
- package/docs/examples/messaging/list-topic-logs.md +0 -3
- package/docs/examples/messaging/list-topics.md +0 -3
- package/docs/examples/messaging/update-apns-provider.md +0 -9
- package/docs/examples/messaging/update-email.md +0 -13
- package/docs/examples/messaging/update-fcm-provider.md +0 -5
- package/docs/examples/messaging/update-mailgun-provider.md +0 -11
- package/docs/examples/messaging/update-msg91provider.md +0 -7
- package/docs/examples/messaging/update-push.md +0 -20
- package/docs/examples/messaging/update-sendgrid-provider.md +0 -9
- package/docs/examples/messaging/update-sms.md +0 -8
- package/docs/examples/messaging/update-smtp-provider.md +0 -15
- package/docs/examples/messaging/update-telesign-provider.md +0 -7
- package/docs/examples/messaging/update-textmagic-provider.md +0 -7
- package/docs/examples/messaging/update-topic.md +0 -4
- package/docs/examples/messaging/update-twilio-provider.md +0 -7
- package/docs/examples/messaging/update-vonage-provider.md +0 -7
- package/docs/examples/migrations/create-appwrite-migration.md +0 -5
- package/docs/examples/migrations/create-csv-migration.md +0 -4
- package/docs/examples/migrations/create-firebase-migration.md +0 -3
- package/docs/examples/migrations/create-n-host-migration.md +0 -9
- package/docs/examples/migrations/create-supabase-migration.md +0 -8
- package/docs/examples/migrations/delete.md +0 -2
- package/docs/examples/migrations/get-appwrite-report.md +0 -5
- package/docs/examples/migrations/get-firebase-report.md +0 -3
- package/docs/examples/migrations/get-n-host-report.md +0 -9
- package/docs/examples/migrations/get-supabase-report.md +0 -8
- package/docs/examples/migrations/get.md +0 -2
- package/docs/examples/migrations/list.md +0 -3
- package/docs/examples/migrations/retry.md +0 -2
- package/docs/examples/project/create-variable.md +0 -4
- package/docs/examples/project/delete-variable.md +0 -2
- package/docs/examples/project/get-usage.md +0 -4
- package/docs/examples/project/get-variable.md +0 -2
- package/docs/examples/project/list-variables.md +0 -1
- package/docs/examples/project/update-variable.md +0 -5
- package/docs/examples/projects/create-dev-key.md +0 -4
- package/docs/examples/projects/create-j-w-t.md +0 -4
- package/docs/examples/projects/create-key.md +0 -5
- package/docs/examples/projects/create-platform.md +0 -7
- package/docs/examples/projects/create-smtp-test.md +0 -11
- package/docs/examples/projects/create-webhook.md +0 -9
- package/docs/examples/projects/create.md +0 -14
- package/docs/examples/projects/delete-dev-key.md +0 -3
- package/docs/examples/projects/delete-email-template.md +0 -4
- package/docs/examples/projects/delete-key.md +0 -3
- package/docs/examples/projects/delete-platform.md +0 -3
- package/docs/examples/projects/delete-sms-template.md +0 -4
- package/docs/examples/projects/delete-webhook.md +0 -3
- package/docs/examples/projects/delete.md +0 -2
- package/docs/examples/projects/get-dev-key.md +0 -3
- package/docs/examples/projects/get-email-template.md +0 -4
- package/docs/examples/projects/get-key.md +0 -3
- package/docs/examples/projects/get-platform.md +0 -3
- package/docs/examples/projects/get-sms-template.md +0 -4
- package/docs/examples/projects/get-webhook.md +0 -3
- package/docs/examples/projects/get.md +0 -2
- package/docs/examples/projects/list-dev-keys.md +0 -3
- package/docs/examples/projects/list-keys.md +0 -2
- package/docs/examples/projects/list-platforms.md +0 -2
- package/docs/examples/projects/list-webhooks.md +0 -2
- package/docs/examples/projects/list.md +0 -3
- package/docs/examples/projects/update-api-status-all.md +0 -3
- package/docs/examples/projects/update-api-status.md +0 -4
- package/docs/examples/projects/update-auth-duration.md +0 -3
- package/docs/examples/projects/update-auth-limit.md +0 -3
- package/docs/examples/projects/update-auth-password-dictionary.md +0 -3
- package/docs/examples/projects/update-auth-password-history.md +0 -3
- package/docs/examples/projects/update-auth-sessions-limit.md +0 -3
- package/docs/examples/projects/update-auth-status.md +0 -4
- package/docs/examples/projects/update-dev-key.md +0 -5
- package/docs/examples/projects/update-email-template.md +0 -9
- package/docs/examples/projects/update-key.md +0 -6
- package/docs/examples/projects/update-memberships-privacy.md +0 -5
- package/docs/examples/projects/update-mock-numbers.md +0 -3
- package/docs/examples/projects/update-o-auth2.md +0 -6
- package/docs/examples/projects/update-personal-data-check.md +0 -3
- package/docs/examples/projects/update-platform.md +0 -7
- package/docs/examples/projects/update-service-status-all.md +0 -3
- package/docs/examples/projects/update-service-status.md +0 -4
- package/docs/examples/projects/update-session-alerts.md +0 -3
- package/docs/examples/projects/update-sms-template.md +0 -5
- package/docs/examples/projects/update-smtp.md +0 -11
- package/docs/examples/projects/update-team.md +0 -3
- package/docs/examples/projects/update-webhook-signature.md +0 -3
- package/docs/examples/projects/update-webhook.md +0 -10
- package/docs/examples/projects/update.md +0 -12
- package/docs/examples/proxy/create-a-p-i-rule.md +0 -2
- package/docs/examples/proxy/create-function-rule.md +0 -4
- package/docs/examples/proxy/create-redirect-rule.md +0 -6
- package/docs/examples/proxy/create-site-rule.md +0 -4
- package/docs/examples/proxy/delete-rule.md +0 -2
- package/docs/examples/proxy/get-rule.md +0 -2
- package/docs/examples/proxy/list-rules.md +0 -3
- package/docs/examples/proxy/update-rule-verification.md +0 -2
- package/docs/examples/sites/create-deployment.md +0 -7
- package/docs/examples/sites/create-duplicate-deployment.md +0 -3
- package/docs/examples/sites/create-template-deployment.md +0 -7
- package/docs/examples/sites/create-variable.md +0 -5
- package/docs/examples/sites/create-vcs-deployment.md +0 -5
- package/docs/examples/sites/create.md +0 -19
- package/docs/examples/sites/delete-deployment.md +0 -3
- package/docs/examples/sites/delete-log.md +0 -3
- package/docs/examples/sites/delete-variable.md +0 -3
- package/docs/examples/sites/delete.md +0 -2
- package/docs/examples/sites/get-deployment-download.md +0 -4
- package/docs/examples/sites/get-deployment.md +0 -3
- package/docs/examples/sites/get-log.md +0 -3
- package/docs/examples/sites/get-template.md +0 -2
- package/docs/examples/sites/get-usage.md +0 -3
- package/docs/examples/sites/get-variable.md +0 -3
- package/docs/examples/sites/get.md +0 -2
- package/docs/examples/sites/list-deployments.md +0 -4
- package/docs/examples/sites/list-frameworks.md +0 -1
- package/docs/examples/sites/list-logs.md +0 -3
- package/docs/examples/sites/list-specifications.md +0 -1
- package/docs/examples/sites/list-templates.md +0 -5
- package/docs/examples/sites/list-usage.md +0 -2
- package/docs/examples/sites/list-variables.md +0 -2
- package/docs/examples/sites/list.md +0 -3
- package/docs/examples/sites/update-deployment-status.md +0 -3
- package/docs/examples/sites/update-site-deployment.md +0 -3
- package/docs/examples/sites/update-variable.md +0 -6
- package/docs/examples/sites/update.md +0 -19
- package/docs/examples/storage/create-bucket.md +0 -11
- package/docs/examples/storage/create-file.md +0 -5
- package/docs/examples/storage/delete-bucket.md +0 -2
- package/docs/examples/storage/delete-file.md +0 -3
- package/docs/examples/storage/get-bucket-usage.md +0 -3
- package/docs/examples/storage/get-bucket.md +0 -2
- package/docs/examples/storage/get-file-download.md +0 -4
- package/docs/examples/storage/get-file-preview.md +0 -15
- package/docs/examples/storage/get-file-view.md +0 -4
- package/docs/examples/storage/get-file.md +0 -3
- package/docs/examples/storage/get-usage.md +0 -2
- package/docs/examples/storage/list-buckets.md +0 -3
- package/docs/examples/storage/list-files.md +0 -4
- package/docs/examples/storage/update-bucket.md +0 -11
- package/docs/examples/storage/update-file.md +0 -5
- package/docs/examples/teams/create-membership.md +0 -8
- package/docs/examples/teams/create.md +0 -4
- package/docs/examples/teams/delete-membership.md +0 -3
- package/docs/examples/teams/delete.md +0 -2
- package/docs/examples/teams/get-membership.md +0 -3
- package/docs/examples/teams/get-prefs.md +0 -2
- package/docs/examples/teams/get.md +0 -2
- package/docs/examples/teams/list-logs.md +0 -3
- package/docs/examples/teams/list-memberships.md +0 -4
- package/docs/examples/teams/list.md +0 -3
- package/docs/examples/teams/update-membership-status.md +0 -5
- package/docs/examples/teams/update-membership.md +0 -4
- package/docs/examples/teams/update-name.md +0 -3
- package/docs/examples/teams/update-prefs.md +0 -3
- package/docs/examples/tokens/create-file-token.md +0 -4
- package/docs/examples/tokens/delete.md +0 -2
- package/docs/examples/tokens/get.md +0 -2
- package/docs/examples/tokens/list.md +0 -4
- package/docs/examples/tokens/update.md +0 -3
- package/docs/examples/users/create-argon2user.md +0 -5
- package/docs/examples/users/create-bcrypt-user.md +0 -5
- package/docs/examples/users/create-j-w-t.md +0 -4
- package/docs/examples/users/create-m-d5user.md +0 -5
- package/docs/examples/users/create-mfa-recovery-codes.md +0 -2
- package/docs/examples/users/create-p-h-pass-user.md +0 -5
- package/docs/examples/users/create-s-h-a-user.md +0 -6
- package/docs/examples/users/create-scrypt-modified-user.md +0 -8
- package/docs/examples/users/create-scrypt-user.md +0 -10
- package/docs/examples/users/create-session.md +0 -2
- package/docs/examples/users/create-target.md +0 -7
- package/docs/examples/users/create-token.md +0 -4
- package/docs/examples/users/create.md +0 -6
- package/docs/examples/users/delete-identity.md +0 -2
- package/docs/examples/users/delete-mfa-authenticator.md +0 -3
- package/docs/examples/users/delete-session.md +0 -3
- package/docs/examples/users/delete-sessions.md +0 -2
- package/docs/examples/users/delete-target.md +0 -3
- package/docs/examples/users/delete.md +0 -2
- package/docs/examples/users/get-mfa-recovery-codes.md +0 -2
- package/docs/examples/users/get-prefs.md +0 -2
- package/docs/examples/users/get-target.md +0 -3
- package/docs/examples/users/get-usage.md +0 -2
- package/docs/examples/users/get.md +0 -2
- package/docs/examples/users/list-identities.md +0 -3
- package/docs/examples/users/list-logs.md +0 -3
- package/docs/examples/users/list-memberships.md +0 -4
- package/docs/examples/users/list-mfa-factors.md +0 -2
- package/docs/examples/users/list-sessions.md +0 -2
- package/docs/examples/users/list-targets.md +0 -3
- package/docs/examples/users/list.md +0 -3
- package/docs/examples/users/update-email-verification.md +0 -3
- package/docs/examples/users/update-email.md +0 -3
- package/docs/examples/users/update-labels.md +0 -3
- package/docs/examples/users/update-mfa-recovery-codes.md +0 -2
- package/docs/examples/users/update-mfa.md +0 -3
- package/docs/examples/users/update-name.md +0 -3
- package/docs/examples/users/update-password.md +0 -3
- package/docs/examples/users/update-phone-verification.md +0 -3
- package/docs/examples/users/update-phone.md +0 -3
- package/docs/examples/users/update-prefs.md +0 -3
- package/docs/examples/users/update-status.md +0 -3
- package/docs/examples/users/update-target.md +0 -6
- package/docs/examples/vcs/create-repository-detection.md +0 -5
- package/docs/examples/vcs/create-repository.md +0 -4
- package/docs/examples/vcs/delete-installation.md +0 -2
- package/docs/examples/vcs/get-installation.md +0 -2
- package/docs/examples/vcs/get-repository-contents.md +0 -5
- package/docs/examples/vcs/get-repository.md +0 -3
- package/docs/examples/vcs/list-installations.md +0 -3
- package/docs/examples/vcs/list-repositories.md +0 -4
- package/docs/examples/vcs/list-repository-branches.md +0 -3
- package/docs/examples/vcs/update-external-deployments.md +0 -4
- package/functions/Starter function/.prettierrc.json +0 -6
- package/functions/Starter function/README.md +0 -48
- package/functions/Starter function/package-lock.json +0 -60
- package/functions/Starter function/package.json +0 -16
- package/functions/Starter function/src/main.js +0 -35
- package/generate/appwrite.d.ts +0 -18
- package/index.js +0 -109
- package/lib/client.js +0 -259
- package/lib/commands/account.js +0 -2074
- package/lib/commands/avatars.js +0 -491
- package/lib/commands/console.js +0 -129
- package/lib/commands/databases.js +0 -2972
- package/lib/commands/functions.js +0 -1737
- package/lib/commands/generic.js +0 -328
- package/lib/commands/graphql.js +0 -128
- package/lib/commands/health.js +0 -891
- package/lib/commands/init.js +0 -566
- package/lib/commands/locale.js +0 -324
- package/lib/commands/messaging.js +0 -2970
- package/lib/commands/migrations.js +0 -751
- package/lib/commands/organizations.js +0 -48
- package/lib/commands/project.js +0 -308
- package/lib/commands/projects.js +0 -2615
- package/lib/commands/proxy.js +0 -406
- package/lib/commands/pull.js +0 -474
- package/lib/commands/push.js +0 -2117
- package/lib/commands/run.js +0 -330
- package/lib/commands/sites.js +0 -1663
- package/lib/commands/storage.js +0 -990
- package/lib/commands/teams.js +0 -682
- package/lib/commands/tokens.js +0 -261
- package/lib/commands/types.js +0 -156
- package/lib/commands/users.js +0 -2035
- package/lib/commands/vcs.js +0 -484
- package/lib/config.js +0 -705
- package/lib/emulation/docker.js +0 -264
- package/lib/emulation/utils.js +0 -186
- package/lib/exception.js +0 -9
- package/lib/id.js +0 -30
- package/lib/paginate.js +0 -52
- package/lib/parser.js +0 -246
- package/lib/questions.js +0 -1006
- package/lib/sdks.js +0 -60
- package/lib/spinner.js +0 -104
- package/lib/type-generation/attribute.js +0 -16
- package/lib/type-generation/languages/dart.js +0 -196
- package/lib/type-generation/languages/java.js +0 -130
- package/lib/type-generation/languages/javascript.js +0 -102
- package/lib/type-generation/languages/kotlin.js +0 -84
- package/lib/type-generation/languages/language.js +0 -125
- package/lib/type-generation/languages/php.js +0 -109
- package/lib/type-generation/languages/swift.js +0 -169
- package/lib/type-generation/languages/typescript.js +0 -102
- package/lib/utils.js +0 -289
- package/lib/validations.js +0 -17
- package/scoop/appwrite.json +0 -30
- package/sites/JavaScript starter/.env.example +0 -3
- package/sites/JavaScript starter/LICENSE +0 -21
- package/sites/JavaScript starter/images/appwrite.svg +0 -8
- package/sites/JavaScript starter/images/javascript.svg +0 -5
- package/sites/JavaScript starter/index.html +0 -250
- package/sites/JavaScript starter/lib/appwrite.js +0 -10
- package/sites/JavaScript starter/package-lock.json +0 -1431
- package/sites/JavaScript starter/package.json +0 -21
- package/sites/JavaScript starter/readme.md +0 -26
- package/sites/JavaScript starter/src/javascript.svg +0 -1
- package/sites/JavaScript starter/style/app.css +0 -20
- package/sites/JavaScript starter/vite.config.js +0 -7
|
@@ -0,0 +1,734 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { getDatabasesService } from "../../services.js";
|
|
3
|
+
import { KeysAttributes } from "../../config.js";
|
|
4
|
+
import { log, success, cliConfig, drawTable } from "../../parser.js";
|
|
5
|
+
import { Pools } from "./pools.js";
|
|
6
|
+
import inquirer from "inquirer";
|
|
7
|
+
|
|
8
|
+
const changeableKeys = [
|
|
9
|
+
"status",
|
|
10
|
+
"required",
|
|
11
|
+
"xdefault",
|
|
12
|
+
"elements",
|
|
13
|
+
"min",
|
|
14
|
+
"max",
|
|
15
|
+
"default",
|
|
16
|
+
"error",
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
export interface AttributeChange {
|
|
20
|
+
key: string;
|
|
21
|
+
attribute: any;
|
|
22
|
+
reason: string;
|
|
23
|
+
action: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface Collection {
|
|
27
|
+
$id: string;
|
|
28
|
+
databaseId: string;
|
|
29
|
+
name: string;
|
|
30
|
+
attributes?: any[];
|
|
31
|
+
indexes?: any[];
|
|
32
|
+
columns?: any[];
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const questionPushChanges = [
|
|
37
|
+
{
|
|
38
|
+
type: "input",
|
|
39
|
+
name: "changes",
|
|
40
|
+
message: 'Type "YES" to confirm or "NO" to cancel:',
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
const questionPushChangesConfirmation = [
|
|
45
|
+
{
|
|
46
|
+
type: "input",
|
|
47
|
+
name: "changes",
|
|
48
|
+
message:
|
|
49
|
+
'Incorrect answer. Please type "YES" to confirm or "NO" to cancel:',
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
export class Attributes {
|
|
54
|
+
private pools: Pools;
|
|
55
|
+
|
|
56
|
+
constructor(pools?: Pools) {
|
|
57
|
+
this.pools = pools || new Pools();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private getConfirmation = async (): Promise<boolean> => {
|
|
61
|
+
if (cliConfig.force) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function fixConfirmation(): Promise<string> {
|
|
66
|
+
const answers = await inquirer.prompt(questionPushChangesConfirmation);
|
|
67
|
+
if (answers.changes !== "YES" && answers.changes !== "NO") {
|
|
68
|
+
return await fixConfirmation();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return answers.changes;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
let answers = await inquirer.prompt(questionPushChanges);
|
|
75
|
+
|
|
76
|
+
if (answers.changes !== "YES" && answers.changes !== "NO") {
|
|
77
|
+
answers.changes = await fixConfirmation();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (answers.changes === "YES") {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return false;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
private isEmpty = (value: any): boolean =>
|
|
88
|
+
value === null ||
|
|
89
|
+
value === undefined ||
|
|
90
|
+
(typeof value === "string" && value.trim().length === 0) ||
|
|
91
|
+
(Array.isArray(value) && value.length === 0);
|
|
92
|
+
|
|
93
|
+
private isEqual = (a: any, b: any): boolean => {
|
|
94
|
+
if (a === b) return true;
|
|
95
|
+
|
|
96
|
+
if (a && b && typeof a === "object" && typeof b === "object") {
|
|
97
|
+
if (
|
|
98
|
+
a.constructor &&
|
|
99
|
+
a.constructor.name === "BigNumber" &&
|
|
100
|
+
b.constructor &&
|
|
101
|
+
b.constructor.name === "BigNumber"
|
|
102
|
+
) {
|
|
103
|
+
return a.eq(b);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (typeof a.equals === "function") {
|
|
107
|
+
return a.equals(b);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (typeof a.eq === "function") {
|
|
111
|
+
return a.eq(b);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (typeof a === "number" && typeof b === "number") {
|
|
116
|
+
if (isNaN(a) && isNaN(b)) return true;
|
|
117
|
+
if (!isFinite(a) && !isFinite(b)) return a === b;
|
|
118
|
+
return Math.abs(a - b) < Number.EPSILON;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return false;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
private compareAttribute = (
|
|
125
|
+
remote: any,
|
|
126
|
+
local: any,
|
|
127
|
+
reason: string,
|
|
128
|
+
key: string,
|
|
129
|
+
): string => {
|
|
130
|
+
if (this.isEmpty(remote) && this.isEmpty(local)) {
|
|
131
|
+
return reason;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (Array.isArray(remote) && Array.isArray(local)) {
|
|
135
|
+
if (JSON.stringify(remote) !== JSON.stringify(local)) {
|
|
136
|
+
const bol = reason === "" ? "" : "\n";
|
|
137
|
+
reason += `${bol}${key} changed from ${chalk.red(remote)} to ${chalk.green(local)}`;
|
|
138
|
+
}
|
|
139
|
+
} else if (!this.isEqual(remote, local)) {
|
|
140
|
+
const bol = reason === "" ? "" : "\n";
|
|
141
|
+
reason += `${bol}${key} changed from ${chalk.red(remote)} to ${chalk.green(local)}`;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return reason;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Check if attribute non-changeable fields has been changed
|
|
149
|
+
* If so return the differences as an object.
|
|
150
|
+
*/
|
|
151
|
+
private checkAttributeChanges = (
|
|
152
|
+
remote: any,
|
|
153
|
+
local: any,
|
|
154
|
+
collection: Collection,
|
|
155
|
+
recreating: boolean = true,
|
|
156
|
+
): AttributeChange | undefined => {
|
|
157
|
+
if (local === undefined) {
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const keyName = `${chalk.yellow(local.key)} in ${collection.name} (${collection["$id"]})`;
|
|
162
|
+
const action = chalk.cyan(recreating ? "recreating" : "changing");
|
|
163
|
+
let reason = "";
|
|
164
|
+
let attribute = recreating ? remote : local;
|
|
165
|
+
|
|
166
|
+
for (let key of Object.keys(remote)) {
|
|
167
|
+
if (!KeysAttributes.has(key)) {
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (changeableKeys.includes(key)) {
|
|
172
|
+
if (!recreating) {
|
|
173
|
+
reason = this.compareAttribute(remote[key], local[key], reason, key);
|
|
174
|
+
}
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (!recreating) {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
reason = this.compareAttribute(remote[key], local[key], reason, key);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return reason === ""
|
|
186
|
+
? undefined
|
|
187
|
+
: { key: keyName, attribute, reason, action };
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Check if attributes contain the given attribute
|
|
192
|
+
*/
|
|
193
|
+
private attributesContains = (attribute: any, attributes: any[]): any =>
|
|
194
|
+
attributes.find((attr) => attr.key === attribute.key);
|
|
195
|
+
|
|
196
|
+
private generateChangesObject = (
|
|
197
|
+
attribute: any,
|
|
198
|
+
collection: Collection,
|
|
199
|
+
isAdding: boolean,
|
|
200
|
+
): AttributeChange => {
|
|
201
|
+
return {
|
|
202
|
+
key: `${chalk.yellow(attribute.key)} in ${collection.name} (${collection["$id"]})`,
|
|
203
|
+
attribute: attribute,
|
|
204
|
+
reason: isAdding
|
|
205
|
+
? "Field isn't present on the remote server"
|
|
206
|
+
: "Field isn't present on the appwrite.config.json file",
|
|
207
|
+
action: isAdding ? chalk.green("adding") : chalk.red("deleting"),
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
public createAttribute = async (
|
|
212
|
+
databaseId: string,
|
|
213
|
+
collectionId: string,
|
|
214
|
+
attribute: any,
|
|
215
|
+
): Promise<any> => {
|
|
216
|
+
const databasesService = await getDatabasesService();
|
|
217
|
+
switch (attribute.type) {
|
|
218
|
+
case "string":
|
|
219
|
+
switch (attribute.format) {
|
|
220
|
+
case "email":
|
|
221
|
+
return databasesService.createEmailAttribute({
|
|
222
|
+
databaseId,
|
|
223
|
+
collectionId,
|
|
224
|
+
key: attribute.key,
|
|
225
|
+
required: attribute.required,
|
|
226
|
+
xdefault: attribute.default,
|
|
227
|
+
array: attribute.array,
|
|
228
|
+
});
|
|
229
|
+
case "url":
|
|
230
|
+
return databasesService.createUrlAttribute({
|
|
231
|
+
databaseId,
|
|
232
|
+
collectionId,
|
|
233
|
+
key: attribute.key,
|
|
234
|
+
required: attribute.required,
|
|
235
|
+
xdefault: attribute.default,
|
|
236
|
+
array: attribute.array,
|
|
237
|
+
});
|
|
238
|
+
case "ip":
|
|
239
|
+
return databasesService.createIpAttribute({
|
|
240
|
+
databaseId,
|
|
241
|
+
collectionId,
|
|
242
|
+
key: attribute.key,
|
|
243
|
+
required: attribute.required,
|
|
244
|
+
xdefault: attribute.default,
|
|
245
|
+
array: attribute.array,
|
|
246
|
+
});
|
|
247
|
+
case "enum":
|
|
248
|
+
return databasesService.createEnumAttribute({
|
|
249
|
+
databaseId,
|
|
250
|
+
collectionId,
|
|
251
|
+
key: attribute.key,
|
|
252
|
+
elements: attribute.elements,
|
|
253
|
+
required: attribute.required,
|
|
254
|
+
xdefault: attribute.default,
|
|
255
|
+
array: attribute.array,
|
|
256
|
+
});
|
|
257
|
+
default:
|
|
258
|
+
return databasesService.createStringAttribute({
|
|
259
|
+
databaseId,
|
|
260
|
+
collectionId,
|
|
261
|
+
key: attribute.key,
|
|
262
|
+
size: attribute.size,
|
|
263
|
+
required: attribute.required,
|
|
264
|
+
xdefault: attribute.default,
|
|
265
|
+
array: attribute.array,
|
|
266
|
+
encrypt: attribute.encrypt,
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
case "integer":
|
|
270
|
+
return databasesService.createIntegerAttribute({
|
|
271
|
+
databaseId,
|
|
272
|
+
collectionId,
|
|
273
|
+
key: attribute.key,
|
|
274
|
+
required: attribute.required,
|
|
275
|
+
min: attribute.min,
|
|
276
|
+
max: attribute.max,
|
|
277
|
+
xdefault: attribute.default,
|
|
278
|
+
array: attribute.array,
|
|
279
|
+
});
|
|
280
|
+
case "double":
|
|
281
|
+
return databasesService.createFloatAttribute({
|
|
282
|
+
databaseId,
|
|
283
|
+
collectionId,
|
|
284
|
+
key: attribute.key,
|
|
285
|
+
required: attribute.required,
|
|
286
|
+
min: attribute.min,
|
|
287
|
+
max: attribute.max,
|
|
288
|
+
xdefault: attribute.default,
|
|
289
|
+
array: attribute.array,
|
|
290
|
+
});
|
|
291
|
+
case "boolean":
|
|
292
|
+
return databasesService.createBooleanAttribute({
|
|
293
|
+
databaseId,
|
|
294
|
+
collectionId,
|
|
295
|
+
key: attribute.key,
|
|
296
|
+
required: attribute.required,
|
|
297
|
+
xdefault: attribute.default,
|
|
298
|
+
array: attribute.array,
|
|
299
|
+
});
|
|
300
|
+
case "datetime":
|
|
301
|
+
return databasesService.createDatetimeAttribute({
|
|
302
|
+
databaseId,
|
|
303
|
+
collectionId,
|
|
304
|
+
key: attribute.key,
|
|
305
|
+
required: attribute.required,
|
|
306
|
+
xdefault: attribute.default,
|
|
307
|
+
array: attribute.array,
|
|
308
|
+
});
|
|
309
|
+
case "relationship":
|
|
310
|
+
return databasesService.createRelationshipAttribute({
|
|
311
|
+
databaseId,
|
|
312
|
+
collectionId,
|
|
313
|
+
relatedCollectionId:
|
|
314
|
+
attribute.relatedTable ?? attribute.relatedCollection,
|
|
315
|
+
type: attribute.relationType,
|
|
316
|
+
twoWay: attribute.twoWay,
|
|
317
|
+
key: attribute.key,
|
|
318
|
+
twoWayKey: attribute.twoWayKey,
|
|
319
|
+
onDelete: attribute.onDelete,
|
|
320
|
+
});
|
|
321
|
+
case "point":
|
|
322
|
+
return databasesService.createPointAttribute({
|
|
323
|
+
databaseId,
|
|
324
|
+
collectionId,
|
|
325
|
+
key: attribute.key,
|
|
326
|
+
required: attribute.required,
|
|
327
|
+
xdefault: attribute.default,
|
|
328
|
+
});
|
|
329
|
+
case "linestring":
|
|
330
|
+
return databasesService.createLineAttribute({
|
|
331
|
+
databaseId,
|
|
332
|
+
collectionId,
|
|
333
|
+
key: attribute.key,
|
|
334
|
+
required: attribute.required,
|
|
335
|
+
xdefault: attribute.default,
|
|
336
|
+
});
|
|
337
|
+
case "polygon":
|
|
338
|
+
return databasesService.createPolygonAttribute({
|
|
339
|
+
databaseId,
|
|
340
|
+
collectionId,
|
|
341
|
+
key: attribute.key,
|
|
342
|
+
required: attribute.required,
|
|
343
|
+
xdefault: attribute.default,
|
|
344
|
+
});
|
|
345
|
+
default:
|
|
346
|
+
throw new Error(`Unsupported attribute type: ${attribute.type}`);
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
public updateAttribute = async (
|
|
351
|
+
databaseId: string,
|
|
352
|
+
collectionId: string,
|
|
353
|
+
attribute: any,
|
|
354
|
+
): Promise<any> => {
|
|
355
|
+
const databasesService = await getDatabasesService();
|
|
356
|
+
switch (attribute.type) {
|
|
357
|
+
case "string":
|
|
358
|
+
switch (attribute.format) {
|
|
359
|
+
case "email":
|
|
360
|
+
return databasesService.updateEmailAttribute({
|
|
361
|
+
databaseId,
|
|
362
|
+
collectionId,
|
|
363
|
+
key: attribute.key,
|
|
364
|
+
required: attribute.required,
|
|
365
|
+
xdefault: attribute.default,
|
|
366
|
+
});
|
|
367
|
+
case "url":
|
|
368
|
+
return databasesService.updateUrlAttribute({
|
|
369
|
+
databaseId,
|
|
370
|
+
collectionId,
|
|
371
|
+
key: attribute.key,
|
|
372
|
+
required: attribute.required,
|
|
373
|
+
xdefault: attribute.default,
|
|
374
|
+
});
|
|
375
|
+
case "ip":
|
|
376
|
+
return databasesService.updateIpAttribute({
|
|
377
|
+
databaseId,
|
|
378
|
+
collectionId,
|
|
379
|
+
key: attribute.key,
|
|
380
|
+
required: attribute.required,
|
|
381
|
+
xdefault: attribute.default,
|
|
382
|
+
});
|
|
383
|
+
case "enum":
|
|
384
|
+
return databasesService.updateEnumAttribute({
|
|
385
|
+
databaseId,
|
|
386
|
+
collectionId,
|
|
387
|
+
key: attribute.key,
|
|
388
|
+
elements: attribute.elements,
|
|
389
|
+
required: attribute.required,
|
|
390
|
+
xdefault: attribute.default,
|
|
391
|
+
});
|
|
392
|
+
default:
|
|
393
|
+
return databasesService.updateStringAttribute({
|
|
394
|
+
databaseId,
|
|
395
|
+
collectionId,
|
|
396
|
+
key: attribute.key,
|
|
397
|
+
required: attribute.required,
|
|
398
|
+
xdefault: attribute.default,
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
case "integer":
|
|
402
|
+
return databasesService.updateIntegerAttribute({
|
|
403
|
+
databaseId,
|
|
404
|
+
collectionId,
|
|
405
|
+
key: attribute.key,
|
|
406
|
+
required: attribute.required,
|
|
407
|
+
min: attribute.min,
|
|
408
|
+
max: attribute.max,
|
|
409
|
+
xdefault: attribute.default,
|
|
410
|
+
});
|
|
411
|
+
case "double":
|
|
412
|
+
return databasesService.updateFloatAttribute({
|
|
413
|
+
databaseId,
|
|
414
|
+
collectionId,
|
|
415
|
+
key: attribute.key,
|
|
416
|
+
required: attribute.required,
|
|
417
|
+
min: attribute.min,
|
|
418
|
+
max: attribute.max,
|
|
419
|
+
xdefault: attribute.default,
|
|
420
|
+
});
|
|
421
|
+
case "boolean":
|
|
422
|
+
return databasesService.updateBooleanAttribute({
|
|
423
|
+
databaseId,
|
|
424
|
+
collectionId,
|
|
425
|
+
key: attribute.key,
|
|
426
|
+
required: attribute.required,
|
|
427
|
+
xdefault: attribute.default,
|
|
428
|
+
});
|
|
429
|
+
case "datetime":
|
|
430
|
+
return databasesService.updateDatetimeAttribute({
|
|
431
|
+
databaseId,
|
|
432
|
+
collectionId,
|
|
433
|
+
key: attribute.key,
|
|
434
|
+
required: attribute.required,
|
|
435
|
+
xdefault: attribute.default,
|
|
436
|
+
});
|
|
437
|
+
case "relationship":
|
|
438
|
+
return databasesService.updateRelationshipAttribute({
|
|
439
|
+
databaseId,
|
|
440
|
+
collectionId,
|
|
441
|
+
key: attribute.key,
|
|
442
|
+
onDelete: attribute.onDelete,
|
|
443
|
+
});
|
|
444
|
+
case "point":
|
|
445
|
+
return databasesService.updatePointAttribute({
|
|
446
|
+
databaseId,
|
|
447
|
+
collectionId,
|
|
448
|
+
key: attribute.key,
|
|
449
|
+
required: attribute.required,
|
|
450
|
+
xdefault: attribute.default,
|
|
451
|
+
});
|
|
452
|
+
case "linestring":
|
|
453
|
+
return databasesService.updateLineAttribute({
|
|
454
|
+
databaseId,
|
|
455
|
+
collectionId,
|
|
456
|
+
key: attribute.key,
|
|
457
|
+
required: attribute.required,
|
|
458
|
+
xdefault: attribute.default,
|
|
459
|
+
});
|
|
460
|
+
case "polygon":
|
|
461
|
+
return databasesService.updatePolygonAttribute({
|
|
462
|
+
databaseId,
|
|
463
|
+
collectionId,
|
|
464
|
+
key: attribute.key,
|
|
465
|
+
required: attribute.required,
|
|
466
|
+
xdefault: attribute.default,
|
|
467
|
+
});
|
|
468
|
+
default:
|
|
469
|
+
throw new Error(`Unsupported attribute type: ${attribute.type}`);
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
public deleteAttribute = async (
|
|
474
|
+
collection: Collection,
|
|
475
|
+
attribute: any,
|
|
476
|
+
isIndex: boolean = false,
|
|
477
|
+
): Promise<void> => {
|
|
478
|
+
log(
|
|
479
|
+
`Deleting ${isIndex ? "index" : "attribute"} ${attribute.key} of ${collection.name} ( ${collection["$id"]} )`,
|
|
480
|
+
);
|
|
481
|
+
|
|
482
|
+
const databasesService = await getDatabasesService();
|
|
483
|
+
if (isIndex) {
|
|
484
|
+
await databasesService.deleteIndex(
|
|
485
|
+
collection["databaseId"],
|
|
486
|
+
collection["$id"],
|
|
487
|
+
attribute.key,
|
|
488
|
+
);
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
await databasesService.deleteAttribute(
|
|
493
|
+
collection["databaseId"],
|
|
494
|
+
collection["$id"],
|
|
495
|
+
attribute.key,
|
|
496
|
+
);
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Filter deleted and recreated attributes,
|
|
501
|
+
* return list of attributes to create
|
|
502
|
+
*/
|
|
503
|
+
public attributesToCreate = async (
|
|
504
|
+
remoteAttributes: any[],
|
|
505
|
+
localAttributes: any[],
|
|
506
|
+
collection: Collection,
|
|
507
|
+
isIndex: boolean = false,
|
|
508
|
+
): Promise<any[]> => {
|
|
509
|
+
const deleting = remoteAttributes
|
|
510
|
+
.filter(
|
|
511
|
+
(attribute) => !this.attributesContains(attribute, localAttributes),
|
|
512
|
+
)
|
|
513
|
+
.map((attr) => this.generateChangesObject(attr, collection, false));
|
|
514
|
+
const adding = localAttributes
|
|
515
|
+
.filter(
|
|
516
|
+
(attribute) => !this.attributesContains(attribute, remoteAttributes),
|
|
517
|
+
)
|
|
518
|
+
.map((attr) => this.generateChangesObject(attr, collection, true));
|
|
519
|
+
const conflicts = remoteAttributes
|
|
520
|
+
.map((attribute) =>
|
|
521
|
+
this.checkAttributeChanges(
|
|
522
|
+
attribute,
|
|
523
|
+
this.attributesContains(attribute, localAttributes),
|
|
524
|
+
collection,
|
|
525
|
+
),
|
|
526
|
+
)
|
|
527
|
+
.filter((attribute) => attribute !== undefined) as AttributeChange[];
|
|
528
|
+
const changes = remoteAttributes
|
|
529
|
+
.map((attribute) =>
|
|
530
|
+
this.checkAttributeChanges(
|
|
531
|
+
attribute,
|
|
532
|
+
this.attributesContains(attribute, localAttributes),
|
|
533
|
+
collection,
|
|
534
|
+
false,
|
|
535
|
+
),
|
|
536
|
+
)
|
|
537
|
+
.filter((attribute) => attribute !== undefined)
|
|
538
|
+
.filter(
|
|
539
|
+
(attribute) =>
|
|
540
|
+
conflicts.filter((attr) => attribute!.key === attr.key).length !== 1,
|
|
541
|
+
) as AttributeChange[];
|
|
542
|
+
|
|
543
|
+
let changedAttributes: any[] = [];
|
|
544
|
+
const changing = [...deleting, ...adding, ...conflicts, ...changes];
|
|
545
|
+
if (changing.length === 0) {
|
|
546
|
+
return changedAttributes;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
log(
|
|
550
|
+
!cliConfig.force
|
|
551
|
+
? "There are pending changes in your collection deployment"
|
|
552
|
+
: "List of applied changes",
|
|
553
|
+
);
|
|
554
|
+
|
|
555
|
+
drawTable(
|
|
556
|
+
changing.map((change) => {
|
|
557
|
+
return {
|
|
558
|
+
Key: change.key,
|
|
559
|
+
Action: change.action,
|
|
560
|
+
Reason: change.reason,
|
|
561
|
+
};
|
|
562
|
+
}),
|
|
563
|
+
);
|
|
564
|
+
|
|
565
|
+
if (!cliConfig.force) {
|
|
566
|
+
if (deleting.length > 0 && !isIndex) {
|
|
567
|
+
console.log(
|
|
568
|
+
`${chalk.red("------------------------------------------------------")}`,
|
|
569
|
+
);
|
|
570
|
+
console.log(
|
|
571
|
+
`${chalk.red("| WARNING: Attribute deletion may cause loss of data |")}`,
|
|
572
|
+
);
|
|
573
|
+
console.log(
|
|
574
|
+
`${chalk.red("------------------------------------------------------")}`,
|
|
575
|
+
);
|
|
576
|
+
console.log();
|
|
577
|
+
}
|
|
578
|
+
if (conflicts.length > 0 && !isIndex) {
|
|
579
|
+
console.log(
|
|
580
|
+
`${chalk.red("--------------------------------------------------------")}`,
|
|
581
|
+
);
|
|
582
|
+
console.log(
|
|
583
|
+
`${chalk.red("| WARNING: Attribute recreation may cause loss of data |")}`,
|
|
584
|
+
);
|
|
585
|
+
console.log(
|
|
586
|
+
`${chalk.red("--------------------------------------------------------")}`,
|
|
587
|
+
);
|
|
588
|
+
console.log();
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
if ((await this.getConfirmation()) !== true) {
|
|
592
|
+
return changedAttributes;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
if (conflicts.length > 0) {
|
|
597
|
+
changedAttributes = conflicts.map((change) => change.attribute);
|
|
598
|
+
await Promise.all(
|
|
599
|
+
changedAttributes.map((changed) =>
|
|
600
|
+
this.deleteAttribute(collection, changed, isIndex),
|
|
601
|
+
),
|
|
602
|
+
);
|
|
603
|
+
remoteAttributes = remoteAttributes.filter(
|
|
604
|
+
(attribute) => !this.attributesContains(attribute, changedAttributes),
|
|
605
|
+
);
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
if (changes.length > 0) {
|
|
609
|
+
changedAttributes = changes.map((change) => change.attribute);
|
|
610
|
+
await Promise.all(
|
|
611
|
+
changedAttributes.map((changed) =>
|
|
612
|
+
this.updateAttribute(
|
|
613
|
+
collection["databaseId"],
|
|
614
|
+
collection["$id"],
|
|
615
|
+
changed,
|
|
616
|
+
),
|
|
617
|
+
),
|
|
618
|
+
);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
const deletingAttributes = deleting.map((change) => change.attribute);
|
|
622
|
+
await Promise.all(
|
|
623
|
+
deletingAttributes.map((attribute) =>
|
|
624
|
+
this.deleteAttribute(collection, attribute, isIndex),
|
|
625
|
+
),
|
|
626
|
+
);
|
|
627
|
+
const attributeKeys = [
|
|
628
|
+
...remoteAttributes.map((attribute: any) => attribute.key),
|
|
629
|
+
...deletingAttributes.map((attribute: any) => attribute.key),
|
|
630
|
+
];
|
|
631
|
+
|
|
632
|
+
if (attributeKeys.length) {
|
|
633
|
+
const deleteAttributesPoolStatus =
|
|
634
|
+
await this.pools.waitForAttributeDeletion(
|
|
635
|
+
collection["databaseId"],
|
|
636
|
+
collection["$id"],
|
|
637
|
+
attributeKeys,
|
|
638
|
+
);
|
|
639
|
+
|
|
640
|
+
if (!deleteAttributesPoolStatus) {
|
|
641
|
+
throw new Error("Attribute deletion timed out.");
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
return localAttributes.filter(
|
|
646
|
+
(attribute) => !this.attributesContains(attribute, remoteAttributes),
|
|
647
|
+
);
|
|
648
|
+
};
|
|
649
|
+
|
|
650
|
+
public createIndexes = async (
|
|
651
|
+
indexes: any[],
|
|
652
|
+
collection: Collection,
|
|
653
|
+
): Promise<void> => {
|
|
654
|
+
log(`Creating indexes ...`);
|
|
655
|
+
|
|
656
|
+
const databasesService = await getDatabasesService();
|
|
657
|
+
for (let index of indexes) {
|
|
658
|
+
await databasesService.createIndex(
|
|
659
|
+
collection["databaseId"],
|
|
660
|
+
collection["$id"],
|
|
661
|
+
index.key,
|
|
662
|
+
index.type,
|
|
663
|
+
index.columns ?? index.attributes,
|
|
664
|
+
index.orders,
|
|
665
|
+
);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
const result = await this.pools.expectIndexes(
|
|
669
|
+
collection["databaseId"],
|
|
670
|
+
collection["$id"],
|
|
671
|
+
indexes.map((index: any) => index.key),
|
|
672
|
+
);
|
|
673
|
+
|
|
674
|
+
if (!result) {
|
|
675
|
+
throw new Error("Index creation timed out.");
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
success(`Created ${indexes.length} indexes`);
|
|
679
|
+
};
|
|
680
|
+
|
|
681
|
+
public createAttributes = async (
|
|
682
|
+
attributes: any[],
|
|
683
|
+
collection: Collection,
|
|
684
|
+
): Promise<void> => {
|
|
685
|
+
for (let attribute of attributes) {
|
|
686
|
+
if (attribute.side !== "child") {
|
|
687
|
+
await this.createAttribute(
|
|
688
|
+
collection["databaseId"],
|
|
689
|
+
collection["$id"],
|
|
690
|
+
attribute,
|
|
691
|
+
);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
const result = await this.pools.expectAttributes(
|
|
696
|
+
collection["databaseId"],
|
|
697
|
+
collection["$id"],
|
|
698
|
+
(collection.attributes || [])
|
|
699
|
+
.filter((attribute: any) => attribute.side !== "child")
|
|
700
|
+
.map((attribute: any) => attribute.key),
|
|
701
|
+
);
|
|
702
|
+
|
|
703
|
+
if (!result) {
|
|
704
|
+
throw new Error(`Attribute creation timed out.`);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
success(`Created ${attributes.length} attributes`);
|
|
708
|
+
};
|
|
709
|
+
|
|
710
|
+
public createColumns = async (
|
|
711
|
+
columns: any[],
|
|
712
|
+
table: Collection,
|
|
713
|
+
): Promise<void> => {
|
|
714
|
+
for (let column of columns) {
|
|
715
|
+
if (column.side !== "child") {
|
|
716
|
+
await this.createAttribute(table["databaseId"], table["$id"], column);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
const result = await this.pools.expectAttributes(
|
|
721
|
+
table["databaseId"],
|
|
722
|
+
table["$id"],
|
|
723
|
+
(table.columns || [])
|
|
724
|
+
.filter((column: any) => column.side !== "child")
|
|
725
|
+
.map((column: any) => column.key),
|
|
726
|
+
);
|
|
727
|
+
|
|
728
|
+
if (!result) {
|
|
729
|
+
throw new Error(`Column creation timed out.`);
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
success(`Created ${columns.length} columns`);
|
|
733
|
+
};
|
|
734
|
+
}
|