-
Notifications
You must be signed in to change notification settings - Fork 0
/
openapi.yml
1080 lines (1079 loc) · 30.6 KB
/
openapi.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.0.3
info:
title: Entity Mapping API
description: API Backend for mapping source entity into target entities
version: 1.0.0
tags:
- name: mappings
description: Entity Mapping Configs
security:
- EpilotAuth: []
paths:
/v1/mappings:
post:
operationId: storeConfig
summary: storeConfig
description: Store new MappingConfig
tags:
- mappings
parameters:
- name: with_id
in: query
required: false
description: Whether ids are part of the body or not
schema:
type: string
requestBody:
description: Mapping Config to store
content:
application/json:
schema:
$ref: '#/components/schemas/MappingConfig'
responses:
'201':
description: The updated entity mapping config
content:
application/json:
schema:
$ref: '#/components/schemas/MappingConfig'
/v1/mappings/{id}:
get:
operationId: getConfig
summary: getConfig
description: Get latest version of a mapping config by id
tags:
- mappings
parameters:
- name: id
in: path
required: true
description: Mapping Config Id
schema:
type: string
example: 70542580-2b38-4bfc-af8d-bb90102f9f47
responses:
'200':
description: Entity Mapping Config
content:
application/json:
schema:
$ref: '#/components/schemas/MappingConfig'
delete:
operationId: deleteConfig
summary: deleteConfig
description: Delete entity mapping config
tags:
- mappings
parameters:
- name: id
in: path
required: true
description: Mapping Config Id
schema:
type: string
example: 70542580-2b38-4bfc-af8d-bb90102f9f47
responses:
'200':
description: The deleted mapping config
content:
application/json:
schema:
$ref: '#/components/schemas/MappingConfig'
/v1/mappings/{id}/versions:
get:
operationId: getAllVersions
summary: getAllVersions
description: Get all version of MappingConfig
tags:
- mappings
parameters:
- name: id
in: path
required: true
description: Mapping Config Id
schema:
type: string
example: 70542580-2b38-4bfc-af8d-bb90102f9f47
responses:
'200':
description: All versions of a MappingConfig
content:
application/json:
schema:
$ref: '#/components/schemas/MappingConfigsResp'
post:
operationId: storeNewVersion
summary: storeNewVersion
description: Store new version of MappingConfig
tags:
- mappings
parameters:
- name: id
in: path
required: true
description: Mapping Config Id
schema:
type: string
example: 70542580-2b38-4bfc-af8d-bb90102f9f47
requestBody:
description: Mapping Config to store
content:
application/json:
schema:
$ref: '#/components/schemas/MappingConfig'
responses:
'200':
description: The updated entity mapping config
content:
application/json:
schema:
$ref: '#/components/schemas/MappingConfig'
/v1/mappings/{id}/versions/{version}:
get:
operationId: getConfigVersion
summary: getConfigVersion
description: Get specific version of a mapping config by id & version
tags:
- mappings
parameters:
- name: id
in: path
required: true
description: Mapping Config Id
schema:
type: string
example: 70542580-2b38-4bfc-af8d-bb90102f9f47
- name: version
in: path
required: true
description: Version to be loaded
schema:
type: number
example: 3
responses:
'200':
description: Entity Mapping Config
content:
application/json:
schema:
$ref: '#/components/schemas/MappingConfig'
/v1/mappings:execute:
post:
operationId: executeMapping
summary: executeMapping
description: Execute entity mapping based on a config
parameters:
- name: preview_mode
in: query
required: false
description: True, if you want to preview the entities which will result
schema:
type: boolean
example: true
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ExecuteMappingReq'
tags:
- mappings
responses:
'200':
description: The target entities which were mapped
content:
application/json:
schema:
$ref: '#/components/schemas/ExecuteMappingResp'
/v1/mappings:search:
post:
operationId: searchConfigs
summary: searchConfigs
description: Search mapping configs
tags:
- mappings
requestBody:
description: Search Mapping Configs
content:
application/json:
schema:
$ref: '#/components/schemas/SearchMappingReq'
responses:
'200':
description: Entity Mapping Config
content:
application/json:
schema:
$ref: '#/components/schemas/MappingConfig'
/v1/mappings/history:
get:
operationId: queryMappingHistory
summary: queryMappingHistory
description: Get the Mapping History
tags:
- mappings
parameters:
- in: query
name: from
schema:
type: string
format: datetime
required: false
description: filter the history from this date on
- in: query
name: to
schema:
type: string
format: datetime
required: false
description: filter the history to this date on
- in: query
name: targetEntityId
schema:
type: string
format: uuid
- in: query
name: sourceEntityId
schema:
type: string
format: uuid
responses:
'200':
description: Query result of mapping history
content:
application/json:
schema:
properties:
results:
type: array
items:
$ref: '#/components/schemas/MappingHistoryResp'
/v1/relations:execute:
post:
operationId: executeRelations
summary: executeRelations
description: Execute relation mapping between source entity and target entities
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ExecuteRelationsReq'
tags:
- mappings
responses:
'200':
description: The relations which were for both source entity and main entity
content:
application/json:
schema:
$ref: '#/components/schemas/ExecuteRelationsResp'
/v2/mappings/{id}:
get:
operationId: getMappingConfig
summary: getMappingConfig
description: Get latest version of a mapping config by id V2
tags:
- mappings
parameters:
- name: id
in: path
required: true
description: Mapping Config Id
schema:
type: string
example: 70542580-2b38-4bfc-af8d-bb90102f9f47
responses:
'200':
description: Entity Mapping Config
content:
application/json:
schema:
$ref: '#/components/schemas/MappingConfigV2'
put:
operationId: putMappingConfig
summary: putMappingConfig
description: Stores new version of entity mapping config
tags:
- mappings
parameters:
- name: id
in: path
required: true
description: Mapping Config Id
schema:
type: string
example: 70542580-2b38-4bfc-af8d-bb90102f9f47
requestBody:
description: Mapping Config to store
content:
application/json:
schema:
$ref: '#/components/schemas/MappingConfigV2'
responses:
'200':
description: The updated entity mapping config
content:
application/json:
schema:
$ref: '#/components/schemas/MappingConfigV2'
components:
securitySchemes:
EpilotAuth:
type: http
scheme: bearer
description: Epilot Bearer Token
schemas:
SearchMappingReq:
type: object
properties:
source:
$ref: '#/components/schemas/SourceConfig'
MappingConfigsResp:
type: object
properties:
configs:
$ref: '#/components/schemas/MappingConfigs'
required:
- configs
MappingConfigs:
type: array
items:
$ref: '#/components/schemas/MappingConfig'
MappingConfig:
allOf:
- $ref: '#/components/schemas/MappingConfigCommonFields'
- type: object
properties:
org_id:
type: string
example: '66'
version:
type: integer
example: 2
required:
- org_id
- version
MappingConfigV2:
allOf:
- $ref: '#/components/schemas/MappingConfigCommonFields'
- type: object
properties:
org_id:
type: string
example: '66'
readOnly: true
version:
type: integer
example: 2
readOnly: true
MappingConfigCommonFields:
type: object
properties:
id:
type: string
source:
$ref: '#/components/schemas/SourceConfig'
targets:
type: array
items:
$ref: '#/components/schemas/TargetConfig'
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
created_by:
$ref: '#/components/schemas/Owner'
description: User / service who created the entity mapping config
example:
type: internal_service
last_updated_by:
$ref: '#/components/schemas/Owner'
description: User / service who last updated entity mapping config
example:
type: user
org_id: 255151
user_id: 99252
required:
- id
- source
- targets
Owner:
type: object
properties:
type:
type: string
enum:
- user
- internal_service
org_id:
type: string
user_id:
type: string
required:
- type
ExecuteRelationsReq:
type: object
description: Build relations between a source entity and one or more target entities, dynamically identified
properties:
source_ref:
$ref: '#/components/schemas/EntityRef'
description: Entity for which to add relations.
target:
type: object
properties:
main_entity_ref:
$ref: '#/components/schemas/EntityRef'
description: Main Entity from where to locate target entities. Eg. submisssion entity
relation_attributes:
type: array
description: Relation mappings
items:
$ref: '#/components/schemas/RelationAttribute'
linkback:
type: object
description: For cases where you want to store a relation between main entity (eg. submission) and current source entity.
properties:
attribute:
type: string
default: mapped_entities
description: |
Relation attribute on the main entity (submission) where the target entity will be linked. Set to false to disable linkback
relation_tags:
type: array
description: Relation tags (labels) to include in main entity linkback relation attribute
items:
type: string
required:
- attribute
- relation_tags
required:
- main_entity_ref
- relation_attributes
additional_relations:
type: array
items:
$ref: '#/components/schemas/RelationItem'
required:
- source_ref
ExecuteRelationsResp:
type: object
properties:
relations:
type: array
items:
$ref: '#/components/schemas/NewRelationItem'
NewRelationItem:
type: object
properties:
source_entity_id:
type: string
target_entity_id:
type: string
relation_attr:
type: string
tags:
type: array
items:
type: string
required:
- source_entity_id
- target_entity_id
- relation_attr
RelationItem:
type: object
properties:
entity_id:
type: string
attribute:
type: string
required:
- entity_id
- attribute
ExecuteMappingReq:
type: object
description: Pass either source or source_entity
properties:
source_ref:
$ref: '#/components/schemas/EntityRef'
description: A reference (id and schema) to the entity to be used as source.
targets:
type: array
items:
$ref: '#/components/schemas/TargetConfig'
description: Mapping Configuration to apply.
required:
- source_ref
- targets
ExecuteMappingResp:
type: object
properties:
mapped_entities:
type: array
items:
$ref: '#/components/schemas/Entity'
failures:
type: array
items:
$ref: '#/components/schemas/MappingFailure'
warnings:
type: array
items:
$ref: '#/components/schemas/MappingWarning'
required:
- mapped_entities
MappingFailure:
type: object
properties:
target:
$ref: '#/components/schemas/TargetConfig'
error:
type: object
properties:
isSilent:
type: boolean
message:
type: string
additionalProperties: true
MappingWarning:
type: object
properties:
explanation:
type: string
context:
type: string
id:
type: string
required:
- explanation
Entity:
type: object
properties:
_id:
type: string
_schema:
type: string
_title:
type: string
nullable: true
_org:
type: string
_tags:
type: array
items:
type: string
nullable: true
_created_at:
type: string
nullable: true
_updated_at:
type: string
nullable: true
required:
- _id
- _schema
- _org
- _created_at
- _updated_at
additionalProperties: true
EntityRef:
type: object
properties:
entity_id:
type: string
description: id of the source entity to be mapped
entity_schema:
description: schema of the source entity
type: string
example: submission
required:
- entity_id
SourceConfig:
type: object
properties:
type:
type: string
enum:
- journey
- entity
config:
anyOf:
- $ref: '#/components/schemas/JourneyRef'
- $ref: '#/components/schemas/EntityRef'
JourneyRef:
type: object
properties:
journey_id:
type: string
Loop_Index_String:
type: string
description: This string value will be replaced with the value of the loop index, when mapping in loop mode
enum:
- '##LOOP_INDEX##'
TargetConfig:
type: object
properties:
id:
type: string
description: Identifier for target configuration. Useful for later usages when trying to identify which target config to map to.
name:
type: string
description: A name for this configuration
allow_failure:
type: boolean
description: Pass it as true, when you don't want failures to interrupt the mapping process.
target_schema:
type: string
description: Schema of target entity
target_unique:
type: array
description: Unique key for target entity (see upsertEntity of Entity API)
items:
type: string
loop_config:
type: object
description: contains config in case of running in loop mode
properties:
source_path:
type: string
description: path to the array from the entity payload
length:
type: number
description: a hard limit of how many times the loop is allowed to run.
default: the length of the array
conditionMode:
description: Mode of how conditions are considered valid
type: string
enum:
- oneOf
- anyOf
- allOf
conditions:
type: array
description: Conditions necessary to hold for the target entity to be mapped
items:
$ref: '#/components/schemas/MapCondition'
mapping_attributes:
type: array
description: Attribute mappings
items:
anyOf:
- $ref: '#/components/schemas/MappingAttributeV2'
- $ref: '#/components/schemas/MappingAttribute'
relation_attributes:
type: array
description: Relation mappings
items:
$ref: '#/components/schemas/RelationAttribute'
linkback_relation_attribute:
type: string
default: mapped_entities
description: |
Relation attribute on the main entity where the target entity will be linked. Set to false to disable linkback
linkback_relation_tags:
type: array
description: Relation tags (labels) to include in main entity linkback relation attribute
items:
type: string
required:
- target_schema
- mapping_attributes
MapCondition:
type: object
properties:
_exists:
$ref: '#/components/schemas/ConditionNode'
_equals:
$ref: '#/components/schemas/ConditionNode'
_not_exists:
$ref: '#/components/schemas/ConditionNode'
_any_of:
$ref: '#/components/schemas/ConditionNode'
ConditionNode:
type: object
properties:
source:
type: string
value:
oneOf:
- type: string
- type: number
- type: object
- type: array
items:
type: object
RelationAttribute:
type: object
properties:
target:
type: string
description: Target attribute to store the relation in
target_tags:
type: array
description: Relation tags (labels) to set for the stored relations
items:
type: string
target_tags_include_source:
type: boolean
description: Include all relation tags (labels) present on the main entity relation
default: false
source_filter:
type: object
description: A filter to identify which source entities to pick as relations from main entity
properties:
limit:
type: integer
description: Limit relations to maximum number (default, all matched relations)
minimum: 0
schema:
type: string
description: Filter by specific schema
attribute:
type: string
description: Filter by a specific relation attribute on the main entity
relation_tag:
type: string
description: Filter by relation tag (label) on the main entity
tag:
type: string
description: Filter by a specific tag on the related entity
self:
type: boolean
description: Picks main entity as relation (overrides other filters)
default: false
related_to:
type: object
additionalProperties: true
deprecated: true
mode:
type: string
enum:
- append
- prepend
- set
origin:
$ref: '#/components/schemas/AttributeOrigin'
required:
- target
- mode
MappingAttributeV2:
type: object
properties:
target:
type: string
description: Target JSON path for the attribute to set
operation:
$ref: '#/components/schemas/OperationNode'
origin:
$ref: '#/components/schemas/AttributeOrigin'
required:
- target
- operation
example:
target: _tags
operation:
_append:
- new
- tags
_uniq: true
AttributeOrigin:
type: string
description: Origin of an attribute.
enum:
- system_recommendation
- user_manually
- entity_updating_system_recommendation
OperationNode:
description: Mapping operation nodes are either primitive values or operation node objects
oneOf:
- $ref: '#/components/schemas/OperationObjectNode'
- $ref: '#/components/schemas/PrimitiveJSONValue'
OperationObjectNode:
type: object
properties:
_set:
$ref: '#/components/schemas/PrimitiveJSONValue'
_append:
description: Append to array
items:
$ref: '#/components/schemas/PrimitiveJSONValue'
_uniq:
description: Unique array
oneOf:
- type: boolean
example: true
- type: array
description: Unique key consisting of object keys
example:
- email
items:
type: string
_copy:
description: Copy JSONPath value from source entity context
type: string
example: contact.first_name
_template:
description: Define handlebars template to output a string
type: string
example: '{{contact.first_name}} {{contact.last_name}}'
_random:
description: Generate random ids / numbers
$ref: '#/components/schemas/RandomOperation'
additionalProperties: true
PrimitiveJSONValue:
x-speakeasy-type-override: any
description: Represents any primitive JSON value
anyOf:
- type: string
- type: boolean
- type: number
- type: object
additionalProperties: true
- type: array
items:
type: string
RandomOperation:
oneOf:
- type: object
properties:
type:
type: string
enum:
- uuid
- nanoid
required:
- type
- type: object
properties:
type:
type: string
enum:
- number
min:
type: number
default: 0
max:
type: number
default: 1
required:
- type
MappingAttribute:
anyOf:
- $ref: '#/components/schemas/SetValueMapper'
- $ref: '#/components/schemas/CopyValueMapper'
- $ref: '#/components/schemas/AppendValueMapper'
MappingAttributeMode:
type: string
enum:
- copy_if_exists
- append_if_exists
- set_value
description: >
- copy_if_exists - it replaces the target attribute with the source value - append_if_exists - it currently replaces target attribute with array like values. Useful when you have multiple values to be added into one attribute. -
set_value - it sets a value to a predefined value. Must be used together with value property.
SetValueMapper:
type: object
deprecated: true
properties:
mode:
$ref: '#/components/schemas/MappingAttributeMode'
target:
type: string
description: JSON like target path for the attribute. Eg. last_name
value:
description: |
Any value to be set: string, number, string[], number[], JSON object, etc. It will override existing values, if any.
required:
- mode
- target
- value
CopyValueMapper:
type: object
deprecated: true
properties:
mode:
$ref: '#/components/schemas/MappingAttributeMode'
target:
type: string
description: JSON like target path for the attribute. Eg. last_name
source:
type: string
description: |
JSON source path for the value to be extracted from the main entity. Eg: steps[1].['Product Info'].price
required:
- mode
- target
- source
AppendValueMapper:
type: object
deprecated: true
properties:
mode:
$ref: '#/components/schemas/MappingAttributeMode'
target:
type: string
description: JSON like target path for the attribute. Eg. last_name
source:
type: string
description: |
JSON source path for the value to be extracted from the main entity. Eg: steps[1].['Product Info'].price
value_json:
type: string
description: |
To be provided only when mapping json objects into a target attribute. Eg array of addresses.
target_unique:
type: array
items:
type: string
description: |
Array of keys which should be used when checking for uniqueness. Eg: [country, city, postal_code]
required:
- mode
- target
- value_json
MappingHistoryResp:
type: object
properties:
results:
type: array
items:
$ref: '#/components/schemas/MappingHistoryEntry'
required:
- results
MappingHistoryEntry:
type: object
properties:
id:
type: string
example: 70542580-2b38-4bfc-af8d-bb90102f9f47
timestamp:
type: string
format: ISO datetime
source_entity_snapshot:
$ref: '#/components/schemas/Entity'
mapped_entities_snapshot:
type: array
items:
$ref: '#/components/schemas/Entity'
target_configs_snapshot:
type: array
items:
$ref: '#/components/schemas/TargetConfig'
required:
- id
- timestamp
- source_entity_snapshot
- target_configs_snapshot
- mapped_entities_snapshot
MappingSource:
type: object
properties:
key:
type: string
description: Key aiming to identify source
sub_properties:
description: Each item describes a property under the main source and a possibly, a default value for its target attribute
type: array
items:
$ref: '#/components/schemas/MappingSourceProperty'
source_type:
type: string
description: Data Structure type of source
possible_target_types:
type: array
items:
$ref: '#/components/schemas/MappingSourceTargetType'
description: Data Structure Type of the underlaying output value
initial_relation:
description: Initial value of a relation to be added
$ref: '#/components/schemas/RelationAttribute'
title:
type: string
description: Human readable name of the Source
sub_title:
type: string
description: Human readable type of the source
target_settings:
type: object
properties:
allowed_ui_actions:
type: array