@guren/server 2.15.0 → 2.16.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.
- package/dist/{DocsViewerServiceProvider-qFCaeiUv.js → DocsViewerServiceProvider-D2cuVgtN.js} +7 -12
- package/dist/{Hash-C8aejmi8.js → Hash-D2DFd8xX.js} +7 -57
- package/dist/{HttpException-BkS3euNG.js → HttpException-BlQ2yEmT.js} +2 -79
- package/dist/{Job-BVT813DO.js → Job-DxQK8h3P.js} +24 -179
- package/dist/{McpServiceProvider-BawsYjgN.js → McpServiceProvider-nNcbCIQX.js} +11 -20
- package/dist/{Random-DbIJ22KQ.js → Random-S0OvCuR8.js} +9 -106
- package/dist/agent/AgentApprovalRequested.d.ts +11 -39
- package/dist/agent/approval.d.ts +76 -187
- package/dist/agent/audit-emitter.d.ts +16 -44
- package/dist/agent/audit.d.ts +20 -56
- package/dist/agent/derive.d.ts +32 -66
- package/dist/agent/dispatch.d.ts +38 -90
- package/dist/agent/events.d.ts +11 -19
- package/dist/agent/meta-tools.d.ts +18 -46
- package/dist/agent/public.d.ts +6 -25
- package/dist/agent/public.js +1 -1
- package/dist/agent/redact.d.ts +16 -38
- package/dist/agent/scopes.d.ts +23 -69
- package/dist/auth/AuthManager.d.ts +19 -40
- package/dist/auth/AuthenticatableModel.d.ts +2 -2
- package/dist/auth/SessionGuard.d.ts +0 -1
- package/dist/auth/TokenGuard.d.ts +6 -26
- package/dist/auth/api-token.d.ts +16 -148
- package/dist/auth/context.d.ts +5 -10
- package/dist/auth/email-verification.d.ts +29 -127
- package/dist/auth/index.js +1 -1
- package/dist/auth/oauth/index.d.ts +35 -57
- package/dist/auth/password/DefaultHasher.d.ts +5 -14
- package/dist/auth/password/PasswordHasher.d.ts +5 -13
- package/dist/auth/password/hash-format.d.ts +5 -13
- package/dist/auth/password-reset.d.ts +16 -42
- package/dist/auth/providers/ModelUserProvider.d.ts +3 -4
- package/dist/auth/providers/UserProvider.d.ts +4 -4
- package/dist/auth/signed-token.d.ts +18 -0
- package/dist/auth/types.d.ts +9 -32
- package/dist/auth/utils.d.ts +6 -27
- package/dist/{auth-DkYoAPVn.js → auth-CbdPH4Cd.js} +169 -502
- package/dist/authorization/Gate.d.ts +9 -145
- package/dist/authorization/Policy.d.ts +6 -53
- package/dist/authorization/index.js +1 -1
- package/dist/authorization/middleware.d.ts +16 -62
- package/dist/authorization/types.d.ts +8 -64
- package/dist/{authorization-CdfbCj8J.js → authorization-CdEWZZw3.js} +44 -309
- package/dist/broadcasting/BroadcastManager.d.ts +29 -149
- package/dist/broadcasting/channels/Channel.d.ts +1 -19
- package/dist/broadcasting/channels/PresenceChannel.d.ts +1 -55
- package/dist/broadcasting/channels/PrivateChannel.d.ts +1 -23
- package/dist/broadcasting/drivers/MemoryDriver.d.ts +18 -70
- package/dist/broadcasting/drivers/RedisDriver.d.ts +3 -80
- package/dist/broadcasting/drivers/index.d.ts +1 -1
- package/dist/broadcasting/index.d.ts +1 -1
- package/dist/broadcasting/index.js +1 -1
- package/dist/broadcasting/types.d.ts +7 -88
- package/dist/{broadcasting-BwodCA4q.js → broadcasting-B5RzB0A2.js} +87 -414
- package/dist/cache/CacheManager.d.ts +8 -62
- package/dist/cache/TaggedCache.d.ts +2 -35
- package/dist/cache/index.js +1 -1
- package/dist/cache/stores/FileStore.d.ts +2 -36
- package/dist/cache/stores/MemoryStore.d.ts +2 -26
- package/dist/cache/stores/RedisStore.d.ts +1 -29
- package/dist/cache/types.d.ts +21 -128
- package/dist/{cache-BYnZf2FR.js → cache-BOOIr324.js} +19 -198
- package/dist/client-C4TEr_Dd.js +9 -0
- package/dist/console/Command.d.ts +17 -126
- package/dist/console/ConsoleKernel.d.ts +2 -74
- package/dist/console/Input.d.ts +5 -113
- package/dist/console/Output.d.ts +3 -99
- package/dist/console/types.d.ts +3 -33
- package/dist/container/Container.d.ts +12 -103
- package/dist/container/ServiceProvider.d.ts +17 -61
- package/dist/container/bindings.d.ts +5 -26
- package/dist/container/defineModule.d.ts +16 -54
- package/dist/container/definePlugin.d.ts +12 -45
- package/dist/container/types.d.ts +2 -34
- package/dist/context-CXk_umpT.js +21 -0
- package/dist/database/Factory.d.ts +4 -57
- package/dist/database/Seeder.d.ts +8 -46
- package/dist/database/SeederRunner.d.ts +3 -33
- package/dist/database/types.d.ts +3 -24
- package/dist/discovery/AutoDiscovery.d.ts +10 -82
- package/dist/{dispatch-erOS9epZ.js → dispatch-BAwzftws.js} +32 -79
- package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +2 -5
- package/dist/docs-viewer/endpoint.d.ts +5 -11
- package/dist/encryption/Encrypter.d.ts +5 -71
- package/dist/encryption/Hash.d.ts +7 -57
- package/dist/encryption/Random.d.ts +6 -99
- package/dist/encryption/index.js +3 -3
- package/dist/encryption/types.d.ts +10 -72
- package/dist/{encryption-D99Vmls3.js → encryption-uwP3Di4D.js} +9 -78
- package/dist/{endpoint-D6GIqOpe.js → endpoint-BXipU2Jj.js} +6 -12
- package/dist/endpoint-Dsw3Acvq.js +26 -0
- package/dist/errors/ExceptionHandler.d.ts +3 -90
- package/dist/errors/HttpException.d.ts +2 -79
- package/dist/errors/debug-page.d.ts +3 -17
- package/dist/errors/error-page.d.ts +1 -0
- package/dist/errors/exceptions/AuthenticationException.d.ts +2 -24
- package/dist/errors/exceptions/AuthorizationException.d.ts +1 -24
- package/dist/errors/exceptions/MethodNotAllowedException.d.ts +1 -23
- package/dist/errors/exceptions/NotFoundHttpException.d.ts +1 -27
- package/dist/errors/exceptions/ValidationException.d.ts +2 -43
- package/dist/errors/types.d.ts +1 -25
- package/dist/{errors-BgeOl_DC.js → errors-JpkcCjjn.js} +3 -41
- package/dist/events/Event.d.ts +1 -28
- package/dist/events/EventManager.d.ts +5 -107
- package/dist/events/Listener.d.ts +7 -55
- package/dist/events/builtin.d.ts +0 -24
- package/dist/events/index.js +1 -1
- package/dist/events/types.d.ts +4 -22
- package/dist/{events-aIH_bWRx.js → events-DOmAHDeP.js} +11 -191
- package/dist/facades/index.d.ts +2 -14
- package/dist/health/HealthCheck.d.ts +0 -24
- package/dist/health/HealthManager.d.ts +0 -36
- package/dist/health/checks/CacheCheck.d.ts +2 -17
- package/dist/health/checks/CustomCheck.d.ts +0 -9
- package/dist/health/checks/DatabaseCheck.d.ts +2 -17
- package/dist/health/checks/MemoryCheck.d.ts +3 -12
- package/dist/health/checks/RedisCheck.d.ts +1 -13
- package/dist/health/checks/StorageCheck.d.ts +2 -17
- package/dist/health/index.js +1 -1
- package/dist/health/types.d.ts +4 -24
- package/dist/{health-VWdWXRwh.js → health-DQSvUplL.js} +1 -76
- package/dist/hot-disposables-B5BXqaIH.js +167 -0
- package/dist/hot-reload/hot-disposables.d.ts +22 -74
- package/dist/hot-reload/testing.d.ts +4 -9
- package/dist/http/Application.d.ts +62 -208
- package/dist/http/FormRequest.d.ts +4 -55
- package/dist/http/dev-assets.d.ts +13 -31
- package/dist/http/dev-banner.d.ts +2 -5
- package/dist/http/inertia-assets.d.ts +3 -6
- package/dist/http/middleware/capabilities.d.ts +27 -50
- package/dist/http/middleware/cors.d.ts +4 -29
- package/dist/http/middleware/csp.d.ts +2 -25
- package/dist/http/middleware/csrf.d.ts +20 -95
- package/dist/http/middleware/detect-locale.d.ts +7 -27
- package/dist/http/middleware/force-https.d.ts +6 -24
- package/dist/http/middleware/host-authorization.d.ts +2 -12
- package/dist/http/middleware/loopback-guard.d.ts +15 -33
- package/dist/http/middleware/rate-limit.d.ts +29 -126
- package/dist/http/middleware/redirect-safety.d.ts +2 -20
- package/dist/http/middleware/request-id.d.ts +1 -14
- package/dist/http/middleware/request-logging.d.ts +2 -13
- package/dist/http/middleware/response-headers.d.ts +5 -13
- package/dist/http/middleware/security-headers.d.ts +2 -16
- package/dist/http/middleware/session.d.ts +15 -34
- package/dist/http/middleware/validation-errors-cookie.d.ts +7 -18
- package/dist/http/middleware/validation.d.ts +8 -63
- package/dist/http/public-assets.d.ts +11 -7
- package/dist/http/request.d.ts +32 -118
- package/dist/http/resources/CursorPaginator.d.ts +5 -64
- package/dist/http/resources/Paginator.d.ts +7 -84
- package/dist/http/resources/Resource.d.ts +9 -65
- package/dist/http/resources/ResourceCollection.d.ts +5 -39
- package/dist/http/resources/types.d.ts +10 -30
- package/dist/http/static-documents.d.ts +10 -20
- package/dist/http/validation/Validator.d.ts +25 -85
- package/dist/http/validation/rules.d.ts +48 -147
- package/dist/http/validation/types.d.ts +16 -61
- package/dist/http/vite-assets.d.ts +5 -28
- package/dist/http/vite-dev-server.d.ts +6 -9
- package/dist/http/vite-manifest.d.ts +19 -33
- package/dist/i18n/I18nManager.d.ts +12 -78
- package/dist/i18n/Translator.d.ts +3 -54
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/loaders/JsonLoader.d.ts +4 -31
- package/dist/i18n/loaders/MemoryLoader.d.ts +1 -21
- package/dist/i18n/pluralization.d.ts +4 -13
- package/dist/i18n/types.d.ts +17 -69
- package/dist/{i18n-mcWi7LCd.js → i18n-Cg1aajRP.js} +31 -225
- package/dist/index.d.ts +2 -1
- package/dist/index.js +714 -3011
- package/dist/internal/agent-preflight.d.ts +9 -21
- package/dist/internal/request.d.ts +6 -19
- package/dist/internal/request.js +1 -1
- package/dist/internal/route-path.d.ts +9 -21
- package/dist/internal/route-path.js +9 -21
- package/dist/internal/zod-compat.d.ts +55 -122
- package/dist/internal/zod-compat.js +39 -70
- package/dist/internal/zod-json-schema.d.ts +18 -54
- package/dist/internal/zod-json-schema.js +46 -123
- package/dist/jsx-runtime.d.ts +3 -8
- package/dist/lambda/index.d.ts +17 -79
- package/dist/lambda/index.js +11 -59
- package/dist/logging/LogManager.d.ts +1 -51
- package/dist/logging/Logger.d.ts +8 -47
- package/dist/logging/channels/ConsoleChannel.d.ts +1 -3
- package/dist/logging/channels/DailyFileChannel.d.ts +1 -3
- package/dist/logging/channels/FileChannel.d.ts +1 -3
- package/dist/logging/daily-file-path.d.ts +7 -16
- package/dist/logging/index.js +1 -1
- package/dist/logging/types.d.ts +13 -45
- package/dist/{logging-B-kngi3q.js → logging-zOY1XCtq.js} +52 -141
- package/dist/{loopback-guard-D0Kc7-xc.js → loopback-guard-DT9gHF0F.js} +41 -92
- package/dist/mail/Mail.d.ts +10 -106
- package/dist/mail/MailManager.d.ts +2 -60
- package/dist/mail/index.js +1 -1
- package/dist/mail/transports/LogTransport.d.ts +1 -4
- package/dist/mail/transports/MemoryTransport.d.ts +1 -63
- package/dist/mail/transports/ResendTransport.d.ts +1 -23
- package/dist/mail/transports/SmtpTransport.d.ts +1 -31
- package/dist/mail/types.d.ts +28 -150
- package/dist/{mail-DfEfSQEr.js → mail-76DWy9lj.js} +31 -289
- package/dist/mcp/McpServiceProvider.d.ts +4 -10
- package/dist/mcp/create-mcp-server.d.ts +25 -57
- package/dist/mcp/endpoint.d.ts +12 -36
- package/dist/mcp/index.js +1 -1
- package/dist/mvc/Controller.d.ts +46 -227
- package/dist/mvc/Router.d.ts +50 -129
- package/dist/mvc/inertia/InertiaEngine.d.ts +18 -48
- package/dist/mvc/inertia/shared.d.ts +6 -19
- package/dist/mvc/mount-route.d.ts +2 -6
- package/dist/mvc/view.d.ts +1 -2
- package/dist/notifications/Notification.d.ts +8 -75
- package/dist/notifications/NotificationManager.d.ts +15 -88
- package/dist/notifications/channels/DatabaseChannel.d.ts +1 -41
- package/dist/notifications/channels/MailChannel.d.ts +2 -31
- package/dist/notifications/channels/MemoryChannel.d.ts +2 -62
- package/dist/notifications/channels/SlackChannel.d.ts +3 -48
- package/dist/notifications/index.js +1 -1
- package/dist/notifications/notifiable-type.d.ts +3 -6
- package/dist/notifications/registry.d.ts +8 -27
- package/dist/notifications/types.d.ts +16 -53
- package/dist/{notifications-BGqmUNZ8.js → notifications-okWFs9ly.js} +37 -335
- package/dist/providers/AuthServiceProvider.d.ts +1 -3
- package/dist/providers/AuthorizationServiceProvider.d.ts +2 -3
- package/dist/providers/BroadcastServiceProvider.d.ts +1 -3
- package/dist/providers/CacheServiceProvider.d.ts +1 -3
- package/dist/providers/EncryptionServiceProvider.d.ts +1 -3
- package/dist/providers/ErrorServiceProvider.d.ts +1 -4
- package/dist/providers/EventServiceProvider.d.ts +1 -3
- package/dist/providers/HealthServiceProvider.d.ts +1 -3
- package/dist/providers/I18nServiceProvider.d.ts +6 -10
- package/dist/providers/InertiaServiceProvider.d.ts +1 -4
- package/dist/providers/LogServiceProvider.d.ts +1 -3
- package/dist/providers/MailServiceProvider.d.ts +1 -3
- package/dist/providers/NotificationServiceProvider.d.ts +1 -3
- package/dist/providers/OAuthServiceProvider.d.ts +1 -3
- package/dist/providers/QueueServiceProvider.d.ts +1 -3
- package/dist/providers/SchedulingServiceProvider.d.ts +1 -3
- package/dist/providers/StorageServiceProvider.d.ts +1 -3
- package/dist/queue/FailedJobReporter.d.ts +1 -24
- package/dist/queue/Job.d.ts +12 -99
- package/dist/queue/QueueManager.d.ts +6 -57
- package/dist/queue/Worker.d.ts +4 -65
- package/dist/queue/drivers/MemoryDriver.d.ts +3 -44
- package/dist/queue/drivers/RedisDriver.d.ts +7 -65
- package/dist/queue/drivers/SqsDriver.d.ts +6 -57
- package/dist/queue/drivers/SyncDriver.d.ts +10 -13
- package/dist/queue/index.js +2 -2
- package/dist/queue/types.d.ts +10 -92
- package/dist/{queue-CXrRK85G.js → queue-CcXCjuJI.js} +32 -260
- package/dist/redis/RedisApiTokenStore.d.ts +4 -56
- package/dist/redis/RedisEmailVerificationStore.d.ts +4 -37
- package/dist/redis/RedisOAuthStateStore.d.ts +2 -10
- package/dist/redis/RedisPasswordResetStore.d.ts +4 -37
- package/dist/redis/RedisRateLimitStore.d.ts +16 -49
- package/dist/redis/RedisSessionStore.d.ts +3 -44
- package/dist/redis/client.d.ts +2 -32
- package/dist/redis/index.js +47 -232
- package/dist/redis/redis-values.d.ts +6 -12
- package/dist/redis/scan-keys.d.ts +1 -4
- package/dist/request-CLOYytGP.js +68 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +50 -92
- package/dist/scheduling/CronParser.d.ts +0 -29
- package/dist/scheduling/Schedule.d.ts +1 -153
- package/dist/scheduling/ScheduledTask.d.ts +0 -31
- package/dist/scheduling/Scheduler.d.ts +0 -70
- package/dist/scheduling/index.js +1 -1
- package/dist/scheduling/types.d.ts +4 -65
- package/dist/{scheduling-CPiEdtQd.js → scheduling-C6tcOtUl.js} +2 -287
- package/dist/storage/StorageManager.d.ts +0 -48
- package/dist/storage/drivers/LocalDriver.d.ts +1 -25
- package/dist/storage/drivers/MemoryDriver.d.ts +5 -35
- package/dist/storage/drivers/S3Driver.d.ts +6 -36
- package/dist/storage/drivers/s3-acl.d.ts +5 -10
- package/dist/storage/index.js +1 -1
- package/dist/storage/types.d.ts +27 -265
- package/dist/{storage-TLD9t0Q2.js → storage-BB59f07j.js} +17 -157
- package/dist/support/contained-path.d.ts +10 -20
- package/dist/support/error-polyfill.d.ts +4 -6
- package/dist/support/expiry.d.ts +17 -33
- package/dist/support/expiry.js +17 -33
- package/dist/support/import-map.d.ts +3 -7
- package/dist/support/inertia-defaults.d.ts +5 -10
- package/dist/support/redirect-target.d.ts +4 -6
- package/dist/support/stack-frames.d.ts +11 -50
- package/dist/support/trim-slashes.d.ts +4 -7
- package/dist/support/warn-once.d.ts +2 -6
- package/dist/{trim-slashes-ZJ_VsY5s.js → trim-slashes-BLY9hKAa.js} +4 -7
- package/dist/{vite-manifest-w_RSOvQW.js → vite-manifest-CTQp-SOo.js} +34 -58
- package/package.json +2 -2
- package/dist/client-Dd7vLcqp.js +0 -27
- package/dist/context-DoD0c7J_.js +0 -26
- package/dist/endpoint-D-20PiHY.js +0 -46
- package/dist/hot-disposables-WsTX2ySN.js +0 -281
- package/dist/request-CVQwpu2J.js +0 -129
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The wire protocol of an agent preflight (RFC 0016 §5.4), in a leaf module
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* in either of those would make one import the other — today only
|
|
8
|
-
* `dispatch → Router` exists, and the day `Router` needs anything from
|
|
9
|
-
* `agent/` that becomes a cycle.
|
|
10
|
-
*
|
|
11
|
-
* Not exported from the package index: an external dispatcher asks for a
|
|
12
|
-
* preflight through `BuildToolRequestOptions.preflight`, and the header
|
|
13
|
-
* spelling is this seam's business, not published API.
|
|
2
|
+
* The wire protocol of an agent preflight (RFC 0016 §5.4), in a leaf module so
|
|
3
|
+
* `Router` (which answers one) and `agent/dispatch` (which asks) share it
|
|
4
|
+
* without importing each other and closing a cycle. Not exported from the
|
|
5
|
+
* package index: an external dispatcher goes through
|
|
6
|
+
* `BuildToolRequestOptions.preflight`, and the header spelling stays internal.
|
|
14
7
|
*/
|
|
15
8
|
/** Request header asking the route for a verdict instead of an execution. */
|
|
16
9
|
export declare const AGENT_PREFLIGHT_HEADER = "X-Guren-Agent-Preflight";
|
|
17
10
|
/**
|
|
18
|
-
* Response header marking a body as a preflight verdict rather than the
|
|
19
|
-
* route's
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* a route's `output` schema validation (which would reject the verdict and
|
|
23
|
-
* turn it into a 500) and the MCP response mapping (which would advertise the
|
|
24
|
-
* verdict as the tool's `structuredContent`, so an SDK client validates it
|
|
25
|
-
* against the tool's output schema and throws). Both are answering the same
|
|
26
|
-
* question — "is this the route's result?" — so both read the same marker.
|
|
11
|
+
* Response header marking a body as a preflight verdict rather than the route's
|
|
12
|
+
* own output. Read by the route's `output` schema validation (which would
|
|
13
|
+
* otherwise reject the verdict as a 500) and by the MCP response mapping (which
|
|
14
|
+
* would otherwise advertise it as the tool's `structuredContent`).
|
|
27
15
|
*/
|
|
28
16
|
export declare const AGENT_PREFLIGHT_VERDICT_HEADER = "X-Guren-Agent-Preflight-Verdict";
|
|
@@ -1,25 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The one set of request-reading rules: which content types are read, how a
|
|
3
3
|
* repeated form field collapses, what an unreadable body falls back to, how a
|
|
4
|
-
* multipart upload is
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* request in a `HonoRequest` and calls straight into these — rather than
|
|
11
|
-
* reimplementing the decisions. A second copy is how the two came to disagree
|
|
12
|
-
* on an uppercase media type, on a `;`-parameterized one, and on a repeated
|
|
13
|
-
* `field[]`.
|
|
14
|
-
*
|
|
15
|
-
* `parseRequestUploads` is here for the same reason. It is deliberately not
|
|
16
|
-
* `parseRequestBody` under another name — its own doc comment owns why, and is
|
|
17
|
-
* the one place that argument is written out.
|
|
18
|
-
*
|
|
19
|
-
* Internal by the rules in `contributing/api-stability.md` — reachable only
|
|
20
|
-
* through a deep import under `internal/`, never re-exported from an index.
|
|
21
|
-
* `parseRequestPayload` beside them *is* public and stays exported from the
|
|
22
|
-
* package root; this subpath exists for the ones that are not.
|
|
4
|
+
* multipart upload is read, and how repeated query parameters flatten.
|
|
5
|
+
* `@guren/testing`'s controller mock wraps its `Request` in a `HonoRequest` and
|
|
6
|
+
* calls into these rather than restating them — a second copy is how the two
|
|
7
|
+
* came to disagree on an uppercase media type and on a repeated `field[]`.
|
|
8
|
+
* Internal per `contributing/api-stability.md`: reachable only through this
|
|
9
|
+
* deep import. `parseRequestPayload` beside them is public.
|
|
23
10
|
*/
|
|
24
11
|
export { parseRequestBody, parseRequestUploads, asRecord, flattenRequestQueries, } from '../http/request.js';
|
|
25
12
|
export type { RequestBodyContext, RequestQueryContext, RequestUploads, RequestUploadsContext, } from '../http/request.js';
|
package/dist/internal/request.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as parseRequestBody, n as flattenRequestQueries, o as parseRequestUploads, t as asRecord } from "../request-
|
|
1
|
+
import { i as parseRequestBody, n as flattenRequestQueries, o as parseRequestUploads, t as asRecord } from "../request-CLOYytGP.js";
|
|
2
2
|
export { asRecord, flattenRequestQueries, parseRequestBody, parseRequestUploads };
|
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The one Hono route-path lexing rule, shared by
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* and
|
|
6
|
-
*
|
|
7
|
-
* Internal
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `@guren/core/internal/route-path` for the same build-order reason the
|
|
11
|
-
* JSON Schema walker beside it does: core's index is
|
|
12
|
-
* `export * from '@guren/server'`, so a server module cannot import a core
|
|
13
|
-
* one.
|
|
14
|
-
*
|
|
15
|
-
* It exists because two lexers is how two surfaces come to describe one path
|
|
16
|
-
* differently. They did: `@guren/openapi` carried its own copy with the `*`
|
|
17
|
-
* outside the capture group, so `/files/:name*` yielded the parameter `name`
|
|
18
|
-
* there and `name*` — what Hono actually registers — everywhere else. What
|
|
19
|
-
* *does* legitimately differ is rendering, not lexing, and that difference now
|
|
20
|
-
* lives at the one call site that needs it (see `stripExplodeModifier`).
|
|
2
|
+
* The one Hono route-path lexing rule, shared by the router's substitution and
|
|
3
|
+
* binding scanners, RFC 0016's agent tool input, and `@guren/openapi`'s path
|
|
4
|
+
* template. Two lexers is how `/files/:name*` came to yield the parameter
|
|
5
|
+
* `name` in openapi and `name*` — what Hono registers — everywhere else; what
|
|
6
|
+
* legitimately differs is rendering, at the call site (`stripExplodeModifier`).
|
|
7
|
+
* Internal per `contributing/api-stability.md`; re-exported by
|
|
8
|
+
* `@guren/core/internal/route-path`, since core's index is
|
|
9
|
+
* `export * from '@guren/server'` and a server module cannot import a core one.
|
|
21
10
|
*/
|
|
22
11
|
export declare const PATH_PARAM_PATTERN: RegExp;
|
|
23
12
|
/**
|
|
24
13
|
* Param labels in path order, exactly as Hono registers them: constraints
|
|
25
|
-
* dropped, a trailing `*` kept (
|
|
26
|
-
* dropped (it is not).
|
|
14
|
+
* dropped, a trailing `*` kept (part of the name), a trailing `?` dropped.
|
|
27
15
|
*/
|
|
28
16
|
export declare function extractPathParamNames(path: string): string[];
|
|
@@ -1,30 +1,18 @@
|
|
|
1
1
|
//#region src/internal/route-path.ts
|
|
2
2
|
/**
|
|
3
|
-
* The one Hono route-path lexing rule, shared by
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* and
|
|
7
|
-
*
|
|
8
|
-
* Internal
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* `@guren/core/internal/route-path` for the same build-order reason the
|
|
12
|
-
* JSON Schema walker beside it does: core's index is
|
|
13
|
-
* `export * from '@guren/server'`, so a server module cannot import a core
|
|
14
|
-
* one.
|
|
15
|
-
*
|
|
16
|
-
* It exists because two lexers is how two surfaces come to describe one path
|
|
17
|
-
* differently. They did: `@guren/openapi` carried its own copy with the `*`
|
|
18
|
-
* outside the capture group, so `/files/:name*` yielded the parameter `name`
|
|
19
|
-
* there and `name*` — what Hono actually registers — everywhere else. What
|
|
20
|
-
* *does* legitimately differ is rendering, not lexing, and that difference now
|
|
21
|
-
* lives at the one call site that needs it (see `stripExplodeModifier`).
|
|
3
|
+
* The one Hono route-path lexing rule, shared by the router's substitution and
|
|
4
|
+
* binding scanners, RFC 0016's agent tool input, and `@guren/openapi`'s path
|
|
5
|
+
* template. Two lexers is how `/files/:name*` came to yield the parameter
|
|
6
|
+
* `name` in openapi and `name*` — what Hono registers — everywhere else; what
|
|
7
|
+
* legitimately differs is rendering, at the call site (`stripExplodeModifier`).
|
|
8
|
+
* Internal per `contributing/api-stability.md`; re-exported by
|
|
9
|
+
* `@guren/core/internal/route-path`, since core's index is
|
|
10
|
+
* `export * from '@guren/server'` and a server module cannot import a core one.
|
|
22
11
|
*/
|
|
23
12
|
const PATH_PARAM_PATTERN = /(^|\/):([A-Za-z0-9_-]+\*?)(?:\{[^{}]*\{[^{}]*\}[^{}]*\}|\{[^{}]*\})?\??/gu;
|
|
24
13
|
/**
|
|
25
14
|
* Param labels in path order, exactly as Hono registers them: constraints
|
|
26
|
-
* dropped, a trailing `*` kept (
|
|
27
|
-
* dropped (it is not).
|
|
15
|
+
* dropped, a trailing `*` kept (part of the name), a trailing `?` dropped.
|
|
28
16
|
*/
|
|
29
17
|
function extractPathParamNames(path) {
|
|
30
18
|
return Array.from(path.matchAll(PATH_PARAM_PATTERN), (match) => match[2]);
|
|
@@ -1,50 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Zod 4 schema-reading primitives shared by everything that
|
|
3
|
-
* application's schemas without parsing
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* through a deep import under `internal/`, never re-exported from
|
|
11
|
-
* `@guren/server`'s or `@guren/core`'s index. It sits in this package rather
|
|
12
|
-
* than `@guren/core` because `zod-json-schema.ts` beside it has to, for the
|
|
13
|
-
* build-order reason that module's header explains;
|
|
14
|
-
* `@guren/core/internal/zod-compat` re-exports it so consumers outside this
|
|
15
|
-
* package keep writing the core specifier.
|
|
16
|
-
*
|
|
17
|
-
* Zod 4 only. The zod 3 API (whether from the old `zod@3` package or the
|
|
18
|
-
* `zod/v3` subpath that zod 4 ships for migration) tags every node with
|
|
19
|
-
* `_def.typeName` and overloads `_def.type` to hold a nested schema — the
|
|
20
|
-
* ambiguity behind a bug this module's predecessors fixed twice. Rather than
|
|
21
|
-
* carrying both dialects forever, a v3 node is detected up front
|
|
22
|
-
* (`isZod3Schema`) and refused with `ZOD3_UNSUPPORTED_MESSAGE`; everything
|
|
23
|
-
* below it assumes the v4 layout, where `_def.type` is always the type name.
|
|
24
|
-
*
|
|
25
|
-
* What does NOT belong here: the two type switches that turn a node into an
|
|
26
|
-
* output (a TypeScript type string vs. a JSON Schema object). Their leaf
|
|
27
|
-
* vocabularies have legitimately diverged — the CLI renders `void`/`any`/
|
|
28
|
-
* `never`, which JSON Schema has no way to express — and that is a rendering
|
|
29
|
-
* decision, not schema-reading knowledge.
|
|
30
|
-
*
|
|
31
|
-
* No caller's `isOptional` belongs here either, but for a weaker reason than
|
|
32
|
-
* "they are all right": the CLI's type renderer reads only the side of a
|
|
33
|
-
* `.pipe()` it renders, while the JSON Schema walker and the CLI's route
|
|
34
|
-
* contract check require both sides to permit omission, and *every* one of them
|
|
35
|
-
* is an approximation that a sufficiently odd pipeline can fool. Fixing them
|
|
36
|
-
* properly means simulating a parse, which is well beyond reading a `_def`.
|
|
37
|
-
* They stay with their callers until someone does that. Applying the wrapper
|
|
38
|
-
* vocabulary is not policy, though, which is why `unwrapSingleChild` does live
|
|
39
|
-
* here: reaching a wrapper's child is schema-reading, while what a caller
|
|
40
|
-
* *concludes* from that wrapper is the caller's to decide.
|
|
2
|
+
* Zod 4 schema-reading primitives shared by everything that reads an
|
|
3
|
+
* application's schemas without parsing: the JSON Schema walker next door and
|
|
4
|
+
* `@guren/cli`'s type renderer and route contract check. Internal per
|
|
5
|
+
* `contributing/api-stability.md`; it lives here rather than in `@guren/core` for
|
|
6
|
+
* the build-order reason `zod-json-schema.ts`'s header gives, re-exported by
|
|
7
|
+
* `@guren/core/internal/zod-compat`. Zod 4 only: a v3 node (tags `_def.typeName`,
|
|
8
|
+
* overloads `_def.type` with a nested schema) is refused up front, so `_def.type`
|
|
9
|
+
* is always the type name here. Rendering decisions (node → output, `isOptional`) stay with callers.
|
|
41
10
|
*/
|
|
42
11
|
export interface ZodSchemaLike {
|
|
43
12
|
_def?: Record<string, unknown>;
|
|
44
13
|
/**
|
|
45
|
-
* zod 4's internal container
|
|
46
|
-
* literals, `def` the definition of whatever the node is
|
|
47
|
-
* the check itself — see `schemaChecks`).
|
|
14
|
+
* zod 4's internal container: `values` is its computed set of accepted
|
|
15
|
+
* literals, `def` the definition of whatever the node is.
|
|
48
16
|
*/
|
|
49
17
|
_zod?: {
|
|
50
18
|
values?: Set<unknown>;
|
|
@@ -54,33 +22,28 @@ export interface ZodSchemaLike {
|
|
|
54
22
|
shape?: Record<string, ZodSchemaLike>;
|
|
55
23
|
}
|
|
56
24
|
/**
|
|
57
|
-
* One entry of `_def.checks
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* a reader that does not recognise one must simply ignore it.
|
|
25
|
+
* One entry of `_def.checks`: a `check` discriminator plus whatever that kind
|
|
26
|
+
* carries. Left open rather than a union — the kinds are zod's to add, and an
|
|
27
|
+
* unrecognised one must simply be ignored.
|
|
61
28
|
*/
|
|
62
29
|
export interface ZodCheckDef extends Record<string, unknown> {
|
|
63
30
|
check: string;
|
|
64
31
|
}
|
|
65
32
|
/**
|
|
66
|
-
* Which side of a schema is being read
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* validation, or what a response body looks like.
|
|
70
|
-
* - `input` — the value a client has to send over the wire. Coercing and
|
|
71
|
-
* piped schemas can differ here from their output side.
|
|
33
|
+
* Which side of a schema is being read: `output` is the parsed value a
|
|
34
|
+
* controller receives, `input` what a client sends. Coercing and piped schemas
|
|
35
|
+
* differ between the two.
|
|
72
36
|
*/
|
|
73
37
|
export type SchemaIo = 'input' | 'output';
|
|
74
38
|
/**
|
|
75
|
-
*
|
|
76
|
-
* `_def.typeName` (`"ZodString"`), so its presence is the discriminator —
|
|
39
|
+
* Only zod 3 sets `_def.typeName`, so its presence is the discriminator —
|
|
77
40
|
* checked before any other read, because on a v3 node `_def.type` holds a
|
|
78
41
|
* nested *schema* and every v4-shaped read below would misfire on it.
|
|
79
42
|
*/
|
|
80
43
|
export declare function isZod3Schema(schema: ZodSchemaLike): boolean;
|
|
81
44
|
/**
|
|
82
|
-
* The one refusal message,
|
|
83
|
-
*
|
|
45
|
+
* The one refusal message, so the CLI's console warning and the OpenAPI
|
|
46
|
+
* document's warnings array cannot drift apart.
|
|
84
47
|
*/
|
|
85
48
|
export declare const ZOD3_UNSUPPORTED_MESSAGE = "this schema was authored with the zod v3 API (zod@3 or the zod/v3 subpath), which Guren does not support. Rewrite it with the zod 4 API (`import { z } from 'zod'`).";
|
|
86
49
|
/** The node's type name: `_def.type` (`"string"`, `"object"`, …) or the schema's own `.type`. */
|
|
@@ -88,11 +51,9 @@ export declare function getTypeName(schema: ZodSchemaLike): string | undefined;
|
|
|
88
51
|
/** `getTypeName` with `'unknown'` for a node that has no readable name. */
|
|
89
52
|
export declare function typeOf(schema: ZodSchemaLike): string;
|
|
90
53
|
/**
|
|
91
|
-
* The schema at `def[key]`, if it actually holds one.
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* v3-era version of this helper took a key *list* and returned the first
|
|
95
|
-
* match; with one dialect there is no precedence left to encode.)
|
|
54
|
+
* The schema at `def[key]`, if it actually holds one. `_def` is untyped data
|
|
55
|
+
* from someone else's package, so a key holding a string or function must read
|
|
56
|
+
* as absent rather than as a schema.
|
|
96
57
|
*/
|
|
97
58
|
export declare function schemaAt(def: Record<string, unknown>, key: string): ZodSchemaLike | undefined;
|
|
98
59
|
/** The schema wrapped by a single-child wrapper (`.optional()`, `.readonly()`, `.catch()`, …) — always `_def.innerType` in zod 4. */
|
|
@@ -102,17 +63,15 @@ export declare function arrayElement(def: Record<string, unknown>): ZodSchemaLik
|
|
|
102
63
|
/** A record's value schema — `_def.valueType`. */
|
|
103
64
|
export declare function recordValueType(def: Record<string, unknown>): ZodSchemaLike | undefined;
|
|
104
65
|
/**
|
|
105
|
-
* Whether this node is a `.transform()`'s output half — a wrapped function
|
|
106
|
-
*
|
|
107
|
-
* `unknown`.
|
|
66
|
+
* Whether this node is a `.transform()`'s output half — a wrapped function with
|
|
67
|
+
* no type to read, as opposed to a schema that parses to `unknown`.
|
|
108
68
|
*/
|
|
109
69
|
export declare function isTransform(schema: ZodSchemaLike): boolean;
|
|
110
70
|
/**
|
|
111
|
-
* Both halves of a `.pipe()`. Zod 4 uses one `pipe` node for
|
|
112
|
-
*
|
|
113
|
-
* controller receives — except for a transform, whose out side is the
|
|
114
|
-
*
|
|
115
|
-
* absent for a transform, leaving `from` as the only readable answer.
|
|
71
|
+
* Both halves of a `.pipe()`. Zod 4 uses one `pipe` node for `.pipe()` and
|
|
72
|
+
* `.transform()` alike: `_def.in` is what a caller sends, `_def.out` what a
|
|
73
|
+
* controller receives — except for a transform, whose out side is the function
|
|
74
|
+
* itself, so `to` is absent and `from` is the only readable answer.
|
|
116
75
|
*/
|
|
117
76
|
export declare function pipeSides(def: Record<string, unknown>): {
|
|
118
77
|
from: ZodSchemaLike | undefined;
|
|
@@ -123,79 +82,53 @@ export declare function pipeSide(def: Record<string, unknown>, io: SchemaIo): Zo
|
|
|
123
82
|
/** An object's property map — `_def.shape`, or the schema's own `.shape`. */
|
|
124
83
|
export declare function objectShape(schema: ZodSchemaLike): Record<string, ZodSchemaLike> | undefined;
|
|
125
84
|
/**
|
|
126
|
-
* An enum's accepted values,
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
* `{ A: 'B', B: 1 }`, the key `A` *looks* like a reverse entry (`entries['B']`
|
|
132
|
-
* is a number) but zod accepts `'B'`. Reading zod's set makes what we document
|
|
133
|
-
* what zod parses, by construction. The `entries` fallback (values unfiltered)
|
|
134
|
-
* only runs if a future zod 4.x stops exposing the set.
|
|
85
|
+
* An enum's accepted values, from zod's computed `_zod.values` rather than
|
|
86
|
+
* re-derived from `_def.entries`: `z.nativeEnum` produces the same node, and a
|
|
87
|
+
* numeric enum's reverse mappings cannot be filtered without false positives
|
|
88
|
+
* (in `{ A: 'B', B: 1 }` the key `A` looks like one, yet zod accepts `'B'`).
|
|
89
|
+
* The `entries` fallback only runs if a future zod 4.x stops exposing the set.
|
|
135
90
|
*/
|
|
136
91
|
export declare function enumValues(schema: ZodSchemaLike): Array<string | number>;
|
|
137
92
|
/**
|
|
138
|
-
* The refinements attached to a node
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
* refinement (`z.string().min(2)`) is stored as a bare check object, while a
|
|
144
|
-
* format method (`z.string().url()`) stores the *format schema* — a full node
|
|
145
|
-
* with `parse`, `safeParse` and the rest — in the same array. Both carry the
|
|
146
|
-
* check definition at `_zod.def`, and nothing else about them is shared.
|
|
147
|
-
*
|
|
148
|
-
* Entries without a string `check` are dropped rather than passed through: a
|
|
149
|
-
* caller switches on that discriminator, so an entry that has none can only be
|
|
150
|
-
* misread.
|
|
93
|
+
* The refinements attached to a node, normalized to the definitions zod keeps
|
|
94
|
+
* at each entry's `_zod.def`. That indirection is what makes the list uniform:
|
|
95
|
+
* `_def.checks` mixes bare check objects (`z.string().min(2)`) with whole
|
|
96
|
+
* format schemas (`z.string().url()`), sharing only `_zod.def`. Entries without
|
|
97
|
+
* a string `check` are dropped — a caller switches on that discriminator.
|
|
151
98
|
*/
|
|
152
99
|
export declare function schemaChecks(schema: ZodSchemaLike): ZodCheckDef[];
|
|
153
100
|
/**
|
|
154
|
-
* The node's declared format
|
|
155
|
-
* `
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* set `_def.format` and attach no check; the equivalent string methods
|
|
160
|
-
* (`z.string().email()`, `z.string().datetime()`) attach a `string_format`
|
|
161
|
-
* check and leave `_def.format` undefined. A reader that wants "the format of
|
|
162
|
-
* this schema" has to consult both this and `schemaChecks`.
|
|
101
|
+
* The node's declared format (`'email'` for `z.email()`), which is only half of
|
|
102
|
+
* how zod 4 records one: top-level constructors set `_def.format` and attach no
|
|
103
|
+
* check, while the string methods (`z.string().email()`) attach a
|
|
104
|
+
* `string_format` check and leave `_def.format` undefined. A reader wanting
|
|
105
|
+
* "the format of this schema" must consult this *and* `schemaChecks`.
|
|
163
106
|
*/
|
|
164
107
|
export declare function schemaFormat(schema: ZodSchemaLike): string | undefined;
|
|
165
108
|
/** A literal's values — always the `_def.values` array in zod 4, which may hold more than one. */
|
|
166
109
|
export declare function literalValues(def: Record<string, unknown>): unknown[];
|
|
167
110
|
/**
|
|
168
|
-
* Wrappers that neither add to a rendered type nor decide
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
* calls, so looking through it reads as "contents unavailable" rather than
|
|
172
|
-
* "unsupported type".)
|
|
111
|
+
* Wrappers that neither add to a rendered type nor decide omissibility.
|
|
112
|
+
* (`lazy` is here for membership only: its child hides behind `_def.getter`,
|
|
113
|
+
* which no walker calls, so it reads as "contents unavailable".)
|
|
173
114
|
*/
|
|
174
115
|
export declare const TRANSPARENT_WRAPPERS: ReadonlySet<string>;
|
|
175
116
|
/**
|
|
176
|
-
* Wrappers
|
|
177
|
-
*
|
|
117
|
+
* Wrappers passing their type through but deciding presence: each makes a field
|
|
118
|
+
* omissible, or (`nonoptional`) re-requires one.
|
|
178
119
|
*/
|
|
179
120
|
export declare const PRESENCE_WRAPPERS: ReadonlySet<string>;
|
|
180
121
|
/**
|
|
181
|
-
* Every type name
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* rendering needs (the CLI splits transparent from presence-deciding because
|
|
187
|
-
* it walks types and presence separately; the JSON Schema walker looks through all
|
|
188
|
-
* of them uniformly). What none of them may do is disagree about *membership*
|
|
189
|
-
* — a name known to one walker and not the other silently changes an output,
|
|
190
|
-
* which is why the list lives here rather than once per package.
|
|
122
|
+
* Every type name carrying exactly one nested schema and no shape of its own —
|
|
123
|
+
* the two sets above plus the two that render specially (`nullable` becomes a
|
|
124
|
+
* union with null; a pipe holds one schema per side). Vocabulary, not policy:
|
|
125
|
+
* callers partition it as their rendering needs, but a name known to one walker
|
|
126
|
+
* and not another silently changes an output, so membership lives here.
|
|
191
127
|
*/
|
|
192
128
|
export declare const SINGLE_CHILD_WRAPPERS: ReadonlySet<string>;
|
|
193
129
|
/**
|
|
194
130
|
* The schema a single-child wrapper wraps, in the direction being read; absent
|
|
195
|
-
* for a
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
* Membership comes from the set above, for the reason stated there; a pipe
|
|
199
|
-
* resolves per direction, for the reason stated on `pipeSides`.
|
|
131
|
+
* for a non-wrapper, or one whose child cannot be reached (`z.lazy()` hides its
|
|
132
|
+
* schema behind a getter no walker calls).
|
|
200
133
|
*/
|
|
201
134
|
export declare function unwrapSingleChild(schema: ZodSchemaLike, io: SchemaIo): ZodSchemaLike | undefined;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
//#region src/internal/zod-compat.ts
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* `_def.typeName` (`"ZodString"`), so its presence is the discriminator —
|
|
3
|
+
* Only zod 3 sets `_def.typeName`, so its presence is the discriminator —
|
|
5
4
|
* checked before any other read, because on a v3 node `_def.type` holds a
|
|
6
5
|
* nested *schema* and every v4-shaped read below would misfire on it.
|
|
7
6
|
*/
|
|
@@ -9,8 +8,8 @@ function isZod3Schema(schema) {
|
|
|
9
8
|
return typeof schema._def?.typeName === "string";
|
|
10
9
|
}
|
|
11
10
|
/**
|
|
12
|
-
* The one refusal message,
|
|
13
|
-
*
|
|
11
|
+
* The one refusal message, so the CLI's console warning and the OpenAPI
|
|
12
|
+
* document's warnings array cannot drift apart.
|
|
14
13
|
*/
|
|
15
14
|
const ZOD3_UNSUPPORTED_MESSAGE = "this schema was authored with the zod v3 API (zod@3 or the zod/v3 subpath), which Guren does not support. Rewrite it with the zod 4 API (`import { z } from 'zod'`).";
|
|
16
15
|
/** The node's type name: `_def.type` (`"string"`, `"object"`, …) or the schema's own `.type`. */
|
|
@@ -23,11 +22,9 @@ function typeOf(schema) {
|
|
|
23
22
|
return getTypeName(schema) ?? "unknown";
|
|
24
23
|
}
|
|
25
24
|
/**
|
|
26
|
-
* The schema at `def[key]`, if it actually holds one.
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* v3-era version of this helper took a key *list* and returned the first
|
|
30
|
-
* match; with one dialect there is no precedence left to encode.)
|
|
25
|
+
* The schema at `def[key]`, if it actually holds one. `_def` is untyped data
|
|
26
|
+
* from someone else's package, so a key holding a string or function must read
|
|
27
|
+
* as absent rather than as a schema.
|
|
31
28
|
*/
|
|
32
29
|
function schemaAt(def, key) {
|
|
33
30
|
const candidate = def[key];
|
|
@@ -46,19 +43,17 @@ function recordValueType(def) {
|
|
|
46
43
|
return schemaAt(def, "valueType");
|
|
47
44
|
}
|
|
48
45
|
/**
|
|
49
|
-
* Whether this node is a `.transform()`'s output half — a wrapped function
|
|
50
|
-
*
|
|
51
|
-
* `unknown`.
|
|
46
|
+
* Whether this node is a `.transform()`'s output half — a wrapped function with
|
|
47
|
+
* no type to read, as opposed to a schema that parses to `unknown`.
|
|
52
48
|
*/
|
|
53
49
|
function isTransform(schema) {
|
|
54
50
|
return typeOf(schema) === "transform";
|
|
55
51
|
}
|
|
56
52
|
/**
|
|
57
|
-
* Both halves of a `.pipe()`. Zod 4 uses one `pipe` node for
|
|
58
|
-
*
|
|
59
|
-
* controller receives — except for a transform, whose out side is the
|
|
60
|
-
*
|
|
61
|
-
* absent for a transform, leaving `from` as the only readable answer.
|
|
53
|
+
* Both halves of a `.pipe()`. Zod 4 uses one `pipe` node for `.pipe()` and
|
|
54
|
+
* `.transform()` alike: `_def.in` is what a caller sends, `_def.out` what a
|
|
55
|
+
* controller receives — except for a transform, whose out side is the function
|
|
56
|
+
* itself, so `to` is absent and `from` is the only readable answer.
|
|
62
57
|
*/
|
|
63
58
|
function pipeSides(def) {
|
|
64
59
|
const to = schemaAt(def, "out");
|
|
@@ -77,15 +72,11 @@ function objectShape(schema) {
|
|
|
77
72
|
return (schema._def ?? {}).shape ?? schema.shape;
|
|
78
73
|
}
|
|
79
74
|
/**
|
|
80
|
-
* An enum's accepted values,
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* `{ A: 'B', B: 1 }`, the key `A` *looks* like a reverse entry (`entries['B']`
|
|
86
|
-
* is a number) but zod accepts `'B'`. Reading zod's set makes what we document
|
|
87
|
-
* what zod parses, by construction. The `entries` fallback (values unfiltered)
|
|
88
|
-
* only runs if a future zod 4.x stops exposing the set.
|
|
75
|
+
* An enum's accepted values, from zod's computed `_zod.values` rather than
|
|
76
|
+
* re-derived from `_def.entries`: `z.nativeEnum` produces the same node, and a
|
|
77
|
+
* numeric enum's reverse mappings cannot be filtered without false positives
|
|
78
|
+
* (in `{ A: 'B', B: 1 }` the key `A` looks like one, yet zod accepts `'B'`).
|
|
79
|
+
* The `entries` fallback only runs if a future zod 4.x stops exposing the set.
|
|
89
80
|
*/
|
|
90
81
|
function enumValues(schema) {
|
|
91
82
|
const values = schema._zod?.values;
|
|
@@ -94,19 +85,11 @@ function enumValues(schema) {
|
|
|
94
85
|
return entries ? Object.values(entries) : [];
|
|
95
86
|
}
|
|
96
87
|
/**
|
|
97
|
-
* The refinements attached to a node
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* refinement (`z.string().min(2)`) is stored as a bare check object, while a
|
|
103
|
-
* format method (`z.string().url()`) stores the *format schema* — a full node
|
|
104
|
-
* with `parse`, `safeParse` and the rest — in the same array. Both carry the
|
|
105
|
-
* check definition at `_zod.def`, and nothing else about them is shared.
|
|
106
|
-
*
|
|
107
|
-
* Entries without a string `check` are dropped rather than passed through: a
|
|
108
|
-
* caller switches on that discriminator, so an entry that has none can only be
|
|
109
|
-
* misread.
|
|
88
|
+
* The refinements attached to a node, normalized to the definitions zod keeps
|
|
89
|
+
* at each entry's `_zod.def`. That indirection is what makes the list uniform:
|
|
90
|
+
* `_def.checks` mixes bare check objects (`z.string().min(2)`) with whole
|
|
91
|
+
* format schemas (`z.string().url()`), sharing only `_zod.def`. Entries without
|
|
92
|
+
* a string `check` are dropped — a caller switches on that discriminator.
|
|
110
93
|
*/
|
|
111
94
|
function schemaChecks(schema) {
|
|
112
95
|
const checks = schema._def?.checks;
|
|
@@ -117,15 +100,11 @@ function schemaChecks(schema) {
|
|
|
117
100
|
});
|
|
118
101
|
}
|
|
119
102
|
/**
|
|
120
|
-
* The node's declared format
|
|
121
|
-
* `
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* set `_def.format` and attach no check; the equivalent string methods
|
|
126
|
-
* (`z.string().email()`, `z.string().datetime()`) attach a `string_format`
|
|
127
|
-
* check and leave `_def.format` undefined. A reader that wants "the format of
|
|
128
|
-
* this schema" has to consult both this and `schemaChecks`.
|
|
103
|
+
* The node's declared format (`'email'` for `z.email()`), which is only half of
|
|
104
|
+
* how zod 4 records one: top-level constructors set `_def.format` and attach no
|
|
105
|
+
* check, while the string methods (`z.string().email()`) attach a
|
|
106
|
+
* `string_format` check and leave `_def.format` undefined. A reader wanting
|
|
107
|
+
* "the format of this schema" must consult this *and* `schemaChecks`.
|
|
129
108
|
*/
|
|
130
109
|
function schemaFormat(schema) {
|
|
131
110
|
const format = schema._def?.format;
|
|
@@ -136,11 +115,9 @@ function literalValues(def) {
|
|
|
136
115
|
return Array.isArray(def.values) ? def.values : [];
|
|
137
116
|
}
|
|
138
117
|
/**
|
|
139
|
-
* Wrappers that neither add to a rendered type nor decide
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
* calls, so looking through it reads as "contents unavailable" rather than
|
|
143
|
-
* "unsupported type".)
|
|
118
|
+
* Wrappers that neither add to a rendered type nor decide omissibility.
|
|
119
|
+
* (`lazy` is here for membership only: its child hides behind `_def.getter`,
|
|
120
|
+
* which no walker calls, so it reads as "contents unavailable".)
|
|
144
121
|
*/
|
|
145
122
|
const TRANSPARENT_WRAPPERS = /* @__PURE__ */ new Set([
|
|
146
123
|
"catch",
|
|
@@ -148,8 +125,8 @@ const TRANSPARENT_WRAPPERS = /* @__PURE__ */ new Set([
|
|
|
148
125
|
"lazy"
|
|
149
126
|
]);
|
|
150
127
|
/**
|
|
151
|
-
* Wrappers
|
|
152
|
-
*
|
|
128
|
+
* Wrappers passing their type through but deciding presence: each makes a field
|
|
129
|
+
* omissible, or (`nonoptional`) re-requires one.
|
|
153
130
|
*/
|
|
154
131
|
const PRESENCE_WRAPPERS = /* @__PURE__ */ new Set([
|
|
155
132
|
"optional",
|
|
@@ -158,16 +135,11 @@ const PRESENCE_WRAPPERS = /* @__PURE__ */ new Set([
|
|
|
158
135
|
"nonoptional"
|
|
159
136
|
]);
|
|
160
137
|
/**
|
|
161
|
-
* Every type name
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
* rendering needs (the CLI splits transparent from presence-deciding because
|
|
167
|
-
* it walks types and presence separately; the JSON Schema walker looks through all
|
|
168
|
-
* of them uniformly). What none of them may do is disagree about *membership*
|
|
169
|
-
* — a name known to one walker and not the other silently changes an output,
|
|
170
|
-
* which is why the list lives here rather than once per package.
|
|
138
|
+
* Every type name carrying exactly one nested schema and no shape of its own —
|
|
139
|
+
* the two sets above plus the two that render specially (`nullable` becomes a
|
|
140
|
+
* union with null; a pipe holds one schema per side). Vocabulary, not policy:
|
|
141
|
+
* callers partition it as their rendering needs, but a name known to one walker
|
|
142
|
+
* and not another silently changes an output, so membership lives here.
|
|
171
143
|
*/
|
|
172
144
|
const SINGLE_CHILD_WRAPPERS = /* @__PURE__ */ new Set([
|
|
173
145
|
...TRANSPARENT_WRAPPERS,
|
|
@@ -177,11 +149,8 @@ const SINGLE_CHILD_WRAPPERS = /* @__PURE__ */ new Set([
|
|
|
177
149
|
]);
|
|
178
150
|
/**
|
|
179
151
|
* The schema a single-child wrapper wraps, in the direction being read; absent
|
|
180
|
-
* for a
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
* Membership comes from the set above, for the reason stated there; a pipe
|
|
184
|
-
* resolves per direction, for the reason stated on `pipeSides`.
|
|
152
|
+
* for a non-wrapper, or one whose child cannot be reached (`z.lazy()` hides its
|
|
153
|
+
* schema behind a getter no walker calls).
|
|
185
154
|
*/
|
|
186
155
|
function unwrapSingleChild(schema, io) {
|
|
187
156
|
const def = schema._def ?? {};
|