@antiphony/shared 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,6 @@
1
- export { ActorProfileRecordSchema, AudioEmbedSchema, AudioEmbedViewSchema, AudioPostRecordSchema, AudioPostViewSchema, PostRecordPublicSchema, ReplyRefSchema, StrongRefSchema, TimedTranscriptSchema, TranscriptEnrichmentRecordSchema, TranscriptSegmentSchema, ViewerStateSchema } from '../chunk-TVOXIQKF.js';
2
- import '../chunk-D655OH2I.js';
1
+ export { ActorProfileRecordSchema, AudioEmbedSchema, AudioEmbedViewSchema, AudioPostRecordSchema, AudioPostViewSchema, PostRecordPublicSchema, ReplyRefSchema, StrongRefSchema, TimedTranscriptSchema, TranscriptEnrichmentRecordSchema, TranscriptSegmentSchema, ViewerStateSchema } from '../chunk-QQ5GOLYW.js';
3
2
  import '../chunk-SMK4OZNU.js';
3
+ import '../chunk-AKIWUNNK.js';
4
+ import '../chunk-D655OH2I.js';
5
+ import '../chunk-KMQWUFMV.js';
4
6
  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';
@@ -0,0 +1,70 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Scheme-restricted URL schema: an absolute `http:`/`https:` URL, trimmed.
5
+ *
6
+ * ## Why this exists
7
+ *
8
+ * `z.string().url()` is `new URL()` under the hood, and `new URL()` accepts
9
+ * ANY scheme. All of these parse clean through a bare `.url()`:
10
+ *
11
+ * javascript:alert(1)
12
+ * data:text/html,<script>alert(1)</script>
13
+ * file:///etc/passwd
14
+ * vbscript:msgbox(1)
15
+ * blob:https://evil.example/x
16
+ *
17
+ * That is harmless for a value nobody dereferences and dangerous for one that
18
+ * clients do. `AudioEmbedView.url` is the field a player puts in `<audio src>`;
19
+ * `ActorProfileRecord.rssFeed` is the field an app renders as `<a href>`. A URL
20
+ * that reaches either of those unchecked is a stored-XSS shape — written once,
21
+ * fired for every viewer afterwards.
22
+ *
23
+ * So every URL field in this contract goes through this helper, and none of
24
+ * them uses a bare `.url()`. The `antiphony/no-bare-zod-url` ESLint rule
25
+ * enforces that, because "remember to use the helper" is not a control.
26
+ *
27
+ * ## Why `http:` is allowed, despite the name
28
+ *
29
+ * The name says https because https is what a deployment should serve; the rule
30
+ * admits `http:` because a self-hosted or local Antiphony is reached at
31
+ * `http://localhost:8787`, and `AudioEmbedView.url` is built from exactly that
32
+ * base (`ANTIPHONY_PUBLIC_BASE_URL`). Excluding plain http would make the
33
+ * contract unparseable in development for no safety gained: what this closes is
34
+ * scheme confusion, not transport confidentiality. Transport is a deployment
35
+ * concern, and the deployment that matters is https already.
36
+ *
37
+ * ## Why a string check and not a `.refine()`
38
+ *
39
+ * Two reasons, both practical:
40
+ *
41
+ * - **It stays a `ZodString`.** A `.refine()` wraps the schema in `ZodEffects`,
42
+ * which costs consumers `.extend()`-friendliness and makes the OpenAPI
43
+ * generator emit a weaker schema. As a plain string check the constraint
44
+ * survives into `openapi.json` as a `pattern`, so a consumer in another
45
+ * language reads the rule instead of having to already know it.
46
+ * - **It is checked against the raw string, not a parsed `protocol`.** HTML
47
+ * strips tabs and newlines out of URL attributes before dereferencing them,
48
+ * so a scheme split by a tab is a live `javascript:` URL in a browser — and
49
+ * one `new URL()` parses happily. Requiring the string to LITERALLY begin
50
+ * `http://` or `https://` rejects that whole family without enumerating it.
51
+ *
52
+ * `.trim()` runs first so surrounding whitespace is normalised away rather than
53
+ * sneaking a scheme past the anchor. It is a normalisation, not a loosening:
54
+ * bare `.url()` accepted padded input too, it just kept the padding.
55
+ *
56
+ * One fidelity note on that generated `pattern`: JSON Schema has no way to
57
+ * express a case-insensitive regex, so `openapi.json` documents
58
+ * `^https?:\/\/` without the `i` flag. `HTTPS://x` therefore passes here and
59
+ * fails a strict reading of the document. Real URLs carry a lowercase scheme,
60
+ * and the alternative — dropping `i` — would reject input for cosmetics, so the
61
+ * runtime stays the more permissive of the two on that one axis.
62
+ *
63
+ * Usage:
64
+ *
65
+ * url: httpsUrl()
66
+ * rssFeed: httpsUrl().optional()
67
+ */
68
+ declare function httpsUrl(): z.ZodString;
69
+
70
+ export { httpsUrl };
@@ -0,0 +1,2 @@
1
+ export { httpsUrl } from '../chunk-KMQWUFMV.js';
2
+ import '../chunk-5JBD5THX.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antiphony/shared",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
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",
@@ -137,14 +137,16 @@
137
137
  "lint": "eslint . --max-warnings=0",
138
138
  "test": "vitest run"
139
139
  },
140
- "dependencies": {
140
+ "//peerDependencies": "zod is a PEER, not a dependency, and the build has always assumed as much: tsup.config.ts marks it `external` so that there is ONE zod module instance shared with the consumer — the comment there spells out the consequence, that `@hono/zod-openapi`'s `.openapi()` extension never reaches schemas defined here if the instance is duplicated. Declaring it under `dependencies` said the opposite, that this package brings its own, and the contradiction was not theoretical: a consumer pinned to zod 3.22.4 against this package's `^3.24.1` gets TWO instances, 3.22.4 hoisted and 3.25.76 nested here. That is a live hazard inside zod 3, not a hedge against zod 4. As a peer, npm resolves one instance and says so when it cannot. The range is `^3.24.1` and is deliberately NOT widened to include `^4.0.0`: the schemas here are written against the zod 3 API, #148 verified that a zod 4 consumer breaks at parse time, and a peer range that overstates what the code supports is exactly the failure mode `@hono/zod-openapi` demonstrated with its `zod: >=3.0.0` — a range npm cannot fault, since 3.25.76 satisfies it, while the code underneath needed `^3.20.2`. Widen it only when the schemas actually move. ⚠️ SHIPS IN 0.6.0, which is unreleased — this changes the install contract, so a consumer that did not declare zod itself must now do so (npm 7+ auto-installs peers, but a consumer with `legacy-peer-deps` set does not). Vox Pop already declares zod in every workspace, so it is a no-op there.",
141
+ "peerDependencies": {
141
142
  "zod": "^3.24.1"
142
143
  },
143
144
  "devDependencies": {
144
145
  "@eslint/js": "^9.39.2",
145
146
  "tsup": "^8.5.1",
146
- "typescript-eslint": "^8.18.0",
147
+ "typescript-eslint": "^8.70.0",
147
148
  "typescript": "^5.7.2",
148
- "vitest": "^4.1.9"
149
+ "vitest": "^4.1.9",
150
+ "zod": "^3.24.1"
149
151
  }
150
152
  }