@epilot/entity-mapping-client 0.10.4 → 0.12.0

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.
package/dist/openapi.json CHANGED
@@ -122,6 +122,9 @@
122
122
  }
123
123
  }
124
124
  }
125
+ },
126
+ "429": {
127
+ "description": "Storage stayed throttled, nothing is lost. Repeat the request after `Retry-After` seconds."
125
128
  }
126
129
  }
127
130
  }
@@ -289,101 +292,168 @@
289
292
  }
290
293
  }
291
294
  },
292
- "/v1/mappings:search": {
295
+ "/v1/mappings:validate": {
293
296
  "post": {
294
- "operationId": "searchConfigs",
295
- "summary": "searchConfigs",
296
- "description": "Search mapping configs",
297
+ "operationId": "validateMapping",
298
+ "x-epilot-permissions": [
299
+ {
300
+ "access": "org"
301
+ }
302
+ ],
303
+ "x-epilot-agent": {
304
+ "effect": "read"
305
+ },
306
+ "summary": "validateMapping",
307
+ "description": "Analyse a stored map-entity action config (engine JSON) line by line: a verdict per line (form, json, broken), issues on the engine line they belong to, suggested rewrites and a sentence each. `valid` is false when an issue is an error; a save gate rejects the config then. Never persists anything. The smallest request is `{ config, source: { journey_id } }`. Send `source` (the trigger's journey or entity schema) instead of `roots.source`, and leave out `target_root` when `config.target_schema` is set: the server loads those descriptions with the caller's authorization. The response is about 1.1 KB per line: from about 5000 lines in one request it exceeds the inline limit (413, see there).",
297
308
  "tags": [
298
309
  "mappings"
299
310
  ],
300
311
  "requestBody": {
301
- "description": "Search Mapping Configs",
312
+ "required": true,
302
313
  "content": {
303
314
  "application/json": {
304
315
  "schema": {
305
- "$ref": "#/components/schemas/SearchMappingReq"
316
+ "$ref": "#/components/schemas/ValidateMappingReq"
306
317
  }
307
318
  }
308
319
  }
309
320
  },
310
321
  "responses": {
311
322
  "200": {
312
- "description": "Entity Mapping Config",
323
+ "description": "The analysis",
313
324
  "content": {
314
325
  "application/json": {
315
326
  "schema": {
316
- "$ref": "#/components/schemas/MappingConfig"
327
+ "$ref": "#/components/schemas/MappingAnalysis"
317
328
  }
318
329
  }
319
330
  }
331
+ },
332
+ "400": {
333
+ "description": "The request body is malformed: missing fields, a `roots` or `target_root` of the wrong shape, a mapping line without a text `target`, a line or relation target that names `__proto__`, `constructor` or `prototype`, or a config the validator cannot read (for example nested too deeply). Malformed operations and relations are not a 400: they come back as issues. Caller input never yields a 500.",
334
+ "content": {
335
+ "application/json": {
336
+ "schema": {
337
+ "type": "object",
338
+ "properties": {
339
+ "messages": {
340
+ "type": "array",
341
+ "items": {
342
+ "type": "string"
343
+ }
344
+ }
345
+ }
346
+ }
347
+ }
348
+ }
349
+ },
350
+ "401": {
351
+ "$ref": "#/components/responses/MappingCheckUnauthorized"
352
+ },
353
+ "403": {
354
+ "$ref": "#/components/responses/MappingCheckForbidden"
355
+ },
356
+ "413": {
357
+ "$ref": "#/components/responses/MappingCheckTooLarge"
320
358
  }
321
359
  }
322
360
  }
323
361
  },
324
- "/v1/mappings/history": {
325
- "get": {
326
- "operationId": "queryMappingHistory",
327
- "summary": "queryMappingHistory",
328
- "description": "Get the Mapping History",
362
+ "/v1/mappings:validate-flow": {
363
+ "post": {
364
+ "operationId": "validateMappingFlow",
365
+ "x-epilot-permissions": [
366
+ {
367
+ "access": "org"
368
+ }
369
+ ],
370
+ "x-epilot-agent": {
371
+ "effect": "read"
372
+ },
373
+ "summary": "validateMappingFlow",
374
+ "description": "Analyse every mapping action (`map-entity`, `cart-checkout`) of an automation, each in its place: against the trigger's source, the entities the earlier actions create and its target schema. The source and every target schema are loaded by id with the caller's authorization. `blocking` lists what a save gate rejects: errors, issues on broken lines and values that are not an option of their attribute. With `previous_actions` (the automation as stored) only issues this change introduced block. Never persists anything. Responses above the inline limit are a 413 (see there).",
329
375
  "tags": [
330
376
  "mappings"
331
377
  ],
332
- "parameters": [
333
- {
334
- "in": "query",
335
- "name": "from",
336
- "schema": {
337
- "type": "string",
338
- "format": "datetime"
339
- },
340
- "required": false,
341
- "description": "filter the history from this date on"
342
- },
343
- {
344
- "in": "query",
345
- "name": "to",
346
- "schema": {
347
- "type": "string",
348
- "format": "datetime"
349
- },
350
- "required": false,
351
- "description": "filter the history to this date on"
352
- },
353
- {
354
- "in": "query",
355
- "name": "targetEntityId",
356
- "schema": {
357
- "type": "string",
358
- "format": "uuid"
359
- }
360
- },
361
- {
362
- "in": "query",
363
- "name": "sourceEntityId",
364
- "schema": {
365
- "type": "string",
366
- "format": "uuid"
378
+ "requestBody": {
379
+ "required": true,
380
+ "content": {
381
+ "application/json": {
382
+ "schema": {
383
+ "$ref": "#/components/schemas/ValidateMappingFlowReq"
384
+ }
367
385
  }
368
386
  }
369
- ],
387
+ },
370
388
  "responses": {
371
389
  "200": {
372
- "description": "Query result of mapping history",
390
+ "description": "The analyses and what blocks a save",
391
+ "content": {
392
+ "application/json": {
393
+ "schema": {
394
+ "$ref": "#/components/schemas/ValidateMappingFlowResp"
395
+ }
396
+ }
397
+ }
398
+ },
399
+ "400": {
400
+ "description": "The request body is malformed: no `actions`, duplicate action ids, a `source` of the wrong shape, a mapping line without a text `target` or one naming `__proto__`, `constructor` or `prototype`, or a config the validator cannot read. Caller input never yields a 500.",
373
401
  "content": {
374
402
  "application/json": {
375
403
  "schema": {
404
+ "type": "object",
376
405
  "properties": {
377
- "results": {
406
+ "messages": {
378
407
  "type": "array",
379
408
  "items": {
380
- "$ref": "#/components/schemas/MappingHistoryResp"
409
+ "type": "string"
381
410
  }
382
411
  }
383
412
  }
384
413
  }
385
414
  }
386
415
  }
416
+ },
417
+ "401": {
418
+ "$ref": "#/components/responses/MappingCheckUnauthorized"
419
+ },
420
+ "403": {
421
+ "$ref": "#/components/responses/MappingCheckForbidden"
422
+ },
423
+ "413": {
424
+ "$ref": "#/components/responses/MappingCheckTooLarge"
425
+ }
426
+ }
427
+ }
428
+ },
429
+ "/v1/mappings:search": {
430
+ "post": {
431
+ "operationId": "searchConfigs",
432
+ "summary": "searchConfigs",
433
+ "description": "Search mapping configs",
434
+ "tags": [
435
+ "mappings"
436
+ ],
437
+ "requestBody": {
438
+ "description": "Search Mapping Configs",
439
+ "content": {
440
+ "application/json": {
441
+ "schema": {
442
+ "$ref": "#/components/schemas/SearchMappingReq"
443
+ }
444
+ }
445
+ }
446
+ },
447
+ "responses": {
448
+ "200": {
449
+ "description": "Entity Mapping Config",
450
+ "content": {
451
+ "application/json": {
452
+ "schema": {
453
+ "$ref": "#/components/schemas/MappingConfigsResp"
454
+ }
455
+ }
456
+ }
387
457
  }
388
458
  }
389
459
  }
@@ -455,7 +525,7 @@
455
525
  "put": {
456
526
  "operationId": "putMappingConfig",
457
527
  "summary": "putMappingConfig",
458
- "description": "Stores new version of entity mapping config",
528
+ "description": "Stores new version of entity mapping config. The targets are not checked on store: check them first with `POST /v1/mappings:validate-flow` (`{ source: { journey_id }, actions: [{ id, type: map-entity, config: <target> }] }`, one action per target) and fix every `blocking` issue.",
459
529
  "tags": [
460
530
  "mappings"
461
531
  ],
@@ -489,22 +559,633 @@
489
559
  "schema": {
490
560
  "$ref": "#/components/schemas/MappingConfigV2"
491
561
  }
492
- }
562
+ }
563
+ }
564
+ }
565
+ }
566
+ }
567
+ }
568
+ },
569
+ "components": {
570
+ "responses": {
571
+ "MappingCheckUnauthorized": {
572
+ "description": "No `Authorization` header. Sent by the API Gateway authorizer.",
573
+ "content": {
574
+ "application/json": {
575
+ "schema": {
576
+ "type": "object",
577
+ "properties": {
578
+ "message": {
579
+ "type": "string",
580
+ "example": "Unauthorized"
581
+ }
582
+ }
583
+ }
584
+ }
585
+ }
586
+ },
587
+ "MappingCheckForbidden": {
588
+ "description": "The token is not valid (unsigned, expired, malformed, or sent without the `Bearer ` prefix). Sent by the API Gateway authorizer.",
589
+ "content": {
590
+ "application/json": {
591
+ "schema": {
592
+ "type": "object",
593
+ "properties": {
594
+ "message": {
595
+ "type": "string",
596
+ "example": "Forbidden"
597
+ }
598
+ }
599
+ }
600
+ }
601
+ }
602
+ },
603
+ "MappingCheckTooLarge": {
604
+ "description": "The request or the response is too large. Requests above 6 MB are rejected by the gateway. A response of more than about 5.4 MB is not sent inline: the analysis returns about 1.1 KB per line, so this happens from about 5000 lines in one config. Send `Accept: application/large-response.vnd+json` to get a `$payload_ref` URL to the full response instead, or validate fewer lines per request.",
605
+ "content": {
606
+ "application/json": {
607
+ "schema": {
608
+ "type": "object",
609
+ "properties": {
610
+ "message": {
611
+ "type": "string"
612
+ }
613
+ }
614
+ }
615
+ }
616
+ }
617
+ }
618
+ },
619
+ "securitySchemes": {
620
+ "EpilotAuth": {
621
+ "type": "http",
622
+ "scheme": "bearer",
623
+ "description": "Epilot Bearer Token"
624
+ }
625
+ },
626
+ "schemas": {
627
+ "MappingCheckContext": {
628
+ "type": "object",
629
+ "description": "Where the action sits in its automation or flow",
630
+ "required": [
631
+ "sourceSchema",
632
+ "taskOrder",
633
+ "taskSchemas",
634
+ "producersBySchema"
635
+ ],
636
+ "properties": {
637
+ "sourceSchema": {
638
+ "type": "string",
639
+ "description": "Root of the source entity, `submission` for journeys, the trigger schema otherwise"
640
+ },
641
+ "taskOrder": {
642
+ "type": "array",
643
+ "items": {
644
+ "type": "string"
645
+ },
646
+ "description": "Every action id of the automation in execution order, the ones after the current action included. An action left out is reported as missing (`task-missing`); with validator 0.4.4, an action listed in `taskSchemas` but not here counts as a later one (`task-not-earlier`)."
647
+ },
648
+ "current": {
649
+ "type": "string",
650
+ "description": "The action being analysed; must be one of `taskOrder`. Defaults to the last id in `taskOrder`. References to `current` itself or to an action after it are reported as `task-not-earlier`."
651
+ },
652
+ "taskSchemas": {
653
+ "type": "object",
654
+ "additionalProperties": {
655
+ "type": "string"
656
+ }
657
+ },
658
+ "producersBySchema": {
659
+ "type": "object",
660
+ "description": "Earlier action ids per schema they create, in execution order",
661
+ "additionalProperties": {
662
+ "type": "array",
663
+ "items": {
664
+ "type": "string"
665
+ }
666
+ }
667
+ },
668
+ "linkbackTags": {
669
+ "type": "array",
670
+ "items": {
671
+ "type": "string"
672
+ }
673
+ },
674
+ "linkbackTagsByTask": {
675
+ "type": "object",
676
+ "additionalProperties": {
677
+ "type": "array",
678
+ "items": {
679
+ "type": "string"
680
+ }
681
+ }
682
+ },
683
+ "configIdsByTask": {
684
+ "type": "object",
685
+ "additionalProperties": {
686
+ "type": "string"
687
+ }
688
+ }
689
+ }
690
+ },
691
+ "MappingIssue": {
692
+ "type": "object",
693
+ "required": [
694
+ "code",
695
+ "severity",
696
+ "path",
697
+ "key",
698
+ "message"
699
+ ],
700
+ "properties": {
701
+ "code": {
702
+ "type": "string",
703
+ "example": "ambiguous-producer"
704
+ },
705
+ "severity": {
706
+ "type": "string",
707
+ "enum": [
708
+ "error",
709
+ "warning"
710
+ ]
711
+ },
712
+ "path": {
713
+ "type": "string",
714
+ "description": "JSON pointer into the config, e.g. `/mapping_attributes/3`; empty for the whole action"
715
+ },
716
+ "key": {
717
+ "type": "string",
718
+ "description": "Translation key"
719
+ },
720
+ "message": {
721
+ "type": "string"
722
+ },
723
+ "params": {
724
+ "type": "object",
725
+ "additionalProperties": {
726
+ "type": "string"
727
+ }
728
+ }
729
+ }
730
+ },
731
+ "MappingAnalysis": {
732
+ "type": "object",
733
+ "required": [
734
+ "valid",
735
+ "lines",
736
+ "issues",
737
+ "counts",
738
+ "skipped_checks"
739
+ ],
740
+ "properties": {
741
+ "valid": {
742
+ "type": "boolean",
743
+ "description": "False when an issue is an error. Only covers the checks that ran: see `skipped_checks`."
744
+ },
745
+ "skipped_checks": {
746
+ "type": "array",
747
+ "description": "Checks that did not run because the request lacks the description they need; `[]` when every check ran. `blocks`: no `roots.source`, so journey blocks and source paths are not checked (`block-removed`, `path-not-in-root`). `attributes`: no `target_root`, so target attributes are not checked (`attribute-not-on-target`). `types`: no `target_root`, so no value is checked against the attribute it fills (`type-mismatch`, `type-converts`, `value-type-mismatch`, `value-not-an-option`). `source-types`: a `target_root` but no `roots.source`, so values copied from the source are not type-checked; fixed values, texts and copies from actions with a `roots.tasks[].description` still are. A description the server loaded (`source`, `config.target_schema`) counts as sent. A `valid: true` with skipped checks does not vouch for those.",
748
+ "items": {
749
+ "type": "string",
750
+ "enum": [
751
+ "attributes",
752
+ "blocks",
753
+ "types",
754
+ "source-types"
755
+ ]
756
+ }
757
+ },
758
+ "counts": {
759
+ "type": "object",
760
+ "properties": {
761
+ "form": {
762
+ "type": "integer"
763
+ },
764
+ "json": {
765
+ "type": "integer"
766
+ },
767
+ "broken": {
768
+ "type": "integer"
769
+ }
770
+ }
771
+ },
772
+ "issues": {
773
+ "type": "array",
774
+ "items": {
775
+ "$ref": "#/components/schemas/MappingIssue"
776
+ }
777
+ },
778
+ "lines": {
779
+ "type": "array",
780
+ "items": {
781
+ "type": "object",
782
+ "properties": {
783
+ "kind": {
784
+ "type": "string",
785
+ "enum": [
786
+ "identity",
787
+ "field",
788
+ "relation"
789
+ ]
790
+ },
791
+ "index": {
792
+ "type": "integer"
793
+ },
794
+ "target": {
795
+ "type": "string"
796
+ },
797
+ "verdict": {
798
+ "type": "string",
799
+ "enum": [
800
+ "form",
801
+ "json",
802
+ "broken"
803
+ ]
804
+ },
805
+ "reason": {
806
+ "type": "string",
807
+ "description": "Why the line has no form, e.g. `op:_each`"
808
+ },
809
+ "issues": {
810
+ "type": "array",
811
+ "items": {
812
+ "$ref": "#/components/schemas/MappingIssue"
813
+ }
814
+ },
815
+ "suggestions": {
816
+ "type": "array",
817
+ "items": {
818
+ "type": "object",
819
+ "properties": {
820
+ "why": {
821
+ "type": "string",
822
+ "description": "What the rewrite does. `template-syntax`, `nearest-attribute`, `nearest-option` and `operation-key` come with validator 0.4.4. `fallback-producers` (validator 0.6.0): every creator of the schema runs behind a condition, so the line copies from all of them in order. Applying any suggestion adds no error to its line.",
823
+ "enum": [
824
+ "pick-producer",
825
+ "fallback-producers",
826
+ "explicit-output",
827
+ "add-mode",
828
+ "merge-keys",
829
+ "template-syntax",
830
+ "nearest-attribute",
831
+ "nearest-option",
832
+ "operation-key"
833
+ ]
834
+ },
835
+ "task": {
836
+ "type": "string"
837
+ },
838
+ "line": {
839
+ "type": "object",
840
+ "additionalProperties": true
841
+ }
842
+ }
843
+ }
844
+ },
845
+ "description": {
846
+ "type": "string"
847
+ }
848
+ }
849
+ }
850
+ }
851
+ }
852
+ },
853
+ "ValidateMappingReq": {
854
+ "type": "object",
855
+ "required": [
856
+ "config"
857
+ ],
858
+ "properties": {
859
+ "config": {
860
+ "type": "object",
861
+ "description": "The stored map-entity action config",
862
+ "additionalProperties": true
863
+ },
864
+ "context": {
865
+ "allOf": [
866
+ {
867
+ "$ref": "#/components/schemas/MappingCheckContext"
868
+ }
869
+ ],
870
+ "description": "Where the action sits in its automation or flow. Optional: without it the config is checked as the only action of its flow, reading the journey submission (or `source.entity_schema`) and writing `config.target_schema`. Send it only to check references to other actions of the same automation."
871
+ },
872
+ "roots": {
873
+ "$ref": "#/components/schemas/MappingRoots"
874
+ },
875
+ "target_root": {
876
+ "allOf": [
877
+ {
878
+ "$ref": "#/components/schemas/MappingRootDescription"
879
+ }
880
+ ],
881
+ "description": "Optional description of the target entity's attributes, as built by `rootFromEntitySchema` of `@epilot/entity-mapping-validator`. Each field carries its attribute `type`; with it the validator checks that a source fits the attribute it is mapped to (`type-mismatch`, `type-converts`) and that `_uniq` matches the shared merge keys (`merge-keys-differ`). When left out and `config.target_schema` is set, the server loads that schema."
882
+ },
883
+ "source": {
884
+ "$ref": "#/components/schemas/MappingSourceRef"
885
+ }
886
+ }
887
+ },
888
+ "MappingSourceRef": {
889
+ "description": "What the automation's trigger provides, by id. Used when `roots.source` is not sent: the server loads the journey's mapping sources (`rootFromMappingSources`) or the entity schema (`rootFromEntitySchema`) with the caller's authorization. A journey or schema that does not exist is an error issue (`source-journey-not-found`, `source-schema-not-found`); one that could not be loaded is a warning (`source-not-loaded`) and the source checks are skipped (`skipped_checks`). Likewise for a target schema (`target-schema-not-found`, `target-schema-not-loaded`). `automation_step` (the trigger of a workflow's automation task) names no data: a warning (`source-not-fixed`) and the source checks are skipped; pass what the workflow was started with instead.",
890
+ "oneOf": [
891
+ {
892
+ "type": "object",
893
+ "required": [
894
+ "journey_id"
895
+ ],
896
+ "properties": {
897
+ "journey_id": {
898
+ "type": "string",
899
+ "description": "The triggering journey; its source root is `submission`"
900
+ }
901
+ }
902
+ },
903
+ {
904
+ "type": "object",
905
+ "required": [
906
+ "entity_schema"
907
+ ],
908
+ "properties": {
909
+ "entity_schema": {
910
+ "type": "string",
911
+ "description": "The slug of the triggering entity's schema, e.g. `contact`"
912
+ }
913
+ }
914
+ }
915
+ ]
916
+ },
917
+ "MappingFlowAction": {
918
+ "type": "object",
919
+ "description": "An action of an automation (as stored in it), in execution order; only mapping actions are analysed",
920
+ "required": [
921
+ "id"
922
+ ],
923
+ "additionalProperties": true,
924
+ "properties": {
925
+ "id": {
926
+ "type": "string"
927
+ },
928
+ "type": {
929
+ "type": "string",
930
+ "description": "`map-entity` and `cart-checkout` are analysed; other actions only count for what they create",
931
+ "example": "map-entity"
932
+ },
933
+ "config": {
934
+ "type": "object",
935
+ "nullable": true,
936
+ "description": "The stored action config (engine JSON); `target_schema` names the schema it writes",
937
+ "additionalProperties": true
938
+ }
939
+ }
940
+ },
941
+ "ValidateMappingFlowReq": {
942
+ "type": "object",
943
+ "required": [
944
+ "actions"
945
+ ],
946
+ "properties": {
947
+ "actions": {
948
+ "type": "array",
949
+ "description": "Every action of the automation in execution order; ids are unique",
950
+ "items": {
951
+ "$ref": "#/components/schemas/MappingFlowAction"
952
+ }
953
+ },
954
+ "source": {
955
+ "$ref": "#/components/schemas/MappingSourceRef"
956
+ },
957
+ "previous_actions": {
958
+ "type": "array",
959
+ "description": "The automation's actions as stored. With them, only issues this change introduced block (`blocking`), matched by action id, target attribute and code.",
960
+ "items": {
961
+ "$ref": "#/components/schemas/MappingFlowAction"
962
+ }
963
+ },
964
+ "acknowledged": {
965
+ "type": "array",
966
+ "maxItems": 200,
967
+ "description": "Blocking findings the user decided to keep, after the agent explained them: they stop blocking and are listed in `acknowledged` of the response instead. Send only what the user explicitly accepted. Each matches by action id and code, and by the line's target attribute when `target` is set (without it, every finding of that code in the action).",
968
+ "items": {
969
+ "type": "object",
970
+ "required": [
971
+ "action_id",
972
+ "code"
973
+ ],
974
+ "properties": {
975
+ "action_id": {
976
+ "type": "string"
977
+ },
978
+ "code": {
979
+ "type": "string",
980
+ "example": "attribute-not-on-target"
981
+ },
982
+ "target": {
983
+ "type": "string",
984
+ "description": "The target attribute of the line the finding is about"
985
+ }
986
+ }
987
+ }
988
+ }
989
+ }
990
+ },
991
+ "FlowMappingIssue": {
992
+ "allOf": [
993
+ {
994
+ "$ref": "#/components/schemas/MappingIssue"
995
+ },
996
+ {
997
+ "type": "object",
998
+ "required": [
999
+ "action_id"
1000
+ ],
1001
+ "properties": {
1002
+ "action_id": {
1003
+ "type": "string"
1004
+ }
1005
+ }
1006
+ }
1007
+ ]
1008
+ },
1009
+ "ValidateMappingFlowResp": {
1010
+ "type": "object",
1011
+ "required": [
1012
+ "valid",
1013
+ "blocking",
1014
+ "analyses"
1015
+ ],
1016
+ "properties": {
1017
+ "valid": {
1018
+ "type": "boolean",
1019
+ "description": "True when nothing blocks a save (`blocking` is empty)"
1020
+ },
1021
+ "blocking": {
1022
+ "type": "array",
1023
+ "description": "What a save gate rejects: per action the errors, the issues on lines whose verdict is `broken` and `value-not-an-option`; with `previous_actions`, only those this change introduced",
1024
+ "items": {
1025
+ "$ref": "#/components/schemas/FlowMappingIssue"
1026
+ }
1027
+ },
1028
+ "generated": {
1029
+ "type": "array",
1030
+ "description": "Findings on lines the Journey Builder generated for a journey's default mapping (`origin` `system_recommendation` or `entity_updating_system_recommendation`). The builder regenerates those lines, so these findings are reported but never block.",
1031
+ "items": {
1032
+ "$ref": "#/components/schemas/FlowMappingIssue"
1033
+ }
1034
+ },
1035
+ "references": {
1036
+ "type": "object",
1037
+ "description": "Actions that only point at a target of a mapping config (`config.mapping_config`) are checked as that target. `unresolved` lists the actions whose config or target could not be found in the organization; they are left out of the check.",
1038
+ "properties": {
1039
+ "resolved": {
1040
+ "type": "array",
1041
+ "items": {
1042
+ "type": "string"
1043
+ }
1044
+ },
1045
+ "unresolved": {
1046
+ "type": "array",
1047
+ "items": {
1048
+ "type": "string"
1049
+ }
1050
+ }
1051
+ }
1052
+ },
1053
+ "acknowledged": {
1054
+ "type": "array",
1055
+ "description": "Only with `acknowledged` in the request; the blocking findings it matched, which did not block",
1056
+ "items": {
1057
+ "$ref": "#/components/schemas/FlowMappingIssue"
1058
+ }
1059
+ },
1060
+ "introduced": {
1061
+ "type": "array",
1062
+ "description": "Only with `previous_actions`; every issue (errors and warnings) this change introduced",
1063
+ "items": {
1064
+ "$ref": "#/components/schemas/FlowMappingIssue"
1065
+ }
1066
+ },
1067
+ "analyses": {
1068
+ "type": "object",
1069
+ "description": "The analysis of each mapping action, by action id; other actions have no entry",
1070
+ "additionalProperties": {
1071
+ "$ref": "#/components/schemas/MappingAnalysis"
1072
+ }
1073
+ }
1074
+ }
1075
+ },
1076
+ "MappingRoots": {
1077
+ "type": "object",
1078
+ "description": "Optional descriptions of the source and of each action's output (`Roots` of `@epilot/entity-mapping-validator`). A body whose `roots` does not have this shape is rejected with 400.",
1079
+ "required": [
1080
+ "tasks"
1081
+ ],
1082
+ "properties": {
1083
+ "source": {
1084
+ "$ref": "#/components/schemas/MappingRootDescription"
1085
+ },
1086
+ "tasks": {
1087
+ "type": "array",
1088
+ "description": "Every action in execution order; `[]` when there are none",
1089
+ "items": {
1090
+ "type": "object",
1091
+ "required": [
1092
+ "id"
1093
+ ],
1094
+ "properties": {
1095
+ "id": {
1096
+ "type": "string"
1097
+ },
1098
+ "schema": {
1099
+ "type": "string"
1100
+ },
1101
+ "label": {
1102
+ "type": "string",
1103
+ "description": "Display name of what the action creates, e.g. \"Contact\""
1104
+ },
1105
+ "description": {
1106
+ "$ref": "#/components/schemas/MappingRootDescription"
1107
+ }
1108
+ }
1109
+ }
1110
+ }
1111
+ }
1112
+ },
1113
+ "MappingRootDescription": {
1114
+ "type": "object",
1115
+ "description": "What the caller knows about a root (`RootDescription` of `@epilot/entity-mapping-validator`)",
1116
+ "required": [
1117
+ "kind",
1118
+ "fields"
1119
+ ],
1120
+ "properties": {
1121
+ "kind": {
1122
+ "type": "string",
1123
+ "enum": [
1124
+ "declared",
1125
+ "inferred"
1126
+ ]
1127
+ },
1128
+ "fields": {
1129
+ "type": "array",
1130
+ "items": {
1131
+ "$ref": "#/components/schemas/MappingRootField"
1132
+ }
1133
+ }
1134
+ }
1135
+ },
1136
+ "MappingRootField": {
1137
+ "type": "object",
1138
+ "required": [
1139
+ "path"
1140
+ ],
1141
+ "additionalProperties": true,
1142
+ "properties": {
1143
+ "path": {
1144
+ "type": "array",
1145
+ "items": {
1146
+ "oneOf": [
1147
+ {
1148
+ "type": "string"
1149
+ },
1150
+ {
1151
+ "type": "integer"
1152
+ }
1153
+ ]
1154
+ }
1155
+ },
1156
+ "label": {
1157
+ "type": "string"
1158
+ },
1159
+ "type": {
1160
+ "type": "string",
1161
+ "enum": [
1162
+ "string",
1163
+ "number",
1164
+ "boolean",
1165
+ "date",
1166
+ "object",
1167
+ "array",
1168
+ "entity"
1169
+ ]
1170
+ },
1171
+ "children": {
1172
+ "type": "array",
1173
+ "items": {
1174
+ "$ref": "#/components/schemas/MappingRootField"
1175
+ }
1176
+ },
1177
+ "open": {
1178
+ "type": "boolean",
1179
+ "description": "Only partly described; a path below it that `children` does not list is unknown, not missing"
1180
+ },
1181
+ "targetTypes": {
1182
+ "type": "array",
1183
+ "items": {
1184
+ "type": "string"
493
1185
  }
494
1186
  }
495
1187
  }
496
- }
497
- }
498
- },
499
- "components": {
500
- "securitySchemes": {
501
- "EpilotAuth": {
502
- "type": "http",
503
- "scheme": "bearer",
504
- "description": "Epilot Bearer Token"
505
- }
506
- },
507
- "schemas": {
1188
+ },
508
1189
  "SearchMappingReq": {
509
1190
  "type": "object",
510
1191
  "properties": {
@@ -518,6 +1199,10 @@
518
1199
  "properties": {
519
1200
  "configs": {
520
1201
  "$ref": "#/components/schemas/MappingConfigs"
1202
+ },
1203
+ "truncated": {
1204
+ "type": "boolean",
1205
+ "description": "the page ceiling was reached; the list is incomplete."
521
1206
  }
522
1207
  },
523
1208
  "required": [
@@ -600,14 +1285,22 @@
600
1285
  "format": "date-time"
601
1286
  },
602
1287
  "created_by": {
603
- "$ref": "#/components/schemas/Owner",
1288
+ "allOf": [
1289
+ {
1290
+ "$ref": "#/components/schemas/Owner"
1291
+ }
1292
+ ],
604
1293
  "description": "User / service who created the entity mapping config",
605
1294
  "example": {
606
1295
  "type": "internal_service"
607
1296
  }
608
1297
  },
609
1298
  "last_updated_by": {
610
- "$ref": "#/components/schemas/Owner",
1299
+ "allOf": [
1300
+ {
1301
+ "$ref": "#/components/schemas/Owner"
1302
+ }
1303
+ ],
611
1304
  "description": "User / service who last updated entity mapping config",
612
1305
  "example": {
613
1306
  "type": "user",
@@ -648,14 +1341,22 @@
648
1341
  "description": "Build relations between a source entity and one or more target entities, dynamically identified",
649
1342
  "properties": {
650
1343
  "source_ref": {
651
- "$ref": "#/components/schemas/EntityRef",
1344
+ "allOf": [
1345
+ {
1346
+ "$ref": "#/components/schemas/EntityRef"
1347
+ }
1348
+ ],
652
1349
  "description": "Entity for which to add relations."
653
1350
  },
654
1351
  "target": {
655
1352
  "type": "object",
656
1353
  "properties": {
657
1354
  "main_entity_ref": {
658
- "$ref": "#/components/schemas/EntityRef",
1355
+ "allOf": [
1356
+ {
1357
+ "$ref": "#/components/schemas/EntityRef"
1358
+ }
1359
+ ],
659
1360
  "description": "Main Entity from where to locate target entities. Eg. submisssion entity"
660
1361
  },
661
1362
  "relation_attributes": {
@@ -698,6 +1399,16 @@
698
1399
  "items": {
699
1400
  "$ref": "#/components/schemas/RelationItem"
700
1401
  }
1402
+ },
1403
+ "outputs": {
1404
+ "type": "object",
1405
+ "description": "The entities earlier actions (later: Flow tasks) of the same run produced, keyed by the\nproducing action's id, as on `ExecuteMappingReq.outputs`. `relation_attributes` select them with\n`source_filter.output_of`. An output that the main entity's relations also contain is used in\nits hydrated form; otherwise its `{ _id, _schema }` reference is enough for the relation write.\n",
1406
+ "additionalProperties": {
1407
+ "type": "array",
1408
+ "items": {
1409
+ "$ref": "#/components/schemas/OutputEntityRef"
1410
+ }
1411
+ }
701
1412
  }
702
1413
  },
703
1414
  "required": [
@@ -760,11 +1471,19 @@
760
1471
  "description": "Pass either source or source_entity",
761
1472
  "properties": {
762
1473
  "source_ref": {
763
- "$ref": "#/components/schemas/EntityRef",
1474
+ "allOf": [
1475
+ {
1476
+ "$ref": "#/components/schemas/EntityRef"
1477
+ }
1478
+ ],
764
1479
  "description": "A reference (id and schema) to the entity to be used as source."
765
1480
  },
766
1481
  "loop_ref": {
767
- "$ref": "#/components/schemas/EntityRef",
1482
+ "allOf": [
1483
+ {
1484
+ "$ref": "#/components/schemas/EntityRef"
1485
+ }
1486
+ ],
768
1487
  "description": "Reference to the current iteration's entity when running inside a flow loop.\nWhen set, its fields and relations are merged into the source context;\non schema conflicts the loop entity wins, so paths like `<schema>._id` resolve\nto the iteration entity rather than to a same-schema relation of the source.\n"
769
1488
  },
770
1489
  "targets": {
@@ -773,6 +1492,31 @@
773
1492
  "$ref": "#/components/schemas/TargetConfig"
774
1493
  },
775
1494
  "description": "Mapping Configuration to apply."
1495
+ },
1496
+ "outputs": {
1497
+ "type": "object",
1498
+ "description": "The entities earlier steps of the same run produced, keyed by the id of the automation action\n(later: Flow task) that produced them, in execution order. The executor passes what it recorded\nas each action's `outputs`. A key with an empty list says the action is known to the run but\nproduced nothing (skipped, failed, or no entity); a mapping that reads it is an ordinary empty\ncopy. A referenced id with no key at all is reported as an `unresolved_output_reference`\nwarning, so send every preceding action's id, including the ones that ran nothing.\n\nMapping attributes read them as `$outputOf['<id>']` (the last entity of that id, so a loop\naction yields its latest iteration) and `$outputsOf['<id>']` (every entity of that id);\nrelation attributes select them with `source_filter.output_of`. An entity is taken from the\nsource entity's hydrated relations when the producing action linked it back, otherwise it is\nfetched by id when a target references the id. Without an entry for an id, the engine falls\nback to the relations tagged `_hidden_<id>` (the convention existing configs use).\n",
1499
+ "additionalProperties": {
1500
+ "type": "array",
1501
+ "items": {
1502
+ "$ref": "#/components/schemas/OutputEntityRef"
1503
+ }
1504
+ },
1505
+ "example": {
1506
+ "9ec3711b-db63-449c-b894-54d5bb622a8f": [
1507
+ {
1508
+ "entity_id": "4c7a6d2e-1f3b-4b8e-9c21-0d5e6f7a8b9c",
1509
+ "entity_schema": "contact"
1510
+ }
1511
+ ]
1512
+ }
1513
+ },
1514
+ "output_ids": {
1515
+ "type": "array",
1516
+ "items": {
1517
+ "type": "string"
1518
+ },
1519
+ "description": "One id per entry in `targets`, in the same order: the id that target's result is published under,\nthe same key as in `outputs` (the automation action or Flow task that runs the target). Read in preview mode\nonly: each target's would-be entity becomes the output of its id for the targets after it\n(`$outputOf['<id>']`, `source_filter.output_of`), so a chain of actions is previewed as it would\nrun, instead of reading what an earlier run stored. The response then lists the entities per target\nin `preview_targets`.\n"
776
1520
  }
777
1521
  },
778
1522
  "required": [
@@ -780,6 +1524,48 @@
780
1524
  "targets"
781
1525
  ]
782
1526
  },
1527
+ "PreviewTarget": {
1528
+ "type": "object",
1529
+ "description": "What one target would write, in preview mode with `output_ids`",
1530
+ "properties": {
1531
+ "index": {
1532
+ "type": "integer",
1533
+ "description": "Position of the target in the request"
1534
+ },
1535
+ "output_id": {
1536
+ "type": "string",
1537
+ "description": "The id from `output_ids` at this position, which the target's entities were published under"
1538
+ },
1539
+ "mapped_entities": {
1540
+ "type": "array",
1541
+ "items": {
1542
+ "$ref": "#/components/schemas/Entity"
1543
+ }
1544
+ },
1545
+ "failure": {
1546
+ "$ref": "#/components/schemas/MappingFailure"
1547
+ }
1548
+ },
1549
+ "required": [
1550
+ "index",
1551
+ "mapped_entities"
1552
+ ]
1553
+ },
1554
+ "OutputEntityRef": {
1555
+ "type": "object",
1556
+ "description": "One entity an earlier action or task produced",
1557
+ "properties": {
1558
+ "entity_id": {
1559
+ "type": "string"
1560
+ },
1561
+ "entity_schema": {
1562
+ "type": "string"
1563
+ }
1564
+ },
1565
+ "required": [
1566
+ "entity_id"
1567
+ ]
1568
+ },
783
1569
  "ExecuteMappingResp": {
784
1570
  "type": "object",
785
1571
  "properties": {
@@ -800,6 +1586,13 @@
800
1586
  "items": {
801
1587
  "$ref": "#/components/schemas/MappingWarning"
802
1588
  }
1589
+ },
1590
+ "preview_targets": {
1591
+ "type": "array",
1592
+ "description": "In preview mode with `output_ids`, the entities and failure of each target, in order",
1593
+ "items": {
1594
+ "$ref": "#/components/schemas/PreviewTarget"
1595
+ }
803
1596
  }
804
1597
  },
805
1598
  "required": [
@@ -873,15 +1666,15 @@
873
1666
  "_updated_at": {
874
1667
  "type": "string",
875
1668
  "nullable": true
876
- },
877
- "required": [
878
- "_id",
879
- "_schema",
880
- "_org",
881
- "_created_at",
882
- "_updated_at"
883
- ]
1669
+ }
884
1670
  },
1671
+ "required": [
1672
+ "_id",
1673
+ "_schema",
1674
+ "_org",
1675
+ "_created_at",
1676
+ "_updated_at"
1677
+ ],
885
1678
  "additionalProperties": true
886
1679
  },
887
1680
  "EntityRef": {
@@ -977,6 +1770,25 @@
977
1770
  "type": "string",
978
1771
  "description": "path to the array from the entity payload"
979
1772
  },
1773
+ "source_type": {
1774
+ "type": "string",
1775
+ "description": "Kind of journey block the loop iterates. 'journey-multi-select' (default) is a cards block with multi selection. 'journey-file-upload' is a file upload block: source_path points at the submission's `_files.$relation` array and `filter_tags` narrows it down to the block's files. Forwarded to the flow-level loop by the Automation Hub.\n",
1776
+ "enum": [
1777
+ "journey-multi-select",
1778
+ "journey-file-upload"
1779
+ ],
1780
+ "default": "journey-multi-select"
1781
+ },
1782
+ "filter_tags": {
1783
+ "type": "array",
1784
+ "description": "Only iterate items of the array whose `_tags` contain every listed tag. Meant for relation arrays such as `submission._files.$relation`, where the journey tags each file relation with the upload block it came from. `##LOOP_INDEX##` keeps referring to the item's index in the unfiltered array.\n",
1785
+ "items": {
1786
+ "type": "string"
1787
+ },
1788
+ "example": [
1789
+ "_hidden_ 2a4b1c3d-0000-4000-8000-000000000000 - Dokumente"
1790
+ ]
1791
+ },
980
1792
  "length": {
981
1793
  "type": "number",
982
1794
  "description": "a hard limit of how many times the loop is allowed to run."
@@ -1141,6 +1953,10 @@
1141
1953
  "type": "string",
1142
1954
  "description": "Filter by relation tag (label) on the main entity"
1143
1955
  },
1956
+ "output_of": {
1957
+ "type": "string",
1958
+ "description": "Pick the entities the automation action (later: Flow task) with this id produced in the same run,\nas passed in `ExecuteMappingReq.outputs`. Combinable with `schema`, `tag` and `limit`. When the\nrequest carries no entry for the id, the relations tagged `_hidden_<id>` are used instead.\n"
1959
+ },
1144
1960
  "tag": {
1145
1961
  "type": "string",
1146
1962
  "description": "Filter by a specific tag on the related entity"
@@ -1267,6 +2083,10 @@
1267
2083
  "items": {
1268
2084
  "$ref": "#/components/schemas/GraphNodeFilter"
1269
2085
  }
2086
+ },
2087
+ "optional": {
2088
+ "type": "boolean",
2089
+ "description": "Only meaningful for a node expected to resolve to a single entity (the seed node, or\n\"cardinality: one\"). When true, finding zero matching entities is not an error - the\nmapping proceeds without this node's data instead of failing. Finding more than one\nmatch still fails regardless of this flag; ambiguity is never silently accepted.\nOn the seed node it also covers an empty seed: when `seed.entity_id` resolves to an\nempty value (e.g. an optional source field is missing), the whole graph_context entry\nis skipped and none of its nodes are added to the mapping context.\n"
1270
2090
  }
1271
2091
  },
1272
2092
  "required": [
@@ -1428,7 +2248,11 @@
1428
2248
  },
1429
2249
  "_random": {
1430
2250
  "description": "Generate random ids / numbers",
1431
- "$ref": "#/components/schemas/RandomOperation"
2251
+ "allOf": [
2252
+ {
2253
+ "$ref": "#/components/schemas/RandomOperation"
2254
+ }
2255
+ ]
1432
2256
  },
1433
2257
  "_each": {
1434
2258
  "description": "Iterate over a source array. Use with _as and _map.\nThe value is a path to resolve from the source entity context.\nExample: \"submission.meterReadings\"\n",
@@ -1442,7 +2266,11 @@
1442
2266
  },
1443
2267
  "_map": {
1444
2268
  "description": "Operation to evaluate per _each iteration item.\nCan be any OperationNode, typically an object with _copy\nreferences to the $<_as name> alias.\n",
1445
- "$ref": "#/components/schemas/OperationNode"
2269
+ "allOf": [
2270
+ {
2271
+ "$ref": "#/components/schemas/OperationNode"
2272
+ }
2273
+ ]
1446
2274
  }
1447
2275
  },
1448
2276
  "additionalProperties": true
@@ -1464,7 +2292,8 @@
1464
2292
  "additionalProperties": true
1465
2293
  },
1466
2294
  {
1467
- "type": "array"
2295
+ "type": "array",
2296
+ "items": {}
1468
2297
  }
1469
2298
  ]
1470
2299
  },
@@ -1607,55 +2436,6 @@
1607
2436
  "value_json"
1608
2437
  ]
1609
2438
  },
1610
- "MappingHistoryResp": {
1611
- "type": "object",
1612
- "properties": {
1613
- "results": {
1614
- "type": "array",
1615
- "items": {
1616
- "$ref": "#/components/schemas/MappingHistoryEntry"
1617
- }
1618
- }
1619
- },
1620
- "required": [
1621
- "results"
1622
- ]
1623
- },
1624
- "MappingHistoryEntry": {
1625
- "type": "object",
1626
- "properties": {
1627
- "id": {
1628
- "type": "string",
1629
- "example": "70542580-2b38-4bfc-af8d-bb90102f9f47"
1630
- },
1631
- "timestamp": {
1632
- "type": "string",
1633
- "format": "ISO datetime"
1634
- },
1635
- "source_entity_snapshot": {
1636
- "$ref": "#/components/schemas/Entity"
1637
- },
1638
- "mapped_entities_snapshot": {
1639
- "type": "array",
1640
- "items": {
1641
- "$ref": "#/components/schemas/Entity"
1642
- }
1643
- },
1644
- "target_configs_snapshot": {
1645
- "type": "array",
1646
- "items": {
1647
- "$ref": "#/components/schemas/TargetConfig"
1648
- }
1649
- }
1650
- },
1651
- "required": [
1652
- "id",
1653
- "timestamp",
1654
- "source_entity_snapshot",
1655
- "target_configs_snapshot",
1656
- "mapped_entities_snapshot"
1657
- ]
1658
- },
1659
2439
  "MappingSource": {
1660
2440
  "type": "object",
1661
2441
  "properties": {
@@ -1663,6 +2443,10 @@
1663
2443
  "type": "string",
1664
2444
  "description": "Key aiming to identify source"
1665
2445
  },
2446
+ "block_id": {
2447
+ "type": "string",
2448
+ "description": "The journey block's id, the key of its value in `_block_values` of the submission"
2449
+ },
1666
2450
  "sub_properties": {
1667
2451
  "description": "Each item describes a property under the main source and a possibly, a default value for its target attribute",
1668
2452
  "type": "array",
@@ -1687,7 +2471,11 @@
1687
2471
  },
1688
2472
  "initial_relation": {
1689
2473
  "description": "Initial value of a relation to be added",
1690
- "$ref": "#/components/schemas/RelationAttribute"
2474
+ "allOf": [
2475
+ {
2476
+ "$ref": "#/components/schemas/RelationAttribute"
2477
+ }
2478
+ ]
1691
2479
  },
1692
2480
  "title": {
1693
2481
  "type": "string",
@@ -1818,6 +2606,128 @@
1818
2606
  "relation",
1819
2607
  "array"
1820
2608
  ]
2609
+ },
2610
+ "JourneyContextUsagesReq": {
2611
+ "type": "object",
2612
+ "required": [
2613
+ "journey_id",
2614
+ "param_keys"
2615
+ ],
2616
+ "properties": {
2617
+ "journey_id": {
2618
+ "type": "string",
2619
+ "format": "uuid"
2620
+ },
2621
+ "param_keys": {
2622
+ "type": "array",
2623
+ "items": {
2624
+ "type": "string"
2625
+ },
2626
+ "description": "Context parameter keys to look for, as plain strings."
2627
+ },
2628
+ "param_ids": {
2629
+ "type": "array",
2630
+ "items": {
2631
+ "type": "string"
2632
+ },
2633
+ "description": "Accepted and ignored. This service stores context references by name only; the field keeps one request shape across every adapter.\n"
2634
+ }
2635
+ }
2636
+ },
2637
+ "JourneyContextUsage": {
2638
+ "type": "object",
2639
+ "required": [
2640
+ "kind",
2641
+ "resource",
2642
+ "matched_as"
2643
+ ],
2644
+ "properties": {
2645
+ "kind": {
2646
+ "type": "string",
2647
+ "enum": [
2648
+ "entity-mapping"
2649
+ ]
2650
+ },
2651
+ "resource": {
2652
+ "type": "object",
2653
+ "required": [
2654
+ "type",
2655
+ "id"
2656
+ ],
2657
+ "properties": {
2658
+ "type": {
2659
+ "type": "string",
2660
+ "enum": [
2661
+ "mapping"
2662
+ ]
2663
+ },
2664
+ "id": {
2665
+ "type": "string"
2666
+ }
2667
+ }
2668
+ },
2669
+ "location": {
2670
+ "type": "object",
2671
+ "properties": {
2672
+ "target_schema": {
2673
+ "type": "string"
2674
+ },
2675
+ "attribute": {
2676
+ "type": "string"
2677
+ }
2678
+ }
2679
+ },
2680
+ "matched_as": {
2681
+ "type": "object",
2682
+ "required": [
2683
+ "dialect",
2684
+ "token",
2685
+ "at"
2686
+ ],
2687
+ "properties": {
2688
+ "dialect": {
2689
+ "type": "string",
2690
+ "enum": [
2691
+ "name"
2692
+ ]
2693
+ },
2694
+ "token": {
2695
+ "type": "string"
2696
+ },
2697
+ "at": {
2698
+ "type": "string"
2699
+ }
2700
+ }
2701
+ }
2702
+ }
2703
+ },
2704
+ "JourneyContextUsagesResp": {
2705
+ "type": "object",
2706
+ "required": [
2707
+ "usages",
2708
+ "status",
2709
+ "scanned"
2710
+ ],
2711
+ "properties": {
2712
+ "usages": {
2713
+ "type": "array",
2714
+ "items": {
2715
+ "$ref": "#/components/schemas/JourneyContextUsage"
2716
+ }
2717
+ },
2718
+ "status": {
2719
+ "type": "string",
2720
+ "enum": [
2721
+ "ok",
2722
+ "partial"
2723
+ ],
2724
+ "description": "partial means the row cap was reached and rows were dropped, or that scanning stopped\nearly and entire configs - some of which may reference the parameter - were never\nscanned.\n"
2725
+ },
2726
+ "scanned": {
2727
+ "type": "integer",
2728
+ "description": "The number of configs actually scanned, not the number found. May be less than the\ntotal number of matching configs when status is partial.\n"
2729
+ }
2730
+ }
1821
2731
  }
1822
2732
  }
1823
2733
  },