appwrite-utils-cli 1.2.12 → 1.2.16
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/README.md +1 -0
- package/dist/collections/indexes.js +6 -7
- package/dist/functions/methods.d.ts +1 -0
- package/dist/functions/methods.js +5 -0
- package/dist/migrations/appwriteToX.js +2 -10
- package/dist/migrations/comprehensiveTransfer.js +187 -100
- package/package.json +1 -1
- package/src/collections/indexes.ts +6 -7
- package/src/functions/methods.ts +10 -0
- package/src/migrations/appwriteToX.ts +3 -17
- package/src/migrations/comprehensiveTransfer.ts +877 -364
package/README.md
CHANGED
@@ -637,6 +637,7 @@ npx appwrite-utils-cli appwrite-migrate --generateConstants --constantsLanguages
|
|
637
637
|
|
638
638
|
### Changelog
|
639
639
|
|
640
|
+
- 1.1.15: Fixed various transfer and sync functionalities
|
640
641
|
- 1.0.5: Fixed `.` directories being ignored. Normally a good thing
|
641
642
|
- 1.0.4: Fixed `appwriteConfig.yaml` being the name for the converted config, instead of `config.yaml`
|
642
643
|
- 1.0.3: Fixed appwriteConfig detection for `--it` so it detects when you can migrate your config
|
@@ -66,7 +66,7 @@ retryCount = 0, maxRetries = 5) => {
|
|
66
66
|
/**
|
67
67
|
* Enhanced index creation with proper status monitoring and retry logic
|
68
68
|
*/
|
69
|
-
export const createOrUpdateIndexWithStatusCheck = async (dbId, db, collectionId, collection, index, retryCount = 0, maxRetries =
|
69
|
+
export const createOrUpdateIndexWithStatusCheck = async (dbId, db, collectionId, collection, index, retryCount = 0, maxRetries = 3) => {
|
70
70
|
console.log(chalk.blue(`Creating/updating index '${index.key}' (attempt ${retryCount + 1}/${maxRetries + 1})`));
|
71
71
|
try {
|
72
72
|
// First, validate that all required attributes exist
|
@@ -101,10 +101,10 @@ export const createOrUpdateIndexWithStatusCheck = async (dbId, db, collectionId,
|
|
101
101
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
102
102
|
console.log(chalk.red(`Error creating index '${index.key}': ${errorMessage}`));
|
103
103
|
// Check if this is a permanent error that shouldn't be retried
|
104
|
-
if (errorMessage.includes('not found') ||
|
105
|
-
errorMessage.includes('missing') ||
|
106
|
-
errorMessage.includes('does not exist') ||
|
107
|
-
errorMessage.includes('attribute') && errorMessage.includes('not found')) {
|
104
|
+
if (errorMessage.toLowerCase().includes('not found') ||
|
105
|
+
errorMessage.toLowerCase().includes('missing') ||
|
106
|
+
errorMessage.toLowerCase().includes('does not exist') ||
|
107
|
+
errorMessage.toLowerCase().includes('attribute') && errorMessage.toLowerCase().includes('not found')) {
|
108
108
|
console.log(chalk.red(`❌ Index '${index.key}' has permanent error - not retrying`));
|
109
109
|
return false;
|
110
110
|
}
|
@@ -170,8 +170,7 @@ export const createOrUpdateIndex = async (dbId, db, collectionId, index) => {
|
|
170
170
|
if (existingIndex.total > 0 &&
|
171
171
|
!existingIndex.indexes.some((existingIndex) => (existingIndex.key === index.key &&
|
172
172
|
existingIndex.type === index.type &&
|
173
|
-
existingIndex.attributes === index.attributes)
|
174
|
-
JSON.stringify(existingIndex) === JSON.stringify(index))) {
|
173
|
+
existingIndex.attributes === index.attributes))) {
|
175
174
|
await db.deleteIndex(dbId, collectionId, existingIndex.indexes[0].key);
|
176
175
|
createIndex = true;
|
177
176
|
}
|
@@ -11,5 +11,6 @@ export declare const deleteFunction: (client: Client, functionId: string) => Pro
|
|
11
11
|
export declare const createFunction: (client: Client, functionConfig: AppwriteFunction) => Promise<import("node-appwrite").Models.Function>;
|
12
12
|
export declare const updateFunctionSpecifications: (client: Client, functionId: string, specification: Specification) => Promise<import("node-appwrite").Models.Function | undefined>;
|
13
13
|
export declare const listSpecifications: (client: Client) => Promise<import("node-appwrite").Models.SpecificationList>;
|
14
|
+
export declare const listFunctionDeployments: (client: Client, functionId: string, queries?: string[]) => Promise<import("node-appwrite").Models.DeploymentList>;
|
14
15
|
export declare const updateFunction: (client: Client, functionConfig: AppwriteFunction) => Promise<import("node-appwrite").Models.Function>;
|
15
16
|
export declare const createFunctionTemplate: (templateType: "typescript-node" | "uv" | "count-docs-in-collection", functionName: string, basePath?: string) => Promise<string>;
|
@@ -94,6 +94,11 @@ export const listSpecifications = async (client) => {
|
|
94
94
|
const specifications = await functions.listSpecifications();
|
95
95
|
return specifications;
|
96
96
|
};
|
97
|
+
export const listFunctionDeployments = async (client, functionId, queries) => {
|
98
|
+
const functions = new Functions(client);
|
99
|
+
const deployments = await functions.listDeployments(functionId, queries);
|
100
|
+
return deployments;
|
101
|
+
};
|
97
102
|
export const updateFunction = async (client, functionConfig) => {
|
98
103
|
const functions = new Functions(client);
|
99
104
|
const functionResponse = await functions.update(functionConfig.$id, functionConfig.name, functionConfig.runtime, functionConfig.execute, functionConfig.events, functionConfig.schedule, functionConfig.timeout, functionConfig.enabled, functionConfig.logging, functionConfig.entrypoint, functionConfig.commands, functionConfig.scopes, functionConfig.installationId, functionConfig.providerRepositoryId, functionConfig.providerBranch, functionConfig.providerSilentMode, functionConfig.providerRootDirectory, functionConfig.specification);
|
@@ -6,7 +6,7 @@ import { fetchAllDatabases } from "../databases/methods.js";
|
|
6
6
|
import { CollectionSchema, attributeSchema, AppwriteConfigSchema, permissionsSchema, attributesSchema, indexesSchema, parseAttribute, } from "appwrite-utils";
|
7
7
|
import { getDatabaseFromConfig } from "./afterImportActions.js";
|
8
8
|
import { listBuckets } from "../storage/methods.js";
|
9
|
-
import { listFunctions } from "../functions/methods.js";
|
9
|
+
import { listFunctions, listFunctionDeployments } from "../functions/methods.js";
|
10
10
|
export class AppwriteToX {
|
11
11
|
config;
|
12
12
|
storage;
|
@@ -169,14 +169,7 @@ export class AppwriteToX {
|
|
169
169
|
const remoteFunctions = await listFunctions(this.config.appwriteClient, [
|
170
170
|
Query.limit(1000),
|
171
171
|
]);
|
172
|
-
|
173
|
-
const deployments = await this.config.appwriteClient.functions.listDeployments(func.$id, [Query.orderDesc("$createdAt"), Query.limit(1)]);
|
174
|
-
return {
|
175
|
-
function: func,
|
176
|
-
schemaStrings: deployments.deployments[0]?.schemaStrings || [],
|
177
|
-
};
|
178
|
-
}));
|
179
|
-
this.updatedConfig.functions = functionDeployments.map(({ function: func, schemaStrings }) => ({
|
172
|
+
this.updatedConfig.functions = remoteFunctions.functions.map((func) => ({
|
180
173
|
$id: func.$id,
|
181
174
|
name: func.name,
|
182
175
|
runtime: func.runtime,
|
@@ -190,7 +183,6 @@ export class AppwriteToX {
|
|
190
183
|
commands: func.commands || "npm install",
|
191
184
|
dirPath: `functions/${func.name}`,
|
192
185
|
specification: func.specification,
|
193
|
-
schemaStrings,
|
194
186
|
}));
|
195
187
|
// Make sure to update the config with all changes
|
196
188
|
this.updatedConfig = {
|