@antiphony/shared 0.3.0 → 0.5.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.
Files changed (45) hide show
  1. package/README.md +4 -4
  2. package/dist/cjs/api-codecs.cjs +149 -142
  3. package/dist/cjs/api-codecs.d.cts +157 -68
  4. package/dist/cjs/index.cjs +187 -192
  5. package/dist/cjs/index.d.cts +310 -7
  6. package/dist/cjs/nsid.cjs +6 -9
  7. package/dist/cjs/nsid.d.cts +7 -8
  8. package/dist/cjs/types/audio.cjs +133 -119
  9. package/dist/cjs/types/audio.d.cts +343 -199
  10. package/dist/cjs/types/blob.cjs +5 -9
  11. package/dist/cjs/types/blob.d.cts +21 -21
  12. package/dist/cjs/types/records.cjs +0 -45
  13. package/dist/cjs/types/records.d.cts +1 -103
  14. package/dist/esm/api-codecs.d.ts +187 -98
  15. package/dist/esm/api-codecs.js +4 -5
  16. package/dist/esm/chunk-D655OH2I.js +35 -0
  17. package/dist/esm/chunk-F5ZKFJL2.js +39 -0
  18. package/dist/esm/{chunk-6LROFBKK.js → chunk-SBYNIQRZ.js} +7 -9
  19. package/dist/esm/chunk-SMK4OZNU.js +17 -0
  20. package/dist/esm/chunk-TVOXIQKF.js +294 -0
  21. package/dist/esm/index.d.ts +310 -7
  22. package/dist/esm/index.js +5 -7
  23. package/dist/esm/nsid.d.ts +7 -8
  24. package/dist/esm/nsid.js +1 -1
  25. package/dist/esm/types/audio.d.ts +420 -276
  26. package/dist/esm/types/audio.js +3 -4
  27. package/dist/esm/types/blob.d.ts +21 -21
  28. package/dist/esm/types/blob.js +1 -1
  29. package/dist/esm/types/records.d.ts +1 -103
  30. package/dist/esm/types/records.js +1 -1
  31. package/package.json +94 -26
  32. package/dist/cjs/types/api.cjs +0 -166
  33. package/dist/cjs/types/api.d.cts +0 -242
  34. package/dist/cjs/types/views.cjs +0 -179
  35. package/dist/cjs/types/views.d.cts +0 -726
  36. package/dist/esm/chunk-5EHV73BA.js +0 -20
  37. package/dist/esm/chunk-F7IHVM34.js +0 -144
  38. package/dist/esm/chunk-FDM5FDN4.js +0 -46
  39. package/dist/esm/chunk-IHIBHQBJ.js +0 -78
  40. package/dist/esm/chunk-R6SBR3IG.js +0 -97
  41. package/dist/esm/chunk-Y6HNNRVD.js +0 -12
  42. package/dist/esm/types/api.d.ts +0 -242
  43. package/dist/esm/types/api.js +0 -4
  44. package/dist/esm/types/views.d.ts +0 -726
  45. package/dist/esm/types/views.js +0 -3
@@ -1,242 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- /**
4
- * Public Profile DTO — the public-facing profile shape.
5
- * Equivalent to ProfileViewBasicSchema plus a few enrichment fields.
6
- */
7
- declare const PublicProfileDtoSchema: z.ZodObject<{
8
- id: z.ZodString;
9
- handle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
10
- displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
11
- avatarUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
12
- bio: z.ZodOptional<z.ZodNullable<z.ZodString>>;
13
- website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
14
- links: z.ZodOptional<z.ZodArray<z.ZodObject<{
15
- label: z.ZodString;
16
- url: z.ZodString;
17
- }, "strip", z.ZodTypeAny, {
18
- label: string;
19
- url: string;
20
- }, {
21
- label: string;
22
- url: string;
23
- }>, "many">>;
24
- stats: z.ZodOptional<z.ZodObject<{
25
- followers: z.ZodDefault<z.ZodNumber>;
26
- following: z.ZodDefault<z.ZodNumber>;
27
- prompts: z.ZodDefault<z.ZodNumber>;
28
- }, "strip", z.ZodTypeAny, {
29
- followers: number;
30
- following: number;
31
- prompts: number;
32
- }, {
33
- followers?: number | undefined;
34
- following?: number | undefined;
35
- prompts?: number | undefined;
36
- }>>;
37
- badges: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
38
- isVerified: z.ZodOptional<z.ZodBoolean>;
39
- createdAt: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodString, z.ZodNumber, z.ZodDate]>, Date, unknown>>;
40
- } & {
41
- bluesky: z.ZodOptional<z.ZodObject<{
42
- handle: z.ZodString;
43
- did: z.ZodString;
44
- }, "strip", z.ZodTypeAny, {
45
- handle: string;
46
- did: string;
47
- }, {
48
- handle: string;
49
- did: string;
50
- }>>;
51
- }, "strip", z.ZodTypeAny, {
52
- id: string;
53
- handle?: string | null | undefined;
54
- displayName?: string | null | undefined;
55
- bio?: string | null | undefined;
56
- avatarUrl?: string | null | undefined;
57
- website?: string | null | undefined;
58
- links?: {
59
- label: string;
60
- url: string;
61
- }[] | undefined;
62
- createdAt?: Date | undefined;
63
- bluesky?: {
64
- handle: string;
65
- did: string;
66
- } | undefined;
67
- stats?: {
68
- followers: number;
69
- following: number;
70
- prompts: number;
71
- } | undefined;
72
- badges?: string[] | undefined;
73
- isVerified?: boolean | undefined;
74
- }, {
75
- id: string;
76
- handle?: string | null | undefined;
77
- displayName?: string | null | undefined;
78
- bio?: string | null | undefined;
79
- avatarUrl?: string | null | undefined;
80
- website?: string | null | undefined;
81
- links?: {
82
- label: string;
83
- url: string;
84
- }[] | undefined;
85
- createdAt?: unknown;
86
- bluesky?: {
87
- handle: string;
88
- did: string;
89
- } | undefined;
90
- stats?: {
91
- followers?: number | undefined;
92
- following?: number | undefined;
93
- prompts?: number | undefined;
94
- } | undefined;
95
- badges?: string[] | undefined;
96
- isVerified?: boolean | undefined;
97
- }>;
98
- type PublicProfileDto = z.infer<typeof PublicProfileDtoSchema>;
99
- /**
100
- * Actor View — the full view returned to the authenticated user about themselves.
101
- * Uses ProfileViewSelfSchema which includes private settings but not admin fields.
102
- */
103
- declare const ActorViewSchema: z.ZodObject<{
104
- id: z.ZodString;
105
- handle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
106
- displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
107
- avatarUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
108
- bio: z.ZodOptional<z.ZodNullable<z.ZodString>>;
109
- website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
110
- links: z.ZodOptional<z.ZodArray<z.ZodObject<{
111
- label: z.ZodString;
112
- url: z.ZodString;
113
- }, "strip", z.ZodTypeAny, {
114
- label: string;
115
- url: string;
116
- }, {
117
- label: string;
118
- url: string;
119
- }>, "many">>;
120
- stats: z.ZodOptional<z.ZodObject<{
121
- followers: z.ZodDefault<z.ZodNumber>;
122
- following: z.ZodDefault<z.ZodNumber>;
123
- prompts: z.ZodDefault<z.ZodNumber>;
124
- }, "strip", z.ZodTypeAny, {
125
- followers: number;
126
- following: number;
127
- prompts: number;
128
- }, {
129
- followers?: number | undefined;
130
- following?: number | undefined;
131
- prompts?: number | undefined;
132
- }>>;
133
- badges: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
134
- isVerified: z.ZodOptional<z.ZodBoolean>;
135
- createdAt: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodString, z.ZodNumber, z.ZodDate]>, Date, unknown>>;
136
- } & {
137
- bluesky: z.ZodOptional<z.ZodObject<{
138
- handle: z.ZodString;
139
- did: z.ZodString;
140
- }, "strip", z.ZodTypeAny, {
141
- handle: string;
142
- did: string;
143
- }, {
144
- handle: string;
145
- did: string;
146
- }>>;
147
- usageIntent: z.ZodOptional<z.ZodNullable<z.ZodString>>;
148
- } & {
149
- phoneNumber: z.ZodOptional<z.ZodNullable<z.ZodString>>;
150
- email: z.ZodOptional<z.ZodString>;
151
- lastSeenAt: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodString, z.ZodNumber, z.ZodDate]>, Date, unknown>>;
152
- lastActiveAt: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodString, z.ZodNumber, z.ZodDate]>, Date, unknown>>;
153
- unreadReplyCount: z.ZodDefault<z.ZodNumber>;
154
- newReplierCount: z.ZodDefault<z.ZodNumber>;
155
- tier: z.ZodOptional<z.ZodEnum<["free", "creator_pro"]>>;
156
- showBlueskyPublicly: z.ZodOptional<z.ZodBoolean>;
157
- settings: z.ZodOptional<z.ZodObject<{
158
- notifications: z.ZodOptional<z.ZodBoolean>;
159
- theme: z.ZodOptional<z.ZodString>;
160
- }, "strip", z.ZodTypeAny, {
161
- notifications?: boolean | undefined;
162
- theme?: string | undefined;
163
- }, {
164
- notifications?: boolean | undefined;
165
- theme?: string | undefined;
166
- }>>;
167
- }, "strip", z.ZodTypeAny, {
168
- id: string;
169
- unreadReplyCount: number;
170
- newReplierCount: number;
171
- handle?: string | null | undefined;
172
- usageIntent?: string | null | undefined;
173
- displayName?: string | null | undefined;
174
- bio?: string | null | undefined;
175
- avatarUrl?: string | null | undefined;
176
- website?: string | null | undefined;
177
- links?: {
178
- label: string;
179
- url: string;
180
- }[] | undefined;
181
- showBlueskyPublicly?: boolean | undefined;
182
- createdAt?: Date | undefined;
183
- tier?: "free" | "creator_pro" | undefined;
184
- bluesky?: {
185
- handle: string;
186
- did: string;
187
- } | undefined;
188
- stats?: {
189
- followers: number;
190
- following: number;
191
- prompts: number;
192
- } | undefined;
193
- badges?: string[] | undefined;
194
- isVerified?: boolean | undefined;
195
- phoneNumber?: string | null | undefined;
196
- email?: string | undefined;
197
- lastSeenAt?: Date | undefined;
198
- lastActiveAt?: Date | undefined;
199
- settings?: {
200
- notifications?: boolean | undefined;
201
- theme?: string | undefined;
202
- } | undefined;
203
- }, {
204
- id: string;
205
- handle?: string | null | undefined;
206
- usageIntent?: string | null | undefined;
207
- displayName?: string | null | undefined;
208
- bio?: string | null | undefined;
209
- avatarUrl?: string | null | undefined;
210
- website?: string | null | undefined;
211
- links?: {
212
- label: string;
213
- url: string;
214
- }[] | undefined;
215
- showBlueskyPublicly?: boolean | undefined;
216
- createdAt?: unknown;
217
- tier?: "free" | "creator_pro" | undefined;
218
- bluesky?: {
219
- handle: string;
220
- did: string;
221
- } | undefined;
222
- stats?: {
223
- followers?: number | undefined;
224
- following?: number | undefined;
225
- prompts?: number | undefined;
226
- } | undefined;
227
- badges?: string[] | undefined;
228
- isVerified?: boolean | undefined;
229
- phoneNumber?: string | null | undefined;
230
- email?: string | undefined;
231
- lastSeenAt?: unknown;
232
- lastActiveAt?: unknown;
233
- unreadReplyCount?: number | undefined;
234
- newReplierCount?: number | undefined;
235
- settings?: {
236
- notifications?: boolean | undefined;
237
- theme?: string | undefined;
238
- } | undefined;
239
- }>;
240
- type ActorView = z.infer<typeof ActorViewSchema>;
241
-
242
- export { type ActorView, ActorViewSchema, type PublicProfileDto, PublicProfileDtoSchema };
@@ -1,179 +0,0 @@
1
- 'use strict';
2
-
3
- var zod = require('zod');
4
-
5
- // types/views.ts
6
- function httpsUrl() {
7
- return zod.z.string().trim().url().refine((u) => /^https?:\/\//i.test(u), {
8
- message: "URL must use the http or https scheme"
9
- });
10
- }
11
- var FirestoreTimestampSchema = zod.z.union([
12
- zod.z.custom((data) => {
13
- return data && typeof data === "object" && (typeof data.toDate === "function" || "seconds" in data && "nanoseconds" in data);
14
- }),
15
- zod.z.string(),
16
- zod.z.number(),
17
- zod.z.date()
18
- ]).transform((data, ctx) => {
19
- let date;
20
- if (data instanceof Date) {
21
- date = data;
22
- } else if (typeof data === "string") {
23
- date = new Date(data);
24
- } else if (typeof data === "number") {
25
- date = new Date(data);
26
- } else if (typeof data.toDate === "function") {
27
- date = data.toDate();
28
- } else {
29
- const timestamp = data;
30
- date = new Date(timestamp.seconds * 1e3 + timestamp.nanoseconds / 1e6);
31
- }
32
- if (Number.isNaN(date.getTime())) {
33
- ctx.addIssue({
34
- code: zod.z.ZodIssueCode.custom,
35
- message: "FirestoreTimestamp coerced to Invalid Date"
36
- });
37
- return zod.z.NEVER;
38
- }
39
- return date;
40
- });
41
- zod.z.object({
42
- /** Unique Firebase UID */
43
- id: zod.z.string(),
44
- /** Public handle (e.g. @brad). Optional for Lite Users. */
45
- handle: zod.z.string().min(3).max(20).regex(/^[a-zA-Z0-9_]+$/).nullable().optional(),
46
- /** User stated intent (e.g. "Podcaster", "Listener") */
47
- usageIntent: zod.z.string().nullable().optional(),
48
- /** Domain for federated handle support. */
49
- domain: zod.z.string().default("antiphony.dev"),
50
- /**
51
- * Display Name (e.g. "Brad Thorson"). Nullable: Firestore stores `null`
52
- * when the user clears this field via the settings form, and the schema
53
- * must match storage reality or `UserRecordSchema.parse` (in
54
- * `getUserRecordByUid`) will throw.
55
- */
56
- displayName: zod.z.string().max(50).nullable().optional(),
57
- /** Short bio/description — nullable for the same reason as displayName. */
58
- bio: zod.z.string().max(160).nullable().optional(),
59
- /** URL to avatar image — nullable for the same reason as displayName. */
60
- avatarUrl: zod.z.string().url().nullable().optional(),
61
- /** Optional personal website surfaced on the public profile. */
62
- website: httpsUrl().nullable().optional(),
63
- /** Up to 5 additional public links (label + URL) shown under the bio. */
64
- links: zod.z.array(zod.z.object({
65
- label: zod.z.string().min(1).max(40),
66
- url: httpsUrl()
67
- })).max(5).optional(),
68
- /** When true and a Bluesky identity is linked, surfaces it on the public profile. */
69
- showBlueskyPublicly: zod.z.boolean().optional(),
70
- /** Server timestamp of creation */
71
- createdAt: FirestoreTimestampSchema,
72
- /** Individual account tier — free or creator_pro */
73
- tier: zod.z.enum(["free", "creator_pro"]).default("free"),
74
- /** Account status. Deactivated accounts retain data but are excluded from lookups. */
75
- status: zod.z.enum(["active", "deactivated"]).default("active"),
76
- /** Timestamp when the account was deactivated (soft deleted) */
77
- deactivatedAt: FirestoreTimestampSchema.optional()
78
- });
79
-
80
- // types/views.ts
81
- var ProfileViewBasicSchema = zod.z.object({
82
- id: zod.z.string(),
83
- handle: zod.z.string().nullable().optional(),
84
- // `displayName` and `bio` are `.nullable()` — Firestore stores `null` for
85
- // empty values on these fields (see users-dependencies.ts), and Zod's
86
- // `.optional()` alone rejects `null`. Consumers already use truthy
87
- // checks / `??` / `||`, so widening the type to include `null` is safe.
88
- displayName: zod.z.string().nullable().optional(),
89
- avatarUrl: zod.z.string().nullable().optional(),
90
- bio: zod.z.string().nullable().optional(),
91
- /** Personal website link surfaced on the public profile. */
92
- website: zod.z.string().nullable().optional(),
93
- /** Public links (label + URL) shown under the bio. */
94
- links: zod.z.array(zod.z.object({
95
- label: zod.z.string(),
96
- url: zod.z.string()
97
- })).optional(),
98
- /**
99
- * AT Protocol identity, surfaced on the public profile only when the user
100
- * opts in (`UserRecord.showBlueskyPublicly === true`). Projection happens
101
- * in the user dependency layer; this schema simply allows the field.
102
- */
103
- bluesky: zod.z.object({
104
- handle: zod.z.string(),
105
- did: zod.z.string()
106
- }).optional(),
107
- stats: zod.z.object({
108
- followers: zod.z.number().default(0),
109
- following: zod.z.number().default(0),
110
- prompts: zod.z.number().default(0)
111
- }).optional(),
112
- badges: zod.z.array(zod.z.string()).optional(),
113
- isVerified: zod.z.boolean().optional(),
114
- createdAt: FirestoreTimestampSchema.optional()
115
- });
116
- function toProfileViewBasic(profile) {
117
- const { id, handle, displayName, avatarUrl, bio, website, links, bluesky, showBlueskyPublicly, stats, badges, isVerified, createdAt } = profile;
118
- return {
119
- id,
120
- handle,
121
- displayName,
122
- avatarUrl,
123
- bio,
124
- website,
125
- links,
126
- bluesky: showBlueskyPublicly ? bluesky : void 0,
127
- stats,
128
- badges,
129
- isVerified,
130
- createdAt
131
- };
132
- }
133
- var ProfileViewDetailedSchema = ProfileViewBasicSchema.extend({
134
- /** AT Protocol Identity link */
135
- bluesky: zod.z.object({
136
- handle: zod.z.string(),
137
- did: zod.z.string()
138
- }).optional(),
139
- usageIntent: zod.z.string().nullable().optional()
140
- });
141
- var ProfileViewSelfSchema = ProfileViewDetailedSchema.extend({
142
- phoneNumber: zod.z.string().nullable().optional(),
143
- email: zod.z.string().optional(),
144
- lastSeenAt: FirestoreTimestampSchema.optional(),
145
- lastActiveAt: FirestoreTimestampSchema.optional(),
146
- unreadReplyCount: zod.z.number().default(0),
147
- newReplierCount: zod.z.number().default(0),
148
- /**
149
- * Account tier from UserRecord — surfaced on the self profile so the
150
- * client can gate paid features. Optional for legacy docs without the
151
- * field; consumers should treat missing as `'free'`.
152
- */
153
- tier: zod.z.enum(["free", "creator_pro"]).optional(),
154
- /**
155
- * Surfaces the linked Bluesky identity (handle + DID) on the public profile
156
- * when true. Persisted on UserRecord; exposed in self/detailed views so the
157
- * settings form can render the toggle's current state.
158
- */
159
- showBlueskyPublicly: zod.z.boolean().optional(),
160
- settings: zod.z.object({
161
- notifications: zod.z.boolean().optional(),
162
- theme: zod.z.string().optional()
163
- }).optional()
164
- });
165
- var ProfileViewAdminSchema = ProfileViewSelfSchema.extend({
166
- blockedUsers: zod.z.array(zod.z.string()).optional(),
167
- followers: zod.z.array(zod.z.string()).optional(),
168
- following: zod.z.array(zod.z.string()).optional(),
169
- reportCount: zod.z.number().optional(),
170
- isBanned: zod.z.boolean().optional()
171
- });
172
- var ProfileViewSchema = ProfileViewAdminSchema;
173
-
174
- exports.ProfileViewAdminSchema = ProfileViewAdminSchema;
175
- exports.ProfileViewBasicSchema = ProfileViewBasicSchema;
176
- exports.ProfileViewDetailedSchema = ProfileViewDetailedSchema;
177
- exports.ProfileViewSchema = ProfileViewSchema;
178
- exports.ProfileViewSelfSchema = ProfileViewSelfSchema;
179
- exports.toProfileViewBasic = toProfileViewBasic;