arvo-core 2.0.5 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -60,7 +60,7 @@ export default class ArvoContract<TUri extends string = string, TType extends st
60
60
  /**
61
61
  * Get the latest version of the contract
62
62
  */
63
- get latestVersion(): ArvoSemanticVersion | undefined;
63
+ get latestVersion(): ArvoSemanticVersion;
64
64
  /**
65
65
  * Gets the type and schema of the event that the contact
66
66
  * bound handler listens to.
@@ -35,6 +35,9 @@ var ArvoContract = /** @class */ (function () {
35
35
  this._type = params.type;
36
36
  this._versions = params.versions;
37
37
  this.description = (_a = params.description) !== null && _a !== void 0 ? _a : null;
38
+ if (!Object.keys(this._versions).length) {
39
+ throw new Error("A contract must have at least one version");
40
+ }
38
41
  }
39
42
  Object.defineProperty(ArvoContract.prototype, "uri", {
40
43
  /**
@@ -144,7 +144,8 @@ var ArvoEventFactory = /** @class */ (function () {
144
144
  try {
145
145
  var validationResult = (_b = (_a = _this.contract.emits) === null || _a === void 0 ? void 0 : _a[event.type]) === null || _b === void 0 ? void 0 : _b.safeParse(event.data);
146
146
  if (!(validationResult === null || validationResult === void 0 ? void 0 : validationResult.success)) {
147
- throw new Error("Emit Event data validation failed: ".concat((_d = (_c = validationResult === null || validationResult === void 0 ? void 0 : validationResult.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : "No contract available for ".concat(event.type)));
147
+ var msg = (_d = (_c = validationResult === null || validationResult === void 0 ? void 0 : validationResult.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : "No contract available for ".concat(event.type);
148
+ throw new Error("Emit Event data validation failed: ".concat(msg));
148
149
  }
149
150
  return (0, helpers_1.createArvoEvent)(__assign(__assign({}, event), { traceparent: (_f = (_e = event.traceparent) !== null && _e !== void 0 ? _e : otelHeaders.traceparent) !== null && _f !== void 0 ? _f : undefined, tracestate: (_h = (_g = event.tracestate) !== null && _g !== void 0 ? _g : otelHeaders.tracestate) !== null && _h !== void 0 ? _h : undefined, datacontenttype: schema_1.ArvoDataContentType, dataschema: "".concat(_this.contract.uri, "/").concat(_this.contract.version), data: validationResult.data }), extensions, opentelemetry);
150
151
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arvo-core",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
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": {