@guren/server 2.15.0 → 2.17.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-Zihx3Bjq.js} +35 -20
- package/dist/{Random-DbIJ22KQ.js → Random-S0OvCuR8.js} +9 -106
- package/dist/agent/AgentApprovalRequested.d.ts +11 -39
- package/dist/agent/approval-status.d.ts +56 -0
- 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 +17 -23
- package/dist/agent/gate.d.ts +118 -0
- package/dist/agent/meta-tools.d.ts +18 -46
- package/dist/agent/pipeline.d.ts +234 -0
- 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 +55 -69
- package/dist/auth/AgentPrincipalGuard.d.ts +49 -0
- package/dist/auth/AuthManager.d.ts +22 -43
- 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-Gg54ppQi.js} +279 -519
- 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 +77 -205
- 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 +28 -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/index.d.ts +1 -1
- 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 +11 -4
- package/dist/index.js +1186 -3040
- package/dist/internal/agent-preflight.d.ts +9 -21
- package/dist/internal/agent-principal.d.ts +32 -0
- 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 +42 -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-B_Iy5183.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,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 ?? {};
|
|
@@ -1,41 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The one Zod → JSON Schema rule,
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* through a
|
|
9
|
-
*
|
|
10
|
-
* exists so two derivations of the same schema cannot disagree, not as a
|
|
11
|
-
* public extension point. That is the whole reason it was promoted out of
|
|
12
|
-
* `@guren/openapi`: a second walker is how an agent tool comes to advertise a
|
|
13
|
-
* schema the documented API contradicts.
|
|
14
|
-
*
|
|
15
|
-
* It lives in `@guren/server` rather than `@guren/core` (where RFC 0016 §2
|
|
16
|
-
* first placed it) for a build-order reason, not a layering one. Core's index
|
|
17
|
-
* is `export * from '@guren/server'`, so core builds *after* server and a
|
|
18
|
-
* server module cannot import a core one — the edge would close a cycle, and
|
|
19
|
-
* server's declaration build (`tsc -p tsconfig.build.json`, `paths: {}`)
|
|
20
|
-
* would look for a core `dist/` that does not exist yet. `deriveAgentTools`
|
|
21
|
-
* lives in `@guren/server`, so the walker had to move down to the package
|
|
22
|
-
* both it and the OpenAPI generator can see. `@guren/core/internal/*`
|
|
23
|
-
* re-exports this module, which keeps that the specifier every consumer
|
|
24
|
-
* outside this package writes.
|
|
25
|
-
*
|
|
26
|
-
* Every `_def` read goes through `zod-compat.ts`, including the check reads
|
|
27
|
-
* this module added. Reaching into `_def` here would put zod-layout knowledge
|
|
28
|
-
* in two places, which is exactly the split `zod-compat` exists to prevent.
|
|
29
|
-
*
|
|
30
|
-
* Zod 4 only, and a v3 node is *refused* rather than walked — on v3 `_def.type`
|
|
31
|
-
* holds a nested schema where v4 keeps the type name, so every read below would
|
|
32
|
-
* misfire and produce a confidently wrong document. The refusal is re-checked
|
|
33
|
-
* at each recursion, because a v3 node can hide inside a v4 wrapper.
|
|
34
|
-
*
|
|
35
|
-
* What this module does not decide: what a caller does with the warnings, and
|
|
36
|
-
* how the result is embedded (a `requestBody` content map, an MCP `inputSchema`).
|
|
37
|
-
* Warnings are appended to a caller-owned array so a document generator can
|
|
38
|
-
* surface them per request and a codegen step can fail on them.
|
|
2
|
+
* The one Zod → JSON Schema rule, so two derivations of the same schema cannot
|
|
3
|
+
* disagree: `@guren/openapi` renders it as OpenAPI 3.1 schema objects, RFC
|
|
4
|
+
* 0016's agent tools advertise it as MCP input/output schemas. Internal per
|
|
5
|
+
* `contributing/api-stability.md`. It sits in `@guren/server` for build order:
|
|
6
|
+
* core's index is `export * from '@guren/server'`, so a server module importing
|
|
7
|
+
* core would close a cycle; `@guren/core/internal/*` re-exports it. Every `_def`
|
|
8
|
+
* read goes through `zod-compat.ts`. Zod 4 only — a v3 node is refused at each
|
|
9
|
+
* recursion (one can hide inside a v4 wrapper). Warnings go to a caller-owned array.
|
|
39
10
|
*/
|
|
40
11
|
import { type SchemaIo, type ZodSchemaLike } from './zod-compat.js';
|
|
41
12
|
export type JsonSchemaPrimitiveType = 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object' | 'null';
|
|
@@ -70,32 +41,25 @@ export interface JsonSchemaObject {
|
|
|
70
41
|
allOf?: JsonSchemaObject[];
|
|
71
42
|
}
|
|
72
43
|
/**
|
|
73
|
-
* An object schema taken apart rather than rendered
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* `params` + `query` + `body` into a single tool input).
|
|
44
|
+
* An object schema taken apart rather than rendered, for callers whose
|
|
45
|
+
* properties do not stay together in one schema object: OpenAPI expands `query`
|
|
46
|
+
* into one parameter each, RFC 0016 merges params/query/body into one input.
|
|
77
47
|
*/
|
|
78
48
|
export interface ObjectSchemaDetails {
|
|
79
49
|
properties: Record<string, JsonSchemaObject>;
|
|
80
50
|
required: Set<string>;
|
|
81
51
|
}
|
|
82
52
|
/**
|
|
83
|
-
* Turn a Zod schema into a JSON Schema object, appending
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* produces.
|
|
88
|
-
*
|
|
89
|
-
* Returns `undefined` when the node contributes nothing (a bare `z.undefined()`)
|
|
90
|
-
* or could not be read; a caller treats that as "omit this property".
|
|
53
|
+
* Turn a Zod schema into a JSON Schema object, appending to `warnings` anything
|
|
54
|
+
* it cannot express. `label` names the schema there (`"POST /posts body.title"`);
|
|
55
|
+
* `io` picks the side of coercing and piped schemas to describe. `undefined`
|
|
56
|
+
* means the node contributes nothing, or could not be read — omit the property.
|
|
91
57
|
*/
|
|
92
58
|
export declare function toJsonSchema(schema: unknown, warnings: string[], label: string, io: SchemaIo): JsonSchemaObject | undefined;
|
|
93
59
|
/**
|
|
94
|
-
* Take an object schema apart into its properties and the
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* unwrapped — a caller that expands properties into something else (query
|
|
98
|
-
* parameters, merged tool input) has nothing to expand otherwise.
|
|
60
|
+
* Take an object schema apart into its properties and the keys a caller must
|
|
61
|
+
* supply, looking through wrappers. Warns and returns `undefined` when the
|
|
62
|
+
* schema is absent, not Zod, or not an object once unwrapped.
|
|
99
63
|
*/
|
|
100
64
|
export declare function readObjectSchema(schema: unknown, warnings: string[], label: string, io: SchemaIo): ObjectSchemaDetails | undefined;
|
|
101
65
|
/** Whether this value looks like a Zod schema at all — the gate every walk opens with. */
|
|
@@ -1,62 +1,21 @@
|
|
|
1
1
|
import { SINGLE_CHILD_WRAPPERS, ZOD3_UNSUPPORTED_MESSAGE, arrayElement, enumValues, getTypeName, innerSchema, isZod3Schema, literalValues, objectShape, pipeSides, recordValueType, schemaChecks, schemaFormat, typeOf, unwrapSingleChild } from "./zod-compat.js";
|
|
2
2
|
//#region src/internal/zod-json-schema.ts
|
|
3
3
|
/**
|
|
4
|
-
* The one Zod → JSON Schema rule,
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* through a
|
|
11
|
-
*
|
|
12
|
-
* exists so two derivations of the same schema cannot disagree, not as a
|
|
13
|
-
* public extension point. That is the whole reason it was promoted out of
|
|
14
|
-
* `@guren/openapi`: a second walker is how an agent tool comes to advertise a
|
|
15
|
-
* schema the documented API contradicts.
|
|
16
|
-
*
|
|
17
|
-
* It lives in `@guren/server` rather than `@guren/core` (where RFC 0016 §2
|
|
18
|
-
* first placed it) for a build-order reason, not a layering one. Core's index
|
|
19
|
-
* is `export * from '@guren/server'`, so core builds *after* server and a
|
|
20
|
-
* server module cannot import a core one — the edge would close a cycle, and
|
|
21
|
-
* server's declaration build (`tsc -p tsconfig.build.json`, `paths: {}`)
|
|
22
|
-
* would look for a core `dist/` that does not exist yet. `deriveAgentTools`
|
|
23
|
-
* lives in `@guren/server`, so the walker had to move down to the package
|
|
24
|
-
* both it and the OpenAPI generator can see. `@guren/core/internal/*`
|
|
25
|
-
* re-exports this module, which keeps that the specifier every consumer
|
|
26
|
-
* outside this package writes.
|
|
27
|
-
*
|
|
28
|
-
* Every `_def` read goes through `zod-compat.ts`, including the check reads
|
|
29
|
-
* this module added. Reaching into `_def` here would put zod-layout knowledge
|
|
30
|
-
* in two places, which is exactly the split `zod-compat` exists to prevent.
|
|
31
|
-
*
|
|
32
|
-
* Zod 4 only, and a v3 node is *refused* rather than walked — on v3 `_def.type`
|
|
33
|
-
* holds a nested schema where v4 keeps the type name, so every read below would
|
|
34
|
-
* misfire and produce a confidently wrong document. The refusal is re-checked
|
|
35
|
-
* at each recursion, because a v3 node can hide inside a v4 wrapper.
|
|
36
|
-
*
|
|
37
|
-
* What this module does not decide: what a caller does with the warnings, and
|
|
38
|
-
* how the result is embedded (a `requestBody` content map, an MCP `inputSchema`).
|
|
39
|
-
* Warnings are appended to a caller-owned array so a document generator can
|
|
40
|
-
* surface them per request and a codegen step can fail on them.
|
|
4
|
+
* The one Zod → JSON Schema rule, so two derivations of the same schema cannot
|
|
5
|
+
* disagree: `@guren/openapi` renders it as OpenAPI 3.1 schema objects, RFC
|
|
6
|
+
* 0016's agent tools advertise it as MCP input/output schemas. Internal per
|
|
7
|
+
* `contributing/api-stability.md`. It sits in `@guren/server` for build order:
|
|
8
|
+
* core's index is `export * from '@guren/server'`, so a server module importing
|
|
9
|
+
* core would close a cycle; `@guren/core/internal/*` re-exports it. Every `_def`
|
|
10
|
+
* read goes through `zod-compat.ts`. Zod 4 only — a v3 node is refused at each
|
|
11
|
+
* recursion (one can hide inside a v4 wrapper). Warnings go to a caller-owned array.
|
|
41
12
|
*/
|
|
42
13
|
/**
|
|
43
|
-
* Zod's string formats mapped to the JSON Schema
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* plenty of formats the spec has never registered (`cuid`, `nanoid`, `emoji`,
|
|
49
|
-
* `ulid`, `jwt`, `base64`…), and emitting those verbatim advertises a
|
|
50
|
-
* constraint no consumer can interpret — an agent reading `format: "cuid"`
|
|
51
|
-
* learns nothing it can act on, while the `type: "string"` it already had stays
|
|
52
|
-
* true. Unmapped formats are dropped, not warned about: the schema is still
|
|
53
|
-
* correct, just less specific.
|
|
54
|
-
*
|
|
55
|
-
* `time` is the one registered format deliberately left out, and zod omits it
|
|
56
|
-
* from its own output for the same reason: JSON Schema's `time` is an RFC 3339
|
|
57
|
-
* `full-time`, which requires an offset, while `z.iso.time()` accepts a local
|
|
58
|
-
* wall-clock time. Claiming the format would assert an offset the schema does
|
|
59
|
-
* not require.
|
|
14
|
+
* Zod's string formats mapped to the JSON Schema names meaning the same thing,
|
|
15
|
+
* matched against zod's own `z.toJSONSchema()` output. Formats JSON Schema
|
|
16
|
+
* 2020-12 does not register (`cuid`, `nanoid`, `jwt`…) say nothing a consumer
|
|
17
|
+
* can act on, so they are dropped silently. `time` is left out as zod does: JSON
|
|
18
|
+
* Schema's is an RFC 3339 `full-time` requiring an offset; `z.iso.time()` accepts local wall-clock.
|
|
60
19
|
*/
|
|
61
20
|
const JSON_SCHEMA_STRING_FORMATS = {
|
|
62
21
|
email: "email",
|
|
@@ -70,18 +29,11 @@ const JSON_SCHEMA_STRING_FORMATS = {
|
|
|
70
29
|
ipv6: "ipv6"
|
|
71
30
|
};
|
|
72
31
|
/**
|
|
73
|
-
* The `number_format` values
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* `float32` / `float64` are the other half of the same zod vocabulary and stay
|
|
79
|
-
* plain numbers. The bounds each of these formats implies (zod's own emitter
|
|
80
|
-
* adds `minimum: -2147483648` for `int32`, and the safe-integer range for
|
|
81
|
-
* `safeint`) are deliberately not emitted: they are the representation's
|
|
82
|
-
* limits rather than the application's contract, and they bury the constraints
|
|
83
|
-
* an author actually wrote. `int64` / `uint64` need no entry — they sit on
|
|
84
|
-
* `bigint` nodes, which this walker already renders as `integer`.
|
|
32
|
+
* The `number_format` values describing an integer. JSON Schema says this with a
|
|
33
|
+
* *type*, so these turn `type: "number"` into `"integer"` — a `z.int()` documented
|
|
34
|
+
* as `number` admits `3.14`. The bounds these formats imply are not emitted: they
|
|
35
|
+
* are the representation's limits and bury the constraints an author wrote.
|
|
36
|
+
* `int64`/`uint64` need no entry; they sit on `bigint` nodes.
|
|
85
37
|
*/
|
|
86
38
|
const INTEGER_NUMBER_FORMATS = /* @__PURE__ */ new Set([
|
|
87
39
|
"safeint",
|
|
@@ -89,14 +41,11 @@ const INTEGER_NUMBER_FORMATS = /* @__PURE__ */ new Set([
|
|
|
89
41
|
"uint32"
|
|
90
42
|
]);
|
|
91
43
|
/**
|
|
92
|
-
* The string formats whose zod-supplied regex is worth carrying as `pattern
|
|
93
|
-
* the ones a user
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* a pattern for them too: their regexes run to hundreds of characters (the
|
|
98
|
-
* `datetime` one alone is ~300), they are zod's parsing implementation rather
|
|
99
|
-
* than the contract, and `format` already says the same thing in a word.
|
|
44
|
+
* The string formats whose zod-supplied regex is worth carrying as `pattern`:
|
|
45
|
+
* the ones a user wrote as a pattern or a prefix/suffix/substring test, which
|
|
46
|
+
* zod stores only as a compiled regex. The registered formats above are
|
|
47
|
+
* excluded even though zod exposes patterns for them — those run to hundreds of
|
|
48
|
+
* characters and are its parser, while `format` says the same in a word.
|
|
100
49
|
*/
|
|
101
50
|
const PATTERN_BEARING_FORMATS = /* @__PURE__ */ new Set([
|
|
102
51
|
"regex",
|
|
@@ -105,14 +54,10 @@ const PATTERN_BEARING_FORMATS = /* @__PURE__ */ new Set([
|
|
|
105
54
|
"includes"
|
|
106
55
|
]);
|
|
107
56
|
/**
|
|
108
|
-
* Turn a Zod schema into a JSON Schema object, appending
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* produces.
|
|
113
|
-
*
|
|
114
|
-
* Returns `undefined` when the node contributes nothing (a bare `z.undefined()`)
|
|
115
|
-
* or could not be read; a caller treats that as "omit this property".
|
|
57
|
+
* Turn a Zod schema into a JSON Schema object, appending to `warnings` anything
|
|
58
|
+
* it cannot express. `label` names the schema there (`"POST /posts body.title"`);
|
|
59
|
+
* `io` picks the side of coercing and piped schemas to describe. `undefined`
|
|
60
|
+
* means the node contributes nothing, or could not be read — omit the property.
|
|
116
61
|
*/
|
|
117
62
|
function toJsonSchema(schema, warnings, label, io) {
|
|
118
63
|
if (warnIfZod3(schema, warnings, label)) return;
|
|
@@ -212,11 +157,9 @@ function toJsonSchema(schema, warnings, label, io) {
|
|
|
212
157
|
}
|
|
213
158
|
}
|
|
214
159
|
/**
|
|
215
|
-
* Take an object schema apart into its properties and the
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
* unwrapped — a caller that expands properties into something else (query
|
|
219
|
-
* parameters, merged tool input) has nothing to expand otherwise.
|
|
160
|
+
* Take an object schema apart into its properties and the keys a caller must
|
|
161
|
+
* supply, looking through wrappers. Warns and returns `undefined` when the
|
|
162
|
+
* schema is absent, not Zod, or not an object once unwrapped.
|
|
220
163
|
*/
|
|
221
164
|
function readObjectSchema(schema, warnings, label, io) {
|
|
222
165
|
if (!schema) return;
|
|
@@ -236,9 +179,8 @@ function isZodSchema(schema) {
|
|
|
236
179
|
}
|
|
237
180
|
/**
|
|
238
181
|
* Push the v3 refusal warning and report whether it fired. One helper so the
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
* ungated recursion would document it wrong instead of refusing it.
|
|
182
|
+
* message cannot drift between entry points, and so recursive walks re-check
|
|
183
|
+
* nested nodes — a v3 schema can sit inside a v4 object.
|
|
242
184
|
*/
|
|
243
185
|
function warnIfZod3(schema, warnings, label) {
|
|
244
186
|
if (schema && typeof schema === "object" && isZod3Schema(schema)) {
|
|
@@ -273,11 +215,8 @@ function readObjectSchemaDetails(schema, warnings, label, io) {
|
|
|
273
215
|
}
|
|
274
216
|
/**
|
|
275
217
|
* Whether a caller may leave this property out — the `required` half of an
|
|
276
|
-
* object schema.
|
|
277
|
-
*
|
|
278
|
-
* Stays here rather than joining `unwrapSingleChild` in `zod-compat`: applying
|
|
279
|
-
* the wrapper vocabulary is schema-reading, but what to *conclude* from a
|
|
280
|
-
* wrapper is a policy each caller sets — see the `pipe` case.
|
|
218
|
+
* object schema. Stays here rather than in `zod-compat`: what to *conclude*
|
|
219
|
+
* from a wrapper is a policy each caller sets, as the `pipe` case shows.
|
|
281
220
|
*/
|
|
282
221
|
function isOptional(schema, io) {
|
|
283
222
|
switch (typeOf(schema)) {
|
|
@@ -318,11 +257,9 @@ function literalSchema(def) {
|
|
|
318
257
|
return {};
|
|
319
258
|
}
|
|
320
259
|
/**
|
|
321
|
-
* A check value
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
* would produce a keyword whose value is not a JSON number (and, for bigint,
|
|
325
|
-
* one that `JSON.stringify` throws on).
|
|
260
|
+
* A check value JSON Schema can carry. The guard is not ceremonial: the same
|
|
261
|
+
* check kinds sit on `z.date()` and `z.bigint()`, whose bounds are not JSON
|
|
262
|
+
* numbers — and a bigint is one `JSON.stringify` throws on.
|
|
326
263
|
*/
|
|
327
264
|
function numeric(value) {
|
|
328
265
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
@@ -365,17 +302,11 @@ function lengthConstraints(checks, minKey, maxKey) {
|
|
|
365
302
|
return constraints;
|
|
366
303
|
}
|
|
367
304
|
/**
|
|
368
|
-
* Every format this node declares, in
|
|
369
|
-
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
* leave the node's own field empty. Reading one source loses half the formats
|
|
374
|
-
* an app writes, so both are collected here once rather than in each caller.
|
|
375
|
-
*
|
|
376
|
-
* Takes the node's checks rather than re-reading them: every caller has already
|
|
377
|
-
* walked `_def.checks` for something else, and this walker is on RFC 0016's
|
|
378
|
-
* tool-derivation path as well as the document one.
|
|
305
|
+
* Every format this node declares, in preference order. Two sources, because
|
|
306
|
+
* zod has two spellings: the top-level constructors record the format on the
|
|
307
|
+
* node, the equivalent methods attach it as a check — reading one loses half
|
|
308
|
+
* the formats an app writes. Takes the checks rather than re-reading them,
|
|
309
|
+
* since every caller has already walked `_def.checks` for something else.
|
|
379
310
|
*/
|
|
380
311
|
function declaredFormats(schema, checks) {
|
|
381
312
|
const onNode = schemaFormat(schema);
|
|
@@ -409,18 +340,10 @@ function stringConstraints(schema) {
|
|
|
409
340
|
}
|
|
410
341
|
/**
|
|
411
342
|
* Put the first value under `keyword` and fold any remainder into `allOf`.
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
* only the first is not a lesser answer, it is a wrong one: the emitted schema
|
|
417
|
-
* then *accepts values the route rejects*, which is the one direction a derived
|
|
418
|
-
* contract must never be wrong in — an agent handed it will send input that
|
|
419
|
-
* fails validation. `allOf` conjoins, so the surplus stays enforceable.
|
|
420
|
-
*
|
|
421
|
-
* The first value stays on the node rather than going into `allOf` with the
|
|
422
|
-
* rest, so the overwhelmingly common single-constraint case emits flat.
|
|
423
|
-
* (zod's own emitter drops the surplus `multipleOf` outright here.)
|
|
343
|
+
* JSON Schema allows one `pattern` and one `multipleOf` per schema object, and
|
|
344
|
+
* keeping only the first would emit a schema *accepting values the route rejects*
|
|
345
|
+
* — the one direction a derived contract must never be wrong in. `allOf` conjoins,
|
|
346
|
+
* so the surplus stays enforceable (zod's own emitter drops it); one constraint still emits flat.
|
|
424
347
|
*/
|
|
425
348
|
function assignWithSurplus(constraints, keyword, values) {
|
|
426
349
|
const [first, ...surplus] = values;
|
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The app-facing JSX runtime for server-rendered content views (RFC 0014).
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* `@guren/core/jsx-runtime` → here → hono. Routing the pragma through the
|
|
7
|
-
* framework rather than at `hono/jsx` directly means applications never
|
|
8
|
-
* declare hono themselves, and the runtime that compiles their JSX is the
|
|
9
|
-
* same hono copy `Controller.view()` renders with — by construction, not by
|
|
10
|
-
* install-layout luck.
|
|
3
|
+
* View files point their `@jsxImportSource` pragma at `@guren/core`, which
|
|
4
|
+
* resolves here and then to hono: apps never declare hono themselves, and their
|
|
5
|
+
* JSX compiles against the same hono copy `Controller.view()` renders with.
|
|
11
6
|
*/
|
|
12
7
|
export * from 'hono/jsx/jsx-runtime';
|