diff --git a/.prettierignore b/.prettierignore index da9b44cc..29a6fff7 100644 --- a/.prettierignore +++ b/.prettierignore @@ -5,3 +5,7 @@ **/*.yml # Ignore rust build files services/account/rust-webhook-server/target +# Ignore generated content +services/*/apps/api/src/metadata.ts +**/swagger.json +services/*/docs/index.html diff --git a/docs/preprocessor.mjs b/docs/preprocessor.mjs index def2fd5f..c4a0ec62 100644 --- a/docs/preprocessor.mjs +++ b/docs/preprocessor.mjs @@ -51,7 +51,14 @@ function swaggerEmbed(chapter) { if (match) { const swaggerFile = match[1]; const output = runNpxCommand('openapi-to-md', [swaggerFile]); - const replaceWith = output.split('\n').slice(5).join('\n'); + const replaceWith = output + .split('\n') + // Remove the default header + .slice(5) + // This hack fixes the markdown issue that mdBook headers support classes which breaks + // with some params lines: https://rust-lang.github.io/mdBook/format/markdown.html#heading-attributes + .map((line) => (line.startsWith('#') ? line + '{}' : line)) + .join('\n'); chapter.content = chapter.content.replace(match[0], replaceWith); } if (chapter.sub_items) { diff --git a/services/account/apps/api/src/controllers/v1/accounts-v1.controller.ts b/services/account/apps/api/src/controllers/v1/accounts-v1.controller.ts index d8d4b95e..9babb265 100644 --- a/services/account/apps/api/src/controllers/v1/accounts-v1.controller.ts +++ b/services/account/apps/api/src/controllers/v1/accounts-v1.controller.ts @@ -1,8 +1,8 @@ import { AccountsService } from '#api/services/accounts.service'; -import { AccountResponse } from '#lib/types/dtos/accounts.response.dto'; +import { AccountResponseDto } from '#lib/types/dtos/accounts.response.dto'; import { WalletLoginRequestDto } from '#lib/types/dtos/wallet.login.request.dto'; -import { WalletLoginConfigResponse } from '#lib/types/dtos/wallet.login.config.response.dto'; -import { WalletLoginResponse } from '#lib/types/dtos/wallet.login.response.dto'; +import { WalletLoginConfigResponseDto } from '#lib/types/dtos/wallet.login.config.response.dto'; +import { WalletLoginResponseDto } from '#lib/types/dtos/wallet.login.response.dto'; import { Body, Controller, Get, Post, HttpCode, HttpStatus, Logger, Param, HttpException } from '@nestjs/common'; import { ApiBody, ApiOkResponse, ApiCreatedResponse, ApiOperation, ApiTags } from '@nestjs/swagger'; @@ -18,8 +18,8 @@ export class AccountsControllerV1 { @Get('siwf') @HttpCode(HttpStatus.OK) @ApiOperation({ summary: 'Get the Sign In With Frequency configuration' }) - @ApiOkResponse({ description: 'Returned SIWF Configuration data', type: WalletLoginConfigResponse }) - async getSIWFConfig(): Promise { + @ApiOkResponse({ description: 'Returned SIWF Configuration data', type: WalletLoginConfigResponseDto }) + async getSIWFConfig(): Promise { try { this.logger.debug('Received request for Sign In With Frequency Configuration'); return this.accountsService.getSIWFConfig(); @@ -33,14 +33,14 @@ export class AccountsControllerV1 { @Get(':msaId') @HttpCode(HttpStatus.OK) @ApiOperation({ summary: 'Fetch an account given an MSA Id' }) - @ApiOkResponse({ description: 'Found account', type: AccountResponse }) + @ApiOkResponse({ description: 'Found account', type: AccountResponseDto }) /** * Gets an account. * @param queryParams - The query parameters for creating the account. * @returns A promise that resolves to an Account object => {msaId, handle}. * @throws An error if the account cannot be found. */ - async getAccountForMsa(@Param('msaId') msaId: string): Promise { + async getAccountForMsa(@Param('msaId') msaId: string): Promise { try { this.logger.debug(`Received request to get account with msaId: ${msaId}`); const account = await this.accountsService.getAccount(msaId); @@ -56,14 +56,14 @@ export class AccountsControllerV1 { @Get('account/:publicKey') @HttpCode(HttpStatus.OK) @ApiOperation({ summary: 'Fetch an account given a public key' }) - @ApiOkResponse({ description: 'Found account', type: AccountResponse }) + @ApiOkResponse({ description: 'Found account', type: AccountResponseDto }) /** * Gets an account. * @param queryParams - The query parameters for creating the account. * @returns A promise that resolves to an Account object => {msaId, handle}. * @throws An error if the msaId or account cannot be found. */ - async getAccountForPublicKey(@Param('publicKey') publicKey: string): Promise { + async getAccountForPublicKey(@Param('publicKey') publicKey: string): Promise { try { this.logger.debug(`Received request to get account with publicKey: ${publicKey}`); const response = await this.accountsService.getMsaIdForPublicKey(publicKey); @@ -82,9 +82,9 @@ export class AccountsControllerV1 { @Post('siwf') @HttpCode(HttpStatus.CREATED) @ApiOperation({ summary: 'Request to Sign In With Frequency' }) - @ApiCreatedResponse({ description: 'Signed in successfully', type: WalletLoginResponse }) + @ApiCreatedResponse({ description: 'Signed in successfully', type: WalletLoginResponseDto }) @ApiBody({ type: WalletLoginRequestDto }) - async postSignInWithFrequency(@Body() walletLoginRequest: WalletLoginRequestDto): Promise { + async postSignInWithFrequency(@Body() walletLoginRequest: WalletLoginRequestDto): Promise { try { this.logger.debug(`Received Sign In With Frequency request: ${JSON.stringify(walletLoginRequest)}`); return this.accountsService.signInWithFrequency(walletLoginRequest); diff --git a/services/account/apps/api/src/controllers/v1/handles-v1.controller.ts b/services/account/apps/api/src/controllers/v1/handles-v1.controller.ts index cae90ed9..892f919f 100644 --- a/services/account/apps/api/src/controllers/v1/handles-v1.controller.ts +++ b/services/account/apps/api/src/controllers/v1/handles-v1.controller.ts @@ -3,9 +3,9 @@ import { ApiBody, ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger'; import { TransactionType } from '#lib/types/enums'; import { HandlesService } from '#api/services/handles.service'; import { EnqueueService } from '#lib/services/enqueue-request.service'; -import { ChangeHandleRequest, CreateHandleRequest, HandleRequest } from '#lib/types/dtos/handles.request.dto'; +import { ChangeHandleRequest, CreateHandleRequest, HandleRequestDto } from '#lib/types/dtos/handles.request.dto'; import { TransactionResponse } from '#lib/types/dtos/transaction.response.dto'; -import { HandleResponseDTO } from '#lib/types/dtos/accounts.response.dto'; +import { HandleResponseDto } from '#lib/types/dtos/accounts.response.dto'; @Controller('v1/handles') @ApiTags('v1/handles') @@ -23,14 +23,14 @@ export class HandlesControllerV1 { @HttpCode(HttpStatus.OK) @ApiOperation({ summary: 'Request to create a new handle for an account' }) @ApiOkResponse({ description: 'Handle creation request enqueued' }) - @ApiBody({ type: HandleRequest }) + @ApiBody({ type: HandleRequestDto }) /** * Creates a handle using the provided query parameters. * @param queryParams - The query parameters for creating the account. * @returns A message that the handle creation is in progress. * @throws An error if the handle creation fails. */ - async createHandle(@Body() createHandleRequest: HandleRequest): Promise { + async createHandle(@Body() createHandleRequest: HandleRequestDto): Promise { try { const response = await this.enqueueService.enqueueRequest({ ...createHandleRequest, @@ -48,14 +48,14 @@ export class HandlesControllerV1 { @HttpCode(HttpStatus.OK) @ApiOperation({ summary: 'Request to change a handle' }) @ApiOkResponse({ description: 'Handle change request enqueued' }) - @ApiBody({ type: HandleRequest }) + @ApiBody({ type: HandleRequestDto }) /** * Using the provided query parameters, removes the old handle and creates a new one. * @param queryParams - The query parameters for changing the handle. * @returns A message that the handle change is in progress. * @throws An error if the handle creation fails. */ - async changeHandle(@Body() changeHandleRequest: HandleRequest): Promise { + async changeHandle(@Body() changeHandleRequest: HandleRequestDto): Promise { try { const response = await this.enqueueService.enqueueRequest({ ...changeHandleRequest, @@ -79,7 +79,7 @@ export class HandlesControllerV1 { * @returns A promise that resolves to a Handle object, representing the found handle. * @throws An error if the handle cannot be found. */ - async getHandle(@Param('msaId') msaId: string): Promise { + async getHandle(@Param('msaId') msaId: string): Promise { try { const handle = await this.handlesService.getHandle(msaId); if (!handle) { diff --git a/services/account/apps/api/src/controllers/v1/keys-v1.controller.ts b/services/account/apps/api/src/controllers/v1/keys-v1.controller.ts index 1ff799d7..175a9be7 100644 --- a/services/account/apps/api/src/controllers/v1/keys-v1.controller.ts +++ b/services/account/apps/api/src/controllers/v1/keys-v1.controller.ts @@ -3,7 +3,7 @@ import { EnqueueService } from '#lib/services/enqueue-request.service'; import { TransactionType } from '#lib/types/enums'; import { Controller, Get, HttpCode, HttpStatus, Logger, Param, HttpException, Body, Post } from '@nestjs/common'; import { ApiBody, ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger'; -import { KeysRequest, AddKeyRequest } from '#lib/types/dtos/keys.request.dto'; +import { KeysRequestDto, AddKeyRequestDto } from '#lib/types/dtos/keys.request.dto'; import { TransactionResponse } from '#lib/types/dtos/transaction.response.dto'; import { KeysResponse } from '#lib/types/dtos/keys.response.dto'; @@ -23,16 +23,16 @@ export class KeysControllerV1 { @HttpCode(HttpStatus.OK) @ApiOperation({ summary: 'Add new control keys for an MSA Id' }) @ApiOkResponse({ description: 'Found public keys' }) - @ApiBody({ type: KeysRequest }) + @ApiBody({ type: KeysRequestDto }) /** * Add new control keys for an MSA Id. * @param queryParams - The query parameters for adding the public keys. * @returns A promise that resolves to an array of public keys associated with the given msaId. * @throws An error if no public keys can be found. */ - async addKey(@Body() addKeysRequest: KeysRequest): Promise { + async addKey(@Body() addKeysRequest: KeysRequestDto): Promise { try { - const response = await this.enqueueService.enqueueRequest({ + const response = await this.enqueueService.enqueueRequest({ ...addKeysRequest, type: TransactionType.ADD_KEY, }); diff --git a/services/account/apps/api/src/metadata.ts b/services/account/apps/api/src/metadata.ts index 66be09d0..083773fa 100644 --- a/services/account/apps/api/src/metadata.ts +++ b/services/account/apps/api/src/metadata.ts @@ -1,209 +1,14 @@ /* eslint-disable */ export default async () => { - const t = { - ['../../../libs/common/src/types/dtos/wallet.login.request.dto']: await import( - '../../../libs/common/src/types/dtos/wallet.login.request.dto' - ), - ['../../../libs/common/src/types/dtos/accounts.response.dto']: await import( - '../../../libs/common/src/types/dtos/accounts.response.dto' - ), - ['@polkadot/types-codec/primitive/U32']: await import('@polkadot/types-codec/primitive/U32'), - ['../../../libs/common/src/types/dtos/wallet.login.config.response.dto']: await import( - '../../../libs/common/src/types/dtos/wallet.login.config.response.dto' - ), - ['../../../libs/common/src/types/dtos/wallet.login.response.dto']: await import( - '../../../libs/common/src/types/dtos/wallet.login.response.dto' - ), - ['../../../libs/common/src/types/dtos/delegation.response.dto']: await import( - '../../../libs/common/src/types/dtos/delegation.response.dto' - ), - ['../../../libs/common/src/types/dtos/transaction.response.dto']: await import( - '../../../libs/common/src/types/dtos/transaction.response.dto' - ), - ['../../../libs/common/src/types/dtos/keys.response.dto']: await import( - '../../../libs/common/src/types/dtos/keys.response.dto' - ), - }; - return { - '@nestjs/swagger': { - models: [ - [ - import('../../../libs/common/src/types/dtos/keys.request.dto'), - { - KeysRequest: { - msaOwnerAddress: { required: true, type: () => String }, - msaOwnerSignature: { required: true, type: () => String }, - newKeyOwnerSignature: { required: true, type: () => String }, - }, - }, - ], - [ - import('../../../libs/common/src/types/dtos/handles.request.dto'), - { - HandleRequest: { - accountId: { required: true, type: () => String }, - proof: { required: true, type: () => String }, - }, - }, - ], - [ - import('../../../libs/common/src/types/dtos/wallet.login.request.dto'), - { - ErrorResponseDto: { message: { required: true, type: () => String } }, - SiwsPayloadDto: { - message: { required: true, type: () => String }, - signature: { required: true, type: () => String }, - }, - SignInResponseDto: { - siwsPayload: { - required: false, - type: () => t['../../../libs/common/src/types/dtos/wallet.login.request.dto'].SiwsPayloadDto, - }, - error: { - required: false, - type: () => t['../../../libs/common/src/types/dtos/wallet.login.request.dto'].ErrorResponseDto, - }, - }, - EncodedExtrinsicDto: { - pallet: { required: true, type: () => String }, - extrinsicName: { required: true, type: () => String }, - encodedExtrinsic: { required: true, type: () => String }, - }, - SignUpResponseDto: { - extrinsics: { - required: false, - type: () => [t['../../../libs/common/src/types/dtos/wallet.login.request.dto'].EncodedExtrinsicDto], - }, - error: { - required: false, - type: () => t['../../../libs/common/src/types/dtos/wallet.login.request.dto'].ErrorResponseDto, - }, - }, - WalletLoginRequestDto: { - signIn: { - required: true, - type: () => t['../../../libs/common/src/types/dtos/wallet.login.request.dto'].SignInResponseDto, - }, - signUp: { - required: true, - type: () => t['../../../libs/common/src/types/dtos/wallet.login.request.dto'].SignUpResponseDto, - }, - }, - }, - ], - [ - import('../../../libs/common/src/types/dtos/accounts.response.dto'), - { - HandleResponseDTO: { - base_handle: { required: true, type: () => String }, - canonical_base: { required: true, type: () => String }, - suffix: { required: true, type: () => Number }, - }, - AccountResponse: { - msaId: { required: true, type: () => String }, - handle: { - required: false, - type: () => t['../../../libs/common/src/types/dtos/accounts.response.dto'].HandleResponseDTO, - }, - }, - MsaIdResponse: { msaId: { required: true, type: () => String } }, - }, - ], - [ - import('../../../libs/common/src/types/dtos/delegation.response.dto'), - { - DelegationResponse: { - providerId: { required: true, type: () => String }, - schemaPermissions: { required: true }, - revokedAt: { required: true, type: () => t['@polkadot/types-codec/primitive/U32'].u32 }, - }, - }, - ], - [ - import('../../../libs/common/src/types/dtos/keys.response.dto'), - { KeysResponse: { msaKeys: { required: true } } }, - ], - [ - import('../../../libs/common/src/types/dtos/transaction.response.dto'), - { TransactionResponse: { referenceId: { required: true, type: () => String } } }, - ], - [ - import('../../../libs/common/src/types/dtos/wallet.login.config.response.dto'), - { - WalletLoginConfigResponse: { - providerId: { required: true, type: () => String }, - siwfUrl: { required: true, type: () => String }, - frequencyRpcUrl: { required: true, type: () => String }, - }, - }, - ], - [ - import('../../../libs/common/src/types/dtos/wallet.login.response.dto'), - { - WalletLoginResponse: { - referenceId: { required: true, type: () => String }, - msaId: { required: false, type: () => String }, - publicKey: { required: false, type: () => String }, - }, - }, - ], - ], - controllers: [ - [import('./controllers/health.controller'), { HealthController: { healthz: {}, livez: {}, readyz: {} } }], - [ - import('./controllers/v1/accounts-v1.controller'), - { - AccountsControllerV1: { - getSIWFConfig: { - type: t['../../../libs/common/src/types/dtos/wallet.login.config.response.dto'] - .WalletLoginConfigResponse, - }, - getAccountForMsa: { - type: t['../../../libs/common/src/types/dtos/accounts.response.dto'].AccountResponse, - }, - getAccountForPublicKey: { - type: t['../../../libs/common/src/types/dtos/accounts.response.dto'].AccountResponse, - }, - postSignInWithFrequency: { - type: t['../../../libs/common/src/types/dtos/wallet.login.response.dto'].WalletLoginResponse, - }, - }, - }, - ], - [ - import('./controllers/v1/delegation-v1.controller'), - { - DelegationControllerV1: { - getDelegation: { - type: t['../../../libs/common/src/types/dtos/delegation.response.dto'].DelegationResponse, - }, - }, - }, - ], - [ - import('./controllers/v1/handles-v1.controller'), - { - HandlesControllerV1: { - createHandle: { - type: t['../../../libs/common/src/types/dtos/transaction.response.dto'].TransactionResponse, - }, - changeHandle: { - type: t['../../../libs/common/src/types/dtos/transaction.response.dto'].TransactionResponse, - }, - getHandle: { type: t['../../../libs/common/src/types/dtos/accounts.response.dto'].HandleResponseDTO }, - }, - }, - ], - [ - import('./controllers/v1/keys-v1.controller'), - { - KeysControllerV1: { - addKey: { type: t['../../../libs/common/src/types/dtos/transaction.response.dto'].TransactionResponse }, - getKeys: { type: t['../../../libs/common/src/types/dtos/keys.response.dto'].KeysResponse }, - }, - }, - ], - ], - }, - }; -}; + const t = { + ["../../../libs/common/src/types/dtos/wallet.login.request.dto"]: await import("../../../libs/common/src/types/dtos/wallet.login.request.dto"), + ["../../../libs/common/src/types/dtos/accounts.response.dto"]: await import("../../../libs/common/src/types/dtos/accounts.response.dto"), + ["@polkadot/types-codec/primitive/U32"]: await import("@polkadot/types-codec/primitive/U32"), + ["../../../libs/common/src/types/dtos/wallet.login.config.response.dto"]: await import("../../../libs/common/src/types/dtos/wallet.login.config.response.dto"), + ["../../../libs/common/src/types/dtos/wallet.login.response.dto"]: await import("../../../libs/common/src/types/dtos/wallet.login.response.dto"), + ["../../../libs/common/src/types/dtos/delegation.response.dto"]: await import("../../../libs/common/src/types/dtos/delegation.response.dto"), + ["../../../libs/common/src/types/dtos/transaction.response.dto"]: await import("../../../libs/common/src/types/dtos/transaction.response.dto"), + ["../../../libs/common/src/types/dtos/keys.response.dto"]: await import("../../../libs/common/src/types/dtos/keys.response.dto") + }; + return { "@nestjs/swagger": { "models": [[import("../../../libs/common/src/types/dtos/keys.request.dto"), { "KeysRequestDto": { msaOwnerAddress: { required: true, type: () => String }, msaOwnerSignature: { required: true, type: () => String }, newKeyOwnerSignature: { required: true, type: () => String } } }], [import("../../../libs/common/src/types/dtos/handles.request.dto"), { "HandleRequestDto": { accountId: { required: true, type: () => String }, proof: { required: true, type: () => String } } }], [import("../../../libs/common/src/types/dtos/wallet.login.request.dto"), { "ErrorResponseDto": { message: { required: true, type: () => String } }, "SiwsPayloadDto": { message: { required: true, type: () => String }, signature: { required: true, type: () => String } }, "SignInResponseDto": { siwsPayload: { required: false, type: () => t["../../../libs/common/src/types/dtos/wallet.login.request.dto"].SiwsPayloadDto }, error: { required: false, type: () => t["../../../libs/common/src/types/dtos/wallet.login.request.dto"].ErrorResponseDto } }, "EncodedExtrinsicDto": { pallet: { required: true, type: () => String }, extrinsicName: { required: true, type: () => String }, encodedExtrinsic: { required: true, type: () => String } }, "SignUpResponseDto": { extrinsics: { required: false, type: () => [t["../../../libs/common/src/types/dtos/wallet.login.request.dto"].EncodedExtrinsicDto] }, error: { required: false, type: () => t["../../../libs/common/src/types/dtos/wallet.login.request.dto"].ErrorResponseDto } }, "WalletLoginRequestDto": { signIn: { required: true, type: () => t["../../../libs/common/src/types/dtos/wallet.login.request.dto"].SignInResponseDto }, signUp: { required: true, type: () => t["../../../libs/common/src/types/dtos/wallet.login.request.dto"].SignUpResponseDto } } }], [import("../../../libs/common/src/types/dtos/accounts.response.dto"), { "HandleResponseDto": { base_handle: { required: true, type: () => String }, canonical_base: { required: true, type: () => String }, suffix: { required: true, type: () => Number } }, "AccountResponseDto": { msaId: { required: true, type: () => String }, handle: { required: false, type: () => t["../../../libs/common/src/types/dtos/accounts.response.dto"].HandleResponseDto } }, "MsaIdResponse": { msaId: { required: true, type: () => String } } }], [import("../../../libs/common/src/types/dtos/delegation.response.dto"), { "DelegationResponse": { providerId: { required: true, type: () => String }, schemaPermissions: { required: true }, revokedAt: { required: true, type: () => t["@polkadot/types-codec/primitive/U32"].u32 } } }], [import("../../../libs/common/src/types/dtos/keys.response.dto"), { "KeysResponse": { msaKeys: { required: true } } }], [import("../../../libs/common/src/types/dtos/transaction.response.dto"), { "TransactionResponse": { referenceId: { required: true, type: () => String } } }], [import("../../../libs/common/src/types/dtos/wallet.login.config.response.dto"), { "WalletLoginConfigResponseDto": { providerId: { required: true, type: () => String }, siwfUrl: { required: true, type: () => String }, frequencyRpcUrl: { required: true, type: () => String } } }], [import("../../../libs/common/src/types/dtos/wallet.login.response.dto"), { "WalletLoginResponseDto": { referenceId: { required: true, type: () => String }, msaId: { required: false, type: () => String }, publicKey: { required: false, type: () => String } } }]], "controllers": [[import("./controllers/health.controller"), { "HealthController": { "healthz": {}, "livez": {}, "readyz": {} } }], [import("./controllers/v1/accounts-v1.controller"), { "AccountsControllerV1": { "getSIWFConfig": { type: t["../../../libs/common/src/types/dtos/wallet.login.config.response.dto"].WalletLoginConfigResponseDto }, "getAccountForMsa": { type: t["../../../libs/common/src/types/dtos/accounts.response.dto"].AccountResponseDto }, "getAccountForPublicKey": { type: t["../../../libs/common/src/types/dtos/accounts.response.dto"].AccountResponseDto }, "postSignInWithFrequency": { type: t["../../../libs/common/src/types/dtos/wallet.login.response.dto"].WalletLoginResponseDto } } }], [import("./controllers/v1/delegation-v1.controller"), { "DelegationControllerV1": { "getDelegation": { type: t["../../../libs/common/src/types/dtos/delegation.response.dto"].DelegationResponse } } }], [import("./controllers/v1/handles-v1.controller"), { "HandlesControllerV1": { "createHandle": { type: t["../../../libs/common/src/types/dtos/transaction.response.dto"].TransactionResponse }, "changeHandle": { type: t["../../../libs/common/src/types/dtos/transaction.response.dto"].TransactionResponse }, "getHandle": { type: t["../../../libs/common/src/types/dtos/accounts.response.dto"].HandleResponseDto } } }], [import("./controllers/v1/keys-v1.controller"), { "KeysControllerV1": { "addKey": { type: t["../../../libs/common/src/types/dtos/transaction.response.dto"].TransactionResponse }, "getKeys": { type: t["../../../libs/common/src/types/dtos/keys.response.dto"].KeysResponse } } }]] } }; +}; \ No newline at end of file diff --git a/services/account/apps/api/src/services/accounts.service.ts b/services/account/apps/api/src/services/accounts.service.ts index e1c0f9c3..e0e0d6b2 100644 --- a/services/account/apps/api/src/services/accounts.service.ts +++ b/services/account/apps/api/src/services/accounts.service.ts @@ -4,10 +4,10 @@ import { BlockchainService } from '#lib/blockchain/blockchain.service'; import { TransactionType } from '#lib/types/enums'; import { ConfigService } from '#lib/config/config.service'; import { EnqueueService } from '#lib/services/enqueue-request.service'; -import { WalletLoginRequestDto, PublishSIWFSignupRequest } from '#lib/types/dtos/wallet.login.request.dto'; -import { WalletLoginResponse } from '#lib/types/dtos/wallet.login.response.dto'; -import { AccountResponse, MsaIdResponse } from '#lib/types/dtos/accounts.response.dto'; -import { WalletLoginConfigResponse } from '#lib/types/dtos/wallet.login.config.response.dto'; +import { WalletLoginRequestDto, PublishSIWFSignupRequestDto } from '#lib/types/dtos/wallet.login.request.dto'; +import { WalletLoginResponseDto } from '#lib/types/dtos/wallet.login.response.dto'; +import { AccountResponseDto, MsaIdResponse } from '#lib/types/dtos/accounts.response.dto'; +import { WalletLoginConfigResponseDto } from '#lib/types/dtos/wallet.login.config.response.dto'; @Injectable() export class AccountsService { @@ -21,7 +21,7 @@ export class AccountsService { this.logger = new Logger(this.constructor.name); } - async getAccount(msaId: string): Promise { + async getAccount(msaId: string): Promise { try { const isValidMsaId = await this.blockchainService.isValidMsaId(msaId); if (isValidMsaId) { @@ -56,8 +56,8 @@ export class AccountsService { } } - async getSIWFConfig(): Promise { - let response: WalletLoginConfigResponse; + async getSIWFConfig(): Promise { + let response: WalletLoginConfigResponseDto; try { const { providerId, frequencyHttpUrl, siwfUrl } = this.configService; response = { @@ -73,17 +73,18 @@ export class AccountsService { } // eslint-disable-next-line class-methods-use-this - async signInWithFrequency(request: WalletLoginRequestDto): Promise { + async signInWithFrequency(request: WalletLoginRequestDto): Promise { const api = await this.blockchainService.getApi(); const { providerId } = this.configService; if (request.signUp) { try { const siwfPayload = await validateSignup(api, request.signUp, providerId.toString()); // Pass all this data to the transaction publisher queue - const referenceId: WalletLoginResponse = await this.enqueueService.enqueueRequest({ - ...siwfPayload, - type: TransactionType.SIWF_SIGNUP, - }); + const referenceId: WalletLoginResponseDto = + await this.enqueueService.enqueueRequest({ + ...siwfPayload, + type: TransactionType.SIWF_SIGNUP, + }); return referenceId; } catch (e: any) { this.logger.error(`Failed Signup validation ${e.toString()}`); @@ -92,7 +93,7 @@ export class AccountsService { } else if (request.signIn) { try { const parsedSignin = await validateSignin(api, request.signIn, 'localhost'); - const response: WalletLoginResponse = { + const response: WalletLoginResponseDto = { referenceId: '0', msaId: parsedSignin.msaId, publicKey: parsedSignin.publicKey, diff --git a/services/account/apps/api/src/services/handles.service.ts b/services/account/apps/api/src/services/handles.service.ts index f77398c3..6513ee2e 100644 --- a/services/account/apps/api/src/services/handles.service.ts +++ b/services/account/apps/api/src/services/handles.service.ts @@ -1,6 +1,6 @@ import { Injectable, Logger } from '@nestjs/common'; import { BlockchainService } from '#lib/blockchain/blockchain.service'; -import { HandleResponseDTO } from '#lib/types/dtos/accounts.response.dto'; +import { HandleResponseDto } from '#lib/types/dtos/accounts.response.dto'; @Injectable() export class HandlesService { @@ -10,7 +10,7 @@ export class HandlesService { this.logger = new Logger(this.constructor.name); } - async getHandle(msaId: string): Promise { + async getHandle(msaId: string): Promise { const isValidMsaId = await this.blockchainService.isValidMsaId(msaId); if (isValidMsaId) { return this.blockchainService.getHandleForMsa(msaId); diff --git a/services/account/apps/api/test/keys.controller.e2e-spec.ts b/services/account/apps/api/test/keys.controller.e2e-spec.ts index 08a797fd..24b838cb 100644 --- a/services/account/apps/api/test/keys.controller.e2e-spec.ts +++ b/services/account/apps/api/test/keys.controller.e2e-spec.ts @@ -6,7 +6,7 @@ import { INestApplication, ValidationPipe } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { EventEmitter2 } from '@nestjs/event-emitter'; import request from 'supertest'; -import { KeysRequest } from '#lib/types/dtos/keys.request.dto'; +import { KeysRequestDto } from '#lib/types/dtos/keys.request.dto'; import { AddKeyData, ChainUser, ExtrinsicHelper, createKeys } from '@projectlibertylabs/frequency-scenario-template'; import { KeyringPair } from '@polkadot/keyring/types'; import { ApiModule } from '../src/api.module'; @@ -81,7 +81,7 @@ describe('Keys Controller', () => { newKeypair, currentBlockNumber, ); - const keysRequest: KeysRequest = { + const keysRequest: KeysRequestDto = { msaOwnerAddress: user.keypair.address, msaOwnerSignature: ownerProof.Sr25519, newKeyOwnerSignature: newKeyProof.Sr25519, diff --git a/services/account/docs/endpoints.json b/services/account/docs/endpoints.json deleted file mode 100644 index 59c60d27..00000000 --- a/services/account/docs/endpoints.json +++ /dev/null @@ -1,728 +0,0 @@ -{ - "openapi": "3.0.0", - "servers": [ - { - "url": "http://0.0.0.0:3000/api" - } - ], - "info": { - "title": "DSNP Gateway Account Services Prototype API Documentation", - "version": "1.0.0" - }, - "paths": { - "/accounts/user": { - "post": { - "operationId": "createUserAccount", - "summary": "Creates a new DSNP Identity and delegations via sponsored account.", - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CreateUserAccountRequest" - } - } - } - }, - "responses": { - "200": { - "description": "Successful response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CreateAccountsResponse" - } - } - } - } - } - } - }, - "/accounts/provider": { - "post": { - "operationId": "createProviderAccount", - "summary": "Creates a new DSNP Identity and delegations via sponsored account.", - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CreateProviderAccountRequest" - } - } - } - }, - "responses": { - "200": { - "description": "Successful response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CreateAccountsResponse" - } - } - } - } - } - } - }, - "/accounts": { - "get": { - "operationId": "getAccounts", - "summary": "Get all accounts", - "security": [ - { - "tokenAuth": [] - } - ], - "responses": { - "401": { - "$ref": "#/components/responses/UnauthorizedError" - }, - "202": { - "description": "Account still pending creation" - }, - "200": { - "description": "Successful response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AuthAccountsResponse" - } - } - } - } - } - } - }, - "/accounts/{msaId}": { - "get": { - "operationId": "getAccount", - "summary": "Get account for current user.", - "security": [ - { - "tokenAuth": [] - } - ], - "responses": { - "401": { - "$ref": "#/components/responses/UnauthorizedError" - }, - "202": { - "description": "Account still pending creation" - }, - "200": { - "description": "Successful response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AuthAccountsResponse" - } - } - } - } - } - } - }, - "/handles": { - "post": { - "operationId": "createHandle", - "summary": "Create a handle.", - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "type": "object", - "items": { - "$ref": "#/components/schemas/HandlesRequest" - } - } - } - } - }, - "responses": { - "200": { - "description": "Successful response of accounts with handles", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/HandlesResponse" - } - } - } - } - } - } - }, - "get": { - "operationId": "getHandles", - "summary": "Get all control keys associated with an MSA Id.", - "responses": { - "401": { - "$ref": "#/components/responses/UnauthorizedError" - }, - "200": { - "description": "Successful response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HandlesResponse" - } - } - } - } - } - } - }, - "/delegation": { - "post": { - "operationId": "createDelegation", - "summary": "Delegate to the provider with an existing DSNP Identity", - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DelegateRequest" - } - } - } - }, - "responses": { - "401": { - "$ref": "#/components/responses/UnauthorizedError" - }, - "200": { - "description": "Successful response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DelegateResponse" - } - } - } - } - } - }, - "get": { - "operationId": "getDelegation", - "summary": "Return the delegation and provider information", - "responses": { - "200": { - "description": "Successful response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProviderResponse" - } - } - } - } - } - } - }, - "/keys/{msaId}": { - "post": { - "operationId": "createKeys", - "summary": "Create new control keys for an MSA Id.", - "parameters": [ - { - "name": "msaId", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "401": { - "$ref": "#/components/responses/UnauthorizedError" - }, - "200": { - "description": "Successful response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/KeysResponse" - } - } - } - } - } - }, - "get": { - "operationId": "getKeys", - "summary": "Get all control keys associated with an MSA Id.", - "parameters": [ - { - "name": "msaId", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "401": { - "$ref": "#/components/responses/UnauthorizedError" - }, - "200": { - "description": "Successful response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/KeysResponse" - } - } - } - } - } - } - }, - "/profiles": { - "get": { - "operationId": "getProfiles", - "summary": "Get all profiles", - "security": [ - { - "tokenAuth": [] - } - ], - "responses": { - "401": { - "$ref": "#/components/responses/UnauthorizedError" - }, - "200": { - "description": "Successful response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProfilesResponse" - } - } - } - } - } - } - }, - "/profiles/{msaId}": { - "post": { - "operationId": "createProfile", - "summary": "Creates a new profile from a DSNP Identity", - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CreateProfileRequest" - } - } - } - }, - "responses": { - "401": { - "$ref": "#/components/responses/UnauthorizedError" - }, - "200": { - "description": "Successful response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProfilesResponse" - } - } - } - } - } - }, - "get": { - "operationId": "getProfile", - "summary": "Get profile information for a specific user", - "security": [ - { - "tokenAuth": [] - } - ], - "parameters": [ - { - "name": "msaId", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "401": { - "$ref": "#/components/responses/UnauthorizedError" - }, - "200": { - "description": "Successful response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProfilesResponse" - } - } - } - } - } - }, - "put": { - "operationId": "createProfile", - "summary": "Create/Edit the profile information for a current user", - "security": [ - { - "tokenAuth": [] - } - ], - "parameters": [ - { - "name": "msaId", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/EditProfileRequest" - } - } - } - }, - "responses": { - "401": { - "$ref": "#/components/responses/UnauthorizedError" - }, - "200": { - "description": "Successful response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProfilesResponse" - } - } - } - } - } - } - } - }, - "components": { - "securitySchemes": { - "tokenAuth": { - "type": "http", - "scheme": "bearer", - "bearerFormat": "accessToken" - } - }, - "responses": { - "UnauthorizedError": { - "description": "Access token invalid or not found" - } - }, - "schemas": { - "CreateUserAccountRequest": { - "type": "object", - "properties": { - "addProviderSignature": { - "type": "string" - }, - "algo": { - "type": "string", - "enum": ["SR25519"] - }, - "baseHandle": { - "type": "string" - }, - "encoding": { - "type": "string", - "enum": ["hex"] - }, - "expiration": { - "type": "number" - }, - "handleSignature": { - "type": "string" - }, - "publicKey": { - "type": "string" - } - }, - "required": [ - "addProviderSignature", - "algo", - "baseHandle", - "encoding", - "expiration", - "handleSignature", - "publicKey" - ] - }, - "CreateProviderAccountRequest": { - "type": "object", - "properties": { - "algo": { - "type": "string", - "enum": ["SR25519"] - }, - "baseHandle": { - "type": "string" - }, - "encoding": { - "type": "string", - "enum": ["hex"] - }, - "expiration": { - "type": "number" - }, - "handleSignature": { - "type": "string" - }, - "publicKey": { - "type": "string" - } - }, - "required": ["algo", "encoding", "expiration", "publicKey"] - }, - "CreateAccountsResponse": { - "type": "object", - "properties": { - "accessToken": { - "type": "string" - }, - "expires": { - "type": "integer" - } - }, - "required": ["expires", "accessToken"] - }, - "CreateProfileResponse": { - "type": "object", - "properties": { - "accessToken": { - "type": "string" - }, - "expires": { - "type": "integer" - } - }, - "required": ["expires", "accessToken"] - }, - "AuthAccountResponse": { - "type": "object", - "properties": { - "msaId": { - "type": "string" - }, - "handle": { - "type": "string" - } - }, - "required": ["msaId"] - }, - "CreateDelegationRequest": { - "type": "object", - "properties": { - "pallet": { - "type": "string" - }, - "extrinsicName": { - "type": "string" - }, - "encodedExtrinsic": { - "type": "string" - } - }, - "required": ["pallet", "extrinsicName", "encodedExtrinsic"] - }, - "DelegateRequest": { - "type": "object", - "properties": { - "pallet": { - "type": "string" - }, - "extrinsicName": { - "type": "string" - }, - "encodedExtrinsic": { - "type": "string" - } - }, - "required": ["pallet", "extrinsicName", "encodedExtrinsic"] - }, - "DelegateResponse": { - "type": "object", - "properties": { - "pallet": { - "type": "string" - }, - "extrinsicName": { - "type": "string" - }, - "encodedExtrinsic": { - "type": "string" - } - }, - "required": ["pallet", "extrinsicName", "encodedExtrinsic"] - }, - "CreateDelegationResponse": { - "type": "object", - "properties": { - "accessToken": { - "type": "string" - }, - "expires": { - "type": "integer" - } - }, - "required": ["expires", "accessToken"] - }, - "DelegationResponse": { - "type": "object", - "properties": { - "nodeUrl": { - "type": "string" - }, - "ipfsGateway": { - "description": "IPFS Path Style Gateway base URI", - "type": "string" - }, - "providerId": { - "type": "string" - }, - "schemas": { - "type": "array", - "items": { - "type": "integer" - } - }, - "network": { - "type": "string", - "enum": ["local", "testnet", "mainnet"] - } - }, - "required": ["nodeUrl", "providerId", "schemas", "network"] - }, - "HandlesRequest": { - "type": "object", - "properties": { - "pallet": { - "type": "string" - }, - "extrinsicName": { - "type": "string" - }, - "encodedExtrinsic": { - "type": "string" - } - }, - "required": ["pallet", "extrinsicName", "encodedExtrinsic"] - }, - "HandlesResponse": { - "type": "object", - "properties": { - "publicKey": { - "type": "string" - }, - "handle": { - "type": "string" - } - }, - "required": ["publicKey", "handle"] - }, - "ProviderResponse": { - "type": "object", - "properties": { - "publicKey": { - "type": "string" - }, - "handle": { - "type": "string" - } - }, - "required": ["publicKey", "handle"] - }, - "KeysResponse": { - "type": "array", - "properties": { - "msaId": { - "type": "string" - }, - "keys": { - "type": "string" - } - }, - "required": ["msaId", "keys"], - "items": { - "type": "string" - } - }, - "CreateProfileRequest": { - "type": "object", - "properties": { - "content": { - "type": "string" - } - }, - "required": ["content"] - }, - "EditProfileRequest": { - "type": "object", - "properties": { - "content": { - "type": "string" - } - }, - "required": ["content"] - }, - "AuthAccountsResponse": { - "type": "object", - "properties": { - "content": { - "type": "string" - } - }, - "required": ["content"] - }, - "ProfilesResponse": { - "type": "array", - "properties": { - "fromId": { - "type": "string" - }, - "contentHash": { - "type": "string" - }, - "content": { - "description": "JSON-encoded Activity Content Note", - "type": "string" - }, - "timestamp": { - "type": "string", - "description": "Timestamp of the post" - }, - "displayHandle": { - "type": "string" - } - }, - "required": ["fromId", "contentHash", "content", "timestamp"], - "items": { - "type": "string" - } - } - } - } -} diff --git a/services/account/docs/endpoints.md b/services/account/docs/endpoints.md deleted file mode 100644 index f24d38a1..00000000 --- a/services/account/docs/endpoints.md +++ /dev/null @@ -1,318 +0,0 @@ - - -# DSNP Gateway Account Services Prototype API Documentation - -## Overview - -The DSNP Gateway Account Services Prototype API is designed for managing DSNP identities, accounts, profiles, and delegations. - -- **Base URL**: -- **Version**: `1.0.0` - -## Endpoints - -### 1. Create User Account - -- **Endpoint**: `/accounts/user` -- **Method**: `POST` -- **Summary**: Create a new User Account with handles and delegations. - -#### Request Body - -- **Schema**: [CreateUserAccountRequest](#createuseraccountrequest) - -#### Response - -- **Status Code**: `200 OK` -- **Schema**: [CreateAccountsResponse](#createAccountsResponse) - -### 2. Create Provider Account - -- **Endpoint**: `/accounts/provider` -- **Method**: `POST` -- **Summary**: Create a new Provider Account with delegations. - -#### Request Body - -- **Schema**: [CreateProviderAccountRequest](#createprovideraccountrequest) - -#### Response - -- **Status Code**: `200 OK` -- **Schema**: [CreateAccountsResponse](#createAccountsResponse) - -### 3. Get Accounts - -- **Endpoint**: `/accounts` -- **Method**: `GET` -- **Summary**: Get all accounts -- **Security**: Token-based authentication - -#### Responses - -- **Status Code**: `401 Unauthorized` -- **Schema**: UnauthorizedError - -- **Status Code**: `202 Accepted` -- **Description**: Account still pending creation - -- **Status Code**: `200 OK` -- **Schema**: [AccountsResponse](#AccountsResponse) - -### 4. Get Account - -- **Endpoint**: `/accounts/{msaId}` -- **Method**: `GET` -- **Summary**: Get account for current MSA Id -- **Security**: Token-based authentication - -#### Parameters - -| Name | In | Description | Required | Type | -| ----- | ---- | -------------------------- | -------- | ------ | -| msaId | path | MSA Id of the current user | Yes | string | - -#### Responses - -- **Status Code**: `401 Unauthorized` -- **Schema**: UnauthorizedError - -- **Status Code**: `202 Accepted` -- **Description**: Account still pending creation - -- **Status Code**: `200 OK` -- **Schema**: [AccountResponse](#AccountResponse) - -### 5. Create Handle - -- **Endpoint**: `/handles` -- **Method**: `POST` -- **Summary**: Create a handle. - -#### Request Body - -- **Schema**: [HandlesRequest](#handlesrequest) - -#### Response - -- **Status Code**: `200 OK` -- **Description**: Successful response of account. -- **Schema**: [HandlesResponse](#handlesresponse) - -### 6. Change Handle - -- **Endpoint**: `/handles/change` -- **Method**: `POST` -- **Summary**: Remove a handle then add the new one. - -#### Request Body - -- **Schema**: [HandlesRequest](#handlesrequest) - -### 7. Remove Handle - -- **Endpoint**: `/handles/remove` -- **Method**: `POST` -- **Summary**: Remove a handle. - -#### Request Body - -- **Schema**: [HandlesRequest](#handlesrequest) - -#### Response - -- **Status Code**: `200 OK` -- **Description**: Successful response of account. -- **Schema**: [HandlesResponse](#handlesresponse) - -### 8. Get Handles - -- **Endpoint**: `/handles` -- **Method**: `GET` -- **Summary**: Get the handle associated with an MSA Id. -- **Security**: Token-based authentication - -#### Responses - -- **Status Code**: `401 Unauthorized` -- **Schema**: UnauthorizedError - -- **Status Code**: `200 OK` -- **Schema**: [HandlesResponse](#handlesresponse) - -### 9. Create Delegation - -- **Endpoint**: `/delegation` -- **Method**: `POST` -- **Summary**: Delegate to the provider with an existing DSNP Identity - -#### Request Body - -- **Schema**: [CreateDelegationRequest](#createdelegationrequest) - -#### Response - -- **Status Code**: `401 Unauthorized` -- **Schema**: UnauthorizedError - -- **Status Code**: `200 OK` -- **Schema**: [CreateDelegationResponse](#createdelegationresponse) - -### 10. Get Delegation - -- **Endpoint**: `/delegation` -- **Method**: `GET` -- **Summary**: Return the delegation and provider information - -#### Responses - -- **Status Code**: `200 OK` -- **Schema**: [DelegationResponse](#delegationresponse) - -### 11. Create Keys - -- **Endpoint**: `/keys/:msaId` -- **Method**: `POST` -- **Summary**: Create new control keys for an MSA Id. - -#### Parameters - -| Name | In | Description | Required | Type | -| ----- | ---- | --------------------------- | -------- | ------ | -| msaId | path | DSNP ID of the current user | Yes | string | - -#### Responses - -- **Status Code**: `401 Unauthorized` -- **Schema**: UnauthorizedError - -- **Status Code**: `200 OK` -- **Schema**: [KeysResponse](#keysresponse) - -### 12. Get Keys - -- **Endpoint**: `/keys/:msaId` -- **Method**: `GET` -- **Summary**: Get all control keys associated with an MSA Id. - -#### Parameters - -| Name | In | Description | Required | Type | -| ----- | ---- | --------------------------- | -------- | ------ | -| msaId | path | DSNP ID of the current user | Yes | string | - -#### Responses - -- **Status Code**: `401 Unauthorized` -- **Schema**: UnauthorizedError - -- **Status Code**: `200 OK` -- **Schema**: [KeysResponse](#keysresponse) - -### 13. Get Profiles - -- **Endpoint**: `/profiles` -- **Method**: `GET` -- **Summary**: Get all profiles -- **Security**: Token-based authentication - -#### Responses - -- **Status Code**: `401 Unauthorized` -- **Schema**: UnauthorizedError - -- **Status Code**: `200 OK` -- **Schema**: [ProfilesResponse](#profilesresponse) - -### 14. Create Profile - -- **Endpoint**: `/profiles/:msaId` -- **Method**: `POST` -- **Summary**: Creates a new profile from a DSNP Identity - -#### Parameters - -| Name | In | Description | Required | Type | -| ----- | ---- | --------------------------- | -------- | ------ | -| msaId | path | DSNP ID of the current user | Yes | string | - -#### Request Body - -- **Schema**: [CreateProfileRequest](#createprofilerequest) - -#### Response - -- **Status Code**: `401 Unauthorized` -- **Schema**: UnauthorizedError - -- **Status Code**: `200 OK` -- **Schema**: [ProfilesResponse](#profilesresponse) - -### 15. Get Profile - -- **Endpoint**: `/profiles/:msaId` -- **Method**: `GET` -- **Summary**: Get profile information for a specific user -- **Security**: Token-based authentication - -#### Parameters - -| Name | In | Description | Required | Type | -| ----- | ---- | --------------------------- | -------- | ------ | -| msaId | path | DSNP ID of the current user | Yes | string | - -#### Responses - -- **Status Code**: `401 Unauthorized` -- **Schema**: UnauthorizedError - -- **Status Code**: `200 OK` -- **Schema**: [ProfilesResponse](#profilesresponse) - -### 16. Create/Edit Profile - -- **Endpoint**: `/profiles/:msaId` -- **Method**: `PUT` -- **Summary**: Create/Edit the profile information for a current user -- **Security**: Token-based authentication - -#### Parameters - -| Name | In | Description | Required | Type | -| ----- | ---- | --------------------------- | -------- | ------ | -| msaId | path | DSNP ID of the current user | Yes | string | - -#### Request Body - -- **Schema**: [EditProfileRequest](#editprofilerequest) - -#### Response - -- **Status Code**: `401 Unauthorized` -- **Schema**: UnauthorizedError - -- **Status Code**: `200 OK` -- **Schema**: [ProfilesResponse](#profilesResponse) - -## Components - -| Component | Type | Description | Properties | Required Properties | -| --------------- | ------------------------ | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- | -| Security Scheme | | | | | -| | http | | scheme: bearer
bearerFormat: accessToken | | -| Responses | | | | | -| | | Unauthorized Error | description: Access token invalid or not found | | -| Schemas | | | | | -| | CreateAccountRequest | Object | addProviderSignature: string
algo: enum (SR25519)
baseHandle: string
encoding: enum (hex)
expiration: number
handleSignature: string
publicKey: string | addProviderSignature, algo, baseHandle, encoding, expiration, handleSignature, publicKey | -| | CreateAccountResponse | Object | accessToken: string
expires: integer | expires, accessToken | -| | AccountsResponse | Array | msaId: string
handle: string | msaId | -| | AccountResponse | Object | msaId: string
handle: string | msaId | -| | CreateDelegationRequest | Object | pallet: string
extrinsicName: string
encodedExtrinsic: hexstring | pallet, extrinsicName, encodedExtrinsic | -| | CreateDelegationResponse | Object | accessToken: string
expires: integer | expires, accessToken | -| | DelegationResponse | Object | nodeUrl: string
ipfsGateway: string
providerId: string
schemas: array of integers
network: enum (local, testnet, mainnet) | nodeUrl, providerId, schemas, network | -| | HandlesRequest | Object | pallet: string
extrinsicName: string
encodedExtrinsic: hexstring | pallet, extrinsicName, encodedExtrinsic | -| | HandlesResponse | Array | msaId: string
handle: string | msaId, handle | -| | KeysResponse | Array | msaId: string
keys: KeyringPair | msaId, keys | -| | CreateProfileRequest | Object | content: string | content | -| | EditProfileRequest | Object | content: string | content | -| | ProfilesResponse | Array | fromId: string
contentHash: string
content: string (JSON-encoded Activity Content Note)
timestamp: string (Timestamp of the post)
displayHandle: string | fromId, contentHash, content, timestamp | diff --git a/services/account/docs/index.html b/services/account/docs/index.html index f859efa3..37683a02 100644 --- a/services/account/docs/index.html +++ b/services/account/docs/index.html @@ -1,1930 +1,345 @@ - + - - - Account Service - - - - - - - - -
-
- -
-
- - - + Account Service + + + + + + + + + +
- - - - - -
-
-
-
-
-
-

- Account Service - (1.0) -

-

- Download OpenAPI specification:Download -

-
-
-
- - -
-
-
-
-
-

Account Service API

-
-
-
-
-
-
-
-

- v1/accounts -

-
-
-
-
-
-
-

- Get the Sign In With Frequency configuration -

-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Response samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "providerId": - "string", -
    -
  • -
  • -
    - "siwfUrl": - "string", -
    -
  • -
  • -
    - "frequencyRpcUrl": - "string" -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- Request to Sign In With Frequency -

-
- Request Body schema: application/json -
required
-
-
- - - - - - - - - - - -
- - -
-
- object -
-
-
-

The wallet login request information

-
-
-
-
- - -
-
- object (SignUpResponseDto) -
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Request samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "signIn": - { -
      -
    • - -
    • -
    • - -
    • -
    - }, -
    -
  • -
  • -
    - "signUp": - { -
      -
    • - -
    • -
    • - -
    • -
    - } -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-

Response samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "referenceId": - "string", -
    -
  • -
  • -
    - "msaId": - "string", -
    -
  • -
  • -
    - "publicKey": - "string" -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- Fetch an account given an MSA Id -

-
-
- path - Parameters -
- - - - - - - -
- msaId -
required
-
-
-
- string -
-
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Response samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "msaId": - "string", -
    -
  • -
  • -
    - "handle": - { -
      -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    - } -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- Fetch an account given a public key -

-
-
- path - Parameters -
- - - - - - - -
- publicKey -
required
-
-
-
- string -
-
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Response samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "msaId": - "string", -
    -
  • -
  • -
    - "handle": - { -
      -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    - } -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- v1/delegation -

-
-
-
-
-
-
-

- Get the delegation information associated with an MSA Id -

-
-
- path - Parameters -
- - - - - - - -
- msaId -
required
-
-
-
- string -
-
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- v1/handles -

-
-
-
-
-
-
-

- Request to create a new handle for an account -

-
- Request Body schema: application/json -
required
-
-
- - - - - - - - - - - - - - - -
- accountId -
required
-
-
-
- string -
-
-
-
- -
required
-
-
-
- object (HandlePayload) -
-
-
-
- proof -
required
-
-
-
- string -
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Request samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "accountId": - "string", -
    -
  • -
  • -
    - "payload": - { -
      -
    • - -
    • -
    • - -
    • -
    - }, -
    -
  • -
  • -
    - "proof": - "string" -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- Request to change a handle -

-
- Request Body schema: application/json -
required
-
-
- - - - - - - - - - - - - - - -
- accountId -
required
-
-
-
- string -
-
-
-
- -
required
-
-
-
- object (HandlePayload) -
-
-
-
- proof -
required
-
-
-
- string -
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Request samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "accountId": - "string", -
    -
  • -
  • -
    - "payload": - { -
      -
    • - -
    • -
    • - -
    • -
    - }, -
    -
  • -
  • -
    - "proof": - "string" -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- Fetch a handle given an MSA Id -

-
-
- path - Parameters -
- - - - - - - -
- msaId -
required
-
-
-
- string -
-
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- v1/keys -

-
-
-
-
-
-
-

- Add new control keys for an MSA Id -

-
- Request Body schema: application/json -
required
-
-
- - - - - - - - - - - - - - - - - - - -
- msaOwnerAddress -
required
-
-
-
- string -
-
-
-
- msaOwnerSignature -
required
-
-
-
- string -
-
-
-
- newKeyOwnerSignature -
required
-
-
-
- string -
-
-
-
- -
required
-
-
-
- object - (KeysRequestPayload) - -
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Request samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "msaOwnerAddress": - "string", -
    -
  • -
  • -
    - "msaOwnerSignature": - "string", -
    -
  • -
  • -
    - "newKeyOwnerSignature": - "string", -
    -
  • -
  • -
    - "payload": - { -
      -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    - } -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- Fetch public keys given an MSA Id -

-
-
- path - Parameters -
- - - - - - - -
- msaId -
required
-
-
-
- string -
-
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- health -

-
-
-
-
-
-
-

- Check the health status of the service -

-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- Check the live status of the service -

-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- Check the ready status of the service -

-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-
- - + + + + diff --git a/services/account/libs/common/src/blockchain/blockchain.service.ts b/services/account/libs/common/src/blockchain/blockchain.service.ts index 0f170547..7a7b6530 100644 --- a/services/account/libs/common/src/blockchain/blockchain.service.ts +++ b/services/account/libs/common/src/blockchain/blockchain.service.ts @@ -20,10 +20,10 @@ import { ConfigService } from '#lib/config/config.service'; import { TransactionType } from '#lib/types/enums'; import { HexString } from '@polkadot/util/types'; import { decodeAddress } from '@polkadot/util-crypto'; -import { KeysRequest } from '#lib/types/dtos/keys.request.dto'; -import { PublishHandleRequest } from '#lib/types/dtos/handles.request.dto'; +import { KeysRequestDto } from '#lib/types/dtos/keys.request.dto'; +import { PublishHandleRequestDto } from '#lib/types/dtos/handles.request.dto'; import { TransactionData } from '#lib/types/dtos/transaction.request.dto'; -import { HandleResponseDTO } from '#lib/types/dtos/accounts.response.dto'; +import { HandleResponseDto } from '#lib/types/dtos/accounts.response.dto'; import { Extrinsic } from './extrinsic'; export type Sr25519Signature = { Sr25519: HexString }; @@ -223,7 +223,7 @@ export class BlockchainService implements OnApplicationBootstrap, OnApplicationS throw new Error(`No keys found for msaId: ${msaId}`); } - public async addPublicKeyToMsa(keysRequest: KeysRequest): Promise> { + public async addPublicKeyToMsa(keysRequest: KeysRequestDto): Promise> { const { msaOwnerAddress, msaOwnerSignature, newKeyOwnerSignature, payload } = keysRequest; const msaIdU64 = this.api.createType('u64', payload.msaId); @@ -242,7 +242,7 @@ export class BlockchainService implements OnApplicationBootstrap, OnApplicationS return addKeyResponse; } - public async publishHandle(jobData: TransactionData) { + public async publishHandle(jobData: TransactionData) { const handleVec = new Bytes(this.api.registry, jobData.payload.baseHandle); const claimHandlePayload: CommonPrimitivesHandlesClaimHandlePayload = this.api.registry.createType( 'CommonPrimitivesHandlesClaimHandlePayload', @@ -268,7 +268,7 @@ export class BlockchainService implements OnApplicationBootstrap, OnApplicationS } } - public async getHandleForMsa(msaId: AnyNumber): Promise { + public async getHandleForMsa(msaId: AnyNumber): Promise { const handleResponse: Option = await this.rpc('handles', 'getHandleForMsa', msaId.toString()); if (handleResponse.isSome) { const handle = handleResponse.unwrap(); diff --git a/services/account/libs/common/src/types/dtos/accounts.response.dto.ts b/services/account/libs/common/src/types/dtos/accounts.response.dto.ts index db5fcd2d..362e502b 100644 --- a/services/account/libs/common/src/types/dtos/accounts.response.dto.ts +++ b/services/account/libs/common/src/types/dtos/accounts.response.dto.ts @@ -2,7 +2,7 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { IsNotEmpty, IsOptional } from 'class-validator'; -export class HandleResponseDTO { +export class HandleResponseDto { @ApiProperty() base_handle: string; @@ -13,14 +13,14 @@ export class HandleResponseDTO { suffix: number; } -export class AccountResponse { +export class AccountResponseDto { @ApiProperty() @IsNotEmpty() msaId: string; @ApiPropertyOptional() @IsOptional() - handle?: HandleResponseDTO; + handle?: HandleResponseDto; } export class MsaIdResponse { diff --git a/services/account/libs/common/src/types/dtos/handles.request.dto.ts b/services/account/libs/common/src/types/dtos/handles.request.dto.ts index b01b8b85..3657d61f 100644 --- a/services/account/libs/common/src/types/dtos/handles.request.dto.ts +++ b/services/account/libs/common/src/types/dtos/handles.request.dto.ts @@ -4,7 +4,7 @@ import { ApiProperty } from '@nestjs/swagger'; import { HexString } from '@polkadot/util/types'; import { TransactionType } from '../enums'; -class HandlePayload { +class HandlePayloadDto { @ApiProperty() @IsNotEmpty() baseHandle: string; @@ -14,26 +14,26 @@ class HandlePayload { expiration: number; } -export class HandleRequest { +export class HandleRequestDto { @ApiProperty() @IsNotEmpty() accountId: string; @ApiProperty() @IsNotEmpty() - payload: HandlePayload; + payload: HandlePayloadDto; @ApiProperty({ type: String }) @IsNotEmpty() proof: HexString; } -export type CreateHandleRequest = HandleRequest & { +export type CreateHandleRequest = HandleRequestDto & { type: TransactionType.CREATE_HANDLE; }; -export type ChangeHandleRequest = HandleRequest & { +export type ChangeHandleRequest = HandleRequestDto & { type: TransactionType.CHANGE_HANDLE; }; -export type PublishHandleRequest = CreateHandleRequest | ChangeHandleRequest; +export type PublishHandleRequestDto = CreateHandleRequest | ChangeHandleRequest; diff --git a/services/account/libs/common/src/types/dtos/keys.request.dto.ts b/services/account/libs/common/src/types/dtos/keys.request.dto.ts index dacdaeae..9ade92c9 100644 --- a/services/account/libs/common/src/types/dtos/keys.request.dto.ts +++ b/services/account/libs/common/src/types/dtos/keys.request.dto.ts @@ -4,7 +4,7 @@ import { IsNotEmpty } from 'class-validator'; import { HexString } from '@polkadot/util/types'; import { TransactionType } from '../enums'; -class KeysRequestPayload { +class KeysRequestPayloadDto { @ApiProperty() @IsNotEmpty() msaId: string; @@ -18,7 +18,7 @@ class KeysRequestPayload { newPublicKey: string; } -export class KeysRequest { +export class KeysRequestDto { @ApiProperty() @IsNotEmpty() msaOwnerAddress: string; @@ -33,11 +33,11 @@ export class KeysRequest { @ApiProperty() @IsNotEmpty() - payload: KeysRequestPayload; + payload: KeysRequestPayloadDto; } -export type AddKeyRequest = KeysRequest & { +export type AddKeyRequestDto = KeysRequestDto & { type: TransactionType.ADD_KEY; }; -export type PublishKeysRequest = AddKeyRequest; +export type PublishKeysRequestDto = AddKeyRequestDto; diff --git a/services/account/libs/common/src/types/dtos/transaction.request.dto.ts b/services/account/libs/common/src/types/dtos/transaction.request.dto.ts index fb930caf..c6f0a737 100644 --- a/services/account/libs/common/src/types/dtos/transaction.request.dto.ts +++ b/services/account/libs/common/src/types/dtos/transaction.request.dto.ts @@ -1,14 +1,15 @@ import { BlockHash } from '@polkadot/types/interfaces'; import { HexString } from '@polkadot/util/types'; -import { PublishHandleRequest } from './handles.request.dto'; -import { PublishSIWFSignupRequest } from './wallet.login.request.dto'; -import { PublishKeysRequest } from './keys.request.dto'; +import { PublishHandleRequestDto } from './handles.request.dto'; +import { PublishSIWFSignupRequestDto } from './wallet.login.request.dto'; +import { PublishKeysRequestDto } from './keys.request.dto'; -export type TransactionData = - RequestType & { - providerId: string; - referenceId: string; - }; +export type TransactionData< + RequestType = PublishHandleRequestDto | PublishSIWFSignupRequestDto | PublishKeysRequestDto, +> = RequestType & { + providerId: string; + referenceId: string; +}; export type TxMonitorJob = TransactionData & { id: string; @@ -29,12 +30,12 @@ export type PublishKeysOpts = { newPublicKey: string }; export type TxWebhookOpts = PublishHandleOpts | SIWFOpts | PublishKeysOpts; export interface PublishHandleWebhookRsp extends TxWebhookRspBase, PublishHandleOpts { - transactionType: PublishHandleRequest['type']; + transactionType: PublishHandleRequestDto['type']; } export interface SIWFWebhookRsp extends TxWebhookRspBase, SIWFOpts { - transactionType: PublishSIWFSignupRequest['type']; + transactionType: PublishSIWFSignupRequestDto['type']; } export interface PublishKeysWebhookRsp extends TxWebhookRspBase, PublishKeysOpts { - transactionType: PublishKeysRequest['type']; + transactionType: PublishKeysRequestDto['type']; } export type TxWebhookRsp = PublishHandleWebhookRsp | SIWFWebhookRsp | PublishKeysWebhookRsp; diff --git a/services/account/libs/common/src/types/dtos/wallet.login.config.response.dto.ts b/services/account/libs/common/src/types/dtos/wallet.login.config.response.dto.ts index 03bc4061..719f811a 100644 --- a/services/account/libs/common/src/types/dtos/wallet.login.config.response.dto.ts +++ b/services/account/libs/common/src/types/dtos/wallet.login.config.response.dto.ts @@ -1,7 +1,7 @@ import { ApiProperty } from '@nestjs/swagger'; import { IsNotEmpty } from 'class-validator'; -export class WalletLoginConfigResponse { +export class WalletLoginConfigResponseDto { @ApiProperty() @IsNotEmpty() providerId: string; diff --git a/services/account/libs/common/src/types/dtos/wallet.login.request.dto.ts b/services/account/libs/common/src/types/dtos/wallet.login.request.dto.ts index 3a1af3ba..52119b17 100644 --- a/services/account/libs/common/src/types/dtos/wallet.login.request.dto.ts +++ b/services/account/libs/common/src/types/dtos/wallet.login.request.dto.ts @@ -76,6 +76,6 @@ export class WalletLoginRequestDto implements WalletProxyResponse { signUp: SignUpResponseDto; } -export type PublishSIWFSignupRequest = ValidSignUpPayloads & { +export type PublishSIWFSignupRequestDto = ValidSignUpPayloads & { type: TransactionType.SIWF_SIGNUP; }; diff --git a/services/account/libs/common/src/types/dtos/wallet.login.response.dto.ts b/services/account/libs/common/src/types/dtos/wallet.login.response.dto.ts index 92cfcbe1..f03f99d4 100644 --- a/services/account/libs/common/src/types/dtos/wallet.login.response.dto.ts +++ b/services/account/libs/common/src/types/dtos/wallet.login.response.dto.ts @@ -1,7 +1,7 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { IsNotEmpty, IsOptional } from 'class-validator'; -export class WalletLoginResponse { +export class WalletLoginResponseDto { @ApiProperty() @IsNotEmpty() referenceId: string; diff --git a/services/account/swagger.json b/services/account/swagger.json index e4bd16f4..5737a47f 100644 --- a/services/account/swagger.json +++ b/services/account/swagger.json @@ -12,13 +12,15 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/WalletLoginConfigResponse" + "$ref": "#/components/schemas/WalletLoginConfigResponseDto" } } } } }, - "tags": ["v1/accounts"] + "tags": [ + "v1/accounts" + ] }, "post": { "operationId": "AccountsControllerV1_postSignInWithFrequency", @@ -40,13 +42,15 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/WalletLoginResponse" + "$ref": "#/components/schemas/WalletLoginResponseDto" } } } } }, - "tags": ["v1/accounts"] + "tags": [ + "v1/accounts" + ] } }, "/v1/accounts/{msaId}": { @@ -69,13 +73,15 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/AccountResponse" + "$ref": "#/components/schemas/AccountResponseDto" } } } } }, - "tags": ["v1/accounts"] + "tags": [ + "v1/accounts" + ] } }, "/v1/accounts/account/{publicKey}": { @@ -98,13 +104,15 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/AccountResponse" + "$ref": "#/components/schemas/AccountResponseDto" } } } } }, - "tags": ["v1/accounts"] + "tags": [ + "v1/accounts" + ] } }, "/v1/delegation/{msaId}": { @@ -126,7 +134,9 @@ "description": "Found delegation information" } }, - "tags": ["v1/delegation"] + "tags": [ + "v1/delegation" + ] } }, "/v1/handles": { @@ -139,7 +149,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HandleRequest" + "$ref": "#/components/schemas/HandleRequestDto" } } } @@ -149,7 +159,9 @@ "description": "Handle creation request enqueued" } }, - "tags": ["v1/handles"] + "tags": [ + "v1/handles" + ] } }, "/v1/handles/change": { @@ -162,7 +174,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HandleRequest" + "$ref": "#/components/schemas/HandleRequestDto" } } } @@ -172,7 +184,9 @@ "description": "Handle change request enqueued" } }, - "tags": ["v1/handles"] + "tags": [ + "v1/handles" + ] } }, "/v1/handles/{msaId}": { @@ -194,7 +208,9 @@ "description": "Found a handle" } }, - "tags": ["v1/handles"] + "tags": [ + "v1/handles" + ] } }, "/v1/keys/add": { @@ -207,7 +223,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/KeysRequest" + "$ref": "#/components/schemas/KeysRequestDto" } } } @@ -217,7 +233,9 @@ "description": "Found public keys" } }, - "tags": ["v1/keys"] + "tags": [ + "v1/keys" + ] } }, "/v1/keys/{msaId}": { @@ -239,7 +257,9 @@ "description": "Found public keys" } }, - "tags": ["v1/keys"] + "tags": [ + "v1/keys" + ] } }, "/healthz": { @@ -252,7 +272,9 @@ "description": "Service is healthy" } }, - "tags": ["health"] + "tags": [ + "health" + ] } }, "/livez": { @@ -265,7 +287,9 @@ "description": "Service is live" } }, - "tags": ["health"] + "tags": [ + "health" + ] } }, "/readyz": { @@ -278,7 +302,9 @@ "description": "Service is ready" } }, - "tags": ["health"] + "tags": [ + "health" + ] } } }, @@ -292,7 +318,7 @@ "servers": [], "components": { "schemas": { - "WalletLoginConfigResponse": { + "WalletLoginConfigResponseDto": { "type": "object", "properties": { "providerId": { @@ -305,9 +331,13 @@ "type": "string" } }, - "required": ["providerId", "siwfUrl", "frequencyRpcUrl"] + "required": [ + "providerId", + "siwfUrl", + "frequencyRpcUrl" + ] }, - "HandleResponseDTO": { + "HandleResponseDto": { "type": "object", "properties": { "base_handle": { @@ -320,19 +350,25 @@ "type": "number" } }, - "required": ["base_handle", "canonical_base", "suffix"] + "required": [ + "base_handle", + "canonical_base", + "suffix" + ] }, - "AccountResponse": { + "AccountResponseDto": { "type": "object", "properties": { "msaId": { "type": "string" }, "handle": { - "$ref": "#/components/schemas/HandleResponseDTO" + "$ref": "#/components/schemas/HandleResponseDto" } }, - "required": ["msaId"] + "required": [ + "msaId" + ] }, "SiwsPayloadDto": { "type": "object", @@ -344,7 +380,10 @@ "type": "string" } }, - "required": ["message", "signature"] + "required": [ + "message", + "signature" + ] }, "ErrorResponseDto": { "type": "object", @@ -353,7 +392,9 @@ "type": "string" } }, - "required": ["message"] + "required": [ + "message" + ] }, "SignInResponseDto": { "type": "object", @@ -379,7 +420,11 @@ "type": "string" } }, - "required": ["pallet", "extrinsicName", "encodedExtrinsic"] + "required": [ + "pallet", + "extrinsicName", + "encodedExtrinsic" + ] }, "SignUpResponseDto": { "type": "object", @@ -420,7 +465,7 @@ } } }, - "WalletLoginResponse": { + "WalletLoginResponseDto": { "type": "object", "properties": { "referenceId": { @@ -433,9 +478,11 @@ "type": "string" } }, - "required": ["referenceId"] + "required": [ + "referenceId" + ] }, - "HandlePayload": { + "HandlePayloadDto": { "type": "object", "properties": { "baseHandle": { @@ -445,24 +492,31 @@ "type": "number" } }, - "required": ["baseHandle", "expiration"] + "required": [ + "baseHandle", + "expiration" + ] }, - "HandleRequest": { + "HandleRequestDto": { "type": "object", "properties": { "accountId": { "type": "string" }, "payload": { - "$ref": "#/components/schemas/HandlePayload" + "$ref": "#/components/schemas/HandlePayloadDto" }, "proof": { "type": "string" } }, - "required": ["accountId", "payload", "proof"] + "required": [ + "accountId", + "payload", + "proof" + ] }, - "KeysRequestPayload": { + "KeysRequestPayloadDto": { "type": "object", "properties": { "msaId": { @@ -475,9 +529,13 @@ "type": "string" } }, - "required": ["msaId", "expiration", "newPublicKey"] + "required": [ + "msaId", + "expiration", + "newPublicKey" + ] }, - "KeysRequest": { + "KeysRequestDto": { "type": "object", "properties": { "msaOwnerAddress": { @@ -490,11 +548,16 @@ "type": "string" }, "payload": { - "$ref": "#/components/schemas/KeysRequestPayload" + "$ref": "#/components/schemas/KeysRequestPayloadDto" } }, - "required": ["msaOwnerAddress", "msaOwnerSignature", "newKeyOwnerSignature", "payload"] + "required": [ + "msaOwnerAddress", + "msaOwnerSignature", + "newKeyOwnerSignature", + "payload" + ] } } } -} +} \ No newline at end of file diff --git a/services/content-publishing/apps/api/src/controllers/v1/development.controller.v1.ts b/services/content-publishing/apps/api/src/controllers/v1/development.controller.v1.ts index 6a377e41..7b625f69 100644 --- a/services/content-publishing/apps/api/src/controllers/v1/development.controller.v1.ts +++ b/services/content-publishing/apps/api/src/controllers/v1/development.controller.v1.ts @@ -67,7 +67,10 @@ export class DevelopmentControllerV1 { @Get('/asset/:assetId') @ApiOperation({ summary: 'Get an Asset given an assetId', description: 'ONLY enabled when ENVIRONMENT="dev".' }) - @ApiResponse({ status: '2XX', type: Buffer }) + @ApiResponse({ + status: '2XX', + content: { 'application/octet-stream': { schema: { type: 'string', format: 'binary' } } }, + }) // eslint-disable-next-line consistent-return async getAsset(@Param('assetId') assetId: string) { if (await this.ipfsService.isPinned(assetId)) { diff --git a/services/content-publishing/apps/api/src/metadata.ts b/services/content-publishing/apps/api/src/metadata.ts index 9bf2d7a6..1445894d 100644 --- a/services/content-publishing/apps/api/src/metadata.ts +++ b/services/content-publishing/apps/api/src/metadata.ts @@ -1,114 +1,8 @@ /* eslint-disable */ export default async () => { - const t = { - ['../../../libs/common/src/dtos/activity.dto']: await import('../../../libs/common/src/dtos/activity.dto'), - ['../../../libs/common/src/dtos/announcement.dto']: await import('../../../libs/common/src/dtos/announcement.dto'), - }; - return { - '@nestjs/swagger': { - models: [ - [ - import('../../../libs/common/src/dtos/common.dto'), - { - DsnpUserIdParam: { userDsnpId: { required: true, type: () => String } }, - AnnouncementResponseDto: { referenceId: { required: true, type: () => String } }, - UploadResponseDto: { assetIds: { required: true, type: () => [String] } }, - FilesUploadDto: { files: { required: true, type: () => [Object] } }, - }, - ], - [ - import('../../../libs/common/src/dtos/activity.dto'), - { - LocationDto: { - name: { required: true, type: () => String, minLength: 1 }, - accuracy: { required: false, type: () => Number, minimum: 0, maximum: 100 }, - altitude: { required: false, type: () => Number }, - latitude: { required: false, type: () => Number }, - longitude: { required: false, type: () => Number }, - radius: { required: false, type: () => Number, minimum: 0 }, - units: { required: false, enum: t['../../../libs/common/src/dtos/activity.dto'].UnitTypeDto }, - }, - AssetReferenceDto: { - referenceId: { required: true, type: () => String, minLength: 1 }, - height: { required: false, type: () => Number, minimum: 1 }, - width: { required: false, type: () => Number, minimum: 1 }, - duration: { required: false, type: () => String, pattern: 'DURATION_REGEX' }, - }, - TagDto: { - type: { required: true, enum: t['../../../libs/common/src/dtos/activity.dto'].TagTypeDto }, - name: { required: false, type: () => String, minLength: 1 }, - mentionedId: { required: false, type: () => String }, - }, - AssetDto: { - references: { - required: false, - type: () => [t['../../../libs/common/src/dtos/activity.dto'].AssetReferenceDto], - }, - name: { required: false, type: () => String, minLength: 1 }, - href: { required: false, type: () => String, minLength: 1 }, - }, - BaseActivityDto: { - name: { required: false, type: () => String }, - tag: { required: false, type: () => [t['../../../libs/common/src/dtos/activity.dto'].TagDto] }, - location: { required: false, type: () => t['../../../libs/common/src/dtos/activity.dto'].LocationDto }, - }, - NoteActivityDto: { - content: { required: true, type: () => String, minLength: 1 }, - published: { required: true, type: () => String }, - assets: { required: false, type: () => [t['../../../libs/common/src/dtos/activity.dto'].AssetDto] }, - }, - ProfileActivityDto: { - icon: { - required: false, - type: () => [t['../../../libs/common/src/dtos/activity.dto'].AssetReferenceDto], - }, - summary: { required: false, type: () => String }, - published: { required: false, type: () => String }, - }, - }, - ], - [ - import('../../../libs/common/src/dtos/announcement.dto'), - { - BroadcastDto: { - content: { required: true, type: () => t['../../../libs/common/src/dtos/activity.dto'].NoteActivityDto }, - }, - ReplyDto: { - inReplyTo: { required: true, type: () => String }, - content: { required: true, type: () => t['../../../libs/common/src/dtos/activity.dto'].NoteActivityDto }, - }, - TombstoneDto: { - targetContentHash: { required: true, type: () => String }, - targetAnnouncementType: { - required: true, - enum: t['../../../libs/common/src/dtos/announcement.dto'].ModifiableAnnouncementTypeDto, - }, - }, - UpdateDto: { - targetContentHash: { required: true, type: () => String }, - targetAnnouncementType: { - required: true, - enum: t['../../../libs/common/src/dtos/announcement.dto'].ModifiableAnnouncementTypeDto, - }, - content: { required: true, type: () => t['../../../libs/common/src/dtos/activity.dto'].NoteActivityDto }, - }, - ReactionDto: { - emoji: { required: true, type: () => String, minLength: 1, pattern: 'DSNP_EMOJI_REGEX' }, - apply: { required: true, type: () => Number, minimum: 0, maximum: 255 }, - inReplyTo: { required: true, type: () => String }, - }, - ProfileDto: { - profile: { - required: true, - type: () => t['../../../libs/common/src/dtos/activity.dto'].ProfileActivityDto, - }, - }, - }, - ], - ], - controllers: [ - [import('./controllers/health.controller'), { HealthController: { healthz: {}, livez: {}, readyz: {} } }], - ], - }, - }; -}; + const t = { + ["../../../libs/common/src/dtos/activity.dto"]: await import("../../../libs/common/src/dtos/activity.dto"), + ["../../../libs/common/src/dtos/announcement.dto"]: await import("../../../libs/common/src/dtos/announcement.dto") + }; + return { "@nestjs/swagger": { "models": [[import("../../../libs/common/src/dtos/common.dto"), { "DsnpUserIdParam": { userDsnpId: { required: true, type: () => String } }, "AnnouncementResponseDto": { referenceId: { required: true, type: () => String } }, "UploadResponseDto": { assetIds: { required: true, type: () => [String] } }, "FilesUploadDto": { files: { required: true, type: () => [Object] } } }], [import("../../../libs/common/src/dtos/activity.dto"), { "LocationDto": { name: { required: true, type: () => String, minLength: 1 }, accuracy: { required: false, type: () => Number, minimum: 0, maximum: 100 }, altitude: { required: false, type: () => Number }, latitude: { required: false, type: () => Number }, longitude: { required: false, type: () => Number }, radius: { required: false, type: () => Number, minimum: 0 }, units: { required: false, enum: t["../../../libs/common/src/dtos/activity.dto"].UnitTypeDto } }, "AssetReferenceDto": { referenceId: { required: true, type: () => String, minLength: 1 }, height: { required: false, type: () => Number, minimum: 1 }, width: { required: false, type: () => Number, minimum: 1 }, duration: { required: false, type: () => String, pattern: "DURATION_REGEX" } }, "TagDto": { type: { required: true, enum: t["../../../libs/common/src/dtos/activity.dto"].TagTypeDto }, name: { required: false, type: () => String, minLength: 1 }, mentionedId: { required: false, type: () => String } }, "AssetDto": { references: { required: false, type: () => [t["../../../libs/common/src/dtos/activity.dto"].AssetReferenceDto] }, name: { required: false, type: () => String, minLength: 1 }, href: { required: false, type: () => String, minLength: 1 } }, "BaseActivityDto": { name: { required: false, type: () => String }, tag: { required: false, type: () => [t["../../../libs/common/src/dtos/activity.dto"].TagDto] }, location: { required: false, type: () => t["../../../libs/common/src/dtos/activity.dto"].LocationDto } }, "NoteActivityDto": { content: { required: true, type: () => String, minLength: 1 }, published: { required: true, type: () => String }, assets: { required: false, type: () => [t["../../../libs/common/src/dtos/activity.dto"].AssetDto] } }, "ProfileActivityDto": { icon: { required: false, type: () => [t["../../../libs/common/src/dtos/activity.dto"].AssetReferenceDto] }, summary: { required: false, type: () => String }, published: { required: false, type: () => String } } }], [import("../../../libs/common/src/dtos/announcement.dto"), { "BroadcastDto": { content: { required: true, type: () => t["../../../libs/common/src/dtos/activity.dto"].NoteActivityDto } }, "ReplyDto": { inReplyTo: { required: true, type: () => String }, content: { required: true, type: () => t["../../../libs/common/src/dtos/activity.dto"].NoteActivityDto } }, "TombstoneDto": { targetContentHash: { required: true, type: () => String }, targetAnnouncementType: { required: true, enum: t["../../../libs/common/src/dtos/announcement.dto"].ModifiableAnnouncementTypeDto } }, "UpdateDto": { targetContentHash: { required: true, type: () => String }, targetAnnouncementType: { required: true, enum: t["../../../libs/common/src/dtos/announcement.dto"].ModifiableAnnouncementTypeDto }, content: { required: true, type: () => t["../../../libs/common/src/dtos/activity.dto"].NoteActivityDto } }, "ReactionDto": { emoji: { required: true, type: () => String, minLength: 1, pattern: "DSNP_EMOJI_REGEX" }, apply: { required: true, type: () => Number, minimum: 0, maximum: 255 }, inReplyTo: { required: true, type: () => String } }, "ProfileDto": { profile: { required: true, type: () => t["../../../libs/common/src/dtos/activity.dto"].ProfileActivityDto } } }]], "controllers": [[import("./controllers/health.controller"), { "HealthController": { "healthz": {}, "livez": {}, "readyz": {} } }]] } }; +}; \ No newline at end of file diff --git a/services/content-publishing/docs/index.html b/services/content-publishing/docs/index.html index 2e716541..b1bafebf 100644 --- a/services/content-publishing/docs/index.html +++ b/services/content-publishing/docs/index.html @@ -1,2002 +1,360 @@ - + - - - Content Publishing Service API - - - - - - - - -
-
- -
-
- - - + Content Publishing Service API + + + + + + + + + +
- - - - - -
-
-
-
-
-
-

- Content Publishing Service API - (1.0) -

-

- Download OpenAPI specification:Download -

-
-
-
- - -
-
-
-
-
-

Content Publishing Service API

-
-
-
-
-
-
-
-

- v1/asset -

-
-
-
-
-
-
-

- Upload asset files -

-
- Request Body schema: multipart/form-data -
required
-
-
-

Asset files

-
- - - - - - - -
- files -
required
-
-
-
- Array of strings - <binary> [ items - <binary - > - ] -
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Response samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "assetIds": - [ -
      -
    • - -
    • -
    - ] -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- v1/content -

-
-
-
-
-
-
-

- Create DSNP Broadcast for user -

-
-
- path - Parameters -
- - - - - - - -
- userDsnpId -
required
-
-
-
- string -
-
-
-
-
-
- Request Body schema: application/json -
required
-
-
- - - - - - - -
- -
required
-
-
-
- object (NoteActivityDto) -
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Request samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "content": - { -
      -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    - } -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-

Response samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "referenceId": - "string" -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- Create DSNP Reply for user -

-
-
- path - Parameters -
- - - - - - - -
- userDsnpId -
required
-
-
-
- string -
-
-
-
-
-
- Request Body schema: application/json -
required
-
-
- - - - - - - - - - - -
- inReplyTo -
required
-
-
-
- string -
-
-
-
- -
required
-
-
-
- object (NoteActivityDto) -
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Request samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "inReplyTo": - "string", -
    -
  • -
  • -
    - "content": - { -
      -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    - } -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-

Response samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "referenceId": - "string" -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- Create DSNP Reaction for user -

-
-
- path - Parameters -
- - - - - - - -
- userDsnpId -
required
-
-
-
- string -
-
-
-
-
-
- Request Body schema: application/json -
required
-
-
- - - - - - - - - - - - - - - -
- emoji -
required
-
-
-
- string - non-empty DSNP_EMOJI_REGEX -
-
-
-
- apply -
required
-
-
-
- number - [ 0 .. 255 ] -
-
-
-
- inReplyTo -
required
-
-
-
- string -
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Request samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "emoji": - "string", -
    -
  • -
  • -
    - "apply": - 255, -
    -
  • -
  • -
    - "inReplyTo": - "string" -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-

Response samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "referenceId": - "string" -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- Update DSNP Content for user -

-
-
- path - Parameters -
- - - - - - - -
- userDsnpId -
required
-
-
-
- string -
-
-
-
-
-
- Request Body schema: application/json -
required
-
-
- - - - - - - - - - - - - - - -
- targetContentHash -
required
-
-
-
- string -
-
-
-
- targetAnnouncementType -
required
-
-
-
- string -
-
- Enum: - "broadcast" - "reply" -
-
-
-
- -
required
-
-
-
- object (NoteActivityDto) -
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Request samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "targetContentHash": - "string", -
    -
  • -
  • -
    - "targetAnnouncementType": - "broadcast", -
    -
  • -
  • -
    - "content": - { -
      -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    - } -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-

Response samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "referenceId": - "string" -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- Delete DSNP Content for user -

-
-
- path - Parameters -
- - - - - - - -
- userDsnpId -
required
-
-
-
- string -
-
-
-
-
-
- Request Body schema: application/json -
required
-
-
- - - - - - - - - - - -
- targetContentHash -
required
-
-
-
- string -
-
-
-
- targetAnnouncementType -
required
-
-
-
- string -
-
- Enum: - "broadcast" - "reply" -
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Request samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "targetContentHash": - "string", -
    -
  • -
  • -
    - "targetAnnouncementType": - "broadcast" -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-

Response samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "referenceId": - "string" -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- v1/profile -

-
-
-
-
-
-
-

- Update a user's Profile -

-
-
- path - Parameters -
- - - - - - - -
- userDsnpId -
required
-
-
-
- string -
-
-
-
-
-
- Request Body schema: application/json -
required
-
-
- - - - - - - -
- -
required
-
-
-
- object - (ProfileActivityDto) - -
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Request samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "profile": - { -
      -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    - } -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-

Response samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "referenceId": - "string" -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- health -

-
-
-
-
-
-
-

- Check the health status of the service -

-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- Check the live status of the service -

-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- Check the ready status of the service -

-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- dev -

-
-
-
-
-
-
-

- Get a Job given a jobId -

-
-
-

ONLY enabled when ENVIRONMENT="dev".

-
-
-
-
- path - Parameters -
- - - - - - - -
- jobId -
required
-
-
-
- string -
-
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- Get an Asset given an assetId -

-
-
-

ONLY enabled when ENVIRONMENT="dev".

-
-
-
-
- path - Parameters -
- - - - - - - -
- assetId -
required
-
-
-
- string -
-
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Response samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { } -
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- Create dummy announcement data -

-
-
-

ONLY enabled when ENVIRONMENT="dev".

-
-
-
-
- path - Parameters -
- - - - - - - - - - - -
- queueType -
required
-
-
-
- string -
-
-
-
- count -
required
-
-
-
- number -
-
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-
- - + + + + diff --git a/services/content-publishing/swagger.json b/services/content-publishing/swagger.json index 832e886d..8ea4b703 100644 --- a/services/content-publishing/swagger.json +++ b/services/content-publishing/swagger.json @@ -29,7 +29,9 @@ } } }, - "tags": ["v1/asset"] + "tags": [ + "v1/asset" + ] } }, "/v1/content/{userDsnpId}/broadcast": { @@ -68,7 +70,9 @@ } } }, - "tags": ["v1/content"] + "tags": [ + "v1/content" + ] } }, "/v1/content/{userDsnpId}/reply": { @@ -107,7 +111,9 @@ } } }, - "tags": ["v1/content"] + "tags": [ + "v1/content" + ] } }, "/v1/content/{userDsnpId}/reaction": { @@ -146,7 +152,9 @@ } } }, - "tags": ["v1/content"] + "tags": [ + "v1/content" + ] } }, "/v1/content/{userDsnpId}": { @@ -185,7 +193,9 @@ } } }, - "tags": ["v1/content"] + "tags": [ + "v1/content" + ] }, "delete": { "operationId": "ContentControllerV1_delete", @@ -222,7 +232,9 @@ } } }, - "tags": ["v1/content"] + "tags": [ + "v1/content" + ] } }, "/v1/profile/{userDsnpId}": { @@ -261,7 +273,9 @@ } } }, - "tags": ["v1/profile"] + "tags": [ + "v1/profile" + ] } }, "/healthz": { @@ -274,7 +288,9 @@ "description": "Service is healthy" } }, - "tags": ["health"] + "tags": [ + "health" + ] } }, "/livez": { @@ -287,7 +303,9 @@ "description": "Service is live" } }, - "tags": ["health"] + "tags": [ + "health" + ] } }, "/readyz": { @@ -300,7 +318,100 @@ "description": "Service is ready" } }, - "tags": ["health"] + "tags": [ + "health" + ] + } + }, + "/dev/request/{jobId}": { + "get": { + "operationId": "DevelopmentControllerV1_requestJob", + "summary": "Get a Job given a jobId", + "description": "ONLY enabled when ENVIRONMENT=\"dev\".", + "parameters": [ + { + "name": "jobId", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "dev" + ] + } + }, + "/dev/asset/{assetId}": { + "get": { + "operationId": "DevelopmentControllerV1_getAsset", + "summary": "Get an Asset given an assetId", + "description": "ONLY enabled when ENVIRONMENT=\"dev\".", + "parameters": [ + { + "name": "assetId", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "responses": { + "2XX": { + "content": { + "application/octet-stream": { + "schema": { + "type": "string", + "format": "binary" + } + } + }, + "description": "" + } + }, + "tags": [ + "dev" + ] + } + }, + "/dev/dummy/announcement/{queueType}/{count}": { + "post": { + "operationId": "DevelopmentControllerV1_populate", + "summary": "Create dummy announcement data", + "description": "ONLY enabled when ENVIRONMENT=\"dev\".", + "parameters": [ + { + "name": "queueType", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + }, + { + "name": "count", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "responses": { + "201": { + "description": "" + } + }, + "tags": [ + "dev" + ] } } }, @@ -325,7 +436,9 @@ } } }, - "required": ["files"] + "required": [ + "files" + ] }, "UploadResponseDto": { "type": "object", @@ -337,7 +450,9 @@ } } }, - "required": ["assetIds"] + "required": [ + "assetIds" + ] }, "AssetReferenceDto": { "type": "object", @@ -359,7 +474,9 @@ "pattern": "DURATION_REGEX" } }, - "required": ["referenceId"] + "required": [ + "referenceId" + ] }, "AssetDto": { "type": "object", @@ -385,7 +502,10 @@ "properties": { "type": { "type": "string", - "enum": ["mention", "hashtag"] + "enum": [ + "mention", + "hashtag" + ] }, "name": { "type": "string", @@ -395,7 +515,9 @@ "type": "string" } }, - "required": ["type"] + "required": [ + "type" + ] }, "LocationDto": { "type": "object", @@ -424,10 +546,19 @@ }, "units": { "type": "string", - "enum": ["cm", "m", "km", "inches", "feet", "miles"] + "enum": [ + "cm", + "m", + "km", + "inches", + "feet", + "miles" + ] } }, - "required": ["name"] + "required": [ + "name" + ] }, "NoteActivityDto": { "type": "object", @@ -458,7 +589,10 @@ "$ref": "#/components/schemas/LocationDto" } }, - "required": ["content", "published"] + "required": [ + "content", + "published" + ] }, "BroadcastDto": { "type": "object", @@ -467,7 +601,9 @@ "$ref": "#/components/schemas/NoteActivityDto" } }, - "required": ["content"] + "required": [ + "content" + ] }, "AnnouncementResponseDto": { "type": "object", @@ -476,7 +612,9 @@ "type": "string" } }, - "required": ["referenceId"] + "required": [ + "referenceId" + ] }, "ReplyDto": { "type": "object", @@ -488,7 +626,10 @@ "$ref": "#/components/schemas/NoteActivityDto" } }, - "required": ["inReplyTo", "content"] + "required": [ + "inReplyTo", + "content" + ] }, "ReactionDto": { "type": "object", @@ -507,7 +648,11 @@ "type": "string" } }, - "required": ["emoji", "apply", "inReplyTo"] + "required": [ + "emoji", + "apply", + "inReplyTo" + ] }, "UpdateDto": { "type": "object", @@ -517,13 +662,20 @@ }, "targetAnnouncementType": { "type": "string", - "enum": ["broadcast", "reply"] + "enum": [ + "broadcast", + "reply" + ] }, "content": { "$ref": "#/components/schemas/NoteActivityDto" } }, - "required": ["targetContentHash", "targetAnnouncementType", "content"] + "required": [ + "targetContentHash", + "targetAnnouncementType", + "content" + ] }, "TombstoneDto": { "type": "object", @@ -533,10 +685,16 @@ }, "targetAnnouncementType": { "type": "string", - "enum": ["broadcast", "reply"] + "enum": [ + "broadcast", + "reply" + ] } }, - "required": ["targetContentHash", "targetAnnouncementType"] + "required": [ + "targetContentHash", + "targetAnnouncementType" + ] }, "ProfileActivityDto": { "type": "object", @@ -574,8 +732,10 @@ "$ref": "#/components/schemas/ProfileActivityDto" } }, - "required": ["profile"] + "required": [ + "profile" + ] } } } -} +} \ No newline at end of file diff --git a/services/content-watcher/apps/api/src/metadata.ts b/services/content-watcher/apps/api/src/metadata.ts index dbc56010..e73502c0 100644 --- a/services/content-watcher/apps/api/src/metadata.ts +++ b/services/content-watcher/apps/api/src/metadata.ts @@ -1,171 +1,9 @@ /* eslint-disable */ export default async () => { - const t = { - ['../../../libs/common/src/dtos/activity.dto']: await import('../../../libs/common/src/dtos/activity.dto'), - ['../../../libs/common/src/dtos/announcement.dto']: await import('../../../libs/common/src/dtos/announcement.dto'), - ['../../../libs/common/src/dtos/chain.watch.dto']: await import('../../../libs/common/src/dtos/chain.watch.dto'), - }; - return { - '@nestjs/swagger': { - models: [ - [ - import('../../../libs/common/src/dtos/common.dto'), - { - DsnpUserIdParam: { userDsnpId: { required: true, type: () => String } }, - AnnouncementResponseDto: { referenceId: { required: true, type: () => String } }, - UploadResponseDto: { assetIds: { required: true, type: () => [String] } }, - FilesUploadDto: { files: { required: true, type: () => [Object] } }, - ResetScannerDto: { - blockNumber: { required: false, type: () => Number, minimum: 1 }, - rewindOffset: { required: false, type: () => Number }, - immediate: { required: false, type: () => Boolean }, - }, - }, - ], - [ - import('../../../libs/common/src/dtos/activity.dto'), - { - LocationDto: { - name: { required: true, type: () => String, minLength: 1 }, - accuracy: { required: false, type: () => Number, minimum: 0, maximum: 100 }, - altitude: { required: false, type: () => Number }, - latitude: { required: false, type: () => Number }, - longitude: { required: false, type: () => Number }, - radius: { required: false, type: () => Number, minimum: 0 }, - units: { required: false, enum: t['../../../libs/common/src/dtos/activity.dto'].UnitTypeDto }, - }, - AssetReferenceDto: { - referenceId: { required: true, type: () => String, minLength: 1 }, - height: { required: false, type: () => Number, minimum: 1 }, - width: { required: false, type: () => Number, minimum: 1 }, - duration: { required: false, type: () => String, pattern: 'DURATION_REGEX' }, - }, - TagDto: { - type: { required: true, enum: t['../../../libs/common/src/dtos/activity.dto'].TagTypeDto }, - name: { required: false, type: () => String, minLength: 1 }, - mentionedId: { required: false, type: () => String, minLength: 1, pattern: 'DSNP_USER_URI_REGEX' }, - }, - AssetDto: { - type: { required: true, enum: t['../../../libs/common/src/dtos/activity.dto'].AttachmentTypeDto }, - references: { - required: false, - type: () => [t['../../../libs/common/src/dtos/activity.dto'].AssetReferenceDto], - }, - name: { required: false, type: () => String, minLength: 1 }, - href: { required: false, type: () => String, minLength: 1 }, - }, - BaseActivityDto: { - name: { required: false, type: () => String }, - tag: { required: false, type: () => [t['../../../libs/common/src/dtos/activity.dto'].TagDto] }, - location: { required: false, type: () => t['../../../libs/common/src/dtos/activity.dto'].LocationDto }, - }, - NoteActivityDto: { - content: { required: true, type: () => String, minLength: 1 }, - published: { required: true, type: () => String, pattern: 'ISO8601_REGEX' }, - assets: { required: false, type: () => [t['../../../libs/common/src/dtos/activity.dto'].AssetDto] }, - }, - ProfileActivityDto: { - icon: { - required: false, - type: () => [t['../../../libs/common/src/dtos/activity.dto'].AssetReferenceDto], - }, - summary: { required: false, type: () => String }, - published: { required: false, type: () => String, pattern: 'ISO8601_REGEX' }, - }, - }, - ], - [ - import('../../../libs/common/src/dtos/announcement.dto'), - { - BroadcastDto: { - content: { required: true, type: () => t['../../../libs/common/src/dtos/activity.dto'].NoteActivityDto }, - }, - ReplyDto: { - inReplyTo: { required: true, type: () => String, pattern: 'DSNP_CONTENT_URI_REGEX' }, - content: { required: true, type: () => t['../../../libs/common/src/dtos/activity.dto'].NoteActivityDto }, - }, - TombstoneDto: { - targetContentHash: { required: true, type: () => String, pattern: 'DSNP_CONTENT_HASH_REGEX' }, - targetAnnouncementType: { - required: true, - enum: t['../../../libs/common/src/dtos/announcement.dto'].ModifiableAnnouncementTypeDto, - }, - }, - UpdateDto: { - targetContentHash: { required: true, type: () => String, pattern: 'DSNP_CONTENT_HASH_REGEX' }, - targetAnnouncementType: { - required: true, - enum: t['../../../libs/common/src/dtos/announcement.dto'].ModifiableAnnouncementTypeDto, - }, - content: { required: true, type: () => t['../../../libs/common/src/dtos/activity.dto'].NoteActivityDto }, - }, - ReactionDto: { - emoji: { required: true, type: () => String, minLength: 1, pattern: 'DSNP_EMOJI_REGEX' }, - apply: { required: true, type: () => Number, minimum: 0, maximum: 255 }, - inReplyTo: { required: true, type: () => String, pattern: 'DSNP_CONTENT_URI_REGEX' }, - }, - ProfileDto: { - profile: { - required: true, - type: () => t['../../../libs/common/src/dtos/activity.dto'].ProfileActivityDto, - }, - }, - }, - ], - [ - import('../../../libs/common/src/dtos/chain.watch.dto'), - { - ChainWatchOptionsDto: { - schemaIds: { required: true, type: () => [Number] }, - dsnpIds: { required: true, type: () => [String] }, - }, - }, - ], - [ - import('../../../libs/common/src/dtos/content-search-request.dto'), - { - ContentSearchRequestDto: { - clientReferenceId: { required: true, type: () => String }, - startBlock: { required: true, type: () => Number, minimum: 1 }, - blockCount: { required: true, type: () => Number, minimum: 1 }, - filters: { - required: true, - type: () => t['../../../libs/common/src/dtos/chain.watch.dto'].ChainWatchOptionsDto, - }, - webhookUrl: { required: true, type: () => String }, - }, - }, - ], - [ - import('../../../libs/common/src/dtos/subscription.webhook.dto'), - { - WebhookRegistrationDto: { - url: { required: true, type: () => String }, - announcementTypes: { required: true, type: () => [String] }, - }, - }, - ], - ], - controllers: [ - [import('./controllers/health.controller'), { HealthController: { healthz: {}, livez: {}, readyz: {} } }], - [ - import('./controllers/v1/scanner.controller'), - { - ScanControllerV1: { - resetScanner: {}, - getWatchOptions: { type: t['../../../libs/common/src/dtos/chain.watch.dto'].ChainWatchOptionsDto }, - setWatchOptions: {}, - pauseScanner: {}, - startScanner: {}, - }, - }, - ], - [import('./controllers/v1/search.controller'), { SearchControllerV1: { search: {} } }], - [ - import('./controllers/v1/webhook.controller'), - { WebhookControllerV1: { registerWebhook: {}, clearAllWebHooks: {}, getRegisteredWebhooks: {} } }, - ], - ], - }, - }; -}; + const t = { + ["../../../libs/common/src/dtos/activity.dto"]: await import("../../../libs/common/src/dtos/activity.dto"), + ["../../../libs/common/src/dtos/announcement.dto"]: await import("../../../libs/common/src/dtos/announcement.dto"), + ["../../../libs/common/src/dtos/chain.watch.dto"]: await import("../../../libs/common/src/dtos/chain.watch.dto") + }; + return { "@nestjs/swagger": { "models": [[import("../../../libs/common/src/dtos/common.dto"), { "DsnpUserIdParam": { userDsnpId: { required: true, type: () => String } }, "AnnouncementResponseDto": { referenceId: { required: true, type: () => String } }, "UploadResponseDto": { assetIds: { required: true, type: () => [String] } }, "FilesUploadDto": { files: { required: true, type: () => [Object] } }, "ResetScannerDto": { blockNumber: { required: false, type: () => Number, minimum: 1 }, rewindOffset: { required: false, type: () => Number }, immediate: { required: false, type: () => Boolean } } }], [import("../../../libs/common/src/dtos/activity.dto"), { "LocationDto": { name: { required: true, type: () => String, minLength: 1 }, accuracy: { required: false, type: () => Number, minimum: 0, maximum: 100 }, altitude: { required: false, type: () => Number }, latitude: { required: false, type: () => Number }, longitude: { required: false, type: () => Number }, radius: { required: false, type: () => Number, minimum: 0 }, units: { required: false, enum: t["../../../libs/common/src/dtos/activity.dto"].UnitTypeDto } }, "AssetReferenceDto": { referenceId: { required: true, type: () => String, minLength: 1 }, height: { required: false, type: () => Number, minimum: 1 }, width: { required: false, type: () => Number, minimum: 1 }, duration: { required: false, type: () => String, pattern: "DURATION_REGEX" } }, "TagDto": { type: { required: true, enum: t["../../../libs/common/src/dtos/activity.dto"].TagTypeDto }, name: { required: false, type: () => String, minLength: 1 }, mentionedId: { required: false, type: () => String, minLength: 1, pattern: "DSNP_USER_URI_REGEX" } }, "AssetDto": { type: { required: true, enum: t["../../../libs/common/src/dtos/activity.dto"].AttachmentTypeDto }, references: { required: false, type: () => [t["../../../libs/common/src/dtos/activity.dto"].AssetReferenceDto] }, name: { required: false, type: () => String, minLength: 1 }, href: { required: false, type: () => String, minLength: 1 } }, "BaseActivityDto": { name: { required: false, type: () => String }, tag: { required: false, type: () => [t["../../../libs/common/src/dtos/activity.dto"].TagDto] }, location: { required: false, type: () => t["../../../libs/common/src/dtos/activity.dto"].LocationDto } }, "NoteActivityDto": { content: { required: true, type: () => String, minLength: 1 }, published: { required: true, type: () => String, pattern: "ISO8601_REGEX" }, assets: { required: false, type: () => [t["../../../libs/common/src/dtos/activity.dto"].AssetDto] } }, "ProfileActivityDto": { icon: { required: false, type: () => [t["../../../libs/common/src/dtos/activity.dto"].AssetReferenceDto] }, summary: { required: false, type: () => String }, published: { required: false, type: () => String, pattern: "ISO8601_REGEX" } } }], [import("../../../libs/common/src/dtos/announcement.dto"), { "BroadcastDto": { content: { required: true, type: () => t["../../../libs/common/src/dtos/activity.dto"].NoteActivityDto } }, "ReplyDto": { inReplyTo: { required: true, type: () => String, pattern: "DSNP_CONTENT_URI_REGEX" }, content: { required: true, type: () => t["../../../libs/common/src/dtos/activity.dto"].NoteActivityDto } }, "TombstoneDto": { targetContentHash: { required: true, type: () => String, pattern: "DSNP_CONTENT_HASH_REGEX" }, targetAnnouncementType: { required: true, enum: t["../../../libs/common/src/dtos/announcement.dto"].ModifiableAnnouncementTypeDto } }, "UpdateDto": { targetContentHash: { required: true, type: () => String, pattern: "DSNP_CONTENT_HASH_REGEX" }, targetAnnouncementType: { required: true, enum: t["../../../libs/common/src/dtos/announcement.dto"].ModifiableAnnouncementTypeDto }, content: { required: true, type: () => t["../../../libs/common/src/dtos/activity.dto"].NoteActivityDto } }, "ReactionDto": { emoji: { required: true, type: () => String, minLength: 1, pattern: "DSNP_EMOJI_REGEX" }, apply: { required: true, type: () => Number, minimum: 0, maximum: 255 }, inReplyTo: { required: true, type: () => String, pattern: "DSNP_CONTENT_URI_REGEX" } }, "ProfileDto": { profile: { required: true, type: () => t["../../../libs/common/src/dtos/activity.dto"].ProfileActivityDto } } }], [import("../../../libs/common/src/dtos/chain.watch.dto"), { "ChainWatchOptionsDto": { schemaIds: { required: true, type: () => [Number] }, dsnpIds: { required: true, type: () => [String] } } }], [import("../../../libs/common/src/dtos/content-search-request.dto"), { "ContentSearchRequestDto": { clientReferenceId: { required: true, type: () => String }, startBlock: { required: true, type: () => Number, minimum: 1 }, blockCount: { required: true, type: () => Number, minimum: 1 }, filters: { required: true, type: () => t["../../../libs/common/src/dtos/chain.watch.dto"].ChainWatchOptionsDto }, webhookUrl: { required: true, type: () => String } } }], [import("../../../libs/common/src/dtos/subscription.webhook.dto"), { "WebhookRegistrationDto": { url: { required: true, type: () => String }, announcementTypes: { required: true, type: () => [String] } } }]], "controllers": [[import("./controllers/health.controller"), { "HealthController": { "healthz": {}, "livez": {}, "readyz": {} } }], [import("./controllers/v1/scanner.controller"), { "ScanControllerV1": { "resetScanner": {}, "getWatchOptions": { type: t["../../../libs/common/src/dtos/chain.watch.dto"].ChainWatchOptionsDto }, "setWatchOptions": {}, "pauseScanner": {}, "startScanner": {} } }], [import("./controllers/v1/search.controller"), { "SearchControllerV1": { "search": {} } }], [import("./controllers/v1/webhook.controller"), { "WebhookControllerV1": { "registerWebhook": {}, "clearAllWebHooks": {}, "getRegisteredWebhooks": {} } }]] } }; +}; \ No newline at end of file diff --git a/services/content-watcher/docs/index.html b/services/content-watcher/docs/index.html index bf6872bb..041abad7 100644 --- a/services/content-watcher/docs/index.html +++ b/services/content-watcher/docs/index.html @@ -1,1926 +1,348 @@ - + - - - Content Watcher Service API - - - - - - - - -
-
- -
-
- - - + Content Watcher Service API + + + + + + + + + +
- - - - - -
-
-
-
-
-
-

- Content Watcher Service API - (1.0) -

-

- Download OpenAPI specification:Download -

-
-
-
- - -
-
-
-
-
-

Content Watcher Service API

-
-
-
-
-
-
-
-

- v1/scanner -

-
-
-
-
-
-
-

- Reset blockchain scan to a specific block number or offset from the current position -

-
- Request Body schema: application/json -
required
-
-
-

blockNumber

-
- - - - - - - - - - - - - - - -
- blockNumber - -
-
- number - >= 1 -
-
-
-

The block number to reset the scanner to

-
-
-
-
- rewindOffset - -
-
- number -
-
-
-

- Number of blocks to rewind the scanner to (from blockNumber if supplied; - else from latest block -

-
-
-
-
- immediate - -
-
- boolean -
-
-
-

- Whether to schedule the new scan immediately or wait for the next scheduled interval -

-
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Request samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "blockNumber": - 0, -
    -
  • -
  • -
    - "rewindOffset": - 100, -
    -
  • -
  • -
    - "immediate": - true -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- Get the current watch options for the blockchain content event scanner -

-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Response samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "schemaIds": - [ -
      -
    • - -
    • -
    • - -
    • -
    - ], -
    -
  • -
  • -
    - "dsnpIds": - [ -
      -
    • - -
    • -
    • - -
    • -
    - ] -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- Set watch options to filter the blockchain content scanner by schemas or MSA Ids -

-
- Request Body schema: application/json -
required
-
-
-

watchOptions: Filter contents by schemaIds and/or msaIds

-
- - - - - - - - - - - -
- schemaIds - -
-
- Array of numbers -
-
-
-

Specific schema ids to watch for

-
-
-
-
- dsnpIds - -
-
- Array of strings -
-
-
-

Specific dsnpIds (msa_id) to watch for

-
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Request samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "schemaIds": - [ -
      -
    • - -
    • -
    • - -
    • -
    - ], -
    -
  • -
  • -
    - "dsnpIds": - [ -
      -
    • - -
    • -
    • - -
    • -
    - ] -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- Pause the blockchain scanner -

-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- Resume the blockchain content event scanner -

-
-
- query - Parameters -
- - - - - - - -
- immediate - -
-
- boolean -
-
-
-

- Immediate: whether to resume scan immediately (true), or wait until next scheduled - scan (false) -

-
-
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- v1/search -

-
-
-
- -
-
-
-

- v1/webhooks -

-
-
-
-
-
-
-

- Register a webhook to be called when new content is encountered on the chain -

-
- Request Body schema: application/json -
required
-
-
-

Register a webhook to be called when a new content is encountered

-
- - - - - - - - - - - -
- url -
required
-
-
-
- string -
-
-
-

Webhook URL

-
-
-
-
- announcementTypes -
required
-
-
-
- Array of strings -
-
-
-

Announcement types to send to the webhook

-
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Request samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "url": - "https://example.com/webhook", -
    -
  • -
  • -
    - "announcementTypes": - [ -
      -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    - ] -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- Clear all previously registered webhooks -

-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- Get the list of currently registered webhooks -

-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Response samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- [ -
    -
  • -
    - { -
      -
    • - -
    • -
    • - -
    • -
    - } -
    -
  • -
- ]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- health -

-
-
-
-
-
-
-

- Check the health status of the service -

-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- Check the live status of the service -

-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- Check the ready status of the service -

-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-
- - + + + + diff --git a/services/content-watcher/swagger.json b/services/content-watcher/swagger.json index ea10af5b..9cc4892c 100644 --- a/services/content-watcher/swagger.json +++ b/services/content-watcher/swagger.json @@ -22,7 +22,9 @@ "description": "" } }, - "tags": ["v1/scanner"] + "tags": [ + "v1/scanner" + ] } }, "/v1/scanner/options": { @@ -42,7 +44,9 @@ } } }, - "tags": ["v1/scanner"] + "tags": [ + "v1/scanner" + ] }, "post": { "operationId": "ScanControllerV1_setWatchOptions", @@ -64,7 +68,9 @@ "description": "" } }, - "tags": ["v1/scanner"] + "tags": [ + "v1/scanner" + ] } }, "/v1/scanner/pause": { @@ -77,7 +83,9 @@ "description": "" } }, - "tags": ["v1/scanner"] + "tags": [ + "v1/scanner" + ] } }, "/v1/scanner/start": { @@ -100,7 +108,9 @@ "description": "" } }, - "tags": ["v1/scanner"] + "tags": [ + "v1/scanner" + ] } }, "/v1/search": { @@ -131,7 +141,9 @@ } } }, - "tags": ["v1/search"] + "tags": [ + "v1/search" + ] } }, "/v1/webhooks": { @@ -155,7 +167,9 @@ "description": "" } }, - "tags": ["v1/webhooks"] + "tags": [ + "v1/webhooks" + ] }, "delete": { "operationId": "WebhookControllerV1_clearAllWebHooks", @@ -166,7 +180,9 @@ "description": "" } }, - "tags": ["v1/webhooks"] + "tags": [ + "v1/webhooks" + ] }, "get": { "operationId": "WebhookControllerV1_getRegisteredWebhooks", @@ -187,7 +203,9 @@ } } }, - "tags": ["v1/webhooks"] + "tags": [ + "v1/webhooks" + ] } }, "/healthz": { @@ -200,7 +218,9 @@ "description": "Service is healthy" } }, - "tags": ["health"] + "tags": [ + "health" + ] } }, "/livez": { @@ -213,7 +233,9 @@ "description": "Service is live" } }, - "tags": ["health"] + "tags": [ + "health" + ] } }, "/readyz": { @@ -226,7 +248,9 @@ "description": "Service is ready" } }, - "tags": ["health"] + "tags": [ + "health" + ] } } }, @@ -270,11 +294,17 @@ "type": "number" }, "description": "Specific schema ids to watch for", - "example": [1, 19] + "example": [ + 1, + 19 + ] }, "dsnpIds": { "description": "Specific dsnpIds (msa_id) to watch for", - "example": ["10074", "100001"], + "example": [ + "10074", + "100001" + ], "type": "array", "items": { "type": "string" @@ -314,7 +344,10 @@ "description": "A webhook URL to be notified of the results of this search" } }, - "required": ["blockCount", "webhookUrl"] + "required": [ + "blockCount", + "webhookUrl" + ] }, "WebhookRegistrationDto": { "type": "object", @@ -326,15 +359,24 @@ }, "announcementTypes": { "description": "Announcement types to send to the webhook", - "example": ["Broadcast", "Reaction", "Tombstone", "Reply", "Update"], + "example": [ + "Broadcast", + "Reaction", + "Tombstone", + "Reply", + "Update" + ], "type": "array", "items": { "type": "string" } } }, - "required": ["url", "announcementTypes"] + "required": [ + "url", + "announcementTypes" + ] } } } -} +} \ No newline at end of file diff --git a/services/graph/apps/api/src/metadata.ts b/services/graph/apps/api/src/metadata.ts index 8e1d0c16..c9174400 100644 --- a/services/graph/apps/api/src/metadata.ts +++ b/services/graph/apps/api/src/metadata.ts @@ -1,158 +1,15 @@ /* eslint-disable */ export default async () => { - const t = { - ['../../../libs/common/src/dtos/privacy-type.enum']: await import( - '../../../libs/common/src/dtos/privacy-type.enum' - ), - ['../../../libs/common/src/dtos/direction.enum']: await import('../../../libs/common/src/dtos/direction.enum'), - ['../../../libs/common/src/dtos/connection-type.enum']: await import( - '../../../libs/common/src/dtos/connection-type.enum' - ), - ['../../../libs/common/src/dtos/connection.dto']: await import('../../../libs/common/src/dtos/connection.dto'), - ['../../../libs/common/src/dtos/key-type.enum']: await import('../../../libs/common/src/dtos/key-type.enum'), - ['../../../libs/common/src/dtos/dsnp-graph-edge.dto']: await import( - '../../../libs/common/src/dtos/dsnp-graph-edge.dto' - ), - ['../../../libs/common/src/dtos/graph-key-pair.dto']: await import( - '../../../libs/common/src/dtos/graph-key-pair.dto' - ), - ['../../../libs/common/src/dtos/user-graph.dto']: await import('../../../libs/common/src/dtos/user-graph.dto'), - ['../../../libs/common/src/dtos/graph-change-response.dto']: await import( - '../../../libs/common/src/dtos/graph-change-response.dto' - ), - }; - return { - '@nestjs/swagger': { - models: [ - [ - import('../../../libs/common/src/dtos/connection.dto'), - { - ConnectionDto: { - dsnpId: { required: true, type: () => String }, - privacyType: { required: true, enum: t['../../../libs/common/src/dtos/privacy-type.enum'].PrivacyType }, - direction: { required: true, enum: t['../../../libs/common/src/dtos/direction.enum'].Direction }, - connectionType: { - required: true, - enum: t['../../../libs/common/src/dtos/connection-type.enum'].ConnectionType, - }, - }, - ConnectionDtoWrapper: { - data: { required: true, type: () => [t['../../../libs/common/src/dtos/connection.dto'].ConnectionDto] }, - }, - }, - ], - [ - import('../../../libs/common/src/dtos/dsnp-graph-edge.dto'), - { - DsnpGraphEdge: { - userId: { required: true, type: () => String }, - since: { required: true, type: () => Number }, - }, - }, - ], - [ - import('../../../libs/common/src/dtos/graph-key-pair.dto'), - { - GraphKeyPairDto: { - publicKey: { required: true, type: () => String }, - privateKey: { required: true, type: () => String }, - keyType: { - required: true, - type: () => String, - enum: t['../../../libs/common/src/dtos/key-type.enum'].KeyType, - }, - }, - }, - ], - [ - import('../../../libs/common/src/dtos/user-graph.dto'), - { - UserGraphDto: { - dsnpId: { required: true, type: () => String }, - dsnpGraphEdges: { - required: false, - type: () => [t['../../../libs/common/src/dtos/dsnp-graph-edge.dto'].DsnpGraphEdge], - }, - }, - }, - ], - [ - import('../../../libs/common/src/dtos/graph-change-response.dto'), - { GraphChangeRepsonseDto: { referenceId: { required: true, type: () => String } } }, - ], - [ - import('../../../libs/common/src/dtos/graph-query-params.dto'), - { - GraphsQueryParamsDto: { - dsnpIds: { required: true, type: () => [String] }, - privacyType: { required: true, enum: t['../../../libs/common/src/dtos/privacy-type.enum'].PrivacyType }, - graphKeyPairs: { - required: false, - type: () => [t['../../../libs/common/src/dtos/graph-key-pair.dto'].GraphKeyPairDto], - }, - }, - }, - ], - [ - import('../../../libs/common/src/dtos/provider-graph.dto'), - { - ProviderGraphDto: { - dsnpId: { required: true, type: () => String }, - connections: { - required: true, - type: () => ({ - data: { - required: true, - type: () => [t['../../../libs/common/src/dtos/connection.dto'].ConnectionDto], - }, - }), - }, - graphKeyPairs: { - required: false, - type: () => [t['../../../libs/common/src/dtos/graph-key-pair.dto'].GraphKeyPairDto], - }, - webhookUrl: { required: false, type: () => String }, - }, - }, - ], - [ - import('../../../libs/common/src/dtos/watch-graphs.dto'), - { - WatchGraphsDto: { - dsnpIds: { required: false, type: () => [String] }, - webhookEndpoint: { required: true, type: () => String }, - }, - }, - ], - ], - controllers: [ - [import('./controllers/health.controller'), { HealthController: { healthz: {}, livez: {}, readyz: {} } }], - [ - import('./controllers/v1/webhooks-v1.controller'), - { - WebhooksControllerV1: { - getAllWebhooks: { type: Object }, - getWebhooksForMsa: { type: [String] }, - getWebhooksForUrl: { type: [String] }, - watchGraphs: {}, - deleteAllWebhooks: {}, - deleteWebhooksForMsa: {}, - deleteAllWebhooksForUrl: {}, - }, - }, - ], - [ - import('./controllers/v1/graph-v1.controller'), - { - GraphControllerV1: { - getGraphs: { type: [t['../../../libs/common/src/dtos/user-graph.dto'].UserGraphDto] }, - updateGraph: { - type: t['../../../libs/common/src/dtos/graph-change-response.dto'].GraphChangeRepsonseDto, - }, - }, - }, - ], - ], - }, - }; -}; + const t = { + ["../../../libs/common/src/dtos/privacy-type.enum"]: await import("../../../libs/common/src/dtos/privacy-type.enum"), + ["../../../libs/common/src/dtos/direction.enum"]: await import("../../../libs/common/src/dtos/direction.enum"), + ["../../../libs/common/src/dtos/connection-type.enum"]: await import("../../../libs/common/src/dtos/connection-type.enum"), + ["../../../libs/common/src/dtos/connection.dto"]: await import("../../../libs/common/src/dtos/connection.dto"), + ["../../../libs/common/src/dtos/key-type.enum"]: await import("../../../libs/common/src/dtos/key-type.enum"), + ["../../../libs/common/src/dtos/dsnp-graph-edge.dto"]: await import("../../../libs/common/src/dtos/dsnp-graph-edge.dto"), + ["../../../libs/common/src/dtos/graph-key-pair.dto"]: await import("../../../libs/common/src/dtos/graph-key-pair.dto"), + ["../../../libs/common/src/dtos/user-graph.dto"]: await import("../../../libs/common/src/dtos/user-graph.dto"), + ["../../../libs/common/src/dtos/graph-change-response.dto"]: await import("../../../libs/common/src/dtos/graph-change-response.dto") + }; + return { "@nestjs/swagger": { "models": [[import("../../../libs/common/src/dtos/connection.dto"), { "ConnectionDto": { dsnpId: { required: true, type: () => String }, privacyType: { required: true, enum: t["../../../libs/common/src/dtos/privacy-type.enum"].PrivacyType }, direction: { required: true, enum: t["../../../libs/common/src/dtos/direction.enum"].Direction }, connectionType: { required: true, enum: t["../../../libs/common/src/dtos/connection-type.enum"].ConnectionType } }, "ConnectionDtoWrapper": { data: { required: true, type: () => [t["../../../libs/common/src/dtos/connection.dto"].ConnectionDto] } } }], [import("../../../libs/common/src/dtos/dsnp-graph-edge.dto"), { "DsnpGraphEdgeDto": { userId: { required: true, type: () => String }, since: { required: true, type: () => Number } } }], [import("../../../libs/common/src/dtos/graph-key-pair.dto"), { "GraphKeyPairDto": { publicKey: { required: true, type: () => String }, privateKey: { required: true, type: () => String }, keyType: { required: true, type: () => String, enum: t["../../../libs/common/src/dtos/key-type.enum"].KeyType } } }], [import("../../../libs/common/src/dtos/user-graph.dto"), { "UserGraphDto": { dsnpId: { required: true, type: () => String }, dsnpGraphEdges: { required: false, type: () => [t["../../../libs/common/src/dtos/dsnp-graph-edge.dto"].DsnpGraphEdgeDto] } } }], [import("../../../libs/common/src/dtos/graph-change-response.dto"), { "GraphChangeRepsonseDto": { referenceId: { required: true, type: () => String } } }], [import("../../../libs/common/src/dtos/graph-query-params.dto"), { "GraphsQueryParamsDto": { dsnpIds: { required: true, type: () => [String] }, privacyType: { required: true, enum: t["../../../libs/common/src/dtos/privacy-type.enum"].PrivacyType }, graphKeyPairs: { required: false, type: () => [t["../../../libs/common/src/dtos/graph-key-pair.dto"].GraphKeyPairDto] } } }], [import("../../../libs/common/src/dtos/provider-graph.dto"), { "ProviderGraphDto": { dsnpId: { required: true, type: () => String }, connections: { required: true, type: () => ({ data: { required: true, type: () => [t["../../../libs/common/src/dtos/connection.dto"].ConnectionDto] } }) }, graphKeyPairs: { required: false, type: () => [t["../../../libs/common/src/dtos/graph-key-pair.dto"].GraphKeyPairDto] }, webhookUrl: { required: false, type: () => String } } }], [import("../../../libs/common/src/dtos/watch-graphs.dto"), { "WatchGraphsDto": { dsnpIds: { required: false, type: () => [String] }, webhookEndpoint: { required: true, type: () => String } } }]], "controllers": [[import("./controllers/health.controller"), { "HealthController": { "healthz": {}, "livez": {}, "readyz": {} } }], [import("./controllers/v1/webhooks-v1.controller"), { "WebhooksControllerV1": { "getAllWebhooks": { type: Object }, "getWebhooksForMsa": { type: [String] }, "getWebhooksForUrl": { type: [String] }, "watchGraphs": {}, "deleteAllWebhooks": {}, "deleteWebhooksForMsa": {}, "deleteAllWebhooksForUrl": {} } }], [import("./controllers/v1/graph-v1.controller"), { "GraphControllerV1": { "getGraphs": { type: [t["../../../libs/common/src/dtos/user-graph.dto"].UserGraphDto] }, "updateGraph": { type: t["../../../libs/common/src/dtos/graph-change-response.dto"].GraphChangeRepsonseDto } } }]] } }; +}; \ No newline at end of file diff --git a/services/graph/docs/index.html b/services/graph/docs/index.html index a092e322..2613d339 100644 --- a/services/graph/docs/index.html +++ b/services/graph/docs/index.html @@ -1,1917 +1,350 @@ - + - - - Graph Service - - - - - - - - -
-
- -
-
- - - + Graph Service + + + + + + + + + +
- - - - - -
-
-
-
-
-
-

- Graph Service - (1.0) -

-

- Download OpenAPI specification:Download -

-
-
-
- - -
-
-
-
-
-

Graph Service API

-
-
-
-
-
-
-
-

- v1/graphs -

-
-
-
-
-
-
-

- Fetch graphs for specified MSA Ids and Block Number -

-
- Request Body schema: application/json -
required
-
-
- - - - - - - - - - - - - - - -
- dsnpIds -
required
-
-
-
- Array of strings -
-
-
-

Array of MSA Ids for which to query graphs

-
-
-
-
- privacyType -
required
-
-
-
- string -
-
- Enum: - "private" - "public" -
-
-
-

Graph type to query (public or private)

-
-
-
-
- - -
-
- Array of objects (GraphKeyPairDto) -
-
-
-

- Graph encryption keypairs for the users requested in dsnpIds. (Only for - privacyType === "private" -

-
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Request samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "dsnpIds": - [ -
      -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    - ], -
    -
  • -
  • -
    - "privacyType": - "public", -
    -
  • -
  • -
    - "graphKeyPairs": - [ -
      -
    • - -
    • -
    - ] -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-

Response samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- [ -
    -
  • -
    - { -
      -
    • - -
    • -
    • - -
    • -
    - } -
    -
  • -
- ]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- Request an update to a given user's graph -

-
- Request Body schema: application/json -
required
-
-
- - - - - - - - - - - - - - - - - - - -
- dsnpId -
required
-
-
-
- string -
-
-
-

MSA Id that owns the connections represented in this object

-
-
-
-
- -
required
-
-
-
- object -
-
-
-

Array of connections known to the Provider for ths MSA referenced in this object

-
-
-
-
- - -
-
- Array of objects (GraphKeyPairDto) -
-
-
-

- Optional array of graph encryption keypairs decrypting/encrypting the above-referenced - users private graph -

-
-
-
-
- webhookUrl - -
-
- string -
-
-
-

Optional URL of a webhook to invoke when the request is complete

-
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Request samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "dsnpId": - "2", -
    -
  • -
  • -
    - "connections": - { -
      -
    • - -
    • -
    - }, -
    -
  • -
  • -
    - "graphKeyPairs": - [ -
      -
    • - -
    • -
    - ], -
    -
  • -
  • -
    - "webhookUrl": - "string" -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-

Response samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "referenceId": - "string" -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- v1/webhooks -

-
-
-
-
-
-
-

- Get all registered webhooks -

-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- Watch graphs for specified dsnpIds and receive updates -

-
- Request Body schema: application/json -
required
-
-
- - - - - - - - - - - -
- dsnpIds - -
-
- Array of strings -
-
-
-

MSA Ids for which to watch for graph updates

-
-
-
-
- webhookEndpoint -
required
-
-
-
- string -
-
-
-

Webhook URL to call when graph changes for the referenced MSAs are detected

-
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-

Request samples

-
-
    - -
-
-
-
- Content type -
application/json
-
-
-
-
- -
-
-
- { -
    -
  • -
    - "dsnpIds": - [ -
      -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    - ], -
    -
  • -
  • -
    - "webhookEndpoint": - "http://localhost/webhook" -
    -
  • -
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- Delete all registered webhooks -

-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- Get all registered webhooks for a specific MSA Id -

-
-
- path - Parameters -
- - - - - - - -
- msaId -
required
-
-
-
- string -
-
- Example: - 2 -
-
-
-

MSA Id for which to request registered webhooks

-
-
-
-
-
-
-
- query - Parameters -
- - - - - - - -
- includeAll - -
-
- boolean -
-
- Example: - includeAll=true -
-
-
-

- Boolean whether to include webhooks registered for 'all' MSA Ids (default: - true) -

-
-
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- Delete all webhooks registered for a specific MSA -

-
-
- path - Parameters -
- - - - - - - -
- msaId -
required
-
-
-
- string -
-
- Example: - 2 -
-
-
-

MSA for which to remove all webhook registrations

-
-
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- Get all webhooks registered to the specified URL -

-
-
- query - Parameters -
- - - - - - - -
- url -
required
-
-
-
- string -
-
- Example: - url=http://localhost/webhook -
-
-
-

URL for which to fetch all watched MSAs

-
-
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- Delete all MSA webhooks registered with the given URL -

-
-
- query - Parameters -
- - - - - - - -
- url -
required
-
-
-
- string -
-
- Example: - url=http://localhost/webhook -
-
-
-

URL for which to un-watch all MSAs

-
-
-
-
-
-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- health -

-
-
-
-
-
-
-

- Check the health status of the service -

-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- Check the live status of the service -

-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-

- Check the ready status of the service -

-
-

Responses

-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-
- - + + + + diff --git a/services/graph/libs/common/src/dtos/dsnp-graph-edge.dto.ts b/services/graph/libs/common/src/dtos/dsnp-graph-edge.dto.ts index b22d771c..3f844dd0 100644 --- a/services/graph/libs/common/src/dtos/dsnp-graph-edge.dto.ts +++ b/services/graph/libs/common/src/dtos/dsnp-graph-edge.dto.ts @@ -1,7 +1,7 @@ import { IsNotEmpty, IsNumber, IsString } from 'class-validator'; import { ApiProperty } from '@nestjs/swagger'; -export class DsnpGraphEdge { +export class DsnpGraphEdgeDto { @IsNotEmpty() @IsString() @ApiProperty({ description: 'MSA Id of the user represented by this graph edge', type: String, example: '3' }) diff --git a/services/graph/libs/common/src/dtos/user-graph.dto.ts b/services/graph/libs/common/src/dtos/user-graph.dto.ts index 57d7598f..ed14cd7d 100644 --- a/services/graph/libs/common/src/dtos/user-graph.dto.ts +++ b/services/graph/libs/common/src/dtos/user-graph.dto.ts @@ -1,5 +1,5 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; -import { DsnpGraphEdge } from './dsnp-graph-edge.dto'; +import { DsnpGraphEdgeDto } from './dsnp-graph-edge.dto'; export class UserGraphDto { @ApiProperty({ @@ -11,7 +11,7 @@ export class UserGraphDto { @ApiPropertyOptional({ description: 'Optional array of graph edges in the specific user graph represented by this object', - type: [DsnpGraphEdge], + type: [DsnpGraphEdgeDto], }) - dsnpGraphEdges?: DsnpGraphEdge[]; + dsnpGraphEdges?: DsnpGraphEdgeDto[]; } diff --git a/services/graph/libs/common/src/services/async_debouncer.ts b/services/graph/libs/common/src/services/async_debouncer.ts index 83f2ea2e..3540903f 100644 --- a/services/graph/libs/common/src/services/async_debouncer.ts +++ b/services/graph/libs/common/src/services/async_debouncer.ts @@ -2,7 +2,7 @@ import { Injectable, Logger } from '@nestjs/common'; import Redis from 'ioredis'; import { PrivacyType } from '@dsnp/graph-sdk'; import * as QueueConstants from '../queues/queue-constants'; -import { DsnpGraphEdge } from '../dtos/dsnp-graph-edge.dto'; +import { DsnpGraphEdgeDto } from '../dtos/dsnp-graph-edge.dto'; import { ConfigService } from '../config/config.service'; import { GraphStateManager } from './graph-state-manager'; import { GraphKeyPairDto } from '../dtos/graph-key-pair.dto'; @@ -23,7 +23,7 @@ export class AsyncDebouncerService { dsnpId: string, privacyType: PrivacyType, graphKeyPairs?: GraphKeyPairDto[], - ): Promise { + ): Promise { return this.debounceAsyncOperation(dsnpId, privacyType, graphKeyPairs); } @@ -31,7 +31,7 @@ export class AsyncDebouncerService { dsnpId: string, schemaId: number, graphKeyPairs?: GraphKeyPairDto[], - ): Promise { + ): Promise { if (!schemaId) { throw new Error('Schema ID is required'); } @@ -43,13 +43,13 @@ export class AsyncDebouncerService { dsnpId: string, privacyType: PrivacyType, graphKeyPairs?: GraphKeyPairDto[], - ): Promise { + ): Promise { const cacheKey = this.getCacheKey(dsnpId, privacyType); const cachedFuture = await this.redis.get(cacheKey); if (cachedFuture) { this.logger.debug(`Async operation for key ${dsnpId} is already inflight`, cachedFuture); - const graphData: DsnpGraphEdge[] = JSON.parse(cachedFuture); + const graphData: DsnpGraphEdgeDto[] = JSON.parse(cachedFuture); if (graphData && graphData.length > 0) { return graphData; } @@ -60,7 +60,7 @@ export class AsyncDebouncerService { throw new Error('Graph key pairs are required for private graph'); } } - let graphEdges: DsnpGraphEdge[] = []; + let graphEdges: DsnpGraphEdgeDto[] = []; try { graphEdges = await this.graphStateManager.getConnectionsWithPrivacyType(dsnpId, privacyType, graphKeyPairs); } catch (err) { diff --git a/services/graph/swagger.json b/services/graph/swagger.json index ce5f28b8..ed2e85ec 100644 --- a/services/graph/swagger.json +++ b/services/graph/swagger.json @@ -31,7 +31,9 @@ } } }, - "tags": ["v1/graphs"] + "tags": [ + "v1/graphs" + ] } }, "/v1/graphs": { @@ -61,7 +63,9 @@ } } }, - "tags": ["v1/graphs"] + "tags": [ + "v1/graphs" + ] } }, "/v1/webhooks": { @@ -74,7 +78,9 @@ "description": "Retrieved all registered webhooks" } }, - "tags": ["v1/webhooks"] + "tags": [ + "v1/webhooks" + ] }, "put": { "operationId": "WebhooksControllerV1_watchGraphs", @@ -95,7 +101,9 @@ "description": "Successfully started watching graphs" } }, - "tags": ["v1/webhooks"] + "tags": [ + "v1/webhooks" + ] }, "delete": { "operationId": "WebhooksControllerV1_deleteAllWebhooks", @@ -106,7 +114,9 @@ "description": "Removed all registered webhooks" } }, - "tags": ["v1/webhooks"] + "tags": [ + "v1/webhooks" + ] } }, "/v1/webhooks/users/{msaId}": { @@ -140,7 +150,9 @@ "description": "Retrieved all registered webhooks for the given MSA Id" } }, - "tags": ["v1/webhooks"] + "tags": [ + "v1/webhooks" + ] }, "delete": { "operationId": "WebhooksControllerV1_deleteWebhooksForMsa", @@ -162,7 +174,9 @@ "description": "Removed all registered webhooks for the specified MSA" } }, - "tags": ["v1/webhooks"] + "tags": [ + "v1/webhooks" + ] } }, "/v1/webhooks/urls": { @@ -186,7 +200,9 @@ "description": "Retrieved all webhooks registered to the specified URL" } }, - "tags": ["v1/webhooks"] + "tags": [ + "v1/webhooks" + ] }, "delete": { "operationId": "WebhooksControllerV1_deleteAllWebhooksForUrl", @@ -208,7 +224,9 @@ "description": "Removed all webhooks registered to the specified URL" } }, - "tags": ["v1/webhooks"] + "tags": [ + "v1/webhooks" + ] } }, "/healthz": { @@ -221,7 +239,9 @@ "description": "Service is healthy" } }, - "tags": ["health"] + "tags": [ + "health" + ] } }, "/livez": { @@ -234,7 +254,9 @@ "description": "Service is live" } }, - "tags": ["health"] + "tags": [ + "health" + ] } }, "/readyz": { @@ -247,7 +269,9 @@ "description": "Service is ready" } }, - "tags": ["health"] + "tags": [ + "health" + ] } } }, @@ -274,26 +298,40 @@ }, "keyType": { "type": "string", - "enum": ["X25519"], + "enum": [ + "X25519" + ], "description": "Key type of graph encryption keypair (currently only X25519 supported)", "example": "X25519" } }, - "required": ["publicKey", "privateKey", "keyType"] + "required": [ + "publicKey", + "privateKey", + "keyType" + ] }, "GraphsQueryParamsDto": { "type": "object", "properties": { "dsnpIds": { "description": "Array of MSA Ids for which to query graphs", - "example": ["2", "3", "4", "5"], + "example": [ + "2", + "3", + "4", + "5" + ], "type": "array", "items": { "type": "string" } }, "privacyType": { - "enum": ["private", "public"], + "enum": [ + "private", + "public" + ], "type": "string", "description": "Graph type to query (public or private)", "example": "public" @@ -306,9 +344,12 @@ } } }, - "required": ["dsnpIds", "privacyType"] + "required": [ + "dsnpIds", + "privacyType" + ] }, - "DsnpGraphEdge": { + "DsnpGraphEdgeDto": { "type": "object", "properties": { "userId": { @@ -322,7 +363,10 @@ "example": 12 } }, - "required": ["userId", "since"] + "required": [ + "userId", + "since" + ] }, "UserGraphDto": { "type": "object", @@ -336,11 +380,13 @@ "description": "Optional array of graph edges in the specific user graph represented by this object", "type": "array", "items": { - "$ref": "#/components/schemas/DsnpGraphEdge" + "$ref": "#/components/schemas/DsnpGraphEdgeDto" } } }, - "required": ["dsnpId"] + "required": [ + "dsnpId" + ] }, "ConnectionDto": { "type": "object", @@ -351,25 +397,41 @@ "example": "3" }, "privacyType": { - "enum": ["private", "public"], + "enum": [ + "private", + "public" + ], "type": "string", "description": "Indicator connection type (public or private)", "example": "public" }, "direction": { - "enum": ["connectionTo", "connectionFrom", "bidirectional", "disconnect"], + "enum": [ + "connectionTo", + "connectionFrom", + "bidirectional", + "disconnect" + ], "type": "string", "description": "Indicator of the direction of this connection", "example": "connectionTo" }, "connectionType": { - "enum": ["follow", "friendship"], + "enum": [ + "follow", + "friendship" + ], "type": "string", "description": "Indicator of the type of connection (follow or friendship)", "example": "follow" } }, - "required": ["dsnpId", "privacyType", "direction", "connectionType"] + "required": [ + "dsnpId", + "privacyType", + "direction", + "connectionType" + ] }, "ConnectionDtoWrapper": { "type": "object", @@ -382,7 +444,9 @@ } } }, - "required": ["data"] + "required": [ + "data" + ] }, "ProviderGraphDto": { "type": "object", @@ -412,7 +476,10 @@ "description": "Optional URL of a webhook to invoke when the request is complete" } }, - "required": ["dsnpId", "connections"] + "required": [ + "dsnpId", + "connections" + ] }, "GraphChangeRepsonseDto": { "type": "object", @@ -422,14 +489,21 @@ "description": "Reference ID by which the results/status of a submitted GraphChangeRequest may be retrieved" } }, - "required": ["referenceId"] + "required": [ + "referenceId" + ] }, "WatchGraphsDto": { "type": "object", "properties": { "dsnpIds": { "description": "MSA Ids for which to watch for graph updates", - "example": ["2", "3", "4", "5"], + "example": [ + "2", + "3", + "4", + "5" + ], "type": "array", "items": { "type": "string" @@ -441,8 +515,10 @@ "example": "http://localhost/webhook" } }, - "required": ["webhookEndpoint"] + "required": [ + "webhookEndpoint" + ] } } } -} +} \ No newline at end of file diff --git a/services/graph/test-setup/main.ts b/services/graph/test-setup/main.ts index 2bd0b107..628c88e6 100644 --- a/services/graph/test-setup/main.ts +++ b/services/graph/test-setup/main.ts @@ -15,7 +15,7 @@ import { provisionUsersOnChain, } from '@projectlibertylabs/frequency-scenario-template'; import { cryptoWaitReady } from '@polkadot/util-crypto'; -import { EnvironmentType, Graph, ImportBundleBuilder } from '@dsnp/graph-sdk'; +import { EnvironmentType, Graph } from '@dsnp/graph-sdk'; const FREQUENCY_URL = process.env.FREQUENCY_URL || 'ws://127.0.0.1:9944';