@epilot/erp-integration-client 0.9.0 → 0.10.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.
@@ -1 +1 @@
1
- (()=>{"use strict";var e={390:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var s=n(r(466));t.default=s.default},466:e=>{e.exports=JSON.parse('{"openapi":"3.0.3","info":{"title":"","version":""},"paths":{"/v1/erp/tracking/acknowledgement":{"post":{"operationId":"acknowledgeTracking","requestBody":{"content":{"application/json":{}}},"responses":{}}},"/v1/erp/trigger":{"post":{"operationId":"triggerErp","requestBody":{"required":true,"content":{"application/json":{}}},"responses":{}}},"/v1/erp/updates/events":{"post":{"operationId":"processErpUpdatesEvents","requestBody":{"content":{"application/json":{}}},"responses":{}}},"/v2/erp/updates/events":{"post":{"operationId":"processErpUpdatesEventsV2","requestBody":{"content":{"application/json":{}}},"responses":{}}},"/v1/erp/updates/mapping_simulation":{"post":{"operationId":"simulateMapping","requestBody":{"required":true,"content":{"application/json":{}}},"responses":{}}},"/v1/integrations":{"get":{"operationId":"listIntegrations","responses":{}},"post":{"operationId":"createIntegration","requestBody":{"required":true,"content":{"application/json":{}}},"responses":{}}},"/v1/integrations/{integrationId}":{"get":{"operationId":"getIntegration","parameters":[{"name":"integrationId","in":"path","required":true}],"responses":{}},"put":{"operationId":"updateIntegration","parameters":[{"name":"integrationId","in":"path","required":true}],"requestBody":{"required":true,"content":{"application/json":{}}},"responses":{}},"delete":{"operationId":"deleteIntegration","parameters":[{"name":"integrationId","in":"path","required":true}],"responses":{}}},"/v1/integrations/{integrationId}/use-cases":{"get":{"operationId":"listUseCases","parameters":[{"name":"integrationId","in":"path","required":true}],"responses":{}},"post":{"operationId":"createUseCase","parameters":[{"name":"integrationId","in":"path","required":true}],"requestBody":{"required":true,"content":{"application/json":{}}},"responses":{}}},"/v1/integrations/{integrationId}/use-cases/{useCaseId}":{"get":{"operationId":"getUseCase","parameters":[{"name":"integrationId","in":"path","required":true},{"name":"useCaseId","in":"path","required":true}],"responses":{}},"put":{"operationId":"updateUseCase","parameters":[{"name":"integrationId","in":"path","required":true},{"name":"useCaseId","in":"path","required":true}],"requestBody":{"required":true,"content":{"application/json":{}}},"responses":{}},"delete":{"operationId":"deleteUseCase","parameters":[{"name":"integrationId","in":"path","required":true},{"name":"useCaseId","in":"path","required":true}],"responses":{}}},"/v1/integrations/{integrationId}/use-cases/{useCaseId}/history":{"get":{"operationId":"listUseCaseHistory","parameters":[{"name":"integrationId","in":"path","required":true},{"name":"useCaseId","in":"path","required":true},{"name":"cursor","in":"query","required":false}],"responses":{}}},"/v1/integrations/{integrationId}/app-mapping":{"put":{"operationId":"setIntegrationAppMapping","parameters":[{"name":"integrationId","in":"path","required":true}],"requestBody":{"required":true,"content":{"application/json":{}}},"responses":{}},"delete":{"operationId":"deleteIntegrationAppMapping","parameters":[{"name":"integrationId","in":"path","required":true}],"requestBody":{"required":true,"content":{"application/json":{}}},"responses":{}}}},"components":{"responses":{"BadRequest":{"content":{"application/json":{}}},"Unauthorized":{"content":{"application/json":{}}},"InternalServerError":{"content":{"application/json":{}}},"ERPUpdatesResponse":{"content":{"application/json":{}}},"TriggerWebhookResponse":{"content":{"application/json":{}}}}},"servers":[{"url":"https://erp-integration-api.sls.epilot.io"}]}')}},t={},r=function r(n){var s=t[n];if(void 0!==s)return s.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}(390),n=exports;for(var s in r)n[s]=r[s];r.__esModule&&Object.defineProperty(n,"__esModule",{value:!0})})();
1
+ (()=>{"use strict";var e={330:function(e,t,n){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var s=r(n(466));t.default=s.default},466:e=>{e.exports=JSON.parse('{"openapi":"3.0.3","info":{"title":"","version":""},"paths":{"/v1/erp/tracking/acknowledgement":{"post":{"operationId":"acknowledgeTracking","requestBody":{"content":{"application/json":{}}},"responses":{}}},"/v1/erp/trigger":{"post":{"operationId":"triggerErp","requestBody":{"required":true,"content":{"application/json":{}}},"responses":{}}},"/v1/erp/updates/events":{"post":{"operationId":"processErpUpdatesEvents","requestBody":{"content":{"application/json":{}}},"responses":{}}},"/v2/erp/updates/events":{"post":{"operationId":"processErpUpdatesEventsV2","requestBody":{"content":{"application/json":{}}},"responses":{}}},"/v2/erp/updates/mapping_simulation":{"post":{"operationId":"simulateMappingV2","requestBody":{"required":true,"content":{"application/json":{}}},"responses":{}}},"/v1/erp/updates/mapping_simulation":{"post":{"operationId":"simulateMapping","requestBody":{"required":true,"content":{"application/json":{}}},"responses":{}}},"/v1/integrations":{"get":{"operationId":"listIntegrations","responses":{}},"post":{"operationId":"createIntegration","requestBody":{"required":true,"content":{"application/json":{}}},"responses":{}}},"/v1/integrations/{integrationId}":{"get":{"operationId":"getIntegration","parameters":[{"name":"integrationId","in":"path","required":true}],"responses":{}},"put":{"operationId":"updateIntegration","parameters":[{"name":"integrationId","in":"path","required":true}],"requestBody":{"required":true,"content":{"application/json":{}}},"responses":{}},"delete":{"operationId":"deleteIntegration","parameters":[{"name":"integrationId","in":"path","required":true}],"responses":{}}},"/v1/integrations/{integrationId}/use-cases":{"get":{"operationId":"listUseCases","parameters":[{"name":"integrationId","in":"path","required":true}],"responses":{}},"post":{"operationId":"createUseCase","parameters":[{"name":"integrationId","in":"path","required":true}],"requestBody":{"required":true,"content":{"application/json":{}}},"responses":{}}},"/v1/integrations/{integrationId}/use-cases/{useCaseId}":{"get":{"operationId":"getUseCase","parameters":[{"name":"integrationId","in":"path","required":true},{"name":"useCaseId","in":"path","required":true}],"responses":{}},"put":{"operationId":"updateUseCase","parameters":[{"name":"integrationId","in":"path","required":true},{"name":"useCaseId","in":"path","required":true}],"requestBody":{"required":true,"content":{"application/json":{}}},"responses":{}},"delete":{"operationId":"deleteUseCase","parameters":[{"name":"integrationId","in":"path","required":true},{"name":"useCaseId","in":"path","required":true}],"responses":{}}},"/v1/integrations/{integrationId}/use-cases/{useCaseId}/history":{"get":{"operationId":"listUseCaseHistory","parameters":[{"name":"integrationId","in":"path","required":true},{"name":"useCaseId","in":"path","required":true},{"name":"cursor","in":"query","required":false}],"responses":{}}},"/v1/integrations/{integrationId}/app-mapping":{"put":{"operationId":"setIntegrationAppMapping","parameters":[{"name":"integrationId","in":"path","required":true}],"requestBody":{"required":true,"content":{"application/json":{}}},"responses":{}},"delete":{"operationId":"deleteIntegrationAppMapping","parameters":[{"name":"integrationId","in":"path","required":true}],"requestBody":{"required":true,"content":{"application/json":{}}},"responses":{}}}},"components":{"responses":{"BadRequest":{"content":{"application/json":{}}},"Unauthorized":{"content":{"application/json":{}}},"InternalServerError":{"content":{"application/json":{}}},"ERPUpdatesResponse":{"content":{"application/json":{}}},"TriggerWebhookResponse":{"content":{"application/json":{}}}}}}')}},t={},n=function n(r){var s=t[r];if(void 0!==s)return s.exports;var a=t[r]={exports:{}};return e[r].call(a.exports,a,a.exports,n),a.exports}(330),r=exports;for(var s in n)r[s]=n[s];n.__esModule&&Object.defineProperty(r,"__esModule",{value:!0})})();
@@ -50,6 +50,18 @@
50
50
  "responses": {}
51
51
  }
52
52
  },
53
+ "/v2/erp/updates/mapping_simulation": {
54
+ "post": {
55
+ "operationId": "simulateMappingV2",
56
+ "requestBody": {
57
+ "required": true,
58
+ "content": {
59
+ "application/json": {}
60
+ }
61
+ },
62
+ "responses": {}
63
+ }
64
+ },
53
65
  "/v1/erp/updates/mapping_simulation": {
54
66
  "post": {
55
67
  "operationId": "simulateMapping",
@@ -293,10 +305,5 @@
293
305
  }
294
306
  }
295
307
  }
296
- },
297
- "servers": [
298
- {
299
- "url": "https://erp-integration-api.sls.epilot.io"
300
- }
301
- ]
308
+ }
302
309
  }
package/dist/openapi.d.ts CHANGED
@@ -358,6 +358,13 @@ declare namespace Components {
358
358
  */
359
359
  enabled?: /* Controls whether this field mapping should be processed. Can be a boolean or a JSONata expression (string) that evaluates to a boolean. Defaults to true if omitted. */ boolean | string;
360
360
  relations?: RelationConfig;
361
+ relation_refs?: /**
362
+ * Configuration for relation references ($relation_ref).
363
+ * Relation references link to a specific item within a repeatable attribute on a related entity.
364
+ * Common use case: referencing a specific address within a contact's address list.
365
+ *
366
+ */
367
+ RelationRefsConfig;
361
368
  }
362
369
  export interface IntegrationFieldV1 {
363
370
  /**
@@ -427,6 +434,24 @@ declare namespace Components {
427
434
  entity_updates: EntityUpdate[];
428
435
  meter_readings_updates?: MeterReadingUpdate[];
429
436
  }
437
+ /**
438
+ * Request for v2 mapping simulation. Uses the same configuration format stored in integration use case resources,
439
+ * making it easier to test configurations before saving them.
440
+ *
441
+ */
442
+ export interface MappingSimulationV2Request {
443
+ event_configuration: /* Configuration for inbound use cases (ERP to epilot) */ InboundIntegrationEventConfiguration;
444
+ /**
445
+ * Format of the payload data
446
+ */
447
+ format: "json" | "xml";
448
+ /**
449
+ * The event data payload - can be either a serialized string or a direct JSON object
450
+ */
451
+ payload: /* The event data payload - can be either a serialized string or a direct JSON object */ string | {
452
+ [name: string]: any;
453
+ };
454
+ }
430
455
  export interface MeterReadingUpdate {
431
456
  meter: {
432
457
  /**
@@ -548,10 +573,11 @@ declare namespace Components {
548
573
  /**
549
574
  * Relation operation:
550
575
  * - '_set': Replace all existing relations with the specified items
551
- * - '_append': Add new items to existing relations (fetches current entity first)
576
+ * - '_append': Add new unique items to existing relations (deduplicates by entity_id)
577
+ * - '_append_all': Add all items to existing relations (no deduplication, allows duplicates)
552
578
  *
553
579
  */
554
- operation: "_set" | "_append";
580
+ operation: "_set" | "_append" | "_append_all";
555
581
  /**
556
582
  * Array of relation item configurations
557
583
  */
@@ -575,6 +601,77 @@ declare namespace Components {
575
601
  */
576
602
  unique_ids: RelationUniqueIdField[];
577
603
  }
604
+ /**
605
+ * Configuration for a single relation reference item
606
+ */
607
+ export interface RelationRefItemConfig {
608
+ /**
609
+ * Schema of the related entity (e.g., "contact")
610
+ */
611
+ entity_schema: string;
612
+ /**
613
+ * Unique identifier mappings for the related entity
614
+ */
615
+ unique_ids: RelationUniqueIdField[];
616
+ /**
617
+ * Attribute path on the related entity (e.g., "address")
618
+ */
619
+ path: string;
620
+ value: /* Configuration for the value to set on the related entity's attribute */ RelationRefValueConfig;
621
+ }
622
+ /**
623
+ * Configuration for the value to set on the related entity's attribute
624
+ */
625
+ export interface RelationRefValueConfig {
626
+ /**
627
+ * Target attribute name on the related entity
628
+ */
629
+ attribute: string;
630
+ /**
631
+ * Operation for the attribute value:
632
+ * - '_set': Replace the attribute value
633
+ * - '_append': Add new unique items (deduplicates)
634
+ * - '_append_all': Add all items (no deduplication)
635
+ *
636
+ */
637
+ operation?: "_set" | "_append" | "_append_all";
638
+ /**
639
+ * Source field name from the event data
640
+ */
641
+ field?: string;
642
+ /**
643
+ * JSONata expression to compute the value
644
+ */
645
+ jsonataExpression?: string;
646
+ /**
647
+ * Constant value (any type)
648
+ */
649
+ constant?: any;
650
+ }
651
+ /**
652
+ * Configuration for relation references ($relation_ref).
653
+ * Relation references link to a specific item within a repeatable attribute on a related entity.
654
+ * Common use case: referencing a specific address within a contact's address list.
655
+ *
656
+ */
657
+ export interface RelationRefsConfig {
658
+ /**
659
+ * Relation reference operation:
660
+ * - '_set': Replace all existing relation_refs with the specified items
661
+ * - '_append': Add new unique items to existing relation_refs (deduplicates by entity_id + _id)
662
+ * - '_append_all': Add all items to existing relation_refs (no deduplication, allows duplicates)
663
+ *
664
+ */
665
+ operation: "_set" | "_append" | "_append_all";
666
+ /**
667
+ * Array of relation reference item configurations
668
+ */
669
+ items?: /* Configuration for a single relation reference item */ RelationRefItemConfig[];
670
+ /**
671
+ * JSONata expression that returns relation_ref items array (alternative to 'items')
672
+ */
673
+ jsonataExpression?: string;
674
+ }
578
675
  export interface RelationUniqueIdField {
579
676
  /**
580
677
  * Target attribute name in the related entity
@@ -1026,6 +1123,21 @@ declare namespace Paths {
1026
1123
  export type $500 = Components.Responses.InternalServerError;
1027
1124
  }
1028
1125
  }
1126
+ namespace SimulateMappingV2 {
1127
+ export type RequestBody = /**
1128
+ * Request for v2 mapping simulation. Uses the same configuration format stored in integration use case resources,
1129
+ * making it easier to test configurations before saving them.
1130
+ *
1131
+ */
1132
+ Components.Schemas.MappingSimulationV2Request;
1133
+ namespace Responses {
1134
+ export type $200 = Components.Schemas.MappingSimulationResponse;
1135
+ export type $400 = Components.Responses.BadRequest;
1136
+ export type $401 = Components.Responses.Unauthorized;
1137
+ export type $422 = Components.Schemas.ErrorResponseBase;
1138
+ export type $500 = Components.Responses.InternalServerError;
1139
+ }
1140
+ }
1029
1141
  namespace TriggerErp {
1030
1142
  export type RequestBody = Components.Schemas.TriggerErpActionRequest;
1031
1143
  namespace Responses {
@@ -1121,6 +1233,22 @@ export interface OperationMethods {
1121
1233
  data?: Paths.ProcessErpUpdatesEventsV2.RequestBody,
1122
1234
  config?: AxiosRequestConfig
1123
1235
  ): OperationResponse<Paths.ProcessErpUpdatesEventsV2.Responses.$200>
1236
+ /**
1237
+ * simulateMappingV2 - simulateMappingV2
1238
+ *
1239
+ * Test v2.0 mapping configuration by transforming a payload using the provided mapping rules without persisting data.
1240
+ *
1241
+ * This endpoint accepts the same configuration format that is stored in the integration use case resource,
1242
+ * making it easier to test configurations before saving them to a use case.
1243
+ *
1244
+ * See documentation at /docs/MAPPING_V2.md for detailed v2.0 format specification.
1245
+ *
1246
+ */
1247
+ 'simulateMappingV2'(
1248
+ parameters?: Parameters<UnknownParamsObject> | null,
1249
+ data?: Paths.SimulateMappingV2.RequestBody,
1250
+ config?: AxiosRequestConfig
1251
+ ): OperationResponse<Paths.SimulateMappingV2.Responses.$200>
1124
1252
  /**
1125
1253
  * simulateMapping - simulateMapping
1126
1254
  *
@@ -1326,6 +1454,24 @@ export interface PathsDictionary {
1326
1454
  config?: AxiosRequestConfig
1327
1455
  ): OperationResponse<Paths.ProcessErpUpdatesEventsV2.Responses.$200>
1328
1456
  }
1457
+ ['/v2/erp/updates/mapping_simulation']: {
1458
+ /**
1459
+ * simulateMappingV2 - simulateMappingV2
1460
+ *
1461
+ * Test v2.0 mapping configuration by transforming a payload using the provided mapping rules without persisting data.
1462
+ *
1463
+ * This endpoint accepts the same configuration format that is stored in the integration use case resource,
1464
+ * making it easier to test configurations before saving them to a use case.
1465
+ *
1466
+ * See documentation at /docs/MAPPING_V2.md for detailed v2.0 format specification.
1467
+ *
1468
+ */
1469
+ 'post'(
1470
+ parameters?: Parameters<UnknownParamsObject> | null,
1471
+ data?: Paths.SimulateMappingV2.RequestBody,
1472
+ config?: AxiosRequestConfig
1473
+ ): OperationResponse<Paths.SimulateMappingV2.Responses.$200>
1474
+ }
1329
1475
  ['/v1/erp/updates/mapping_simulation']: {
1330
1476
  /**
1331
1477
  * simulateMapping - simulateMapping
@@ -1520,6 +1666,7 @@ export type IntegrationMeterReading = Components.Schemas.IntegrationMeterReading
1520
1666
  export type IntegrationObjectV1 = Components.Schemas.IntegrationObjectV1;
1521
1667
  export type MappingSimulationRequest = Components.Schemas.MappingSimulationRequest;
1522
1668
  export type MappingSimulationResponse = Components.Schemas.MappingSimulationResponse;
1669
+ export type MappingSimulationV2Request = Components.Schemas.MappingSimulationV2Request;
1523
1670
  export type MeterReadingUpdate = Components.Schemas.MeterReadingUpdate;
1524
1671
  export type MeterUniqueIdsConfig = Components.Schemas.MeterUniqueIdsConfig;
1525
1672
  export type OutboundIntegrationEventConfiguration = Components.Schemas.OutboundIntegrationEventConfiguration;
@@ -1527,6 +1674,9 @@ export type OutboundUseCase = Components.Schemas.OutboundUseCase;
1527
1674
  export type OutboundUseCaseHistoryEntry = Components.Schemas.OutboundUseCaseHistoryEntry;
1528
1675
  export type RelationConfig = Components.Schemas.RelationConfig;
1529
1676
  export type RelationItemConfig = Components.Schemas.RelationItemConfig;
1677
+ export type RelationRefItemConfig = Components.Schemas.RelationRefItemConfig;
1678
+ export type RelationRefValueConfig = Components.Schemas.RelationRefValueConfig;
1679
+ export type RelationRefsConfig = Components.Schemas.RelationRefsConfig;
1530
1680
  export type RelationUniqueIdField = Components.Schemas.RelationUniqueIdField;
1531
1681
  export type SetIntegrationAppMappingRequest = Components.Schemas.SetIntegrationAppMappingRequest;
1532
1682
  export type TriggerErpActionRequest = Components.Schemas.TriggerErpActionRequest;
package/dist/openapi.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "openapi": "3.0.3",
3
3
  "info": {
4
4
  "title": "ERP Integration API",
5
- "version": "0.13.0",
5
+ "version": "0.15.0",
6
6
  "description": "API for integrating with ERP systems, handling tracking acknowledgments, triggering ERP processes, and processing ERP updates."
7
7
  },
8
8
  "tags": [
@@ -272,6 +272,277 @@
272
272
  }
273
273
  }
274
274
  },
275
+ "/v2/erp/updates/mapping_simulation": {
276
+ "post": {
277
+ "operationId": "simulateMappingV2",
278
+ "summary": "simulateMappingV2",
279
+ "description": "Test v2.0 mapping configuration by transforming a payload using the provided mapping rules without persisting data.\n\nThis endpoint accepts the same configuration format that is stored in the integration use case resource,\nmaking it easier to test configurations before saving them to a use case.\n\nSee documentation at /docs/MAPPING_V2.md for detailed v2.0 format specification.\n",
280
+ "tags": [
281
+ "erp"
282
+ ],
283
+ "requestBody": {
284
+ "required": true,
285
+ "content": {
286
+ "application/json": {
287
+ "schema": {
288
+ "$ref": "#/components/schemas/MappingSimulationV2Request"
289
+ },
290
+ "examples": {
291
+ "simple": {
292
+ "summary": "Simple Example",
293
+ "value": {
294
+ "event_configuration": {
295
+ "entities": [
296
+ {
297
+ "entity_schema": "contact",
298
+ "unique_ids": [
299
+ "customer_number"
300
+ ],
301
+ "fields": [
302
+ {
303
+ "attribute": "customer_number",
304
+ "field": "customerId"
305
+ },
306
+ {
307
+ "attribute": "first_name",
308
+ "field": "firstName"
309
+ },
310
+ {
311
+ "attribute": "last_name",
312
+ "field": "lastName"
313
+ },
314
+ {
315
+ "attribute": "email",
316
+ "field": "email"
317
+ },
318
+ {
319
+ "attribute": "source",
320
+ "constant": "ERP"
321
+ }
322
+ ]
323
+ }
324
+ ]
325
+ },
326
+ "format": "json",
327
+ "payload": "{\"customerId\":\"12345\",\"firstName\":\"Anna\",\"lastName\":\"Schmidt\",\"email\":\"anna@example.com\"}"
328
+ }
329
+ },
330
+ "advanced_with_relations": {
331
+ "summary": "Advanced with Relations",
332
+ "value": {
333
+ "event_configuration": {
334
+ "entities": [
335
+ {
336
+ "entity_schema": "contract",
337
+ "unique_ids": [
338
+ "contract_number"
339
+ ],
340
+ "fields": [
341
+ {
342
+ "attribute": "contract_number",
343
+ "field": "number"
344
+ },
345
+ {
346
+ "attribute": "display_name",
347
+ "field": "displayName"
348
+ },
349
+ {
350
+ "attribute": "billing_account",
351
+ "relations": {
352
+ "operation": "_set",
353
+ "items": [
354
+ {
355
+ "entity_schema": "billing_account",
356
+ "_tags": [
357
+ "PRIMARY"
358
+ ],
359
+ "unique_ids": [
360
+ {
361
+ "attribute": "external_id",
362
+ "field": "customerAccountId"
363
+ }
364
+ ]
365
+ }
366
+ ]
367
+ }
368
+ }
369
+ ]
370
+ },
371
+ {
372
+ "entity_schema": "meter",
373
+ "unique_ids": [
374
+ "meter_number"
375
+ ],
376
+ "jsonataExpression": "meters.{\"number\": number, \"type\": meterType}",
377
+ "fields": [
378
+ {
379
+ "attribute": "meter_number",
380
+ "field": "number"
381
+ },
382
+ {
383
+ "attribute": "meter_type",
384
+ "field": "type"
385
+ }
386
+ ]
387
+ }
388
+ ]
389
+ },
390
+ "format": "json",
391
+ "payload": "{\"number\":\"CTR-001\",\"displayName\":\"Premium Contract\",\"customerAccountId\":\"ACC-999\",\"meters\":[{\"number\":\"M-001\",\"meterType\":\"electricity\"},{\"number\":\"M-002\",\"meterType\":\"gas\"}]}"
392
+ }
393
+ },
394
+ "with_meter_readings": {
395
+ "summary": "With Meter Readings",
396
+ "value": {
397
+ "event_configuration": {
398
+ "entities": [
399
+ {
400
+ "entity_schema": "contract",
401
+ "unique_ids": [
402
+ "contract_number"
403
+ ],
404
+ "fields": [
405
+ {
406
+ "attribute": "contract_number",
407
+ "field": "number"
408
+ },
409
+ {
410
+ "attribute": "display_name",
411
+ "field": "name"
412
+ }
413
+ ]
414
+ }
415
+ ],
416
+ "meter_readings": [
417
+ {
418
+ "jsonataExpression": "$.readings",
419
+ "meter": {
420
+ "unique_ids": [
421
+ {
422
+ "attribute": "external_id",
423
+ "field": "meter_id"
424
+ }
425
+ ]
426
+ },
427
+ "fields": [
428
+ {
429
+ "attribute": "external_id",
430
+ "field": "reading_id"
431
+ },
432
+ {
433
+ "attribute": "timestamp",
434
+ "field": "read_at"
435
+ },
436
+ {
437
+ "attribute": "source",
438
+ "constant": "ERP"
439
+ },
440
+ {
441
+ "attribute": "value",
442
+ "field": "value"
443
+ }
444
+ ]
445
+ }
446
+ ]
447
+ },
448
+ "format": "json",
449
+ "payload": "{\"number\":\"CTR-001\",\"name\":\"Main Contract\",\"readings\":[{\"meter_id\":\"M-001\",\"reading_id\":\"R-001\",\"read_at\":\"2025-01-15T10:00:00Z\",\"value\":12345.6}]}"
450
+ }
451
+ },
452
+ "conditional_fields": {
453
+ "summary": "Conditional Field Processing",
454
+ "description": "Example showing how to conditionally enable/disable individual field mappings",
455
+ "value": {
456
+ "event_configuration": {
457
+ "entities": [
458
+ {
459
+ "entity_schema": "contact",
460
+ "unique_ids": [
461
+ "customer_number"
462
+ ],
463
+ "fields": [
464
+ {
465
+ "attribute": "customer_number",
466
+ "field": "customerId"
467
+ },
468
+ {
469
+ "attribute": "email",
470
+ "field": "email",
471
+ "enabled": "$exists(email) and email != ''"
472
+ },
473
+ {
474
+ "attribute": "phone",
475
+ "field": "phone",
476
+ "enabled": "$exists(phone) and phone != ''"
477
+ },
478
+ {
479
+ "attribute": "vip_status",
480
+ "constant": "VIP",
481
+ "enabled": "vipFlag = true"
482
+ },
483
+ {
484
+ "attribute": "billing_account",
485
+ "enabled": "$exists(billingAccountId)",
486
+ "relations": {
487
+ "operation": "_set",
488
+ "items": [
489
+ {
490
+ "entity_schema": "billing_account",
491
+ "unique_ids": [
492
+ {
493
+ "attribute": "external_id",
494
+ "field": "billingAccountId"
495
+ }
496
+ ]
497
+ }
498
+ ]
499
+ }
500
+ }
501
+ ]
502
+ }
503
+ ]
504
+ },
505
+ "format": "json",
506
+ "payload": "{\"customerId\":\"12345\",\"email\":\"user@example.com\",\"phone\":\"\",\"vipFlag\":true,\"billingAccountId\":\"ACC-999\"}"
507
+ }
508
+ }
509
+ }
510
+ }
511
+ }
512
+ },
513
+ "responses": {
514
+ "200": {
515
+ "description": "Successfully simulated mapping",
516
+ "content": {
517
+ "application/json": {
518
+ "schema": {
519
+ "$ref": "#/components/schemas/MappingSimulationResponse"
520
+ }
521
+ }
522
+ }
523
+ },
524
+ "400": {
525
+ "$ref": "#/components/responses/BadRequest"
526
+ },
527
+ "401": {
528
+ "$ref": "#/components/responses/Unauthorized"
529
+ },
530
+ "422": {
531
+ "description": "Unprocessable entity - mapping configuration or payload validation failed",
532
+ "content": {
533
+ "application/json": {
534
+ "schema": {
535
+ "$ref": "#/components/schemas/ErrorResponseBase"
536
+ }
537
+ }
538
+ }
539
+ },
540
+ "500": {
541
+ "$ref": "#/components/responses/InternalServerError"
542
+ }
543
+ }
544
+ }
545
+ },
275
546
  "/v1/erp/updates/mapping_simulation": {
276
547
  "post": {
277
548
  "operationId": "simulateMapping",
@@ -2111,6 +2382,43 @@
2111
2382
  }
2112
2383
  }
2113
2384
  },
2385
+ "MappingSimulationV2Request": {
2386
+ "type": "object",
2387
+ "description": "Request for v2 mapping simulation. Uses the same configuration format stored in integration use case resources,\nmaking it easier to test configurations before saving them.\n",
2388
+ "required": [
2389
+ "event_configuration",
2390
+ "format",
2391
+ "payload"
2392
+ ],
2393
+ "properties": {
2394
+ "event_configuration": {
2395
+ "$ref": "#/components/schemas/InboundIntegrationEventConfiguration"
2396
+ },
2397
+ "format": {
2398
+ "type": "string",
2399
+ "enum": [
2400
+ "json",
2401
+ "xml"
2402
+ ],
2403
+ "default": "json",
2404
+ "description": "Format of the payload data"
2405
+ },
2406
+ "payload": {
2407
+ "oneOf": [
2408
+ {
2409
+ "type": "string",
2410
+ "description": "The serialized event data payload (JSON, XML, etc.) as a string"
2411
+ },
2412
+ {
2413
+ "type": "object",
2414
+ "description": "Direct JSON object (will be automatically serialized)",
2415
+ "additionalProperties": true
2416
+ }
2417
+ ],
2418
+ "description": "The event data payload - can be either a serialized string or a direct JSON object"
2419
+ }
2420
+ }
2421
+ },
2114
2422
  "MappingSimulationResponse": {
2115
2423
  "type": "object",
2116
2424
  "required": [
@@ -2462,6 +2770,9 @@
2462
2770
  },
2463
2771
  "relations": {
2464
2772
  "$ref": "#/components/schemas/RelationConfig"
2773
+ },
2774
+ "relation_refs": {
2775
+ "$ref": "#/components/schemas/RelationRefsConfig"
2465
2776
  }
2466
2777
  }
2467
2778
  },
@@ -2475,9 +2786,10 @@
2475
2786
  "type": "string",
2476
2787
  "enum": [
2477
2788
  "_set",
2478
- "_append"
2789
+ "_append",
2790
+ "_append_all"
2479
2791
  ],
2480
- "description": "Relation operation:\n- '_set': Replace all existing relations with the specified items\n- '_append': Add new items to existing relations (fetches current entity first)\n"
2792
+ "description": "Relation operation:\n- '_set': Replace all existing relations with the specified items\n- '_append': Add new unique items to existing relations (deduplicates by entity_id)\n- '_append_all': Add all items to existing relations (no deduplication, allows duplicates)\n"
2481
2793
  },
2482
2794
  "items": {
2483
2795
  "type": "array",
@@ -2541,6 +2853,98 @@
2541
2853
  "description": "Constant value (any type)"
2542
2854
  }
2543
2855
  }
2856
+ },
2857
+ "RelationRefsConfig": {
2858
+ "type": "object",
2859
+ "description": "Configuration for relation references ($relation_ref).\nRelation references link to a specific item within a repeatable attribute on a related entity.\nCommon use case: referencing a specific address within a contact's address list.\n",
2860
+ "required": [
2861
+ "operation"
2862
+ ],
2863
+ "properties": {
2864
+ "operation": {
2865
+ "type": "string",
2866
+ "enum": [
2867
+ "_set",
2868
+ "_append",
2869
+ "_append_all"
2870
+ ],
2871
+ "description": "Relation reference operation:\n- '_set': Replace all existing relation_refs with the specified items\n- '_append': Add new unique items to existing relation_refs (deduplicates by entity_id + _id)\n- '_append_all': Add all items to existing relation_refs (no deduplication, allows duplicates)\n"
2872
+ },
2873
+ "items": {
2874
+ "type": "array",
2875
+ "description": "Array of relation reference item configurations",
2876
+ "items": {
2877
+ "$ref": "#/components/schemas/RelationRefItemConfig"
2878
+ }
2879
+ },
2880
+ "jsonataExpression": {
2881
+ "type": "string",
2882
+ "description": "JSONata expression that returns relation_ref items array (alternative to 'items')"
2883
+ }
2884
+ }
2885
+ },
2886
+ "RelationRefItemConfig": {
2887
+ "type": "object",
2888
+ "description": "Configuration for a single relation reference item",
2889
+ "required": [
2890
+ "entity_schema",
2891
+ "unique_ids",
2892
+ "path",
2893
+ "value"
2894
+ ],
2895
+ "properties": {
2896
+ "entity_schema": {
2897
+ "type": "string",
2898
+ "description": "Schema of the related entity (e.g., \"contact\")"
2899
+ },
2900
+ "unique_ids": {
2901
+ "type": "array",
2902
+ "description": "Unique identifier mappings for the related entity",
2903
+ "items": {
2904
+ "$ref": "#/components/schemas/RelationUniqueIdField"
2905
+ }
2906
+ },
2907
+ "path": {
2908
+ "type": "string",
2909
+ "description": "Attribute path on the related entity (e.g., \"address\")"
2910
+ },
2911
+ "value": {
2912
+ "$ref": "#/components/schemas/RelationRefValueConfig"
2913
+ }
2914
+ }
2915
+ },
2916
+ "RelationRefValueConfig": {
2917
+ "type": "object",
2918
+ "description": "Configuration for the value to set on the related entity's attribute",
2919
+ "required": [
2920
+ "attribute"
2921
+ ],
2922
+ "properties": {
2923
+ "attribute": {
2924
+ "type": "string",
2925
+ "description": "Target attribute name on the related entity"
2926
+ },
2927
+ "operation": {
2928
+ "type": "string",
2929
+ "enum": [
2930
+ "_set",
2931
+ "_append",
2932
+ "_append_all"
2933
+ ],
2934
+ "description": "Operation for the attribute value:\n- '_set': Replace the attribute value\n- '_append': Add new unique items (deduplicates)\n- '_append_all': Add all items (no deduplication)\n"
2935
+ },
2936
+ "field": {
2937
+ "type": "string",
2938
+ "description": "Source field name from the event data"
2939
+ },
2940
+ "jsonataExpression": {
2941
+ "type": "string",
2942
+ "description": "JSONata expression to compute the value"
2943
+ },
2944
+ "constant": {
2945
+ "description": "Constant value (any type)"
2946
+ }
2947
+ }
2544
2948
  }
2545
2949
  },
2546
2950
  "responses": {
@@ -2625,13 +3029,5 @@
2625
3029
  }
2626
3030
  }
2627
3031
  }
2628
- },
2629
- "servers": [
2630
- {
2631
- "url": "https://erp-integration-api.sls.epilot.io"
2632
- },
2633
- {
2634
- "url": "https://erp-integration-api.sls.epilot.io"
2635
- }
2636
- ]
3032
+ }
2637
3033
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epilot/erp-integration-client",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Client library for ePilot ERP Integration API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",