@oppulence/stripe-sync-engine-sdk 0.0.1-alpha

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/README.md ADDED
@@ -0,0 +1,177 @@
1
+ # Oppulence Stripe Sync SDK for TypeScript
2
+
3
+ TypeScript/JavaScript SDK for interacting with the Oppulence Stripe Sync Engine API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @oppulence/stripe-sync-engine-sdk
9
+ ```
10
+
11
+ or with yarn:
12
+
13
+ ```bash
14
+ yarn add @oppulence/stripe-sync-engine-sdk
15
+ ```
16
+
17
+ or with pnpm:
18
+
19
+ ```bash
20
+ pnpm add @oppulence/stripe-sync-engine-sdk
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ### Basic Setup
26
+
27
+ ```typescript
28
+ import { Configuration, TenantsApi, SyncApi } from '@oppulence/stripe-sync-engine-sdk';
29
+
30
+ // Configure the SDK with your API credentials
31
+ const config = new Configuration({
32
+ basePath: 'https://your-sync-engine.example.com',
33
+ headers: {
34
+ 'x-api-key': 'your-api-key-here'
35
+ }
36
+ });
37
+
38
+ // Initialize API clients
39
+ const tenantsApi = new TenantsApi(config);
40
+ const syncApi = new SyncApi(config);
41
+ ```
42
+
43
+ ### Create a Tenant
44
+
45
+ ```typescript
46
+ const createTenantResponse = await tenantsApi.createTenant({
47
+ createTenantRequest: {
48
+ tenantId: 'customer-123',
49
+ stripeSecretKey: 'sk_test_...',
50
+ // optional fields
51
+ webhookSecret: 'whsec_...',
52
+ metadata: { customerId: '123' }
53
+ }
54
+ });
55
+
56
+ console.log('Tenant created:', createTenantResponse);
57
+ ```
58
+
59
+ ### Trigger a Sync
60
+
61
+ ```typescript
62
+ const syncResponse = await syncApi.syncTenant({
63
+ tenantId: 'customer-123'
64
+ });
65
+
66
+ console.log('Sync initiated:', syncResponse);
67
+ ```
68
+
69
+ ### List Tenants
70
+
71
+ ```typescript
72
+ const tenants = await tenantsApi.listTenants({
73
+ limit: 100,
74
+ offset: 0
75
+ });
76
+
77
+ console.log('Tenants:', tenants.data);
78
+ ```
79
+
80
+ ### Get Tenant Health
81
+
82
+ ```typescript
83
+ const health = await tenantsApi.getTenantHealth({
84
+ tenantId: 'customer-123'
85
+ });
86
+
87
+ console.log('Tenant health:', health);
88
+ ```
89
+
90
+ ### Trigger Backfill
91
+
92
+ ```typescript
93
+ const backfillResponse = await syncApi.syncBackfill({
94
+ tenantId: 'customer-123',
95
+ syncBackfillRequest: {
96
+ entities: ['customer', 'subscription', 'invoice'],
97
+ startDate: '2024-01-01',
98
+ endDate: '2024-12-31'
99
+ }
100
+ });
101
+
102
+ console.log('Backfill initiated:', backfillResponse);
103
+ ```
104
+
105
+ ## API Reference
106
+
107
+ ### Available APIs
108
+
109
+ - **TenantsApi**: Manage tenants (create, update, list, delete)
110
+ - **SyncApi**: Trigger sync operations
111
+ - **HealthApi**: Check API and tenant health status
112
+ - **WebhooksApi**: Process webhooks
113
+
114
+ ### Configuration Options
115
+
116
+ ```typescript
117
+ const config = new Configuration({
118
+ basePath: 'https://api.example.com', // API base URL
119
+ headers: {
120
+ 'x-api-key': 'your-api-key', // API key for authentication
121
+ 'Content-Type': 'application/json'
122
+ },
123
+ fetchApi: fetch, // Optional: custom fetch implementation
124
+ });
125
+ ```
126
+
127
+ ## Error Handling
128
+
129
+ ```typescript
130
+ try {
131
+ const response = await tenantsApi.createTenant({
132
+ createTenantRequest: { /* ... */ }
133
+ });
134
+ } catch (error) {
135
+ if (error instanceof Response) {
136
+ const errorData = await error.json();
137
+ console.error('API Error:', errorData);
138
+ } else {
139
+ console.error('Unexpected error:', error);
140
+ }
141
+ }
142
+ ```
143
+
144
+ ## TypeScript Support
145
+
146
+ This SDK is written in TypeScript and provides full type definitions out of the box. All request and response types are exported and can be imported:
147
+
148
+ ```typescript
149
+ import type {
150
+ CreateTenantRequest,
151
+ CreateTenant201Response,
152
+ ListTenants200Response,
153
+ SyncBackfillRequest
154
+ } from '@oppulence/stripe-sync-engine-sdk';
155
+ ```
156
+
157
+ ## Development
158
+
159
+ ### Building
160
+
161
+ ```bash
162
+ npm run build
163
+ ```
164
+
165
+ ### Publishing
166
+
167
+ This SDK is automatically published to npm when a new release is created. See the main repository documentation for release procedures.
168
+
169
+ ## Support
170
+
171
+ For issues and questions, please visit:
172
+ - GitHub Issues: https://github.com/Oppulence-Engineering/oppulence-sync-engine/issues
173
+ - Documentation: https://github.com/Oppulence-Engineering/oppulence-sync-engine
174
+
175
+ ## License
176
+
177
+ MIT