Skip to content

Commit 8c64326

Browse files
committed
hot fixes
1 parent c61704e commit 8c64326

File tree

13 files changed

+268
-40
lines changed

13 files changed

+268
-40
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using
2929

3030
```sh
3131
$ appwrite -v
32-
10.0.0
32+
9.0.3
3333
```
3434

3535
### Install using prebuilt binaries
@@ -60,7 +60,7 @@ $ scoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/sc
6060
Once the installation completes, you can verify your install using
6161
```
6262
$ appwrite -v
63-
10.0.0
63+
9.0.3
6464
```
6565

6666
## Getting Started

install.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# You can use "View source" of this page to see the full script.
1414

1515
# REPO
16-
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/10.0.0/appwrite-cli-win-x64.exe"
17-
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/10.0.0/appwrite-cli-win-arm64.exe"
16+
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/9.0.3/appwrite-cli-win-x64.exe"
17+
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/9.0.3/appwrite-cli-win-arm64.exe"
1818

1919
$APPWRITE_BINARY_NAME = "appwrite.exe"
2020

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ printSuccess() {
9797
downloadBinary() {
9898
echo "[2/4] Downloading executable for $OS ($ARCH) ..."
9999

100-
GITHUB_LATEST_VERSION="10.0.0"
100+
GITHUB_LATEST_VERSION="9.0.3"
101101
GITHUB_FILE="appwrite-cli-${OS}-${ARCH}"
102102
GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE"
103103

lib/client.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const os = require('os');
2+
const join = require('path').join;
23
const https = require("https");
34
const { fetch, FormData, Agent } = require("undici");
45
const JSONbig = require("json-bigint")({ storeAsString: false });
@@ -16,8 +17,8 @@ class Client {
1617
'x-sdk-name': 'Command Line',
1718
'x-sdk-platform': 'console',
1819
'x-sdk-language': 'cli',
19-
'x-sdk-version': '10.0.0',
20-
'user-agent' : `AppwriteCLI/10.0.0 (${os.type()} ${os.version()}; ${os.arch()})`,
20+
'x-sdk-version': '9.0.3',
21+
'user-agent' : `AppwriteCLI/9.0.3 (${os.type()} ${os.version()}; ${os.arch()})`,
2122
'X-Appwrite-Response-Format' : '1.8.0',
2223
};
2324
}
@@ -149,7 +150,7 @@ class Client {
149150

150151
async call(method, path = "", headers = {}, params = {}, responseType = "json") {
151152
headers = {...this.headers, ...headers};
152-
const url = new URL(this.endpoint + path);
153+
const url = new URL(join(this.endpoint + path));
153154

154155
let body = undefined;
155156

lib/commands/generic.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const { sdkForConsole } = require("../sdks");
55
const { globalConfig, localConfig } = require("../config");
66
const { actionRunner, success, parseBool, commandDescriptions, error, parse, hint, log, drawTable, cliConfig } = require("../parser");
77
const ID = require("../id");
8-
const { questionsLogin, questionsLogout, questionsListFactors, questionsMfaChallenge } = require("../questions");
9-
const { accountUpdateMfaChallenge, accountCreateMfaChallenge, accountGet, accountCreateEmailPasswordSession, accountDeleteSession } = require("./account");
8+
const { questionsLogin, questionsLogout, questionsListFactors, questionsMFAChallenge } = require("../questions");
9+
const { accountUpdateMFAChallenge, accountCreateMFAChallenge, accountGet, accountCreateEmailPasswordSession, accountDeleteSession } = require("./account");
1010

1111
const DEFAULT_ENDPOINT = 'https://cloud.appwrite.io/v1';
1212

@@ -71,15 +71,15 @@ const loginCommand = async ({ email, password, endpoint, mfa, code }) => {
7171
if (error.response === 'user_more_factors_required') {
7272
const { factor } = mfa ? { factor: mfa } : await inquirer.prompt(questionsListFactors);
7373

74-
const challenge = await accountCreateMfaChallenge({
74+
const challenge = await accountCreateMFAChallenge({
7575
factor,
7676
parseOutput: false,
7777
sdk: client
7878
});
7979

80-
const { otp } = code ? { otp: code } : await inquirer.prompt(questionsMfaChallenge);
80+
const { otp } = code ? { otp: code } : await inquirer.prompt(questionsMFAChallenge);
8181

82-
await accountUpdateMfaChallenge({
82+
await accountUpdateMFAChallenge({
8383
challengeId: challenge.$id,
8484
otp,
8585
parseOutput: false,

lib/commands/push.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,25 @@ const createAttributes = async (attributes, collection) => {
918918

919919
success(`Created ${attributes.length} attributes`);
920920
}
921+
const createColumns = async (columns, table) => {
922+
for (let column of columns) {
923+
if (column.side !== 'child') {
924+
await createAttribute(table['databaseId'], table['$id'], column);
925+
}
926+
}
927+
928+
const result = await awaitPools.expectAttributes(
929+
table['databaseId'],
930+
table['$id'],
931+
table.columns.filter(column => column.side !== 'child').map(column => column.key)
932+
);
933+
934+
if (!result) {
935+
throw new Error(`Column creation timed out.`);
936+
}
937+
938+
success(`Created ${columns.length} columns`);
939+
}
921940

922941
const pushResources = async () => {
923942
const actions = {
@@ -1797,13 +1816,12 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
17971816
if ((Array.isArray(columns) && columns.length <= 0) && (Array.isArray(indexes) && indexes.length <= 0)) {
17981817
continue;
17991818
}
1800-
18011819
}
18021820

18031821
log(`Pushing table ${table.name} ( ${table['databaseId']} - ${table['$id']} ) attributes`)
18041822

18051823
try {
1806-
await createAttributes(columns, table)
1824+
await createColumns(columns, table)
18071825
} catch (e) {
18081826
throw e;
18091827
}

lib/commands/types.js

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const { Swift } = require("../type-generation/languages/swift");
1212
const { Java } = require("../type-generation/languages/java");
1313
const { Dart } = require("../type-generation/languages/dart");
1414
const { JavaScript } = require("../type-generation/languages/javascript");
15+
const { CSharp } = require("../type-generation/languages/csharp");
1516

1617
/**
1718
* @param {string} language
@@ -33,6 +34,8 @@ function createLanguageMeta(language) {
3334
return new Java();
3435
case "dart":
3536
return new Dart();
37+
case "cs":
38+
return new CSharp();
3639
default:
3740
throw new Error(`Language '${language}' is not supported`);
3841
}
@@ -55,7 +58,7 @@ const typesLanguageOption = new Option(
5558
"-l, --language <language>",
5659
"The language of the types"
5760
)
58-
.choices(["auto", "ts", "js", "php", "kotlin", "swift", "java", "dart"])
61+
.choices(["auto", "ts", "js", "php", "kotlin", "swift", "java", "dart", "cs"])
5962
.default("auto");
6063

6164
const typesStrictOption = new Option(
@@ -97,22 +100,58 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language, strict})
97100
fs.mkdirSync(outputDirectory, { recursive: true });
98101
}
99102

100-
const collections = localConfig.getCollections();
101-
if (collections.length === 0) {
102-
const configFileName = path.basename(localConfig.path);
103-
throw new Error(`No collections found in configuration. Make sure ${configFileName} exists and contains collections.`);
103+
// Try tables first, fallback to collections
104+
let tables = localConfig.getTables();
105+
let collections = [];
106+
let dataSource = 'tables';
107+
108+
if (tables.length === 0) {
109+
collections = localConfig.getCollections();
110+
dataSource = 'collections';
111+
112+
if (collections.length === 0) {
113+
const configFileName = path.basename(localConfig.path);
114+
throw new Error(`No tables or collections found in configuration. Make sure ${configFileName} exists and contains tables or collections.`);
115+
}
116+
}
117+
118+
// Use tables if available, otherwise use collections
119+
let dataItems = tables.length > 0 ? tables : collections;
120+
const itemType = tables.length > 0 ? 'tables' : 'collections';
121+
122+
// Normalize tables data: rename 'columns' to 'attributes' for template compatibility
123+
if (tables.length > 0) {
124+
dataItems = dataItems.map(table => {
125+
const { columns, ...rest } = table;
126+
return {
127+
...rest,
128+
attributes: (columns || []).map(column => {
129+
if (column.relatedTable) {
130+
const { relatedTable, ...columnRest } = column;
131+
return {
132+
...columnRest,
133+
relatedCollection: relatedTable
134+
};
135+
}
136+
return column;
137+
})
138+
};
139+
});
104140
}
105141

106-
log(`Found ${collections.length} collections: ${collections.map(c => c.name).join(", ")}`);
142+
log(`Found ${dataItems.length} ${itemType}: ${dataItems.map(c => c.name).join(", ")}`);
143+
144+
// Use columns if available, otherwise use attributes
145+
const resourceType = tables.length > 0 ? 'columns' : 'attributes';
107146

108-
const totalAttributes = collections.reduce((count, collection) => count + collection.attributes.length, 0);
109-
log(`Found ${totalAttributes} attributes across all collections`);
147+
const totalAttributes = dataItems.reduce((count, item) => count + (item.attributes || []).length, 0);
148+
log(`Found ${totalAttributes} ${resourceType} across all ${itemType}`);
110149

111150
const templater = ejs.compile(meta.getTemplate());
112151

113152
if (meta.isSingleFile()) {
114153
const content = templater({
115-
collections,
154+
collections: dataItems,
116155
strict,
117156
...templateHelpers,
118157
getType: meta.getType,
@@ -123,23 +162,23 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language, strict})
123162
fs.writeFileSync(destination, content);
124163
log(`Added types to ${destination}`);
125164
} else {
126-
for (const collection of collections) {
165+
for (const item of dataItems) {
127166
const content = templater({
128-
collections,
129-
collection,
167+
collections: dataItems,
168+
collection: item,
130169
strict,
131170
...templateHelpers,
132171
getType: meta.getType,
133172
});
134173

135-
const destination = path.join(outputDirectory, meta.getFileName(collection));
174+
const destination = path.join(outputDirectory, meta.getFileName(item));
136175

137176
fs.writeFileSync(destination, content);
138-
log(`Added types for ${collection.name} to ${destination}`);
177+
log(`Added types for ${item.name} to ${destination}`);
139178
}
140179
}
141180

142-
success(`Generated types for all the listed collections`);
181+
success(`Generated types for all the listed ${itemType}`);
143182
});
144183

145184
const types = new Command("types")

lib/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const KeysColumns = new Set([
5555
// enum
5656
"elements",
5757
// relationship
58-
"relatedCollection",
58+
"relatedTable",
5959
"relationType",
6060
"twoWay",
6161
"twoWayKey",

lib/parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ const parseError = (err) => {
122122
} catch {
123123
}
124124

125-
const version = '10.0.0';
125+
const version = '9.0.3';
126126
const stepsToReproduce = `Running \`appwrite ${cliConfig.reportData.data.args.join(' ')}\``;
127127
const yourEnvironment = `CLI version: ${version}\nOperation System: ${os.type()}\nAppwrite version: ${appwriteVersion}\nIs Cloud: ${isCloud()}`;
128128

lib/questions.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { projectsList } = require('./commands/projects');
55
const { organizationsList } = require('./commands/organizations');
66
const { teamsList } = require('./commands/teams');
77
const { functionsListRuntimes, functionsListSpecifications, functionsList } = require('./commands/functions');
8-
const { accountListMfaFactors } = require("./commands/account");
8+
const { accountListMFAFactors } = require("./commands/account");
99
const { sdkForConsole } = require("./sdks");
1010
const { validateRequired } = require("./validations");
1111
const { paginate } = require('./paginate');
@@ -877,7 +877,7 @@ const questionsListFactors = [
877877
message: "Your account is protected by multi-factor authentication. Please choose one for verification.",
878878
choices: async () => {
879879
let client = await sdkForConsole(false);
880-
const factors = await accountListMfaFactors({
880+
const factors = await accountListMFAFactors({
881881
sdk: client,
882882
parseOutput: false
883883
});
@@ -906,7 +906,7 @@ const questionsListFactors = [
906906
}
907907
];
908908

909-
const questionsMfaChallenge = [
909+
const questionsMFAChallenge = [
910910
{
911911
type: "input",
912912
name: "otp",
@@ -1019,7 +1019,7 @@ module.exports = {
10191019
questionsPushTeams,
10201020
questionsGetEntrypoint,
10211021
questionsListFactors,
1022-
questionsMfaChallenge,
1022+
questionsMFAChallenge,
10231023
questionsRunFunctions,
10241024
questionGetEndpoint,
10251025
questionsInitResources,

0 commit comments

Comments
 (0)