원클릭으로
getting-started
Offset and Keyset pagination for NestJS applications. Use when an endpoints need a paginated response.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Offset and Keyset pagination for NestJS applications. Use when an endpoints need a paginated response.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Use when scanning NestJS providers with DiscoveryService-backed utilities.
Use when working with the @wisemen/nestjs-custom-fields package — developer-defined custom fields in NestJS with TypeORM persistence and runtime validation. Covers registering the CustomFieldDefinition entity, authoring definitions with customFieldDefinition(), storing resolved values via @CustomFieldValueColumn(), exposing them through CustomFieldValueDto / @IsCustomFields(), and validating submissions with CustomFieldDefinitionsRepository + validateCustomFieldValues(). Use this whenever a task involves custom field definitions, CustomFieldValue columns, custom-field DTOs, or tenant-scoped field definitions, even if the package is not named explicitly.
Use when defining Typesense collections, collectors, and search queries in NestJS APIs.
Generate PDFs through API2PDF in NestJS. Use when converting HTML or URLs to PDFs in apis.
Use when storing and validating multilingual text in NestJS apis with TypeORM and class-validator.
Use when configuring NATS messaging, subscribers, or the simple NatsClient in NestJS applications.
| name | getting-started |
| description | Offset and Keyset pagination for NestJS applications. Use when an endpoints need a paginated response. |
import { PaginatedOffsetSearchQuery, PaginatedOffsetResponse, PaginatedOffsetResponseMeta, PaginatedKeysetQuery, PaginatedKeysetResponse, typeormPagination, KeysetDirection, } from '@wisemen/pagination'
export class ViewJobsIndexQueryKey {
@ApiProperty({ type: 'string', format: 'date-time', required: false })
@IsDateString({ strict: true })
createdAt: string
@ApiProperty({ type: 'string' })
@IsString()
@IsNotEmpty()
id: string
static nextKey (jobs: ViewJobsIndexJob[]): ViewJobsIndexQueryKey | null {
if (jobs.length == 0) {
return null
}
const lastItem = jobs.at(-1) as ViewJobsIndexJob
return this.from(lastItem)
}
static from (job: ViewJobsIndexJob): ViewJobsIndexQueryKey {
const key = new ViewJobsIndexQueryKey()
key.createdAt = job.createdAt
key.id = job.id
return key
}
}
export class ViewJobsIndexPaginationQuery extends PaginatedKeysetQuery {
@ApiProperty({ type: ViewJobsIndexQueryKey, required: false, nullable: true })
@Type(() => ViewJobsIndexQueryKey)
@ValidateNested()
@IsObject()
@IsOptional()
key?: ViewJobsIndexQueryKey | null
}
class ViewJobsIndexResponseMeta implements PaginatedKeysetResponseMeta {
@ApiProperty({ type: ViewJobsIndexQueryKey, nullable: true })
next: ViewJobsIndexQueryKey | null
constructor (jobs: ViewJobsIndexJob[]) {
this.next = ViewJobsIndexQueryKey.nextKey(jobs)
}
}
Typically keyset pagination can be used in combination with @wisemen/nestjs-typeorm.
The key is then typically the lastEntity parameter for the findNextBatch method on the repository.
// 1. Define your search query DTO
import { PaginatedOffsetSearchQuery } from '@wisemen/pagination'
import { IsString } from 'class-validator'
import { IsUndefinable } from '@wisemen/validators'
export class ViewUserIndexQuery extends PaginatedOffsetSearchQuery {
@Equals(undefined)
sort: never
@Equals(undefined)
filter: never
@IsString()
@IsUndefinable()
search?: string
}
// 2. Define your response DTO
import { ApiProperty } from '@nestjs/swagger'
import { PaginatedOffsetResponse } from '@wisemen/pagination'
class ViewUserIndexItemResponse{
@ApiProperty({ type: String, format: 'uuid' })
uuid: UserUuid
@ApiProperty({ type: String})
name: string
constructor (user: User) {
this.uuid = user.uuid
this.name = user.name
}
}
export class ViewUserIndexResponse extends PaginatedOffsetResponse<UserIndexView> {
@ApiProperty({ type: UserIndexView, isArray: true })
declare items: UserIndexView[]
constructor (users: User[]) {
const userViews = users.map(user => new UserIndexView(user))
super(userViews, users.meta)
}
}
`PaginatedOffsetSearchQuery` provides `pagination?: { offset, limit }` with validation and Swagger docs. `typeormPagination()` maps it to `{ skip, take }`.