Browse Source

add default query module

Stephen Wong 2 years ago
parent
commit
f198ef6041

+ 8 - 0
README.md

@@ -173,8 +173,16 @@ $ git rm --cached src/FisAppQueryModule/message/fisappmessagejsutility/
 $ git submodule update --init --recursive
 $ git submodule update --init --recursive
 ```
 ```
 
 
+
 ## Running the app
 ## Running the app
 
 
+#####Package Required for DefaultQuery Module
+```bash
+npm install gql-query-builder
+npm install node-json-transform
+```
+
+
 ```bash
 ```bash
 # development
 # development
 $ npm run start
 $ npm run start

File diff suppressed because it is too large
+ 17374 - 1
package-lock.json


+ 2 - 0
package.json

@@ -36,10 +36,12 @@
     "axios-observable": "^1.3.0",
     "axios-observable": "^1.3.0",
     "class-transformer": "^0.5.1",
     "class-transformer": "^0.5.1",
     "class-validator": "^0.13.2",
     "class-validator": "^0.13.2",
+    "gql-query-builder": "^3.7.0",
     "graceful-fs": "^4.2.10",
     "graceful-fs": "^4.2.10",
     "graphql": "^15.8.0",
     "graphql": "^15.8.0",
     "graphql-ws": "^5.5.5",
     "graphql-ws": "^5.5.5",
     "jsonschema": "^1.4.0",
     "jsonschema": "^1.4.0",
+    "node-json-transform": "^1.1.2",
     "reflect-metadata": "^0.1.13",
     "reflect-metadata": "^0.1.13",
     "rfdc": "^1.3.0",
     "rfdc": "^1.3.0",
     "rimraf": "^3.0.2",
     "rimraf": "^3.0.2",

+ 39 - 17
src/FisAppQueryModule/DefaultQuery/defaultQuery.dataservice.ts

@@ -1,31 +1,53 @@
 import { Injectable } from "@nestjs/common";
 import { Injectable } from "@nestjs/common";
-import { ObjectType, ArgsType } from "@nestjs/graphql";
-import { from, Observable, of } from "rxjs";
-
+import { ObjectType, ArgsType, Field } from "@nestjs/graphql";
+import { Observable, of } from "rxjs";
+import * as fs from 'graceful-fs';
+import { converter } from "./Fis-GraphQLQueryGenerator/GraphQLTypescriptConverter/GraphQLTypescriptConverter";
 @ObjectType()
 @ObjectType()
 @ArgsType()
 @ArgsType()
 export class DefaultQueryData {
 export class DefaultQueryData {
-    queryName:string 
-    queryString:string
+
+    @Field(type => [DefaultQueryDataItem])
+    data: DefaultQueryDataItem[];
+}
+
+@ObjectType()
+@ArgsType()
+export class DefaultQueryDataItem {
+    @Field()
+    queryName: string
+
+    @Field()
+    queryString: string
 }
 }
 
 
 @Injectable()
 @Injectable()
-export class DefaultQueryService { 
+export class DefaultQueryService {
+
+    defaultQueryDatas: DefaultQueryData
+
+    constructor() {
+        converter();
+
+        const directoryPath = fs.readdirSync('./src/FisAppQueryModule/DefaultQuery/Fis-GraphQLQueryGenerator/GraphQLConverted', 'utf8');
+        let arrayItems = [];
+        directoryPath.forEach(file => {
+            
+            let data: DefaultQueryDataItem = {
+                queryName: file.split('.')[0],
+                queryString: fs.readFileSync('./src/FisAppQueryModule/DefaultQuery/Fis-GraphQLQueryGenerator/GraphQLConverted/' + file, 'utf8')
+            }
 
 
-    defaultQueryDatas:DefaultQueryData[]
+            arrayItems.push(data)
 
 
-    constructor(){
-        // Trigger or somehow call the converter function
-        // ...
+        })
+        
+        this.defaultQueryDatas = {data: arrayItems}
 
 
-        // Read the default query from files and set to here to this.defaultQueryDatas array format
-        // ...
     }
     }
 
 
-    GetDefaultQuery():Observable<DefaultQueryData>{
-        // process defaultQueryDatas into multiple observable defaultQueryData responses
-        // ...
-        let defaultQuery = new DefaultQueryData();
-        return of(defaultQuery);
+    GetDefaultQuery(): Observable<DefaultQueryData> {
+        
+        return of(this.defaultQueryDatas);
     }
     }
 }
 }

+ 17 - 17
src/FisAppQueryModule/dataservice.classesList.json

@@ -7,7 +7,7 @@
             "parameter": "accountType=AP"
             "parameter": "accountType=AP"
         },
         },
         "dataName": "DataService",
         "dataName": "DataService",
-        "ucpId": "uhh8ig7187"
+        "ucpId": "ifjn9d5470"
     },
     },
     "APAccountProfileDataService": {
     "APAccountProfileDataService": {
         "http": {},
         "http": {},
@@ -17,7 +17,7 @@
             "parameter": "accountType=AP"
             "parameter": "accountType=AP"
         },
         },
         "dataName": "DataService",
         "dataName": "DataService",
-        "ucpId": "uhh8ig7187"
+        "ucpId": "ifjn9d5470"
     },
     },
     "ARAccountProfileDataService": {
     "ARAccountProfileDataService": {
         "http": {},
         "http": {},
@@ -27,7 +27,7 @@
             "parameter": "accountType=AR"
             "parameter": "accountType=AR"
         },
         },
         "dataName": "DataService",
         "dataName": "DataService",
-        "ucpId": "uhh8ig7187"
+        "ucpId": "ifjn9d5470"
     },
     },
     "CMAccountProfileDataService": {
     "CMAccountProfileDataService": {
         "http": {},
         "http": {},
@@ -37,7 +37,7 @@
             "parameter": "accountType=CM"
             "parameter": "accountType=CM"
         },
         },
         "dataName": "DataService",
         "dataName": "DataService",
-        "ucpId": "uhh8ig7187"
+        "ucpId": "ifjn9d5470"
     },
     },
     "DocumentDataService": {
     "DocumentDataService": {
         "http": {},
         "http": {},
@@ -47,7 +47,7 @@
             "parameter": "subsystemcode=AP"
             "parameter": "subsystemcode=AP"
         },
         },
         "dataName": "DataService",
         "dataName": "DataService",
-        "ucpId": "uhh8ig7187"
+        "ucpId": "ifjn9d5470"
     },
     },
     "ARInvoiceDocumentDataService": {
     "ARInvoiceDocumentDataService": {
         "http": {},
         "http": {},
@@ -57,7 +57,7 @@
             "parameter": "doccategory=IV,subsystemcode=AR"
             "parameter": "doccategory=IV,subsystemcode=AR"
         },
         },
         "dataName": "DataService",
         "dataName": "DataService",
-        "ucpId": "uhh8ig7187"
+        "ucpId": "ifjn9d5470"
     },
     },
     "APInvoiceDocumentDataService": {
     "APInvoiceDocumentDataService": {
         "http": {},
         "http": {},
@@ -67,7 +67,7 @@
             "parameter": "doccategory=RC,subsystemcode=AR"
             "parameter": "doccategory=RC,subsystemcode=AR"
         },
         },
         "dataName": "DataService",
         "dataName": "DataService",
-        "ucpId": "uhh8ig7187"
+        "ucpId": "ifjn9d5470"
     },
     },
     "ARReceiptDocumentDataService": {
     "ARReceiptDocumentDataService": {
         "http": {},
         "http": {},
@@ -77,7 +77,7 @@
             "parameter": "doccategory=RC,subsystemcode=AR"
             "parameter": "doccategory=RC,subsystemcode=AR"
         },
         },
         "dataName": "DataService",
         "dataName": "DataService",
-        "ucpId": "uhh8ig7187"
+        "ucpId": "ifjn9d5470"
     },
     },
     "APReceiptDocumentDataService": {
     "APReceiptDocumentDataService": {
         "http": {},
         "http": {},
@@ -87,7 +87,7 @@
             "parameter": "doccategory=RC,subsystemcode=AP"
             "parameter": "doccategory=RC,subsystemcode=AP"
         },
         },
         "dataName": "DataService",
         "dataName": "DataService",
-        "ucpId": "uhh8ig7187"
+        "ucpId": "ifjn9d5470"
     },
     },
     "OrganisationProfileDataService": {
     "OrganisationProfileDataService": {
         "http": {},
         "http": {},
@@ -97,7 +97,7 @@
             "parameter": ""
             "parameter": ""
         },
         },
         "dataName": "DataService",
         "dataName": "DataService",
-        "ucpId": "uhh8ig7187"
+        "ucpId": "ifjn9d5470"
     },
     },
     "ProductProfileDataService": {
     "ProductProfileDataService": {
         "http": {},
         "http": {},
@@ -107,7 +107,7 @@
             "parameter": ""
             "parameter": ""
         },
         },
         "dataName": "DataService",
         "dataName": "DataService",
-        "ucpId": "uhh8ig7187"
+        "ucpId": "ifjn9d5470"
     },
     },
     "ServiceProgramProfileDataService": {
     "ServiceProgramProfileDataService": {
         "http": {},
         "http": {},
@@ -117,7 +117,7 @@
             "parameter": ""
             "parameter": ""
         },
         },
         "dataName": "ServiceProgramProfileData",
         "dataName": "ServiceProgramProfileData",
-        "ucpId": "uhh8ig7187"
+        "ucpId": "ifjn9d5470"
     },
     },
     "FisServiceProgramProfileDataService": {
     "FisServiceProgramProfileDataService": {
         "http": {},
         "http": {},
@@ -127,7 +127,7 @@
             "parameter": "serviceTypeCode=dataservice"
             "parameter": "serviceTypeCode=dataservice"
         },
         },
         "dataName": "ServiceProgramProfileSecurityAccessRightData",
         "dataName": "ServiceProgramProfileSecurityAccessRightData",
-        "ucpId": "uhh8ig7187"
+        "ucpId": "ifjn9d5470"
     },
     },
     "RoleTypeProfileDataService": {
     "RoleTypeProfileDataService": {
         "http": {},
         "http": {},
@@ -137,7 +137,7 @@
             "parameter": ""
             "parameter": ""
         },
         },
         "dataName": "DataService",
         "dataName": "DataService",
-        "ucpId": "uhh8ig7187"
+        "ucpId": "ifjn9d5470"
     },
     },
     "LeaveBalanceDataService": {
     "LeaveBalanceDataService": {
         "http": {},
         "http": {},
@@ -147,7 +147,7 @@
             "parameter": ""
             "parameter": ""
         },
         },
         "dataName": "DataService",
         "dataName": "DataService",
-        "ucpId": "uhh8ig7187"
+        "ucpId": "ifjn9d5470"
     },
     },
     "LeaveHistoryDataService": {
     "LeaveHistoryDataService": {
         "http": {},
         "http": {},
@@ -157,7 +157,7 @@
             "parameter": ""
             "parameter": ""
         },
         },
         "dataName": "DataService",
         "dataName": "DataService",
-        "ucpId": "uhh8ig7187"
+        "ucpId": "ifjn9d5470"
     },
     },
     "LeaveTypeProfileDataService": {
     "LeaveTypeProfileDataService": {
         "http": {},
         "http": {},
@@ -167,6 +167,6 @@
             "parameter": ""
             "parameter": ""
         },
         },
         "dataName": "DataService",
         "dataName": "DataService",
-        "ucpId": "uhh8ig7187"
+        "ucpId": "ifjn9d5470"
     }
     }
 }
 }

+ 2 - 1
src/FisAppQueryModule/dataservice.module.ts

@@ -1,12 +1,13 @@
 import { HttpModule } from '@nestjs/axios';
 import { HttpModule } from '@nestjs/axios';
 import { Module } from '@nestjs/common';
 import { Module } from '@nestjs/common';
 import { ApplicationDataservice } from './Application.dataservice';
 import { ApplicationDataservice } from './Application.dataservice';
+import { DefaultQueryService } from './DefaultQuery/defaultQuery.dataservice';
 import { FisAppQueryResolver } from './fisAppQuery.resolver';
 import { FisAppQueryResolver } from './fisAppQuery.resolver';
 import { FisAppQueryService } from './fisAppQuery.service';
 import { FisAppQueryService } from './fisAppQuery.service';
 import { DataServiceManager } from './Manager.dataservice';
 import { DataServiceManager } from './Manager.dataservice';
 
 
 @Module({
 @Module({
     imports: [HttpModule],
     imports: [HttpModule],
-    providers: [DataServiceManager,ApplicationDataservice, FisAppQueryResolver,FisAppQueryService]
+    providers: [DataServiceManager,ApplicationDataservice, FisAppQueryResolver,FisAppQueryService, DefaultQueryService]
 })
 })
 export class DataserviceModule {}
 export class DataserviceModule {}

+ 10 - 0
src/schema.gql

@@ -271,6 +271,15 @@ type DataServiceMessage {
   returnSequenceTotal: Float
   returnSequenceTotal: Float
 }
 }
 
 
+type DefaultQueryData {
+  data: [DefaultQueryDataItem!]!
+}
+
+type DefaultQueryDataItem {
+  queryName: String!
+  queryString: String!
+}
+
 type Document {
 type Document {
   acct_id: Int
   acct_id: Int
   doc_by_org_code: String
   doc_by_org_code: String
@@ -522,6 +531,7 @@ type Query {
   ARReceiptDocumentQuery(filter: String, returnFormatType: String): ARReceiptDocumentUnion!
   ARReceiptDocumentQuery(filter: String, returnFormatType: String): ARReceiptDocumentUnion!
   AccountProfileQuery(filter: String, returnFormatType: String): AccountProfileUnion!
   AccountProfileQuery(filter: String, returnFormatType: String): AccountProfileUnion!
   CMAccountProfileQuery(filter: String, returnFormatType: String): CMAccountProfileUnion!
   CMAccountProfileQuery(filter: String, returnFormatType: String): CMAccountProfileUnion!
+  DefaultQuery: DefaultQueryData!
   DocumentQuery(filter: String, returnFormatType: String): DocumentUnion!
   DocumentQuery(filter: String, returnFormatType: String): DocumentUnion!
   FisServiceProgramProfileQuery(filter: String, returnFormatType: String): FisServiceProgramUnion!
   FisServiceProgramProfileQuery(filter: String, returnFormatType: String): FisServiceProgramUnion!
   LeaveBalanceQuery(filter: String, returnFormatType: String): LeaveBalanceUnion!
   LeaveBalanceQuery(filter: String, returnFormatType: String): LeaveBalanceUnion!

Some files were not shown because too many files changed in this diff