@rpgjs/client 5.0.0-beta.2 → 5.0.0-beta.22
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/CHANGELOG.md +130 -0
- package/dist/Game/AnimationManager.d.ts +2 -1
- package/dist/Game/AnimationManager.js +21 -9
- package/dist/Game/AnimationManager.js.map +1 -1
- package/dist/Game/AnimationManager.spec.d.ts +1 -0
- package/dist/Game/ClientVisuals.d.ts +61 -0
- package/dist/Game/ClientVisuals.js +96 -0
- package/dist/Game/ClientVisuals.js.map +1 -0
- package/dist/Game/ClientVisuals.spec.d.ts +1 -0
- package/dist/Game/Event.js.map +1 -1
- package/dist/Game/EventComponentResolver.d.ts +16 -0
- package/dist/Game/EventComponentResolver.js +52 -0
- package/dist/Game/EventComponentResolver.js.map +1 -0
- package/dist/Game/EventComponentResolver.spec.d.ts +1 -0
- package/dist/Game/Map.d.ts +9 -1
- package/dist/Game/Map.js +83 -5
- package/dist/Game/Map.js.map +1 -1
- package/dist/Game/Object.d.ts +49 -15
- package/dist/Game/Object.js +101 -42
- package/dist/Game/Object.js.map +1 -1
- package/dist/Game/Object.spec.d.ts +1 -0
- package/dist/Game/Player.js.map +1 -1
- package/dist/Game/ProjectileManager.d.ts +98 -0
- package/dist/Game/ProjectileManager.js +196 -0
- package/dist/Game/ProjectileManager.js.map +1 -0
- package/dist/Game/ProjectileManager.spec.d.ts +1 -0
- package/dist/Gui/Gui.d.ts +20 -6
- package/dist/Gui/Gui.js +132 -57
- package/dist/Gui/Gui.js.map +1 -1
- package/dist/Gui/Gui.spec.d.ts +1 -0
- package/dist/Gui/NotificationManager.js.map +1 -1
- package/dist/Resource.js +1 -1
- package/dist/Resource.js.map +1 -1
- package/dist/RpgClient.d.ts +194 -15
- package/dist/RpgClientEngine.d.ts +191 -19
- package/dist/RpgClientEngine.js +693 -74
- package/dist/RpgClientEngine.js.map +1 -1
- package/dist/Sound.js.map +1 -1
- package/dist/_virtual/{_@oxc-project_runtime@0.122.0/helpers → _@oxc-project_runtime@0.133.0/helpers/esm}/decorate.js +1 -1
- package/dist/_virtual/{_@oxc-project_runtime@0.122.0/helpers → _@oxc-project_runtime@0.133.0/helpers/esm}/decorateMetadata.js +1 -1
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/components/animations/animation.ce.js +6 -5
- package/dist/components/animations/animation.ce.js.map +1 -1
- package/dist/components/animations/fx.ce.js +60 -0
- package/dist/components/animations/fx.ce.js.map +1 -0
- package/dist/components/animations/hit.ce.js +24 -28
- package/dist/components/animations/hit.ce.js.map +1 -1
- package/dist/components/animations/index.d.ts +1 -0
- package/dist/components/animations/index.js +6 -4
- package/dist/components/animations/index.js.map +1 -1
- package/dist/components/character.ce.js +748 -249
- package/dist/components/character.ce.js.map +1 -1
- package/dist/components/dynamics/bar.ce.js +99 -0
- package/dist/components/dynamics/bar.ce.js.map +1 -0
- package/dist/components/dynamics/image.ce.js +26 -0
- package/dist/components/dynamics/image.ce.js.map +1 -0
- package/dist/components/dynamics/parse-value.d.ts +3 -0
- package/dist/components/dynamics/parse-value.js +54 -35
- package/dist/components/dynamics/parse-value.js.map +1 -1
- package/dist/components/dynamics/parse-value.spec.d.ts +1 -0
- package/dist/components/dynamics/shape-utils.d.ts +16 -0
- package/dist/components/dynamics/shape-utils.js +73 -0
- package/dist/components/dynamics/shape-utils.js.map +1 -0
- package/dist/components/dynamics/shape-utils.spec.d.ts +1 -0
- package/dist/components/dynamics/shape.ce.js +86 -0
- package/dist/components/dynamics/shape.ce.js.map +1 -0
- package/dist/components/dynamics/text.ce.js +36 -56
- package/dist/components/dynamics/text.ce.js.map +1 -1
- package/dist/components/gui/box.ce.js +9 -9
- package/dist/components/gui/box.ce.js.map +1 -1
- package/dist/components/gui/dialogbox/index.ce.js +75 -65
- package/dist/components/gui/dialogbox/index.ce.js.map +1 -1
- package/dist/components/gui/gameover.ce.js +47 -68
- package/dist/components/gui/gameover.ce.js.map +1 -1
- package/dist/components/gui/hud/hud.ce.js +23 -31
- package/dist/components/gui/hud/hud.ce.js.map +1 -1
- package/dist/components/gui/menu/equip-menu.ce.js +121 -172
- package/dist/components/gui/menu/equip-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/exit-menu.ce.js +15 -10
- package/dist/components/gui/menu/exit-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/items-menu.ce.js +62 -77
- package/dist/components/gui/menu/items-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/main-menu.ce.js +89 -104
- package/dist/components/gui/menu/main-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/options-menu.ce.js +12 -8
- package/dist/components/gui/menu/options-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/skills-menu.ce.js +17 -19
- package/dist/components/gui/menu/skills-menu.ce.js.map +1 -1
- package/dist/components/gui/mobile/index.d.ts +51 -2
- package/dist/components/gui/mobile/index.js +14 -6
- package/dist/components/gui/mobile/index.js.map +1 -1
- package/dist/components/gui/mobile/index.spec.d.ts +1 -0
- package/dist/components/gui/mobile/mobile.ce.js +309 -59
- package/dist/components/gui/mobile/mobile.ce.js.map +1 -1
- package/dist/components/gui/notification/notification.ce.js +28 -26
- package/dist/components/gui/notification/notification.ce.js.map +1 -1
- package/dist/components/gui/save-load.ce.js +81 -256
- package/dist/components/gui/save-load.ce.js.map +1 -1
- package/dist/components/gui/shop/shop.ce.js +107 -142
- package/dist/components/gui/shop/shop.ce.js.map +1 -1
- package/dist/components/gui/title-screen.ce.js +50 -73
- package/dist/components/gui/title-screen.ce.js.map +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +1 -0
- package/dist/components/interaction-components.ce.js +22 -0
- package/dist/components/interaction-components.ce.js.map +1 -0
- package/dist/components/player-components-utils.d.ts +67 -0
- package/dist/components/player-components-utils.js +162 -0
- package/dist/components/player-components-utils.js.map +1 -0
- package/dist/components/player-components-utils.spec.d.ts +1 -0
- package/dist/components/player-components.ce.js +191 -0
- package/dist/components/player-components.ce.js.map +1 -0
- package/dist/components/prebuilt/hp-bar.ce.js +45 -45
- package/dist/components/prebuilt/hp-bar.ce.js.map +1 -1
- package/dist/components/prebuilt/light-halo.ce.js +39 -60
- package/dist/components/prebuilt/light-halo.ce.js.map +1 -1
- package/dist/components/scenes/canvas.ce.js +205 -27
- package/dist/components/scenes/canvas.ce.js.map +1 -1
- package/dist/components/scenes/draw-map.ce.js +39 -39
- package/dist/components/scenes/draw-map.ce.js.map +1 -1
- package/dist/components/scenes/event-layer.ce.js +51 -10
- package/dist/components/scenes/event-layer.ce.js.map +1 -1
- package/dist/core/inject.js +1 -1
- package/dist/core/inject.js.map +1 -1
- package/dist/core/setup.js +1 -1
- package/dist/core/setup.js.map +1 -1
- package/dist/decorators/spritesheet.d.ts +1 -0
- package/dist/decorators/spritesheet.js +11 -0
- package/dist/decorators/spritesheet.js.map +1 -0
- package/dist/i18n.d.ts +55 -0
- package/dist/i18n.js +60 -0
- package/dist/i18n.js.map +1 -0
- package/dist/i18n.spec.d.ts +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +29 -21
- package/dist/module.js +45 -4
- package/dist/module.js.map +1 -1
- package/dist/node_modules/.pnpm/{@signe_di@2.9.0 → @signe_di@3.1.0}/node_modules/@signe/di/dist/index.js +7 -117
- package/dist/node_modules/.pnpm/@signe_di@3.1.0/node_modules/@signe/di/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_reactive@3.1.0/node_modules/@signe/reactive/dist/index.js +239 -0
- package/dist/node_modules/.pnpm/@signe_reactive@3.1.0/node_modules/@signe/reactive/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_room@3.1.0_react@19.2.7/node_modules/@signe/room/dist/chunk-EUXUH3YW.js +13 -0
- package/dist/node_modules/.pnpm/@signe_room@3.1.0_react@19.2.7/node_modules/@signe/room/dist/chunk-EUXUH3YW.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_room@3.1.0_react@19.2.7/node_modules/@signe/room/dist/index.js +698 -0
- package/dist/node_modules/.pnpm/@signe_room@3.1.0_react@19.2.7/node_modules/@signe/room/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_sync@3.1.0_react@19.2.7/node_modules/@signe/sync/dist/client/index.js +43 -0
- package/dist/node_modules/.pnpm/@signe_sync@3.1.0_react@19.2.7/node_modules/@signe/sync/dist/client/index.js.map +1 -0
- package/dist/node_modules/.pnpm/{@signe_sync@2.9.0 → @signe_sync@3.1.0_react@19.2.7}/node_modules/@signe/sync/dist/index.js +57 -141
- package/dist/node_modules/.pnpm/@signe_sync@3.1.0_react@19.2.7/node_modules/@signe/sync/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/{partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js → partysocket@1.2.0_react@19.2.7/node_modules/partysocket/dist/index.js} +30 -17
- package/dist/node_modules/.pnpm/partysocket@1.2.0_react@19.2.7/node_modules/partysocket/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/{partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js → partysocket@1.2.0_react@19.2.7/node_modules/partysocket/dist/ws.js} +65 -34
- package/dist/node_modules/.pnpm/partysocket@1.2.0_react@19.2.7/node_modules/partysocket/dist/ws.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/index.js +13 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/index.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js +106 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js +13 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js +121 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js +10 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js +110 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js +99 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js +82 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js.map +1 -0
- package/dist/node_modules/.pnpm/{zod@3.24.2/node_modules/zod/lib/index.js → zod@3.25.76/node_modules/zod/v3/types.js} +74 -611
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js.map +1 -0
- package/dist/presets/animation.js.map +1 -1
- package/dist/presets/faceset.js.map +1 -1
- package/dist/presets/icon.js.map +1 -1
- package/dist/presets/index.js.map +1 -1
- package/dist/presets/lpc.js.map +1 -1
- package/dist/presets/rmspritesheet.js.map +1 -1
- package/dist/services/AbstractSocket.d.ts +2 -0
- package/dist/services/AbstractSocket.js.map +1 -1
- package/dist/services/actionInput.d.ts +14 -0
- package/dist/services/actionInput.js +59 -0
- package/dist/services/actionInput.js.map +1 -0
- package/dist/services/actionInput.spec.d.ts +1 -0
- package/dist/services/cameraFollow.d.ts +51 -0
- package/dist/services/cameraFollow.js +134 -0
- package/dist/services/cameraFollow.js.map +1 -0
- package/dist/services/cameraFollow.spec.d.ts +1 -0
- package/dist/services/interactions.d.ts +159 -0
- package/dist/services/interactions.js +460 -0
- package/dist/services/interactions.js.map +1 -0
- package/dist/services/interactions.spec.d.ts +1 -0
- package/dist/services/keyboardControls.d.ts +1 -0
- package/dist/services/keyboardControls.js +1 -0
- package/dist/services/keyboardControls.js.map +1 -1
- package/dist/services/loadMap.d.ts +9 -0
- package/dist/services/loadMap.js +1 -1
- package/dist/services/loadMap.js.map +1 -1
- package/dist/services/mmorpg-connection.d.ts +5 -0
- package/dist/services/mmorpg-connection.js +50 -0
- package/dist/services/mmorpg-connection.js.map +1 -0
- package/dist/services/mmorpg-connection.spec.d.ts +1 -0
- package/dist/services/mmorpg.d.ts +11 -4
- package/dist/services/mmorpg.js +57 -33
- package/dist/services/mmorpg.js.map +1 -1
- package/dist/services/pointerContext.d.ts +11 -0
- package/dist/services/pointerContext.js +48 -0
- package/dist/services/pointerContext.js.map +1 -0
- package/dist/services/pointerContext.spec.d.ts +1 -0
- package/dist/services/save.js.map +1 -1
- package/dist/services/save.spec.d.ts +1 -0
- package/dist/services/standalone-message.d.ts +1 -0
- package/dist/services/standalone-message.js +9 -0
- package/dist/services/standalone-message.js.map +1 -0
- package/dist/services/standalone.d.ts +4 -1
- package/dist/services/standalone.js +36 -16
- package/dist/services/standalone.js.map +1 -1
- package/dist/services/standalone.spec.d.ts +1 -0
- package/dist/utils/getEntityProp.js +4 -3
- package/dist/utils/getEntityProp.js.map +1 -1
- package/dist/utils/getEntityProp.spec.d.ts +1 -0
- package/dist/utils/mapId.d.ts +1 -0
- package/dist/utils/mapId.js +6 -0
- package/dist/utils/mapId.js.map +1 -0
- package/dist/utils/readPropValue.d.ts +2 -0
- package/dist/utils/readPropValue.js +13 -0
- package/dist/utils/readPropValue.js.map +1 -0
- package/package.json +13 -13
- package/src/Game/AnimationManager.spec.ts +30 -0
- package/src/Game/AnimationManager.ts +26 -10
- package/src/Game/ClientVisuals.spec.ts +56 -0
- package/src/Game/ClientVisuals.ts +184 -0
- package/src/Game/EventComponentResolver.spec.ts +84 -0
- package/src/Game/EventComponentResolver.ts +74 -0
- package/src/Game/Map.ts +134 -2
- package/src/Game/Object.spec.ts +59 -0
- package/src/Game/Object.ts +181 -77
- package/src/Game/ProjectileManager.spec.ts +449 -0
- package/src/Game/ProjectileManager.ts +346 -0
- package/src/Gui/Gui.spec.ts +359 -0
- package/src/Gui/Gui.ts +178 -67
- package/src/Resource.ts +1 -2
- package/src/RpgClient.ts +220 -17
- package/src/RpgClientEngine.ts +995 -133
- package/src/components/animations/fx.ce +101 -0
- package/src/components/animations/index.ts +4 -2
- package/src/components/character.ce +839 -45
- package/src/components/dynamics/bar.ce +88 -0
- package/src/components/dynamics/image.ce +21 -0
- package/src/components/dynamics/parse-value.spec.ts +83 -0
- package/src/components/dynamics/parse-value.ts +111 -37
- package/src/components/dynamics/shape-utils.spec.ts +46 -0
- package/src/components/dynamics/shape-utils.ts +61 -0
- package/src/components/dynamics/shape.ce +90 -0
- package/src/components/dynamics/text.ce +35 -149
- package/src/components/gui/dialogbox/index.ce +52 -21
- package/src/components/gui/gameover.ce +6 -4
- package/src/components/gui/menu/equip-menu.ce +11 -9
- package/src/components/gui/menu/exit-menu.ce +6 -4
- package/src/components/gui/menu/items-menu.ce +11 -9
- package/src/components/gui/menu/main-menu.ce +14 -12
- package/src/components/gui/menu/options-menu.ce +4 -3
- package/src/components/gui/menu/skills-menu.ce +2 -1
- package/src/components/gui/mobile/index.spec.ts +94 -0
- package/src/components/gui/mobile/index.ts +74 -6
- package/src/components/gui/mobile/mobile.ce +347 -65
- package/src/components/gui/notification/notification.ce +7 -1
- package/src/components/gui/save-load.ce +13 -11
- package/src/components/gui/shop/shop.ce +20 -18
- package/src/components/gui/title-screen.ce +6 -4
- package/src/components/index.ts +2 -1
- package/src/components/interaction-components.ce +23 -0
- package/src/components/player-components-utils.spec.ts +109 -0
- package/src/components/player-components-utils.ts +205 -0
- package/src/components/player-components.ce +222 -0
- package/src/components/prebuilt/hp-bar.ce +4 -3
- package/src/components/prebuilt/light-halo.ce +2 -2
- package/src/components/scenes/canvas.ce +219 -15
- package/src/components/scenes/draw-map.ce +34 -22
- package/src/components/scenes/event-layer.ce +55 -4
- package/src/core/setup.ts +2 -2
- package/src/decorators/spritesheet.ts +8 -0
- package/src/i18n.spec.ts +39 -0
- package/src/i18n.ts +59 -0
- package/src/index.ts +19 -0
- package/src/module.ts +61 -11
- package/src/services/AbstractSocket.ts +3 -0
- package/src/services/actionInput.spec.ts +155 -0
- package/src/services/actionInput.ts +120 -0
- package/src/services/cameraFollow.spec.ts +220 -0
- package/src/services/cameraFollow.ts +222 -0
- package/src/services/interactions.spec.ts +175 -0
- package/src/services/interactions.ts +722 -0
- package/src/services/keyboardControls.ts +2 -1
- package/src/services/loadMap.ts +5 -1
- package/src/services/mmorpg-connection.spec.ts +99 -0
- package/src/services/mmorpg-connection.ts +69 -0
- package/src/services/mmorpg.ts +70 -36
- package/src/services/pointerContext.spec.ts +36 -0
- package/src/services/pointerContext.ts +84 -0
- package/src/services/save.spec.ts +127 -0
- package/src/services/standalone-message.ts +7 -0
- package/src/services/standalone.spec.ts +54 -0
- package/src/services/standalone.ts +44 -12
- package/src/utils/getEntityProp.spec.ts +96 -0
- package/src/utils/getEntityProp.ts +4 -3
- package/src/utils/mapId.ts +2 -0
- package/src/utils/readPropValue.ts +16 -0
- package/dist/node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js.map +0 -1
- package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js +0 -457
- package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js.map +0 -1
- package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js +0 -463
- package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js.map +0 -1
- package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js +0 -2191
- package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js.map +0 -1
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js +0 -10
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js.map +0 -1
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js +0 -91
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js.map +0 -1
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/index.js.map +0 -1
- package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js +0 -14
- package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js.map +0 -1
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +0 -1
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +0 -1
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/index.js +0 -2
- package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +0 -1
|
@@ -1,412 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
throw new Error();
|
|
9
|
-
}
|
|
10
|
-
util.assertNever = assertNever;
|
|
11
|
-
util.arrayToEnum = (items) => {
|
|
12
|
-
const obj = {};
|
|
13
|
-
for (const item of items) obj[item] = item;
|
|
14
|
-
return obj;
|
|
15
|
-
};
|
|
16
|
-
util.getValidEnumValues = (obj) => {
|
|
17
|
-
const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
|
|
18
|
-
const filtered = {};
|
|
19
|
-
for (const k of validKeys) filtered[k] = obj[k];
|
|
20
|
-
return util.objectValues(filtered);
|
|
21
|
-
};
|
|
22
|
-
util.objectValues = (obj) => {
|
|
23
|
-
return util.objectKeys(obj).map(function(e) {
|
|
24
|
-
return obj[e];
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
util.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
|
|
28
|
-
const keys = [];
|
|
29
|
-
for (const key in object) if (Object.prototype.hasOwnProperty.call(object, key)) keys.push(key);
|
|
30
|
-
return keys;
|
|
31
|
-
};
|
|
32
|
-
util.find = (arr, checker) => {
|
|
33
|
-
for (const item of arr) if (checker(item)) return item;
|
|
34
|
-
};
|
|
35
|
-
util.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
|
|
36
|
-
function joinValues(array, separator = " | ") {
|
|
37
|
-
return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
|
|
38
|
-
}
|
|
39
|
-
util.joinValues = joinValues;
|
|
40
|
-
util.jsonStringifyReplacer = (_, value) => {
|
|
41
|
-
if (typeof value === "bigint") return value.toString();
|
|
42
|
-
return value;
|
|
43
|
-
};
|
|
44
|
-
})(util || (util = {}));
|
|
45
|
-
var objectUtil;
|
|
46
|
-
(function(objectUtil) {
|
|
47
|
-
objectUtil.mergeShapes = (first, second) => {
|
|
48
|
-
return {
|
|
49
|
-
...first,
|
|
50
|
-
...second
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
})(objectUtil || (objectUtil = {}));
|
|
54
|
-
var ZodParsedType = util.arrayToEnum([
|
|
55
|
-
"string",
|
|
56
|
-
"nan",
|
|
57
|
-
"number",
|
|
58
|
-
"integer",
|
|
59
|
-
"float",
|
|
60
|
-
"boolean",
|
|
61
|
-
"date",
|
|
62
|
-
"bigint",
|
|
63
|
-
"symbol",
|
|
64
|
-
"function",
|
|
65
|
-
"undefined",
|
|
66
|
-
"null",
|
|
67
|
-
"array",
|
|
68
|
-
"object",
|
|
69
|
-
"unknown",
|
|
70
|
-
"promise",
|
|
71
|
-
"void",
|
|
72
|
-
"never",
|
|
73
|
-
"map",
|
|
74
|
-
"set"
|
|
75
|
-
]);
|
|
76
|
-
var getParsedType = (data) => {
|
|
77
|
-
switch (typeof data) {
|
|
78
|
-
case "undefined": return ZodParsedType.undefined;
|
|
79
|
-
case "string": return ZodParsedType.string;
|
|
80
|
-
case "number": return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
|
81
|
-
case "boolean": return ZodParsedType.boolean;
|
|
82
|
-
case "function": return ZodParsedType.function;
|
|
83
|
-
case "bigint": return ZodParsedType.bigint;
|
|
84
|
-
case "symbol": return ZodParsedType.symbol;
|
|
85
|
-
case "object":
|
|
86
|
-
if (Array.isArray(data)) return ZodParsedType.array;
|
|
87
|
-
if (data === null) return ZodParsedType.null;
|
|
88
|
-
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") return ZodParsedType.promise;
|
|
89
|
-
if (typeof Map !== "undefined" && data instanceof Map) return ZodParsedType.map;
|
|
90
|
-
if (typeof Set !== "undefined" && data instanceof Set) return ZodParsedType.set;
|
|
91
|
-
if (typeof Date !== "undefined" && data instanceof Date) return ZodParsedType.date;
|
|
92
|
-
return ZodParsedType.object;
|
|
93
|
-
default: return ZodParsedType.unknown;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
var ZodIssueCode = util.arrayToEnum([
|
|
97
|
-
"invalid_type",
|
|
98
|
-
"invalid_literal",
|
|
99
|
-
"custom",
|
|
100
|
-
"invalid_union",
|
|
101
|
-
"invalid_union_discriminator",
|
|
102
|
-
"invalid_enum_value",
|
|
103
|
-
"unrecognized_keys",
|
|
104
|
-
"invalid_arguments",
|
|
105
|
-
"invalid_return_type",
|
|
106
|
-
"invalid_date",
|
|
107
|
-
"invalid_string",
|
|
108
|
-
"too_small",
|
|
109
|
-
"too_big",
|
|
110
|
-
"invalid_intersection_types",
|
|
111
|
-
"not_multiple_of",
|
|
112
|
-
"not_finite"
|
|
113
|
-
]);
|
|
114
|
-
var quotelessJson = (obj) => {
|
|
115
|
-
return JSON.stringify(obj, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
116
|
-
};
|
|
117
|
-
var ZodError = class ZodError extends Error {
|
|
118
|
-
get errors() {
|
|
119
|
-
return this.issues;
|
|
120
|
-
}
|
|
121
|
-
constructor(issues) {
|
|
122
|
-
super();
|
|
123
|
-
this.issues = [];
|
|
124
|
-
this.addIssue = (sub) => {
|
|
125
|
-
this.issues = [...this.issues, sub];
|
|
126
|
-
};
|
|
127
|
-
this.addIssues = (subs = []) => {
|
|
128
|
-
this.issues = [...this.issues, ...subs];
|
|
129
|
-
};
|
|
130
|
-
const actualProto = new.target.prototype;
|
|
131
|
-
if (Object.setPrototypeOf) Object.setPrototypeOf(this, actualProto);
|
|
132
|
-
else this.__proto__ = actualProto;
|
|
133
|
-
this.name = "ZodError";
|
|
134
|
-
this.issues = issues;
|
|
135
|
-
}
|
|
136
|
-
format(_mapper) {
|
|
137
|
-
const mapper = _mapper || function(issue) {
|
|
138
|
-
return issue.message;
|
|
139
|
-
};
|
|
140
|
-
const fieldErrors = { _errors: [] };
|
|
141
|
-
const processError = (error) => {
|
|
142
|
-
for (const issue of error.issues) if (issue.code === "invalid_union") issue.unionErrors.map(processError);
|
|
143
|
-
else if (issue.code === "invalid_return_type") processError(issue.returnTypeError);
|
|
144
|
-
else if (issue.code === "invalid_arguments") processError(issue.argumentsError);
|
|
145
|
-
else if (issue.path.length === 0) fieldErrors._errors.push(mapper(issue));
|
|
146
|
-
else {
|
|
147
|
-
let curr = fieldErrors;
|
|
148
|
-
let i = 0;
|
|
149
|
-
while (i < issue.path.length) {
|
|
150
|
-
const el = issue.path[i];
|
|
151
|
-
if (!(i === issue.path.length - 1)) curr[el] = curr[el] || { _errors: [] };
|
|
152
|
-
else {
|
|
153
|
-
curr[el] = curr[el] || { _errors: [] };
|
|
154
|
-
curr[el]._errors.push(mapper(issue));
|
|
155
|
-
}
|
|
156
|
-
curr = curr[el];
|
|
157
|
-
i++;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
processError(this);
|
|
162
|
-
return fieldErrors;
|
|
163
|
-
}
|
|
164
|
-
static assert(value) {
|
|
165
|
-
if (!(value instanceof ZodError)) throw new Error(`Not a ZodError: ${value}`);
|
|
166
|
-
}
|
|
167
|
-
toString() {
|
|
168
|
-
return this.message;
|
|
169
|
-
}
|
|
170
|
-
get message() {
|
|
171
|
-
return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
|
|
172
|
-
}
|
|
173
|
-
get isEmpty() {
|
|
174
|
-
return this.issues.length === 0;
|
|
175
|
-
}
|
|
176
|
-
flatten(mapper = (issue) => issue.message) {
|
|
177
|
-
const fieldErrors = {};
|
|
178
|
-
const formErrors = [];
|
|
179
|
-
for (const sub of this.issues) if (sub.path.length > 0) {
|
|
180
|
-
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
181
|
-
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
182
|
-
} else formErrors.push(mapper(sub));
|
|
183
|
-
return {
|
|
184
|
-
formErrors,
|
|
185
|
-
fieldErrors
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
get formErrors() {
|
|
189
|
-
return this.flatten();
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
ZodError.create = (issues) => {
|
|
193
|
-
return new ZodError(issues);
|
|
194
|
-
};
|
|
195
|
-
var errorMap = (issue, _ctx) => {
|
|
196
|
-
let message;
|
|
197
|
-
switch (issue.code) {
|
|
198
|
-
case ZodIssueCode.invalid_type:
|
|
199
|
-
if (issue.received === ZodParsedType.undefined) message = "Required";
|
|
200
|
-
else message = `Expected ${issue.expected}, received ${issue.received}`;
|
|
201
|
-
break;
|
|
202
|
-
case ZodIssueCode.invalid_literal:
|
|
203
|
-
message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
|
|
204
|
-
break;
|
|
205
|
-
case ZodIssueCode.unrecognized_keys:
|
|
206
|
-
message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
|
|
207
|
-
break;
|
|
208
|
-
case ZodIssueCode.invalid_union:
|
|
209
|
-
message = `Invalid input`;
|
|
210
|
-
break;
|
|
211
|
-
case ZodIssueCode.invalid_union_discriminator:
|
|
212
|
-
message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
|
|
213
|
-
break;
|
|
214
|
-
case ZodIssueCode.invalid_enum_value:
|
|
215
|
-
message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
|
|
216
|
-
break;
|
|
217
|
-
case ZodIssueCode.invalid_arguments:
|
|
218
|
-
message = `Invalid function arguments`;
|
|
219
|
-
break;
|
|
220
|
-
case ZodIssueCode.invalid_return_type:
|
|
221
|
-
message = `Invalid function return type`;
|
|
222
|
-
break;
|
|
223
|
-
case ZodIssueCode.invalid_date:
|
|
224
|
-
message = `Invalid date`;
|
|
225
|
-
break;
|
|
226
|
-
case ZodIssueCode.invalid_string:
|
|
227
|
-
if (typeof issue.validation === "object") if ("includes" in issue.validation) {
|
|
228
|
-
message = `Invalid input: must include "${issue.validation.includes}"`;
|
|
229
|
-
if (typeof issue.validation.position === "number") message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
|
|
230
|
-
} else if ("startsWith" in issue.validation) message = `Invalid input: must start with "${issue.validation.startsWith}"`;
|
|
231
|
-
else if ("endsWith" in issue.validation) message = `Invalid input: must end with "${issue.validation.endsWith}"`;
|
|
232
|
-
else util.assertNever(issue.validation);
|
|
233
|
-
else if (issue.validation !== "regex") message = `Invalid ${issue.validation}`;
|
|
234
|
-
else message = "Invalid";
|
|
235
|
-
break;
|
|
236
|
-
case ZodIssueCode.too_small:
|
|
237
|
-
if (issue.type === "array") message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
|
|
238
|
-
else if (issue.type === "string") message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
|
|
239
|
-
else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
240
|
-
else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
|
|
241
|
-
else message = "Invalid input";
|
|
242
|
-
break;
|
|
243
|
-
case ZodIssueCode.too_big:
|
|
244
|
-
if (issue.type === "array") message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
|
|
245
|
-
else if (issue.type === "string") message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
|
|
246
|
-
else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
247
|
-
else if (issue.type === "bigint") message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
248
|
-
else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
|
|
249
|
-
else message = "Invalid input";
|
|
250
|
-
break;
|
|
251
|
-
case ZodIssueCode.custom:
|
|
252
|
-
message = `Invalid input`;
|
|
253
|
-
break;
|
|
254
|
-
case ZodIssueCode.invalid_intersection_types:
|
|
255
|
-
message = `Intersection results could not be merged`;
|
|
256
|
-
break;
|
|
257
|
-
case ZodIssueCode.not_multiple_of:
|
|
258
|
-
message = `Number must be a multiple of ${issue.multipleOf}`;
|
|
259
|
-
break;
|
|
260
|
-
case ZodIssueCode.not_finite:
|
|
261
|
-
message = "Number must be finite";
|
|
262
|
-
break;
|
|
263
|
-
default:
|
|
264
|
-
message = _ctx.defaultError;
|
|
265
|
-
util.assertNever(issue);
|
|
266
|
-
}
|
|
267
|
-
return { message };
|
|
268
|
-
};
|
|
269
|
-
var overrideErrorMap = errorMap;
|
|
270
|
-
function setErrorMap(map) {
|
|
271
|
-
overrideErrorMap = map;
|
|
272
|
-
}
|
|
273
|
-
function getErrorMap() {
|
|
274
|
-
return overrideErrorMap;
|
|
275
|
-
}
|
|
276
|
-
var makeIssue = (params) => {
|
|
277
|
-
const { data, path, errorMaps, issueData } = params;
|
|
278
|
-
const fullPath = [...path, ...issueData.path || []];
|
|
279
|
-
const fullIssue = {
|
|
280
|
-
...issueData,
|
|
281
|
-
path: fullPath
|
|
282
|
-
};
|
|
283
|
-
if (issueData.message !== void 0) return {
|
|
284
|
-
...issueData,
|
|
285
|
-
path: fullPath,
|
|
286
|
-
message: issueData.message
|
|
287
|
-
};
|
|
288
|
-
let errorMessage = "";
|
|
289
|
-
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
290
|
-
for (const map of maps) errorMessage = map(fullIssue, {
|
|
291
|
-
data,
|
|
292
|
-
defaultError: errorMessage
|
|
293
|
-
}).message;
|
|
294
|
-
return {
|
|
295
|
-
...issueData,
|
|
296
|
-
path: fullPath,
|
|
297
|
-
message: errorMessage
|
|
298
|
-
};
|
|
299
|
-
};
|
|
300
|
-
var EMPTY_PATH = [];
|
|
301
|
-
function addIssueToContext(ctx, issueData) {
|
|
302
|
-
const overrideMap = getErrorMap();
|
|
303
|
-
const issue = makeIssue({
|
|
304
|
-
issueData,
|
|
305
|
-
data: ctx.data,
|
|
306
|
-
path: ctx.path,
|
|
307
|
-
errorMaps: [
|
|
308
|
-
ctx.common.contextualErrorMap,
|
|
309
|
-
ctx.schemaErrorMap,
|
|
310
|
-
overrideMap,
|
|
311
|
-
overrideMap === errorMap ? void 0 : errorMap
|
|
312
|
-
].filter((x) => !!x)
|
|
313
|
-
});
|
|
314
|
-
ctx.common.issues.push(issue);
|
|
315
|
-
}
|
|
316
|
-
var ParseStatus = class ParseStatus {
|
|
317
|
-
constructor() {
|
|
318
|
-
this.value = "valid";
|
|
319
|
-
}
|
|
320
|
-
dirty() {
|
|
321
|
-
if (this.value === "valid") this.value = "dirty";
|
|
322
|
-
}
|
|
323
|
-
abort() {
|
|
324
|
-
if (this.value !== "aborted") this.value = "aborted";
|
|
325
|
-
}
|
|
326
|
-
static mergeArray(status, results) {
|
|
327
|
-
const arrayValue = [];
|
|
328
|
-
for (const s of results) {
|
|
329
|
-
if (s.status === "aborted") return INVALID;
|
|
330
|
-
if (s.status === "dirty") status.dirty();
|
|
331
|
-
arrayValue.push(s.value);
|
|
332
|
-
}
|
|
333
|
-
return {
|
|
334
|
-
status: status.value,
|
|
335
|
-
value: arrayValue
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
static async mergeObjectAsync(status, pairs) {
|
|
339
|
-
const syncPairs = [];
|
|
340
|
-
for (const pair of pairs) {
|
|
341
|
-
const key = await pair.key;
|
|
342
|
-
const value = await pair.value;
|
|
343
|
-
syncPairs.push({
|
|
344
|
-
key,
|
|
345
|
-
value
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
return ParseStatus.mergeObjectSync(status, syncPairs);
|
|
349
|
-
}
|
|
350
|
-
static mergeObjectSync(status, pairs) {
|
|
351
|
-
const finalObject = {};
|
|
352
|
-
for (const pair of pairs) {
|
|
353
|
-
const { key, value } = pair;
|
|
354
|
-
if (key.status === "aborted") return INVALID;
|
|
355
|
-
if (value.status === "aborted") return INVALID;
|
|
356
|
-
if (key.status === "dirty") status.dirty();
|
|
357
|
-
if (value.status === "dirty") status.dirty();
|
|
358
|
-
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) finalObject[key.value] = value.value;
|
|
359
|
-
}
|
|
360
|
-
return {
|
|
361
|
-
status: status.value,
|
|
362
|
-
value: finalObject
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
var INVALID = Object.freeze({ status: "aborted" });
|
|
367
|
-
var DIRTY = (value) => ({
|
|
368
|
-
status: "dirty",
|
|
369
|
-
value
|
|
370
|
-
});
|
|
371
|
-
var OK = (value) => ({
|
|
372
|
-
status: "valid",
|
|
373
|
-
value
|
|
374
|
-
});
|
|
375
|
-
var isAborted = (x) => x.status === "aborted";
|
|
376
|
-
var isDirty = (x) => x.status === "dirty";
|
|
377
|
-
var isValid = (x) => x.status === "valid";
|
|
378
|
-
var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
379
|
-
/******************************************************************************
|
|
380
|
-
Copyright (c) Microsoft Corporation.
|
|
381
|
-
|
|
382
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
383
|
-
purpose with or without fee is hereby granted.
|
|
384
|
-
|
|
385
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
386
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
387
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
388
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
389
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
390
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
391
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
392
|
-
***************************************************************************** */
|
|
393
|
-
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
394
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
395
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
396
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
397
|
-
}
|
|
398
|
-
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
399
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
400
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
401
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
402
|
-
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
403
|
-
}
|
|
404
|
-
var errorUtil;
|
|
405
|
-
(function(errorUtil) {
|
|
406
|
-
errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
407
|
-
errorUtil.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
408
|
-
})(errorUtil || (errorUtil = {}));
|
|
409
|
-
var _ZodEnum_cache, _ZodNativeEnum_cache;
|
|
1
|
+
import { ZodParsedType, getParsedType, util } from "./helpers/util.js";
|
|
2
|
+
import { ZodError, ZodIssueCode } from "./ZodError.js";
|
|
3
|
+
import errorMap from "./locales/en.js";
|
|
4
|
+
import { getErrorMap } from "./errors.js";
|
|
5
|
+
import { DIRTY, INVALID, OK, ParseStatus, addIssueToContext, isAborted, isAsync, isDirty, isValid, makeIssue } from "./helpers/parseUtil.js";
|
|
6
|
+
import { errorUtil } from "./helpers/errorUtil.js";
|
|
7
|
+
//#region ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
410
8
|
var ParseInputLazyPath = class {
|
|
411
9
|
constructor(parent, value, path, key) {
|
|
412
10
|
this._cachedPath = [];
|
|
@@ -416,7 +14,7 @@ var ParseInputLazyPath = class {
|
|
|
416
14
|
this._key = key;
|
|
417
15
|
}
|
|
418
16
|
get path() {
|
|
419
|
-
if (!this._cachedPath.length) if (this._key
|
|
17
|
+
if (!this._cachedPath.length) if (Array.isArray(this._key)) this._cachedPath.push(...this._path, ...this._key);
|
|
420
18
|
else this._cachedPath.push(...this._path, this._key);
|
|
421
19
|
return this._cachedPath;
|
|
422
20
|
}
|
|
@@ -432,7 +30,8 @@ var handleResult = (ctx, result) => {
|
|
|
432
30
|
success: false,
|
|
433
31
|
get error() {
|
|
434
32
|
if (this._error) return this._error;
|
|
435
|
-
|
|
33
|
+
const error = new ZodError(ctx.common.issues);
|
|
34
|
+
this._error = error;
|
|
436
35
|
return this._error;
|
|
437
36
|
}
|
|
438
37
|
};
|
|
@@ -447,12 +46,11 @@ function processCreateParams(params) {
|
|
|
447
46
|
description
|
|
448
47
|
};
|
|
449
48
|
const customMap = (iss, ctx) => {
|
|
450
|
-
var _a, _b;
|
|
451
49
|
const { message } = params;
|
|
452
|
-
if (iss.code === "invalid_enum_value") return { message: message
|
|
453
|
-
if (typeof ctx.data === "undefined") return { message:
|
|
50
|
+
if (iss.code === "invalid_enum_value") return { message: message ?? ctx.defaultError };
|
|
51
|
+
if (typeof ctx.data === "undefined") return { message: message ?? required_error ?? ctx.defaultError };
|
|
454
52
|
if (iss.code !== "invalid_type") return { message: ctx.defaultError };
|
|
455
|
-
return { message:
|
|
53
|
+
return { message: message ?? invalid_type_error ?? ctx.defaultError };
|
|
456
54
|
};
|
|
457
55
|
return {
|
|
458
56
|
errorMap: customMap,
|
|
@@ -504,14 +102,13 @@ var ZodType = class {
|
|
|
504
102
|
throw result.error;
|
|
505
103
|
}
|
|
506
104
|
safeParse(data, params) {
|
|
507
|
-
var _a;
|
|
508
105
|
const ctx = {
|
|
509
106
|
common: {
|
|
510
107
|
issues: [],
|
|
511
|
-
async:
|
|
512
|
-
contextualErrorMap: params
|
|
108
|
+
async: params?.async ?? false,
|
|
109
|
+
contextualErrorMap: params?.errorMap
|
|
513
110
|
},
|
|
514
|
-
path:
|
|
111
|
+
path: params?.path || [],
|
|
515
112
|
schemaErrorMap: this._def.errorMap,
|
|
516
113
|
parent: null,
|
|
517
114
|
data,
|
|
@@ -524,7 +121,6 @@ var ZodType = class {
|
|
|
524
121
|
}));
|
|
525
122
|
}
|
|
526
123
|
"~validate"(data) {
|
|
527
|
-
var _a, _b;
|
|
528
124
|
const ctx = {
|
|
529
125
|
common: {
|
|
530
126
|
issues: [],
|
|
@@ -544,7 +140,7 @@ var ZodType = class {
|
|
|
544
140
|
});
|
|
545
141
|
return isValid(result) ? { value: result.value } : { issues: ctx.common.issues };
|
|
546
142
|
} catch (err) {
|
|
547
|
-
if (
|
|
143
|
+
if (err?.message?.toLowerCase()?.includes("encountered")) this["~standard"].async = true;
|
|
548
144
|
ctx.common = {
|
|
549
145
|
issues: [],
|
|
550
146
|
async: true
|
|
@@ -565,10 +161,10 @@ var ZodType = class {
|
|
|
565
161
|
const ctx = {
|
|
566
162
|
common: {
|
|
567
163
|
issues: [],
|
|
568
|
-
contextualErrorMap: params
|
|
164
|
+
contextualErrorMap: params?.errorMap,
|
|
569
165
|
async: true
|
|
570
166
|
},
|
|
571
|
-
path:
|
|
167
|
+
path: params?.path || [],
|
|
572
168
|
schemaErrorMap: this._def.errorMap,
|
|
573
169
|
parent: null,
|
|
574
170
|
data,
|
|
@@ -756,10 +352,11 @@ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_
|
|
|
756
352
|
var dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
|
|
757
353
|
var dateRegex = new RegExp(`^${dateRegexSource}$`);
|
|
758
354
|
function timeRegexSource(args) {
|
|
759
|
-
let
|
|
760
|
-
if (args.precision)
|
|
761
|
-
else if (args.precision == null)
|
|
762
|
-
|
|
355
|
+
let secondsRegexSource = `[0-5]\\d`;
|
|
356
|
+
if (args.precision) secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
|
|
357
|
+
else if (args.precision == null) secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
|
|
358
|
+
const secondsQuantifier = args.precision ? "+" : "?";
|
|
359
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
|
|
763
360
|
}
|
|
764
361
|
function timeRegex(args) {
|
|
765
362
|
return new RegExp(`^${timeRegexSource(args)}$`);
|
|
@@ -781,13 +378,15 @@ function isValidJWT(jwt, alg) {
|
|
|
781
378
|
if (!jwtRegex.test(jwt)) return false;
|
|
782
379
|
try {
|
|
783
380
|
const [header] = jwt.split(".");
|
|
381
|
+
if (!header) return false;
|
|
784
382
|
const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
|
|
785
383
|
const decoded = JSON.parse(atob(base64));
|
|
786
384
|
if (typeof decoded !== "object" || decoded === null) return false;
|
|
787
|
-
if (
|
|
385
|
+
if ("typ" in decoded && decoded?.typ !== "JWT") return false;
|
|
386
|
+
if (!decoded.alg) return false;
|
|
788
387
|
if (alg && decoded.alg !== alg) return false;
|
|
789
388
|
return true;
|
|
790
|
-
} catch
|
|
389
|
+
} catch {
|
|
791
390
|
return false;
|
|
792
391
|
}
|
|
793
392
|
}
|
|
@@ -932,7 +531,7 @@ var ZodString = class ZodString extends ZodType {
|
|
|
932
531
|
}
|
|
933
532
|
} else if (check.kind === "url") try {
|
|
934
533
|
new URL(input.data);
|
|
935
|
-
} catch
|
|
534
|
+
} catch {
|
|
936
535
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
937
536
|
addIssueToContext(ctx, {
|
|
938
537
|
validation: "url",
|
|
@@ -1176,7 +775,6 @@ var ZodString = class ZodString extends ZodType {
|
|
|
1176
775
|
});
|
|
1177
776
|
}
|
|
1178
777
|
datetime(options) {
|
|
1179
|
-
var _a, _b;
|
|
1180
778
|
if (typeof options === "string") return this._addCheck({
|
|
1181
779
|
kind: "datetime",
|
|
1182
780
|
precision: null,
|
|
@@ -1186,10 +784,10 @@ var ZodString = class ZodString extends ZodType {
|
|
|
1186
784
|
});
|
|
1187
785
|
return this._addCheck({
|
|
1188
786
|
kind: "datetime",
|
|
1189
|
-
precision: typeof
|
|
1190
|
-
offset:
|
|
1191
|
-
local:
|
|
1192
|
-
...errorUtil.errToObj(options
|
|
787
|
+
precision: typeof options?.precision === "undefined" ? null : options?.precision,
|
|
788
|
+
offset: options?.offset ?? false,
|
|
789
|
+
local: options?.local ?? false,
|
|
790
|
+
...errorUtil.errToObj(options?.message)
|
|
1193
791
|
});
|
|
1194
792
|
}
|
|
1195
793
|
date(message) {
|
|
@@ -1206,8 +804,8 @@ var ZodString = class ZodString extends ZodType {
|
|
|
1206
804
|
});
|
|
1207
805
|
return this._addCheck({
|
|
1208
806
|
kind: "time",
|
|
1209
|
-
precision: typeof
|
|
1210
|
-
...errorUtil.errToObj(options
|
|
807
|
+
precision: typeof options?.precision === "undefined" ? null : options?.precision,
|
|
808
|
+
...errorUtil.errToObj(options?.message)
|
|
1211
809
|
});
|
|
1212
810
|
}
|
|
1213
811
|
duration(message) {
|
|
@@ -1227,8 +825,8 @@ var ZodString = class ZodString extends ZodType {
|
|
|
1227
825
|
return this._addCheck({
|
|
1228
826
|
kind: "includes",
|
|
1229
827
|
value,
|
|
1230
|
-
position: options
|
|
1231
|
-
...errorUtil.errToObj(options
|
|
828
|
+
position: options?.position,
|
|
829
|
+
...errorUtil.errToObj(options?.message)
|
|
1232
830
|
});
|
|
1233
831
|
}
|
|
1234
832
|
startsWith(value, message) {
|
|
@@ -1354,11 +952,10 @@ var ZodString = class ZodString extends ZodType {
|
|
|
1354
952
|
}
|
|
1355
953
|
};
|
|
1356
954
|
ZodString.create = (params) => {
|
|
1357
|
-
var _a;
|
|
1358
955
|
return new ZodString({
|
|
1359
956
|
checks: [],
|
|
1360
957
|
typeName: ZodFirstPartyTypeKind.ZodString,
|
|
1361
|
-
coerce:
|
|
958
|
+
coerce: params?.coerce ?? false,
|
|
1362
959
|
...processCreateParams(params)
|
|
1363
960
|
});
|
|
1364
961
|
};
|
|
@@ -1366,7 +963,7 @@ function floatSafeRemainder(val, step) {
|
|
|
1366
963
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
1367
964
|
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
|
1368
965
|
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
1369
|
-
return parseInt(val.toFixed(decCount).replace(".", "")) % parseInt(step.toFixed(decCount).replace(".", "")) /
|
|
966
|
+
return Number.parseInt(val.toFixed(decCount).replace(".", "")) % Number.parseInt(step.toFixed(decCount).replace(".", "")) / 10 ** decCount;
|
|
1370
967
|
}
|
|
1371
968
|
var ZodNumber = class ZodNumber extends ZodType {
|
|
1372
969
|
constructor() {
|
|
@@ -1561,7 +1158,8 @@ var ZodNumber = class ZodNumber extends ZodType {
|
|
|
1561
1158
|
return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
|
|
1562
1159
|
}
|
|
1563
1160
|
get isFinite() {
|
|
1564
|
-
let max = null
|
|
1161
|
+
let max = null;
|
|
1162
|
+
let min = null;
|
|
1565
1163
|
for (const ch of this._def.checks) if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") return true;
|
|
1566
1164
|
else if (ch.kind === "min") {
|
|
1567
1165
|
if (min === null || ch.value > min) min = ch.value;
|
|
@@ -1575,7 +1173,7 @@ ZodNumber.create = (params) => {
|
|
|
1575
1173
|
return new ZodNumber({
|
|
1576
1174
|
checks: [],
|
|
1577
1175
|
typeName: ZodFirstPartyTypeKind.ZodNumber,
|
|
1578
|
-
coerce:
|
|
1176
|
+
coerce: params?.coerce || false,
|
|
1579
1177
|
...processCreateParams(params)
|
|
1580
1178
|
});
|
|
1581
1179
|
};
|
|
@@ -1588,7 +1186,7 @@ var ZodBigInt = class ZodBigInt extends ZodType {
|
|
|
1588
1186
|
_parse(input) {
|
|
1589
1187
|
if (this._def.coerce) try {
|
|
1590
1188
|
input.data = BigInt(input.data);
|
|
1591
|
-
} catch
|
|
1189
|
+
} catch {
|
|
1592
1190
|
return this._getInvalidInput(input);
|
|
1593
1191
|
}
|
|
1594
1192
|
if (this._getType(input) !== ZodParsedType.bigint) return this._getInvalidInput(input);
|
|
@@ -1727,11 +1325,10 @@ var ZodBigInt = class ZodBigInt extends ZodType {
|
|
|
1727
1325
|
}
|
|
1728
1326
|
};
|
|
1729
1327
|
ZodBigInt.create = (params) => {
|
|
1730
|
-
var _a;
|
|
1731
1328
|
return new ZodBigInt({
|
|
1732
1329
|
checks: [],
|
|
1733
1330
|
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
|
1734
|
-
coerce:
|
|
1331
|
+
coerce: params?.coerce ?? false,
|
|
1735
1332
|
...processCreateParams(params)
|
|
1736
1333
|
});
|
|
1737
1334
|
};
|
|
@@ -1753,7 +1350,7 @@ var ZodBoolean = class extends ZodType {
|
|
|
1753
1350
|
ZodBoolean.create = (params) => {
|
|
1754
1351
|
return new ZodBoolean({
|
|
1755
1352
|
typeName: ZodFirstPartyTypeKind.ZodBoolean,
|
|
1756
|
-
coerce:
|
|
1353
|
+
coerce: params?.coerce || false,
|
|
1757
1354
|
...processCreateParams(params)
|
|
1758
1355
|
});
|
|
1759
1356
|
};
|
|
@@ -1769,7 +1366,7 @@ var ZodDate = class ZodDate extends ZodType {
|
|
|
1769
1366
|
});
|
|
1770
1367
|
return INVALID;
|
|
1771
1368
|
}
|
|
1772
|
-
if (isNaN(input.data.getTime())) {
|
|
1369
|
+
if (Number.isNaN(input.data.getTime())) {
|
|
1773
1370
|
addIssueToContext(this._getOrReturnCtx(input), { code: ZodIssueCode.invalid_date });
|
|
1774
1371
|
return INVALID;
|
|
1775
1372
|
}
|
|
@@ -1845,7 +1442,7 @@ var ZodDate = class ZodDate extends ZodType {
|
|
|
1845
1442
|
ZodDate.create = (params) => {
|
|
1846
1443
|
return new ZodDate({
|
|
1847
1444
|
checks: [],
|
|
1848
|
-
coerce:
|
|
1445
|
+
coerce: params?.coerce || false,
|
|
1849
1446
|
typeName: ZodFirstPartyTypeKind.ZodDate,
|
|
1850
1447
|
...processCreateParams(params)
|
|
1851
1448
|
});
|
|
@@ -2122,10 +1719,12 @@ var ZodObject = class ZodObject extends ZodType {
|
|
|
2122
1719
|
_getCached() {
|
|
2123
1720
|
if (this._cached !== null) return this._cached;
|
|
2124
1721
|
const shape = this._def.shape();
|
|
2125
|
-
|
|
1722
|
+
const keys = util.objectKeys(shape);
|
|
1723
|
+
this._cached = {
|
|
2126
1724
|
shape,
|
|
2127
|
-
keys
|
|
1725
|
+
keys
|
|
2128
1726
|
};
|
|
1727
|
+
return this._cached;
|
|
2129
1728
|
}
|
|
2130
1729
|
_parse(input) {
|
|
2131
1730
|
if (this._getType(input) !== ZodParsedType.object) {
|
|
@@ -2176,8 +1775,7 @@ var ZodObject = class ZodObject extends ZodType {
|
|
|
2176
1775
|
});
|
|
2177
1776
|
status.dirty();
|
|
2178
1777
|
}
|
|
2179
|
-
} else if (unknownKeys === "strip");
|
|
2180
|
-
else throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
|
|
1778
|
+
} else if (unknownKeys === "strip") {} else throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
|
|
2181
1779
|
} else {
|
|
2182
1780
|
const catchall = this._def.catchall;
|
|
2183
1781
|
for (const key of extraKeys) {
|
|
@@ -2218,9 +1816,8 @@ var ZodObject = class ZodObject extends ZodType {
|
|
|
2218
1816
|
...this._def,
|
|
2219
1817
|
unknownKeys: "strict",
|
|
2220
1818
|
...message !== void 0 ? { errorMap: (issue, ctx) => {
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
if (issue.code === "unrecognized_keys") return { message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError };
|
|
1819
|
+
const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
|
|
1820
|
+
if (issue.code === "unrecognized_keys") return { message: errorUtil.errToObj(message).message ?? defaultError };
|
|
2224
1821
|
return { message: defaultError };
|
|
2225
1822
|
} } : {}
|
|
2226
1823
|
});
|
|
@@ -2273,9 +1870,7 @@ var ZodObject = class ZodObject extends ZodType {
|
|
|
2273
1870
|
}
|
|
2274
1871
|
pick(mask) {
|
|
2275
1872
|
const shape = {};
|
|
2276
|
-
util.objectKeys(mask)
|
|
2277
|
-
if (mask[key] && this.shape[key]) shape[key] = this.shape[key];
|
|
2278
|
-
});
|
|
1873
|
+
for (const key of util.objectKeys(mask)) if (mask[key] && this.shape[key]) shape[key] = this.shape[key];
|
|
2279
1874
|
return new ZodObject({
|
|
2280
1875
|
...this._def,
|
|
2281
1876
|
shape: () => shape
|
|
@@ -2283,9 +1878,7 @@ var ZodObject = class ZodObject extends ZodType {
|
|
|
2283
1878
|
}
|
|
2284
1879
|
omit(mask) {
|
|
2285
1880
|
const shape = {};
|
|
2286
|
-
util.objectKeys(this.shape)
|
|
2287
|
-
if (!mask[key]) shape[key] = this.shape[key];
|
|
2288
|
-
});
|
|
1881
|
+
for (const key of util.objectKeys(this.shape)) if (!mask[key]) shape[key] = this.shape[key];
|
|
2289
1882
|
return new ZodObject({
|
|
2290
1883
|
...this._def,
|
|
2291
1884
|
shape: () => shape
|
|
@@ -2299,11 +1892,11 @@ var ZodObject = class ZodObject extends ZodType {
|
|
|
2299
1892
|
}
|
|
2300
1893
|
partial(mask) {
|
|
2301
1894
|
const newShape = {};
|
|
2302
|
-
util.objectKeys(this.shape)
|
|
1895
|
+
for (const key of util.objectKeys(this.shape)) {
|
|
2303
1896
|
const fieldSchema = this.shape[key];
|
|
2304
1897
|
if (mask && !mask[key]) newShape[key] = fieldSchema;
|
|
2305
1898
|
else newShape[key] = fieldSchema.optional();
|
|
2306
|
-
}
|
|
1899
|
+
}
|
|
2307
1900
|
return new ZodObject({
|
|
2308
1901
|
...this._def,
|
|
2309
1902
|
shape: () => newShape
|
|
@@ -2311,14 +1904,12 @@ var ZodObject = class ZodObject extends ZodType {
|
|
|
2311
1904
|
}
|
|
2312
1905
|
required(mask) {
|
|
2313
1906
|
const newShape = {};
|
|
2314
|
-
util.objectKeys(this.shape)
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
}
|
|
2321
|
-
});
|
|
1907
|
+
for (const key of util.objectKeys(this.shape)) if (mask && !mask[key]) newShape[key] = this.shape[key];
|
|
1908
|
+
else {
|
|
1909
|
+
let newField = this.shape[key];
|
|
1910
|
+
while (newField instanceof ZodOptional) newField = newField._def.innerType;
|
|
1911
|
+
newShape[key] = newField;
|
|
1912
|
+
}
|
|
2322
1913
|
return new ZodObject({
|
|
2323
1914
|
...this._def,
|
|
2324
1915
|
shape: () => newShape
|
|
@@ -3031,10 +2622,6 @@ function createZodEnum(values, params) {
|
|
|
3031
2622
|
});
|
|
3032
2623
|
}
|
|
3033
2624
|
var ZodEnum = class ZodEnum extends ZodType {
|
|
3034
|
-
constructor() {
|
|
3035
|
-
super(...arguments);
|
|
3036
|
-
_ZodEnum_cache.set(this, void 0);
|
|
3037
|
-
}
|
|
3038
2625
|
_parse(input) {
|
|
3039
2626
|
if (typeof input.data !== "string") {
|
|
3040
2627
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3046,8 +2633,8 @@ var ZodEnum = class ZodEnum extends ZodType {
|
|
|
3046
2633
|
});
|
|
3047
2634
|
return INVALID;
|
|
3048
2635
|
}
|
|
3049
|
-
if (!
|
|
3050
|
-
if (!
|
|
2636
|
+
if (!this._cache) this._cache = new Set(this._def.values);
|
|
2637
|
+
if (!this._cache.has(input.data)) {
|
|
3051
2638
|
const ctx = this._getOrReturnCtx(input);
|
|
3052
2639
|
const expectedValues = this._def.values;
|
|
3053
2640
|
addIssueToContext(ctx, {
|
|
@@ -3090,13 +2677,8 @@ var ZodEnum = class ZodEnum extends ZodType {
|
|
|
3090
2677
|
});
|
|
3091
2678
|
}
|
|
3092
2679
|
};
|
|
3093
|
-
_ZodEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
3094
2680
|
ZodEnum.create = createZodEnum;
|
|
3095
2681
|
var ZodNativeEnum = class extends ZodType {
|
|
3096
|
-
constructor() {
|
|
3097
|
-
super(...arguments);
|
|
3098
|
-
_ZodNativeEnum_cache.set(this, void 0);
|
|
3099
|
-
}
|
|
3100
2682
|
_parse(input) {
|
|
3101
2683
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
3102
2684
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3109,8 +2691,8 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3109
2691
|
});
|
|
3110
2692
|
return INVALID;
|
|
3111
2693
|
}
|
|
3112
|
-
if (!
|
|
3113
|
-
if (!
|
|
2694
|
+
if (!this._cache) this._cache = new Set(util.getValidEnumValues(this._def.values));
|
|
2695
|
+
if (!this._cache.has(input.data)) {
|
|
3114
2696
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
3115
2697
|
addIssueToContext(ctx, {
|
|
3116
2698
|
received: ctx.data,
|
|
@@ -3125,7 +2707,6 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3125
2707
|
return this._def.values;
|
|
3126
2708
|
}
|
|
3127
2709
|
};
|
|
3128
|
-
_ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
3129
2710
|
ZodNativeEnum.create = (values, params) => {
|
|
3130
2711
|
return new ZodNativeEnum({
|
|
3131
2712
|
values,
|
|
@@ -3251,7 +2832,7 @@ var ZodEffects = class extends ZodType {
|
|
|
3251
2832
|
path: ctx.path,
|
|
3252
2833
|
parent: ctx
|
|
3253
2834
|
});
|
|
3254
|
-
if (!isValid(base)) return
|
|
2835
|
+
if (!isValid(base)) return INVALID;
|
|
3255
2836
|
const result = effect.transform(base.value, checkCtx);
|
|
3256
2837
|
if (result instanceof Promise) throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
|
|
3257
2838
|
return {
|
|
@@ -3263,7 +2844,7 @@ var ZodEffects = class extends ZodType {
|
|
|
3263
2844
|
path: ctx.path,
|
|
3264
2845
|
parent: ctx
|
|
3265
2846
|
}).then((base) => {
|
|
3266
|
-
if (!isValid(base)) return
|
|
2847
|
+
if (!isValid(base)) return INVALID;
|
|
3267
2848
|
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
|
3268
2849
|
status: status.value,
|
|
3269
2850
|
value: result
|
|
@@ -3507,13 +3088,11 @@ function cleanParams(params, data) {
|
|
|
3507
3088
|
}
|
|
3508
3089
|
function custom(check, _params = {}, fatal) {
|
|
3509
3090
|
if (check) return ZodAny.create().superRefine((data, ctx) => {
|
|
3510
|
-
var _a, _b;
|
|
3511
3091
|
const r = check(data);
|
|
3512
3092
|
if (r instanceof Promise) return r.then((r) => {
|
|
3513
|
-
var _a, _b;
|
|
3514
3093
|
if (!r) {
|
|
3515
3094
|
const params = cleanParams(_params, data);
|
|
3516
|
-
const _fatal =
|
|
3095
|
+
const _fatal = params.fatal ?? fatal ?? true;
|
|
3517
3096
|
ctx.addIssue({
|
|
3518
3097
|
code: "custom",
|
|
3519
3098
|
...params,
|
|
@@ -3523,7 +3102,7 @@ function custom(check, _params = {}, fatal) {
|
|
|
3523
3102
|
});
|
|
3524
3103
|
if (!r) {
|
|
3525
3104
|
const params = cleanParams(_params, data);
|
|
3526
|
-
const _fatal =
|
|
3105
|
+
const _fatal = params.fatal ?? fatal ?? true;
|
|
3527
3106
|
ctx.addIssue({
|
|
3528
3107
|
code: "custom",
|
|
3529
3108
|
...params,
|
|
@@ -3634,123 +3213,7 @@ var coerce = {
|
|
|
3634
3213
|
}))
|
|
3635
3214
|
};
|
|
3636
3215
|
var NEVER = INVALID;
|
|
3637
|
-
var z = /* @__PURE__ */ Object.freeze({
|
|
3638
|
-
__proto__: null,
|
|
3639
|
-
defaultErrorMap: errorMap,
|
|
3640
|
-
setErrorMap,
|
|
3641
|
-
getErrorMap,
|
|
3642
|
-
makeIssue,
|
|
3643
|
-
EMPTY_PATH,
|
|
3644
|
-
addIssueToContext,
|
|
3645
|
-
ParseStatus,
|
|
3646
|
-
INVALID,
|
|
3647
|
-
DIRTY,
|
|
3648
|
-
OK,
|
|
3649
|
-
isAborted,
|
|
3650
|
-
isDirty,
|
|
3651
|
-
isValid,
|
|
3652
|
-
isAsync,
|
|
3653
|
-
get util() {
|
|
3654
|
-
return util;
|
|
3655
|
-
},
|
|
3656
|
-
get objectUtil() {
|
|
3657
|
-
return objectUtil;
|
|
3658
|
-
},
|
|
3659
|
-
ZodParsedType,
|
|
3660
|
-
getParsedType,
|
|
3661
|
-
ZodType,
|
|
3662
|
-
datetimeRegex,
|
|
3663
|
-
ZodString,
|
|
3664
|
-
ZodNumber,
|
|
3665
|
-
ZodBigInt,
|
|
3666
|
-
ZodBoolean,
|
|
3667
|
-
ZodDate,
|
|
3668
|
-
ZodSymbol,
|
|
3669
|
-
ZodUndefined,
|
|
3670
|
-
ZodNull,
|
|
3671
|
-
ZodAny,
|
|
3672
|
-
ZodUnknown,
|
|
3673
|
-
ZodNever,
|
|
3674
|
-
ZodVoid,
|
|
3675
|
-
ZodArray,
|
|
3676
|
-
ZodObject,
|
|
3677
|
-
ZodUnion,
|
|
3678
|
-
ZodDiscriminatedUnion,
|
|
3679
|
-
ZodIntersection,
|
|
3680
|
-
ZodTuple,
|
|
3681
|
-
ZodRecord,
|
|
3682
|
-
ZodMap,
|
|
3683
|
-
ZodSet,
|
|
3684
|
-
ZodFunction,
|
|
3685
|
-
ZodLazy,
|
|
3686
|
-
ZodLiteral,
|
|
3687
|
-
ZodEnum,
|
|
3688
|
-
ZodNativeEnum,
|
|
3689
|
-
ZodPromise,
|
|
3690
|
-
ZodEffects,
|
|
3691
|
-
ZodTransformer: ZodEffects,
|
|
3692
|
-
ZodOptional,
|
|
3693
|
-
ZodNullable,
|
|
3694
|
-
ZodDefault,
|
|
3695
|
-
ZodCatch,
|
|
3696
|
-
ZodNaN,
|
|
3697
|
-
BRAND,
|
|
3698
|
-
ZodBranded,
|
|
3699
|
-
ZodPipeline,
|
|
3700
|
-
ZodReadonly,
|
|
3701
|
-
custom,
|
|
3702
|
-
Schema: ZodType,
|
|
3703
|
-
ZodSchema: ZodType,
|
|
3704
|
-
late,
|
|
3705
|
-
get ZodFirstPartyTypeKind() {
|
|
3706
|
-
return ZodFirstPartyTypeKind;
|
|
3707
|
-
},
|
|
3708
|
-
coerce,
|
|
3709
|
-
any: anyType,
|
|
3710
|
-
array: arrayType,
|
|
3711
|
-
bigint: bigIntType,
|
|
3712
|
-
boolean: booleanType,
|
|
3713
|
-
date: dateType,
|
|
3714
|
-
discriminatedUnion: discriminatedUnionType,
|
|
3715
|
-
effect: effectsType,
|
|
3716
|
-
"enum": enumType,
|
|
3717
|
-
"function": functionType,
|
|
3718
|
-
"instanceof": instanceOfType,
|
|
3719
|
-
intersection: intersectionType,
|
|
3720
|
-
lazy: lazyType,
|
|
3721
|
-
literal: literalType,
|
|
3722
|
-
map: mapType,
|
|
3723
|
-
nan: nanType,
|
|
3724
|
-
nativeEnum: nativeEnumType,
|
|
3725
|
-
never: neverType,
|
|
3726
|
-
"null": nullType,
|
|
3727
|
-
nullable: nullableType,
|
|
3728
|
-
number: numberType,
|
|
3729
|
-
object: objectType,
|
|
3730
|
-
oboolean,
|
|
3731
|
-
onumber,
|
|
3732
|
-
optional: optionalType,
|
|
3733
|
-
ostring,
|
|
3734
|
-
pipeline: pipelineType,
|
|
3735
|
-
preprocess: preprocessType,
|
|
3736
|
-
promise: promiseType,
|
|
3737
|
-
record: recordType,
|
|
3738
|
-
set: setType,
|
|
3739
|
-
strictObject: strictObjectType,
|
|
3740
|
-
string: stringType,
|
|
3741
|
-
symbol: symbolType,
|
|
3742
|
-
transformer: effectsType,
|
|
3743
|
-
tuple: tupleType,
|
|
3744
|
-
"undefined": undefinedType,
|
|
3745
|
-
union: unionType,
|
|
3746
|
-
unknown: unknownType,
|
|
3747
|
-
"void": voidType,
|
|
3748
|
-
NEVER,
|
|
3749
|
-
ZodIssueCode,
|
|
3750
|
-
quotelessJson,
|
|
3751
|
-
ZodError
|
|
3752
|
-
});
|
|
3753
3216
|
//#endregion
|
|
3754
|
-
export {
|
|
3217
|
+
export { BRAND, NEVER, ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodBranded, ZodCatch, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodEffects, ZodEnum, ZodFirstPartyTypeKind, ZodFunction, ZodIntersection, ZodLazy, ZodLiteral, ZodMap, ZodNaN, ZodNativeEnum, ZodNever, ZodNull, ZodNullable, ZodNumber, ZodObject, ZodOptional, ZodPipeline, ZodPromise, ZodReadonly, ZodRecord, ZodSet, ZodString, ZodSymbol, ZodTuple, ZodType, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid, anyType, arrayType, bigIntType, booleanType, coerce, custom, dateType, datetimeRegex, discriminatedUnionType, effectsType, enumType, functionType, instanceOfType, intersectionType, late, lazyType, literalType, mapType, nanType, nativeEnumType, neverType, nullType, nullableType, numberType, objectType, oboolean, onumber, optionalType, ostring, pipelineType, preprocessType, promiseType, recordType, setType, strictObjectType, stringType, symbolType, tupleType, undefinedType, unionType, unknownType, voidType };
|
|
3755
3218
|
|
|
3756
|
-
//# sourceMappingURL=
|
|
3219
|
+
//# sourceMappingURL=types.js.map
|