@sapiom/tools 0.6.2 → 0.8.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +17 -11
  3. package/dist/cjs/_client/index.d.ts +22 -2
  4. package/dist/cjs/_client/index.d.ts.map +1 -1
  5. package/dist/cjs/_client/index.js +16 -6
  6. package/dist/cjs/_client/index.js.map +1 -1
  7. package/dist/cjs/client.d.ts +46 -1
  8. package/dist/cjs/client.d.ts.map +1 -1
  9. package/dist/cjs/client.js +20 -0
  10. package/dist/cjs/client.js.map +1 -1
  11. package/dist/cjs/content-generation/index.d.ts +118 -3
  12. package/dist/cjs/content-generation/index.d.ts.map +1 -1
  13. package/dist/cjs/content-generation/index.js +200 -4
  14. package/dist/cjs/content-generation/index.js.map +1 -1
  15. package/dist/cjs/database/errors.d.ts +16 -0
  16. package/dist/cjs/database/errors.d.ts.map +1 -0
  17. package/dist/cjs/database/errors.js +36 -0
  18. package/dist/cjs/database/errors.js.map +1 -0
  19. package/dist/cjs/database/index.d.ts +101 -0
  20. package/dist/cjs/database/index.d.ts.map +1 -0
  21. package/dist/cjs/database/index.js +118 -0
  22. package/dist/cjs/database/index.js.map +1 -0
  23. package/dist/cjs/index.d.ts +8 -1
  24. package/dist/cjs/index.d.ts.map +1 -1
  25. package/dist/cjs/index.js +13 -1
  26. package/dist/cjs/index.js.map +1 -1
  27. package/dist/cjs/search/errors.d.ts +16 -0
  28. package/dist/cjs/search/errors.d.ts.map +1 -0
  29. package/dist/cjs/search/errors.js +36 -0
  30. package/dist/cjs/search/errors.js.map +1 -0
  31. package/dist/cjs/search/index.d.ts +234 -0
  32. package/dist/cjs/search/index.d.ts.map +1 -0
  33. package/dist/cjs/search/index.js +286 -0
  34. package/dist/cjs/search/index.js.map +1 -0
  35. package/dist/cjs/stub/index.d.ts.map +1 -1
  36. package/dist/cjs/stub/index.js +150 -2
  37. package/dist/cjs/stub/index.js.map +1 -1
  38. package/dist/esm/_client/index.d.ts +22 -2
  39. package/dist/esm/_client/index.d.ts.map +1 -1
  40. package/dist/esm/_client/index.js +16 -6
  41. package/dist/esm/_client/index.js.map +1 -1
  42. package/dist/esm/client.d.ts +46 -1
  43. package/dist/esm/client.d.ts.map +1 -1
  44. package/dist/esm/client.js +20 -0
  45. package/dist/esm/client.js.map +1 -1
  46. package/dist/esm/content-generation/index.d.ts +118 -3
  47. package/dist/esm/content-generation/index.d.ts.map +1 -1
  48. package/dist/esm/content-generation/index.js +196 -3
  49. package/dist/esm/content-generation/index.js.map +1 -1
  50. package/dist/esm/database/errors.d.ts +16 -0
  51. package/dist/esm/database/errors.d.ts.map +1 -0
  52. package/dist/esm/database/errors.js +31 -0
  53. package/dist/esm/database/errors.js.map +1 -0
  54. package/dist/esm/database/index.d.ts +101 -0
  55. package/dist/esm/database/index.d.ts.map +1 -0
  56. package/dist/esm/database/index.js +113 -0
  57. package/dist/esm/database/index.js.map +1 -0
  58. package/dist/esm/index.d.ts +8 -1
  59. package/dist/esm/index.d.ts.map +1 -1
  60. package/dist/esm/index.js +9 -1
  61. package/dist/esm/index.js.map +1 -1
  62. package/dist/esm/search/errors.d.ts +16 -0
  63. package/dist/esm/search/errors.d.ts.map +1 -0
  64. package/dist/esm/search/errors.js +31 -0
  65. package/dist/esm/search/errors.js.map +1 -0
  66. package/dist/esm/search/index.d.ts +234 -0
  67. package/dist/esm/search/index.d.ts.map +1 -0
  68. package/dist/esm/search/index.js +278 -0
  69. package/dist/esm/search/index.js.map +1 -0
  70. package/dist/esm/stub/index.d.ts.map +1 -1
  71. package/dist/esm/stub/index.js +150 -2
  72. package/dist/esm/stub/index.js.map +1 -1
  73. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  74. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  75. package/package.json +11 -1
  76. package/src/content-generation/README.md +90 -2
  77. package/src/database/README.md +62 -0
  78. package/src/search/README.md +255 -0
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.images = exports.ContentGenerationHttpError = void 0;
3
+ exports.video = exports.images = exports.VIDEO_RESULT_SIGNAL = exports.ContentGenerationHttpError = void 0;
4
4
  exports.createImage = createImage;
5
+ exports.createVideo = createVideo;
6
+ exports.toVideoResumePayload = toVideoResumePayload;
7
+ exports.launchVideo = launchVideo;
5
8
  /**
6
- * `contentGeneration` capability — generate media (images today; video and audio
9
+ * `contentGeneration` capability — generate media (images and video today; audio
7
10
  * to come), with an optional `storage` param that persists each output to Sapiom
8
11
  * file storage so you get a durable `fileId` back inline.
9
12
  *
@@ -16,11 +19,24 @@ exports.createImage = createImage;
16
19
  * out.images[0].fileId; // present when `storage` was passed → use with fileStorage
17
20
  *
18
21
  * Or via an explicit client: `createClient({ apiKey }).contentGeneration.images.create(...)`.
22
+ *
23
+ * `video.launch` is the dispatchable surface: it submits the job and returns a
24
+ * handle immediately. Pass the handle to `pauseUntilSignal(handle, { resumeStep })`
25
+ * to suspend the workflow step until the video is ready, or call `handle.wait()`
26
+ * inline to block until done — same as `video.create` but with the ability to
27
+ * pause a running workflow.
19
28
  */
20
29
  const index_js_1 = require("../_client/index.js");
21
30
  const errors_js_1 = require("./errors.js");
22
31
  Object.defineProperty(exports, "ContentGenerationHttpError", { enumerable: true, get: function () { return errors_js_1.ContentGenerationHttpError; } });
23
32
  const DEFAULT_BASE_URL = process.env.SAPIOM_CONTENT_GENERATION_URL || "https://fal.services.sapiom.ai";
33
+ /**
34
+ * Capability-stable signal a video launch fires when the video reaches a terminal
35
+ * state (ready OR failed — it carries the result either way, the resumed step
36
+ * branches). A workflow step paused on a launch handle resumes on this; it is the
37
+ * value carried in the handle's `dispatch.resultSignal`.
38
+ */
39
+ exports.VIDEO_RESULT_SIGNAL = "contentGeneration.video.result";
24
40
  /** Default image model when the caller doesn't pick one — a fast, low-cost model. */
25
41
  const DEFAULT_IMAGE_MODEL = "fal-ai/flux/schnell";
26
42
  function mapImage(raw) {
@@ -44,12 +60,34 @@ function mapResult(raw) {
44
60
  function modelToPath(model) {
45
61
  return model.split("/").filter(Boolean).map(encodeURIComponent).join("/");
46
62
  }
63
+ /**
64
+ * Guard a prompt value: throw a clear error before a paid job is submitted when
65
+ * the prompt is absent, empty, or not a string. A JS caller passing `null`,
66
+ * `undefined`, or `""` gets an immediate, actionable error instead of a silent
67
+ * paid request with a blank prompt.
68
+ */
69
+ function assertPrompt(prompt) {
70
+ if (typeof prompt !== "string" || prompt.trim() === "") {
71
+ throw new errors_js_1.ContentGenerationHttpError("prompt is required and must be a non-empty string", 400, { error: "invalid_prompt" });
72
+ }
73
+ }
74
+ /**
75
+ * When launched from inside a Sapiom workflow step, the engine injects an opaque
76
+ * per-execution resume token into the transport. Forwarding it as a header — NOT
77
+ * a body field, so author-supplied request fields can't clobber it — lets the
78
+ * service call back into the engine to resume the paused workflow when the job
79
+ * finishes. Absent outside a workflow → no header, no behavior change.
80
+ */
81
+ function workflowResumeHeaders(token) {
82
+ return token ? { "x-sapiom-workflow-token": token } : {};
83
+ }
47
84
  /**
48
85
  * Generate one or more images from a prompt. Pass `storage` to persist each output
49
86
  * (the returned images then carry `fileId`). Failed requests throw
50
87
  * {@link ContentGenerationHttpError}.
51
88
  */
52
89
  async function createImage(input, transport = (0, index_js_1.defaultTransport)(), baseUrl = DEFAULT_BASE_URL) {
90
+ assertPrompt(input.prompt);
53
91
  const path = modelToPath(input.model || DEFAULT_IMAGE_MODEL);
54
92
  const body = {
55
93
  prompt: input.prompt,
@@ -70,8 +108,166 @@ async function createImage(input, transport = (0, index_js_1.defaultTransport)()
70
108
  }
71
109
  /**
72
110
  * The `images` sub-namespace, so `contentGeneration.images.create(...)` reads the
73
- * same whether imported from the barrel or used on a client. Video and audio will
74
- * land here as sibling sub-namespaces.
111
+ * same whether imported from the barrel or used on a client.
75
112
  */
76
113
  exports.images = { create: createImage };
114
+ // ----- Video (async) -----
115
+ /** Default video model when the caller doesn't pick one. */
116
+ const DEFAULT_VIDEO_MODEL = "fal-ai/veo3/fast";
117
+ /** How often to poll for the async result, and when to give up. Caller-overridable. */
118
+ const DEFAULT_VIDEO_POLL_INTERVAL_MS = 5000;
119
+ const DEFAULT_VIDEO_TIMEOUT_MS = 5 * 60000;
120
+ function mapVideo(raw) {
121
+ return {
122
+ url: raw.url,
123
+ ...(raw.content_type !== undefined && { contentType: raw.content_type }),
124
+ ...(raw.file_id !== undefined && { fileId: raw.file_id }),
125
+ ...(raw.storage_error !== undefined && { storageError: raw.storage_error }),
126
+ };
127
+ }
128
+ function mapVideoResult(raw) {
129
+ const { video, ...rest } = raw;
130
+ return video === undefined
131
+ ? { ...rest }
132
+ : { ...rest, video: mapVideo(video) };
133
+ }
134
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
135
+ /**
136
+ * Generate a video from a prompt. Video generation is asynchronous: this submits the
137
+ * job, then polls the result through Sapiom until it's ready and returns it — so you
138
+ * `await` it just like {@link createImage}, it just takes longer. Pass `storage` to
139
+ * persist the output (the returned `video` then carries `fileId`). Throws
140
+ * {@link ContentGenerationHttpError} on a failed submit, or an `Error` if the result
141
+ * isn't ready within `timeoutMs`.
142
+ */
143
+ async function createVideo(input, transport = (0, index_js_1.defaultTransport)(), baseUrl = DEFAULT_BASE_URL) {
144
+ assertPrompt(input.prompt);
145
+ const path = modelToPath(input.model || DEFAULT_VIDEO_MODEL);
146
+ const body = {
147
+ prompt: input.prompt,
148
+ ...input.params,
149
+ };
150
+ // Truthy check (not `!== undefined`) so `storage: null` is treated as "no storage".
151
+ if (input.storage)
152
+ body.storage = input.storage;
153
+ // Submit — for an async model Sapiom returns a queue handle, not the result.
154
+ const submitRes = await (0, errors_js_1.ensureOk)(await transport.fetch(`${baseUrl}/run/${path}`, {
155
+ method: "POST",
156
+ headers: { "content-type": "application/json" },
157
+ body: JSON.stringify(body),
158
+ }), "Failed to submit video generation");
159
+ const handle = (await submitRes.json());
160
+ if (!handle.response_url) {
161
+ throw new Error("Video submit did not return a result URL to poll");
162
+ }
163
+ // Poll the result THROUGH Sapiom until it's ready. The poll is what persists the
164
+ // output when `storage` was requested, so `fileId` is filled in by the time it returns.
165
+ const intervalMs = input.pollIntervalMs ?? DEFAULT_VIDEO_POLL_INTERVAL_MS;
166
+ const timeoutMs = input.timeoutMs ?? DEFAULT_VIDEO_TIMEOUT_MS;
167
+ const deadline = Date.now() + timeoutMs;
168
+ while (Date.now() < deadline) {
169
+ const res = await transport.fetch(handle.response_url, { method: "GET" });
170
+ if (res.ok) {
171
+ const raw = (await res.json());
172
+ if (raw.video?.url)
173
+ return mapVideoResult(raw);
174
+ }
175
+ else {
176
+ // Still generating, or a transient error. Drain the unread body so the
177
+ // connection can be reused, then keep polling — `timeoutMs` is the backstop
178
+ // for a result that never arrives.
179
+ try {
180
+ await res.body?.cancel();
181
+ }
182
+ catch {
183
+ // best-effort drain
184
+ }
185
+ }
186
+ await sleep(intervalMs);
187
+ }
188
+ throw new Error(`Video generation did not complete within ${timeoutMs}ms (request id: ${handle.request_id ?? "unknown"})`);
189
+ }
190
+ /**
191
+ * Map a live, awaited {@link VideoGenerationResult} to the plain
192
+ * {@link VideoResultPayload} a resumed step receives across the wire boundary.
193
+ */
194
+ function toVideoResumePayload(result) {
195
+ if (!result.video)
196
+ return { outputs: [] };
197
+ return {
198
+ outputs: [
199
+ {
200
+ ...(result.video.fileId !== undefined && {
201
+ fileId: result.video.fileId,
202
+ }),
203
+ ...(result.video.storageError !== undefined && {
204
+ storageError: result.video.storageError,
205
+ }),
206
+ },
207
+ ],
208
+ };
209
+ }
210
+ /**
211
+ * Submit a video generation job and return a dispatchable handle immediately.
212
+ * The handle's `dispatch` member lets a workflow step pause until the video
213
+ * is ready; `handle.wait()` blocks inline instead — same as `video.create` but
214
+ * with the ability to suspend a running workflow.
215
+ *
216
+ * Pass `storage` to persist the output (the result then carries `fileId`).
217
+ * Throws {@link ContentGenerationHttpError} when the submit fails.
218
+ */
219
+ async function launchVideo(input, transport = (0, index_js_1.defaultTransport)(), baseUrl = DEFAULT_BASE_URL) {
220
+ assertPrompt(input.prompt);
221
+ const path = modelToPath(input.model || DEFAULT_VIDEO_MODEL);
222
+ const body = {
223
+ prompt: input.prompt,
224
+ ...input.params,
225
+ };
226
+ if (input.storage)
227
+ body.storage = input.storage;
228
+ // Submit — includes the workflow resume token header so the service can resume
229
+ // the paused step when the job completes (no-op outside a workflow context).
230
+ const submitRes = await (0, errors_js_1.ensureOk)(await transport.fetch(`${baseUrl}/run/${path}`, {
231
+ method: "POST",
232
+ headers: {
233
+ "content-type": "application/json",
234
+ ...workflowResumeHeaders(transport.resumeToken),
235
+ },
236
+ body: JSON.stringify(body),
237
+ }), "Failed to submit video generation");
238
+ const handle = (await submitRes.json());
239
+ if (!handle.response_url) {
240
+ throw new Error("Video submit did not return a result URL to poll");
241
+ }
242
+ const requestId = handle.request_id ?? "unknown";
243
+ const responseUrl = handle.response_url;
244
+ const wait = async ({ timeoutMs = input.timeoutMs ?? DEFAULT_VIDEO_TIMEOUT_MS, pollMs = input.pollIntervalMs ?? DEFAULT_VIDEO_POLL_INTERVAL_MS, } = {}) => {
245
+ const deadline = Date.now() + timeoutMs;
246
+ while (Date.now() < deadline) {
247
+ const res = await transport.fetch(responseUrl, { method: "GET" });
248
+ if (res.ok) {
249
+ const raw = (await res.json());
250
+ if (raw.video?.url)
251
+ return mapVideoResult(raw);
252
+ }
253
+ else {
254
+ try {
255
+ await res.body?.cancel();
256
+ }
257
+ catch {
258
+ // best-effort drain
259
+ }
260
+ }
261
+ await sleep(pollMs);
262
+ }
263
+ throw new Error(`Video generation did not complete within ${timeoutMs}ms (request id: ${requestId})`);
264
+ };
265
+ return {
266
+ requestId,
267
+ dispatch: { correlationId: requestId, resultSignal: exports.VIDEO_RESULT_SIGNAL },
268
+ wait,
269
+ };
270
+ }
271
+ /** The `video` sub-namespace: `contentGeneration.video.create(...)` and `contentGeneration.video.launch(...)`. */
272
+ exports.video = { create: createVideo, launch: launchVideo };
77
273
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/content-generation/index.ts"],"names":[],"mappings":";;;AAoIA,kCAyBC;AA7JD;;;;;;;;;;;;;;GAcG;AACH,kDAAkE;AAClE,2CAAmE;AAE1D,2GAFU,sCAA0B,OAEV;AAEnC,MAAM,gBAAgB,GACpB,OAAO,CAAC,GAAG,CAAC,6BAA6B,IAAI,gCAAgC,CAAC;AAEhF,qFAAqF;AACrF,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AA8ElD,SAAS,QAAQ,CAAC,GAAa;IAC7B,OAAO;QACL,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,GAAG,CAAC,GAAG,CAAC,YAAY,KAAK,SAAS,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,YAAY,EAAE,CAAC;QACxE,GAAG,CAAC,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC;QACpD,GAAG,CAAC,GAAG,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;QACvD,GAAG,CAAC,GAAG,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;QACzD,GAAG,CAAC,GAAG,CAAC,aAAa,KAAK,SAAS,IAAI,EAAE,YAAY,EAAE,GAAG,CAAC,aAAa,EAAE,CAAC;KAC5E,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,GAAmB;IACpC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,CAAC;IAChC,OAAO,MAAM,KAAK,SAAS;QACzB,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE;QACb,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,C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/**
2
+ * Error thrown by the `database` capability when a request fails (non-2xx
3
+ * response). Exposes `status` (HTTP status code) and `body` (parsed JSON body, or
4
+ * raw text when the body isn't JSON) for programmatic inspection.
5
+ */
6
+ export declare class DatabaseHttpError extends Error {
7
+ readonly status: number;
8
+ readonly body: unknown;
9
+ constructor(message: string, status: number, body: unknown);
10
+ }
11
+ /**
12
+ * Return the response when 2xx, otherwise throw a {@link DatabaseHttpError}.
13
+ * Parses the error body as JSON when possible; falls back to raw text.
14
+ */
15
+ export declare function ensureOk(response: Response, errorPrefix: string): Promise<Response>;
16
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/database/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAM3D;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAC5B,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,QAAQ,CAAC,CAcnB"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DatabaseHttpError = void 0;
4
+ exports.ensureOk = ensureOk;
5
+ /**
6
+ * Error thrown by the `database` capability when a request fails (non-2xx
7
+ * response). Exposes `status` (HTTP status code) and `body` (parsed JSON body, or
8
+ * raw text when the body isn't JSON) for programmatic inspection.
9
+ */
10
+ class DatabaseHttpError extends Error {
11
+ constructor(message, status, body) {
12
+ super(message);
13
+ this.name = "DatabaseHttpError";
14
+ this.status = status;
15
+ this.body = body;
16
+ }
17
+ }
18
+ exports.DatabaseHttpError = DatabaseHttpError;
19
+ /**
20
+ * Return the response when 2xx, otherwise throw a {@link DatabaseHttpError}.
21
+ * Parses the error body as JSON when possible; falls back to raw text.
22
+ */
23
+ async function ensureOk(response, errorPrefix) {
24
+ if (response.ok)
25
+ return response;
26
+ let body;
27
+ const text = await response.text().catch(() => "");
28
+ try {
29
+ body = JSON.parse(text);
30
+ }
31
+ catch {
32
+ body = text;
33
+ }
34
+ throw new DatabaseHttpError(`${errorPrefix}: ${response.status} ${text}`, response.status, body);
35
+ }
36
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/database/errors.ts"],"names":[],"mappings":";;;AAqBA,4BAiBC;AAtCD;;;;GAIG;AACH,MAAa,iBAAkB,SAAQ,KAAK;IAI1C,YAAY,OAAe,EAAE,MAAc,EAAE,IAAa;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAVD,8CAUC;AAED;;;GAGG;AACI,KAAK,UAAU,QAAQ,CAC5B,QAAkB,EAClB,WAAmB;IAEnB,IAAI,QAAQ,CAAC,EAAE;QAAE,OAAO,QAAQ,CAAC;IACjC,IAAI,IAAa,CAAC;IAClB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;IACnD,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,GAAG,IAAI,CAAC;IACd,CAAC;IACD,MAAM,IAAI,iBAAiB,CACzB,GAAG,WAAW,KAAK,QAAQ,CAAC,MAAM,IAAI,IAAI,EAAE,EAC5C,QAAQ,CAAC,MAAM,EACf,IAAI,CACL,CAAC;AACJ,CAAC"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * `database` capability — provision an on-demand Postgres database, retrieve it,
3
+ * and delete it. You get back direct connection credentials, so you can connect
4
+ * with any standard Postgres client or driver.
5
+ *
6
+ * import { database } from "@sapiom/tools"; // ambient auth
7
+ * const db = await database.create({ duration: "1h", handle: "analytics" });
8
+ * db.connection?.connectionString; // a ready-to-use Postgres URI
9
+ *
10
+ * const again = await database.get(db.id); // or get("analytics") by handle
11
+ * await database.delete(db.id); // or delete("analytics")
12
+ *
13
+ * Or via an explicit client: `createClient({ apiKey }).database.create(...)`.
14
+ *
15
+ * This is a provisioning surface, not a query layer: it hands you connection
16
+ * credentials and you run your own SQL with the client of your choice.
17
+ */
18
+ import { Transport } from "../_client/index.js";
19
+ import { DatabaseHttpError } from "./errors.js";
20
+ export { DatabaseHttpError };
21
+ /** How long the database lives before it is automatically removed. */
22
+ export type DatabaseDuration = "15m" | "1h" | "4h" | "24h" | "7d";
23
+ /** Lifecycle state of a database. */
24
+ export type DatabaseStatus = "provisioning" | "active" | "expired" | "deleting" | "deleted";
25
+ export interface CreateDatabaseInput {
26
+ /** How long the database lives before it is automatically removed (required). */
27
+ duration: DatabaseDuration;
28
+ /**
29
+ * Optional stable, human-friendly key you can use to look the database up later
30
+ * (`get(handle)` / `delete(handle)`). 3–63 chars, `^[a-z0-9][a-z0-9-]*[a-z0-9]$`.
31
+ * Unique within your tenant.
32
+ */
33
+ handle?: string;
34
+ /** Optional display name. */
35
+ name?: string;
36
+ /** Optional description (up to 500 chars). */
37
+ description?: string;
38
+ /** Optional region to provision in. Defaults to a US region. */
39
+ region?: string;
40
+ /** Optional Postgres major version. Defaults to the latest supported. */
41
+ pgVersion?: 15 | 16 | 17;
42
+ }
43
+ export interface DatabaseConnection {
44
+ /**
45
+ * The full Postgres connection URI — pass this to any Postgres client. This is
46
+ * the canonical value and is always present; the component fields below are
47
+ * parsed from it on a best-effort basis and may be absent if it can't be parsed.
48
+ */
49
+ connectionString: string;
50
+ /** Database host. */
51
+ host?: string;
52
+ /** Database port. */
53
+ port?: number;
54
+ /** Database user. */
55
+ username?: string;
56
+ /** Database password. */
57
+ password?: string;
58
+ /** Name of the database to connect to. */
59
+ databaseName?: string;
60
+ /** SSL mode from the connection URI, when present (e.g. "require"). */
61
+ sslmode?: string;
62
+ }
63
+ export interface Database {
64
+ /** Unique database identifier. */
65
+ id: string;
66
+ /** The handle you set at creation, or `null` if none was given. */
67
+ handle: string | null;
68
+ /** Display name, or `null`. */
69
+ name: string | null;
70
+ /** Description, or `null`. */
71
+ description: string | null;
72
+ /** Lifecycle state. */
73
+ status: DatabaseStatus;
74
+ /** Region the database is provisioned in. */
75
+ region: string;
76
+ /** Postgres major version. */
77
+ pgVersion: number;
78
+ /** The lifetime the database was created with. */
79
+ duration: DatabaseDuration | string;
80
+ /** Connection credentials — `null` while the database is still being provisioned. */
81
+ connection: DatabaseConnection | null;
82
+ /** ISO-8601 timestamp when the database expires, or `null`. */
83
+ expiresAt: string | null;
84
+ /** ISO-8601 timestamp when the database was created. */
85
+ createdAt: string;
86
+ }
87
+ /**
88
+ * Provision a new Postgres database. `duration` is required. Returns the database
89
+ * with connection credentials in `connection`. Failed requests throw
90
+ * {@link DatabaseHttpError}.
91
+ */
92
+ export declare function create(input: CreateDatabaseInput, transport?: Transport, baseUrl?: string): Promise<Database>;
93
+ /** Retrieve a database by its id or handle. */
94
+ export declare function get(idOrHandle: string, transport?: Transport, baseUrl?: string): Promise<Database>;
95
+ /**
96
+ * Delete a database by its id or handle. Exported as `delete`:
97
+ * `import { database } from "@sapiom/tools"; await database.delete(id)`.
98
+ */
99
+ declare function deleteDatabase(idOrHandle: string, transport?: Transport, baseUrl?: string): Promise<void>;
100
+ export { deleteDatabase as delete };
101
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/database/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;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C;IACtB,+BAA+B;IAC/B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,8BAA8B;IAC9B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,uBAAuB;IACvB,MAAM,EAAE,cAAc,CAAC;IACvB,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,QAAQ,EAAE,gBAAgB,GAAG,MAAM,CAAC;IACpC,qFAAqF;IACrF,UAAU,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACtC,+DAA+D;IAC/D,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;CACnB;AAoED;;;;GAIG;AACH,wBAAsB,MAAM,CAC1B,KAAK,EAAE,mBAAmB,EAC1B,SAAS,GAAE,SAA8B,EACzC,OAAO,SAAmB,GACzB,OAAO,CAAC,QAAQ,CAAC,CAuBnB;AAED,+CAA+C;AAC/C,wBAAsB,GAAG,CACvB,UAAU,EAAE,MAAM,EAClB,SAAS,GAAE,SAA8B,EACzC,OAAO,SAAmB,GACzB,OAAO,CAAC,QAAQ,CAAC,CAQnB;AAED;;;GAGG;AACH,iBAAe,cAAc,CAC3B,UAAU,EAAE,MAAM,EAClB,SAAS,GAAE,SAA8B,EACzC,OAAO,SAAmB,GACzB,OAAO,CAAC,IAAI,CAAC,CAmBf;AAED,OAAO,EAAE,cAAc,IAAI,MAAM,EAAE,CAAC"}
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DatabaseHttpError = void 0;
4
+ exports.create = create;
5
+ exports.get = get;
6
+ exports.delete = deleteDatabase;
7
+ /**
8
+ * `database` capability — provision an on-demand Postgres database, retrieve it,
9
+ * and delete it. You get back direct connection credentials, so you can connect
10
+ * with any standard Postgres client or driver.
11
+ *
12
+ * import { database } from "@sapiom/tools"; // ambient auth
13
+ * const db = await database.create({ duration: "1h", handle: "analytics" });
14
+ * db.connection?.connectionString; // a ready-to-use Postgres URI
15
+ *
16
+ * const again = await database.get(db.id); // or get("analytics") by handle
17
+ * await database.delete(db.id); // or delete("analytics")
18
+ *
19
+ * Or via an explicit client: `createClient({ apiKey }).database.create(...)`.
20
+ *
21
+ * This is a provisioning surface, not a query layer: it hands you connection
22
+ * credentials and you run your own SQL with the client of your choice.
23
+ */
24
+ const index_js_1 = require("../_client/index.js");
25
+ const errors_js_1 = require("./errors.js");
26
+ Object.defineProperty(exports, "DatabaseHttpError", { enumerable: true, get: function () { return errors_js_1.DatabaseHttpError; } });
27
+ const DEFAULT_BASE_URL = process.env.SAPIOM_DATABASE_URL || "https://neon.services.sapiom.ai";
28
+ /**
29
+ * Break a Postgres connection URI into its parts. `connectionString` is always
30
+ * preserved (it is the value you pass to a client); the parsed components are a
31
+ * convenience. If the URI can't be parsed, only `connectionString` is returned.
32
+ */
33
+ function parseConnectionUri(uri) {
34
+ try {
35
+ const u = new URL(uri);
36
+ return {
37
+ connectionString: uri,
38
+ host: u.hostname,
39
+ port: u.port ? Number(u.port) : 5432,
40
+ username: decodeURIComponent(u.username),
41
+ password: decodeURIComponent(u.password),
42
+ databaseName: u.pathname.replace(/^\//, ""),
43
+ sslmode: u.searchParams.get("sslmode") ?? undefined,
44
+ };
45
+ }
46
+ catch {
47
+ return { connectionString: uri };
48
+ }
49
+ }
50
+ function mapDatabase(raw) {
51
+ return {
52
+ id: raw.id,
53
+ handle: raw.handle,
54
+ name: raw.name,
55
+ description: raw.description,
56
+ status: raw.status,
57
+ region: raw.region,
58
+ pgVersion: raw.pgVersion,
59
+ duration: raw.duration,
60
+ connection: raw.connectionUri == null ? null : parseConnectionUri(raw.connectionUri),
61
+ expiresAt: raw.expiresAt,
62
+ createdAt: raw.createdAt,
63
+ };
64
+ }
65
+ // ----- Capability operations -----
66
+ /**
67
+ * Provision a new Postgres database. `duration` is required. Returns the database
68
+ * with connection credentials in `connection`. Failed requests throw
69
+ * {@link DatabaseHttpError}.
70
+ */
71
+ async function create(input, transport = (0, index_js_1.defaultTransport)(), baseUrl = DEFAULT_BASE_URL) {
72
+ if (!input.duration) {
73
+ throw new errors_js_1.DatabaseHttpError("duration is required", 400, {
74
+ message: "duration is required",
75
+ });
76
+ }
77
+ const body = { duration: input.duration };
78
+ if (input.handle !== undefined)
79
+ body.handle = input.handle;
80
+ if (input.name !== undefined)
81
+ body.name = input.name;
82
+ if (input.description !== undefined)
83
+ body.description = input.description;
84
+ if (input.region !== undefined)
85
+ body.region = input.region;
86
+ if (input.pgVersion !== undefined)
87
+ body.pgVersion = input.pgVersion;
88
+ const res = await (0, errors_js_1.ensureOk)(await transport.fetch(`${baseUrl}/v1/databases`, {
89
+ method: "POST",
90
+ headers: { "content-type": "application/json" },
91
+ body: JSON.stringify(body),
92
+ }), "Failed to create database");
93
+ return mapDatabase((await res.json()));
94
+ }
95
+ /** Retrieve a database by its id or handle. */
96
+ async function get(idOrHandle, transport = (0, index_js_1.defaultTransport)(), baseUrl = DEFAULT_BASE_URL) {
97
+ const res = await (0, errors_js_1.ensureOk)(await transport.fetch(`${baseUrl}/v1/databases/${encodeURIComponent(idOrHandle)}`), `Failed to get database '${idOrHandle}'`);
98
+ return mapDatabase((await res.json()));
99
+ }
100
+ /**
101
+ * Delete a database by its id or handle. Exported as `delete`:
102
+ * `import { database } from "@sapiom/tools"; await database.delete(id)`.
103
+ */
104
+ async function deleteDatabase(idOrHandle, transport = (0, index_js_1.defaultTransport)(), baseUrl = DEFAULT_BASE_URL) {
105
+ const res = await transport.fetch(`${baseUrl}/v1/databases/${encodeURIComponent(idOrHandle)}`, { method: "DELETE" });
106
+ if (!res.ok) {
107
+ const text = await res.text().catch(() => "");
108
+ let parsed;
109
+ try {
110
+ parsed = JSON.parse(text);
111
+ }
112
+ catch {
113
+ parsed = text;
114
+ }
115
+ throw new errors_js_1.DatabaseHttpError(`Failed to delete database '${idOrHandle}': ${res.status} ${text}`, res.status, parsed);
116
+ }
117
+ }
118
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/database/index.ts"],"names":[],"mappings":";;;AA8KA,wBA2BC;AAGD,kBAYC;AA+B0B,gCAAM;AAvPjC;;;;;;;;;;;;;;;;GAgBG;AACH,kDAAkE;AAClE,2CAA0D;AAEjD,kGAFU,6BAAiB,OAEV;AAE1B,MAAM,gBAAgB,GACpB,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,iCAAiC,CAAC;AAyGvE;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,GAAW;IACrC,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACvB,OAAO;YACL,gBAAgB,EAAE,GAAG;YACrB,IAAI,EAAE,CAAC,CAAC,QAAQ;YAChB,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI;YACpC,QAAQ,EAAE,kBAAkB,CAAC,CAAC,CAAC,QAAQ,CAAC;YACxC,QAAQ,EAAE,kBAAkB,CAAC,CAAC,CAAC,QAAQ,CAAC;YACxC,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;YAC3C,OAAO,EAAE,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,SAAS;SACpD,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,gBAAgB,EAAE,GAAG,EAAE,CAAC;IACnC,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,GAAwB;IAC3C,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,WAAW,EA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YACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC;QACD,MAAM,IAAI,6BAAiB,CACzB,8BAA8B,UAAU,MAAM,GAAG,CAAC,MAAM,IAAI,IAAI,EAAE,EAClE,GAAG,CAAC,MAAM,EACV,MAAM,CACP,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -26,9 +26,16 @@ export { codingResultSchema, CodingResultSchemaError, toResumePayload, EXECUTION
26
26
  export * as orchestrations from "./orchestrations/index.js";
27
27
  export { ORCHESTRATIONS_RESULT_SIGNAL } from "./orchestrations/index.js";
28
28
  export type { OrchestrationRunResultPayload } from "./orchestrations/index.js";
29
- export { orchestrationResultSchema, OrchestrationResultSchemaError } from "./orchestrations/index.js";
29
+ export { orchestrationResultSchema, OrchestrationResultSchemaError, } from "./orchestrations/index.js";
30
30
  export * as fileStorage from "./file-storage/index.js";
31
31
  export { FileStorageHttpError } from "./file-storage/index.js";
32
32
  export * as contentGeneration from "./content-generation/index.js";
33
33
  export { ContentGenerationHttpError } from "./content-generation/index.js";
34
+ export { VIDEO_RESULT_SIGNAL } from "./content-generation/index.js";
35
+ export type { VideoResultPayload } from "./content-generation/index.js";
36
+ export { toVideoResumePayload } from "./content-generation/index.js";
37
+ export * as search from "./search/index.js";
38
+ export { SearchHttpError } from "./search/index.js";
39
+ export * as database from "./database/index.js";
40
+ export { DatabaseHttpError } from "./database/index.js";
34
41
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAChE,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE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,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/cjs/index.js CHANGED
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ContentGenerationHttpError = exports.contentGeneration = exports.FileStorageHttpError = exports.fileStorage = exports.OrchestrationResultSchemaError = exports.orchestrationResultSchema = exports.ORCHESTRATIONS_RESULT_SIGNAL = exports.orchestrations = exports.EXECUTION_ENVIRONMENT_BLAXEL_SANDBOX = exports.toResumePayload = exports.CodingResultSchemaError = exports.codingResultSchema = exports.CODING_RESULT_SIGNAL = exports.agent = exports.Repository = exports.repositories = exports.Sandbox = exports.sandboxes = exports.createClientFromEnv = exports.createClient = void 0;
36
+ exports.DatabaseHttpError = exports.database = exports.SearchHttpError = exports.search = exports.toVideoResumePayload = exports.VIDEO_RESULT_SIGNAL = exports.ContentGenerationHttpError = exports.contentGeneration = exports.FileStorageHttpError = exports.fileStorage = exports.OrchestrationResultSchemaError = exports.orchestrationResultSchema = exports.ORCHESTRATIONS_RESULT_SIGNAL = exports.orchestrations = exports.EXECUTION_ENVIRONMENT_BLAXEL_SANDBOX = exports.toResumePayload = exports.CodingResultSchemaError = exports.codingResultSchema = exports.CODING_RESULT_SIGNAL = exports.agent = exports.Repository = exports.repositories = exports.Sandbox = exports.sandboxes = exports.createClientFromEnv = exports.createClient = void 0;
37
37
  /**
38
38
  * `@sapiom/tools` — the typed Sapiom capability client.
39
39
  *
@@ -81,4 +81,16 @@ Object.defineProperty(exports, "FileStorageHttpError", { enumerable: true, get:
81
81
  exports.contentGeneration = __importStar(require("./content-generation/index.js"));
82
82
  var index_js_8 = require("./content-generation/index.js");
83
83
  Object.defineProperty(exports, "ContentGenerationHttpError", { enumerable: true, get: function () { return index_js_8.ContentGenerationHttpError; } });
84
+ // Surfaced top-level for the static `pause: { signal }` decl on a workflow step.
85
+ var index_js_9 = require("./content-generation/index.js");
86
+ Object.defineProperty(exports, "VIDEO_RESULT_SIGNAL", { enumerable: true, get: function () { return index_js_9.VIDEO_RESULT_SIGNAL; } });
87
+ // Map a live VideoGenerationResult to the wire shape the resumed step receives.
88
+ var index_js_10 = require("./content-generation/index.js");
89
+ Object.defineProperty(exports, "toVideoResumePayload", { enumerable: true, get: function () { return index_js_10.toVideoResumePayload; } });
90
+ exports.search = __importStar(require("./search/index.js"));
91
+ var index_js_11 = require("./search/index.js");
92
+ Object.defineProperty(exports, "SearchHttpError", { enumerable: true, get: function () { return index_js_11.SearchHttpError; } });
93
+ exports.database = __importStar(require("./database/index.js"));
94
+ var index_js_12 = require("./database/index.js");
95
+ Object.defineProperty(exports, "DatabaseHttpError", { enumerable: true, get: function () { return index_js_12.DatabaseHttpError; } });
84
96
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;GAYG;AACH,yCAAgE;AAAvD,yGAAA,YAAY,OAAA;AAAE,gHAAA,mBAAmB,OAAA;AAQ1C,kEAAkD;AAClD,iDAA+C;AAAtC,mGAAA,OAAO,OAAA;AAEhB,wEAAwD;AACxD,oDAAqD;AAA5C,sGAAA,UAAU,OAAA;AAEnB,0DAA0C;AAC1C,iFAAiF;AACjF,6CAAwD;AAA/C,gHAAA,oBAAoB,OAAA;AAO7B,+EAA+E;AAC/E,2CAA2C;AAC3C,6CAK0B;AAJxB,8GAAA,kBAAkB,OAAA;AAClB,mHAAA,uBAAuB,OAAA;AACvB,2GAAA,eAAe,OAAA;AACf,gIAAA,oCAAoC,OAAA;AAGtC,4EAA4D;AAC5D,iFAAiF;AACjF,sDAAyE;AAAhE,wHAAA,4BAA4B,OAAA;AAIrC,oEAAoE;AACpE,sDAAsG;AAA7F,qHAAA,yBAAyB,OAAA;AAAE,0HAAA,8BAA8B,OAAA;AAElE,uEAAuD;AACvD,oDAA+D;AAAtD,gHAAA,oBAAoB,OAAA;AAE7B,mFAAmE;AACnE,0DAA2E;AAAlE,sHAAA,0BAA0B,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;GAYG;AACH,yCAAgE;AAAvD,yGAAA,YAAY,OAAA;AAAE,gHAAA,mBAAmB,OAAA;AAQ1C,kEAAkD;AAClD,iDAA+C;AAAtC,mGAAA,OAAO,OAAA;AAEhB,wEAAwD;AACxD,oDAAqD;AAA5C,sGAAA,UAAU,OAAA;AAEnB,0DAA0C;AAC1C,iFAAiF;AACjF,6CAAwD;AAA/C,gHAAA,oBAAoB,OAAA;AAO7B,+EAA+E;AAC/E,2CAA2C;AAC3C,6CAK0B;AAJxB,8GAAA,kBAAkB,OAAA;AAClB,mHAAA,uBAAuB,OAAA;AACvB,2GAAA,eAAe,OAAA;AACf,gIAAA,oCAAoC,OAAA;AAGtC,4EAA4D;AAC5D,iFAAiF;AACjF,sDAAyE;AAAhE,wHAAA,4BAA4B,OAAA;AAIrC,oEAAoE;AACpE,sDAGmC;AAFjC,qHAAA,yBAAyB,OAAA;AACzB,0HAAA,8BAA8B,OAAA;AAGhC,uEAAuD;AACvD,oDAA+D;AAAtD,gHAAA,oBAAoB,OAAA;AAE7B,mFAAmE;AACnE,0DAA2E;AAAlE,sHAAA,0BAA0B,OAAA;AACnC,iFAAiF;AACjF,0DAAoE;AAA3D,+GAAA,mBAAmB,OAAA;AAI5B,gFAAgF;AAChF,2DAAqE;AAA5D,iHAAA,oBAAoB,OAAA;AAE7B,4DAA4C;AAC5C,+CAAoD;AAA3C,4GAAA,eAAe,OAAA;AAExB,gEAAgD;AAChD,iDAAwD;AAA/C,8GAAA,iBAAiB,OAAA"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Error thrown by the `search` capability when a request fails (non-2xx
3
+ * response). Exposes `status` (HTTP status code) and `body` (parsed JSON body, or
4
+ * raw text when the body isn't JSON) for programmatic inspection.
5
+ */
6
+ export declare class SearchHttpError extends Error {
7
+ readonly status: number;
8
+ readonly body: unknown;
9
+ constructor(message: string, status: number, body: unknown);
10
+ }
11
+ /**
12
+ * Return the response when 2xx, otherwise throw a {@link SearchHttpError}.
13
+ * Parses the error body as JSON when possible; falls back to raw text.
14
+ */
15
+ export declare function ensureOk(response: Response, errorPrefix: string): Promise<Response>;
16
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/search/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAM3D;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAC5B,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,QAAQ,CAAC,CAcnB"}