@opra/core 1.28.5 → 1.29.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.
@@ -0,0 +1,44 @@
1
+ import { OpraException, OpraSchema } from '@opra/common';
2
+ import { AsyncEventEmitter } from 'node-events-async';
3
+ import type { ExecutionContext } from './execution-context.js';
4
+ import type { PlatformAdapter } from './platform-adapter.js';
5
+ /**
6
+ * ExecutionBundle provides a context for executing multiple operations.
7
+ */
8
+ export declare class ExecutionBundle extends AsyncEventEmitter {
9
+ /** The platform adapter that created this context */
10
+ readonly __adapter: PlatformAdapter;
11
+ /** The transport protocol being used (e.g., 'http', 'socketio') */
12
+ readonly transport?: OpraSchema.Transport;
13
+ /** The platform name (e.g., 'express', 'koa') */
14
+ readonly platform: string;
15
+ /** A collection of ExecutionContext created during execution */
16
+ contexts: ExecutionContext[];
17
+ /** Whether a transaction will be used in this bundle context */
18
+ readonly transaction?: boolean;
19
+ success?: boolean;
20
+ finished?: boolean;
21
+ error?: OpraException;
22
+ /**
23
+ * Creates a new ExecutionContext instance.
24
+ *
25
+ * @param init - The initialization parameters for the context.
26
+ */
27
+ constructor(init: ExecutionBundle.Initiator);
28
+ }
29
+ /**
30
+ * Namespace for {@link ExecutionBundle} related types and interfaces.
31
+ */
32
+ export declare namespace ExecutionBundle {
33
+ /**
34
+ * Initialization parameters for creating an {@link ExecutionBundle}.
35
+ */
36
+ interface Initiator {
37
+ /** The platform adapter */
38
+ __adapter: PlatformAdapter;
39
+ /** The transport protocol */
40
+ transport?: OpraSchema.Transport;
41
+ /** The platform name */
42
+ platform?: string;
43
+ }
44
+ }
@@ -0,0 +1,31 @@
1
+ import { OpraException, OpraSchema } from '@opra/common';
2
+ import { AsyncEventEmitter } from 'node-events-async';
3
+ /**
4
+ * ExecutionBundle provides a context for executing multiple operations.
5
+ */
6
+ export class ExecutionBundle extends AsyncEventEmitter {
7
+ /** The platform adapter that created this context */
8
+ __adapter;
9
+ /** The transport protocol being used (e.g., 'http', 'socketio') */
10
+ transport;
11
+ /** The platform name (e.g., 'express', 'koa') */
12
+ platform = '';
13
+ /** A collection of ExecutionContext created during execution */
14
+ contexts = [];
15
+ /** Whether a transaction will be used in this bundle context */
16
+ transaction;
17
+ success;
18
+ finished;
19
+ error;
20
+ /**
21
+ * Creates a new ExecutionContext instance.
22
+ *
23
+ * @param init - The initialization parameters for the context.
24
+ */
25
+ constructor(init) {
26
+ super();
27
+ this.__adapter = init.__adapter;
28
+ this.transport = init.transport;
29
+ this.platform = init.platform || '';
30
+ }
31
+ }
@@ -1,21 +1,26 @@
1
1
  import { DocumentNode, OpraSchema } from '@opra/common';
2
- import { AsyncEventEmitter } from 'node-events-async';
2
+ import { AsyncEventEmitter, type EventMap } from 'node-events-async';
3
+ import type { ExecutionBundle } from './execution-bundle.js';
3
4
  import type { PlatformAdapter } from './platform-adapter.js';
4
5
  /**
5
6
  * ExecutionContext provides a context for executing operations within an adapter.
6
7
  * It carries information about the document node, adapter, transport, and platform.
7
8
  */
8
- export declare class ExecutionContext extends AsyncEventEmitter {
9
- /** The document node associated with this context */
10
- readonly __docNode: DocumentNode;
9
+ export declare class ExecutionContext<T extends EventMap<T> = never> extends AsyncEventEmitter<T> {
11
10
  /** The platform adapter that created this context */
12
11
  readonly __adapter: PlatformAdapter;
12
+ /** The document node associated with this context */
13
+ readonly __docNode: DocumentNode;
14
+ /** The execution bundle associated with this context */
15
+ readonly bundle?: ExecutionBundle;
13
16
  /** The transport protocol being used (e.g., 'http', 'socketio') */
14
17
  readonly transport?: OpraSchema.Transport;
15
18
  /** The platform name (e.g., 'express', 'koa') */
16
19
  readonly platform: string;
17
20
  /** A collection of errors encountered during execution */
18
21
  errors: Error[];
22
+ success?: boolean;
23
+ finished?: boolean;
19
24
  /**
20
25
  * Creates a new ExecutionContext instance.
21
26
  *
@@ -35,6 +40,8 @@ export declare namespace ExecutionContext {
35
40
  __adapter: PlatformAdapter;
36
41
  /** The document node */
37
42
  __docNode: DocumentNode;
43
+ /** The execution bundle */
44
+ bundle?: ExecutionBundle;
38
45
  /** The transport protocol */
39
46
  transport?: OpraSchema.Transport;
40
47
  /** The platform name */
@@ -5,16 +5,20 @@ import { AsyncEventEmitter } from 'node-events-async';
5
5
  * It carries information about the document node, adapter, transport, and platform.
6
6
  */
7
7
  export class ExecutionContext extends AsyncEventEmitter {
8
- /** The document node associated with this context */
9
- __docNode;
10
8
  /** The platform adapter that created this context */
11
9
  __adapter;
10
+ /** The document node associated with this context */
11
+ __docNode;
12
+ /** The execution bundle associated with this context */
13
+ bundle;
12
14
  /** The transport protocol being used (e.g., 'http', 'socketio') */
13
15
  transport;
14
16
  /** The platform name (e.g., 'express', 'koa') */
15
17
  platform = '';
16
18
  /** A collection of errors encountered during execution */
17
19
  errors = [];
20
+ success;
21
+ finished;
18
22
  /**
19
23
  * Creates a new ExecutionContext instance.
20
24
  *
@@ -24,6 +28,7 @@ export class ExecutionContext extends AsyncEventEmitter {
24
28
  super();
25
29
  this.__adapter = init.__adapter;
26
30
  this.__docNode = init.__docNode;
31
+ this.bundle = init.bundle;
27
32
  this.transport = init.transport;
28
33
  this.platform = init.platform || '';
29
34
  }
package/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import 'reflect-metadata';
2
2
  import './augmentation/18n.augmentation.js';
3
3
  export * from './asset-cache.js';
4
4
  export * from './constants.js';
5
+ export * from './execution-bundle.js';
5
6
  export * from './execution-context.js';
6
7
  export * from './interfaces/logger.interface.js';
7
8
  export * from './platform-adapter.js';
package/index.js CHANGED
@@ -2,6 +2,7 @@ import 'reflect-metadata';
2
2
  import './augmentation/18n.augmentation.js';
3
3
  export * from './asset-cache.js';
4
4
  export * from './constants.js';
5
+ export * from './execution-bundle.js';
5
6
  export * from './execution-context.js';
6
7
  export * from './interfaces/logger.interface.js';
7
8
  export * from './platform-adapter.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/core",
3
- "version": "1.28.5",
3
+ "version": "1.29.0",
4
4
  "description": "Opra schema package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -11,7 +11,7 @@
11
11
  "tslib": "^2.8.1"
12
12
  },
13
13
  "peerDependencies": {
14
- "@opra/common": "^1.28.5"
14
+ "@opra/common": "^1.29.0"
15
15
  },
16
16
  "type": "module",
17
17
  "module": "./index.js",