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.

87 lines (86 loc) 2.66 kB
import type { Attribute } from "appwrite-utils"; interface ColumnPropertyChange { property: string; oldValue: any; newValue: any; requiresRecreate: boolean; } interface ColumnOperationPlan { toCreate: Attribute[]; toUpdate: Array<{ attribute: Attribute; changes: ColumnPropertyChange[]; }>; toRecreate: Array<{ oldAttribute: any; newAttribute: Attribute; }>; toDelete: Array<{ attribute: any; }>; unchanged: string[]; } type ComparableColumn = { key: string; type: string; required?: boolean; array?: boolean; default?: any; size?: number; min?: number; max?: number; elements?: string[]; encrypt?: boolean; relatedCollection?: string; relationType?: string; twoWay?: boolean; twoWayKey?: string; onDelete?: string; side?: string; }; export declare function normalizeAttributeToComparable(attr: Attribute): ComparableColumn; export declare function normalizeColumnToComparable(col: any): ComparableColumn; export declare function isColumnEqualToColumn(a: any, b: any): boolean; export declare function isIndexEqualToIndex(a: any, b: any): boolean; /** * Enhanced version of columns diff with detailed change analysis * Order: desired first, then existing (matches internal usage here) */ export declare function diffColumnsDetailed(desiredAttributes: Attribute[], existingColumns: any[]): ColumnOperationPlan; /** * Returns true if there is any difference between existing columns and desired attributes */ export declare function areTableColumnsDiff(existingColumns: any[], desired: Attribute[]): boolean; export declare function diffTableColumns(existingColumns: any[], desired: Attribute[]): { toCreate: Attribute[]; toUpdate: Attribute[]; unchanged: string[]; }; /** * Execute the column operation plan using the adapter */ export declare function executeColumnOperations(adapter: any, databaseId: string, tableId: string, plan: ColumnOperationPlan): Promise<{ success: string[]; errors: Array<{ column: string; error: string; }>; }>; /** * Integration function for methods.ts - processes columns using enhanced logic */ export declare function processTableColumns(adapter: any, databaseId: string, tableId: string, desiredAttributes: Attribute[], existingColumns?: any[]): Promise<{ totalProcessed: number; success: string[]; errors: Array<{ column: string; error: string; }>; summary: { created: number; updated: number; recreated: number; unchanged: number; }; }>; export {};