@visulima/pagination 4.0.3 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## @visulima/pagination [4.0.4](https://github.com/visulima/visulima/compare/@visulima/pagination@4.0.3...@visulima/pagination@4.0.4) (2025-11-12)
2
+
3
+ ### Bug Fixes
4
+
5
+ * update package configurations and TypeScript definitions ([b59aa59](https://github.com/visulima/visulima/commit/b59aa59dac1508216b944f4b917fb4a7ab1f70a4))
6
+
7
+ ### Miscellaneous Chores
8
+
9
+ * Add jsr file to all packages for release ([#565](https://github.com/visulima/visulima/issues/565)) ([ec91652](https://github.com/visulima/visulima/commit/ec91652b4e4112adf14ba152c1239a7703ba425a))
10
+ * update license files and clean up TypeScript definitions ([fe668cc](https://github.com/visulima/visulima/commit/fe668cc26de23591d4df54a0954455ebbe31b22d))
11
+
1
12
  ## @visulima/pagination [4.0.3](https://github.com/visulima/visulima/compare/@visulima/pagination@4.0.2...@visulima/pagination@4.0.3) (2025-11-07)
2
13
 
3
14
  ### Bug Fixes
package/LICENSE.md CHANGED
@@ -67,11 +67,14 @@ Repository: https://github.com/payloadcms/qs-esm.git
67
67
  <!-- TYPE_DEPENDENCIES -->
68
68
 
69
69
  # Licenses of bundled types
70
+
70
71
  The published @visulima/pagination artifact additionally contains code with the following licenses:
71
72
  MIT
72
73
 
73
74
  # Bundled types:
75
+
74
76
  ## openapi-types
77
+
75
78
  License: MIT
76
79
  By: Joseph Spencer
77
80
  Repository: https://github.com/kogosoftwarellc/open-api/tree/master/packages/openapi-types
package/dist/index.d.ts CHANGED
@@ -1,400 +1,5 @@
1
- interface PaginationMeta {
2
- firstPage: number;
3
- firstPageUrl: string | null;
4
- lastPage: number;
5
- lastPageUrl: string | null;
6
- nextPageUrl: string | null;
7
- page: number;
8
- perPage: number;
9
- previousPageUrl: string | null;
10
- total: number;
11
- }
12
-
13
- interface PaginationResult<Result> {
14
- data: Result[];
15
- meta: PaginationMeta;
16
- }
17
-
18
- interface Paginator$1<Result> extends Array<Result> {
19
- all: () => Result[];
20
-
21
- baseUrl: (url: string) => this;
22
- readonly currentPage: number;
23
- readonly firstPage: number;
24
- getMeta: () => PaginationMeta;
25
- getNextPageUrl: () => string | null;
26
- getPreviousPageUrl: () => string | null;
27
- getUrl: (page: number) => string;
28
- getUrlsForRange: (start: number, end: number) => { isActive: boolean; page: number; url: string }[];
29
- readonly hasMorePages: boolean;
30
-
31
- readonly hasPages: boolean;
32
- readonly hasTotal: boolean;
33
- readonly isEmpty: boolean;
34
- readonly lastPage: number;
35
- readonly perPage: number;
36
- queryString: (values: Record<string, unknown>) => this;
37
- toJSON: () => PaginationResult<Result>;
38
- readonly total: number;
39
- }
40
-
41
- type UrlsForRange = {
42
- isActive: boolean;
43
- page: number;
44
- url: string;
45
- }[];
46
- declare class Paginator<T = unknown> extends Array<T> implements Paginator$1<T> {
47
- private readonly totalNumber;
48
- readonly perPage: number;
49
- currentPage: number;
50
- readonly firstPage: number;
51
- readonly isEmpty: boolean;
52
- private qs;
53
- private readonly rows;
54
- private url;
55
- constructor(totalNumber: number, perPage: number, currentPage: number, ...rows: T[]);
56
- all(): T[];
57
- baseUrl(url: string): this;
58
- getMeta(): PaginationMeta;
59
- getNextPageUrl(): string | null;
60
- getPreviousPageUrl(): string | null;
61
- getUrl(page: number): string;
62
- getUrlsForRange(start: number, end: number): UrlsForRange;
63
- queryString(values: Record<string, unknown>): this;
64
- toJSON(): PaginationResult<T>;
65
- get hasMorePages(): boolean;
66
- get hasPages(): boolean;
67
- get hasTotal(): boolean;
68
- get lastPage(): number;
69
- get total(): number;
70
- }
71
-
72
- declare namespace OpenAPIV3 {
73
- interface Document<T extends {} = {}> {
74
- openapi: string;
75
- info: InfoObject;
76
- servers?: ServerObject[];
77
- paths: PathsObject<T>;
78
- components?: ComponentsObject;
79
- security?: SecurityRequirementObject[];
80
- tags?: TagObject[];
81
- externalDocs?: ExternalDocumentationObject;
82
- 'x-express-openapi-additional-middleware'?: (((request: any, response: any, next: any) => Promise<void>) | ((request: any, response: any, next: any) => void))[];
83
- 'x-express-openapi-validation-strict'?: boolean;
84
- }
85
- interface InfoObject {
86
- title: string;
87
- description?: string;
88
- termsOfService?: string;
89
- contact?: ContactObject;
90
- license?: LicenseObject;
91
- version: string;
92
- }
93
- interface ContactObject {
94
- name?: string;
95
- url?: string;
96
- email?: string;
97
- }
98
- interface LicenseObject {
99
- name: string;
100
- url?: string;
101
- }
102
- interface ServerObject {
103
- url: string;
104
- description?: string;
105
- variables?: {
106
- [variable: string]: ServerVariableObject;
107
- };
108
- }
109
- interface ServerVariableObject {
110
- enum?: string[];
111
- default: string;
112
- description?: string;
113
- }
114
- interface PathsObject<T extends {} = {}, P extends {} = {}> {
115
- [pattern: string]: (PathItemObject<T> & P) | undefined;
116
- }
117
- enum HttpMethods {
118
- GET = "get",
119
- PUT = "put",
120
- POST = "post",
121
- DELETE = "delete",
122
- OPTIONS = "options",
123
- HEAD = "head",
124
- PATCH = "patch",
125
- TRACE = "trace"
126
- }
127
- type PathItemObject<T extends {} = {}> = {
128
- $ref?: string;
129
- summary?: string;
130
- description?: string;
131
- servers?: ServerObject[];
132
- parameters?: (ReferenceObject | ParameterObject)[];
133
- } & {
134
- [method in HttpMethods]?: OperationObject<T>;
135
- };
136
- type OperationObject<T extends {} = {}> = {
137
- tags?: string[];
138
- summary?: string;
139
- description?: string;
140
- externalDocs?: ExternalDocumentationObject;
141
- operationId?: string;
142
- parameters?: (ReferenceObject | ParameterObject)[];
143
- requestBody?: ReferenceObject | RequestBodyObject;
144
- responses: ResponsesObject;
145
- callbacks?: {
146
- [callback: string]: ReferenceObject | CallbackObject;
147
- };
148
- deprecated?: boolean;
149
- security?: SecurityRequirementObject[];
150
- servers?: ServerObject[];
151
- } & T;
152
- interface ExternalDocumentationObject {
153
- description?: string;
154
- url: string;
155
- }
156
- interface ParameterObject extends ParameterBaseObject {
157
- name: string;
158
- in: string;
159
- }
160
- interface HeaderObject extends ParameterBaseObject {
161
- }
162
- interface ParameterBaseObject {
163
- description?: string;
164
- required?: boolean;
165
- deprecated?: boolean;
166
- allowEmptyValue?: boolean;
167
- style?: string;
168
- explode?: boolean;
169
- allowReserved?: boolean;
170
- schema?: ReferenceObject | SchemaObject;
171
- example?: any;
172
- examples?: {
173
- [media: string]: ReferenceObject | ExampleObject;
174
- };
175
- content?: {
176
- [media: string]: MediaTypeObject;
177
- };
178
- }
179
- type NonArraySchemaObjectType = 'boolean' | 'object' | 'number' | 'string' | 'integer';
180
- type ArraySchemaObjectType = 'array';
181
- type SchemaObject = ArraySchemaObject | NonArraySchemaObject;
182
- interface ArraySchemaObject extends BaseSchemaObject {
183
- type: ArraySchemaObjectType;
184
- items: ReferenceObject | SchemaObject;
185
- }
186
- interface NonArraySchemaObject extends BaseSchemaObject {
187
- type?: NonArraySchemaObjectType;
188
- }
189
- interface BaseSchemaObject {
190
- title?: string;
191
- description?: string;
192
- format?: string;
193
- default?: any;
194
- multipleOf?: number;
195
- maximum?: number;
196
- exclusiveMaximum?: boolean;
197
- minimum?: number;
198
- exclusiveMinimum?: boolean;
199
- maxLength?: number;
200
- minLength?: number;
201
- pattern?: string;
202
- additionalProperties?: boolean | ReferenceObject | SchemaObject;
203
- maxItems?: number;
204
- minItems?: number;
205
- uniqueItems?: boolean;
206
- maxProperties?: number;
207
- minProperties?: number;
208
- required?: string[];
209
- enum?: any[];
210
- properties?: {
211
- [name: string]: ReferenceObject | SchemaObject;
212
- };
213
- allOf?: (ReferenceObject | SchemaObject)[];
214
- oneOf?: (ReferenceObject | SchemaObject)[];
215
- anyOf?: (ReferenceObject | SchemaObject)[];
216
- not?: ReferenceObject | SchemaObject;
217
- nullable?: boolean;
218
- discriminator?: DiscriminatorObject;
219
- readOnly?: boolean;
220
- writeOnly?: boolean;
221
- xml?: XMLObject;
222
- externalDocs?: ExternalDocumentationObject;
223
- example?: any;
224
- deprecated?: boolean;
225
- }
226
- interface DiscriminatorObject {
227
- propertyName: string;
228
- mapping?: {
229
- [value: string]: string;
230
- };
231
- }
232
- interface XMLObject {
233
- name?: string;
234
- namespace?: string;
235
- prefix?: string;
236
- attribute?: boolean;
237
- wrapped?: boolean;
238
- }
239
- interface ReferenceObject {
240
- $ref: string;
241
- }
242
- interface ExampleObject {
243
- summary?: string;
244
- description?: string;
245
- value?: any;
246
- externalValue?: string;
247
- }
248
- interface MediaTypeObject {
249
- schema?: ReferenceObject | SchemaObject;
250
- example?: any;
251
- examples?: {
252
- [media: string]: ReferenceObject | ExampleObject;
253
- };
254
- encoding?: {
255
- [media: string]: EncodingObject;
256
- };
257
- }
258
- interface EncodingObject {
259
- contentType?: string;
260
- headers?: {
261
- [header: string]: ReferenceObject | HeaderObject;
262
- };
263
- style?: string;
264
- explode?: boolean;
265
- allowReserved?: boolean;
266
- }
267
- interface RequestBodyObject {
268
- description?: string;
269
- content: {
270
- [media: string]: MediaTypeObject;
271
- };
272
- required?: boolean;
273
- }
274
- interface ResponsesObject {
275
- [code: string]: ReferenceObject | ResponseObject;
276
- }
277
- interface ResponseObject {
278
- description: string;
279
- headers?: {
280
- [header: string]: ReferenceObject | HeaderObject;
281
- };
282
- content?: {
283
- [media: string]: MediaTypeObject;
284
- };
285
- links?: {
286
- [link: string]: ReferenceObject | LinkObject;
287
- };
288
- }
289
- interface LinkObject {
290
- operationRef?: string;
291
- operationId?: string;
292
- parameters?: {
293
- [parameter: string]: any;
294
- };
295
- requestBody?: any;
296
- description?: string;
297
- server?: ServerObject;
298
- }
299
- interface CallbackObject {
300
- [url: string]: PathItemObject;
301
- }
302
- interface SecurityRequirementObject {
303
- [name: string]: string[];
304
- }
305
- interface ComponentsObject {
306
- schemas?: {
307
- [key: string]: ReferenceObject | SchemaObject;
308
- };
309
- responses?: {
310
- [key: string]: ReferenceObject | ResponseObject;
311
- };
312
- parameters?: {
313
- [key: string]: ReferenceObject | ParameterObject;
314
- };
315
- examples?: {
316
- [key: string]: ReferenceObject | ExampleObject;
317
- };
318
- requestBodies?: {
319
- [key: string]: ReferenceObject | RequestBodyObject;
320
- };
321
- headers?: {
322
- [key: string]: ReferenceObject | HeaderObject;
323
- };
324
- securitySchemes?: {
325
- [key: string]: ReferenceObject | SecuritySchemeObject;
326
- };
327
- links?: {
328
- [key: string]: ReferenceObject | LinkObject;
329
- };
330
- callbacks?: {
331
- [key: string]: ReferenceObject | CallbackObject;
332
- };
333
- }
334
- type SecuritySchemeObject = HttpSecurityScheme | ApiKeySecurityScheme | OAuth2SecurityScheme | OpenIdSecurityScheme;
335
- interface HttpSecurityScheme {
336
- type: 'http';
337
- description?: string;
338
- scheme: string;
339
- bearerFormat?: string;
340
- }
341
- interface ApiKeySecurityScheme {
342
- type: 'apiKey';
343
- description?: string;
344
- name: string;
345
- in: string;
346
- }
347
- interface OAuth2SecurityScheme {
348
- type: 'oauth2';
349
- description?: string;
350
- flows: {
351
- implicit?: {
352
- authorizationUrl: string;
353
- refreshUrl?: string;
354
- scopes: {
355
- [scope: string]: string;
356
- };
357
- };
358
- password?: {
359
- tokenUrl: string;
360
- refreshUrl?: string;
361
- scopes: {
362
- [scope: string]: string;
363
- };
364
- };
365
- clientCredentials?: {
366
- tokenUrl: string;
367
- refreshUrl?: string;
368
- scopes: {
369
- [scope: string]: string;
370
- };
371
- };
372
- authorizationCode?: {
373
- authorizationUrl: string;
374
- tokenUrl: string;
375
- refreshUrl?: string;
376
- scopes: {
377
- [scope: string]: string;
378
- };
379
- };
380
- };
381
- }
382
- interface OpenIdSecurityScheme {
383
- type: 'openIdConnect';
384
- description?: string;
385
- openIdConnectUrl: string;
386
- }
387
- interface TagObject {
388
- name: string;
389
- description?: string;
390
- externalDocs?: ExternalDocumentationObject;
391
- }
392
- }
393
-
394
- declare const createPaginationMetaSchemaObject: (name?: string) => Record<string, OpenAPIV3.SchemaObject>;
395
- declare const createPaginationSchemaObject: (name: string, items: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject, metaReference?: string) => Record<string, OpenAPIV3.SchemaObject>;
396
-
397
- declare const paginate: <Result>(page: number, perPage: number, total: number, rows: Result[]) => Paginator$1<Result>;
398
-
399
- export { Paginator, createPaginationMetaSchemaObject, createPaginationSchemaObject, paginate };
400
- export type { PaginationMeta, PaginationResult, Paginator$1 as PaginatorInterface };
1
+ import type { Paginator as PaginatorInterface } from "./types.d.d.ts";
2
+ export { default as Paginator } from "./paginator.d.ts";
3
+ export { createPaginationMetaSchemaObject, createPaginationSchemaObject } from "./swagger.d.ts";
4
+ export declare const paginate: <Result>(page: number, perPage: number, total: number, rows: Result[]) => PaginatorInterface<Result>;
5
+ export type { PaginationMeta, PaginationResult, Paginator as PaginatorInterface } from "./types.d.ts";
@@ -0,0 +1,90 @@
1
+ import type { PaginationMeta, PaginationResult, Paginator as IPaginator } from "./types.d.d.ts";
2
+ type UrlsForRange = {
3
+ isActive: boolean;
4
+ page: number;
5
+ url: string;
6
+ }[];
7
+ /**
8
+ * Simple paginator works with the data set provided by the standard
9
+ * `offset` and `limit` based pagination.
10
+ */
11
+ export default class Paginator<T = unknown> extends Array<T> implements IPaginator<T> {
12
+ private readonly totalNumber;
13
+ readonly perPage: number;
14
+ currentPage: number;
15
+ /**
16
+ * The first page is always 1
17
+ */
18
+ readonly firstPage: number;
19
+ /**
20
+ * Find if results set is empty or not
21
+ */
22
+ readonly isEmpty: boolean;
23
+ private qs;
24
+ private readonly rows;
25
+ private url;
26
+ constructor(totalNumber: number, perPage: number, currentPage: number, ...rows: T[]);
27
+ /**
28
+ * A reference to the result rows.
29
+ */
30
+ all(): T[];
31
+ /**
32
+ * Define base url for making the pagination links.
33
+ */
34
+ baseUrl(url: string): this;
35
+ /**
36
+ * Returns JSON meta data.
37
+ */
38
+ getMeta(): PaginationMeta;
39
+ /**
40
+ * Returns url for the next page.
41
+ */
42
+ getNextPageUrl(): string | null;
43
+ /**
44
+ * Returns URL for the previous page.
45
+ */
46
+ getPreviousPageUrl(): string | null;
47
+ /**
48
+ * Returns url for a given page. Doesn't validate the integrity of the
49
+ * page.
50
+ */
51
+ getUrl(page: number): string;
52
+ /**
53
+ * Returns an array of urls under a given range.
54
+ */
55
+ getUrlsForRange(start: number, end: number): UrlsForRange;
56
+ /**
57
+ * Define query string to be appended to the pagination links.
58
+ */
59
+ queryString(values: Record<string, unknown>): this;
60
+ /**
61
+ * Returns JSON representation of the paginated data.
62
+ */
63
+ toJSON(): PaginationResult<T>;
64
+ /**
65
+ * Find if there are more pages to come.
66
+ */
67
+ get hasMorePages(): boolean;
68
+ /**
69
+ * Find if there are enough results to be paginated or not.
70
+ */
71
+ get hasPages(): boolean;
72
+ /**
73
+ * Find if there are total records or not. This is not same as
74
+ * `isEmpty`.
75
+ *
76
+ * The `isEmpty` reports about the current set of results. However, `hasTotal`
77
+ * reports about the total number of records, regardless of the current.
78
+ */
79
+ get hasTotal(): boolean;
80
+ /**
81
+ * The Last page number.
82
+ */
83
+ get lastPage(): number;
84
+ /**
85
+ * Casting `total` to a number. Later, we can think of situations
86
+ * to cast it to a bigint.
87
+ */
88
+ get total(): number;
89
+ }
90
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { OpenAPIV3 } from "openapi-types";
2
+ export declare const createPaginationMetaSchemaObject: (name?: string) => Record<string, OpenAPIV3.SchemaObject>;
3
+ export declare const createPaginationSchemaObject: (name: string, items: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject, metaReference?: string) => Record<string, OpenAPIV3.SchemaObject>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/pagination",
3
- "version": "4.0.3",
3
+ "version": "4.0.4",
4
4
  "description": "Simple Pagination for Node.",
5
5
  "keywords": [
6
6
  "anolilab",