@neo-edi/sdk 1.0.19 → 1.0.21
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/README.md +88 -0
- package/dist/index.d.mts +49 -2
- package/dist/index.d.ts +49 -2
- package/dist/index.js +80 -1
- package/dist/index.mjs +80 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -267,6 +267,94 @@ const data = await client.graphql.query<{ edi852Headers: Edi852Header[] }>(`
|
|
|
267
267
|
`, { filter: { vendorPartnerId: 'VENDOR-001' } });
|
|
268
268
|
```
|
|
269
269
|
|
|
270
|
+
## Webhooks
|
|
271
|
+
|
|
272
|
+
Register endpoints that receive HMAC-signed HTTP callbacks when events happen for a
|
|
273
|
+
trading partner — e.g. `document.ingested` when a delivery is ingested — so you don't
|
|
274
|
+
have to poll.
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
// Create (subscribe) an endpoint.
|
|
278
|
+
// The returned signingSecret is shown ONCE — store it now.
|
|
279
|
+
const endpoint = await client.webhooks.create({
|
|
280
|
+
partnerId: 'PARTNER-001',
|
|
281
|
+
url: 'https://your-app.com/hooks/neo-edi',
|
|
282
|
+
description: 'Production receiver',
|
|
283
|
+
eventTypes: ['document.ingested'] // omit to subscribe to all events
|
|
284
|
+
});
|
|
285
|
+
console.log(endpoint.signingSecret); // whsec_... — persist this securely
|
|
286
|
+
|
|
287
|
+
// List endpoints for a partner
|
|
288
|
+
const endpoints = await client.webhooks.list('PARTNER-001');
|
|
289
|
+
|
|
290
|
+
// Get one endpoint
|
|
291
|
+
const one = await client.webhooks.get(endpoint.id);
|
|
292
|
+
|
|
293
|
+
// Update — change the URL, events, or pause delivery with isActive: false
|
|
294
|
+
await client.webhooks.update(endpoint.id, {
|
|
295
|
+
url: 'https://your-app.com/hooks/neo-edi/v2',
|
|
296
|
+
isActive: false
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
// Delete (unsubscribe)
|
|
300
|
+
await client.webhooks.delete(endpoint.id);
|
|
301
|
+
|
|
302
|
+
// Inspect recent delivery attempts (audit / debugging)
|
|
303
|
+
const deliveries = await client.webhooks.listDeliveries(endpoint.id, { limit: 20 });
|
|
304
|
+
for (const d of deliveries) {
|
|
305
|
+
console.log(d.status, d.responseStatus, d.attemptCount);
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### Receiving & verifying deliveries
|
|
310
|
+
|
|
311
|
+
Each delivery is an HTTP `POST` to your URL with a JSON envelope
|
|
312
|
+
(`{ id, type, partnerId, createdAt, data }`) and these headers:
|
|
313
|
+
|
|
314
|
+
| Header | Example | Purpose |
|
|
315
|
+
|--------|---------|---------|
|
|
316
|
+
| `X-Webhook-Timestamp` | `1717416000` | Unix seconds; part of the signed content |
|
|
317
|
+
| `X-Webhook-Signature` | `t=1717416000,v1=9f86d08...` | `v1` is the HMAC-SHA256 hex digest |
|
|
318
|
+
|
|
319
|
+
Verify by recomputing `HMAC_SHA256(signingSecret, "{timestamp}.{rawBody}")` over the
|
|
320
|
+
**raw** body (before JSON parsing) and comparing it to the `v1=` value. Example with
|
|
321
|
+
Express:
|
|
322
|
+
|
|
323
|
+
```typescript
|
|
324
|
+
import crypto from 'node:crypto';
|
|
325
|
+
import express from 'express';
|
|
326
|
+
|
|
327
|
+
const app = express();
|
|
328
|
+
|
|
329
|
+
// Capture the raw body — the signature is computed over the exact bytes sent.
|
|
330
|
+
app.post(
|
|
331
|
+
'/hooks/neo-edi',
|
|
332
|
+
express.raw({ type: 'application/json' }),
|
|
333
|
+
(req, res) => {
|
|
334
|
+
const sig = req.header('X-Webhook-Signature') ?? '';
|
|
335
|
+
const parts = Object.fromEntries(sig.split(',').map((kv) => kv.split('=')));
|
|
336
|
+
const rawBody = req.body.toString('utf8');
|
|
337
|
+
|
|
338
|
+
const expected = crypto
|
|
339
|
+
.createHmac('sha256', process.env.WEBHOOK_SECRET!)
|
|
340
|
+
.update(`${parts.t}.${rawBody}`)
|
|
341
|
+
.digest('hex');
|
|
342
|
+
|
|
343
|
+
const valid =
|
|
344
|
+
parts.v1?.length === expected.length &&
|
|
345
|
+
crypto.timingSafeEqual(Buffer.from(parts.v1), Buffer.from(expected));
|
|
346
|
+
|
|
347
|
+
if (!valid) return res.status(401).send('bad signature');
|
|
348
|
+
|
|
349
|
+
const event = JSON.parse(rawBody);
|
|
350
|
+
// Dedupe on event.id — it is stable across retries.
|
|
351
|
+
// ... handle event.data ...
|
|
352
|
+
|
|
353
|
+
res.sendStatus(200); // any 2xx acknowledges; otherwise it's retried (up to 3x)
|
|
354
|
+
}
|
|
355
|
+
);
|
|
356
|
+
```
|
|
357
|
+
|
|
270
358
|
## Error Handling
|
|
271
359
|
|
|
272
360
|
```typescript
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ListCustomersParams, EdiCustomer, CustomerIdentifierType, CreateCustomerRequest, UpdateCustomerRequest, ListSubCustomersParams, SubCustomerWithIdentifiers, SubCustomer, AddSubCustomerResponse, CreateSubCustomerRequest, CreateSubCustomerResponse, EdiPartner, RegisterPartnerCustomerRequest, PartnerCustomerRegistrationResult, GetSubscriptionsParams, CustomerSubscriptionsResponse, IdentifierPattern, ListMappingTemplatesParams, EdiMappingTemplate, CreateMappingTemplateRequest, UpdateMappingTemplateRequest, CsvHeaderMappingCollection, CsvDataTransformationConfig, IngestCsvResult, DryRunResult } from '@neo-edi/types';
|
|
2
|
-
export { AddSubCustomerRequest, AddSubCustomerResponse, Address, ApiResponse, CreateCustomerRequest, CreateMappingTemplateRequest, CreatePartnerRequest, CsvDataTransformationConfig, CsvHeaderMappingCollection, CsvHeaderMappingConfig, CsvHeaderTableEntry, DryRunResult, Edi852DeliverySummary, Edi852Header, Edi852HeaderFilter, Edi852Item, Edi852Location, Edi852Status, EdiCustomer, EdiMappingTemplate, EdiPartner, EdiPartnerCustomer, IngestCsvResult, ListCustomersParams, ListMappingTemplatesParams, ListSubCustomersParams, PaginatedResponse, PartnerCustomerRegistrationResult, RegisterPartnerCustomerRequest, SubCustomer, SubCustomersResponse, UpdateCustomerRequest, UpdateMappingTemplateRequest, UpdatePartnerRequest } from '@neo-edi/types';
|
|
1
|
+
import { ListCustomersParams, EdiCustomer, CustomerIdentifierType, CreateCustomerRequest, UpdateCustomerRequest, ListSubCustomersParams, SubCustomerWithIdentifiers, SubCustomer, AddSubCustomerResponse, CreateSubCustomerRequest, CreateSubCustomerResponse, EdiPartner, RegisterPartnerCustomerRequest, PartnerCustomerRegistrationResult, GetSubscriptionsParams, CustomerSubscriptionsResponse, IdentifierPattern, ListMappingTemplatesParams, EdiMappingTemplate, CreateMappingTemplateRequest, UpdateMappingTemplateRequest, CsvHeaderMappingCollection, CsvDataTransformationConfig, IngestCsvResult, DryRunResult, WebhookEndpoint, CreateWebhookRequest, WebhookEndpointWithSecret, UpdateWebhookRequest, ListWebhookDeliveriesParams, WebhookDelivery } from '@neo-edi/types';
|
|
2
|
+
export { AddSubCustomerRequest, AddSubCustomerResponse, Address, ApiResponse, CreateCustomerRequest, CreateMappingTemplateRequest, CreatePartnerRequest, CreateWebhookRequest, CsvDataTransformationConfig, CsvHeaderMappingCollection, CsvHeaderMappingConfig, CsvHeaderTableEntry, DryRunResult, Edi852DeliverySummary, Edi852Header, Edi852HeaderFilter, Edi852Item, Edi852Location, Edi852Status, EdiCustomer, EdiMappingTemplate, EdiPartner, EdiPartnerCustomer, IngestCsvResult, ListCustomersParams, ListMappingTemplatesParams, ListSubCustomersParams, ListWebhookDeliveriesParams, PaginatedResponse, PartnerCustomerRegistrationResult, RegisterPartnerCustomerRequest, SubCustomer, SubCustomersResponse, UpdateCustomerRequest, UpdateMappingTemplateRequest, UpdatePartnerRequest, UpdateWebhookRequest, WebhookDelivery, WebhookDeliveryStatus, WebhookEndpoint, WebhookEndpointWithSecret, WebhookEventType } from '@neo-edi/types';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Base HTTP client for the SDK
|
|
@@ -440,6 +440,49 @@ declare const Queries: {
|
|
|
440
440
|
GET_EXECUTION_SUMMARIES: string;
|
|
441
441
|
};
|
|
442
442
|
|
|
443
|
+
/**
|
|
444
|
+
* Webhooks resource
|
|
445
|
+
*
|
|
446
|
+
* Register endpoints that receive HMAC-signed HTTP callbacks when events occur
|
|
447
|
+
* for a trading partner — e.g. `document.ingested` when a delivery is ingested.
|
|
448
|
+
*
|
|
449
|
+
* Verifying incoming webhooks (on your receiver):
|
|
450
|
+
* const expected = "sha256=" + hmacSHA256(`${timestamp}.${rawBody}`, signingSecret)
|
|
451
|
+
* compare against the `v1=` value in the `X-Webhook-Signature` header, where
|
|
452
|
+
* `timestamp` is the `X-Webhook-Timestamp` header (and the `t=` value).
|
|
453
|
+
*/
|
|
454
|
+
|
|
455
|
+
declare class WebhooksResource {
|
|
456
|
+
private http;
|
|
457
|
+
constructor(http: HttpClient);
|
|
458
|
+
/**
|
|
459
|
+
* List webhook endpoints for a trading partner.
|
|
460
|
+
*/
|
|
461
|
+
list(partnerId: string): Promise<WebhookEndpoint[]>;
|
|
462
|
+
/**
|
|
463
|
+
* Get a single webhook endpoint by id.
|
|
464
|
+
*/
|
|
465
|
+
get(endpointId: string): Promise<WebhookEndpoint>;
|
|
466
|
+
/**
|
|
467
|
+
* Create (subscribe) a webhook endpoint. The returned object includes the
|
|
468
|
+
* `signingSecret` — store it now, it is never returned again.
|
|
469
|
+
*/
|
|
470
|
+
create(data: CreateWebhookRequest): Promise<WebhookEndpointWithSecret>;
|
|
471
|
+
/**
|
|
472
|
+
* Update a webhook endpoint (url, description, subscribed events, or enable/
|
|
473
|
+
* disable via `isActive`).
|
|
474
|
+
*/
|
|
475
|
+
update(endpointId: string, data: UpdateWebhookRequest): Promise<WebhookEndpoint>;
|
|
476
|
+
/**
|
|
477
|
+
* Delete (unsubscribe) a webhook endpoint.
|
|
478
|
+
*/
|
|
479
|
+
delete(endpointId: string): Promise<void>;
|
|
480
|
+
/**
|
|
481
|
+
* List recent delivery attempts for an endpoint (audit / debugging).
|
|
482
|
+
*/
|
|
483
|
+
listDeliveries(endpointId: string, params?: ListWebhookDeliveriesParams): Promise<WebhookDelivery[]>;
|
|
484
|
+
}
|
|
485
|
+
|
|
443
486
|
/**
|
|
444
487
|
* Neo-EDI SDK Client
|
|
445
488
|
*/
|
|
@@ -529,6 +572,10 @@ declare class NeoEdiClient {
|
|
|
529
572
|
* GraphQL query operations
|
|
530
573
|
*/
|
|
531
574
|
readonly graphql: GraphQLResource;
|
|
575
|
+
/**
|
|
576
|
+
* Webhook subscription operations
|
|
577
|
+
*/
|
|
578
|
+
readonly webhooks: WebhooksResource;
|
|
532
579
|
constructor(config: NeoEdiClientConfig);
|
|
533
580
|
}
|
|
534
581
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ListCustomersParams, EdiCustomer, CustomerIdentifierType, CreateCustomerRequest, UpdateCustomerRequest, ListSubCustomersParams, SubCustomerWithIdentifiers, SubCustomer, AddSubCustomerResponse, CreateSubCustomerRequest, CreateSubCustomerResponse, EdiPartner, RegisterPartnerCustomerRequest, PartnerCustomerRegistrationResult, GetSubscriptionsParams, CustomerSubscriptionsResponse, IdentifierPattern, ListMappingTemplatesParams, EdiMappingTemplate, CreateMappingTemplateRequest, UpdateMappingTemplateRequest, CsvHeaderMappingCollection, CsvDataTransformationConfig, IngestCsvResult, DryRunResult } from '@neo-edi/types';
|
|
2
|
-
export { AddSubCustomerRequest, AddSubCustomerResponse, Address, ApiResponse, CreateCustomerRequest, CreateMappingTemplateRequest, CreatePartnerRequest, CsvDataTransformationConfig, CsvHeaderMappingCollection, CsvHeaderMappingConfig, CsvHeaderTableEntry, DryRunResult, Edi852DeliverySummary, Edi852Header, Edi852HeaderFilter, Edi852Item, Edi852Location, Edi852Status, EdiCustomer, EdiMappingTemplate, EdiPartner, EdiPartnerCustomer, IngestCsvResult, ListCustomersParams, ListMappingTemplatesParams, ListSubCustomersParams, PaginatedResponse, PartnerCustomerRegistrationResult, RegisterPartnerCustomerRequest, SubCustomer, SubCustomersResponse, UpdateCustomerRequest, UpdateMappingTemplateRequest, UpdatePartnerRequest } from '@neo-edi/types';
|
|
1
|
+
import { ListCustomersParams, EdiCustomer, CustomerIdentifierType, CreateCustomerRequest, UpdateCustomerRequest, ListSubCustomersParams, SubCustomerWithIdentifiers, SubCustomer, AddSubCustomerResponse, CreateSubCustomerRequest, CreateSubCustomerResponse, EdiPartner, RegisterPartnerCustomerRequest, PartnerCustomerRegistrationResult, GetSubscriptionsParams, CustomerSubscriptionsResponse, IdentifierPattern, ListMappingTemplatesParams, EdiMappingTemplate, CreateMappingTemplateRequest, UpdateMappingTemplateRequest, CsvHeaderMappingCollection, CsvDataTransformationConfig, IngestCsvResult, DryRunResult, WebhookEndpoint, CreateWebhookRequest, WebhookEndpointWithSecret, UpdateWebhookRequest, ListWebhookDeliveriesParams, WebhookDelivery } from '@neo-edi/types';
|
|
2
|
+
export { AddSubCustomerRequest, AddSubCustomerResponse, Address, ApiResponse, CreateCustomerRequest, CreateMappingTemplateRequest, CreatePartnerRequest, CreateWebhookRequest, CsvDataTransformationConfig, CsvHeaderMappingCollection, CsvHeaderMappingConfig, CsvHeaderTableEntry, DryRunResult, Edi852DeliverySummary, Edi852Header, Edi852HeaderFilter, Edi852Item, Edi852Location, Edi852Status, EdiCustomer, EdiMappingTemplate, EdiPartner, EdiPartnerCustomer, IngestCsvResult, ListCustomersParams, ListMappingTemplatesParams, ListSubCustomersParams, ListWebhookDeliveriesParams, PaginatedResponse, PartnerCustomerRegistrationResult, RegisterPartnerCustomerRequest, SubCustomer, SubCustomersResponse, UpdateCustomerRequest, UpdateMappingTemplateRequest, UpdatePartnerRequest, UpdateWebhookRequest, WebhookDelivery, WebhookDeliveryStatus, WebhookEndpoint, WebhookEndpointWithSecret, WebhookEventType } from '@neo-edi/types';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Base HTTP client for the SDK
|
|
@@ -440,6 +440,49 @@ declare const Queries: {
|
|
|
440
440
|
GET_EXECUTION_SUMMARIES: string;
|
|
441
441
|
};
|
|
442
442
|
|
|
443
|
+
/**
|
|
444
|
+
* Webhooks resource
|
|
445
|
+
*
|
|
446
|
+
* Register endpoints that receive HMAC-signed HTTP callbacks when events occur
|
|
447
|
+
* for a trading partner — e.g. `document.ingested` when a delivery is ingested.
|
|
448
|
+
*
|
|
449
|
+
* Verifying incoming webhooks (on your receiver):
|
|
450
|
+
* const expected = "sha256=" + hmacSHA256(`${timestamp}.${rawBody}`, signingSecret)
|
|
451
|
+
* compare against the `v1=` value in the `X-Webhook-Signature` header, where
|
|
452
|
+
* `timestamp` is the `X-Webhook-Timestamp` header (and the `t=` value).
|
|
453
|
+
*/
|
|
454
|
+
|
|
455
|
+
declare class WebhooksResource {
|
|
456
|
+
private http;
|
|
457
|
+
constructor(http: HttpClient);
|
|
458
|
+
/**
|
|
459
|
+
* List webhook endpoints for a trading partner.
|
|
460
|
+
*/
|
|
461
|
+
list(partnerId: string): Promise<WebhookEndpoint[]>;
|
|
462
|
+
/**
|
|
463
|
+
* Get a single webhook endpoint by id.
|
|
464
|
+
*/
|
|
465
|
+
get(endpointId: string): Promise<WebhookEndpoint>;
|
|
466
|
+
/**
|
|
467
|
+
* Create (subscribe) a webhook endpoint. The returned object includes the
|
|
468
|
+
* `signingSecret` — store it now, it is never returned again.
|
|
469
|
+
*/
|
|
470
|
+
create(data: CreateWebhookRequest): Promise<WebhookEndpointWithSecret>;
|
|
471
|
+
/**
|
|
472
|
+
* Update a webhook endpoint (url, description, subscribed events, or enable/
|
|
473
|
+
* disable via `isActive`).
|
|
474
|
+
*/
|
|
475
|
+
update(endpointId: string, data: UpdateWebhookRequest): Promise<WebhookEndpoint>;
|
|
476
|
+
/**
|
|
477
|
+
* Delete (unsubscribe) a webhook endpoint.
|
|
478
|
+
*/
|
|
479
|
+
delete(endpointId: string): Promise<void>;
|
|
480
|
+
/**
|
|
481
|
+
* List recent delivery attempts for an endpoint (audit / debugging).
|
|
482
|
+
*/
|
|
483
|
+
listDeliveries(endpointId: string, params?: ListWebhookDeliveriesParams): Promise<WebhookDelivery[]>;
|
|
484
|
+
}
|
|
485
|
+
|
|
443
486
|
/**
|
|
444
487
|
* Neo-EDI SDK Client
|
|
445
488
|
*/
|
|
@@ -529,6 +572,10 @@ declare class NeoEdiClient {
|
|
|
529
572
|
* GraphQL query operations
|
|
530
573
|
*/
|
|
531
574
|
readonly graphql: GraphQLResource;
|
|
575
|
+
/**
|
|
576
|
+
* Webhook subscription operations
|
|
577
|
+
*/
|
|
578
|
+
readonly webhooks: WebhooksResource;
|
|
532
579
|
constructor(config: NeoEdiClientConfig);
|
|
533
580
|
}
|
|
534
581
|
|
package/dist/index.js
CHANGED
|
@@ -63,7 +63,7 @@ var NeoEdiValidationError = class extends NeoEdiError {
|
|
|
63
63
|
// package.json
|
|
64
64
|
var package_default = {
|
|
65
65
|
name: "@neo-edi/sdk",
|
|
66
|
-
version: "1.0.
|
|
66
|
+
version: "1.0.21",
|
|
67
67
|
description: "TypeScript SDK for the Neo-EDI platform",
|
|
68
68
|
main: "./dist/index.js",
|
|
69
69
|
module: "./dist/index.mjs",
|
|
@@ -786,6 +786,84 @@ var Queries = {
|
|
|
786
786
|
`
|
|
787
787
|
};
|
|
788
788
|
|
|
789
|
+
// src/resources/webhooks.ts
|
|
790
|
+
var WebhooksResource = class {
|
|
791
|
+
constructor(http) {
|
|
792
|
+
this.http = http;
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* List webhook endpoints for a trading partner.
|
|
796
|
+
*/
|
|
797
|
+
async list(partnerId) {
|
|
798
|
+
const response = await this.http.get(
|
|
799
|
+
"/api/v1/webhooks",
|
|
800
|
+
{ partnerId }
|
|
801
|
+
);
|
|
802
|
+
if (!response.success) {
|
|
803
|
+
throw new Error(response.error);
|
|
804
|
+
}
|
|
805
|
+
return response.data;
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Get a single webhook endpoint by id.
|
|
809
|
+
*/
|
|
810
|
+
async get(endpointId) {
|
|
811
|
+
const response = await this.http.get(
|
|
812
|
+
`/api/v1/webhooks/${encodeURIComponent(endpointId)}`
|
|
813
|
+
);
|
|
814
|
+
if (!response.success) {
|
|
815
|
+
throw new Error(response.error);
|
|
816
|
+
}
|
|
817
|
+
return response.data;
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* Create (subscribe) a webhook endpoint. The returned object includes the
|
|
821
|
+
* `signingSecret` — store it now, it is never returned again.
|
|
822
|
+
*/
|
|
823
|
+
async create(data) {
|
|
824
|
+
const response = await this.http.post("/api/v1/webhooks", data);
|
|
825
|
+
if (!response.success) {
|
|
826
|
+
throw new Error(response.error);
|
|
827
|
+
}
|
|
828
|
+
return response.data;
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Update a webhook endpoint (url, description, subscribed events, or enable/
|
|
832
|
+
* disable via `isActive`).
|
|
833
|
+
*/
|
|
834
|
+
async update(endpointId, data) {
|
|
835
|
+
const response = await this.http.patch(
|
|
836
|
+
`/api/v1/webhooks/${encodeURIComponent(endpointId)}`,
|
|
837
|
+
data
|
|
838
|
+
);
|
|
839
|
+
if (!response.success) {
|
|
840
|
+
throw new Error(response.error);
|
|
841
|
+
}
|
|
842
|
+
return response.data;
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Delete (unsubscribe) a webhook endpoint.
|
|
846
|
+
*/
|
|
847
|
+
async delete(endpointId) {
|
|
848
|
+
await this.http.delete(
|
|
849
|
+
`/api/v1/webhooks/${encodeURIComponent(endpointId)}`
|
|
850
|
+
);
|
|
851
|
+
}
|
|
852
|
+
/**
|
|
853
|
+
* List recent delivery attempts for an endpoint (audit / debugging).
|
|
854
|
+
*/
|
|
855
|
+
async listDeliveries(endpointId, params) {
|
|
856
|
+
const response = await this.http.get(
|
|
857
|
+
`/api/v1/webhooks/${encodeURIComponent(endpointId)}/deliveries`,
|
|
858
|
+
params
|
|
859
|
+
);
|
|
860
|
+
if (!response.success) {
|
|
861
|
+
throw new Error(response.error);
|
|
862
|
+
}
|
|
863
|
+
return response.data;
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
|
|
789
867
|
// src/client.ts
|
|
790
868
|
var NeoEdiClient = class {
|
|
791
869
|
constructor(config) {
|
|
@@ -803,6 +881,7 @@ var NeoEdiClient = class {
|
|
|
803
881
|
this.mappingTemplates = new MappingTemplatesResource(this.http);
|
|
804
882
|
this.ingest = new IngestResource(this.http);
|
|
805
883
|
this.graphql = new GraphQLResource(this.http);
|
|
884
|
+
this.webhooks = new WebhooksResource(this.http);
|
|
806
885
|
}
|
|
807
886
|
};
|
|
808
887
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -32,7 +32,7 @@ var NeoEdiValidationError = class extends NeoEdiError {
|
|
|
32
32
|
// package.json
|
|
33
33
|
var package_default = {
|
|
34
34
|
name: "@neo-edi/sdk",
|
|
35
|
-
version: "1.0.
|
|
35
|
+
version: "1.0.21",
|
|
36
36
|
description: "TypeScript SDK for the Neo-EDI platform",
|
|
37
37
|
main: "./dist/index.js",
|
|
38
38
|
module: "./dist/index.mjs",
|
|
@@ -755,6 +755,84 @@ var Queries = {
|
|
|
755
755
|
`
|
|
756
756
|
};
|
|
757
757
|
|
|
758
|
+
// src/resources/webhooks.ts
|
|
759
|
+
var WebhooksResource = class {
|
|
760
|
+
constructor(http) {
|
|
761
|
+
this.http = http;
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* List webhook endpoints for a trading partner.
|
|
765
|
+
*/
|
|
766
|
+
async list(partnerId) {
|
|
767
|
+
const response = await this.http.get(
|
|
768
|
+
"/api/v1/webhooks",
|
|
769
|
+
{ partnerId }
|
|
770
|
+
);
|
|
771
|
+
if (!response.success) {
|
|
772
|
+
throw new Error(response.error);
|
|
773
|
+
}
|
|
774
|
+
return response.data;
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Get a single webhook endpoint by id.
|
|
778
|
+
*/
|
|
779
|
+
async get(endpointId) {
|
|
780
|
+
const response = await this.http.get(
|
|
781
|
+
`/api/v1/webhooks/${encodeURIComponent(endpointId)}`
|
|
782
|
+
);
|
|
783
|
+
if (!response.success) {
|
|
784
|
+
throw new Error(response.error);
|
|
785
|
+
}
|
|
786
|
+
return response.data;
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* Create (subscribe) a webhook endpoint. The returned object includes the
|
|
790
|
+
* `signingSecret` — store it now, it is never returned again.
|
|
791
|
+
*/
|
|
792
|
+
async create(data) {
|
|
793
|
+
const response = await this.http.post("/api/v1/webhooks", data);
|
|
794
|
+
if (!response.success) {
|
|
795
|
+
throw new Error(response.error);
|
|
796
|
+
}
|
|
797
|
+
return response.data;
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Update a webhook endpoint (url, description, subscribed events, or enable/
|
|
801
|
+
* disable via `isActive`).
|
|
802
|
+
*/
|
|
803
|
+
async update(endpointId, data) {
|
|
804
|
+
const response = await this.http.patch(
|
|
805
|
+
`/api/v1/webhooks/${encodeURIComponent(endpointId)}`,
|
|
806
|
+
data
|
|
807
|
+
);
|
|
808
|
+
if (!response.success) {
|
|
809
|
+
throw new Error(response.error);
|
|
810
|
+
}
|
|
811
|
+
return response.data;
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Delete (unsubscribe) a webhook endpoint.
|
|
815
|
+
*/
|
|
816
|
+
async delete(endpointId) {
|
|
817
|
+
await this.http.delete(
|
|
818
|
+
`/api/v1/webhooks/${encodeURIComponent(endpointId)}`
|
|
819
|
+
);
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* List recent delivery attempts for an endpoint (audit / debugging).
|
|
823
|
+
*/
|
|
824
|
+
async listDeliveries(endpointId, params) {
|
|
825
|
+
const response = await this.http.get(
|
|
826
|
+
`/api/v1/webhooks/${encodeURIComponent(endpointId)}/deliveries`,
|
|
827
|
+
params
|
|
828
|
+
);
|
|
829
|
+
if (!response.success) {
|
|
830
|
+
throw new Error(response.error);
|
|
831
|
+
}
|
|
832
|
+
return response.data;
|
|
833
|
+
}
|
|
834
|
+
};
|
|
835
|
+
|
|
758
836
|
// src/client.ts
|
|
759
837
|
var NeoEdiClient = class {
|
|
760
838
|
constructor(config) {
|
|
@@ -772,6 +850,7 @@ var NeoEdiClient = class {
|
|
|
772
850
|
this.mappingTemplates = new MappingTemplatesResource(this.http);
|
|
773
851
|
this.ingest = new IngestResource(this.http);
|
|
774
852
|
this.graphql = new GraphQLResource(this.http);
|
|
853
|
+
this.webhooks = new WebhooksResource(this.http);
|
|
775
854
|
}
|
|
776
855
|
};
|
|
777
856
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neo-edi/sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
4
4
|
"description": "TypeScript SDK for the Neo-EDI platform",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@neo-edi/types": "1.0.
|
|
19
|
+
"@neo-edi/types": "1.0.21"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/node": "^20",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"typescript": "^5.0.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@neo-edi/types": "1.0.
|
|
27
|
+
"@neo-edi/types": "1.0.21"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "tsup src/index.ts --format cjs,esm --dts",
|