@temporary-name/server 1.9.3-alpha.b7ce8fb6e9463a26fd2564cb172dc612ae4de52d → 1.9.3-alpha.c13915862ce0feb161cb37a7c0da5ab7d57bd1bf
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/adapters/aws-lambda/index.mjs +2 -2
- package/dist/adapters/fetch/index.mjs +2 -2
- package/dist/adapters/node/index.mjs +2 -2
- package/dist/adapters/standard/index.d.mts +2 -2
- package/dist/adapters/standard/index.d.ts +2 -2
- package/dist/adapters/standard/index.mjs +3 -3
- package/dist/index.mjs +5 -2
- package/dist/plugins/index.d.mts +3 -78
- package/dist/plugins/index.d.ts +3 -78
- package/dist/plugins/index.mjs +17 -189
- package/dist/shared/{server.ClhVCxfg.mjs → server.C61o1Zch.mjs} +5 -5
- package/dist/shared/{server.CVBLzkro.mjs → server.DwbIdsnK.mjs} +5 -6
- package/package.json +10 -22
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { resolveMaybeOptionalOptions } from '@temporary-name/shared';
|
|
2
2
|
import { toStandardLazyRequest, sendStandardResponse } from '@temporary-name/standard-server-aws-lambda';
|
|
3
|
-
import { S as StandardHandler, r as resolveFriendlyStandardHandleOptions } from '../../shared/server.
|
|
3
|
+
import { S as StandardHandler, r as resolveFriendlyStandardHandleOptions } from '../../shared/server.DwbIdsnK.mjs';
|
|
4
4
|
import '@temporary-name/contract';
|
|
5
5
|
import '@temporary-name/standard-server';
|
|
6
6
|
import '@temporary-name/server';
|
|
7
7
|
import 'rou3';
|
|
8
|
-
import '../../shared/server.
|
|
8
|
+
import '../../shared/server.C61o1Zch.mjs';
|
|
9
9
|
import '@temporary-name/zod';
|
|
10
10
|
import '../../shared/server.JtIZ8YG7.mjs';
|
|
11
11
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ORPCError, toArray, intercept, resolveMaybeOptionalOptions } from '@temporary-name/shared';
|
|
2
2
|
import { toStandardLazyRequest, toFetchResponse } from '@temporary-name/standard-server-fetch';
|
|
3
|
-
import { C as CompositeStandardHandlerPlugin, S as StandardHandler, r as resolveFriendlyStandardHandleOptions } from '../../shared/server.
|
|
3
|
+
import { C as CompositeStandardHandlerPlugin, S as StandardHandler, r as resolveFriendlyStandardHandleOptions } from '../../shared/server.DwbIdsnK.mjs';
|
|
4
4
|
import '@temporary-name/contract';
|
|
5
5
|
import '@temporary-name/standard-server';
|
|
6
6
|
import '@temporary-name/server';
|
|
7
7
|
import 'rou3';
|
|
8
8
|
import '@temporary-name/zod';
|
|
9
|
-
import '../../shared/server.
|
|
9
|
+
import '../../shared/server.C61o1Zch.mjs';
|
|
10
10
|
import '../../shared/server.JtIZ8YG7.mjs';
|
|
11
11
|
|
|
12
12
|
class BodyLimitPlugin {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { once, ORPCError, toArray, intercept, resolveMaybeOptionalOptions } from '@temporary-name/shared';
|
|
2
2
|
import compression from '@temporary-name/interop/compression';
|
|
3
3
|
import { toStandardLazyRequest, sendStandardResponse } from '@temporary-name/standard-server-node';
|
|
4
|
-
import { C as CompositeStandardHandlerPlugin, S as StandardHandler, r as resolveFriendlyStandardHandleOptions } from '../../shared/server.
|
|
4
|
+
import { C as CompositeStandardHandlerPlugin, S as StandardHandler, r as resolveFriendlyStandardHandleOptions } from '../../shared/server.DwbIdsnK.mjs';
|
|
5
5
|
import '@temporary-name/contract';
|
|
6
6
|
import '@temporary-name/standard-server';
|
|
7
7
|
import '@temporary-name/server';
|
|
8
8
|
import 'rou3';
|
|
9
9
|
import '@temporary-name/zod';
|
|
10
|
-
import '../../shared/server.
|
|
10
|
+
import '../../shared/server.C61o1Zch.mjs';
|
|
11
11
|
import '../../shared/server.JtIZ8YG7.mjs';
|
|
12
12
|
|
|
13
13
|
class BodyLimitPlugin {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { C as CompositeStandardHandlerPlugin, c as StandardHandleOptions, d as StandardHandleResult, e as StandardHandler, S as StandardHandlerInterceptorOptions, b as StandardHandlerOptions, a as StandardHandlerPlugin } from '../../shared/server.D6Qs_UcF.mjs';
|
|
2
2
|
import { AnyProcedure, AnyRouter } from '@temporary-name/server';
|
|
3
|
-
import { StandardLazyRequest,
|
|
3
|
+
import { StandardLazyRequest, StandardResponse, ORPCError, HTTPPath } from '@temporary-name/shared';
|
|
4
4
|
export { F as FriendlyStandardHandleOptions, d as decodeParams, r as resolveFriendlyStandardHandleOptions, t as toRou3Pattern } from '../../shared/server.7aL9gcoU.mjs';
|
|
5
5
|
import '@temporary-name/contract';
|
|
6
6
|
import '../../shared/server.BL2R5jcp.mjs';
|
|
@@ -8,7 +8,7 @@ import '../../shared/server.BL2R5jcp.mjs';
|
|
|
8
8
|
declare function decode(request: StandardLazyRequest, pathParams: Record<string, string> | undefined): Promise<{
|
|
9
9
|
path: unknown;
|
|
10
10
|
query: unknown;
|
|
11
|
-
headers:
|
|
11
|
+
headers: Headers;
|
|
12
12
|
body: unknown;
|
|
13
13
|
}>;
|
|
14
14
|
declare function encode(output: unknown, procedure: AnyProcedure): StandardResponse;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { C as CompositeStandardHandlerPlugin, c as StandardHandleOptions, d as StandardHandleResult, e as StandardHandler, S as StandardHandlerInterceptorOptions, b as StandardHandlerOptions, a as StandardHandlerPlugin } from '../../shared/server.DpoO_ER_.js';
|
|
2
2
|
import { AnyProcedure, AnyRouter } from '@temporary-name/server';
|
|
3
|
-
import { StandardLazyRequest,
|
|
3
|
+
import { StandardLazyRequest, StandardResponse, ORPCError, HTTPPath } from '@temporary-name/shared';
|
|
4
4
|
export { F as FriendlyStandardHandleOptions, d as decodeParams, r as resolveFriendlyStandardHandleOptions, t as toRou3Pattern } from '../../shared/server.DFptr1Nz.js';
|
|
5
5
|
import '@temporary-name/contract';
|
|
6
6
|
import '../../shared/server.BL2R5jcp.js';
|
|
@@ -8,7 +8,7 @@ import '../../shared/server.BL2R5jcp.js';
|
|
|
8
8
|
declare function decode(request: StandardLazyRequest, pathParams: Record<string, string> | undefined): Promise<{
|
|
9
9
|
path: unknown;
|
|
10
10
|
query: unknown;
|
|
11
|
-
headers:
|
|
11
|
+
headers: Headers;
|
|
12
12
|
body: unknown;
|
|
13
13
|
}>;
|
|
14
14
|
declare function encode(output: unknown, procedure: AnyProcedure): StandardResponse;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { C as CompositeStandardHandlerPlugin, S as StandardHandler, b as StandardOpenAPIMatcher, d as decode, c as decodeParams, e as encode, a as encodeError, r as resolveFriendlyStandardHandleOptions, t as toRou3Pattern } from '../../shared/server.
|
|
1
|
+
export { C as CompositeStandardHandlerPlugin, S as StandardHandler, b as StandardOpenAPIMatcher, d as decode, c as decodeParams, e as encode, a as encodeError, r as resolveFriendlyStandardHandleOptions, t as toRou3Pattern } from '../../shared/server.DwbIdsnK.mjs';
|
|
2
2
|
import '@temporary-name/shared';
|
|
3
|
-
import '
|
|
4
|
-
import '../../shared/server.ClhVCxfg.mjs';
|
|
3
|
+
import '../../shared/server.C61o1Zch.mjs';
|
|
5
4
|
import '@temporary-name/contract';
|
|
5
|
+
import '@temporary-name/standard-server';
|
|
6
6
|
import '@temporary-name/zod';
|
|
7
7
|
import '../../shared/server.JtIZ8YG7.mjs';
|
|
8
8
|
import '@temporary-name/server';
|
package/dist/index.mjs
CHANGED
|
@@ -3,8 +3,8 @@ export { ValidationError, eventIterator, validateORPCError } from '@temporary-na
|
|
|
3
3
|
import { onError, resolveMaybeOptionalOptions } from '@temporary-name/shared';
|
|
4
4
|
export { AsyncIteratorClass, EventPublisher, ORPCError, asyncIteratorToStream as eventIteratorToStream, isDefinedError, onError, onFinish, onStart, onSuccess, safe, streamToAsyncIteratorClass as streamToEventIterator } from '@temporary-name/shared';
|
|
5
5
|
import { SchemaClass, object, core, gatingContext } from '@temporary-name/zod';
|
|
6
|
-
import { P as Procedure, c as createProcedureClient, e as enhanceRouter, a as addMiddleware, s as setHiddenRouterContract, l as lazyInternal, g as getLazyMeta, u as unlazy, i as isProcedure, b as isLazy, d as getRouter } from './shared/server.
|
|
7
|
-
export { L as LAZY_SYMBOL, p as createAccessibleLazyRouter, f as createORPCErrorConstructorMap, o as getHiddenRouterContract, k as isStartWithMiddlewares, h as lazy, m as mergeCurrentContext, n as mergeMiddlewares, j as middlewareOutputFn, r as resolveContractProcedures, t as traverseContractProcedures, q as unlazyRouter } from './shared/server.
|
|
6
|
+
import { P as Procedure, c as createProcedureClient, e as enhanceRouter, a as addMiddleware, s as setHiddenRouterContract, l as lazyInternal, g as getLazyMeta, u as unlazy, i as isProcedure, b as isLazy, d as getRouter } from './shared/server.C61o1Zch.mjs';
|
|
7
|
+
export { L as LAZY_SYMBOL, p as createAccessibleLazyRouter, f as createORPCErrorConstructorMap, o as getHiddenRouterContract, k as isStartWithMiddlewares, h as lazy, m as mergeCurrentContext, n as mergeMiddlewares, j as middlewareOutputFn, r as resolveContractProcedures, t as traverseContractProcedures, q as unlazyRouter } from './shared/server.C61o1Zch.mjs';
|
|
8
8
|
export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
|
|
9
9
|
|
|
10
10
|
class DecoratedProcedure extends Procedure {
|
|
@@ -146,6 +146,9 @@ class ProcedureBuilder extends ContractProcedure {
|
|
|
146
146
|
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
147
147
|
*/
|
|
148
148
|
handler(handler) {
|
|
149
|
+
if (this["~orpc"].schemas.outputSchema === initialSchemas.outputSchema) {
|
|
150
|
+
throw new Error("You must call .output() before calling .handler()");
|
|
151
|
+
}
|
|
149
152
|
return new DecoratedProcedure({
|
|
150
153
|
...this["~orpc"],
|
|
151
154
|
handler
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,57 +1,8 @@
|
|
|
1
|
-
import { Value, Promisable,
|
|
2
|
-
import { BatchResponseBodyItem } from '@temporary-name/standard-server/batch';
|
|
1
|
+
import { Value, Promisable, ORPCError } from '@temporary-name/shared';
|
|
3
2
|
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.D6Qs_UcF.mjs';
|
|
4
3
|
import { C as Context, G as ProcedureClientInterceptorOptions } from '../shared/server.BL2R5jcp.mjs';
|
|
5
4
|
import { Meta } from '@temporary-name/contract';
|
|
6
5
|
|
|
7
|
-
interface BatchHandlerOptions<T extends Context> {
|
|
8
|
-
/**
|
|
9
|
-
* The max size of the batch allowed.
|
|
10
|
-
*
|
|
11
|
-
* @default 10
|
|
12
|
-
*/
|
|
13
|
-
maxSize?: Value<Promisable<number>, [StandardHandlerInterceptorOptions<T>]>;
|
|
14
|
-
/**
|
|
15
|
-
* Map the request before processing it.
|
|
16
|
-
*
|
|
17
|
-
* @default merged back batch request headers into the request
|
|
18
|
-
*/
|
|
19
|
-
mapRequestItem?(request: StandardRequest, batchOptions: StandardHandlerInterceptorOptions<T>): StandardRequest;
|
|
20
|
-
/**
|
|
21
|
-
* Success batch response status code.
|
|
22
|
-
*
|
|
23
|
-
* @default 207
|
|
24
|
-
*/
|
|
25
|
-
successStatus?: Value<Promisable<number>, [
|
|
26
|
-
responses: Promise<BatchResponseBodyItem>[],
|
|
27
|
-
batchOptions: StandardHandlerInterceptorOptions<T>
|
|
28
|
-
]>;
|
|
29
|
-
/**
|
|
30
|
-
* success batch response headers.
|
|
31
|
-
*
|
|
32
|
-
* @default {}
|
|
33
|
-
*/
|
|
34
|
-
headers?: Value<Promisable<StandardHeaders>, [
|
|
35
|
-
responses: Promise<BatchResponseBodyItem>[],
|
|
36
|
-
batchOptions: StandardHandlerInterceptorOptions<T>
|
|
37
|
-
]>;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* The Batch Requests Plugin allows you to combine multiple requests and responses into a single batch,
|
|
41
|
-
* reducing the overhead of sending each one separately.
|
|
42
|
-
*
|
|
43
|
-
* @see {@link https://orpc.unnoq.com/docs/plugins/batch-requests Batch Requests Plugin Docs}
|
|
44
|
-
*/
|
|
45
|
-
declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
46
|
-
private readonly maxSize;
|
|
47
|
-
private readonly mapRequestItem;
|
|
48
|
-
private readonly successStatus;
|
|
49
|
-
private readonly headers;
|
|
50
|
-
order: number;
|
|
51
|
-
constructor(options?: BatchHandlerOptions<T>);
|
|
52
|
-
init(options: StandardHandlerOptions<T>): void;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
6
|
interface CORSOptions<T extends Context> {
|
|
56
7
|
origin?: Value<Promisable<string | readonly string[] | null | undefined>, [
|
|
57
8
|
origin: string,
|
|
@@ -79,32 +30,6 @@ declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T>
|
|
|
79
30
|
init(options: StandardHandlerOptions<T>): void;
|
|
80
31
|
}
|
|
81
32
|
|
|
82
|
-
interface RequestHeadersPluginContext {
|
|
83
|
-
reqHeaders?: Headers;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* The Request Headers Plugin injects a `reqHeaders` instance into the context,
|
|
87
|
-
* allowing access to request headers in oRPC.
|
|
88
|
-
*
|
|
89
|
-
* @see {@link https://orpc.unnoq.com/docs/plugins/request-headers Request Headers Plugin Docs}
|
|
90
|
-
*/
|
|
91
|
-
declare class RequestHeadersPlugin<T extends RequestHeadersPluginContext> implements StandardHandlerPlugin<T> {
|
|
92
|
-
init(options: StandardHandlerOptions<T>): void;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
interface ResponseHeadersPluginContext {
|
|
96
|
-
resHeaders?: Headers;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* The Response Headers Plugin allows you to set response headers in oRPC.
|
|
100
|
-
* It injects a resHeaders instance into the context, enabling you to modify response headers easily.
|
|
101
|
-
*
|
|
102
|
-
* @see {@link https://orpc.unnoq.com/docs/plugins/response-headers Response Headers Plugin Docs}
|
|
103
|
-
*/
|
|
104
|
-
declare class ResponseHeadersPlugin<T extends ResponseHeadersPluginContext> implements StandardHandlerPlugin<T> {
|
|
105
|
-
init(options: StandardHandlerOptions<T>): void;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
33
|
interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
|
|
109
34
|
/**
|
|
110
35
|
* The name of the header to check.
|
|
@@ -155,5 +80,5 @@ declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements St
|
|
|
155
80
|
init(options: StandardHandlerOptions<T>): void;
|
|
156
81
|
}
|
|
157
82
|
|
|
158
|
-
export {
|
|
159
|
-
export type {
|
|
83
|
+
export { CORSPlugin, SimpleCsrfProtectionHandlerPlugin };
|
|
84
|
+
export type { CORSOptions, SimpleCsrfProtectionHandlerPluginOptions };
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,57 +1,8 @@
|
|
|
1
|
-
import { Value, Promisable,
|
|
2
|
-
import { BatchResponseBodyItem } from '@temporary-name/standard-server/batch';
|
|
1
|
+
import { Value, Promisable, ORPCError } from '@temporary-name/shared';
|
|
3
2
|
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.DpoO_ER_.js';
|
|
4
3
|
import { C as Context, G as ProcedureClientInterceptorOptions } from '../shared/server.BL2R5jcp.js';
|
|
5
4
|
import { Meta } from '@temporary-name/contract';
|
|
6
5
|
|
|
7
|
-
interface BatchHandlerOptions<T extends Context> {
|
|
8
|
-
/**
|
|
9
|
-
* The max size of the batch allowed.
|
|
10
|
-
*
|
|
11
|
-
* @default 10
|
|
12
|
-
*/
|
|
13
|
-
maxSize?: Value<Promisable<number>, [StandardHandlerInterceptorOptions<T>]>;
|
|
14
|
-
/**
|
|
15
|
-
* Map the request before processing it.
|
|
16
|
-
*
|
|
17
|
-
* @default merged back batch request headers into the request
|
|
18
|
-
*/
|
|
19
|
-
mapRequestItem?(request: StandardRequest, batchOptions: StandardHandlerInterceptorOptions<T>): StandardRequest;
|
|
20
|
-
/**
|
|
21
|
-
* Success batch response status code.
|
|
22
|
-
*
|
|
23
|
-
* @default 207
|
|
24
|
-
*/
|
|
25
|
-
successStatus?: Value<Promisable<number>, [
|
|
26
|
-
responses: Promise<BatchResponseBodyItem>[],
|
|
27
|
-
batchOptions: StandardHandlerInterceptorOptions<T>
|
|
28
|
-
]>;
|
|
29
|
-
/**
|
|
30
|
-
* success batch response headers.
|
|
31
|
-
*
|
|
32
|
-
* @default {}
|
|
33
|
-
*/
|
|
34
|
-
headers?: Value<Promisable<StandardHeaders>, [
|
|
35
|
-
responses: Promise<BatchResponseBodyItem>[],
|
|
36
|
-
batchOptions: StandardHandlerInterceptorOptions<T>
|
|
37
|
-
]>;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* The Batch Requests Plugin allows you to combine multiple requests and responses into a single batch,
|
|
41
|
-
* reducing the overhead of sending each one separately.
|
|
42
|
-
*
|
|
43
|
-
* @see {@link https://orpc.unnoq.com/docs/plugins/batch-requests Batch Requests Plugin Docs}
|
|
44
|
-
*/
|
|
45
|
-
declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
46
|
-
private readonly maxSize;
|
|
47
|
-
private readonly mapRequestItem;
|
|
48
|
-
private readonly successStatus;
|
|
49
|
-
private readonly headers;
|
|
50
|
-
order: number;
|
|
51
|
-
constructor(options?: BatchHandlerOptions<T>);
|
|
52
|
-
init(options: StandardHandlerOptions<T>): void;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
6
|
interface CORSOptions<T extends Context> {
|
|
56
7
|
origin?: Value<Promisable<string | readonly string[] | null | undefined>, [
|
|
57
8
|
origin: string,
|
|
@@ -79,32 +30,6 @@ declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T>
|
|
|
79
30
|
init(options: StandardHandlerOptions<T>): void;
|
|
80
31
|
}
|
|
81
32
|
|
|
82
|
-
interface RequestHeadersPluginContext {
|
|
83
|
-
reqHeaders?: Headers;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* The Request Headers Plugin injects a `reqHeaders` instance into the context,
|
|
87
|
-
* allowing access to request headers in oRPC.
|
|
88
|
-
*
|
|
89
|
-
* @see {@link https://orpc.unnoq.com/docs/plugins/request-headers Request Headers Plugin Docs}
|
|
90
|
-
*/
|
|
91
|
-
declare class RequestHeadersPlugin<T extends RequestHeadersPluginContext> implements StandardHandlerPlugin<T> {
|
|
92
|
-
init(options: StandardHandlerOptions<T>): void;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
interface ResponseHeadersPluginContext {
|
|
96
|
-
resHeaders?: Headers;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* The Response Headers Plugin allows you to set response headers in oRPC.
|
|
100
|
-
* It injects a resHeaders instance into the context, enabling you to modify response headers easily.
|
|
101
|
-
*
|
|
102
|
-
* @see {@link https://orpc.unnoq.com/docs/plugins/response-headers Response Headers Plugin Docs}
|
|
103
|
-
*/
|
|
104
|
-
declare class ResponseHeadersPlugin<T extends ResponseHeadersPluginContext> implements StandardHandlerPlugin<T> {
|
|
105
|
-
init(options: StandardHandlerOptions<T>): void;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
33
|
interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
|
|
109
34
|
/**
|
|
110
35
|
* The name of the header to check.
|
|
@@ -155,5 +80,5 @@ declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements St
|
|
|
155
80
|
init(options: StandardHandlerOptions<T>): void;
|
|
156
81
|
}
|
|
157
82
|
|
|
158
|
-
export {
|
|
159
|
-
export type {
|
|
83
|
+
export { CORSPlugin, SimpleCsrfProtectionHandlerPlugin };
|
|
84
|
+
export type { CORSOptions, SimpleCsrfProtectionHandlerPluginOptions };
|
package/dist/plugins/index.mjs
CHANGED
|
@@ -1,119 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { parseBatchRequest, toBatchResponse } from '@temporary-name/standard-server/batch';
|
|
4
|
-
import { toFetchHeaders } from '@temporary-name/standard-server-fetch';
|
|
5
|
-
|
|
6
|
-
class BatchHandlerPlugin {
|
|
7
|
-
maxSize;
|
|
8
|
-
mapRequestItem;
|
|
9
|
-
successStatus;
|
|
10
|
-
headers;
|
|
11
|
-
order = 5e6;
|
|
12
|
-
constructor(options = {}) {
|
|
13
|
-
this.maxSize = options.maxSize ?? 10;
|
|
14
|
-
this.mapRequestItem = options.mapRequestItem ?? ((request, { request: batchRequest }) => ({
|
|
15
|
-
...request,
|
|
16
|
-
headers: {
|
|
17
|
-
...batchRequest.headers,
|
|
18
|
-
...request.headers
|
|
19
|
-
}
|
|
20
|
-
}));
|
|
21
|
-
this.successStatus = options.successStatus ?? 207;
|
|
22
|
-
this.headers = options.headers ?? {};
|
|
23
|
-
}
|
|
24
|
-
init(options) {
|
|
25
|
-
options.rootInterceptors ??= [];
|
|
26
|
-
options.rootInterceptors.unshift(async (options2) => {
|
|
27
|
-
const xHeader = flattenHeader(options2.request.headers["x-orpc-batch"]);
|
|
28
|
-
if (xHeader === void 0) {
|
|
29
|
-
return options2.next();
|
|
30
|
-
}
|
|
31
|
-
let isParsing = false;
|
|
32
|
-
try {
|
|
33
|
-
return await runWithSpan({ name: "handle_batch_request" }, async (span) => {
|
|
34
|
-
const mode = xHeader === "buffered" ? "buffered" : "streaming";
|
|
35
|
-
isParsing = true;
|
|
36
|
-
const parsed = parseBatchRequest({ ...options2.request, body: await options2.request.body() });
|
|
37
|
-
isParsing = false;
|
|
38
|
-
span?.setAttribute("batch.mode", mode);
|
|
39
|
-
span?.setAttribute("batch.size", parsed.length);
|
|
40
|
-
const maxSize = await value(this.maxSize, options2);
|
|
41
|
-
if (parsed.length > maxSize) {
|
|
42
|
-
const message = "Batch request size exceeds the maximum allowed size";
|
|
43
|
-
setSpanError(span, message);
|
|
44
|
-
return {
|
|
45
|
-
matched: true,
|
|
46
|
-
response: {
|
|
47
|
-
status: 413,
|
|
48
|
-
headers: {},
|
|
49
|
-
body: message
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
const responses = parsed.map((request, index) => {
|
|
54
|
-
const mapped = this.mapRequestItem(request, options2);
|
|
55
|
-
return options2.next({ ...options2, request: { ...mapped, body: () => Promise.resolve(mapped.body) } }).then(({ response: response2, matched }) => {
|
|
56
|
-
span?.addEvent(`response.${index}.${matched ? "success" : "not_matched"}`);
|
|
57
|
-
if (matched) {
|
|
58
|
-
if (response2.body instanceof Blob || response2.body instanceof FormData || isAsyncIteratorObject(response2.body)) {
|
|
59
|
-
return {
|
|
60
|
-
index,
|
|
61
|
-
status: 500,
|
|
62
|
-
headers: {},
|
|
63
|
-
body: "Batch responses do not support file/blob, or event-iterator. Please call this procedure separately outside of the batch request."
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
return { ...response2, index };
|
|
67
|
-
}
|
|
68
|
-
return { index, status: 404, headers: {}, body: "No procedure matched" };
|
|
69
|
-
}).catch((err) => {
|
|
70
|
-
Promise.reject(err);
|
|
71
|
-
return { index, status: 500, headers: {}, body: "Internal server error" };
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
await Promise.race(responses);
|
|
75
|
-
const status = await value(this.successStatus, responses, options2);
|
|
76
|
-
const headers = await value(this.headers, responses, options2);
|
|
77
|
-
const promises = [...responses];
|
|
78
|
-
const response = await toBatchResponse({
|
|
79
|
-
status,
|
|
80
|
-
headers,
|
|
81
|
-
mode,
|
|
82
|
-
body: new AsyncIteratorClass(
|
|
83
|
-
async () => {
|
|
84
|
-
const handling = promises.filter((p) => p !== void 0);
|
|
85
|
-
if (handling.length <= 0) {
|
|
86
|
-
return { done: true, value: void 0 };
|
|
87
|
-
}
|
|
88
|
-
const value2 = await Promise.race(handling);
|
|
89
|
-
promises[value2.index] = void 0;
|
|
90
|
-
return { done: false, value: value2 };
|
|
91
|
-
},
|
|
92
|
-
async () => {
|
|
93
|
-
}
|
|
94
|
-
)
|
|
95
|
-
});
|
|
96
|
-
return {
|
|
97
|
-
matched: true,
|
|
98
|
-
response
|
|
99
|
-
};
|
|
100
|
-
});
|
|
101
|
-
} catch (cause) {
|
|
102
|
-
if (isParsing) {
|
|
103
|
-
return {
|
|
104
|
-
matched: true,
|
|
105
|
-
response: {
|
|
106
|
-
status: 400,
|
|
107
|
-
headers: {},
|
|
108
|
-
body: "Invalid batch request, this could be caused by a malformed request body or a missing header"
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
throw cause;
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
}
|
|
1
|
+
import { value, ORPCError } from '@temporary-name/shared';
|
|
2
|
+
import { maybeSetHeader } from '@temporary-name/standard-server';
|
|
117
3
|
|
|
118
4
|
class CORSPlugin {
|
|
119
5
|
options;
|
|
@@ -132,17 +18,13 @@ class CORSPlugin {
|
|
|
132
18
|
options.rootInterceptors ??= [];
|
|
133
19
|
options.rootInterceptors.unshift(async (interceptorOptions) => {
|
|
134
20
|
if (interceptorOptions.request.method === "OPTIONS") {
|
|
135
|
-
const resHeaders =
|
|
21
|
+
const resHeaders = new Headers();
|
|
136
22
|
if (this.options.maxAge !== void 0) {
|
|
137
|
-
resHeaders
|
|
138
|
-
}
|
|
139
|
-
if (this.options.allowMethods?.length) {
|
|
140
|
-
resHeaders["access-control-allow-methods"] = flattenHeader(this.options.allowMethods);
|
|
141
|
-
}
|
|
142
|
-
const allowHeaders = this.options.allowHeaders ?? interceptorOptions.request.headers["access-control-request-headers"];
|
|
143
|
-
if (typeof allowHeaders === "string" || allowHeaders?.length) {
|
|
144
|
-
resHeaders["access-control-allow-headers"] = flattenHeader(allowHeaders);
|
|
23
|
+
resHeaders.set("access-control-max-age", this.options.maxAge.toString());
|
|
145
24
|
}
|
|
25
|
+
maybeSetHeader(resHeaders, "access-control-allow-methods", this.options.allowMethods);
|
|
26
|
+
const allowHeaders = this.options.allowHeaders ?? interceptorOptions.request.headers.get("access-control-request-headers");
|
|
27
|
+
maybeSetHeader(resHeaders, "access-control-allow-headers", allowHeaders);
|
|
146
28
|
return {
|
|
147
29
|
matched: true,
|
|
148
30
|
response: {
|
|
@@ -159,87 +41,33 @@ class CORSPlugin {
|
|
|
159
41
|
if (!result.matched) {
|
|
160
42
|
return result;
|
|
161
43
|
}
|
|
162
|
-
const origin =
|
|
44
|
+
const origin = interceptorOptions.request.headers.get("origin") ?? "";
|
|
163
45
|
const allowedOrigin = await value(this.options.origin, origin, interceptorOptions);
|
|
164
46
|
const allowedOriginArr = Array.isArray(allowedOrigin) ? allowedOrigin : [allowedOrigin];
|
|
165
47
|
if (allowedOriginArr.includes("*")) {
|
|
166
|
-
result.response.headers
|
|
48
|
+
result.response.headers.set("access-control-allow-origin", "*");
|
|
167
49
|
} else {
|
|
168
50
|
if (allowedOriginArr.includes(origin)) {
|
|
169
|
-
result.response.headers
|
|
51
|
+
result.response.headers.set("access-control-allow-origin", origin);
|
|
170
52
|
}
|
|
171
|
-
result.response.headers.vary
|
|
53
|
+
result.response.headers.set("vary", interceptorOptions.request.headers.get("vary") ?? "origin");
|
|
172
54
|
}
|
|
173
55
|
const allowedTimingOrigin = await value(this.options.timingOrigin, origin, interceptorOptions);
|
|
174
56
|
const allowedTimingOriginArr = Array.isArray(allowedTimingOrigin) ? allowedTimingOrigin : [allowedTimingOrigin];
|
|
175
57
|
if (allowedTimingOriginArr.includes("*")) {
|
|
176
|
-
result.response.headers
|
|
58
|
+
result.response.headers.set("timing-allow-origin", "*");
|
|
177
59
|
} else if (allowedTimingOriginArr.includes(origin)) {
|
|
178
|
-
result.response.headers
|
|
60
|
+
result.response.headers.set("timing-allow-origin", origin);
|
|
179
61
|
}
|
|
180
62
|
if (this.options.credentials) {
|
|
181
|
-
result.response.headers
|
|
182
|
-
}
|
|
183
|
-
if (this.options.exposeHeaders?.length) {
|
|
184
|
-
result.response.headers["access-control-expose-headers"] = flattenHeader(this.options.exposeHeaders);
|
|
63
|
+
result.response.headers.set("access-control-allow-credentials", "true");
|
|
185
64
|
}
|
|
65
|
+
maybeSetHeader(result.response.headers, "access-control-expose-headers", this.options.exposeHeaders);
|
|
186
66
|
return result;
|
|
187
67
|
});
|
|
188
68
|
}
|
|
189
69
|
}
|
|
190
70
|
|
|
191
|
-
class RequestHeadersPlugin {
|
|
192
|
-
init(options) {
|
|
193
|
-
options.rootInterceptors ??= [];
|
|
194
|
-
options.rootInterceptors.push((interceptorOptions) => {
|
|
195
|
-
const reqHeaders = interceptorOptions.context.reqHeaders ?? toFetchHeaders(interceptorOptions.request.headers);
|
|
196
|
-
return interceptorOptions.next({
|
|
197
|
-
...interceptorOptions,
|
|
198
|
-
context: {
|
|
199
|
-
...interceptorOptions.context,
|
|
200
|
-
reqHeaders
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
class ResponseHeadersPlugin {
|
|
208
|
-
init(options) {
|
|
209
|
-
options.rootInterceptors ??= [];
|
|
210
|
-
options.rootInterceptors.push(async (interceptorOptions) => {
|
|
211
|
-
const resHeaders = interceptorOptions.context.resHeaders ?? new Headers();
|
|
212
|
-
const result = await interceptorOptions.next({
|
|
213
|
-
...interceptorOptions,
|
|
214
|
-
context: {
|
|
215
|
-
...interceptorOptions.context,
|
|
216
|
-
resHeaders
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
if (!result.matched) {
|
|
220
|
-
return result;
|
|
221
|
-
}
|
|
222
|
-
const responseHeaders = clone(result.response.headers);
|
|
223
|
-
for (const [key, value] of resHeaders) {
|
|
224
|
-
if (Array.isArray(responseHeaders[key])) {
|
|
225
|
-
responseHeaders[key].push(value);
|
|
226
|
-
} else if (responseHeaders[key] !== void 0) {
|
|
227
|
-
responseHeaders[key] = [responseHeaders[key], value];
|
|
228
|
-
} else {
|
|
229
|
-
responseHeaders[key] = value;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return {
|
|
233
|
-
...result,
|
|
234
|
-
response: {
|
|
235
|
-
...result.response,
|
|
236
|
-
headers: responseHeaders
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
71
|
const SIMPLE_CSRF_PROTECTION_CONTEXT_SYMBOL = Symbol("SIMPLE_CSRF_PROTECTION_CONTEXT");
|
|
244
72
|
class SimpleCsrfProtectionHandlerPlugin {
|
|
245
73
|
headerName;
|
|
@@ -266,7 +94,7 @@ class SimpleCsrfProtectionHandlerPlugin {
|
|
|
266
94
|
...options2,
|
|
267
95
|
context: {
|
|
268
96
|
...options2.context,
|
|
269
|
-
[SIMPLE_CSRF_PROTECTION_CONTEXT_SYMBOL]: options2.request.headers
|
|
97
|
+
[SIMPLE_CSRF_PROTECTION_CONTEXT_SYMBOL]: options2.request.headers.get(headerName) === headerValue
|
|
270
98
|
}
|
|
271
99
|
});
|
|
272
100
|
});
|
|
@@ -285,4 +113,4 @@ class SimpleCsrfProtectionHandlerPlugin {
|
|
|
285
113
|
}
|
|
286
114
|
}
|
|
287
115
|
|
|
288
|
-
export {
|
|
116
|
+
export { CORSPlugin, SimpleCsrfProtectionHandlerPlugin };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isContractProcedure, mergePrefix, mergeErrorMap, enhanceRoute, 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 {
|
|
4
|
+
import { safeDecodeAsync, safeEncodeAsync } from '@temporary-name/zod';
|
|
5
5
|
|
|
6
6
|
function isStartWithMiddlewares(middlewares, compare) {
|
|
7
7
|
if (compare.length > middlewares.length) {
|
|
@@ -309,9 +309,9 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
309
309
|
async function validateInput(procedure, input) {
|
|
310
310
|
const schemas = procedure["~orpc"].schemas;
|
|
311
311
|
return runWithSpan({ name: "validate_input" }, async () => {
|
|
312
|
-
const resultBody = await
|
|
313
|
-
const resultPath = await
|
|
314
|
-
const resultQuery = await
|
|
312
|
+
const resultBody = await safeDecodeAsync(schemas.bodySchema, input.body, { parseType: "body" });
|
|
313
|
+
const resultPath = await safeDecodeAsync(schemas.pathSchema, input.path, { parseType: "path" });
|
|
314
|
+
const resultQuery = await safeDecodeAsync(schemas.querySchema, input.query, { parseType: "query" });
|
|
315
315
|
const issues = [];
|
|
316
316
|
if (!resultBody.success) {
|
|
317
317
|
issues.push(...resultBody.error.issues.map((i) => ({ ...i, path: ["body", ...i.path] })));
|
|
@@ -349,7 +349,7 @@ async function validateOutput(procedure, output) {
|
|
|
349
349
|
return output;
|
|
350
350
|
}
|
|
351
351
|
return runWithSpan({ name: "validate_output" }, async () => {
|
|
352
|
-
const result = await
|
|
352
|
+
const result = await safeEncodeAsync(schema, output, { parseType: "output" });
|
|
353
353
|
if (!result.success) {
|
|
354
354
|
throw new ORPCError("INTERNAL_SERVER_ERROR", {
|
|
355
355
|
message: "Output validation failed",
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { stringifyJSON, isObject, isORPCErrorStatus, tryDecodeURIComponent, toHttpPath, toArray, intercept, runWithSpan, ORPC_NAME, isAsyncIteratorObject, asyncIteratorWithSpan, setSpanError, ORPCError, toORPCError } from '@temporary-name/shared';
|
|
2
|
-
import {
|
|
3
|
-
import { c as createProcedureClient } from './server.ClhVCxfg.mjs';
|
|
2
|
+
import { c as createProcedureClient } from './server.C61o1Zch.mjs';
|
|
4
3
|
import { fallbackContractConfig, standardizeHTTPPath } from '@temporary-name/contract';
|
|
5
4
|
import { d as deserialize, b as bracketNotationDeserialize, s as serialize } from './server.JtIZ8YG7.mjs';
|
|
6
5
|
import { traverseContractProcedures, isProcedure, getLazyMeta, unlazy, getRouter, createContractedProcedure } from '@temporary-name/server';
|
|
@@ -26,7 +25,7 @@ function encode(output, procedure) {
|
|
|
26
25
|
if (outputStructure === "compact") {
|
|
27
26
|
return {
|
|
28
27
|
status: successStatus,
|
|
29
|
-
headers:
|
|
28
|
+
headers: new Headers(),
|
|
30
29
|
body: serialize(output)
|
|
31
30
|
};
|
|
32
31
|
}
|
|
@@ -45,14 +44,14 @@ function encode(output, procedure) {
|
|
|
45
44
|
}
|
|
46
45
|
return {
|
|
47
46
|
status: output.status ?? successStatus,
|
|
48
|
-
headers: output.headers ??
|
|
47
|
+
headers: output.headers ?? new Headers(),
|
|
49
48
|
body: serialize(output.body)
|
|
50
49
|
};
|
|
51
50
|
}
|
|
52
51
|
function encodeError(error) {
|
|
53
52
|
return {
|
|
54
53
|
status: error.status,
|
|
55
|
-
headers:
|
|
54
|
+
headers: new Headers(),
|
|
56
55
|
body: serialize(error.toJSON(), { outputFormat: "plain" })
|
|
57
56
|
};
|
|
58
57
|
}
|
|
@@ -223,7 +222,7 @@ class StandardHandler {
|
|
|
223
222
|
const output = await client(input, {
|
|
224
223
|
request: request2,
|
|
225
224
|
signal: request2.signal,
|
|
226
|
-
lastEventId:
|
|
225
|
+
lastEventId: request2.headers.get("last-event-id") ?? void 0
|
|
227
226
|
});
|
|
228
227
|
step = void 0;
|
|
229
228
|
const response = encode(output, match.procedure);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporary-name/server",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.9.3-alpha.
|
|
4
|
+
"version": "1.9.3-alpha.c13915862ce0feb161cb37a7c0da5ab7d57bd1bf",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.stainless.com/",
|
|
7
7
|
"repository": {
|
|
@@ -57,31 +57,19 @@
|
|
|
57
57
|
"files": [
|
|
58
58
|
"dist"
|
|
59
59
|
],
|
|
60
|
-
"peerDependencies": {
|
|
61
|
-
"drizzle-orm": "^0.44.5",
|
|
62
|
-
"drizzle-zod": "^0.8.3"
|
|
63
|
-
},
|
|
64
|
-
"peerDependenciesMeta": {
|
|
65
|
-
"drizzle-orm": {
|
|
66
|
-
"optional": true
|
|
67
|
-
},
|
|
68
|
-
"drizzle-zod": {
|
|
69
|
-
"optional": true
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
60
|
"dependencies": {
|
|
73
61
|
"cookie": "^1.0.2",
|
|
74
62
|
"rou3": "^0.7.7",
|
|
75
63
|
"zod": "^4.1.12",
|
|
76
|
-
"@temporary-name/contract": "1.9.3-alpha.
|
|
77
|
-
"@temporary-name/
|
|
78
|
-
"@temporary-name/
|
|
79
|
-
"@temporary-name/
|
|
80
|
-
"@temporary-name/
|
|
81
|
-
"@temporary-name/standard-server-
|
|
82
|
-
"@temporary-name/
|
|
83
|
-
"@temporary-name/
|
|
84
|
-
"@temporary-name/standard-server
|
|
64
|
+
"@temporary-name/contract": "1.9.3-alpha.c13915862ce0feb161cb37a7c0da5ab7d57bd1bf",
|
|
65
|
+
"@temporary-name/json-schema": "1.9.3-alpha.c13915862ce0feb161cb37a7c0da5ab7d57bd1bf",
|
|
66
|
+
"@temporary-name/shared": "1.9.3-alpha.c13915862ce0feb161cb37a7c0da5ab7d57bd1bf",
|
|
67
|
+
"@temporary-name/standard-server-fetch": "1.9.3-alpha.c13915862ce0feb161cb37a7c0da5ab7d57bd1bf",
|
|
68
|
+
"@temporary-name/interop": "1.9.3-alpha.c13915862ce0feb161cb37a7c0da5ab7d57bd1bf",
|
|
69
|
+
"@temporary-name/standard-server-node": "1.9.3-alpha.c13915862ce0feb161cb37a7c0da5ab7d57bd1bf",
|
|
70
|
+
"@temporary-name/zod": "1.9.3-alpha.c13915862ce0feb161cb37a7c0da5ab7d57bd1bf",
|
|
71
|
+
"@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.c13915862ce0feb161cb37a7c0da5ab7d57bd1bf",
|
|
72
|
+
"@temporary-name/standard-server": "1.9.3-alpha.c13915862ce0feb161cb37a7c0da5ab7d57bd1bf"
|
|
85
73
|
},
|
|
86
74
|
"devDependencies": {
|
|
87
75
|
"@types/supertest": "^6.0.3",
|