@solomonai/stripe-sync-graphql-sdk 0.0.1

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 * from './gql'
package/src/index.ts ADDED
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Stripe Sync GraphQL SDK
3
+ *
4
+ * Type-safe GraphQL client for the Stripe Sync Engine API.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { createClient } from '@solomonai/stripe-sync-graphql-sdk'
9
+ *
10
+ * const client = createClient({
11
+ * endpoint: 'https://api.example.com/graphql',
12
+ * headers: {
13
+ * 'x-tenant-id': 'your-tenant-id',
14
+ * 'x-api-key': 'your-api-key',
15
+ * }
16
+ * })
17
+ *
18
+ * const { customers } = await client.getCustomers({ first: 10 })
19
+ * ```
20
+ */
21
+
22
+ import { GraphQLClient } from 'graphql-request'
23
+
24
+ // Re-export generated types and utilities
25
+ export * from './generated'
26
+
27
+ /**
28
+ * SDK client configuration options
29
+ */
30
+ export interface ClientOptions {
31
+ /** GraphQL endpoint URL */
32
+ endpoint: string
33
+ /** HTTP headers to include with every request */
34
+ headers?: Record<string, string>
35
+ /** Request timeout in milliseconds */
36
+ timeout?: number
37
+ }
38
+
39
+ /**
40
+ * Creates a GraphQL client instance for the Stripe Sync API
41
+ *
42
+ * @param options - Client configuration options
43
+ * @returns Configured GraphQLClient instance
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * const client = createClient({
48
+ * endpoint: 'https://api.example.com/graphql',
49
+ * headers: {
50
+ * 'x-tenant-id': 'tenant-123',
51
+ * }
52
+ * })
53
+ * ```
54
+ */
55
+ export function createClient(options: ClientOptions): GraphQLClient {
56
+ const config: { headers?: Record<string, string> } = {}
57
+
58
+ if (options.headers) {
59
+ config.headers = options.headers
60
+ }
61
+
62
+ // Note: graphql-request v7 doesn't support timeout in constructor
63
+ // Timeout can be implemented using AbortController if needed
64
+ // For now, we accept the option but don't use it
65
+ if (options.timeout) {
66
+ // Timeout option is accepted but not yet implemented
67
+ // TODO: Implement timeout using AbortController
68
+ }
69
+
70
+ const client = new GraphQLClient(options.endpoint, config)
71
+
72
+ return client
73
+ }
74
+
75
+ /**
76
+ * Default export for convenience
77
+ */
78
+ export default createClient