@temporary-name/server 1.9.3-alpha.9f176ca3f9388d51e8dffa98a15fcf9f14f6a75e → 1.9.3-alpha.afd18ec2afa743b08cf1b5c2eb6252ded18a1f43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/adapters/aws-lambda/index.d.mts +12 -6
  2. package/dist/adapters/aws-lambda/index.d.ts +12 -6
  3. package/dist/adapters/aws-lambda/index.mjs +14 -4
  4. package/dist/adapters/fetch/index.d.mts +12 -6
  5. package/dist/adapters/fetch/index.d.ts +12 -6
  6. package/dist/adapters/fetch/index.mjs +11 -8
  7. package/dist/adapters/node/index.d.mts +12 -6
  8. package/dist/adapters/node/index.d.ts +12 -6
  9. package/dist/adapters/node/index.mjs +11 -8
  10. package/dist/adapters/standard/index.d.mts +85 -13
  11. package/dist/adapters/standard/index.d.ts +85 -13
  12. package/dist/adapters/standard/index.mjs +7 -97
  13. package/dist/index.d.mts +6 -108
  14. package/dist/index.d.ts +6 -108
  15. package/dist/index.mjs +2 -3
  16. package/dist/openapi/index.d.mts +221 -0
  17. package/dist/openapi/index.d.ts +221 -0
  18. package/dist/openapi/index.mjs +784 -0
  19. package/dist/plugins/index.d.mts +2 -2
  20. package/dist/plugins/index.d.ts +2 -2
  21. package/dist/shared/{server.C1YnHvvf.d.ts → server.BKSOrA6h.d.mts} +2 -2
  22. package/dist/shared/{server.C1YnHvvf.d.mts → server.BKSOrA6h.d.ts} +2 -2
  23. package/dist/shared/{server.BEQrAa3A.mjs → server.BKh8I1Ny.mjs} +34 -2
  24. package/dist/shared/server.BeuTpcmO.d.mts +23 -0
  25. package/dist/shared/{server.Btxrgkj5.d.ts → server.C1fnTLq0.d.mts} +8 -24
  26. package/dist/shared/{server.Bo94xDTv.d.mts → server.CQyYNJ1H.d.ts} +8 -24
  27. package/dist/shared/server.DhdDYN-Z.mjs +261 -0
  28. package/dist/shared/server.SLLuK6_v.d.ts +23 -0
  29. package/dist/shared/server._YqJjI50.mjs +297 -0
  30. package/package.json +15 -9
  31. package/dist/shared/server.D6K9uoPI.mjs +0 -35
  32. package/dist/shared/server.DZ5BIITo.mjs +0 -9
  33. package/dist/shared/server.X0YaZxSJ.mjs +0 -13
@@ -1,8 +1,8 @@
1
1
  import { Value, Promisable, ORPCError } from '@temporary-name/shared';
2
2
  import { StandardRequest, StandardHeaders } from '@temporary-name/standard-server';
3
3
  import { BatchResponseBodyItem } from '@temporary-name/standard-server/batch';
4
- import { c as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, d as StandardHandlerOptions } from '../shared/server.Bo94xDTv.mjs';
5
- import { C as Context, P as ProcedureClientInterceptorOptions } from '../shared/server.C1YnHvvf.mjs';
4
+ import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.C1fnTLq0.mjs';
5
+ import { C as Context, E as ProcedureClientInterceptorOptions } from '../shared/server.BKSOrA6h.mjs';
6
6
  import { Meta } from '@temporary-name/contract';
7
7
 
8
8
  interface BatchHandlerOptions<T extends Context> {
@@ -1,8 +1,8 @@
1
1
  import { Value, Promisable, ORPCError } from '@temporary-name/shared';
2
2
  import { StandardRequest, StandardHeaders } from '@temporary-name/standard-server';
3
3
  import { BatchResponseBodyItem } from '@temporary-name/standard-server/batch';
4
- import { c as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, d as StandardHandlerOptions } from '../shared/server.Btxrgkj5.js';
5
- import { C as Context, P as ProcedureClientInterceptorOptions } from '../shared/server.C1YnHvvf.js';
4
+ import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.CQyYNJ1H.js';
5
+ import { C as Context, E as ProcedureClientInterceptorOptions } from '../shared/server.BKSOrA6h.js';
6
6
  import { Meta } from '@temporary-name/contract';
7
7
 
8
8
  interface BatchHandlerOptions<T extends Context> {
@@ -188,5 +188,5 @@ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any
188
188
  [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
189
189
  };
190
190
 
191
- export { isProcedure as E, createProcedureClient as F, Procedure as b, mergeCurrentContext as m, createORPCErrorConstructorMap as n, LAZY_SYMBOL as o, lazy as q, isLazy as r, getLazyMeta as s, unlazy as u, middlewareOutputFn as z };
192
- export type { AnyRouter as A, ProcedureHandlerOptions as B, Context as C, ProcedureDef as D, InferRouterInitialContexts as G, InferRouterCurrentContexts as H, InferRouterInitialContext as I, InferRouterInputs as J, InferRouterOutputs as K, Lazyable as L, Middleware as M, ORPCErrorConstructorMap as O, ProcedureClientInterceptorOptions as P, Router as R, AnyProcedure as a, MergedInitialContext as c, MergedCurrentContext as d, MapInputMiddleware as e, CreateProcedureClientOptions as f, ProcedureClient as g, AnyMiddleware as h, Lazy as i, ProcedureHandler as j, ORPCErrorConstructorMapItemOptions as k, ORPCErrorConstructorMapItem as l, LazyMeta as p, MiddlewareResult as t, MiddlewareNextFnOptions as v, MiddlewareNextFn as w, MiddlewareOutputFn as x, MiddlewareOptions as y };
191
+ export { isProcedure as D, createProcedureClient as F, Procedure as P, createORPCErrorConstructorMap as l, mergeCurrentContext as m, LAZY_SYMBOL as n, lazy as p, isLazy as q, getLazyMeta as r, unlazy as u, middlewareOutputFn as y };
192
+ export type { AnyMiddleware as A, ProcedureDef as B, Context as C, ProcedureClientInterceptorOptions as E, InferRouterInitialContexts as G, InferRouterCurrentContexts as H, InferRouterInitialContext as I, InferRouterInputs as J, InferRouterOutputs as K, Lazyable as L, Middleware as M, ORPCErrorConstructorMap as O, Router as R, MergedInitialContext as a, MergedCurrentContext as b, MapInputMiddleware as c, CreateProcedureClientOptions as d, ProcedureClient as e, AnyRouter as f, Lazy as g, AnyProcedure as h, ProcedureHandler as i, ORPCErrorConstructorMapItemOptions as j, ORPCErrorConstructorMapItem as k, LazyMeta as o, MiddlewareResult as s, MiddlewareNextFnOptions as t, MiddlewareNextFn as v, MiddlewareOutputFn as w, MiddlewareOptions as x, ProcedureHandlerOptions as z };
@@ -188,5 +188,5 @@ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any
188
188
  [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
189
189
  };
190
190
 
191
- export { isProcedure as E, createProcedureClient as F, Procedure as b, mergeCurrentContext as m, createORPCErrorConstructorMap as n, LAZY_SYMBOL as o, lazy as q, isLazy as r, getLazyMeta as s, unlazy as u, middlewareOutputFn as z };
192
- export type { AnyRouter as A, ProcedureHandlerOptions as B, Context as C, ProcedureDef as D, InferRouterInitialContexts as G, InferRouterCurrentContexts as H, InferRouterInitialContext as I, InferRouterInputs as J, InferRouterOutputs as K, Lazyable as L, Middleware as M, ORPCErrorConstructorMap as O, ProcedureClientInterceptorOptions as P, Router as R, AnyProcedure as a, MergedInitialContext as c, MergedCurrentContext as d, MapInputMiddleware as e, CreateProcedureClientOptions as f, ProcedureClient as g, AnyMiddleware as h, Lazy as i, ProcedureHandler as j, ORPCErrorConstructorMapItemOptions as k, ORPCErrorConstructorMapItem as l, LazyMeta as p, MiddlewareResult as t, MiddlewareNextFnOptions as v, MiddlewareNextFn as w, MiddlewareOutputFn as x, MiddlewareOptions as y };
191
+ export { isProcedure as D, createProcedureClient as F, Procedure as P, createORPCErrorConstructorMap as l, mergeCurrentContext as m, LAZY_SYMBOL as n, lazy as p, isLazy as q, getLazyMeta as r, unlazy as u, middlewareOutputFn as y };
192
+ export type { AnyMiddleware as A, ProcedureDef as B, Context as C, ProcedureClientInterceptorOptions as E, InferRouterInitialContexts as G, InferRouterCurrentContexts as H, InferRouterInitialContext as I, InferRouterInputs as J, InferRouterOutputs as K, Lazyable as L, Middleware as M, ORPCErrorConstructorMap as O, Router as R, MergedInitialContext as a, MergedCurrentContext as b, MapInputMiddleware as c, CreateProcedureClientOptions as d, ProcedureClient as e, AnyRouter as f, Lazy as g, AnyProcedure as h, ProcedureHandler as i, ORPCErrorConstructorMapItemOptions as j, ORPCErrorConstructorMapItem as k, LazyMeta as o, MiddlewareResult as s, MiddlewareNextFnOptions as t, MiddlewareNextFn as v, MiddlewareOutputFn as w, MiddlewareOptions as x, ProcedureHandlerOptions as z };
@@ -1,7 +1,39 @@
1
1
  import { validateORPCError, ValidationError } from '@temporary-name/contract';
2
2
  import { resolveMaybeOptionalOptions, ORPCError, toArray, value, runWithSpan, intercept, isAsyncIteratorObject, overlayProxy, asyncIteratorWithSpan } from '@temporary-name/shared';
3
3
  import { HibernationEventIterator, mapEventIterator } from '@temporary-name/standard-server';
4
- import { g as gatingContext, w as withoutGatedFields } from './server.D6K9uoPI.mjs';
4
+ import { AsyncLocalStorage } from 'node:async_hooks';
5
+ import 'zod';
6
+ import * as z4 from 'zod/v4/core';
7
+
8
+ const gatingContext = new AsyncLocalStorage();
9
+ function withoutGatedFields(data, schema, isGateEnabled) {
10
+ const filtered = { ...data };
11
+ const gatedFields = getGatedFields(schema);
12
+ for (const [fieldName, gate] of gatedFields) {
13
+ if (!isGateEnabled(gate)) {
14
+ delete filtered[fieldName];
15
+ }
16
+ }
17
+ return filtered;
18
+ }
19
+ function getGatedFields(schema) {
20
+ if (!schema || schema["~standard"].vendor !== "zod") {
21
+ return [];
22
+ }
23
+ const gatedFields = [];
24
+ const zodDef = schema._zod.def;
25
+ if (zodDef.type === "object") {
26
+ const shape = zodDef.shape;
27
+ for (const fieldName in shape) {
28
+ const fieldSchema = shape[fieldName];
29
+ const gate = z4.globalRegistry.get(fieldSchema)?.gate;
30
+ if (gate) {
31
+ gatedFields.push([fieldName, gate]);
32
+ }
33
+ }
34
+ }
35
+ return gatedFields;
36
+ }
5
37
 
6
38
  const LAZY_SYMBOL = Symbol("ORPC_LAZY_SYMBOL");
7
39
  function lazy(loader, meta = {}) {
@@ -204,4 +236,4 @@ async function executeProcedureInternal(procedure, options) {
204
236
  return next(0, options.context, options.input);
205
237
  }
206
238
 
207
- export { LAZY_SYMBOL as L, createORPCErrorConstructorMap as a, middlewareOutputFn as b, createProcedureClient as c, getLazyMeta as g, isLazy as i, lazy as l, mergeCurrentContext as m, unlazy as u };
239
+ export { LAZY_SYMBOL as L, gatingContext as a, createORPCErrorConstructorMap as b, createProcedureClient as c, middlewareOutputFn as d, getLazyMeta as g, isLazy as i, lazy as l, mergeCurrentContext as m, unlazy as u };
@@ -0,0 +1,23 @@
1
+ import { HTTPPath } from '@temporary-name/shared';
2
+ import { C as Context } from './server.BKSOrA6h.mjs';
3
+ import { c as StandardHandleOptions } from './server.C1fnTLq0.mjs';
4
+
5
+ type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
6
+ context?: T;
7
+ } : {
8
+ context: T;
9
+ });
10
+ declare function resolveFriendlyStandardHandleOptions<T extends Context>(options: FriendlyStandardHandleOptions<T>): StandardHandleOptions<T>;
11
+ /**
12
+ * {@link https://github.com/unjs/rou3}
13
+ *
14
+ * @internal
15
+ */
16
+ declare function toRou3Pattern(path: HTTPPath): string;
17
+ /**
18
+ * @internal
19
+ */
20
+ declare function decodeParams(params: Record<string, string>): Record<string, string>;
21
+
22
+ export { decodeParams as d, resolveFriendlyStandardHandleOptions as r, toRou3Pattern as t };
23
+ export type { FriendlyStandardHandleOptions as F };
@@ -1,7 +1,7 @@
1
1
  import { Meta } from '@temporary-name/contract';
2
- import { HTTPPath, ORPCError, Interceptor } from '@temporary-name/shared';
3
- import { StandardResponse, StandardLazyRequest } from '@temporary-name/standard-server';
4
- import { C as Context, R as Router, A as AnyRouter, a as AnyProcedure, P as ProcedureClientInterceptorOptions } from './server.C1YnHvvf.js';
2
+ import { HTTPPath, Interceptor } from '@temporary-name/shared';
3
+ import { StandardLazyRequest, StandardResponse } from '@temporary-name/standard-server';
4
+ import { C as Context, R as Router, E as ProcedureClientInterceptorOptions } from './server.BKSOrA6h.mjs';
5
5
 
6
6
  interface StandardHandlerPlugin<T extends Context> {
7
7
  order?: number;
@@ -13,22 +13,6 @@ declare class CompositeStandardHandlerPlugin<T extends Context, TPlugin extends
13
13
  init(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
14
14
  }
15
15
 
16
- type StandardParams = Record<string, string>;
17
- type StandardMatchResult = {
18
- path: readonly string[];
19
- procedure: AnyProcedure;
20
- params?: StandardParams;
21
- } | undefined;
22
- interface StandardMatcher {
23
- init(router: AnyRouter): void;
24
- match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
25
- }
26
- interface StandardCodec {
27
- encode(output: unknown, procedure: AnyProcedure): StandardResponse;
28
- encodeError(error: ORPCError<any, any>): StandardResponse;
29
- decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
30
- }
31
-
32
16
  interface StandardHandleOptions<T extends Context> {
33
17
  prefix?: HTTPPath;
34
18
  context: T;
@@ -60,14 +44,14 @@ interface StandardHandlerOptions<TContext extends Context> {
60
44
  clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, Promise<unknown>>[];
61
45
  }
62
46
  declare class StandardHandler<T extends Context> {
63
- private readonly matcher;
64
- private readonly codec;
65
47
  private readonly interceptors;
66
48
  private readonly clientInterceptors;
67
49
  private readonly rootInterceptors;
68
- constructor(router: Router<any, T>, matcher: StandardMatcher, codec: StandardCodec, options: NoInfer<StandardHandlerOptions<T>>);
50
+ private readonly matcher;
51
+ private readonly codec;
52
+ constructor(router: Router<any, T>, options: NoInfer<StandardHandlerOptions<T>>);
69
53
  handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
70
54
  }
71
55
 
72
- export { CompositeStandardHandlerPlugin as C, StandardHandler as S };
73
- export type { StandardHandlerPlugin as a, StandardHandleOptions as b, StandardHandlerInterceptorOptions as c, StandardHandlerOptions as d, StandardHandleResult as e, StandardParams as f, StandardMatchResult as g, StandardMatcher as h, StandardCodec as i };
56
+ export { CompositeStandardHandlerPlugin as C, StandardHandler as e };
57
+ export type { StandardHandlerInterceptorOptions as S, StandardHandlerPlugin as a, StandardHandlerOptions as b, StandardHandleOptions as c, StandardHandleResult as d };
@@ -1,7 +1,7 @@
1
1
  import { Meta } from '@temporary-name/contract';
2
- import { HTTPPath, ORPCError, Interceptor } from '@temporary-name/shared';
3
- import { StandardResponse, StandardLazyRequest } from '@temporary-name/standard-server';
4
- import { C as Context, R as Router, A as AnyRouter, a as AnyProcedure, P as ProcedureClientInterceptorOptions } from './server.C1YnHvvf.mjs';
2
+ import { HTTPPath, Interceptor } from '@temporary-name/shared';
3
+ import { StandardLazyRequest, StandardResponse } from '@temporary-name/standard-server';
4
+ import { C as Context, R as Router, E as ProcedureClientInterceptorOptions } from './server.BKSOrA6h.js';
5
5
 
6
6
  interface StandardHandlerPlugin<T extends Context> {
7
7
  order?: number;
@@ -13,22 +13,6 @@ declare class CompositeStandardHandlerPlugin<T extends Context, TPlugin extends
13
13
  init(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
14
14
  }
15
15
 
16
- type StandardParams = Record<string, string>;
17
- type StandardMatchResult = {
18
- path: readonly string[];
19
- procedure: AnyProcedure;
20
- params?: StandardParams;
21
- } | undefined;
22
- interface StandardMatcher {
23
- init(router: AnyRouter): void;
24
- match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
25
- }
26
- interface StandardCodec {
27
- encode(output: unknown, procedure: AnyProcedure): StandardResponse;
28
- encodeError(error: ORPCError<any, any>): StandardResponse;
29
- decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
30
- }
31
-
32
16
  interface StandardHandleOptions<T extends Context> {
33
17
  prefix?: HTTPPath;
34
18
  context: T;
@@ -60,14 +44,14 @@ interface StandardHandlerOptions<TContext extends Context> {
60
44
  clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, Promise<unknown>>[];
61
45
  }
62
46
  declare class StandardHandler<T extends Context> {
63
- private readonly matcher;
64
- private readonly codec;
65
47
  private readonly interceptors;
66
48
  private readonly clientInterceptors;
67
49
  private readonly rootInterceptors;
68
- constructor(router: Router<any, T>, matcher: StandardMatcher, codec: StandardCodec, options: NoInfer<StandardHandlerOptions<T>>);
50
+ private readonly matcher;
51
+ private readonly codec;
52
+ constructor(router: Router<any, T>, options: NoInfer<StandardHandlerOptions<T>>);
69
53
  handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
70
54
  }
71
55
 
72
- export { CompositeStandardHandlerPlugin as C, StandardHandler as S };
73
- export type { StandardHandlerPlugin as a, StandardHandleOptions as b, StandardHandlerInterceptorOptions as c, StandardHandlerOptions as d, StandardHandleResult as e, StandardParams as f, StandardMatchResult as g, StandardMatcher as h, StandardCodec as i };
56
+ export { CompositeStandardHandlerPlugin as C, StandardHandler as e };
57
+ export type { StandardHandlerInterceptorOptions as S, StandardHandlerPlugin as a, StandardHandlerOptions as b, StandardHandleOptions as c, StandardHandleResult as d };
@@ -0,0 +1,261 @@
1
+ import { isObject, NullProtoObj, isAsyncIteratorObject, toORPCError, isORPCErrorJson, createORPCErrorFromJson } from '@temporary-name/shared';
2
+ import { mapEventIterator, ErrorEvent } from '@temporary-name/standard-server';
3
+
4
+ class StandardBracketNotationSerializer {
5
+ maxArrayIndex;
6
+ constructor(options = {}) {
7
+ this.maxArrayIndex = options.maxBracketNotationArrayIndex ?? 9999;
8
+ }
9
+ serialize(data, segments = [], result = []) {
10
+ if (Array.isArray(data)) {
11
+ data.forEach((item, i) => {
12
+ this.serialize(item, [...segments, i], result);
13
+ });
14
+ } else if (isObject(data)) {
15
+ for (const key in data) {
16
+ this.serialize(data[key], [...segments, key], result);
17
+ }
18
+ } else {
19
+ result.push([this.stringifyPath(segments), data]);
20
+ }
21
+ return result;
22
+ }
23
+ deserialize(serialized) {
24
+ if (serialized.length === 0) {
25
+ return {};
26
+ }
27
+ const arrayPushStyles = /* @__PURE__ */ new WeakSet();
28
+ const ref = { value: [] };
29
+ for (const [path, value] of serialized) {
30
+ const segments = this.parsePath(path);
31
+ let currentRef = ref;
32
+ let nextSegment = "value";
33
+ segments.forEach((segment, i) => {
34
+ if (!Array.isArray(currentRef[nextSegment]) && !isObject(currentRef[nextSegment])) {
35
+ currentRef[nextSegment] = [];
36
+ }
37
+ if (i !== segments.length - 1) {
38
+ if (Array.isArray(currentRef[nextSegment]) && !isValidArrayIndex(segment, this.maxArrayIndex)) {
39
+ if (arrayPushStyles.has(currentRef[nextSegment])) {
40
+ arrayPushStyles.delete(currentRef[nextSegment]);
41
+ currentRef[nextSegment] = pushStyleArrayToObject(currentRef[nextSegment]);
42
+ } else {
43
+ currentRef[nextSegment] = arrayToObject(currentRef[nextSegment]);
44
+ }
45
+ }
46
+ } else {
47
+ if (Array.isArray(currentRef[nextSegment])) {
48
+ if (segment === "") {
49
+ if (currentRef[nextSegment].length && !arrayPushStyles.has(currentRef[nextSegment])) {
50
+ currentRef[nextSegment] = arrayToObject(currentRef[nextSegment]);
51
+ }
52
+ } else {
53
+ if (arrayPushStyles.has(currentRef[nextSegment])) {
54
+ arrayPushStyles.delete(currentRef[nextSegment]);
55
+ currentRef[nextSegment] = pushStyleArrayToObject(currentRef[nextSegment]);
56
+ } else if (!isValidArrayIndex(segment, this.maxArrayIndex)) {
57
+ currentRef[nextSegment] = arrayToObject(currentRef[nextSegment]);
58
+ }
59
+ }
60
+ }
61
+ }
62
+ currentRef = currentRef[nextSegment];
63
+ nextSegment = segment;
64
+ });
65
+ if (Array.isArray(currentRef) && nextSegment === "") {
66
+ arrayPushStyles.add(currentRef);
67
+ currentRef.push(value);
68
+ } else if (nextSegment in currentRef) {
69
+ if (Array.isArray(currentRef[nextSegment])) {
70
+ currentRef[nextSegment].push(value);
71
+ } else {
72
+ currentRef[nextSegment] = [currentRef[nextSegment], value];
73
+ }
74
+ } else {
75
+ currentRef[nextSegment] = value;
76
+ }
77
+ }
78
+ return ref.value;
79
+ }
80
+ stringifyPath(segments) {
81
+ return segments.map((segment) => {
82
+ return segment.toString().replace(/[\\[\]]/g, (match) => {
83
+ switch (match) {
84
+ case "\\":
85
+ return "\\\\";
86
+ case "[":
87
+ return "\\[";
88
+ case "]":
89
+ return "\\]";
90
+ /* v8 ignore next 2 */
91
+ default:
92
+ return match;
93
+ }
94
+ });
95
+ }).reduce((result, segment, i) => {
96
+ if (i === 0) {
97
+ return segment;
98
+ }
99
+ return `${result}[${segment}]`;
100
+ }, "");
101
+ }
102
+ parsePath(path) {
103
+ const segments = [];
104
+ let inBrackets = false;
105
+ let currentSegment = "";
106
+ let backslashCount = 0;
107
+ for (let i = 0; i < path.length; i++) {
108
+ const char = path[i];
109
+ const nextChar = path[i + 1];
110
+ if (inBrackets && char === "]" && (nextChar === void 0 || nextChar === "[") && backslashCount % 2 === 0) {
111
+ if (nextChar === void 0) {
112
+ inBrackets = false;
113
+ }
114
+ segments.push(currentSegment);
115
+ currentSegment = "";
116
+ i++;
117
+ } else if (segments.length === 0 && char === "[" && backslashCount % 2 === 0) {
118
+ inBrackets = true;
119
+ segments.push(currentSegment);
120
+ currentSegment = "";
121
+ } else if (char === "\\") {
122
+ backslashCount++;
123
+ } else {
124
+ currentSegment += "\\".repeat(backslashCount / 2) + char;
125
+ backslashCount = 0;
126
+ }
127
+ }
128
+ return inBrackets || segments.length === 0 ? [path] : segments;
129
+ }
130
+ }
131
+ function isValidArrayIndex(value, maxIndex) {
132
+ return /^0$|^[1-9]\d*$/.test(value) && Number(value) <= maxIndex;
133
+ }
134
+ function arrayToObject(array) {
135
+ const obj = new NullProtoObj();
136
+ array.forEach((item, i) => {
137
+ obj[i] = item;
138
+ });
139
+ return obj;
140
+ }
141
+ function pushStyleArrayToObject(array) {
142
+ const obj = new NullProtoObj();
143
+ obj[""] = array.length === 1 ? array[0] : array;
144
+ return obj;
145
+ }
146
+
147
+ class StandardOpenAPIJsonSerializer {
148
+ serialize(data, hasBlobRef = { value: false }) {
149
+ if (data instanceof Blob) {
150
+ hasBlobRef.value = true;
151
+ return [data, hasBlobRef.value];
152
+ }
153
+ if (data instanceof Set) {
154
+ return this.serialize(Array.from(data), hasBlobRef);
155
+ }
156
+ if (data instanceof Map) {
157
+ return this.serialize(Array.from(data.entries()), hasBlobRef);
158
+ }
159
+ if (Array.isArray(data)) {
160
+ const json = data.map((v) => v === void 0 ? null : this.serialize(v, hasBlobRef)[0]);
161
+ return [json, hasBlobRef.value];
162
+ }
163
+ if (isObject(data)) {
164
+ const json = {};
165
+ for (const k in data) {
166
+ if (k === "toJSON" && typeof data[k] === "function") {
167
+ continue;
168
+ }
169
+ json[k] = this.serialize(data[k], hasBlobRef)[0];
170
+ }
171
+ return [json, hasBlobRef.value];
172
+ }
173
+ if (typeof data === "bigint" || data instanceof RegExp || data instanceof URL) {
174
+ return [data.toString(), hasBlobRef.value];
175
+ }
176
+ if (data instanceof Date) {
177
+ return [Number.isNaN(data.getTime()) ? null : data.toISOString(), hasBlobRef.value];
178
+ }
179
+ if (Number.isNaN(data)) {
180
+ return [null, hasBlobRef.value];
181
+ }
182
+ return [data, hasBlobRef.value];
183
+ }
184
+ }
185
+
186
+ class StandardOpenAPISerializer {
187
+ constructor(jsonSerializer, bracketNotation) {
188
+ this.jsonSerializer = jsonSerializer;
189
+ this.bracketNotation = bracketNotation;
190
+ }
191
+ serialize(data, options = {}) {
192
+ if (isAsyncIteratorObject(data) && !options.outputFormat) {
193
+ return mapEventIterator(data, {
194
+ value: async (value) => this.#serialize(value, { outputFormat: "plain" }),
195
+ error: async (e) => {
196
+ return new ErrorEvent({
197
+ data: this.#serialize(toORPCError(e).toJSON(), { outputFormat: "plain" }),
198
+ cause: e
199
+ });
200
+ }
201
+ });
202
+ }
203
+ return this.#serialize(data, options);
204
+ }
205
+ #serialize(data, options) {
206
+ const [json, hasBlob] = this.jsonSerializer.serialize(data);
207
+ if (options.outputFormat === "plain") {
208
+ return json;
209
+ }
210
+ if (options.outputFormat === "URLSearchParams") {
211
+ const params = new URLSearchParams();
212
+ for (const [path, value] of this.bracketNotation.serialize(json)) {
213
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
214
+ params.append(path, value.toString());
215
+ }
216
+ }
217
+ return params;
218
+ }
219
+ if (json instanceof Blob || json === void 0 || !hasBlob) {
220
+ return json;
221
+ }
222
+ const form = new FormData();
223
+ for (const [path, value] of this.bracketNotation.serialize(json)) {
224
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
225
+ form.append(path, value.toString());
226
+ } else if (value instanceof Blob) {
227
+ form.append(path, value);
228
+ }
229
+ }
230
+ return form;
231
+ }
232
+ deserialize(data) {
233
+ if (data instanceof URLSearchParams || data instanceof FormData) {
234
+ return this.bracketNotation.deserialize(Array.from(data.entries()));
235
+ }
236
+ if (isAsyncIteratorObject(data)) {
237
+ return mapEventIterator(data, {
238
+ value: async (value) => value,
239
+ error: async (e) => {
240
+ if (e instanceof ErrorEvent && isORPCErrorJson(e.data)) {
241
+ return createORPCErrorFromJson(e.data, { cause: e });
242
+ }
243
+ return e;
244
+ }
245
+ });
246
+ }
247
+ return data;
248
+ }
249
+ }
250
+
251
+ function standardizeHTTPPath(path) {
252
+ return `/${path.replace(/\/{2,}/g, "/").replace(/^\/|\/$/g, "")}`;
253
+ }
254
+ function getDynamicParams(path) {
255
+ return path ? standardizeHTTPPath(path).match(/\/\{[^}]+\}/g)?.map((v) => ({
256
+ raw: v,
257
+ name: v.match(/\{\+?([^}]+)\}/)[1]
258
+ })) : void 0;
259
+ }
260
+
261
+ export { StandardBracketNotationSerializer as S, StandardOpenAPISerializer as a, StandardOpenAPIJsonSerializer as b, getDynamicParams as g, standardizeHTTPPath as s };
@@ -0,0 +1,23 @@
1
+ import { HTTPPath } from '@temporary-name/shared';
2
+ import { C as Context } from './server.BKSOrA6h.js';
3
+ import { c as StandardHandleOptions } from './server.CQyYNJ1H.js';
4
+
5
+ type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
6
+ context?: T;
7
+ } : {
8
+ context: T;
9
+ });
10
+ declare function resolveFriendlyStandardHandleOptions<T extends Context>(options: FriendlyStandardHandleOptions<T>): StandardHandleOptions<T>;
11
+ /**
12
+ * {@link https://github.com/unjs/rou3}
13
+ *
14
+ * @internal
15
+ */
16
+ declare function toRou3Pattern(path: HTTPPath): string;
17
+ /**
18
+ * @internal
19
+ */
20
+ declare function decodeParams(params: Record<string, string>): Record<string, string>;
21
+
22
+ export { decodeParams as d, resolveFriendlyStandardHandleOptions as r, toRou3Pattern as t };
23
+ export type { FriendlyStandardHandleOptions as F };