@temporary-name/server 1.9.3-alpha.5c041722542bb790586629fc98d4c72d9f6ee65e → 1.9.3-alpha.5dc8b200530586870ac736830d4584e0333cfd05

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 +3 -4
  2. package/dist/adapters/aws-lambda/index.d.ts +3 -4
  3. package/dist/adapters/aws-lambda/index.mjs +3 -3
  4. package/dist/adapters/fetch/index.d.mts +3 -4
  5. package/dist/adapters/fetch/index.d.ts +3 -4
  6. package/dist/adapters/fetch/index.mjs +3 -3
  7. package/dist/adapters/node/index.d.mts +3 -4
  8. package/dist/adapters/node/index.d.ts +3 -4
  9. package/dist/adapters/node/index.mjs +3 -3
  10. package/dist/adapters/standard/index.d.mts +10 -6
  11. package/dist/adapters/standard/index.d.ts +10 -6
  12. package/dist/adapters/standard/index.mjs +4 -4
  13. package/dist/helpers/index.mjs +3 -29
  14. package/dist/index.d.mts +29 -23
  15. package/dist/index.d.ts +29 -23
  16. package/dist/index.mjs +121 -15
  17. package/dist/openapi/index.d.mts +1 -1
  18. package/dist/openapi/index.d.ts +1 -1
  19. package/dist/openapi/index.mjs +51 -34
  20. package/dist/plugins/index.d.mts +4 -80
  21. package/dist/plugins/index.d.ts +4 -80
  22. package/dist/plugins/index.mjs +17 -189
  23. package/dist/shared/{server.C4l2ZA3m.d.ts → server.B-meye9-.d.ts} +2 -3
  24. package/dist/shared/{server.SmOM3Fae.mjs → server.Ba0Z2fNc.mjs} +18 -26
  25. package/dist/shared/server.C1RJffw4.mjs +30 -0
  26. package/dist/shared/{server.B5czSQQh.d.mts → server.DkYpsO6W.d.mts} +71 -55
  27. package/dist/shared/{server.B5czSQQh.d.ts → server.DkYpsO6W.d.ts} +71 -55
  28. package/dist/shared/{server.D7UjcuIv.d.ts → server.DwNnHUZP.d.ts} +2 -2
  29. package/dist/shared/{server.Bk8Hmx7Z.d.mts → server.I-tTl_ce.d.mts} +2 -2
  30. package/dist/shared/{server.Kxw442A9.mjs → server.JtIZ8YG7.mjs} +1 -11
  31. package/dist/shared/{server.BdGbIyq8.mjs → server.miXh-9wo.mjs} +38 -18
  32. package/dist/shared/{server.TgmlNh8r.d.mts → server.vLcMd_kA.d.mts} +2 -3
  33. package/package.json +10 -22
package/dist/index.mjs CHANGED
@@ -1,11 +1,64 @@
1
- import { mergePrefix, mergeTags, ContractProcedure, mergeErrorMap, mergeMeta, mergeRoute, prefixRoute, initialSchemas, isContractProcedure, getContractRouter } from '@temporary-name/contract';
1
+ import { mergePrefix, mergeTags, ContractProcedure, mergeErrorMap, mergeMeta, parseEndpointDefinition, mergeRoute, prefixRoute, initialSchemas, isContractProcedure, getContractRouter } from '@temporary-name/contract';
2
2
  export { ValidationError, eventIterator, validateORPCError } from '@temporary-name/contract';
3
- import { onError, resolveMaybeOptionalOptions } from '@temporary-name/shared';
3
+ import { assertNever, splitFirst, ORPCError, 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
- import { SchemaClass, 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.BdGbIyq8.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.BdGbIyq8.mjs';
5
+ import { SchemaClass, object, core, gatingContext } from '@temporary-name/zod';
6
+ import { g as getCookie } from './shared/server.C1RJffw4.mjs';
7
+ 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.miXh-9wo.mjs';
8
+ 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.miXh-9wo.mjs';
8
9
  export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
10
+ import 'cookie';
11
+
12
+ function validateTokenPrefix(prefix, token) {
13
+ if (prefix && !token.startsWith(prefix)) {
14
+ throw new ORPCError("UNAUTHORIZED", { message: `Invalid auth token. It must start with "${prefix}"` });
15
+ }
16
+ }
17
+ function validateTokenAuth(config, token, options) {
18
+ const { tokenPrefix, validate } = config;
19
+ validateTokenPrefix(tokenPrefix, token);
20
+ return validate(token, options);
21
+ }
22
+ function authByQuery(config, options) {
23
+ const { name, tokenPrefix, validate } = config;
24
+ const query = options.request.url.searchParams;
25
+ const token = query.get(name);
26
+ if (!token) return void 0;
27
+ validateTokenPrefix(tokenPrefix, token);
28
+ return validate(token, options);
29
+ }
30
+ function authByHeader(config, options) {
31
+ const authHeader = options.request.headers.get(config.name);
32
+ return authHeader ? validateTokenAuth(config, authHeader, options) : void 0;
33
+ }
34
+ function authByCookie(config, options) {
35
+ const cookie = getCookie(options.request.headers, config.name);
36
+ return cookie ? validateTokenAuth(config, cookie, options) : void 0;
37
+ }
38
+ function authByBearer(config, options) {
39
+ const authHeader = options.request.headers.get("Authorization");
40
+ if (!authHeader) return void 0;
41
+ const [authType, bearer] = splitFirst(authHeader, " ");
42
+ return authType === "Bearer" ? validateTokenAuth(config, bearer, options) : void 0;
43
+ }
44
+ function authByBasic(config, options) {
45
+ const authHeader = options.request.headers.get("Authorization");
46
+ if (!authHeader) return void 0;
47
+ const [authType, encoded] = splitFirst(authHeader, " ");
48
+ if (authType !== "Basic") return void 0;
49
+ const decoded = Buffer.from(encoded, "base64").toString("utf-8");
50
+ const [username, password] = splitFirst(decoded, ":");
51
+ validateTokenPrefix(config.tokenPrefix, password);
52
+ return config.validate(username, password, options);
53
+ }
54
+ function authByType(config, options) {
55
+ const { type } = config;
56
+ return type === "header" ? authByHeader(config, options) : type === "query" ? authByQuery(config, options) : type === "cookie" ? authByCookie(config, options) : type === "bearer" ? authByBearer(config, options) : type === "basic" ? authByBasic(config, options) : type === "none" ? false : assertNever(type);
57
+ }
58
+ function authDescription(config) {
59
+ const { type } = config;
60
+ return type === "basic" ? "a Basic Authentication header" : type === "bearer" ? "a Bearer Authentication header" : type === "header" ? `a header named "${config.name}"` : type === "query" ? `a query parameter named "${config.name}"` : type === "cookie" ? `a cookie named "${config.name}"` : type === "none" ? "no authentication" : assertNever(type);
61
+ }
9
62
 
10
63
  class DecoratedProcedure extends Procedure {
11
64
  /**
@@ -56,6 +109,19 @@ class ProcedureBuilder extends ContractProcedure {
56
109
  meta: mergeMeta(this["~orpc"].meta, meta)
57
110
  });
58
111
  }
112
+ endpoint(stringsOrEndpoint, ...values) {
113
+ const { method, path, pathSchema } = parseEndpointDefinition(stringsOrEndpoint, values);
114
+ const { prefix } = this["~orpc"];
115
+ const route = { method, path };
116
+ return new ProcedureBuilder({
117
+ ...this["~orpc"],
118
+ route: mergeRoute(this["~orpc"].route, prefix ? prefixRoute(route, prefix) : route),
119
+ schemas: {
120
+ ...this["~orpc"].schemas,
121
+ pathSchema
122
+ }
123
+ });
124
+ }
59
125
  /**
60
126
  * Sets or updates the route definition for the contract.
61
127
  * The provided route is spared-merged with any existing route in the contract.
@@ -64,24 +130,29 @@ class ProcedureBuilder extends ContractProcedure {
64
130
  * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
65
131
  * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
66
132
  */
67
- route(route) {
133
+ endpointOpts(route) {
68
134
  const { prefix } = this["~orpc"];
69
135
  return new ProcedureBuilder({
70
136
  ...this["~orpc"],
71
137
  route: mergeRoute(this["~orpc"].route, prefix ? prefixRoute(route, prefix) : route)
72
138
  });
73
139
  }
74
- /**
75
- * Defines the input validation schema.
76
- *
77
- * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
78
- */
79
- input(schema) {
140
+ query(schema) {
141
+ return new ProcedureBuilder({
142
+ ...this["~orpc"],
143
+ schemas: {
144
+ ...this["~orpc"].schemas,
145
+ querySchema: schema instanceof core.$ZodType ? schema : object(schema)
146
+ },
147
+ inputValidationIndex: this["~orpc"].middlewares.length
148
+ });
149
+ }
150
+ body(schema) {
80
151
  return new ProcedureBuilder({
81
152
  ...this["~orpc"],
82
153
  schemas: {
83
154
  ...this["~orpc"].schemas,
84
- inputSchema: schema
155
+ bodySchema: schema instanceof core.$ZodType ? schema : object(schema)
85
156
  },
86
157
  inputValidationIndex: this["~orpc"].middlewares.length
87
158
  });
@@ -96,7 +167,7 @@ class ProcedureBuilder extends ContractProcedure {
96
167
  ...this["~orpc"],
97
168
  schemas: {
98
169
  ...this["~orpc"].schemas,
99
- outputSchema: schema
170
+ outputSchema: schema instanceof core.$ZodType ? schema : object(schema)
100
171
  },
101
172
  outputValidationIndex: this["~orpc"].middlewares.length
102
173
  });
@@ -114,6 +185,36 @@ class ProcedureBuilder extends ContractProcedure {
114
185
  middlewares: addMiddleware(this["~orpc"].middlewares, middleware)
115
186
  });
116
187
  }
188
+ // `& {}` is so AuthType will be expanded in parameter info tooltips.
189
+ // The default of false for ValidatedAuthContext is used when you pass in the type 'none'. We use false
190
+ // because we can't use null or undefined (see ValidatedAuthContext) but we still want it to be falsy.
191
+ useAuth(type, ...rest) {
192
+ const config = { type, ...rest[0] };
193
+ const middleware = os.$context().middleware(async (options) => {
194
+ const { next, context } = options;
195
+ if (context.auth) return next();
196
+ const auth = await authByType(config, options);
197
+ if (auth === void 0) {
198
+ const { authConfigs } = options.procedure["~orpc"];
199
+ if (context.auth !== false && config === authConfigs.at(-1)) {
200
+ let authDescriptions = authConfigs.map(authDescription).join(", ");
201
+ if (authConfigs.length > 1) {
202
+ authDescriptions = `one of: ${authDescriptions}`;
203
+ }
204
+ throw new ORPCError("UNAUTHORIZED", {
205
+ message: `Authentication required. You must provide ${authDescriptions}`
206
+ });
207
+ }
208
+ return next();
209
+ }
210
+ return next({ context: { auth } });
211
+ });
212
+ return new this.constructor({
213
+ ...this["~orpc"],
214
+ authConfigs: [...this["~orpc"].authConfigs, config],
215
+ middlewares: addMiddleware(this["~orpc"].middlewares, middleware)
216
+ });
217
+ }
117
218
  useGating(gates, isGateEnabled) {
118
219
  return this.use(({ next, context }) => {
119
220
  return gatingContext.run(
@@ -128,6 +229,9 @@ class ProcedureBuilder extends ContractProcedure {
128
229
  * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
129
230
  */
130
231
  handler(handler) {
232
+ if (this["~orpc"].schemas.outputSchema === initialSchemas.outputSchema) {
233
+ throw new Error("You must call .output() before calling .handler()");
234
+ }
131
235
  return new DecoratedProcedure({
132
236
  ...this["~orpc"],
133
237
  handler
@@ -240,7 +344,8 @@ function createApiBuilder(opts = {}) {
240
344
  schemas: initialSchemas,
241
345
  // NB: this is a relic from orpc -- I'm not convinced there's a need for this (or if there is, that it's
242
346
  // the best solution). For now I've removed the interface to configure it externally.
243
- dedupeLeadingMiddlewares: true
347
+ dedupeLeadingMiddlewares: true,
348
+ authConfigs: []
244
349
  });
245
350
  }
246
351
  const os = createApiBuilder();
@@ -250,6 +355,7 @@ function implementerInternal(contract, middlewares) {
250
355
  const impl2 = new Builder({
251
356
  ...contract["~orpc"],
252
357
  middlewares,
358
+ authConfigs: [],
253
359
  inputValidationIndex: middlewares.length,
254
360
  outputValidationIndex: middlewares.length,
255
361
  dedupeLeadingMiddlewares: true
@@ -55,7 +55,7 @@ interface SchemaConvertOptions {
55
55
  minStructureDepthForRef?: number;
56
56
  }
57
57
  interface SchemaConverter {
58
- convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
58
+ convert(schemas: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
59
59
  }
60
60
  interface ConditionalSchemaConverter extends SchemaConverter {
61
61
  condition(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<boolean>;
@@ -55,7 +55,7 @@ interface SchemaConvertOptions {
55
55
  minStructureDepthForRef?: number;
56
56
  }
57
57
  interface SchemaConverter {
58
- convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
58
+ convert(schemas: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
59
59
  }
60
60
  interface ConditionalSchemaConverter extends SchemaConverter {
61
61
  condition(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<boolean>;
@@ -1,7 +1,7 @@
1
1
  import { isProcedure, resolveContractProcedures, ORPCError, createRouterClient } from '@temporary-name/server';
2
- import { fallbackContractConfig, getEventIteratorSchemaDetails } from '@temporary-name/contract';
2
+ import { standardizeHTTPPath, fallbackContractConfig, getDynamicParams, getEventIteratorSchemaDetails } from '@temporary-name/contract';
3
3
  import { isObject, stringifyJSON, findDeepMatches, toArray, clone, value, toHttpPath, isORPCErrorStatus, fallbackORPCErrorStatus, fallbackORPCErrorMessage, resolveMaybeOptionalOptions, createORPCErrorFromJson } from '@temporary-name/shared';
4
- import { a as standardizeHTTPPath, j as jsonSerialize, g as getDynamicParams, d as deserialize, s as serialize } from '../shared/server.Kxw442A9.mjs';
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';
@@ -530,56 +530,73 @@ ${errors.join("\n\n")}`
530
530
  }
531
531
  async #request(doc, ref, def, baseSchemaConvertOptions) {
532
532
  const method = fallbackContractConfig("defaultMethod", def.route.method);
533
- const details = getEventIteratorSchemaDetails(def.schemas.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
533
  const dynamicParams = getDynamicParams(def.route.path)?.map((v) => v.name);
545
- let [required, schema] = await this.converter.convert(def.schemas.inputSchema, {
534
+ const [_pathRequired, pathSchema] = await this.converter.convert(def.schemas.pathSchema, {
546
535
  ...baseSchemaConvertOptions,
547
536
  strategy: "input",
548
- minStructureDepthForRef: dynamicParams?.length ? 1 : 0
537
+ minStructureDepthForRef: 1
549
538
  });
550
- if (isAnySchema(schema) && !dynamicParams?.length) {
551
- return;
552
- }
553
539
  if (dynamicParams?.length) {
554
540
  const error = new OpenAPIGeneratorError(
541
+ // TODO: fix this error
555
542
  'When input structure is "compact", and path has dynamic params, input schema must be an object with all dynamic params as required.'
556
543
  );
557
- if (!isObjectSchema(schema)) {
544
+ if (!isObjectSchema(pathSchema)) {
558
545
  throw error;
559
546
  }
560
- const [paramsSchema, rest] = separateObjectSchema(schema, dynamicParams);
561
- schema = rest;
562
- required = rest.required ? rest.required.length !== 0 : false;
563
- if (!checkParamsSchema(paramsSchema, dynamicParams)) {
547
+ if (!checkParamsSchema(pathSchema, dynamicParams)) {
564
548
  throw error;
565
549
  }
566
550
  ref.parameters ??= [];
567
- ref.parameters.push(...toOpenAPIParameters(paramsSchema, "path"));
551
+ ref.parameters.push(...toOpenAPIParameters(pathSchema, "path"));
552
+ } else {
553
+ const error = new OpenAPIGeneratorError("Params set via path do not match those on the route");
554
+ if (!isObjectSchema(pathSchema)) {
555
+ console.log("FOO", pathSchema);
556
+ throw error;
557
+ }
558
+ if (!checkParamsSchema(pathSchema, [])) {
559
+ console.log("BAR", pathSchema);
560
+ throw error;
561
+ }
568
562
  }
569
- if (method === "GET") {
570
- const resolvedSchema = resolveOpenAPIJsonSchemaRef(doc, schema);
563
+ const [_queryRequired, querySchema] = await this.converter.convert(def.schemas.querySchema, {
564
+ ...baseSchemaConvertOptions,
565
+ strategy: "input",
566
+ minStructureDepthForRef: 0
567
+ });
568
+ if (!isAnySchema(querySchema)) {
569
+ const resolvedSchema = resolveOpenAPIJsonSchemaRef(doc, querySchema);
571
570
  if (!isObjectSchema(resolvedSchema)) {
572
- throw new OpenAPIGeneratorError(
573
- 'When method is "GET", input schema must satisfy: object | any | unknown'
574
- );
571
+ throw new OpenAPIGeneratorError("Query param schema must satisfy: object | any | unknown");
575
572
  }
576
573
  ref.parameters ??= [];
577
574
  ref.parameters.push(...toOpenAPIParameters(resolvedSchema, "query"));
578
- } else {
579
- ref.requestBody = {
580
- required,
581
- content: toOpenAPIContent(schema)
582
- };
575
+ }
576
+ if (method !== "GET") {
577
+ const details = getEventIteratorSchemaDetails(def.schemas.bodySchema);
578
+ if (details) {
579
+ ref.requestBody = {
580
+ required: true,
581
+ content: toOpenAPIEventIteratorContent(
582
+ await this.converter.convert(details.yields, { ...baseSchemaConvertOptions, strategy: "input" }),
583
+ await this.converter.convert(details.returns, { ...baseSchemaConvertOptions, strategy: "input" })
584
+ )
585
+ };
586
+ } else {
587
+ const [bodyRequired, bodySchema] = await this.converter.convert(def.schemas.bodySchema, {
588
+ ...baseSchemaConvertOptions,
589
+ strategy: "input",
590
+ minStructureDepthForRef: 0
591
+ });
592
+ if (isAnySchema(bodySchema)) {
593
+ return;
594
+ }
595
+ ref.requestBody = {
596
+ required: bodyRequired,
597
+ content: toOpenAPIContent(bodySchema)
598
+ };
599
+ }
583
600
  }
584
601
  }
585
602
  async #successResponse(doc, ref, def, baseSchemaConvertOptions) {
@@ -1,58 +1,8 @@
1
1
  import { Value, Promisable, ORPCError } from '@temporary-name/shared';
2
- import { StandardRequest, StandardHeaders } from '@temporary-name/standard-server';
3
- import { BatchResponseBodyItem } from '@temporary-name/standard-server/batch';
4
- import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.TgmlNh8r.mjs';
5
- import { C as Context, H as ProcedureClientInterceptorOptions } from '../shared/server.B5czSQQh.mjs';
2
+ import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.vLcMd_kA.mjs';
3
+ import { C as Context, N as ProcedureClientInterceptorOptions } from '../shared/server.DkYpsO6W.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.
@@ -156,5 +80,5 @@ declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements St
156
80
  init(options: StandardHandlerOptions<T>): void;
157
81
  }
158
82
 
159
- export { BatchHandlerPlugin, CORSPlugin, RequestHeadersPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin };
160
- export type { BatchHandlerOptions, CORSOptions, RequestHeadersPluginContext, ResponseHeadersPluginContext, SimpleCsrfProtectionHandlerPluginOptions };
83
+ export { CORSPlugin, SimpleCsrfProtectionHandlerPlugin };
84
+ export type { CORSOptions, SimpleCsrfProtectionHandlerPluginOptions };
@@ -1,58 +1,8 @@
1
1
  import { Value, Promisable, ORPCError } from '@temporary-name/shared';
2
- import { StandardRequest, StandardHeaders } from '@temporary-name/standard-server';
3
- import { BatchResponseBodyItem } from '@temporary-name/standard-server/batch';
4
- import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.C4l2ZA3m.js';
5
- import { C as Context, H as ProcedureClientInterceptorOptions } from '../shared/server.B5czSQQh.js';
2
+ import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.B-meye9-.js';
3
+ import { C as Context, N as ProcedureClientInterceptorOptions } from '../shared/server.DkYpsO6W.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.
@@ -156,5 +80,5 @@ declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements St
156
80
  init(options: StandardHandlerOptions<T>): void;
157
81
  }
158
82
 
159
- export { BatchHandlerPlugin, CORSPlugin, RequestHeadersPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin };
160
- export type { BatchHandlerOptions, CORSOptions, RequestHeadersPluginContext, ResponseHeadersPluginContext, SimpleCsrfProtectionHandlerPluginOptions };
83
+ export { CORSPlugin, SimpleCsrfProtectionHandlerPlugin };
84
+ export type { CORSOptions, SimpleCsrfProtectionHandlerPluginOptions };