arvo-core 1.0.27 → 1.0.29

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -48,3 +48,7 @@
48
48
 
49
49
  - Added OpenTelemetry attributes for Arvo and OpenInference
50
50
 
51
+ ## [1.0.28] - 2024-09-10
52
+
53
+ - Added SonarCloud integration for code scanning
54
+
@@ -31,10 +31,11 @@ var ArvoContract = /** @class */ (function () {
31
31
  * @param params - The contract parameters.
32
32
  */
33
33
  function ArvoContract(params) {
34
+ var _a;
34
35
  this._uri = validators_1.ArvoContractValidators.contract.uri.parse(params.uri);
35
36
  this._accepts = this._validateAccepts(params.accepts);
36
37
  this._emits = this._validateEmits(params.emits);
37
- this.description = params.description || null;
38
+ this.description = (_a = params.description) !== null && _a !== void 0 ? _a : null;
38
39
  }
39
40
  Object.defineProperty(ArvoContract.prototype, "uri", {
40
41
  /**
@@ -47,6 +47,7 @@ var uuid_1 = require("uuid");
47
47
  var createArvoEvent = function (event, extensions) {
48
48
  var span = OpenTelemetry_1.ArvoCoreTracer.startSpan("createArvoEvent<".concat(event.type, ">"), {});
49
49
  return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), function () {
50
+ var _a, _b, _c, _d, _e, _f, _g, _h;
50
51
  span.setStatus({ code: api_1.SpanStatusCode.OK });
51
52
  try {
52
53
  if (event.datacontenttype &&
@@ -58,15 +59,15 @@ var createArvoEvent = function (event, extensions) {
58
59
  });
59
60
  }
60
61
  return new _1.default({
61
- id: event.id || (0, uuid_1.v4)(),
62
+ id: (_a = event.id) !== null && _a !== void 0 ? _a : (0, uuid_1.v4)(),
62
63
  type: event.type,
63
- accesscontrol: event.accesscontrol || null,
64
- executionunits: event.executionunits || null,
65
- traceparent: event.traceparent || null,
66
- tracestate: event.tracestate || null,
67
- datacontenttype: event.datacontenttype || schema_1.ArvoDataContentType,
68
- specversion: event.specversion || '1.0',
69
- time: event.time || (0, utils_1.createTimestamp)(),
64
+ accesscontrol: (_b = event.accesscontrol) !== null && _b !== void 0 ? _b : null,
65
+ executionunits: (_c = event.executionunits) !== null && _c !== void 0 ? _c : null,
66
+ traceparent: (_d = event.traceparent) !== null && _d !== void 0 ? _d : null,
67
+ tracestate: (_e = event.tracestate) !== null && _e !== void 0 ? _e : null,
68
+ datacontenttype: (_f = event.datacontenttype) !== null && _f !== void 0 ? _f : schema_1.ArvoDataContentType,
69
+ specversion: (_g = event.specversion) !== null && _g !== void 0 ? _g : '1.0',
70
+ time: (_h = event.time) !== null && _h !== void 0 ? _h : (0, utils_1.createTimestamp)(),
70
71
  source: encodeURI(event.source),
71
72
  subject: encodeURI(event.subject),
72
73
  to: event.to ? encodeURI(event.to) : null,
@@ -105,6 +105,7 @@ var ArvoEvent = /** @class */ (function () {
105
105
  * as `cloudevents.arvo.event_*` fields
106
106
  */
107
107
  get: function () {
108
+ var _a, _b, _c, _d;
108
109
  return {
109
110
  'cloudevents.event_id': this.id || OpenTelemetry_1.OTelNull,
110
111
  'cloudevents.event_source': this.source || OpenTelemetry_1.OTelNull,
@@ -113,10 +114,10 @@ var ArvoEvent = /** @class */ (function () {
113
114
  'cloudevents.event_type': this.type || OpenTelemetry_1.OTelNull,
114
115
  'cloudevents.event_time': this.time || OpenTelemetry_1.OTelNull,
115
116
  'cloudevents.event_datacontenttype': this.datacontenttype || OpenTelemetry_1.OTelNull,
116
- 'cloudevents.event_dataschema': this.dataschema || OpenTelemetry_1.OTelNull,
117
- 'cloudevents.arvo.event_redirectto': this.extensions.redirectto || OpenTelemetry_1.OTelNull,
118
- 'cloudevents.arvo.event_to': this.extensions.to || OpenTelemetry_1.OTelNull,
119
- 'cloudevents.arvo.event_executionunits': this.extensions.executionunits || OpenTelemetry_1.OTelNull,
117
+ 'cloudevents.event_dataschema': (_a = this.dataschema) !== null && _a !== void 0 ? _a : OpenTelemetry_1.OTelNull,
118
+ 'cloudevents.arvo.event_redirectto': (_b = this.extensions.redirectto) !== null && _b !== void 0 ? _b : OpenTelemetry_1.OTelNull,
119
+ 'cloudevents.arvo.event_to': (_c = this.extensions.to) !== null && _c !== void 0 ? _c : OpenTelemetry_1.OTelNull,
120
+ 'cloudevents.arvo.event_executionunits': (_d = this.extensions.executionunits) !== null && _d !== void 0 ? _d : OpenTelemetry_1.OTelNull,
120
121
  };
121
122
  },
122
123
  enumerable: false,
@@ -124,13 +124,14 @@ var ArvoEventFactory = /** @class */ (function () {
124
124
  var _this = this;
125
125
  var span = OpenTelemetry_1.ArvoCoreTracer.startSpan("ArvoEventFactory<".concat(this.contract.uri, ">.systemError<sys.").concat(this.contract.accepts.type, ".error>.create"));
126
126
  return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), function () {
127
+ var _a;
127
128
  span.setStatus({ code: api_1.SpanStatusCode.OK });
128
129
  try {
129
130
  var error = event.error, _events = __rest(event, ["error"]);
130
131
  return (0, helpers_1.createArvoEvent)(__assign(__assign({}, event), { type: "sys.".concat(_this.contract.accepts.type, ".error"), data: {
131
132
  errorName: error.name,
132
133
  errorMessage: error.message,
133
- errorStack: error.stack || null,
134
+ errorStack: (_a = error.stack) !== null && _a !== void 0 ? _a : null,
134
135
  }, datacontenttype: schema_1.ArvoDataContentType, dataschema: _this.contract.uri }), extensions);
135
136
  }
136
137
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arvo-core",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
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": {