@cat-factory/sdk 0.5.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/LICENSE +21 -0
- package/README.md +109 -0
- package/dist/client.d.ts +26 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +37 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +127 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +143 -0
- package/dist/errors.js.map +1 -0
- package/dist/http.d.ts +70 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +214 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/models.generated.d.ts +795 -0
- package/dist/models.generated.d.ts.map +1 -0
- package/dist/models.generated.js +79 -0
- package/dist/models.generated.js.map +1 -0
- package/dist/operations.generated.d.ts +399 -0
- package/dist/operations.generated.d.ts.map +1 -0
- package/dist/operations.generated.js +698 -0
- package/dist/operations.generated.js.map +1 -0
- package/dist/sse.d.ts +24 -0
- package/dist/sse.d.ts.map +1 -0
- package/dist/sse.js +124 -0
- package/dist/sse.js.map +1 -0
- package/package.json +49 -0
package/dist/http.js
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
// The transport: the one place that knows about auth, retries, timeouts and error mapping.
|
|
2
|
+
//
|
|
3
|
+
// The 38 generated operation methods do nothing but describe a request and hand it here, so any
|
|
4
|
+
// change to HOW the SDK talks to a deployment is a change to this file alone.
|
|
5
|
+
import { CatFactoryConnectionError, CatFactoryDecodeError, CatFactoryError, CatFactoryTimeoutError, toApiError, } from './errors.js';
|
|
6
|
+
import { readEventStream } from './sse.js';
|
|
7
|
+
/** SDK version, stamped into `User-Agent`. Kept in step with package.json by `check:sdk`. */
|
|
8
|
+
export const SDK_VERSION = '0.5.0';
|
|
9
|
+
/**
|
|
10
|
+
* Percent-encode a path parameter.
|
|
11
|
+
*
|
|
12
|
+
* `encodeURIComponent` and not a raw interpolation: an id is server-supplied but travels through
|
|
13
|
+
* a caller's own storage, and one carrying a `/` or a `?` would otherwise silently re-target the
|
|
14
|
+
* request at a different route rather than 404 on the id it names.
|
|
15
|
+
*/
|
|
16
|
+
export function encodePathSegment(value) {
|
|
17
|
+
return encodeURIComponent(value);
|
|
18
|
+
}
|
|
19
|
+
/** Whether a failed attempt may be replayed. */
|
|
20
|
+
function isRetriable(method, status) {
|
|
21
|
+
// A transport failure with no response (status null) tells us nothing about whether the
|
|
22
|
+
// server acted, so only a method that is idempotent BY DEFINITION may be replayed. `POST
|
|
23
|
+
// /jobs` and `POST /tasks/:id/start` both cost real LLM work, and a duplicate is not
|
|
24
|
+
// something the SDK may decide to risk on the caller's behalf.
|
|
25
|
+
const idempotent = method === 'GET' || method === 'HEAD' || method === 'DELETE';
|
|
26
|
+
if (!idempotent)
|
|
27
|
+
return false;
|
|
28
|
+
if (status === null)
|
|
29
|
+
return true;
|
|
30
|
+
return status === 429 || status === 502 || status === 503 || status === 504;
|
|
31
|
+
}
|
|
32
|
+
/** Full jitter on an exponential base, so a fleet of clients does not retry in lockstep. */
|
|
33
|
+
function backoffMs(attempt) {
|
|
34
|
+
return Math.round(Math.random() * Math.min(8_000, 250 * 2 ** attempt));
|
|
35
|
+
}
|
|
36
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
37
|
+
/** Serialize the query bag, dropping absent values so `?limit=undefined` is impossible. */
|
|
38
|
+
function buildQuery(query) {
|
|
39
|
+
if (!query)
|
|
40
|
+
return '';
|
|
41
|
+
const params = new URLSearchParams();
|
|
42
|
+
for (const [key, value] of Object.entries(query)) {
|
|
43
|
+
if (value === undefined || value === null)
|
|
44
|
+
continue;
|
|
45
|
+
params.append(key, String(value));
|
|
46
|
+
}
|
|
47
|
+
const rendered = params.toString();
|
|
48
|
+
return rendered ? `?${rendered}` : '';
|
|
49
|
+
}
|
|
50
|
+
export class Transport {
|
|
51
|
+
baseUrl;
|
|
52
|
+
apiKey;
|
|
53
|
+
timeoutMs;
|
|
54
|
+
maxRetries;
|
|
55
|
+
headers;
|
|
56
|
+
doFetch;
|
|
57
|
+
constructor(options) {
|
|
58
|
+
if (!options.baseUrl)
|
|
59
|
+
throw new Error('cat-factory SDK: `baseUrl` is required.');
|
|
60
|
+
if (!options.apiKey)
|
|
61
|
+
throw new Error('cat-factory SDK: `apiKey` is required.');
|
|
62
|
+
this.baseUrl = options.baseUrl.replace(/\/+$/, '');
|
|
63
|
+
this.apiKey = options.apiKey;
|
|
64
|
+
this.timeoutMs = options.timeoutMs ?? 30_000;
|
|
65
|
+
this.maxRetries = options.maxRetries ?? 2;
|
|
66
|
+
const agent = options.userAgent ? `${options.userAgent} ` : '';
|
|
67
|
+
this.headers = {
|
|
68
|
+
accept: 'application/json',
|
|
69
|
+
'user-agent': `${agent}cat-factory-sdk-js/${SDK_VERSION}`,
|
|
70
|
+
...options.headers,
|
|
71
|
+
};
|
|
72
|
+
this.doFetch = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
73
|
+
}
|
|
74
|
+
/** Perform a request, returning the decoded JSON body. */
|
|
75
|
+
async request(spec) {
|
|
76
|
+
const response = await this.send(spec, 'application/json');
|
|
77
|
+
const text = await response.text();
|
|
78
|
+
if (text.length === 0)
|
|
79
|
+
return undefined;
|
|
80
|
+
try {
|
|
81
|
+
return JSON.parse(text);
|
|
82
|
+
}
|
|
83
|
+
catch (cause) {
|
|
84
|
+
throw new CatFactoryDecodeError(`cat-factory SDK: ${spec.method} ${spec.path} returned a body that is not JSON.`, text, { cause });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** Perform a request whose success carries no body (a 204). */
|
|
88
|
+
async requestNoContent(spec) {
|
|
89
|
+
const response = await this.send(spec, 'application/json');
|
|
90
|
+
// Drain, so a keep-alive connection is returned to the pool rather than held open.
|
|
91
|
+
await response.arrayBuffer();
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Open a server-sent event stream. Deliberately NOT retried: a reconnect would replay the
|
|
95
|
+
* stream from its start, and the caller — who knows which events it has already acted on —
|
|
96
|
+
* is the only party that can decide whether that is safe.
|
|
97
|
+
*/
|
|
98
|
+
async stream(spec) {
|
|
99
|
+
const response = await this.send({ ...spec, options: { ...spec.options, maxRetries: 0 } }, 'text/event-stream');
|
|
100
|
+
if (!response.body) {
|
|
101
|
+
throw new CatFactoryConnectionError('cat-factory SDK: the event stream carried no body.');
|
|
102
|
+
}
|
|
103
|
+
return readEventStream(response.body);
|
|
104
|
+
}
|
|
105
|
+
async send(spec, accept) {
|
|
106
|
+
const url = `${this.baseUrl}${spec.path}${buildQuery(spec.query)}`;
|
|
107
|
+
const budget = spec.options.maxRetries ?? this.maxRetries;
|
|
108
|
+
let lastError;
|
|
109
|
+
for (let attempt = 0;; attempt += 1) {
|
|
110
|
+
const timeoutMs = spec.options.timeoutMs ?? this.timeoutMs;
|
|
111
|
+
const controller = new AbortController();
|
|
112
|
+
const onAbort = () => controller.abort(spec.options.signal?.reason);
|
|
113
|
+
spec.options.signal?.addEventListener('abort', onAbort, { once: true });
|
|
114
|
+
const timer = timeoutMs > 0 ? setTimeout(() => controller.abort(new DeadlineReached()), timeoutMs) : null;
|
|
115
|
+
try {
|
|
116
|
+
const response = await this.doFetch(url, {
|
|
117
|
+
method: spec.method,
|
|
118
|
+
headers: {
|
|
119
|
+
// Client headers, then per-call ones, then the three the SDK owns — which therefore
|
|
120
|
+
// win. An `authorization` the transport did not build, or an `accept` that disagrees
|
|
121
|
+
// with how the response is about to be read, are not customisations; they are the
|
|
122
|
+
// client not working. All four SDKs apply this same precedence.
|
|
123
|
+
...this.headers,
|
|
124
|
+
...spec.options.headers,
|
|
125
|
+
accept,
|
|
126
|
+
authorization: `Bearer ${this.apiKey}`,
|
|
127
|
+
...(spec.body === undefined ? {} : { 'content-type': 'application/json' }),
|
|
128
|
+
},
|
|
129
|
+
body: spec.body === undefined ? undefined : JSON.stringify(spec.body),
|
|
130
|
+
signal: controller.signal,
|
|
131
|
+
});
|
|
132
|
+
if (response.ok)
|
|
133
|
+
return response;
|
|
134
|
+
const requestId = response.headers.get('x-request-id');
|
|
135
|
+
if (attempt < budget && isRetriable(spec.method, response.status)) {
|
|
136
|
+
// Honour `Retry-After` when the server states one: it is the deployment's own
|
|
137
|
+
// knowledge of when the limit clears, which beats our blind backoff curve.
|
|
138
|
+
await sleep(retryAfterMs(response) ?? backoffMs(attempt));
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
throw toApiError(response.status, await readBodySafely(response), requestId);
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
// The CALLER's cancellation is checked FIRST, and on the signal rather than on the shape
|
|
145
|
+
// of the error: `abort(reason)` rejects the fetch with that reason verbatim, so a caller
|
|
146
|
+
// who aborts with a plain `new Error('user navigated away')` produces something whose
|
|
147
|
+
// `name` is not `AbortError`. Gating on the name alone let exactly that case fall through
|
|
148
|
+
// to the retry branch below — a cancelled GET was replayed to the budget and then
|
|
149
|
+
// reported as a connection failure, which is neither what happened nor what was asked
|
|
150
|
+
// for. A cancellation is the outcome the caller chose; it is never retried, and never
|
|
151
|
+
// re-wrapped.
|
|
152
|
+
if (spec.options.signal?.aborted)
|
|
153
|
+
throw spec.options.signal.reason ?? error;
|
|
154
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
155
|
+
// Ours, then: the deadline. Distinct from the above because a timeout is something the
|
|
156
|
+
// caller may want to retry with a longer budget.
|
|
157
|
+
throw new CatFactoryTimeoutError(`cat-factory SDK: ${spec.method} ${spec.path} exceeded ${timeoutMs}ms.`, { cause: error });
|
|
158
|
+
}
|
|
159
|
+
// An error we already classified (an API refusal) propagates untouched.
|
|
160
|
+
if (isSdkError(error))
|
|
161
|
+
throw error;
|
|
162
|
+
lastError = error;
|
|
163
|
+
if (attempt < budget && isRetriable(spec.method, null)) {
|
|
164
|
+
await sleep(backoffMs(attempt));
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
throw new CatFactoryConnectionError(`cat-factory SDK: ${spec.method} ${spec.path} failed to reach ${this.baseUrl}.`, { cause: lastError });
|
|
168
|
+
}
|
|
169
|
+
finally {
|
|
170
|
+
if (timer)
|
|
171
|
+
clearTimeout(timer);
|
|
172
|
+
spec.options.signal?.removeEventListener('abort', onAbort);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/** Marker carried by the abort reason our own deadline raises. */
|
|
178
|
+
class DeadlineReached extends Error {
|
|
179
|
+
name = 'AbortError';
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* An error this SDK already classified. It propagates untouched rather than being re-wrapped as
|
|
183
|
+
* a connection failure: an API refusal that reached us through the `catch` below is a verdict,
|
|
184
|
+
* not a transport fault, and re-wrapping it would hide the status the caller needs.
|
|
185
|
+
*/
|
|
186
|
+
function isSdkError(error) {
|
|
187
|
+
return error instanceof CatFactoryError;
|
|
188
|
+
}
|
|
189
|
+
/** Read a failed response's body without letting a decode fault mask the real failure. */
|
|
190
|
+
async function readBodySafely(response) {
|
|
191
|
+
const text = await response.text().catch(() => '');
|
|
192
|
+
if (!text)
|
|
193
|
+
return null;
|
|
194
|
+
try {
|
|
195
|
+
return JSON.parse(text);
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
return text;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/** `Retry-After` in ms — seconds or an HTTP date — or null when absent/unparsable. */
|
|
202
|
+
function retryAfterMs(response) {
|
|
203
|
+
const header = response.headers.get('retry-after');
|
|
204
|
+
if (!header)
|
|
205
|
+
return null;
|
|
206
|
+
const seconds = Number(header);
|
|
207
|
+
if (Number.isFinite(seconds) && seconds >= 0)
|
|
208
|
+
return Math.min(seconds * 1000, 60_000);
|
|
209
|
+
const date = Date.parse(header);
|
|
210
|
+
if (Number.isNaN(date))
|
|
211
|
+
return null;
|
|
212
|
+
return Math.max(0, Math.min(date - Date.now(), 60_000));
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,EAAE;AACF,gGAAgG;AAChG,8EAA8E;AAE9E,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,UAAU,GACX,MAAM,aAAa,CAAA;AACpB,OAAO,EAAoB,eAAe,EAAE,MAAM,UAAU,CAAA;AA2C5D,6FAA6F;AAC7F,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAA;AAElC;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAA;AAClC,CAAC;AAED,gDAAgD;AAChD,SAAS,WAAW,CAAC,MAAc,EAAE,MAAqB;IACxD,wFAAwF;IACxF,yFAAyF;IACzF,qFAAqF;IACrF,+DAA+D;IAC/D,MAAM,UAAU,GAAG,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,QAAQ,CAAA;IAC/E,IAAI,CAAC,UAAU;QAAE,OAAO,KAAK,CAAA;IAC7B,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,IAAI,CAAA;IAChC,OAAO,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,CAAA;AAC7E,CAAC;AAED,4FAA4F;AAC5F,SAAS,SAAS,CAAC,OAAe;IAChC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC,CAAA;AACxE,CAAC;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MAAM,CAAC,CAAC,CAAA;AACzD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { CatFactoryClient } from './client.ts';
|
|
2
|
+
export type { ClientOptions, RequestOptions } from './http.ts';
|
|
3
|
+
export { encodePathSegment, SDK_VERSION } from './http.ts';
|
|
4
|
+
export type { EventStream, StreamEvent } from './sse.ts';
|
|
5
|
+
export { type ApiErrorBody, CatFactoryApiError, CatFactoryConflictError, CatFactoryConnectionError, CatFactoryCredentialRequiredError, CatFactoryDecodeError, CatFactoryError, CatFactoryForbiddenError, CatFactoryNotFoundError, CatFactoryPaginationError, CatFactoryRateLimitedError, CatFactoryServerError, CatFactoryTimeoutError, CatFactoryUnauthorizedError, CatFactoryValidationError, } from './errors.ts';
|
|
6
|
+
export * from './models.generated.ts';
|
|
7
|
+
export * from './operations.generated.ts';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC9D,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC1D,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACxD,OAAO,EACL,KAAK,YAAY,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,iCAAiC,EACjC,qBAAqB,EACrB,eAAe,EACf,wBAAwB,EACxB,uBAAuB,EACvB,yBAAyB,EACzB,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,EACtB,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,aAAa,CAAA;AAIpB,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// `@cat-factory/sdk` — the TypeScript client for the cat-factory public API (`/api/v1`).
|
|
2
|
+
//
|
|
3
|
+
// The models and the 38 operation methods are GENERATED from `docs/openapi.json` (itself
|
|
4
|
+
// generated from the Valibot route contracts), so they cannot drift from the deployment they
|
|
5
|
+
// talk to. The transport, errors and SSE framing are hand-written.
|
|
6
|
+
export { CatFactoryClient } from './client.js';
|
|
7
|
+
export { encodePathSegment, SDK_VERSION } from './http.js';
|
|
8
|
+
export { CatFactoryApiError, CatFactoryConflictError, CatFactoryConnectionError, CatFactoryCredentialRequiredError, CatFactoryDecodeError, CatFactoryError, CatFactoryForbiddenError, CatFactoryNotFoundError, CatFactoryPaginationError, CatFactoryRateLimitedError, CatFactoryServerError, CatFactoryTimeoutError, CatFactoryUnauthorizedError, CatFactoryValidationError, } from './errors.js';
|
|
9
|
+
// Every wire model (plus each enum's `*_VALUES` list), the resource classes, and the
|
|
10
|
+
// per-operation query-parameter shapes. `export *` carries types and values alike.
|
|
11
|
+
export * from './models.generated.js';
|
|
12
|
+
export * from './operations.generated.js';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,EAAE;AACF,yFAAyF;AACzF,6FAA6F;AAC7F,mEAAmE;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE1D,OAAO,EAEL,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,iCAAiC,EACjC,qBAAqB,EACrB,eAAe,EACf,wBAAwB,EACxB,uBAAuB,EACvB,yBAAyB,EACzB,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,EACtB,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,aAAa,CAAA;AAEpB,qFAAqF;AACrF,mFAAmF;AACnF,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA"}
|