appwrite-cli 13.0.0-rc.1 → 13.0.0-rc.2
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 +106 -102
- package/LICENSE.md +1 -1
- package/README.md +58 -35
- package/bun.lock +625 -0
- package/dist/bundle.cjs +94853 -0
- package/dist/index.js +99 -99
- package/dist/index.js.map +1 -1
- package/dist/lib/client.d.ts +2 -3
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/lib/client.js +56 -45
- package/dist/lib/client.js.map +1 -1
- package/dist/lib/commands/generic.d.ts +2 -2
- package/dist/lib/commands/generic.d.ts.map +1 -1
- package/dist/lib/commands/generic.js +170 -157
- package/dist/lib/commands/generic.js.map +1 -1
- package/dist/lib/commands/init.d.ts +1 -1
- package/dist/lib/commands/init.d.ts.map +1 -1
- package/dist/lib/commands/init.js +197 -189
- package/dist/lib/commands/init.js.map +1 -1
- package/dist/lib/commands/pull.d.ts +2 -2
- package/dist/lib/commands/pull.d.ts.map +1 -1
- package/dist/lib/commands/pull.js +215 -244
- package/dist/lib/commands/pull.js.map +1 -1
- package/dist/lib/commands/push.d.ts.map +1 -1
- package/dist/lib/commands/push.js +814 -841
- package/dist/lib/commands/push.js.map +1 -1
- package/dist/lib/commands/run.d.ts +1 -1
- package/dist/lib/commands/run.d.ts.map +1 -1
- package/dist/lib/commands/run.js +129 -127
- package/dist/lib/commands/run.js.map +1 -1
- 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 +1 -1
- package/dist/lib/commands/types.d.ts.map +1 -1
- package/dist/lib/commands/types.js +53 -57
- package/dist/lib/commands/types.js.map +1 -1
- package/dist/lib/commands/update.d.ts +1 -1
- package/dist/lib/commands/update.d.ts.map +1 -1
- package/dist/lib/commands/update.js +65 -66
- package/dist/lib/commands/update.js.map +1 -1
- package/dist/lib/config.d.ts +39 -39
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +264 -202
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/emulation/docker.d.ts +1 -9
- package/dist/lib/emulation/docker.d.ts.map +1 -1
- package/dist/lib/emulation/docker.js +111 -107
- package/dist/lib/emulation/docker.js.map +1 -1
- package/dist/lib/emulation/utils.d.ts +1 -1
- package/dist/lib/emulation/utils.d.ts.map +1 -1
- package/dist/lib/emulation/utils.js +55 -58
- package/dist/lib/emulation/utils.js.map +1 -1
- package/dist/lib/id.d.ts +1 -1
- package/dist/lib/id.d.ts.map +1 -1
- package/dist/lib/id.js +13 -18
- package/dist/lib/id.js.map +1 -1
- package/dist/lib/paginate.d.ts +3 -4
- package/dist/lib/paginate.d.ts.map +1 -1
- package/dist/lib/paginate.js +7 -10
- package/dist/lib/paginate.js.map +1 -1
- package/dist/lib/parser.d.ts +1 -1
- package/dist/lib/parser.d.ts.map +1 -1
- package/dist/lib/parser.js +84 -96
- package/dist/lib/parser.js.map +1 -1
- package/dist/lib/questions.d.ts +1 -1
- package/dist/lib/questions.d.ts.map +1 -1
- package/dist/lib/questions.js +364 -368
- package/dist/lib/questions.js.map +1 -1
- package/dist/lib/sdks.d.ts +1 -1
- package/dist/lib/sdks.d.ts.map +1 -1
- package/dist/lib/sdks.js +40 -30
- package/dist/lib/sdks.js.map +1 -1
- 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 +1 -1
- package/dist/lib/spinner.d.ts.map +1 -1
- package/dist/lib/spinner.js +25 -27
- package/dist/lib/spinner.js.map +1 -1
- package/dist/lib/type-generation/attribute.d.ts +1 -1
- package/dist/lib/type-generation/attribute.d.ts.map +1 -1
- package/dist/lib/type-generation/attribute.js +14 -17
- package/dist/lib/type-generation/attribute.js.map +1 -1
- package/dist/lib/type-generation/languages/csharp.d.ts +1 -1
- package/dist/lib/type-generation/languages/csharp.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/csharp.js +34 -34
- package/dist/lib/type-generation/languages/csharp.js.map +1 -1
- package/dist/lib/type-generation/languages/dart.d.ts +1 -1
- package/dist/lib/type-generation/languages/dart.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/dart.js +57 -57
- package/dist/lib/type-generation/languages/dart.js.map +1 -1
- package/dist/lib/type-generation/languages/java.d.ts +1 -1
- package/dist/lib/type-generation/languages/java.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/java.js +35 -35
- package/dist/lib/type-generation/languages/java.js.map +1 -1
- package/dist/lib/type-generation/languages/javascript.d.ts +1 -1
- package/dist/lib/type-generation/languages/javascript.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/javascript.js +45 -44
- package/dist/lib/type-generation/languages/javascript.js.map +1 -1
- package/dist/lib/type-generation/languages/kotlin.d.ts +1 -1
- package/dist/lib/type-generation/languages/kotlin.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/kotlin.js +35 -35
- package/dist/lib/type-generation/languages/kotlin.js.map +1 -1
- package/dist/lib/type-generation/languages/language.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/language.js +32 -37
- package/dist/lib/type-generation/languages/language.js.map +1 -1
- package/dist/lib/type-generation/languages/php.d.ts +1 -1
- package/dist/lib/type-generation/languages/php.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/php.js +34 -34
- package/dist/lib/type-generation/languages/php.js.map +1 -1
- package/dist/lib/type-generation/languages/swift.d.ts +1 -1
- package/dist/lib/type-generation/languages/swift.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/swift.js +35 -35
- package/dist/lib/type-generation/languages/swift.js.map +1 -1
- package/dist/lib/type-generation/languages/typescript.d.ts +1 -1
- package/dist/lib/type-generation/languages/typescript.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/typescript.js +49 -46
- package/dist/lib/type-generation/languages/typescript.js.map +1 -1
- package/dist/lib/types.d.ts +189 -45
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js +1 -2
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +102 -98
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/validations.d.ts.map +1 -1
- package/dist/lib/validations.js +2 -6
- package/dist/lib/validations.js.map +1 -1
- package/dist/package.json +67 -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/index.ts +146 -130
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.ts +253 -220
- package/lib/commands/generic.ts +371 -269
- package/lib/commands/init.ts +620 -519
- package/lib/commands/pull.ts +581 -470
- package/lib/commands/push.ts +2838 -2269
- package/lib/commands/run.ts +382 -302
- 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 +144 -117
- package/lib/commands/update.ts +198 -159
- package/lib/config.ts +815 -700
- package/lib/emulation/docker.ts +291 -244
- package/lib/emulation/utils.ts +188 -174
- package/lib/id.ts +23 -23
- package/lib/paginate.ts +69 -55
- package/lib/parser.ts +215 -189
- package/lib/questions.ts +1025 -948
- package/lib/sdks.ts +80 -51
- package/lib/services.ts +72 -0
- package/lib/spinner.ts +112 -99
- package/lib/type-generation/attribute.ts +15 -14
- package/lib/type-generation/languages/csharp.ts +71 -60
- package/lib/type-generation/languages/dart.ts +106 -93
- package/lib/type-generation/languages/java.ts +69 -58
- package/lib/type-generation/languages/javascript.ts +84 -73
- package/lib/type-generation/languages/kotlin.ts +71 -60
- package/lib/type-generation/languages/language.ts +103 -95
- package/lib/type-generation/languages/php.ts +67 -56
- package/lib/type-generation/languages/swift.ts +71 -60
- package/lib/type-generation/languages/typescript.ts +93 -76
- package/lib/types.ts +261 -107
- package/lib/utils.ts +263 -233
- package/lib/validations.ts +17 -14
- package/package.json +27 -19
- package/scoop/appwrite.config.json +19 -29
- package/scripts/generate-commands.ts +539 -0
- package/tsconfig.json +7 -13
- package/.github/workflows/autoclose.yml +0 -11
- package/dist/lib/commands/account.d.ts +0 -379
- package/dist/lib/commands/account.d.ts.map +0 -1
- package/dist/lib/commands/account.js +0 -1228
- package/dist/lib/commands/account.js.map +0 -1
- package/dist/lib/commands/console.d.ts +0 -20
- package/dist/lib/commands/console.d.ts.map +0 -1
- package/dist/lib/commands/console.js +0 -78
- package/dist/lib/commands/console.js.map +0 -1
- package/dist/lib/commands/databases.d.ts +0 -732
- package/dist/lib/commands/databases.d.ts.map +0 -1
- package/dist/lib/commands/databases.js +0 -2196
- package/dist/lib/commands/databases.js.map +0 -1
- package/dist/lib/commands/functions.d.ts +0 -310
- package/dist/lib/commands/functions.d.ts.map +0 -1
- package/dist/lib/commands/functions.js +0 -1100
- package/dist/lib/commands/functions.js.map +0 -1
- package/dist/lib/commands/graphql.d.ts +0 -19
- package/dist/lib/commands/graphql.d.ts.map +0 -1
- package/dist/lib/commands/graphql.js +0 -77
- package/dist/lib/commands/graphql.js.map +0 -1
- package/dist/lib/commands/health.d.ts +0 -153
- package/dist/lib/commands/health.d.ts.map +0 -1
- package/dist/lib/commands/health.js +0 -464
- package/dist/lib/commands/health.js.map +0 -1
- package/dist/lib/commands/locale.d.ts +0 -53
- package/dist/lib/commands/locale.d.ts.map +0 -1
- package/dist/lib/commands/locale.js +0 -165
- package/dist/lib/commands/locale.js.map +0 -1
- package/dist/lib/commands/messaging.d.ts +0 -588
- package/dist/lib/commands/messaging.d.ts.map +0 -1
- package/dist/lib/commands/messaging.js +0 -2042
- package/dist/lib/commands/messaging.js.map +0 -1
- package/dist/lib/commands/migrations.d.ts +0 -150
- package/dist/lib/commands/migrations.d.ts.map +0 -1
- package/dist/lib/commands/migrations.js +0 -524
- package/dist/lib/commands/migrations.js.map +0 -1
- package/dist/lib/commands/organizations.d.ts +0 -11
- package/dist/lib/commands/organizations.d.ts.map +0 -1
- package/dist/lib/commands/organizations.js +0 -31
- package/dist/lib/commands/organizations.js.map +0 -1
- package/dist/lib/commands/project.d.ts +0 -53
- package/dist/lib/commands/project.d.ts.map +0 -1
- package/dist/lib/commands/project.js +0 -176
- package/dist/lib/commands/project.js.map +0 -1
- package/dist/lib/commands/projects.d.ts +0 -516
- package/dist/lib/commands/projects.d.ts.map +0 -1
- package/dist/lib/commands/projects.js +0 -1590
- package/dist/lib/commands/projects.js.map +0 -1
- package/dist/lib/commands/proxy.d.ts +0 -71
- package/dist/lib/commands/proxy.d.ts.map +0 -1
- package/dist/lib/commands/proxy.js +0 -240
- package/dist/lib/commands/proxy.js.map +0 -1
- package/dist/lib/commands/sites.d.ts +0 -296
- package/dist/lib/commands/sites.d.ts.map +0 -1
- package/dist/lib/commands/sites.js +0 -1046
- package/dist/lib/commands/sites.js.map +0 -1
- package/dist/lib/commands/storage.d.ts +0 -170
- package/dist/lib/commands/storage.d.ts.map +0 -1
- package/dist/lib/commands/storage.js +0 -651
- package/dist/lib/commands/storage.js.map +0 -1
- package/dist/lib/commands/tables-db.d.ts +0 -728
- package/dist/lib/commands/tables-db.d.ts.map +0 -1
- package/dist/lib/commands/tables-db.js +0 -2198
- package/dist/lib/commands/tables-db.js.map +0 -1
- package/dist/lib/commands/teams.d.ts +0 -129
- package/dist/lib/commands/teams.d.ts.map +0 -1
- package/dist/lib/commands/teams.js +0 -403
- package/dist/lib/commands/teams.js.map +0 -1
- package/dist/lib/commands/tokens.d.ts +0 -48
- package/dist/lib/commands/tokens.d.ts.map +0 -1
- package/dist/lib/commands/tokens.js +0 -156
- package/dist/lib/commands/tokens.js.map +0 -1
- package/dist/lib/commands/users.d.ts +0 -382
- package/dist/lib/commands/users.d.ts.map +0 -1
- package/dist/lib/commands/users.js +0 -1195
- package/dist/lib/commands/users.js.map +0 -1
- package/dist/lib/commands/vcs.d.ts +0 -92
- package/dist/lib/commands/vcs.d.ts.map +0 -1
- package/dist/lib/commands/vcs.js +0 -276
- package/dist/lib/commands/vcs.js.map +0 -1
- package/dist/lib/exception.d.ts +0 -8
- package/dist/lib/exception.d.ts.map +0 -1
- package/dist/lib/exception.js +0 -16
- package/dist/lib/exception.js.map +0 -1
- 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 -3
- package/docs/examples/account/create-email-verification.md +0 -2
- package/docs/examples/account/create-jwt.md +0 -1
- package/docs/examples/account/create-magic-url-token.md +0 -3
- 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-auth-2-session.md +0 -2
- package/docs/examples/account/create-o-auth-2-token.md +0 -2
- 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 -3
- 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 -4
- 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 -1
- package/docs/examples/account/list-logs.md +0 -1
- 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-verification.md +0 -3
- package/docs/examples/account/update-email.md +0 -3
- package/docs/examples/account/update-magic-url-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-mfa.md +0 -2
- package/docs/examples/account/update-name.md +0 -2
- package/docs/examples/account/update-password.md +0 -2
- 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/console/get-resource.md +0 -3
- package/docs/examples/console/variables.md +0 -1
- package/docs/examples/databases/create-boolean-attribute.md +0 -5
- package/docs/examples/databases/create-collection.md +0 -4
- package/docs/examples/databases/create-datetime-attribute.md +0 -5
- package/docs/examples/databases/create-document.md +0 -5
- package/docs/examples/databases/create-documents.md +0 -4
- package/docs/examples/databases/create-email-attribute.md +0 -5
- package/docs/examples/databases/create-enum-attribute.md +0 -6
- package/docs/examples/databases/create-float-attribute.md +0 -5
- package/docs/examples/databases/create-index.md +0 -6
- package/docs/examples/databases/create-integer-attribute.md +0 -5
- package/docs/examples/databases/create-ip-attribute.md +0 -5
- package/docs/examples/databases/create-line-attribute.md +0 -5
- package/docs/examples/databases/create-operations.md +0 -2
- package/docs/examples/databases/create-point-attribute.md +0 -5
- package/docs/examples/databases/create-polygon-attribute.md +0 -5
- package/docs/examples/databases/create-relationship-attribute.md +0 -5
- package/docs/examples/databases/create-string-attribute.md +0 -6
- package/docs/examples/databases/create-transaction.md +0 -1
- package/docs/examples/databases/create-url-attribute.md +0 -5
- package/docs/examples/databases/create.md +0 -3
- package/docs/examples/databases/decrement-document-attribute.md +0 -5
- 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 -3
- package/docs/examples/databases/delete-index.md +0 -4
- package/docs/examples/databases/delete-transaction.md +0 -2
- 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 -3
- package/docs/examples/databases/get-collection.md +0 -3
- package/docs/examples/databases/get-document.md +0 -4
- package/docs/examples/databases/get-index.md +0 -4
- package/docs/examples/databases/get-transaction.md +0 -2
- 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 -5
- package/docs/examples/databases/list-attributes.md +0 -3
- package/docs/examples/databases/list-collection-logs.md +0 -3
- package/docs/examples/databases/list-collections.md +0 -2
- package/docs/examples/databases/list-document-logs.md +0 -4
- package/docs/examples/databases/list-documents.md +0 -3
- package/docs/examples/databases/list-indexes.md +0 -3
- package/docs/examples/databases/list-logs.md +0 -2
- package/docs/examples/databases/list-transactions.md +0 -1
- package/docs/examples/databases/list-usage.md +0 -1
- package/docs/examples/databases/list.md +0 -1
- package/docs/examples/databases/update-boolean-attribute.md +0 -6
- package/docs/examples/databases/update-collection.md +0 -4
- package/docs/examples/databases/update-datetime-attribute.md +0 -6
- package/docs/examples/databases/update-document.md +0 -4
- package/docs/examples/databases/update-documents.md +0 -3
- package/docs/examples/databases/update-email-attribute.md +0 -6
- package/docs/examples/databases/update-enum-attribute.md +0 -7
- package/docs/examples/databases/update-float-attribute.md +0 -6
- package/docs/examples/databases/update-integer-attribute.md +0 -6
- package/docs/examples/databases/update-ip-attribute.md +0 -6
- package/docs/examples/databases/update-line-attribute.md +0 -5
- package/docs/examples/databases/update-point-attribute.md +0 -5
- package/docs/examples/databases/update-polygon-attribute.md +0 -5
- package/docs/examples/databases/update-relationship-attribute.md +0 -4
- package/docs/examples/databases/update-string-attribute.md +0 -6
- package/docs/examples/databases/update-transaction.md +0 -2
- package/docs/examples/databases/update-url-attribute.md +0 -6
- package/docs/examples/databases/update.md +0 -3
- package/docs/examples/databases/upsert-document.md +0 -4
- package/docs/examples/databases/upsert-documents.md +0 -4
- package/docs/examples/functions/create-deployment.md +0 -4
- package/docs/examples/functions/create-duplicate-deployment.md +0 -3
- package/docs/examples/functions/create-execution.md +0 -2
- package/docs/examples/functions/create-template-deployment.md +0 -7
- package/docs/examples/functions/create-variable.md +0 -4
- package/docs/examples/functions/create-vcs-deployment.md +0 -4
- package/docs/examples/functions/create.md +0 -4
- 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 -3
- 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 -2
- 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 -2
- package/docs/examples/functions/list-executions.md +0 -2
- 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 -1
- package/docs/examples/functions/list-usage.md +0 -1
- package/docs/examples/functions/list-variables.md +0 -2
- package/docs/examples/functions/list.md +0 -1
- 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 -4
- package/docs/examples/functions/update.md +0 -3
- 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 -1
- package/docs/examples/health/get-db.md +0 -1
- package/docs/examples/health/get-failed-jobs.md +0 -2
- package/docs/examples/health/get-pub-sub.md +0 -1
- package/docs/examples/health/get-queue-builds.md +0 -1
- package/docs/examples/health/get-queue-certificates.md +0 -1
- package/docs/examples/health/get-queue-databases.md +0 -1
- package/docs/examples/health/get-queue-deletes.md +0 -1
- package/docs/examples/health/get-queue-functions.md +0 -1
- package/docs/examples/health/get-queue-logs.md +0 -1
- package/docs/examples/health/get-queue-mails.md +0 -1
- package/docs/examples/health/get-queue-messaging.md +0 -1
- package/docs/examples/health/get-queue-migrations.md +0 -1
- package/docs/examples/health/get-queue-stats-resources.md +0 -1
- package/docs/examples/health/get-queue-usage.md +0 -1
- package/docs/examples/health/get-queue-webhooks.md +0 -1
- 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-eu.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 -3
- package/docs/examples/messaging/create-email.md +0 -4
- package/docs/examples/messaging/create-fcm-provider.md +0 -3
- package/docs/examples/messaging/create-mailgun-provider.md +0 -3
- package/docs/examples/messaging/create-msg-91-provider.md +0 -3
- package/docs/examples/messaging/create-push.md +0 -2
- package/docs/examples/messaging/create-resend-provider.md +0 -3
- package/docs/examples/messaging/create-sendgrid-provider.md +0 -3
- package/docs/examples/messaging/create-sms.md +0 -3
- package/docs/examples/messaging/create-smtp-provider.md +0 -4
- package/docs/examples/messaging/create-subscriber.md +0 -4
- package/docs/examples/messaging/create-telesign-provider.md +0 -3
- package/docs/examples/messaging/create-textmagic-provider.md +0 -3
- package/docs/examples/messaging/create-topic.md +0 -3
- package/docs/examples/messaging/create-twilio-provider.md +0 -3
- package/docs/examples/messaging/create-vonage-provider.md +0 -3
- 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 -2
- package/docs/examples/messaging/list-messages.md +0 -1
- package/docs/examples/messaging/list-provider-logs.md +0 -2
- package/docs/examples/messaging/list-providers.md +0 -1
- package/docs/examples/messaging/list-subscriber-logs.md +0 -2
- package/docs/examples/messaging/list-subscribers.md +0 -2
- package/docs/examples/messaging/list-targets.md +0 -2
- package/docs/examples/messaging/list-topic-logs.md +0 -2
- package/docs/examples/messaging/list-topics.md +0 -1
- package/docs/examples/messaging/update-apns-provider.md +0 -2
- package/docs/examples/messaging/update-email.md +0 -2
- package/docs/examples/messaging/update-fcm-provider.md +0 -2
- package/docs/examples/messaging/update-mailgun-provider.md +0 -2
- package/docs/examples/messaging/update-msg-91-provider.md +0 -2
- package/docs/examples/messaging/update-push.md +0 -2
- package/docs/examples/messaging/update-resend-provider.md +0 -2
- package/docs/examples/messaging/update-sendgrid-provider.md +0 -2
- package/docs/examples/messaging/update-sms.md +0 -2
- package/docs/examples/messaging/update-smtp-provider.md +0 -2
- package/docs/examples/messaging/update-telesign-provider.md +0 -2
- package/docs/examples/messaging/update-textmagic-provider.md +0 -2
- package/docs/examples/messaging/update-topic.md +0 -2
- package/docs/examples/messaging/update-twilio-provider.md +0 -2
- package/docs/examples/messaging/update-vonage-provider.md +0 -2
- package/docs/examples/migrations/create-appwrite-migration.md +0 -5
- package/docs/examples/migrations/create-csv-export.md +0 -3
- package/docs/examples/migrations/create-csv-import.md +0 -4
- package/docs/examples/migrations/create-firebase-migration.md +0 -3
- package/docs/examples/migrations/create-n-host-migration.md +0 -8
- package/docs/examples/migrations/create-supabase-migration.md +0 -7
- 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 -8
- package/docs/examples/migrations/get-supabase-report.md +0 -7
- package/docs/examples/migrations/get.md +0 -2
- package/docs/examples/migrations/list.md +0 -1
- package/docs/examples/migrations/retry.md +0 -2
- package/docs/examples/project/create-variable.md +0 -3
- package/docs/examples/project/delete-variable.md +0 -2
- package/docs/examples/project/get-usage.md +0 -3
- 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 -3
- package/docs/examples/projects/create-dev-key.md +0 -4
- package/docs/examples/projects/create-jwt.md +0 -3
- package/docs/examples/projects/create-key.md +0 -4
- package/docs/examples/projects/create-platform.md +0 -4
- package/docs/examples/projects/create-smtp-test.md +0 -6
- package/docs/examples/projects/create-webhook.md +0 -6
- package/docs/examples/projects/create.md +0 -4
- 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 -2
- 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 -1
- 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 -6
- package/docs/examples/projects/update-key.md +0 -5
- 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-auth-2.md +0 -3
- package/docs/examples/projects/update-personal-data-check.md +0 -3
- package/docs/examples/projects/update-platform.md +0 -4
- 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-session-invalidation.md +0 -3
- package/docs/examples/projects/update-sms-template.md +0 -5
- package/docs/examples/projects/update-smtp.md +0 -3
- 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 -7
- package/docs/examples/projects/update.md +0 -3
- package/docs/examples/proxy/create-api-rule.md +0 -2
- package/docs/examples/proxy/create-function-rule.md +0 -3
- package/docs/examples/proxy/create-redirect-rule.md +0 -6
- package/docs/examples/proxy/create-site-rule.md +0 -3
- 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 -1
- package/docs/examples/proxy/update-rule-verification.md +0 -2
- package/docs/examples/sites/create-deployment.md +0 -4
- 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 -4
- package/docs/examples/sites/create-vcs-deployment.md +0 -4
- package/docs/examples/sites/create.md +0 -5
- 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 -3
- 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 -2
- 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 -2
- package/docs/examples/sites/list-frameworks.md +0 -1
- package/docs/examples/sites/list-logs.md +0 -2
- package/docs/examples/sites/list-specifications.md +0 -1
- package/docs/examples/sites/list-templates.md +0 -1
- package/docs/examples/sites/list-usage.md +0 -1
- package/docs/examples/sites/list-variables.md +0 -2
- package/docs/examples/sites/list.md +0 -1
- 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 -4
- package/docs/examples/sites/update.md +0 -4
- package/docs/examples/storage/create-bucket.md +0 -3
- package/docs/examples/storage/create-file.md +0 -4
- 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 -2
- package/docs/examples/storage/get-bucket.md +0 -2
- package/docs/examples/storage/get-file-download.md +0 -3
- package/docs/examples/storage/get-file-preview.md +0 -3
- package/docs/examples/storage/get-file-view.md +0 -3
- package/docs/examples/storage/get-file.md +0 -3
- package/docs/examples/storage/get-usage.md +0 -1
- package/docs/examples/storage/list-buckets.md +0 -1
- package/docs/examples/storage/list-files.md +0 -2
- package/docs/examples/storage/update-bucket.md +0 -3
- package/docs/examples/storage/update-file.md +0 -3
- package/docs/examples/tablesdb/create-boolean-column.md +0 -5
- package/docs/examples/tablesdb/create-datetime-column.md +0 -5
- package/docs/examples/tablesdb/create-email-column.md +0 -5
- package/docs/examples/tablesdb/create-enum-column.md +0 -6
- package/docs/examples/tablesdb/create-float-column.md +0 -5
- package/docs/examples/tablesdb/create-index.md +0 -6
- package/docs/examples/tablesdb/create-integer-column.md +0 -5
- package/docs/examples/tablesdb/create-ip-column.md +0 -5
- package/docs/examples/tablesdb/create-line-column.md +0 -5
- package/docs/examples/tablesdb/create-operations.md +0 -2
- package/docs/examples/tablesdb/create-point-column.md +0 -5
- package/docs/examples/tablesdb/create-polygon-column.md +0 -5
- package/docs/examples/tablesdb/create-relationship-column.md +0 -5
- package/docs/examples/tablesdb/create-row.md +0 -5
- package/docs/examples/tablesdb/create-rows.md +0 -4
- package/docs/examples/tablesdb/create-string-column.md +0 -6
- package/docs/examples/tablesdb/create-table.md +0 -4
- package/docs/examples/tablesdb/create-transaction.md +0 -1
- package/docs/examples/tablesdb/create-url-column.md +0 -5
- package/docs/examples/tablesdb/create.md +0 -3
- package/docs/examples/tablesdb/decrement-row-column.md +0 -5
- package/docs/examples/tablesdb/delete-column.md +0 -4
- package/docs/examples/tablesdb/delete-index.md +0 -4
- package/docs/examples/tablesdb/delete-row.md +0 -4
- package/docs/examples/tablesdb/delete-rows.md +0 -3
- package/docs/examples/tablesdb/delete-table.md +0 -3
- package/docs/examples/tablesdb/delete-transaction.md +0 -2
- package/docs/examples/tablesdb/delete.md +0 -2
- package/docs/examples/tablesdb/get-column.md +0 -4
- package/docs/examples/tablesdb/get-index.md +0 -4
- package/docs/examples/tablesdb/get-row.md +0 -4
- package/docs/examples/tablesdb/get-table-usage.md +0 -3
- package/docs/examples/tablesdb/get-table.md +0 -3
- package/docs/examples/tablesdb/get-transaction.md +0 -2
- package/docs/examples/tablesdb/get-usage.md +0 -2
- package/docs/examples/tablesdb/get.md +0 -2
- package/docs/examples/tablesdb/increment-row-column.md +0 -5
- package/docs/examples/tablesdb/list-columns.md +0 -3
- package/docs/examples/tablesdb/list-indexes.md +0 -3
- package/docs/examples/tablesdb/list-row-logs.md +0 -4
- package/docs/examples/tablesdb/list-rows.md +0 -3
- package/docs/examples/tablesdb/list-table-logs.md +0 -3
- package/docs/examples/tablesdb/list-tables.md +0 -2
- package/docs/examples/tablesdb/list-transactions.md +0 -1
- package/docs/examples/tablesdb/list-usage.md +0 -1
- package/docs/examples/tablesdb/list.md +0 -1
- package/docs/examples/tablesdb/update-boolean-column.md +0 -6
- package/docs/examples/tablesdb/update-datetime-column.md +0 -6
- package/docs/examples/tablesdb/update-email-column.md +0 -6
- package/docs/examples/tablesdb/update-enum-column.md +0 -7
- package/docs/examples/tablesdb/update-float-column.md +0 -6
- package/docs/examples/tablesdb/update-integer-column.md +0 -6
- package/docs/examples/tablesdb/update-ip-column.md +0 -6
- package/docs/examples/tablesdb/update-line-column.md +0 -5
- package/docs/examples/tablesdb/update-point-column.md +0 -5
- package/docs/examples/tablesdb/update-polygon-column.md +0 -5
- package/docs/examples/tablesdb/update-relationship-column.md +0 -4
- package/docs/examples/tablesdb/update-row.md +0 -4
- package/docs/examples/tablesdb/update-rows.md +0 -3
- package/docs/examples/tablesdb/update-string-column.md +0 -6
- package/docs/examples/tablesdb/update-table.md +0 -4
- package/docs/examples/tablesdb/update-transaction.md +0 -2
- package/docs/examples/tablesdb/update-url-column.md +0 -6
- package/docs/examples/tablesdb/update.md +0 -3
- package/docs/examples/tablesdb/upsert-row.md +0 -4
- package/docs/examples/tablesdb/upsert-rows.md +0 -4
- package/docs/examples/teams/create-membership.md +0 -3
- package/docs/examples/teams/create.md +0 -3
- 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 -2
- package/docs/examples/teams/list-memberships.md +0 -2
- package/docs/examples/teams/list.md +0 -1
- 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 -3
- package/docs/examples/tokens/delete.md +0 -2
- package/docs/examples/tokens/get.md +0 -2
- package/docs/examples/tokens/list.md +0 -3
- package/docs/examples/tokens/update.md +0 -2
- package/docs/examples/users/create-argon-2-user.md +0 -4
- package/docs/examples/users/create-bcrypt-user.md +0 -4
- package/docs/examples/users/create-jwt.md +0 -2
- package/docs/examples/users/create-md-5-user.md +0 -4
- package/docs/examples/users/create-mfa-recovery-codes.md +0 -2
- package/docs/examples/users/create-ph-pass-user.md +0 -4
- package/docs/examples/users/create-scrypt-modified-user.md +0 -7
- package/docs/examples/users/create-scrypt-user.md +0 -9
- package/docs/examples/users/create-session.md +0 -2
- package/docs/examples/users/create-sha-user.md +0 -4
- package/docs/examples/users/create-target.md +0 -5
- package/docs/examples/users/create-token.md +0 -2
- package/docs/examples/users/create.md +0 -2
- 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 -1
- package/docs/examples/users/get.md +0 -2
- package/docs/examples/users/list-identities.md +0 -1
- package/docs/examples/users/list-logs.md +0 -2
- package/docs/examples/users/list-memberships.md +0 -2
- 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 -2
- package/docs/examples/users/list.md +0 -1
- 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 -3
- package/docs/examples/vcs/create-repository-detection.md +0 -4
- 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 -3
- package/docs/examples/vcs/get-repository.md +0 -3
- package/docs/examples/vcs/list-installations.md +0 -1
- package/docs/examples/vcs/list-repositories.md +0 -3
- package/docs/examples/vcs/list-repository-branches.md +0 -3
- package/docs/examples/vcs/update-external-deployments.md +0 -4
- package/lib/commands/account.ts +0 -1867
- package/lib/commands/console.ts +0 -112
- package/lib/commands/databases.ts +0 -3272
- package/lib/commands/functions.ts +0 -1587
- package/lib/commands/graphql.ts +0 -110
- package/lib/commands/health.ts +0 -753
- package/lib/commands/locale.ts +0 -270
- package/lib/commands/messaging.ts +0 -2878
- package/lib/commands/migrations.ts +0 -754
- package/lib/commands/organizations.ts +0 -46
- package/lib/commands/project.ts +0 -266
- package/lib/commands/projects.ts +0 -2370
- package/lib/commands/proxy.ts +0 -357
- package/lib/commands/sites.ts +0 -1514
- package/lib/commands/storage.ts +0 -919
- package/lib/commands/tables-db.ts +0 -3260
- package/lib/commands/teams.ts +0 -609
- package/lib/commands/tokens.ts +0 -232
- package/lib/commands/users.ts +0 -1804
- package/lib/commands/vcs.ts +0 -428
- package/lib/exception.ts +0 -20
|
@@ -1,51 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const config_1 = require("../config");
|
|
15
|
-
const spinner_1 = require("../spinner");
|
|
16
|
-
const paginate_1 = require("../paginate");
|
|
17
|
-
const questions_1 = require("../questions");
|
|
18
|
-
const parser_1 = require("../parser");
|
|
19
|
-
const proxy_1 = require("./proxy");
|
|
20
|
-
const console_1 = require("./console");
|
|
21
|
-
const sdks_1 = require("../sdks");
|
|
22
|
-
const functions_1 = require("./functions");
|
|
23
|
-
const sites_1 = require("./sites");
|
|
24
|
-
const databases_1 = require("./databases");
|
|
25
|
-
const tables_db_1 = require("./tables-db");
|
|
26
|
-
const storage_1 = require("./storage");
|
|
27
|
-
const messaging_1 = require("./messaging");
|
|
28
|
-
const teams_1 = require("./teams");
|
|
29
|
-
const projects_1 = require("./projects");
|
|
30
|
-
const utils_1 = require("../utils");
|
|
31
|
-
const JSONbigNative = (0, json_bigint_1.default)({ storeAsString: false });
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { parse as parseDotenv } from "dotenv";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import inquirer from "inquirer";
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
import ID from "../id.js";
|
|
7
|
+
import { localConfig, globalConfig, KeysAttributes, KeysFunction, KeysSite, whitelistKeys, KeysTopics, KeysStorage, KeysTeams, KeysCollection, KeysTable, } from "../config.js";
|
|
8
|
+
import { Spinner, SPINNER_ARC, SPINNER_DOTS } from "../spinner.js";
|
|
9
|
+
import { paginate } from "../paginate.js";
|
|
10
|
+
import { questionsPushBuckets, questionsPushTeams, questionsPushFunctions, questionsPushSites, questionsGetEntrypoint, questionsPushCollections, questionsPushTables, questionPushChanges, questionPushChangesConfirmation, questionsPushMessagingTopics, questionsPushResources, } from "../questions.js";
|
|
11
|
+
import { cliConfig, actionRunner, success, warn, log, hint, error, commandDescriptions, drawTable, } from "../parser.js";
|
|
12
|
+
import { getProxyService, getConsoleService, getFunctionsService, getSitesService, getDatabasesService, getTablesDBService, getStorageService, getMessagingService, getTeamsService, getProjectsService, } from "../services.js";
|
|
13
|
+
import { checkDeployConditions } from "../utils.js";
|
|
32
14
|
const STEP_SIZE = 100; // Resources
|
|
33
15
|
const POLL_DEBOUNCE = 2000; // Milliseconds
|
|
34
|
-
const POLL_MAX_DEBOUNCE = 1800; // Times of POLL_DEBOUNCE (1 hour)
|
|
35
16
|
const POLL_DEFAULT_VALUE = 30;
|
|
36
17
|
let pollMaxDebounces = POLL_DEFAULT_VALUE;
|
|
37
|
-
const changeableKeys = [
|
|
18
|
+
const changeableKeys = [
|
|
19
|
+
"status",
|
|
20
|
+
"required",
|
|
21
|
+
"xdefault",
|
|
22
|
+
"elements",
|
|
23
|
+
"min",
|
|
24
|
+
"max",
|
|
25
|
+
"default",
|
|
26
|
+
"error",
|
|
27
|
+
];
|
|
38
28
|
const awaitPools = {
|
|
39
29
|
wipeAttributes: async (databaseId, collectionId, iteration = 1) => {
|
|
40
30
|
if (iteration > pollMaxDebounces) {
|
|
41
31
|
return false;
|
|
42
32
|
}
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
queries: [JSON.stringify({ method: 'limit', values: [1] })],
|
|
47
|
-
parseOutput: false
|
|
48
|
-
});
|
|
33
|
+
const databasesService = await getDatabasesService();
|
|
34
|
+
const response = await databasesService.listAttributes(databaseId, collectionId, [JSON.stringify({ method: "limit", values: [1] })]);
|
|
35
|
+
const { total } = response;
|
|
49
36
|
if (total === 0) {
|
|
50
37
|
return true;
|
|
51
38
|
}
|
|
@@ -53,22 +40,21 @@ const awaitPools = {
|
|
|
53
40
|
let steps = Math.max(1, Math.ceil(total / STEP_SIZE));
|
|
54
41
|
if (steps > 1 && iteration === 1) {
|
|
55
42
|
pollMaxDebounces *= steps;
|
|
56
|
-
|
|
43
|
+
log("Found a large number of attributes, increasing timeout to " +
|
|
44
|
+
(pollMaxDebounces * POLL_DEBOUNCE) / 1000 / 60 +
|
|
45
|
+
" minutes");
|
|
57
46
|
}
|
|
58
47
|
}
|
|
59
|
-
await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE));
|
|
48
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_DEBOUNCE));
|
|
60
49
|
return await awaitPools.wipeAttributes(databaseId, collectionId, iteration + 1);
|
|
61
50
|
},
|
|
62
51
|
wipeIndexes: async (databaseId, collectionId, iteration = 1) => {
|
|
63
52
|
if (iteration > pollMaxDebounces) {
|
|
64
53
|
return false;
|
|
65
54
|
}
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
queries: [JSON.stringify({ method: 'limit', values: [1] })],
|
|
70
|
-
parseOutput: false
|
|
71
|
-
});
|
|
55
|
+
const databasesService = await getDatabasesService();
|
|
56
|
+
const response = await databasesService.listIndexes(databaseId, collectionId, [JSON.stringify({ method: "limit", values: [1] })]);
|
|
57
|
+
const { total } = response;
|
|
72
58
|
if (total === 0) {
|
|
73
59
|
return true;
|
|
74
60
|
}
|
|
@@ -76,10 +62,12 @@ const awaitPools = {
|
|
|
76
62
|
let steps = Math.max(1, Math.ceil(total / STEP_SIZE));
|
|
77
63
|
if (steps > 1 && iteration === 1) {
|
|
78
64
|
pollMaxDebounces *= steps;
|
|
79
|
-
|
|
65
|
+
log("Found a large number of indexes, increasing timeout to " +
|
|
66
|
+
(pollMaxDebounces * POLL_DEBOUNCE) / 1000 / 60 +
|
|
67
|
+
" minutes");
|
|
80
68
|
}
|
|
81
69
|
}
|
|
82
|
-
await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE));
|
|
70
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_DEBOUNCE));
|
|
83
71
|
return await awaitPools.wipeIndexes(databaseId, collectionId, iteration + 1);
|
|
84
72
|
},
|
|
85
73
|
deleteAttributes: async (databaseId, collectionId, attributeKeys, iteration = 1) => {
|
|
@@ -90,19 +78,23 @@ const awaitPools = {
|
|
|
90
78
|
let steps = Math.max(1, Math.ceil(attributeKeys.length / STEP_SIZE));
|
|
91
79
|
if (steps > 1 && iteration === 1) {
|
|
92
80
|
pollMaxDebounces *= steps;
|
|
93
|
-
|
|
81
|
+
log("Found a large number of attributes to be deleted. Increasing timeout to " +
|
|
82
|
+
(pollMaxDebounces * POLL_DEBOUNCE) / 1000 / 60 +
|
|
83
|
+
" minutes");
|
|
94
84
|
}
|
|
95
85
|
}
|
|
96
|
-
const { attributes } = await (
|
|
86
|
+
const { attributes } = await paginate(async (args) => {
|
|
87
|
+
const databasesService = await getDatabasesService();
|
|
88
|
+
return await databasesService.listAttributes(args.databaseId, args.collectionId, args.queries || []);
|
|
89
|
+
}, {
|
|
97
90
|
databaseId,
|
|
98
91
|
collectionId,
|
|
99
|
-
|
|
100
|
-
}, 100, 'attributes');
|
|
92
|
+
}, 100, "attributes");
|
|
101
93
|
const ready = attributeKeys.filter((attribute) => attributes.includes(attribute.key));
|
|
102
94
|
if (ready.length === 0) {
|
|
103
95
|
return true;
|
|
104
96
|
}
|
|
105
|
-
await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE));
|
|
97
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_DEBOUNCE));
|
|
106
98
|
return await awaitPools.expectAttributes(databaseId, collectionId, attributeKeys, iteration + 1);
|
|
107
99
|
},
|
|
108
100
|
expectAttributes: async (databaseId, collectionId, attributeKeys, iteration = 1) => {
|
|
@@ -113,21 +105,25 @@ const awaitPools = {
|
|
|
113
105
|
let steps = Math.max(1, Math.ceil(attributeKeys.length / STEP_SIZE));
|
|
114
106
|
if (steps > 1 && iteration === 1) {
|
|
115
107
|
pollMaxDebounces *= steps;
|
|
116
|
-
|
|
108
|
+
log("Creating a large number of attributes, increasing timeout to " +
|
|
109
|
+
(pollMaxDebounces * POLL_DEBOUNCE) / 1000 / 60 +
|
|
110
|
+
" minutes");
|
|
117
111
|
}
|
|
118
112
|
}
|
|
119
|
-
const { attributes } = await (
|
|
113
|
+
const { attributes } = await paginate(async (args) => {
|
|
114
|
+
const databasesService = await getDatabasesService();
|
|
115
|
+
return await databasesService.listAttributes(args.databaseId, args.collectionId, args.queries || []);
|
|
116
|
+
}, {
|
|
120
117
|
databaseId,
|
|
121
118
|
collectionId,
|
|
122
|
-
|
|
123
|
-
}, 100, 'attributes');
|
|
119
|
+
}, 100, "attributes");
|
|
124
120
|
const ready = attributes
|
|
125
121
|
.filter((attribute) => {
|
|
126
122
|
if (attributeKeys.includes(attribute.key)) {
|
|
127
|
-
if ([
|
|
123
|
+
if (["stuck", "failed"].includes(attribute.status)) {
|
|
128
124
|
throw new Error(`Attribute '${attribute.key}' failed!`);
|
|
129
125
|
}
|
|
130
|
-
return attribute.status ===
|
|
126
|
+
return attribute.status === "available";
|
|
131
127
|
}
|
|
132
128
|
return false;
|
|
133
129
|
})
|
|
@@ -135,7 +131,7 @@ const awaitPools = {
|
|
|
135
131
|
if (ready.length === attributeKeys.length) {
|
|
136
132
|
return true;
|
|
137
133
|
}
|
|
138
|
-
await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE));
|
|
134
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_DEBOUNCE));
|
|
139
135
|
return await awaitPools.expectAttributes(databaseId, collectionId, attributeKeys, iteration + 1);
|
|
140
136
|
},
|
|
141
137
|
deleteIndexes: async (databaseId, collectionId, indexesKeys, iteration = 1) => {
|
|
@@ -146,19 +142,23 @@ const awaitPools = {
|
|
|
146
142
|
let steps = Math.max(1, Math.ceil(indexesKeys.length / STEP_SIZE));
|
|
147
143
|
if (steps > 1 && iteration === 1) {
|
|
148
144
|
pollMaxDebounces *= steps;
|
|
149
|
-
|
|
145
|
+
log("Found a large number of indexes to be deleted. Increasing timeout to " +
|
|
146
|
+
(pollMaxDebounces * POLL_DEBOUNCE) / 1000 / 60 +
|
|
147
|
+
" minutes");
|
|
150
148
|
}
|
|
151
149
|
}
|
|
152
|
-
const { indexes } = await (
|
|
150
|
+
const { indexes } = await paginate(async (args) => {
|
|
151
|
+
const databasesService = await getDatabasesService();
|
|
152
|
+
return await databasesService.listIndexes(args.databaseId, args.collectionId, args.queries || []);
|
|
153
|
+
}, {
|
|
153
154
|
databaseId,
|
|
154
155
|
collectionId,
|
|
155
|
-
|
|
156
|
-
}, 100, 'indexes');
|
|
156
|
+
}, 100, "indexes");
|
|
157
157
|
const ready = indexesKeys.filter((index) => indexes.includes(index.key));
|
|
158
158
|
if (ready.length === 0) {
|
|
159
159
|
return true;
|
|
160
160
|
}
|
|
161
|
-
await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE));
|
|
161
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_DEBOUNCE));
|
|
162
162
|
return await awaitPools.expectIndexes(databaseId, collectionId, indexesKeys, iteration + 1);
|
|
163
163
|
},
|
|
164
164
|
expectIndexes: async (databaseId, collectionId, indexKeys, iteration = 1) => {
|
|
@@ -169,21 +169,25 @@ const awaitPools = {
|
|
|
169
169
|
let steps = Math.max(1, Math.ceil(indexKeys.length / STEP_SIZE));
|
|
170
170
|
if (steps > 1 && iteration === 1) {
|
|
171
171
|
pollMaxDebounces *= steps;
|
|
172
|
-
|
|
172
|
+
log("Creating a large number of indexes, increasing timeout to " +
|
|
173
|
+
(pollMaxDebounces * POLL_DEBOUNCE) / 1000 / 60 +
|
|
174
|
+
" minutes");
|
|
173
175
|
}
|
|
174
176
|
}
|
|
175
|
-
const { indexes } = await (
|
|
177
|
+
const { indexes } = await paginate(async (args) => {
|
|
178
|
+
const databasesService = await getDatabasesService();
|
|
179
|
+
return await databasesService.listIndexes(args.databaseId, args.collectionId, args.queries || []);
|
|
180
|
+
}, {
|
|
176
181
|
databaseId,
|
|
177
182
|
collectionId,
|
|
178
|
-
|
|
179
|
-
}, 100, 'indexes');
|
|
183
|
+
}, 100, "indexes");
|
|
180
184
|
const ready = indexes
|
|
181
185
|
.filter((index) => {
|
|
182
186
|
if (indexKeys.includes(index.key)) {
|
|
183
|
-
if ([
|
|
187
|
+
if (["stuck", "failed"].includes(index.status)) {
|
|
184
188
|
throw new Error(`Index '${index.key}' failed!`);
|
|
185
189
|
}
|
|
186
|
-
return index.status ===
|
|
190
|
+
return index.status === "available";
|
|
187
191
|
}
|
|
188
192
|
return false;
|
|
189
193
|
})
|
|
@@ -191,46 +195,48 @@ const awaitPools = {
|
|
|
191
195
|
if (ready.length >= indexKeys.length) {
|
|
192
196
|
return true;
|
|
193
197
|
}
|
|
194
|
-
await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE));
|
|
198
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_DEBOUNCE));
|
|
195
199
|
return await awaitPools.expectIndexes(databaseId, collectionId, indexKeys, iteration + 1);
|
|
196
200
|
},
|
|
197
201
|
};
|
|
198
202
|
const getConfirmation = async () => {
|
|
199
|
-
if (
|
|
203
|
+
if (cliConfig.force) {
|
|
200
204
|
return true;
|
|
201
205
|
}
|
|
202
206
|
async function fixConfirmation() {
|
|
203
|
-
const answers = await
|
|
204
|
-
if (answers.changes !==
|
|
207
|
+
const answers = await inquirer.prompt(questionPushChangesConfirmation);
|
|
208
|
+
if (answers.changes !== "YES" && answers.changes !== "NO") {
|
|
205
209
|
return await fixConfirmation();
|
|
206
210
|
}
|
|
207
211
|
return answers.changes;
|
|
208
212
|
}
|
|
209
|
-
let answers = await
|
|
210
|
-
if (answers.changes !==
|
|
213
|
+
let answers = await inquirer.prompt(questionPushChanges);
|
|
214
|
+
if (answers.changes !== "YES" && answers.changes !== "NO") {
|
|
211
215
|
answers.changes = await fixConfirmation();
|
|
212
216
|
}
|
|
213
|
-
if (answers.changes ===
|
|
217
|
+
if (answers.changes === "YES") {
|
|
214
218
|
return true;
|
|
215
219
|
}
|
|
216
|
-
|
|
220
|
+
warn("Skipping push action. Changes were not applied.");
|
|
217
221
|
return false;
|
|
218
222
|
};
|
|
219
|
-
const isEmpty = (value) =>
|
|
220
|
-
|
|
221
|
-
(
|
|
223
|
+
const isEmpty = (value) => value === null ||
|
|
224
|
+
value === undefined ||
|
|
225
|
+
(typeof value === "string" && value.trim().length === 0) ||
|
|
226
|
+
(Array.isArray(value) && value.length === 0);
|
|
227
|
+
const approveChanges = async (resource, resourceGetFunction, keys, resourceName, resourcePlural, skipKeys = [], secondId = "", secondResourceName = "") => {
|
|
228
|
+
log("Checking for changes ...");
|
|
222
229
|
const changes = [];
|
|
223
230
|
await Promise.all(resource.map(async (localResource) => {
|
|
224
231
|
try {
|
|
225
232
|
const options = {
|
|
226
|
-
[resourceName]: localResource[
|
|
227
|
-
parseOutput: false,
|
|
233
|
+
[resourceName]: localResource["$id"],
|
|
228
234
|
};
|
|
229
|
-
if (secondId !==
|
|
235
|
+
if (secondId !== "" && secondResourceName !== "") {
|
|
230
236
|
options[secondResourceName] = localResource[secondId];
|
|
231
237
|
}
|
|
232
238
|
const remoteResource = await resourceGetFunction(options);
|
|
233
|
-
for (let [key, value] of Object.entries(
|
|
239
|
+
for (let [key, value] of Object.entries(whitelistKeys(remoteResource, keys))) {
|
|
234
240
|
if (skipKeys.includes(key)) {
|
|
235
241
|
continue;
|
|
236
242
|
}
|
|
@@ -240,19 +246,19 @@ const approveChanges = async (resource, resourceGetFunction, keys, resourceName,
|
|
|
240
246
|
if (Array.isArray(value) && Array.isArray(localResource[key])) {
|
|
241
247
|
if (JSON.stringify(value) !== JSON.stringify(localResource[key])) {
|
|
242
248
|
changes.push({
|
|
243
|
-
id: localResource[
|
|
249
|
+
id: localResource["$id"],
|
|
244
250
|
key,
|
|
245
|
-
remote:
|
|
246
|
-
local:
|
|
251
|
+
remote: chalk.red(value.join("\n")),
|
|
252
|
+
local: chalk.green(localResource[key].join("\n")),
|
|
247
253
|
});
|
|
248
254
|
}
|
|
249
255
|
}
|
|
250
256
|
else if (value !== localResource[key]) {
|
|
251
257
|
changes.push({
|
|
252
|
-
id: localResource[
|
|
258
|
+
id: localResource["$id"],
|
|
253
259
|
key,
|
|
254
|
-
remote:
|
|
255
|
-
local:
|
|
260
|
+
remote: chalk.red(value),
|
|
261
|
+
local: chalk.green(localResource[key]),
|
|
256
262
|
});
|
|
257
263
|
}
|
|
258
264
|
}
|
|
@@ -266,18 +272,27 @@ const approveChanges = async (resource, resourceGetFunction, keys, resourceName,
|
|
|
266
272
|
if (changes.length === 0) {
|
|
267
273
|
return true;
|
|
268
274
|
}
|
|
269
|
-
|
|
275
|
+
drawTable(changes);
|
|
270
276
|
if ((await getConfirmation()) === true) {
|
|
271
277
|
return true;
|
|
272
278
|
}
|
|
273
|
-
|
|
279
|
+
success(`Successfully pushed 0 ${resourcePlural}.`);
|
|
274
280
|
return false;
|
|
275
281
|
};
|
|
276
282
|
const getObjectChanges = (remote, local, index, what) => {
|
|
277
283
|
const changes = [];
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
284
|
+
const remoteNested = remote[index];
|
|
285
|
+
const localNested = local[index];
|
|
286
|
+
if (remoteNested &&
|
|
287
|
+
localNested &&
|
|
288
|
+
typeof remoteNested === "object" &&
|
|
289
|
+
!Array.isArray(remoteNested) &&
|
|
290
|
+
typeof localNested === "object" &&
|
|
291
|
+
!Array.isArray(localNested)) {
|
|
292
|
+
const remoteObj = remoteNested;
|
|
293
|
+
const localObj = localNested;
|
|
294
|
+
for (const [service, status] of Object.entries(remoteObj)) {
|
|
295
|
+
const localValue = localObj[service];
|
|
281
296
|
let valuesEqual = false;
|
|
282
297
|
if (Array.isArray(status) && Array.isArray(localValue)) {
|
|
283
298
|
valuesEqual = JSON.stringify(status) === JSON.stringify(localValue);
|
|
@@ -286,48 +301,51 @@ const getObjectChanges = (remote, local, index, what) => {
|
|
|
286
301
|
valuesEqual = status === localValue;
|
|
287
302
|
}
|
|
288
303
|
if (!valuesEqual) {
|
|
289
|
-
changes.push({
|
|
304
|
+
changes.push({
|
|
305
|
+
group: what,
|
|
306
|
+
setting: service,
|
|
307
|
+
remote: chalk.red(String(status ?? "")),
|
|
308
|
+
local: chalk.green(String(localValue ?? "")),
|
|
309
|
+
});
|
|
290
310
|
}
|
|
291
311
|
}
|
|
292
312
|
}
|
|
293
313
|
return changes;
|
|
294
314
|
};
|
|
295
|
-
const createAttribute = (databaseId, collectionId, attribute) => {
|
|
315
|
+
const createAttribute = async (databaseId, collectionId, attribute) => {
|
|
316
|
+
const databasesService = await getDatabasesService();
|
|
296
317
|
switch (attribute.type) {
|
|
297
|
-
case
|
|
318
|
+
case "string":
|
|
298
319
|
switch (attribute.format) {
|
|
299
|
-
case
|
|
300
|
-
return
|
|
320
|
+
case "email":
|
|
321
|
+
return databasesService.createEmailAttribute({
|
|
301
322
|
databaseId,
|
|
302
323
|
collectionId,
|
|
303
324
|
key: attribute.key,
|
|
304
325
|
required: attribute.required,
|
|
305
326
|
xdefault: attribute.default,
|
|
306
327
|
array: attribute.array,
|
|
307
|
-
parseOutput: false
|
|
308
328
|
});
|
|
309
|
-
case
|
|
310
|
-
return
|
|
329
|
+
case "url":
|
|
330
|
+
return databasesService.createUrlAttribute({
|
|
311
331
|
databaseId,
|
|
312
332
|
collectionId,
|
|
313
333
|
key: attribute.key,
|
|
314
334
|
required: attribute.required,
|
|
315
335
|
xdefault: attribute.default,
|
|
316
336
|
array: attribute.array,
|
|
317
|
-
parseOutput: false
|
|
318
337
|
});
|
|
319
|
-
case
|
|
320
|
-
return
|
|
338
|
+
case "ip":
|
|
339
|
+
return databasesService.createIpAttribute({
|
|
321
340
|
databaseId,
|
|
322
341
|
collectionId,
|
|
323
342
|
key: attribute.key,
|
|
324
343
|
required: attribute.required,
|
|
325
344
|
xdefault: attribute.default,
|
|
326
345
|
array: attribute.array,
|
|
327
|
-
parseOutput: false
|
|
328
346
|
});
|
|
329
|
-
case
|
|
330
|
-
return
|
|
347
|
+
case "enum":
|
|
348
|
+
return databasesService.createEnumAttribute({
|
|
331
349
|
databaseId,
|
|
332
350
|
collectionId,
|
|
333
351
|
key: attribute.key,
|
|
@@ -335,10 +353,9 @@ const createAttribute = (databaseId, collectionId, attribute) => {
|
|
|
335
353
|
required: attribute.required,
|
|
336
354
|
xdefault: attribute.default,
|
|
337
355
|
array: attribute.array,
|
|
338
|
-
parseOutput: false
|
|
339
356
|
});
|
|
340
357
|
default:
|
|
341
|
-
return
|
|
358
|
+
return databasesService.createStringAttribute({
|
|
342
359
|
databaseId,
|
|
343
360
|
collectionId,
|
|
344
361
|
key: attribute.key,
|
|
@@ -347,11 +364,10 @@ const createAttribute = (databaseId, collectionId, attribute) => {
|
|
|
347
364
|
xdefault: attribute.default,
|
|
348
365
|
array: attribute.array,
|
|
349
366
|
encrypt: attribute.encrypt,
|
|
350
|
-
parseOutput: false
|
|
351
367
|
});
|
|
352
368
|
}
|
|
353
|
-
case
|
|
354
|
-
return
|
|
369
|
+
case "integer":
|
|
370
|
+
return databasesService.createIntegerAttribute({
|
|
355
371
|
databaseId,
|
|
356
372
|
collectionId,
|
|
357
373
|
key: attribute.key,
|
|
@@ -360,10 +376,9 @@ const createAttribute = (databaseId, collectionId, attribute) => {
|
|
|
360
376
|
max: attribute.max,
|
|
361
377
|
xdefault: attribute.default,
|
|
362
378
|
array: attribute.array,
|
|
363
|
-
parseOutput: false
|
|
364
379
|
});
|
|
365
|
-
case
|
|
366
|
-
return
|
|
380
|
+
case "double":
|
|
381
|
+
return databasesService.createFloatAttribute({
|
|
367
382
|
databaseId,
|
|
368
383
|
collectionId,
|
|
369
384
|
key: attribute.key,
|
|
@@ -372,30 +387,27 @@ const createAttribute = (databaseId, collectionId, attribute) => {
|
|
|
372
387
|
max: attribute.max,
|
|
373
388
|
xdefault: attribute.default,
|
|
374
389
|
array: attribute.array,
|
|
375
|
-
parseOutput: false
|
|
376
390
|
});
|
|
377
|
-
case
|
|
378
|
-
return
|
|
391
|
+
case "boolean":
|
|
392
|
+
return databasesService.createBooleanAttribute({
|
|
379
393
|
databaseId,
|
|
380
394
|
collectionId,
|
|
381
395
|
key: attribute.key,
|
|
382
396
|
required: attribute.required,
|
|
383
397
|
xdefault: attribute.default,
|
|
384
398
|
array: attribute.array,
|
|
385
|
-
parseOutput: false
|
|
386
399
|
});
|
|
387
|
-
case
|
|
388
|
-
return
|
|
400
|
+
case "datetime":
|
|
401
|
+
return databasesService.createDatetimeAttribute({
|
|
389
402
|
databaseId,
|
|
390
403
|
collectionId,
|
|
391
404
|
key: attribute.key,
|
|
392
405
|
required: attribute.required,
|
|
393
406
|
xdefault: attribute.default,
|
|
394
407
|
array: attribute.array,
|
|
395
|
-
parseOutput: false
|
|
396
408
|
});
|
|
397
|
-
case
|
|
398
|
-
return
|
|
409
|
+
case "relationship":
|
|
410
|
+
return databasesService.createRelationshipAttribute({
|
|
399
411
|
databaseId,
|
|
400
412
|
collectionId,
|
|
401
413
|
relatedCollectionId: attribute.relatedTable ?? attribute.relatedCollection,
|
|
@@ -404,98 +416,84 @@ const createAttribute = (databaseId, collectionId, attribute) => {
|
|
|
404
416
|
key: attribute.key,
|
|
405
417
|
twoWayKey: attribute.twoWayKey,
|
|
406
418
|
onDelete: attribute.onDelete,
|
|
407
|
-
parseOutput: false
|
|
408
419
|
});
|
|
409
|
-
case
|
|
410
|
-
return
|
|
420
|
+
case "point":
|
|
421
|
+
return databasesService.createPointAttribute({
|
|
411
422
|
databaseId,
|
|
412
423
|
collectionId,
|
|
413
424
|
key: attribute.key,
|
|
414
425
|
required: attribute.required,
|
|
415
426
|
xdefault: attribute.default,
|
|
416
|
-
parseOutput: false
|
|
417
427
|
});
|
|
418
|
-
case
|
|
419
|
-
return
|
|
428
|
+
case "linestring":
|
|
429
|
+
return databasesService.createLineAttribute({
|
|
420
430
|
databaseId,
|
|
421
431
|
collectionId,
|
|
422
432
|
key: attribute.key,
|
|
423
433
|
required: attribute.required,
|
|
424
434
|
xdefault: attribute.default,
|
|
425
|
-
parseOutput: false
|
|
426
435
|
});
|
|
427
|
-
case
|
|
428
|
-
return
|
|
436
|
+
case "polygon":
|
|
437
|
+
return databasesService.createPolygonAttribute({
|
|
429
438
|
databaseId,
|
|
430
439
|
collectionId,
|
|
431
440
|
key: attribute.key,
|
|
432
441
|
required: attribute.required,
|
|
433
442
|
xdefault: attribute.default,
|
|
434
|
-
parseOutput: false
|
|
435
443
|
});
|
|
436
444
|
default:
|
|
437
445
|
throw new Error(`Unsupported attribute type: ${attribute.type}`);
|
|
438
446
|
}
|
|
439
447
|
};
|
|
440
|
-
const updateAttribute = (databaseId, collectionId, attribute) => {
|
|
448
|
+
const updateAttribute = async (databaseId, collectionId, attribute) => {
|
|
449
|
+
const databasesService = await getDatabasesService();
|
|
441
450
|
switch (attribute.type) {
|
|
442
|
-
case
|
|
451
|
+
case "string":
|
|
443
452
|
switch (attribute.format) {
|
|
444
|
-
case
|
|
445
|
-
return
|
|
453
|
+
case "email":
|
|
454
|
+
return databasesService.updateEmailAttribute({
|
|
446
455
|
databaseId,
|
|
447
456
|
collectionId,
|
|
448
457
|
key: attribute.key,
|
|
449
458
|
required: attribute.required,
|
|
450
459
|
xdefault: attribute.default,
|
|
451
|
-
array: attribute.array,
|
|
452
|
-
parseOutput: false
|
|
453
460
|
});
|
|
454
|
-
case
|
|
455
|
-
return
|
|
461
|
+
case "url":
|
|
462
|
+
return databasesService.updateUrlAttribute({
|
|
456
463
|
databaseId,
|
|
457
464
|
collectionId,
|
|
458
465
|
key: attribute.key,
|
|
459
466
|
required: attribute.required,
|
|
460
467
|
xdefault: attribute.default,
|
|
461
|
-
array: attribute.array,
|
|
462
|
-
parseOutput: false
|
|
463
468
|
});
|
|
464
|
-
case
|
|
465
|
-
return
|
|
469
|
+
case "ip":
|
|
470
|
+
return databasesService.updateIpAttribute({
|
|
466
471
|
databaseId,
|
|
467
472
|
collectionId,
|
|
468
473
|
key: attribute.key,
|
|
469
474
|
required: attribute.required,
|
|
470
475
|
xdefault: attribute.default,
|
|
471
|
-
array: attribute.array,
|
|
472
|
-
parseOutput: false
|
|
473
476
|
});
|
|
474
|
-
case
|
|
475
|
-
return
|
|
477
|
+
case "enum":
|
|
478
|
+
return databasesService.updateEnumAttribute({
|
|
476
479
|
databaseId,
|
|
477
480
|
collectionId,
|
|
478
481
|
key: attribute.key,
|
|
479
482
|
elements: attribute.elements,
|
|
480
483
|
required: attribute.required,
|
|
481
484
|
xdefault: attribute.default,
|
|
482
|
-
array: attribute.array,
|
|
483
|
-
parseOutput: false
|
|
484
485
|
});
|
|
485
486
|
default:
|
|
486
|
-
return
|
|
487
|
+
return databasesService.updateStringAttribute({
|
|
487
488
|
databaseId,
|
|
488
489
|
collectionId,
|
|
489
490
|
key: attribute.key,
|
|
490
|
-
size: attribute.size,
|
|
491
491
|
required: attribute.required,
|
|
492
492
|
xdefault: attribute.default,
|
|
493
|
-
array: attribute.array,
|
|
494
|
-
parseOutput: false
|
|
495
493
|
});
|
|
496
494
|
}
|
|
497
|
-
case
|
|
498
|
-
return
|
|
495
|
+
case "integer":
|
|
496
|
+
return databasesService.updateIntegerAttribute({
|
|
499
497
|
databaseId,
|
|
500
498
|
collectionId,
|
|
501
499
|
key: attribute.key,
|
|
@@ -503,11 +501,9 @@ const updateAttribute = (databaseId, collectionId, attribute) => {
|
|
|
503
501
|
min: attribute.min,
|
|
504
502
|
max: attribute.max,
|
|
505
503
|
xdefault: attribute.default,
|
|
506
|
-
array: attribute.array,
|
|
507
|
-
parseOutput: false
|
|
508
504
|
});
|
|
509
|
-
case
|
|
510
|
-
return
|
|
505
|
+
case "double":
|
|
506
|
+
return databasesService.updateFloatAttribute({
|
|
511
507
|
databaseId,
|
|
512
508
|
collectionId,
|
|
513
509
|
key: attribute.key,
|
|
@@ -515,106 +511,85 @@ const updateAttribute = (databaseId, collectionId, attribute) => {
|
|
|
515
511
|
min: attribute.min,
|
|
516
512
|
max: attribute.max,
|
|
517
513
|
xdefault: attribute.default,
|
|
518
|
-
array: attribute.array,
|
|
519
|
-
parseOutput: false
|
|
520
514
|
});
|
|
521
|
-
case
|
|
522
|
-
return
|
|
515
|
+
case "boolean":
|
|
516
|
+
return databasesService.updateBooleanAttribute({
|
|
523
517
|
databaseId,
|
|
524
518
|
collectionId,
|
|
525
519
|
key: attribute.key,
|
|
526
520
|
required: attribute.required,
|
|
527
521
|
xdefault: attribute.default,
|
|
528
|
-
array: attribute.array,
|
|
529
|
-
parseOutput: false
|
|
530
522
|
});
|
|
531
|
-
case
|
|
532
|
-
return
|
|
523
|
+
case "datetime":
|
|
524
|
+
return databasesService.updateDatetimeAttribute({
|
|
533
525
|
databaseId,
|
|
534
526
|
collectionId,
|
|
535
527
|
key: attribute.key,
|
|
536
528
|
required: attribute.required,
|
|
537
529
|
xdefault: attribute.default,
|
|
538
|
-
array: attribute.array,
|
|
539
|
-
parseOutput: false
|
|
540
530
|
});
|
|
541
|
-
case
|
|
542
|
-
return
|
|
531
|
+
case "relationship":
|
|
532
|
+
return databasesService.updateRelationshipAttribute({
|
|
543
533
|
databaseId,
|
|
544
534
|
collectionId,
|
|
545
|
-
relatedCollectionId: attribute.relatedTable ?? attribute.relatedCollection,
|
|
546
|
-
type: attribute.relationType,
|
|
547
|
-
twoWay: attribute.twoWay,
|
|
548
535
|
key: attribute.key,
|
|
549
|
-
twoWayKey: attribute.twoWayKey,
|
|
550
536
|
onDelete: attribute.onDelete,
|
|
551
|
-
parseOutput: false
|
|
552
537
|
});
|
|
553
|
-
case
|
|
554
|
-
return
|
|
538
|
+
case "point":
|
|
539
|
+
return databasesService.updatePointAttribute({
|
|
555
540
|
databaseId,
|
|
556
541
|
collectionId,
|
|
557
542
|
key: attribute.key,
|
|
558
543
|
required: attribute.required,
|
|
559
544
|
xdefault: attribute.default,
|
|
560
|
-
parseOutput: false
|
|
561
545
|
});
|
|
562
|
-
case
|
|
563
|
-
return
|
|
546
|
+
case "linestring":
|
|
547
|
+
return databasesService.updateLineAttribute({
|
|
564
548
|
databaseId,
|
|
565
549
|
collectionId,
|
|
566
550
|
key: attribute.key,
|
|
567
551
|
required: attribute.required,
|
|
568
552
|
xdefault: attribute.default,
|
|
569
|
-
parseOutput: false
|
|
570
553
|
});
|
|
571
|
-
case
|
|
572
|
-
return
|
|
554
|
+
case "polygon":
|
|
555
|
+
return databasesService.updatePolygonAttribute({
|
|
573
556
|
databaseId,
|
|
574
557
|
collectionId,
|
|
575
558
|
key: attribute.key,
|
|
576
559
|
required: attribute.required,
|
|
577
560
|
xdefault: attribute.default,
|
|
578
|
-
parseOutput: false
|
|
579
561
|
});
|
|
580
562
|
default:
|
|
581
563
|
throw new Error(`Unsupported attribute type: ${attribute.type}`);
|
|
582
564
|
}
|
|
583
565
|
};
|
|
584
566
|
const deleteAttribute = async (collection, attribute, isIndex = false) => {
|
|
585
|
-
|
|
567
|
+
log(`Deleting ${isIndex ? "index" : "attribute"} ${attribute.key} of ${collection.name} ( ${collection["$id"]} )`);
|
|
568
|
+
const databasesService = await getDatabasesService();
|
|
586
569
|
if (isIndex) {
|
|
587
|
-
await (
|
|
588
|
-
databaseId: collection['databaseId'],
|
|
589
|
-
collectionId: collection['$id'],
|
|
590
|
-
key: attribute.key,
|
|
591
|
-
parseOutput: false
|
|
592
|
-
});
|
|
570
|
+
await databasesService.deleteIndex(collection["databaseId"], collection["$id"], attribute.key);
|
|
593
571
|
return;
|
|
594
572
|
}
|
|
595
|
-
await (
|
|
596
|
-
databaseId: collection['databaseId'],
|
|
597
|
-
collectionId: collection['$id'],
|
|
598
|
-
key: attribute.key,
|
|
599
|
-
parseOutput: false
|
|
600
|
-
});
|
|
573
|
+
await databasesService.deleteAttribute(collection["databaseId"], collection["$id"], attribute.key);
|
|
601
574
|
};
|
|
602
575
|
const isEqual = (a, b) => {
|
|
603
576
|
if (a === b)
|
|
604
577
|
return true;
|
|
605
|
-
if (a && b && typeof a ===
|
|
606
|
-
if (a.constructor &&
|
|
607
|
-
|
|
578
|
+
if (a && b && typeof a === "object" && typeof b === "object") {
|
|
579
|
+
if (a.constructor &&
|
|
580
|
+
a.constructor.name === "BigNumber" &&
|
|
581
|
+
b.constructor &&
|
|
582
|
+
b.constructor.name === "BigNumber") {
|
|
608
583
|
return a.eq(b);
|
|
609
584
|
}
|
|
610
|
-
if (typeof a.equals ===
|
|
585
|
+
if (typeof a.equals === "function") {
|
|
611
586
|
return a.equals(b);
|
|
612
587
|
}
|
|
613
|
-
if (typeof a.eq ===
|
|
588
|
+
if (typeof a.eq === "function") {
|
|
614
589
|
return a.eq(b);
|
|
615
590
|
}
|
|
616
591
|
}
|
|
617
|
-
if (typeof a ===
|
|
592
|
+
if (typeof a === "number" && typeof b === "number") {
|
|
618
593
|
if (isNaN(a) && isNaN(b))
|
|
619
594
|
return true;
|
|
620
595
|
if (!isFinite(a) && !isFinite(b))
|
|
@@ -629,13 +604,13 @@ const compareAttribute = (remote, local, reason, key) => {
|
|
|
629
604
|
}
|
|
630
605
|
if (Array.isArray(remote) && Array.isArray(local)) {
|
|
631
606
|
if (JSON.stringify(remote) !== JSON.stringify(local)) {
|
|
632
|
-
const bol = reason ===
|
|
633
|
-
reason += `${bol}${key} changed from ${
|
|
607
|
+
const bol = reason === "" ? "" : "\n";
|
|
608
|
+
reason += `${bol}${key} changed from ${chalk.red(remote)} to ${chalk.green(local)}`;
|
|
634
609
|
}
|
|
635
610
|
}
|
|
636
611
|
else if (!isEqual(remote, local)) {
|
|
637
|
-
const bol = reason ===
|
|
638
|
-
reason += `${bol}${key} changed from ${
|
|
612
|
+
const bol = reason === "" ? "" : "\n";
|
|
613
|
+
reason += `${bol}${key} changed from ${chalk.red(remote)} to ${chalk.green(local)}`;
|
|
639
614
|
}
|
|
640
615
|
return reason;
|
|
641
616
|
};
|
|
@@ -647,12 +622,12 @@ const checkAttributeChanges = (remote, local, collection, recreating = true) =>
|
|
|
647
622
|
if (local === undefined) {
|
|
648
623
|
return undefined;
|
|
649
624
|
}
|
|
650
|
-
const keyName = `${
|
|
651
|
-
const action =
|
|
652
|
-
let reason =
|
|
625
|
+
const keyName = `${chalk.yellow(local.key)} in ${collection.name} (${collection["$id"]})`;
|
|
626
|
+
const action = chalk.cyan(recreating ? "recreating" : "changing");
|
|
627
|
+
let reason = "";
|
|
653
628
|
let attribute = recreating ? remote : local;
|
|
654
629
|
for (let key of Object.keys(remote)) {
|
|
655
|
-
if (!
|
|
630
|
+
if (!KeysAttributes.has(key)) {
|
|
656
631
|
continue;
|
|
657
632
|
}
|
|
658
633
|
if (changeableKeys.includes(key)) {
|
|
@@ -666,7 +641,9 @@ const checkAttributeChanges = (remote, local, collection, recreating = true) =>
|
|
|
666
641
|
}
|
|
667
642
|
reason = compareAttribute(remote[key], local[key], reason, key);
|
|
668
643
|
}
|
|
669
|
-
return reason ===
|
|
644
|
+
return reason === ""
|
|
645
|
+
? undefined
|
|
646
|
+
: { key: keyName, attribute, reason, action };
|
|
670
647
|
};
|
|
671
648
|
/**
|
|
672
649
|
* Check if attributes contain the given attribute
|
|
@@ -674,10 +651,12 @@ const checkAttributeChanges = (remote, local, collection, recreating = true) =>
|
|
|
674
651
|
const attributesContains = (attribute, attributes) => attributes.find((attr) => attr.key === attribute.key);
|
|
675
652
|
const generateChangesObject = (attribute, collection, isAdding) => {
|
|
676
653
|
return {
|
|
677
|
-
key: `${
|
|
654
|
+
key: `${chalk.yellow(attribute.key)} in ${collection.name} (${collection["$id"]})`,
|
|
678
655
|
attribute: attribute,
|
|
679
|
-
reason: isAdding
|
|
680
|
-
|
|
656
|
+
reason: isAdding
|
|
657
|
+
? "Field isn't present on the remote server"
|
|
658
|
+
: "Field isn't present on the appwrite.config.json file",
|
|
659
|
+
action: isAdding ? chalk.green("adding") : chalk.red("deleting"),
|
|
681
660
|
};
|
|
682
661
|
};
|
|
683
662
|
/**
|
|
@@ -685,32 +664,41 @@ const generateChangesObject = (attribute, collection, isAdding) => {
|
|
|
685
664
|
* return list of attributes to create
|
|
686
665
|
*/
|
|
687
666
|
const attributesToCreate = async (remoteAttributes, localAttributes, collection, isIndex = false) => {
|
|
688
|
-
const deleting = remoteAttributes
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
const
|
|
692
|
-
.filter(attribute => attribute
|
|
693
|
-
.
|
|
667
|
+
const deleting = remoteAttributes
|
|
668
|
+
.filter((attribute) => !attributesContains(attribute, localAttributes))
|
|
669
|
+
.map((attr) => generateChangesObject(attr, collection, false));
|
|
670
|
+
const adding = localAttributes
|
|
671
|
+
.filter((attribute) => !attributesContains(attribute, remoteAttributes))
|
|
672
|
+
.map((attr) => generateChangesObject(attr, collection, true));
|
|
673
|
+
const conflicts = remoteAttributes
|
|
674
|
+
.map((attribute) => checkAttributeChanges(attribute, attributesContains(attribute, localAttributes), collection))
|
|
675
|
+
.filter((attribute) => attribute !== undefined);
|
|
676
|
+
const changes = remoteAttributes
|
|
677
|
+
.map((attribute) => checkAttributeChanges(attribute, attributesContains(attribute, localAttributes), collection, false))
|
|
678
|
+
.filter((attribute) => attribute !== undefined)
|
|
679
|
+
.filter((attribute) => conflicts.filter((attr) => attribute.key === attr.key).length !== 1);
|
|
694
680
|
let changedAttributes = [];
|
|
695
681
|
const changing = [...deleting, ...adding, ...conflicts, ...changes];
|
|
696
682
|
if (changing.length === 0) {
|
|
697
683
|
return changedAttributes;
|
|
698
684
|
}
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
685
|
+
log(!cliConfig.force
|
|
686
|
+
? "There are pending changes in your collection deployment"
|
|
687
|
+
: "List of applied changes");
|
|
688
|
+
drawTable(changing.map((change) => {
|
|
689
|
+
return { Key: change.key, Action: change.action, Reason: change.reason };
|
|
702
690
|
}));
|
|
703
|
-
if (!
|
|
691
|
+
if (!cliConfig.force) {
|
|
704
692
|
if (deleting.length > 0 && !isIndex) {
|
|
705
|
-
console.log(`${
|
|
706
|
-
console.log(`${
|
|
707
|
-
console.log(`${
|
|
693
|
+
console.log(`${chalk.red("------------------------------------------------------")}`);
|
|
694
|
+
console.log(`${chalk.red("| WARNING: Attribute deletion may cause loss of data |")}`);
|
|
695
|
+
console.log(`${chalk.red("------------------------------------------------------")}`);
|
|
708
696
|
console.log();
|
|
709
697
|
}
|
|
710
698
|
if (conflicts.length > 0 && !isIndex) {
|
|
711
|
-
console.log(`${
|
|
712
|
-
console.log(`${
|
|
713
|
-
console.log(`${
|
|
699
|
+
console.log(`${chalk.red("--------------------------------------------------------")}`);
|
|
700
|
+
console.log(`${chalk.red("| WARNING: Attribute recreation may cause loss of data |")}`);
|
|
701
|
+
console.log(`${chalk.red("--------------------------------------------------------")}`);
|
|
714
702
|
console.log();
|
|
715
703
|
}
|
|
716
704
|
if ((await getConfirmation()) !== true) {
|
|
@@ -724,13 +712,16 @@ const attributesToCreate = async (remoteAttributes, localAttributes, collection,
|
|
|
724
712
|
}
|
|
725
713
|
if (changes.length > 0) {
|
|
726
714
|
changedAttributes = changes.map((change) => change.attribute);
|
|
727
|
-
await Promise.all(changedAttributes.map((changed) => updateAttribute(collection[
|
|
715
|
+
await Promise.all(changedAttributes.map((changed) => updateAttribute(collection["databaseId"], collection["$id"], changed)));
|
|
728
716
|
}
|
|
729
717
|
const deletingAttributes = deleting.map((change) => change.attribute);
|
|
730
718
|
await Promise.all(deletingAttributes.map((attribute) => deleteAttribute(collection, attribute, isIndex)));
|
|
731
|
-
const attributeKeys = [
|
|
719
|
+
const attributeKeys = [
|
|
720
|
+
...remoteAttributes.map((attribute) => attribute.key),
|
|
721
|
+
...deletingAttributes.map((attribute) => attribute.key),
|
|
722
|
+
];
|
|
732
723
|
if (attributeKeys.length) {
|
|
733
|
-
const deleteAttributesPoolStatus = await awaitPools.deleteAttributes(collection[
|
|
724
|
+
const deleteAttributesPoolStatus = await awaitPools.deleteAttributes(collection["databaseId"], collection["$id"], attributeKeys);
|
|
734
725
|
if (!deleteAttributesPoolStatus) {
|
|
735
726
|
throw new Error("Attribute deletion timed out.");
|
|
736
727
|
}
|
|
@@ -738,49 +729,46 @@ const attributesToCreate = async (remoteAttributes, localAttributes, collection,
|
|
|
738
729
|
return localAttributes.filter((attribute) => !attributesContains(attribute, remoteAttributes));
|
|
739
730
|
};
|
|
740
731
|
const createIndexes = async (indexes, collection) => {
|
|
741
|
-
|
|
732
|
+
log(`Creating indexes ...`);
|
|
733
|
+
const databasesService = await getDatabasesService();
|
|
742
734
|
for (let index of indexes) {
|
|
743
|
-
await (
|
|
744
|
-
databaseId: collection['databaseId'],
|
|
745
|
-
collectionId: collection['$id'],
|
|
746
|
-
key: index.key,
|
|
747
|
-
type: index.type,
|
|
748
|
-
attributes: index.columns ?? index.attributes,
|
|
749
|
-
orders: index.orders,
|
|
750
|
-
parseOutput: false
|
|
751
|
-
});
|
|
735
|
+
await databasesService.createIndex(collection["databaseId"], collection["$id"], index.key, index.type, index.columns ?? index.attributes, index.orders);
|
|
752
736
|
}
|
|
753
|
-
const result = await awaitPools.expectIndexes(collection[
|
|
737
|
+
const result = await awaitPools.expectIndexes(collection["databaseId"], collection["$id"], indexes.map((index) => index.key));
|
|
754
738
|
if (!result) {
|
|
755
|
-
throw new Error(
|
|
739
|
+
throw new Error("Index creation timed out.");
|
|
756
740
|
}
|
|
757
|
-
|
|
741
|
+
success(`Created ${indexes.length} indexes`);
|
|
758
742
|
};
|
|
759
743
|
const createAttributes = async (attributes, collection) => {
|
|
760
744
|
for (let attribute of attributes) {
|
|
761
|
-
if (attribute.side !==
|
|
762
|
-
await createAttribute(collection[
|
|
745
|
+
if (attribute.side !== "child") {
|
|
746
|
+
await createAttribute(collection["databaseId"], collection["$id"], attribute);
|
|
763
747
|
}
|
|
764
748
|
}
|
|
765
|
-
const result = await awaitPools.expectAttributes(collection[
|
|
749
|
+
const result = await awaitPools.expectAttributes(collection["databaseId"], collection["$id"], collection.attributes
|
|
750
|
+
.filter((attribute) => attribute.side !== "child")
|
|
751
|
+
.map((attribute) => attribute.key));
|
|
766
752
|
if (!result) {
|
|
767
753
|
throw new Error(`Attribute creation timed out.`);
|
|
768
754
|
}
|
|
769
|
-
|
|
755
|
+
success(`Created ${attributes.length} attributes`);
|
|
770
756
|
};
|
|
771
757
|
const createColumns = async (columns, table) => {
|
|
772
758
|
for (let column of columns) {
|
|
773
|
-
if (column.side !==
|
|
774
|
-
await createAttribute(table[
|
|
759
|
+
if (column.side !== "child") {
|
|
760
|
+
await createAttribute(table["databaseId"], table["$id"], column);
|
|
775
761
|
}
|
|
776
762
|
}
|
|
777
|
-
const result = await awaitPools.expectAttributes(table[
|
|
763
|
+
const result = await awaitPools.expectAttributes(table["databaseId"], table["$id"], table.columns
|
|
764
|
+
.filter((column) => column.side !== "child")
|
|
765
|
+
.map((column) => column.key));
|
|
778
766
|
if (!result) {
|
|
779
767
|
throw new Error(`Column creation timed out.`);
|
|
780
768
|
}
|
|
781
|
-
|
|
769
|
+
success(`Created ${columns.length} columns`);
|
|
782
770
|
};
|
|
783
|
-
const pushResources = async () => {
|
|
771
|
+
const pushResources = async ({ skipDeprecated = false, } = {}) => {
|
|
784
772
|
const actions = {
|
|
785
773
|
settings: pushSettings,
|
|
786
774
|
functions: pushFunction,
|
|
@@ -789,184 +777,176 @@ const pushResources = async () => {
|
|
|
789
777
|
tables: pushTable,
|
|
790
778
|
buckets: pushBucket,
|
|
791
779
|
teams: pushTeam,
|
|
792
|
-
messages: pushMessagingTopic
|
|
780
|
+
messages: pushMessagingTopic,
|
|
793
781
|
};
|
|
794
|
-
if (
|
|
782
|
+
if (skipDeprecated) {
|
|
783
|
+
delete actions.collections;
|
|
784
|
+
}
|
|
785
|
+
if (cliConfig.all) {
|
|
795
786
|
for (let action of Object.values(actions)) {
|
|
796
|
-
await action(
|
|
787
|
+
await action();
|
|
797
788
|
}
|
|
798
789
|
}
|
|
799
790
|
else {
|
|
800
|
-
const answers = await
|
|
791
|
+
const answers = await inquirer.prompt(questionsPushResources);
|
|
801
792
|
const action = actions[answers.resource];
|
|
802
793
|
if (action !== undefined) {
|
|
803
|
-
await action(
|
|
794
|
+
await action();
|
|
804
795
|
}
|
|
805
796
|
}
|
|
806
797
|
};
|
|
807
798
|
const pushSettings = async () => {
|
|
808
|
-
|
|
799
|
+
checkDeployConditions(localConfig);
|
|
809
800
|
try {
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
const localSettings = config_1.localConfig.getProject().projectSettings ?? {};
|
|
816
|
-
(0, parser_1.log)('Checking for changes ...');
|
|
801
|
+
const projectsService = await getProjectsService();
|
|
802
|
+
let response = await projectsService.get(localConfig.getProject().projectId);
|
|
803
|
+
const remoteSettings = localConfig.createSettingsObject(response ?? {});
|
|
804
|
+
const localSettings = localConfig.getProject().projectSettings ?? {};
|
|
805
|
+
log("Checking for changes ...");
|
|
817
806
|
const changes = [];
|
|
818
|
-
changes.push(...
|
|
819
|
-
changes.push(...
|
|
820
|
-
changes.push(...
|
|
807
|
+
changes.push(...getObjectChanges(remoteSettings, localSettings, "services", "Service"));
|
|
808
|
+
changes.push(...getObjectChanges(remoteSettings["auth"] ?? {}, localSettings["auth"] ?? {}, "methods", "Auth method"));
|
|
809
|
+
changes.push(...getObjectChanges(remoteSettings["auth"] ?? {}, localSettings["auth"] ?? {}, "security", "Auth security"));
|
|
821
810
|
if (changes.length > 0) {
|
|
822
|
-
|
|
811
|
+
drawTable(changes);
|
|
823
812
|
if ((await getConfirmation()) !== true) {
|
|
824
|
-
|
|
813
|
+
success(`Successfully pushed 0 project settings.`);
|
|
825
814
|
return;
|
|
826
815
|
}
|
|
827
816
|
}
|
|
828
817
|
}
|
|
829
|
-
catch (e) {
|
|
830
|
-
}
|
|
818
|
+
catch (e) { }
|
|
831
819
|
try {
|
|
832
|
-
|
|
833
|
-
const
|
|
834
|
-
const
|
|
835
|
-
const
|
|
820
|
+
log("Pushing project settings ...");
|
|
821
|
+
const projectsService = await getProjectsService();
|
|
822
|
+
const projectId = localConfig.getProject().projectId;
|
|
823
|
+
const projectName = localConfig.getProject().projectName;
|
|
824
|
+
const settings = localConfig.getProject().projectSettings ?? {};
|
|
836
825
|
if (projectName) {
|
|
837
|
-
|
|
838
|
-
await (
|
|
839
|
-
projectId,
|
|
840
|
-
name: projectName,
|
|
841
|
-
parseOutput: false
|
|
842
|
-
});
|
|
826
|
+
log("Applying project name ...");
|
|
827
|
+
await projectsService.update(projectId, projectName);
|
|
843
828
|
}
|
|
844
829
|
if (settings.services) {
|
|
845
|
-
|
|
830
|
+
log("Applying service statuses ...");
|
|
846
831
|
for (let [service, status] of Object.entries(settings.services)) {
|
|
847
|
-
await (
|
|
848
|
-
projectId,
|
|
849
|
-
service,
|
|
850
|
-
status,
|
|
851
|
-
parseOutput: false
|
|
852
|
-
});
|
|
832
|
+
await projectsService.updateServiceStatus(projectId, service, status);
|
|
853
833
|
}
|
|
854
834
|
}
|
|
855
835
|
if (settings.auth) {
|
|
856
836
|
if (settings.auth.security) {
|
|
857
|
-
|
|
858
|
-
await
|
|
859
|
-
await
|
|
860
|
-
await
|
|
861
|
-
await
|
|
862
|
-
await
|
|
863
|
-
await
|
|
864
|
-
await
|
|
865
|
-
await
|
|
837
|
+
log("Applying auth security settings ...");
|
|
838
|
+
await projectsService.updateAuthDuration(projectId, settings.auth.security.duration);
|
|
839
|
+
await projectsService.updateAuthLimit(projectId, settings.auth.security.limit);
|
|
840
|
+
await projectsService.updateAuthSessionsLimit(projectId, settings.auth.security.sessionsLimit);
|
|
841
|
+
await projectsService.updateAuthPasswordDictionary(projectId, settings.auth.security.passwordDictionary);
|
|
842
|
+
await projectsService.updateAuthPasswordHistory(projectId, settings.auth.security.passwordHistory);
|
|
843
|
+
await projectsService.updatePersonalDataCheck(projectId, settings.auth.security.personalDataCheck);
|
|
844
|
+
await projectsService.updateSessionAlerts(projectId, settings.auth.security.sessionAlerts);
|
|
845
|
+
await projectsService.updateMockNumbers(projectId, settings.auth.security.mockNumbers);
|
|
866
846
|
}
|
|
867
847
|
if (settings.auth.methods) {
|
|
868
|
-
|
|
848
|
+
log("Applying auth methods statuses ...");
|
|
869
849
|
for (let [method, status] of Object.entries(settings.auth.methods)) {
|
|
870
|
-
await (
|
|
871
|
-
projectId,
|
|
872
|
-
method,
|
|
873
|
-
status,
|
|
874
|
-
parseOutput: false
|
|
875
|
-
});
|
|
850
|
+
await projectsService.updateAuthStatus(projectId, method, status);
|
|
876
851
|
}
|
|
877
852
|
}
|
|
878
853
|
}
|
|
879
|
-
|
|
854
|
+
success(`Successfully pushed ${chalk.bold("all")} project settings.`);
|
|
880
855
|
}
|
|
881
856
|
catch (e) {
|
|
882
857
|
throw e;
|
|
883
858
|
}
|
|
884
859
|
};
|
|
885
|
-
const pushSite = async ({ siteId, async: asyncDeploy, code, withVariables } = {
|
|
886
|
-
process.chdir(
|
|
860
|
+
const pushSite = async ({ siteId, async: asyncDeploy, code, withVariables, } = {}) => {
|
|
861
|
+
process.chdir(localConfig.configDirectoryPath);
|
|
887
862
|
const siteIds = [];
|
|
888
863
|
if (siteId) {
|
|
889
864
|
siteIds.push(siteId);
|
|
890
865
|
}
|
|
891
|
-
else if (
|
|
892
|
-
|
|
893
|
-
const sites =
|
|
866
|
+
else if (cliConfig.all) {
|
|
867
|
+
checkDeployConditions(localConfig);
|
|
868
|
+
const sites = localConfig.getSites();
|
|
894
869
|
siteIds.push(...sites.map((site) => {
|
|
895
870
|
return site.$id;
|
|
896
871
|
}));
|
|
897
872
|
}
|
|
898
873
|
if (siteIds.length <= 0) {
|
|
899
|
-
const answers = await
|
|
874
|
+
const answers = await inquirer.prompt(questionsPushSites);
|
|
900
875
|
if (answers.sites) {
|
|
901
876
|
siteIds.push(...answers.sites);
|
|
902
877
|
}
|
|
903
878
|
}
|
|
904
879
|
if (siteIds.length === 0) {
|
|
905
|
-
|
|
906
|
-
|
|
880
|
+
log("No sites found.");
|
|
881
|
+
hint("Use 'appwrite pull sites' to synchronize existing one, or use 'appwrite init site' to create a new one.");
|
|
907
882
|
return;
|
|
908
883
|
}
|
|
909
884
|
let sites = siteIds.map((id) => {
|
|
910
|
-
const sites =
|
|
885
|
+
const sites = localConfig.getSites();
|
|
911
886
|
const site = sites.find((s) => s.$id === id);
|
|
912
887
|
if (!site) {
|
|
913
888
|
throw new Error("Site '" + id + "' not found.");
|
|
914
889
|
}
|
|
915
890
|
return site;
|
|
916
891
|
});
|
|
917
|
-
|
|
892
|
+
log("Validating sites ...");
|
|
918
893
|
// Validation is done BEFORE pushing so the deployment process can be run in async with progress update
|
|
919
894
|
for (let site of sites) {
|
|
920
895
|
if (!site.buildCommand) {
|
|
921
|
-
|
|
922
|
-
const answers = await
|
|
896
|
+
log(`Site ${site.name} is missing build command.`);
|
|
897
|
+
const answers = await inquirer.prompt(questionsGetEntrypoint);
|
|
923
898
|
site.buildCommand = answers.entrypoint;
|
|
924
|
-
|
|
899
|
+
localConfig.addSite(site);
|
|
925
900
|
}
|
|
926
901
|
}
|
|
927
|
-
if (!(await approveChanges(sites,
|
|
902
|
+
if (!(await approveChanges(sites, async (args) => {
|
|
903
|
+
const sitesService = await getSitesService();
|
|
904
|
+
return await sitesService.get({ siteId: args.siteId });
|
|
905
|
+
}, KeysSite, "siteId", "sites", ["vars"]))) {
|
|
928
906
|
return;
|
|
929
907
|
}
|
|
930
|
-
|
|
931
|
-
|
|
908
|
+
log("Pushing sites ...");
|
|
909
|
+
Spinner.start(false);
|
|
932
910
|
let successfullyPushed = 0;
|
|
933
911
|
let successfullyDeployed = 0;
|
|
934
912
|
const failedDeployments = [];
|
|
935
913
|
const errors = [];
|
|
936
914
|
await Promise.all(sites.map(async (site) => {
|
|
937
915
|
let response = {};
|
|
938
|
-
const ignore = site.ignore ?
|
|
916
|
+
const ignore = site.ignore ? "appwrite.config.json" : ".gitignore";
|
|
939
917
|
let siteExists = false;
|
|
940
918
|
let deploymentCreated = false;
|
|
941
|
-
const updaterRow = new
|
|
942
|
-
|
|
919
|
+
const updaterRow = new Spinner({
|
|
920
|
+
status: "",
|
|
921
|
+
resource: site.name,
|
|
922
|
+
id: site["$id"],
|
|
923
|
+
end: `Ignoring using: ${ignore}`,
|
|
924
|
+
});
|
|
925
|
+
updaterRow.update({ status: "Getting" }).startSpinner(SPINNER_DOTS);
|
|
926
|
+
const sitesService = await getSitesService();
|
|
943
927
|
try {
|
|
944
|
-
response = await (
|
|
945
|
-
siteId: site['$id'],
|
|
946
|
-
parseOutput: false,
|
|
947
|
-
});
|
|
928
|
+
response = await sitesService.get({ siteId: site["$id"] });
|
|
948
929
|
siteExists = true;
|
|
949
930
|
if (response.framework !== site.framework) {
|
|
950
|
-
updaterRow.fail({
|
|
931
|
+
updaterRow.fail({
|
|
932
|
+
errorMessage: `Framework mismatch! (local=${site.framework},remote=${response.framework}) Please delete remote site or update your appwrite.config.json`,
|
|
933
|
+
});
|
|
951
934
|
return;
|
|
952
935
|
}
|
|
953
|
-
updaterRow.update({ status:
|
|
954
|
-
response = await
|
|
955
|
-
siteId: site[
|
|
936
|
+
updaterRow.update({ status: "Updating" }).replaceSpinner(SPINNER_ARC);
|
|
937
|
+
response = await sitesService.update({
|
|
938
|
+
siteId: site["$id"],
|
|
956
939
|
name: site.name,
|
|
957
940
|
framework: site.framework,
|
|
958
|
-
buildRuntime: site.buildRuntime,
|
|
959
|
-
specification: site.specification,
|
|
960
|
-
timeout: site.timeout,
|
|
961
941
|
enabled: site.enabled,
|
|
962
942
|
logging: site.logging,
|
|
963
|
-
|
|
964
|
-
buildCommand: site.buildCommand,
|
|
943
|
+
timeout: site.timeout,
|
|
965
944
|
installCommand: site.installCommand,
|
|
945
|
+
buildCommand: site.buildCommand,
|
|
966
946
|
outputDirectory: site.outputDirectory,
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
947
|
+
buildRuntime: site.buildRuntime,
|
|
948
|
+
adapter: site.adapter,
|
|
949
|
+
specification: site.specification,
|
|
970
950
|
});
|
|
971
951
|
}
|
|
972
952
|
catch (e) {
|
|
@@ -975,74 +955,79 @@ const pushSite = async ({ siteId, async: asyncDeploy, code, withVariables } = {
|
|
|
975
955
|
}
|
|
976
956
|
else {
|
|
977
957
|
errors.push(e);
|
|
978
|
-
updaterRow.fail({
|
|
958
|
+
updaterRow.fail({
|
|
959
|
+
errorMessage: e.message ?? "General error occurs please try again",
|
|
960
|
+
});
|
|
979
961
|
return;
|
|
980
962
|
}
|
|
981
963
|
}
|
|
982
964
|
if (!siteExists) {
|
|
983
|
-
updaterRow.update({ status:
|
|
965
|
+
updaterRow.update({ status: "Creating" }).replaceSpinner(SPINNER_DOTS);
|
|
984
966
|
try {
|
|
985
|
-
response = await
|
|
967
|
+
response = await sitesService.create({
|
|
986
968
|
siteId: site.$id,
|
|
987
969
|
name: site.name,
|
|
988
970
|
framework: site.framework,
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
971
|
+
enabled: site.enabled,
|
|
972
|
+
logging: site.logging,
|
|
973
|
+
timeout: site.timeout,
|
|
992
974
|
installCommand: site.installCommand,
|
|
975
|
+
buildCommand: site.buildCommand,
|
|
993
976
|
outputDirectory: site.outputDirectory,
|
|
994
|
-
|
|
977
|
+
buildRuntime: site.buildRuntime,
|
|
995
978
|
adapter: site.adapter,
|
|
996
|
-
|
|
997
|
-
enabled: site.enabled,
|
|
998
|
-
logging: site.logging,
|
|
999
|
-
parseOutput: false
|
|
979
|
+
specification: site.specification,
|
|
1000
980
|
});
|
|
1001
|
-
let domain =
|
|
981
|
+
let domain = "";
|
|
1002
982
|
try {
|
|
1003
|
-
const
|
|
1004
|
-
|
|
983
|
+
const consoleService = await getConsoleService();
|
|
984
|
+
const variables = await consoleService.variables();
|
|
985
|
+
domain = ID.unique() + "." + variables["_APP_DOMAIN_SITES"];
|
|
1005
986
|
}
|
|
1006
987
|
catch (error) {
|
|
1007
|
-
console.error(
|
|
988
|
+
console.error("Error fetching console variables.");
|
|
1008
989
|
throw error;
|
|
1009
990
|
}
|
|
1010
991
|
try {
|
|
1011
|
-
const
|
|
1012
|
-
|
|
1013
|
-
siteId: site.$id
|
|
1014
|
-
});
|
|
992
|
+
const proxyService = await getProxyService();
|
|
993
|
+
const rule = await proxyService.createSiteRule(domain, site.$id);
|
|
1015
994
|
}
|
|
1016
995
|
catch (error) {
|
|
1017
|
-
console.error(
|
|
996
|
+
console.error("Error creating site rule.");
|
|
1018
997
|
throw error;
|
|
1019
998
|
}
|
|
1020
|
-
updaterRow.update({ status:
|
|
999
|
+
updaterRow.update({ status: "Created" });
|
|
1021
1000
|
}
|
|
1022
1001
|
catch (e) {
|
|
1023
1002
|
errors.push(e);
|
|
1024
|
-
updaterRow.fail({
|
|
1003
|
+
updaterRow.fail({
|
|
1004
|
+
errorMessage: e.message ?? "General error occurs please try again",
|
|
1005
|
+
});
|
|
1025
1006
|
return;
|
|
1026
1007
|
}
|
|
1027
1008
|
}
|
|
1028
1009
|
if (withVariables) {
|
|
1029
|
-
updaterRow
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
}
|
|
1010
|
+
updaterRow
|
|
1011
|
+
.update({ status: "Creating variables" })
|
|
1012
|
+
.replaceSpinner(SPINNER_ARC);
|
|
1013
|
+
const sitesService = await getSitesService();
|
|
1014
|
+
const { variables } = await paginate(async (args) => {
|
|
1015
|
+
return await sitesService.listVariables({ siteId: args.siteId });
|
|
1016
|
+
}, {
|
|
1017
|
+
siteId: site["$id"],
|
|
1018
|
+
}, 100, "variables");
|
|
1034
1019
|
await Promise.all(variables.map(async (variable) => {
|
|
1035
|
-
await (
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1020
|
+
const sitesService = await getSitesService();
|
|
1021
|
+
await sitesService.deleteVariable({
|
|
1022
|
+
siteId: site["$id"],
|
|
1023
|
+
variableId: variable["$id"],
|
|
1039
1024
|
});
|
|
1040
1025
|
}));
|
|
1041
|
-
const envFileLocation = `${site[
|
|
1026
|
+
const envFileLocation = `${site["path"]}/.env`;
|
|
1042
1027
|
let envVariables = [];
|
|
1043
1028
|
try {
|
|
1044
1029
|
if (fs.existsSync(envFileLocation)) {
|
|
1045
|
-
const envObject = (
|
|
1030
|
+
const envObject = parseDotenv(fs.readFileSync(envFileLocation, "utf8"));
|
|
1046
1031
|
envVariables = Object.entries(envObject || {}).map(([key, value]) => ({ key, value }));
|
|
1047
1032
|
}
|
|
1048
1033
|
}
|
|
@@ -1051,196 +1036,229 @@ const pushSite = async ({ siteId, async: asyncDeploy, code, withVariables } = {
|
|
|
1051
1036
|
envVariables = [];
|
|
1052
1037
|
}
|
|
1053
1038
|
await Promise.all(envVariables.map(async (variable) => {
|
|
1054
|
-
await (
|
|
1055
|
-
|
|
1039
|
+
const sitesService = await getSitesService();
|
|
1040
|
+
await sitesService.createVariable({
|
|
1041
|
+
siteId: site["$id"],
|
|
1056
1042
|
key: variable.key,
|
|
1057
1043
|
value: variable.value,
|
|
1058
|
-
|
|
1059
|
-
secret: false
|
|
1044
|
+
secret: false,
|
|
1060
1045
|
});
|
|
1061
1046
|
}));
|
|
1062
1047
|
}
|
|
1063
1048
|
if (code === false) {
|
|
1064
1049
|
successfullyPushed++;
|
|
1065
1050
|
successfullyDeployed++;
|
|
1066
|
-
updaterRow.update({ status:
|
|
1051
|
+
updaterRow.update({ status: "Pushed" });
|
|
1067
1052
|
updaterRow.stopSpinner();
|
|
1068
1053
|
return;
|
|
1069
1054
|
}
|
|
1070
1055
|
try {
|
|
1071
|
-
updaterRow.update({ status:
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1056
|
+
updaterRow.update({ status: "Pushing" }).replaceSpinner(SPINNER_ARC);
|
|
1057
|
+
const sitesService = await getSitesService();
|
|
1058
|
+
response = await sitesService.createDeployment({
|
|
1059
|
+
siteId: site["$id"],
|
|
1075
1060
|
installCommand: site.installCommand,
|
|
1061
|
+
buildCommand: site.buildCommand,
|
|
1076
1062
|
outputDirectory: site.outputDirectory,
|
|
1077
|
-
fallbackFile: site.fallbackFile,
|
|
1078
1063
|
code: site.path,
|
|
1079
1064
|
activate: true,
|
|
1080
|
-
parseOutput: false
|
|
1081
1065
|
});
|
|
1082
|
-
updaterRow.update({ status:
|
|
1066
|
+
updaterRow.update({ status: "Pushed" });
|
|
1083
1067
|
deploymentCreated = true;
|
|
1084
1068
|
successfullyPushed++;
|
|
1085
1069
|
}
|
|
1086
1070
|
catch (e) {
|
|
1087
1071
|
errors.push(e);
|
|
1088
1072
|
switch (e.code) {
|
|
1089
|
-
case
|
|
1090
|
-
updaterRow.fail({
|
|
1073
|
+
case "ENOENT":
|
|
1074
|
+
updaterRow.fail({
|
|
1075
|
+
errorMessage: "Not found in the current directory. Skipping...",
|
|
1076
|
+
});
|
|
1091
1077
|
break;
|
|
1092
1078
|
default:
|
|
1093
|
-
updaterRow.fail({
|
|
1079
|
+
updaterRow.fail({
|
|
1080
|
+
errorMessage: e.message ?? "An unknown error occurred. Please try again.",
|
|
1081
|
+
});
|
|
1094
1082
|
}
|
|
1095
1083
|
}
|
|
1096
1084
|
if (deploymentCreated && !asyncDeploy) {
|
|
1097
1085
|
try {
|
|
1098
|
-
const deploymentId = response[
|
|
1099
|
-
updaterRow.update({
|
|
1086
|
+
const deploymentId = response["$id"];
|
|
1087
|
+
updaterRow.update({
|
|
1088
|
+
status: "Deploying",
|
|
1089
|
+
end: "Checking deployment status...",
|
|
1090
|
+
});
|
|
1100
1091
|
let pollChecks = 0;
|
|
1101
1092
|
while (true) {
|
|
1102
|
-
|
|
1103
|
-
|
|
1093
|
+
const sitesService = await getSitesService();
|
|
1094
|
+
response = await sitesService.getDeployment({
|
|
1095
|
+
siteId: site["$id"],
|
|
1104
1096
|
deploymentId: deploymentId,
|
|
1105
|
-
parseOutput: false
|
|
1106
1097
|
});
|
|
1107
|
-
const status = response[
|
|
1108
|
-
if (status ===
|
|
1098
|
+
const status = response["status"];
|
|
1099
|
+
if (status === "ready") {
|
|
1109
1100
|
successfullyDeployed++;
|
|
1110
|
-
let url =
|
|
1111
|
-
const
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1101
|
+
let url = "";
|
|
1102
|
+
const proxyService = await getProxyService();
|
|
1103
|
+
const res = await proxyService.listRules([
|
|
1104
|
+
JSON.stringify({ method: "limit", values: [1] }),
|
|
1105
|
+
JSON.stringify({
|
|
1106
|
+
method: "equal",
|
|
1107
|
+
attribute: "deploymentResourceType",
|
|
1108
|
+
values: ["site"],
|
|
1109
|
+
}),
|
|
1110
|
+
JSON.stringify({
|
|
1111
|
+
method: "equal",
|
|
1112
|
+
attribute: "deploymentResourceId",
|
|
1113
|
+
values: [site["$id"]],
|
|
1114
|
+
}),
|
|
1115
|
+
JSON.stringify({
|
|
1116
|
+
method: "equal",
|
|
1117
|
+
attribute: "trigger",
|
|
1118
|
+
values: ["manual"],
|
|
1119
|
+
}),
|
|
1120
|
+
]);
|
|
1120
1121
|
if (Number(res.total) === 1) {
|
|
1121
1122
|
url = res.rules[0].domain;
|
|
1122
1123
|
}
|
|
1123
|
-
updaterRow.update({ status:
|
|
1124
|
+
updaterRow.update({ status: "Deployed", end: url });
|
|
1124
1125
|
break;
|
|
1125
1126
|
}
|
|
1126
|
-
else if (status ===
|
|
1127
|
-
failedDeployments.push({
|
|
1127
|
+
else if (status === "failed") {
|
|
1128
|
+
failedDeployments.push({
|
|
1129
|
+
name: site["name"],
|
|
1130
|
+
$id: site["$id"],
|
|
1131
|
+
deployment: response["$id"],
|
|
1132
|
+
});
|
|
1128
1133
|
updaterRow.fail({ errorMessage: `Failed to deploy` });
|
|
1129
1134
|
break;
|
|
1130
1135
|
}
|
|
1131
1136
|
else {
|
|
1132
|
-
updaterRow.update({
|
|
1137
|
+
updaterRow.update({
|
|
1138
|
+
status: "Deploying",
|
|
1139
|
+
end: `Current status: ${status}`,
|
|
1140
|
+
});
|
|
1133
1141
|
}
|
|
1134
1142
|
pollChecks++;
|
|
1135
|
-
await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE * 1.5));
|
|
1143
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_DEBOUNCE * 1.5));
|
|
1136
1144
|
}
|
|
1137
1145
|
}
|
|
1138
1146
|
catch (e) {
|
|
1139
1147
|
errors.push(e);
|
|
1140
|
-
updaterRow.fail({
|
|
1148
|
+
updaterRow.fail({
|
|
1149
|
+
errorMessage: e.message ?? "Unknown error occurred. Please try again",
|
|
1150
|
+
});
|
|
1141
1151
|
}
|
|
1142
1152
|
}
|
|
1143
1153
|
updaterRow.stopSpinner();
|
|
1144
1154
|
}));
|
|
1145
|
-
|
|
1155
|
+
Spinner.stop();
|
|
1146
1156
|
failedDeployments.forEach((failed) => {
|
|
1147
1157
|
const { name, deployment, $id } = failed;
|
|
1148
|
-
const failUrl = `${
|
|
1149
|
-
|
|
1158
|
+
const failUrl = `${globalConfig.getEndpoint().slice(0, -3)}/console/project-${localConfig.getProject().projectId}/sites/site-${$id}/deployments/deployment-${deployment}`;
|
|
1159
|
+
error(`Deployment of ${name} has failed. Check at ${failUrl} for more details\n`);
|
|
1150
1160
|
});
|
|
1151
1161
|
if (!asyncDeploy) {
|
|
1152
1162
|
if (successfullyPushed === 0) {
|
|
1153
|
-
|
|
1163
|
+
error("No sites were pushed.");
|
|
1154
1164
|
}
|
|
1155
1165
|
else if (successfullyDeployed !== successfullyPushed) {
|
|
1156
|
-
|
|
1166
|
+
warn(`Successfully pushed ${successfullyDeployed} of ${successfullyPushed} sites`);
|
|
1157
1167
|
}
|
|
1158
1168
|
else {
|
|
1159
|
-
|
|
1169
|
+
success(`Successfully pushed ${successfullyPushed} sites.`);
|
|
1160
1170
|
}
|
|
1161
1171
|
}
|
|
1162
1172
|
else {
|
|
1163
|
-
|
|
1173
|
+
success(`Successfully pushed ${successfullyPushed} sites.`);
|
|
1164
1174
|
}
|
|
1165
|
-
if (
|
|
1166
|
-
errors.forEach(e => {
|
|
1175
|
+
if (cliConfig.verbose) {
|
|
1176
|
+
errors.forEach((e) => {
|
|
1167
1177
|
console.error(e);
|
|
1168
1178
|
});
|
|
1169
1179
|
}
|
|
1170
1180
|
};
|
|
1171
|
-
const pushFunction = async ({ functionId, async: asyncDeploy, code, withVariables } = {
|
|
1172
|
-
process.chdir(
|
|
1181
|
+
const pushFunction = async ({ functionId, async: asyncDeploy, code, withVariables, } = {}) => {
|
|
1182
|
+
process.chdir(localConfig.configDirectoryPath);
|
|
1173
1183
|
const functionIds = [];
|
|
1174
1184
|
if (functionId) {
|
|
1175
1185
|
functionIds.push(functionId);
|
|
1176
1186
|
}
|
|
1177
|
-
else if (
|
|
1178
|
-
|
|
1179
|
-
const functions =
|
|
1187
|
+
else if (cliConfig.all) {
|
|
1188
|
+
checkDeployConditions(localConfig);
|
|
1189
|
+
const functions = localConfig.getFunctions();
|
|
1180
1190
|
functionIds.push(...functions.map((func) => {
|
|
1181
1191
|
return func.$id;
|
|
1182
1192
|
}));
|
|
1183
1193
|
}
|
|
1184
1194
|
if (functionIds.length <= 0) {
|
|
1185
|
-
const answers = await
|
|
1195
|
+
const answers = await inquirer.prompt(questionsPushFunctions);
|
|
1186
1196
|
if (answers.functions) {
|
|
1187
1197
|
functionIds.push(...answers.functions);
|
|
1188
1198
|
}
|
|
1189
1199
|
}
|
|
1190
1200
|
if (functionIds.length === 0) {
|
|
1191
|
-
|
|
1192
|
-
|
|
1201
|
+
log("No functions found.");
|
|
1202
|
+
hint("Use 'appwrite pull functions' to synchronize existing one, or use 'appwrite init function' to create a new one.");
|
|
1193
1203
|
return;
|
|
1194
1204
|
}
|
|
1195
1205
|
let functions = functionIds.map((id) => {
|
|
1196
|
-
const functions =
|
|
1206
|
+
const functions = localConfig.getFunctions();
|
|
1197
1207
|
const func = functions.find((f) => f.$id === id);
|
|
1198
1208
|
if (!func) {
|
|
1199
1209
|
throw new Error("Function '" + id + "' not found.");
|
|
1200
1210
|
}
|
|
1201
1211
|
return func;
|
|
1202
1212
|
});
|
|
1203
|
-
|
|
1213
|
+
log("Validating functions ...");
|
|
1204
1214
|
// Validation is done BEFORE pushing so the deployment process can be run in async with progress update
|
|
1205
1215
|
for (let func of functions) {
|
|
1206
1216
|
if (!func.entrypoint) {
|
|
1207
|
-
|
|
1208
|
-
const answers = await
|
|
1217
|
+
log(`Function ${func.name} is missing an entrypoint.`);
|
|
1218
|
+
const answers = await inquirer.prompt(questionsGetEntrypoint);
|
|
1209
1219
|
func.entrypoint = answers.entrypoint;
|
|
1210
|
-
|
|
1220
|
+
localConfig.addFunction(func);
|
|
1211
1221
|
}
|
|
1212
1222
|
}
|
|
1213
|
-
if (!(await approveChanges(functions,
|
|
1223
|
+
if (!(await approveChanges(functions, async (args) => {
|
|
1224
|
+
const functionsService = await getFunctionsService();
|
|
1225
|
+
return await functionsService.get({ functionId: args.functionId });
|
|
1226
|
+
}, KeysFunction, "functionId", "functions", ["vars"]))) {
|
|
1214
1227
|
return;
|
|
1215
1228
|
}
|
|
1216
|
-
|
|
1217
|
-
|
|
1229
|
+
log("Pushing functions ...");
|
|
1230
|
+
Spinner.start(false);
|
|
1218
1231
|
let successfullyPushed = 0;
|
|
1219
1232
|
let successfullyDeployed = 0;
|
|
1220
1233
|
const failedDeployments = [];
|
|
1221
1234
|
const errors = [];
|
|
1222
1235
|
await Promise.all(functions.map(async (func) => {
|
|
1223
1236
|
let response = {};
|
|
1224
|
-
const ignore = func.ignore ?
|
|
1237
|
+
const ignore = func.ignore ? "appwrite.config.json" : ".gitignore";
|
|
1225
1238
|
let functionExists = false;
|
|
1226
1239
|
let deploymentCreated = false;
|
|
1227
|
-
const updaterRow = new
|
|
1228
|
-
|
|
1240
|
+
const updaterRow = new Spinner({
|
|
1241
|
+
status: "",
|
|
1242
|
+
resource: func.name,
|
|
1243
|
+
id: func["$id"],
|
|
1244
|
+
end: `Ignoring using: ${ignore}`,
|
|
1245
|
+
});
|
|
1246
|
+
updaterRow.update({ status: "Getting" }).startSpinner(SPINNER_DOTS);
|
|
1247
|
+
const functionsService = await getFunctionsService();
|
|
1229
1248
|
try {
|
|
1230
|
-
response = await (
|
|
1231
|
-
functionId: func['$id'],
|
|
1232
|
-
parseOutput: false,
|
|
1233
|
-
});
|
|
1249
|
+
response = await functionsService.get({ functionId: func["$id"] });
|
|
1234
1250
|
functionExists = true;
|
|
1235
1251
|
if (response.runtime !== func.runtime) {
|
|
1236
|
-
updaterRow.fail({
|
|
1252
|
+
updaterRow.fail({
|
|
1253
|
+
errorMessage: `Runtime mismatch! (local=${func.runtime},remote=${response.runtime}) Please delete remote function or update your appwrite.config.json`,
|
|
1254
|
+
});
|
|
1237
1255
|
return;
|
|
1238
1256
|
}
|
|
1239
|
-
updaterRow.update({ status:
|
|
1240
|
-
response = await
|
|
1241
|
-
functionId: func[
|
|
1257
|
+
updaterRow.update({ status: "Updating" }).replaceSpinner(SPINNER_ARC);
|
|
1258
|
+
response = await functionsService.update({
|
|
1259
|
+
functionId: func["$id"],
|
|
1242
1260
|
name: func.name,
|
|
1243
|
-
|
|
1261
|
+
runtime: func.runtime,
|
|
1244
1262
|
execute: func.execute,
|
|
1245
1263
|
events: func.events,
|
|
1246
1264
|
schedule: func.schedule,
|
|
@@ -1250,8 +1268,7 @@ const pushFunction = async ({ functionId, async: asyncDeploy, code, withVariable
|
|
|
1250
1268
|
entrypoint: func.entrypoint,
|
|
1251
1269
|
commands: func.commands,
|
|
1252
1270
|
scopes: func.scopes,
|
|
1253
|
-
|
|
1254
|
-
parseOutput: false
|
|
1271
|
+
specification: func.specification,
|
|
1255
1272
|
});
|
|
1256
1273
|
}
|
|
1257
1274
|
catch (e) {
|
|
@@ -1260,18 +1277,19 @@ const pushFunction = async ({ functionId, async: asyncDeploy, code, withVariable
|
|
|
1260
1277
|
}
|
|
1261
1278
|
else {
|
|
1262
1279
|
errors.push(e);
|
|
1263
|
-
updaterRow.fail({
|
|
1280
|
+
updaterRow.fail({
|
|
1281
|
+
errorMessage: e.message ?? "General error occurs please try again",
|
|
1282
|
+
});
|
|
1264
1283
|
return;
|
|
1265
1284
|
}
|
|
1266
1285
|
}
|
|
1267
1286
|
if (!functionExists) {
|
|
1268
|
-
updaterRow.update({ status:
|
|
1287
|
+
updaterRow.update({ status: "Creating" }).replaceSpinner(SPINNER_DOTS);
|
|
1269
1288
|
try {
|
|
1270
|
-
response = await
|
|
1289
|
+
response = await functionsService.create({
|
|
1271
1290
|
functionId: func.$id,
|
|
1272
1291
|
name: func.name,
|
|
1273
1292
|
runtime: func.runtime,
|
|
1274
|
-
specification: func.specification,
|
|
1275
1293
|
execute: func.execute,
|
|
1276
1294
|
events: func.events,
|
|
1277
1295
|
schedule: func.schedule,
|
|
@@ -1281,53 +1299,60 @@ const pushFunction = async ({ functionId, async: asyncDeploy, code, withVariable
|
|
|
1281
1299
|
entrypoint: func.entrypoint,
|
|
1282
1300
|
commands: func.commands,
|
|
1283
1301
|
scopes: func.scopes,
|
|
1284
|
-
|
|
1302
|
+
specification: func.specification,
|
|
1285
1303
|
});
|
|
1286
|
-
let domain =
|
|
1304
|
+
let domain = "";
|
|
1287
1305
|
try {
|
|
1288
|
-
const
|
|
1289
|
-
|
|
1306
|
+
const consoleService = await getConsoleService();
|
|
1307
|
+
const variables = await consoleService.variables();
|
|
1308
|
+
domain = ID.unique() + "." + variables["_APP_DOMAIN_FUNCTIONS"];
|
|
1290
1309
|
}
|
|
1291
1310
|
catch (error) {
|
|
1292
|
-
console.error(
|
|
1311
|
+
console.error("Error fetching console variables.");
|
|
1293
1312
|
throw error;
|
|
1294
1313
|
}
|
|
1295
1314
|
try {
|
|
1296
|
-
const
|
|
1297
|
-
|
|
1298
|
-
functionId: func.$id
|
|
1299
|
-
});
|
|
1315
|
+
const proxyService = await getProxyService();
|
|
1316
|
+
const rule = await proxyService.createFunctionRule(domain, func.$id);
|
|
1300
1317
|
}
|
|
1301
1318
|
catch (error) {
|
|
1302
|
-
console.error(
|
|
1319
|
+
console.error("Error creating function rule.");
|
|
1303
1320
|
throw error;
|
|
1304
1321
|
}
|
|
1305
|
-
updaterRow.update({ status:
|
|
1322
|
+
updaterRow.update({ status: "Created" });
|
|
1306
1323
|
}
|
|
1307
1324
|
catch (e) {
|
|
1308
1325
|
errors.push(e);
|
|
1309
|
-
updaterRow.fail({
|
|
1326
|
+
updaterRow.fail({
|
|
1327
|
+
errorMessage: e.message ?? "General error occurs please try again",
|
|
1328
|
+
});
|
|
1310
1329
|
return;
|
|
1311
1330
|
}
|
|
1312
1331
|
}
|
|
1313
1332
|
if (withVariables) {
|
|
1314
|
-
updaterRow
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
}
|
|
1333
|
+
updaterRow
|
|
1334
|
+
.update({ status: "Updating variables" })
|
|
1335
|
+
.replaceSpinner(SPINNER_ARC);
|
|
1336
|
+
const functionsService = await getFunctionsService();
|
|
1337
|
+
const { variables } = await paginate(async (args) => {
|
|
1338
|
+
return await functionsService.listVariables({
|
|
1339
|
+
functionId: args.functionId,
|
|
1340
|
+
});
|
|
1341
|
+
}, {
|
|
1342
|
+
functionId: func["$id"],
|
|
1343
|
+
}, 100, "variables");
|
|
1319
1344
|
await Promise.all(variables.map(async (variable) => {
|
|
1320
|
-
await (
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1345
|
+
const functionsService = await getFunctionsService();
|
|
1346
|
+
await functionsService.deleteVariable({
|
|
1347
|
+
functionId: func["$id"],
|
|
1348
|
+
variableId: variable["$id"],
|
|
1324
1349
|
});
|
|
1325
1350
|
}));
|
|
1326
|
-
const envFileLocation = `${func[
|
|
1351
|
+
const envFileLocation = `${func["path"]}/.env`;
|
|
1327
1352
|
let envVariables = [];
|
|
1328
1353
|
try {
|
|
1329
1354
|
if (fs.existsSync(envFileLocation)) {
|
|
1330
|
-
const envObject = (
|
|
1355
|
+
const envObject = parseDotenv(fs.readFileSync(envFileLocation, "utf8"));
|
|
1331
1356
|
envVariables = Object.entries(envObject || {}).map(([key, value]) => ({ key, value }));
|
|
1332
1357
|
}
|
|
1333
1358
|
}
|
|
@@ -1336,126 +1361,154 @@ const pushFunction = async ({ functionId, async: asyncDeploy, code, withVariable
|
|
|
1336
1361
|
envVariables = [];
|
|
1337
1362
|
}
|
|
1338
1363
|
await Promise.all(envVariables.map(async (variable) => {
|
|
1339
|
-
await (
|
|
1340
|
-
|
|
1341
|
-
|
|
1364
|
+
const functionsService = await getFunctionsService();
|
|
1365
|
+
await functionsService.createVariable({
|
|
1366
|
+
functionId: func["$id"],
|
|
1342
1367
|
key: variable.key,
|
|
1343
1368
|
value: variable.value,
|
|
1344
|
-
|
|
1345
|
-
secret: false
|
|
1369
|
+
secret: false,
|
|
1346
1370
|
});
|
|
1347
1371
|
}));
|
|
1348
1372
|
}
|
|
1349
1373
|
if (code === false) {
|
|
1350
1374
|
successfullyPushed++;
|
|
1351
1375
|
successfullyDeployed++;
|
|
1352
|
-
updaterRow.update({ status:
|
|
1376
|
+
updaterRow.update({ status: "Pushed" });
|
|
1353
1377
|
updaterRow.stopSpinner();
|
|
1354
1378
|
return;
|
|
1355
1379
|
}
|
|
1356
1380
|
try {
|
|
1357
|
-
updaterRow.update({ status:
|
|
1358
|
-
|
|
1359
|
-
|
|
1381
|
+
updaterRow.update({ status: "Pushing" }).replaceSpinner(SPINNER_ARC);
|
|
1382
|
+
const functionsService = await getFunctionsService();
|
|
1383
|
+
response = await functionsService.createDeployment({
|
|
1384
|
+
functionId: func["$id"],
|
|
1360
1385
|
entrypoint: func.entrypoint,
|
|
1361
1386
|
commands: func.commands,
|
|
1362
1387
|
code: func.path,
|
|
1363
1388
|
activate: true,
|
|
1364
|
-
parseOutput: false
|
|
1365
1389
|
});
|
|
1366
|
-
updaterRow.update({ status:
|
|
1390
|
+
updaterRow.update({ status: "Pushed" });
|
|
1367
1391
|
deploymentCreated = true;
|
|
1368
1392
|
successfullyPushed++;
|
|
1369
1393
|
}
|
|
1370
1394
|
catch (e) {
|
|
1371
1395
|
errors.push(e);
|
|
1372
1396
|
switch (e.code) {
|
|
1373
|
-
case
|
|
1374
|
-
updaterRow.fail({
|
|
1397
|
+
case "ENOENT":
|
|
1398
|
+
updaterRow.fail({
|
|
1399
|
+
errorMessage: "Not found in the current directory. Skipping...",
|
|
1400
|
+
});
|
|
1375
1401
|
break;
|
|
1376
1402
|
default:
|
|
1377
|
-
updaterRow.fail({
|
|
1403
|
+
updaterRow.fail({
|
|
1404
|
+
errorMessage: e.message ?? "An unknown error occurred. Please try again.",
|
|
1405
|
+
});
|
|
1378
1406
|
}
|
|
1379
1407
|
}
|
|
1380
1408
|
if (deploymentCreated && !asyncDeploy) {
|
|
1381
1409
|
try {
|
|
1382
|
-
const deploymentId = response[
|
|
1383
|
-
updaterRow.update({
|
|
1410
|
+
const deploymentId = response["$id"];
|
|
1411
|
+
updaterRow.update({
|
|
1412
|
+
status: "Deploying",
|
|
1413
|
+
end: "Checking deployment status...",
|
|
1414
|
+
});
|
|
1384
1415
|
let pollChecks = 0;
|
|
1385
1416
|
while (true) {
|
|
1386
|
-
|
|
1387
|
-
|
|
1417
|
+
const functionsService = await getFunctionsService();
|
|
1418
|
+
response = await functionsService.getDeployment({
|
|
1419
|
+
functionId: func["$id"],
|
|
1388
1420
|
deploymentId: deploymentId,
|
|
1389
|
-
parseOutput: false
|
|
1390
1421
|
});
|
|
1391
|
-
const status = response[
|
|
1392
|
-
if (status ===
|
|
1422
|
+
const status = response["status"];
|
|
1423
|
+
if (status === "ready") {
|
|
1393
1424
|
successfullyDeployed++;
|
|
1394
|
-
let url =
|
|
1395
|
-
const
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1425
|
+
let url = "";
|
|
1426
|
+
const proxyService = await getProxyService();
|
|
1427
|
+
const res = await proxyService.listRules([
|
|
1428
|
+
JSON.stringify({ method: "limit", values: [1] }),
|
|
1429
|
+
JSON.stringify({
|
|
1430
|
+
method: "equal",
|
|
1431
|
+
attribute: "deploymentResourceType",
|
|
1432
|
+
values: ["function"],
|
|
1433
|
+
}),
|
|
1434
|
+
JSON.stringify({
|
|
1435
|
+
method: "equal",
|
|
1436
|
+
attribute: "deploymentResourceId",
|
|
1437
|
+
values: [func["$id"]],
|
|
1438
|
+
}),
|
|
1439
|
+
JSON.stringify({
|
|
1440
|
+
method: "equal",
|
|
1441
|
+
attribute: "trigger",
|
|
1442
|
+
values: ["manual"],
|
|
1443
|
+
}),
|
|
1444
|
+
]);
|
|
1404
1445
|
if (Number(res.total) === 1) {
|
|
1405
1446
|
url = res.rules[0].domain;
|
|
1406
1447
|
}
|
|
1407
|
-
updaterRow.update({ status:
|
|
1448
|
+
updaterRow.update({ status: "Deployed", end: url });
|
|
1408
1449
|
break;
|
|
1409
1450
|
}
|
|
1410
|
-
else if (status ===
|
|
1411
|
-
failedDeployments.push({
|
|
1451
|
+
else if (status === "failed") {
|
|
1452
|
+
failedDeployments.push({
|
|
1453
|
+
name: func["name"],
|
|
1454
|
+
$id: func["$id"],
|
|
1455
|
+
deployment: response["$id"],
|
|
1456
|
+
});
|
|
1412
1457
|
updaterRow.fail({ errorMessage: `Failed to deploy` });
|
|
1413
1458
|
break;
|
|
1414
1459
|
}
|
|
1415
1460
|
else {
|
|
1416
|
-
updaterRow.update({
|
|
1461
|
+
updaterRow.update({
|
|
1462
|
+
status: "Deploying",
|
|
1463
|
+
end: `Current status: ${status}`,
|
|
1464
|
+
});
|
|
1417
1465
|
}
|
|
1418
1466
|
pollChecks++;
|
|
1419
|
-
await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE * 1.5));
|
|
1467
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_DEBOUNCE * 1.5));
|
|
1420
1468
|
}
|
|
1421
1469
|
}
|
|
1422
1470
|
catch (e) {
|
|
1423
1471
|
errors.push(e);
|
|
1424
|
-
updaterRow.fail({
|
|
1472
|
+
updaterRow.fail({
|
|
1473
|
+
errorMessage: e.message ?? "Unknown error occurred. Please try again",
|
|
1474
|
+
});
|
|
1425
1475
|
}
|
|
1426
1476
|
}
|
|
1427
1477
|
updaterRow.stopSpinner();
|
|
1428
1478
|
}));
|
|
1429
|
-
|
|
1479
|
+
Spinner.stop();
|
|
1430
1480
|
failedDeployments.forEach((failed) => {
|
|
1431
1481
|
const { name, deployment, $id } = failed;
|
|
1432
|
-
const failUrl = `${
|
|
1433
|
-
|
|
1482
|
+
const failUrl = `${globalConfig.getEndpoint().slice(0, -3)}/console/project-${localConfig.getProject().projectId}/functions/function-${$id}/deployment-${deployment}`;
|
|
1483
|
+
error(`Deployment of ${name} has failed. Check at ${failUrl} for more details\n`);
|
|
1434
1484
|
});
|
|
1435
1485
|
if (!asyncDeploy) {
|
|
1436
1486
|
if (successfullyPushed === 0) {
|
|
1437
|
-
|
|
1487
|
+
error("No functions were pushed.");
|
|
1438
1488
|
}
|
|
1439
1489
|
else if (successfullyDeployed !== successfullyPushed) {
|
|
1440
|
-
|
|
1490
|
+
warn(`Successfully pushed ${successfullyDeployed} of ${successfullyPushed} functions`);
|
|
1441
1491
|
}
|
|
1442
1492
|
else {
|
|
1443
|
-
|
|
1493
|
+
success(`Successfully pushed ${successfullyPushed} functions.`);
|
|
1444
1494
|
}
|
|
1445
1495
|
}
|
|
1446
1496
|
else {
|
|
1447
|
-
|
|
1497
|
+
success(`Successfully pushed ${successfullyPushed} functions.`);
|
|
1448
1498
|
}
|
|
1449
|
-
if (
|
|
1450
|
-
errors.forEach(e => {
|
|
1499
|
+
if (cliConfig.verbose) {
|
|
1500
|
+
errors.forEach((e) => {
|
|
1451
1501
|
console.error(e);
|
|
1452
1502
|
});
|
|
1453
1503
|
}
|
|
1454
1504
|
};
|
|
1455
1505
|
const checkAndApplyTablesDBChanges = async () => {
|
|
1456
|
-
|
|
1457
|
-
const localTablesDBs =
|
|
1458
|
-
const { databases: remoteTablesDBs } = await (
|
|
1506
|
+
log("Checking for tablesDB changes ...");
|
|
1507
|
+
const localTablesDBs = localConfig.getTablesDBs();
|
|
1508
|
+
const { databases: remoteTablesDBs } = await paginate(async (args) => {
|
|
1509
|
+
const tablesDBService = await getTablesDBService();
|
|
1510
|
+
return await tablesDBService.list(args.queries || []);
|
|
1511
|
+
}, {}, 100, "databases");
|
|
1459
1512
|
if (localTablesDBs.length === 0 && remoteTablesDBs.length === 0) {
|
|
1460
1513
|
return { applied: false, resyncNeeded: false };
|
|
1461
1514
|
}
|
|
@@ -1470,10 +1523,10 @@ const checkAndApplyTablesDBChanges = async () => {
|
|
|
1470
1523
|
toDelete.push(remoteDB);
|
|
1471
1524
|
changes.push({
|
|
1472
1525
|
id: remoteDB.$id,
|
|
1473
|
-
action:
|
|
1474
|
-
key:
|
|
1526
|
+
action: chalk.red("deleting"),
|
|
1527
|
+
key: "Database",
|
|
1475
1528
|
remote: remoteDB.name,
|
|
1476
|
-
local:
|
|
1529
|
+
local: "(deleted locally)",
|
|
1477
1530
|
});
|
|
1478
1531
|
}
|
|
1479
1532
|
}
|
|
@@ -1484,10 +1537,10 @@ const checkAndApplyTablesDBChanges = async () => {
|
|
|
1484
1537
|
toCreate.push(localDB);
|
|
1485
1538
|
changes.push({
|
|
1486
1539
|
id: localDB.$id,
|
|
1487
|
-
action:
|
|
1488
|
-
key:
|
|
1489
|
-
remote:
|
|
1490
|
-
local: localDB.name
|
|
1540
|
+
action: chalk.green("creating"),
|
|
1541
|
+
key: "Database",
|
|
1542
|
+
remote: "(does not exist)",
|
|
1543
|
+
local: localDB.name,
|
|
1491
1544
|
});
|
|
1492
1545
|
}
|
|
1493
1546
|
else {
|
|
@@ -1496,20 +1549,20 @@ const checkAndApplyTablesDBChanges = async () => {
|
|
|
1496
1549
|
hasChanges = true;
|
|
1497
1550
|
changes.push({
|
|
1498
1551
|
id: localDB.$id,
|
|
1499
|
-
action:
|
|
1500
|
-
key:
|
|
1552
|
+
action: chalk.yellow("updating"),
|
|
1553
|
+
key: "Name",
|
|
1501
1554
|
remote: remoteDB.name,
|
|
1502
|
-
local: localDB.name
|
|
1555
|
+
local: localDB.name,
|
|
1503
1556
|
});
|
|
1504
1557
|
}
|
|
1505
1558
|
if (remoteDB.enabled !== localDB.enabled) {
|
|
1506
1559
|
hasChanges = true;
|
|
1507
1560
|
changes.push({
|
|
1508
1561
|
id: localDB.$id,
|
|
1509
|
-
action:
|
|
1510
|
-
key:
|
|
1562
|
+
action: chalk.yellow("updating"),
|
|
1563
|
+
key: "Enabled",
|
|
1511
1564
|
remote: remoteDB.enabled,
|
|
1512
|
-
local: localDB.enabled
|
|
1565
|
+
local: localDB.enabled,
|
|
1513
1566
|
});
|
|
1514
1567
|
}
|
|
1515
1568
|
if (hasChanges) {
|
|
@@ -1518,16 +1571,14 @@ const checkAndApplyTablesDBChanges = async () => {
|
|
|
1518
1571
|
}
|
|
1519
1572
|
}
|
|
1520
1573
|
if (changes.length === 0) {
|
|
1521
|
-
console.log('No changes found in tablesDB resource');
|
|
1522
|
-
console.log();
|
|
1523
1574
|
return { applied: false, resyncNeeded: false };
|
|
1524
1575
|
}
|
|
1525
|
-
|
|
1526
|
-
|
|
1576
|
+
log("Found changes in tablesDB resource:");
|
|
1577
|
+
drawTable(changes);
|
|
1527
1578
|
if (toDelete.length > 0) {
|
|
1528
|
-
console.log(`${
|
|
1529
|
-
console.log(`${
|
|
1530
|
-
console.log(`${
|
|
1579
|
+
console.log(`${chalk.red("------------------------------------------------------------------")}`);
|
|
1580
|
+
console.log(`${chalk.red("| WARNING: Database deletion will also delete all related tables |")}`);
|
|
1581
|
+
console.log(`${chalk.red("------------------------------------------------------------------")}`);
|
|
1531
1582
|
console.log();
|
|
1532
1583
|
}
|
|
1533
1584
|
if ((await getConfirmation()) !== true) {
|
|
@@ -1537,50 +1588,40 @@ const checkAndApplyTablesDBChanges = async () => {
|
|
|
1537
1588
|
let needsResync = false;
|
|
1538
1589
|
for (const db of toDelete) {
|
|
1539
1590
|
try {
|
|
1540
|
-
|
|
1541
|
-
await (
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
});
|
|
1545
|
-
(0, parser_1.success)(`Deleted ${db.name} ( ${db.$id} )`);
|
|
1591
|
+
log(`Deleting database ${db.name} ( ${db.$id} ) ...`);
|
|
1592
|
+
const tablesDBService = await getTablesDBService();
|
|
1593
|
+
await tablesDBService.delete(db.$id);
|
|
1594
|
+
success(`Deleted ${db.name} ( ${db.$id} )`);
|
|
1546
1595
|
needsResync = true;
|
|
1547
1596
|
}
|
|
1548
1597
|
catch (e) {
|
|
1549
|
-
|
|
1598
|
+
error(`Failed to delete database ${db.name} ( ${db.$id} ): ${e.message}`);
|
|
1550
1599
|
throw new Error(`Database sync failed during deletion of ${db.$id}. Some changes may have been applied.`);
|
|
1551
1600
|
}
|
|
1552
1601
|
}
|
|
1553
1602
|
// Apply creations
|
|
1554
1603
|
for (const db of toCreate) {
|
|
1555
1604
|
try {
|
|
1556
|
-
|
|
1557
|
-
await (
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
enabled: db.enabled,
|
|
1561
|
-
parseOutput: false
|
|
1562
|
-
});
|
|
1563
|
-
(0, parser_1.success)(`Created ${db.name} ( ${db.$id} )`);
|
|
1605
|
+
log(`Creating database ${db.name} ( ${db.$id} ) ...`);
|
|
1606
|
+
const tablesDBService = await getTablesDBService();
|
|
1607
|
+
await tablesDBService.create(db.$id, db.name, db.enabled);
|
|
1608
|
+
success(`Created ${db.name} ( ${db.$id} )`);
|
|
1564
1609
|
}
|
|
1565
1610
|
catch (e) {
|
|
1566
|
-
|
|
1611
|
+
error(`Failed to create database ${db.name} ( ${db.$id} ): ${e.message}`);
|
|
1567
1612
|
throw new Error(`Database sync failed during creation of ${db.$id}. Some changes may have been applied.`);
|
|
1568
1613
|
}
|
|
1569
1614
|
}
|
|
1570
1615
|
// Apply updates
|
|
1571
1616
|
for (const db of toUpdate) {
|
|
1572
1617
|
try {
|
|
1573
|
-
|
|
1574
|
-
await (
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
enabled: db.enabled,
|
|
1578
|
-
parseOutput: false
|
|
1579
|
-
});
|
|
1580
|
-
(0, parser_1.success)(`Updated ${db.name} ( ${db.$id} )`);
|
|
1618
|
+
log(`Updating database ${db.name} ( ${db.$id} ) ...`);
|
|
1619
|
+
const tablesDBService = await getTablesDBService();
|
|
1620
|
+
await tablesDBService.update(db.$id, db.name, db.enabled);
|
|
1621
|
+
success(`Updated ${db.name} ( ${db.$id} )`);
|
|
1581
1622
|
}
|
|
1582
1623
|
catch (e) {
|
|
1583
|
-
|
|
1624
|
+
error(`Failed to update database ${db.name} ( ${db.$id} ): ${e.message}`);
|
|
1584
1625
|
throw new Error(`Database sync failed during update of ${db.$id}. Some changes may have been applied.`);
|
|
1585
1626
|
}
|
|
1586
1627
|
}
|
|
@@ -1589,42 +1630,47 @@ const checkAndApplyTablesDBChanges = async () => {
|
|
|
1589
1630
|
}
|
|
1590
1631
|
return { applied: true, resyncNeeded: needsResync };
|
|
1591
1632
|
};
|
|
1592
|
-
const pushTable = async ({
|
|
1633
|
+
const pushTable = async ({ attempts, } = {}) => {
|
|
1593
1634
|
const tables = [];
|
|
1594
1635
|
if (attempts) {
|
|
1595
1636
|
pollMaxDebounces = attempts;
|
|
1596
1637
|
}
|
|
1597
1638
|
const { applied: tablesDBApplied, resyncNeeded } = await checkAndApplyTablesDBChanges();
|
|
1598
1639
|
if (resyncNeeded) {
|
|
1599
|
-
|
|
1600
|
-
const remoteTablesDBs = (await (
|
|
1601
|
-
|
|
1640
|
+
log("Resyncing configuration due to tablesDB deletions ...");
|
|
1641
|
+
const remoteTablesDBs = (await paginate(async (args) => {
|
|
1642
|
+
const tablesDBService = await getTablesDBService();
|
|
1643
|
+
return await tablesDBService.list(args.queries || []);
|
|
1644
|
+
}, {}, 100, "databases")).databases;
|
|
1645
|
+
const localTablesDBs = localConfig.getTablesDBs();
|
|
1602
1646
|
const remoteDatabaseIds = new Set(remoteTablesDBs.map((db) => db.$id));
|
|
1603
|
-
const localTables =
|
|
1647
|
+
const localTables = localConfig.getTables();
|
|
1604
1648
|
const validTables = localTables.filter((table) => remoteDatabaseIds.has(table.databaseId));
|
|
1605
|
-
|
|
1649
|
+
localConfig.set("tables", validTables);
|
|
1606
1650
|
const validTablesDBs = localTablesDBs.filter((db) => remoteDatabaseIds.has(db.$id));
|
|
1607
|
-
|
|
1608
|
-
|
|
1651
|
+
localConfig.set("tablesDB", validTablesDBs);
|
|
1652
|
+
success("Configuration resynced successfully.");
|
|
1609
1653
|
console.log();
|
|
1610
1654
|
}
|
|
1611
|
-
|
|
1612
|
-
const localTablesDBs =
|
|
1613
|
-
const localTables =
|
|
1655
|
+
log("Checking for deleted tables ...");
|
|
1656
|
+
const localTablesDBs = localConfig.getTablesDBs();
|
|
1657
|
+
const localTables = localConfig.getTables();
|
|
1614
1658
|
const tablesToDelete = [];
|
|
1615
1659
|
for (const db of localTablesDBs) {
|
|
1616
1660
|
try {
|
|
1617
|
-
const { tables: remoteTables } = await (
|
|
1661
|
+
const { tables: remoteTables } = await paginate(async (args) => {
|
|
1662
|
+
const tablesDBService = await getTablesDBService();
|
|
1663
|
+
return await tablesDBService.listTables(args.databaseId, args.queries || []);
|
|
1664
|
+
}, {
|
|
1618
1665
|
databaseId: db.$id,
|
|
1619
|
-
|
|
1620
|
-
}, 100, 'tables');
|
|
1666
|
+
}, 100, "tables");
|
|
1621
1667
|
for (const remoteTable of remoteTables) {
|
|
1622
1668
|
const localTable = localTables.find((t) => t.$id === remoteTable.$id && t.databaseId === db.$id);
|
|
1623
1669
|
if (!localTable) {
|
|
1624
1670
|
tablesToDelete.push({
|
|
1625
1671
|
...remoteTable,
|
|
1626
1672
|
databaseId: db.$id,
|
|
1627
|
-
databaseName: db.name
|
|
1673
|
+
databaseName: db.name,
|
|
1628
1674
|
});
|
|
1629
1675
|
}
|
|
1630
1676
|
}
|
|
@@ -1634,47 +1680,40 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
|
|
|
1634
1680
|
}
|
|
1635
1681
|
}
|
|
1636
1682
|
if (tablesToDelete.length > 0) {
|
|
1637
|
-
|
|
1683
|
+
log("Found tables that exist remotely but not locally:");
|
|
1638
1684
|
const deletionChanges = tablesToDelete.map((table) => ({
|
|
1639
1685
|
id: table.$id,
|
|
1640
|
-
action:
|
|
1641
|
-
key:
|
|
1686
|
+
action: chalk.red("deleting"),
|
|
1687
|
+
key: "Table",
|
|
1642
1688
|
database: table.databaseName,
|
|
1643
1689
|
remote: table.name,
|
|
1644
|
-
local:
|
|
1690
|
+
local: "(deleted locally)",
|
|
1645
1691
|
}));
|
|
1646
|
-
|
|
1692
|
+
drawTable(deletionChanges);
|
|
1647
1693
|
if ((await getConfirmation()) === true) {
|
|
1648
1694
|
for (const table of tablesToDelete) {
|
|
1649
1695
|
try {
|
|
1650
|
-
|
|
1651
|
-
await (
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
parseOutput: false
|
|
1655
|
-
});
|
|
1656
|
-
(0, parser_1.success)(`Deleted ${table.name} ( ${table.$id} )`);
|
|
1696
|
+
log(`Deleting table ${table.name} ( ${table.$id} ) from database ${table.databaseName} ...`);
|
|
1697
|
+
const tablesDBService = await getTablesDBService();
|
|
1698
|
+
await tablesDBService.deleteTable(table.databaseId, table.$id);
|
|
1699
|
+
success(`Deleted ${table.name} ( ${table.$id} )`);
|
|
1657
1700
|
}
|
|
1658
1701
|
catch (e) {
|
|
1659
|
-
|
|
1702
|
+
error(`Failed to delete table ${table.name} ( ${table.$id} ): ${e.message}`);
|
|
1660
1703
|
}
|
|
1661
1704
|
}
|
|
1662
1705
|
}
|
|
1663
1706
|
}
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
console.log();
|
|
1668
|
-
if (parser_1.cliConfig.all) {
|
|
1669
|
-
(0, utils_1.checkDeployConditions)(config_1.localConfig);
|
|
1670
|
-
tables.push(...config_1.localConfig.getTables());
|
|
1707
|
+
if (cliConfig.all) {
|
|
1708
|
+
checkDeployConditions(localConfig);
|
|
1709
|
+
tables.push(...localConfig.getTables());
|
|
1671
1710
|
}
|
|
1672
1711
|
else {
|
|
1673
|
-
const answers = await
|
|
1712
|
+
const answers = await inquirer.prompt(questionsPushTables);
|
|
1674
1713
|
if (answers.tables) {
|
|
1675
1714
|
const configTables = new Map();
|
|
1676
|
-
|
|
1677
|
-
configTables.set(`${c[
|
|
1715
|
+
localConfig.getTables().forEach((c) => {
|
|
1716
|
+
configTables.set(`${c["databaseId"]}|${c["$id"]}`, c);
|
|
1678
1717
|
});
|
|
1679
1718
|
answers.tables.forEach((a) => {
|
|
1680
1719
|
const table = configTables.get(a);
|
|
@@ -1683,59 +1722,47 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
|
|
|
1683
1722
|
}
|
|
1684
1723
|
}
|
|
1685
1724
|
if (tables.length === 0) {
|
|
1686
|
-
|
|
1687
|
-
|
|
1725
|
+
log("No tables found.");
|
|
1726
|
+
hint("Use 'appwrite pull tables' to synchronize existing one, or use 'appwrite init table' to create a new one.");
|
|
1688
1727
|
return;
|
|
1689
1728
|
}
|
|
1690
|
-
if (!(await approveChanges(tables,
|
|
1729
|
+
if (!(await approveChanges(tables, async (args) => {
|
|
1730
|
+
const tablesDBService = await getTablesDBService();
|
|
1731
|
+
return await tablesDBService.getTable(args.databaseId, args.tableId);
|
|
1732
|
+
}, KeysTable, "tableId", "tables", ["columns", "indexes"], "databaseId", "databaseId"))) {
|
|
1691
1733
|
return;
|
|
1692
1734
|
}
|
|
1693
1735
|
let tablesChanged = new Set();
|
|
1694
1736
|
// Parallel tables actions
|
|
1695
1737
|
await Promise.all(tables.map(async (table) => {
|
|
1696
1738
|
try {
|
|
1697
|
-
const
|
|
1698
|
-
|
|
1699
|
-
tableId: table['$id'],
|
|
1700
|
-
parseOutput: false,
|
|
1701
|
-
});
|
|
1739
|
+
const tablesDBService = await getTablesDBService();
|
|
1740
|
+
const remoteTable = await tablesDBService.getTable(table["databaseId"], table["$id"]);
|
|
1702
1741
|
const changes = [];
|
|
1703
1742
|
if (remoteTable.name !== table.name)
|
|
1704
|
-
changes.push(
|
|
1743
|
+
changes.push("name");
|
|
1705
1744
|
if (remoteTable.rowSecurity !== table.rowSecurity)
|
|
1706
|
-
changes.push(
|
|
1745
|
+
changes.push("rowSecurity");
|
|
1707
1746
|
if (remoteTable.enabled !== table.enabled)
|
|
1708
|
-
changes.push(
|
|
1709
|
-
if (JSON.stringify(remoteTable[
|
|
1710
|
-
|
|
1747
|
+
changes.push("enabled");
|
|
1748
|
+
if (JSON.stringify(remoteTable["$permissions"]) !==
|
|
1749
|
+
JSON.stringify(table["$permissions"]))
|
|
1750
|
+
changes.push("permissions");
|
|
1711
1751
|
if (changes.length > 0) {
|
|
1712
|
-
await (
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
name: table.name,
|
|
1716
|
-
parseOutput: false,
|
|
1717
|
-
rowSecurity: table.rowSecurity,
|
|
1718
|
-
permissions: table['$permissions']
|
|
1719
|
-
});
|
|
1720
|
-
(0, parser_1.success)(`Updated ${table.name} ( ${table['$id']} ) - ${changes.join(', ')}`);
|
|
1721
|
-
tablesChanged.add(table['$id']);
|
|
1752
|
+
await tablesDBService.updateTable(table["databaseId"], table["$id"], table.name, table.rowSecurity, table["$permissions"]);
|
|
1753
|
+
success(`Updated ${table.name} ( ${table["$id"]} ) - ${changes.join(", ")}`);
|
|
1754
|
+
tablesChanged.add(table["$id"]);
|
|
1722
1755
|
}
|
|
1723
1756
|
table.remoteVersion = remoteTable;
|
|
1724
1757
|
table.isExisted = true;
|
|
1725
1758
|
}
|
|
1726
1759
|
catch (e) {
|
|
1727
1760
|
if (Number(e.code) === 404) {
|
|
1728
|
-
|
|
1729
|
-
await (
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
rowSecurity: table.rowSecurity,
|
|
1734
|
-
permissions: table['$permissions'],
|
|
1735
|
-
parseOutput: false
|
|
1736
|
-
});
|
|
1737
|
-
(0, parser_1.success)(`Created ${table.name} ( ${table['$id']} )`);
|
|
1738
|
-
tablesChanged.add(table['$id']);
|
|
1761
|
+
log(`Table ${table.name} does not exist in the project. Creating ... `);
|
|
1762
|
+
const tablesDBService = await getTablesDBService();
|
|
1763
|
+
await tablesDBService.createTable(table["databaseId"], table["$id"], table.name, table.rowSecurity, table["$permissions"]);
|
|
1764
|
+
success(`Created ${table.name} ( ${table["$id"]} )`);
|
|
1765
|
+
tablesChanged.add(table["$id"]);
|
|
1739
1766
|
}
|
|
1740
1767
|
else {
|
|
1741
1768
|
throw e;
|
|
@@ -1749,11 +1776,14 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
|
|
|
1749
1776
|
if (table.isExisted) {
|
|
1750
1777
|
columns = await attributesToCreate(table.remoteVersion.columns, table.columns, table);
|
|
1751
1778
|
indexes = await attributesToCreate(table.remoteVersion.indexes, table.indexes, table, true);
|
|
1752
|
-
if (
|
|
1779
|
+
if (Array.isArray(columns) &&
|
|
1780
|
+
columns.length <= 0 &&
|
|
1781
|
+
Array.isArray(indexes) &&
|
|
1782
|
+
indexes.length <= 0) {
|
|
1753
1783
|
continue;
|
|
1754
1784
|
}
|
|
1755
1785
|
}
|
|
1756
|
-
|
|
1786
|
+
log(`Pushing table ${table.name} ( ${table["databaseId"]} - ${table["$id"]} ) attributes`);
|
|
1757
1787
|
try {
|
|
1758
1788
|
await createColumns(columns, table);
|
|
1759
1789
|
}
|
|
@@ -1766,27 +1796,27 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
|
|
|
1766
1796
|
catch (e) {
|
|
1767
1797
|
throw e;
|
|
1768
1798
|
}
|
|
1769
|
-
tablesChanged.add(table[
|
|
1770
|
-
|
|
1799
|
+
tablesChanged.add(table["$id"]);
|
|
1800
|
+
success(`Successfully pushed ${table.name} ( ${table["$id"]} )`);
|
|
1771
1801
|
}
|
|
1772
|
-
|
|
1802
|
+
success(`Successfully pushed ${tablesChanged.size} tables`);
|
|
1773
1803
|
};
|
|
1774
|
-
const pushCollection = async ({
|
|
1775
|
-
|
|
1804
|
+
const pushCollection = async ({ attempts }) => {
|
|
1805
|
+
warn("appwrite push collection has been deprecated. Please consider using 'appwrite push tables' instead");
|
|
1776
1806
|
const collections = [];
|
|
1777
1807
|
if (attempts) {
|
|
1778
1808
|
pollMaxDebounces = attempts;
|
|
1779
1809
|
}
|
|
1780
|
-
if (
|
|
1781
|
-
|
|
1782
|
-
collections.push(...
|
|
1810
|
+
if (cliConfig.all) {
|
|
1811
|
+
checkDeployConditions(localConfig);
|
|
1812
|
+
collections.push(...localConfig.getCollections());
|
|
1783
1813
|
}
|
|
1784
1814
|
else {
|
|
1785
|
-
const answers = await
|
|
1815
|
+
const answers = await inquirer.prompt(questionsPushCollections);
|
|
1786
1816
|
if (answers.collections) {
|
|
1787
1817
|
const configCollections = new Map();
|
|
1788
|
-
|
|
1789
|
-
configCollections.set(`${c[
|
|
1818
|
+
localConfig.getCollections().forEach((c) => {
|
|
1819
|
+
configCollections.set(`${c["databaseId"]}|${c["$id"]}`, c);
|
|
1790
1820
|
});
|
|
1791
1821
|
answers.collections.forEach((a) => {
|
|
1792
1822
|
const collection = configCollections.get(a);
|
|
@@ -1795,71 +1825,50 @@ const pushCollection = async ({ returnOnZero, attempts } = { returnOnZero: false
|
|
|
1795
1825
|
}
|
|
1796
1826
|
}
|
|
1797
1827
|
if (collections.length === 0) {
|
|
1798
|
-
|
|
1799
|
-
|
|
1828
|
+
log("No collections found.");
|
|
1829
|
+
hint("Use 'appwrite pull collections' to synchronize existing one, or use 'appwrite init collection' to create a new one.");
|
|
1800
1830
|
return;
|
|
1801
1831
|
}
|
|
1802
|
-
const databases = Array.from(new Set(collections.map((collection) => collection[
|
|
1832
|
+
const databases = Array.from(new Set(collections.map((collection) => collection["databaseId"])));
|
|
1803
1833
|
// Parallel db actions
|
|
1804
1834
|
await Promise.all(databases.map(async (databaseId) => {
|
|
1805
|
-
const localDatabase =
|
|
1835
|
+
const localDatabase = localConfig.getDatabase(databaseId);
|
|
1836
|
+
const databasesService = await getDatabasesService();
|
|
1806
1837
|
try {
|
|
1807
|
-
const database = await (
|
|
1808
|
-
databaseId: databaseId,
|
|
1809
|
-
parseOutput: false,
|
|
1810
|
-
});
|
|
1838
|
+
const database = await databasesService.get(databaseId);
|
|
1811
1839
|
if (database.name !== (localDatabase.name ?? databaseId)) {
|
|
1812
|
-
await (
|
|
1813
|
-
|
|
1814
|
-
name: localDatabase.name ?? databaseId,
|
|
1815
|
-
parseOutput: false
|
|
1816
|
-
});
|
|
1817
|
-
(0, parser_1.success)(`Updated ${localDatabase.name} ( ${databaseId} ) name`);
|
|
1840
|
+
await databasesService.update(databaseId, localDatabase.name ?? databaseId);
|
|
1841
|
+
success(`Updated ${localDatabase.name} ( ${databaseId} ) name`);
|
|
1818
1842
|
}
|
|
1819
1843
|
}
|
|
1820
1844
|
catch (err) {
|
|
1821
|
-
|
|
1822
|
-
await (
|
|
1823
|
-
databaseId: databaseId,
|
|
1824
|
-
name: localDatabase.name ?? databaseId,
|
|
1825
|
-
parseOutput: false,
|
|
1826
|
-
});
|
|
1845
|
+
log(`Database ${databaseId} not found. Creating it now ...`);
|
|
1846
|
+
await databasesService.create(databaseId, localDatabase.name ?? databaseId);
|
|
1827
1847
|
}
|
|
1828
1848
|
}));
|
|
1829
|
-
if (!(await approveChanges(collections,
|
|
1849
|
+
if (!(await approveChanges(collections, async (args) => {
|
|
1850
|
+
const databasesService = await getDatabasesService();
|
|
1851
|
+
return await databasesService.getCollection(args.databaseId, args.collectionId);
|
|
1852
|
+
}, KeysCollection, "collectionId", "collections", ["attributes", "indexes"], "databaseId", "databaseId"))) {
|
|
1830
1853
|
return;
|
|
1831
1854
|
}
|
|
1832
1855
|
// Parallel collection actions
|
|
1833
1856
|
await Promise.all(collections.map(async (collection) => {
|
|
1834
1857
|
try {
|
|
1835
|
-
const
|
|
1836
|
-
|
|
1837
|
-
collectionId: collection['$id'],
|
|
1838
|
-
parseOutput: false,
|
|
1839
|
-
});
|
|
1858
|
+
const databasesService = await getDatabasesService();
|
|
1859
|
+
const remoteCollection = await databasesService.getCollection(collection["databaseId"], collection["$id"]);
|
|
1840
1860
|
if (remoteCollection.name !== collection.name) {
|
|
1841
|
-
await (
|
|
1842
|
-
|
|
1843
|
-
collectionId: collection['$id'],
|
|
1844
|
-
name: collection.name,
|
|
1845
|
-
parseOutput: false
|
|
1846
|
-
});
|
|
1847
|
-
(0, parser_1.success)(`Updated ${collection.name} ( ${collection['$id']} ) name`);
|
|
1861
|
+
await databasesService.updateCollection(collection["databaseId"], collection["$id"], collection.name);
|
|
1862
|
+
success(`Updated ${collection.name} ( ${collection["$id"]} ) name`);
|
|
1848
1863
|
}
|
|
1849
1864
|
collection.remoteVersion = remoteCollection;
|
|
1850
1865
|
collection.isExisted = true;
|
|
1851
1866
|
}
|
|
1852
1867
|
catch (e) {
|
|
1853
1868
|
if (Number(e.code) === 404) {
|
|
1854
|
-
|
|
1855
|
-
await (
|
|
1856
|
-
|
|
1857
|
-
collectionId: collection['$id'],
|
|
1858
|
-
name: collection.name,
|
|
1859
|
-
documentSecurity: collection.documentSecurity,
|
|
1860
|
-
permissions: collection['$permissions'],
|
|
1861
|
-
parseOutput: false
|
|
1862
|
-
});
|
|
1869
|
+
log(`Collection ${collection.name} does not exist in the project. Creating ... `);
|
|
1870
|
+
const databasesService = await getDatabasesService();
|
|
1871
|
+
await databasesService.createCollection(collection["databaseId"], collection["$id"], collection.name, collection.documentSecurity, collection["$permissions"]);
|
|
1863
1872
|
}
|
|
1864
1873
|
else {
|
|
1865
1874
|
throw e;
|
|
@@ -1874,11 +1883,14 @@ const pushCollection = async ({ returnOnZero, attempts } = { returnOnZero: false
|
|
|
1874
1883
|
if (collection.isExisted) {
|
|
1875
1884
|
attributes = await attributesToCreate(collection.remoteVersion.attributes, collection.attributes, collection);
|
|
1876
1885
|
indexes = await attributesToCreate(collection.remoteVersion.indexes, collection.indexes, collection, true);
|
|
1877
|
-
if (
|
|
1886
|
+
if (Array.isArray(attributes) &&
|
|
1887
|
+
attributes.length <= 0 &&
|
|
1888
|
+
Array.isArray(indexes) &&
|
|
1889
|
+
indexes.length <= 0) {
|
|
1878
1890
|
continue;
|
|
1879
1891
|
}
|
|
1880
1892
|
}
|
|
1881
|
-
|
|
1893
|
+
log(`Pushing collection ${collection.name} ( ${collection["databaseId"]} - ${collection["$id"]} ) attributes`);
|
|
1882
1894
|
try {
|
|
1883
1895
|
await createAttributes(attributes, collection);
|
|
1884
1896
|
}
|
|
@@ -1892,27 +1904,27 @@ const pushCollection = async ({ returnOnZero, attempts } = { returnOnZero: false
|
|
|
1892
1904
|
throw e;
|
|
1893
1905
|
}
|
|
1894
1906
|
numberOfCollections++;
|
|
1895
|
-
|
|
1907
|
+
success(`Successfully pushed ${collection.name} ( ${collection["$id"]} )`);
|
|
1896
1908
|
}
|
|
1897
|
-
|
|
1909
|
+
success(`Successfully pushed ${numberOfCollections} collections`);
|
|
1898
1910
|
};
|
|
1899
|
-
const pushBucket = async (
|
|
1911
|
+
const pushBucket = async () => {
|
|
1900
1912
|
let response = {};
|
|
1901
1913
|
let bucketIds = [];
|
|
1902
|
-
const configBuckets =
|
|
1903
|
-
if (
|
|
1904
|
-
|
|
1914
|
+
const configBuckets = localConfig.getBuckets();
|
|
1915
|
+
if (cliConfig.all) {
|
|
1916
|
+
checkDeployConditions(localConfig);
|
|
1905
1917
|
bucketIds.push(...configBuckets.map((b) => b.$id));
|
|
1906
1918
|
}
|
|
1907
1919
|
if (bucketIds.length === 0) {
|
|
1908
|
-
const answers = await
|
|
1920
|
+
const answers = await inquirer.prompt(questionsPushBuckets);
|
|
1909
1921
|
if (answers.buckets) {
|
|
1910
1922
|
bucketIds.push(...answers.buckets);
|
|
1911
1923
|
}
|
|
1912
1924
|
}
|
|
1913
1925
|
if (bucketIds.length === 0) {
|
|
1914
|
-
|
|
1915
|
-
|
|
1926
|
+
log("No buckets found.");
|
|
1927
|
+
hint("Use 'appwrite pull buckets' to synchronize existing one, or use 'appwrite init bucket' to create a new one.");
|
|
1916
1928
|
return;
|
|
1917
1929
|
}
|
|
1918
1930
|
let buckets = [];
|
|
@@ -1920,72 +1932,49 @@ const pushBucket = async ({ returnOnZero } = { returnOnZero: false }) => {
|
|
|
1920
1932
|
const idBuckets = configBuckets.filter((b) => b.$id === bucketId);
|
|
1921
1933
|
buckets.push(...idBuckets);
|
|
1922
1934
|
}
|
|
1923
|
-
if (!(await approveChanges(buckets,
|
|
1935
|
+
if (!(await approveChanges(buckets, async (args) => {
|
|
1936
|
+
const storageService = await getStorageService();
|
|
1937
|
+
return await storageService.getBucket(args.bucketId);
|
|
1938
|
+
}, KeysStorage, "bucketId", "buckets"))) {
|
|
1924
1939
|
return;
|
|
1925
1940
|
}
|
|
1926
|
-
|
|
1941
|
+
log("Pushing buckets ...");
|
|
1927
1942
|
for (let bucket of buckets) {
|
|
1928
|
-
|
|
1943
|
+
log(`Pushing bucket ${chalk.bold(bucket["name"])} ...`);
|
|
1944
|
+
const storageService = await getStorageService();
|
|
1929
1945
|
try {
|
|
1930
|
-
response = await (
|
|
1931
|
-
|
|
1932
|
-
parseOutput: false,
|
|
1933
|
-
});
|
|
1934
|
-
await (0, storage_1.storageUpdateBucket)({
|
|
1935
|
-
bucketId: bucket['$id'],
|
|
1936
|
-
name: bucket.name,
|
|
1937
|
-
permissions: bucket['$permissions'],
|
|
1938
|
-
fileSecurity: bucket.fileSecurity,
|
|
1939
|
-
enabled: bucket.enabled,
|
|
1940
|
-
maximumFileSize: bucket.maximumFileSize,
|
|
1941
|
-
allowedFileExtensions: bucket.allowedFileExtensions,
|
|
1942
|
-
encryption: bucket.encryption,
|
|
1943
|
-
antivirus: bucket.antivirus,
|
|
1944
|
-
compression: bucket.compression,
|
|
1945
|
-
parseOutput: false
|
|
1946
|
-
});
|
|
1946
|
+
response = await storageService.getBucket(bucket["$id"]);
|
|
1947
|
+
await storageService.updateBucket(bucket["$id"], bucket.name, bucket["$permissions"], bucket.fileSecurity, bucket.enabled, bucket.maximumFileSize, bucket.allowedFileExtensions, bucket.encryption, bucket.antivirus, bucket.compression);
|
|
1947
1948
|
}
|
|
1948
1949
|
catch (e) {
|
|
1949
1950
|
if (Number(e.code) === 404) {
|
|
1950
|
-
|
|
1951
|
-
response = await (
|
|
1952
|
-
bucketId: bucket['$id'],
|
|
1953
|
-
name: bucket.name,
|
|
1954
|
-
permissions: bucket['$permissions'],
|
|
1955
|
-
fileSecurity: bucket.fileSecurity,
|
|
1956
|
-
enabled: bucket.enabled,
|
|
1957
|
-
maximumFileSize: bucket.maximumFileSize,
|
|
1958
|
-
allowedFileExtensions: bucket.allowedFileExtensions,
|
|
1959
|
-
compression: bucket.compression,
|
|
1960
|
-
encryption: bucket.encryption,
|
|
1961
|
-
antivirus: bucket.antivirus,
|
|
1962
|
-
parseOutput: false
|
|
1963
|
-
});
|
|
1951
|
+
log(`Bucket ${bucket.name} does not exist in the project. Creating ... `);
|
|
1952
|
+
response = await storageService.createBucket(bucket["$id"], bucket.name, bucket["$permissions"], bucket.fileSecurity, bucket.enabled, bucket.maximumFileSize, bucket.allowedFileExtensions, bucket.compression, bucket.encryption, bucket.antivirus);
|
|
1964
1953
|
}
|
|
1965
1954
|
else {
|
|
1966
1955
|
throw e;
|
|
1967
1956
|
}
|
|
1968
1957
|
}
|
|
1969
1958
|
}
|
|
1970
|
-
|
|
1959
|
+
success(`Successfully pushed ${buckets.length} buckets.`);
|
|
1971
1960
|
};
|
|
1972
|
-
const pushTeam = async (
|
|
1961
|
+
const pushTeam = async () => {
|
|
1973
1962
|
let response = {};
|
|
1974
1963
|
let teamIds = [];
|
|
1975
|
-
const configTeams =
|
|
1976
|
-
if (
|
|
1977
|
-
|
|
1964
|
+
const configTeams = localConfig.getTeams();
|
|
1965
|
+
if (cliConfig.all) {
|
|
1966
|
+
checkDeployConditions(localConfig);
|
|
1978
1967
|
teamIds.push(...configTeams.map((t) => t.$id));
|
|
1979
1968
|
}
|
|
1980
1969
|
if (teamIds.length === 0) {
|
|
1981
|
-
const answers = await
|
|
1970
|
+
const answers = await inquirer.prompt(questionsPushTeams);
|
|
1982
1971
|
if (answers.teams) {
|
|
1983
1972
|
teamIds.push(...answers.teams);
|
|
1984
1973
|
}
|
|
1985
1974
|
}
|
|
1986
1975
|
if (teamIds.length === 0) {
|
|
1987
|
-
|
|
1988
|
-
|
|
1976
|
+
log("No teams found.");
|
|
1977
|
+
hint("Use 'appwrite pull teams' to synchronize existing one, or use 'appwrite init team' to create a new one.");
|
|
1989
1978
|
return;
|
|
1990
1979
|
}
|
|
1991
1980
|
let teams = [];
|
|
@@ -1993,56 +1982,49 @@ const pushTeam = async ({ returnOnZero } = { returnOnZero: false }) => {
|
|
|
1993
1982
|
const idTeams = configTeams.filter((t) => t.$id === teamId);
|
|
1994
1983
|
teams.push(...idTeams);
|
|
1995
1984
|
}
|
|
1996
|
-
if (!(await approveChanges(teams,
|
|
1985
|
+
if (!(await approveChanges(teams, async (args) => {
|
|
1986
|
+
const teamsService = await getTeamsService();
|
|
1987
|
+
return await teamsService.get(args.teamId);
|
|
1988
|
+
}, KeysTeams, "teamId", "teams"))) {
|
|
1997
1989
|
return;
|
|
1998
1990
|
}
|
|
1999
|
-
|
|
1991
|
+
log("Pushing teams ...");
|
|
2000
1992
|
for (let team of teams) {
|
|
2001
|
-
|
|
1993
|
+
log(`Pushing team ${chalk.bold(team["name"])} ...`);
|
|
1994
|
+
const teamsService = await getTeamsService();
|
|
2002
1995
|
try {
|
|
2003
|
-
response = await (
|
|
2004
|
-
|
|
2005
|
-
parseOutput: false,
|
|
2006
|
-
});
|
|
2007
|
-
await (0, teams_1.teamsUpdateName)({
|
|
2008
|
-
teamId: team['$id'],
|
|
2009
|
-
name: team.name,
|
|
2010
|
-
parseOutput: false
|
|
2011
|
-
});
|
|
1996
|
+
response = await teamsService.get(team["$id"]);
|
|
1997
|
+
await teamsService.updateName(team["$id"], team.name);
|
|
2012
1998
|
}
|
|
2013
1999
|
catch (e) {
|
|
2014
2000
|
if (Number(e.code) === 404) {
|
|
2015
|
-
|
|
2016
|
-
response = await (
|
|
2017
|
-
teamId: team['$id'],
|
|
2018
|
-
name: team.name,
|
|
2019
|
-
parseOutput: false
|
|
2020
|
-
});
|
|
2001
|
+
log(`Team ${team.name} does not exist in the project. Creating ... `);
|
|
2002
|
+
response = await teamsService.create(team["$id"], team.name);
|
|
2021
2003
|
}
|
|
2022
2004
|
else {
|
|
2023
2005
|
throw e;
|
|
2024
2006
|
}
|
|
2025
2007
|
}
|
|
2026
2008
|
}
|
|
2027
|
-
|
|
2009
|
+
success(`Successfully pushed ${teams.length} teams.`);
|
|
2028
2010
|
};
|
|
2029
|
-
const pushMessagingTopic = async (
|
|
2011
|
+
const pushMessagingTopic = async () => {
|
|
2030
2012
|
let response = {};
|
|
2031
2013
|
let topicsIds = [];
|
|
2032
|
-
const configTopics =
|
|
2033
|
-
if (
|
|
2034
|
-
|
|
2014
|
+
const configTopics = localConfig.getMessagingTopics();
|
|
2015
|
+
if (cliConfig.all) {
|
|
2016
|
+
checkDeployConditions(localConfig);
|
|
2035
2017
|
topicsIds.push(...configTopics.map((b) => b.$id));
|
|
2036
2018
|
}
|
|
2037
2019
|
if (topicsIds.length === 0) {
|
|
2038
|
-
const answers = await
|
|
2020
|
+
const answers = await inquirer.prompt(questionsPushMessagingTopics);
|
|
2039
2021
|
if (answers.topics) {
|
|
2040
2022
|
topicsIds.push(...answers.topics);
|
|
2041
2023
|
}
|
|
2042
2024
|
}
|
|
2043
2025
|
if (topicsIds.length === 0) {
|
|
2044
|
-
|
|
2045
|
-
|
|
2026
|
+
log("No topics found.");
|
|
2027
|
+
hint("Use 'appwrite pull topics' to synchronize existing one, or use 'appwrite init topic' to create a new one.");
|
|
2046
2028
|
return;
|
|
2047
2029
|
}
|
|
2048
2030
|
let topics = [];
|
|
@@ -2050,58 +2032,49 @@ const pushMessagingTopic = async ({ returnOnZero } = { returnOnZero: false }) =>
|
|
|
2050
2032
|
const idTopic = configTopics.filter((b) => b.$id === topicId);
|
|
2051
2033
|
topics.push(...idTopic);
|
|
2052
2034
|
}
|
|
2053
|
-
if (!(await approveChanges(topics,
|
|
2035
|
+
if (!(await approveChanges(topics, async (args) => {
|
|
2036
|
+
const messagingService = await getMessagingService();
|
|
2037
|
+
return await messagingService.getTopic(args.topicId);
|
|
2038
|
+
}, KeysTopics, "topicId", "topics"))) {
|
|
2054
2039
|
return;
|
|
2055
2040
|
}
|
|
2056
|
-
|
|
2041
|
+
log("Pushing topics ...");
|
|
2057
2042
|
for (let topic of topics) {
|
|
2058
|
-
|
|
2043
|
+
log(`Pushing topic ${chalk.bold(topic["name"])} ...`);
|
|
2044
|
+
const messagingService = await getMessagingService();
|
|
2059
2045
|
try {
|
|
2060
|
-
response = await (
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
});
|
|
2064
|
-
(0, parser_1.log)(`Topic ${topic.name} ( ${topic['$id']} ) already exists.`);
|
|
2065
|
-
await (0, messaging_1.messagingUpdateTopic)({
|
|
2066
|
-
topicId: topic['$id'],
|
|
2067
|
-
name: topic.name,
|
|
2068
|
-
subscribe: topic.subscribe,
|
|
2069
|
-
parseOutput: false
|
|
2070
|
-
});
|
|
2046
|
+
response = await messagingService.getTopic(topic["$id"]);
|
|
2047
|
+
log(`Topic ${topic.name} ( ${topic["$id"]} ) already exists.`);
|
|
2048
|
+
await messagingService.updateTopic(topic["$id"], topic.name, topic.subscribe);
|
|
2071
2049
|
}
|
|
2072
2050
|
catch (e) {
|
|
2073
2051
|
if (Number(e.code) === 404) {
|
|
2074
|
-
|
|
2075
|
-
response = await (
|
|
2076
|
-
|
|
2077
|
-
name: topic.name,
|
|
2078
|
-
subscribe: topic.subscribe,
|
|
2079
|
-
parseOutput: false
|
|
2080
|
-
});
|
|
2081
|
-
(0, parser_1.success)(`Created ${topic.name} ( ${topic['$id']} )`);
|
|
2052
|
+
log(`Topic ${topic.name} does not exist in the project. Creating ... `);
|
|
2053
|
+
response = await messagingService.createTopic(topic["$id"], topic.name, topic.subscribe);
|
|
2054
|
+
success(`Created ${topic.name} ( ${topic["$id"]} )`);
|
|
2082
2055
|
}
|
|
2083
2056
|
else {
|
|
2084
2057
|
throw e;
|
|
2085
2058
|
}
|
|
2086
2059
|
}
|
|
2087
2060
|
}
|
|
2088
|
-
|
|
2061
|
+
success(`Successfully pushed ${topics.length} topics.`);
|
|
2089
2062
|
};
|
|
2090
|
-
|
|
2091
|
-
.description(
|
|
2092
|
-
.action((
|
|
2093
|
-
|
|
2063
|
+
export const push = new Command("push")
|
|
2064
|
+
.description(commandDescriptions["push"])
|
|
2065
|
+
.action(actionRunner(() => pushResources({ skipDeprecated: true })));
|
|
2066
|
+
push
|
|
2094
2067
|
.command("all")
|
|
2095
2068
|
.description("Push all resource.")
|
|
2096
|
-
.action(
|
|
2097
|
-
|
|
2098
|
-
return pushResources();
|
|
2069
|
+
.action(actionRunner(() => {
|
|
2070
|
+
cliConfig.all = true;
|
|
2071
|
+
return pushResources({ skipDeprecated: true });
|
|
2099
2072
|
}));
|
|
2100
|
-
|
|
2073
|
+
push
|
|
2101
2074
|
.command("settings")
|
|
2102
2075
|
.description("Push project name, services and auth settings")
|
|
2103
|
-
.action(
|
|
2104
|
-
|
|
2076
|
+
.action(actionRunner(pushSettings));
|
|
2077
|
+
push
|
|
2105
2078
|
.command("function")
|
|
2106
2079
|
.alias("functions")
|
|
2107
2080
|
.description("Push functions in the current directory.")
|
|
@@ -2109,8 +2082,8 @@ exports.push
|
|
|
2109
2082
|
.option(`-A, --async`, `Don't wait for functions deployments status`)
|
|
2110
2083
|
.option("--no-code", "Don't push the function's code")
|
|
2111
2084
|
.option("--with-variables", `Push function variables.`)
|
|
2112
|
-
.action(
|
|
2113
|
-
|
|
2085
|
+
.action(actionRunner(pushFunction));
|
|
2086
|
+
push
|
|
2114
2087
|
.command("site")
|
|
2115
2088
|
.alias("sites")
|
|
2116
2089
|
.description("Push sites in the current directory.")
|
|
@@ -2118,37 +2091,37 @@ exports.push
|
|
|
2118
2091
|
.option(`-A, --async`, `Don't wait for sites deployments status`)
|
|
2119
2092
|
.option("--no-code", "Don't push the site's code")
|
|
2120
2093
|
.option("--with-variables", `Push site variables.`)
|
|
2121
|
-
.action(
|
|
2122
|
-
|
|
2094
|
+
.action(actionRunner(pushSite));
|
|
2095
|
+
push
|
|
2123
2096
|
.command("collection")
|
|
2124
2097
|
.alias("collections")
|
|
2125
2098
|
.description("Push collections in the current project. (deprecated, please use 'push tables' instead)")
|
|
2126
2099
|
.option(`-a, --attempts <numberOfAttempts>`, `Max number of attempts before timing out. default: 30.`)
|
|
2127
|
-
.action(
|
|
2128
|
-
|
|
2100
|
+
.action(actionRunner(pushCollection));
|
|
2101
|
+
push
|
|
2129
2102
|
.command("table")
|
|
2130
2103
|
.alias("tables")
|
|
2131
2104
|
.description("Push tables in the current project.")
|
|
2132
2105
|
.option(`-a, --attempts <numberOfAttempts>`, `Max number of attempts before timing out. default: 30.`)
|
|
2133
|
-
.action(
|
|
2134
|
-
|
|
2106
|
+
.action(actionRunner(pushTable));
|
|
2107
|
+
push
|
|
2135
2108
|
.command("bucket")
|
|
2136
2109
|
.alias("buckets")
|
|
2137
2110
|
.description("Push buckets in the current project.")
|
|
2138
|
-
.action(
|
|
2139
|
-
|
|
2111
|
+
.action(actionRunner(pushBucket));
|
|
2112
|
+
push
|
|
2140
2113
|
.command("team")
|
|
2141
2114
|
.alias("teams")
|
|
2142
2115
|
.description("Push teams in the current project.")
|
|
2143
|
-
.action(
|
|
2144
|
-
|
|
2116
|
+
.action(actionRunner(pushTeam));
|
|
2117
|
+
push
|
|
2145
2118
|
.command("topic")
|
|
2146
2119
|
.alias("topics")
|
|
2147
2120
|
.description("Push messaging topics in the current project.")
|
|
2148
|
-
.action(
|
|
2149
|
-
|
|
2150
|
-
.description(
|
|
2151
|
-
.action(
|
|
2152
|
-
|
|
2121
|
+
.action(actionRunner(pushMessagingTopic));
|
|
2122
|
+
export const deploy = new Command("deploy")
|
|
2123
|
+
.description("Removed. Use appwrite push instead")
|
|
2124
|
+
.action(actionRunner(async () => {
|
|
2125
|
+
warn("appwrite deploy has been removed. Please use 'appwrite push' instead");
|
|
2153
2126
|
}));
|
|
2154
2127
|
//# sourceMappingURL=push.js.map
|