@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
@@ -6,18 +6,14 @@ var zod = require('zod');
6
6
  var BlobRefSchema = zod.z.object({
7
7
  /** Discriminator for AT Protocol type system */
8
8
  $type: zod.z.literal("blob"),
9
- /** Content Identifier (CID) or URL pointing to the blob */
10
- ref: zod.z.string(),
9
+ /** IPLD link to the blob bytes: the content CID. */
10
+ ref: zod.z.object({
11
+ $link: zod.z.string().min(1)
12
+ }),
11
13
  /** MIME type of the blob (e.g., 'audio/webm') */
12
14
  mimeType: zod.z.string(),
13
15
  /** Size of the blob in bytes */
14
- size: zod.z.number()
16
+ size: zod.z.number().int().min(0)
15
17
  });
16
- function resolveAudioUrl(record) {
17
- var _a;
18
- if ((_a = record.audio) == null ? void 0 : _a.ref) return record.audio.ref;
19
- return record.audioUrl;
20
- }
21
18
 
22
19
  exports.BlobRefSchema = BlobRefSchema;
23
- exports.resolveAudioUrl = resolveAudioUrl;
@@ -1,45 +1,45 @@
1
1
  import { z } from 'zod';
2
2
 
3
3
  /**
4
- * AT Protocol Blob Reference.
4
+ * AT Protocol Blob Reference — the canonical atproto JSON shape:
5
5
  *
6
- * Represents a reference to a binary blob (audio, image, etc.) stored
7
- * outside the record itself. This aligns with AT Protocol's blob handling
8
- * where binary data is stored in the PDS blob store with a CID reference.
6
+ * { "$type": "blob", "ref": { "$link": "<cid>" }, "mimeType", "size" }
9
7
  *
10
- * During the transition from `audioUrl: string` to `audio: BlobRef`,
11
- * both fields coexist. Use `resolveAudioUrl()` to get the correct URL.
8
+ * `ref.$link` is a REAL content CID (CIDv1, raw codec, sha2-256 over the
9
+ * blob bytes), computed at upload time. Storage location is derived from the
10
+ * CID (`blobs/{originAppId}/{cid}`), never stored on the record — records
11
+ * carry content addresses, not provider URLs, so they stay portable.
12
12
  */
13
13
  declare const BlobRefSchema: z.ZodObject<{
14
14
  /** Discriminator for AT Protocol type system */
15
15
  $type: z.ZodLiteral<"blob">;
16
- /** Content Identifier (CID) or URL pointing to the blob */
17
- ref: z.ZodString;
16
+ /** IPLD link to the blob bytes: the content CID. */
17
+ ref: z.ZodObject<{
18
+ $link: z.ZodString;
19
+ }, "strip", z.ZodTypeAny, {
20
+ $link: string;
21
+ }, {
22
+ $link: string;
23
+ }>;
18
24
  /** MIME type of the blob (e.g., 'audio/webm') */
19
25
  mimeType: z.ZodString;
20
26
  /** Size of the blob in bytes */
21
27
  size: z.ZodNumber;
22
28
  }, "strip", z.ZodTypeAny, {
23
29
  $type: "blob";
24
- ref: string;
30
+ ref: {
31
+ $link: string;
32
+ };
25
33
  mimeType: string;
26
34
  size: number;
27
35
  }, {
28
36
  $type: "blob";
29
- ref: string;
37
+ ref: {
38
+ $link: string;
39
+ };
30
40
  mimeType: string;
31
41
  size: number;
32
42
  }>;
33
43
  type BlobRef = z.infer<typeof BlobRefSchema>;
34
- /**
35
- * Resolve the audio URL from a record that may have either `audio` (BlobRef)
36
- * or `audioUrl` (legacy string) field.
37
- *
38
- * Prefers BlobRef.ref if present, falls back to audioUrl.
39
- */
40
- declare function resolveAudioUrl(record: {
41
- audio?: BlobRef;
42
- audioUrl?: string;
43
- }): string | undefined;
44
44
 
45
- export { type BlobRef, BlobRefSchema, resolveAudioUrl };
45
+ export { type BlobRef, BlobRefSchema };
@@ -3,11 +3,6 @@
3
3
  var zod = require('zod');
4
4
 
5
5
  // types/records.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
6
  var FirestoreTimestampSchema = zod.z.union([
12
7
  zod.z.custom((data) => {
13
8
  return data && typeof data === "object" && (typeof data.toDate === "function" || "seconds" in data && "nanoseconds" in data);
@@ -38,45 +33,5 @@ var FirestoreTimestampSchema = zod.z.union([
38
33
  }
39
34
  return date;
40
35
  });
41
- var UserRecordSchema = 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
36
 
80
37
  exports.FirestoreTimestampSchema = FirestoreTimestampSchema;
81
- exports.UserRecordSchema = UserRecordSchema;
82
- exports.httpsUrl = httpsUrl;
@@ -1,19 +1,5 @@
1
1
  import { z } from 'zod';
2
2
 
3
- /**
4
- * Reusable http/https scheme allowlist refinement.
5
- *
6
- * `z.string().url()` accepts any scheme including `javascript:`, `data:`, and
7
- * `vbscript:`, which are stored-XSS vectors when values land in an `<a href>`.
8
- * Wrap any user-supplied URL field with this helper instead of bare `.url()`.
9
- *
10
- * Usage:
11
- * website: httpsUrl().nullable().optional()
12
- * url: httpsUrl()
13
- *
14
- * Audit ref: M7 — javascript: URLs in profile links.
15
- */
16
- declare function httpsUrl(): z.ZodEffects<z.ZodString, string, string>;
17
3
  /**
18
4
  * Firestore Timestamp schema (strict).
19
5
  *
@@ -26,93 +12,5 @@ declare function httpsUrl(): z.ZodEffects<z.ZodString, string, string>;
26
12
  */
27
13
  declare const FirestoreTimestampSchema: z.ZodEffects<z.ZodUnion<[z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodString, z.ZodNumber, z.ZodDate]>, Date, unknown>;
28
14
  type FirestoreTimestamp = Date;
29
- /**
30
- * The raw actor (user) identity record stored in Firestore.
31
- *
32
- * This is the canonical identity record for the Antiphony actor surface.
33
- * Audio content lives in `dev.antiphony.audio.post` (see `types/audio.ts`),
34
- * never on the user record.
35
- */
36
- declare const UserRecordSchema: z.ZodObject<{
37
- /** Unique Firebase UID */
38
- id: z.ZodString;
39
- /** Public handle (e.g. @brad). Optional for Lite Users. */
40
- handle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
41
- /** User stated intent (e.g. "Podcaster", "Listener") */
42
- usageIntent: z.ZodOptional<z.ZodNullable<z.ZodString>>;
43
- /** Domain for federated handle support. */
44
- domain: z.ZodDefault<z.ZodString>;
45
- /**
46
- * Display Name (e.g. "Brad Thorson"). Nullable: Firestore stores `null`
47
- * when the user clears this field via the settings form, and the schema
48
- * must match storage reality or `UserRecordSchema.parse` (in
49
- * `getUserRecordByUid`) will throw.
50
- */
51
- displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
52
- /** Short bio/description — nullable for the same reason as displayName. */
53
- bio: z.ZodOptional<z.ZodNullable<z.ZodString>>;
54
- /** URL to avatar image — nullable for the same reason as displayName. */
55
- avatarUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
56
- /** Optional personal website surfaced on the public profile. */
57
- website: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>;
58
- /** Up to 5 additional public links (label + URL) shown under the bio. */
59
- links: z.ZodOptional<z.ZodArray<z.ZodObject<{
60
- label: z.ZodString;
61
- url: z.ZodEffects<z.ZodString, string, string>;
62
- }, "strip", z.ZodTypeAny, {
63
- label: string;
64
- url: string;
65
- }, {
66
- label: string;
67
- url: string;
68
- }>, "many">>;
69
- /** When true and a Bluesky identity is linked, surfaces it on the public profile. */
70
- showBlueskyPublicly: z.ZodOptional<z.ZodBoolean>;
71
- /** Server timestamp of creation */
72
- createdAt: z.ZodEffects<z.ZodUnion<[z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodString, z.ZodNumber, z.ZodDate]>, Date, unknown>;
73
- /** Individual account tier — free or creator_pro */
74
- tier: z.ZodDefault<z.ZodEnum<["free", "creator_pro"]>>;
75
- /** Account status. Deactivated accounts retain data but are excluded from lookups. */
76
- status: z.ZodDefault<z.ZodEnum<["active", "deactivated"]>>;
77
- /** Timestamp when the account was deactivated (soft deleted) */
78
- deactivatedAt: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodString, z.ZodNumber, z.ZodDate]>, Date, unknown>>;
79
- }, "strip", z.ZodTypeAny, {
80
- status: "active" | "deactivated";
81
- id: string;
82
- domain: string;
83
- createdAt: Date;
84
- tier: "free" | "creator_pro";
85
- handle?: string | null | undefined;
86
- usageIntent?: string | null | undefined;
87
- displayName?: string | null | undefined;
88
- bio?: string | null | undefined;
89
- avatarUrl?: string | null | undefined;
90
- website?: string | null | undefined;
91
- links?: {
92
- label: string;
93
- url: string;
94
- }[] | undefined;
95
- showBlueskyPublicly?: boolean | undefined;
96
- deactivatedAt?: Date | undefined;
97
- }, {
98
- id: string;
99
- status?: "active" | "deactivated" | undefined;
100
- handle?: string | null | undefined;
101
- usageIntent?: string | null | undefined;
102
- domain?: string | undefined;
103
- displayName?: string | null | undefined;
104
- bio?: string | null | undefined;
105
- avatarUrl?: string | null | undefined;
106
- website?: string | null | undefined;
107
- links?: {
108
- label: string;
109
- url: string;
110
- }[] | undefined;
111
- showBlueskyPublicly?: boolean | undefined;
112
- createdAt?: unknown;
113
- tier?: "free" | "creator_pro" | undefined;
114
- deactivatedAt?: unknown;
115
- }>;
116
- type UserRecord = z.infer<typeof UserRecordSchema>;
117
15
 
118
- export { type FirestoreTimestamp, FirestoreTimestampSchema, type UserRecord, UserRecordSchema, httpsUrl };
16
+ export { type FirestoreTimestamp, FirestoreTimestampSchema };