@ebitex/forms-sdk 0.3.84 → 0.4.86
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 +7 -0
- package/dist/client.d.ts +7 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +25 -3
- package/dist/client.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,6 +43,13 @@ function ContactPage({ form }: { form: SdkForm }) {
|
|
|
43
43
|
endpoint ebitex's own hosted page and iframe embed use — so it never needs your API key either.
|
|
44
44
|
Multi-step forms save progress as the respondent advances.
|
|
45
45
|
|
|
46
|
+
### Errors
|
|
47
|
+
|
|
48
|
+
`getForm` throws `FormsApiError` for a non-2xx response, carrying `status`, the parsed `body`, and
|
|
49
|
+
`requestId`: the request's reference, from the `X-Request-Id` response header or an unhandled
|
|
50
|
+
`500`'s body (`null` when a proxy answered and the request never reached ebitex). The message ends
|
|
51
|
+
`[request <id>]` when there is one. Log it, and quote it to support.
|
|
52
|
+
|
|
46
53
|
## Rendering nodes yourself
|
|
47
54
|
|
|
48
55
|
If you're not using `<EbitexForm>` — building a custom renderer, or validating a submission
|
package/dist/client.d.ts
CHANGED
|
@@ -20,11 +20,17 @@ export interface FormsClientOptions {
|
|
|
20
20
|
* organization's subscription needs attention), 404 (no such form for this organization), 409 (the
|
|
21
21
|
* form has two fields sharing a submission key and must be fixed in the Forms editor), 429 (rate
|
|
22
22
|
* limited — a `Retry-After` header accompanies it).
|
|
23
|
+
*
|
|
24
|
+
* `requestId` is the request's reference (spec 739-request-correlation-id): the `X-Request-Id`
|
|
25
|
+
* response header, else the body's `requestId` (an unhandled `500` carries it there too), else
|
|
26
|
+
* `null` — as it is for a response a proxy generated, which never reached the API. Quote it to
|
|
27
|
+
* support; it is how that request is found in the logs.
|
|
23
28
|
*/
|
|
24
29
|
export declare class FormsApiError extends Error {
|
|
25
30
|
readonly status: number;
|
|
26
31
|
readonly body: unknown;
|
|
27
|
-
|
|
32
|
+
readonly requestId: string | null;
|
|
33
|
+
constructor(status: number, body: unknown, requestId?: string | null);
|
|
28
34
|
}
|
|
29
35
|
export interface FormsClient {
|
|
30
36
|
getForm(externalId: string): Promise<SdkForm>;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEzC,MAAM,WAAW,kBAAkB;IACjC;;;;;;;OAOG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd,2FAA2F;IAC3F,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB,uEAAuE;IACvE,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;CAChC;AAED
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEzC,MAAM,WAAW,kBAAkB;IACjC;;;;;;;OAOG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd,2FAA2F;IAC3F,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB,uEAAuE;IACvE,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;CAChC;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;gBAErB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,GAAE,MAAM,GAAG,IAAW;CAO3E;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CAC9C;AAID,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CA6B1E"}
|
package/dist/client.js
CHANGED
|
@@ -4,15 +4,22 @@
|
|
|
4
4
|
* organization's subscription needs attention), 404 (no such form for this organization), 409 (the
|
|
5
5
|
* form has two fields sharing a submission key and must be fixed in the Forms editor), 429 (rate
|
|
6
6
|
* limited — a `Retry-After` header accompanies it).
|
|
7
|
+
*
|
|
8
|
+
* `requestId` is the request's reference (spec 739-request-correlation-id): the `X-Request-Id`
|
|
9
|
+
* response header, else the body's `requestId` (an unhandled `500` carries it there too), else
|
|
10
|
+
* `null` — as it is for a response a proxy generated, which never reached the API. Quote it to
|
|
11
|
+
* support; it is how that request is found in the logs.
|
|
7
12
|
*/
|
|
8
13
|
export class FormsApiError extends Error {
|
|
9
14
|
status;
|
|
10
15
|
body;
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
requestId;
|
|
17
|
+
constructor(status, body, requestId = null) {
|
|
18
|
+
super(`ebitex Forms API request failed with status ${status}${requestId ? ` [request ${requestId}]` : ''}`);
|
|
13
19
|
this.name = 'FormsApiError';
|
|
14
20
|
this.status = status;
|
|
15
21
|
this.body = body;
|
|
22
|
+
this.requestId = requestId;
|
|
16
23
|
}
|
|
17
24
|
}
|
|
18
25
|
const DEFAULT_BASE_URL = 'https://api.ebitex.io';
|
|
@@ -32,7 +39,8 @@ export function createFormsClient(options) {
|
|
|
32
39
|
},
|
|
33
40
|
});
|
|
34
41
|
if (!response.ok) {
|
|
35
|
-
|
|
42
|
+
const body = await readBody(response);
|
|
43
|
+
throw new FormsApiError(response.status, body, readRequestId(response, body));
|
|
36
44
|
}
|
|
37
45
|
return (await response.json());
|
|
38
46
|
},
|
|
@@ -47,4 +55,18 @@ async function readBody(response) {
|
|
|
47
55
|
return null;
|
|
48
56
|
}
|
|
49
57
|
}
|
|
58
|
+
/** The request's reference (spec 739): the `X-Request-Id` header first; an unhandled `500` also carries `requestId` in its body. */
|
|
59
|
+
function readRequestId(response, body) {
|
|
60
|
+
const header = response.headers.get('X-Request-Id');
|
|
61
|
+
if (header) {
|
|
62
|
+
return header;
|
|
63
|
+
}
|
|
64
|
+
if (typeof body === 'object' && body !== null && 'requestId' in body) {
|
|
65
|
+
const requestId = body.requestId;
|
|
66
|
+
if (typeof requestId === 'string' && requestId) {
|
|
67
|
+
return requestId;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
50
72
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAoBA
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAoBA;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,MAAM,CAAQ;IACd,IAAI,CAAS;IACb,SAAS,CAAe;IAEjC,YAAY,MAAc,EAAE,IAAa,EAAE,YAA2B,IAAI;QACxE,KAAK,CAAC,+CAA+C,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,aAAa,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QAC3G,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;CACF;AAMD,MAAM,gBAAgB,GAAG,uBAAuB,CAAA;AAEhD,MAAM,UAAU,iBAAiB,CAAC,OAA2B;IAC3D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;IAC1B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAA;IAC1D,CAA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