@stackbe/sdk 0.6.0 → 0.6.2

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/index.d.mts CHANGED
@@ -336,7 +336,7 @@ interface UpdateSubscriptionOptions {
336
336
  type StackBEErrorCode = 'TOKEN_EXPIRED' | 'TOKEN_ALREADY_USED' | 'TOKEN_INVALID' | 'SESSION_EXPIRED' | 'SESSION_INVALID' | 'UNAUTHORIZED' | 'NOT_FOUND' | 'CUSTOMER_NOT_FOUND' | 'SUBSCRIPTION_NOT_FOUND' | 'PLAN_NOT_FOUND' | 'APP_NOT_FOUND' | 'VALIDATION_ERROR' | 'MISSING_REQUIRED_FIELD' | 'INVALID_EMAIL' | 'USAGE_LIMIT_EXCEEDED' | 'METRIC_NOT_FOUND' | 'FEATURE_NOT_AVAILABLE' | 'NO_ACTIVE_SUBSCRIPTION' | 'TIMEOUT' | 'NETWORK_ERROR' | 'UNKNOWN_ERROR';
337
337
  interface StackBEErrorResponse {
338
338
  statusCode: number;
339
- message: string;
339
+ message: string | string[];
340
340
  error: string;
341
341
  code?: StackBEErrorCode;
342
342
  }
package/dist/index.d.ts CHANGED
@@ -336,7 +336,7 @@ interface UpdateSubscriptionOptions {
336
336
  type StackBEErrorCode = 'TOKEN_EXPIRED' | 'TOKEN_ALREADY_USED' | 'TOKEN_INVALID' | 'SESSION_EXPIRED' | 'SESSION_INVALID' | 'UNAUTHORIZED' | 'NOT_FOUND' | 'CUSTOMER_NOT_FOUND' | 'SUBSCRIPTION_NOT_FOUND' | 'PLAN_NOT_FOUND' | 'APP_NOT_FOUND' | 'VALIDATION_ERROR' | 'MISSING_REQUIRED_FIELD' | 'INVALID_EMAIL' | 'USAGE_LIMIT_EXCEEDED' | 'METRIC_NOT_FOUND' | 'FEATURE_NOT_AVAILABLE' | 'NO_ACTIVE_SUBSCRIPTION' | 'TIMEOUT' | 'NETWORK_ERROR' | 'UNKNOWN_ERROR';
337
337
  interface StackBEErrorResponse {
338
338
  statusCode: number;
339
- message: string;
339
+ message: string | string[];
340
340
  error: string;
341
341
  code?: StackBEErrorCode;
342
342
  }
package/dist/index.js CHANGED
@@ -73,7 +73,8 @@ function mapErrorCode(status, message, errorType) {
73
73
  if (codeFromError.includes("NOT_FOUND")) return "NOT_FOUND";
74
74
  if (codeFromError.includes("UNAUTHORIZED")) return "UNAUTHORIZED";
75
75
  }
76
- const lowerMessage = message.toLowerCase();
76
+ const messageStr = Array.isArray(message) ? message.join(" ") : String(message || "");
77
+ const lowerMessage = messageStr.toLowerCase();
77
78
  if (lowerMessage.includes("token") && lowerMessage.includes("expired")) return "TOKEN_EXPIRED";
78
79
  if (lowerMessage.includes("already been used")) return "TOKEN_ALREADY_USED";
79
80
  if (lowerMessage.includes("invalid") && lowerMessage.includes("token")) return "TOKEN_INVALID";
@@ -132,8 +133,9 @@ var HttpClient = class {
132
133
  const data = await response.json();
133
134
  if (!response.ok) {
134
135
  const errorData = data;
135
- const message = errorData.message || "Unknown error";
136
- const code = errorData.code || mapErrorCode(response.status, message, errorData.error || "");
136
+ const rawMessage = errorData.message || "Unknown error";
137
+ const message = Array.isArray(rawMessage) ? rawMessage.join(", ") : String(rawMessage);
138
+ const code = errorData.code || mapErrorCode(response.status, rawMessage, errorData.error || "");
137
139
  throw new StackBEError(message, errorData.statusCode || response.status, code);
138
140
  }
139
141
  return data;
@@ -622,6 +624,7 @@ var CheckoutClient = class {
622
624
  */
623
625
  async createSession(options) {
624
626
  const body = {
627
+ appId: this.appId,
625
628
  planId: options.planId,
626
629
  successUrl: options.successUrl,
627
630
  cancelUrl: options.cancelUrl,
package/dist/index.mjs CHANGED
@@ -40,7 +40,8 @@ function mapErrorCode(status, message, errorType) {
40
40
  if (codeFromError.includes("NOT_FOUND")) return "NOT_FOUND";
41
41
  if (codeFromError.includes("UNAUTHORIZED")) return "UNAUTHORIZED";
42
42
  }
43
- const lowerMessage = message.toLowerCase();
43
+ const messageStr = Array.isArray(message) ? message.join(" ") : String(message || "");
44
+ const lowerMessage = messageStr.toLowerCase();
44
45
  if (lowerMessage.includes("token") && lowerMessage.includes("expired")) return "TOKEN_EXPIRED";
45
46
  if (lowerMessage.includes("already been used")) return "TOKEN_ALREADY_USED";
46
47
  if (lowerMessage.includes("invalid") && lowerMessage.includes("token")) return "TOKEN_INVALID";
@@ -99,8 +100,9 @@ var HttpClient = class {
99
100
  const data = await response.json();
100
101
  if (!response.ok) {
101
102
  const errorData = data;
102
- const message = errorData.message || "Unknown error";
103
- const code = errorData.code || mapErrorCode(response.status, message, errorData.error || "");
103
+ const rawMessage = errorData.message || "Unknown error";
104
+ const message = Array.isArray(rawMessage) ? rawMessage.join(", ") : String(rawMessage);
105
+ const code = errorData.code || mapErrorCode(response.status, rawMessage, errorData.error || "");
104
106
  throw new StackBEError(message, errorData.statusCode || response.status, code);
105
107
  }
106
108
  return data;
@@ -589,6 +591,7 @@ var CheckoutClient = class {
589
591
  */
590
592
  async createSession(options) {
591
593
  const body = {
594
+ appId: this.appId,
592
595
  planId: options.planId,
593
596
  successUrl: options.successUrl,
594
597
  cancelUrl: options.cancelUrl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackbe/sdk",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "Official JavaScript/TypeScript SDK for StackBE - the billing backend for your side project",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",