@orpc/zod 0.0.0-next.7b09958 → 0.0.0-next.7d3bd71

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/index.js CHANGED
@@ -1,18 +1,57 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ // ../../node_modules/.pnpm/escape-string-regexp@4.0.0/node_modules/escape-string-regexp/index.js
28
+ var require_escape_string_regexp = __commonJS({
29
+ "../../node_modules/.pnpm/escape-string-regexp@4.0.0/node_modules/escape-string-regexp/index.js"(exports, module) {
30
+ "use strict";
31
+ module.exports = (string) => {
32
+ if (typeof string !== "string") {
33
+ throw new TypeError("Expected a string");
34
+ }
35
+ return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
36
+ };
37
+ }
38
+ });
39
+
1
40
  // src/coercer.ts
2
41
  import { guard, isObject } from "@orpc/shared";
3
42
  import {
4
43
  ZodFirstPartyTypeKind
5
44
  } from "zod";
6
- var ZodAutoCoercePlugin = class {
7
- beforeCreateProcedureClient(clientOptions) {
8
- clientOptions.interceptors ??= [];
9
- clientOptions.interceptors.unshift((options) => {
10
- const inputSchema = options.procedure["~orpc"].inputSchema;
45
+ var ZodSmartCoercionPlugin = class {
46
+ init(options) {
47
+ options.clientInterceptors ??= [];
48
+ options.clientInterceptors.unshift((options2) => {
49
+ const inputSchema = options2.procedure["~orpc"].inputSchema;
11
50
  if (!inputSchema || inputSchema["~standard"].vendor !== "zod") {
12
- return options.next();
51
+ return options2.next();
13
52
  }
14
- const coercedInput = zodCoerceInternal(inputSchema, options.input, { bracketNotation: true });
15
- return options.next({ ...options, input: coercedInput });
53
+ const coercedInput = zodCoerceInternal(inputSchema, options2.input, { bracketNotation: true });
54
+ return options2.next({ ...options2, input: coercedInput });
16
55
  });
17
56
  }
18
57
  };
@@ -316,17 +355,8 @@ function zodCoerceInternal(schema, value, options) {
316
355
  }
317
356
 
318
357
  // src/converter.ts
358
+ var import_escape_string_regexp = __toESM(require_escape_string_regexp(), 1);
319
359
  import { JSONSchemaFormat } from "@orpc/openapi";
320
-
321
- // ../../node_modules/.pnpm/escape-string-regexp@5.0.0/node_modules/escape-string-regexp/index.js
322
- function escapeStringRegexp(string) {
323
- if (typeof string !== "string") {
324
- throw new TypeError("Expected a string");
325
- }
326
- return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
327
- }
328
-
329
- // src/converter.ts
330
360
  import {
331
361
  ZodFirstPartyTypeKind as ZodFirstPartyTypeKind2
332
362
  } from "zod";
@@ -586,13 +616,13 @@ function zodToJsonSchema(schema, options) {
586
616
  json.maxLength = check.value;
587
617
  break;
588
618
  case "includes":
589
- json.pattern = escapeStringRegexp(check.value);
619
+ json.pattern = (0, import_escape_string_regexp.default)(check.value);
590
620
  break;
591
621
  case "startsWith":
592
- json.pattern = `^${escapeStringRegexp(check.value)}`;
622
+ json.pattern = `^${(0, import_escape_string_regexp.default)(check.value)}`;
593
623
  break;
594
624
  case "endsWith":
595
- json.pattern = `${escapeStringRegexp(check.value)}$`;
625
+ json.pattern = `${(0, import_escape_string_regexp.default)(check.value)}$`;
596
626
  break;
597
627
  case "emoji":
598
628
  json.pattern = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
@@ -932,7 +962,8 @@ export {
932
962
  NON_LOGIC_KEYWORDS,
933
963
  UNDEFINED_JSON_SCHEMA,
934
964
  UNSUPPORTED_JSON_SCHEMA,
935
- ZodAutoCoercePlugin,
965
+ ZodSmartCoercionPlugin as ZodAutoCoercePlugin,
966
+ ZodSmartCoercionPlugin,
936
967
  ZodToJsonSchemaConverter,
937
968
  blob,
938
969
  file,
@@ -1,7 +1,12 @@
1
1
  import type { Context } from '@orpc/server';
2
2
  import type { Plugin } from '@orpc/server/plugins';
3
- import type { WellCreateProcedureClientOptions } from '@orpc/server/standard';
4
- export declare class ZodAutoCoercePlugin<TContext extends Context> implements Plugin<TContext> {
5
- beforeCreateProcedureClient(clientOptions: WellCreateProcedureClientOptions<TContext>): void;
3
+ import type { StandardHandlerOptions } from '@orpc/server/standard';
4
+ export declare class ZodSmartCoercionPlugin<TContext extends Context> implements Plugin<TContext> {
5
+ init(options: StandardHandlerOptions<TContext>): void;
6
6
  }
7
+ export {
8
+ /**
9
+ * @deprecated ZodAutoCoercePlugin has renamed to ZodSmartCoercionPlugin
10
+ */
11
+ ZodSmartCoercionPlugin as ZodAutoCoercePlugin, };
7
12
  //# sourceMappingURL=coercer.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/zod",
3
3
  "type": "module",
4
- "version": "0.0.0-next.7b09958",
4
+ "version": "0.0.0-next.7d3bd71",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -29,15 +29,16 @@
29
29
  "dist"
30
30
  ],
31
31
  "peerDependencies": {
32
- "@orpc/openapi": "0.0.0-next.7b09958",
33
- "@orpc/server": "0.0.0-next.7b09958"
32
+ "@orpc/contract": "0.0.0-next.7d3bd71",
33
+ "@orpc/openapi": "0.0.0-next.7d3bd71",
34
+ "@orpc/server": "0.0.0-next.7d3bd71"
34
35
  },
35
36
  "dependencies": {
36
37
  "@standard-schema/spec": "^1.0.0",
37
38
  "json-schema-typed": "^8.0.1",
38
39
  "wildcard-match": "^5.1.3",
39
40
  "zod": "^3.24.1",
40
- "@orpc/shared": "0.0.0-next.7b09958"
41
+ "@orpc/shared": "0.0.0-next.7d3bd71"
41
42
  },
42
43
  "scripts": {
43
44
  "build": "tsup --clean --sourcemap --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",