@mindignited/continuum-client 3.0.0-beta.1 → 3.0.0-beta.2
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/continuum.cjs +2 -2
- package/dist/continuum.cjs.map +1 -1
- package/dist/continuum.js +58 -56
- package/dist/continuum.js.map +1 -1
- package/package.json +1 -1
package/dist/continuum.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Q=require("@stomp/rx-stomp"),ee=require("@stomp/stompjs"),A=require("uuid"),L=require("debug"),f=require("@opentelemetry/api"),g=require("rxjs"),v=require("rxjs/operators"),x=require("typescript-optional");require("reflect-metadata");const D=require("@opentelemetry/semantic-conventions");class te{}class C{host;port;useSSL}class re extends C{connectHeaders;maxConnectionAttempts;disableStickySession}class R extends Error{constructor(e){super(e),Object.setPrototypeOf(this,R.prototype)}}var o=(s=>(s.CONTENT_TYPE_HEADER="content-type",s.CONTENT_LENGTH_HEADER="content-length",s.REPLY_TO_HEADER="reply-to",s.REPLY_TO_ID_HEADER="reply-to-id",s.SESSION_HEADER="session",s.CONNECTED_INFO_HEADER="connected-info",s.DISABLE_STICKY_SESSION_HEADER="disable-sticky-session",s.CORRELATION_ID_HEADER="__correlation-id",s.ERROR_HEADER="error",s.COMPLETE_HEADER="complete",s.CONTROL_HEADER="control",s.CONTROL_VALUE_COMPLETE="complete",s.CONTROL_VALUE_CANCEL="cancel",s.CONTROL_VALUE_SUSPEND="suspend",s.CONTROL_VALUE_RESUME="resume",s.SERVICE_DESTINATION_PREFIX="srv://",s.SERVICE_DESTINATION_SCHEME="srv",s.STREAM_DESTINATION_PREFIX="stream://",s.STREAM_DESTINATION_SCHEME="stream",s.CONTENT_JSON="application/json",s.CONTENT_TEXT="text/plain",s.TRACEPARENT_HEADER="traceparent",s.TRACESTATE_HEADER="tracestate",s))(o||{});class se{lastWebsocketError=null;maxConnectionAttemptsReached=!1;rxStomp=null;INITIAL_RECONNECT_DELAY=2e3;MAX_RECONNECT_DELAY=12e4;JITTER_MAX=5e3;connectionAttempts=0;initialConnectionSuccessful=!1;debugLogger=L("continuum:stomp");replyToId=A.v4();replyToCri=o.SERVICE_DESTINATION_PREFIX+this.replyToId+":"+A.v4()+"@continuum.js.EventBus/replyHandler";deactivationHandler=null;get active(){return!!this.rxStomp}get connected(){return this.rxStomp!=null&&this.rxStomp.connected()}activate(e){return new Promise((t,r)=>{if(!e){r("You must supply a valid connectionInfo object");return}if(!e.host){r("No host provided");return}if(this.rxStomp){r("Stomp connection already active");return}this.connectionAttempts=0,this.initialConnectionSuccessful=!1,this.lastWebsocketError=null,this.maxConnectionAttemptsReached=!1;const n="ws"+(e.useSSL?"s":"")+"://"+e.host+(e.port?":"+e.port:"")+"/v1";this.rxStomp=new Q.RxStomp;let i=typeof e.connectHeaders!="function"&&e.connectHeaders!=null?e.connectHeaders:{};const c={brokerURL:n,connectHeaders:i,heartbeatIncoming:12e4,heartbeatOutgoing:3e4,reconnectDelay:this.INITIAL_RECONNECT_DELAY,beforeConnect:async()=>{if(typeof e.connectHeaders=="function"){const u=await e.connectHeaders();for(const l in u)i[l]=u[l]}if(e.disableStickySession&&(i[o.DISABLE_STICKY_SESSION_HEADER]="true"),i[o.REPLY_TO_ID_HEADER]=this.replyToId,e?.maxConnectionAttempts)if(this.connectionAttempts++,this.connectionAttempts>e.maxConnectionAttempts){if(this.maxConnectionAttemptsReached=!0,await this.deactivate(),!this.initialConnectionSuccessful){let u=this.lastWebsocketError?.message?this.lastWebsocketError?.message:"UNKNOWN";r(`Max number of reconnection attempts reached. Last WS Error ${u}`)}}else await this.connectionJitterDelay();else await this.connectionJitterDelay()}};this.debugLogger.enabled&&(c.debug=u=>{this.debugLogger(u)}),this.rxStomp.configure(c),this.rxStomp.stompClient.maxReconnectDelay=this.MAX_RECONNECT_DELAY,this.rxStomp.stompClient.reconnectTimeMode=ee.ReconnectionTimeMode.EXPONENTIAL,this.rxStomp.webSocketErrors$.subscribe(u=>{this.lastWebsocketError=u});const a=this.rxStomp.connected$.subscribe(()=>{a.unsubscribe(),this.initialConnectionSuccessful||(this.initialConnectionSuccessful=!0)}),h=this.rxStomp.stompErrors$.subscribe(u=>{h.unsubscribe();const l=u.headers.message;this.rxStomp?.deactivate(),this.rxStomp=null,r(l)}),p=this.rxStomp.serverHeaders$.subscribe(u=>{let l=u[o.CONNECTED_INFO_HEADER];if(l!=null){const d=JSON.parse(l);if(e.disableStickySession)if(typeof e.connectHeaders=="function"){for(let T in i)delete i[T];this.initialConnectionSuccessful||t(d)}else typeof e.connectHeaders=="object"&&(p.unsubscribe(),t(d));else if(p.unsubscribe(),d.sessionId!=null&&d.replyToId!=null){if(e.connectHeaders!=null)for(let T in i)delete i[T];i[o.SESSION_HEADER]=d.sessionId,t(d)}else r("Server did not return proper data for successful login")}else r("Server did not return proper data for successful login")});this.rxStomp.activate()})}async deactivate(e){this.rxStomp&&(await this.rxStomp.deactivate({force:e}),this.deactivationHandler&&this.deactivationHandler(),this.rxStomp=null)}async connectionJitterDelay(){if(this.initialConnectionSuccessful){const e=Math.random()*this.JITTER_MAX;return this.debugLogger(`Adding ${e}ms of jitter delay`),new Promise(t=>setTimeout(t,e))}}}class m{cri;headers;data;constructor(e,t,r){this.cri=e,t!==void 0?this.headers=t:this.headers=new Map,this.data=x.Optional.ofNullable(r)}getHeader(e){return this.headers.get(e)}hasHeader(e){return this.headers.has(e)}setHeader(e,t){this.headers.set(e,t)}removeHeader(e){return this.headers.delete(e)}setDataString(e){const t=new TextEncoder().encode(e);this.data=x.Optional.ofNonNull(t)}getDataString(){let e="";return this.data.ifPresent(t=>e=new TextDecoder().decode(t)),e}}class H{fatalErrors;serverInfo=null;stompConnectionManager=new se;replyToCri=null;requestRepliesObservable=null;requestRepliesSubject=null;requestRepliesSubscription=null;errorSubject=new g.Subject;errorSubjectSubscription=null;constructor(){this.fatalErrors=this.errorSubject.pipe(v.map(e=>(this.disconnect().catch(t=>{console&&console.error("Error disconnecting from Stomp: "+t)}),new R(e.headers.message)))),this.stompConnectionManager.deactivationHandler=()=>{this.cleanup()}}isConnectionActive(){return this.stompConnectionManager.active}isConnected(){return this.stompConnectionManager.connected}async connect(e){if(this.stompConnectionManager.active)throw new Error("Event Bus connection already active");{this.cleanup();const t=await this.stompConnectionManager.activate(e);return this.serverInfo=new C,this.serverInfo.host=e.host,this.serverInfo.port=e.port,this.serverInfo.useSSL=e.useSSL,this.replyToCri=this.stompConnectionManager.replyToCri,this.errorSubjectSubscription=this.stompConnectionManager.rxStomp?.stompErrors$.subscribe(this.errorSubject),t}}async disconnect(e){await this.stompConnectionManager.deactivate(e),this.cleanup()}send(e){if(this.stompConnectionManager.rxStomp){const t={};for(const[n,i]of e.headers.entries())t[n]=i;const r={};f.propagation.inject(f.context.active(),r),r.traceparent&&(t[o.TRACEPARENT_HEADER]=r.traceparent),r.tracestate&&(t[o.TRACESTATE_HEADER]=r.tracestate),this.stompConnectionManager.rxStomp.publish({destination:e.cri,headers:t,binaryBody:e.data.orUndefined()})}else throw this.createSendUnavailableError()}request(e){return g.firstValueFrom(this.requestStream(e,!1))}requestStream(e,t=!0){return this.stompConnectionManager?.rxStomp?new g.Observable(r=>{this.requestRepliesObservable==null&&(this.requestRepliesSubject=new g.Subject,this.requestRepliesObservable=this._observe(this.replyToCri).pipe(v.multicast(this.requestRepliesSubject)),this.requestRepliesSubscription=this.requestRepliesObservable.connect());let n=!1;const i=A.v4(),c=this.requestRepliesObservable.pipe(v.filter(a=>a.headers.get(o.CORRELATION_ID_HEADER)===i)).subscribe({next(a){if(a.hasHeader(o.CONTROL_HEADER))if(a.headers.get(o.CONTROL_HEADER)==="complete")n=!0,r.complete();else throw new Error("Control Header "+a.headers.get(o.CONTROL_HEADER)+" is not supported");else a.hasHeader(o.ERROR_HEADER)?(n=!0,r.error(new Error(a.getHeader(o.ERROR_HEADER)))):r.next(a)},error(a){r.error(a)},complete(){r.complete()}});return r.add(c),e.setHeader(o.REPLY_TO_HEADER,this.replyToCri),e.setHeader(o.CORRELATION_ID_HEADER,i),this.send(e),()=>{if(t&&!n){const a=new m(e.cri);a.setHeader(o.CONTROL_HEADER,o.CONTROL_VALUE_CANCEL),a.setHeader(o.CORRELATION_ID_HEADER,i),this.send(a)}}}):g.throwError(()=>this.createSendUnavailableError())}listen(e){return Promise.reject("Not implemented")}observe(e){return this._observe(e)}cleanup(){this.requestRepliesSubject!=null&&(this.requestRepliesSubject.error(new Error("Connection disconnected")),this.requestRepliesSubscription!=null&&(this.requestRepliesSubscription.unsubscribe(),this.requestRepliesSubscription=null),this.requestRepliesSubject=null,this.requestRepliesObservable=null),this.errorSubjectSubscription&&(this.errorSubjectSubscription.unsubscribe(),this.errorSubjectSubscription=null),this.serverInfo=null}createSendUnavailableError(){let e="You must call connect on the event bus before sending any request";return this.stompConnectionManager.maxConnectionAttemptsReached&&(e="Max connection attempts reached event bus is not available"),new Error(e)}_observe(e){return this.stompConnectionManager?.rxStomp?this.stompConnectionManager.rxStomp.watch(e).pipe(v.map(t=>{const r=new Map;let n="";for(const i of Object.keys(t.headers))i==="destination"?n=t.headers[i]:r.set(i,t.headers[i]);return new m(n,r,t.binaryBody)})):g.throwError(()=>this.createSendUnavailableError())}}class E{_scheme;_scope;_resourceName;_path;_version;_raw;constructor(...e){if(e.length===1){const t=e[0];if(typeof t!="string")throw new Error("Raw URI must be a string");const r=E.parseRaw(t);this._scheme=r.scheme,this._scope=r.scope,this._resourceName=r.resourceName,this._path=r.path,this._version=r.version,this._raw=t}else if(e.length===5){const[t,r,n,i,c]=e;this._scheme=t,this._scope=r,this._resourceName=n,this._path=i,this._version=c,this._raw=E.buildRaw(t,r,n,i,c)}else throw new Error("Invalid constructor arguments for DefaultCRI");if(!this._scheme||!this._resourceName)throw new Error(`Invalid CRI: scheme and resourceName are required. Got: ${this._raw}`)}scheme(){return this._scheme}scope(){return this._scope}hasScope(){return this._scope!==null}resourceName(){return this._resourceName}version(){return this._version}hasVersion(){return this._version!==null}path(){return this._path}hasPath(){return this._path!==null}baseResource(){let e=`${this._scheme}://`;return this.hasScope()&&(e+=`${this._scope}@`),e+=this._resourceName,e}raw(){return this._raw}equals(e){return this===e?!0:e instanceof E?this._raw===e.raw():!1}hashCode(){let e=17;return e=e*37+this._raw.split("").reduce((t,r)=>t+r.charCodeAt(0),0),e}toString(){return this._raw}static parseRaw(e){const t=/^([^:]+):\/\/(?:([^@]+)@)?([^\/#]+)(\/[^#]*)?(?:#(.+))?$/,r=e.match(t);if(!r)throw new Error(`Invalid CRI format: ${e}`);const[,n,i,c,a,h]=r;return{scheme:n,scope:i||null,resourceName:c,path:a?a.substring(1):null,version:h||null}}static buildRaw(e,t,r,n,i){let c=`${e}://`;return t&&(c+=`${t}@`),c+=r,n&&(c+=`/${n}`),i&&(c+=`#${i}`),c}}function I(...s){if(s.length===1)return new E(s[0]);if(s.length===2)return new E(s[0],null,s[1],null,null);if(s.length===3)return new E(s[0],s[1],s[2],null,null);if(s.length===5)return new E(s[0],s[1],s[2],s[3],s[4]);throw new Error("Invalid arguments for createCRI")}class ne{resolveArguments(e){if(this.containsJsonContent(e)){const t=e.getDataString();return t?JSON.parse(t):[]}else throw new Error("Currently only JSON content is supported")}containsJsonContent(e){const t=e.getHeader(o.CONTENT_TYPE_HEADER);return t!=null&&t!==""&&t==="application/json"}}class M{static createReplyEvent(e,t,r){if(!e)throw new Error("incomingHeaders cannot be null");const n=e.get(o.REPLY_TO_HEADER);if(!n||n.trim()==="")throw new Error("No reply-to header found, cannot create outgoing message");const i=new Map;for(const[c,a]of e)c.startsWith("__")&&i.set(c,a);if(t)for(const[c,a]of t)i.set(c,a);return new m(n,i,r||void 0)}}class ie{convert(e,t){return M.createReplyEvent(e,new Map([[o.CONTENT_TYPE_HEADER,"application/json"]]),new TextEncoder().encode(JSON.stringify(t)))}}function oe(s){let e;try{e=require("debug")(s)}catch{e=(...r)=>console.debug(`[${s}]`,...r)}return{trace:(...t)=>e("TRACE",...t),debug:(...t)=>e("DEBUG",...t),info:(...t)=>e("INFO",...t),warn:(...t)=>e("WARN",...t),error:(...t)=>e("ERROR",...t)}}class ce{namespace;name;scope;version;_cri=null;constructor(e,t){this.namespace=e,this.name=t}qualifiedName(){return this.namespace+"."+this.name}cri(){return this._cri==null&&(this._cri=I(o.SERVICE_DESTINATION_SCHEME,this.scope||null,this.qualifiedName(),null,this.version||null)),this._cri}}const k=Symbol("scope"),B=Symbol("version"),_=Symbol("context");function ae(s,e,t){Reflect.defineMetadata(k,e,s)}function ue(s){if(!/^\d+\.\d+\.\d+(-[a-zA-Z0-9]+)?$/.test(s))throw new Error(`Invalid semantic version: ${s}. Must follow X.Y.Z[-optional] format.`);return function(e){Reflect.defineMetadata(B,s,e)}}function le(){return function(s,e,t){const r=Reflect.getMetadata(_,s,e)||[];r.push(t),Reflect.defineMetadata(_,r,s,e)}}function he(s,e){return function(t){const r=t,n=new ce(s,e||t.name),i=Reflect.getMetadata(B,t);i&&(n.version=i);const c=function(...a){const h=Reflect.construct(r,a),p=Reflect.getMetadata(k,t.prototype);if(p){const u=h[p];n.scope=typeof u=="function"?u.call(h):u}return N.serviceRegistry.register(n,h),h};return c.prototype=r.prototype,c}}class pe{log;active=!1;_eventBus;interceptorProvider;argumentResolver;returnValueConverter;serviceIdentifier;serviceInstance;methodSubscription=null;methodMap;constructor(e,t,r,n,i={}){if(!e)throw new Error("ServiceIdentifier must not be null");if(!t)throw new Error("Service instance must not be null");if(!r)throw new Error("IEventBus must not be null");if(!n)throw new Error("interceptorProvider must not be null");this.serviceIdentifier=e,this.serviceInstance=t,this._eventBus=r,this.interceptorProvider=n,this.log=i.logger||oe("continuum:ServiceInvocationSupervisor"),this.argumentResolver=i.argumentResolver||new ne,this.returnValueConverter=i.returnValueConverter||new ie,this.methodMap=this.buildMethodMap(t)}isActive(){return this.active}set eventBus(e){this.active?(this.stop(),this._eventBus=e,this.start()):this._eventBus=e}start(){if(this.active)throw new Error("Service already started");this.active=!0;const e=this.serviceIdentifier.cri().baseResource();this.methodSubscription=this._eventBus.observe(e).subscribe({next:async t=>{await this.processEvent(t)},error:t=>{this.log.error("Event listener error",t),this.active=!1},complete:()=>{this.log.error("Event listener stopped unexpectedly. Setting supervisor inactive."),this.active=!1}}),this.log.info(`ServiceInvocationSupervisor started for ${e}`)}stop(){if(!this.active)throw new Error("Service already stopped");this.active=!1,this.methodSubscription&&(this.methodSubscription.unsubscribe(),this.methodSubscription=null),this.log.info("ServiceInvocationSupervisor stopped")}buildMethodMap(e){const t={};for(const r of Object.getOwnPropertyNames(Object.getPrototypeOf(e))){const n=e[r];typeof n=="function"&&r!=="constructor"&&(t[r]=n.bind(e))}return t}async processEvent(e){const t=e.hasHeader(o.CONTROL_HEADER);this.log.trace(`Service ${t?"Control":"Invocation"} requested for ${e.cri}`);try{t?this.processControlPlaneRequest(e):this.validateReplyTo(e)?await this.processInvocationRequest(e):this.log.error(`ReplyTo header missing or invalid. Ignoring event: ${JSON.stringify(e)}`)}catch(r){this.log.debug(`Exception processing service request: ${JSON.stringify(e)}`,r),this.handleException(e,r)}}processControlPlaneRequest(e){const t=e.getHeader(o.CORRELATION_ID_HEADER);if(!t)throw new Error("Streaming control plane messages require a CORRELATION_ID_HEADER");this.log.trace(`Processing control event for correlationId: ${t}`)}async processInvocationRequest(e){const t=I(e.cri).path();if(!t)throw new Error("The methodId must not be blank");const r=this.methodMap[t];if(!r)throw new Error(`No method resolved for methodId ${t}`);const n=t,i=this.argumentResolver.resolveArguments(e),c=Reflect.getMetadata(_,this.serviceInstance,n)||[];let a={};const h=this.interceptorProvider();if(h)try{a=await h.intercept(e,a)}catch(l){this.log.error(`Interceptor failed to create context for event: ${JSON.stringify(e)}`,l),this.handleException(e,new Error("Internal server error"));return}for(const l of c)i[l]=a;const p=r.length;if(i.length!==p)throw new Error(`Argument count mismatch for method ${t}: expected ${p}, got ${i.length}`);let u;try{u=r(...i),u instanceof Promise?u.then(l=>this.processMethodInvocationResult(e,l),l=>this.handleException(e,l)):this.processMethodInvocationResult(e,u)}catch(l){this.handleException(e,l)}}processMethodInvocationResult(e,t){const r=this.returnValueConverter.convert(e.headers,t);this._eventBus.send(r)}handleException(e,t){const r=M.createReplyEvent(e.headers,new Map([[o.ERROR_HEADER,t.message||"Unknown error"],[o.CONTENT_TYPE_HEADER,"application/json"]]),new TextEncoder().encode(JSON.stringify({message:t.message})));this._eventBus.send(r)}validateReplyTo(e){const t=e.getHeader(o.REPLY_TO_HEADER);return t?t.trim()===""?(this.log.warn("Reply-to header must not be blank"),!1):t.startsWith(`${o.SERVICE_DESTINATION_SCHEME}:`)?!0:(this.log.warn("Reply-to header must be a valid service destination"),!1):(this.log.warn("No reply-to header found in event"),!1)}}const de="3.0.0-beta.1",Ee={version:de};class q{create(e,t){const r=new m(e);return r.setHeader(o.CONTENT_TYPE_HEADER,o.CONTENT_JSON),t!=null&&r.setDataString(JSON.stringify(t)),r}}class ge{create(e,t){const r=new m(e);if(r.setHeader(o.CONTENT_TYPE_HEADER,o.CONTENT_TEXT),t!=null){let n="",i=0;for(const c of t)i>0&&(n=n+`
|
|
2
|
-
`),n=n+c,i++;n.length>0&&r.setDataString(n)}return r}}class F{_eventBus;supervisors=new Map;contextInterceptor=null;debugLogger=L("continuum:serviceRegistry");constructor(e){this._eventBus=e}set eventBus(e){this._eventBus=e;for(const t of this.supervisors.values())t.eventBus=e}get eventBus(){return this._eventBus}serviceProxy(e){return new ve(e,this)}register(e,t){const r=e.cri().raw();if(!this.supervisors.has(r)){this.debugLogger(`Registering service for CRI: ${r}`);const n=new pe(e,t,this.eventBus,()=>this.contextInterceptor);this.supervisors.set(r,n),n.start()}}unRegister(e){const t=e.cri().raw(),r=this.supervisors.get(t);r&&(this.debugLogger(`Unregistering service for CRI: ${t}`),r.stop(),this.supervisors.delete(t))}registerContextInterceptor(e){this.contextInterceptor=e}}const fe=new q;class ve{serviceIdentifier;serviceRegistry;tracer;constructor(e,t){if(typeof e>"u"||e.length===0)throw new Error("The serviceIdentifier provided must contain a value");this.serviceIdentifier=e,this.serviceRegistry=t,this.tracer=
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Q=require("@stomp/rx-stomp"),ee=require("@stomp/stompjs"),A=require("uuid"),L=require("debug"),g=require("@opentelemetry/api"),R=require("rxjs"),f=require("rxjs/operators"),x=require("typescript-optional");require("reflect-metadata");const D=require("@opentelemetry/semantic-conventions");class te{}class C{host;port;useSSL}class re extends C{connectHeaders;maxConnectionAttempts;disableStickySession}class m extends Error{constructor(e){super(e),Object.setPrototypeOf(this,m.prototype)}}var o=(s=>(s.CONTENT_TYPE_HEADER="content-type",s.CONTENT_LENGTH_HEADER="content-length",s.REPLY_TO_HEADER="reply-to",s.REPLY_TO_ID_HEADER="reply-to-id",s.SESSION_HEADER="session",s.CONNECTED_INFO_HEADER="connected-info",s.DISABLE_STICKY_SESSION_HEADER="disable-sticky-session",s.CORRELATION_ID_HEADER="__correlation-id",s.ERROR_HEADER="error",s.COMPLETE_HEADER="complete",s.CONTROL_HEADER="control",s.CONTROL_VALUE_COMPLETE="complete",s.CONTROL_VALUE_CANCEL="cancel",s.CONTROL_VALUE_SUSPEND="suspend",s.CONTROL_VALUE_RESUME="resume",s.SERVICE_DESTINATION_PREFIX="srv://",s.SERVICE_DESTINATION_SCHEME="srv",s.STREAM_DESTINATION_PREFIX="stream://",s.STREAM_DESTINATION_SCHEME="stream",s.CONTENT_JSON="application/json",s.CONTENT_TEXT="text/plain",s.TRACEPARENT_HEADER="traceparent",s.TRACESTATE_HEADER="tracestate",s))(o||{});class se{lastWebsocketError=null;maxConnectionAttemptsReached=!1;rxStomp=null;INITIAL_RECONNECT_DELAY=2e3;MAX_RECONNECT_DELAY=12e4;JITTER_MAX=5e3;connectionAttempts=0;initialConnectionSuccessful=!1;debugLogger=L("continuum:stomp");replyToId=A.v4();replyToCri=o.SERVICE_DESTINATION_PREFIX+this.replyToId+":"+A.v4()+"@continuum.js.EventBus/replyHandler";deactivationHandler=null;get active(){return!!this.rxStomp}get connected(){return this.rxStomp!=null&&this.rxStomp.connected()}activate(e){return new Promise((t,r)=>{if(!e){r("You must supply a valid connectionInfo object");return}if(!e.host){r("No host provided");return}if(this.rxStomp){r("Stomp connection already active");return}this.connectionAttempts=0,this.initialConnectionSuccessful=!1,this.lastWebsocketError=null,this.maxConnectionAttemptsReached=!1;const n="ws"+(e.useSSL?"s":"")+"://"+e.host+(e.port?":"+e.port:"")+"/v1";this.rxStomp=new Q.RxStomp;let i=typeof e.connectHeaders!="function"&&e.connectHeaders!=null?e.connectHeaders:{};const c={brokerURL:n,connectHeaders:i,heartbeatIncoming:12e4,heartbeatOutgoing:3e4,reconnectDelay:this.INITIAL_RECONNECT_DELAY,beforeConnect:async()=>{if(typeof e.connectHeaders=="function"){const u=await e.connectHeaders();for(const l in u)i[l]=u[l]}if(e.disableStickySession&&(i[o.DISABLE_STICKY_SESSION_HEADER]="true"),i[o.REPLY_TO_ID_HEADER]=this.replyToId,e?.maxConnectionAttempts)if(this.connectionAttempts++,this.connectionAttempts>e.maxConnectionAttempts){if(this.maxConnectionAttemptsReached=!0,await this.deactivate(),!this.initialConnectionSuccessful){let u=this.lastWebsocketError?.message?this.lastWebsocketError?.message:"UNKNOWN";r(`Max number of reconnection attempts reached. Last WS Error ${u}`)}}else await this.connectionJitterDelay();else await this.connectionJitterDelay()}};this.debugLogger.enabled&&(c.debug=u=>{this.debugLogger(u)}),this.rxStomp.configure(c),this.rxStomp.stompClient.maxReconnectDelay=this.MAX_RECONNECT_DELAY,this.rxStomp.stompClient.reconnectTimeMode=ee.ReconnectionTimeMode.EXPONENTIAL,this.rxStomp.webSocketErrors$.subscribe(u=>{this.lastWebsocketError=u});const a=this.rxStomp.connected$.subscribe(()=>{a.unsubscribe(),this.initialConnectionSuccessful||(this.initialConnectionSuccessful=!0)}),h=this.rxStomp.stompErrors$.subscribe(u=>{h.unsubscribe();const l=u.headers.message;this.rxStomp?.deactivate(),this.rxStomp=null,r(l)}),p=this.rxStomp.serverHeaders$.subscribe(u=>{let l=u[o.CONNECTED_INFO_HEADER];if(l!=null){const d=JSON.parse(l);if(e.disableStickySession)if(typeof e.connectHeaders=="function"){for(let T in i)delete i[T];this.initialConnectionSuccessful||t(d)}else typeof e.connectHeaders=="object"&&(p.unsubscribe(),t(d));else if(p.unsubscribe(),d.sessionId!=null&&d.replyToId!=null){if(e.connectHeaders!=null)for(let T in i)delete i[T];i[o.SESSION_HEADER]=d.sessionId,t(d)}else r("Server did not return proper data for successful login")}else r("Server did not return proper data for successful login")});this.rxStomp.activate()})}async deactivate(e){this.rxStomp&&(await this.rxStomp.deactivate({force:e}),this.deactivationHandler&&this.deactivationHandler(),this.rxStomp=null)}async connectionJitterDelay(){if(this.initialConnectionSuccessful){const e=Math.random()*this.JITTER_MAX;return this.debugLogger(`Adding ${e}ms of jitter delay`),new Promise(t=>setTimeout(t,e))}}}class S{cri;headers;data;constructor(e,t,r){this.cri=e,t!==void 0?this.headers=t:this.headers=new Map,this.data=x.Optional.ofNullable(r)}getHeader(e){return this.headers.get(e)}hasHeader(e){return this.headers.has(e)}setHeader(e,t){this.headers.set(e,t)}removeHeader(e){return this.headers.delete(e)}setDataString(e){const t=new TextEncoder().encode(e);this.data=x.Optional.ofNonNull(t)}getDataString(){let e="";return this.data.ifPresent(t=>e=new TextDecoder().decode(t)),e}}class H{fatalErrors;serverInfo=null;stompConnectionManager=new se;replyToCri=null;requestRepliesObservable=null;requestRepliesSubject=null;requestRepliesSubscription=null;errorSubject=new R.Subject;errorSubjectSubscription=null;constructor(){this.fatalErrors=this.errorSubject.pipe(f.map(e=>(this.disconnect().catch(t=>{console&&console.error("Error disconnecting from Stomp: "+t)}),new m(e.headers.message)))),this.stompConnectionManager.deactivationHandler=()=>{this.cleanup()}}isConnectionActive(){return this.stompConnectionManager.active}isConnected(){return this.stompConnectionManager.connected}async connect(e){if(this.stompConnectionManager.active)throw new Error("Event Bus connection already active");{this.cleanup();const t=await this.stompConnectionManager.activate(e);return this.serverInfo=new C,this.serverInfo.host=e.host,this.serverInfo.port=e.port,this.serverInfo.useSSL=e.useSSL,this.replyToCri=this.stompConnectionManager.replyToCri,this.errorSubjectSubscription=this.stompConnectionManager.rxStomp?.stompErrors$.subscribe(this.errorSubject),t}}async disconnect(e){await this.stompConnectionManager.deactivate(e),this.cleanup()}send(e){if(this.stompConnectionManager.rxStomp){const t={};for(const[n,i]of e.headers.entries())t[n]=i;const r={};g.propagation.inject(g.context.active(),r),r.traceparent&&(t[o.TRACEPARENT_HEADER]=r.traceparent),r.tracestate&&(t[o.TRACESTATE_HEADER]=r.tracestate),this.stompConnectionManager.rxStomp.publish({destination:e.cri,headers:t,binaryBody:e.data.orUndefined()})}else throw this.createSendUnavailableError()}request(e){return R.firstValueFrom(this.requestStream(e,!1))}requestStream(e,t=!0){return this.stompConnectionManager?.rxStomp?new R.Observable(r=>{this.requestRepliesObservable==null&&(this.requestRepliesSubject=new R.Subject,this.requestRepliesObservable=this._observe(this.replyToCri).pipe(f.multicast(this.requestRepliesSubject)),this.requestRepliesSubscription=this.requestRepliesObservable.connect());let n=!1;const i=A.v4(),c=this.requestRepliesObservable.pipe(f.filter(a=>a.headers.get(o.CORRELATION_ID_HEADER)===i)).subscribe({next(a){if(a.hasHeader(o.CONTROL_HEADER))if(a.headers.get(o.CONTROL_HEADER)==="complete")n=!0,r.complete();else throw new Error("Control Header "+a.headers.get(o.CONTROL_HEADER)+" is not supported");else a.hasHeader(o.ERROR_HEADER)?(n=!0,r.error(new Error(a.getHeader(o.ERROR_HEADER)))):r.next(a)},error(a){r.error(a)},complete(){r.complete()}});return r.add(c),e.setHeader(o.REPLY_TO_HEADER,this.replyToCri),e.setHeader(o.CORRELATION_ID_HEADER,i),this.send(e),()=>{if(t&&!n){const a=new S(e.cri);a.setHeader(o.CONTROL_HEADER,o.CONTROL_VALUE_CANCEL),a.setHeader(o.CORRELATION_ID_HEADER,i),this.send(a)}}}):R.throwError(()=>this.createSendUnavailableError())}listen(e){return Promise.reject("Not implemented")}observe(e){return this._observe(e)}cleanup(){this.requestRepliesSubject!=null&&(this.requestRepliesSubject.error(new Error("Connection disconnected")),this.requestRepliesSubscription!=null&&(this.requestRepliesSubscription.unsubscribe(),this.requestRepliesSubscription=null),this.requestRepliesSubject=null,this.requestRepliesObservable=null),this.errorSubjectSubscription&&(this.errorSubjectSubscription.unsubscribe(),this.errorSubjectSubscription=null),this.serverInfo=null}createSendUnavailableError(){let e="You must call connect on the event bus before sending any request";return this.stompConnectionManager.maxConnectionAttemptsReached&&(e="Max connection attempts reached event bus is not available"),new Error(e)}_observe(e){if(this.stompConnectionManager?.rxStomp)return this.stompConnectionManager.rxStomp.watch(e).pipe(f.map(t=>{const r=new Map;let n="";for(const i of Object.keys(t.headers))i==="destination"?n=t.headers[i]:r.set(i,t.headers[i]);return new S(n,r,t.binaryBody)}));throw this.createSendUnavailableError()}}class E{_scheme;_scope;_resourceName;_path;_version;_raw;constructor(...e){if(e.length===1){const t=e[0];if(typeof t!="string")throw new Error("Raw URI must be a string");const r=E.parseRaw(t);this._scheme=r.scheme,this._scope=r.scope,this._resourceName=r.resourceName,this._path=r.path,this._version=r.version,this._raw=t}else if(e.length===5){const[t,r,n,i,c]=e;this._scheme=t,this._scope=r,this._resourceName=n,this._path=i,this._version=c,this._raw=E.buildRaw(t,r,n,i,c)}else throw new Error("Invalid constructor arguments for DefaultCRI");if(!this._scheme||!this._resourceName)throw new Error(`Invalid CRI: scheme and resourceName are required. Got: ${this._raw}`)}scheme(){return this._scheme}scope(){return this._scope}hasScope(){return this._scope!==null}resourceName(){return this._resourceName}version(){return this._version}hasVersion(){return this._version!==null}path(){return this._path}hasPath(){return this._path!==null}baseResource(){let e=`${this._scheme}://`;return this.hasScope()&&(e+=`${this._scope}@`),e+=this._resourceName,e}raw(){return this._raw}equals(e){return this===e?!0:e instanceof E?this._raw===e.raw():!1}hashCode(){let e=17;return e=e*37+this._raw.split("").reduce((t,r)=>t+r.charCodeAt(0),0),e}toString(){return this._raw}static parseRaw(e){const t=/^([^:]+):\/\/(?:([^@]+)@)?([^\/#]+)(\/[^#]*)?(?:#(.+))?$/,r=e.match(t);if(!r)throw new Error(`Invalid CRI format: ${e}`);const[,n,i,c,a,h]=r;return{scheme:n,scope:i||null,resourceName:c,path:a?a.substring(1):null,version:h||null}}static buildRaw(e,t,r,n,i){let c=`${e}://`;return t&&(c+=`${t}@`),c+=r,n&&(c+=`/${n}`),i&&(c+=`#${i}`),c}}function I(...s){if(s.length===1)return new E(s[0]);if(s.length===2)return new E(s[0],null,s[1],null,null);if(s.length===3)return new E(s[0],s[1],s[2],null,null);if(s.length===5)return new E(s[0],s[1],s[2],s[3],s[4]);throw new Error("Invalid arguments for createCRI")}class ne{resolveArguments(e){if(this.containsJsonContent(e)){const t=e.getDataString();return t?JSON.parse(t):[]}else throw new Error("Currently only JSON content is supported")}containsJsonContent(e){const t=e.getHeader(o.CONTENT_TYPE_HEADER);return t!=null&&t!==""&&t==="application/json"}}class M{static createReplyEvent(e,t,r){if(!e)throw new Error("incomingHeaders cannot be null");const n=e.get(o.REPLY_TO_HEADER);if(!n||n.trim()==="")throw new Error("No reply-to header found, cannot create outgoing message");const i=new Map;for(const[c,a]of e)c.startsWith("__")&&i.set(c,a);if(t)for(const[c,a]of t)i.set(c,a);return new S(n,i,r||void 0)}}class ie{convert(e,t){return M.createReplyEvent(e,new Map([[o.CONTENT_TYPE_HEADER,"application/json"]]),new TextEncoder().encode(JSON.stringify(t)))}}function oe(s){let e;try{e=require("debug")(s)}catch{e=(...r)=>console.debug(`[${s}]`,...r)}return{trace:(...t)=>e("TRACE",...t),debug:(...t)=>e("DEBUG",...t),info:(...t)=>e("INFO",...t),warn:(...t)=>e("WARN",...t),error:(...t)=>e("ERROR",...t)}}class ce{namespace;name;scope;version;_cri=null;constructor(e,t){this.namespace=e,this.name=t}qualifiedName(){return this.namespace+"."+this.name}cri(){return this._cri==null&&(this._cri=I(o.SERVICE_DESTINATION_SCHEME,this.scope||null,this.qualifiedName(),null,this.version||null)),this._cri}}const k=Symbol("scope"),B=Symbol("version"),_=Symbol("context");function ae(s,e,t){Reflect.defineMetadata(k,e,s)}function ue(s){if(!/^\d+\.\d+\.\d+(-[a-zA-Z0-9]+)?$/.test(s))throw new Error(`Invalid semantic version: ${s}. Must follow X.Y.Z[-optional] format.`);return function(e){Reflect.defineMetadata(B,s,e)}}function le(){return function(s,e,t){const r=Reflect.getMetadata(_,s,e)||[];r.push(t),Reflect.defineMetadata(_,r,s,e)}}function he(s,e){return function(t){const r=t,n=new ce(s,e||t.name),i=Reflect.getMetadata(B,t);i&&(n.version=i);const c=function(...a){const h=Reflect.construct(r,a),p=Reflect.getMetadata(k,t.prototype);if(p){const u=h[p];n.scope=typeof u=="function"?u.call(h):u}return N.serviceRegistry.register(n,h),h};return c.prototype=r.prototype,c}}class pe{log;active=!1;_eventBus;interceptorProvider;argumentResolver;returnValueConverter;serviceIdentifier;serviceInstance;methodSubscription=null;methodMap;constructor(e,t,r,n,i={}){if(!e)throw new Error("ServiceIdentifier must not be null");if(!t)throw new Error("Service instance must not be null");if(!r)throw new Error("IEventBus must not be null");if(!n)throw new Error("interceptorProvider must not be null");this.serviceIdentifier=e,this.serviceInstance=t,this._eventBus=r,this.interceptorProvider=n,this.log=i.logger||oe("continuum:ServiceInvocationSupervisor"),this.argumentResolver=i.argumentResolver||new ne,this.returnValueConverter=i.returnValueConverter||new ie,this.methodMap=this.buildMethodMap(t)}isActive(){return this.active}set eventBus(e){this.active?(this.stop(),this._eventBus=e,this.start()):this._eventBus=e}start(){if(this.active)throw new Error("Service already started");this.active=!0;const e=this.serviceIdentifier.cri().baseResource();this.methodSubscription=this._eventBus.observe(e).subscribe({next:async t=>{await this.processEvent(t)},error:t=>{this.log.error("Event listener error",t),this.active=!1},complete:()=>{this.log.error("Event listener stopped unexpectedly. Setting supervisor inactive."),this.active=!1}}),this.log.info(`ServiceInvocationSupervisor started for ${e}`)}stop(){if(!this.active)throw new Error("Service already stopped");this.active=!1,this.methodSubscription&&(this.methodSubscription.unsubscribe(),this.methodSubscription=null),this.log.info("ServiceInvocationSupervisor stopped")}buildMethodMap(e){const t={};for(const r of Object.getOwnPropertyNames(Object.getPrototypeOf(e))){const n=e[r];typeof n=="function"&&r!=="constructor"&&(t[r]=n.bind(e))}return t}async processEvent(e){const t=e.hasHeader(o.CONTROL_HEADER);this.log.trace(`Service ${t?"Control":"Invocation"} requested for ${e.cri}`);try{t?this.processControlPlaneRequest(e):this.validateReplyTo(e)?await this.processInvocationRequest(e):this.log.error(`ReplyTo header missing or invalid. Ignoring event: ${JSON.stringify(e)}`)}catch(r){this.log.debug(`Exception processing service request: ${JSON.stringify(e)}`,r),this.handleException(e,r)}}processControlPlaneRequest(e){const t=e.getHeader(o.CORRELATION_ID_HEADER);if(!t)throw new Error("Streaming control plane messages require a CORRELATION_ID_HEADER");this.log.trace(`Processing control event for correlationId: ${t}`)}async processInvocationRequest(e){const t=I(e.cri).path();if(!t)throw new Error("The methodId must not be blank");const r=this.methodMap[t];if(!r)throw new Error(`No method resolved for methodId ${t}`);const n=t,i=this.argumentResolver.resolveArguments(e),c=Reflect.getMetadata(_,this.serviceInstance,n)||[];let a={};const h=this.interceptorProvider();if(h)try{a=await h.intercept(e,a)}catch(l){this.log.error(`Interceptor failed to create context for event: ${JSON.stringify(e)}`,l),this.handleException(e,new Error("Internal server error"));return}for(const l of c)i[l]=a;const p=r.length;if(i.length!==p)throw new Error(`Argument count mismatch for method ${t}: expected ${p}, got ${i.length}`);let u;try{u=r(...i),u instanceof Promise?u.then(l=>this.processMethodInvocationResult(e,l),l=>this.handleException(e,l)):this.processMethodInvocationResult(e,u)}catch(l){this.handleException(e,l)}}processMethodInvocationResult(e,t){const r=this.returnValueConverter.convert(e.headers,t);this._eventBus.send(r)}handleException(e,t){const r=M.createReplyEvent(e.headers,new Map([[o.ERROR_HEADER,t.message||"Unknown error"],[o.CONTENT_TYPE_HEADER,"application/json"]]),new TextEncoder().encode(JSON.stringify({message:t.message})));this._eventBus.send(r)}validateReplyTo(e){const t=e.getHeader(o.REPLY_TO_HEADER);return t?t.trim()===""?(this.log.warn("Reply-to header must not be blank"),!1):t.startsWith(`${o.SERVICE_DESTINATION_SCHEME}:`)?!0:(this.log.warn("Reply-to header must be a valid service destination"),!1):(this.log.warn("No reply-to header found in event"),!1)}}const de="3.0.0-beta.2",Ee={version:de};class q{create(e,t){const r=new S(e);return r.setHeader(o.CONTENT_TYPE_HEADER,o.CONTENT_JSON),t!=null&&r.setDataString(JSON.stringify(t)),r}}class ge{create(e,t){const r=new S(e);if(r.setHeader(o.CONTENT_TYPE_HEADER,o.CONTENT_TEXT),t!=null){let n="",i=0;for(const c of t)i>0&&(n=n+`
|
|
2
|
+
`),n=n+c,i++;n.length>0&&r.setDataString(n)}return r}}class F{_eventBus;supervisors=new Map;contextInterceptor=null;debugLogger=L("continuum:serviceRegistry");constructor(e){this._eventBus=e}set eventBus(e){this._eventBus=e;for(const t of this.supervisors.values())t.eventBus=e}get eventBus(){return this._eventBus}serviceProxy(e){return new ve(e,this)}register(e,t){const r=e.cri().raw();if(!this.supervisors.has(r)){this.debugLogger(`Registering service for CRI: ${r}`);const n=new pe(e,t,this.eventBus,()=>this.contextInterceptor);this.supervisors.set(r,n),n.start()}}unRegister(e){const t=e.cri().raw(),r=this.supervisors.get(t);r&&(this.debugLogger(`Unregistering service for CRI: ${t}`),r.stop(),this.supervisors.delete(t))}registerContextInterceptor(e){this.contextInterceptor=e}}const fe=new q;class ve{serviceIdentifier;serviceRegistry;tracer;constructor(e,t){if(typeof e>"u"||e.length===0)throw new Error("The serviceIdentifier provided must contain a value");this.serviceIdentifier=e,this.serviceRegistry=t,this.tracer=g.trace.getTracer("continuum.client",Ee.version)}invoke(e,t,r,n){return this.tracer.startActiveSpan(`${this.serviceIdentifier}/${e}`,{kind:g.SpanKind.CLIENT},async i=>(r&&i.setAttribute("continuum.scope",r),i.setAttribute("rpc.system","continuum"),i.setAttribute("rpc.service",this.serviceIdentifier),i.setAttribute("rpc.method",e),this.__invokeStream(!1,e,t,r,n).pipe(f.first()).toPromise().then(async c=>(i.end(),c),async c=>{throw i.recordException(c),i.setStatus({code:g.SpanStatusCode.ERROR}),i.end(),c})))}invokeStream(e,t,r,n){return this.__invokeStream(!0,e,t,r,n)}__invokeStream(e,t,r,n,i){const c=o.SERVICE_DESTINATION_PREFIX+(n!=null?n+"@":"")+this.serviceIdentifier+"/"+t;let a=fe;i?a=i:v.getEventFactory()&&(a=v.getEventFactory());let h=this.serviceRegistry.eventBus;v.getContinuumInstance()&&(h=v.getContinuumInstance().eventBus);const p=g.trace.getActiveSpan();p&&(p.setAttribute(D.ATTR_SERVER_ADDRESS,h.serverInfo?.host||"unknown"),p.setAttribute(D.ATTR_SERVER_PORT,h.serverInfo?.port||"unknown"));let u=a.create(c,r);return h.requestStream(u,e).pipe(f.map(l=>{const d=l.getHeader(o.CONTENT_TYPE_HEADER);if(d!==void 0){if(d==="application/json")return JSON.parse(l.getDataString());if(d==="text/plain")return l.getDataString();throw new Error("Content Type "+d+" is not supported")}else return null}))}}class y{pageable;currentPage;firstPage=!0;constructor(e,t){this.pageable=e,this.currentPage=t}async next(){let e;if(this.firstPage)this.firstPage=!1,e={done:!this.hasContent(),value:this};else if(this.isOffsetPageable()){const t=this.pageable;t.pageNumber++;const r=Math.ceil(this.totalElements/this.pageable.pageSize);t.pageNumber<r?(this.currentPage=await this.findNext(this.pageable),e={done:!1,value:this}):e={done:!0,value:this}}else{const t=this.pageable;t.cursor=this.currentPage.cursor||null,this.currentPage=await this.findNext(this.pageable),e={done:this.isLastPage(),value:this}}return e}[Symbol.asyncIterator](){return this}hasContent(){return this.currentPage.content!==null&&this.currentPage.content!==void 0&&this.currentPage.content.length>0}isLastPage(){let e;return this.isOffsetPageable()?e=Math.ceil(this.totalElements/this.pageable.pageSize)===this.pageable.pageNumber+1:e=!this.firstPage&&this.currentPage.cursor===null,e}isOffsetPageable(){return this.pageable.pageNumber!==void 0}get totalElements(){return this.currentPage.totalElements}get cursor(){return this.currentPage.cursor}get content(){return this.currentPage.content}}class Se extends y{crudServiceProxy;constructor(e,t,r){super(e,t),this.crudServiceProxy=r}findNext(e){return this.crudServiceProxy.findAllSinglePage(e)}}class me extends y{searchText;crudServiceProxy;constructor(e,t,r,n){super(e,t),this.searchText=r,this.crudServiceProxy=n}findNext(e){return this.crudServiceProxy.searchSinglePage(this.searchText,e)}}class ${serviceProxy;constructor(e){this.serviceProxy=e}count(){return this.serviceProxy.invoke("count")}create(e){return this.serviceProxy.invoke("create",[e])}deleteById(e){return this.serviceProxy.invoke("deleteById",[e])}async findAll(e){const t=await this.findAllSinglePage(e);return new Se(e,t,this)}findAllSinglePage(e){return this.serviceProxy.invoke("findAll",[e])}findById(e){return this.serviceProxy.invoke("findById",[e])}save(e){return this.serviceProxy.invoke("save",[e])}findByIdNotIn(e,t){return this.serviceProxy.invoke("findByIdNotIn",[e,t])}async search(e,t){const r=await this.searchSinglePage(e,t);return new me(t,r,e,this)}searchSinglePage(e,t){return this.serviceProxy.invoke("search",[e,t])}}class U{serviceRegistry;constructor(e){this.serviceRegistry=e}crudServiceProxy(e){if(typeof e>"u"||e.length===0)throw new Error("The serviceIdentifier provided must contain a value");return new $(this.serviceRegistry.serviceProxy(e))}}class Re{continuumOverride=[];getContinuumInstance(){return this.continuumOverride[this.continuumOverride.length-1]?.instance}getEventFactory(){return this.continuumOverride[this.continuumOverride.length-1]?.eventFactory}push(e){this.continuumOverride.push(e)}pop(){this.continuumOverride.pop()}}const v=new Re;class Y{_eventBus;serviceRegistry;crudServiceProxyFactory;constructor(){this._eventBus=new H,this.serviceRegistry=new F(this._eventBus),this.crudServiceProxyFactory=new U(this.serviceRegistry)}get eventBus(){return this._eventBus}set eventBus(e){this._eventBus=e,this.serviceRegistry.eventBus=e}connect(e){return this._eventBus.connect(e)}disconnect(e){return this._eventBus.disconnect(e)}serviceProxy(e){return this.serviceRegistry.serviceProxy(e)}crudServiceProxy(e){return this.crudServiceProxyFactory.crudServiceProxy(e)}async execute(e,t){const r=v;r.push({instance:this,eventFactory:t});let n;try{n=await e()}finally{r.pop()}return n}}const N=new Y;var j=(s=>(s.TRACE="TRACE",s.DEBUG="DEBUG",s.INFO="INFO",s.WARN="WARN",s.ERROR="ERROR",s.FATAL="FATAL",s.OFF="OFF",s))(j||{});class b{configuredLevel}class V extends b{members=[]}class J extends b{effectiveLevel}class _e{levels=[];loggerLevels=new Map;groups=new Map}class X{serviceProxy;constructor(){this.serviceProxy=N.serviceProxy("org.kinotic.continuum.api.log.LogManager")}loggers(e){return this.serviceProxy.invoke("loggers",null,e)}async loggerLevels(e,t){const r=await this.serviceProxy.invoke("loggerLevels",[t],e);let n=null;return r.hasOwnProperty("members")?n=new V:r.hasOwnProperty("effectiveLevel")?n=new J:n=new b,Object.assign(n,r),n}configureLogLevel(e,t,r){return this.serviceProxy.invoke("configureLogLevel",[t,r],e)}}const ye=new X;class w extends m{constructor(e){super(e),Object.setPrototypeOf(this,w.prototype)}}class P extends m{constructor(e){super(e),Object.setPrototypeOf(this,P.prototype)}}class be{sessionId;replyToId;participant}class Te{id;tenantId;metadata;roles;constructor(e,t,r,n){this.id=e,this.tenantId=t,this.metadata=r||new Map,this.roles=n||[]}}class Ae{static PARTICIPANT_TYPE_METADATA_KEY="type";static PARTICIPANT_TYPE_DEVICE="device";static PARTICIPANT_TYPE_CLI="cli";static PARTICIPANT_TYPE_USER="user";static PARTICIPANT_TYPE_NODE="node";static CLI_PARTICIPANT_ID="-42-Continuum-CLI-42-"}var W=(s=>(s.EXISTING="EXISTING",s.UPDATE="UPDATE",s.REMOVE="REMOVE",s))(W||{});class Ce{streamOperation;id;value;constructor(e,t,r){this.streamOperation=e,this.id=t,this.value=r}isSet(){return this.value!==null&&this.value!==void 0}}class Ie extends y{pageFunction;constructor(e,t,r){super(e,t),this.pageFunction=r}findNext(e){return this.pageFunction(e)}}class Ne{static instanceOfEditableDataSource(e){return"create"in e}}class O{sort=null;pageSize=25;static create(e,t,r){return new G(e,t,r)}static createWithCursor(e,t,r){return new K(e,t,r)}}class G extends O{pageNumber=0;constructor(e,t,r){super(),this.pageNumber=e,this.pageSize=t,this.sort=r}}class K extends O{cursor;constructor(e,t,r){super(),this.cursor=e,this.pageSize=t,this.sort=r}}var z=(s=>(s.ASC="ASC",s.DESC="DESC",s))(z||{}),Z=(s=>(s.NATIVE="NATIVE",s.NULLS_FIRST="NULLS_FIRST",s.NULLS_LAST="NULLS_LAST",s))(Z||{});class we{property;direction="ASC";nullHandling="NATIVE";constructor(e,t){this.property=e,t!==null&&(this.direction=t)}isAscending(){return this.direction==="ASC"}isDescending(){return this.direction==="DESC"}}class Pe{orders=[]}exports.AbstractIterablePage=y;exports.AuthenticationError=w;exports.AuthorizationError=P;exports.CONTEXT_METADATA_KEY=_;exports.ConnectHeaders=te;exports.ConnectedInfo=be;exports.ConnectionInfo=re;exports.Context=le;exports.Continuum=N;exports.ContinuumContextStack=v;exports.ContinuumError=m;exports.ContinuumSingleton=Y;exports.CrudServiceProxy=$;exports.CrudServiceProxyFactory=U;exports.CursorPageable=K;exports.DataSourceUtils=Ne;exports.DefaultCRI=E;exports.Direction=z;exports.Event=S;exports.EventBus=H;exports.EventConstants=o;exports.FunctionalIterablePage=Ie;exports.GroupLoggerLevelsDescriptor=V;exports.JsonEventFactory=q;exports.LogLevel=j;exports.LogManager=X;exports.LoggerLevelsDescriptor=b;exports.LoggersDescriptor=_e;exports.NullHandling=Z;exports.OffsetPageable=G;exports.Order=we;exports.Pageable=O;exports.Participant=Te;exports.ParticipantConstants=Ae;exports.Publish=he;exports.Scope=ae;exports.ServerInfo=C;exports.ServiceRegistry=F;exports.SingleLoggerLevelsDescriptor=J;exports.Sort=Pe;exports.StreamData=Ce;exports.StreamOperation=W;exports.TextEventFactory=ge;exports.Version=ue;exports.createCRI=I;exports.logManager=ye;
|
|
3
3
|
//# sourceMappingURL=continuum.cjs.map
|