UNPKG

appwrite-utils-cli

Version:

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.

688 lines (687 loc) 26.1 kB
import { z } from "zod"; export declare const BackupSchema: z.ZodObject<{ $id: z.ZodString; $createdAt: z.ZodString; $updatedAt: z.ZodString; database: z.ZodString; collections: z.ZodArray<z.ZodString, "many">; documents: z.ZodDefault<z.ZodArray<z.ZodObject<{ collectionId: z.ZodString; data: z.ZodString; }, "strip", z.ZodTypeAny, { data: string; collectionId: string; }, { data: string; collectionId: string; }>, "many">>; }, "strip", z.ZodTypeAny, { documents: { data: string; collectionId: string; }[]; $id: string; collections: string[]; $createdAt: string; $updatedAt: string; database: string; }, { $id: string; collections: string[]; $createdAt: string; $updatedAt: string; database: string; documents?: { data: string; collectionId: string; }[] | undefined; }>; export type Backup = z.infer<typeof BackupSchema>; export declare const BackupCreateSchema: z.ZodObject<Omit<{ $id: z.ZodString; $createdAt: z.ZodString; $updatedAt: z.ZodString; database: z.ZodString; collections: z.ZodArray<z.ZodString, "many">; documents: z.ZodDefault<z.ZodArray<z.ZodObject<{ collectionId: z.ZodString; data: z.ZodString; }, "strip", z.ZodTypeAny, { data: string; collectionId: string; }, { data: string; collectionId: string; }>, "many">>; }, "$id" | "$createdAt" | "$updatedAt">, "strip", z.ZodTypeAny, { documents: { data: string; collectionId: string; }[]; collections: string[]; database: string; }, { collections: string[]; database: string; documents?: { data: string; collectionId: string; }[] | undefined; }>; export type BackupCreate = z.infer<typeof BackupCreateSchema>; export declare const BatchSchema: z.ZodObject<{ $id: z.ZodString; $createdAt: z.ZodString; $updatedAt: z.ZodString; data: z.ZodString; processed: z.ZodDefault<z.ZodBoolean>; }, "strip", z.ZodTypeAny, { data: string; $id: string; $createdAt: string; $updatedAt: string; processed: boolean; }, { data: string; $id: string; $createdAt: string; $updatedAt: string; processed?: boolean | undefined; }>; export type Batch = z.infer<typeof BatchSchema>; export declare const BatchCreateSchema: z.ZodObject<Omit<{ $id: z.ZodString; $createdAt: z.ZodString; $updatedAt: z.ZodString; data: z.ZodString; processed: z.ZodDefault<z.ZodBoolean>; }, "$id" | "$createdAt" | "$updatedAt">, "strip", z.ZodTypeAny, { data: string; processed: boolean; }, { data: string; processed?: boolean | undefined; }>; export type BatchCreate = z.infer<typeof BatchCreateSchema>; export declare const OperationSchema: z.ZodObject<{ $id: z.ZodString; $createdAt: z.ZodString; $updatedAt: z.ZodString; operationType: z.ZodString; collectionId: z.ZodString; data: z.ZodAny; batches: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>; progress: z.ZodNumber; total: z.ZodNumber; error: z.ZodString; status: z.ZodDefault<z.ZodEnum<["pending", "ready", "in_progress", "completed", "error", "cancelled"]>>; }, "strip", z.ZodTypeAny, { status: "error" | "pending" | "ready" | "in_progress" | "completed" | "cancelled"; error: string; $id: string; $createdAt: string; $updatedAt: string; collectionId: string; operationType: string; progress: number; total: number; data?: any; batches?: string[] | undefined; }, { error: string; $id: string; $createdAt: string; $updatedAt: string; collectionId: string; operationType: string; progress: number; total: number; status?: "error" | "pending" | "ready" | "in_progress" | "completed" | "cancelled" | undefined; data?: any; batches?: string[] | undefined; }>; export type Operation = z.infer<typeof OperationSchema>; export declare const OperationCreateSchema: z.ZodObject<Omit<{ $id: z.ZodString; $createdAt: z.ZodString; $updatedAt: z.ZodString; operationType: z.ZodString; collectionId: z.ZodString; data: z.ZodAny; batches: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>; progress: z.ZodNumber; total: z.ZodNumber; error: z.ZodString; status: z.ZodDefault<z.ZodEnum<["pending", "ready", "in_progress", "completed", "error", "cancelled"]>>; }, "$id" | "$createdAt" | "$updatedAt">, "strip", z.ZodTypeAny, { status: "error" | "pending" | "ready" | "in_progress" | "completed" | "cancelled"; error: string; collectionId: string; operationType: string; progress: number; total: number; data?: any; batches?: string[] | undefined; }, { error: string; collectionId: string; operationType: string; progress: number; total: number; status?: "error" | "pending" | "ready" | "in_progress" | "completed" | "cancelled" | undefined; data?: any; batches?: string[] | undefined; }>; export type OperationCreate = z.infer<typeof OperationCreateSchema>; export declare const getMigrationCollectionSchemas: () => { CurrentOperations: { collection: { name: string; attributes: ({ type: "string"; key: string; size: number; format?: string | null | undefined; description?: string | Record<string, string> | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; encrypted?: boolean | undefined; } | { type: "integer"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: number | null | undefined; min?: number | undefined; max?: number | undefined; } | { type: "float"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: number | null | undefined; min?: number | undefined; max?: number | undefined; } | { type: "boolean"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: boolean | null | undefined; } | { type: "datetime"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; } | { type: "email"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; } | { type: "ip"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; } | { type: "url"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; } | { type: "enum"; key: string; elements: string[]; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; } | { type: "relationship"; key: string; relatedCollection: string; relationType: "oneToMany" | "manyToOne" | "oneToOne" | "manyToMany"; twoWay: boolean; twoWayKey: string; onDelete: "setNull" | "cascade" | "restrict"; side: "parent" | "child"; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; importMapping?: { originalIdField: string; targetField?: string | undefined; } | undefined; })[]; $permissions: { permission: string; target: string; }[]; indexes: { type: "key" | "unique" | "fulltext"; key: string; attributes: string[]; status?: string | undefined; error?: string | undefined; orders?: string[] | undefined; }[]; importDefs: { filePath: string; primaryKeyField: string; attributeMappings: { targetKey: string; oldKey?: string | undefined; oldKeys?: string[] | undefined; valueToSet?: any; fileData?: { path: string; name: string; } | undefined; converters?: string[] | undefined; validationActions?: { params: string[]; action: string; }[] | undefined; postImportActions?: { params: (string | Record<string, any>)[]; action: string; }[] | undefined; }[]; type?: "create" | "update" | undefined; basePath?: string | undefined; idMappings?: { sourceField: string; targetField: string; targetCollection: string; fieldToSet?: string | undefined; targetFieldToMatch?: string | undefined; }[] | undefined; createUsers?: boolean | null | undefined; updateMapping?: { targetField: string; originalIdField: string; } | undefined; }[]; description?: string | undefined; $id?: string | undefined; enabled?: boolean | undefined; documentSecurity?: boolean | undefined; databaseId?: string | undefined; }; attributes: ({ type: "string"; key: string; size: number; format?: string | null | undefined; description?: string | Record<string, string> | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; encrypted?: boolean | undefined; } | { type: "integer"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: number | null | undefined; min?: number | undefined; max?: number | undefined; } | { type: "float"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: number | null | undefined; min?: number | undefined; max?: number | undefined; } | { type: "boolean"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: boolean | null | undefined; } | { type: "datetime"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; } | { type: "email"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; } | { type: "ip"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; } | { type: "url"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; } | { type: "enum"; key: string; elements: string[]; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; } | { type: "relationship"; key: string; relatedCollection: string; relationType: "oneToMany" | "manyToOne" | "oneToOne" | "manyToMany"; twoWay: boolean; twoWayKey: string; onDelete: "setNull" | "cascade" | "restrict"; side: "parent" | "child"; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; importMapping?: { originalIdField: string; targetField?: string | undefined; } | undefined; })[]; }; Batches: { collection: { name: string; attributes: ({ type: "string"; key: string; size: number; format?: string | null | undefined; description?: string | Record<string, string> | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; encrypted?: boolean | undefined; } | { type: "integer"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: number | null | undefined; min?: number | undefined; max?: number | undefined; } | { type: "float"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: number | null | undefined; min?: number | undefined; max?: number | undefined; } | { type: "boolean"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: boolean | null | undefined; } | { type: "datetime"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; } | { type: "email"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; } | { type: "ip"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; } | { type: "url"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; } | { type: "enum"; key: string; elements: string[]; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; } | { type: "relationship"; key: string; relatedCollection: string; relationType: "oneToMany" | "manyToOne" | "oneToOne" | "manyToMany"; twoWay: boolean; twoWayKey: string; onDelete: "setNull" | "cascade" | "restrict"; side: "parent" | "child"; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; importMapping?: { originalIdField: string; targetField?: string | undefined; } | undefined; })[]; $permissions: { permission: string; target: string; }[]; indexes: { type: "key" | "unique" | "fulltext"; key: string; attributes: string[]; status?: string | undefined; error?: string | undefined; orders?: string[] | undefined; }[]; importDefs: { filePath: string; primaryKeyField: string; attributeMappings: { targetKey: string; oldKey?: string | undefined; oldKeys?: string[] | undefined; valueToSet?: any; fileData?: { path: string; name: string; } | undefined; converters?: string[] | undefined; validationActions?: { params: string[]; action: string; }[] | undefined; postImportActions?: { params: (string | Record<string, any>)[]; action: string; }[] | undefined; }[]; type?: "create" | "update" | undefined; basePath?: string | undefined; idMappings?: { sourceField: string; targetField: string; targetCollection: string; fieldToSet?: string | undefined; targetFieldToMatch?: string | undefined; }[] | undefined; createUsers?: boolean | null | undefined; updateMapping?: { targetField: string; originalIdField: string; } | undefined; }[]; description?: string | undefined; $id?: string | undefined; enabled?: boolean | undefined; documentSecurity?: boolean | undefined; databaseId?: string | undefined; }; attributes: ({ type: "string"; key: string; size: number; format?: string | null | undefined; description?: string | Record<string, string> | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; encrypted?: boolean | undefined; } | { type: "integer"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: number | null | undefined; min?: number | undefined; max?: number | undefined; } | { type: "float"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: number | null | undefined; min?: number | undefined; max?: number | undefined; } | { type: "boolean"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: boolean | null | undefined; } | { type: "datetime"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; } | { type: "email"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; } | { type: "ip"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; } | { type: "url"; key: string; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; } | { type: "enum"; key: string; elements: string[]; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; xdefault?: string | null | undefined; } | { type: "relationship"; key: string; relatedCollection: string; relationType: "oneToMany" | "manyToOne" | "oneToOne" | "manyToMany"; twoWay: boolean; twoWayKey: string; onDelete: "setNull" | "cascade" | "restrict"; side: "parent" | "child"; description?: string | Record<string, string> | null | undefined; required?: boolean | undefined; array?: boolean | undefined; error?: string | undefined; importMapping?: { originalIdField: string; targetField?: string | undefined; } | undefined; })[]; }; };