hedge-broker 0.2.0 → 0.3.0
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/index.js +57 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -571,6 +571,17 @@ function registerSubmissions(program2) {
|
|
|
571
571
|
ready: m.ready ? "yes" : "no",
|
|
572
572
|
needs_from_you: (m.needs_from_you || []).join("; ")
|
|
573
573
|
})), ["market", "ready", "needs_from_you"]) + "\n");
|
|
574
|
+
} else {
|
|
575
|
+
const hint = typeof r.marketing_hint === "string" && r.marketing_hint ? r.marketing_hint : null;
|
|
576
|
+
if (r.marketing_status === "matching") {
|
|
577
|
+
process.stdout.write("\nNo markets yet - " + (hint ?? "Hedge is matching carrier markets now (usually ~5 minutes after finalize); re-run this in a few minutes.") + "\n");
|
|
578
|
+
} else if (r.marketing_status === "not_started") {
|
|
579
|
+
process.stdout.write("\nNo markets yet - " + (hint ?? "run hedge finalize " + submissionId + " to start marketing.") + "\n");
|
|
580
|
+
} else if (r.marketing_status === "no_markets_matched") {
|
|
581
|
+
process.stdout.write("\nNo markets attached - " + (hint ?? "Hedge is reviewing options for this risk and will follow up.") + "\n");
|
|
582
|
+
} else {
|
|
583
|
+
process.stdout.write("\nNo markets yet. If you just finalized, matching usually completes within ~5 minutes - re-run this shortly or use hedge status " + submissionId + ".\n");
|
|
584
|
+
}
|
|
574
585
|
}
|
|
575
586
|
if (r.carrier_api_sessions?.length) {
|
|
576
587
|
process.stdout.write("\nInstant-quote carriers:\n" + table(r.carrier_api_sessions.map((s) => ({
|
|
@@ -594,6 +605,8 @@ function registerSubmissions(program2) {
|
|
|
594
605
|
status: l.status_label ?? l.status,
|
|
595
606
|
quote: l.quote_premium ?? ""
|
|
596
607
|
}))), ["carrier", "line", "status", "quote"]) + "\n");
|
|
608
|
+
} else {
|
|
609
|
+
process.stdout.write("\nNo markets attached yet. Matching usually completes within ~5 minutes of finalize - re-run this shortly (or check hedge requirements " + submissionId + ").\n");
|
|
597
610
|
}
|
|
598
611
|
const byStatus = s.status_summary?.by_status;
|
|
599
612
|
if (byStatus && Object.keys(byStatus).length) {
|
|
@@ -617,11 +630,51 @@ function registerSubmissions(program2) {
|
|
|
617
630
|
premium: r.premium ?? ""
|
|
618
631
|
})), ["id", "insured", "lines", "status", "premium"]) + "\n");
|
|
619
632
|
});
|
|
620
|
-
program2.command("finalize <submissionId>").description("Start marketing the submission to carriers").action(async (submissionId) => {
|
|
633
|
+
program2.command("finalize <submissionId>").description("Start marketing the submission to carriers").option("--wait", "poll until markets attach (usually ~5 minutes), then print them").option("--timeout <minutes>", "how long --wait polls before giving up", "8").action(async (submissionId, opts) => {
|
|
621
634
|
const ctx = makeCtx(program2.opts());
|
|
622
635
|
const r = await apiRequest(ctx.client, "POST", `/broker/submissions/${submissionId}/finalize`);
|
|
623
|
-
if (ctx.json) return printJson(r);
|
|
624
|
-
|
|
636
|
+
if (ctx.json && !opts.wait) return printJson(r);
|
|
637
|
+
if (!opts.wait) {
|
|
638
|
+
const wait = Number(r.typical_wait_seconds) > 0 ? Math.round(Number(r.typical_wait_seconds) / 60) : 5;
|
|
639
|
+
process.stdout.write(
|
|
640
|
+
`Marketing started. Markets usually attach within ~${wait} minutes.
|
|
641
|
+
Track with: hedge status ${submissionId} (or use finalize --wait next time)
|
|
642
|
+
`
|
|
643
|
+
);
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
const timeoutMin = intFlag(opts.timeout, "--timeout");
|
|
647
|
+
const deadline = Date.now() + Math.max(1, timeoutMin) * 6e4;
|
|
648
|
+
process.stdout.write("Marketing started - waiting for markets to attach (usually ~5 minutes)");
|
|
649
|
+
let markets = [];
|
|
650
|
+
while (Date.now() < deadline) {
|
|
651
|
+
await new Promise((resolve) => setTimeout(resolve, 15e3));
|
|
652
|
+
process.stdout.write(".");
|
|
653
|
+
const s = await apiRequest(ctx.client, "GET", `/broker/submissions/${submissionId}`);
|
|
654
|
+
if (s.markets?.length) {
|
|
655
|
+
markets = s.markets;
|
|
656
|
+
break;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
process.stdout.write("\n");
|
|
660
|
+
if (!markets.length) {
|
|
661
|
+
process.stdout.write(
|
|
662
|
+
`Still matching after ${timeoutMin} minutes - this can occasionally take longer.
|
|
663
|
+
Check in with: hedge status ${submissionId} or hedge requirements ${submissionId}
|
|
664
|
+
`
|
|
665
|
+
);
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
const rows = markets.flatMap((m) => (m.lines || []).map((l) => ({
|
|
669
|
+
carrier: m.carrier_name,
|
|
670
|
+
line: l.lob_label ?? l.lob_slug,
|
|
671
|
+
status: l.status_label ?? l.status
|
|
672
|
+
})));
|
|
673
|
+
if (ctx.json) return printJson({ finalize: r, markets });
|
|
674
|
+
process.stdout.write(`Matched ${markets.length} market(s):
|
|
675
|
+
|
|
676
|
+
` + table(rows, ["carrier", "line", "status"]) + "\n");
|
|
677
|
+
process.stdout.write("\nNext: hedge requirements " + submissionId + " shows what each market still needs from you.\n");
|
|
625
678
|
});
|
|
626
679
|
program2.command("documents <submissionId>").description("List a submission's finalized documents (ACORDs, quotes, binders)").action(async (submissionId) => {
|
|
627
680
|
const ctx = makeCtx(program2.opts());
|
|
@@ -794,7 +847,7 @@ function registerQuotes(program2) {
|
|
|
794
847
|
|
|
795
848
|
// src/index.ts
|
|
796
849
|
var program = new Command();
|
|
797
|
-
program.name("hedge").description("Submit risks to Hedge and track them from your terminal.").version("0.
|
|
850
|
+
program.name("hedge").description("Submit risks to Hedge and track them from your terminal.").version("0.3.0").option("--staging", "use the staging environment").option("--json", "output raw JSON (for scripting)");
|
|
798
851
|
registerAuth(program);
|
|
799
852
|
registerSubmissions(program);
|
|
800
853
|
registerAppetite(program);
|
package/package.json
CHANGED