@orpc/server 2.0.0-beta.48 → 2.0.0-beta.49
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/README.md +4 -4
- package/dist/adapters/aws-lambda/handler.d.ts +25 -0
- package/dist/adapters/aws-lambda/handler.js +24 -0
- package/dist/adapters/aws-lambda/index.d.ts +16 -0
- package/dist/adapters/aws-lambda/index.js +2 -0
- package/dist/adapters/aws-lambda/rpc-handler.d.ts +19 -0
- package/dist/adapters/aws-lambda/rpc-handler.js +18 -0
- package/dist/adapters/crossws/handler.d.ts +45 -0
- package/dist/adapters/crossws/handler.js +60 -0
- package/dist/adapters/crossws/index.d.ts +2 -0
- package/dist/adapters/crossws/index.js +2 -0
- package/dist/adapters/crossws/rpc-handler.d.ts +16 -0
- package/dist/adapters/crossws/rpc-handler.js +15 -0
- package/dist/adapters/fastify/handler.d.ts +21 -0
- package/dist/adapters/fastify/handler.js +20 -0
- package/dist/adapters/fastify/index.d.ts +2 -0
- package/dist/adapters/fastify/index.js +2 -0
- package/dist/adapters/fastify/rpc-handler.d.ts +15 -0
- package/dist/adapters/fastify/rpc-handler.js +14 -0
- package/dist/adapters/fetch/handler.d.ts +23 -0
- package/dist/adapters/fetch/handler.js +22 -0
- package/dist/adapters/fetch/index.d.ts +7 -0
- package/dist/adapters/fetch/index.js +7 -0
- package/dist/adapters/fetch/rpc-handler.d.ts +17 -0
- package/dist/adapters/fetch/rpc-handler.js +16 -0
- package/dist/adapters/message-port/handler.d.ts +64 -0
- package/dist/adapters/message-port/handler.js +86 -0
- package/dist/adapters/message-port/index.d.ts +2 -0
- package/dist/adapters/message-port/index.js +2 -0
- package/dist/adapters/message-port/rpc-handler.d.ts +16 -0
- package/dist/adapters/message-port/rpc-handler.js +15 -0
- package/dist/adapters/node/handler.d.ts +21 -0
- package/dist/adapters/node/handler.js +20 -0
- package/dist/adapters/node/index.d.ts +7 -0
- package/dist/adapters/node/index.js +7 -0
- package/dist/adapters/node/rpc-handler.d.ts +16 -0
- package/dist/adapters/node/rpc-handler.js +15 -0
- package/dist/adapters/standard/codec.d.ts +16 -0
- package/dist/adapters/standard/handler.d.ts +68 -0
- package/dist/adapters/standard/handler.js +205 -0
- package/dist/adapters/standard/index.d.ts +6 -0
- package/dist/adapters/standard/index.js +5 -0
- package/dist/adapters/standard/plugin.d.ts +32 -0
- package/dist/adapters/standard/plugin.js +16 -0
- package/dist/adapters/standard/rpc-handler-codec.d.ts +46 -0
- package/dist/adapters/standard/rpc-handler-codec.js +51 -0
- package/dist/adapters/standard/rpc-matcher.d.ts +53 -0
- package/dist/adapters/standard/rpc-matcher.js +152 -0
- package/dist/adapters/standard/utils.d.ts +10 -0
- package/dist/adapters/standard/utils.js +6 -0
- package/dist/adapters/standard-peer/index.d.ts +1 -0
- package/dist/adapters/standard-peer/index.js +1 -0
- package/dist/adapters/standard-peer/{utils.d.mts → utils.d.ts} +3 -3
- package/dist/adapters/standard-peer/utils.js +7 -0
- package/dist/adapters/websocket/handler.d.ts +59 -0
- package/dist/adapters/websocket/handler.js +85 -0
- package/dist/adapters/websocket/index.d.ts +2 -0
- package/dist/adapters/websocket/index.js +2 -0
- package/dist/adapters/websocket/rpc-handler.d.ts +16 -0
- package/dist/adapters/websocket/rpc-handler.js +15 -0
- package/dist/builder-variants.d.ts +226 -0
- package/dist/builder.d.ts +127 -0
- package/dist/builder.js +226 -0
- package/dist/context.d.ts +6 -0
- package/dist/extensions/callable.d.ts +11 -0
- package/dist/extensions/callable.js +7 -0
- package/dist/helpers/base64url.d.ts +31 -0
- package/dist/helpers/base64url.js +53 -0
- package/dist/helpers/cookie.d.ts +51 -0
- package/dist/helpers/cookie.js +69 -0
- package/dist/helpers/encryption.d.ts +28 -0
- package/dist/helpers/encryption.js +80 -0
- package/dist/helpers/index.d.ts +4 -0
- package/dist/helpers/index.js +4 -0
- package/dist/helpers/signing.d.ts +50 -0
- package/dist/helpers/signing.js +88 -0
- package/dist/implementer-procedure.d.ts +16 -0
- package/dist/implementer-procedure.js +44 -0
- package/dist/implementer-router.d.ts +40 -0
- package/dist/implementer-router.js +117 -0
- package/dist/implementer.d.ts +16 -0
- package/dist/implementer.js +37 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +48 -0
- package/dist/lazy.d.ts +20 -0
- package/dist/lazy.js +31 -0
- package/dist/middleware-decorated.d.ts +10 -0
- package/dist/middleware-decorated.js +71 -0
- package/dist/middleware.d.ts +54 -0
- package/dist/plugins/batch.d.ts +102 -0
- package/dist/plugins/batch.js +405 -0
- package/dist/plugins/cors.d.ts +73 -0
- package/dist/plugins/cors.js +112 -0
- package/dist/plugins/get-method-csrf-protection.d.ts +23 -0
- package/dist/plugins/get-method-csrf-protection.js +64 -0
- package/dist/plugins/head-method.d.ts +23 -0
- package/dist/plugins/head-method.js +104 -0
- package/dist/plugins/index.d.ts +39 -0
- package/dist/plugins/index.js +29 -0
- package/dist/plugins/method-override.d.ts +38 -0
- package/dist/plugins/method-override.js +50 -0
- package/dist/plugins/request-compression.d.ts +16 -0
- package/dist/plugins/request-compression.js +82 -0
- package/dist/plugins/request-headers.d.ts +22 -0
- package/dist/plugins/request-headers.js +30 -0
- package/dist/plugins/request-limit.d.ts +30 -0
- package/dist/plugins/request-limit.js +68 -0
- package/dist/plugins/response-compression.d.ts +59 -0
- package/dist/plugins/response-compression.js +209 -0
- package/dist/plugins/response-headers.d.ts +30 -0
- package/dist/plugins/response-headers.js +47 -0
- package/dist/plugins/rethrow.d.ts +33 -0
- package/dist/plugins/rethrow.js +59 -0
- package/dist/plugins/signal-sync.d.ts +13 -0
- package/dist/plugins/signal-sync.js +91 -0
- package/dist/plugins/timeout.d.ts +37 -0
- package/dist/plugins/timeout.js +59 -0
- package/dist/procedure-client.d.ts +19 -0
- package/dist/procedure-client.js +175 -0
- package/dist/procedure-decorated.d.ts +10 -0
- package/dist/procedure-decorated.js +44 -0
- package/dist/procedure-utils.d.ts +41 -0
- package/dist/procedure-utils.js +49 -0
- package/dist/procedure.d.ts +72 -0
- package/dist/procedure.js +24 -0
- package/dist/router-client.d.ts +23 -0
- package/dist/router-client.js +43 -0
- package/dist/{router-hidden.d.mts → router-hidden.d.ts} +3 -3
- package/dist/router-hidden.js +14 -0
- package/dist/router-utils.d.ts +48 -0
- package/dist/router-utils.js +202 -0
- package/dist/router.d.ts +72 -0
- package/package.json +84 -86
- package/dist/adapters/aws-lambda/handler.d.mts +0 -25
- package/dist/adapters/aws-lambda/handler.mjs +0 -21
- package/dist/adapters/aws-lambda/index.d.mts +0 -16
- package/dist/adapters/aws-lambda/index.mjs +0 -2
- package/dist/adapters/aws-lambda/rpc-handler.d.mts +0 -18
- package/dist/adapters/aws-lambda/rpc-handler.mjs +0 -10
- package/dist/adapters/crossws/handler.d.mts +0 -41
- package/dist/adapters/crossws/handler.mjs +0 -38
- package/dist/adapters/crossws/index.d.mts +0 -2
- package/dist/adapters/crossws/index.mjs +0 -2
- package/dist/adapters/crossws/rpc-handler.d.mts +0 -15
- package/dist/adapters/crossws/rpc-handler.mjs +0 -10
- package/dist/adapters/fastify/handler.d.mts +0 -21
- package/dist/adapters/fastify/handler.mjs +0 -20
- package/dist/adapters/fastify/index.d.mts +0 -2
- package/dist/adapters/fastify/index.mjs +0 -2
- package/dist/adapters/fastify/rpc-handler.d.mts +0 -14
- package/dist/adapters/fastify/rpc-handler.mjs +0 -10
- package/dist/adapters/fetch/handler.d.mts +0 -23
- package/dist/adapters/fetch/handler.mjs +0 -22
- package/dist/adapters/fetch/index.d.mts +0 -7
- package/dist/adapters/fetch/index.mjs +0 -5
- package/dist/adapters/fetch/rpc-handler.d.mts +0 -16
- package/dist/adapters/fetch/rpc-handler.mjs +0 -10
- package/dist/adapters/message-port/handler.d.mts +0 -57
- package/dist/adapters/message-port/handler.mjs +0 -62
- package/dist/adapters/message-port/index.d.mts +0 -2
- package/dist/adapters/message-port/index.mjs +0 -2
- package/dist/adapters/message-port/rpc-handler.d.mts +0 -15
- package/dist/adapters/message-port/rpc-handler.mjs +0 -10
- package/dist/adapters/node/handler.d.mts +0 -21
- package/dist/adapters/node/handler.mjs +0 -20
- package/dist/adapters/node/index.d.mts +0 -7
- package/dist/adapters/node/index.mjs +0 -5
- package/dist/adapters/node/rpc-handler.d.mts +0 -15
- package/dist/adapters/node/rpc-handler.mjs +0 -10
- package/dist/adapters/standard/codec.d.mts +0 -16
- package/dist/adapters/standard/handler.d.mts +0 -68
- package/dist/adapters/standard/handler.mjs +0 -185
- package/dist/adapters/standard/index.d.mts +0 -6
- package/dist/adapters/standard/index.mjs +0 -5
- package/dist/adapters/standard/plugin.d.mts +0 -32
- package/dist/adapters/standard/plugin.mjs +0 -16
- package/dist/adapters/standard/rpc-handler-codec.d.mts +0 -42
- package/dist/adapters/standard/rpc-handler-codec.mjs +0 -51
- package/dist/adapters/standard/rpc-matcher.d.mts +0 -53
- package/dist/adapters/standard/rpc-matcher.mjs +0 -140
- package/dist/adapters/standard/utils.d.mts +0 -10
- package/dist/adapters/standard/utils.mjs +0 -6
- package/dist/adapters/standard-peer/index.d.mts +0 -1
- package/dist/adapters/standard-peer/index.mjs +0 -1
- package/dist/adapters/standard-peer/utils.mjs +0 -11
- package/dist/adapters/websocket/handler.d.mts +0 -55
- package/dist/adapters/websocket/handler.mjs +0 -55
- package/dist/adapters/websocket/index.d.mts +0 -2
- package/dist/adapters/websocket/index.mjs +0 -2
- package/dist/adapters/websocket/rpc-handler.d.mts +0 -15
- package/dist/adapters/websocket/rpc-handler.mjs +0 -10
- package/dist/builder-variants.d.mts +0 -267
- package/dist/builder.d.mts +0 -141
- package/dist/builder.mjs +0 -145
- package/dist/context.d.mts +0 -13
- package/dist/extensions/callable.d.mts +0 -17
- package/dist/extensions/callable.mjs +0 -7
- package/dist/helpers/base64url.d.mts +0 -31
- package/dist/helpers/base64url.mjs +0 -25
- package/dist/helpers/cookie.d.mts +0 -50
- package/dist/helpers/cookie.mjs +0 -35
- package/dist/helpers/encryption.d.mts +0 -28
- package/dist/helpers/encryption.mjs +0 -62
- package/dist/helpers/index.d.mts +0 -4
- package/dist/helpers/index.mjs +0 -4
- package/dist/helpers/signing.d.mts +0 -50
- package/dist/helpers/signing.mjs +0 -43
- package/dist/implementer-procedure.d.mts +0 -36
- package/dist/implementer-procedure.mjs +0 -38
- package/dist/implementer-router.d.mts +0 -78
- package/dist/implementer-router.mjs +0 -77
- package/dist/implementer.d.mts +0 -22
- package/dist/implementer.mjs +0 -30
- package/dist/index.d.mts +0 -57
- package/dist/index.mjs +0 -30
- package/dist/lazy.d.mts +0 -20
- package/dist/lazy.mjs +0 -22
- package/dist/middleware-decorated.d.mts +0 -27
- package/dist/middleware-decorated.mjs +0 -65
- package/dist/middleware.d.mts +0 -70
- package/dist/plugins/batch.d.mts +0 -104
- package/dist/plugins/batch.mjs +0 -373
- package/dist/plugins/cors.d.mts +0 -67
- package/dist/plugins/cors.mjs +0 -134
- package/dist/plugins/get-method-csrf-protection.d.mts +0 -23
- package/dist/plugins/get-method-csrf-protection.mjs +0 -45
- package/dist/plugins/head-method.d.mts +0 -23
- package/dist/plugins/head-method.mjs +0 -95
- package/dist/plugins/index.d.mts +0 -39
- package/dist/plugins/index.mjs +0 -23
- package/dist/plugins/method-override.d.mts +0 -38
- package/dist/plugins/method-override.mjs +0 -50
- package/dist/plugins/request-compression.d.mts +0 -16
- package/dist/plugins/request-compression.mjs +0 -67
- package/dist/plugins/request-headers.d.mts +0 -22
- package/dist/plugins/request-headers.mjs +0 -21
- package/dist/plugins/request-limit.d.mts +0 -30
- package/dist/plugins/request-limit.mjs +0 -53
- package/dist/plugins/response-compression.d.mts +0 -59
- package/dist/plugins/response-compression.mjs +0 -172
- package/dist/plugins/response-headers.d.mts +0 -30
- package/dist/plugins/response-headers.mjs +0 -34
- package/dist/plugins/rethrow.d.mts +0 -33
- package/dist/plugins/rethrow.mjs +0 -46
- package/dist/plugins/signal-sync.d.mts +0 -13
- package/dist/plugins/signal-sync.mjs +0 -84
- package/dist/plugins/timeout.d.mts +0 -37
- package/dist/plugins/timeout.mjs +0 -56
- package/dist/procedure-client.d.mts +0 -41
- package/dist/procedure-client.mjs +0 -157
- package/dist/procedure-decorated.d.mts +0 -20
- package/dist/procedure-decorated.mjs +0 -41
- package/dist/procedure-utils.d.mts +0 -52
- package/dist/procedure-utils.mjs +0 -33
- package/dist/procedure.d.mts +0 -93
- package/dist/procedure.mjs +0 -20
- package/dist/router-client.d.mts +0 -27
- package/dist/router-client.mjs +0 -35
- package/dist/router-hidden.mjs +0 -12
- package/dist/router-utils.d.mts +0 -59
- package/dist/router-utils.mjs +0 -191
- package/dist/router.d.mts +0 -61
- /package/dist/adapters/standard/{codec.mjs → codec.js} +0 -0
- /package/dist/{builder-variants.mjs → builder-variants.js} +0 -0
- /package/dist/{constants.d.mts → constants.d.ts} +0 -0
- /package/dist/{constants.mjs → constants.js} +0 -0
- /package/dist/{context.mjs → context.js} +0 -0
- /package/dist/{middleware.mjs → middleware.js} +0 -0
- /package/dist/{router.mjs → router.js} +0 -0
package/dist/builder.mjs
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { getHiddenMetaPlugins, mergeErrorMap, resolveMetaPlugins } from "@orpc/contract";
|
|
2
|
-
import { toArray } from "@orpc/shared";
|
|
3
|
-
import { Lazy } from "./lazy.mjs";
|
|
4
|
-
import { decorateMiddleware } from "./middleware-decorated.mjs";
|
|
5
|
-
import { DecoratedProcedure } from "./procedure-decorated.mjs";
|
|
6
|
-
import { augmentRouter } from "./router-utils.mjs";
|
|
7
|
-
|
|
8
|
-
export class Builder {
|
|
9
|
-
"~orpc";
|
|
10
|
-
|
|
11
|
-
constructor(definition) {
|
|
12
|
-
this["~orpc"] = definition;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
static create() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return new Builder({
|
|
19
|
-
errorMap: {},
|
|
20
|
-
meta: {},
|
|
21
|
-
orderedMiddlewares: []
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
$context() {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
$config(config) {
|
|
33
|
-
return new Builder({
|
|
34
|
-
...this["~orpc"],
|
|
35
|
-
...config
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
meta(...plugins) {
|
|
40
|
-
const [meta, metaPlugins] = resolveMetaPlugins(this["~orpc"].meta, this["~orpc"].metaPlugins, plugins);
|
|
41
|
-
return new Builder({
|
|
42
|
-
...this["~orpc"],
|
|
43
|
-
meta,
|
|
44
|
-
metaPlugins
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
errors(errors) {
|
|
49
|
-
let builder = new Builder({
|
|
50
|
-
...this["~orpc"],
|
|
51
|
-
errorMap: mergeErrorMap(this["~orpc"].errorMap, errors)
|
|
52
|
-
});
|
|
53
|
-
const plugins = getHiddenMetaPlugins(errors);
|
|
54
|
-
if (plugins) {
|
|
55
|
-
builder = builder.meta(...plugins);
|
|
56
|
-
}
|
|
57
|
-
return builder;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
use(middleware) {
|
|
61
|
-
let builder = new Builder({
|
|
62
|
-
...this["~orpc"],
|
|
63
|
-
errorMap: mergeErrorMap(middleware["~orpc"]?.errorMap ?? {}, this["~orpc"].errorMap),
|
|
64
|
-
orderedMiddlewares: [...this["~orpc"].orderedMiddlewares, {
|
|
65
|
-
middleware,
|
|
66
|
-
inputSchemasLengthAtUse: this["~orpc"].inputSchemas?.length,
|
|
67
|
-
outputSchemasLengthAtUse: this["~orpc"].outputSchemas?.length
|
|
68
|
-
}]
|
|
69
|
-
});
|
|
70
|
-
if (middleware["~orpc"]?.metaPlugins) {
|
|
71
|
-
builder = builder.meta(...middleware["~orpc"]?.metaPlugins);
|
|
72
|
-
}
|
|
73
|
-
return builder;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
middleware(middleware) {
|
|
77
|
-
const allMiddlewares = [...this["~orpc"].orderedMiddlewares.map(({ middleware }) => middleware), middleware];
|
|
78
|
-
let current = decorateMiddleware(allMiddlewares.shift());
|
|
79
|
-
for (const mid of allMiddlewares) {
|
|
80
|
-
current = current.use(mid);
|
|
81
|
-
}
|
|
82
|
-
current["~orpc"] = {
|
|
83
|
-
...current["~orpc"],
|
|
84
|
-
errorMap: this["~orpc"].errorMap,
|
|
85
|
-
metaPlugins: [...toArray(this["~orpc"].metaPlugins), ...toArray(middleware["~orpc"]?.metaPlugins)]
|
|
86
|
-
};
|
|
87
|
-
return current;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
input(schema) {
|
|
91
|
-
let builder = new Builder({
|
|
92
|
-
...this["~orpc"],
|
|
93
|
-
inputSchemas: [...toArray(this["~orpc"].inputSchemas), schema]
|
|
94
|
-
});
|
|
95
|
-
const plugins = getHiddenMetaPlugins(schema);
|
|
96
|
-
if (plugins) {
|
|
97
|
-
builder = builder.meta(...plugins);
|
|
98
|
-
}
|
|
99
|
-
return builder;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
output(schema) {
|
|
103
|
-
let builder = new Builder({
|
|
104
|
-
...this["~orpc"],
|
|
105
|
-
outputSchemas: [...toArray(this["~orpc"].outputSchemas), schema]
|
|
106
|
-
});
|
|
107
|
-
const plugins = getHiddenMetaPlugins(schema);
|
|
108
|
-
if (plugins) {
|
|
109
|
-
builder = builder.meta(...plugins);
|
|
110
|
-
}
|
|
111
|
-
return builder;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
handler(handler) {
|
|
115
|
-
let procedure = new DecoratedProcedure({
|
|
116
|
-
...this["~orpc"],
|
|
117
|
-
handler
|
|
118
|
-
});
|
|
119
|
-
const plugins = getHiddenMetaPlugins(handler);
|
|
120
|
-
if (plugins) {
|
|
121
|
-
procedure = procedure.meta(...plugins);
|
|
122
|
-
}
|
|
123
|
-
return procedure;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
router(router) {
|
|
127
|
-
return augmentRouter(router, {
|
|
128
|
-
...this["~orpc"],
|
|
129
|
-
middlewares: this["~orpc"].orderedMiddlewares.map(({ middleware }) => middleware)
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
lazy(loader) {
|
|
134
|
-
return new Lazy({
|
|
135
|
-
loader: async () => {
|
|
136
|
-
const { default: router } = await loader();
|
|
137
|
-
return { default: this.router(router) };
|
|
138
|
-
},
|
|
139
|
-
meta: this["~orpc"].meta,
|
|
140
|
-
metaPlugins: this["~orpc"].metaPlugins
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export const os = /* @__PURE__ */ Builder.create();
|
package/dist/context.d.mts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { DistributiveOmit } from "@orpc/shared";
|
|
2
|
-
export interface Context {
|
|
3
|
-
[key: PropertyKey]: any;
|
|
4
|
-
}
|
|
5
|
-
export type MergedInitialContext<
|
|
6
|
-
TInitial extends Context,
|
|
7
|
-
TOutContext extends Context,
|
|
8
|
-
TInContext extends Context
|
|
9
|
-
> = TInContext extends any ? Exclude<keyof TInContext, keyof TInitial | keyof TOutContext> extends never ? TInitial : TInitial & DistributiveOmit<TInContext, keyof TInitial | keyof TOutContext> : never;
|
|
10
|
-
export type MergedContext<
|
|
11
|
-
TCurrent extends Context,
|
|
12
|
-
TOutContext extends Context
|
|
13
|
-
> = keyof TOutContext extends never ? TCurrent : DistributiveOmit<TCurrent, keyof TOutContext> & TOutContext;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ClientContext } from "@orpc/client";
|
|
2
|
-
import type { AnySchema, ErrorMap } from "@orpc/contract";
|
|
3
|
-
import type { MaybeOptionalOptions } from "@orpc/shared";
|
|
4
|
-
import type { Context } from "../context.mjs";
|
|
5
|
-
import type { Procedure } from "../procedure.mjs";
|
|
6
|
-
import type { ProcedureClient, ProcedureClientOptions } from "../procedure-client.mjs";
|
|
7
|
-
declare module "@orpc/server" {
|
|
8
|
-
interface DecoratedProcedure<
|
|
9
|
-
TInitialContext extends Context,
|
|
10
|
-
TInjectedContext extends Context,
|
|
11
|
-
TInputSchema extends AnySchema,
|
|
12
|
-
TOutputSchema extends AnySchema,
|
|
13
|
-
TErrorMap extends ErrorMap
|
|
14
|
-
> {
|
|
15
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<ProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TClientContext>>): Procedure<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createProcedureClient } from "../procedure-client.mjs";
|
|
2
|
-
import { DecoratedProcedure } from "../procedure-decorated.mjs";
|
|
3
|
-
DecoratedProcedure.prototype.callable = function callable(...rest) {
|
|
4
|
-
const callable = createProcedureClient(this, ...rest);
|
|
5
|
-
callable["~orpc"] = this["~orpc"];
|
|
6
|
-
return callable;
|
|
7
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Encodes a Uint8Array to base64url format
|
|
3
|
-
* Base64url is URL-safe and doesn't use padding
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* const text = "Hello World"
|
|
8
|
-
* const encoded = encodeBase64url(new TextEncoder().encode(text))
|
|
9
|
-
* const decoded = decodeBase64url(encoded)
|
|
10
|
-
* expect(new TextDecoder().decode(decoded)).toEqual(text)
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* @see {@link https://orpc.dev/docs/helpers/base64url | Base64Url Helpers}
|
|
14
|
-
*/
|
|
15
|
-
export declare function encodeBase64url(data: Uint8Array): string;
|
|
16
|
-
/**
|
|
17
|
-
* Decodes a base64url string to Uint8Array
|
|
18
|
-
* Only accepts canonical, unpadded base64url (the form produced by `encodeBase64url`),
|
|
19
|
-
* returns undefined for anything else, including padded or standard base64 input
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```ts
|
|
23
|
-
* const text = "Hello World"
|
|
24
|
-
* const encoded = encodeBase64url(new TextEncoder().encode(text))
|
|
25
|
-
* const decoded = decodeBase64url(encoded)
|
|
26
|
-
* expect(new TextDecoder().decode(decoded)).toEqual(text)
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @see {@link https://orpc.dev/docs/helpers/base64url | Base64Url Helpers}
|
|
30
|
-
*/
|
|
31
|
-
export declare function decodeBase64url(base64url: string | undefined | null): Uint8Array<ArrayBuffer> | undefined;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { encodeBase64 } from "@orpc/shared";
|
|
2
|
-
|
|
3
|
-
export function encodeBase64url(data) {
|
|
4
|
-
return encodeBase64(data).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function decodeBase64url(base64url) {
|
|
8
|
-
try {
|
|
9
|
-
if (typeof base64url !== "string") {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
let base64 = base64url.replace(/-/g, "+").replace(/_/g, "/");
|
|
13
|
-
while (base64.length % 4) {
|
|
14
|
-
base64 += "=";
|
|
15
|
-
}
|
|
16
|
-
const binaryString = atob(base64);
|
|
17
|
-
const bytes = new Uint8Array(binaryString.length);
|
|
18
|
-
for (let i = 0; i < binaryString.length; i++) {
|
|
19
|
-
bytes[i] = binaryString.charCodeAt(i);
|
|
20
|
-
}
|
|
21
|
-
return encodeBase64url(bytes) === base64url ? bytes : undefined;
|
|
22
|
-
} catch {
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { ParseOptions, SetCookie, StringifyOptions } from "cookie";
|
|
2
|
-
export interface SetCookieOptions extends Omit<SetCookie, "name" | "value">, StringifyOptions {
|
|
3
|
-
/**
|
|
4
|
-
* Specifies the value for the [`Path` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.4).
|
|
5
|
-
*
|
|
6
|
-
* @default '/'
|
|
7
|
-
*/
|
|
8
|
-
path?: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Sets a cookie in the response headers.
|
|
12
|
-
*
|
|
13
|
-
* Does nothing if `headers` is `undefined`.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```ts
|
|
17
|
-
* const headers = new Headers()
|
|
18
|
-
*
|
|
19
|
-
* setCookie(headers, 'sessionId', 'abc123', { httpOnly: true, maxAge: 3600 })
|
|
20
|
-
*
|
|
21
|
-
* expect(headers.get('Set-Cookie')).toBe('sessionId=abc123; Max-Age=3600; Path=/; HttpOnly')
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* @see {@link https://orpc.dev/docs/helpers/cookie | Cookie Helpers}
|
|
25
|
-
*/
|
|
26
|
-
export declare function setCookie(headers: Headers | undefined, name: string, value: string, options?: SetCookieOptions): void;
|
|
27
|
-
export interface GetCookieOptions extends ParseOptions {}
|
|
28
|
-
/**
|
|
29
|
-
* Gets a cookie value from request headers
|
|
30
|
-
*
|
|
31
|
-
* Returns `undefined` if the cookie is not found or headers are `undefined`.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```ts
|
|
35
|
-
* const headers = new Headers({ 'Cookie': 'sessionId=abc123; theme=dark' })
|
|
36
|
-
*
|
|
37
|
-
* const sessionId = getCookie(headers, 'sessionId')
|
|
38
|
-
*
|
|
39
|
-
* expect(sessionId).toEqual('abc123')
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @see {@link https://orpc.dev/docs/helpers/cookie | Cookie Helpers}
|
|
43
|
-
*/
|
|
44
|
-
export declare function getCookie(headers: Headers | undefined, name: string, options?: GetCookieOptions): string | undefined;
|
|
45
|
-
/**
|
|
46
|
-
* Deletes a cookie by marking it expired.
|
|
47
|
-
*
|
|
48
|
-
* @see {@link https://orpc.dev/docs/helpers/cookie | Cookie Helpers}
|
|
49
|
-
*/
|
|
50
|
-
export declare function deleteCookie(headers: Headers | undefined, name: string, options?: Omit<SetCookieOptions, "maxAge">): void;
|
package/dist/helpers/cookie.mjs
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { parseCookie, stringifySetCookie } from "cookie";
|
|
2
|
-
|
|
3
|
-
export function setCookie(headers, name, value, options = {}) {
|
|
4
|
-
if (headers === undefined) {
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
const cookieString = stringifySetCookie({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
path: "/",
|
|
12
|
-
...options,
|
|
13
|
-
name,
|
|
14
|
-
value
|
|
15
|
-
}, options);
|
|
16
|
-
headers.append("Set-Cookie", cookieString);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function getCookie(headers, name, options = {}) {
|
|
20
|
-
if (headers === undefined) {
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
const cookieHeader = headers.get("cookie");
|
|
24
|
-
if (cookieHeader === null) {
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
return parseCookie(cookieHeader, options)[name];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function deleteCookie(headers, name, options = {}) {
|
|
31
|
-
return setCookie(headers, name, "", {
|
|
32
|
-
...options,
|
|
33
|
-
maxAge: 0
|
|
34
|
-
});
|
|
35
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Encrypts a string using AES-GCM with a secret key.
|
|
3
|
-
* The output is base64url encoded to be URL-safe.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* const encrypted = await encrypt("Hello, World!", "test-secret-key")
|
|
8
|
-
* const decrypted = await decrypt(encrypted, "test-secret-key")
|
|
9
|
-
* expect(decrypted).toBe("Hello, World!")
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* @see {@link https://orpc.dev/docs/helpers/encryption | Encryption Helpers}
|
|
13
|
-
*/
|
|
14
|
-
export declare function encrypt(value: string, secret: string): Promise<string>;
|
|
15
|
-
/**
|
|
16
|
-
* Decrypts a base64url encoded string using AES-GCM with a secret key.
|
|
17
|
-
* Returns the original string if decryption is successful, or undefined if it fails.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```ts
|
|
21
|
-
* const encrypted = await encrypt("Hello, World!", "test-secret-key")
|
|
22
|
-
* const decrypted = await decrypt(encrypted, "test-secret-key")
|
|
23
|
-
* expect(decrypted).toBe("Hello, World!")
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* @see {@link https://orpc.dev/docs/helpers/encryption | Encryption Helpers}
|
|
27
|
-
*/
|
|
28
|
-
export declare function decrypt(encrypted: string | undefined | null, secret: string): Promise<string | undefined>;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { decodeBase64url, encodeBase64url } from "./base64url.mjs";
|
|
2
|
-
const PBKDF2_CONFIG = {
|
|
3
|
-
name: "PBKDF2",
|
|
4
|
-
iterations: 6e4,
|
|
5
|
-
hash: "SHA-256"
|
|
6
|
-
};
|
|
7
|
-
const AES_GCM_CONFIG = {
|
|
8
|
-
name: "AES-GCM",
|
|
9
|
-
length: 256
|
|
10
|
-
};
|
|
11
|
-
const CRYPTO_CONSTANTS = {
|
|
12
|
-
SALT_LENGTH: 16,
|
|
13
|
-
IV_LENGTH: 12
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export async function encrypt(value, secret) {
|
|
17
|
-
const encoder = new TextEncoder();
|
|
18
|
-
const data = encoder.encode(value);
|
|
19
|
-
const salt = crypto.getRandomValues(new Uint8Array(CRYPTO_CONSTANTS.SALT_LENGTH));
|
|
20
|
-
const keyMaterial = await crypto.subtle.importKey("raw", encoder.encode(secret), PBKDF2_CONFIG.name, false, ["deriveKey"]);
|
|
21
|
-
const key = await crypto.subtle.deriveKey({
|
|
22
|
-
...PBKDF2_CONFIG,
|
|
23
|
-
salt
|
|
24
|
-
}, keyMaterial, AES_GCM_CONFIG, false, ["encrypt"]);
|
|
25
|
-
const iv = crypto.getRandomValues(new Uint8Array(CRYPTO_CONSTANTS.IV_LENGTH));
|
|
26
|
-
const encrypted = await crypto.subtle.encrypt({
|
|
27
|
-
name: AES_GCM_CONFIG.name,
|
|
28
|
-
iv
|
|
29
|
-
}, key, data);
|
|
30
|
-
const result = new Uint8Array(salt.length + iv.length + encrypted.byteLength);
|
|
31
|
-
result.set(salt, 0);
|
|
32
|
-
result.set(iv, salt.length);
|
|
33
|
-
result.set(new Uint8Array(encrypted), salt.length + iv.length);
|
|
34
|
-
return encodeBase64url(result);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export async function decrypt(encrypted, secret) {
|
|
38
|
-
try {
|
|
39
|
-
const data = decodeBase64url(encrypted);
|
|
40
|
-
if (data === undefined) {
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
const encoder = new TextEncoder();
|
|
44
|
-
const decoder = new TextDecoder();
|
|
45
|
-
const salt = data.slice(0, CRYPTO_CONSTANTS.SALT_LENGTH);
|
|
46
|
-
const iv = data.slice(CRYPTO_CONSTANTS.SALT_LENGTH, CRYPTO_CONSTANTS.SALT_LENGTH + CRYPTO_CONSTANTS.IV_LENGTH);
|
|
47
|
-
const encryptedData = data.slice(CRYPTO_CONSTANTS.SALT_LENGTH + CRYPTO_CONSTANTS.IV_LENGTH);
|
|
48
|
-
const keyMaterial = await crypto.subtle.importKey("raw", encoder.encode(secret), PBKDF2_CONFIG.name, false, ["deriveKey"]);
|
|
49
|
-
const key = await crypto.subtle.deriveKey({
|
|
50
|
-
...PBKDF2_CONFIG,
|
|
51
|
-
salt
|
|
52
|
-
}, keyMaterial, AES_GCM_CONFIG, false, ["decrypt"]);
|
|
53
|
-
const decrypted = await crypto.subtle.decrypt({
|
|
54
|
-
name: AES_GCM_CONFIG.name,
|
|
55
|
-
iv
|
|
56
|
-
}, key, encryptedData);
|
|
57
|
-
return decoder.decode(decrypted);
|
|
58
|
-
} catch {
|
|
59
|
-
|
|
60
|
-
return undefined;
|
|
61
|
-
}
|
|
62
|
-
}
|
package/dist/helpers/index.d.mts
DELETED
package/dist/helpers/index.mjs
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Signs a string value using HMAC-SHA256 with a secret key.
|
|
3
|
-
*
|
|
4
|
-
* This function creates a cryptographic signature that can be used to verify
|
|
5
|
-
* the integrity and authenticity of the data. The signature is appended to
|
|
6
|
-
* the original value, separated by a dot, using base64url encoding (no padding).
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* const signedValue = await sign("user123", "my-secret-key")
|
|
11
|
-
* expect(signedValue).toEqual("user123.oneQsU0r5dvwQFHFEjjV1uOI_IR3gZfkYHij3TRauVA")
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* @see {@link https://orpc.dev/docs/helpers/signing | Signing Helpers}
|
|
15
|
-
*/
|
|
16
|
-
export declare function sign(value: string, secret: string): Promise<string>;
|
|
17
|
-
/**
|
|
18
|
-
* Verifies and extracts the original value from a signed string.
|
|
19
|
-
*
|
|
20
|
-
* This function validates the signature of a previously signed value using the same
|
|
21
|
-
* secret key. If the signature is valid, it returns the original value. If the
|
|
22
|
-
* signature is invalid or the format is incorrect, it returns undefined.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* const signedValue = "user123.oneQsU0r5dvwQFHFEjjV1uOI_IR3gZfkYHij3TRauVA"
|
|
27
|
-
* const originalValue = await unsign(signedValue, "my-secret-key")
|
|
28
|
-
* expect(originalValue).toEqual("user123")
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* @see {@link https://orpc.dev/docs/helpers/signing | Signing Helpers}
|
|
32
|
-
*/
|
|
33
|
-
export declare function unsign(signedValue: string | undefined | null, secret: string): Promise<string | undefined>;
|
|
34
|
-
/**
|
|
35
|
-
* Extracts the value part from a signed string without verification.
|
|
36
|
-
*
|
|
37
|
-
* This function simply extracts the original value from a signed string
|
|
38
|
-
* without performing any signature verification. It's useful when you need
|
|
39
|
-
* to access the value quickly without the overhead of cryptographic verification.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```ts
|
|
43
|
-
* const signedValue = "user123.oneQsU0r5dvwQFHFEjjV1uOI_IR3gZfkYHij3TRauVA"
|
|
44
|
-
* const value = getSignedValue(signedValue)
|
|
45
|
-
* expect(value).toEqual("user123")
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* @see {@link https://orpc.dev/docs/helpers/signing | Signing Helpers}
|
|
49
|
-
*/
|
|
50
|
-
export declare function getSignedValue(signedValue: string | undefined | null): string | undefined;
|
package/dist/helpers/signing.mjs
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { decodeBase64url, encodeBase64url } from "./base64url.mjs";
|
|
2
|
-
const ALGORITHM = {
|
|
3
|
-
name: "HMAC",
|
|
4
|
-
hash: "SHA-256"
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export async function sign(value, secret) {
|
|
8
|
-
const encoder = new TextEncoder();
|
|
9
|
-
const key = await crypto.subtle.importKey("raw", encoder.encode(secret), ALGORITHM, false, ["sign"]);
|
|
10
|
-
const signature = await crypto.subtle.sign(ALGORITHM, key, encoder.encode(value));
|
|
11
|
-
return `${value}.${encodeBase64url(new Uint8Array(signature))}`;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export async function unsign(signedValue, secret) {
|
|
15
|
-
if (typeof signedValue !== "string") {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
const lastDotIndex = signedValue.lastIndexOf(".");
|
|
19
|
-
if (lastDotIndex === -1) {
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
const value = signedValue.slice(0, lastDotIndex);
|
|
23
|
-
const signatureBase64url = signedValue.slice(lastDotIndex + 1);
|
|
24
|
-
const signature = decodeBase64url(signatureBase64url);
|
|
25
|
-
if (signature === undefined) {
|
|
26
|
-
return undefined;
|
|
27
|
-
}
|
|
28
|
-
const encoder = new TextEncoder();
|
|
29
|
-
const key = await crypto.subtle.importKey("raw", encoder.encode(secret), ALGORITHM, false, ["verify"]);
|
|
30
|
-
const isValid = await crypto.subtle.verify(ALGORITHM, key, signature, encoder.encode(value));
|
|
31
|
-
return isValid ? value : undefined;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function getSignedValue(signedValue) {
|
|
35
|
-
if (typeof signedValue !== "string") {
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
const lastDotIndex = signedValue.lastIndexOf(".");
|
|
39
|
-
if (lastDotIndex === -1) {
|
|
40
|
-
return undefined;
|
|
41
|
-
}
|
|
42
|
-
return signedValue.slice(0, lastDotIndex);
|
|
43
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { AnySchema, ErrorMap, InferSchemaInput, InferSchemaOutput, ORPCErrorConstructorMap } from "@orpc/contract";
|
|
2
|
-
import type { IntersectPick } from "@orpc/shared";
|
|
3
|
-
import type { BuilderDefinition } from "./builder.mjs";
|
|
4
|
-
import type { Context, MergedContext, MergedInitialContext } from "./context.mjs";
|
|
5
|
-
import type { Middleware } from "./middleware.mjs";
|
|
6
|
-
import type { ProcedureHandler } from "./procedure.mjs";
|
|
7
|
-
import { Procedure } from "./procedure.mjs";
|
|
8
|
-
export declare class ProcedureImplementer<
|
|
9
|
-
TInitialContext extends Context,
|
|
10
|
-
TInjectedContext extends Context,
|
|
11
|
-
TInputSchema extends AnySchema,
|
|
12
|
-
TOutputSchema extends AnySchema,
|
|
13
|
-
TErrorMap extends ErrorMap
|
|
14
|
-
> {
|
|
15
|
-
"~orpc": BuilderDefinition<TInputSchema, TOutputSchema, TErrorMap>;
|
|
16
|
-
constructor(definition: BuilderDefinition<TInputSchema, TOutputSchema, TErrorMap>);
|
|
17
|
-
"use"<
|
|
18
|
-
$OutContext extends IntersectPick<MergedContext<TInitialContext, TInjectedContext>, $OutContext>,
|
|
19
|
-
$InContext extends Context = MergedContext<TInitialContext, TInjectedContext>,
|
|
20
|
-
$ErrorMap extends ErrorMap = TErrorMap
|
|
21
|
-
>(middleware: Middleware<$InContext | MergedContext<TInitialContext, TInjectedContext>, $OutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, $ErrorMap>): ProcedureImplementer<MergedInitialContext<TInitialContext, TInjectedContext, $InContext>, MergedContext<TInjectedContext, $OutContext>, TInputSchema, TOutputSchema, TErrorMap>;
|
|
22
|
-
"handler"(handler: ProcedureHandler<MergedContext<TInitialContext, TInjectedContext>, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>>): ImplementedProcedure<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
23
|
-
}
|
|
24
|
-
export declare class ImplementedProcedure<
|
|
25
|
-
TInitialContext extends Context,
|
|
26
|
-
TInjectedContext extends Context,
|
|
27
|
-
TInputSchema extends AnySchema,
|
|
28
|
-
TOutputSchema extends AnySchema,
|
|
29
|
-
TErrorMap extends ErrorMap
|
|
30
|
-
> extends Procedure<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap> {
|
|
31
|
-
use<
|
|
32
|
-
$OutContext extends IntersectPick<MergedContext<TInitialContext, TInjectedContext>, $OutContext>,
|
|
33
|
-
$InContext extends Context = MergedContext<TInitialContext, TInjectedContext>,
|
|
34
|
-
$ErrorMap extends ErrorMap = TErrorMap
|
|
35
|
-
>(middleware: Middleware<$InContext | MergedContext<TInitialContext, TInjectedContext>, $OutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, $ErrorMap>): ImplementedProcedure<MergedInitialContext<TInitialContext, TInjectedContext, $InContext>, MergedContext<TInjectedContext, $OutContext>, TInputSchema, TOutputSchema, TErrorMap>;
|
|
36
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Procedure } from "./procedure.mjs";
|
|
2
|
-
export class ProcedureImplementer {
|
|
3
|
-
"~orpc";
|
|
4
|
-
constructor(definition) {
|
|
5
|
-
this["~orpc"] = definition;
|
|
6
|
-
}
|
|
7
|
-
"use"(middleware) {
|
|
8
|
-
return new ProcedureImplementer({
|
|
9
|
-
...this["~orpc"],
|
|
10
|
-
orderedMiddlewares: [...this["~orpc"].orderedMiddlewares, {
|
|
11
|
-
middleware,
|
|
12
|
-
inputSchemasLengthAtUse: this["~orpc"].inputSchemas?.length,
|
|
13
|
-
outputSchemasLengthAtUse: this["~orpc"].outputSchemas?.length
|
|
14
|
-
}]
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
"handler"(handler) {
|
|
18
|
-
return new ImplementedProcedure({
|
|
19
|
-
...this["~orpc"],
|
|
20
|
-
handler
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
export class ImplementedProcedure extends Procedure {
|
|
25
|
-
use(middleware) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return new ImplementedProcedure({
|
|
30
|
-
...this["~orpc"],
|
|
31
|
-
orderedMiddlewares: [...this["~orpc"].orderedMiddlewares, {
|
|
32
|
-
middleware,
|
|
33
|
-
inputSchemasLengthAtUse: this["~orpc"].inputSchemas?.length,
|
|
34
|
-
outputSchemasLengthAtUse: this["~orpc"].outputSchemas?.length
|
|
35
|
-
}]
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|