@xylex-group/athena 2.0.0 → 2.3.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 +287 -95
- package/dist/browser.cjs +4791 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +25 -0
- package/dist/browser.d.ts +25 -0
- package/dist/browser.js +4745 -0
- package/dist/browser.js.map +1 -0
- package/dist/cli/index.cjs +2087 -220
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +3 -2
- package/dist/cli/index.d.ts +3 -2
- package/dist/cli/index.js +2089 -222
- package/dist/cli/index.js.map +1 -1
- package/dist/cookies.cjs +890 -0
- package/dist/cookies.cjs.map +1 -0
- package/dist/cookies.d.cts +174 -0
- package/dist/cookies.d.ts +174 -0
- package/dist/cookies.js +869 -0
- package/dist/cookies.js.map +1 -0
- package/dist/index.cjs +3046 -1200
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -408
- package/dist/index.d.ts +8 -408
- package/dist/index.js +3045 -1202
- package/dist/index.js.map +1 -1
- package/dist/{model-form-CVOtC8jq.d.ts → model-form-BpDXlbxb.d.ts} +97 -2
- package/dist/{model-form-hXkvHS_3.d.cts → model-form-hoE2jHIi.d.cts} +97 -2
- package/dist/pipeline-BNIw8pDQ.d.ts +8 -0
- package/dist/pipeline-DNIpEsN8.d.cts +8 -0
- package/dist/react-email-BvyCZnfW.d.cts +610 -0
- package/dist/react-email-qPA1wjFV.d.ts +610 -0
- package/dist/react.cjs +30 -9
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +4 -4
- package/dist/react.d.ts +4 -4
- package/dist/react.js +30 -9
- package/dist/react.js.map +1 -1
- package/dist/{types-BnzoaNRC.d.cts → types-A5e97acl.d.cts} +2 -1
- package/dist/{types-BnzoaNRC.d.ts → types-A5e97acl.d.ts} +2 -1
- package/dist/{pipeline-CQgV-Yfo.d.ts → types-BnD22-vb.d.ts} +2 -7
- package/dist/{pipeline-C-cN0ACi.d.cts → types-bDlr4u7p.d.cts} +2 -7
- package/dist/utils.cjs +153 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +23 -0
- package/dist/utils.d.ts +23 -0
- package/dist/utils.js +146 -0
- package/dist/utils.js.map +1 -0
- package/package.json +87 -9
package/dist/react.cjs
CHANGED
|
@@ -93,23 +93,39 @@ function normalizeHeaderValue(value) {
|
|
|
93
93
|
function isRecord(value) {
|
|
94
94
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
95
95
|
}
|
|
96
|
+
function nonEmptyString(value) {
|
|
97
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
98
|
+
}
|
|
99
|
+
function resolveStructuredErrorPayload(payload) {
|
|
100
|
+
if (!isRecord(payload)) return null;
|
|
101
|
+
return isRecord(payload.error) ? payload.error : payload;
|
|
102
|
+
}
|
|
96
103
|
function resolveRequestId(headers) {
|
|
97
104
|
return headers.get("x-request-id") ?? headers.get("x-correlation-id") ?? headers.get("x-athena-request-id") ?? void 0;
|
|
98
105
|
}
|
|
99
106
|
function resolveErrorMessage(payload, fallback) {
|
|
100
|
-
|
|
101
|
-
|
|
107
|
+
const structuredPayload = resolveStructuredErrorPayload(payload);
|
|
108
|
+
if (structuredPayload) {
|
|
109
|
+
const messageCandidates = [structuredPayload.message, structuredPayload.error, structuredPayload.details];
|
|
102
110
|
for (const candidate of messageCandidates) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
111
|
+
const resolved = nonEmptyString(candidate);
|
|
112
|
+
if (resolved) return resolved;
|
|
106
113
|
}
|
|
107
114
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
115
|
+
const rawMessage = nonEmptyString(payload);
|
|
116
|
+
if (rawMessage) return rawMessage;
|
|
111
117
|
return fallback;
|
|
112
118
|
}
|
|
119
|
+
function resolveErrorHint(payload) {
|
|
120
|
+
const structuredPayload = resolveStructuredErrorPayload(payload);
|
|
121
|
+
return structuredPayload ? nonEmptyString(structuredPayload.hint) : void 0;
|
|
122
|
+
}
|
|
123
|
+
function resolveStatusText(response, payload) {
|
|
124
|
+
const rawStatusText = nonEmptyString(response.statusText);
|
|
125
|
+
if (rawStatusText) return rawStatusText;
|
|
126
|
+
const payloadRecord = isRecord(payload) ? payload : null;
|
|
127
|
+
return payloadRecord ? nonEmptyString(payloadRecord.statusText) ?? null : null;
|
|
128
|
+
}
|
|
113
129
|
function detailsFromError(error) {
|
|
114
130
|
return error.toDetails();
|
|
115
131
|
}
|
|
@@ -280,6 +296,7 @@ async function callAthena(config, endpoint, method, payload, options) {
|
|
|
280
296
|
return {
|
|
281
297
|
ok: false,
|
|
282
298
|
status: response.status,
|
|
299
|
+
statusText: resolveStatusText(response, parsedBody.parsed),
|
|
283
300
|
data: null,
|
|
284
301
|
error: invalidJsonError.message,
|
|
285
302
|
errorDetails: detailsFromError(invalidJsonError),
|
|
@@ -298,11 +315,13 @@ async function callAthena(config, endpoint, method, payload, options) {
|
|
|
298
315
|
status: response.status,
|
|
299
316
|
endpoint,
|
|
300
317
|
method,
|
|
301
|
-
requestId
|
|
318
|
+
requestId,
|
|
319
|
+
hint: resolveErrorHint(parsed)
|
|
302
320
|
});
|
|
303
321
|
return {
|
|
304
322
|
ok: false,
|
|
305
323
|
status: response.status,
|
|
324
|
+
statusText: resolveStatusText(response, parsed),
|
|
306
325
|
data: null,
|
|
307
326
|
error: httpError.message,
|
|
308
327
|
errorDetails: detailsFromError(httpError),
|
|
@@ -314,6 +333,7 @@ async function callAthena(config, endpoint, method, payload, options) {
|
|
|
314
333
|
return {
|
|
315
334
|
ok: true,
|
|
316
335
|
status: response.status,
|
|
336
|
+
statusText: resolveStatusText(response, parsed),
|
|
317
337
|
data: payloadData ?? null,
|
|
318
338
|
count: payloadCount,
|
|
319
339
|
error: void 0,
|
|
@@ -333,6 +353,7 @@ async function callAthena(config, endpoint, method, payload, options) {
|
|
|
333
353
|
return {
|
|
334
354
|
ok: false,
|
|
335
355
|
status: 0,
|
|
356
|
+
statusText: null,
|
|
336
357
|
data: null,
|
|
337
358
|
error: networkError.message,
|
|
338
359
|
errorDetails: detailsFromError(networkError),
|