@odla-ai/chapter 0.42.3 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -32,16 +32,25 @@ __export(index_exports, {
32
32
  DEFAULT_CHAPTER_COPY: () => DEFAULT_CHAPTER_COPY,
33
33
  DEFAULT_SHARE_FIELDS: () => DEFAULT_SHARE_FIELDS,
34
34
  GIFT_OFFER_CATALOG_VERSION: () => GIFT_OFFER_CATALOG_VERSION,
35
+ JOURNEY_ENDINGS: () => JOURNEY_ENDINGS,
36
+ JOURNEY_STAGES: () => JOURNEY_STAGES,
35
37
  MAX_GIFT_OFFERS: () => MAX_GIFT_OFFERS,
36
38
  MEMBERSHIP_PAGE_RENDERER: () => MEMBERSHIP_PAGE_RENDERER,
37
39
  MEMBER_CONTENT_CONTROL_PATH: () => MEMBER_CONTENT_CONTROL_PATH,
38
40
  MEMBER_CONTENT_PATH: () => MEMBER_CONTENT_PATH,
39
41
  MEMBER_CONTENT_SCHEMA_VERSION: () => MEMBER_CONTENT_SCHEMA_VERSION,
42
+ MEMBER_SELF_EDITABLE_FIELDS: () => MEMBER_SELF_EDITABLE_FIELDS,
43
+ MEMBER_SELF_READABLE_FIELDS: () => MEMBER_SELF_READABLE_FIELDS,
44
+ MEMBER_SYSTEM_AUTHORITY_MATRIX: () => MEMBER_SYSTEM_AUTHORITY_MATRIX,
45
+ MEMBER_SYSTEM_CONTRACT_VERSION: () => MEMBER_SYSTEM_CONTRACT_VERSION,
46
+ MEMBER_SYSTEM_RECOVERY_OBJECTIVES: () => MEMBER_SYSTEM_RECOVERY_OBJECTIVES,
47
+ REQUIRED_NOTICE_KINDS: () => REQUIRED_NOTICE_KINDS,
40
48
  SCHEDULING_DEFAULTS: () => SCHEDULING_DEFAULTS,
41
49
  SIGNUP_CONTROL_PATH: () => SIGNUP_CONTROL_PATH,
42
50
  SIGNUP_CONTROL_SCHEMA_VERSION: () => SIGNUP_CONTROL_SCHEMA_VERSION,
43
51
  SIGNUP_CONTROL_THEME_MARKER: () => SIGNUP_CONTROL_THEME_MARKER,
44
52
  SIGNUP_CONTROL_THEME_STYLE_ID: () => SIGNUP_CONTROL_THEME_STYLE_ID,
53
+ SILVER_SALT_P0_FIXTURE: () => SILVER_SALT_P0_FIXTURE,
45
54
  applicantProfile: () => applicantProfile,
46
55
  applicationBookingUpdate: () => applicationBookingUpdate,
47
56
  applicationFlowFields: () => applicationFlowFields,
@@ -68,6 +77,8 @@ __export(index_exports, {
68
77
  chapterDb: () => chapterDb,
69
78
  chapterFlowFieldContract: () => chapterFlowFieldContract,
70
79
  clampArray: () => clampArray,
80
+ classifyMemberStripeEvent: () => classifyMemberStripeEvent,
81
+ classifyMemberSystemWrite: () => classifyMemberSystemWrite,
71
82
  clerkGetUser: () => clerkGetUser,
72
83
  clerkGetUserByEmail: () => clerkGetUserByEmail,
73
84
  clerkIntegration: () => clerkIntegration,
@@ -121,6 +132,8 @@ __export(index_exports, {
121
132
  memberContentDigest: () => memberContentDigest,
122
133
  memberContentDocument: () => memberContentDocument,
123
134
  memberSession: () => memberSession,
135
+ memberSystemAvailability: () => memberSystemAvailability,
136
+ memberSystemRollbackPlan: () => memberSystemRollbackPlan,
124
137
  membershipPageDocument: () => membershipPageDocument,
125
138
  membershipTierPresentationFromMarkdown: () => membershipTierPresentationFromMarkdown,
126
139
  networkSourceTag: () => networkSourceTag,
@@ -132,9 +145,12 @@ __export(index_exports, {
132
145
  paymentsReady: () => paymentsReady,
133
146
  personInputFromApp: () => personInputFromApp,
134
147
  planDelivery: () => planDelivery,
148
+ planMemberSystemEventReplay: () => planMemberSystemEventReplay,
149
+ planMemberSystemMigration: () => planMemberSystemMigration,
135
150
  projectApplicant: () => projectApplicant,
136
151
  projectBuilderLibraryDelivery: () => projectBuilderLibraryDelivery,
137
152
  projectMemberContent: () => projectMemberContent,
153
+ projectMemberSelf: () => projectMemberSelf,
138
154
  projectSharedRecord: () => projectSharedRecord,
139
155
  promoteBuilderLibraryResource: () => promoteBuilderLibraryResource,
140
156
  publicGiftOffers: () => publicGiftOffers,
@@ -177,6 +193,7 @@ __export(index_exports, {
177
193
  validateBuilderLibraryDocument: () => validateBuilderLibraryDocument,
178
194
  validateGiftOfferCatalog: () => validateGiftOfferCatalog,
179
195
  validateMemberContentDocument: () => validateMemberContentDocument,
196
+ validateMemberSystemAuthority: () => validateMemberSystemAuthority,
180
197
  validateMembershipPageDocument: () => validateMembershipPageDocument,
181
198
  validateScheduling: () => validateScheduling,
182
199
  validateSignupControlDocument: () => validateSignupControlDocument,
@@ -629,8 +646,32 @@ var giftRedemptionAttemptsEntity = { attrs: {
629
646
  updatedAt: attr3("number")
630
647
  } };
631
648
 
649
+ // src/schema-stripe.ts
650
+ var attr4 = (type, flags = {}) => ({
651
+ type,
652
+ unique: flags.unique ?? false,
653
+ indexed: flags.indexed ?? false,
654
+ optional: flags.optional ?? false
655
+ });
656
+ var stripeEventReceiptsEntity = {
657
+ attrs: {
658
+ id: attr4("string", { unique: true, indexed: true }),
659
+ eventId: attr4("string", { unique: true, indexed: true }),
660
+ digest: attr4("string", { indexed: true }),
661
+ disposition: attr4("string", { indexed: true }),
662
+ kind: attr4("string", { indexed: true }),
663
+ matched: attr4("boolean", { indexed: true }),
664
+ appId: attr4("string", { indexed: true, optional: true }),
665
+ environment: attr4("string", { indexed: true, optional: true }),
666
+ dataEnvironment: attr4("string", { indexed: true, optional: true }),
667
+ runtime: attr4("string", { indexed: true, optional: true }),
668
+ chapterId: attr4("string", { indexed: true, optional: true }),
669
+ receivedAt: attr4("number", { indexed: true })
670
+ }
671
+ };
672
+
632
673
  // src/schema.ts
633
- function attr4(type, flags = {}) {
674
+ function attr5(type, flags = {}) {
634
675
  return {
635
676
  type,
636
677
  unique: flags.unique ?? false,
@@ -638,167 +679,167 @@ function attr4(type, flags = {}) {
638
679
  optional: flags.optional ?? false
639
680
  };
640
681
  }
641
- var id3 = () => attr4("string", { unique: true, indexed: true });
682
+ var id3 = () => attr5("string", { unique: true, indexed: true });
642
683
  var admins = {
643
684
  attrs: {
644
685
  id: id3(),
645
- email: attr4("string", { unique: true, indexed: true }),
646
- name: attr4("string", { optional: true }),
647
- note: attr4("string", { optional: true })
686
+ email: attr5("string", { unique: true, indexed: true }),
687
+ name: attr5("string", { optional: true }),
688
+ note: attr5("string", { optional: true })
648
689
  }
649
690
  };
650
691
  var superAdmins = {
651
692
  attrs: {
652
693
  id: id3(),
653
- email: attr4("string", { unique: true, indexed: true }),
654
- note: attr4("string", { optional: true }),
655
- createdAt: attr4("number", { indexed: true })
694
+ email: attr5("string", { unique: true, indexed: true }),
695
+ note: attr5("string", { optional: true }),
696
+ createdAt: attr5("number", { indexed: true })
656
697
  }
657
698
  };
658
699
  var networkNotes = {
659
700
  attrs: {
660
701
  id: id3(),
661
- recordKey: attr4("string", { indexed: true }),
662
- targetId: attr4("string", { indexed: true }),
663
- recordType: attr4("string", { indexed: true }),
664
- recordId: attr4("string", { indexed: true }),
665
- body: attr4("string"),
666
- authorId: attr4("string", { indexed: true }),
667
- authorEmail: attr4("string", { optional: true }),
668
- createdAt: attr4("number", { indexed: true })
702
+ recordKey: attr5("string", { indexed: true }),
703
+ targetId: attr5("string", { indexed: true }),
704
+ recordType: attr5("string", { indexed: true }),
705
+ recordId: attr5("string", { indexed: true }),
706
+ body: attr5("string"),
707
+ authorId: attr5("string", { indexed: true }),
708
+ authorEmail: attr5("string", { optional: true }),
709
+ createdAt: attr5("number", { indexed: true })
669
710
  }
670
711
  };
671
712
  var signupControls = {
672
713
  attrs: {
673
714
  id: id3(),
674
- sourceId: attr4("string", { indexed: true }),
675
- targetId: attr4("string", { indexed: true }),
676
- environment: attr4("string", { indexed: true }),
677
- revision: attr4("number", { indexed: true }),
678
- digest: attr4("string", { indexed: true }),
679
- document: attr4("json"),
680
- active: attr4("boolean", { indexed: true }),
681
- receivedAt: attr4("number", { indexed: true })
715
+ sourceId: attr5("string", { indexed: true }),
716
+ targetId: attr5("string", { indexed: true }),
717
+ environment: attr5("string", { indexed: true }),
718
+ revision: attr5("number", { indexed: true }),
719
+ digest: attr5("string", { indexed: true }),
720
+ document: attr5("json"),
721
+ active: attr5("boolean", { indexed: true }),
722
+ receivedAt: attr5("number", { indexed: true })
682
723
  }
683
724
  };
684
725
  var memberContentControls = {
685
726
  attrs: {
686
727
  id: id3(),
687
- sourceId: attr4("string", { indexed: true }),
688
- targetId: attr4("string", { indexed: true }),
689
- environment: attr4("string", { indexed: true }),
690
- revision: attr4("number", { indexed: true }),
691
- digest: attr4("string", { indexed: true }),
692
- document: attr4("json"),
693
- active: attr4("boolean", { indexed: true }),
694
- receivedAt: attr4("number", { indexed: true })
728
+ sourceId: attr5("string", { indexed: true }),
729
+ targetId: attr5("string", { indexed: true }),
730
+ environment: attr5("string", { indexed: true }),
731
+ revision: attr5("number", { indexed: true }),
732
+ digest: attr5("string", { indexed: true }),
733
+ document: attr5("json"),
734
+ active: attr5("boolean", { indexed: true }),
735
+ receivedAt: attr5("number", { indexed: true })
695
736
  }
696
737
  };
697
738
  var memberContentLocal = {
698
739
  attrs: {
699
740
  id: id3(),
700
- chapterId: attr4("string", { indexed: true }),
701
- environment: attr4("string", { indexed: true }),
702
- revision: attr4("number", { indexed: true }),
703
- document: attr4("json"),
704
- updatedAt: attr4("number", { indexed: true }),
705
- updatedBy: attr4("string", { optional: true })
741
+ chapterId: attr5("string", { indexed: true }),
742
+ environment: attr5("string", { indexed: true }),
743
+ revision: attr5("number", { indexed: true }),
744
+ document: attr5("json"),
745
+ updatedAt: attr5("number", { indexed: true }),
746
+ updatedBy: attr5("string", { optional: true })
706
747
  }
707
748
  };
708
749
  var builderLibraryControls = {
709
750
  attrs: {
710
751
  id: id3(),
711
- sourceId: attr4("string", { indexed: true }),
712
- targetId: attr4("string", { indexed: true }),
713
- environment: attr4("string", { indexed: true }),
714
- revision: attr4("number", { indexed: true }),
715
- digest: attr4("string", { indexed: true }),
716
- document: attr4("json"),
717
- active: attr4("boolean", { indexed: true }),
718
- receivedAt: attr4("number", { indexed: true })
752
+ sourceId: attr5("string", { indexed: true }),
753
+ targetId: attr5("string", { indexed: true }),
754
+ environment: attr5("string", { indexed: true }),
755
+ revision: attr5("number", { indexed: true }),
756
+ digest: attr5("string", { indexed: true }),
757
+ document: attr5("json"),
758
+ active: attr5("boolean", { indexed: true }),
759
+ receivedAt: attr5("number", { indexed: true })
719
760
  }
720
761
  };
721
762
  var builderLibraryLocal = {
722
763
  attrs: {
723
764
  id: id3(),
724
- appId: attr4("string", { indexed: true }),
725
- environment: attr4("string", { indexed: true }),
726
- revision: attr4("number", { indexed: true }),
727
- document: attr4("json"),
728
- updatedAt: attr4("number", { indexed: true }),
729
- updatedBy: attr4("string", { optional: true })
765
+ appId: attr5("string", { indexed: true }),
766
+ environment: attr5("string", { indexed: true }),
767
+ revision: attr5("number", { indexed: true }),
768
+ document: attr5("json"),
769
+ updatedAt: attr5("number", { indexed: true }),
770
+ updatedBy: attr5("string", { optional: true })
730
771
  }
731
772
  };
732
773
  var groups = {
733
774
  attrs: {
734
775
  id: id3(),
735
- name: attr4("string"),
736
- standardPriceCents: attr4("number"),
737
- foundingDiscountCents: attr4("number"),
738
- stripePriceId: attr4("string", { optional: true }),
739
- stripePublishableKey: attr4("string", { optional: true }),
740
- notificationEmail: attr4("string"),
741
- replyTo: attr4("string"),
742
- debugEmail: attr4("string", { optional: true }),
743
- calendarLink: attr4("string", { optional: true }),
744
- disclaimerText: attr4("string"),
745
- refundPolicyText: attr4("string"),
746
- merchantDisclosureText: attr4("string", { optional: true }),
747
- trustCopy: attr4("string"),
748
- commitmentText: attr4("string", { optional: true }),
749
- normsText: attr4("string", { optional: true }),
750
- emailTemplates: attr4("json"),
751
- schedulingJson: attr4("json", { optional: true }),
752
- createdAt: attr4("number", { indexed: true })
776
+ name: attr5("string"),
777
+ standardPriceCents: attr5("number"),
778
+ foundingDiscountCents: attr5("number"),
779
+ stripePriceId: attr5("string", { optional: true }),
780
+ stripePublishableKey: attr5("string", { optional: true }),
781
+ notificationEmail: attr5("string"),
782
+ replyTo: attr5("string"),
783
+ debugEmail: attr5("string", { optional: true }),
784
+ calendarLink: attr5("string", { optional: true }),
785
+ disclaimerText: attr5("string"),
786
+ refundPolicyText: attr5("string"),
787
+ merchantDisclosureText: attr5("string", { optional: true }),
788
+ trustCopy: attr5("string"),
789
+ commitmentText: attr5("string", { optional: true }),
790
+ normsText: attr5("string", { optional: true }),
791
+ emailTemplates: attr5("json"),
792
+ schedulingJson: attr5("json", { optional: true }),
793
+ createdAt: attr5("number", { indexed: true })
753
794
  }
754
795
  };
755
796
  var tiers = {
756
797
  attrs: {
757
798
  id: id3(),
758
- groupId: attr4("string", { indexed: true }),
759
- name: attr4("string"),
760
- priceCents: attr4("number"),
761
- stripePriceId: attr4("string", { optional: true }),
762
- blurb: attr4("string", { optional: true }),
763
- sortOrder: attr4("number", { indexed: true }),
764
- active: attr4("boolean", { indexed: true }),
765
- createdAt: attr4("number", { indexed: true })
799
+ groupId: attr5("string", { indexed: true }),
800
+ name: attr5("string"),
801
+ priceCents: attr5("number"),
802
+ stripePriceId: attr5("string", { optional: true }),
803
+ blurb: attr5("string", { optional: true }),
804
+ sortOrder: attr5("number", { indexed: true }),
805
+ active: attr5("boolean", { indexed: true }),
806
+ createdAt: attr5("number", { indexed: true })
766
807
  }
767
808
  };
768
809
  var meetings = {
769
810
  attrs: {
770
811
  id: id3(),
771
- applicationId: attr4("string", { indexed: true }),
772
- groupId: attr4("string", { indexed: true }),
773
- startAt: attr4("number", { indexed: true }),
774
- endAt: attr4("number"),
775
- timezone: attr4("string"),
776
- status: attr4("string", { indexed: true }),
777
- googleEventId: attr4("string", { indexed: true, optional: true }),
778
- meetUrl: attr4("string", { optional: true }),
779
- htmlLink: attr4("string", { optional: true }),
780
- drift: attr4("string", { indexed: true, optional: true }),
781
- driftGoogleStartAt: attr4("number", { optional: true }),
782
- driftDetectedAt: attr4("number", { optional: true }),
783
- adoptedFromGoogleAt: attr4("number", { optional: true }),
784
- createdAt: attr4("number", { indexed: true })
812
+ applicationId: attr5("string", { indexed: true }),
813
+ groupId: attr5("string", { indexed: true }),
814
+ startAt: attr5("number", { indexed: true }),
815
+ endAt: attr5("number"),
816
+ timezone: attr5("string"),
817
+ status: attr5("string", { indexed: true }),
818
+ googleEventId: attr5("string", { indexed: true, optional: true }),
819
+ meetUrl: attr5("string", { optional: true }),
820
+ htmlLink: attr5("string", { optional: true }),
821
+ drift: attr5("string", { indexed: true, optional: true }),
822
+ driftGoogleStartAt: attr5("number", { optional: true }),
823
+ driftDetectedAt: attr5("number", { optional: true }),
824
+ adoptedFromGoogleAt: attr5("number", { optional: true }),
825
+ createdAt: attr5("number", { indexed: true })
785
826
  }
786
827
  };
787
828
  var emailLog = {
788
829
  attrs: {
789
830
  id: id3(),
790
- groupId: attr4("string", { indexed: true }),
791
- applicationId: attr4("string", { indexed: true, optional: true }),
792
- to: attr4("string", { indexed: true }),
793
- template: attr4("string", { indexed: true }),
794
- subject: attr4("string"),
795
- body: attr4("string", { optional: true }),
796
- transport: attr4("string"),
797
- messageId: attr4("string", { optional: true }),
798
- redirected: attr4("boolean", { optional: true }),
799
- dedupeKey: attr4("string", { indexed: true, optional: true }),
800
- error: attr4("string", { optional: true }),
801
- sentAt: attr4("number", { indexed: true })
831
+ groupId: attr5("string", { indexed: true }),
832
+ applicationId: attr5("string", { indexed: true, optional: true }),
833
+ to: attr5("string", { indexed: true }),
834
+ template: attr5("string", { indexed: true }),
835
+ subject: attr5("string"),
836
+ body: attr5("string", { optional: true }),
837
+ transport: attr5("string"),
838
+ messageId: attr5("string", { optional: true }),
839
+ redirected: attr5("boolean", { optional: true }),
840
+ dedupeKey: attr5("string", { indexed: true, optional: true }),
841
+ error: attr5("string", { optional: true }),
842
+ sentAt: attr5("number", { indexed: true })
802
843
  }
803
844
  };
804
845
  function chapterDb(mode, auth, includeNetworkNotes = false, application = resolveApplication(void 0), includeSignupControl = false, includeMemberContent = false, includeBuilderLibrary = false, includeLeaderAdmissions = false) {
@@ -809,6 +850,7 @@ function chapterDb(mode, auth, includeNetworkNotes = false, application = resolv
809
850
  entities.tiers = tiers;
810
851
  entities.meetings = meetings;
811
852
  entities.emailLog = emailLog;
853
+ entities.stripeEventReceipts = stripeEventReceiptsEntity;
812
854
  entities.admissionGrants = admissionGrantsEntity;
813
855
  entities.admissionGrantRevisions = admissionGrantRevisionsEntity;
814
856
  entities.giftPurchaseIntents = giftPurchaseIntentsEntity;
@@ -2219,8 +2261,8 @@ function tierPayable(tier, group, hasSecretKey) {
2219
2261
  function byOrder(a, b) {
2220
2262
  return a.sortOrder - b.sortOrder || a.id.localeCompare(b.id);
2221
2263
  }
2222
- function resolveTiers(group, rows2 = []) {
2223
- const stored = rows2.filter((tier) => tier.active);
2264
+ function resolveTiers(group, rows3 = []) {
2265
+ const stored = rows3.filter((tier) => tier.active);
2224
2266
  if (stored.length) return [...stored].sort(byOrder);
2225
2267
  return [{
2226
2268
  id: "standard",
@@ -3008,6 +3050,7 @@ function findApplicationRef(obj) {
3008
3050
  const environment = candidates.map((metadata) => typeof metadata.odlaEnvironment === "string" ? metadata.odlaEnvironment : void 0).find(Boolean);
3009
3051
  const dataEnvironment = candidates.map((metadata) => typeof metadata.odlaDataEnvironment === "string" ? metadata.odlaDataEnvironment : void 0).find(Boolean);
3010
3052
  const runtime = candidates.map((metadata) => typeof metadata.odlaRuntime === "string" ? metadata.odlaRuntime : void 0).find(Boolean);
3053
+ const chapterId = candidates.map((metadata) => typeof metadata.chapterId === "string" ? metadata.chapterId : void 0).find(Boolean);
3011
3054
  const customerId = typeof obj.customer === "string" ? obj.customer : void 0;
3012
3055
  return {
3013
3056
  ...applicationId ? { applicationId } : {},
@@ -3015,7 +3058,8 @@ function findApplicationRef(obj) {
3015
3058
  ...appId ? { appId } : {},
3016
3059
  ...environment ? { environment } : {},
3017
3060
  ...dataEnvironment ? { dataEnvironment } : {},
3018
- ...runtime ? { runtime } : {}
3061
+ ...runtime ? { runtime } : {},
3062
+ ...chapterId ? { chapterId } : {}
3019
3063
  };
3020
3064
  }
3021
3065
  function findGiftRef(obj) {
@@ -3031,13 +3075,15 @@ function findGiftRef(obj) {
3031
3075
  const environment = pickIdentity("odlaEnvironment");
3032
3076
  const dataEnvironment = pickIdentity("odlaDataEnvironment");
3033
3077
  const runtime = pickIdentity("odlaRuntime");
3078
+ const chapterId = pickIdentity("chapterId");
3034
3079
  return {
3035
3080
  ...giftIntentId ? { giftIntentId } : {},
3036
3081
  providerObjectId: subscriptionId ?? String(obj.id ?? ""),
3037
3082
  ...appId ? { appId } : {},
3038
3083
  ...environment ? { environment } : {},
3039
3084
  ...dataEnvironment ? { dataEnvironment } : {},
3040
- ...runtime ? { runtime } : {}
3085
+ ...runtime ? { runtime } : {},
3086
+ ...chapterId ? { chapterId } : {}
3041
3087
  };
3042
3088
  }
3043
3089
  function normalizeWebhookEvent(event) {
@@ -4248,15 +4294,15 @@ function rowToTier(row, groupId) {
4248
4294
  }
4249
4295
  async function loadTiers(db, group) {
4250
4296
  const groupId = String(group.id ?? "");
4251
- let rows2;
4297
+ let rows3;
4252
4298
  try {
4253
- rows2 = (await db.query({
4299
+ rows3 = (await db.query({
4254
4300
  tiers: { $: { where: { groupId }, order: { sortOrder: "asc" }, limit: 100 } }
4255
4301
  })).tiers;
4256
4302
  } catch {
4257
- rows2 = void 0;
4303
+ rows3 = void 0;
4258
4304
  }
4259
- const list = Array.isArray(rows2) ? rows2.map((row) => rowToTier(row, groupId)) : [];
4305
+ const list = Array.isArray(rows3) ? rows3.map((row) => rowToTier(row, groupId)) : [];
4260
4306
  return resolveTiers(group, list);
4261
4307
  }
4262
4308
  async function loadOfferableTiers(db, group, hasSecretKey) {
@@ -4954,4 +5000,446 @@ async function exportChapterPromotion(input) {
4954
5000
  ]
4955
5001
  };
4956
5002
  }
5003
+
5004
+ // src/member-system-authority.ts
5005
+ var rows2 = (group) => group.fields.map((id4) => ({ ...group, id: id4 }));
5006
+ var MEMBER_SYSTEM_AUTHORITY_MATRIX = [
5007
+ ...rows2({
5008
+ scope: "network",
5009
+ writer: "network_person",
5010
+ projections: ["bnf_admin", "chapter_admin", "member_self_service"],
5011
+ sensitivity: "pii",
5012
+ memberAccess: "edit",
5013
+ fields: [
5014
+ "person.legalName",
5015
+ "person.preferredName",
5016
+ "person.namePronunciation",
5017
+ "person.pronouns",
5018
+ "person.displayLegalName",
5019
+ "person.primaryEmail",
5020
+ "person.secondaryEmails",
5021
+ "person.phone",
5022
+ "person.linkedinUrl",
5023
+ "person.photo",
5024
+ "person.homeAddress",
5025
+ "person.fulfillmentFit",
5026
+ "person.fulfillmentSize"
5027
+ ]
5028
+ }),
5029
+ ...rows2({
5030
+ scope: "network",
5031
+ writer: "network_person",
5032
+ projections: ["bnf_admin", "chapter_admin", "member_self_service"],
5033
+ sensitivity: "ordinary",
5034
+ memberAccess: "edit",
5035
+ fields: [
5036
+ "person.title",
5037
+ "person.company",
5038
+ "person.companyObservedAt",
5039
+ "person.region",
5040
+ "person.whyText",
5041
+ "person.whyTokens",
5042
+ "person.skillsOffered",
5043
+ "person.openToRequests",
5044
+ "person.directoryPhotoConsent"
5045
+ ]
5046
+ }),
5047
+ ...rows2({
5048
+ scope: "network",
5049
+ writer: "network_person",
5050
+ projections: ["bnf_admin", "chapter_admin"],
5051
+ sensitivity: "restricted",
5052
+ memberAccess: "none",
5053
+ fields: [
5054
+ "person.linkedinMemberId",
5055
+ "person.identityClaims",
5056
+ "person.aliases",
5057
+ "person.mergeHistory",
5058
+ "person.introducedByPersonId",
5059
+ "person.introducedAt",
5060
+ "person.firstTouch",
5061
+ "person.globalSuppression",
5062
+ "person.deceasedAt",
5063
+ "person.archivedAt"
5064
+ ]
5065
+ }),
5066
+ ...rows2({
5067
+ scope: "network",
5068
+ writer: "network_person",
5069
+ projections: ["bnf_admin", "chapter_admin", "member_self_service"],
5070
+ sensitivity: "sensitive",
5071
+ memberAccess: "edit",
5072
+ fields: ["person.accreditationSelfCertification", "person.accreditationCategory", "person.accreditationExpiresAt"]
5073
+ }),
5074
+ ...rows2({
5075
+ scope: "network",
5076
+ writer: "network_person",
5077
+ projections: ["bnf_admin", "chapter_admin", "member_self_service"],
5078
+ sensitivity: "restricted",
5079
+ memberAccess: "read",
5080
+ fields: ["person.acknowledgements"]
5081
+ }),
5082
+ ...rows2({
5083
+ scope: "provider",
5084
+ writer: "clerk",
5085
+ projections: ["clerk_identity", "bnf_admin", "chapter_admin"],
5086
+ sensitivity: "restricted",
5087
+ memberAccess: "none",
5088
+ fields: ["identity.clerkUserIds", "identity.clerkEmailVerification"]
5089
+ }),
5090
+ ...rows2({
5091
+ scope: "chapter",
5092
+ writer: "chapter_journey",
5093
+ projections: ["chapter_admin", "chapter_crm", "bnf_admin"],
5094
+ sensitivity: "ordinary",
5095
+ memberAccess: "none",
5096
+ fields: [
5097
+ "journey.chapterId",
5098
+ "journey.stage",
5099
+ "journey.stageEnteredAt",
5100
+ "journey.stageHistory",
5101
+ "journey.ending",
5102
+ "journey.endingReason",
5103
+ "journey.source",
5104
+ "journey.entryChapterId",
5105
+ "journey.route",
5106
+ "journey.flags",
5107
+ "journey.applicationStartedAt",
5108
+ "journey.appliedAt",
5109
+ "journey.paidAt",
5110
+ "journey.callBookedAt",
5111
+ "journey.metAt",
5112
+ "journey.approvedAt",
5113
+ "journey.onboardedAt",
5114
+ "journey.firstLoginAt",
5115
+ "journey.firstDealAt"
5116
+ ]
5117
+ }),
5118
+ ...rows2({
5119
+ scope: "chapter",
5120
+ writer: "chapter_journey",
5121
+ projections: ["chapter_admin", "chapter_crm"],
5122
+ sensitivity: "sensitive",
5123
+ memberAccess: "none",
5124
+ fields: [
5125
+ "journey.relationshipOwnerId",
5126
+ "journey.lastContactAt",
5127
+ "journey.nextAction",
5128
+ "journey.owes",
5129
+ "journey.asks",
5130
+ "journey.preparation",
5131
+ "journey.notes"
5132
+ ]
5133
+ }),
5134
+ ...rows2({
5135
+ scope: "chapter",
5136
+ writer: "chapter_journey",
5137
+ projections: ["chapter_admin", "chapter_crm", "member_self_service"],
5138
+ sensitivity: "ordinary",
5139
+ memberAccess: "edit",
5140
+ fields: ["journey.dealFlowConsent", "journey.directoryConsent", "journey.emailConsent", "journey.smsConsent"]
5141
+ }),
5142
+ ...rows2({
5143
+ scope: "chapter",
5144
+ writer: "chapter_journey",
5145
+ projections: ["chapter_admin", "bnf_admin", "member_self_service"],
5146
+ sensitivity: "ordinary",
5147
+ memberAccess: "read",
5148
+ fields: ["journey.memberNumber"]
5149
+ }),
5150
+ ...rows2({
5151
+ scope: "network",
5152
+ writer: "network_membership",
5153
+ projections: ["bnf_admin", "chapter_admin", "member_self_service"],
5154
+ sensitivity: "ordinary",
5155
+ memberAccess: "read",
5156
+ fields: [
5157
+ "membership.chapterId",
5158
+ "membership.journeyId",
5159
+ "membership.termStartsAt",
5160
+ "membership.termEndsAt",
5161
+ "membership.tier",
5162
+ "membership.status",
5163
+ "membership.joinedAt",
5164
+ "membership.autoRenews",
5165
+ "membership.renewalAt",
5166
+ "membership.cancelsAt",
5167
+ "membership.graceEndsAt",
5168
+ "membership.foundingCohort",
5169
+ "membership.offeringPolicyVersion",
5170
+ "membership.discountPolicyVersion"
5171
+ ]
5172
+ }),
5173
+ ...rows2({
5174
+ scope: "network",
5175
+ writer: "network_commercial_projection",
5176
+ projections: ["bnf_admin", "chapter_admin"],
5177
+ sensitivity: "restricted",
5178
+ memberAccess: "none",
5179
+ fields: [
5180
+ "membership.stripeCustomerId",
5181
+ "membership.stripeSubscriptionId",
5182
+ "membership.stripePriceId",
5183
+ "membership.lastInvoiceId",
5184
+ "membership.paymentOutcome",
5185
+ "membership.refundOutcome"
5186
+ ]
5187
+ }),
5188
+ ...rows2({
5189
+ scope: "network",
5190
+ writer: "network_discount_policy",
5191
+ projections: ["bnf_admin", "chapter_admin", "stripe_billing"],
5192
+ sensitivity: "ordinary",
5193
+ memberAccess: "none",
5194
+ fields: [
5195
+ "discountPolicy.chapterId",
5196
+ "discountPolicy.version",
5197
+ "discountPolicy.eligibleOfferingIds",
5198
+ "discountPolicy.percentOff",
5199
+ "discountPolicy.amountOff",
5200
+ "discountPolicy.activatesOn",
5201
+ "discountPolicy.invoiceCount",
5202
+ "discountPolicy.expiresAt",
5203
+ "discountPolicy.stackingOrder",
5204
+ "discountPolicy.status"
5205
+ ]
5206
+ }),
5207
+ ...rows2({
5208
+ scope: "network",
5209
+ writer: "network_entitlement",
5210
+ projections: ["bnf_admin", "chapter_admin", "member_self_service", "stripe_billing"],
5211
+ sensitivity: "ordinary",
5212
+ memberAccess: "read",
5213
+ fields: [
5214
+ "entitlement.membershipId",
5215
+ "entitlement.kind",
5216
+ "entitlement.priceCents",
5217
+ "entitlement.currency",
5218
+ "entitlement.payerPersonId",
5219
+ "entitlement.purchasedAt",
5220
+ "entitlement.termEndsAt",
5221
+ "entitlement.renewsWithMembership",
5222
+ "entitlement.status"
5223
+ ]
5224
+ }),
5225
+ ...rows2({
5226
+ scope: "network",
5227
+ writer: "network_seat",
5228
+ projections: ["bnf_admin", "chapter_admin", "member_self_service"],
5229
+ sensitivity: "pii",
5230
+ memberAccess: "read",
5231
+ fields: [
5232
+ "seat.membershipId",
5233
+ "seat.entitlementId",
5234
+ "seat.personId",
5235
+ "seat.recipientName",
5236
+ "seat.recipientEmail",
5237
+ "seat.role",
5238
+ "seat.status",
5239
+ "seat.acceptanceExpiresAt",
5240
+ "seat.acceptedAt",
5241
+ "seat.activatedAt",
5242
+ "seat.refundedAt"
5243
+ ]
5244
+ }),
5245
+ ...rows2({
5246
+ scope: "network",
5247
+ writer: "network_referral_ledger",
5248
+ projections: ["bnf_admin", "chapter_admin", "member_self_service"],
5249
+ sensitivity: "ordinary",
5250
+ memberAccess: "read",
5251
+ fields: [
5252
+ "referral.referrerPersonId",
5253
+ "referral.referredPersonId",
5254
+ "referral.qualifiedMembershipId",
5255
+ "referral.creditCents",
5256
+ "referral.status",
5257
+ "referral.appliedInvoiceId",
5258
+ "referral.carryForwardCents",
5259
+ "referral.adjustmentOf"
5260
+ ]
5261
+ }),
5262
+ ...rows2({
5263
+ scope: "network",
5264
+ writer: "network_investment_ledger",
5265
+ projections: ["bnf_admin", "chapter_admin", "member_self_service"],
5266
+ sensitivity: "restricted",
5267
+ memberAccess: "read",
5268
+ fields: [
5269
+ "investment.personId",
5270
+ "investment.chapterId",
5271
+ "investment.season",
5272
+ "investment.purpose",
5273
+ "investment.targetCount",
5274
+ "investment.status",
5275
+ "investment.amountCents",
5276
+ "investment.closedAt",
5277
+ "investment.sourceReference"
5278
+ ]
5279
+ }),
5280
+ ...rows2({
5281
+ scope: "provider",
5282
+ writer: "stripe",
5283
+ projections: ["stripe_billing", "bnf_admin", "chapter_admin"],
5284
+ sensitivity: "restricted",
5285
+ memberAccess: "none",
5286
+ fields: [
5287
+ "commercial.charge",
5288
+ "commercial.invoice",
5289
+ "commercial.refund",
5290
+ "commercial.providerSubscription",
5291
+ "commercial.paymentMethod"
5292
+ ]
5293
+ })
5294
+ ];
5295
+ var MEMBER_SELF_EDITABLE_FIELDS = new Set(
5296
+ MEMBER_SYSTEM_AUTHORITY_MATRIX.filter((row) => row.memberAccess === "edit").map((row) => row.id)
5297
+ );
5298
+ var MEMBER_SELF_READABLE_FIELDS = new Set(
5299
+ MEMBER_SYSTEM_AUTHORITY_MATRIX.filter((row) => row.memberAccess !== "none").map((row) => row.id)
5300
+ );
5301
+ function projectMemberSelf(record4) {
5302
+ return Object.fromEntries(Object.entries(record4).filter(([field]) => MEMBER_SELF_READABLE_FIELDS.has(field)));
5303
+ }
5304
+ function classifyMemberSystemWrite(intent) {
5305
+ if (intent.actor === "bnf") return "reject_bnf_surface";
5306
+ const authority = MEMBER_SYSTEM_AUTHORITY_MATRIX.find((row) => row.id === intent.field);
5307
+ if (!authority) return "reject_unknown_field";
5308
+ if (authority.writer !== intent.actor) return "reject_wrong_writer";
5309
+ if (intent.expectedRevision !== intent.actualRevision) return "reject_stale_revision";
5310
+ return "apply";
5311
+ }
5312
+ function validateMemberSystemAuthority(matrix = MEMBER_SYSTEM_AUTHORITY_MATRIX) {
5313
+ const errors = [];
5314
+ const ids = /* @__PURE__ */ new Set();
5315
+ for (const row of matrix) {
5316
+ if (!row.id || !row.id.includes(".")) errors.push(`invalid field id "${row.id}"`);
5317
+ if (ids.has(row.id)) errors.push(`duplicate field authority "${row.id}"`);
5318
+ ids.add(row.id);
5319
+ if (row.memberAccess !== "none" && !row.projections.includes("member_self_service")) {
5320
+ errors.push(`${row.id} grants member access without a member_self_service projection`);
5321
+ }
5322
+ if (row.id.startsWith("person.") && (row.scope !== "network" || row.writer !== "network_person")) {
5323
+ errors.push(`${row.id} must be network_person authority`);
5324
+ }
5325
+ if (row.id.startsWith("journey.") && (row.scope !== "chapter" || row.writer !== "chapter_journey")) {
5326
+ errors.push(`${row.id} must be chapter_journey authority`);
5327
+ }
5328
+ }
5329
+ return { ok: errors.length === 0, errors };
5330
+ }
5331
+
5332
+ // src/member-system-contract.ts
5333
+ var MEMBER_SYSTEM_CONTRACT_VERSION = 1;
5334
+ var JOURNEY_STAGES = [
5335
+ "identified",
5336
+ "researched",
5337
+ "outreach",
5338
+ "in_conversation",
5339
+ "invited_or_requested",
5340
+ "application_started",
5341
+ "applied",
5342
+ "paid_awaiting_conversation",
5343
+ "ready_to_book",
5344
+ "booked",
5345
+ "met",
5346
+ "approved",
5347
+ "onboarded",
5348
+ "active",
5349
+ "first_deal"
5350
+ ];
5351
+ var JOURNEY_ENDINGS = ["passed", "declined", "withdrew", "lapsed"];
5352
+ var REQUIRED_NOTICE_KINDS = [
5353
+ "payment_receipt",
5354
+ "refund_confirmation",
5355
+ "security_alert",
5356
+ "legal_notice",
5357
+ "membership_status",
5358
+ "renewal_notice",
5359
+ "cancellation_confirmation"
5360
+ ];
5361
+ function memberSystemAvailability(input) {
5362
+ if (!input.odlaReachable) {
5363
+ return {
5364
+ bnfAdministration: false,
5365
+ chapterWorkflow: false,
5366
+ memberSelfService: false,
5367
+ newApplication: false,
5368
+ newCheckout: false,
5369
+ providerRenewalsMayContinue: true,
5370
+ reason: "odla_unavailable"
5371
+ };
5372
+ }
5373
+ return {
5374
+ bnfAdministration: input.bnfFrontendReachable,
5375
+ chapterWorkflow: true,
5376
+ memberSelfService: true,
5377
+ newApplication: true,
5378
+ newCheckout: true,
5379
+ providerRenewalsMayContinue: true,
5380
+ ...!input.bnfFrontendReachable ? { reason: "bnf_frontend_unavailable" } : {}
5381
+ };
5382
+ }
5383
+ function classifyMemberStripeEvent(identity, target, hasProvenLegacyLocalLink) {
5384
+ const keys = ["appId", "environment", "dataEnvironment", "runtime", "chapterId"];
5385
+ const supplied = keys.filter((key) => identity[key] !== void 0);
5386
+ if (supplied.some((key) => identity[key] !== target[key])) return "ignore_sibling";
5387
+ if (supplied.length === keys.length) return "apply";
5388
+ return hasProvenLegacyLocalLink ? "apply_legacy" : "quarantine_unmatched";
5389
+ }
5390
+ function planMemberSystemEventReplay(events) {
5391
+ const seen = /* @__PURE__ */ new Map();
5392
+ const plan = { accepted: [], replayed: [], collisions: [] };
5393
+ for (const event of events) {
5394
+ const digest = seen.get(event.id);
5395
+ if (digest === void 0) {
5396
+ seen.set(event.id, event.digest);
5397
+ plan.accepted.push(event.id);
5398
+ } else if (digest === event.digest) plan.replayed.push(event.id);
5399
+ else plan.collisions.push(event.id);
5400
+ }
5401
+ return plan;
5402
+ }
5403
+ var MEMBER_SYSTEM_RECOVERY_OBJECTIVES = {
5404
+ failClosedWithinMs: 0,
5405
+ replayProjectionWithinMinutes: 15,
5406
+ providerEventsRemainReplayable: true,
5407
+ requireHumanReviewForCollision: true
5408
+ };
5409
+ function planMemberSystemMigration(rows3) {
5410
+ const plan = { importIds: [], fixtureIds: [], rejectedIds: [] };
5411
+ for (const row of rows3) {
5412
+ if (row.source === "synthetic_fixture" && !row.isRealPerson) plan.fixtureIds.push(row.id);
5413
+ else if (row.source === "external_reimport" && row.isRealPerson && row.provenance) plan.importIds.push(row.id);
5414
+ else plan.rejectedIds.push(row.id);
5415
+ }
5416
+ return plan;
5417
+ }
5418
+ function memberSystemRollbackPlan() {
5419
+ return {
5420
+ stopNetworkWrites: true,
5421
+ disableBnfMemberMutations: true,
5422
+ keepChapterProductionReads: true,
5423
+ keepStripeBillingAuthority: true,
5424
+ deleteProviderObjects: false,
5425
+ reverseProviderPayments: false,
5426
+ reconciliationRequired: true
5427
+ };
5428
+ }
5429
+ var SILVER_SALT_P0_FIXTURE = {
5430
+ sourceInventory: { applications: 36, meetings: 7, emails: 49, realPeople: 0 },
5431
+ application: { id: "fixture_application_001", personId: "fixture_person_001", migrates: false },
5432
+ crm: { recordId: "fixture_crm_001", email: "fixture.member@example.invalid", migrates: false },
5433
+ clerk: { userId: "user_fixture_001", verifiedEmail: "fixture.member@example.invalid", migrates: false },
5434
+ stripe: {
5435
+ customerId: "cus_fixture_001",
5436
+ subscriptionId: "sub_fixture_001",
5437
+ productId: "prod_fixture_001",
5438
+ priceId: "price_fixture_001",
5439
+ eventId: "evt_fixture_001",
5440
+ migrates: false
5441
+ },
5442
+ unmatchedStripeEvent: { id: "evt_fixture_unmatched", disposition: "quarantine_unmatched" },
5443
+ legacyStripeEvent: { id: "evt_fixture_legacy", requiresProvenLocalLink: true }
5444
+ };
4957
5445
  //# sourceMappingURL=index.cjs.map