appwrite-utils-cli 1.2.11 → 1.2.15

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.
@@ -244,7 +244,7 @@ declare const YamlConfigSchema: z.ZodObject<{
244
244
  logging: z.ZodOptional<z.ZodBoolean>;
245
245
  entrypoint: z.ZodOptional<z.ZodString>;
246
246
  commands: z.ZodOptional<z.ZodString>;
247
- scopes: z.ZodOptional<z.ZodArray<z.ZodEnum<["users.read", "users.write", "teams.read", "teams.write", "databases.read", "databases.write", "collections.read", "collections.write", "attributes.read", "attributes.write", "indexes.read", "indexes.write", "documents.read", "documents.write", "files.read", "files.write", "buckets.read", "buckets.write", "functions.read", "functions.write", "execution.read", "execution.write", "locale.read", "avatars.read", "health.read", "rules.read", "rules.write", "migrations.read", "migrations.write", "vcs.read", "vcs.write", "assistant.read", "messages.read", "messages.write", "targets.read", "targets.write", "providers.read", "providers.write", "topics.read", "topics.write", "subscribers.read", "subscribers.write"]>, "many">>;
247
+ scopes: z.ZodOptional<z.ZodArray<z.ZodEnum<["users.read", "users.write", "sessions.read", "sessions.write", "teams.read", "teams.write", "databases.read", "databases.write", "collections.read", "collections.write", "attributes.read", "attributes.write", "indexes.read", "indexes.write", "documents.read", "documents.write", "files.read", "files.write", "buckets.read", "buckets.write", "functions.read", "functions.write", "execution.read", "execution.write", "locale.read", "avatars.read", "health.read", "rules.read", "rules.write", "migrations.read", "migrations.write", "sites.read", "sites.write", "log.read", "log.write", "tokens.read", "tokens.write", "vcs.read", "vcs.write", "assistant.read", "messages.read", "messages.write", "targets.read", "targets.write", "providers.read", "providers.write", "topics.read", "topics.write", "subscribers.read", "subscribers.write"]>, "many">>;
248
248
  installationId: z.ZodOptional<z.ZodString>;
249
249
  providerRepositoryId: z.ZodOptional<z.ZodString>;
250
250
  providerBranch: z.ZodOptional<z.ZodString>;
@@ -267,7 +267,7 @@ declare const YamlConfigSchema: z.ZodObject<{
267
267
  timeout?: number | undefined;
268
268
  entrypoint?: string | undefined;
269
269
  commands?: string | undefined;
270
- scopes?: ("users.read" | "users.write" | "teams.read" | "teams.write" | "databases.read" | "databases.write" | "collections.read" | "collections.write" | "attributes.read" | "attributes.write" | "indexes.read" | "indexes.write" | "documents.read" | "documents.write" | "files.read" | "files.write" | "buckets.read" | "buckets.write" | "functions.read" | "functions.write" | "execution.read" | "execution.write" | "locale.read" | "avatars.read" | "health.read" | "rules.read" | "rules.write" | "migrations.read" | "migrations.write" | "vcs.read" | "vcs.write" | "assistant.read" | "messages.read" | "messages.write" | "targets.read" | "targets.write" | "providers.read" | "providers.write" | "topics.read" | "topics.write" | "subscribers.read" | "subscribers.write")[] | undefined;
270
+ scopes?: ("users.read" | "users.write" | "sessions.read" | "sessions.write" | "teams.read" | "teams.write" | "databases.read" | "databases.write" | "collections.read" | "collections.write" | "attributes.read" | "attributes.write" | "indexes.read" | "indexes.write" | "documents.read" | "documents.write" | "files.read" | "files.write" | "buckets.read" | "buckets.write" | "functions.read" | "functions.write" | "execution.read" | "execution.write" | "locale.read" | "avatars.read" | "health.read" | "rules.read" | "rules.write" | "migrations.read" | "migrations.write" | "sites.read" | "sites.write" | "log.read" | "log.write" | "tokens.read" | "tokens.write" | "vcs.read" | "vcs.write" | "assistant.read" | "messages.read" | "messages.write" | "targets.read" | "targets.write" | "providers.read" | "providers.write" | "topics.read" | "topics.write" | "subscribers.read" | "subscribers.write")[] | undefined;
271
271
  installationId?: string | undefined;
272
272
  providerRepositoryId?: string | undefined;
273
273
  providerBranch?: string | undefined;
@@ -290,7 +290,7 @@ declare const YamlConfigSchema: z.ZodObject<{
290
290
  timeout?: number | undefined;
291
291
  entrypoint?: string | undefined;
292
292
  commands?: string | undefined;
293
- scopes?: ("users.read" | "users.write" | "teams.read" | "teams.write" | "databases.read" | "databases.write" | "collections.read" | "collections.write" | "attributes.read" | "attributes.write" | "indexes.read" | "indexes.write" | "documents.read" | "documents.write" | "files.read" | "files.write" | "buckets.read" | "buckets.write" | "functions.read" | "functions.write" | "execution.read" | "execution.write" | "locale.read" | "avatars.read" | "health.read" | "rules.read" | "rules.write" | "migrations.read" | "migrations.write" | "vcs.read" | "vcs.write" | "assistant.read" | "messages.read" | "messages.write" | "targets.read" | "targets.write" | "providers.read" | "providers.write" | "topics.read" | "topics.write" | "subscribers.read" | "subscribers.write")[] | undefined;
293
+ scopes?: ("users.read" | "users.write" | "sessions.read" | "sessions.write" | "teams.read" | "teams.write" | "databases.read" | "databases.write" | "collections.read" | "collections.write" | "attributes.read" | "attributes.write" | "indexes.read" | "indexes.write" | "documents.read" | "documents.write" | "files.read" | "files.write" | "buckets.read" | "buckets.write" | "functions.read" | "functions.write" | "execution.read" | "execution.write" | "locale.read" | "avatars.read" | "health.read" | "rules.read" | "rules.write" | "migrations.read" | "migrations.write" | "sites.read" | "sites.write" | "log.read" | "log.write" | "tokens.read" | "tokens.write" | "vcs.read" | "vcs.write" | "assistant.read" | "messages.read" | "messages.write" | "targets.read" | "targets.write" | "providers.read" | "providers.write" | "topics.read" | "topics.write" | "subscribers.read" | "subscribers.write")[] | undefined;
294
294
  installationId?: string | undefined;
295
295
  providerRepositoryId?: string | undefined;
296
296
  providerBranch?: string | undefined;
@@ -385,7 +385,7 @@ declare const YamlConfigSchema: z.ZodObject<{
385
385
  timeout?: number | undefined;
386
386
  entrypoint?: string | undefined;
387
387
  commands?: string | undefined;
388
- scopes?: ("users.read" | "users.write" | "teams.read" | "teams.write" | "databases.read" | "databases.write" | "collections.read" | "collections.write" | "attributes.read" | "attributes.write" | "indexes.read" | "indexes.write" | "documents.read" | "documents.write" | "files.read" | "files.write" | "buckets.read" | "buckets.write" | "functions.read" | "functions.write" | "execution.read" | "execution.write" | "locale.read" | "avatars.read" | "health.read" | "rules.read" | "rules.write" | "migrations.read" | "migrations.write" | "vcs.read" | "vcs.write" | "assistant.read" | "messages.read" | "messages.write" | "targets.read" | "targets.write" | "providers.read" | "providers.write" | "topics.read" | "topics.write" | "subscribers.read" | "subscribers.write")[] | undefined;
388
+ scopes?: ("users.read" | "users.write" | "sessions.read" | "sessions.write" | "teams.read" | "teams.write" | "databases.read" | "databases.write" | "collections.read" | "collections.write" | "attributes.read" | "attributes.write" | "indexes.read" | "indexes.write" | "documents.read" | "documents.write" | "files.read" | "files.write" | "buckets.read" | "buckets.write" | "functions.read" | "functions.write" | "execution.read" | "execution.write" | "locale.read" | "avatars.read" | "health.read" | "rules.read" | "rules.write" | "migrations.read" | "migrations.write" | "sites.read" | "sites.write" | "log.read" | "log.write" | "tokens.read" | "tokens.write" | "vcs.read" | "vcs.write" | "assistant.read" | "messages.read" | "messages.write" | "targets.read" | "targets.write" | "providers.read" | "providers.write" | "topics.read" | "topics.write" | "subscribers.read" | "subscribers.write")[] | undefined;
389
389
  installationId?: string | undefined;
390
390
  providerRepositoryId?: string | undefined;
391
391
  providerBranch?: string | undefined;
@@ -474,7 +474,7 @@ declare const YamlConfigSchema: z.ZodObject<{
474
474
  timeout?: number | undefined;
475
475
  entrypoint?: string | undefined;
476
476
  commands?: string | undefined;
477
- scopes?: ("users.read" | "users.write" | "teams.read" | "teams.write" | "databases.read" | "databases.write" | "collections.read" | "collections.write" | "attributes.read" | "attributes.write" | "indexes.read" | "indexes.write" | "documents.read" | "documents.write" | "files.read" | "files.write" | "buckets.read" | "buckets.write" | "functions.read" | "functions.write" | "execution.read" | "execution.write" | "locale.read" | "avatars.read" | "health.read" | "rules.read" | "rules.write" | "migrations.read" | "migrations.write" | "vcs.read" | "vcs.write" | "assistant.read" | "messages.read" | "messages.write" | "targets.read" | "targets.write" | "providers.read" | "providers.write" | "topics.read" | "topics.write" | "subscribers.read" | "subscribers.write")[] | undefined;
477
+ scopes?: ("users.read" | "users.write" | "sessions.read" | "sessions.write" | "teams.read" | "teams.write" | "databases.read" | "databases.write" | "collections.read" | "collections.write" | "attributes.read" | "attributes.write" | "indexes.read" | "indexes.write" | "documents.read" | "documents.write" | "files.read" | "files.write" | "buckets.read" | "buckets.write" | "functions.read" | "functions.write" | "execution.read" | "execution.write" | "locale.read" | "avatars.read" | "health.read" | "rules.read" | "rules.write" | "migrations.read" | "migrations.write" | "sites.read" | "sites.write" | "log.read" | "log.write" | "tokens.read" | "tokens.write" | "vcs.read" | "vcs.write" | "assistant.read" | "messages.read" | "messages.write" | "targets.read" | "targets.write" | "providers.read" | "providers.write" | "topics.read" | "topics.write" | "subscribers.read" | "subscribers.write")[] | undefined;
478
478
  installationId?: string | undefined;
479
479
  providerRepositoryId?: string | undefined;
480
480
  providerBranch?: string | undefined;
@@ -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
- const functionDeployments = await Promise.all(remoteFunctions.functions.map(async (func) => {
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 = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "appwrite-utils-cli",
3
3
  "description": "Appwrite Utility Functions to help with database management, data conversion, data import, migrations, and much more. Meant to be used as a CLI tool, I do not recommend installing this in frontend environments.",
4
- "version": "1.2.11",
4
+ "version": "1.2.15",
5
5
  "main": "src/main.ts",
6
6
  "type": "module",
7
7
  "repository": {
@@ -33,7 +33,7 @@
33
33
  "@types/inquirer": "^9.0.8",
34
34
  "@types/json-schema": "^7.0.15",
35
35
  "@types/yargs": "^17.0.33",
36
- "appwrite-utils": "^1.2.0",
36
+ "appwrite-utils": "^1.2.1",
37
37
  "chalk": "^5.4.1",
38
38
  "cli-progress": "^3.12.0",
39
39
  "commander": "^12.1.0",
@@ -161,6 +161,16 @@ export const listSpecifications = async (client: Client) => {
161
161
  return specifications;
162
162
  };
163
163
 
164
+ export const listFunctionDeployments = async (
165
+ client: Client,
166
+ functionId: string,
167
+ queries?: string[]
168
+ ) => {
169
+ const functions = new Functions(client);
170
+ const deployments = await functions.listDeployments(functionId, queries);
171
+ return deployments;
172
+ };
173
+
164
174
  export const updateFunction = async (
165
175
  client: Client,
166
176
  functionConfig: AppwriteFunction
@@ -27,7 +27,7 @@ import {
27
27
  } from "appwrite-utils";
28
28
  import { getDatabaseFromConfig } from "./afterImportActions.js";
29
29
  import { listBuckets } from "../storage/methods.js";
30
- import { listFunctions } from "../functions/methods.js";
30
+ import { listFunctions, listFunctionDeployments } from "../functions/methods.js";
31
31
 
32
32
  export class AppwriteToX {
33
33
  config: AppwriteConfig;
@@ -241,22 +241,9 @@ export class AppwriteToX {
241
241
  const remoteFunctions = await listFunctions(this.config.appwriteClient!, [
242
242
  Query.limit(1000),
243
243
  ]);
244
- const functionDeployments = await Promise.all(
245
- remoteFunctions.functions.map(async (func) => {
246
- const deployments =
247
- await this.config.appwriteClient!.functions.listDeployments(
248
- func.$id,
249
- [Query.orderDesc("$createdAt"), Query.limit(1)]
250
- );
251
- return {
252
- function: func,
253
- schemaStrings: deployments.deployments[0]?.schemaStrings || [],
254
- };
255
- })
256
- );
257
244
 
258
- this.updatedConfig.functions = functionDeployments.map(
259
- ({ function: func, schemaStrings }) => ({
245
+ this.updatedConfig.functions = remoteFunctions.functions.map(
246
+ (func) => ({
260
247
  $id: func.$id,
261
248
  name: func.name,
262
249
  runtime: func.runtime as Runtime,
@@ -270,7 +257,6 @@ export class AppwriteToX {
270
257
  commands: func.commands || "npm install",
271
258
  dirPath: `functions/${func.name}`,
272
259
  specification: func.specification as Specification,
273
- schemaStrings,
274
260
  })
275
261
  );
276
262