@happyvertical/smrt-support 0.51.39 → 0.53.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.
@@ -2,7 +2,7 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-support",
5
- "packageVersion": "0.51.39",
5
+ "packageVersion": "0.53.0",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-support:ServiceTimeEntry": {
8
8
  "name": "servicetimeentry",
@@ -9210,6 +9210,7 @@
9210
9210
  "@happyvertical/smrt-messages",
9211
9211
  "@happyvertical/smrt-projects",
9212
9212
  "@happyvertical/smrt-tenancy",
9213
+ "@happyvertical/smrt-timesheets",
9213
9214
  "@happyvertical/smrt-users"
9214
9215
  ]
9215
9216
  }
@@ -1,11 +1,19 @@
1
- /** Compatibility mapping for issue #1955. */
1
+ /**
2
+ * Support's subtype of the shared time entry (#1955, #3288). The base entry
3
+ * lives in `@happyvertical/smrt-timesheets` with no domain-specific foreign
4
+ * key; support adds the case and specialist context here.
5
+ */
2
6
  import { SmrtCollection } from '@happyvertical/smrt-core';
3
- import { type ServiceParticipantKind, type ServiceTimeEntrySource, type ServiceTimeEntryStatus, ServiceTimeEntry as SharedServiceTimeEntry } from '@happyvertical/smrt-projects';
7
+ import { type ServiceParticipantKind, type ServiceTimeEntrySource, type ServiceTimeEntryStatus, ServiceTimeEntry as SharedServiceTimeEntry } from '@happyvertical/smrt-timesheets';
4
8
  /**
5
- * Source-compatible support subtype over the shared canonical table. The
6
- * fields are restated because package-isolated manifest scanning deliberately
7
- * does not inspect dependency source trees. Runtime behavior remains inherited
8
- * from the shared model and both packages address the same table and rows.
9
+ * Support subtype over the shared `service_time_entries` table: the shared
10
+ * entry plus `caseId` (a `SupportCase`) and `specialistId` (a
11
+ * `SupportSpecialist`). It directly extends the smrt-timesheets entry (which
12
+ * smrt-projects re-exports), so the classes on this table stay one two-level
13
+ * inheritance chain. The shared fields are restated because package-isolated
14
+ * manifest scanning deliberately does not inspect dependency source trees.
15
+ * Runtime behavior is inherited from the shared model; every package
16
+ * addresses the same table and rows.
9
17
  */
10
18
  export declare class ServiceTimeEntry extends SharedServiceTimeEntry {
11
19
  tenantId: string | null;
@@ -33,6 +41,8 @@ export declare class ServiceTimeEntry extends SharedServiceTimeEntry {
33
41
  rejectionReason: string;
34
42
  correctionOfId: string | null;
35
43
  metadata: string;
44
+ /** The case and specialist are frozen with the rest of approved evidence. */
45
+ protected frozenFieldNames(): readonly string[];
36
46
  }
37
47
  export declare class ServiceTimeEntryCollection extends SmrtCollection<ServiceTimeEntry> {
38
48
  static readonly _itemClass: typeof ServiceTimeEntry;
@@ -1 +1 @@
1
- {"version":3,"file":"service-time-entry.d.ts","sourceRoot":"","sources":["../../src/models/service-time-entry.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,OAAO,EAIL,cAAc,EAEf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,gBAAgB,IAAI,sBAAsB,EAC3C,MAAM,8BAA8B,CAAC;AAGtC;;;;;GAKG;AACH,qBAOa,gBAAiB,SAAQ,sBAAsB;IAC5B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAClC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAQ;IACf,WAAW,EAAE,MAAM,GAAG,IAAI,CAAQ;IAClC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAQ;IACxC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC3C,eAAe,EAAE,sBAAsB,CAAW;IAE3E,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAQ;IAClB,QAAQ,EAAE,MAAM,CAAM;IACtB,MAAM,EAAE,sBAAsB,CAAY;IAC1C,WAAW,EAAE,MAAM,CAAM;IAClD,SAAS,EAAE,IAAI,GAAG,IAAI,CAAQ;IAC9B,OAAO,EAAE,I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AM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAGhE,eAAe,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;CAMrD;AAED,eAAe,gBAAgB,CAAC"}
@@ -3,13 +3,13 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-support",
6
- "packageVersion": "0.51.39",
6
+ "packageVersion": "0.53.0",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "dc38ad3345d34f6b10a3feb52fa6a8d1cedc209611f81c756e1008b215d40d5b",
11
- "packageJson": "9d609a5b1bab89fce8142b67c0f1a92684652f38919f2e58370ed0968ba63b46",
12
- "agents": "57d75c4e48c549de0e7e50bfc16d739384cd37f4a0c66f0375d1985b24e6cbdd"
10
+ "manifest": "9fcfb674cefa600a78b4076105e92f368c648afdc128ce6a067b6fc6ec3be24b",
11
+ "packageJson": "b714c83923c45731c37ad4d1c6cce700fc96d0781552ca0e1f8f3a2d7a33186f",
12
+ "agents": "2ad2109ce8b2880f6144b97076a94ed185c68e84dfcd468f368d6a571ece0ef7"
13
13
  },
14
14
  "exports": [
15
15
  ".",
@@ -25,6 +25,7 @@
25
25
  "@happyvertical/smrt-messages": "workspace:*",
26
26
  "@happyvertical/smrt-projects": "workspace:*",
27
27
  "@happyvertical/smrt-tenancy": "workspace:*",
28
+ "@happyvertical/smrt-timesheets": "workspace:*",
28
29
  "@happyvertical/smrt-ui": "workspace:*",
29
30
  "@happyvertical/smrt-users": "workspace:*",
30
31
  "@happyvertical/sql": "catalog:",
@@ -32,7 +33,7 @@
32
33
  "@sveltejs/package": "^2.5.8",
33
34
  "@sveltejs/vite-plugin-svelte": "^7.3.0",
34
35
  "@types/node": "24.13.6",
35
- "svelte": "^5.57.1",
36
+ "svelte": "^5.57.0",
36
37
  "svelte-check": "^4.7.6",
37
38
  "typescript": "6.0.3",
38
39
  "vite": "8.1.4",
@@ -45,6 +46,7 @@
45
46
  "@happyvertical/smrt-messages",
46
47
  "@happyvertical/smrt-projects",
47
48
  "@happyvertical/smrt-tenancy",
49
+ "@happyvertical/smrt-timesheets",
48
50
  "@happyvertical/smrt-ui",
49
51
  "@happyvertical/smrt-users",
50
52
  "@happyvertical/smrt-vitest"
@@ -6859,5 +6861,5 @@
6859
6861
  "polymorphicAssociations": 0,
6860
6862
  "uuidColumns": 150
6861
6863
  },
6862
- "agentDoc": "# @happyvertical/smrt-support\n\nAI-first Support Cases for the SMRT framework (epic #1934). Every inbound\nsupport interaction — chat message or email — creates or joins one canonical,\ntenant-scoped **Support Case**; channels stay transports, never separate\nsystems of record. The package owns the case lifecycle, channel intake, the\nAutomated Support Response workflow with lossless **Human Handoff**,\nProject-qualified routing, **Service Target** clocks with timed escalation,\nand auditable **Service Time Entries** whose client charges and provider\ncompensation stay separate. Since #1955 the canonical `ServiceTimeEntry` class\nis owned by `smrt-projects`; this package exposes a compatibility subtype that\nrestates the shared fields for isolated manifest scanning. Both imports use the\nunchanged `service_time_entries` table, so no data is duplicated.\n\n**Boundary (FR-29a):** Support owns tickets, interactions, routing, and\nservice targets. Delivery Operations owns repository work — a **Delivery\nHandoff** links a case to a Development Work Item (e.g.\n`@happyvertical/smrt-projects:Issue`) via a `SupportWorkLink` without ever\ndriving its execution; the delivery side reports status echoes back.\n\n## Models\n\nCase-side models are **internal**: generated API/CLI/MCP surfaces are\nread-only (`list`/`get`) and every write goes through the service facades\n(the `smrt-chat` `ChatService` idiom). Operational configuration models\n(bindings, policies, specialists, qualifications, availability) expose full\ngenerated CRUD; **commercial terms** (`SupportPlan`,\n`SupportCompensationPlan`) are read-only too — their writes flow through the\n`support.manage-plans`-gated `SupportPlanAdminService`.\n\n### Case core (#1926)\n\n- **SupportCase** (`support_cases`) — canonical ticket: `caseNumber`,\n `subject`, `status` (`new → triaged → assigned → in_progress →\n waiting_on_client|escalated → resolved → closed`, guarded at save time via\n the WeakMap + authoritative-DB-read idiom from S5 #1390), `priority`,\n `severity` (plan-defined key), `category`, `sensitive`, `channelKind`,\n `clientProfileId`/`openedByProfileId` (crossPackageRef → Profile),\n `projectId` (app-defined string — deliberately not an FK), `bindingId`,\n `threadKey` (create-or-join dedup key), `planId` + `planSnapshot` (terms\n frozen at apply time), assignment fields, response stamps\n (`acknowledgedAt`, `firstRespondedAt`), `humanRequestedAt`, resolution\n fields, `reopenCount`/`lastReopenedAt`, `aiEnabled`.\n- **SupportInteraction** (`support_interactions`,\n `conflictColumns: ['source_key']`) — channel-neutral transport record:\n `direction` (`inbound`/`outbound`/`internal`), `channelKind`, `actorKind`\n (`client`/`specialist`/`agent`/`system`), denormalized `body`, and the\n qualified `sourceType`/`sourceId` + globally unique `sourceKey`\n (`chat:<messageId>`, `email:<emailId>`, `manual:<uuid>`) that makes\n re-ingestion idempotent.\n- **SupportCaseEvent** (`support_case_events`) — append-only audit trail\n (transitions, assignments, AI runs, handoffs, escalations, target state,\n work links, reopens). Together with interactions this is the complete\n context a Human Handoff transfers.\n- **SupportChannelBinding** (`support_channel_bindings`,\n `conflictColumns: ['target_type','target_id']`) — marks a container as a\n support intake channel: `bindingKind` (`chat_room`/`email_account`),\n qualified `targetType` + `targetId`, default client/project/plan,\n `selfAddresses` (email direction heuristic). Unbound containers are never\n touched.\n- **SupportWorkLink** (`support_work_links`) — Support/Development Work Item\n links with a read-only `status` echo.\n\n### AI workflow (#1928)\n\n- **SupportPolicy** (`support_policies`) — what the AI may do without a\n human: `autoAcknowledge`/`autoClassify`/`autoAnswer` (on by default),\n `autoTroubleshoot`/`autoResolve` (off by default),\n `autoResolveMaxSeverity`, `confidenceThreshold`, `maxAutoAttempts`,\n `sensitiveCategories`, `allowedTools`, `autoSendEmailReplies` (off —\n email replies are drafted, not sent). Resolution is most-specific-wins on\n `(planId, projectId)`; no row → `DEFAULT_SUPPORT_POLICY` (conservative).\n- **SupportAiRun** (`support_ai_runs`) — append-only audit of each phase\n (`acknowledge`/`classify`/`answer`/`troubleshoot`/`resolve`) with\n `confidence`, classification output, knowledge refs, tool calls, outcome\n (`completed`/`skipped`/`failed`/`handed_off`), and `correlationId`.\n\n### Routing, targets, escalation (#1929)\n\n- **SupportSpecialist** (`support_specialists`) — specialist role record on a\n Profile (the commerce `Customer` role-record idiom): `languages`,\n `timezone`, `maxConcurrentCases`, `onCallPriority`, status.\n- **SupportQualification** (`support_qualifications`) — effective-dated\n Project Support Qualification (`trainee`/`qualified`/`expert`).\n- **SupportAvailability** (`support_availability_windows`) — weekly windows\n plus `on_call`/`time_off` spans.\n- **SupportPlan** (`support_plans`, `conflictColumns:\n ['tenant_id','plan_key']`) — the Managed Support Plan: coverage calendar +\n holidays + timezone, channels, severity definitions, per-severity\n acknowledgement/response/update/resolution target minutes, `pauseStatuses`\n (clocks pause only when the plan says so), escalation policy steps,\n availability fee, `includedMinutes`, `overageHourlyRate`,\n `onCallHourlyRate`, time-approval policy, optional\n `subscriptionPlanKey` binding (string, not a dependency).\n `snapshotTerms()` feeds `SupportCase.planSnapshot`.\n- **SupportServiceTarget** (`support_service_targets`,\n `conflictColumns: ['case_id','target_type','cycle']`) — one clock per\n target type (update clocks recur via `cycle`), with pause accounting and\n `escalationJobId` (the one-shot `_smrt_jobs` row scheduled at `dueAt`,\n cancelled on satisfy).\n- **SupportEscalation** (`support_escalations`) — the audit record of one\n escalation firing.\n- **SupportCompensationPlan** (`support_compensation_plans`) —\n effective-dated Support Specialist earning terms; specialist-specific plan\n wins over the tenant default at the work instant. Deliberately separate\n from `SupportPlan` (client pricing) so margin stays measurable.\n\n### Service time (#1930)\n\n- **ServiceTimeEntry** (`service_time_entries`) — auditable Professional\n Service duration: work-context-generic (`caseId` and/or polymorphic\n `workRefType`/`workRefId`), delivering Participant (`participantKind`\n `human`/`agent` + `participantProfileId`/`agentRef`), `source`\n (`timer`/`manual`/`import`/`agent` — one shared validation/audit\n contract), evidence JSON, and lifecycle `draft → submitted →\n approved|rejected`, `approved → corrected` only. **Approved entries are\n immutable**: the work-defining fields are frozen at save time (the\n `LicenseSale` WeakMap-freeze idiom, backed by an authoritative DB-row\n comparison); disputes create explicit corrections via `correctionOfId`.\n- **SupportCharge** / **SupportCompensation** (`support_charges` /\n `support_compensations`, one per time entry) — derived commercial\n snapshots: client amount from the Managed Support Plan (included-time\n consumption then metered overage) vs provider amount from the Support\n Compensation Plan, each with a frozen `rateSnapshot`. Margin = charge −\n compensation, computed by readers; settlement/invoicing composes at the\n app/accounting boundary (#1925) and is out of scope here.\n\n## Services\n\n- **SupportCaseService** — the closed write facade: `openCase`,\n `recordInteraction` (idempotent on `sourceKey`; stamps\n `acknowledgedAt`/`firstRespondedAt`; inbound un-parks\n `waiting_on_client`), `transition`, `assign`, `resolve`, `close`,\n `reopen` (preserves prior resolution in the reopen event), `requestHuman`,\n `linkWork`/`recordWorkStatus` (Delivery Handoff), `recordEvent`,\n `getTimeline` (merged interactions + events).\n- **SupportIntakeService** — create-or-join intake for both channels:\n `ingestChatMessage` (bound `ChatRoom`; `chat:<roomId>[:<threadId>]` thread\n keys; only `role: 'user'` messages), `ingestEmail` (bound `EmailAccount`;\n RFC-thread joins via `inReplyTo`; `selfAddresses` skip; unresolved senders\n park the case with `metadata.unresolvedClient`), plus\n `registerSupportIntake()` — an opt-in `GlobalInterceptors.afterSave`\n observer keyed on the `ChatMessage`/`Email` class names that never throws\n into the source package's save path. Join semantics: open case → join;\n resolved → reopen; closed → new case.\n- **SupportAiWorkflow** — the Automated Support Response (FR-28a):\n `processIntake`/`processCase` run acknowledge → classify → answer →\n resolve under the resolved `SupportPolicy` (conservative defaults), each\n phase writing a `SupportAiRun` + `ai_run` case event. AI calls go through\n the injected `SupportAiBoundary` (default uses `supportCase.do()` with\n defensive JSON parsing that fails toward the human); knowledge comes from\n the pluggable `SupportKnowledgeProvider` (default no-op). Classification\n never overwrites human triage; email answers are drafted\n (`metadata.draft`) unless the policy allows sending. Handoff triggers —\n `client_request`, `low_confidence`, `high_severity`, `sensitive`,\n `failed_resolution`, `policy` (attempt budget) — are always active.\n- **HumanHandoffService** — the lossless Human Handoff (FR-28b):\n `handoff` assembles the full context package (case state + compact\n timeline + AI runs) into the `handoff` event, stamps\n `metadata.activeHandoff` for the no-repeat guarantee (repeat triggers are\n deduped events), routes through the injected `assignSpecialist` seam\n (#1929's routing service plugs in; default queues `new` cases to\n `triaged`), and `releaseHandoff` clears the flag.\n- **ServiceTargetEngine** — Service Target clocks (FR-30/31):\n `startTargetsForCase` derives per-severity clocks from the case's\n `planSnapshot` (live plan fallback) with due times computed in covered\n time (`coverage-calendar.ts`: timezone-aware weekly windows + holidays;\n empty coverage = 24×7) and schedules one-shot `_smrt_jobs` escalation jobs\n at `dueAt`; `onInteractionRecorded` satisfies acknowledgement/response and\n recurs `update` cycles; `onCaseTransition` pauses/resumes clocks only when\n the plan's `pauseStatuses` say so (recomputing remaining covered minutes)\n and settles targets on resolve. Breach → `SupportServiceTarget.\n checkAndEscalate` (background-eligible, at-least-once-safe) marks the\n breach and escalates through the plan's policy steps (notify/reassign,\n delayed follow-up levels), transitioning the case to `escalated`.\n- **SupportPlanAdminService** — the permission-gated write surface for\n commercial terms: create/update/archive for Managed Support Plans and\n Support Compensation Plans, every act behind `support.manage-plans` with\n cross-tenant writes refused (generated CRUD on both models is read-only).\n- **SupportRoutingService** — explainable ranked routing (FR-30):\n `rankSpecialists` hard-filters on active status, effective Project\n Support Qualification, workload cap, and availability windows (specialist\n timezone), then scores preferred-specialist, qualification level, on-call,\n workload headroom, and language (weights in `ROUTING_WEIGHTS`; every\n factor recorded so ineligible specialists show why); `autoAssign` writes\n the assignment with its rationale; `reassign` is gated by\n `support.reassign-case` and refuses cross-tenant principals.\n- **ServiceTimeEntryService** — the ONE recording contract for all four\n entry sources (FR-40): `record` validates duration (explicit or derived\n from the period; `timer` needs both bounds), participant coherence\n (`human` → `participantProfileId`, `agent` → `agentRef`), and the work\n context (case and/or work ref; case entries copy the tenant and append a\n `time_recorded` event); `submit` stamps the submitter.\n- **TimeEntryApprovalService** — the approval gate and only writer of the\n commercial snapshots (FR-36): `approve` resolves the governing terms (case\n `planSnapshot` first, live plan fallback, zero-rate default), gates by\n policy path (`automatic`/`threshold`/`operator`/`client`; operator paths\n behind `support.approve-time-entry`; cross-tenant principals refused), then\n derives the `SupportCharge` (included time first, then overage/on-call) and\n `SupportCompensation` (effective-dated plan) rows; `reject` and `correct`\n (supersede + linked fresh draft via `correctionOfId`) round out the\n lifecycle. Case events carry the charge amount only — compensation never\n leaks case-side.\n\n## Permissions\n\nContributed to the runtime catalog on import (the\n`personas.activate-directive` pattern): `support.reassign-case`,\n`support.approve-time-entry`, `support.manage-plans`. Privileged service\noperations take a `SupportPrincipal` (`can(slug)`), built from explicit slugs\nor a `PermissionResolver`.\n\n## Svelte UI\n\n`@happyvertical/smrt-support/svelte` ships presentational Svelte 5 surfaces:\n`CaseQueue` (priority/status/assignment/channel at a glance, `onselect`),\n`CaseDetail` (header, meta, linked work, merged timeline), `TargetList`\n(Service Target clocks with due/paused/satisfied/breached badges),\n`RoutingRationale` (ranked specialists with eligibility + factor chips and\nan optional reassign action), and `TimeEntryApprovalQueue`\n(date/hours/description/worker/status/amount with\napprove/reject-with-reason actions on submitted rows). Hosts adapt models\nwith `toSupportCaseView` / `toCaseTimelineItemView` / `toServiceTargetView`\n/ `toSupportTimeEntryView` — the time-entry view's first eight fields\ndeliberately match `smrt-projects`' presentation `TimeEntry` contract.\nComponents use `smrt-ui` primitives (`smrtRawPrimitives: \"strict\"`).\n\n## Dependencies\n\nPackage dependencies: `smrt-core`, `smrt-tenancy`, `smrt-projects`,\n`smrt-chat`, `smrt-messages`, `smrt-jobs`, `smrt-users`, `smrt-ui`,\n`@happyvertical/logger`, `@happyvertical/sql`. Profile and subscriptions\nreferences are `@crossPackageRef` string ids or plain string\nkeys. `smrt-projects` is the intentional shared delivery/evidence edge added\nby #1955. No inter-`smrt-*` `peerDependencies`.\n\n## Validation\n\n```sh\npnpm --filter @happyvertical/smrt-support test\npnpm --filter @happyvertical/smrt-support test:postgres\npnpm --filter @happyvertical/smrt-support typecheck\npnpm --filter @happyvertical/smrt-support build\n```\n\n`test:postgres` is the lane that holds the money/rate line — SQLite's type\naffinity stores a REAL in an INTEGER column without complaint, so a money field\nthat reverted to DECIMAL passes every SQLite suite.\n\n## Money and rates\n\n- **Money is integer minor units** (cents) — `$19.99` is `1999`.\n `SupportPlan.availabilityFeeAmount`, `SupportCharge.amount` and\n `SupportCompensation.amount` initialize `= 0`, never `= 0.0`: the integer\n literal is what maps them to INTEGER columns (BIGINT on fresh PostgreSQL/DuckDB databases; #2401, #2373).\n- **Rates stay DECIMAL but their unit changed.**\n `SupportPlan.overageHourlyRate` / `onCallHourlyRate` and\n `SupportCompensationPlan.hourlyRate` are **minor units per hour**, so\n `hours * rate` yields minor units. INTEGER would truncate a sub-unit rate to\n zero, which is why they keep a decimal initializer.\n- **`roundMoney()` is the single rate↔money boundary.** It rounds\n `(seconds / 3600) * hourlyRate` to a whole minor unit, which is what lets the\n `thresholdAmount` comparison in `determinePath()` be an exact `>` with no\n tolerance. `TimeApprovalPolicy.thresholdAmount` is in the same unit as\n `SupportCharge.amount`.\n- **Migrating an existing database**: `preflightSupportMoneyMinorUnits(db)`\n reports which columns still hold major units and which rows would be rounded\n or exceed JavaScript's safe-integer range; `migrateSupportMoneyToMinorUnits(db)` converts them\n (idempotent via `_smrt_backfills`). The **rate columns are not in that list**\n — their type does not change, but their stored values must still be\n multiplied by the same scale in the same deploy step. Frozen `rateSnapshot`\n JSON on settled charges is history and is left alone. On SQLite the values\n are rescaled but the declared type needs the table-rebuild path (#2370).\n Fresh PostgreSQL/DuckDB INTEGER columns are BIGINT and hydration rejects\n values outside JavaScript's safe-integer range; existing PostgreSQL `int4`\n columns require #2424.\n\n## Gotchas\n\n- **Writes go through the facades** — the case-side generated routes are\n read-only on purpose; `create`/`update` on them is not a bug to \"fix\".\n- **`projectId` is an app-defined string** — the consuming app owns the\n Project concept; don't turn it into an FK or a crossPackageRef to\n `smrt-projects:Project` (that class is a provider board, not a client\n initiative).\n- **`SupportCase.threadKey` + `SupportInteraction.sourceKey` carry intake\n correctness** — `sourceKey` is globally unique (`conflictColumns`), so\n replayed transport rows are no-ops; new manual interactions must use a\n fresh `manual:<uuid>` key.\n- **High-volume models avoid the inherited `name` field** (`subject`,\n `displayName`, …) so the default `(slug, context, _meta_type)` unique index\n falls back to id-derived slugs; named config models carry\n `conflictColumns` instead (which replaces that index).\n- **Approved time entries never change** — corrections are new rows linked\n by `correctionOfId`; the original flips to `corrected` with its snapshot\n intact.\n- **Plan edits never rewrite history** — cases keep `planSnapshot`, charges\n and compensation keep `rateSnapshot`.\n- **Create-or-join and included-time consumption serialize in-process** —\n `SupportIntakeService` (per conversation key) and\n `TimeEntryApprovalService` (per case) use a `KeyedMutex`, which covers the\n single-app-process deployment these paths run in. Multi-replica\n deployments must serialize at the app layer (route a conversation's\n intake / a case's approvals through one worker, or add an app-level\n claim) — the framework exposes no cross-adapter transaction primitive at\n this seam. Escalation is additionally idempotent per `(target, level)`,\n so at-least-once job redelivery never stacks duplicate escalations.\n"
6864
+ "agentDoc": "# @happyvertical/smrt-support\n\nAI-first Support Cases for the SMRT framework (epic #1934). Every inbound\nsupport interaction — chat message or email — creates or joins one canonical,\ntenant-scoped **Support Case**; channels stay transports, never separate\nsystems of record. The package owns the case lifecycle, channel intake, the\nAutomated Support Response workflow with lossless **Human Handoff**,\nProject-qualified routing, **Service Target** clocks with timed escalation,\nand auditable **Service Time Entries** whose client charges and provider\ncompensation stay separate. Since #3288 the shared `ServiceTimeEntry` class\nis owned by `smrt-timesheets` (smrt-projects re-exports it); this package's\nsubtype extends it directly, adds `caseId` / `specialistId` (frozen on\napproval via `frozenFieldNames()`), and restates the shared fields for\nisolated manifest scanning. Every import uses the unchanged\n`service_time_entries` table, so no data is duplicated. Keep the subtype a\ndirect child of the timesheets entry: a third same-named level on the table\nbreaks single-table-family resolution.\n\n**Boundary (FR-29a):** Support owns tickets, interactions, routing, and\nservice targets. Delivery Operations owns repository work — a **Delivery\nHandoff** links a case to a Development Work Item (e.g.\n`@happyvertical/smrt-projects:Issue`) via a `SupportWorkLink` without ever\ndriving its execution; the delivery side reports status echoes back.\n\n## Models\n\nCase-side models are **internal**: generated API/CLI/MCP surfaces are\nread-only (`list`/`get`) and every write goes through the service facades\n(the `smrt-chat` `ChatService` idiom). Operational configuration models\n(bindings, policies, specialists, qualifications, availability) expose full\ngenerated CRUD; **commercial terms** (`SupportPlan`,\n`SupportCompensationPlan`) are read-only too — their writes flow through the\n`support.manage-plans`-gated `SupportPlanAdminService`.\n\n### Case core (#1926)\n\n- **SupportCase** (`support_cases`) — canonical ticket: `caseNumber`,\n `subject`, `status` (`new → triaged → assigned → in_progress →\n waiting_on_client|escalated → resolved → closed`, guarded at save time via\n the WeakMap + authoritative-DB-read idiom from S5 #1390), `priority`,\n `severity` (plan-defined key), `category`, `sensitive`, `channelKind`,\n `clientProfileId`/`openedByProfileId` (crossPackageRef → Profile),\n `projectId` (app-defined string — deliberately not an FK), `bindingId`,\n `threadKey` (create-or-join dedup key), `planId` + `planSnapshot` (terms\n frozen at apply time), assignment fields, response stamps\n (`acknowledgedAt`, `firstRespondedAt`), `humanRequestedAt`, resolution\n fields, `reopenCount`/`lastReopenedAt`, `aiEnabled`.\n- **SupportInteraction** (`support_interactions`,\n `conflictColumns: ['source_key']`) — channel-neutral transport record:\n `direction` (`inbound`/`outbound`/`internal`), `channelKind`, `actorKind`\n (`client`/`specialist`/`agent`/`system`), denormalized `body`, and the\n qualified `sourceType`/`sourceId` + globally unique `sourceKey`\n (`chat:<messageId>`, `email:<emailId>`, `manual:<uuid>`) that makes\n re-ingestion idempotent.\n- **SupportCaseEvent** (`support_case_events`) — append-only audit trail\n (transitions, assignments, AI runs, handoffs, escalations, target state,\n work links, reopens). Together with interactions this is the complete\n context a Human Handoff transfers.\n- **SupportChannelBinding** (`support_channel_bindings`,\n `conflictColumns: ['target_type','target_id']`) — marks a container as a\n support intake channel: `bindingKind` (`chat_room`/`email_account`),\n qualified `targetType` + `targetId`, default client/project/plan,\n `selfAddresses` (email direction heuristic). Unbound containers are never\n touched.\n- **SupportWorkLink** (`support_work_links`) — Support/Development Work Item\n links with a read-only `status` echo.\n\n### AI workflow (#1928)\n\n- **SupportPolicy** (`support_policies`) — what the AI may do without a\n human: `autoAcknowledge`/`autoClassify`/`autoAnswer` (on by default),\n `autoTroubleshoot`/`autoResolve` (off by default),\n `autoResolveMaxSeverity`, `confidenceThreshold`, `maxAutoAttempts`,\n `sensitiveCategories`, `allowedTools`, `autoSendEmailReplies` (off —\n email replies are drafted, not sent). Resolution is most-specific-wins on\n `(planId, projectId)`; no row → `DEFAULT_SUPPORT_POLICY` (conservative).\n- **SupportAiRun** (`support_ai_runs`) — append-only audit of each phase\n (`acknowledge`/`classify`/`answer`/`troubleshoot`/`resolve`) with\n `confidence`, classification output, knowledge refs, tool calls, outcome\n (`completed`/`skipped`/`failed`/`handed_off`), and `correlationId`.\n\n### Routing, targets, escalation (#1929)\n\n- **SupportSpecialist** (`support_specialists`) — specialist role record on a\n Profile (the commerce `Customer` role-record idiom): `languages`,\n `timezone`, `maxConcurrentCases`, `onCallPriority`, status.\n- **SupportQualification** (`support_qualifications`) — effective-dated\n Project Support Qualification (`trainee`/`qualified`/`expert`).\n- **SupportAvailability** (`support_availability_windows`) — weekly windows\n plus `on_call`/`time_off` spans.\n- **SupportPlan** (`support_plans`, `conflictColumns:\n ['tenant_id','plan_key']`) — the Managed Support Plan: coverage calendar +\n holidays + timezone, channels, severity definitions, per-severity\n acknowledgement/response/update/resolution target minutes, `pauseStatuses`\n (clocks pause only when the plan says so), escalation policy steps,\n availability fee, `includedMinutes`, `overageHourlyRate`,\n `onCallHourlyRate`, time-approval policy, optional\n `subscriptionPlanKey` binding (string, not a dependency).\n `snapshotTerms()` feeds `SupportCase.planSnapshot`.\n- **SupportServiceTarget** (`support_service_targets`,\n `conflictColumns: ['case_id','target_type','cycle']`) — one clock per\n target type (update clocks recur via `cycle`), with pause accounting and\n `escalationJobId` (the one-shot `_smrt_jobs` row scheduled at `dueAt`,\n cancelled on satisfy).\n- **SupportEscalation** (`support_escalations`) — the audit record of one\n escalation firing.\n- **SupportCompensationPlan** (`support_compensation_plans`) —\n effective-dated Support Specialist earning terms; specialist-specific plan\n wins over the tenant default at the work instant. Deliberately separate\n from `SupportPlan` (client pricing) so margin stays measurable.\n\n### Service time (#1930)\n\n- **ServiceTimeEntry** (`service_time_entries`) — auditable Professional\n Service duration: work-context-generic (`caseId` and/or polymorphic\n `workRefType`/`workRefId`), delivering Participant (`participantKind`\n `human`/`agent` + `participantProfileId`/`agentRef`), `source`\n (`timer`/`manual`/`import`/`agent` — one shared validation/audit\n contract), evidence JSON, and lifecycle `draft → submitted →\n approved|rejected`, `approved → corrected` only. **Approved entries are\n immutable**: the work-defining fields are frozen at save time (the\n `LicenseSale` WeakMap-freeze idiom, backed by an authoritative DB-row\n comparison); disputes create explicit corrections via `correctionOfId`.\n- **SupportCharge** / **SupportCompensation** (`support_charges` /\n `support_compensations`, one per time entry) — derived commercial\n snapshots: client amount from the Managed Support Plan (included-time\n consumption then metered overage) vs provider amount from the Support\n Compensation Plan, each with a frozen `rateSnapshot`. Margin = charge −\n compensation, computed by readers; settlement/invoicing composes at the\n app/accounting boundary (#1925) and is out of scope here.\n\n## Services\n\n- **SupportCaseService** — the closed write facade: `openCase`,\n `recordInteraction` (idempotent on `sourceKey`; stamps\n `acknowledgedAt`/`firstRespondedAt`; inbound un-parks\n `waiting_on_client`), `transition`, `assign`, `resolve`, `close`,\n `reopen` (preserves prior resolution in the reopen event), `requestHuman`,\n `linkWork`/`recordWorkStatus` (Delivery Handoff), `recordEvent`,\n `getTimeline` (merged interactions + events).\n- **SupportIntakeService** — create-or-join intake for both channels:\n `ingestChatMessage` (bound `ChatRoom`; `chat:<roomId>[:<threadId>]` thread\n keys; only `role: 'user'` messages), `ingestEmail` (bound `EmailAccount`;\n RFC-thread joins via `inReplyTo`; `selfAddresses` skip; unresolved senders\n park the case with `metadata.unresolvedClient`), plus\n `registerSupportIntake()` — an opt-in `GlobalInterceptors.afterSave`\n observer keyed on the `ChatMessage`/`Email` class names that never throws\n into the source package's save path. Join semantics: open case → join;\n resolved → reopen; closed → new case.\n- **SupportAiWorkflow** — the Automated Support Response (FR-28a):\n `processIntake`/`processCase` run acknowledge → classify → answer →\n resolve under the resolved `SupportPolicy` (conservative defaults), each\n phase writing a `SupportAiRun` + `ai_run` case event. AI calls go through\n the injected `SupportAiBoundary` (default uses `supportCase.do()` with\n defensive JSON parsing that fails toward the human); knowledge comes from\n the pluggable `SupportKnowledgeProvider` (default no-op). Classification\n never overwrites human triage; email answers are drafted\n (`metadata.draft`) unless the policy allows sending. Handoff triggers —\n `client_request`, `low_confidence`, `high_severity`, `sensitive`,\n `failed_resolution`, `policy` (attempt budget) — are always active.\n- **HumanHandoffService** — the lossless Human Handoff (FR-28b):\n `handoff` assembles the full context package (case state + compact\n timeline + AI runs) into the `handoff` event, stamps\n `metadata.activeHandoff` for the no-repeat guarantee (repeat triggers are\n deduped events), routes through the injected `assignSpecialist` seam\n (#1929's routing service plugs in; default queues `new` cases to\n `triaged`), and `releaseHandoff` clears the flag.\n- **ServiceTargetEngine** — Service Target clocks (FR-30/31):\n `startTargetsForCase` derives per-severity clocks from the case's\n `planSnapshot` (live plan fallback) with due times computed in covered\n time (`coverage-calendar.ts`: timezone-aware weekly windows + holidays;\n empty coverage = 24×7) and schedules one-shot `_smrt_jobs` escalation jobs\n at `dueAt`; `onInteractionRecorded` satisfies acknowledgement/response and\n recurs `update` cycles; `onCaseTransition` pauses/resumes clocks only when\n the plan's `pauseStatuses` say so (recomputing remaining covered minutes)\n and settles targets on resolve. Breach → `SupportServiceTarget.\n checkAndEscalate` (background-eligible, at-least-once-safe) marks the\n breach and escalates through the plan's policy steps (notify/reassign,\n delayed follow-up levels), transitioning the case to `escalated`.\n- **SupportPlanAdminService** — the permission-gated write surface for\n commercial terms: create/update/archive for Managed Support Plans and\n Support Compensation Plans, every act behind `support.manage-plans` with\n cross-tenant writes refused (generated CRUD on both models is read-only).\n- **SupportRoutingService** — explainable ranked routing (FR-30):\n `rankSpecialists` hard-filters on active status, effective Project\n Support Qualification, workload cap, and availability windows (specialist\n timezone), then scores preferred-specialist, qualification level, on-call,\n workload headroom, and language (weights in `ROUTING_WEIGHTS`; every\n factor recorded so ineligible specialists show why); `autoAssign` writes\n the assignment with its rationale; `reassign` is gated by\n `support.reassign-case` and refuses cross-tenant principals.\n- **ServiceTimeEntryService** — the ONE recording contract for all four\n entry sources (FR-40): `record` validates duration (explicit or derived\n from the period; `timer` needs both bounds), participant coherence\n (`human` → `participantProfileId`, `agent` → `agentRef`), and the work\n context (case and/or work ref; case entries copy the tenant and append a\n `time_recorded` event); `submit` stamps the submitter.\n- **TimeEntryApprovalService** — the approval gate and only writer of the\n commercial snapshots (FR-36): `approve` resolves the governing terms (case\n `planSnapshot` first, live plan fallback, zero-rate default), gates by\n policy path (`automatic`/`threshold`/`operator`/`client`; operator paths\n behind `support.approve-time-entry`; cross-tenant principals refused), then\n derives the `SupportCharge` (included time first, then overage/on-call) and\n `SupportCompensation` (effective-dated plan) rows; `reject` and `correct`\n (supersede + linked fresh draft via `correctionOfId`) round out the\n lifecycle. Case events carry the charge amount only — compensation never\n leaks case-side.\n\n## Permissions\n\nContributed to the runtime catalog on import (the\n`personas.activate-directive` pattern): `support.reassign-case`,\n`support.approve-time-entry`, `support.manage-plans`. Privileged service\noperations take a `SupportPrincipal` (`can(slug)`), built from explicit slugs\nor a `PermissionResolver`.\n\n## Svelte UI\n\n`@happyvertical/smrt-support/svelte` ships presentational Svelte 5 surfaces:\n`CaseQueue` (priority/status/assignment/channel at a glance, `onselect`),\n`CaseDetail` (header, meta, linked work, merged timeline), `TargetList`\n(Service Target clocks with due/paused/satisfied/breached badges),\n`RoutingRationale` (ranked specialists with eligibility + factor chips and\nan optional reassign action), and `TimeEntryApprovalQueue`\n(date/hours/description/worker/status/amount with\napprove/reject-with-reason actions on submitted rows; owned by\nsmrt-timesheets since #3288 and re-exported here). Hosts adapt models\nwith `toSupportCaseView` / `toCaseTimelineItemView` / `toServiceTargetView`\n/ `toSupportTimeEntryView` — the time-entry view's first eight fields\ndeliberately match the presentation `TimeEntry` contract, and\n`SupportTimeEntryView` extends smrt-timesheets' `TimeEntryApprovalView`.\nComponents use `smrt-ui` primitives (`smrtRawPrimitives: \"strict\"`).\n\n## Dependencies\n\nPackage dependencies: `smrt-core`, `smrt-tenancy`, `smrt-projects`,\n`smrt-timesheets`, `smrt-chat`, `smrt-messages`, `smrt-jobs`, `smrt-users`,\n`smrt-ui`,\n`@happyvertical/logger`, `@happyvertical/sql`. Profile and subscriptions\nreferences are `@crossPackageRef` string ids or plain string\nkeys. `smrt-projects` is the intentional shared delivery edge added by #1955;\n`smrt-timesheets` owns the shared time-entry evidence (#3288). No inter-`smrt-*` `peerDependencies`.\n\n## Validation\n\n```sh\npnpm --filter @happyvertical/smrt-support test\npnpm --filter @happyvertical/smrt-support test:postgres\npnpm --filter @happyvertical/smrt-support typecheck\npnpm --filter @happyvertical/smrt-support build\n```\n\n`test:postgres` is the lane that holds the money/rate line — SQLite's type\naffinity stores a REAL in an INTEGER column without complaint, so a money field\nthat reverted to DECIMAL passes every SQLite suite.\n\n## Money and rates\n\n- **Money is integer minor units** (cents) — `$19.99` is `1999`.\n `SupportPlan.availabilityFeeAmount`, `SupportCharge.amount` and\n `SupportCompensation.amount` initialize `= 0`, never `= 0.0`: the integer\n literal is what maps them to INTEGER columns (BIGINT on fresh PostgreSQL/DuckDB databases; #2401, #2373).\n- **Rates stay DECIMAL but their unit changed.**\n `SupportPlan.overageHourlyRate` / `onCallHourlyRate` and\n `SupportCompensationPlan.hourlyRate` are **minor units per hour**, so\n `hours * rate` yields minor units. INTEGER would truncate a sub-unit rate to\n zero, which is why they keep a decimal initializer.\n- **`roundMoney()` is the single rate↔money boundary.** It rounds\n `(seconds / 3600) * hourlyRate` to a whole minor unit, which is what lets the\n `thresholdAmount` comparison in `determinePath()` be an exact `>` with no\n tolerance. `TimeApprovalPolicy.thresholdAmount` is in the same unit as\n `SupportCharge.amount`.\n- **Migrating an existing database**: `preflightSupportMoneyMinorUnits(db)`\n reports which columns still hold major units and which rows would be rounded\n or exceed JavaScript's safe-integer range; `migrateSupportMoneyToMinorUnits(db)` converts them\n (idempotent via `_smrt_backfills`). The **rate columns are not in that list**\n — their type does not change, but their stored values must still be\n multiplied by the same scale in the same deploy step. Frozen `rateSnapshot`\n JSON on settled charges is history and is left alone. On SQLite the values\n are rescaled but the declared type needs the table-rebuild path (#2370).\n Fresh PostgreSQL/DuckDB INTEGER columns are BIGINT and hydration rejects\n values outside JavaScript's safe-integer range; existing PostgreSQL `int4`\n columns require #2424.\n\n## Gotchas\n\n- **Writes go through the facades** — the case-side generated routes are\n read-only on purpose; `create`/`update` on them is not a bug to \"fix\".\n- **`projectId` is an app-defined string** — the consuming app owns the\n Project concept; don't turn it into an FK or a crossPackageRef to\n `smrt-projects:Project` (that class is a provider board, not a client\n initiative).\n- **`SupportCase.threadKey` + `SupportInteraction.sourceKey` carry intake\n correctness** — `sourceKey` is globally unique (`conflictColumns`), so\n replayed transport rows are no-ops; new manual interactions must use a\n fresh `manual:<uuid>` key.\n- **High-volume models avoid the inherited `name` field** (`subject`,\n `displayName`, …) so the default `(slug, context, _meta_type)` unique index\n falls back to id-derived slugs; named config models carry\n `conflictColumns` instead (which replaces that index).\n- **Approved time entries never change** — corrections are new rows linked\n by `correctionOfId`; the original flips to `corrected` with its snapshot\n intact.\n- **Plan edits never rewrite history** — cases keep `planSnapshot`, charges\n and compensation keep `rateSnapshot`.\n- **Create-or-join and included-time consumption serialize in-process** —\n `SupportIntakeService` (per conversation key) and\n `TimeEntryApprovalService` (per case) use a `KeyedMutex`, which covers the\n single-app-process deployment these paths run in. Multi-replica\n deployments must serialize at the app layer (route a conversation's\n intake / a case's approvals through one worker, or add an app-level\n claim) — the framework exposes no cross-adapter transaction primitive at\n this seam. Escalation is additionally idempotent per `(target, level)`,\n so at-least-once job redelivery never stacks duplicate escalations.\n"
6863
6865
  }
@@ -0,0 +1,16 @@
1
+ // @vitest-environment jsdom
2
+ /**
3
+ * #3288: `TimeEntryApprovalQueue` moved to smrt-timesheets and stays
4
+ * importable from `@happyvertical/smrt-support/svelte`; support's time-entry
5
+ * view still adapts a support entry for it.
6
+ */
7
+ import * as timesheets from '@happyvertical/smrt-timesheets/svelte';
8
+ import { describe, expect, it } from 'vitest';
9
+ import * as support from '../../index.js';
10
+ describe('smrt-support/svelte time-entry re-exports', () => {
11
+ it('re-exports the approval queue and its status badge mapping', () => {
12
+ expect(support.TimeEntryApprovalQueue).toBe(timesheets.TimeEntryApprovalQueue);
13
+ expect(support.timeEntryStatusBadgeKey).toBe(timesheets.timeEntryStatusBadgeKey);
14
+ expect(support.timeEntryStatusBadgeKey('corrected')).toBe('warning');
15
+ });
16
+ });
@@ -14,12 +14,11 @@ import CaseDetail from './components/CaseDetail.svelte';
14
14
  import CaseQueue from './components/CaseQueue.svelte';
15
15
  import RoutingRationale from './components/RoutingRationale.svelte';
16
16
  import TargetList from './components/TargetList.svelte';
17
- import TimeEntryApprovalQueue from './components/TimeEntryApprovalQueue.svelte';
18
- export { CaseDetail, CaseQueue, RoutingRationale, TargetList, TimeEntryApprovalQueue, };
17
+ export { TimeEntryApprovalQueue, type TimeEntryApprovalQueueProps, } from '@happyvertical/smrt-timesheets/svelte';
18
+ export { CaseDetail, CaseQueue, RoutingRationale, TargetList };
19
19
  export type CaseQueueProps = ComponentProps<typeof CaseQueue>;
20
20
  export type CaseDetailProps = ComponentProps<typeof CaseDetail>;
21
21
  export type TargetListProps = ComponentProps<typeof TargetList>;
22
22
  export type RoutingRationaleProps = ComponentProps<typeof RoutingRationale>;
23
- export type TimeEntryApprovalQueueProps = ComponentProps<typeof TimeEntryApprovalQueue>;
24
23
  export { type CaseTimelineItemView, caseStatusBadgeKey, humanizeStatus, priorityBadgeKey, type RankedSpecialistView, type ServiceTargetView, type SupportCaseView, type SupportTimeEntryView, type SupportWorkLinkView, targetStatusBadgeKey, timeEntryStatusBadgeKey, toCaseTimelineItemView, toServiceTargetView, toSupportCaseView, toSupportTimeEntryView, } from './types.js';
25
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/svelte/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,UAAU,MAAM,gCAAgC,CAAC;AACxD,OAAO,SAAS,MAAM,+BAA+B,CAAC;AACtD,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,UAAU,MAAM,gCAAgC,CAAC;AACxD,OAAO,sBAAsB,MAAM,4CAA4C,CAAC;AAEhF,OAAO,EACL,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,sBAAsB,GACvB,CAAC;AACF,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9D,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC,OAAO,UAAU,CAAC,CAAC;AAChE,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC,OAAO,UAAU,CAAC,CAAC;AAChE,MAAM,MAAM,qBAAqB,GAAG,cAAc,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC5E,MAAM,MAAM,2BAA2B,GAAG,cAAc,CACtD,OAAO,sBAAsB,CAC9B,CAAC;AAEF,OAAO,EACL,KAAK,oBAAoB,EACzB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/svelte/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,UAAU,MAAM,gCAAgC,CAAC;AACxD,OAAO,SAAS,MAAM,+BAA+B,CAAC;AACtD,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,UAAU,MAAM,gCAAgC,CAAC;AAGxD,OAAO,EACL,sBAAsB,EACtB,KAAK,2BAA2B,GACjC,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,CAAC;AAC/D,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9D,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC,OAAO,UAAU,CAAC,CAAC;AAChE,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC,OAAO,UAAU,CAAC,CAAC;AAChE,MAAM,MAAM,qBAAqB,GAAG,cAAc,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE5E,OAAO,EACL,KAAK,oBAAoB,EACzB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,YAAY,CAAC"}
@@ -13,6 +13,7 @@ import CaseDetail from './components/CaseDetail.svelte';
13
13
  import CaseQueue from './components/CaseQueue.svelte';
14
14
  import RoutingRationale from './components/RoutingRationale.svelte';
15
15
  import TargetList from './components/TargetList.svelte';
16
- import TimeEntryApprovalQueue from './components/TimeEntryApprovalQueue.svelte';
17
- export { CaseDetail, CaseQueue, RoutingRationale, TargetList, TimeEntryApprovalQueue, };
16
+ // The approval queue moved to smrt-timesheets (#3288) and stays exported here.
17
+ export { TimeEntryApprovalQueue, } from '@happyvertical/smrt-timesheets/svelte';
18
+ export { CaseDetail, CaseQueue, RoutingRationale, TargetList };
18
19
  export { caseStatusBadgeKey, humanizeStatus, priorityBadgeKey, targetStatusBadgeKey, timeEntryStatusBadgeKey, toCaseTimelineItemView, toServiceTargetView, toSupportCaseView, toSupportTimeEntryView, } from './types.js';
@@ -6,6 +6,7 @@
6
6
  * `toCaseTimelineItemView` adapt the models. Explicit interfaces (not inline
7
7
  * intersections) keep Svelte 5 prop type evaluation cheap.
8
8
  */
9
+ import type { TimeEntryApprovalView } from '@happyvertical/smrt-timesheets/svelte';
9
10
  import type { ServiceTimeEntry } from '../models/service-time-entry.js';
10
11
  import type { SupportCase } from '../models/support-case.js';
11
12
  import type { SupportServiceTarget } from '../models/support-service-target.js';
@@ -46,40 +47,11 @@ export interface SupportWorkLinkView {
46
47
  status: string;
47
48
  }
48
49
  /**
49
- * View shape for a Service Time Entry in approval/review surfaces. The first
50
- * eight fields deliberately match `smrt-projects`' presentation `TimeEntry`
51
- * contract (`packages/projects/src/svelte/utils.ts`) — smrt-support promotes
52
- * that presentation-only shape into persisted models, so hosts can reuse
53
- * either package's time surfaces over the same view rows.
50
+ * View shape for a Service Time Entry in approval/review surfaces: the shared
51
+ * `TimeEntryApprovalView` from smrt-timesheets (whose first eight fields match
52
+ * the presentation `TimeEntry` contract) plus the support case.
54
53
  */
55
- export interface SupportTimeEntryView {
56
- id: string;
57
- /** ISO date part (`YYYY-MM-DD`) of the work period start. */
58
- date: string;
59
- /** Worked duration in decimal hours, rounded to 2 decimals. */
60
- hours: number;
61
- description: string;
62
- status: string;
63
- /**
64
- * Client charge in integer minor units, when a derived
65
- * {@link SupportCharge} is supplied — `$19.99` is `1999` (#2401).
66
- */
67
- amount?: number;
68
- /**
69
- * ISO 4217 code `amount` / `hourlyRate` are denominated in, when a charge is
70
- * supplied. Carried on the view because the minor-unit exponent is a property
71
- * of the currency, not a constant: `¥1999` is 1999 minor units, not 19.99
72
- * (#2401).
73
- */
74
- currency?: string;
75
- workerName?: string;
76
- /**
77
- * Hourly rate from the charge's frozen `rateSnapshot`, when supplied, in
78
- * minor units per hour (#2401).
79
- */
80
- hourlyRate?: number;
81
- source: string;
82
- participantKind: string;
54
+ export interface SupportTimeEntryView extends TimeEntryApprovalView {
83
55
  caseId: string | null;
84
56
  }
85
57
  /** Adapt a SupportCase model to the queue/detail view shape. */
@@ -96,6 +68,7 @@ export declare function toCaseTimelineItemView(item: CaseTimelineItem): CaseTime
96
68
  export declare function caseStatusBadgeKey(status: string): string;
97
69
  /** Map a case priority onto `StatusBadge` default color-scheme keys. */
98
70
  export declare function priorityBadgeKey(priority: string): string;
71
+ export { timeEntryStatusBadgeKey } from '@happyvertical/smrt-timesheets/svelte';
99
72
  /** Human-readable label for a snake_case status value. */
100
73
  export declare function humanizeStatus(value: string): string;
101
74
  /** Adapt a ServiceTimeEntry model (plus its optional charge) to the view. */
@@ -103,8 +76,6 @@ export declare function toSupportTimeEntryView(entry: ServiceTimeEntry, opts?: {
103
76
  charge?: SupportCharge | null;
104
77
  workerName?: string | null;
105
78
  }): SupportTimeEntryView;
106
- /** Map a time-entry status onto `StatusBadge` default color-scheme keys. */
107
- export declare function timeEntryStatusBadgeKey(status: string): string;
108
79
  /** Serializable Service Target clock view for `TargetList` (#1929). */
109
80
  export interface ServiceTargetView {
110
81
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/svelte/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAG7D,OAAO,KAAK,EAAE,oB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EAAyE;AACzE,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,oBAAoB,GAC3B,iBAAiB,CAcnB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAe3D;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;CACpD"}
@@ -97,6 +97,8 @@ export function priorityBadgeKey(priority) {
97
97
  return 'active';
98
98
  }
99
99
  }
100
+ // Moved to smrt-timesheets with `TimeEntryApprovalQueue` (#3288).
101
+ export { timeEntryStatusBadgeKey } from '@happyvertical/smrt-timesheets/svelte';
100
102
  /** Human-readable label for a snake_case status value. */
101
103
  export function humanizeStatus(value) {
102
104
  return (value ?? '').replace(/_/g, ' ');
@@ -127,23 +129,6 @@ export function toSupportTimeEntryView(entry, opts = {}) {
127
129
  }
128
130
  return view;
129
131
  }
130
- /** Map a time-entry status onto `StatusBadge` default color-scheme keys. */
131
- export function timeEntryStatusBadgeKey(status) {
132
- switch (status) {
133
- case 'draft':
134
- return 'inactive';
135
- case 'submitted':
136
- return 'pending';
137
- case 'approved':
138
- return 'success';
139
- case 'rejected':
140
- return 'error';
141
- case 'corrected':
142
- return 'warning';
143
- default:
144
- return 'pending';
145
- }
146
- }
147
132
  /** Adapt a SupportServiceTarget model to the `TargetList` view shape. */
148
133
  export function toServiceTargetView(target) {
149
134
  return {
package/dist/types.d.ts CHANGED
@@ -46,16 +46,7 @@ export type SupportAiRunPhase = 'acknowledge' | 'classify' | 'answer' | 'trouble
46
46
  export type SupportAiRunOutcome = 'completed' | 'skipped' | 'failed' | 'handed_off';
47
47
  /** What triggered a Human Handoff (FR-28b). */
48
48
  export type HumanHandoffTrigger = 'client_request' | 'low_confidence' | 'ambiguous_classification' | 'high_severity' | 'sensitive' | 'failed_resolution' | 'target_risk' | 'policy' | 'manual';
49
- /** Service Time Entry lifecycle (FR-36). */
50
- export type ServiceTimeEntryStatus = 'draft' | 'submitted' | 'approved' | 'rejected' | 'corrected';
51
- /**
52
- * Legal Service Time Entry status transitions. `approved → corrected` is the
53
- * only exit from `approved` and is reachable exclusively through the explicit
54
- * correction path (the approved snapshot itself stays frozen).
55
- */
56
- export declare const SERVICE_TIME_ENTRY_STATUS_TRANSITIONS: Record<ServiceTimeEntryStatus, ServiceTimeEntryStatus[]>;
57
- /** How a Service Time Entry was produced (FR-40). */
58
- export type ServiceTimeEntrySource = 'timer' | 'manual' | 'import' | 'agent';
49
+ export { SERVICE_TIME_ENTRY_STATUS_TRANSITIONS, type ServiceTimeEntrySource, type ServiceTimeEntryStatus, } from '@happyvertical/smrt-timesheets';
59
50
  /** Who/what delivered the work behind a Service Time Entry. */
60
51
  export type SupportParticipantKind = 'human' | 'agent';
61
52
  /** Which approval path accepted a Service Time Entry (FR-36). */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,8CAA8C;AAC9C,MAAM,MAAM,iBAAiB,GACzB,KAAK,GACL,SAAS,GACT,UAAU,GACV,aAAa,GACb,mBAAmB,GACnB,WAAW,GACX,UAAU,GACV,QAAQ,CAAC;AAEb;;;;;;GAMG;AACH,eAAO,MAAM,+BAA+B,EAAE,MAAM,CAClD,iBAAiB,EACjB,iBAAiB,EAAE,CAkDpB,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,0BAA0B,EAAE,iBAAiB,EAOzD,CAAC;AAEF,gEAAgE;AAChE,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEvE,4DAA4D;AAC5D,MAAM,MAAM,k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9D;AAED,uEAAuE;AACvE,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC7B,MAAM,EAAE,CAKV"}
package/dist/types.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { SERVICE_TIME_ENTRY_STATUS_TRANSITIONS } from "@happyvertical/smrt-timesheets";
1
2
  //#region src/types.ts
2
3
  var SUPPORT_CASE_STATUS_TRANSITIONS = {
3
4
  new: [
@@ -61,17 +62,6 @@ var OPEN_SUPPORT_CASE_STATUSES = [
61
62
  "waiting_on_client",
62
63
  "escalated"
63
64
  ];
64
- var SERVICE_TIME_ENTRY_STATUS_TRANSITIONS = {
65
- draft: ["submitted", "rejected"],
66
- submitted: [
67
- "approved",
68
- "rejected",
69
- "draft"
70
- ],
71
- approved: ["corrected"],
72
- rejected: ["draft", "submitted"],
73
- corrected: []
74
- };
75
65
  var DEFAULT_SEVERITY_DEFINITIONS = {
76
66
  sev1: {
77
67
  label: "Critical",
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["/**\n * Shared types, enums, and lifecycle maps for `@happyvertical/smrt-support`.\n *\n * Domain language follows the HappyVertical support glossary: a **Support\n * Case** is the canonical record of a client support request; **Support\n * Interactions** are channel transports attached to it; **Service Targets**\n * are operational clocks (not contractual SLAs); a **Managed Support Plan**\n * carries the client-facing terms while a **Support Compensation Plan**\n * carries the provider-facing terms — the two are never merged.\n */\n\n/** Support Case lifecycle states (FR-29b). */\nexport type SupportCaseStatus =\n | 'new'\n | 'triaged'\n | 'assigned'\n | 'in_progress'\n | 'waiting_on_client'\n | 'escalated'\n | 'resolved'\n | 'closed';\n\n/**\n * Legal Support Case status transitions, enforced at save time by\n * {@link SupportCase} (S5 guarded-lifecycle idiom — raw mass-assignment on a\n * generated route cannot skip states). Reopening (`resolved`/`closed` back to\n * an active state) is legal here; the reopen bookkeeping (count, history\n * event) is layered by `SupportCaseService.reopen()`.\n */\nexport const SUPPORT_CASE_STATUS_TRANSITIONS: Record<\n SupportCaseStatus,\n SupportCaseStatus[]\n> = {\n new: [\n 'triaged',\n 'assigned',\n 'in_progress',\n 'waiting_on_client',\n 'escalated',\n 'resolved',\n 'closed',\n ],\n triaged: [\n 'assigned',\n 'in_progress',\n 'waiting_on_client',\n 'escalated',\n 'resolved',\n 'closed',\n ],\n assigned: [\n 'triaged',\n 'in_progress',\n 'waiting_on_client',\n 'escalated',\n 'resolved',\n 'closed',\n ],\n in_progress: [\n 'assigned',\n 'waiting_on_client',\n 'escalated',\n 'resolved',\n 'closed',\n ],\n waiting_on_client: [\n 'assigned',\n 'in_progress',\n 'escalated',\n 'resolved',\n 'closed',\n ],\n escalated: [\n 'assigned',\n 'in_progress',\n 'waiting_on_client',\n 'resolved',\n 'closed',\n ],\n resolved: ['closed', 'in_progress', 'triaged'],\n closed: ['triaged', 'in_progress'],\n};\n\n/** Case statuses considered \"open\" for create-or-join intake dedup. */\nexport const OPEN_SUPPORT_CASE_STATUSES: SupportCaseStatus[] = [\n 'new',\n 'triaged',\n 'assigned',\n 'in_progress',\n 'waiting_on_client',\n 'escalated',\n];\n\n/** Client-facing priority (ordering/urgency inside a queue). */\nexport type SupportCasePriority = 'low' | 'normal' | 'high' | 'urgent';\n\n/** Transport kind a Support Interaction arrived through. */\nexport type SupportChannelKind =\n | 'chat'\n | 'email'\n | 'phone'\n | 'voice'\n | 'web'\n | 'api';\n\n/** Direction of a Support Interaction relative to the Client. */\nexport type SupportInteractionDirection = 'inbound' | 'outbound' | 'internal';\n\n/** Who performed an interaction or case event. */\nexport type SupportActorKind = 'client' | 'specialist' | 'agent' | 'system';\n\n/** Append-only case audit event types. */\nexport type SupportCaseEventType =\n | 'created'\n | 'interaction'\n | 'transition'\n | 'assignment'\n | 'ai_run'\n | 'handoff'\n | 'human_requested'\n | 'escalation'\n | 'target_scheduled'\n | 'target_satisfied'\n | 'target_breached'\n | 'target_paused'\n | 'target_resumed'\n | 'work_linked'\n | 'reopened'\n | 'plan_applied'\n | 'time_recorded'\n | 'note';\n\n/** What kind of transport container a channel binding points at. */\nexport type SupportBindingKind = 'chat_room' | 'email_account';\n\n/** Operational Work Item link kinds carried by a {@link SupportWorkLink}. */\nexport type SupportWorkLinkKind = 'support_work_item' | 'development_work_item';\n\n/** Service Target clock types (FR-30/FR-31). */\nexport type ServiceTargetType =\n | 'acknowledgement'\n | 'response'\n | 'update'\n | 'resolution';\n\n/** Service Target clock states. */\nexport type ServiceTargetStatus =\n | 'pending'\n | 'paused'\n | 'satisfied'\n | 'breached'\n | 'cancelled';\n\n/** Why a case was escalated. */\nexport type SupportEscalationReason =\n | 'target_breach'\n | 'target_risk'\n | 'manual'\n | 'ai_trigger';\n\n/** AI support workflow phases (FR-28a). */\nexport type SupportAiRunPhase =\n | 'acknowledge'\n | 'classify'\n | 'answer'\n | 'troubleshoot'\n | 'resolve';\n\n/** Terminal outcome of one AI workflow phase run. */\nexport type SupportAiRunOutcome =\n | 'completed'\n | 'skipped'\n | 'failed'\n | 'handed_off';\n\n/** What triggered a Human Handoff (FR-28b). */\nexport type HumanHandoffTrigger =\n | 'client_request'\n | 'low_confidence'\n | 'ambiguous_classification'\n | 'high_severity'\n | 'sensitive'\n | 'failed_resolution'\n | 'target_risk'\n | 'policy'\n | 'manual';\n\n/** Service Time Entry lifecycle (FR-36). */\nexport type ServiceTimeEntryStatus =\n | 'draft'\n | 'submitted'\n | 'approved'\n | 'rejected'\n | 'corrected';\n\n/**\n * Legal Service Time Entry status transitions. `approved → corrected` is the\n * only exit from `approved` and is reachable exclusively through the explicit\n * correction path (the approved snapshot itself stays frozen).\n */\nexport const SERVICE_TIME_ENTRY_STATUS_TRANSITIONS: Record<\n ServiceTimeEntryStatus,\n ServiceTimeEntryStatus[]\n> = {\n draft: ['submitted', 'rejected'],\n submitted: ['approved', 'rejected', 'draft'],\n approved: ['corrected'],\n rejected: ['draft', 'submitted'],\n corrected: [],\n};\n\n/** How a Service Time Entry was produced (FR-40). */\nexport type ServiceTimeEntrySource = 'timer' | 'manual' | 'import' | 'agent';\n\n/** Who/what delivered the work behind a Service Time Entry. */\nexport type SupportParticipantKind = 'human' | 'agent';\n\n/** Which approval path accepted a Service Time Entry (FR-36). */\nexport type TimeEntryApprovalPath =\n | 'automatic'\n | 'operator'\n | 'client'\n | 'threshold';\n\n/** Derived commercial snapshot lifecycle (charges and compensation). */\nexport type SupportSettlementStatus =\n | 'pending'\n | 'final'\n | 'corrected'\n | 'voided';\n\n/** Support Specialist availability window kinds. */\nexport type SupportAvailabilityKind = 'weekly' | 'on_call' | 'time_off';\n\n/** Support Specialist activation state. */\nexport type SupportSpecialistStatus = 'active' | 'inactive';\n\n/** Project Support Qualification levels. */\nexport type SupportQualificationLevel = 'trainee' | 'qualified' | 'expert';\n\n/** A weekly coverage window in a plan's coverage calendar. */\nexport interface CoverageWindow {\n /** 0 = Sunday … 6 = Saturday (JS `Date#getDay` convention). */\n weekday: number;\n /** Minutes from midnight, inclusive start. */\n startMinute: number;\n /** Minutes from midnight, exclusive end. */\n endMinute: number;\n}\n\n/** Per-severity Service Target minutes; `null` disables that clock. */\nexport interface ServiceTargetMinutes {\n acknowledgementMinutes: number | null;\n responseMinutes: number | null;\n updateMinutes: number | null;\n resolutionMinutes: number | null;\n}\n\n/** One step of a plan's escalation policy, applied in `level` order. */\nexport interface EscalationStep {\n level: number;\n action: 'notify' | 'reassign';\n /** Profile ids to notify (recorded on the escalation; delivery is app-side). */\n notifyProfileIds?: string[];\n /** Minutes after the previous step before this one fires (0 = immediately). */\n delayMinutes?: number;\n}\n\n/** A severity definition entry in a plan (key → labels). */\nexport interface SeverityDefinition {\n label: string;\n description?: string;\n}\n\n/**\n * Default severity vocabulary used when a plan doesn't define its own.\n * `sev1` is the most severe.\n */\nexport const DEFAULT_SEVERITY_DEFINITIONS: Record<string, SeverityDefinition> =\n {\n sev1: { label: 'Critical', description: 'Service down or unusable' },\n sev2: { label: 'Major', description: 'Significant degradation' },\n sev3: { label: 'Minor', description: 'Limited impact' },\n sev4: { label: 'Question', description: 'Question or request' },\n };\n\n/** Time-entry approval policy carried by a Managed Support Plan (FR-36). */\nexport interface TimeApprovalPolicy {\n /** Base path when no threshold applies. */\n mode: 'automatic' | 'operator' | 'client';\n /** Entries longer than this require review even under `automatic`. */\n thresholdMinutes?: number;\n /**\n * Entries pricing above this amount require review even under `automatic`.\n * Integer minor units, matching `SupportCharge.amount` it is compared\n * against — `$19.99` is `1999` (#2401).\n */\n thresholdAmount?: number;\n}\n\n/** One piece of work evidence attached to a Service Time Entry. */\nexport interface TimeEntryEvidence {\n kind: string;\n ref: string;\n label?: string;\n}\n\n/**\n * Parse a JSON value stored as text, returning the fallback on malformed\n * input (never throws — stored JSON may predate schema changes). Accepts an\n * already-parsed value (e.g. a `type: 'json'` column that hydrated as an\n * object) and hands it back unchanged.\n */\nexport function parseJsonField<T>(raw: unknown, fallback: T): T {\n if (!raw) {\n return fallback;\n }\n // Text columns hydrate as strings; a non-string here means the caller\n // already holds a parsed value — hand it back rather than throwing.\n if (typeof raw !== 'string') {\n return raw as T;\n }\n try {\n const parsed = JSON.parse(raw);\n return (parsed ?? fallback) as T;\n } catch {\n return fallback;\n }\n}\n\n/** Parse a JSON array-of-strings field, tolerating malformed input. */\nexport function parseStringArrayField(\n raw: string | null | undefined,\n): string[] {\n const parsed = parseJsonField<unknown>(raw, []);\n return Array.isArray(parsed)\n ? parsed.filter((value): value is string => typeof value === 'string')\n : [];\n}\n"],"mappings":";AA6BO,IAAM,kCAGT;CACF,KAAK;EACH;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,SAAS;EACP;EACA;EACA;EACA;EACA;EACA;CACF;CACA,UAAU;EACR;EACA;EACA;EACA;EACA;EACA;CACF;CACA,aAAa;EACX;EACA;EACA;EACA;EACA;CACF;CACA,mBAAmB;EACjB;EACA;EACA;EACA;EACA;CACF;CACA,WAAW;EACT;EACA;EACA;EACA;EACA;CACF;CACA,UAAU;EAAC;EAAU;EAAe;CAAS;CAC7C,QAAQ,CAAC,WAAW,aAAa;AACnC;AAGO,IAAM,6BAAkD;CAC7D;CACA;CACA;CACA;CACA;CACA;AACF;AA6GO,IAAM,wCAGT;CACF,OAAO,CAAC,aAAa,UAAU;CAC/B,WAAW;EAAC;EAAY;EAAY;CAAO;CAC3C,UAAU,CAAC,WAAW;CACtB,UAAU,CAAC,SAAS,WAAW;CAC/B,WAAW,CAAC;AACd;AAqEO,IAAM,+BACX;CACE,MAAM;EAAE,OAAO;EAAY,aAAa;CAA2B;CACnE,MAAM;EAAE,OAAO;EAAS,aAAa;CAA0B;CAC/D,MAAM;EAAE,OAAO;EAAS,aAAa;CAAiB;CACtD,MAAM;EAAE,OAAO;EAAY,aAAa;CAAsB;AAChE;AA6BK,SAAS,eAAkB,KAAc,UAAgB;CAC9D,IAAI,CAAC,KACH,OAAO;CAIT,IAAI,OAAO,QAAQ,UACjB,OAAO;CAET,IAAI;EAEF,OADe,KAAK,MAAM,GAClB,KAAU;CACpB,QAAQ;EACN,OAAO;CACT;AACF;AAGO,SAAS,sBACd,KACU;CACV,MAAM,SAAS,eAAwB,KAAK,CAAC,CAAC;CAC9C,OAAO,MAAM,QAAQ,MAAM,IACvB,OAAO,QAAQ,UAA2B,OAAO,UAAU,QAAQ,IACnE,CAAC;AACP"}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["/**\n * Shared types, enums, and lifecycle maps for `@happyvertical/smrt-support`.\n *\n * Domain language follows the HappyVertical support glossary: a **Support\n * Case** is the canonical record of a client support request; **Support\n * Interactions** are channel transports attached to it; **Service Targets**\n * are operational clocks (not contractual SLAs); a **Managed Support Plan**\n * carries the client-facing terms while a **Support Compensation Plan**\n * carries the provider-facing terms — the two are never merged.\n */\n\n/** Support Case lifecycle states (FR-29b). */\nexport type SupportCaseStatus =\n | 'new'\n | 'triaged'\n | 'assigned'\n | 'in_progress'\n | 'waiting_on_client'\n | 'escalated'\n | 'resolved'\n | 'closed';\n\n/**\n * Legal Support Case status transitions, enforced at save time by\n * {@link SupportCase} (S5 guarded-lifecycle idiom — raw mass-assignment on a\n * generated route cannot skip states). Reopening (`resolved`/`closed` back to\n * an active state) is legal here; the reopen bookkeeping (count, history\n * event) is layered by `SupportCaseService.reopen()`.\n */\nexport const SUPPORT_CASE_STATUS_TRANSITIONS: Record<\n SupportCaseStatus,\n SupportCaseStatus[]\n> = {\n new: [\n 'triaged',\n 'assigned',\n 'in_progress',\n 'waiting_on_client',\n 'escalated',\n 'resolved',\n 'closed',\n ],\n triaged: [\n 'assigned',\n 'in_progress',\n 'waiting_on_client',\n 'escalated',\n 'resolved',\n 'closed',\n ],\n assigned: [\n 'triaged',\n 'in_progress',\n 'waiting_on_client',\n 'escalated',\n 'resolved',\n 'closed',\n ],\n in_progress: [\n 'assigned',\n 'waiting_on_client',\n 'escalated',\n 'resolved',\n 'closed',\n ],\n waiting_on_client: [\n 'assigned',\n 'in_progress',\n 'escalated',\n 'resolved',\n 'closed',\n ],\n escalated: [\n 'assigned',\n 'in_progress',\n 'waiting_on_client',\n 'resolved',\n 'closed',\n ],\n resolved: ['closed', 'in_progress', 'triaged'],\n closed: ['triaged', 'in_progress'],\n};\n\n/** Case statuses considered \"open\" for create-or-join intake dedup. */\nexport const OPEN_SUPPORT_CASE_STATUSES: SupportCaseStatus[] = [\n 'new',\n 'triaged',\n 'assigned',\n 'in_progress',\n 'waiting_on_client',\n 'escalated',\n];\n\n/** Client-facing priority (ordering/urgency inside a queue). */\nexport type SupportCasePriority = 'low' | 'normal' | 'high' | 'urgent';\n\n/** Transport kind a Support Interaction arrived through. */\nexport type SupportChannelKind =\n | 'chat'\n | 'email'\n | 'phone'\n | 'voice'\n | 'web'\n | 'api';\n\n/** Direction of a Support Interaction relative to the Client. */\nexport type SupportInteractionDirection = 'inbound' | 'outbound' | 'internal';\n\n/** Who performed an interaction or case event. */\nexport type SupportActorKind = 'client' | 'specialist' | 'agent' | 'system';\n\n/** Append-only case audit event types. */\nexport type SupportCaseEventType =\n | 'created'\n | 'interaction'\n | 'transition'\n | 'assignment'\n | 'ai_run'\n | 'handoff'\n | 'human_requested'\n | 'escalation'\n | 'target_scheduled'\n | 'target_satisfied'\n | 'target_breached'\n | 'target_paused'\n | 'target_resumed'\n | 'work_linked'\n | 'reopened'\n | 'plan_applied'\n | 'time_recorded'\n | 'note';\n\n/** What kind of transport container a channel binding points at. */\nexport type SupportBindingKind = 'chat_room' | 'email_account';\n\n/** Operational Work Item link kinds carried by a {@link SupportWorkLink}. */\nexport type SupportWorkLinkKind = 'support_work_item' | 'development_work_item';\n\n/** Service Target clock types (FR-30/FR-31). */\nexport type ServiceTargetType =\n | 'acknowledgement'\n | 'response'\n | 'update'\n | 'resolution';\n\n/** Service Target clock states. */\nexport type ServiceTargetStatus =\n | 'pending'\n | 'paused'\n | 'satisfied'\n | 'breached'\n | 'cancelled';\n\n/** Why a case was escalated. */\nexport type SupportEscalationReason =\n | 'target_breach'\n | 'target_risk'\n | 'manual'\n | 'ai_trigger';\n\n/** AI support workflow phases (FR-28a). */\nexport type SupportAiRunPhase =\n | 'acknowledge'\n | 'classify'\n | 'answer'\n | 'troubleshoot'\n | 'resolve';\n\n/** Terminal outcome of one AI workflow phase run. */\nexport type SupportAiRunOutcome =\n | 'completed'\n | 'skipped'\n | 'failed'\n | 'handed_off';\n\n/** What triggered a Human Handoff (FR-28b). */\nexport type HumanHandoffTrigger =\n | 'client_request'\n | 'low_confidence'\n | 'ambiguous_classification'\n | 'high_severity'\n | 'sensitive'\n | 'failed_resolution'\n | 'target_risk'\n | 'policy'\n | 'manual';\n\n// Service Time Entry lifecycle (FR-36), its legal transitions, and sources\n// (FR-40) are owned by smrt-timesheets (#3288) and re-exported unchanged.\nexport {\n SERVICE_TIME_ENTRY_STATUS_TRANSITIONS,\n type ServiceTimeEntrySource,\n type ServiceTimeEntryStatus,\n} from '@happyvertical/smrt-timesheets';\n\n/** Who/what delivered the work behind a Service Time Entry. */\nexport type SupportParticipantKind = 'human' | 'agent';\n\n/** Which approval path accepted a Service Time Entry (FR-36). */\nexport type TimeEntryApprovalPath =\n | 'automatic'\n | 'operator'\n | 'client'\n | 'threshold';\n\n/** Derived commercial snapshot lifecycle (charges and compensation). */\nexport type SupportSettlementStatus =\n | 'pending'\n | 'final'\n | 'corrected'\n | 'voided';\n\n/** Support Specialist availability window kinds. */\nexport type SupportAvailabilityKind = 'weekly' | 'on_call' | 'time_off';\n\n/** Support Specialist activation state. */\nexport type SupportSpecialistStatus = 'active' | 'inactive';\n\n/** Project Support Qualification levels. */\nexport type SupportQualificationLevel = 'trainee' | 'qualified' | 'expert';\n\n/** A weekly coverage window in a plan's coverage calendar. */\nexport interface CoverageWindow {\n /** 0 = Sunday … 6 = Saturday (JS `Date#getDay` convention). */\n weekday: number;\n /** Minutes from midnight, inclusive start. */\n startMinute: number;\n /** Minutes from midnight, exclusive end. */\n endMinute: number;\n}\n\n/** Per-severity Service Target minutes; `null` disables that clock. */\nexport interface ServiceTargetMinutes {\n acknowledgementMinutes: number | null;\n responseMinutes: number | null;\n updateMinutes: number | null;\n resolutionMinutes: number | null;\n}\n\n/** One step of a plan's escalation policy, applied in `level` order. */\nexport interface EscalationStep {\n level: number;\n action: 'notify' | 'reassign';\n /** Profile ids to notify (recorded on the escalation; delivery is app-side). */\n notifyProfileIds?: string[];\n /** Minutes after the previous step before this one fires (0 = immediately). */\n delayMinutes?: number;\n}\n\n/** A severity definition entry in a plan (key → labels). */\nexport interface SeverityDefinition {\n label: string;\n description?: string;\n}\n\n/**\n * Default severity vocabulary used when a plan doesn't define its own.\n * `sev1` is the most severe.\n */\nexport const DEFAULT_SEVERITY_DEFINITIONS: Record<string, SeverityDefinition> =\n {\n sev1: { label: 'Critical', description: 'Service down or unusable' },\n sev2: { label: 'Major', description: 'Significant degradation' },\n sev3: { label: 'Minor', description: 'Limited impact' },\n sev4: { label: 'Question', description: 'Question or request' },\n };\n\n/** Time-entry approval policy carried by a Managed Support Plan (FR-36). */\nexport interface TimeApprovalPolicy {\n /** Base path when no threshold applies. */\n mode: 'automatic' | 'operator' | 'client';\n /** Entries longer than this require review even under `automatic`. */\n thresholdMinutes?: number;\n /**\n * Entries pricing above this amount require review even under `automatic`.\n * Integer minor units, matching `SupportCharge.amount` it is compared\n * against — `$19.99` is `1999` (#2401).\n */\n thresholdAmount?: number;\n}\n\n/** One piece of work evidence attached to a Service Time Entry. */\nexport interface TimeEntryEvidence {\n kind: string;\n ref: string;\n label?: string;\n}\n\n/**\n * Parse a JSON value stored as text, returning the fallback on malformed\n * input (never throws — stored JSON may predate schema changes). Accepts an\n * already-parsed value (e.g. a `type: 'json'` column that hydrated as an\n * object) and hands it back unchanged.\n */\nexport function parseJsonField<T>(raw: unknown, fallback: T): T {\n if (!raw) {\n return fallback;\n }\n // Text columns hydrate as strings; a non-string here means the caller\n // already holds a parsed value — hand it back rather than throwing.\n if (typeof raw !== 'string') {\n return raw as T;\n }\n try {\n const parsed = JSON.parse(raw);\n return (parsed ?? fallback) as T;\n } catch {\n return fallback;\n }\n}\n\n/** Parse a JSON array-of-strings field, tolerating malformed input. */\nexport function parseStringArrayField(\n raw: string | null | undefined,\n): string[] {\n const parsed = parseJsonField<unknown>(raw, []);\n return Array.isArray(parsed)\n ? parsed.filter((value): value is string => typeof value === 'string')\n : [];\n}\n"],"mappings":";;AA6BO,IAAM,kCAGT;CACF,KAAK;EACH;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,SAAS;EACP;EACA;EACA;EACA;EACA;EACA;CACF;CACA,UAAU;EACR;EACA;EACA;EACA;EACA;EACA;CACF;CACA,aAAa;EACX;EACA;EACA;EACA;EACA;CACF;CACA,mBAAmB;EACjB;EACA;EACA;EACA;EACA;CACF;CACA,WAAW;EACT;EACA;EACA;EACA;EACA;CACF;CACA,UAAU;EAAC;EAAU;EAAe;CAAS;CAC7C,QAAQ,CAAC,WAAW,aAAa;AACnC;AAGO,IAAM,6BAAkD;CAC7D;CACA;CACA;CACA;CACA;CACA;AACF;AAwKO,IAAM,+BACX;CACE,MAAM;EAAE,OAAO;EAAY,aAAa;CAA2B;CACnE,MAAM;EAAE,OAAO;EAAS,aAAa;CAA0B;CAC/D,MAAM;EAAE,OAAO;EAAS,aAAa;CAAiB;CACtD,MAAM;EAAE,OAAO;EAAY,aAAa;CAAsB;AAChE;AA6BK,SAAS,eAAkB,KAAc,UAAgB;CAC9D,IAAI,CAAC,KACH,OAAO;CAIT,IAAI,OAAO,QAAQ,UACjB,OAAO;CAET,IAAI;EAEF,OADe,KAAK,MAAM,GAClB,KAAU;CACpB,QAAQ;EACN,OAAO;CACT;AACF;AAGO,SAAS,sBACd,KACU;CACV,MAAM,SAAS,eAAwB,KAAK,CAAC,CAAC;CAC9C,OAAO,MAAM,QAAQ,MAAM,IACvB,OAAO,QAAQ,UAA2B,OAAO,UAAU,QAAQ,IACnE,CAAC;AACP"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-support",
3
- "version": "0.51.39",
3
+ "version": "0.53.0",
4
4
  "smrtJsdoc": "strict",
5
5
  "description": "AI-first Support Cases: channel-neutral intake, lifecycle, routing, service targets, and service time for the SMRT framework",
6
6
  "type": "module",
@@ -26,19 +26,20 @@
26
26
  "./manifest.json": "./dist/manifest.json"
27
27
  },
28
28
  "dependencies": {
29
- "@happyvertical/logger": "^0.96.0",
30
- "@happyvertical/smrt-chat": "0.51.39",
31
- "@happyvertical/smrt-core": "0.51.39",
32
- "@happyvertical/smrt-jobs": "0.51.39",
33
- "@happyvertical/smrt-messages": "0.51.39",
34
- "@happyvertical/smrt-projects": "0.51.39",
35
- "@happyvertical/smrt-tenancy": "0.51.39",
36
- "@happyvertical/smrt-ui": "0.51.39",
37
- "@happyvertical/smrt-users": "0.51.39",
38
- "@happyvertical/sql": "^0.96.0"
29
+ "@happyvertical/logger": "^0.98.0",
30
+ "@happyvertical/smrt-chat": "0.53.0",
31
+ "@happyvertical/smrt-core": "0.53.0",
32
+ "@happyvertical/smrt-jobs": "0.53.0",
33
+ "@happyvertical/smrt-messages": "0.53.0",
34
+ "@happyvertical/smrt-projects": "0.53.0",
35
+ "@happyvertical/smrt-tenancy": "0.53.0",
36
+ "@happyvertical/smrt-timesheets": "0.53.0",
37
+ "@happyvertical/smrt-ui": "0.53.0",
38
+ "@happyvertical/smrt-users": "0.53.0",
39
+ "@happyvertical/sql": "^0.98.0"
39
40
  },
40
41
  "peerDependencies": {
41
- "svelte": "^5.57.1"
42
+ "svelte": "^5.57.0"
42
43
  },
43
44
  "peerDependenciesMeta": {
44
45
  "svelte": {
@@ -46,7 +47,7 @@
46
47
  }
47
48
  },
48
49
  "devDependencies": {
49
- "@happyvertical/smrt-vitest": "0.51.39",
50
+ "@happyvertical/smrt-vitest": "0.53.0",
50
51
  "@sveltejs/package": "^2.5.8",
51
52
  "@sveltejs/vite-plugin-svelte": "^7.3.0",
52
53
  "@types/node": "24.13.6",