@syndroo/sdk 0.4.0-rc.1
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 +202 -0
- package/NOTICE +9 -0
- package/README.md +172 -0
- package/dist/client.d.ts +109 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +354 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +104 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +162 -0
- package/dist/errors.js.map +1 -0
- package/dist/http.d.ts +45 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +298 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +91 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +159 -0
- package/dist/types.js.map +1 -0
- package/package.json +43 -0
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single HTTP transport used by the SDK.
|
|
3
|
+
*
|
|
4
|
+
* Invariants this module enforces for every request:
|
|
5
|
+
*
|
|
6
|
+
* - exactly one network request per call; the SDK never retries a write,
|
|
7
|
+
* because a retry without a stable idempotency key can duplicate a post;
|
|
8
|
+
* - redirects are not followed, so the `Authorization` header can never reach
|
|
9
|
+
* a redirect target;
|
|
10
|
+
* - every request is bounded by a finite deadline;
|
|
11
|
+
* - the response body is read with a size limit, so an oversized or hostile
|
|
12
|
+
* response cannot exhaust the caller's memory;
|
|
13
|
+
* - no logging, so credentials and content never reach stdout or stderr.
|
|
14
|
+
*/
|
|
15
|
+
export declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
16
|
+
export declare const DEFAULT_MAX_RESPONSE_BYTES: number;
|
|
17
|
+
export declare const MIN_MAX_RESPONSE_BYTES = 1024;
|
|
18
|
+
export interface TransportConfig {
|
|
19
|
+
baseUrl: string;
|
|
20
|
+
apiKey: string;
|
|
21
|
+
timeoutMs: number;
|
|
22
|
+
maxResponseBytes: number;
|
|
23
|
+
}
|
|
24
|
+
export interface TransportRequest {
|
|
25
|
+
method: "GET" | "POST";
|
|
26
|
+
path: string;
|
|
27
|
+
query?: Record<string, string> | undefined;
|
|
28
|
+
json?: unknown;
|
|
29
|
+
idempotencyKey?: string | undefined;
|
|
30
|
+
/** `false` for unauthenticated endpoints such as `/health`. */
|
|
31
|
+
authenticated?: boolean | undefined;
|
|
32
|
+
signal?: AbortSignal | undefined;
|
|
33
|
+
timeoutMs?: number | undefined;
|
|
34
|
+
}
|
|
35
|
+
export interface TransportResponse {
|
|
36
|
+
status: number;
|
|
37
|
+
body: unknown;
|
|
38
|
+
}
|
|
39
|
+
export declare function sendRequest(config: TransportConfig, request: TransportRequest): Promise<TransportResponse>;
|
|
40
|
+
/**
|
|
41
|
+
* Node keeps the process alive for a pending timer. An SDK call must not pin a
|
|
42
|
+
* CLI process open after its response or its deadline.
|
|
43
|
+
*/
|
|
44
|
+
export declare function unrefTimer(handle: unknown): void;
|
|
45
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAYH,eAAO,MAAM,kBAAkB,QAAS,CAAC;AACzC,eAAO,MAAM,0BAA0B,QAAkB,CAAC;AAC1D,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAI3C,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAC3C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,+DAA+D;IAC/D,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;CACf;AAED,wBAAsB,WAAW,CAC/B,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,iBAAiB,CAAC,CAiH5B;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAOhD"}
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single HTTP transport used by the SDK.
|
|
3
|
+
*
|
|
4
|
+
* Invariants this module enforces for every request:
|
|
5
|
+
*
|
|
6
|
+
* - exactly one network request per call; the SDK never retries a write,
|
|
7
|
+
* because a retry without a stable idempotency key can duplicate a post;
|
|
8
|
+
* - redirects are not followed, so the `Authorization` header can never reach
|
|
9
|
+
* a redirect target;
|
|
10
|
+
* - every request is bounded by a finite deadline;
|
|
11
|
+
* - the response body is read with a size limit, so an oversized or hostile
|
|
12
|
+
* response cannot exhaust the caller's memory;
|
|
13
|
+
* - no logging, so credentials and content never reach stdout or stderr.
|
|
14
|
+
*/
|
|
15
|
+
import { SyndrooAbortError, SyndrooApiError, SyndrooError, SyndrooNetworkError, SyndrooResponseError, SyndrooTimeoutError, truncate, } from "./errors.js";
|
|
16
|
+
export const DEFAULT_TIMEOUT_MS = 30_000;
|
|
17
|
+
export const DEFAULT_MAX_RESPONSE_BYTES = 8 * 1024 * 1024;
|
|
18
|
+
export const MIN_MAX_RESPONSE_BYTES = 1024;
|
|
19
|
+
const PREVIEW_LIMIT = 200;
|
|
20
|
+
const MAX_RETRY_AFTER_MS = 24 * 60 * 60 * 1000;
|
|
21
|
+
export async function sendRequest(config, request) {
|
|
22
|
+
const url = buildUrl(config.baseUrl, request.path, request.query);
|
|
23
|
+
const timeoutMs = request.timeoutMs ?? config.timeoutMs;
|
|
24
|
+
const isWrite = request.method !== "GET";
|
|
25
|
+
const userSignal = request.signal;
|
|
26
|
+
if (userSignal?.aborted === true) {
|
|
27
|
+
throw new SyndrooAbortError("The request was aborted before it was sent, so nothing reached Syndroo.", { cause: userSignal.reason, requestMayHaveBeenApplied: false });
|
|
28
|
+
}
|
|
29
|
+
// Read through a call so TypeScript's narrowing from the check above does not
|
|
30
|
+
// make the later failure classification unreachable.
|
|
31
|
+
const callerAbort = () => ({
|
|
32
|
+
aborted: userSignal?.aborted === true,
|
|
33
|
+
reason: userSignal?.reason,
|
|
34
|
+
});
|
|
35
|
+
const headers = new Headers({ accept: "application/json" });
|
|
36
|
+
if (request.authenticated !== false) {
|
|
37
|
+
headers.set("authorization", `Bearer ${config.apiKey}`);
|
|
38
|
+
}
|
|
39
|
+
if (request.idempotencyKey !== undefined) {
|
|
40
|
+
headers.set("idempotency-key", request.idempotencyKey);
|
|
41
|
+
}
|
|
42
|
+
const init = {
|
|
43
|
+
method: request.method,
|
|
44
|
+
headers,
|
|
45
|
+
redirect: "manual",
|
|
46
|
+
};
|
|
47
|
+
if (request.json !== undefined) {
|
|
48
|
+
headers.set("content-type", "application/json");
|
|
49
|
+
init.body = JSON.stringify(request.json);
|
|
50
|
+
}
|
|
51
|
+
const controller = new AbortController();
|
|
52
|
+
let timedOut = false;
|
|
53
|
+
const handle = setTimeout(() => {
|
|
54
|
+
timedOut = true;
|
|
55
|
+
controller.abort();
|
|
56
|
+
}, timeoutMs);
|
|
57
|
+
unrefTimer(handle);
|
|
58
|
+
init.signal = controller.signal;
|
|
59
|
+
const forwardAbort = () => {
|
|
60
|
+
controller.abort();
|
|
61
|
+
};
|
|
62
|
+
userSignal?.addEventListener("abort", forwardAbort, { once: true });
|
|
63
|
+
try {
|
|
64
|
+
const response = await globalThis.fetch(url, init);
|
|
65
|
+
if (isRedirectResponse(response)) {
|
|
66
|
+
throw new SyndrooApiError("Syndroo answered with a redirect. The SDK does not follow redirects " +
|
|
67
|
+
"because the Authorization header must never be forwarded to another " +
|
|
68
|
+
"location; point baseUrl at the final API origin instead.", {
|
|
69
|
+
code: "REDIRECT_NOT_FOLLOWED",
|
|
70
|
+
status: response.status,
|
|
71
|
+
requestMayHaveBeenApplied: false,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const text = await readBody(response, config.maxResponseBytes, isWrite);
|
|
75
|
+
const preview = truncate(text, PREVIEW_LIMIT);
|
|
76
|
+
if (!response.ok) {
|
|
77
|
+
throw apiError(response, text, preview, isWrite);
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
status: response.status,
|
|
81
|
+
body: parseJson(text, response.status, preview, isWrite),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
if (error instanceof SyndrooError) {
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
if (timedOut) {
|
|
89
|
+
throw new SyndrooTimeoutError(timeoutMessage(isWrite, timeoutMs), {
|
|
90
|
+
timeoutMs,
|
|
91
|
+
cause: error,
|
|
92
|
+
requestMayHaveBeenApplied: isWrite,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const caller = callerAbort();
|
|
96
|
+
if (caller.aborted) {
|
|
97
|
+
throw new SyndrooAbortError(abortMessage(isWrite), {
|
|
98
|
+
cause: caller.reason ?? error,
|
|
99
|
+
requestMayHaveBeenApplied: isWrite,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
throw new SyndrooNetworkError(networkMessage(isWrite, error), {
|
|
103
|
+
cause: error,
|
|
104
|
+
networkCode: networkCodeOf(error),
|
|
105
|
+
requestMayHaveBeenApplied: isWrite,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
clearTimeout(handle);
|
|
110
|
+
userSignal?.removeEventListener("abort", forwardAbort);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Node keeps the process alive for a pending timer. An SDK call must not pin a
|
|
115
|
+
* CLI process open after its response or its deadline.
|
|
116
|
+
*/
|
|
117
|
+
export function unrefTimer(handle) {
|
|
118
|
+
const candidate = handle;
|
|
119
|
+
const unref = candidate.unref;
|
|
120
|
+
if (typeof unref === "function") {
|
|
121
|
+
unref.call(handle);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function buildUrl(baseUrl, path, query) {
|
|
125
|
+
const url = new URL(`${baseUrl}${path}`);
|
|
126
|
+
for (const [key, value] of Object.entries(query ?? {})) {
|
|
127
|
+
url.searchParams.set(key, value);
|
|
128
|
+
}
|
|
129
|
+
return url;
|
|
130
|
+
}
|
|
131
|
+
function isRedirectResponse(response) {
|
|
132
|
+
if (response.type === "opaqueredirect") {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
return response.status >= 300 && response.status < 400;
|
|
136
|
+
}
|
|
137
|
+
async function readBody(response, maxBytes, isWrite) {
|
|
138
|
+
const body = response.body;
|
|
139
|
+
if (body === null) {
|
|
140
|
+
return "";
|
|
141
|
+
}
|
|
142
|
+
const reader = body.getReader();
|
|
143
|
+
const chunks = [];
|
|
144
|
+
let length = 0;
|
|
145
|
+
try {
|
|
146
|
+
for (;;) {
|
|
147
|
+
const { done, value } = await reader.read();
|
|
148
|
+
if (done) {
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
length += value.byteLength;
|
|
152
|
+
if (length > maxBytes) {
|
|
153
|
+
await reader.cancel("Response exceeded the SDK response size limit").catch(() => undefined);
|
|
154
|
+
throw new SyndrooResponseError(`Syndroo returned a response larger than the configured limit of ${maxBytes} bytes. ` +
|
|
155
|
+
"Raise maxResponseBytes only for a trusted deployment.", {
|
|
156
|
+
status: response.status,
|
|
157
|
+
requestMayHaveBeenApplied: mayHaveBeenApplied(response.status, isWrite),
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
chunks.push(value);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
finally {
|
|
164
|
+
reader.releaseLock();
|
|
165
|
+
}
|
|
166
|
+
const bytes = new Uint8Array(length);
|
|
167
|
+
let offset = 0;
|
|
168
|
+
for (const chunk of chunks) {
|
|
169
|
+
bytes.set(chunk, offset);
|
|
170
|
+
offset += chunk.byteLength;
|
|
171
|
+
}
|
|
172
|
+
return new TextDecoder().decode(bytes);
|
|
173
|
+
}
|
|
174
|
+
function parseJson(text, status, preview, isWrite) {
|
|
175
|
+
if (text === "") {
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
return JSON.parse(text);
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
throw new SyndrooResponseError(`Syndroo returned HTTP ${status} with a body that is not JSON: ${preview}`, {
|
|
183
|
+
status,
|
|
184
|
+
preview,
|
|
185
|
+
requestMayHaveBeenApplied: mayHaveBeenApplied(status, isWrite),
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function apiError(response, text, preview, isWrite) {
|
|
190
|
+
const envelope = errorEnvelope(text);
|
|
191
|
+
return new SyndrooApiError(envelope?.message ??
|
|
192
|
+
`Syndroo returned HTTP ${response.status} without a documented error body: ${preview}`, {
|
|
193
|
+
code: envelope?.code ?? `HTTP_${response.status}`,
|
|
194
|
+
status: response.status,
|
|
195
|
+
requestMayHaveBeenApplied: mayHaveBeenApplied(response.status, isWrite),
|
|
196
|
+
retryAfterMs: retryAfterMs(response.headers.get("retry-after")),
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
function errorEnvelope(text) {
|
|
200
|
+
if (text === "") {
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
203
|
+
let parsed;
|
|
204
|
+
try {
|
|
205
|
+
parsed = JSON.parse(text);
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
const error = parsed.error;
|
|
214
|
+
if (typeof error !== "object" || error === null) {
|
|
215
|
+
return undefined;
|
|
216
|
+
}
|
|
217
|
+
const record = error;
|
|
218
|
+
const code = typeof record.code === "string" ? record.code : undefined;
|
|
219
|
+
const message = typeof record.message === "string" ? record.message : undefined;
|
|
220
|
+
if (code === undefined || message === undefined) {
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
return { code, message: truncate(message, PREVIEW_LIMIT) };
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* `Retry-After` is either a number of seconds or an HTTP date. Both are
|
|
227
|
+
* converted to a bounded delay so a caller can honor backpressure without
|
|
228
|
+
* trusting an attacker-controlled header to park the process for days.
|
|
229
|
+
*/
|
|
230
|
+
function retryAfterMs(header) {
|
|
231
|
+
if (header === null) {
|
|
232
|
+
return undefined;
|
|
233
|
+
}
|
|
234
|
+
const trimmed = header.trim();
|
|
235
|
+
const seconds = Number(trimmed);
|
|
236
|
+
if (trimmed !== "" && Number.isFinite(seconds) && seconds >= 0) {
|
|
237
|
+
return Math.min(seconds * 1000, MAX_RETRY_AFTER_MS);
|
|
238
|
+
}
|
|
239
|
+
const date = Date.parse(trimmed);
|
|
240
|
+
if (Number.isNaN(date)) {
|
|
241
|
+
return undefined;
|
|
242
|
+
}
|
|
243
|
+
return Math.min(Math.max(date - Date.now(), 0), MAX_RETRY_AFTER_MS);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* A write may have been applied when Syndroo accepted it (2xx) or when the
|
|
247
|
+
* failure happened at or after the server's processing boundary (5xx). A 4xx
|
|
248
|
+
* is a decision, so nothing was applied.
|
|
249
|
+
*/
|
|
250
|
+
function mayHaveBeenApplied(status, isWrite) {
|
|
251
|
+
if (!isWrite) {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
return status >= 500 || (status >= 200 && status < 300);
|
|
255
|
+
}
|
|
256
|
+
function timeoutMessage(isWrite, timeoutMs) {
|
|
257
|
+
if (!isWrite) {
|
|
258
|
+
return (`Request timed out after ${timeoutMs}ms. This was a read, so nothing was ` +
|
|
259
|
+
"created; retrying is safe.");
|
|
260
|
+
}
|
|
261
|
+
return (`Request timed out after ${timeoutMs}ms. Syndroo may still have accepted the ` +
|
|
262
|
+
"post: do not resend it with a new Idempotency-Key. Look the post up with " +
|
|
263
|
+
"posts.list, or retry the identical request with the same key.");
|
|
264
|
+
}
|
|
265
|
+
function abortMessage(isWrite) {
|
|
266
|
+
if (!isWrite) {
|
|
267
|
+
return "The request was aborted after it was sent. This was a read, so nothing was created.";
|
|
268
|
+
}
|
|
269
|
+
return ("The request was aborted after it was sent, so Syndroo may still have " +
|
|
270
|
+
"accepted the post: do not resend it with a new Idempotency-Key. Look the " +
|
|
271
|
+
"post up with posts.list, or retry the identical request with the same key.");
|
|
272
|
+
}
|
|
273
|
+
function networkMessage(isWrite, error) {
|
|
274
|
+
const code = networkCodeOf(error);
|
|
275
|
+
const suffix = code === undefined ? "" : ` (${code})`;
|
|
276
|
+
if (!isWrite) {
|
|
277
|
+
return `The request failed before a response was received${suffix}.`;
|
|
278
|
+
}
|
|
279
|
+
return (`The request failed before a response was received${suffix}. Syndroo may ` +
|
|
280
|
+
"still have accepted the post: do not resend it with a new " +
|
|
281
|
+
"Idempotency-Key. Look the post up with posts.list, or retry the identical " +
|
|
282
|
+
"request with the same key.");
|
|
283
|
+
}
|
|
284
|
+
function networkCodeOf(error) {
|
|
285
|
+
let current = error;
|
|
286
|
+
for (let depth = 0; depth < 4; depth += 1) {
|
|
287
|
+
if (typeof current !== "object" || current === null) {
|
|
288
|
+
return undefined;
|
|
289
|
+
}
|
|
290
|
+
const code = current.code;
|
|
291
|
+
if (typeof code === "string" && code !== "") {
|
|
292
|
+
return truncate(code, 40);
|
|
293
|
+
}
|
|
294
|
+
current = current.cause;
|
|
295
|
+
}
|
|
296
|
+
return undefined;
|
|
297
|
+
}
|
|
298
|
+
//# 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;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,QAAQ,GACT,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AACzC,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAC1D,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAC3C,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AA0B/C,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAuB,EACvB,OAAyB;IAEzB,MAAM,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAClE,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC;IACxD,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,KAAK,KAAK,CAAC;IACzC,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAElC,IAAI,UAAU,EAAE,OAAO,KAAK,IAAI,EAAE,CAAC;QACjC,MAAM,IA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package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entry point of `@syndroo/sdk`.
|
|
3
|
+
*
|
|
4
|
+
* The SDK is a thin HTTP client for a deployed Syndroo instance. It keeps the
|
|
5
|
+
* documented `/v1` contract and adds no server-side behavior.
|
|
6
|
+
*/
|
|
7
|
+
export { DEFAULT_MAX_POLL_INTERVAL_MS, DEFAULT_POLL_INTERVAL_MS, DEFAULT_WAIT_TIMEOUT_MS, PostsResource, SyndrooClient, type CreatePostOptions, type ListPostsOptions, type RequestOptions, type SyndrooClientOptions, type WaitOptions, } from "./client.js";
|
|
8
|
+
export { SyndrooAbortError, SyndrooApiError, SyndrooConfigError, SyndrooError, SyndrooNetworkError, SyndrooResponseError, SyndrooTimeoutError, SyndrooValidationError, SyndrooWaitTimeoutError, isSyndrooError, type SyndrooErrorCode, type SyndrooErrorInit, } from "./errors.js";
|
|
9
|
+
export { isPostDelivered, isPostTerminal, type CreatePostInput, type HealthStatus, type KnownPlatform, type Platform, type PostDetail, type PostOverride, type PostReceipt, type PostStatus, type PostSummary, type Publication, type PublicationStatus, type PublishErrorCode, type SupportsFutureValues, } from "./types.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,uBAAuB,EACvB,aAAa,EACb,aAAa,EACb,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,WAAW,GACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACd,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,eAAe,EACf,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,GAC1B,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entry point of `@syndroo/sdk`.
|
|
3
|
+
*
|
|
4
|
+
* The SDK is a thin HTTP client for a deployed Syndroo instance. It keeps the
|
|
5
|
+
* documented `/v1` contract and adds no server-side behavior.
|
|
6
|
+
*/
|
|
7
|
+
export { DEFAULT_MAX_POLL_INTERVAL_MS, DEFAULT_POLL_INTERVAL_MS, DEFAULT_WAIT_TIMEOUT_MS, PostsResource, SyndrooClient, } from "./client.js";
|
|
8
|
+
export { SyndrooAbortError, SyndrooApiError, SyndrooConfigError, SyndrooError, SyndrooNetworkError, SyndrooResponseError, SyndrooTimeoutError, SyndrooValidationError, SyndrooWaitTimeoutError, isSyndrooError, } from "./errors.js";
|
|
9
|
+
export { isPostDelivered, isPostTerminal, } from "./types.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,uBAAuB,EACvB,aAAa,EACb,aAAa,GAMd,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,GAGf,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,eAAe,EACf,cAAc,GAcf,MAAM,YAAY,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire types and narrow runtime readers for the documented Syndroo HTTP
|
|
3
|
+
* contract (see the "HTTP API" section of the repository README).
|
|
4
|
+
*
|
|
5
|
+
* These declarations are intentionally independent of the private
|
|
6
|
+
* `@syndroo/core` workspace package: the published SDK must keep zero runtime
|
|
7
|
+
* dependencies, and the server contract — not the internal domain model — is
|
|
8
|
+
* what users depend on.
|
|
9
|
+
*/
|
|
10
|
+
/** Platforms the docs describe today. The SDK accepts any string the server accepts. */
|
|
11
|
+
export type KnownPlatform = "x" | "threads" | "bluesky" | "tumblr" | "mastodon" | "linkedin" | "nostr";
|
|
12
|
+
/**
|
|
13
|
+
* Literal-union helper: editors still complete the documented names, while a
|
|
14
|
+
* value the server adds later does not become a type error for consumers.
|
|
15
|
+
*/
|
|
16
|
+
export type SupportsFutureValues<T extends string> = T | (string & {});
|
|
17
|
+
export type Platform = SupportsFutureValues<KnownPlatform>;
|
|
18
|
+
export type PostStatus = "scheduled" | "queued" | "publishing" | "published" | "partial" | "failed";
|
|
19
|
+
export type PublicationStatus = "scheduled" | "pending" | "publishing" | "published" | "failed";
|
|
20
|
+
export type PublishErrorCode = "AUTH" | "RATE_LIMIT" | "INVALID_CONTENT" | "PROVIDER_UNAVAILABLE" | "NETWORK" | "UNKNOWN";
|
|
21
|
+
export interface PostOverride {
|
|
22
|
+
content?: string;
|
|
23
|
+
}
|
|
24
|
+
/** The request body of `POST /v1/posts`, passed through unchanged. */
|
|
25
|
+
export interface CreatePostInput {
|
|
26
|
+
content: string;
|
|
27
|
+
platforms: Platform[];
|
|
28
|
+
overrides?: Record<string, PostOverride>;
|
|
29
|
+
scheduledAt?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The acceptance receipt for `POST /v1/posts`. HTTP `202` means the request was
|
|
33
|
+
* accepted for processing; it is not a delivery result. Read the post (and each
|
|
34
|
+
* publication) before claiming that anything reached a platform.
|
|
35
|
+
*/
|
|
36
|
+
export interface PostReceipt {
|
|
37
|
+
id: string;
|
|
38
|
+
status: SupportsFutureValues<PostStatus>;
|
|
39
|
+
scheduledAt?: string;
|
|
40
|
+
enqueueDeferred?: boolean;
|
|
41
|
+
replayed?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface PostSummary {
|
|
44
|
+
id: string;
|
|
45
|
+
content: string;
|
|
46
|
+
platforms: Platform[];
|
|
47
|
+
status: SupportsFutureValues<PostStatus>;
|
|
48
|
+
createdAt: string;
|
|
49
|
+
scheduledAt?: string;
|
|
50
|
+
overrides?: Record<string, PostOverride>;
|
|
51
|
+
}
|
|
52
|
+
export interface Publication {
|
|
53
|
+
id: string;
|
|
54
|
+
postId: string;
|
|
55
|
+
platform: Platform;
|
|
56
|
+
provider: string;
|
|
57
|
+
content: string;
|
|
58
|
+
status: SupportsFutureValues<PublicationStatus>;
|
|
59
|
+
attempts: number;
|
|
60
|
+
errorAmbiguous?: boolean;
|
|
61
|
+
externalId?: string;
|
|
62
|
+
externalUrl?: string;
|
|
63
|
+
errorCode?: SupportsFutureValues<PublishErrorCode>;
|
|
64
|
+
errorMessage?: string;
|
|
65
|
+
createdAt?: string;
|
|
66
|
+
scheduledAt?: string;
|
|
67
|
+
enqueuedAt?: string;
|
|
68
|
+
publishingAt?: string;
|
|
69
|
+
publishedAt?: string;
|
|
70
|
+
}
|
|
71
|
+
export interface PostDetail extends PostSummary {
|
|
72
|
+
publications: Publication[];
|
|
73
|
+
}
|
|
74
|
+
export interface HealthStatus {
|
|
75
|
+
status: string;
|
|
76
|
+
}
|
|
77
|
+
/** Context attached to a parse failure so callers know what Syndroo answered. */
|
|
78
|
+
export interface ParseContext {
|
|
79
|
+
status?: number | undefined;
|
|
80
|
+
requestMayHaveBeenApplied?: boolean | undefined;
|
|
81
|
+
}
|
|
82
|
+
/** `published`, `partial`, and `failed` stop changing without a new request. */
|
|
83
|
+
export declare function isPostTerminal(status: string): boolean;
|
|
84
|
+
/** Every selected platform succeeded. Anything else is not a delivery. */
|
|
85
|
+
export declare function isPostDelivered(status: string): boolean;
|
|
86
|
+
export declare function parsePostReceipt(value: unknown, context?: ParseContext): PostReceipt;
|
|
87
|
+
export declare function parsePostSummary(value: unknown, context?: ParseContext, label?: string): PostSummary;
|
|
88
|
+
export declare function parsePostDetail(value: unknown, context?: ParseContext): PostDetail;
|
|
89
|
+
export declare function parsePostList(value: unknown, context?: ParseContext): PostSummary[];
|
|
90
|
+
export declare function parseHealth(value: unknown, context?: ParseContext): HealthStatus;
|
|
91
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,wFAAwF;AACxF,MAAM,MAAM,aAAa,GACrB,GAAG,GACH,SAAS,GACT,SAAS,GACT,QAAQ,GACR,UAAU,GACV,UAAU,GACV,OAAO,CAAC;AAEZ;;;GAGG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAEvE,MAAM,MAAM,QAAQ,GAAG,oBAAoB,CAAC,aAAa,CAAC,CAAC;AAE3D,MAAM,MAAM,UAAU,GAClB,WAAW,GACX,QAAQ,GACR,YAAY,GACZ,WAAW,GACX,SAAS,GACT,QAAQ,CAAC;AAEb,MAAM,MAAM,iBAAiB,GACzB,WAAW,GACX,SAAS,GACT,YAAY,GACZ,WAAW,GACX,QAAQ,CAAC;AAEb,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,YAAY,GACZ,iBAAiB,GACjB,sBAAsB,GACtB,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
|
|
2
|
+
* Wire types and narrow runtime readers for the documented Syndroo HTTP
|
|
3
|
+
* contract (see the "HTTP API" section of the repository README).
|
|
4
|
+
*
|
|
5
|
+
* These declarations are intentionally independent of the private
|
|
6
|
+
* `@syndroo/core` workspace package: the published SDK must keep zero runtime
|
|
7
|
+
* dependencies, and the server contract — not the internal domain model — is
|
|
8
|
+
* what users depend on.
|
|
9
|
+
*/
|
|
10
|
+
import { SyndrooResponseError, truncate } from "./errors.js";
|
|
11
|
+
const TERMINAL_POST_STATUSES = new Set([
|
|
12
|
+
"published",
|
|
13
|
+
"partial",
|
|
14
|
+
"failed",
|
|
15
|
+
]);
|
|
16
|
+
/** `published`, `partial`, and `failed` stop changing without a new request. */
|
|
17
|
+
export function isPostTerminal(status) {
|
|
18
|
+
return TERMINAL_POST_STATUSES.has(status);
|
|
19
|
+
}
|
|
20
|
+
/** Every selected platform succeeded. Anything else is not a delivery. */
|
|
21
|
+
export function isPostDelivered(status) {
|
|
22
|
+
return status === "published";
|
|
23
|
+
}
|
|
24
|
+
export function parsePostReceipt(value, context = {}) {
|
|
25
|
+
const record = requireRecord(value, "the create response");
|
|
26
|
+
const receipt = {
|
|
27
|
+
id: requireString(record["id"], "create response id", context),
|
|
28
|
+
status: requireString(record["status"], "create response status", context),
|
|
29
|
+
};
|
|
30
|
+
assignOptional(receipt, "scheduledAt", optionalString(record["scheduledAt"], "create response scheduledAt", context));
|
|
31
|
+
assignOptional(receipt, "enqueueDeferred", optionalBoolean(record["enqueueDeferred"], "create response enqueueDeferred", context));
|
|
32
|
+
assignOptional(receipt, "replayed", optionalBoolean(record["replayed"], "create response replayed", context));
|
|
33
|
+
return receipt;
|
|
34
|
+
}
|
|
35
|
+
export function parsePostSummary(value, context = {}, label = "post") {
|
|
36
|
+
const record = requireRecord(value, label, context);
|
|
37
|
+
const summary = {
|
|
38
|
+
id: requireString(record["id"], `${label} id`, context),
|
|
39
|
+
content: requireString(record["content"], `${label} content`, context),
|
|
40
|
+
platforms: requireArray(record["platforms"], `${label} platforms`, context).map((platform, index) => requireString(platform, `${label} platforms[${index}]`, context)),
|
|
41
|
+
status: requireString(record["status"], `${label} status`, context),
|
|
42
|
+
createdAt: requireString(record["createdAt"], `${label} createdAt`, context),
|
|
43
|
+
};
|
|
44
|
+
assignOptional(summary, "scheduledAt", optionalString(record["scheduledAt"], `${label} scheduledAt`, context));
|
|
45
|
+
assignOptional(summary, "overrides", optionalOverrides(record["overrides"], `${label} overrides`, context));
|
|
46
|
+
return summary;
|
|
47
|
+
}
|
|
48
|
+
export function parsePostDetail(value, context = {}) {
|
|
49
|
+
const record = requireRecord(value, "post", context);
|
|
50
|
+
const publications = requireArray(record["publications"], "post publications", context).map((item, index) => parsePublication(item, `post publications[${index}]`, context));
|
|
51
|
+
return { ...parsePostSummary(record, context), publications };
|
|
52
|
+
}
|
|
53
|
+
export function parsePostList(value, context = {}) {
|
|
54
|
+
const record = requireRecord(value, "the list response", context);
|
|
55
|
+
return requireArray(record["items"], "list response items", context).map((item, index) => parsePostSummary(item, context, `list response items[${index}]`));
|
|
56
|
+
}
|
|
57
|
+
export function parseHealth(value, context = {}) {
|
|
58
|
+
const record = requireRecord(value, "the health response", context);
|
|
59
|
+
return { status: requireString(record["status"], "health response status", context) };
|
|
60
|
+
}
|
|
61
|
+
function parsePublication(value, label, context) {
|
|
62
|
+
const record = requireRecord(value, label, context);
|
|
63
|
+
const publication = {
|
|
64
|
+
id: requireString(record["id"], `${label} id`, context),
|
|
65
|
+
postId: requireString(record["postId"], `${label} postId`, context),
|
|
66
|
+
platform: requireString(record["platform"], `${label} platform`, context),
|
|
67
|
+
provider: requireString(record["provider"], `${label} provider`, context),
|
|
68
|
+
content: requireString(record["content"], `${label} content`, context),
|
|
69
|
+
status: requireString(record["status"], `${label} status`, context),
|
|
70
|
+
attempts: requireNumber(record["attempts"], `${label} attempts`, context),
|
|
71
|
+
};
|
|
72
|
+
assignOptional(publication, "errorAmbiguous", optionalBoolean(record["errorAmbiguous"], `${label} errorAmbiguous`, context));
|
|
73
|
+
assignOptional(publication, "externalId", optionalString(record["externalId"], `${label} externalId`, context));
|
|
74
|
+
assignOptional(publication, "externalUrl", optionalString(record["externalUrl"], `${label} externalUrl`, context));
|
|
75
|
+
assignOptional(publication, "errorCode", optionalString(record["errorCode"], `${label} errorCode`, context));
|
|
76
|
+
assignOptional(publication, "errorMessage", optionalString(record["errorMessage"], `${label} errorMessage`, context));
|
|
77
|
+
assignOptional(publication, "createdAt", optionalString(record["createdAt"], `${label} createdAt`, context));
|
|
78
|
+
assignOptional(publication, "scheduledAt", optionalString(record["scheduledAt"], `${label} scheduledAt`, context));
|
|
79
|
+
assignOptional(publication, "enqueuedAt", optionalString(record["enqueuedAt"], `${label} enqueuedAt`, context));
|
|
80
|
+
assignOptional(publication, "publishingAt", optionalString(record["publishingAt"], `${label} publishingAt`, context));
|
|
81
|
+
assignOptional(publication, "publishedAt", optionalString(record["publishedAt"], `${label} publishedAt`, context));
|
|
82
|
+
return publication;
|
|
83
|
+
}
|
|
84
|
+
function optionalOverrides(value, label, context) {
|
|
85
|
+
if (value === undefined || value === null) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
const record = requireRecord(value, label, context);
|
|
89
|
+
const overrides = {};
|
|
90
|
+
for (const [platform, override] of Object.entries(record)) {
|
|
91
|
+
const entry = requireRecord(override, `${label}.${platform}`, context);
|
|
92
|
+
const content = optionalString(entry["content"], `${label}.${platform}.content`, context);
|
|
93
|
+
overrides[platform] = content === undefined ? {} : { content };
|
|
94
|
+
}
|
|
95
|
+
return overrides;
|
|
96
|
+
}
|
|
97
|
+
function assignOptional(target, key, value) {
|
|
98
|
+
if (value !== undefined) {
|
|
99
|
+
target[key] = value;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function requireRecord(value, label, context = {}) {
|
|
103
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
104
|
+
throw invalid(`${label} must be a JSON object, received ${describe(value)}`, context);
|
|
105
|
+
}
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
108
|
+
function requireArray(value, label, context = {}) {
|
|
109
|
+
if (!Array.isArray(value)) {
|
|
110
|
+
throw invalid(`${label} must be an array, received ${describe(value)}`, context);
|
|
111
|
+
}
|
|
112
|
+
return value;
|
|
113
|
+
}
|
|
114
|
+
function requireString(value, label, context = {}) {
|
|
115
|
+
if (typeof value !== "string") {
|
|
116
|
+
throw invalid(`${label} must be a string, received ${describe(value)}`, context);
|
|
117
|
+
}
|
|
118
|
+
return value;
|
|
119
|
+
}
|
|
120
|
+
function requireNumber(value, label, context = {}) {
|
|
121
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
122
|
+
throw invalid(`${label} must be a number, received ${describe(value)}`, context);
|
|
123
|
+
}
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
126
|
+
function optionalString(value, label, context = {}) {
|
|
127
|
+
if (value === undefined || value === null) {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
return requireString(value, label, context);
|
|
131
|
+
}
|
|
132
|
+
function optionalBoolean(value, label, context = {}) {
|
|
133
|
+
if (value === undefined || value === null) {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
if (typeof value !== "boolean") {
|
|
137
|
+
throw invalid(`${label} must be a boolean, received ${describe(value)}`, context);
|
|
138
|
+
}
|
|
139
|
+
return value;
|
|
140
|
+
}
|
|
141
|
+
function invalid(message, context) {
|
|
142
|
+
return new SyndrooResponseError(`Syndroo returned a response that does not match the documented contract: ${message}.`, {
|
|
143
|
+
status: context.status,
|
|
144
|
+
requestMayHaveBeenApplied: context.requestMayHaveBeenApplied,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function describe(value) {
|
|
148
|
+
if (value === null) {
|
|
149
|
+
return "null";
|
|
150
|
+
}
|
|
151
|
+
if (Array.isArray(value)) {
|
|
152
|
+
return `an array of ${value.length} item(s)`;
|
|
153
|
+
}
|
|
154
|
+
if (typeof value === "object") {
|
|
155
|
+
return `an object with keys ${truncate(Object.keys(value).join(", "), 80)}`;
|
|
156
|
+
}
|
|
157
|
+
return `${typeof value} (${truncate(String(value), 80)})`;
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=types.js.map
|