-
Notifications
You must be signed in to change notification settings - Fork 37
feat: Command Line SDK update for version 10.0.1 #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,10 +50,12 @@ const { | |
databasesUpdateCollection | ||
} = require("./databases"); | ||
const { | ||
tablesDBCreate, | ||
tablesDBGet, | ||
tablesDBUpdate, | ||
tablesDBCreateTable, | ||
tablesDBGetTable, | ||
tablesDBUpdateTable, | ||
tablesDBCreateTable | ||
tablesDBUpdateTable | ||
} = require("./tables-db"); | ||
const { | ||
storageGetBucket, storageUpdateBucket, storageCreateBucket | ||
|
@@ -548,7 +550,7 @@ const createAttribute = (databaseId, collectionId, attribute) => { | |
return databasesCreateRelationshipAttribute({ | ||
databaseId, | ||
collectionId, | ||
relatedCollectionId: attribute.relatedCollection, | ||
relatedCollectionId: attribute.relatedTable ?? attribute.relatedCollection, | ||
type: attribute.relationType, | ||
twoWay: attribute.twoWay, | ||
key: attribute.key, | ||
|
@@ -667,7 +669,7 @@ const updateAttribute = (databaseId, collectionId, attribute) => { | |
return databasesUpdateRelationshipAttribute({ | ||
databaseId, | ||
collectionId, | ||
relatedCollectionId: attribute.relatedCollection, | ||
relatedCollectionId: attribute.relatedTable ?? attribute.relatedCollection, | ||
type: attribute.relationType, | ||
twoWay: attribute.twoWay, | ||
key: attribute.key, | ||
|
@@ -881,7 +883,7 @@ const createIndexes = async (indexes, collection) => { | |
collectionId: collection['$id'], | ||
key: index.key, | ||
type: index.type, | ||
attributes: index.attributes, | ||
attributes: index.columns ?? index.attributes, | ||
orders: index.orders, | ||
parseOutput: false | ||
}); | ||
|
@@ -1730,7 +1732,7 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) = | |
|
||
const databases = Array.from(new Set(tables.map(table => table['databaseId']))); | ||
|
||
// Parallel db actions | ||
// Parallel tablesDB actions | ||
await Promise.all(databases.map(async (databaseId) => { | ||
const localDatabase = localConfig.getTablesDB(databaseId); | ||
|
||
|
@@ -1741,7 +1743,7 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) = | |
}); | ||
|
||
if (database.name !== (localDatabase.name ?? databaseId)) { | ||
await databasesUpdate({ | ||
await tablesDBUpdate({ | ||
databaseId: databaseId, | ||
name: localDatabase.name ?? databaseId, | ||
parseOutput: false | ||
|
@@ -1752,7 +1754,7 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) = | |
} catch (err) { | ||
log(`Database ${databaseId} not found. Creating it now ...`); | ||
|
||
await databasesCreate({ | ||
await tablesDBCreate({ | ||
databaseId: databaseId, | ||
name: localDatabase.name ?? databaseId, | ||
parseOutput: false, | ||
|
@@ -1761,10 +1763,12 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) = | |
})); | ||
|
||
|
||
if (!(await approveChanges(tables, tablesDBGetTable, KeysTable, 'tableId', 'tables', ['columns', 'indexes'], 'databaseId', 'databaseId',))) { | ||
if (!(await approveChanges(tables, tablesDBGetTable, KeysTable, 'tableId', 'tables', ['columns', 'indexes'], 'databaseId', 'databaseId'))) { | ||
return; | ||
} | ||
// Parallel collection actions | ||
let tablesChanged = new Set(); | ||
|
||
// Parallel tables actions | ||
await Promise.all(tables.map(async (table) => { | ||
try { | ||
const remoteTable = await tablesDBGetTable({ | ||
|
@@ -1773,15 +1777,23 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) = | |
parseOutput: false, | ||
}); | ||
|
||
if (remoteTable.name !== table.name) { | ||
const changes = []; | ||
if (remoteTable.name !== table.name) changes.push('name'); | ||
if (remoteTable.rowSecurity !== table.rowSecurity) changes.push('rowSecurity'); | ||
if (JSON.stringify(remoteTable['$permissions']) !== JSON.stringify(table['$permissions'])) changes.push('permissions'); | ||
|
||
if (changes.length > 0) { | ||
await tablesDBUpdateTable({ | ||
databaseId: table['databaseId'], | ||
tableId: table['$id'], | ||
name: table.name, | ||
parseOutput: false | ||
parseOutput: false, | ||
rowSecurity: table.rowSecurity, | ||
permissions: table['$permissions'] | ||
}) | ||
Comment on lines
+1781
to
1793
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't drop table We no longer propagate the table Apply this diff to restore the missing behavior: const changes = [];
if (remoteTable.name !== table.name) changes.push('name');
if (remoteTable.rowSecurity !== table.rowSecurity) changes.push('rowSecurity');
+ if (remoteTable.enabled !== table.enabled) changes.push('enabled');
if (JSON.stringify(remoteTable['$permissions']) !== JSON.stringify(table['$permissions'])) changes.push('permissions');
if (changes.length > 0) {
await tablesDBUpdateTable({
databaseId: table['databaseId'],
tableId: table['$id'],
name: table.name,
parseOutput: false,
rowSecurity: table.rowSecurity,
- permissions: table['$permissions']
+ permissions: table['$permissions'],
+ enabled: table.enabled
})
@@
await tablesDBCreateTable({
databaseId: table['databaseId'],
tableId: table['$id'],
name: table.name,
rowSecurity: table.rowSecurity,
- permissions: table['$permissions'],
+ permissions: table['$permissions'],
+ enabled: table.enabled,
parseOutput: false
}) Also applies to: 1805-1811 🤖 Prompt for AI Agents
|
||
|
||
success(`Updated ${table.name} ( ${table['$id']} ) name`); | ||
success(`Updated ${table.name} ( ${table['$id']} ) - ${changes.join(', ')}`); | ||
tablesChanged.add(table['$id']); | ||
} | ||
table.remoteVersion = remoteTable; | ||
|
||
|
@@ -1794,16 +1806,19 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) = | |
databaseId: table['databaseId'], | ||
tableId: table['$id'], | ||
name: table.name, | ||
documentSecurity: table.documentSecurity, | ||
rowSecurity: table.rowSecurity, | ||
permissions: table['$permissions'], | ||
parseOutput: false | ||
}) | ||
|
||
success(`Created ${table.name} ( ${table['$id']} )`); | ||
tablesChanged.add(table['$id']); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
})) | ||
let numberOfTables = 0; | ||
|
||
// Serialize attribute actions | ||
for (let table of tables) { | ||
let columns = table.columns; | ||
|
@@ -1831,11 +1846,11 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) = | |
} catch (e) { | ||
throw e; | ||
} | ||
numberOfTables++; | ||
tablesChanged.add(table['$id']); | ||
success(`Successfully pushed ${table.name} ( ${table['$id']} )`); | ||
} | ||
|
||
success(`Successfully pushed ${numberOfTables} tables`); | ||
success(`Successfully pushed ${tablesChanged.size} tables`); | ||
} | ||
|
||
const pushCollection = async ({ returnOnZero, attempts } = { returnOnZero: false }) => { | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -122,7 +122,7 @@ const parseError = (err) => { | |||||||||||||||||||||
} catch { | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
const version = '10.0.0'; | ||||||||||||||||||||||
const version = '10.0.1'; | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Avoid hardcoding the version string. The version is hardcoded here but Apply this diff to use the version from package.json: +const { description, version } = require('../package.json');
-const { description } = require('../package.json'); Then update line 125: - const version = '10.0.1';
+ // version is now imported from package.json above 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||
const stepsToReproduce = `Running \`appwrite ${cliConfig.reportData.data.args.join(' ')}\``; | ||||||||||||||||||||||
const yourEnvironment = `CLI version: ${version}\nOperation System: ${os.type()}\nAppwrite version: ${appwriteVersion}\nIs Cloud: ${isCloud()}`; | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Avoid hardcoding the version strings.
The version is hardcoded in the SDK headers. This creates maintenance burden and risks version drift. Consider importing the version from package.json for consistency.
Apply this approach:
📝 Committable suggestion
🤖 Prompt for AI Agents