perspectapi-ts-sdk 6.0.2 → 6.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "perspectapi-ts-sdk",
3
- "version": "6.0.2",
3
+ "version": "6.1.0",
4
4
  "description": "TypeScript SDK for PerspectAPI - Cloudflare Workers compatible",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -10,11 +10,13 @@
10
10
  "import": "./dist/index.mjs",
11
11
  "require": "./dist/index.js",
12
12
  "types": "./dist/index.d.ts"
13
- }
13
+ },
14
+ "./package.json": "./package.json"
14
15
  },
15
16
  "files": [
16
17
  "dist/**/*",
17
18
  "src/**/*",
19
+ "tsconfig.json",
18
20
  "README.md"
19
21
  ],
20
22
  "scripts": {
@@ -0,0 +1,24 @@
1
+ /**
2
+ * v1 deprecation constants — kept in sync with the backend's
3
+ * `src/lib/deprecation.ts`.
4
+ *
5
+ * v1 sunsets 2026-06-01. All new integrations must use the v2 client.
6
+ */
7
+
8
+ export const V1_SUNSET_DATE = "2026-06-01";
9
+ export const V1_DEPRECATION_NOTICE =
10
+ "perspectapi-ts-sdk v1 client is deprecated; sunsets 2026-06-01. " +
11
+ "New integrations must use createPerspectApiV2Client.";
12
+
13
+ let warned = false;
14
+
15
+ /**
16
+ * Emit the v1 deprecation warning at most once per process. Called from v1
17
+ * client constructors so anyone instantiating a v1 client sees it.
18
+ */
19
+ export function warnV1Deprecated(): void {
20
+ if (warned) return;
21
+ warned = true;
22
+ // eslint-disable-next-line no-console
23
+ console.warn(`[perspectapi-ts-sdk] ${V1_DEPRECATION_NOTICE}`);
24
+ }
package/src/index.ts CHANGED
@@ -1,31 +1,56 @@
1
1
  /**
2
2
  * PerspectAPI TypeScript SDK
3
3
  * Cloudflare Workers compatible SDK for PerspectAPI
4
+ *
5
+ * ⚠️ v1 clients (everything exported from `./perspect-api-client` and
6
+ * `./client/*`) are deprecated and sunset on 2026-06-01. New integrations
7
+ * must use `PerspectApiV2Client` / `createPerspectApiV2Client`. See
8
+ * `src/deprecation.ts` for the shared sunset constants.
4
9
  */
5
10
 
6
- // Main client (v1)
7
- export { PerspectApiClient, createPerspectApiClient } from './perspect-api-client';
8
- export { default } from './perspect-api-client';
11
+ export { V1_SUNSET_DATE, V1_DEPRECATION_NOTICE } from './deprecation';
9
12
 
10
- // v2 client
13
+ // ───────────────────────────────────────────────────────────────────────────
14
+ // v2 client (current — use for all new integrations)
15
+ // ───────────────────────────────────────────────────────────────────────────
11
16
  export { PerspectApiV2Client, createPerspectApiV2Client } from './v2';
12
17
  export { PerspectV2Error } from './v2/client/base-v2-client';
13
18
  export type * from './v2/types';
14
19
 
15
- // Individual clients (for advanced usage)
20
+ // ───────────────────────────────────────────────────────────────────────────
21
+ // v1 client — DEPRECATED, sunsets 2026-06-01. Do not use for new code.
22
+ // ───────────────────────────────────────────────────────────────────────────
23
+ /** @deprecated v1 — sunsets 2026-06-01. Use PerspectApiV2Client. */
24
+ export { PerspectApiClient, createPerspectApiClient } from './perspect-api-client';
25
+ export { default } from './perspect-api-client';
26
+
27
+ /** @deprecated v1 — sunsets 2026-06-01. Use v2 client. */
16
28
  export { AuthClient } from './client/auth-client';
29
+ /** @deprecated v1 — sunsets 2026-06-01. Use v2 client. */
17
30
  export { ContentClient } from './client/content-client';
31
+ /** @deprecated v1 — sunsets 2026-06-01. Use v2 client. */
18
32
  export { ApiKeysClient } from './client/api-keys-client';
33
+ /** @deprecated v1 — sunsets 2026-06-01. Use v2 client. */
19
34
  export { OrganizationsClient } from './client/organizations-client';
35
+ /** @deprecated v1 — sunsets 2026-06-01. Use v2 client. */
20
36
  export { SitesClient } from './client/sites-client';
37
+ /** @deprecated v1 — sunsets 2026-06-01. Use v2 client. */
21
38
  export { ProductsClient } from './client/products-client';
39
+ /** @deprecated v1 — sunsets 2026-06-01. Use v2 client. */
22
40
  export { CategoriesClient } from './client/categories-client';
41
+ /** @deprecated v1 — sunsets 2026-06-01. Use v2 client. */
23
42
  export { WebhooksClient } from './client/webhooks-client';
43
+ /** @deprecated v1 — sunsets 2026-06-01. Use v2 client. */
24
44
  export { CheckoutClient } from './client/checkout-client';
45
+ /** @deprecated v1 — sunsets 2026-06-01. Use v2 client. */
25
46
  export { ContactClient } from './client/contact-client';
47
+ /** @deprecated v1 — sunsets 2026-06-01. Use v2 client. */
26
48
  export { NewsletterClient } from './client/newsletter-client';
49
+ /** @deprecated v1 — sunsets 2026-06-01. Use v2 client. */
27
50
  export { NewsletterManagementClient } from './client/newsletter-management-client';
51
+ /** @deprecated v1 — sunsets 2026-06-01. Use v2 client. */
28
52
  export { SiteUsersClient } from './client/site-users-client';
53
+ /** @deprecated v1 — sunsets 2026-06-01. Use v2 client. */
29
54
  export { BundlesClient } from './client/bundles-client';
30
55
 
31
56
  // Base classes
@@ -19,9 +19,15 @@ import { NewsletterClient } from './client/newsletter-client';
19
19
  import { NewsletterManagementClient } from './client/newsletter-management-client';
20
20
  import { SiteUsersClient } from './client/site-users-client';
21
21
  import { BundlesClient } from './client/bundles-client';
22
+ import { warnV1Deprecated } from './deprecation';
22
23
 
23
24
  import type { PerspectApiConfig, ApiResponse } from './types';
24
25
 
26
+ /**
27
+ * @deprecated v1 client is deprecated and sunsets 2026-06-01. New
28
+ * integrations must use `PerspectApiV2Client` / `createPerspectApiV2Client`
29
+ * from `perspectapi-ts-sdk` (see the `v2-client` reference page).
30
+ */
25
31
  export class PerspectApiClient {
26
32
  private http: HttpClient;
27
33
  public readonly cache: CacheManager;
@@ -43,6 +49,8 @@ export class PerspectApiClient {
43
49
  public readonly bundles: BundlesClient;
44
50
 
45
51
  constructor(config: PerspectApiConfig) {
52
+ warnV1Deprecated();
53
+
46
54
  // Validate required configuration
47
55
  if (!config.baseUrl) {
48
56
  throw new Error('baseUrl is required in PerspectApiConfig');
@@ -182,7 +190,10 @@ export class PerspectApiClient {
182
190
  }
183
191
 
184
192
  /**
185
- * Create a new PerspectAPI client instance
193
+ * Create a new PerspectAPI client instance.
194
+ *
195
+ * @deprecated v1 factory is deprecated and sunsets 2026-06-01. Use
196
+ * `createPerspectApiV2Client` for new integrations.
186
197
  */
187
198
  export function createPerspectApiClient(config: PerspectApiConfig): PerspectApiClient {
188
199
  return new PerspectApiClient(config);
package/tsconfig.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "lib": ["ES2022", "DOM"],
5
+ "module": "ESNext",
6
+ "moduleResolution": "node",
7
+ "declaration": true,
8
+ "declarationMap": true,
9
+ "sourceMap": true,
10
+ "outDir": "./dist",
11
+ "rootDir": "./src",
12
+ "strict": true,
13
+ "noUnusedLocals": true,
14
+ "noUnusedParameters": true,
15
+ "noImplicitReturns": true,
16
+ "noFallthroughCasesInSwitch": true,
17
+ "skipLibCheck": true,
18
+ "forceConsistentCasingInFileNames": true,
19
+ "esModuleInterop": true,
20
+ "allowSyntheticDefaultImports": true,
21
+ "resolveJsonModule": true,
22
+ "isolatedModules": true,
23
+ "noEmit": true
24
+ },
25
+ "include": [
26
+ "src/**/*"
27
+ ],
28
+ "exclude": [
29
+ "node_modules",
30
+ "dist",
31
+ "**/*.test.ts",
32
+ "**/*.spec.ts"
33
+ ]
34
+ }