@singi-labs/sifa-sdk 0.18.11 → 0.18.13

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 (47) hide show
  1. package/dist/index.cjs +29 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +28 -3
  4. package/dist/index.d.ts +28 -3
  5. package/dist/index.js +28 -2
  6. package/dist/index.js.map +1 -1
  7. package/dist/{network-map-CMod-9od.d.ts → network-map-5WbfyFed.d.ts} +12 -3
  8. package/dist/{network-map-CH37aj_Q.d.cts → network-map-Cwv7SsL0.d.cts} +12 -3
  9. package/dist/{org-3gFPQ_pC.d.cts → org-BHz9ymjp.d.cts} +122 -4
  10. package/dist/{org-CTSJ5zTZ.d.ts → org-Bgz5parA.d.ts} +122 -4
  11. package/dist/{profile-investment-CmiQxk5C.d.cts → profile-investment-CIG7Hy8g.d.cts} +16 -1
  12. package/dist/{profile-investment-CmiQxk5C.d.ts → profile-investment-CIG7Hy8g.d.ts} +16 -1
  13. package/dist/publishing/index.cjs +5 -0
  14. package/dist/publishing/index.cjs.map +1 -1
  15. package/dist/publishing/index.js +5 -0
  16. package/dist/publishing/index.js.map +1 -1
  17. package/dist/query/fetchers/index.cjs +121 -5
  18. package/dist/query/fetchers/index.cjs.map +1 -1
  19. package/dist/query/fetchers/index.d.cts +3 -3
  20. package/dist/query/fetchers/index.d.ts +3 -3
  21. package/dist/query/fetchers/index.js +118 -6
  22. package/dist/query/fetchers/index.js.map +1 -1
  23. package/dist/query/hooks/index.cjs +157 -4
  24. package/dist/query/hooks/index.cjs.map +1 -1
  25. package/dist/query/hooks/index.d.cts +3 -3
  26. package/dist/query/hooks/index.d.ts +3 -3
  27. package/dist/query/hooks/index.js +155 -5
  28. package/dist/query/hooks/index.js.map +1 -1
  29. package/dist/query/index.cjs +161 -5
  30. package/dist/query/index.cjs.map +1 -1
  31. package/dist/query/index.d.cts +5 -5
  32. package/dist/query/index.d.ts +5 -5
  33. package/dist/query/index.js +155 -6
  34. package/dist/query/index.js.map +1 -1
  35. package/dist/schemas/index.cjs +6 -0
  36. package/dist/schemas/index.cjs.map +1 -1
  37. package/dist/schemas/index.d.cts +1 -1
  38. package/dist/schemas/index.d.ts +1 -1
  39. package/dist/schemas/index.js +6 -1
  40. package/dist/schemas/index.js.map +1 -1
  41. package/dist/schemas/write/index.cjs +7 -2
  42. package/dist/schemas/write/index.cjs.map +1 -1
  43. package/dist/schemas/write/index.js +7 -2
  44. package/dist/schemas/write/index.js.map +1 -1
  45. package/dist/{use-org-notification-emails-J29DcsSu.d.ts → use-org-notification-emails-C9CWyhSC.d.ts} +24 -2
  46. package/dist/{use-org-notification-emails-CdRgTAj4.d.cts → use-org-notification-emails-vNekuQKF.d.cts} +24 -2
  47. package/package.json +1 -1
@@ -161,11 +161,23 @@ var sifaQueryKeys = {
161
161
  byHandle: (handleOrDid) => ["sifa", "profile", handleOrDid],
162
162
  atFundLink: (did) => ["sifa", "profile", "at-fund-link", did],
163
163
  view: (actor) => ["sifa", "profile", "view", actor],
164
- externalAccounts: (handleOrDid) => ["sifa", "profile", "external-accounts", handleOrDid]
164
+ externalAccounts: (handleOrDid) => ["sifa", "profile", "external-accounts", handleOrDid],
165
+ // Session-scoped: the AppView reads the owner from the session cookie, so
166
+ // there is only ever one completeness result per client.
167
+ completeness: () => ["sifa", "profile", "completeness"]
165
168
  },
166
169
  position: {
167
170
  all: () => ["sifa", "position"],
168
- byOwner: (did) => ["sifa", "position", "by-owner", did]
171
+ byOwner: (did) => ["sifa", "position", "by-owner", did],
172
+ // Session-scoped: the AppView reads the owner from the session cookie.
173
+ unlinked: () => ["sifa", "position", "unlinked"]
174
+ },
175
+ // Aggregate inbox counts for the header bell badge (session-scoped). The first
176
+ // aggregate namespace: it fans in across confirmations, endorsements, drift,
177
+ // unlinked positions and profile completeness on the server.
178
+ inbox: {
179
+ all: () => ["sifa", "inbox"],
180
+ counts: () => ["sifa", "inbox", "counts"]
169
181
  },
170
182
  search: {
171
183
  all: () => ["sifa", "search"],
@@ -1207,12 +1219,16 @@ function useCreateEndorsement(endorsedHandleOrDid, options) {
1207
1219
 
1208
1220
  // src/query/fetchers/confirmations.ts
1209
1221
  async function fetchPendingConfirmations(config, options = {}) {
1222
+ const { cookieHeader, ...rest } = options;
1223
+ const headers = { ...rest.headers ?? {} };
1224
+ if (cookieHeader) headers.cookie = cookieHeader;
1210
1225
  try {
1211
1226
  const data = await apiFetch(config, "/api/confirmations/pending", {
1212
1227
  cache: "no-store",
1213
1228
  credentials: "include",
1214
1229
  timeoutMs: 5e3,
1215
- ...options
1230
+ ...rest,
1231
+ headers
1216
1232
  });
1217
1233
  return { confirmations: data?.confirmations ?? [], cursor: data?.cursor };
1218
1234
  } catch {
@@ -1220,11 +1236,14 @@ async function fetchPendingConfirmations(config, options = {}) {
1220
1236
  }
1221
1237
  }
1222
1238
  async function fetchGivenConfirmations(config, options = {}) {
1239
+ const { cookieHeader, ...rest } = options;
1240
+ const headers = { ...rest.headers ?? {} };
1241
+ if (cookieHeader) headers.cookie = cookieHeader;
1223
1242
  try {
1224
1243
  const data = await apiFetch(
1225
1244
  config,
1226
1245
  "/api/confirmations/mine",
1227
- { cache: "no-store", credentials: "include", timeoutMs: 5e3, ...options }
1246
+ { cache: "no-store", credentials: "include", timeoutMs: 5e3, ...rest, headers }
1228
1247
  );
1229
1248
  return { confirmations: data?.confirmations ?? [] };
1230
1249
  } catch {
@@ -1274,6 +1293,9 @@ function useCreateConfirmation(claimerHandleOrDid, options) {
1274
1293
  await queryClient.invalidateQueries({
1275
1294
  queryKey: sifaQueryKeys.confirmation.given()
1276
1295
  });
1296
+ await queryClient.invalidateQueries({
1297
+ queryKey: sifaQueryKeys.inbox.counts()
1298
+ });
1277
1299
  if (claimerHandleOrDid) {
1278
1300
  await queryClient.invalidateQueries({
1279
1301
  queryKey: sifaQueryKeys.profile.byHandle(claimerHandleOrDid)
@@ -1297,6 +1319,9 @@ function useDismissConfirmation(options) {
1297
1319
  await queryClient.invalidateQueries({
1298
1320
  queryKey: sifaQueryKeys.confirmation.pending()
1299
1321
  });
1322
+ await queryClient.invalidateQueries({
1323
+ queryKey: sifaQueryKeys.inbox.counts()
1324
+ });
1300
1325
  }
1301
1326
  await options?.onSuccess?.(result, variables, onMutateResult, context);
1302
1327
  }
@@ -1315,6 +1340,12 @@ function useRevokeConfirmation(claimerHandleOrDid, options) {
1315
1340
  await queryClient.invalidateQueries({
1316
1341
  queryKey: sifaQueryKeys.confirmation.pending()
1317
1342
  });
1343
+ await queryClient.invalidateQueries({
1344
+ queryKey: sifaQueryKeys.confirmation.given()
1345
+ });
1346
+ await queryClient.invalidateQueries({
1347
+ queryKey: sifaQueryKeys.inbox.counts()
1348
+ });
1318
1349
  if (claimerHandleOrDid) {
1319
1350
  await queryClient.invalidateQueries({
1320
1351
  queryKey: sifaQueryKeys.profile.byHandle(claimerHandleOrDid)
@@ -1326,6 +1357,120 @@ function useRevokeConfirmation(claimerHandleOrDid, options) {
1326
1357
  });
1327
1358
  }
1328
1359
 
1360
+ // src/query/fetchers/inbox.ts
1361
+ function toCount(value) {
1362
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.trunc(value) : 0;
1363
+ }
1364
+ async function fetchInboxCounts(config, options = {}) {
1365
+ const { cookieHeader, ...rest } = options;
1366
+ const headers = { ...rest.headers ?? {} };
1367
+ if (cookieHeader) headers.cookie = cookieHeader;
1368
+ try {
1369
+ const data = await apiFetch(config, "/api/inbox/counts", {
1370
+ cache: "no-store",
1371
+ credentials: "include",
1372
+ timeoutMs: 5e3,
1373
+ ...rest,
1374
+ headers
1375
+ });
1376
+ return {
1377
+ tasks: toCount(data?.tasks),
1378
+ unreadNotifications: toCount(data?.unreadNotifications)
1379
+ };
1380
+ } catch {
1381
+ return { tasks: 0, unreadNotifications: 0 };
1382
+ }
1383
+ }
1384
+
1385
+ // src/query/hooks/use-inbox.ts
1386
+ function useInboxCounts(options) {
1387
+ const config = useSifaConfig();
1388
+ return reactQuery.useQuery({
1389
+ queryKey: sifaQueryKeys.inbox.counts(),
1390
+ queryFn: () => fetchInboxCounts(config),
1391
+ ...options
1392
+ });
1393
+ }
1394
+
1395
+ // src/query/fetchers/unlinked-positions.ts
1396
+ async function fetchUnlinkedPositions(config, options = {}) {
1397
+ const { cookieHeader, ...rest } = options;
1398
+ const headers = { ...rest.headers ?? {} };
1399
+ if (cookieHeader) headers.cookie = cookieHeader;
1400
+ try {
1401
+ const data = await apiFetch(config, "/api/positions/unlinked", {
1402
+ cache: "no-store",
1403
+ credentials: "include",
1404
+ timeoutMs: 5e3,
1405
+ ...rest,
1406
+ headers
1407
+ });
1408
+ return { positions: Array.isArray(data?.positions) ? data.positions : [] };
1409
+ } catch {
1410
+ return { positions: [] };
1411
+ }
1412
+ }
1413
+
1414
+ // src/query/hooks/use-unlinked-positions.ts
1415
+ function useUnlinkedPositions(options) {
1416
+ const config = useSifaConfig();
1417
+ return reactQuery.useQuery({
1418
+ queryKey: sifaQueryKeys.position.unlinked(),
1419
+ queryFn: () => fetchUnlinkedPositions(config),
1420
+ ...options
1421
+ });
1422
+ }
1423
+
1424
+ // src/query/fetchers/profile-completeness.ts
1425
+ var PROFILE_COMPLETENESS_SIGNALS = [
1426
+ "headline",
1427
+ "about",
1428
+ "position",
1429
+ "education",
1430
+ "skill",
1431
+ "certification"
1432
+ ];
1433
+ async function fetchProfileCompleteness(config, options = {}) {
1434
+ const { cookieHeader, ...rest } = options;
1435
+ const headers = { ...rest.headers ?? {} };
1436
+ if (cookieHeader) headers.cookie = cookieHeader;
1437
+ const empty = {
1438
+ complete: true,
1439
+ score: PROFILE_COMPLETENESS_SIGNALS.length,
1440
+ total: PROFILE_COMPLETENESS_SIGNALS.length,
1441
+ missing: []
1442
+ };
1443
+ try {
1444
+ const data = await apiFetch(config, "/api/profile/completeness", {
1445
+ cache: "no-store",
1446
+ credentials: "include",
1447
+ timeoutMs: 5e3,
1448
+ ...rest,
1449
+ headers
1450
+ });
1451
+ if (!data) return empty;
1452
+ const missing = Array.isArray(data.missing) ? data.missing : [];
1453
+ return {
1454
+ complete: data.complete ?? missing.length === 0,
1455
+ score: data.score ?? PROFILE_COMPLETENESS_SIGNALS.length - missing.length,
1456
+ total: data.total ?? PROFILE_COMPLETENESS_SIGNALS.length,
1457
+ missing
1458
+ };
1459
+ } catch {
1460
+ return empty;
1461
+ }
1462
+ }
1463
+
1464
+ // src/query/hooks/use-profile-completeness.ts
1465
+ function useProfileCompleteness(options) {
1466
+ const config = useSifaConfig();
1467
+ return reactQuery.useQuery({
1468
+ queryKey: sifaQueryKeys.profile.completeness(),
1469
+ queryFn: () => fetchProfileCompleteness(config),
1470
+ ...options
1471
+ });
1472
+ }
1473
+
1329
1474
  // src/query/fetchers/keytrace-claims.ts
1330
1475
  function hideKeytraceClaim(config, rkey, options = {}) {
1331
1476
  return apiWrite(
@@ -3162,6 +3307,11 @@ var externalRecordRefSchema = zod.z.object({
3162
3307
  uri: atUriSchema,
3163
3308
  cid: cidSchema.optional()
3164
3309
  });
3310
+ zod.z.object({
3311
+ name: zod.z.string().min(1).refine(maxGraphemes(256)).max(2560),
3312
+ did: didSchema.optional(),
3313
+ entityRef: uriSchema.optional()
3314
+ }).passthrough();
3165
3315
  var selfLabelsSchema = zod.z.object({
3166
3316
  $type: zod.z.literal("com.atproto.label.defs#selfLabels").optional(),
3167
3317
  values: zod.z.array(zod.z.object({ val: zod.z.string() }))
@@ -3383,6 +3533,7 @@ exports.useHideProfileItem = useHideProfileItem;
3383
3533
  exports.useHideSifaPublication = useHideSifaPublication;
3384
3534
  exports.useHideStandardPublication = useHideStandardPublication;
3385
3535
  exports.useImportSearchEntities = useImportSearchEntities;
3536
+ exports.useInboxCounts = useInboxCounts;
3386
3537
  exports.useLinkSkillToPosition = useLinkSkillToPosition;
3387
3538
  exports.useMutuals = useMutuals;
3388
3539
  exports.useMyGithubPullRequests = useMyGithubPullRequests;
@@ -3394,6 +3545,7 @@ exports.useOrgDomainVerify = useOrgDomainVerify;
3394
3545
  exports.useOrgProfile = useOrgProfile;
3395
3546
  exports.usePendingConfirmations = usePendingConfirmations;
3396
3547
  exports.useProfile = useProfile;
3548
+ exports.useProfileCompleteness = useProfileCompleteness;
3397
3549
  exports.useReactionStatus = useReactionStatus;
3398
3550
  exports.useRefreshOrcidPublications = useRefreshOrcidPublications;
3399
3551
  exports.useRefreshPds = useRefreshPds;
@@ -3425,6 +3577,7 @@ exports.useUnhideProfileItem = useUnhideProfileItem;
3425
3577
  exports.useUnhideSifaPublication = useUnhideSifaPublication;
3426
3578
  exports.useUnhideStandardPublication = useUnhideStandardPublication;
3427
3579
  exports.useUnlinkSkillFromPosition = useUnlinkSkillFromPosition;
3580
+ exports.useUnlinkedPositions = useUnlinkedPositions;
3428
3581
  exports.useUnrevealMarqueDomain = useUnrevealMarqueDomain;
3429
3582
  exports.useUnsetExternalAccountPrimary = useUnsetExternalAccountPrimary;
3430
3583
  exports.useUnsetPositionPrimary = useUnsetPositionPrimary;