Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore : minor fixes #17

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 9 additions & 22 deletions src/data-model/data-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
dataModels_queryQueryVariables,
FilterDataModelInput,
} from '../../.mesh';
import { DEFAULT_TAKE_LIMIT } from '../utils/constants';
import { errorHandler } from '../utils/errorHandler';
import { isUUIDValid, validateObjectProperties } from '../utils/validators';

Expand All @@ -29,7 +28,7 @@ export class DataModel {
async createDataModel(createModelInput: CreateDataModelInput) {
try {
validateObjectProperties(createModelInput);
return await this.sdk.createDataModel_mutation({
return this.sdk.createDataModel_mutation({
input: createModelInput,
});
} catch (error: any) {
Expand All @@ -47,7 +46,7 @@ export class DataModel {
async getDataModel(dataModelId: string) {
try {
isUUIDValid(dataModelId);
return await this.sdk.dataModel_query({ id: dataModelId });
return this.sdk.dataModel_query({ id: dataModelId });
} catch (error: any) {
throw new Error(errorHandler(error));
}
Expand All @@ -62,21 +61,9 @@ export class DataModel {
* call.
*/

async getDataModels(
{ filter, order, skip, take }: dataModels_queryQueryVariables = {
filter: {},
order: {},
skip: 0,
take: DEFAULT_TAKE_LIMIT,
},
) {
async getDataModels(variables?: dataModels_queryQueryVariables) {
try {
const data = await this.sdk.dataModels_query({
filter,
order,
skip,
take,
});
const data = this.sdk.dataModels_query(variables);
return data;
} catch (error: any) {
throw new Error(errorHandler(error));
Expand Down Expand Up @@ -107,7 +94,7 @@ export class DataModel {

async getDataModelsCount(filterVariables?: FilterDataModelInput) {
try {
return await this.sdk.dataModelsCount_query({
return this.sdk.dataModelsCount_query({
filter: filterVariables,
});
} catch (error: any) {
Expand All @@ -123,7 +110,7 @@ export class DataModel {
*/
async getDataModelsMetaData() {
try {
return await this.sdk.dataModelsMetadata_query();
return this.sdk.dataModelsMetadata_query();
} catch (error: any) {
throw new Error(errorHandler(error));
}
Expand All @@ -137,7 +124,7 @@ export class DataModel {
async getIssuersByDataModel(id: string) {
try {
isUUIDValid(id);
return await this.sdk.issuersByDataModel_query({ id: id });
return this.sdk.issuersByDataModel_query({ id: id });
} catch (error: any) {
throw new Error(errorHandler(error));
}
Expand All @@ -153,7 +140,7 @@ export class DataModel {
async getIssuersByDataModelCount(dataModelId: string) {
try {
isUUIDValid(dataModelId);
return await this.sdk.issuersByDataModelCount_query({ id: dataModelId });
return this.sdk.issuersByDataModelCount_query({ id: dataModelId });
} catch (error: any) {
throw new Error(errorHandler(error));
}
Expand All @@ -169,7 +156,7 @@ export class DataModel {
async getTotalofIssuersByDataModel(dataModelId: string) {
try {
isUUIDValid(dataModelId);
return await this.sdk.getTotalofIssuersByDataModel_query({ dataModelId });
return this.sdk.getTotalofIssuersByDataModel_query({ dataModelId });
} catch (error: any) {
throw new Error(errorHandler(error));
}
Expand Down
28 changes: 6 additions & 22 deletions src/dataRequestsTemplate/dataRequestsTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
FilterDataRequestTemplateInput,
Sdk,
TemplateSchemaInput,
dataRequestTemplates_queryQueryVariables,
} from '../../.mesh';
import { errorHandler } from '../utils/errorHandler';
import { isUUIDValid, validateObjectProperties } from '../utils/validators';
Expand All @@ -24,7 +25,7 @@ export class DataRequestTemplate {
async createDataRequestTemplate(templateInput: TemplateSchemaInput) {
try {
validateObjectProperties(templateInput);
return await this.sdk.createDataRequestTemplate_mutation({
return this.sdk.createDataRequestTemplate_mutation({
input: templateInput,
});
} catch (error) {
Expand All @@ -42,7 +43,7 @@ export class DataRequestTemplate {
async getDataRequestTemplate(id: string) {
try {
isUUIDValid(id);
return await this.sdk.dataRequestTemplate_query({ id });
return this.sdk.dataRequestTemplate_query({ id });
} catch (error) {
throw new Error(errorHandler(error));
}
Expand All @@ -57,25 +58,10 @@ export class DataRequestTemplate {
* that resolves to the data request templates.
*/
async getDataRequestTemplates(
{
filter,
order,
skip,
take,
}: {
filter?: FilterDataRequestTemplateInput;
order?: JSON;
skip?: number;
take?: number;
} = { filter: {}, order: {} as JSON, skip: 0, take: 10 },
variables?: dataRequestTemplates_queryQueryVariables,
) {
try {
return await this.sdk.dataRequestTemplates_query({
filter,
order,
skip,
take,
});
return this.sdk.dataRequestTemplates_query(variables);
} catch (error) {
throw new Error(errorHandler(error));
}
Expand All @@ -89,9 +75,7 @@ export class DataRequestTemplate {
* `FilterDataRequestTemplateInput`.
* @returns the count of data request templates.
*/
async getDataRequestsTemplateCount(
filter: FilterDataRequestTemplateInput = {},
) {
async getDataRequestsTemplateCount(filter?: FilterDataRequestTemplateInput) {
try {
return (await this.sdk.dataRequestTemplatesCount_query({ filter }))
.dataRequestTemplatesCount;
Expand Down
28 changes: 9 additions & 19 deletions src/organization/organization.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {
CreateOrganizationInput,
FilterOrganizationInput,
MemberInput,
Sdk,
TransferMemberInput,
UpdateOrganizationInput,
organizations_queryQueryVariables,
} from '../../.mesh';
import { OrganizationIdentifierType } from '../types';
import { DEFAULT_TAKE_LIMIT } from '../utils/constants';

import { errorHandler } from '../utils/errorHandler';
import { isStringValid, validateObjectProperties } from '../utils/validators';

Expand All @@ -31,7 +31,7 @@ export class Organization {
async createOrganization(organizationInput: CreateOrganizationInput) {
try {
validateObjectProperties(organizationInput);
return await this.sdk.createOrganization_mutation({
return this.sdk.createOrganization_mutation({
input: organizationInput,
});
} catch (error) {
Expand All @@ -48,7 +48,7 @@ export class Organization {
*/
async addMemberToOrganization(memberInput: MemberInput) {
try {
return await this.sdk.addMemberToOrganization_mutation({
return this.sdk.addMemberToOrganization_mutation({
input: memberInput,
});
} catch (error) {
Expand All @@ -66,7 +66,7 @@ export class Organization {
*/
async changeMemberRole(memberInput: MemberInput) {
try {
return await this.sdk.changeMemberRole_mutation({ input: memberInput });
return this.sdk.changeMemberRole_mutation({ input: memberInput });
} catch (error) {
throw new Error(errorHandler(error));
}
Expand Down Expand Up @@ -101,7 +101,7 @@ export class Organization {
async updateOrganization(updatedOrganization: UpdateOrganizationInput) {
try {
validateObjectProperties(updatedOrganization);
return await this.sdk.updateOrganization_mutation({
return this.sdk.updateOrganization_mutation({
input: updatedOrganization,
});
} catch (error) {
Expand All @@ -123,7 +123,7 @@ export class Organization {
async getOrganization(type: OrganizationIdentifierType, value: string) {
try {
isStringValid(value);
return await this.sdk.organization_query({ input: { type, value } });
return this.sdk.organization_query({ input: { type, value } });
} catch (error) {
throw new Error(errorHandler(error));
}
Expand All @@ -136,19 +136,9 @@ export class Organization {
* to filter the organizations based on certain criteria.
* @returns the result of the `organizations_query` method call from the `sdk` object.
*/
async getOrganizations(
{
filter,
skip,
take,
}: {
filter?: FilterOrganizationInput;
skip?: number;
take?: number;
} = { filter: {}, skip: 0, take: DEFAULT_TAKE_LIMIT },
) {
async getOrganizations(variables?: organizations_queryQueryVariables) {
try {
return await this.sdk.organizations_query({ filter, skip, take });
return await this.sdk.organizations_query(variables);
} catch (error) {
throw new Error(errorHandler(error));
}
Expand Down
39 changes: 13 additions & 26 deletions src/pda/pda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import {
Sdk,
FilterPDAInput,
UpdatePDAInput,
PDAs_queryQueryVariables,
issuedPDAs_queryQueryVariables,
} from '../../.mesh';
import { PDAFilter, PDAStatus } from '../types';
import { DEFAULT_TAKE_LIMIT } from '../utils/constants';
import { PDAStatus } from '../types';
import { errorHandler } from '../utils/errorHandler';
import { isUUIDValid, validateObjectProperties } from '../utils/validators';

Expand All @@ -26,7 +27,7 @@ export class PDA {
async getPDA(id: string) {
try {
isUUIDValid(id);
return await this.sdk.PDA_query({ id });
return this.sdk.PDA_query({ id });
} catch (error) {
throw new Error(errorHandler(error));
}
Expand Down Expand Up @@ -54,16 +55,9 @@ export class PDA {
* @param {PDAFilter} - - `filter`: An object that contains filter criteria for the query.
* @returns a Promise that resolves to a value of type PDAs_queryQuery.
*/
async getPDAs(
{ filter, order, skip, take }: PDAFilter = {
filter: {},
order: {} as JSON,
skip: 0,
take: DEFAULT_TAKE_LIMIT,
},
) {
async getPDAs(variables?: PDAs_queryQueryVariables) {
try {
return await this.sdk.PDAs_query({ filter, order, skip, take });
return this.sdk.PDAs_query(variables);
} catch (error) {
throw new Error(errorHandler(error));
}
Expand All @@ -76,16 +70,9 @@ export class PDA {
* used to specify conditions that the returned PDAs must meet.
* @returns a Promise that resolves to an object of type `issuedPDAs_queryQuery`.
*/
async getIssuedPDAs(
{ filter, order, skip, take }: PDAFilter = {
filter: {},
order: {} as JSON,
skip: 0,
take: DEFAULT_TAKE_LIMIT,
},
) {
async getIssuedPDAs(variables?: issuedPDAs_queryQueryVariables) {
try {
return await this.sdk.issuedPDAs_query({ filter, order, skip, take });
return this.sdk.issuedPDAs_query(variables);
} catch (error) {
throw new Error(errorHandler(error));
}
Expand All @@ -98,7 +85,7 @@ export class PDA {
* specify criteria for filtering the issued PDAs. It is of type `FilterPDAInput`.
* @returns a Promise that resolves to a number.
*/
async getIssuedPDAsCount(filter: FilterPDAInput = {}) {
async getIssuedPDAsCount(filter?: FilterPDAInput) {
try {
return (await this.sdk.issuedPDAsCount_query({ filter })).issuedPDAsCount;
} catch (error) {
Expand All @@ -113,7 +100,7 @@ export class PDA {
* filter the results of the query. It is of type `FilterPDAInput`.
* @returns a Promise that resolves to a number.
*/
async myPDACount(filter: FilterPDAInput = {}) {
async myPDACount(filter?: FilterPDAInput) {
try {
return (await this.sdk.myPDACount_query({ filter })).myPDACount;
} catch (error) {
Expand All @@ -130,7 +117,7 @@ export class PDA {
async changePDAStatus({ id, status }: { id: string; status: PDAStatus }) {
try {
isUUIDValid(id);
return await this.sdk.changePDAStatus_mutation({ input: { id, status } });
return this.sdk.changePDAStatus_mutation({ input: { id, status } });
} catch (error) {
throw new Error(errorHandler(error));
}
Expand All @@ -145,7 +132,7 @@ export class PDA {
async createPDA(pdaInput: CreatePDAInput) {
try {
validateObjectProperties(pdaInput);
return await this.sdk.createPDA_mutation({ input: pdaInput });
return this.sdk.createPDA_mutation({ input: pdaInput });
} catch (error) {
throw new Error(errorHandler(error));
}
Expand All @@ -163,7 +150,7 @@ export class PDA {
async updatePDA(updatedPDA: UpdatePDAInput) {
try {
validateObjectProperties(updatedPDA);
return await this.sdk.updatePDA_mutation({ input: updatedPDA });
return this.sdk.updatePDA_mutation({ input: updatedPDA });
} catch (error) {
throw new Error(errorHandler(error));
}
Expand Down
Loading
Loading