@yaotoshi/wa-followup-shared
v0.1.2
Published
Shared source contract (types + parser/builder) for the WhatsApp follow-up service and its consumer SDK
Maintainers
Readme
@yaotoshi/wa-followup-shared
The single source of truth for the WhatsApp follow-up service's source contract — the
{ status, message?, progress? } shape every consumer's source_check_url must return —
plus the request/response types shared with the consumer SDK.
Zero runtime dependencies. CommonJS output.
Install
npm install @yaotoshi/wa-followup-sharedUsage
Build the canonical contract response for your source_check_url handler:
import { buildStatus } from '@yaotoshi/wa-followup-shared';
// pending, with progress + a short note
export function GET(req, res) {
res.json(
buildStatus({
status: 'pending',
progress: { done: 2, total: 5 },
message: 'Menunggu approval',
}),
);
// => { status: 'pending', progress: { done: 2, total: 5 }, message: 'Menunggu approval' }
}Parse a raw contract body (the same logic the service uses), accepting the fields at the top
level or wrapped in a { data: { ... } } envelope:
import { parseSourceBody } from '@yaotoshi/wa-followup-shared';
parseSourceBody({ data: { status: 'done' } }); // => { status: 'done' }
parseSourceBody({ status: 'bogus' }); // throws — status is strictTypes
FollowupStatusValue = 'pending' | 'done' | 'failed'SourceStatus { status; message?; progress? }SourceProgress { done; total }CreateFollowupInput— thePOST /followupsrequest shape (initial_datais stored aslast_snapshotserver-side)PublicFollowup— the curated public response shape (secrets/internal fields omitted)
Requirements
Node 18+ (uses native fetch only if you call parseSourceBody on await res.json() results;
this package itself has no runtime deps).
License
MIT
