@opra/http 1.5.0 → 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.
@@ -16,6 +16,7 @@ class HttpAdapter extends core_1.PlatformAdapter {
16
16
  this.basePath = options?.basePath || '/';
17
17
  if (!this.basePath.startsWith('/'))
18
18
  this.basePath = '/' + this.basePath;
19
+ this.scope = options?.scope;
19
20
  }
20
21
  get api() {
21
22
  return this.document.httpApi;
@@ -98,6 +98,7 @@ class HttpContext extends core_1.ExecutionContext {
98
98
  if (!decode) {
99
99
  decode =
100
100
  mediaType.type?.generateCodec('decode', {
101
+ scope: this.adapter.scope,
101
102
  partial: operation?.requestBody?.partial,
102
103
  projection: '*',
103
104
  ignoreReadonlyFields: true,
@@ -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', { ignoreReadonlyFields: true }) ||
132
- valgen_1.vg.isAny();
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,7 +320,7 @@ class HttpHandler {
318
320
  let operationResultEncoder = this[core_1.kAssetCache].get(operationResultType, 'encode');
319
321
  if (!operationResultEncoder) {
320
322
  operationResultEncoder = operationResultType.generateCodec('encode', {
321
- scope: this.adapter.document.scopes,
323
+ scope: this.adapter.scope,
322
324
  ignoreWriteonlyFields: true,
323
325
  });
324
326
  this[core_1.kAssetCache].set(operationResultType, 'encode', operationResultEncoder);
@@ -333,7 +335,7 @@ 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', {
336
- scope: this.adapter.document.scopes,
338
+ scope: this.adapter.scope,
337
339
  partial: operationResponse.partial,
338
340
  projection,
339
341
  ignoreWriteonlyFields: true,
@@ -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', { ignoreWriteonlyFields: true });
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
  });
@@ -13,6 +13,7 @@ export class HttpAdapter extends PlatformAdapter {
13
13
  this.basePath = options?.basePath || '/';
14
14
  if (!this.basePath.startsWith('/'))
15
15
  this.basePath = '/' + this.basePath;
16
+ this.scope = options?.scope;
16
17
  }
17
18
  get api() {
18
19
  return this.document.httpApi;
@@ -94,6 +94,7 @@ export class HttpContext extends ExecutionContext {
94
94
  if (!decode) {
95
95
  decode =
96
96
  mediaType.type?.generateCodec('decode', {
97
+ scope: this.adapter.scope,
97
98
  partial: operation?.requestBody?.partial,
98
99
  projection: '*',
99
100
  ignoreReadonlyFields: true,
@@ -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', { ignoreReadonlyFields: true }) ||
128
- vg.isAny();
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,7 +316,7 @@ export class HttpHandler {
314
316
  let operationResultEncoder = this[kAssetCache].get(operationResultType, 'encode');
315
317
  if (!operationResultEncoder) {
316
318
  operationResultEncoder = operationResultType.generateCodec('encode', {
317
- scope: this.adapter.document.scopes,
319
+ scope: this.adapter.scope,
318
320
  ignoreWriteonlyFields: true,
319
321
  });
320
322
  this[kAssetCache].set(operationResultType, 'encode', operationResultEncoder);
@@ -329,7 +331,7 @@ export class HttpHandler {
329
331
  let encode = this[kAssetCache].get(operationResponse, 'encode:' + assetKey);
330
332
  if (!encode) {
331
333
  encode = operationResponse.type.generateCodec('encode', {
332
- scope: this.adapter.document.scopes,
334
+ scope: this.adapter.scope,
333
335
  partial: operationResponse.partial,
334
336
  projection,
335
337
  ignoreWriteonlyFields: true,
@@ -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', { ignoreWriteonlyFields: true });
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.5.0",
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.5.0",
13
- "@opra/core": "^1.5.0",
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",
@@ -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>;