agentleFS
TiledeskTiledesk/tiledesk-dashboard/.cursor/rules/data-tables.openapi.yaml

tiledesk-dashboard / rules

Cursor rule16 starsChanged 4 months agoMITView on GitHub

openapi: 3.0.3 info: title: Tiledesk Data Tables API description: | API per gestire tabelle dati multi-tenant per progetto. - Ogni tabella appartiene a un projectId. - Le righe usano chiavi = nomi colonna definiti nello schema (non gli id colonna). - I nomi colonna ammessi: lettere, numeri e underscore (^[a-zA-Z0-9_]+$). - Tipi colonna: string, number, boolean, datetime. - Colonne aggiunte dopo l'inserimento righe: in lettura i campi mancanti sono null. version: 1.0.0 servers: - url: http://localhost:3000 description: Local development -…

The file

Files
data-tables.openapi.yaml
openapi: 3.0.3
info:
  title: Tiledesk Data Tables API
  description: |
    API per gestire tabelle dati multi-tenant per progetto.

    - Ogni tabella appartiene a un `projectId`.
    - Le righe usano chiavi = **nomi colonna** definiti nello schema (non gli id colonna).
    - I nomi colonna ammessi: lettere, numeri e underscore (`^[a-zA-Z0-9_]+$`).
    - Tipi colonna: `string`, `number`, `boolean`, `datetime`.
    - Colonne aggiunte dopo l'inserimento righe: in lettura i campi mancanti sono `null`.
  version: 1.0.0

servers:
  - url: http://localhost:3000
    description: Local development
  - url: https://api.tiledesk.com
    description: Production (example)

tags:
  - name: Tables
    description: CRUD tabelle e schema
  - name: Columns
    description: Gestione colonne (alternativa a PUT tabella con schema)
  - name: Rows
    description: Lettura e modifica righe

security:
  - basicAuth: []
  - bearerAuth: []

paths:
  /{projectId}/tables:
    parameters:
      - $ref: '#/components/parameters/projectId'
    get:
      tags: [Tables]
      summary: Elenco tabelle del progetto
      operationId: listTables
      responses:
        '200':
          description: Lista tabelle
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Table'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalError'
    post:
      tags: [Tables]
      summary: Crea tabella
      operationId: createTable
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTableRequest'
            examples:
              emptySchema:
                summary: Schema vuoto
                value:
                  name: Users
              withSchema:
                summary: Schema iniziale
                value:
                  name: Users
                  schema:
                    - name: fullname
                      type: string
                    - name: age
                      type: number
      responses:
        '200':
          description: Tabella creata
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Table'
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalError'

  /{projectId}/tables/{tableId}:
    parameters:
      - $ref: '#/components/parameters/projectId'
      - $ref: '#/components/parameters/tableId'
    get:
      tags: [Tables]
      summary: Dettaglio tabella con prime 100 righe
      description: |
        Restituisce la tabella e fino a 100 righe ordinate per `createdAt` ascendente.
        Ogni elemento di `rows` contiene solo i campi dello schema; i valori assenti sono `null`.
      operationId: getTable
      responses:
        '200':
          description: Tabella con righe
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TableWithRows'
        '404':
          $ref: '#/components/responses/TableNotFound'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalError'
    put:
      tags: [Tables]
      summary: Aggiorna tabella (nome e/o schema)
      description: |
        Aggiorna il nome e/o lo schema completo.

        - Colonna **senza** `id` nello schema inviato → nuova colonna (solo metadata, righe invariate).
        - Stesso `id`, **nome** diverso → rinomina colonna e `$rename` su tutte le righe.
        - `id` assente nel nuovo schema → colonna eliminata (`$unset` su tutte le righe).
      operationId: updateTable
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateTableRequest'
      responses:
        '200':
          description: Tabella aggiornata
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Table'
        '400':
          $ref: '#/components/responses/ValidationError'
        '404':
          $ref: '#/components/responses/TableNotFound'
        '409':
          $ref: '#/components/responses/ConflictError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalError'
    delete:
      tags: [Tables]
      summary: Elimina tabella e tutte le righe
      operationId: deleteTable
      responses:
        '200':
          description: Tabella eliminata
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: Table deleted successfully
        '404':
          $ref: '#/components/responses/TableNotFound'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalError'

  /{projectId}/tables/{tableId}/columns:
    parameters:
      - $ref: '#/components/parameters/projectId'
      - $ref: '#/components/parameters/tableId'
    post:
      tags: [Columns]
      summary: Aggiungi colonna
      description: Aggiorna solo lo schema; le righe esistenti non vengono modificate.
      operationId: addColumn
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ColumnInput'
      responses:
        '200':
          description: Tabella aggiornata
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Table'
        '400':
          $ref: '#/components/responses/ValidationError'
        '404':
          $ref: '#/components/responses/TableNotFound'
        '409':
          $ref: '#/components/responses/ConflictError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalError'

  /{projectId}/tables/{tableId}/columns/{columnId}:
    parameters:
      - $ref: '#/components/parameters/projectId'
      - $ref: '#/components/parameters/tableId'
      - $ref: '#/components/parameters/columnId'
    patch:
      tags: [Columns]
      summary: Rinomina colonna
      description: Aggiorna lo schema e rinomina il campo in tutte le righe (`$rename`).
      operationId: renameColumn
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [name]
              properties:
                name:
                  type: string
                  pattern: '^[a-zA-Z0-9_]+$'
                  example: user_fullname
      responses:
        '200':
          description: Tabella aggiornata
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Table'
        '400':
          $ref: '#/components/responses/ValidationError'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/ConflictError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalError'
    delete:
      tags: [Columns]
      summary: Elimina colonna
      description: Rimuove la colonna dallo schema e il campo da tutte le righe (`$unset`).
      operationId: deleteColumn
      responses:
        '200':
          description: Tabella aggiornata
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Table'
        '404':
          $ref: '#/components/responses/NotFound'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalError'

  /{projectId}/tables/{tableId}/rows/list:
    parameters:
      - $ref: '#/components/parameters/projectId'
      - $ref: '#/components/parameters/tableId'
    get:
      tags: [Rows]
      summary: Elenco o ricerca righe
      description: |
        - **Senza** `conditions` (o array vuoto): tutte le righe, ordinate per `createdAt` ascendente.
        - **Con** `conditions`: filtra con `must_match` (`all` = AND, `any` = OR).

        Ogni riga include `_id` e i campi schema; valori mancanti = `null`.

        Parametri in query string; `conditions` può essere JSON (URL-encoded).
        Opzionalmente `must_match` / `conditions` nel body se il client lo supporta su GET.
      operationId: listRows
      parameters:
        - name: must_match
          in: query
          schema:
            $ref: '#/components/schemas/MatchMode'
          description: Alias supportato `match`
        - name: match
          in: query
          schema:
            $ref: '#/components/schemas/MatchMode'
        - name: conditions
          in: query
          description: JSON array di condizioni (URL-encoded)
          schema:
            type: string
            example: '[{"column":"email","operator":"equal","value":"a@b.com"}]'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RowSearchRequest'
      responses:
        '200':
          description: Lista righe (formato flat)
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/RowListItem'
        '400':
          $ref: '#/components/responses/ValidationError'
        '404':
          $ref: '#/components/responses/TableNotFound'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalError'

  /{projectId}/tables/{tableId}/row/insert:
    parameters:
      - $ref: '#/components/parameters/projectId'
      - $ref: '#/components/parameters/tableId'
    post:
      tags: [Rows]
      summary: Inserisci riga
      operationId: insertRow
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InsertRowRequest'
      responses:
        '200':
          description: Riga creata
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RowDocument'
        '400':
          $ref: '#/components/responses/ValidationError'
        '404':
          $ref: '#/components/responses/TableNotFound'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalError'

  /{projectId}/tables/{tableId}/row/update:
    parameters:
      - $ref: '#/components/parameters/projectId'
      - $ref: '#/components/parameters/tableId'
    put:
      tags: [Rows]
      summary: Aggiorna riga
      description: |
        Identificazione riga (uno dei due modi):

        1. `id_row` + `data` (aggiornamento parziale dei campi in `data`)
        2. `must_match` + `conditions` + `data`
      operationId: updateRow
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateRowRequest'
      responses:
        '200':
          description: Riga aggiornata
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RowDocument'
        '400':
          $ref: '#/components/responses/ValidationError'
        '404':
          $ref: '#/components/responses/RowOrTableNotFound'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalError'

  /{projectId}/tables/{tableId}/row/upsert:
    parameters:
      - $ref: '#/components/parameters/projectId'
      - $ref: '#/components/parameters/tableId'
    put:
      tags: [Rows]
      summary: Upsert riga
      description: |
        Come update, più creazione se nessuna riga corrisponde.

        - Con `id_row`: update se esiste, altrimenti create con quell'`_id`.
        - Con `conditions`: 0 match → insert; 1 match → update; >1 match → 409 (salvo `multi: true`).
        - `multi: true`: aggiorna tutte le righe che soddisfano le condizioni; se nessuna, ne crea una.
      operationId: upsertRow
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpsertRowRequest'
      responses:
        '200':
          description: Riga o righe upsert
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/RowDocument'
                  - type: array
                    items:
                      $ref: '#/components/schemas/RowDocument'
        '400':
          $ref: '#/components/responses/ValidationError'
        '404':
          $ref: '#/components/responses/RowOrTableNotFound'
        '409':
          description: Più righe corrispondono alle condizioni
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalError'

  /{projectId}/tables/{tableId}/row/delete:
    parameters:
      - $ref: '#/components/parameters/projectId'
      - $ref: '#/components/parameters/tableId'
    put:
      tags: [Rows]
      summary: Elimina riga
      description: |
        Identificazione riga (uno dei due modi):

        1. `id_row`
        2. `must_match` + `conditions` (elimina la prima riga corrispondente)
      operationId: deleteRow
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeleteRowRequest'
      responses:
        '200':
          description: Riga eliminata
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RowDocument'
        '400':
          $ref: '#/components/responses/ValidationError'
        '404':
          $ref: '#/components/responses/RowOrTableNotFound'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalError'

components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: Basic auth (email + password)
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT token (header Authorization Bearer o Basic)

  parameters:
    projectId:
      name: projectId
      in: path
      required: true
      description: ID progetto Tiledesk
      schema:
        type: string
        example: 5e28108c361fbb001729e960
    tableId:
      name: tableId
      in: path
      required: true
      description: ID tabella
      schema:
        type: string
        example: 6a217a72d154149630eac727
    columnId:
      name: columnId
      in: path
      required: true
      description: ID immutabile colonna (es. col_a1b2c3d4e5f67890)
      schema:
        type: string
        example: col_a1b2c3d4e5f67890

  schemas:
    ColumnType:
      type: string
      enum: [string, number, boolean, datetime]

    MatchMode:
      type: string
      enum: [all, any]
      default: all
      description: "`all` = AND logico, `any` = OR logico"

    Column:
      type: object
      required: [id, name, type, index]
      properties:
        id:
          type: string
          readOnly: true
          example: col_a1b2c3d4e5f67890
        name:
          type: string
          pattern: '^[a-zA-Z0-9_]+$'
          example: fullname
        type:
          $ref: '#/components/schemas/ColumnType'
        index:
          type: integer
          description: Ordine colonna (uso futuro)
          example: 0

    ColumnInput:
      type: object
      required: [name, type]
      properties:
        name:
          type: string
          pattern: '^[a-zA-Z0-9_]+$'
        type:
          $ref: '#/components/schemas/ColumnType'
        index:
          type: integer

    Table:
      type: object
      properties:
        _id:
          type: string
        id_project:
          type: string
        name:
          type: string
        schema:
          type: array
          items:
            $ref: '#/components/schemas/Column'
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time

    TableWithRows:
      allOf:
        - $ref: '#/components/schemas/Table'
        - type: object
          properties:
            rows:
              type: array
              maxItems: 100
              description: Solo campi schema; senza `_id`; assenti = null
              items:
                type: object
                additionalProperties: true
                example:
                  name: John Doe
                  age: 30
                  email: null

    CreateTableRequest:
      type: object
      required: [name]
      properties:
        name:
          type: string
        schema:
          type: array
          items:
            $ref: '#/components/schemas/ColumnInput'
          description: Opzionale; array vuoto se omesso

    UpdateTableRequest:
      type: object
      properties:
        name:
          type: string
        schema:
          type: array
          description: Schema completo desiderato
          items:
            oneOf:
              - type: object
                required: [name, type]
                properties:
                  name:
                    type: string
                  type:
                    $ref: '#/components/schemas/ColumnType'
                  index:
                    type: integer
                description: Nuova colonna (senza id)
              - type: object
                required: [id, name, type]
                properties:
                  id:
                    type: string
                  name:
                    type: string
                  type:
                    $ref: '#/components/schemas/ColumnType'
                  index:
                    type: integer
                description: Colonna esistente

    ConditionOperator:
      type: string
      enum:
        - equal
        - not_equal
        - contains
        - starts_with
        - ends_with
        - greater_than
        - greater_or_equal
        - less_than
        - less_or_equal
        - exists
        - not_exists

    RowCondition:
      type: object
      required: [column, operator]
      properties:
        column:
          type: string
          description: Nome colonna (non id)
          example: email
        operator:
          $ref: '#/components/schemas/ConditionOperator'
        value:
          description: Obbligatorio tranne per exists / not_exists
          oneOf:
            - type: string
            - type: number
            - type: boolean
            - type: string
              format: date-time

    RowSearchRequest:
      type: object
      properties:
        must_match:
          $ref: '#/components/schemas/MatchMode'
        match:
          $ref: '#/components/schemas/MatchMode'
        conditions:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/RowCondition'

    RowData:
      type: object
      additionalProperties: true
      description: Chiavi = nomi colonna schema; valori validati per tipo
      example:
        fullname: Mario Rossi
        age: 30

    RowListItem:
      type: object
      properties:
        _id:
          type: string
      additionalProperties: true
      description: _id + campi schema; mancanti = null
      example:
        _id: 6a217a72d154149630eac748
        name: John Doe
        repo: 100
        country: null

    RowDocument:
      type: object
      properties:
        _id:
          type: string
        id_project:
          type: string
        id_table:
          type: string
        data:
          $ref: '#/components/schemas/RowData'
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time

    InsertRowRequest:
      type: object
      required: [data]
      properties:
        data:
          $ref: '#/components/schemas/RowData'
        id_row:
          type: string
          description: Opzionale; forza l'_id MongoDB della nuova riga

    UpdateRowRequest:
      type: object
      required: [data]
      properties:
        id_row:
          type: string
        must_match:
          $ref: '#/components/schemas/MatchMode'
        match:
          $ref: '#/components/schemas/MatchMode'
        conditions:
          type: array
          items:
            $ref: '#/components/schemas/RowCondition'
        data:
          $ref: '#/components/schemas/RowData'
      oneOf:
        - required: [id_row, data]
        - required: [conditions, data]

    UpsertRowRequest:
      allOf:
        - $ref: '#/components/schemas/UpdateRowRequest'
        - type: object
          properties:
            multi:
              type: boolean
              default: false
              description: Se true con conditions, aggiorna tutte le righe match

    DeleteRowRequest:
      type: object
      properties:
        id_row:
          type: string
        must_match:
          $ref: '#/components/schemas/MatchMode'
        match:
          $ref: '#/components/schemas/MatchMode'
        conditions:
          type: array
          items:
            $ref: '#/components/schemas/RowCondition'
      oneOf:
        - required: [id_row]
        - required: [conditions]

    ErrorMessage:
      type: object
      properties:
        success:
          type: boolean
          example: false
        message:
          type: string
        error:
          type: string

  responses:
    Unauthorized:
      description: Non autenticato
    InternalError:
      description: Errore server
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorMessage'
    ValidationError:
      description: Input non valido
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorMessage'
    ConflictError:
      description: Conflitto (es. nome colonna duplicato)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorMessage'
    TableNotFound:
      description: Tabella non trovata
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorMessage'
    RowOrTableNotFound:
      description: Tabella o riga non trovata
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorMessage'
    NotFound:
      description: Risorsa non trovata
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorMessage'

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.