@ontemper/edi 1.1.4 → 1.1.5

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.
Files changed (3) hide show
  1. package/README.md +16 -11
  2. package/dist/index.js +4 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -150,18 +150,23 @@ the document, so keep the file and retry (`error.retryable === true`).
150
150
  ```typescript
151
151
  import { isEdiInfrastructureError, isTemperEdiClientError } from '@ontemper/edi';
152
152
 
153
- try {
154
- await edi.fromX12({ input: rawX12 });
155
- } catch (error) {
156
- if (isEdiInfrastructureError(error)) {
157
- // Transient platform fault — the document is fine. Keep the file, retry later.
158
- throw error;
159
- }
160
- if (isTemperEdiClientError(error)) {
161
- // A verdict on the document (see codes below) — route the file to your error handling.
162
- console.error('EDI Error:', error.code, error.message);
153
+ async function processFile(rawX12: string) {
154
+ try {
155
+ return await edi.fromX12({ input: rawX12 });
156
+ } catch (error) {
157
+ if (isEdiInfrastructureError(error)) {
158
+ // Transient platform fault — the document is fine. Keep the file and rethrow
159
+ // so your poll loop / caller retries.
160
+ throw error;
161
+ }
162
+ if (isTemperEdiClientError(error)) {
163
+ // A verdict on the document (see codes below) — handle it terminally (e.g.
164
+ // quarantine the file) and STOP. Do not rethrow into retry paths.
165
+ console.error('EDI Error:', error.code, error.message);
166
+ return undefined;
167
+ }
168
+ throw error; // unrecognized — surface to the caller
163
169
  }
164
- throw error;
165
170
  }
166
171
  ```
167
172
 
package/dist/index.js CHANGED
@@ -112,9 +112,11 @@ class TemperEdiClient {
112
112
  if (error instanceof EdiInfrastructureError)
113
113
  throw error;
114
114
  if ((0, axios_1.isAxiosError)(error)) {
115
- if (error.status === 403)
115
+ // 401 = missing/expired/invalid credential (e.g. the sandbox EDI-gateway JWT),
116
+ // 403 = access denied. Neither is a verdict on the document.
117
+ if (error.status === 401 || error.status === 403)
116
118
  throw new TemperEdiClientError({
117
- message: 'Unauthorized access to EDI service. Reach out to support.',
119
+ message: 'Unauthorized access to EDI service (credentials missing, expired, or invalid). Reach out to support.',
118
120
  code: 'edi_unauthorized_error',
119
121
  });
120
122
  // Transport failures (no response: ECONNREFUSED/timeout/DNS), 5xx, and
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ontemper/edi",
3
3
  "description": "An EDI client with structured logging.",
4
- "version": "1.1.4",
4
+ "version": "1.1.5",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "author": "Unnbound Team",