@opra/core 1.23.0 → 1.23.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.
@@ -1,13 +1,13 @@
1
1
  import { DocumentNode, OpraSchema } from '@opra/common';
2
2
  import { AsyncEventEmitter } from 'node-events-async';
3
- import { PlatformAdapter } from './platform-adapter.js';
3
+ import type { PlatformAdapter } from './platform-adapter.js';
4
4
  /**
5
5
  * @class ExecutionContext
6
6
  */
7
7
  export declare class ExecutionContext extends AsyncEventEmitter {
8
8
  readonly __docNode: DocumentNode;
9
9
  readonly __adapter: PlatformAdapter;
10
- readonly transport: OpraSchema.Transport;
10
+ readonly transport?: OpraSchema.Transport;
11
11
  readonly platform: string;
12
12
  errors: Error[];
13
13
  constructor(init: ExecutionContext.Initiator);
@@ -18,7 +18,7 @@ export declare class ExecutionContext extends AsyncEventEmitter {
18
18
  export declare namespace ExecutionContext {
19
19
  interface Initiator {
20
20
  __adapter: PlatformAdapter;
21
- __docNode?: DocumentNode;
21
+ __docNode: DocumentNode;
22
22
  transport?: OpraSchema.Transport;
23
23
  platform?: string;
24
24
  }
@@ -6,13 +6,13 @@ export class ExecutionContext extends AsyncEventEmitter {
6
6
  __docNode;
7
7
  __adapter;
8
8
  transport;
9
- platform;
9
+ platform = '';
10
10
  errors = [];
11
11
  constructor(init) {
12
12
  super();
13
13
  this.__adapter = init.__adapter;
14
- this.__docNode = init.__docNode || init.__adapter.document.node;
15
- this.transport = init.transport || 'custom';
14
+ this.__docNode = init.__docNode;
15
+ this.transport = init.transport;
16
16
  this.platform = init.platform || '';
17
17
  }
18
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/core",
3
- "version": "1.23.0",
3
+ "version": "1.23.2",
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.23.0"
13
+ "@opra/common": "^1.23.2"
14
14
  },
15
15
  "type": "module",
16
16
  "module": "./index.js",
@@ -3,6 +3,7 @@ import { ApiDocument, I18n, OpraSchema } from '@opra/common';
3
3
  import { AsyncEventEmitter, EventMap } from 'node-events-async';
4
4
  import { AssetCache } from './asset-cache.js';
5
5
  import { kAssetCache } from './constants.js';
6
+ import { ExecutionContext } from './execution-context.js';
6
7
  import { ILogger } from './interfaces/logger.interface.js';
7
8
  /**
8
9
  * @class PlatformAdapter
@@ -11,11 +12,13 @@ export declare abstract class PlatformAdapter<T extends EventMap<T> = never> ext
11
12
  protected [kAssetCache]: AssetCache;
12
13
  protected _document: ApiDocument;
13
14
  abstract readonly transform: OpraSchema.Transport;
15
+ abstract readonly platform: string;
14
16
  i18n: I18n;
15
17
  logger?: ILogger;
16
18
  protected constructor(options?: PlatformAdapter.Options);
17
19
  get document(): ApiDocument;
18
20
  abstract close(): Promise<void>;
21
+ createRootContext(): ExecutionContext;
19
22
  }
20
23
  /**
21
24
  * @namespace PlatformAdapter
@@ -3,6 +3,7 @@ import { I18n } from '@opra/common';
3
3
  import { AsyncEventEmitter } from 'node-events-async';
4
4
  import { AssetCache } from './asset-cache.js';
5
5
  import { kAssetCache } from './constants.js';
6
+ import { ExecutionContext } from './execution-context.js';
6
7
  /**
7
8
  * @class PlatformAdapter
8
9
  */
@@ -19,4 +20,12 @@ export class PlatformAdapter extends AsyncEventEmitter {
19
20
  get document() {
20
21
  return this._document;
21
22
  }
23
+ createRootContext() {
24
+ return new ExecutionContext({
25
+ __adapter: this,
26
+ __docNode: this.document.node,
27
+ transport: this.transform,
28
+ platform: this.platform,
29
+ });
30
+ }
22
31
  }
package/service-base.js CHANGED
@@ -6,12 +6,12 @@ export class ServiceBase {
6
6
  for(context, overwriteProperties, overwriteContext) {
7
7
  if (context instanceof ServiceBase)
8
8
  context = context.context;
9
- /** Create new context instance */
9
+ /** Create a new context instance */
10
10
  const ctx = {};
11
11
  Object.setPrototypeOf(ctx, context);
12
12
  if (overwriteContext)
13
13
  Object.assign(ctx, overwriteContext);
14
- /** Create new service instance */
14
+ /** Create a new service instance */
15
15
  const instance = { _context: ctx };
16
16
  Object.setPrototypeOf(instance, this);
17
17
  if (overwriteProperties)