@persei/perseed-api 5.0.20 → 5.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/client.cjs +103 -8
  2. package/dist/client.cjs.map +1 -1
  3. package/dist/client.mjs +103 -8
  4. package/dist/client.mjs.map +1 -1
  5. package/dist/ecosystem-action-system.cjs +82 -2
  6. package/dist/ecosystem-action-system.cjs.map +1 -1
  7. package/dist/ecosystem-action-system.mjs +82 -2
  8. package/dist/ecosystem-action-system.mjs.map +1 -1
  9. package/dist/lib/src/generated/client.d.ts +594 -77
  10. package/dist/lib/src/generated/client.d.ts.map +1 -1
  11. package/dist/src/Services/ProcessLogService.d.ts +1 -1
  12. package/dist/src/Services/ProcessLogService.d.ts.map +1 -1
  13. package/dist/src/Services/QueryService.d.ts +24 -1
  14. package/dist/src/Services/QueryService.d.ts.map +1 -1
  15. package/dist/src/Services/RedisQueueService.d.ts.map +1 -1
  16. package/dist/src/models/ecosystem/NotificationConfiguration.d.ts +1 -1
  17. package/dist/src/models/ecosystem/NotificationConfiguration.d.ts.map +1 -1
  18. package/dist/src/models/ecosystem/User.d.ts +17 -0
  19. package/dist/src/models/ecosystem/User.d.ts.map +1 -1
  20. package/dist/src/models/ecosystem/User.getProjectUser.test.d.ts +2 -0
  21. package/dist/src/models/ecosystem/User.getProjectUser.test.d.ts.map +1 -0
  22. package/dist/src/models/perseed/PerseedEcosystem.d.ts +2 -0
  23. package/dist/src/models/perseed/PerseedEcosystem.d.ts.map +1 -1
  24. package/dist/src/schemas/api_action/ApiActionTypes.d.ts +11 -0
  25. package/dist/src/schemas/api_action/ApiActionTypes.d.ts.map +1 -1
  26. package/dist/src/schemas/index.d.ts +1 -0
  27. package/dist/src/schemas/index.d.ts.map +1 -1
  28. package/dist/src/schemas/project_user/index.d.ts +2 -0
  29. package/dist/src/schemas/project_user/index.d.ts.map +1 -0
  30. package/dist/src/schemas/project_user/types.d.ts +44 -0
  31. package/dist/src/schemas/project_user/types.d.ts.map +1 -0
  32. package/dist/src/v2/modules/ecosystem/action-system/action-system.controller/manual-trigger.controller.d.ts.map +1 -1
  33. package/dist/src/v2/modules/ecosystem/action-system/action-system.helper/action-system.helper.d.ts +26 -4
  34. package/dist/src/v2/modules/ecosystem/action-system/action-system.helper/action-system.helper.d.ts.map +1 -1
  35. package/dist/src/v2/modules/ecosystem/action-system/action-system.helper/index.d.ts +1 -0
  36. package/dist/src/v2/modules/ecosystem/action-system/action-system.helper/index.d.ts.map +1 -1
  37. package/dist/src/v2/modules/ecosystem/action-system/action-system.helper/manual-trigger.helper.d.ts +13 -0
  38. package/dist/src/v2/modules/ecosystem/action-system/action-system.helper/manual-trigger.helper.d.ts.map +1 -0
  39. package/dist/src/v2/modules/ecosystem/action-system/action-system.helper/manual-trigger.helper.test.d.ts +2 -0
  40. package/dist/src/v2/modules/ecosystem/action-system/action-system.helper/manual-trigger.helper.test.d.ts.map +1 -0
  41. package/dist/src/v2/modules/ecosystem/action-system/action-system.model.d.ts +2 -1
  42. package/dist/src/v2/modules/ecosystem/action-system/action-system.model.d.ts.map +1 -1
  43. package/dist/src/v2/modules/ecosystem/action-system/action-system.schema.d.ts +165 -0
  44. package/dist/src/v2/modules/ecosystem/action-system/action-system.schema.d.ts.map +1 -1
  45. package/dist/src/v2/modules/ecosystem/action-system/action-system.service/manual-trigger-engine.service.d.ts +6 -0
  46. package/dist/src/v2/modules/ecosystem/action-system/action-system.service/manual-trigger-engine.service.d.ts.map +1 -1
  47. package/dist/src/v2/modules/ecosystem/action-system/action-system.service/manual-trigger.service.d.ts +42 -0
  48. package/dist/src/v2/modules/ecosystem/action-system/action-system.service/manual-trigger.service.d.ts.map +1 -1
  49. package/dist/src/v2/modules/ecosystem/action-system/action-system.service/trigger-engine.service.d.ts +5 -0
  50. package/dist/src/v2/modules/ecosystem/action-system/action-system.service/trigger-engine.service.d.ts.map +1 -1
  51. package/dist/src/v2/modules/ecosystem/process-log/index.d.ts +3 -0
  52. package/dist/src/v2/modules/ecosystem/process-log/index.d.ts.map +1 -0
  53. package/dist/src/{models/ecosystem/ProcessLog.d.ts → v2/modules/ecosystem/process-log/process-log.model.d.ts} +5 -5
  54. package/dist/src/v2/modules/ecosystem/process-log/process-log.model.d.ts.map +1 -0
  55. package/dist/src/v2/modules/ecosystem/process-log/process-log.model.test.d.ts +2 -0
  56. package/dist/src/v2/modules/ecosystem/process-log/process-log.model.test.d.ts.map +1 -0
  57. package/dist/src/v2/modules/ecosystem/process-log/process-log.service.d.ts +20 -0
  58. package/dist/src/v2/modules/ecosystem/process-log/process-log.service.d.ts.map +1 -0
  59. package/dist/src/v2/modules/ecosystem/process-log/process-log.service.e2e.d.ts +2 -0
  60. package/dist/src/v2/modules/ecosystem/process-log/process-log.service.e2e.d.ts.map +1 -0
  61. package/dist/src/v2/modules/ecosystem/process-log/process-log.service.test.d.ts +2 -0
  62. package/dist/src/v2/modules/ecosystem/process-log/process-log.service.test.d.ts.map +1 -0
  63. package/dist/src/v2/modules/global/e2e-operation/e2e-operation.controller.d.ts.map +1 -1
  64. package/dist/src/v2/modules/global/e2e-operation/e2e-operation.service.d.ts.map +1 -1
  65. package/package.json +1 -1
  66. package/dist/src/models/ecosystem/ProcessLog.d.ts.map +0 -1
  67. package/dist/src/models/ecosystem/ProcessLog.test.d.ts +0 -2
  68. package/dist/src/models/ecosystem/ProcessLog.test.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ecosystem-action-system.mjs","sources":["../../src/v2/routes/v2/ecosystem/_ecosystemName/param.schema.ts","../../src/v2/routes/v2/ecosystem/_ecosystemName/project/_projectName/params.schema.ts","../../src/v2/modules/ecosystem/action-system/action-system.schema.ts"],"sourcesContent":["import { Type } from 'typebox'\n\nexport const ecosystemParamsSchema = Type.Object(\n {\n ecosystemName: Type.String({ maxLength: 255, description: 'Ecosystem name code' }),\n },\n { title: 'EcosystemParams', description: 'Params with ecosystem name' },\n)\n","import { Type } from 'typebox'\nimport { ecosystemParamsSchema } from '@/routes/v2/ecosystem/_ecosystemName/param.schema'\n\nexport const ecosystemProjectParamsSchema = Type.Intersect(\n [\n ecosystemParamsSchema,\n Type.Object({\n projectName: Type.String({ maxLength: 255, description: 'Project name code' }),\n }),\n ],\n { title: 'EcosystemProjectParams', description: 'Params with ecosystem name and project name' },\n)\n","import { Type, Static, type TSchema } from 'typebox'\nimport { ecosystemProjectParamsSchema } from '@/routes/v2/ecosystem/_ecosystemName/project/_projectName/params.schema'\n\n// ── Enums / literal unions ────────────────────────────────────────────\n// Each enum is a const object (source of truth, ergonomic dot access like\n// `TriggerSource.MODEL`) from which the runtime schema is derived with\n// `Type.Enum(Object.values(...))` and the type with `Static`.\n\nexport const ConditionsFormat = {\n JSON_LOGIC: 'jsonLogic',\n CUSTOM: 'custom',\n} as const\nexport const conditionsFormatSchema = Type.Enum(Object.values(ConditionsFormat), {\n title: 'ConditionsFormat',\n description: 'Format of the conditions evaluated by the conditions matcher',\n})\nexport type ConditionsFormat = Static<typeof conditionsFormatSchema>\n\nexport const TriggerSource = {\n MODEL: 'model',\n DESIGNER: 'designer',\n DISPLAYER: 'displayer',\n} as const\nexport const triggerSourceSchema = Type.Enum(Object.values(TriggerSource), {\n title: 'TriggerSource',\n description: 'Source of the event that fires a trigger',\n})\nexport type TriggerSource = Static<typeof triggerSourceSchema>\n\nexport const TriggerOperation = {\n CREATE: 'create',\n UPDATE: 'update',\n DELETE: 'delete',\n} as const\nexport const triggerOperationSchema = Type.Enum(Object.values(TriggerOperation), {\n title: 'TriggerOperation',\n description: 'Operation on the target that fires the trigger',\n})\nexport type TriggerOperation = Static<typeof triggerOperationSchema>\n\n// Executable mechanism of an action. `ApiAction` now; extensible to\n// `ExternalApiCall`, `Webhook`, … in the future (each adds a member here plus a\n// config schema below).\nexport const ActionType = {\n API_ACTION: 'ApiAction',\n} as const\nexport const actionTypeSchema = Type.Enum(Object.values(ActionType), {\n title: 'ActionType',\n description: 'Executable mechanism of an action',\n})\nexport type ActionType = Static<typeof actionTypeSchema>\n\n// ── Action config (discriminated union by `actions.type`) ─────────────\n// Forward-compatible contract shared with front/app via @persei/perseed-api.\n// Principles that the structure keeps prepared (not implemented here):\n// - `id` + fixed per-type fields: every type extends `ActionConfigBase`, so its\n// structure is known from `actions.type`.\n// - Objects always under a key (`payload`, …), never loose object fields, so new\n// fields can be added later without breaking compatibility.\n// - default + override: a type may carry a default config plus a `payload` that\n// overrides parts of it, both with the same typing (effective config = merge).\n//\n// `overridable`/`default`/`location` are generic base support for future\n// override-types (e.g. `ExternalApiCall`, #175): an override-type MUST declare\n// `overridable` (the allow-list of keys its payload may override on top of\n// `default`); `location` is a generic string here, refined per type when a\n// concrete type needs it. `ApiAction` is NOT an override-type — its `payload`\n// is the Handlebars data mapping, not an override of a default config — so it\n// gains these fields optionally but never sets `overridable`/`default`.\n\nexport const actionConfigBaseSchema = Type.Object(\n {\n id: Type.String({\n description:\n 'Identifier of the concrete action within its type (e.g. the ApiAction value for type \"ApiAction\"). Any identifier for future types.',\n }),\n location: Type.Optional(\n Type.String({\n description:\n 'Where the effective config is resolved from. Generic string in the base; refined per type in the future (e.g. \"inline\" | \"file\").',\n }),\n ),\n overridable: Type.Optional(\n Type.Array(Type.String(), {\n description:\n 'Allow-list of config keys a payload may override on top of `default`. Mandatory for override-types; absent for non-override types such as ApiAction.',\n }),\n ),\n default: Type.Optional(\n Type.Record(Type.String(), Type.Unknown(), {\n description: 'Base config an override-type merges its `payload` over (only overridable keys are applied).',\n }),\n ),\n },\n { title: 'ActionConfigBase', description: 'Base fields shared by every action config' },\n)\nexport type ActionConfigBaseData = Static<typeof actionConfigBaseSchema>\n\n// type = 'ApiAction' (current). `payload` is the data mapping needed to run the\n// ApiAction; it is always an object under a key for forward compatibility.\nexport const apiActionConfigSchema = Type.Intersect(\n [\n actionConfigBaseSchema,\n Type.Object({\n payload: Type.Record(Type.String(), Type.Unknown(), {\n description: 'Data mapping needed to run the ApiAction',\n }),\n }),\n ],\n { title: 'ApiActionConfig', description: 'Config for actions of type \"ApiAction\"' },\n)\nexport type ApiActionConfig = Static<typeof apiActionConfigSchema>\n\n// Discriminated (by `actions.type`) union of every action config. Extensible:\n// new types add a member that inherits from `ActionConfigBase`.\nexport const actionConfigSchema = Type.Union([apiActionConfigSchema], {\n title: 'ActionConfig',\n description: 'Union of action configs, selected by actions.type',\n})\nexport type ActionConfig = Static<typeof actionConfigSchema>\n\n// Registry mapping each action type to its config schema. Single seam to extend\n// when a new type is added, and the source used to validate a config by type.\nexport const ACTION_CONFIG_SCHEMAS: Record<ActionType, TSchema> = {\n [ActionType.API_ACTION]: apiActionConfigSchema,\n}\n\n// ── Action context (assembled data each action type evaluates against) ─\n// Mirrors the config-schema pattern above but for the *runtime* context\n// (jsonLogic conditions + handlebars payload refs are resolved against it),\n// not the static config. `additionalProperties: true` because the context is\n// enriched dynamically by the engine/ApiActionController (e.g. `ctx`).\n\nexport const actionContextBaseSchema = Type.Object(\n {\n current: Type.Record(Type.String(), Type.Unknown(), {\n description: 'Current state of the entity that fired the event',\n }),\n old: Type.Optional(\n Type.Union([Type.Record(Type.String(), Type.Unknown()), Type.Null()], {\n description: 'Previous state of the entity, when applicable (e.g. update/delete). Null otherwise',\n }),\n ),\n requestContextData: Type.Optional(\n Type.Unknown({ description: 'Snapshot of the request context (user, ecosystem, project…) when available' }),\n ),\n projectId: Type.Optional(\n Type.Union([Type.Number(), Type.Null()], {\n description: 'Project the event belongs to. Null for ecosystem-wide events',\n }),\n ),\n },\n {\n title: 'ActionContextBase',\n description: 'Base fields of the context assembled for every action execution',\n additionalProperties: true,\n },\n)\nexport type ActionContextBaseData = Static<typeof actionContextBaseSchema>\n\n// type = 'ApiAction' (current). No extra required keys beyond the base context\n// yet; kept as a distinct schema so future types can refine it independently.\nexport const apiActionContextSchema = actionContextBaseSchema\n\n// Registry mapping each action type to its context schema. Mirrors\n// `ACTION_CONFIG_SCHEMAS` — single seam to extend when a new type is added.\nexport const ACTION_CONTEXT_SCHEMAS: Record<ActionType, TSchema> = {\n [ActionType.API_ACTION]: apiActionContextSchema,\n}\n\n// Related models to load into the context before a trigger is evaluated — the\n// \"Load relations\" selector of the admin UI. Declared explicitly instead of being\n// derived from the paths a trigger uses: an action templating the whole context\n// (`{{json current}}`) references `current`, never `current.patient`, so deriving\n// would tie the loaded data to how a template is written rather than to what the\n// action needs. An object (not a bare list) because assembling the context has\n// historically taken more than one knob, leaving room to grow.\n//\n// Closed to unknown keys on purpose. The legacy trigger system had a second knob,\n// `load_patient` (`{where, join}`), with semantics this engine does not implement:\n// accepting it would persist a configuration that is then silently ignored, so a\n// trigger would look configured while its conditions never see the related data.\n// Rejecting it at the edge surfaces the mismatch as a 400 instead. Adding a knob\n// here is a deliberate act: declare the field AND read it in `loadRelations`.\nexport const triggerRelationsSchema = Type.Object(\n {\n join: Type.Optional(\n Type.Array(\n // A relation name, not free text: it is interpolated into the eager-loading graph\n // expression. Objection resolves it against the relations declared on the model (never\n // SQL), so an unknown name throws rather than leaking data — but validating the shape\n // here turns that runtime failure into a 400 at the edge, which is cheaper to diagnose.\n Type.String({ pattern: '^[A-Za-z_][A-Za-z0-9_]*$' }),\n { description: 'Relation names to eager-load onto `current` (e.g. [\"patient\"])' },\n ),\n ),\n },\n { title: 'TriggerRelations', additionalProperties: false },\n)\nexport type TriggerRelations = Static<typeof triggerRelationsSchema>\n\n// ── actions (independent reusable catalog) ────────────────────────────\n// Declared before the triggers because a trigger payload can carry actions\n// inline (see `triggerActionsInputSchema` below).\n\nexport const actionSchema = Type.Object(\n {\n id: Type.Number({ description: 'Unique identifier of the action' }),\n project_id: Type.Optional(\n Type.Union([Type.Number(), Type.Null()], {\n description: 'Project this action belongs to. Null when it is ecosystem-wide',\n }),\n ),\n name: Type.String({ maxLength: 255, description: 'Human-readable identifier of the action' }),\n type: actionTypeSchema,\n config: actionConfigSchema,\n retention_days: Type.Optional(\n Type.Union([Type.Number(), Type.Null()], {\n description:\n 'Retention in days for the process_log entries of this action (issue #175). Null = inherit (use the firing trigger retention; never if the trigger is null/0); 0 = disabled (never expires, regardless of the trigger); N (>0) = enabled (expires N days after write).',\n }),\n ),\n // Mirrors `dashboard_widget.library`. False by default, so an action created\n // inline from a trigger screen is single-use unless it is said otherwise.\n library: Type.Optional(\n Type.Boolean({\n description:\n 'Whether the action belongs to the reusable catalog. False (the default) marks it single-use: it is deleted once no trigger links it any more, including before it is ever linked — a standalone action created through POST /action and left unlinked is swept as soon as any trigger of the project writes its links. Set it to true to create one that survives on its own',\n }),\n ),\n },\n { title: 'Action', description: 'Reusable executable action (ecosystem level)' },\n)\nexport type ActionData = Static<typeof actionSchema>\n\n// `Type.Omit` keeps this a plain object — unlike `Type.Intersect` — so closing it here works: an\n// undeclared key is rejected with its name instead of being dropped on the way in. `id` and\n// `project_id` are omitted because the server sets them.\nexport const createActionSchema = Type.Omit(actionSchema, ['id', 'project_id'], {\n title: 'CreateAction',\n description: 'Payload used to create an action',\n additionalProperties: false,\n})\nexport type CreateActionData = Static<typeof createActionSchema>\n\n// Restated: `Type.Partial` rebuilds the object and does not carry over the options it derives from.\nexport const updateActionSchema = Type.Partial(createActionSchema, {\n title: 'UpdateAction',\n description: 'Payload used to update an action',\n additionalProperties: false,\n})\nexport type UpdateActionData = Static<typeof updateActionSchema>\n\n// ── Actions carried by a trigger payload ──────────────────────────────\n// One array, not two fields (`action_ids` + `new_actions`): the position IS the\n// `execution_order`, so splitting the list would make an order that interleaves\n// new and existing actions inexpressible. Each item takes one of three forms,\n// which `number` vs object and object with/without `id` disambiguate on their\n// own — no marker field needed:\n//\n// number link an existing catalog action, untouched\n// object without `id` create the action and link it\n// object with `id` update that catalog action and link it\n//\n// An object carrying only `id` is equivalent to passing the bare number.\n//\n// A malformed id is rejected rather than reinterpreted: `{ id: \"55\", name, type, config }` matches\n// no branch — the update one needs a numeric `id`, and the create one is closed against the key —\n// so it answers 400 instead of quietly landing on \"create a new action\".\nexport const triggerActionInputSchema = Type.Union(\n [\n Type.Number({ description: 'Identifier of an existing action to link, left untouched' }),\n Type.Object(\n { ...createActionSchema.properties },\n {\n title: 'TriggerActionCreate',\n description: 'Action created and linked in the same request',\n additionalProperties: false,\n },\n ),\n Type.Object(\n { id: Type.Number(), ...updateActionSchema.properties },\n {\n title: 'TriggerActionUpdate',\n description: 'Existing action updated and linked in the same request',\n additionalProperties: false,\n },\n ),\n ],\n { title: 'TriggerActionInput', description: 'An action a trigger runs: linked, created, or updated in place' },\n)\nexport type TriggerActionInput = Static<typeof triggerActionInputSchema>\n\nexport const triggerActionsInputSchema = Type.Array(triggerActionInputSchema, {\n description:\n 'Full ordered set of actions the trigger runs; the array position is the execution order. An empty array leaves the trigger with none',\n})\n\n// ── automatic_trigger ─────────────────────────────────────────────────\n\nexport const automaticTriggerSchema = Type.Object(\n {\n id: Type.Number({ description: 'Unique identifier of the automatic trigger' }),\n project_id: Type.Optional(\n Type.Union([Type.Number(), Type.Null()], {\n description: 'Project this trigger belongs to. Null when it is ecosystem-wide',\n }),\n ),\n source: triggerSourceSchema,\n target: Type.Optional(\n Type.Union([Type.String({ maxLength: 255 }), Type.Null()], {\n description: 'Concrete model/designer/field the event refers to. Null for sourceless events',\n }),\n ),\n operation: Type.Optional(\n Type.Union([triggerOperationSchema, Type.Null()], {\n description: 'Operation on the target that fires the trigger. Null when not applicable',\n }),\n ),\n conditions: Type.Optional(\n Type.Union([Type.Object({}, { additionalProperties: true }), Type.Null()], {\n description: 'jsonLogic conditions (root object) evaluated to decide whether the trigger runs',\n }),\n ),\n relations: Type.Optional(\n Type.Union([triggerRelationsSchema, Type.Null()], {\n description:\n 'Related models loaded into the context before evaluating the conditions and running the actions. Null means none.',\n }),\n ),\n enabled: Type.Optional(Type.Boolean({ description: 'Whether the trigger is active' })),\n retention_days: Type.Optional(\n Type.Union([Type.Number(), Type.Null()], {\n description:\n 'Retention in days for the process_log entries of this trigger (issue #175). Origin — no inheritance: null or 0 = disabled (never expires); N (>0) = enabled (expires N days after write).',\n }),\n ),\n },\n { title: 'AutomaticTrigger', description: 'Automatic trigger definition (ecosystem level)' },\n)\nexport type AutomaticTriggerData = Static<typeof automaticTriggerSchema>\n\n// `includeActions` arrives from the query string, where everything is a string: Fastify coerces\n// `?includeActions=true` to a boolean against this schema, so the handler reads a real boolean.\n//\n// Opt-in rather than always-on: the join costs a query per trigger and most reads do not need it.\n// The read reuses the `*WithActions` schema of each kind (declared with the write responses below):\n// `actions` is optional there, so with the flag off the key is simply absent — the same way a\n// write that did not touch the field says nothing about it instead of reporting an empty set.\n//\n// Shared by both trigger kinds: the flag means the same thing on each, and the query schema carries\n// no kind-specific field.\nexport const includeActionsQuerySchema = Type.Object(\n {\n includeActions: Type.Optional(\n Type.Boolean({\n default: false,\n description: 'Return each trigger with its ordered `actions` resolved, in a single request',\n }),\n ),\n },\n { title: 'IncludeActionsQuery', description: 'Opt-in flag to embed the actions of a trigger' },\n)\n\n// Written out rather than derived from `automaticTriggerSchema`: a request schema and an entity\n// schema answer different questions — what a client may send vs what a row holds — and only the\n// first can close itself. `additionalProperties: false` does not survive `Type.Intersect`, so a\n// derived payload had to be cleaned before validating, which dropped unknown keys silently. Spelled\n// out, an undeclared key is a 400 that names it, and `id`/`project_id` are absent because the server\n// owns them, not because an `Omit` removed them.\nexport const createAutomaticTriggerSchema = Type.Object(\n {\n source: triggerSourceSchema,\n target: Type.Optional(\n Type.Union([Type.String({ maxLength: 255 }), Type.Null()], {\n description: 'Concrete model/designer/field the event refers to. Null for sourceless events',\n }),\n ),\n operation: Type.Optional(\n Type.Union([triggerOperationSchema, Type.Null()], {\n description: 'Operation on the target that fires the trigger. Null when not applicable',\n }),\n ),\n conditions: Type.Optional(\n Type.Union([Type.Object({}, { additionalProperties: true }), Type.Null()], {\n description: 'jsonLogic conditions (root object) evaluated to decide whether the trigger runs',\n }),\n ),\n relations: Type.Optional(\n Type.Union([triggerRelationsSchema, Type.Null()], {\n description:\n 'Related models loaded into the context before evaluating the conditions and running the actions. Null means none.',\n }),\n ),\n enabled: Type.Optional(Type.Boolean({ description: 'Whether the trigger is active' })),\n retention_days: Type.Optional(\n Type.Union([Type.Number(), Type.Null()], {\n description:\n 'Retention in days for the process_log entries of this trigger (issue #175). Origin — no inheritance: null or 0 = disabled (never expires); N (>0) = enabled (expires N days after write).',\n }),\n ),\n actions: Type.Optional(triggerActionsInputSchema),\n },\n {\n title: 'CreateAutomaticTrigger',\n description: 'Payload used to create an automatic trigger, optionally with the actions it runs',\n additionalProperties: false,\n },\n)\nexport type CreateAutomaticTriggerData = Static<typeof createAutomaticTriggerSchema>\n\n// `actions` is inherited from the create schema and stays optional here, which is\n// what the update contract wants: absent leaves the links untouched, present\n// replaces the whole ordered set (never merges), `[]` leaves the trigger with none.\n// `additionalProperties: false` is restated: `Type.Partial` rebuilds the object and drops the\n// options of the schema it derives from, so inheriting it would leave this payload open.\nexport const updateAutomaticTriggerSchema = Type.Partial(createAutomaticTriggerSchema, {\n title: 'UpdateAutomaticTrigger',\n description: 'Payload used to update an automatic trigger, optionally replacing the actions it runs',\n additionalProperties: false,\n})\nexport type UpdateAutomaticTriggerData = Static<typeof updateAutomaticTriggerSchema>\n\n// ── manual_trigger ────────────────────────────────────────────────────\n\nexport const manualTriggerSchema = Type.Object(\n {\n id: Type.Number({ description: 'Unique identifier of the manual trigger' }),\n project_id: Type.Optional(\n Type.Union([Type.Number(), Type.Null()], {\n description: 'Project this trigger belongs to. Null when it is ecosystem-wide',\n }),\n ),\n name: Type.String({ maxLength: 255, description: 'Human-readable label of the trigger where it is offered' }),\n source: triggerSourceSchema,\n target: Type.String({\n maxLength: 255,\n description: 'Concrete model/designer/field the trigger is bound to. Always set: there is no wildcard',\n }),\n conditions: Type.Optional(\n Type.Union([Type.Object({}, { additionalProperties: true }), Type.Null()], {\n description:\n 'jsonLogic conditions (root object) evaluated to decide whether the trigger runs. Evaluated against the selected entity and the request context; `old` is always null, because the trigger is invoked explicitly and there is no previous state to compare against.',\n }),\n ),\n relations: Type.Optional(\n Type.Union([triggerRelationsSchema, Type.Null()], {\n description:\n 'Related models loaded into the context before evaluating the conditions and running the actions. Null means none.',\n }),\n ),\n enabled: Type.Optional(Type.Boolean({ description: 'Whether the trigger is active' })),\n retention_days: Type.Optional(\n Type.Union([Type.Number(), Type.Null()], {\n description:\n 'Retention in days for the process_log entries of this trigger (issue #175). Origin — no inheritance: null or 0 = disabled (never expires); N (>0) = enabled (expires N days after write).',\n }),\n ),\n },\n { title: 'ManualTrigger', description: 'Manual trigger definition (ecosystem level)' },\n)\nexport type ManualTriggerData = Static<typeof manualTriggerSchema>\n\n// Written out and closed, for the same reasons as `createAutomaticTriggerSchema` above.\nexport const createManualTriggerSchema = Type.Object(\n {\n name: Type.String({ maxLength: 255, description: 'Human-readable label of the trigger where it is offered' }),\n source: triggerSourceSchema,\n target: Type.String({\n maxLength: 255,\n description: 'Concrete model/designer/field the trigger is bound to. Always set: there is no wildcard',\n }),\n conditions: Type.Optional(\n Type.Union([Type.Object({}, { additionalProperties: true }), Type.Null()], {\n description:\n 'jsonLogic conditions (root object) evaluated to decide whether the trigger runs. Evaluated against the selected entity and the request context; `old` is always null, because the trigger is invoked explicitly and there is no previous state to compare against.',\n }),\n ),\n relations: Type.Optional(\n Type.Union([triggerRelationsSchema, Type.Null()], {\n description:\n 'Related models loaded into the context before evaluating the conditions and running the actions. Null means none.',\n }),\n ),\n enabled: Type.Optional(Type.Boolean({ description: 'Whether the trigger is active' })),\n retention_days: Type.Optional(\n Type.Union([Type.Number(), Type.Null()], {\n description:\n 'Retention in days for the process_log entries of this trigger (issue #175). Origin — no inheritance: null or 0 = disabled (never expires); N (>0) = enabled (expires N days after write).',\n }),\n ),\n actions: Type.Optional(triggerActionsInputSchema),\n },\n {\n title: 'CreateManualTrigger',\n description: 'Payload used to create a manual trigger, optionally with the actions it runs',\n additionalProperties: false,\n },\n)\nexport type CreateManualTriggerData = Static<typeof createManualTriggerSchema>\n\n// Same inheritance and semantics as `updateAutomaticTriggerSchema`.\nexport const updateManualTriggerSchema = Type.Partial(createManualTriggerSchema, {\n title: 'UpdateManualTrigger',\n description: 'Payload used to update a manual trigger, optionally replacing the actions it runs',\n additionalProperties: false,\n})\nexport type UpdateManualTriggerData = Static<typeof updateManualTriggerSchema>\n\n// What the listing endpoint returns per applicable manual trigger: enough to\n// render it and nothing more. `matched` is the *evaluated* conditions outcome —\n// the back reports it, the front decides whether to show the trigger disabled or\n// hide it. It is never an authorisation: running re-evaluates server-side.\nexport const manualTriggerAvailabilitySchema = Type.Object(\n {\n id: Type.Number({ description: 'Identifier of the manual trigger' }),\n name: Type.String({ description: 'Human-readable label of the trigger' }),\n matched: Type.Boolean({\n description:\n 'Whether the trigger conditions hold for this entity right now. A trigger with no conditions always matches',\n }),\n actionsCount: Type.Number({ description: 'Number of actions the trigger would run' }),\n relationsSkipped: Type.Optional(\n Type.Union([Type.String(), Type.Null()], {\n description:\n 'Reason the declared relations could not be loaded before evaluating, when that happened. Null otherwise',\n }),\n ),\n },\n {\n title: 'ManualTriggerAvailability',\n description: 'A manual trigger applicable to an entity, with its conditions already evaluated',\n },\n)\nexport type ManualTriggerAvailability = Static<typeof manualTriggerAvailabilitySchema>\n\nexport const manualTriggerAvailabilityListSchema = Type.Object(\n { results: Type.Array(manualTriggerAvailabilitySchema, { description: 'Applicable manual triggers' }) },\n {\n title: 'ManualTriggerAvailabilityList',\n description: 'Manual triggers applicable to an entity, with their conditions evaluated',\n },\n)\n\n// Query the listing endpoint is called with: the entity the triggers are offered\n// on. `source`/`target` are the coordinates a manual trigger is bound to, and\n// `entityId` the concrete row.\nexport const manualTriggerAvailabilityQuerySchema = Type.Object(\n {\n source: triggerSourceSchema,\n target: Type.String({ maxLength: 255, description: 'Concrete model/designer/field the triggers are bound to' }),\n entityId: Type.Number({ description: 'Identifier of the entity the triggers would run against' }),\n },\n { title: 'ManualTriggerAvailabilityQuery', description: 'Entity the applicable manual triggers are listed for' },\n)\nexport type ManualTriggerAvailabilityQuery = Static<typeof manualTriggerAvailabilityQuerySchema>\n\n// Body of the run endpoint. It carries only the entity: `source`/`target` are\n// read from the trigger row, never from the client, so a trigger cannot be\n// re-pointed at an entity it was not bound to.\nexport const runManualTriggerSchema = Type.Object(\n { entityId: Type.Number({ description: 'Identifier of the entity to run the trigger against' }) },\n { title: 'RunManualTrigger', description: 'Payload used to run a manual trigger against an entity' },\n)\nexport type RunManualTriggerData = Static<typeof runManualTriggerSchema>\n\n// ── automatic_trigger_action (intermediate N:M automatic_trigger↔actions,\n// ordered) ──────────────────────────────────────────────────────────────\n// Dedicated table per trigger kind (no ORM polymorphism): `automatic_trigger_id`\n// is a real FK. `manual_trigger_action` is a future table for manual triggers.\n\nexport const automaticTriggerActionSchema = Type.Object(\n {\n id: Type.Number({ description: 'Unique identifier of the trigger-action link' }),\n automatic_trigger_id: Type.Number({\n description: 'Automatic trigger executing the action (FK to automatic_trigger)',\n }),\n action_id: Type.Number({ description: 'Action executed by the trigger (FK to actions)' }),\n execution_order: Type.Number({ description: 'Execution order of the action within the trigger' }),\n },\n { title: 'AutomaticTriggerAction', description: 'Ordered link between an automatic trigger and an action' },\n)\nexport type AutomaticTriggerActionData = Static<typeof automaticTriggerActionSchema>\n\n// The `create*`/`update*` pair below is not an endpoint contract: the links are\n// written through the `actions` field of the trigger create/update payloads.\n// They remain because `action-system.model.ts` builds the Objection\n// `jsonSchema` of the link models out of their union.\nexport const createAutomaticTriggerActionSchema = Type.Omit(automaticTriggerActionSchema, ['id'], {\n title: 'CreateAutomaticTriggerAction',\n description: 'Row shape of an automatic trigger-action link',\n})\nexport type CreateAutomaticTriggerActionData = Static<typeof createAutomaticTriggerActionSchema>\n\nexport const updateAutomaticTriggerActionSchema = Type.Partial(createAutomaticTriggerActionSchema, {\n title: 'UpdateAutomaticTriggerAction',\n description: 'Partial row shape of an automatic trigger-action link',\n})\nexport type UpdateAutomaticTriggerActionData = Static<typeof updateAutomaticTriggerActionSchema>\n\n// ── manual_trigger_action (intermediate N:M manual_trigger↔actions,\n// ordered) ──────────────────────────────────────────────────────────────\n// Same dedicated-table-per-trigger-kind rule as `automatic_trigger_action`:\n// `manual_trigger_id` is a real FK, and the `actions` catalog is shared\n// between kinds — only the link table differs.\n\nexport const manualTriggerActionSchema = Type.Object(\n {\n id: Type.Number({ description: 'Unique identifier of the trigger-action link' }),\n manual_trigger_id: Type.Number({\n description: 'Manual trigger executing the action (FK to manual_trigger)',\n }),\n action_id: Type.Number({ description: 'Action executed by the trigger (FK to actions)' }),\n execution_order: Type.Number({ description: 'Execution order of the action within the trigger' }),\n },\n { title: 'ManualTriggerAction', description: 'Ordered link between a manual trigger and an action' },\n)\nexport type ManualTriggerActionData = Static<typeof manualTriggerActionSchema>\n\n// Same as the automatic pair above: kept for the model `jsonSchema`, not as an\n// endpoint contract.\nexport const createManualTriggerActionSchema = Type.Omit(manualTriggerActionSchema, ['id'], {\n title: 'CreateManualTriggerAction',\n description: 'Row shape of a manual trigger-action link',\n})\nexport type CreateManualTriggerActionData = Static<typeof createManualTriggerActionSchema>\n\nexport const updateManualTriggerActionSchema = Type.Partial(createManualTriggerActionSchema, {\n title: 'UpdateManualTriggerAction',\n description: 'Partial row shape of a manual trigger-action link',\n})\nexport type UpdateManualTriggerActionData = Static<typeof updateManualTriggerActionSchema>\n\n// ── Declarative trigger↔actions contract ──────────────────────────────\n// The link tables are written as a whole through the `actions` field of the trigger payload,\n// never row by row. The array position IS the `execution_order`, so ordering can\n// never disagree with the list the client sent — which per-row endpoints allowed\n// (duplicate or gapped orders after a reorder). Shared by both trigger kinds:\n// only the parent FK differs, and that comes from the URL.\n//\n// The field is `actions`, not `action_ids`: items are no longer only ids (see\n// `triggerActionInputSchema`). Same body as the `actions` field of the create and\n// update trigger payloads, so the three ways of writing the set agree.\n\n// What create/update answer with. `actions` carries the resolved catalog rows —\n// not the link rows — so a client that sent actions inline learns the ids they\n// were given without chaining a second request. It is present only when the\n// request carried the field: a create/update that did not mention actions says\n// nothing about them, rather than reporting an empty set it never touched.\nconst withResolvedActions = Type.Object({\n actions: Type.Optional(Type.Array(actionSchema, { description: 'Actions the trigger runs, in execution order' })),\n})\n\nexport const automaticTriggerWithActionsSchema = Type.Intersect([automaticTriggerSchema, withResolvedActions], {\n title: 'AutomaticTriggerWithActions',\n description:\n 'An automatic trigger and, when the request wrote them or `includeActions` asked for them, the actions it runs',\n})\nexport type AutomaticTriggerWithActionsData = Static<typeof automaticTriggerWithActionsSchema>\n\nexport const manualTriggerWithActionsSchema = Type.Intersect([manualTriggerSchema, withResolvedActions], {\n title: 'ManualTriggerWithActions',\n description:\n 'A manual trigger and, when the request wrote them or `includeActions` asked for them, the actions it runs',\n})\nexport type ManualTriggerWithActionsData = Static<typeof manualTriggerWithActionsSchema>\n\n// ── Execution engine (pure, model-independent contract types) ──────────\n// Exported types the engine (service/helper) works with. Kept here (rather\n// than in service/helper) so they can be imported without pulling in\n// service/helper code. None of them references a model: the engine types\n// itself structurally (see the `*Like` shapes below).\n\nexport interface ActionEvent {\n source: TriggerSource\n target?: string | null\n operation?: TriggerOperation | null\n current: Record<string, unknown>\n old?: Record<string, unknown> | null\n}\n\n// Outcome of evaluating (and, when matched, running) a single trigger. Declared\n// as a TypeBox schema — not just an interface — because the manual-trigger run\n// endpoint returns it verbatim; `TriggerExecutionResult` is its static type, so\n// engine and endpoint cannot drift apart.\nexport const triggerExecutionResultSchema = Type.Object(\n {\n triggerId: Type.Number({ description: 'Identifier of the evaluated trigger' }),\n matched: Type.Boolean({ description: 'Whether the conditions held, so the actions were run' }),\n actionsRun: Type.Number({ description: 'Number of actions that were executed' }),\n actionsAborted: Type.Number({ description: 'Number of actions aborted by context validation' }),\n },\n { title: 'TriggerExecutionResult', description: 'Outcome of evaluating and running one trigger' },\n)\nexport type TriggerExecutionResult = Static<typeof triggerExecutionResultSchema>\n\n// ── Trigger-kind-agnostic engine contract ─────────────────────────────\n// The execution engine is shared by every kind of trigger: it consumes the\n// minimal structural shapes below rather than a concrete model, so a new kind\n// only has to resolve its own candidates and hand them over. The `*Like` types\n// are deliberately structural (not the Objection classes) so the engine never\n// imports a model to type itself — `AutomaticTrigger` / `AutomaticTriggerAction`\n// / `Action` satisfy them as they are, without a cast.\n\n/**\n * Structural shape the engine needs from an action it is about to run: the\n * identity it logs, the `type` that selects the validation/dispatch branch, the\n * config it executes with, and the retention it resolves `expires_at` from.\n * Deliberately loose (`type: string`, not `ActionType`) so an unknown type still\n * reaches the always-blocking context validation instead of failing to typecheck.\n */\nexport interface ActionLike {\n id: number\n type: string\n config: ActionConfig\n retention_days?: number | null\n}\n\n/** Ordered trigger↔action link in the minimal shape the engine consumes. */\nexport interface TriggerActionLike {\n action_id: number\n execution_order: number\n action?: ActionLike\n}\n\n/** Minimal shape of a trigger for the engine, whatever its kind. */\nexport interface EvaluableTrigger {\n id: number\n conditions?: object | null\n relations?: TriggerRelations | null\n retention_days?: number | null\n trigger_actions?: TriggerActionLike[]\n}\n\n/**\n * A batch of already-resolved candidates a trigger kind hands to the engine,\n * together with the event data they were resolved for. `relatedModel` is what\n * the evaluation `process_log` row is related to (the trigger table of that\n * kind), which is how trigger evaluations stay independently queryable per kind.\n */\nexport interface TriggerBatch<T extends EvaluableTrigger = EvaluableTrigger> {\n triggers: T[]\n relatedModel: string\n source: TriggerSource\n target?: string | null\n operation?: TriggerOperation | null\n current: Record<string, unknown>\n old?: Record<string, unknown> | null\n}\n\n// ── Context validation (pure data types) ────────────────────────────────\n\nexport interface ContextValidationResult {\n ok: boolean\n type: string\n baseErrors: { path: string; message: string }[]\n missingRefs: string[]\n referencedRefs: string[]\n overridableErrors: string[]\n}\n\n// Structural shape `buildEffectiveConfig`/`validateActionContext` need from an\n// action config — deliberately loose (not `ActionConfig`) so it works for any\n// current or future type without a cast at every call site.\nexport interface ActionConfigLike {\n payload?: Record<string, unknown>\n overridable?: string[]\n default?: Record<string, unknown>\n}\n\nexport interface EffectiveConfigResult {\n effective: Record<string, unknown>\n overridableErrors: string[]\n}\n\n// ── Route-level schemas ───────────────────────────────────────────────\n// Shared by every router of the module.\n\nexport const successResponseSchema = Type.Object(\n { success: Type.Boolean({ description: 'If the request success or not' }) },\n { title: 'ActionSystemSuccessResponse', description: 'Response when the request is successful' },\n)\n\nexport const withIdParamsSchema = Type.Intersect(\n [ecosystemProjectParamsSchema, Type.Object({ id: Type.Number({ description: 'Entity ID' }) })],\n { title: 'EcosystemProjectWithActionSystemIdParams', description: 'Params with ecosystem, project and entity ID' },\n)\n"],"names":[],"mappings":";AAEO,MAAM,wBAAwB,KAAK;AAAA,EACxC;AAAA,IACE,eAAe,KAAK,OAAO,EAAE,WAAW,KAAK,aAAa,uBAAuB;AAAA,EAAA;AAAA,EAEnF,EAAE,OAAO,mBAAmB,aAAa,6BAAA;AAC3C;ACJO,MAAM,+BAA+B,KAAK;AAAA,EAC/C;AAAA,IACE;AAAA,IACA,KAAK,OAAO;AAAA,MACV,aAAa,KAAK,OAAO,EAAE,WAAW,KAAK,aAAa,qBAAqB;AAAA,IAAA,CAC9E;AAAA,EAAA;AAAA,EAEH,EAAE,OAAO,0BAA0B,aAAa,8CAAA;AAClD;ACHO,MAAM,mBAAmB;AAAA,EAC9B,YAAY;AAAA,EACZ,QAAQ;AACV;AACO,MAAM,yBAAyB,KAAK,KAAK,OAAO,OAAO,gBAAgB,GAAG;AAAA,EAC/E,OAAO;AAAA,EACP,aAAa;AACf,CAAC;AAGM,MAAM,gBAAgB;AAAA,EAC3B,OAAO;AAAA,EACP,UAAU;AAAA,EACV,WAAW;AACb;AACO,MAAM,sBAAsB,KAAK,KAAK,OAAO,OAAO,aAAa,GAAG;AAAA,EACzE,OAAO;AAAA,EACP,aAAa;AACf,CAAC;AAGM,MAAM,mBAAmB;AAAA,EAC9B,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AACV;AACO,MAAM,yBAAyB,KAAK,KAAK,OAAO,OAAO,gBAAgB,GAAG;AAAA,EAC/E,OAAO;AAAA,EACP,aAAa;AACf,CAAC;AAMM,MAAM,aAAa;AAAA,EACxB,YAAY;AACd;AACO,MAAM,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aAAa,gDAAgD,CAAC;AAClH,CAAC;AAEM,MAAM,oCAAoC,KAAK,UAAU,CAAC,wBAAwB,mBAAmB,GAAG;AAAA,EAC7G,OAAO;AAAA,EACP,aACE;AACJ,CAAC;AAGM,MAAM,iCAAiC,KAAK,UAAU,CAAC,qBAAqB,mBAAmB,GAAG;AAAA,EACvG,OAAO;AAAA,EACP,aACE;AACJ,CAAC;AAqBM,MAAM,+BAA+B,KAAK;AAAA,EAC/C;AAAA,IACE,WAAW,KAAK,OAAO,EAAE,aAAa,uCAAuC;AAAA,IAC7E,SAAS,KAAK,QAAQ,EAAE,aAAa,wDAAwD;AAAA,IAC7F,YAAY,KAAK,OAAO,EAAE,aAAa,wCAAwC;AAAA,IAC/E,gBAAgB,KAAK,OAAO,EAAE,aAAa,mDAAmD;AAAA,EAAA;AAAA,EAEhG,EAAE,OAAO,0BAA0B,aAAa,gDAAA;AAClD;AAqFO,MAAM,wBAAwB,KAAK;AAAA,EACxC,EAAE,SAAS,KAAK,QAAQ,EAAE,aAAa,gCAAA,CAAiC,EAAA;AAAA,EACxE,EAAE,OAAO,+BAA+B,aAAa,0CAAA;AACvD;AAEO,MAAM,qBAAqB,KAAK;AAAA,EACrC,CAAC,8BAA8B,KAAK,OAAO,EAAE,IAAI,KAAK,OAAO,EAAE,aAAa,YAAA,CAAa,EAAA,CAAG,CAAC;AAAA,EAC7F,EAAE,OAAO,4CAA4C,aAAa,+CAAA;AACpE;"}
1
+ {"version":3,"file":"ecosystem-action-system.mjs","sources":["../../src/v2/routes/v2/ecosystem/_ecosystemName/param.schema.ts","../../src/v2/routes/v2/ecosystem/_ecosystemName/project/_projectName/params.schema.ts","../../src/v2/modules/ecosystem/action-system/action-system.schema.ts"],"sourcesContent":["import { Type } from 'typebox'\n\nexport const ecosystemParamsSchema = Type.Object(\n {\n ecosystemName: Type.String({ maxLength: 255, description: 'Ecosystem name code' }),\n },\n { title: 'EcosystemParams', description: 'Params with ecosystem name' },\n)\n","import { Type } from 'typebox'\nimport { ecosystemParamsSchema } from '@/routes/v2/ecosystem/_ecosystemName/param.schema'\n\nexport const ecosystemProjectParamsSchema = Type.Intersect(\n [\n ecosystemParamsSchema,\n Type.Object({\n projectName: Type.String({ maxLength: 255, description: 'Project name code' }),\n }),\n ],\n { title: 'EcosystemProjectParams', description: 'Params with ecosystem name and project name' },\n)\n","import { Type, Static, type TSchema } from 'typebox'\nimport { ecosystemProjectParamsSchema } from '@/routes/v2/ecosystem/_ecosystemName/project/_projectName/params.schema'\n\n// ── Enums / literal unions ────────────────────────────────────────────\n// Each enum is a const object (source of truth, ergonomic dot access like\n// `TriggerSource.MODEL`) from which the runtime schema is derived with\n// `Type.Enum(Object.values(...))` and the type with `Static`.\n\nexport const ConditionsFormat = {\n JSON_LOGIC: 'jsonLogic',\n CUSTOM: 'custom',\n} as const\nexport const conditionsFormatSchema = Type.Enum(Object.values(ConditionsFormat), {\n title: 'ConditionsFormat',\n description: 'Format of the conditions evaluated by the conditions matcher',\n})\nexport type ConditionsFormat = Static<typeof conditionsFormatSchema>\n\nexport const TriggerSource = {\n MODEL: 'model',\n DESIGNER: 'designer',\n DISPLAYER: 'displayer',\n} as const\nexport const triggerSourceSchema = Type.Enum(Object.values(TriggerSource), {\n title: 'TriggerSource',\n description: 'Source of the event that fires a trigger',\n})\nexport type TriggerSource = Static<typeof triggerSourceSchema>\n\nexport const TriggerOperation = {\n CREATE: 'create',\n UPDATE: 'update',\n DELETE: 'delete',\n} as const\nexport const triggerOperationSchema = Type.Enum(Object.values(TriggerOperation), {\n title: 'TriggerOperation',\n description: 'Operation on the target that fires the trigger',\n})\nexport type TriggerOperation = Static<typeof triggerOperationSchema>\n\n// Executable mechanism of an action. `ApiAction` now; extensible to\n// `ExternalApiCall`, `Webhook`, … in the future (each adds a member here plus a\n// config schema below).\nexport const ActionType = {\n API_ACTION: 'ApiAction',\n} as const\nexport const actionTypeSchema = Type.Enum(Object.values(ActionType), {\n title: 'ActionType',\n description: 'Executable mechanism of an action',\n})\nexport type ActionType = Static<typeof actionTypeSchema>\n\n// ── Action config (discriminated union by `actions.type`) ─────────────\n// Forward-compatible contract shared with front/app via @persei/perseed-api.\n// Principles that the structure keeps prepared (not implemented here):\n// - `id` + fixed per-type fields: every type extends `ActionConfigBase`, so its\n// structure is known from `actions.type`.\n// - Objects always under a key (`payload`, …), never loose object fields, so new\n// fields can be added later without breaking compatibility.\n// - default + override: a type may carry a default config plus a `payload` that\n// overrides parts of it, both with the same typing (effective config = merge).\n//\n// `overridable`/`default`/`location` are generic base support for future\n// override-types (e.g. `ExternalApiCall`, #175): an override-type MUST declare\n// `overridable` (the allow-list of keys its payload may override on top of\n// `default`); `location` is a generic string here, refined per type when a\n// concrete type needs it. `ApiAction` is NOT an override-type — its `payload`\n// is the Handlebars data mapping, not an override of a default config — so it\n// gains these fields optionally but never sets `overridable`/`default`.\n\nexport const actionConfigBaseSchema = Type.Object(\n {\n id: Type.String({\n description:\n 'Identifier of the concrete action within its type (e.g. the ApiAction value for type \"ApiAction\"). Any identifier for future types.',\n }),\n location: Type.Optional(\n Type.String({\n description:\n 'Where the effective config is resolved from. Generic string in the base; refined per type in the future (e.g. \"inline\" | \"file\").',\n }),\n ),\n overridable: Type.Optional(\n Type.Array(Type.String(), {\n description:\n 'Allow-list of config keys a payload may override on top of `default`. Mandatory for override-types; absent for non-override types such as ApiAction.',\n }),\n ),\n default: Type.Optional(\n Type.Record(Type.String(), Type.Unknown(), {\n description: 'Base config an override-type merges its `payload` over (only overridable keys are applied).',\n }),\n ),\n },\n { title: 'ActionConfigBase', description: 'Base fields shared by every action config' },\n)\nexport type ActionConfigBaseData = Static<typeof actionConfigBaseSchema>\n\n// type = 'ApiAction' (current). `payload` is the data mapping needed to run the\n// ApiAction; it is always an object under a key for forward compatibility.\nexport const apiActionConfigSchema = Type.Intersect(\n [\n actionConfigBaseSchema,\n Type.Object({\n payload: Type.Record(Type.String(), Type.Unknown(), {\n description: 'Data mapping needed to run the ApiAction',\n }),\n }),\n ],\n { title: 'ApiActionConfig', description: 'Config for actions of type \"ApiAction\"' },\n)\nexport type ApiActionConfig = Static<typeof apiActionConfigSchema>\n\n// Discriminated (by `actions.type`) union of every action config. Extensible:\n// new types add a member that inherits from `ActionConfigBase`.\nexport const actionConfigSchema = Type.Union([apiActionConfigSchema], {\n title: 'ActionConfig',\n description: 'Union of action configs, selected by actions.type',\n})\nexport type ActionConfig = Static<typeof actionConfigSchema>\n\n// Registry mapping each action type to its config schema. Single seam to extend\n// when a new type is added, and the source used to validate a config by type.\nexport const ACTION_CONFIG_SCHEMAS: Record<ActionType, TSchema> = {\n [ActionType.API_ACTION]: apiActionConfigSchema,\n}\n\n// ── Action context (assembled data each action type evaluates against) ─\n// Mirrors the config-schema pattern above but for the *runtime* context\n// (jsonLogic conditions + handlebars payload refs are resolved against it),\n// not the static config. `additionalProperties: true` because the context is\n// enriched dynamically by the engine/ApiActionController (e.g. `ctx`).\n\nexport const actionContextBaseSchema = Type.Object(\n {\n current: Type.Record(Type.String(), Type.Unknown(), {\n description: 'Current state of the entity that fired the event',\n }),\n old: Type.Optional(\n Type.Union([Type.Record(Type.String(), Type.Unknown()), Type.Null()], {\n description: 'Previous state of the entity, when applicable (e.g. update/delete). Null otherwise',\n }),\n ),\n requestContextData: Type.Optional(\n Type.Unknown({ description: 'Snapshot of the request context (user, ecosystem, project…) when available' }),\n ),\n // Declared even though `additionalProperties: true` would already let it through: what a\n // condition may be written against is part of the contract, and a field only the engine knows\n // about is one no admin can discover.\n requester: Type.Optional(\n Type.Unknown({\n description:\n 'Who is making the request — role, administrator flags, privileges and clinics of their profiling in the project. Absent when the request carries no user (an internal call, a job)',\n }),\n ),\n projectId: Type.Optional(\n Type.Union([Type.Number(), Type.Null()], {\n description: 'Project the event belongs to. Null for ecosystem-wide events',\n }),\n ),\n },\n {\n title: 'ActionContextBase',\n description: 'Base fields of the context assembled for every action execution',\n additionalProperties: true,\n },\n)\nexport type ActionContextBaseData = Static<typeof actionContextBaseSchema>\n\n// type = 'ApiAction' (current). No extra required keys beyond the base context\n// yet; kept as a distinct schema so future types can refine it independently.\nexport const apiActionContextSchema = actionContextBaseSchema\n\n// Registry mapping each action type to its context schema. Mirrors\n// `ACTION_CONFIG_SCHEMAS` — single seam to extend when a new type is added.\nexport const ACTION_CONTEXT_SCHEMAS: Record<ActionType, TSchema> = {\n [ActionType.API_ACTION]: apiActionContextSchema,\n}\n\n// Related models to load into the context before a trigger is evaluated — the\n// \"Load relations\" selector of the admin UI. Declared explicitly instead of being\n// derived from the paths a trigger uses: an action templating the whole context\n// (`{{json current}}`) references `current`, never `current.patient`, so deriving\n// would tie the loaded data to how a template is written rather than to what the\n// action needs. An object (not a bare list) because assembling the context has\n// historically taken more than one knob, leaving room to grow.\n//\n// Closed to unknown keys on purpose. The legacy trigger system had a second knob,\n// `load_patient` (`{where, join}`), with semantics this engine does not implement:\n// accepting it would persist a configuration that is then silently ignored, so a\n// trigger would look configured while its conditions never see the related data.\n// Rejecting it at the edge surfaces the mismatch as a 400 instead. Adding a knob\n// here is a deliberate act: declare the field AND read it in `loadRelations`.\nexport const triggerRelationsSchema = Type.Object(\n {\n join: Type.Optional(\n Type.Array(\n // A relation name, not free text: it is interpolated into the eager-loading graph\n // expression. Objection resolves it against the relations declared on the model (never\n // SQL), so an unknown name throws rather than leaking data — but validating the shape\n // here turns that runtime failure into a 400 at the edge, which is cheaper to diagnose.\n Type.String({ pattern: '^[A-Za-z_][A-Za-z0-9_]*$' }),\n { description: 'Relation names to eager-load onto `current` (e.g. [\"patient\"])' },\n ),\n ),\n },\n { title: 'TriggerRelations', additionalProperties: false },\n)\nexport type TriggerRelations = Static<typeof triggerRelationsSchema>\n\n// ── actions (independent reusable catalog) ────────────────────────────\n// Declared before the triggers because a trigger payload can carry actions\n// inline (see `triggerActionsInputSchema` below).\n\nexport const actionSchema = Type.Object(\n {\n id: Type.Number({ description: 'Unique identifier of the action' }),\n project_id: Type.Optional(\n Type.Union([Type.Number(), Type.Null()], {\n description: 'Project this action belongs to. Null when it is ecosystem-wide',\n }),\n ),\n name: Type.String({ maxLength: 255, description: 'Human-readable identifier of the action' }),\n type: actionTypeSchema,\n config: actionConfigSchema,\n retention_days: Type.Optional(\n Type.Union([Type.Number(), Type.Null()], {\n description:\n 'Retention in days for the process_log entries of this action (issue #175). Null = inherit (use the firing trigger retention; never if the trigger is null/0); 0 = disabled (never expires, regardless of the trigger); N (>0) = enabled (expires N days after write).',\n }),\n ),\n // Mirrors `dashboard_widget.library`. False by default, so an action created\n // inline from a trigger screen is single-use unless it is said otherwise.\n library: Type.Optional(\n Type.Boolean({\n description:\n 'Whether the action belongs to the reusable catalog. False (the default) marks it single-use: it is deleted once no trigger links it any more, including before it is ever linked — a standalone action created through POST /action and left unlinked is swept as soon as any trigger of the project writes its links. Set it to true to create one that survives on its own',\n }),\n ),\n },\n { title: 'Action', description: 'Reusable executable action (ecosystem level)' },\n)\nexport type ActionData = Static<typeof actionSchema>\n\n// `Type.Omit` keeps this a plain object — unlike `Type.Intersect` — so closing it here works: an\n// undeclared key is rejected with its name instead of being dropped on the way in. `id` and\n// `project_id` are omitted because the server sets them.\nexport const createActionSchema = Type.Omit(actionSchema, ['id', 'project_id'], {\n title: 'CreateAction',\n description: 'Payload used to create an action',\n additionalProperties: false,\n})\nexport type CreateActionData = Static<typeof createActionSchema>\n\n// Restated: `Type.Partial` rebuilds the object and does not carry over the options it derives from.\nexport const updateActionSchema = Type.Partial(createActionSchema, {\n title: 'UpdateAction',\n description: 'Payload used to update an action',\n additionalProperties: false,\n})\nexport type UpdateActionData = Static<typeof updateActionSchema>\n\n// ── Actions carried by a trigger payload ──────────────────────────────\n// One array, not two fields (`action_ids` + `new_actions`): the position IS the\n// `execution_order`, so splitting the list would make an order that interleaves\n// new and existing actions inexpressible. Each item takes one of three forms,\n// which `number` vs object and object with/without `id` disambiguate on their\n// own — no marker field needed:\n//\n// number link an existing catalog action, untouched\n// object without `id` create the action and link it\n// object with `id` update that catalog action and link it\n//\n// An object carrying only `id` is equivalent to passing the bare number.\n//\n// A malformed id is rejected rather than reinterpreted: `{ id: \"55\", name, type, config }` matches\n// no branch — the update one needs a numeric `id`, and the create one is closed against the key —\n// so it answers 400 instead of quietly landing on \"create a new action\".\nexport const triggerActionInputSchema = Type.Union(\n [\n Type.Number({ description: 'Identifier of an existing action to link, left untouched' }),\n Type.Object(\n { ...createActionSchema.properties },\n {\n title: 'TriggerActionCreate',\n description: 'Action created and linked in the same request',\n additionalProperties: false,\n },\n ),\n Type.Object(\n { id: Type.Number(), ...updateActionSchema.properties },\n {\n title: 'TriggerActionUpdate',\n description: 'Existing action updated and linked in the same request',\n additionalProperties: false,\n },\n ),\n ],\n { title: 'TriggerActionInput', description: 'An action a trigger runs: linked, created, or updated in place' },\n)\nexport type TriggerActionInput = Static<typeof triggerActionInputSchema>\n\nexport const triggerActionsInputSchema = Type.Array(triggerActionInputSchema, {\n description:\n 'Full ordered set of actions the trigger runs; the array position is the execution order. An empty array leaves the trigger with none',\n})\n\n// ── automatic_trigger ─────────────────────────────────────────────────\n\nexport const automaticTriggerSchema = Type.Object(\n {\n id: Type.Number({ description: 'Unique identifier of the automatic trigger' }),\n project_id: Type.Optional(\n Type.Union([Type.Number(), Type.Null()], {\n description: 'Project this trigger belongs to. Null when it is ecosystem-wide',\n }),\n ),\n source: triggerSourceSchema,\n target: Type.Optional(\n Type.Union([Type.String({ maxLength: 255 }), Type.Null()], {\n description: 'Concrete model/designer/field the event refers to. Null for sourceless events',\n }),\n ),\n operation: Type.Optional(\n Type.Union([triggerOperationSchema, Type.Null()], {\n description: 'Operation on the target that fires the trigger. Null when not applicable',\n }),\n ),\n conditions: Type.Optional(\n Type.Union([Type.Object({}, { additionalProperties: true }), Type.Null()], {\n description: 'jsonLogic conditions (root object) evaluated to decide whether the trigger runs',\n }),\n ),\n relations: Type.Optional(\n Type.Union([triggerRelationsSchema, Type.Null()], {\n description:\n 'Related models loaded into the context before evaluating the conditions and running the actions. Null means none.',\n }),\n ),\n enabled: Type.Optional(Type.Boolean({ description: 'Whether the trigger is active' })),\n retention_days: Type.Optional(\n Type.Union([Type.Number(), Type.Null()], {\n description:\n 'Retention in days for the process_log entries of this trigger (issue #175). Origin — no inheritance: null or 0 = disabled (never expires); N (>0) = enabled (expires N days after write).',\n }),\n ),\n },\n { title: 'AutomaticTrigger', description: 'Automatic trigger definition (ecosystem level)' },\n)\nexport type AutomaticTriggerData = Static<typeof automaticTriggerSchema>\n\n// `includeActions` arrives from the query string, where everything is a string: Fastify coerces\n// `?includeActions=true` to a boolean against this schema, so the handler reads a real boolean.\n//\n// Opt-in rather than always-on: the join costs a query per trigger and most reads do not need it.\n// The read reuses the `*WithActions` schema of each kind (declared with the write responses below):\n// `actions` is optional there, so with the flag off the key is simply absent — the same way a\n// write that did not touch the field says nothing about it instead of reporting an empty set.\n//\n// Shared by both trigger kinds: the flag means the same thing on each, and the query schema carries\n// no kind-specific field.\nexport const includeActionsQuerySchema = Type.Object(\n {\n includeActions: Type.Optional(\n Type.Boolean({\n default: false,\n description: 'Return each trigger with its ordered `actions` resolved, in a single request',\n }),\n ),\n },\n { title: 'IncludeActionsQuery', description: 'Opt-in flag to embed the actions of a trigger' },\n)\n\n// Written out rather than derived from `automaticTriggerSchema`: a request schema and an entity\n// schema answer different questions — what a client may send vs what a row holds — and only the\n// first can close itself. `additionalProperties: false` does not survive `Type.Intersect`, so a\n// derived payload had to be cleaned before validating, which dropped unknown keys silently. Spelled\n// out, an undeclared key is a 400 that names it, and `id`/`project_id` are absent because the server\n// owns them, not because an `Omit` removed them.\nexport const createAutomaticTriggerSchema = Type.Object(\n {\n source: triggerSourceSchema,\n target: Type.Optional(\n Type.Union([Type.String({ maxLength: 255 }), Type.Null()], {\n description: 'Concrete model/designer/field the event refers to. Null for sourceless events',\n }),\n ),\n operation: Type.Optional(\n Type.Union([triggerOperationSchema, Type.Null()], {\n description: 'Operation on the target that fires the trigger. Null when not applicable',\n }),\n ),\n conditions: Type.Optional(\n Type.Union([Type.Object({}, { additionalProperties: true }), Type.Null()], {\n description: 'jsonLogic conditions (root object) evaluated to decide whether the trigger runs',\n }),\n ),\n relations: Type.Optional(\n Type.Union([triggerRelationsSchema, Type.Null()], {\n description:\n 'Related models loaded into the context before evaluating the conditions and running the actions. Null means none.',\n }),\n ),\n enabled: Type.Optional(Type.Boolean({ description: 'Whether the trigger is active' })),\n retention_days: Type.Optional(\n Type.Union([Type.Number(), Type.Null()], {\n description:\n 'Retention in days for the process_log entries of this trigger (issue #175). Origin — no inheritance: null or 0 = disabled (never expires); N (>0) = enabled (expires N days after write).',\n }),\n ),\n actions: Type.Optional(triggerActionsInputSchema),\n },\n {\n title: 'CreateAutomaticTrigger',\n description: 'Payload used to create an automatic trigger, optionally with the actions it runs',\n additionalProperties: false,\n },\n)\nexport type CreateAutomaticTriggerData = Static<typeof createAutomaticTriggerSchema>\n\n// `actions` is inherited from the create schema and stays optional here, which is\n// what the update contract wants: absent leaves the links untouched, present\n// replaces the whole ordered set (never merges), `[]` leaves the trigger with none.\n// `additionalProperties: false` is restated: `Type.Partial` rebuilds the object and drops the\n// options of the schema it derives from, so inheriting it would leave this payload open.\nexport const updateAutomaticTriggerSchema = Type.Partial(createAutomaticTriggerSchema, {\n title: 'UpdateAutomaticTrigger',\n description: 'Payload used to update an automatic trigger, optionally replacing the actions it runs',\n additionalProperties: false,\n})\nexport type UpdateAutomaticTriggerData = Static<typeof updateAutomaticTriggerSchema>\n\n// ── manual_trigger ────────────────────────────────────────────────────\n\n// What the consumer does with the button when the trigger conditions do not hold. It lives at the\n// root of the config, outside `styles`, so no conditional style can reach it: whether the button is\n// active is decided by the trigger conditions alone, and the style system only dresses it.\nexport const UnmatchedBehavior = {\n HIDE: 'hide',\n DISABLE: 'disable',\n} as const\nexport const unmatchedBehaviorSchema = Type.Enum(Object.values(UnmatchedBehavior), {\n title: 'UnmatchedBehavior',\n description: 'What to do with the button when the trigger does not match: hide it or disable it',\n})\nexport type UnmatchedBehavior = Static<typeof unmatchedBehaviorSchema>\n\nexport const IconPosition = {\n LEFT: 'left',\n RIGHT: 'right',\n} as const\nexport const iconPositionSchema = Type.Enum(Object.values(IconPosition), {\n title: 'IconPosition',\n description: 'Side of the label the icon sits on',\n})\nexport type IconPosition = Static<typeof iconPositionSchema>\n\nexport const manualTriggerButtonStyleSchema = Type.Object(\n {\n text: Type.Optional(Type.String({ description: 'Handlebars template rendered as the button label' })),\n textColor: Type.Optional(Type.String({ description: 'Label colour' })),\n bgColor: Type.Optional(Type.String({ description: 'Background colour' })),\n icon: Type.Optional(Type.String({ description: 'Icon name, resolved by the consumer' })),\n iconPosition: Type.Optional(iconPositionSchema),\n },\n { title: 'ManualTriggerButtonStyle', description: 'Presentation of the button a manual trigger is offered on' },\n)\nexport type ManualTriggerButtonStyleData = Static<typeof manualTriggerButtonStyleSchema>\n\n// Same shape as the base style plus the conditions that select it. Every style field is optional:\n// an entry only overrides what it declares.\nexport const manualTriggerConditionalStyleSchema = Type.Intersect(\n [\n manualTriggerButtonStyleSchema,\n Type.Object({\n conditions: Type.Optional(\n Type.Union([Type.Object({}, { additionalProperties: true }), Type.Null()], {\n description: 'jsonLogic conditions selecting this style. Absent or null always applies',\n }),\n ),\n continueEvaluate: Type.Optional(\n Type.Boolean({ description: 'Keep evaluating later entries after this one matches' }),\n ),\n }),\n ],\n { title: 'ManualTriggerConditionalStyle' },\n)\nexport type ManualTriggerConditionalStyleData = Static<typeof manualTriggerConditionalStyleSchema>\n\n/**\n * Envelope for everything a manual trigger configures beyond its firing rules. Today it carries\n * whether an unmatched trigger is hidden or shown disabled, plus the button presentation;\n * `additionalProperties` stays open so a future concern can be added without another column.\n *\n * The two are deliberately separate concerns: `unmatchedBehavior` answers whether the button is\n * offered at all, which only the trigger `conditions` decide, while `styles`/`conditionalStyles`\n * only dress a button that is already going to be shown.\n */\nexport const manualTriggerConfigSchema = Type.Object(\n {\n unmatchedBehavior: Type.Optional(unmatchedBehaviorSchema),\n styles: Type.Optional(manualTriggerButtonStyleSchema),\n conditionalStyles: Type.Optional(Type.Array(manualTriggerConditionalStyleSchema)),\n },\n { title: 'ManualTriggerConfig', additionalProperties: true },\n)\nexport type ManualTriggerConfigData = Static<typeof manualTriggerConfigSchema>\n\nexport const manualTriggerSchema = Type.Object(\n {\n id: Type.Number({ description: 'Unique identifier of the manual trigger' }),\n project_id: Type.Optional(\n Type.Union([Type.Number(), Type.Null()], {\n description: 'Project this trigger belongs to. Null when it is ecosystem-wide',\n }),\n ),\n name: Type.String({ maxLength: 255, description: 'Human-readable label of the trigger where it is offered' }),\n source: triggerSourceSchema,\n target: Type.String({\n maxLength: 255,\n description: 'Concrete model/designer/field the trigger is bound to. Always set: there is no wildcard',\n }),\n conditions: Type.Optional(\n Type.Union([Type.Object({}, { additionalProperties: true }), Type.Null()], {\n description:\n 'jsonLogic conditions (root object) evaluated to decide whether the trigger runs. Evaluated against the selected entity and the request context; `old` is always null, because the trigger is invoked explicitly and there is no previous state to compare against.',\n }),\n ),\n relations: Type.Optional(\n Type.Union([triggerRelationsSchema, Type.Null()], {\n description:\n 'Related models loaded into the context before evaluating the conditions and running the actions. Null means none.',\n }),\n ),\n enabled: Type.Optional(Type.Boolean({ description: 'Whether the trigger is active' })),\n retention_days: Type.Optional(\n Type.Union([Type.Number(), Type.Null()], {\n description:\n 'Retention in days for the process_log entries of this trigger (issue #175). Origin — no inheritance: null or 0 = disabled (never expires); N (>0) = enabled (expires N days after write).',\n }),\n ),\n config: Type.Optional(\n Type.Union([manualTriggerConfigSchema, Type.Null()], {\n description: 'Configuration of the trigger beyond its firing rules. Null means none',\n }),\n ),\n },\n { title: 'ManualTrigger', description: 'Manual trigger definition (ecosystem level)' },\n)\nexport type ManualTriggerData = Static<typeof manualTriggerSchema>\n\n// Written out and closed, for the same reasons as `createAutomaticTriggerSchema` above.\nexport const createManualTriggerSchema = Type.Object(\n {\n name: Type.String({ maxLength: 255, description: 'Human-readable label of the trigger where it is offered' }),\n source: triggerSourceSchema,\n target: Type.String({\n maxLength: 255,\n description: 'Concrete model/designer/field the trigger is bound to. Always set: there is no wildcard',\n }),\n conditions: Type.Optional(\n Type.Union([Type.Object({}, { additionalProperties: true }), Type.Null()], {\n description:\n 'jsonLogic conditions (root object) evaluated to decide whether the trigger runs. Evaluated against the selected entity and the request context; `old` is always null, because the trigger is invoked explicitly and there is no previous state to compare against.',\n }),\n ),\n relations: Type.Optional(\n Type.Union([triggerRelationsSchema, Type.Null()], {\n description:\n 'Related models loaded into the context before evaluating the conditions and running the actions. Null means none.',\n }),\n ),\n enabled: Type.Optional(Type.Boolean({ description: 'Whether the trigger is active' })),\n retention_days: Type.Optional(\n Type.Union([Type.Number(), Type.Null()], {\n description:\n 'Retention in days for the process_log entries of this trigger (issue #175). Origin — no inheritance: null or 0 = disabled (never expires); N (>0) = enabled (expires N days after write).',\n }),\n ),\n config: Type.Optional(\n Type.Union([manualTriggerConfigSchema, Type.Null()], {\n description: 'Configuration of the trigger beyond its firing rules. Null means none',\n }),\n ),\n actions: Type.Optional(triggerActionsInputSchema),\n },\n {\n title: 'CreateManualTrigger',\n description: 'Payload used to create a manual trigger, optionally with the actions it runs',\n additionalProperties: false,\n },\n)\nexport type CreateManualTriggerData = Static<typeof createManualTriggerSchema>\n\n// Same inheritance and semantics as `updateAutomaticTriggerSchema`.\nexport const updateManualTriggerSchema = Type.Partial(createManualTriggerSchema, {\n title: 'UpdateManualTrigger',\n description: 'Payload used to update a manual trigger, optionally replacing the actions it runs',\n additionalProperties: false,\n})\nexport type UpdateManualTriggerData = Static<typeof updateManualTriggerSchema>\n\n// What the listing endpoint returns per applicable manual trigger: enough to\n// render it and nothing more. Only triggers that are going to be shown are\n// listed, so `matched: false` means a button rendered disabled, never a hidden\n// one. `matched` is never an authorisation: running re-evaluates server-side.\nexport const manualTriggerAvailabilitySchema = Type.Object(\n {\n id: Type.Number({ description: 'Identifier of the manual trigger' }),\n name: Type.String({ description: 'Human-readable label of the trigger' }),\n matched: Type.Boolean({\n description:\n 'Whether the trigger conditions hold for this entity right now. A trigger with no conditions always matches. False means the button is shown disabled: triggers configured to hide when unmatched are not listed',\n }),\n actionsCount: Type.Number({ description: 'Number of actions the trigger would run' }),\n relationsSkipped: Type.Optional(\n Type.Union([Type.String(), Type.Null()], {\n description:\n 'Reason the declared relations could not be loaded before evaluating, when that happened. Null otherwise',\n }),\n ),\n /**\n * Resolved server-side: conditional styles already evaluated and label already compiled. Absent\n * when the trigger has no config — the consumer then paints its own default button.\n */\n style: Type.Optional(manualTriggerButtonStyleSchema),\n },\n {\n title: 'ManualTriggerAvailability',\n description: 'A manual trigger applicable to an entity, with its conditions already evaluated',\n },\n)\nexport type ManualTriggerAvailability = Static<typeof manualTriggerAvailabilitySchema>\n\nexport const manualTriggerAvailabilityListSchema = Type.Object(\n { results: Type.Array(manualTriggerAvailabilitySchema, { description: 'Applicable manual triggers' }) },\n {\n title: 'ManualTriggerAvailabilityList',\n description: 'Manual triggers applicable to an entity, with their conditions evaluated',\n },\n)\n\n// Query the listing endpoint is called with: the entity the triggers are offered\n// on. `source`/`target` are the coordinates a manual trigger is bound to, and\n// `entityId` the concrete row.\nexport const manualTriggerAvailabilityQuerySchema = Type.Object(\n {\n source: triggerSourceSchema,\n target: Type.String({ maxLength: 255, description: 'Concrete model/designer/field the triggers are bound to' }),\n entityId: Type.Number({ description: 'Identifier of the entity the triggers would run against' }),\n },\n { title: 'ManualTriggerAvailabilityQuery', description: 'Entity the applicable manual triggers are listed for' },\n)\nexport type ManualTriggerAvailabilityQuery = Static<typeof manualTriggerAvailabilityQuerySchema>\n\n// Body of the run endpoint. It carries only the entity: `source`/`target` are\n// read from the trigger row, never from the client, so a trigger cannot be\n// re-pointed at an entity it was not bound to.\nexport const runManualTriggerSchema = Type.Object(\n { entityId: Type.Number({ description: 'Identifier of the entity to run the trigger against' }) },\n { title: 'RunManualTrigger', description: 'Payload used to run a manual trigger against an entity' },\n)\nexport type RunManualTriggerData = Static<typeof runManualTriggerSchema>\n\n// ── automatic_trigger_action (intermediate N:M automatic_trigger↔actions,\n// ordered) ──────────────────────────────────────────────────────────────\n// Dedicated table per trigger kind (no ORM polymorphism): `automatic_trigger_id`\n// is a real FK. `manual_trigger_action` is a future table for manual triggers.\n\nexport const automaticTriggerActionSchema = Type.Object(\n {\n id: Type.Number({ description: 'Unique identifier of the trigger-action link' }),\n automatic_trigger_id: Type.Number({\n description: 'Automatic trigger executing the action (FK to automatic_trigger)',\n }),\n action_id: Type.Number({ description: 'Action executed by the trigger (FK to actions)' }),\n execution_order: Type.Number({ description: 'Execution order of the action within the trigger' }),\n },\n { title: 'AutomaticTriggerAction', description: 'Ordered link between an automatic trigger and an action' },\n)\nexport type AutomaticTriggerActionData = Static<typeof automaticTriggerActionSchema>\n\n// The `create*`/`update*` pair below is not an endpoint contract: the links are\n// written through the `actions` field of the trigger create/update payloads.\n// They remain because `action-system.model.ts` builds the Objection\n// `jsonSchema` of the link models out of their union.\nexport const createAutomaticTriggerActionSchema = Type.Omit(automaticTriggerActionSchema, ['id'], {\n title: 'CreateAutomaticTriggerAction',\n description: 'Row shape of an automatic trigger-action link',\n})\nexport type CreateAutomaticTriggerActionData = Static<typeof createAutomaticTriggerActionSchema>\n\nexport const updateAutomaticTriggerActionSchema = Type.Partial(createAutomaticTriggerActionSchema, {\n title: 'UpdateAutomaticTriggerAction',\n description: 'Partial row shape of an automatic trigger-action link',\n})\nexport type UpdateAutomaticTriggerActionData = Static<typeof updateAutomaticTriggerActionSchema>\n\n// ── manual_trigger_action (intermediate N:M manual_trigger↔actions,\n// ordered) ──────────────────────────────────────────────────────────────\n// Same dedicated-table-per-trigger-kind rule as `automatic_trigger_action`:\n// `manual_trigger_id` is a real FK, and the `actions` catalog is shared\n// between kinds — only the link table differs.\n\nexport const manualTriggerActionSchema = Type.Object(\n {\n id: Type.Number({ description: 'Unique identifier of the trigger-action link' }),\n manual_trigger_id: Type.Number({\n description: 'Manual trigger executing the action (FK to manual_trigger)',\n }),\n action_id: Type.Number({ description: 'Action executed by the trigger (FK to actions)' }),\n execution_order: Type.Number({ description: 'Execution order of the action within the trigger' }),\n },\n { title: 'ManualTriggerAction', description: 'Ordered link between a manual trigger and an action' },\n)\nexport type ManualTriggerActionData = Static<typeof manualTriggerActionSchema>\n\n// Same as the automatic pair above: kept for the model `jsonSchema`, not as an\n// endpoint contract.\nexport const createManualTriggerActionSchema = Type.Omit(manualTriggerActionSchema, ['id'], {\n title: 'CreateManualTriggerAction',\n description: 'Row shape of a manual trigger-action link',\n})\nexport type CreateManualTriggerActionData = Static<typeof createManualTriggerActionSchema>\n\nexport const updateManualTriggerActionSchema = Type.Partial(createManualTriggerActionSchema, {\n title: 'UpdateManualTriggerAction',\n description: 'Partial row shape of a manual trigger-action link',\n})\nexport type UpdateManualTriggerActionData = Static<typeof updateManualTriggerActionSchema>\n\n// ── Declarative trigger↔actions contract ──────────────────────────────\n// The link tables are written as a whole through the `actions` field of the trigger payload,\n// never row by row. The array position IS the `execution_order`, so ordering can\n// never disagree with the list the client sent — which per-row endpoints allowed\n// (duplicate or gapped orders after a reorder). Shared by both trigger kinds:\n// only the parent FK differs, and that comes from the URL.\n//\n// The field is `actions`, not `action_ids`: items are no longer only ids (see\n// `triggerActionInputSchema`). Same body as the `actions` field of the create and\n// update trigger payloads, so the three ways of writing the set agree.\n\n// What create/update answer with. `actions` carries the resolved catalog rows —\n// not the link rows — so a client that sent actions inline learns the ids they\n// were given without chaining a second request. It is present only when the\n// request carried the field: a create/update that did not mention actions says\n// nothing about them, rather than reporting an empty set it never touched.\nconst withResolvedActions = Type.Object({\n actions: Type.Optional(Type.Array(actionSchema, { description: 'Actions the trigger runs, in execution order' })),\n})\n\nexport const automaticTriggerWithActionsSchema = Type.Intersect([automaticTriggerSchema, withResolvedActions], {\n title: 'AutomaticTriggerWithActions',\n description:\n 'An automatic trigger and, when the request wrote them or `includeActions` asked for them, the actions it runs',\n})\nexport type AutomaticTriggerWithActionsData = Static<typeof automaticTriggerWithActionsSchema>\n\nexport const manualTriggerWithActionsSchema = Type.Intersect([manualTriggerSchema, withResolvedActions], {\n title: 'ManualTriggerWithActions',\n description:\n 'A manual trigger and, when the request wrote them or `includeActions` asked for them, the actions it runs',\n})\nexport type ManualTriggerWithActionsData = Static<typeof manualTriggerWithActionsSchema>\n\n// ── Execution engine (pure, model-independent contract types) ──────────\n// Exported types the engine (service/helper) works with. Kept here (rather\n// than in service/helper) so they can be imported without pulling in\n// service/helper code. None of them references a model: the engine types\n// itself structurally (see the `*Like` shapes below).\n\nexport interface ActionEvent {\n source: TriggerSource\n target?: string | null\n operation?: TriggerOperation | null\n current: Record<string, unknown>\n old?: Record<string, unknown> | null\n}\n\n// Outcome of evaluating (and, when matched, running) a single trigger. Declared\n// as a TypeBox schema — not just an interface — because the manual-trigger run\n// endpoint returns it verbatim; `TriggerExecutionResult` is its static type, so\n// engine and endpoint cannot drift apart.\nexport const triggerExecutionResultSchema = Type.Object(\n {\n triggerId: Type.Number({ description: 'Identifier of the evaluated trigger' }),\n matched: Type.Boolean({ description: 'Whether the conditions held, so the actions were run' }),\n actionsRun: Type.Number({ description: 'Number of actions that were executed' }),\n actionsAborted: Type.Number({ description: 'Number of actions aborted by context validation' }),\n },\n { title: 'TriggerExecutionResult', description: 'Outcome of evaluating and running one trigger' },\n)\nexport type TriggerExecutionResult = Static<typeof triggerExecutionResultSchema>\n\n// ── Trigger-kind-agnostic engine contract ─────────────────────────────\n// The execution engine is shared by every kind of trigger: it consumes the\n// minimal structural shapes below rather than a concrete model, so a new kind\n// only has to resolve its own candidates and hand them over. The `*Like` types\n// are deliberately structural (not the Objection classes) so the engine never\n// imports a model to type itself — `AutomaticTrigger` / `AutomaticTriggerAction`\n// / `Action` satisfy them as they are, without a cast.\n\n/**\n * Structural shape the engine needs from an action it is about to run: the\n * identity it logs, the `type` that selects the validation/dispatch branch, the\n * config it executes with, and the retention it resolves `expires_at` from.\n * Deliberately loose (`type: string`, not `ActionType`) so an unknown type still\n * reaches the always-blocking context validation instead of failing to typecheck.\n */\nexport interface ActionLike {\n id: number\n type: string\n config: ActionConfig\n retention_days?: number | null\n}\n\n/** Ordered trigger↔action link in the minimal shape the engine consumes. */\nexport interface TriggerActionLike {\n action_id: number\n execution_order: number\n action?: ActionLike\n}\n\n/** Minimal shape of a trigger for the engine, whatever its kind. */\nexport interface EvaluableTrigger {\n id: number\n conditions?: object | null\n relations?: TriggerRelations | null\n retention_days?: number | null\n trigger_actions?: TriggerActionLike[]\n}\n\n/**\n * A batch of already-resolved candidates a trigger kind hands to the engine,\n * together with the event data they were resolved for. `relatedModel` is what\n * the evaluation `process_log` row is related to (the trigger table of that\n * kind), which is how trigger evaluations stay independently queryable per kind.\n */\nexport interface TriggerBatch<T extends EvaluableTrigger = EvaluableTrigger> {\n triggers: T[]\n relatedModel: string\n source: TriggerSource\n target?: string | null\n operation?: TriggerOperation | null\n current: Record<string, unknown>\n old?: Record<string, unknown> | null\n}\n\n// ── Context validation (pure data types) ────────────────────────────────\n\nexport interface ContextValidationResult {\n ok: boolean\n type: string\n baseErrors: { path: string; message: string }[]\n missingRefs: string[]\n referencedRefs: string[]\n overridableErrors: string[]\n}\n\n// Structural shape `buildEffectiveConfig`/`validateActionContext` need from an\n// action config — deliberately loose (not `ActionConfig`) so it works for any\n// current or future type without a cast at every call site.\nexport interface ActionConfigLike {\n payload?: Record<string, unknown>\n overridable?: string[]\n default?: Record<string, unknown>\n}\n\nexport interface EffectiveConfigResult {\n effective: Record<string, unknown>\n overridableErrors: string[]\n}\n\n// ── Route-level schemas ───────────────────────────────────────────────\n// Shared by every router of the module.\n\nexport const successResponseSchema = Type.Object(\n { success: Type.Boolean({ description: 'If the request success or not' }) },\n { title: 'ActionSystemSuccessResponse', description: 'Response when the request is successful' },\n)\n\nexport const withIdParamsSchema = Type.Intersect(\n [ecosystemProjectParamsSchema, Type.Object({ id: Type.Number({ description: 'Entity ID' }) })],\n { title: 'EcosystemProjectWithActionSystemIdParams', description: 'Params with ecosystem, project and entity ID' },\n)\n"],"names":[],"mappings":";AAEO,MAAM,wB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