ugcinc 4.6.3 → 4.7.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/README.md CHANGED
@@ -58,7 +58,7 @@ All client methods return the same response envelope:
58
58
 
59
59
  ```typescript
60
60
  type ApiResponse<T> =
61
- | { ok: true; code: 200; message: string; data: T }
61
+ | { ok: true; code: 200; message: string; data: T; nextCursor?: string | null }
62
62
  | { ok: false; code: number; message: string };
63
63
  ```
64
64
 
@@ -74,6 +74,25 @@ if (posts.ok) {
74
74
  }
75
75
  ```
76
76
 
77
+ ## Pagination
78
+
79
+ `accounts.getAccounts()` and `posts.getPosts()` support keyset pagination via `limit`/`cursor`.
80
+ Omit `limit` to fetch everything matching your filters (the default, unpaginated behavior); pass
81
+ `limit` to page through results newest-first, using each response's `nextCursor` to fetch the next
82
+ page (`null`/absent means there are no more pages):
83
+
84
+ ```typescript
85
+ let cursor: string | undefined;
86
+ const allPosts = [];
87
+
88
+ do {
89
+ const res = await client.posts.getPosts({ limit: 100, cursor });
90
+ if (!res.ok) break;
91
+ allPosts.push(...res.data);
92
+ cursor = res.nextCursor ?? undefined;
93
+ } while (cursor);
94
+ ```
95
+
77
96
  ## Useful Exports
78
97
 
79
98
  - `UGCClient` for API access
@@ -74,6 +74,10 @@ export interface GetAccountsParams {
74
74
  org_group?: string;
75
75
  user_group?: string;
76
76
  status?: 'uninitialized' | 'pending' | 'initialized' | 'setup' | 'warming' | 'warmed' | 'needs_replacement' | 'replacing' | 'failed' | 'deleted' | 'reclaimed';
77
+ /** Max rows to return. Omit to fetch all matching accounts (no pagination). */
78
+ limit?: number;
79
+ /** Opaque cursor from a previous response's `nextCursor`, to fetch the next page. */
80
+ cursor?: string;
77
81
  }
78
82
  export interface GetAccountStatsParams {
79
83
  accountIds?: string[];
@@ -239,6 +243,9 @@ export interface TroubleshootParams {
239
243
  export declare class AccountsClient extends BaseClient {
240
244
  /**
241
245
  * Get accounts with optional filters
246
+ *
247
+ * Pass `limit` to paginate; the response's `nextCursor` (when present) can be
248
+ * passed back as `cursor` to fetch the next page, ordered newest-first.
242
249
  */
243
250
  getAccounts(params?: GetAccountsParams): Promise<ApiResponse<Account[]>>;
244
251
  /**
package/dist/accounts.js CHANGED
@@ -8,6 +8,9 @@ const base_1 = require("./base");
8
8
  class AccountsClient extends base_1.BaseClient {
9
9
  /**
10
10
  * Get accounts with optional filters
11
+ *
12
+ * Pass `limit` to paginate; the response's `nextCursor` (when present) can be
13
+ * passed back as `cursor` to fetch the next page, ordered newest-first.
11
14
  */
12
15
  async getAccounts(params) {
13
16
  return this.post('/accounts', params ?? {});
package/dist/base.js CHANGED
@@ -44,6 +44,7 @@ class BaseClient {
44
44
  code: rawData.code,
45
45
  message: rawData.message ?? 'Success',
46
46
  data: rawData.data,
47
+ ...(rawData.nextCursor !== undefined ? { nextCursor: rawData.nextCursor } : {}),
47
48
  };
48
49
  }
49
50
  else {
package/dist/posts.d.ts CHANGED
@@ -32,6 +32,10 @@ export interface GetPostsParams {
32
32
  startDate?: string;
33
33
  endDate?: string;
34
34
  includeHidden?: boolean;
35
+ /** Max rows to return. Omit to fetch all matching posts (no pagination). */
36
+ limit?: number;
37
+ /** Opaque cursor from a previous response's `nextCursor`, to fetch the next page. */
38
+ cursor?: string;
35
39
  }
36
40
  export interface CreateSlideshowParams {
37
41
  accountId: string | null;
@@ -131,6 +135,9 @@ export interface PreviewScheduleResult {
131
135
  export declare class PostsClient extends BaseClient {
132
136
  /**
133
137
  * Get posts with optional filters
138
+ *
139
+ * Pass `limit` to paginate; the response's `nextCursor` (when present) can be
140
+ * passed back as `cursor` to fetch the next page, ordered newest-first.
134
141
  */
135
142
  getPosts(params?: GetPostsParams): Promise<ApiResponse<Post[]>>;
136
143
  /**
package/dist/posts.js CHANGED
@@ -8,6 +8,9 @@ const base_1 = require("./base");
8
8
  class PostsClient extends base_1.BaseClient {
9
9
  /**
10
10
  * Get posts with optional filters
11
+ *
12
+ * Pass `limit` to paginate; the response's `nextCursor` (when present) can be
13
+ * passed back as `cursor` to fetch the next page, ordered newest-first.
11
14
  */
12
15
  async getPosts(params) {
13
16
  return this.post('/post', params ?? {});
@@ -11,6 +11,8 @@ exports.accountTools = [
11
11
  org_group: zod_1.z.string().optional().describe('Filter by org group'),
12
12
  user_group: zod_1.z.string().optional().describe('Filter by user group'),
13
13
  status: zod_1.z.enum(['uninitialized', 'pending', 'initialized', 'setup', 'warming', 'warmed', 'needs_replacement', 'replacing', 'failed', 'deleted']).optional().describe('Filter by account status'),
14
+ limit: zod_1.z.number().optional().describe('Max rows to return, for pagination'),
15
+ cursor: zod_1.z.string().optional().describe('Opaque cursor from a previous response\'s nextCursor, to fetch the next page'),
14
16
  }).optional().describe('Optional filters'),
15
17
  execute: async (client, params) => {
16
18
  return client.accounts.getAccounts(params ?? undefined);
@@ -11,6 +11,8 @@ exports.postTools = [
11
11
  postIds: zod_1.z.array(zod_1.z.string()).optional().describe('Filter by specific post IDs'),
12
12
  startDate: zod_1.z.string().optional().describe('Start date (ISO 8601)'),
13
13
  endDate: zod_1.z.string().optional().describe('End date (ISO 8601)'),
14
+ limit: zod_1.z.number().optional().describe('Max rows to return, for pagination'),
15
+ cursor: zod_1.z.string().optional().describe('Opaque cursor from a previous response\'s nextCursor, to fetch the next page'),
14
16
  }).optional(),
15
17
  execute: async (client, params) => {
16
18
  return client.posts.getPosts(params ?? undefined);
package/dist/types.d.ts CHANGED
@@ -6,6 +6,8 @@ export interface SuccessResponse<T> {
6
6
  message: string;
7
7
  data: T;
8
8
  ok: true;
9
+ /** Present on keyset-paginated endpoints (see `limit`/`cursor` params). Pass back as `cursor` to fetch the next page; `null`/absent means no more pages. */
10
+ nextCursor?: string | null;
9
11
  }
10
12
  export interface ErrorResponse {
11
13
  code: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc",
3
- "version": "4.6.3",
3
+ "version": "4.7.0",
4
4
  "description": "TypeScript/JavaScript client for the UGC Inc API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",