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.
101 lines (100 loc) • 3.04 kB
TypeScript
import type { Collection, CollectionCreate } from "appwrite-utils";
export interface YamlCollectionData {
name: string;
id?: string;
documentSecurity?: boolean;
rowSecurity?: boolean;
enabled?: boolean;
permissions?: Array<{
permission: string;
target: string;
}>;
attributes?: Array<{
key: string;
type: string;
size?: number;
required?: boolean;
array?: boolean;
encrypt?: boolean;
default?: any;
min?: number;
max?: number;
elements?: string[];
relatedCollection?: string;
relationType?: string;
twoWay?: boolean;
twoWayKey?: string;
onDelete?: string;
side?: string;
}>;
columns?: Array<{
key: string;
type: string;
size?: number;
required?: boolean;
array?: boolean;
encrypt?: boolean;
default?: any;
min?: number;
max?: number;
elements?: string[];
relatedTable?: string;
relationType?: string;
twoWay?: boolean;
twoWayKey?: string;
onDelete?: string;
side?: string;
}>;
indexes?: Array<{
key: string;
type: string;
attributes: string[];
columns?: string[];
orders?: string[];
}>;
importDefs?: any[];
}
/**
* Configuration for terminology selection
*/
export interface YamlTerminologyConfig {
useTableTerminology: boolean;
entityType: 'collection' | 'table';
schemaPath?: string;
}
/**
* Converts a Collection object to YAML format with proper schema reference
* Supports both collection and table terminology based on configuration
*/
export declare function collectionToYaml(collection: Collection | CollectionCreate, config?: YamlTerminologyConfig): string;
/**
* Sanitizes a collection name for use as a filename
*/
export declare function sanitizeFilename(name: string): string;
/**
* Generates the filename for a collection/table YAML file
*/
export declare function getCollectionYamlFilename(collection: Collection | CollectionCreate, useTableTerminology?: boolean): string;
/**
* Converts column terminology back to attribute terminology for loading
*/
export declare function normalizeYamlData(yamlData: YamlCollectionData): YamlCollectionData;
/**
* Determines if YAML data uses table terminology
*/
export declare function usesTableTerminology(yamlData: YamlCollectionData): boolean;
/**
* Converts between attribute and column terminology
*/
export declare function convertTerminology(yamlData: YamlCollectionData, toTableTerminology: boolean): YamlCollectionData;
/**
* Generates a template YAML file for collections or tables
*/
export declare function generateYamlTemplate(entityName: string, config: YamlTerminologyConfig): string;
/**
* Generates example YAML files for both collection and table formats
*/
export declare function generateExampleYamls(entityName: string): {
collection: string;
table: string;
};