/** * Supplied fictional request data. The changed variant is a LOCAL preview exercise only. * @param {TwilioVariant} variant * @returns {string} */ function twilioPracticeLine_(variant) { if (variant === 'baseline') return 'REQ-001 map ready.'; if (variant === 'changed') return 'REQ-001 map checked.'; throw new Error('TWILIO_UNKNOWN_FICTIONAL_VARIANT'); } /** * Only a small one-unit GSM-7 subset is accepted; no emoji, smart quotes or extended characters. * The actual consent-holding sender supplies its short identity, not a fictional organization. * @param {string} senderLabel @param {TwilioVariant} variant @param {string} id * @returns {string} */ function twilioBody_(senderLabel, variant, id) { if (!/^[A-Za-z][A-Za-z0-9 -]{1,23}$/.test(senderLabel) || senderLabel.trim() !== senderLabel || !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(id)) throw new Error('TWILIO_BODY_INPUT'); const body = senderLabel + ': Fictional workshop ' + twilioPracticeLine_(variant) + ' Ref ' + id + '. Reply STOP to unsubscribe.'; if (body.length > 160 || !/^[A-Za-z0-9 .:-]+$/.test(body)) throw new Error('TWILIO_ONE_SEGMENT_BODY_REQUIRED'); return body; } /** Describe only SMS-specific evidence. Never treat an unfamiliar channel status as delivery. @param {string} status @returns {string} */ function twilioStatusMeaning_(status) { switch (status) { case 'queued': return 'Twilio queued the SMS for its sender; not delivery.'; case 'sending': return 'Twilio is dispatching upstream; not delivery.'; case 'sent': return 'The nearest upstream carrier accepted it; not handset delivery.'; case 'delivered': return 'Twilio has a delivery confirmation; not proof a person read it.'; case 'undelivered': return 'Twilio received a non-delivery receipt; do not resend automatically.'; case 'failed': return 'Twilio reports failure to send; do not resend automatically.'; default: return 'Unexpected status for this direct SMS path; inspect without inferring delivery.'; } }