@forgecart/sdk 0.1.0 → 1.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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @forgecart/sdk - Admin API
3
+ *
4
+ * Admin namespace and types
5
+ */
6
+ export { AdminNamespace } from './admin-namespace.js';
7
+ export type { SDKConfig as AdminSDKConfig } from './admin-namespace.js';
8
+ export * from './admin-types.js';
package/dist/admin.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @forgecart/sdk - Admin API
3
+ *
4
+ * Admin namespace and types
5
+ */
6
+ export { AdminNamespace } from './admin-namespace.js';
7
+ export * from './admin-types.js';
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @forgecart/sdk - Auto-generated TypeScript SDK
3
+ *
4
+ * This file was automatically generated and should not be manually edited.
5
+ * To regenerate, run: npm run codegen:ts
6
+ *
7
+ * 🤖 Generated with ForgeCart SDK Generator
8
+ */
9
+ import { AdminNamespace, AdminSDKConfig } from './admin.js';
10
+ import { ShopNamespace, ShopSDKConfig } from './shop.js';
11
+ /**
12
+ * Unified SDK Configuration
13
+ */
14
+ export interface ForgeCartSDKConfig {
15
+ /** Base API endpoint (e.g., 'https://api.forgecart.com') */
16
+ endpoint?: string;
17
+ /** Channel token for Vendure multi-tenancy */
18
+ token?: string;
19
+ /** Use HTTP only, skip WebSocket initialization (default: false) */
20
+ httpOnly?: boolean;
21
+ /** Custom HTTP headers */
22
+ headers?: Record<string, string>;
23
+ /** Custom WebSocket implementation (optional, auto-detected if not provided) */
24
+ webSocketImpl?: unknown;
25
+ }
26
+ export type { AdminSDKConfig, ShopSDKConfig };
27
+ export { AdminNamespace, ShopNamespace };
28
+ /**
29
+ * ForgeCartSDK
30
+ * Unified SDK with categorized operations across multiple namespaces
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const sdk = new ForgeCartSDK({
35
+ * endpoint: 'https://api.forgecart.com',
36
+ * token: 'your-channel-token',
37
+ * });
38
+ *
39
+ * // Admin namespace → Category → Operations
40
+ * await sdk.admin.products.products({ take: 10 });
41
+ * await sdk.admin.customer.customer({ id: '1' });
42
+ *
43
+ * // Shop namespace → Category → Operations
44
+ * await sdk.shop.products.products({ take: 10 });
45
+ * await sdk.shop.order.addItemToOrder({ productVariantId: '1', quantity: 1 });
46
+ * ```
47
+ */
48
+ export declare class ForgeCartSDK {
49
+ readonly admin: AdminNamespace;
50
+ readonly shop: ShopNamespace;
51
+ constructor(config?: ForgeCartSDKConfig);
52
+ setAdminAuthToken(token: string): void;
53
+ clearAdminAuthToken(): void;
54
+ setShopAuthToken(token: string): void;
55
+ clearShopAuthToken(): void;
56
+ dispose(): void;
57
+ }
package/dist/index.js ADDED
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @forgecart/sdk - Auto-generated TypeScript SDK
3
+ *
4
+ * This file was automatically generated and should not be manually edited.
5
+ * To regenerate, run: npm run codegen:ts
6
+ *
7
+ * 🤖 Generated with ForgeCart SDK Generator
8
+ */
9
+ import { AdminNamespace } from './admin.js';
10
+ import { ShopNamespace } from './shop.js';
11
+ export { AdminNamespace, ShopNamespace };
12
+ /**
13
+ * ForgeCartSDK
14
+ * Unified SDK with categorized operations across multiple namespaces
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const sdk = new ForgeCartSDK({
19
+ * endpoint: 'https://api.forgecart.com',
20
+ * token: 'your-channel-token',
21
+ * });
22
+ *
23
+ * // Admin namespace → Category → Operations
24
+ * await sdk.admin.products.products({ take: 10 });
25
+ * await sdk.admin.customer.customer({ id: '1' });
26
+ *
27
+ * // Shop namespace → Category → Operations
28
+ * await sdk.shop.products.products({ take: 10 });
29
+ * await sdk.shop.order.addItemToOrder({ productVariantId: '1', quantity: 1 });
30
+ * ```
31
+ */
32
+ export class ForgeCartSDK {
33
+ constructor(config = {}) {
34
+ const baseEndpoint = config.endpoint || 'https://api.forgecart.com';
35
+ const baseWsEndpoint = baseEndpoint.replace('http', 'ws');
36
+ // Build headers with token
37
+ const headers = {
38
+ ...config.headers,
39
+ ...(config.token ? { 'forge-token': config.token } : {}),
40
+ };
41
+ const adminConfig = {
42
+ endpoint: `${baseEndpoint}/admin-api`,
43
+ wsEndpoint: `${baseWsEndpoint}/admin-api`,
44
+ headers,
45
+ webSocketImpl: config.webSocketImpl,
46
+ httpOnly: config.httpOnly,
47
+ };
48
+ this.admin = new AdminNamespace(adminConfig);
49
+ const shopConfig = {
50
+ endpoint: `${baseEndpoint}/shop-api`,
51
+ wsEndpoint: `${baseWsEndpoint}/shop-api`,
52
+ headers,
53
+ webSocketImpl: config.webSocketImpl,
54
+ httpOnly: config.httpOnly,
55
+ };
56
+ this.shop = new ShopNamespace(shopConfig);
57
+ }
58
+ setAdminAuthToken(token) {
59
+ this.admin.setAuthToken(token);
60
+ }
61
+ clearAdminAuthToken() {
62
+ this.admin.clearAuthToken();
63
+ }
64
+ setShopAuthToken(token) {
65
+ this.shop.setAuthToken(token);
66
+ }
67
+ clearShopAuthToken() {
68
+ this.shop.clearAuthToken();
69
+ }
70
+ dispose() {
71
+ this.admin.dispose();
72
+ this.shop.dispose();
73
+ }
74
+ }