arvo-core 1.1.17 → 1.1.18
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/dist/ArvoContract/helpers.js +2 -2
- package/dist/ArvoEvent/helpers.js +1 -1
- package/dist/ArvoEventFactory/index.d.ts +1 -1
- package/dist/ArvoEventFactory/index.js +3 -3
- package/dist/ArvoOrchestratorContract/typegen.d.ts +61 -6
- package/dist/ArvoOrchestratorContract/typegen.js +71 -12
- package/dist/OpenTelemetry/index.d.ts +1 -1
- package/dist/OpenTelemetry/index.js +6 -3
- package/dist/OpenTelemetry/utils.d.ts +1 -1
- package/dist/OpenTelemetry/utils.js +2 -2
- package/dist/index.d.ts +1 -2
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
@@ -35,10 +35,10 @@ var utils_1 = require("../utils");
|
|
35
35
|
*/
|
36
36
|
var createArvoContract = function (contract) {
|
37
37
|
var createErrorMessage = function (source, type) {
|
38
|
-
return (0, utils_1.cleanString)("\n In contract (uri=".concat(contract.uri, "), the '").concat(source, "' event (type=").concat(type, ") must not start \n with '").concat(typegen_1.ArvoOrchestratorEventTypeGen.
|
38
|
+
return (0, utils_1.cleanString)("\n In contract (uri=".concat(contract.uri, "), the '").concat(source, "' event (type=").concat(type, ") must not start \n with '").concat(typegen_1.ArvoOrchestratorEventTypeGen.prefix, "' becuase this a reserved pattern \n for Arvo orchestrators.\n "));
|
39
39
|
};
|
40
40
|
var validator = function (value) {
|
41
|
-
return value.startsWith(typegen_1.ArvoOrchestratorEventTypeGen.
|
41
|
+
return value.startsWith(typegen_1.ArvoOrchestratorEventTypeGen.prefix);
|
42
42
|
};
|
43
43
|
if (validator(contract.accepts.type)) {
|
44
44
|
throw new Error(createErrorMessage('accepts', contract.accepts.type));
|
@@ -47,7 +47,7 @@ var uuid_1 = require("uuid");
|
|
47
47
|
*/
|
48
48
|
var createArvoEvent = function (event, extensions, opentelemetry) {
|
49
49
|
if (opentelemetry === void 0) { opentelemetry = {
|
50
|
-
tracer: OpenTelemetry_1.
|
50
|
+
tracer: (0, OpenTelemetry_1.fetchOpenTelemetryTracer)(),
|
51
51
|
}; }
|
52
52
|
var span = opentelemetry.tracer.startSpan("createArvoEvent<".concat(event.type, ">"), {});
|
53
53
|
return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), function () {
|
@@ -11,7 +11,7 @@ import { ExecutionOpenTelemetryConfiguration } from '../types';
|
|
11
11
|
* @template TEmits - The type of records the contract bound handler emits.
|
12
12
|
*/
|
13
13
|
export default class ArvoEventFactory<TUri extends string = string, TType extends string = string, TAcceptSchema extends z.ZodTypeAny = z.ZodTypeAny, TEmits extends Record<string, z.ZodTypeAny> = Record<string, z.ZodTypeAny>> {
|
14
|
-
private contract;
|
14
|
+
private readonly contract;
|
15
15
|
/**
|
16
16
|
* Creates an instance of ArvoEventFactory.
|
17
17
|
*
|
@@ -55,7 +55,7 @@ var ArvoEventFactory = /** @class */ (function () {
|
|
55
55
|
ArvoEventFactory.prototype.accepts = function (event, extensions, opentelemetry) {
|
56
56
|
var _this = this;
|
57
57
|
if (opentelemetry === void 0) { opentelemetry = {
|
58
|
-
tracer: OpenTelemetry_1.
|
58
|
+
tracer: (0, OpenTelemetry_1.fetchOpenTelemetryTracer)(),
|
59
59
|
}; }
|
60
60
|
var span = opentelemetry.tracer.startSpan("ArvoEventFactory<".concat(this.contract.uri, ">.accepts<").concat(this.contract.accepts.type, ">.create"));
|
61
61
|
return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), function () {
|
@@ -95,7 +95,7 @@ var ArvoEventFactory = /** @class */ (function () {
|
|
95
95
|
ArvoEventFactory.prototype.emits = function (event, extensions, opentelemetry) {
|
96
96
|
var _this = this;
|
97
97
|
if (opentelemetry === void 0) { opentelemetry = {
|
98
|
-
tracer: OpenTelemetry_1.
|
98
|
+
tracer: (0, OpenTelemetry_1.fetchOpenTelemetryTracer)(),
|
99
99
|
}; }
|
100
100
|
var span = opentelemetry.tracer.startSpan("ArvoEventFactory<".concat(this.contract.uri, ">.emits<").concat(event.type, ">.create"));
|
101
101
|
return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), function () {
|
@@ -133,7 +133,7 @@ var ArvoEventFactory = /** @class */ (function () {
|
|
133
133
|
ArvoEventFactory.prototype.systemError = function (event, extensions, opentelemetry) {
|
134
134
|
var _this = this;
|
135
135
|
if (opentelemetry === void 0) { opentelemetry = {
|
136
|
-
tracer: OpenTelemetry_1.
|
136
|
+
tracer: (0, OpenTelemetry_1.fetchOpenTelemetryTracer)(),
|
137
137
|
}; }
|
138
138
|
var span = opentelemetry.tracer.startSpan("ArvoEventFactory<".concat(this.contract.uri, ">.systemError<sys.").concat(this.contract.accepts.type, ".error>.create"));
|
139
139
|
return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), function () {
|
@@ -1,6 +1,61 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
/**
|
2
|
+
* Utility class for generating standardized event type strings for the Arvo orchestrator.
|
3
|
+
* This class provides methods to create consistent event type identifiers with predefined prefixes
|
4
|
+
* and suffixes for different event states (init, complete, error).
|
5
|
+
*
|
6
|
+
* @example
|
7
|
+
* ```typescript
|
8
|
+
* // Generate event types for a 'payment' event
|
9
|
+
* const initEvent = ArvoOrchestratorEventTypeGen.init('payment') // 'arvo.orc.payment'
|
10
|
+
* const doneEvent = ArvoOrchestratorEventTypeGen.complete('payment') // 'arvo.orc.payment.done'
|
11
|
+
* const errorEvent = ArvoOrchestratorEventTypeGen.systemError('payment') // 'sys.arvo.orc.payment.error'
|
12
|
+
* ```
|
13
|
+
*/
|
14
|
+
export declare class ArvoOrchestratorEventTypeGen {
|
15
|
+
/**
|
16
|
+
* The standard prefix used for all Arvo orchestrator events.
|
17
|
+
* This prefix helps identify events that belong to the Arvo orchestrator system.
|
18
|
+
*/
|
19
|
+
static readonly prefix: 'arvo.orc';
|
20
|
+
/**
|
21
|
+
* Generates an initialization event type string for a given event name.
|
22
|
+
*
|
23
|
+
* @param name - The base name of the event
|
24
|
+
* @returns A type-safe string combining the standard prefix with the provided name
|
25
|
+
* @typeParam T - String literal type for the event name
|
26
|
+
*
|
27
|
+
* @example
|
28
|
+
* ```typescript
|
29
|
+
* ArvoOrchestratorEventTypeGen.init('userRegistration') // Returns: 'arvo.orc.userRegistration'
|
30
|
+
* ```
|
31
|
+
*/
|
32
|
+
static init<T extends string>(name: T): `${typeof ArvoOrchestratorEventTypeGen.prefix}.${T}`;
|
33
|
+
/**
|
34
|
+
* Generates a completion event type string for a given event name.
|
35
|
+
* Appends '.done' to the initialization event type.
|
36
|
+
*
|
37
|
+
* @param name - The base name of the event
|
38
|
+
* @returns A type-safe string for the completion event
|
39
|
+
* @typeParam T - String literal type for the event name
|
40
|
+
*
|
41
|
+
* @example
|
42
|
+
* ```typescript
|
43
|
+
* ArvoOrchestratorEventTypeGen.complete('userRegistration') // Returns: 'arvo.orc.userRegistration.done'
|
44
|
+
* ```
|
45
|
+
*/
|
46
|
+
static complete<T extends string>(name: T): `${ReturnType<typeof ArvoOrchestratorEventTypeGen.init<T>>}.done`;
|
47
|
+
/**
|
48
|
+
* Generates a system error event type string for a given event name.
|
49
|
+
* Prepends 'sys.' and appends '.error' to the initialization event type.
|
50
|
+
*
|
51
|
+
* @param name - The base name of the event
|
52
|
+
* @returns A type-safe string for the system error event
|
53
|
+
* @typeParam T - String literal type for the event name
|
54
|
+
*
|
55
|
+
* @example
|
56
|
+
* ```typescript
|
57
|
+
* ArvoOrchestratorEventTypeGen.systemError('userRegistration') // Returns: 'sys.arvo.orc.userRegistration.error'
|
58
|
+
* ```
|
59
|
+
*/
|
60
|
+
static systemError<T extends string>(name: T): `sys.${ReturnType<typeof ArvoOrchestratorEventTypeGen.init<T>>}.error`;
|
61
|
+
}
|
@@ -1,15 +1,74 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.ArvoOrchestratorEventTypeGen = void 0;
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
4
|
+
/**
|
5
|
+
* Utility class for generating standardized event type strings for the Arvo orchestrator.
|
6
|
+
* This class provides methods to create consistent event type identifiers with predefined prefixes
|
7
|
+
* and suffixes for different event states (init, complete, error).
|
8
|
+
*
|
9
|
+
* @example
|
10
|
+
* ```typescript
|
11
|
+
* // Generate event types for a 'payment' event
|
12
|
+
* const initEvent = ArvoOrchestratorEventTypeGen.init('payment') // 'arvo.orc.payment'
|
13
|
+
* const doneEvent = ArvoOrchestratorEventTypeGen.complete('payment') // 'arvo.orc.payment.done'
|
14
|
+
* const errorEvent = ArvoOrchestratorEventTypeGen.systemError('payment') // 'sys.arvo.orc.payment.error'
|
15
|
+
* ```
|
16
|
+
*/
|
17
|
+
var ArvoOrchestratorEventTypeGen = /** @class */ (function () {
|
18
|
+
function ArvoOrchestratorEventTypeGen() {
|
19
|
+
}
|
20
|
+
/**
|
21
|
+
* Generates an initialization event type string for a given event name.
|
22
|
+
*
|
23
|
+
* @param name - The base name of the event
|
24
|
+
* @returns A type-safe string combining the standard prefix with the provided name
|
25
|
+
* @typeParam T - String literal type for the event name
|
26
|
+
*
|
27
|
+
* @example
|
28
|
+
* ```typescript
|
29
|
+
* ArvoOrchestratorEventTypeGen.init('userRegistration') // Returns: 'arvo.orc.userRegistration'
|
30
|
+
* ```
|
31
|
+
*/
|
32
|
+
ArvoOrchestratorEventTypeGen.init = function (name) {
|
33
|
+
return "".concat(ArvoOrchestratorEventTypeGen.prefix, ".").concat(name);
|
34
|
+
};
|
35
|
+
/**
|
36
|
+
* Generates a completion event type string for a given event name.
|
37
|
+
* Appends '.done' to the initialization event type.
|
38
|
+
*
|
39
|
+
* @param name - The base name of the event
|
40
|
+
* @returns A type-safe string for the completion event
|
41
|
+
* @typeParam T - String literal type for the event name
|
42
|
+
*
|
43
|
+
* @example
|
44
|
+
* ```typescript
|
45
|
+
* ArvoOrchestratorEventTypeGen.complete('userRegistration') // Returns: 'arvo.orc.userRegistration.done'
|
46
|
+
* ```
|
47
|
+
*/
|
48
|
+
ArvoOrchestratorEventTypeGen.complete = function (name) {
|
49
|
+
return "".concat(ArvoOrchestratorEventTypeGen.init(name), ".done");
|
50
|
+
};
|
51
|
+
/**
|
52
|
+
* Generates a system error event type string for a given event name.
|
53
|
+
* Prepends 'sys.' and appends '.error' to the initialization event type.
|
54
|
+
*
|
55
|
+
* @param name - The base name of the event
|
56
|
+
* @returns A type-safe string for the system error event
|
57
|
+
* @typeParam T - String literal type for the event name
|
58
|
+
*
|
59
|
+
* @example
|
60
|
+
* ```typescript
|
61
|
+
* ArvoOrchestratorEventTypeGen.systemError('userRegistration') // Returns: 'sys.arvo.orc.userRegistration.error'
|
62
|
+
* ```
|
63
|
+
*/
|
64
|
+
ArvoOrchestratorEventTypeGen.systemError = function (name) {
|
65
|
+
return "sys.".concat(ArvoOrchestratorEventTypeGen.init(name), ".error");
|
66
|
+
};
|
67
|
+
/**
|
68
|
+
* The standard prefix used for all Arvo orchestrator events.
|
69
|
+
* This prefix helps identify events that belong to the Arvo orchestrator system.
|
70
|
+
*/
|
71
|
+
ArvoOrchestratorEventTypeGen.prefix = 'arvo.orc';
|
72
|
+
return ArvoOrchestratorEventTypeGen;
|
73
|
+
}());
|
74
|
+
exports.ArvoOrchestratorEventTypeGen = ArvoOrchestratorEventTypeGen;
|
@@ -3,7 +3,7 @@ import { TelemetryLogLevel, OpenTelemetryHeaders } from './types';
|
|
3
3
|
/**
|
4
4
|
* A tracer instance for the ArvoCore package.
|
5
5
|
*/
|
6
|
-
export declare const
|
6
|
+
export declare const fetchOpenTelemetryTracer: () => import("@opentelemetry/api").Tracer;
|
7
7
|
/**
|
8
8
|
* Logs a message to a span with additional parameters.
|
9
9
|
* @param params - The parameters for the log message.
|
@@ -11,16 +11,19 @@ var __assign = (this && this.__assign) || function () {
|
|
11
11
|
return __assign.apply(this, arguments);
|
12
12
|
};
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
14
|
-
exports.OTelNull = exports.exceptionToSpan = exports.logToSpan = exports.
|
14
|
+
exports.OTelNull = exports.exceptionToSpan = exports.logToSpan = exports.fetchOpenTelemetryTracer = void 0;
|
15
15
|
exports.currentOpenTelemetryHeaders = currentOpenTelemetryHeaders;
|
16
16
|
var api_1 = require("@opentelemetry/api");
|
17
17
|
var utils_1 = require("./utils");
|
18
18
|
var core_1 = require("@opentelemetry/core");
|
19
|
-
var pkg = (0, utils_1.getPackageInfo)();
|
20
19
|
/**
|
21
20
|
* A tracer instance for the ArvoCore package.
|
22
21
|
*/
|
23
|
-
|
22
|
+
var fetchOpenTelemetryTracer = function () {
|
23
|
+
var pkg = (0, utils_1.getPackageInfo)('arvo-core');
|
24
|
+
return api_1.trace.getTracer(pkg.name, pkg.version);
|
25
|
+
};
|
26
|
+
exports.fetchOpenTelemetryTracer = fetchOpenTelemetryTracer;
|
24
27
|
/**
|
25
28
|
* Logs a message to a span with additional parameters.
|
26
29
|
* @param params - The parameters for the log message.
|
@@ -26,7 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.getPackageInfo = getPackageInfo;
|
27
27
|
var fs = __importStar(require("fs"));
|
28
28
|
var path = __importStar(require("path"));
|
29
|
-
function getPackageInfo() {
|
29
|
+
function getPackageInfo(defaultName) {
|
30
30
|
try {
|
31
31
|
// Read the package.json file
|
32
32
|
var packageJsonPath = path.resolve(__dirname, '../../package.json');
|
@@ -39,6 +39,6 @@ function getPackageInfo() {
|
|
39
39
|
}
|
40
40
|
catch (error) {
|
41
41
|
console.error('Error reading package.json:', error);
|
42
|
-
return { name:
|
42
|
+
return { name: defaultName, version: 'Unknown' };
|
43
43
|
}
|
44
44
|
}
|
package/dist/index.d.ts
CHANGED
@@ -23,12 +23,11 @@ import { ArvoOrchestrationSubjectContentSchema, ArvoOrchestratorVersionSchema }
|
|
23
23
|
import { ArvoOrchestrationSubjectContent, ArvoOrchestratorVersion } from './ArvoOrchestrationSubject/type';
|
24
24
|
import ArvoEventHttp from './ArvoEventHttp';
|
25
25
|
import { ArvoEventHttpConfig } from './ArvoEventHttp/types';
|
26
|
-
import { InferArvoContract, InferArvoEvent, InferArvoOrchestratorContract } from './types';
|
26
|
+
import { InferArvoContract, InferArvoEvent, InferArvoOrchestratorContract, ExecutionOpenTelemetryConfiguration } from './types';
|
27
27
|
import { createArvoOrchestratorContract } from './ArvoOrchestratorContract/helpers';
|
28
28
|
import ArvoOrchestratorContract from './ArvoOrchestratorContract';
|
29
29
|
import { ICreateArvoOrchestratorContract, IArvoOrchestratorContract } from './ArvoOrchestratorContract/types';
|
30
30
|
import { ArvoOrchestratorEventTypeGen } from './ArvoOrchestratorContract/typegen';
|
31
|
-
import { ExecutionOpenTelemetryConfiguration } from './types';
|
32
31
|
/**
|
33
32
|
* Collection of Zod schemas for validating various aspects of Arvo events.
|
34
33
|
* @property {z.ZodObject} CloudEventContextSchema - Schema for core CloudEvent properties.
|
package/dist/types.d.ts
CHANGED
@@ -12,7 +12,7 @@ import { Tracer } from '@opentelemetry/api';
|
|
12
12
|
*/
|
13
13
|
export type ExecutionOpenTelemetryConfiguration = {
|
14
14
|
/**
|
15
|
-
*
|
15
|
+
* OpenTelemetry tracer instance to use for creating spans.
|
16
16
|
* If not provided, a default tracer may be used depending on the implementation.
|
17
17
|
*/
|
18
18
|
tracer: Tracer;
|