@opra/http 1.4.4 → 1.5.1
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/cjs/http-adapter.js +1 -0
- package/cjs/http-context.js +1 -0
- package/cjs/http-handler.js +10 -5
- package/cjs/impl/multipart-reader.js +2 -0
- package/esm/http-adapter.js +1 -0
- package/esm/http-context.js +1 -0
- package/esm/http-handler.js +10 -5
- package/esm/impl/multipart-reader.js +2 -0
- package/package.json +3 -3
- package/types/http-adapter.d.ts +2 -0
- package/types/impl/multipart-reader.d.ts +2 -0
package/cjs/http-adapter.js
CHANGED
package/cjs/http-context.js
CHANGED
package/cjs/http-handler.js
CHANGED
|
@@ -128,8 +128,10 @@ class HttpHandler {
|
|
|
128
128
|
let decode = this[core_1.kAssetCache].get(prm, 'decode');
|
|
129
129
|
if (!decode) {
|
|
130
130
|
decode =
|
|
131
|
-
prm.type?.generateCodec('decode', {
|
|
132
|
-
|
|
131
|
+
prm.type?.generateCodec('decode', {
|
|
132
|
+
scope: this.adapter.scope,
|
|
133
|
+
ignoreReadonlyFields: true,
|
|
134
|
+
}) || valgen_1.vg.isAny();
|
|
133
135
|
this[core_1.kAssetCache].set(prm, 'decode', decode);
|
|
134
136
|
}
|
|
135
137
|
return decode;
|
|
@@ -318,8 +320,8 @@ class HttpHandler {
|
|
|
318
320
|
let operationResultEncoder = this[core_1.kAssetCache].get(operationResultType, 'encode');
|
|
319
321
|
if (!operationResultEncoder) {
|
|
320
322
|
operationResultEncoder = operationResultType.generateCodec('encode', {
|
|
323
|
+
scope: this.adapter.scope,
|
|
321
324
|
ignoreWriteonlyFields: true,
|
|
322
|
-
ignoreHiddenFields: true,
|
|
323
325
|
});
|
|
324
326
|
this[core_1.kAssetCache].set(operationResultType, 'encode', operationResultEncoder);
|
|
325
327
|
}
|
|
@@ -333,10 +335,10 @@ class HttpHandler {
|
|
|
333
335
|
let encode = this[core_1.kAssetCache].get(operationResponse, 'encode:' + assetKey);
|
|
334
336
|
if (!encode) {
|
|
335
337
|
encode = operationResponse.type.generateCodec('encode', {
|
|
338
|
+
scope: this.adapter.scope,
|
|
336
339
|
partial: operationResponse.partial,
|
|
337
340
|
projection,
|
|
338
341
|
ignoreWriteonlyFields: true,
|
|
339
|
-
ignoreHiddenFields: true,
|
|
340
342
|
onFail: issue => `Response body validation failed: ` + issue.message,
|
|
341
343
|
});
|
|
342
344
|
if (operationResponse) {
|
|
@@ -454,7 +456,10 @@ class HttpHandler {
|
|
|
454
456
|
const dt = document.node.getComplexType('OperationResult');
|
|
455
457
|
let encode = this[core_1.kAssetCache].get(dt, 'encode');
|
|
456
458
|
if (!encode) {
|
|
457
|
-
encode = dt.generateCodec('encode', {
|
|
459
|
+
encode = dt.generateCodec('encode', {
|
|
460
|
+
scope: this.adapter.scope,
|
|
461
|
+
ignoreWriteonlyFields: true,
|
|
462
|
+
});
|
|
458
463
|
this[core_1.kAssetCache].set(dt, 'encode', encode);
|
|
459
464
|
}
|
|
460
465
|
// const { i18n } = this.adapter;
|
|
@@ -24,6 +24,7 @@ class MultipartReader extends events_1.EventEmitter {
|
|
|
24
24
|
this._stack = [];
|
|
25
25
|
this.setMaxListeners(1000);
|
|
26
26
|
this.tempDirectory = options?.tempDirectory || node_os_1.default.tmpdir();
|
|
27
|
+
this.scope = options?.scope;
|
|
27
28
|
const { request } = context;
|
|
28
29
|
const form = (0, busboy_1.default)({ headers: request.headers });
|
|
29
30
|
this._form = form;
|
|
@@ -103,6 +104,7 @@ class MultipartReader extends events_1.EventEmitter {
|
|
|
103
104
|
throw new common_1.BadRequestError(`Unknown multipart field (${item.field})`);
|
|
104
105
|
if (item.kind === 'field') {
|
|
105
106
|
const decode = field.generateCodec('decode', {
|
|
107
|
+
scope: this.scope,
|
|
106
108
|
ignoreReadonlyFields: true,
|
|
107
109
|
projection: '*',
|
|
108
110
|
});
|
package/esm/http-adapter.js
CHANGED
package/esm/http-context.js
CHANGED
package/esm/http-handler.js
CHANGED
|
@@ -124,8 +124,10 @@ export class HttpHandler {
|
|
|
124
124
|
let decode = this[kAssetCache].get(prm, 'decode');
|
|
125
125
|
if (!decode) {
|
|
126
126
|
decode =
|
|
127
|
-
prm.type?.generateCodec('decode', {
|
|
128
|
-
|
|
127
|
+
prm.type?.generateCodec('decode', {
|
|
128
|
+
scope: this.adapter.scope,
|
|
129
|
+
ignoreReadonlyFields: true,
|
|
130
|
+
}) || vg.isAny();
|
|
129
131
|
this[kAssetCache].set(prm, 'decode', decode);
|
|
130
132
|
}
|
|
131
133
|
return decode;
|
|
@@ -314,8 +316,8 @@ export class HttpHandler {
|
|
|
314
316
|
let operationResultEncoder = this[kAssetCache].get(operationResultType, 'encode');
|
|
315
317
|
if (!operationResultEncoder) {
|
|
316
318
|
operationResultEncoder = operationResultType.generateCodec('encode', {
|
|
319
|
+
scope: this.adapter.scope,
|
|
317
320
|
ignoreWriteonlyFields: true,
|
|
318
|
-
ignoreHiddenFields: true,
|
|
319
321
|
});
|
|
320
322
|
this[kAssetCache].set(operationResultType, 'encode', operationResultEncoder);
|
|
321
323
|
}
|
|
@@ -329,10 +331,10 @@ export class HttpHandler {
|
|
|
329
331
|
let encode = this[kAssetCache].get(operationResponse, 'encode:' + assetKey);
|
|
330
332
|
if (!encode) {
|
|
331
333
|
encode = operationResponse.type.generateCodec('encode', {
|
|
334
|
+
scope: this.adapter.scope,
|
|
332
335
|
partial: operationResponse.partial,
|
|
333
336
|
projection,
|
|
334
337
|
ignoreWriteonlyFields: true,
|
|
335
|
-
ignoreHiddenFields: true,
|
|
336
338
|
onFail: issue => `Response body validation failed: ` + issue.message,
|
|
337
339
|
});
|
|
338
340
|
if (operationResponse) {
|
|
@@ -450,7 +452,10 @@ export class HttpHandler {
|
|
|
450
452
|
const dt = document.node.getComplexType('OperationResult');
|
|
451
453
|
let encode = this[kAssetCache].get(dt, 'encode');
|
|
452
454
|
if (!encode) {
|
|
453
|
-
encode = dt.generateCodec('encode', {
|
|
455
|
+
encode = dt.generateCodec('encode', {
|
|
456
|
+
scope: this.adapter.scope,
|
|
457
|
+
ignoreWriteonlyFields: true,
|
|
458
|
+
});
|
|
454
459
|
this[kAssetCache].set(dt, 'encode', encode);
|
|
455
460
|
}
|
|
456
461
|
// const { i18n } = this.adapter;
|
|
@@ -20,6 +20,7 @@ export class MultipartReader extends EventEmitter {
|
|
|
20
20
|
this._stack = [];
|
|
21
21
|
this.setMaxListeners(1000);
|
|
22
22
|
this.tempDirectory = options?.tempDirectory || os.tmpdir();
|
|
23
|
+
this.scope = options?.scope;
|
|
23
24
|
const { request } = context;
|
|
24
25
|
const form = busboy({ headers: request.headers });
|
|
25
26
|
this._form = form;
|
|
@@ -99,6 +100,7 @@ export class MultipartReader extends EventEmitter {
|
|
|
99
100
|
throw new BadRequestError(`Unknown multipart field (${item.field})`);
|
|
100
101
|
if (item.kind === 'field') {
|
|
101
102
|
const decode = field.generateCodec('decode', {
|
|
103
|
+
scope: this.scope,
|
|
102
104
|
ignoreReadonlyFields: true,
|
|
103
105
|
projection: '*',
|
|
104
106
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/http",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Opra Http Server Adapter",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"@browsery/http-parser": "^0.5.9-r1",
|
|
10
10
|
"@browsery/type-is": "^1.6.18-r5",
|
|
11
11
|
"@jsopen/objects": "^1.5.0",
|
|
12
|
-
"@opra/common": "^1.
|
|
13
|
-
"@opra/core": "^1.
|
|
12
|
+
"@opra/common": "^1.5.1",
|
|
13
|
+
"@opra/core": "^1.5.1",
|
|
14
14
|
"accepts": "^1.3.8",
|
|
15
15
|
"base64-stream": "^1.0.0",
|
|
16
16
|
"busboy": "^1.6.0",
|
package/types/http-adapter.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare namespace HttpAdapter {
|
|
|
17
17
|
interface Options extends PlatformAdapter.Options {
|
|
18
18
|
basePath?: string;
|
|
19
19
|
interceptors?: (InterceptorFunction | IHttpInterceptor)[];
|
|
20
|
+
scope?: string;
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
@@ -27,6 +28,7 @@ export declare abstract class HttpAdapter extends PlatformAdapter {
|
|
|
27
28
|
readonly handler: HttpHandler;
|
|
28
29
|
readonly protocol: OpraSchema.Transport;
|
|
29
30
|
readonly basePath: string;
|
|
31
|
+
scope?: string;
|
|
30
32
|
interceptors: (HttpAdapter.InterceptorFunction | HttpAdapter.IHttpInterceptor)[];
|
|
31
33
|
protected constructor(options?: HttpAdapter.Options);
|
|
32
34
|
get api(): HttpApi;
|
|
@@ -6,6 +6,7 @@ import type { HttpContext } from '../http-context.js';
|
|
|
6
6
|
export declare namespace MultipartReader {
|
|
7
7
|
interface Options extends StrictOmit<busboy.BusboyConfig, 'headers'> {
|
|
8
8
|
tempDirectory?: string;
|
|
9
|
+
scope?: string;
|
|
9
10
|
}
|
|
10
11
|
interface FieldInfo {
|
|
11
12
|
kind: 'field';
|
|
@@ -34,6 +35,7 @@ export declare class MultipartReader extends EventEmitter {
|
|
|
34
35
|
protected _items: MultipartReader.Item[];
|
|
35
36
|
protected _stack: MultipartReader.Item[];
|
|
36
37
|
protected tempDirectory: string;
|
|
38
|
+
scope?: string;
|
|
37
39
|
constructor(context: HttpContext, options?: MultipartReader.Options, mediaType?: HttpMediaType | undefined);
|
|
38
40
|
get items(): MultipartReader.Item[];
|
|
39
41
|
getNext(): Promise<MultipartReader.Item | undefined>;
|