@neo-edi/sdk 0.1.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.
- package/README.md +203 -0
- package/dist/index.d.mts +289 -0
- package/dist/index.d.ts +289 -0
- package/dist/index.js +512 -0
- package/dist/index.mjs +480 -0
- package/package.json +34 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { ListCustomersParams, EdiCustomer, CreateCustomerRequest, UpdateCustomerRequest, RegisterPartnerCustomerRequest, PartnerCustomerRegistrationResult, ListMappingTemplatesParams, EdiMappingTemplate, CreateMappingTemplateRequest, UpdateMappingTemplateRequest, CsvHeaderMappingCollection, CsvDataTransformationConfig, IngestCsvResult, DryRunResult } from '@neo-edi/types';
|
|
2
|
+
export { Address, ApiResponse, CreateCustomerRequest, CreateMappingTemplateRequest, CreatePartnerRequest, CsvDataTransformationConfig, CsvHeaderMappingCollection, CsvHeaderMappingConfig, CsvHeaderTableEntry, DryRunResult, Edi852DeliverySummary, Edi852Header, Edi852HeaderFilter, Edi852Item, Edi852Location, Edi852Status, EdiCustomer, EdiMappingTemplate, EdiPartner, EdiPartnerCustomer, IngestCsvResult, ListCustomersParams, ListMappingTemplatesParams, PaginatedResponse, PartnerCustomerRegistrationResult, RegisterPartnerCustomerRequest, UpdateCustomerRequest, UpdateMappingTemplateRequest, UpdatePartnerRequest } from '@neo-edi/types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Base HTTP client for the SDK
|
|
6
|
+
*/
|
|
7
|
+
interface HttpClientConfig {
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
apiKey: string;
|
|
10
|
+
timeout?: number;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
interface RequestOptions {
|
|
14
|
+
method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
|
|
15
|
+
path: string;
|
|
16
|
+
body?: unknown;
|
|
17
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
18
|
+
headers?: Record<string, string>;
|
|
19
|
+
}
|
|
20
|
+
declare class HttpClient {
|
|
21
|
+
private baseUrl;
|
|
22
|
+
private apiKey;
|
|
23
|
+
private timeout;
|
|
24
|
+
private defaultHeaders;
|
|
25
|
+
constructor(config: HttpClientConfig);
|
|
26
|
+
request<T>(options: RequestOptions): Promise<T>;
|
|
27
|
+
private buildUrl;
|
|
28
|
+
private parseResponse;
|
|
29
|
+
get<T>(path: string, query?: Record<string, string | number | boolean | undefined>): Promise<T>;
|
|
30
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
31
|
+
patch<T>(path: string, body?: unknown): Promise<T>;
|
|
32
|
+
put<T>(path: string, body?: unknown): Promise<T>;
|
|
33
|
+
delete<T>(path: string): Promise<T>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Customers resource
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
declare class CustomersResource {
|
|
41
|
+
private http;
|
|
42
|
+
constructor(http: HttpClient);
|
|
43
|
+
/**
|
|
44
|
+
* List all customers
|
|
45
|
+
*/
|
|
46
|
+
list(params?: ListCustomersParams): Promise<EdiCustomer[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Get a customer by ID
|
|
49
|
+
*/
|
|
50
|
+
get(customerId: string): Promise<EdiCustomer>;
|
|
51
|
+
/**
|
|
52
|
+
* Create a new customer
|
|
53
|
+
*/
|
|
54
|
+
create(data: CreateCustomerRequest): Promise<EdiCustomer>;
|
|
55
|
+
/**
|
|
56
|
+
* Update a customer
|
|
57
|
+
*/
|
|
58
|
+
update(customerId: string, data: UpdateCustomerRequest): Promise<EdiCustomer>;
|
|
59
|
+
/**
|
|
60
|
+
* Delete a customer
|
|
61
|
+
*/
|
|
62
|
+
delete(customerId: string): Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Partner-Customers resource
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
declare class PartnerCustomersResource {
|
|
70
|
+
private http;
|
|
71
|
+
constructor(http: HttpClient);
|
|
72
|
+
/**
|
|
73
|
+
* Register customer-partner relationships
|
|
74
|
+
* Creates or activates relationships between a customer and multiple trading partners
|
|
75
|
+
*/
|
|
76
|
+
register(data: RegisterPartnerCustomerRequest): Promise<PartnerCustomerRegistrationResult>;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Mapping Templates resource
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
declare class MappingTemplatesResource {
|
|
84
|
+
private http;
|
|
85
|
+
constructor(http: HttpClient);
|
|
86
|
+
/**
|
|
87
|
+
* List all mapping templates
|
|
88
|
+
*/
|
|
89
|
+
list(params?: ListMappingTemplatesParams): Promise<EdiMappingTemplate[]>;
|
|
90
|
+
/**
|
|
91
|
+
* Get a mapping template by ID
|
|
92
|
+
*/
|
|
93
|
+
get(templateId: string): Promise<EdiMappingTemplate>;
|
|
94
|
+
/**
|
|
95
|
+
* Create a new mapping template
|
|
96
|
+
*/
|
|
97
|
+
create(data: CreateMappingTemplateRequest): Promise<EdiMappingTemplate>;
|
|
98
|
+
/**
|
|
99
|
+
* Update a mapping template
|
|
100
|
+
*/
|
|
101
|
+
update(templateId: string, data: UpdateMappingTemplateRequest): Promise<EdiMappingTemplate>;
|
|
102
|
+
/**
|
|
103
|
+
* Delete a mapping template
|
|
104
|
+
*/
|
|
105
|
+
delete(templateId: string): Promise<void>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Ingest resource for CSV data ingestion
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
interface UploadCsvOptions {
|
|
113
|
+
partnerId: string;
|
|
114
|
+
mappingConfig: CsvHeaderMappingCollection;
|
|
115
|
+
transformationConfig?: CsvDataTransformationConfig;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* File input type for CSV upload
|
|
119
|
+
* In browser: File or Blob
|
|
120
|
+
* In Node.js: Use `new Blob([buffer])` to convert Buffer to Blob
|
|
121
|
+
*/
|
|
122
|
+
type CsvFileInput = File | Blob;
|
|
123
|
+
declare class IngestResource {
|
|
124
|
+
private http;
|
|
125
|
+
constructor(http: HttpClient);
|
|
126
|
+
/**
|
|
127
|
+
* Upload a CSV file for ingestion
|
|
128
|
+
*
|
|
129
|
+
* @example Browser
|
|
130
|
+
* ```typescript
|
|
131
|
+
* const input = document.querySelector('input[type="file"]');
|
|
132
|
+
* const file = input.files[0];
|
|
133
|
+
* await client.ingest.uploadCsv(file, options);
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* @example Node.js
|
|
137
|
+
* ```typescript
|
|
138
|
+
* import { readFileSync } from 'fs';
|
|
139
|
+
* const buffer = readFileSync('data.csv');
|
|
140
|
+
* const blob = new Blob([buffer], { type: 'text/csv' });
|
|
141
|
+
* await client.ingest.uploadCsv(blob, options);
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
uploadCsv(file: CsvFileInput, options: UploadCsvOptions): Promise<IngestCsvResult>;
|
|
145
|
+
/**
|
|
146
|
+
* Perform a dry run of CSV ingestion (validation only)
|
|
147
|
+
*/
|
|
148
|
+
dryRun(file: CsvFileInput, options: UploadCsvOptions): Promise<DryRunResult>;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* GraphQL resource for flexible queries
|
|
153
|
+
*/
|
|
154
|
+
|
|
155
|
+
interface GraphQLRequestOptions {
|
|
156
|
+
operationName?: string;
|
|
157
|
+
}
|
|
158
|
+
declare class GraphQLResource {
|
|
159
|
+
private http;
|
|
160
|
+
constructor(http: HttpClient);
|
|
161
|
+
/**
|
|
162
|
+
* Execute a GraphQL query
|
|
163
|
+
*/
|
|
164
|
+
query<T>(query: string, variables?: Record<string, unknown>, options?: GraphQLRequestOptions): Promise<T>;
|
|
165
|
+
/**
|
|
166
|
+
* Execute a GraphQL mutation
|
|
167
|
+
*/
|
|
168
|
+
mutate<T>(mutation: string, variables?: Record<string, unknown>, options?: GraphQLRequestOptions): Promise<T>;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Pre-built GraphQL queries for common operations
|
|
172
|
+
*/
|
|
173
|
+
declare const Queries: {
|
|
174
|
+
/**
|
|
175
|
+
* Get EDI 852 headers with filtering
|
|
176
|
+
*/
|
|
177
|
+
GET_EDI_852_HEADERS: string;
|
|
178
|
+
/**
|
|
179
|
+
* Get a single EDI 852 header by ID with locations
|
|
180
|
+
*/
|
|
181
|
+
GET_EDI_852_HEADER_BY_ID: string;
|
|
182
|
+
/**
|
|
183
|
+
* Get trading partner execution summaries
|
|
184
|
+
*/
|
|
185
|
+
GET_EXECUTION_SUMMARIES: string;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Neo-EDI SDK Client
|
|
190
|
+
*/
|
|
191
|
+
|
|
192
|
+
interface NeoEdiClientConfig {
|
|
193
|
+
/**
|
|
194
|
+
* Base URL of the Neo-EDI API
|
|
195
|
+
* @example "https://api.neo-edi.com"
|
|
196
|
+
*/
|
|
197
|
+
baseUrl: string;
|
|
198
|
+
/**
|
|
199
|
+
* API key for authentication
|
|
200
|
+
* @example "nedk_live_xxxxxxxxxxxx"
|
|
201
|
+
*/
|
|
202
|
+
apiKey: string;
|
|
203
|
+
/**
|
|
204
|
+
* Request timeout in milliseconds (default: 30000)
|
|
205
|
+
*/
|
|
206
|
+
timeout?: number;
|
|
207
|
+
/**
|
|
208
|
+
* Additional headers to send with every request
|
|
209
|
+
*/
|
|
210
|
+
headers?: Record<string, string>;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Neo-EDI SDK Client
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```typescript
|
|
217
|
+
* const client = new NeoEdiClient({
|
|
218
|
+
* baseUrl: "https://api.neo-edi.com",
|
|
219
|
+
* apiKey: "nedk_live_xxxxxxxxxxxx"
|
|
220
|
+
* });
|
|
221
|
+
*
|
|
222
|
+
* // List customers
|
|
223
|
+
* const customers = await client.customers.list({ isActive: true });
|
|
224
|
+
*
|
|
225
|
+
* // Create a customer
|
|
226
|
+
* const customer = await client.customers.create({
|
|
227
|
+
* customerId: "ACME-001",
|
|
228
|
+
* customerName: "Acme Corporation"
|
|
229
|
+
* });
|
|
230
|
+
*
|
|
231
|
+
* // Upload CSV data
|
|
232
|
+
* const result = await client.ingest.uploadCsv(file, {
|
|
233
|
+
* partnerId: "PARTNER-001",
|
|
234
|
+
* mappingConfig: { ... }
|
|
235
|
+
* });
|
|
236
|
+
*
|
|
237
|
+
* // Run GraphQL query
|
|
238
|
+
* const data = await client.graphql.query(
|
|
239
|
+
* `query { edi852Headers { id reportDate } }`
|
|
240
|
+
* );
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
declare class NeoEdiClient {
|
|
244
|
+
private http;
|
|
245
|
+
/**
|
|
246
|
+
* Customer management operations
|
|
247
|
+
*/
|
|
248
|
+
readonly customers: CustomersResource;
|
|
249
|
+
/**
|
|
250
|
+
* Partner-Customer relationship operations
|
|
251
|
+
*/
|
|
252
|
+
readonly partnerCustomers: PartnerCustomersResource;
|
|
253
|
+
/**
|
|
254
|
+
* Mapping template operations
|
|
255
|
+
*/
|
|
256
|
+
readonly mappingTemplates: MappingTemplatesResource;
|
|
257
|
+
/**
|
|
258
|
+
* CSV data ingestion operations
|
|
259
|
+
*/
|
|
260
|
+
readonly ingest: IngestResource;
|
|
261
|
+
/**
|
|
262
|
+
* GraphQL query operations
|
|
263
|
+
*/
|
|
264
|
+
readonly graphql: GraphQLResource;
|
|
265
|
+
constructor(config: NeoEdiClientConfig);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* SDK error types
|
|
270
|
+
*/
|
|
271
|
+
declare class NeoEdiError extends Error {
|
|
272
|
+
readonly code?: string | undefined;
|
|
273
|
+
readonly statusCode?: number | undefined;
|
|
274
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
275
|
+
constructor(message: string, code?: string | undefined, statusCode?: number | undefined, details?: Record<string, unknown> | undefined);
|
|
276
|
+
}
|
|
277
|
+
declare class NeoEdiApiError extends NeoEdiError {
|
|
278
|
+
readonly statusCode: number;
|
|
279
|
+
constructor(message: string, statusCode: number, code?: string, details?: Record<string, unknown>);
|
|
280
|
+
}
|
|
281
|
+
declare class NeoEdiNetworkError extends NeoEdiError {
|
|
282
|
+
readonly cause?: Error | undefined;
|
|
283
|
+
constructor(message: string, cause?: Error | undefined);
|
|
284
|
+
}
|
|
285
|
+
declare class NeoEdiValidationError extends NeoEdiError {
|
|
286
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export { type CsvFileInput, NeoEdiApiError, NeoEdiClient, type NeoEdiClientConfig, NeoEdiError, NeoEdiNetworkError, NeoEdiValidationError, Queries, type UploadCsvOptions };
|