@antiphony/shared 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/api-codecs.cjs +130 -21
- package/dist/cjs/api-codecs.d.cts +67 -23
- package/dist/cjs/index.cjs +168 -21
- package/dist/cjs/index.d.cts +3 -86
- package/dist/cjs/nsid.cjs +10 -0
- package/dist/cjs/nsid.d.cts +25 -1
- package/dist/cjs/types/audio.cjs +125 -18
- package/dist/cjs/types/audio.d.cts +157 -47
- package/dist/cjs/types/processing.cjs +174 -0
- package/dist/cjs/types/processing.d.cts +336 -0
- package/dist/esm/api-codecs.d.ts +101 -57
- package/dist/esm/api-codecs.js +3 -2
- package/dist/esm/chunk-AKIWUNNK.js +129 -0
- package/dist/esm/{chunk-SBYNIQRZ.js → chunk-F5RKN3GY.js} +10 -1
- package/dist/esm/{chunk-WL2GSPGC.js → chunk-J2HE6PE2.js} +31 -29
- package/dist/esm/{chunk-RUUHUNZ6.js → chunk-UYCXRNTK.js} +7 -4
- package/dist/esm/index.d.ts +3 -86
- package/dist/esm/index.js +4 -3
- package/dist/esm/nsid.d.ts +25 -1
- package/dist/esm/nsid.js +1 -1
- package/dist/esm/types/audio.d.ts +268 -158
- package/dist/esm/types/audio.js +2 -1
- package/dist/esm/types/processing.d.ts +336 -0
- package/dist/esm/types/processing.js +3 -0
- package/package.json +6 -2
|
@@ -123,9 +123,9 @@ declare const AudioEmbedSchema: z.ZodObject<{
|
|
|
123
123
|
mimeType: string;
|
|
124
124
|
size: number;
|
|
125
125
|
};
|
|
126
|
+
waveform?: number[] | undefined;
|
|
126
127
|
durationMs?: number | undefined;
|
|
127
128
|
alt?: string | undefined;
|
|
128
|
-
waveform?: number[] | undefined;
|
|
129
129
|
}, {
|
|
130
130
|
$type: "dev.antiphony.embed.audio";
|
|
131
131
|
audio: {
|
|
@@ -136,9 +136,9 @@ declare const AudioEmbedSchema: z.ZodObject<{
|
|
|
136
136
|
mimeType: string;
|
|
137
137
|
size: number;
|
|
138
138
|
};
|
|
139
|
+
waveform?: number[] | undefined;
|
|
139
140
|
durationMs?: number | undefined;
|
|
140
141
|
alt?: string | undefined;
|
|
141
|
-
waveform?: number[] | undefined;
|
|
142
142
|
}>;
|
|
143
143
|
type AudioEmbed = z.infer<typeof AudioEmbedSchema>;
|
|
144
144
|
/**
|
|
@@ -217,6 +217,18 @@ type TimedTranscript = z.infer<typeof TimedTranscriptSchema>;
|
|
|
217
217
|
*/
|
|
218
218
|
declare const AudioEmbedViewSchema: z.ZodObject<{
|
|
219
219
|
$type: z.ZodLiteral<"dev.antiphony.embed.audio#view">;
|
|
220
|
+
/**
|
|
221
|
+
* `url`, `durationMs` and `waveform` are RESOLVED, not copied: once
|
|
222
|
+
* processing has produced an audio variant they describe that variant
|
|
223
|
+
* rather than the bytes the client uploaded. They always agree with one
|
|
224
|
+
* another — a duration and a set of peaks are only meaningful against the
|
|
225
|
+
* audio `url` actually points at.
|
|
226
|
+
*
|
|
227
|
+
* A client that stored `durationMs` at upload time should therefore expect
|
|
228
|
+
* it to change (trim removes leading/trailing silence), and should render
|
|
229
|
+
* these three as a set rather than caching them independently. The record's
|
|
230
|
+
* originals are immutable and unaffected; this is a read-time resolution.
|
|
231
|
+
*/
|
|
220
232
|
url: z.ZodString;
|
|
221
233
|
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
222
234
|
alt: z.ZodOptional<z.ZodString>;
|
|
@@ -261,28 +273,36 @@ declare const AudioEmbedViewSchema: z.ZodObject<{
|
|
|
261
273
|
text?: string | undefined;
|
|
262
274
|
}>>;
|
|
263
275
|
/**
|
|
264
|
-
* Per-stage audio-processing status (
|
|
265
|
-
* opted into processing
|
|
266
|
-
* means the client should poll (or re-render) for the
|
|
267
|
-
*
|
|
268
|
-
*
|
|
276
|
+
* Per-stage audio-processing status (denoise / trim / transcribe /
|
|
277
|
+
* waveform), when the app opted into processing. Absent otherwise. A
|
|
278
|
+
* `pending` stage means the client should poll (or re-render) for the
|
|
279
|
+
* result — including a stage that returns to `pending` after having been
|
|
280
|
+
* `ready`, which is how a recompute surfaces. Once a byte-mutating stage
|
|
281
|
+
* completes, `url`/`durationMs`/`waveform` above already resolve to the
|
|
282
|
+
* processed audio variant. See `types/processing.ts`.
|
|
269
283
|
*/
|
|
270
284
|
processing: z.ZodOptional<z.ZodObject<{
|
|
271
285
|
transcribe: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
272
286
|
denoise: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
287
|
+
trim: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
288
|
+
waveform: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
273
289
|
}, "strip", z.ZodTypeAny, {
|
|
274
|
-
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
275
290
|
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
276
|
-
|
|
291
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
277
292
|
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
293
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
294
|
+
}, {
|
|
278
295
|
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
296
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
297
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
298
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
279
299
|
}>>;
|
|
280
300
|
}, "strip", z.ZodTypeAny, {
|
|
281
301
|
$type: "dev.antiphony.embed.audio#view";
|
|
282
302
|
url: string;
|
|
303
|
+
waveform?: number[] | undefined;
|
|
283
304
|
durationMs?: number | undefined;
|
|
284
305
|
alt?: string | undefined;
|
|
285
|
-
waveform?: number[] | undefined;
|
|
286
306
|
transcript?: {
|
|
287
307
|
segments: {
|
|
288
308
|
startMs: number;
|
|
@@ -292,15 +312,17 @@ declare const AudioEmbedViewSchema: z.ZodObject<{
|
|
|
292
312
|
text?: string | undefined;
|
|
293
313
|
} | undefined;
|
|
294
314
|
processing?: {
|
|
295
|
-
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
296
315
|
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
316
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
317
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
318
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
297
319
|
} | undefined;
|
|
298
320
|
}, {
|
|
299
321
|
$type: "dev.antiphony.embed.audio#view";
|
|
300
322
|
url: string;
|
|
323
|
+
waveform?: number[] | undefined;
|
|
301
324
|
durationMs?: number | undefined;
|
|
302
325
|
alt?: string | undefined;
|
|
303
|
-
waveform?: number[] | undefined;
|
|
304
326
|
transcript?: {
|
|
305
327
|
segments: {
|
|
306
328
|
startMs: number;
|
|
@@ -310,8 +332,10 @@ declare const AudioEmbedViewSchema: z.ZodObject<{
|
|
|
310
332
|
text?: string | undefined;
|
|
311
333
|
} | undefined;
|
|
312
334
|
processing?: {
|
|
313
|
-
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
314
335
|
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
336
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
337
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
338
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
315
339
|
} | undefined;
|
|
316
340
|
}>;
|
|
317
341
|
type AudioEmbedView = z.infer<typeof AudioEmbedViewSchema>;
|
|
@@ -370,17 +394,43 @@ declare const AudioPostRecordSchema: z.ZodEffects<z.ZodObject<{
|
|
|
370
394
|
processing: z.ZodOptional<z.ZodObject<{
|
|
371
395
|
transcribe: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
372
396
|
denoise: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
373
|
-
|
|
397
|
+
trim: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
398
|
+
waveform: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
399
|
+
} & {
|
|
400
|
+
reprocess: z.ZodOptional<z.ZodBoolean>;
|
|
401
|
+
} & {
|
|
402
|
+
processedBlobCid: z.ZodOptional<z.ZodString>;
|
|
403
|
+
processedMimeType: z.ZodOptional<z.ZodString>;
|
|
404
|
+
processedDurationMs: z.ZodOptional<z.ZodNumber>;
|
|
405
|
+
denoiseModel: z.ZodOptional<z.ZodString>;
|
|
406
|
+
waveformPeaks: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
407
|
+
leaseUntil: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodString, z.ZodNumber, z.ZodDate]>, Date, unknown>>;
|
|
374
408
|
updatedAt: z.ZodEffects<z.ZodUnion<[z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodString, z.ZodNumber, z.ZodDate]>, Date, unknown>;
|
|
375
409
|
}, "strip", z.ZodTypeAny, {
|
|
376
410
|
updatedAt: Date;
|
|
377
|
-
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
378
411
|
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
379
|
-
|
|
380
|
-
}, {
|
|
412
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
381
413
|
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
414
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
415
|
+
reprocess?: boolean | undefined;
|
|
416
|
+
processedBlobCid?: string | undefined;
|
|
417
|
+
processedMimeType?: string | undefined;
|
|
418
|
+
processedDurationMs?: number | undefined;
|
|
419
|
+
denoiseModel?: string | undefined;
|
|
420
|
+
waveformPeaks?: number[] | undefined;
|
|
421
|
+
leaseUntil?: Date | undefined;
|
|
422
|
+
}, {
|
|
382
423
|
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
383
|
-
|
|
424
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
425
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
426
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
427
|
+
reprocess?: boolean | undefined;
|
|
428
|
+
processedBlobCid?: string | undefined;
|
|
429
|
+
processedMimeType?: string | undefined;
|
|
430
|
+
processedDurationMs?: number | undefined;
|
|
431
|
+
denoiseModel?: string | undefined;
|
|
432
|
+
waveformPeaks?: number[] | undefined;
|
|
433
|
+
leaseUntil?: unknown;
|
|
384
434
|
updatedAt?: unknown;
|
|
385
435
|
}>>;
|
|
386
436
|
/** User-authored text (bsky-semantic). May be empty for pure-audio posts. NEVER the transcript. */
|
|
@@ -433,9 +483,9 @@ declare const AudioPostRecordSchema: z.ZodEffects<z.ZodObject<{
|
|
|
433
483
|
mimeType: string;
|
|
434
484
|
size: number;
|
|
435
485
|
};
|
|
486
|
+
waveform?: number[] | undefined;
|
|
436
487
|
durationMs?: number | undefined;
|
|
437
488
|
alt?: string | undefined;
|
|
438
|
-
waveform?: number[] | undefined;
|
|
439
489
|
}, {
|
|
440
490
|
$type: "dev.antiphony.embed.audio";
|
|
441
491
|
audio: {
|
|
@@ -446,9 +496,9 @@ declare const AudioPostRecordSchema: z.ZodEffects<z.ZodObject<{
|
|
|
446
496
|
mimeType: string;
|
|
447
497
|
size: number;
|
|
448
498
|
};
|
|
499
|
+
waveform?: number[] | undefined;
|
|
449
500
|
durationMs?: number | undefined;
|
|
450
501
|
alt?: string | undefined;
|
|
451
|
-
waveform?: number[] | undefined;
|
|
452
502
|
}>>;
|
|
453
503
|
/** Present iff this post is a reply (StrongRef root + parent). */
|
|
454
504
|
reply: z.ZodOptional<z.ZodObject<{
|
|
@@ -507,9 +557,17 @@ declare const AudioPostRecordSchema: z.ZodEffects<z.ZodObject<{
|
|
|
507
557
|
createdAt: Date;
|
|
508
558
|
processing?: {
|
|
509
559
|
updatedAt: Date;
|
|
510
|
-
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
511
560
|
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
512
|
-
|
|
561
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
562
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
563
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
564
|
+
reprocess?: boolean | undefined;
|
|
565
|
+
processedBlobCid?: string | undefined;
|
|
566
|
+
processedMimeType?: string | undefined;
|
|
567
|
+
processedDurationMs?: number | undefined;
|
|
568
|
+
denoiseModel?: string | undefined;
|
|
569
|
+
waveformPeaks?: number[] | undefined;
|
|
570
|
+
leaseUntil?: Date | undefined;
|
|
513
571
|
} | undefined;
|
|
514
572
|
authorDid?: string | undefined;
|
|
515
573
|
orgId?: string | null | undefined;
|
|
@@ -536,9 +594,9 @@ declare const AudioPostRecordSchema: z.ZodEffects<z.ZodObject<{
|
|
|
536
594
|
mimeType: string;
|
|
537
595
|
size: number;
|
|
538
596
|
};
|
|
597
|
+
waveform?: number[] | undefined;
|
|
539
598
|
durationMs?: number | undefined;
|
|
540
599
|
alt?: string | undefined;
|
|
541
|
-
waveform?: number[] | undefined;
|
|
542
600
|
} | undefined;
|
|
543
601
|
langs?: string[] | undefined;
|
|
544
602
|
selfLabels?: string[] | undefined;
|
|
@@ -550,9 +608,17 @@ declare const AudioPostRecordSchema: z.ZodEffects<z.ZodObject<{
|
|
|
550
608
|
authorId: string;
|
|
551
609
|
kind: "prompt" | "reply";
|
|
552
610
|
processing?: {
|
|
553
|
-
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
554
611
|
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
555
|
-
|
|
612
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
613
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
614
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
615
|
+
reprocess?: boolean | undefined;
|
|
616
|
+
processedBlobCid?: string | undefined;
|
|
617
|
+
processedMimeType?: string | undefined;
|
|
618
|
+
processedDurationMs?: number | undefined;
|
|
619
|
+
denoiseModel?: string | undefined;
|
|
620
|
+
waveformPeaks?: number[] | undefined;
|
|
621
|
+
leaseUntil?: unknown;
|
|
556
622
|
updatedAt?: unknown;
|
|
557
623
|
} | undefined;
|
|
558
624
|
authorDid?: string | undefined;
|
|
@@ -580,9 +646,9 @@ declare const AudioPostRecordSchema: z.ZodEffects<z.ZodObject<{
|
|
|
580
646
|
mimeType: string;
|
|
581
647
|
size: number;
|
|
582
648
|
};
|
|
649
|
+
waveform?: number[] | undefined;
|
|
583
650
|
durationMs?: number | undefined;
|
|
584
651
|
alt?: string | undefined;
|
|
585
|
-
waveform?: number[] | undefined;
|
|
586
652
|
} | undefined;
|
|
587
653
|
langs?: string[] | undefined;
|
|
588
654
|
selfLabels?: string[] | undefined;
|
|
@@ -597,9 +663,17 @@ declare const AudioPostRecordSchema: z.ZodEffects<z.ZodObject<{
|
|
|
597
663
|
createdAt: Date;
|
|
598
664
|
processing?: {
|
|
599
665
|
updatedAt: Date;
|
|
600
|
-
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
601
666
|
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
602
|
-
|
|
667
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
668
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
669
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
670
|
+
reprocess?: boolean | undefined;
|
|
671
|
+
processedBlobCid?: string | undefined;
|
|
672
|
+
processedMimeType?: string | undefined;
|
|
673
|
+
processedDurationMs?: number | undefined;
|
|
674
|
+
denoiseModel?: string | undefined;
|
|
675
|
+
waveformPeaks?: number[] | undefined;
|
|
676
|
+
leaseUntil?: Date | undefined;
|
|
603
677
|
} | undefined;
|
|
604
678
|
authorDid?: string | undefined;
|
|
605
679
|
orgId?: string | null | undefined;
|
|
@@ -626,9 +700,9 @@ declare const AudioPostRecordSchema: z.ZodEffects<z.ZodObject<{
|
|
|
626
700
|
mimeType: string;
|
|
627
701
|
size: number;
|
|
628
702
|
};
|
|
703
|
+
waveform?: number[] | undefined;
|
|
629
704
|
durationMs?: number | undefined;
|
|
630
705
|
alt?: string | undefined;
|
|
631
|
-
waveform?: number[] | undefined;
|
|
632
706
|
} | undefined;
|
|
633
707
|
langs?: string[] | undefined;
|
|
634
708
|
selfLabels?: string[] | undefined;
|
|
@@ -640,9 +714,17 @@ declare const AudioPostRecordSchema: z.ZodEffects<z.ZodObject<{
|
|
|
640
714
|
authorId: string;
|
|
641
715
|
kind: "prompt" | "reply";
|
|
642
716
|
processing?: {
|
|
643
|
-
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
644
717
|
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
645
|
-
|
|
718
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
719
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
720
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
721
|
+
reprocess?: boolean | undefined;
|
|
722
|
+
processedBlobCid?: string | undefined;
|
|
723
|
+
processedMimeType?: string | undefined;
|
|
724
|
+
processedDurationMs?: number | undefined;
|
|
725
|
+
denoiseModel?: string | undefined;
|
|
726
|
+
waveformPeaks?: number[] | undefined;
|
|
727
|
+
leaseUntil?: unknown;
|
|
646
728
|
updatedAt?: unknown;
|
|
647
729
|
} | undefined;
|
|
648
730
|
authorDid?: string | undefined;
|
|
@@ -670,9 +752,9 @@ declare const AudioPostRecordSchema: z.ZodEffects<z.ZodObject<{
|
|
|
670
752
|
mimeType: string;
|
|
671
753
|
size: number;
|
|
672
754
|
};
|
|
755
|
+
waveform?: number[] | undefined;
|
|
673
756
|
durationMs?: number | undefined;
|
|
674
757
|
alt?: string | undefined;
|
|
675
|
-
waveform?: number[] | undefined;
|
|
676
758
|
} | undefined;
|
|
677
759
|
langs?: string[] | undefined;
|
|
678
760
|
selfLabels?: string[] | undefined;
|
|
@@ -1014,6 +1096,18 @@ declare const AudioPostViewSchema: z.ZodObject<{
|
|
|
1014
1096
|
/** Hydrated audio embed (signed URL + lifted transcript). */
|
|
1015
1097
|
embed: z.ZodOptional<z.ZodObject<{
|
|
1016
1098
|
$type: z.ZodLiteral<"dev.antiphony.embed.audio#view">;
|
|
1099
|
+
/**
|
|
1100
|
+
* `url`, `durationMs` and `waveform` are RESOLVED, not copied: once
|
|
1101
|
+
* processing has produced an audio variant they describe that variant
|
|
1102
|
+
* rather than the bytes the client uploaded. They always agree with one
|
|
1103
|
+
* another — a duration and a set of peaks are only meaningful against the
|
|
1104
|
+
* audio `url` actually points at.
|
|
1105
|
+
*
|
|
1106
|
+
* A client that stored `durationMs` at upload time should therefore expect
|
|
1107
|
+
* it to change (trim removes leading/trailing silence), and should render
|
|
1108
|
+
* these three as a set rather than caching them independently. The record's
|
|
1109
|
+
* originals are immutable and unaffected; this is a read-time resolution.
|
|
1110
|
+
*/
|
|
1017
1111
|
url: z.ZodString;
|
|
1018
1112
|
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
1019
1113
|
alt: z.ZodOptional<z.ZodString>;
|
|
@@ -1058,28 +1152,36 @@ declare const AudioPostViewSchema: z.ZodObject<{
|
|
|
1058
1152
|
text?: string | undefined;
|
|
1059
1153
|
}>>;
|
|
1060
1154
|
/**
|
|
1061
|
-
* Per-stage audio-processing status (
|
|
1062
|
-
* opted into processing
|
|
1063
|
-
* means the client should poll (or re-render) for the
|
|
1064
|
-
*
|
|
1065
|
-
*
|
|
1155
|
+
* Per-stage audio-processing status (denoise / trim / transcribe /
|
|
1156
|
+
* waveform), when the app opted into processing. Absent otherwise. A
|
|
1157
|
+
* `pending` stage means the client should poll (or re-render) for the
|
|
1158
|
+
* result — including a stage that returns to `pending` after having been
|
|
1159
|
+
* `ready`, which is how a recompute surfaces. Once a byte-mutating stage
|
|
1160
|
+
* completes, `url`/`durationMs`/`waveform` above already resolve to the
|
|
1161
|
+
* processed audio variant. See `types/processing.ts`.
|
|
1066
1162
|
*/
|
|
1067
1163
|
processing: z.ZodOptional<z.ZodObject<{
|
|
1068
1164
|
transcribe: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
1069
1165
|
denoise: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
1166
|
+
trim: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
1167
|
+
waveform: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
1070
1168
|
}, "strip", z.ZodTypeAny, {
|
|
1071
|
-
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1072
1169
|
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1073
|
-
|
|
1170
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1074
1171
|
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1172
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1173
|
+
}, {
|
|
1075
1174
|
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1175
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1176
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1177
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1076
1178
|
}>>;
|
|
1077
1179
|
}, "strip", z.ZodTypeAny, {
|
|
1078
1180
|
$type: "dev.antiphony.embed.audio#view";
|
|
1079
1181
|
url: string;
|
|
1182
|
+
waveform?: number[] | undefined;
|
|
1080
1183
|
durationMs?: number | undefined;
|
|
1081
1184
|
alt?: string | undefined;
|
|
1082
|
-
waveform?: number[] | undefined;
|
|
1083
1185
|
transcript?: {
|
|
1084
1186
|
segments: {
|
|
1085
1187
|
startMs: number;
|
|
@@ -1089,15 +1191,17 @@ declare const AudioPostViewSchema: z.ZodObject<{
|
|
|
1089
1191
|
text?: string | undefined;
|
|
1090
1192
|
} | undefined;
|
|
1091
1193
|
processing?: {
|
|
1092
|
-
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1093
1194
|
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1195
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1196
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1197
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1094
1198
|
} | undefined;
|
|
1095
1199
|
}, {
|
|
1096
1200
|
$type: "dev.antiphony.embed.audio#view";
|
|
1097
1201
|
url: string;
|
|
1202
|
+
waveform?: number[] | undefined;
|
|
1098
1203
|
durationMs?: number | undefined;
|
|
1099
1204
|
alt?: string | undefined;
|
|
1100
|
-
waveform?: number[] | undefined;
|
|
1101
1205
|
transcript?: {
|
|
1102
1206
|
segments: {
|
|
1103
1207
|
startMs: number;
|
|
@@ -1107,8 +1211,10 @@ declare const AudioPostViewSchema: z.ZodObject<{
|
|
|
1107
1211
|
text?: string | undefined;
|
|
1108
1212
|
} | undefined;
|
|
1109
1213
|
processing?: {
|
|
1110
|
-
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1111
1214
|
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1215
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1216
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1217
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1112
1218
|
} | undefined;
|
|
1113
1219
|
}>>;
|
|
1114
1220
|
viewer: z.ZodObject<{
|
|
@@ -1162,9 +1268,9 @@ declare const AudioPostViewSchema: z.ZodObject<{
|
|
|
1162
1268
|
embed?: {
|
|
1163
1269
|
$type: "dev.antiphony.embed.audio#view";
|
|
1164
1270
|
url: string;
|
|
1271
|
+
waveform?: number[] | undefined;
|
|
1165
1272
|
durationMs?: number | undefined;
|
|
1166
1273
|
alt?: string | undefined;
|
|
1167
|
-
waveform?: number[] | undefined;
|
|
1168
1274
|
transcript?: {
|
|
1169
1275
|
segments: {
|
|
1170
1276
|
startMs: number;
|
|
@@ -1174,8 +1280,10 @@ declare const AudioPostViewSchema: z.ZodObject<{
|
|
|
1174
1280
|
text?: string | undefined;
|
|
1175
1281
|
} | undefined;
|
|
1176
1282
|
processing?: {
|
|
1177
|
-
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1178
1283
|
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1284
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1285
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1286
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1179
1287
|
} | undefined;
|
|
1180
1288
|
} | undefined;
|
|
1181
1289
|
}, {
|
|
@@ -1209,9 +1317,9 @@ declare const AudioPostViewSchema: z.ZodObject<{
|
|
|
1209
1317
|
embed?: {
|
|
1210
1318
|
$type: "dev.antiphony.embed.audio#view";
|
|
1211
1319
|
url: string;
|
|
1320
|
+
waveform?: number[] | undefined;
|
|
1212
1321
|
durationMs?: number | undefined;
|
|
1213
1322
|
alt?: string | undefined;
|
|
1214
|
-
waveform?: number[] | undefined;
|
|
1215
1323
|
transcript?: {
|
|
1216
1324
|
segments: {
|
|
1217
1325
|
startMs: number;
|
|
@@ -1221,8 +1329,10 @@ declare const AudioPostViewSchema: z.ZodObject<{
|
|
|
1221
1329
|
text?: string | undefined;
|
|
1222
1330
|
} | undefined;
|
|
1223
1331
|
processing?: {
|
|
1224
|
-
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1225
1332
|
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1333
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1334
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1335
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
1226
1336
|
} | undefined;
|
|
1227
1337
|
} | undefined;
|
|
1228
1338
|
}>;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
|
|
5
|
+
// types/processing.ts
|
|
6
|
+
var FirestoreTimestampSchema = zod.z.union([
|
|
7
|
+
zod.z.custom((data) => {
|
|
8
|
+
return data && typeof data === "object" && (typeof data.toDate === "function" || "seconds" in data && "nanoseconds" in data);
|
|
9
|
+
}),
|
|
10
|
+
zod.z.string(),
|
|
11
|
+
zod.z.number(),
|
|
12
|
+
zod.z.date()
|
|
13
|
+
]).transform((data, ctx) => {
|
|
14
|
+
let date;
|
|
15
|
+
if (data instanceof Date) {
|
|
16
|
+
date = data;
|
|
17
|
+
} else if (typeof data === "string") {
|
|
18
|
+
date = new Date(data);
|
|
19
|
+
} else if (typeof data === "number") {
|
|
20
|
+
date = new Date(data);
|
|
21
|
+
} else if (typeof data.toDate === "function") {
|
|
22
|
+
date = data.toDate();
|
|
23
|
+
} else {
|
|
24
|
+
const timestamp = data;
|
|
25
|
+
date = new Date(timestamp.seconds * 1e3 + timestamp.nanoseconds / 1e6);
|
|
26
|
+
}
|
|
27
|
+
if (Number.isNaN(date.getTime())) {
|
|
28
|
+
ctx.addIssue({
|
|
29
|
+
code: zod.z.ZodIssueCode.custom,
|
|
30
|
+
message: "FirestoreTimestamp coerced to Invalid Date"
|
|
31
|
+
});
|
|
32
|
+
return zod.z.NEVER;
|
|
33
|
+
}
|
|
34
|
+
return date;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// types/processing.ts
|
|
38
|
+
var ProcessingStageStatusSchema = zod.z.enum(["pending", "ready", "failed", "skipped"]);
|
|
39
|
+
var PROCESSING_STAGES = ["denoise", "trim", "transcribe", "waveform"];
|
|
40
|
+
var ProcessingStageSchema = zod.z.enum(PROCESSING_STAGES);
|
|
41
|
+
var BYTE_MUTATING_STAGES = ["denoise", "trim"];
|
|
42
|
+
var DERIVED_STAGES = ["transcribe", "waveform"];
|
|
43
|
+
var ProcessingRequestSchema = zod.z.object({
|
|
44
|
+
transcribe: zod.z.boolean().optional(),
|
|
45
|
+
denoise: zod.z.boolean().optional(),
|
|
46
|
+
trim: zod.z.boolean().optional(),
|
|
47
|
+
waveform: zod.z.boolean().optional(),
|
|
48
|
+
/**
|
|
49
|
+
* Whether a completed byte-mutating stage should invalidate and recompute
|
|
50
|
+
* the derived artifacts that describe the old audio. Defaults to **true**
|
|
51
|
+
* — a transcript of superseded audio is wrong, not merely stale.
|
|
52
|
+
*
|
|
53
|
+
* `false` opts out, for an app that would rather keep the existing
|
|
54
|
+
* transcript than pay to regenerate it. It does NOT name a stage, so a
|
|
55
|
+
* request carrying only `reprocess` requests no work.
|
|
56
|
+
*/
|
|
57
|
+
reprocess: zod.z.boolean().optional()
|
|
58
|
+
});
|
|
59
|
+
var ProcessingStageMapSchema = zod.z.object({
|
|
60
|
+
transcribe: ProcessingStageStatusSchema.optional(),
|
|
61
|
+
denoise: ProcessingStageStatusSchema.optional(),
|
|
62
|
+
trim: ProcessingStageStatusSchema.optional(),
|
|
63
|
+
waveform: ProcessingStageStatusSchema.optional()
|
|
64
|
+
});
|
|
65
|
+
var ResolvedProcessingSchema = ProcessingStageMapSchema.extend({
|
|
66
|
+
reprocess: zod.z.boolean().optional()
|
|
67
|
+
});
|
|
68
|
+
var ProcessingStateSchema = ResolvedProcessingSchema.extend({
|
|
69
|
+
/**
|
|
70
|
+
* Content CID of the processed audio variant — the composed output of every
|
|
71
|
+
* byte-mutating stage that has completed. The record's own
|
|
72
|
+
* `embed.audio.ref.$link` stays the ORIGINAL CID (immutable content
|
|
73
|
+
* address); only the read-time view swaps playback to this variant.
|
|
74
|
+
*/
|
|
75
|
+
processedBlobCid: zod.z.string().optional(),
|
|
76
|
+
/**
|
|
77
|
+
* MIME type of the processed variant. Present because providers may
|
|
78
|
+
* TRANSCODE — the ElevenLabs Voice Isolator returns MP3 regardless of what
|
|
79
|
+
* it is given — so the variant's type cannot be assumed to match
|
|
80
|
+
* `embed.audio.mimeType`. Anything reading the variant's bytes must use
|
|
81
|
+
* this, not the embed's.
|
|
82
|
+
*/
|
|
83
|
+
processedMimeType: zod.z.string().optional(),
|
|
84
|
+
/**
|
|
85
|
+
* Duration of the processed variant, when a byte-mutating stage changed it
|
|
86
|
+
* (i.e. trim). Absent when the variant's duration matches the original.
|
|
87
|
+
*/
|
|
88
|
+
processedDurationMs: zod.z.number().int().min(0).optional(),
|
|
89
|
+
/**
|
|
90
|
+
* Which denoiser produced the variant's denoise contribution — provenance,
|
|
91
|
+
* the counterpart to a transcript record's `model`.
|
|
92
|
+
*
|
|
93
|
+
* Lives here because a cleaned variant, unlike a transcript, has no record
|
|
94
|
+
* of its own to carry it: it is a blob CID on this state. Without it,
|
|
95
|
+
* changing denoisers leaves no way to tell which variants predate the
|
|
96
|
+
* switch, so nothing can identify what to re-run.
|
|
97
|
+
*
|
|
98
|
+
* Named for the STAGE, not the variant (`processedModel`), because it
|
|
99
|
+
* describes one link of the byte-mutating chain rather than the composed
|
|
100
|
+
* artifact. Trim contributes to the same variant and has no model, and a
|
|
101
|
+
* later external link would want its own field rather than to overwrite
|
|
102
|
+
* this one.
|
|
103
|
+
*
|
|
104
|
+
* Written on every successful denoise, never cleared — it moves with
|
|
105
|
+
* `processedBlobCid`, which is only ever set, never reset. A denoise that
|
|
106
|
+
* FAILS leaves both alone, which is correct: the variant still holds the
|
|
107
|
+
* previous denoiser's output, so the previous model still describes it.
|
|
108
|
+
*
|
|
109
|
+
* Internal, like the other variant fields — `toProcessingView` projects
|
|
110
|
+
* stages only, so this never reaches a client.
|
|
111
|
+
*/
|
|
112
|
+
denoiseModel: zod.z.string().optional(),
|
|
113
|
+
/**
|
|
114
|
+
* Peaks for the processed variant, once the `waveform` stage completes.
|
|
115
|
+
* Same normalization and bounds as `embed.waveform` (0–100, max 1000), so
|
|
116
|
+
* a view can never carry a larger payload than the record allows.
|
|
117
|
+
*/
|
|
118
|
+
waveformPeaks: zod.z.array(zod.z.number().int().min(0).max(100)).max(1e3).optional(),
|
|
119
|
+
/**
|
|
120
|
+
* When the current runner's exclusive claim on this post expires.
|
|
121
|
+
*
|
|
122
|
+
* Queue delivery is at-least-once, so the same job can arrive twice and
|
|
123
|
+
* run CONCURRENTLY. `process()` is idempotent under sequential retry — it
|
|
124
|
+
* acts on `pending` and re-does nothing already settled — but two passes
|
|
125
|
+
* interleaved is a different failure: both read the same `pending` state,
|
|
126
|
+
* both bill the provider for the same stage, and both write
|
|
127
|
+
* `processedBlobCid`, so the surviving variant is whichever finished last
|
|
128
|
+
* and the other's blob is orphaned.
|
|
129
|
+
*
|
|
130
|
+
* A runner claims this field transactionally before doing any work and
|
|
131
|
+
* clears it when finished; a second runner finding it unexpired declines
|
|
132
|
+
* and returns. It is an EXPIRY, not a boolean lock, because the holder can
|
|
133
|
+
* die mid-run (instance recycled, process killed) with no chance to
|
|
134
|
+
* release — a plain flag would strand the post permanently, where a lapsed
|
|
135
|
+
* lease lets the next delivery pick it up.
|
|
136
|
+
*
|
|
137
|
+
* Internal, like the variant fields above: `toProcessingView` projects
|
|
138
|
+
* stages only, so this never reaches a client.
|
|
139
|
+
*/
|
|
140
|
+
leaseUntil: FirestoreTimestampSchema.optional(),
|
|
141
|
+
updatedAt: FirestoreTimestampSchema
|
|
142
|
+
});
|
|
143
|
+
var ProcessingViewSchema = ProcessingStageMapSchema;
|
|
144
|
+
function toProcessingView(state) {
|
|
145
|
+
const view = {};
|
|
146
|
+
for (const stage of PROCESSING_STAGES) {
|
|
147
|
+
if (state[stage] !== void 0) view[stage] = state[stage];
|
|
148
|
+
}
|
|
149
|
+
return view;
|
|
150
|
+
}
|
|
151
|
+
function resolveAudioVariant(canonical, state) {
|
|
152
|
+
var _a;
|
|
153
|
+
if (!state) return canonical;
|
|
154
|
+
const hasVariant = state.processedBlobCid !== void 0;
|
|
155
|
+
const peaksAreCurrent = state.waveform === "ready" && state.waveformPeaks !== void 0;
|
|
156
|
+
return {
|
|
157
|
+
blobCid: hasVariant ? state.processedBlobCid : canonical.blobCid,
|
|
158
|
+
durationMs: hasVariant ? (_a = state.processedDurationMs) != null ? _a : canonical.durationMs : canonical.durationMs,
|
|
159
|
+
waveform: peaksAreCurrent ? state.waveformPeaks : canonical.waveform
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
exports.BYTE_MUTATING_STAGES = BYTE_MUTATING_STAGES;
|
|
164
|
+
exports.DERIVED_STAGES = DERIVED_STAGES;
|
|
165
|
+
exports.PROCESSING_STAGES = PROCESSING_STAGES;
|
|
166
|
+
exports.ProcessingRequestSchema = ProcessingRequestSchema;
|
|
167
|
+
exports.ProcessingStageMapSchema = ProcessingStageMapSchema;
|
|
168
|
+
exports.ProcessingStageSchema = ProcessingStageSchema;
|
|
169
|
+
exports.ProcessingStageStatusSchema = ProcessingStageStatusSchema;
|
|
170
|
+
exports.ProcessingStateSchema = ProcessingStateSchema;
|
|
171
|
+
exports.ProcessingViewSchema = ProcessingViewSchema;
|
|
172
|
+
exports.ResolvedProcessingSchema = ResolvedProcessingSchema;
|
|
173
|
+
exports.resolveAudioVariant = resolveAudioVariant;
|
|
174
|
+
exports.toProcessingView = toProcessingView;
|