@opra/core 1.26.3 → 1.27.0
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/README.md +24 -1
- package/asset-cache.d.ts +25 -0
- package/asset-cache.js +25 -0
- package/execution-context.d.ts +20 -2
- package/execution-context.js +12 -1
- package/interfaces/logger.interface.d.ts +47 -0
- package/package.json +2 -2
- package/platform-adapter.d.ts +33 -2
- package/platform-adapter.js +20 -1
- package/service-base.d.ts +38 -0
- package/service-base.js +36 -2
package/README.md
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
1
|
# @opra/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[![NPM Version][npm-image]][npm-url]
|
|
4
|
+
[![NPM Downloads][downloads-image]][downloads-url]
|
|
5
|
+
[![CI Tests][ci-test-image]][ci-test-url]
|
|
6
|
+
[![Test Coverage][coveralls-image]][coveralls-url]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## Support
|
|
10
|
+
You can report bugs and discuss features on the [GitHub issues](https://github.com/panates/opra/issues) page.
|
|
11
|
+
|
|
12
|
+
## Node Compatibility
|
|
13
|
+
- node >= 20.x
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## License
|
|
17
|
+
Available under [MIT](LICENSE) license.
|
|
18
|
+
|
|
19
|
+
[npm-image]: https://img.shields.io/npm/v/@opra/core
|
|
20
|
+
[npm-url]: https://npmjs.org/package/@opra/core
|
|
21
|
+
[downloads-image]: https://img.shields.io/npm/dm/@opra/core.svg
|
|
22
|
+
[downloads-url]: https://npmjs.org/package/@opra/core
|
|
23
|
+
[ci-test-image]: https://github.com/panates/opra/actions/workflows/test.yml/badge.svg
|
|
24
|
+
[ci-test-url]: https://github.com/panates/opra/actions/workflows/test.yml
|
|
25
|
+
[coveralls-image]: https://coveralls.io/repos/github/panates/opra/badge.svg?branch=main
|
|
26
|
+
[coveralls-url]: https://coveralls.io/github/panates/opra?branch=main
|
package/asset-cache.d.ts
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AssetCache is a utility class for caching assets associated with objects.
|
|
3
|
+
* It uses a WeakMap to store assets, ensuring that they are garbage collected
|
|
4
|
+
* when the objects themselves are no longer referenced.
|
|
5
|
+
*/
|
|
1
6
|
export declare class AssetCache {
|
|
2
7
|
protected _items: WeakMap<any, Record<string, any>>;
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves an asset from the cache for a given object and asset name.
|
|
10
|
+
*
|
|
11
|
+
* @param obj - The object associated with the asset.
|
|
12
|
+
* @param name - The name of the asset.
|
|
13
|
+
* @returns The cached asset, or undefined if not found.
|
|
14
|
+
*/
|
|
3
15
|
get<T>(obj: any, name: string): T | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Stores an asset in the cache for a given object and asset name.
|
|
18
|
+
*
|
|
19
|
+
* @param obj - The object to associate with the asset.
|
|
20
|
+
* @param name - The name of the asset.
|
|
21
|
+
* @param asset - The asset to be cached.
|
|
22
|
+
*/
|
|
4
23
|
set(obj: any, name: string, asset: any): void;
|
|
24
|
+
/**
|
|
25
|
+
* Removes an asset from the cache for a given object and asset name.
|
|
26
|
+
*
|
|
27
|
+
* @param obj - The object associated with the asset.
|
|
28
|
+
* @param name - The name of the asset to be removed.
|
|
29
|
+
*/
|
|
5
30
|
delete(obj: any, name: string): void;
|
|
6
31
|
}
|
package/asset-cache.js
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AssetCache is a utility class for caching assets associated with objects.
|
|
3
|
+
* It uses a WeakMap to store assets, ensuring that they are garbage collected
|
|
4
|
+
* when the objects themselves are no longer referenced.
|
|
5
|
+
*/
|
|
1
6
|
export class AssetCache {
|
|
2
7
|
_items = new WeakMap();
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves an asset from the cache for a given object and asset name.
|
|
10
|
+
*
|
|
11
|
+
* @param obj - The object associated with the asset.
|
|
12
|
+
* @param name - The name of the asset.
|
|
13
|
+
* @returns The cached asset, or undefined if not found.
|
|
14
|
+
*/
|
|
3
15
|
get(obj, name) {
|
|
4
16
|
const cache = this._items.get(obj);
|
|
5
17
|
return cache && cache[name];
|
|
6
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Stores an asset in the cache for a given object and asset name.
|
|
21
|
+
*
|
|
22
|
+
* @param obj - The object to associate with the asset.
|
|
23
|
+
* @param name - The name of the asset.
|
|
24
|
+
* @param asset - The asset to be cached.
|
|
25
|
+
*/
|
|
7
26
|
set(obj, name, asset) {
|
|
8
27
|
let cache = this._items.get(obj);
|
|
9
28
|
if (!cache) {
|
|
@@ -12,6 +31,12 @@ export class AssetCache {
|
|
|
12
31
|
}
|
|
13
32
|
cache[name] = asset;
|
|
14
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Removes an asset from the cache for a given object and asset name.
|
|
36
|
+
*
|
|
37
|
+
* @param obj - The object associated with the asset.
|
|
38
|
+
* @param name - The name of the asset to be removed.
|
|
39
|
+
*/
|
|
15
40
|
delete(obj, name) {
|
|
16
41
|
const cache = this._items.get(obj);
|
|
17
42
|
if (!cache)
|
package/execution-context.d.ts
CHANGED
|
@@ -2,24 +2,42 @@ import { DocumentNode, OpraSchema } from '@opra/common';
|
|
|
2
2
|
import { AsyncEventEmitter } from 'node-events-async';
|
|
3
3
|
import type { PlatformAdapter } from './platform-adapter.js';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* ExecutionContext provides a context for executing operations within an adapter.
|
|
6
|
+
* It carries information about the document node, adapter, transport, and platform.
|
|
6
7
|
*/
|
|
7
8
|
export declare class ExecutionContext extends AsyncEventEmitter {
|
|
9
|
+
/** The document node associated with this context */
|
|
8
10
|
readonly __docNode: DocumentNode;
|
|
11
|
+
/** The platform adapter that created this context */
|
|
9
12
|
readonly __adapter: PlatformAdapter;
|
|
13
|
+
/** The transport protocol being used (e.g., 'http', 'socketio') */
|
|
10
14
|
readonly transport?: OpraSchema.Transport;
|
|
15
|
+
/** The platform name (e.g., 'express', 'koa') */
|
|
11
16
|
readonly platform: string;
|
|
17
|
+
/** A collection of errors encountered during execution */
|
|
12
18
|
errors: Error[];
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new ExecutionContext instance.
|
|
21
|
+
*
|
|
22
|
+
* @param init - The initialization parameters for the context.
|
|
23
|
+
*/
|
|
13
24
|
constructor(init: ExecutionContext.Initiator);
|
|
14
25
|
}
|
|
15
26
|
/**
|
|
16
|
-
* @
|
|
27
|
+
* Namespace for {@link ExecutionContext} related types and interfaces.
|
|
17
28
|
*/
|
|
18
29
|
export declare namespace ExecutionContext {
|
|
30
|
+
/**
|
|
31
|
+
* Initialization parameters for creating an {@link ExecutionContext}.
|
|
32
|
+
*/
|
|
19
33
|
interface Initiator {
|
|
34
|
+
/** The platform adapter */
|
|
20
35
|
__adapter: PlatformAdapter;
|
|
36
|
+
/** The document node */
|
|
21
37
|
__docNode: DocumentNode;
|
|
38
|
+
/** The transport protocol */
|
|
22
39
|
transport?: OpraSchema.Transport;
|
|
40
|
+
/** The platform name */
|
|
23
41
|
platform?: string;
|
|
24
42
|
}
|
|
25
43
|
}
|
package/execution-context.js
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import { AsyncEventEmitter } from 'node-events-async';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* ExecutionContext provides a context for executing operations within an adapter.
|
|
4
|
+
* It carries information about the document node, adapter, transport, and platform.
|
|
4
5
|
*/
|
|
5
6
|
export class ExecutionContext extends AsyncEventEmitter {
|
|
7
|
+
/** The document node associated with this context */
|
|
6
8
|
__docNode;
|
|
9
|
+
/** The platform adapter that created this context */
|
|
7
10
|
__adapter;
|
|
11
|
+
/** The transport protocol being used (e.g., 'http', 'socketio') */
|
|
8
12
|
transport;
|
|
13
|
+
/** The platform name (e.g., 'express', 'koa') */
|
|
9
14
|
platform = '';
|
|
15
|
+
/** A collection of errors encountered during execution */
|
|
10
16
|
errors = [];
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new ExecutionContext instance.
|
|
19
|
+
*
|
|
20
|
+
* @param init - The initialization parameters for the context.
|
|
21
|
+
*/
|
|
11
22
|
constructor(init) {
|
|
12
23
|
super();
|
|
13
24
|
this.__adapter = init.__adapter;
|
|
@@ -1,9 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for logging services used within the OPRA framework.
|
|
3
|
+
* This interface defines standard logging methods that can be implemented
|
|
4
|
+
* by various logging providers (e.g., Winston, Pino, or a simple console logger).
|
|
5
|
+
*/
|
|
1
6
|
export interface ILogger {
|
|
7
|
+
/**
|
|
8
|
+
* Logs an error message.
|
|
9
|
+
*
|
|
10
|
+
* @param message - The error message or object.
|
|
11
|
+
* @param optionalParams - Additional parameters for formatting the message.
|
|
12
|
+
*/
|
|
2
13
|
error(message: any, ...optionalParams: any[]): void;
|
|
14
|
+
/**
|
|
15
|
+
* Logs a general log message.
|
|
16
|
+
*
|
|
17
|
+
* @param message - The message or object.
|
|
18
|
+
* @param optionalParams - Additional parameters for formatting the message.
|
|
19
|
+
*/
|
|
3
20
|
log?(message: any, ...optionalParams: any[]): void;
|
|
21
|
+
/**
|
|
22
|
+
* Logs an informational message.
|
|
23
|
+
*
|
|
24
|
+
* @param message - The message or object.
|
|
25
|
+
* @param optionalParams - Additional parameters for formatting the message.
|
|
26
|
+
*/
|
|
4
27
|
info?(message: any, ...optionalParams: any[]): void;
|
|
28
|
+
/**
|
|
29
|
+
* Logs a warning message.
|
|
30
|
+
*
|
|
31
|
+
* @param message - The message or object.
|
|
32
|
+
* @param optionalParams - Additional parameters for formatting the message.
|
|
33
|
+
*/
|
|
5
34
|
warn?(message: any, ...optionalParams: any[]): void;
|
|
35
|
+
/**
|
|
36
|
+
* Logs a fatal error message.
|
|
37
|
+
*
|
|
38
|
+
* @param message - The message or object.
|
|
39
|
+
* @param optionalParams - Additional parameters for formatting the message.
|
|
40
|
+
*/
|
|
6
41
|
fatal?(message: any, ...optionalParams: any[]): void;
|
|
42
|
+
/**
|
|
43
|
+
* Logs a debug message.
|
|
44
|
+
*
|
|
45
|
+
* @param message - The message or object.
|
|
46
|
+
* @param optionalParams - Additional parameters for formatting the message.
|
|
47
|
+
*/
|
|
7
48
|
debug?(message: any, ...optionalParams: any[]): void;
|
|
49
|
+
/**
|
|
50
|
+
* Logs a verbose message.
|
|
51
|
+
*
|
|
52
|
+
* @param message - The message or object.
|
|
53
|
+
* @param optionalParams - Additional parameters for formatting the message.
|
|
54
|
+
*/
|
|
8
55
|
verbose?(message: any, ...optionalParams: any[]): void;
|
|
9
56
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.27.0",
|
|
4
4
|
"description": "Opra schema package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"tslib": "^2.8.1"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"@opra/common": "^1.
|
|
13
|
+
"@opra/common": "^1.27.0"
|
|
14
14
|
},
|
|
15
15
|
"type": "module",
|
|
16
16
|
"module": "./index.js",
|
package/platform-adapter.d.ts
CHANGED
|
@@ -6,26 +6,57 @@ import { kAssetCache } from './constants.js';
|
|
|
6
6
|
import { ExecutionContext } from './execution-context.js';
|
|
7
7
|
import { ILogger } from './interfaces/logger.interface.js';
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Base class for all platform adapters in the OPRA framework.
|
|
10
|
+
* A platform adapter bridge between a specific platform (like Express, Socket.io, etc.)
|
|
11
|
+
* and the OPRA application logic.
|
|
12
|
+
*
|
|
13
|
+
* @typeParam T - The event map type for the adapter.
|
|
10
14
|
*/
|
|
11
15
|
export declare abstract class PlatformAdapter<T extends EventMap<T> = never> extends AsyncEventEmitter<T> {
|
|
12
16
|
protected [kAssetCache]: AssetCache;
|
|
13
17
|
protected _document: ApiDocument;
|
|
18
|
+
/** The transport protocol supported by this adapter */
|
|
14
19
|
abstract readonly transform: OpraSchema.Transport;
|
|
20
|
+
/** The platform name of this adapter */
|
|
15
21
|
abstract readonly platform: string;
|
|
22
|
+
/** Internationalization service instance */
|
|
16
23
|
i18n: I18n;
|
|
24
|
+
/** Logger instance for the adapter */
|
|
17
25
|
logger?: ILogger;
|
|
26
|
+
/**
|
|
27
|
+
* Initializes the platform adapter.
|
|
28
|
+
*
|
|
29
|
+
* @param options - Configuration options for the adapter.
|
|
30
|
+
*/
|
|
18
31
|
protected constructor(options?: PlatformAdapter.Options);
|
|
32
|
+
/**
|
|
33
|
+
* Returns the API document associated with this adapter.
|
|
34
|
+
*/
|
|
19
35
|
get document(): ApiDocument;
|
|
36
|
+
/**
|
|
37
|
+
* Closes the adapter and releases any resources.
|
|
38
|
+
*
|
|
39
|
+
* @returns A promise that resolves when the adapter is closed.
|
|
40
|
+
*/
|
|
20
41
|
abstract close(): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a root execution context for the adapter.
|
|
44
|
+
*
|
|
45
|
+
* @returns A new {@link ExecutionContext} instance.
|
|
46
|
+
*/
|
|
21
47
|
createRootContext(): ExecutionContext;
|
|
22
48
|
}
|
|
23
49
|
/**
|
|
24
|
-
* @
|
|
50
|
+
* Namespace for {@link PlatformAdapter} related types and interfaces.
|
|
25
51
|
*/
|
|
26
52
|
export declare namespace PlatformAdapter {
|
|
53
|
+
/**
|
|
54
|
+
* Configuration options for {@link PlatformAdapter}.
|
|
55
|
+
*/
|
|
27
56
|
interface Options {
|
|
57
|
+
/** The internationalization instance to use */
|
|
28
58
|
i18n?: I18n;
|
|
59
|
+
/** The logger instance to use */
|
|
29
60
|
logger?: ILogger;
|
|
30
61
|
}
|
|
31
62
|
}
|
package/platform-adapter.js
CHANGED
|
@@ -5,21 +5,40 @@ import { AssetCache } from './asset-cache.js';
|
|
|
5
5
|
import { kAssetCache } from './constants.js';
|
|
6
6
|
import { ExecutionContext } from './execution-context.js';
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Base class for all platform adapters in the OPRA framework.
|
|
9
|
+
* A platform adapter bridge between a specific platform (like Express, Socket.io, etc.)
|
|
10
|
+
* and the OPRA application logic.
|
|
11
|
+
*
|
|
12
|
+
* @typeParam T - The event map type for the adapter.
|
|
9
13
|
*/
|
|
10
14
|
export class PlatformAdapter extends AsyncEventEmitter {
|
|
11
15
|
[kAssetCache];
|
|
16
|
+
/** Internationalization service instance */
|
|
12
17
|
i18n;
|
|
18
|
+
/** Logger instance for the adapter */
|
|
13
19
|
logger;
|
|
20
|
+
/**
|
|
21
|
+
* Initializes the platform adapter.
|
|
22
|
+
*
|
|
23
|
+
* @param options - Configuration options for the adapter.
|
|
24
|
+
*/
|
|
14
25
|
constructor(options) {
|
|
15
26
|
super();
|
|
16
27
|
this[kAssetCache] = new AssetCache();
|
|
17
28
|
this.i18n = options?.i18n || I18n.defaultInstance;
|
|
18
29
|
this.logger = options?.logger;
|
|
19
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns the API document associated with this adapter.
|
|
33
|
+
*/
|
|
20
34
|
get document() {
|
|
21
35
|
return this._document;
|
|
22
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Creates a root execution context for the adapter.
|
|
39
|
+
*
|
|
40
|
+
* @returns A new {@link ExecutionContext} instance.
|
|
41
|
+
*/
|
|
23
42
|
createRootContext() {
|
|
24
43
|
return new ExecutionContext({
|
|
25
44
|
__adapter: this,
|
package/service-base.d.ts
CHANGED
|
@@ -1,15 +1,53 @@
|
|
|
1
1
|
import type { Nullish } from 'ts-gems';
|
|
2
2
|
import type { ExecutionContext } from './execution-context.js';
|
|
3
|
+
/**
|
|
4
|
+
* Base class for services in the OPRA framework.
|
|
5
|
+
* Provides access to the {@link ExecutionContext} and allows creating new
|
|
6
|
+
* service instances with modified context or properties.
|
|
7
|
+
*/
|
|
3
8
|
export declare abstract class ServiceBase {
|
|
4
9
|
protected _context?: ExecutionContext;
|
|
10
|
+
/**
|
|
11
|
+
* Initializes the service with optional configuration.
|
|
12
|
+
*
|
|
13
|
+
* @param options - Configuration options for the service.
|
|
14
|
+
*/
|
|
5
15
|
constructor(options?: ServiceBase.Options);
|
|
16
|
+
/**
|
|
17
|
+
* Returns the execution context associated with this service.
|
|
18
|
+
*
|
|
19
|
+
* @throws {@link Error} if no context is assigned to the service.
|
|
20
|
+
* @returns The execution context.
|
|
21
|
+
*/
|
|
6
22
|
get context(): ExecutionContext;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new instance of the service with a modified context or properties.
|
|
25
|
+
*
|
|
26
|
+
* @param context - The execution context or another service to inherit the context from.
|
|
27
|
+
* @param overwriteProperties - Optional properties to overwrite in the new service instance.
|
|
28
|
+
* @param overwriteContext - Optional context properties to overwrite in the new context.
|
|
29
|
+
* @returns A new service instance with the specified modifications.
|
|
30
|
+
*/
|
|
7
31
|
for<C extends ExecutionContext, P extends Partial<this>>(context: C | ServiceBase, overwriteProperties?: Nullish<P>, overwriteContext?: Partial<C>): this & Required<P>;
|
|
32
|
+
/**
|
|
33
|
+
* Asserts that a context is assigned to the service.
|
|
34
|
+
*
|
|
35
|
+
* @throws {@link Error} if no context is assigned.
|
|
36
|
+
* @protected
|
|
37
|
+
*/
|
|
8
38
|
protected _assertContext(): void;
|
|
9
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Namespace for {@link ServiceBase} related constants and interfaces.
|
|
42
|
+
*/
|
|
10
43
|
export declare namespace ServiceBase {
|
|
44
|
+
/** Symbol used for extending service instances. */
|
|
11
45
|
const extendSymbol: unique symbol;
|
|
46
|
+
/**
|
|
47
|
+
* Configuration options for {@link ServiceBase}.
|
|
48
|
+
*/
|
|
12
49
|
interface Options {
|
|
50
|
+
/** The execution context to be associated with the service. */
|
|
13
51
|
context?: ExecutionContext;
|
|
14
52
|
}
|
|
15
53
|
}
|
package/service-base.js
CHANGED
|
@@ -1,20 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for services in the OPRA framework.
|
|
3
|
+
* Provides access to the {@link ExecutionContext} and allows creating new
|
|
4
|
+
* service instances with modified context or properties.
|
|
5
|
+
*/
|
|
1
6
|
export class ServiceBase {
|
|
7
|
+
/**
|
|
8
|
+
* Initializes the service with optional configuration.
|
|
9
|
+
*
|
|
10
|
+
* @param options - Configuration options for the service.
|
|
11
|
+
*/
|
|
2
12
|
constructor(options) {
|
|
3
13
|
this._context = options?.context;
|
|
4
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Returns the execution context associated with this service.
|
|
17
|
+
*
|
|
18
|
+
* @throws {@link Error} if no context is assigned to the service.
|
|
19
|
+
* @returns The execution context.
|
|
20
|
+
*/
|
|
5
21
|
get context() {
|
|
6
22
|
this._assertContext();
|
|
7
23
|
return this._context;
|
|
8
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new instance of the service with a modified context or properties.
|
|
27
|
+
*
|
|
28
|
+
* @param context - The execution context or another service to inherit the context from.
|
|
29
|
+
* @param overwriteProperties - Optional properties to overwrite in the new service instance.
|
|
30
|
+
* @param overwriteContext - Optional context properties to overwrite in the new context.
|
|
31
|
+
* @returns A new service instance with the specified modifications.
|
|
32
|
+
*/
|
|
9
33
|
for(context, overwriteProperties, overwriteContext) {
|
|
10
34
|
if (context instanceof ServiceBase)
|
|
11
35
|
context = context.context;
|
|
12
|
-
|
|
36
|
+
/* Create a new context instance */
|
|
13
37
|
const ctx = {};
|
|
14
38
|
Object.setPrototypeOf(ctx, context);
|
|
15
39
|
if (overwriteContext)
|
|
16
40
|
Object.assign(ctx, overwriteContext);
|
|
17
|
-
|
|
41
|
+
/* Create a new service instance */
|
|
18
42
|
const instance = { _context: ctx };
|
|
19
43
|
Object.setPrototypeOf(instance, this);
|
|
20
44
|
if (overwriteProperties)
|
|
@@ -23,11 +47,21 @@ export class ServiceBase {
|
|
|
23
47
|
this[ServiceBase.extendSymbol](instance);
|
|
24
48
|
return instance;
|
|
25
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Asserts that a context is assigned to the service.
|
|
52
|
+
*
|
|
53
|
+
* @throws {@link Error} if no context is assigned.
|
|
54
|
+
* @protected
|
|
55
|
+
*/
|
|
26
56
|
_assertContext() {
|
|
27
57
|
if (!this._context)
|
|
28
58
|
throw new Error(`No context assigned for ${Object.getPrototypeOf(this).constructor.name}`);
|
|
29
59
|
}
|
|
30
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Namespace for {@link ServiceBase} related constants and interfaces.
|
|
63
|
+
*/
|
|
31
64
|
(function (ServiceBase) {
|
|
65
|
+
/** Symbol used for extending service instances. */
|
|
32
66
|
ServiceBase.extendSymbol = Symbol('extend');
|
|
33
67
|
})(ServiceBase || (ServiceBase = {}));
|