@forgecart/sdk 1.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.
package/src/admin.ts ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @forgecart/sdk - Admin API
3
+ *
4
+ * Admin namespace and types
5
+ */
6
+
7
+ export { AdminNamespace } from './admin-namespace.js'
8
+ export type { SDKConfig as AdminSDKConfig } from './admin-namespace.js'
9
+ export * from './admin-types.js'
package/src/index.ts ADDED
@@ -0,0 +1,97 @@
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
+
10
+ import { AdminNamespace, AdminSDKConfig } from './admin.js'
11
+ import { ShopNamespace, ShopSDKConfig } from './shop.js'
12
+
13
+ /**
14
+ * Unified SDK Configuration
15
+ */
16
+ export interface ForgeCartSDKConfig {
17
+ /** GraphQL HTTP endpoint for admin API */
18
+ adminEndpoint?: string
19
+ /** WebSocket endpoint for admin subscriptions */
20
+ adminWsEndpoint?: string
21
+ /** GraphQL HTTP endpoint for shop API */
22
+ shopEndpoint?: string
23
+ /** WebSocket endpoint for shop subscriptions */
24
+ shopWsEndpoint?: string
25
+ /** Custom HTTP headers */
26
+ headers?: Record<string, string>
27
+ /** Custom WebSocket implementation (optional, auto-detected if not provided) */
28
+ webSocketImpl?: unknown
29
+ }
30
+
31
+ // Re-export individual namespace configs and classes
32
+ export type { AdminSDKConfig, ShopSDKConfig }
33
+ export { AdminNamespace, ShopNamespace }
34
+
35
+ /**
36
+ * ForgeCartSDK
37
+ * Unified SDK with categorized operations across multiple namespaces
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * const sdk = new ForgeCartSDK({
42
+ * adminEndpoint: 'https://api.forgecart.com/admin-api',
43
+ * shopEndpoint: 'https://api.forgecart.com/shop-api'
44
+ * });
45
+ *
46
+ * // Admin namespace → Category → Operations
47
+ * await sdk.admin.products.products({ take: 10 });
48
+ * await sdk.admin.customer.customer({ id: '1' });
49
+ *
50
+ * // Shop namespace → Category → Operations
51
+ * await sdk.shop.products.products({ take: 10 });
52
+ * await sdk.shop.order.addItemToOrder({ productVariantId: '1', quantity: 1 });
53
+ * ```
54
+ */
55
+ export class ForgeCartSDK {
56
+ readonly admin: AdminNamespace
57
+ readonly shop: ShopNamespace
58
+
59
+ constructor(config: ForgeCartSDKConfig = {}) {
60
+ const adminConfig: AdminSDKConfig = {
61
+ endpoint: config.adminEndpoint || 'https://api.forgecart.com/admin-api',
62
+ wsEndpoint: config.adminWsEndpoint || 'wss://api.forgecart.com/admin-api',
63
+ headers: config.headers,
64
+ webSocketImpl: config.webSocketImpl,
65
+ }
66
+ this.admin = new AdminNamespace(adminConfig)
67
+
68
+ const shopConfig: ShopSDKConfig = {
69
+ endpoint: config.shopEndpoint || 'https://api.forgecart.com/shop-api',
70
+ wsEndpoint: config.shopWsEndpoint || 'wss://api.forgecart.com/shop-api',
71
+ headers: config.headers,
72
+ webSocketImpl: config.webSocketImpl,
73
+ }
74
+ this.shop = new ShopNamespace(shopConfig)
75
+ }
76
+
77
+ setAdminAuthToken(token: string): void {
78
+ this.admin.setAuthToken(token)
79
+ }
80
+
81
+ clearAdminAuthToken(): void {
82
+ this.admin.clearAuthToken()
83
+ }
84
+
85
+ setShopAuthToken(token: string): void {
86
+ this.shop.setAuthToken(token)
87
+ }
88
+
89
+ clearShopAuthToken(): void {
90
+ this.shop.clearAuthToken()
91
+ }
92
+
93
+ dispose(): void {
94
+ this.admin.dispose()
95
+ this.shop.dispose()
96
+ }
97
+ }