perspectapi-ts-sdk 6.5.7 → 7.0.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.
Files changed (58) hide show
  1. package/README.md +46 -1011
  2. package/dist/chunk-K3T2AFYA.mjs +1393 -0
  3. package/dist/index-CWvUyMt3.d.mts +2224 -0
  4. package/dist/index-CWvUyMt3.d.ts +2224 -0
  5. package/dist/index.d.mts +130 -2201
  6. package/dist/index.d.ts +130 -2201
  7. package/dist/index.js +15 -2
  8. package/dist/index.mjs +13 -1357
  9. package/dist/v2/index.d.mts +1 -0
  10. package/dist/v2/index.d.ts +1 -0
  11. package/dist/v2/index.js +1419 -0
  12. package/dist/v2/index.mjs +40 -0
  13. package/docs/README.md +15 -0
  14. package/docs/v1-deprecated/README.md +9 -0
  15. package/docs/v1-deprecated/examples/README.md +324 -0
  16. package/docs/v1-deprecated/examples/basic-usage.ts +258 -0
  17. package/docs/v1-deprecated/examples/cloudflare-worker.ts +274 -0
  18. package/docs/v1-deprecated/examples/content-query-with-slug-prefix.ts +237 -0
  19. package/docs/v1-deprecated/examples/image-transforms.ts +200 -0
  20. package/docs/v1-deprecated/examples/site-user-checkout.ts +186 -0
  21. package/docs/v1-deprecated/examples/slug-prefix-examples.ts +491 -0
  22. package/docs/v1-deprecated/legacy-docs/caching.md +667 -0
  23. package/docs/v1-deprecated/legacy-docs/contact.md +1396 -0
  24. package/docs/v1-deprecated/legacy-docs/csrf-protection.md +664 -0
  25. package/docs/v1-deprecated/legacy-docs/image-transforms.md +523 -0
  26. package/docs/v1-deprecated/legacy-docs/loaders.md +304 -0
  27. package/docs/v1-deprecated/legacy-docs/newsletter.md +811 -0
  28. package/docs/v1-deprecated/legacy-docs/site-users.md +817 -0
  29. package/docs/v1-deprecated/legacy-notes/CHANGELOG-CHECKOUT.md +143 -0
  30. package/docs/v1-deprecated/legacy-notes/CSRF-CHECKOUT.md +271 -0
  31. package/docs/v1-deprecated/legacy-notes/IMAGE_TRANSFORMS_PORT.md +298 -0
  32. package/docs/v1-deprecated/sdk-readme.md +1076 -0
  33. package/examples/README.md +19 -0
  34. package/examples/basic-v2.ts +37 -0
  35. package/llms.txt +25 -0
  36. package/package.json +18 -7
  37. package/src/client/api-keys-client.ts +4 -0
  38. package/src/client/auth-client.ts +4 -0
  39. package/src/client/base-client.ts +7 -0
  40. package/src/client/bundles-client.ts +4 -0
  41. package/src/client/categories-client.ts +4 -0
  42. package/src/client/checkout-client.ts +4 -0
  43. package/src/client/contact-client.ts +4 -0
  44. package/src/client/content-client.ts +4 -0
  45. package/src/client/newsletter-client.ts +4 -0
  46. package/src/client/newsletter-management-client.ts +4 -0
  47. package/src/client/organizations-client.ts +4 -0
  48. package/src/client/products-client.ts +4 -0
  49. package/src/client/site-users-client.ts +10 -1
  50. package/src/client/sites-client.ts +4 -0
  51. package/src/client/webhooks-client.ts +4 -0
  52. package/src/deprecation.ts +2 -1
  53. package/src/index.ts +2 -1
  54. package/src/loaders.ts +59 -0
  55. package/src/perspect-api-client.ts +2 -2
  56. package/src/v2/client/orders-client.ts +6 -1
  57. package/src/v2/client/subscriptions-client.ts +15 -0
  58. package/src/v2/types.ts +23 -0
@@ -0,0 +1,19 @@
1
+ # PerspectAPI SDK Examples
2
+
3
+ These examples use the current v2 SDK surface.
4
+
5
+ Do not use `/api/v1`, `PerspectApiClient`, or `createPerspectApiClient` for new
6
+ code. Historical v1 examples live under `docs/v1-deprecated/examples/`.
7
+
8
+ ## Basic v2 Usage
9
+
10
+ ```typescript
11
+ import { createPerspectApiV2Client } from 'perspectapi-ts-sdk/v2';
12
+
13
+ const client = createPerspectApiV2Client({
14
+ baseUrl: process.env.PERSPECTAPI_BASE_URL!,
15
+ apiKey: process.env.PERSPECTAPI_API_KEY!,
16
+ });
17
+
18
+ const products = await client.products.list('my-site', { limit: 20 });
19
+ ```
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Basic usage example for the current PerspectAPI v2 TypeScript SDK.
3
+ */
4
+
5
+ import { createPerspectApiV2Client, PerspectV2Error } from '../src/v2';
6
+
7
+ const client = createPerspectApiV2Client({
8
+ baseUrl: process.env.PERSPECTAPI_BASE_URL || 'https://api.perspect.com',
9
+ apiKey: process.env.PERSPECTAPI_API_KEY || 'your-api-key',
10
+ });
11
+
12
+ const siteName = process.env.PERSPECTAPI_SITE_NAME || 'my-site';
13
+
14
+ async function main() {
15
+ try {
16
+ const site = await client.sites.get(siteName);
17
+ console.log('Site:', site.id, site.name);
18
+
19
+ const products = await client.products.list(siteName, { limit: 10 });
20
+ console.log(`Loaded ${products.data.length} products`);
21
+
22
+ const content = await client.content.list(siteName, {
23
+ type: 'post',
24
+ status: 'publish',
25
+ limit: 10,
26
+ });
27
+ console.log(`Loaded ${content.data.length} posts`);
28
+ } catch (error) {
29
+ if (error instanceof PerspectV2Error) {
30
+ console.error('Perspect API error:', error.type, error.code, error.message);
31
+ return;
32
+ }
33
+ console.error('Unexpected error:', error);
34
+ }
35
+ }
36
+
37
+ main();
package/llms.txt ADDED
@@ -0,0 +1,25 @@
1
+ # PerspectAPI TypeScript SDK
2
+
3
+ PerspectAPI's current SDK and REST API surface is v2.
4
+
5
+ ## Hard Rule For Code Generation
6
+
7
+ Do not generate new code that uses `/api/v1`, `PerspectApiClient`,
8
+ `createPerspectApiClient`, or `src/client/*`.
9
+
10
+ v1 is deprecated and sunsets on 2026-06-01.
11
+
12
+ ## Use This Instead
13
+
14
+ ```typescript
15
+ import { createPerspectApiV2Client } from 'perspectapi-ts-sdk/v2';
16
+
17
+ const client = createPerspectApiV2Client({
18
+ baseUrl: 'https://api.perspect.com',
19
+ apiKey: process.env.PERSPECTAPI_API_KEY!,
20
+ });
21
+
22
+ const products = await client.products.list('my-site', { limit: 20 });
23
+ ```
24
+
25
+ REST calls should use `/api/v2`.
package/package.json CHANGED
@@ -1,27 +1,38 @@
1
1
  {
2
2
  "name": "perspectapi-ts-sdk",
3
- "version": "6.5.7",
3
+ "version": "7.0.0",
4
4
  "description": "TypeScript SDK for PerspectAPI - Cloudflare Workers compatible",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
+ "types": "./dist/index.d.ts",
10
11
  "import": "./dist/index.mjs",
11
- "require": "./dist/index.js",
12
- "types": "./dist/index.d.ts"
12
+ "require": "./dist/index.js"
13
+ },
14
+ "./v2": {
15
+ "types": "./dist/v2/index.d.ts",
16
+ "import": "./dist/v2/index.mjs",
17
+ "require": "./dist/v2/index.js"
13
18
  },
14
19
  "./package.json": "./package.json"
15
20
  },
16
21
  "files": [
17
22
  "dist/**/*",
18
23
  "src/**/*",
24
+ "docs/README.md",
25
+ "docs/v1-deprecated/**/*",
26
+ "examples/README.md",
27
+ "examples/basic-v2.ts",
19
28
  "tsconfig.json",
20
- "README.md"
29
+ "README.md",
30
+ "llms.txt"
21
31
  ],
22
32
  "scripts": {
23
- "build": "tsup src/index.ts --format cjs,esm --dts --clean",
24
- "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
33
+ "build": "tsup src/index.ts src/v2/index.ts --format cjs,esm --dts --clean",
34
+ "dev": "tsup src/index.ts src/v2/index.ts --format cjs,esm --dts --watch",
35
+ "lint:deprecated-v1": "node scripts/check-deprecated-v1.mjs",
25
36
  "test": "node scripts/test-runner.js",
26
37
  "test:all": "vitest run",
27
38
  "test:watch": "node scripts/test-runner.js watch",
@@ -29,7 +40,7 @@
29
40
  "test:unit": "node scripts/test-runner.js unit",
30
41
  "test:integration": "node scripts/test-runner.js integration",
31
42
  "test:types": "node scripts/test-runner.js types",
32
- "test:ci": "node scripts/test-runner.js ci",
43
+ "test:ci": "npm run lint:deprecated-v1 && node scripts/test-runner.js ci",
33
44
  "lint": "eslint src --ext .ts",
34
45
  "typecheck": "tsc --noEmit",
35
46
  "prepublishOnly": "npm run build && npm run test:ci"
@@ -12,6 +12,10 @@ import type {
12
12
  ApiResponse,
13
13
  } from '../types';
14
14
 
15
+ /**
16
+ * @deprecated v1 client. v1 sunsets on 2026-06-01. Use `client.apiKeys` from
17
+ * `PerspectApiV2Client` / `createPerspectApiV2Client`.
18
+ */
15
19
  export class ApiKeysClient extends BaseClient {
16
20
  constructor(http: any, cache?: CacheManager) {
17
21
  super(http, '/api/v1', cache);
@@ -12,6 +12,10 @@ import type {
12
12
  ApiResponse,
13
13
  } from '../types';
14
14
 
15
+ /**
16
+ * @deprecated v1 client. v1 sunsets on 2026-06-01. Use
17
+ * `PerspectApiV2Client` / `createPerspectApiV2Client` for new integrations.
18
+ */
15
19
  export class AuthClient extends BaseClient {
16
20
  constructor(http: any, cache?: CacheManager) {
17
21
  super(http, '/api/v1', cache);
@@ -3,16 +3,23 @@
3
3
  */
4
4
 
5
5
  import { HttpClient } from '../utils/http-client';
6
+ import { warnV1Deprecated } from '../deprecation';
6
7
  import type { ApiResponse } from '../types';
7
8
  import type { CacheManager } from '../cache/cache-manager';
8
9
  import type { CachePolicy, CacheInvalidateOptions } from '../cache/types';
9
10
 
11
+ /**
12
+ * @deprecated v1 base client. v1 sunsets on 2026-06-01. Use
13
+ * `PerspectApiV2Client` / `createPerspectApiV2Client` from
14
+ * `perspectapi-ts-sdk/v2` for new integrations.
15
+ */
10
16
  export abstract class BaseClient {
11
17
  protected http: HttpClient;
12
18
  protected basePath: string;
13
19
  protected cache?: CacheManager;
14
20
 
15
21
  constructor(http: HttpClient, basePath: string, cache?: CacheManager) {
22
+ warnV1Deprecated();
16
23
  this.http = http;
17
24
  this.basePath = basePath;
18
25
  this.cache = cache && cache.isEnabled() ? cache : undefined;
@@ -16,6 +16,10 @@ import type {
16
16
  ApiResponse,
17
17
  } from '../types';
18
18
 
19
+ /**
20
+ * @deprecated v1 client. v1 sunsets on 2026-06-01. Use v2 collections and
21
+ * products clients from `PerspectApiV2Client`.
22
+ */
19
23
  export class BundlesClient extends BaseClient {
20
24
  constructor(http: any, cache?: CacheManager) {
21
25
  super(http, '/api/v1', cache);
@@ -11,6 +11,10 @@ import type {
11
11
  ApiResponse,
12
12
  } from '../types';
13
13
 
14
+ /**
15
+ * @deprecated v1 client. v1 sunsets on 2026-06-01. Use `client.categories`
16
+ * from `PerspectApiV2Client` / `createPerspectApiV2Client`.
17
+ */
14
18
  export class CategoriesClient extends BaseClient {
15
19
  constructor(http: any, cache?: CacheManager) {
16
20
  super(http, '/api/v1', cache);
@@ -10,6 +10,10 @@ import type {
10
10
  ApiResponse,
11
11
  } from '../types';
12
12
 
13
+ /**
14
+ * @deprecated v1 client. v1 sunsets on 2026-06-01. Use v2 checkout/orders
15
+ * surfaces from `PerspectApiV2Client`.
16
+ */
13
17
  export class CheckoutClient extends BaseClient {
14
18
  constructor(http: any, cache?: CacheManager) {
15
19
  super(http, '/api/v1', cache);
@@ -13,6 +13,10 @@ import type {
13
13
  ApiResponse,
14
14
  } from '../types';
15
15
 
16
+ /**
17
+ * @deprecated v1 client. v1 sunsets on 2026-06-01. Use `client.contacts`
18
+ * from `PerspectApiV2Client` / `createPerspectApiV2Client`.
19
+ */
16
20
  export class ContactClient extends BaseClient {
17
21
  constructor(http: any, cache?: CacheManager) {
18
22
  super(http, '/api/v1', cache);
@@ -16,6 +16,10 @@ import type {
16
16
  } from '../types';
17
17
  import { validateOptionalContentType, validateOptionalLimit } from '../utils/validators';
18
18
 
19
+ /**
20
+ * @deprecated v1 client. v1 sunsets on 2026-06-01. Use `client.content`
21
+ * from `PerspectApiV2Client` / `createPerspectApiV2Client`.
22
+ */
19
23
  export class ContentClient extends BaseClient {
20
24
  constructor(http: any, cache?: CacheManager) {
21
25
  super(http, '/api/v1', cache);
@@ -20,6 +20,10 @@ import type {
20
20
  } from '../types';
21
21
  import { validateOptionalLimit } from '../utils/validators';
22
22
 
23
+ /**
24
+ * @deprecated v1 client. v1 sunsets on 2026-06-01. Use `client.newsletter`
25
+ * from `PerspectApiV2Client` / `createPerspectApiV2Client`.
26
+ */
23
27
  export class NewsletterClient extends BaseClient {
24
28
  constructor(http: any, cache?: CacheManager) {
25
29
  super(http, '/api/v1', cache);
@@ -27,6 +27,10 @@ import type {
27
27
  NewsletterSubscriptionsImportResponse,
28
28
  } from '../types';
29
29
 
30
+ /**
31
+ * @deprecated v1 client. v1 sunsets on 2026-06-01. Use `client.newsletter`
32
+ * from `PerspectApiV2Client` / `createPerspectApiV2Client`.
33
+ */
30
34
  export class NewsletterManagementClient extends BaseClient {
31
35
  constructor(http: any, cache?: CacheManager) {
32
36
  super(http, '/api/v1', cache);
@@ -11,6 +11,10 @@ import type {
11
11
  ApiResponse,
12
12
  } from '../types';
13
13
 
14
+ /**
15
+ * @deprecated v1 client. v1 sunsets on 2026-06-01. Use
16
+ * `client.organizations` from `PerspectApiV2Client`.
17
+ */
14
18
  export class OrganizationsClient extends BaseClient {
15
19
  constructor(http: any, cache?: CacheManager) {
16
20
  super(http, '/api/v1', cache);
@@ -16,6 +16,10 @@ import type {
16
16
  } from '../types';
17
17
  import { validateOptionalLimit } from '../utils/validators';
18
18
 
19
+ /**
20
+ * @deprecated v1 client. v1 sunsets on 2026-06-01. Use `client.products`
21
+ * from `PerspectApiV2Client` / `createPerspectApiV2Client`.
22
+ */
19
23
  export class ProductsClient extends BaseClient {
20
24
  constructor(http: any, cache?: CacheManager) {
21
25
  super(http, '/api/v1', cache);
@@ -23,6 +23,10 @@ import type {
23
23
  ApiResponse,
24
24
  } from '../types';
25
25
 
26
+ /**
27
+ * @deprecated v1 client. v1 sunsets on 2026-06-01. Use `client.siteUsers`
28
+ * from `PerspectApiV2Client` / `createPerspectApiV2Client`.
29
+ */
26
30
  export class SiteUsersClient extends BaseClient {
27
31
  constructor(http: any, cache?: CacheManager) {
28
32
  super(http, '/api/v1', cache);
@@ -511,7 +515,12 @@ export class SiteUsersClient extends BaseClient {
511
515
  async updateOrderFulfillment(
512
516
  siteName: string,
513
517
  sessionId: string,
514
- data: { fulfillment_status: string; tracking_number?: string; notes?: string }
518
+ data: {
519
+ fulfillment_status: string;
520
+ tracking_number?: string;
521
+ notes?: string;
522
+ notify_customer?: boolean;
523
+ }
515
524
  ): Promise<ApiResponse<{ success: boolean }>> {
516
525
  return this.patch<typeof data, { success: boolean }>(
517
526
  this.siteUserEndpoint(siteName, `/users/orders/${encodeURIComponent(sessionId)}/fulfillment`),
@@ -11,6 +11,10 @@ import type {
11
11
  ApiResponse,
12
12
  } from '../types';
13
13
 
14
+ /**
15
+ * @deprecated v1 client. v1 sunsets on 2026-06-01. Use `client.sites`
16
+ * from `PerspectApiV2Client` / `createPerspectApiV2Client`.
17
+ */
14
18
  export class SitesClient extends BaseClient {
15
19
  constructor(http: any, cache?: CacheManager) {
16
20
  super(http, '/api/v1', cache);
@@ -11,6 +11,10 @@ import type {
11
11
  ApiResponse,
12
12
  } from '../types';
13
13
 
14
+ /**
15
+ * @deprecated v1 client. v1 sunsets on 2026-06-01. Use `client.webhooks`
16
+ * from `PerspectApiV2Client` / `createPerspectApiV2Client`.
17
+ */
14
18
  export class WebhooksClient extends BaseClient {
15
19
  constructor(http: any, cache?: CacheManager) {
16
20
  super(http, '/api/v1', cache);
@@ -8,7 +8,8 @@
8
8
  export const V1_SUNSET_DATE = "2026-06-01";
9
9
  export const V1_DEPRECATION_NOTICE =
10
10
  "perspectapi-ts-sdk v1 client is deprecated; sunsets 2026-06-01. " +
11
- "New integrations must use createPerspectApiV2Client.";
11
+ "Do not use it for new code. Use createPerspectApiV2Client from " +
12
+ "perspectapi-ts-sdk/v2.";
12
13
 
13
14
  let warned = false;
14
15
 
package/src/index.ts CHANGED
@@ -4,7 +4,8 @@
4
4
  *
5
5
  * ⚠️ v1 clients (everything exported from `./perspect-api-client` and
6
6
  * `./client/*`) are deprecated and sunset on 2026-06-01. New integrations
7
- * must use `PerspectApiV2Client` / `createPerspectApiV2Client`. See
7
+ * must use `PerspectApiV2Client` / `createPerspectApiV2Client`, preferably
8
+ * imported from `perspectapi-ts-sdk/v2` so the version is explicit. See
8
9
  * `src/deprecation.ts` for the shared sunset constants.
9
10
  */
10
11
 
package/src/loaders.ts CHANGED
@@ -2,6 +2,11 @@
2
2
  * High-level data loading helpers that wrap the PerspectAPI SDK clients.
3
3
  * These helpers provide convenient product and content loading utilities with
4
4
  * graceful fallbacks that can be reused across applications.
5
+ *
6
+ * @deprecated These helpers are tied to the v1 `PerspectApiClient` and
7
+ * `/api/v1` route shapes. v1 sunsets on 2026-06-01. New integrations should
8
+ * use `PerspectApiV2Client` / `createPerspectApiV2Client` from
9
+ * `perspectapi-ts-sdk/v2` and call v2 resource clients directly.
5
10
  */
6
11
 
7
12
  import type { PerspectApiClient } from './perspect-api-client';
@@ -123,6 +128,9 @@ const normalizeQueryParamList = (
123
128
 
124
129
  /**
125
130
  * Transform a PerspectAPI product payload into a friendlier shape for UI layers.
131
+ *
132
+ * @deprecated Legacy v1 payload transformer. Prefer v2 product response types
133
+ * from `perspectapi-ts-sdk/v2`.
126
134
  */
127
135
  export const transformProduct = (
128
136
  perspectProduct: any,
@@ -180,6 +188,9 @@ export const transformProduct = (
180
188
 
181
189
  /**
182
190
  * Transform PerspectAPI content payload to a simplified BlogPost structure.
191
+ *
192
+ * @deprecated Legacy v1 payload transformer. Prefer v2 content response types
193
+ * from `perspectapi-ts-sdk/v2`.
183
194
  */
184
195
  export const transformContent = (
185
196
  perspectContent: Content | (Content & Record<string, unknown>),
@@ -305,6 +316,9 @@ const getDefaultFallbackPosts = (siteName: string): BlogPost[] => {
305
316
  ];
306
317
  };
307
318
 
319
+ /**
320
+ * @deprecated v1 loader options. Use v2 resource clients directly.
321
+ */
308
322
  export interface LoaderOptions {
309
323
  /**
310
324
  * Pre-configured PerspectAPI client. Pass null/undefined to force fallback behaviour.
@@ -329,6 +343,9 @@ export interface LoaderOptions {
329
343
  limit?: number;
330
344
  }
331
345
 
346
+ /**
347
+ * @deprecated v1 loader options. Use `client.products` from v2 directly.
348
+ */
332
349
  export interface LoadProductsOptions extends LoaderOptions {
333
350
  /**
334
351
  * Optional search term applied server-side.
@@ -368,6 +385,9 @@ const resolveFallbackPosts = (
368
385
 
369
386
  /**
370
387
  * Load products for a site with graceful fallbacks.
388
+ *
389
+ * @deprecated Uses the v1 client. Use `client.products.list(...)` from
390
+ * `perspectapi-ts-sdk/v2` for new integrations.
371
391
  */
372
392
  export async function loadProducts(options: LoadProductsOptions): Promise<Product[]> {
373
393
  const {
@@ -426,12 +446,18 @@ export async function loadProducts(options: LoadProductsOptions): Promise<Produc
426
446
  }
427
447
  }
428
448
 
449
+ /**
450
+ * @deprecated v1 loader options. Use `client.products` from v2 directly.
451
+ */
429
452
  export interface LoadProductBySlugOptions extends LoaderOptions {
430
453
  slug: string;
431
454
  }
432
455
 
433
456
  /**
434
457
  * Load single product by slug.
458
+ *
459
+ * @deprecated Uses the v1 client. Use `client.products.get(...)` from
460
+ * `perspectapi-ts-sdk/v2` for new integrations.
435
461
  */
436
462
  export async function loadProductBySlug(
437
463
  options: LoadProductBySlugOptions
@@ -467,6 +493,9 @@ export async function loadProductBySlug(
467
493
  }
468
494
  }
469
495
 
496
+ /**
497
+ * @deprecated v1 loader options. Use `client.content` from v2 directly.
498
+ */
470
499
  export interface LoadContentOptions extends LoaderOptions {
471
500
  /**
472
501
  * Additional query parameters for content filtering.
@@ -481,6 +510,9 @@ export interface LoadContentOptions extends LoaderOptions {
481
510
 
482
511
  /**
483
512
  * Load published pages for a site.
513
+ *
514
+ * @deprecated Uses the v1 client. Use `client.content.list(...)` from
515
+ * `perspectapi-ts-sdk/v2` for new integrations.
484
516
  */
485
517
  export async function loadPages(
486
518
  options: LoadContentOptions
@@ -529,6 +561,9 @@ export async function loadPages(
529
561
 
530
562
  /**
531
563
  * Load published blog posts for a site.
564
+ *
565
+ * @deprecated Uses the v1 client. Use `client.content.list(...)` from
566
+ * `perspectapi-ts-sdk/v2` for new integrations.
532
567
  */
533
568
  export async function loadPosts(
534
569
  options: LoadContentOptions
@@ -574,12 +609,18 @@ export async function loadPosts(
574
609
  }
575
610
  }
576
611
 
612
+ /**
613
+ * @deprecated v1 loader options. Use `client.content` from v2 directly.
614
+ */
577
615
  export interface LoadContentBySlugOptions extends LoaderOptions {
578
616
  slug: string;
579
617
  }
580
618
 
581
619
  /**
582
620
  * Load a single content item (post or page) by slug.
621
+ *
622
+ * @deprecated Uses the v1 client. Use `client.content.get(...)` from
623
+ * `perspectapi-ts-sdk/v2` for new integrations.
583
624
  */
584
625
  export async function loadContentBySlug(
585
626
  options: LoadContentBySlugOptions
@@ -615,12 +656,18 @@ export async function loadContentBySlug(
615
656
  }
616
657
  }
617
658
 
659
+ /**
660
+ * @deprecated v1 loader options. Use `client.content` from v2 directly.
661
+ */
618
662
  export interface LoadBlockBySlugOptions extends LoaderOptions {
619
663
  slug: string;
620
664
  }
621
665
 
622
666
  /**
623
667
  * Load published blocks for a site.
668
+ *
669
+ * @deprecated Uses the v1 client. Use `client.content.list(...)` from
670
+ * `perspectapi-ts-sdk/v2` for new integrations.
624
671
  */
625
672
  export async function loadBlocks(
626
673
  options: LoadContentOptions
@@ -664,6 +711,9 @@ export async function loadBlocks(
664
711
 
665
712
  /**
666
713
  * Load a single block by slug.
714
+ *
715
+ * @deprecated Uses the v1 client. Use `client.content.get(...)` from
716
+ * `perspectapi-ts-sdk/v2` for new integrations.
667
717
  */
668
718
  export async function loadBlockBySlug(
669
719
  options: LoadBlockBySlugOptions
@@ -694,6 +744,9 @@ export async function loadBlockBySlug(
694
744
 
695
745
  /**
696
746
  * Load all published content (pages + posts).
747
+ *
748
+ * @deprecated Uses the v1 client. Use v2 `client.content` reads directly for
749
+ * new integrations.
697
750
  */
698
751
  export async function loadAllContent(
699
752
  options: LoaderOptions
@@ -709,6 +762,9 @@ export async function loadAllContent(
709
762
  return [...pages, ...posts];
710
763
  }
711
764
 
765
+ /**
766
+ * @deprecated v1 checkout helper options. Use v2 checkout/orders surfaces.
767
+ */
712
768
  export interface CheckoutSessionOptions {
713
769
  client?: PerspectApiClient | null;
714
770
  siteName: string;
@@ -749,6 +805,9 @@ export interface CheckoutSessionOptions {
749
805
  /**
750
806
  * Convenience helper that creates a checkout session by looking up Stripe price IDs
751
807
  * from product metadata. Falls back to gateway price IDs if Stripe IDs are missing.
808
+ *
809
+ * @deprecated Uses the v1 client. Use v2 checkout/orders surfaces for new
810
+ * integrations.
752
811
  */
753
812
  export async function createCheckoutSession(
754
813
  options: CheckoutSessionOptions
@@ -26,7 +26,7 @@ import type { PerspectApiConfig, ApiResponse } from './types';
26
26
  /**
27
27
  * @deprecated v1 client is deprecated and sunsets 2026-06-01. New
28
28
  * integrations must use `PerspectApiV2Client` / `createPerspectApiV2Client`
29
- * from `perspectapi-ts-sdk` (see the `v2-client` reference page).
29
+ * from `perspectapi-ts-sdk/v2` (see the `v2-client` reference page).
30
30
  */
31
31
  export class PerspectApiClient {
32
32
  private http: HttpClient;
@@ -193,7 +193,7 @@ export class PerspectApiClient {
193
193
  * Create a new PerspectAPI client instance.
194
194
  *
195
195
  * @deprecated v1 factory is deprecated and sunsets 2026-06-01. Use
196
- * `createPerspectApiV2Client` for new integrations.
196
+ * `createPerspectApiV2Client` from `perspectapi-ts-sdk/v2` for new integrations.
197
197
  */
198
198
  export function createPerspectApiClient(config: PerspectApiConfig): PerspectApiClient {
199
199
  return new PerspectApiClient(config);
@@ -47,7 +47,12 @@ export class OrdersV2Client extends BaseV2Client {
47
47
  );
48
48
  }
49
49
 
50
- /** Update fulfillment status, tracking number, and/or notes on an order. */
50
+ /**
51
+ * Update fulfillment status, tracking number, and/or notes on an order.
52
+ *
53
+ * Set `notify_customer: true` when moving the order into a terminal
54
+ * fulfillment state to send the customer fulfillment email.
55
+ */
51
56
  async updateFulfillment(
52
57
  siteName: string,
53
58
  id: string,
@@ -13,6 +13,8 @@ import type {
13
13
  V2SubscriptionPauseParams,
14
14
  V2SubscriptionCancelParams,
15
15
  V2SubscriptionChangePlanParams,
16
+ V2SubscriptionChargeParams,
17
+ V2SubscriptionChargeResult,
16
18
  V2CancelSubscriptionResult,
17
19
  V2List,
18
20
  } from '../types';
@@ -130,4 +132,17 @@ export class SubscriptionsV2Client extends BaseV2Client {
130
132
  params ?? {},
131
133
  );
132
134
  }
135
+
136
+ /** Charge a user's subscription once (admin). */
137
+ async chargeUserSubscription(
138
+ siteName: string,
139
+ userId: string,
140
+ subId: string,
141
+ params: V2SubscriptionChargeParams,
142
+ ): Promise<V2SubscriptionChargeResult> {
143
+ return this.post<V2SubscriptionChargeResult>(
144
+ this.sitePath(siteName, 'users', `${userId}/subscriptions/${subId}/charges`),
145
+ params,
146
+ );
147
+ }
133
148
  }
package/src/v2/types.ts CHANGED
@@ -253,6 +253,7 @@ export interface V2Order extends V2Object {
253
253
 
254
254
  export interface V2OrderListParams extends V2PaginationParams {
255
255
  status?: string;
256
+ fulfillment_status?: string;
256
257
  customer_email?: string;
257
258
  date_from?: string;
258
259
  date_to?: string;
@@ -327,6 +328,8 @@ export interface V2OrderFulfillmentUpdate {
327
328
  fulfillment_status: string;
328
329
  tracking_number?: string;
329
330
  notes?: string;
331
+ /** When true, a terminal fulfillment status triggers a customer email. */
332
+ notify_customer?: boolean;
330
333
  }
331
334
 
332
335
  export interface V2OrderCreateResult extends V2Object {
@@ -689,6 +692,26 @@ export interface V2SubscriptionChangePlanParams {
689
692
  product_id: string;
690
693
  }
691
694
 
695
+ export interface V2SubscriptionChargeParams {
696
+ amount_cents: number;
697
+ currency?: string;
698
+ description?: string;
699
+ idempotency_key: string;
700
+ metadata?: Record<string, string>;
701
+ }
702
+
703
+ export interface V2SubscriptionChargeResult {
704
+ object: "subscription_charge";
705
+ provider_invoice_id: string | null;
706
+ provider_invoice_item_id: string | null;
707
+ provider_payment_intent_id: string | null;
708
+ status: string | null;
709
+ paid: boolean;
710
+ amount_due: number | null;
711
+ amount_paid: number | null;
712
+ currency: string;
713
+ }
714
+
692
715
  export interface V2CancelSubscriptionResult {
693
716
  object: "subscription_cancel_result";
694
717
  mode: string;