@proveanything/smartlinks 1.5.3 → 1.5.5

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.
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 1.5.3 | Generated: 2026-02-25T13:03:38.388Z
3
+ Version: 1.5.5 | Generated: 2026-02-26T07:58:07.537Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -130,6 +130,92 @@ await app.records.create(collectionId, appId, {
130
130
 
131
131
  ---
132
132
 
133
+ ## Paginated List Responses
134
+
135
+ Every `.list()` call returns a **`PaginatedResponse<T>`** object. The items are in the `data` array and all page-level metadata lives in a nested `pagination` object:
136
+
137
+ ```json
138
+ {
139
+ "data": [
140
+ {
141
+ "id": "7ac44316-c227-4c39-bf99-a287bc08c6f5",
142
+ "collectionId": "veho-demo",
143
+ "appId": "knowledgeBase",
144
+ "visibility": "public",
145
+ "recordType": "article",
146
+ "status": "published",
147
+ "createdAt": "2026-02-25T22:13:14.310Z",
148
+ "updatedAt": "2026-02-25T22:47:36.712Z",
149
+ "data": {
150
+ "title": "Getting Started",
151
+ "slug": "getting-started",
152
+ "body": "..."
153
+ }
154
+ }
155
+ ],
156
+ "pagination": {
157
+ "total": 42,
158
+ "limit": 10,
159
+ "offset": 0,
160
+ "hasMore": true
161
+ }
162
+ }
163
+ ```
164
+
165
+ ### Pagination fields
166
+
167
+ | Field | Type | Description |
168
+ |---|---|---|
169
+ | `data` | `T[]` | The page of items returned |
170
+ | `pagination.total` | `number` | Total number of matching records across **all** pages |
171
+ | `pagination.limit` | `number` | The `limit` that was applied to this request (default `50`, max `500`) |
172
+ | `pagination.offset` | `number` | The `offset` that was applied to this request |
173
+ | `pagination.hasMore` | `boolean` | `true` when more pages exist — use this instead of computing `offset + limit < total` yourself |
174
+
175
+ > **Note:** The items are always in `response.data`, **not** at the top level. A common mistake is reading `response.total` — the correct path is `response.pagination.total`.
176
+
177
+ ### Fetching all pages
178
+
179
+ ```typescript
180
+ import { app, PaginatedResponse, AppRecord } from '@proveanything/smartlinks';
181
+
182
+ async function fetchAllRecords(collectionId: string, appId: string) {
183
+ const results: AppRecord[] = [];
184
+ let offset = 0;
185
+ const limit = 100;
186
+
187
+ while (true) {
188
+ const page: PaginatedResponse<AppRecord> = await app.records.list(
189
+ collectionId,
190
+ appId,
191
+ { limit, offset, sort: 'createdAt:desc' }
192
+ );
193
+
194
+ results.push(...page.data);
195
+
196
+ if (!page.pagination.hasMore) break; // no more pages
197
+ offset += limit;
198
+ }
199
+
200
+ console.log(`Fetched ${results.length} of ${/* saved from first page */ 0} total`);
201
+ return results;
202
+ }
203
+ ```
204
+
205
+ ### Reading the count and checking for more
206
+
207
+ ```typescript
208
+ const page = await app.cases.list(collectionId, appId, { status: 'open', limit: 10 });
209
+
210
+ console.log(page.data); // array of AppCase objects
211
+ console.log(page.pagination.total); // e.g. 142 — total open cases
212
+ console.log(page.pagination.hasMore); // true / false
213
+ console.log(page.pagination.offset); // current page start
214
+ console.log(page.pagination.limit); // items per page
215
+ ```
216
+
217
+ ---
218
+
133
219
  ## Cases
134
220
 
135
221
  **Cases** represent trackable issues, requests, or tasks that move through states and require resolution.
@@ -7,13 +7,33 @@ export type Visibility = 'public' | 'owner' | 'admin';
7
7
  */
8
8
  export type CallerRole = 'admin' | 'owner' | 'public';
9
9
  /**
10
- * Paginated response wrapper for list endpoints
10
+ * Paginated response wrapper for list endpoints.
11
+ *
12
+ * All list endpoints return this shape:
13
+ * ```json
14
+ * {
15
+ * "data": [ ...items ],
16
+ * "pagination": {
17
+ * "total": 142,
18
+ * "limit": 10,
19
+ * "offset": 0,
20
+ * "hasMore": true
21
+ * }
22
+ * }
23
+ * ```
11
24
  */
12
25
  export interface PaginatedResponse<T> {
13
26
  data: T[];
14
- total: number;
15
- limit: number;
16
- offset: number;
27
+ pagination: {
28
+ /** Total number of matching records in the collection */
29
+ total: number;
30
+ /** Maximum number of items returned in this page */
31
+ limit: number;
32
+ /** Number of items skipped before this page */
33
+ offset: number;
34
+ /** `true` when more pages are available (offset + limit < total) */
35
+ hasMore: boolean;
36
+ };
17
37
  }
18
38
  /**
19
39
  * Request body for aggregate endpoints
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 1.5.3 | Generated: 2026-02-25T13:03:38.388Z
3
+ Version: 1.5.5 | Generated: 2026-02-26T07:58:07.537Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -130,6 +130,92 @@ await app.records.create(collectionId, appId, {
130
130
 
131
131
  ---
132
132
 
133
+ ## Paginated List Responses
134
+
135
+ Every `.list()` call returns a **`PaginatedResponse<T>`** object. The items are in the `data` array and all page-level metadata lives in a nested `pagination` object:
136
+
137
+ ```json
138
+ {
139
+ "data": [
140
+ {
141
+ "id": "7ac44316-c227-4c39-bf99-a287bc08c6f5",
142
+ "collectionId": "veho-demo",
143
+ "appId": "knowledgeBase",
144
+ "visibility": "public",
145
+ "recordType": "article",
146
+ "status": "published",
147
+ "createdAt": "2026-02-25T22:13:14.310Z",
148
+ "updatedAt": "2026-02-25T22:47:36.712Z",
149
+ "data": {
150
+ "title": "Getting Started",
151
+ "slug": "getting-started",
152
+ "body": "..."
153
+ }
154
+ }
155
+ ],
156
+ "pagination": {
157
+ "total": 42,
158
+ "limit": 10,
159
+ "offset": 0,
160
+ "hasMore": true
161
+ }
162
+ }
163
+ ```
164
+
165
+ ### Pagination fields
166
+
167
+ | Field | Type | Description |
168
+ |---|---|---|
169
+ | `data` | `T[]` | The page of items returned |
170
+ | `pagination.total` | `number` | Total number of matching records across **all** pages |
171
+ | `pagination.limit` | `number` | The `limit` that was applied to this request (default `50`, max `500`) |
172
+ | `pagination.offset` | `number` | The `offset` that was applied to this request |
173
+ | `pagination.hasMore` | `boolean` | `true` when more pages exist — use this instead of computing `offset + limit < total` yourself |
174
+
175
+ > **Note:** The items are always in `response.data`, **not** at the top level. A common mistake is reading `response.total` — the correct path is `response.pagination.total`.
176
+
177
+ ### Fetching all pages
178
+
179
+ ```typescript
180
+ import { app, PaginatedResponse, AppRecord } from '@proveanything/smartlinks';
181
+
182
+ async function fetchAllRecords(collectionId: string, appId: string) {
183
+ const results: AppRecord[] = [];
184
+ let offset = 0;
185
+ const limit = 100;
186
+
187
+ while (true) {
188
+ const page: PaginatedResponse<AppRecord> = await app.records.list(
189
+ collectionId,
190
+ appId,
191
+ { limit, offset, sort: 'createdAt:desc' }
192
+ );
193
+
194
+ results.push(...page.data);
195
+
196
+ if (!page.pagination.hasMore) break; // no more pages
197
+ offset += limit;
198
+ }
199
+
200
+ console.log(`Fetched ${results.length} of ${/* saved from first page */ 0} total`);
201
+ return results;
202
+ }
203
+ ```
204
+
205
+ ### Reading the count and checking for more
206
+
207
+ ```typescript
208
+ const page = await app.cases.list(collectionId, appId, { status: 'open', limit: 10 });
209
+
210
+ console.log(page.data); // array of AppCase objects
211
+ console.log(page.pagination.total); // e.g. 142 — total open cases
212
+ console.log(page.pagination.hasMore); // true / false
213
+ console.log(page.pagination.offset); // current page start
214
+ console.log(page.pagination.limit); // items per page
215
+ ```
216
+
217
+ ---
218
+
133
219
  ## Cases
134
220
 
135
221
  **Cases** represent trackable issues, requests, or tasks that move through states and require resolution.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proveanything/smartlinks",
3
- "version": "1.5.3",
3
+ "version": "1.5.5",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",