@odla-ai/chapter 0.32.3 → 0.33.1

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.d.cts CHANGED
@@ -161,6 +161,22 @@ type DeepPartial<T> = T extends readonly (infer Item)[] ? readonly Item[] : T ex
161
161
  /** Recursively partial copy overrides accepted by `defineChapter({ copy })`. */
162
162
  type ChapterCopyInput = DeepPartial<ChapterCopy>;
163
163
 
164
+ /** Explicit authority a chapter grants to one Built Not Found-style hub. */
165
+ interface ChapterSignupControl {
166
+ /** Stable app id expected in the signed delivery envelope. */
167
+ sourceId: string;
168
+ /** Follower-vault key holding the dedicated edge secret. */
169
+ secretName?: string;
170
+ /** Stripe mode this deployed environment accepts. */
171
+ stripeMode: "test" | "live";
172
+ }
173
+ /** Validated signup-control authority carried on a resolved Chapter. */
174
+ interface ResolvedSignupControl {
175
+ sourceId: string;
176
+ secretName: string;
177
+ stripeMode: "test" | "live";
178
+ }
179
+
164
180
  /** One follower site a leader can push CRM records to. The secret VALUE never
165
181
  * lives in config: `secretName` names the leader tenant's vaulted copy of the
166
182
  * follower's `network_share_secret`. */
@@ -294,6 +310,16 @@ interface DbOp {
294
310
  * member routes consume — so route logic is testable against an in-memory fake. */
295
311
  interface ChapterDb {
296
312
  query(q: Record<string, unknown>): Promise<Record<string, Array<Record<string, unknown>>>>;
313
+ /** Optional bounded aggregate supported by the real privileged odla-db
314
+ * client. Routes use it to prove a result set is non-empty before issuing
315
+ * an ordered lookup, while small test doubles may continue to omit it. */
316
+ aggregate?(ns: string, spec: {
317
+ count?: boolean;
318
+ }, opts?: {
319
+ where?: Record<string, unknown>;
320
+ }): Promise<{
321
+ count?: number;
322
+ }>;
297
323
  transact(ops: DbOp[], opts?: {
298
324
  mutationId?: string;
299
325
  }): Promise<{
@@ -552,6 +578,8 @@ interface ChapterConfig {
552
578
  /** Signed network edges: leader delivery targets and follower-owned,
553
579
  * privacy-bounded record readers. Secret values stay in tenant vaults. */
554
580
  network?: ChapterNetwork;
581
+ /** A separate signed edge that may control this chapter's complete signup. */
582
+ signupControl?: ChapterSignupControl;
555
583
  /** Enable a public, host-rendered formation application workflow. */
556
584
  formation?: LeaderFormationConfig;
557
585
  thesis?: unknown;
@@ -646,6 +674,8 @@ interface Chapter {
646
674
  copy: ChapterCopy;
647
675
  /** Validated follower targets for leader-driven record pushes. */
648
676
  network: ResolvedNetwork;
677
+ /** Null unless this follower explicitly delegates signup authority. */
678
+ signupControl: ResolvedSignupControl | null;
649
679
  /** Resolved public formation intake contract (disabled when omitted). */
650
680
  formation: ResolvedLeaderFormation;
651
681
  /** Resolved CRM engine (from `defineCrm`). */
@@ -678,6 +708,9 @@ interface Chapter {
678
708
  */
679
709
  declare function defineChapter(config: ChapterConfig): Chapter;
680
710
 
711
+ /** Validate one deliberately separate signup-control edge. */
712
+ declare function resolveSignupControl(input: ChapterSignupControl | undefined): ResolvedSignupControl | null;
713
+
681
714
  /** Options for {@link leaderCrmConfig}. */
682
715
  interface LeaderCrmOptions {
683
716
  /** Existing host CRM config to preserve. Defaults to Chapter's people +
@@ -773,7 +806,7 @@ declare function createChapterIntegration(chapter: Chapter, options?: ChapterInt
773
806
  * read-only super-admin tier (default on for the `"claim"` ladder). A `"claim"`
774
807
  * chapter therefore emits the reference namespace set — `applications`,
775
808
  * `groups`, `meetings`, `emailLog`, `superAdmins` — with no `admins` table. */
776
- declare function chapterDb(mode: ChapterMode, auth: ResolvedAuth, includeNetworkNotes?: boolean, application?: ResolvedApplication): {
809
+ declare function chapterDb(mode: ChapterMode, auth: ResolvedAuth, includeNetworkNotes?: boolean, application?: ResolvedApplication, includeSignupControl?: boolean): {
777
810
  schema: DbSchema;
778
811
  rules: DbRules;
779
812
  };
@@ -1921,6 +1954,101 @@ declare function validateMembershipPageDocument(input: unknown, options?: Member
1921
1954
  /** Validate a document or fail closed with all actionable validation errors. */
1922
1955
  declare function membershipPageDocument(input: unknown, options?: MembershipPageValidationOptions): MembershipPageDocument;
1923
1956
 
1957
+ /** Current wire-format version for complete signup-control documents. */
1958
+ declare const SIGNUP_CONTROL_SCHEMA_VERSION: 1;
1959
+ /** Package-owned follower endpoint for signed signup-control delivery. */
1960
+ declare const SIGNUP_CONTROL_PATH: "/api/signup-control";
1961
+ /** One authoritative membership tier in a signup-control revision. */
1962
+ interface SignupControlTier {
1963
+ id: string;
1964
+ name: string;
1965
+ available: boolean;
1966
+ sortOrder: number;
1967
+ priceCents: number;
1968
+ stripePriceId?: string;
1969
+ blurb?: string;
1970
+ }
1971
+ /** A bounded application contract. Fields must already exist in the follower schema. */
1972
+ interface SignupControlApplication {
1973
+ required: readonly string[];
1974
+ optional: readonly string[];
1975
+ conditions?: Readonly<Record<string, FieldConditions>>;
1976
+ copy?: Readonly<Record<string, string>>;
1977
+ }
1978
+ /** Delegated legal and trust copy used by the packaged join journey. */
1979
+ interface SignupControlPolicy {
1980
+ disclaimerText: string;
1981
+ refundPolicyText: string;
1982
+ trustCopy?: string;
1983
+ commitmentText?: string;
1984
+ normsText?: string;
1985
+ }
1986
+ /** Bounded semantic design tokens delegated to the chapter signup surface. */
1987
+ interface SignupControlTheme {
1988
+ /** Includes color, spacing, and typography tokens such as font families. */
1989
+ tokens: Readonly<Record<string, string | number>>;
1990
+ }
1991
+ /** Complete desired state delivered by a controlling hub. */
1992
+ interface SignupControlDocument {
1993
+ schemaVersion: typeof SIGNUP_CONTROL_SCHEMA_VERSION;
1994
+ revision: number;
1995
+ generatedAt: number;
1996
+ source: {
1997
+ appId: string;
1998
+ };
1999
+ target: {
2000
+ chapterId: string;
2001
+ environment: string;
2002
+ stripeMode: "test" | "live";
2003
+ };
2004
+ tiers: readonly SignupControlTier[];
2005
+ membershipPage: MembershipPageDocument;
2006
+ application?: SignupControlApplication;
2007
+ policy?: SignupControlPolicy;
2008
+ scheduling?: ChapterScheduling;
2009
+ theme?: SignupControlTheme;
2010
+ }
2011
+ /** Digest travels beside the document so the exact desired state is attestable. */
2012
+ interface SignupControlEnvelope {
2013
+ digest: string;
2014
+ document: SignupControlDocument;
2015
+ }
2016
+ /** Exact follower acknowledgement for one accepted or replayed revision. */
2017
+ interface SignupControlReceipt {
2018
+ ok: true;
2019
+ target: {
2020
+ chapterId: string;
2021
+ environment: string;
2022
+ };
2023
+ revision: number;
2024
+ digest: string;
2025
+ status: "accepted" | "replayed";
2026
+ acknowledgedAt: number;
2027
+ }
2028
+ /** Stable reason codes returned when a follower refuses desired state. */
2029
+ type SignupControlRejection = "invalid_document" | "invalid_digest" | "wrong_source" | "wrong_target" | "wrong_environment" | "wrong_stripe_mode" | "stale_revision" | "conflicting_revision";
2030
+ /** Normalized document result returned by the package validator. */
2031
+ type SignupControlValidation = {
2032
+ ok: true;
2033
+ value: SignupControlDocument;
2034
+ } | {
2035
+ ok: false;
2036
+ errors: readonly string[];
2037
+ };
2038
+
2039
+ /** Serialize JSON-like signup state with recursively sorted object keys. */
2040
+ declare function canonicalSignupControl(value: unknown): string;
2041
+ /** Compute the protocol's canonical SHA-256 digest for desired signup state. */
2042
+ declare function signupControlDigest(document: unknown): Promise<string>;
2043
+ /** Pair one desired-state document with its canonical digest for delivery. */
2044
+ declare function createSignupControlEnvelope(document: SignupControlDocument): Promise<{
2045
+ document: SignupControlDocument;
2046
+ digest: string;
2047
+ }>;
2048
+
2049
+ /** Validate and normalize one complete desired signup state. */
2050
+ declare function validateSignupControlDocument(input: unknown): SignupControlValidation;
2051
+
1924
2052
  /** A presentation overlay parsed from the constrained membership Markdown convention. */
1925
2053
  type MembershipTierMarkdownResult = {
1926
2054
  ok: true;
@@ -1944,4 +2072,4 @@ declare function applyMembershipTierMarkdown(presentation: MembershipTierPresent
1944
2072
  /** Apply constrained membership Markdown or fail closed with actionable errors. */
1945
2073
  declare function membershipTierPresentationFromMarkdown(presentation: MembershipTierPresentation, source: string): MembershipTierPresentation;
1946
2074
 
1947
- export { type AccountModel, type AdminNotificationTrigger, type Applicant, type ApplicationBookingPatch, type ApplicationRecord, type ApplicationSummary, type Attr, type AttrType, type Chapter, type ChapterApplication, type ChapterAuth, type ChapterBrand, type ChapterConfig, type ChapterCopy, type ChapterCopyInput, type ChapterDb, type ChapterEmails, type ChapterIntegrationDescriptor, type ChapterIntegrationOptions, type ChapterMode, type ChapterNetwork, type ChapterNetworkReader, type ChapterNetworkTarget, type ChapterOperations, type ChapterPipeline, type ChapterPolicy, type ChapterPrices, type ChapterRunbookHints, type ChapterScheduling, type ChapterSends, type ChapterTier, type ChapterTierConfig, type ClerkInviteInput, type ClerkMetadataInput, type ClerkResult, type ClerkUserInput, type ClerkUserRecord, type CompiledChapterBrandTokens, DEFAULT_CHAPTER_COPY, DEFAULT_SHARE_FIELDS, type DashboardMetricData, type DashboardMetricSeries, type DbOp, type DbRules, type DbSchema, type DeliveryDecision, type EmailGroup, type EmailTemplate, type EmailTemplateRow, type Entity, type ExistingMeeting, type GuardResult, type IntegrationDescriptor, type IntegrationProvision, type IntegrationSecret, type IntegrationSetting, type IntegrationSync, type JoinConfigGroup, type JoinConfigTier, type LeaderCrmOptions, type LeaderFormationConfig, type LiveEvent, MEMBERSHIP_PAGE_RENDERER, type MailSender, type MeetingForReconcile, type MeetingRecord, type MeetingReschedulePatch, type MemberApplication, type MemberSession, type MembershipPageDocument, type MembershipPageValidationOptions, type MembershipPageValidationResult, type MembershipTierAuthority, type MembershipTierCallout, type MembershipTierCapacity, type MembershipTierMarkdownResult, type MembershipTierPresentation, type MembershipTierVariant, type NetworkRecord, type NetworkRecordNote, type NetworkRecordPage, type NetworkRollup, type NetworkRollupTarget, type NetworkSharedNote, type NetworkSnapshot, type NewMeetingRow, type NotifyDeps, type NotifyInput, type NotifyResult, type PaymentsGroup, type ProjectionDeps, type ReconcileDecision, type ResolvedApplication, type ResolvedAuth, type ResolvedLeaderFormation, type ResolvedNetwork, type ResolvedNetworkReader, type ResolvedNetworkTarget, type ResolvedOperations, type ResolvedPipeline, type ResolvedScheduling, type ResolvedSends, type RoleChangeContext, type Rule, SCHEDULING_DEFAULTS, type SchedulingErrors, type SecretMode, type SecretStore, type SessionUser, type SharedBusiness, type SharedPerson, type SharedRecord, type SharedRecordV1, type SharedRecordV2, type StripeEvent, type StripeResult, type SubmitResult, type TierGroup, type TierGroupRow, type WebhookEvent, applicantProfile, applicationBookingUpdate, applicationSummary, applyMembershipTierMarkdown, backfillCrm, bookingDecision, brandTokens, bucketSeries, buildGroupSeed, buildTierSeeds, canApprove, canBook, canChangeRole, canTransition, canceledPatch, chapterBrandFromTokens, chapterDb, clampArray, clerkGetUser, clerkGetUserByEmail, clerkIntegration, clerkInviteRequest, clerkListUsers, clerkSetRole, clerkUserRequest, createChapterIntegration, createClerkInvitation, createClerkUser, dashboardMetricData, defaultCrm, defineChapter, emailGroupFrom, endForSlot, findApplicationRef, findTier, firstPaymentPatch, formatChapterCopy, formationFields, getVaultSecret, hasDisclaimerAck, introIdempotencyKey, isAdminRole, isAlreadySent, isReconcilable, isSlotAvailable, isValidEmail, joinConfig, joinConfigTiers, leaderCrmConfig, loadOfferableTiers, loadTiers, meetingCreateRow, meetingRescheduleUpdate, memberApplication, memberSession, membershipPageDocument, membershipTierPresentationFromMarkdown, networkSourceTag, normalizeSharedRecord, normalizeWebhookEvent, offerableTiers, paymentsReady, personInputFromApp, planDelivery, projectApplicant, projectSharedRecord, reconcileMeetings, refundedPatch, render, renderSummary, renderTemplateBody, renewalPatch, resolveApplication, resolveAuth, resolveChapterCopy, resolveLeaderFormation, resolvePipeline, resolveScheduling, resolveTiers, roleFromClaim, sendTemplated, sharedPersonInput, sharedRecordFromCrm, slotWindow, stageIndex, stripeCall, subAnnualCents, submitApplication, subscriptionIdempotencyKey, syncApplicationToCrm, tierIsFree, tierPayable, updateClerkUserMetadata, updateClerkUserMetadataByEmail, validateMembershipPageDocument, validateScheduling, webhookMutationId };
2075
+ export { type AccountModel, type AdminNotificationTrigger, type Applicant, type ApplicationBookingPatch, type ApplicationRecord, type ApplicationSummary, type Attr, type AttrType, type Chapter, type ChapterApplication, type ChapterAuth, type ChapterBrand, type ChapterConfig, type ChapterCopy, type ChapterCopyInput, type ChapterDb, type ChapterEmails, type ChapterIntegrationDescriptor, type ChapterIntegrationOptions, type ChapterMode, type ChapterNetwork, type ChapterNetworkReader, type ChapterNetworkTarget, type ChapterOperations, type ChapterPipeline, type ChapterPolicy, type ChapterPrices, type ChapterRunbookHints, type ChapterScheduling, type ChapterSends, type ChapterSignupControl, type ChapterTier, type ChapterTierConfig, type ClerkInviteInput, type ClerkMetadataInput, type ClerkResult, type ClerkUserInput, type ClerkUserRecord, type CompiledChapterBrandTokens, DEFAULT_CHAPTER_COPY, DEFAULT_SHARE_FIELDS, type DashboardMetricData, type DashboardMetricSeries, type DbOp, type DbRules, type DbSchema, type DeliveryDecision, type EmailGroup, type EmailTemplate, type EmailTemplateRow, type Entity, type ExistingMeeting, type GuardResult, type IntegrationDescriptor, type IntegrationProvision, type IntegrationSecret, type IntegrationSetting, type IntegrationSync, type JoinConfigGroup, type JoinConfigTier, type LeaderCrmOptions, type LeaderFormationConfig, type LiveEvent, MEMBERSHIP_PAGE_RENDERER, type MailSender, type MeetingForReconcile, type MeetingRecord, type MeetingReschedulePatch, type MemberApplication, type MemberSession, type MembershipPageDocument, type MembershipPageValidationOptions, type MembershipPageValidationResult, type MembershipTierAuthority, type MembershipTierCallout, type MembershipTierCapacity, type MembershipTierMarkdownResult, type MembershipTierPresentation, type MembershipTierVariant, type NetworkRecord, type NetworkRecordNote, type NetworkRecordPage, type NetworkRollup, type NetworkRollupTarget, type NetworkSharedNote, type NetworkSnapshot, type NewMeetingRow, type NotifyDeps, type NotifyInput, type NotifyResult, type PaymentsGroup, type ProjectionDeps, type ReconcileDecision, type ResolvedApplication, type ResolvedAuth, type ResolvedLeaderFormation, type ResolvedNetwork, type ResolvedNetworkReader, type ResolvedNetworkTarget, type ResolvedOperations, type ResolvedPipeline, type ResolvedScheduling, type ResolvedSends, type ResolvedSignupControl, type RoleChangeContext, type Rule, SCHEDULING_DEFAULTS, SIGNUP_CONTROL_PATH, SIGNUP_CONTROL_SCHEMA_VERSION, type SchedulingErrors, type SecretMode, type SecretStore, type SessionUser, type SharedBusiness, type SharedPerson, type SharedRecord, type SharedRecordV1, type SharedRecordV2, type SignupControlApplication, type SignupControlDocument, type SignupControlEnvelope, type SignupControlPolicy, type SignupControlReceipt, type SignupControlRejection, type SignupControlTheme, type SignupControlTier, type SignupControlValidation, type StripeEvent, type StripeResult, type SubmitResult, type TierGroup, type TierGroupRow, type WebhookEvent, applicantProfile, applicationBookingUpdate, applicationSummary, applyMembershipTierMarkdown, backfillCrm, bookingDecision, brandTokens, bucketSeries, buildGroupSeed, buildTierSeeds, canApprove, canBook, canChangeRole, canTransition, canceledPatch, canonicalSignupControl, chapterBrandFromTokens, chapterDb, clampArray, clerkGetUser, clerkGetUserByEmail, clerkIntegration, clerkInviteRequest, clerkListUsers, clerkSetRole, clerkUserRequest, createChapterIntegration, createClerkInvitation, createClerkUser, createSignupControlEnvelope, dashboardMetricData, defaultCrm, defineChapter, emailGroupFrom, endForSlot, findApplicationRef, findTier, firstPaymentPatch, formatChapterCopy, formationFields, getVaultSecret, hasDisclaimerAck, introIdempotencyKey, isAdminRole, isAlreadySent, isReconcilable, isSlotAvailable, isValidEmail, joinConfig, joinConfigTiers, leaderCrmConfig, loadOfferableTiers, loadTiers, meetingCreateRow, meetingRescheduleUpdate, memberApplication, memberSession, membershipPageDocument, membershipTierPresentationFromMarkdown, networkSourceTag, normalizeSharedRecord, normalizeWebhookEvent, offerableTiers, paymentsReady, personInputFromApp, planDelivery, projectApplicant, projectSharedRecord, reconcileMeetings, refundedPatch, render, renderSummary, renderTemplateBody, renewalPatch, resolveApplication, resolveAuth, resolveChapterCopy, resolveLeaderFormation, resolvePipeline, resolveScheduling, resolveSignupControl, resolveTiers, roleFromClaim, sendTemplated, sharedPersonInput, sharedRecordFromCrm, signupControlDigest, slotWindow, stageIndex, stripeCall, subAnnualCents, submitApplication, subscriptionIdempotencyKey, syncApplicationToCrm, tierIsFree, tierPayable, updateClerkUserMetadata, updateClerkUserMetadataByEmail, validateMembershipPageDocument, validateScheduling, validateSignupControlDocument, webhookMutationId };
package/dist/index.d.ts CHANGED
@@ -161,6 +161,22 @@ type DeepPartial<T> = T extends readonly (infer Item)[] ? readonly Item[] : T ex
161
161
  /** Recursively partial copy overrides accepted by `defineChapter({ copy })`. */
162
162
  type ChapterCopyInput = DeepPartial<ChapterCopy>;
163
163
 
164
+ /** Explicit authority a chapter grants to one Built Not Found-style hub. */
165
+ interface ChapterSignupControl {
166
+ /** Stable app id expected in the signed delivery envelope. */
167
+ sourceId: string;
168
+ /** Follower-vault key holding the dedicated edge secret. */
169
+ secretName?: string;
170
+ /** Stripe mode this deployed environment accepts. */
171
+ stripeMode: "test" | "live";
172
+ }
173
+ /** Validated signup-control authority carried on a resolved Chapter. */
174
+ interface ResolvedSignupControl {
175
+ sourceId: string;
176
+ secretName: string;
177
+ stripeMode: "test" | "live";
178
+ }
179
+
164
180
  /** One follower site a leader can push CRM records to. The secret VALUE never
165
181
  * lives in config: `secretName` names the leader tenant's vaulted copy of the
166
182
  * follower's `network_share_secret`. */
@@ -294,6 +310,16 @@ interface DbOp {
294
310
  * member routes consume — so route logic is testable against an in-memory fake. */
295
311
  interface ChapterDb {
296
312
  query(q: Record<string, unknown>): Promise<Record<string, Array<Record<string, unknown>>>>;
313
+ /** Optional bounded aggregate supported by the real privileged odla-db
314
+ * client. Routes use it to prove a result set is non-empty before issuing
315
+ * an ordered lookup, while small test doubles may continue to omit it. */
316
+ aggregate?(ns: string, spec: {
317
+ count?: boolean;
318
+ }, opts?: {
319
+ where?: Record<string, unknown>;
320
+ }): Promise<{
321
+ count?: number;
322
+ }>;
297
323
  transact(ops: DbOp[], opts?: {
298
324
  mutationId?: string;
299
325
  }): Promise<{
@@ -552,6 +578,8 @@ interface ChapterConfig {
552
578
  /** Signed network edges: leader delivery targets and follower-owned,
553
579
  * privacy-bounded record readers. Secret values stay in tenant vaults. */
554
580
  network?: ChapterNetwork;
581
+ /** A separate signed edge that may control this chapter's complete signup. */
582
+ signupControl?: ChapterSignupControl;
555
583
  /** Enable a public, host-rendered formation application workflow. */
556
584
  formation?: LeaderFormationConfig;
557
585
  thesis?: unknown;
@@ -646,6 +674,8 @@ interface Chapter {
646
674
  copy: ChapterCopy;
647
675
  /** Validated follower targets for leader-driven record pushes. */
648
676
  network: ResolvedNetwork;
677
+ /** Null unless this follower explicitly delegates signup authority. */
678
+ signupControl: ResolvedSignupControl | null;
649
679
  /** Resolved public formation intake contract (disabled when omitted). */
650
680
  formation: ResolvedLeaderFormation;
651
681
  /** Resolved CRM engine (from `defineCrm`). */
@@ -678,6 +708,9 @@ interface Chapter {
678
708
  */
679
709
  declare function defineChapter(config: ChapterConfig): Chapter;
680
710
 
711
+ /** Validate one deliberately separate signup-control edge. */
712
+ declare function resolveSignupControl(input: ChapterSignupControl | undefined): ResolvedSignupControl | null;
713
+
681
714
  /** Options for {@link leaderCrmConfig}. */
682
715
  interface LeaderCrmOptions {
683
716
  /** Existing host CRM config to preserve. Defaults to Chapter's people +
@@ -773,7 +806,7 @@ declare function createChapterIntegration(chapter: Chapter, options?: ChapterInt
773
806
  * read-only super-admin tier (default on for the `"claim"` ladder). A `"claim"`
774
807
  * chapter therefore emits the reference namespace set — `applications`,
775
808
  * `groups`, `meetings`, `emailLog`, `superAdmins` — with no `admins` table. */
776
- declare function chapterDb(mode: ChapterMode, auth: ResolvedAuth, includeNetworkNotes?: boolean, application?: ResolvedApplication): {
809
+ declare function chapterDb(mode: ChapterMode, auth: ResolvedAuth, includeNetworkNotes?: boolean, application?: ResolvedApplication, includeSignupControl?: boolean): {
777
810
  schema: DbSchema;
778
811
  rules: DbRules;
779
812
  };
@@ -1921,6 +1954,101 @@ declare function validateMembershipPageDocument(input: unknown, options?: Member
1921
1954
  /** Validate a document or fail closed with all actionable validation errors. */
1922
1955
  declare function membershipPageDocument(input: unknown, options?: MembershipPageValidationOptions): MembershipPageDocument;
1923
1956
 
1957
+ /** Current wire-format version for complete signup-control documents. */
1958
+ declare const SIGNUP_CONTROL_SCHEMA_VERSION: 1;
1959
+ /** Package-owned follower endpoint for signed signup-control delivery. */
1960
+ declare const SIGNUP_CONTROL_PATH: "/api/signup-control";
1961
+ /** One authoritative membership tier in a signup-control revision. */
1962
+ interface SignupControlTier {
1963
+ id: string;
1964
+ name: string;
1965
+ available: boolean;
1966
+ sortOrder: number;
1967
+ priceCents: number;
1968
+ stripePriceId?: string;
1969
+ blurb?: string;
1970
+ }
1971
+ /** A bounded application contract. Fields must already exist in the follower schema. */
1972
+ interface SignupControlApplication {
1973
+ required: readonly string[];
1974
+ optional: readonly string[];
1975
+ conditions?: Readonly<Record<string, FieldConditions>>;
1976
+ copy?: Readonly<Record<string, string>>;
1977
+ }
1978
+ /** Delegated legal and trust copy used by the packaged join journey. */
1979
+ interface SignupControlPolicy {
1980
+ disclaimerText: string;
1981
+ refundPolicyText: string;
1982
+ trustCopy?: string;
1983
+ commitmentText?: string;
1984
+ normsText?: string;
1985
+ }
1986
+ /** Bounded semantic design tokens delegated to the chapter signup surface. */
1987
+ interface SignupControlTheme {
1988
+ /** Includes color, spacing, and typography tokens such as font families. */
1989
+ tokens: Readonly<Record<string, string | number>>;
1990
+ }
1991
+ /** Complete desired state delivered by a controlling hub. */
1992
+ interface SignupControlDocument {
1993
+ schemaVersion: typeof SIGNUP_CONTROL_SCHEMA_VERSION;
1994
+ revision: number;
1995
+ generatedAt: number;
1996
+ source: {
1997
+ appId: string;
1998
+ };
1999
+ target: {
2000
+ chapterId: string;
2001
+ environment: string;
2002
+ stripeMode: "test" | "live";
2003
+ };
2004
+ tiers: readonly SignupControlTier[];
2005
+ membershipPage: MembershipPageDocument;
2006
+ application?: SignupControlApplication;
2007
+ policy?: SignupControlPolicy;
2008
+ scheduling?: ChapterScheduling;
2009
+ theme?: SignupControlTheme;
2010
+ }
2011
+ /** Digest travels beside the document so the exact desired state is attestable. */
2012
+ interface SignupControlEnvelope {
2013
+ digest: string;
2014
+ document: SignupControlDocument;
2015
+ }
2016
+ /** Exact follower acknowledgement for one accepted or replayed revision. */
2017
+ interface SignupControlReceipt {
2018
+ ok: true;
2019
+ target: {
2020
+ chapterId: string;
2021
+ environment: string;
2022
+ };
2023
+ revision: number;
2024
+ digest: string;
2025
+ status: "accepted" | "replayed";
2026
+ acknowledgedAt: number;
2027
+ }
2028
+ /** Stable reason codes returned when a follower refuses desired state. */
2029
+ type SignupControlRejection = "invalid_document" | "invalid_digest" | "wrong_source" | "wrong_target" | "wrong_environment" | "wrong_stripe_mode" | "stale_revision" | "conflicting_revision";
2030
+ /** Normalized document result returned by the package validator. */
2031
+ type SignupControlValidation = {
2032
+ ok: true;
2033
+ value: SignupControlDocument;
2034
+ } | {
2035
+ ok: false;
2036
+ errors: readonly string[];
2037
+ };
2038
+
2039
+ /** Serialize JSON-like signup state with recursively sorted object keys. */
2040
+ declare function canonicalSignupControl(value: unknown): string;
2041
+ /** Compute the protocol's canonical SHA-256 digest for desired signup state. */
2042
+ declare function signupControlDigest(document: unknown): Promise<string>;
2043
+ /** Pair one desired-state document with its canonical digest for delivery. */
2044
+ declare function createSignupControlEnvelope(document: SignupControlDocument): Promise<{
2045
+ document: SignupControlDocument;
2046
+ digest: string;
2047
+ }>;
2048
+
2049
+ /** Validate and normalize one complete desired signup state. */
2050
+ declare function validateSignupControlDocument(input: unknown): SignupControlValidation;
2051
+
1924
2052
  /** A presentation overlay parsed from the constrained membership Markdown convention. */
1925
2053
  type MembershipTierMarkdownResult = {
1926
2054
  ok: true;
@@ -1944,4 +2072,4 @@ declare function applyMembershipTierMarkdown(presentation: MembershipTierPresent
1944
2072
  /** Apply constrained membership Markdown or fail closed with actionable errors. */
1945
2073
  declare function membershipTierPresentationFromMarkdown(presentation: MembershipTierPresentation, source: string): MembershipTierPresentation;
1946
2074
 
1947
- export { type AccountModel, type AdminNotificationTrigger, type Applicant, type ApplicationBookingPatch, type ApplicationRecord, type ApplicationSummary, type Attr, type AttrType, type Chapter, type ChapterApplication, type ChapterAuth, type ChapterBrand, type ChapterConfig, type ChapterCopy, type ChapterCopyInput, type ChapterDb, type ChapterEmails, type ChapterIntegrationDescriptor, type ChapterIntegrationOptions, type ChapterMode, type ChapterNetwork, type ChapterNetworkReader, type ChapterNetworkTarget, type ChapterOperations, type ChapterPipeline, type ChapterPolicy, type ChapterPrices, type ChapterRunbookHints, type ChapterScheduling, type ChapterSends, type ChapterTier, type ChapterTierConfig, type ClerkInviteInput, type ClerkMetadataInput, type ClerkResult, type ClerkUserInput, type ClerkUserRecord, type CompiledChapterBrandTokens, DEFAULT_CHAPTER_COPY, DEFAULT_SHARE_FIELDS, type DashboardMetricData, type DashboardMetricSeries, type DbOp, type DbRules, type DbSchema, type DeliveryDecision, type EmailGroup, type EmailTemplate, type EmailTemplateRow, type Entity, type ExistingMeeting, type GuardResult, type IntegrationDescriptor, type IntegrationProvision, type IntegrationSecret, type IntegrationSetting, type IntegrationSync, type JoinConfigGroup, type JoinConfigTier, type LeaderCrmOptions, type LeaderFormationConfig, type LiveEvent, MEMBERSHIP_PAGE_RENDERER, type MailSender, type MeetingForReconcile, type MeetingRecord, type MeetingReschedulePatch, type MemberApplication, type MemberSession, type MembershipPageDocument, type MembershipPageValidationOptions, type MembershipPageValidationResult, type MembershipTierAuthority, type MembershipTierCallout, type MembershipTierCapacity, type MembershipTierMarkdownResult, type MembershipTierPresentation, type MembershipTierVariant, type NetworkRecord, type NetworkRecordNote, type NetworkRecordPage, type NetworkRollup, type NetworkRollupTarget, type NetworkSharedNote, type NetworkSnapshot, type NewMeetingRow, type NotifyDeps, type NotifyInput, type NotifyResult, type PaymentsGroup, type ProjectionDeps, type ReconcileDecision, type ResolvedApplication, type ResolvedAuth, type ResolvedLeaderFormation, type ResolvedNetwork, type ResolvedNetworkReader, type ResolvedNetworkTarget, type ResolvedOperations, type ResolvedPipeline, type ResolvedScheduling, type ResolvedSends, type RoleChangeContext, type Rule, SCHEDULING_DEFAULTS, type SchedulingErrors, type SecretMode, type SecretStore, type SessionUser, type SharedBusiness, type SharedPerson, type SharedRecord, type SharedRecordV1, type SharedRecordV2, type StripeEvent, type StripeResult, type SubmitResult, type TierGroup, type TierGroupRow, type WebhookEvent, applicantProfile, applicationBookingUpdate, applicationSummary, applyMembershipTierMarkdown, backfillCrm, bookingDecision, brandTokens, bucketSeries, buildGroupSeed, buildTierSeeds, canApprove, canBook, canChangeRole, canTransition, canceledPatch, chapterBrandFromTokens, chapterDb, clampArray, clerkGetUser, clerkGetUserByEmail, clerkIntegration, clerkInviteRequest, clerkListUsers, clerkSetRole, clerkUserRequest, createChapterIntegration, createClerkInvitation, createClerkUser, dashboardMetricData, defaultCrm, defineChapter, emailGroupFrom, endForSlot, findApplicationRef, findTier, firstPaymentPatch, formatChapterCopy, formationFields, getVaultSecret, hasDisclaimerAck, introIdempotencyKey, isAdminRole, isAlreadySent, isReconcilable, isSlotAvailable, isValidEmail, joinConfig, joinConfigTiers, leaderCrmConfig, loadOfferableTiers, loadTiers, meetingCreateRow, meetingRescheduleUpdate, memberApplication, memberSession, membershipPageDocument, membershipTierPresentationFromMarkdown, networkSourceTag, normalizeSharedRecord, normalizeWebhookEvent, offerableTiers, paymentsReady, personInputFromApp, planDelivery, projectApplicant, projectSharedRecord, reconcileMeetings, refundedPatch, render, renderSummary, renderTemplateBody, renewalPatch, resolveApplication, resolveAuth, resolveChapterCopy, resolveLeaderFormation, resolvePipeline, resolveScheduling, resolveTiers, roleFromClaim, sendTemplated, sharedPersonInput, sharedRecordFromCrm, slotWindow, stageIndex, stripeCall, subAnnualCents, submitApplication, subscriptionIdempotencyKey, syncApplicationToCrm, tierIsFree, tierPayable, updateClerkUserMetadata, updateClerkUserMetadataByEmail, validateMembershipPageDocument, validateScheduling, webhookMutationId };
2075
+ export { type AccountModel, type AdminNotificationTrigger, type Applicant, type ApplicationBookingPatch, type ApplicationRecord, type ApplicationSummary, type Attr, type AttrType, type Chapter, type ChapterApplication, type ChapterAuth, type ChapterBrand, type ChapterConfig, type ChapterCopy, type ChapterCopyInput, type ChapterDb, type ChapterEmails, type ChapterIntegrationDescriptor, type ChapterIntegrationOptions, type ChapterMode, type ChapterNetwork, type ChapterNetworkReader, type ChapterNetworkTarget, type ChapterOperations, type ChapterPipeline, type ChapterPolicy, type ChapterPrices, type ChapterRunbookHints, type ChapterScheduling, type ChapterSends, type ChapterSignupControl, type ChapterTier, type ChapterTierConfig, type ClerkInviteInput, type ClerkMetadataInput, type ClerkResult, type ClerkUserInput, type ClerkUserRecord, type CompiledChapterBrandTokens, DEFAULT_CHAPTER_COPY, DEFAULT_SHARE_FIELDS, type DashboardMetricData, type DashboardMetricSeries, type DbOp, type DbRules, type DbSchema, type DeliveryDecision, type EmailGroup, type EmailTemplate, type EmailTemplateRow, type Entity, type ExistingMeeting, type GuardResult, type IntegrationDescriptor, type IntegrationProvision, type IntegrationSecret, type IntegrationSetting, type IntegrationSync, type JoinConfigGroup, type JoinConfigTier, type LeaderCrmOptions, type LeaderFormationConfig, type LiveEvent, MEMBERSHIP_PAGE_RENDERER, type MailSender, type MeetingForReconcile, type MeetingRecord, type MeetingReschedulePatch, type MemberApplication, type MemberSession, type MembershipPageDocument, type MembershipPageValidationOptions, type MembershipPageValidationResult, type MembershipTierAuthority, type MembershipTierCallout, type MembershipTierCapacity, type MembershipTierMarkdownResult, type MembershipTierPresentation, type MembershipTierVariant, type NetworkRecord, type NetworkRecordNote, type NetworkRecordPage, type NetworkRollup, type NetworkRollupTarget, type NetworkSharedNote, type NetworkSnapshot, type NewMeetingRow, type NotifyDeps, type NotifyInput, type NotifyResult, type PaymentsGroup, type ProjectionDeps, type ReconcileDecision, type ResolvedApplication, type ResolvedAuth, type ResolvedLeaderFormation, type ResolvedNetwork, type ResolvedNetworkReader, type ResolvedNetworkTarget, type ResolvedOperations, type ResolvedPipeline, type ResolvedScheduling, type ResolvedSends, type ResolvedSignupControl, type RoleChangeContext, type Rule, SCHEDULING_DEFAULTS, SIGNUP_CONTROL_PATH, SIGNUP_CONTROL_SCHEMA_VERSION, type SchedulingErrors, type SecretMode, type SecretStore, type SessionUser, type SharedBusiness, type SharedPerson, type SharedRecord, type SharedRecordV1, type SharedRecordV2, type SignupControlApplication, type SignupControlDocument, type SignupControlEnvelope, type SignupControlPolicy, type SignupControlReceipt, type SignupControlRejection, type SignupControlTheme, type SignupControlTier, type SignupControlValidation, type StripeEvent, type StripeResult, type SubmitResult, type TierGroup, type TierGroupRow, type WebhookEvent, applicantProfile, applicationBookingUpdate, applicationSummary, applyMembershipTierMarkdown, backfillCrm, bookingDecision, brandTokens, bucketSeries, buildGroupSeed, buildTierSeeds, canApprove, canBook, canChangeRole, canTransition, canceledPatch, canonicalSignupControl, chapterBrandFromTokens, chapterDb, clampArray, clerkGetUser, clerkGetUserByEmail, clerkIntegration, clerkInviteRequest, clerkListUsers, clerkSetRole, clerkUserRequest, createChapterIntegration, createClerkInvitation, createClerkUser, createSignupControlEnvelope, dashboardMetricData, defaultCrm, defineChapter, emailGroupFrom, endForSlot, findApplicationRef, findTier, firstPaymentPatch, formatChapterCopy, formationFields, getVaultSecret, hasDisclaimerAck, introIdempotencyKey, isAdminRole, isAlreadySent, isReconcilable, isSlotAvailable, isValidEmail, joinConfig, joinConfigTiers, leaderCrmConfig, loadOfferableTiers, loadTiers, meetingCreateRow, meetingRescheduleUpdate, memberApplication, memberSession, membershipPageDocument, membershipTierPresentationFromMarkdown, networkSourceTag, normalizeSharedRecord, normalizeWebhookEvent, offerableTiers, paymentsReady, personInputFromApp, planDelivery, projectApplicant, projectSharedRecord, reconcileMeetings, refundedPatch, render, renderSummary, renderTemplateBody, renewalPatch, resolveApplication, resolveAuth, resolveChapterCopy, resolveLeaderFormation, resolvePipeline, resolveScheduling, resolveSignupControl, resolveTiers, roleFromClaim, sendTemplated, sharedPersonInput, sharedRecordFromCrm, signupControlDigest, slotWindow, stageIndex, stripeCall, subAnnualCents, submitApplication, subscriptionIdempotencyKey, syncApplicationToCrm, tierIsFree, tierPayable, updateClerkUserMetadata, updateClerkUserMetadataByEmail, validateMembershipPageDocument, validateScheduling, validateSignupControlDocument, webhookMutationId };