architect/_archive/2025-11-26-cleanup/cifra/09_MODULES_AND_PLUGINS.md

CIFRA — Модули и плагины

Версия: 2.0.0
Дата: 2025-11-10


Module System

modules:
  contacts:
    entities: [Contact, Company]

  deals:
    entities: [Deal, Stage, Pipeline]

Создание модуля

# modules/my-module/module.cifra
module:
  id: my-module
  name: "My Custom Module"
  version: "1.0.0"

  entities:
    - CustomEntity

  dependencies:
    - contacts

Plugin API

Структура плагина

my-plugin/
├── plugin.yaml
├── __init__.py
├── hooks.py
└── ui/
    └── widgets.py

plugin.yaml

plugin:
  id: social-media
  name: "Social Media Fields"
  version: "1.0.0"

  entities:
    Contact:
      fields:
        facebook: {type: string}
        twitter: {type: string}

  hooks:
    - event: "entity.Contact.before_save"
      handler: "hooks.validate_social_urls"

Hooks

from cifra.plugins import hook

@hook('entity.Contact.after_create')
async def on_contact_created(contact):
    await send_welcome_email(contact.email)

@hook('entity.Deal.stage_changed')
async def on_deal_won(deal, old_stage, new_stage):
    if new_stage == 'won':
        await create_invoice(deal)

CIFRA Hub

# Search modules
cifra hub search payment

# Install module
cifra hub install stripe-integration

# Publish module
cifra hub publish

Следующий документ: WORKFLOWS_AND_AUTOMATION.md →