yesilcam-studios 0.1.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/src/jobs.js DELETED
@@ -1,45 +0,0 @@
1
- // İş oluşturma ve bekleme. Sözleşme: aistudio_jobs.status ∈ queued|processing|succeeded|failed.
2
- export const TIERS = ['draft', 'standard', 'cinema', 'cinemapro']
3
- export const ASPECTS = ['1:1', '16:9', '9:16', '3:4', '4:3']
4
-
5
- export function imageJob({ prompt, tier = 'draft', aspect = '16:9', framing }) {
6
- const p = { job_type: 'text2image', prompt, quality_tier: tier, aspect_ratio: aspect }
7
- if (framing) p.framing = framing
8
- return p
9
- }
10
- export function videoJob({ prompt = '', tier = 'draft', aspect = '16:9', sourceAssetId, duration, resolution, generateAudio }) {
11
- const p = { job_type: sourceAssetId ? 'image2video' : 'text2video', prompt, quality_tier: tier, aspect_ratio: aspect }
12
- if (sourceAssetId) p.source_asset_id = Number(sourceAssetId)
13
- if (duration) p.duration = Number(duration)
14
- if (resolution) p.resolution = resolution
15
- if (generateAudio) p.generate_audio = true
16
- return p
17
- }
18
- export function tryonJob({ garmentAssetId, personAssetId, characterId, prompt = '' }) {
19
- const p = { job_type: 'tryon', garment_asset_id: Number(garmentAssetId), prompt, quality_tier: 'standard' }
20
- if (characterId) p.character_id = Number(characterId)
21
- else if (personAssetId) p.source_asset_id = Number(personAssetId)
22
- return p
23
- }
24
-
25
- const sleep = (ms) => new Promise((r) => setTimeout(r, ms))
26
- const isDone = (s) => ['succeeded', 'failed', 'cancelled', 'refunded'].includes(String(s))
27
-
28
- /** İş bitene kadar bekler (varsayılan 4 sn aralık, 20 dk). onTick(job) ilerleme için. */
29
- export async function waitForJob(client, jobId, { intervalMs = 4000, timeoutMs = 20 * 60 * 1000, onTick, sleepImpl = sleep } = {}) {
30
- const started = Date.now()
31
- for (;;) {
32
- const r = await client.jobStatus(Number(jobId))
33
- const job = r?.job
34
- onTick?.(job)
35
- if (job && isDone(job.status)) return job
36
- if (Date.now() - started > timeoutMs) throw new Error('job_wait_timeout')
37
- await sleepImpl(intervalMs)
38
- }
39
- }
40
- export function describeJob(job) {
41
- if (!job) return null
42
- return { id: String(job.id), type: job.job_type, status: job.status, tier: job.quality_tier, progress: job.render_progress != null ? Number(job.render_progress) : null,
43
- tokens_charged: job.tokens_charged != null ? Number(job.tokens_charged) : null, error: job.error_code || null,
44
- result: job.result_asset ? { asset_id: String(job.result_asset.id), kind: job.result_asset.kind, url: job.result_asset.spaces_url, thumb: job.result_asset.thumb_url } : null }
45
- }