@antiphony/shared 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/api-codecs.cjs +26 -650
- package/dist/cjs/api-codecs.d.cts +15 -233
- package/dist/cjs/index.cjs +29 -761
- package/dist/cjs/index.d.cts +4 -4
- package/dist/cjs/nsid.cjs +3 -10
- package/dist/cjs/nsid.d.cts +1 -9
- package/dist/cjs/types/api.cjs +11 -571
- package/dist/cjs/types/api.d.cts +13 -265
- package/dist/cjs/types/audio.cjs +26 -547
- package/dist/cjs/types/audio.d.cts +93 -52
- package/dist/cjs/types/records.cjs +3 -328
- package/dist/cjs/types/records.d.cts +7 -729
- package/dist/cjs/types/views.cjs +8 -649
- package/dist/cjs/types/views.d.cts +43 -9123
- package/dist/esm/api-codecs.d.ts +46 -264
- package/dist/esm/api-codecs.js +5 -5
- package/dist/esm/{chunk-ORMEWXMH.js → chunk-5JBD5THX.js} +1 -16
- package/dist/esm/{chunk-XDBKR6LW.js → chunk-6LROFBKK.js} +3 -10
- package/dist/esm/{chunk-F2CANZZ7.js → chunk-BNNLHRH7.js} +1 -1
- package/dist/esm/{chunk-BUNMR4ZO.js → chunk-F7IHVM34.js} +20 -3
- package/dist/esm/chunk-FDM5FDN4.js +46 -0
- package/dist/esm/chunk-IHIBHQBJ.js +78 -0
- package/dist/esm/chunk-R6SBR3IG.js +97 -0
- package/dist/esm/chunk-Y6HNNRVD.js +12 -0
- package/dist/esm/errors/index.js +1 -1
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +8 -8
- package/dist/esm/nsid.d.ts +1 -9
- package/dist/esm/nsid.js +2 -2
- package/dist/esm/observability/index.js +2 -2
- package/dist/esm/observability/report-error.js +2 -2
- package/dist/esm/types/api.d.ts +15 -267
- package/dist/esm/types/api.js +4 -5
- package/dist/esm/types/audio.d.ts +170 -129
- package/dist/esm/types/audio.js +4 -4
- package/dist/esm/types/blob.js +1 -1
- package/dist/esm/types/records.d.ts +10 -732
- package/dist/esm/types/records.js +2 -3
- package/dist/esm/types/views.d.ts +51 -9131
- package/dist/esm/types/views.js +3 -4
- package/dist/esm/utils/index.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/types/channels.cjs +0 -170
- package/dist/cjs/types/channels.d.cts +0 -262
- package/dist/cjs/types/storage.cjs +0 -414
- package/dist/cjs/types/storage.d.cts +0 -197
- package/dist/esm/chunk-3WZJXJNU.js +0 -378
- package/dist/esm/chunk-7V44CPRR.js +0 -132
- package/dist/esm/chunk-EA4OONDV.js +0 -380
- package/dist/esm/chunk-TIZRJORN.js +0 -24
- package/dist/esm/types/channels.d.ts +0 -262
- package/dist/esm/types/channels.js +0 -162
- package/dist/esm/types/storage.d.ts +0 -197
- package/dist/esm/types/storage.js +0 -26
package/dist/cjs/index.cjs
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
var zod = require('zod');
|
|
4
4
|
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
6
|
-
var __defProps = Object.defineProperties;
|
|
7
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
8
6
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
8
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -20,19 +18,6 @@ var __spreadValues = (a, b) => {
|
|
|
20
18
|
}
|
|
21
19
|
return a;
|
|
22
20
|
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
var __objRest = (source, exclude) => {
|
|
25
|
-
var target = {};
|
|
26
|
-
for (var prop in source)
|
|
27
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
if (source != null && __getOwnPropSymbols)
|
|
30
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
-
target[prop] = source[prop];
|
|
33
|
-
}
|
|
34
|
-
return target;
|
|
35
|
-
};
|
|
36
21
|
var BlobRefSchema = zod.z.object({
|
|
37
22
|
/** Discriminator for AT Protocol type system */
|
|
38
23
|
$type: zod.z.literal("blob"),
|
|
@@ -48,8 +33,6 @@ function resolveAudioUrl(record) {
|
|
|
48
33
|
if ((_a = record.audio) == null ? void 0 : _a.ref) return record.audio.ref;
|
|
49
34
|
return record.audioUrl;
|
|
50
35
|
}
|
|
51
|
-
|
|
52
|
-
// types/records.ts
|
|
53
36
|
function httpsUrl() {
|
|
54
37
|
return zod.z.string().trim().url().refine((u) => /^https?:\/\//i.test(u), {
|
|
55
38
|
message: "URL must use the http or https scheme"
|
|
@@ -92,11 +75,8 @@ var UserRecordSchema = zod.z.object({
|
|
|
92
75
|
handle: zod.z.string().min(3).max(20).regex(/^[a-zA-Z0-9_]+$/).nullable().optional(),
|
|
93
76
|
/** User stated intent (e.g. "Podcaster", "Listener") */
|
|
94
77
|
usageIntent: zod.z.string().nullable().optional(),
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
* Defaults to 'voxpop.com'.
|
|
98
|
-
*/
|
|
99
|
-
domain: zod.z.string().default("voxpop.com"),
|
|
78
|
+
/** Domain for federated handle support. */
|
|
79
|
+
domain: zod.z.string().default("antiphony.dev"),
|
|
100
80
|
/**
|
|
101
81
|
* Display Name (e.g. "Brad Thorson"). Nullable: Firestore stores `null`
|
|
102
82
|
* when the user clears this field via the settings form, and the schema
|
|
@@ -124,313 +104,14 @@ var UserRecordSchema = zod.z.object({
|
|
|
124
104
|
/** Account status. Deactivated accounts retain data but are excluded from lookups. */
|
|
125
105
|
status: zod.z.enum(["active", "deactivated"]).default("active"),
|
|
126
106
|
/** Timestamp when the account was deactivated (soft deleted) */
|
|
127
|
-
deactivatedAt: FirestoreTimestampSchema.optional()
|
|
128
|
-
/**
|
|
129
|
-
* Denormalized org memberships — { orgId: role } for fast lookup.
|
|
130
|
-
* Source of truth is organizations/{orgId}/members/{userId}.
|
|
131
|
-
* Kept in sync by Cloud Function trigger.
|
|
132
|
-
*/
|
|
133
|
-
orgMemberships: zod.z.record(zod.z.string(), zod.z.enum(["owner", "admin", "member"])).optional()
|
|
134
|
-
});
|
|
135
|
-
var PromptRecordSchema = zod.z.object({
|
|
136
|
-
/** Unique Prompt ID */
|
|
137
|
-
id: zod.z.string(),
|
|
138
|
-
/** ID of the User who created this prompt. Always a user ID, never an org ID. @see UserRecord */
|
|
139
|
-
authorId: zod.z.string(),
|
|
140
|
-
/** Organization context this prompt belongs to (null = personal/no org) */
|
|
141
|
-
orgId: zod.z.string().nullable().optional(),
|
|
142
|
-
/** The main text of the question/prompt */
|
|
143
|
-
title: zod.z.string().min(3),
|
|
144
|
-
/** Optional extra context */
|
|
145
|
-
description: zod.z.string().nullable().optional(),
|
|
146
|
-
/** User who created this prompt (differs from authorId when org-owned) */
|
|
147
|
-
createdBy: zod.z.string().optional(),
|
|
148
|
-
/** URL to the recorded audio file (GCS) */
|
|
149
|
-
audioUrl: zod.z.string().url().or(zod.z.literal("")),
|
|
150
|
-
/** AT Protocol blob reference (future replacement for audioUrl) */
|
|
151
|
-
audio: BlobRefSchema.optional(),
|
|
152
|
-
/**
|
|
153
|
-
* AT Protocol URI returned by the publisher after a successful
|
|
154
|
-
* `repo.putRecord` against the author's PDS — e.g.
|
|
155
|
-
* `at://did:plc:abc123/com.voxpop.audio.prompt/3kj4...`. Optional,
|
|
156
|
-
* no migration: existing rows leave it unset. Format-validated so
|
|
157
|
-
* malformed strings surface at the schema-parse boundary rather than
|
|
158
|
-
* being silently stored.
|
|
159
|
-
*/
|
|
160
|
-
atprotoUri: zod.z.string().regex(/^at:\/\/.+/).optional(),
|
|
161
|
-
/** Server timestamp of creation */
|
|
162
|
-
createdAt: FirestoreTimestampSchema,
|
|
163
|
-
/**
|
|
164
|
-
* Life-cycle status.
|
|
165
|
-
* - `live`: Visible and accepting replies.
|
|
166
|
-
* - `archived`: Visible but closed for new replies.
|
|
167
|
-
* - `deleted`: Soft deleted.
|
|
168
|
-
*/
|
|
169
|
-
status: zod.z.enum(["live", "archived", "deleted"]).default("live"),
|
|
170
|
-
/** AI Enrichment Fields */
|
|
171
|
-
aiStatus: zod.z.enum(["pending", "complete", "error"]).optional(),
|
|
172
|
-
aiError: zod.z.string().optional(),
|
|
173
|
-
aiSummary: zod.z.string().optional(),
|
|
174
|
-
aiLabels: zod.z.array(zod.z.string()).optional(),
|
|
175
|
-
transcription: zod.z.string().optional(),
|
|
176
|
-
/** Pre-computed waveform peaks (normalized 0–1) for instant audio visualization */
|
|
177
|
-
waveformPeaks: zod.z.array(zod.z.number()).optional(),
|
|
178
|
-
/** Social Share Video Fields */
|
|
179
|
-
socialVideoUrl: zod.z.string().url().optional(),
|
|
180
|
-
socialVideoStoragePath: zod.z.string().optional(),
|
|
181
|
-
socialVideoStatus: zod.z.enum(["pending", "complete", "error"]).optional(),
|
|
182
|
-
socialVideoError: zod.z.string().optional(),
|
|
183
|
-
/** The audio URL/path used to generate the current video (for cache invalidation) */
|
|
184
|
-
socialVideoSourceAudio: zod.z.string().optional()
|
|
185
|
-
});
|
|
186
|
-
var ReplyRecordSchema = zod.z.object({
|
|
187
|
-
/** Unique Reply ID */
|
|
188
|
-
id: zod.z.string(),
|
|
189
|
-
/** The Prompt being replied to. @see PromptRecord */
|
|
190
|
-
promptId: zod.z.string(),
|
|
191
|
-
/** The User who replied. @see UserRecord */
|
|
192
|
-
authorId: zod.z.string(),
|
|
193
|
-
/** URL to the recorded audio file (GCS) */
|
|
194
|
-
audioUrl: zod.z.string().url(),
|
|
195
|
-
/** AT Protocol blob reference (future replacement for audioUrl) */
|
|
196
|
-
audio: BlobRefSchema.optional(),
|
|
197
|
-
/** Server timestamp of creation */
|
|
198
|
-
createdAt: FirestoreTimestampSchema,
|
|
199
|
-
/**
|
|
200
|
-
* Life-cycle status.
|
|
201
|
-
* - `live`: Visible and accepting replies.
|
|
202
|
-
* - `archived`: Visible but closed for new replies.
|
|
203
|
-
* - `deleted`: Soft deleted.
|
|
204
|
-
*/
|
|
205
|
-
status: zod.z.enum(["live", "archived", "deleted"]).default("live"),
|
|
206
|
-
/**
|
|
207
|
-
* Pre-computed waveform peaks (normalized 0–1) for instant audio
|
|
208
|
-
* visualization. **Stays on canonical** (does NOT move to the
|
|
209
|
-
* enrichment doc) — produced by a plain ffmpeg pass at ingestion,
|
|
210
|
-
* not an AI step; a self-hoster without paid-tier AI still needs
|
|
211
|
-
* this on every reply for the audio player. See
|
|
212
|
-
* `specs/ai-enrichment-split.md` § 5.
|
|
213
|
-
*/
|
|
214
|
-
waveformPeaks: zod.z.array(zod.z.number()).optional(),
|
|
215
|
-
/**
|
|
216
|
-
* Duration of the audio in seconds, computed server-side from
|
|
217
|
-
* ffmpeg. **Stays on canonical** (same reasoning as `waveformPeaks`
|
|
218
|
-
* above — ingestion ffmpeg output, not an AI enrichment). See
|
|
219
|
-
* `specs/ai-enrichment-split.md` § 5.
|
|
220
|
-
*/
|
|
221
|
-
audioDurationSec: zod.z.number().optional()
|
|
222
|
-
});
|
|
223
|
-
var ReplyEnrichmentRecordSchema = zod.z.object({
|
|
224
|
-
id: zod.z.string(),
|
|
225
|
-
/** Private notes by the prompt author about this reply. */
|
|
226
|
-
notes: zod.z.string().optional(),
|
|
227
|
-
// === AI-enrichment fields (sole source of truth post Stage 4) ===
|
|
228
|
-
//
|
|
229
|
-
// These lifted off canonical in Stage 4 of `specs/ai-enrichment-split.md`.
|
|
230
|
-
// Writers (`functions/`) route AI updates here via the split-write
|
|
231
|
-
// helper in `functions/src/services/replyEnrichmentDualWrite.ts`;
|
|
232
|
-
// readers source them via the hydrator's enrichment branch (see
|
|
233
|
-
// `packages/core/services/hydration.ts`).
|
|
234
|
-
// --- AI core (Gemini-generated) ---
|
|
235
|
-
aiStatus: zod.z.enum(["pending", "complete", "error", "skipped_too_short"]).optional(),
|
|
236
|
-
aiError: zod.z.string().optional(),
|
|
237
|
-
aiSummary: zod.z.string().optional(),
|
|
238
|
-
aiLabels: zod.z.array(zod.z.string()).optional(),
|
|
239
|
-
transcription: zod.z.string().optional(),
|
|
240
|
-
sentiment: zod.z.enum(["Positive", "Negative", "Neutral"]).optional(),
|
|
241
|
-
/** Must match the widened enum in `ReplyRecordSchema.energyLevel`. */
|
|
242
|
-
energyLevel: zod.z.enum(["High", "Low", "Neutral"]).optional(),
|
|
243
|
-
engagementScore: zod.z.number().min(1).max(10).optional(),
|
|
244
|
-
// --- Voice isolation (ElevenLabs, paid tier) ---
|
|
245
|
-
/** Noise-reduced audio URL — replaces `audioUrl` for downstream players when present. PUBLIC. */
|
|
246
|
-
enhancedAudioUrl: zod.z.string().url().optional(),
|
|
247
|
-
/** Storage path companion to `enhancedAudioUrl` — private. */
|
|
248
|
-
enhancedStoragePath: zod.z.string().optional(),
|
|
249
|
-
// --- Social-share video (paid tier) ---
|
|
250
|
-
//
|
|
251
|
-
// All `socialVideo*` fields are creator-only. The URL points at the
|
|
252
|
-
// generated artifact (a video file the creator can download and post
|
|
253
|
-
// to social media); the reply detail page does NOT render it.
|
|
254
|
-
socialVideoUrl: zod.z.string().url().optional(),
|
|
255
|
-
socialVideoStoragePath: zod.z.string().optional(),
|
|
256
|
-
socialVideoStatus: zod.z.enum(["pending", "complete", "error"]).optional(),
|
|
257
|
-
socialVideoError: zod.z.string().optional(),
|
|
258
|
-
/** The audio URL/path used to generate the current video (for cache invalidation). */
|
|
259
|
-
socialVideoSourceAudio: zod.z.string().optional()
|
|
260
|
-
});
|
|
261
|
-
var PersonEnrichmentRecordSchema = zod.z.object({
|
|
262
|
-
/** Composite key `${viewerUid}_${targetUid}`. */
|
|
263
|
-
id: zod.z.string(),
|
|
264
|
-
/** Per-viewer CRM notes about the target. */
|
|
265
|
-
notes: zod.z.string().optional(),
|
|
266
|
-
/** Per-viewer freeform tags about the target. */
|
|
267
|
-
tags: zod.z.array(zod.z.string()).optional(),
|
|
268
|
-
// === Identity-merge: alias set ===
|
|
269
|
-
//
|
|
270
|
-
// Other identifiers the viewer has declared to be the SAME person as
|
|
271
|
-
// this entry's `targetUid`. vCard/URI-aligned: each entry is a
|
|
272
|
-
// scheme-prefixed identifier, so one field generalizes across networks
|
|
273
|
-
// AND across the future contact-sync import (which carries phone/email):
|
|
274
|
-
// "uid:<firebaseUid>" | "did:plc:…" | "handle:bob.bsky.social"
|
|
275
|
-
// | "tel:+15551234567" | "mailto:x@example.com"
|
|
276
|
-
// Mirrors vCard 4.0's `UID` + `CLIENTPIDMAP`/`PID` source-tracking
|
|
277
|
-
// (RFC 6350) — the standard answer to "the same person from multiple
|
|
278
|
-
// sources". See `specs/people-lexicon-prior-art.md`. The People
|
|
279
|
-
// read-path collapses any replier whose "uid:<uid>" appears here into
|
|
280
|
-
// this primary entry. Empty until the merge feature is used.
|
|
281
|
-
aliases: zod.z.array(zod.z.string()).optional(),
|
|
282
|
-
lastUpdated: FirestoreTimestampSchema.optional()
|
|
283
|
-
});
|
|
284
|
-
var SipEnrichmentSchema = zod.z.object({
|
|
285
|
-
sipUri: zod.z.string(),
|
|
286
|
-
sipUsername: zod.z.string(),
|
|
287
|
-
sipSecret: zod.z.string(),
|
|
288
|
-
provider: zod.z.enum(["twilio", "plivo", "internal"])
|
|
289
|
-
});
|
|
290
|
-
var CallForwardingConfigSchema = zod.z.object({
|
|
291
|
-
/** User's personal phone number (E.164) */
|
|
292
|
-
phoneNumber: zod.z.string(),
|
|
293
|
-
/** Line type from Twilio Lookup v2 */
|
|
294
|
-
lineType: zod.z.string().nullable(),
|
|
295
|
-
/** Carrier name from Twilio Lookup v2 */
|
|
296
|
-
carrier: zod.z.string().nullable(),
|
|
297
|
-
/** free = shared Twilio number (ForwardedFrom routing), paid = dedicated number */
|
|
298
|
-
tier: zod.z.enum(["free", "paid"]),
|
|
299
|
-
/** The VoxPop Twilio number calls forward to (E.164) */
|
|
300
|
-
voxpopNumber: zod.z.string(),
|
|
301
|
-
/** Twilio Phone Number SID (paid tier only) */
|
|
302
|
-
twilioNumberSid: zod.z.string().nullable().optional(),
|
|
303
|
-
/** Forwarding verification state */
|
|
304
|
-
verificationStatus: zod.z.enum(["pending", "verifying", "verified", "failed"]).default("pending"),
|
|
305
|
-
/** Last verification attempt timestamp */
|
|
306
|
-
lastVerificationAt: FirestoreTimestampSchema.optional(),
|
|
307
|
-
/** Number of verification attempts */
|
|
308
|
-
verificationAttempts: zod.z.number().default(0),
|
|
309
|
-
/** Reason for verification failure */
|
|
310
|
-
failureReason: zod.z.string().nullable().optional(),
|
|
311
|
-
/** Whether call forwarding is active */
|
|
312
|
-
enabled: zod.z.boolean().default(false),
|
|
313
|
-
createdAt: FirestoreTimestampSchema,
|
|
314
|
-
updatedAt: FirestoreTimestampSchema
|
|
315
|
-
});
|
|
316
|
-
var ConnectorTypeSchema = zod.z.enum(["telephony"]);
|
|
317
|
-
var ConnectorStatusSchema = zod.z.object({
|
|
318
|
-
/** Coarse, generic lifecycle the control-plane UI can render without
|
|
319
|
-
* connector-specific knowledge. */
|
|
320
|
-
state: zod.z.enum(["unconfigured", "pending", "active", "error", "disabled"]).default("unconfigured"),
|
|
321
|
-
detail: zod.z.string().nullable().optional(),
|
|
322
|
-
/** Opaque, connector-specific status detail (e.g. telephony's
|
|
323
|
-
* `{ verificationStatus, verificationAttempts, failureReason }`). Connector-
|
|
324
|
-
* owned like the rest of `status` — never user-writable. Nullable so a doc
|
|
325
|
-
* that stored `data: null` round-trips without a parse error. */
|
|
326
|
-
data: zod.z.record(zod.z.unknown()).nullable().optional(),
|
|
327
|
-
updatedAt: FirestoreTimestampSchema.optional()
|
|
328
|
-
});
|
|
329
|
-
var ConnectorConfigRecordSchema = zod.z.object({
|
|
330
|
-
connectorType: ConnectorTypeSchema,
|
|
331
|
-
/** The owning user. Org-scoping (ownerId as an orgId) is a later step. */
|
|
332
|
-
ownerId: zod.z.string(),
|
|
333
|
-
/** Opaque, connector-specific blob. Core does not interpret this. */
|
|
334
|
-
settings: zod.z.record(zod.z.unknown()).default({}),
|
|
335
|
-
/** Reference into a secret store (e.g. Secret Manager key). Never a raw secret. */
|
|
336
|
-
secretRef: zod.z.string().nullable().optional(),
|
|
337
|
-
enabled: zod.z.boolean().default(false),
|
|
338
|
-
status: ConnectorStatusSchema.default({ state: "unconfigured" }),
|
|
339
|
-
createdAt: FirestoreTimestampSchema,
|
|
340
|
-
updatedAt: FirestoreTimestampSchema
|
|
341
|
-
});
|
|
342
|
-
var ScreeningRuleRecordSchema = zod.z.object({
|
|
343
|
-
id: zod.z.string(),
|
|
344
|
-
ownerId: zod.z.string(),
|
|
345
|
-
/** The caller number this rule matches (E.164). Format-enforced at the
|
|
346
|
-
* record level so any writer (API, future contact-sync/callback) can't
|
|
347
|
-
* persist a malformed number. */
|
|
348
|
-
e164: zod.z.string().regex(/^\+[1-9]\d{6,14}$/, "Must be an E.164 phone number"),
|
|
349
|
-
/** Display label, e.g. "Mom" / "Delta Airlines". null = unlabeled. */
|
|
350
|
-
label: zod.z.string().nullable().optional(),
|
|
351
|
-
/** `allow` = ring through; `screen` = async voicemail. */
|
|
352
|
-
action: zod.z.enum(["allow", "screen"]),
|
|
353
|
-
/** Provenance. `manual` = user-created; the others are future writers. */
|
|
354
|
-
source: zod.z.enum(["manual", "contact-sync", "callback"]),
|
|
355
|
-
/** null = permanent; a date = self-expiring exception. */
|
|
356
|
-
expiresAt: FirestoreTimestampSchema.nullable().optional(),
|
|
357
|
-
createdAt: FirestoreTimestampSchema
|
|
358
|
-
});
|
|
359
|
-
var OrganizationRecordSchema = zod.z.object({
|
|
360
|
-
id: zod.z.string(),
|
|
361
|
-
/** Display name of the organization */
|
|
362
|
-
name: zod.z.string().min(3).max(50),
|
|
363
|
-
/**
|
|
364
|
-
* Unique handle for the organization (e.g. voxpop.com/@mypodcast).
|
|
365
|
-
* Used for public URLs.
|
|
366
|
-
*/
|
|
367
|
-
slug: zod.z.string().min(3).max(30).regex(/^[a-z0-9-]+$/),
|
|
368
|
-
/** URL to avatar/logo */
|
|
369
|
-
avatarUrl: zod.z.string().url().optional(),
|
|
370
|
-
/** URL to the podcast RSS feed */
|
|
371
|
-
rssFeedUrl: zod.z.string().url().optional(),
|
|
372
|
-
/** External website URL */
|
|
373
|
-
websiteUrl: httpsUrl().optional(),
|
|
374
|
-
/** Description or tagline */
|
|
375
|
-
description: zod.z.string().optional(),
|
|
376
|
-
/** Owner ID (User ID) */
|
|
377
|
-
ownerId: zod.z.string(),
|
|
378
|
-
/** Server timestamp of creation */
|
|
379
|
-
createdAt: FirestoreTimestampSchema,
|
|
380
|
-
/** Verified domain (e.g., "acme.com") — enables auto-join, enterprise features */
|
|
381
|
-
domain: zod.z.string().nullable().optional(),
|
|
382
|
-
/** Whether the domain has been verified via DNS TXT record */
|
|
383
|
-
domainVerified: zod.z.boolean().default(false),
|
|
384
|
-
/** DNS verification token (stored server-side until verification completes) */
|
|
385
|
-
domainVerificationToken: zod.z.string().optional(),
|
|
386
|
-
/** Billing email — required for paid orgs, where invoices go */
|
|
387
|
-
billingEmail: zod.z.string().email().nullable().optional(),
|
|
388
|
-
/**
|
|
389
|
-
* Tier determines isolation and feature set. Orgs are meant to be paid
|
|
390
|
-
* (business or enterprise); free/pro exist on the enum for the individual track.
|
|
391
|
-
* Default is provisionally `business` (the entry paid tier) — it's assigned at
|
|
392
|
-
* creation with no subscription behind it yet, so it stays provisional until billing
|
|
393
|
-
* promotes/reconciles the org. See docs/tech-debt.md "Org tier billing reconciliation".
|
|
394
|
-
*/
|
|
395
|
-
tier: zod.z.enum(["free", "pro", "business", "enterprise"]).default("business"),
|
|
396
|
-
/** Stripe Customer ID */
|
|
397
|
-
stripeCustomerId: zod.z.string().optional(),
|
|
398
|
-
/** Subscription Status */
|
|
399
|
-
subscriptionStatus: zod.z.enum(["active", "trialing", "past_due", "canceled", "unpaid"]).optional()
|
|
400
|
-
});
|
|
401
|
-
var OrganizationMemberRecordSchema = zod.z.object({
|
|
402
|
-
orgId: zod.z.string(),
|
|
403
|
-
userId: zod.z.string(),
|
|
404
|
-
/** Role in the organization */
|
|
405
|
-
role: zod.z.enum(["owner", "admin", "member"]),
|
|
406
|
-
/** Server timestamp of joining */
|
|
407
|
-
joinedAt: FirestoreTimestampSchema,
|
|
408
|
-
invitedBy: zod.z.string().optional()
|
|
409
|
-
});
|
|
410
|
-
var OrgInviteRecordSchema = zod.z.object({
|
|
411
|
-
id: zod.z.string(),
|
|
412
|
-
orgId: zod.z.string(),
|
|
413
|
-
/** Email the invite was sent to */
|
|
414
|
-
email: zod.z.string().email(),
|
|
415
|
-
/** Role to assign on acceptance */
|
|
416
|
-
role: zod.z.enum(["admin", "member"]),
|
|
417
|
-
/** User ID of who sent the invite */
|
|
418
|
-
invitedBy: zod.z.string(),
|
|
419
|
-
/** Invite lifecycle status */
|
|
420
|
-
status: zod.z.enum(["pending", "accepted", "expired", "revoked"]).default("pending"),
|
|
421
|
-
/** Server timestamp of creation */
|
|
422
|
-
createdAt: FirestoreTimestampSchema,
|
|
423
|
-
/** When this invite expires */
|
|
424
|
-
expiresAt: FirestoreTimestampSchema
|
|
107
|
+
deactivatedAt: FirestoreTimestampSchema.optional()
|
|
425
108
|
});
|
|
426
109
|
var ProfileViewBasicSchema = zod.z.object({
|
|
427
110
|
id: zod.z.string(),
|
|
428
111
|
handle: zod.z.string().nullable().optional(),
|
|
429
112
|
// `displayName` and `bio` are `.nullable()` — Firestore stores `null` for
|
|
430
113
|
// empty values on these fields (see users-dependencies.ts), and Zod's
|
|
431
|
-
// `.optional()` alone rejects `null`.
|
|
432
|
-
// Phase 3.1 HTTP cutover, when transport-layer Zod validation started
|
|
433
|
-
// actually exercising the wire shape. Consumers already use truthy
|
|
114
|
+
// `.optional()` alone rejects `null`. Consumers already use truthy
|
|
434
115
|
// checks / `??` / `||`, so widening the type to include `null` is safe.
|
|
435
116
|
displayName: zod.z.string().nullable().optional(),
|
|
436
117
|
avatarUrl: zod.z.string().nullable().optional(),
|
|
@@ -483,24 +164,7 @@ var ProfileViewDetailedSchema = ProfileViewBasicSchema.extend({
|
|
|
483
164
|
handle: zod.z.string(),
|
|
484
165
|
did: zod.z.string()
|
|
485
166
|
}).optional(),
|
|
486
|
-
usageIntent: zod.z.string().nullable().optional()
|
|
487
|
-
/** Hydrated RSS Data (fetched from sub-collection) */
|
|
488
|
-
rssSummary: zod.z.object({
|
|
489
|
-
title: zod.z.string().optional(),
|
|
490
|
-
description: zod.z.string().optional(),
|
|
491
|
-
items: zod.z.array(zod.z.object({
|
|
492
|
-
title: zod.z.string().optional(),
|
|
493
|
-
link: zod.z.string().optional(),
|
|
494
|
-
content: zod.z.string().optional(),
|
|
495
|
-
pubDate: zod.z.string().optional()
|
|
496
|
-
})).optional(),
|
|
497
|
-
lastFetchedAt: FirestoreTimestampSchema.optional()
|
|
498
|
-
}).optional(),
|
|
499
|
-
promptAudioUrl: zod.z.string().optional(),
|
|
500
|
-
/** @deprecated Use stats.prompts from ProfileViewBasic instead */
|
|
501
|
-
totalPrompts: zod.z.number().optional(),
|
|
502
|
-
totalReplies: zod.z.number().optional(),
|
|
503
|
-
favoritePromptId: zod.z.string().optional()
|
|
167
|
+
usageIntent: zod.z.string().nullable().optional()
|
|
504
168
|
});
|
|
505
169
|
var ProfileViewSelfSchema = ProfileViewDetailedSchema.extend({
|
|
506
170
|
phoneNumber: zod.z.string().nullable().optional(),
|
|
@@ -511,9 +175,8 @@ var ProfileViewSelfSchema = ProfileViewDetailedSchema.extend({
|
|
|
511
175
|
newReplierCount: zod.z.number().default(0),
|
|
512
176
|
/**
|
|
513
177
|
* Account tier from UserRecord — surfaced on the self profile so the
|
|
514
|
-
* client can gate paid features
|
|
515
|
-
*
|
|
516
|
-
* missing as `'free'`.
|
|
178
|
+
* client can gate paid features. Optional for legacy docs without the
|
|
179
|
+
* field; consumers should treat missing as `'free'`.
|
|
517
180
|
*/
|
|
518
181
|
tier: zod.z.enum(["free", "creator_pro"]).optional(),
|
|
519
182
|
/**
|
|
@@ -535,268 +198,6 @@ var ProfileViewAdminSchema = ProfileViewSelfSchema.extend({
|
|
|
535
198
|
isBanned: zod.z.boolean().optional()
|
|
536
199
|
});
|
|
537
200
|
var ProfileViewSchema = ProfileViewAdminSchema;
|
|
538
|
-
var PromptViewSchema = zod.z.object({
|
|
539
|
-
/** AT Protocol URI (e.g. at://did:plc.../app.../123) */
|
|
540
|
-
uri: zod.z.string().optional(),
|
|
541
|
-
/** IPFS Content ID */
|
|
542
|
-
cid: zod.z.string().optional(),
|
|
543
|
-
/** The raw prompt data */
|
|
544
|
-
record: PromptRecordSchema,
|
|
545
|
-
/** The hydrated author profile */
|
|
546
|
-
author: ProfileViewSchema,
|
|
547
|
-
/** Total number of replies */
|
|
548
|
-
replyCount: zod.z.number().default(0),
|
|
549
|
-
likeCount: zod.z.number().default(0),
|
|
550
|
-
updatedAt: FirestoreTimestampSchema.optional(),
|
|
551
|
-
lastReplyAt: FirestoreTimestampSchema.optional(),
|
|
552
|
-
tags: zod.z.array(zod.z.string()).optional(),
|
|
553
|
-
visibility: zod.z.enum(["public", "private", "unlisted", "archived"]).default("public"),
|
|
554
|
-
analytics: zod.z.object({
|
|
555
|
-
views: zod.z.number().default(0),
|
|
556
|
-
listens: zod.z.number().default(0),
|
|
557
|
-
/**
|
|
558
|
-
* Mean engagementScore (1–10) across this prompt's `status: 'live'`
|
|
559
|
-
* replies that completed AI enrichment. `null` when no such replies
|
|
560
|
-
* exist (0 would alias a valid bottom-of-range score). Derived in
|
|
561
|
-
* hydration from the prompt doc's `engagementScoreSum / Count`.
|
|
562
|
-
*/
|
|
563
|
-
avgEngagementScore: zod.z.number().nullable().optional(),
|
|
564
|
-
/**
|
|
565
|
-
* Counts of `status: 'live'` AI-enriched replies grouped by sentiment.
|
|
566
|
-
* Keys lowercase by convention; source enum
|
|
567
|
-
* (`Positive | Neutral | Negative`) is mapped at the write site.
|
|
568
|
-
*/
|
|
569
|
-
sentimentBreakdown: zod.z.object({
|
|
570
|
-
positive: zod.z.number(),
|
|
571
|
-
neutral: zod.z.number(),
|
|
572
|
-
negative: zod.z.number()
|
|
573
|
-
}).optional()
|
|
574
|
-
}).optional(),
|
|
575
|
-
moderation: zod.z.object({
|
|
576
|
-
flagged: zod.z.boolean().default(false),
|
|
577
|
-
reason: zod.z.string().optional()
|
|
578
|
-
}).optional(),
|
|
579
|
-
// AI Enrichment Fields (Hydrated from Record but hidden from Record Schema)
|
|
580
|
-
aiLabels: zod.z.array(zod.z.string()).optional(),
|
|
581
|
-
aiSummary: zod.z.string().optional(),
|
|
582
|
-
aiStatus: zod.z.enum(["pending", "complete", "error"]).optional(),
|
|
583
|
-
aiError: zod.z.string().optional(),
|
|
584
|
-
transcription: zod.z.string().optional()
|
|
585
|
-
});
|
|
586
|
-
var PromptViewPublicSchema = PromptViewSchema.omit({
|
|
587
|
-
analytics: true,
|
|
588
|
-
moderation: true,
|
|
589
|
-
aiLabels: true,
|
|
590
|
-
aiSummary: true,
|
|
591
|
-
aiStatus: true,
|
|
592
|
-
aiError: true,
|
|
593
|
-
transcription: true
|
|
594
|
-
}).extend({
|
|
595
|
-
author: ProfileViewBasicSchema
|
|
596
|
-
});
|
|
597
|
-
function toPromptViewPublic(prompt) {
|
|
598
|
-
const _a = prompt, { analytics, moderation, aiLabels, aiSummary, aiStatus, aiError, transcription } = _a, rest = __objRest(_a, ["analytics", "moderation", "aiLabels", "aiSummary", "aiStatus", "aiError", "transcription"]);
|
|
599
|
-
return __spreadProps(__spreadValues({}, rest), {
|
|
600
|
-
author: toProfileViewBasic(rest.author)
|
|
601
|
-
});
|
|
602
|
-
}
|
|
603
|
-
var ReplyViewSchema = zod.z.object({
|
|
604
|
-
record: ReplyRecordSchema,
|
|
605
|
-
author: ProfileViewSchema,
|
|
606
|
-
recipient: ProfileViewSchema,
|
|
607
|
-
/** GCS Storage Path for audio file */
|
|
608
|
-
storagePath: zod.z.string().optional(),
|
|
609
|
-
duration: zod.z.number().optional(),
|
|
610
|
-
updatedAt: FirestoreTimestampSchema.optional(),
|
|
611
|
-
isRead: zod.z.boolean(),
|
|
612
|
-
readBy: zod.z.array(zod.z.string()).default([]),
|
|
613
|
-
isDeleted: zod.z.boolean().default(false),
|
|
614
|
-
reactions: zod.z.record(zod.z.string(), zod.z.number()).optional(),
|
|
615
|
-
moderation: zod.z.object({
|
|
616
|
-
flagged: zod.z.boolean().default(false),
|
|
617
|
-
reason: zod.z.string().optional()
|
|
618
|
-
}).optional(),
|
|
619
|
-
// AI Enrichment Fields (Hydrated from Record but hidden from Record Schema)
|
|
620
|
-
aiLabels: zod.z.array(zod.z.string()).optional(),
|
|
621
|
-
aiSummary: zod.z.string().optional(),
|
|
622
|
-
aiStatus: zod.z.enum(["pending", "complete", "error", "skipped_too_short"]).optional(),
|
|
623
|
-
aiError: zod.z.string().optional(),
|
|
624
|
-
transcription: zod.z.string().optional(),
|
|
625
|
-
sentiment: zod.z.enum(["Positive", "Negative", "Neutral"]).optional(),
|
|
626
|
-
/** Must match the widened enum in `ReplyRecordSchema.energyLevel`. */
|
|
627
|
-
energyLevel: zod.z.enum(["High", "Low", "Neutral"]).optional(),
|
|
628
|
-
engagementScore: zod.z.number().min(1).max(10).optional(),
|
|
629
|
-
// === Voice-isolation enrichment (lifted; see specs/ai-enrichment-split.md) ===
|
|
630
|
-
//
|
|
631
|
-
// `enhancedAudioUrl` is the only one of these the public view keeps —
|
|
632
|
-
// it replaces `audioUrl` for downstream players when present.
|
|
633
|
-
// `enhancedStoragePath` is private (storage paths are server-side
|
|
634
|
-
// bookkeeping).
|
|
635
|
-
enhancedAudioUrl: zod.z.string().url().optional(),
|
|
636
|
-
enhancedStoragePath: zod.z.string().optional(),
|
|
637
|
-
// === Social-share video enrichment (lifted; creator-only) ===
|
|
638
|
-
//
|
|
639
|
-
// All `socialVideo*` fields are stripped by `toReplyViewPublic` —
|
|
640
|
-
// the URL points at a generated artifact the creator may share to
|
|
641
|
-
// social media, NOT at content the reply page should render. Status /
|
|
642
|
-
// error / source-audio are job-tracking state.
|
|
643
|
-
socialVideoUrl: zod.z.string().url().optional(),
|
|
644
|
-
socialVideoStoragePath: zod.z.string().optional(),
|
|
645
|
-
socialVideoStatus: zod.z.enum(["pending", "complete", "error"]).optional(),
|
|
646
|
-
socialVideoError: zod.z.string().optional(),
|
|
647
|
-
socialVideoSourceAudio: zod.z.string().optional(),
|
|
648
|
-
/** @private Confirmed listener phone number (never exposed publicly) */
|
|
649
|
-
listenerPhoneNumber: zod.z.string().regex(/^\+[1-9]\d{1,14}$/).optional(),
|
|
650
|
-
/**
|
|
651
|
-
* @private Per-viewer private notes about this reply (CRM enrichment).
|
|
652
|
-
* Lifted into the view from `enrichments/replies/{id}.notes` by the
|
|
653
|
-
* hydrator when the viewer is the prompt author. Never populated for
|
|
654
|
-
* non-author viewers; defensively stripped by `toReplyViewPublic`.
|
|
655
|
-
*/
|
|
656
|
-
notes: zod.z.string().optional()
|
|
657
|
-
});
|
|
658
|
-
var ReplyViewPublicSchema = ReplyViewSchema.omit({
|
|
659
|
-
listenerPhoneNumber: true,
|
|
660
|
-
notes: true,
|
|
661
|
-
// AI cluster — only `transcription` survives.
|
|
662
|
-
aiStatus: true,
|
|
663
|
-
aiError: true,
|
|
664
|
-
aiSummary: true,
|
|
665
|
-
aiLabels: true,
|
|
666
|
-
sentiment: true,
|
|
667
|
-
energyLevel: true,
|
|
668
|
-
engagementScore: true,
|
|
669
|
-
// Voice isolation — keep enhancedAudioUrl, strip the path.
|
|
670
|
-
enhancedStoragePath: true,
|
|
671
|
-
// Social-video — entire cluster is creator-only.
|
|
672
|
-
socialVideoUrl: true,
|
|
673
|
-
socialVideoStoragePath: true,
|
|
674
|
-
socialVideoStatus: true,
|
|
675
|
-
socialVideoError: true,
|
|
676
|
-
socialVideoSourceAudio: true
|
|
677
|
-
});
|
|
678
|
-
function toReplyViewPublic(reply) {
|
|
679
|
-
const _a = reply, {
|
|
680
|
-
listenerPhoneNumber,
|
|
681
|
-
notes,
|
|
682
|
-
aiStatus: aiStatus,
|
|
683
|
-
aiError,
|
|
684
|
-
aiSummary,
|
|
685
|
-
aiLabels,
|
|
686
|
-
sentiment,
|
|
687
|
-
energyLevel,
|
|
688
|
-
engagementScore,
|
|
689
|
-
enhancedStoragePath: enhancedStoragePath,
|
|
690
|
-
socialVideoUrl: socialVideoUrl,
|
|
691
|
-
socialVideoStoragePath,
|
|
692
|
-
socialVideoStatus,
|
|
693
|
-
socialVideoError,
|
|
694
|
-
socialVideoSourceAudio
|
|
695
|
-
} = _a, publicReply = __objRest(_a, [
|
|
696
|
-
"listenerPhoneNumber",
|
|
697
|
-
"notes",
|
|
698
|
-
// AI cluster (only transcription stays public)
|
|
699
|
-
"aiStatus",
|
|
700
|
-
"aiError",
|
|
701
|
-
"aiSummary",
|
|
702
|
-
"aiLabels",
|
|
703
|
-
"sentiment",
|
|
704
|
-
"energyLevel",
|
|
705
|
-
"engagementScore",
|
|
706
|
-
// Voice isolation (only enhancedAudioUrl stays public)
|
|
707
|
-
"enhancedStoragePath",
|
|
708
|
-
// Social-video (entire cluster is creator-only)
|
|
709
|
-
"socialVideoUrl",
|
|
710
|
-
"socialVideoStoragePath",
|
|
711
|
-
"socialVideoStatus",
|
|
712
|
-
"socialVideoError",
|
|
713
|
-
"socialVideoSourceAudio"
|
|
714
|
-
]);
|
|
715
|
-
return publicReply;
|
|
716
|
-
}
|
|
717
|
-
var OrganizationViewSchema = zod.z.object({
|
|
718
|
-
record: OrganizationRecordSchema,
|
|
719
|
-
memberCount: zod.z.number().default(1),
|
|
720
|
-
currentUserRole: zod.z.enum(["owner", "admin", "member"]).optional()
|
|
721
|
-
});
|
|
722
|
-
var OrganizationMemberViewSchema = zod.z.object({
|
|
723
|
-
record: OrganizationMemberRecordSchema,
|
|
724
|
-
profile: ProfileViewBasicSchema
|
|
725
|
-
});
|
|
726
|
-
var OrgInviteViewSchema = zod.z.object({
|
|
727
|
-
record: OrgInviteRecordSchema,
|
|
728
|
-
/** Display name of the user who sent the invite */
|
|
729
|
-
inviterName: zod.z.string().optional(),
|
|
730
|
-
/** Name of the organization */
|
|
731
|
-
orgName: zod.z.string()
|
|
732
|
-
});
|
|
733
|
-
var PromptRepliersSchema = zod.z.object({
|
|
734
|
-
promptId: zod.z.string(),
|
|
735
|
-
repliers: zod.z.record(zod.z.string(), zod.z.object({
|
|
736
|
-
firstReplyAt: FirestoreTimestampSchema,
|
|
737
|
-
lastReplyAt: FirestoreTimestampSchema,
|
|
738
|
-
replyCount: zod.z.number()
|
|
739
|
-
}))
|
|
740
|
-
});
|
|
741
|
-
var PromptWithRepliesSchema = PromptViewSchema.extend({
|
|
742
|
-
replies: zod.z.array(ReplyViewSchema)
|
|
743
|
-
});
|
|
744
|
-
var ReplierSchema = zod.z.object({
|
|
745
|
-
handle: zod.z.string(),
|
|
746
|
-
/** ISO date string */
|
|
747
|
-
lastReplyDate: zod.z.string(),
|
|
748
|
-
/** ISO date string */
|
|
749
|
-
firstReplyAt: zod.z.string(),
|
|
750
|
-
totalReplies: zod.z.number()
|
|
751
|
-
});
|
|
752
|
-
var HandleResolutionSchema = zod.z.discriminatedUnion("type", [
|
|
753
|
-
// Public endpoint (`GET /resolve/:handle`) — project to the basic shape so
|
|
754
|
-
// PII/admin fields (email, phoneNumber, settings, blockedUsers, …) never
|
|
755
|
-
// cross the public API boundary. See `toProfileViewBasic`.
|
|
756
|
-
zod.z.object({ type: zod.z.literal("user"), profile: ProfileViewBasicSchema }),
|
|
757
|
-
zod.z.object({ type: zod.z.literal("org"), org: OrganizationViewSchema })
|
|
758
|
-
]);
|
|
759
|
-
var UserProfileDataSchema = zod.z.object({
|
|
760
|
-
// Public endpoint (`GET /users/:handle/profile`) — basic shape only, so the
|
|
761
|
-
// owner's PII/admin fields never serialize to anonymous callers.
|
|
762
|
-
profileUser: ProfileViewBasicSchema,
|
|
763
|
-
// Each prompt's nested `author` is the profile owner, hydrated from the
|
|
764
|
-
// wide admin profile (`getPromptsForUser` prefetches via getUserDataByUid).
|
|
765
|
-
// Use the PUBLIC prompt/reply shapes so that nested author PII (email,
|
|
766
|
-
// phoneNumber, settings, …) and owner-only prompt enrichment never leak.
|
|
767
|
-
allPromptsWithReplies: zod.z.array(PromptViewPublicSchema.extend({
|
|
768
|
-
replies: zod.z.array(ReplyViewPublicSchema)
|
|
769
|
-
})),
|
|
770
|
-
repliers: zod.z.array(ReplierSchema)
|
|
771
|
-
});
|
|
772
|
-
var RssSummarySchema = zod.z.object({
|
|
773
|
-
title: zod.z.string().optional(),
|
|
774
|
-
description: zod.z.string().optional(),
|
|
775
|
-
image: zod.z.string().optional(),
|
|
776
|
-
link: zod.z.string().optional(),
|
|
777
|
-
items: zod.z.array(zod.z.object({
|
|
778
|
-
title: zod.z.string().optional(),
|
|
779
|
-
link: zod.z.string().optional(),
|
|
780
|
-
content: zod.z.string().optional(),
|
|
781
|
-
pubDate: zod.z.string().optional()
|
|
782
|
-
})).optional(),
|
|
783
|
-
lastFetchedAt: FirestoreTimestampSchema.optional()
|
|
784
|
-
});
|
|
785
|
-
var OrgProfileDataSchema = zod.z.object({
|
|
786
|
-
org: OrganizationViewSchema,
|
|
787
|
-
prompts: zod.z.array(PromptViewSchema),
|
|
788
|
-
rssSummary: RssSummarySchema.nullable()
|
|
789
|
-
});
|
|
790
|
-
var EnrichedReplierSchema = zod.z.object({
|
|
791
|
-
profile: ProfileViewBasicSchema,
|
|
792
|
-
totalReplies: zod.z.number(),
|
|
793
|
-
/** ISO date string */
|
|
794
|
-
lastReplyDate: zod.z.string(),
|
|
795
|
-
/** ISO date string */
|
|
796
|
-
firstReplyAt: zod.z.string(),
|
|
797
|
-
/** Phone number for anonymous repliers (from Firebase Auth, only visible to prompt author) */
|
|
798
|
-
phoneNumber: zod.z.string().optional()
|
|
799
|
-
});
|
|
800
201
|
|
|
801
202
|
// types/audio.ts
|
|
802
203
|
var StrongRefSchema = zod.z.object({
|
|
@@ -855,6 +256,15 @@ var AudioPostRecordSchema = zod.z.object({
|
|
|
855
256
|
orgId: zod.z.string().nullable().optional(),
|
|
856
257
|
/** Denormalized from `reply` presence: `reply` set ⇒ 'reply', else 'prompt'. */
|
|
857
258
|
kind: zod.z.enum(["prompt", "reply"]),
|
|
259
|
+
/**
|
|
260
|
+
* Branch participant pair (author ids) for reply gating — the parties to a
|
|
261
|
+
* reply's sub-thread: the creator (thread-root author) + the responder who
|
|
262
|
+
* opened the branch. Set on replies (deduped, 1–2 ids); absent on prompts
|
|
263
|
+
* (a prompt's repliers are the app's audience policy, not a fixed pair).
|
|
264
|
+
* Inherited down the branch so reply gating is an O(1) field check, never a
|
|
265
|
+
* thread walk. See `specs/antiphony-data-model.md` §6 "Reply gating".
|
|
266
|
+
*/
|
|
267
|
+
threadParticipants: zod.z.array(zod.z.string()).optional(),
|
|
858
268
|
// --- Lexicon fields (public contract) ---
|
|
859
269
|
/** User-authored text (bsky-semantic). May be empty for pure-audio posts. NEVER the transcript. */
|
|
860
270
|
text: zod.z.string().max(3e3),
|
|
@@ -898,7 +308,15 @@ var ActorProfileRecordSchema = zod.z.object({
|
|
|
898
308
|
});
|
|
899
309
|
var ViewerStateSchema = zod.z.object({
|
|
900
310
|
/** True when the authenticated caller authored this post. */
|
|
901
|
-
isAuthor: zod.z.boolean().default(false)
|
|
311
|
+
isAuthor: zod.z.boolean().default(false),
|
|
312
|
+
/**
|
|
313
|
+
* Whether the caller may reply to this post (reply gating, §6). A prompt is
|
|
314
|
+
* repliable by any authenticated viewer (the app's audience-policy default);
|
|
315
|
+
* a reply only by its branch participants (`{ creator, branch responder }`).
|
|
316
|
+
*/
|
|
317
|
+
canReply: zod.z.boolean().default(false),
|
|
318
|
+
/** Why `canReply` is false, when it is (omitted when the caller can reply). */
|
|
319
|
+
replyDisabledReason: zod.z.enum(["unauthenticated", "not_a_participant"]).optional()
|
|
902
320
|
});
|
|
903
321
|
var PostRecordPublicSchema = zod.z.object({
|
|
904
322
|
text: zod.z.string(),
|
|
@@ -941,19 +359,6 @@ var CreateAudioPostRequestSchema = zod.z.object({
|
|
|
941
359
|
message: "Post must have text or an audio embed",
|
|
942
360
|
path: ["text"]
|
|
943
361
|
});
|
|
944
|
-
var CreatePromptRequestSchema = zod.z.object({
|
|
945
|
-
// Bounds chosen so the public prompt hero never needs to clip: title +
|
|
946
|
-
// description sit between the two dots inside an h-dvh, overflow-hidden
|
|
947
|
-
// layout. 80/200 keeps typical content to a few lines on short phones.
|
|
948
|
-
// (Record-level schema stays unbounded so any pre-existing longer values
|
|
949
|
-
// still read cleanly — this only gates new writes.)
|
|
950
|
-
title: zod.z.string().min(3).max(80),
|
|
951
|
-
description: zod.z.string().max(200).optional(),
|
|
952
|
-
audioUrl: zod.z.string().url().or(zod.z.literal("")),
|
|
953
|
-
setAsGreeting: zod.z.union([zod.z.boolean(), zod.z.string().transform((val) => val === "true")]).optional(),
|
|
954
|
-
/** Explicit org context override (normally inferred from auth.currentOrg) */
|
|
955
|
-
orgId: zod.z.string().nullable().optional()
|
|
956
|
-
});
|
|
957
362
|
var UpdateProfileRequestSchema = zod.z.object({
|
|
958
363
|
handle: zod.z.string().min(3).max(20).regex(/^[a-zA-Z0-9_]+$/).optional(),
|
|
959
364
|
displayName: zod.z.string().max(50).optional(),
|
|
@@ -975,105 +380,18 @@ var UpdateProfileRequestSchema = zod.z.object({
|
|
|
975
380
|
/** When true, surfaces the linked Bluesky identity on the public profile. */
|
|
976
381
|
showBlueskyPublicly: zod.z.boolean().optional()
|
|
977
382
|
});
|
|
978
|
-
var FcmTokenRequestSchema = zod.z.object({
|
|
979
|
-
// FCM registration tokens are typically ~163–200 chars; Google's docs
|
|
980
|
-
// don't publish a hard max but 4096 is a safe upper bound that prevents
|
|
981
|
-
// multi-MB payloads while accommodating any plausible FCM token format.
|
|
982
|
-
token: zod.z.string().min(1).max(4096)
|
|
983
|
-
});
|
|
984
|
-
var BadgeResetRequestSchema = zod.z.object({
|
|
985
|
-
type: zod.z.enum(["new_replier", "unread_reply"])
|
|
986
|
-
});
|
|
987
|
-
var CreateOrgRequestSchema = zod.z.object({
|
|
988
|
-
name: zod.z.string().min(3).max(50),
|
|
989
|
-
slug: zod.z.string().min(3).max(30).regex(/^[a-z0-9-]+$/),
|
|
990
|
-
avatarUrl: zod.z.string().url().optional(),
|
|
991
|
-
rssFeedUrl: zod.z.string().url().optional(),
|
|
992
|
-
websiteUrl: zod.z.string().url().optional(),
|
|
993
|
-
// 500 chars — enough for a multi-sentence blurb, prevents multi-MB writes.
|
|
994
|
-
description: zod.z.string().max(500).optional()
|
|
995
|
-
});
|
|
996
|
-
var UpdateOrgRequestSchema = zod.z.object({
|
|
997
|
-
name: zod.z.string().min(3).max(50).optional(),
|
|
998
|
-
slug: zod.z.string().min(3).max(30).regex(/^[a-z0-9-]+$/).optional(),
|
|
999
|
-
// 500 chars — matches CreateOrgRequestSchema.description.
|
|
1000
|
-
description: zod.z.string().max(500).optional(),
|
|
1001
|
-
avatarUrl: zod.z.string().url().nullable().optional(),
|
|
1002
|
-
rssFeedUrl: zod.z.string().url().nullable().optional(),
|
|
1003
|
-
websiteUrl: zod.z.string().url().nullable().optional(),
|
|
1004
|
-
billingEmail: zod.z.string().email().nullable().optional(),
|
|
1005
|
-
// 253 chars — the DNS spec maximum for a fully-qualified domain name.
|
|
1006
|
-
domain: zod.z.string().max(253).nullable().optional()
|
|
1007
|
-
});
|
|
1008
|
-
var CreateOrgInviteRequestSchema = zod.z.object({
|
|
1009
|
-
email: zod.z.string().email(),
|
|
1010
|
-
role: zod.z.enum(["admin", "member"])
|
|
1011
|
-
});
|
|
1012
|
-
var UpdateMemberRoleRequestSchema = zod.z.object({
|
|
1013
|
-
role: zod.z.enum(["admin", "member"])
|
|
1014
|
-
});
|
|
1015
|
-
var SwitchOrgRequestSchema = zod.z.object({
|
|
1016
|
-
/** orgId to switch to, or null to switch to personal context */
|
|
1017
|
-
orgId: zod.z.string().nullable()
|
|
1018
|
-
});
|
|
1019
|
-
var ConnectorConfigInputSchema = ConnectorConfigRecordSchema.omit({
|
|
1020
|
-
connectorType: true,
|
|
1021
|
-
ownerId: true,
|
|
1022
|
-
status: true,
|
|
1023
|
-
createdAt: true,
|
|
1024
|
-
updatedAt: true
|
|
1025
|
-
});
|
|
1026
|
-
var ConnectorConfigUpdateSchema = ConnectorConfigInputSchema.partial();
|
|
1027
|
-
var PersonNotesUpdateSchema = zod.z.object({
|
|
1028
|
-
notes: zod.z.string().max(1e4).optional(),
|
|
1029
|
-
tags: zod.z.array(zod.z.string().max(64)).max(50).optional()
|
|
1030
|
-
});
|
|
1031
|
-
var PersonMergeRequestSchema = zod.z.object({
|
|
1032
|
-
alternateUid: zod.z.string().min(1)
|
|
1033
|
-
});
|
|
1034
|
-
var ScreeningRuleInputSchema = zod.z.object({
|
|
1035
|
-
e164: zod.z.string().regex(/^\+[1-9]\d{6,14}$/, "Must be an E.164 phone number"),
|
|
1036
|
-
label: zod.z.string().max(120).nullable().optional(),
|
|
1037
|
-
action: zod.z.enum(["allow", "screen"]),
|
|
1038
|
-
expiresAt: zod.z.union([zod.z.string(), zod.z.number()]).nullable().optional().refine((v) => v == null || !Number.isNaN(new Date(v).getTime()), {
|
|
1039
|
-
message: "Must be a valid ISO date string or epoch-ms timestamp"
|
|
1040
|
-
})
|
|
1041
|
-
});
|
|
1042
|
-
var ScreeningRuleUpdateSchema = ScreeningRuleInputSchema.partial();
|
|
1043
|
-
var UpdateReplyStatusRequestSchema = zod.z.object({
|
|
1044
|
-
status: zod.z.enum(["live", "archived", "deleted"])
|
|
1045
|
-
});
|
|
1046
|
-
var BulkReplyActionRequestSchema = zod.z.object({
|
|
1047
|
-
replyIds: zod.z.array(zod.z.string()).min(1).max(100),
|
|
1048
|
-
action: zod.z.enum(["markRead", "archive", "delete", "restore"])
|
|
1049
|
-
});
|
|
1050
383
|
var PublicProfileDtoSchema = ProfileViewBasicSchema.extend({
|
|
1051
384
|
bluesky: zod.z.object({
|
|
1052
385
|
handle: zod.z.string(),
|
|
1053
386
|
did: zod.z.string()
|
|
1054
|
-
}).optional()
|
|
1055
|
-
rssFeedUrl: zod.z.string().nullable().optional()
|
|
1056
|
-
});
|
|
1057
|
-
var PublicReplyDtoSchema = zod.z.object({
|
|
1058
|
-
id: zod.z.string(),
|
|
1059
|
-
audioUrl: zod.z.string().url(),
|
|
1060
|
-
duration: zod.z.number().optional(),
|
|
1061
|
-
createdAt: FirestoreTimestampSchema,
|
|
1062
|
-
transcription: zod.z.string().optional(),
|
|
1063
|
-
sentiment: zod.z.enum(["Positive", "Negative", "Neutral"]).optional(),
|
|
1064
|
-
aiSummary: zod.z.string().optional(),
|
|
1065
|
-
author: PublicProfileDtoSchema
|
|
387
|
+
}).optional()
|
|
1066
388
|
});
|
|
1067
389
|
var ActorViewSchema = ProfileViewSelfSchema;
|
|
1068
390
|
|
|
1069
391
|
// nsid.ts
|
|
1070
392
|
var NSID = {
|
|
1071
|
-
//
|
|
1072
|
-
|
|
1073
|
-
Reply: "com.voxpop.audio.reply",
|
|
1074
|
-
Profile: "com.voxpop.actor.profile",
|
|
1075
|
-
// Antiphony canonical record types (dev.antiphony.*). Added additively in
|
|
1076
|
-
// Stream 1; see lexicons/dev/antiphony/ + packages/shared/types/audio.ts.
|
|
393
|
+
// Antiphony canonical record types (dev.antiphony.*).
|
|
394
|
+
// See lexicons/dev/antiphony/ + packages/shared/types/audio.ts.
|
|
1077
395
|
AudioPost: "dev.antiphony.audio.post",
|
|
1078
396
|
AudioTranscript: "dev.antiphony.audio.transcript",
|
|
1079
397
|
ActorProfile: "dev.antiphony.actor.profile"
|
|
@@ -1083,10 +401,7 @@ var EMBED_NSID = {
|
|
|
1083
401
|
RecordWithAudio: "dev.antiphony.embed.recordWithAudio"
|
|
1084
402
|
};
|
|
1085
403
|
var COLLECTIONS = {
|
|
1086
|
-
|
|
1087
|
-
[NSID.Reply]: "replies",
|
|
1088
|
-
[NSID.Profile]: "users",
|
|
1089
|
-
// Antiphony: one post collection + the transcript enrichment namespace.
|
|
404
|
+
// One post collection + the transcript enrichment namespace + actors.
|
|
1090
405
|
[NSID.AudioPost]: "posts",
|
|
1091
406
|
[NSID.AudioTranscript]: "audio_transcripts",
|
|
1092
407
|
[NSID.ActorProfile]: "users"
|
|
@@ -1192,76 +507,31 @@ exports.AudioEmbedSchema = AudioEmbedSchema;
|
|
|
1192
507
|
exports.AudioEmbedViewSchema = AudioEmbedViewSchema;
|
|
1193
508
|
exports.AudioPostRecordSchema = AudioPostRecordSchema;
|
|
1194
509
|
exports.AudioPostViewSchema = AudioPostViewSchema;
|
|
1195
|
-
exports.BadgeResetRequestSchema = BadgeResetRequestSchema;
|
|
1196
510
|
exports.BlobRefSchema = BlobRefSchema;
|
|
1197
|
-
exports.BulkReplyActionRequestSchema = BulkReplyActionRequestSchema;
|
|
1198
511
|
exports.COLLECTIONS = COLLECTIONS;
|
|
1199
|
-
exports.CallForwardingConfigSchema = CallForwardingConfigSchema;
|
|
1200
512
|
exports.ConflictError = ConflictError;
|
|
1201
|
-
exports.ConnectorConfigInputSchema = ConnectorConfigInputSchema;
|
|
1202
|
-
exports.ConnectorConfigRecordSchema = ConnectorConfigRecordSchema;
|
|
1203
|
-
exports.ConnectorConfigUpdateSchema = ConnectorConfigUpdateSchema;
|
|
1204
|
-
exports.ConnectorStatusSchema = ConnectorStatusSchema;
|
|
1205
|
-
exports.ConnectorTypeSchema = ConnectorTypeSchema;
|
|
1206
513
|
exports.CreateAudioPostRequestSchema = CreateAudioPostRequestSchema;
|
|
1207
|
-
exports.CreateOrgInviteRequestSchema = CreateOrgInviteRequestSchema;
|
|
1208
|
-
exports.CreateOrgRequestSchema = CreateOrgRequestSchema;
|
|
1209
|
-
exports.CreatePromptRequestSchema = CreatePromptRequestSchema;
|
|
1210
514
|
exports.EMBED_NSID = EMBED_NSID;
|
|
1211
|
-
exports.EnrichedReplierSchema = EnrichedReplierSchema;
|
|
1212
|
-
exports.FcmTokenRequestSchema = FcmTokenRequestSchema;
|
|
1213
515
|
exports.FirestoreTimestampSchema = FirestoreTimestampSchema;
|
|
1214
516
|
exports.ForbiddenError = ForbiddenError;
|
|
1215
|
-
exports.HandleResolutionSchema = HandleResolutionSchema;
|
|
1216
517
|
exports.NSID = NSID;
|
|
1217
518
|
exports.NotFoundError = NotFoundError;
|
|
1218
|
-
exports.OrgInviteRecordSchema = OrgInviteRecordSchema;
|
|
1219
|
-
exports.OrgInviteViewSchema = OrgInviteViewSchema;
|
|
1220
|
-
exports.OrgProfileDataSchema = OrgProfileDataSchema;
|
|
1221
|
-
exports.OrganizationMemberRecordSchema = OrganizationMemberRecordSchema;
|
|
1222
|
-
exports.OrganizationMemberViewSchema = OrganizationMemberViewSchema;
|
|
1223
|
-
exports.OrganizationRecordSchema = OrganizationRecordSchema;
|
|
1224
|
-
exports.OrganizationViewSchema = OrganizationViewSchema;
|
|
1225
|
-
exports.PersonEnrichmentRecordSchema = PersonEnrichmentRecordSchema;
|
|
1226
|
-
exports.PersonMergeRequestSchema = PersonMergeRequestSchema;
|
|
1227
|
-
exports.PersonNotesUpdateSchema = PersonNotesUpdateSchema;
|
|
1228
519
|
exports.PostRecordPublicSchema = PostRecordPublicSchema;
|
|
1229
520
|
exports.ProfileViewAdminSchema = ProfileViewAdminSchema;
|
|
1230
521
|
exports.ProfileViewBasicSchema = ProfileViewBasicSchema;
|
|
1231
522
|
exports.ProfileViewDetailedSchema = ProfileViewDetailedSchema;
|
|
1232
523
|
exports.ProfileViewSchema = ProfileViewSchema;
|
|
1233
524
|
exports.ProfileViewSelfSchema = ProfileViewSelfSchema;
|
|
1234
|
-
exports.PromptRecordSchema = PromptRecordSchema;
|
|
1235
|
-
exports.PromptRepliersSchema = PromptRepliersSchema;
|
|
1236
|
-
exports.PromptViewPublicSchema = PromptViewPublicSchema;
|
|
1237
|
-
exports.PromptViewSchema = PromptViewSchema;
|
|
1238
|
-
exports.PromptWithRepliesSchema = PromptWithRepliesSchema;
|
|
1239
525
|
exports.PublicProfileDtoSchema = PublicProfileDtoSchema;
|
|
1240
|
-
exports.PublicReplyDtoSchema = PublicReplyDtoSchema;
|
|
1241
526
|
exports.RateLimitError = RateLimitError;
|
|
1242
|
-
exports.ReplierSchema = ReplierSchema;
|
|
1243
|
-
exports.ReplyEnrichmentRecordSchema = ReplyEnrichmentRecordSchema;
|
|
1244
|
-
exports.ReplyRecordSchema = ReplyRecordSchema;
|
|
1245
527
|
exports.ReplyRefSchema = ReplyRefSchema;
|
|
1246
|
-
exports.ReplyViewPublicSchema = ReplyViewPublicSchema;
|
|
1247
|
-
exports.ReplyViewSchema = ReplyViewSchema;
|
|
1248
|
-
exports.RssSummarySchema = RssSummarySchema;
|
|
1249
|
-
exports.ScreeningRuleInputSchema = ScreeningRuleInputSchema;
|
|
1250
|
-
exports.ScreeningRuleRecordSchema = ScreeningRuleRecordSchema;
|
|
1251
|
-
exports.ScreeningRuleUpdateSchema = ScreeningRuleUpdateSchema;
|
|
1252
528
|
exports.ServiceError = ServiceError;
|
|
1253
|
-
exports.SipEnrichmentSchema = SipEnrichmentSchema;
|
|
1254
529
|
exports.StrongRefSchema = StrongRefSchema;
|
|
1255
|
-
exports.SwitchOrgRequestSchema = SwitchOrgRequestSchema;
|
|
1256
530
|
exports.TimedTranscriptSchema = TimedTranscriptSchema;
|
|
1257
531
|
exports.TranscriptEnrichmentRecordSchema = TranscriptEnrichmentRecordSchema;
|
|
1258
532
|
exports.TranscriptSegmentSchema = TranscriptSegmentSchema;
|
|
1259
533
|
exports.UnauthorizedError = UnauthorizedError;
|
|
1260
|
-
exports.UpdateMemberRoleRequestSchema = UpdateMemberRoleRequestSchema;
|
|
1261
|
-
exports.UpdateOrgRequestSchema = UpdateOrgRequestSchema;
|
|
1262
534
|
exports.UpdateProfileRequestSchema = UpdateProfileRequestSchema;
|
|
1263
|
-
exports.UpdateReplyStatusRequestSchema = UpdateReplyStatusRequestSchema;
|
|
1264
|
-
exports.UserProfileDataSchema = UserProfileDataSchema;
|
|
1265
535
|
exports.UserRecordSchema = UserRecordSchema;
|
|
1266
536
|
exports.ValidationError = ValidationError;
|
|
1267
537
|
exports.ViewerStateSchema = ViewerStateSchema;
|
|
@@ -1272,5 +542,3 @@ exports.nsidForCollection = nsidForCollection;
|
|
|
1272
542
|
exports.reportError = reportError;
|
|
1273
543
|
exports.resolveAudioUrl = resolveAudioUrl;
|
|
1274
544
|
exports.toProfileViewBasic = toProfileViewBasic;
|
|
1275
|
-
exports.toPromptViewPublic = toPromptViewPublic;
|
|
1276
|
-
exports.toReplyViewPublic = toReplyViewPublic;
|