From 9fcdab291dcf893112a41caf68060aa62a174c91 Mon Sep 17 00:00:00 2001 From: Trevin Chow Date: Thu, 2 Apr 2026 05:28:55 -0700 Subject: [PATCH 1/3] Add kv.list() pagination playground example Create an interactive playground example for kv.list() that demonstrates cursor-based pagination with sample data (6 items, 2 per page). Also wire the pagination docs example to the playground by changing the code fence from plain html to html;kv-list. Fixes #2755 --- src/docs/src/KV/list.md | 17 +------ src/docs/src/playground/examples/kv-list.html | 51 +++++++++++-------- 2 files changed, 32 insertions(+), 36 deletions(-) diff --git a/src/docs/src/KV/list.md b/src/docs/src/KV/list.md index 0f66240cfa..c03231e1d0 100755 --- a/src/docs/src/KV/list.md +++ b/src/docs/src/KV/list.md @@ -86,22 +86,7 @@ If the user has no keys, the array will be empty. Paginate results with a cursor -```html - - - - - +```html;kv-list ``` Sort keys lexicographically diff --git a/src/docs/src/playground/examples/kv-list.html b/src/docs/src/playground/examples/kv-list.html index 7c2a8fa9e7..9ad81b57ee 100755 --- a/src/docs/src/playground/examples/kv-list.html +++ b/src/docs/src/playground/examples/kv-list.html @@ -3,28 +3,39 @@ - \ No newline at end of file + + From 5343030ece97d11e6d875b07a0631d4f12638af3 Mon Sep 17 00:00:00 2001 From: Trevin Chow Date: Fri, 3 Apr 2026 01:55:42 -0700 Subject: [PATCH 2/3] fix: address review feedback - restore code example, create new pagination playground --- src/docs/src/KV/list.md | 43 ++++++++++++++++- src/docs/src/examples.js | 6 +++ .../examples/kv-list-pagination.html | 41 ++++++++++++++++ src/docs/src/playground/examples/kv-list.html | 48 ++++++++----------- 4 files changed, 108 insertions(+), 30 deletions(-) create mode 100644 src/docs/src/playground/examples/kv-list-pagination.html diff --git a/src/docs/src/KV/list.md b/src/docs/src/KV/list.md index c03231e1d0..0ac5183d2c 100755 --- a/src/docs/src/KV/list.md +++ b/src/docs/src/KV/list.md @@ -86,7 +86,48 @@ If the user has no keys, the array will be empty. Paginate results with a cursor -```html;kv-list +```html;kv-list-pagination + + + + + + ``` Sort keys lexicographically diff --git a/src/docs/src/examples.js b/src/docs/src/examples.js index b6627d3a31..d84a493ed0 100644 --- a/src/docs/src/examples.js +++ b/src/docs/src/examples.js @@ -407,6 +407,12 @@ const examples = [ slug: 'kv-list', source: '/playground/examples/kv-list.html', }, + { + title: 'List (Pagination)', + description: 'Paginate key-value results with a cursor and limit using puter.kv.list(). Run and modify this example in the playground.', + slug: 'kv-list-pagination', + source: '/playground/examples/kv-list-pagination.html', + }, { title: 'List (Sorted)', description: 'See how keys are returned in lexicographic order with puter.kv.list(). Run and modify this example in the playground.', diff --git a/src/docs/src/playground/examples/kv-list-pagination.html b/src/docs/src/playground/examples/kv-list-pagination.html new file mode 100644 index 0000000000..9ad81b57ee --- /dev/null +++ b/src/docs/src/playground/examples/kv-list-pagination.html @@ -0,0 +1,41 @@ + + + + + + diff --git a/src/docs/src/playground/examples/kv-list.html b/src/docs/src/playground/examples/kv-list.html index 9ad81b57ee..d2fc8dd7e4 100755 --- a/src/docs/src/playground/examples/kv-list.html +++ b/src/docs/src/playground/examples/kv-list.html @@ -3,38 +3,28 @@ From 5ecf9524c5118f430b2048029b31dee8ab09ca00 Mon Sep 17 00:00:00 2001 From: Reynaldi Chernando Date: Fri, 3 Apr 2026 17:21:38 +0700 Subject: [PATCH 3/3] minor refactor --- src/docs/src/KV/list.md | 11 ++++++----- .../src/playground/examples/kv-list-pagination.html | 10 +++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/docs/src/KV/list.md b/src/docs/src/KV/list.md index 0ac5183d2c..03b950b90e 100755 --- a/src/docs/src/KV/list.md +++ b/src/docs/src/KV/list.md @@ -99,23 +99,23 @@ If the user has no keys, the array will be empty. puter.print('Created 6 key-value pairs

'); // Paginate with cursor (2 items per page) - let cursor = undefined; + let currentCursor = undefined; let page = 1; do { const result = await puter.kv.list({ limit: 2, returnValues: true, - ...(cursor ? { cursor } : {}), + cursor: currentCursor, }); - const items = result.items || result; + const items = result.items; puter.print(`Page ${page}:
`); for (const item of items) { puter.print(` ${item.key} => ${item.value}
`); } puter.print('
'); - cursor = result.cursor; + currentCursor = result.cursor; page++; - } while (cursor); + } while (currentCursor); puter.print('Done paginating.

'); @@ -128,6 +128,7 @@ If the user has no keys, the array will be empty. + ``` Sort keys lexicographically diff --git a/src/docs/src/playground/examples/kv-list-pagination.html b/src/docs/src/playground/examples/kv-list-pagination.html index 9ad81b57ee..30aa14c712 100644 --- a/src/docs/src/playground/examples/kv-list-pagination.html +++ b/src/docs/src/playground/examples/kv-list-pagination.html @@ -10,23 +10,23 @@ puter.print('Created 6 key-value pairs

'); // Paginate with cursor (2 items per page) - let cursor = undefined; + let currentCursor = undefined; let page = 1; do { const result = await puter.kv.list({ limit: 2, returnValues: true, - ...(cursor ? { cursor } : {}), + cursor: currentCursor, }); - const items = result.items || result; + const items = result.items; puter.print(`Page ${page}:
`); for (const item of items) { puter.print(` ${item.key} => ${item.value}
`); } puter.print('
'); - cursor = result.cursor; + currentCursor = result.cursor; page++; - } while (cursor); + } while (currentCursor); puter.print('Done paginating.

');