@visulima/pagination 5.0.0-alpha.9 → 5.0.0

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,154 @@
1
+ ## @visulima/pagination [5.0.0](https://github.com/visulima/visulima/compare/@visulima/pagination@4.0.5...@visulima/pagination@5.0.0) (2026-07-03)
2
+
3
+ ### ⚠ BREAKING CHANGES
4
+
5
+ * change min node version to 22.13
6
+
7
+ ### Features
8
+
9
+ * **pagination:** fix docs, add cursor/window pagination + openapi nullability ([d33feb8](https://github.com/visulima/visulima/commit/d33feb85ad49a1336c55b5ab12a18a80c9a776b0))
10
+ * **web:** auto-generate packages page from workspace metadata ([623e520](https://github.com/visulima/visulima/commit/623e5207693a7fe720f5f2f179593a3654c880e3))
11
+
12
+ ### Bug Fixes
13
+
14
+ * add new package image, fixed readme rendering on npm, fixed building of packages ([b790ba2](https://github.com/visulima/visulima/commit/b790ba253ea07fef83528fd822a678facf021b5f))
15
+ * **api:** resolve eslint and type-safety issues across api packages ([3601491](https://github.com/visulima/visulima/commit/3601491261de56b5cfad87c97daafd458e4ee3b6))
16
+ * **jsdoc-open-api:** combine name and description for path-based YAML parsing ([68e7d23](https://github.com/visulima/visulima/commit/68e7d2395ab97de3221892afe03da27688df7569))
17
+ * **pagination:** 3 bug fixes ([bcc5dbf](https://github.com/visulima/visulima/commit/bcc5dbf91aac391b3df1d83d6a1850a7b4bdbcc2))
18
+ * **pagination:** accept rows as an array, not variadic ([f4c3940](https://github.com/visulima/visulima/commit/f4c3940a7c799b32f1639473c01e2d43426f3c0c))
19
+ * **pagination:** remove unnecessary Number() type conversions ([1393f87](https://github.com/visulima/visulima/commit/1393f8721e3824af7fdf59361ddd1e445bc2bff5))
20
+ * **pagination:** update package files ([008ea06](https://github.com/visulima/visulima/commit/008ea06ff573a61eaabbc913f9dbe436b4943d67))
21
+ * **pagination:** update packem to 2.0.0-alpha.54 ([6fd896e](https://github.com/visulima/visulima/commit/6fd896ed94b501df1ec85baff72015e5d8112540))
22
+ * Remove JSR configuration generation script and generated jsr.json files ([#616](https://github.com/visulima/visulima/issues/616)) ([533744b](https://github.com/visulima/visulima/commit/533744b103b74896941db5b727173e617a27a63b))
23
+ * **storage-client:** percent-encode user fields in defaultFingerprint ([7c78a0f](https://github.com/visulima/visulima/commit/7c78a0f9512e2a673b941d80839e9f1e86b7b5d0))
24
+ * update Node.js engine version requirement to >=22.13 in multiple package.json files for improved compatibility ([b828e9a](https://github.com/visulima/visulima/commit/b828e9aeaebfc798eecddccd90e6ec7560c6d36a))
25
+ * update package OG images across multiple packages ([f08e4dd](https://github.com/visulima/visulima/commit/f08e4dd2b105ccb29c8412020a9c2be36d6c1e9e))
26
+ * update package.json description and keywords ([#578](https://github.com/visulima/visulima/issues/578)) ([154709c](https://github.com/visulima/visulima/commit/154709c05e71d1ffd3e360b27e12febd817912f0))
27
+ * **web:** improve build setup with incremental stats caching and prod install ([fe33e75](https://github.com/visulima/visulima/commit/fe33e75827586779b4b3a0c6d57b39f889ee6207))
28
+
29
+ ### Documentation
30
+
31
+ * **crud,health-check,pagination:** add comprehensive Fumadocs documentation ([1fc3748](https://github.com/visulima/visulima/commit/1fc3748b2d9b1ef2332b5d38cb6dd2c7c1f78589))
32
+
33
+ ### Styles
34
+
35
+ * cs fixes ([2a960bb](https://github.com/visulima/visulima/commit/2a960bb1772c9dc70080e2d75d3a0d827034e294))
36
+
37
+ ### Miscellaneous Chores
38
+
39
+ * add fallow code-intelligence across all packages ([a3b4821](https://github.com/visulima/visulima/commit/a3b48215002e86fed20f2973038b5d4a0aa1ce04))
40
+ * **api:** remove empty dependency objects from package.json ([f6bfc85](https://github.com/visulima/visulima/commit/f6bfc85c48c973ff8ea0a7db5951794ae0ea3efb))
41
+ * **api:** update dependencies ([f3b6f7c](https://github.com/visulima/visulima/commit/f3b6f7c956e8ae2c0da67773b3790f159c07de29))
42
+ * apply eslint + prettier autofixes across packages ([c1bb784](https://github.com/visulima/visulima/commit/c1bb7848a0d93d0dfe2960c77e3cda22239c79a0))
43
+ * bump engines.node to ^22.14.0 || >=24.10.0 ([c3d0931](https://github.com/visulima/visulima/commit/c3d0931d1504e4f21ebf50ea680cfa7ce4ba15ce))
44
+ * **ci-stability:** green CI across vis, native, lint, tests, attw ([#651](https://github.com/visulima/visulima/issues/651)) ([d4eb684](https://github.com/visulima/visulima/commit/d4eb684b5f75c818c9251048c605a0ed54a268e3))
45
+ * fixed jsr.json ([5d85e51](https://github.com/visulima/visulima/commit/5d85e5179de38e284ec433b14d77c71a1619c8d6))
46
+ * fixed project.json names and schema path ([964722f](https://github.com/visulima/visulima/commit/964722f691db205c7edb9aa6db29e849a647500b))
47
+ * moved all packages into groups ([0615e9d](https://github.com/visulima/visulima/commit/0615e9d14a8a886e11da529ce150cf31ca973c10))
48
+ * **pagination:** add tsconfig.eslint.json for type-aware linting ([d66266c](https://github.com/visulima/visulima/commit/d66266cf401e974d7dda3418228daa06d6ec7253))
49
+ * **pagination:** apply auto-fix formatting ([343ccc0](https://github.com/visulima/visulima/commit/343ccc01b8e398f11bd592f865dec6d04b3a8fca))
50
+ * **pagination:** apply formatting ([52c9c3b](https://github.com/visulima/visulima/commit/52c9c3b312d9e918235e2403918539a653c53a87))
51
+ * **pagination:** apply prettier formatting ([8e4e960](https://github.com/visulima/visulima/commit/8e4e9609ac04bd3aee32ba8b73af49d995849fe2))
52
+ * **pagination:** housekeeping cleanup ([bfd1f8f](https://github.com/visulima/visulima/commit/bfd1f8fb9263481b7bda22f5000c8b5aed49e62e))
53
+ * **pagination:** migrate .prettierrc.cjs to prettier.config.js ([17c14e6](https://github.com/visulima/visulima/commit/17c14e69da0aa3beee75631cb33266fd41060e86))
54
+ * **pagination:** migrate deps to pnpm catalogs ([ddb084e](https://github.com/visulima/visulima/commit/ddb084e6376edf13378862ea2d2196edcc24d310))
55
+ * **pagination:** reformat long lines and normalize markdown italics ([8467425](https://github.com/visulima/visulima/commit/84674254fb5dcb2fcab600abe3f006b41bfabb88))
56
+ * **pagination:** update dependencies ([31339af](https://github.com/visulima/visulima/commit/31339afb17bf8e0c3d0b4a4e9d7ec9645db2dda8))
57
+ * **pagination:** update dependencies ([b47aee3](https://github.com/visulima/visulima/commit/b47aee327e28ba302f7c60cfc3cae3db5b2a101f))
58
+ * **pagination:** upgrade packem to 2.0.0-alpha.76 ([443e12d](https://github.com/visulima/visulima/commit/443e12d4f90977f1d807d5d4d73f0bc17c2bd044))
59
+ * re-sort workspace package.json files via vis sort-package-json ([f625696](https://github.com/visulima/visulima/commit/f625696cfac974325774b3243e1a83c3d23acbd7))
60
+ * **release:** @visulima/pagination@5.0.0-alpha.1 [skip ci]\n\n## @visulima/pagination [5.0.0-alpha.1](https://github.com/visulima/visulima/compare/@visulima/pagination@4.0.5...@visulima/pagination@5.0.0-alpha.1) (2025-12-04) ([98c157b](https://github.com/visulima/visulima/commit/98c157b555416ce0e83e4c0d35a3a3ec6e542c68))
61
+ * **release:** @visulima/pagination@5.0.0-alpha.10 [skip ci]\n\n## @visulima/pagination [5.0.0-alpha.10](https://github.com/visulima/visulima/compare/@visulima/pagination@5.0.0-alpha.9...@visulima/pagination@5.0.0-alpha.10) (2026-04-15) ([8062a52](https://github.com/visulima/visulima/commit/8062a527c8338941f30c38d29ed1f655cca72b0c))
62
+ * **release:** @visulima/pagination@5.0.0-alpha.11 [skip ci]\n\n## @visulima/pagination [5.0.0-alpha.11](https://github.com/visulima/visulima/compare/@visulima/pagination@5.0.0-alpha.10...@visulima/pagination@5.0.0-alpha.11) (2026-04-22) ([df73344](https://github.com/visulima/visulima/commit/df733440ff8e7f375f7691639f084af060e3fa71))
63
+ * **release:** @visulima/pagination@5.0.0-alpha.12 [skip ci]\n\n## @visulima/pagination [5.0.0-alpha.12](https://github.com/visulima/visulima/compare/@visulima/pagination@5.0.0-alpha.11...@visulima/pagination@5.0.0-alpha.12) (2026-05-27) ([0e762b6](https://github.com/visulima/visulima/commit/0e762b60dbdc6a3d5a8c9d42b7181d51bba3115b))
64
+ * **release:** @visulima/pagination@5.0.0-alpha.13 [skip ci]\n\n## @visulima/pagination [5.0.0-alpha.13](https://github.com/visulima/visulima/compare/@visulima/pagination@5.0.0-alpha.12...@visulima/pagination@5.0.0-alpha.13) (2026-06-04) ([039acc4](https://github.com/visulima/visulima/commit/039acc4e83ba8b8c63aedcc54a9f7d619a87a211))
65
+ * **release:** @visulima/pagination@5.0.0-alpha.14 [skip ci]\n\n## @visulima/pagination [5.0.0-alpha.14](https://github.com/visulima/visulima/compare/@visulima/pagination@5.0.0-alpha.13...@visulima/pagination@5.0.0-alpha.14) (2026-06-13) ([2fb0fa4](https://github.com/visulima/visulima/commit/2fb0fa4e4507825be1e778f4eecea24b866dfda0))
66
+ * **release:** @visulima/pagination@5.0.0-alpha.2 [skip ci]\n\n## @visulima/pagination [5.0.0-alpha.2](https://github.com/visulima/visulima/compare/@visulima/pagination@5.0.0-alpha.1...@visulima/pagination@5.0.0-alpha.2) (2025-12-06) ([d40d825](https://github.com/visulima/visulima/commit/d40d825fb9c38ec598d9d7d66352a5b938ea1dc7))
67
+ * **release:** @visulima/pagination@5.0.0-alpha.3 [skip ci]\n\n## @visulima/pagination [5.0.0-alpha.3](https://github.com/visulima/visulima/compare/@visulima/pagination@5.0.0-alpha.2...@visulima/pagination@5.0.0-alpha.3) (2025-12-11) ([c980e7d](https://github.com/visulima/visulima/commit/c980e7d7f4cfa93ef3ebcb71d36e6d90bc5ed2e4))
68
+ * **release:** @visulima/pagination@5.0.0-alpha.4 [skip ci]\n\n## @visulima/pagination [5.0.0-alpha.4](https://github.com/visulima/visulima/compare/@visulima/pagination@5.0.0-alpha.3...@visulima/pagination@5.0.0-alpha.4) (2025-12-27) ([ab7cd49](https://github.com/visulima/visulima/commit/ab7cd498492161e98b85ba2274ffc09776e7ad5f))
69
+ * **release:** @visulima/pagination@5.0.0-alpha.5 [skip ci]\n\n## @visulima/pagination [5.0.0-alpha.5](https://github.com/visulima/visulima/compare/@visulima/pagination@5.0.0-alpha.4...@visulima/pagination@5.0.0-alpha.5) (2026-01-17) ([9d08240](https://github.com/visulima/visulima/commit/9d082409368bab361163d3fe8704793681a6da7f))
70
+ * **release:** @visulima/pagination@5.0.0-alpha.6 [skip ci]\n\n## @visulima/pagination [5.0.0-alpha.6](https://github.com/visulima/visulima/compare/@visulima/pagination@5.0.0-alpha.5...@visulima/pagination@5.0.0-alpha.6) (2026-03-06) ([ccae713](https://github.com/visulima/visulima/commit/ccae713c6a741f0e6d53b6e7c890c200dbcce9da))
71
+ * **release:** @visulima/pagination@5.0.0-alpha.7 [skip ci]\n\n## @visulima/pagination [5.0.0-alpha.7](https://github.com/visulima/visulima/compare/@visulima/pagination@5.0.0-alpha.6...@visulima/pagination@5.0.0-alpha.7) (2026-03-26) ([800ba4f](https://github.com/visulima/visulima/commit/800ba4fe478f5371f23ac22c07daa33fc48e68c7))
72
+ * **release:** @visulima/pagination@5.0.0-alpha.8 [skip ci]\n\n## @visulima/pagination [5.0.0-alpha.8](https://github.com/visulima/visulima/compare/@visulima/pagination@5.0.0-alpha.7...@visulima/pagination@5.0.0-alpha.8) (2026-03-26) ([6dca8de](https://github.com/visulima/visulima/commit/6dca8deeff47966e4b903c2b4cd9ab704468cace))
73
+ * **release:** @visulima/pagination@5.0.0-alpha.9 [skip ci]\n\n## @visulima/pagination [5.0.0-alpha.9](https://github.com/visulima/visulima/compare/@visulima/pagination@5.0.0-alpha.8...@visulima/pagination@5.0.0-alpha.9) (2026-04-08) ([94fe558](https://github.com/visulima/visulima/commit/94fe558e654dfdfd9c823e29588b6f17eda8d696))
74
+ * **repo:** sort package.json keys across all packages ([e1fd9ab](https://github.com/visulima/visulima/commit/e1fd9ab467ef96a98c777da1572ff6a50fcf7e71))
75
+ * sorted package.json ([b47c545](https://github.com/visulima/visulima/commit/b47c545591600fdab17d5cd3a3fbc68b61e199da))
76
+ * update @anolilab/semantic-release-pnpm and @anolilab/semantic-release-preset to versions 3.2.2 and 12.1.2 across multiple package.json files for improved compatibility ([3921626](https://github.com/visulima/visulima/commit/3921626141fe5da398749bf0ba675f1596f18afb))
77
+ * update dependencies across multiple packages to improve compatibility and performance, including upgrading `@anolilab/semantic-release-pnpm` and `@anolilab/semantic-release-preset` to versions 3.2.0 and 12.1.0 respectively, and updating `react`, `react-dom`, and `next` versions to 19.2.1 and 16.0.7 in various package.json files ([aee8fcd](https://github.com/visulima/visulima/commit/aee8fcd796ae9b8d055903260e7150996ea9f53d))
78
+ * update homepage URLs to visulima.com/packages/ format ([be42968](https://github.com/visulima/visulima/commit/be42968129df85fb074224435e33135ff44cab91))
79
+ * update lock file maintenance ([d83e716](https://github.com/visulima/visulima/commit/d83e71697b75d24704185b66bb521a934d2db02d))
80
+ * visulima website ([#591](https://github.com/visulima/visulima/issues/591)) ([59ab2e2](https://github.com/visulima/visulima/commit/59ab2e2befb03e51cd2088956f83d9b87de6d033))
81
+ * year update ([47f4105](https://github.com/visulima/visulima/commit/47f410596ce7190cfea36a073db32e0cec50bbcd))
82
+
83
+ ### Tests
84
+
85
+ * **repo:** add dist runtime + types integration tests ([32ee300](https://github.com/visulima/visulima/commit/32ee300b7184117a0ddf9f9d390f75f8932d5ed9))
86
+
87
+ ### Continuous Integration
88
+
89
+ * **fallow:** make fallow:health advisory (--report-only) ([d57148e](https://github.com/visulima/visulima/commit/d57148ea0e3556b4c24d8d336b9fa14987f5dc7d))
90
+
91
+ ## @visulima/pagination [5.0.0-alpha.14](https://github.com/visulima/visulima/compare/@visulima/pagination@5.0.0-alpha.13...@visulima/pagination@5.0.0-alpha.14) (2026-06-13)
92
+
93
+ ### Features
94
+
95
+ * **pagination:** fix docs, add cursor/window pagination + openapi nullability ([d33feb8](https://github.com/visulima/visulima/commit/d33feb85ad49a1336c55b5ab12a18a80c9a776b0))
96
+
97
+ ### Bug Fixes
98
+
99
+ * **pagination:** accept rows as an array, not variadic ([f4c3940](https://github.com/visulima/visulima/commit/f4c3940a7c799b32f1639473c01e2d43426f3c0c))
100
+
101
+ ### Miscellaneous Chores
102
+
103
+ * **pagination:** apply formatting ([52c9c3b](https://github.com/visulima/visulima/commit/52c9c3b312d9e918235e2403918539a653c53a87))
104
+ * **pagination:** reformat long lines and normalize markdown italics ([8467425](https://github.com/visulima/visulima/commit/84674254fb5dcb2fcab600abe3f006b41bfabb88))
105
+
106
+ ## @visulima/pagination [5.0.0-alpha.13](https://github.com/visulima/visulima/compare/@visulima/pagination@5.0.0-alpha.12...@visulima/pagination@5.0.0-alpha.13) (2026-06-04)
107
+
108
+ ### Bug Fixes
109
+
110
+ * **pagination:** 3 bug fixes ([bcc5dbf](https://github.com/visulima/visulima/commit/bcc5dbf91aac391b3df1d83d6a1850a7b4bdbcc2))
111
+
112
+ ### Miscellaneous Chores
113
+
114
+ * apply eslint + prettier autofixes across packages ([c1bb784](https://github.com/visulima/visulima/commit/c1bb7848a0d93d0dfe2960c77e3cda22239c79a0))
115
+
116
+ ## @visulima/pagination [5.0.0-alpha.12](https://github.com/visulima/visulima/compare/@visulima/pagination@5.0.0-alpha.11...@visulima/pagination@5.0.0-alpha.12) (2026-05-27)
117
+
118
+ ### Bug Fixes
119
+
120
+ * **storage-client:** percent-encode user fields in defaultFingerprint ([7c78a0f](https://github.com/visulima/visulima/commit/7c78a0f9512e2a673b941d80839e9f1e86b7b5d0))
121
+
122
+ ### Miscellaneous Chores
123
+
124
+ * **ci-stability:** green CI across vis, native, lint, tests, attw ([#651](https://github.com/visulima/visulima/issues/651)) ([d4eb684](https://github.com/visulima/visulima/commit/d4eb684b5f75c818c9251048c605a0ed54a268e3))
125
+ * **pagination:** housekeeping cleanup ([bfd1f8f](https://github.com/visulima/visulima/commit/bfd1f8fb9263481b7bda22f5000c8b5aed49e62e))
126
+ * **pagination:** upgrade packem to 2.0.0-alpha.76 ([443e12d](https://github.com/visulima/visulima/commit/443e12d4f90977f1d807d5d4d73f0bc17c2bd044))
127
+ * re-sort workspace package.json files via vis sort-package-json ([f625696](https://github.com/visulima/visulima/commit/f625696cfac974325774b3243e1a83c3d23acbd7))
128
+ * **repo:** sort package.json keys across all packages ([e1fd9ab](https://github.com/visulima/visulima/commit/e1fd9ab467ef96a98c777da1572ff6a50fcf7e71))
129
+ * sorted package.json ([b47c545](https://github.com/visulima/visulima/commit/b47c545591600fdab17d5cd3a3fbc68b61e199da))
130
+
131
+ ### Tests
132
+
133
+ * **repo:** add dist runtime + types integration tests ([32ee300](https://github.com/visulima/visulima/commit/32ee300b7184117a0ddf9f9d390f75f8932d5ed9))
134
+
135
+ ## @visulima/pagination [5.0.0-alpha.11](https://github.com/visulima/visulima/compare/@visulima/pagination@5.0.0-alpha.10...@visulima/pagination@5.0.0-alpha.11) (2026-04-22)
136
+
137
+ ### Bug Fixes
138
+
139
+ * Remove JSR configuration generation script and generated jsr.json files ([#616](https://github.com/visulima/visulima/issues/616)) ([533744b](https://github.com/visulima/visulima/commit/533744b103b74896941db5b727173e617a27a63b))
140
+
141
+ ### Miscellaneous Chores
142
+
143
+ * bump engines.node to ^22.14.0 || >=24.10.0 ([c3d0931](https://github.com/visulima/visulima/commit/c3d0931d1504e4f21ebf50ea680cfa7ce4ba15ce))
144
+ * fixed jsr.json ([5d85e51](https://github.com/visulima/visulima/commit/5d85e5179de38e284ec433b14d77c71a1619c8d6))
145
+
146
+ ## @visulima/pagination [5.0.0-alpha.10](https://github.com/visulima/visulima/compare/@visulima/pagination@5.0.0-alpha.9...@visulima/pagination@5.0.0-alpha.10) (2026-04-15)
147
+
148
+ ### Bug Fixes
149
+
150
+ * **api:** resolve eslint and type-safety issues across api packages ([3601491](https://github.com/visulima/visulima/commit/3601491261de56b5cfad87c97daafd458e4ee3b6))
151
+
1
152
  ## @visulima/pagination [5.0.0-alpha.9](https://github.com/visulima/visulima/compare/@visulima/pagination@5.0.0-alpha.8...@visulima/pagination@5.0.0-alpha.9) (2026-04-08)
2
153
 
3
154
  ### Bug Fixes
package/LICENSE.md CHANGED
@@ -23,11 +23,14 @@ SOFTWARE.
23
23
  <!-- DEPENDENCIES -->
24
24
 
25
25
  # Licenses of bundled dependencies
26
+
26
27
  The published @visulima/pagination artifact additionally contains code with the following licenses:
27
28
  BSD-3-Clause
28
29
 
29
30
  # Bundled dependencies:
31
+
30
32
  ## qs-esm
33
+
31
34
  License: BSD-3-Clause
32
35
  By: Payload, Jordan Harband
33
36
  Repository: https://github.com/payloadcms/qs-esm.git
@@ -42,11 +45,9 @@ Repository: https://github.com/payloadcms/qs-esm.git
42
45
  >
43
46
  > 1. Redistributions of source code must retain the above copyright notice, this
44
47
  > list of conditions and the following disclaimer.
45
- >
46
48
  > 2. Redistributions in binary form must reproduce the above copyright notice,
47
49
  > this list of conditions and the following disclaimer in the documentation
48
50
  > and/or other materials provided with the distribution.
49
- >
50
51
  > 3. Neither the name of the copyright holder nor the names of its
51
52
  > contributors may be used to endorse or promote products derived from
52
53
  > this software without specific prior written permission.
package/README.md CHANGED
@@ -36,6 +36,18 @@
36
36
 
37
37
  ## Features
38
38
 
39
+ - **Zero runtime dependencies** — tiny offset/limit paginator (Adonis-style).
40
+ - **`Paginator`** — an `Array` subclass holding the current page's rows, with rich meta (`total`, `lastPage`, first/last/next/previous URLs).
41
+ - **`CursorPaginator`** — cursor/keyset pagination for stable infinite scroll over large tables.
42
+ - **URL helpers** — `baseUrl()`, `queryString()`, `getUrl()`, `getUrlsForRange()`, and `getUrlsForWindow()` (windowed page links with `…` ellipsis markers).
43
+ - **Naming strategies** — emit `camelCase` (default) or `snake_case` (`per_page`, `last_page`, …) meta keys.
44
+ - **OpenAPI schema builders** — `createPaginationSchemaObject` / `createPaginationMetaSchemaObject`, with correct nullability + `required`, and an OpenAPI 3.1 variant.
45
+
46
+ > **Important:** `Paginator`/`paginate()` do **not** slice your rows. Pass in the
47
+ > rows for the current page already sliced at the data source
48
+ > (offset `(page - 1) * perPage`, limit `perPage`). `total` is the count of _all_
49
+ > matching records and is what drives `lastPage` and the URLs.
50
+
39
51
  ## Installation
40
52
 
41
53
  ```sh
@@ -52,30 +64,103 @@ pnpm add @visulima/pagination
52
64
 
53
65
  ## Usage
54
66
 
67
+ `paginate(page, perPage, total, rows)` returns a `Paginator` — an `Array`
68
+ subclass that holds the **current page's rows** (it does not slice them for you).
69
+ Call `.toJSON()` (or `JSON.stringify`) to get the `{ data, meta }` shape.
70
+
55
71
  ```ts
56
72
  import { paginate } from "@visulima/pagination";
57
73
 
58
- const items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
74
+ const allItems = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
75
+
76
+ const page = 1;
77
+ const perPage = 5;
59
78
 
60
- const pagination = paginate(1, 5, items.length, items);
79
+ // Slice the rows for the current page yourself (a real app would do this in SQL).
80
+ const pageRows = allItems.slice((page - 1) * perPage, page * perPage);
61
81
 
62
- console.log(pagination);
82
+ const pagination = paginate(page, perPage, allItems.length, pageRows);
83
+
84
+ console.log(pagination.toJSON());
63
85
  // {
64
86
  // data: [1, 2, 3, 4, 5],
65
87
  // meta: {
66
- // total: 10,
67
- // perPage: 5,
68
- // page: 1,
69
- // lastPage: 2,
70
88
  // firstPage: 1,
71
89
  // firstPageUrl: "/?page=1",
90
+ // lastPage: 2,
72
91
  // lastPageUrl: "/?page=2",
73
92
  // nextPageUrl: "/?page=2",
93
+ // page: 1,
94
+ // perPage: 5,
74
95
  // previousPageUrl: null,
96
+ // total: 10,
75
97
  // }
76
98
  // }
99
+
100
+ // Note: `console.log(pagination)` prints just the array rows ([1,2,3,4,5]),
101
+ // because `Paginator` extends `Array`. Use `.toJSON()` / `JSON.stringify` for
102
+ // the full `{ data, meta }` payload.
103
+ ```
104
+
105
+ ### URLs and query strings
106
+
107
+ ```ts
108
+ const p = paginate(2, 10, 200, pageRows).baseUrl("/api/items").queryString({ sort: "asc" });
109
+
110
+ p.getUrl(3); // "/api/items?sort=asc&page=3"
111
+ p.getNextPageUrl(); // "/api/items?sort=asc&page=3"
112
+ p.getPreviousPageUrl(); // "/api/items?sort=asc&page=1"
113
+
114
+ // Windowed page links with ellipsis markers (page === null => render "…").
115
+ p.getUrlsForWindow({ eachSide: 2 });
116
+ // [ {page:1,...}, {page:null,url:null,...}, ...window..., {page:null,url:null}, {page:20,...} ]
77
117
  ```
78
118
 
119
+ ### snake_case meta (Laravel / AdonisJS style)
120
+
121
+ ```ts
122
+ import { paginate, snakeCaseNamingStrategy } from "@visulima/pagination";
123
+
124
+ paginate(1, 10, 100, pageRows).getMeta(snakeCaseNamingStrategy);
125
+ // { first_page: 1, per_page: 10, last_page: 10, ... }
126
+ ```
127
+
128
+ ### Cursor-based pagination
129
+
130
+ For stable infinite scroll / keyset pagination over large tables, use
131
+ `CursorPaginator`:
132
+
133
+ ```ts
134
+ import { CursorPaginator } from "@visulima/pagination";
135
+
136
+ const rows = [{ id: 5 }, { id: 6 }]; // pre-fetched page rows
137
+
138
+ const p = CursorPaginator.fromArray(2, rows, { currentCursor: "4", hasMore: true }).baseUrl("/api/items");
139
+
140
+ p.getMeta();
141
+ // {
142
+ // nextCursor: "6",
143
+ // nextPageUrl: "/api/items?cursor=6",
144
+ // perPage: 2,
145
+ // previousCursor: "5",
146
+ // previousPageUrl: "/api/items?cursor=5",
147
+ // }
148
+ ```
149
+
150
+ ### OpenAPI schemas
151
+
152
+ ```ts
153
+ import { createPaginationMetaSchemaObject, createPaginationSchemaObject } from "@visulima/pagination";
154
+
155
+ const meta = createPaginationMetaSchemaObject("PaginationData"); // OpenAPI 3.0
156
+ const meta31 = createPaginationMetaSchemaObject("PaginationData", { openApiVersion: "3.1" });
157
+
158
+ const schema = createPaginationSchemaObject("UserList", { $ref: "#/components/schemas/User" });
159
+ ```
160
+
161
+ `nextPageUrl`/`previousPageUrl` are emitted as nullable (they are `null` on the
162
+ last/first page) and every field is listed in `required`.
163
+
79
164
  ## Supported Node.js Versions
80
165
 
81
166
  Libraries in this ecosystem make the best effort to track