@orpc/nest 2.0.0-beta.15 → 2.0.0-beta.17
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 +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +14 -14
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -175,7 +175,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
175
175
|
<a href="https://github.com/illarionvk?ref=orpc" target="_blank" rel="noopener" title="Illarion Koperski"><img src="https://avatars.githubusercontent.com/u/5012724?u=7cfa13652f7ac5fb3c56d880e3eb3fbe40c3ea34&v=4" width="32" height="32" alt="Illarion Koperski" /></a>
|
|
176
176
|
<a href="https://github.com/steelbrain?ref=orpc" target="_blank" rel="noopener" title="Anees Iqbal"><img src="https://avatars.githubusercontent.com/u/4278113?u=22b80b5399eed68ac76cd58b02961b0481f1db11&v=4" width="32" height="32" alt="Anees Iqbal" /></a>
|
|
177
177
|
<a href="https://github.com/Scrumplex?ref=orpc" target="_blank" rel="noopener" title="Sefa Eyeoglu"><img src="https://avatars.githubusercontent.com/u/11587657?u=ab503582165c0bbff0cca47ce31c9450bb1553c9&v=4" width="32" height="32" alt="Sefa Eyeoglu" /></a>
|
|
178
|
-
<a href="https://github.com/nattstack?ref=orpc" target="_blank" rel="noopener" title="
|
|
178
|
+
<a href="https://github.com/nattstack?ref=orpc" target="_blank" rel="noopener" title="natt"><img src="https://avatars.githubusercontent.com/u/31426677?u=fa9dbb8b3e66eb0ea3c88db5dc07f31c8c5418fe&v=4" width="32" height="32" alt="natt" /></a>
|
|
179
179
|
<a href="https://github.com/ChromeGG?ref=orpc" target="_blank" rel="noopener" title="Adam Tkaczyk"><img src="https://avatars.githubusercontent.com/u/39050595?u=a58ca6042a6950e94e6e92442db76ef584279bc0&v=4" width="32" height="32" alt="Adam Tkaczyk" /></a>
|
|
180
180
|
<a href="https://github.com/plancraft?ref=orpc" target="_blank" rel="noopener" title="plancraft"><img src="https://avatars.githubusercontent.com/u/46482287?v=4" width="32" height="32" alt="plancraft" /></a>
|
|
181
181
|
</p>
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DynamicModule, NestInterceptor,
|
|
1
|
+
import { ExecutionContext, DynamicModule, NestInterceptor, CallHandler } from '@nestjs/common';
|
|
2
2
|
import { RouterContract } from '@orpc/contract';
|
|
3
3
|
import { DefaultInitialContext, ContractedRouter } from '@orpc/server';
|
|
4
|
-
import { Promisable } from '@orpc/shared';
|
|
4
|
+
import { Value, Promisable } from '@orpc/shared';
|
|
5
5
|
import { Observable } from 'rxjs';
|
|
6
6
|
import { OpenAPIHandlerCodecCoreOptions } from '@orpc/openapi/standard';
|
|
7
7
|
import { StandardHandlerOptions } from '@orpc/server/standard';
|
|
@@ -17,9 +17,9 @@ interface NestStandardLazyRequest extends StandardLazyRequest {
|
|
|
17
17
|
params?: undefined | Record<string, string | string[]>;
|
|
18
18
|
}
|
|
19
19
|
type ORPCModuleConfig = OpenAPIHandlerCodecCoreOptions<DefaultInitialContext> & StandardHandlerOptions<DefaultInitialContext> & (object extends DefaultInitialContext ? {
|
|
20
|
-
context?: DefaultInitialContext
|
|
20
|
+
context?: Value<Promisable<DefaultInitialContext>, [ctx: ExecutionContext]>;
|
|
21
21
|
} : {
|
|
22
|
-
context: DefaultInitialContext
|
|
22
|
+
context: Value<Promisable<DefaultInitialContext>, [ctx: ExecutionContext]>;
|
|
23
23
|
}) & {
|
|
24
24
|
/**
|
|
25
25
|
* Customize how to convert NestJS `req` and `res` to {@link NestStandardLazyRequest}.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DynamicModule, NestInterceptor,
|
|
1
|
+
import { ExecutionContext, DynamicModule, NestInterceptor, CallHandler } from '@nestjs/common';
|
|
2
2
|
import { RouterContract } from '@orpc/contract';
|
|
3
3
|
import { DefaultInitialContext, ContractedRouter } from '@orpc/server';
|
|
4
|
-
import { Promisable } from '@orpc/shared';
|
|
4
|
+
import { Value, Promisable } from '@orpc/shared';
|
|
5
5
|
import { Observable } from 'rxjs';
|
|
6
6
|
import { OpenAPIHandlerCodecCoreOptions } from '@orpc/openapi/standard';
|
|
7
7
|
import { StandardHandlerOptions } from '@orpc/server/standard';
|
|
@@ -17,9 +17,9 @@ interface NestStandardLazyRequest extends StandardLazyRequest {
|
|
|
17
17
|
params?: undefined | Record<string, string | string[]>;
|
|
18
18
|
}
|
|
19
19
|
type ORPCModuleConfig = OpenAPIHandlerCodecCoreOptions<DefaultInitialContext> & StandardHandlerOptions<DefaultInitialContext> & (object extends DefaultInitialContext ? {
|
|
20
|
-
context?: DefaultInitialContext
|
|
20
|
+
context?: Value<Promisable<DefaultInitialContext>, [ctx: ExecutionContext]>;
|
|
21
21
|
} : {
|
|
22
|
-
context: DefaultInitialContext
|
|
22
|
+
context: Value<Promisable<DefaultInitialContext>, [ctx: ExecutionContext]>;
|
|
23
23
|
}) & {
|
|
24
24
|
/**
|
|
25
25
|
* Customize how to convert NestJS `req` and `res` to {@link NestStandardLazyRequest}.
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { getOpenAPIMeta, DEFAULT_OPENAPI_METHOD, getDynamicPathParams } from '@o
|
|
|
6
6
|
import { OpenAPIHandlerCodecCore } from '@orpc/openapi/standard';
|
|
7
7
|
import { DEFAULT_SUCCESS_STATUS, getRouter, unlazy, Procedure } from '@orpc/server';
|
|
8
8
|
import { StandardHandler } from '@orpc/server/standard';
|
|
9
|
-
import { mergeHttpPath, get, isAsyncIteratorObject, stringifyJSON } from '@orpc/shared';
|
|
9
|
+
import { mergeHttpPath, get, value, isAsyncIteratorObject, stringifyJSON } from '@orpc/shared';
|
|
10
10
|
import { flattenStandardHeader, generateContentDisposition } from '@standardserver/core';
|
|
11
11
|
import { toStandardLazyRequest, toEventStream } from '@standardserver/node';
|
|
12
12
|
import { mergeMap } from 'rxjs';
|
|
@@ -162,7 +162,7 @@ let ImplementInterceptor = class {
|
|
|
162
162
|
encodeOutput: this.codec.encodeOutput.bind(this.codec)
|
|
163
163
|
}, this.config);
|
|
164
164
|
const result = await handler.handle(standardRequest, {
|
|
165
|
-
context: this.config.context ?? {}
|
|
165
|
+
context: await value(this.config.context ?? {}, ctx)
|
|
166
166
|
});
|
|
167
167
|
if (!result.matched) {
|
|
168
168
|
throw new TypeError(
|
|
@@ -172,15 +172,15 @@ let ImplementInterceptor = class {
|
|
|
172
172
|
const httpAdapter = this.httpAdapterHost.httpAdapter;
|
|
173
173
|
httpAdapter.status(res, result.response.status);
|
|
174
174
|
for (const key in result.response.headers) {
|
|
175
|
-
const
|
|
176
|
-
if (typeof
|
|
177
|
-
httpAdapter.setHeader(res, key,
|
|
175
|
+
const value2 = result.response.headers[key];
|
|
176
|
+
if (typeof value2 === "string") {
|
|
177
|
+
httpAdapter.setHeader(res, key, value2);
|
|
178
178
|
} else {
|
|
179
|
-
|
|
179
|
+
value2?.forEach((value3, index) => {
|
|
180
180
|
if (index === 0) {
|
|
181
|
-
httpAdapter.setHeader(res, key,
|
|
181
|
+
httpAdapter.setHeader(res, key, value3);
|
|
182
182
|
} else {
|
|
183
|
-
httpAdapter.appendHeader(res, key,
|
|
183
|
+
httpAdapter.appendHeader(res, key, value3);
|
|
184
184
|
}
|
|
185
185
|
});
|
|
186
186
|
}
|
|
@@ -203,7 +203,7 @@ let ImplementInterceptor = class {
|
|
|
203
203
|
type: body.type,
|
|
204
204
|
disposition: flattenStandardHeader(result.response.headers["content-disposition"]) ?? generateContentDisposition(body instanceof File ? body.name : "blob"),
|
|
205
205
|
// BunS3 can use NaN for the size
|
|
206
|
-
length: Number.
|
|
206
|
+
length: Number.isFinite(body.size) ? body.size : void 0
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
209
|
if (body instanceof FormData) {
|
|
@@ -234,8 +234,8 @@ ImplementInterceptor = __decorateClass([
|
|
|
234
234
|
__decorateParam(0, Optional()),
|
|
235
235
|
__decorateParam(1, Inject(HttpAdapterHost))
|
|
236
236
|
], ImplementInterceptor);
|
|
237
|
-
function flattenParamValue(
|
|
238
|
-
return Array.isArray(
|
|
237
|
+
function flattenParamValue(value2) {
|
|
238
|
+
return Array.isArray(value2) ? value2.join("/") : value2;
|
|
239
239
|
}
|
|
240
240
|
function toORPCOpenAPIParams(contract, params) {
|
|
241
241
|
const meta = getOpenAPIMeta(contract);
|
|
@@ -247,11 +247,11 @@ function toORPCOpenAPIParams(contract, params) {
|
|
|
247
247
|
return void 0;
|
|
248
248
|
}
|
|
249
249
|
return dynamicParams.reduce((acc, config) => {
|
|
250
|
-
const
|
|
251
|
-
if (
|
|
250
|
+
const value2 = config.allowsSlash ? flattenParamValue(params?.["*"] ?? params?.path) : flattenParamValue(params?.[config.parameterName]);
|
|
251
|
+
if (value2 === void 0) {
|
|
252
252
|
return acc;
|
|
253
253
|
}
|
|
254
|
-
acc[config.parameterName] =
|
|
254
|
+
acc[config.parameterName] = value2;
|
|
255
255
|
return acc;
|
|
256
256
|
}, {});
|
|
257
257
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/nest",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.17",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.dev",
|
|
7
7
|
"repository": {
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@standardserver/core": "^0.
|
|
41
|
-
"@standardserver/node": "^0.
|
|
42
|
-
"@orpc/client": "2.0.0-beta.
|
|
43
|
-
"@orpc/contract": "2.0.0-beta.
|
|
44
|
-
"@orpc/
|
|
45
|
-
"@orpc/
|
|
46
|
-
"@orpc/
|
|
40
|
+
"@standardserver/core": "^0.4.2",
|
|
41
|
+
"@standardserver/node": "^0.4.2",
|
|
42
|
+
"@orpc/client": "2.0.0-beta.17",
|
|
43
|
+
"@orpc/contract": "2.0.0-beta.17",
|
|
44
|
+
"@orpc/server": "2.0.0-beta.17",
|
|
45
|
+
"@orpc/openapi": "2.0.0-beta.17",
|
|
46
|
+
"@orpc/shared": "2.0.0-beta.17"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@fastify/cookie": "^11.0.2",
|