@odla-ai/chapter 0.23.0 → 0.24.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/README.md +2 -2
- package/dist/{chunk-OYXNI6VR.js → chunk-GMGTJIY3.js} +28 -15
- package/dist/chunk-GMGTJIY3.js.map +1 -0
- package/dist/{chunk-NTZSXAFT.js → chunk-WGQO4WDJ.js} +3 -2
- package/dist/chunk-WGQO4WDJ.js.map +1 -0
- package/dist/{chunk-VCC4S6JU.js → chunk-ZPAJL7KG.js} +28 -21
- package/dist/chunk-ZPAJL7KG.js.map +1 -0
- package/dist/{copy-context-pDogTR4x.d.ts → copy-context-Dp5hvj5W.d.ts} +8 -1
- package/dist/index.cjs +19 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -2
- package/dist/index.d.ts +23 -2
- package/dist/index.js +19 -7
- package/dist/index.js.map +1 -1
- package/dist/ui/admin/index.d.ts +2 -2
- package/dist/ui/admin/index.js +2 -2
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +3 -3
- package/dist/ui/member/index.d.ts +2 -2
- package/dist/ui/member/index.js +2 -2
- package/dist/worker/index.cjs +97 -86
- package/dist/worker/index.cjs.map +1 -1
- package/dist/worker/index.d.cts +8 -1
- package/dist/worker/index.d.ts +8 -1
- package/dist/worker/index.js +97 -86
- package/dist/worker/index.js.map +1 -1
- package/package.json +1 -1
- package/runbooks/adopt-existing.md +1 -1
- package/runbooks/greenfield.md +3 -3
- package/dist/chunk-NTZSXAFT.js.map +0 -1
- package/dist/chunk-OYXNI6VR.js.map +0 -1
- package/dist/chunk-VCC4S6JU.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -21,7 +21,14 @@ interface ChapterCopy {
|
|
|
21
21
|
join: {
|
|
22
22
|
form: TextFields<"submit" | "submitting" | "submitFailed" | "unexpectedFailure">;
|
|
23
23
|
booking: TextFields<"unavailable" | "loadFailed" | "slotTaken" | "failed" | "loading" | "book" | "booking">;
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* `consent` is the affirmative statement a member agrees to before the card
|
|
26
|
+
* form appears, rendered beside the checkbox and beneath the policy text.
|
|
27
|
+
* It is what the member is shown at the moment of consent, so it says they
|
|
28
|
+
* agree rather than merely restating the policy. Set it to an empty string
|
|
29
|
+
* to render the checkbox with the policy as its only label.
|
|
30
|
+
*/
|
|
31
|
+
payment: TextFields<"setupFailed" | "preparing" | "pending" | "processing" | "payAndContinue" | "incomplete" | "consent">;
|
|
25
32
|
done: TextFields<"label" | "calendarInvite" | "memberArea">;
|
|
26
33
|
};
|
|
27
34
|
members: {
|
|
@@ -521,6 +528,20 @@ interface ChapterIntegrationDescriptor {
|
|
|
521
528
|
path: string;
|
|
522
529
|
expectedStatus: number;
|
|
523
530
|
}>;
|
|
531
|
+
/** Runbooks that bear on THIS chapter's role, so tooling can point at the
|
|
532
|
+
* right procedure without the operator knowing it exists. A chapter declaring
|
|
533
|
+
* `network.targets` is a leader hub; one declaring none is a follower site,
|
|
534
|
+
* and the two follow different procedures for the same words ("connect",
|
|
535
|
+
* "share records"). */
|
|
536
|
+
runbooks: ChapterRunbookHints;
|
|
537
|
+
}
|
|
538
|
+
/** Which runbooks apply, and why. */
|
|
539
|
+
interface ChapterRunbookHints {
|
|
540
|
+
role: "leader" | "follower";
|
|
541
|
+
/** Platform runbook slugs, most relevant first. */
|
|
542
|
+
slugs: string[];
|
|
543
|
+
/** One line a human or agent can act on. */
|
|
544
|
+
guidance: string;
|
|
524
545
|
}
|
|
525
546
|
/**
|
|
526
547
|
* Build the one CLI-consumable integration for a chapter/hub: the crm_*
|
|
@@ -1470,4 +1491,4 @@ type ApplicationBookingPatch = {
|
|
|
1470
1491
|
* already there (never backward). */
|
|
1471
1492
|
declare function applicationBookingUpdate(currentStatus: string, startAt: number, htmlLink?: string | null): ApplicationBookingPatch;
|
|
1472
1493
|
|
|
1473
|
-
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 ChapterNetworkTarget, type ChapterOperations, type ChapterPipeline, type ChapterPolicy, type ChapterPrices, type ChapterScheduling, type ChapterSends, type ClerkInviteInput, 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 LiveEvent, type MailSender, type MeetingForReconcile, type MeetingRecord, type MeetingReschedulePatch, type MemberApplication, type MemberSession, type NewMeetingRow, type NotifyDeps, type NotifyInput, type NotifyResult, type PaymentsGroup, type ProjectionDeps, type ReconcileDecision, type ResolvedApplication, type ResolvedAuth, type ResolvedNetwork, 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 StripeEvent, type StripeResult, type SubmitResult, type WebhookEvent, applicantProfile, applicationBookingUpdate, applicationSummary, backfillCrm, bookingDecision, brandTokens, bucketSeries, buildGroupSeed, canApprove, canBook, canChangeRole, canTransition, canceledPatch, chapterBrandFromTokens, chapterDb, clampArray, clerkGetUser, clerkGetUserByEmail, clerkIntegration, clerkInviteRequest, clerkListUsers, clerkSetRole, clerkUserRequest, createChapterIntegration, createClerkInvitation, createClerkUser, dashboardMetricData, defaultCrm, defineChapter, emailGroupFrom, endForSlot, findApplicationRef, firstPaymentPatch, formatChapterCopy, getVaultSecret, hasDisclaimerAck, introIdempotencyKey, isAdminRole, isAlreadySent, isReconcilable, isSlotAvailable, isValidEmail, joinConfig, meetingCreateRow, meetingRescheduleUpdate, memberApplication, memberSession, networkSourceTag, normalizeSharedRecord, normalizeWebhookEvent, paymentsReady, personInputFromApp, planDelivery, projectApplicant, projectSharedRecord, reconcileMeetings, refundedPatch, render, renderSummary, renderTemplateBody, renewalPatch, resolveApplication, resolveAuth, resolveChapterCopy, resolvePipeline, resolveScheduling, roleFromClaim, sendTemplated, sharedPersonInput, sharedRecordFromCrm, slotWindow, stageIndex, stripeCall, stripeForm, subAnnualCents, submitApplication, subscriptionIdempotencyKey, syncApplicationToCrm, validateScheduling, verifyStripeSignature, webhookMutationId };
|
|
1494
|
+
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 ChapterNetworkTarget, type ChapterOperations, type ChapterPipeline, type ChapterPolicy, type ChapterPrices, type ChapterRunbookHints, type ChapterScheduling, type ChapterSends, type ClerkInviteInput, 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 LiveEvent, type MailSender, type MeetingForReconcile, type MeetingRecord, type MeetingReschedulePatch, type MemberApplication, type MemberSession, type NewMeetingRow, type NotifyDeps, type NotifyInput, type NotifyResult, type PaymentsGroup, type ProjectionDeps, type ReconcileDecision, type ResolvedApplication, type ResolvedAuth, type ResolvedNetwork, 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 StripeEvent, type StripeResult, type SubmitResult, type WebhookEvent, applicantProfile, applicationBookingUpdate, applicationSummary, backfillCrm, bookingDecision, brandTokens, bucketSeries, buildGroupSeed, canApprove, canBook, canChangeRole, canTransition, canceledPatch, chapterBrandFromTokens, chapterDb, clampArray, clerkGetUser, clerkGetUserByEmail, clerkIntegration, clerkInviteRequest, clerkListUsers, clerkSetRole, clerkUserRequest, createChapterIntegration, createClerkInvitation, createClerkUser, dashboardMetricData, defaultCrm, defineChapter, emailGroupFrom, endForSlot, findApplicationRef, firstPaymentPatch, formatChapterCopy, getVaultSecret, hasDisclaimerAck, introIdempotencyKey, isAdminRole, isAlreadySent, isReconcilable, isSlotAvailable, isValidEmail, joinConfig, meetingCreateRow, meetingRescheduleUpdate, memberApplication, memberSession, networkSourceTag, normalizeSharedRecord, normalizeWebhookEvent, paymentsReady, personInputFromApp, planDelivery, projectApplicant, projectSharedRecord, reconcileMeetings, refundedPatch, render, renderSummary, renderTemplateBody, renewalPatch, resolveApplication, resolveAuth, resolveChapterCopy, resolvePipeline, resolveScheduling, roleFromClaim, sendTemplated, sharedPersonInput, sharedRecordFromCrm, slotWindow, stageIndex, stripeCall, stripeForm, subAnnualCents, submitApplication, subscriptionIdempotencyKey, syncApplicationToCrm, validateScheduling, verifyStripeSignature, webhookMutationId };
|
package/dist/index.d.ts
CHANGED
|
@@ -21,7 +21,14 @@ interface ChapterCopy {
|
|
|
21
21
|
join: {
|
|
22
22
|
form: TextFields<"submit" | "submitting" | "submitFailed" | "unexpectedFailure">;
|
|
23
23
|
booking: TextFields<"unavailable" | "loadFailed" | "slotTaken" | "failed" | "loading" | "book" | "booking">;
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* `consent` is the affirmative statement a member agrees to before the card
|
|
26
|
+
* form appears, rendered beside the checkbox and beneath the policy text.
|
|
27
|
+
* It is what the member is shown at the moment of consent, so it says they
|
|
28
|
+
* agree rather than merely restating the policy. Set it to an empty string
|
|
29
|
+
* to render the checkbox with the policy as its only label.
|
|
30
|
+
*/
|
|
31
|
+
payment: TextFields<"setupFailed" | "preparing" | "pending" | "processing" | "payAndContinue" | "incomplete" | "consent">;
|
|
25
32
|
done: TextFields<"label" | "calendarInvite" | "memberArea">;
|
|
26
33
|
};
|
|
27
34
|
members: {
|
|
@@ -521,6 +528,20 @@ interface ChapterIntegrationDescriptor {
|
|
|
521
528
|
path: string;
|
|
522
529
|
expectedStatus: number;
|
|
523
530
|
}>;
|
|
531
|
+
/** Runbooks that bear on THIS chapter's role, so tooling can point at the
|
|
532
|
+
* right procedure without the operator knowing it exists. A chapter declaring
|
|
533
|
+
* `network.targets` is a leader hub; one declaring none is a follower site,
|
|
534
|
+
* and the two follow different procedures for the same words ("connect",
|
|
535
|
+
* "share records"). */
|
|
536
|
+
runbooks: ChapterRunbookHints;
|
|
537
|
+
}
|
|
538
|
+
/** Which runbooks apply, and why. */
|
|
539
|
+
interface ChapterRunbookHints {
|
|
540
|
+
role: "leader" | "follower";
|
|
541
|
+
/** Platform runbook slugs, most relevant first. */
|
|
542
|
+
slugs: string[];
|
|
543
|
+
/** One line a human or agent can act on. */
|
|
544
|
+
guidance: string;
|
|
524
545
|
}
|
|
525
546
|
/**
|
|
526
547
|
* Build the one CLI-consumable integration for a chapter/hub: the crm_*
|
|
@@ -1470,4 +1491,4 @@ type ApplicationBookingPatch = {
|
|
|
1470
1491
|
* already there (never backward). */
|
|
1471
1492
|
declare function applicationBookingUpdate(currentStatus: string, startAt: number, htmlLink?: string | null): ApplicationBookingPatch;
|
|
1472
1493
|
|
|
1473
|
-
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 ChapterNetworkTarget, type ChapterOperations, type ChapterPipeline, type ChapterPolicy, type ChapterPrices, type ChapterScheduling, type ChapterSends, type ClerkInviteInput, 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 LiveEvent, type MailSender, type MeetingForReconcile, type MeetingRecord, type MeetingReschedulePatch, type MemberApplication, type MemberSession, type NewMeetingRow, type NotifyDeps, type NotifyInput, type NotifyResult, type PaymentsGroup, type ProjectionDeps, type ReconcileDecision, type ResolvedApplication, type ResolvedAuth, type ResolvedNetwork, 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 StripeEvent, type StripeResult, type SubmitResult, type WebhookEvent, applicantProfile, applicationBookingUpdate, applicationSummary, backfillCrm, bookingDecision, brandTokens, bucketSeries, buildGroupSeed, canApprove, canBook, canChangeRole, canTransition, canceledPatch, chapterBrandFromTokens, chapterDb, clampArray, clerkGetUser, clerkGetUserByEmail, clerkIntegration, clerkInviteRequest, clerkListUsers, clerkSetRole, clerkUserRequest, createChapterIntegration, createClerkInvitation, createClerkUser, dashboardMetricData, defaultCrm, defineChapter, emailGroupFrom, endForSlot, findApplicationRef, firstPaymentPatch, formatChapterCopy, getVaultSecret, hasDisclaimerAck, introIdempotencyKey, isAdminRole, isAlreadySent, isReconcilable, isSlotAvailable, isValidEmail, joinConfig, meetingCreateRow, meetingRescheduleUpdate, memberApplication, memberSession, networkSourceTag, normalizeSharedRecord, normalizeWebhookEvent, paymentsReady, personInputFromApp, planDelivery, projectApplicant, projectSharedRecord, reconcileMeetings, refundedPatch, render, renderSummary, renderTemplateBody, renewalPatch, resolveApplication, resolveAuth, resolveChapterCopy, resolvePipeline, resolveScheduling, roleFromClaim, sendTemplated, sharedPersonInput, sharedRecordFromCrm, slotWindow, stageIndex, stripeCall, stripeForm, subAnnualCents, submitApplication, subscriptionIdempotencyKey, syncApplicationToCrm, validateScheduling, verifyStripeSignature, webhookMutationId };
|
|
1494
|
+
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 ChapterNetworkTarget, type ChapterOperations, type ChapterPipeline, type ChapterPolicy, type ChapterPrices, type ChapterRunbookHints, type ChapterScheduling, type ChapterSends, type ClerkInviteInput, 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 LiveEvent, type MailSender, type MeetingForReconcile, type MeetingRecord, type MeetingReschedulePatch, type MemberApplication, type MemberSession, type NewMeetingRow, type NotifyDeps, type NotifyInput, type NotifyResult, type PaymentsGroup, type ProjectionDeps, type ReconcileDecision, type ResolvedApplication, type ResolvedAuth, type ResolvedNetwork, 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 StripeEvent, type StripeResult, type SubmitResult, type WebhookEvent, applicantProfile, applicationBookingUpdate, applicationSummary, backfillCrm, bookingDecision, brandTokens, bucketSeries, buildGroupSeed, canApprove, canBook, canChangeRole, canTransition, canceledPatch, chapterBrandFromTokens, chapterDb, clampArray, clerkGetUser, clerkGetUserByEmail, clerkIntegration, clerkInviteRequest, clerkListUsers, clerkSetRole, clerkUserRequest, createChapterIntegration, createClerkInvitation, createClerkUser, dashboardMetricData, defaultCrm, defineChapter, emailGroupFrom, endForSlot, findApplicationRef, firstPaymentPatch, formatChapterCopy, getVaultSecret, hasDisclaimerAck, introIdempotencyKey, isAdminRole, isAlreadySent, isReconcilable, isSlotAvailable, isValidEmail, joinConfig, meetingCreateRow, meetingRescheduleUpdate, memberApplication, memberSession, networkSourceTag, normalizeSharedRecord, normalizeWebhookEvent, paymentsReady, personInputFromApp, planDelivery, projectApplicant, projectSharedRecord, reconcileMeetings, refundedPatch, render, renderSummary, renderTemplateBody, renewalPatch, resolveApplication, resolveAuth, resolveChapterCopy, resolvePipeline, resolveScheduling, roleFromClaim, sendTemplated, sharedPersonInput, sharedRecordFromCrm, slotWindow, stageIndex, stripeCall, stripeForm, subAnnualCents, submitApplication, subscriptionIdempotencyKey, syncApplicationToCrm, validateScheduling, verifyStripeSignature, webhookMutationId };
|
package/dist/index.js
CHANGED
|
@@ -687,7 +687,8 @@ var DEFAULT_JOIN_COPY = {
|
|
|
687
687
|
pending: "Confirming your payment\u2026",
|
|
688
688
|
processing: "Processing\u2026",
|
|
689
689
|
payAndContinue: "Pay and continue",
|
|
690
|
-
incomplete: "The payment did not complete. Please try again."
|
|
690
|
+
incomplete: "The payment did not complete. Please try again.",
|
|
691
|
+
consent: "I have read and agree to the pricing and refund policy above."
|
|
691
692
|
},
|
|
692
693
|
done: {
|
|
693
694
|
label: "You're booked",
|
|
@@ -949,6 +950,16 @@ function createChapterIntegration(chapter, options = {}) {
|
|
|
949
950
|
if (group) {
|
|
950
951
|
seeds.push({ id: "group", ns: "groups", key: { attr: "id", value: chapter.id }, attrs: { ...group, createdAt: now } });
|
|
951
952
|
}
|
|
953
|
+
const isLeader = (chapter.config.network?.targets?.length ?? 0) > 0;
|
|
954
|
+
const runbooks = isLeader ? {
|
|
955
|
+
role: "leader",
|
|
956
|
+
slugs: ["chapter-leader", "chapter-network", "crm"],
|
|
957
|
+
guidance: `${chapter.name} is a LEADER hub: it holds the CRM and shares records with its chapters. Read it with \`odla-ai runbook get chapter-leader\`.`
|
|
958
|
+
} : {
|
|
959
|
+
role: "follower",
|
|
960
|
+
slugs: ["chapter-follower", "chapter-network"],
|
|
961
|
+
guidance: `${chapter.name} is a FOLLOWER site: it receives people and records from a leader hub. Read it with \`odla-ai runbook get chapter-follower\`.`
|
|
962
|
+
};
|
|
952
963
|
return {
|
|
953
964
|
id: "chapter",
|
|
954
965
|
title: `Chapter: ${chapter.name}`,
|
|
@@ -959,7 +970,8 @@ function createChapterIntegration(chapter, options = {}) {
|
|
|
959
970
|
},
|
|
960
971
|
rules: { ...crmDesc.rules, ...chapter.rules },
|
|
961
972
|
seeds,
|
|
962
|
-
probes: [...crmDesc.probes ?? []]
|
|
973
|
+
probes: [...crmDesc.probes ?? []],
|
|
974
|
+
runbooks
|
|
963
975
|
};
|
|
964
976
|
}
|
|
965
977
|
|
|
@@ -1346,7 +1358,7 @@ function billingColumns(app) {
|
|
|
1346
1358
|
async function syncApplicationToCrm(deps, opts) {
|
|
1347
1359
|
const emailKey = str(opts.app.email).toLowerCase();
|
|
1348
1360
|
if (!emailKey) return null;
|
|
1349
|
-
const
|
|
1361
|
+
const recordDeps = { crm: deps.crm, db: deps.db, now: deps.now, newId: deps.newId };
|
|
1350
1362
|
const input = personInputFromApp(deps.chapter, opts.app);
|
|
1351
1363
|
const { crm_record } = await deps.db.query({
|
|
1352
1364
|
crm_record: { $: { where: { type: "person", primaryEmail: emailKey }, limit: 1 } }
|
|
@@ -1356,16 +1368,16 @@ async function syncApplicationToCrm(deps, opts) {
|
|
|
1356
1368
|
let recordId;
|
|
1357
1369
|
if (existing && typeof existing.id === "string") {
|
|
1358
1370
|
recordId = existing.id;
|
|
1359
|
-
await updateRecord2(
|
|
1371
|
+
await updateRecord2(recordDeps, { id: recordId, input });
|
|
1360
1372
|
} else {
|
|
1361
|
-
const created = await createRecord2(
|
|
1373
|
+
const created = await createRecord2(recordDeps, { type: "person", input, ...stage ? { stage } : {} });
|
|
1362
1374
|
recordId = created.id;
|
|
1363
1375
|
}
|
|
1364
1376
|
if (existing && stage && existing.stage !== stage) {
|
|
1365
|
-
await setStage(
|
|
1377
|
+
await setStage(recordDeps, { id: recordId, to: stage, authorId: "system", mutationId: `crm:stage:${recordId}:${stage}` }).catch(() => void 0);
|
|
1366
1378
|
}
|
|
1367
1379
|
await deps.db.transact([{ t: "update", ns: "crm_record", id: recordId, attrs: billingColumns(opts.app) }]);
|
|
1368
|
-
await linkIdentity(
|
|
1380
|
+
await linkIdentity(recordDeps, { recordId, email: emailKey, mutationId: `crm:link:${recordId}:${emailKey}` }).catch(() => void 0);
|
|
1369
1381
|
return recordId;
|
|
1370
1382
|
}
|
|
1371
1383
|
async function backfillCrm(deps) {
|