Přeskočit obsah

Formát spec.yaml

Hlavní struktura

# spec.yaml - Kompletní specifikace modulu

module:
  name: "GavonaService"          # PascalCase název
  version: "1.0.0"               # Sémantické verzování
  description: "Servisní modul pro správu zásahů"
  dependencies:
    - "AutoCRM >= 1.0"
    - "Sales >= 1.0"

entities:
  ServiceRequest:
    # ... definice entity

workflows:
  ServiceRequestAssignment:
    # ... definice workflow

integrations:
  pohodaExport:
    # ... definice integrace

Entity Definition

entities:
  ServiceRequest:
    # Základní metadata
    label: "Servisní zásah"
    labelPlural: "Servisní zásahy"
    type: "Base"                   # Base|BasePlus|Event|Person|Company
    table: "service_request"       # snake_case
    iconClass: "fas fa-wrench"
    color: "#e74c3c"

    # Definice polí
    fields:
      number:
        type: "autoincrement"
        pattern: "SRV-{YYYY}-{0000}"
        label: "Číslo zásahu"
        required: true
        readonly: true

      account:
        type: "link"
        entity: "Account"
        label: "Organizace"
        required: true
        audited: true              # Logování změn

      priority:
        type: "enum"
        options:
          - value: "Critical"
            label: "Kritická"
            color: "#dc3545"
            style:
              fontWeight: "bold"
          - value: "High"
            label: "Vysoká"
            color: "#fd7e14"
          - value: "Normal"
            label: "Běžná"
            color: "#0d6efd"
          - value: "Low"
            label: "Nízká"
            color: "#6c757d"
        default: "Normal"
        required: true

      status:
        type: "enum"
        options:
          - "New"
          - "Assigned"
          - "InProgress"
          - "WaitingParts"
          - "Completed"
          - "Invoiced"
          - "Cancelled"
        default: "New"
        required: true
        audited: true

      description:
        type: "text"
        label: "Popis závady"
        required: true
        rowsMin: 3
        rowsMax: 10

      estimatedHours:
        type: "float"
        label: "Odhadované hodiny"
        min: 0
        decimalPlaces: 1

    # Vztahy s jinými entitami
    links:
      account:
        type: "belongsTo"
        entity: "Account"
        foreign: "serviceRequests"

      assignedUser:
        type: "belongsTo"
        entity: "User"
        foreign: "assignedServiceRequests"

      trips:
        type: "hasMany"
        entity: "ServiceTrip"
        foreign: "serviceRequestId"

    # UI Layouts
    layouts:
      detail:
        - panel: "default"
          label: "Základní informace"
          rows:
            - ["number", "status"]
            - ["account", "priority"]
            - ["assignedUser", "estimatedHours"]

        - panel: "description"
          label: "Popis"
          rows:
            - ["description"]

      list:
        columns:
          - name: "number"
            width: 120
            link: true
          - name: "account"
            width: 200
          - name: "priority"
            width: 100
          - name: "status"
            width: 120
          - name: "assignedUser"
            width: 150

      filters:
        - "status"
        - "priority"
        - "assignedUser"
        - "account"

    # Databázové indexy
    indexes:
      - fields: ["accountId", "status"]
      - fields: ["assignedUserId", "status"]
      - fields: ["createdAt"]

Workflow Definition

workflows:
  ServiceRequestAutoAssignment:
    trigger: "afterSave"
    entity: "ServiceRequest"
    isActive: true

    conditions:
      - type: "fieldEquals"
        field: "status"
        value: "New"

      - type: "fieldIsEmpty"
        field: "assignedUserId"

      - type: "formula"
        formula: "entity.get('priority') == 'Critical'"

    actions:
      - type: "notification"
        target: "role:Dispatcher"
        template: "critical_service_request"
        message: "Nový kritický zásah: {entity.number}"

      - type: "createTask"
        entity: "Task"
        data:
          name: "Přidělit technika: {entity.number}"
          assignedUserId: "role:Dispatcher"
          dateEnd: "{dateAdd(now, 1, 'hour')}"
          priority: "Urgent"

      - type: "updateEntity"
        field: "status"
        value: "Assigned"
        when: "assignedUserId IS NOT NULL"

  ServiceRequestCompletion:
    trigger: "afterSave"
    entity: "ServiceRequest"

    conditions:
      - type: "fieldChanged"
        field: "status"

      - type: "fieldEquals"
        field: "status"
        value: "Completed"

    actions:
      - type: "sendEmail"
        to: "{entity.account.emailAddress}"
        template: "service_completed"

      - type: "executeFormula"
        formula: |
          entity.set('completedAt', datetime.now());
          entity.set('completedById', user.id);

➡️ Pokračujte na Akceptační kritéria.