@happyvertical/smrt-support 0.39.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +270 -0
- package/CLAUDE.md +1 -0
- package/LICENSE +7 -0
- package/dist/__smrt-register__.d.ts +2 -0
- package/dist/__smrt-register__.d.ts.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4358 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.json +6770 -0
- package/dist/models/index.d.ts +17 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/service-time-entry.d.ts +75 -0
- package/dist/models/service-time-entry.d.ts.map +1 -0
- package/dist/models/support-ai-run.d.ts +45 -0
- package/dist/models/support-ai-run.d.ts.map +1 -0
- package/dist/models/support-case-event.d.ts +25 -0
- package/dist/models/support-case-event.d.ts.map +1 -0
- package/dist/models/support-case.d.ts +125 -0
- package/dist/models/support-case.d.ts.map +1 -0
- package/dist/models/support-channel-binding.d.ts +47 -0
- package/dist/models/support-channel-binding.d.ts.map +1 -0
- package/dist/models/support-compensation-plan.d.ts +42 -0
- package/dist/models/support-compensation-plan.d.ts.map +1 -0
- package/dist/models/support-interaction.d.ts +49 -0
- package/dist/models/support-interaction.d.ts.map +1 -0
- package/dist/models/support-plan.d.ts +92 -0
- package/dist/models/support-plan.d.ts.map +1 -0
- package/dist/models/support-policy.d.ts +84 -0
- package/dist/models/support-policy.d.ts.map +1 -0
- package/dist/models/support-service-target.d.ts +90 -0
- package/dist/models/support-service-target.d.ts.map +1 -0
- package/dist/models/support-settlement.d.ts +58 -0
- package/dist/models/support-settlement.d.ts.map +1 -0
- package/dist/models/support-specialist.d.ts +71 -0
- package/dist/models/support-specialist.d.ts.map +1 -0
- package/dist/models/support-work-link.d.ts +31 -0
- package/dist/models/support-work-link.d.ts.map +1 -0
- package/dist/permissions.d.ts +32 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/services/coverage-calendar.d.ts +53 -0
- package/dist/services/coverage-calendar.d.ts.map +1 -0
- package/dist/services/human-handoff-service.d.ts +113 -0
- package/dist/services/human-handoff-service.d.ts.map +1 -0
- package/dist/services/index.d.ts +15 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/keyed-mutex.d.ts +22 -0
- package/dist/services/keyed-mutex.d.ts.map +1 -0
- package/dist/services/service-target-engine.d.ts +133 -0
- package/dist/services/service-target-engine.d.ts.map +1 -0
- package/dist/services/service-time-entry-service.d.ts +73 -0
- package/dist/services/service-time-entry-service.d.ts.map +1 -0
- package/dist/services/support-ai-workflow.d.ts +178 -0
- package/dist/services/support-ai-workflow.d.ts.map +1 -0
- package/dist/services/support-case-service.d.ts +162 -0
- package/dist/services/support-case-service.d.ts.map +1 -0
- package/dist/services/support-intake-service.d.ts +106 -0
- package/dist/services/support-intake-service.d.ts.map +1 -0
- package/dist/services/support-plan-admin-service.d.ts +45 -0
- package/dist/services/support-plan-admin-service.d.ts.map +1 -0
- package/dist/services/support-routing-service.d.ts +117 -0
- package/dist/services/support-routing-service.d.ts.map +1 -0
- package/dist/services/time-entry-approval-service.d.ts +162 -0
- package/dist/services/time-entry-approval-service.d.ts.map +1 -0
- package/dist/smrt-knowledge.json +4242 -0
- package/dist/svelte/components/CaseDetail.svelte +277 -0
- package/dist/svelte/components/CaseDetail.svelte.d.ts +10 -0
- package/dist/svelte/components/CaseDetail.svelte.d.ts.map +1 -0
- package/dist/svelte/components/CaseQueue.svelte +148 -0
- package/dist/svelte/components/CaseQueue.svelte.d.ts +12 -0
- package/dist/svelte/components/CaseQueue.svelte.d.ts.map +1 -0
- package/dist/svelte/components/RoutingRationale.svelte +131 -0
- package/dist/svelte/components/RoutingRationale.svelte.d.ts +11 -0
- package/dist/svelte/components/RoutingRationale.svelte.d.ts.map +1 -0
- package/dist/svelte/components/TargetList.svelte +127 -0
- package/dist/svelte/components/TargetList.svelte.d.ts +9 -0
- package/dist/svelte/components/TargetList.svelte.d.ts.map +1 -0
- package/dist/svelte/components/TimeEntryApprovalQueue.svelte +226 -0
- package/dist/svelte/components/TimeEntryApprovalQueue.svelte.d.ts +11 -0
- package/dist/svelte/components/TimeEntryApprovalQueue.svelte.d.ts.map +1 -0
- package/dist/svelte/components/__tests__/CaseDetail.test.js +86 -0
- package/dist/svelte/components/__tests__/CaseQueue.test.js +67 -0
- package/dist/svelte/components/__tests__/RoutingRationale.test.js +69 -0
- package/dist/svelte/components/__tests__/TargetList.test.js +84 -0
- package/dist/svelte/components/__tests__/TimeEntryApprovalQueue.test.js +105 -0
- package/dist/svelte/index.d.ts +25 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +18 -0
- package/dist/svelte/types.d.ts +129 -0
- package/dist/svelte/types.d.ts.map +1 -0
- package/dist/svelte/types.js +182 -0
- package/dist/types.d.ts +130 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +109 -0
- package/dist/types.js.map +1 -0
- package/package.json +86 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
# @happyvertical/smrt-support
|
|
2
|
+
|
|
3
|
+
AI-first Support Cases for the SMRT framework (epic #1934). Every inbound
|
|
4
|
+
support interaction — chat message or email — creates or joins one canonical,
|
|
5
|
+
tenant-scoped **Support Case**; channels stay transports, never separate
|
|
6
|
+
systems of record. The package owns the case lifecycle, channel intake, the
|
|
7
|
+
Automated Support Response workflow with lossless **Human Handoff**,
|
|
8
|
+
Project-qualified routing, **Service Target** clocks with timed escalation,
|
|
9
|
+
and auditable **Service Time Entries** whose client charges and provider
|
|
10
|
+
compensation stay separate.
|
|
11
|
+
|
|
12
|
+
**Boundary (FR-29a):** Support owns tickets, interactions, routing, and
|
|
13
|
+
service targets. Delivery Operations owns repository work — a **Delivery
|
|
14
|
+
Handoff** links a case to a Development Work Item (e.g.
|
|
15
|
+
`@happyvertical/smrt-projects:Issue`) via a `SupportWorkLink` without ever
|
|
16
|
+
driving its execution; the delivery side reports status echoes back.
|
|
17
|
+
|
|
18
|
+
## Models
|
|
19
|
+
|
|
20
|
+
Case-side models are **internal**: generated API/CLI/MCP surfaces are
|
|
21
|
+
read-only (`list`/`get`) and every write goes through the service facades
|
|
22
|
+
(the `smrt-chat` `ChatService` idiom). Operational configuration models
|
|
23
|
+
(bindings, policies, specialists, qualifications, availability) expose full
|
|
24
|
+
generated CRUD; **commercial terms** (`SupportPlan`,
|
|
25
|
+
`SupportCompensationPlan`) are read-only too — their writes flow through the
|
|
26
|
+
`support.manage-plans`-gated `SupportPlanAdminService`.
|
|
27
|
+
|
|
28
|
+
### Case core (#1926)
|
|
29
|
+
|
|
30
|
+
- **SupportCase** (`support_cases`) — canonical ticket: `caseNumber`,
|
|
31
|
+
`subject`, `status` (`new → triaged → assigned → in_progress →
|
|
32
|
+
waiting_on_client|escalated → resolved → closed`, guarded at save time via
|
|
33
|
+
the WeakMap + authoritative-DB-read idiom from S5 #1390), `priority`,
|
|
34
|
+
`severity` (plan-defined key), `category`, `sensitive`, `channelKind`,
|
|
35
|
+
`clientProfileId`/`openedByProfileId` (crossPackageRef → Profile),
|
|
36
|
+
`projectId` (app-defined string — deliberately not an FK), `bindingId`,
|
|
37
|
+
`threadKey` (create-or-join dedup key), `planId` + `planSnapshot` (terms
|
|
38
|
+
frozen at apply time), assignment fields, response stamps
|
|
39
|
+
(`acknowledgedAt`, `firstRespondedAt`), `humanRequestedAt`, resolution
|
|
40
|
+
fields, `reopenCount`/`lastReopenedAt`, `aiEnabled`.
|
|
41
|
+
- **SupportInteraction** (`support_interactions`,
|
|
42
|
+
`conflictColumns: ['source_key']`) — channel-neutral transport record:
|
|
43
|
+
`direction` (`inbound`/`outbound`/`internal`), `channelKind`, `actorKind`
|
|
44
|
+
(`client`/`specialist`/`agent`/`system`), denormalized `body`, and the
|
|
45
|
+
qualified `sourceType`/`sourceId` + globally unique `sourceKey`
|
|
46
|
+
(`chat:<messageId>`, `email:<emailId>`, `manual:<uuid>`) that makes
|
|
47
|
+
re-ingestion idempotent.
|
|
48
|
+
- **SupportCaseEvent** (`support_case_events`) — append-only audit trail
|
|
49
|
+
(transitions, assignments, AI runs, handoffs, escalations, target state,
|
|
50
|
+
work links, reopens). Together with interactions this is the complete
|
|
51
|
+
context a Human Handoff transfers.
|
|
52
|
+
- **SupportChannelBinding** (`support_channel_bindings`,
|
|
53
|
+
`conflictColumns: ['target_type','target_id']`) — marks a container as a
|
|
54
|
+
support intake channel: `bindingKind` (`chat_room`/`email_account`),
|
|
55
|
+
qualified `targetType` + `targetId`, default client/project/plan,
|
|
56
|
+
`selfAddresses` (email direction heuristic). Unbound containers are never
|
|
57
|
+
touched.
|
|
58
|
+
- **SupportWorkLink** (`support_work_links`) — Support/Development Work Item
|
|
59
|
+
links with a read-only `status` echo.
|
|
60
|
+
|
|
61
|
+
### AI workflow (#1928)
|
|
62
|
+
|
|
63
|
+
- **SupportPolicy** (`support_policies`) — what the AI may do without a
|
|
64
|
+
human: `autoAcknowledge`/`autoClassify`/`autoAnswer` (on by default),
|
|
65
|
+
`autoTroubleshoot`/`autoResolve` (off by default),
|
|
66
|
+
`autoResolveMaxSeverity`, `confidenceThreshold`, `maxAutoAttempts`,
|
|
67
|
+
`sensitiveCategories`, `allowedTools`, `autoSendEmailReplies` (off —
|
|
68
|
+
email replies are drafted, not sent). Resolution is most-specific-wins on
|
|
69
|
+
`(planId, projectId)`; no row → `DEFAULT_SUPPORT_POLICY` (conservative).
|
|
70
|
+
- **SupportAiRun** (`support_ai_runs`) — append-only audit of each phase
|
|
71
|
+
(`acknowledge`/`classify`/`answer`/`troubleshoot`/`resolve`) with
|
|
72
|
+
`confidence`, classification output, knowledge refs, tool calls, outcome
|
|
73
|
+
(`completed`/`skipped`/`failed`/`handed_off`), and `correlationId`.
|
|
74
|
+
|
|
75
|
+
### Routing, targets, escalation (#1929)
|
|
76
|
+
|
|
77
|
+
- **SupportSpecialist** (`support_specialists`) — specialist role record on a
|
|
78
|
+
Profile (the commerce `Customer` role-record idiom): `languages`,
|
|
79
|
+
`timezone`, `maxConcurrentCases`, `onCallPriority`, status.
|
|
80
|
+
- **SupportQualification** (`support_qualifications`) — effective-dated
|
|
81
|
+
Project Support Qualification (`trainee`/`qualified`/`expert`).
|
|
82
|
+
- **SupportAvailability** (`support_availability_windows`) — weekly windows
|
|
83
|
+
plus `on_call`/`time_off` spans.
|
|
84
|
+
- **SupportPlan** (`support_plans`, `conflictColumns:
|
|
85
|
+
['tenant_id','plan_key']`) — the Managed Support Plan: coverage calendar +
|
|
86
|
+
holidays + timezone, channels, severity definitions, per-severity
|
|
87
|
+
acknowledgement/response/update/resolution target minutes, `pauseStatuses`
|
|
88
|
+
(clocks pause only when the plan says so), escalation policy steps,
|
|
89
|
+
availability fee, `includedMinutes`, `overageHourlyRate`,
|
|
90
|
+
`onCallHourlyRate`, time-approval policy, optional
|
|
91
|
+
`subscriptionPlanKey` binding (string, not a dependency).
|
|
92
|
+
`snapshotTerms()` feeds `SupportCase.planSnapshot`.
|
|
93
|
+
- **SupportServiceTarget** (`support_service_targets`,
|
|
94
|
+
`conflictColumns: ['case_id','target_type','cycle']`) — one clock per
|
|
95
|
+
target type (update clocks recur via `cycle`), with pause accounting and
|
|
96
|
+
`escalationJobId` (the one-shot `_smrt_jobs` row scheduled at `dueAt`,
|
|
97
|
+
cancelled on satisfy).
|
|
98
|
+
- **SupportEscalation** (`support_escalations`) — the audit record of one
|
|
99
|
+
escalation firing.
|
|
100
|
+
- **SupportCompensationPlan** (`support_compensation_plans`) —
|
|
101
|
+
effective-dated Support Specialist earning terms; specialist-specific plan
|
|
102
|
+
wins over the tenant default at the work instant. Deliberately separate
|
|
103
|
+
from `SupportPlan` (client pricing) so margin stays measurable.
|
|
104
|
+
|
|
105
|
+
### Service time (#1930)
|
|
106
|
+
|
|
107
|
+
- **ServiceTimeEntry** (`service_time_entries`) — auditable Professional
|
|
108
|
+
Service duration: work-context-generic (`caseId` and/or polymorphic
|
|
109
|
+
`workRefType`/`workRefId`), delivering Participant (`participantKind`
|
|
110
|
+
`human`/`agent` + `participantProfileId`/`agentRef`), `source`
|
|
111
|
+
(`timer`/`manual`/`import`/`agent` — one shared validation/audit
|
|
112
|
+
contract), evidence JSON, and lifecycle `draft → submitted →
|
|
113
|
+
approved|rejected`, `approved → corrected` only. **Approved entries are
|
|
114
|
+
immutable**: the work-defining fields are frozen at save time (the
|
|
115
|
+
`LicenseSale` WeakMap-freeze idiom, backed by an authoritative DB-row
|
|
116
|
+
comparison); disputes create explicit corrections via `correctionOfId`.
|
|
117
|
+
- **SupportCharge** / **SupportCompensation** (`support_charges` /
|
|
118
|
+
`support_compensations`, one per time entry) — derived commercial
|
|
119
|
+
snapshots: client amount from the Managed Support Plan (included-time
|
|
120
|
+
consumption then metered overage) vs provider amount from the Support
|
|
121
|
+
Compensation Plan, each with a frozen `rateSnapshot`. Margin = charge −
|
|
122
|
+
compensation, computed by readers; settlement/invoicing composes at the
|
|
123
|
+
app/accounting boundary (#1925) and is out of scope here.
|
|
124
|
+
|
|
125
|
+
## Services
|
|
126
|
+
|
|
127
|
+
- **SupportCaseService** — the closed write facade: `openCase`,
|
|
128
|
+
`recordInteraction` (idempotent on `sourceKey`; stamps
|
|
129
|
+
`acknowledgedAt`/`firstRespondedAt`; inbound un-parks
|
|
130
|
+
`waiting_on_client`), `transition`, `assign`, `resolve`, `close`,
|
|
131
|
+
`reopen` (preserves prior resolution in the reopen event), `requestHuman`,
|
|
132
|
+
`linkWork`/`recordWorkStatus` (Delivery Handoff), `recordEvent`,
|
|
133
|
+
`getTimeline` (merged interactions + events).
|
|
134
|
+
- **SupportIntakeService** — create-or-join intake for both channels:
|
|
135
|
+
`ingestChatMessage` (bound `ChatRoom`; `chat:<roomId>[:<threadId>]` thread
|
|
136
|
+
keys; only `role: 'user'` messages), `ingestEmail` (bound `EmailAccount`;
|
|
137
|
+
RFC-thread joins via `inReplyTo`; `selfAddresses` skip; unresolved senders
|
|
138
|
+
park the case with `metadata.unresolvedClient`), plus
|
|
139
|
+
`registerSupportIntake()` — an opt-in `GlobalInterceptors.afterSave`
|
|
140
|
+
observer keyed on the `ChatMessage`/`Email` class names that never throws
|
|
141
|
+
into the source package's save path. Join semantics: open case → join;
|
|
142
|
+
resolved → reopen; closed → new case.
|
|
143
|
+
- **SupportAiWorkflow** — the Automated Support Response (FR-28a):
|
|
144
|
+
`processIntake`/`processCase` run acknowledge → classify → answer →
|
|
145
|
+
resolve under the resolved `SupportPolicy` (conservative defaults), each
|
|
146
|
+
phase writing a `SupportAiRun` + `ai_run` case event. AI calls go through
|
|
147
|
+
the injected `SupportAiBoundary` (default uses `supportCase.do()` with
|
|
148
|
+
defensive JSON parsing that fails toward the human); knowledge comes from
|
|
149
|
+
the pluggable `SupportKnowledgeProvider` (default no-op). Classification
|
|
150
|
+
never overwrites human triage; email answers are drafted
|
|
151
|
+
(`metadata.draft`) unless the policy allows sending. Handoff triggers —
|
|
152
|
+
`client_request`, `low_confidence`, `high_severity`, `sensitive`,
|
|
153
|
+
`failed_resolution`, `policy` (attempt budget) — are always active.
|
|
154
|
+
- **HumanHandoffService** — the lossless Human Handoff (FR-28b):
|
|
155
|
+
`handoff` assembles the full context package (case state + compact
|
|
156
|
+
timeline + AI runs) into the `handoff` event, stamps
|
|
157
|
+
`metadata.activeHandoff` for the no-repeat guarantee (repeat triggers are
|
|
158
|
+
deduped events), routes through the injected `assignSpecialist` seam
|
|
159
|
+
(#1929's routing service plugs in; default queues `new` cases to
|
|
160
|
+
`triaged`), and `releaseHandoff` clears the flag.
|
|
161
|
+
- **ServiceTargetEngine** — Service Target clocks (FR-30/31):
|
|
162
|
+
`startTargetsForCase` derives per-severity clocks from the case's
|
|
163
|
+
`planSnapshot` (live plan fallback) with due times computed in covered
|
|
164
|
+
time (`coverage-calendar.ts`: timezone-aware weekly windows + holidays;
|
|
165
|
+
empty coverage = 24×7) and schedules one-shot `_smrt_jobs` escalation jobs
|
|
166
|
+
at `dueAt`; `onInteractionRecorded` satisfies acknowledgement/response and
|
|
167
|
+
recurs `update` cycles; `onCaseTransition` pauses/resumes clocks only when
|
|
168
|
+
the plan's `pauseStatuses` say so (recomputing remaining covered minutes)
|
|
169
|
+
and settles targets on resolve. Breach → `SupportServiceTarget.
|
|
170
|
+
checkAndEscalate` (background-eligible, at-least-once-safe) marks the
|
|
171
|
+
breach and escalates through the plan's policy steps (notify/reassign,
|
|
172
|
+
delayed follow-up levels), transitioning the case to `escalated`.
|
|
173
|
+
- **SupportPlanAdminService** — the permission-gated write surface for
|
|
174
|
+
commercial terms: create/update/archive for Managed Support Plans and
|
|
175
|
+
Support Compensation Plans, every act behind `support.manage-plans` with
|
|
176
|
+
cross-tenant writes refused (generated CRUD on both models is read-only).
|
|
177
|
+
- **SupportRoutingService** — explainable ranked routing (FR-30):
|
|
178
|
+
`rankSpecialists` hard-filters on active status, effective Project
|
|
179
|
+
Support Qualification, workload cap, and availability windows (specialist
|
|
180
|
+
timezone), then scores preferred-specialist, qualification level, on-call,
|
|
181
|
+
workload headroom, and language (weights in `ROUTING_WEIGHTS`; every
|
|
182
|
+
factor recorded so ineligible specialists show why); `autoAssign` writes
|
|
183
|
+
the assignment with its rationale; `reassign` is gated by
|
|
184
|
+
`support.reassign-case` and refuses cross-tenant principals.
|
|
185
|
+
- **ServiceTimeEntryService** — the ONE recording contract for all four
|
|
186
|
+
entry sources (FR-40): `record` validates duration (explicit or derived
|
|
187
|
+
from the period; `timer` needs both bounds), participant coherence
|
|
188
|
+
(`human` → `participantProfileId`, `agent` → `agentRef`), and the work
|
|
189
|
+
context (case and/or work ref; case entries copy the tenant and append a
|
|
190
|
+
`time_recorded` event); `submit` stamps the submitter.
|
|
191
|
+
- **TimeEntryApprovalService** — the approval gate and only writer of the
|
|
192
|
+
commercial snapshots (FR-36): `approve` resolves the governing terms (case
|
|
193
|
+
`planSnapshot` first, live plan fallback, zero-rate default), gates by
|
|
194
|
+
policy path (`automatic`/`threshold`/`operator`/`client`; operator paths
|
|
195
|
+
behind `support.approve-time-entry`; cross-tenant principals refused), then
|
|
196
|
+
derives the `SupportCharge` (included time first, then overage/on-call) and
|
|
197
|
+
`SupportCompensation` (effective-dated plan) rows; `reject` and `correct`
|
|
198
|
+
(supersede + linked fresh draft via `correctionOfId`) round out the
|
|
199
|
+
lifecycle. Case events carry the charge amount only — compensation never
|
|
200
|
+
leaks case-side.
|
|
201
|
+
|
|
202
|
+
## Permissions
|
|
203
|
+
|
|
204
|
+
Contributed to the runtime catalog on import (the
|
|
205
|
+
`personas.activate-directive` pattern): `support.reassign-case`,
|
|
206
|
+
`support.approve-time-entry`, `support.manage-plans`. Privileged service
|
|
207
|
+
operations take a `SupportPrincipal` (`can(slug)`), built from explicit slugs
|
|
208
|
+
or a `PermissionResolver`.
|
|
209
|
+
|
|
210
|
+
## Svelte UI
|
|
211
|
+
|
|
212
|
+
`@happyvertical/smrt-support/svelte` ships presentational Svelte 5 surfaces:
|
|
213
|
+
`CaseQueue` (priority/status/assignment/channel at a glance, `onselect`),
|
|
214
|
+
`CaseDetail` (header, meta, linked work, merged timeline), `TargetList`
|
|
215
|
+
(Service Target clocks with due/paused/satisfied/breached badges),
|
|
216
|
+
`RoutingRationale` (ranked specialists with eligibility + factor chips and
|
|
217
|
+
an optional reassign action), and `TimeEntryApprovalQueue`
|
|
218
|
+
(date/hours/description/worker/status/amount with
|
|
219
|
+
approve/reject-with-reason actions on submitted rows). Hosts adapt models
|
|
220
|
+
with `toSupportCaseView` / `toCaseTimelineItemView` / `toServiceTargetView`
|
|
221
|
+
/ `toSupportTimeEntryView` — the time-entry view's first eight fields
|
|
222
|
+
deliberately match `smrt-projects`' presentation `TimeEntry` contract.
|
|
223
|
+
Components use `smrt-ui` primitives (`smrtRawPrimitives: "strict"`).
|
|
224
|
+
|
|
225
|
+
## Dependencies
|
|
226
|
+
|
|
227
|
+
Leaf package (nothing depends back on it): `smrt-core`, `smrt-tenancy`,
|
|
228
|
+
`smrt-chat`, `smrt-messages`, `smrt-jobs`, `smrt-users`, `smrt-ui`,
|
|
229
|
+
`@happyvertical/logger`, `@happyvertical/sql`. Profile / smrt-projects /
|
|
230
|
+
subscriptions references are `@crossPackageRef` string ids or plain string
|
|
231
|
+
keys only — no package edge. No inter-`smrt-*` `peerDependencies`.
|
|
232
|
+
|
|
233
|
+
## Validation
|
|
234
|
+
|
|
235
|
+
```sh
|
|
236
|
+
pnpm --filter @happyvertical/smrt-support test
|
|
237
|
+
pnpm --filter @happyvertical/smrt-support typecheck
|
|
238
|
+
pnpm --filter @happyvertical/smrt-support build
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Gotchas
|
|
242
|
+
|
|
243
|
+
- **Writes go through the facades** — the case-side generated routes are
|
|
244
|
+
read-only on purpose; `create`/`update` on them is not a bug to "fix".
|
|
245
|
+
- **`projectId` is an app-defined string** — the consuming app owns the
|
|
246
|
+
Project concept; don't turn it into an FK or a crossPackageRef to
|
|
247
|
+
`smrt-projects:Project` (that class is a provider board, not a client
|
|
248
|
+
initiative).
|
|
249
|
+
- **`SupportCase.threadKey` + `SupportInteraction.sourceKey` carry intake
|
|
250
|
+
correctness** — `sourceKey` is globally unique (`conflictColumns`), so
|
|
251
|
+
replayed transport rows are no-ops; new manual interactions must use a
|
|
252
|
+
fresh `manual:<uuid>` key.
|
|
253
|
+
- **High-volume models avoid the inherited `name` field** (`subject`,
|
|
254
|
+
`displayName`, …) so the default `(slug, context, _meta_type)` unique index
|
|
255
|
+
falls back to id-derived slugs; named config models carry
|
|
256
|
+
`conflictColumns` instead (which replaces that index).
|
|
257
|
+
- **Approved time entries never change** — corrections are new rows linked
|
|
258
|
+
by `correctionOfId`; the original flips to `corrected` with its snapshot
|
|
259
|
+
intact.
|
|
260
|
+
- **Plan edits never rewrite history** — cases keep `planSnapshot`, charges
|
|
261
|
+
and compensation keep `rateSnapshot`.
|
|
262
|
+
- **Create-or-join and included-time consumption serialize in-process** —
|
|
263
|
+
`SupportIntakeService` (per conversation key) and
|
|
264
|
+
`TimeEntryApprovalService` (per case) use a `KeyedMutex`, which covers the
|
|
265
|
+
single-app-process deployment these paths run in. Multi-replica
|
|
266
|
+
deployments must serialize at the app layer (route a conversation's
|
|
267
|
+
intake / a case's approvals through one worker, or add an app-level
|
|
268
|
+
claim) — the framework exposes no cross-adapter transaction primitive at
|
|
269
|
+
this seam. Escalation is additionally idempotent per `(target, level)`,
|
|
270
|
+
so at-least-once job redelivery never stacks duplicate escalations.
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@AGENTS.md
|
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright <2025> <Happy Vertical Corporation>
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"__smrt-register__.d.ts","sourceRoot":"","sources":["../src/__smrt-register__.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from './models/index.js';
|
|
2
|
+
export { APPROVE_TIME_ENTRY_PERMISSION, ensureSupportPermissionsRegistered, MANAGE_PLANS_PERMISSION, REASSIGN_CASE_PERMISSION, registerSupportPermissions, SUPPORT_PERMISSION_DEFS, type SupportPrincipal, supportPrincipalFromPermissions, } from './permissions.js';
|
|
3
|
+
export * from './services/index.js';
|
|
4
|
+
export * from './types.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,wBAAwB,CAAC;AAIhC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EACL,6BAA6B,EAC7B,kCAAkC,EAClC,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC1B,uBAAuB,EACvB,KAAK,gBAAgB,EACrB,+BAA+B,GAChC,MAAM,kBAAkB,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC"}
|