@simplelayer/graniteer-core 0.2.2 → 0.2.3
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/adminBookingCredit.d.ts +107 -0
- package/dist/adminBookingCredit.js +163 -0
- package/dist/agreementCheckout.d.ts +34 -0
- package/dist/agreementCheckout.js +211 -0
- package/dist/agreementPortalEmail.d.ts +15 -0
- package/dist/agreementPortalEmail.js +107 -0
- package/dist/availability.d.ts +51 -0
- package/dist/availability.js +152 -0
- package/dist/billingPortalLinkEmail.d.ts +14 -0
- package/dist/billingPortalLinkEmail.js +98 -0
- package/dist/bookingAgreementEmail.d.ts +23 -0
- package/dist/bookingAgreementEmail.js +116 -0
- package/dist/bookingEffects.d.ts +84 -0
- package/dist/bookingEffects.js +309 -0
- package/dist/bookingHoldReclaim.d.ts +16 -0
- package/dist/bookingHoldReclaim.js +74 -0
- package/dist/busClient.d.ts +44 -0
- package/dist/busClient.js +196 -0
- package/dist/busSignature.d.ts +19 -0
- package/{src/busSignature.ts → dist/busSignature.js} +64 -71
- package/dist/checkoutCoupon.d.ts +156 -0
- package/dist/checkoutCoupon.js +369 -0
- package/dist/checkoutSessionParams.d.ts +19 -0
- package/dist/checkoutSessionParams.js +36 -0
- package/dist/commonsContract.d.ts +70 -0
- package/dist/commonsContract.js +142 -0
- package/dist/commonsDeposit.d.ts +78 -0
- package/dist/commonsDeposit.js +199 -0
- package/dist/commonsDepositWebhook.d.ts +37 -0
- package/dist/commonsDepositWebhook.js +147 -0
- package/dist/conductorAdmin.d.ts +76 -0
- package/dist/conductorAdmin.js +88 -0
- package/dist/dayPassConfirmation.d.ts +17 -0
- package/dist/dayPassConfirmation.js +187 -0
- package/dist/dunningEmails.d.ts +40 -0
- package/dist/dunningEmails.js +174 -0
- package/dist/email-templates/brand.d.ts +82 -0
- package/dist/email-templates/brand.js +72 -0
- package/dist/email-templates/email-change.d.ts +10 -0
- package/dist/email-templates/email-change.js +50 -0
- package/dist/email-templates/invite.d.ts +8 -0
- package/dist/email-templates/invite.js +44 -0
- package/dist/email-templates/magic-link.d.ts +10 -0
- package/dist/email-templates/magic-link.js +26 -0
- package/dist/email-templates/reauthentication.d.ts +6 -0
- package/dist/email-templates/reauthentication.js +35 -0
- package/dist/email-templates/recovery.d.ts +10 -0
- package/dist/email-templates/recovery.js +26 -0
- package/dist/email-templates/signup.d.ts +12 -0
- package/dist/email-templates/signup.js +30 -0
- package/dist/functions/admin-cancel-membership.d.ts +1 -0
- package/dist/functions/admin-cancel-membership.js +286 -0
- package/dist/functions/admin-change-membership-plan.d.ts +1 -0
- package/dist/functions/admin-change-membership-plan.js +281 -0
- package/dist/functions/admin-charge-guest-print.d.ts +1 -0
- package/dist/functions/admin-charge-guest-print.js +227 -0
- package/dist/functions/admin-correct-booking.d.ts +1 -0
- package/dist/functions/admin-correct-booking.js +326 -0
- package/dist/functions/admin-create-booking.d.ts +43 -0
- package/dist/functions/admin-create-booking.js +410 -0
- package/dist/functions/admin-create-commons-event.d.ts +1 -0
- package/dist/functions/admin-create-commons-event.js +237 -0
- package/dist/functions/admin-debug-boldsign-doc.d.ts +1 -0
- package/dist/functions/admin-debug-boldsign-doc.js +110 -0
- package/dist/functions/admin-door-write.d.ts +1 -0
- package/dist/functions/admin-door-write.js +267 -0
- package/dist/functions/admin-issue-day-pass.d.ts +14 -0
- package/dist/functions/admin-issue-day-pass.js +213 -0
- package/dist/functions/admin-mark-booking-paid.d.ts +1 -0
- package/dist/functions/admin-mark-booking-paid.js +202 -0
- package/dist/functions/admin-mint-billing-portal-link.d.ts +6 -0
- package/dist/functions/admin-mint-billing-portal-link.js +159 -0
- package/dist/functions/admin-mint-portal-link.d.ts +3 -0
- package/dist/functions/admin-mint-portal-link.js +54 -0
- package/dist/functions/admin-photo-upload.d.ts +1 -0
- package/dist/functions/admin-photo-upload.js +104 -0
- package/dist/functions/admin-remove-team-member.d.ts +1 -0
- package/dist/functions/admin-remove-team-member.js +140 -0
- package/dist/functions/admin-request-trial.d.ts +5 -0
- package/dist/functions/admin-request-trial.js +349 -0
- package/dist/functions/admin-resend-commons-deposit-link.d.ts +7 -0
- package/dist/functions/admin-resend-commons-deposit-link.js +298 -0
- package/dist/functions/admin-reset-mfa.d.ts +1 -0
- package/dist/functions/admin-reset-mfa.js +129 -0
- package/dist/functions/admin-retry-invoice-payment.d.ts +76 -0
- package/dist/functions/admin-retry-invoice-payment.js +269 -0
- package/dist/functions/admin-reverse-coupon-redemption.d.ts +1 -0
- package/dist/functions/admin-reverse-coupon-redemption.js +91 -0
- package/dist/functions/admin-revoke-agreement.d.ts +4 -0
- package/dist/functions/admin-revoke-agreement.js +410 -0
- package/dist/functions/admin-send-commons-agreement.d.ts +1 -0
- package/dist/functions/admin-send-commons-agreement.js +212 -0
- package/dist/functions/admin-set-credit-amount.d.ts +1 -0
- package/dist/functions/admin-set-credit-amount.js +112 -0
- package/dist/functions/admin-skip-commons-contract.d.ts +1 -0
- package/dist/functions/admin-skip-commons-contract.js +170 -0
- package/dist/functions/admin-undo-membership-cancel.d.ts +1 -0
- package/dist/functions/admin-undo-membership-cancel.js +135 -0
- package/dist/functions/admin-wall-photo-write.d.ts +1 -0
- package/dist/functions/admin-wall-photo-write.js +137 -0
- package/dist/functions/auth-email-hook.d.ts +20 -0
- package/dist/functions/auth-email-hook.js +209 -0
- package/dist/functions/boldsign-sender-identity.d.ts +1 -0
- package/dist/functions/boldsign-sender-identity.js +109 -0
- package/dist/functions/booking-availability.d.ts +1 -0
- package/dist/functions/booking-availability.js +355 -0
- package/dist/functions/booking-member-preview.d.ts +1 -0
- package/dist/functions/booking-member-preview.js +123 -0
- package/dist/functions/booking-status.d.ts +3 -0
- package/dist/functions/booking-status.js +139 -0
- package/dist/functions/conductor.d.ts +3 -0
- package/dist/functions/conductor.js +451 -0
- package/dist/functions/create-agreement.d.ts +8 -0
- package/dist/functions/create-agreement.js +498 -0
- package/dist/functions/create-booking.d.ts +44 -0
- package/dist/functions/create-booking.js +538 -0
- package/dist/functions/create-day-pass-checkout.d.ts +4 -0
- package/dist/functions/create-day-pass-checkout.js +196 -0
- package/dist/functions/create-portal-session.d.ts +4 -0
- package/dist/functions/create-portal-session.js +127 -0
- package/dist/functions/create-subscription-checkout.d.ts +4 -0
- package/dist/functions/create-subscription-checkout.js +394 -0
- package/dist/functions/day-pass-status.d.ts +1 -0
- package/dist/functions/day-pass-status.js +70 -0
- package/dist/functions/dayStatus.d.ts +15 -0
- package/dist/functions/dayStatus.js +59 -0
- package/dist/functions/diag-webpush-test.d.ts +1 -0
- package/dist/functions/diag-webpush-test.js +42 -0
- package/dist/functions/event-access-admin.d.ts +17 -0
- package/dist/functions/event-access-admin.js +262 -0
- package/dist/functions/event-access-store.d.ts +1 -0
- package/dist/functions/event-access-store.js +343 -0
- package/dist/functions/ezeep-print-webhook.d.ts +1 -0
- package/dist/functions/ezeep-print-webhook.js +160 -0
- package/dist/functions/ezeep-usage-reconcile.d.ts +1 -0
- package/dist/functions/ezeep-usage-reconcile.js +305 -0
- package/dist/functions/fetch-avatar-original.d.ts +3 -0
- package/dist/functions/fetch-avatar-original.js +423 -0
- package/dist/functions/get-provider-sign-link.d.ts +3 -0
- package/dist/functions/get-provider-sign-link.js +146 -0
- package/dist/functions/get-signing-link.d.ts +1 -0
- package/dist/functions/get-signing-link.js +192 -0
- package/dist/functions/guest-print-setup-confirm.d.ts +1 -0
- package/dist/functions/guest-print-setup-confirm.js +126 -0
- package/dist/functions/guest-print-submit.d.ts +1 -0
- package/dist/functions/guest-print-submit.js +145 -0
- package/dist/functions/luma-webhook.d.ts +1 -0
- package/dist/functions/luma-webhook.js +123 -0
- package/dist/functions/manage-booking.d.ts +75 -0
- package/dist/functions/manage-booking.js +409 -0
- package/dist/functions/mcp.d.ts +16 -0
- package/dist/functions/mcp.js +51 -0
- package/dist/functions/member-door-action.d.ts +60 -0
- package/dist/functions/member-door-action.js +774 -0
- package/dist/functions/member-unifi-mapping.d.ts +15 -0
- package/dist/functions/member-unifi-mapping.js +198 -0
- package/dist/functions/membership-door-sync.d.ts +14 -0
- package/dist/functions/membership-door-sync.js +863 -0
- package/dist/functions/migration-collision-alert.copy.d.ts +7 -0
- package/dist/functions/migration-collision-alert.copy.js +207 -0
- package/dist/functions/migration-collision-alert.d.ts +7 -0
- package/dist/functions/migration-collision-alert.js +207 -0
- package/dist/functions/office-assignment-end.d.ts +12 -0
- package/dist/functions/office-assignment-end.js +140 -0
- package/dist/functions/portal-booking-access.d.ts +22 -0
- package/dist/functions/portal-booking-access.js +163 -0
- package/dist/functions/portal-list-invoices.d.ts +1 -0
- package/dist/functions/portal-list-invoices.js +90 -0
- package/dist/functions/portal-request-login.d.ts +7 -0
- package/dist/functions/portal-request-login.js +199 -0
- package/dist/functions/portal-resend-invite.d.ts +6 -0
- package/dist/functions/portal-resend-invite.js +225 -0
- package/dist/functions/portal-submit-event.d.ts +4 -0
- package/dist/functions/portal-submit-event.js +152 -0
- package/dist/functions/print-billing-recover.d.ts +1 -0
- package/dist/functions/print-billing-recover.js +83 -0
- package/dist/functions/print-billing-run.d.ts +1 -0
- package/dist/functions/print-billing-run.js +153 -0
- package/dist/functions/public-facts.d.ts +1 -0
- package/dist/functions/public-facts.js +141 -0
- package/dist/functions/push-send.d.ts +3 -0
- package/dist/functions/push-send.js +297 -0
- package/dist/functions/push-test.d.ts +3 -0
- package/dist/functions/push-test.js +215 -0
- package/dist/functions/request-portal-link.d.ts +7 -0
- package/dist/functions/request-portal-link.js +178 -0
- package/dist/functions/reschedule-booking.d.ts +50 -0
- package/dist/functions/reschedule-booking.js +571 -0
- package/dist/functions/review-ratings.d.ts +1 -0
- package/dist/functions/review-ratings.js +95 -0
- package/dist/functions/space-availability-range.d.ts +1 -0
- package/dist/functions/space-availability-range.js +109 -0
- package/dist/functions/stripe-db-reconcile.d.ts +3 -0
- package/dist/functions/stripe-db-reconcile.js +314 -0
- package/dist/functions/stripe-webhook.d.ts +46 -0
- package/dist/functions/stripe-webhook.js +2367 -0
- package/dist/functions/sync-gcal-blackouts.d.ts +1 -0
- package/dist/functions/sync-gcal-blackouts.js +251 -0
- package/dist/functions/timetable-event-register.d.ts +1 -0
- package/dist/functions/timetable-event-register.js +155 -0
- package/dist/functions/timetable-event-status.d.ts +1 -0
- package/dist/functions/timetable-event-status.js +86 -0
- package/dist/functions/timetable-spaces.d.ts +1 -0
- package/dist/functions/timetable-spaces.js +161 -0
- package/dist/functions/touch-pass-reconciler.d.ts +1 -0
- package/dist/functions/touch-pass-reconciler.js +688 -0
- package/dist/functions/touch-pass-signup.d.ts +1 -0
- package/dist/functions/touch-pass-signup.js +447 -0
- package/dist/functions/upload-booking-display-image.d.ts +4 -0
- package/dist/functions/upload-booking-display-image.js +159 -0
- package/dist/functions/virtual-onboarding-purge.d.ts +1 -0
- package/dist/functions/virtual-onboarding-purge.js +123 -0
- package/dist/functions/virtual-onboarding-submit.d.ts +1 -0
- package/dist/functions/virtual-onboarding-submit.js +303 -0
- package/dist/functions/voice-booking.d.ts +10 -0
- package/dist/functions/voice-booking.js +360 -0
- package/dist/functions/voice-day-pass.d.ts +15 -0
- package/dist/functions/voice-day-pass.js +269 -0
- package/dist/functions/voice-inquiry.d.ts +1 -0
- package/dist/functions/voice-inquiry.js +156 -0
- package/dist/functions/voice-membership-signup.d.ts +15 -0
- package/dist/functions/voice-membership-signup.js +273 -0
- package/dist/functions/voice-tour-availability.d.ts +1 -0
- package/dist/functions/voice-tour-availability.js +179 -0
- package/dist/functions/voice-tour-booking.d.ts +21 -0
- package/dist/functions/voice-tour-booking.js +308 -0
- package/dist/gcalSync.d.ts +29 -0
- package/dist/gcalSync.js +119 -0
- package/dist/ghlEventInquiry.d.ts +16 -0
- package/dist/ghlEventInquiry.js +116 -0
- package/dist/ghlNote.d.ts +5 -0
- package/dist/ghlNote.js +29 -0
- package/dist/ghlTask.d.ts +7 -0
- package/dist/ghlTask.js +39 -0
- package/dist/ghlVoiceInquiry.d.ts +26 -0
- package/dist/ghlVoiceInquiry.js +68 -0
- package/dist/guestPrintCapture.d.ts +217 -0
- package/dist/guestPrintCapture.js +362 -0
- package/dist/index.d.ts +3 -0
- package/{index.js → dist/index.js} +3 -2
- package/dist/lumaGhl.d.ts +19 -0
- package/dist/lumaGhl.js +147 -0
- package/dist/mailArrivalEmail.d.ts +15 -0
- package/dist/mailArrivalEmail.js +99 -0
- package/dist/manageToken.d.ts +64 -0
- package/dist/manageToken.js +261 -0
- package/dist/membership.d.ts +20 -0
- package/dist/membership.js +87 -0
- package/dist/membershipBusClient.d.ts +139 -0
- package/dist/membershipBusClient.js +443 -0
- package/dist/membershipWelcome.d.ts +117 -0
- package/dist/membershipWelcome.js +497 -0
- package/dist/migrationCheckout.d.ts +169 -0
- package/dist/migrationCheckout.js +250 -0
- package/dist/money.d.ts +20 -0
- package/dist/money.js +35 -0
- package/dist/ops.d.ts +27 -0
- package/dist/ops.js +87 -0
- package/dist/pacificDate.d.ts +8 -0
- package/{src/pacificDate.ts → dist/pacificDate.js} +76 -88
- package/dist/paymentLinkEmail.d.ts +15 -0
- package/dist/paymentLinkEmail.js +102 -0
- package/dist/policyAcknowledgment.d.ts +46 -0
- package/dist/policyAcknowledgment.js +58 -0
- package/dist/portalSession.d.ts +15 -0
- package/dist/portalSession.js +31 -0
- package/dist/pricing.d.ts +306 -0
- package/dist/pricing.js +788 -0
- package/dist/printBilling.d.ts +340 -0
- package/dist/printBilling.js +619 -0
- package/dist/printBillingAdapters.d.ts +29 -0
- package/dist/printBillingAdapters.js +130 -0
- package/dist/printCorrections.d.ts +175 -0
- package/dist/printCorrections.js +328 -0
- package/dist/rateLimit.d.ts +20 -0
- package/dist/rateLimit.js +70 -0
- package/dist/referralCredits.d.ts +5 -0
- package/{src/referralCredits.ts → dist/referralCredits.js} +27 -34
- package/dist/referralGrant.d.ts +49 -0
- package/dist/referralGrant.js +268 -0
- package/dist/rescheduleCredit.d.ts +98 -0
- package/dist/rescheduleCredit.js +263 -0
- package/dist/reservationWifiCode.d.ts +19 -0
- package/{src/reservationWifiCode.ts → dist/reservationWifiCode.js} +67 -81
- package/dist/retellCallAnalyzed.d.ts +18 -0
- package/dist/retellCallAnalyzed.js +91 -0
- package/dist/retellSignature.d.ts +14 -0
- package/dist/retellSignature.js +60 -0
- package/dist/signedUnpaidReminderEmail.d.ts +15 -0
- package/dist/signedUnpaidReminderEmail.js +111 -0
- package/dist/slackAlert.d.ts +13 -0
- package/dist/slackAlert.js +37 -0
- package/dist/stripeCoworkingPortal.d.ts +21 -0
- package/dist/stripeCoworkingPortal.js +80 -0
- package/dist/supabaseTestFakes.d.ts +67 -0
- package/dist/supabaseTestFakes.js +79 -0
- package/dist/supportTicketEmail.d.ts +16 -0
- package/dist/supportTicketEmail.js +98 -0
- package/dist/tier1Agreement.d.ts +51 -0
- package/dist/tier1Agreement.js +86 -0
- package/dist/unifiAccessPolicies.d.ts +36 -0
- package/dist/unifiAccessPolicies.js +185 -0
- package/dist/unifiGroups.d.ts +26 -0
- package/dist/unifiGroups.js +106 -0
- package/package.json +645 -169
- package/src/adminBookingCredit.test.ts +0 -451
- package/src/adminBookingCredit.ts +0 -239
- package/src/agreementCheckout.ts +0 -250
- package/src/agreementPortalEmail.ts +0 -128
- package/src/availability.test.ts +0 -25
- package/src/availability.ts +0 -201
- package/src/billingPortalLinkEmail.ts +0 -117
- package/src/bookingAgreementEmail.ts +0 -149
- package/src/bookingEffects.ts +0 -388
- package/src/bookingHoldReclaim.ts +0 -94
- package/src/busClient.ts +0 -268
- package/src/checkoutCoupon.test.ts +0 -675
- package/src/checkoutCoupon.ts +0 -455
- package/src/checkoutSessionParams.ts +0 -56
- package/src/commonsContract.ts +0 -175
- package/src/commonsDeposit.ts +0 -298
- package/src/commonsDepositWebhook.ts +0 -237
- package/src/conductorAdmin.ts +0 -141
- package/src/dayPassConfirmation.ts +0 -230
- package/src/dunningEmails.test.ts +0 -263
- package/src/dunningEmails.ts +0 -203
- package/src/email-templates/brand.ts +0 -93
- package/src/email-templates/email-change.tsx +0 -92
- package/src/email-templates/invite.tsx +0 -79
- package/src/email-templates/magic-link.tsx +0 -59
- package/src/email-templates/reauthentication.tsx +0 -60
- package/src/email-templates/recovery.tsx +0 -59
- package/src/email-templates/signup.tsx +0 -67
- package/src/functions/admin-cancel-membership.ts +0 -311
- package/src/functions/admin-change-membership-plan.ts +0 -312
- package/src/functions/admin-charge-guest-print.ts +0 -229
- package/src/functions/admin-correct-booking.ts +0 -333
- package/src/functions/admin-create-booking.ts +0 -460
- package/src/functions/admin-create-commons-event.ts +0 -244
- package/src/functions/admin-debug-boldsign-doc.ts +0 -93
- package/src/functions/admin-door-write.ts +0 -272
- package/src/functions/admin-issue-day-pass.ts +0 -231
- package/src/functions/admin-mark-booking-paid.ts +0 -203
- package/src/functions/admin-mint-billing-portal-link.ts +0 -168
- package/src/functions/admin-mint-portal-link.ts +0 -62
- package/src/functions/admin-photo-upload.ts +0 -128
- package/src/functions/admin-remove-team-member.ts +0 -150
- package/src/functions/admin-request-trial.ts +0 -366
- package/src/functions/admin-resend-commons-deposit-link.ts +0 -323
- package/src/functions/admin-reset-mfa.ts +0 -138
- package/src/functions/admin-retry-invoice-payment.test.ts +0 -567
- package/src/functions/admin-retry-invoice-payment.ts +0 -333
- package/src/functions/admin-reverse-coupon-redemption.ts +0 -98
- package/src/functions/admin-revoke-agreement.ts +0 -467
- package/src/functions/admin-send-commons-agreement.ts +0 -214
- package/src/functions/admin-set-credit-amount.ts +0 -123
- package/src/functions/admin-skip-commons-contract.ts +0 -165
- package/src/functions/admin-undo-membership-cancel.ts +0 -144
- package/src/functions/admin-wall-photo-write.ts +0 -141
- package/src/functions/auth-email-hook.ts +0 -259
- package/src/functions/boldsign-sender-identity.ts +0 -114
- package/src/functions/booking-availability.ts +0 -419
- package/src/functions/booking-member-preview.ts +0 -136
- package/src/functions/booking-status.ts +0 -149
- package/src/functions/conductor.ts +0 -505
- package/src/functions/create-agreement.ts +0 -537
- package/src/functions/create-booking.ts +0 -648
- package/src/functions/create-day-pass-checkout.ts +0 -218
- package/src/functions/create-portal-session.ts +0 -142
- package/src/functions/create-subscription-checkout.test.ts +0 -222
- package/src/functions/create-subscription-checkout.ts +0 -440
- package/src/functions/day-pass-status.ts +0 -89
- package/src/functions/dayStatus.ts +0 -71
- package/src/functions/diag-webpush-test.ts +0 -45
- package/src/functions/event-access-admin.ts +0 -277
- package/src/functions/event-access-store.ts +0 -334
- package/src/functions/ezeep-print-webhook.ts +0 -213
- package/src/functions/ezeep-usage-reconcile.ts +0 -299
- package/src/functions/fetch-avatar-original.ts +0 -457
- package/src/functions/get-provider-sign-link.ts +0 -155
- package/src/functions/get-signing-link.ts +0 -211
- package/src/functions/guest-print-setup-confirm.ts +0 -128
- package/src/functions/guest-print-submit.ts +0 -149
- package/src/functions/luma-webhook.ts +0 -165
- package/src/functions/manage-booking.ts +0 -472
- package/src/functions/mcp.ts +0 -67
- package/src/functions/member-door-action.test.ts +0 -1248
- package/src/functions/member-door-action.ts +0 -863
- package/src/functions/member-unifi-mapping.test.ts +0 -516
- package/src/functions/member-unifi-mapping.ts +0 -206
- package/src/functions/membership-door-sync.ts +0 -956
- package/src/functions/migration-collision-alert.copy.ts +0 -232
- package/src/functions/migration-collision-alert.test.ts +0 -349
- package/src/functions/migration-collision-alert.ts +0 -232
- package/src/functions/office-assignment-end.ts +0 -146
- package/src/functions/portal-booking-access.ts +0 -217
- package/src/functions/portal-list-invoices.ts +0 -99
- package/src/functions/portal-request-login.ts +0 -219
- package/src/functions/portal-resend-invite.ts +0 -248
- package/src/functions/portal-submit-event.ts +0 -168
- package/src/functions/print-billing-recover.ts +0 -97
- package/src/functions/print-billing-run.ts +0 -183
- package/src/functions/public-facts.ts +0 -168
- package/src/functions/push-send.ts +0 -348
- package/src/functions/push-test.ts +0 -234
- package/src/functions/request-portal-link.ts +0 -211
- package/src/functions/reschedule-booking.ts +0 -649
- package/src/functions/review-ratings.ts +0 -113
- package/src/functions/space-availability-range.acceptance.test.ts +0 -161
- package/src/functions/space-availability-range.ts +0 -142
- package/src/functions/stripe-db-reconcile.ts +0 -319
- package/src/functions/stripe-webhook.moved-regression.test.ts +0 -78
- package/src/functions/stripe-webhook.ts +0 -2595
- package/src/functions/sync-gcal-blackouts.ts +0 -298
- package/src/functions/timetable-event-register.ts +0 -162
- package/src/functions/timetable-event-status.ts +0 -90
- package/src/functions/timetable-spaces.ts +0 -219
- package/src/functions/touch-pass-reconciler.ts +0 -689
- package/src/functions/touch-pass-signup.ts +0 -478
- package/src/functions/upload-booking-display-image.ts +0 -179
- package/src/functions/virtual-onboarding-purge.ts +0 -134
- package/src/functions/virtual-onboarding-submit.ts +0 -315
- package/src/functions/voice-booking.ts +0 -453
- package/src/functions/voice-day-pass.ts +0 -346
- package/src/functions/voice-inquiry.test.ts +0 -301
- package/src/functions/voice-inquiry.ts +0 -198
- package/src/functions/voice-membership-signup.ts +0 -355
- package/src/functions/voice-tour-availability.ts +0 -204
- package/src/functions/voice-tour-booking.ts +0 -429
- package/src/gcalSync.ts +0 -142
- package/src/ghlEventInquiry.ts +0 -143
- package/src/ghlNote.ts +0 -34
- package/src/ghlTask.ts +0 -48
- package/src/ghlVoiceInquiry.ts +0 -90
- package/src/guestPrintCapture.test.ts +0 -722
- package/src/guestPrintCapture.ts +0 -538
- package/src/lumaGhl.ts +0 -195
- package/src/mailArrivalEmail.ts +0 -121
- package/src/manageToken.ts +0 -363
- package/src/membership.ts +0 -109
- package/src/membershipBusClient.ts +0 -537
- package/src/membershipWelcome.ts +0 -683
- package/src/migrationCheckout.ts +0 -366
- package/src/money.ts +0 -36
- package/src/ops.ts +0 -97
- package/src/paymentLinkEmail.ts +0 -123
- package/src/policyAcknowledgment.test.ts +0 -50
- package/src/policyAcknowledgment.ts +0 -96
- package/src/portalSession.ts +0 -46
- package/src/pricing.test.ts +0 -660
- package/src/pricing.ts +0 -1025
- package/src/printBilling.test.ts +0 -750
- package/src/printBilling.ts +0 -891
- package/src/printBillingAdapters.ts +0 -169
- package/src/printCorrections.test.ts +0 -348
- package/src/printCorrections.ts +0 -496
- package/src/rateLimit.ts +0 -82
- package/src/referralCredits.test.ts +0 -31
- package/src/referralGrant.ts +0 -321
- package/src/rescheduleCredit.test.ts +0 -521
- package/src/rescheduleCredit.ts +0 -337
- package/src/reservationWifiCode.test.ts +0 -69
- package/src/retellCallAnalyzed.test.ts +0 -167
- package/src/retellCallAnalyzed.ts +0 -113
- package/src/retellSignature.test.ts +0 -137
- package/src/retellSignature.ts +0 -82
- package/src/signedUnpaidReminderEmail.test.ts +0 -246
- package/src/signedUnpaidReminderEmail.ts +0 -132
- package/src/slackAlert.ts +0 -38
- package/src/stripeCoworkingPortal.ts +0 -91
- package/src/supabaseTestFakes.ts +0 -131
- package/src/supportTicketEmail.ts +0 -119
- package/src/tier1Agreement.ts +0 -125
- package/src/unifiAccessPolicies.ts +0 -228
- package/src/unifiGroups.ts +0 -129
package/src/agreementCheckout.ts
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
// Shared Stripe checkout construction for private-office agreements.
|
|
2
|
-
//
|
|
3
|
-
// Extracted VERBATIM from boldsign-webhook/index.ts so the first-issuance path
|
|
4
|
-
// and the admin resend path can never drift apart.
|
|
5
|
-
|
|
6
|
-
import Stripe from 'npm:stripe@17.5.0';
|
|
7
|
-
import type { createClient, SupabaseClient } from 'npm:@supabase/supabase-js@2';
|
|
8
|
-
import { centsFrom, parseRetainerConfig } from './money.ts';
|
|
9
|
-
|
|
10
|
-
export interface AddonRow { label?: string; amount?: string; notes?: string }
|
|
11
|
-
|
|
12
|
-
// Re-exported so the existing `import { centsFrom } from './agreementCheckout.ts'`
|
|
13
|
-
// call sites (create-agreement, agreement-portal-get) keep working unchanged.
|
|
14
|
-
export { centsFrom };
|
|
15
|
-
|
|
16
|
-
export function buildAgreementLineItems(
|
|
17
|
-
fieldValues: Record<string, unknown>,
|
|
18
|
-
): Stripe.Checkout.SessionCreateParams.LineItem[] {
|
|
19
|
-
const v = fieldValues ?? {};
|
|
20
|
-
const lineItems: Stripe.Checkout.SessionCreateParams.LineItem[] = [];
|
|
21
|
-
|
|
22
|
-
// A source value counts as "configured" unless it is null/undefined/blank.
|
|
23
|
-
const isPresent = (x: unknown) =>
|
|
24
|
-
x !== null && x !== undefined && String(x).trim() !== '';
|
|
25
|
-
const bad = (field: string, value: unknown) => {
|
|
26
|
-
throw new Error(`unparseable_amount: ${field}=${JSON.stringify(value)}`);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const monthlyCents = centsFrom(v.monthly_fee);
|
|
30
|
-
if (isPresent(v.monthly_fee) && monthlyCents <= 0) bad('monthly_fee', v.monthly_fee);
|
|
31
|
-
if (monthlyCents > 0) {
|
|
32
|
-
lineItems.push({
|
|
33
|
-
price_data: {
|
|
34
|
-
currency: 'usd',
|
|
35
|
-
product_data: { name: `Private Office ${String(v.office_number ?? '')}`.trim() },
|
|
36
|
-
unit_amount: monthlyCents,
|
|
37
|
-
recurring: { interval: 'month' },
|
|
38
|
-
},
|
|
39
|
-
quantity: 1,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const addons = Array.isArray(v.addons) ? (v.addons as AddonRow[]) : [];
|
|
44
|
-
for (const addon of addons) {
|
|
45
|
-
const cents = centsFrom(addon?.amount);
|
|
46
|
-
if (isPresent(addon?.amount) && cents <= 0) bad('addon.amount', addon?.amount);
|
|
47
|
-
if (cents <= 0) continue;
|
|
48
|
-
lineItems.push({
|
|
49
|
-
price_data: {
|
|
50
|
-
currency: 'usd',
|
|
51
|
-
product_data: { name: String(addon.label || 'Add-on') },
|
|
52
|
-
unit_amount: cents,
|
|
53
|
-
recurring: { interval: 'month' },
|
|
54
|
-
},
|
|
55
|
-
quantity: 1,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const retainer = parseRetainerConfig(v);
|
|
60
|
-
if (!retainer.ok && retainer.code !== 'service_retainer_absent') bad('service_retainer', v.service_retainer);
|
|
61
|
-
else if (retainer.ok && retainer.cents > 0) {
|
|
62
|
-
lineItems.push({
|
|
63
|
-
price_data: {
|
|
64
|
-
currency: 'usd',
|
|
65
|
-
product_data: { name: 'Service retainer' },
|
|
66
|
-
unit_amount: retainer.cents,
|
|
67
|
-
},
|
|
68
|
-
quantity: 1,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
// absent, or ok-and-zero (an explicit waiver): no line item, no throw.
|
|
72
|
-
|
|
73
|
-
if (lineItems.length === 0) throw new Error('no_line_items_from_field_values');
|
|
74
|
-
|
|
75
|
-
return lineItems;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Reuse-or-create the Stripe customer by email (search is eventually consistent).
|
|
80
|
-
* If `existingCustomerId` is supplied and non-empty, it is returned as-is.
|
|
81
|
-
*/
|
|
82
|
-
export async function resolveStripeCustomer(
|
|
83
|
-
stripe: Stripe,
|
|
84
|
-
email: string,
|
|
85
|
-
name: string | null | undefined,
|
|
86
|
-
existingCustomerId?: string | null,
|
|
87
|
-
): Promise<string> {
|
|
88
|
-
if (existingCustomerId && existingCustomerId.trim() !== '') return existingCustomerId;
|
|
89
|
-
|
|
90
|
-
const emailKey = String(email ?? '').toLowerCase();
|
|
91
|
-
let customerId: string | null = null;
|
|
92
|
-
let matchCount = 0;
|
|
93
|
-
try {
|
|
94
|
-
const found = await stripe.customers.search({
|
|
95
|
-
query: `email:'${emailKey.replace(/'/g, "\\'")}'`,
|
|
96
|
-
limit: 2,
|
|
97
|
-
});
|
|
98
|
-
matchCount = found.data.length;
|
|
99
|
-
if (found.data.length > 0) customerId = found.data[0].id;
|
|
100
|
-
} catch (e) {
|
|
101
|
-
console.warn('[agreementCheckout] customers.search failed', e);
|
|
102
|
-
}
|
|
103
|
-
if (!customerId) {
|
|
104
|
-
try {
|
|
105
|
-
const listed = await stripe.customers.list({ email: emailKey, limit: 2 });
|
|
106
|
-
matchCount = listed.data.length;
|
|
107
|
-
if (listed.data.length > 0) customerId = listed.data[0].id;
|
|
108
|
-
} catch (e2) {
|
|
109
|
-
console.warn('[agreementCheckout] customers.list failed', e2);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
// Stripe does NOT enforce Customer email uniqueness. With >1 Customer per
|
|
113
|
-
// email the reused id is arbitrary, which makes any stripe_customer_id
|
|
114
|
-
// predicate downstream nondeterministic. Assert exactly one; flag otherwise.
|
|
115
|
-
if (matchCount > 1) {
|
|
116
|
-
console.error('[agreementCheckout] multiple Stripe Customers for one email',
|
|
117
|
-
{ email: emailKey, match_count: matchCount, chosen: customerId });
|
|
118
|
-
}
|
|
119
|
-
if (!customerId) {
|
|
120
|
-
const created = await stripe.customers.create({
|
|
121
|
-
email: emailKey,
|
|
122
|
-
name: name ?? undefined,
|
|
123
|
-
});
|
|
124
|
-
customerId = created.id;
|
|
125
|
-
}
|
|
126
|
-
return customerId;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export async function createAgreementCheckoutSession(
|
|
130
|
-
stripe: Stripe,
|
|
131
|
-
args: {
|
|
132
|
-
customerId: string;
|
|
133
|
-
lineItems: Stripe.Checkout.SessionCreateParams.LineItem[];
|
|
134
|
-
metadata: Record<string, string>;
|
|
135
|
-
idempotencyKey?: string;
|
|
136
|
-
baseUrl: string;
|
|
137
|
-
},
|
|
138
|
-
): Promise<Stripe.Checkout.Session> {
|
|
139
|
-
return await stripe.checkout.sessions.create({
|
|
140
|
-
mode: 'subscription',
|
|
141
|
-
customer: args.customerId,
|
|
142
|
-
line_items: args.lineItems,
|
|
143
|
-
metadata: args.metadata,
|
|
144
|
-
subscription_data: { metadata: args.metadata },
|
|
145
|
-
success_url: `${args.baseUrl}/membership/success?session_id={CHECKOUT_SESSION_ID}`,
|
|
146
|
-
cancel_url: `${args.baseUrl}/private-offices/`,
|
|
147
|
-
}, args.idempotencyKey ? { idempotencyKey: args.idempotencyKey } : undefined);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// ---------------------------------------------------------------------------
|
|
151
|
-
// Unified sign+pay flow additions. The legacy checkout helpers above are
|
|
152
|
-
// unchanged and remain the only thing boldsign-webhook / admin-resend use.
|
|
153
|
-
// ---------------------------------------------------------------------------
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Recurring subscription items for the unified flow. Uses a real Stripe
|
|
157
|
-
* Product ID because the Subscriptions API's price_data accepts `product`
|
|
158
|
-
* only (no inline product_data, unlike Checkout line items).
|
|
159
|
-
*/
|
|
160
|
-
export function buildAgreementSubscriptionItems(
|
|
161
|
-
fieldValues: Record<string, unknown>,
|
|
162
|
-
stripeProductId: string,
|
|
163
|
-
): Stripe.SubscriptionCreateParams.Item[] {
|
|
164
|
-
const v = fieldValues ?? {};
|
|
165
|
-
const items: Stripe.SubscriptionCreateParams.Item[] = [];
|
|
166
|
-
const isPresent = (x: unknown) => x !== null && x !== undefined && String(x).trim() !== '';
|
|
167
|
-
const bad = (field: string, value: unknown) => {
|
|
168
|
-
throw new Error(`unparseable_amount: ${field}=${JSON.stringify(value)}`);
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
const monthlyCents = centsFrom(v.monthly_fee);
|
|
172
|
-
if (isPresent(v.monthly_fee) && monthlyCents <= 0) bad('monthly_fee', v.monthly_fee);
|
|
173
|
-
if (monthlyCents <= 0) throw new Error('no_monthly_fee_for_subscription');
|
|
174
|
-
items.push({
|
|
175
|
-
price_data: {
|
|
176
|
-
currency: 'usd',
|
|
177
|
-
product: stripeProductId,
|
|
178
|
-
unit_amount: monthlyCents,
|
|
179
|
-
recurring: { interval: 'month' },
|
|
180
|
-
},
|
|
181
|
-
quantity: 1,
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
const addons = Array.isArray(v.addons) ? (v.addons as AddonRow[]) : [];
|
|
185
|
-
for (const addon of addons) {
|
|
186
|
-
const cents = centsFrom(addon?.amount);
|
|
187
|
-
if (isPresent(addon?.amount) && cents <= 0) bad('addon.amount', addon?.amount);
|
|
188
|
-
if (cents <= 0) continue;
|
|
189
|
-
items.push({
|
|
190
|
-
price_data: {
|
|
191
|
-
currency: 'usd',
|
|
192
|
-
// Same product as monthly rent -- addons are additional recurring line
|
|
193
|
-
// items on the same office subscription, not separate products.
|
|
194
|
-
product: stripeProductId,
|
|
195
|
-
unit_amount: cents,
|
|
196
|
-
recurring: { interval: 'month' },
|
|
197
|
-
},
|
|
198
|
-
quantity: 1,
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// Deliberately no reference to v.service_retainer anywhere in this function --
|
|
203
|
-
// the retainer is a one-time PaymentIntent charged separately (see
|
|
204
|
-
// agreementActivation.ts), never a subscription line item.
|
|
205
|
-
return items;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
type SupabaseLike = SupabaseClient<any, 'public', any>;
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Idempotent Stripe customer resolution + persistence for the unified flow.
|
|
212
|
-
* Not used by the legacy callers of resolveStripeCustomer.
|
|
213
|
-
*/
|
|
214
|
-
export async function resolveAndPersistStripeCustomer(
|
|
215
|
-
supabase: SupabaseLike,
|
|
216
|
-
stripe: Stripe,
|
|
217
|
-
signatureDocumentId: string,
|
|
218
|
-
email: string,
|
|
219
|
-
name: string | null | undefined,
|
|
220
|
-
): Promise<string> {
|
|
221
|
-
// Re-read fresh -- a concurrent call may already have persisted a customer id.
|
|
222
|
-
const { data: row } = await supabase
|
|
223
|
-
.from('signature_documents')
|
|
224
|
-
.select('stripe_customer_id')
|
|
225
|
-
.eq('id', signatureDocumentId)
|
|
226
|
-
.maybeSingle();
|
|
227
|
-
const existing = (row as { stripe_customer_id?: string | null } | null)?.stripe_customer_id;
|
|
228
|
-
if (existing && existing.trim() !== '') return existing;
|
|
229
|
-
|
|
230
|
-
const customerId = await resolveStripeCustomer(stripe, email, name, undefined);
|
|
231
|
-
|
|
232
|
-
// Conditional write: only the first caller for this row wins.
|
|
233
|
-
const { data: claimed } = await supabase
|
|
234
|
-
.from('signature_documents')
|
|
235
|
-
.update({ stripe_customer_id: customerId } as never)
|
|
236
|
-
.eq('id', signatureDocumentId)
|
|
237
|
-
.is('stripe_customer_id', null)
|
|
238
|
-
.select('id')
|
|
239
|
-
.maybeSingle();
|
|
240
|
-
|
|
241
|
-
if (claimed) return customerId;
|
|
242
|
-
|
|
243
|
-
// Someone else's write won the race -- use theirs.
|
|
244
|
-
const { data: fresh } = await supabase
|
|
245
|
-
.from('signature_documents')
|
|
246
|
-
.select('stripe_customer_id')
|
|
247
|
-
.eq('id', signatureDocumentId)
|
|
248
|
-
.maybeSingle();
|
|
249
|
-
return (fresh as { stripe_customer_id?: string | null } | null)?.stripe_customer_id ?? customerId;
|
|
250
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
// Initial "sign and pay" portal email for a unified private-office agreement.
|
|
2
|
-
//
|
|
3
|
-
// Sent by create-agreement immediately after BoldSign accepts the send. This is
|
|
4
|
-
// the FIRST outreach -- BoldSign delivers its own signing email separately.
|
|
5
|
-
//
|
|
6
|
-
// Mirrors the GHL request shape, headers, timeouts, escaping and error
|
|
7
|
-
// classification of sendPaymentLinkEmail in ./paymentLinkEmail.ts.
|
|
8
|
-
|
|
9
|
-
import type { createClient, SupabaseClient } from 'npm:@supabase/supabase-js@2';
|
|
10
|
-
import { logOps } from './ops.ts';
|
|
11
|
-
|
|
12
|
-
type SupabaseLike = SupabaseClient<any, 'public', any>;
|
|
13
|
-
|
|
14
|
-
export type AgreementPortalEmailResult = 'sent' | 'skipped' | 'failed_retryable' | 'failed_permanent';
|
|
15
|
-
|
|
16
|
-
/** Escape untrusted values interpolated into outbound HTML. */
|
|
17
|
-
function esc(v: unknown): string {
|
|
18
|
-
return String(v ?? '')
|
|
19
|
-
.replace(/&/g, '&')
|
|
20
|
-
.replace(/</g, '<')
|
|
21
|
-
.replace(/>/g, '>')
|
|
22
|
-
.replace(/"/g, '"')
|
|
23
|
-
.replace(/'/g, ''');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** Classify a caught error as transient (worth another event) or hopeless. */
|
|
27
|
-
function classifyError(e: unknown): 'failed_retryable' | 'failed_permanent' {
|
|
28
|
-
const name = e instanceof Error ? e.name : '';
|
|
29
|
-
if (name === 'AbortError' || name === 'TimeoutError') return 'failed_retryable';
|
|
30
|
-
const msg = e instanceof Error ? e.message : String(e);
|
|
31
|
-
const m = msg.match(/^ghl_(?:upsert|email)_(\d{3})/);
|
|
32
|
-
if (m) {
|
|
33
|
-
const code = Number(m[1]);
|
|
34
|
-
if (code === 429 || code >= 500) return 'failed_retryable';
|
|
35
|
-
}
|
|
36
|
-
return 'failed_permanent';
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export async function sendAgreementPortalEmail(
|
|
40
|
-
supabase: SupabaseLike,
|
|
41
|
-
{ email, name, portalUrl, officeNumber }: {
|
|
42
|
-
email: string;
|
|
43
|
-
name?: string | null;
|
|
44
|
-
portalUrl: string;
|
|
45
|
-
officeNumber?: string | null;
|
|
46
|
-
},
|
|
47
|
-
operator: { name: string; shortName: string; domain: string; supportEmail: string },
|
|
48
|
-
): Promise<AgreementPortalEmailResult> {
|
|
49
|
-
try {
|
|
50
|
-
const apiKey = Deno.env.get('GHL_API_KEY');
|
|
51
|
-
const locationId = Deno.env.get('GHL_LOCATION_ID');
|
|
52
|
-
if (!apiKey || !locationId) {
|
|
53
|
-
await logOps(supabase, 'agreement_portal_email_skipped',
|
|
54
|
-
{ email, reason: 'ghl_not_configured' }, { severity: 'warning' }).catch(() => {});
|
|
55
|
-
return 'skipped';
|
|
56
|
-
}
|
|
57
|
-
const GHL_BASE = 'https://services.leadconnectorhq.com';
|
|
58
|
-
const headers = {
|
|
59
|
-
Authorization: `Bearer ${apiKey}`,
|
|
60
|
-
Version: '2021-07-28',
|
|
61
|
-
'Content-Type': 'application/json',
|
|
62
|
-
Accept: 'application/json',
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const trimmed = (name || '').trim();
|
|
66
|
-
const parts = trimmed.split(/\s+/).filter(Boolean);
|
|
67
|
-
// Greeting is display-only. The CRM name is OMITTED when we have no name —
|
|
68
|
-
// never defaulted, or we would overwrite a real contact with "there".
|
|
69
|
-
const greetingName = parts[0] || 'there';
|
|
70
|
-
const crmName: { firstName?: string; lastName?: string } = {};
|
|
71
|
-
if (parts[0]) crmName.firstName = parts[0];
|
|
72
|
-
if (parts.length > 1) crmName.lastName = parts.slice(1).join(' ');
|
|
73
|
-
|
|
74
|
-
const upRes = await fetch(`${GHL_BASE}/contacts/upsert`, {
|
|
75
|
-
method: 'POST', headers,
|
|
76
|
-
signal: AbortSignal.timeout(8000),
|
|
77
|
-
body: JSON.stringify({
|
|
78
|
-
locationId, ...crmName, email,
|
|
79
|
-
source: `${operator.shortName} Website — Office Agreement`,
|
|
80
|
-
tags: ['Office Agreement', 'Unified Portal', operator.domain],
|
|
81
|
-
}),
|
|
82
|
-
});
|
|
83
|
-
if (!upRes.ok) throw new Error(`ghl_upsert_${upRes.status}: ${await upRes.text()}`);
|
|
84
|
-
const upJson = await upRes.json();
|
|
85
|
-
const contactId = upJson.contact?.id || upJson.id || null;
|
|
86
|
-
if (!contactId) throw new Error('ghl_upsert_no_contact_id');
|
|
87
|
-
|
|
88
|
-
const p = (t: string) =>
|
|
89
|
-
`<p style="margin:0 0 8px 0;color:#22263B;font-family:Inter,Arial,sans-serif;font-size:14px;line-height:22px">${t}</p>`;
|
|
90
|
-
|
|
91
|
-
const office = (officeNumber || '').trim();
|
|
92
|
-
const officeClause = office ? ` for office ${esc(office)}` : '';
|
|
93
|
-
const subject = `Your ${operator.shortName} private office agreement is ready — review and pay your retainer`;
|
|
94
|
-
|
|
95
|
-
const html = `<div style="background:#F6F6F6;padding:24px 0;margin:0"><table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse;background:#F6F6F6"><tr><td align="center" style="padding:0 12px"><table role="presentation" width="560" cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse;max-width:560px;width:100%;background:#FFFFFF;border-radius:10px"><tr><td style="padding:24px">
|
|
96
|
-
<h2 style="margin:0 0 12px 0;color:#22263B;font-family:Inter,Arial,sans-serif;font-size:22px">Your ${operator.shortName} private office agreement is ready</h2>
|
|
97
|
-
${p(`Hi ${esc(greetingName)},`)}
|
|
98
|
-
${p(`Your ${operator.name} private office agreement${officeClause} is ready to review. There are two quick steps to get you moved in.`)}
|
|
99
|
-
${p('<strong>1. Review your terms and pay your service retainer.</strong> Open your secure agreement portal:')}
|
|
100
|
-
${p(`<a href="${esc(portalUrl)}" style="color:#C98A5E">Review and pay your retainer →</a>`)}
|
|
101
|
-
${p('<strong>2. Sign your agreement.</strong> BoldSign is sending you a separate email with the signing link — watch for it in your inbox (check spam if you don\'t see it shortly).')}
|
|
102
|
-
${p('Your monthly billing starts only after both steps are complete. This portal link is unique to your agreement, so please don\'t forward it.')}
|
|
103
|
-
${p(`Questions in the meantime? Just reply to this email or reach us at <a href="mailto:${operator.supportEmail}" style="color:#C98A5E">${operator.supportEmail}</a>.`)}
|
|
104
|
-
${p(`Welcome aboard,<br />The ${operator.name} team`)}
|
|
105
|
-
</td></tr></table></td></tr></table></div>`;
|
|
106
|
-
|
|
107
|
-
const emailRes = await fetch(`${GHL_BASE}/conversations/messages`, {
|
|
108
|
-
method: 'POST', headers,
|
|
109
|
-
signal: AbortSignal.timeout(8000),
|
|
110
|
-
body: JSON.stringify({
|
|
111
|
-
type: 'Email',
|
|
112
|
-
contactId,
|
|
113
|
-
subject,
|
|
114
|
-
html,
|
|
115
|
-
}),
|
|
116
|
-
});
|
|
117
|
-
if (!emailRes.ok) throw new Error(`ghl_email_${emailRes.status}: ${await emailRes.text()}`);
|
|
118
|
-
|
|
119
|
-
await logOps(supabase, 'agreement_portal_email_sent', { email }, { severity: 'info' }).catch(() => {});
|
|
120
|
-
return 'sent';
|
|
121
|
-
} catch (e) {
|
|
122
|
-
const classification = classifyError(e);
|
|
123
|
-
await logOps(supabase, 'agreement_portal_email_failed',
|
|
124
|
-
{ email, message: e instanceof Error ? e.message : String(e) },
|
|
125
|
-
{ severity: classification === 'failed_permanent' ? 'error' : 'warning' }).catch(() => {});
|
|
126
|
-
return classification;
|
|
127
|
-
}
|
|
128
|
-
}
|
package/src/availability.test.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { assertEquals } from 'https://deno.land/std@0.224.0/assert/mod.ts';
|
|
2
|
-
import { parsePgRange } from './availability.ts';
|
|
3
|
-
|
|
4
|
-
const START = Date.UTC(2026, 6, 21, 15, 30, 0);
|
|
5
|
-
const END = Date.UTC(2026, 6, 21, 16, 30, 0);
|
|
6
|
-
|
|
7
|
-
Deno.test('parsePgRange handles bare +00 with space separator', () => {
|
|
8
|
-
assertEquals(
|
|
9
|
-
parsePgRange('["2026-07-21 15:30:00+00","2026-07-21 16:30:00+00")'),
|
|
10
|
-
[START, END],
|
|
11
|
-
);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
Deno.test('parsePgRange handles ISO form', () => {
|
|
15
|
-
assertEquals(
|
|
16
|
-
parsePgRange('["2026-07-21T15:30:00+00:00","2026-07-21T16:30:00+00:00")'),
|
|
17
|
-
[START, END],
|
|
18
|
-
);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
Deno.test('parsePgRange returns null for malformed input', () => {
|
|
22
|
-
assertEquals(parsePgRange('[,)'), null);
|
|
23
|
-
assertEquals(parsePgRange('garbage'), null);
|
|
24
|
-
assertEquals(parsePgRange(''), null);
|
|
25
|
-
});
|
package/src/availability.ts
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
// Shared availability primitives for room booking surfaces.
|
|
2
|
-
//
|
|
3
|
-
// Extracted verbatim (behaviour-identical) from booking-availability so that
|
|
4
|
-
// every consumer answers "is this room busy?" the same way. Do NOT fork these
|
|
5
|
-
// helpers — add a caller instead.
|
|
6
|
-
|
|
7
|
-
// Structural client type: the concrete SupabaseClient generics differ between
|
|
8
|
-
// call sites, so we only describe the query surface these helpers use.
|
|
9
|
-
interface QueryResult {
|
|
10
|
-
data: unknown[] | null;
|
|
11
|
-
error: { message: string } | null;
|
|
12
|
-
}
|
|
13
|
-
interface FilterBuilder extends PromiseLike<QueryResult> {
|
|
14
|
-
eq(column: string, value: unknown): FilterBuilder;
|
|
15
|
-
in(column: string, values: unknown[]): FilterBuilder;
|
|
16
|
-
or(filters: string): FilterBuilder;
|
|
17
|
-
filter(column: string, operator: string, value: unknown): FilterBuilder;
|
|
18
|
-
}
|
|
19
|
-
interface QueryClient {
|
|
20
|
-
from(table: string): { select(columns: string): FilterBuilder };
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Minimal accepted shape. Kept deliberately loose: the concrete
|
|
24
|
-
* SupabaseClient generics vary per call site and matching the full builder
|
|
25
|
-
* type structurally is prohibitively expensive for the type checker.
|
|
26
|
-
*/
|
|
27
|
-
export interface SupabaseLike {
|
|
28
|
-
from(table: string): unknown;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** LA offset in hours (integer: -7 DST, -8 STD) for a given UTC instant. */
|
|
32
|
-
export function laOffsetHours(atUtc: Date): number {
|
|
33
|
-
const parts = new Intl.DateTimeFormat('en-US', {
|
|
34
|
-
timeZone: 'America/Los_Angeles',
|
|
35
|
-
timeZoneName: 'longOffset',
|
|
36
|
-
}).formatToParts(atUtc);
|
|
37
|
-
const tz = parts.find((p) => p.type === 'timeZoneName')?.value ?? 'GMT-08:00';
|
|
38
|
-
const m = tz.match(/GMT([+-])(\d{1,2}):?(\d{2})?/);
|
|
39
|
-
if (!m) return -8;
|
|
40
|
-
const sign = m[1] === '+' ? 1 : -1;
|
|
41
|
-
return sign * (parseInt(m[2], 10) + parseInt(m[3] || '0', 10) / 60);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** Convert an LA wall-clock (YYYY-MM-DD + HH:MM) to a real UTC Date. */
|
|
45
|
-
export function laWallToUtc(dateStr: string, hh: number, mm: number): Date {
|
|
46
|
-
const [y, mo, d] = dateStr.split('-').map(Number);
|
|
47
|
-
// Use noon-UTC that day to pick a stable offset (no DST edge case at noon).
|
|
48
|
-
const guess = new Date(Date.UTC(y, mo - 1, d, 12));
|
|
49
|
-
const off = laOffsetHours(guess); // negative integer
|
|
50
|
-
return new Date(Date.UTC(y, mo - 1, d, hh - Math.trunc(off), mm));
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function laWeekday(dateStr: string): number {
|
|
54
|
-
const [y, mo, d] = dateStr.split('-').map(Number);
|
|
55
|
-
const guess = new Date(Date.UTC(y, mo - 1, d, 12));
|
|
56
|
-
const s = new Intl.DateTimeFormat('en-US', {
|
|
57
|
-
timeZone: 'America/Los_Angeles',
|
|
58
|
-
weekday: 'short',
|
|
59
|
-
}).format(guess);
|
|
60
|
-
return ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].indexOf(s);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* The America/Los_Angeles calendar date (YYYY-MM-DD) for a UTC instant.
|
|
65
|
-
* Added so callers never hand-roll a second timezone conversion.
|
|
66
|
-
*/
|
|
67
|
-
export function laDateStr(atUtc: Date): string {
|
|
68
|
-
const parts = new Intl.DateTimeFormat('en-CA', {
|
|
69
|
-
timeZone: 'America/Los_Angeles',
|
|
70
|
-
year: 'numeric',
|
|
71
|
-
month: '2-digit',
|
|
72
|
-
day: '2-digit',
|
|
73
|
-
}).formatToParts(atUtc);
|
|
74
|
-
const get = (t: string) => parts.find((p) => p.type === t)?.value ?? '';
|
|
75
|
-
return `${get('year')}-${get('month')}-${get('day')}`;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Normalise a Postgres timestamptz text value into something V8 parses
|
|
80
|
-
* unambiguously: space separator -> "T", bare "+00"/"-00" -> "+00:00"/"-00:00".
|
|
81
|
-
* Defensive only — current data already parses.
|
|
82
|
-
*/
|
|
83
|
-
function normalizeTimestamp(s: string): string {
|
|
84
|
-
return s
|
|
85
|
-
.trim()
|
|
86
|
-
.replace(' ', 'T')
|
|
87
|
-
.replace(/([+-]\d{2})$/, '$1:00');
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/** Parse a Postgres tstzrange text literal `[start,end)` into epoch ms bounds. */
|
|
91
|
-
export function parsePgRange(r: string): [number, number] | null {
|
|
92
|
-
if (typeof r !== 'string' || r.length < 2) return null;
|
|
93
|
-
const inner = r.slice(1, -1);
|
|
94
|
-
const parts = inner.split(',').map((s) => s.replace(/^"|"$/g, ''));
|
|
95
|
-
if (parts.length !== 2 || !parts[0] || !parts[1]) return null;
|
|
96
|
-
const a = new Date(normalizeTimestamp(parts[0])).getTime();
|
|
97
|
-
const b = new Date(normalizeTimestamp(parts[1])).getTime();
|
|
98
|
-
if (Number.isNaN(a) || Number.isNaN(b)) return null;
|
|
99
|
-
return [a, b];
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* business_hours row for a room + weekday. A room-specific row wins over the
|
|
104
|
-
* global (room_id IS NULL) row. Returns null/undefined when closed.
|
|
105
|
-
*/
|
|
106
|
-
export interface BusinessHoursRow {
|
|
107
|
-
room_id: string | null;
|
|
108
|
-
open_time: string;
|
|
109
|
-
close_time: string;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export async function getBusinessHoursRow(
|
|
113
|
-
supabase: SupabaseLike,
|
|
114
|
-
roomId: string,
|
|
115
|
-
weekday: number,
|
|
116
|
-
): Promise<BusinessHoursRow | undefined> {
|
|
117
|
-
const db = supabase as unknown as QueryClient;
|
|
118
|
-
const { data, error } = await db
|
|
119
|
-
.from('business_hours')
|
|
120
|
-
.select('*')
|
|
121
|
-
.eq('weekday', weekday)
|
|
122
|
-
.or(`room_id.eq.${roomId},room_id.is.null`);
|
|
123
|
-
if (error) throw error;
|
|
124
|
-
const rows = (data ?? []) as BusinessHoursRow[];
|
|
125
|
-
// Room-specific row wins over the global (room_id IS NULL) row.
|
|
126
|
-
return rows.sort((a, b) => (a.room_id ? -1 : 1))[0];
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Busy intervals (epoch ms pairs) for a room overlapping `rangeLiteral`:
|
|
131
|
-
* pending/paid bookings (pending only while its hold is still valid) plus
|
|
132
|
-
* blackouts.
|
|
133
|
-
*/
|
|
134
|
-
export async function getBusyRanges(
|
|
135
|
-
supabase: SupabaseLike,
|
|
136
|
-
roomId: string,
|
|
137
|
-
rangeLiteral: string,
|
|
138
|
-
): Promise<[number, number][]> {
|
|
139
|
-
return (await getBusyRangesDetailed(supabase, roomId, rangeLiteral)).busy;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Same query and same busy computation as `getBusyRanges`, but also reports
|
|
144
|
-
* how many rows had a `during` value that could not be parsed.
|
|
145
|
-
*
|
|
146
|
-
* `getBusyRanges` silently skips those rows (a skipped row reads as *free*).
|
|
147
|
-
* That is fine for the booking flow, where the DB exclusion constraint is the
|
|
148
|
-
* real gate, but a read-only "what's open right now?" surface must fail the
|
|
149
|
-
* other way — an unparseable row has to be treated as busy. Callers that need
|
|
150
|
-
* that safety use this function; the historical behaviour of `getBusyRanges`
|
|
151
|
-
* is unchanged (it simply delegates here and drops the count).
|
|
152
|
-
*/
|
|
153
|
-
export async function getBusyRangesDetailed(
|
|
154
|
-
supabase: SupabaseLike,
|
|
155
|
-
roomId: string,
|
|
156
|
-
rangeLiteral: string,
|
|
157
|
-
): Promise<{ busy: [number, number][]; unparsed: number }> {
|
|
158
|
-
const db = supabase as unknown as QueryClient;
|
|
159
|
-
const [bRes, blRes] = await Promise.all([
|
|
160
|
-
db
|
|
161
|
-
.from('bookings')
|
|
162
|
-
.select('during,status,hold_expires_at')
|
|
163
|
-
.eq('room_id', roomId)
|
|
164
|
-
.in('status', ['pending', 'paid'])
|
|
165
|
-
.filter('during', 'ov', rangeLiteral),
|
|
166
|
-
db
|
|
167
|
-
.from('blackouts')
|
|
168
|
-
.select('during')
|
|
169
|
-
.eq('room_id', roomId)
|
|
170
|
-
.filter('during', 'ov', rangeLiteral),
|
|
171
|
-
]);
|
|
172
|
-
if (bRes.error) throw bRes.error;
|
|
173
|
-
if (blRes.error) throw blRes.error;
|
|
174
|
-
|
|
175
|
-
const bookingRows = (bRes.data ?? []) as Array<{
|
|
176
|
-
during: string;
|
|
177
|
-
status: string;
|
|
178
|
-
hold_expires_at: string | null;
|
|
179
|
-
}>;
|
|
180
|
-
const blackoutRows = (blRes.data ?? []) as Array<{ during: string }>;
|
|
181
|
-
|
|
182
|
-
const busy: [number, number][] = [];
|
|
183
|
-
let unparsed = 0;
|
|
184
|
-
const nowMs = Date.now();
|
|
185
|
-
for (const row of bookingRows) {
|
|
186
|
-
// Paid bookings always block; pending only blocks while the hold is still valid.
|
|
187
|
-
if (row.status === 'pending') {
|
|
188
|
-
const holdMs = row.hold_expires_at ? new Date(row.hold_expires_at).getTime() : null;
|
|
189
|
-
if (holdMs !== null && holdMs < nowMs) continue;
|
|
190
|
-
}
|
|
191
|
-
const p = parsePgRange(row.during);
|
|
192
|
-
if (p) busy.push(p);
|
|
193
|
-
else unparsed += 1;
|
|
194
|
-
}
|
|
195
|
-
for (const row of blackoutRows) {
|
|
196
|
-
const p = parsePgRange(row.during);
|
|
197
|
-
if (p) busy.push(p);
|
|
198
|
-
else unparsed += 1;
|
|
199
|
-
}
|
|
200
|
-
return { busy, unparsed };
|
|
201
|
-
}
|