arvo-core 2.2.4 → 2.2.6
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.
| @@ -3,6 +3,8 @@ import { ArvoSemanticVersion } from '../../types'; | |
| 3 3 | 
             
            import { ArvoContractRecord } from '../types';
         | 
| 4 4 | 
             
            import { IVersionedArvoContract, VersionedArvoContractJSONSchema } from './types';
         | 
| 5 5 | 
             
            import { transformEmitsToArray } from './utils';
         | 
| 6 | 
            +
            import { EventDataschemaUtil } from '../../utils';
         | 
| 7 | 
            +
            import { WildCardArvoSemanticVersion } from '../WildCardArvoSemanticVersion';
         | 
| 6 8 | 
             
            /**
         | 
| 7 9 | 
             
             * Implements a version-specific view of an ArvoContract with type-safe schema validation
         | 
| 8 10 | 
             
             * and JSON Schema generation capabilities.
         | 
| @@ -17,10 +19,13 @@ export declare class VersionedArvoContract<TContract extends ArvoContract, TVers | |
| 17 19 | 
             
                get version(): TVersion;
         | 
| 18 20 | 
             
                get description(): TContract['description'];
         | 
| 19 21 | 
             
                get metadata(): TContract['metadata'];
         | 
| 20 | 
            -
                get systemError(): TContract['systemError'] | 
| 22 | 
            +
                get systemError(): TContract['systemError'] & {
         | 
| 23 | 
            +
                    dataschema: ReturnType<typeof EventDataschemaUtil.build<TContract['uri'], typeof WildCardArvoSemanticVersion>>;
         | 
| 24 | 
            +
                };
         | 
| 21 25 | 
             
                get accepts(): ArvoContractRecord<TContract["type"], TContract["versions"][TVersion]["accepts"]>;
         | 
| 22 26 | 
             
                get emits(): TContract["versions"][TVersion]["emits"];
         | 
| 23 27 | 
             
                get emitList(): { [K in keyof TContract["versions"][TVersion]["emits"] & string]: ArvoContractRecord<K, TContract["versions"][TVersion]["emits"][K]>; }[keyof TContract["versions"][TVersion]["emits"] & string][];
         | 
| 28 | 
            +
                get dataschema(): `${TContract["uri"]}/${TVersion}`;
         | 
| 24 29 | 
             
                constructor(param: IVersionedArvoContract<TContract, TVersion>);
         | 
| 25 30 | 
             
                /**
         | 
| 26 31 | 
             
                 * Converts the contract to JSON Schema format
         | 
| @@ -1,4 +1,15 @@ | |
| 1 1 | 
             
            "use strict";
         | 
| 2 | 
            +
            var __assign = (this && this.__assign) || function () {
         | 
| 3 | 
            +
                __assign = Object.assign || function(t) {
         | 
| 4 | 
            +
                    for (var s, i = 1, n = arguments.length; i < n; i++) {
         | 
| 5 | 
            +
                        s = arguments[i];
         | 
| 6 | 
            +
                        for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
         | 
| 7 | 
            +
                            t[p] = s[p];
         | 
| 8 | 
            +
                    }
         | 
| 9 | 
            +
                    return t;
         | 
| 10 | 
            +
                };
         | 
| 11 | 
            +
                return __assign.apply(this, arguments);
         | 
| 12 | 
            +
            };
         | 
| 2 13 | 
             
            var __importDefault = (this && this.__importDefault) || function (mod) {
         | 
| 3 14 | 
             
                return (mod && mod.__esModule) ? mod : { "default": mod };
         | 
| 4 15 | 
             
            };
         | 
| @@ -7,6 +18,8 @@ exports.VersionedArvoContract = void 0; | |
| 7 18 | 
             
            var zod_to_json_schema_1 = __importDefault(require("zod-to-json-schema"));
         | 
| 8 19 | 
             
            var utils_1 = require("./utils");
         | 
| 9 20 | 
             
            var OpenTelemetry_1 = require("../../OpenTelemetry");
         | 
| 21 | 
            +
            var utils_2 = require("../../utils");
         | 
| 22 | 
            +
            var WildCardArvoSemanticVersion_1 = require("../WildCardArvoSemanticVersion");
         | 
| 10 23 | 
             
            /**
         | 
| 11 24 | 
             
             * Implements a version-specific view of an ArvoContract with type-safe schema validation
         | 
| 12 25 | 
             
             * and JSON Schema generation capabilities.
         | 
| @@ -52,7 +65,7 @@ var VersionedArvoContract = /** @class */ (function () { | |
| 52 65 | 
             
                });
         | 
| 53 66 | 
             
                Object.defineProperty(VersionedArvoContract.prototype, "systemError", {
         | 
| 54 67 | 
             
                    get: function () {
         | 
| 55 | 
            -
                        return this._contract.systemError;
         | 
| 68 | 
            +
                        return __assign(__assign({}, this._contract.systemError), { dataschema: utils_2.EventDataschemaUtil.build(this.uri, WildCardArvoSemanticVersion_1.WildCardArvoSemanticVersion) });
         | 
| 56 69 | 
             
                    },
         | 
| 57 70 | 
             
                    enumerable: false,
         | 
| 58 71 | 
             
                    configurable: true
         | 
| @@ -78,6 +91,13 @@ var VersionedArvoContract = /** @class */ (function () { | |
| 78 91 | 
             
                    enumerable: false,
         | 
| 79 92 | 
             
                    configurable: true
         | 
| 80 93 | 
             
                });
         | 
| 94 | 
            +
                Object.defineProperty(VersionedArvoContract.prototype, "dataschema", {
         | 
| 95 | 
            +
                    get: function () {
         | 
| 96 | 
            +
                        return utils_2.EventDataschemaUtil.build(this.uri, this.version);
         | 
| 97 | 
            +
                    },
         | 
| 98 | 
            +
                    enumerable: false,
         | 
| 99 | 
            +
                    configurable: true
         | 
| 100 | 
            +
                });
         | 
| 81 101 | 
             
                /**
         | 
| 82 102 | 
             
                 * Converts the contract to JSON Schema format
         | 
| 83 103 | 
             
                 * @returns Contract specification in JSON Schema format for documentation/serialization
         | 
    
        package/dist/errors.d.ts
    CHANGED
    
    | @@ -1,11 +1,35 @@ | |
| 1 | 
            +
            /**
         | 
| 2 | 
            +
             * Parameters for constructing a ViolationError
         | 
| 3 | 
            +
             */
         | 
| 1 4 | 
             
            export type ViolationErrorParam<T extends string = string> = {
         | 
| 5 | 
            +
                /** The specific type/category of the violation */
         | 
| 2 6 | 
             
                type: T;
         | 
| 7 | 
            +
                /** A human-readable description of what went wrong */
         | 
| 3 8 | 
             
                message: string;
         | 
| 9 | 
            +
                /** Optional structured data providing additional context about the error */
         | 
| 4 10 | 
             
                metadata?: Record<string, any>;
         | 
| 5 11 | 
             
            };
         | 
| 12 | 
            +
            /**
         | 
| 13 | 
            +
             * ViolationError represents errors that require explicit handling in the system.
         | 
| 14 | 
            +
             * These are distinct from recoverable errors that can be automatically handled
         | 
| 15 | 
            +
             * by workflow logic. The explicit handling may be required for severe
         | 
| 16 | 
            +
             * violation of service contracts or explict retry handling
         | 
| 17 | 
            +
             *
         | 
| 18 | 
            +
             * Common violation scenarios include:
         | 
| 19 | 
            +
             * - Execution error like rate limit exceeded on external API calls
         | 
| 20 | 
            +
             * - Contract violations (invalid input/output)
         | 
| 21 | 
            +
             * - Configuration errors
         | 
| 22 | 
            +
             * - Permission/authorization failures
         | 
| 23 | 
            +
             */
         | 
| 6 24 | 
             
            export declare class ViolationError<T extends string = string> extends Error {
         | 
| 25 | 
            +
                /** The specific type/category of the violation */
         | 
| 7 26 | 
             
                readonly type: T;
         | 
| 27 | 
            +
                /** Additional structured data about the violation */
         | 
| 8 28 | 
             
                readonly metadata: Record<string, any> | null;
         | 
| 29 | 
            +
                /**
         | 
| 30 | 
            +
                 * The error name, formatted as ViolationError<TYPE>
         | 
| 31 | 
            +
                 * This helps with error identification in logs and stack traces
         | 
| 32 | 
            +
                 */
         | 
| 9 33 | 
             
                readonly name: `ViolationError<${T}>`;
         | 
| 10 34 | 
             
                constructor({ type, message, metadata }: ViolationErrorParam<T>);
         | 
| 11 35 | 
             
            }
         | 
    
        package/dist/errors.js
    CHANGED
    
    | @@ -16,6 +16,18 @@ var __extends = (this && this.__extends) || (function () { | |
| 16 16 | 
             
            })();
         | 
| 17 17 | 
             
            Object.defineProperty(exports, "__esModule", { value: true });
         | 
| 18 18 | 
             
            exports.ViolationError = void 0;
         | 
| 19 | 
            +
            /**
         | 
| 20 | 
            +
             * ViolationError represents errors that require explicit handling in the system.
         | 
| 21 | 
            +
             * These are distinct from recoverable errors that can be automatically handled
         | 
| 22 | 
            +
             * by workflow logic. The explicit handling may be required for severe
         | 
| 23 | 
            +
             * violation of service contracts or explict retry handling
         | 
| 24 | 
            +
             *
         | 
| 25 | 
            +
             * Common violation scenarios include:
         | 
| 26 | 
            +
             * - Execution error like rate limit exceeded on external API calls
         | 
| 27 | 
            +
             * - Contract violations (invalid input/output)
         | 
| 28 | 
            +
             * - Configuration errors
         | 
| 29 | 
            +
             * - Permission/authorization failures
         | 
| 30 | 
            +
             */
         | 
| 19 31 | 
             
            var ViolationError = /** @class */ (function (_super) {
         | 
| 20 32 | 
             
                __extends(ViolationError, _super);
         | 
| 21 33 | 
             
                function ViolationError(_a) {
         | 
    
        package/dist/utils.d.ts
    CHANGED
    
    | @@ -1,5 +1,4 @@ | |
| 1 1 | 
             
            import { VersionedArvoContract } from './ArvoContract/VersionedArvoContract';
         | 
| 2 | 
            -
            import { WildCardArvoSemanticVersion } from './ArvoContract/WildCardArvoSemanticVersion';
         | 
| 3 2 | 
             
            import ArvoEvent from './ArvoEvent';
         | 
| 4 3 | 
             
            import { ArvoSemanticVersion } from './types';
         | 
| 5 4 | 
             
            /**
         | 
| @@ -76,6 +75,7 @@ export declare function compareSemanticVersions(version1: ArvoSemanticVersion, v | |
| 76 75 | 
             
             * Handles creation and parsing of dataschema identifiers.
         | 
| 77 76 | 
             
             */
         | 
| 78 77 | 
             
            export declare class EventDataschemaUtil {
         | 
| 78 | 
            +
                static build<TUri extends string, TVersion extends ArvoSemanticVersion>(uri: TUri, version: TVersion): `${TUri}/${TVersion}`;
         | 
| 79 79 | 
             
                /**
         | 
| 80 80 | 
             
                 * Creates a dataschema string from a versioned contract.
         | 
| 81 81 | 
             
                 * Format: `{contract.uri}/{contract.version}`
         | 
| @@ -89,13 +89,13 @@ export declare class EventDataschemaUtil { | |
| 89 89 | 
             
                 * // Returns: "my-contract/1.0.0"
         | 
| 90 90 | 
             
                 * ```
         | 
| 91 91 | 
             
                 */
         | 
| 92 | 
            -
                static create<T extends VersionedArvoContract<any, any>>(contract: T): `${T[ | 
| 92 | 
            +
                static create<T extends VersionedArvoContract<any, any>>(contract: T): `${T["uri"]}/${T["version"]}`;
         | 
| 93 93 | 
             
                /**
         | 
| 94 94 | 
             
                 * Creates dataschema string with wildcard version.
         | 
| 95 95 | 
             
                 * @param contract Versioned contract
         | 
| 96 96 | 
             
                 * @returns `{contract.uri}/{WildCardArvoSemanticVersion}`
         | 
| 97 97 | 
             
                 */
         | 
| 98 | 
            -
                static createWithWildCardVersion<T extends VersionedArvoContract<any, any>>(contract: T): `${T[ | 
| 98 | 
            +
                static createWithWildCardVersion<T extends VersionedArvoContract<any, any>>(contract: T): `${T["uri"]}/0.0.0`;
         | 
| 99 99 | 
             
                /**
         | 
| 100 100 | 
             
                 * Extracts URI and version from dataschema string.
         | 
| 101 101 | 
             
                 *
         | 
    
        package/dist/utils.js
    CHANGED
    
    | @@ -120,6 +120,9 @@ function compareSemanticVersions(version1, version2) { | |
| 120 120 | 
             
            var EventDataschemaUtil = /** @class */ (function () {
         | 
| 121 121 | 
             
                function EventDataschemaUtil() {
         | 
| 122 122 | 
             
                }
         | 
| 123 | 
            +
                EventDataschemaUtil.build = function (uri, version) {
         | 
| 124 | 
            +
                    return "".concat(uri, "/").concat(version);
         | 
| 125 | 
            +
                };
         | 
| 123 126 | 
             
                /**
         | 
| 124 127 | 
             
                 * Creates a dataschema string from a versioned contract.
         | 
| 125 128 | 
             
                 * Format: `{contract.uri}/{contract.version}`
         | 
| @@ -134,7 +137,7 @@ var EventDataschemaUtil = /** @class */ (function () { | |
| 134 137 | 
             
                 * ```
         | 
| 135 138 | 
             
                 */
         | 
| 136 139 | 
             
                EventDataschemaUtil.create = function (contract) {
         | 
| 137 | 
            -
                    return  | 
| 140 | 
            +
                    return EventDataschemaUtil.build(contract.uri, contract.version);
         | 
| 138 141 | 
             
                };
         | 
| 139 142 | 
             
                /**
         | 
| 140 143 | 
             
                 * Creates dataschema string with wildcard version.
         | 
| @@ -142,7 +145,7 @@ var EventDataschemaUtil = /** @class */ (function () { | |
| 142 145 | 
             
                 * @returns `{contract.uri}/{WildCardArvoSemanticVersion}`
         | 
| 143 146 | 
             
                 */
         | 
| 144 147 | 
             
                EventDataschemaUtil.createWithWildCardVersion = function (contract) {
         | 
| 145 | 
            -
                    return  | 
| 148 | 
            +
                    return EventDataschemaUtil.build(contract.uri, WildCardArvoSemanticVersion_1.WildCardArvoSemanticVersion);
         | 
| 146 149 | 
             
                };
         | 
| 147 150 | 
             
                /**
         | 
| 148 151 | 
             
                 * Extracts URI and version from dataschema string.
         |