perspectapi-ts-sdk 3.2.0 → 3.4.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/dist/index.d.mts CHANGED
@@ -355,11 +355,23 @@ interface Product {
355
355
  [key: string]: any;
356
356
  }
357
357
  interface CreateProductRequest {
358
- name: string;
358
+ product: string;
359
+ name?: string;
359
360
  description?: string;
361
+ excerpt?: string;
360
362
  price: number;
363
+ unit_amount: number;
361
364
  currency?: string;
362
365
  sku?: string;
366
+ slug?: string;
367
+ slug_prefix?: string;
368
+ published?: boolean;
369
+ custom?: Record<string, any>;
370
+ recurring?: {
371
+ interval: "day" | "week" | "month" | "year";
372
+ interval_count?: number;
373
+ };
374
+ stock_quantity?: number | null;
363
375
  isActive?: boolean;
364
376
  }
365
377
  interface ProductQueryParams extends PaginationParams {
@@ -1244,16 +1256,23 @@ declare class ProductsClient extends BaseClient {
1244
1256
  }>>;
1245
1257
  /**
1246
1258
  * Create new product
1259
+ * @param siteName - The site name
1260
+ * @param data - Product data
1247
1261
  */
1248
- createProduct(data: CreateProductRequest): Promise<ApiResponse<Product>>;
1262
+ createProduct(siteName: string, data: CreateProductRequest): Promise<ApiResponse<Product>>;
1249
1263
  /**
1250
1264
  * Update product
1265
+ * @param siteName - The site name
1266
+ * @param id - Product ID
1267
+ * @param data - Fields to update
1251
1268
  */
1252
- updateProduct(id: number, data: Partial<CreateProductRequest>): Promise<ApiResponse<Product>>;
1269
+ updateProduct(siteName: string, id: number, data: Partial<CreateProductRequest>): Promise<ApiResponse<Product>>;
1253
1270
  /**
1254
1271
  * Delete product
1272
+ * @param siteName - The site name
1273
+ * @param id - Product ID
1255
1274
  */
1256
- deleteProduct(id: number): Promise<ApiResponse<{
1275
+ deleteProduct(siteName: string, id: number): Promise<ApiResponse<{
1257
1276
  message: string;
1258
1277
  }>>;
1259
1278
  /**
@@ -2461,6 +2480,32 @@ declare class SiteUsersClient extends BaseClient {
2461
2480
  success: boolean;
2462
2481
  new_balance_cents: number;
2463
2482
  }>>;
2483
+ /**
2484
+ * List orders for a site (admin only)
2485
+ * @param siteName - The site name
2486
+ * @param params - Query params (limit, offset, status, fulfillment_status)
2487
+ */
2488
+ listOrders(siteName: string, params?: {
2489
+ limit?: number;
2490
+ offset?: number;
2491
+ status?: string;
2492
+ fulfillment_status?: string;
2493
+ }): Promise<ApiResponse<{
2494
+ orders: any[];
2495
+ }>>;
2496
+ /**
2497
+ * Update order fulfillment status (admin only)
2498
+ * @param siteName - The site name
2499
+ * @param sessionId - Checkout session ID
2500
+ * @param data - Fulfillment data
2501
+ */
2502
+ updateOrderFulfillment(siteName: string, sessionId: string, data: {
2503
+ fulfillment_status: string;
2504
+ tracking_number?: string;
2505
+ notes?: string;
2506
+ }): Promise<ApiResponse<{
2507
+ success: boolean;
2508
+ }>>;
2464
2509
  }
2465
2510
 
2466
2511
  /**
package/dist/index.d.ts CHANGED
@@ -355,11 +355,23 @@ interface Product {
355
355
  [key: string]: any;
356
356
  }
357
357
  interface CreateProductRequest {
358
- name: string;
358
+ product: string;
359
+ name?: string;
359
360
  description?: string;
361
+ excerpt?: string;
360
362
  price: number;
363
+ unit_amount: number;
361
364
  currency?: string;
362
365
  sku?: string;
366
+ slug?: string;
367
+ slug_prefix?: string;
368
+ published?: boolean;
369
+ custom?: Record<string, any>;
370
+ recurring?: {
371
+ interval: "day" | "week" | "month" | "year";
372
+ interval_count?: number;
373
+ };
374
+ stock_quantity?: number | null;
363
375
  isActive?: boolean;
364
376
  }
365
377
  interface ProductQueryParams extends PaginationParams {
@@ -1244,16 +1256,23 @@ declare class ProductsClient extends BaseClient {
1244
1256
  }>>;
1245
1257
  /**
1246
1258
  * Create new product
1259
+ * @param siteName - The site name
1260
+ * @param data - Product data
1247
1261
  */
1248
- createProduct(data: CreateProductRequest): Promise<ApiResponse<Product>>;
1262
+ createProduct(siteName: string, data: CreateProductRequest): Promise<ApiResponse<Product>>;
1249
1263
  /**
1250
1264
  * Update product
1265
+ * @param siteName - The site name
1266
+ * @param id - Product ID
1267
+ * @param data - Fields to update
1251
1268
  */
1252
- updateProduct(id: number, data: Partial<CreateProductRequest>): Promise<ApiResponse<Product>>;
1269
+ updateProduct(siteName: string, id: number, data: Partial<CreateProductRequest>): Promise<ApiResponse<Product>>;
1253
1270
  /**
1254
1271
  * Delete product
1272
+ * @param siteName - The site name
1273
+ * @param id - Product ID
1255
1274
  */
1256
- deleteProduct(id: number): Promise<ApiResponse<{
1275
+ deleteProduct(siteName: string, id: number): Promise<ApiResponse<{
1257
1276
  message: string;
1258
1277
  }>>;
1259
1278
  /**
@@ -2461,6 +2480,32 @@ declare class SiteUsersClient extends BaseClient {
2461
2480
  success: boolean;
2462
2481
  new_balance_cents: number;
2463
2482
  }>>;
2483
+ /**
2484
+ * List orders for a site (admin only)
2485
+ * @param siteName - The site name
2486
+ * @param params - Query params (limit, offset, status, fulfillment_status)
2487
+ */
2488
+ listOrders(siteName: string, params?: {
2489
+ limit?: number;
2490
+ offset?: number;
2491
+ status?: string;
2492
+ fulfillment_status?: string;
2493
+ }): Promise<ApiResponse<{
2494
+ orders: any[];
2495
+ }>>;
2496
+ /**
2497
+ * Update order fulfillment status (admin only)
2498
+ * @param siteName - The site name
2499
+ * @param sessionId - Checkout session ID
2500
+ * @param data - Fulfillment data
2501
+ */
2502
+ updateOrderFulfillment(siteName: string, sessionId: string, data: {
2503
+ fulfillment_status: string;
2504
+ tracking_number?: string;
2505
+ notes?: string;
2506
+ }): Promise<ApiResponse<{
2507
+ success: boolean;
2508
+ }>>;
2464
2509
  }
2465
2510
 
2466
2511
  /**
package/dist/index.js CHANGED
@@ -1356,21 +1356,31 @@ var ProductsClient = class extends BaseClient {
1356
1356
  }
1357
1357
  /**
1358
1358
  * Create new product
1359
+ * @param siteName - The site name
1360
+ * @param data - Product data
1359
1361
  */
1360
- async createProduct(data) {
1361
- return this.create("/products", data);
1362
+ async createProduct(siteName, data) {
1363
+ const endpoint = this.siteScopedEndpoint(siteName, "/products", { includeSitesSegment: false });
1364
+ return this.create(endpoint, data);
1362
1365
  }
1363
1366
  /**
1364
1367
  * Update product
1368
+ * @param siteName - The site name
1369
+ * @param id - Product ID
1370
+ * @param data - Fields to update
1365
1371
  */
1366
- async updateProduct(id, data) {
1367
- return this.update(`/products/${id}`, data);
1372
+ async updateProduct(siteName, id, data) {
1373
+ const endpoint = this.siteScopedEndpoint(siteName, `/products/${id}`, { includeSitesSegment: false });
1374
+ return this.update(endpoint, data);
1368
1375
  }
1369
1376
  /**
1370
1377
  * Delete product
1378
+ * @param siteName - The site name
1379
+ * @param id - Product ID
1371
1380
  */
1372
- async deleteProduct(id) {
1373
- return this.delete(`/products/${id}`);
1381
+ async deleteProduct(siteName, id) {
1382
+ const endpoint = this.siteScopedEndpoint(siteName, `/products/${id}`, { includeSitesSegment: false });
1383
+ return this.delete(endpoint);
1374
1384
  }
1375
1385
  /**
1376
1386
  * Activate product
@@ -2604,6 +2614,29 @@ var SiteUsersClient = class extends BaseClient {
2604
2614
  csrfToken
2605
2615
  );
2606
2616
  }
2617
+ /**
2618
+ * List orders for a site (admin only)
2619
+ * @param siteName - The site name
2620
+ * @param params - Query params (limit, offset, status, fulfillment_status)
2621
+ */
2622
+ async listOrders(siteName, params) {
2623
+ return this.http.get(
2624
+ this.buildPath(this.siteUserEndpoint(siteName, "/users/orders")),
2625
+ params
2626
+ );
2627
+ }
2628
+ /**
2629
+ * Update order fulfillment status (admin only)
2630
+ * @param siteName - The site name
2631
+ * @param sessionId - Checkout session ID
2632
+ * @param data - Fulfillment data
2633
+ */
2634
+ async updateOrderFulfillment(siteName, sessionId, data) {
2635
+ return this.patch(
2636
+ this.siteUserEndpoint(siteName, `/users/orders/${encodeURIComponent(sessionId)}/fulfillment`),
2637
+ data
2638
+ );
2639
+ }
2607
2640
  };
2608
2641
 
2609
2642
  // src/client/bundles-client.ts
package/dist/index.mjs CHANGED
@@ -1293,21 +1293,31 @@ var ProductsClient = class extends BaseClient {
1293
1293
  }
1294
1294
  /**
1295
1295
  * Create new product
1296
+ * @param siteName - The site name
1297
+ * @param data - Product data
1296
1298
  */
1297
- async createProduct(data) {
1298
- return this.create("/products", data);
1299
+ async createProduct(siteName, data) {
1300
+ const endpoint = this.siteScopedEndpoint(siteName, "/products", { includeSitesSegment: false });
1301
+ return this.create(endpoint, data);
1299
1302
  }
1300
1303
  /**
1301
1304
  * Update product
1305
+ * @param siteName - The site name
1306
+ * @param id - Product ID
1307
+ * @param data - Fields to update
1302
1308
  */
1303
- async updateProduct(id, data) {
1304
- return this.update(`/products/${id}`, data);
1309
+ async updateProduct(siteName, id, data) {
1310
+ const endpoint = this.siteScopedEndpoint(siteName, `/products/${id}`, { includeSitesSegment: false });
1311
+ return this.update(endpoint, data);
1305
1312
  }
1306
1313
  /**
1307
1314
  * Delete product
1315
+ * @param siteName - The site name
1316
+ * @param id - Product ID
1308
1317
  */
1309
- async deleteProduct(id) {
1310
- return this.delete(`/products/${id}`);
1318
+ async deleteProduct(siteName, id) {
1319
+ const endpoint = this.siteScopedEndpoint(siteName, `/products/${id}`, { includeSitesSegment: false });
1320
+ return this.delete(endpoint);
1311
1321
  }
1312
1322
  /**
1313
1323
  * Activate product
@@ -2541,6 +2551,29 @@ var SiteUsersClient = class extends BaseClient {
2541
2551
  csrfToken
2542
2552
  );
2543
2553
  }
2554
+ /**
2555
+ * List orders for a site (admin only)
2556
+ * @param siteName - The site name
2557
+ * @param params - Query params (limit, offset, status, fulfillment_status)
2558
+ */
2559
+ async listOrders(siteName, params) {
2560
+ return this.http.get(
2561
+ this.buildPath(this.siteUserEndpoint(siteName, "/users/orders")),
2562
+ params
2563
+ );
2564
+ }
2565
+ /**
2566
+ * Update order fulfillment status (admin only)
2567
+ * @param siteName - The site name
2568
+ * @param sessionId - Checkout session ID
2569
+ * @param data - Fulfillment data
2570
+ */
2571
+ async updateOrderFulfillment(siteName, sessionId, data) {
2572
+ return this.patch(
2573
+ this.siteUserEndpoint(siteName, `/users/orders/${encodeURIComponent(sessionId)}/fulfillment`),
2574
+ data
2575
+ );
2576
+ }
2544
2577
  };
2545
2578
 
2546
2579
  // src/client/bundles-client.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "perspectapi-ts-sdk",
3
- "version": "3.2.0",
3
+ "version": "3.4.0",
4
4
  "description": "TypeScript SDK for PerspectAPI - Cloudflare Workers compatible",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -138,23 +138,33 @@ export class ProductsClient extends BaseClient {
138
138
 
139
139
  /**
140
140
  * Create new product
141
+ * @param siteName - The site name
142
+ * @param data - Product data
141
143
  */
142
- async createProduct(data: CreateProductRequest): Promise<ApiResponse<Product>> {
143
- return this.create<CreateProductRequest, Product>('/products', data);
144
+ async createProduct(siteName: string, data: CreateProductRequest): Promise<ApiResponse<Product>> {
145
+ const endpoint = this.siteScopedEndpoint(siteName, '/products', { includeSitesSegment: false });
146
+ return this.create<CreateProductRequest, Product>(endpoint, data);
144
147
  }
145
148
 
146
149
  /**
147
150
  * Update product
151
+ * @param siteName - The site name
152
+ * @param id - Product ID
153
+ * @param data - Fields to update
148
154
  */
149
- async updateProduct(id: number, data: Partial<CreateProductRequest>): Promise<ApiResponse<Product>> {
150
- return this.update<Partial<CreateProductRequest>, Product>(`/products/${id}`, data);
155
+ async updateProduct(siteName: string, id: number, data: Partial<CreateProductRequest>): Promise<ApiResponse<Product>> {
156
+ const endpoint = this.siteScopedEndpoint(siteName, `/products/${id}`, { includeSitesSegment: false });
157
+ return this.update<Partial<CreateProductRequest>, Product>(endpoint, data);
151
158
  }
152
159
 
153
160
  /**
154
161
  * Delete product
162
+ * @param siteName - The site name
163
+ * @param id - Product ID
155
164
  */
156
- async deleteProduct(id: number): Promise<ApiResponse<{ message: string }>> {
157
- return this.delete<{ message: string }>(`/products/${id}`);
165
+ async deleteProduct(siteName: string, id: number): Promise<ApiResponse<{ message: string }>> {
166
+ const endpoint = this.siteScopedEndpoint(siteName, `/products/${id}`, { includeSitesSegment: false });
167
+ return this.delete<{ message: string }>(endpoint);
158
168
  }
159
169
 
160
170
  /**
@@ -464,4 +464,36 @@ export class SiteUsersClient extends BaseClient {
464
464
  csrfToken
465
465
  );
466
466
  }
467
+
468
+ /**
469
+ * List orders for a site (admin only)
470
+ * @param siteName - The site name
471
+ * @param params - Query params (limit, offset, status, fulfillment_status)
472
+ */
473
+ async listOrders(
474
+ siteName: string,
475
+ params?: { limit?: number; offset?: number; status?: string; fulfillment_status?: string }
476
+ ): Promise<ApiResponse<{ orders: any[] }>> {
477
+ return this.http.get<{ orders: any[] }>(
478
+ this.buildPath(this.siteUserEndpoint(siteName, '/users/orders')),
479
+ params
480
+ );
481
+ }
482
+
483
+ /**
484
+ * Update order fulfillment status (admin only)
485
+ * @param siteName - The site name
486
+ * @param sessionId - Checkout session ID
487
+ * @param data - Fulfillment data
488
+ */
489
+ async updateOrderFulfillment(
490
+ siteName: string,
491
+ sessionId: string,
492
+ data: { fulfillment_status: string; tracking_number?: string; notes?: string }
493
+ ): Promise<ApiResponse<{ success: boolean }>> {
494
+ return this.patch<typeof data, { success: boolean }>(
495
+ this.siteUserEndpoint(siteName, `/users/orders/${encodeURIComponent(sessionId)}/fulfillment`),
496
+ data
497
+ );
498
+ }
467
499
  }
@@ -314,11 +314,20 @@ export interface Product {
314
314
  }
315
315
 
316
316
  export interface CreateProductRequest {
317
- name: string;
317
+ product: string;
318
+ name?: string;
318
319
  description?: string;
320
+ excerpt?: string;
319
321
  price: number;
322
+ unit_amount: number;
320
323
  currency?: string;
321
324
  sku?: string;
325
+ slug?: string;
326
+ slug_prefix?: string;
327
+ published?: boolean;
328
+ custom?: Record<string, any>;
329
+ recurring?: { interval: "day" | "week" | "month" | "year"; interval_count?: number };
330
+ stock_quantity?: number | null;
322
331
  isActive?: boolean;
323
332
  }
324
333