@simplelayer/graniteer-core 0.2.1 → 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} +26 -33
- 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} +2 -1
- 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 -192
- 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/rescheduleCredit.ts
DELETED
|
@@ -1,337 +0,0 @@
|
|
|
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
|
-
/**
|
|
37
|
-
* Floor applied to a capped credit-funded grant so it's never issued
|
|
38
|
-
* already-dead (or nearly so) just because the ORIGINAL credit it's capped
|
|
39
|
-
* against had already expired by refund/cancellation time. Kyle's call,
|
|
40
|
-
* E10/GATE-0188 follow-up, 2026-09-10.
|
|
41
|
-
*/
|
|
42
|
-
export const MIN_CREDIT_GRANT_LIFETIME_DAYS = 30;
|
|
43
|
-
|
|
44
|
-
/** Minimal structural client surface this module needs. */
|
|
45
|
-
export interface RescheduleCreditLookupClient {
|
|
46
|
-
// deno-lint-ignore no-explicit-any
|
|
47
|
-
from(table: string): any;
|
|
48
|
-
// deno-lint-ignore no-explicit-any
|
|
49
|
-
rpc(fn: string, args: Record<string, unknown>): PromiseLike<{ data: any; error: any }>;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* period_month is always the 1st of a calendar month (DB CHECK
|
|
54
|
-
* credit_periods_period_month_is_first) — pure calendar arithmetic, no
|
|
55
|
-
* timezone ambiguity in computing "the following month" from it.
|
|
56
|
-
*/
|
|
57
|
-
export function nextPeriodMonthStr(periodMonthStr: string): string {
|
|
58
|
-
const [y, m] = periodMonthStr.split('-').map((n) => parseInt(n, 10));
|
|
59
|
-
const ny = m === 12 ? y + 1 : y;
|
|
60
|
-
const nm = m === 12 ? 1 : m + 1;
|
|
61
|
-
return `${ny}-${String(nm).padStart(2, '0')}-01`;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export type OrigCreditExpiryResult =
|
|
65
|
-
| { exp: Date; source: 'system_a' | 'system_b'; errored: false }
|
|
66
|
-
| { exp: Date; source: 'error' | 'not_found'; errored: true; detail: string };
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Finds the real expiry that must cap a reschedule's credit-funded refund
|
|
70
|
-
* portion, by tracing which of the two credit mechanisms actually funded
|
|
71
|
-
* `bookingId`'s `credit_applied_cents`. See the module doc comment above.
|
|
72
|
-
*
|
|
73
|
-
* Returns `errored: true` whenever the real expiry could not be confirmed —
|
|
74
|
-
* a query failure OR (just as importantly) a *clean, zero-row* result
|
|
75
|
-
* despite the caller already knowing credit_applied_cents > 0. Both failure
|
|
76
|
-
* shapes are treated identically: fall back to `defaultExp`, but tell the
|
|
77
|
-
* caller so it can log at ERROR severity rather than silently over-granting.
|
|
78
|
-
*/
|
|
79
|
-
export async function resolveOriginalCreditExpiry(
|
|
80
|
-
admin: RescheduleCreditLookupClient,
|
|
81
|
-
bookingId: string,
|
|
82
|
-
defaultExp: Date,
|
|
83
|
-
): Promise<OrigCreditExpiryResult> {
|
|
84
|
-
try {
|
|
85
|
-
// System A: monthly membership credit, hold/consume rows keyed directly
|
|
86
|
-
// by booking_id (NOT entry_type='grant' — that's System B and was the
|
|
87
|
-
// first attempt's bug).
|
|
88
|
-
const { data: ledgerRows, error: ledgerErr } = await admin
|
|
89
|
-
.from('credits')
|
|
90
|
-
.select('period_id, entry_type, created_at')
|
|
91
|
-
.eq('booking_id', bookingId)
|
|
92
|
-
.in('entry_type', ['hold', 'consume'])
|
|
93
|
-
.order('created_at', { ascending: false })
|
|
94
|
-
.limit(1);
|
|
95
|
-
if (ledgerErr) throw ledgerErr;
|
|
96
|
-
const periodId = ledgerRows && ledgerRows.length > 0 ? ledgerRows[0].period_id : null;
|
|
97
|
-
if (periodId) {
|
|
98
|
-
const { data: periodRow, error: periodErr } = await admin
|
|
99
|
-
.from('credit_periods')
|
|
100
|
-
.select('period_month')
|
|
101
|
-
.eq('id', periodId)
|
|
102
|
-
.maybeSingle();
|
|
103
|
-
if (periodErr) throw periodErr;
|
|
104
|
-
if (periodRow?.period_month) {
|
|
105
|
-
const { data: anchor, error: anchorErr } = await admin.rpc('period_anchor', {
|
|
106
|
-
p_period_month: nextPeriodMonthStr(String(periodRow.period_month)),
|
|
107
|
-
});
|
|
108
|
-
if (anchorErr) throw anchorErr;
|
|
109
|
-
if (anchor) return { exp: new Date(anchor as string), source: 'system_a', errored: false };
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// System B: a prior reschedule's own cancellation credit, funding this
|
|
114
|
-
// booking via redeemed_booking_id. Deliberately NOT filtered on
|
|
115
|
-
// `redeemed_at IS NOT NULL`: that column is only set once
|
|
116
|
-
// credit_reservation_finalize succeeds, and both its call sites
|
|
117
|
-
// (reschedule-booking's own 4A branch, stripe-webhook) treat a finalize
|
|
118
|
-
// failure as log-only, non-fatal — leaving a PAID booking with
|
|
119
|
-
// redeemed_booking_id set and redeemed_at forever NULL. Requiring
|
|
120
|
-
// redeemed_at here would silently push exactly that booking down to
|
|
121
|
-
// 'not_found' and the full 1-year default, reopening the bug this module
|
|
122
|
-
// exists to close. redeemed_booking_id alone is already the real funding
|
|
123
|
-
// link (credit_reservation_release nulls it on an abandoned reservation,
|
|
124
|
-
// so a released grant can never false-positive here).
|
|
125
|
-
const { data: grantRows, error: grantErr } = await admin
|
|
126
|
-
.from('credits')
|
|
127
|
-
.select('expires_at')
|
|
128
|
-
.eq('redeemed_booking_id', bookingId)
|
|
129
|
-
.eq('entry_type', 'grant')
|
|
130
|
-
.order('expires_at', { ascending: true, nullsFirst: false })
|
|
131
|
-
.limit(1);
|
|
132
|
-
if (grantErr) throw grantErr;
|
|
133
|
-
if (grantRows && grantRows.length > 0) {
|
|
134
|
-
const rawExpiry = grantRows[0].expires_at;
|
|
135
|
-
// A funding row was found either way — this is NOT an error case. Every
|
|
136
|
-
// known producer of a System-B grant sets expires_at, but if one ever
|
|
137
|
-
// doesn't, there's simply nothing to cap against: fall back to the
|
|
138
|
-
// plain 1-year default without flagging it as a lookup failure.
|
|
139
|
-
return {
|
|
140
|
-
exp: rawExpiry ? new Date(rawExpiry) : defaultExp,
|
|
141
|
-
source: 'system_b',
|
|
142
|
-
errored: false,
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// credit_applied_cents > 0 but neither system explains it — a data-
|
|
147
|
-
// integrity gap, not the ordinary "no credit used" case (the caller only
|
|
148
|
-
// reaches this function when credit_applied_cents > 0). Never let this
|
|
149
|
-
// silently default to the full 1-year grant.
|
|
150
|
-
return {
|
|
151
|
-
exp: defaultExp,
|
|
152
|
-
source: 'not_found',
|
|
153
|
-
errored: true,
|
|
154
|
-
detail: 'no_funding_row_found_for_credit_applied_cents',
|
|
155
|
-
};
|
|
156
|
-
} catch (e) {
|
|
157
|
-
// Supabase/PostgREST errors thrown above (ledgerErr, periodErr, anchorErr,
|
|
158
|
-
// grantErr) are plain {message, code, ...} objects, NOT Error instances —
|
|
159
|
-
// `e instanceof Error` would miss them and collapse the detail down to
|
|
160
|
-
// the useless literal "[object Object]".
|
|
161
|
-
const message = typeof e === 'object' && e !== null && 'message' in e
|
|
162
|
-
? String((e as { message: unknown }).message)
|
|
163
|
-
: String(e);
|
|
164
|
-
return {
|
|
165
|
-
exp: defaultExp,
|
|
166
|
-
source: 'error',
|
|
167
|
-
errored: true,
|
|
168
|
-
detail: message,
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export interface RescheduleCreditGrant {
|
|
174
|
-
entry_type: 'grant';
|
|
175
|
-
contact_email: string;
|
|
176
|
-
ghl_contact_id: string | null;
|
|
177
|
-
delta_cents: number;
|
|
178
|
-
reason: string;
|
|
179
|
-
booking_id: string;
|
|
180
|
-
expires_at: string;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export interface BuildRescheduleCreditGrantsResult {
|
|
184
|
-
grants: RescheduleCreditGrant[];
|
|
185
|
-
/** True when the credit-portion expiry lookup failed/came up empty — caller should log at ERROR. */
|
|
186
|
-
expiryLookupErrored: boolean;
|
|
187
|
-
expiryLookupDetail?: string;
|
|
188
|
-
expirySource?: string;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Shared core: splits a refund/credit-issuance into up to two 'grant' rows
|
|
193
|
-
* with caller-supplied reason text for each portion. Used by both the
|
|
194
|
-
* reschedule path (buildRescheduleCreditGrants) and the cancellation paths
|
|
195
|
-
* (buildCancellationCreditGrants) below — the credit-system lookup and
|
|
196
|
-
* splitting logic is identical; only the ledger reason text differs.
|
|
197
|
-
*/
|
|
198
|
-
async function buildSplitCreditGrants(
|
|
199
|
-
admin: RescheduleCreditLookupClient,
|
|
200
|
-
opts: {
|
|
201
|
-
bookingId: string;
|
|
202
|
-
contactEmail: string;
|
|
203
|
-
ghlContactId: string | null;
|
|
204
|
-
cashPortionCents: number;
|
|
205
|
-
creditPortionCents: number;
|
|
206
|
-
defaultExp: Date;
|
|
207
|
-
cashReason: string;
|
|
208
|
-
creditReason: (source: string) => string;
|
|
209
|
-
},
|
|
210
|
-
): Promise<BuildRescheduleCreditGrantsResult> {
|
|
211
|
-
const { bookingId, contactEmail, ghlContactId, cashPortionCents, creditPortionCents, defaultExp, cashReason, creditReason } = opts;
|
|
212
|
-
const emailLower = contactEmail.toLowerCase();
|
|
213
|
-
const grants: RescheduleCreditGrant[] = [];
|
|
214
|
-
let expiryLookupErrored = false;
|
|
215
|
-
let expiryLookupDetail: string | undefined;
|
|
216
|
-
let expirySource: string | undefined;
|
|
217
|
-
|
|
218
|
-
if (cashPortionCents > 0) {
|
|
219
|
-
grants.push({
|
|
220
|
-
entry_type: 'grant',
|
|
221
|
-
contact_email: emailLower,
|
|
222
|
-
ghl_contact_id: ghlContactId,
|
|
223
|
-
delta_cents: cashPortionCents,
|
|
224
|
-
reason: cashReason,
|
|
225
|
-
booking_id: bookingId,
|
|
226
|
-
expires_at: defaultExp.toISOString(),
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if (creditPortionCents > 0) {
|
|
231
|
-
const resolved = await resolveOriginalCreditExpiry(admin, bookingId, defaultExp);
|
|
232
|
-
expirySource = resolved.source;
|
|
233
|
-
if (resolved.errored) {
|
|
234
|
-
expiryLookupErrored = true;
|
|
235
|
-
expiryLookupDetail = resolved.detail;
|
|
236
|
-
}
|
|
237
|
-
// Floor: never issue a grant that's ALREADY DEAD ON ARRIVAL just because
|
|
238
|
-
// the ORIGINAL credit it's being capped against had already expired by
|
|
239
|
-
// the time of this reschedule/cancellation. Kyle's call (E10/GATE-0188
|
|
240
|
-
// follow-up, 2026-09-10).
|
|
241
|
-
//
|
|
242
|
-
// The trigger is deliberately narrow — `resolved.exp` in the PAST, full
|
|
243
|
-
// stop — not "expiring within the floor window". A System-A (monthly
|
|
244
|
-
// membership credit) cap is USUALLY well under 30 days out (it's the
|
|
245
|
-
// real end of the current calendar month, per period_anchor()); a
|
|
246
|
-
// System-B grant capped at a genuinely short remaining lifetime is
|
|
247
|
-
// equally a correct, intended cap. Flooring either of those up to 30
|
|
248
|
-
// days would silently re-widen the exact laundering gap this module
|
|
249
|
-
// exists to close (an earlier draft of this floor made precisely that
|
|
250
|
-
// mistake — caught on review before merge — and would have let a member
|
|
251
|
-
// ratchet a near-expired credit's lifetime back up to 30 days on every
|
|
252
|
-
// cancel/rebook cycle). Only a TRULY expired original (already in the
|
|
253
|
-
// past) is a stale reference point rather than an intentional cap.
|
|
254
|
-
const finalExp = resolved.exp.getTime() < Date.now()
|
|
255
|
-
? new Date(Date.now() + MIN_CREDIT_GRANT_LIFETIME_DAYS * 24 * 60 * 60 * 1000)
|
|
256
|
-
: resolved.exp;
|
|
257
|
-
grants.push({
|
|
258
|
-
entry_type: 'grant',
|
|
259
|
-
contact_email: emailLower,
|
|
260
|
-
ghl_contact_id: ghlContactId,
|
|
261
|
-
delta_cents: creditPortionCents,
|
|
262
|
-
reason: creditReason(resolved.source),
|
|
263
|
-
booking_id: bookingId,
|
|
264
|
-
expires_at: finalExp.toISOString(),
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
return { grants, expiryLookupErrored, expiryLookupDetail, expirySource };
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Builds the credits-table INSERT payload for a reschedule's refund: up to
|
|
273
|
-
* two 'grant' rows — a cash-funded portion at the plain 1-year default, and
|
|
274
|
-
* (only if > 0) a credit-funded portion capped at the ORIGINAL credit's own
|
|
275
|
-
* expiry. A zero-cents portion is omitted entirely (a 'grant' row with
|
|
276
|
-
* delta_cents = 0 would violate credits_delta_sign_check).
|
|
277
|
-
*/
|
|
278
|
-
export async function buildRescheduleCreditGrants(
|
|
279
|
-
admin: RescheduleCreditLookupClient,
|
|
280
|
-
opts: {
|
|
281
|
-
bookingId: string;
|
|
282
|
-
contactEmail: string;
|
|
283
|
-
ghlContactId: string | null;
|
|
284
|
-
cashPortionCents: number;
|
|
285
|
-
creditPortionCents: number;
|
|
286
|
-
defaultExp: Date;
|
|
287
|
-
},
|
|
288
|
-
): Promise<BuildRescheduleCreditGrantsResult> {
|
|
289
|
-
return buildSplitCreditGrants(admin, {
|
|
290
|
-
...opts,
|
|
291
|
-
cashReason: 'Booking rescheduled by customer (cash-funded portion)',
|
|
292
|
-
creditReason: (source) => `Booking rescheduled by customer (credit-funded portion, source=${source})`,
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Same split as buildRescheduleCreditGrants, for the two cancellation paths
|
|
298
|
-
* (manage-booking's customer-initiated cancel, admin-cancel-booking's
|
|
299
|
-
* staff-initiated cancel/refund) — a cancellation credit carries exactly the
|
|
300
|
-
* same laundering risk a reschedule credit does: it must not extend a
|
|
301
|
-
* short-lived credit into a fresh 1-year grant just because it passed
|
|
302
|
-
* through a cancellation instead of a reschedule. See E10/GATE-0188.
|
|
303
|
-
*
|
|
304
|
-
* `reasonOverride`, when given (admin-cancel-booking's optional free-text
|
|
305
|
-
* reason field), replaces the whole default reason string for BOTH portions
|
|
306
|
-
* verbatim — matching this codebase's pre-existing behavior where an admin's
|
|
307
|
-
* stated reason describes the whole cancellation, not which system funded
|
|
308
|
-
* which slice of it.
|
|
309
|
-
*/
|
|
310
|
-
export async function buildCancellationCreditGrants(
|
|
311
|
-
admin: RescheduleCreditLookupClient,
|
|
312
|
-
opts: {
|
|
313
|
-
bookingId: string;
|
|
314
|
-
contactEmail: string;
|
|
315
|
-
ghlContactId: string | null;
|
|
316
|
-
cashPortionCents: number;
|
|
317
|
-
creditPortionCents: number;
|
|
318
|
-
defaultExp: Date;
|
|
319
|
-
actor: 'customer' | 'admin';
|
|
320
|
-
reasonOverride?: string | null;
|
|
321
|
-
},
|
|
322
|
-
): Promise<BuildRescheduleCreditGrantsResult> {
|
|
323
|
-
const actorLabel = opts.actor === 'admin' ? 'Booking cancelled by staff' : 'Booking cancelled by customer';
|
|
324
|
-
const cashReason = opts.reasonOverride || `${actorLabel} — credit issued (cash-funded portion)`;
|
|
325
|
-
const creditReason = (source: string) =>
|
|
326
|
-
opts.reasonOverride || `${actorLabel} — credit issued (credit-funded portion, source=${source})`;
|
|
327
|
-
return buildSplitCreditGrants(admin, {
|
|
328
|
-
bookingId: opts.bookingId,
|
|
329
|
-
contactEmail: opts.contactEmail,
|
|
330
|
-
ghlContactId: opts.ghlContactId,
|
|
331
|
-
cashPortionCents: opts.cashPortionCents,
|
|
332
|
-
creditPortionCents: opts.creditPortionCents,
|
|
333
|
-
defaultExp: opts.defaultExp,
|
|
334
|
-
cashReason,
|
|
335
|
-
creditReason,
|
|
336
|
-
});
|
|
337
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { assert, assertEquals, assertFalse } from 'https://deno.land/std@0.224.0/assert/mod.ts';
|
|
2
|
-
import {
|
|
3
|
-
deriveReservationWifiCode,
|
|
4
|
-
isReservationWifiRoom,
|
|
5
|
-
RESERVATION_WIFI_ENABLED_ROOM_SLUGS,
|
|
6
|
-
} from './reservationWifiCode.ts';
|
|
7
|
-
|
|
8
|
-
// Known-answer vectors cross-checked against ftw-middleware's own Python
|
|
9
|
-
// reference (reservation_wifi_code.py's `derive_code`), computed by running
|
|
10
|
-
// that exact algorithm in a scratch script:
|
|
11
|
-
//
|
|
12
|
-
// import hmac, hashlib
|
|
13
|
-
// _ALPHABET = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ"
|
|
14
|
-
// def derive_code(secret, booking_id):
|
|
15
|
-
// digest = hmac.new(secret.encode("utf-8"), booking_id.encode("utf-8"), hashlib.sha256).digest()
|
|
16
|
-
// num = int.from_bytes(digest[:5], byteorder="big")
|
|
17
|
-
// chars = []
|
|
18
|
-
// for _ in range(7):
|
|
19
|
-
// num, rem = divmod(num, 32)
|
|
20
|
-
// chars.append(_ALPHABET[rem])
|
|
21
|
-
// return "".join(reversed(chars))
|
|
22
|
-
//
|
|
23
|
-
// Output for these three (secret, booking_id) pairs:
|
|
24
|
-
// ("test-signing-secret", "18bc51ff-8d9d-4081-9cc8-4b87a1901e38") -> "RCET8NR"
|
|
25
|
-
// ("another-secret-xyz", "00000000-0000-0000-0000-000000000000") -> "6ZQ52X9"
|
|
26
|
-
// ("k", "payload") -> "HJWXRCP"
|
|
27
|
-
const KNOWN_ANSWERS: Array<[secret: string, bookingId: string, expected: string]> = [
|
|
28
|
-
['test-signing-secret', '18bc51ff-8d9d-4081-9cc8-4b87a1901e38', 'RCET8NR'],
|
|
29
|
-
['another-secret-xyz', '00000000-0000-0000-0000-000000000000', '6ZQ52X9'],
|
|
30
|
-
['k', 'payload', 'HJWXRCP'],
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
for (const [secret, bookingId, expected] of KNOWN_ANSWERS) {
|
|
34
|
-
Deno.test(`deriveReservationWifiCode: matches Python reference for (${secret}, ${bookingId})`, async () => {
|
|
35
|
-
const code = await deriveReservationWifiCode(secret, bookingId);
|
|
36
|
-
assertEquals(code, expected);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
Deno.test('deriveReservationWifiCode: output is always 7 characters from the restricted alphabet', async () => {
|
|
41
|
-
const code = await deriveReservationWifiCode('some-secret', 'b1');
|
|
42
|
-
assertEquals(code.length, 7);
|
|
43
|
-
assert(/^[23456789ABCDEFGHJKLMNPQRSTUVWXYZ]{7}$/.test(code));
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
Deno.test('deriveReservationWifiCode: different booking ids produce different codes', async () => {
|
|
47
|
-
const a = await deriveReservationWifiCode('same-secret', 'booking-a');
|
|
48
|
-
const b = await deriveReservationWifiCode('same-secret', 'booking-b');
|
|
49
|
-
assert(a !== b);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
Deno.test('deriveReservationWifiCode: different secrets produce different codes for the same booking', async () => {
|
|
53
|
-
const a = await deriveReservationWifiCode('secret-one', 'booking-x');
|
|
54
|
-
const b = await deriveReservationWifiCode('secret-two', 'booking-x');
|
|
55
|
-
assert(a !== b);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
Deno.test('isReservationWifiRoom: true only for the 4 enabled hourly meeting room slugs', () => {
|
|
59
|
-
for (const slug of RESERVATION_WIFI_ENABLED_ROOM_SLUGS) {
|
|
60
|
-
assert(isReservationWifiRoom(slug));
|
|
61
|
-
}
|
|
62
|
-
assertFalse(isReservationWifiRoom('executive-office'));
|
|
63
|
-
assertFalse(isReservationWifiRoom('cove'));
|
|
64
|
-
assertFalse(isReservationWifiRoom('midtown'));
|
|
65
|
-
assertFalse(isReservationWifiRoom('commons'));
|
|
66
|
-
assertFalse(isReservationWifiRoom(null));
|
|
67
|
-
assertFalse(isReservationWifiRoom(undefined));
|
|
68
|
-
assertFalse(isReservationWifiRoom(''));
|
|
69
|
-
});
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { assert, assertEquals, assertFalse } from 'https://deno.land/std@0.224.0/assert/mod.ts';
|
|
2
|
-
import { isCallAnalyzedEvent, parseCallAnalyzed } from './retellCallAnalyzed.ts';
|
|
3
|
-
|
|
4
|
-
Deno.test('isCallAnalyzedEvent: true for call_analyzed', () => {
|
|
5
|
-
assert(isCallAnalyzedEvent({ event: 'call_analyzed' }));
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
Deno.test('isCallAnalyzedEvent: false for other Retell event types', () => {
|
|
9
|
-
assertFalse(isCallAnalyzedEvent({ event: 'call_started' }));
|
|
10
|
-
assertFalse(isCallAnalyzedEvent({ event: 'call_ended' }));
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
Deno.test('isCallAnalyzedEvent: false for a malformed/eventless payload', () => {
|
|
14
|
-
assertFalse(isCallAnalyzedEvent({}));
|
|
15
|
-
assertFalse(isCallAnalyzedEvent(null));
|
|
16
|
-
assertFalse(isCallAnalyzedEvent('garbage'));
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
Deno.test('parseCallAnalyzed: extracts every custom_analysis_data field', () => {
|
|
20
|
-
const parsed = parseCallAnalyzed({
|
|
21
|
-
event: 'call_analyzed',
|
|
22
|
-
call: {
|
|
23
|
-
call_id: 'call_abc123',
|
|
24
|
-
duration_ms: 45000,
|
|
25
|
-
from_number: '+19165559999',
|
|
26
|
-
call_analysis: {
|
|
27
|
-
custom_analysis_data: {
|
|
28
|
-
call_outcome: 'booking_completed',
|
|
29
|
-
caller_name: 'Jane Doe',
|
|
30
|
-
callback_number: '+19165551234',
|
|
31
|
-
inquiry_reason: 'Asked about day passes',
|
|
32
|
-
had_tool_error: false,
|
|
33
|
-
callback_promised: true,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
assert(parsed);
|
|
39
|
-
assertEquals(parsed.callId, 'call_abc123');
|
|
40
|
-
assertEquals(parsed.callOutcome, 'booking_completed');
|
|
41
|
-
assertEquals(parsed.callerName, 'Jane Doe');
|
|
42
|
-
assertEquals(parsed.callbackNumber, '+19165551234');
|
|
43
|
-
assertEquals(parsed.inquiryReason, 'Asked about day passes');
|
|
44
|
-
assertEquals(parsed.hadToolError, false);
|
|
45
|
-
assertEquals(parsed.durationMs, 45000);
|
|
46
|
-
assertFalse(parsed.needsAlert);
|
|
47
|
-
assertEquals(parsed.fromNumber, '+19165559999');
|
|
48
|
-
assertEquals(parsed.callbackPromised, true);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
Deno.test('parseCallAnalyzed: every custom_analysis_data field is optional', () => {
|
|
52
|
-
const parsed = parseCallAnalyzed({ event: 'call_analyzed', call: { call_id: 'call_xyz' } });
|
|
53
|
-
assert(parsed);
|
|
54
|
-
assertEquals(parsed.callId, 'call_xyz');
|
|
55
|
-
assertEquals(parsed.callOutcome, null);
|
|
56
|
-
assertEquals(parsed.callerName, null);
|
|
57
|
-
assertEquals(parsed.callbackNumber, null);
|
|
58
|
-
assertEquals(parsed.inquiryReason, null);
|
|
59
|
-
assertEquals(parsed.hadToolError, null);
|
|
60
|
-
assertFalse(parsed.needsAlert);
|
|
61
|
-
assertEquals(parsed.fromNumber, null);
|
|
62
|
-
assertEquals(parsed.callbackPromised, null);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
Deno.test('parseCallAnalyzed: from_number is read from call, not custom_analysis_data', () => {
|
|
66
|
-
const parsed = parseCallAnalyzed({
|
|
67
|
-
event: 'call_analyzed',
|
|
68
|
-
call: { call_id: 'call_from_number', from_number: '+19165550000' },
|
|
69
|
-
});
|
|
70
|
-
assert(parsed);
|
|
71
|
-
assertEquals(parsed.fromNumber, '+19165550000');
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
Deno.test('parseCallAnalyzed: callback_promised absent parses as null, not false', () => {
|
|
75
|
-
const parsed = parseCallAnalyzed({
|
|
76
|
-
event: 'call_analyzed',
|
|
77
|
-
call: { call_analysis: { custom_analysis_data: { call_outcome: 'booking_completed' } } },
|
|
78
|
-
});
|
|
79
|
-
assert(parsed);
|
|
80
|
-
assertEquals(parsed.callbackPromised, null);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
Deno.test('parseCallAnalyzed: missing call/call_analysis entirely still parses', () => {
|
|
84
|
-
const parsed = parseCallAnalyzed({ event: 'call_analyzed' });
|
|
85
|
-
assert(parsed);
|
|
86
|
-
assertEquals(parsed.callId, null);
|
|
87
|
-
assertFalse(parsed.needsAlert);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
Deno.test('parseCallAnalyzed: derives duration from start/end timestamps when duration_ms is absent', () => {
|
|
91
|
-
const parsed = parseCallAnalyzed({
|
|
92
|
-
event: 'call_analyzed',
|
|
93
|
-
call: { start_timestamp: 1000, end_timestamp: 9500 },
|
|
94
|
-
});
|
|
95
|
-
assert(parsed);
|
|
96
|
-
assertEquals(parsed.durationMs, 8500);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
Deno.test('parseCallAnalyzed: returns null for a non-call_analyzed payload', () => {
|
|
100
|
-
assertEquals(parseCallAnalyzed({ event: 'call_started' }), null);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
for (const outcome of ['transfer_failed_no_answer', 'tool_error_occurred']) {
|
|
104
|
-
Deno.test(`parseCallAnalyzed: needsAlert is true for call_outcome=${outcome}`, () => {
|
|
105
|
-
const parsed = parseCallAnalyzed({
|
|
106
|
-
event: 'call_analyzed',
|
|
107
|
-
call: { call_analysis: { custom_analysis_data: { call_outcome: outcome } } },
|
|
108
|
-
});
|
|
109
|
-
assert(parsed);
|
|
110
|
-
assert(parsed.needsAlert);
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
for (const outcome of [
|
|
115
|
-
'booking_completed',
|
|
116
|
-
'transferred_to_staff',
|
|
117
|
-
'transferred_to_event_day',
|
|
118
|
-
'inquiry_only_no_action',
|
|
119
|
-
'abandoned_unclear',
|
|
120
|
-
'day_pass_purchased',
|
|
121
|
-
'membership_signup_completed',
|
|
122
|
-
'callback_logged_after_hours',
|
|
123
|
-
]) {
|
|
124
|
-
Deno.test(`parseCallAnalyzed: needsAlert is false for call_outcome=${outcome}`, () => {
|
|
125
|
-
const parsed = parseCallAnalyzed({
|
|
126
|
-
event: 'call_analyzed',
|
|
127
|
-
call: { call_analysis: { custom_analysis_data: { call_outcome: outcome } } },
|
|
128
|
-
});
|
|
129
|
-
assert(parsed);
|
|
130
|
-
assertFalse(parsed.needsAlert);
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// Regression test for the 2026-08-25 incident: these two outcomes were added
|
|
135
|
-
// to the live Retell agent's post_call_analysis_data on 2026-08-24 but this
|
|
136
|
-
// module's CallOutcome enum wasn't updated to match, so any call_analyzed
|
|
137
|
-
// payload carrying one of them failed the whole parse and the webhook
|
|
138
|
-
// handler silently no-opped. This test exists so that gap can never recur
|
|
139
|
-
// silently again — see the gc-voice-ai-agent skill's dated log for the full
|
|
140
|
-
// incident.
|
|
141
|
-
for (const outcome of ['day_pass_purchased', 'membership_signup_completed', 'callback_logged_after_hours']) {
|
|
142
|
-
Deno.test(`parseCallAnalyzed: does not reject call_outcome=${outcome} (2026-08-25 regression)`, () => {
|
|
143
|
-
const parsed = parseCallAnalyzed({
|
|
144
|
-
event: 'call_analyzed',
|
|
145
|
-
call: { call_id: 'call_regression_check', call_analysis: { custom_analysis_data: { call_outcome: outcome } } },
|
|
146
|
-
});
|
|
147
|
-
assert(parsed, `expected a parsed result for call_outcome=${outcome}, got null`);
|
|
148
|
-
assertEquals(parsed.callOutcome, outcome);
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
Deno.test('parseCallAnalyzed: needsAlert is true when had_tool_error is true regardless of outcome', () => {
|
|
153
|
-
const parsed = parseCallAnalyzed({
|
|
154
|
-
event: 'call_analyzed',
|
|
155
|
-
call: { call_analysis: { custom_analysis_data: { call_outcome: 'booking_completed', had_tool_error: true } } },
|
|
156
|
-
});
|
|
157
|
-
assert(parsed);
|
|
158
|
-
assert(parsed.needsAlert);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
Deno.test('parseCallAnalyzed: rejects an unknown call_outcome value rather than passing it through', () => {
|
|
162
|
-
const parsed = parseCallAnalyzed({
|
|
163
|
-
event: 'call_analyzed',
|
|
164
|
-
call: { call_analysis: { custom_analysis_data: { call_outcome: 'not_a_real_outcome' } } },
|
|
165
|
-
});
|
|
166
|
-
assertEquals(parsed, null);
|
|
167
|
-
});
|
|
@@ -1,113 +0,0 @@
|
|
|
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 'npm:zod@3.23.8';
|
|
5
|
-
|
|
6
|
-
// Outcomes the Retell agent's post-call analysis is configured to emit.
|
|
7
|
-
export const CallOutcome = z.enum([
|
|
8
|
-
'booking_completed',
|
|
9
|
-
'transferred_to_staff',
|
|
10
|
-
'transferred_to_event_day',
|
|
11
|
-
'transfer_failed_no_answer',
|
|
12
|
-
'tool_error_occurred',
|
|
13
|
-
'inquiry_only_no_action',
|
|
14
|
-
'abandoned_unclear',
|
|
15
|
-
// Added 2026-08-25: the Retell agent's post_call_analysis_data gained these
|
|
16
|
-
// two outcome values on 2026-08-24 (round 2, day pass + membership signup
|
|
17
|
-
// tools) but this enum was never updated to match. Because call_outcome is
|
|
18
|
-
// strictly typed here (not passthrough), any call_analyzed payload with one
|
|
19
|
-
// of the two missing values failed the whole zod parse, and the webhook
|
|
20
|
-
// handler silently no-opped (zero ops_events logging, zero alerting, zero
|
|
21
|
-
// fallback GHL sync) for every such call since 2026-08-24. See the
|
|
22
|
-
// gc-voice-ai-agent skill's 2026-08-25 dated log for the full incident —
|
|
23
|
-
// keep this enum in sync with the agent's real post_call_analysis_data
|
|
24
|
-
// call_outcome enum going forward; check both any time either changes.
|
|
25
|
-
'day_pass_purchased',
|
|
26
|
-
'membership_signup_completed',
|
|
27
|
-
// Added 2026-09-04, restored 2026-09-10 after an accidental removal: the
|
|
28
|
-
// agent emits this when a caller reaches us outside business hours and
|
|
29
|
-
// leaves a callback request. Missing from this enum, the whole
|
|
30
|
-
// call_analyzed payload fails to parse and the call is silently dropped
|
|
31
|
-
// (no ops_events row, no alert, no GHL fallback sync) -- see the
|
|
32
|
-
// 2026-08-25 incident note above.
|
|
33
|
-
'callback_logged_after_hours',
|
|
34
|
-
]);
|
|
35
|
-
|
|
36
|
-
// Every field here is optional/may be absent — the agent's analysis prompt
|
|
37
|
-
// can fail to extract a field, or simply have nothing to say for it.
|
|
38
|
-
const CustomAnalysisData = z.object({
|
|
39
|
-
call_outcome: CallOutcome.optional(),
|
|
40
|
-
caller_name: z.string().max(200).optional(),
|
|
41
|
-
callback_number: z.string().max(40).optional(),
|
|
42
|
-
inquiry_reason: z.string().max(2000).optional(),
|
|
43
|
-
had_tool_error: z.boolean().optional(),
|
|
44
|
-
callback_promised: z.boolean().optional(),
|
|
45
|
-
}).partial().passthrough();
|
|
46
|
-
|
|
47
|
-
const CallAnalyzedBody = z.object({
|
|
48
|
-
event: z.literal('call_analyzed'),
|
|
49
|
-
call: z.object({
|
|
50
|
-
call_id: z.string().max(200).optional(),
|
|
51
|
-
duration_ms: z.number().optional(),
|
|
52
|
-
start_timestamp: z.number().optional(),
|
|
53
|
-
end_timestamp: z.number().optional(),
|
|
54
|
-
from_number: z.string().max(40).optional(),
|
|
55
|
-
call_analysis: z.object({
|
|
56
|
-
custom_analysis_data: CustomAnalysisData.optional(),
|
|
57
|
-
}).partial().passthrough().optional(),
|
|
58
|
-
}).partial().passthrough().optional(),
|
|
59
|
-
}).passthrough();
|
|
60
|
-
|
|
61
|
-
// Any other Retell event (call_started, call_ended, ...) — just the event
|
|
62
|
-
// name matters here; the payload otherwise passes through unread.
|
|
63
|
-
const OtherEventBody = z.object({ event: z.string() }).passthrough();
|
|
64
|
-
|
|
65
|
-
const OUTCOMES_REQUIRING_ALERT = new Set(['transfer_failed_no_answer', 'tool_error_occurred']);
|
|
66
|
-
|
|
67
|
-
export interface ParsedCallAnalyzed {
|
|
68
|
-
callId: string | null;
|
|
69
|
-
callOutcome: z.infer<typeof CallOutcome> | null;
|
|
70
|
-
callerName: string | null;
|
|
71
|
-
callbackNumber: string | null;
|
|
72
|
-
inquiryReason: string | null;
|
|
73
|
-
hadToolError: boolean | null;
|
|
74
|
-
durationMs: number | null;
|
|
75
|
-
needsAlert: boolean;
|
|
76
|
-
fromNumber: string | null;
|
|
77
|
-
callbackPromised: boolean | null;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/** True for the "act on this" event; false for any other Retell event type. */
|
|
81
|
-
export function isCallAnalyzedEvent(raw: unknown): boolean {
|
|
82
|
-
const parsed = OtherEventBody.safeParse(raw);
|
|
83
|
-
return parsed.success && parsed.data.event === 'call_analyzed';
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/** Returns null if `raw` isn't a well-formed call_analyzed payload. */
|
|
87
|
-
export function parseCallAnalyzed(raw: unknown): ParsedCallAnalyzed | null {
|
|
88
|
-
const parsed = CallAnalyzedBody.safeParse(raw);
|
|
89
|
-
if (!parsed.success) return null;
|
|
90
|
-
|
|
91
|
-
const call = parsed.data.call ?? {};
|
|
92
|
-
const data = call.call_analysis?.custom_analysis_data ?? {};
|
|
93
|
-
const durationMs = call.duration_ms
|
|
94
|
-
?? (typeof call.start_timestamp === 'number' && typeof call.end_timestamp === 'number'
|
|
95
|
-
? call.end_timestamp - call.start_timestamp
|
|
96
|
-
: null);
|
|
97
|
-
|
|
98
|
-
const badOutcome = data.call_outcome !== undefined && OUTCOMES_REQUIRING_ALERT.has(data.call_outcome);
|
|
99
|
-
const needsAlert = badOutcome || data.had_tool_error === true;
|
|
100
|
-
|
|
101
|
-
return {
|
|
102
|
-
callId: call.call_id ?? null,
|
|
103
|
-
callOutcome: data.call_outcome ?? null,
|
|
104
|
-
callerName: data.caller_name ?? null,
|
|
105
|
-
callbackNumber: data.callback_number ?? null,
|
|
106
|
-
inquiryReason: data.inquiry_reason ?? null,
|
|
107
|
-
hadToolError: data.had_tool_error ?? null,
|
|
108
|
-
durationMs,
|
|
109
|
-
needsAlert,
|
|
110
|
-
fromNumber: call.from_number ?? null,
|
|
111
|
-
callbackPromised: data.callback_promised ?? null,
|
|
112
|
-
};
|
|
113
|
-
}
|