/** * Utility class for content copy operations between platforms/spaces. * * Handles: * - Field ID stripping for type creation * - Content type reference remapping * - Entry field value remapping (assets, content types) * - UID conflict resolution with auto-suffix */ /** * Type field definition from content types */ export interface TypeField { id: number | null; name: string; type: string; position: number; hint?: string; _destroy?: boolean; multi?: boolean; parent_id?: number | null; validations?: { required?: boolean; unique?: boolean; length?: { min_number: string; max_number: string; }; number_range?: { min_number: string; max_number: string; }; date_range?: { min_date: string; max_date: string; }; regexp?: string; values?: string; content_type?: number | null; asset_types?: Array<{ value: string; label: string; level: number; }>; }; children?: TypeField[]; } /** * Entry field value structure */ export interface EntryFieldValue { field_id: number; type: string; value: unknown; multi?: boolean; id?: number | null; parent_id?: number | null; } /** * Location value structure for location fields * Handles transformation between different API formats */ export interface LocationValue { id?: number; location_street: string; latitude?: string; longitude?: string; lat?: number; lng?: number; country: string; administrative_area_level_1?: string; administrative_area_level_2?: string; administrative_area_level_3?: string; administrative_area_level_4?: string; administrative_area_level_5?: string; } /** * Category with hierarchy information */ export interface CategoryWithPath { id: number; name: string; slug: string; full_path: string; parent_id: number | null; depth: number; } export declare class CopyUtils { /** * Generate unique UID on conflict. * Tries: original → {uid}-copy → {uid}-2 → {uid}-3 ... → {uid}-{timestamp} */ static generateUniqueUid(baseUid: string, existingUids: string[]): string; /** * Derive a downloadTempAsset `knownFileType` hint from an already-known * source asset instead of re-sniffing the downloaded bytes. Byte-sniffing * (file-type) can't detect some formats at all (.csv, .txt) and can * misdetect others (.svg as generic .xml) — the source asset's own * data_file_name/data_content_type are ground truth and should win. * Returns undefined when the filename has no extension, so the caller * falls back to sniffing. */ static knownFileTypeFromAsset(dataFileName: string, dataContentType: string): { ext: string; mime: string; } | undefined; /** * Resolve a possibly-relative asset URL against a platform base URL. * Source asset URLs are space-relative paths (e.g. * /uploads//original/foo.svg) that need the source platform's base * URL prepended before they can be fetched; absolute http(s) URLs are * passed through unchanged. */ static resolveAssetUrl(url: string, baseUrl: string): string; /** * Strip IDs from type fields for creation. * Sets all field.id to null for API to generate new IDs. * Also handles group children recursively. */ static stripFieldIds(fields: TypeField[]): TypeField[]; /** * Remap content_type references in type field definitions. * Used when copying types that reference other types. * * @param fields - Array of type fields * @param typeMapping - Map of source type ID → target type ID * @returns Fields with remapped content_type references */ static remapContentTypeReferences(fields: TypeField[], typeMapping: Map): TypeField[]; /** * Update entry field values with asset and type mappings. * Handles all 17 field types including groups. * * @param fieldValues - Array of entry field values * @param assetMapping - Map of source asset ID → target asset ID * @param entryMapping - Map of source entry ID → target entry ID (for content_type fields) * @returns Field values with remapped IDs */ static remapEntryFieldValues(fieldValues: EntryFieldValue[], assetMapping: Map, entryMapping: Map): EntryFieldValue[]; /** * Extract all asset IDs from entry field values. * Used to collect assets that need to be copied. * * @param fieldValues - Array of entry field values * @returns Set of asset IDs */ static extractAssetIds(fieldValues: EntryFieldValue[]): Set; /** * Extract all entry IDs from content_type fields. * Used to determine entry copy order (dependencies). * * @param fieldValues - Array of entry field values * @returns Set of referenced entry IDs */ static extractEntryReferences(fieldValues: EntryFieldValue[]): Set; /** * Flatten category hierarchy into a sorted array. * Returns categories sorted by depth (parents before children). * * @param categories - Array of categories with parent_id * @returns Flattened array with full_path and depth */ static flattenCategories(categories: Array<{ id: number; name: string; slug: string; parent_id: number | null; }>): CategoryWithPath[]; /** * Build field ID mapping between source and target type fields. * Maps source field ID → target field ID by matching field names. * * @param sourceFields - Fields from source type * @param targetFields - Fields from target type * @returns Map of source field ID → target field ID */ static buildFieldIdMapping(sourceFields: TypeField[], targetFields: TypeField[]): Map; /** * Update entry field values to use target field IDs. * Used when copying entries to a type with different field IDs. * * @param fieldValues - Source entry field values * @param fieldIdMapping - Map of source field ID → target field ID * @returns Field values with updated field_ids */ static remapFieldIds(fieldValues: EntryFieldValue[], fieldIdMapping: Map): EntryFieldValue[]; /** * Find content_type fields in a type definition. * Used to detect type dependencies. * * @param fields - Type field definitions * @returns Array of content_type IDs referenced */ static findContentTypeReferences(fields: TypeField[]): number[]; } //# sourceMappingURL=CopyUtils.d.ts.map