@beep-it/sdk-core 0.1.6 → 0.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.
- package/dist/errors/index.d.ts +105 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +496 -26
- package/dist/index.mjs +480 -22
- package/dist/modules/invoices.d.ts.map +1 -1
- package/dist/modules/payments.d.ts.map +1 -1
- package/dist/modules/widget.d.ts +9 -4
- package/dist/modules/widget.d.ts.map +1 -1
- package/dist/types/cash-payment.d.ts +13 -0
- package/dist/types/cash-payment.d.ts.map +1 -0
- package/dist/types/public.d.ts +95 -1
- package/dist/types/public.d.ts.map +1 -1
- package/dist/utils/debug.d.ts +75 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/package.json +4 -3
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Enhanced error handling for the BEEP SDK
|
|
3
|
+
* Provides typed, semantic errors with proper error codes and context
|
|
4
|
+
*/
|
|
5
|
+
export declare enum BeepErrorCode {
|
|
6
|
+
INVALID_API_KEY = "BEEP_1001",
|
|
7
|
+
MISSING_API_KEY = "BEEP_1002",
|
|
8
|
+
UNAUTHORIZED = "BEEP_1003",
|
|
9
|
+
INVALID_PUBLISHABLE_KEY = "BEEP_1004",
|
|
10
|
+
NETWORK_ERROR = "BEEP_2001",
|
|
11
|
+
TIMEOUT = "BEEP_2002",
|
|
12
|
+
SERVER_ERROR = "BEEP_2003",
|
|
13
|
+
PAYMENT_FAILED = "BEEP_3001",
|
|
14
|
+
PAYMENT_EXPIRED = "BEEP_3002",
|
|
15
|
+
PAYMENT_NOT_FOUND = "BEEP_3003",
|
|
16
|
+
INSUFFICIENT_FUNDS = "BEEP_3004",
|
|
17
|
+
PAYMENT_ALREADY_PROCESSED = "BEEP_3005",
|
|
18
|
+
INVOICE_NOT_FOUND = "BEEP_4001",
|
|
19
|
+
INVOICE_EXPIRED = "BEEP_4002",
|
|
20
|
+
INVOICE_ALREADY_PAID = "BEEP_4003",
|
|
21
|
+
INVALID_PARAMETER = "BEEP_5001",
|
|
22
|
+
MISSING_PARAMETER = "BEEP_5002",
|
|
23
|
+
INVALID_AMOUNT = "BEEP_5003",
|
|
24
|
+
INVALID_TOKEN = "BEEP_5004",
|
|
25
|
+
RATE_LIMIT_EXCEEDED = "BEEP_6001",
|
|
26
|
+
UNKNOWN_ERROR = "BEEP_9999"
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Options for creating a BeepError
|
|
30
|
+
*/
|
|
31
|
+
export interface BeepErrorOptions {
|
|
32
|
+
code: BeepErrorCode;
|
|
33
|
+
statusCode?: number;
|
|
34
|
+
details?: Record<string, any>;
|
|
35
|
+
requestId?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Base error class for all BEEP SDK errors
|
|
39
|
+
* Provides structured error information for better debugging and handling
|
|
40
|
+
*/
|
|
41
|
+
export declare class BeepError extends Error {
|
|
42
|
+
readonly code: BeepErrorCode;
|
|
43
|
+
readonly statusCode?: number;
|
|
44
|
+
readonly details?: Record<string, any>;
|
|
45
|
+
readonly timestamp: Date;
|
|
46
|
+
readonly requestId?: string;
|
|
47
|
+
constructor(message: string, options: BeepErrorOptions);
|
|
48
|
+
/**
|
|
49
|
+
* Returns a user-friendly error message
|
|
50
|
+
*/
|
|
51
|
+
getUserMessage(): string;
|
|
52
|
+
/**
|
|
53
|
+
* Returns a JSON representation of the error for logging
|
|
54
|
+
*/
|
|
55
|
+
toJSON(): Record<string, any>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Options for specialized error classes
|
|
59
|
+
*/
|
|
60
|
+
export interface SpecializedErrorOptions {
|
|
61
|
+
code?: BeepErrorCode;
|
|
62
|
+
details?: Record<string, any>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Authentication error - thrown when API key is invalid or missing
|
|
66
|
+
*/
|
|
67
|
+
export declare class BeepAuthenticationError extends BeepError {
|
|
68
|
+
constructor(message: string, options?: SpecializedErrorOptions);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Validation error - thrown when request parameters are invalid
|
|
72
|
+
*/
|
|
73
|
+
export declare class BeepValidationError extends BeepError {
|
|
74
|
+
constructor(message: string, options?: SpecializedErrorOptions);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Payment error - thrown when payment operations fail
|
|
78
|
+
*/
|
|
79
|
+
export declare class BeepPaymentError extends BeepError {
|
|
80
|
+
constructor(message: string, options?: SpecializedErrorOptions);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Network error - thrown when network operations fail
|
|
84
|
+
*/
|
|
85
|
+
export declare class BeepNetworkError extends BeepError {
|
|
86
|
+
constructor(message: string, options?: SpecializedErrorOptions);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Options for rate limit error
|
|
90
|
+
*/
|
|
91
|
+
export interface RateLimitErrorOptions extends SpecializedErrorOptions {
|
|
92
|
+
retryAfter?: number;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Rate limit error - thrown when API rate limits are exceeded
|
|
96
|
+
*/
|
|
97
|
+
export declare class BeepRateLimitError extends BeepError {
|
|
98
|
+
readonly retryAfter?: number;
|
|
99
|
+
constructor(message: string, options?: RateLimitErrorOptions);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Utility function to create appropriate error from axios error response
|
|
103
|
+
*/
|
|
104
|
+
export declare function createBeepErrorFromAxios(error: any): BeepError;
|
|
105
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,oBAAY,aAAa;IAEvB,eAAe,cAAc;IAC7B,eAAe,cAAc;I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AQ,SAAS;gBACxC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,uBAA4B;CAQnE;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;gBACpC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,uBAA4B;CAQnE;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,SAAS;gBACjC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,uBAA4B;CAQnE;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,SAAS;gBACjC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,uBAA4B;CAOnE;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,uBAAuB;IACpE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,SAAS;IAC/C,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;gBAExB,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,qBAA0B;CASjE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,GAAG,GAAG,SAAS,CA4F9D"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { PaymentsModule } from './modules/payments';
|
|
|
7
7
|
import { ProductsModule } from './modules/products';
|
|
8
8
|
import { WidgetModule } from './modules/widget';
|
|
9
9
|
import { UserModule } from './modules/user';
|
|
10
|
+
import { BeepDebugOptions } from './utils/debug';
|
|
10
11
|
/**
|
|
11
12
|
* Configuration options for initializing the BeepClient
|
|
12
13
|
*/
|
|
@@ -18,6 +19,8 @@ export interface BeepClientOptions {
|
|
|
18
19
|
* @default 'https://api.justbeep.it'
|
|
19
20
|
*/
|
|
20
21
|
serverUrl?: string;
|
|
22
|
+
/** Debug options for enhanced developer experience */
|
|
23
|
+
debug?: BeepDebugOptions;
|
|
21
24
|
}
|
|
22
25
|
/**
|
|
23
26
|
* The main BEEP SDK client for server-side applications using secret API keys
|
|
@@ -57,6 +60,7 @@ export interface BeepClientOptions {
|
|
|
57
60
|
*/
|
|
58
61
|
export declare class BeepClient {
|
|
59
62
|
private client;
|
|
63
|
+
private debugger;
|
|
60
64
|
/** Access to product management functionality (server-side only) */
|
|
61
65
|
readonly products: ProductsModule;
|
|
62
66
|
/** Access to invoice management functionality (server-side only) */
|
|
@@ -179,4 +183,6 @@ export declare class BeepPublicClient {
|
|
|
179
183
|
constructor(options: BeepPublicClientOptions);
|
|
180
184
|
}
|
|
181
185
|
export type { PublicPaymentSessionRequest, PublicPaymentSessionResponse, PublicPaymentStatusResponse, EphemeralItem, } from './types/public';
|
|
186
|
+
export * from './errors';
|
|
187
|
+
export * from './types';
|
|
182
188
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,mFAAmF;IACnF,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO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