@odla-ai/chapter 0.47.3 → 0.47.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.
@@ -6993,6 +6993,9 @@ async function networkSourceKey(sourceSystem, sourceRecordId) {
6993
6993
  async function networkChapterLinkId(personId, chapterId, chapterPersonId) {
6994
6994
  return `chapter_person_${await sha256(`${personId}\0${chapterId}\0${chapterPersonId}`)}`;
6995
6995
  }
6996
+ async function networkChapterPersonSourceKey(chapterId, chapterPersonId) {
6997
+ return `chapter_source_${await sha256(`${chapterId}\0${chapterPersonId}`)}`;
6998
+ }
6996
6999
  function projectNetworkContactPolicy(policy, links) {
6997
7000
  return links.map((link) => ({ ...link, contactPolicy: { ...policy } }));
6998
7001
  }
@@ -7254,10 +7257,11 @@ var MUTATION_ID4 = /^[A-Za-z0-9_-]{16,128}$/;
7254
7257
  function redactedName(displayName) {
7255
7258
  return displayName.split(/\s+/).filter(Boolean).map((part) => `${part[0]?.toUpperCase() ?? ""}\u2026`).join(" ");
7256
7259
  }
7257
- var redactedLink = (link) => ({
7260
+ var redactedLink = async (link) => ({
7258
7261
  id: link.id,
7259
7262
  personId: link.personId,
7260
7263
  chapterId: link.chapterId,
7264
+ sourceKey: await networkChapterPersonSourceKey(link.chapterId, link.chapterPersonId),
7261
7265
  state: link.state,
7262
7266
  createdAt: link.createdAt
7263
7267
  });
@@ -7421,8 +7425,9 @@ var handleAdminNetworkPersonRegistry = async (req, url, env, ctx) => {
7421
7425
  }
7422
7426
  }
7423
7427
  const state = await loadNetworkPersonRegistry(db);
7424
- const persons = state.persons.map((person) => {
7428
+ const persons = await Promise.all(state.persons.map(async (person) => {
7425
7429
  const links = state.links.filter((link) => link.personId === person.id);
7430
+ const safeLinks = await Promise.all(links.map(redactedLink));
7426
7431
  const canonicalId = canonicalNetworkPersonId(person.id, state.persons);
7427
7432
  const canonical2 = state.persons.find((candidate) => candidate.id === canonicalId) ?? person;
7428
7433
  return {
@@ -7434,16 +7439,20 @@ var handleAdminNetworkPersonRegistry = async (req, url, env, ctx) => {
7434
7439
  revision: person.revision,
7435
7440
  contactPolicy: safePolicy(person.contactPolicy),
7436
7441
  identityClaims: state.claims.filter((claim) => claim.personId === person.id).map(({ id, kind, hint, verifiedAt }) => ({ id, kind, hint: hint ?? null, verifiedAt })),
7437
- chapterLinks: links.map(redactedLink),
7438
- chapterProjections: projectNetworkContactPolicy(canonical2.contactPolicy, links.map(redactedLink)).map(({ contactPolicy, ...projection }) => ({ ...projection, contactPolicy: safePolicy(contactPolicy) }))
7442
+ chapterLinks: safeLinks,
7443
+ chapterProjections: projectNetworkContactPolicy(canonical2.contactPolicy, safeLinks).map(({ contactPolicy, ...projection }) => ({ ...projection, contactPolicy: safePolicy(contactPolicy) }))
7439
7444
  };
7440
- });
7445
+ }));
7441
7446
  const aliases = state.aliases.map(safeAlias);
7442
7447
  return json({
7443
7448
  version: 1,
7444
7449
  mode: "shadow",
7445
7450
  writable: true,
7446
7451
  authoritativeForChapterOperation: false,
7452
+ // loadNetworkPersonRegistry deliberately bounds each collection at 1,000.
7453
+ // Exactly 1,000 links may mean there are more, so fail closed rather than
7454
+ // letting a consumer mistake an omitted explicit link for "source only".
7455
+ chapterLinkProjectionComplete: state.links.length < 1e3,
7447
7456
  configuredChapterIds: ctx.chapter.networkPersonRegistry.chapterIds,
7448
7457
  persons,
7449
7458
  aliases,