@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.
- package/CHANGELOG.md +35 -0
- package/README.md +17 -11
- package/dist/cjs/_client/index.d.ts +22 -2
- package/dist/cjs/_client/index.d.ts.map +1 -1
- package/dist/cjs/_client/index.js +16 -6
- package/dist/cjs/_client/index.js.map +1 -1
- package/dist/cjs/client.d.ts +46 -1
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +20 -0
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/content-generation/index.d.ts +118 -3
- package/dist/cjs/content-generation/index.d.ts.map +1 -1
- package/dist/cjs/content-generation/index.js +200 -4
- package/dist/cjs/content-generation/index.js.map +1 -1
- package/dist/cjs/database/errors.d.ts +16 -0
- package/dist/cjs/database/errors.d.ts.map +1 -0
- package/dist/cjs/database/errors.js +36 -0
- package/dist/cjs/database/errors.js.map +1 -0
- package/dist/cjs/database/index.d.ts +101 -0
- package/dist/cjs/database/index.d.ts.map +1 -0
- package/dist/cjs/database/index.js +118 -0
- package/dist/cjs/database/index.js.map +1 -0
- package/dist/cjs/index.d.ts +8 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +13 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/search/errors.d.ts +16 -0
- package/dist/cjs/search/errors.d.ts.map +1 -0
- package/dist/cjs/search/errors.js +36 -0
- package/dist/cjs/search/errors.js.map +1 -0
- package/dist/cjs/search/index.d.ts +234 -0
- package/dist/cjs/search/index.d.ts.map +1 -0
- package/dist/cjs/search/index.js +286 -0
- package/dist/cjs/search/index.js.map +1 -0
- package/dist/cjs/stub/index.d.ts.map +1 -1
- package/dist/cjs/stub/index.js +150 -2
- package/dist/cjs/stub/index.js.map +1 -1
- package/dist/esm/_client/index.d.ts +22 -2
- package/dist/esm/_client/index.d.ts.map +1 -1
- package/dist/esm/_client/index.js +16 -6
- package/dist/esm/_client/index.js.map +1 -1
- package/dist/esm/client.d.ts +46 -1
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +20 -0
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/content-generation/index.d.ts +118 -3
- package/dist/esm/content-generation/index.d.ts.map +1 -1
- package/dist/esm/content-generation/index.js +196 -3
- package/dist/esm/content-generation/index.js.map +1 -1
- package/dist/esm/database/errors.d.ts +16 -0
- package/dist/esm/database/errors.d.ts.map +1 -0
- package/dist/esm/database/errors.js +31 -0
- package/dist/esm/database/errors.js.map +1 -0
- package/dist/esm/database/index.d.ts +101 -0
- package/dist/esm/database/index.d.ts.map +1 -0
- package/dist/esm/database/index.js +113 -0
- package/dist/esm/database/index.js.map +1 -0
- package/dist/esm/index.d.ts +8 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +9 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/search/errors.d.ts +16 -0
- package/dist/esm/search/errors.d.ts.map +1 -0
- package/dist/esm/search/errors.js +31 -0
- package/dist/esm/search/errors.js.map +1 -0
- package/dist/esm/search/index.d.ts +234 -0
- package/dist/esm/search/index.d.ts.map +1 -0
- package/dist/esm/search/index.js +278 -0
- package/dist/esm/search/index.js.map +1 -0
- package/dist/esm/stub/index.d.ts.map +1 -1
- package/dist/esm/stub/index.js +150 -2
- package/dist/esm/stub/index.js.map +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +11 -1
- package/src/content-generation/README.md +90 -2
- package/src/database/README.md +62 -0
- package/src/search/README.md +255 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/content-generation/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/content-generation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;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pC;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,KAAK,CAAC;QACb,6DAA6D;QAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,4EAA4E;QAC5E,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC,CAAC;CACJ;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,qBAAqB,GAC5B,kBAAkB,CAcpB;AAED;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,gBAAgB,EACvB,SAAS,GAAE,SAA8B,EACzC,OAAO,SAAmB,GACzB,OAAO,CAAC,iBAAiB,CAAC,CA+D5B;AAED,kHAAkH;AAClH,eAAO,MAAM,KAAK;;;CAA+C,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `contentGeneration` capability — generate media (images
|
|
2
|
+
* `contentGeneration` capability — generate media (images and video today; audio
|
|
3
3
|
* to come), with an optional `storage` param that persists each output to Sapiom
|
|
4
4
|
* file storage so you get a durable `fileId` back inline.
|
|
5
5
|
*
|
|
@@ -12,11 +12,24 @@
|
|
|
12
12
|
* out.images[0].fileId; // present when `storage` was passed → use with fileStorage
|
|
13
13
|
*
|
|
14
14
|
* Or via an explicit client: `createClient({ apiKey }).contentGeneration.images.create(...)`.
|
|
15
|
+
*
|
|
16
|
+
* `video.launch` is the dispatchable surface: it submits the job and returns a
|
|
17
|
+
* handle immediately. Pass the handle to `pauseUntilSignal(handle, { resumeStep })`
|
|
18
|
+
* to suspend the workflow step until the video is ready, or call `handle.wait()`
|
|
19
|
+
* inline to block until done — same as `video.create` but with the ability to
|
|
20
|
+
* pause a running workflow.
|
|
15
21
|
*/
|
|
16
22
|
import { defaultTransport } from "../_client/index.js";
|
|
17
23
|
import { ensureOk, ContentGenerationHttpError } from "./errors.js";
|
|
18
24
|
export { ContentGenerationHttpError };
|
|
19
25
|
const DEFAULT_BASE_URL = process.env.SAPIOM_CONTENT_GENERATION_URL || "https://fal.services.sapiom.ai";
|
|
26
|
+
/**
|
|
27
|
+
* Capability-stable signal a video launch fires when the video reaches a terminal
|
|
28
|
+
* state (ready OR failed — it carries the result either way, the resumed step
|
|
29
|
+
* branches). A workflow step paused on a launch handle resumes on this; it is the
|
|
30
|
+
* value carried in the handle's `dispatch.resultSignal`.
|
|
31
|
+
*/
|
|
32
|
+
export const VIDEO_RESULT_SIGNAL = "contentGeneration.video.result";
|
|
20
33
|
/** Default image model when the caller doesn't pick one — a fast, low-cost model. */
|
|
21
34
|
const DEFAULT_IMAGE_MODEL = "fal-ai/flux/schnell";
|
|
22
35
|
function mapImage(raw) {
|
|
@@ -40,12 +53,34 @@ function mapResult(raw) {
|
|
|
40
53
|
function modelToPath(model) {
|
|
41
54
|
return model.split("/").filter(Boolean).map(encodeURIComponent).join("/");
|
|
42
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Guard a prompt value: throw a clear error before a paid job is submitted when
|
|
58
|
+
* the prompt is absent, empty, or not a string. A JS caller passing `null`,
|
|
59
|
+
* `undefined`, or `""` gets an immediate, actionable error instead of a silent
|
|
60
|
+
* paid request with a blank prompt.
|
|
61
|
+
*/
|
|
62
|
+
function assertPrompt(prompt) {
|
|
63
|
+
if (typeof prompt !== "string" || prompt.trim() === "") {
|
|
64
|
+
throw new ContentGenerationHttpError("prompt is required and must be a non-empty string", 400, { error: "invalid_prompt" });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* When launched from inside a Sapiom workflow step, the engine injects an opaque
|
|
69
|
+
* per-execution resume token into the transport. Forwarding it as a header — NOT
|
|
70
|
+
* a body field, so author-supplied request fields can't clobber it — lets the
|
|
71
|
+
* service call back into the engine to resume the paused workflow when the job
|
|
72
|
+
* finishes. Absent outside a workflow → no header, no behavior change.
|
|
73
|
+
*/
|
|
74
|
+
function workflowResumeHeaders(token) {
|
|
75
|
+
return token ? { "x-sapiom-workflow-token": token } : {};
|
|
76
|
+
}
|
|
43
77
|
/**
|
|
44
78
|
* Generate one or more images from a prompt. Pass `storage` to persist each output
|
|
45
79
|
* (the returned images then carry `fileId`). Failed requests throw
|
|
46
80
|
* {@link ContentGenerationHttpError}.
|
|
47
81
|
*/
|
|
48
82
|
export async function createImage(input, transport = defaultTransport(), baseUrl = DEFAULT_BASE_URL) {
|
|
83
|
+
assertPrompt(input.prompt);
|
|
49
84
|
const path = modelToPath(input.model || DEFAULT_IMAGE_MODEL);
|
|
50
85
|
const body = {
|
|
51
86
|
prompt: input.prompt,
|
|
@@ -66,8 +101,166 @@ export async function createImage(input, transport = defaultTransport(), baseUrl
|
|
|
66
101
|
}
|
|
67
102
|
/**
|
|
68
103
|
* The `images` sub-namespace, so `contentGeneration.images.create(...)` reads the
|
|
69
|
-
* same whether imported from the barrel or used on a client.
|
|
70
|
-
* land here as sibling sub-namespaces.
|
|
104
|
+
* same whether imported from the barrel or used on a client.
|
|
71
105
|
*/
|
|
72
106
|
export const images = { create: createImage };
|
|
107
|
+
// ----- Video (async) -----
|
|
108
|
+
/** Default video model when the caller doesn't pick one. */
|
|
109
|
+
const DEFAULT_VIDEO_MODEL = "fal-ai/veo3/fast";
|
|
110
|
+
/** How often to poll for the async result, and when to give up. Caller-overridable. */
|
|
111
|
+
const DEFAULT_VIDEO_POLL_INTERVAL_MS = 5000;
|
|
112
|
+
const DEFAULT_VIDEO_TIMEOUT_MS = 5 * 60000;
|
|
113
|
+
function mapVideo(raw) {
|
|
114
|
+
return {
|
|
115
|
+
url: raw.url,
|
|
116
|
+
...(raw.content_type !== undefined && { contentType: raw.content_type }),
|
|
117
|
+
...(raw.file_id !== undefined && { fileId: raw.file_id }),
|
|
118
|
+
...(raw.storage_error !== undefined && { storageError: raw.storage_error }),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function mapVideoResult(raw) {
|
|
122
|
+
const { video, ...rest } = raw;
|
|
123
|
+
return video === undefined
|
|
124
|
+
? { ...rest }
|
|
125
|
+
: { ...rest, video: mapVideo(video) };
|
|
126
|
+
}
|
|
127
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
128
|
+
/**
|
|
129
|
+
* Generate a video from a prompt. Video generation is asynchronous: this submits the
|
|
130
|
+
* job, then polls the result through Sapiom until it's ready and returns it — so you
|
|
131
|
+
* `await` it just like {@link createImage}, it just takes longer. Pass `storage` to
|
|
132
|
+
* persist the output (the returned `video` then carries `fileId`). Throws
|
|
133
|
+
* {@link ContentGenerationHttpError} on a failed submit, or an `Error` if the result
|
|
134
|
+
* isn't ready within `timeoutMs`.
|
|
135
|
+
*/
|
|
136
|
+
export async function createVideo(input, transport = defaultTransport(), baseUrl = DEFAULT_BASE_URL) {
|
|
137
|
+
assertPrompt(input.prompt);
|
|
138
|
+
const path = modelToPath(input.model || DEFAULT_VIDEO_MODEL);
|
|
139
|
+
const body = {
|
|
140
|
+
prompt: input.prompt,
|
|
141
|
+
...input.params,
|
|
142
|
+
};
|
|
143
|
+
// Truthy check (not `!== undefined`) so `storage: null` is treated as "no storage".
|
|
144
|
+
if (input.storage)
|
|
145
|
+
body.storage = input.storage;
|
|
146
|
+
// Submit — for an async model Sapiom returns a queue handle, not the result.
|
|
147
|
+
const submitRes = await ensureOk(await transport.fetch(`${baseUrl}/run/${path}`, {
|
|
148
|
+
method: "POST",
|
|
149
|
+
headers: { "content-type": "application/json" },
|
|
150
|
+
body: JSON.stringify(body),
|
|
151
|
+
}), "Failed to submit video generation");
|
|
152
|
+
const handle = (await submitRes.json());
|
|
153
|
+
if (!handle.response_url) {
|
|
154
|
+
throw new Error("Video submit did not return a result URL to poll");
|
|
155
|
+
}
|
|
156
|
+
// Poll the result THROUGH Sapiom until it's ready. The poll is what persists the
|
|
157
|
+
// output when `storage` was requested, so `fileId` is filled in by the time it returns.
|
|
158
|
+
const intervalMs = input.pollIntervalMs ?? DEFAULT_VIDEO_POLL_INTERVAL_MS;
|
|
159
|
+
const timeoutMs = input.timeoutMs ?? DEFAULT_VIDEO_TIMEOUT_MS;
|
|
160
|
+
const deadline = Date.now() + timeoutMs;
|
|
161
|
+
while (Date.now() < deadline) {
|
|
162
|
+
const res = await transport.fetch(handle.response_url, { method: "GET" });
|
|
163
|
+
if (res.ok) {
|
|
164
|
+
const raw = (await res.json());
|
|
165
|
+
if (raw.video?.url)
|
|
166
|
+
return mapVideoResult(raw);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
// Still generating, or a transient error. Drain the unread body so the
|
|
170
|
+
// connection can be reused, then keep polling — `timeoutMs` is the backstop
|
|
171
|
+
// for a result that never arrives.
|
|
172
|
+
try {
|
|
173
|
+
await res.body?.cancel();
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
// best-effort drain
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
await sleep(intervalMs);
|
|
180
|
+
}
|
|
181
|
+
throw new Error(`Video generation did not complete within ${timeoutMs}ms (request id: ${handle.request_id ?? "unknown"})`);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Map a live, awaited {@link VideoGenerationResult} to the plain
|
|
185
|
+
* {@link VideoResultPayload} a resumed step receives across the wire boundary.
|
|
186
|
+
*/
|
|
187
|
+
export function toVideoResumePayload(result) {
|
|
188
|
+
if (!result.video)
|
|
189
|
+
return { outputs: [] };
|
|
190
|
+
return {
|
|
191
|
+
outputs: [
|
|
192
|
+
{
|
|
193
|
+
...(result.video.fileId !== undefined && {
|
|
194
|
+
fileId: result.video.fileId,
|
|
195
|
+
}),
|
|
196
|
+
...(result.video.storageError !== undefined && {
|
|
197
|
+
storageError: result.video.storageError,
|
|
198
|
+
}),
|
|
199
|
+
},
|
|
200
|
+
],
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Submit a video generation job and return a dispatchable handle immediately.
|
|
205
|
+
* The handle's `dispatch` member lets a workflow step pause until the video
|
|
206
|
+
* is ready; `handle.wait()` blocks inline instead — same as `video.create` but
|
|
207
|
+
* with the ability to suspend a running workflow.
|
|
208
|
+
*
|
|
209
|
+
* Pass `storage` to persist the output (the result then carries `fileId`).
|
|
210
|
+
* Throws {@link ContentGenerationHttpError} when the submit fails.
|
|
211
|
+
*/
|
|
212
|
+
export async function launchVideo(input, transport = defaultTransport(), baseUrl = DEFAULT_BASE_URL) {
|
|
213
|
+
assertPrompt(input.prompt);
|
|
214
|
+
const path = modelToPath(input.model || DEFAULT_VIDEO_MODEL);
|
|
215
|
+
const body = {
|
|
216
|
+
prompt: input.prompt,
|
|
217
|
+
...input.params,
|
|
218
|
+
};
|
|
219
|
+
if (input.storage)
|
|
220
|
+
body.storage = input.storage;
|
|
221
|
+
// Submit — includes the workflow resume token header so the service can resume
|
|
222
|
+
// the paused step when the job completes (no-op outside a workflow context).
|
|
223
|
+
const submitRes = await ensureOk(await transport.fetch(`${baseUrl}/run/${path}`, {
|
|
224
|
+
method: "POST",
|
|
225
|
+
headers: {
|
|
226
|
+
"content-type": "application/json",
|
|
227
|
+
...workflowResumeHeaders(transport.resumeToken),
|
|
228
|
+
},
|
|
229
|
+
body: JSON.stringify(body),
|
|
230
|
+
}), "Failed to submit video generation");
|
|
231
|
+
const handle = (await submitRes.json());
|
|
232
|
+
if (!handle.response_url) {
|
|
233
|
+
throw new Error("Video submit did not return a result URL to poll");
|
|
234
|
+
}
|
|
235
|
+
const requestId = handle.request_id ?? "unknown";
|
|
236
|
+
const responseUrl = handle.response_url;
|
|
237
|
+
const wait = async ({ timeoutMs = input.timeoutMs ?? DEFAULT_VIDEO_TIMEOUT_MS, pollMs = input.pollIntervalMs ?? DEFAULT_VIDEO_POLL_INTERVAL_MS, } = {}) => {
|
|
238
|
+
const deadline = Date.now() + timeoutMs;
|
|
239
|
+
while (Date.now() < deadline) {
|
|
240
|
+
const res = await transport.fetch(responseUrl, { method: "GET" });
|
|
241
|
+
if (res.ok) {
|
|
242
|
+
const raw = (await res.json());
|
|
243
|
+
if (raw.video?.url)
|
|
244
|
+
return mapVideoResult(raw);
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
try {
|
|
248
|
+
await res.body?.cancel();
|
|
249
|
+
}
|
|
250
|
+
catch {
|
|
251
|
+
// best-effort drain
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
await sleep(pollMs);
|
|
255
|
+
}
|
|
256
|
+
throw new Error(`Video generation did not complete within ${timeoutMs}ms (request id: ${requestId})`);
|
|
257
|
+
};
|
|
258
|
+
return {
|
|
259
|
+
requestId,
|
|
260
|
+
dispatch: { correlationId: requestId, resultSignal: VIDEO_RESULT_SIGNAL },
|
|
261
|
+
wait,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
/** The `video` sub-namespace: `contentGeneration.video.create(...)` and `contentGeneration.video.launch(...)`. */
|
|
265
|
+
export const video = { create: createVideo, launch: launchVideo };
|
|
73
266
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/content-generation/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/content-generation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAa,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAGnE,OAAO,EAAE,0BAA0B,EAAE,CAAC;AAEtC,MAAM,gBAAgB,GACpB,OAAO,CAAC,GAAG,CAAC,6BAA6B,IAAI,gCAAgC,CAAC;AAEhF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,gCAAgC,CAAC;AAEpE,qFAAqF;AACrF,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AA8ElD,SAAS,QAAQ,CAAC,GAAa;IAC7B,OAAO;QACL,GAAG,EAAE,GAAG,CAA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E,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC;gBACX,MAAM,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAmB,CAAC;gBACjD,IAAI,GAAG,CAAC,KAAK,EAAE,GAAG;oBAAE,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC;YACjD,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC;oBACH,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;gBAC3B,CAAC;gBAAC,MAAM,CAAC;oBACP,oBAAoB;gBACtB,CAAC;YACH,CAAC;YACD,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC;QACtB,CAAC;QACD,MAAM,IAAI,KAAK,CACb,4CAA4C,SAAS,mBAAmB,SAAS,GAAG,CACrF,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO;QACL,SAAS;QACT,QAAQ,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,mBAAmB,EAAE;QACzE,IAAI;KACL,CAAC;AACJ,CAAC;AAED,kHAAkH;AAClH,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
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,31 @@
|
|
|
1
|
+
/**
|
|
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 class DatabaseHttpError extends Error {
|
|
7
|
+
constructor(message, status, body) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "DatabaseHttpError";
|
|
10
|
+
this.status = status;
|
|
11
|
+
this.body = body;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Return the response when 2xx, otherwise throw a {@link DatabaseHttpError}.
|
|
16
|
+
* Parses the error body as JSON when possible; falls back to raw text.
|
|
17
|
+
*/
|
|
18
|
+
export async function ensureOk(response, errorPrefix) {
|
|
19
|
+
if (response.ok)
|
|
20
|
+
return response;
|
|
21
|
+
let body;
|
|
22
|
+
const text = await response.text().catch(() => "");
|
|
23
|
+
try {
|
|
24
|
+
body = JSON.parse(text);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
body = text;
|
|
28
|
+
}
|
|
29
|
+
throw new DatabaseHttpError(`${errorPrefix}: ${response.status} ${text}`, response.status, body);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/database/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,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;AAED;;;GAGG;AACH,MAAM,CAAC,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;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,SAAS,EAAoB,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAY,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAO7B,sEAAsE;AACtE,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC;AAElE,qCAAqC;AACrC,MAAM,MAAM,cAAc,GACtB,cAAc,GACd,QAAQ,GACR,SAAS,GACT,UAAU,GACV,SAAS,CAAC;AAEd,MAAM,WAAW,mBAAmB;IAClC,iFAAiF;IACjF,QAAQ,EAAE,gBAAgB,CAAC;IAC3B;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yEAAyE;IACzE,SAAS,CAAC,E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E,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,113 @@
|
|
|
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 { defaultTransport } from "../_client/index.js";
|
|
19
|
+
import { ensureOk, DatabaseHttpError } from "./errors.js";
|
|
20
|
+
export { DatabaseHttpError };
|
|
21
|
+
const DEFAULT_BASE_URL = process.env.SAPIOM_DATABASE_URL || "https://neon.services.sapiom.ai";
|
|
22
|
+
/**
|
|
23
|
+
* Break a Postgres connection URI into its parts. `connectionString` is always
|
|
24
|
+
* preserved (it is the value you pass to a client); the parsed components are a
|
|
25
|
+
* convenience. If the URI can't be parsed, only `connectionString` is returned.
|
|
26
|
+
*/
|
|
27
|
+
function parseConnectionUri(uri) {
|
|
28
|
+
try {
|
|
29
|
+
const u = new URL(uri);
|
|
30
|
+
return {
|
|
31
|
+
connectionString: uri,
|
|
32
|
+
host: u.hostname,
|
|
33
|
+
port: u.port ? Number(u.port) : 5432,
|
|
34
|
+
username: decodeURIComponent(u.username),
|
|
35
|
+
password: decodeURIComponent(u.password),
|
|
36
|
+
databaseName: u.pathname.replace(/^\//, ""),
|
|
37
|
+
sslmode: u.searchParams.get("sslmode") ?? undefined,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return { connectionString: uri };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function mapDatabase(raw) {
|
|
45
|
+
return {
|
|
46
|
+
id: raw.id,
|
|
47
|
+
handle: raw.handle,
|
|
48
|
+
name: raw.name,
|
|
49
|
+
description: raw.description,
|
|
50
|
+
status: raw.status,
|
|
51
|
+
region: raw.region,
|
|
52
|
+
pgVersion: raw.pgVersion,
|
|
53
|
+
duration: raw.duration,
|
|
54
|
+
connection: raw.connectionUri == null ? null : parseConnectionUri(raw.connectionUri),
|
|
55
|
+
expiresAt: raw.expiresAt,
|
|
56
|
+
createdAt: raw.createdAt,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
// ----- Capability operations -----
|
|
60
|
+
/**
|
|
61
|
+
* Provision a new Postgres database. `duration` is required. Returns the database
|
|
62
|
+
* with connection credentials in `connection`. Failed requests throw
|
|
63
|
+
* {@link DatabaseHttpError}.
|
|
64
|
+
*/
|
|
65
|
+
export async function create(input, transport = defaultTransport(), baseUrl = DEFAULT_BASE_URL) {
|
|
66
|
+
if (!input.duration) {
|
|
67
|
+
throw new DatabaseHttpError("duration is required", 400, {
|
|
68
|
+
message: "duration is required",
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
const body = { duration: input.duration };
|
|
72
|
+
if (input.handle !== undefined)
|
|
73
|
+
body.handle = input.handle;
|
|
74
|
+
if (input.name !== undefined)
|
|
75
|
+
body.name = input.name;
|
|
76
|
+
if (input.description !== undefined)
|
|
77
|
+
body.description = input.description;
|
|
78
|
+
if (input.region !== undefined)
|
|
79
|
+
body.region = input.region;
|
|
80
|
+
if (input.pgVersion !== undefined)
|
|
81
|
+
body.pgVersion = input.pgVersion;
|
|
82
|
+
const res = await ensureOk(await transport.fetch(`${baseUrl}/v1/databases`, {
|
|
83
|
+
method: "POST",
|
|
84
|
+
headers: { "content-type": "application/json" },
|
|
85
|
+
body: JSON.stringify(body),
|
|
86
|
+
}), "Failed to create database");
|
|
87
|
+
return mapDatabase((await res.json()));
|
|
88
|
+
}
|
|
89
|
+
/** Retrieve a database by its id or handle. */
|
|
90
|
+
export async function get(idOrHandle, transport = defaultTransport(), baseUrl = DEFAULT_BASE_URL) {
|
|
91
|
+
const res = await ensureOk(await transport.fetch(`${baseUrl}/v1/databases/${encodeURIComponent(idOrHandle)}`), `Failed to get database '${idOrHandle}'`);
|
|
92
|
+
return mapDatabase((await res.json()));
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Delete a database by its id or handle. Exported as `delete`:
|
|
96
|
+
* `import { database } from "@sapiom/tools"; await database.delete(id)`.
|
|
97
|
+
*/
|
|
98
|
+
async function deleteDatabase(idOrHandle, transport = defaultTransport(), baseUrl = DEFAULT_BASE_URL) {
|
|
99
|
+
const res = await transport.fetch(`${baseUrl}/v1/databases/${encodeURIComponent(idOrHandle)}`, { method: "DELETE" });
|
|
100
|
+
if (!res.ok) {
|
|
101
|
+
const text = await res.text().catch(() => "");
|
|
102
|
+
let parsed;
|
|
103
|
+
try {
|
|
104
|
+
parsed = JSON.parse(text);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
parsed = text;
|
|
108
|
+
}
|
|
109
|
+
throw new DatabaseHttpError(`Failed to delete database '${idOrHandle}': ${res.status} ${text}`, res.status, parsed);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
export { deleteDatabase as delete };
|
|
113
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -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,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC;QACD,MAAM,IAAI,iBAAiB,CACzB,8BAA8B,UAAU,MAAM,GAAG,CAAC,MAAM,IAAI,IAAI,EAAE,EAClE,GAAG,CAAC,MAAM,EACV,MAAM,CACP,CAAC;IACJ,CAAC;AACH,CAAC;AAED,OAAO,EAAE,cAAc,IAAI,MAAM,EAAE,CAAC"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -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
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -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,MAAM,oBAAoB,CAAC;AAIvE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,KAAK,YAAY,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGxD,YAAY,EACV,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,oCAAoC,GACrC,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,cAAc,MAAM,2BAA2B,CAAC;AAE5D,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAGzE,YAAY,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAE/E,OAAO,
|
|
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,MAAM,oBAAoB,CAAC;AAIvE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC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}
|
package/dist/esm/index.js
CHANGED
|
@@ -26,9 +26,17 @@ export * as orchestrations from "./orchestrations/index.js";
|
|
|
26
26
|
// Surfaced top-level for the static `pause: { signal }` decl on a workflow step.
|
|
27
27
|
export { ORCHESTRATIONS_RESULT_SIGNAL } from "./orchestrations/index.js";
|
|
28
28
|
// Validate an OrchestrationRunResultPayload at the resume boundary.
|
|
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
|
+
// Surfaced top-level for the static `pause: { signal }` decl on a workflow step.
|
|
35
|
+
export { VIDEO_RESULT_SIGNAL } from "./content-generation/index.js";
|
|
36
|
+
// Map a live VideoGenerationResult to the wire shape the resumed step receives.
|
|
37
|
+
export { toVideoResumePayload } from "./content-generation/index.js";
|
|
38
|
+
export * as search from "./search/index.js";
|
|
39
|
+
export { SearchHttpError } from "./search/index.js";
|
|
40
|
+
export * as database from "./database/index.js";
|
|
41
|
+
export { DatabaseHttpError } from "./database/index.js";
|
|
34
42
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAQhE,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,KAAK,YAAY,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAA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AAyB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,KAAK,iBAAiB,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,iFAAiF;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAIpE,gFAAgF;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -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"}
|