@opra/core 0.25.0 → 0.25.2

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.
@@ -7,7 +7,7 @@ var EndpointContext;
7
7
  const out = {
8
8
  request,
9
9
  response,
10
- requestScope: {}
10
+ session: {}
11
11
  };
12
12
  Object.setPrototypeOf(out, executionContext);
13
13
  return out;
@@ -8,7 +8,7 @@ class ExecutionContextHost extends strict_typed_events_1.AsyncEventEmitter {
8
8
  this.api = api;
9
9
  this.platform = platform;
10
10
  this.errors = [];
11
- this.executionScope = {};
11
+ this.session = {};
12
12
  this.ws = protocol.ws;
13
13
  this.rpc = protocol.rpc;
14
14
  if (protocol.http) {
@@ -160,8 +160,7 @@ class EntityRequestHandler extends request_handler_base_js_1.RequestHandlerBase
160
160
  outgoing.end();
161
161
  }
162
162
  async parseCollectionRequest(resource, incoming) {
163
- if ((incoming.method === 'POST' || incoming.method === 'PATCH') &&
164
- incoming.headers['content-type'] !== 'application/json')
163
+ if ((incoming.method === 'POST' || incoming.method === 'PATCH') && !incoming.is('json'))
165
164
  throw new common_1.BadRequestError({ message: 'Unsupported Content-Type' });
166
165
  const contentId = incoming.headers['content-id'];
167
166
  const p = incoming.parsedUrl.path[0];
@@ -4,7 +4,7 @@ export var EndpointContext;
4
4
  const out = {
5
5
  request,
6
6
  response,
7
- requestScope: {}
7
+ session: {}
8
8
  };
9
9
  Object.setPrototypeOf(out, executionContext);
10
10
  return out;
@@ -5,7 +5,7 @@ export class ExecutionContextHost extends AsyncEventEmitter {
5
5
  this.api = api;
6
6
  this.platform = platform;
7
7
  this.errors = [];
8
- this.executionScope = {};
8
+ this.session = {};
9
9
  this.ws = protocol.ws;
10
10
  this.rpc = protocol.rpc;
11
11
  if (protocol.http) {
@@ -156,8 +156,7 @@ export class EntityRequestHandler extends RequestHandlerBase {
156
156
  outgoing.end();
157
157
  }
158
158
  async parseCollectionRequest(resource, incoming) {
159
- if ((incoming.method === 'POST' || incoming.method === 'PATCH') &&
160
- incoming.headers['content-type'] !== 'application/json')
159
+ if ((incoming.method === 'POST' || incoming.method === 'PATCH') && !incoming.is('json'))
161
160
  throw new BadRequestError({ message: 'Unsupported Content-Type' });
162
161
  const contentId = incoming.headers['content-id'];
163
162
  const p = incoming.parsedUrl.path[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/core",
3
- "version": "0.25.0",
3
+ "version": "0.25.2",
4
4
  "description": "Opra schema package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -27,7 +27,7 @@
27
27
  "clean:cover": "rimraf ../../coverage/core"
28
28
  },
29
29
  "dependencies": {
30
- "@opra/common": "^0.25.0",
30
+ "@opra/common": "^0.25.1",
31
31
  "accepts": "^1.3.8",
32
32
  "content-disposition": "^0.5.4",
33
33
  "content-type": "^1.0.5",
@@ -94,4 +94,4 @@
94
94
  "swagger",
95
95
  "raml"
96
96
  ]
97
- }
97
+ }
@@ -1,11 +1,10 @@
1
1
  import type { ExecutionContext } from './execution-context';
2
2
  import type { Request } from './request';
3
3
  import type { Response } from './response';
4
- export interface EndpointContext<TRequest extends Request = Request, TResponse extends Response = Response> extends ExecutionContext {
5
- request: TRequest;
6
- response: TResponse;
7
- requestScope: Record<string | number | symbol, any>;
4
+ export interface EndpointContext<TSpace extends object = Record<string | number | symbol, any>> extends ExecutionContext<TSpace> {
5
+ request: Request;
6
+ response: Response;
8
7
  }
9
8
  export declare namespace EndpointContext {
10
- function from<TRequest extends Request = Request, TResponse extends Response = Response>(executionContext: ExecutionContext, request: TRequest, response: TResponse): EndpointContext;
9
+ function from(executionContext: ExecutionContext, request: Request, response: Response): EndpointContext;
11
10
  }
@@ -1,22 +1,22 @@
1
1
  import type { HttpServerRequest } from './http/http-server-request';
2
2
  import type { HttpServerResponse } from './http/http-server-response';
3
3
  import type { Protocol } from './platform-adapter';
4
- export declare namespace ExecutionContext {
5
- type OnFinishArgs = {
6
- context: ExecutionContext;
7
- failed: boolean;
8
- };
9
- }
10
- export interface ExecutionContext {
4
+ export interface ExecutionContext<TSession extends {} = {}> {
11
5
  readonly protocol: Protocol;
12
6
  readonly platform: string;
7
+ session: TSession;
13
8
  errors: Error[];
14
- executionScope: Record<string | number | symbol, any>;
15
9
  switchToHttp(): HttpMessageContext;
16
10
  switchToWs(): WsMessageContext;
17
11
  switchToRpc(): RpcMessageContext;
18
12
  on(event: 'finish', fn: (args: ExecutionContext.OnFinishArgs) => void | Promise<void>): any;
19
13
  }
14
+ export declare namespace ExecutionContext {
15
+ type OnFinishArgs = {
16
+ context: ExecutionContext;
17
+ failed: boolean;
18
+ };
19
+ }
20
20
  export interface HttpMessageContext {
21
21
  readonly platform: string;
22
22
  readonly incoming: HttpServerRequest;
@@ -4,7 +4,7 @@ import type { HttpServerResponse } from './/http/http-server-response.js';
4
4
  import type { ExecutionContext, HttpMessageContext, RpcMessageContext, WsMessageContext } from './execution-context.js';
5
5
  import type { HttpServerRequest } from './http/http-server-request.js';
6
6
  import { Protocol } from './platform-adapter.js';
7
- export declare class ExecutionContextHost extends AsyncEventEmitter implements ExecutionContext {
7
+ export declare class ExecutionContextHost<TSession extends {} = {}> extends AsyncEventEmitter implements ExecutionContext<TSession> {
8
8
  readonly api: ApiDocument;
9
9
  readonly platform: string;
10
10
  readonly protocol: Protocol;
@@ -12,7 +12,7 @@ export declare class ExecutionContextHost extends AsyncEventEmitter implements E
12
12
  readonly ws?: WsMessageContext;
13
13
  readonly rpc?: RpcMessageContext;
14
14
  errors: Error[];
15
- executionScope: Record<string | number | symbol, any>;
15
+ session: TSession;
16
16
  constructor(api: ApiDocument, platform: string, protocol: {
17
17
  http?: {
18
18
  incoming: HttpServerRequest;