@opra/core 0.33.13 → 1.0.0-alpha.10
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/augmentation/18n.augmentation.js +18 -5
- package/cjs/augmentation/http-controller.augmentation.js +25 -0
- package/cjs/constants.js +5 -0
- package/cjs/execution-context.js +24 -12
- package/cjs/{services → helpers}/logger.js +1 -2
- package/cjs/{services/api-service.js → helpers/service-base.js} +8 -8
- package/cjs/http/express-adapter.js +153 -0
- package/cjs/http/http-adapter.js +27 -0
- package/cjs/http/http-context.js +119 -0
- package/cjs/http/impl/asset-cache.js +21 -0
- package/cjs/http/impl/http-handler.js +584 -0
- package/cjs/http/{http-server-request.js → impl/http-incoming.host.js} +24 -49
- package/cjs/http/{http-server-response.js → impl/http-outgoing.host.js} +9 -28
- package/cjs/http/{helpers/multipart-helper.js → impl/multipart-reader.js} +23 -27
- package/cjs/http/impl/{http-incoming-message.host.js → node-incoming-message.host.js} +18 -57
- package/cjs/http/impl/{http-outgoing-message.host.js → node-outgoing-message.host.js} +11 -14
- package/cjs/http/interfaces/http-incoming.interface.js +25 -0
- package/cjs/http/interfaces/http-outgoing.interface.js +22 -0
- package/cjs/http/interfaces/node-incoming-message.interface.js +64 -0
- package/cjs/http/interfaces/node-outgoing-message.interface.js +15 -0
- package/cjs/http/utils/body-reader.js +217 -0
- package/cjs/http/{helpers → utils}/common.js +2 -1
- package/cjs/http/{helpers → utils}/convert-to-raw-headers.js +1 -2
- package/cjs/http/{helpers → utils}/match-known-fields.js +11 -9
- package/cjs/http/utils/wrap-exception.js +34 -0
- package/cjs/index.js +26 -26
- package/cjs/platform-adapter.js +21 -0
- package/cjs/type-guards.js +23 -0
- package/esm/augmentation/18n.augmentation.js +20 -7
- package/esm/augmentation/http-controller.augmentation.js +23 -0
- package/esm/constants.js +2 -0
- package/esm/execution-context.js +24 -13
- package/esm/{services → helpers}/logger.js +1 -2
- package/esm/{services/api-service.js → helpers/service-base.js} +6 -6
- package/esm/http/express-adapter.js +148 -0
- package/esm/http/http-adapter.js +23 -0
- package/esm/http/http-context.js +114 -0
- package/esm/http/impl/asset-cache.js +17 -0
- package/esm/http/impl/http-handler.js +579 -0
- package/esm/http/{http-server-request.js → impl/http-incoming.host.js} +20 -46
- package/esm/http/{http-server-response.js → impl/http-outgoing.host.js} +7 -27
- package/esm/http/{helpers/multipart-helper.js → impl/multipart-reader.js} +21 -25
- package/esm/http/impl/{http-incoming-message.host.js → node-incoming-message.host.js} +16 -55
- package/esm/http/impl/{http-outgoing-message.host.js → node-outgoing-message.host.js} +9 -12
- package/esm/http/interfaces/http-incoming.interface.js +22 -0
- package/esm/http/interfaces/http-outgoing.interface.js +19 -0
- package/esm/http/interfaces/node-incoming-message.interface.js +61 -0
- package/esm/http/interfaces/node-outgoing-message.interface.js +12 -0
- package/esm/http/utils/body-reader.js +212 -0
- package/esm/http/{helpers → utils}/common.js +2 -1
- package/esm/http/{helpers → utils}/convert-to-headers.js +1 -1
- package/esm/http/{helpers → utils}/convert-to-raw-headers.js +2 -3
- package/esm/http/{helpers → utils}/match-known-fields.js +11 -9
- package/esm/http/utils/wrap-exception.js +30 -0
- package/esm/index.js +26 -27
- package/esm/platform-adapter.js +19 -1
- package/esm/type-guards.js +16 -0
- package/package.json +31 -13
- package/types/augmentation/18n.augmentation.d.ts +31 -1
- package/types/augmentation/http-controller.augmentation.d.ts +21 -0
- package/types/constants.d.ts +2 -0
- package/types/execution-context.d.ts +22 -26
- package/types/helpers/service-base.d.ts +10 -0
- package/types/http/express-adapter.d.ts +13 -0
- package/types/http/http-adapter.d.ts +27 -0
- package/types/http/http-context.d.ts +44 -0
- package/types/http/impl/asset-cache.d.ts +5 -0
- package/types/http/impl/http-handler.d.ts +73 -0
- package/types/http/impl/http-incoming.host.d.ts +23 -0
- package/types/http/impl/http-outgoing.host.d.ts +17 -0
- package/types/http/{helpers/multipart-helper.d.ts → impl/multipart-reader.d.ts} +8 -6
- package/types/http/impl/{http-incoming-message.host.d.ts → node-incoming-message.host.d.ts} +10 -23
- package/types/http/impl/{http-outgoing-message.host.d.ts → node-outgoing-message.host.d.ts} +11 -27
- package/types/http/{http-server-request.d.ts → interfaces/http-incoming.interface.d.ts} +28 -17
- package/types/http/{http-server-response.d.ts → interfaces/http-outgoing.interface.d.ts} +17 -10
- package/types/http/interfaces/node-incoming-message.interface.d.ts +38 -0
- package/types/http/interfaces/node-outgoing-message.interface.d.ts +29 -0
- package/types/http/utils/body-reader.d.ts +41 -0
- package/types/http/utils/wrap-exception.d.ts +2 -0
- package/types/index.d.ts +25 -27
- package/types/platform-adapter.d.ts +20 -48
- package/types/type-guards.d.ts +8 -0
- package/cjs/augmentation/collection.augmentation.js +0 -2
- package/cjs/augmentation/container.augmentation.js +0 -2
- package/cjs/augmentation/resource.augmentation.js +0 -26
- package/cjs/augmentation/singleton.augmentation.js +0 -2
- package/cjs/augmentation/storage.augmentation.js +0 -2
- package/cjs/execution-context.host.js +0 -46
- package/cjs/http/adapters/express-adapter.host.js +0 -34
- package/cjs/http/adapters/express-adapter.js +0 -14
- package/cjs/http/adapters/node-http-adapter.host.js +0 -70
- package/cjs/http/adapters/node-http-adapter.js +0 -14
- package/cjs/http/helpers/json-body-loader.js +0 -29
- package/cjs/http/helpers/query-parsers.js +0 -16
- package/cjs/http/http-adapter-host.js +0 -715
- package/cjs/interfaces/interceptor.interface.js +0 -2
- package/cjs/interfaces/request-handler.interface.js +0 -2
- package/cjs/platform-adapter.host.js +0 -154
- package/cjs/request-context.js +0 -25
- package/cjs/request.host.js +0 -24
- package/cjs/request.js +0 -2
- package/cjs/response.host.js +0 -22
- package/cjs/response.js +0 -2
- package/esm/augmentation/collection.augmentation.js +0 -1
- package/esm/augmentation/container.augmentation.js +0 -1
- package/esm/augmentation/resource.augmentation.js +0 -24
- package/esm/augmentation/singleton.augmentation.js +0 -1
- package/esm/augmentation/storage.augmentation.js +0 -1
- package/esm/execution-context.host.js +0 -42
- package/esm/http/adapters/express-adapter.host.js +0 -30
- package/esm/http/adapters/express-adapter.js +0 -11
- package/esm/http/adapters/node-http-adapter.host.js +0 -65
- package/esm/http/adapters/node-http-adapter.js +0 -11
- package/esm/http/helpers/json-body-loader.js +0 -24
- package/esm/http/helpers/query-parsers.js +0 -12
- package/esm/http/http-adapter-host.js +0 -710
- package/esm/interfaces/interceptor.interface.js +0 -1
- package/esm/interfaces/request-handler.interface.js +0 -1
- package/esm/platform-adapter.host.js +0 -149
- package/esm/request-context.js +0 -22
- package/esm/request.host.js +0 -20
- package/esm/request.js +0 -1
- package/esm/response.host.js +0 -18
- package/esm/response.js +0 -1
- package/types/augmentation/collection.augmentation.d.ts +0 -146
- package/types/augmentation/container.augmentation.d.ts +0 -14
- package/types/augmentation/resource.augmentation.d.ts +0 -38
- package/types/augmentation/singleton.augmentation.d.ts +0 -83
- package/types/augmentation/storage.augmentation.d.ts +0 -50
- package/types/execution-context.host.d.ts +0 -25
- package/types/http/adapters/express-adapter.d.ts +0 -15
- package/types/http/adapters/express-adapter.host.d.ts +0 -12
- package/types/http/adapters/node-http-adapter.d.ts +0 -17
- package/types/http/adapters/node-http-adapter.host.d.ts +0 -19
- package/types/http/helpers/json-body-loader.d.ts +0 -5
- package/types/http/helpers/query-parsers.d.ts +0 -1
- package/types/http/http-adapter-host.d.ts +0 -34
- package/types/interfaces/interceptor.interface.d.ts +0 -2
- package/types/interfaces/request-handler.interface.d.ts +0 -4
- package/types/platform-adapter.host.d.ts +0 -43
- package/types/request-context.d.ts +0 -13
- package/types/request.d.ts +0 -14
- package/types/request.host.d.ts +0 -27
- package/types/response.d.ts +0 -22
- package/types/response.host.d.ts +0 -22
- package/types/services/api-service.d.ts +0 -10
- /package/cjs/http/{helpers → utils}/concat-readable.js +0 -0
- /package/cjs/http/{helpers → utils}/convert-to-headers.js +0 -0
- /package/esm/http/{helpers → utils}/concat-readable.js +0 -0
- /package/types/{services → helpers}/logger.d.ts +0 -0
- /package/types/http/{helpers → utils}/common.d.ts +0 -0
- /package/types/http/{helpers → utils}/concat-readable.d.ts +0 -0
- /package/types/http/{helpers → utils}/convert-to-headers.d.ts +0 -0
- /package/types/http/{helpers → utils}/convert-to-raw-headers.d.ts +0 -0
- /package/types/http/{helpers → utils}/match-known-fields.d.ts +0 -0
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Collection, OpraURLPath, Parameter, Resource, Singleton, Storage } from '@opra/common';
|
|
2
|
-
import { ExecutionContext } from '../execution-context.js';
|
|
3
|
-
import { PlatformAdapterHost } from '../platform-adapter.host.js';
|
|
4
|
-
import type { Protocol } from '../platform-adapter.js';
|
|
5
|
-
import { RequestHost } from '../request.host.js';
|
|
6
|
-
import { Request } from '../request.js';
|
|
7
|
-
import { RequestContext } from '../request-context.js';
|
|
8
|
-
import { HttpServerRequest } from './http-server-request.js';
|
|
9
|
-
import { HttpServerResponse } from './http-server-response.js';
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* @class HttpAdapterHost
|
|
13
|
-
*/
|
|
14
|
-
export declare abstract class HttpAdapterHost extends PlatformAdapterHost {
|
|
15
|
-
protected _protocol: Protocol;
|
|
16
|
-
protected _tempDir: string;
|
|
17
|
-
/**
|
|
18
|
-
* Main http request handler
|
|
19
|
-
* @param incoming
|
|
20
|
-
* @param outgoing
|
|
21
|
-
* @protected
|
|
22
|
-
*/
|
|
23
|
-
protected handleHttp(incoming: HttpServerRequest, outgoing: HttpServerResponse): Promise<void>;
|
|
24
|
-
handleExecution(executionContext: ExecutionContext): Promise<void>;
|
|
25
|
-
parseRequest(executionContext: ExecutionContext): Promise<Request>;
|
|
26
|
-
protected _parseRequestAction(executionContext: ExecutionContext, resource: Resource, urlPath: OpraURLPath, searchParams: URLSearchParams): Promise<RequestHost>;
|
|
27
|
-
protected _parseRequestCollection(executionContext: ExecutionContext, resource: Collection, urlPath: OpraURLPath, searchParams: URLSearchParams): Promise<RequestHost>;
|
|
28
|
-
protected _parseRequestSingleton(executionContext: ExecutionContext, resource: Singleton, urlPath: OpraURLPath, searchParams?: URLSearchParams): Promise<RequestHost>;
|
|
29
|
-
protected _parseRequestStorage(executionContext: ExecutionContext, resource: Storage, urlPath: OpraURLPath, searchParams: URLSearchParams): Promise<RequestHost>;
|
|
30
|
-
protected parseParameters(paramDefs: Map<string, Parameter>, searchParams?: URLSearchParams): Record<string, any>;
|
|
31
|
-
protected executeRequest(context: RequestContext): Promise<void>;
|
|
32
|
-
sendResponse(context: RequestContext): Promise<void>;
|
|
33
|
-
protected sendErrorResponse(context: ExecutionContext, errors: any[]): Promise<void>;
|
|
34
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import './augmentation/18n.augmentation.js';
|
|
2
|
-
import { AsyncEventEmitter } from 'strict-typed-events';
|
|
3
|
-
import { Action, ApiDocument, CrudOperation, I18n, Resource } from '@opra/common';
|
|
4
|
-
import { ExecutionContext } from './execution-context.js';
|
|
5
|
-
import { Interceptor } from './interfaces/interceptor.interface.js';
|
|
6
|
-
import type { PlatformAdapter, Protocol } from './platform-adapter.js';
|
|
7
|
-
import { Logger } from './services/logger.js';
|
|
8
|
-
/**
|
|
9
|
-
* @class PlatformAdapterHost
|
|
10
|
-
*/
|
|
11
|
-
export declare abstract class PlatformAdapterHost extends AsyncEventEmitter implements PlatformAdapter {
|
|
12
|
-
protected _api: ApiDocument;
|
|
13
|
-
protected _controllers: Map<Resource, any>;
|
|
14
|
-
protected _protocol: Protocol;
|
|
15
|
-
protected _platform: string;
|
|
16
|
-
protected _serviceName: string;
|
|
17
|
-
protected _i18n: I18n;
|
|
18
|
-
protected _logger: Logger;
|
|
19
|
-
protected _interceptors: Interceptor[];
|
|
20
|
-
get api(): ApiDocument;
|
|
21
|
-
get platform(): string;
|
|
22
|
-
get protocol(): Protocol;
|
|
23
|
-
get serviceName(): string;
|
|
24
|
-
get i18n(): I18n;
|
|
25
|
-
close(): Promise<void>;
|
|
26
|
-
/**
|
|
27
|
-
* Initializes the adapter
|
|
28
|
-
*/
|
|
29
|
-
protected init(api: ApiDocument, options?: PlatformAdapter.Options): Promise<void>;
|
|
30
|
-
getController(resource: Resource | string): Promise<any>;
|
|
31
|
-
getActionHandler(resource: Resource | string, name: string): Promise<{
|
|
32
|
-
endpoint: Action;
|
|
33
|
-
controller: any;
|
|
34
|
-
handler: Function;
|
|
35
|
-
}>;
|
|
36
|
-
getOperationHandler(resource: Resource | string, name: string): Promise<{
|
|
37
|
-
endpoint: CrudOperation;
|
|
38
|
-
controller: any;
|
|
39
|
-
handler: Function;
|
|
40
|
-
}>;
|
|
41
|
-
protected _createI18n(options?: PlatformAdapter.I18nOptions): Promise<I18n>;
|
|
42
|
-
abstract handleExecution(executionContext: ExecutionContext): Promise<void>;
|
|
43
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ApiDocument } from '@opra/common';
|
|
2
|
-
import { ExecutionContext } from './execution-context.js';
|
|
3
|
-
import type { Request } from './request.js';
|
|
4
|
-
import type { Response } from './response.js';
|
|
5
|
-
export interface RequestContext extends ExecutionContext {
|
|
6
|
-
request: Request;
|
|
7
|
-
response: Response;
|
|
8
|
-
api: ApiDocument;
|
|
9
|
-
}
|
|
10
|
-
export declare namespace RequestContext {
|
|
11
|
-
function from(executionContext: ExecutionContext, api: ApiDocument, request: Request, response: Response): RequestContext;
|
|
12
|
-
function is(v: any): v is RequestContext;
|
|
13
|
-
}
|
package/types/request.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Action, CrudOperation, Resource } from '@opra/common';
|
|
2
|
-
import { HttpServerRequest } from './http/http-server-request.js';
|
|
3
|
-
export interface Request {
|
|
4
|
-
resource: Resource;
|
|
5
|
-
endpoint: Action | CrudOperation;
|
|
6
|
-
key?: any;
|
|
7
|
-
controller: Object;
|
|
8
|
-
handler: Function;
|
|
9
|
-
contentId?: string;
|
|
10
|
-
params: Record<string, any>;
|
|
11
|
-
switchToHttp(): HttpServerRequest;
|
|
12
|
-
switchToWs(): never;
|
|
13
|
-
switchToRpc(): never;
|
|
14
|
-
}
|
package/types/request.host.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { PartialSome, StrictOmit } from 'ts-gems';
|
|
2
|
-
import type { Resource } from '@opra/common';
|
|
3
|
-
import { Action, CrudOperation } from '@opra/common';
|
|
4
|
-
import type { HttpServerRequest } from './http/http-server-request.js';
|
|
5
|
-
import type { Request } from './request.js';
|
|
6
|
-
export declare namespace RequestHost {
|
|
7
|
-
interface Initiator extends PartialSome<StrictOmit<Request, 'resource' | 'switchToHttp' | 'switchToWs' | 'switchToRpc'>, 'params'> {
|
|
8
|
-
controller: Object;
|
|
9
|
-
handler: Function;
|
|
10
|
-
http?: HttpServerRequest;
|
|
11
|
-
[key: string]: any;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export interface RequestHost extends Request {
|
|
15
|
-
}
|
|
16
|
-
export declare class RequestHost implements Request {
|
|
17
|
-
controller: any;
|
|
18
|
-
endpoint: Action | CrudOperation;
|
|
19
|
-
http?: HttpServerRequest;
|
|
20
|
-
key?: any;
|
|
21
|
-
params: Record<string, any>;
|
|
22
|
-
constructor(init: RequestHost.Initiator);
|
|
23
|
-
get resource(): Resource;
|
|
24
|
-
switchToHttp(): HttpServerRequest;
|
|
25
|
-
switchToWs(): never;
|
|
26
|
-
switchToRpc(): never;
|
|
27
|
-
}
|
package/types/response.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { HttpServerResponse } from './http/http-server-response.js';
|
|
2
|
-
export interface Response {
|
|
3
|
-
/**
|
|
4
|
-
* Result value
|
|
5
|
-
*/
|
|
6
|
-
value?: any;
|
|
7
|
-
/**
|
|
8
|
-
* List of errors
|
|
9
|
-
*/
|
|
10
|
-
errors: any[];
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
continueOnError?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Total count of matched entities. (Used in "search" endpoint with "count" option
|
|
17
|
-
*/
|
|
18
|
-
totalMatches?: number;
|
|
19
|
-
switchToHttp(): HttpServerResponse;
|
|
20
|
-
switchToWs(): never;
|
|
21
|
-
switchToRpc(): never;
|
|
22
|
-
}
|
package/types/response.host.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { HttpServerResponse } from './http/http-server-response.js';
|
|
2
|
-
import type { Response } from './response.js';
|
|
3
|
-
export declare namespace ResponseHost {
|
|
4
|
-
interface Initiator {
|
|
5
|
-
value?: any;
|
|
6
|
-
errors?: Error[];
|
|
7
|
-
continueOnError?: boolean;
|
|
8
|
-
count?: number;
|
|
9
|
-
http?: HttpServerResponse;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export declare class ResponseHost implements Response {
|
|
13
|
-
value?: any;
|
|
14
|
-
errors: Error[];
|
|
15
|
-
continueOnError?: boolean;
|
|
16
|
-
count?: number;
|
|
17
|
-
http?: HttpServerResponse;
|
|
18
|
-
constructor(init: ResponseHost.Initiator);
|
|
19
|
-
switchToHttp(): HttpServerResponse;
|
|
20
|
-
switchToWs(): never;
|
|
21
|
-
switchToRpc(): never;
|
|
22
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Nullish } from 'ts-gems';
|
|
2
|
-
import { RequestContext } from '../request-context.js';
|
|
3
|
-
export declare abstract class ApiService {
|
|
4
|
-
protected _context: RequestContext;
|
|
5
|
-
get context(): RequestContext;
|
|
6
|
-
for<C extends RequestContext, P extends Partial<this>>(context: C, overwriteProperties?: Nullish<P>, overwriteContext?: Partial<C>): this & Required<P>;
|
|
7
|
-
}
|
|
8
|
-
export declare namespace ApiService {
|
|
9
|
-
const extendSymbol: unique symbol;
|
|
10
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|