@use-stall/core 0.0.2 → 0.0.4
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 +345 -430
- package/dist/index.d.mts +71 -664
- package/dist/index.d.ts +71 -664
- package/dist/index.js +2084 -1247
- package/dist/index.mjs +2056 -1239
- package/package.json +6 -5
- package/bun.lock +0 -211
package/dist/index.d.mts
CHANGED
|
@@ -1,673 +1,80 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConnectorModuleKey, UnifiedProductType, UnifiedVariantsType, UnifiedCollectionType, UnifiedCategoryType, UnifiedInventoryLevelType, UnifiedPromotion, UnifiedOrderType, UnifiedOrderNote, UnifiedOrderRefundType, UnifiedPaymentProviderType, UnifiedPaymentCollectionType, UnifiedTaxRegionType, UnifiedTaxRateType, UnifiedCustomerType, UnifiedLocationType, UnifiedFulfillmentType } from '@use-stall/types';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
success: boolean;
|
|
8
|
-
data?: T;
|
|
9
|
-
error?: {
|
|
10
|
-
code: string;
|
|
11
|
-
message: string;
|
|
12
|
-
details?: Record<string, any>;
|
|
13
|
-
};
|
|
14
|
-
metadata?: {
|
|
15
|
-
timestamp: number;
|
|
16
|
-
connector_id: string;
|
|
17
|
-
operation: string;
|
|
18
|
-
request_id: string;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Pagination options for list operations
|
|
23
|
-
*/
|
|
24
|
-
interface PaginationOptions {
|
|
25
|
-
limit?: number;
|
|
26
|
-
offset?: number;
|
|
27
|
-
page?: number;
|
|
28
|
-
per_page?: number;
|
|
29
|
-
sort?: string;
|
|
30
|
-
order?: "asc" | "desc";
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Plugin metadata and capabilities
|
|
34
|
-
*/
|
|
35
|
-
interface PluginMetadata {
|
|
36
|
-
id: string;
|
|
37
|
-
version: string;
|
|
38
|
-
name: string;
|
|
39
|
-
description: string;
|
|
40
|
-
}
|
|
41
|
-
interface ModuleCapability {
|
|
42
|
-
module: "orders" | "products" | "customers" | "refunds" | "inventory" | "payments";
|
|
43
|
-
actions: {
|
|
44
|
-
create?: boolean;
|
|
45
|
-
read?: boolean;
|
|
46
|
-
update?: boolean;
|
|
47
|
-
delete?: boolean;
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Configuration passed to connector plugins
|
|
52
|
-
*/
|
|
53
|
-
interface ConnectorPluginConfig {
|
|
54
|
-
/**
|
|
55
|
-
* The connector ID from the database
|
|
56
|
-
*/
|
|
57
|
-
connectorId: string;
|
|
58
|
-
/**
|
|
59
|
-
* The integration ID (e.g., woocommerce, shopify)
|
|
60
|
-
*/
|
|
61
|
-
integrationId: string;
|
|
62
|
-
/**
|
|
63
|
-
* Organization ID for context
|
|
64
|
-
*/
|
|
65
|
-
organizationId: string;
|
|
66
|
-
/**
|
|
67
|
-
* Decrypted connector configuration with credentials
|
|
68
|
-
*/
|
|
69
|
-
configuration: {
|
|
70
|
-
endpoint: string;
|
|
71
|
-
username?: string;
|
|
72
|
-
password?: string;
|
|
73
|
-
token?: string;
|
|
74
|
-
api_key_header?: string;
|
|
75
|
-
api_key_value?: string;
|
|
76
|
-
[key: string]: any;
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* Optional additional options
|
|
80
|
-
*/
|
|
81
|
-
options?: {
|
|
82
|
-
timeout?: number;
|
|
83
|
-
retries?: number;
|
|
84
|
-
logLevel?: "debug" | "info" | "warn" | "error";
|
|
85
|
-
[key: string]: any;
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Base plugin interface that all connectors must implement
|
|
90
|
-
*/
|
|
91
|
-
interface IConnectorPlugin {
|
|
92
|
-
metadata: PluginMetadata;
|
|
93
|
-
/**
|
|
94
|
-
* Initialize the plugin with configuration
|
|
95
|
-
*/
|
|
96
|
-
initialize(config: ConnectorPluginConfig): Promise<void>;
|
|
97
|
-
/**
|
|
98
|
-
* Verify the configuration is valid and credentials work
|
|
99
|
-
*/
|
|
100
|
-
verify(): Promise<ConnectorResponse<boolean>>;
|
|
101
|
-
/**
|
|
102
|
-
* Get supported modules for this connector
|
|
103
|
-
*/
|
|
104
|
-
getSupportedModules(): string[];
|
|
105
|
-
/**
|
|
106
|
-
* Order-related operations
|
|
107
|
-
*/
|
|
108
|
-
orders: {
|
|
109
|
-
create(order: UnifiedOrderType): Promise<ConnectorResponse<any>>;
|
|
110
|
-
get(orderId: string): Promise<ConnectorResponse<any>>;
|
|
111
|
-
update(orderId: string, order: Partial<UnifiedOrderType>): Promise<ConnectorResponse<any>>;
|
|
112
|
-
delete(orderId: string): Promise<ConnectorResponse<any>>;
|
|
113
|
-
list(options?: PaginationOptions & {
|
|
114
|
-
[key: string]: any;
|
|
115
|
-
}): Promise<ConnectorResponse<any[]>>;
|
|
116
|
-
};
|
|
117
|
-
/**
|
|
118
|
-
* Product-related operations
|
|
119
|
-
*/
|
|
120
|
-
products: {
|
|
121
|
-
create(product: UnifiedProductType): Promise<ConnectorResponse<any>>;
|
|
122
|
-
get(productId: string): Promise<ConnectorResponse<any>>;
|
|
123
|
-
update(productId: string, product: Partial<UnifiedProductType>): Promise<ConnectorResponse<any>>;
|
|
124
|
-
delete(productId: string): Promise<ConnectorResponse<any>>;
|
|
125
|
-
list(options?: PaginationOptions & {
|
|
126
|
-
[key: string]: any;
|
|
127
|
-
}): Promise<ConnectorResponse<any[]>>;
|
|
128
|
-
};
|
|
129
|
-
/**
|
|
130
|
-
* Customer-related operations
|
|
131
|
-
*/
|
|
132
|
-
customers: {
|
|
133
|
-
create(customer: any): Promise<ConnectorResponse<any>>;
|
|
134
|
-
get(customerId: string): Promise<ConnectorResponse<any>>;
|
|
135
|
-
update(customerId: string, customer: any): Promise<ConnectorResponse<any>>;
|
|
136
|
-
delete(customerId: string): Promise<ConnectorResponse<any>>;
|
|
137
|
-
list(options?: PaginationOptions & {
|
|
138
|
-
[key: string]: any;
|
|
139
|
-
}): Promise<ConnectorResponse<any[]>>;
|
|
140
|
-
};
|
|
141
|
-
/**
|
|
142
|
-
* Inventory/Stock-related operations
|
|
143
|
-
*/
|
|
144
|
-
inventory: {
|
|
145
|
-
get(productId: string, variantId?: string): Promise<ConnectorResponse<any>>;
|
|
146
|
-
update(productId: string, inventory: any, variantId?: string): Promise<ConnectorResponse<any>>;
|
|
147
|
-
list(options?: PaginationOptions & {
|
|
148
|
-
[key: string]: any;
|
|
149
|
-
}): Promise<ConnectorResponse<any[]>>;
|
|
150
|
-
};
|
|
151
|
-
/**
|
|
152
|
-
* Refund-related operations
|
|
153
|
-
*/
|
|
154
|
-
refunds: {
|
|
155
|
-
create(orderId: string, refund: UnifiedOrderRefundType): Promise<ConnectorResponse<any>>;
|
|
156
|
-
get(refundId: string): Promise<ConnectorResponse<any>>;
|
|
157
|
-
list(orderId: string, options?: PaginationOptions & {
|
|
158
|
-
[key: string]: any;
|
|
159
|
-
}): Promise<ConnectorResponse<any[]>>;
|
|
160
|
-
};
|
|
161
|
-
/**
|
|
162
|
-
* Payment-related operations
|
|
163
|
-
*/
|
|
164
|
-
payments: {
|
|
165
|
-
create(payment: any): Promise<ConnectorResponse<any>>;
|
|
166
|
-
get(paymentId: string): Promise<ConnectorResponse<any>>;
|
|
167
|
-
list(options?: PaginationOptions & {
|
|
168
|
-
[key: string]: any;
|
|
169
|
-
}): Promise<ConnectorResponse<any[]>>;
|
|
170
|
-
};
|
|
171
|
-
/**
|
|
172
|
-
* Webhook support (optional)
|
|
173
|
-
*/
|
|
174
|
-
webhooks?: {
|
|
175
|
-
register(url: string, events: string[]): Promise<ConnectorResponse<any>>;
|
|
176
|
-
unregister(webhookId: string): Promise<ConnectorResponse<any>>;
|
|
177
|
-
verifySignature(payload: string, signature: string): Promise<ConnectorResponse<boolean>>;
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Plugin constructor type for dynamic loading
|
|
182
|
-
*/
|
|
183
|
-
type PluginConstructor = new () => IConnectorPlugin;
|
|
184
|
-
/**
|
|
185
|
-
* Plugin module structure when loaded from storage
|
|
186
|
-
*/
|
|
187
|
-
interface PluginModule {
|
|
188
|
-
default: PluginConstructor;
|
|
189
|
-
Plugin?: PluginConstructor;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Options for initializing the Stall SDK
|
|
194
|
-
* Uses ConnectorConfigurationType directly for configuration
|
|
195
|
-
*/
|
|
196
|
-
interface StallSDKOptions extends ConnectorConfigurationType {
|
|
197
|
-
/**
|
|
198
|
-
* Optional additional options
|
|
199
|
-
*/
|
|
200
|
-
options?: {
|
|
201
|
-
timeout?: number;
|
|
202
|
-
retries?: number;
|
|
203
|
-
logLevel?: "debug" | "info" | "warn" | "error";
|
|
204
|
-
cachePlugins?: boolean;
|
|
205
|
-
connectorUrl?: string;
|
|
206
|
-
[key: string]: any;
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Connector loader options
|
|
211
|
-
*/
|
|
212
|
-
interface ConnectorLoaderOptions {
|
|
213
|
-
/**
|
|
214
|
-
* Base URL for loading connector plugins
|
|
215
|
-
* e.g., https://connectors.myapp.xyz
|
|
216
|
-
*/
|
|
217
|
-
connectorUrl: string;
|
|
218
|
-
/**
|
|
219
|
-
* Whether to cache loaded plugins in memory
|
|
220
|
-
*/
|
|
221
|
-
cache?: boolean;
|
|
222
|
-
/**
|
|
223
|
-
* Cache TTL in milliseconds (default: 1 hour)
|
|
224
|
-
*/
|
|
225
|
-
cacheTtl?: number;
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Error response from connector operations
|
|
229
|
-
*/
|
|
230
|
-
interface ConnectorError extends Error {
|
|
231
|
-
code: string;
|
|
232
|
-
details?: any;
|
|
233
|
-
statusCode?: number;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Operation metadata
|
|
237
|
-
*/
|
|
238
|
-
interface OperationMetadata {
|
|
239
|
-
connector_id: string;
|
|
240
|
-
integration_id: string;
|
|
241
|
-
organization_id: string;
|
|
242
|
-
operation: string;
|
|
243
|
-
timestamp: number;
|
|
244
|
-
request_id: string;
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Batch operation options
|
|
248
|
-
*/
|
|
249
|
-
interface BatchOperationOptions {
|
|
250
|
-
/**
|
|
251
|
-
* Whether to stop on first error
|
|
252
|
-
*/
|
|
253
|
-
stopOnError?: boolean;
|
|
254
|
-
/**
|
|
255
|
-
* Parallel execution count
|
|
256
|
-
*/
|
|
257
|
-
parallel?: number;
|
|
258
|
-
/**
|
|
259
|
-
* Timeout per item in milliseconds
|
|
260
|
-
*/
|
|
261
|
-
timeout?: number;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Manages connector plugin lifecycle and operations
|
|
266
|
-
*/
|
|
267
|
-
declare class PluginManager {
|
|
268
|
-
private plugin;
|
|
269
|
-
private logger;
|
|
270
|
-
private connectorLoader;
|
|
271
|
-
private initialized;
|
|
272
|
-
constructor(logLevel?: "debug" | "info" | "warn" | "error");
|
|
273
|
-
/**
|
|
274
|
-
* Initialize the plugin manager with a plugin
|
|
275
|
-
*/
|
|
276
|
-
initialize(plugin: IConnectorPlugin | null, options: StallSDKOptions): Promise<void>;
|
|
277
|
-
/**
|
|
278
|
-
* Get the loaded plugin
|
|
279
|
-
*/
|
|
280
|
-
getPlugin(): IConnectorPlugin;
|
|
281
|
-
/**
|
|
282
|
-
* Check if plugin is initialized
|
|
283
|
-
*/
|
|
284
|
-
isInitialized(): boolean;
|
|
285
|
-
/**
|
|
286
|
-
* Verify the plugin configuration
|
|
287
|
-
*/
|
|
288
|
-
verify(): Promise<boolean>;
|
|
289
|
-
/**
|
|
290
|
-
* Get metadata about the loaded plugin
|
|
291
|
-
*/
|
|
292
|
-
getMetadata(): {
|
|
293
|
-
id: string;
|
|
294
|
-
name: string;
|
|
295
|
-
version: string;
|
|
296
|
-
description: string;
|
|
297
|
-
supportedModules: string[];
|
|
298
|
-
};
|
|
299
|
-
/**
|
|
300
|
-
* Check if a module is supported
|
|
301
|
-
*/
|
|
302
|
-
isModuleSupported(module: string): boolean;
|
|
303
|
-
/**
|
|
304
|
-
* Clear plugin cache (if using remote loading)
|
|
305
|
-
*/
|
|
306
|
-
clearCache(): void;
|
|
3
|
+
interface StallCoreConfigOptions {
|
|
4
|
+
connector_url: string;
|
|
5
|
+
version: string;
|
|
6
|
+
configuration: Record<string, any>;
|
|
307
7
|
}
|
|
308
8
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
declare class Logger {
|
|
314
|
-
private level;
|
|
315
|
-
private context;
|
|
316
|
-
constructor(context?: string, level?: LogLevel);
|
|
317
|
-
private shouldLog;
|
|
318
|
-
private format;
|
|
319
|
-
debug(message: string, data?: any): void;
|
|
320
|
-
info(message: string, data?: any): void;
|
|
321
|
-
warn(message: string, data?: any): void;
|
|
322
|
-
error(message: string, error?: Error | any): void;
|
|
323
|
-
setLevel(level: LogLevel): void;
|
|
9
|
+
interface CoreConfig {
|
|
10
|
+
options: StallCoreConfigOptions;
|
|
11
|
+
adapter: () => Promise<AdapterModuleType>;
|
|
12
|
+
refreshAdapter: () => Promise<AdapterModuleType>;
|
|
324
13
|
}
|
|
325
|
-
/**
|
|
326
|
-
* Create a logger instance
|
|
327
|
-
*/
|
|
328
|
-
declare function createLogger(context?: string, level?: LogLevel): Logger;
|
|
329
14
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
*/
|
|
353
|
-
protected ensurePluginInitialized(): void;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* Service for managing orders through connectors
|
|
358
|
-
*/
|
|
359
|
-
declare class OrdersService extends BaseService {
|
|
360
|
-
constructor(pluginManager: PluginManager, connectorId: string);
|
|
361
|
-
/**
|
|
362
|
-
* Create a new order
|
|
363
|
-
*/
|
|
364
|
-
createOrder(order: UnifiedOrderType): Promise<ConnectorResponse<UnifiedOrderType>>;
|
|
365
|
-
/**
|
|
366
|
-
* Get an order by ID
|
|
367
|
-
*/
|
|
368
|
-
getOrder(orderId: string): Promise<ConnectorResponse<UnifiedOrderType>>;
|
|
369
|
-
/**
|
|
370
|
-
* Update an existing order
|
|
371
|
-
*/
|
|
372
|
-
updateOrder(orderId: string, order: Partial<UnifiedOrderType>): Promise<ConnectorResponse<UnifiedOrderType>>;
|
|
373
|
-
/**
|
|
374
|
-
* Delete/cancel an order
|
|
375
|
-
*/
|
|
376
|
-
deleteOrder(orderId: string): Promise<ConnectorResponse<void>>;
|
|
377
|
-
/**
|
|
378
|
-
* List orders with optional filtering
|
|
379
|
-
*/
|
|
380
|
-
listOrders(options?: PaginationOptions & {
|
|
381
|
-
[key: string]: any;
|
|
382
|
-
}): Promise<ConnectorResponse<UnifiedOrderType[]>>;
|
|
383
|
-
/**
|
|
384
|
-
* Create a refund for an order
|
|
385
|
-
*/
|
|
386
|
-
createRefund(orderId: string, refund: UnifiedOrderRefundType): Promise<ConnectorResponse<UnifiedOrderRefundType>>;
|
|
387
|
-
/**
|
|
388
|
-
* Get a refund by ID
|
|
389
|
-
*/
|
|
390
|
-
getRefund(refundId: string): Promise<ConnectorResponse<UnifiedOrderRefundType>>;
|
|
391
|
-
/**
|
|
392
|
-
* List refunds for an order
|
|
393
|
-
*/
|
|
394
|
-
listRefunds(orderId: string, options?: PaginationOptions & {
|
|
395
|
-
[key: string]: any;
|
|
396
|
-
}): Promise<ConnectorResponse<UnifiedOrderRefundType[]>>;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
* Service for managing products through connectors
|
|
401
|
-
*/
|
|
402
|
-
declare class ProductsService extends BaseService {
|
|
403
|
-
constructor(pluginManager: PluginManager, connectorId: string);
|
|
404
|
-
/**
|
|
405
|
-
* Create a new product
|
|
406
|
-
*/
|
|
407
|
-
createProduct(product: UnifiedProductType): Promise<ConnectorResponse<UnifiedProductType>>;
|
|
408
|
-
/**
|
|
409
|
-
* Get a product by ID
|
|
410
|
-
*/
|
|
411
|
-
getProduct(productId: string): Promise<ConnectorResponse<UnifiedProductType>>;
|
|
412
|
-
/**
|
|
413
|
-
* Update an existing product
|
|
414
|
-
*/
|
|
415
|
-
updateProduct(productId: string, product: Partial<UnifiedProductType>): Promise<ConnectorResponse<UnifiedProductType>>;
|
|
416
|
-
/**
|
|
417
|
-
* Delete a product
|
|
418
|
-
*/
|
|
419
|
-
deleteProduct(productId: string): Promise<ConnectorResponse<void>>;
|
|
420
|
-
/**
|
|
421
|
-
* List products with optional filtering
|
|
422
|
-
*/
|
|
423
|
-
listProducts(options?: PaginationOptions & {
|
|
424
|
-
[key: string]: any;
|
|
425
|
-
}): Promise<ConnectorResponse<UnifiedProductType[]>>;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* Main Stall Core for unified connector access
|
|
430
|
-
* Firebase-style initialization using ConnectorConfigurationType
|
|
431
|
-
*
|
|
432
|
-
* Usage:
|
|
433
|
-
* const stall = await StallCore.initialize({
|
|
434
|
-
* id: 'config_123',
|
|
435
|
-
* integration_id: 'woocommerce',
|
|
436
|
-
* created_at: Date.now(),
|
|
437
|
-
* updated_at: Date.now(),
|
|
438
|
-
* configuration: {
|
|
439
|
-
* endpoint: 'https://myshop.com',
|
|
440
|
-
* token: 'decrypted_token',
|
|
441
|
-
* },
|
|
442
|
-
* options: {
|
|
443
|
-
* logLevel: 'info',
|
|
444
|
-
* connectorUrl: 'https://connectors.myapp.xyz'
|
|
445
|
-
* }
|
|
446
|
-
* });
|
|
447
|
-
*
|
|
448
|
-
* // Then use services
|
|
449
|
-
* const result = await stall.orders.createOrder(unifiedOrder);
|
|
450
|
-
* const products = await stall.products.listProducts();
|
|
451
|
-
*/
|
|
452
|
-
declare class StallCore {
|
|
453
|
-
private pluginManager;
|
|
454
|
-
private logger;
|
|
455
|
-
private options;
|
|
456
|
-
orders: OrdersService;
|
|
457
|
-
products: ProductsService;
|
|
458
|
-
private constructor();
|
|
459
|
-
/**
|
|
460
|
-
* Firebase-style initialization with automatic plugin loading
|
|
461
|
-
* Loads connector from public URL: {connectorUrl}/{integration_id}/index.js
|
|
462
|
-
* Default URL: https://connectors.myapp.xyz
|
|
463
|
-
*/
|
|
464
|
-
static initialize(options: StallSDKOptions): Promise<StallCore>;
|
|
465
|
-
/**
|
|
466
|
-
* Initialize with a provided plugin instance (for testing/custom plugins)
|
|
467
|
-
* Useful for mock plugins or custom implementations
|
|
468
|
-
*/
|
|
469
|
-
static initializeWithPlugin(options: StallSDKOptions, plugin: IConnectorPlugin): Promise<StallCore>;
|
|
470
|
-
/**
|
|
471
|
-
* Get plugin metadata
|
|
472
|
-
*/
|
|
473
|
-
getMetadata(): {
|
|
474
|
-
id: string;
|
|
475
|
-
name: string;
|
|
476
|
-
version: string;
|
|
477
|
-
description: string;
|
|
478
|
-
supportedModules: string[];
|
|
479
|
-
};
|
|
480
|
-
/**
|
|
481
|
-
* Verify the connector configuration
|
|
482
|
-
*/
|
|
483
|
-
verify(): Promise<boolean>;
|
|
484
|
-
/**
|
|
485
|
-
* Check if a module is supported
|
|
486
|
-
*/
|
|
487
|
-
isModuleSupported(module: string): boolean;
|
|
488
|
-
/**
|
|
489
|
-
* Check if SDK is initialized
|
|
490
|
-
*/
|
|
491
|
-
isInitialized(): boolean;
|
|
492
|
-
/**
|
|
493
|
-
* Clear plugin cache
|
|
494
|
-
*/
|
|
495
|
-
clearCache(): void;
|
|
496
|
-
/**
|
|
497
|
-
* Get the underlying plugin instance
|
|
498
|
-
*/
|
|
499
|
-
getPlugin(): IConnectorPlugin;
|
|
500
|
-
/**
|
|
501
|
-
* Get SDK configuration
|
|
502
|
-
*/
|
|
503
|
-
getConfiguration(): {
|
|
504
|
-
id: string;
|
|
505
|
-
integration_id: string;
|
|
506
|
-
created_at: number;
|
|
507
|
-
updated_at: number;
|
|
508
|
-
};
|
|
509
|
-
}
|
|
15
|
+
type ModuleTypeMap = {
|
|
16
|
+
products: UnifiedProductType;
|
|
17
|
+
variants: UnifiedVariantsType;
|
|
18
|
+
collections: UnifiedCollectionType;
|
|
19
|
+
categories: UnifiedCategoryType;
|
|
20
|
+
tags: string;
|
|
21
|
+
inventory_levels: UnifiedInventoryLevelType;
|
|
22
|
+
inventory_history: UnifiedInventoryLevelType;
|
|
23
|
+
promotions: UnifiedPromotion;
|
|
24
|
+
orders: UnifiedOrderType;
|
|
25
|
+
order_notes: UnifiedOrderNote;
|
|
26
|
+
refunds: UnifiedOrderRefundType;
|
|
27
|
+
payment_providers: UnifiedPaymentProviderType;
|
|
28
|
+
payments: UnifiedPaymentCollectionType;
|
|
29
|
+
tax_regions: UnifiedTaxRegionType;
|
|
30
|
+
tax_rates: UnifiedTaxRateType;
|
|
31
|
+
customers: UnifiedCustomerType;
|
|
32
|
+
locations: UnifiedLocationType;
|
|
33
|
+
fulfillment_types: string;
|
|
34
|
+
fulfillment_providers: string;
|
|
35
|
+
fulfillments: UnifiedFulfillmentType;
|
|
36
|
+
};
|
|
510
37
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
*/
|
|
515
|
-
declare class ConnectorLoader {
|
|
516
|
-
private logger;
|
|
517
|
-
private connectorUrl;
|
|
518
|
-
private cache;
|
|
519
|
-
private cacheTtl;
|
|
520
|
-
constructor(options: ConnectorLoaderOptions);
|
|
521
|
-
/**
|
|
522
|
-
* Load a connector plugin from public URL
|
|
523
|
-
* URL pattern: {connectorUrl}/{integrationId}/index.js
|
|
524
|
-
*/
|
|
525
|
-
loadConnector(integrationId: string): Promise<IConnectorPlugin>;
|
|
526
|
-
/**
|
|
527
|
-
* Instantiate a plugin from code
|
|
528
|
-
*/
|
|
529
|
-
private instantiatePlugin;
|
|
530
|
-
/**
|
|
531
|
-
* Validate that an object implements IConnectorPlugin
|
|
532
|
-
*/
|
|
533
|
-
private validatePlugin;
|
|
534
|
-
/**
|
|
535
|
-
* Build the connector plugin URL
|
|
536
|
-
* Pattern: {connectorUrl}/{integrationId}/index.js
|
|
537
|
-
*/
|
|
538
|
-
private buildConnectorUrl;
|
|
539
|
-
/**
|
|
540
|
-
* Create a proxy for require() in loaded plugins
|
|
541
|
-
*/
|
|
542
|
-
private createRequireProxy;
|
|
543
|
-
/**
|
|
544
|
-
* Clear the cache
|
|
545
|
-
*/
|
|
546
|
-
clearCache(): void;
|
|
547
|
-
/**
|
|
548
|
-
* Remove a specific plugin from cache
|
|
549
|
-
*/
|
|
550
|
-
removeCacheEntry(integrationId: string): void;
|
|
551
|
-
}
|
|
38
|
+
type GetModuleType<K extends ConnectorModuleKey> = K extends keyof ModuleTypeMap
|
|
39
|
+
? ModuleTypeMap[K]
|
|
40
|
+
: never;
|
|
552
41
|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
42
|
+
type AdapterModuleType = {
|
|
43
|
+
[K in ConnectorModuleKey]: {
|
|
44
|
+
list: (props: {
|
|
45
|
+
connector_config: Record<string, any>;
|
|
46
|
+
query?: string;
|
|
47
|
+
}) => Promise<GetModuleType<K>[]>;
|
|
48
|
+
retrieve: (props: {
|
|
49
|
+
connector_config: Record<string, any>;
|
|
50
|
+
id: string;
|
|
51
|
+
}) => Promise<GetModuleType<K>>;
|
|
52
|
+
create: (props: {
|
|
53
|
+
connector_config: Record<string, any>;
|
|
54
|
+
data: GetModuleType<K>;
|
|
55
|
+
}) => Promise<GetModuleType<K>>;
|
|
56
|
+
update: (props: {
|
|
57
|
+
connector_config: Record<string, any>;
|
|
58
|
+
id: string;
|
|
59
|
+
data: Partial<GetModuleType<K>>;
|
|
60
|
+
}) => Promise<GetModuleType<K>>;
|
|
61
|
+
delete: (props: {
|
|
62
|
+
connector_config: Record<string, any>;
|
|
63
|
+
id: string;
|
|
64
|
+
}) => Promise<void>;
|
|
65
|
+
bulk_create: (props: {
|
|
66
|
+
connector_config: Record<string, any>;
|
|
67
|
+
data: GetModuleType<K>[];
|
|
68
|
+
}) => Promise<GetModuleType<K>[]>;
|
|
69
|
+
bulk_update: (props: {
|
|
70
|
+
connector_config: Record<string, any>;
|
|
71
|
+
data: Array<{ id: string; data: Partial<GetModuleType<K>> }>;
|
|
72
|
+
}) => Promise<GetModuleType<K>[]>;
|
|
73
|
+
bulk_delete: (props: {
|
|
74
|
+
connector_config: Record<string, any>;
|
|
75
|
+
ids: string[];
|
|
76
|
+
}) => Promise<void>;
|
|
77
|
+
};
|
|
585
78
|
};
|
|
586
|
-
/**
|
|
587
|
-
* Handle errors from connector operations
|
|
588
|
-
*/
|
|
589
|
-
declare function handleConnectorError(error: any, context: string): StallConnectorError;
|
|
590
|
-
/**
|
|
591
|
-
* Create a ConnectorResponse error format
|
|
592
|
-
*/
|
|
593
|
-
declare function createErrorResponse(error: Error | StallConnectorError, operation: string, connectorId: string): {
|
|
594
|
-
success: boolean;
|
|
595
|
-
error: {
|
|
596
|
-
code: string;
|
|
597
|
-
message: string;
|
|
598
|
-
details: any;
|
|
599
|
-
};
|
|
600
|
-
metadata: {
|
|
601
|
-
connector_id: string;
|
|
602
|
-
operation: string;
|
|
603
|
-
timestamp: number;
|
|
604
|
-
request_id: string;
|
|
605
|
-
};
|
|
606
|
-
};
|
|
607
|
-
/**
|
|
608
|
-
* Generate a unique request ID
|
|
609
|
-
*/
|
|
610
|
-
declare function generateRequestId(): string;
|
|
611
|
-
|
|
612
|
-
/**
|
|
613
|
-
* Mock connector plugin for development and testing
|
|
614
|
-
* This demonstrates the plugin interface and can be used as a template
|
|
615
|
-
*/
|
|
616
|
-
declare class MockConnectorPlugin implements IConnectorPlugin {
|
|
617
|
-
metadata: PluginMetadata;
|
|
618
|
-
private config;
|
|
619
|
-
private initialized;
|
|
620
|
-
initialize(config: ConnectorPluginConfig): Promise<void>;
|
|
621
|
-
verify(): Promise<ConnectorResponse<boolean>>;
|
|
622
|
-
getSupportedModules(): string[];
|
|
623
|
-
orders: {
|
|
624
|
-
create: (order: UnifiedOrderType) => Promise<ConnectorResponse<any>>;
|
|
625
|
-
get: (orderId: string) => Promise<ConnectorResponse<any>>;
|
|
626
|
-
update: (orderId: string, order: Partial<UnifiedOrderType>) => Promise<ConnectorResponse<any>>;
|
|
627
|
-
delete: (orderId: string) => Promise<ConnectorResponse<any>>;
|
|
628
|
-
list: (options?: PaginationOptions & {
|
|
629
|
-
[key: string]: any;
|
|
630
|
-
}) => Promise<ConnectorResponse<any[]>>;
|
|
631
|
-
};
|
|
632
|
-
products: {
|
|
633
|
-
create: (product: UnifiedProductType) => Promise<ConnectorResponse<any>>;
|
|
634
|
-
get: (productId: string) => Promise<ConnectorResponse<any>>;
|
|
635
|
-
update: (productId: string, product: Partial<UnifiedProductType>) => Promise<ConnectorResponse<any>>;
|
|
636
|
-
delete: (productId: string) => Promise<ConnectorResponse<any>>;
|
|
637
|
-
list: (options?: PaginationOptions & {
|
|
638
|
-
[key: string]: any;
|
|
639
|
-
}) => Promise<ConnectorResponse<any[]>>;
|
|
640
|
-
};
|
|
641
|
-
customers: {
|
|
642
|
-
create: (customer: any) => Promise<ConnectorResponse<any>>;
|
|
643
|
-
get: (customerId: string) => Promise<ConnectorResponse<any>>;
|
|
644
|
-
update: (customerId: string, customer: any) => Promise<ConnectorResponse<any>>;
|
|
645
|
-
delete: (customerId: string) => Promise<ConnectorResponse<any>>;
|
|
646
|
-
list: (options?: PaginationOptions & {
|
|
647
|
-
[key: string]: any;
|
|
648
|
-
}) => Promise<ConnectorResponse<any[]>>;
|
|
649
|
-
};
|
|
650
|
-
inventory: {
|
|
651
|
-
get: (productId: string, variantId?: string) => Promise<ConnectorResponse<any>>;
|
|
652
|
-
update: (productId: string, inventory: any, variantId?: string) => Promise<ConnectorResponse<any>>;
|
|
653
|
-
list: (options?: PaginationOptions & {
|
|
654
|
-
[key: string]: any;
|
|
655
|
-
}) => Promise<ConnectorResponse<any[]>>;
|
|
656
|
-
};
|
|
657
|
-
refunds: {
|
|
658
|
-
create: (orderId: string, refund: UnifiedOrderRefundType) => Promise<ConnectorResponse<any>>;
|
|
659
|
-
get: (refundId: string) => Promise<ConnectorResponse<any>>;
|
|
660
|
-
list: (orderId: string, options?: PaginationOptions & {
|
|
661
|
-
[key: string]: any;
|
|
662
|
-
}) => Promise<ConnectorResponse<any[]>>;
|
|
663
|
-
};
|
|
664
|
-
payments: {
|
|
665
|
-
create: (payment: any) => Promise<ConnectorResponse<any>>;
|
|
666
|
-
get: (paymentId: string) => Promise<ConnectorResponse<any>>;
|
|
667
|
-
list: (options?: PaginationOptions & {
|
|
668
|
-
[key: string]: any;
|
|
669
|
-
}) => Promise<ConnectorResponse<any[]>>;
|
|
670
|
-
};
|
|
671
|
-
}
|
|
672
79
|
|
|
673
|
-
export
|
|
80
|
+
export type { AdapterModuleType, CoreConfig, StallCoreConfigOptions };
|