@singi-labs/sifa-sdk 0.7.2 → 0.7.4
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 +1 -1
- package/dist/index.js +1 -1
- package/dist/query/fetchers/index.cjs +994 -0
- package/dist/query/fetchers/index.cjs.map +1 -0
- package/dist/query/fetchers/index.d.cts +1004 -0
- package/dist/query/fetchers/index.d.ts +1004 -0
- package/dist/query/fetchers/index.js +913 -0
- package/dist/query/fetchers/index.js.map +1 -0
- package/dist/query/index.cjs +1201 -49
- package/dist/query/index.cjs.map +1 -1
- package/dist/query/index.d.cts +218 -617
- package/dist/query/index.d.ts +218 -617
- package/dist/query/index.js +1102 -50
- package/dist/query/index.js.map +1 -1
- package/package.json +11 -1
|
@@ -0,0 +1,1004 @@
|
|
|
1
|
+
import { f as Profile, o as ProfilePosition, S as SkillRef, c as ExternalAccount, t as SkillSuggestion } from '../../index-CpM21_Oy.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Foundation HTTP client for talking to the Sifa AppView.
|
|
5
|
+
*
|
|
6
|
+
* Stateless. Consumers supply a {@link SifaApiConfig} per call (the React
|
|
7
|
+
* hooks read it from context; non-React consumers pass it explicitly). No
|
|
8
|
+
* singletons, no module-level state.
|
|
9
|
+
*/
|
|
10
|
+
/** Configuration passed to every fetcher. */
|
|
11
|
+
interface SifaApiConfig {
|
|
12
|
+
/** Base URL of the sifa-api AppView, e.g. `https://api.sifa.id`. No trailing slash. */
|
|
13
|
+
baseUrl: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optional fetch implementation. Defaults to {@link globalThis.fetch}.
|
|
16
|
+
* Lets Next.js consumers pass their cache-enhanced fetch; node/Expo
|
|
17
|
+
* consumers can leave this unset.
|
|
18
|
+
*/
|
|
19
|
+
fetch?: typeof fetch;
|
|
20
|
+
}
|
|
21
|
+
/** Options accepted by {@link apiFetch}. */
|
|
22
|
+
interface ApiFetchOptions {
|
|
23
|
+
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
24
|
+
/** Request body. Serialized to JSON automatically. */
|
|
25
|
+
body?: unknown;
|
|
26
|
+
/** AbortSignal. Defaults to `AbortSignal.timeout(timeoutMs)` if `timeoutMs` is set. */
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
/** Per-call timeout in milliseconds. Default: 10_000. Ignored if `signal` is provided. */
|
|
29
|
+
timeoutMs?: number;
|
|
30
|
+
/** Retry on HTTP 429 up to 3 times with the server's `Retry-After` delay (capped at 3s). */
|
|
31
|
+
retryOn429?: boolean;
|
|
32
|
+
/** Additional headers. `Content-Type: application/json` is set automatically when `body` is present. */
|
|
33
|
+
headers?: Record<string, string>;
|
|
34
|
+
credentials?: RequestCredentials;
|
|
35
|
+
cache?: RequestCache;
|
|
36
|
+
/**
|
|
37
|
+
* Next.js-specific cache hints. Ignored on non-Next runtimes. Passed
|
|
38
|
+
* through transparently as part of {@link RequestInit}.
|
|
39
|
+
*/
|
|
40
|
+
next?: {
|
|
41
|
+
revalidate?: number | false;
|
|
42
|
+
tags?: string[];
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** Error thrown by {@link apiFetch} on non-2xx responses. */
|
|
46
|
+
declare class ApiError extends Error {
|
|
47
|
+
readonly status: number;
|
|
48
|
+
readonly body: unknown;
|
|
49
|
+
constructor(message: string, status: number, body?: unknown);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Generic fetcher used by all SDK query and mutation functions.
|
|
53
|
+
*
|
|
54
|
+
* Returns parsed JSON typed as `T`. Throws {@link ApiError} on non-2xx
|
|
55
|
+
* responses. Use {@link apiFetchOrNull} when 404 should resolve to `null`
|
|
56
|
+
* instead.
|
|
57
|
+
*/
|
|
58
|
+
declare function apiFetch<T = unknown>(config: SifaApiConfig, path: string, options?: ApiFetchOptions): Promise<T>;
|
|
59
|
+
/**
|
|
60
|
+
* Variant of {@link apiFetch} that resolves to `null` on HTTP 404 instead
|
|
61
|
+
* of throwing. Useful for "fetch by handle" reads where missing is
|
|
62
|
+
* expected (e.g. unknown profile).
|
|
63
|
+
*/
|
|
64
|
+
declare function apiFetchOrNull<T>(config: SifaApiConfig, path: string, options?: ApiFetchOptions): Promise<T | null>;
|
|
65
|
+
/**
|
|
66
|
+
* Result returned by record-write mutations (create / update / delete).
|
|
67
|
+
*
|
|
68
|
+
* Never throws -- writes against the user's PDS can fail in many ways
|
|
69
|
+
* (network, PDS unreachable, rate limit) and the UI needs structured
|
|
70
|
+
* results to render appropriate messages.
|
|
71
|
+
*/
|
|
72
|
+
interface WriteResult {
|
|
73
|
+
success: boolean;
|
|
74
|
+
error?: string;
|
|
75
|
+
/**
|
|
76
|
+
* PDS hostname returned by sifa-api when a write failed at the user's
|
|
77
|
+
* Personal Data Server (issue #167). Lets the UI render
|
|
78
|
+
* "Your data server (eurosky.social) isn't responding" instead of a
|
|
79
|
+
* generic "Request failed (500)".
|
|
80
|
+
*/
|
|
81
|
+
pdsHost?: string;
|
|
82
|
+
}
|
|
83
|
+
/** Result returned by create mutations. Includes the newly created `rkey`. */
|
|
84
|
+
interface CreateResult extends WriteResult {
|
|
85
|
+
rkey?: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Write mutation against the Sifa AppView. Wraps {@link apiFetch} with the
|
|
89
|
+
* never-throws contract used by all sifa-web mutations: returns a
|
|
90
|
+
* structured {@link WriteResult} on both success and failure, and
|
|
91
|
+
* preserves the `pdsHost` field when the AppView reports a PDS-side
|
|
92
|
+
* failure (issue #167).
|
|
93
|
+
*
|
|
94
|
+
* On success: returns `{ success: true, ...payload }` where `payload` is
|
|
95
|
+
* whatever the server returned in JSON (or `{}` for 204).
|
|
96
|
+
*
|
|
97
|
+
* On failure: returns `{ success: false, error, pdsHost? }`. Never throws.
|
|
98
|
+
*
|
|
99
|
+
* Use {@link apiWriteCreate} when you specifically need the `rkey` from a
|
|
100
|
+
* create response folded into the result shape.
|
|
101
|
+
*/
|
|
102
|
+
declare function apiWrite<TExtra extends object = Record<never, never>>(config: SifaApiConfig, path: string, method: 'POST' | 'PUT' | 'DELETE' | 'PATCH', options?: Omit<ApiFetchOptions, 'method'>): Promise<WriteResult & TExtra>;
|
|
103
|
+
/**
|
|
104
|
+
* Write mutation that expects the server to return a record key (`rkey`)
|
|
105
|
+
* in its response body. Wraps {@link apiWrite} and folds the `rkey` into
|
|
106
|
+
* the result shape so consumers get `{ success, rkey?, error?, pdsHost? }`.
|
|
107
|
+
*
|
|
108
|
+
* If the server returns additional fields (e.g. `feedUrl` from external
|
|
109
|
+
* account creation), pass them via the `TExtra` generic to keep them
|
|
110
|
+
* typed.
|
|
111
|
+
*/
|
|
112
|
+
declare function apiWriteCreate<TExtra extends object = Record<never, never>>(config: SifaApiConfig, path: string, body: unknown, options?: Omit<ApiFetchOptions, 'method' | 'body'>): Promise<CreateResult & TExtra>;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Read the aggregated profile for a handle or DID.
|
|
116
|
+
*
|
|
117
|
+
* Returns `null` when the AppView has no profile for the given identifier
|
|
118
|
+
* (HTTP 404). Throws {@link ApiError} on other non-2xx responses.
|
|
119
|
+
*
|
|
120
|
+
* Server-callable (Next.js RSC) and client-callable (Expo, browser).
|
|
121
|
+
*/
|
|
122
|
+
declare function fetchProfile(config: SifaApiConfig, handleOrDid: string, options?: ApiFetchOptions): Promise<Profile | null>;
|
|
123
|
+
/**
|
|
124
|
+
* Public AT Fund link for a profile, if one is configured. Returns `null`
|
|
125
|
+
* on any error or when the response payload's `url` field is missing or
|
|
126
|
+
* non-string.
|
|
127
|
+
*/
|
|
128
|
+
declare function fetchAtFundLink(config: SifaApiConfig, did: string, options?: ApiFetchOptions): Promise<string | null>;
|
|
129
|
+
|
|
130
|
+
/** Industry/domain entry on the profile self record. */
|
|
131
|
+
interface ProfileIndustryInput {
|
|
132
|
+
industry: string;
|
|
133
|
+
domain?: string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Location payload accepted by `updateProfileSelf`.
|
|
137
|
+
*
|
|
138
|
+
* Accepts both shapes during the community.lexicon.location.address
|
|
139
|
+
* migration. Prefer `locality` (new) over `city` (legacy) when sending.
|
|
140
|
+
* The API's locationSchema is a Zod union that resolves either input.
|
|
141
|
+
*/
|
|
142
|
+
interface ProfileSelfLocation {
|
|
143
|
+
country: string;
|
|
144
|
+
countryCode?: string;
|
|
145
|
+
region?: string;
|
|
146
|
+
city?: string;
|
|
147
|
+
locality?: string;
|
|
148
|
+
}
|
|
149
|
+
/** Body accepted by {@link updateProfileSelf}. */
|
|
150
|
+
interface UpdateProfileSelfInput {
|
|
151
|
+
headline?: string;
|
|
152
|
+
about?: string;
|
|
153
|
+
industries?: ProfileIndustryInput[];
|
|
154
|
+
location?: ProfileSelfLocation;
|
|
155
|
+
website?: string;
|
|
156
|
+
openTo?: string[];
|
|
157
|
+
preferredWorkplace?: string[];
|
|
158
|
+
availableFromUtc?: number;
|
|
159
|
+
availableToUtc?: number;
|
|
160
|
+
}
|
|
161
|
+
/** Update the authenticated user's `id.sifa.profile.self` record. */
|
|
162
|
+
declare function updateProfileSelf(config: SifaApiConfig, data: UpdateProfileSelfInput, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
163
|
+
/** Body accepted by {@link updateProfileOverride}. */
|
|
164
|
+
interface UpdateProfileOverrideInput {
|
|
165
|
+
headline?: string | null;
|
|
166
|
+
about?: string | null;
|
|
167
|
+
displayName?: string | null;
|
|
168
|
+
pronouns?: string | null;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Override aggregated profile fields with sifa-specific values. `null`
|
|
172
|
+
* clears the override and falls back to the upstream PDS value.
|
|
173
|
+
*/
|
|
174
|
+
declare function updateProfileOverride(config: SifaApiConfig, data: UpdateProfileOverrideInput, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
175
|
+
/** Extended result for {@link refreshPds}. */
|
|
176
|
+
interface RefreshPdsResult extends WriteResult {
|
|
177
|
+
displayName?: string | null;
|
|
178
|
+
avatar?: string | null;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Re-pull the authenticated user's `app.bsky.actor.profile` from their
|
|
182
|
+
* PDS. Returns the freshly resolved `displayName` and `avatar` on
|
|
183
|
+
* success so the UI can update without a full profile refetch.
|
|
184
|
+
*/
|
|
185
|
+
declare function refreshPds(config: SifaApiConfig, options?: ApiFetchOptions): Promise<RefreshPdsResult>;
|
|
186
|
+
/** Extended result for {@link uploadAvatar}. */
|
|
187
|
+
interface UploadAvatarResult extends WriteResult {
|
|
188
|
+
/** Publicly accessible URL of the newly uploaded avatar. */
|
|
189
|
+
url?: string;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Upload a new avatar via `multipart/form-data`. Pass either a `File`
|
|
193
|
+
* (browser) or any `Blob` (Expo, node). The SDK leaves `Content-Type`
|
|
194
|
+
* unset so the runtime can set the multipart boundary automatically.
|
|
195
|
+
*
|
|
196
|
+
* Never throws -- inspect `result.success` and `result.url`.
|
|
197
|
+
*/
|
|
198
|
+
declare function uploadAvatar(config: SifaApiConfig, file: Blob, options?: ApiFetchOptions): Promise<UploadAvatarResult>;
|
|
199
|
+
/** Delete the authenticated user's avatar override (revert to PDS avatar). */
|
|
200
|
+
declare function deleteAvatarOverride(config: SifaApiConfig, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Create a new `id.sifa.profile.position` record on the authenticated
|
|
204
|
+
* user's PDS. The AppView signs and writes via the user's OAuth session.
|
|
205
|
+
*
|
|
206
|
+
* `data` should be a lexicon-shaped position record (without `createdAt`
|
|
207
|
+
* or `rkey`; the AppView fills both). Validate with
|
|
208
|
+
* `ProfilePositionRecordSchema.omit({ createdAt: true })` before calling
|
|
209
|
+
* if you want client-side guarantees.
|
|
210
|
+
*
|
|
211
|
+
* Never throws -- inspect `result.success` and use `result.error` /
|
|
212
|
+
* `result.pdsHost` for UI messaging.
|
|
213
|
+
*/
|
|
214
|
+
declare function createPosition(config: SifaApiConfig, data: Record<string, unknown>, options?: ApiFetchOptions): Promise<CreateResult>;
|
|
215
|
+
/** Update an existing position by `rkey`. */
|
|
216
|
+
declare function updatePosition(config: SifaApiConfig, rkey: string, data: Record<string, unknown>, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
217
|
+
/** Delete a position by `rkey`. */
|
|
218
|
+
declare function deletePosition(config: SifaApiConfig, rkey: string, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
219
|
+
/** Mark a position as the user's primary (current) role. */
|
|
220
|
+
declare function setPositionPrimary(config: SifaApiConfig, rkey: string, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
221
|
+
/** Clear the "primary" flag on a position. */
|
|
222
|
+
declare function unsetPositionPrimary(config: SifaApiConfig, rkey: string, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
223
|
+
/**
|
|
224
|
+
* Add a skill link to a position. Idempotent: if the skill is already
|
|
225
|
+
* linked, resolves to `{ success: true }` without a network call.
|
|
226
|
+
*
|
|
227
|
+
* Implementation note: the AppView only exposes whole-record PUTs, so
|
|
228
|
+
* this helper rebuilds the position body with the new skills list.
|
|
229
|
+
*/
|
|
230
|
+
declare function linkSkillToPosition(config: SifaApiConfig, position: ProfilePosition, skillRef: SkillRef, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
231
|
+
/** Remove a skill link from a position. */
|
|
232
|
+
declare function unlinkSkillFromPosition(config: SifaApiConfig, position: ProfilePosition, skillRef: SkillRef, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Create a new `id.sifa.profile.education` record on the authenticated
|
|
236
|
+
* user's PDS.
|
|
237
|
+
*/
|
|
238
|
+
declare function createEducation(config: SifaApiConfig, data: Record<string, unknown>, options?: ApiFetchOptions): Promise<CreateResult>;
|
|
239
|
+
/** Update an existing education record by `rkey`. */
|
|
240
|
+
declare function updateEducation(config: SifaApiConfig, rkey: string, data: Record<string, unknown>, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
241
|
+
/** Delete an education record by `rkey`. */
|
|
242
|
+
declare function deleteEducation(config: SifaApiConfig, rkey: string, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Create a new `id.sifa.profile.skill` record on the authenticated
|
|
246
|
+
* user's PDS.
|
|
247
|
+
*/
|
|
248
|
+
declare function createSkill(config: SifaApiConfig, data: Record<string, unknown>, options?: ApiFetchOptions): Promise<CreateResult>;
|
|
249
|
+
/** Update an existing skill record by `rkey`. */
|
|
250
|
+
declare function updateSkill(config: SifaApiConfig, rkey: string, data: Record<string, unknown>, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
251
|
+
/** Delete a skill record by `rkey`. */
|
|
252
|
+
declare function deleteSkill(config: SifaApiConfig, rkey: string, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Generic record-create escape hatch. Most callers should prefer the
|
|
256
|
+
* dedicated section helpers (`createPosition`, `createEducation`, etc.)
|
|
257
|
+
* which take typed payloads and ship matching hooks. Use this when the
|
|
258
|
+
* lexicon doesn't yet have a dedicated endpoint (certifications,
|
|
259
|
+
* projects, publications, volunteering, honors, languages, courses).
|
|
260
|
+
*
|
|
261
|
+
* `collection` is a `id.sifa.profile.*` collection NSID. Routes to
|
|
262
|
+
* `POST /api/profile/records/<collection>`.
|
|
263
|
+
*/
|
|
264
|
+
declare function createRecord(config: SifaApiConfig, collection: string, data: Record<string, unknown>, options?: ApiFetchOptions): Promise<CreateResult>;
|
|
265
|
+
/** Generic record-update escape hatch. See {@link createRecord}. */
|
|
266
|
+
declare function updateRecord(config: SifaApiConfig, collection: string, rkey: string, data: Record<string, unknown>, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
267
|
+
/** Generic record-delete escape hatch. See {@link createRecord}. */
|
|
268
|
+
declare function deleteRecord(config: SifaApiConfig, collection: string, rkey: string, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Address payload accepted by `/api/profile/location` endpoints.
|
|
272
|
+
*
|
|
273
|
+
* Accepts both shapes during the community.lexicon.location.address
|
|
274
|
+
* migration. Prefer `country` + `locality` (new) over `countryCode` +
|
|
275
|
+
* `city` (legacy). The API's `locationSchema` is a Zod union that
|
|
276
|
+
* accepts either pair.
|
|
277
|
+
*/
|
|
278
|
+
interface ProfileLocationAddress {
|
|
279
|
+
/** Legacy alias for `country` (alpha-2). */
|
|
280
|
+
countryCode?: string;
|
|
281
|
+
/** community.lexicon.location.address field -- prefer over `countryCode`. */
|
|
282
|
+
country?: string;
|
|
283
|
+
region?: string;
|
|
284
|
+
/** Legacy alias for `locality`. */
|
|
285
|
+
city?: string;
|
|
286
|
+
/** community.lexicon.location.address field -- prefer over `city`. */
|
|
287
|
+
locality?: string;
|
|
288
|
+
}
|
|
289
|
+
/** Body accepted by {@link createProfileLocation} / {@link updateProfileLocation}. */
|
|
290
|
+
interface ProfileLocationInput {
|
|
291
|
+
address: ProfileLocationAddress;
|
|
292
|
+
type: string;
|
|
293
|
+
label?: string;
|
|
294
|
+
isPrimary?: boolean;
|
|
295
|
+
}
|
|
296
|
+
/** Create a new profile location entry. */
|
|
297
|
+
declare function createProfileLocation(config: SifaApiConfig, data: ProfileLocationInput, options?: ApiFetchOptions): Promise<CreateResult>;
|
|
298
|
+
/** Update an existing profile location by `rkey`. */
|
|
299
|
+
declare function updateProfileLocation(config: SifaApiConfig, rkey: string, data: ProfileLocationInput, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
300
|
+
/** Delete a profile location by `rkey`. */
|
|
301
|
+
declare function deleteProfileLocation(config: SifaApiConfig, rkey: string, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
302
|
+
|
|
303
|
+
/** Body accepted by {@link createExternalAccount} / {@link updateExternalAccount}. */
|
|
304
|
+
interface ExternalAccountInput {
|
|
305
|
+
platform: string;
|
|
306
|
+
url: string;
|
|
307
|
+
label?: string;
|
|
308
|
+
feedUrl?: string;
|
|
309
|
+
}
|
|
310
|
+
/** Extended create result for {@link createExternalAccount}. */
|
|
311
|
+
interface CreateExternalAccountResult extends WriteResult {
|
|
312
|
+
rkey?: string;
|
|
313
|
+
feedUrl?: string | null;
|
|
314
|
+
}
|
|
315
|
+
/** Extended write result for {@link verifyExternalAccount}. */
|
|
316
|
+
interface VerifyExternalAccountResult extends WriteResult {
|
|
317
|
+
verified?: boolean;
|
|
318
|
+
verifiedVia?: string;
|
|
319
|
+
}
|
|
320
|
+
/** List external accounts attached to a profile. Returns `[]` on error. */
|
|
321
|
+
declare function fetchExternalAccounts(config: SifaApiConfig, handleOrDid: string, options?: ApiFetchOptions): Promise<ExternalAccount[]>;
|
|
322
|
+
/**
|
|
323
|
+
* Create a new external account record. Returns the newly-created `rkey`
|
|
324
|
+
* and the server-resolved `feedUrl` (sifa-api inspects the target for
|
|
325
|
+
* RSS feeds on platforms that publish them).
|
|
326
|
+
*/
|
|
327
|
+
declare function createExternalAccount(config: SifaApiConfig, data: ExternalAccountInput, options?: ApiFetchOptions): Promise<CreateExternalAccountResult>;
|
|
328
|
+
/** Update an existing external account by `rkey`. */
|
|
329
|
+
declare function updateExternalAccount(config: SifaApiConfig, rkey: string, data: ExternalAccountInput, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
330
|
+
/** Delete an external account by `rkey`. */
|
|
331
|
+
declare function deleteExternalAccount(config: SifaApiConfig, rkey: string, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
332
|
+
/** Mark an external account as the user's primary. */
|
|
333
|
+
declare function setExternalAccountPrimary(config: SifaApiConfig, rkey: string, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
334
|
+
/** Clear the "primary" flag on an external account. */
|
|
335
|
+
declare function unsetExternalAccountPrimary(config: SifaApiConfig, rkey: string, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
336
|
+
/**
|
|
337
|
+
* Run server-side verification on an external account (e.g. inspect
|
|
338
|
+
* the target for a keytrace claim). Returns `{ verified, verifiedVia }`
|
|
339
|
+
* on success.
|
|
340
|
+
*/
|
|
341
|
+
declare function verifyExternalAccount(config: SifaApiConfig, rkey: string, options?: ApiFetchOptions): Promise<VerifyExternalAccountResult>;
|
|
342
|
+
|
|
343
|
+
/** Body accepted by {@link createEndorsement}. */
|
|
344
|
+
interface EndorsementInput {
|
|
345
|
+
skillUri: string;
|
|
346
|
+
comment?: string;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Create an endorsement of another user's skill. The endorsed user
|
|
350
|
+
* must confirm before the endorsement appears on their profile (the
|
|
351
|
+
* endorsement record is on the endorser's PDS; a separate confirmation
|
|
352
|
+
* record on the endorsed user's PDS gates display).
|
|
353
|
+
*/
|
|
354
|
+
declare function createEndorsement(config: SifaApiConfig, data: EndorsementInput, options?: ApiFetchOptions): Promise<CreateResult>;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Hide a keytrace claim (verified-account claim discovered on the
|
|
358
|
+
* user's external accounts) from the user's profile. The claim itself
|
|
359
|
+
* stays in the index; only its display is suppressed.
|
|
360
|
+
*/
|
|
361
|
+
declare function hideKeytraceClaim(config: SifaApiConfig, rkey: string, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
362
|
+
/** Restore a previously-hidden keytrace claim. */
|
|
363
|
+
declare function unhideKeytraceClaim(config: SifaApiConfig, rkey: string, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
364
|
+
|
|
365
|
+
/** Extended result for {@link refreshOrcidPublications}. */
|
|
366
|
+
interface RefreshOrcidPublicationsResult extends WriteResult {
|
|
367
|
+
added?: number;
|
|
368
|
+
removed?: number;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Hide an ORCID-imported publication from the user's profile. The
|
|
372
|
+
* `putCode` is the ORCID-side identifier; the underlying record stays
|
|
373
|
+
* in the index, only its display is suppressed.
|
|
374
|
+
*/
|
|
375
|
+
declare function hideOrcidPublication(config: SifaApiConfig, putCode: number, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
376
|
+
/** Restore a previously-hidden ORCID publication. */
|
|
377
|
+
declare function unhideOrcidPublication(config: SifaApiConfig, putCode: number, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
378
|
+
/** Hide a standard (auto-imported) publication by its AT URI. */
|
|
379
|
+
declare function hideStandardPublication(config: SifaApiConfig, uri: string, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
380
|
+
/** Restore a previously-hidden standard publication. */
|
|
381
|
+
declare function unhideStandardPublication(config: SifaApiConfig, uri: string, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
382
|
+
/** Bulk-hide standard publications by AT URI list. */
|
|
383
|
+
declare function bulkHideStandardPublications(config: SifaApiConfig, uris: string[], options?: ApiFetchOptions): Promise<WriteResult>;
|
|
384
|
+
/** Bulk-unhide standard publications by AT URI list. */
|
|
385
|
+
declare function bulkUnhideStandardPublications(config: SifaApiConfig, uris: string[], options?: ApiFetchOptions): Promise<WriteResult>;
|
|
386
|
+
/** Hide an `id.sifa.profile.publication` (user-authored publication record). */
|
|
387
|
+
declare function hideSifaPublication(config: SifaApiConfig, rkey: string, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
388
|
+
/** Restore a previously-hidden Sifa publication. */
|
|
389
|
+
declare function unhideSifaPublication(config: SifaApiConfig, rkey: string, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
390
|
+
/**
|
|
391
|
+
* Re-pull the authenticated user's ORCID publications. Returns counts
|
|
392
|
+
* of added and removed records. The server returns `{ error: '...' }`
|
|
393
|
+
* inline (not via HTTP status) on quota / linkage failures; the SDK
|
|
394
|
+
* folds that into `{ success: false, error }` to keep the contract
|
|
395
|
+
* consistent with other mutations.
|
|
396
|
+
*/
|
|
397
|
+
declare function refreshOrcidPublications(config: SifaApiConfig, options?: ApiFetchOptions): Promise<RefreshOrcidPublicationsResult>;
|
|
398
|
+
|
|
399
|
+
/** Public, aggregate stats shown on the homepage and similar surfaces. */
|
|
400
|
+
interface StatsResponse {
|
|
401
|
+
profileCount: number;
|
|
402
|
+
avatars: string[];
|
|
403
|
+
atproto: {
|
|
404
|
+
userCount: number;
|
|
405
|
+
growthPerSecond: number;
|
|
406
|
+
timestamp: number;
|
|
407
|
+
} | null;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Homepage stats (profile count, avatar samples, ATproto growth). Public
|
|
411
|
+
* endpoint -- safe to cache. Returns `null` on any error so callers can
|
|
412
|
+
* render a graceful empty state.
|
|
413
|
+
*/
|
|
414
|
+
declare function fetchStats(config: SifaApiConfig, options?: ApiFetchOptions): Promise<StatsResponse | null>;
|
|
415
|
+
|
|
416
|
+
/** Catalog entry describing an ATproto app that Sifa surfaces activity for. */
|
|
417
|
+
interface AppRegistryEntry {
|
|
418
|
+
id: string;
|
|
419
|
+
name: string;
|
|
420
|
+
category: string;
|
|
421
|
+
collectionPrefixes: string[];
|
|
422
|
+
scanCollections: string[];
|
|
423
|
+
urlPattern?: string;
|
|
424
|
+
color: string;
|
|
425
|
+
}
|
|
426
|
+
/** Compact app representation returned by the hidden-apps endpoint. */
|
|
427
|
+
interface HiddenApp {
|
|
428
|
+
id: string;
|
|
429
|
+
name: string;
|
|
430
|
+
category: string;
|
|
431
|
+
}
|
|
432
|
+
interface FetchHiddenAppsOptions extends ApiFetchOptions {
|
|
433
|
+
/**
|
|
434
|
+
* Pass the caller's `Cookie` header on Next.js RSC server-side calls.
|
|
435
|
+
* `credentials: 'include'` does NOT propagate browser cookies in RSC,
|
|
436
|
+
* so authenticated server fetches must forward the header explicitly.
|
|
437
|
+
*/
|
|
438
|
+
cookieHeader?: string;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Public app registry shown across discovery surfaces. Heavily cached.
|
|
442
|
+
* Returns `[]` on any error.
|
|
443
|
+
*/
|
|
444
|
+
declare function fetchAppsRegistry(config: SifaApiConfig, options?: ApiFetchOptions): Promise<AppRegistryEntry[]>;
|
|
445
|
+
/**
|
|
446
|
+
* Apps the authenticated user has chosen to hide from their activity feed.
|
|
447
|
+
* Requires an authenticated session. Returns `[]` on any error (including
|
|
448
|
+
* the unauthenticated case).
|
|
449
|
+
*/
|
|
450
|
+
declare function fetchHiddenApps(config: SifaApiConfig, options?: FetchHiddenAppsOptions): Promise<HiddenApp[]>;
|
|
451
|
+
|
|
452
|
+
/** Profile entry returned by the search endpoint. */
|
|
453
|
+
interface ProfileSearchResult {
|
|
454
|
+
did?: string;
|
|
455
|
+
handle: string;
|
|
456
|
+
displayName?: string;
|
|
457
|
+
headline?: string;
|
|
458
|
+
avatar?: string;
|
|
459
|
+
about?: string;
|
|
460
|
+
currentRole?: string;
|
|
461
|
+
currentCompany?: string;
|
|
462
|
+
industry?: string;
|
|
463
|
+
domain?: string;
|
|
464
|
+
countryCode?: string;
|
|
465
|
+
locationCountry?: string;
|
|
466
|
+
preferredWorkplace?: string[];
|
|
467
|
+
claimed?: boolean;
|
|
468
|
+
blueskyVerified?: boolean;
|
|
469
|
+
blueskyVerifiedAt?: string | null;
|
|
470
|
+
}
|
|
471
|
+
interface SearchFilters {
|
|
472
|
+
q?: string;
|
|
473
|
+
skill?: string;
|
|
474
|
+
country?: string;
|
|
475
|
+
industry?: string;
|
|
476
|
+
domain?: string;
|
|
477
|
+
workplace?: string;
|
|
478
|
+
app?: string;
|
|
479
|
+
limit?: number;
|
|
480
|
+
}
|
|
481
|
+
interface SearchResponse {
|
|
482
|
+
profiles: ProfileSearchResult[];
|
|
483
|
+
total: number;
|
|
484
|
+
limit: number;
|
|
485
|
+
offset: number;
|
|
486
|
+
}
|
|
487
|
+
/** Skill typeahead suggestion. */
|
|
488
|
+
interface SkillSearchResult {
|
|
489
|
+
name: string;
|
|
490
|
+
slug: string;
|
|
491
|
+
category: string;
|
|
492
|
+
userCount: number;
|
|
493
|
+
}
|
|
494
|
+
interface FilterOptions {
|
|
495
|
+
countries: {
|
|
496
|
+
countryCode: string;
|
|
497
|
+
country: string;
|
|
498
|
+
count: number;
|
|
499
|
+
}[];
|
|
500
|
+
industries: {
|
|
501
|
+
industry: string;
|
|
502
|
+
count: number;
|
|
503
|
+
}[];
|
|
504
|
+
apps: {
|
|
505
|
+
appId: string;
|
|
506
|
+
count: number;
|
|
507
|
+
}[];
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Search profiles by free-text query and optional filters. Returns an
|
|
511
|
+
* empty result set when no filters are provided (matching sifa-web's
|
|
512
|
+
* "no input, no fetch" behavior).
|
|
513
|
+
*/
|
|
514
|
+
declare function fetchSearchProfiles(config: SifaApiConfig, filters: SearchFilters, options?: ApiFetchOptions): Promise<SearchResponse>;
|
|
515
|
+
/**
|
|
516
|
+
* Skill typeahead. Returns up to 8 matches for the given prefix. Empty
|
|
517
|
+
* input returns an empty array without hitting the server.
|
|
518
|
+
*/
|
|
519
|
+
declare function fetchSkillSuggestions(config: SifaApiConfig, query: string, options?: ApiFetchOptions): Promise<SkillSearchResult[]>;
|
|
520
|
+
/** Available filter facets (countries, industries, apps) for search UI. */
|
|
521
|
+
declare function fetchSearchFilters(config: SifaApiConfig, options?: ApiFetchOptions): Promise<FilterOptions>;
|
|
522
|
+
/**
|
|
523
|
+
* Canonical-skill search backing the position-editor and similar
|
|
524
|
+
* skill-pickers. Hits `/api/skills/search` (the canonical-skills DB
|
|
525
|
+
* lookup) which is distinct from {@link fetchSkillSuggestions}'s
|
|
526
|
+
* `/api/search/skills` (the profile-skill typeahead).
|
|
527
|
+
*
|
|
528
|
+
* Returns `[]` on empty input (no network call) or any error.
|
|
529
|
+
*/
|
|
530
|
+
declare function searchSkills(config: SifaApiConfig, query: string, limit?: number, options?: ApiFetchOptions): Promise<SkillSuggestion[]>;
|
|
531
|
+
|
|
532
|
+
/** Lightweight profile representation used by discovery endpoints. */
|
|
533
|
+
interface SimilarProfile {
|
|
534
|
+
did: string;
|
|
535
|
+
handle: string;
|
|
536
|
+
displayName?: string | null;
|
|
537
|
+
avatar?: string | null;
|
|
538
|
+
headline?: string | null;
|
|
539
|
+
currentRole?: string | null;
|
|
540
|
+
currentCompany?: string | null;
|
|
541
|
+
industry?: string | null;
|
|
542
|
+
domain?: string | null;
|
|
543
|
+
}
|
|
544
|
+
interface SuggestionProfile {
|
|
545
|
+
did: string;
|
|
546
|
+
handle: string;
|
|
547
|
+
displayName?: string;
|
|
548
|
+
headline?: string;
|
|
549
|
+
avatarUrl?: string;
|
|
550
|
+
source: string;
|
|
551
|
+
dismissed: boolean;
|
|
552
|
+
blueskyVerified?: boolean;
|
|
553
|
+
}
|
|
554
|
+
interface SuggestionsResponse {
|
|
555
|
+
onSifa: SuggestionProfile[];
|
|
556
|
+
notOnSifa: SuggestionProfile[];
|
|
557
|
+
cursor?: string;
|
|
558
|
+
}
|
|
559
|
+
interface FeaturedProfile {
|
|
560
|
+
did: string;
|
|
561
|
+
handle: string;
|
|
562
|
+
displayName?: string;
|
|
563
|
+
avatar?: string;
|
|
564
|
+
pronouns?: string;
|
|
565
|
+
headline?: string;
|
|
566
|
+
about?: string;
|
|
567
|
+
currentRole?: string;
|
|
568
|
+
currentCompany?: string;
|
|
569
|
+
locationCountry?: string;
|
|
570
|
+
locationRegion?: string;
|
|
571
|
+
/** Legacy alias for `locationLocality`; emitted by sifa-api during the additive response window. */
|
|
572
|
+
locationCity?: string;
|
|
573
|
+
/** community.lexicon.location.address field name -- prefer over `locationCity`. */
|
|
574
|
+
locationLocality?: string;
|
|
575
|
+
countryCode?: string;
|
|
576
|
+
location?: string;
|
|
577
|
+
website?: string;
|
|
578
|
+
openTo?: string[];
|
|
579
|
+
preferredWorkplace?: string[];
|
|
580
|
+
availableFromUtc?: number;
|
|
581
|
+
availableToUtc?: number;
|
|
582
|
+
followersCount?: number;
|
|
583
|
+
atprotoFollowersCount?: number;
|
|
584
|
+
pdsProvider?: {
|
|
585
|
+
name: string;
|
|
586
|
+
host: string;
|
|
587
|
+
} | null;
|
|
588
|
+
claimed: boolean;
|
|
589
|
+
featuredDate: string;
|
|
590
|
+
}
|
|
591
|
+
/** Profiles similar to the given DID (matchmaking). Returns `[]` on error. */
|
|
592
|
+
declare function fetchSimilarProfiles(config: SifaApiConfig, did: string, opts?: {
|
|
593
|
+
limit?: number;
|
|
594
|
+
} & ApiFetchOptions): Promise<SimilarProfile[]>;
|
|
595
|
+
interface FetchSuggestionsOptions extends ApiFetchOptions {
|
|
596
|
+
source?: string;
|
|
597
|
+
includeDismissed?: boolean;
|
|
598
|
+
cursor?: string;
|
|
599
|
+
limit?: number;
|
|
600
|
+
/**
|
|
601
|
+
* Pass the caller's `Cookie` header on Next.js RSC server-side calls.
|
|
602
|
+
* `credentials: 'include'` does NOT propagate browser cookies in RSC,
|
|
603
|
+
* so authenticated server fetches must forward the header explicitly.
|
|
604
|
+
*/
|
|
605
|
+
cookieHeader?: string;
|
|
606
|
+
}
|
|
607
|
+
/** Discovery suggestions feed. Resolves to empty arrays on error. */
|
|
608
|
+
declare function fetchSuggestions(config: SifaApiConfig, opts?: FetchSuggestionsOptions): Promise<SuggestionsResponse>;
|
|
609
|
+
/** Count of pending suggestions since an optional timestamp. */
|
|
610
|
+
declare function fetchSuggestionCount(config: SifaApiConfig, since?: string, options?: ApiFetchOptions): Promise<number>;
|
|
611
|
+
/** Featured profile (rotated by sifa-api). Returns `null` when none. */
|
|
612
|
+
declare function fetchFeaturedProfile(config: SifaApiConfig, options?: ApiFetchOptions): Promise<FeaturedProfile | null>;
|
|
613
|
+
|
|
614
|
+
interface FollowProfile {
|
|
615
|
+
did: string;
|
|
616
|
+
handle: string;
|
|
617
|
+
displayName?: string;
|
|
618
|
+
headline?: string;
|
|
619
|
+
avatarUrl?: string;
|
|
620
|
+
source: string;
|
|
621
|
+
claimed: boolean;
|
|
622
|
+
followedAt: string;
|
|
623
|
+
blueskyVerified?: boolean;
|
|
624
|
+
blueskyVerifiedAt?: string | null;
|
|
625
|
+
}
|
|
626
|
+
interface FollowingResponse {
|
|
627
|
+
follows: FollowProfile[];
|
|
628
|
+
cursor?: string;
|
|
629
|
+
}
|
|
630
|
+
/** People the authenticated user follows. Empty on error. */
|
|
631
|
+
declare function fetchFollowing(config: SifaApiConfig, opts?: {
|
|
632
|
+
source?: string;
|
|
633
|
+
cursor?: string;
|
|
634
|
+
limit?: number;
|
|
635
|
+
} & ApiFetchOptions): Promise<FollowingResponse>;
|
|
636
|
+
|
|
637
|
+
interface QuotedPostAuthor {
|
|
638
|
+
did: string;
|
|
639
|
+
handle: string;
|
|
640
|
+
displayName?: string;
|
|
641
|
+
avatar?: string;
|
|
642
|
+
}
|
|
643
|
+
interface QuotedPostImage {
|
|
644
|
+
thumb: string;
|
|
645
|
+
fullsize: string;
|
|
646
|
+
alt?: string;
|
|
647
|
+
}
|
|
648
|
+
interface QuotedPostView {
|
|
649
|
+
uri: string;
|
|
650
|
+
cid: string;
|
|
651
|
+
author: QuotedPostAuthor;
|
|
652
|
+
text: string;
|
|
653
|
+
createdAt: string;
|
|
654
|
+
images?: QuotedPostImage[];
|
|
655
|
+
}
|
|
656
|
+
type QuotedPostResult = {
|
|
657
|
+
status: 'ok';
|
|
658
|
+
record: QuotedPostView;
|
|
659
|
+
} | {
|
|
660
|
+
status: 'deleted';
|
|
661
|
+
uri: string;
|
|
662
|
+
} | {
|
|
663
|
+
status: 'unavailable';
|
|
664
|
+
uri: string;
|
|
665
|
+
};
|
|
666
|
+
/** Max URIs per request to `POST /api/quoted-posts/resolve` (mirrors server cap). */
|
|
667
|
+
declare const QUOTED_POSTS_BATCH_MAX = 20;
|
|
668
|
+
interface ResolveQuotedPostsOptions extends ApiFetchOptions {
|
|
669
|
+
/** Cookie header for Next.js RSC server-side calls; ignored in browsers. */
|
|
670
|
+
cookieHeader?: string;
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Resolve a batch of AT-URIs to their quoted-post snapshots via the Sifa AppView.
|
|
674
|
+
*
|
|
675
|
+
* Auto-deduplicates input URIs and splits requests into chunks of
|
|
676
|
+
* {@link QUOTED_POSTS_BATCH_MAX} so callers can pass an arbitrary-length array.
|
|
677
|
+
* Each chunk is fired in parallel. The server caches results in Valkey, so
|
|
678
|
+
* repeated calls for the same URI are cheap.
|
|
679
|
+
*
|
|
680
|
+
* Returns a map of `uri -> QuotedPostResult`. URIs that fail (network error,
|
|
681
|
+
* non-2xx, or the server omitting them) are absent from the map; the caller
|
|
682
|
+
* should render a skeleton or tombstone for those.
|
|
683
|
+
*/
|
|
684
|
+
declare function resolveQuotedPosts(config: SifaApiConfig, uris: string[], options?: ResolveQuotedPostsOptions): Promise<Record<string, QuotedPostResult>>;
|
|
685
|
+
|
|
686
|
+
interface HeatmapDay {
|
|
687
|
+
date: string;
|
|
688
|
+
total: number;
|
|
689
|
+
apps: {
|
|
690
|
+
appId: string;
|
|
691
|
+
count: number;
|
|
692
|
+
}[];
|
|
693
|
+
}
|
|
694
|
+
interface HeatmapResponse {
|
|
695
|
+
days: HeatmapDay[];
|
|
696
|
+
appTotals: {
|
|
697
|
+
appId: string;
|
|
698
|
+
appName: string;
|
|
699
|
+
total: number;
|
|
700
|
+
}[];
|
|
701
|
+
thresholds: [number, number, number, number];
|
|
702
|
+
}
|
|
703
|
+
interface ActivityItem {
|
|
704
|
+
uri: string;
|
|
705
|
+
cid: string;
|
|
706
|
+
collection: string;
|
|
707
|
+
rkey: string;
|
|
708
|
+
record: Record<string, unknown>;
|
|
709
|
+
appId: string;
|
|
710
|
+
appName: string;
|
|
711
|
+
category: string;
|
|
712
|
+
indexedAt: string;
|
|
713
|
+
/**
|
|
714
|
+
* Set by the server when an `app.bsky.embed.record` quote was already
|
|
715
|
+
* resolved upstream (AppView path). Mutually exclusive with `quotedPostUri`.
|
|
716
|
+
*/
|
|
717
|
+
quotedPost?: QuotedPostResult;
|
|
718
|
+
/**
|
|
719
|
+
* Set by the server when an `app.bsky.embed.record` quote needs client-side
|
|
720
|
+
* resolution (PDS path). Pass batches to {@link resolveQuotedPosts}.
|
|
721
|
+
* Mutually exclusive with `quotedPost`.
|
|
722
|
+
*/
|
|
723
|
+
quotedPostUri?: string;
|
|
724
|
+
}
|
|
725
|
+
interface ActivityTeaserResponse {
|
|
726
|
+
items: ActivityItem[];
|
|
727
|
+
blueskyGated?: boolean;
|
|
728
|
+
backfillPending?: boolean;
|
|
729
|
+
failedApps?: string[];
|
|
730
|
+
}
|
|
731
|
+
interface ActivityFeedResponse {
|
|
732
|
+
items: ActivityItem[];
|
|
733
|
+
cursor: string | null;
|
|
734
|
+
hasMore: boolean;
|
|
735
|
+
availableCategories?: string[];
|
|
736
|
+
blueskyGated?: boolean;
|
|
737
|
+
failedApps?: string[];
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Per-day activity counts for a profile across all ATproto apps. Returns
|
|
741
|
+
* `null` on any error so callers can render a graceful empty state.
|
|
742
|
+
*/
|
|
743
|
+
declare function fetchHeatmapData(config: SifaApiConfig, handleOrDid: string, days: number, options?: ApiFetchOptions): Promise<HeatmapResponse | null>;
|
|
744
|
+
interface FetchActivityTeaserOptions extends ApiFetchOptions {
|
|
745
|
+
/**
|
|
746
|
+
* Pass the caller's `Cookie` header on Next.js RSC server-side calls.
|
|
747
|
+
* Required for authenticated server fetches because `credentials: 'include'`
|
|
748
|
+
* does not propagate browser cookies in RSC.
|
|
749
|
+
*/
|
|
750
|
+
cookieHeader?: string;
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Recent activity teaser for a profile (homepage-sized slice). Caps the
|
|
754
|
+
* upstream wait so the SSR path cannot hang. Returns `null` on any error.
|
|
755
|
+
*/
|
|
756
|
+
declare function fetchActivityTeaser(config: SifaApiConfig, handleOrDid: string, options?: FetchActivityTeaserOptions): Promise<ActivityTeaserResponse | null>;
|
|
757
|
+
interface FetchActivityFeedOptions extends ApiFetchOptions {
|
|
758
|
+
category?: string;
|
|
759
|
+
limit?: number;
|
|
760
|
+
cursor?: string;
|
|
761
|
+
cookieHeader?: string;
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* Paginated activity feed for a profile. Always fresh (`cache: 'no-store'`).
|
|
765
|
+
* Returns `null` on any error.
|
|
766
|
+
*/
|
|
767
|
+
declare function fetchActivityFeed(config: SifaApiConfig, handleOrDid: string, options?: FetchActivityFeedOptions): Promise<ActivityFeedResponse | null>;
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Counts confirmed endorsements received by a DID. The backend's
|
|
771
|
+
* `GET /api/endorsement/:did` already returns only confirmed endorsements
|
|
772
|
+
* (via inner join with `endorsementConfirmations`), so this helper just
|
|
773
|
+
* returns the array length. Failures return 0 so callers can route safely.
|
|
774
|
+
*
|
|
775
|
+
* Public endpoint -- no credentials needed.
|
|
776
|
+
*/
|
|
777
|
+
declare function fetchEndorsementCount(config: SifaApiConfig, did: string, options?: ApiFetchOptions): Promise<number>;
|
|
778
|
+
|
|
779
|
+
interface FetchNetworkStreamCountOptions extends ApiFetchOptions {
|
|
780
|
+
/**
|
|
781
|
+
* Pass the caller's `Cookie` header on Next.js RSC server-side calls.
|
|
782
|
+
* Required for authenticated server fetches because `credentials: 'include'`
|
|
783
|
+
* does not propagate browser cookies in RSC.
|
|
784
|
+
*
|
|
785
|
+
* When omitted, the request falls back to `credentials: 'include'` so
|
|
786
|
+
* client-side calls work without extra plumbing.
|
|
787
|
+
*/
|
|
788
|
+
cookieHeader?: string;
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* Counts items in the authenticated user's network stream digest. The
|
|
792
|
+
* underlying `GET /api/stream/network` endpoint may 404 while the feature
|
|
793
|
+
* is in development; in that case (and on any other error) this returns
|
|
794
|
+
* 0 so callers can route safely to a fallback experience.
|
|
795
|
+
*/
|
|
796
|
+
declare function fetchNetworkStreamCount(config: SifaApiConfig, did: string, options?: FetchNetworkStreamCountOptions): Promise<number>;
|
|
797
|
+
|
|
798
|
+
/** Per-URI reaction state for the authenticated viewer. */
|
|
799
|
+
interface ReactionStatus {
|
|
800
|
+
reacted: boolean;
|
|
801
|
+
rkey?: string;
|
|
802
|
+
collection?: string;
|
|
803
|
+
}
|
|
804
|
+
/** Result of checking whether the authenticated viewer has an account on a given app. */
|
|
805
|
+
interface AccountCheckResult {
|
|
806
|
+
hasAccount: boolean;
|
|
807
|
+
appName: string;
|
|
808
|
+
appUrl: string;
|
|
809
|
+
}
|
|
810
|
+
interface FetchReactionStatusOptions extends ApiFetchOptions {
|
|
811
|
+
/**
|
|
812
|
+
* Pass the caller's `Cookie` header on Next.js RSC server-side calls.
|
|
813
|
+
* Required for authenticated server fetches because `credentials: 'include'`
|
|
814
|
+
* does not propagate browser cookies in RSC.
|
|
815
|
+
*/
|
|
816
|
+
cookieHeader?: string;
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* Batch-look up reaction status for multiple URIs. Returns `{}` for an
|
|
820
|
+
* empty input list (no network call) and `null` on any error.
|
|
821
|
+
*/
|
|
822
|
+
declare function fetchReactionStatus(config: SifaApiConfig, uris: string[], options?: FetchReactionStatusOptions): Promise<Record<string, ReactionStatus> | null>;
|
|
823
|
+
interface CheckAppAccountOptions extends ApiFetchOptions {
|
|
824
|
+
cookieHeader?: string;
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Check whether the authenticated viewer has an account on a given app.
|
|
828
|
+
* Returns `null` on any error.
|
|
829
|
+
*/
|
|
830
|
+
declare function checkAppAccount(config: SifaApiConfig, appId: string, options?: CheckAppAccountOptions): Promise<AccountCheckResult | null>;
|
|
831
|
+
/** Result of a successful {@link createReaction}. */
|
|
832
|
+
interface ReactionResult {
|
|
833
|
+
uri: string;
|
|
834
|
+
rkey: string;
|
|
835
|
+
}
|
|
836
|
+
/** Structured error returned by {@link createReaction} on failure. */
|
|
837
|
+
interface ReactionError {
|
|
838
|
+
type: 'scope_insufficient' | 'error';
|
|
839
|
+
/** When `type === 'scope_insufficient'`, the lexicon scope the user must re-authorize for. */
|
|
840
|
+
requiredScope?: string;
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* Create a reaction (like / star) on a target ATproto record.
|
|
844
|
+
*
|
|
845
|
+
* Returns a discriminated-union result instead of the generic
|
|
846
|
+
* {@link WriteResult} shape because reactions have a distinct
|
|
847
|
+
* "scope insufficient" failure that callers handle differently from
|
|
848
|
+
* other errors (it triggers an OAuth scope-upgrade flow rather than
|
|
849
|
+
* an error toast).
|
|
850
|
+
*
|
|
851
|
+
* Never throws.
|
|
852
|
+
*/
|
|
853
|
+
declare function createReaction(config: SifaApiConfig, targetUri: string, appId: string, targetCid?: string, options?: ApiFetchOptions): Promise<{
|
|
854
|
+
ok: true;
|
|
855
|
+
data: ReactionResult;
|
|
856
|
+
} | {
|
|
857
|
+
ok: false;
|
|
858
|
+
error: ReactionError;
|
|
859
|
+
}>;
|
|
860
|
+
/**
|
|
861
|
+
* Delete a reaction (like / star) on a target ATproto record. Returns
|
|
862
|
+
* `{ success: true }` on 2xx, `{ success: false, error }` on failure.
|
|
863
|
+
*/
|
|
864
|
+
declare function deleteReaction(config: SifaApiConfig, targetUri: string, appId: string, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
865
|
+
|
|
866
|
+
/** Voter on a roadmap item. */
|
|
867
|
+
interface RoadmapVoter {
|
|
868
|
+
did: string;
|
|
869
|
+
avatarUrl?: string;
|
|
870
|
+
}
|
|
871
|
+
/** Map of item key -> vote tally and voter list. */
|
|
872
|
+
type RoadmapVotesResponse = Record<string, {
|
|
873
|
+
count: number;
|
|
874
|
+
voters: RoadmapVoter[];
|
|
875
|
+
}>;
|
|
876
|
+
/**
|
|
877
|
+
* Public roadmap vote tallies, keyed by item. Returns `{}` on any error.
|
|
878
|
+
*/
|
|
879
|
+
declare function fetchRoadmapVotes(config: SifaApiConfig, options?: ApiFetchOptions): Promise<RoadmapVotesResponse>;
|
|
880
|
+
interface FetchMyRoadmapVotesOptions extends ApiFetchOptions {
|
|
881
|
+
/**
|
|
882
|
+
* Pass the caller's `Cookie` header on Next.js RSC server-side calls.
|
|
883
|
+
* Required for authenticated server fetches because `credentials: 'include'`
|
|
884
|
+
* does not propagate browser cookies in RSC.
|
|
885
|
+
*/
|
|
886
|
+
cookieHeader?: string;
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* Roadmap items the authenticated user has voted on. Returns `[]` on any
|
|
890
|
+
* error or when the response payload is shaped unexpectedly.
|
|
891
|
+
*/
|
|
892
|
+
declare function fetchMyRoadmapVotes(config: SifaApiConfig, options?: FetchMyRoadmapVotesOptions): Promise<string[]>;
|
|
893
|
+
/** Cast a vote on a roadmap item by its key. */
|
|
894
|
+
declare function castRoadmapVote(config: SifaApiConfig, key: string, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
895
|
+
/** Retract a previously-cast roadmap vote. */
|
|
896
|
+
declare function retractRoadmapVote(config: SifaApiConfig, key: string, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
897
|
+
|
|
898
|
+
/** Extended write result for {@link deleteAccount}. */
|
|
899
|
+
interface DeleteAccountResult extends WriteResult {
|
|
900
|
+
/** The deleted handle, returned by the server for confirmation UIs. */
|
|
901
|
+
handle?: string;
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* Reset the authenticated user's Sifa profile.
|
|
905
|
+
*
|
|
906
|
+
* `deletePdsData: true` also deletes the corresponding records on the
|
|
907
|
+
* user's PDS. `deletePdsData: false` only removes the AppView's
|
|
908
|
+
* indexed state -- the records on the PDS are left intact and could be
|
|
909
|
+
* re-indexed later.
|
|
910
|
+
*
|
|
911
|
+
* Destructive. Server enforces session check + attestation; the SDK
|
|
912
|
+
* does not gate on additional confirmation. Wrap call sites in your
|
|
913
|
+
* own modal if you want a UX confirmation step.
|
|
914
|
+
*/
|
|
915
|
+
declare function resetProfile(config: SifaApiConfig, deletePdsData: boolean, options?: ApiFetchOptions): Promise<WriteResult>;
|
|
916
|
+
/**
|
|
917
|
+
* Delete the authenticated user's account. Returns the deleted handle
|
|
918
|
+
* on success (used by the post-delete confirmation screen).
|
|
919
|
+
*
|
|
920
|
+
* `deletePdsData: true` also deletes the corresponding records on the
|
|
921
|
+
* user's PDS; `false` leaves the PDS records intact.
|
|
922
|
+
*
|
|
923
|
+
* Destructive. Same caveat as {@link resetProfile}.
|
|
924
|
+
*/
|
|
925
|
+
declare function deleteAccount(config: SifaApiConfig, deletePdsData: boolean, options?: ApiFetchOptions): Promise<DeleteAccountResult>;
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* Query key factory for TanStack Query.
|
|
929
|
+
*
|
|
930
|
+
* Keys are read-only tuples; the hierarchy matches the SDK's fetcher
|
|
931
|
+
* grouping. Use these instead of inline arrays so consumers can target
|
|
932
|
+
* `queryClient.invalidateQueries({ queryKey: keys.profile.all() })` and
|
|
933
|
+
* similar patterns without typos.
|
|
934
|
+
*
|
|
935
|
+
* Convention: every leaf key starts with the namespace ('sifa') so
|
|
936
|
+
* consumers can invalidate everything Sifa-related in one call.
|
|
937
|
+
*/
|
|
938
|
+
declare const sifaQueryKeys: {
|
|
939
|
+
readonly all: () => readonly ["sifa"];
|
|
940
|
+
readonly profile: {
|
|
941
|
+
readonly all: () => readonly ["sifa", "profile"];
|
|
942
|
+
readonly byHandle: (handleOrDid: string) => readonly ["sifa", "profile", string];
|
|
943
|
+
readonly atFundLink: (did: string) => readonly ["sifa", "profile", "at-fund-link", string];
|
|
944
|
+
readonly externalAccounts: (handleOrDid: string) => readonly ["sifa", "profile", "external-accounts", string];
|
|
945
|
+
};
|
|
946
|
+
readonly position: {
|
|
947
|
+
readonly all: () => readonly ["sifa", "position"];
|
|
948
|
+
readonly byOwner: (did: string) => readonly ["sifa", "position", "by-owner", string];
|
|
949
|
+
};
|
|
950
|
+
readonly search: {
|
|
951
|
+
readonly all: () => readonly ["sifa", "search"];
|
|
952
|
+
readonly profiles: (filters: Record<string, unknown>) => readonly ["sifa", "search", "profiles", Record<string, unknown>];
|
|
953
|
+
readonly skills: (query: string) => readonly ["sifa", "search", "skills", string];
|
|
954
|
+
readonly canonicalSkills: (query: string, limit: number) => readonly ["sifa", "search", "canonical-skills", string, number];
|
|
955
|
+
readonly filters: () => readonly ["sifa", "search", "filters"];
|
|
956
|
+
};
|
|
957
|
+
readonly discovery: {
|
|
958
|
+
readonly all: () => readonly ["sifa", "discovery"];
|
|
959
|
+
readonly similar: (did: string, limit: number) => readonly ["sifa", "discovery", "similar", string, number];
|
|
960
|
+
readonly suggestions: (opts: Record<string, unknown>) => readonly ["sifa", "discovery", "suggestions", Record<string, unknown>];
|
|
961
|
+
readonly suggestionCount: (since: string | undefined) => readonly ["sifa", "discovery", "suggestion-count", string | null];
|
|
962
|
+
readonly featured: () => readonly ["sifa", "discovery", "featured"];
|
|
963
|
+
};
|
|
964
|
+
readonly follow: {
|
|
965
|
+
readonly all: () => readonly ["sifa", "follow"];
|
|
966
|
+
readonly following: (opts: Record<string, unknown>) => readonly ["sifa", "follow", "following", Record<string, unknown>];
|
|
967
|
+
};
|
|
968
|
+
readonly stats: {
|
|
969
|
+
readonly all: () => readonly ["sifa", "stats"];
|
|
970
|
+
readonly homepage: () => readonly ["sifa", "stats", "homepage"];
|
|
971
|
+
};
|
|
972
|
+
readonly apps: {
|
|
973
|
+
readonly all: () => readonly ["sifa", "apps"];
|
|
974
|
+
readonly registry: () => readonly ["sifa", "apps", "registry"];
|
|
975
|
+
readonly hidden: () => readonly ["sifa", "apps", "hidden"];
|
|
976
|
+
};
|
|
977
|
+
readonly activity: {
|
|
978
|
+
readonly all: () => readonly ["sifa", "activity"];
|
|
979
|
+
readonly heatmap: (handleOrDid: string, days: number) => readonly ["sifa", "activity", "heatmap", string, number];
|
|
980
|
+
readonly teaser: (handleOrDid: string) => readonly ["sifa", "activity", "teaser", string];
|
|
981
|
+
readonly feed: (handleOrDid: string, opts: Record<string, unknown>) => readonly ["sifa", "activity", "feed", string, Record<string, unknown>];
|
|
982
|
+
};
|
|
983
|
+
readonly endorsement: {
|
|
984
|
+
readonly all: () => readonly ["sifa", "endorsement"];
|
|
985
|
+
readonly count: (did: string) => readonly ["sifa", "endorsement", "count", string];
|
|
986
|
+
};
|
|
987
|
+
readonly stream: {
|
|
988
|
+
readonly all: () => readonly ["sifa", "stream"];
|
|
989
|
+
readonly networkCount: (did: string) => readonly ["sifa", "stream", "network-count", string];
|
|
990
|
+
};
|
|
991
|
+
readonly reactions: {
|
|
992
|
+
readonly all: () => readonly ["sifa", "reactions"];
|
|
993
|
+
readonly status: (uris: string[]) => readonly ["sifa", "reactions", "status", string[]];
|
|
994
|
+
readonly accountCheck: (appId: string) => readonly ["sifa", "reactions", "account-check", string];
|
|
995
|
+
};
|
|
996
|
+
readonly roadmap: {
|
|
997
|
+
readonly all: () => readonly ["sifa", "roadmap"];
|
|
998
|
+
readonly votes: () => readonly ["sifa", "roadmap", "votes"];
|
|
999
|
+
readonly myVotes: () => readonly ["sifa", "roadmap", "my-votes"];
|
|
1000
|
+
};
|
|
1001
|
+
};
|
|
1002
|
+
type SifaQueryKey = ReturnType<typeof sifaQueryKeys.all> | ReturnType<typeof sifaQueryKeys.profile.all> | ReturnType<typeof sifaQueryKeys.profile.byHandle> | ReturnType<typeof sifaQueryKeys.profile.atFundLink> | ReturnType<typeof sifaQueryKeys.profile.externalAccounts> | ReturnType<typeof sifaQueryKeys.position.all> | ReturnType<typeof sifaQueryKeys.position.byOwner> | ReturnType<typeof sifaQueryKeys.search.all> | ReturnType<typeof sifaQueryKeys.search.profiles> | ReturnType<typeof sifaQueryKeys.search.canonicalSkills> | ReturnType<typeof sifaQueryKeys.search.skills> | ReturnType<typeof sifaQueryKeys.search.filters> | ReturnType<typeof sifaQueryKeys.discovery.all> | ReturnType<typeof sifaQueryKeys.discovery.similar> | ReturnType<typeof sifaQueryKeys.discovery.suggestions> | ReturnType<typeof sifaQueryKeys.discovery.suggestionCount> | ReturnType<typeof sifaQueryKeys.discovery.featured> | ReturnType<typeof sifaQueryKeys.follow.all> | ReturnType<typeof sifaQueryKeys.follow.following> | ReturnType<typeof sifaQueryKeys.stats.all> | ReturnType<typeof sifaQueryKeys.stats.homepage> | ReturnType<typeof sifaQueryKeys.apps.all> | ReturnType<typeof sifaQueryKeys.apps.registry> | ReturnType<typeof sifaQueryKeys.apps.hidden> | ReturnType<typeof sifaQueryKeys.activity.all> | ReturnType<typeof sifaQueryKeys.activity.heatmap> | ReturnType<typeof sifaQueryKeys.activity.teaser> | ReturnType<typeof sifaQueryKeys.activity.feed> | ReturnType<typeof sifaQueryKeys.endorsement.all> | ReturnType<typeof sifaQueryKeys.endorsement.count> | ReturnType<typeof sifaQueryKeys.stream.all> | ReturnType<typeof sifaQueryKeys.stream.networkCount> | ReturnType<typeof sifaQueryKeys.reactions.all> | ReturnType<typeof sifaQueryKeys.reactions.status> | ReturnType<typeof sifaQueryKeys.reactions.accountCheck> | ReturnType<typeof sifaQueryKeys.roadmap.all> | ReturnType<typeof sifaQueryKeys.roadmap.votes> | ReturnType<typeof sifaQueryKeys.roadmap.myVotes>;
|
|
1003
|
+
|
|
1004
|
+
export { type AccountCheckResult, type ActivityFeedResponse, type ActivityItem, type ActivityTeaserResponse, ApiError, type ApiFetchOptions, type AppRegistryEntry, type CheckAppAccountOptions, type CreateExternalAccountResult, type CreateResult, type DeleteAccountResult, type EndorsementInput, type ExternalAccountInput, type FeaturedProfile, type FetchActivityFeedOptions, type FetchActivityTeaserOptions, type FetchHiddenAppsOptions, type FetchMyRoadmapVotesOptions, type FetchNetworkStreamCountOptions, type FetchReactionStatusOptions, type FetchSuggestionsOptions, type FilterOptions, type FollowProfile, type FollowingResponse, type HeatmapDay, type HeatmapResponse, type HiddenApp, type ProfileIndustryInput, type ProfileLocationAddress, type ProfileLocationInput, type ProfileSearchResult, type ProfileSelfLocation, QUOTED_POSTS_BATCH_MAX, type QuotedPostAuthor, type QuotedPostImage, type QuotedPostResult, type QuotedPostView, type ReactionError, type ReactionResult, type ReactionStatus, type RefreshOrcidPublicationsResult, type RefreshPdsResult, type ResolveQuotedPostsOptions, type RoadmapVoter, type RoadmapVotesResponse, type SearchFilters, type SearchResponse, type SifaApiConfig, type SifaQueryKey, type SimilarProfile, type SkillSearchResult, type StatsResponse, type SuggestionProfile, type SuggestionsResponse, type UpdateProfileOverrideInput, type UpdateProfileSelfInput, type UploadAvatarResult, type VerifyExternalAccountResult, type WriteResult, apiFetch, apiFetchOrNull, apiWrite, apiWriteCreate, bulkHideStandardPublications, bulkUnhideStandardPublications, castRoadmapVote, checkAppAccount, createEducation, createEndorsement, createExternalAccount, createPosition, createProfileLocation, createReaction, createRecord, createSkill, deleteAccount, deleteAvatarOverride, deleteEducation, deleteExternalAccount, deletePosition, deleteProfileLocation, deleteReaction, deleteRecord, deleteSkill, fetchActivityFeed, fetchActivityTeaser, fetchAppsRegistry, fetchAtFundLink, fetchEndorsementCount, fetchExternalAccounts, fetchFeaturedProfile, fetchFollowing, fetchHeatmapData, fetchHiddenApps, fetchMyRoadmapVotes, fetchNetworkStreamCount, fetchProfile, fetchReactionStatus, fetchRoadmapVotes, fetchSearchFilters, fetchSearchProfiles, fetchSimilarProfiles, fetchSkillSuggestions, fetchStats, fetchSuggestionCount, fetchSuggestions, hideKeytraceClaim, hideOrcidPublication, hideSifaPublication, hideStandardPublication, linkSkillToPosition, refreshOrcidPublications, refreshPds, resetProfile, resolveQuotedPosts, retractRoadmapVote, searchSkills, setExternalAccountPrimary, setPositionPrimary, sifaQueryKeys, unhideKeytraceClaim, unhideOrcidPublication, unhideSifaPublication, unhideStandardPublication, unlinkSkillFromPosition, unsetExternalAccountPrimary, unsetPositionPrimary, updateEducation, updateExternalAccount, updatePosition, updateProfileLocation, updateProfileOverride, updateProfileSelf, updateRecord, updateSkill, uploadAvatar, verifyExternalAccount };
|