From ad2758bef71a33dae2f4dfb72914e45fbef71633 Mon Sep 17 00:00:00 2001
From: Konstantin Tsabolov <konstantin.tsabolov@spherity.com>
Date: Wed, 13 Dec 2023 17:24:31 +0100
Subject: [PATCH] chore: add multitenancy and pagination params to shared

---
 apps/shared/package.json                      |  3 +++
 .../shared/src/dto/multitenancy-params.dto.ts | 12 +++++++++
 apps/shared/src/dto/pagination-params.dto.ts  | 26 +++++++++++++++++++
 apps/shared/src/index.ts                      |  3 +++
 4 files changed, 44 insertions(+)
 create mode 100644 apps/shared/src/dto/multitenancy-params.dto.ts
 create mode 100644 apps/shared/src/dto/pagination-params.dto.ts

diff --git a/apps/shared/package.json b/apps/shared/package.json
index e092ae5..0553f1a 100644
--- a/apps/shared/package.json
+++ b/apps/shared/package.json
@@ -27,7 +27,10 @@
     "@elastic/ecs-winston-format": "^1.5.0",
     "@nestjs/common": "^10.2.10",
     "@nestjs/microservices": "^10.2.10",
+    "@nestjs/swagger": "^7.1.16",
     "axios": "^1.6.2",
+    "class-transformer": "^0.5.1",
+    "class-validator": "^0.14.0",
     "joi": "^17.6.0",
     "nats": "^2.18.0",
     "rxjs": "^7.2.0",
diff --git a/apps/shared/src/dto/multitenancy-params.dto.ts b/apps/shared/src/dto/multitenancy-params.dto.ts
new file mode 100644
index 0000000..c6dc7c0
--- /dev/null
+++ b/apps/shared/src/dto/multitenancy-params.dto.ts
@@ -0,0 +1,12 @@
+import { ApiProperty } from '@nestjs/swagger';
+import { IsNotEmpty, IsString } from 'class-validator';
+
+export class MultitenancyParams {
+  @IsString()
+  @IsNotEmpty()
+  @ApiProperty({
+    required: true,
+    description: 'Specifies the tenant ID',
+  })
+  public tenantId: string;
+}
diff --git a/apps/shared/src/dto/pagination-params.dto.ts b/apps/shared/src/dto/pagination-params.dto.ts
new file mode 100644
index 0000000..262663e
--- /dev/null
+++ b/apps/shared/src/dto/pagination-params.dto.ts
@@ -0,0 +1,26 @@
+import { ApiProperty } from '@nestjs/swagger';
+import { Type } from 'class-transformer';
+import { IsNumber, IsOptional, Min } from 'class-validator';
+
+export class PaginationParams {
+  @IsNumber()
+  @Min(1)
+  @Type(() => Number)
+  @IsOptional()
+  @ApiProperty({
+    required: false,
+    description: 'Specifies the page number of a result set',
+  })
+  public page?: number;
+
+  @IsNumber()
+  @Min(1)
+  @Type(() => Number)
+  @IsOptional()
+  @ApiProperty({
+    required: false,
+    description:
+      'Specifies the number of items to return in a single page of a result set',
+  })
+  public pageSize?: number;
+}
diff --git a/apps/shared/src/index.ts b/apps/shared/src/index.ts
index 8fa24d3..d05de3d 100644
--- a/apps/shared/src/index.ts
+++ b/apps/shared/src/index.ts
@@ -9,3 +9,6 @@ export * from './events/didEvents.js';
 export * from './events/tenantEvents.js';
 export * from './events/schemaEvents.js';
 export * from './events/credentialDefinitionEvents.js';
+
+export * from './dto/pagination-params.dto.js';
+export * from './dto/multitenancy-params.dto.js';
-- 
GitLab