@singi-labs/sifa-sdk 0.9.12 → 0.9.14
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/index.cjs +40 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.js +39 -2
- package/dist/index.js.map +1 -1
- package/dist/publishing/index.cjs +155 -0
- package/dist/publishing/index.cjs.map +1 -0
- package/dist/publishing/index.d.cts +253 -0
- package/dist/publishing/index.d.ts +253 -0
- package/dist/publishing/index.js +138 -0
- package/dist/publishing/index.js.map +1 -0
- package/dist/query/index.d.cts +20 -20
- package/dist/query/index.d.ts +20 -20
- package/package.json +13 -3
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
|
|
5
|
+
// src/publishing/schemas.ts
|
|
6
|
+
function maxGraphemes(max) {
|
|
7
|
+
return (value) => {
|
|
8
|
+
const segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
9
|
+
let count = 0;
|
|
10
|
+
for (const _ of segmenter.segment(value)) {
|
|
11
|
+
count++;
|
|
12
|
+
if (count > max) return false;
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
var didSchema = zod.z.string().regex(/^did:[a-z]+:[a-zA-Z0-9._:%-]+$/, "Invalid DID");
|
|
18
|
+
var datetimeSchema = zod.z.string().datetime({ offset: true });
|
|
19
|
+
var atUriSchema = zod.z.string().regex(/^at:\/\/[^\s]+$/, "Invalid AT-URI");
|
|
20
|
+
var cidSchema = zod.z.string().regex(/^(Qm[1-9A-HJ-NP-Za-km-z]{44}|b[A-Za-z0-9+/=]+)$/, "Invalid CID");
|
|
21
|
+
zod.z.string().regex(/^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/, "Invalid BCP 47 language tag");
|
|
22
|
+
var uriSchema = zod.z.string().url();
|
|
23
|
+
var strongRefSchema = zod.z.object({
|
|
24
|
+
uri: atUriSchema,
|
|
25
|
+
cid: cidSchema
|
|
26
|
+
});
|
|
27
|
+
var selfLabelsSchema = zod.z.object({
|
|
28
|
+
$type: zod.z.literal("com.atproto.label.defs#selfLabels").optional(),
|
|
29
|
+
values: zod.z.array(zod.z.object({ val: zod.z.string() }))
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// src/publishing/schemas.ts
|
|
33
|
+
var rgbColorSchema = zod.z.object({
|
|
34
|
+
r: zod.z.number().int().min(0).max(255),
|
|
35
|
+
g: zod.z.number().int().min(0).max(255),
|
|
36
|
+
b: zod.z.number().int().min(0).max(255)
|
|
37
|
+
});
|
|
38
|
+
var BasicThemeSchema = zod.z.object({
|
|
39
|
+
background: rgbColorSchema,
|
|
40
|
+
foreground: rgbColorSchema,
|
|
41
|
+
accent: rgbColorSchema,
|
|
42
|
+
accentForeground: rgbColorSchema
|
|
43
|
+
});
|
|
44
|
+
var blobRefSchema = zod.z.object({
|
|
45
|
+
$type: zod.z.string().optional(),
|
|
46
|
+
ref: zod.z.unknown(),
|
|
47
|
+
mimeType: zod.z.string().optional(),
|
|
48
|
+
size: zod.z.number().optional()
|
|
49
|
+
}).passthrough();
|
|
50
|
+
var StandardSitePublicationRecordSchema = zod.z.object({
|
|
51
|
+
url: uriSchema,
|
|
52
|
+
name: zod.z.string().min(1).refine(maxGraphemes(500)).max(5e3),
|
|
53
|
+
description: zod.z.string().refine(maxGraphemes(3e3)).max(3e4).optional(),
|
|
54
|
+
icon: blobRefSchema.optional(),
|
|
55
|
+
basicTheme: BasicThemeSchema.optional(),
|
|
56
|
+
labels: selfLabelsSchema.optional(),
|
|
57
|
+
preferences: zod.z.object({
|
|
58
|
+
showInDiscover: zod.z.boolean().optional()
|
|
59
|
+
}).partial().optional()
|
|
60
|
+
}).passthrough();
|
|
61
|
+
var contributorSchema = zod.z.object({
|
|
62
|
+
did: didSchema,
|
|
63
|
+
role: zod.z.string().refine(maxGraphemes(100)).max(1e3).optional(),
|
|
64
|
+
displayName: zod.z.string().refine(maxGraphemes(100)).max(1e3).optional()
|
|
65
|
+
}).passthrough();
|
|
66
|
+
var StandardSiteDocumentRecordSchema = zod.z.object({
|
|
67
|
+
site: zod.z.string().min(1),
|
|
68
|
+
title: zod.z.string().min(1).refine(maxGraphemes(500)).max(5e3),
|
|
69
|
+
path: zod.z.string().optional(),
|
|
70
|
+
publishedAt: datetimeSchema,
|
|
71
|
+
updatedAt: datetimeSchema.optional(),
|
|
72
|
+
description: zod.z.string().refine(maxGraphemes(3e3)).max(3e4).optional(),
|
|
73
|
+
textContent: zod.z.string().optional(),
|
|
74
|
+
tags: zod.z.array(zod.z.string().refine(maxGraphemes(128)).max(1280)).optional(),
|
|
75
|
+
coverImage: blobRefSchema.optional(),
|
|
76
|
+
contributors: zod.z.array(contributorSchema).optional(),
|
|
77
|
+
bskyPostRef: strongRefSchema.optional(),
|
|
78
|
+
labels: selfLabelsSchema.optional()
|
|
79
|
+
}).passthrough();
|
|
80
|
+
var StandardSiteSubscriptionRecordSchema = zod.z.object({
|
|
81
|
+
publication: atUriSchema,
|
|
82
|
+
createdAt: datetimeSchema.optional()
|
|
83
|
+
});
|
|
84
|
+
var StandardSiteRecommendRecordSchema = zod.z.object({
|
|
85
|
+
document: atUriSchema,
|
|
86
|
+
createdAt: datetimeSchema
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// src/publishing/registry.ts
|
|
90
|
+
var STANDARD_SITE_PUBLISHERS = Object.freeze([
|
|
91
|
+
{ host: "leaflet.pub", name: "Leaflet", iconKey: "leaflet" },
|
|
92
|
+
{ host: "pckt.blog", name: "pckt", iconKey: "pckt" },
|
|
93
|
+
{ host: "offprint.app", name: "Offprint", iconKey: "offprint" }
|
|
94
|
+
]);
|
|
95
|
+
function hostMatches(host, target) {
|
|
96
|
+
return host === target || host.endsWith("." + target);
|
|
97
|
+
}
|
|
98
|
+
function hostFromUri(uri) {
|
|
99
|
+
if (!uri) return null;
|
|
100
|
+
try {
|
|
101
|
+
return new URL(uri).host.toLowerCase();
|
|
102
|
+
} catch {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function matchPublisherByHost(host) {
|
|
107
|
+
if (!host) return null;
|
|
108
|
+
const lower = host.toLowerCase();
|
|
109
|
+
return STANDARD_SITE_PUBLISHERS.find((p) => hostMatches(lower, p.host)) ?? null;
|
|
110
|
+
}
|
|
111
|
+
function matchPublisherByUri(uri) {
|
|
112
|
+
return matchPublisherByHost(hostFromUri(uri));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// src/publishing/types.ts
|
|
116
|
+
var STANDARD_SITE_PUBLICATION_NSID = "site.standard.publication";
|
|
117
|
+
var STANDARD_SITE_DOCUMENT_NSID = "site.standard.document";
|
|
118
|
+
var STANDARD_SITE_SUBSCRIPTION_NSID = "site.standard.graph.subscription";
|
|
119
|
+
var STANDARD_SITE_RECOMMEND_NSID = "site.standard.graph.recommend";
|
|
120
|
+
var STANDARD_SITE_AUTH_SOCIAL_NSID = "site.standard.authSocial";
|
|
121
|
+
var COLLECTION_SET = /* @__PURE__ */ new Set([
|
|
122
|
+
STANDARD_SITE_PUBLICATION_NSID,
|
|
123
|
+
STANDARD_SITE_DOCUMENT_NSID,
|
|
124
|
+
STANDARD_SITE_SUBSCRIPTION_NSID,
|
|
125
|
+
STANDARD_SITE_RECOMMEND_NSID
|
|
126
|
+
]);
|
|
127
|
+
function isStandardSiteAtUri(uri) {
|
|
128
|
+
if (!uri.startsWith("at://")) return false;
|
|
129
|
+
const segments = uri.slice("at://".length).split("/");
|
|
130
|
+
const collection = segments[1];
|
|
131
|
+
return collection !== void 0 && COLLECTION_SET.has(collection);
|
|
132
|
+
}
|
|
133
|
+
function hasStandardSiteAssociatedRef(refs) {
|
|
134
|
+
if (!refs) return false;
|
|
135
|
+
return refs.some((r) => isStandardSiteAtUri(r.uri));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
exports.BasicThemeSchema = BasicThemeSchema;
|
|
139
|
+
exports.STANDARD_SITE_AUTH_SOCIAL_NSID = STANDARD_SITE_AUTH_SOCIAL_NSID;
|
|
140
|
+
exports.STANDARD_SITE_DOCUMENT_NSID = STANDARD_SITE_DOCUMENT_NSID;
|
|
141
|
+
exports.STANDARD_SITE_PUBLICATION_NSID = STANDARD_SITE_PUBLICATION_NSID;
|
|
142
|
+
exports.STANDARD_SITE_PUBLISHERS = STANDARD_SITE_PUBLISHERS;
|
|
143
|
+
exports.STANDARD_SITE_RECOMMEND_NSID = STANDARD_SITE_RECOMMEND_NSID;
|
|
144
|
+
exports.STANDARD_SITE_SUBSCRIPTION_NSID = STANDARD_SITE_SUBSCRIPTION_NSID;
|
|
145
|
+
exports.StandardSiteDocumentRecordSchema = StandardSiteDocumentRecordSchema;
|
|
146
|
+
exports.StandardSitePublicationRecordSchema = StandardSitePublicationRecordSchema;
|
|
147
|
+
exports.StandardSiteRecommendRecordSchema = StandardSiteRecommendRecordSchema;
|
|
148
|
+
exports.StandardSiteSubscriptionRecordSchema = StandardSiteSubscriptionRecordSchema;
|
|
149
|
+
exports.hasStandardSiteAssociatedRef = hasStandardSiteAssociatedRef;
|
|
150
|
+
exports.hostMatches = hostMatches;
|
|
151
|
+
exports.isStandardSiteAtUri = isStandardSiteAtUri;
|
|
152
|
+
exports.matchPublisherByHost = matchPublisherByHost;
|
|
153
|
+
exports.matchPublisherByUri = matchPublisherByUri;
|
|
154
|
+
//# sourceMappingURL=index.cjs.map
|
|
155
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/schemas/shared.ts","../../src/publishing/schemas.ts","../../src/publishing/registry.ts","../../src/publishing/types.ts"],"names":["z"],"mappings":";;;;;AASO,SAAS,aAAa,GAAA,EAAa;AACxC,EAAA,OAAO,CAAC,KAAA,KAA2B;AACjC,IAAA,MA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O,KAAK,IAAA,CAAK,CAAC,MAAM,mBAAA,CAAoB,CAAA,CAAE,GAAG,CAAC,CAAA;AACpD","file":"index.cjs","sourcesContent":["import { z } from 'zod';\n\n/**\n * Grapheme-aware refinement matching the AT Protocol lexicon `maxGraphemes`\n * constraint. JS strings are sequences of UTF-16 code units, but lexicon\n * `maxGraphemes` counts user-perceived characters (grapheme clusters), so\n * emoji sequences, regional indicators, ZWJ joins, and combining marks all\n * count as one unit each. We use `Intl.Segmenter` to enforce this correctly.\n */\nexport function maxGraphemes(max: number) {\n return (value: string): boolean => {\n const segmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });\n let count = 0;\n for (const _ of segmenter.segment(value)) {\n count++;\n if (count > max) return false;\n }\n return true;\n };\n}\n\n/** Decentralized identifier, AT Protocol `format: did`. */\nexport const didSchema = z.string().regex(/^did:[a-z]+:[a-zA-Z0-9._:%-]+$/, 'Invalid DID');\n\n/** RFC 3339 datetime with timezone offset, AT Protocol `format: datetime`. */\nexport const datetimeSchema = z.string().datetime({ offset: true });\n\n/** Generic AT-URI, AT Protocol `format: at-uri`. */\nexport const atUriSchema = z.string().regex(/^at:\\/\\/[^\\s]+$/, 'Invalid AT-URI');\n\n/** Content identifier, AT Protocol `format: cid`. Loose validation -- accepts CIDv0 and CIDv1. */\nexport const cidSchema = z\n .string()\n .regex(/^(Qm[1-9A-HJ-NP-Za-km-z]{44}|b[A-Za-z0-9+/=]+)$/, 'Invalid CID');\n\n/** BCP 47 language tag, AT Protocol `format: language`. */\nexport const languageTagSchema = z\n .string()\n .regex(/^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/, 'Invalid BCP 47 language tag');\n\n/** Generic URI, AT Protocol `format: uri`. */\nexport const uriSchema = z.string().url();\n\n/**\n * StrongRef shape from `com.atproto.repo.strongRef` -- pins a record by both\n * AT-URI (identity) and CID (version).\n */\nexport const strongRefSchema = z.object({\n uri: atUriSchema,\n cid: cidSchema,\n});\n\n/**\n * Self-labels shape from `com.atproto.label.defs#selfLabels`. Modelled\n * permissively because clients rarely construct this directly; the AppView\n * handles label validation.\n */\nexport const selfLabelsSchema = z.object({\n $type: z.literal('com.atproto.label.defs#selfLabels').optional(),\n values: z.array(z.object({ val: z.string() })),\n});\n","import { z } from 'zod';\n\nimport {\n atUriSchema,\n datetimeSchema,\n didSchema,\n maxGraphemes,\n selfLabelsSchema,\n strongRefSchema,\n uriSchema,\n} from '../schemas/shared.js';\n\n/**\n * Zod schemas mirroring the canonical Standard.site lexicons that Sifa\n * consumes when rendering publication embeds.\n *\n * Canonical lexicons live at:\n * DID: did:plc:re3ebnp5v7ffagz6rb6xfei4\n * PDS: https://auriporia.us-west.host.bsky.network\n * Collection: com.atproto.lexicon.schema\n *\n * Sifa does NOT own these lexicons; we vendor the validation shapes so\n * clients can parse augmented embeds and (in Phase 4) write subscription\n * records to viewers' PDSes. Re-check against the canonical PDS on each\n * SDK release to detect schema drift.\n */\n\nconst rgbColorSchema = z.object({\n r: z.number().int().min(0).max(255),\n g: z.number().int().min(0).max(255),\n b: z.number().int().min(0).max(255),\n});\n\nexport type RgbColor = z.infer<typeof rgbColorSchema>;\n\n/** site.standard.theme.basic */\nexport const BasicThemeSchema = z.object({\n background: rgbColorSchema,\n foreground: rgbColorSchema,\n accent: rgbColorSchema,\n accentForeground: rgbColorSchema,\n});\n\nexport type BasicTheme = z.infer<typeof BasicThemeSchema>;\n\nconst blobRefSchema = z\n .object({\n $type: z.string().optional(),\n ref: z.unknown(),\n mimeType: z.string().optional(),\n size: z.number().optional(),\n })\n .passthrough();\n\n/** site.standard.publication */\nexport const StandardSitePublicationRecordSchema = z\n .object({\n url: uriSchema,\n name: z.string().min(1).refine(maxGraphemes(500)).max(5000),\n description: z.string().refine(maxGraphemes(3000)).max(30000).optional(),\n icon: blobRefSchema.optional(),\n basicTheme: BasicThemeSchema.optional(),\n labels: selfLabelsSchema.optional(),\n preferences: z\n .object({\n showInDiscover: z.boolean().optional(),\n })\n .partial()\n .optional(),\n })\n .passthrough();\n\nexport type StandardSitePublicationRecord = z.infer<typeof StandardSitePublicationRecordSchema>;\n\nconst contributorSchema = z\n .object({\n did: didSchema,\n role: z.string().refine(maxGraphemes(100)).max(1000).optional(),\n displayName: z.string().refine(maxGraphemes(100)).max(1000).optional(),\n })\n .passthrough();\n\n/** site.standard.document */\nexport const StandardSiteDocumentRecordSchema = z\n .object({\n site: z.string().min(1),\n title: z.string().min(1).refine(maxGraphemes(500)).max(5000),\n path: z.string().optional(),\n publishedAt: datetimeSchema,\n updatedAt: datetimeSchema.optional(),\n description: z.string().refine(maxGraphemes(3000)).max(30000).optional(),\n textContent: z.string().optional(),\n tags: z.array(z.string().refine(maxGraphemes(128)).max(1280)).optional(),\n coverImage: blobRefSchema.optional(),\n contributors: z.array(contributorSchema).optional(),\n bskyPostRef: strongRefSchema.optional(),\n labels: selfLabelsSchema.optional(),\n })\n .passthrough();\n\nexport type StandardSiteDocumentRecord = z.infer<typeof StandardSiteDocumentRecordSchema>;\n\n/**\n * site.standard.graph.subscription\n *\n * Authored by a viewer to declare a subscription to a publication. Used\n * by Phase 4 inline-subscribe path. Record key is a TID; the AT-URI\n * shape is `at://<viewer-did>/site.standard.graph.subscription/<rkey>`.\n */\nexport const StandardSiteSubscriptionRecordSchema = z.object({\n publication: atUriSchema,\n createdAt: datetimeSchema.optional(),\n});\n\nexport type StandardSiteSubscriptionRecord = z.infer<typeof StandardSiteSubscriptionRecordSchema>;\n\n/**\n * site.standard.graph.recommend\n *\n * Document-level \"like\" record. Same scope as subscription via the\n * site.standard.authSocial OAuth permission-set, so Phase 4 unlocks\n * inline likes alongside inline subscribes.\n */\nexport const StandardSiteRecommendRecordSchema = z.object({\n document: atUriSchema,\n createdAt: datetimeSchema,\n});\n\nexport type StandardSiteRecommendRecord = z.infer<typeof StandardSiteRecommendRecordSchema>;\n","/**\n * Publisher allowlist for the Standard.site rich embed.\n *\n * Mirrors `bluesky-social/social-app`\n * `src/components/Post/Embed/StandardSiteEmbed/publishers.ts`. The only\n * gate this provides is which publishers get the highlighted\n * \"Subscribe on {Publisher}\" CTA with a publisher icon vs the plain\n * \"View publication\" fallback — any Standard.site embed renders\n * regardless of allowlist membership.\n *\n * Sync policy: review additions against the upstream bsky list weekly;\n * Singi Labs reviews before merge.\n */\n\nexport interface Publisher {\n /** Lowercase host. Subdomains are matched via `hostMatches`. */\n host: string;\n /** Human-facing publisher name shown in CTA copy. */\n name: string;\n /**\n * Stable identifier used by clients to look up brand icons. The SDK\n * does not ship icon assets — sifa-web maintains them keyed by this\n * id so React Native vs web rendering can diverge.\n */\n iconKey: 'leaflet' | 'pckt' | 'offprint';\n}\n\nexport const STANDARD_SITE_PUBLISHERS: readonly Publisher[] = Object.freeze([\n { host: 'leaflet.pub', name: 'Leaflet', iconKey: 'leaflet' },\n { host: 'pckt.blog', name: 'pckt', iconKey: 'pckt' },\n { host: 'offprint.app', name: 'Offprint', iconKey: 'offprint' },\n]);\n\n/**\n * Returns true when `host` exactly matches `target` or is a subdomain of\n * it. Hosts are expected to be lowercase already.\n */\nexport function hostMatches(host: string, target: string): boolean {\n return host === target || host.endsWith('.' + target);\n}\n\nfunction hostFromUri(uri: string | undefined | null): string | null {\n if (!uri) return null;\n try {\n return new URL(uri).host.toLowerCase();\n } catch {\n return null;\n }\n}\n\n/**\n * Match a publisher by host. Returns the publisher when `host` is on the\n * allowlist (exact or subdomain match), null otherwise. Host should be\n * lowercase.\n */\nexport function matchPublisherByHost(host: string | null | undefined): Publisher | null {\n if (!host) return null;\n const lower = host.toLowerCase();\n return STANDARD_SITE_PUBLISHERS.find((p) => hostMatches(lower, p.host)) ?? null;\n}\n\n/**\n * Match a publisher by URI. Convenience wrapper around\n * `matchPublisherByHost` for callers that have a publication URL handy.\n */\nexport function matchPublisherByUri(uri: string | undefined | null): Publisher | null {\n return matchPublisherByHost(hostFromUri(uri));\n}\n","import type { BasicTheme } from './schemas.js';\n\n/**\n * Publication metadata embedded in the augmented activity view by\n * sifa-api when an external link card matches an indexed publication.\n *\n * `uri` is the publication's AT-URI (e.g.\n * `at://did:plc:abc/site.standard.publication/xyz`). `theme` carries\n * the publication's own colors when supplied — clients should apply a\n * WCAG min-contrast fallback before honoring them.\n *\n * `icon` is left as `unknown` here because its representation depends\n * on the surface: blob ref on the wire, CDN URL after resolution.\n */\nexport interface PublicationSource {\n uri: string;\n title: string;\n icon?: unknown;\n theme?: BasicTheme;\n}\n\n/**\n * Shape attached to activity items whose external link card URL matches\n * a Standard.site record. Mirrors the relevant fields of bsky's\n * `StandardSiteEmbed` view so a sifa-web renderer can be near-1:1.\n *\n * `associatedRefs` carries AT-URIs the client may use in Phase 4 to\n * query subscription state for the viewer.\n */\nexport interface StandardSiteEmbedView {\n uri: string;\n source: PublicationSource;\n associatedRefs: { uri: string }[];\n createdAt?: string;\n readingTime?: number;\n}\n\nexport const STANDARD_SITE_PUBLICATION_NSID = 'site.standard.publication' as const;\nexport const STANDARD_SITE_DOCUMENT_NSID = 'site.standard.document' as const;\nexport const STANDARD_SITE_SUBSCRIPTION_NSID = 'site.standard.graph.subscription' as const;\nexport const STANDARD_SITE_RECOMMEND_NSID = 'site.standard.graph.recommend' as const;\n\n/**\n * Pre-defined OAuth permission-set the consumer apps request to write\n * subscription + recommend records on behalf of the viewer. The actual\n * permission-set is published under\n * `at://did:plc:re3ebnp5v7ffagz6rb6xfei4/com.atproto.lexicon.schema/site.standard.authSocial`.\n */\nexport const STANDARD_SITE_AUTH_SOCIAL_NSID = 'site.standard.authSocial' as const;\n\nconst COLLECTION_SET = new Set<string>([\n STANDARD_SITE_PUBLICATION_NSID,\n STANDARD_SITE_DOCUMENT_NSID,\n STANDARD_SITE_SUBSCRIPTION_NSID,\n STANDARD_SITE_RECOMMEND_NSID,\n]);\n\n/**\n * True when the AT-URI's collection segment is a Standard.site\n * collection. Useful for detecting Standard.site embed augmentation on\n * arbitrary activity items.\n */\nexport function isStandardSiteAtUri(uri: string): boolean {\n if (!uri.startsWith('at://')) return false;\n const segments = uri.slice('at://'.length).split('/');\n const collection = segments[1];\n return collection !== undefined && COLLECTION_SET.has(collection);\n}\n\n/**\n * True when any `associatedRefs[].uri` is a Standard.site collection\n * AT-URI. The bsky client uses the same check to gate the\n * `StandardSiteEmbed` renderer.\n */\nexport function hasStandardSiteAssociatedRef(refs: { uri: string }[] | undefined): boolean {\n if (!refs) return false;\n return refs.some((r) => isStandardSiteAtUri(r.uri));\n}\n"]}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Zod schemas mirroring the canonical Standard.site lexicons that Sifa
|
|
5
|
+
* consumes when rendering publication embeds.
|
|
6
|
+
*
|
|
7
|
+
* Canonical lexicons live at:
|
|
8
|
+
* DID: did:plc:re3ebnp5v7ffagz6rb6xfei4
|
|
9
|
+
* PDS: https://auriporia.us-west.host.bsky.network
|
|
10
|
+
* Collection: com.atproto.lexicon.schema
|
|
11
|
+
*
|
|
12
|
+
* Sifa does NOT own these lexicons; we vendor the validation shapes so
|
|
13
|
+
* clients can parse augmented embeds and (in Phase 4) write subscription
|
|
14
|
+
* records to viewers' PDSes. Re-check against the canonical PDS on each
|
|
15
|
+
* SDK release to detect schema drift.
|
|
16
|
+
*/
|
|
17
|
+
declare const rgbColorSchema: z.ZodObject<{
|
|
18
|
+
r: z.ZodNumber;
|
|
19
|
+
g: z.ZodNumber;
|
|
20
|
+
b: z.ZodNumber;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
type RgbColor = z.infer<typeof rgbColorSchema>;
|
|
23
|
+
/** site.standard.theme.basic */
|
|
24
|
+
declare const BasicThemeSchema: z.ZodObject<{
|
|
25
|
+
background: z.ZodObject<{
|
|
26
|
+
r: z.ZodNumber;
|
|
27
|
+
g: z.ZodNumber;
|
|
28
|
+
b: z.ZodNumber;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
foreground: z.ZodObject<{
|
|
31
|
+
r: z.ZodNumber;
|
|
32
|
+
g: z.ZodNumber;
|
|
33
|
+
b: z.ZodNumber;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
accent: z.ZodObject<{
|
|
36
|
+
r: z.ZodNumber;
|
|
37
|
+
g: z.ZodNumber;
|
|
38
|
+
b: z.ZodNumber;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
accentForeground: z.ZodObject<{
|
|
41
|
+
r: z.ZodNumber;
|
|
42
|
+
g: z.ZodNumber;
|
|
43
|
+
b: z.ZodNumber;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
type BasicTheme = z.infer<typeof BasicThemeSchema>;
|
|
47
|
+
/** site.standard.publication */
|
|
48
|
+
declare const StandardSitePublicationRecordSchema: z.ZodObject<{
|
|
49
|
+
url: z.ZodString;
|
|
50
|
+
name: z.ZodString;
|
|
51
|
+
description: z.ZodOptional<z.ZodString>;
|
|
52
|
+
icon: z.ZodOptional<z.ZodObject<{
|
|
53
|
+
$type: z.ZodOptional<z.ZodString>;
|
|
54
|
+
ref: z.ZodUnknown;
|
|
55
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
56
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
57
|
+
}, z.core.$loose>>;
|
|
58
|
+
basicTheme: z.ZodOptional<z.ZodObject<{
|
|
59
|
+
background: z.ZodObject<{
|
|
60
|
+
r: z.ZodNumber;
|
|
61
|
+
g: z.ZodNumber;
|
|
62
|
+
b: z.ZodNumber;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
foreground: z.ZodObject<{
|
|
65
|
+
r: z.ZodNumber;
|
|
66
|
+
g: z.ZodNumber;
|
|
67
|
+
b: z.ZodNumber;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
accent: z.ZodObject<{
|
|
70
|
+
r: z.ZodNumber;
|
|
71
|
+
g: z.ZodNumber;
|
|
72
|
+
b: z.ZodNumber;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
accentForeground: z.ZodObject<{
|
|
75
|
+
r: z.ZodNumber;
|
|
76
|
+
g: z.ZodNumber;
|
|
77
|
+
b: z.ZodNumber;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
}, z.core.$strip>>;
|
|
80
|
+
labels: z.ZodOptional<z.ZodObject<{
|
|
81
|
+
$type: z.ZodOptional<z.ZodLiteral<"com.atproto.label.defs#selfLabels">>;
|
|
82
|
+
values: z.ZodArray<z.ZodObject<{
|
|
83
|
+
val: z.ZodString;
|
|
84
|
+
}, z.core.$strip>>;
|
|
85
|
+
}, z.core.$strip>>;
|
|
86
|
+
preferences: z.ZodOptional<z.ZodObject<{
|
|
87
|
+
showInDiscover: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
88
|
+
}, z.core.$strip>>;
|
|
89
|
+
}, z.core.$loose>;
|
|
90
|
+
type StandardSitePublicationRecord = z.infer<typeof StandardSitePublicationRecordSchema>;
|
|
91
|
+
/** site.standard.document */
|
|
92
|
+
declare const StandardSiteDocumentRecordSchema: z.ZodObject<{
|
|
93
|
+
site: z.ZodString;
|
|
94
|
+
title: z.ZodString;
|
|
95
|
+
path: z.ZodOptional<z.ZodString>;
|
|
96
|
+
publishedAt: z.ZodString;
|
|
97
|
+
updatedAt: z.ZodOptional<z.ZodString>;
|
|
98
|
+
description: z.ZodOptional<z.ZodString>;
|
|
99
|
+
textContent: z.ZodOptional<z.ZodString>;
|
|
100
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
101
|
+
coverImage: z.ZodOptional<z.ZodObject<{
|
|
102
|
+
$type: z.ZodOptional<z.ZodString>;
|
|
103
|
+
ref: z.ZodUnknown;
|
|
104
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
105
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
106
|
+
}, z.core.$loose>>;
|
|
107
|
+
contributors: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
108
|
+
did: z.ZodString;
|
|
109
|
+
role: z.ZodOptional<z.ZodString>;
|
|
110
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
111
|
+
}, z.core.$loose>>>;
|
|
112
|
+
bskyPostRef: z.ZodOptional<z.ZodObject<{
|
|
113
|
+
uri: z.ZodString;
|
|
114
|
+
cid: z.ZodString;
|
|
115
|
+
}, z.core.$strip>>;
|
|
116
|
+
labels: z.ZodOptional<z.ZodObject<{
|
|
117
|
+
$type: z.ZodOptional<z.ZodLiteral<"com.atproto.label.defs#selfLabels">>;
|
|
118
|
+
values: z.ZodArray<z.ZodObject<{
|
|
119
|
+
val: z.ZodString;
|
|
120
|
+
}, z.core.$strip>>;
|
|
121
|
+
}, z.core.$strip>>;
|
|
122
|
+
}, z.core.$loose>;
|
|
123
|
+
type StandardSiteDocumentRecord = z.infer<typeof StandardSiteDocumentRecordSchema>;
|
|
124
|
+
/**
|
|
125
|
+
* site.standard.graph.subscription
|
|
126
|
+
*
|
|
127
|
+
* Authored by a viewer to declare a subscription to a publication. Used
|
|
128
|
+
* by Phase 4 inline-subscribe path. Record key is a TID; the AT-URI
|
|
129
|
+
* shape is `at://<viewer-did>/site.standard.graph.subscription/<rkey>`.
|
|
130
|
+
*/
|
|
131
|
+
declare const StandardSiteSubscriptionRecordSchema: z.ZodObject<{
|
|
132
|
+
publication: z.ZodString;
|
|
133
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
134
|
+
}, z.core.$strip>;
|
|
135
|
+
type StandardSiteSubscriptionRecord = z.infer<typeof StandardSiteSubscriptionRecordSchema>;
|
|
136
|
+
/**
|
|
137
|
+
* site.standard.graph.recommend
|
|
138
|
+
*
|
|
139
|
+
* Document-level "like" record. Same scope as subscription via the
|
|
140
|
+
* site.standard.authSocial OAuth permission-set, so Phase 4 unlocks
|
|
141
|
+
* inline likes alongside inline subscribes.
|
|
142
|
+
*/
|
|
143
|
+
declare const StandardSiteRecommendRecordSchema: z.ZodObject<{
|
|
144
|
+
document: z.ZodString;
|
|
145
|
+
createdAt: z.ZodString;
|
|
146
|
+
}, z.core.$strip>;
|
|
147
|
+
type StandardSiteRecommendRecord = z.infer<typeof StandardSiteRecommendRecordSchema>;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Publisher allowlist for the Standard.site rich embed.
|
|
151
|
+
*
|
|
152
|
+
* Mirrors `bluesky-social/social-app`
|
|
153
|
+
* `src/components/Post/Embed/StandardSiteEmbed/publishers.ts`. The only
|
|
154
|
+
* gate this provides is which publishers get the highlighted
|
|
155
|
+
* "Subscribe on {Publisher}" CTA with a publisher icon vs the plain
|
|
156
|
+
* "View publication" fallback — any Standard.site embed renders
|
|
157
|
+
* regardless of allowlist membership.
|
|
158
|
+
*
|
|
159
|
+
* Sync policy: review additions against the upstream bsky list weekly;
|
|
160
|
+
* Singi Labs reviews before merge.
|
|
161
|
+
*/
|
|
162
|
+
interface Publisher {
|
|
163
|
+
/** Lowercase host. Subdomains are matched via `hostMatches`. */
|
|
164
|
+
host: string;
|
|
165
|
+
/** Human-facing publisher name shown in CTA copy. */
|
|
166
|
+
name: string;
|
|
167
|
+
/**
|
|
168
|
+
* Stable identifier used by clients to look up brand icons. The SDK
|
|
169
|
+
* does not ship icon assets — sifa-web maintains them keyed by this
|
|
170
|
+
* id so React Native vs web rendering can diverge.
|
|
171
|
+
*/
|
|
172
|
+
iconKey: 'leaflet' | 'pckt' | 'offprint';
|
|
173
|
+
}
|
|
174
|
+
declare const STANDARD_SITE_PUBLISHERS: readonly Publisher[];
|
|
175
|
+
/**
|
|
176
|
+
* Returns true when `host` exactly matches `target` or is a subdomain of
|
|
177
|
+
* it. Hosts are expected to be lowercase already.
|
|
178
|
+
*/
|
|
179
|
+
declare function hostMatches(host: string, target: string): boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Match a publisher by host. Returns the publisher when `host` is on the
|
|
182
|
+
* allowlist (exact or subdomain match), null otherwise. Host should be
|
|
183
|
+
* lowercase.
|
|
184
|
+
*/
|
|
185
|
+
declare function matchPublisherByHost(host: string | null | undefined): Publisher | null;
|
|
186
|
+
/**
|
|
187
|
+
* Match a publisher by URI. Convenience wrapper around
|
|
188
|
+
* `matchPublisherByHost` for callers that have a publication URL handy.
|
|
189
|
+
*/
|
|
190
|
+
declare function matchPublisherByUri(uri: string | undefined | null): Publisher | null;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Publication metadata embedded in the augmented activity view by
|
|
194
|
+
* sifa-api when an external link card matches an indexed publication.
|
|
195
|
+
*
|
|
196
|
+
* `uri` is the publication's AT-URI (e.g.
|
|
197
|
+
* `at://did:plc:abc/site.standard.publication/xyz`). `theme` carries
|
|
198
|
+
* the publication's own colors when supplied — clients should apply a
|
|
199
|
+
* WCAG min-contrast fallback before honoring them.
|
|
200
|
+
*
|
|
201
|
+
* `icon` is left as `unknown` here because its representation depends
|
|
202
|
+
* on the surface: blob ref on the wire, CDN URL after resolution.
|
|
203
|
+
*/
|
|
204
|
+
interface PublicationSource {
|
|
205
|
+
uri: string;
|
|
206
|
+
title: string;
|
|
207
|
+
icon?: unknown;
|
|
208
|
+
theme?: BasicTheme;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Shape attached to activity items whose external link card URL matches
|
|
212
|
+
* a Standard.site record. Mirrors the relevant fields of bsky's
|
|
213
|
+
* `StandardSiteEmbed` view so a sifa-web renderer can be near-1:1.
|
|
214
|
+
*
|
|
215
|
+
* `associatedRefs` carries AT-URIs the client may use in Phase 4 to
|
|
216
|
+
* query subscription state for the viewer.
|
|
217
|
+
*/
|
|
218
|
+
interface StandardSiteEmbedView {
|
|
219
|
+
uri: string;
|
|
220
|
+
source: PublicationSource;
|
|
221
|
+
associatedRefs: {
|
|
222
|
+
uri: string;
|
|
223
|
+
}[];
|
|
224
|
+
createdAt?: string;
|
|
225
|
+
readingTime?: number;
|
|
226
|
+
}
|
|
227
|
+
declare const STANDARD_SITE_PUBLICATION_NSID: "site.standard.publication";
|
|
228
|
+
declare const STANDARD_SITE_DOCUMENT_NSID: "site.standard.document";
|
|
229
|
+
declare const STANDARD_SITE_SUBSCRIPTION_NSID: "site.standard.graph.subscription";
|
|
230
|
+
declare const STANDARD_SITE_RECOMMEND_NSID: "site.standard.graph.recommend";
|
|
231
|
+
/**
|
|
232
|
+
* Pre-defined OAuth permission-set the consumer apps request to write
|
|
233
|
+
* subscription + recommend records on behalf of the viewer. The actual
|
|
234
|
+
* permission-set is published under
|
|
235
|
+
* `at://did:plc:re3ebnp5v7ffagz6rb6xfei4/com.atproto.lexicon.schema/site.standard.authSocial`.
|
|
236
|
+
*/
|
|
237
|
+
declare const STANDARD_SITE_AUTH_SOCIAL_NSID: "site.standard.authSocial";
|
|
238
|
+
/**
|
|
239
|
+
* True when the AT-URI's collection segment is a Standard.site
|
|
240
|
+
* collection. Useful for detecting Standard.site embed augmentation on
|
|
241
|
+
* arbitrary activity items.
|
|
242
|
+
*/
|
|
243
|
+
declare function isStandardSiteAtUri(uri: string): boolean;
|
|
244
|
+
/**
|
|
245
|
+
* True when any `associatedRefs[].uri` is a Standard.site collection
|
|
246
|
+
* AT-URI. The bsky client uses the same check to gate the
|
|
247
|
+
* `StandardSiteEmbed` renderer.
|
|
248
|
+
*/
|
|
249
|
+
declare function hasStandardSiteAssociatedRef(refs: {
|
|
250
|
+
uri: string;
|
|
251
|
+
}[] | undefined): boolean;
|
|
252
|
+
|
|
253
|
+
export { type BasicTheme, BasicThemeSchema, type PublicationSource, type Publisher, type RgbColor, STANDARD_SITE_AUTH_SOCIAL_NSID, STANDARD_SITE_DOCUMENT_NSID, STANDARD_SITE_PUBLICATION_NSID, STANDARD_SITE_PUBLISHERS, STANDARD_SITE_RECOMMEND_NSID, STANDARD_SITE_SUBSCRIPTION_NSID, type StandardSiteDocumentRecord, StandardSiteDocumentRecordSchema, type StandardSiteEmbedView, type StandardSitePublicationRecord, StandardSitePublicationRecordSchema, type StandardSiteRecommendRecord, StandardSiteRecommendRecordSchema, type StandardSiteSubscriptionRecord, StandardSiteSubscriptionRecordSchema, hasStandardSiteAssociatedRef, hostMatches, isStandardSiteAtUri, matchPublisherByHost, matchPublisherByUri };
|