diff --git a/app/types/common.ts b/app/types/common.ts new file mode 100644 index 0000000..3d4e2ce --- /dev/null +++ b/app/types/common.ts @@ -0,0 +1,7 @@ +export type JsonPrimitive = string | number | boolean | null; + +export type JsonArray = JsonValue[]; + +export type JsonObject = { [key: string]: JsonValue }; + +export type JsonValue = JsonPrimitive | JsonArray | JsonObject; diff --git a/app/types/directus/index.ts b/app/types/directus/index.ts new file mode 100644 index 0000000..eb148e7 --- /dev/null +++ b/app/types/directus/index.ts @@ -0,0 +1 @@ +export * from './my-schema'; diff --git a/app/types/directus/my-schema.ts b/app/types/directus/my-schema.ts new file mode 100644 index 0000000..706719b --- /dev/null +++ b/app/types/directus/my-schema.ts @@ -0,0 +1,835 @@ +import type { JsonValue } from '../common'; + +export interface CompanyProfile { + /** @primaryKey */ + id: number; + translations?: CompanyProfileTranslation[] | null; +} + +export interface CompanyProfileTranslation { + /** @primaryKey */ + id: number; + company_profile_id?: CompanyProfile | string | null; + languages_code?: Language | string | null; + content?: 'json' | null; +} + +export interface ContactInfo { + /** @primaryKey */ + id: number; + translations?: ContactInfoTranslation[] | null; +} + +export interface ContactInfoTranslation { + /** @primaryKey */ + id: number; + contact_info_id?: ContactInfo | string | null; + languages_code?: Language | string | null; + content?: 'json' | null; +} + +export interface Document { + /** @primaryKey */ + id: number; + status?: 'published' | 'draft' | 'archived'; + file?: DirectusFile | string | null; + /** @description i18n字段 */ + translations?: DocumentsTranslation[] | null; + products?: ProductsDocument[] | string[]; +} + +export interface DocumentsTranslation { + /** @primaryKey */ + id: number; + documents_id?: Document | string | null; + languages_code?: Language | string | null; + title?: string | null; +} + +export interface Homepage { + /** @primaryKey */ + id: number; + carousel?: HomepageFile[] | string[]; + recommend_products?: Product[] | string[]; + recommend_solutions?: Solution[] | string[]; +} + +export interface HomepageFile { + /** @primaryKey */ + id: number; + homepage_id?: Homepage | string | null; + directus_files_id?: DirectusFile | string | null; +} + +export interface Language { + /** @primaryKey */ + code: string; + name?: string | null; + direction?: 'ltr' | 'rtl' | null; +} + +export interface ProductImage { + /** @primaryKey */ + id: number; + image?: DirectusFile | string | null; + translations?: ProductImagesTranslation[] | null; + products?: ProductsProductImage[] | string[]; +} + +export interface ProductImagesTranslation { + /** @primaryKey */ + id: number; + product_images_id?: ProductImage | string | null; + languages_code?: Language | string | null; + caption?: string | null; +} + +export interface ProductSpecGroup { + /** @primaryKey */ + id: number; + product?: Product | string | null; + sort?: number | null; + translations?: ProductSpecGroupsTranslation[] | null; + specs?: ProductSpec[] | string[]; +} + +export interface ProductSpecGroupsTranslation { + /** @primaryKey */ + id: number; + product_spec_groups_id?: ProductSpecGroup | string | null; + languages_code?: Language | string | null; + name?: string | null; +} + +export interface ProductSpec { + /** @primaryKey */ + id: number; + group?: ProductSpecGroup | string | null; + sort?: number | null; + value?: string | null; + translations?: ProductSpecsTranslation[] | null; +} + +export interface ProductSpecsTranslation { + /** @primaryKey */ + id: number; + product_specs_id?: ProductSpec | string | null; + languages_code?: Language | string | null; + key?: string | null; +} + +export interface ProductType { + /** @primaryKey */ + id: number; + /** @description 当前产品条目的状态 */ + status?: 'published' | 'draft' | 'archived'; + /** @description i18n文本 */ + translations?: ProductTypesTranslation[] | null; +} + +export interface ProductTypesTranslation { + /** @primaryKey */ + id: number; + product_types_id?: ProductType | string | null; + languages_code?: Language | string | null; + /** @required */ + name: string; +} + +export interface Product { + /** @primaryKey */ + id: number; + /** @description 当前产品条目的状态 */ + status?: 'published' | 'draft' | 'archived'; + product_type?: ProductType | string | null; + /** @description 在产品列表中显示 */ + cover?: DirectusFile | string | null; + homepage_recommend?: Homepage | string | null; + recommend_sort?: number | null; + faqs?: ProductsQuestion[] | string[]; + /** @description i18n字段 */ + translations?: ProductsTranslation[] | null; + /** @description 在产品详情页中展示 */ + images?: ProductsProductImage[] | string[]; + documents?: ProductsDocument[] | string[]; + specs?: ProductSpecGroup[] | string[]; +} + +export interface ProductsDocument { + /** @primaryKey */ + id: number; + products_id?: Product | string | null; + documents_id?: Document | string | null; + sort?: number | null; +} + +export interface ProductsProductImage { + /** @primaryKey */ + id: number; + products_id?: Product | string | null; + product_images_id?: ProductImage | string | null; + sort?: number | null; +} + +export interface ProductsQuestion { + /** @primaryKey */ + id: number; + products_id?: Product | string | null; + questions_id?: Question | string | null; + sort?: number | null; +} + +export interface ProductsTranslation { + /** @primaryKey */ + id: number; + products_id?: Product | string | null; + languages_code?: Language | string | null; + /** @required */ + name: string; + summary?: string | null; + description?: JsonValue | null; +} + +export interface Question { + /** @primaryKey */ + id: number; + status?: 'published' | 'draft' | 'archived'; + /** @description i18n字段 */ + translations?: QuestionsTranslation[] | null; + products?: ProductsQuestion[] | string[]; +} + +export interface QuestionsTranslation { + /** @primaryKey */ + id: number; + questions_id?: Question | string | null; + languages_code?: Language | string | null; + /** @required */ + title: string; + content?: 'json' | null; +} + +export interface SolutionType { + /** @primaryKey */ + id: number; + status?: 'published' | 'draft' | 'archived'; + /** @description i18n字段 */ + translations?: SolutionTypesTranslation[] | null; +} + +export interface SolutionTypesTranslation { + /** @primaryKey */ + id: number; + solution_types_id?: SolutionType | string | null; + languages_code?: Language | string | null; + name?: string | null; +} + +export interface Solution { + /** @primaryKey */ + id: number; + status?: 'published' | 'draft' | 'archived'; + type?: SolutionType | string | null; + cover?: DirectusFile | string | null; + homepage_recommend?: Homepage | string | null; + recommend_sort?: number | null; + translations?: SolutionsTranslation[] | null; +} + +export interface SolutionsTranslation { + /** @primaryKey */ + id: number; + solutions_id?: Solution | string | null; + languages_code?: Language | string | null; + title?: string | null; + summary?: string | null; + content?: 'json' | null; +} + +export interface DirectusAccess { + /** @primaryKey */ + id: string; + role?: DirectusRole | string | null; + user?: DirectusUser | string | null; + policy?: DirectusPolicy | string; + sort?: number | null; +} + +export interface DirectusActivity { + /** @primaryKey */ + id: number; + action?: string; + user?: DirectusUser | string | null; + timestamp?: string; + ip?: string | null; + user_agent?: string | null; + collection?: string; + item?: string; + origin?: string | null; + revisions?: DirectusRevision[] | string[]; +} + +export interface DirectusCollection { + /** @primaryKey */ + collection: string; + icon?: string | null; + note?: string | null; + display_template?: string | null; + hidden?: boolean; + singleton?: boolean; + translations?: Array<{ + language: string; + translation: string; + singular: string; + plural: string; + }> | null; + archive_field?: string | null; + archive_app_filter?: boolean; + archive_value?: string | null; + unarchive_value?: string | null; + sort_field?: string | null; + accountability?: 'all' | 'activity' | null | null; + color?: string | null; + item_duplication_fields?: 'json' | null; + sort?: number | null; + group?: DirectusCollection | string | null; + collapse?: string; + preview_url?: string | null; + versioning?: boolean; +} + +export interface DirectusComment { + /** @primaryKey */ + id: string; + collection?: DirectusCollection | string; + item?: string; + comment?: string; + date_created?: string | null; + date_updated?: string | null; + user_created?: DirectusUser | string | null; + user_updated?: DirectusUser | string | null; +} + +export interface DirectusField { + /** @primaryKey */ + id: number; + collection?: DirectusCollection | string; + field?: string; + special?: string[] | null; + interface?: string | null; + options?: 'json' | null; + display?: string | null; + display_options?: 'json' | null; + readonly?: boolean; + hidden?: boolean; + sort?: number | null; + width?: string | null; + translations?: 'json' | null; + note?: string | null; + conditions?: 'json' | null; + required?: boolean | null; + group?: DirectusField | string | null; + validation?: 'json' | null; + validation_message?: string | null; +} + +export interface DirectusFile { + /** @primaryKey */ + id: string; + storage?: string; + filename_disk?: string | null; + filename_download?: string; + title?: string | null; + type?: string | null; + folder?: DirectusFolder | string | null; + uploaded_by?: DirectusUser | string | null; + created_on?: string; + modified_by?: DirectusUser | string | null; + modified_on?: string; + charset?: string | null; + filesize?: number | null; + width?: number | null; + height?: number | null; + duration?: number | null; + embed?: string | null; + description?: string | null; + location?: string | null; + tags?: string[] | null; + metadata?: 'json' | null; + focal_point_x?: number | null; + focal_point_y?: number | null; + tus_id?: string | null; + tus_data?: 'json' | null; + uploaded_on?: string | null; +} + +export interface DirectusFolder { + /** @primaryKey */ + id: string; + name?: string; + parent?: DirectusFolder | string | null; +} + +export interface DirectusMigration { + /** @primaryKey */ + version: string; + name?: string; + timestamp?: string | null; +} + +export interface DirectusPermission { + /** @primaryKey */ + id: number; + collection?: string; + action?: string; + permissions?: 'json' | null; + validation?: 'json' | null; + presets?: 'json' | null; + fields?: string[] | null; + policy?: DirectusPolicy | string; +} + +export interface DirectusPolicy { + /** @primaryKey */ + id: string; + /** @required */ + name: string; + icon?: string; + description?: string | null; + ip_access?: string[] | null; + enforce_tfa?: boolean; + admin_access?: boolean; + app_access?: boolean; + permissions?: DirectusPermission[] | string[]; + users?: DirectusAccess[] | string[]; + roles?: DirectusAccess[] | string[]; +} + +export interface DirectusPreset { + /** @primaryKey */ + id: number; + bookmark?: string | null; + user?: DirectusUser | string | null; + role?: DirectusRole | string | null; + collection?: string | null; + search?: string | null; + layout?: string | null; + layout_query?: 'json' | null; + layout_options?: 'json' | null; + refresh_interval?: number | null; + filter?: 'json' | null; + icon?: string | null; + color?: string | null; +} + +export interface DirectusRelation { + /** @primaryKey */ + id: number; + many_collection?: string; + many_field?: string; + one_collection?: string | null; + one_field?: string | null; + one_collection_field?: string | null; + one_allowed_collections?: string[] | null; + junction_field?: string | null; + sort_field?: string | null; + one_deselect_action?: string; +} + +export interface DirectusRevision { + /** @primaryKey */ + id: number; + activity?: DirectusActivity | string; + collection?: string; + item?: string; + data?: 'json' | null; + delta?: 'json' | null; + parent?: DirectusRevision | string | null; + version?: DirectusVersion | string | null; +} + +export interface DirectusRole { + /** @primaryKey */ + id: string; + /** @required */ + name: string; + icon?: string; + description?: string | null; + parent?: DirectusRole | string | null; + children?: DirectusRole[] | string[]; + policies?: DirectusAccess[] | string[]; + users?: DirectusUser[] | string[]; +} + +export interface DirectusSession { + /** @primaryKey */ + token: string; + user?: DirectusUser | string | null; + expires?: string; + ip?: string | null; + user_agent?: string | null; + share?: DirectusShare | string | null; + origin?: string | null; + next_token?: string | null; +} + +export interface DirectusSettings { + /** @primaryKey */ + id: number; + project_name?: string; + project_url?: string | null; + project_color?: string; + project_logo?: DirectusFile | string | null; + public_foreground?: DirectusFile | string | null; + public_background?: DirectusFile | string | null; + public_note?: string | null; + auth_login_attempts?: number | null; + auth_password_policy?: + | null + | `/^.{8,}$/` + | `/(?=^.{8,}$)(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()_+}{';'?>.<,])(?!.*\\s).*$/` + | null; + storage_asset_transform?: 'all' | 'none' | 'presets' | null; + storage_asset_presets?: Array<{ + key: string; + fit: 'contain' | 'cover' | 'inside' | 'outside'; + width: number; + height: number; + quality: number; + withoutEnlargement: boolean; + format: 'auto' | 'jpeg' | 'png' | 'webp' | 'tiff' | 'avif'; + transforms: 'json'; + }> | null; + custom_css?: string | null; + storage_default_folder?: DirectusFolder | string | null; + basemaps?: Array<{ + name: string; + type: 'raster' | 'tile' | 'style'; + url: string; + tileSize: number; + attribution: string; + }> | null; + mapbox_key?: string | null; + module_bar?: 'json' | null; + project_descriptor?: string | null; + default_language?: string; + custom_aspect_ratios?: Array<{ text: string; value: number }> | null; + public_favicon?: DirectusFile | string | null; + default_appearance?: 'auto' | 'light' | 'dark'; + default_theme_light?: string | null; + theme_light_overrides?: 'json' | null; + default_theme_dark?: string | null; + theme_dark_overrides?: 'json' | null; + report_error_url?: string | null; + report_bug_url?: string | null; + report_feature_url?: string | null; + public_registration?: boolean; + public_registration_verify_email?: boolean; + public_registration_role?: DirectusRole | string | null; + public_registration_email_filter?: 'json' | null; + visual_editor_urls?: Array<{ url: string }> | null; + accepted_terms?: boolean | null; + project_id?: string | null; + mcp_enabled?: boolean; + mcp_allow_deletes?: boolean; + mcp_prompts_collection?: string | null; + mcp_system_prompt_enabled?: boolean; + mcp_system_prompt?: string | null; +} + +export interface DirectusUser { + /** @primaryKey */ + id: string; + first_name?: string | null; + last_name?: string | null; + email?: string | null; + password?: string | null; + location?: string | null; + title?: string | null; + description?: string | null; + tags?: string[] | null; + avatar?: DirectusFile | string | null; + language?: string | null; + tfa_secret?: string | null; + status?: + | 'draft' + | 'invited' + | 'unverified' + | 'active' + | 'suspended' + | 'archived'; + role?: DirectusRole | string | null; + token?: string | null; + last_access?: string | null; + last_page?: string | null; + provider?: string; + external_identifier?: string | null; + auth_data?: 'json' | null; + email_notifications?: boolean | null; + appearance?: null | 'auto' | 'light' | 'dark' | null; + theme_dark?: string | null; + theme_light?: string | null; + theme_light_overrides?: 'json' | null; + theme_dark_overrides?: 'json' | null; + text_direction?: 'auto' | 'ltr' | 'rtl'; + policies?: DirectusAccess[] | string[]; +} + +export interface DirectusWebhook { + /** @primaryKey */ + id: number; + name?: string; + method?: null; + url?: string; + status?: 'active' | 'inactive'; + data?: boolean; + actions?: 'create' | 'update' | 'delete'; + collections?: string[]; + headers?: Array<{ header: string; value: string }> | null; + was_active_before_deprecation?: boolean; + migrated_flow?: DirectusFlow | string | null; +} + +export interface DirectusDashboard { + /** @primaryKey */ + id: string; + name?: string; + icon?: string; + note?: string | null; + date_created?: string | null; + user_created?: DirectusUser | string | null; + color?: string | null; + panels?: DirectusPanel[] | string[]; +} + +export interface DirectusPanel { + /** @primaryKey */ + id: string; + dashboard?: DirectusDashboard | string; + name?: string | null; + icon?: string | null; + color?: string | null; + show_header?: boolean; + note?: string | null; + type?: string; + position_x?: number; + position_y?: number; + width?: number; + height?: number; + options?: 'json' | null; + date_created?: string | null; + user_created?: DirectusUser | string | null; +} + +export interface DirectusNotification { + /** @primaryKey */ + id: number; + timestamp?: string | null; + status?: string | null; + recipient?: DirectusUser | string; + sender?: DirectusUser | string | null; + subject?: string; + message?: string | null; + collection?: string | null; + item?: string | null; +} + +export interface DirectusShare { + /** @primaryKey */ + id: string; + name?: string | null; + collection?: DirectusCollection | string; + item?: string; + role?: DirectusRole | string | null; + password?: string | null; + user_created?: DirectusUser | string | null; + date_created?: string | null; + date_start?: string | null; + date_end?: string | null; + times_used?: number | null; + max_uses?: number | null; +} + +export interface DirectusFlow { + /** @primaryKey */ + id: string; + name?: string; + icon?: string | null; + color?: string | null; + description?: string | null; + status?: string; + trigger?: string | null; + accountability?: string | null; + options?: 'json' | null; + operation?: DirectusOperation | string | null; + date_created?: string | null; + user_created?: DirectusUser | string | null; + operations?: DirectusOperation[] | string[]; +} + +export interface DirectusOperation { + /** @primaryKey */ + id: string; + name?: string | null; + key?: string; + type?: string; + position_x?: number; + position_y?: number; + options?: 'json' | null; + resolve?: DirectusOperation | string | null; + reject?: DirectusOperation | string | null; + flow?: DirectusFlow | string; + date_created?: string | null; + user_created?: DirectusUser | string | null; +} + +export interface DirectusTranslation { + /** @primaryKey */ + id: string; + /** @required */ + language: string; + /** @required */ + key: string; + /** @required */ + value: string; +} + +export interface DirectusVersion { + /** @primaryKey */ + id: string; + key?: string; + name?: string | null; + collection?: DirectusCollection | string; + item?: string; + hash?: string | null; + date_created?: string | null; + date_updated?: string | null; + user_created?: DirectusUser | string | null; + user_updated?: DirectusUser | string | null; + delta?: 'json' | null; +} + +export interface DirectusExtension { + enabled?: boolean; + /** @primaryKey */ + id: string; + folder?: string; + source?: string; + bundle?: string | null; +} + +export interface Schema { + company_profile: CompanyProfile; + company_profile_translations: CompanyProfileTranslation[]; + contact_info: ContactInfo; + contact_info_translations: ContactInfoTranslation[]; + documents: Document[]; + documents_translations: DocumentsTranslation[]; + homepage: Homepage; + homepage_files: HomepageFile[]; + languages: Language[]; + product_images: ProductImage[]; + product_images_translations: ProductImagesTranslation[]; + product_spec_groups: ProductSpecGroup[]; + product_spec_groups_translations: ProductSpecGroupsTranslation[]; + product_specs: ProductSpec[]; + product_specs_translations: ProductSpecsTranslation[]; + product_types: ProductType[]; + product_types_translations: ProductTypesTranslation[]; + products: Product[]; + products_documents: ProductsDocument[]; + products_product_images: ProductsProductImage[]; + products_questions: ProductsQuestion[]; + products_translations: ProductsTranslation[]; + questions: Question[]; + questions_translations: QuestionsTranslation[]; + solution_types: SolutionType[]; + solution_types_translations: SolutionTypesTranslation[]; + solutions: Solution[]; + solutions_translations: SolutionsTranslation[]; + directus_access: DirectusAccess[]; + directus_activity: DirectusActivity[]; + directus_collections: DirectusCollection[]; + directus_comments: DirectusComment[]; + directus_fields: DirectusField[]; + directus_files: DirectusFile[]; + directus_folders: DirectusFolder[]; + directus_migrations: DirectusMigration[]; + directus_permissions: DirectusPermission[]; + directus_policies: DirectusPolicy[]; + directus_presets: DirectusPreset[]; + directus_relations: DirectusRelation[]; + directus_revisions: DirectusRevision[]; + directus_roles: DirectusRole[]; + directus_sessions: DirectusSession[]; + directus_settings: DirectusSettings; + directus_users: DirectusUser[]; + directus_webhooks: DirectusWebhook[]; + directus_dashboards: DirectusDashboard[]; + directus_panels: DirectusPanel[]; + directus_notifications: DirectusNotification[]; + directus_shares: DirectusShare[]; + directus_flows: DirectusFlow[]; + directus_operations: DirectusOperation[]; + directus_translations: DirectusTranslation[]; + directus_versions: DirectusVersion[]; + directus_extensions: DirectusExtension[]; +} + +export enum CollectionNames { + company_profile = 'company_profile', + company_profile_translations = 'company_profile_translations', + contact_info = 'contact_info', + contact_info_translations = 'contact_info_translations', + documents = 'documents', + documents_translations = 'documents_translations', + homepage = 'homepage', + homepage_files = 'homepage_files', + languages = 'languages', + product_images = 'product_images', + product_images_translations = 'product_images_translations', + product_spec_groups = 'product_spec_groups', + product_spec_groups_translations = 'product_spec_groups_translations', + product_specs = 'product_specs', + product_specs_translations = 'product_specs_translations', + product_types = 'product_types', + product_types_translations = 'product_types_translations', + products = 'products', + products_documents = 'products_documents', + products_product_images = 'products_product_images', + products_questions = 'products_questions', + products_translations = 'products_translations', + questions = 'questions', + questions_translations = 'questions_translations', + solution_types = 'solution_types', + solution_types_translations = 'solution_types_translations', + solutions = 'solutions', + solutions_translations = 'solutions_translations', + directus_access = 'directus_access', + directus_activity = 'directus_activity', + directus_collections = 'directus_collections', + directus_comments = 'directus_comments', + directus_fields = 'directus_fields', + directus_files = 'directus_files', + directus_folders = 'directus_folders', + directus_migrations = 'directus_migrations', + directus_permissions = 'directus_permissions', + directus_policies = 'directus_policies', + directus_presets = 'directus_presets', + directus_relations = 'directus_relations', + directus_revisions = 'directus_revisions', + directus_roles = 'directus_roles', + directus_sessions = 'directus_sessions', + directus_settings = 'directus_settings', + directus_users = 'directus_users', + directus_webhooks = 'directus_webhooks', + directus_dashboards = 'directus_dashboards', + directus_panels = 'directus_panels', + directus_notifications = 'directus_notifications', + directus_shares = 'directus_shares', + directus_flows = 'directus_flows', + directus_operations = 'directus_operations', + directus_translations = 'directus_translations', + directus_versions = 'directus_versions', + directus_extensions = 'directus_extensions', +}