From 055491b383df67ad5651f20c08f331a04322423f Mon Sep 17 00:00:00 2001 From: r11manish Date: Fri, 1 Dec 2023 16:11:19 +0530 Subject: [PATCH] chore : feedback and merge fixes --- src/data-model/data-model.ts | 23 +++++++++-------------- src/proof/proof.ts | 19 ++++++++++--------- src/request/request.ts | 20 ++++++++++---------- test/data-model.test.ts | 9 ++++----- 4 files changed, 33 insertions(+), 38 deletions(-) diff --git a/src/data-model/data-model.ts b/src/data-model/data-model.ts index bc34ce6..4d016e0 100644 --- a/src/data-model/data-model.ts +++ b/src/data-model/data-model.ts @@ -4,6 +4,7 @@ import { dataModels_queryQueryVariables, FilterDataModelInput, } from '../../.mesh'; +import { errorHandler } from '../utils/errorHandler'; /* The `DataModel` class is a TypeScript class that provides methods for creating and retrieving data models. */ @@ -29,8 +30,7 @@ export class DataModel { input: createModelInput, }); } catch (error: any) { - console.log(error); - throw new Error(error); + throw new Error(errorHandler(error)); } } @@ -45,8 +45,7 @@ export class DataModel { try { return await this.sdk.dataModel_query({ id: dataModelId }); } catch (error: any) { - console.log(error); - throw new Error(error); + throw new Error(errorHandler(error)); } } @@ -74,8 +73,7 @@ export class DataModel { }); return data; } catch (error: any) { - console.log(error); - throw new Error(error); + throw new Error(errorHandler(error)); } } @@ -107,7 +105,7 @@ export class DataModel { filter: filterVariables, }); } catch (error: any) { - throw new Error(error); + throw new Error(errorHandler(error)); } } @@ -121,7 +119,7 @@ export class DataModel { try { return await this.sdk.dataModelsMetadata_query(); } catch (error: any) { - throw new Error(error); + throw new Error(errorHandler(error)); } } @@ -134,8 +132,7 @@ export class DataModel { try { return await this.sdk.issuersByDataModel_query({ id: id }); } catch (error: any) { - console.error(error); - throw new Error(error); + throw new Error(errorHandler(error)); } } @@ -150,8 +147,7 @@ export class DataModel { try { return await this.sdk.issuersByDataModelCount_query({ id: dataModelId }); } catch (error: any) { - console.error(error); - throw new Error(error); + throw new Error(errorHandler(error)); } } @@ -166,8 +162,7 @@ export class DataModel { try { return await this.sdk.getTotalofIssuersByDataModel_query({ dataModelId }); } catch (error: any) { - console.error(error); - throw new Error(error); + throw new Error(errorHandler(error)); } } } diff --git a/src/proof/proof.ts b/src/proof/proof.ts index fbba8aa..27cb879 100644 --- a/src/proof/proof.ts +++ b/src/proof/proof.ts @@ -7,6 +7,7 @@ import { sentProofsCount_queryQueryVariables, sentProofs_queryQueryVariables, } from '../../.mesh'; +import { errorHandler } from '../utils/errorHandler'; export class Proof { private sdk: Sdk; @@ -27,7 +28,7 @@ export class Proof { try { return await this.sdk.proof_query({ id: id }); } catch (error: any) { - throw new Error(error); + throw new Error(errorHandler(error)); } } /** @@ -46,7 +47,7 @@ export class Proof { try { return await this.sdk.createProof_mutation(inputVariables); } catch (error: any) { - throw new Error(error); + throw new Error(errorHandler(error)); } } @@ -64,7 +65,7 @@ export class Proof { requestId: requestId, }); } catch (error: any) { - throw new Error(error); + throw new Error(errorHandler(error)); } } @@ -89,7 +90,7 @@ export class Proof { take, }); } catch (error: any) { - throw new Error(error); + throw new Error(errorHandler(error)); } } @@ -109,7 +110,7 @@ export class Proof { try { return await this.sdk.proofsByPDAIds_query({ pdaIds, skip, take }); } catch (error: any) { - throw new Error(error); + throw new Error(errorHandler(error)); } } @@ -136,7 +137,7 @@ export class Proof { take, }); } catch (error: any) { - throw new Error(error); + throw new Error(errorHandler(error)); } } @@ -153,7 +154,7 @@ export class Proof { try { return await this.sdk.receivedProofsCount_query({ organizationId }); } catch (error: any) { - throw new Error(error); + throw new Error(errorHandler(error)); } } /** @@ -173,7 +174,7 @@ export class Proof { try { return await this.sdk.sentProofs_query({ order, skip, take }); } catch (error: any) { - throw new Error(error); + throw new Error(errorHandler(error)); } } @@ -191,7 +192,7 @@ export class Proof { try { return await this.sdk.sentProofsCount_query(queryVariables); } catch (error: any) { - throw new Error(error); + throw new Error(errorHandler(error)); } } } diff --git a/src/request/request.ts b/src/request/request.ts index 5cb7dbb..b7113bc 100644 --- a/src/request/request.ts +++ b/src/request/request.ts @@ -5,6 +5,7 @@ import { requestsReceived_queryQueryVariables, requestsSent_queryQueryVariables, } from '../../.mesh'; +import { errorHandler } from '../utils/errorHandler'; export class Request { private sdk: Sdk; @@ -27,7 +28,7 @@ export class Request { try { return this.sdk.createDataRequest_mutation({ input: inputSchema }); } catch (error: any) { - throw new Error(error); + throw new Error(errorHandler(error)); } } @@ -44,7 +45,7 @@ export class Request { try { return await this.sdk.dataRequest_query({ requestId }); } catch (error: any) { - throw new Error(error); + throw new Error(errorHandler(error)); } } @@ -60,7 +61,7 @@ export class Request { try { return await this.sdk.dataRequestCount_query({ filter: filterVariables }); } catch (error: any) { - throw new Error(error); + throw new Error(errorHandler(error)); } } @@ -75,7 +76,7 @@ export class Request { try { return await this.sdk.dataRequestStatus_query({ requestId }); } catch (error: any) { - throw new Error(error); + throw new Error(errorHandler(error)); } } @@ -92,8 +93,7 @@ export class Request { try { return await this.sdk.dataRequests_query({ filter: filterVariables }); } catch (error: any) { - console.log(error); - throw new Error(error); + throw new Error(errorHandler(error)); } } @@ -119,7 +119,7 @@ export class Request { take, }); } catch (error: any) { - throw new Error(error); + throw new Error(errorHandler(error)); } } @@ -137,7 +137,7 @@ export class Request { filter: filterVariables, }); } catch (error: any) { - throw new Error(error); + throw new Error(errorHandler(error)); } } @@ -159,7 +159,7 @@ export class Request { try { return await this.sdk.requestsSent_query({ filter, order, skip, take }); } catch (error: any) { - throw new Error(error); + throw new Error(errorHandler(error)); } } @@ -177,7 +177,7 @@ export class Request { filter: filterVariables, }); } catch (error: any) { - throw new Error(error); + throw new Error(errorHandler(error)); } } } diff --git a/test/data-model.test.ts b/test/data-model.test.ts index 13ea2f4..b777196 100644 --- a/test/data-model.test.ts +++ b/test/data-model.test.ts @@ -38,7 +38,6 @@ describe('data model function tests', () => { }, 40000); it('get the data model', async () => { - // first we create datamodel and then check with id const { createDataModel } = await api.dataModel.createDataModel({ schema: { type: 'object', @@ -59,11 +58,11 @@ describe('data model function tests', () => { expect(dataModel.id).toEqual(createDataModel.id); }); - // it('gets data moldel', async () => { - // const { dataModels } = await api.dataModel.getDataModels(); + it('gets data moldel', async () => { + const { dataModels } = await api.dataModel.getDataModels(); - // expect(dataModels.length).toBeGreaterThanOrEqual(0); - // }, 2200000); + expect(dataModels.length).toBeGreaterThanOrEqual(0); + }, 5000); it('models count', async () => { const { dataModelsCount } = await api.dataModel.getDataModelsCount();