Browse Source

remove faker lib<Causing issue for UCP>

Enzo 1 month ago
parent
commit
241fecf1a7

+ 0 - 16
package-lock.json

@@ -9,7 +9,6 @@
       "version": "1.0.0",
       "license": "ISC",
       "dependencies": {
-        "@faker-js/faker": "^8.1.0",
         "@grpc/grpc-js": "^1.9.4",
         "dotenv": "^16.3.1",
         "express": "^4.18.2",
@@ -642,21 +641,6 @@
       "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==",
       "dev": true
     },
-    "node_modules/@faker-js/faker": {
-      "version": "8.1.0",
-      "resolved": "https://registry.npmjs.org/@faker-js/faker/-/faker-8.1.0.tgz",
-      "integrity": "sha512-38DT60rumHfBYynif3lmtxMqMqmsOQIxQgEuPZxCk2yUYN0eqWpTACgxi0VpidvsJB8CRxCpvP7B3anK85FjtQ==",
-      "funding": [
-        {
-          "type": "opencollective",
-          "url": "https://opencollective.com/fakerjs"
-        }
-      ],
-      "engines": {
-        "node": "^14.17.0 || ^16.13.0 || >=18.0.0",
-        "npm": ">=6.14.13"
-      }
-    },
     "node_modules/@grpc/grpc-js": {
       "version": "1.9.5",
       "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.9.5.tgz",

+ 0 - 1
package.json

@@ -26,7 +26,6 @@
   "author": "",
   "license": "ISC",
   "dependencies": {
-    "@faker-js/faker": "^8.1.0",
     "@grpc/grpc-js": "^1.9.4",
     "dotenv": "^16.3.1",
     "express": "^4.18.2",

+ 0 - 60
services/utility/generateData.ts

@@ -1,60 +0,0 @@
-import * as fs from "fs"
-import { faker } from '@faker-js/faker';
-
-let GigaPayload: any[] = []
-let tags = ['free', 'basic', 'business', 'enterprise', 'rich', 'super-rich', 'mega-rich', 'empire'];
-
-export function createMessage(): any {
-  return {
-    appLogLocId: faker.string.uuid(),
-    appData: {
-      msgId: faker.string.uuid(),
-      msgLogDateTime: faker.date.past(),
-      msgDateTime: faker.date.past(),
-      msgTag: faker.helpers.arrayElements(tags, 3),
-      msgPayload: faker.lorem.paragraphs(5)
-      // msgPayload: {
-      //   header: {
-      //     messageType: "Command",
-      //     messageID: faker.string.uuid(),
-      //     messageName: faker.word.adjective(),
-      //     dateCreated: faker.date.recent(),
-      //     isAggregated: faker.datatype.boolean(),
-      //     servicecId: faker.string.uuid(),
-      //     userId: faker.string.uuid(),
-      //     requesterId: faker.string.uuid(),
-      //     messagePreoducerInformation: {
-      //       origin: {
-      //         userApplication: {
-      //           userAppId: faker.finance.accountName(),
-      //           userAppName: faker.person.jobTitle()
-      //         }
-      //       },
-      //       components: faker.word.adverb()
-      //     },
-      //     security: {
-      //       ucpid: faker.string.uuid()
-      //     },
-      //     messageDataLocation: {
-      //       isEmbaded: faker.datatype.boolean()
-      //     },
-      //     messageDataFormat: {
-      //       dataFormate: faker.date.anytime()
-      //     },
-      //     requestExecutiomNode: faker.number.int(),
-      //     requestTimeOut: faker.number.int(),
-      //     command: faker.word.adjective()
-      //   },
-      // }
-    }
-  }
-}
-
-
-
-Array.from({ length: 100 }).forEach(() => {
-  GigaPayload.push(createMessage());
-});
-
-
-fs.writeFileSync('payload2.json', JSON.stringify(GigaPayload))

+ 21 - 0
services/utility/message-ordering.ts

@@ -1,3 +1,4 @@
+import { Subject, takeWhile } from "rxjs";
 import { WrappedMessage } from "../../interfaces/general.interface";
 
 export function sortMessageBasedOnDate(array: WrappedMessage[]): WrappedMessage[] {
@@ -6,3 +7,23 @@ export function sortMessageBasedOnDate(array: WrappedMessage[]): WrappedMessage[
         return new Date(a.timeReceived).getTime() - new Date(b.timeReceived).getTime();
     });
 }
+
+// SO concept will be that if the message behind it is received, then 
+export async function checkMessage(message: WrappedMessage, messageChecking: Subject<WrappedMessage>): Promise<any> {
+    return new Promise((resolve, reject) => {
+        if (message.previousMessageID) {
+            messageChecking.pipe(
+                takeWhile(item => message.previousMessageID === item.thisMessageID)
+            ).subscribe({
+                complete: () => {
+                    resolve('previousMessageID matched')
+                    // console.log(`${message.payload.header.messageID} : Previous messageID(${message.previousMessageID}) matched`)
+                    // console.log(`matched`)
+                }
+            })
+        } else {
+            console.log('No previous messageID. This should be the first message')
+            resolve('No previous message ID. Please Proceed.')
+        }
+    })
+}

+ 0 - 2
test/http2.ts

@@ -2,11 +2,9 @@
 
 import { BehaviorSubject, buffer, filter, interval, map, Observable, startWith, Subject, Subscriber, Subscription, switchMap, takeUntil, tap } from "rxjs";
 import { ClientNotificationState } from "../interfaces/general.interface";
-import { rxjsBuffer } from "../services/utility/buffer-obs";
 import { LogSetting } from "../dependencies/logging/type/datatype";
 import { BaseMessage } from "../dependencies/logging/services/logging-service";
 import { prepareResponseMessages } from "../services/utility/prepareFISmessage";
-import { StorageService } from "../services/storage.service";
 import { RetransmissionService } from "../services/retransmission.service";
 
 

+ 0 - 1
test/rxjsbuffer.sample.ts

@@ -1,4 +1,3 @@
-import { fa } from "@faker-js/faker"
 import { Subject, interval, Observable, buffer, switchMap, bufferToggle, map, scan, startWith, BehaviorSubject, tap } from "rxjs"
 import { prepareResponseMessages } from "../services/utility/prepareFISmessage"
 

+ 2 - 21
test/socket/socket-client.ts

@@ -13,7 +13,7 @@ let toBePassedOverToApp: Subject<BaseMessage> = new Subject()
 let sender: Subject<BaseMessage> = prepareResponseMessages(5, 1000)
 let serverSocketUrl: string = 'http://192.168.100.96:3000'
 let socket: Socket
-let client: string = 'client2'
+let client: string = 'client3'
 let mongoService: MongoService = new MongoService(client)
 
 
@@ -83,7 +83,7 @@ async function establishSocketConnection(serverUrl: string): Promise<any> {
                 mongoService.write(msg.payload, msg.payload.header.messageID, () => console.log(`Error function doesn't exist.`))
                 // Check the sequence by ensuring the message value before the current message exists, then pass them over to "App"
                 // onHoldMessagesSubject.next(msg)
-                // checkMessage(msg).then(() => [
+                // checkMessage(msg, onHoldMessageSubject).then(() => [
                     //     toBePassedOverToApp.next(msg.payload as BaseMessage)
                     // ]).catch((err) => console.error(err))
                 toBePassedOverToApp.next(msg.payload as BaseMessage)
@@ -175,22 +175,3 @@ async function sendMessage(message: BaseMessage): Promise<any> {
 }
 
 
-// SO concept will be that if the message behind it is received, then 
-async function checkMessage(message: WrappedMessage): Promise<any> {
-    return new Promise((resolve, reject) => {
-        if (message.previousMessageID) {
-            onHoldMessagesSubject.pipe(
-                takeWhile(item => message.previousMessageID === item.thisMessageID)
-            ).subscribe({
-                complete: () => {
-                    resolve('previousMessageID matched')
-                    // console.log(`${message.payload.header.messageID} : Previous messageID(${message.previousMessageID}) matched`)
-                    // console.log(`matched`)
-                }
-            })
-        } else {
-            console.log('No previous messageID. This should be the first message')
-            resolve('No previous message ID. Please Proceed.')
-        }
-    })
-}