@aglyn/aglyn 1.0.0-beta.271 → 1.0.0-beta.273
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/package.json +11 -11
- package/src/lib/app-utils/account-preferences.d.ts +50 -0
- package/src/lib/app-utils/account-preferences.js +96 -0
- package/src/lib/app-utils/account-preferences.js.map +1 -1
- package/src/lib/app-utils/analytics-events.d.ts +3 -2
- package/src/lib/app-utils/analytics-events.js.map +1 -1
- package/src/lib/app-utils/client-build.d.ts +4 -1
- package/src/lib/app-utils/client-build.js.map +1 -1
- package/src/lib/app-utils/docs-help-sections.generated.js +6 -1
- package/src/lib/app-utils/docs-help-sections.generated.js.map +1 -1
- package/src/lib/app-utils/docs-help.generated.d.ts +7 -1
- package/src/lib/app-utils/docs-help.generated.js +22 -0
- package/src/lib/app-utils/docs-help.generated.js.map +1 -1
- package/src/lib/app-utils/docs-index.generated.js +15 -8
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/plan-card-meters.d.ts +96 -0
- package/src/lib/app-utils/plan-card-meters.js +197 -0
- package/src/lib/app-utils/plan-card-meters.js.map +1 -0
- package/src/lib/app-utils/release-flags.d.ts +1 -1
- package/src/lib/app-utils/release-flags.js +12 -0
- package/src/lib/app-utils/release-flags.js.map +1 -1
- package/src/lib/app-utils/site-care.d.ts +25 -2
- package/src/lib/app-utils/site-care.js +28 -1
- package/src/lib/app-utils/site-care.js.map +1 -1
- package/src/lib/foundation/definitions/platform.types.d.ts +20 -0
- package/src/lib/foundation/definitions/platform.types.js.map +1 -1
- package/src/lib/plugin-manager/first-party-plugins.generated.js +16 -0
- package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
- package/src/lib/plugin-manager/plugin-media-ingest.d.ts +18 -1
- package/src/lib/plugin-manager/plugin-media-ingest.js.map +1 -1
- package/src/lib/plugin-manager/plugin-resource-drafts.d.ts +30 -0
- package/src/lib/plugin-manager/plugin-resource-drafts.js.map +1 -1
- package/src/lib/plugin-manager/plugin-site-resources.d.ts +74 -0
- package/src/lib/plugin-manager/plugin-site-resources.js +135 -0
- package/src/lib/plugin-manager/plugin-site-resources.js.map +1 -0
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/ import { SITE_CARE_EXTRA_HOUR_USD, SITE_CARE_INCLUDED_BLOCK_MINUTES, SITE_CARE_INCLUDED_MINUTES } from "./plan-entitlements.js";
|
|
17
|
+
import { operatorIdentity } from "./operator-identity.js";
|
|
17
18
|
import { describeHours } from "./owner-approval-record.js";
|
|
18
19
|
/**
|
|
19
20
|
* SITE CARE REQUESTS: THE ARITHMETIC (AGL-3959).
|
|
@@ -51,7 +52,33 @@ import { describeHours } from "./owner-approval-record.js";
|
|
|
51
52
|
* product carries (the Decision Log of 2026-10-18), read off the Site Care
|
|
52
53
|
* product, which is checked to carry it before anything is charged.
|
|
53
54
|
*/ export const SITE_CARE_EXTRA_TIME_TAX_CODE = 'txcd_10103001';
|
|
54
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* WHERE A CHANGE IS EMAILED (AGL-3997): the support address. Site Care has no
|
|
57
|
+
* address of its own. An owner writes to the support address they already
|
|
58
|
+
* know, and a message to it from a member of a workspace with Site Care files
|
|
59
|
+
* itself as a request; every other message is ordinary support mail. The
|
|
60
|
+
* support mailbox also delivers each message to `support@<inbound mail
|
|
61
|
+
* domain>`, where the mail provider announces it, and every Site Care email
|
|
62
|
+
* replies to `support+<requestId>@<inbound mail domain>`, so an answer joins
|
|
63
|
+
* its own request.
|
|
64
|
+
*/ export const SITE_CARE_INBOUND_LOCAL_PART = 'support';
|
|
65
|
+
/**
|
|
66
|
+
* The operator's support address, from the operator identity: what an owner
|
|
67
|
+
* is told to email a change to, and what the intake reads as one. `null` on
|
|
68
|
+
* a deployment that publishes no support address, where Request a change on
|
|
69
|
+
* a site's dashboard is the only way in.
|
|
70
|
+
*/ export function siteCareSupportAddress() {
|
|
71
|
+
return operatorIdentity().supportEmail;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The Reply-To of a Site Care email: `support+<requestId>@<domain>` for an
|
|
75
|
+
* email about one request, so the answer joins it; the support address for
|
|
76
|
+
* one about no single request (a statement, a project), so the answer reaches
|
|
77
|
+
* the support inbox like any other message to it.
|
|
78
|
+
*/ export function siteCareReplyAddress(requestId, domain, supportEmail = siteCareSupportAddress()) {
|
|
79
|
+
if (requestId) return `${SITE_CARE_INBOUND_LOCAL_PART}+${requestId}@${domain}`;
|
|
80
|
+
return supportEmail != null ? supportEmail : `${SITE_CARE_INBOUND_LOCAL_PART}@${domain}`;
|
|
81
|
+
}
|
|
55
82
|
/** The longest title and message a request keeps. */ export const SITE_CARE_SUBJECT_MAX = 150;
|
|
56
83
|
export const SITE_CARE_BODY_MAX = 5000;
|
|
57
84
|
/** Stripe's limit on an invoice item's description is generous; ours is not. */ export const SITE_CARE_LINE_DESCRIPTION_MAX = 480;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/site-care.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n SITE_CARE_EXTRA_HOUR_USD,\n SITE_CARE_INCLUDED_BLOCK_MINUTES,\n SITE_CARE_INCLUDED_MINUTES,\n} from './plan-entitlements'\nimport { describeHours, type OwnerApprovalRecord } from './owner-approval-record'\n\n/**\n * SITE CARE REQUESTS: THE ARITHMETIC (AGL-3959).\n *\n * A Site Care owner asks for a change by email or from the console, and the\n * request is a support ticket tagged `siteCare`. Staff open it (a timer\n * starts), make the change, and close it with one number: the minutes. This\n * module is everything about that which needs no Firestore and no Stripe —\n * the month a request counts in, how its minutes are counted against the\n * included hour, what the close allows, what extra time bills, and the\n * statement the month adds up to. The routes, the staff panel, the owner's\n * Billing card and the reconciliation all read it, so they cannot disagree.\n *\n * ## The rules, from the Decision Log of 2026-10-19\n *\n * - The included hour is `SITE_CARE_INCLUDED_MINUTES` a month, no rollover,\n * plus any goodwill minutes staff add to that month. Each request counts\n * against it in `SITE_CARE_INCLUDED_BLOCK_MINUTES` blocks, rounded UP.\n * - A request's share of the hour is fixed when it closes, against what the\n * month's earlier requests left. Correcting one request's minutes later\n * recomputes that request alone, against the same remainder, so a fix\n * never moves a charge on a request nobody touched.\n * - Past the hour, extra time bills at `SITE_CARE_EXTRA_HOUR_USD` per\n * STARTED hour — whole hours, rounded up — and never less than the hours\n * the owner approved. With no approval on file, or more time than was\n * approved, the close is blocked: ask the owner first, or absorb it (no\n * charge, the minutes still count).\n */\n\n/** The `kind` a Site Care support ticket carries. */\nexport const SITE_CARE_TICKET_KIND = 'siteCare'\n\n/** Site Care's promise: done within two business days. */\nexport const SITE_CARE_RESPONSE_BUSINESS_DAYS = 2\n\n/** The zone a Site Care month is drawn in: where the work is done. */\nexport const SITE_CARE_TIME_ZONE = 'America/Chicago'\n\n/** The close's minutes are rounded up to this step. */\nexport const SITE_CARE_CLOSE_STEP_MINUTES = 5\n\n/** The most minutes one request may log. */\nexport const SITE_CARE_MAX_REQUEST_MINUTES = 60 * 40\n\n/**\n * The tax code the extra-time item is billed under: the code every Aglyn\n * product carries (the Decision Log of 2026-10-18), read off the Site Care\n * product, which is checked to carry it before anything is charged.\n */\nexport const SITE_CARE_EXTRA_TIME_TAX_CODE = 'txcd_10103001'\n\n/** The local part of the inbound address: `care@<inbound mail domain>`. */\nexport const SITE_CARE_INBOUND_LOCAL_PART = 'care'\n\n/** The longest title and message a request keeps. */\nexport const SITE_CARE_SUBJECT_MAX = 150\nexport const SITE_CARE_BODY_MAX = 5000\n\n/** Stripe's limit on an invoice item's description is generous; ours is not. */\nexport const SITE_CARE_LINE_DESCRIPTION_MAX = 480\n\n/** Where a request came from. */\nexport type SiteCareSource = 'email' | 'console'\n\n/**\n * Where an extra-time charge stands, as the platform recorded it.\n *\n * `creating` is written BEFORE the Stripe call and `pending` after it, so a\n * call that succeeded with no row behind it shows as `creating` with no item\n * id — which the reconciliation reports. Whether a `pending` item has been\n * invoiced yet is read from Stripe when it matters, never assumed.\n */\nexport type SiteCareChargeStatus =\n | 'creating'\n | 'pending'\n | 'failed'\n | 'voided'\n | 'credited'\n | 'refunded'\n\n/** Charges that still bill, or are about to. */\nexport const SITE_CARE_LIVE_CHARGE_STATUSES: readonly SiteCareChargeStatus[] = [\n 'creating',\n 'pending',\n]\n\nexport interface SiteCareCharge {\n status: SiteCareChargeStatus\n /** Whole hours billed. */\n hours: number\n /** `hours × rate`, in cents, before tax. */\n amountCents: number\n /** The invoice line description, exactly as it was sent. */\n description: string\n /** The key the create was sent under, so a retry makes nothing twice. */\n idempotencyKey: string\n invoiceItemId: string | null\n /** The invoice the item landed on, once read. */\n invoiceId: string | null\n creditNoteId: string | null\n refundId: string | null\n /** What Stripe said, when a call failed. */\n error: string | null\n updatedAtMs: number\n}\n\n/** The site publish that shipped the change, from the site's activity log. */\nexport interface SiteCarePublishLink {\n hostId: string\n activityId: string\n action: string\n targetName: string | null\n targetId: string | null\n atMs: number\n}\n\n/** The `siteCare` map on a Site Care ticket. */\nexport interface SiteCareRequest {\n source: SiteCareSource\n hostId: string | null\n requesterEmail: string | null\n state: 'open' | 'closed'\n /** The month the request counts in: opened, until it closes; then closed. */\n month: string\n timerStartedAtMs: number | null\n timerStartedByUid: string | null\n closedAtMs: number | null\n /** The one number staff entered at close, or the latest correction of it. */\n minutesLogged: number | null\n /** The timer's own minutes at close, unrounded, for the record. */\n timerMinutes: number | null\n countedMinutes: number\n includedMinutesUsed: number\n overMinutes: number\n billedHours: number\n absorbed: boolean\n approval: OwnerApprovalRecord | null\n charge: SiteCareCharge | null\n /** How many charges this request has ever started; keys each one. */\n chargeSeq: number\n publish: SiteCarePublishLink | null\n}\n\n/** Whether a value is a `YYYY-MM` month key. */\nexport function isSiteCareMonthKey(value: unknown): value is string {\n return typeof value === 'string' && /^\\d{4}-(0[1-9]|1[0-2])$/.test(value)\n}\n\n/** The month an instant falls in, in Site Care's zone: `2026-10`. */\nexport function siteCareMonthKey(ms: number): string {\n const parts = new Intl.DateTimeFormat('en-US', {\n timeZone: SITE_CARE_TIME_ZONE,\n year: 'numeric',\n month: '2-digit',\n }).formatToParts(new Date(ms))\n const year = parts.find((part) => part.type === 'year')?.value ?? '1970'\n const month = parts.find((part) => part.type === 'month')?.value ?? '01'\n return `${year}-${month}`\n}\n\n/** The month before a month key. */\nexport function previousSiteCareMonthKey(key: string): string {\n const [year, month] = key.split('-').map(Number)\n return month === 1 ? `${year - 1}-12` : `${year}-${String(month - 1).padStart(2, '0')}`\n}\n\n/** \"October 2026\". */\nexport function siteCareMonthLabel(key: string): string {\n if (!isSiteCareMonthKey(key)) return key\n const [year, month] = key.split('-').map(Number)\n return new Date(Date.UTC(year, month - 1, 15)).toLocaleString('en-US', {\n month: 'long',\n year: 'numeric',\n timeZone: 'UTC',\n })\n}\n\n/** The document id of an org's month: `{orgId}_{YYYY-MM}`, and the ticket field. */\nexport function siteCareOrgMonth(orgId: string, month: string): string {\n return `${orgId}_${month}`\n}\n\n/** \"45 min\", \"1 h\", \"1 h 15 min\". */\nexport function formatSiteCareMinutes(minutes: number): string {\n const total = Math.max(0, Math.round(Number(minutes) || 0))\n if (total < 60) return `${total} min`\n const hours = Math.floor(total / 60)\n const rest = total % 60\n return rest ? `${hours} h ${rest} min` : `${hours} h`\n}\n\n/** \"$79\", \"$158.00\" → always whole-dollar style when whole. */\nexport function formatSiteCareUsd(cents: number): string {\n const dollars = (Math.round(Number(cents) || 0) / 100)\n return Number.isInteger(dollars) ? `$${dollars}` : `$${dollars.toFixed(2)}`\n}\n\n/**\n * The close's number from the timer: elapsed minutes rounded UP to the next\n * five, and never less than five — a request somebody opened and closed was\n * still a request worked.\n */\nexport function closeMinutesFromTimer(startedAtMs: number | null, nowMs: number): number {\n if (!startedAtMs || nowMs <= startedAtMs) return SITE_CARE_CLOSE_STEP_MINUTES\n const elapsed = (nowMs - startedAtMs) / 60_000\n const rounded = Math.ceil(elapsed / SITE_CARE_CLOSE_STEP_MINUTES) * SITE_CARE_CLOSE_STEP_MINUTES\n return Math.min(SITE_CARE_MAX_REQUEST_MINUTES, Math.max(SITE_CARE_CLOSE_STEP_MINUTES, rounded))\n}\n\n/** Staff's number read back, or null when it is not a usable count of minutes. */\nexport function readSiteCareMinutes(value: unknown): number | null {\n const minutes = Number(value)\n if (!Number.isInteger(minutes) || minutes < 1 || minutes > SITE_CARE_MAX_REQUEST_MINUTES) {\n return null\n }\n return minutes\n}\n\n/** Minutes as they count against the included hour: whole blocks, rounded up. */\nexport function countedSiteCareMinutes(minutes: number): number {\n const value = Math.max(0, Number(minutes) || 0)\n return Math.ceil(value / SITE_CARE_INCLUDED_BLOCK_MINUTES) * SITE_CARE_INCLUDED_BLOCK_MINUTES\n}\n\n/** The month's included minutes: the hour plus goodwill. */\nexport function siteCareIncludedPool(goodwillMinutes: number): number {\n return SITE_CARE_INCLUDED_MINUTES + Math.max(0, Math.floor(Number(goodwillMinutes) || 0))\n}\n\nexport interface SiteCareAllocation {\n countedMinutes: number\n includedMinutesUsed: number\n overMinutes: number\n /** Whole hours the over-time needs, rounded up; 0 when within the hour. */\n requiredHours: number\n /** Included minutes the month had left before this request. */\n remainingBefore: number\n}\n\n/**\n * One request's minutes against what the month's OTHER closed requests left\n * of the included pool.\n */\nexport function allocateSiteCareMinutes(input: {\n minutes: number\n otherIncludedUsed: number\n goodwillMinutes: number\n}): SiteCareAllocation {\n const countedMinutes = countedSiteCareMinutes(input.minutes)\n const remainingBefore = Math.max(\n 0,\n siteCareIncludedPool(input.goodwillMinutes) - Math.max(0, input.otherIncludedUsed),\n )\n const includedMinutesUsed = Math.min(countedMinutes, remainingBefore)\n const overMinutes = countedMinutes - includedMinutesUsed\n return {\n countedMinutes,\n includedMinutesUsed,\n overMinutes,\n requiredHours: overMinutes > 0 ? Math.ceil(overMinutes / 60) : 0,\n remainingBefore,\n }\n}\n\nexport type SiteCareCloseVerdict =\n | { ok: true; billedHours: number; absorbed: boolean }\n | {\n ok: false\n /** No approval on file, or one for fewer hours than the work took. */\n reason: 'no-approval' | 'approval-exceeded'\n requiredHours: number\n approvedHours: number | null\n }\n\n/**\n * What a close (or a correction) may do with a request's extra time.\n *\n * Within the hour nothing bills. Past it, `absorb` closes with no charge;\n * otherwise an approval must cover the whole hours needed, and the bill is\n * the larger of those and the approved hours — the approved amount is the\n * floor. Nothing bills without the owner's recorded yes.\n */\nexport function siteCareCloseVerdict(input: {\n requiredHours: number\n approval: Pick<OwnerApprovalRecord, 'hours'> | null\n absorb: boolean\n}): SiteCareCloseVerdict {\n if (input.requiredHours <= 0) return { ok: true, billedHours: 0, absorbed: false }\n if (input.absorb) return { ok: true, billedHours: 0, absorbed: true }\n if (!input.approval) {\n return {\n ok: false,\n reason: 'no-approval',\n requiredHours: input.requiredHours,\n approvedHours: null,\n }\n }\n if (input.approval.hours < input.requiredHours) {\n return {\n ok: false,\n reason: 'approval-exceeded',\n requiredHours: input.requiredHours,\n approvedHours: input.approval.hours,\n }\n }\n return {\n ok: true,\n billedHours: Math.max(input.requiredHours, input.approval.hours),\n absorbed: false,\n }\n}\n\n/** Extra time in cents, before tax. */\nexport function siteCareExtraTimeCents(hours: number): number {\n return Math.max(0, Math.floor(hours)) * SITE_CARE_EXTRA_HOUR_USD * 100\n}\n\n/** One request as the month's statement counts it. */\nexport interface SiteCareStatementRequest {\n requestId: string\n title: string\n state: 'open' | 'closed'\n closedAtMs: number | null\n minutesLogged: number | null\n countedMinutes: number\n includedMinutesUsed: number\n overMinutes: number\n billedHours: number\n absorbed: boolean\n chargeStatus: SiteCareChargeStatus | null\n chargeCents: number\n}\n\nexport interface SiteCareMonthStatement {\n month: string\n monthLabel: string\n includedMinutes: number\n goodwillMinutes: number\n poolMinutes: number\n requests: number\n openRequests: number\n minutesLogged: number\n countedMinutes: number\n includedMinutesUsed: number\n minutesLeft: number\n /** Hours on charges that still bill. */\n extraHoursBilled: number\n extraBilledCents: number\n /** Cents voided, credited or refunded. */\n extraReversedCents: number\n}\n\n/** A request's facts as the statement reads them, from the stored map. */\nexport function siteCareStatementRequest(\n requestId: string,\n title: string,\n request: Partial<SiteCareRequest> | null | undefined,\n): SiteCareStatementRequest {\n const charge = request?.charge ?? null\n return {\n requestId,\n title,\n state: request?.state === 'closed' ? 'closed' : 'open',\n closedAtMs: request?.closedAtMs ?? null,\n minutesLogged: request?.minutesLogged ?? null,\n countedMinutes: Number(request?.countedMinutes) || 0,\n includedMinutesUsed: Number(request?.includedMinutesUsed) || 0,\n overMinutes: Number(request?.overMinutes) || 0,\n billedHours: Number(request?.billedHours) || 0,\n absorbed: request?.absorbed === true,\n chargeStatus: charge?.status ?? null,\n chargeCents: Number(charge?.amountCents) || 0,\n }\n}\n\n/** The month, summed. */\nexport function siteCareMonthStatement(input: {\n month: string\n requests: readonly SiteCareStatementRequest[]\n goodwillMinutes: number\n}): SiteCareMonthStatement {\n const closed = input.requests.filter((request) => request.state === 'closed')\n const goodwillMinutes = Math.max(0, Math.floor(Number(input.goodwillMinutes) || 0))\n const poolMinutes = siteCareIncludedPool(goodwillMinutes)\n const includedMinutesUsed = closed.reduce((sum, r) => sum + r.includedMinutesUsed, 0)\n const live = closed.filter(\n (r) => r.chargeStatus !== null && SITE_CARE_LIVE_CHARGE_STATUSES.includes(r.chargeStatus),\n )\n const reversed = closed.filter(\n (r) => r.chargeStatus === 'voided' || r.chargeStatus === 'credited' || r.chargeStatus === 'refunded',\n )\n return {\n month: input.month,\n monthLabel: siteCareMonthLabel(input.month),\n includedMinutes: SITE_CARE_INCLUDED_MINUTES,\n goodwillMinutes,\n poolMinutes,\n requests: input.requests.length,\n openRequests: input.requests.length - closed.length,\n minutesLogged: closed.reduce((sum, r) => sum + (r.minutesLogged ?? 0), 0),\n countedMinutes: closed.reduce((sum, r) => sum + r.countedMinutes, 0),\n includedMinutesUsed,\n minutesLeft: Math.max(0, poolMinutes - includedMinutesUsed),\n extraHoursBilled: live.reduce((sum, r) => sum + r.billedHours, 0),\n extraBilledCents: live.reduce((sum, r) => sum + r.chargeCents, 0),\n extraReversedCents: reversed.reduce((sum, r) => sum + r.chargeCents, 0),\n }\n}\n\n/** The month's totals in one line, as the statement and the invoice line say them. */\nexport function siteCareMonthSentence(statement: SiteCareMonthStatement): string {\n const requests = `${statement.requests} ${statement.requests === 1 ? 'request' : 'requests'}`\n return (\n `${statement.monthLabel}: ${requests}, ${formatSiteCareMinutes(statement.minutesLogged)} of work, ` +\n `${statement.includedMinutesUsed} of ${statement.poolMinutes} included minutes used` +\n (statement.extraHoursBilled > 0\n ? `, ${describeHours(statement.extraHoursBilled)} of extra time billed`\n : '') +\n '.'\n )\n}\n\n/**\n * The extra-time invoice line's description: the request, its minutes, the\n * hours billed and why, and the month's statement — what the owner reads on\n * the invoice, and what the reconciliation compares Stripe's copy against.\n */\nexport function siteCareExtraTimeDescription(input: {\n title: string\n minutesLogged: number\n overMinutes: number\n billedHours: number\n approvedHours: number | null\n statement: SiteCareMonthStatement\n}): string {\n const title = input.title.length > 80 ? `${input.title.slice(0, 79)}…` : input.title\n const approved =\n input.approvedHours && input.approvedHours > Math.ceil(input.overMinutes / 60)\n ? ` (the ${describeHours(input.approvedHours)} you approved)`\n : ''\n const line =\n `Site Care extra time — “${title}”: ${formatSiteCareMinutes(input.minutesLogged)} of work, ` +\n `${formatSiteCareMinutes(input.overMinutes)} past the included hour, billed as ` +\n `${describeHours(input.billedHours)}${approved} at $${SITE_CARE_EXTRA_HOUR_USD}/hour. ` +\n siteCareMonthSentence(input.statement)\n return line.length > SITE_CARE_LINE_DESCRIPTION_MAX\n ? `${line.slice(0, SITE_CARE_LINE_DESCRIPTION_MAX - 1)}…`\n : line\n}\n\n/** A charge's standing in the owner's words. */\nexport function siteCareChargeWords(status: SiteCareChargeStatus | null): string {\n switch (status) {\n case 'creating':\n case 'pending':\n return 'On your next invoice'\n case 'failed':\n return 'Not billed'\n case 'voided':\n return 'Removed, not billed'\n case 'credited':\n return 'Credited back'\n case 'refunded':\n return 'Refunded'\n default:\n return 'Included'\n }\n}\n\n/** Whether a site activity row is a publish a request can be linked to. */\nexport function isSiteCarePublishAction(action: unknown): boolean {\n return typeof action === 'string' && /^published\\b/i.test(action.trim())\n}\n\n/** A publish link as a sentence: \"Published “Home” on Oct 19, 2026, 3:04 PM\". */\nexport function siteCarePublishSentence(\n publish: SiteCarePublishLink | null,\n formatDate: (ms: number) => string,\n): string | null {\n if (!publish) return null\n const what = publish.targetName ? ` “${publish.targetName}”` : ''\n return `${publish.action}${what} on ${formatDate(publish.atMs)}`\n}\n\n/** A date as the owner's emails and statement write it, in Site Care's zone. */\nexport function formatSiteCareDate(ms: number): string {\n return new Date(ms).toLocaleString('en-US', {\n timeZone: SITE_CARE_TIME_ZONE,\n month: 'short',\n day: 'numeric',\n year: 'numeric',\n hour: 'numeric',\n minute: '2-digit',\n timeZoneName: 'short',\n })\n}\n"],"names":["SITE_CARE_EXTRA_HOUR_USD","SITE_CARE_INCLUDED_BLOCK_MINUTES","SITE_CARE_INCLUDED_MINUTES","describeHours","SITE_CARE_TICKET_KIND","SITE_CARE_RESPONSE_BUSINESS_DAYS","SITE_CARE_TIME_ZONE","SITE_CARE_CLOSE_STEP_MINUTES","SITE_CARE_MAX_REQUEST_MINUTES","SITE_CARE_EXTRA_TIME_TAX_CODE","SITE_CARE_INBOUND_LOCAL_PART","SITE_CARE_SUBJECT_MAX","SITE_CARE_BODY_MAX","SITE_CARE_LINE_DESCRIPTION_MAX","SITE_CARE_LIVE_CHARGE_STATUSES","isSiteCareMonthKey","value","test","siteCareMonthKey","ms","parts","Intl","DateTimeFormat","timeZone","year","month","formatToParts","Date","find","part","type","previousSiteCareMonthKey","key","split","map","Number","String","padStart","siteCareMonthLabel","UTC","toLocaleString","siteCareOrgMonth","orgId","formatSiteCareMinutes","minutes","total","Math","max","round","hours","floor","rest","formatSiteCareUsd","cents","dollars","isInteger","toFixed","closeMinutesFromTimer","startedAtMs","nowMs","elapsed","rounded","ceil","min","readSiteCareMinutes","countedSiteCareMinutes","siteCareIncludedPool","goodwillMinutes","allocateSiteCareMinutes","input","countedMinutes","remainingBefore","otherIncludedUsed","includedMinutesUsed","overMinutes","requiredHours","siteCareCloseVerdict","ok","billedHours","absorbed","absorb","approval","reason","approvedHours","siteCareExtraTimeCents","siteCareStatementRequest","requestId","title","request","charge","state","closedAtMs","minutesLogged","chargeStatus","status","chargeCents","amountCents","siteCareMonthStatement","closed","requests","filter","poolMinutes","reduce","sum","r","live","includes","reversed","monthLabel","includedMinutes","length","openRequests","minutesLeft","extraHoursBilled","extraBilledCents","extraReversedCents","siteCareMonthSentence","statement","siteCareExtraTimeDescription","slice","approved","line","siteCareChargeWords","isSiteCarePublishAction","action","trim","siteCarePublishSentence","publish","formatDate","what","targetName","atMs","formatSiteCareDate","day","hour","minute","timeZoneName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,wBAAwB,EACxBC,gCAAgC,EAChCC,0BAA0B,QACrB,yBAAqB;AAC5B,SAASC,aAAa,QAAkC,6BAAyB;AAEjF;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BC,GAED,mDAAmD,GACnD,OAAO,MAAMC,wBAAwB,WAAU;AAE/C,wDAAwD,GACxD,OAAO,MAAMC,mCAAmC,EAAC;AAEjD,oEAAoE,GACpE,OAAO,MAAMC,sBAAsB,kBAAiB;AAEpD,qDAAqD,GACrD,OAAO,MAAMC,+BAA+B,EAAC;AAE7C,0CAA0C,GAC1C,OAAO,MAAMC,gCAAgC,KAAK,GAAE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BAAsB/C,MAAMgD,SAAS;IACvC,OAAOI,KAAKX,MAAM,GAAGjG,iCACjB,GAAG4G,KAAKF,KAAK,CAAC,GAAG1G,iCAAiC,GAAG,CAAC,CAAC,GACvD4G;AACN;AAEA,8CAA8C,GAC9C,OAAO,SAASC,oBAAoB5B,MAAmC;IACrE,OAAQA;QACN,KAAK;QACL,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT;YACE,OAAO;IACX;AACF;AAEA,yEAAyE,GACzE,OAAO,SAAS6B,wBAAwBC,MAAe;IACrD,OAAO,OAAOA,WAAW,YAAY,gBAAgB3G,IAAI,CAAC2G,OAAOC,IAAI;AACvE;AAEA,+EAA+E,GAC/E,OAAO,SAASC,wBACdC,OAAmC,EACnCC,UAAkC;IAElC,IAAI,CAACD,SAAS,OAAO;IACrB,MAAME,OAAOF,QAAQG,UAAU,GAAG,CAAC,EAAE,EAAEH,QAAQG,UAAU,CAAC,CAAC,CAAC,GAAG;IAC/D,OAAO,GAAGH,QAAQH,MAAM,GAAGK,KAAK,IAAI,EAAED,WAAWD,QAAQI,IAAI,GAAG;AAClE;AAEA,8EAA8E,GAC9E,OAAO,SAASC,mBAAmBjH,EAAU;IAC3C,OAAO,IAAIQ,KAAKR,IAAIqB,cAAc,CAAC,SAAS;QAC1CjB,UAAUjB;QACVmB,OAAO;QACP4G,KAAK;QACL7G,MAAM;QACN8G,MAAM;QACNC,QAAQ;QACRC,cAAc;IAChB;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/site-care.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n SITE_CARE_EXTRA_HOUR_USD,\n SITE_CARE_INCLUDED_BLOCK_MINUTES,\n SITE_CARE_INCLUDED_MINUTES,\n} from './plan-entitlements'\nimport { operatorIdentity } from './operator-identity'\nimport { describeHours, type OwnerApprovalRecord } from './owner-approval-record'\n\n/**\n * SITE CARE REQUESTS: THE ARITHMETIC (AGL-3959).\n *\n * A Site Care owner asks for a change by email or from the console, and the\n * request is a support ticket tagged `siteCare`. Staff open it (a timer\n * starts), make the change, and close it with one number: the minutes. This\n * module is everything about that which needs no Firestore and no Stripe —\n * the month a request counts in, how its minutes are counted against the\n * included hour, what the close allows, what extra time bills, and the\n * statement the month adds up to. The routes, the staff panel, the owner's\n * Billing card and the reconciliation all read it, so they cannot disagree.\n *\n * ## The rules, from the Decision Log of 2026-10-19\n *\n * - The included hour is `SITE_CARE_INCLUDED_MINUTES` a month, no rollover,\n * plus any goodwill minutes staff add to that month. Each request counts\n * against it in `SITE_CARE_INCLUDED_BLOCK_MINUTES` blocks, rounded UP.\n * - A request's share of the hour is fixed when it closes, against what the\n * month's earlier requests left. Correcting one request's minutes later\n * recomputes that request alone, against the same remainder, so a fix\n * never moves a charge on a request nobody touched.\n * - Past the hour, extra time bills at `SITE_CARE_EXTRA_HOUR_USD` per\n * STARTED hour — whole hours, rounded up — and never less than the hours\n * the owner approved. With no approval on file, or more time than was\n * approved, the close is blocked: ask the owner first, or absorb it (no\n * charge, the minutes still count).\n */\n\n/** The `kind` a Site Care support ticket carries. */\nexport const SITE_CARE_TICKET_KIND = 'siteCare'\n\n/** Site Care's promise: done within two business days. */\nexport const SITE_CARE_RESPONSE_BUSINESS_DAYS = 2\n\n/** The zone a Site Care month is drawn in: where the work is done. */\nexport const SITE_CARE_TIME_ZONE = 'America/Chicago'\n\n/** The close's minutes are rounded up to this step. */\nexport const SITE_CARE_CLOSE_STEP_MINUTES = 5\n\n/** The most minutes one request may log. */\nexport const SITE_CARE_MAX_REQUEST_MINUTES = 60 * 40\n\n/**\n * The tax code the extra-time item is billed under: the code every Aglyn\n * product carries (the Decision Log of 2026-10-18), read off the Site Care\n * product, which is checked to carry it before anything is charged.\n */\nexport const SITE_CARE_EXTRA_TIME_TAX_CODE = 'txcd_10103001'\n\n/**\n * WHERE A CHANGE IS EMAILED (AGL-3997): the support address. Site Care has no\n * address of its own. An owner writes to the support address they already\n * know, and a message to it from a member of a workspace with Site Care files\n * itself as a request; every other message is ordinary support mail. The\n * support mailbox also delivers each message to `support@<inbound mail\n * domain>`, where the mail provider announces it, and every Site Care email\n * replies to `support+<requestId>@<inbound mail domain>`, so an answer joins\n * its own request.\n */\nexport const SITE_CARE_INBOUND_LOCAL_PART = 'support'\n\n/**\n * The operator's support address, from the operator identity: what an owner\n * is told to email a change to, and what the intake reads as one. `null` on\n * a deployment that publishes no support address, where Request a change on\n * a site's dashboard is the only way in.\n */\nexport function siteCareSupportAddress(): string | null {\n return operatorIdentity().supportEmail\n}\n\n/**\n * The Reply-To of a Site Care email: `support+<requestId>@<domain>` for an\n * email about one request, so the answer joins it; the support address for\n * one about no single request (a statement, a project), so the answer reaches\n * the support inbox like any other message to it.\n */\nexport function siteCareReplyAddress(\n requestId: string | null,\n domain: string,\n supportEmail: string | null = siteCareSupportAddress(),\n): string {\n if (requestId) return `${SITE_CARE_INBOUND_LOCAL_PART}+${requestId}@${domain}`\n return supportEmail ?? `${SITE_CARE_INBOUND_LOCAL_PART}@${domain}`\n}\n\n/** The longest title and message a request keeps. */\nexport const SITE_CARE_SUBJECT_MAX = 150\nexport const SITE_CARE_BODY_MAX = 5000\n\n/** Stripe's limit on an invoice item's description is generous; ours is not. */\nexport const SITE_CARE_LINE_DESCRIPTION_MAX = 480\n\n/** Where a request came from. */\nexport type SiteCareSource = 'email' | 'console'\n\n/**\n * Where an extra-time charge stands, as the platform recorded it.\n *\n * `creating` is written BEFORE the Stripe call and `pending` after it, so a\n * call that succeeded with no row behind it shows as `creating` with no item\n * id — which the reconciliation reports. Whether a `pending` item has been\n * invoiced yet is read from Stripe when it matters, never assumed.\n */\nexport type SiteCareChargeStatus =\n | 'creating'\n | 'pending'\n | 'failed'\n | 'voided'\n | 'credited'\n | 'refunded'\n\n/** Charges that still bill, or are about to. */\nexport const SITE_CARE_LIVE_CHARGE_STATUSES: readonly SiteCareChargeStatus[] = [\n 'creating',\n 'pending',\n]\n\nexport interface SiteCareCharge {\n status: SiteCareChargeStatus\n /** Whole hours billed. */\n hours: number\n /** `hours × rate`, in cents, before tax. */\n amountCents: number\n /** The invoice line description, exactly as it was sent. */\n description: string\n /** The key the create was sent under, so a retry makes nothing twice. */\n idempotencyKey: string\n invoiceItemId: string | null\n /** The invoice the item landed on, once read. */\n invoiceId: string | null\n creditNoteId: string | null\n refundId: string | null\n /** What Stripe said, when a call failed. */\n error: string | null\n updatedAtMs: number\n}\n\n/** The site publish that shipped the change, from the site's activity log. */\nexport interface SiteCarePublishLink {\n hostId: string\n activityId: string\n action: string\n targetName: string | null\n targetId: string | null\n atMs: number\n}\n\n/** The `siteCare` map on a Site Care ticket. */\nexport interface SiteCareRequest {\n source: SiteCareSource\n hostId: string | null\n requesterEmail: string | null\n state: 'open' | 'closed'\n /** The month the request counts in: opened, until it closes; then closed. */\n month: string\n timerStartedAtMs: number | null\n timerStartedByUid: string | null\n closedAtMs: number | null\n /** The one number staff entered at close, or the latest correction of it. */\n minutesLogged: number | null\n /** The timer's own minutes at close, unrounded, for the record. */\n timerMinutes: number | null\n countedMinutes: number\n includedMinutesUsed: number\n overMinutes: number\n billedHours: number\n absorbed: boolean\n approval: OwnerApprovalRecord | null\n charge: SiteCareCharge | null\n /** How many charges this request has ever started; keys each one. */\n chargeSeq: number\n publish: SiteCarePublishLink | null\n}\n\n/** Whether a value is a `YYYY-MM` month key. */\nexport function isSiteCareMonthKey(value: unknown): value is string {\n return typeof value === 'string' && /^\\d{4}-(0[1-9]|1[0-2])$/.test(value)\n}\n\n/** The month an instant falls in, in Site Care's zone: `2026-10`. */\nexport function siteCareMonthKey(ms: number): string {\n const parts = new Intl.DateTimeFormat('en-US', {\n timeZone: SITE_CARE_TIME_ZONE,\n year: 'numeric',\n month: '2-digit',\n }).formatToParts(new Date(ms))\n const year = parts.find((part) => part.type === 'year')?.value ?? '1970'\n const month = parts.find((part) => part.type === 'month')?.value ?? '01'\n return `${year}-${month}`\n}\n\n/** The month before a month key. */\nexport function previousSiteCareMonthKey(key: string): string {\n const [year, month] = key.split('-').map(Number)\n return month === 1 ? `${year - 1}-12` : `${year}-${String(month - 1).padStart(2, '0')}`\n}\n\n/** \"October 2026\". */\nexport function siteCareMonthLabel(key: string): string {\n if (!isSiteCareMonthKey(key)) return key\n const [year, month] = key.split('-').map(Number)\n return new Date(Date.UTC(year, month - 1, 15)).toLocaleString('en-US', {\n month: 'long',\n year: 'numeric',\n timeZone: 'UTC',\n })\n}\n\n/** The document id of an org's month: `{orgId}_{YYYY-MM}`, and the ticket field. */\nexport function siteCareOrgMonth(orgId: string, month: string): string {\n return `${orgId}_${month}`\n}\n\n/** \"45 min\", \"1 h\", \"1 h 15 min\". */\nexport function formatSiteCareMinutes(minutes: number): string {\n const total = Math.max(0, Math.round(Number(minutes) || 0))\n if (total < 60) return `${total} min`\n const hours = Math.floor(total / 60)\n const rest = total % 60\n return rest ? `${hours} h ${rest} min` : `${hours} h`\n}\n\n/** \"$79\", \"$158.00\" → always whole-dollar style when whole. */\nexport function formatSiteCareUsd(cents: number): string {\n const dollars = (Math.round(Number(cents) || 0) / 100)\n return Number.isInteger(dollars) ? `$${dollars}` : `$${dollars.toFixed(2)}`\n}\n\n/**\n * The close's number from the timer: elapsed minutes rounded UP to the next\n * five, and never less than five — a request somebody opened and closed was\n * still a request worked.\n */\nexport function closeMinutesFromTimer(startedAtMs: number | null, nowMs: number): number {\n if (!startedAtMs || nowMs <= startedAtMs) return SITE_CARE_CLOSE_STEP_MINUTES\n const elapsed = (nowMs - startedAtMs) / 60_000\n const rounded = Math.ceil(elapsed / SITE_CARE_CLOSE_STEP_MINUTES) * SITE_CARE_CLOSE_STEP_MINUTES\n return Math.min(SITE_CARE_MAX_REQUEST_MINUTES, Math.max(SITE_CARE_CLOSE_STEP_MINUTES, rounded))\n}\n\n/** Staff's number read back, or null when it is not a usable count of minutes. */\nexport function readSiteCareMinutes(value: unknown): number | null {\n const minutes = Number(value)\n if (!Number.isInteger(minutes) || minutes < 1 || minutes > SITE_CARE_MAX_REQUEST_MINUTES) {\n return null\n }\n return minutes\n}\n\n/** Minutes as they count against the included hour: whole blocks, rounded up. */\nexport function countedSiteCareMinutes(minutes: number): number {\n const value = Math.max(0, Number(minutes) || 0)\n return Math.ceil(value / SITE_CARE_INCLUDED_BLOCK_MINUTES) * SITE_CARE_INCLUDED_BLOCK_MINUTES\n}\n\n/** The month's included minutes: the hour plus goodwill. */\nexport function siteCareIncludedPool(goodwillMinutes: number): number {\n return SITE_CARE_INCLUDED_MINUTES + Math.max(0, Math.floor(Number(goodwillMinutes) || 0))\n}\n\nexport interface SiteCareAllocation {\n countedMinutes: number\n includedMinutesUsed: number\n overMinutes: number\n /** Whole hours the over-time needs, rounded up; 0 when within the hour. */\n requiredHours: number\n /** Included minutes the month had left before this request. */\n remainingBefore: number\n}\n\n/**\n * One request's minutes against what the month's OTHER closed requests left\n * of the included pool.\n */\nexport function allocateSiteCareMinutes(input: {\n minutes: number\n otherIncludedUsed: number\n goodwillMinutes: number\n}): SiteCareAllocation {\n const countedMinutes = countedSiteCareMinutes(input.minutes)\n const remainingBefore = Math.max(\n 0,\n siteCareIncludedPool(input.goodwillMinutes) - Math.max(0, input.otherIncludedUsed),\n )\n const includedMinutesUsed = Math.min(countedMinutes, remainingBefore)\n const overMinutes = countedMinutes - includedMinutesUsed\n return {\n countedMinutes,\n includedMinutesUsed,\n overMinutes,\n requiredHours: overMinutes > 0 ? Math.ceil(overMinutes / 60) : 0,\n remainingBefore,\n }\n}\n\nexport type SiteCareCloseVerdict =\n | { ok: true; billedHours: number; absorbed: boolean }\n | {\n ok: false\n /** No approval on file, or one for fewer hours than the work took. */\n reason: 'no-approval' | 'approval-exceeded'\n requiredHours: number\n approvedHours: number | null\n }\n\n/**\n * What a close (or a correction) may do with a request's extra time.\n *\n * Within the hour nothing bills. Past it, `absorb` closes with no charge;\n * otherwise an approval must cover the whole hours needed, and the bill is\n * the larger of those and the approved hours — the approved amount is the\n * floor. Nothing bills without the owner's recorded yes.\n */\nexport function siteCareCloseVerdict(input: {\n requiredHours: number\n approval: Pick<OwnerApprovalRecord, 'hours'> | null\n absorb: boolean\n}): SiteCareCloseVerdict {\n if (input.requiredHours <= 0) return { ok: true, billedHours: 0, absorbed: false }\n if (input.absorb) return { ok: true, billedHours: 0, absorbed: true }\n if (!input.approval) {\n return {\n ok: false,\n reason: 'no-approval',\n requiredHours: input.requiredHours,\n approvedHours: null,\n }\n }\n if (input.approval.hours < input.requiredHours) {\n return {\n ok: false,\n reason: 'approval-exceeded',\n requiredHours: input.requiredHours,\n approvedHours: input.approval.hours,\n }\n }\n return {\n ok: true,\n billedHours: Math.max(input.requiredHours, input.approval.hours),\n absorbed: false,\n }\n}\n\n/** Extra time in cents, before tax. */\nexport function siteCareExtraTimeCents(hours: number): number {\n return Math.max(0, Math.floor(hours)) * SITE_CARE_EXTRA_HOUR_USD * 100\n}\n\n/** One request as the month's statement counts it. */\nexport interface SiteCareStatementRequest {\n requestId: string\n title: string\n state: 'open' | 'closed'\n closedAtMs: number | null\n minutesLogged: number | null\n countedMinutes: number\n includedMinutesUsed: number\n overMinutes: number\n billedHours: number\n absorbed: boolean\n chargeStatus: SiteCareChargeStatus | null\n chargeCents: number\n}\n\nexport interface SiteCareMonthStatement {\n month: string\n monthLabel: string\n includedMinutes: number\n goodwillMinutes: number\n poolMinutes: number\n requests: number\n openRequests: number\n minutesLogged: number\n countedMinutes: number\n includedMinutesUsed: number\n minutesLeft: number\n /** Hours on charges that still bill. */\n extraHoursBilled: number\n extraBilledCents: number\n /** Cents voided, credited or refunded. */\n extraReversedCents: number\n}\n\n/** A request's facts as the statement reads them, from the stored map. */\nexport function siteCareStatementRequest(\n requestId: string,\n title: string,\n request: Partial<SiteCareRequest> | null | undefined,\n): SiteCareStatementRequest {\n const charge = request?.charge ?? null\n return {\n requestId,\n title,\n state: request?.state === 'closed' ? 'closed' : 'open',\n closedAtMs: request?.closedAtMs ?? null,\n minutesLogged: request?.minutesLogged ?? null,\n countedMinutes: Number(request?.countedMinutes) || 0,\n includedMinutesUsed: Number(request?.includedMinutesUsed) || 0,\n overMinutes: Number(request?.overMinutes) || 0,\n billedHours: Number(request?.billedHours) || 0,\n absorbed: request?.absorbed === true,\n chargeStatus: charge?.status ?? null,\n chargeCents: Number(charge?.amountCents) || 0,\n }\n}\n\n/** The month, summed. */\nexport function siteCareMonthStatement(input: {\n month: string\n requests: readonly SiteCareStatementRequest[]\n goodwillMinutes: number\n}): SiteCareMonthStatement {\n const closed = input.requests.filter((request) => request.state === 'closed')\n const goodwillMinutes = Math.max(0, Math.floor(Number(input.goodwillMinutes) || 0))\n const poolMinutes = siteCareIncludedPool(goodwillMinutes)\n const includedMinutesUsed = closed.reduce((sum, r) => sum + r.includedMinutesUsed, 0)\n const live = closed.filter(\n (r) => r.chargeStatus !== null && SITE_CARE_LIVE_CHARGE_STATUSES.includes(r.chargeStatus),\n )\n const reversed = closed.filter(\n (r) => r.chargeStatus === 'voided' || r.chargeStatus === 'credited' || r.chargeStatus === 'refunded',\n )\n return {\n month: input.month,\n monthLabel: siteCareMonthLabel(input.month),\n includedMinutes: SITE_CARE_INCLUDED_MINUTES,\n goodwillMinutes,\n poolMinutes,\n requests: input.requests.length,\n openRequests: input.requests.length - closed.length,\n minutesLogged: closed.reduce((sum, r) => sum + (r.minutesLogged ?? 0), 0),\n countedMinutes: closed.reduce((sum, r) => sum + r.countedMinutes, 0),\n includedMinutesUsed,\n minutesLeft: Math.max(0, poolMinutes - includedMinutesUsed),\n extraHoursBilled: live.reduce((sum, r) => sum + r.billedHours, 0),\n extraBilledCents: live.reduce((sum, r) => sum + r.chargeCents, 0),\n extraReversedCents: reversed.reduce((sum, r) => sum + r.chargeCents, 0),\n }\n}\n\n/** The month's totals in one line, as the statement and the invoice line say them. */\nexport function siteCareMonthSentence(statement: SiteCareMonthStatement): string {\n const requests = `${statement.requests} ${statement.requests === 1 ? 'request' : 'requests'}`\n return (\n `${statement.monthLabel}: ${requests}, ${formatSiteCareMinutes(statement.minutesLogged)} of work, ` +\n `${statement.includedMinutesUsed} of ${statement.poolMinutes} included minutes used` +\n (statement.extraHoursBilled > 0\n ? `, ${describeHours(statement.extraHoursBilled)} of extra time billed`\n : '') +\n '.'\n )\n}\n\n/**\n * The extra-time invoice line's description: the request, its minutes, the\n * hours billed and why, and the month's statement — what the owner reads on\n * the invoice, and what the reconciliation compares Stripe's copy against.\n */\nexport function siteCareExtraTimeDescription(input: {\n title: string\n minutesLogged: number\n overMinutes: number\n billedHours: number\n approvedHours: number | null\n statement: SiteCareMonthStatement\n}): string {\n const title = input.title.length > 80 ? `${input.title.slice(0, 79)}…` : input.title\n const approved =\n input.approvedHours && input.approvedHours > Math.ceil(input.overMinutes / 60)\n ? ` (the ${describeHours(input.approvedHours)} you approved)`\n : ''\n const line =\n `Site Care extra time — “${title}”: ${formatSiteCareMinutes(input.minutesLogged)} of work, ` +\n `${formatSiteCareMinutes(input.overMinutes)} past the included hour, billed as ` +\n `${describeHours(input.billedHours)}${approved} at $${SITE_CARE_EXTRA_HOUR_USD}/hour. ` +\n siteCareMonthSentence(input.statement)\n return line.length > SITE_CARE_LINE_DESCRIPTION_MAX\n ? `${line.slice(0, SITE_CARE_LINE_DESCRIPTION_MAX - 1)}…`\n : line\n}\n\n/** A charge's standing in the owner's words. */\nexport function siteCareChargeWords(status: SiteCareChargeStatus | null): string {\n switch (status) {\n case 'creating':\n case 'pending':\n return 'On your next invoice'\n case 'failed':\n return 'Not billed'\n case 'voided':\n return 'Removed, not billed'\n case 'credited':\n return 'Credited back'\n case 'refunded':\n return 'Refunded'\n default:\n return 'Included'\n }\n}\n\n/** Whether a site activity row is a publish a request can be linked to. */\nexport function isSiteCarePublishAction(action: unknown): boolean {\n return typeof action === 'string' && /^published\\b/i.test(action.trim())\n}\n\n/** A publish link as a sentence: \"Published “Home” on Oct 19, 2026, 3:04 PM\". */\nexport function siteCarePublishSentence(\n publish: SiteCarePublishLink | null,\n formatDate: (ms: number) => string,\n): string | null {\n if (!publish) return null\n const what = publish.targetName ? ` “${publish.targetName}”` : ''\n return `${publish.action}${what} on ${formatDate(publish.atMs)}`\n}\n\n/** A date as the owner's emails and statement write it, in Site Care's zone. */\nexport function formatSiteCareDate(ms: number): string {\n return new Date(ms).toLocaleString('en-US', {\n timeZone: SITE_CARE_TIME_ZONE,\n month: 'short',\n day: 'numeric',\n year: 'numeric',\n hour: 'numeric',\n minute: '2-digit',\n timeZoneName: 'short',\n })\n}\n"],"names":["SITE_CARE_EXTRA_HOUR_USD","SITE_CARE_INCLUDED_BLOCK_MINUTES","SITE_CARE_INCLUDED_MINUTES","operatorIdentity","describeHours","SITE_CARE_TICKET_KIND","SITE_CARE_RESPONSE_BUSINESS_DAYS","SITE_CARE_TIME_ZONE","SITE_CARE_CLOSE_STEP_MINUTES","SITE_CARE_MAX_REQUEST_MINUTES","SITE_CARE_EXTRA_TIME_TAX_CODE","SITE_CARE_INBOUND_LOCAL_PART","siteCareSupportAddress","supportEmail","siteCareReplyAddress","requestId","domain","SITE_CARE_SUBJECT_MAX","SITE_CARE_BODY_MAX","SITE_CARE_LINE_DESCRIPTION_MAX","SITE_CARE_LIVE_CHARGE_STATUSES","isSiteCareMonthKey","value","test","siteCareMonthKey","ms","parts","Intl","DateTimeFormat","timeZone","year","month","formatToParts","Date","find","part","type","previousSiteCareMonthKey","key","split","map","Number","String","padStart","siteCareMonthLabel","UTC","toLocaleString","siteCareOrgMonth","orgId","formatSiteCareMinutes","minutes","total","Math","max","round","hours","floor","rest","formatSiteCareUsd","cents","dollars","isInteger","toFixed","closeMinutesFromTimer","startedAtMs","nowMs","elapsed","rounded","ceil","min","readSiteCareMinutes","countedSiteCareMinutes","siteCareIncludedPool","goodwillMinutes","allocateSiteCareMinutes","input","countedMinutes","remainingBefore","otherIncludedUsed","includedMinutesUsed","overMinutes","requiredHours","siteCareCloseVerdict","ok","billedHours","absorbed","absorb","approval","reason","approvedHours","siteCareExtraTimeCents","siteCareStatementRequest","title","request","charge","state","closedAtMs","minutesLogged","chargeStatus","status","chargeCents","amountCents","siteCareMonthStatement","closed","requests","filter","poolMinutes","reduce","sum","r","live","includes","reversed","monthLabel","includedMinutes","length","openRequests","minutesLeft","extraHoursBilled","extraBilledCents","extraReversedCents","siteCareMonthSentence","statement","siteCareExtraTimeDescription","slice","approved","line","siteCareChargeWords","isSiteCarePublishAction","action","trim","siteCarePublishSentence","publish","formatDate","what","targetName","atMs","formatSiteCareDate","day","hour","minute","timeZoneName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,wBAAwB,EACxBC,gCAAgC,EAChCC,0BAA0B,QACrB,yBAAqB;AAC5B,SAASC,gBAAgB,QAAQ,yBAAqB;AACtD,SAASC,aAAa,QAAkC,6BAAyB;AAEjF;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BC,GAED,mDAAmD,GACnD,OAAO,MAAMC,wBAAwB,WAAU;AAE/C,wDAAwD,GACxD,OAAO,MAAMC,mCAAmC,EAAC;AAEjD,oEAAoE,GACpE,OAAO,MAAMC,sBAAsB,kBAAiB;AAEpD,qDAAqD,GACrD,OAAO,MAAMC,+BAA+B,EAAC;AAE7C,0CAA0C,GAC1C,OAAO,MAAMC,gCAAgC,KAAK,GAAE;AAEpD;;;;CAIC,GACD,OAAO,MAAMC,gCAAgC,gBAAe;AAE5D;;;;;;;;;CASC,GACD,OAAO,MAAMC,+BAA+B,UAAS;AAErD;;;;;CAKC,GACD,OAAO,SAASC;IACd,OAA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/** The photo link the asset came through (AGL-3957), with `ownerPhoto`. */
|
|
860
860
|
photoLinkId?: string;
|
|
861
|
+
/**
|
|
862
|
+
* The website a photo was brought in from by a site import (AGL-3976),
|
|
863
|
+
* written by the server ingest that copied it. `key` is what the site's
|
|
864
|
+
* library is searched by before the same picture is copied again, so one
|
|
865
|
+
* photo is stored once per site however many imported pages show it.
|
|
866
|
+
*/
|
|
867
|
+
importedFrom?: AglynHostMediaImportSource;
|
|
861
868
|
createdAt?: ITimestamp;
|
|
862
869
|
updatedAt?: ITimestamp;
|
|
863
870
|
deletedAt?: ITimestamp;
|
|
@@ -888,6 +895,19 @@ export interface AglynHostMediaStockSource {
|
|
|
888
895
|
query?: string;
|
|
889
896
|
importedAt?: ITimestamp;
|
|
890
897
|
}
|
|
898
|
+
/**
|
|
899
|
+
* Where a photo a site import brought in came from (AGL-3976): the proved
|
|
900
|
+
* website and the picture's own address there.
|
|
901
|
+
*/
|
|
902
|
+
export interface AglynHostMediaImportSource {
|
|
903
|
+
/** `import:<hash of the address>`: the key a site's library reuses the asset by. */
|
|
904
|
+
key: string;
|
|
905
|
+
/** The picture's address on the website it was brought in from. */
|
|
906
|
+
url: string;
|
|
907
|
+
/** The proved domain the import read. */
|
|
908
|
+
domain: string;
|
|
909
|
+
importedAt?: ITimestamp;
|
|
910
|
+
}
|
|
891
911
|
/**
|
|
892
912
|
* Media folder doc (AGL-171): `hosts/{hostId}/mediaFolders/{folderId}`.
|
|
893
913
|
* Hierarchy/validation helpers live in `app-utils/media-folders`.
|