@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
package/dist/esm/types/audio.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { ActorProfileRecordSchema, AudioEmbedSchema, AudioEmbedViewSchema, AudioPostRecordSchema, AudioPostViewSchema, PostRecordPublicSchema, ReplyRefSchema, StrongRefSchema, TimedTranscriptSchema, TranscriptEnrichmentRecordSchema, TranscriptSegmentSchema, ViewerStateSchema } from '../chunk-
|
|
1
|
+
export { ActorProfileRecordSchema, AudioEmbedSchema, AudioEmbedViewSchema, AudioPostRecordSchema, AudioPostViewSchema, PostRecordPublicSchema, ReplyRefSchema, StrongRefSchema, TimedTranscriptSchema, TranscriptEnrichmentRecordSchema, TranscriptSegmentSchema, ViewerStateSchema } from '../chunk-J2HE6PE2.js';
|
|
2
|
+
import '../chunk-AKIWUNNK.js';
|
|
2
3
|
import '../chunk-D655OH2I.js';
|
|
3
4
|
import '../chunk-SMK4OZNU.js';
|
|
4
5
|
import '../chunk-5JBD5THX.js';
|
|
@@ -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
|
+
waveform?: boolean | undefined;
|
|
84
|
+
transcribe?: boolean | undefined;
|
|
85
|
+
denoise?: boolean | undefined;
|
|
86
|
+
trim?: boolean | undefined;
|
|
87
|
+
reprocess?: boolean | undefined;
|
|
88
|
+
}, {
|
|
89
|
+
waveform?: boolean | undefined;
|
|
90
|
+
transcribe?: boolean | undefined;
|
|
91
|
+
denoise?: boolean | undefined;
|
|
92
|
+
trim?: 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
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
108
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
109
|
+
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
110
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
111
|
+
}, {
|
|
112
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
113
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
114
|
+
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
115
|
+
trim?: "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
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
137
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
138
|
+
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
139
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
140
|
+
reprocess?: boolean | undefined;
|
|
141
|
+
}, {
|
|
142
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
143
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
144
|
+
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
145
|
+
trim?: "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
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
249
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
250
|
+
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
251
|
+
trim?: "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
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
261
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
262
|
+
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
263
|
+
trim?: "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
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
286
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
287
|
+
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
288
|
+
trim?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
289
|
+
}, {
|
|
290
|
+
waveform?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
291
|
+
transcribe?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
292
|
+
denoise?: "pending" | "ready" | "failed" | "skipped" | undefined;
|
|
293
|
+
trim?: "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 };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { BYTE_MUTATING_STAGES, DERIVED_STAGES, PROCESSING_STAGES, ProcessingRequestSchema, ProcessingStageMapSchema, ProcessingStageSchema, ProcessingStageStatusSchema, ProcessingStateSchema, ProcessingViewSchema, ResolvedProcessingSchema, resolveAudioVariant, toProcessingView } from '../chunk-AKIWUNNK.js';
|
|
2
|
+
import '../chunk-D655OH2I.js';
|
|
3
|
+
import '../chunk-5JBD5THX.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antiphony/shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Shared types, Zod schemas, and codecs for Antiphony — open audio call-and-response infrastructure and AT Protocol lexicons.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://docs.antiphony.dev",
|
|
@@ -131,15 +131,19 @@
|
|
|
131
131
|
},
|
|
132
132
|
"scripts": {
|
|
133
133
|
"build": "node ./scripts/clean.mjs && tsup",
|
|
134
|
+
"//prepare": "Every export in this package resolves into dist/, so a tree without it cannot be typechecked by the workspaces that consume it (apps/reference imports @antiphony/shared/* directly). npm runs prepare for workspace packages on install, which makes `git clone && npm ci && npm run typecheck` work on a cold checkout instead of only on a machine that happens to have built already.",
|
|
135
|
+
"prepare": "npm run build",
|
|
134
136
|
"typecheck": "tsc --noEmit",
|
|
135
|
-
"lint": "eslint .",
|
|
137
|
+
"lint": "eslint . --max-warnings=0",
|
|
136
138
|
"test": "vitest run"
|
|
137
139
|
},
|
|
138
140
|
"dependencies": {
|
|
139
141
|
"zod": "^3.24.1"
|
|
140
142
|
},
|
|
141
143
|
"devDependencies": {
|
|
144
|
+
"@eslint/js": "^9.39.2",
|
|
142
145
|
"tsup": "^8.5.1",
|
|
146
|
+
"typescript-eslint": "^8.18.0",
|
|
143
147
|
"typescript": "^5.7.2",
|
|
144
148
|
"vitest": "^4.1.9"
|
|
145
149
|
}
|