@valtimo/sse 13.2.1 → 13.4.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"valtimo-sse.mjs","sources":["../../../../projects/valtimo/sse/src/lib/models/sse-bucket.model.ts","../../../../projects/valtimo/sse/src/lib/models/sse-events.model.ts","../../../../projects/valtimo/sse/src/lib/models/index.ts","../../../../projects/valtimo/sse/src/lib/services/sse.service.ts","../../../../projects/valtimo/sse/src/lib/services/index.ts","../../../../projects/valtimo/sse/src/lib/sse.module.ts","../../../../projects/valtimo/sse/src/public-api.ts","../../../../projects/valtimo/sse/src/valtimo-sse.ts"],"sourcesContent":["/*\n * Copyright 2015-2025 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// generic bucket for listeners of any type\nimport {BaseSseEvent, SseError, SseEventListener} from './sse-events.model';\n\nexport class SseSubscriptionBucket<T> {\n readonly listeners: SseEventListener<T>[] = [];\n\n on(listener: SseEventListener<T>) {\n this.listeners.push(listener);\n }\n\n off(listener: SseEventListener<T>) {\n const index = this.listeners.indexOf(listener);\n if (index > -1) {\n this.listeners.splice(index, 1);\n }\n }\n\n offAll() {\n this.listeners.length = 0;\n }\n\n sendEvent(event: T) {\n this.listeners.forEach(listener => {\n listener(event);\n });\n }\n}\n\n// error bucket for error listeners\nexport class SseErrorBucket extends SseSubscriptionBucket<SseError> {}\n\n// implicit type bucket with event for filtering\nexport class SseEventSubscriptionBucket<T extends BaseSseEvent> extends SseSubscriptionBucket<T> {\n readonly event: string;\n\n constructor(event: string) {\n super();\n this.event = event;\n }\n}\n","/*\n * Copyright 2015-2025 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\ntype SseEventType =\n | 'CASE_CREATED'\n | 'TASK_UPDATE'\n | 'PROCESS_END'\n | 'CASE_ASSIGNED'\n | 'CASE_UNASSIGNED'\n | 'ESTABLISHED_CONNECTION';\n\ntype SseEventListener<T> = (event: T) => void;\n\n// base event containing the event type\ninterface BaseSseEvent {\n eventType?: SseEventType;\n processInstanceId?: string;\n}\n\ninterface EstablishedConnectionSseEvent extends BaseSseEvent {\n subscriptionId: string;\n}\n\ninterface SseError {\n state: number;\n message: string;\n data?: any;\n}\n\nexport {SseError, EstablishedConnectionSseEvent, BaseSseEvent, SseEventListener, SseEventType};\n","/*\n * Copyright 2015-2025 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './sse-bucket.model';\nexport * from './sse-events.model';\n","/*\n * Copyright 2015-2025 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Injectable} from '@angular/core';\nimport {filter, map, Observable, Subject, Subscription} from 'rxjs';\nimport {\n BaseSseEvent,\n EstablishedConnectionSseEvent,\n SseEventListener,\n SseEventType,\n} from '../models/sse-events.model';\nimport {ConfigService} from '@valtimo/shared';\nimport {\n SseErrorBucket,\n SseEventSubscriptionBucket,\n SseSubscriptionBucket,\n} from '../models/sse-bucket.model';\nimport {NGXLogger} from 'ngx-logger';\n\n/**\n * Server-side events service, for connecting and reconnecting to SSE,\n * and a translation layer between SSE json string data and TS typed events.\n *\n * The service is always present, and so events can be registered with {@link onMessage} and {@link onEvent},\n * and will not be lost on disconnect or reconnect of the SSE connection itself.\n * It is expected to also unregister events using the off-method variants of the on-method listeners.\n *\n * To ensure messages are received the connection must be explicitly opened with {@link connect},\n * likewise the connection should also be closed with {@link disconnect} to stop receiving messages.\n *\n * This service can reconnect itself with the backend, and might use the {@link subscriptionId} to ask for its\n * previous connection state. This state currently exists in the backend as the \"Subscriber\" class, and might\n * have a state containing queues of items that need to be sent, so you can reconnect and receive the rest.\n *\n * At this time no state data is kept, so reconnection without a subscriptionId does not give a different result\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class SseService {\n private static readonly CONNECTION_RETRIES_EXCEEDED = -1;\n private static readonly NOT_CONNECTED = 0;\n private static readonly CONNECTING = 1;\n private static readonly RECONNECTING = 2;\n private static readonly CONNECTED = 10;\n\n private readonly VALTIMO_ENDPOINT_URL: string;\n private connectionCount = 0; // amount of times we have connected sequentially, no concurrent connections\n private establishedDataHandler?: Subscription = null;\n private establishedConnection?: EventSource = null;\n private establishedConnectionObservable: Observable<MessageEvent<BaseSseEvent>> = null;\n private subscriptionId?: string = null;\n private sequentialConnectionAttemptFailCount = 0;\n\n private errorBucket = new SseErrorBucket();\n private anySubscribersBucket = new SseSubscriptionBucket<BaseSseEvent>();\n private eventSubscribersBuckets: SseEventSubscriptionBucket<BaseSseEvent>[] = [];\n\n private state: number = SseService.NOT_CONNECTED;\n\n private _sseMessages$ = new Subject<MessageEvent<BaseSseEvent>>();\n\n get sseMessages$(): Observable<MessageEvent<BaseSseEvent>> {\n return this._sseMessages$.asObservable().pipe(filter(message => !!message));\n }\n\n constructor(\n private readonly configService: ConfigService,\n private readonly logger: NGXLogger\n ) {\n this.VALTIMO_ENDPOINT_URL = configService.config.valtimoApi.endpointUri;\n this.connect();\n }\n\n public getSseMessagesObservableByEventType(\n eventTypes: Array<SseEventType>\n ): Observable<MessageEvent<BaseSseEvent>> {\n return this._sseMessages$.asObservable().pipe(\n filter(message => !!message),\n filter(message => eventTypes.includes(message.data?.eventType))\n );\n }\n\n public getSseEventObservable<Event>(eventType: SseEventType): Observable<Event> {\n return this._sseMessages$.asObservable().pipe(\n filter(message => eventType === message?.data?.eventType),\n map(message => message.data as Event)\n );\n }\n\n /**\n * Start receiving SSE events\n */\n private connect() {\n this.ensureConnection();\n return this;\n }\n\n private onMessage(listener: SseEventListener<BaseSseEvent>) {\n this.ensureConnection(); // ensure connection\n this.anySubscribersBucket.on(listener);\n return this;\n }\n\n private onEvent<T extends BaseSseEvent>(event: string, listener: SseEventListener<T>) {\n this.ensureConnection(); // ensure connection\n let found = false;\n this.eventSubscribersBuckets.forEach(bucket => {\n if (bucket.event === event) {\n bucket.on(listener);\n found = true;\n }\n });\n if (!found) {\n const bucket = new SseEventSubscriptionBucket(event);\n bucket.on(listener);\n this.eventSubscribersBuckets.push(bucket);\n }\n return this;\n }\n\n private offMessage(listener: SseEventListener<BaseSseEvent>) {\n this.anySubscribersBucket.off(listener);\n }\n\n private offEvent(event: string, listener: SseEventListener<any>) {\n this.eventSubscribersBuckets.forEach(bucket => {\n if (bucket.event === event) {\n bucket.off(listener);\n }\n });\n }\n\n private offEvents(type?: string) {\n this.eventSubscribersBuckets.forEach(bucket => {\n if (type === null || type === bucket.event) {\n bucket.offAll();\n }\n });\n }\n\n private offMessages() {\n this.anySubscribersBucket.offAll();\n }\n\n private offAll() {\n this.offEvents();\n this.offMessages();\n }\n\n private disconnect(keepSubscriptionId: boolean = false) {\n this.disconnectWith(SseService.NOT_CONNECTED, keepSubscriptionId);\n }\n\n private disconnectWith(state: number, keepSubscriptionId: boolean = false) {\n this.state = state;\n if (this.establishedConnection?.readyState !== EventSource.CLOSED) {\n this.establishedConnection?.close();\n }\n this.establishedDataHandler.unsubscribe();\n this.establishedConnection = null;\n this.establishedConnectionObservable = null;\n this.establishedDataHandler = null;\n if (!keepSubscriptionId) {\n this.subscriptionId = null;\n }\n }\n\n private ensureConnection(retry: boolean = false) {\n if (this.establishedConnection !== null && this.establishedConnectionObservable !== null) {\n if (this.establishedConnection.readyState !== EventSource.CLOSED) {\n return; // found\n }\n }\n if (this.state === SseService.CONNECTING || this.state === SseService.RECONNECTING) {\n return; // already connecting\n }\n this.establishedConnection = null;\n this.establishedConnectionObservable = null;\n\n this.constructNewSse(retry); // create new\n }\n\n private constructNewSse(retry: boolean) {\n this.logger.debug('subscribing to sse events');\n if (this.connectionCount > 0) {\n this.state = SseService.RECONNECTING;\n } else {\n this.state = SseService.CONNECTING;\n }\n const observable = new Observable<MessageEvent<BaseSseEvent>>(observer => {\n const eventSource = this.getEventSource();\n eventSource.onopen = () => {\n this.establishedConnection = eventSource;\n this.logger.debug('connected to sse');\n this.connectionCount++;\n this.sequentialConnectionAttemptFailCount = 0; // reset retry count\n this.state = SseService.CONNECTED;\n };\n eventSource.onmessage = event => {\n observer.next({\n ...event, // forward event object but replace data field\n data: JSON.parse(event.data), // parse JSON string to JSON object\n });\n };\n eventSource.onerror = () => {\n eventSource.close();\n observer.complete();\n if (retry) {\n this.sequentialConnectionAttemptFailCount++;\n this.logger.debug(`retry failed: ${this.sequentialConnectionAttemptFailCount}`);\n if (this.sequentialConnectionAttemptFailCount > 3) {\n this.disconnectWith(SseService.CONNECTION_RETRIES_EXCEEDED, false);\n this.err(\n `Failed to connect to SSE after ${this.sequentialConnectionAttemptFailCount} retries`\n );\n return;\n }\n }\n this.disconnect(true);\n this.ensureConnection(true);\n };\n return () => eventSource.close();\n });\n this.establishedConnectionObservable = observable;\n this.registerSseEventHandling(observable);\n return observable;\n }\n\n private getEventSource() {\n let suffix = '';\n if (this.subscriptionId != null) {\n suffix = '/' + this.subscriptionId;\n }\n // subscribe to /sse or /sse/<subscriptionId>\n return new EventSource(this.VALTIMO_ENDPOINT_URL + 'v1/sse' + suffix);\n }\n\n private registerSseEventHandling(observable: Observable<MessageEvent<BaseSseEvent>>) {\n this.establishedDataHandler = observable.subscribe(event => {\n this._sseMessages$.next(event);\n this.internalListenerEstablishConnection(event);\n // notify all generic listeners\n this.anySubscribersBucket.sendEvent(event.data);\n // notify the specific event listener bucket\n this.eventSubscribersBuckets.forEach(bucket => {\n if (bucket.event === event?.data?.eventType) {\n bucket.sendEvent(event.data);\n }\n });\n });\n }\n\n private internalListenerEstablishConnection(event: MessageEvent<BaseSseEvent>) {\n if (event?.data?.eventType !== 'ESTABLISHED_CONNECTION') {\n return;\n }\n this.logger.debug(`established connection: ${event}`);\n this.subscriptionId = (event.data as EstablishedConnectionSseEvent).subscriptionId;\n }\n\n private err(message: string, ...data: any) {\n this.errorBucket.sendEvent({\n state: this.state,\n message,\n data,\n });\n }\n}\n","/*\n * Copyright 2015-2025 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './sse.service';\n","/*\n * Copyright 2015-2025 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {NgModule} from '@angular/core';\n\n@NgModule({\n declarations: [],\n imports: [],\n exports: [],\n})\nexport class SseModule {}\n","/*\n * Copyright 2015-2025 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * Public API Surface of sse\n */\n\nexport * from './lib/models';\nexport * from './lib/services';\nexport * from './lib/sse.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;AAcG;MAKU,qBAAqB,CAAA;AAAlC,IAAA,WAAA,GAAA;QACW,IAAS,CAAA,SAAA,GAA0B,EAAE;;AAE9C,IAAA,EAAE,CAAC,QAA6B,EAAA;AAC9B,QAAA,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC;;AAG/B,IAAA,GAAG,CAAC,QAA6B,EAAA;QAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC;AAC9C,QAAA,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE;YACd,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,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A,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE,EAAE;AACX,oBAAA,OAAO,EAAE,EAAE;AACZ,iBAAA;;;ACtBD;;;;;;;;;;;;;;AAcG;AAEH;;AAEG;;AClBH;;AAEG;;;;"}
1
+ {"version":3,"file":"valtimo-sse.mjs","sources":["../../../../projects/valtimo/sse/src/lib/models/sse-bucket.model.ts","../../../../projects/valtimo/sse/src/lib/models/sse-events.model.ts","../../../../projects/valtimo/sse/src/lib/models/index.ts","../../../../projects/valtimo/sse/src/lib/services/sse.service.ts","../../../../projects/valtimo/sse/src/lib/services/index.ts","../../../../projects/valtimo/sse/src/lib/sse.module.ts","../../../../projects/valtimo/sse/src/public-api.ts","../../../../projects/valtimo/sse/src/valtimo-sse.ts"],"sourcesContent":["/*\n * Copyright 2015-2025 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// generic bucket for listeners of any type\nimport {BaseSseEvent, SseError, SseEventListener} from './sse-events.model';\n\nexport class SseSubscriptionBucket<T> {\n readonly listeners: SseEventListener<T>[] = [];\n\n on(listener: SseEventListener<T>) {\n this.listeners.push(listener);\n }\n\n off(listener: SseEventListener<T>) {\n const index = this.listeners.indexOf(listener);\n if (index > -1) {\n this.listeners.splice(index, 1);\n }\n }\n\n offAll() {\n this.listeners.length = 0;\n }\n\n sendEvent(event: T) {\n this.listeners.forEach(listener => {\n listener(event);\n });\n }\n}\n\n// error bucket for error listeners\nexport class SseErrorBucket extends SseSubscriptionBucket<SseError> {}\n\n// implicit type bucket with event for filtering\nexport class SseEventSubscriptionBucket<T extends BaseSseEvent> extends SseSubscriptionBucket<T> {\n readonly event: string;\n\n constructor(event: string) {\n super();\n this.event = event;\n }\n}\n","/*\n * Copyright 2015-2025 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\ntype SseEventType =\n | 'CASE_CREATED'\n | 'TASK_UPDATE'\n | 'DOCUMENT_UPDATED'\n | 'PROCESS_END'\n | 'CASE_ASSIGNED'\n | 'CASE_UNASSIGNED'\n | 'ESTABLISHED_CONNECTION';\n\ntype SseEventListener<T> = (event: T) => void;\n\n// base event containing the event type\ninterface BaseSseEvent {\n eventType?: SseEventType;\n processInstanceId?: string;\n}\n\ninterface EstablishedConnectionSseEvent extends BaseSseEvent {\n subscriptionId: string;\n}\n\ninterface SseError {\n state: number;\n message: string;\n data?: any;\n}\n\nexport {SseError, EstablishedConnectionSseEvent, BaseSseEvent, SseEventListener, SseEventType};\n","/*\n * Copyright 2015-2025 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './sse-bucket.model';\nexport * from './sse-events.model';\n","/*\n * Copyright 2015-2025 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Injectable} from '@angular/core';\nimport {filter, map, Observable, Subject, Subscription} from 'rxjs';\nimport {\n BaseSseEvent,\n EstablishedConnectionSseEvent,\n SseEventListener,\n SseEventType,\n} from '../models/sse-events.model';\nimport {ConfigService} from '@valtimo/shared';\nimport {\n SseErrorBucket,\n SseEventSubscriptionBucket,\n SseSubscriptionBucket,\n} from '../models/sse-bucket.model';\nimport {NGXLogger} from 'ngx-logger';\n\n/**\n * Server-side events service, for connecting and reconnecting to SSE,\n * and a translation layer between SSE json string data and TS typed events.\n *\n * The service is always present, and so events can be registered with {@link onMessage} and {@link onEvent},\n * and will not be lost on disconnect or reconnect of the SSE connection itself.\n * It is expected to also unregister events using the off-method variants of the on-method listeners.\n *\n * To ensure messages are received the connection must be explicitly opened with {@link connect},\n * likewise the connection should also be closed with {@link disconnect} to stop receiving messages.\n *\n * This service can reconnect itself with the backend, and might use the {@link subscriptionId} to ask for its\n * previous connection state. This state currently exists in the backend as the \"Subscriber\" class, and might\n * have a state containing queues of items that need to be sent, so you can reconnect and receive the rest.\n *\n * At this time no state data is kept, so reconnection without a subscriptionId does not give a different result\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class SseService {\n private static readonly CONNECTION_RETRIES_EXCEEDED = -1;\n private static readonly NOT_CONNECTED = 0;\n private static readonly CONNECTING = 1;\n private static readonly RECONNECTING = 2;\n private static readonly CONNECTED = 10;\n\n private readonly VALTIMO_ENDPOINT_URL: string;\n private connectionCount = 0; // amount of times we have connected sequentially, no concurrent connections\n private establishedDataHandler?: Subscription = null;\n private establishedConnection?: EventSource = null;\n private establishedConnectionObservable: Observable<MessageEvent<BaseSseEvent>> = null;\n private subscriptionId?: string = null;\n private sequentialConnectionAttemptFailCount = 0;\n\n private errorBucket = new SseErrorBucket();\n private anySubscribersBucket = new SseSubscriptionBucket<BaseSseEvent>();\n private eventSubscribersBuckets: SseEventSubscriptionBucket<BaseSseEvent>[] = [];\n\n private state: number = SseService.NOT_CONNECTED;\n\n private _sseMessages$ = new Subject<MessageEvent<BaseSseEvent>>();\n\n get sseMessages$(): Observable<MessageEvent<BaseSseEvent>> {\n return this._sseMessages$.asObservable().pipe(filter(message => !!message));\n }\n\n constructor(\n private readonly configService: ConfigService,\n private readonly logger: NGXLogger\n ) {\n this.VALTIMO_ENDPOINT_URL = configService.config.valtimoApi.endpointUri;\n this.connect();\n }\n\n public getSseMessagesObservableByEventType(\n eventTypes: Array<SseEventType>\n ): Observable<MessageEvent<BaseSseEvent>> {\n return this._sseMessages$.asObservable().pipe(\n filter(message => !!message),\n filter(message => eventTypes.includes(message.data?.eventType))\n );\n }\n\n public getSseEventObservable<Event>(eventType: SseEventType): Observable<Event> {\n return this._sseMessages$.asObservable().pipe(\n filter(message => eventType === message?.data?.eventType),\n map(message => message.data as Event)\n );\n }\n\n /**\n * Start receiving SSE events\n */\n private connect() {\n this.ensureConnection();\n return this;\n }\n\n private onMessage(listener: SseEventListener<BaseSseEvent>) {\n this.ensureConnection(); // ensure connection\n this.anySubscribersBucket.on(listener);\n return this;\n }\n\n private onEvent<T extends BaseSseEvent>(event: string, listener: SseEventListener<T>) {\n this.ensureConnection(); // ensure connection\n let found = false;\n this.eventSubscribersBuckets.forEach(bucket => {\n if (bucket.event === event) {\n bucket.on(listener);\n found = true;\n }\n });\n if (!found) {\n const bucket = new SseEventSubscriptionBucket(event);\n bucket.on(listener);\n this.eventSubscribersBuckets.push(bucket);\n }\n return this;\n }\n\n private offMessage(listener: SseEventListener<BaseSseEvent>) {\n this.anySubscribersBucket.off(listener);\n }\n\n private offEvent(event: string, listener: SseEventListener<any>) {\n this.eventSubscribersBuckets.forEach(bucket => {\n if (bucket.event === event) {\n bucket.off(listener);\n }\n });\n }\n\n private offEvents(type?: string) {\n this.eventSubscribersBuckets.forEach(bucket => {\n if (type === null || type === bucket.event) {\n bucket.offAll();\n }\n });\n }\n\n private offMessages() {\n this.anySubscribersBucket.offAll();\n }\n\n private offAll() {\n this.offEvents();\n this.offMessages();\n }\n\n private disconnect(keepSubscriptionId: boolean = false) {\n this.disconnectWith(SseService.NOT_CONNECTED, keepSubscriptionId);\n }\n\n private disconnectWith(state: number, keepSubscriptionId: boolean = false) {\n this.state = state;\n if (this.establishedConnection?.readyState !== EventSource.CLOSED) {\n this.establishedConnection?.close();\n }\n this.establishedDataHandler.unsubscribe();\n this.establishedConnection = null;\n this.establishedConnectionObservable = null;\n this.establishedDataHandler = null;\n if (!keepSubscriptionId) {\n this.subscriptionId = null;\n }\n }\n\n private ensureConnection(retry: boolean = false) {\n if (this.establishedConnection !== null && this.establishedConnectionObservable !== null) {\n if (this.establishedConnection.readyState !== EventSource.CLOSED) {\n return; // found\n }\n }\n if (this.state === SseService.CONNECTING || this.state === SseService.RECONNECTING) {\n return; // already connecting\n }\n this.establishedConnection = null;\n this.establishedConnectionObservable = null;\n\n this.constructNewSse(retry); // create new\n }\n\n private constructNewSse(retry: boolean) {\n this.logger.debug('subscribing to sse events');\n if (this.connectionCount > 0) {\n this.state = SseService.RECONNECTING;\n } else {\n this.state = SseService.CONNECTING;\n }\n const observable = new Observable<MessageEvent<BaseSseEvent>>(observer => {\n const eventSource = this.getEventSource();\n eventSource.onopen = () => {\n this.establishedConnection = eventSource;\n this.logger.debug('connected to sse');\n this.connectionCount++;\n this.sequentialConnectionAttemptFailCount = 0; // reset retry count\n this.state = SseService.CONNECTED;\n };\n eventSource.onmessage = event => {\n observer.next({\n ...event, // forward event object but replace data field\n data: JSON.parse(event.data), // parse JSON string to JSON object\n });\n };\n eventSource.onerror = () => {\n eventSource.close();\n observer.complete();\n if (retry) {\n this.sequentialConnectionAttemptFailCount++;\n this.logger.debug(`retry failed: ${this.sequentialConnectionAttemptFailCount}`);\n if (this.sequentialConnectionAttemptFailCount > 3) {\n this.disconnectWith(SseService.CONNECTION_RETRIES_EXCEEDED, false);\n this.err(\n `Failed to connect to SSE after ${this.sequentialConnectionAttemptFailCount} retries`\n );\n return;\n }\n }\n this.disconnect(true);\n this.ensureConnection(true);\n };\n return () => eventSource.close();\n });\n this.establishedConnectionObservable = observable;\n this.registerSseEventHandling(observable);\n return observable;\n }\n\n private getEventSource() {\n let suffix = '';\n if (this.subscriptionId != null) {\n suffix = '/' + this.subscriptionId;\n }\n // subscribe to /sse or /sse/<subscriptionId>\n return new EventSource(this.VALTIMO_ENDPOINT_URL + 'v1/sse' + suffix);\n }\n\n private registerSseEventHandling(observable: Observable<MessageEvent<BaseSseEvent>>) {\n this.establishedDataHandler = observable.subscribe(event => {\n this._sseMessages$.next(event);\n this.internalListenerEstablishConnection(event);\n // notify all generic listeners\n this.anySubscribersBucket.sendEvent(event.data);\n // notify the specific event listener bucket\n this.eventSubscribersBuckets.forEach(bucket => {\n if (bucket.event === event?.data?.eventType) {\n bucket.sendEvent(event.data);\n }\n });\n });\n }\n\n private internalListenerEstablishConnection(event: MessageEvent<BaseSseEvent>) {\n if (event?.data?.eventType !== 'ESTABLISHED_CONNECTION') {\n return;\n }\n this.logger.debug(`established connection: ${event}`);\n this.subscriptionId = (event.data as EstablishedConnectionSseEvent).subscriptionId;\n }\n\n private err(message: string, ...data: any) {\n this.errorBucket.sendEvent({\n state: this.state,\n message,\n data,\n });\n }\n}\n","/*\n * Copyright 2015-2025 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './sse.service';\n","/*\n * Copyright 2015-2025 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {NgModule} from '@angular/core';\n\n@NgModule({\n declarations: [],\n imports: [],\n exports: [],\n})\nexport class SseModule {}\n","/*\n * Copyright 2015-2025 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * Public API Surface of sse\n */\n\nexport * from './lib/models';\nexport * from './lib/services';\nexport * from './lib/sse.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;AAcG;MAKU,qBAAqB,CAAA;AAAlC,IAAA,WAAA,GAAA;QACW,IAAS,CAAA,SAAA,GAA0B,EAAE;;AAE9C,IAAA,EAAE,CAAC,QAA6B,EAAA;AAC9B,QAAA,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC;;AAG/B,IAAA,GAAG,CAAC,QAA6B,EAAA;QAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC;AAC9C,QAAA,IAAI,KAAK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AA;;4FAAT,SAAS,EAAA,UAAA,EAAA,CAAA;kBALrB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE,EAAE;AACX,oBAAA,OAAO,EAAE,EAAE;AACZ,iBAAA;;;ACtBD;;;;;;;;;;;;;;AAcG;AAEH;;AAEG;;AClBH;;AAEG;;;;"}
@@ -1,4 +1,4 @@
1
- type SseEventType = 'CASE_CREATED' | 'TASK_UPDATE' | 'PROCESS_END' | 'CASE_ASSIGNED' | 'CASE_UNASSIGNED' | 'ESTABLISHED_CONNECTION';
1
+ type SseEventType = 'CASE_CREATED' | 'TASK_UPDATE' | 'DOCUMENT_UPDATED' | 'PROCESS_END' | 'CASE_ASSIGNED' | 'CASE_UNASSIGNED' | 'ESTABLISHED_CONNECTION';
2
2
  type SseEventListener<T> = (event: T) => void;
3
3
  interface BaseSseEvent {
4
4
  eventType?: SseEventType;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@valtimo/sse",
3
3
  "license": "EUPL-1.2",
4
- "version": "13.2.1",
4
+ "version": "13.4.0",
5
5
  "peerDependencies": {
6
6
  "@angular/common": "^19.2.8",
7
7
  "@angular/core": "^19.2.8"