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

Data model , proof and request #11

Closed
wants to merge 9 commits into from
Closed
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
16 changes: 15 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,18 @@ node_modules/
.mesh/
.vscode/
.env
build/
build/


# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json


# System Files
.DS_Store
Thumbs.db
.env.*
1 change: 0 additions & 1 deletion .meshrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ sources:
- Query.!transaction
- Query.!transactions
- Query.!myTransactions

customFetch: ./custom-fetch.ts

sdk:
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"docwriter.style": "JSDoc"
}
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
setupFiles: [
'dotenv/config'
],
};
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion src/Gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ import { Organization } from './organization/organization';
import { Auth } from './auth/auth';
import { PDA } from './pda/pda';
import { DataRequestTemplate } from './dataRequestsTemplate/dataRequestsTemplate';
import { Proof } from './proof/proof';
import { Request } from './request/request';
import { DataModel } from './data-model/data-model';
import { User } from './user/user';

export class Gateway {
private sdk: Sdk;
public dataModel: DataModel;
public proof: Proof;
public user: User;
public request: Request;
public pda: PDA;
public dataRequestTemplate: DataRequestTemplate;
public organization: Organization;
Expand All @@ -20,9 +26,12 @@ export class Gateway {
token,
});
this.pda = new PDA(this.sdk);
this.user = new User(this.sdk);
this.dataRequestTemplate = new DataRequestTemplate(this.sdk);
this.organization = new Organization(this.sdk);
this.auth = new Auth(this.sdk);
this.dataModel = new DataModel(this.sdk);
this.proof = new Proof(this.sdk);
this.request = new Request(this.sdk);
this.user = new User(this.sdk);
}
}
168 changes: 168 additions & 0 deletions src/data-model/data-model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
import {
CreateDataModelInput,
Sdk,
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. */

export class DataModel {
private sdk: Sdk;

constructor(sdk: Sdk) {
this.sdk = sdk;
}

/**
* The function `createModelInput` is an asynchronous function that takes a `CreateDataModelInput`
* object as input and returns a promise that resolves to a `createDataModel_mutationMutation` object.
* @param {CreateDataModelInput} createModelInput - The `createModelInput` parameter is of type
* `CreateDataModelInput`. It is an input object that contains the data needed to create a new data
* model.
* @returns a Promise that resolves to a value of type `createDataModel_mutationMutation`.
*/
async createDataModel(createModelInput: CreateDataModelInput) {
try {
return await this.sdk.createDataModel_mutation({
input: createModelInput,
});
} catch (error: any) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove :any part from all catch blocks just to maintain consistency

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool

throw new Error(errorHandler(error));
}
}

/**
* The function `getDataModel` retrieves a data model using its ID and returns a promise that resolves
* to the queried data model.
* @param {string} dataModelId - The dataModelId parameter is a string that represents the unique
* identifier of a data model. It is used to query and retrieve a specific data model from the system.
* @returns a Promise that resolves to a dataModel_queryQuery object.
*/
async getDataModel(dataModelId: string) {
try {
return await this.sdk.dataModel_query({ id: dataModelId });
} catch (error: any) {
throw new Error(errorHandler(error));
}
}

/**
* The function `getDataModels` is an asynchronous function that queries data models and returns the
* result.
* @param {dataModels_queryQueryVariables} dataModel - The `dataModel` parameter is an object that
* contains variables for the `dataModels_query` query. It is of type `dataModels_queryQueryVariables`.
* @returns The `getDataModels` function is returning the result of the `dataModels_query` function
* call.
*/

async getDataModels({
filter,
order,
skip,
take,
}: dataModels_queryQueryVariables = {}) {
try {
const data = await this.sdk.dataModels_query({
filter,
order,
skip,
take,
});
return data;
} catch (error: any) {
throw new Error(errorHandler(error));
}
}

/**
* The function `getDataModelsCount` is an asynchronous function that retrieves the count of data
* models based on the provided filter variables.
* @param variables - The `variables` parameter is of type `InputMaybe<FilterDataModelInput>`. It is an
* optional input that can be used to filter the data models. The `FilterDataModelInput` is a type that
* contains various filter options .
* * The above type represents the input data model for filtering data, including consumption price,
* organization identification, and user information.
* @property {InputMaybe<FloatRangeDto> | undefined} consumptionPrice - It is an optional property of
* type `InputMaybe<FloatRangeDto>`. This means that it can either be `undefined` or an object of type
* `FloatRangeDto`.
* @property {InputMaybe<OrganizationIdentificationInput> | undefined} organization - The
* "organization" property is an optional input that represents the identification of an organization.
* It can be of type "InputMaybe<OrganizationIdentificationInput>", which means it can either be a
* valid organization identification input or undefined.
* @property {InputMaybe} user - The "user" property is of type "InputMaybe" which means it can either
* be a value of type "undefined" or a value of another type. The specific type of "user" is not
* provided in the code snippet, so it is unclear what type it should be.
* @returns The `getDataModelsCount` function is returning the result of the `dataModelsCount_query`
* method call, which is a promise.
*/

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run pnpm format missing lines in test files as well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool

async getDataModelsCount(filterVariables?: FilterDataModelInput) {
try {
return await this.sdk.dataModelsCount_query({
filter: filterVariables,
});
} catch (error: any) {
throw new Error(errorHandler(error));
}
}

/**
* The function `getDataModelMetaData` is an asynchronous function that retrieves metadata for data
* models and throws an error if there is any.
* @returns The `getDataModelMetaData` function is returning the result of the
* `dataModelsMetadata_query` method call.
*/
async getDataModelMetaData() {
try {
return await this.sdk.dataModelsMetadata_query();
} catch (error: any) {
throw new Error(errorHandler(error));
}
}

/**
* The function `getIssuersByDataModel` retrieves issuers based on a given data model ID using an SDK.
* @param {string} id - A string representing the ID of the data model.
* @returns the result of the `issuersByDataModel_query` method call.
*/
async getIssuersByDataModel(id: string) {
try {
return await this.sdk.issuersByDataModel_query({ id: id });
} catch (error: any) {
throw new Error(errorHandler(error));
}
}

/**
* The function `getIssuersByDataModelCount` retrieves the count of issuers based on a given data model
* ID.
* @param {string} dataModelId - The dataModelId parameter is a string that represents the ID of a data
* model.
* @returns the result of the `issuersByDataModelCount_query` method call.
*/
async getIssuersByDataModelCount(dataModelId: string) {
try {
return await this.sdk.issuersByDataModelCount_query({ id: dataModelId });
} catch (error: any) {
throw new Error(errorHandler(error));
}
}

/**
* The function `getTotalofIssuersByDataModel` retrieves the total number of issuers based on a given
* data model ID.
* @param {string} dataModelId - The dataModelId parameter is a string that represents the identifier
* of a data model. It is used to query the total number of issuers associated with that data model.
* @returns the result of the `getTotalofIssuersByDataModel_query` method call.
*/
async getTotalofIssuersByDataModel(dataModelId: string) {
try {
return await this.sdk.getTotalofIssuersByDataModel_query({ dataModelId });
} catch (error: any) {
throw new Error(errorHandler(error));
}
}
}
Loading
Loading