arvo-core 3.0.7 → 3.0.8

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.
@@ -7,8 +7,8 @@ exports.createArvoEvent = void 0;
7
7
  var _1 = __importDefault(require("."));
8
8
  var OpenTelemetry_1 = require("../OpenTelemetry");
9
9
  var utils_1 = require("../utils");
10
- var schema_1 = require("./schema");
11
10
  var id_1 = require("./id");
11
+ var schema_1 = require("./schema");
12
12
  /**
13
13
  * Internal generator function for creating instances.
14
14
  */
@@ -1,5 +1,5 @@
1
- import { CreateArvoEvent } from './types';
2
1
  import { z } from 'zod';
2
+ import type { CreateArvoEvent } from './types';
3
3
  export declare const ArvoEventIdObjectSchema: z.ZodObject<{
4
4
  uuid: z.ZodString;
5
5
  value: z.ZodString;
@@ -4,11 +4,11 @@ export declare const ArvoOrchestrationSubjectContentSchema: z.ZodObject<{
4
4
  name: z.ZodEffects<z.ZodString, string, string>;
5
5
  version: z.ZodString;
6
6
  }, "strip", z.ZodTypeAny, {
7
- version: string;
8
7
  name: string;
9
- }, {
10
8
  version: string;
9
+ }, {
11
10
  name: string;
11
+ version: string;
12
12
  }>;
13
13
  execution: z.ZodObject<{
14
14
  id: z.ZodEffects<z.ZodString, string, string>;
@@ -26,8 +26,8 @@ export declare const ArvoOrchestrationSubjectContentSchema: z.ZodObject<{
26
26
  meta: z.ZodRecord<z.ZodString, z.ZodString>;
27
27
  }, "strip", z.ZodTypeAny, {
28
28
  orchestrator: {
29
- version: string;
30
29
  name: string;
30
+ version: string;
31
31
  };
32
32
  execution: {
33
33
  id: string;
@@ -37,8 +37,8 @@ export declare const ArvoOrchestrationSubjectContentSchema: z.ZodObject<{
37
37
  meta: Record<string, string>;
38
38
  }, {
39
39
  orchestrator: {
40
- version: string;
41
40
  name: string;
41
+ version: string;
42
42
  };
43
43
  execution: {
44
44
  id: string;
package/dist/errors.d.ts CHANGED
@@ -26,6 +26,8 @@ export declare class ViolationError<T extends string = string> extends Error {
26
26
  readonly type: T;
27
27
  /** Additional structured data about the violation */
28
28
  readonly metadata: Record<string, any> | null;
29
+ /** An additional flag to determine if it is an Arvo specific violation error */
30
+ readonly isArvoViolationError = true;
29
31
  /**
30
32
  * The error name, formatted as ViolationError<TYPE>
31
33
  * This helps with error identification in logs and stack traces
@@ -33,3 +35,22 @@ export declare class ViolationError<T extends string = string> extends Error {
33
35
  readonly name: `ViolationError<${T}>`;
34
36
  constructor({ type, message, metadata }: ViolationErrorParam<T>);
35
37
  }
38
+ /**
39
+ * Type guard to determine if an unknown value is a ViolationError, an instance
40
+ * of a class that inherits from ViolationError.
41
+ *
42
+ * @param e - The value to check, typically an unknown error or exception
43
+ * @returns `true` if the value is a ViolationError, inherits from it, or has the isArvoViolationError flag, `false` otherwise
44
+ *
45
+ * ```typescript
46
+ * const error = new ViolationError({
47
+ * type: 'RATE_LIMIT',
48
+ * message: 'API rate limit exceeded'
49
+ * });
50
+ *
51
+ * console.log(isViolationError(error)); // true
52
+ * console.log(isViolationError(new Error())); // false
53
+ * console.log(isViolationError(null)); // false
54
+ * ```
55
+ */
56
+ export declare const isViolationError: (e: unknown) => boolean;
package/dist/errors.js CHANGED
@@ -14,8 +14,12 @@ var __extends = (this && this.__extends) || (function () {
14
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
15
  };
16
16
  })();
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
17
20
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.ViolationError = void 0;
21
+ exports.isViolationError = exports.ViolationError = void 0;
22
+ var zod_1 = __importDefault(require("zod"));
19
23
  /**
20
24
  * ViolationError represents errors that require explicit handling in the system.
21
25
  * These are distinct from recoverable errors that can be automatically handled
@@ -33,6 +37,8 @@ var ViolationError = /** @class */ (function (_super) {
33
37
  function ViolationError(_a) {
34
38
  var type = _a.type, message = _a.message, metadata = _a.metadata;
35
39
  var _this = _super.call(this, "ViolationError<".concat(type, "> ").concat(message)) || this;
40
+ /** An additional flag to determine if it is an Arvo specific violation error */
41
+ _this.isArvoViolationError = true;
36
42
  _this.type = type;
37
43
  _this.name = "ViolationError<".concat(_this.type, ">");
38
44
  _this.metadata = metadata !== null && metadata !== void 0 ? metadata : null;
@@ -41,3 +47,31 @@ var ViolationError = /** @class */ (function (_super) {
41
47
  return ViolationError;
42
48
  }(Error));
43
49
  exports.ViolationError = ViolationError;
50
+ /**
51
+ * Type guard to determine if an unknown value is a ViolationError, an instance
52
+ * of a class that inherits from ViolationError.
53
+ *
54
+ * @param e - The value to check, typically an unknown error or exception
55
+ * @returns `true` if the value is a ViolationError, inherits from it, or has the isArvoViolationError flag, `false` otherwise
56
+ *
57
+ * ```typescript
58
+ * const error = new ViolationError({
59
+ * type: 'RATE_LIMIT',
60
+ * message: 'API rate limit exceeded'
61
+ * });
62
+ *
63
+ * console.log(isViolationError(error)); // true
64
+ * console.log(isViolationError(new Error())); // false
65
+ * console.log(isViolationError(null)); // false
66
+ * ```
67
+ */
68
+ var isViolationError = function (e) {
69
+ var ViolationErrorSchema = zod_1.default.object({
70
+ isArvoViolationError: zod_1.default.literal(true),
71
+ type: zod_1.default.string().min(1),
72
+ name: zod_1.default.string().min(1),
73
+ message: zod_1.default.string().min(1),
74
+ });
75
+ return e instanceof Error && ViolationErrorSchema.safeParse(e).success;
76
+ };
77
+ exports.isViolationError = isViolationError;
package/dist/index.d.ts CHANGED
@@ -13,6 +13,7 @@ import { VersionedArvoContract } from './ArvoContract/VersionedArvoContract';
13
13
  import { WildCardArvoSemanticVersion, isWildCardArvoSematicVersion } from './ArvoContract/WildCardArvoSemanticVersion';
14
14
  import { ArvoContractJSONSchema, ArvoContractRecord, IArvoContract, ResolveArvoContractRecord } from './ArvoContract/types';
15
15
  import { ArvoContractValidators } from './ArvoContract/validators';
16
+ import { ArvoEventIdObject, ArvoEventIdObjectSchema, createArvoEventId, parseArvoEventId } from './ArvoEvent/id';
16
17
  import ArvoEventFactory from './ArvoEventFactory';
17
18
  import { ArvoOrchestratorEventFactory } from './ArvoEventFactory/Orchestrator';
18
19
  import { createArvoEventFactory, createArvoOrchestratorEventFactory } from './ArvoEventFactory/helpers';
@@ -26,10 +27,9 @@ import ArvoExecution from './OpenTelemetry/ArvoExecution';
26
27
  import { ArvoExecutionSpanKind } from './OpenTelemetry/ArvoExecution/types';
27
28
  import OpenInference from './OpenTelemetry/OpenInference';
28
29
  import { OpenInferenceSpanKind } from './OpenTelemetry/OpenInference/types';
29
- import { ViolationError, ViolationErrorParam } from './errors';
30
+ import { ViolationError, ViolationErrorParam, isViolationError } from './errors';
30
31
  import { ArvoErrorSchema, ArvoSemanticVersionSchema, isValidArvoSemanticVersion } from './schema';
31
32
  import { ArvoErrorType, ArvoSemanticVersion, InferArvoEvent, InferVersionedArvoContract } from './types';
32
- import { ArvoEventIdObjectSchema, createArvoEventId, parseArvoEventId, ArvoEventIdObject } from './ArvoEvent/id';
33
33
  /**
34
34
  * Collection of Zod schemas for validating various aspects of Arvo events.
35
35
  * @property {z.ZodObject} CloudEventContextSchema - Schema for core CloudEvent properties.
@@ -110,4 +110,4 @@ declare const ArvoEventSchema: {
110
110
  parentSubject$$: string | null;
111
111
  }>;
112
112
  };
113
- export { ArvoEvent, createArvoEvent, ArvoDataContentType, ArvoEventData, CloudEventExtension, ArvoEventSchema, CloudEventContext, ArvoExtension, OpenTelemetryExtension, CreateArvoEvent, exceptionToSpan, logToSpan, OpenTelemetryHeaders, TelemetryLogLevel, OTelNull, validateURI, cleanString, ArvoContract, createArvoContract, ArvoContractValidators, ArvoContractRecord, IArvoContract, ResolveArvoContractRecord, ArvoEventFactory, createArvoEventFactory, currentOpenTelemetryHeaders, OpenInference, OpenInferenceSpanKind, ArvoExecution, ArvoExecutionSpanKind, ArvoContractJSONSchema, ArvoOrchestrationSubject, ArvoOrchestrationSubjectContent, ArvoSemanticVersion, InferArvoEvent, createArvoOrchestratorContract, ICreateArvoOrchestratorContract, ArvoOrchestratorEventTypeGen, EventDataschemaUtil, ArvoOrchestrationSubjectContentSchema, ArvoSemanticVersionSchema, ArvoErrorSchema, ArvoErrorType, compareSemanticVersions, parseSemanticVersion, createSimpleArvoContract, ArvoOrchestratorContract, VersionedArvoContract, InferVersionedArvoContract, isWildCardArvoSematicVersion, WildCardArvoSemanticVersion, isValidArvoSemanticVersion, SimpleArvoContract, ArvoOrchestratorEventFactory, createArvoOrchestratorEventFactory, ArvoOpenTelemetry, ViolationError, ViolationErrorParam, createArvoError, createArvoEventId, parseArvoEventId, ArvoEventIdObjectSchema, ArvoEventIdObject, };
113
+ export { ArvoEvent, createArvoEvent, ArvoDataContentType, ArvoEventData, CloudEventExtension, ArvoEventSchema, CloudEventContext, ArvoExtension, OpenTelemetryExtension, CreateArvoEvent, exceptionToSpan, logToSpan, OpenTelemetryHeaders, TelemetryLogLevel, OTelNull, validateURI, cleanString, ArvoContract, createArvoContract, ArvoContractValidators, ArvoContractRecord, IArvoContract, ResolveArvoContractRecord, ArvoEventFactory, createArvoEventFactory, currentOpenTelemetryHeaders, OpenInference, OpenInferenceSpanKind, ArvoExecution, ArvoExecutionSpanKind, ArvoContractJSONSchema, ArvoOrchestrationSubject, ArvoOrchestrationSubjectContent, ArvoSemanticVersion, InferArvoEvent, createArvoOrchestratorContract, ICreateArvoOrchestratorContract, ArvoOrchestratorEventTypeGen, EventDataschemaUtil, ArvoOrchestrationSubjectContentSchema, ArvoSemanticVersionSchema, ArvoErrorSchema, ArvoErrorType, compareSemanticVersions, parseSemanticVersion, createSimpleArvoContract, ArvoOrchestratorContract, VersionedArvoContract, InferVersionedArvoContract, isWildCardArvoSematicVersion, WildCardArvoSemanticVersion, isValidArvoSemanticVersion, SimpleArvoContract, ArvoOrchestratorEventFactory, createArvoOrchestratorEventFactory, ArvoOpenTelemetry, ViolationError, ViolationErrorParam, createArvoError, createArvoEventId, parseArvoEventId, ArvoEventIdObjectSchema, ArvoEventIdObject, isViolationError, };
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ArvoEventIdObjectSchema = exports.parseArvoEventId = exports.createArvoEventId = exports.createArvoError = exports.ViolationError = exports.ArvoOpenTelemetry = exports.createArvoOrchestratorEventFactory = exports.ArvoOrchestratorEventFactory = exports.isValidArvoSemanticVersion = exports.WildCardArvoSemanticVersion = exports.isWildCardArvoSematicVersion = exports.VersionedArvoContract = exports.createSimpleArvoContract = exports.parseSemanticVersion = exports.compareSemanticVersions = exports.ArvoErrorSchema = exports.ArvoSemanticVersionSchema = exports.ArvoOrchestrationSubjectContentSchema = exports.EventDataschemaUtil = exports.ArvoOrchestratorEventTypeGen = exports.createArvoOrchestratorContract = exports.ArvoOrchestrationSubject = exports.ArvoExecutionSpanKind = exports.ArvoExecution = exports.OpenInferenceSpanKind = exports.OpenInference = exports.currentOpenTelemetryHeaders = exports.createArvoEventFactory = exports.ArvoEventFactory = exports.ArvoContractValidators = exports.createArvoContract = exports.ArvoContract = exports.cleanString = exports.validateURI = exports.OTelNull = exports.logToSpan = exports.exceptionToSpan = exports.ArvoEventSchema = exports.ArvoDataContentType = exports.createArvoEvent = exports.ArvoEvent = void 0;
6
+ exports.isViolationError = exports.ArvoEventIdObjectSchema = exports.parseArvoEventId = exports.createArvoEventId = exports.createArvoError = exports.ViolationError = exports.ArvoOpenTelemetry = exports.createArvoOrchestratorEventFactory = exports.ArvoOrchestratorEventFactory = exports.isValidArvoSemanticVersion = exports.WildCardArvoSemanticVersion = exports.isWildCardArvoSematicVersion = exports.VersionedArvoContract = exports.createSimpleArvoContract = exports.parseSemanticVersion = exports.compareSemanticVersions = exports.ArvoErrorSchema = exports.ArvoSemanticVersionSchema = exports.ArvoOrchestrationSubjectContentSchema = exports.EventDataschemaUtil = exports.ArvoOrchestratorEventTypeGen = exports.createArvoOrchestratorContract = exports.ArvoOrchestrationSubject = exports.ArvoExecutionSpanKind = exports.ArvoExecution = exports.OpenInferenceSpanKind = exports.OpenInference = exports.currentOpenTelemetryHeaders = exports.createArvoEventFactory = exports.ArvoEventFactory = exports.ArvoContractValidators = exports.createArvoContract = exports.ArvoContract = exports.cleanString = exports.validateURI = exports.OTelNull = exports.logToSpan = exports.exceptionToSpan = exports.ArvoEventSchema = exports.ArvoDataContentType = exports.createArvoEvent = exports.ArvoEvent = void 0;
7
7
  var ArvoContract_1 = __importDefault(require("./ArvoContract"));
8
8
  exports.ArvoContract = ArvoContract_1.default;
9
9
  var helpers_1 = require("./ArvoContract/helpers");
@@ -36,6 +36,10 @@ Object.defineProperty(exports, "WildCardArvoSemanticVersion", { enumerable: true
36
36
  Object.defineProperty(exports, "isWildCardArvoSematicVersion", { enumerable: true, get: function () { return WildCardArvoSemanticVersion_1.isWildCardArvoSematicVersion; } });
37
37
  var validators_1 = require("./ArvoContract/validators");
38
38
  Object.defineProperty(exports, "ArvoContractValidators", { enumerable: true, get: function () { return validators_1.ArvoContractValidators; } });
39
+ var id_1 = require("./ArvoEvent/id");
40
+ Object.defineProperty(exports, "ArvoEventIdObjectSchema", { enumerable: true, get: function () { return id_1.ArvoEventIdObjectSchema; } });
41
+ Object.defineProperty(exports, "createArvoEventId", { enumerable: true, get: function () { return id_1.createArvoEventId; } });
42
+ Object.defineProperty(exports, "parseArvoEventId", { enumerable: true, get: function () { return id_1.parseArvoEventId; } });
39
43
  var ArvoEventFactory_1 = __importDefault(require("./ArvoEventFactory"));
40
44
  exports.ArvoEventFactory = ArvoEventFactory_1.default;
41
45
  var Orchestrator_1 = require("./ArvoEventFactory/Orchestrator");
@@ -62,14 +66,11 @@ var types_2 = require("./OpenTelemetry/OpenInference/types");
62
66
  Object.defineProperty(exports, "OpenInferenceSpanKind", { enumerable: true, get: function () { return types_2.OpenInferenceSpanKind; } });
63
67
  var errors_1 = require("./errors");
64
68
  Object.defineProperty(exports, "ViolationError", { enumerable: true, get: function () { return errors_1.ViolationError; } });
69
+ Object.defineProperty(exports, "isViolationError", { enumerable: true, get: function () { return errors_1.isViolationError; } });
65
70
  var schema_4 = require("./schema");
66
71
  Object.defineProperty(exports, "ArvoErrorSchema", { enumerable: true, get: function () { return schema_4.ArvoErrorSchema; } });
67
72
  Object.defineProperty(exports, "ArvoSemanticVersionSchema", { enumerable: true, get: function () { return schema_4.ArvoSemanticVersionSchema; } });
68
73
  Object.defineProperty(exports, "isValidArvoSemanticVersion", { enumerable: true, get: function () { return schema_4.isValidArvoSemanticVersion; } });
69
- var id_1 = require("./ArvoEvent/id");
70
- Object.defineProperty(exports, "ArvoEventIdObjectSchema", { enumerable: true, get: function () { return id_1.ArvoEventIdObjectSchema; } });
71
- Object.defineProperty(exports, "createArvoEventId", { enumerable: true, get: function () { return id_1.createArvoEventId; } });
72
- Object.defineProperty(exports, "parseArvoEventId", { enumerable: true, get: function () { return id_1.parseArvoEventId; } });
73
74
  /**
74
75
  * Collection of Zod schemas for validating various aspects of Arvo events.
75
76
  * @property {z.ZodObject} CloudEventContextSchema - Schema for core CloudEvent properties.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arvo-core",
3
- "version": "3.0.7",
3
+ "version": "3.0.8",
4
4
  "description": "This core package contains all the core classes and components of the Arvo Event Driven System",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {