@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.
- package/cjs/adapter/endpoint-context.js +1 -1
- package/cjs/adapter/execution-context.host.js +1 -1
- package/cjs/adapter/http/request-handlers/entity-request-handler.js +1 -2
- package/esm/adapter/endpoint-context.js +1 -1
- package/esm/adapter/execution-context.host.js +1 -1
- package/esm/adapter/http/request-handlers/entity-request-handler.js +1 -2
- package/package.json +3 -3
- package/types/adapter/endpoint-context.d.ts +4 -5
- package/types/adapter/execution-context.d.ts +8 -8
- package/types/adapter/execution-context.host.d.ts +2 -2
|
@@ -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.
|
|
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];
|
|
@@ -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.
|
|
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.
|
|
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<
|
|
5
|
-
request:
|
|
6
|
-
response:
|
|
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
|
|
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
|
|
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
|
-
|
|
15
|
+
session: TSession;
|
|
16
16
|
constructor(api: ApiDocument, platform: string, protocol: {
|
|
17
17
|
http?: {
|
|
18
18
|
incoming: HttpServerRequest;
|