@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
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Audio hygiene / enrichment processing (B5).
|
|
5
|
+
*
|
|
6
|
+
* Antiphony can, when the calling app opts in, run audio processing on a
|
|
7
|
+
* post's audio. Four stages, classified on two axes (see
|
|
8
|
+
* `specs/enrichment-pipeline.md`):
|
|
9
|
+
*
|
|
10
|
+
* - **Byte-mutating** (`denoise`, `trim`) produce new audio. They compose in
|
|
11
|
+
* order into a SINGLE processed variant — trimmed-and-denoised audio is one
|
|
12
|
+
* artifact, not two — addressed by `processedBlobCid`.
|
|
13
|
+
* - **Derived** (`transcribe`, `waveform`) are pure analysis over the final
|
|
14
|
+
* variant and modify no audio. Because they are a function of the variant,
|
|
15
|
+
* recomputation is always the correct response to their input changing.
|
|
16
|
+
*
|
|
17
|
+
* Every stage is OFF by default — the app asks for them per post via
|
|
18
|
+
* `CreateAudioPostRequest.processing`, or after the fact via the `processing`
|
|
19
|
+
* opt-in on `PATCH /api/v1/posts/{postId}`.
|
|
20
|
+
*
|
|
21
|
+
* The work runs asynchronously (outside the create request), so a post
|
|
22
|
+
* carries a mutable `processing` state that starts `pending` and settles to
|
|
23
|
+
* `ready`/`failed`/`skipped` per stage. That state is a storage-layer field —
|
|
24
|
+
* it is NOT part of the canonical lexicon record and never enters the record
|
|
25
|
+
* CID (like `kind` and `threadParticipants`), so processing can update it
|
|
26
|
+
* without changing the post's content address.
|
|
27
|
+
*
|
|
28
|
+
* That immutability is why stage OUTPUT lives here rather than on the embed:
|
|
29
|
+
* `embed.audio.ref.$link`, `embed.durationMs`, and `embed.waveform` are inside
|
|
30
|
+
* the CID and can never be rewritten. The read-time view resolves per field
|
|
31
|
+
* between the record's canonical values and the variant values below.
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* Per-stage status.
|
|
35
|
+
* - `pending` — requested, not yet done (the worker acts on these).
|
|
36
|
+
* - `ready` — completed.
|
|
37
|
+
* - `failed` — attempted and errored.
|
|
38
|
+
* - `skipped` — requested but this deployment has no provider for it.
|
|
39
|
+
*
|
|
40
|
+
* A stage returning to `pending` after having been `ready` is NORMAL, not a
|
|
41
|
+
* regression: a byte-mutating stage completing invalidates derived artifacts,
|
|
42
|
+
* which are then recomputed. Clients treat any `pending` stage as "still
|
|
43
|
+
* working", which already covers this.
|
|
44
|
+
*/
|
|
45
|
+
declare const ProcessingStageStatusSchema: z.ZodEnum<["pending", "ready", "failed", "skipped"]>;
|
|
46
|
+
type ProcessingStageStatus = z.infer<typeof ProcessingStageStatusSchema>;
|
|
47
|
+
/**
|
|
48
|
+
* The stage names, in the order a multi-stage request runs them:
|
|
49
|
+
* denoise → trim → (transcribe, waveform).
|
|
50
|
+
*
|
|
51
|
+
* All byte-mutating stages run first; the two derived stages then consume the
|
|
52
|
+
* final variant and are mutually independent. Denoise precedes trim
|
|
53
|
+
* deliberately — silence detection keys off a noise floor, so on noisy input
|
|
54
|
+
* the "silence" is not actually quiet and trim under-cuts.
|
|
55
|
+
*/
|
|
56
|
+
declare const PROCESSING_STAGES: readonly ["denoise", "trim", "transcribe", "waveform"];
|
|
57
|
+
declare const ProcessingStageSchema: z.ZodEnum<["denoise", "trim", "transcribe", "waveform"]>;
|
|
58
|
+
type ProcessingStage = z.infer<typeof ProcessingStageSchema>;
|
|
59
|
+
/** Stages that produce new audio bytes, composing into one processed variant. */
|
|
60
|
+
declare const BYTE_MUTATING_STAGES: readonly ["denoise", "trim"];
|
|
61
|
+
/** Stages that are pure analysis over the final variant, modifying no audio. */
|
|
62
|
+
declare const DERIVED_STAGES: readonly ["transcribe", "waveform"];
|
|
63
|
+
/**
|
|
64
|
+
* What the calling app opts into, on `CreateAudioPostRequest`. All default
|
|
65
|
+
* off; only `true` values request a stage.
|
|
66
|
+
*/
|
|
67
|
+
declare const ProcessingRequestSchema: z.ZodObject<{
|
|
68
|
+
transcribe: z.ZodOptional<z.ZodBoolean>;
|
|
69
|
+
denoise: z.ZodOptional<z.ZodBoolean>;
|
|
70
|
+
trim: z.ZodOptional<z.ZodBoolean>;
|
|
71
|
+
waveform: z.ZodOptional<z.ZodBoolean>;
|
|
72
|
+
/**
|
|
73
|
+
* Whether a completed byte-mutating stage should invalidate and recompute
|
|
74
|
+
* the derived artifacts that describe the old audio. Defaults to **true**
|
|
75
|
+
* — a transcript of superseded audio is wrong, not merely stale.
|
|
76
|
+
*
|
|
77
|
+
* `false` opts out, for an app that would rather keep the existing
|
|
78
|
+
* transcript than pay to regenerate it. It does NOT name a stage, so a
|
|
79
|
+
* request carrying only `reprocess` requests no work.
|
|
80
|
+
*/
|
|
81
|
+
reprocess: z.ZodOptional<z.ZodBoolean>;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
denoise?: boolean | undefined;
|
|
84
|
+
trim?: boolean | undefined;
|
|
85
|
+
transcribe?: boolean | undefined;
|
|
86
|
+
waveform?: boolean | undefined;
|
|
87
|
+
reprocess?: boolean | undefined;
|
|
88
|
+
}, {
|
|
89
|
+
denoise?: boolean | undefined;
|
|
90
|
+
trim?: boolean | undefined;
|
|
91
|
+
transcribe?: boolean | undefined;
|
|
92
|
+
waveform?: boolean | undefined;
|
|
93
|
+
reprocess?: boolean | undefined;
|
|
94
|
+
}>;
|
|
95
|
+
type ProcessingRequest = z.infer<typeof ProcessingRequestSchema>;
|
|
96
|
+
/**
|
|
97
|
+
* Per-stage status across all stages — the shape shared by the stored state,
|
|
98
|
+
* the hydrated view, and the resolved-initial-state handoff between the route
|
|
99
|
+
* and the service. A key is present iff that stage was requested.
|
|
100
|
+
*/
|
|
101
|
+
declare const ProcessingStageMapSchema: z.ZodObject<{
|
|
102
|
+
transcribe: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
103
|
+
denoise: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
104
|
+
trim: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
105
|
+
waveform: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
106
|
+
}, "strip", z.ZodTypeAny, {
|
|
107
|
+
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
108
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
109
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
110
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
111
|
+
}, {
|
|
112
|
+
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
113
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
114
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
115
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
116
|
+
}>;
|
|
117
|
+
type ProcessingStageMap = z.infer<typeof ProcessingStageMapSchema>;
|
|
118
|
+
/**
|
|
119
|
+
* An opt-in request resolved against a deployment's capabilities: the initial
|
|
120
|
+
* per-stage state plus the settings the async worker needs to honour it.
|
|
121
|
+
*
|
|
122
|
+
* `reprocess` is carried here — and persisted — rather than passed to the
|
|
123
|
+
* worker as an argument, because the request that asks for the work and the
|
|
124
|
+
* pass that performs it are separated by a queue (step 8). Written on every
|
|
125
|
+
* request including the default, because the stored state is MERGED onto —
|
|
126
|
+
* absent means true only for posts written before this field existed.
|
|
127
|
+
*/
|
|
128
|
+
declare const ResolvedProcessingSchema: z.ZodObject<{
|
|
129
|
+
transcribe: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
130
|
+
denoise: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
131
|
+
trim: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
132
|
+
waveform: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
133
|
+
} & {
|
|
134
|
+
reprocess: z.ZodOptional<z.ZodBoolean>;
|
|
135
|
+
}, "strip", z.ZodTypeAny, {
|
|
136
|
+
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
137
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
138
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
139
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
140
|
+
reprocess?: boolean | undefined;
|
|
141
|
+
}, {
|
|
142
|
+
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
143
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
144
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
145
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
146
|
+
reprocess?: boolean | undefined;
|
|
147
|
+
}>;
|
|
148
|
+
type ResolvedProcessing = z.infer<typeof ResolvedProcessingSchema>;
|
|
149
|
+
/**
|
|
150
|
+
* Stored processing state on the post record (storage-layer; not in the CID):
|
|
151
|
+
* the per-stage statuses plus the output of the stages themselves.
|
|
152
|
+
*
|
|
153
|
+
* The variant fields below all exist for the same reason — their canonical
|
|
154
|
+
* counterparts live inside the record CID and cannot be updated:
|
|
155
|
+
*
|
|
156
|
+
* - `processedBlobCid` ↔ `embed.audio.ref.$link`
|
|
157
|
+
* - `processedMimeType` ↔ `embed.audio.mimeType` (providers may transcode)
|
|
158
|
+
* - `processedDurationMs` ↔ `embed.durationMs` (trim changes duration)
|
|
159
|
+
* - `waveformPeaks` ↔ `embed.waveform` (the client's peaks describe the original)
|
|
160
|
+
*
|
|
161
|
+
* `denoiseModel` is the exception: it has no canonical counterpart at all. It
|
|
162
|
+
* is provenance for the variant, recorded here because the variant is a blob
|
|
163
|
+
* CID rather than a record that could carry its own.
|
|
164
|
+
*/
|
|
165
|
+
declare const ProcessingStateSchema: z.ZodObject<{
|
|
166
|
+
transcribe: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
167
|
+
denoise: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
168
|
+
trim: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
169
|
+
waveform: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
170
|
+
} & {
|
|
171
|
+
reprocess: z.ZodOptional<z.ZodBoolean>;
|
|
172
|
+
} & {
|
|
173
|
+
/**
|
|
174
|
+
* Content CID of the processed audio variant — the composed output of every
|
|
175
|
+
* byte-mutating stage that has completed. The record's own
|
|
176
|
+
* `embed.audio.ref.$link` stays the ORIGINAL CID (immutable content
|
|
177
|
+
* address); only the read-time view swaps playback to this variant.
|
|
178
|
+
*/
|
|
179
|
+
processedBlobCid: z.ZodOptional<z.ZodString>;
|
|
180
|
+
/**
|
|
181
|
+
* MIME type of the processed variant. Present because providers may
|
|
182
|
+
* TRANSCODE — the ElevenLabs Voice Isolator returns MP3 regardless of what
|
|
183
|
+
* it is given — so the variant's type cannot be assumed to match
|
|
184
|
+
* `embed.audio.mimeType`. Anything reading the variant's bytes must use
|
|
185
|
+
* this, not the embed's.
|
|
186
|
+
*/
|
|
187
|
+
processedMimeType: z.ZodOptional<z.ZodString>;
|
|
188
|
+
/**
|
|
189
|
+
* Duration of the processed variant, when a byte-mutating stage changed it
|
|
190
|
+
* (i.e. trim). Absent when the variant's duration matches the original.
|
|
191
|
+
*/
|
|
192
|
+
processedDurationMs: z.ZodOptional<z.ZodNumber>;
|
|
193
|
+
/**
|
|
194
|
+
* Which denoiser produced the variant's denoise contribution — provenance,
|
|
195
|
+
* the counterpart to a transcript record's `model`.
|
|
196
|
+
*
|
|
197
|
+
* Lives here because a cleaned variant, unlike a transcript, has no record
|
|
198
|
+
* of its own to carry it: it is a blob CID on this state. Without it,
|
|
199
|
+
* changing denoisers leaves no way to tell which variants predate the
|
|
200
|
+
* switch, so nothing can identify what to re-run.
|
|
201
|
+
*
|
|
202
|
+
* Named for the STAGE, not the variant (`processedModel`), because it
|
|
203
|
+
* describes one link of the byte-mutating chain rather than the composed
|
|
204
|
+
* artifact. Trim contributes to the same variant and has no model, and a
|
|
205
|
+
* later external link would want its own field rather than to overwrite
|
|
206
|
+
* this one.
|
|
207
|
+
*
|
|
208
|
+
* Written on every successful denoise, never cleared — it moves with
|
|
209
|
+
* `processedBlobCid`, which is only ever set, never reset. A denoise that
|
|
210
|
+
* FAILS leaves both alone, which is correct: the variant still holds the
|
|
211
|
+
* previous denoiser's output, so the previous model still describes it.
|
|
212
|
+
*
|
|
213
|
+
* Internal, like the other variant fields — `toProcessingView` projects
|
|
214
|
+
* stages only, so this never reaches a client.
|
|
215
|
+
*/
|
|
216
|
+
denoiseModel: z.ZodOptional<z.ZodString>;
|
|
217
|
+
/**
|
|
218
|
+
* Peaks for the processed variant, once the `waveform` stage completes.
|
|
219
|
+
* Same normalization and bounds as `embed.waveform` (0–100, max 1000), so
|
|
220
|
+
* a view can never carry a larger payload than the record allows.
|
|
221
|
+
*/
|
|
222
|
+
waveformPeaks: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
223
|
+
/**
|
|
224
|
+
* When the current runner's exclusive claim on this post expires.
|
|
225
|
+
*
|
|
226
|
+
* Queue delivery is at-least-once, so the same job can arrive twice and
|
|
227
|
+
* run CONCURRENTLY. `process()` is idempotent under sequential retry — it
|
|
228
|
+
* acts on `pending` and re-does nothing already settled — but two passes
|
|
229
|
+
* interleaved is a different failure: both read the same `pending` state,
|
|
230
|
+
* both bill the provider for the same stage, and both write
|
|
231
|
+
* `processedBlobCid`, so the surviving variant is whichever finished last
|
|
232
|
+
* and the other's blob is orphaned.
|
|
233
|
+
*
|
|
234
|
+
* A runner claims this field transactionally before doing any work and
|
|
235
|
+
* clears it when finished; a second runner finding it unexpired declines
|
|
236
|
+
* and returns. It is an EXPIRY, not a boolean lock, because the holder can
|
|
237
|
+
* die mid-run (instance recycled, process killed) with no chance to
|
|
238
|
+
* release — a plain flag would strand the post permanently, where a lapsed
|
|
239
|
+
* lease lets the next delivery pick it up.
|
|
240
|
+
*
|
|
241
|
+
* Internal, like the variant fields above: `toProcessingView` projects
|
|
242
|
+
* stages only, so this never reaches a client.
|
|
243
|
+
*/
|
|
244
|
+
leaseUntil: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodString, z.ZodNumber, z.ZodDate]>, Date, unknown>>;
|
|
245
|
+
updatedAt: z.ZodEffects<z.ZodUnion<[z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodString, z.ZodNumber, z.ZodDate]>, Date, unknown>;
|
|
246
|
+
}, "strip", z.ZodTypeAny, {
|
|
247
|
+
updatedAt: Date;
|
|
248
|
+
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
249
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
250
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
251
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
252
|
+
reprocess?: boolean | undefined;
|
|
253
|
+
processedBlobCid?: string | undefined;
|
|
254
|
+
processedMimeType?: string | undefined;
|
|
255
|
+
processedDurationMs?: number | undefined;
|
|
256
|
+
denoiseModel?: string | undefined;
|
|
257
|
+
waveformPeaks?: number[] | undefined;
|
|
258
|
+
leaseUntil?: Date | undefined;
|
|
259
|
+
}, {
|
|
260
|
+
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
261
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
262
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
263
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
264
|
+
reprocess?: boolean | undefined;
|
|
265
|
+
processedBlobCid?: string | undefined;
|
|
266
|
+
processedMimeType?: string | undefined;
|
|
267
|
+
processedDurationMs?: number | undefined;
|
|
268
|
+
denoiseModel?: string | undefined;
|
|
269
|
+
waveformPeaks?: number[] | undefined;
|
|
270
|
+
leaseUntil?: unknown;
|
|
271
|
+
updatedAt?: unknown;
|
|
272
|
+
}>;
|
|
273
|
+
type ProcessingState = z.infer<typeof ProcessingStateSchema>;
|
|
274
|
+
/**
|
|
275
|
+
* The processing status surfaced on the hydrated view — the per-stage status
|
|
276
|
+
* only (no internal storage fields: variant CID, duration, peaks, timestamps).
|
|
277
|
+
* Absent when no processing was requested.
|
|
278
|
+
*/
|
|
279
|
+
declare const ProcessingViewSchema: z.ZodObject<{
|
|
280
|
+
transcribe: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
281
|
+
denoise: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
282
|
+
trim: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
283
|
+
waveform: z.ZodOptional<z.ZodEnum<["pending", "ready", "failed", "skipped"]>>;
|
|
284
|
+
}, "strip", z.ZodTypeAny, {
|
|
285
|
+
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
286
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
287
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
288
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
289
|
+
}, {
|
|
290
|
+
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
291
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
292
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
293
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
294
|
+
}>;
|
|
295
|
+
type ProcessingView = z.infer<typeof ProcessingViewSchema>;
|
|
296
|
+
/**
|
|
297
|
+
* Project the stored state onto the view — drops every internal field.
|
|
298
|
+
*
|
|
299
|
+
* Derived from `PROCESSING_STAGES` rather than listing the stages by hand, so
|
|
300
|
+
* a stage added to the set cannot be silently omitted from the view (which
|
|
301
|
+
* would leave clients unable to tell "not requested" from "in progress").
|
|
302
|
+
*/
|
|
303
|
+
declare function toProcessingView(state: ProcessingState): ProcessingView;
|
|
304
|
+
/** The record's own audio fields — canonical, inside the CID, never rewritten. */
|
|
305
|
+
interface CanonicalAudioFields {
|
|
306
|
+
blobCid: string;
|
|
307
|
+
durationMs?: number;
|
|
308
|
+
waveform?: number[];
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Resolve the audio fields a reader should see: canonical from the record,
|
|
312
|
+
* variant from `ProcessingState` wherever processing has superseded it.
|
|
313
|
+
*
|
|
314
|
+
* The three fields have to move together. Peaks are rendered ACROSS a duration
|
|
315
|
+
* and a duration describes a specific set of bytes, so serving a processed URL
|
|
316
|
+
* beside the original duration puts a scrubber out of alignment with the audio
|
|
317
|
+
* under it — the failure this function exists to prevent.
|
|
318
|
+
*
|
|
319
|
+
* Resolution is not a uniform `??` per field, because the state's fields do not
|
|
320
|
+
* all mean the same thing when absent:
|
|
321
|
+
*
|
|
322
|
+
* - `processedDurationMs` absent is DEFINED as "the variant's duration equals
|
|
323
|
+
* the original" (denoise transcodes without retiming), so falling back to
|
|
324
|
+
* the record there is correct, not a guess.
|
|
325
|
+
* - `waveformPeaks` carries no such guarantee. Recompute marks the stage
|
|
326
|
+
* `pending` without clearing the field, so between a variant change and the
|
|
327
|
+
* recomputed peaks landing it holds peaks for the SUPERSEDED variant. Hence
|
|
328
|
+
* the status gate rather than a presence check.
|
|
329
|
+
*
|
|
330
|
+
* Peaks do not key off `processedBlobCid`: `waveform` always runs over the
|
|
331
|
+
* final variant, so when it is `ready` its peaks describe whatever playback
|
|
332
|
+
* resolves to here, variant or original alike.
|
|
333
|
+
*/
|
|
334
|
+
declare function resolveAudioVariant(canonical: CanonicalAudioFields, state: ProcessingState | undefined): CanonicalAudioFields;
|
|
335
|
+
|
|
336
|
+
export { BYTE_MUTATING_STAGES, type CanonicalAudioFields, DERIVED_STAGES, PROCESSING_STAGES, type ProcessingRequest, ProcessingRequestSchema, type ProcessingStage, type ProcessingStageMap, ProcessingStageMapSchema, ProcessingStageSchema, type ProcessingStageStatus, ProcessingStageStatusSchema, type ProcessingState, ProcessingStateSchema, type ProcessingView, ProcessingViewSchema, type ResolvedProcessing, ResolvedProcessingSchema, resolveAudioVariant, toProcessingView };
|
package/dist/esm/api-codecs.d.ts
CHANGED
|
@@ -116,37 +116,34 @@ declare const CreateAudioPostRequestSchema: z.ZodEffects<z.ZodEffects<z.ZodObjec
|
|
|
116
116
|
/** Author self-label values (content warnings). */
|
|
117
117
|
selfLabels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
118
118
|
/**
|
|
119
|
-
* Opt-in audio processing for this post's audio (
|
|
120
|
-
*
|
|
121
|
-
* `skipped` on the view rather than failing the
|
|
119
|
+
* Opt-in audio processing for this post's audio (denoise / trim /
|
|
120
|
+
* transcribe / waveform). All default off. Stages the deployment can't
|
|
121
|
+
* provide come back marked `skipped` on the view rather than failing the
|
|
122
|
+
* create. A multi-stage request runs denoise → trim → (transcribe,
|
|
123
|
+
* waveform); request stages individually to override that order. See
|
|
122
124
|
* `types/processing.ts`.
|
|
123
125
|
*/
|
|
124
126
|
processing: z.ZodOptional<z.ZodObject<{
|
|
125
127
|
transcribe: z.ZodOptional<z.ZodBoolean>;
|
|
126
128
|
denoise: z.ZodOptional<z.ZodBoolean>;
|
|
129
|
+
trim: z.ZodOptional<z.ZodBoolean>;
|
|
130
|
+
waveform: z.ZodOptional<z.ZodBoolean>;
|
|
131
|
+
reprocess: z.ZodOptional<z.ZodBoolean>;
|
|
127
132
|
}, "strip", z.ZodTypeAny, {
|
|
133
|
+
waveform?: boolean | undefined;
|
|
128
134
|
transcribe?: boolean | undefined;
|
|
129
135
|
denoise?: boolean | undefined;
|
|
136
|
+
trim?: boolean | undefined;
|
|
137
|
+
reprocess?: boolean | undefined;
|
|
130
138
|
}, {
|
|
139
|
+
waveform?: boolean | undefined;
|
|
131
140
|
transcribe?: boolean | undefined;
|
|
132
141
|
denoise?: boolean | undefined;
|
|
142
|
+
trim?: boolean | undefined;
|
|
143
|
+
reprocess?: boolean | undefined;
|
|
133
144
|
}>>;
|
|
134
145
|
}, "strip", z.ZodTypeAny, {
|
|
135
146
|
text: string;
|
|
136
|
-
processing?: {
|
|
137
|
-
transcribe?: boolean | undefined;
|
|
138
|
-
denoise?: boolean | undefined;
|
|
139
|
-
} | undefined;
|
|
140
|
-
reply?: {
|
|
141
|
-
root: {
|
|
142
|
-
uri: string;
|
|
143
|
-
cid: string;
|
|
144
|
-
};
|
|
145
|
-
parent: {
|
|
146
|
-
uri: string;
|
|
147
|
-
cid: string;
|
|
148
|
-
};
|
|
149
|
-
} | undefined;
|
|
150
147
|
title?: string | undefined;
|
|
151
148
|
embed?: {
|
|
152
149
|
$type: "dev.antiphony.embed.audio";
|
|
@@ -162,14 +159,6 @@ declare const CreateAudioPostRequestSchema: z.ZodEffects<z.ZodEffects<z.ZodObjec
|
|
|
162
159
|
alt?: string | undefined;
|
|
163
160
|
waveform?: number[] | undefined;
|
|
164
161
|
} | undefined;
|
|
165
|
-
langs?: string[] | undefined;
|
|
166
|
-
selfLabels?: string[] | undefined;
|
|
167
|
-
}, {
|
|
168
|
-
text?: string | undefined;
|
|
169
|
-
processing?: {
|
|
170
|
-
transcribe?: boolean | undefined;
|
|
171
|
-
denoise?: boolean | undefined;
|
|
172
|
-
} | undefined;
|
|
173
162
|
reply?: {
|
|
174
163
|
root: {
|
|
175
164
|
uri: string;
|
|
@@ -180,6 +169,17 @@ declare const CreateAudioPostRequestSchema: z.ZodEffects<z.ZodEffects<z.ZodObjec
|
|
|
180
169
|
cid: string;
|
|
181
170
|
};
|
|
182
171
|
} | undefined;
|
|
172
|
+
langs?: string[] | undefined;
|
|
173
|
+
selfLabels?: string[] | undefined;
|
|
174
|
+
processing?: {
|
|
175
|
+
waveform?: boolean | undefined;
|
|
176
|
+
transcribe?: boolean | undefined;
|
|
177
|
+
denoise?: boolean | undefined;
|
|
178
|
+
trim?: boolean | undefined;
|
|
179
|
+
reprocess?: boolean | undefined;
|
|
180
|
+
} | undefined;
|
|
181
|
+
}, {
|
|
182
|
+
text?: string | undefined;
|
|
183
183
|
title?: string | undefined;
|
|
184
184
|
embed?: {
|
|
185
185
|
$type: "dev.antiphony.embed.audio";
|
|
@@ -195,14 +195,6 @@ declare const CreateAudioPostRequestSchema: z.ZodEffects<z.ZodEffects<z.ZodObjec
|
|
|
195
195
|
alt?: string | undefined;
|
|
196
196
|
waveform?: number[] | undefined;
|
|
197
197
|
} | undefined;
|
|
198
|
-
langs?: string[] | undefined;
|
|
199
|
-
selfLabels?: string[] | undefined;
|
|
200
|
-
}>, {
|
|
201
|
-
text: string;
|
|
202
|
-
processing?: {
|
|
203
|
-
transcribe?: boolean | undefined;
|
|
204
|
-
denoise?: boolean | undefined;
|
|
205
|
-
} | undefined;
|
|
206
198
|
reply?: {
|
|
207
199
|
root: {
|
|
208
200
|
uri: string;
|
|
@@ -213,6 +205,17 @@ declare const CreateAudioPostRequestSchema: z.ZodEffects<z.ZodEffects<z.ZodObjec
|
|
|
213
205
|
cid: string;
|
|
214
206
|
};
|
|
215
207
|
} | undefined;
|
|
208
|
+
langs?: string[] | undefined;
|
|
209
|
+
selfLabels?: string[] | undefined;
|
|
210
|
+
processing?: {
|
|
211
|
+
waveform?: boolean | undefined;
|
|
212
|
+
transcribe?: boolean | undefined;
|
|
213
|
+
denoise?: boolean | undefined;
|
|
214
|
+
trim?: boolean | undefined;
|
|
215
|
+
reprocess?: boolean | undefined;
|
|
216
|
+
} | undefined;
|
|
217
|
+
}>, {
|
|
218
|
+
text: string;
|
|
216
219
|
title?: string | undefined;
|
|
217
220
|
embed?: {
|
|
218
221
|
$type: "dev.antiphony.embed.audio";
|
|
@@ -228,14 +231,6 @@ declare const CreateAudioPostRequestSchema: z.ZodEffects<z.ZodEffects<z.ZodObjec
|
|
|
228
231
|
alt?: string | undefined;
|
|
229
232
|
waveform?: number[] | undefined;
|
|
230
233
|
} | undefined;
|
|
231
|
-
langs?: string[] | undefined;
|
|
232
|
-
selfLabels?: string[] | undefined;
|
|
233
|
-
}, {
|
|
234
|
-
text?: string | undefined;
|
|
235
|
-
processing?: {
|
|
236
|
-
transcribe?: boolean | undefined;
|
|
237
|
-
denoise?: boolean | undefined;
|
|
238
|
-
} | undefined;
|
|
239
234
|
reply?: {
|
|
240
235
|
root: {
|
|
241
236
|
uri: string;
|
|
@@ -246,6 +241,17 @@ declare const CreateAudioPostRequestSchema: z.ZodEffects<z.ZodEffects<z.ZodObjec
|
|
|
246
241
|
cid: string;
|
|
247
242
|
};
|
|
248
243
|
} | undefined;
|
|
244
|
+
langs?: string[] | undefined;
|
|
245
|
+
selfLabels?: string[] | undefined;
|
|
246
|
+
processing?: {
|
|
247
|
+
waveform?: boolean | undefined;
|
|
248
|
+
transcribe?: boolean | undefined;
|
|
249
|
+
denoise?: boolean | undefined;
|
|
250
|
+
trim?: boolean | undefined;
|
|
251
|
+
reprocess?: boolean | undefined;
|
|
252
|
+
} | undefined;
|
|
253
|
+
}, {
|
|
254
|
+
text?: string | undefined;
|
|
249
255
|
title?: string | undefined;
|
|
250
256
|
embed?: {
|
|
251
257
|
$type: "dev.antiphony.embed.audio";
|
|
@@ -261,14 +267,6 @@ declare const CreateAudioPostRequestSchema: z.ZodEffects<z.ZodEffects<z.ZodObjec
|
|
|
261
267
|
alt?: string | undefined;
|
|
262
268
|
waveform?: number[] | undefined;
|
|
263
269
|
} | undefined;
|
|
264
|
-
langs?: string[] | undefined;
|
|
265
|
-
selfLabels?: string[] | undefined;
|
|
266
|
-
}>, {
|
|
267
|
-
text: string;
|
|
268
|
-
processing?: {
|
|
269
|
-
transcribe?: boolean | undefined;
|
|
270
|
-
denoise?: boolean | undefined;
|
|
271
|
-
} | undefined;
|
|
272
270
|
reply?: {
|
|
273
271
|
root: {
|
|
274
272
|
uri: string;
|
|
@@ -279,6 +277,17 @@ declare const CreateAudioPostRequestSchema: z.ZodEffects<z.ZodEffects<z.ZodObjec
|
|
|
279
277
|
cid: string;
|
|
280
278
|
};
|
|
281
279
|
} | undefined;
|
|
280
|
+
langs?: string[] | undefined;
|
|
281
|
+
selfLabels?: string[] | undefined;
|
|
282
|
+
processing?: {
|
|
283
|
+
waveform?: boolean | undefined;
|
|
284
|
+
transcribe?: boolean | undefined;
|
|
285
|
+
denoise?: boolean | undefined;
|
|
286
|
+
trim?: boolean | undefined;
|
|
287
|
+
reprocess?: boolean | undefined;
|
|
288
|
+
} | undefined;
|
|
289
|
+
}>, {
|
|
290
|
+
text: string;
|
|
282
291
|
title?: string | undefined;
|
|
283
292
|
embed?: {
|
|
284
293
|
$type: "dev.antiphony.embed.audio";
|
|
@@ -294,14 +303,6 @@ declare const CreateAudioPostRequestSchema: z.ZodEffects<z.ZodEffects<z.ZodObjec
|
|
|
294
303
|
alt?: string | undefined;
|
|
295
304
|
waveform?: number[] | undefined;
|
|
296
305
|
} | undefined;
|
|
297
|
-
langs?: string[] | undefined;
|
|
298
|
-
selfLabels?: string[] | undefined;
|
|
299
|
-
}, {
|
|
300
|
-
text?: string | undefined;
|
|
301
|
-
processing?: {
|
|
302
|
-
transcribe?: boolean | undefined;
|
|
303
|
-
denoise?: boolean | undefined;
|
|
304
|
-
} | undefined;
|
|
305
306
|
reply?: {
|
|
306
307
|
root: {
|
|
307
308
|
uri: string;
|
|
@@ -312,6 +313,17 @@ declare const CreateAudioPostRequestSchema: z.ZodEffects<z.ZodEffects<z.ZodObjec
|
|
|
312
313
|
cid: string;
|
|
313
314
|
};
|
|
314
315
|
} | undefined;
|
|
316
|
+
langs?: string[] | undefined;
|
|
317
|
+
selfLabels?: string[] | undefined;
|
|
318
|
+
processing?: {
|
|
319
|
+
waveform?: boolean | undefined;
|
|
320
|
+
transcribe?: boolean | undefined;
|
|
321
|
+
denoise?: boolean | undefined;
|
|
322
|
+
trim?: boolean | undefined;
|
|
323
|
+
reprocess?: boolean | undefined;
|
|
324
|
+
} | undefined;
|
|
325
|
+
}, {
|
|
326
|
+
text?: string | undefined;
|
|
315
327
|
title?: string | undefined;
|
|
316
328
|
embed?: {
|
|
317
329
|
$type: "dev.antiphony.embed.audio";
|
|
@@ -327,8 +339,25 @@ declare const CreateAudioPostRequestSchema: z.ZodEffects<z.ZodEffects<z.ZodObjec
|
|
|
327
339
|
alt?: string | undefined;
|
|
328
340
|
waveform?: number[] | undefined;
|
|
329
341
|
} | undefined;
|
|
342
|
+
reply?: {
|
|
343
|
+
root: {
|
|
344
|
+
uri: string;
|
|
345
|
+
cid: string;
|
|
346
|
+
};
|
|
347
|
+
parent: {
|
|
348
|
+
uri: string;
|
|
349
|
+
cid: string;
|
|
350
|
+
};
|
|
351
|
+
} | undefined;
|
|
330
352
|
langs?: string[] | undefined;
|
|
331
353
|
selfLabels?: string[] | undefined;
|
|
354
|
+
processing?: {
|
|
355
|
+
waveform?: boolean | undefined;
|
|
356
|
+
transcribe?: boolean | undefined;
|
|
357
|
+
denoise?: boolean | undefined;
|
|
358
|
+
trim?: boolean | undefined;
|
|
359
|
+
reprocess?: boolean | undefined;
|
|
360
|
+
} | undefined;
|
|
332
361
|
}>;
|
|
333
362
|
type CreateAudioPostRequest = z.infer<typeof CreateAudioPostRequestSchema>;
|
|
334
363
|
/**
|
|
@@ -346,22 +375,37 @@ declare const PatchAudioPostRequestSchema: z.ZodObject<{
|
|
|
346
375
|
processing: z.ZodObject<{
|
|
347
376
|
transcribe: z.ZodOptional<z.ZodBoolean>;
|
|
348
377
|
denoise: z.ZodOptional<z.ZodBoolean>;
|
|
378
|
+
trim: z.ZodOptional<z.ZodBoolean>;
|
|
379
|
+
waveform: z.ZodOptional<z.ZodBoolean>;
|
|
380
|
+
reprocess: z.ZodOptional<z.ZodBoolean>;
|
|
349
381
|
}, "strip", z.ZodTypeAny, {
|
|
382
|
+
waveform?: boolean | undefined;
|
|
350
383
|
transcribe?: boolean | undefined;
|
|
351
384
|
denoise?: boolean | undefined;
|
|
385
|
+
trim?: boolean | undefined;
|
|
386
|
+
reprocess?: boolean | undefined;
|
|
352
387
|
}, {
|
|
388
|
+
waveform?: boolean | undefined;
|
|
353
389
|
transcribe?: boolean | undefined;
|
|
354
390
|
denoise?: boolean | undefined;
|
|
391
|
+
trim?: boolean | undefined;
|
|
392
|
+
reprocess?: boolean | undefined;
|
|
355
393
|
}>;
|
|
356
394
|
}, "strip", z.ZodTypeAny, {
|
|
357
395
|
processing: {
|
|
396
|
+
waveform?: boolean | undefined;
|
|
358
397
|
transcribe?: boolean | undefined;
|
|
359
398
|
denoise?: boolean | undefined;
|
|
399
|
+
trim?: boolean | undefined;
|
|
400
|
+
reprocess?: boolean | undefined;
|
|
360
401
|
};
|
|
361
402
|
}, {
|
|
362
403
|
processing: {
|
|
404
|
+
waveform?: boolean | undefined;
|
|
363
405
|
transcribe?: boolean | undefined;
|
|
364
406
|
denoise?: boolean | undefined;
|
|
407
|
+
trim?: boolean | undefined;
|
|
408
|
+
reprocess?: boolean | undefined;
|
|
365
409
|
};
|
|
366
410
|
}>;
|
|
367
411
|
type PatchAudioPostRequest = z.infer<typeof PatchAudioPostRequestSchema>;
|
package/dist/esm/api-codecs.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { CreateAudioPostRequestSchema, PatchAudioPostRequestSchema } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { CreateAudioPostRequestSchema, PatchAudioPostRequestSchema } from './chunk-UYCXRNTK.js';
|
|
2
|
+
import './chunk-J2HE6PE2.js';
|
|
3
|
+
import './chunk-AKIWUNNK.js';
|
|
3
4
|
import './chunk-D655OH2I.js';
|
|
4
5
|
import './chunk-SMK4OZNU.js';
|
|
5
6
|
import './chunk-5JBD5THX.js';
|