@temporary-name/server 1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3 → 1.9.3-alpha.2957dbc009ec31fa21575f028b83c96651cba827

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 (39) hide show
  1. package/dist/adapters/aws-lambda/index.d.mts +3 -5
  2. package/dist/adapters/aws-lambda/index.d.ts +3 -5
  3. package/dist/adapters/aws-lambda/index.mjs +3 -3
  4. package/dist/adapters/fetch/index.d.mts +7 -85
  5. package/dist/adapters/fetch/index.d.ts +7 -85
  6. package/dist/adapters/fetch/index.mjs +15 -154
  7. package/dist/adapters/node/index.d.mts +7 -62
  8. package/dist/adapters/node/index.d.ts +7 -62
  9. package/dist/adapters/node/index.mjs +13 -119
  10. package/dist/adapters/standard/index.d.mts +9 -6
  11. package/dist/adapters/standard/index.d.ts +9 -6
  12. package/dist/adapters/standard/index.mjs +4 -4
  13. package/dist/helpers/index.mjs +3 -29
  14. package/dist/index.d.mts +72 -195
  15. package/dist/index.d.ts +72 -195
  16. package/dist/index.mjs +131 -114
  17. package/dist/openapi/index.d.mts +10 -27
  18. package/dist/openapi/index.d.ts +10 -27
  19. package/dist/openapi/index.mjs +57 -108
  20. package/dist/shared/{server.CjkiSCui.mjs → server.B7tjiDal.mjs} +73 -115
  21. package/dist/shared/server.C1RJffw4.mjs +30 -0
  22. package/dist/shared/server.CQIFwyhc.mjs +40 -0
  23. package/dist/shared/server.CpS0m3at.mjs +403 -0
  24. package/dist/shared/server.DPD7R7h_.d.mts +226 -0
  25. package/dist/shared/server.DPD7R7h_.d.ts +226 -0
  26. package/dist/shared/server.DfUs5c4R.d.ts +41 -0
  27. package/dist/shared/server.L8lRAYBR.d.mts +41 -0
  28. package/package.json +10 -27
  29. package/dist/plugins/index.d.mts +0 -160
  30. package/dist/plugins/index.d.ts +0 -160
  31. package/dist/plugins/index.mjs +0 -288
  32. package/dist/shared/server.BYnDyuDL.d.mts +0 -23
  33. package/dist/shared/server.BlJrjUA9.d.mts +0 -56
  34. package/dist/shared/server.C-tNYmY_.d.ts +0 -56
  35. package/dist/shared/server.DdHBdcen.mjs +0 -262
  36. package/dist/shared/server.JI4dqTgD.d.ts +0 -23
  37. package/dist/shared/server.Kxw442A9.mjs +0 -247
  38. package/dist/shared/server.WsFQIubj.d.mts +0 -235
  39. package/dist/shared/server.WsFQIubj.d.ts +0 -235
@@ -0,0 +1,226 @@
1
+ import { Promisable, StandardLazyRequest, HTTPPath } from '@temporary-name/shared';
2
+ import { Meta, Schemas, Route, InferProcedureClientInputs, InferSchemaOutput, EnhanceRouteOptions } from '@temporary-name/contract';
3
+
4
+ type Context = Record<PropertyKey, any>;
5
+ type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
6
+ type MergedCurrentContext<T extends Context, U extends Context> = Omit<T, keyof U> & U;
7
+ type BuildContextWithAuth<TContext extends Context, TAuthContext> = MergedCurrentContext<TContext, {
8
+ auth: TAuthContext | ('auth' extends keyof TContext ? TContext['auth'] : never);
9
+ }>;
10
+ declare function mergeCurrentContext<T extends Context, U extends Context>(context: T, other: U): MergedCurrentContext<T, U>;
11
+
12
+ type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
13
+ output: TOutput;
14
+ context: TOutContext;
15
+ }>;
16
+ interface MiddlewareNextFn<TOutput> {
17
+ <U extends Context = {}>(options?: {
18
+ context?: U;
19
+ }): MiddlewareResult<U, TOutput>;
20
+ }
21
+ interface MiddlewareOutputFn<TOutput> {
22
+ (output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
23
+ }
24
+ interface MiddlewareOptions<TInContext extends Context, TOutput, TMeta extends Meta> extends ProcedureHandlerOptions<TInContext, TMeta> {
25
+ next: MiddlewareNextFn<TOutput>;
26
+ }
27
+ /**
28
+ * A function that represents a middleware.
29
+ *
30
+ * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
31
+ */
32
+ interface Middleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TMeta extends Meta> {
33
+ (options: MiddlewareOptions<TInContext, TOutput, TMeta>, input: TInput, output: MiddlewareOutputFn<TOutput>): Promisable<MiddlewareResult<TOutContext, TOutput>>;
34
+ }
35
+ type AnyMiddleware = Middleware<any, any, any, any, any>;
36
+ interface MapInputMiddleware<TInput, TMappedInput> {
37
+ (input: TInput): TMappedInput;
38
+ }
39
+ declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
40
+
41
+ type DefaultProcedureHandlerOptions = ProcedureHandlerOptions<Context, Meta>;
42
+ interface ProcedureHandlerOptions<TCurrentContext extends Context, TMeta extends Meta> {
43
+ context: TCurrentContext;
44
+ path: readonly string[];
45
+ procedure: Procedure<Context, Context, Schemas, TMeta>;
46
+ signal?: AbortSignal;
47
+ request?: StandardLazyRequest;
48
+ lastEventId: string | undefined;
49
+ }
50
+ interface ProcedureHandler<TCurrentContext extends Context, TInput extends {
51
+ path: any;
52
+ query: any;
53
+ body: any;
54
+ }, THandlerOutput, TMeta extends Meta> {
55
+ (input: TInput, opt: ProcedureHandlerOptions<TCurrentContext, TMeta>): Promisable<THandlerOutput>;
56
+ }
57
+ interface ContractDef<TInitialContext extends Context, TSchemas extends Schemas, TMeta extends Meta> {
58
+ meta: TMeta;
59
+ route: Route;
60
+ schemas: TSchemas;
61
+ middlewares: readonly Middleware<TInitialContext, any, any, any, any>[];
62
+ authConfigs: TypedAuthConfig[];
63
+ inputValidationIndex: number;
64
+ outputValidationIndex: number;
65
+ }
66
+ type AnyContractDef = ContractDef<Context, Schemas, Meta>;
67
+ declare class Contract<TDef extends AnyContractDef = AnyContractDef> {
68
+ /**
69
+ * This property holds the defined options.
70
+ */
71
+ '~orpc': TDef;
72
+ constructor(def: TDef);
73
+ }
74
+ interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TMeta extends Meta> extends ContractDef<TInitialContext, TSchemas, TMeta> {
75
+ handler: ProcedureHandler<TCurrentContext, any, any, any>;
76
+ }
77
+ /**
78
+ * This class represents a procedure.
79
+ *
80
+ * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
81
+ */
82
+ declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TMeta extends Meta> extends Contract<ProcedureDef<TInitialContext, TCurrentContext, TSchemas, TMeta>> {
83
+ }
84
+ type AnyProcedure = Procedure<any, any, Schemas, any>;
85
+ declare function isProcedure(item: unknown): item is AnyProcedure;
86
+
87
+ type ValidatedAuthContext = {};
88
+ interface BasicAuthConfig<TAuthContext extends ValidatedAuthContext, TCurrentContext extends Context, TMeta extends Meta> {
89
+ tokenPrefix?: string;
90
+ validate: (username: string, password: string, options: ProcedureHandlerOptions<TCurrentContext, TMeta>) => Promisable<TAuthContext>;
91
+ }
92
+ interface TokenAuthConfig<TAuthContext extends ValidatedAuthContext, TCurrentContext extends Context, TMeta extends Meta> {
93
+ tokenPrefix?: string;
94
+ validate: (token: string, options: ProcedureHandlerOptions<TCurrentContext, TMeta>) => Promisable<TAuthContext>;
95
+ }
96
+ interface NamedTokenAuthConfig<TAuthContext extends ValidatedAuthContext, TCurrentContext extends Context, TMeta extends Meta> extends TokenAuthConfig<TAuthContext, TCurrentContext, TMeta> {
97
+ name: string;
98
+ }
99
+ type AuthType = 'header' | 'query' | 'cookie' | 'bearer' | 'basic' | 'none';
100
+ type AuthConfig<TAuthType extends AuthType, TAuthContext extends ValidatedAuthContext = ValidatedAuthContext, TCurrentContext extends Context = Context, TMeta extends Meta = Meta> = TAuthType extends 'basic' ? BasicAuthConfig<TAuthContext, TCurrentContext, TMeta> : TAuthType extends 'bearer' ? TokenAuthConfig<TAuthContext, TCurrentContext, TMeta> : TAuthType extends 'header' ? NamedTokenAuthConfig<TAuthContext, TCurrentContext, TMeta> : TAuthType extends 'query' ? NamedTokenAuthConfig<TAuthContext, TCurrentContext, TMeta> : TAuthType extends 'cookie' ? NamedTokenAuthConfig<TAuthContext, TCurrentContext, TMeta> : TAuthType extends 'none' ? {} : never;
101
+ type TypedAuthConfig<TAuthType extends AuthType = AuthType> = {
102
+ type: TAuthType;
103
+ } & AuthConfig<TAuthType, object>;
104
+
105
+ type ContractRouter = Contract | {
106
+ [k: string]: ContractRouter;
107
+ };
108
+ /**
109
+ * Represents a router, which defines a hierarchical structure of procedures.
110
+ *
111
+ * @info A procedure is a router too.
112
+ * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs}
113
+ */
114
+ type Router<TInitialContext extends Context> = Procedure<TInitialContext, any, any, any> | {
115
+ [k: string]: Lazyable<Router<TInitialContext>>;
116
+ };
117
+ type AnyRouter = Router<any>;
118
+ type InferRouterInitialContext<T extends AnyRouter> = T extends Router<infer UInitialContext> ? UInitialContext : never;
119
+ /**
120
+ * Infer all initial context of the router.
121
+ *
122
+ * @info A procedure is a router too.
123
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
124
+ */
125
+ type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any> ? UInitialContext : {
126
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
127
+ };
128
+ /**
129
+ * Infer all current context of the router.
130
+ *
131
+ * @info A procedure is a router too.
132
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
133
+ */
134
+ type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any> ? UCurrentContext : {
135
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
136
+ };
137
+ /**
138
+ * Infer all router inputs
139
+ *
140
+ * @info A procedure is a router too.
141
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
142
+ */
143
+ type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer USchemas, any> ? InferProcedureClientInputs<USchemas> : {
144
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
145
+ };
146
+ /**
147
+ * Infer all router outputs
148
+ *
149
+ * @info A procedure is a router too.
150
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
151
+ */
152
+ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, infer USchemas, any> ? InferSchemaOutput<USchemas['outputSchema']> : {
153
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
154
+ };
155
+
156
+ declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
157
+ type AccessibleLazyRouter<T extends Lazyable<AnyRouter | undefined>> = T extends Lazy<infer U extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> ? AccessibleLazyRouter<U> : T extends AnyProcedure | undefined ? Lazy<T> : Lazy<T> & {
158
+ [K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
159
+ };
160
+ declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
161
+ type EnhancedRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context> = T extends Lazy<infer U extends AnyRouter> ? AccessibleLazyRouter<EnhancedRouter<U, TInitialContext, TCurrentContext>> : T extends Procedure<infer UInitialContext, infer UCurrentContext, infer USchemas, infer UMeta> ? Procedure<MergedInitialContext<TInitialContext, UInitialContext, TCurrentContext>, UCurrentContext, USchemas, UMeta> : {
162
+ [K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TCurrentContext> : never;
163
+ };
164
+ interface EnhanceRouterOptions extends EnhanceRouteOptions {
165
+ middlewares: readonly AnyMiddleware[];
166
+ dedupeLeadingMiddlewares: boolean;
167
+ }
168
+ declare function enhanceRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context>(router: T, options: EnhanceRouterOptions): EnhancedRouter<T, TInitialContext, TCurrentContext>;
169
+ interface TraverseContractProceduresOptions {
170
+ router: ContractRouter | AnyRouter;
171
+ path: readonly string[];
172
+ }
173
+ interface TraverseContractProcedureCallbackOptions {
174
+ contract: Contract;
175
+ path: readonly string[];
176
+ }
177
+ /**
178
+ * @deprecated Use `TraverseContractProcedureCallbackOptions` instead.
179
+ */
180
+ type ContractProcedureCallbackOptions = TraverseContractProcedureCallbackOptions;
181
+ interface LazyTraverseContractProceduresOptions {
182
+ router: Lazy<AnyRouter>;
183
+ path: readonly string[];
184
+ }
185
+ declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
186
+ declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void): Promise<void>;
187
+ type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
188
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
189
+ };
190
+ declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
191
+
192
+ declare const LAZY_SYMBOL: unique symbol;
193
+ interface LazyMeta {
194
+ prefix?: HTTPPath;
195
+ }
196
+ interface Lazy<T> {
197
+ [LAZY_SYMBOL]: {
198
+ loader: () => Promise<{
199
+ default: T;
200
+ }>;
201
+ meta: LazyMeta;
202
+ };
203
+ }
204
+ type Lazyable<T> = T | Lazy<T>;
205
+ /**
206
+ * @internal
207
+ */
208
+ declare function lazyInternal<T>(loader: () => Promise<{
209
+ default: T;
210
+ }>, meta?: LazyMeta): Lazy<T>;
211
+ /**
212
+ * Creates a lazy-loaded item.
213
+ *
214
+ * @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
215
+ */
216
+ declare function lazy<T extends Router<any>>(prefix: HTTPPath, loader: () => Promise<{
217
+ default: T;
218
+ }>): EnhancedRouter<Lazy<T>, {}, {}>;
219
+ declare function isLazy(item: unknown): item is Lazy<any>;
220
+ declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
221
+ declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
222
+ default: T extends Lazy<infer U> ? U : T;
223
+ }>;
224
+
225
+ export { traverseContractProcedures as $, isProcedure as H, Procedure as P, getRouter as S, createAccessibleLazyRouter as U, enhanceRouter as W, Contract as a, resolveContractProcedures as a0, unlazyRouter as a2, mergeCurrentContext as m, LAZY_SYMBOL as n, lazyInternal as p, lazy as q, isLazy as r, getLazyMeta as s, unlazy as u, middlewareOutputFn as y };
226
+ export type { AuthType as A, BuildContextWithAuth as B, Context as C, DefaultProcedureHandlerOptions as D, EnhanceRouterOptions as E, AnyContractDef as F, ProcedureDef as G, InferRouterInitialContext as I, ContractRouter as J, InferRouterInitialContexts as K, Lazyable as L, Middleware as M, InferRouterCurrentContexts as N, InferRouterInputs as O, InferRouterOutputs as Q, Router as R, AccessibleLazyRouter as T, ValidatedAuthContext as V, TraverseContractProceduresOptions as X, TraverseContractProcedureCallbackOptions as Y, ContractProcedureCallbackOptions as Z, LazyTraverseContractProceduresOptions as _, UnlaziedRouter as a1, MergedInitialContext as b, MergedCurrentContext as c, AuthConfig as d, ProcedureHandler as e, EnhancedRouter as f, MapInputMiddleware as g, ContractDef as h, AnyMiddleware as i, Lazy as j, AnyProcedure as k, AnyRouter as l, LazyMeta as o, MiddlewareResult as t, MiddlewareNextFn as v, MiddlewareOutputFn as w, MiddlewareOptions as x, ProcedureHandlerOptions as z };
@@ -0,0 +1,41 @@
1
+ import { HTTPPath, StandardResponse, StandardLazyRequest } from '@temporary-name/shared';
2
+ import { C as Context, R as Router } from './server.DPD7R7h_.js';
3
+
4
+ interface StandardHandleOptions<T extends Context> {
5
+ prefix?: HTTPPath;
6
+ context: T;
7
+ }
8
+ type StandardHandleResult = {
9
+ matched: true;
10
+ response: StandardResponse;
11
+ } | {
12
+ matched: false;
13
+ response: undefined;
14
+ };
15
+ interface StandardHandlerOptions<TContext extends Context> {
16
+ }
17
+ declare class StandardHandler<T extends Context> {
18
+ private readonly matcher;
19
+ constructor(router: Router<T>, _options: NoInfer<StandardHandlerOptions<T>>);
20
+ handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
21
+ }
22
+
23
+ type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
24
+ context?: T;
25
+ } : {
26
+ context: T;
27
+ });
28
+ declare function resolveFriendlyStandardHandleOptions<T extends Context>(options: FriendlyStandardHandleOptions<T>): StandardHandleOptions<T>;
29
+ /**
30
+ * {@link https://github.com/unjs/rou3}
31
+ *
32
+ * @internal
33
+ */
34
+ declare function toRou3Pattern(path: HTTPPath): string;
35
+ /**
36
+ * @internal
37
+ */
38
+ declare function decodeParams(params: Record<string, string>): Record<string, string>;
39
+
40
+ export { StandardHandler as c, decodeParams as d, resolveFriendlyStandardHandleOptions as r, toRou3Pattern as t };
41
+ export type { FriendlyStandardHandleOptions as F, StandardHandleOptions as S, StandardHandleResult as a, StandardHandlerOptions as b };
@@ -0,0 +1,41 @@
1
+ import { HTTPPath, StandardResponse, StandardLazyRequest } from '@temporary-name/shared';
2
+ import { C as Context, R as Router } from './server.DPD7R7h_.mjs';
3
+
4
+ interface StandardHandleOptions<T extends Context> {
5
+ prefix?: HTTPPath;
6
+ context: T;
7
+ }
8
+ type StandardHandleResult = {
9
+ matched: true;
10
+ response: StandardResponse;
11
+ } | {
12
+ matched: false;
13
+ response: undefined;
14
+ };
15
+ interface StandardHandlerOptions<TContext extends Context> {
16
+ }
17
+ declare class StandardHandler<T extends Context> {
18
+ private readonly matcher;
19
+ constructor(router: Router<T>, _options: NoInfer<StandardHandlerOptions<T>>);
20
+ handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
21
+ }
22
+
23
+ type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
24
+ context?: T;
25
+ } : {
26
+ context: T;
27
+ });
28
+ declare function resolveFriendlyStandardHandleOptions<T extends Context>(options: FriendlyStandardHandleOptions<T>): StandardHandleOptions<T>;
29
+ /**
30
+ * {@link https://github.com/unjs/rou3}
31
+ *
32
+ * @internal
33
+ */
34
+ declare function toRou3Pattern(path: HTTPPath): string;
35
+ /**
36
+ * @internal
37
+ */
38
+ declare function decodeParams(params: Record<string, string>): Record<string, string>;
39
+
40
+ export { StandardHandler as c, decodeParams as d, resolveFriendlyStandardHandleOptions as r, toRou3Pattern as t };
41
+ export type { FriendlyStandardHandleOptions as F, StandardHandleOptions as S, StandardHandleResult as a, StandardHandlerOptions as b };
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.26612c2cf6a7177d2b500d984d282309d8320ca3",
4
+ "version": "1.9.3-alpha.2957dbc009ec31fa21575f028b83c96651cba827",
5
5
  "license": "MIT",
6
6
  "homepage": "https://www.stainless.com/",
7
7
  "repository": {
@@ -23,11 +23,6 @@
23
23
  "import": "./dist/helpers/index.mjs",
24
24
  "default": "./dist/helpers/index.mjs"
25
25
  },
26
- "./plugins": {
27
- "types": "./dist/plugins/index.d.mts",
28
- "import": "./dist/plugins/index.mjs",
29
- "default": "./dist/plugins/index.mjs"
30
- },
31
26
  "./standard": {
32
27
  "types": "./dist/adapters/standard/index.d.mts",
33
28
  "import": "./dist/adapters/standard/index.mjs",
@@ -57,31 +52,19 @@
57
52
  "files": [
58
53
  "dist"
59
54
  ],
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
55
  "dependencies": {
73
56
  "cookie": "^1.0.2",
74
57
  "rou3": "^0.7.7",
75
58
  "zod": "^4.1.12",
76
- "@temporary-name/contract": "1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3",
77
- "@temporary-name/shared": "1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3",
78
- "@temporary-name/json-schema": "1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3",
79
- "@temporary-name/standard-server": "1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3",
80
- "@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3",
81
- "@temporary-name/interop": "1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3",
82
- "@temporary-name/standard-server-fetch": "1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3",
83
- "@temporary-name/zod": "1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3",
84
- "@temporary-name/standard-server-node": "1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3"
59
+ "@temporary-name/contract": "1.9.3-alpha.2957dbc009ec31fa21575f028b83c96651cba827",
60
+ "@temporary-name/interop": "1.9.3-alpha.2957dbc009ec31fa21575f028b83c96651cba827",
61
+ "@temporary-name/json-schema": "1.9.3-alpha.2957dbc009ec31fa21575f028b83c96651cba827",
62
+ "@temporary-name/shared": "1.9.3-alpha.2957dbc009ec31fa21575f028b83c96651cba827",
63
+ "@temporary-name/standard-server": "1.9.3-alpha.2957dbc009ec31fa21575f028b83c96651cba827",
64
+ "@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.2957dbc009ec31fa21575f028b83c96651cba827",
65
+ "@temporary-name/standard-server-node": "1.9.3-alpha.2957dbc009ec31fa21575f028b83c96651cba827",
66
+ "@temporary-name/standard-server-fetch": "1.9.3-alpha.2957dbc009ec31fa21575f028b83c96651cba827",
67
+ "@temporary-name/zod": "1.9.3-alpha.2957dbc009ec31fa21575f028b83c96651cba827"
85
68
  },
86
69
  "devDependencies": {
87
70
  "@types/supertest": "^6.0.3",
@@ -1,160 +0,0 @@
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.BlJrjUA9.mjs';
5
- import { C as Context, H as ProcedureClientInterceptorOptions } from '../shared/server.WsFQIubj.mjs';
6
- import { Meta } from '@temporary-name/contract';
7
-
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
- interface CORSOptions<T extends Context> {
57
- origin?: Value<Promisable<string | readonly string[] | null | undefined>, [
58
- origin: string,
59
- options: StandardHandlerInterceptorOptions<T>
60
- ]>;
61
- timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [
62
- origin: string,
63
- options: StandardHandlerInterceptorOptions<T>
64
- ]>;
65
- allowMethods?: readonly string[];
66
- allowHeaders?: readonly string[];
67
- maxAge?: number;
68
- credentials?: boolean;
69
- exposeHeaders?: readonly string[];
70
- }
71
- /**
72
- * CORSPlugin is a plugin for oRPC that allows you to configure CORS for your API.
73
- *
74
- * @see {@link https://orpc.unnoq.com/docs/plugins/cors CORS Plugin Docs}
75
- */
76
- declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T> {
77
- private readonly options;
78
- order: number;
79
- constructor(options?: CORSOptions<T>);
80
- init(options: StandardHandlerOptions<T>): void;
81
- }
82
-
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
- interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
110
- /**
111
- * The name of the header to check.
112
- *
113
- * @default 'x-csrf-token'
114
- */
115
- headerName?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
116
- /**
117
- * The value of the header to check.
118
- *
119
- * @default 'orpc'
120
- *
121
- */
122
- headerValue?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
123
- /**
124
- * Exclude a procedure from the plugin.
125
- *
126
- * @default false
127
- *
128
- */
129
- exclude?: Value<Promisable<boolean>, [
130
- options: ProcedureClientInterceptorOptions<T, Record<never, never>, Meta>
131
- ]>;
132
- /**
133
- * The error thrown when the CSRF token is invalid.
134
- *
135
- * @default new ORPCError('CSRF_TOKEN_MISMATCH', {
136
- * status: 403,
137
- * message: 'Invalid CSRF token',
138
- * })
139
- */
140
- error?: InstanceType<typeof ORPCError>;
141
- }
142
- /**
143
- * This plugin adds basic Cross-Site Request Forgery (CSRF) protection to your oRPC application.
144
- * It helps ensure that requests to your procedures originate from JavaScript code,
145
- * not from other sources like standard HTML forms or direct browser navigation.
146
- *
147
- * @see {@link https://orpc.unnoq.com/docs/plugins/simple-csrf-protection Simple CSRF Protection Plugin Docs}
148
- */
149
- declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
150
- private readonly headerName;
151
- private readonly headerValue;
152
- private readonly exclude;
153
- private readonly error;
154
- constructor(options?: SimpleCsrfProtectionHandlerPluginOptions<T>);
155
- order: number;
156
- init(options: StandardHandlerOptions<T>): void;
157
- }
158
-
159
- export { BatchHandlerPlugin, CORSPlugin, RequestHeadersPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin };
160
- export type { BatchHandlerOptions, CORSOptions, RequestHeadersPluginContext, ResponseHeadersPluginContext, SimpleCsrfProtectionHandlerPluginOptions };