@teamscala/service-boot 0.23.345 → 0.23.346

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 (136) hide show
  1. package/package.json +1064 -1093
  2. package/src/two-phase-boot.ts +2 -1
  3. package/src/agreement-gate.d.ts +0 -19
  4. package/src/asset-cache-key.d.ts +0 -11
  5. package/src/asset-optimize.d.ts +0 -17
  6. package/src/asset-proxy.d.ts +0 -11
  7. package/src/asset-social-card.d.ts +0 -17
  8. package/src/attach-agreement-magic.d.ts +0 -20
  9. package/src/attach-portal-members.d.ts +0 -23
  10. package/src/attach-proposal-accept.d.ts +0 -26
  11. package/src/attach-proposal-magic.d.ts +0 -18
  12. package/src/attach-transfers-upload.d.ts +0 -27
  13. package/src/auth-gate.d.ts +0 -29
  14. package/src/bind-page-handler.d.ts +0 -18
  15. package/src/build-client-assets/input-hashing.d.ts +0 -25
  16. package/src/build-client-assets/source-candidates.d.ts +0 -27
  17. package/src/build-client-assets.d.ts +0 -50
  18. package/src/compose-page-title.d.ts +0 -41
  19. package/src/content-gate/access.d.ts +0 -15
  20. package/src/content-gate/config-types.d.ts +0 -99
  21. package/src/content-gate/gate.d.ts +0 -13
  22. package/src/content-gate/parse-cookie.d.ts +0 -9
  23. package/src/content-gate/token.d.ts +0 -48
  24. package/src/content-page-floor.d.ts +0 -39
  25. package/src/discover-blocks.d.ts +0 -28
  26. package/src/expand-roster.d.ts +0 -34
  27. package/src/fn-routers/agreement-completion-email.d.ts +0 -14
  28. package/src/fn-routers/agreement-send-router.d.ts +0 -82
  29. package/src/fn-routers/ai-health-router.d.ts +0 -35
  30. package/src/fn-routers/auth-router.d.ts +0 -47
  31. package/src/fn-routers/cache-admin-router.d.ts +0 -57
  32. package/src/fn-routers/chat-session-router.d.ts +0 -219
  33. package/src/fn-routers/email-defaults.d.ts +0 -1
  34. package/src/fn-routers/email-link-ttl.d.ts +0 -1
  35. package/src/fn-routers/index.d.ts +0 -18
  36. package/src/fn-routers/orchestrator-registration-router.d.ts +0 -60
  37. package/src/fn-routers/orchestrator-registration-router.ts +0 -77
  38. package/src/fn-routers/orchestrator-registration.live.test.ts +0 -70
  39. package/src/fn-routers/orchestrator-registration.test.ts +0 -23
  40. package/src/fn-routers/panel-data-router.d.ts +0 -19
  41. package/src/fn-routers/persist-chat-messages.d.ts +0 -36
  42. package/src/fn-routers/plans-router.d.ts +0 -25
  43. package/src/fn-routers/proposal-send-router.d.ts +0 -58
  44. package/src/fn-routers/public-agreement-router.d.ts +0 -289
  45. package/src/fn-routers/public-assessment-router.d.ts +0 -68
  46. package/src/fn-routers/public-gpt-session-router.d.ts +0 -143
  47. package/src/fn-routers/sign-in-flow-router.d.ts +0 -107
  48. package/src/fn-routers/task-sync-assign.d.ts +0 -307
  49. package/src/fn-routers/task-sync-brief.d.ts +0 -98
  50. package/src/fn-routers/task-sync-close.d.ts +0 -41
  51. package/src/fn-routers/task-sync-dispatch.d.ts +0 -47
  52. package/src/fn-routers/task-sync-dispatch.ts +0 -81
  53. package/src/fn-routers/task-sync-lane.d.ts +0 -49
  54. package/src/fn-routers/task-sync-lane.ts +0 -114
  55. package/src/fn-routers/task-sync-projection.d.ts +0 -144
  56. package/src/fn-routers/task-sync-rename.d.ts +0 -91
  57. package/src/fn-routers/task-sync-router.d.ts +0 -455
  58. package/src/fn-routers/task-sync-router.ts +0 -1075
  59. package/src/fn-routers/tasks-router.d.ts +0 -25
  60. package/src/fn-routers/user-preferences-router.d.ts +0 -77
  61. package/src/fn-routers/work-items-router.d.ts +0 -102
  62. package/src/gate-ttls.d.ts +0 -6
  63. package/src/gpt-gate.d.ts +0 -25
  64. package/src/handlers/bun-stable-watch.d.ts +0 -1
  65. package/src/handlers/pane-outbox-drain.d.ts +0 -1
  66. package/src/handlers/projects-digest.d.ts +0 -26
  67. package/src/handlers/prune-stale-data.d.ts +0 -30
  68. package/src/handlers/registry-stale-inactive-sweep.d.ts +0 -1
  69. package/src/handlers/scala-tools-currency-watch.d.ts +0 -1
  70. package/src/handlers/singleton-tools-currency-watch.d.ts +0 -1
  71. package/src/handlers/sweep-event-log.d.ts +0 -1
  72. package/src/handlers/sweep-host-cache.d.ts +0 -24
  73. package/src/handlers/upstream-issue-sync.d.ts +0 -1
  74. package/src/handlers/whatsapp-liveness-logic.d.ts +0 -34
  75. package/src/handlers/whatsapp-liveness.d.ts +0 -4
  76. package/src/hono-error-handler.d.ts +0 -25
  77. package/src/install-harness.d.ts +0 -45
  78. package/src/install-logging.d.ts +0 -34
  79. package/src/load-service-install-row.d.ts +0 -24
  80. package/src/load-service-prisma-client.d.ts +0 -18
  81. package/src/mount-orpc-router.d.ts +0 -15
  82. package/src/mount-server-packages.d.ts +0 -29
  83. package/src/mount.d.ts +0 -9
  84. package/src/mutable-app-ref.d.ts +0 -44
  85. package/src/page-route-shell-types.d.ts +0 -12
  86. package/src/page-server-orpc/audit-revert-router.d.ts +0 -37
  87. package/src/page-server-orpc/hub-mcp-client.d.ts +0 -12
  88. package/src/page-server-orpc/portal-diagnostics-router.d.ts +0 -49
  89. package/src/page-server-orpc/puck-pages-router.d.ts +0 -58
  90. package/src/page-server-orpc/server-client.d.ts +0 -16
  91. package/src/page-server-orpc/templates-router.d.ts +0 -34
  92. package/src/page-server-orpc/user-preferences-router.d.ts +0 -79
  93. package/src/pg-boss-handler-registry.d.ts +0 -27
  94. package/src/pg-boss-mount.d.ts +0 -42
  95. package/src/proposal-authorized-emails.d.ts +0 -28
  96. package/src/proposal-chat-inject.d.ts +0 -17
  97. package/src/proposal-gate.d.ts +0 -18
  98. package/src/read-html-template.d.ts +0 -38
  99. package/src/read-viewport-from-request.d.ts +0 -18
  100. package/src/readiness-gate.d.ts +0 -16
  101. package/src/register-api-routes.d.ts +0 -18
  102. package/src/register-crash-handlers.d.ts +0 -15
  103. package/src/register-page-routes.d.ts +0 -27
  104. package/src/register-page-server-client.d.ts +0 -11
  105. package/src/register-registry-page-route/ai-chat-prefetch.d.ts +0 -13
  106. package/src/register-registry-page-route/graph-cache.d.ts +0 -30
  107. package/src/register-registry-page-route/meta-title.d.ts +0 -2
  108. package/src/register-registry-page-route/proposal-approval-email-token.d.ts +0 -14
  109. package/src/register-registry-page-route/proposal-brand-stamping.d.ts +0 -28
  110. package/src/register-registry-page-route/resolve-page-data.d.ts +0 -1
  111. package/src/register-registry-page-route.d.ts +0 -27
  112. package/src/register-static-assets.d.ts +0 -13
  113. package/src/register-ws-routes.d.ts +0 -28
  114. package/src/resolve-app-base-url.d.ts +0 -13
  115. package/src/resolve-brand-favicon.d.ts +0 -28
  116. package/src/resolve-from-loader-config.d.ts +0 -32
  117. package/src/resolve-service-context.d.ts +0 -17
  118. package/src/resolve-service-port.d.ts +0 -75
  119. package/src/resolve-theme-mode.d.ts +0 -42
  120. package/src/resolvers/fetch-org-brand.d.ts +0 -2
  121. package/src/resolvers/portal-route-paths.d.ts +0 -39
  122. package/src/resolvers/website-by-host-map.d.ts +0 -12
  123. package/src/resource-chat-inject.d.ts +0 -46
  124. package/src/resource-not-found.d.ts +0 -60
  125. package/src/run-boot-hook-list.d.ts +0 -19
  126. package/src/run-boot-hooks.d.ts +0 -31
  127. package/src/scala-tools-currency-watchdog.d.ts +0 -10
  128. package/src/security-headers.d.ts +0 -12
  129. package/src/serve/serve.d.ts +0 -46
  130. package/src/serve/stamp-transport-identity.d.ts +0 -39
  131. package/src/server-error-page.d.ts +0 -29
  132. package/src/start-scheduled-jobs.d.ts +0 -18
  133. package/src/two-phase-boot.d.ts +0 -176
  134. package/src/types.d.ts +0 -46
  135. package/src/ui-service.d.ts +0 -46
  136. package/src/ws-boot-self-test.d.ts +0 -19
@@ -1,25 +0,0 @@
1
- /**
2
- * @system service-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- *
6
- * ORPC procedures for task creation with initial comment.
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 tasksRouter: {
12
- createWithComment: 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,77 +0,0 @@
1
- /**
2
- * @system service-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- *
6
- * ORPC procedures for a GENERIC per-user preference store backed by the
7
- * `user_preferences` table. The user is resolved from the ORPC session context
8
- * (`authed` middleware → `context.user.id`); the client supplies the org + key
9
- * + value. This is the DB-durable, user-scoped key/value surface any feature
10
- * can use — the AI browser-control focus (key `ai_ui_focus`) is the first
11
- * consumer; it is NOT scala-projects-bespoke.
12
- *
13
- * Why this exists (over the generated `user_preferences` CRUD): the generated
14
- * create/update do NOT resolve `user_id` server-side (only `organisation_id`
15
- * from ctx.orgId), so a client cannot correctly write a per-user row through
16
- * them. This proc stamps `user_id` from the authenticated caller, making the
17
- * write safe + per-user. It also emits the `data_change` notify so the
18
- * realtime surface (regions.watchDataChange) pushes updates to subscribed
19
- * clients — the cross-region channel for the AI focus (the AiChat panel writes
20
- * a focus here; the project-list-view in a different region subscribes +
21
- * reacts, no shared React-context ancestor needed).
22
- *
23
- * Ownership is user_id: a caller reads/writes ONLY their own preferences. The
24
- * org is part of the compound key (per-org isolation) but is client-supplied
25
- * (the session carries the user, not the active org).
26
- *
27
- * DECISION — host-scoping of `user_preferences`: the table is NOT yet a shared
28
- * `@teamscala/db` model (it lives in scala-projects's schema today), so this proc
29
- * is genuinely host-scoped: it runs correctly on services whose Prisma client
30
- * declares `user_preferences` (scala-projects is the first host) + is inert
31
- * elsewhere. `Context.prisma` is `any`-typed, so the proc COMPILES workspace-
32
- * wide (no type error on a model a host may not declare) — the `any` is the
33
- * deliberate seam that lets one generic proc serve hosts incrementally as they
34
- * adopt the table. Per-user preferences are platform-universal, so the tracked
35
- * follow-on is to promote `user_preferences` to a shared `@teamscala/db` model
36
- * (open-migration: `user_preferences→shared-model`, exit: every kind:ui host
37
- * can mount this proc with no schema precondition) — at which point the proc is
38
- * universally hostable + the `any` seam can tighten to the shared client. Until
39
- * then the proc is opt-in per host (declare the table → get the capability).
40
- */
41
- import * as v from "valibot";
42
- import { type Context } from "./auth-router.ts";
43
- export declare const userPreferencesRouter: {
44
- upsert: import("@orpc/server").DecoratedProcedure<import("@orpc/server").MergedInitialContext<Context & Record<never, never>, Context, Context>, import("@orpc/server").MergedCurrentContext<Context, {
45
- headers: Headers;
46
- resolveUser?: (headers: Headers, prisma: any) => Promise<import("./auth-router.ts").User | null>;
47
- prisma: any;
48
- user: import("./auth-router.ts").User;
49
- orgId: string | null | undefined;
50
- }>, v.ObjectSchema<{
51
- readonly organisationId: v.StringSchema<undefined>;
52
- /** The preference key (e.g. `ai_ui_focus`). Namespaced by feature. */
53
- readonly key: v.StringSchema<undefined>;
54
- /** The JSON value. Arbitrary per feature — typed by the caller. */
55
- readonly value: v.AnySchema;
56
- }, undefined>, import("@orpc/contract").Schema<{
57
- success: boolean;
58
- }, {
59
- success: boolean;
60
- }>, Record<never, never>, Record<never, never>>;
61
- get: import("@orpc/server").DecoratedProcedure<import("@orpc/server").MergedInitialContext<Context & Record<never, never>, Context, Context>, import("@orpc/server").MergedCurrentContext<Context, {
62
- headers: Headers;
63
- resolveUser?: (headers: Headers, prisma: any) => Promise<import("./auth-router.ts").User | null>;
64
- prisma: any;
65
- user: import("./auth-router.ts").User;
66
- orgId: string | null | undefined;
67
- }>, v.ObjectSchema<{
68
- readonly organisationId: v.StringSchema<undefined>;
69
- readonly key: v.StringSchema<undefined>;
70
- }, undefined>, import("@orpc/contract").Schema<{
71
- value: any;
72
- updatedAt: any;
73
- }, {
74
- value: any;
75
- updatedAt: any;
76
- }>, Record<never, never>, Record<never, never>>;
77
- };
@@ -1,102 +0,0 @@
1
- /**
2
- * @system service-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- *
6
- * ORPC procedure for safely deleting a work_item (initiative/project/task).
7
- * Refuses the delete when the row still has child rows (parent_id = id), so a
8
- * delete can NEVER orphan its descendants — the tree must be emptied bottom-up.
9
- *
10
- * Initiatives, projects and tasks are all rows of the ONE `work_items` table
11
- * discriminated by `kind`, and `parent_id` carries no DB-level foreign key, so
12
- * a plain `work_items.delete` leaves dangling children with no referential
13
- * integrity to stop it. This one guard covers every level (you may only delete
14
- * a leaf — a node with no children), which is exactly the "empty it first"
15
- * behaviour the board wants.
16
- */
17
- import { type Context } from "./auth-router.ts";
18
- export declare const workItemsRouter: {
19
- /**
20
- * Fired client-side right after a task's status is set to
21
- * "pending_approval" (RaCI: the task's assignee is Responsible; the
22
- * project's Accountable person is the approver). Walks parent_id up to
23
- * the nearest project-kind ancestor, emails every accountable person on
24
- * it. Never throws to the caller — a notification failure must not block
25
- * the status change that already committed.
26
- */
27
- requestApproval: import("@orpc/server").DecoratedProcedure<import("@orpc/server").MergedInitialContext<Context & Record<never, never>, Context, Context>, import("@orpc/server").MergedCurrentContext<Context, {
28
- headers: Headers;
29
- resolveUser?: (headers: Headers, prisma: any) => Promise<import("./auth-router.ts").User | null>;
30
- prisma: any;
31
- user: import("./auth-router.ts").User;
32
- orgId: string | null | undefined;
33
- }>, import("@orpc/contract").Schema<unknown, unknown>, import("@orpc/contract").Schema<{
34
- notified: number;
35
- }, {
36
- notified: number;
37
- }>, Record<never, never>, Record<never, never>>;
38
- /**
39
- * Fired client-side right after a comment is created, when the comment
40
- * text contains an @mention the client already resolved to a team-member
41
- * id (client does the name matching against the people list it already
42
- * has loaded; this handler only sends). Never throws to the caller for
43
- * same reason as requestApproval -- a notification failure must not
44
- * surface as a failed comment post.
45
- */
46
- notifyMentions: import("@orpc/server").DecoratedProcedure<import("@orpc/server").MergedInitialContext<Context & Record<never, never>, Context, Context>, import("@orpc/server").MergedCurrentContext<Context, {
47
- headers: Headers;
48
- resolveUser?: (headers: Headers, prisma: any) => Promise<import("./auth-router.ts").User | null>;
49
- prisma: any;
50
- user: import("./auth-router.ts").User;
51
- orgId: string | null | undefined;
52
- }>, import("@orpc/contract").Schema<unknown, unknown>, import("@orpc/contract").Schema<{
53
- notified: number;
54
- }, {
55
- notified: number;
56
- }>, Record<never, never>, Record<never, never>>;
57
- /**
58
- * Org-scoped member list for the task-comments panel — @mention matching AND
59
- * comment-sender display (name + avatar). ChatPanel.tsx has no
60
- * serverLoader/orgId prop (client-only overlay content), so it can't do the
61
- * SSR raw-SQL org-scope join load-project-list-view.ts uses; this exposes
62
- * the same result via a custom procedure instead of widening service_schema
63
- * to the raw better_auth_member table.
64
- *
65
- * This is the SINGLE source of member display info for the comments panel:
66
- * it coalesces BOTH name/email/avatar families on the user model into one
67
- * shape (the `full_name`/`primary_email`/`avatar_url` family AND the
68
- * better-auth `name`/`email`/`image` family). Returning avatar here lets the
69
- * client resolve sender name+avatar from this one list and drop the separate
70
- * `user.findMany` enrichment fetch it previously ran as a second waterfall
71
- * hop after `comments.findMany` (loading-shape: one wave-parallel hit, not a
72
- * dependent client-side round-trip chain).
73
- */
74
- orgMembers: import("@orpc/server").DecoratedProcedure<import("@orpc/server").MergedInitialContext<Context & Record<never, never>, Context, Context>, import("@orpc/server").MergedCurrentContext<Context, {
75
- headers: Headers;
76
- resolveUser?: (headers: Headers, prisma: any) => Promise<import("./auth-router.ts").User | null>;
77
- prisma: any;
78
- user: import("./auth-router.ts").User;
79
- orgId: string | null | undefined;
80
- }>, import("@orpc/contract").Schema<unknown, unknown>, import("@orpc/contract").Schema<{
81
- id: string;
82
- name: string;
83
- email: string;
84
- avatar: string | null;
85
- }[], {
86
- id: string;
87
- name: string;
88
- email: string;
89
- avatar: string | null;
90
- }[]>, Record<never, never>, Record<never, never>>;
91
- deleteEmpty: import("@orpc/server").DecoratedProcedure<import("@orpc/server").MergedInitialContext<Context & Record<never, never>, Context, Context>, import("@orpc/server").MergedCurrentContext<Context, {
92
- headers: Headers;
93
- resolveUser?: (headers: Headers, prisma: any) => Promise<import("./auth-router.ts").User | null>;
94
- prisma: any;
95
- user: import("./auth-router.ts").User;
96
- orgId: string | null | undefined;
97
- }>, import("@orpc/contract").Schema<unknown, unknown>, import("@orpc/contract").Schema<{
98
- success: boolean;
99
- }, {
100
- success: boolean;
101
- }>, Record<never, never>, Record<never, never>>;
102
- };
@@ -1,6 +0,0 @@
1
- /** Populate the TTL cache from the registry rows. Idempotent; keeps defaults on
2
- * any miss so the gates ALWAYS render (protective-layers-fail-explicitly). */
3
- export declare function initGateTtls(): Promise<void>;
4
- export declare function agTtlMs(): number;
5
- export declare function propTtlMs(): number;
6
- export declare function gptTtlMs(): number;
package/src/gpt-gate.d.ts DELETED
@@ -1,25 +0,0 @@
1
- /**
2
- * @system service-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- *
6
- * The PUBLIC GPT identity gate, expressed as config for the content-gate
7
- * primitive (content-gate/). Unlike proposals/agreements this is NOT access
8
- * control — every email is a valid visitor (lead capture). Its whole job is to
9
- * make a returning visitor's identity known AT SSR so the GPT body renders the
10
- * real conversation on first paint instead of server-rendering the capture gate
11
- * and then swapping to the chat after hydration (the ssr-then-live-handoff +
12
- * "know the visitor at SSR first paint" violation: building-applications).
13
- *
14
- * Flow: the capture form POSTs {gptId, email} to /api/gpt-access (openCapture →
15
- * any email matches); the access endpoint sets a signed `gpt_token` cookie. On
16
- * the next request runContentGate verifies that cookie for this agent and seeds
17
- * resolved.initialVisitor — which the GPT body serverLoader (ssrGptSession) then
18
- * uses to SSR-restore the conversation, and GptBodyBlock uses to skip the gate.
19
- * onUnauthorized is a no-op: an un-gated (first-time) visitor sees the capture
20
- * form the block renders itself when no visitor is known — that is correct, not
21
- * a flash (they ARE anonymous), so there is nothing to withhold.
22
- */
23
- import type { AccessConfig, ContentGateConfig } from "./content-gate/config-types.ts";
24
- export declare const gptGateConfig: ContentGateConfig;
25
- export declare const gptAccessConfig: AccessConfig;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,26 +0,0 @@
1
- /**
2
- * @system server-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- *
6
- * The `projects-daily-digest` / `projects-weekly-digest` pg-boss handlers for
7
- * scala-projects. Same fixed-query shape as prune-stale-data: no row-driven
8
- * SQL, every query is a literal Prisma call against work_items; the
9
- * scheduled_job row only carries the cron.
10
- *
11
- * Daily digest: per assignee, tasks assigned to them created in the last 24h.
12
- * Weekly digest: per assignee, their overdue tasks + tasks due in the next 7
13
- * days. Both group work_items by assignee_id so one org-wide query covers
14
- * every member, then send one email per assignee via the
15
- * projects-daily-digest / projects-weekly-digest email_template rows.
16
- *
17
- * Registered under `@teamscala/service-boot:projects-daily-digest` and
18
- * `@teamscala/service-boot:projects-weekly-digest`.
19
- */
20
- import type { ScheduledJobConfig } from "@teamscala/db-validation/registry-schemas/scheduled-job";
21
- export declare function sendDailyDigest(_ctx: {
22
- config: ScheduledJobConfig;
23
- }): Promise<void>;
24
- export declare function sendWeeklyDigest(_ctx: {
25
- config: ScheduledJobConfig;
26
- }): Promise<void>;
@@ -1,30 +0,0 @@
1
- /**
2
- * @system server-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- *
6
- * The `db-prune-stale-data` pg-boss handler. Reads the `retention` map from the
7
- * `scheduled_job` row config and prunes stale rows per entry.
8
- *
9
- * Writes use Prisma ORM methods (deleteMany/updateMany) via the prisma-registry
10
- * client — NEVER raw SQL. The `@teamscala/db` client carries the `blockRawSqlWrites`
11
- * audit extension: `$executeRaw`/`$executeRawUnsafe` are blocked so every write
12
- * is audited; ORM methods are the canonical audited path.
13
- *
14
- * SAFETY — identifier allowlist: each retention key selects a FIXED, hardcoded
15
- * Prisma model + field (table/field names are literal in code, never derived
16
- * from the row); the row's value (a duration string) is parsed to a cutoff Date.
17
- * A row can therefore never inject arbitrary SQL or address an unvetted model.
18
- * Keys not in the allowlist are skipped + logged.
19
- *
20
- * `audit_trail.*` is INTENTIONALLY EXCLUDED: `audit-trail-permanent` (critical)
21
- * forbids any DELETE FROM audit_trail. The legacy row's
22
- * `audit_trail.sync_entities: "delete all"` entry is stale drift from before
23
- * the 2026-06-19 hardening — surfaced (skipped + warned), never executed.
24
- *
25
- * Registered under slug `@teamscala/service-boot:prune-stale-data`.
26
- */
27
- import type { ScheduledJobConfig } from "@teamscala/db-validation/registry-schemas/scheduled-job";
28
- export declare function pruneStaleData({ config, }: {
29
- config: ScheduledJobConfig;
30
- }): Promise<void>;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,24 +0,0 @@
1
- /**
2
- * Expand a path pattern containing single-segment `*` wildcards into concrete
3
- * paths (files or dirs). Used by `retention_dirs` so a single config key like
4
- * a pattern like `${WORKSPACE}/<star>/target` reaches every repo's target dir.
5
- * Sync + bounded: the
6
- * pattern is shallow (3 segments), and this runs once
7
- * nightly. Non-existent segments yield no matches (the caller stats each result).
8
- */
9
- export declare function expandGlob(pattern: string): string[];
10
- /**
11
- * Is `dir` stale — i.e. NO file under it is newer than `cutoffMs`? Walks
12
- * recursively and SHORT-CIRCUITS the instant it finds a fresh file (so an
13
- * actively-built target dir returns fast without walking its full tree). On a
14
- * stale dir the walk is complete and returns the total size + file count, so
15
- * the caller can report bytes-freed before deleting the dir whole.
16
- */
17
- export declare function checkDirStale(dir: string, cutoffMs: number): Promise<{
18
- stale: boolean;
19
- bytes: number;
20
- fileCount: number;
21
- }>;
22
- /** Parse the root-fs Use% from `df --output=pcent,target` output (pure, for tests).
23
- * Returns null if no root-mount line is found. */
24
- export declare function parseRootDiskPct(out: string): number | null;
@@ -1 +0,0 @@
1
- export {};
@@ -1,34 +0,0 @@
1
- /**
2
- * @system server-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- *
6
- * Pure transition-detection logic for the WhatsApp linked-device liveness monitor
7
- * (`whatsapp-liveness` handler). Split out from the GOWA-coupled handler so the
8
- * logic is unit-testable with zero adapter dependencies, and the handler is a thin
9
- * poll→detect→emit shell. The connection signal is the GOWA device `state` field
10
- * (`"logged_in"` == connected) — see `whatsapp-remote-logout-monitor`.
11
- */
12
- /** GOWA device `state` value meaning the linked phone is connected + authenticated. */
13
- export declare const GOWA_CONNECTED_STATE = "logged_in";
14
- export interface WhatsAppDeviceState {
15
- id: string;
16
- state: string;
17
- jid?: string;
18
- display_name?: string;
19
- }
20
- export interface LivenessTransitions {
21
- disconnected: WhatsAppDeviceState[];
22
- reconnected: WhatsAppDeviceState[];
23
- }
24
- /**
25
- * Detect connected↔disconnected transitions between the last-known and the freshly
26
- * observed device states.
27
- *
28
- * `prev` is the last-known `state` per device id. A device ABSENT from `prev` is a
29
- * first sighting: it seeds the baseline and yields NO transition (so the monitor
30
- * never alerts on a state it never observed the device leave, and a process restart
31
- * re-baselines without false positives). A device present in `prev` is compared:
32
- * connected→not is `disconnected`; not→connected is `reconnected`.
33
- */
34
- export declare function detectLivenessTransitions(prev: Map<string, string>, curr: WhatsAppDeviceState[]): LivenessTransitions;
@@ -1,4 +0,0 @@
1
- import type { ScheduledJobConfig } from "@teamscala/db-validation/registry-schemas/scheduled-job";
2
- export declare function pollWhatsAppLiveness({ config: _config, }: {
3
- config: ScheduledJobConfig;
4
- }): Promise<void>;
@@ -1,25 +0,0 @@
1
- /**
2
- * @system service-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- *
6
- * The single app.onError factory for every Hono app (UI + backend). Two error
7
- * classes, deliberately separate:
8
- * - HTTPException: a DELIBERATE status-bearing throw (e.g. hono bodyLimit's
9
- * 413). Preserve its status + message verbatim — buildErrorReport only knows
10
- * 500/503 and would erase a deliberate 413/401/etc.
11
- * - anything else: an UNEXPECTED error → buildErrorReport (errorId correlation,
12
- * transient-vs-bug classification, 503 + Retry-After when retryable, else 500).
13
- *
14
- * Resolves the apparent tension between `hono-global-error-handler` (HTTPException
15
- * → status + JSON) and `error-responses-via-error-report` (every error response
16
- * via buildErrorReport): the latter governs UNEXPECTED errors; HTTPException is
17
- * the documented deliberate-status carve-out. The handler is a consumer of
18
- * buildErrorReport, never a second classifier for the unexpected branch.
19
- */
20
- import type { Context } from "hono";
21
- /**
22
- * Returns an `app.onError` handler tagged with `label` (used in the log line so
23
- * the boot site that surfaced the error is identifiable).
24
- */
25
- export declare function createRequestErrorHandler(label: string): (err: unknown, c: Context) => Response;
@@ -1,45 +0,0 @@
1
- /**
2
- * @system server-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- * @indivisible-unit
6
- *
7
- * Install harness — sandbox-mounts each declared package and captures
8
- * registry.require() calls via AsyncLocalStorage. Validates all required
9
- * rows exist before returning. Throws HarnessInstallError with full
10
- * context on failure. Per Constitution Rule 2 step 3.
11
- *
12
- * Marked @indivisible-unit: HarnessInstallError is the error class
13
- * validatePackageDependencies (might) throw — they form one canonical
14
- * "install harness validation" unit (the validator + the failure-mode
15
- * class it produces).
16
- */
17
- export interface PackageDescriptor {
18
- name: string;
19
- initPath: string;
20
- }
21
- export interface HarnessValidationResult {
22
- valid: true;
23
- dependencies: Array<{
24
- slug: string;
25
- }>;
26
- }
27
- export interface HarnessValidationError {
28
- valid: false;
29
- missing: Array<{
30
- slug: string;
31
- packageName: string;
32
- }>;
33
- }
34
- export type HarnessOutcome = HarnessValidationResult | HarnessValidationError;
35
- export declare class HarnessInstallError extends Error {
36
- readonly missing: Array<{
37
- slug: string;
38
- packageName: string;
39
- }>;
40
- constructor(missing: Array<{
41
- slug: string;
42
- packageName: string;
43
- }>);
44
- }
45
- export declare function validatePackageDependencies(packages: PackageDescriptor[], mountFn: (pkg: PackageDescriptor) => Promise<void>): Promise<HarnessOutcome>;
@@ -1,34 +0,0 @@
1
- /**
2
- * @system server-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- * @indivisible-unit
6
- *
7
- * One-call install of the entire logging pipeline. After installLogging()
8
- * runs, every error in the service — process-level, HTTP middleware, Hono
9
- * handlers, Puck blocks, even third-party packages calling console.* — is
10
- * captured by @teamscala/logger and flows to Sentry/GlitchTip (prod) or
11
- * loga (dev) with full context. Application code never imports the logger
12
- * or wraps anything in try/catch for telemetry purposes.
13
- *
14
- * Marked @indivisible-unit: installLogging (early bootstrap, hardcoded
15
- * defaults) and applyLoggerConfig (late-stage, DB-driven) are the two
16
- * phases of the same one-call install — the service boot pipeline calls
17
- * them in sequence with the same serviceSlug.
18
- */
19
- import { attachRequestLogger } from "@teamscala/logger/install-logging";
20
- export { attachRequestLogger };
21
- export interface InstallLoggingOptions {
22
- serviceSlug: string;
23
- }
24
- /** Initial bootstrap install — runs BEFORE DB/Registry are available.
25
- * Uses hardcoded defaults (INFO level, /tmp/scala-logs). */
26
- export declare function installLogging(opts: InstallLoggingOptions): void;
27
- /** Late-stage configuration — runs AFTER Registry is loaded.
28
- * Injects DB-driven settings into the logger primitive. */
29
- export declare function applyLoggerConfig(config: {
30
- minLevel?: "debug" | "info" | "warn" | "error";
31
- logDir?: string;
32
- maxFileSize?: number;
33
- maxFiles?: number;
34
- }): void;
@@ -1,24 +0,0 @@
1
- /**
2
- * @system server-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- *
6
- * Loads the service_install registry row for a given service slug.
7
- * Uses registry.require() per Constitution Rule 11.
8
- * Schema is owned by @teamscala/db-validation (Rule 7).
9
- */
10
- import type { ServiceInstallConfig } from "@teamscala/db-validation/registry-schemas/service-install";
11
- export { ServiceInstallConfigSchema } from "@teamscala/db-validation/registry-schemas/service-install";
12
- export type { ServiceInstallConfig };
13
- export interface LoadServiceInstallRowResult {
14
- success: true;
15
- config: ServiceInstallConfig;
16
- }
17
- export interface LoadServiceInstallRowError {
18
- success: false;
19
- error: "row_not_found" | "validation_failed";
20
- slug: string;
21
- message: string;
22
- }
23
- export type LoadServiceInstallRowOutcome = LoadServiceInstallRowResult | LoadServiceInstallRowError;
24
- export declare function loadServiceInstallRow(serviceSlug: string): Promise<LoadServiceInstallRowOutcome>;
@@ -1,18 +0,0 @@
1
- /**
2
- * @system server-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- *
6
- * Loads the service's own generated PrismaClient from
7
- * <cwd>/prisma/generated/prisma/client.ts. Each service repo generates its own
8
- * client from its own schema.prisma; resolving a static import would pick up
9
- * whichever @prisma/generated bun resolves first in a multi-service workspace,
10
- * which is wrong.
11
- *
12
- * No fallback: if the generated client is missing the deploy is broken — fail
13
- * loud with the remediation step.
14
- */
15
- export type ServicePrismaClientConstructor = new (args: {
16
- adapter: unknown;
17
- }) => unknown;
18
- export declare function loadServicePrismaClient(serviceSlug: string): Promise<ServicePrismaClientConstructor>;
@@ -1,15 +0,0 @@
1
- /**
2
- * @system service-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- *
6
- * Mounts the composed ORPC app router (generated Prisma CRUD + custom fn routers)
7
- * at /api/rpc/* over HTTP via @orpc/server/fetch's RPCHandler.
8
- * Uses getAppRouter() from @teamscala/orpc/app-router which merges generated
9
- * routers with custom routers registered via registerCustomRouter().
10
- */
11
- import type { Hono } from "hono";
12
- export interface OrpcMountResult {
13
- routeCount: number;
14
- }
15
- export declare function mountOrpcRouter(app: Hono, serviceSlug: string): Promise<OrpcMountResult | null>;
@@ -1,29 +0,0 @@
1
- /**
2
- * @system server-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- *
6
- * Walks `service_install.server_packages[]`, dynamic-imports each, and calls
7
- * its `mount(ctx)` function. Server packages register handlers / boot hooks /
8
- * scheduled jobs / WS routes via the MountContext exposed in ctx; the
9
- * resulting MountRegistry is consumed by register-api-routes /
10
- * register-ws-routes / run-boot-hook-list / start-scheduled-jobs.
11
- */
12
- import type { ServiceInstallConfig } from "@teamscala/db/registry/loader/load-service-install-row";
13
- import { type MountRegistry } from "@teamscala/os/runtime-contracts/mount-context";
14
- import type { Hono } from "hono";
15
- /**
16
- * Speculatively import every server_package's mount module so Bun compiles
17
- * the module graphs into its cache NOW, overlapping the (CPU-bound)
18
- * compilation with whatever I/O the caller runs next. When mountServerPackages
19
- * later imports the same paths they hit the cache (instant).
20
- *
21
- * Same pattern as create-boot-pipeline's speculative preloads — the
22
- * cross-internet DB I/O in the gate chain (~3.4s) is dead time the compiler
23
- * can use. Best-effort + non-fatal: a failed import here (wrong candidate
24
- * path, transient resolution race) is silently swallowed because
25
- * mountServerPackages will re-attempt with full error surfacing; the preload
26
- * only warms the cache, never gates boot.
27
- */
28
- export declare function preloadServerPackages(packages: string[]): Promise<void>;
29
- export declare function mountServerPackages(app: Hono, config: ServiceInstallConfig, serviceSlug: string): Promise<MountRegistry>;
package/src/mount.d.ts DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * @system server-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- *
6
- * Server-package mount for opt-in service-boot watchdogs.
7
- */
8
- import type { MountContext } from "@teamscala/os/runtime-contracts/mount-context";
9
- export declare function mount(ctx: MountContext): void;
@@ -1,44 +0,0 @@
1
- /**
2
- * @system service-boot
3
- * @status handwritten
4
- * @edit edit directly
5
- *
6
- * Mutable app reference for two-phase boot. Allows swapping the Hono app
7
- * atomically after building the full app in the background. The initial app
8
- * is a minimal tool-only surface (ORPC, data routes) that starts serving
9
- * immediately; the full app (pages, hydration) is built off-to-the-side and
10
- * swapped in once complete.
11
- *
12
- * Thread-safety: Bun is single-threaded, so a simple module-level variable
13
- * is sufficient. Atomics are not needed.
14
- */
15
- import type { Hono } from "hono";
16
- /**
17
- * Create a new mutable app reference initialized with the provided app.
18
- * This should be called once at boot time.
19
- */
20
- export declare function initMutableAppRef(initialApp: Hono, label: string): void;
21
- /**
22
- * Get the current app. Throws if the ref hasn't been initialized.
23
- */
24
- export declare function getApp(): Hono;
25
- /**
26
- * Get the current app label for logging.
27
- */
28
- export declare function getAppLabel(): string;
29
- /**
30
- * Atomically swap the app to a new instance. This is called after the
31
- * full app is built in the background. Returns the previous label for logging.
32
- */
33
- export declare function swapApp(newApp: Hono, newLabel: string): string;
34
- /**
35
- * Fetch handler that routes through the mutable app reference.
36
- * This replaces the direct app.fetch call in the serve layer.
37
- *
38
- * Stamps transport-derived identity (x-caller-remote-address/-port + the
39
- * loopback local-caller comm) via the SAME stampTransportIdentity helper as
40
- * direct mode, so two-phase-boot (mutable-ref) UI services carry identical
41
- * identity on every request — closing the gap where the mutable-ref path
42
- * previously served requests with no transport headers stamped at all.
43
- */
44
- export declare function fetchWithMutableApp(req: Request, server: ReturnType<typeof Bun.serve>): Promise<Response>;