@supscale/sculdoc-client 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 +84 -0
- package/dist/client.d.ts +78 -0
- package/dist/client.js +146 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +57 -0
- package/dist/errors.js +108 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated/api.d.ts +4322 -0
- package/dist/generated/api.js +2 -0
- package/dist/generated/api.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/webhooks.d.ts +14 -0
- package/dist/webhooks.js +40 -0
- package/dist/webhooks.js.map +1 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# @supscale/sculdoc-client (TypeScript)
|
|
2
|
+
|
|
3
|
+
Client de l'API Sculdoc pour Node 20+ (et tout environnement `fetch`) : rendus synchrones en flux, jobs (lots, attente avec repli exponentiel), contrats des versions de templates, erreurs typées, vérification des webhooks. Les types sont générés depuis `apps/api/openapi.json` par openapi-typescript (`src/generated/api.ts`, ne pas modifier à la main) ; la couche mince (`client.ts`, `errors.ts`, `webhooks.ts`) est écrite à la main. Mêmes concepts que les clients Java, C# et Python (`clients/README.md`).
|
|
4
|
+
|
|
5
|
+
*Client of the Sculdoc API for Node 20+: streamed synchronous renders, jobs, contracts of template versions, typed errors, webhook verification.*
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Paquet public sur npmjs, comme `@supscale/logger` : aucun registre ni jeton à configurer.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @supscale/sculdoc-client # ou npm install
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Le SDK d'une version (`sculdoc sdk generate --lang ts`) embarque ce client : pas d'accès au registre nécessaire.
|
|
16
|
+
|
|
17
|
+
## Démarrage
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { SculdocClient } from '@supscale/sculdoc-client';
|
|
21
|
+
|
|
22
|
+
const client = new SculdocClient({ baseUrl: 'https://api.example.com', apiKey: process.env.SCULDOC_API_KEY ?? '' });
|
|
23
|
+
const pdf = await client.render({ template: 'certificat', version: 1, data: { customer: { name: 'Ada' } } });
|
|
24
|
+
await writeFile('certificat.pdf', await pdf.bytes()); // ou pdf.body : ReadableStream, lu une seule fois
|
|
25
|
+
console.log(pdf.renderId, pdf.version, pdf.pages, pdf.sha256);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- `baseUrl` sans `/v1` (ajouté par le client) ; clé d'API de l'organisation (`x-api-key`).
|
|
29
|
+
- **Épingler la version** en production (`version: 1`). Avec `'latest'`, l'API répond avec l'avertissement `version.latest` (ou refuse en `422 version.unpinned` si l'organisation l'exige) ; les avertissements passent par `onWarning` (`console.warn` par défaut).
|
|
30
|
+
- `idempotencyKey` (rendus, jobs) : un rejeu renvoie le premier résultat pendant 24 h ; la même clé avec une autre requête est un `ConflictError`.
|
|
31
|
+
- `call(method, path, …)` : toute autre opération de l'API, erreurs typées.
|
|
32
|
+
|
|
33
|
+
## Jobs et lots
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
const job = await client.runJob(
|
|
37
|
+
{ template: 'certificat', version: 1, items: [{ data: a, filename: 'a.pdf' }, { data: b }], output: 'zip' },
|
|
38
|
+
{ idempotencyKey: 'lot-2026-10-04' },
|
|
39
|
+
);
|
|
40
|
+
console.log((await client.jobOutput(job.id)).url); // URL signée de l'archive
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`submitJob` dépose le job (avertissements transmis) ; `waitForJob(id, { timeoutMs, initialDelayMs, maxDelayMs, signal })` interroge avec repli exponentiel (500 ms doublés jusqu'à 15 s, 10 min au plus) et renvoie le job réussi, sinon lève `JobFailedError` (`.job.error`) ou `JobTimeoutError` (le job continue). `jobItems(id, { status, limit, cursor })` liste les documents d'un lot. Plutôt que d'attendre : `callbackUrl` dans la requête, ou un abonnement webhook.
|
|
44
|
+
|
|
45
|
+
## Contrats
|
|
46
|
+
|
|
47
|
+
`validate({ template, version, data })` (rapport avec chemins JSON), `templates()`, `versions(template)`, `version(template, n)`, `schema(template, n)` (JSON Schema 2020-12), `getRender(id)`, `getDocument(id)` (URL signée).
|
|
48
|
+
|
|
49
|
+
## Erreurs
|
|
50
|
+
|
|
51
|
+
| Classe | Statut | Cas |
|
|
52
|
+
|---|---|---|
|
|
53
|
+
| `BadRequestError` | 400 | requête mal formée |
|
|
54
|
+
| `AuthenticationError` | 401 | clé absente ou révoquée |
|
|
55
|
+
| `PermissionDeniedError` | 403 | clé de rendu qui publie, portée de dossier |
|
|
56
|
+
| `NotFoundError` | 404 | template, version, rendu, job inconnu dans l'organisation |
|
|
57
|
+
| `ConflictError` | 409 | clé d'idempotence réutilisée avec une autre requête, publication concurrente |
|
|
58
|
+
| `GoneError` | 410 | version archivée, document supprimé par la rétention |
|
|
59
|
+
| `ValidationError` | 422 | données refusées par le contrat, version non épinglée refusée (`issues` : chemins JSON) |
|
|
60
|
+
| `RateLimitError` | 429 | limite de la clé ou quota de l'organisation ; `retryAfter` en secondes |
|
|
61
|
+
|
|
62
|
+
Toutes dérivent de `SculdocApiError` (`status`, `code`, `message`, `issues`, `requestId` à citer au support), elle-même de `SculdocError`, comme `JobFailedError`, `JobTimeoutError` et `WebhookSignatureError`.
|
|
63
|
+
|
|
64
|
+
## Webhooks
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { SIGNATURE_HEADER, verifyWebhook } from '@supscale/sculdoc-client';
|
|
68
|
+
|
|
69
|
+
const event = await verifyWebhook(secret, req.headers[SIGNATURE_HEADER], rawBody); // corps brut, avant JSON.parse
|
|
70
|
+
if (alreadySeen(event.id)) return; // une livraison peut être rejouée
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Signature HMAC-SHA256 de `<t>.<corps>` (`X-Sculdoc-Signature: t=…,v1=…`), comparée en temps constant ; horodatage refusé au-delà de 5 minutes (`toleranceSeconds`). Secret : celui de l'abonnement (`whsec_…`), ou le secret de rappel de l'organisation pour le `callbackUrl` d'un job.
|
|
74
|
+
|
|
75
|
+
## Exemple
|
|
76
|
+
|
|
77
|
+
`examples/render-certificate.ts` : rendu épinglé puis lot de deux documents (`SCULDOC_URL`, `SCULDOC_API_KEY`).
|
|
78
|
+
|
|
79
|
+
## Développement
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
pnpm --filter @supscale/sculdoc-client test # faux serveur fetch : rendu, jobs, erreurs, webhooks
|
|
83
|
+
pnpm --filter @sculdoc/clients generate # régénère les quatre clients depuis apps/api/openapi.json
|
|
84
|
+
```
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { components, paths } from './generated/api.js';
|
|
2
|
+
type Schemas = components['schemas'];
|
|
3
|
+
export type RenderRequest = Schemas['RenderRequest'];
|
|
4
|
+
export type JobRequest = Schemas['JobRequest'];
|
|
5
|
+
export type BatchItem = Schemas['BatchItem'];
|
|
6
|
+
export type Render = Schemas['Render'];
|
|
7
|
+
export type RenderDetail = Schemas['RenderDetail'];
|
|
8
|
+
export type Document = Schemas['Document'];
|
|
9
|
+
export type Job = Schemas['Job'];
|
|
10
|
+
export type JobAccepted = Schemas['JobAccepted'];
|
|
11
|
+
export type JobItem = Schemas['JobItem'];
|
|
12
|
+
export type JobOutput = Schemas['JobOutput'];
|
|
13
|
+
export type Validation = Schemas['Validation'];
|
|
14
|
+
export type Template = Schemas['Template'];
|
|
15
|
+
export type VersionSummary = Schemas['VersionSummary'];
|
|
16
|
+
export type Version = Schemas['Version'];
|
|
17
|
+
export type ApiWarning = Schemas['Warning'];
|
|
18
|
+
export type ValidateRequest = paths['/validate']['post']['requestBody']['content']['application/json'];
|
|
19
|
+
export type JobItemsQuery = NonNullable<paths['/jobs/{jobId}/items']['get']['parameters']['query']>;
|
|
20
|
+
export type JobItemsPage = paths['/jobs/{jobId}/items']['get']['responses']['200']['content']['application/json'];
|
|
21
|
+
export type DataSchema = Record<string, unknown>;
|
|
22
|
+
export type VersionRef = number | 'latest';
|
|
23
|
+
export interface ClientOptions {
|
|
24
|
+
baseUrl: string;
|
|
25
|
+
apiKey: string;
|
|
26
|
+
fetch?: typeof fetch;
|
|
27
|
+
onWarning?: (warning: ApiWarning) => void;
|
|
28
|
+
}
|
|
29
|
+
export interface RequestOptions {
|
|
30
|
+
idempotencyKey?: string;
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
}
|
|
33
|
+
export interface WaitOptions {
|
|
34
|
+
timeoutMs?: number;
|
|
35
|
+
initialDelayMs?: number;
|
|
36
|
+
maxDelayMs?: number;
|
|
37
|
+
signal?: AbortSignal;
|
|
38
|
+
}
|
|
39
|
+
export interface RenderedPdf {
|
|
40
|
+
renderId: string;
|
|
41
|
+
version: number | undefined;
|
|
42
|
+
pages: number | undefined;
|
|
43
|
+
sha256: string | undefined;
|
|
44
|
+
warnings: ApiWarning[];
|
|
45
|
+
body: ReadableStream<Uint8Array>;
|
|
46
|
+
bytes(): Promise<Uint8Array>;
|
|
47
|
+
}
|
|
48
|
+
export declare class SculdocClient {
|
|
49
|
+
private readonly o;
|
|
50
|
+
private readonly f;
|
|
51
|
+
private readonly base;
|
|
52
|
+
constructor(o: ClientOptions);
|
|
53
|
+
private warn;
|
|
54
|
+
call(method: string, path: string, o?: RequestOptions & {
|
|
55
|
+
body?: unknown;
|
|
56
|
+
accept?: string;
|
|
57
|
+
}): Promise<Response>;
|
|
58
|
+
private json;
|
|
59
|
+
render(request: RenderRequest, o?: RequestOptions): Promise<RenderedPdf>;
|
|
60
|
+
getRender(id: string): Promise<RenderDetail>;
|
|
61
|
+
getDocument(id: string): Promise<Document>;
|
|
62
|
+
submitJob(request: JobRequest, o?: RequestOptions): Promise<JobAccepted>;
|
|
63
|
+
getJob(id: string, o?: {
|
|
64
|
+
signal?: AbortSignal;
|
|
65
|
+
}): Promise<Job>;
|
|
66
|
+
waitForJob(id: string, o?: WaitOptions): Promise<Job>;
|
|
67
|
+
runJob(request: JobRequest, o?: RequestOptions & WaitOptions): Promise<Job>;
|
|
68
|
+
jobItems(id: string, query?: JobItemsQuery): Promise<JobItemsPage>;
|
|
69
|
+
jobOutput(id: string): Promise<JobOutput>;
|
|
70
|
+
validate(request: ValidateRequest): Promise<Validation>;
|
|
71
|
+
templates(o?: {
|
|
72
|
+
folderId?: string;
|
|
73
|
+
}): Promise<Template[]>;
|
|
74
|
+
versions(template: string): Promise<VersionSummary[]>;
|
|
75
|
+
version(template: string, version: VersionRef): Promise<Version>;
|
|
76
|
+
schema(template: string, version: VersionRef): Promise<DataSchema>;
|
|
77
|
+
}
|
|
78
|
+
export {};
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// Sculdoc API client: a thin `fetch` layer over the types generated from the OpenAPI document (generated/api.ts).
|
|
2
|
+
// API key authentication, synchronous renders streamed as PDF, jobs with exponential backoff, contracts of template
|
|
3
|
+
// versions, typed errors, and the warnings of the API (`version.latest`: pin a version in production).
|
|
4
|
+
import { errorFromResponse, JobFailedError, JobTimeoutError } from './errors.js';
|
|
5
|
+
const sleep = (ms, signal) => new Promise((resolve, reject) => {
|
|
6
|
+
const timer = setTimeout(resolve, ms);
|
|
7
|
+
signal?.addEventListener('abort', () => {
|
|
8
|
+
clearTimeout(timer);
|
|
9
|
+
reject(signal.reason);
|
|
10
|
+
}, { once: true });
|
|
11
|
+
});
|
|
12
|
+
const segment = (v) => encodeURIComponent(String(v));
|
|
13
|
+
export class SculdocClient {
|
|
14
|
+
o;
|
|
15
|
+
f;
|
|
16
|
+
base;
|
|
17
|
+
constructor(o) {
|
|
18
|
+
this.o = o;
|
|
19
|
+
this.f = o.fetch ?? fetch;
|
|
20
|
+
this.base = `${o.baseUrl.replace(/\/+$/, '')}/v1`;
|
|
21
|
+
}
|
|
22
|
+
warn(warnings) {
|
|
23
|
+
const report = this.o.onWarning ?? ((w) => console.warn(`sculdoc: ${w.code}: ${w.message}`));
|
|
24
|
+
for (const w of warnings ?? [])
|
|
25
|
+
report(w);
|
|
26
|
+
}
|
|
27
|
+
// Escape hatch: any operation of the API (`path` after /v1), errors typed. Prefer the methods below.
|
|
28
|
+
async call(method, path, o = {}) {
|
|
29
|
+
const headers = new Headers({ 'x-api-key': this.o.apiKey, accept: o.accept ?? 'application/json' });
|
|
30
|
+
if (o.body !== undefined)
|
|
31
|
+
headers.set('content-type', 'application/json');
|
|
32
|
+
if (o.idempotencyKey)
|
|
33
|
+
headers.set('idempotency-key', o.idempotencyKey);
|
|
34
|
+
const res = await this.f(`${this.base}${path}`, {
|
|
35
|
+
method,
|
|
36
|
+
headers,
|
|
37
|
+
...(o.body !== undefined ? { body: JSON.stringify(o.body) } : {}),
|
|
38
|
+
...(o.signal ? { signal: o.signal } : {}),
|
|
39
|
+
});
|
|
40
|
+
if (!res.ok)
|
|
41
|
+
throw await errorFromResponse(res);
|
|
42
|
+
return res;
|
|
43
|
+
}
|
|
44
|
+
// The shapes are those of the OpenAPI document the API answers to (generated/api.ts).
|
|
45
|
+
async json(method, path, o = {}) {
|
|
46
|
+
return (await (await this.call(method, path, o)).json());
|
|
47
|
+
}
|
|
48
|
+
// ---- renders --------------------------------------------------------------------------------------------------
|
|
49
|
+
// Synchronous render (light limits; larger documents go through jobs). The PDF is streamed.
|
|
50
|
+
async render(request, o = {}) {
|
|
51
|
+
const res = await this.call('POST', '/renders', { ...o, body: request, accept: 'application/pdf' });
|
|
52
|
+
const resolved = res.headers.get('x-sculdoc-version-resolved');
|
|
53
|
+
const warnings = (res.headers.get('x-sculdoc-warning') ?? '')
|
|
54
|
+
.split(',')
|
|
55
|
+
.map((code) => code.trim())
|
|
56
|
+
.filter(Boolean)
|
|
57
|
+
.map((code) => ({
|
|
58
|
+
code,
|
|
59
|
+
message: code === 'version.latest'
|
|
60
|
+
? `version "latest" resolved to ${resolved ?? '?'}: pin a version number in production`
|
|
61
|
+
: code,
|
|
62
|
+
}));
|
|
63
|
+
this.warn(warnings);
|
|
64
|
+
const pages = res.headers.get('x-sculdoc-pages');
|
|
65
|
+
const body = res.body ?? new ReadableStream({ start: (c) => c.close() });
|
|
66
|
+
return {
|
|
67
|
+
renderId: res.headers.get('x-sculdoc-render-id') ?? '',
|
|
68
|
+
version: resolved ? Number(resolved) : undefined,
|
|
69
|
+
pages: pages ? Number(pages) : undefined,
|
|
70
|
+
sha256: res.headers.get('x-sculdoc-pdf-sha256') || undefined,
|
|
71
|
+
warnings,
|
|
72
|
+
body,
|
|
73
|
+
bytes: async () => new Uint8Array(await new Response(body).arrayBuffer()),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
getRender(id) {
|
|
77
|
+
return this.json('GET', `/renders/${segment(id)}`);
|
|
78
|
+
}
|
|
79
|
+
// Time-limited signed URL of a stored PDF (id of a render, or of an item of a batch).
|
|
80
|
+
getDocument(id) {
|
|
81
|
+
return this.json('GET', `/documents/${segment(id)}`);
|
|
82
|
+
}
|
|
83
|
+
// ---- jobs -----------------------------------------------------------------------------------------------------
|
|
84
|
+
// Asynchronous render, one document or a batch (`items`). Give a `callbackUrl` to be notified instead of polling.
|
|
85
|
+
async submitJob(request, o = {}) {
|
|
86
|
+
const job = await this.json('POST', '/jobs', { ...o, body: request });
|
|
87
|
+
this.warn(job.warnings);
|
|
88
|
+
return job;
|
|
89
|
+
}
|
|
90
|
+
getJob(id, o = {}) {
|
|
91
|
+
return this.json('GET', `/jobs/${segment(id)}`, o);
|
|
92
|
+
}
|
|
93
|
+
// Polls with exponential backoff until the job ends: the succeeded job, else JobFailedError or JobTimeoutError.
|
|
94
|
+
async waitForJob(id, o = {}) {
|
|
95
|
+
const deadline = Date.now() + (o.timeoutMs ?? 600_000);
|
|
96
|
+
let delay = o.initialDelayMs ?? 500;
|
|
97
|
+
for (;;) {
|
|
98
|
+
const job = await this.getJob(id, o.signal ? { signal: o.signal } : {});
|
|
99
|
+
if (job.status === 'succeeded')
|
|
100
|
+
return job;
|
|
101
|
+
if (job.status === 'failed')
|
|
102
|
+
throw new JobFailedError(job);
|
|
103
|
+
const left = deadline - Date.now();
|
|
104
|
+
if (left <= 0)
|
|
105
|
+
throw new JobTimeoutError(job);
|
|
106
|
+
await sleep(Math.min(delay, left), o.signal);
|
|
107
|
+
delay = Math.min(delay * 2, o.maxDelayMs ?? 15_000);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// submitJob + waitForJob.
|
|
111
|
+
async runJob(request, o = {}) {
|
|
112
|
+
const job = await this.submitJob(request, o);
|
|
113
|
+
return this.waitForJob(job.id, o);
|
|
114
|
+
}
|
|
115
|
+
jobItems(id, query = {}) {
|
|
116
|
+
const q = new URLSearchParams(Object.entries(query).map(([k, v]) => [k, String(v)])).toString();
|
|
117
|
+
return this.json('GET', `/jobs/${segment(id)}/items${q ? `?${q}` : ''}`);
|
|
118
|
+
}
|
|
119
|
+
// Signed URL of the ZIP archive or of the merged PDF of a succeeded batch.
|
|
120
|
+
jobOutput(id) {
|
|
121
|
+
return this.json('GET', `/jobs/${segment(id)}/output`);
|
|
122
|
+
}
|
|
123
|
+
// ---- contracts --------------------------------------------------------------------------------------------------
|
|
124
|
+
// Dry run: data checked against the contract of a version, issues with JSON paths.
|
|
125
|
+
async validate(request) {
|
|
126
|
+
const v = await this.json('POST', '/validate', { body: request });
|
|
127
|
+
this.warn(v.warnings);
|
|
128
|
+
return v;
|
|
129
|
+
}
|
|
130
|
+
async templates(o = {}) {
|
|
131
|
+
const q = o.folderId ? `?folderId=${segment(o.folderId)}` : '';
|
|
132
|
+
return (await this.json('GET', `/templates${q}`)).templates;
|
|
133
|
+
}
|
|
134
|
+
async versions(template) {
|
|
135
|
+
return (await this.json('GET', `/templates/${segment(template)}/versions`))
|
|
136
|
+
.versions;
|
|
137
|
+
}
|
|
138
|
+
version(template, version) {
|
|
139
|
+
return this.json('GET', `/templates/${segment(template)}/versions/${segment(version)}`);
|
|
140
|
+
}
|
|
141
|
+
// Data contract of a version (JSON Schema 2020-12).
|
|
142
|
+
schema(template, version) {
|
|
143
|
+
return this.json('GET', `/templates/${segment(template)}/versions/${segment(version)}/schema`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,oHAAoH;AACpH,uGAAuG;AACvG,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAyDjF,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,MAAoB,EAAE,EAAE,CAClD,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;IACrC,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACtC,MAAM,EAAE,gBAAgB,CACvB,OAAO,EACP,GAAG,EAAE;QACJ,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC,EACD,EAAE,IAAI,EAAE,IAAI,EAAE,CACd,CAAC;AACH,CAAC,CAAC,CAAC;AAEJ,MAAM,OAAO,GAAG,CAAC,CAAkB,EAAE,EAAE,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAEtE,MAAM,OAAO,aAAa;IAGI;IAFZ,CAAC,CAAe;IAChB,IAAI,CAAS;IAC9B,YAA6B,CAAgB;QAAhB,MAAC,GAAD,CAAC,CAAe;QAC5C,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC;IACnD,CAAC;IAEO,IAAI,CA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AAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/D,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAA4B,KAAK,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACxF,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,QAAgB;QAC9B,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAiC,KAAK,EAAE,cAAc,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;aACzG,QAAQ,CAAC;IACZ,CAAC;IAED,OAAO,CAAC,QAAgB,EAAE,OAAmB;QAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,cAAc,OAAO,CAAC,QAAQ,CAAC,aAAa,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACzF,CAAC;IAED,oDAAoD;IACpD,MAAM,CAAC,QAAgB,EAAE,OAAmB;QAC3C,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,cAAc,OAAO,CAAC,QAAQ,CAAC,aAAa,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChG,CAAC;CACD"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { components } from './generated/api.js';
|
|
2
|
+
export type ApiErrorBody = components['schemas']['Error'];
|
|
3
|
+
export interface Issue {
|
|
4
|
+
path: string;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class SculdocError extends Error {
|
|
8
|
+
name: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class SculdocApiError extends SculdocError {
|
|
11
|
+
name: string;
|
|
12
|
+
readonly status: number;
|
|
13
|
+
readonly code: string;
|
|
14
|
+
readonly issues: Issue[];
|
|
15
|
+
readonly requestId: string | undefined;
|
|
16
|
+
constructor(status: number, body: ApiErrorBody | undefined, fallback?: string);
|
|
17
|
+
}
|
|
18
|
+
export declare class BadRequestError extends SculdocApiError {
|
|
19
|
+
name: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class AuthenticationError extends SculdocApiError {
|
|
22
|
+
name: string;
|
|
23
|
+
}
|
|
24
|
+
export declare class PermissionDeniedError extends SculdocApiError {
|
|
25
|
+
name: string;
|
|
26
|
+
}
|
|
27
|
+
export declare class NotFoundError extends SculdocApiError {
|
|
28
|
+
name: string;
|
|
29
|
+
}
|
|
30
|
+
export declare class ConflictError extends SculdocApiError {
|
|
31
|
+
name: string;
|
|
32
|
+
}
|
|
33
|
+
export declare class GoneError extends SculdocApiError {
|
|
34
|
+
name: string;
|
|
35
|
+
}
|
|
36
|
+
export declare class ValidationError extends SculdocApiError {
|
|
37
|
+
name: string;
|
|
38
|
+
}
|
|
39
|
+
export declare class RateLimitError extends SculdocApiError {
|
|
40
|
+
name: string;
|
|
41
|
+
readonly retryAfter: number | undefined;
|
|
42
|
+
constructor(status: number, body: ApiErrorBody | undefined, retryAfter: number | undefined);
|
|
43
|
+
}
|
|
44
|
+
export declare class JobFailedError extends SculdocError {
|
|
45
|
+
readonly job: components['schemas']['Job'];
|
|
46
|
+
name: string;
|
|
47
|
+
constructor(job: components['schemas']['Job']);
|
|
48
|
+
}
|
|
49
|
+
export declare class JobTimeoutError extends SculdocError {
|
|
50
|
+
readonly job: components['schemas']['Job'];
|
|
51
|
+
name: string;
|
|
52
|
+
constructor(job: components['schemas']['Job']);
|
|
53
|
+
}
|
|
54
|
+
export declare class WebhookSignatureError extends SculdocError {
|
|
55
|
+
name: string;
|
|
56
|
+
}
|
|
57
|
+
export declare function errorFromResponse(res: Response): Promise<SculdocApiError>;
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
export class SculdocError extends Error {
|
|
2
|
+
name = 'SculdocError';
|
|
3
|
+
}
|
|
4
|
+
// Any non-2xx answer of the API.
|
|
5
|
+
export class SculdocApiError extends SculdocError {
|
|
6
|
+
name = 'SculdocApiError';
|
|
7
|
+
status;
|
|
8
|
+
code;
|
|
9
|
+
issues;
|
|
10
|
+
requestId;
|
|
11
|
+
constructor(status, body, fallback = `HTTP ${status}`) {
|
|
12
|
+
super(body?.error.message ?? fallback);
|
|
13
|
+
this.status = status;
|
|
14
|
+
this.code = body?.error.code ?? `http.${status}`;
|
|
15
|
+
this.issues = body?.error.issues ?? [];
|
|
16
|
+
this.requestId = body?.requestId;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
// 400: malformed request (JSON, parameters).
|
|
20
|
+
export class BadRequestError extends SculdocApiError {
|
|
21
|
+
name = 'BadRequestError';
|
|
22
|
+
}
|
|
23
|
+
// 401: missing or revoked API key.
|
|
24
|
+
export class AuthenticationError extends SculdocApiError {
|
|
25
|
+
name = 'AuthenticationError';
|
|
26
|
+
}
|
|
27
|
+
// 403: the API key may not do this (render key publishing, folder scope).
|
|
28
|
+
export class PermissionDeniedError extends SculdocApiError {
|
|
29
|
+
name = 'PermissionDeniedError';
|
|
30
|
+
}
|
|
31
|
+
// 404: template, version, render, job… not found in the organization of the key.
|
|
32
|
+
export class NotFoundError extends SculdocApiError {
|
|
33
|
+
name = 'NotFoundError';
|
|
34
|
+
}
|
|
35
|
+
// 409: conflict with the current state (idempotency key reused with another body, concurrent publication…).
|
|
36
|
+
export class ConflictError extends SculdocApiError {
|
|
37
|
+
name = 'ConflictError';
|
|
38
|
+
}
|
|
39
|
+
// 410: archived version, document deleted by the retention.
|
|
40
|
+
export class GoneError extends SculdocApiError {
|
|
41
|
+
name = 'GoneError';
|
|
42
|
+
}
|
|
43
|
+
// 422: data refused by the contract of the version, publication refused, unpinned version refused (`issues`).
|
|
44
|
+
export class ValidationError extends SculdocApiError {
|
|
45
|
+
name = 'ValidationError';
|
|
46
|
+
}
|
|
47
|
+
// 429: rate limit of the key or quota of the organization; `retryAfter` seconds before the same request may succeed.
|
|
48
|
+
export class RateLimitError extends SculdocApiError {
|
|
49
|
+
name = 'RateLimitError';
|
|
50
|
+
retryAfter;
|
|
51
|
+
constructor(status, body, retryAfter) {
|
|
52
|
+
super(status, body);
|
|
53
|
+
this.retryAfter = body?.error.retryAfter ?? retryAfter;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// A job that ended in `failed`; `job.error` tells why.
|
|
57
|
+
export class JobFailedError extends SculdocError {
|
|
58
|
+
job;
|
|
59
|
+
name = 'JobFailedError';
|
|
60
|
+
constructor(job) {
|
|
61
|
+
super(`job ${job.id} failed${job.error ? `: ${job.error.code}: ${job.error.message}` : ''}`);
|
|
62
|
+
this.job = job;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// `waitForJob` gave up before the job ended (the job goes on: wait again or use a webhook).
|
|
66
|
+
export class JobTimeoutError extends SculdocError {
|
|
67
|
+
job;
|
|
68
|
+
name = 'JobTimeoutError';
|
|
69
|
+
constructor(job) {
|
|
70
|
+
super(`job ${job.id} still ${job.status} after the wait timeout`);
|
|
71
|
+
this.job = job;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// A webhook delivery whose signature or timestamp does not check out.
|
|
75
|
+
export class WebhookSignatureError extends SculdocError {
|
|
76
|
+
name = 'WebhookSignatureError';
|
|
77
|
+
}
|
|
78
|
+
const isRecord = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
79
|
+
const isErrorBody = (v) => isRecord(v) && isRecord(v.error) && typeof v.error.code === 'string' && typeof v.error.message === 'string';
|
|
80
|
+
export async function errorFromResponse(res) {
|
|
81
|
+
const parsed = await res.json().catch(() => undefined);
|
|
82
|
+
const body = isErrorBody(parsed)
|
|
83
|
+
? { ...parsed, error: { ...parsed.error, issues: parsed.error.issues ?? [] } }
|
|
84
|
+
: undefined;
|
|
85
|
+
switch (res.status) {
|
|
86
|
+
case 400:
|
|
87
|
+
return new BadRequestError(res.status, body);
|
|
88
|
+
case 401:
|
|
89
|
+
return new AuthenticationError(res.status, body);
|
|
90
|
+
case 403:
|
|
91
|
+
return new PermissionDeniedError(res.status, body);
|
|
92
|
+
case 404:
|
|
93
|
+
return new NotFoundError(res.status, body);
|
|
94
|
+
case 409:
|
|
95
|
+
return new ConflictError(res.status, body);
|
|
96
|
+
case 410:
|
|
97
|
+
return new GoneError(res.status, body);
|
|
98
|
+
case 422:
|
|
99
|
+
return new ValidationError(res.status, body);
|
|
100
|
+
case 429: {
|
|
101
|
+
const header = Number(res.headers.get('retry-after'));
|
|
102
|
+
return new RateLimitError(res.status, body, Number.isFinite(header) && header > 0 ? header : undefined);
|
|
103
|
+
}
|
|
104
|
+
default:
|
|
105
|
+
return new SculdocApiError(res.status, body);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAUA,MAAM,OAAO,YAAa,SAAQ,KAAK;IAC7B,IAAI,GAAG,cAAc,CAAC;CAC/B;AAED,iCAAiC;AACjC,MAAM,OAAO,eAAgB,SAAQ,YAAY;IACvC,IAAI,GAAG,iBAAiB,CAAC;IACzB,MAAM,CAAS;IACf,IAAI,CAAS;IACb,MAAM,CAAU;IAChB,SAAS,CAAqB;IACvC,YAAY,MAAc,EAAE,IAA8B,EAAE,QAAQ,GAAG,QAAQ,MAAM,EAAE;QACtF,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,IAAI,QAAQ,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,QAAQ,MAAM,EAAE,CAAC;QACjD,IAAI,CAAC,MAAM,GAAG,IAAI,EAAE,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,IAAI,EAAE,SAAS,CAAC;IAClC,CAAC;CACD;AAED,6CAA6C;AAC7C,MAAM,OAAO,eAAgB,SAAQ,eAAe;IAC1C,IAAI,GAAG,iBAAiB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