@fuzdev/fuz_app 0.163.0 → 0.164.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/README.md +2 -1
  2. package/dist/actions/action_event_data.d.ts +1 -1
  3. package/dist/actions/action_rpc.d.ts.map +1 -1
  4. package/dist/actions/action_rpc.js +4 -0
  5. package/dist/actions/action_spec.d.ts +3 -3
  6. package/dist/actions/action_spec.d.ts.map +1 -1
  7. package/dist/auth/CLAUDE.md +1 -1
  8. package/dist/auth/account_route_schema.d.ts +3 -27
  9. package/dist/auth/account_route_schema.d.ts.map +1 -1
  10. package/dist/auth/account_route_schema.js +6 -20
  11. package/dist/auth/admin_action_specs.d.ts +56 -56
  12. package/dist/auth/audit_log_route_schema.d.ts +1 -1
  13. package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
  14. package/dist/auth/audit_log_route_schema.js +4 -5
  15. package/dist/auth/audit_log_schema.d.ts +18 -18
  16. package/dist/auth/bootstrap_route_schema.d.ts +1 -30
  17. package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
  18. package/dist/auth/bootstrap_route_schema.js +3 -8
  19. package/dist/auth/daemon_token.d.ts +4 -4
  20. package/dist/auth/daemon_token.d.ts.map +1 -1
  21. package/dist/auth/daemon_token.js +3 -3
  22. package/dist/auth/daemon_token_middleware.d.ts +1 -1
  23. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  24. package/dist/auth/daemon_token_middleware.js +5 -5
  25. package/dist/auth/middleware.js +4 -4
  26. package/dist/auth/role_grant_offer_action_specs.d.ts +2 -2
  27. package/dist/auth/signup_route_schema.d.ts.map +1 -1
  28. package/dist/auth/signup_route_schema.js +3 -7
  29. package/dist/db/CLAUDE.md +2 -1
  30. package/dist/db/file_fact_url.d.ts +11 -6
  31. package/dist/db/file_fact_url.d.ts.map +1 -1
  32. package/dist/db/file_fact_url.js +5 -5
  33. package/dist/db/schema_ready.d.ts +0 -5
  34. package/dist/db/schema_ready.d.ts.map +1 -1
  35. package/dist/db/schema_ready.js +0 -5
  36. package/dist/http/CLAUDE.md +104 -71
  37. package/dist/http/auth_shape.d.ts +48 -29
  38. package/dist/http/auth_shape.d.ts.map +1 -1
  39. package/dist/http/auth_shape.js +12 -85
  40. package/dist/http/body_limit.d.ts +12 -0
  41. package/dist/http/body_limit.d.ts.map +1 -1
  42. package/dist/http/body_limit.js +15 -0
  43. package/dist/http/body_limit_schema.d.ts +20 -0
  44. package/dist/http/body_limit_schema.d.ts.map +1 -0
  45. package/dist/http/body_limit_schema.js +20 -0
  46. package/dist/http/common_routes.d.ts +1 -1
  47. package/dist/http/common_routes.d.ts.map +1 -1
  48. package/dist/http/common_routes.js +11 -14
  49. package/dist/http/db_routes.d.ts.map +1 -1
  50. package/dist/http/db_routes.js +59 -69
  51. package/dist/http/dev_route_error_check.d.ts +70 -0
  52. package/dist/http/dev_route_error_check.d.ts.map +1 -0
  53. package/dist/http/dev_route_error_check.js +119 -0
  54. package/dist/http/error_schemas.d.ts +365 -189
  55. package/dist/http/error_schemas.d.ts.map +1 -1
  56. package/dist/http/error_schemas.js +256 -149
  57. package/dist/http/health_schema.d.ts +10 -6
  58. package/dist/http/health_schema.d.ts.map +1 -1
  59. package/dist/http/health_schema.js +3 -3
  60. package/dist/http/middleware_spec.d.ts +8 -3
  61. package/dist/http/middleware_spec.d.ts.map +1 -1
  62. package/dist/http/origin.d.ts +12 -43
  63. package/dist/http/origin.d.ts.map +1 -1
  64. package/dist/http/origin.js +10 -6
  65. package/dist/http/route_error_check.d.ts +158 -0
  66. package/dist/http/route_error_check.d.ts.map +1 -0
  67. package/dist/http/route_error_check.js +247 -0
  68. package/dist/http/route_errors.d.ts +80 -0
  69. package/dist/http/route_errors.d.ts.map +1 -0
  70. package/dist/http/route_errors.js +83 -0
  71. package/dist/http/route_spec.d.ts +33 -17
  72. package/dist/http/route_spec.d.ts.map +1 -1
  73. package/dist/http/route_spec.js +48 -62
  74. package/dist/http/schema_helpers.d.ts +0 -33
  75. package/dist/http/schema_helpers.d.ts.map +1 -1
  76. package/dist/http/schema_helpers.js +0 -45
  77. package/dist/http/surface.d.ts +19 -12
  78. package/dist/http/surface.d.ts.map +1 -1
  79. package/dist/http/surface.js +25 -38
  80. package/dist/http/surface_query.d.ts +11 -2
  81. package/dist/http/surface_query.d.ts.map +1 -1
  82. package/dist/http/surface_query.js +7 -1
  83. package/dist/primitive_schemas_fuz.d.ts +17 -3
  84. package/dist/primitive_schemas_fuz.d.ts.map +1 -1
  85. package/dist/primitive_schemas_fuz.js +13 -3
  86. package/dist/rate_limiter.d.ts +13 -0
  87. package/dist/rate_limiter.d.ts.map +1 -1
  88. package/dist/rate_limiter.js +20 -2
  89. package/dist/schema_issues.d.ts +29 -11
  90. package/dist/schema_issues.d.ts.map +1 -1
  91. package/dist/schema_issues.js +11 -10
  92. package/dist/schema_meta.d.ts +8 -1
  93. package/dist/schema_meta.d.ts.map +1 -1
  94. package/dist/schema_meta.js +2 -1
  95. package/dist/server/app_server.d.ts +3 -1
  96. package/dist/server/app_server.d.ts.map +1 -1
  97. package/dist/server/app_server.js +24 -10
  98. package/dist/server/serve_fact_route.d.ts.map +1 -1
  99. package/dist/server/serve_fact_route.js +8 -31
  100. package/dist/server/surface_route.d.ts.map +1 -1
  101. package/dist/server/surface_route.js +5 -6
  102. package/dist/server/x_accel.d.ts +12 -7
  103. package/dist/server/x_accel.d.ts.map +1 -1
  104. package/dist/server/x_accel.js +7 -9
  105. package/dist/testing/CLAUDE.md +33 -39
  106. package/dist/testing/admin_integration.js +1 -1
  107. package/dist/testing/adversarial_404.d.ts +4 -18
  108. package/dist/testing/adversarial_404.d.ts.map +1 -1
  109. package/dist/testing/adversarial_404.js +19 -51
  110. package/dist/testing/adversarial_headers.d.ts +3 -4
  111. package/dist/testing/adversarial_headers.d.ts.map +1 -1
  112. package/dist/testing/adversarial_headers.js +8 -6
  113. package/dist/testing/adversarial_input.d.ts.map +1 -1
  114. package/dist/testing/adversarial_input.js +18 -17
  115. package/dist/testing/assertions.d.ts +33 -11
  116. package/dist/testing/assertions.d.ts.map +1 -1
  117. package/dist/testing/assertions.js +52 -12
  118. package/dist/testing/attack_surface.d.ts +5 -35
  119. package/dist/testing/attack_surface.d.ts.map +1 -1
  120. package/dist/testing/attack_surface.js +29 -91
  121. package/dist/testing/auth_apps.d.ts.map +1 -1
  122. package/dist/testing/auth_apps.js +2 -1
  123. package/dist/testing/cross_backend/action_manifest.d.ts +126 -56
  124. package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
  125. package/dist/testing/cross_backend/action_manifest.js +11 -11
  126. package/dist/testing/cross_backend/action_manifest_parity.d.ts +1 -1
  127. package/dist/testing/cross_backend/action_manifest_parity.d.ts.map +1 -1
  128. package/dist/testing/cross_backend/cell_crud.d.ts.map +1 -1
  129. package/dist/testing/cross_backend/cell_crud.js +2 -1
  130. package/dist/testing/cross_backend/conformance_table.js +1 -1
  131. package/dist/testing/cross_backend/fact_serving.js +3 -3
  132. package/dist/testing/cross_backend/origin_conformance.d.ts +278 -102
  133. package/dist/testing/cross_backend/origin_conformance.d.ts.map +1 -1
  134. package/dist/testing/cross_backend/origin_conformance.js +21 -21
  135. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
  136. package/dist/testing/cross_backend/rust_spine_consumer_surface.js +7 -1
  137. package/dist/testing/cross_backend/setup.d.ts +13 -0
  138. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  139. package/dist/testing/cross_backend/setup.js +24 -7
  140. package/dist/testing/cross_backend/testing_origin_check.d.ts +147 -71
  141. package/dist/testing/cross_backend/testing_origin_check.d.ts.map +1 -1
  142. package/dist/testing/cross_backend/testing_origin_check.js +16 -13
  143. package/dist/testing/cross_backend/testing_reset_actions.d.ts +70 -27
  144. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  145. package/dist/testing/data_exposure.d.ts.map +1 -1
  146. package/dist/testing/data_exposure.js +5 -4
  147. package/dist/testing/error_coverage.d.ts +24 -34
  148. package/dist/testing/error_coverage.d.ts.map +1 -1
  149. package/dist/testing/error_coverage.js +46 -89
  150. package/dist/testing/integration.d.ts.map +1 -1
  151. package/dist/testing/integration.js +5 -13
  152. package/dist/testing/integration_helpers.d.ts +37 -9
  153. package/dist/testing/integration_helpers.d.ts.map +1 -1
  154. package/dist/testing/integration_helpers.js +86 -40
  155. package/dist/testing/middleware.d.ts +3 -5
  156. package/dist/testing/middleware.d.ts.map +1 -1
  157. package/dist/testing/middleware.js +5 -4
  158. package/dist/testing/rate_limiting.d.ts +1 -1
  159. package/dist/testing/rate_limiting.d.ts.map +1 -1
  160. package/dist/testing/rate_limiting.js +5 -4
  161. package/dist/testing/round_trip.d.ts.map +1 -1
  162. package/dist/testing/round_trip.js +5 -3
  163. package/dist/testing/schema_generators.d.ts +10 -3
  164. package/dist/testing/schema_generators.d.ts.map +1 -1
  165. package/dist/testing/schema_generators.js +23 -11
  166. package/dist/testing/stubs.d.ts +10 -1
  167. package/dist/testing/stubs.d.ts.map +1 -1
  168. package/dist/testing/stubs.js +15 -5
  169. package/dist/testing/surface_invariants.d.ts +36 -115
  170. package/dist/testing/surface_invariants.d.ts.map +1 -1
  171. package/dist/testing/surface_invariants.js +106 -269
  172. package/dist/ui/CLAUDE.md +4 -2
  173. package/dist/ui/auth_state.svelte.d.ts.map +1 -1
  174. package/dist/ui/auth_state.svelte.js +2 -8
  175. package/dist/ui/backend_probe.svelte.js +3 -3
  176. package/dist/ui/table_state.svelte.d.ts.map +1 -1
  177. package/dist/ui/table_state.svelte.js +1 -8
  178. package/dist/ui/ui_fetch.d.ts +12 -2
  179. package/dist/ui/ui_fetch.d.ts.map +1 -1
  180. package/dist/ui/ui_fetch.js +22 -4
  181. package/package.json +1 -1
@@ -15,9 +15,9 @@ import './assert_dev_env.js';
15
15
  */
16
16
  import { vi } from 'vitest';
17
17
  import { Hono } from 'hono';
18
- import type { z } from 'zod';
19
18
  import { type RequestContext } from '../auth/request_context.js';
20
19
  import type { TokenScope } from '../auth/token_scope.js';
20
+ import type { RestErrorDef } from '../http/error_schemas.js';
21
21
  /** Mock configuration for bearer auth middleware test setup. */
22
22
  export interface BearerAuthTestOptions {
23
23
  /** Test description. */
@@ -36,10 +36,8 @@ export interface BearerAuthTestOptions {
36
36
  mock_role_grants_result?: unknown;
37
37
  /** Expected HTTP status, or `'next'` if the middleware should call `next()`. */
38
38
  expected_status: number | 'next';
39
- /** Expected `error` field in JSON response body. */
40
- expected_error?: string;
41
- /** Zod schema to validate error response body against. Defaults to `ApiError` when `expected_error` is set. */
42
- expected_error_schema?: z.ZodType;
39
+ /** The error definition the JSON body must be — its code, and a body its schema accepts. */
40
+ expected_error?: RestErrorDef;
43
41
  }
44
42
  /** A full test case for the table-driven bearer auth runner. */
45
43
  export interface BearerAuthTestCase extends BearerAuthTestOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,EAAE,EAA0B,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAoB7B,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAOtF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAsBzD,gEAAgE;AAChE,MAAM,WAAW,qBAAqB;IACrC,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,oEAAoE;IACpE,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B,iDAAiD;IACjD,oBAAoB,CAAC,EAAE,OAAO,CAA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AC,MAAM,CAAC,CAAC;IAChC,oFAAoF;IACpF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,6DAA6D;IAC7D,aAAa,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC;CACpD;AAED,yDAAyD;AACzD,MAAM,WAAW,sBAAsB;IACtC,GAAG,EAAE,IAAI,CAAC;IACV,aAAa,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IACxC,eAAe,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IAC1C,qBAAqB,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IAChD,2BAA2B,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IACtD,0BAA0B,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;CACrD;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gCAAgC,GAC5C,UAAU,0BAA0B,KAClC,sBA4DF,CAAC"}
@@ -28,7 +28,7 @@ import { REQUEST_CONTEXT_KEY } from '../auth/request_context.js';
28
28
  import { RESOLVED_AUTH_KEY, TEST_CONTEXT_PRESET, TEST_CONTEXT_PRESET_KEY } from '../hono_context.js';
29
29
  import { get_resolved_auth } from '../auth/resolved_auth.js';
30
30
  import { create_test_resolved_auth } from './resolved_auth.js';
31
- import { ApiError } from '../http/error_schemas.js';
31
+ import { parse_any } from '../schema_issues.js';
32
32
  // Mock the query modules so test cases can control return values.
33
33
  // vi.mock() is hoisted by vitest, so these run before any imports resolve.
34
34
  vi.mock('../auth/api_token_queries.js', () => ({
@@ -175,9 +175,10 @@ export const describe_bearer_auth_cases = (suite_name, cases) => {
175
175
  else {
176
176
  assert.strictEqual(res.status, tc.expected_status);
177
177
  if (tc.expected_error) {
178
- assert.strictEqual(body.error, tc.expected_error);
179
- const error_schema = tc.expected_error_schema ?? ApiError;
180
- error_schema.parse(body);
178
+ assert.strictEqual(body.error, tc.expected_error.code);
179
+ assert.strictEqual(res.status, tc.expected_error.status);
180
+ const parsed = parse_any(tc.expected_error.schema, body);
181
+ assert.ok(parsed.ok, `error body fails its schema: ${JSON.stringify(body)}`);
181
182
  }
182
183
  }
183
184
  if (tc.validate_expectation === 'not_called') {
@@ -41,7 +41,7 @@ export interface RateLimitingTestOptions {
41
41
  *
42
42
  * Creates 2 test groups:
43
43
  * 1. IP rate limiting on login — fires `max_attempts + 1` login requests,
44
- * verifies the last returns 429 with a valid `RateLimitError` body.
44
+ * verifies the last returns 429 with a valid `REST_RATE_LIMIT_EXCEEDED` body.
45
45
  * 2. Per-account rate limiting on login — fires `max_attempts + 1` login
46
46
  * requests with the same username, verifies the last returns 429.
47
47
  *
@@ -1 +1 @@
1
- {"version":3,"file":"rate_limiting.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/rate_limiting.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AA0B7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIvD,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAExE,OAAO,EAIN,KAAK,SAAS,EACd,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAIhE;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,4CAA4C;IAC5C,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,wDAAwD;IACxD,kBAAkB,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IAChE,iDAAiD;IACjD,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B;;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,uBAAuB,KAAG,IA2J/E,CAAC"}
@@ -21,8 +21,9 @@ import './assert_dev_env.js';
21
21
  * @module
22
22
  */
23
23
  import { describe, test, assert } from 'vitest';
24
+ import { parse_or_throw } from '@fuzdev/fuz_schema/schema.ts';
24
25
  import { RateLimiter } from '../rate_limiter.js';
25
- import { RateLimitError } from '../http/error_schemas.js';
26
+ import { REST_RATE_LIMIT_EXCEEDED } from '../http/error_schemas.js';
26
27
  import { AUTH_MIGRATION_NS } from '../auth/migrations.js';
27
28
  import { create_test_app } from './app_server.js';
28
29
  import { create_test_request_headers } from './test_origin.js';
@@ -34,7 +35,7 @@ import { run_migrations } from '../db/migrate.js';
34
35
  *
35
36
  * Creates 2 test groups:
36
37
  * 1. IP rate limiting on login — fires `max_attempts + 1` login requests,
37
- * verifies the last returns 429 with a valid `RateLimitError` body.
38
+ * verifies the last returns 429 with a valid `REST_RATE_LIMIT_EXCEEDED` body.
38
39
  * 2. Per-account rate limiting on login — fires `max_attempts + 1` login
39
40
  * requests with the same username, verifies the last returns 429.
40
41
  *
@@ -94,7 +95,7 @@ export const describe_rate_limiting_tests = (options) => {
94
95
  });
95
96
  assert.strictEqual(blocked_res.status, 429);
96
97
  const body = await blocked_res.json();
97
- RateLimitError.parse(body);
98
+ parse_or_throw(REST_RATE_LIMIT_EXCEEDED.schema, body);
98
99
  assert.ok(typeof body.retry_after === 'number' && body.retry_after > 0, 'Expected positive retry_after');
99
100
  assert_rate_limit_retry_after_header(blocked_res, body);
100
101
  }
@@ -143,7 +144,7 @@ export const describe_rate_limiting_tests = (options) => {
143
144
  });
144
145
  assert.strictEqual(blocked_res.status, 429);
145
146
  const body = await blocked_res.json();
146
- RateLimitError.parse(body);
147
+ parse_or_throw(REST_RATE_LIMIT_EXCEEDED.schema, body);
147
148
  assert.ok(typeof body.retry_after === 'number' && body.retry_after > 0, 'Expected positive retry_after');
148
149
  assert_rate_limit_retry_after_header(blocked_res, body);
149
150
  // A different username should NOT be rate limited
@@ -1 +1 @@
1
- {"version":3,"file":"round_trip.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AA6B7B,OAAO,EAON,KAAK,aAAa,EAClB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,oDAAoD;AACpD,MAAM,WAAW,oBAAoB;IACpC;;;;;OAKG;IACH,UAAU,EAAE,SAAS,CAAC;IACtB;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B,kDAAkD;IAClD,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,+EAA+E;IAC/E,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACvD;;;;;;;;;;;;;OAaG;IACH,gBAAgB,CAAC,EAAE,GAAG,CACrB,MAAM,EACN,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CACnF,CAAC;CACF;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,0BAA0B,GACtC,WAAW,MAAM,EACjB,QAAQ,MAAM,EACd,MAAM,OAAO,EACb,WAAW,aAAa,KACtB,IAUF,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,8BAA8B,GAAI,SAAS,oBAAoB,KAAG,IAmJ9E,CAAC"}
1
+ {"version":3,"file":"round_trip.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AA8B7B,OAAO,EAON,KAAK,aAAa,EAClB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,oDAAoD;AACpD,MAAM,WAAW,oBAAoB;IACpC;;;;;OAKG;IACH,UAAU,EAAE,SAAS,CAAC;IACtB;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B,kDAAkD;IAClD,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,+EAA+E;IAC/E,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACvD;;;;;;;;;;;;;OAaG;IACH,gBAAgB,CAAC,EAAE,GAAG,CACrB,MAAM,EACN,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CACnF,CAAC;CACF;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,0BAA0B,GACtC,WAAW,MAAM,EACjB,QAAQ,MAAM,EACd,MAAM,OAAO,EACb,WAAW,aAAa,KACtB,IAUF,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,8BAA8B,GAAI,SAAS,oBAAoB,KAAG,IAgK9E,CAAC"}
@@ -22,6 +22,7 @@ import './assert_dev_env.js';
22
22
  */
23
23
  import { describe, test, beforeAll, assert } from 'vitest';
24
24
  import { ROLE_ADMIN } from '../auth/role_schema.js';
25
+ import { format_route_key } from '../http/surface_query.js';
25
26
  import { needs_actor, input_schema_declares_acting } from '../http/auth_shape.js';
26
27
  import { assert_response_matches_spec, is_unauthenticated_refusal, pick_auth_headers, pick_auth_principal, round_trip_uses_fresh_account, to_principal_headers } from './integration_helpers.js';
27
28
  import { resolve_valid_path, generate_valid_body, to_route_content_type } from './schema_generators.js';
@@ -64,6 +65,7 @@ export const assert_route_authenticated = (route_key, status, body, principal) =
64
65
  */
65
66
  export const describe_round_trip_validation = (options) => {
66
67
  const describe_time_specs = options.surface_source.route_specs;
68
+ const route_error_maps = options.surface_source.route_error_maps;
67
69
  const skip_set = new Set(options.skip_routes);
68
70
  describe('round-trip validation', () => {
69
71
  let fixture;
@@ -99,7 +101,7 @@ export const describe_round_trip_validation = (options) => {
99
101
  }
100
102
  };
101
103
  test.each(describe_time_specs)('$method $path produces schema-valid response', async (spec) => {
102
- const route_key = `${spec.method} ${spec.path}`;
104
+ const route_key = format_route_key(spec);
103
105
  if (skip_set.has(route_key))
104
106
  return;
105
107
  // Raw-byte / streaming routes (git smart-HTTP, binary upload/download)
@@ -150,7 +152,7 @@ export const describe_round_trip_validation = (options) => {
150
152
  .catch(() => undefined);
151
153
  assert_route_authenticated(route_key, res.status, body, principal);
152
154
  }
153
- await assert_response_matches_spec(describe_time_specs, spec.method, url, res);
155
+ await assert_response_matches_spec(describe_time_specs, spec.method, url, res, route_error_maps);
154
156
  }
155
157
  catch (e) {
156
158
  throw new Error(`Round-trip validation failed for ${route_key} (status ${res.status}): ${e.message}`);
@@ -180,7 +182,7 @@ export const describe_round_trip_validation = (options) => {
180
182
  .clone()
181
183
  .text()
182
184
  .catch(() => '<unreadable>')}`);
183
- await assert_response_matches_spec(describe_time_specs, spec.method, url, res);
185
+ await assert_response_matches_spec(describe_time_specs, spec.method, url, res, route_error_maps);
184
186
  }
185
187
  catch (e) {
186
188
  throw new Error(`Round-trip success-fixture failed for ${route_key} (status ${res.status}): ${e.message}`);
@@ -171,8 +171,14 @@ export declare const to_route_content_type: (route: {
171
171
  * Resolve a route path with valid-ish param values so params validation passes.
172
172
  * Used when testing input on routes that also have params.
173
173
  *
174
+ * The template is read as Hono reads it (`split_route_template`,
175
+ * `parse_route_param`): only a whole param segment — `:name` or `:name{re}`,
176
+ * optional or not — is filled, so a `:` inside a literal segment
177
+ * (`/v1/files:upload`) stays, and a `{re}` goes with its param. An optional
178
+ * param is filled too.
179
+ *
174
180
  * Without a params schema (or for a param the schema doesn't name) each
175
- * `:name` becomes `test_<name>` — fine for an unconstrained segment. With
181
+ * param becomes `test_<name>` — fine for an unconstrained segment. With
176
182
  * one, `test_<name>` is still preferred wherever the field schema accepts
177
183
  * it, because the param name in the URL is what makes a failure message
178
184
  * readable. Only a segment that refuses it falls through: a `uuid` param
@@ -180,13 +186,14 @@ export declare const to_route_content_type: (route: {
180
186
  * anything else is synthesized by `generate_valid_string`, so a
181
187
  * format-constrained segment (a `blake3:…` fact hash, a `tok_…` id)
182
188
  * resolves to a value its schema accepts instead of a `test_<name>` that
183
- * 400s before the route's real gates run.
189
+ * 400s before the route's real gates run. A `{re}` is not read: the value
190
+ * comes from the schema alone.
184
191
  *
185
192
  * The synthesized value is percent-encoded, and a value containing `/` is
186
193
  * refused (it would silently add a path segment and route elsewhere) —
187
194
  * both fall back to `test_<name>`.
188
195
  *
189
- * @param path - the route path, its params as `:name`
196
+ * @param path - the route's path template
190
197
  * @param params_schema - the route's params schema, a Zod or `@fuzdev/fuz_schema` object schema
191
198
  * @throws Error when `params_schema` is no object schema, or of neither library
192
199
  */
@@ -1 +1 @@
1
- {"version":3,"file":"schema_generators.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/schema_generators.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAsB7B,OAAO,EAKN,KAAK,eAAe,EACpB,MAAM,WAAW,CAAC;AAGnB,OAAO,EAIN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,oBAAoB,GAAI,cAAc,gBAAgB,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAe3F,CAAC;AAEF;;;;;;;;;GAS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;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,EAAE,gBAAgB,gBAAgB,KAAG,MAqBnF,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,GAC/B,cAAc,gBAAgB,KAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAW5B,CAAC"}
@@ -16,6 +16,7 @@ import { get_schema_entries, get_schema_fields, unwrap_schema } from '@fuzdev/fu
16
16
  import { to_json_schema } from '@fuzdev/fuz_schema/json_schema.ts';
17
17
  import { zod_unwrap_def, zod_get_base_type, zod_unwrap_to_object, zod_extract_fields } from '../zod.js';
18
18
  import { is_null_schema, is_void_schema } from '../http/schema_helpers.js';
19
+ import { parse_route_param, split_route_template } from '../http/route_error_check.js';
19
20
  import { assert_zod_schema, format_issues, parse_any } from '../schema_issues.js';
20
21
  /**
21
22
  * The JSON Schema of a field's input side — where its format, pattern and
@@ -663,8 +664,14 @@ export const to_route_content_type = (route) => route.raw_body ? 'application/oc
663
664
  * Resolve a route path with valid-ish param values so params validation passes.
664
665
  * Used when testing input on routes that also have params.
665
666
  *
667
+ * The template is read as Hono reads it (`split_route_template`,
668
+ * `parse_route_param`): only a whole param segment — `:name` or `:name{re}`,
669
+ * optional or not — is filled, so a `:` inside a literal segment
670
+ * (`/v1/files:upload`) stays, and a `{re}` goes with its param. An optional
671
+ * param is filled too.
672
+ *
666
673
  * Without a params schema (or for a param the schema doesn't name) each
667
- * `:name` becomes `test_<name>` — fine for an unconstrained segment. With
674
+ * param becomes `test_<name>` — fine for an unconstrained segment. With
668
675
  * one, `test_<name>` is still preferred wherever the field schema accepts
669
676
  * it, because the param name in the URL is what makes a failure message
670
677
  * readable. Only a segment that refuses it falls through: a `uuid` param
@@ -672,27 +679,27 @@ export const to_route_content_type = (route) => route.raw_body ? 'application/oc
672
679
  * anything else is synthesized by `generate_valid_string`, so a
673
680
  * format-constrained segment (a `blake3:…` fact hash, a `tok_…` id)
674
681
  * resolves to a value its schema accepts instead of a `test_<name>` that
675
- * 400s before the route's real gates run.
682
+ * 400s before the route's real gates run. A `{re}` is not read: the value
683
+ * comes from the schema alone.
676
684
  *
677
685
  * The synthesized value is percent-encoded, and a value containing `/` is
678
686
  * refused (it would silently add a path segment and route elsewhere) —
679
687
  * both fall back to `test_<name>`.
680
688
  *
681
- * @param path - the route path, its params as `:name`
689
+ * @param path - the route's path template
682
690
  * @param params_schema - the route's params schema, a Zod or `@fuzdev/fuz_schema` object schema
683
691
  * @throws Error when `params_schema` is no object schema, or of neither library
684
692
  */
685
693
  export const resolve_valid_path = (path, params_schema) => {
686
- if (!params_schema) {
687
- return path.replace(/:(\w+)/g, 'test_$1');
688
- }
689
- const view = to_object_schema_view(params_schema, `resolve_valid_path(${path}): the params schema`);
690
- return path.replace(/:(\w+)/g, (_match, name) => {
691
- const fallback = `test_${name}`;
692
- const field_schema = view.field_schema(name);
694
+ const view = params_schema
695
+ ? to_object_schema_view(params_schema, `resolve_valid_path(${path}): the params schema`)
696
+ : null;
697
+ const fill = (name) => {
698
+ const fallback = encodeURIComponent(`test_${name}`);
699
+ const field_schema = view?.field_schema(name);
693
700
  if (!field_schema)
694
701
  return fallback;
695
- if (accepts(field_schema, fallback))
702
+ if (accepts(field_schema, `test_${name}`))
696
703
  return fallback;
697
704
  if (to_base_type(field_schema) === 'uuid')
698
705
  return NIL_UUID;
@@ -703,7 +710,12 @@ export const resolve_valid_path = (path, params_schema) => {
703
710
  if (generated.includes('/'))
704
711
  return fallback;
705
712
  return encodeURIComponent(generated);
713
+ };
714
+ const segments = split_route_template(path).map((segment) => {
715
+ const param = parse_route_param(segment);
716
+ return param ? fill(param.name) : segment;
706
717
  });
718
+ return (path.startsWith('/') ? '/' : '') + segments.join('/');
707
719
  };
708
720
  /**
709
721
  * Generate a valid request body for a route's or action's input schema.
@@ -207,6 +207,13 @@ export interface CreateTestAppSurfaceSpecOptions {
207
207
  * @default false
208
208
  */
209
209
  daemon_token?: boolean;
210
+ /**
211
+ * Symmetric with `AppServerOptions.max_body_size` — `null` leaves out the
212
+ * body limit's spec, which `create_app_server` mounts ahead of the other
213
+ * middleware unless the limit is disabled. Only whether it is `null` is
214
+ * read: the spec's handler here is a stub.
215
+ */
216
+ max_body_size?: number | null;
210
217
  }
211
218
  /**
212
219
  * Create an `AppSurfaceSpec` for the standard testing suites.
@@ -231,7 +238,9 @@ export interface CreateTestAppSurfaceSpecOptions {
231
238
  * one: a stub `trusted_proxy` spec at `'*'`, then the stub auth stack (with
232
239
  * `daemon_token` when `options.daemon_token` is set). If
233
240
  * `create_app_server` changes how it wires routes, update this helper
234
- * to stay in sync (single source of truth for all consumers).
241
+ * to stay in sync (single source of truth for all consumers). The body
242
+ * limit's spec heads the list unless `max_body_size` is `null`, as it does on
243
+ * the live server.
235
244
  *
236
245
  * @param options - surface spec options
237
246
  * @returns the surface spec for the standard suites
@@ -1 +1 @@
1
- {"version":3,"file":"stubs.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/stubs.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAa7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAErF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAs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AY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAmBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,4BAA4B,GACxC,SAAS,+BAA+B,KACtC,cA+GF,CAAC"}
@@ -8,7 +8,8 @@ import './assert_dev_env.js';
8
8
  * @module
9
9
  */
10
10
  import { Logger } from '@fuzdev/fuz_util/log.ts';
11
- import { ApiError } from '../http/error_schemas.js';
11
+ import { REST_FORBIDDEN_ORIGIN } from '../http/error_schemas.js';
12
+ import { body_limit_middleware_shape } from '../http/body_limit_schema.js';
12
13
  import { create_realtime_closer } from '../actions/connection_closer.js';
13
14
  import { Db } from '../db/db.js';
14
15
  import { prefix_route_specs } from '../http/route_spec.js';
@@ -188,7 +189,7 @@ export const create_stub_api_middleware = (options) => {
188
189
  name: 'origin',
189
190
  path: ORIGIN_MIDDLEWARE_PATH,
190
191
  handler: create_stub_mw(),
191
- errors: { 403: ApiError },
192
+ errors: [REST_FORBIDDEN_ORIGIN],
192
193
  ...(origin_carve_outs.length > 0 && { carve_outs: origin_carve_outs })
193
194
  },
194
195
  ...(options?.include_daemon_token
@@ -197,7 +198,7 @@ export const create_stub_api_middleware = (options) => {
197
198
  name: 'daemon_token',
198
199
  path: AUTH_MIDDLEWARE_PATH,
199
200
  handler: create_stub_mw(),
200
- errors: {}
201
+ errors: []
201
202
  }
202
203
  ]
203
204
  : []),
@@ -207,7 +208,7 @@ export const create_stub_api_middleware = (options) => {
207
208
  name: 'bearer_auth',
208
209
  path: AUTH_MIDDLEWARE_PATH,
209
210
  handler: create_stub_mw(),
210
- errors: {}
211
+ errors: []
211
212
  }
212
213
  ];
213
214
  return specs;
@@ -274,7 +275,9 @@ const assert_self_resolved_ws_origins = (endpoint) => {
274
275
  * one: a stub `trusted_proxy` spec at `'*'`, then the stub auth stack (with
275
276
  * `daemon_token` when `options.daemon_token` is set). If
276
277
  * `create_app_server` changes how it wires routes, update this helper
277
- * to stay in sync (single source of truth for all consumers).
278
+ * to stay in sync (single source of truth for all consumers). The body
279
+ * limit's spec heads the list unless `max_body_size` is `null`, as it does on
280
+ * the live server.
278
281
  *
279
282
  * @param options - surface spec options
280
283
  * @returns the surface spec for the standard suites
@@ -369,6 +372,13 @@ export const create_test_app_surface_spec = (options) => {
369
372
  middleware_specs = options.transform_middleware(stack_specs.map((spec) => ({ ...spec })));
370
373
  assert_middleware_stack_mounted(stack_specs, middleware_specs);
371
374
  }
375
+ // mirrors `create_app_server`'s body limit spec, ahead of the transformed stack
376
+ if (options.max_body_size !== null) {
377
+ middleware_specs = [
378
+ { ...body_limit_middleware_shape, handler: create_stub_mw() },
379
+ ...middleware_specs
380
+ ];
381
+ }
372
382
  const surface_spec = create_app_surface_spec({
373
383
  middleware_specs,
374
384
  route_specs,
@@ -15,15 +15,16 @@ export declare const assert_protected_routes_declare_401: (surface: AppSurface)
15
15
  */
16
16
  export declare const assert_role_routes_declare_403: (surface: AppSurface) => void;
17
17
  /**
18
- * Every route with non-null `input_schema` has 400 in `error_schemas`.
18
+ * Every route with a body — a non-null `input_schema` on a method other than
19
+ * `GET`, which reads no body — declares a 400 naming `invalid_request_body`.
19
20
  */
20
21
  export declare const assert_input_routes_declare_400: (surface: AppSurface) => void;
21
22
  /**
22
- * Every route with non-null `params_schema` has 400 in `error_schemas`.
23
+ * Every route with non-null `params_schema` declares a 400 naming `invalid_route_params`.
23
24
  */
24
25
  export declare const assert_params_routes_declare_400: (surface: AppSurface) => void;
25
26
  /**
26
- * Every route with non-null `query_schema` has 400 in `error_schemas`.
27
+ * Every route with non-null `query_schema` declares a 400 naming `invalid_query_params`.
27
28
  */
28
29
  export declare const assert_query_routes_declare_400: (surface: AppSurface) => void;
29
30
  /**
@@ -37,71 +38,45 @@ export declare const assert_no_duplicate_routes: (surface: AppSurface) => void;
37
38
  /**
38
39
  * Every applicable middleware that declares errors must have those status codes
39
40
  * present in the route's `error_schemas`.
41
+ *
42
+ * Holds by construction for a surface `generate_app_surface` builds: each
43
+ * route's error map (`resolve_route_error_map`) already unions every applying
44
+ * layer's definitions. It earns its place only on a surface built another
45
+ * way — a committed snapshot read back, or one written by hand.
40
46
  */
41
47
  export declare const assert_middleware_errors_propagated: (surface: AppSurface) => void;
42
48
  /**
43
- * Every route's declared error schemas must have an `error` field at the top level
44
- * (conforming to the `ApiError` base shape `{error: string}`).
45
- *
46
- * Walks union branches (`anyOf` from `z.union`, `oneOf` from
47
- * `z.discriminatedUnion`) so every emit shape inside a merged 400 / 404
48
- * is checked, not just the top-level wrapper.
49
+ * Every error a route or middleware layer declares names its code exactly:
50
+ * each body at each status (each branch of an `anyOf` or `oneOf`) is an
51
+ * object whose `error` is a `const` or an `enum` — what a definition built by
52
+ * `rest_error` writes. A bare string `error`, or a body with no `error`, is a
53
+ * contract a client can't key on.
49
54
  *
50
- * Catches typos in error schema definitions and ensures consumers can always
51
- * read `.error` from error responses.
55
+ * @throws AssertionError naming the route or layer, the status, and the body
52
56
  */
53
- export declare const assert_error_schemas_structurally_valid: (surface: AppSurface) => void;
57
+ export declare const assert_error_codes_specific: (surface: AppSurface) => void;
54
58
  /**
55
- * The same `z.literal()` error code should not appear at different HTTP status codes
56
- * across routes.
59
+ * Every declared `error` code is a code — `REST_ERROR_CODE_PATTERN`, a
60
+ * lowercase letter then lowercase letters, digits, and `_` — never prose,
61
+ * which belongs in `message`. `rest_error` refuses one off the pattern; this
62
+ * holds a surface built another way (a snapshot, a hand-written layer) to the
63
+ * same rule.
57
64
  *
58
- * Extracts `const` values from error schema `error` properties (which correspond to
59
- * `z.literal()` in the Zod source). Walks union branches (`anyOf` from `z.union`,
60
- * `oneOf` from `z.discriminatedUnion`) so literal codes nested inside merged unions
61
- * (e.g. validation 400 + actor-resolution 400) are still tracked. Flags when the
62
- * same literal appears at different status codes — e.g., `ERROR_INVALID_CREDENTIALS`
63
- * at both 401 and 403 would be a bug.
64
- *
65
- * Only checks `const` values (literal schemas). Generic `z.string()` schemas
66
- * (which produce `{type: 'string'}`) and `z.enum()` schemas are ignored — the
67
- * literal-only narrow keeps the check unambiguous.
65
+ * @throws AssertionError naming the route or layer, the status, and the code
68
66
  */
69
- export declare const assert_error_code_status_consistency: (surface: AppSurface) => void;
67
+ export declare const assert_error_codes_well_formed: (surface: AppSurface) => void;
70
68
  /**
71
- * Routes declaring 404 error schemas should use specific `z.literal()` or `z.enum()`
72
- * error codes, not generic `z.string()`.
73
- *
74
- * A generic 404 schema (`ApiError` with `z.string()`) means the error code is
75
- * unconstrained — the handler could return any string, making client error handling
76
- * fragile. Routes with params (`:id`) are the primary 404 producers; their error
77
- * schemas should use specific constants like `ERROR_ACCOUNT_NOT_FOUND`.
78
- *
79
- * Only flags routes that have `params_schema` (param-driven resource lookup) — routes
80
- * declaring 404 for other reasons (e.g., bootstrap not configured) may legitimately
81
- * use generic schemas.
69
+ * One error code at one HTTP status: the same code declared at two statuses
70
+ * across the surface's routes and middleware layers fails — e.g.
71
+ * `invalid_credentials` at both 401 and 403 would be a bug.
72
+ *
73
+ * Reads each body's `error` `const` (what `rest_error` writes), through every
74
+ * branch of an `anyOf` or `oneOf` — the surface writes a status with several
75
+ * definitions as an `anyOf` — and nested unions within them. An `error` with
76
+ * no `const` (an `enum`, a bare string) is not read; `assert_error_codes_specific`
77
+ * refuses the bare string.
82
78
  */
83
- export declare const assert_404_schemas_use_specific_errors: (surface: AppSurface) => void;
84
- /** Specificity level of an error schema's `error` field. */
85
- export type ErrorSchemaSpecificity = 'literal' | 'enum' | 'generic';
86
- /** A single entry in the error schema tightness audit report. */
87
- export interface ErrorSchemaAuditEntry {
88
- method: string;
89
- route_path: string;
90
- status: string;
91
- specificity: ErrorSchemaSpecificity;
92
- /** The literal value or enum values, if specific. */
93
- error_codes: Array<string> | null;
94
- }
95
- /**
96
- * Audit error schema tightness across all routes in a surface.
97
- *
98
- * Reports which route x status code combinations use generic `ApiError`
99
- * (`z.string()`) vs specific `z.literal()` or `z.enum()` error codes.
100
- * Use the output to prioritize progressive tightening of error schemas.
101
- *
102
- * @returns audit entries for every route x status combination
103
- */
104
- export declare const audit_error_schema_tightness: (surface: AppSurface) => Array<ErrorSchemaAuditEntry>;
79
+ export declare const assert_error_code_status_consistency: (surface: AppSurface) => void;
105
80
  /**
106
81
  * Every RPC method on every endpoint has a non-empty `description`.
107
82
  *
@@ -242,68 +217,14 @@ export declare const assert_mutation_routes_use_post: (surface: AppSurface) => v
242
217
  * (e.g., a keeper route at `/health` or `/admin/` instead of `/api/...`).
243
218
  */
244
219
  export declare const assert_keeper_routes_under_prefix: (surface: AppSurface, prefixes?: Array<string>) => void;
245
- /** Options for `assert_error_schema_tightness`. */
246
- export interface ErrorSchemaTightnessOptions {
247
- /** Minimum specificity level. Error schemas below this threshold fail. Default: `'enum'`. */
248
- min_specificity?: ErrorSchemaSpecificity;
249
- /** HTTP status codes to skip (e.g., middleware-injected codes). */
250
- ignore_statuses?: Array<number>;
251
- /** Routes to skip, in `'METHOD /path'` format. */
252
- allowlist?: Array<string>;
253
- }
254
- /**
255
- * Routes shipped by fuz_app whose error schemas require a tightness exemption.
256
- *
257
- * Currently empty — every fuz_app-shipped route (account login/password/
258
- * bootstrap/signup, db health/tables/:name/tables/:name/rows/:id) was tightened
259
- * in place to `z.enum([...])` / `z.literal(...)` against every emit-site error
260
- * code.
261
- *
262
- * Kept as a forward-compatibility hook: when new stock routes ship with
263
- * heterogeneous error surfaces that need an interim generic schema, add
264
- * them here instead of forcing every consumer to hand-maintain the entry.
265
- *
266
- * Paths assume the standard `/api/account` + `/api/db` prefixes used by every
267
- * fuz_app consumer. Merged into `default_error_schema_tightness.allowlist` so
268
- * consumers calling `assert_error_schema_tightness` directly inherit the
269
- * exemptions; the standard attack-surface suite also prepends these entries
270
- * underneath any consumer-supplied allowlist so project-specific entries are
271
- * additive.
272
- */
273
- export declare const fuz_app_stock_route_tightness_allowlist: ReadonlyArray<string>;
274
- /**
275
- * Baseline error schema tightness applied by
276
- * `describe_standard_attack_surface_tests` when no config is passed.
277
- *
278
- * Uses `min_specificity: 'enum'` (the assertion default) with `ignore_statuses`
279
- * for middleware-derived status codes that are commonly generic (auth middleware
280
- * produces multiple error codes at 401/403, and 429 comes from rate limiters),
281
- * and `allowlist` seeded with `fuz_app_stock_route_tightness_allowlist` so
282
- * fuz_app-shipped routes with heterogeneous generic schemas don't force every
283
- * consumer to hand-maintain an identical allowlist. Consumers can pass a
284
- * narrower config with project-specific `allowlist` entries, or pass `null`
285
- * to skip the assertion entirely.
286
- */
287
- export declare const default_error_schema_tightness: ErrorSchemaTightnessOptions;
288
- /**
289
- * Assert that all error schemas meet a minimum specificity threshold.
290
- *
291
- * Calls `audit_error_schema_tightness` and fails on any entry below
292
- * the configured threshold. Use `allowlist` and `ignore_statuses` to exclude
293
- * known exceptions during progressive tightening.
294
- *
295
- * @throws AssertionError listing every route × status combination whose error
296
- * schema specificity is below `min_specificity` (default `'enum'`) and is
297
- * not in `allowlist` or `ignore_statuses`.
298
- */
299
- export declare const assert_error_schema_tightness: (surface: AppSurface, options?: ErrorSchemaTightnessOptions) => void;
300
220
  /**
301
221
  * Run all structural invariants. Options-free — applies universally.
302
222
  *
303
223
  * Catches schema/surface generation bugs: missing 401/403/400 declarations,
304
224
  * empty descriptions, duplicate routes, middleware-injected error codes
305
- * unpropagated to routes, structurally invalid error schemas, error codes
306
- * appearing at multiple statuses, and generic 404 schemas on param routes.
225
+ * unpropagated to routes (by construction on a generated surface, so a
226
+ * snapshot's check), an error that doesn't name its code or whose code is
227
+ * not one, and error codes appearing at multiple statuses.
307
228
  *
308
229
  * @throws AssertionError on the first invariant violation; the message names
309
230
  * the offending route and the missing/inconsistent field.
@@ -1 +1 @@
1
- {"version":3,"file":"surface_invariants.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/surface_invariants.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAuB7B,OAAO,KAAK,EAAE,UAAU,EA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AACH,eAAO,MAAM,iCAAiC,GAC7C,SAAS,UAAU,EACnB,WAAU,KAAK,CAAC,MAAM,CAAiC,KACrD,IAWF,CAAC;AAWF,mDAAmD;AACnD,MAAM,WAAW,2BAA2B;IAC3C,6FAA6F;IAC7F,eAAe,CAAC,EAAE,sBAAsB,CAAC;IACzC,mEAAmE;IACnE,eAAe,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,kDAAkD;IAClD,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,uCAAuC,EAAE,aAAa,CAAC,MAAM,CAAM,CAAC;AAEjF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,8BAA8B,EAAE,2BAG5C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,6BAA6B,GACzC,SAAS,UAAU,EACnB,UAAU,2BAA2B,KACnC,IAsBF,CAAC;AAIF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB,GAAI,SAAS,UAAU,KAAG,IAY/D,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,gCAAgC,GAAI,SAAS,UAAU,KAAG,IAMtE,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,8BAA8B,GAC1C,SAAS,UAAU,EACnB,UAAS,4BAAiC,KACxC,IAKF,CAAC"}
1
+ {"version":3,"file":"surface_invariants.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/surface_invariants.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAuB7B,OAAO,KAAK,EAAE,UAAU,EAAwB,MAAM,oBAAoB,CAAC;AAuB3E;;GAEG;AACH,eAAO,MAAM,mCAAmC,GAAI,SAAS,UAAU,KAAG,IAQzE,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,8BAA8B,GAAI,SAAS,UAAU,KAAG,IASp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