@temporary-name/server 1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36 → 1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f
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.d.mts +3 -4
- package/dist/adapters/aws-lambda/index.d.ts +3 -4
- package/dist/adapters/aws-lambda/index.mjs +3 -3
- package/dist/adapters/fetch/index.d.mts +3 -4
- package/dist/adapters/fetch/index.d.ts +3 -4
- package/dist/adapters/fetch/index.mjs +3 -3
- package/dist/adapters/node/index.d.mts +3 -4
- package/dist/adapters/node/index.d.ts +3 -4
- package/dist/adapters/node/index.mjs +3 -3
- package/dist/adapters/standard/index.d.mts +10 -6
- package/dist/adapters/standard/index.d.ts +10 -6
- package/dist/adapters/standard/index.mjs +4 -4
- package/dist/helpers/index.mjs +3 -29
- package/dist/index.d.mts +73 -126
- package/dist/index.d.ts +73 -126
- package/dist/index.mjs +125 -234
- package/dist/openapi/index.d.mts +4 -4
- package/dist/openapi/index.d.ts +4 -4
- package/dist/openapi/index.mjs +61 -128
- package/dist/plugins/index.d.mts +5 -83
- package/dist/plugins/index.d.ts +5 -83
- package/dist/plugins/index.mjs +17 -189
- package/dist/shared/{server.Bk5r0-2R.d.ts → server.25yUS-xw.d.mts} +3 -4
- package/dist/shared/{server.Bs6ka_UE.d.mts → server.BKwU5-Ea.d.mts} +2 -2
- package/dist/shared/server.C1RJffw4.mjs +30 -0
- package/dist/shared/{server.CbLTWfgn.d.mts → server.Co-zpS8Y.d.ts} +3 -4
- package/dist/shared/{server.BVxcyR6X.mjs → server.DRYRuXpK.mjs} +17 -50
- package/dist/shared/{server.D2UFMrxf.d.ts → server.DV_PWBS2.d.ts} +2 -2
- package/dist/shared/server.DWEp52Gx.mjs +379 -0
- package/dist/shared/{server.BEHw7Eyx.mjs → server.JtIZ8YG7.mjs} +1 -11
- package/dist/shared/server.VtI8pLxV.d.mts +242 -0
- package/dist/shared/server.VtI8pLxV.d.ts +242 -0
- package/package.json +10 -22
- package/dist/shared/server.CZNLCQBm.d.mts +0 -192
- package/dist/shared/server.CZNLCQBm.d.ts +0 -192
- package/dist/shared/server.DcfsPloY.mjs +0 -202
package/dist/openapi/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isProcedure, resolveContractProcedures, ORPCError, createRouterClient } from '@temporary-name/server';
|
|
2
|
-
import { fallbackContractConfig, getEventIteratorSchemaDetails } from '@temporary-name/contract';
|
|
3
|
-
import { isObject, stringifyJSON, findDeepMatches, toArray, clone, value, toHttpPath, isORPCErrorStatus,
|
|
4
|
-
import {
|
|
2
|
+
import { standardizeHTTPPath, fallbackContractConfig, getDynamicParams, getEventIteratorSchemaDetails } from '@temporary-name/contract';
|
|
3
|
+
import { isObject, stringifyJSON, findDeepMatches, toArray, clone, value, toHttpPath, isORPCErrorStatus, resolveMaybeOptionalOptions, createORPCErrorFromJson } from '@temporary-name/shared';
|
|
4
|
+
import { j as jsonSerialize, d as deserialize, s as serialize } from '../shared/server.JtIZ8YG7.mjs';
|
|
5
5
|
import '@temporary-name/standard-server';
|
|
6
6
|
import { TypeName } from '@temporary-name/interop/json-schema-typed/draft-2020-12';
|
|
7
7
|
export { ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from '@temporary-name/interop/json-schema-typed/draft-2020-12';
|
|
@@ -22,12 +22,6 @@ function getCustomOpenAPIOperation(o) {
|
|
|
22
22
|
}
|
|
23
23
|
function applyCustomOpenAPIOperation(operation, contract) {
|
|
24
24
|
const operationCustoms = [];
|
|
25
|
-
for (const errorItem of Object.values(contract["~orpc"].errorMap)) {
|
|
26
|
-
const maybeExtender = errorItem ? getCustomOpenAPIOperation(errorItem) : void 0;
|
|
27
|
-
if (maybeExtender) {
|
|
28
|
-
operationCustoms.push(maybeExtender);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
25
|
if (isProcedure(contract)) {
|
|
32
26
|
for (const middleware of contract["~orpc"].middlewares) {
|
|
33
27
|
const maybeExtender = getCustomOpenAPIOperation(middleware);
|
|
@@ -432,12 +426,6 @@ class OpenAPIGenerator {
|
|
|
432
426
|
};
|
|
433
427
|
await this.#request(doc, operationObjectRef, def, baseSchemaConvertOptions);
|
|
434
428
|
await this.#successResponse(doc, operationObjectRef, def, baseSchemaConvertOptions);
|
|
435
|
-
await this.#errorResponse(
|
|
436
|
-
operationObjectRef,
|
|
437
|
-
def,
|
|
438
|
-
baseSchemaConvertOptions,
|
|
439
|
-
undefinedErrorJsonSchema
|
|
440
|
-
);
|
|
441
429
|
}
|
|
442
430
|
if (typeof def.route.spec === "function") {
|
|
443
431
|
operationObjectRef = def.route.spec(operationObjectRef);
|
|
@@ -530,94 +518,77 @@ ${errors.join("\n\n")}`
|
|
|
530
518
|
}
|
|
531
519
|
async #request(doc, ref, def, baseSchemaConvertOptions) {
|
|
532
520
|
const method = fallbackContractConfig("defaultMethod", def.route.method);
|
|
533
|
-
const details = getEventIteratorSchemaDetails(def.inputSchema);
|
|
534
|
-
if (details) {
|
|
535
|
-
ref.requestBody = {
|
|
536
|
-
required: true,
|
|
537
|
-
content: toOpenAPIEventIteratorContent(
|
|
538
|
-
await this.converter.convert(details.yields, { ...baseSchemaConvertOptions, strategy: "input" }),
|
|
539
|
-
await this.converter.convert(details.returns, { ...baseSchemaConvertOptions, strategy: "input" })
|
|
540
|
-
)
|
|
541
|
-
};
|
|
542
|
-
return;
|
|
543
|
-
}
|
|
544
521
|
const dynamicParams = getDynamicParams(def.route.path)?.map((v) => v.name);
|
|
545
|
-
const
|
|
546
|
-
let [required, schema] = await this.converter.convert(def.inputSchema, {
|
|
522
|
+
const [_pathRequired, pathSchema] = await this.converter.convert(def.schemas.pathSchema, {
|
|
547
523
|
...baseSchemaConvertOptions,
|
|
548
524
|
strategy: "input",
|
|
549
|
-
minStructureDepthForRef:
|
|
525
|
+
minStructureDepthForRef: 1
|
|
550
526
|
});
|
|
551
|
-
if (
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
);
|
|
559
|
-
if (!isObjectSchema(schema)) {
|
|
560
|
-
throw error2;
|
|
561
|
-
}
|
|
562
|
-
const [paramsSchema, rest] = separateObjectSchema(schema, dynamicParams);
|
|
563
|
-
schema = rest;
|
|
564
|
-
required = rest.required ? rest.required.length !== 0 : false;
|
|
565
|
-
if (!checkParamsSchema(paramsSchema, dynamicParams)) {
|
|
566
|
-
throw error2;
|
|
567
|
-
}
|
|
568
|
-
ref.parameters ??= [];
|
|
569
|
-
ref.parameters.push(...toOpenAPIParameters(paramsSchema, "path"));
|
|
527
|
+
if (dynamicParams?.length) {
|
|
528
|
+
const error = new OpenAPIGeneratorError(
|
|
529
|
+
// TODO: fix this error
|
|
530
|
+
'When input structure is "compact", and path has dynamic params, input schema must be an object with all dynamic params as required.'
|
|
531
|
+
);
|
|
532
|
+
if (!isObjectSchema(pathSchema)) {
|
|
533
|
+
throw error;
|
|
570
534
|
}
|
|
571
|
-
if (
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
535
|
+
if (!checkParamsSchema(pathSchema, dynamicParams)) {
|
|
536
|
+
throw error;
|
|
537
|
+
}
|
|
538
|
+
ref.parameters ??= [];
|
|
539
|
+
ref.parameters.push(...toOpenAPIParameters(pathSchema, "path"));
|
|
540
|
+
} else {
|
|
541
|
+
const error = new OpenAPIGeneratorError("Params set via path do not match those on the route");
|
|
542
|
+
if (!isObjectSchema(pathSchema)) {
|
|
543
|
+
console.log("FOO", pathSchema);
|
|
544
|
+
throw error;
|
|
545
|
+
}
|
|
546
|
+
if (!checkParamsSchema(pathSchema, [])) {
|
|
547
|
+
console.log("BAR", pathSchema);
|
|
548
|
+
throw error;
|
|
585
549
|
}
|
|
586
|
-
return;
|
|
587
|
-
}
|
|
588
|
-
const error = new OpenAPIGeneratorError(
|
|
589
|
-
'When input structure is "detailed", input schema must satisfy: { params?: Record<string, unknown>, query?: Record<string, unknown>, headers?: Record<string, unknown>, body?: unknown }'
|
|
590
|
-
);
|
|
591
|
-
if (!isObjectSchema(schema)) {
|
|
592
|
-
throw error;
|
|
593
550
|
}
|
|
594
|
-
const
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
551
|
+
const [_queryRequired, querySchema] = await this.converter.convert(def.schemas.querySchema, {
|
|
552
|
+
...baseSchemaConvertOptions,
|
|
553
|
+
strategy: "input",
|
|
554
|
+
minStructureDepthForRef: 0
|
|
555
|
+
});
|
|
556
|
+
if (!isAnySchema(querySchema)) {
|
|
557
|
+
const resolvedSchema = resolveOpenAPIJsonSchemaRef(doc, querySchema);
|
|
558
|
+
if (!isObjectSchema(resolvedSchema)) {
|
|
559
|
+
throw new OpenAPIGeneratorError("Query param schema must satisfy: object | any | unknown");
|
|
560
|
+
}
|
|
561
|
+
ref.parameters ??= [];
|
|
562
|
+
ref.parameters.push(...toOpenAPIParameters(resolvedSchema, "query"));
|
|
599
563
|
}
|
|
600
|
-
|
|
601
|
-
const
|
|
602
|
-
if (
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
564
|
+
if (method !== "GET") {
|
|
565
|
+
const details = getEventIteratorSchemaDetails(def.schemas.bodySchema);
|
|
566
|
+
if (details) {
|
|
567
|
+
ref.requestBody = {
|
|
568
|
+
required: true,
|
|
569
|
+
content: toOpenAPIEventIteratorContent(
|
|
570
|
+
await this.converter.convert(details.yields, { ...baseSchemaConvertOptions, strategy: "input" }),
|
|
571
|
+
await this.converter.convert(details.returns, { ...baseSchemaConvertOptions, strategy: "input" })
|
|
572
|
+
)
|
|
573
|
+
};
|
|
574
|
+
} else {
|
|
575
|
+
const [bodyRequired, bodySchema] = await this.converter.convert(def.schemas.bodySchema, {
|
|
576
|
+
...baseSchemaConvertOptions,
|
|
577
|
+
strategy: "input",
|
|
578
|
+
minStructureDepthForRef: 0
|
|
579
|
+
});
|
|
580
|
+
if (isAnySchema(bodySchema)) {
|
|
581
|
+
return;
|
|
606
582
|
}
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
583
|
+
ref.requestBody = {
|
|
584
|
+
required: bodyRequired,
|
|
585
|
+
content: toOpenAPIContent(bodySchema)
|
|
586
|
+
};
|
|
610
587
|
}
|
|
611
588
|
}
|
|
612
|
-
if (schema.properties?.body !== void 0) {
|
|
613
|
-
ref.requestBody = {
|
|
614
|
-
required: schema.required?.includes("body"),
|
|
615
|
-
content: toOpenAPIContent(schema.properties.body)
|
|
616
|
-
};
|
|
617
|
-
}
|
|
618
589
|
}
|
|
619
590
|
async #successResponse(doc, ref, def, baseSchemaConvertOptions) {
|
|
620
|
-
const outputSchema = def.outputSchema;
|
|
591
|
+
const outputSchema = def.schemas.outputSchema;
|
|
621
592
|
const status = fallbackContractConfig("defaultSuccessStatus", def.route.successStatus);
|
|
622
593
|
const description = fallbackContractConfig("defaultSuccessDescription", def.route?.successDescription);
|
|
623
594
|
const eventIteratorSchemaDetails = getEventIteratorSchemaDetails(outputSchema);
|
|
@@ -713,44 +684,6 @@ ${errors.join("\n\n")}`
|
|
|
713
684
|
}
|
|
714
685
|
}
|
|
715
686
|
}
|
|
716
|
-
async #errorResponse(ref, def, baseSchemaConvertOptions, undefinedErrorSchema) {
|
|
717
|
-
const errorMap = def.errorMap;
|
|
718
|
-
const errors = {};
|
|
719
|
-
for (const code in errorMap) {
|
|
720
|
-
const config = errorMap[code];
|
|
721
|
-
if (!config) {
|
|
722
|
-
continue;
|
|
723
|
-
}
|
|
724
|
-
const status = fallbackORPCErrorStatus(code, config.status);
|
|
725
|
-
const message = fallbackORPCErrorMessage(code, config.message);
|
|
726
|
-
const [dataRequired, dataSchema] = await this.converter.convert(config.data, {
|
|
727
|
-
...baseSchemaConvertOptions,
|
|
728
|
-
strategy: "output"
|
|
729
|
-
});
|
|
730
|
-
errors[status] ??= [];
|
|
731
|
-
errors[status].push({
|
|
732
|
-
type: "object",
|
|
733
|
-
properties: {
|
|
734
|
-
defined: { const: true },
|
|
735
|
-
code: { const: code },
|
|
736
|
-
status: { const: status },
|
|
737
|
-
message: { type: "string", default: message },
|
|
738
|
-
data: dataSchema
|
|
739
|
-
},
|
|
740
|
-
required: dataRequired ? ["defined", "code", "status", "message", "data"] : ["defined", "code", "status", "message"]
|
|
741
|
-
});
|
|
742
|
-
}
|
|
743
|
-
ref.responses ??= {};
|
|
744
|
-
for (const status in errors) {
|
|
745
|
-
const schemas = errors[status];
|
|
746
|
-
ref.responses[status] = {
|
|
747
|
-
description: status,
|
|
748
|
-
content: toOpenAPIContent({
|
|
749
|
-
oneOf: [...schemas, undefinedErrorSchema]
|
|
750
|
-
})
|
|
751
|
-
};
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
687
|
}
|
|
755
688
|
|
|
756
689
|
function createJsonifiedRouterClient(router, ...rest) {
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,58 +1,8 @@
|
|
|
1
1
|
import { Value, Promisable, ORPCError } from '@temporary-name/shared';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.CbLTWfgn.mjs';
|
|
5
|
-
import { C as Context, E as ProcedureClientInterceptorOptions } from '../shared/server.CZNLCQBm.mjs';
|
|
2
|
+
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.25yUS-xw.mjs';
|
|
3
|
+
import { C as Context, H as ProcedureClientInterceptorOptions } from '../shared/server.VtI8pLxV.mjs';
|
|
6
4
|
import { Meta } from '@temporary-name/contract';
|
|
7
5
|
|
|
8
|
-
interface BatchHandlerOptions<T extends Context> {
|
|
9
|
-
/**
|
|
10
|
-
* The max size of the batch allowed.
|
|
11
|
-
*
|
|
12
|
-
* @default 10
|
|
13
|
-
*/
|
|
14
|
-
maxSize?: Value<Promisable<number>, [StandardHandlerInterceptorOptions<T>]>;
|
|
15
|
-
/**
|
|
16
|
-
* Map the request before processing it.
|
|
17
|
-
*
|
|
18
|
-
* @default merged back batch request headers into the request
|
|
19
|
-
*/
|
|
20
|
-
mapRequestItem?(request: StandardRequest, batchOptions: StandardHandlerInterceptorOptions<T>): StandardRequest;
|
|
21
|
-
/**
|
|
22
|
-
* Success batch response status code.
|
|
23
|
-
*
|
|
24
|
-
* @default 207
|
|
25
|
-
*/
|
|
26
|
-
successStatus?: Value<Promisable<number>, [
|
|
27
|
-
responses: Promise<BatchResponseBodyItem>[],
|
|
28
|
-
batchOptions: StandardHandlerInterceptorOptions<T>
|
|
29
|
-
]>;
|
|
30
|
-
/**
|
|
31
|
-
* success batch response headers.
|
|
32
|
-
*
|
|
33
|
-
* @default {}
|
|
34
|
-
*/
|
|
35
|
-
headers?: Value<Promisable<StandardHeaders>, [
|
|
36
|
-
responses: Promise<BatchResponseBodyItem>[],
|
|
37
|
-
batchOptions: StandardHandlerInterceptorOptions<T>
|
|
38
|
-
]>;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* The Batch Requests Plugin allows you to combine multiple requests and responses into a single batch,
|
|
42
|
-
* reducing the overhead of sending each one separately.
|
|
43
|
-
*
|
|
44
|
-
* @see {@link https://orpc.unnoq.com/docs/plugins/batch-requests Batch Requests Plugin Docs}
|
|
45
|
-
*/
|
|
46
|
-
declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
47
|
-
private readonly maxSize;
|
|
48
|
-
private readonly mapRequestItem;
|
|
49
|
-
private readonly successStatus;
|
|
50
|
-
private readonly headers;
|
|
51
|
-
order: number;
|
|
52
|
-
constructor(options?: BatchHandlerOptions<T>);
|
|
53
|
-
init(options: StandardHandlerOptions<T>): void;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
6
|
interface CORSOptions<T extends Context> {
|
|
57
7
|
origin?: Value<Promisable<string | readonly string[] | null | undefined>, [
|
|
58
8
|
origin: string,
|
|
@@ -80,32 +30,6 @@ declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T>
|
|
|
80
30
|
init(options: StandardHandlerOptions<T>): void;
|
|
81
31
|
}
|
|
82
32
|
|
|
83
|
-
interface RequestHeadersPluginContext {
|
|
84
|
-
reqHeaders?: Headers;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* The Request Headers Plugin injects a `reqHeaders` instance into the context,
|
|
88
|
-
* allowing access to request headers in oRPC.
|
|
89
|
-
*
|
|
90
|
-
* @see {@link https://orpc.unnoq.com/docs/plugins/request-headers Request Headers Plugin Docs}
|
|
91
|
-
*/
|
|
92
|
-
declare class RequestHeadersPlugin<T extends RequestHeadersPluginContext> implements StandardHandlerPlugin<T> {
|
|
93
|
-
init(options: StandardHandlerOptions<T>): void;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
interface ResponseHeadersPluginContext {
|
|
97
|
-
resHeaders?: Headers;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* The Response Headers Plugin allows you to set response headers in oRPC.
|
|
101
|
-
* It injects a resHeaders instance into the context, enabling you to modify response headers easily.
|
|
102
|
-
*
|
|
103
|
-
* @see {@link https://orpc.unnoq.com/docs/plugins/response-headers Response Headers Plugin Docs}
|
|
104
|
-
*/
|
|
105
|
-
declare class ResponseHeadersPlugin<T extends ResponseHeadersPluginContext> implements StandardHandlerPlugin<T> {
|
|
106
|
-
init(options: StandardHandlerOptions<T>): void;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
33
|
interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
|
|
110
34
|
/**
|
|
111
35
|
* The name of the header to check.
|
|
@@ -126,9 +50,7 @@ interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
|
|
|
126
50
|
* @default false
|
|
127
51
|
*
|
|
128
52
|
*/
|
|
129
|
-
exclude?: Value<Promisable<boolean>, [
|
|
130
|
-
options: ProcedureClientInterceptorOptions<T, Record<never, never>, Meta>
|
|
131
|
-
]>;
|
|
53
|
+
exclude?: Value<Promisable<boolean>, [options: ProcedureClientInterceptorOptions<T, Meta>]>;
|
|
132
54
|
/**
|
|
133
55
|
* The error thrown when the CSRF token is invalid.
|
|
134
56
|
*
|
|
@@ -156,5 +78,5 @@ declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements St
|
|
|
156
78
|
init(options: StandardHandlerOptions<T>): void;
|
|
157
79
|
}
|
|
158
80
|
|
|
159
|
-
export {
|
|
160
|
-
export type {
|
|
81
|
+
export { CORSPlugin, SimpleCsrfProtectionHandlerPlugin };
|
|
82
|
+
export type { CORSOptions, SimpleCsrfProtectionHandlerPluginOptions };
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,58 +1,8 @@
|
|
|
1
1
|
import { Value, Promisable, ORPCError } from '@temporary-name/shared';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.Bk5r0-2R.js';
|
|
5
|
-
import { C as Context, E as ProcedureClientInterceptorOptions } from '../shared/server.CZNLCQBm.js';
|
|
2
|
+
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.Co-zpS8Y.js';
|
|
3
|
+
import { C as Context, H as ProcedureClientInterceptorOptions } from '../shared/server.VtI8pLxV.js';
|
|
6
4
|
import { Meta } from '@temporary-name/contract';
|
|
7
5
|
|
|
8
|
-
interface BatchHandlerOptions<T extends Context> {
|
|
9
|
-
/**
|
|
10
|
-
* The max size of the batch allowed.
|
|
11
|
-
*
|
|
12
|
-
* @default 10
|
|
13
|
-
*/
|
|
14
|
-
maxSize?: Value<Promisable<number>, [StandardHandlerInterceptorOptions<T>]>;
|
|
15
|
-
/**
|
|
16
|
-
* Map the request before processing it.
|
|
17
|
-
*
|
|
18
|
-
* @default merged back batch request headers into the request
|
|
19
|
-
*/
|
|
20
|
-
mapRequestItem?(request: StandardRequest, batchOptions: StandardHandlerInterceptorOptions<T>): StandardRequest;
|
|
21
|
-
/**
|
|
22
|
-
* Success batch response status code.
|
|
23
|
-
*
|
|
24
|
-
* @default 207
|
|
25
|
-
*/
|
|
26
|
-
successStatus?: Value<Promisable<number>, [
|
|
27
|
-
responses: Promise<BatchResponseBodyItem>[],
|
|
28
|
-
batchOptions: StandardHandlerInterceptorOptions<T>
|
|
29
|
-
]>;
|
|
30
|
-
/**
|
|
31
|
-
* success batch response headers.
|
|
32
|
-
*
|
|
33
|
-
* @default {}
|
|
34
|
-
*/
|
|
35
|
-
headers?: Value<Promisable<StandardHeaders>, [
|
|
36
|
-
responses: Promise<BatchResponseBodyItem>[],
|
|
37
|
-
batchOptions: StandardHandlerInterceptorOptions<T>
|
|
38
|
-
]>;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* The Batch Requests Plugin allows you to combine multiple requests and responses into a single batch,
|
|
42
|
-
* reducing the overhead of sending each one separately.
|
|
43
|
-
*
|
|
44
|
-
* @see {@link https://orpc.unnoq.com/docs/plugins/batch-requests Batch Requests Plugin Docs}
|
|
45
|
-
*/
|
|
46
|
-
declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
47
|
-
private readonly maxSize;
|
|
48
|
-
private readonly mapRequestItem;
|
|
49
|
-
private readonly successStatus;
|
|
50
|
-
private readonly headers;
|
|
51
|
-
order: number;
|
|
52
|
-
constructor(options?: BatchHandlerOptions<T>);
|
|
53
|
-
init(options: StandardHandlerOptions<T>): void;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
6
|
interface CORSOptions<T extends Context> {
|
|
57
7
|
origin?: Value<Promisable<string | readonly string[] | null | undefined>, [
|
|
58
8
|
origin: string,
|
|
@@ -80,32 +30,6 @@ declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T>
|
|
|
80
30
|
init(options: StandardHandlerOptions<T>): void;
|
|
81
31
|
}
|
|
82
32
|
|
|
83
|
-
interface RequestHeadersPluginContext {
|
|
84
|
-
reqHeaders?: Headers;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* The Request Headers Plugin injects a `reqHeaders` instance into the context,
|
|
88
|
-
* allowing access to request headers in oRPC.
|
|
89
|
-
*
|
|
90
|
-
* @see {@link https://orpc.unnoq.com/docs/plugins/request-headers Request Headers Plugin Docs}
|
|
91
|
-
*/
|
|
92
|
-
declare class RequestHeadersPlugin<T extends RequestHeadersPluginContext> implements StandardHandlerPlugin<T> {
|
|
93
|
-
init(options: StandardHandlerOptions<T>): void;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
interface ResponseHeadersPluginContext {
|
|
97
|
-
resHeaders?: Headers;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* The Response Headers Plugin allows you to set response headers in oRPC.
|
|
101
|
-
* It injects a resHeaders instance into the context, enabling you to modify response headers easily.
|
|
102
|
-
*
|
|
103
|
-
* @see {@link https://orpc.unnoq.com/docs/plugins/response-headers Response Headers Plugin Docs}
|
|
104
|
-
*/
|
|
105
|
-
declare class ResponseHeadersPlugin<T extends ResponseHeadersPluginContext> implements StandardHandlerPlugin<T> {
|
|
106
|
-
init(options: StandardHandlerOptions<T>): void;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
33
|
interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
|
|
110
34
|
/**
|
|
111
35
|
* The name of the header to check.
|
|
@@ -126,9 +50,7 @@ interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
|
|
|
126
50
|
* @default false
|
|
127
51
|
*
|
|
128
52
|
*/
|
|
129
|
-
exclude?: Value<Promisable<boolean>, [
|
|
130
|
-
options: ProcedureClientInterceptorOptions<T, Record<never, never>, Meta>
|
|
131
|
-
]>;
|
|
53
|
+
exclude?: Value<Promisable<boolean>, [options: ProcedureClientInterceptorOptions<T, Meta>]>;
|
|
132
54
|
/**
|
|
133
55
|
* The error thrown when the CSRF token is invalid.
|
|
134
56
|
*
|
|
@@ -156,5 +78,5 @@ declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements St
|
|
|
156
78
|
init(options: StandardHandlerOptions<T>): void;
|
|
157
79
|
}
|
|
158
80
|
|
|
159
|
-
export {
|
|
160
|
-
export type {
|
|
81
|
+
export { CORSPlugin, SimpleCsrfProtectionHandlerPlugin };
|
|
82
|
+
export type { CORSOptions, SimpleCsrfProtectionHandlerPluginOptions };
|