@slopmachine/core 0.2.0 → 0.3.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 +6 -0
- package/dist/index.d.mts +5 -6
- package/dist/index.d.ts +5 -6
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +6 -7
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -219,7 +219,7 @@ interface SlopVideoOptions {
|
|
|
219
219
|
variables?: Record<string, string | number | undefined | null>;
|
|
220
220
|
/**
|
|
221
221
|
* The duration of the generated video in seconds.
|
|
222
|
-
*
|
|
222
|
+
* If not specified, defaults to the bucket version's configured duration (or 4).
|
|
223
223
|
*/
|
|
224
224
|
duration?: number;
|
|
225
225
|
/**
|
|
@@ -234,18 +234,17 @@ interface SlopVideoOptions {
|
|
|
234
234
|
*/
|
|
235
235
|
baseUrl?: string;
|
|
236
236
|
/**
|
|
237
|
-
* If
|
|
238
|
-
* Defaults to false.
|
|
237
|
+
* If true, serves the original generated uncompressed asset directly from storage.
|
|
239
238
|
*/
|
|
240
239
|
original?: boolean;
|
|
241
240
|
/**
|
|
242
|
-
* Array of
|
|
241
|
+
* Array of runtime image attachments (URLs) to use with the video model.
|
|
242
|
+
* Only allowed if the bucket version has runtime attachments enabled.
|
|
243
243
|
*/
|
|
244
244
|
attachments?: string[];
|
|
245
245
|
}
|
|
246
246
|
/**
|
|
247
|
-
* Builds
|
|
248
|
-
*
|
|
247
|
+
* Builds the URL to render or stream an AI-generated video.
|
|
249
248
|
* Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).
|
|
250
249
|
*
|
|
251
250
|
* @param options - Configuration options for the video generation.
|
package/dist/index.d.ts
CHANGED
|
@@ -219,7 +219,7 @@ interface SlopVideoOptions {
|
|
|
219
219
|
variables?: Record<string, string | number | undefined | null>;
|
|
220
220
|
/**
|
|
221
221
|
* The duration of the generated video in seconds.
|
|
222
|
-
*
|
|
222
|
+
* If not specified, defaults to the bucket version's configured duration (or 4).
|
|
223
223
|
*/
|
|
224
224
|
duration?: number;
|
|
225
225
|
/**
|
|
@@ -234,18 +234,17 @@ interface SlopVideoOptions {
|
|
|
234
234
|
*/
|
|
235
235
|
baseUrl?: string;
|
|
236
236
|
/**
|
|
237
|
-
* If
|
|
238
|
-
* Defaults to false.
|
|
237
|
+
* If true, serves the original generated uncompressed asset directly from storage.
|
|
239
238
|
*/
|
|
240
239
|
original?: boolean;
|
|
241
240
|
/**
|
|
242
|
-
* Array of
|
|
241
|
+
* Array of runtime image attachments (URLs) to use with the video model.
|
|
242
|
+
* Only allowed if the bucket version has runtime attachments enabled.
|
|
243
243
|
*/
|
|
244
244
|
attachments?: string[];
|
|
245
245
|
}
|
|
246
246
|
/**
|
|
247
|
-
* Builds
|
|
248
|
-
*
|
|
247
|
+
* Builds the URL to render or stream an AI-generated video.
|
|
249
248
|
* Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).
|
|
250
249
|
*
|
|
251
250
|
* @param options - Configuration options for the video generation.
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { AspectRatio as ImageAspectRatio, VideoAspectRatio } from \"@pixerate/schemas\";\nexport type { ImageAspectRatio, VideoAspectRatio };\n\nexport interface PipelineStepResult {\n stepId: string;\n stepName?: string;\n type: string;\n outputUrl?: string;\n outputText?: string;\n outputData?: any;\n computeTimeMs?: number;\n fuelCost?: number;\n error?: string;\n}\n\nexport interface PipelineResult {\n id: string;\n pipelineId: string;\n siloId: string;\n url?: string;\n text?: string;\n data?: any;\n resultType: string;\n status: \"completed\" | \"failed\" | \"pending\";\n stepResults: PipelineStepResult[];\n totalComputeTimeMs: number;\n totalFuelCost: number;\n metadata?: Record<string, any>;\n timestamp: any;\n error?: string;\n}\n\nexport interface SlopPipelineOptions {\n /**\n * The unique identifier of the pipeline to execute.\n */\n pipelineId: string;\n /**\n * Optional silo identifier for direct pipeline path resolution.\n */\n siloId?: string;\n /**\n * Dynamic runtime prompt to feed into the pipeline.\n */\n prompt?: string;\n /**\n * Variables to interpolate into prompt or step configs.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * Arbitrary user metadata to attach to the pipeline result document.\n */\n metadata?: Record<string, any>;\n /**\n * Whether to wait for full execution (default true) or return a job ID immediately.\n */\n sync?: boolean;\n /**\n * Whether to redirect to the primary media output URL upon completion.\n */\n redirect?: boolean;\n /**\n * Result ID to retrieve a specific previously generated result.\n */\n resultId?: string;\n /**\n * Base URL for the renderPipeline cloud function endpoint.\n */\n baseUrl?: string;\n}\n\nexport interface ExecutePipelineOptions {\n /**\n * The unique identifier of the pipeline to execute.\n */\n pipelineId: string;\n /**\n * Optional silo identifier for direct pipeline path resolution.\n */\n siloId?: string;\n /**\n * Dynamic runtime prompt to feed into the pipeline.\n */\n prompt?: string;\n /**\n * Variables to interpolate into prompt or step configs.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * Arbitrary user metadata to attach to the pipeline result document.\n */\n metadata?: Record<string, any>;\n /**\n * Base URL for the renderPipeline cloud function endpoint.\n */\n baseUrl?: string;\n}\n\nexport interface SlopImageOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n * Required when using a bucket unless pipelineId is provided.\n */\n bucketId?: string;\n /**\n * The unique identifier of your Slop Machine pipeline.\n * Required when targeting a pipeline instead of a bucket.\n */\n pipelineId?: string;\n /**\n * Optional silo identifier.\n */\n siloId?: string;\n /**\n * Dynamic runtime prompt (used when targeting a pipeline).\n */\n prompt?: string;\n /**\n * Arbitrary user metadata to attach to the generation request / result document.\n */\n metadata?: Record<string, any>;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated image\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated image. Defaults to \"1:1\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: ImageAspectRatio;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A photo of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The target quality (\"fast\" or \"high\"). Only affects new generations and is ignored for caching.\n * Ignored if `model` is provided.\n * Defaults to \"fast\".\n */\n quality?: \"fast\" | \"high\";\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n /**\n * If `true` (or `?raw=true`), bypasses the WebP optimized media and returns the original generated file (e.g., PNG/JPEG).\n * Defaults to false.\n */\n original?: boolean;\n /**\n * Array of attachment URLs to include with the request.\n */\n attachments?: string[];\n}\n\nexport function interpolatePrompt(\n prompt?: string,\n variables?: Record<string, string | number | undefined | null>,\n): string {\n if (!prompt) return \"\";\n let text = prompt;\n if (!variables) return text;\n\n Object.keys(variables).forEach((key) => {\n const value = variables[key];\n if (value !== undefined && value !== null) {\n text = text.replace(new RegExp(`\\\\{${key}\\\\}`, \"g\"), String(value));\n }\n });\n return text;\n}\n\n/**\n * Builds a URL to render or retrieve an image from Slop Machine.\n *\n * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).\n *\n * @param options - Configuration options for the image generation.\n * @returns A string containing the fully constructed URL.\n */\nexport function buildImageUrl(options: SlopImageOptions): string {\n const {\n bucketId,\n pipelineId,\n siloId,\n prompt,\n metadata,\n version,\n resultId,\n aspectRatio = \"1:1\",\n quality = \"fast\",\n variables = {},\n baseUrl,\n original,\n attachments,\n } = options;\n\n if (pipelineId) {\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderPipeline\";\n const params = new URLSearchParams();\n params.set(\"pipelineId\", pipelineId);\n params.set(\"redirect\", \"true\");\n\n if (siloId) params.set(\"siloId\", siloId);\n if (prompt) params.set(\"prompt\", prompt);\n if (resultId) params.set(\"resultId\", resultId);\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n return `${endpoint}?${params.toString()}`;\n }\n\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage\";\n const params = new URLSearchParams();\n if (bucketId) {\n params.set(\"bucketId\", bucketId);\n }\n\n if (!resultId) {\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (quality && quality !== \"fast\") {\n params.set(\"quality\", quality);\n } else if (quality === \"fast\") {\n params.set(\"quality\", \"fast\");\n }\n\n if (original) {\n params.set(\"original\", \"true\");\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n if (attachments && attachments.length > 0) {\n params.set(\"attachments\", JSON.stringify(attachments));\n }\n } else {\n params.set(\"resultId\", resultId);\n }\n\n return `${endpoint}?${params.toString()}`;\n}\n\n/**\n * Preloads an image from Slop Machine into the browser's cache.\n * Useful for ensuring images are ready before displaying them.\n *\n * @param options - Configuration options for the image generation.\n * @returns A promise that resolves when the image has been loaded.\n */\nexport function preloadImage(options: SlopImageOptions): Promise<void> {\n return new Promise((resolve, reject) => {\n if (typeof window === \"undefined\") {\n resolve();\n return;\n }\n\n const img = new Image();\n img.onload = () => resolve();\n img.onerror = (err) => reject(err);\n img.src = buildImageUrl(options);\n });\n}\n\nexport interface SlopVideoOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n * Required when using a bucket unless pipelineId is provided.\n */\n bucketId?: string;\n /**\n * The unique identifier of your Slop Machine pipeline.\n * Required when targeting a pipeline instead of a bucket.\n */\n pipelineId?: string;\n /**\n * Optional silo identifier.\n */\n siloId?: string;\n /**\n * Dynamic runtime prompt (used when targeting a pipeline).\n */\n prompt?: string;\n /**\n * Arbitrary user metadata to attach to the generation request / result document.\n */\n metadata?: Record<string, any>;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated video\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated video. Defaults to \"16:9\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: VideoAspectRatio;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A video of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The duration of the generated video in seconds.\n * Must be between 4 and 8. Defaults to 4.\n */\n duration?: number;\n /**\n * The target quality (\"fast\" or \"high\"). Only affects new generations and is ignored for caching.\n * Ignored if `model` is provided.\n * Defaults to \"fast\".\n */\n quality?: \"fast\" | \"high\";\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n /**\n * If `true` (or `?raw=true`), bypasses the WebP optimized media and returns the original generated file.\n * Defaults to false.\n */\n original?: boolean;\n /**\n * Array of attachment URLs to include with the request.\n */\n attachments?: string[];\n}\n\n/**\n * Builds a URL to render or retrieve a video from Slop Machine.\n *\n * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).\n *\n * @param options - Configuration options for the video generation.\n * @returns A string containing the fully constructed URL.\n */\nexport function buildVideoUrl(options: SlopVideoOptions): string {\n const {\n bucketId,\n pipelineId,\n siloId,\n prompt,\n metadata,\n version,\n resultId,\n aspectRatio = \"16:9\",\n quality = \"fast\",\n variables = {},\n duration = 4,\n baseUrl,\n original,\n attachments,\n } = options;\n\n if (pipelineId) {\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderPipeline\";\n const params = new URLSearchParams();\n params.set(\"pipelineId\", pipelineId);\n params.set(\"redirect\", \"true\");\n\n if (siloId) params.set(\"siloId\", siloId);\n if (prompt) params.set(\"prompt\", prompt);\n if (resultId) params.set(\"resultId\", resultId);\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n return `${endpoint}?${params.toString()}`;\n }\n\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderVideo\";\n const params = new URLSearchParams();\n if (bucketId) {\n params.set(\"bucketId\", bucketId);\n }\n\n if (!resultId) {\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (duration) {\n params.set(\"duration\", String(duration));\n }\n if (quality) {\n params.set(\"quality\", quality);\n }\n\n if (original) {\n params.set(\"original\", \"true\");\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n if (attachments && attachments.length > 0) {\n params.set(\"attachments\", JSON.stringify(attachments));\n }\n } else {\n params.set(\"resultId\", resultId);\n }\n\n return `${endpoint}?${params.toString()}`;\n}\n\n/**\n * Preloads a video from Slop Machine into the browser's cache.\n * Useful for ensuring videos are ready before displaying them.\n *\n * @param options - Configuration options for the video generation.\n * @returns A promise that resolves when the video preload request has been initiated.\n */\nexport function preloadVideo(options: SlopVideoOptions): Promise<void> {\n return new Promise((resolve, reject) => {\n if (typeof window === \"undefined\") {\n resolve();\n return;\n }\n\n fetch(buildVideoUrl(options), { mode: \"no-cors\" })\n .then(() => resolve())\n .catch((err) => reject(err));\n });\n}\n\nexport interface SlopTextOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n * Required when using a bucket unless pipelineId is provided.\n */\n bucketId?: string;\n /**\n * The unique identifier of your Slop Machine pipeline.\n * Required when targeting a pipeline instead of a bucket.\n */\n pipelineId?: string;\n /**\n * Optional silo identifier.\n */\n siloId?: string;\n /**\n * Dynamic runtime prompt (used when targeting a pipeline).\n */\n prompt?: string;\n /**\n * Arbitrary user metadata to attach to the generation request / result document.\n */\n metadata?: Record<string, any>;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated text\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A story about a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n /**\n * Array of attachment URLs to include with the request.\n */\n attachments?: string[];\n}\n\n/**\n * Builds a URL to render or retrieve text from Slop Machine.\n *\n * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).\n *\n * @param options - Configuration options for the text generation.\n * @returns A string containing the fully constructed URL.\n */\nexport function buildTextUrl(options: SlopTextOptions): string {\n const {\n bucketId,\n pipelineId,\n siloId,\n prompt,\n metadata,\n version,\n resultId,\n variables = {},\n baseUrl,\n attachments,\n } = options;\n\n if (pipelineId) {\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderPipeline\";\n const params = new URLSearchParams();\n params.set(\"pipelineId\", pipelineId);\n params.set(\"sync\", \"true\");\n\n if (siloId) params.set(\"siloId\", siloId);\n if (prompt) params.set(\"prompt\", prompt);\n if (resultId) params.set(\"resultId\", resultId);\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n return `${endpoint}?${params.toString()}`;\n }\n\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderText\";\n const params = new URLSearchParams();\n if (bucketId) {\n params.set(\"bucketId\", bucketId);\n }\n\n if (!resultId) {\n if (version) {\n params.set(\"version\", String(version));\n }\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n if (attachments && attachments.length > 0) {\n params.set(\"attachments\", JSON.stringify(attachments));\n }\n } else {\n params.set(\"resultId\", resultId);\n }\n\n return `${endpoint}?${params.toString()}`;\n}\n\n/**\n * Preloads text from Slop Machine into the browser's cache.\n * Useful for ensuring text is ready before displaying it.\n *\n * @param options - Configuration options for the text generation.\n * @returns A promise that resolves when the text preload request has been initiated.\n */\nexport function preloadText(options: SlopTextOptions): Promise<void> {\n return new Promise((resolve, reject) => {\n if (typeof window === \"undefined\") {\n resolve();\n return;\n }\n\n fetch(buildTextUrl(options), { mode: \"no-cors\" })\n .then(() => resolve())\n .catch((err) => reject(err));\n });\n}\n\n/**\n * Builds a URL to execute or inspect a multi-step Pipeline from Slop Machine.\n *\n * @param options - Configuration options for the pipeline execution.\n * @returns A string containing the fully constructed URL.\n */\nexport function buildPipelineUrl(options: SlopPipelineOptions): string {\n const {\n pipelineId,\n siloId,\n prompt,\n variables = {},\n metadata = {},\n sync = true,\n redirect = false,\n resultId,\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderPipeline\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"pipelineId\", pipelineId);\n\n if (siloId) params.set(\"siloId\", siloId);\n if (prompt) params.set(\"prompt\", prompt);\n if (resultId) params.set(\"resultId\", resultId);\n if (sync !== undefined) params.set(\"sync\", String(sync));\n if (redirect) params.set(\"redirect\", \"true\");\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n if (Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n\n/**\n * Executes a Slop Machine multi-step Pipeline programmatically and returns the full typed result payload.\n *\n * @param options - Execution parameters including the pipelineId and runtime prompt/variables/metadata.\n * @returns A promise resolving to the completed PipelineResult document.\n */\nexport async function executePipeline(\n options: ExecutePipelineOptions,\n): Promise<PipelineResult> {\n const {\n pipelineId,\n siloId,\n prompt,\n variables,\n metadata,\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderPipeline\",\n } = options;\n\n const response = await fetch(baseUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n pipelineId,\n ...(siloId ? { siloId } : {}),\n ...(prompt ? { prompt } : {}),\n variables,\n metadata,\n sync: true,\n }),\n });\n\n if (!response.ok) {\n let errorDetail = response.statusText;\n try {\n const errorJson = await response.json();\n if (errorJson.error) {\n errorDetail = errorJson.error;\n }\n } catch {\n // Use statusText\n }\n throw new Error(\n `Pipeline execution failed (${response.status}): ${errorDetail}`,\n );\n }\n\n return (await response.json()) as PipelineResult;\n}\n\n/**\n * Uploads a base64 encoded file as a temporary attachment to be used in generation requests.\n *\n * @param base64 - The base64 encoded file data (without the data:mime/type;base64, prefix).\n * @param mimeType - The MIME type of the file.\n * @returns A promise that resolves to an object containing the URL of the uploaded attachment.\n */\nexport async function uploadTempAttachment(\n base64: string,\n mimeType: string,\n): Promise<{ url: string }> {\n const response = await fetch(\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/uploadTempAttachment\",\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ data: { base64, mimeType } }),\n },\n );\n if (!response.ok) {\n throw new Error(`Failed to upload attachment: ${response.statusText}`);\n }\n const json = await response.json();\n if (json.error) {\n throw new Error(\n `Failed to upload attachment: ${json.error.message || JSON.stringify(json.error)}`,\n );\n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AAA,MACA;AAAA,MACA,MAAM;AAAA,IACR,CAAC;AAAA,EACH,CAAC;AAED,MAAI,CAAC,SAAS,IAAI;AAChB,QAAI,cAAc,SAAS;AAC3B,QAAI;AACF,YAAM,YAAY,MAAM,SAAS,KAAK;AACtC,UAAI,UAAU,OAAO;AACnB,sBAAc,UAAU;AAAA,MAC1B;AAAA,IACF,QAAQ;AAAA,IAER;AACA,UAAM,IAAI;AAAA,MACR,8BAA8B,SAAS,MAAM,MAAM,WAAW;AAAA,IAChE;AAAA,EACF;AAEA,SAAQ,MAAM,SAAS,KAAK;AAC9B;AASA,eAAsB,qBACpB,QACA,UAC0B;AAC1B,QAAM,WAAW,MAAM;AAAA,IACrB;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM,KAAK,UAAU,EAAE,MAAM,EAAE,QAAQ,SAAS,EAAE,CAAC;AAAA,IACrD;AAAA,EACF;AACA,MAAI,CAAC,SAAS,IAAI;AAChB,UAAM,IAAI,MAAM,gCAAgC,SAAS,UAAU,EAAE;AAAA,EACvE;AACA,QAAM,OAAO,MAAM,SAAS,KAAK;AACjC,MAAI,KAAK,OAAO;AACd,UAAM,IAAI;AAAA,MACR,gCAAgC,KAAK,MAAM,WAAW,KAAK,UAAU,KAAK,KAAK,CAAC;AAAA,IAClF;AAAA,EACF;AACA,SAAO,EAAE,KAAK,KAAK,OAAO,IAAI;AAChC;","names":["endpoint","params"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { AspectRatio as ImageAspectRatio, VideoAspectRatio } from \"@pixerate/schemas\";\nexport type { ImageAspectRatio, VideoAspectRatio };\n\nexport interface PipelineStepResult {\n stepId: string;\n stepName?: string;\n type: string;\n outputUrl?: string;\n outputText?: string;\n outputData?: any;\n computeTimeMs?: number;\n fuelCost?: number;\n error?: string;\n}\n\nexport interface PipelineResult {\n id: string;\n pipelineId: string;\n siloId: string;\n url?: string;\n text?: string;\n data?: any;\n resultType: string;\n status: \"completed\" | \"failed\" | \"pending\";\n stepResults: PipelineStepResult[];\n totalComputeTimeMs: number;\n totalFuelCost: number;\n metadata?: Record<string, any>;\n timestamp: any;\n error?: string;\n}\n\nexport interface SlopPipelineOptions {\n /**\n * The unique identifier of the pipeline to execute.\n */\n pipelineId: string;\n /**\n * Optional silo identifier for direct pipeline path resolution.\n */\n siloId?: string;\n /**\n * Dynamic runtime prompt to feed into the pipeline.\n */\n prompt?: string;\n /**\n * Variables to interpolate into prompt or step configs.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * Arbitrary user metadata to attach to the pipeline result document.\n */\n metadata?: Record<string, any>;\n /**\n * Whether to wait for full execution (default true) or return a job ID immediately.\n */\n sync?: boolean;\n /**\n * Whether to redirect to the primary media output URL upon completion.\n */\n redirect?: boolean;\n /**\n * Result ID to retrieve a specific previously generated result.\n */\n resultId?: string;\n /**\n * Base URL for the renderPipeline cloud function endpoint.\n */\n baseUrl?: string;\n}\n\nexport interface ExecutePipelineOptions {\n /**\n * The unique identifier of the pipeline to execute.\n */\n pipelineId: string;\n /**\n * Optional silo identifier for direct pipeline path resolution.\n */\n siloId?: string;\n /**\n * Dynamic runtime prompt to feed into the pipeline.\n */\n prompt?: string;\n /**\n * Variables to interpolate into prompt or step configs.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * Arbitrary user metadata to attach to the pipeline result document.\n */\n metadata?: Record<string, any>;\n /**\n * Base URL for the renderPipeline cloud function endpoint.\n */\n baseUrl?: string;\n}\n\nexport interface SlopImageOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n * Required when using a bucket unless pipelineId is provided.\n */\n bucketId?: string;\n /**\n * The unique identifier of your Slop Machine pipeline.\n * Required when targeting a pipeline instead of a bucket.\n */\n pipelineId?: string;\n /**\n * Optional silo identifier.\n */\n siloId?: string;\n /**\n * Dynamic runtime prompt (used when targeting a pipeline).\n */\n prompt?: string;\n /**\n * Arbitrary user metadata to attach to the generation request / result document.\n */\n metadata?: Record<string, any>;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated image\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated image. Defaults to \"1:1\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: ImageAspectRatio;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A photo of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The target quality (\"fast\" or \"high\"). Only affects new generations and is ignored for caching.\n * Ignored if `model` is provided.\n * Defaults to \"fast\".\n */\n quality?: \"fast\" | \"high\";\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n /**\n * If `true` (or `?raw=true`), bypasses the WebP optimized media and returns the original generated file (e.g., PNG/JPEG).\n * Defaults to false.\n */\n original?: boolean;\n /**\n * Array of attachment URLs to include with the request.\n */\n attachments?: string[];\n}\n\nexport function interpolatePrompt(\n prompt?: string,\n variables?: Record<string, string | number | undefined | null>,\n): string {\n if (!prompt) return \"\";\n let text = prompt;\n if (!variables) return text;\n\n Object.keys(variables).forEach((key) => {\n const value = variables[key];\n if (value !== undefined && value !== null) {\n text = text.replace(new RegExp(`\\\\{${key}\\\\}`, \"g\"), String(value));\n }\n });\n return text;\n}\n\n/**\n * Builds a URL to render or retrieve an image from Slop Machine.\n *\n * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).\n *\n * @param options - Configuration options for the image generation.\n * @returns A string containing the fully constructed URL.\n */\nexport function buildImageUrl(options: SlopImageOptions): string {\n const {\n bucketId,\n pipelineId,\n siloId,\n prompt,\n metadata,\n version,\n resultId,\n aspectRatio = \"1:1\",\n quality = \"fast\",\n variables = {},\n baseUrl,\n original,\n attachments,\n } = options;\n\n if (pipelineId) {\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderPipeline\";\n const params = new URLSearchParams();\n params.set(\"pipelineId\", pipelineId);\n params.set(\"redirect\", \"true\");\n\n if (siloId) params.set(\"siloId\", siloId);\n if (prompt) params.set(\"prompt\", prompt);\n if (resultId) params.set(\"resultId\", resultId);\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n return `${endpoint}?${params.toString()}`;\n }\n\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage\";\n const params = new URLSearchParams();\n if (bucketId) {\n params.set(\"bucketId\", bucketId);\n }\n\n if (!resultId) {\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (quality && quality !== \"fast\") {\n params.set(\"quality\", quality);\n } else if (quality === \"fast\") {\n params.set(\"quality\", \"fast\");\n }\n\n if (original) {\n params.set(\"original\", \"true\");\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n if (attachments && attachments.length > 0) {\n params.set(\"attachments\", JSON.stringify(attachments));\n }\n } else {\n params.set(\"resultId\", resultId);\n }\n\n return `${endpoint}?${params.toString()}`;\n}\n\n/**\n * Preloads an image from Slop Machine into the browser's cache.\n * Useful for ensuring images are ready before displaying them.\n *\n * @param options - Configuration options for the image generation.\n * @returns A promise that resolves when the image has been loaded.\n */\nexport function preloadImage(options: SlopImageOptions): Promise<void> {\n return new Promise((resolve, reject) => {\n if (typeof window === \"undefined\") {\n resolve();\n return;\n }\n\n const img = new Image();\n img.onload = () => resolve();\n img.onerror = (err) => reject(err);\n img.src = buildImageUrl(options);\n });\n}\n\nexport interface SlopVideoOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n * Required when using a bucket unless pipelineId is provided.\n */\n bucketId?: string;\n /**\n * The unique identifier of your Slop Machine pipeline.\n * Required when targeting a pipeline instead of a bucket.\n */\n pipelineId?: string;\n /**\n * Optional silo identifier.\n */\n siloId?: string;\n /**\n * Dynamic runtime prompt (used when targeting a pipeline).\n */\n prompt?: string;\n /**\n * Arbitrary user metadata to attach to the generation request / result document.\n */\n metadata?: Record<string, any>;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated video\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated video. Defaults to \"16:9\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: VideoAspectRatio;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A video of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The duration of the generated video in seconds.\n * If not specified, defaults to the bucket version's configured duration (or 4).\n */\n duration?: number;\n /**\n * The target quality (\"fast\" or \"high\"). Only affects new generations and is ignored for caching.\n * Ignored if `model` is provided.\n * Defaults to \"fast\".\n */\n quality?: \"fast\" | \"high\";\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n /**\n * If true, serves the original generated uncompressed asset directly from storage.\n */\n original?: boolean;\n /**\n * Array of runtime image attachments (URLs) to use with the video model.\n * Only allowed if the bucket version has runtime attachments enabled.\n */\n attachments?: string[];\n}\n\n/**\n * Builds the URL to render or stream an AI-generated video.\n * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).\n *\n * @param options - Configuration options for the video generation.\n * @returns A string containing the fully constructed URL.\n */\nexport function buildVideoUrl(options: SlopVideoOptions): string {\n const {\n bucketId,\n pipelineId,\n siloId,\n prompt,\n metadata,\n version,\n resultId,\n aspectRatio = \"16:9\",\n quality = \"fast\",\n variables = {},\n duration,\n baseUrl,\n original,\n attachments,\n } = options;\n\n if (pipelineId) {\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderPipeline\";\n const params = new URLSearchParams();\n params.set(\"pipelineId\", pipelineId);\n params.set(\"redirect\", \"true\");\n\n if (siloId) params.set(\"siloId\", siloId);\n if (prompt) params.set(\"prompt\", prompt);\n if (resultId) params.set(\"resultId\", resultId);\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n return `${endpoint}?${params.toString()}`;\n }\n\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderVideo\";\n const params = new URLSearchParams();\n if (bucketId) {\n params.set(\"bucketId\", bucketId);\n }\n\n if (!resultId) {\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (duration) {\n params.set(\"duration\", String(duration));\n }\n if (quality) {\n params.set(\"quality\", quality);\n }\n\n if (original) {\n params.set(\"original\", \"true\");\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n if (attachments && attachments.length > 0) {\n params.set(\"attachments\", JSON.stringify(attachments));\n }\n } else {\n params.set(\"resultId\", resultId);\n }\n\n return `${endpoint}?${params.toString()}`;\n}\n\n/**\n * Preloads a video from Slop Machine into the browser's cache.\n * Useful for ensuring videos are ready before displaying them.\n *\n * @param options - Configuration options for the video generation.\n * @returns A promise that resolves when the video preload request has been initiated.\n */\nexport function preloadVideo(options: SlopVideoOptions): Promise<void> {\n return new Promise((resolve, reject) => {\n if (typeof window === \"undefined\") {\n resolve();\n return;\n }\n\n fetch(buildVideoUrl(options), { mode: \"no-cors\" })\n .then(() => resolve())\n .catch((err) => reject(err));\n });\n}\n\nexport interface SlopTextOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n * Required when using a bucket unless pipelineId is provided.\n */\n bucketId?: string;\n /**\n * The unique identifier of your Slop Machine pipeline.\n * Required when targeting a pipeline instead of a bucket.\n */\n pipelineId?: string;\n /**\n * Optional silo identifier.\n */\n siloId?: string;\n /**\n * Dynamic runtime prompt (used when targeting a pipeline).\n */\n prompt?: string;\n /**\n * Arbitrary user metadata to attach to the generation request / result document.\n */\n metadata?: Record<string, any>;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated text\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A story about a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n /**\n * Array of attachment URLs to include with the request.\n */\n attachments?: string[];\n}\n\n/**\n * Builds a URL to render or retrieve text from Slop Machine.\n *\n * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).\n *\n * @param options - Configuration options for the text generation.\n * @returns A string containing the fully constructed URL.\n */\nexport function buildTextUrl(options: SlopTextOptions): string {\n const {\n bucketId,\n pipelineId,\n siloId,\n prompt,\n metadata,\n version,\n resultId,\n variables = {},\n baseUrl,\n attachments,\n } = options;\n\n if (pipelineId) {\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderPipeline\";\n const params = new URLSearchParams();\n params.set(\"pipelineId\", pipelineId);\n params.set(\"sync\", \"true\");\n\n if (siloId) params.set(\"siloId\", siloId);\n if (prompt) params.set(\"prompt\", prompt);\n if (resultId) params.set(\"resultId\", resultId);\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n return `${endpoint}?${params.toString()}`;\n }\n\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderText\";\n const params = new URLSearchParams();\n if (bucketId) {\n params.set(\"bucketId\", bucketId);\n }\n\n if (!resultId) {\n if (version) {\n params.set(\"version\", String(version));\n }\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n if (attachments && attachments.length > 0) {\n params.set(\"attachments\", JSON.stringify(attachments));\n }\n } else {\n params.set(\"resultId\", resultId);\n }\n\n return `${endpoint}?${params.toString()}`;\n}\n\n/**\n * Preloads text from Slop Machine into the browser's cache.\n * Useful for ensuring text is ready before displaying it.\n *\n * @param options - Configuration options for the text generation.\n * @returns A promise that resolves when the text preload request has been initiated.\n */\nexport function preloadText(options: SlopTextOptions): Promise<void> {\n return new Promise((resolve, reject) => {\n if (typeof window === \"undefined\") {\n resolve();\n return;\n }\n\n fetch(buildTextUrl(options), { mode: \"no-cors\" })\n .then(() => resolve())\n .catch((err) => reject(err));\n });\n}\n\n/**\n * Builds a URL to execute or inspect a multi-step Pipeline from Slop Machine.\n *\n * @param options - Configuration options for the pipeline execution.\n * @returns A string containing the fully constructed URL.\n */\nexport function buildPipelineUrl(options: SlopPipelineOptions): string {\n const {\n pipelineId,\n siloId,\n prompt,\n variables = {},\n metadata = {},\n sync = true,\n redirect = false,\n resultId,\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderPipeline\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"pipelineId\", pipelineId);\n\n if (siloId) params.set(\"siloId\", siloId);\n if (prompt) params.set(\"prompt\", prompt);\n if (resultId) params.set(\"resultId\", resultId);\n if (sync !== undefined) params.set(\"sync\", String(sync));\n if (redirect) params.set(\"redirect\", \"true\");\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n if (Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n\n/**\n * Executes a Slop Machine multi-step Pipeline programmatically and returns the full typed result payload.\n *\n * @param options - Execution parameters including the pipelineId and runtime prompt/variables/metadata.\n * @returns A promise resolving to the completed PipelineResult document.\n */\nexport async function executePipeline(\n options: ExecutePipelineOptions,\n): Promise<PipelineResult> {\n const {\n pipelineId,\n siloId,\n prompt,\n variables,\n metadata,\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderPipeline\",\n } = options;\n\n const response = await fetch(baseUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n pipelineId,\n ...(siloId ? { siloId } : {}),\n ...(prompt ? { prompt } : {}),\n variables,\n metadata,\n sync: true,\n }),\n });\n\n if (!response.ok) {\n let errorDetail = response.statusText;\n try {\n const errorJson = await response.json();\n if (errorJson.error) {\n errorDetail = errorJson.error;\n }\n } catch {\n // Use statusText\n }\n throw new Error(\n `Pipeline execution failed (${response.status}): ${errorDetail}`,\n );\n }\n\n return (await response.json()) as PipelineResult;\n}\n\n/**\n * Uploads a base64 encoded file as a temporary attachment to be used in generation requests.\n *\n * @param base64 - The base64 encoded file data (without the data:mime/type;base64, prefix).\n * @param mimeType - The MIME type of the file.\n * @returns A promise that resolves to an object containing the URL of the uploaded attachment.\n */\nexport async function uploadTempAttachment(\n base64: string,\n mimeType: string,\n): Promise<{ url: string }> {\n const response = await fetch(\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/uploadTempAttachment\",\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ data: { base64, mimeType } }),\n },\n );\n if (!response.ok) {\n throw new Error(`Failed to upload attachment: ${response.statusText}`);\n }\n const json = await response.json();\n if (json.error) {\n throw new Error(\n `Failed to upload attachment: ${json.error.message || JSON.stringify(json.error)}`,\n );\n }\n return { url: json.result.url };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmKO,SAAS,kBACd,QACA,WACQ;AACR,MAAI,CAAC,OAAQ,QAAO;AACpB,MAAI,OAAO;AACX,MAAI,CAAC,UAAW,QAAO;AAEvB,SAAO,KAAK,SAAS,EAAE,QAAQ,CAAC,QAAQ;AACtC,UAAM,QAAQ,UAAU,GAAG;AAC3B,QAAI,UAAU,UAAa,UAAU,MAAM;AACzC,aAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,GAAG,OAAO,GAAG,GAAG,OAAO,KAAK,CAAC;AAAA,IACpE;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAUO,SAAS,cAAc,SAAmC;AAC/D,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,UAAU;AAAA,IACV,YAAY,CAAC;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,MAAI,YAAY;AACd,UAAMA,YACJ,WACA;AACF,UAAMC,UAAS,IAAI,gBAAgB;AACnC,IAAAA,QAAO,IAAI,cAAc,UAAU;AACnC,IAAAA,QAAO,IAAI,YAAY,MAAM;AAE7B,QAAI,OAAQ,CAAAA,QAAO,IAAI,UAAU,MAAM;AACvC,QAAI,OAAQ,CAAAA,QAAO,IAAI,UAAU,MAAM;AACvC,QAAI,SAAU,CAAAA,QAAO,IAAI,YAAY,QAAQ;AAE7C,QAAI,OAAO,KAAK,SAAS,EAAE,SAAS,GAAG;AACrC,MAAAA,QAAO,IAAI,aAAa,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AU;AAAA,MACnB;AAAA,MACA,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;AAAA,MAC3B,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;AAAA,MAC3B;AAAA,MACA;AAAA,MACA,MAAM;AAAA,IACR,CAAC;AAAA,EACH,CAAC;AAED,MAAI,CAAC,SAAS,IAAI;AAChB,QAAI,cAAc,SAAS;AAC3B,QAAI;AACF,YAAM,YAAY,MAAM,SAAS,KAAK;AACtC,UAAI,UAAU,OAAO;AACnB,sBAAc,UAAU;AAAA,MAC1B;AAAA,IACF,QAAQ;AAAA,IAER;AACA,UAAM,IAAI;AAAA,MACR,8BAA8B,SAAS,MAAM,MAAM,WAAW;AAAA,IAChE;AAAA,EACF;AAEA,SAAQ,MAAM,SAAS,KAAK;AAC9B;AASA,eAAsB,qBACpB,QACA,UAC0B;AAC1B,QAAM,WAAW,MAAM;AAAA,IACrB;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM,KAAK,UAAU,EAAE,MAAM,EAAE,QAAQ,SAAS,EAAE,CAAC;AAAA,IACrD;AAAA,EACF;AACA,MAAI,CAAC,SAAS,IAAI;AAChB,UAAM,IAAI,MAAM,gCAAgC,SAAS,UAAU,EAAE;AAAA,EACvE;AACA,QAAM,OAAO,MAAM,SAAS,KAAK;AACjC,MAAI,KAAK,OAAO;AACd,UAAM,IAAI;AAAA,MACR,gCAAgC,KAAK,MAAM,WAAW,KAAK,UAAU,KAAK,KAAK,CAAC;AAAA,IAClF;AAAA,EACF;AACA,SAAO,EAAE,KAAK,KAAK,OAAO,IAAI;AAChC;","names":["endpoint","params"]}
|
package/dist/index.mjs
CHANGED
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { AspectRatio as ImageAspectRatio, VideoAspectRatio } from \"@pixerate/schemas\";\nexport type { ImageAspectRatio, VideoAspectRatio };\n\nexport interface PipelineStepResult {\n stepId: string;\n stepName?: string;\n type: string;\n outputUrl?: string;\n outputText?: string;\n outputData?: any;\n computeTimeMs?: number;\n fuelCost?: number;\n error?: string;\n}\n\nexport interface PipelineResult {\n id: string;\n pipelineId: string;\n siloId: string;\n url?: string;\n text?: string;\n data?: any;\n resultType: string;\n status: \"completed\" | \"failed\" | \"pending\";\n stepResults: PipelineStepResult[];\n totalComputeTimeMs: number;\n totalFuelCost: number;\n metadata?: Record<string, any>;\n timestamp: any;\n error?: string;\n}\n\nexport interface SlopPipelineOptions {\n /**\n * The unique identifier of the pipeline to execute.\n */\n pipelineId: string;\n /**\n * Optional silo identifier for direct pipeline path resolution.\n */\n siloId?: string;\n /**\n * Dynamic runtime prompt to feed into the pipeline.\n */\n prompt?: string;\n /**\n * Variables to interpolate into prompt or step configs.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * Arbitrary user metadata to attach to the pipeline result document.\n */\n metadata?: Record<string, any>;\n /**\n * Whether to wait for full execution (default true) or return a job ID immediately.\n */\n sync?: boolean;\n /**\n * Whether to redirect to the primary media output URL upon completion.\n */\n redirect?: boolean;\n /**\n * Result ID to retrieve a specific previously generated result.\n */\n resultId?: string;\n /**\n * Base URL for the renderPipeline cloud function endpoint.\n */\n baseUrl?: string;\n}\n\nexport interface ExecutePipelineOptions {\n /**\n * The unique identifier of the pipeline to execute.\n */\n pipelineId: string;\n /**\n * Optional silo identifier for direct pipeline path resolution.\n */\n siloId?: string;\n /**\n * Dynamic runtime prompt to feed into the pipeline.\n */\n prompt?: string;\n /**\n * Variables to interpolate into prompt or step configs.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * Arbitrary user metadata to attach to the pipeline result document.\n */\n metadata?: Record<string, any>;\n /**\n * Base URL for the renderPipeline cloud function endpoint.\n */\n baseUrl?: string;\n}\n\nexport interface SlopImageOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n * Required when using a bucket unless pipelineId is provided.\n */\n bucketId?: string;\n /**\n * The unique identifier of your Slop Machine pipeline.\n * Required when targeting a pipeline instead of a bucket.\n */\n pipelineId?: string;\n /**\n * Optional silo identifier.\n */\n siloId?: string;\n /**\n * Dynamic runtime prompt (used when targeting a pipeline).\n */\n prompt?: string;\n /**\n * Arbitrary user metadata to attach to the generation request / result document.\n */\n metadata?: Record<string, any>;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated image\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated image. Defaults to \"1:1\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: ImageAspectRatio;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A photo of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The target quality (\"fast\" or \"high\"). Only affects new generations and is ignored for caching.\n * Ignored if `model` is provided.\n * Defaults to \"fast\".\n */\n quality?: \"fast\" | \"high\";\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n /**\n * If `true` (or `?raw=true`), bypasses the WebP optimized media and returns the original generated file (e.g., PNG/JPEG).\n * Defaults to false.\n */\n original?: boolean;\n /**\n * Array of attachment URLs to include with the request.\n */\n attachments?: string[];\n}\n\nexport function interpolatePrompt(\n prompt?: string,\n variables?: Record<string, string | number | undefined | null>,\n): string {\n if (!prompt) return \"\";\n let text = prompt;\n if (!variables) return text;\n\n Object.keys(variables).forEach((key) => {\n const value = variables[key];\n if (value !== undefined && value !== null) {\n text = text.replace(new RegExp(`\\\\{${key}\\\\}`, \"g\"), String(value));\n }\n });\n return text;\n}\n\n/**\n * Builds a URL to render or retrieve an image from Slop Machine.\n *\n * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).\n *\n * @param options - Configuration options for the image generation.\n * @returns A string containing the fully constructed URL.\n */\nexport function buildImageUrl(options: SlopImageOptions): string {\n const {\n bucketId,\n pipelineId,\n siloId,\n prompt,\n metadata,\n version,\n resultId,\n aspectRatio = \"1:1\",\n quality = \"fast\",\n variables = {},\n baseUrl,\n original,\n attachments,\n } = options;\n\n if (pipelineId) {\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderPipeline\";\n const params = new URLSearchParams();\n params.set(\"pipelineId\", pipelineId);\n params.set(\"redirect\", \"true\");\n\n if (siloId) params.set(\"siloId\", siloId);\n if (prompt) params.set(\"prompt\", prompt);\n if (resultId) params.set(\"resultId\", resultId);\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n return `${endpoint}?${params.toString()}`;\n }\n\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage\";\n const params = new URLSearchParams();\n if (bucketId) {\n params.set(\"bucketId\", bucketId);\n }\n\n if (!resultId) {\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (quality && quality !== \"fast\") {\n params.set(\"quality\", quality);\n } else if (quality === \"fast\") {\n params.set(\"quality\", \"fast\");\n }\n\n if (original) {\n params.set(\"original\", \"true\");\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n if (attachments && attachments.length > 0) {\n params.set(\"attachments\", JSON.stringify(attachments));\n }\n } else {\n params.set(\"resultId\", resultId);\n }\n\n return `${endpoint}?${params.toString()}`;\n}\n\n/**\n * Preloads an image from Slop Machine into the browser's cache.\n * Useful for ensuring images are ready before displaying them.\n *\n * @param options - Configuration options for the image generation.\n * @returns A promise that resolves when the image has been loaded.\n */\nexport function preloadImage(options: SlopImageOptions): Promise<void> {\n return new Promise((resolve, reject) => {\n if (typeof window === \"undefined\") {\n resolve();\n return;\n }\n\n const img = new Image();\n img.onload = () => resolve();\n img.onerror = (err) => reject(err);\n img.src = buildImageUrl(options);\n });\n}\n\nexport interface SlopVideoOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n * Required when using a bucket unless pipelineId is provided.\n */\n bucketId?: string;\n /**\n * The unique identifier of your Slop Machine pipeline.\n * Required when targeting a pipeline instead of a bucket.\n */\n pipelineId?: string;\n /**\n * Optional silo identifier.\n */\n siloId?: string;\n /**\n * Dynamic runtime prompt (used when targeting a pipeline).\n */\n prompt?: string;\n /**\n * Arbitrary user metadata to attach to the generation request / result document.\n */\n metadata?: Record<string, any>;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated video\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated video. Defaults to \"16:9\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: VideoAspectRatio;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A video of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The duration of the generated video in seconds.\n * Must be between 4 and 8. Defaults to 4.\n */\n duration?: number;\n /**\n * The target quality (\"fast\" or \"high\"). Only affects new generations and is ignored for caching.\n * Ignored if `model` is provided.\n * Defaults to \"fast\".\n */\n quality?: \"fast\" | \"high\";\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n /**\n * If `true` (or `?raw=true`), bypasses the WebP optimized media and returns the original generated file.\n * Defaults to false.\n */\n original?: boolean;\n /**\n * Array of attachment URLs to include with the request.\n */\n attachments?: string[];\n}\n\n/**\n * Builds a URL to render or retrieve a video from Slop Machine.\n *\n * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).\n *\n * @param options - Configuration options for the video generation.\n * @returns A string containing the fully constructed URL.\n */\nexport function buildVideoUrl(options: SlopVideoOptions): string {\n const {\n bucketId,\n pipelineId,\n siloId,\n prompt,\n metadata,\n version,\n resultId,\n aspectRatio = \"16:9\",\n quality = \"fast\",\n variables = {},\n duration = 4,\n baseUrl,\n original,\n attachments,\n } = options;\n\n if (pipelineId) {\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderPipeline\";\n const params = new URLSearchParams();\n params.set(\"pipelineId\", pipelineId);\n params.set(\"redirect\", \"true\");\n\n if (siloId) params.set(\"siloId\", siloId);\n if (prompt) params.set(\"prompt\", prompt);\n if (resultId) params.set(\"resultId\", resultId);\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n return `${endpoint}?${params.toString()}`;\n }\n\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderVideo\";\n const params = new URLSearchParams();\n if (bucketId) {\n params.set(\"bucketId\", bucketId);\n }\n\n if (!resultId) {\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (duration) {\n params.set(\"duration\", String(duration));\n }\n if (quality) {\n params.set(\"quality\", quality);\n }\n\n if (original) {\n params.set(\"original\", \"true\");\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n if (attachments && attachments.length > 0) {\n params.set(\"attachments\", JSON.stringify(attachments));\n }\n } else {\n params.set(\"resultId\", resultId);\n }\n\n return `${endpoint}?${params.toString()}`;\n}\n\n/**\n * Preloads a video from Slop Machine into the browser's cache.\n * Useful for ensuring videos are ready before displaying them.\n *\n * @param options - Configuration options for the video generation.\n * @returns A promise that resolves when the video preload request has been initiated.\n */\nexport function preloadVideo(options: SlopVideoOptions): Promise<void> {\n return new Promise((resolve, reject) => {\n if (typeof window === \"undefined\") {\n resolve();\n return;\n }\n\n fetch(buildVideoUrl(options), { mode: \"no-cors\" })\n .then(() => resolve())\n .catch((err) => reject(err));\n });\n}\n\nexport interface SlopTextOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n * Required when using a bucket unless pipelineId is provided.\n */\n bucketId?: string;\n /**\n * The unique identifier of your Slop Machine pipeline.\n * Required when targeting a pipeline instead of a bucket.\n */\n pipelineId?: string;\n /**\n * Optional silo identifier.\n */\n siloId?: string;\n /**\n * Dynamic runtime prompt (used when targeting a pipeline).\n */\n prompt?: string;\n /**\n * Arbitrary user metadata to attach to the generation request / result document.\n */\n metadata?: Record<string, any>;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated text\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A story about a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n /**\n * Array of attachment URLs to include with the request.\n */\n attachments?: string[];\n}\n\n/**\n * Builds a URL to render or retrieve text from Slop Machine.\n *\n * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).\n *\n * @param options - Configuration options for the text generation.\n * @returns A string containing the fully constructed URL.\n */\nexport function buildTextUrl(options: SlopTextOptions): string {\n const {\n bucketId,\n pipelineId,\n siloId,\n prompt,\n metadata,\n version,\n resultId,\n variables = {},\n baseUrl,\n attachments,\n } = options;\n\n if (pipelineId) {\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderPipeline\";\n const params = new URLSearchParams();\n params.set(\"pipelineId\", pipelineId);\n params.set(\"sync\", \"true\");\n\n if (siloId) params.set(\"siloId\", siloId);\n if (prompt) params.set(\"prompt\", prompt);\n if (resultId) params.set(\"resultId\", resultId);\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n return `${endpoint}?${params.toString()}`;\n }\n\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderText\";\n const params = new URLSearchParams();\n if (bucketId) {\n params.set(\"bucketId\", bucketId);\n }\n\n if (!resultId) {\n if (version) {\n params.set(\"version\", String(version));\n }\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n if (attachments && attachments.length > 0) {\n params.set(\"attachments\", JSON.stringify(attachments));\n }\n } else {\n params.set(\"resultId\", resultId);\n }\n\n return `${endpoint}?${params.toString()}`;\n}\n\n/**\n * Preloads text from Slop Machine into the browser's cache.\n * Useful for ensuring text is ready before displaying it.\n *\n * @param options - Configuration options for the text generation.\n * @returns A promise that resolves when the text preload request has been initiated.\n */\nexport function preloadText(options: SlopTextOptions): Promise<void> {\n return new Promise((resolve, reject) => {\n if (typeof window === \"undefined\") {\n resolve();\n return;\n }\n\n fetch(buildTextUrl(options), { mode: \"no-cors\" })\n .then(() => resolve())\n .catch((err) => reject(err));\n });\n}\n\n/**\n * Builds a URL to execute or inspect a multi-step Pipeline from Slop Machine.\n *\n * @param options - Configuration options for the pipeline execution.\n * @returns A string containing the fully constructed URL.\n */\nexport function buildPipelineUrl(options: SlopPipelineOptions): string {\n const {\n pipelineId,\n siloId,\n prompt,\n variables = {},\n metadata = {},\n sync = true,\n redirect = false,\n resultId,\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderPipeline\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"pipelineId\", pipelineId);\n\n if (siloId) params.set(\"siloId\", siloId);\n if (prompt) params.set(\"prompt\", prompt);\n if (resultId) params.set(\"resultId\", resultId);\n if (sync !== undefined) params.set(\"sync\", String(sync));\n if (redirect) params.set(\"redirect\", \"true\");\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n if (Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n\n/**\n * Executes a Slop Machine multi-step Pipeline programmatically and returns the full typed result payload.\n *\n * @param options - Execution parameters including the pipelineId and runtime prompt/variables/metadata.\n * @returns A promise resolving to the completed PipelineResult document.\n */\nexport async function executePipeline(\n options: ExecutePipelineOptions,\n): Promise<PipelineResult> {\n const {\n pipelineId,\n siloId,\n prompt,\n variables,\n metadata,\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderPipeline\",\n } = options;\n\n const response = await fetch(baseUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n pipelineId,\n ...(siloId ? { siloId } : {}),\n ...(prompt ? { prompt } : {}),\n variables,\n metadata,\n sync: true,\n }),\n });\n\n if (!response.ok) {\n let errorDetail = response.statusText;\n try {\n const errorJson = await response.json();\n if (errorJson.error) {\n errorDetail = errorJson.error;\n }\n } catch {\n // Use statusText\n }\n throw new Error(\n `Pipeline execution failed (${response.status}): ${errorDetail}`,\n );\n }\n\n return (await response.json()) as PipelineResult;\n}\n\n/**\n * Uploads a base64 encoded file as a temporary attachment to be used in generation requests.\n *\n * @param base64 - The base64 encoded file data (without the data:mime/type;base64, prefix).\n * @param mimeType - The MIME type of the file.\n * @returns A promise that resolves to an object containing the URL of the uploaded attachment.\n */\nexport async function uploadTempAttachment(\n base64: string,\n mimeType: string,\n): Promise<{ url: string }> {\n const response = await fetch(\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/uploadTempAttachment\",\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ data: { base64, mimeType } }),\n },\n );\n if (!response.ok) {\n throw new Error(`Failed to upload attachment: ${response.statusText}`);\n }\n const json = await response.json();\n if (json.error) {\n throw new Error(\n `Failed to upload attachment: ${json.error.message || JSON.stringify(json.error)}`,\n );\n }\n return { url: json.result.url };\n}\n"],"mappings":";AAmKO,SAAS,kBACd,QACA,WACQ;AACR,MAAI,CAAC,OAAQ,QAAO;AACpB,MAAI,OAAO;AACX,MAAI,CAAC,UAAW,QAAO;AAEvB,SAAO,KAAK,SAAS,EAAE,QAAQ,CAAC,QAAQ;AACtC,UAAM,QAAQ,UAAU,GAAG;AAC3B,QAAI,UAAU,UAAa,UAAU,MAAM;AACzC,aAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,GAAG,OAAO,GAAG,GAAG,OAAO,KAAK,CAAC;AAAA,IACpE;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAUO,SAAS,cAAc,SAAmC;AAC/D,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,UAAU;AAAA,IACV,YAAY,CAAC;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,MAAI,YAAY;AACd,UAAMA,YACJ,WACA;AACF,UAAMC,UAAS,IAAI,gBAAgB;AACnC,IAAAA,QAAO,IAAI,cAAc,UAAU;AACnC,IAAAA,QAAO,IAAI,YAAY,MAAM;AAE7B,QAAI,OAAQ,CAAAA,QAAO,IAAI,UAAU,MAAM;AACvC,QAAI,OAAQ,CAAAA,QAAO,IAAI,UAAU,MAAM;AACvC,QAAI,SAAU,CAAAA,QAAO,IAAI,YAAY,QAAQ;A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ACpC,QAAQ;AAAA,IACR,SAAS;AAAA,MACP,gBAAgB;AAAA,IAClB;AAAA,IACA,MAAM,KAAK,UAAU;AAAA,MACnB;AAAA,MACA,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;AAAA,MAC3B,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;AAAA,MAC3B;AAAA,MACA;AAAA,MACA,MAAM;AAAA,IACR,CAAC;AAAA,EACH,CAAC;AAED,MAAI,CAAC,SAAS,IAAI;AAChB,QAAI,cAAc,SAAS;AAC3B,QAAI;AACF,YAAM,YAAY,MAAM,SAAS,KAAK;AACtC,UAAI,UAAU,OAAO;AACnB,sBAAc,UAAU;AAAA,MAC1B;AAAA,IACF,QAAQ;AAAA,IAER;AACA,UAAM,IAAI;AAAA,MACR,8BAA8B,SAAS,MAAM,MAAM,WAAW;AAAA,IAChE;AAAA,EACF;AAEA,SAAQ,MAAM,SAAS,KAAK;AAC9B;AASA,eAAsB,qBACpB,QACA,UAC0B;AAC1B,QAAM,WAAW,MAAM;AAAA,IACrB;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM,KAAK,UAAU,EAAE,MAAM,EAAE,QAAQ,SAAS,EAAE,CAAC;AAAA,IACrD;AAAA,EACF;AACA,MAAI,CAAC,SAAS,IAAI;AAChB,UAAM,IAAI,MAAM,gCAAgC,SAAS,UAAU,EAAE;AAAA,EACvE;AACA,QAAM,OAAO,MAAM,SAAS,KAAK;AACjC,MAAI,KAAK,OAAO;AACd,UAAM,IAAI;AAAA,MACR,gCAAgC,KAAK,MAAM,WAAW,KAAK,UAAU,KAAK,KAAK,CAAC;AAAA,IAClF;AAAA,EACF;AACA,SAAO,EAAE,KAAK,KAAK,OAAO,IAAI;AAChC;","names":["endpoint","params"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { AspectRatio as ImageAspectRatio, VideoAspectRatio } from \"@pixerate/schemas\";\nexport type { ImageAspectRatio, VideoAspectRatio };\n\nexport interface PipelineStepResult {\n stepId: string;\n stepName?: string;\n type: string;\n outputUrl?: string;\n outputText?: string;\n outputData?: any;\n computeTimeMs?: number;\n fuelCost?: number;\n error?: string;\n}\n\nexport interface PipelineResult {\n id: string;\n pipelineId: string;\n siloId: string;\n url?: string;\n text?: string;\n data?: any;\n resultType: string;\n status: \"completed\" | \"failed\" | \"pending\";\n stepResults: PipelineStepResult[];\n totalComputeTimeMs: number;\n totalFuelCost: number;\n metadata?: Record<string, any>;\n timestamp: any;\n error?: string;\n}\n\nexport interface SlopPipelineOptions {\n /**\n * The unique identifier of the pipeline to execute.\n */\n pipelineId: string;\n /**\n * Optional silo identifier for direct pipeline path resolution.\n */\n siloId?: string;\n /**\n * Dynamic runtime prompt to feed into the pipeline.\n */\n prompt?: string;\n /**\n * Variables to interpolate into prompt or step configs.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * Arbitrary user metadata to attach to the pipeline result document.\n */\n metadata?: Record<string, any>;\n /**\n * Whether to wait for full execution (default true) or return a job ID immediately.\n */\n sync?: boolean;\n /**\n * Whether to redirect to the primary media output URL upon completion.\n */\n redirect?: boolean;\n /**\n * Result ID to retrieve a specific previously generated result.\n */\n resultId?: string;\n /**\n * Base URL for the renderPipeline cloud function endpoint.\n */\n baseUrl?: string;\n}\n\nexport interface ExecutePipelineOptions {\n /**\n * The unique identifier of the pipeline to execute.\n */\n pipelineId: string;\n /**\n * Optional silo identifier for direct pipeline path resolution.\n */\n siloId?: string;\n /**\n * Dynamic runtime prompt to feed into the pipeline.\n */\n prompt?: string;\n /**\n * Variables to interpolate into prompt or step configs.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * Arbitrary user metadata to attach to the pipeline result document.\n */\n metadata?: Record<string, any>;\n /**\n * Base URL for the renderPipeline cloud function endpoint.\n */\n baseUrl?: string;\n}\n\nexport interface SlopImageOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n * Required when using a bucket unless pipelineId is provided.\n */\n bucketId?: string;\n /**\n * The unique identifier of your Slop Machine pipeline.\n * Required when targeting a pipeline instead of a bucket.\n */\n pipelineId?: string;\n /**\n * Optional silo identifier.\n */\n siloId?: string;\n /**\n * Dynamic runtime prompt (used when targeting a pipeline).\n */\n prompt?: string;\n /**\n * Arbitrary user metadata to attach to the generation request / result document.\n */\n metadata?: Record<string, any>;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated image\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated image. Defaults to \"1:1\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: ImageAspectRatio;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A photo of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The target quality (\"fast\" or \"high\"). Only affects new generations and is ignored for caching.\n * Ignored if `model` is provided.\n * Defaults to \"fast\".\n */\n quality?: \"fast\" | \"high\";\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n /**\n * If `true` (or `?raw=true`), bypasses the WebP optimized media and returns the original generated file (e.g., PNG/JPEG).\n * Defaults to false.\n */\n original?: boolean;\n /**\n * Array of attachment URLs to include with the request.\n */\n attachments?: string[];\n}\n\nexport function interpolatePrompt(\n prompt?: string,\n variables?: Record<string, string | number | undefined | null>,\n): string {\n if (!prompt) return \"\";\n let text = prompt;\n if (!variables) return text;\n\n Object.keys(variables).forEach((key) => {\n const value = variables[key];\n if (value !== undefined && value !== null) {\n text = text.replace(new RegExp(`\\\\{${key}\\\\}`, \"g\"), String(value));\n }\n });\n return text;\n}\n\n/**\n * Builds a URL to render or retrieve an image from Slop Machine.\n *\n * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).\n *\n * @param options - Configuration options for the image generation.\n * @returns A string containing the fully constructed URL.\n */\nexport function buildImageUrl(options: SlopImageOptions): string {\n const {\n bucketId,\n pipelineId,\n siloId,\n prompt,\n metadata,\n version,\n resultId,\n aspectRatio = \"1:1\",\n quality = \"fast\",\n variables = {},\n baseUrl,\n original,\n attachments,\n } = options;\n\n if (pipelineId) {\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderPipeline\";\n const params = new URLSearchParams();\n params.set(\"pipelineId\", pipelineId);\n params.set(\"redirect\", \"true\");\n\n if (siloId) params.set(\"siloId\", siloId);\n if (prompt) params.set(\"prompt\", prompt);\n if (resultId) params.set(\"resultId\", resultId);\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n return `${endpoint}?${params.toString()}`;\n }\n\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage\";\n const params = new URLSearchParams();\n if (bucketId) {\n params.set(\"bucketId\", bucketId);\n }\n\n if (!resultId) {\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (quality && quality !== \"fast\") {\n params.set(\"quality\", quality);\n } else if (quality === \"fast\") {\n params.set(\"quality\", \"fast\");\n }\n\n if (original) {\n params.set(\"original\", \"true\");\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n if (attachments && attachments.length > 0) {\n params.set(\"attachments\", JSON.stringify(attachments));\n }\n } else {\n params.set(\"resultId\", resultId);\n }\n\n return `${endpoint}?${params.toString()}`;\n}\n\n/**\n * Preloads an image from Slop Machine into the browser's cache.\n * Useful for ensuring images are ready before displaying them.\n *\n * @param options - Configuration options for the image generation.\n * @returns A promise that resolves when the image has been loaded.\n */\nexport function preloadImage(options: SlopImageOptions): Promise<void> {\n return new Promise((resolve, reject) => {\n if (typeof window === \"undefined\") {\n resolve();\n return;\n }\n\n const img = new Image();\n img.onload = () => resolve();\n img.onerror = (err) => reject(err);\n img.src = buildImageUrl(options);\n });\n}\n\nexport interface SlopVideoOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n * Required when using a bucket unless pipelineId is provided.\n */\n bucketId?: string;\n /**\n * The unique identifier of your Slop Machine pipeline.\n * Required when targeting a pipeline instead of a bucket.\n */\n pipelineId?: string;\n /**\n * Optional silo identifier.\n */\n siloId?: string;\n /**\n * Dynamic runtime prompt (used when targeting a pipeline).\n */\n prompt?: string;\n /**\n * Arbitrary user metadata to attach to the generation request / result document.\n */\n metadata?: Record<string, any>;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated video\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated video. Defaults to \"16:9\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: VideoAspectRatio;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A video of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The duration of the generated video in seconds.\n * If not specified, defaults to the bucket version's configured duration (or 4).\n */\n duration?: number;\n /**\n * The target quality (\"fast\" or \"high\"). Only affects new generations and is ignored for caching.\n * Ignored if `model` is provided.\n * Defaults to \"fast\".\n */\n quality?: \"fast\" | \"high\";\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n /**\n * If true, serves the original generated uncompressed asset directly from storage.\n */\n original?: boolean;\n /**\n * Array of runtime image attachments (URLs) to use with the video model.\n * Only allowed if the bucket version has runtime attachments enabled.\n */\n attachments?: string[];\n}\n\n/**\n * Builds the URL to render or stream an AI-generated video.\n * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).\n *\n * @param options - Configuration options for the video generation.\n * @returns A string containing the fully constructed URL.\n */\nexport function buildVideoUrl(options: SlopVideoOptions): string {\n const {\n bucketId,\n pipelineId,\n siloId,\n prompt,\n metadata,\n version,\n resultId,\n aspectRatio = \"16:9\",\n quality = \"fast\",\n variables = {},\n duration,\n baseUrl,\n original,\n attachments,\n } = options;\n\n if (pipelineId) {\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderPipeline\";\n const params = new URLSearchParams();\n params.set(\"pipelineId\", pipelineId);\n params.set(\"redirect\", \"true\");\n\n if (siloId) params.set(\"siloId\", siloId);\n if (prompt) params.set(\"prompt\", prompt);\n if (resultId) params.set(\"resultId\", resultId);\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n return `${endpoint}?${params.toString()}`;\n }\n\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderVideo\";\n const params = new URLSearchParams();\n if (bucketId) {\n params.set(\"bucketId\", bucketId);\n }\n\n if (!resultId) {\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (duration) {\n params.set(\"duration\", String(duration));\n }\n if (quality) {\n params.set(\"quality\", quality);\n }\n\n if (original) {\n params.set(\"original\", \"true\");\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n if (attachments && attachments.length > 0) {\n params.set(\"attachments\", JSON.stringify(attachments));\n }\n } else {\n params.set(\"resultId\", resultId);\n }\n\n return `${endpoint}?${params.toString()}`;\n}\n\n/**\n * Preloads a video from Slop Machine into the browser's cache.\n * Useful for ensuring videos are ready before displaying them.\n *\n * @param options - Configuration options for the video generation.\n * @returns A promise that resolves when the video preload request has been initiated.\n */\nexport function preloadVideo(options: SlopVideoOptions): Promise<void> {\n return new Promise((resolve, reject) => {\n if (typeof window === \"undefined\") {\n resolve();\n return;\n }\n\n fetch(buildVideoUrl(options), { mode: \"no-cors\" })\n .then(() => resolve())\n .catch((err) => reject(err));\n });\n}\n\nexport interface SlopTextOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n * Required when using a bucket unless pipelineId is provided.\n */\n bucketId?: string;\n /**\n * The unique identifier of your Slop Machine pipeline.\n * Required when targeting a pipeline instead of a bucket.\n */\n pipelineId?: string;\n /**\n * Optional silo identifier.\n */\n siloId?: string;\n /**\n * Dynamic runtime prompt (used when targeting a pipeline).\n */\n prompt?: string;\n /**\n * Arbitrary user metadata to attach to the generation request / result document.\n */\n metadata?: Record<string, any>;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated text\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A story about a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n /**\n * Array of attachment URLs to include with the request.\n */\n attachments?: string[];\n}\n\n/**\n * Builds a URL to render or retrieve text from Slop Machine.\n *\n * Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).\n *\n * @param options - Configuration options for the text generation.\n * @returns A string containing the fully constructed URL.\n */\nexport function buildTextUrl(options: SlopTextOptions): string {\n const {\n bucketId,\n pipelineId,\n siloId,\n prompt,\n metadata,\n version,\n resultId,\n variables = {},\n baseUrl,\n attachments,\n } = options;\n\n if (pipelineId) {\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderPipeline\";\n const params = new URLSearchParams();\n params.set(\"pipelineId\", pipelineId);\n params.set(\"sync\", \"true\");\n\n if (siloId) params.set(\"siloId\", siloId);\n if (prompt) params.set(\"prompt\", prompt);\n if (resultId) params.set(\"resultId\", resultId);\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n return `${endpoint}?${params.toString()}`;\n }\n\n const endpoint =\n baseUrl ||\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderText\";\n const params = new URLSearchParams();\n if (bucketId) {\n params.set(\"bucketId\", bucketId);\n }\n\n if (!resultId) {\n if (version) {\n params.set(\"version\", String(version));\n }\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n if (metadata && Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n if (attachments && attachments.length > 0) {\n params.set(\"attachments\", JSON.stringify(attachments));\n }\n } else {\n params.set(\"resultId\", resultId);\n }\n\n return `${endpoint}?${params.toString()}`;\n}\n\n/**\n * Preloads text from Slop Machine into the browser's cache.\n * Useful for ensuring text is ready before displaying it.\n *\n * @param options - Configuration options for the text generation.\n * @returns A promise that resolves when the text preload request has been initiated.\n */\nexport function preloadText(options: SlopTextOptions): Promise<void> {\n return new Promise((resolve, reject) => {\n if (typeof window === \"undefined\") {\n resolve();\n return;\n }\n\n fetch(buildTextUrl(options), { mode: \"no-cors\" })\n .then(() => resolve())\n .catch((err) => reject(err));\n });\n}\n\n/**\n * Builds a URL to execute or inspect a multi-step Pipeline from Slop Machine.\n *\n * @param options - Configuration options for the pipeline execution.\n * @returns A string containing the fully constructed URL.\n */\nexport function buildPipelineUrl(options: SlopPipelineOptions): string {\n const {\n pipelineId,\n siloId,\n prompt,\n variables = {},\n metadata = {},\n sync = true,\n redirect = false,\n resultId,\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderPipeline\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"pipelineId\", pipelineId);\n\n if (siloId) params.set(\"siloId\", siloId);\n if (prompt) params.set(\"prompt\", prompt);\n if (resultId) params.set(\"resultId\", resultId);\n if (sync !== undefined) params.set(\"sync\", String(sync));\n if (redirect) params.set(\"redirect\", \"true\");\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n if (Object.keys(metadata).length > 0) {\n params.set(\"metadata\", JSON.stringify(metadata));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n\n/**\n * Executes a Slop Machine multi-step Pipeline programmatically and returns the full typed result payload.\n *\n * @param options - Execution parameters including the pipelineId and runtime prompt/variables/metadata.\n * @returns A promise resolving to the completed PipelineResult document.\n */\nexport async function executePipeline(\n options: ExecutePipelineOptions,\n): Promise<PipelineResult> {\n const {\n pipelineId,\n siloId,\n prompt,\n variables,\n metadata,\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderPipeline\",\n } = options;\n\n const response = await fetch(baseUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n pipelineId,\n ...(siloId ? { siloId } : {}),\n ...(prompt ? { prompt } : {}),\n variables,\n metadata,\n sync: true,\n }),\n });\n\n if (!response.ok) {\n let errorDetail = response.statusText;\n try {\n const errorJson = await response.json();\n if (errorJson.error) {\n errorDetail = errorJson.error;\n }\n } catch {\n // Use statusText\n }\n throw new Error(\n `Pipeline execution failed (${response.status}): ${errorDetail}`,\n );\n }\n\n return (await response.json()) as PipelineResult;\n}\n\n/**\n * Uploads a base64 encoded file as a temporary attachment to be used in generation requests.\n *\n * @param base64 - The base64 encoded file data (without the data:mime/type;base64, prefix).\n * @param mimeType - The MIME type of the file.\n * @returns A promise that resolves to an object containing the URL of the uploaded attachment.\n */\nexport async function uploadTempAttachment(\n base64: string,\n mimeType: string,\n): Promise<{ url: string }> {\n const response = await fetch(\n \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/uploadTempAttachment\",\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ data: { base64, mimeType } }),\n },\n );\n if (!response.ok) {\n throw new Error(`Failed to upload attachment: ${response.statusText}`);\n }\n const json = await response.json();\n if (json.error) {\n throw new Error(\n `Failed to upload attachment: ${json.error.message || JSON.stringify(json.error)}`,\n );\n }\n return { url: json.result.url };\n}\n"],"mappings":";AAmKO,SAAS,kBACd,QACA,WACQ;AACR,MAAI,CAAC,OAAQ,QAAO;AACpB,MAAI,OAAO;AACX,MAAI,CAAC,UAAW,QAAO;AAEvB,SAAO,KAAK,SAAS,EAAE,QAAQ,CAAC,QAAQ;AACtC,UAAM,QAAQ,UAAU,GAAG;AAC3B,QAAI,UAAU,UAAa,UAAU,MAAM;AACzC,aAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,GAAG,OAAO,GAAG,GAAG,OAAO,KAAK,CAAC;AAAA,IACpE;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAUO,SAAS,cAAc,SAAmC;AAC/D,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,UAAU;AAAA,IACV,YAAY,CAAC;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,MAAI,YAAY;AACd,UAAMA,YACJ,WACA;AACF,UAAMC,UAAS,IAAI,gBAAgB;AACnC,IAAAA,QAAO,IAAI,cAAc,UAAU;AACnC,IAAAA,QAAO,IAAI,YAAY,MAAM;AAE7B,QAAI,OAAQ,CAAAA,QAAO,IAAI,UAAU,MAAM;AACvC,QAAI,OAAQ,CAAAA,QAAO,IAAI,UAAU,MAAM;AACvC,QAAI,SAAU,CAAAA,Q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MAAM,SAAS;AAAA,IACpC,QAAQ;AAAA,IACR,SAAS;AAAA,MACP,gBAAgB;AAAA,IAClB;AAAA,IACA,MAAM,KAAK,UAAU;AAAA,MACnB;AAAA,MACA,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;AAAA,MAC3B,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;AAAA,MAC3B;AAAA,MACA;AAAA,MACA,MAAM;AAAA,IACR,CAAC;AAAA,EACH,CAAC;AAED,MAAI,CAAC,SAAS,IAAI;AAChB,QAAI,cAAc,SAAS;AAC3B,QAAI;AACF,YAAM,YAAY,MAAM,SAAS,KAAK;AACtC,UAAI,UAAU,OAAO;AACnB,sBAAc,UAAU;AAAA,MAC1B;AAAA,IACF,QAAQ;AAAA,IAER;AACA,UAAM,IAAI;AAAA,MACR,8BAA8B,SAAS,MAAM,MAAM,WAAW;AAAA,IAChE;AAAA,EACF;AAEA,SAAQ,MAAM,SAAS,KAAK;AAC9B;AASA,eAAsB,qBACpB,QACA,UAC0B;AAC1B,QAAM,WAAW,MAAM;AAAA,IACrB;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM,KAAK,UAAU,EAAE,MAAM,EAAE,QAAQ,SAAS,EAAE,CAAC;AAAA,IACrD;AAAA,EACF;AACA,MAAI,CAAC,SAAS,IAAI;AAChB,UAAM,IAAI,MAAM,gCAAgC,SAAS,UAAU,EAAE;AAAA,EACvE;AACA,QAAM,OAAO,MAAM,SAAS,KAAK;AACjC,MAAI,KAAK,OAAO;AACd,UAAM,IAAI;AAAA,MACR,gCAAgC,KAAK,MAAM,WAAW,KAAK,UAAU,KAAK,KAAK,CAAC;AAAA,IAClF;AAAA,EACF;AACA,SAAO,EAAE,KAAK,KAAK,OAAO,IAAI;AAChC;","names":["endpoint","params"]}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -334,7 +334,7 @@ export interface SlopVideoOptions {
|
|
|
334
334
|
variables?: Record<string, string | number | undefined | null>;
|
|
335
335
|
/**
|
|
336
336
|
* The duration of the generated video in seconds.
|
|
337
|
-
*
|
|
337
|
+
* If not specified, defaults to the bucket version's configured duration (or 4).
|
|
338
338
|
*/
|
|
339
339
|
duration?: number;
|
|
340
340
|
/**
|
|
@@ -349,19 +349,18 @@ export interface SlopVideoOptions {
|
|
|
349
349
|
*/
|
|
350
350
|
baseUrl?: string;
|
|
351
351
|
/**
|
|
352
|
-
* If
|
|
353
|
-
* Defaults to false.
|
|
352
|
+
* If true, serves the original generated uncompressed asset directly from storage.
|
|
354
353
|
*/
|
|
355
354
|
original?: boolean;
|
|
356
355
|
/**
|
|
357
|
-
* Array of
|
|
356
|
+
* Array of runtime image attachments (URLs) to use with the video model.
|
|
357
|
+
* Only allowed if the bucket version has runtime attachments enabled.
|
|
358
358
|
*/
|
|
359
359
|
attachments?: string[];
|
|
360
360
|
}
|
|
361
361
|
|
|
362
362
|
/**
|
|
363
|
-
* Builds
|
|
364
|
-
*
|
|
363
|
+
* Builds the URL to render or stream an AI-generated video.
|
|
365
364
|
* Supports both standard Buckets (via `bucketId`) and multi-step Pipelines (via `pipelineId`).
|
|
366
365
|
*
|
|
367
366
|
* @param options - Configuration options for the video generation.
|
|
@@ -379,7 +378,7 @@ export function buildVideoUrl(options: SlopVideoOptions): string {
|
|
|
379
378
|
aspectRatio = "16:9",
|
|
380
379
|
quality = "fast",
|
|
381
380
|
variables = {},
|
|
382
|
-
duration
|
|
381
|
+
duration,
|
|
383
382
|
baseUrl,
|
|
384
383
|
original,
|
|
385
384
|
attachments,
|