|
@@ -1,185 +0,0 @@
|
|
|
-import { resolve } from "path";
|
|
|
-import { Observable, map, Subject, takeUntil, take } from "rxjs";
|
|
|
-import { BaseMessage } from "../dependencies/fisappmessagejsutilty/dependencies/dependencies";
|
|
|
-import { LogSetting } from "../dependencies/fisloggingservice/type/datatype";
|
|
|
-import { AcknowledgementService } from "../services/acknowledgement.service";
|
|
|
-import { IncomingMessageService } from "../services/incomingMessage.service";
|
|
|
-import { MessageSyncrhonizationService } from "../services/synchronization.service";
|
|
|
-import { MessageSynchronisationServiceSetting } from "../type/datatype";
|
|
|
-import { StreamingService } from "./test-streamOBS";
|
|
|
-
|
|
|
-
|
|
|
-/* Pre - Defined Data && Settings */
|
|
|
-const stream = new StreamingService()
|
|
|
-// Declare source Services && Observables (Using File Storage) Simulating Full Logs
|
|
|
-const source_synchronize = new MessageSyncrhonizationService()
|
|
|
-const source_payload: Observable<BaseMessage> = stream.stream()
|
|
|
-const source_incoming = new IncomingMessageService()
|
|
|
-const source_payload_subject : Subject<BaseMessage> = new Subject()
|
|
|
-source_payload.subscribe(
|
|
|
- {
|
|
|
- next: (data) => {
|
|
|
- source_payload_subject.next(data)
|
|
|
- // console.log(data)
|
|
|
- }
|
|
|
- }
|
|
|
-)
|
|
|
-const source_acknowledge = new AcknowledgementService()
|
|
|
-const source_payload_string = source_payload.pipe(
|
|
|
- map((data) => {
|
|
|
- return JSON.stringify(data);
|
|
|
- })
|
|
|
-)
|
|
|
-
|
|
|
-// Declare target Services && Observables (Using MongoDB Storage) Simulating Partial Logs
|
|
|
-const target_payload: Observable<BaseMessage> = stream.stream().pipe(take(2))
|
|
|
-const target_payload_subject: Subject<BaseMessage> = new Subject()
|
|
|
-target_payload.subscribe(
|
|
|
- {
|
|
|
- next: (data) => {
|
|
|
- target_payload_subject.next(data)
|
|
|
- // console.log(data)
|
|
|
- }
|
|
|
- }
|
|
|
-)
|
|
|
-const target_incoming = new IncomingMessageService()
|
|
|
-const target_syncrhonize = new MessageSyncrhonizationService()
|
|
|
-const target_acknowledge = new AcknowledgementService()
|
|
|
-const target_payload_string = target_payload.pipe(
|
|
|
- map((data) => {
|
|
|
- return JSON.stringify(data);
|
|
|
- }),
|
|
|
-)
|
|
|
-
|
|
|
-// Decalre Source Storage
|
|
|
-let source_storage: LogSetting = {
|
|
|
- storage: "File",
|
|
|
- setting: {
|
|
|
- appName: 'Default from client',
|
|
|
- appLocName: 'To be generated in client',
|
|
|
- logLocName: 'To be generated in client',
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-let source_dataSet: LogSetting & { incomingObservable: Observable<BaseMessage> } = {
|
|
|
- storage: source_storage.storage,
|
|
|
- setting: source_storage.setting,
|
|
|
- customSetting: source_storage.customSetting,
|
|
|
- incomingObservable: source_payload_subject
|
|
|
-}
|
|
|
-
|
|
|
-//Declare Target Storage
|
|
|
-let target_storage: LogSetting = {
|
|
|
- storage: "MongoDB",
|
|
|
- setting: {
|
|
|
- appName: 'Default from client',
|
|
|
- appLocName: 'To be generated in client',
|
|
|
- logLocName: 'To be generated in client',
|
|
|
- },
|
|
|
- customSetting: {
|
|
|
- srv: true,
|
|
|
- user: "testDB",
|
|
|
- password: "h1nt1OyXw6QeUnzS",
|
|
|
- server: "cluster0.29sklte.mongodb.net",
|
|
|
- collection: "log",
|
|
|
- }
|
|
|
-}
|
|
|
-let target_dataSet: LogSetting & { incomingObservable: Observable<BaseMessage> } = {
|
|
|
- storage: target_storage.storage,
|
|
|
- setting: target_storage.setting,
|
|
|
- customSetting: target_storage.customSetting,
|
|
|
- incomingObservable: target_payload_subject
|
|
|
-}
|
|
|
-
|
|
|
-// Combine source and target storage to form MessageSynchronisationServiceSetting
|
|
|
-let settings: MessageSynchronisationServiceSetting = {
|
|
|
- incomingSource: {
|
|
|
- //all of the settings to be combined here
|
|
|
- ...source_storage,
|
|
|
- tags: ['Incoming']
|
|
|
- }, //LogSetting & {tags:string[] },
|
|
|
- target: {
|
|
|
- ...target_storage,
|
|
|
- tags: ['Incoming']
|
|
|
- } //LogSetting & {tags:string[] }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-/* ------------- CODING TEST --------------- */
|
|
|
-const new_subject: Subject<BaseMessage> = new Subject();
|
|
|
-const subjectObs = { // Observer but a subject looking to subscribe
|
|
|
- next: (data) => {
|
|
|
- console.log(data)
|
|
|
- }
|
|
|
-}
|
|
|
-new_subject.subscribe(subjectObs) // Observerble(Subject) subcribed and stream data for observer(subject) "subjectObs"
|
|
|
-
|
|
|
-source_incoming.init(
|
|
|
- {
|
|
|
- storage: source_storage.storage,
|
|
|
- setting: source_storage.setting,
|
|
|
- customSetting: source_storage.customSetting,
|
|
|
- incomingObservable: new_subject.asObservable()
|
|
|
- }
|
|
|
-)
|
|
|
-target_incoming.init(
|
|
|
- {
|
|
|
- storage: target_storage.storage,
|
|
|
- setting: target_storage.setting,
|
|
|
- customSetting: target_storage.customSetting,
|
|
|
- incomingObservable: new_subject.asObservable()
|
|
|
- }
|
|
|
-)
|
|
|
-setTimeout(() => {
|
|
|
- new_subject.next(<BaseMessage>{
|
|
|
- "header": {
|
|
|
- "messageType": "Command",
|
|
|
- "messageID": "ab05f310-f3c5-4fd0-9af1-15cda97b4444",
|
|
|
- "messageName": "Command",
|
|
|
- "dateCreated": "2023-02-13T03:33:58.746Z",
|
|
|
- "isAggregate": false,
|
|
|
- "dataSourceTiming": "",
|
|
|
- "serviceId": "",
|
|
|
- "userId": "",
|
|
|
- "requesterId": "Generatede203a86a-c99e-460e-95ff-f2dc7f484a7d",
|
|
|
- "messageProducerInformation": {
|
|
|
- "origin": {
|
|
|
- "userApplication": {
|
|
|
- "userAppId": "FisAppID/Name",
|
|
|
- "userAppName": "Client"
|
|
|
- }
|
|
|
- },
|
|
|
- "components": "Presentation"
|
|
|
- },
|
|
|
- "security": {
|
|
|
- "ucpId": "GeneratedFromMessageSync"
|
|
|
- },
|
|
|
- "messageDataLocation": {
|
|
|
- "isEmbaded": true
|
|
|
- },
|
|
|
- "messageDataFormat": {
|
|
|
- "dataFormat": "Json"
|
|
|
- },
|
|
|
- "requestExecutionMode": 0,
|
|
|
- "resquestTimeOut": 0,
|
|
|
- "command": "New"
|
|
|
- },
|
|
|
- "data": {
|
|
|
- "header": "fa29074d-9718-4aba-9999-0001",
|
|
|
- "data": {
|
|
|
- "appLogLocId": "fa29074d-9718-4aba-9999-0001",
|
|
|
- "appData": {
|
|
|
- "msgId": "6c162cd3-d42d-4ab4-8882-0001",
|
|
|
- "msgLogDateTime": "2022-12-06T15:01:46.987Z",
|
|
|
- "msgDateTime": "2022-12-06T08:50:33.809Z",
|
|
|
- "msgTag": [
|
|
|
- "oval",
|
|
|
- "likable"
|
|
|
- ],
|
|
|
- "msgPayload": "Molestias facilis iusto similique iste voluptas facere. Alias est sequi. Quos consequatur temporibus blanditiis numquam vel. Eos repellat eaque. Voluptatibus optio optio magni eveniet. Quidem architecto esse aut sint neque error magnam perspiciatis."
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- )
|
|
|
-}, 1000)
|