@teamscala/service-boot 0.23.317 → 0.23.319

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.
Files changed (165) hide show
  1. package/package.json +526 -526
  2. package/src/agreement-gate.ts +12 -0
  3. package/src/auth-gate.test.ts +70 -0
  4. package/src/auth-gate.ts +68 -6
  5. package/src/build-client-assets.test.ts +1 -1
  6. package/src/build-client-assets.ts +1 -1
  7. package/src/discover-blocks.ts +1 -1
  8. package/src/fn-routers/index.ts +2 -0
  9. package/src/fn-routers/task-sync-assign.test.ts +123 -8
  10. package/src/fn-routers/task-sync-assign.ts +105 -18
  11. package/src/fn-routers/task-sync-bind.test.ts +18 -18
  12. package/src/fn-routers/task-sync-brief.test.ts +65 -22
  13. package/src/fn-routers/task-sync-brief.ts +77 -23
  14. package/src/fn-routers/task-sync-close.test.ts +44 -0
  15. package/src/fn-routers/task-sync-close.ts +82 -0
  16. package/src/fn-routers/task-sync-dispatch.test.ts +51 -33
  17. package/src/fn-routers/task-sync-hook-lifecycle.test.ts +204 -0
  18. package/src/fn-routers/task-sync-lane.test.ts +36 -0
  19. package/src/fn-routers/task-sync-projection.test.ts +26 -0
  20. package/src/fn-routers/task-sync-projection.ts +51 -0
  21. package/src/fn-routers/task-sync-rename.test.ts +53 -0
  22. package/src/fn-routers/task-sync-rename.ts +111 -0
  23. package/src/fn-routers/task-sync-router.test.ts +14 -2
  24. package/src/handlers/singleton-tools-currency-watch.ts +114 -11
  25. package/src/handlers/sweep-host-cache.test.ts +133 -0
  26. package/src/handlers/sweep-host-cache.ts +143 -26
  27. package/src/install-logging.ts +3 -0
  28. package/src/mount-orpc-router.ts +1 -1
  29. package/src/register-api-routes.ts +8 -2
  30. package/src/register-page-routes.ts +0 -3
  31. package/src/resolve-brand-favicon.ts +1 -1
  32. package/src/resource-not-found.ts +10 -0
  33. package/src/serve/stamp-transport-identity.test.ts +24 -0
  34. package/src/serve/stamp-transport-identity.ts +20 -7
  35. package/src/two-phase-boot.ts +85 -17
  36. package/src/two-phase-health-gate-client-only.test.ts +77 -0
  37. package/src/two-phase-health-gate.test.ts +13 -2
  38. package/src/agreement-gate.d.ts +0 -19
  39. package/src/asset-cache-key.d.ts +0 -11
  40. package/src/asset-optimize.d.ts +0 -17
  41. package/src/asset-proxy.d.ts +0 -11
  42. package/src/asset-social-card.d.ts +0 -17
  43. package/src/attach-agreement-magic.d.ts +0 -20
  44. package/src/attach-portal-members.d.ts +0 -23
  45. package/src/attach-proposal-accept.d.ts +0 -26
  46. package/src/attach-proposal-magic.d.ts +0 -18
  47. package/src/attach-transfers-upload.d.ts +0 -27
  48. package/src/auth-gate.d.ts +0 -28
  49. package/src/bind-page-handler.d.ts +0 -18
  50. package/src/build-client-assets/input-hashing.d.ts +0 -25
  51. package/src/build-client-assets/source-candidates.d.ts +0 -27
  52. package/src/build-client-assets.d.ts +0 -50
  53. package/src/compose-page-title.d.ts +0 -41
  54. package/src/content-gate/access.d.ts +0 -15
  55. package/src/content-gate/config-types.d.ts +0 -99
  56. package/src/content-gate/gate.d.ts +0 -13
  57. package/src/content-gate/parse-cookie.d.ts +0 -9
  58. package/src/content-gate/token.d.ts +0 -48
  59. package/src/content-page-floor.d.ts +0 -39
  60. package/src/discover-blocks.d.ts +0 -28
  61. package/src/expand-roster.d.ts +0 -34
  62. package/src/fn-routers/agreement-completion-email.d.ts +0 -14
  63. package/src/fn-routers/agreement-send-router.d.ts +0 -82
  64. package/src/fn-routers/ai-health-router.d.ts +0 -35
  65. package/src/fn-routers/auth-router.d.ts +0 -47
  66. package/src/fn-routers/cache-admin-router.d.ts +0 -57
  67. package/src/fn-routers/chat-session-router.d.ts +0 -219
  68. package/src/fn-routers/email-defaults.d.ts +0 -1
  69. package/src/fn-routers/email-link-ttl.d.ts +0 -1
  70. package/src/fn-routers/index.d.ts +0 -18
  71. package/src/fn-routers/panel-data-router.d.ts +0 -19
  72. package/src/fn-routers/persist-chat-messages.d.ts +0 -36
  73. package/src/fn-routers/plans-router.d.ts +0 -25
  74. package/src/fn-routers/proposal-send-router.d.ts +0 -58
  75. package/src/fn-routers/public-agreement-router.d.ts +0 -289
  76. package/src/fn-routers/public-assessment-router.d.ts +0 -68
  77. package/src/fn-routers/public-gpt-session-router.d.ts +0 -143
  78. package/src/fn-routers/sign-in-flow-router.d.ts +0 -107
  79. package/src/fn-routers/task-sync-assign.d.ts +0 -276
  80. package/src/fn-routers/task-sync-brief.d.ts +0 -69
  81. package/src/fn-routers/task-sync-dispatch.d.ts +0 -61
  82. package/src/fn-routers/task-sync-dispatch.ts +0 -124
  83. package/src/fn-routers/task-sync-lane.d.ts +0 -28
  84. package/src/fn-routers/task-sync-lane.ts +0 -91
  85. package/src/fn-routers/task-sync-projection.d.ts +0 -121
  86. package/src/fn-routers/task-sync-router.d.ts +0 -375
  87. package/src/fn-routers/task-sync-router.ts +0 -1011
  88. package/src/fn-routers/tasks-router.d.ts +0 -25
  89. package/src/fn-routers/user-preferences-router.d.ts +0 -77
  90. package/src/fn-routers/work-items-router.d.ts +0 -102
  91. package/src/gate-ttls.d.ts +0 -6
  92. package/src/gpt-gate.d.ts +0 -25
  93. package/src/handlers/bun-stable-watch.d.ts +0 -1
  94. package/src/handlers/pane-outbox-drain.d.ts +0 -1
  95. package/src/handlers/projects-digest.d.ts +0 -26
  96. package/src/handlers/prune-stale-data.d.ts +0 -30
  97. package/src/handlers/registry-stale-inactive-sweep.d.ts +0 -1
  98. package/src/handlers/scala-tools-currency-watch.d.ts +0 -1
  99. package/src/handlers/singleton-tools-currency-watch.d.ts +0 -1
  100. package/src/handlers/sweep-event-log.d.ts +0 -1
  101. package/src/handlers/sweep-host-cache.d.ts +0 -1
  102. package/src/handlers/upstream-issue-sync.d.ts +0 -1
  103. package/src/handlers/whatsapp-liveness-logic.d.ts +0 -34
  104. package/src/handlers/whatsapp-liveness.d.ts +0 -4
  105. package/src/hono-error-handler.d.ts +0 -25
  106. package/src/install-harness.d.ts +0 -45
  107. package/src/install-logging.d.ts +0 -34
  108. package/src/load-service-install-row.d.ts +0 -24
  109. package/src/load-service-prisma-client.d.ts +0 -18
  110. package/src/mount-orpc-router.d.ts +0 -15
  111. package/src/mount-server-packages.d.ts +0 -29
  112. package/src/mount.d.ts +0 -9
  113. package/src/mutable-app-ref.d.ts +0 -44
  114. package/src/page-route-shell-types.d.ts +0 -12
  115. package/src/page-server-orpc/audit-revert-router.d.ts +0 -37
  116. package/src/page-server-orpc/hub-mcp-client.d.ts +0 -12
  117. package/src/page-server-orpc/portal-diagnostics-router.d.ts +0 -49
  118. package/src/page-server-orpc/puck-pages-router.d.ts +0 -58
  119. package/src/page-server-orpc/server-client.d.ts +0 -16
  120. package/src/page-server-orpc/templates-router.d.ts +0 -34
  121. package/src/page-server-orpc/user-preferences-router.d.ts +0 -79
  122. package/src/pg-boss-handler-registry.d.ts +0 -27
  123. package/src/pg-boss-mount.d.ts +0 -42
  124. package/src/proposal-authorized-emails.d.ts +0 -28
  125. package/src/proposal-chat-inject.d.ts +0 -17
  126. package/src/proposal-gate.d.ts +0 -18
  127. package/src/read-html-template.d.ts +0 -38
  128. package/src/read-viewport-from-request.d.ts +0 -18
  129. package/src/readiness-gate.d.ts +0 -16
  130. package/src/register-api-routes.d.ts +0 -18
  131. package/src/register-crash-handlers.d.ts +0 -15
  132. package/src/register-page-routes.d.ts +0 -27
  133. package/src/register-page-server-client.d.ts +0 -11
  134. package/src/register-registry-page-route/ai-chat-prefetch.d.ts +0 -13
  135. package/src/register-registry-page-route/graph-cache.d.ts +0 -30
  136. package/src/register-registry-page-route/meta-title.d.ts +0 -2
  137. package/src/register-registry-page-route/proposal-approval-email-token.d.ts +0 -14
  138. package/src/register-registry-page-route/proposal-brand-stamping.d.ts +0 -28
  139. package/src/register-registry-page-route/resolve-page-data.d.ts +0 -1
  140. package/src/register-registry-page-route.d.ts +0 -27
  141. package/src/register-static-assets.d.ts +0 -13
  142. package/src/register-ws-routes.d.ts +0 -28
  143. package/src/resolve-app-base-url.d.ts +0 -13
  144. package/src/resolve-brand-favicon.d.ts +0 -28
  145. package/src/resolve-from-loader-config.d.ts +0 -32
  146. package/src/resolve-service-context.d.ts +0 -17
  147. package/src/resolve-service-port.d.ts +0 -75
  148. package/src/resolve-theme-mode.d.ts +0 -42
  149. package/src/resolvers/fetch-org-brand.d.ts +0 -2
  150. package/src/resolvers/portal-route-paths.d.ts +0 -39
  151. package/src/resolvers/website-by-host-map.d.ts +0 -12
  152. package/src/resource-chat-inject.d.ts +0 -46
  153. package/src/resource-not-found.d.ts +0 -60
  154. package/src/run-boot-hook-list.d.ts +0 -19
  155. package/src/run-boot-hooks.d.ts +0 -31
  156. package/src/scala-tools-currency-watchdog.d.ts +0 -10
  157. package/src/security-headers.d.ts +0 -12
  158. package/src/serve/serve.d.ts +0 -46
  159. package/src/serve/stamp-transport-identity.d.ts +0 -32
  160. package/src/server-error-page.d.ts +0 -29
  161. package/src/start-scheduled-jobs.d.ts +0 -18
  162. package/src/two-phase-boot.d.ts +0 -136
  163. package/src/types.d.ts +0 -46
  164. package/src/ui-service.d.ts +0 -46
  165. package/src/ws-boot-self-test.d.ts +0 -19
@@ -1,219 +0,0 @@
1
- /**
2
- * @system service-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- *
6
- * ORPC procedures for the AUTHENTICATED AI-chat conversation lifecycle —
7
- * the org+user-keyed sibling of publicGptSessionRouter (which is contact-
8
- * linked for anonymous public GPT visitors). One signed-in user chatting
9
- * with one agent in one org owns a thread of `conversations` rows; this
10
- * router createOrRestore-s the active one, saves turns, archives+news on
11
- * clear, lists past threads, and loads a specific thread.
12
- *
13
- * Identity: the USER is resolved from the ORPC session context (`authed`
14
- * middleware → `context.user.id`); the ORGANISATION is supplied by the
15
- * client (it is the URL :orgId for org-scoped apps like scala-projects —
16
- * the session does not carry it) and VERIFIED — the caller must be a
17
- * member of that organisation, else FORBIDDEN. A caller cannot read or
18
- * write another user's threads (ownership is user_id) or another org's
19
- * (createOrRestore/list are membership-scoped to the supplied org).
20
- *
21
- * This restores the capability the portal AI chat lost when the June
22
- * chat-engine migration severed `usePortalConversationId` + the
23
- * `portalConversation` router (capability-named `chatSession` here per
24
- * name-by-capability; the host-named orphan was deleted in the same change).
25
- *
26
- * Persistence model: the chat client owns writes via onMessagesPersist →
27
- * saveMessages, and sends clientPersists:true so handle-chat-stream skips its
28
- * own persistChatRun (single writer, no double-persist). Verbatim UIMessage
29
- * parts are stored in messages.channel_data.parts so multi-step (tool-using)
30
- * turns round-trip losslessly (apps/chat.md messages-stored-as-uimessage-verbatim).
31
- */
32
- import * as v from "valibot";
33
- import { type Context } from "./auth-router.ts";
34
- export declare const chatSessionRouter: {
35
- createOrRestore: import("@orpc/server").DecoratedProcedure<import("@orpc/server").MergedInitialContext<Context & Record<never, never>, Context, Context>, import("@orpc/server").MergedCurrentContext<Context, {
36
- headers: Headers;
37
- resolveUser?: (headers: Headers, prisma: any) => Promise<import("./auth-router.ts").User | null>;
38
- prisma: any;
39
- user: import("./auth-router.ts").User;
40
- orgId: string | null | undefined;
41
- }>, v.ObjectSchema<{
42
- readonly agentId: v.StringSchema<undefined>;
43
- readonly organisationId: v.StringSchema<undefined>;
44
- /**
45
- * SSR-only: the real user's id, passed by the AiChat serverLoader. The
46
- * in-process server client is system-authed (context.user.id === "system"),
47
- * so without this the conversation is created under user_id="system" and
48
- * the real user's saveMessages hits assertOwns → FORBIDDEN. Only honoured
49
- * when the caller is the system user (server-side SSR), never from a
50
- * client-side ORPC call.
51
- */
52
- readonly userId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
53
- }, undefined>, import("@orpc/contract").Schema<{
54
- conversationId: any;
55
- model: any;
56
- messages: {
57
- id: any;
58
- role: any;
59
- content: any;
60
- parts: unknown[] | undefined;
61
- metadata: Record<string, unknown> | undefined;
62
- created_at: any;
63
- occurred_at: any;
64
- }[];
65
- tokenTotals: {
66
- inputTokens: number;
67
- outputTokens: number;
68
- };
69
- hasMore: boolean;
70
- }, {
71
- conversationId: any;
72
- model: any;
73
- messages: {
74
- id: any;
75
- role: any;
76
- content: any;
77
- parts: unknown[] | undefined;
78
- metadata: Record<string, unknown> | undefined;
79
- created_at: any;
80
- occurred_at: any;
81
- }[];
82
- tokenTotals: {
83
- inputTokens: number;
84
- outputTokens: number;
85
- };
86
- hasMore: boolean;
87
- }>, Record<never, never>, Record<never, never>>;
88
- loadEarlier: import("@orpc/server").DecoratedProcedure<import("@orpc/server").MergedInitialContext<Context & Record<never, never>, Context, Context>, import("@orpc/server").MergedCurrentContext<Context, {
89
- headers: Headers;
90
- resolveUser?: (headers: Headers, prisma: any) => Promise<import("./auth-router.ts").User | null>;
91
- prisma: any;
92
- user: import("./auth-router.ts").User;
93
- orgId: string | null | undefined;
94
- }>, v.ObjectSchema<{
95
- readonly conversationId: v.StringSchema<undefined>;
96
- /** Cursor: the occurred_at (ISO) of the oldest currently-loaded message. */
97
- readonly before: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, undefined>]>;
98
- /** Cap; defaults to RECENT_MESSAGE_LIMIT, clamped to it. */
99
- readonly limit: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
100
- }, undefined>, import("@orpc/contract").Schema<{
101
- messages: {
102
- id: any;
103
- role: any;
104
- content: any;
105
- parts: unknown[] | undefined;
106
- metadata: Record<string, unknown> | undefined;
107
- created_at: any;
108
- occurred_at: any;
109
- }[];
110
- hasMore: boolean;
111
- }, {
112
- messages: {
113
- id: any;
114
- role: any;
115
- content: any;
116
- parts: unknown[] | undefined;
117
- metadata: Record<string, unknown> | undefined;
118
- created_at: any;
119
- occurred_at: any;
120
- }[];
121
- hasMore: boolean;
122
- }>, Record<never, never>, Record<never, never>>;
123
- saveMessages: import("@orpc/server").DecoratedProcedure<import("@orpc/server").MergedInitialContext<Context & Record<never, never>, Context, Context>, import("@orpc/server").MergedCurrentContext<Context, {
124
- headers: Headers;
125
- resolveUser?: (headers: Headers, prisma: any) => Promise<import("./auth-router.ts").User | null>;
126
- prisma: any;
127
- user: import("./auth-router.ts").User;
128
- orgId: string | null | undefined;
129
- }>, v.ObjectSchema<{
130
- readonly conversationId: v.StringSchema<undefined>;
131
- readonly messages: v.ArraySchema<v.ObjectSchema<{
132
- readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
133
- readonly role: v.StringSchema<undefined>;
134
- readonly content: v.StringSchema<undefined>;
135
- readonly parts: v.OptionalSchema<v.ArraySchema<v.AnySchema, undefined>, undefined>;
136
- readonly metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.AnySchema, undefined>, undefined>;
137
- }, undefined>, undefined>;
138
- }, undefined>, import("@orpc/contract").Schema<{
139
- success: boolean;
140
- }, {
141
- success: boolean;
142
- }>, Record<never, never>, Record<never, never>>;
143
- clear: import("@orpc/server").DecoratedProcedure<import("@orpc/server").MergedInitialContext<Context & Record<never, never>, Context, Context>, import("@orpc/server").MergedCurrentContext<Context, {
144
- headers: Headers;
145
- resolveUser?: (headers: Headers, prisma: any) => Promise<import("./auth-router.ts").User | null>;
146
- prisma: any;
147
- user: import("./auth-router.ts").User;
148
- orgId: string | null | undefined;
149
- }>, v.ObjectSchema<{
150
- readonly conversationId: v.StringSchema<undefined>;
151
- }, undefined>, import("@orpc/contract").Schema<{
152
- conversationId: any;
153
- messages: never[];
154
- tokenTotals: {
155
- inputTokens: number;
156
- outputTokens: number;
157
- };
158
- }, {
159
- conversationId: any;
160
- messages: never[];
161
- tokenTotals: {
162
- inputTokens: number;
163
- outputTokens: number;
164
- };
165
- }>, Record<never, never>, Record<never, never>>;
166
- list: import("@orpc/server").DecoratedProcedure<import("@orpc/server").MergedInitialContext<Context & Record<never, never>, Context, Context>, import("@orpc/server").MergedCurrentContext<Context, {
167
- headers: Headers;
168
- resolveUser?: (headers: Headers, prisma: any) => Promise<import("./auth-router.ts").User | null>;
169
- prisma: any;
170
- user: import("./auth-router.ts").User;
171
- orgId: string | null | undefined;
172
- }>, v.ObjectSchema<{
173
- readonly agentId: v.StringSchema<undefined>;
174
- readonly organisationId: v.StringSchema<undefined>;
175
- }, undefined>, import("@orpc/contract").Schema<{
176
- conversations: any;
177
- }, {
178
- conversations: any;
179
- }>, Record<never, never>, Record<never, never>>;
180
- load: import("@orpc/server").DecoratedProcedure<import("@orpc/server").MergedInitialContext<Context & Record<never, never>, Context, Context>, import("@orpc/server").MergedCurrentContext<Context, {
181
- headers: Headers;
182
- resolveUser?: (headers: Headers, prisma: any) => Promise<import("./auth-router.ts").User | null>;
183
- prisma: any;
184
- user: import("./auth-router.ts").User;
185
- orgId: string | null | undefined;
186
- }>, v.ObjectSchema<{
187
- readonly conversationId: v.StringSchema<undefined>;
188
- }, undefined>, import("@orpc/contract").Schema<{
189
- conversationId: any;
190
- messages: {
191
- id: any;
192
- role: any;
193
- content: any;
194
- parts: unknown[] | undefined;
195
- metadata: Record<string, unknown> | undefined;
196
- created_at: any;
197
- occurred_at: any;
198
- }[];
199
- tokenTotals: {
200
- inputTokens: number;
201
- outputTokens: number;
202
- };
203
- }, {
204
- conversationId: any;
205
- messages: {
206
- id: any;
207
- role: any;
208
- content: any;
209
- parts: unknown[] | undefined;
210
- metadata: Record<string, unknown> | undefined;
211
- created_at: any;
212
- occurred_at: any;
213
- }[];
214
- tokenTotals: {
215
- inputTokens: number;
216
- outputTokens: number;
217
- };
218
- }>, Record<never, never>, Record<never, never>>;
219
- };
@@ -1 +0,0 @@
1
- export declare function getDefaultEmailSender(): Promise<string>;
@@ -1 +0,0 @@
1
- export declare function getEmailLinkTtlMs(): Promise<number>;
@@ -1,18 +0,0 @@
1
- /**
2
- * @system service-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- *
6
- * Composes auth, tasks, work-items, plans, chat-session, public-gpt-session,
7
- * public-agreement, and user-preferences routers into the `fn` namespace and
8
- * registers it via registerCustomRouter.
9
- * Called at boot by registerFnRouters() — invoked before any ORPC dispatch.
10
- *
11
- * Also exposes the `regions` namespace on the client /api/rpc mount: a single
12
- * `loadPage` procedure (reusing puckPagesRouter.loadFromWebsite) so a client
13
- * RegionPageSwap can fetch a region's Puck page on demand and render it into a
14
- * slot — the no-reload half of `region-views-are-pages` (every region is a Puck
15
- * page; switching a view loads a different page's content). loadById is NOT
16
- * exposed (website+path is the client-facing contract, not raw page ids).
17
- */
18
- export declare function registerFnRouters(): void;
@@ -1,19 +0,0 @@
1
- import * as v from "valibot";
2
- interface Context {
3
- prisma: {
4
- builda_websites: {
5
- findFirst: (args: unknown) => Promise<{
6
- organisation_id?: string | null;
7
- } | null>;
8
- };
9
- };
10
- }
11
- export declare const resolvePanelDataHandler: import("@orpc/server").DecoratedProcedure<Context & Record<never, never>, Context, v.ObjectSchema<{
12
- readonly panelSlug: v.StringSchema<undefined>;
13
- readonly websiteSlug: v.StringSchema<undefined>;
14
- /** Tenant orgId (preferred over the website's organisation_id, which is
15
- * the platform org on a multi-tenant portal — not the tenant). The
16
- * caller (RegionPageSwap) threads this from __PAGE_DATA__.orgId. */
17
- readonly orgId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
18
- }, undefined>, import("@orpc/contract").Schema<Record<string, unknown> | null, Record<string, unknown> | null>, Record<never, never>, Record<never, never>>;
19
- export {};
@@ -1,36 +0,0 @@
1
- /**
2
- * @system service-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- *
6
- * The ONE chat-message write surface for the session routers. Both the authed
7
- * (chatSession) and public (publicGptSession) saveMessages procedures persist
8
- * turns through here — they differ only in IDENTITY/ownership (user_id vs
9
- * contact_email, resolved in the router before calling this), never in the
10
- * write itself. Keeping the write in two routers was literal duplication
11
- * (no-duplicate-canonical-units) and is why the stable-id fix had to be applied
12
- * twice.
13
- *
14
- * Upserts each message on its SDK UIMessage id so a re-save of a turn (a retry,
15
- * a reconnect after a network drop, or a stray dual-write) updates the one row
16
- * in place instead of inserting a duplicate (chat-message-ids-server-stable);
17
- * falls back to create only for legacy id-less callers. occurred_at is stamped
18
- * with a 1ms step preserving array order so same-second saves restore in order.
19
- */
20
- export interface ChatMessageInput {
21
- id?: string;
22
- role: string;
23
- content: string;
24
- parts?: unknown[];
25
- /** The SDK UIMessage `metadata` — carries per-message token usage
26
- * (`inputTokens`/`outputTokens`/`contextWindow`/`model`) the stream attaches
27
- * via `messageMetadata`. Persisted so the context-usage gauge can rehydrate
28
- * on reload and budget-enforcement can read per-message token counts; without
29
- * it the save dropped the usage and the gauge came back blank on refresh. */
30
- metadata?: Record<string, unknown> | null;
31
- }
32
- export declare function persistChatMessages(prisma: any, opts: {
33
- conversationId: string;
34
- organisationId: string | null;
35
- messages: ChatMessageInput[];
36
- }): Promise<void>;
@@ -1,25 +0,0 @@
1
- /**
2
- * @system service-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- *
6
- * ORPC procedures for plan creation with tasks and subtasks.
7
- * Extracted from @teamscala/orpc/fn-router — primitives tier must not
8
- * contain application-specific work_items logic.
9
- */
10
- import { type Context } from "./auth-router.ts";
11
- export declare const plansRouter: {
12
- save: import("@orpc/server").DecoratedProcedure<import("@orpc/server").MergedInitialContext<Context & Record<never, never>, Context, Context>, import("@orpc/server").MergedCurrentContext<Context, {
13
- headers: Headers;
14
- resolveUser?: (headers: Headers, prisma: any) => Promise<import("./auth-router.ts").User | null>;
15
- prisma: any;
16
- user: import("./auth-router.ts").User;
17
- orgId: string | null | undefined;
18
- }>, import("@orpc/contract").Schema<unknown, unknown>, import("@orpc/contract").Schema<{
19
- success: boolean;
20
- data: any;
21
- }, {
22
- success: boolean;
23
- data: any;
24
- }>, Record<never, never>, Record<never, never>>;
25
- };
@@ -1,58 +0,0 @@
1
- /**
2
- * @system service-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- *
6
- * The proposal SEND router — the proposal twin of agreement-send-router. An
7
- * authed portal caller POSTs {proposalId, baseUrl} to email the proposal's CRM
8
- * contact a per-recipient magic-link (no email gate, no OTP — see
9
- * attach-proposal-magic.ts) to view their proposal. Resend-backed.
10
- */
11
- import * as v from "valibot";
12
- interface User {
13
- id: string;
14
- organisationId: string | null;
15
- }
16
- interface Context {
17
- user: User | null | undefined;
18
- headers: Headers;
19
- resolveUser?: (headers: Headers, prisma: any) => Promise<User | null>;
20
- prisma: any;
21
- }
22
- export declare const proposalSendRouter: {
23
- send: import("@orpc/server").DecoratedProcedure<import("@orpc/server").MergedInitialContext<Context & Record<never, never>, Context, Context>, import("@orpc/server").MergedCurrentContext<Context, {
24
- headers: Headers;
25
- resolveUser?: (headers: Headers, prisma: any) => Promise<User | null>;
26
- prisma: any;
27
- user: User;
28
- }>, v.ObjectSchema<{
29
- readonly proposalId: v.StringSchema<undefined>;
30
- /** Public base URL of the proposals site, e.g. https://proposals-dev.scala.business (no trailing slash). */
31
- readonly baseUrl: v.StringSchema<undefined>;
32
- }, undefined>, import("@orpc/contract").Schema<{
33
- ok: false;
34
- error: string;
35
- sentAt?: undefined;
36
- url?: undefined;
37
- email?: undefined;
38
- } | {
39
- error?: undefined;
40
- ok: true;
41
- sentAt: string;
42
- url: string;
43
- email: string;
44
- }, {
45
- ok: false;
46
- error: string;
47
- sentAt?: undefined;
48
- url?: undefined;
49
- email?: undefined;
50
- } | {
51
- error?: undefined;
52
- ok: true;
53
- sentAt: string;
54
- url: string;
55
- email: string;
56
- }>, Record<never, never>, Record<never, never>>;
57
- };
58
- export {};
@@ -1,289 +0,0 @@
1
- /**
2
- * @system service-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- *
6
- * Public ORPC procedures for DocuSign-style agreement signing, reached by the
7
- * sign-in block's in-document signing blocks over the public HTTP transport
8
- * (getOrpcClient().fn.publicAgreement.*). The unguessable agreement id plus an
9
- * email that matches one of the agreement's parties IS the gate (no password).
10
- *
11
- * This is the off-the-shelf path per building-applications: server logic beyond
12
- * CRUD is a typed ORPC procedure (the publicAssessment/publicGptSession shape),
13
- * NOT a hand-written /api/data/* Hono handler and NOT a loopback fetch to the
14
- * service's own ORPC. Writes go through context.prisma inside the handler — the
15
- * sanctioned in-handler DB access (orpc-is-the-only-api) — so the audit trigger
16
- * sees the ORPC caller context, the same proven path publicGptSession uses.
17
- *
18
- * Multi-party model: signature_data holds a parties roster (JSON) so one
19
- * agreement can require signatures from several parties (e.g. Provider + Client)
20
- * with no schema change. Each party is gated by its own email; the agreement
21
- * completes (signed_at set) only when every party has signed. A single-signer
22
- * agreement falls back to the original signer_email/signer_name columns.
23
- */
24
- import * as v from "valibot";
25
- /** The Certificate of Completion display copy. DB-driven via the
26
- * `config/certificate-of-completion` registry row — mirrors the agreement gate's
27
- * `config/content-gate-agreement` pattern (same signing surface), so an operator
28
- * can rebrand/reword the certificate via `registry_edit` with no deploy; the
29
- * hardcoded defaults are the fallback. Generic structural data-column labels
30
- * (Signer/Role/Envelope ID/…) stay in the component, exactly as the gate keeps
31
- * its structural markup in code. */
32
- export interface CertificateCopy {
33
- title: string;
34
- signersHeading: string;
35
- sealHeading: string;
36
- sealNote: string;
37
- footer: string;
38
- badgeCompleted: string;
39
- badgeInProgress: string;
40
- /** Audit-table column labels — DB-driven so rewording is a registry_edit.
41
- * Each labels BOTH the <th> header AND the stacked-row data-label on mobile
42
- * (one source, kept in sync), never a second hardcoded copy. */
43
- colSigner: string;
44
- colRole: string;
45
- colSigned: string;
46
- colIp: string;
47
- colAuth: string;
48
- }
49
- /** The Certificate of Completion data shape — the court-style audit certificate.
50
- * One home: {@link buildCertificateData} is consumed by both the
51
- * `publicAgreement.certificate` ORPC and the SSR agreement gate, so the signing
52
- * block receives identical data whether it reads the ORPC response or the
53
- * server-seeded prop. */
54
- export interface CertificateData {
55
- ok: boolean;
56
- envelopeId?: string;
57
- documentName?: string | null;
58
- issuedAt?: string;
59
- complete?: boolean;
60
- createdAt?: string | null;
61
- sentAt?: string | null;
62
- viewedAt?: string | null;
63
- signedAt?: string | null;
64
- documentHash?: string | null;
65
- hashAlgo?: string | null;
66
- hashedAt?: string | null;
67
- parties?: {
68
- role: string;
69
- name: string | null;
70
- email: string | null;
71
- title: string | null;
72
- company: string | null;
73
- signedAt: string | null;
74
- ip: string | null;
75
- userAgent: string | null;
76
- authMethod: string | null;
77
- }[];
78
- /** DB-driven display copy (config/certificate-of-completion); null when the
79
- * config row is missing/broken — the component falls back to FALLBACK_COPY. */
80
- copy?: CertificateCopy | null;
81
- }
82
- /**
83
- * Build the Certificate of Completion data for an agreement, gated to a party
84
- * email — signer evidence (IP/device) is never exposed to a non-party. One data
85
- * home: the `publicAgreement.certificate` ORPC and the SSR agreement gate
86
- * (`buildSigningSession` in agreement-gate.ts) both call this. The read is
87
- * intentionally RLS-unscoped via the raw registry prisma — the certificate is
88
- * reached without a session (AG cookie only), which context.prisma's RLS would
89
- * otherwise treat as no-org and hide. Accepts either the agreement record id or
90
- * its page id (the UUID the signer sees in the URL is the page id).
91
- */
92
- export declare function buildCertificateData(agreementId: string, email: string): Promise<CertificateData>;
93
- interface Context {
94
- prisma: any;
95
- headers: Headers;
96
- resolveUser?: (headers: Headers, prisma: any) => Promise<any>;
97
- }
98
- export declare const publicAgreementRouter: {
99
- verify: import("@orpc/server").DecoratedProcedure<Context & Record<never, never>, Context, v.ObjectSchema<{
100
- readonly agreementId: v.StringSchema<undefined>;
101
- readonly email: v.StringSchema<undefined>;
102
- }, undefined>, import("@orpc/contract").Schema<{
103
- matched: false;
104
- multiParty?: undefined;
105
- role?: undefined;
106
- partySignedAt?: undefined;
107
- allSigned?: undefined;
108
- parties?: undefined;
109
- name?: undefined;
110
- signerName?: undefined;
111
- signedAt?: undefined;
112
- accessToken?: undefined;
113
- } | {
114
- matched: boolean;
115
- multiParty: boolean;
116
- name: any;
117
- role: string;
118
- signerName: string;
119
- partySignedAt: string | null;
120
- allSigned: boolean;
121
- parties: import("@teamscala/document-signing/agreement-parties").PublicAgreementParty[];
122
- accessToken: string | null;
123
- signedAt?: undefined;
124
- } | {
125
- multiParty?: undefined;
126
- role?: undefined;
127
- partySignedAt?: undefined;
128
- allSigned?: undefined;
129
- parties?: undefined;
130
- matched: boolean;
131
- name: any;
132
- signerName: any;
133
- signedAt: any;
134
- accessToken: string | null;
135
- }, {
136
- matched: false;
137
- multiParty?: undefined;
138
- role?: undefined;
139
- partySignedAt?: undefined;
140
- allSigned?: undefined;
141
- parties?: undefined;
142
- name?: undefined;
143
- signerName?: undefined;
144
- signedAt?: undefined;
145
- accessToken?: undefined;
146
- } | {
147
- matched: boolean;
148
- multiParty: boolean;
149
- name: any;
150
- role: string;
151
- signerName: string;
152
- partySignedAt: string | null;
153
- allSigned: boolean;
154
- parties: import("@teamscala/document-signing/agreement-parties").PublicAgreementParty[];
155
- accessToken: string | null;
156
- signedAt?: undefined;
157
- } | {
158
- multiParty?: undefined;
159
- role?: undefined;
160
- partySignedAt?: undefined;
161
- allSigned?: undefined;
162
- parties?: undefined;
163
- matched: boolean;
164
- name: any;
165
- signerName: any;
166
- signedAt: any;
167
- accessToken: string | null;
168
- }>, Record<never, never>, Record<never, never>>;
169
- sign: import("@orpc/server").DecoratedProcedure<Context & Record<never, never>, Context, v.ObjectSchema<{
170
- readonly agreementId: v.StringSchema<undefined>;
171
- readonly email: v.StringSchema<undefined>;
172
- readonly signatureData: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
173
- readonly signerName: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
174
- readonly title: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
175
- readonly company: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
176
- }, undefined>, import("@orpc/contract").Schema<{
177
- signerName?: undefined;
178
- signedAt?: undefined;
179
- ok: false;
180
- error: string;
181
- alreadySigned?: undefined;
182
- payUrl?: undefined;
183
- } | {
184
- ok: true;
185
- role: string;
186
- signedAt: string;
187
- allSigned: boolean;
188
- parties: import("@teamscala/document-signing/agreement-parties").PublicAgreementParty[];
189
- payUrl: string | null;
190
- } | {
191
- error?: undefined;
192
- ok: true;
193
- alreadySigned: boolean;
194
- signedAt: any;
195
- signerName: any;
196
- payUrl?: undefined;
197
- } | {
198
- error?: undefined;
199
- alreadySigned?: undefined;
200
- ok: true;
201
- signedAt: any;
202
- signerName: any;
203
- payUrl: string | null;
204
- }, {
205
- signerName?: undefined;
206
- signedAt?: undefined;
207
- ok: false;
208
- error: string;
209
- alreadySigned?: undefined;
210
- payUrl?: undefined;
211
- } | {
212
- ok: true;
213
- role: string;
214
- signedAt: string;
215
- allSigned: boolean;
216
- parties: import("@teamscala/document-signing/agreement-parties").PublicAgreementParty[];
217
- payUrl: string | null;
218
- } | {
219
- error?: undefined;
220
- ok: true;
221
- alreadySigned: boolean;
222
- signedAt: any;
223
- signerName: any;
224
- payUrl?: undefined;
225
- } | {
226
- error?: undefined;
227
- alreadySigned?: undefined;
228
- ok: true;
229
- signedAt: any;
230
- signerName: any;
231
- payUrl: string | null;
232
- }>, Record<never, never>, Record<never, never>>;
233
- certificate: import("@orpc/server").DecoratedProcedure<Context & Record<never, never>, Context, v.ObjectSchema<{
234
- readonly agreementId: v.StringSchema<undefined>;
235
- readonly email: v.StringSchema<undefined>;
236
- }, undefined>, import("@orpc/contract").Schema<CertificateData, CertificateData>, Record<never, never>, Record<never, never>>;
237
- verifyDocument: import("@orpc/server").DecoratedProcedure<Context & Record<never, never>, Context, v.ObjectSchema<{
238
- readonly agreementId: v.StringSchema<undefined>;
239
- }, undefined>, import("@orpc/contract").Schema<{
240
- parties?: undefined;
241
- signedAt?: undefined;
242
- ok: false;
243
- envelopeId?: undefined;
244
- documentName?: undefined;
245
- complete?: undefined;
246
- sealedHash?: undefined;
247
- recomputedHash?: undefined;
248
- valid?: undefined;
249
- } | {
250
- ok: true;
251
- envelopeId: string;
252
- documentName: string;
253
- complete: boolean;
254
- signedAt: string | null;
255
- sealedHash: string | null;
256
- recomputedHash: string | null;
257
- valid: boolean;
258
- parties: {
259
- role: string;
260
- name: string;
261
- signedAt: string | null;
262
- }[];
263
- }, {
264
- parties?: undefined;
265
- signedAt?: undefined;
266
- ok: false;
267
- envelopeId?: undefined;
268
- documentName?: undefined;
269
- complete?: undefined;
270
- sealedHash?: undefined;
271
- recomputedHash?: undefined;
272
- valid?: undefined;
273
- } | {
274
- ok: true;
275
- envelopeId: string;
276
- documentName: string;
277
- complete: boolean;
278
- signedAt: string | null;
279
- sealedHash: string | null;
280
- recomputedHash: string | null;
281
- valid: boolean;
282
- parties: {
283
- role: string;
284
- name: string;
285
- signedAt: string | null;
286
- }[];
287
- }>, Record<never, never>, Record<never, never>>;
288
- };
289
- export {};