@epilot/entity-mapping-client 0.0.1-alpha.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.
@@ -0,0 +1,840 @@
1
+ {
2
+ "openapi": "3.0.3",
3
+ "info": {
4
+ "title": "Entity Mapping API",
5
+ "description": "API Backend for mapping source entity into target entities",
6
+ "version": "1.0.0"
7
+ },
8
+ "tags": [
9
+ {
10
+ "name": "mappings",
11
+ "description": "Entity Mapping Configs"
12
+ }
13
+ ],
14
+ "security": [
15
+ {
16
+ "EpilotAuth": []
17
+ }
18
+ ],
19
+ "paths": {
20
+ "/v1/mappings": {
21
+ "post": {
22
+ "operationId": "storeConfig",
23
+ "summary": "storeConfig",
24
+ "description": "Store new MappingConfig",
25
+ "tags": [
26
+ "mappings"
27
+ ],
28
+ "requestBody": {
29
+ "description": "Mapping Config to store",
30
+ "content": {
31
+ "application/json": {
32
+ "schema": {
33
+ "$ref": "#/components/schemas/MappingConfig"
34
+ }
35
+ }
36
+ }
37
+ },
38
+ "responses": {
39
+ "201": {
40
+ "description": "The updated entity mapping config",
41
+ "content": {
42
+ "application/json": {
43
+ "schema": {
44
+ "$ref": "#/components/schemas/MappingConfig"
45
+ }
46
+ }
47
+ }
48
+ }
49
+ }
50
+ }
51
+ },
52
+ "/v1/mappings/{id}": {
53
+ "get": {
54
+ "operationId": "getConfig",
55
+ "summary": "getConfig",
56
+ "description": "Get latest version of a mapping config by id",
57
+ "tags": [
58
+ "mappings"
59
+ ],
60
+ "parameters": [
61
+ {
62
+ "name": "id",
63
+ "in": "path",
64
+ "required": true,
65
+ "description": "Mapping Config Id",
66
+ "schema": {
67
+ "type": "string",
68
+ "example": "uuidv4"
69
+ }
70
+ }
71
+ ],
72
+ "responses": {
73
+ "200": {
74
+ "description": "Entity Mapping Config",
75
+ "content": {
76
+ "application/json": {
77
+ "schema": {
78
+ "$ref": "#/components/schemas/MappingConfig"
79
+ }
80
+ }
81
+ }
82
+ }
83
+ }
84
+ },
85
+ "delete": {
86
+ "operationId": "deleteConfig",
87
+ "summary": "deleteConfig",
88
+ "description": "Delete entity mapping config",
89
+ "tags": [
90
+ "mappings"
91
+ ],
92
+ "parameters": [
93
+ {
94
+ "name": "id",
95
+ "in": "path",
96
+ "required": true,
97
+ "description": "Mapping Config Id",
98
+ "schema": {
99
+ "type": "string",
100
+ "example": "uuidv4"
101
+ }
102
+ }
103
+ ],
104
+ "responses": {
105
+ "200": {
106
+ "description": "The deleted mapping config",
107
+ "content": {
108
+ "application/json": {
109
+ "schema": {
110
+ "$ref": "#/components/schemas/MappingConfig"
111
+ }
112
+ }
113
+ }
114
+ }
115
+ }
116
+ }
117
+ },
118
+ "/v1/mappings/{id}/versions": {
119
+ "get": {
120
+ "operationId": "getAllVersions",
121
+ "summary": "getAllVersions",
122
+ "description": "Get all version of MappingConfig",
123
+ "tags": [
124
+ "mappings"
125
+ ],
126
+ "parameters": [
127
+ {
128
+ "name": "id",
129
+ "in": "path",
130
+ "required": true,
131
+ "description": "Mapping Config Id",
132
+ "schema": {
133
+ "type": "string",
134
+ "example": "uuidv4"
135
+ }
136
+ }
137
+ ],
138
+ "responses": {
139
+ "200": {
140
+ "description": "All versions of a MappingConfig",
141
+ "content": {
142
+ "application/json": {
143
+ "schema": {
144
+ "$ref": "#/components/schemas/MappingConfigsResp"
145
+ }
146
+ }
147
+ }
148
+ }
149
+ }
150
+ },
151
+ "post": {
152
+ "operationId": "storeNewVersion",
153
+ "summary": "storeNewVersion",
154
+ "description": "Store new version of MappingConfig",
155
+ "tags": [
156
+ "mappings"
157
+ ],
158
+ "parameters": [
159
+ {
160
+ "name": "id",
161
+ "in": "path",
162
+ "required": true,
163
+ "description": "Mapping Config Id",
164
+ "schema": {
165
+ "type": "string",
166
+ "example": "uuidv4"
167
+ }
168
+ }
169
+ ],
170
+ "requestBody": {
171
+ "description": "Mapping Config to store",
172
+ "content": {
173
+ "application/json": {
174
+ "schema": {
175
+ "$ref": "#/components/schemas/MappingConfig"
176
+ }
177
+ }
178
+ }
179
+ },
180
+ "responses": {
181
+ "200": {
182
+ "description": "The updated entity mapping config",
183
+ "content": {
184
+ "application/json": {
185
+ "schema": {
186
+ "$ref": "#/components/schemas/MappingConfig"
187
+ }
188
+ }
189
+ }
190
+ }
191
+ }
192
+ }
193
+ },
194
+ "/v1/mappings/{id}:execute": {
195
+ "post": {
196
+ "operationId": "executeMapping",
197
+ "summary": "executeMapping",
198
+ "description": "Execute entity mapping based on a config",
199
+ "parameters": [
200
+ {
201
+ "name": "id",
202
+ "in": "path",
203
+ "required": true,
204
+ "description": "Mapping Config Id",
205
+ "schema": {
206
+ "type": "string",
207
+ "example": "uuidv4"
208
+ }
209
+ }
210
+ ],
211
+ "requestBody": {
212
+ "content": {
213
+ "application/json": {
214
+ "schema": {
215
+ "$ref": "#/components/schemas/ExecuteMappingReq"
216
+ }
217
+ }
218
+ }
219
+ },
220
+ "tags": [
221
+ "mappings"
222
+ ],
223
+ "responses": {
224
+ "200": {
225
+ "description": "The target entities which were mapped",
226
+ "content": {
227
+ "application/json": {
228
+ "schema": {
229
+ "$ref": "#/components/schemas/ExecuteMappingResp"
230
+ }
231
+ }
232
+ }
233
+ }
234
+ }
235
+ }
236
+ },
237
+ "/v1/mappings:search": {
238
+ "post": {
239
+ "operationId": "searchConfigs",
240
+ "summary": "searchConfigs",
241
+ "description": "Search mapping configs",
242
+ "tags": [
243
+ "mappings"
244
+ ],
245
+ "requestBody": {
246
+ "description": "Search Mapping Configs",
247
+ "content": {
248
+ "application/json": {
249
+ "schema": {
250
+ "$ref": "#/components/schemas/SearchMappingReq"
251
+ }
252
+ }
253
+ }
254
+ },
255
+ "responses": {
256
+ "200": {
257
+ "description": "Entity Mapping Config",
258
+ "content": {
259
+ "application/json": {
260
+ "schema": {
261
+ "$ref": "#/components/schemas/MappingConfig"
262
+ }
263
+ }
264
+ }
265
+ }
266
+ }
267
+ }
268
+ }
269
+ },
270
+ "components": {
271
+ "securitySchemes": {
272
+ "EpilotAuth": {
273
+ "type": "http",
274
+ "scheme": "bearer",
275
+ "description": "Epilot Bearer Token"
276
+ }
277
+ },
278
+ "schemas": {
279
+ "SearchMappingReq": {
280
+ "type": "object",
281
+ "properties": {
282
+ "source": {
283
+ "$ref": "#/components/schemas/SourceConfig"
284
+ }
285
+ }
286
+ },
287
+ "MappingConfigsResp": {
288
+ "type": "object",
289
+ "properties": {
290
+ "configs": {
291
+ "$ref": "#/components/schemas/MappingConfigs"
292
+ }
293
+ },
294
+ "required": [
295
+ "configs"
296
+ ]
297
+ },
298
+ "MappingConfigs": {
299
+ "type": "array",
300
+ "items": {
301
+ "$ref": "#/components/schemas/MappingConfig"
302
+ }
303
+ },
304
+ "MappingConfig": {
305
+ "type": "object",
306
+ "properties": {
307
+ "id": {
308
+ "type": "string"
309
+ },
310
+ "org_id": {
311
+ "type": "string"
312
+ },
313
+ "version": {
314
+ "type": "number"
315
+ },
316
+ "source": {
317
+ "$ref": "#/components/schemas/SourceConfig"
318
+ },
319
+ "targets": {
320
+ "type": "array",
321
+ "items": {
322
+ "$ref": "#/components/schemas/TargetConfig"
323
+ }
324
+ },
325
+ "created_at": {
326
+ "type": "string",
327
+ "format": "date-time"
328
+ },
329
+ "updated_at": {
330
+ "type": "string",
331
+ "format": "date-time"
332
+ },
333
+ "created_by": {
334
+ "$ref": "#/components/schemas/Owner",
335
+ "description": "User / service who created the entity mapping config",
336
+ "example": {
337
+ "type": "internal_service"
338
+ }
339
+ },
340
+ "last_updated_by": {
341
+ "$ref": "#/components/schemas/Owner",
342
+ "description": "User / service who last updated entity mapping config",
343
+ "example": {
344
+ "type": "user",
345
+ "org_id": 255151,
346
+ "user_id": 99252
347
+ }
348
+ }
349
+ },
350
+ "required": [
351
+ "id",
352
+ "org_id",
353
+ "version",
354
+ "source",
355
+ "targets"
356
+ ]
357
+ },
358
+ "Owner": {
359
+ "type": "object",
360
+ "properties": {
361
+ "type": {
362
+ "type": "string",
363
+ "enum": [
364
+ "user",
365
+ "internal_service"
366
+ ]
367
+ },
368
+ "org_id": {
369
+ "type": "string"
370
+ },
371
+ "user_id": {
372
+ "type": "string"
373
+ }
374
+ },
375
+ "required": [
376
+ "type"
377
+ ]
378
+ },
379
+ "ExecuteMappingReq": {
380
+ "type": "object",
381
+ "description": "Pass either source or source_entity",
382
+ "properties": {
383
+ "source": {
384
+ "$ref": "#/components/schemas/EntityRef"
385
+ },
386
+ "source_entity": {
387
+ "$ref": "#/components/schemas/Entity"
388
+ }
389
+ }
390
+ },
391
+ "ExecuteMappingResp": {
392
+ "type": "object",
393
+ "properties": {
394
+ "mapped_entities": {
395
+ "type": "array",
396
+ "items": {
397
+ "$ref": "#/components/schemas/Entity"
398
+ }
399
+ }
400
+ }
401
+ },
402
+ "Entity": {
403
+ "type": "object",
404
+ "properties": {
405
+ "_id": {
406
+ "type": "string"
407
+ },
408
+ "_schema": {
409
+ "type": "string"
410
+ }
411
+ },
412
+ "additionalProperties": true
413
+ },
414
+ "EntityRef": {
415
+ "type": "object",
416
+ "properties": {
417
+ "entity_id": {
418
+ "type": "string",
419
+ "description": "id of the source entity to be mapped"
420
+ },
421
+ "entity_schema": {
422
+ "description": "schema of the source entity",
423
+ "type": "string",
424
+ "example": "submission"
425
+ }
426
+ },
427
+ "required": [
428
+ "entity_id"
429
+ ]
430
+ },
431
+ "SourceConfig": {
432
+ "type": "object",
433
+ "properties": {
434
+ "type": {
435
+ "type": "string",
436
+ "enum": [
437
+ "journey",
438
+ "entity"
439
+ ]
440
+ },
441
+ "config": {
442
+ "anyOf": [
443
+ {
444
+ "$ref": "#/components/schemas/JourneyRef"
445
+ },
446
+ {
447
+ "$ref": "#/components/schemas/EntityRef"
448
+ }
449
+ ]
450
+ }
451
+ }
452
+ },
453
+ "JourneyRef": {
454
+ "type": "object",
455
+ "properties": {
456
+ "journey_id": {
457
+ "type": "string"
458
+ }
459
+ }
460
+ },
461
+ "TargetConfig": {
462
+ "type": "object",
463
+ "properties": {
464
+ "name": {
465
+ "type": "string",
466
+ "description": "A name for this configuration"
467
+ },
468
+ "target_schema": {
469
+ "type": "string",
470
+ "description": "Schema of target entity"
471
+ },
472
+ "target_unique": {
473
+ "type": "array",
474
+ "description": "Unique key for target entity (see upsertEntity of Entity API)",
475
+ "items": {
476
+ "type": "string"
477
+ }
478
+ },
479
+ "conditions": {
480
+ "type": "array",
481
+ "description": "Conditions necessary to hold for the target entity to be mapped",
482
+ "items": {
483
+ "$ref": "#/components/schemas/MapCondition"
484
+ }
485
+ },
486
+ "mapping_attributes": {
487
+ "type": "array",
488
+ "description": "Attribute mappings",
489
+ "items": {
490
+ "anyOf": [
491
+ {
492
+ "$ref": "#/components/schemas/MappingAttributeV2"
493
+ },
494
+ {
495
+ "$ref": "#/components/schemas/MappingAttribute"
496
+ }
497
+ ]
498
+ }
499
+ },
500
+ "relation_attributes": {
501
+ "type": "array",
502
+ "description": "Relation mappings",
503
+ "items": {
504
+ "$ref": "#/components/schemas/RelationAttribute"
505
+ }
506
+ },
507
+ "linkback_relation_attribute": {
508
+ "type": "string",
509
+ "default": "mapped_entities",
510
+ "description": "Relation attribute on the main entity where the target entity will be linked. Set to false to disable linkback\n"
511
+ },
512
+ "linkback_relation_tags": {
513
+ "type": "array",
514
+ "description": "Relation tags (labels) to include in main entity linkback relation attribute",
515
+ "items": {
516
+ "type": "string"
517
+ }
518
+ }
519
+ },
520
+ "required": [
521
+ "target_schema"
522
+ ]
523
+ },
524
+ "MapCondition": {
525
+ "type": "object",
526
+ "properties": {
527
+ "_exists": {
528
+ "$ref": "#/components/schemas/ConditionNode"
529
+ },
530
+ "_equals": {
531
+ "$ref": "#/components/schemas/ConditionNode"
532
+ },
533
+ "_not_exists": {
534
+ "$ref": "#/components/schemas/ConditionNode"
535
+ },
536
+ "_any_of": {
537
+ "$ref": "#/components/schemas/ConditionNode"
538
+ }
539
+ }
540
+ },
541
+ "ConditionNode": {
542
+ "type": "object",
543
+ "properties": {
544
+ "source": {
545
+ "type": "string"
546
+ },
547
+ "value": {
548
+ "oneOf": [
549
+ {
550
+ "type": "string"
551
+ },
552
+ {
553
+ "type": "number"
554
+ },
555
+ {
556
+ "type": "object"
557
+ },
558
+ {
559
+ "type": "array",
560
+ "items": {
561
+ "type": "object"
562
+ }
563
+ }
564
+ ]
565
+ }
566
+ }
567
+ },
568
+ "RelationAttribute": {
569
+ "type": "object",
570
+ "properties": {
571
+ "target": {
572
+ "type": "string",
573
+ "description": "Target attribute to store the relation in"
574
+ },
575
+ "target_tags": {
576
+ "type": "array",
577
+ "description": "Relation tags (labels) to set for the stored relations",
578
+ "items": {
579
+ "type": "string"
580
+ }
581
+ },
582
+ "target_tags_include_source": {
583
+ "type": "boolean",
584
+ "description": "Include all relation tags (labels) present on the main entity relation",
585
+ "default": false
586
+ },
587
+ "source_filter": {
588
+ "type": "object",
589
+ "description": "A filter to identify which source entities to pick as relations from main entity",
590
+ "properties": {
591
+ "limit": {
592
+ "type": "integer",
593
+ "description": "Limit relations to maximum number (default, all matched relations)",
594
+ "minimum": 0
595
+ },
596
+ "schema": {
597
+ "type": "string",
598
+ "description": "Filter by specific schema"
599
+ },
600
+ "attribute": {
601
+ "type": "string",
602
+ "description": "Filter by a specific relation attribute on the main entity"
603
+ },
604
+ "relation_tag": {
605
+ "type": "string",
606
+ "description": "Filter by relation tag (label) on the main entity"
607
+ },
608
+ "tag": {
609
+ "type": "string",
610
+ "description": "Filter by a specific tag on the related entity"
611
+ },
612
+ "self": {
613
+ "type": "boolean",
614
+ "description": "Picks main entity as relation (overrides other filters)",
615
+ "default": false
616
+ }
617
+ }
618
+ },
619
+ "related_to": {
620
+ "type": "object",
621
+ "additionalProperties": true,
622
+ "deprecated": true
623
+ },
624
+ "mode": {
625
+ "type": "string",
626
+ "enum": [
627
+ "append",
628
+ "prepend",
629
+ "set"
630
+ ]
631
+ }
632
+ },
633
+ "required": [
634
+ "target",
635
+ "mode"
636
+ ]
637
+ },
638
+ "MappingAttributeV2": {
639
+ "type": "object",
640
+ "properties": {
641
+ "target": {
642
+ "type": "string",
643
+ "description": "Target JSON path for the attribute to set"
644
+ },
645
+ "operation": {
646
+ "$ref": "#/components/schemas/OperationNode"
647
+ }
648
+ },
649
+ "required": [
650
+ "targetPath",
651
+ "operation"
652
+ ],
653
+ "example": {
654
+ "target": "_tags",
655
+ "operation": {
656
+ "_append": [
657
+ "new",
658
+ "tags"
659
+ ],
660
+ "_uniq": true
661
+ }
662
+ }
663
+ },
664
+ "OperationNode": {
665
+ "description": "Mapping operation nodes are either primitive values or operation node objects",
666
+ "oneOf": [
667
+ {
668
+ "$ref": "#/components/schemas/OperationObjectNode"
669
+ },
670
+ {
671
+ "$ref": "#/components/schemas/PrimitiveJSONValue"
672
+ }
673
+ ]
674
+ },
675
+ "OperationObjectNode": {
676
+ "type": "object",
677
+ "properties": {
678
+ "_set": {
679
+ "$ref": "#/components/schemas/PrimitiveJSONValue"
680
+ },
681
+ "_append": {
682
+ "description": "Append to array",
683
+ "items": {
684
+ "$ref": "#/components/schemas/PrimitiveJSONValue"
685
+ }
686
+ },
687
+ "_uniq": {
688
+ "description": "Unique array",
689
+ "oneOf": [
690
+ {
691
+ "type": "boolean",
692
+ "example": true
693
+ },
694
+ {
695
+ "type": "array",
696
+ "description": "Unique key consisting of object keys",
697
+ "example": [
698
+ "email"
699
+ ],
700
+ "items": {
701
+ "type": "string"
702
+ }
703
+ }
704
+ ]
705
+ },
706
+ "_copy": {
707
+ "description": "Copy JSONPath value from source entity context",
708
+ "type": "string",
709
+ "example": "contact.first_name"
710
+ }
711
+ },
712
+ "additionalProperties": true
713
+ },
714
+ "PrimitiveJSONValue": {
715
+ "description": "Represents any primitive JSON value",
716
+ "anyOf": [
717
+ {
718
+ "type": "string"
719
+ },
720
+ {
721
+ "type": "boolean"
722
+ },
723
+ {
724
+ "type": "number"
725
+ },
726
+ {
727
+ "type": "object",
728
+ "additionalProperties": true
729
+ },
730
+ {
731
+ "type": "array"
732
+ }
733
+ ]
734
+ },
735
+ "MappingAttribute": {
736
+ "anyOf": [
737
+ {
738
+ "$ref": "#/components/schemas/SetValueMapper"
739
+ },
740
+ {
741
+ "$ref": "#/components/schemas/CopyValueMapper"
742
+ },
743
+ {
744
+ "$ref": "#/components/schemas/AppendValueMapper"
745
+ }
746
+ ]
747
+ },
748
+ "MappingAttributeMode": {
749
+ "type": "string",
750
+ "enum": [
751
+ "copy_if_exists",
752
+ "append_if_exists",
753
+ "set_value"
754
+ ],
755
+ "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.\n"
756
+ },
757
+ "SetValueMapper": {
758
+ "type": "object",
759
+ "deprecated": true,
760
+ "properties": {
761
+ "mode": {
762
+ "$ref": "#/components/schemas/MappingAttributeMode"
763
+ },
764
+ "target": {
765
+ "type": "string",
766
+ "description": "JSON like target path for the attribute. Eg. last_name"
767
+ },
768
+ "value": {
769
+ "description": "Any value to be set: string, number, string[], number[], JSON object, etc. It will override existing values, if any.\n"
770
+ }
771
+ },
772
+ "required": [
773
+ "mode",
774
+ "target",
775
+ "value"
776
+ ]
777
+ },
778
+ "CopyValueMapper": {
779
+ "type": "object",
780
+ "deprecated": true,
781
+ "properties": {
782
+ "mode": {
783
+ "$ref": "#/components/schemas/MappingAttributeMode"
784
+ },
785
+ "target": {
786
+ "type": "string",
787
+ "description": "JSON like target path for the attribute. Eg. last_name"
788
+ },
789
+ "source": {
790
+ "type": "string",
791
+ "description": "JSON source path for the value to be extracted from the main entity. Eg: steps[1].['Product Info'].price\n"
792
+ }
793
+ },
794
+ "required": [
795
+ "mode",
796
+ "target",
797
+ "source"
798
+ ]
799
+ },
800
+ "AppendValueMapper": {
801
+ "type": "object",
802
+ "deprecated": true,
803
+ "properties": {
804
+ "mode": {
805
+ "$ref": "#/components/schemas/MappingAttributeMode"
806
+ },
807
+ "target": {
808
+ "type": "string",
809
+ "description": "JSON like target path for the attribute. Eg. last_name"
810
+ },
811
+ "source": {
812
+ "type": "string",
813
+ "description": "JSON source path for the value to be extracted from the main entity. Eg: steps[1].['Product Info'].price\n"
814
+ },
815
+ "value_json": {
816
+ "type": "string",
817
+ "description": "To be provided only when mapping json objects into a target attribute. Eg array of addresses.\n"
818
+ },
819
+ "target_unique": {
820
+ "type": "array",
821
+ "items": {
822
+ "type": "string"
823
+ },
824
+ "description": "Array of keys which should be used when checking for uniqueness. Eg: [country, city, postal_code]\n"
825
+ }
826
+ },
827
+ "required": [
828
+ "mode",
829
+ "target",
830
+ "value_json"
831
+ ]
832
+ }
833
+ }
834
+ },
835
+ "servers": [
836
+ {
837
+ "url": "null"
838
+ }
839
+ ]
840
+ }