Public: anyone can read this; the crew can change it.
New deal starts from the agent's own standard contingency lengths, set once, so a market with a 7-day inspection does not retype it every deal #55
Check · Review · Land · Live done — Landed and live in production.
mason/deal-clock:mason/52-new-deal-starts-from-the-agent-s-own-sta → main 2 commits fork 2 threads · 2 unresolved
9 files
changed +182
−32
README.md +14
| @@ -139,6 +139,20 @@ your phone and email, so a party can call or write back straight from it. | ||
| 139 | 139 | Reminders you already sent keep the words you approved. A phone or email that |
| 140 | 140 | does not look right is ignored in favour of the sample, with a line in the log. |
| 141 | 141 | |
| 142 | Your contracts may use other standard contingency lengths. Set them once and | |
| 143 | every New deal form, its date preview, the API and the MCP tool start from them | |
| 144 | (you can still change any length for one deal): | |
| 145 | ||
| 146 | - `DEAL_CLOCK_INSPECTION_DAYS` (brief: 10), `DEAL_CLOCK_APPRAISAL_DAYS` (21), | |
| 147 | `DEAL_CLOCK_FINANCING_DAYS` (30), `DEAL_CLOCK_TITLE_DAYS` (14): days after the | |
| 148 | contract date. | |
| 149 | - `DEAL_CLOCK_WALKTHROUGH_DAYS` (1): days before closing. | |
| 150 | - `DEAL_CLOCK_BUSINESS_DAYS`: `1` to count business days by default; otherwise | |
| 151 | calendar days. | |
| 152 | ||
| 153 | A length that is missing, not a whole number, or outside 0 to 180 is the | |
| 154 | brief's, with a line in the log. The sample deals always use the brief's. | |
| 155 | ||
| 142 | 156 | ## What is real, and what is not yet |
| 143 | 157 | |
| 144 | 158 | - **Real:** the dates and their math, mark done, moves with their reasons, |
src/deadlines.ts +2 −8
| @@ -6,6 +6,7 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | import { addBusinessDays, addDays, daysBetween } from "./dates.ts"; |
| 9 | import { standard } from "./env.ts"; | |
| 9 | 10 | |
| 10 | 11 | export const PARTY_ROLES = [ |
| 11 | 12 | "buyer", |
| @@ -113,14 +114,7 @@ export interface Lengths { | ||
| 113 | 114 | /** Days before closing. */ |
| 114 | 115 | readonly walkthrough: number; |
| 115 | 116 | } |
| 116 | export const DEFAULT_LENGTHS: Lengths = { | |
| 117 | inspection: 10, | |
| 118 | appraisal: 21, | |
| 119 | financing: 30, | |
| 120 | title: 14, | |
| 121 | walkthrough: 1, | |
| 122 | }; | |
| 123 | export const LENGTH_MAX = 180; | |
| 117 | export const DEFAULT_LENGTHS: Lengths = standard.lengths; | |
| 124 | 118 | |
| 125 | 119 | export interface Planned { |
| 126 | 120 | readonly kind: Kind; |
src/deals.ts +4 −3
| @@ -14,13 +14,12 @@ import { | ||
| 14 | 14 | isClosed, |
| 15 | 15 | isPartyRole, |
| 16 | 16 | KIND, |
| 17 | LENGTH_MAX, | |
| 18 | 17 | schedule, |
| 19 | 18 | type Kind, |
| 20 | 19 | type Lengths, |
| 21 | 20 | type PartyRole, |
| 22 | 21 | } from "./deadlines.ts"; |
| 23 | import { agent as defaultAgent } from "./env.ts"; | |
| 22 | import { agent as defaultAgent, LENGTH_MAX, standard } from "./env.ts"; | |
| 24 | 23 | import { emit } from "./live.ts"; |
| 25 | 24 | import { draftsFor, type Agent, type Draft } from "./reminders.ts"; |
| 26 | 25 | import { audited, fail, ok, refuse, type Result } from "./result.ts"; |
| @@ -400,7 +399,9 @@ export function plan(input: NewDeal): Result<Plan> { | ||
| 400 | 399 | lengths[key] = n; |
| 401 | 400 | } |
| 402 | 401 | const businessDays = |
| 403 | input.businessDays === true || input.businessDays === "on" || input.businessDays === "1"; | |
| 402 | input.businessDays === undefined | |
| 403 | ? standard.businessDays | |
| 404 | : input.businessDays === true || input.businessDays === "on" || input.businessDays === "1"; | |
| 404 | 405 | return ok({ address, buyer, seller, contractDate, closingDate, lengths, businessDays }); |
| 405 | 406 | } |
| 406 | 407 |
src/env.ts +37
| @@ -52,3 +52,40 @@ export const agent = { | ||
| 52 | 52 | phone: setting("DEAL_CLOCK_PHONE", "(555) 010-0142", validPhone), |
| 53 | 53 | email: setting("DEAL_CLOCK_EMAIL", "[email protected]", validEmail), |
| 54 | 54 | } as const; |
| 55 | ||
| 56 | /** The brief's contingency lengths, in days: what a new deal starts from unless the agent says otherwise. */ | |
| 57 | export const BRIEF_LENGTHS = { | |
| 58 | inspection: 10, | |
| 59 | appraisal: 21, | |
| 60 | financing: 30, | |
| 61 | title: 14, | |
| 62 | walkthrough: 1, | |
| 63 | } as const; | |
| 64 | export const LENGTH_MAX = 180; | |
| 65 | ||
| 66 | /** | |
| 67 | * The agent's standard lengths from `DEAL_CLOCK_<NAME>_DAYS` and whether they | |
| 68 | * count business days. A missing, non-integer or out-of-range value is the | |
| 69 | * brief's, with one line in the log; it never stops the boot. | |
| 70 | */ | |
| 71 | export function resolveLengths(source: Record<string, string | undefined>): { | |
| 72 | lengths: { -readonly [K in keyof typeof BRIEF_LENGTHS]: number }; | |
| 73 | businessDays: boolean; | |
| 74 | } { | |
| 75 | const lengths = { ...BRIEF_LENGTHS } as { -readonly [K in keyof typeof BRIEF_LENGTHS]: number }; | |
| 76 | for (const key of Object.keys(BRIEF_LENGTHS) as (keyof typeof BRIEF_LENGTHS)[]) { | |
| 77 | const name = `DEAL_CLOCK_${key.toUpperCase()}_DAYS`; | |
| 78 | const v = (source[name] ?? "").trim(); | |
| 79 | if (v === "") continue; | |
| 80 | const n = Number(v); | |
| 81 | if (/^\d{1,3}$/.test(v) && n <= LENGTH_MAX) lengths[key] = n; | |
| 82 | else console.warn(`${name} is not a whole number of days, 0 to ${LENGTH_MAX}; using ${BRIEF_LENGTHS[key]}`); | |
| 83 | } | |
| 84 | const raw = (source.DEAL_CLOCK_BUSINESS_DAYS ?? "").trim().toLowerCase(); | |
| 85 | if (raw !== "" && !["1", "0", "true", "false"].includes(raw)) | |
| 86 | console.warn("DEAL_CLOCK_BUSINESS_DAYS is not valid; counting calendar days"); | |
| 87 | return { lengths, businessDays: raw === "1" || raw === "true" }; | |
| 88 | } | |
| 89 | ||
| 90 | /** What a new deal starts from: the form, its preview, the API and the MCP tool all read this one set. */ | |
| 91 | export const standard = resolveLengths(process.env); |
src/lengths.test.ts added +94
| @@ -0,0 +1,94 @@ | ||
| 1 | /** The agent's standard contingency lengths: set once, read by the form, preview, API and MCP. */ | |
| 2 | import { expect, test } from "bun:test"; | |
| 3 | import { BRIEF_LENGTHS, resolveLengths } from "./env.ts"; | |
| 4 | ||
| 5 | test("nothing set: the brief's lengths, calendar days", () => { | |
| 6 | const r = resolveLengths({}); | |
| 7 | expect(r.lengths).toEqual({ inspection: 10, appraisal: 21, financing: 30, title: 14, walkthrough: 1 }); | |
| 8 | expect(r.businessDays).toBe(false); | |
| 9 | expect(BRIEF_LENGTHS.inspection).toBe(10); | |
| 10 | }); | |
| 11 | ||
| 12 | test("set values replace the brief's; bad ones fall back without throwing", () => { | |
| 13 | const r = resolveLengths({ | |
| 14 | DEAL_CLOCK_INSPECTION_DAYS: "7", | |
| 15 | DEAL_CLOCK_APPRAISAL_DAYS: "abc", | |
| 16 | DEAL_CLOCK_FINANCING_DAYS: "181", | |
| 17 | DEAL_CLOCK_TITLE_DAYS: "-3", | |
| 18 | DEAL_CLOCK_WALKTHROUGH_DAYS: "0", | |
| 19 | DEAL_CLOCK_BUSINESS_DAYS: "1", | |
| 20 | }); | |
| 21 | expect(r.lengths).toEqual({ inspection: 7, appraisal: 21, financing: 30, title: 14, walkthrough: 0 }); | |
| 22 | expect(r.businessDays).toBe(true); | |
| 23 | expect(resolveLengths({ DEAL_CLOCK_TITLE_DAYS: "2.5" }).lengths.title).toBe(14); | |
| 24 | }); | |
| 25 | ||
| 26 | test("a set value changes the form's number, the computed dates and the API default", async () => { | |
| 27 | const script = ` | |
| 28 | const { plan } = await import("./src/deals.ts"); | |
| 29 | const { newDealPage } = await import("./src/pages/deal.ts"); | |
| 30 | const p = plan({ address: "1 Oak", buyer: "A", seller: "B", contractDate: "2026-10-01", closingDate: "2026-12-01" }); | |
| 31 | const html = newDealPage({ who: { role: "user", id: "u", name: "u" }, on: "2026-10-01" }); | |
| 32 | console.log(JSON.stringify({ i: p.value.lengths.inspection, biz: p.value.businessDays, | |
| 33 | field: /name="inspection"[^>]*value="(\\d+)"/.exec(html)?.[1], note: html.includes("standard") }));`; | |
| 34 | const run = async (env: Record<string, string>) => { | |
| 35 | const proc = Bun.spawn([process.execPath, "-e", script], { env: { ...process.env, ...env }, stdout: "pipe", stderr: "ignore" }); | |
| 36 | return JSON.parse(await new Response(proc.stdout).text()); | |
| 37 | }; | |
| 38 | expect(await run({ DEAL_CLOCK_INSPECTION_DAYS: "7" })).toEqual({ i: 7, biz: false, field: "7", note: true }); | |
| 39 | expect(await run({ DEAL_CLOCK_INSPECTION_DAYS: "x" })).toEqual({ i: 10, biz: false, field: "10", note: true }); | |
| 40 | }); | |
| 41 | ||
| 42 | test("with business days as the agent's standard, a form's unticked box still means calendar days", async () => { | |
| 43 | const script = ` | |
| 44 | const { mkdtempSync } = await import("node:fs"); | |
| 45 | const { tmpdir } = await import("node:os"); | |
| 46 | const { join } = await import("node:path"); | |
| 47 | const { serve } = await import("./src/server.ts"); | |
| 48 | const { sign } = await import("./src/who.ts"); | |
| 49 | const KEY = "k"; | |
| 50 | const server = serve({ port: 0, dataDir: mkdtempSync(join(tmpdir(), "app-len-")), identityKey: KEY }); | |
| 51 | const base = "http://" + server.hostname + ":" + server.port; | |
| 52 | const identity = "u1|alice|user|" + (Date.now() + 60000); | |
| 53 | const who = { "x-forge-identity": identity, "x-forge-signature": sign(identity, KEY) }; | |
| 54 | const fields = { address: "1 Oak", buyer: "A", seller: "B", contract_date: "2026-10-02", closing_date: "2026-12-01" }; | |
| 55 | const form = () => { const f = new FormData(); for (const [k, v] of Object.entries(fields)) f.set(k, v); return f; }; | |
| 56 | const first = await (await fetch(base + "/deals/new", { headers: who })).text(); | |
| 57 | const check = await (await fetch(base + "/deals/check", { method: "POST", body: form(), headers: who })).text(); | |
| 58 | const posted = await fetch(base + "/deals", { method: "POST", body: form(), headers: who, redirect: "manual" }); | |
| 59 | const formPage = await (await fetch(base + posted.headers.get("location"), { headers: who })).text(); | |
| 60 | const api = await fetch(base + "/api/deals", { method: "POST", headers: { ...who, "content-type": "application/json" }, body: JSON.stringify(fields) }); | |
| 61 | const apiBody = await api.json(); | |
| 62 | const apiPage = await (await fetch(base + "/deals/" + apiBody.id, { headers: who })).text(); | |
| 63 | const mcp = await (await fetch(base + "/mcp", { method: "POST", headers: { ...who, "content-type": "application/json" }, | |
| 64 | body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name: "open_deal", arguments: fields } }) })).json(); | |
| 65 | const mcpId = JSON.parse(mcp.result.content[0].text).id; | |
| 66 | const mcpPage = await (await fetch(base + "/deals/" + mcpId, { headers: who })).text(); | |
| 67 | const list = await (await fetch(base + "/mcp", { method: "POST", headers: { ...who, "content-type": "application/json" }, | |
| 68 | body: JSON.stringify({ jsonrpc: "2.0", id: 2, method: "tools/list" }) })).json(); | |
| 69 | const schema = list.result.tools.find((t) => t.name === "open_deal").inputSchema.properties; | |
| 70 | console.log(JSON.stringify({ | |
| 71 | firstTicked: first.includes('name="business_days" checked'), | |
| 72 | checkTicked: check.includes('name="business_days" checked'), | |
| 73 | formBiz: formPage.includes("business days"), | |
| 74 | apiBiz: apiPage.includes("business days"), | |
| 75 | mcpBiz: mcpPage.includes("business days"), | |
| 76 | mcpInspection: schema.inspection.default, mcpBizDefault: schema.business_days.default, | |
| 77 | })); | |
| 78 | server.stop(true);`; | |
| 79 | const proc = Bun.spawn([process.execPath, "-e", script], { | |
| 80 | env: { ...process.env, DEAL_CLOCK_BUSINESS_DAYS: "1", DEAL_CLOCK_INSPECTION_DAYS: "7" }, | |
| 81 | stdout: "pipe", | |
| 82 | stderr: "pipe", | |
| 83 | }); | |
| 84 | const out = await new Response(proc.stdout).text(); | |
| 85 | expect(JSON.parse(out)).toEqual({ | |
| 86 | firstTicked: true, | |
| 87 | checkTicked: false, | |
| 88 | formBiz: false, | |
| 89 | apiBiz: true, | |
| 90 | mcpBiz: true, | |
| 91 | mcpInspection: 7, | |
| 92 | mcpBizDefault: true, | |
| 93 | }); | |
| 94 | }); |
src/mcp.ts +8 −8
| @@ -9,7 +9,7 @@ | ||
| 9 | 9 | import type { Database } from "bun:sqlite"; |
| 10 | 10 | import { restoreSamples, type Result } from "./actions.ts"; |
| 11 | 11 | import { today } from "./dates.ts"; |
| 12 | import { PARTY_ROLES } from "./deadlines.ts"; | |
| 12 | import { DEFAULT_LENGTHS, PARTY_ROLES } from "./deadlines.ts"; | |
| 13 | 13 | import { |
| 14 | 14 | addDeadline, |
| 15 | 15 | addParty, |
| @@ -27,7 +27,7 @@ import { | ||
| 27 | 27 | declineReminder, |
| 28 | 28 | undoDecline, |
| 29 | 29 | } from "./deals.ts"; |
| 30 | import { agent, title } from "./env.ts"; | |
| 30 | import { agent, LENGTH_MAX, standard, title } from "./env.ts"; | |
| 31 | 31 | import { dueOn } from "./reminders.ts"; |
| 32 | 32 | import { FIND_REFUSAL, find, query } from "./find.ts"; |
| 33 | 33 | import { fields } from "./http.ts"; |
| @@ -194,12 +194,12 @@ export const tools: readonly Tool[] = [ | ||
| 194 | 194 | seller: { type: "string", maxLength: 100 }, |
| 195 | 195 | contract_date: { type: "string", format: "date" }, |
| 196 | 196 | closing_date: { type: "string", format: "date" }, |
| 197 | inspection: { type: "integer", minimum: 0 }, | |
| 198 | appraisal: { type: "integer", minimum: 0 }, | |
| 199 | financing: { type: "integer", minimum: 0 }, | |
| 200 | title: { type: "integer", minimum: 0 }, | |
| 201 | walkthrough: { type: "integer", minimum: 0 }, | |
| 202 | business_days: { type: "boolean" }, | |
| 197 | inspection: { type: "integer", minimum: 0, maximum: LENGTH_MAX, default: DEFAULT_LENGTHS.inspection }, | |
| 198 | appraisal: { type: "integer", minimum: 0, maximum: LENGTH_MAX, default: DEFAULT_LENGTHS.appraisal }, | |
| 199 | financing: { type: "integer", minimum: 0, maximum: LENGTH_MAX, default: DEFAULT_LENGTHS.financing }, | |
| 200 | title: { type: "integer", minimum: 0, maximum: LENGTH_MAX, default: DEFAULT_LENGTHS.title }, | |
| 201 | walkthrough: { type: "integer", minimum: 0, maximum: LENGTH_MAX, default: DEFAULT_LENGTHS.walkthrough }, | |
| 202 | business_days: { type: "boolean", default: standard.businessDays }, | |
| 203 | 203 | }, |
| 204 | 204 | required: ["address", "buyer", "seller", "contract_date", "closing_date"], |
| 205 | 205 | }, |
src/pages/deal.ts +3 −1
| @@ -6,6 +6,7 @@ | ||
| 6 | 6 | |
| 7 | 7 | import { addDays, relative, short, spoken } from "../dates.ts"; |
| 8 | 8 | import { canChange, canRemove, closedOn, type DealView, type Party, type Plan, type PlannedDate, type Sent } from "../deals.ts"; |
| 9 | import { standard } from "../env.ts"; | |
| 9 | 10 | import { DEFAULT_LENGTHS, PARTY_LABEL, PARTY_ROLES } from "../deadlines.ts"; |
| 10 | 11 | import { escape } from "../http.ts"; |
| 11 | 12 | import { MOMENT_LABEL } from "../reminders.ts"; |
| @@ -191,7 +192,7 @@ export function newDealPage(input: { | ||
| 191 | 192 | : ""; |
| 192 | 193 | const length = (name: keyof typeof DEFAULT_LENGTHS, label: string) => |
| 193 | 194 | `<label>${label}<input class="input" type="number" inputmode="numeric" name="${name}" min="0" max="180" value="${val(name, String(DEFAULT_LENGTHS[name]))}" required${bad(name)}>${why(name)}</label>`; |
| 194 | const ticked = values.business_days !== undefined; | |
| 195 | const ticked = state === undefined ? standard.businessDays : values.business_days !== undefined; | |
| 195 | 196 | const body = |
| 196 | 197 | who.role === "anon" |
| 197 | 198 | ? `<p class="crumb"><a href="/">← The clock</a></p><section class="card"><h1>New deal</h1><p><a href="/__forge/signin?to=/deals/new">Sign in</a> to open a deal.</p></section>` |
| @@ -199,6 +200,7 @@ export function newDealPage(input: { | ||
| 199 | 200 | <section class="card narrow"> |
| 200 | 201 | <h1>New deal</h1> |
| 201 | 202 | <p class="muted">The contract and closing dates, and the contingency lengths, set every date. You can move any of them after.</p> |
| 203 | <p class="muted small">The lengths start from your standard ones; change any for this deal.</p> | |
| 202 | 204 | <form class="stack" method="post" action="/deals"> |
| 203 | 205 | ${general} |
| 204 | 206 | <label>Property address<input class="input" name="address" required minlength="3" maxlength="200" autocomplete="off" placeholder="1418 Alder Lane" value="${val("address", "")}"${bad("address")}>${why("address")}</label> |
src/routes.ts +16 −9
| @@ -20,7 +20,8 @@ import { | ||
| 20 | 20 | type Failure, |
| 21 | 21 | type Result, |
| 22 | 22 | } from "./actions.ts"; |
| 23 | import { agent, commit, description, env, forgeUrl, publicOrigin, startedAt, title, version } from "./env.ts"; | |
| 23 | import { DEFAULT_LENGTHS } from "./deadlines.ts"; | |
| 24 | import { agent, commit, description, env, standard, forgeUrl, publicOrigin, startedAt, title, version } from "./env.ts"; | |
| 24 | 25 | import { |
| 25 | 26 | asset, |
| 26 | 27 | back, |
| @@ -231,12 +232,12 @@ const NEW_DEAL: Schema = { | ||
| 231 | 232 | seller: { type: "string", minLength: 1, maxLength: 100 }, |
| 232 | 233 | contract_date: DATE, |
| 233 | 234 | closing_date: DATE, |
| 234 | inspection: { type: "integer", minimum: 0, maximum: 180, default: 10 }, | |
| 235 | appraisal: { type: "integer", minimum: 0, maximum: 180, default: 21 }, | |
| 236 | financing: { type: "integer", minimum: 0, maximum: 180, default: 30 }, | |
| 237 | title: { type: "integer", minimum: 0, maximum: 180, default: 14 }, | |
| 238 | walkthrough: { type: "integer", minimum: 0, maximum: 180, default: 1 }, | |
| 239 | business_days: { type: "boolean", default: false }, | |
| 235 | inspection: { type: "integer", minimum: 0, maximum: 180, default: DEFAULT_LENGTHS.inspection }, | |
| 236 | appraisal: { type: "integer", minimum: 0, maximum: 180, default: DEFAULT_LENGTHS.appraisal }, | |
| 237 | financing: { type: "integer", minimum: 0, maximum: 180, default: DEFAULT_LENGTHS.financing }, | |
| 238 | title: { type: "integer", minimum: 0, maximum: 180, default: DEFAULT_LENGTHS.title }, | |
| 239 | walkthrough: { type: "integer", minimum: 0, maximum: 180, default: DEFAULT_LENGTHS.walkthrough }, | |
| 240 | business_days: { type: "boolean", default: standard.businessDays }, | |
| 240 | 241 | }, |
| 241 | 242 | required: ["address", "buyer", "seller", "contract_date", "closing_date"], |
| 242 | 243 | }; |
| @@ -317,6 +318,12 @@ async function form(c: Context): Promise<Record<string, string> | Response> { | ||
| 317 | 318 | return out; |
| 318 | 319 | } |
| 319 | 320 | |
| 321 | /** An unticked box is absent from a form: that says no, not "the agent's default". */ | |
| 322 | const fromForm = (f: Record<string, unknown>): Record<string, unknown> => ({ | |
This override is untested; add a test that fails without it (see body). |
||
| 323 | ...f, | |
| 324 | business_days: f.business_days ?? "0", | |
| 325 | }); | |
| 326 | ||
| 320 | 327 | /** A new deal from a form or a JSON body: the same names either way. */ |
| 321 | 328 | const newDeal = (f: Record<string, unknown>): NewDeal => ({ |
| 322 | 329 | address: f.address, |
| @@ -456,7 +463,7 @@ export const routes: readonly Route[] = [ | ||
| 456 | 463 | handle: async (c) => { |
| 457 | 464 | const f = await form(c); |
| 458 | 465 | if (f instanceof Response) return f; |
| 459 | const made = createDeal(c.db, c.who, newDeal(f)); | |
| 466 | const made = createDeal(c.db, c.who, newDeal(fromForm(f))); | |
| 460 | 467 | if (made.ok) return back("Deal opened. Every date is on the clock.", `/deals/${made.value.id}`); |
| 461 | 468 | if (made.error !== "invalid") return back(made.message, "/deals/new"); |
| 462 | 469 | return html(newDealPage({ who: c.who, on: today(), state: { values: f, problem: made } }), 422); |
| @@ -471,7 +478,7 @@ export const routes: readonly Route[] = [ | ||
| 471 | 478 | if (f instanceof Response) return f; |
| 472 | 479 | const may = mayOpen(c.who); |
| 473 | 480 | if (!may.ok) return back(may.message, "/deals/new"); |
| 474 | const planned = plan(newDeal(f)); | |
| 481 | const planned = plan(newDeal(fromForm(f))); | |
| 475 | 482 | if (!planned.ok) |
| 476 | 483 | return html(newDealPage({ who: c.who, on: today(), state: { values: f, problem: planned } }), 422); |
| 477 | 484 | const preview = { plan: planned.value, dates: plannedDates(planned.value) }; |
src/sample.ts +4 −3
| @@ -7,7 +7,8 @@ | ||
| 7 | 7 | |
| 8 | 8 | import type { Database } from "bun:sqlite"; |
| 9 | 9 | import { addDays, daysBetween, today } from "./dates.ts"; |
| 10 | import { DEFAULT_LENGTHS, type PartyRole } from "./deadlines.ts"; | |
| 10 | import { type PartyRole } from "./deadlines.ts"; | |
| 11 | import { BRIEF_LENGTHS } from "./env.ts"; | |
| 11 | 12 | import { insertDeal } from "./deals.ts"; |
| 12 | 13 | |
| 13 | 14 | export const SAMPLE = { id: "sample", name: "Sample data" }; |
| @@ -19,7 +20,7 @@ interface Sample { | ||
| 19 | 20 | /** Days from today. */ |
| 20 | 21 | readonly contract: number; |
| 21 | 22 | readonly closing: number; |
| 22 | readonly lengths?: Partial<typeof DEFAULT_LENGTHS>; | |
| 23 | readonly lengths?: Partial<typeof BRIEF_LENGTHS>; | |
| 23 | 24 | readonly parties: readonly [PartyRole, string, string][]; |
| 24 | 25 | readonly done?: readonly string[]; |
| 25 | 26 | readonly custom?: readonly [string, number, PartyRole, string][]; |
| @@ -213,7 +214,7 @@ function writeSamples(db: Database, on: string): void { | ||
| 213 | 214 | seller: s.seller, |
| 214 | 215 | contractDate: addDays(on, s.contract), |
| 215 | 216 | closingDate: addDays(on, s.closing), |
| 216 | lengths: { ...DEFAULT_LENGTHS, ...s.lengths }, | |
| 217 | lengths: { ...BRIEF_LENGTHS, ...s.lengths }, | |
| 217 | 218 | businessDays: false, |
| 218 | 219 | }); |
| 219 | 220 | db.query("INSERT INTO sample_deal (deal_id, sample) VALUES (?1, ?2)").run(deal.id, s.address); |
new above
offline
Re-exporting LENGTH_MAX only to keep old imports working; point importers at env.ts instead.