Skip to content

Commit

Permalink
fix: data asset naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth9890 committed Oct 9, 2024
1 parent 347fea8 commit c14a613
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 116 deletions.
35 changes: 22 additions & 13 deletions api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ paths:
schema:
type: array
items:
$ref: '#/components/schemas/model.ACLRequest'
$ref: '#/components/schemas/model.DeleteACLRequest'
description: Delete Assigned ACL Items Request
required: true
responses:
Expand Down Expand Up @@ -537,12 +537,7 @@ paths:
- Data models
summary: Create data model
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/model.DataModelRequest'
description: Data Model
required: true
$ref: '#/components/requestBodies/model.DataModelRequest'
responses:
'201':
description: Created
Expand Down Expand Up @@ -620,12 +615,7 @@ paths:
schema:
type: integer
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/model.DataModel'
description: Data Model
required: true
$ref: '#/components/requestBodies/model.DataModelRequest'
responses:
'200':
description: OK
Expand All @@ -637,6 +627,14 @@ servers:
- url: 'https://localhost:8080'
- url: 'http://localhost:8080'
components:
requestBodies:
model.DataModelRequest:
content:
application/json:
schema:
$ref: '#/components/schemas/model.DataModelRequest'
description: Data Model
required: true
securitySchemes:
BearerAuth:
description: Type "Bearer" followed by a space and the JWT token.
Expand Down Expand Up @@ -779,11 +777,13 @@ components:
model.DataModel:
type: object
required:
- created_at
- created_by
- description
- id
- schema
- title
- updated_at
properties:
created_at:
type: string
Expand Down Expand Up @@ -822,6 +822,15 @@ components:
type: string
title:
type: string
model.DeleteACLRequest:
type: object
required:
- addresses
properties:
addresses:
type: array
items:
type: string
model.MessageResponse:
type: object
required:
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import { WalletService } from '../services/wallet-service';
signingKey: string;
}\n\n`,
`export enum WalletTypeEnum {
Etherum = 'etherum',
Ethereum = 'ethereum',
Solana = 'solana',
}\n\n`,
`export interface JWTData {
Expand Down
32 changes: 16 additions & 16 deletions src/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ export interface paths {
/** @description Delete Assigned ACL Items Request */
requestBody: {
content: {
'application/json': components['schemas']['model.ACLRequest'][];
'application/json': components['schemas']['model.DeleteACLRequest'][];
};
};
responses: {
Expand Down Expand Up @@ -852,12 +852,7 @@ export interface paths {
path?: never;
cookie?: never;
};
/** @description Data Model */
requestBody: {
content: {
'application/json': components['schemas']['model.DataModelRequest'];
};
};
requestBody: components['requestBodies']['model.DataModelRequest'];
responses: {
/** @description Created */
201: {
Expand Down Expand Up @@ -970,12 +965,7 @@ export interface paths {
};
cookie?: never;
};
/** @description Data Model */
requestBody: {
content: {
'application/json': components['schemas']['model.DataModel'];
};
};
requestBody: components['requestBodies']['model.DataModelRequest'];
responses: {
/** @description OK */
200: {
Expand Down Expand Up @@ -1049,22 +1039,25 @@ export interface components {
id: number;
};
'model.DataModel': {
created_at?: string;
created_at: string;
created_by: string;
deleted_at?: string;
description: string;
id: number;
schema: Record<string, never>;
tags?: string[];
title: string;
updated_at?: string;
updated_at: string;
};
'model.DataModelRequest': {
description: string;
schema: Record<string, never>;
tags?: string[];
title: string;
};
'model.DeleteACLRequest': {
addresses: string[];
};
'model.MessageResponse': {
message: string;
};
Expand Down Expand Up @@ -1130,7 +1123,14 @@ export interface components {
};
responses: never;
parameters: never;
requestBodies: never;
requestBodies: {
/** @description Data Model */
'model.DataModelRequest': {
content: {
'application/json': components['schemas']['model.DataModelRequest'];
};
};
};
headers: never;
pathItems: never;
}
Expand Down
10 changes: 6 additions & 4 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export type Environment = 'dev' | 'prod';
export type TokenManagementMode = 'jwt' | 'privateKey';

export interface Config {
environment: Environment;
jwt?: string;
environment: Environment;
logging?: boolean;
wallet?: {
privateKey: string;
Expand All @@ -26,7 +26,7 @@ export interface WalletSignMessageType {
}

export enum WalletTypeEnum {
Etherum = 'etherum',
Ethereum = 'ethereum',
Solana = 'solana',
}

Expand Down Expand Up @@ -131,15 +131,15 @@ export type CreateDataAssetRequest = {
export type DataAssetIDRequestAndResponse = { id: number };

export type DataModel = {
created_at?: string;
created_at: string;
created_by: string;
deleted_at?: string;
description: string;
id: number;
schema: {};
tags?: string[];
title: string;
updated_at?: string;
updated_at: string;
};

export type DataModelRequest = {
Expand All @@ -149,6 +149,8 @@ export type DataModelRequest = {
title: string;
};

export type DeleteACLRequest = { addresses: string[] };

export type MessageResponse = { message: string };

export type MyAccountResponse = {
Expand Down
11 changes: 8 additions & 3 deletions src/modules/data-asset/acl.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { MediaType } from 'openapi-typescript-helpers';
import { paths } from '../../api';
import { OpenAPIClient, ACLRequest, PublicACL } from '../../common/types';
import {
OpenAPIClient,
ACLRequest,
PublicACL,
DeleteACLRequest,
} from '../../common/types';
import { GTWError } from '../../helpers/custom-error';
import { ValidationService } from '../../services/validator-service';

Expand Down Expand Up @@ -81,12 +86,12 @@ export class ACL {
* access control entries should be deleted for the data
* @returns the message from the `data` object, which is accessed using `data.message`.
*/
public async delete(id: number, aclList: ACLRequest[]) {
public async delete(id: number, aclList: DeleteACLRequest) {
const { data, error, response } = await this.client.PATCH(
'/data-assets/{id}/acl/delete',
{
params: { path: { id } },
body: aclList,
body: [aclList],
},
);

Expand Down
14 changes: 7 additions & 7 deletions src/modules/data-asset/data-asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ export class DataAsset {
* This TypeScript function retrieves received data assets with pagination parameters.
* @param {number} [page=1] - The `page` parameter is used to specify the page number of the
* paginated data that you want to retrieve. It defaults to 1 if not provided.
* @param {number} [page_size=10] - The `page_size` parameter in the `getReceivedToMe` function
* @param {number} [page_size=10] - The `page_size` parameter in the `getReceivedByMe` function
* specifies the number of items to be displayed per page when fetching received data assets. By
* default, it is set to 10, meaning that the function will return a maximum of 10 data assets per
* page unless specified otherwise.
* @returns The `getReceivedToMe` function is returning a `HelperPaginatedResponse` object containing
* @returns The `getReceivedByMe` function is returning a `HelperPaginatedResponse` object containing
* an array of `PublicDataAsset` objects.
*/
public async getReceivedToMe(page: number = 1, page_size: number = 10) {
public async getReceivedByMe(page: number = 1, page_size: number = 10) {
const { data, response, error } = await this.client.GET(
'/data-assets/received',
{
Expand All @@ -160,14 +160,14 @@ export class DataAsset {
/**
* This TypeScript function retrieves detailed information about a public data asset using an API
* call.
* @param {number} id - The `id` parameter in the `getDetail` function is a number that represents
* @param {number} id - The `id` parameter in the `get` function is a number that represents
* the unique identifier of the data asset you want to retrieve details for.
* @returns The `getDetail` function is returning a Promise that resolves to a `PublicDataAsset`
* @returns The `get` function is returning a Promise that resolves to a `PublicDataAsset`
* object. The function makes an asynchronous GET request to fetch details of a data asset with the
* specified `id`. If there is an error during the request, a `GTWError` is thrown with the error and
* response details. Otherwise, the function returns the fetched data.
*/
public async getDetail(id: number): Promise<PublicDataAsset> {
public async get(id: number): Promise<PublicDataAsset> {
const { data, error, response } = await this.client.GET(
'/data-assets/{id}',
{
Expand Down Expand Up @@ -308,7 +308,7 @@ export class DataAsset {
* representing the name of the file.
*/
public async download(id: number): Promise<{ file: Blob; fileName: string }> {
const { name } = await this.getDetail(id);
const { name } = await this.get(id);

const {
data: file,
Expand Down
32 changes: 16 additions & 16 deletions src/modules/data-model/data-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,24 @@ export class DataModel {
* @returns The `updateDataModel` function is returning the updated data model after making a PUT
* request to the server with the provided `dataModelInput` for the specified `dataModelId`.
*/
// async updateDataModel(
// dataModelId: number,
// dataModelInput: DataModelRequest,
// ): Promise<DataModelType> {
// const { data, error, response } = await this.client.PUT(
// '/data-models/{id}',
// {
// body: {},
// params: { path: { id: dataModelId } },
// },
// );
async updateDataModel(
dataModelId: number,
dataModelInput: DataModelRequest,
): Promise<DataModelType> {
const { data, error, response } = await this.client.PUT(
'/data-models/{id}',
{
body: dataModelInput,
params: { path: { id: dataModelId } },
},
);

// if (error) {
// throw new GTWError(error, response);
// }
if (error) {
throw new GTWError(error, response);
}

// return data;
// }
return data;
}

/**
* This TypeScript function asynchronously fetches a data model by its ID using a GET request.
Expand Down
4 changes: 2 additions & 2 deletions src/services/wallet-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export class WalletService {
walletType?: WalletTypeEnum | undefined;
}) {
this.walletPrivateKey = walletPrivateKey;
this.walletType = walletType ? walletType : WalletTypeEnum.Etherum;
this.walletType = walletType ? walletType : WalletTypeEnum.Ethereum;
this.wallet =
this.walletType === WalletTypeEnum.Etherum
this.walletType === WalletTypeEnum.Ethereum
? new EtherumService(this.walletPrivateKey)
: new SolanaService(this.walletPrivateKey);
}
Expand Down
Loading

0 comments on commit c14a613

Please sign in to comment.