@epilot/erp-integration-client 0.4.1 → 0.5.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,o){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var r=n(o(466));t.default=r.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":{}}}},"components":{"responses":{"BadRequest":{"content":{"application/json":{}}},"Unauthorized":{"content":{"application/json":{}}},"NotFound":{"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={},o=function o(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,o),s.exports}(390),n=exports;for(var r in o)n[r]=o[r];o.__esModule&&Object.defineProperty(n,"__esModule",{value:!0})})();
1
+ (()=>{"use strict";var e={330:function(e,t,o){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var r=n(o(466));t.default=r.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":{}}},"/v1/erp/updates/mapping_simulation":{"post":{"operationId":"simulateMapping","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={},o=function o(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,o),s.exports}(330),n=exports;for(var r in o)n[r]=o[r];o.__esModule&&Object.defineProperty(n,"__esModule",{value:!0})})();
@@ -38,6 +38,18 @@
38
38
  },
39
39
  "responses": {}
40
40
  }
41
+ },
42
+ "/v1/erp/updates/mapping_simulation": {
43
+ "post": {
44
+ "operationId": "simulateMapping",
45
+ "requestBody": {
46
+ "required": true,
47
+ "content": {
48
+ "application/json": {}
49
+ }
50
+ },
51
+ "responses": {}
52
+ }
41
53
  }
42
54
  },
43
55
  "components": {
@@ -52,11 +64,6 @@
52
64
  "application/json": {}
53
65
  }
54
66
  },
55
- "NotFound": {
56
- "content": {
57
- "application/json": {}
58
- }
59
- },
60
67
  "InternalServerError": {
61
68
  "content": {
62
69
  "application/json": {}
package/dist/openapi.d.ts CHANGED
@@ -18,14 +18,13 @@ declare namespace Components {
18
18
  */
19
19
  event_id: string;
20
20
  /**
21
- * Processing status for the event
21
+ * Processing status for the event (skipped indicates duplicate deduplication_id)
22
22
  */
23
- status: "success" | "error";
23
+ status: "success" | "error" | "skipped";
24
24
  message?: string;
25
25
  }[];
26
26
  }
27
27
  export type InternalServerError = Schemas.ErrorResponseBase;
28
- export type NotFound = Schemas.ErrorResponseBase;
29
28
  export type TriggerWebhookResponse = Schemas.TriggerWebhookResp;
30
29
  export type Unauthorized = Schemas.ErrorResponseBase;
31
30
  }
@@ -162,6 +161,13 @@ declare namespace Paths {
162
161
  * The serialized object data payload (JSON, XML, etc.) as a string
163
162
  */
164
163
  payload: string;
164
+ /**
165
+ * Optional unique identifier for idempotency - prevents duplicate processing of the same event within 24 hours in context of the same app and component. Must contain only alphanumeric characters, hyphens, and underscores.
166
+ *
167
+ * example:
168
+ * evt-2025-05-01-12345-create-bp
169
+ */
170
+ deduplication_id?: string; // ^[a-zA-Z0-9_-]+$
165
171
  }[];
166
172
  }
167
173
  namespace Responses {
@@ -172,6 +178,91 @@ declare namespace Paths {
172
178
  export type $500 = Components.Responses.InternalServerError;
173
179
  }
174
180
  }
181
+ namespace SimulateMapping {
182
+ export interface RequestBody {
183
+ /**
184
+ * The integration mapping configuration
185
+ */
186
+ mapping_configuration: {
187
+ mapping: {
188
+ /**
189
+ * Object type mappings
190
+ */
191
+ objects: {
192
+ [name: string]: {
193
+ /**
194
+ * Mapping of entity types to their unique identifier field mappings
195
+ */
196
+ unique_ids: {
197
+ [name: string]: {
198
+ [name: string]: string;
199
+ };
200
+ };
201
+ /**
202
+ * Field mapping definitions
203
+ */
204
+ fields: {
205
+ /**
206
+ * Target entity slug
207
+ */
208
+ entity: string;
209
+ /**
210
+ * Target attribute name
211
+ */
212
+ attribute: string;
213
+ /**
214
+ * Source field name (mutually exclusive with jsonataExpression)
215
+ */
216
+ field?: string;
217
+ /**
218
+ * JSONata expression for transformation (mutually exclusive with field)
219
+ */
220
+ jsonataExpression?: string;
221
+ }[];
222
+ };
223
+ };
224
+ };
225
+ };
226
+ /**
227
+ * Type of the object being mapped (must match a key in mapping_configuration.mapping.objects)
228
+ */
229
+ object_type: string;
230
+ /**
231
+ * Format of the payload data
232
+ */
233
+ format: "json" | "xml";
234
+ /**
235
+ * The serialized object data payload (JSON, XML, etc.) as a string
236
+ */
237
+ payload: string;
238
+ }
239
+ namespace Responses {
240
+ export interface $200 {
241
+ entity_updates: {
242
+ /**
243
+ * The entity type slug
244
+ */
245
+ entity_slug: string;
246
+ /**
247
+ * Unique identifier mappings for this entity
248
+ */
249
+ uniqueIdentifiers: {
250
+ [name: string]: any;
251
+ };
252
+ /**
253
+ * Mapped attribute values
254
+ */
255
+ attributes: {
256
+ [name: string]: any;
257
+ };
258
+ }[];
259
+ }
260
+ export type $400 = Components.Responses.BadRequest;
261
+ export type $401 = Components.Responses.Unauthorized;
262
+ export type $422 = Components.Schemas.ErrorResponseBase;
263
+ export type $500 = Components.Responses.InternalServerError;
264
+ }
265
+ }
175
266
  namespace TriggerErp {
176
267
  export type RequestBody = Components.Schemas.TriggerErpActionRequest;
177
268
  namespace Responses {
@@ -218,6 +309,16 @@ export interface OperationMethods {
218
309
  data?: Paths.ProcessErpUpdatesEvents.RequestBody,
219
310
  config?: AxiosRequestConfig
220
311
  ): OperationResponse<Paths.ProcessErpUpdatesEvents.Responses.$200>
312
+ /**
313
+ * simulateMapping - Simulate ERP mapping transformation
314
+ *
315
+ * Test mapping configuration by transforming a payload using the provided mapping rules without persisting data
316
+ */
317
+ 'simulateMapping'(
318
+ parameters?: Parameters<UnknownParamsObject> | null,
319
+ data?: Paths.SimulateMapping.RequestBody,
320
+ config?: AxiosRequestConfig
321
+ ): OperationResponse<Paths.SimulateMapping.Responses.$200>
221
322
  }
222
323
 
223
324
  export interface PathsDictionary {
@@ -257,6 +358,18 @@ export interface PathsDictionary {
257
358
  config?: AxiosRequestConfig
258
359
  ): OperationResponse<Paths.ProcessErpUpdatesEvents.Responses.$200>
259
360
  }
361
+ ['/v1/erp/updates/mapping_simulation']: {
362
+ /**
363
+ * simulateMapping - Simulate ERP mapping transformation
364
+ *
365
+ * Test mapping configuration by transforming a payload using the provided mapping rules without persisting data
366
+ */
367
+ 'post'(
368
+ parameters?: Parameters<UnknownParamsObject> | null,
369
+ data?: Paths.SimulateMapping.RequestBody,
370
+ config?: AxiosRequestConfig
371
+ ): OperationResponse<Paths.SimulateMapping.Responses.$200>
372
+ }
260
373
  }
261
374
 
262
375
  export type Client = OpenAPIClient<OperationMethods, PathsDictionary>
package/dist/openapi.json CHANGED
@@ -2,12 +2,17 @@
2
2
  "openapi": "3.0.3",
3
3
  "info": {
4
4
  "title": "ERP Integration API",
5
- "version": "1.0.0"
5
+ "version": "0.3.0",
6
+ "description": "API for integrating with ERP systems, handling tracking acknowledgments, triggering ERP processes, and processing ERP updates."
6
7
  },
7
8
  "tags": [
8
9
  {
9
10
  "name": "erp",
10
11
  "description": "ERP integration endpoints"
12
+ },
13
+ {
14
+ "name": "trigger",
15
+ "description": "Endpoints to trigger ERP related actions"
11
16
  }
12
17
  ],
13
18
  "security": [
@@ -192,6 +197,14 @@
192
197
  "payload": {
193
198
  "type": "string",
194
199
  "description": "The serialized object data payload (JSON, XML, etc.) as a string"
200
+ },
201
+ "deduplication_id": {
202
+ "type": "string",
203
+ "pattern": "^[a-zA-Z0-9_-]+$",
204
+ "minLength": 1,
205
+ "maxLength": 255,
206
+ "description": "Optional unique identifier for idempotency - prevents duplicate processing of the same event within 24 hours in context of the same app and component. Must contain only alphanumeric characters, hyphens, and underscores.\n",
207
+ "example": "evt-2025-05-01-12345-create-bp"
195
208
  }
196
209
  }
197
210
  }
@@ -201,20 +214,25 @@
201
214
  "example": {
202
215
  "app_id": "123e4567-e89b-12d3-a456-426614174000",
203
216
  "component_id": "123e4567-e89b-12d3-a456-426614174000",
217
+ "meta": {
218
+ "correlation_id": "req-789e4567-e89b-12d3-a456-426614174000"
219
+ },
204
220
  "events": [
205
221
  {
206
222
  "event_type": "CREATE",
207
223
  "object_type": "business_partner",
208
224
  "timestamp": "2025-05-01T08:30:00Z",
209
225
  "format": "json",
210
- "payload": "{\"id\":\"BP10001\",\"name\":\"Acme Corporation\",\"type\":\"organization\",\"tax_id\":\"DE123456789\",\"status\":\"active\"}"
226
+ "payload": "{\"id\":\"BP10001\",\"name\":\"Acme Corporation\",\"type\":\"organization\",\"tax_id\":\"DE123456789\",\"status\":\"active\"}",
227
+ "deduplication_id": "bp-create-20250501-083000-001"
211
228
  },
212
229
  {
213
230
  "event_type": "UPDATE",
214
231
  "object_type": "contract_account",
215
232
  "timestamp": "2025-05-01T08:35:00Z",
216
233
  "format": "json",
217
- "payload": "{\"id\":\"CA20001\",\"business_partner_id\":\"BP10001\",\"status\":\"active\",\"payment_method\":\"direct_debit\"}"
234
+ "payload": "{\"id\":\"CA20001\",\"business_partner_id\":\"BP10001\",\"status\":\"active\",\"payment_method\":\"direct_debit\"}",
235
+ "deduplication_id": "ca-update-20250501-083500-001"
218
236
  }
219
237
  ]
220
238
  }
@@ -239,6 +257,214 @@
239
257
  }
240
258
  }
241
259
  }
260
+ },
261
+ "/v1/erp/updates/mapping_simulation": {
262
+ "post": {
263
+ "operationId": "simulateMapping",
264
+ "summary": "Simulate ERP mapping transformation",
265
+ "description": "Test mapping configuration by transforming a payload using the provided mapping rules without persisting data",
266
+ "tags": [
267
+ "erp"
268
+ ],
269
+ "requestBody": {
270
+ "required": true,
271
+ "content": {
272
+ "application/json": {
273
+ "schema": {
274
+ "type": "object",
275
+ "required": [
276
+ "mapping_configuration",
277
+ "object_type",
278
+ "format",
279
+ "payload"
280
+ ],
281
+ "properties": {
282
+ "mapping_configuration": {
283
+ "type": "object",
284
+ "description": "The integration mapping configuration",
285
+ "required": [
286
+ "mapping"
287
+ ],
288
+ "properties": {
289
+ "mapping": {
290
+ "type": "object",
291
+ "required": [
292
+ "objects"
293
+ ],
294
+ "properties": {
295
+ "objects": {
296
+ "type": "object",
297
+ "description": "Object type mappings",
298
+ "additionalProperties": {
299
+ "type": "object",
300
+ "required": [
301
+ "unique_ids",
302
+ "fields"
303
+ ],
304
+ "properties": {
305
+ "unique_ids": {
306
+ "type": "object",
307
+ "description": "Mapping of entity types to their unique identifier field mappings",
308
+ "additionalProperties": {
309
+ "type": "object",
310
+ "description": "Map of remote keys to local entity keys",
311
+ "additionalProperties": {
312
+ "type": "string"
313
+ }
314
+ }
315
+ },
316
+ "fields": {
317
+ "type": "array",
318
+ "description": "Field mapping definitions",
319
+ "items": {
320
+ "type": "object",
321
+ "required": [
322
+ "entity",
323
+ "attribute"
324
+ ],
325
+ "properties": {
326
+ "entity": {
327
+ "type": "string",
328
+ "description": "Target entity slug"
329
+ },
330
+ "attribute": {
331
+ "type": "string",
332
+ "description": "Target attribute name"
333
+ },
334
+ "field": {
335
+ "type": "string",
336
+ "description": "Source field name (mutually exclusive with jsonataExpression)"
337
+ },
338
+ "jsonataExpression": {
339
+ "type": "string",
340
+ "description": "JSONata expression for transformation (mutually exclusive with field)"
341
+ }
342
+ }
343
+ }
344
+ }
345
+ }
346
+ }
347
+ }
348
+ }
349
+ }
350
+ }
351
+ },
352
+ "object_type": {
353
+ "type": "string",
354
+ "description": "Type of the object being mapped (must match a key in mapping_configuration.mapping.objects)"
355
+ },
356
+ "format": {
357
+ "type": "string",
358
+ "enum": [
359
+ "json",
360
+ "xml"
361
+ ],
362
+ "default": "json",
363
+ "description": "Format of the payload data"
364
+ },
365
+ "payload": {
366
+ "type": "string",
367
+ "description": "The serialized object data payload (JSON, XML, etc.) as a string"
368
+ }
369
+ }
370
+ },
371
+ "example": {
372
+ "mapping_configuration": {
373
+ "mapping": {
374
+ "objects": {
375
+ "business_partner": {
376
+ "unique_ids": {
377
+ "contact": {
378
+ "partner_id": "_id"
379
+ }
380
+ },
381
+ "fields": [
382
+ {
383
+ "entity": "contact",
384
+ "attribute": "first_name",
385
+ "field": "firstName"
386
+ },
387
+ {
388
+ "entity": "contact",
389
+ "attribute": "last_name",
390
+ "field": "lastName"
391
+ }
392
+ ]
393
+ }
394
+ }
395
+ }
396
+ },
397
+ "object_type": "business_partner",
398
+ "format": "json",
399
+ "payload": "{\"partner_id\":\"BP10001\",\"firstName\":\"John\",\"lastName\":\"Doe\"}"
400
+ }
401
+ }
402
+ }
403
+ },
404
+ "responses": {
405
+ "200": {
406
+ "description": "Successfully simulated mapping",
407
+ "content": {
408
+ "application/json": {
409
+ "schema": {
410
+ "type": "object",
411
+ "required": [
412
+ "entity_updates"
413
+ ],
414
+ "properties": {
415
+ "entity_updates": {
416
+ "type": "array",
417
+ "items": {
418
+ "type": "object",
419
+ "required": [
420
+ "entity_slug",
421
+ "uniqueIdentifiers",
422
+ "attributes"
423
+ ],
424
+ "properties": {
425
+ "entity_slug": {
426
+ "type": "string",
427
+ "description": "The entity type slug"
428
+ },
429
+ "uniqueIdentifiers": {
430
+ "type": "object",
431
+ "description": "Unique identifier mappings for this entity",
432
+ "additionalProperties": true
433
+ },
434
+ "attributes": {
435
+ "type": "object",
436
+ "description": "Mapped attribute values",
437
+ "additionalProperties": true
438
+ }
439
+ }
440
+ }
441
+ }
442
+ }
443
+ }
444
+ }
445
+ }
446
+ },
447
+ "400": {
448
+ "$ref": "#/components/responses/BadRequest"
449
+ },
450
+ "401": {
451
+ "$ref": "#/components/responses/Unauthorized"
452
+ },
453
+ "422": {
454
+ "description": "Unprocessable entity - mapping configuration or payload validation failed",
455
+ "content": {
456
+ "application/json": {
457
+ "schema": {
458
+ "$ref": "#/components/schemas/ErrorResponseBase"
459
+ }
460
+ }
461
+ }
462
+ },
463
+ "500": {
464
+ "$ref": "#/components/responses/InternalServerError"
465
+ }
466
+ }
467
+ }
242
468
  }
243
469
  },
244
470
  "components": {
@@ -248,12 +474,6 @@
248
474
  "scheme": "bearer",
249
475
  "description": "Authorization header with epilot OAuth2 bearer token",
250
476
  "bearerFormat": "JWT"
251
- },
252
- "EpilotPublicAuth": {
253
- "type": "http",
254
- "scheme": "bearer",
255
- "description": "Authorization header with epilot public access token",
256
- "bearerFormat": "JWT"
257
477
  }
258
478
  },
259
479
  "schemas": {
@@ -383,16 +603,6 @@
383
603
  }
384
604
  }
385
605
  },
386
- "NotFound": {
387
- "description": "The specified resource was not found",
388
- "content": {
389
- "application/json": {
390
- "schema": {
391
- "$ref": "#/components/schemas/ErrorResponseBase"
392
- }
393
- }
394
- }
395
- },
396
606
  "InternalServerError": {
397
607
  "description": "Internal Server Error",
398
608
  "content": {
@@ -427,9 +637,10 @@
427
637
  "type": "string",
428
638
  "enum": [
429
639
  "success",
430
- "error"
640
+ "error",
641
+ "skipped"
431
642
  ],
432
- "description": "Processing status for the event"
643
+ "description": "Processing status for the event (skipped indicates duplicate deduplication_id)"
433
644
  },
434
645
  "message": {
435
646
  "type": "string"
@@ -455,9 +666,6 @@
455
666
  }
456
667
  },
457
668
  "servers": [
458
- {
459
- "url": "https://erp-integration-api.sls.epilot.io"
460
- },
461
669
  {
462
670
  "url": "https://erp-integration-api.sls.epilot.io"
463
671
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epilot/erp-integration-client",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "Client library for ePilot ERP Integration API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,6 +22,18 @@
22
22
  "erp",
23
23
  "integration"
24
24
  ],
25
+ "scripts": {
26
+ "test": "jest",
27
+ "typescript": "tsc",
28
+ "bundle-definition": "webpack",
29
+ "openapi": "node ../../scripts/update-openapi.js https://docs.api.epilot.io/erp-integration.yaml",
30
+ "typegen": "openapi typegen src/openapi.json --client -b '/* eslint-disable */' > src/openapi.d.ts",
31
+ "build": "tsc && npm run build:patch && npm run bundle-definition",
32
+ "build:patch": "sed -i'' -e '/^__exportStar.*openapi.*$/d' dist/index.js",
33
+ "build:watch": "npm run build && tsc -w",
34
+ "prepublishOnly": "npm run typegen && npm run build",
35
+ "lint": "pnpm exec eslint src"
36
+ },
25
37
  "files": [
26
38
  "*.js",
27
39
  "*.d.ts",
@@ -51,25 +63,14 @@
51
63
  "@types/jest": "^26.0.20",
52
64
  "axios": "^1.11.0",
53
65
  "copy-webpack-plugin": "^7.0.0",
54
- "jest": "^26.6.3",
66
+ "jest": "^29.6.2",
55
67
  "json-loader": "^0.5.7",
56
68
  "openapicmd": "^2.7.0",
57
- "ts-jest": "^26.5.0",
69
+ "ts-jest": "^29.4.1",
58
70
  "ts-loader": "^8.0.14",
59
71
  "ts-node": "^10.9.1",
60
72
  "typescript": "^4.1.3",
61
73
  "webpack": "^5.18.0",
62
74
  "webpack-cli": "^4.4.0"
63
- },
64
- "scripts": {
65
- "test": "jest",
66
- "typescript": "tsc",
67
- "bundle-definition": "webpack",
68
- "openapi": "node ../../scripts/update-openapi.js https://docs.api.epilot.io/erp-integration.yaml",
69
- "typegen": "openapi typegen src/openapi.json --client -b '/* eslint-disable */' > src/openapi.d.ts",
70
- "build": "tsc && npm run build:patch && npm run bundle-definition",
71
- "build:patch": "sed -i'' -e '/^__exportStar.*openapi.*$/d' dist/index.js",
72
- "build:watch": "npm run build && tsc -w",
73
- "lint": "pnpm exec eslint src"
74
75
  }
75
- }
76
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2025 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.