@teamscala/service-boot 0.23.284

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 (138) hide show
  1. package/package.json +1016 -0
  2. package/src/agreement-gate.test.ts +118 -0
  3. package/src/agreement-gate.ts +887 -0
  4. package/src/asset-cache-key.ts +59 -0
  5. package/src/asset-optimize.ts +93 -0
  6. package/src/asset-proxy.ts +148 -0
  7. package/src/asset-social-card.ts +58 -0
  8. package/src/attach-agreement-magic.ts +62 -0
  9. package/src/attach-portal-members.ts +107 -0
  10. package/src/attach-proposal-accept.ts +123 -0
  11. package/src/attach-proposal-magic.ts +55 -0
  12. package/src/attach-transfers-upload.ts +100 -0
  13. package/src/auth-gate.ts +385 -0
  14. package/src/bind-page-handler.ts +223 -0
  15. package/src/build-client-assets/input-hashing.ts +206 -0
  16. package/src/build-client-assets/source-candidates.ts +115 -0
  17. package/src/build-client-assets.test.ts +216 -0
  18. package/src/build-client-assets.ts +962 -0
  19. package/src/compose-page-title.test.ts +88 -0
  20. package/src/compose-page-title.ts +73 -0
  21. package/src/content-gate/access.ts +89 -0
  22. package/src/content-gate/config-types.ts +108 -0
  23. package/src/content-gate/gate.ts +74 -0
  24. package/src/content-gate/parse-cookie.ts +23 -0
  25. package/src/content-gate/token.test.ts +70 -0
  26. package/src/content-gate/token.ts +148 -0
  27. package/src/content-page-floor.test.ts +127 -0
  28. package/src/content-page-floor.ts +70 -0
  29. package/src/discover-blocks.ts +228 -0
  30. package/src/expand-roster.ts +197 -0
  31. package/src/fn-routers/agreement-completion-email.ts +115 -0
  32. package/src/fn-routers/agreement-send-router.ts +303 -0
  33. package/src/fn-routers/ai-health-router.ts +64 -0
  34. package/src/fn-routers/auth-router.ts +131 -0
  35. package/src/fn-routers/cache-admin-router.ts +50 -0
  36. package/src/fn-routers/chat-session-router.ts +455 -0
  37. package/src/fn-routers/email-defaults.ts +22 -0
  38. package/src/fn-routers/email-link-ttl.ts +23 -0
  39. package/src/fn-routers/index.ts +70 -0
  40. package/src/fn-routers/panel-data-router.ts +93 -0
  41. package/src/fn-routers/persist-chat-messages.test.ts +86 -0
  42. package/src/fn-routers/persist-chat-messages.ts +96 -0
  43. package/src/fn-routers/plans-router.ts +141 -0
  44. package/src/fn-routers/proposal-send-router.ts +207 -0
  45. package/src/fn-routers/public-agreement-router.ts +865 -0
  46. package/src/fn-routers/public-assessment-router.ts +421 -0
  47. package/src/fn-routers/public-gpt-session-router.ts +373 -0
  48. package/src/fn-routers/sign-in-flow-router.ts +196 -0
  49. package/src/fn-routers/task-sync-bind.test.ts +105 -0
  50. package/src/fn-routers/task-sync-classify.test.ts +109 -0
  51. package/src/fn-routers/task-sync-dispatch.test.ts +44 -0
  52. package/src/fn-routers/task-sync-dispatch.ts +124 -0
  53. package/src/fn-routers/task-sync-router.test.ts +279 -0
  54. package/src/fn-routers/task-sync-router.ts +1036 -0
  55. package/src/fn-routers/tasks-router.ts +77 -0
  56. package/src/fn-routers/user-preferences-router.ts +139 -0
  57. package/src/fn-routers/work-items-router.ts +341 -0
  58. package/src/gate-ttls.ts +56 -0
  59. package/src/gpt-gate.ts +76 -0
  60. package/src/handlers/bun-stable-watch.ts +89 -0
  61. package/src/handlers/projects-digest.ts +198 -0
  62. package/src/handlers/prune-stale-data.ts +110 -0
  63. package/src/handlers/registry-stale-inactive-sweep.ts +82 -0
  64. package/src/handlers/scala-tools-currency-watch.test.ts +60 -0
  65. package/src/handlers/scala-tools-currency-watch.ts +171 -0
  66. package/src/handlers/scheduled-browser-tests.ts +85 -0
  67. package/src/handlers/sweep-event-log.ts +98 -0
  68. package/src/handlers/sweep-host-cache.ts +211 -0
  69. package/src/handlers/upstream-issue-sync.ts +210 -0
  70. package/src/handlers/whatsapp-liveness-handler.test.ts +59 -0
  71. package/src/handlers/whatsapp-liveness-logic.ts +53 -0
  72. package/src/handlers/whatsapp-liveness.test.ts +78 -0
  73. package/src/handlers/whatsapp-liveness.ts +125 -0
  74. package/src/hono-error-handler.ts +55 -0
  75. package/src/install-harness.ts +80 -0
  76. package/src/install-logging.ts +182 -0
  77. package/src/load-service-install-row.ts +98 -0
  78. package/src/load-service-prisma-client.ts +53 -0
  79. package/src/mount-orpc-router.ts +148 -0
  80. package/src/mount-server-packages.ts +155 -0
  81. package/src/mount.ts +18 -0
  82. package/src/mutable-app-ref.ts +68 -0
  83. package/src/page-route-shell-types.ts +16 -0
  84. package/src/page-server-orpc/audit-revert-router.ts +102 -0
  85. package/src/page-server-orpc/hub-mcp-client.ts +20 -0
  86. package/src/page-server-orpc/portal-diagnostics-router.ts +170 -0
  87. package/src/page-server-orpc/puck-pages-router.ts +272 -0
  88. package/src/page-server-orpc/server-client.ts +31 -0
  89. package/src/page-server-orpc/templates-router.ts +116 -0
  90. package/src/page-server-orpc/user-preferences-router.ts +132 -0
  91. package/src/pg-boss-handler-registry.ts +36 -0
  92. package/src/pg-boss-mount.ts +295 -0
  93. package/src/proposal-authorized-emails.ts +65 -0
  94. package/src/proposal-chat-inject.ts +141 -0
  95. package/src/proposal-gate.ts +175 -0
  96. package/src/read-html-template.test.ts +74 -0
  97. package/src/read-html-template.ts +102 -0
  98. package/src/read-viewport-from-request.ts +36 -0
  99. package/src/readiness-gate.ts +39 -0
  100. package/src/register-api-routes.ts +127 -0
  101. package/src/register-crash-handlers.ts +39 -0
  102. package/src/register-page-routes.ts +62 -0
  103. package/src/register-page-server-client.ts +109 -0
  104. package/src/register-registry-page-route/ai-chat-prefetch.ts +106 -0
  105. package/src/register-registry-page-route/graph-cache.test.ts +84 -0
  106. package/src/register-registry-page-route/graph-cache.ts +90 -0
  107. package/src/register-registry-page-route/meta-title.ts +73 -0
  108. package/src/register-registry-page-route/proposal-approval-email-token.ts +78 -0
  109. package/src/register-registry-page-route/proposal-brand-stamping.ts +60 -0
  110. package/src/register-registry-page-route/resolve-page-data.ts +518 -0
  111. package/src/register-registry-page-route.ts +765 -0
  112. package/src/register-static-assets.ts +180 -0
  113. package/src/register-ws-routes.ts +180 -0
  114. package/src/resolve-app-base-url.ts +28 -0
  115. package/src/resolve-brand-favicon.ts +65 -0
  116. package/src/resolve-from-loader-config.test.ts +44 -0
  117. package/src/resolve-from-loader-config.ts +291 -0
  118. package/src/resolve-service-context.ts +67 -0
  119. package/src/resolve-theme-mode.ts +61 -0
  120. package/src/resolvers/fetch-org-brand.ts +28 -0
  121. package/src/resolvers/portal-route-paths.test.ts +102 -0
  122. package/src/resolvers/portal-route-paths.ts +83 -0
  123. package/src/resolvers/website-by-host-map.ts +49 -0
  124. package/src/resource-chat-inject.ts +168 -0
  125. package/src/resource-not-found.ts +263 -0
  126. package/src/run-boot-hook-list.ts +75 -0
  127. package/src/run-boot-hooks.ts +97 -0
  128. package/src/scala-tools-currency-watchdog.ts +160 -0
  129. package/src/security-headers.ts +59 -0
  130. package/src/serve/serve-ws.test.ts +135 -0
  131. package/src/serve/serve.ts +190 -0
  132. package/src/server-error-page.test.ts +102 -0
  133. package/src/server-error-page.ts +95 -0
  134. package/src/start-scheduled-jobs.ts +84 -0
  135. package/src/two-phase-boot.ts +449 -0
  136. package/src/types.ts +52 -0
  137. package/src/ui-service.ts +171 -0
  138. package/src/ws-boot-self-test.ts +114 -0
@@ -0,0 +1,118 @@
1
+ /**
2
+ * @system service-boot
3
+ * @status handwritten
4
+ * @edit edit directly
5
+ *
6
+ * Regression test for the new-flow agreement gate's body-region targeting.
7
+ * The body region of the public sign shell IS resolved.page (composed by
8
+ * register-registry-page-route.ts Branch 2 as extractPuckData(resolved.page)).
9
+ * A prior version of getBodyContentArray scored every region by top-level
10
+ * non-shell block count and picked the highest — which misruted to /header when
11
+ * the body wrapped its clauses inside a Container (body top-level count ~1-2
12
+ * vs nested clause count ~40). onUnauthorized then cleared the HEADER and
13
+ * injected the gate there, leaving the entire agreement body visible past the
14
+ * gate. This test pins the fix: the body is withheld, the header is untouched.
15
+ */
16
+
17
+ import { describe, expect, test } from "bun:test";
18
+ import { agreementGateConfig } from "./agreement-gate.ts";
19
+
20
+ const AGREEMENT_UUID = "019ecae8-518d-7000-8786-7255ca8716eb";
21
+
22
+ /** A resolved graph shaped like the real sign shell at the failing case:
23
+ * body wraps its clauses in a Container (low top-level score), header has more
24
+ * top-level blocks (would out-score the body under the old heuristic). */
25
+ function makeResolved(): Record<string, unknown> {
26
+ return {
27
+ page: {
28
+ id: "page-1",
29
+ meta_title: "Demo Agreement",
30
+ name: "Demo Agreement",
31
+ puck_data: {
32
+ root: { props: {} },
33
+ zones: {},
34
+ content: [
35
+ {
36
+ type: "Container",
37
+ props: {
38
+ id: "body-container",
39
+ content: [
40
+ { type: "Text", props: { id: "t1", text: "1. Parties" } },
41
+ { type: "Text", props: { id: "t2", text: "16. Electronic Signature" } },
42
+ { type: "Text", props: { id: "t3", text: "Scope of Services & Fees" } },
43
+ ],
44
+ },
45
+ },
46
+ ],
47
+ },
48
+ },
49
+ header: {
50
+ id: "header-page",
51
+ puck_data: {
52
+ root: { props: {} },
53
+ zones: {},
54
+ // 4 top-level blocks — MORE than the body's single Container. The
55
+ // old scorer picked this region as the "body" and cleared it.
56
+ content: [
57
+ { type: "OrgLogo", props: { id: "logo" } },
58
+ { type: "Text", props: { id: "h1", text: "Brand" } },
59
+ { type: "Text", props: { id: "h2", text: "Nav A" } },
60
+ { type: "Text", props: { id: "h3", text: "Nav B" } },
61
+ ],
62
+ },
63
+ },
64
+ footer: {
65
+ id: "footer-page",
66
+ puck_data: {
67
+ root: { props: {} },
68
+ zones: {},
69
+ content: [{ type: "Text", props: { id: "f1", text: "© 2026" } }],
70
+ },
71
+ },
72
+ };
73
+ }
74
+
75
+ describe("agreement-gate — body-region targeting", () => {
76
+ test("onUnauthorized withholds the BODY (resolved.page), not the header", async () => {
77
+ const resolved = makeResolved();
78
+ const bodyContent = (
79
+ (resolved.page as { puck_data: { content: unknown[] } }).puck_data
80
+ .content
81
+ );
82
+ const headerContent = (
83
+ (resolved.header as { puck_data: { content: unknown[] } }).puck_data
84
+ .content
85
+ );
86
+
87
+ await agreementGateConfig.onUnauthorized(resolved, AGREEMENT_UUID);
88
+
89
+ // Body is reduced to the injected SignIn gate — clauses are NOT leaked.
90
+ expect(bodyContent).toHaveLength(1);
91
+ const gate = bodyContent[0] as {
92
+ type: string;
93
+ props: { mode?: string; gateContextValue?: string };
94
+ };
95
+ expect(gate.type).toBe("SignIn");
96
+ expect(gate.props.mode).toBe("gate");
97
+ expect(gate.props.gateContextValue).toBe(AGREEMENT_UUID);
98
+
99
+ // Header is untouched — the old bug cleared this region instead.
100
+ expect(headerContent).toHaveLength(4);
101
+ expect((headerContent[0] as { type: string }).type).toBe("OrgLogo");
102
+ });
103
+
104
+ test("onUnauthorized leaves no agreement body text reachable past the gate", async () => {
105
+ const resolved = makeResolved();
106
+ await agreementGateConfig.onUnauthorized(resolved, AGREEMENT_UUID);
107
+
108
+ const bodyContent = (
109
+ (resolved.page as { puck_data: { content: unknown[] } }).puck_data
110
+ .content
111
+ );
112
+ // The clause text must not survive anywhere in the withheld body tree.
113
+ const serialized = JSON.stringify(bodyContent);
114
+ expect(serialized).not.toContain("Parties");
115
+ expect(serialized).not.toContain("Electronic Signature");
116
+ expect(serialized).not.toContain("Scope of Services");
117
+ });
118
+ });