@epilot/entity-mapping-client 0.0.1-alpha.0 → 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 epilot GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -1 +1 @@
1
- (()=>{"use strict";var e={914:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var r=n(i(534));t.default=r.default},534:e=>{e.exports=JSON.parse('{"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"],"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":"uuidv4"}}],"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":"uuidv4"}}],"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":"uuidv4"}}],"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":"uuidv4"}}],"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}:execute":{"post":{"operationId":"executeMapping","summary":"executeMapping","description":"Execute entity mapping based on a config","parameters":[{"name":"id","in":"path","required":true,"description":"Mapping Config Id","schema":{"type":"string","example":"uuidv4"}}],"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"}}}}}}}},"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":{"type":"object","properties":{"id":{"type":"string"},"org_id":{"type":"string"},"version":{"type":"number"},"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","org_id","version","source","targets"]},"Owner":{"type":"object","properties":{"type":{"type":"string","enum":["user","internal_service"]},"org_id":{"type":"string"},"user_id":{"type":"string"}},"required":["type"]},"ExecuteMappingReq":{"type":"object","description":"Pass either source or source_entity","properties":{"source":{"$ref":"#/components/schemas/EntityRef"},"source_entity":{"$ref":"#/components/schemas/Entity"}}},"ExecuteMappingResp":{"type":"object","properties":{"mapped_entities":{"type":"array","items":{"$ref":"#/components/schemas/Entity"}}}},"Entity":{"type":"object","properties":{"_id":{"type":"string"},"_schema":{"type":"string"}},"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"}}},"TargetConfig":{"type":"object","properties":{"name":{"type":"string","description":"A name for this configuration"},"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"}},"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\\n"},"linkback_relation_tags":{"type":"array","description":"Relation tags (labels) to include in main entity linkback relation attribute","items":{"type":"string"}}},"required":["target_schema"]},"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"]}},"required":["target","mode"]},"MappingAttributeV2":{"type":"object","properties":{"target":{"type":"string","description":"Target JSON path for the attribute to set"},"operation":{"$ref":"#/components/schemas/OperationNode"}},"required":["targetPath","operation"],"example":{"target":"_tags","operation":{"_append":["new","tags"],"_uniq":true}}},"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"}},"additionalProperties":true},"PrimitiveJSONValue":{"description":"Represents any primitive JSON value","anyOf":[{"type":"string"},{"type":"boolean"},{"type":"number"},{"type":"object","additionalProperties":true},{"type":"array"}]},"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.\\n"},"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.\\n"}},"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\\n"}},"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\\n"},"value_json":{"type":"string","description":"To be provided only when mapping json objects into a target attribute. Eg array of addresses.\\n"},"target_unique":{"type":"array","items":{"type":"string"},"description":"Array of keys which should be used when checking for uniqueness. Eg: [country, city, postal_code]\\n"}},"required":["mode","target","value_json"]}}},"servers":[{"url":"null"}]}')}},t={},i=function i(n){var r=t[n];if(void 0!==r)return r.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,i),o.exports}(914),n=exports;for(var r in i)n[r]=i[r];i.__esModule&&Object.defineProperty(n,"__esModule",{value:!0})})();
1
+ (()=>{"use strict";var e={914:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var r=n(i(534));t.default=r.default},534:e=>{e.exports=JSON.parse('{"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"],"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":"uuidv4"}}],"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":"uuidv4"}}],"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":"uuidv4"}}],"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":"uuidv4"}}],"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: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/{id}/history":{"get":{"operationId":"getMappingHistory","summary":"getMappingHistory","description":"Get the Mapping History","tags":["history"],"parameters":[{"in":"path","name":"id","schema":{"type":"string"},"required":true,"description":"the id of the mapping"},{"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"}],"responses":{"200":{"description":"Query result of mapping history","content":{"application/json":{"schema":{"properties":{"results":{"type":"array","items":{"$ref":"#/components/schemas/MappingHistoryResponse"}}}}}}}}}}},"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":{"type":"object","properties":{"id":{"type":"string"},"org_id":{"type":"string"},"version":{"type":"number"},"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","org_id","version","source","targets"]},"Owner":{"type":"object","properties":{"type":{"type":"string","enum":["user","internal_service"]},"org_id":{"type":"string"},"user_id":{"type":"string"}},"required":["type"]},"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"}}},"required":["mapped_entities"]},"MappingFailure":{"type":"object","properties":{"target":{"$ref":"#/components/schemas/TargetConfig"},"error":{"type":"object","properties":{"message":{"type":"string"}},"additionalProperties":true}}},"Entity":{"type":"object","properties":{"_id":{"type":"string"},"_schema":{"type":"string"},"_title":{"type":"string"},"_org":{"type":"string"},"_tags":{"type":"array","items":{"type":"string"}},"_created_at":{"type":"string"},"_updated_at":{"type":"string"}},"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"}}},"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"}},"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\\n"},"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"]}},"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":["targetPath","operation"],"example":{"target":"_tags","operation":{"_append":["new","tags"],"_uniq":true}}},"AttributeOrigin":{"type":"string","description":"Origin of an attribute.","enum":["system_recommendation","user_manually"]},"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"}},"additionalProperties":true},"PrimitiveJSONValue":{"description":"Represents any primitive JSON value","anyOf":[{"type":"string"},{"type":"boolean"},{"type":"number"},{"type":"object","additionalProperties":true},{"type":"array"}]},"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.\\n"},"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.\\n"}},"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\\n"}},"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\\n"},"value_json":{"type":"string","description":"To be provided only when mapping json objects into a target attribute. Eg array of addresses.\\n"},"target_unique":{"type":"array","items":{"type":"string"},"description":"Array of keys which should be used when checking for uniqueness. Eg: [country, city, postal_code]\\n"}},"required":["mode","target","value_json"]},"MappingHistoryResponse":{"type":"object","properties":{"configId":{"type":"string","example":"source#entity_id"},"timestamp":{"type":"string","format":"datetime"},"version":{"type":"string","example":"v1"},"attributes":{"type":"object"}}}}},"servers":[{"url":"null"}]}')}},t={},i=function i(n){var r=t[n];if(void 0!==r)return r.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,i),s.exports}(914),n=exports;for(var r in i)n[r]=i[r];i.__esModule&&Object.defineProperty(n,"__esModule",{value:!0})})();
package/dist/openapi.d.ts CHANGED
@@ -35,6 +35,10 @@ declare namespace Components {
35
35
  */
36
36
  target_unique?: string[];
37
37
  }
38
+ /**
39
+ * Origin of an attribute.
40
+ */
41
+ export type AttributeOrigin = "system_recommendation" | "user_manually";
38
42
  export interface ConditionNode {
39
43
  source?: string;
40
44
  value?: string | number | {
@@ -63,6 +67,11 @@ declare namespace Components {
63
67
  [name: string]: any;
64
68
  _id?: string;
65
69
  _schema?: string;
70
+ _title?: string;
71
+ _org?: string;
72
+ _tags?: string[];
73
+ _created_at?: string;
74
+ _updated_at?: string;
66
75
  }
67
76
  export interface EntityRef {
68
77
  /**
@@ -80,11 +89,18 @@ declare namespace Components {
80
89
  * Pass either source or source_entity
81
90
  */
82
91
  export interface ExecuteMappingReq {
83
- source?: EntityRef;
84
- source_entity?: Entity;
92
+ /**
93
+ * A reference (id and schema) to the entity to be used as source.
94
+ */
95
+ source_ref: EntityRef;
96
+ /**
97
+ * Mapping Configuration to apply.
98
+ */
99
+ targets: TargetConfig[];
85
100
  }
86
101
  export interface ExecuteMappingResp {
87
- mapped_entities?: Entity[];
102
+ mapped_entities: Entity[];
103
+ failures?: MappingFailure[];
88
104
  }
89
105
  export interface JourneyRef {
90
106
  journey_id?: string;
@@ -120,6 +136,7 @@ declare namespace Components {
120
136
  */
121
137
  target?: string;
122
138
  operation: /* Mapping operation nodes are either primitive values or operation node objects */ OperationNode;
139
+ origin?: /* Origin of an attribute. */ AttributeOrigin;
123
140
  }
124
141
  export interface MappingConfig {
125
142
  id: string;
@@ -152,6 +169,29 @@ declare namespace Components {
152
169
  export interface MappingConfigsResp {
153
170
  configs: MappingConfigs;
154
171
  }
172
+ export interface MappingFailure {
173
+ target?: TargetConfig;
174
+ error?: {
175
+ [name: string]: any;
176
+ message?: string;
177
+ };
178
+ }
179
+ export interface MappingHistoryResponse {
180
+ /**
181
+ * example:
182
+ * source#entity_id
183
+ */
184
+ configId?: string;
185
+ timestamp?: string; // datetime
186
+ /**
187
+ * example:
188
+ * v1
189
+ */
190
+ version?: string;
191
+ attributes?: {
192
+ [key: string]: any;
193
+ };
194
+ }
155
195
  /**
156
196
  * Mapping operation nodes are either primitive values or operation node objects
157
197
  */
@@ -256,10 +296,18 @@ declare namespace Components {
256
296
  config?: JourneyRef | EntityRef;
257
297
  }
258
298
  export interface TargetConfig {
299
+ /**
300
+ * Identifier for target configuration. Useful for later usages when trying to identify which target config to map to.
301
+ */
302
+ id?: string;
259
303
  /**
260
304
  * A name for this configuration
261
305
  */
262
306
  name?: string;
307
+ /**
308
+ * Pass it as true, when you don't want failures to interrupt the mapping process.
309
+ */
310
+ allow_failure?: boolean;
263
311
  /**
264
312
  * Schema of target entity
265
313
  */
@@ -275,7 +323,7 @@ declare namespace Components {
275
323
  /**
276
324
  * Attribute mappings
277
325
  */
278
- mapping_attributes?: (/**
326
+ mapping_attributes: (/**
279
327
  * example:
280
328
  * {
281
329
  * "target": "_tags",
@@ -329,16 +377,16 @@ declare namespace Paths {
329
377
  namespace Parameters {
330
378
  /**
331
379
  * example:
332
- * uuidv4
380
+ * true
333
381
  */
334
- export type Id = string;
382
+ export type PreviewMode = boolean;
335
383
  }
336
- export interface PathParameters {
337
- id: /**
384
+ export interface QueryParameters {
385
+ preview_mode?: /**
338
386
  * example:
339
- * uuidv4
387
+ * true
340
388
  */
341
- Parameters.Id;
389
+ Parameters.PreviewMode;
342
390
  }
343
391
  export type RequestBody = /* Pass either source or source_entity */ Components.Schemas.ExecuteMappingReq;
344
392
  namespace Responses {
@@ -383,6 +431,25 @@ declare namespace Paths {
383
431
  export type $200 = Components.Schemas.MappingConfig;
384
432
  }
385
433
  }
434
+ namespace GetMappingHistory {
435
+ namespace Parameters {
436
+ export type From = string; // datetime
437
+ export type Id = string;
438
+ export type To = string; // datetime
439
+ }
440
+ export interface PathParameters {
441
+ id: Parameters.Id;
442
+ }
443
+ export interface QueryParameters {
444
+ from?: Parameters.From /* datetime */;
445
+ to?: Parameters.To /* datetime */;
446
+ }
447
+ namespace Responses {
448
+ export interface $200 {
449
+ results?: Components.Schemas.MappingHistoryResponse[];
450
+ }
451
+ }
452
+ }
386
453
  namespace SearchConfigs {
387
454
  export type RequestBody = Components.Schemas.SearchMappingReq;
388
455
  namespace Responses {
@@ -474,7 +541,7 @@ export interface OperationMethods {
474
541
  * Execute entity mapping based on a config
475
542
  */
476
543
  'executeMapping'(
477
- parameters?: Parameters<Paths.ExecuteMapping.PathParameters> | null,
544
+ parameters?: Parameters<Paths.ExecuteMapping.QueryParameters> | null,
478
545
  data?: Paths.ExecuteMapping.RequestBody,
479
546
  config?: AxiosRequestConfig
480
547
  ): OperationResponse<Paths.ExecuteMapping.Responses.$200>
@@ -488,6 +555,16 @@ export interface OperationMethods {
488
555
  data?: Paths.SearchConfigs.RequestBody,
489
556
  config?: AxiosRequestConfig
490
557
  ): OperationResponse<Paths.SearchConfigs.Responses.$200>
558
+ /**
559
+ * getMappingHistory - getMappingHistory
560
+ *
561
+ * Get the Mapping History
562
+ */
563
+ 'getMappingHistory'(
564
+ parameters?: Parameters<Paths.GetMappingHistory.PathParameters & Paths.GetMappingHistory.QueryParameters> | null,
565
+ data?: any,
566
+ config?: AxiosRequestConfig
567
+ ): OperationResponse<Paths.GetMappingHistory.Responses.$200>
491
568
  }
492
569
 
493
570
  export interface PathsDictionary {
@@ -547,14 +624,14 @@ export interface PathsDictionary {
547
624
  config?: AxiosRequestConfig
548
625
  ): OperationResponse<Paths.StoreNewVersion.Responses.$200>
549
626
  }
550
- ['/v1/mappings/{id}:execute']: {
627
+ ['/v1/mappings:execute']: {
551
628
  /**
552
629
  * executeMapping - executeMapping
553
630
  *
554
631
  * Execute entity mapping based on a config
555
632
  */
556
633
  'post'(
557
- parameters?: Parameters<Paths.ExecuteMapping.PathParameters> | null,
634
+ parameters?: Parameters<Paths.ExecuteMapping.QueryParameters> | null,
558
635
  data?: Paths.ExecuteMapping.RequestBody,
559
636
  config?: AxiosRequestConfig
560
637
  ): OperationResponse<Paths.ExecuteMapping.Responses.$200>
@@ -571,6 +648,18 @@ export interface PathsDictionary {
571
648
  config?: AxiosRequestConfig
572
649
  ): OperationResponse<Paths.SearchConfigs.Responses.$200>
573
650
  }
651
+ ['/v1/mappings/{id}/history']: {
652
+ /**
653
+ * getMappingHistory - getMappingHistory
654
+ *
655
+ * Get the Mapping History
656
+ */
657
+ 'get'(
658
+ parameters?: Parameters<Paths.GetMappingHistory.PathParameters & Paths.GetMappingHistory.QueryParameters> | null,
659
+ data?: any,
660
+ config?: AxiosRequestConfig
661
+ ): OperationResponse<Paths.GetMappingHistory.Responses.$200>
662
+ }
574
663
  }
575
664
 
576
665
  export type Client = OpenAPIClient<OperationMethods, PathsDictionary>
package/dist/openapi.json CHANGED
@@ -191,20 +191,20 @@
191
191
  }
192
192
  }
193
193
  },
194
- "/v1/mappings/{id}:execute": {
194
+ "/v1/mappings:execute": {
195
195
  "post": {
196
196
  "operationId": "executeMapping",
197
197
  "summary": "executeMapping",
198
198
  "description": "Execute entity mapping based on a config",
199
199
  "parameters": [
200
200
  {
201
- "name": "id",
202
- "in": "path",
203
- "required": true,
204
- "description": "Mapping Config Id",
201
+ "name": "preview_mode",
202
+ "in": "query",
203
+ "required": false,
204
+ "description": "True, if you want to preview the entities which will result",
205
205
  "schema": {
206
- "type": "string",
207
- "example": "uuidv4"
206
+ "type": "boolean",
207
+ "example": true
208
208
  }
209
209
  }
210
210
  ],
@@ -265,6 +265,66 @@
265
265
  }
266
266
  }
267
267
  }
268
+ },
269
+ "/v1/mappings/{id}/history": {
270
+ "get": {
271
+ "operationId": "getMappingHistory",
272
+ "summary": "getMappingHistory",
273
+ "description": "Get the Mapping History",
274
+ "tags": [
275
+ "history"
276
+ ],
277
+ "parameters": [
278
+ {
279
+ "in": "path",
280
+ "name": "id",
281
+ "schema": {
282
+ "type": "string"
283
+ },
284
+ "required": true,
285
+ "description": "the id of the mapping"
286
+ },
287
+ {
288
+ "in": "query",
289
+ "name": "from",
290
+ "schema": {
291
+ "type": "string",
292
+ "format": "datetime"
293
+ },
294
+ "required": false,
295
+ "description": "filter the history from this date on"
296
+ },
297
+ {
298
+ "in": "query",
299
+ "name": "to",
300
+ "schema": {
301
+ "type": "string",
302
+ "format": "datetime"
303
+ },
304
+ "required": false,
305
+ "description": "filter the history to this date on"
306
+ }
307
+ ],
308
+ "responses": {
309
+ "200": {
310
+ "description": "Query result of mapping history",
311
+ "content": {
312
+ "application/json": {
313
+ "schema": {
314
+ "properties": {
315
+ "results": {
316
+ "type": "array",
317
+ "items": {
318
+ "$ref": "#/components/schemas/MappingHistoryResponse"
319
+ }
320
+ }
321
+ }
322
+ }
323
+ }
324
+ }
325
+ }
326
+ }
327
+ }
268
328
  }
269
329
  },
270
330
  "components": {
@@ -380,13 +440,22 @@
380
440
  "type": "object",
381
441
  "description": "Pass either source or source_entity",
382
442
  "properties": {
383
- "source": {
384
- "$ref": "#/components/schemas/EntityRef"
443
+ "source_ref": {
444
+ "$ref": "#/components/schemas/EntityRef",
445
+ "description": "A reference (id and schema) to the entity to be used as source."
385
446
  },
386
- "source_entity": {
387
- "$ref": "#/components/schemas/Entity"
447
+ "targets": {
448
+ "type": "array",
449
+ "items": {
450
+ "$ref": "#/components/schemas/TargetConfig"
451
+ },
452
+ "description": "Mapping Configuration to apply."
388
453
  }
389
- }
454
+ },
455
+ "required": [
456
+ "source_ref",
457
+ "targets"
458
+ ]
390
459
  },
391
460
  "ExecuteMappingResp": {
392
461
  "type": "object",
@@ -396,6 +465,32 @@
396
465
  "items": {
397
466
  "$ref": "#/components/schemas/Entity"
398
467
  }
468
+ },
469
+ "failures": {
470
+ "type": "array",
471
+ "items": {
472
+ "$ref": "#/components/schemas/MappingFailure"
473
+ }
474
+ }
475
+ },
476
+ "required": [
477
+ "mapped_entities"
478
+ ]
479
+ },
480
+ "MappingFailure": {
481
+ "type": "object",
482
+ "properties": {
483
+ "target": {
484
+ "$ref": "#/components/schemas/TargetConfig"
485
+ },
486
+ "error": {
487
+ "type": "object",
488
+ "properties": {
489
+ "message": {
490
+ "type": "string"
491
+ }
492
+ },
493
+ "additionalProperties": true
399
494
  }
400
495
  }
401
496
  },
@@ -407,6 +502,24 @@
407
502
  },
408
503
  "_schema": {
409
504
  "type": "string"
505
+ },
506
+ "_title": {
507
+ "type": "string"
508
+ },
509
+ "_org": {
510
+ "type": "string"
511
+ },
512
+ "_tags": {
513
+ "type": "array",
514
+ "items": {
515
+ "type": "string"
516
+ }
517
+ },
518
+ "_created_at": {
519
+ "type": "string"
520
+ },
521
+ "_updated_at": {
522
+ "type": "string"
410
523
  }
411
524
  },
412
525
  "additionalProperties": true
@@ -461,10 +574,18 @@
461
574
  "TargetConfig": {
462
575
  "type": "object",
463
576
  "properties": {
577
+ "id": {
578
+ "type": "string",
579
+ "description": "Identifier for target configuration. Useful for later usages when trying to identify which target config to map to."
580
+ },
464
581
  "name": {
465
582
  "type": "string",
466
583
  "description": "A name for this configuration"
467
584
  },
585
+ "allow_failure": {
586
+ "type": "boolean",
587
+ "description": "Pass it as true, when you don't want failures to interrupt the mapping process."
588
+ },
468
589
  "target_schema": {
469
590
  "type": "string",
470
591
  "description": "Schema of target entity"
@@ -518,7 +639,8 @@
518
639
  }
519
640
  },
520
641
  "required": [
521
- "target_schema"
642
+ "target_schema",
643
+ "mapping_attributes"
522
644
  ]
523
645
  },
524
646
  "MapCondition": {
@@ -644,6 +766,9 @@
644
766
  },
645
767
  "operation": {
646
768
  "$ref": "#/components/schemas/OperationNode"
769
+ },
770
+ "origin": {
771
+ "$ref": "#/components/schemas/AttributeOrigin"
647
772
  }
648
773
  },
649
774
  "required": [
@@ -661,6 +786,14 @@
661
786
  }
662
787
  }
663
788
  },
789
+ "AttributeOrigin": {
790
+ "type": "string",
791
+ "description": "Origin of an attribute.",
792
+ "enum": [
793
+ "system_recommendation",
794
+ "user_manually"
795
+ ]
796
+ },
664
797
  "OperationNode": {
665
798
  "description": "Mapping operation nodes are either primitive values or operation node objects",
666
799
  "oneOf": [
@@ -829,6 +962,26 @@
829
962
  "target",
830
963
  "value_json"
831
964
  ]
965
+ },
966
+ "MappingHistoryResponse": {
967
+ "type": "object",
968
+ "properties": {
969
+ "configId": {
970
+ "type": "string",
971
+ "example": "source#entity_id"
972
+ },
973
+ "timestamp": {
974
+ "type": "string",
975
+ "format": "datetime"
976
+ },
977
+ "version": {
978
+ "type": "string",
979
+ "example": "v1"
980
+ },
981
+ "attributes": {
982
+ "type": "object"
983
+ }
984
+ }
832
985
  }
833
986
  }
834
987
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epilot/entity-mapping-client",
3
- "version": "0.0.1-alpha.0",
3
+ "version": "0.0.1",
4
4
  "description": "JavaScript client library for the ePilot Entity Mapping API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -72,5 +72,6 @@
72
72
  "typescript": "^4.1.3",
73
73
  "webpack": "^5.18.0",
74
74
  "webpack-cli": "^4.4.0"
75
- }
75
+ },
76
+ "gitHead": "a00557cc68f2e87db088ac7a84bea09471348907"
76
77
  }