@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
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
// Money-path helper for reschedule-booking/index.ts: splits a reschedule's
|
|
2
|
+
// refund into up to TWO separate credit grants so a reschedule can never
|
|
3
|
+
// launder a short-lived credit into a longer-lived one.
|
|
4
|
+
//
|
|
5
|
+
// Two independent, mutually-exclusive credit mechanisms can fund a booking's
|
|
6
|
+
// `credit_applied_cents`:
|
|
7
|
+
// - System A (monthly membership credit): a `credits` ledger row with
|
|
8
|
+
// `booking_id` set directly and entry_type 'hold'/'consume', tied via
|
|
9
|
+
// `period_id` to a `credit_periods` row (create-booking / admin-create-
|
|
10
|
+
// booking's credit_hold/credit_consume — see _shared/adminBookingCredit.ts).
|
|
11
|
+
// This credit is "use it or lose it" for that calendar month and has no
|
|
12
|
+
// `expires_at` of its own — its equivalent expiry is the Pacific-anchored
|
|
13
|
+
// START of the FOLLOWING period_month (period_anchor() of next month),
|
|
14
|
+
// the same boundary the credit system itself uses to define a period's
|
|
15
|
+
// end.
|
|
16
|
+
// - System B (a previously-issued, since-redeemed credit grant): a
|
|
17
|
+
// `credits` row with `redeemed_booking_id` set, entry_type 'grant',
|
|
18
|
+
// already redeemed, carrying its own `expires_at` (how a PRIOR
|
|
19
|
+
// reschedule's own cancellation credit funds a booking — see
|
|
20
|
+
// reschedule-booking/index.ts's own credit-reservation step).
|
|
21
|
+
//
|
|
22
|
+
// A booking is funded by at most one of the two: create-booking / admin-
|
|
23
|
+
// create-booking never touch System B, and reschedule-booking's own credit
|
|
24
|
+
// application never calls credit_hold. Checking System A first and falling
|
|
25
|
+
// back to System B is therefore unambiguous, not a guess.
|
|
26
|
+
//
|
|
27
|
+
// F6 fix, corrected: the first attempt at this fix summed both the cash and
|
|
28
|
+
// credit portions into ONE grant, and capped the WHOLE thing only if it
|
|
29
|
+
// happened to find a System-B entry_type='grant' row. A System-A-funded
|
|
30
|
+
// (monthly membership credit) booking found zero rows there — no error, no
|
|
31
|
+
// log — and silently got the full 1-year grant on the entire charged+credit
|
|
32
|
+
// sum. This module fixes that by (a) querying System A first, and (b)
|
|
33
|
+
// treating "credit_applied_cents > 0 but neither system explains it" as
|
|
34
|
+
// exactly as dangerous as an outright query error.
|
|
35
|
+
/**
|
|
36
|
+
* Floor applied to a capped credit-funded grant so it's never issued
|
|
37
|
+
* already-dead (or nearly so) just because the ORIGINAL credit it's capped
|
|
38
|
+
* against had already expired by refund/cancellation time. Kyle's call,
|
|
39
|
+
* E10/GATE-0188 follow-up, 2026-09-10.
|
|
40
|
+
*/
|
|
41
|
+
export const MIN_CREDIT_GRANT_LIFETIME_DAYS = 30;
|
|
42
|
+
/**
|
|
43
|
+
* period_month is always the 1st of a calendar month (DB CHECK
|
|
44
|
+
* credit_periods_period_month_is_first) — pure calendar arithmetic, no
|
|
45
|
+
* timezone ambiguity in computing "the following month" from it.
|
|
46
|
+
*/
|
|
47
|
+
export function nextPeriodMonthStr(periodMonthStr) {
|
|
48
|
+
const [y, m] = periodMonthStr.split('-').map((n) => parseInt(n, 10));
|
|
49
|
+
const ny = m === 12 ? y + 1 : y;
|
|
50
|
+
const nm = m === 12 ? 1 : m + 1;
|
|
51
|
+
return `${ny}-${String(nm).padStart(2, '0')}-01`;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Finds the real expiry that must cap a reschedule's credit-funded refund
|
|
55
|
+
* portion, by tracing which of the two credit mechanisms actually funded
|
|
56
|
+
* `bookingId`'s `credit_applied_cents`. See the module doc comment above.
|
|
57
|
+
*
|
|
58
|
+
* Returns `errored: true` whenever the real expiry could not be confirmed —
|
|
59
|
+
* a query failure OR (just as importantly) a *clean, zero-row* result
|
|
60
|
+
* despite the caller already knowing credit_applied_cents > 0. Both failure
|
|
61
|
+
* shapes are treated identically: fall back to `defaultExp`, but tell the
|
|
62
|
+
* caller so it can log at ERROR severity rather than silently over-granting.
|
|
63
|
+
*/
|
|
64
|
+
export async function resolveOriginalCreditExpiry(admin, bookingId, defaultExp) {
|
|
65
|
+
try {
|
|
66
|
+
// System A: monthly membership credit, hold/consume rows keyed directly
|
|
67
|
+
// by booking_id (NOT entry_type='grant' — that's System B and was the
|
|
68
|
+
// first attempt's bug).
|
|
69
|
+
const { data: ledgerRows, error: ledgerErr } = await admin
|
|
70
|
+
.from('credits')
|
|
71
|
+
.select('period_id, entry_type, created_at')
|
|
72
|
+
.eq('booking_id', bookingId)
|
|
73
|
+
.in('entry_type', ['hold', 'consume'])
|
|
74
|
+
.order('created_at', { ascending: false })
|
|
75
|
+
.limit(1);
|
|
76
|
+
if (ledgerErr)
|
|
77
|
+
throw ledgerErr;
|
|
78
|
+
const periodId = ledgerRows && ledgerRows.length > 0 ? ledgerRows[0].period_id : null;
|
|
79
|
+
if (periodId) {
|
|
80
|
+
const { data: periodRow, error: periodErr } = await admin
|
|
81
|
+
.from('credit_periods')
|
|
82
|
+
.select('period_month')
|
|
83
|
+
.eq('id', periodId)
|
|
84
|
+
.maybeSingle();
|
|
85
|
+
if (periodErr)
|
|
86
|
+
throw periodErr;
|
|
87
|
+
if (periodRow?.period_month) {
|
|
88
|
+
const { data: anchor, error: anchorErr } = await admin.rpc('period_anchor', {
|
|
89
|
+
p_period_month: nextPeriodMonthStr(String(periodRow.period_month)),
|
|
90
|
+
});
|
|
91
|
+
if (anchorErr)
|
|
92
|
+
throw anchorErr;
|
|
93
|
+
if (anchor)
|
|
94
|
+
return { exp: new Date(anchor), source: 'system_a', errored: false };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// System B: a prior reschedule's own cancellation credit, funding this
|
|
98
|
+
// booking via redeemed_booking_id. Deliberately NOT filtered on
|
|
99
|
+
// `redeemed_at IS NOT NULL`: that column is only set once
|
|
100
|
+
// credit_reservation_finalize succeeds, and both its call sites
|
|
101
|
+
// (reschedule-booking's own 4A branch, stripe-webhook) treat a finalize
|
|
102
|
+
// failure as log-only, non-fatal — leaving a PAID booking with
|
|
103
|
+
// redeemed_booking_id set and redeemed_at forever NULL. Requiring
|
|
104
|
+
// redeemed_at here would silently push exactly that booking down to
|
|
105
|
+
// 'not_found' and the full 1-year default, reopening the bug this module
|
|
106
|
+
// exists to close. redeemed_booking_id alone is already the real funding
|
|
107
|
+
// link (credit_reservation_release nulls it on an abandoned reservation,
|
|
108
|
+
// so a released grant can never false-positive here).
|
|
109
|
+
const { data: grantRows, error: grantErr } = await admin
|
|
110
|
+
.from('credits')
|
|
111
|
+
.select('expires_at')
|
|
112
|
+
.eq('redeemed_booking_id', bookingId)
|
|
113
|
+
.eq('entry_type', 'grant')
|
|
114
|
+
.order('expires_at', { ascending: true, nullsFirst: false })
|
|
115
|
+
.limit(1);
|
|
116
|
+
if (grantErr)
|
|
117
|
+
throw grantErr;
|
|
118
|
+
if (grantRows && grantRows.length > 0) {
|
|
119
|
+
const rawExpiry = grantRows[0].expires_at;
|
|
120
|
+
// A funding row was found either way — this is NOT an error case. Every
|
|
121
|
+
// known producer of a System-B grant sets expires_at, but if one ever
|
|
122
|
+
// doesn't, there's simply nothing to cap against: fall back to the
|
|
123
|
+
// plain 1-year default without flagging it as a lookup failure.
|
|
124
|
+
return {
|
|
125
|
+
exp: rawExpiry ? new Date(rawExpiry) : defaultExp,
|
|
126
|
+
source: 'system_b',
|
|
127
|
+
errored: false,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
// credit_applied_cents > 0 but neither system explains it — a data-
|
|
131
|
+
// integrity gap, not the ordinary "no credit used" case (the caller only
|
|
132
|
+
// reaches this function when credit_applied_cents > 0). Never let this
|
|
133
|
+
// silently default to the full 1-year grant.
|
|
134
|
+
return {
|
|
135
|
+
exp: defaultExp,
|
|
136
|
+
source: 'not_found',
|
|
137
|
+
errored: true,
|
|
138
|
+
detail: 'no_funding_row_found_for_credit_applied_cents',
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
catch (e) {
|
|
142
|
+
// Supabase/PostgREST errors thrown above (ledgerErr, periodErr, anchorErr,
|
|
143
|
+
// grantErr) are plain {message, code, ...} objects, NOT Error instances —
|
|
144
|
+
// `e instanceof Error` would miss them and collapse the detail down to
|
|
145
|
+
// the useless literal "[object Object]".
|
|
146
|
+
const message = typeof e === 'object' && e !== null && 'message' in e
|
|
147
|
+
? String(e.message)
|
|
148
|
+
: String(e);
|
|
149
|
+
return {
|
|
150
|
+
exp: defaultExp,
|
|
151
|
+
source: 'error',
|
|
152
|
+
errored: true,
|
|
153
|
+
detail: message,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Shared core: splits a refund/credit-issuance into up to two 'grant' rows
|
|
159
|
+
* with caller-supplied reason text for each portion. Used by both the
|
|
160
|
+
* reschedule path (buildRescheduleCreditGrants) and the cancellation paths
|
|
161
|
+
* (buildCancellationCreditGrants) below — the credit-system lookup and
|
|
162
|
+
* splitting logic is identical; only the ledger reason text differs.
|
|
163
|
+
*/
|
|
164
|
+
async function buildSplitCreditGrants(admin, opts) {
|
|
165
|
+
const { bookingId, contactEmail, ghlContactId, cashPortionCents, creditPortionCents, defaultExp, cashReason, creditReason } = opts;
|
|
166
|
+
const emailLower = contactEmail.toLowerCase();
|
|
167
|
+
const grants = [];
|
|
168
|
+
let expiryLookupErrored = false;
|
|
169
|
+
let expiryLookupDetail;
|
|
170
|
+
let expirySource;
|
|
171
|
+
if (cashPortionCents > 0) {
|
|
172
|
+
grants.push({
|
|
173
|
+
entry_type: 'grant',
|
|
174
|
+
contact_email: emailLower,
|
|
175
|
+
ghl_contact_id: ghlContactId,
|
|
176
|
+
delta_cents: cashPortionCents,
|
|
177
|
+
reason: cashReason,
|
|
178
|
+
booking_id: bookingId,
|
|
179
|
+
expires_at: defaultExp.toISOString(),
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
if (creditPortionCents > 0) {
|
|
183
|
+
const resolved = await resolveOriginalCreditExpiry(admin, bookingId, defaultExp);
|
|
184
|
+
expirySource = resolved.source;
|
|
185
|
+
if (resolved.errored) {
|
|
186
|
+
expiryLookupErrored = true;
|
|
187
|
+
expiryLookupDetail = resolved.detail;
|
|
188
|
+
}
|
|
189
|
+
// Floor: never issue a grant that's ALREADY DEAD ON ARRIVAL just because
|
|
190
|
+
// the ORIGINAL credit it's being capped against had already expired by
|
|
191
|
+
// the time of this reschedule/cancellation. Kyle's call (E10/GATE-0188
|
|
192
|
+
// follow-up, 2026-09-10).
|
|
193
|
+
//
|
|
194
|
+
// The trigger is deliberately narrow — `resolved.exp` in the PAST, full
|
|
195
|
+
// stop — not "expiring within the floor window". A System-A (monthly
|
|
196
|
+
// membership credit) cap is USUALLY well under 30 days out (it's the
|
|
197
|
+
// real end of the current calendar month, per period_anchor()); a
|
|
198
|
+
// System-B grant capped at a genuinely short remaining lifetime is
|
|
199
|
+
// equally a correct, intended cap. Flooring either of those up to 30
|
|
200
|
+
// days would silently re-widen the exact laundering gap this module
|
|
201
|
+
// exists to close (an earlier draft of this floor made precisely that
|
|
202
|
+
// mistake — caught on review before merge — and would have let a member
|
|
203
|
+
// ratchet a near-expired credit's lifetime back up to 30 days on every
|
|
204
|
+
// cancel/rebook cycle). Only a TRULY expired original (already in the
|
|
205
|
+
// past) is a stale reference point rather than an intentional cap.
|
|
206
|
+
const finalExp = resolved.exp.getTime() < Date.now()
|
|
207
|
+
? new Date(Date.now() + MIN_CREDIT_GRANT_LIFETIME_DAYS * 24 * 60 * 60 * 1000)
|
|
208
|
+
: resolved.exp;
|
|
209
|
+
grants.push({
|
|
210
|
+
entry_type: 'grant',
|
|
211
|
+
contact_email: emailLower,
|
|
212
|
+
ghl_contact_id: ghlContactId,
|
|
213
|
+
delta_cents: creditPortionCents,
|
|
214
|
+
reason: creditReason(resolved.source),
|
|
215
|
+
booking_id: bookingId,
|
|
216
|
+
expires_at: finalExp.toISOString(),
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
return { grants, expiryLookupErrored, expiryLookupDetail, expirySource };
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Builds the credits-table INSERT payload for a reschedule's refund: up to
|
|
223
|
+
* two 'grant' rows — a cash-funded portion at the plain 1-year default, and
|
|
224
|
+
* (only if > 0) a credit-funded portion capped at the ORIGINAL credit's own
|
|
225
|
+
* expiry. A zero-cents portion is omitted entirely (a 'grant' row with
|
|
226
|
+
* delta_cents = 0 would violate credits_delta_sign_check).
|
|
227
|
+
*/
|
|
228
|
+
export async function buildRescheduleCreditGrants(admin, opts) {
|
|
229
|
+
return buildSplitCreditGrants(admin, {
|
|
230
|
+
...opts,
|
|
231
|
+
cashReason: 'Booking rescheduled by customer (cash-funded portion)',
|
|
232
|
+
creditReason: (source) => `Booking rescheduled by customer (credit-funded portion, source=${source})`,
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Same split as buildRescheduleCreditGrants, for the two cancellation paths
|
|
237
|
+
* (manage-booking's customer-initiated cancel, admin-cancel-booking's
|
|
238
|
+
* staff-initiated cancel/refund) — a cancellation credit carries exactly the
|
|
239
|
+
* same laundering risk a reschedule credit does: it must not extend a
|
|
240
|
+
* short-lived credit into a fresh 1-year grant just because it passed
|
|
241
|
+
* through a cancellation instead of a reschedule. See E10/GATE-0188.
|
|
242
|
+
*
|
|
243
|
+
* `reasonOverride`, when given (admin-cancel-booking's optional free-text
|
|
244
|
+
* reason field), replaces the whole default reason string for BOTH portions
|
|
245
|
+
* verbatim — matching this codebase's pre-existing behavior where an admin's
|
|
246
|
+
* stated reason describes the whole cancellation, not which system funded
|
|
247
|
+
* which slice of it.
|
|
248
|
+
*/
|
|
249
|
+
export async function buildCancellationCreditGrants(admin, opts) {
|
|
250
|
+
const actorLabel = opts.actor === 'admin' ? 'Booking cancelled by staff' : 'Booking cancelled by customer';
|
|
251
|
+
const cashReason = opts.reasonOverride || `${actorLabel} — credit issued (cash-funded portion)`;
|
|
252
|
+
const creditReason = (source) => opts.reasonOverride || `${actorLabel} — credit issued (credit-funded portion, source=${source})`;
|
|
253
|
+
return buildSplitCreditGrants(admin, {
|
|
254
|
+
bookingId: opts.bookingId,
|
|
255
|
+
contactEmail: opts.contactEmail,
|
|
256
|
+
ghlContactId: opts.ghlContactId,
|
|
257
|
+
cashPortionCents: opts.cashPortionCents,
|
|
258
|
+
creditPortionCents: opts.creditPortionCents,
|
|
259
|
+
defaultExp: opts.defaultExp,
|
|
260
|
+
cashReason,
|
|
261
|
+
creditReason,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const RESERVATION_WIFI_ENABLED_ROOM_SLUGS: Set<string>;
|
|
2
|
+
export declare function isReservationWifiRoom(slug: string | null | undefined): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* HMAC-SHA256(secret, booking_id), truncated to the first 5 digest bytes,
|
|
5
|
+
* read as a big-endian integer, then repeatedly divmod-32'd into 7 symbols.
|
|
6
|
+
* The LAST computed remainder is the FIRST output character (the digits come
|
|
7
|
+
* out least-significant-first from repeated divmod, so the char list is
|
|
8
|
+
* built in that order and then reversed) -- this must match
|
|
9
|
+
* reservation_wifi_code.py's `derive_code` exactly:
|
|
10
|
+
*
|
|
11
|
+
* digest = hmac.new(secret, booking_id, sha256).digest()
|
|
12
|
+
* num = int.from_bytes(digest[:5], byteorder="big")
|
|
13
|
+
* chars = []
|
|
14
|
+
* for _ in range(7):
|
|
15
|
+
* num, rem = divmod(num, 32)
|
|
16
|
+
* chars.append(ALPHABET[rem])
|
|
17
|
+
* return "".join(reversed(chars))
|
|
18
|
+
*/
|
|
19
|
+
export declare function deriveReservationWifiCode(secret: string, bookingId: string): Promise<string>;
|
|
@@ -1,81 +1,67 @@
|
|
|
1
|
-
// Derived, per-booking guest-WiFi code -- NEVER stored. Computed fresh from
|
|
2
|
-
// RESERVATION_WIFI_CODE_SECRET + the booking's own id, wherever it's needed
|
|
3
|
-
// (confirmation email, manage-booking page). ftw-middleware's
|
|
4
|
-
// reservation_wifi_code.py implements the IDENTICAL algorithm against the
|
|
5
|
-
// same secret and validates guest connections against it live -- this file
|
|
6
|
-
// must keep byte-for-byte parity with that reference or every code shown to
|
|
7
|
-
// a guest here will fail to validate there. See
|
|
8
|
-
// RESERVATION-SCOPED-GUEST-WIFI-DESIGN.md's 2026-09-02 addendum.
|
|
9
|
-
//
|
|
10
|
-
// Because the code is derived, not stored, a cancelled booking's code simply
|
|
11
|
-
// stops being honored on the middleware side (which only trusts currently
|
|
12
|
-
// live/paid bookings) -- there is nothing to invalidate here.
|
|
13
|
-
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* chars
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
// depend on).
|
|
69
|
-
let num = 0n;
|
|
70
|
-
for (let i = 0; i < DIGEST_BYTES_NEEDED; i++) {
|
|
71
|
-
num = (num << 8n) | BigInt(digest[i]);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const chars: string[] = [];
|
|
75
|
-
for (let i = 0; i < CODE_LENGTH; i++) {
|
|
76
|
-
const rem = num % 32n;
|
|
77
|
-
num = num / 32n;
|
|
78
|
-
chars.push(ALPHABET[Number(rem)]);
|
|
79
|
-
}
|
|
80
|
-
return chars.reverse().join('');
|
|
81
|
-
}
|
|
1
|
+
// Derived, per-booking guest-WiFi code -- NEVER stored. Computed fresh from
|
|
2
|
+
// RESERVATION_WIFI_CODE_SECRET + the booking's own id, wherever it's needed
|
|
3
|
+
// (confirmation email, manage-booking page). ftw-middleware's
|
|
4
|
+
// reservation_wifi_code.py implements the IDENTICAL algorithm against the
|
|
5
|
+
// same secret and validates guest connections against it live -- this file
|
|
6
|
+
// must keep byte-for-byte parity with that reference or every code shown to
|
|
7
|
+
// a guest here will fail to validate there. See
|
|
8
|
+
// RESERVATION-SCOPED-GUEST-WIFI-DESIGN.md's 2026-09-02 addendum.
|
|
9
|
+
//
|
|
10
|
+
// Because the code is derived, not stored, a cancelled booking's code simply
|
|
11
|
+
// stops being honored on the middleware side (which only trusts currently
|
|
12
|
+
// live/paid bookings) -- there is nothing to invalidate here.
|
|
13
|
+
// 32 symbols, no 0/O/1/I -- chosen to avoid transcription errors when a guest
|
|
14
|
+
// reads this off a screen and types it into a WiFi captive portal.
|
|
15
|
+
const ALPHABET = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ';
|
|
16
|
+
const CODE_LENGTH = 7;
|
|
17
|
+
const DIGEST_BYTES_NEEDED = 5;
|
|
18
|
+
// Rollout scope: the 4 hourly meeting rooms only (room slugs, confirmed
|
|
19
|
+
// against private.room_contract_tier()'s tier-1 list minus 'executive-office',
|
|
20
|
+
// which is a private office, not a bookable meeting room). Do NOT add Cove,
|
|
21
|
+
// Midtown, or Commons here without a deliberate follow-up decision -- this is
|
|
22
|
+
// an explicit allowlist, not a "hourly booking_mode" inference, so adding a
|
|
23
|
+
// future hourly room to `rooms` does NOT silently enable this feature for it.
|
|
24
|
+
export const RESERVATION_WIFI_ENABLED_ROOM_SLUGS = new Set([
|
|
25
|
+
'gallery',
|
|
26
|
+
'town-hall',
|
|
27
|
+
'loft',
|
|
28
|
+
'nook',
|
|
29
|
+
]);
|
|
30
|
+
export function isReservationWifiRoom(slug) {
|
|
31
|
+
return typeof slug === 'string' && RESERVATION_WIFI_ENABLED_ROOM_SLUGS.has(slug);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* HMAC-SHA256(secret, booking_id), truncated to the first 5 digest bytes,
|
|
35
|
+
* read as a big-endian integer, then repeatedly divmod-32'd into 7 symbols.
|
|
36
|
+
* The LAST computed remainder is the FIRST output character (the digits come
|
|
37
|
+
* out least-significant-first from repeated divmod, so the char list is
|
|
38
|
+
* built in that order and then reversed) -- this must match
|
|
39
|
+
* reservation_wifi_code.py's `derive_code` exactly:
|
|
40
|
+
*
|
|
41
|
+
* digest = hmac.new(secret, booking_id, sha256).digest()
|
|
42
|
+
* num = int.from_bytes(digest[:5], byteorder="big")
|
|
43
|
+
* chars = []
|
|
44
|
+
* for _ in range(7):
|
|
45
|
+
* num, rem = divmod(num, 32)
|
|
46
|
+
* chars.append(ALPHABET[rem])
|
|
47
|
+
* return "".join(reversed(chars))
|
|
48
|
+
*/
|
|
49
|
+
export async function deriveReservationWifiCode(secret, bookingId) {
|
|
50
|
+
const key = await crypto.subtle.importKey('raw', new TextEncoder().encode(secret), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']);
|
|
51
|
+
const digest = new Uint8Array(await crypto.subtle.sign('HMAC', key, new TextEncoder().encode(bookingId)));
|
|
52
|
+
// Big-endian bytes -> bigint (bigint, not number, so this is exact for the
|
|
53
|
+
// full 5-byte/40-bit range -- Number.MAX_SAFE_INTEGER only covers 53 bits
|
|
54
|
+
// but there's no reason to trust that margin here for something guests
|
|
55
|
+
// depend on).
|
|
56
|
+
let num = 0n;
|
|
57
|
+
for (let i = 0; i < DIGEST_BYTES_NEEDED; i++) {
|
|
58
|
+
num = (num << 8n) | BigInt(digest[i]);
|
|
59
|
+
}
|
|
60
|
+
const chars = [];
|
|
61
|
+
for (let i = 0; i < CODE_LENGTH; i++) {
|
|
62
|
+
const rem = num % 32n;
|
|
63
|
+
num = num / 32n;
|
|
64
|
+
chars.push(ALPHABET[Number(rem)]);
|
|
65
|
+
}
|
|
66
|
+
return chars.reverse().join('');
|
|
67
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const CallOutcome: z.ZodEnum<["booking_completed", "transferred_to_staff", "transferred_to_event_day", "transfer_failed_no_answer", "tool_error_occurred", "inquiry_only_no_action", "abandoned_unclear", "day_pass_purchased", "membership_signup_completed", "callback_logged_after_hours"]>;
|
|
3
|
+
export interface ParsedCallAnalyzed {
|
|
4
|
+
callId: string | null;
|
|
5
|
+
callOutcome: z.infer<typeof CallOutcome> | null;
|
|
6
|
+
callerName: string | null;
|
|
7
|
+
callbackNumber: string | null;
|
|
8
|
+
inquiryReason: string | null;
|
|
9
|
+
hadToolError: boolean | null;
|
|
10
|
+
durationMs: number | null;
|
|
11
|
+
needsAlert: boolean;
|
|
12
|
+
fromNumber: string | null;
|
|
13
|
+
callbackPromised: boolean | null;
|
|
14
|
+
}
|
|
15
|
+
/** True for the "act on this" event; false for any other Retell event type. */
|
|
16
|
+
export declare function isCallAnalyzedEvent(raw: unknown): boolean;
|
|
17
|
+
/** Returns null if `raw` isn't a well-formed call_analyzed payload. */
|
|
18
|
+
export declare function parseCallAnalyzed(raw: unknown): ParsedCallAnalyzed | null;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Pure payload parsing/decision logic for the `call_analyzed` Retell event,
|
|
2
|
+
// split out of retell-call-webhook/index.ts so it's importable and testable
|
|
3
|
+
// without booting the HTTP handler (which calls Deno.serve at module load).
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
// Outcomes the Retell agent's post-call analysis is configured to emit.
|
|
6
|
+
export const CallOutcome = z.enum([
|
|
7
|
+
'booking_completed',
|
|
8
|
+
'transferred_to_staff',
|
|
9
|
+
'transferred_to_event_day',
|
|
10
|
+
'transfer_failed_no_answer',
|
|
11
|
+
'tool_error_occurred',
|
|
12
|
+
'inquiry_only_no_action',
|
|
13
|
+
'abandoned_unclear',
|
|
14
|
+
// Added 2026-08-25: the Retell agent's post_call_analysis_data gained these
|
|
15
|
+
// two outcome values on 2026-08-24 (round 2, day pass + membership signup
|
|
16
|
+
// tools) but this enum was never updated to match. Because call_outcome is
|
|
17
|
+
// strictly typed here (not passthrough), any call_analyzed payload with one
|
|
18
|
+
// of the two missing values failed the whole zod parse, and the webhook
|
|
19
|
+
// handler silently no-opped (zero ops_events logging, zero alerting, zero
|
|
20
|
+
// fallback GHL sync) for every such call since 2026-08-24. See the
|
|
21
|
+
// gc-voice-ai-agent skill's 2026-08-25 dated log for the full incident —
|
|
22
|
+
// keep this enum in sync with the agent's real post_call_analysis_data
|
|
23
|
+
// call_outcome enum going forward; check both any time either changes.
|
|
24
|
+
'day_pass_purchased',
|
|
25
|
+
'membership_signup_completed',
|
|
26
|
+
// Added 2026-09-04, restored 2026-09-10 after an accidental removal: the
|
|
27
|
+
// agent emits this when a caller reaches us outside business hours and
|
|
28
|
+
// leaves a callback request. Missing from this enum, the whole
|
|
29
|
+
// call_analyzed payload fails to parse and the call is silently dropped
|
|
30
|
+
// (no ops_events row, no alert, no GHL fallback sync) -- see the
|
|
31
|
+
// 2026-08-25 incident note above.
|
|
32
|
+
'callback_logged_after_hours',
|
|
33
|
+
]);
|
|
34
|
+
// Every field here is optional/may be absent — the agent's analysis prompt
|
|
35
|
+
// can fail to extract a field, or simply have nothing to say for it.
|
|
36
|
+
const CustomAnalysisData = z.object({
|
|
37
|
+
call_outcome: CallOutcome.optional(),
|
|
38
|
+
caller_name: z.string().max(200).optional(),
|
|
39
|
+
callback_number: z.string().max(40).optional(),
|
|
40
|
+
inquiry_reason: z.string().max(2000).optional(),
|
|
41
|
+
had_tool_error: z.boolean().optional(),
|
|
42
|
+
callback_promised: z.boolean().optional(),
|
|
43
|
+
}).partial().passthrough();
|
|
44
|
+
const CallAnalyzedBody = z.object({
|
|
45
|
+
event: z.literal('call_analyzed'),
|
|
46
|
+
call: z.object({
|
|
47
|
+
call_id: z.string().max(200).optional(),
|
|
48
|
+
duration_ms: z.number().optional(),
|
|
49
|
+
start_timestamp: z.number().optional(),
|
|
50
|
+
end_timestamp: z.number().optional(),
|
|
51
|
+
from_number: z.string().max(40).optional(),
|
|
52
|
+
call_analysis: z.object({
|
|
53
|
+
custom_analysis_data: CustomAnalysisData.optional(),
|
|
54
|
+
}).partial().passthrough().optional(),
|
|
55
|
+
}).partial().passthrough().optional(),
|
|
56
|
+
}).passthrough();
|
|
57
|
+
// Any other Retell event (call_started, call_ended, ...) — just the event
|
|
58
|
+
// name matters here; the payload otherwise passes through unread.
|
|
59
|
+
const OtherEventBody = z.object({ event: z.string() }).passthrough();
|
|
60
|
+
const OUTCOMES_REQUIRING_ALERT = new Set(['transfer_failed_no_answer', 'tool_error_occurred']);
|
|
61
|
+
/** True for the "act on this" event; false for any other Retell event type. */
|
|
62
|
+
export function isCallAnalyzedEvent(raw) {
|
|
63
|
+
const parsed = OtherEventBody.safeParse(raw);
|
|
64
|
+
return parsed.success && parsed.data.event === 'call_analyzed';
|
|
65
|
+
}
|
|
66
|
+
/** Returns null if `raw` isn't a well-formed call_analyzed payload. */
|
|
67
|
+
export function parseCallAnalyzed(raw) {
|
|
68
|
+
const parsed = CallAnalyzedBody.safeParse(raw);
|
|
69
|
+
if (!parsed.success)
|
|
70
|
+
return null;
|
|
71
|
+
const call = parsed.data.call ?? {};
|
|
72
|
+
const data = call.call_analysis?.custom_analysis_data ?? {};
|
|
73
|
+
const durationMs = call.duration_ms
|
|
74
|
+
?? (typeof call.start_timestamp === 'number' && typeof call.end_timestamp === 'number'
|
|
75
|
+
? call.end_timestamp - call.start_timestamp
|
|
76
|
+
: null);
|
|
77
|
+
const badOutcome = data.call_outcome !== undefined && OUTCOMES_REQUIRING_ALERT.has(data.call_outcome);
|
|
78
|
+
const needsAlert = badOutcome || data.had_tool_error === true;
|
|
79
|
+
return {
|
|
80
|
+
callId: call.call_id ?? null,
|
|
81
|
+
callOutcome: data.call_outcome ?? null,
|
|
82
|
+
callerName: data.caller_name ?? null,
|
|
83
|
+
callbackNumber: data.callback_number ?? null,
|
|
84
|
+
inquiryReason: data.inquiry_reason ?? null,
|
|
85
|
+
hadToolError: data.had_tool_error ?? null,
|
|
86
|
+
durationMs,
|
|
87
|
+
needsAlert,
|
|
88
|
+
fromNumber: call.from_number ?? null,
|
|
89
|
+
callbackPromised: data.callback_promised ?? null,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const RETELL_SIGNATURE_HEADER = "X-Retell-Signature";
|
|
2
|
+
export declare const RETELL_MAX_SKEW_MS: number;
|
|
3
|
+
export declare function timingSafeEqualHex(a: string, b: string): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Computes the expected hex digest for a given raw body + header timestamp.
|
|
6
|
+
* Split out from `verifyRetellSignature` so tests can exercise the HMAC
|
|
7
|
+
* computation directly without constructing a `Request`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function computeRetellSignature(secret: string, rawBody: string, timestampRaw: string): Promise<string>;
|
|
10
|
+
/**
|
|
11
|
+
* `callerLabel` (e.g. 'voice-booking', 'retell-call-webhook') is only used to
|
|
12
|
+
* namespace the console.warn / Slack alert when the secret is unset.
|
|
13
|
+
*/
|
|
14
|
+
export declare function verifyRetellSignature(req: Request, rawBody: string, callerLabel: string): Promise<boolean>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Shared Retell webhook signature verification, used by both `voice-booking`
|
|
2
|
+
// and `retell-call-webhook` — do not reimplement this per function.
|
|
3
|
+
//
|
|
4
|
+
// Header `X-Retell-Signature: v={unix_ms},d={hex}`; digest is
|
|
5
|
+
// HMAC-SHA256(raw_body + timestamp_string) keyed with RETELL_SIGNING_SECRET,
|
|
6
|
+
// with the timestamp used verbatim as it appears in the header. Matches
|
|
7
|
+
// Retell's `Retell.verify(body, apiKey, signature)` helper.
|
|
8
|
+
// While RETELL_SIGNING_SECRET is unset this is a no-op: one console.warn plus
|
|
9
|
+
// a best-effort Slack alert (so the gap doesn't fire silently in production
|
|
10
|
+
// with nobody noticing), and the request proceeds. Enforcement turns on by
|
|
11
|
+
// itself the moment the secret exists.
|
|
12
|
+
import { sendSlackAlert, OPS_ALERTS_CHANNEL_ID } from './slackAlert.js';
|
|
13
|
+
export const RETELL_SIGNATURE_HEADER = 'X-Retell-Signature';
|
|
14
|
+
export const RETELL_MAX_SKEW_MS = 5 * 60 * 1000;
|
|
15
|
+
export function timingSafeEqualHex(a, b) {
|
|
16
|
+
// Fixed-length walk: a length mismatch still consumes the whole loop.
|
|
17
|
+
const len = Math.max(a.length, b.length);
|
|
18
|
+
let diff = a.length ^ b.length;
|
|
19
|
+
for (let i = 0; i < len; i++) {
|
|
20
|
+
diff |= (a.charCodeAt(i) | 0) ^ (b.charCodeAt(i) | 0);
|
|
21
|
+
}
|
|
22
|
+
return diff === 0;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Computes the expected hex digest for a given raw body + header timestamp.
|
|
26
|
+
* Split out from `verifyRetellSignature` so tests can exercise the HMAC
|
|
27
|
+
* computation directly without constructing a `Request`.
|
|
28
|
+
*/
|
|
29
|
+
export async function computeRetellSignature(secret, rawBody, timestampRaw) {
|
|
30
|
+
const key = await crypto.subtle.importKey('raw', new TextEncoder().encode(secret), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']);
|
|
31
|
+
const sig = await crypto.subtle.sign('HMAC', key, new TextEncoder().encode(rawBody + timestampRaw));
|
|
32
|
+
return Array.from(new Uint8Array(sig))
|
|
33
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
34
|
+
.join('');
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* `callerLabel` (e.g. 'voice-booking', 'retell-call-webhook') is only used to
|
|
38
|
+
* namespace the console.warn / Slack alert when the secret is unset.
|
|
39
|
+
*/
|
|
40
|
+
export async function verifyRetellSignature(req, rawBody, callerLabel) {
|
|
41
|
+
const secret = Deno.env.get('RETELL_SIGNING_SECRET');
|
|
42
|
+
if (!secret) {
|
|
43
|
+
console.warn(`[${callerLabel}] RETELL_SIGNING_SECRET not set — signature verification disabled`);
|
|
44
|
+
// Best-effort — must never block or throw over a missing/unreachable Slack.
|
|
45
|
+
void sendSlackAlert(OPS_ALERTS_CHANNEL_ID, `:warning: GC Connect *${callerLabel}* received a Retell webhook with RETELL_SIGNING_SECRET unset — signature verification is disabled.`);
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
const header = req.headers.get(RETELL_SIGNATURE_HEADER);
|
|
49
|
+
if (!header)
|
|
50
|
+
return false;
|
|
51
|
+
const m = /^v=(\d+),d=([0-9a-fA-F]+)$/.exec(header.trim());
|
|
52
|
+
if (!m)
|
|
53
|
+
return false;
|
|
54
|
+
const [, tsRaw, provided] = m;
|
|
55
|
+
const ts = Number(tsRaw);
|
|
56
|
+
if (!Number.isFinite(ts) || Math.abs(Date.now() - ts) > RETELL_MAX_SKEW_MS)
|
|
57
|
+
return false;
|
|
58
|
+
const expected = await computeRetellSignature(secret, rawBody, tsRaw);
|
|
59
|
+
return timingSafeEqualHex(expected, provided.toLowerCase());
|
|
60
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
type SupabaseLike = SupabaseClient<any, 'public', any>;
|
|
3
|
+
export type SignedUnpaidReminderEmailResult = 'sent' | 'skipped' | 'failed_retryable' | 'failed_permanent';
|
|
4
|
+
export declare function sendSignedUnpaidReminderEmail(supabase: SupabaseLike, { email, name, portalUrl, officeNumber }: {
|
|
5
|
+
email: string;
|
|
6
|
+
name?: string | null;
|
|
7
|
+
portalUrl: string;
|
|
8
|
+
officeNumber?: string | null;
|
|
9
|
+
}, operator: {
|
|
10
|
+
name: string;
|
|
11
|
+
shortName: string;
|
|
12
|
+
domain: string;
|
|
13
|
+
supportEmail: string;
|
|
14
|
+
}): Promise<SignedUnpaidReminderEmailResult>;
|
|
15
|
+
export {};
|