All files / services/workflow-service-api/src/shared/models Workflow.js

100% Statements 64/64
100% Branches 1/1
0% Functions 0/1
100% Lines 64/64

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 651x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
const mongoose = require('mongoose');
 
const destinationSchema = new mongoose.Schema({
  type: {
    type: String,
    // 'display' : aucune cible, le résultat raffiné est seulement conservé en output du job.
    // 'semantic-kb' : KB sémantique (RDF/OWL/SHACL sur Oxigraph).
    enum: ['assertion-kb', 'data-kb', 'semantic-kb', 'api', 'display'],
    required: true
  },
  id: {
    type: String,
    // Obligatoire sauf pour une destination 'display' (pas de cible).
    required: function () { return this.type !== 'display'; }
  },
  prompt: {
    type: String,
    default: ''
  },
  // { mode: 'assertion'|'data', spec: {...}, llmModel: '...' }
  refinement: {
    type: mongoose.Schema.Types.Mixed,
    default: null
  }
}, { _id: false });
 
const workflowSchema = new mongoose.Schema({
  organizationId: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'Organization',
    required: true,
    index: true
  },
  userId: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'User',
    required: true,
    index: true
  },
  name: {
    type: String,
    required: true,
    trim: true
  },
  description: {
    type: String,
    default: ''
  },
  // Un workflow = une obtention + une liste de destinations. Le raffinage (mode + spec +
  // modèle LLM) vit exclusivement dans `destination.refinement` : plus aucun raffinage
  // au niveau du workflow.
  destinations: {
    type: [destinationSchema],
    default: []
  },
  isActive: {
    type: Boolean,
    default: true
  }
}, {
  timestamps: true
});
 
module.exports = mongoose.model('Workflow', workflowSchema);