@vuevox/sdk 0.1.0 → 0.2.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
@@ -18,10 +18,11 @@ Settings -> Developer API -> Manage API Clients
18
18
 
19
19
  Create a client, select the scopes it can request, and copy the `client_secret` immediately. VueVox shows each client secret only once.
20
20
 
21
- Available scope:
21
+ Available scopes:
22
22
 
23
23
  ```text
24
24
  hello:read
25
+ spaces:read
25
26
  ```
26
27
 
27
28
  ## Basic Usage
@@ -32,11 +33,14 @@ import { createVueVoxClient } from "@vuevox/sdk";
32
33
  const vuevox = createVueVoxClient({
33
34
  clientId: process.env.VUEVOX_CLIENT_ID!,
34
35
  clientSecret: process.env.VUEVOX_CLIENT_SECRET!,
35
- scope: "hello:read",
36
+ scope: ["hello:read", "spaces:read"],
36
37
  });
37
38
 
38
39
  const hello = await vuevox.hello();
39
40
  console.log(hello.message);
41
+
42
+ const spaces = await vuevox.listSpaces({ limit: 50 });
43
+ console.log(spaces.data);
40
44
  ```
41
45
 
42
46
  The SDK requests and caches a short-lived access token using client credentials, then sends it as a bearer token for API calls.
@@ -51,11 +55,11 @@ import { VueVoxApiError, createVueVoxClient } from "@vuevox/sdk";
51
55
  const vuevox = createVueVoxClient({
52
56
  clientId: process.env.VUEVOX_CLIENT_ID!,
53
57
  clientSecret: process.env.VUEVOX_CLIENT_SECRET!,
54
- scope: "hello:read",
58
+ scope: ["hello:read", "spaces:read"],
55
59
  });
56
60
 
57
61
  try {
58
- await vuevox.hello();
62
+ await vuevox.listSpaces({ limit: 50 });
59
63
  } catch (error) {
60
64
  if (error instanceof VueVoxApiError) {
61
65
  console.error(error.status, error.code, error.message);
@@ -100,7 +104,7 @@ const vuevox = createVueVoxClient({
100
104
  baseUrl: "https://api.vuevox.com",
101
105
  clientId: process.env.VUEVOX_CLIENT_ID!,
102
106
  clientSecret: process.env.VUEVOX_CLIENT_SECRET!,
103
- scope: "hello:read",
107
+ scope: ["hello:read", "spaces:read"],
104
108
  });
105
109
  ```
106
110
 
@@ -115,3 +119,18 @@ const { data, error } = await vuevox.raw.GET("/v1/hello", {
115
119
  },
116
120
  });
117
121
  ```
122
+
123
+ ## Pagination
124
+
125
+ List endpoints use cursor pagination.
126
+
127
+ ```ts
128
+ const firstPage = await vuevox.listSpaces({ limit: 50 });
129
+
130
+ if (firstPage.pagination.nextCursor) {
131
+ const secondPage = await vuevox.listSpaces({
132
+ limit: 50,
133
+ cursor: firstPage.pagination.nextCursor,
134
+ });
135
+ }
136
+ ```
package/dist/client.d.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  import type { components, paths } from "./generated/schema.js";
2
2
  type HelloResponse = components["schemas"]["HelloResponse"];
3
+ type SpacesListResponse = components["schemas"]["SpacesListResponse"];
4
+ export interface ListSpacesOptions {
5
+ limit?: number;
6
+ cursor?: string;
7
+ }
3
8
  export interface VueVoxClientOptions {
4
9
  baseUrl?: string;
5
10
  clientId: string;
@@ -10,6 +15,7 @@ export interface VueVoxClientOptions {
10
15
  export declare function createVueVoxClient(options: VueVoxClientOptions): {
11
16
  getAccessToken: () => Promise<string>;
12
17
  hello: () => Promise<HelloResponse>;
18
+ listSpaces: (options?: ListSpacesOptions) => Promise<SpacesListResponse>;
13
19
  raw: import("openapi-fetch").Client<paths, `${string}/${string}`>;
14
20
  };
15
21
  export {};
package/dist/client.js CHANGED
@@ -47,9 +47,25 @@ export function createVueVoxClient(options) {
47
47
  }
48
48
  return data;
49
49
  }
50
+ async function listSpaces(options = {}) {
51
+ const accessToken = await getAccessToken();
52
+ const { data, error, response } = await raw.GET("/v1/spaces", {
53
+ params: {
54
+ query: options,
55
+ },
56
+ headers: {
57
+ Authorization: `Bearer ${accessToken}`,
58
+ },
59
+ });
60
+ if (error) {
61
+ throw new VueVoxApiError(response.status, error.error.code, error.error.message, error);
62
+ }
63
+ return data;
64
+ }
50
65
  return {
51
66
  getAccessToken,
52
67
  hello,
68
+ listSpaces,
53
69
  raw,
54
70
  };
55
71
  }
@@ -44,6 +44,26 @@ export interface paths {
44
44
  patch?: never;
45
45
  trace?: never;
46
46
  };
47
+ "/v1/spaces": {
48
+ parameters: {
49
+ query?: never;
50
+ header?: never;
51
+ path?: never;
52
+ cookie?: never;
53
+ };
54
+ /**
55
+ * List organization spaces
56
+ * @description Returns spaces for the API client's organization using cursor pagination.
57
+ */
58
+ get: operations["listSpaces"];
59
+ put?: never;
60
+ post?: never;
61
+ delete?: never;
62
+ options?: never;
63
+ head?: never;
64
+ patch?: never;
65
+ trace?: never;
66
+ };
47
67
  }
48
68
  export type webhooks = Record<string, never>;
49
69
  export interface components {
@@ -72,6 +92,30 @@ export interface components {
72
92
  /** @example Hello world */
73
93
  message: string;
74
94
  };
95
+ Space: {
96
+ /** Format: uuid */
97
+ id: string;
98
+ /** @example Sales Team */
99
+ name: string;
100
+ /** @example Workspace for inbound sales calls. */
101
+ description: string | null;
102
+ /** Format: date-time */
103
+ createdAt: string;
104
+ /** Format: date-time */
105
+ updatedAt: string;
106
+ };
107
+ SpacesListResponse: {
108
+ data: components["schemas"]["Space"][];
109
+ pagination: components["schemas"]["CursorPagination"];
110
+ };
111
+ CursorPagination: {
112
+ /** @example 50 */
113
+ limit: number;
114
+ /** @example false */
115
+ hasMore: boolean;
116
+ /** @description Opaque cursor to pass as cursor on the next request. */
117
+ nextCursor: string | null;
118
+ };
75
119
  ErrorResponse: {
76
120
  error: components["schemas"]["Error"];
77
121
  };
@@ -197,4 +241,69 @@ export interface operations {
197
241
  };
198
242
  };
199
243
  };
244
+ listSpaces: {
245
+ parameters: {
246
+ query?: {
247
+ /** @description Number of spaces to return. Defaults to 50. Maximum is 100. */
248
+ limit?: number;
249
+ /** @description Opaque cursor from the previous response's pagination.nextCursor value. */
250
+ cursor?: string;
251
+ };
252
+ header?: never;
253
+ path?: never;
254
+ cookie?: never;
255
+ };
256
+ requestBody?: never;
257
+ responses: {
258
+ /** @description Paginated spaces response. */
259
+ 200: {
260
+ headers: {
261
+ [name: string]: unknown;
262
+ };
263
+ content: {
264
+ "application/json": components["schemas"]["SpacesListResponse"];
265
+ };
266
+ };
267
+ /** @description Bearer token is missing, invalid, or expired. */
268
+ 401: {
269
+ headers: {
270
+ [name: string]: unknown;
271
+ };
272
+ content: {
273
+ "application/json": components["schemas"]["ErrorResponse"];
274
+ };
275
+ };
276
+ /** @description Bearer token does not include the required scope. */
277
+ 403: {
278
+ headers: {
279
+ [name: string]: unknown;
280
+ };
281
+ content: {
282
+ "application/json": components["schemas"]["ErrorResponse"];
283
+ };
284
+ };
285
+ /** @description Query parameters failed validation. */
286
+ 422: {
287
+ headers: {
288
+ [name: string]: unknown;
289
+ };
290
+ content: {
291
+ "application/json": components["schemas"]["ErrorResponse"];
292
+ };
293
+ };
294
+ /** @description Per-client rate limit exceeded. */
295
+ 429: {
296
+ headers: {
297
+ /** @description Seconds to wait before retrying. */
298
+ "Retry-After"?: string;
299
+ /** @description Request limit per minute for this API client. */
300
+ "X-RateLimit-Limit"?: string;
301
+ [name: string]: unknown;
302
+ };
303
+ content: {
304
+ "application/json": components["schemas"]["ErrorResponse"];
305
+ };
306
+ };
307
+ };
308
+ };
200
309
  }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { createVueVoxClient } from "./client.js";
2
- export type { VueVoxClientOptions } from "./client.js";
2
+ export type { ListSpacesOptions, VueVoxClientOptions } from "./client.js";
3
3
  export { VueVoxApiError } from "./errors.js";
4
4
  export type { VueVoxErrorResponse } from "./errors.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuevox/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "TypeScript SDK for the VueVox Developer API.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",