@sapiom/tools 0.7.0 → 0.8.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/CHANGELOG.md +35 -0
- package/README.md +10 -9
- package/dist/cjs/client.d.ts +28 -2
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +12 -0
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/content-generation/index.d.ts +64 -1
- package/dist/cjs/content-generation/index.d.ts.map +1 -1
- package/dist/cjs/content-generation/index.js +129 -5
- 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 +103 -0
- package/dist/cjs/database/index.d.ts.map +1 -0
- package/dist/cjs/database/index.js +120 -0
- package/dist/cjs/database/index.js.map +1 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +12 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/search/index.d.ts +132 -3
- package/dist/cjs/search/index.d.ts.map +1 -1
- package/dist/cjs/search/index.js +160 -3
- package/dist/cjs/search/index.js.map +1 -1
- package/dist/cjs/stub/index.d.ts.map +1 -1
- package/dist/cjs/stub/index.js +112 -2
- package/dist/cjs/stub/index.js.map +1 -1
- package/dist/esm/client.d.ts +28 -2
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +13 -1
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/content-generation/index.d.ts +64 -1
- package/dist/esm/content-generation/index.d.ts.map +1 -1
- package/dist/esm/content-generation/index.js +126 -4
- 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 +103 -0
- package/dist/esm/database/index.d.ts.map +1 -0
- package/dist/esm/database/index.js +115 -0
- package/dist/esm/database/index.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/search/index.d.ts +132 -3
- package/dist/esm/search/index.d.ts.map +1 -1
- package/dist/esm/search/index.js +157 -3
- package/dist/esm/search/index.js.map +1 -1
- package/dist/esm/stub/index.d.ts.map +1 -1
- package/dist/esm/stub/index.js +112 -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 +6 -1
- package/src/content-generation/README.md +67 -0
- package/src/database/README.md +62 -0
- package/src/search/README.md +130 -1
|
@@ -12,10 +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 { Transport } from "../_client/index.js";
|
|
17
23
|
import { ContentGenerationHttpError } from "./errors.js";
|
|
24
|
+
import type { DispatchHandle } from "../dispatch.js";
|
|
18
25
|
export { ContentGenerationHttpError };
|
|
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 declare const VIDEO_RESULT_SIGNAL = "contentGeneration.video.result";
|
|
19
33
|
export interface StorageOptions {
|
|
20
34
|
/**
|
|
21
35
|
* Visibility of the persisted output.
|
|
@@ -132,8 +146,57 @@ export interface VideoGenerationResult {
|
|
|
132
146
|
* isn't ready within `timeoutMs`.
|
|
133
147
|
*/
|
|
134
148
|
export declare function createVideo(input: VideoCreateInput, transport?: Transport, baseUrl?: string): Promise<VideoGenerationResult>;
|
|
135
|
-
/**
|
|
149
|
+
/**
|
|
150
|
+
* A launched-but-not-awaited video generation job. Satisfies {@link DispatchHandle},
|
|
151
|
+
* so it can be handed straight to `pauseUntilSignal(handle, { resumeStep })` to
|
|
152
|
+
* suspend a workflow step until the video is ready — or `wait()`-ed inline for
|
|
153
|
+
* standalone use (same as `video.create`, but with the dispatchable surface).
|
|
154
|
+
*/
|
|
155
|
+
export interface VideoLaunchHandle extends DispatchHandle {
|
|
156
|
+
/** The queue request id for this job. */
|
|
157
|
+
requestId: string;
|
|
158
|
+
/** Poll to completion and resolve the full result. */
|
|
159
|
+
wait(opts?: {
|
|
160
|
+
timeoutMs?: number;
|
|
161
|
+
pollMs?: number;
|
|
162
|
+
}): Promise<VideoGenerationResult>;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* The video job's terminal result as it arrives at a step **resumed** from
|
|
166
|
+
* `pauseUntilSignal(launchHandle, { resumeStep })`. It crossed a wire boundary,
|
|
167
|
+
* so the shape is plain JSON. Annotate a resumed step's input with this type.
|
|
168
|
+
*
|
|
169
|
+
* const finalize = defineStep({
|
|
170
|
+
* name: "finalize", terminal: true,
|
|
171
|
+
* async run(result: VideoResultPayload, ctx) { … },
|
|
172
|
+
* });
|
|
173
|
+
*/
|
|
174
|
+
export interface VideoResultPayload {
|
|
175
|
+
outputs: Array<{
|
|
176
|
+
/** Present when the output was persisted to file storage. */
|
|
177
|
+
fileId?: string;
|
|
178
|
+
/** Present when storage was requested but persisting this output failed. */
|
|
179
|
+
storageError?: string;
|
|
180
|
+
}>;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Map a live, awaited {@link VideoGenerationResult} to the plain
|
|
184
|
+
* {@link VideoResultPayload} a resumed step receives across the wire boundary.
|
|
185
|
+
*/
|
|
186
|
+
export declare function toVideoResumePayload(result: VideoGenerationResult): VideoResultPayload;
|
|
187
|
+
/**
|
|
188
|
+
* Submit a video generation job and return a dispatchable handle immediately.
|
|
189
|
+
* The handle's `dispatch` member lets a workflow step pause until the video
|
|
190
|
+
* is ready; `handle.wait()` blocks inline instead — same as `video.create` but
|
|
191
|
+
* with the ability to suspend a running workflow.
|
|
192
|
+
*
|
|
193
|
+
* Pass `storage` to persist the output (the result then carries `fileId`).
|
|
194
|
+
* Throws {@link ContentGenerationHttpError} when the submit fails.
|
|
195
|
+
*/
|
|
196
|
+
export declare function launchVideo(input: VideoCreateInput, transport?: Transport, baseUrl?: string): Promise<VideoLaunchHandle>;
|
|
197
|
+
/** The `video` sub-namespace: `contentGeneration.video.create(...)` and `contentGeneration.video.launch(...)`. */
|
|
136
198
|
export declare const video: {
|
|
137
199
|
create: typeof createVideo;
|
|
200
|
+
launch: typeof launchVideo;
|
|
138
201
|
};
|
|
139
202
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,SAAS,EAAoB,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAY,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,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C;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"}
|
|
@@ -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,
|
|
@@ -85,7 +120,9 @@ function mapVideo(raw) {
|
|
|
85
120
|
}
|
|
86
121
|
function mapVideoResult(raw) {
|
|
87
122
|
const { video, ...rest } = raw;
|
|
88
|
-
return video === undefined
|
|
123
|
+
return video === undefined
|
|
124
|
+
? { ...rest }
|
|
125
|
+
: { ...rest, video: mapVideo(video) };
|
|
89
126
|
}
|
|
90
127
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
91
128
|
/**
|
|
@@ -97,8 +134,12 @@ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
|
97
134
|
* isn't ready within `timeoutMs`.
|
|
98
135
|
*/
|
|
99
136
|
export async function createVideo(input, transport = defaultTransport(), baseUrl = DEFAULT_BASE_URL) {
|
|
137
|
+
assertPrompt(input.prompt);
|
|
100
138
|
const path = modelToPath(input.model || DEFAULT_VIDEO_MODEL);
|
|
101
|
-
const body = {
|
|
139
|
+
const body = {
|
|
140
|
+
prompt: input.prompt,
|
|
141
|
+
...input.params,
|
|
142
|
+
};
|
|
102
143
|
// Truthy check (not `!== undefined`) so `storage: null` is treated as "no storage".
|
|
103
144
|
if (input.storage)
|
|
104
145
|
body.storage = input.storage;
|
|
@@ -139,6 +180,87 @@ export async function createVideo(input, transport = defaultTransport(), baseUrl
|
|
|
139
180
|
}
|
|
140
181
|
throw new Error(`Video generation did not complete within ${timeoutMs}ms (request id: ${handle.request_id ?? "unknown"})`);
|
|
141
182
|
}
|
|
142
|
-
/**
|
|
143
|
-
|
|
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 };
|
|
144
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,gB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7D,EAAE,EAAkC,EAAE;QACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;QACxC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;YAC7B,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;YAClE,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,103 @@
|
|
|
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
|
+
/** The set of valid database lifetimes, in ascending order. */
|
|
22
|
+
export declare const DATABASE_DURATIONS: readonly ["15m", "1h", "4h", "24h", "7d"];
|
|
23
|
+
/** How long the database lives before it is automatically removed. */
|
|
24
|
+
export type DatabaseDuration = (typeof DATABASE_DURATIONS)[number];
|
|
25
|
+
/** Lifecycle state of a database. */
|
|
26
|
+
export type DatabaseStatus = "provisioning" | "active" | "expired" | "deleting" | "deleted";
|
|
27
|
+
export interface CreateDatabaseInput {
|
|
28
|
+
/** How long the database lives before it is automatically removed (required). */
|
|
29
|
+
duration: DatabaseDuration;
|
|
30
|
+
/**
|
|
31
|
+
* Optional stable, human-friendly key you can use to look the database up later
|
|
32
|
+
* (`get(handle)` / `delete(handle)`). 3–63 chars, `^[a-z0-9][a-z0-9-]*[a-z0-9]$`.
|
|
33
|
+
* Unique within your tenant.
|
|
34
|
+
*/
|
|
35
|
+
handle?: string;
|
|
36
|
+
/** Optional display name. */
|
|
37
|
+
name?: string;
|
|
38
|
+
/** Optional description (up to 500 chars). */
|
|
39
|
+
description?: string;
|
|
40
|
+
/** Optional region to provision in. Defaults to a US region. */
|
|
41
|
+
region?: string;
|
|
42
|
+
/** Optional Postgres major version. Defaults to the latest supported. */
|
|
43
|
+
pgVersion?: 15 | 16 | 17;
|
|
44
|
+
}
|
|
45
|
+
export interface DatabaseConnection {
|
|
46
|
+
/**
|
|
47
|
+
* The full Postgres connection URI — pass this to any Postgres client. This is
|
|
48
|
+
* the canonical value and is always present; the component fields below are
|
|
49
|
+
* parsed from it on a best-effort basis and may be absent if it can't be parsed.
|
|
50
|
+
*/
|
|
51
|
+
connectionString: string;
|
|
52
|
+
/** Database host. */
|
|
53
|
+
host?: string;
|
|
54
|
+
/** Database port. */
|
|
55
|
+
port?: number;
|
|
56
|
+
/** Database user. */
|
|
57
|
+
username?: string;
|
|
58
|
+
/** Database password. */
|
|
59
|
+
password?: string;
|
|
60
|
+
/** Name of the database to connect to. */
|
|
61
|
+
databaseName?: string;
|
|
62
|
+
/** SSL mode from the connection URI, when present (e.g. "require"). */
|
|
63
|
+
sslmode?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface Database {
|
|
66
|
+
/** Unique database identifier. */
|
|
67
|
+
id: string;
|
|
68
|
+
/** The handle you set at creation, or `null` if none was given. */
|
|
69
|
+
handle: string | null;
|
|
70
|
+
/** Display name, or `null`. */
|
|
71
|
+
name: string | null;
|
|
72
|
+
/** Description, or `null`. */
|
|
73
|
+
description: string | null;
|
|
74
|
+
/** Lifecycle state. */
|
|
75
|
+
status: DatabaseStatus;
|
|
76
|
+
/** Region the database is provisioned in. */
|
|
77
|
+
region: string;
|
|
78
|
+
/** Postgres major version. */
|
|
79
|
+
pgVersion: number;
|
|
80
|
+
/** The lifetime the database was created with. */
|
|
81
|
+
duration: DatabaseDuration | string;
|
|
82
|
+
/** Connection credentials — `null` while the database is still being provisioned. */
|
|
83
|
+
connection: DatabaseConnection | null;
|
|
84
|
+
/** ISO-8601 timestamp when the database expires, or `null`. */
|
|
85
|
+
expiresAt: string | null;
|
|
86
|
+
/** ISO-8601 timestamp when the database was created. */
|
|
87
|
+
createdAt: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Provision a new Postgres database. `duration` is required. Returns the database
|
|
91
|
+
* with connection credentials in `connection`. Failed requests throw
|
|
92
|
+
* {@link DatabaseHttpError}.
|
|
93
|
+
*/
|
|
94
|
+
export declare function create(input: CreateDatabaseInput, transport?: Transport, baseUrl?: string): Promise<Database>;
|
|
95
|
+
/** Retrieve a database by its id or handle. */
|
|
96
|
+
export declare function get(idOrHandle: string, transport?: Transport, baseUrl?: string): Promise<Database>;
|
|
97
|
+
/**
|
|
98
|
+
* Delete a database by its id or handle. Exported as `delete`:
|
|
99
|
+
* `import { database } from "@sapiom/tools"; await database.delete(id)`.
|
|
100
|
+
*/
|
|
101
|
+
declare function deleteDatabase(idOrHandle: string, transport?: Transport, baseUrl?: string): Promise<void>;
|
|
102
|
+
export { deleteDatabase as delete };
|
|
103
|
+
//# 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,+DAA+D;AAC/D,eAAO,MAAM,kBAAkB,2CAA4C,CAAC;AAE5E,sEAAsE;AACtE,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE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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,CA4BnB;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,115 @@
|
|
|
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
|
+
// ----- Types -----
|
|
23
|
+
/** The set of valid database lifetimes, in ascending order. */
|
|
24
|
+
export const DATABASE_DURATIONS = ["15m", "1h", "4h", "24h", "7d"];
|
|
25
|
+
/**
|
|
26
|
+
* Break a Postgres connection URI into its parts. `connectionString` is always
|
|
27
|
+
* preserved (it is the value you pass to a client); the parsed components are a
|
|
28
|
+
* convenience. If the URI can't be parsed, only `connectionString` is returned.
|
|
29
|
+
*/
|
|
30
|
+
function parseConnectionUri(uri) {
|
|
31
|
+
try {
|
|
32
|
+
const u = new URL(uri);
|
|
33
|
+
return {
|
|
34
|
+
connectionString: uri,
|
|
35
|
+
host: u.hostname,
|
|
36
|
+
port: u.port ? Number(u.port) : 5432,
|
|
37
|
+
username: decodeURIComponent(u.username),
|
|
38
|
+
password: decodeURIComponent(u.password),
|
|
39
|
+
databaseName: u.pathname.replace(/^\//, ""),
|
|
40
|
+
sslmode: u.searchParams.get("sslmode") ?? undefined,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return { connectionString: uri };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function mapDatabase(raw) {
|
|
48
|
+
return {
|
|
49
|
+
id: raw.id,
|
|
50
|
+
handle: raw.handle,
|
|
51
|
+
name: raw.name,
|
|
52
|
+
description: raw.description,
|
|
53
|
+
status: raw.status,
|
|
54
|
+
region: raw.region,
|
|
55
|
+
pgVersion: raw.pgVersion,
|
|
56
|
+
duration: raw.duration,
|
|
57
|
+
connection: raw.connectionUri == null ? null : parseConnectionUri(raw.connectionUri),
|
|
58
|
+
expiresAt: raw.expiresAt,
|
|
59
|
+
createdAt: raw.createdAt,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
// ----- Capability operations -----
|
|
63
|
+
/**
|
|
64
|
+
* Provision a new Postgres database. `duration` is required. Returns the database
|
|
65
|
+
* with connection credentials in `connection`. Failed requests throw
|
|
66
|
+
* {@link DatabaseHttpError}.
|
|
67
|
+
*/
|
|
68
|
+
export async function create(input, transport = defaultTransport(), baseUrl = DEFAULT_BASE_URL) {
|
|
69
|
+
if (!input?.duration ||
|
|
70
|
+
!DATABASE_DURATIONS.includes(input.duration)) {
|
|
71
|
+
throw new DatabaseHttpError("duration must be one of: 15m, 1h, 4h, 24h, 7d", 400, { duration: input?.duration });
|
|
72
|
+
}
|
|
73
|
+
const body = { duration: input.duration };
|
|
74
|
+
if (input.handle !== undefined)
|
|
75
|
+
body.handle = input.handle;
|
|
76
|
+
if (input.name !== undefined)
|
|
77
|
+
body.name = input.name;
|
|
78
|
+
if (input.description !== undefined)
|
|
79
|
+
body.description = input.description;
|
|
80
|
+
if (input.region !== undefined)
|
|
81
|
+
body.region = input.region;
|
|
82
|
+
if (input.pgVersion !== undefined)
|
|
83
|
+
body.pgVersion = input.pgVersion;
|
|
84
|
+
const res = await ensureOk(await transport.fetch(`${baseUrl}/v1/databases`, {
|
|
85
|
+
method: "POST",
|
|
86
|
+
headers: { "content-type": "application/json" },
|
|
87
|
+
body: JSON.stringify(body),
|
|
88
|
+
}), "Failed to create database");
|
|
89
|
+
return mapDatabase((await res.json()));
|
|
90
|
+
}
|
|
91
|
+
/** Retrieve a database by its id or handle. */
|
|
92
|
+
export async function get(idOrHandle, transport = defaultTransport(), baseUrl = DEFAULT_BASE_URL) {
|
|
93
|
+
const res = await ensureOk(await transport.fetch(`${baseUrl}/v1/databases/${encodeURIComponent(idOrHandle)}`), `Failed to get database '${idOrHandle}'`);
|
|
94
|
+
return mapDatabase((await res.json()));
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Delete a database by its id or handle. Exported as `delete`:
|
|
98
|
+
* `import { database } from "@sapiom/tools"; await database.delete(id)`.
|
|
99
|
+
*/
|
|
100
|
+
async function deleteDatabase(idOrHandle, transport = defaultTransport(), baseUrl = DEFAULT_BASE_URL) {
|
|
101
|
+
const res = await transport.fetch(`${baseUrl}/v1/databases/${encodeURIComponent(idOrHandle)}`, { method: "DELETE" });
|
|
102
|
+
if (!res.ok) {
|
|
103
|
+
const text = await res.text().catch(() => "");
|
|
104
|
+
let parsed;
|
|
105
|
+
try {
|
|
106
|
+
parsed = JSON.parse(text);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
parsed = text;
|
|
110
|
+
}
|
|
111
|
+
throw new DatabaseHttpError(`Failed to delete database '${idOrHandle}': ${res.status} ${text}`, res.status, parsed);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
export { deleteDatabase as delete };
|
|
115
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/database/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAa,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B,MAAM,gBAAgB,GACpB,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,iCAAiC,CAAC;AAEvE,oBAAoB;AAEpB,+DAA+D;AAC/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAU,CAAC;AAuG5E;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,GAAW;IACrC,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACvB,OAAO;YACL,gBAAgB,EAAE,GA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AClB,YAAuB,gBAAgB,EAAE,EACzC,OAAO,GAAG,gBAAgB;IAE1B,MAAM,GAAG,GAAG,MAAM,QAAQ,CACxB,MAAM,SAAS,CAAC,KAAK,CACnB,GAAG,OAAO,iBAAiB,kBAAkB,CAAC,UAAU,CAAC,EAAE,CAC5D,EACD,2BAA2B,UAAU,GAAG,CACzC,CAAC;IACF,OAAO,WAAW,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAwB,CAAC,CAAC;AAChE,CAAC;AAED;;;GAGG;AACH,KAAK,UAAU,cAAc,CAC3B,UAAkB,EAClB,YAAuB,gBAAgB,EAAE,EACzC,OAAO,GAAG,gBAAgB;IAE1B,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,KAAK,CAC/B,GAAG,OAAO,iBAAiB,kBAAkB,CAAC,UAAU,CAAC,EAAE,EAC3D,EAAE,MAAM,EAAE,QAAQ,EAAE,CACrB,CAAC;IACF,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QAC9C,IAAI,MAAe,CAAC;QACpB,IAAI,CAAC;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,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
|
@@ -31,6 +31,11 @@ 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";
|
|
34
37
|
export * as search from "./search/index.js";
|
|
35
38
|
export { SearchHttpError } from "./search/index.js";
|
|
39
|
+
export * as database from "./database/index.js";
|
|
40
|
+
export { DatabaseHttpError } from "./database/index.js";
|
|
36
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,c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e,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,EACL,yBAAyB,EACzB,8BAA8B,GAC/B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,WAAW,MAAM,yBAAyB,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;AAE3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAGpE,YAAY,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAExE,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"}
|
package/dist/esm/index.js
CHANGED
|
@@ -31,6 +31,12 @@ 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";
|
|
34
38
|
export * as search from "./search/index.js";
|
|
35
39
|
export { SearchHttpError } from "./search/index.js";
|
|
40
|
+
export * as database from "./database/index.js";
|
|
41
|
+
export { DatabaseHttpError } from "./database/index.js";
|
|
36
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,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,iFAAiF;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAOxD,+EAA+E;AAC/E,2CAA2C;AAC3C,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,oCAAoC,GACrC,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,cAAc,MAAM,2BAA2B,CAAC;AAC5D,iFAAiF;AACjF,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAIzE,oEAAoE;AACpE,OAAO,EACL,yBAAyB,EACzB,8BAA8B,GAC/B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,WAAW,MAAM,yBAAyB,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;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],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