hedge-broker 0.3.0 → 0.3.2
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 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -565,6 +565,9 @@ function registerSubmissions(program2) {
|
|
|
565
565
|
const r = await apiRequest(ctx.client, "GET", `/broker/submissions/${submissionId}/requirements`);
|
|
566
566
|
if (ctx.json) return printJson(r);
|
|
567
567
|
process.stdout.write(kv({ insured: r.insured_name, lines: (r.lines || []).join(", "), state: r.state, forms: (r.forms || []).join(", ") }) + "\n");
|
|
568
|
+
if (r.forms?.length) {
|
|
569
|
+
process.stdout.write("(download blanks with: hedge form <form_key>)\n");
|
|
570
|
+
}
|
|
568
571
|
if (r.markets?.length) {
|
|
569
572
|
process.stdout.write("\nMarkets:\n" + table(r.markets.map((m) => ({
|
|
570
573
|
market: m.market_name,
|
|
@@ -645,36 +648,73 @@ Track with: hedge status ${submissionId} (or use finalize --wait next time)
|
|
|
645
648
|
}
|
|
646
649
|
const timeoutMin = intFlag(opts.timeout, "--timeout");
|
|
647
650
|
const deadline = Date.now() + Math.max(1, timeoutMin) * 6e4;
|
|
648
|
-
process.stdout.write("Marketing started - waiting for markets to
|
|
649
|
-
let
|
|
651
|
+
process.stdout.write("Marketing started - waiting for markets to match (usually ~5 minutes)");
|
|
652
|
+
let req = null;
|
|
653
|
+
let noMarkets = false;
|
|
650
654
|
while (Date.now() < deadline) {
|
|
651
655
|
await new Promise((resolve) => setTimeout(resolve, 15e3));
|
|
652
656
|
process.stdout.write(".");
|
|
653
|
-
const
|
|
654
|
-
if (
|
|
655
|
-
|
|
657
|
+
const view = await apiRequest(ctx.client, "GET", `/broker/submissions/${submissionId}/requirements`);
|
|
658
|
+
if (view.marketing_status === "matched" || view.markets?.length) {
|
|
659
|
+
req = view;
|
|
660
|
+
break;
|
|
661
|
+
}
|
|
662
|
+
if (view.marketing_status === "no_markets_matched") {
|
|
663
|
+
req = view;
|
|
664
|
+
noMarkets = true;
|
|
656
665
|
break;
|
|
657
666
|
}
|
|
658
667
|
}
|
|
659
668
|
process.stdout.write("\n");
|
|
660
|
-
if (!
|
|
669
|
+
if (!req) {
|
|
661
670
|
process.stdout.write(
|
|
662
671
|
`Still matching after ${timeoutMin} minutes - this can occasionally take longer.
|
|
663
|
-
Check in with: hedge
|
|
672
|
+
Check in with: hedge requirements ${submissionId}
|
|
664
673
|
`
|
|
665
674
|
);
|
|
666
675
|
return;
|
|
667
676
|
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
}
|
|
673
|
-
if (ctx.json) return printJson({ finalize: r,
|
|
674
|
-
|
|
677
|
+
if (noMarkets) {
|
|
678
|
+
if (ctx.json) return printJson({ finalize: r, requirements: req });
|
|
679
|
+
process.stdout.write((req.marketing_hint ?? "No carrier lanes attached - Hedge is reviewing options for this risk and will follow up.") + "\n");
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
if (ctx.json) return printJson({ finalize: r, requirements: req });
|
|
683
|
+
const rows = (req.markets || []).map((m) => ({
|
|
684
|
+
market: m.market_name,
|
|
685
|
+
ready: m.ready ? "yes" : "no",
|
|
686
|
+
needs_from_you: (m.needs_from_you || []).join("; ")
|
|
687
|
+
}));
|
|
688
|
+
process.stdout.write(`Matched ${rows.length} market(s):
|
|
675
689
|
|
|
676
|
-
` + table(rows, ["
|
|
677
|
-
|
|
690
|
+
` + table(rows, ["market", "ready", "needs_from_you"]) + "\n");
|
|
691
|
+
if (req.forms?.length) {
|
|
692
|
+
process.stdout.write("\nForms Hedge prepares: " + req.forms.join(", ") + "\n(download blanks with: hedge form <form_key>)\n");
|
|
693
|
+
}
|
|
694
|
+
process.stdout.write("\nTrack sends and quotes with: hedge status " + submissionId + "\n");
|
|
695
|
+
});
|
|
696
|
+
program2.command("forms [search]").description('Search the blank application-form catalog, e.g. hedge forms "liquor"').action(async (search) => {
|
|
697
|
+
const ctx = makeCtx(program2.opts());
|
|
698
|
+
const rows = await apiRequest(ctx.client, "GET", "/broker/forms", {
|
|
699
|
+
query: { q: search }
|
|
700
|
+
});
|
|
701
|
+
if (ctx.json) return printJson(rows);
|
|
702
|
+
if (!rows.length) {
|
|
703
|
+
process.stdout.write("No forms matched" + (search ? ` "${search}"` : "") + ".\n");
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
process.stdout.write(table(rows.map((f) => ({
|
|
707
|
+
form_key: f.form_key,
|
|
708
|
+
title: f.title ?? "",
|
|
709
|
+
acord: f.is_acord ? "yes" : "",
|
|
710
|
+
pages: f.page_count ?? ""
|
|
711
|
+
})), ["form_key", "title", "acord", "pages"]) + "\n");
|
|
712
|
+
process.stdout.write("\nDownload a blank with: hedge form <form_key>\n");
|
|
713
|
+
});
|
|
714
|
+
program2.command("form <formKey>").description("Download a blank application form by its catalog key (the keys `hedge requirements` lists)").option("-o, --output <file>", "output file (default <formKey>.pdf)").action(async (formKey, opts) => {
|
|
715
|
+
const ctx = makeCtx(program2.opts());
|
|
716
|
+
const out = await downloadRequest(ctx.client, "GET", `/broker/forms/${encodeURIComponent(formKey)}/pdf`, opts.output, `${formKey}.pdf`);
|
|
717
|
+
process.stdout.write("Saved " + out + "\n");
|
|
678
718
|
});
|
|
679
719
|
program2.command("documents <submissionId>").description("List a submission's finalized documents (ACORDs, quotes, binders)").action(async (submissionId) => {
|
|
680
720
|
const ctx = makeCtx(program2.opts());
|
|
@@ -847,7 +887,7 @@ function registerQuotes(program2) {
|
|
|
847
887
|
|
|
848
888
|
// src/index.ts
|
|
849
889
|
var program = new Command();
|
|
850
|
-
program.name("hedge").description("Submit risks to Hedge and track them from your terminal.").version("0.3.
|
|
890
|
+
program.name("hedge").description("Submit risks to Hedge and track them from your terminal.").version("0.3.2").option("--staging", "use the staging environment").option("--json", "output raw JSON (for scripting)");
|
|
851
891
|
registerAuth(program);
|
|
852
892
|
registerSubmissions(program);
|
|
853
893
|
registerAppetite(program);
|
package/package.json
CHANGED