@modelrelay/sdk 0.19.0 → 0.20.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/index.cjs CHANGED
@@ -96,7 +96,11 @@ var ErrorCodes = {
96
96
  SERVICE_UNAVAILABLE: "SERVICE_UNAVAILABLE",
97
97
  INVALID_INPUT: "INVALID_INPUT",
98
98
  PAYMENT_REQUIRED: "PAYMENT_REQUIRED",
99
- METHOD_NOT_ALLOWED: "METHOD_NOT_ALLOWED"
99
+ METHOD_NOT_ALLOWED: "METHOD_NOT_ALLOWED",
100
+ /** No tiers configured for the project - create a tier first. */
101
+ NO_TIERS: "NO_TIERS",
102
+ /** No free tier available for auto-provisioning - create a free tier or use checkout flow. */
103
+ NO_FREE_TIER: "NO_FREE_TIER"
100
104
  };
101
105
  var ModelRelayError = class extends Error {
102
106
  constructor(message, opts) {
@@ -165,6 +169,29 @@ var APIError = class extends ModelRelayError {
165
169
  isUnavailable() {
166
170
  return this.code === ErrorCodes.SERVICE_UNAVAILABLE;
167
171
  }
172
+ /**
173
+ * Returns true if the error indicates no tiers are configured.
174
+ * To resolve: create at least one tier in your project dashboard.
175
+ */
176
+ isNoTiers() {
177
+ return this.code === ErrorCodes.NO_TIERS;
178
+ }
179
+ /**
180
+ * Returns true if the error indicates no free tier is available for auto-provisioning.
181
+ * To resolve: either create a free tier for automatic customer creation,
182
+ * or use the checkout flow to create paying customers first.
183
+ */
184
+ isNoFreeTier() {
185
+ return this.code === ErrorCodes.NO_FREE_TIER;
186
+ }
187
+ /**
188
+ * Returns true if this is a customer provisioning error (NO_TIERS or NO_FREE_TIER).
189
+ * These errors occur when calling frontendToken() with a customer that doesn't exist
190
+ * and automatic provisioning cannot complete.
191
+ */
192
+ isProvisioningError() {
193
+ return this.isNoTiers() || this.isNoFreeTier();
194
+ }
168
195
  };
169
196
  async function parseErrorResponse(response, retries) {
170
197
  const requestId = response.headers.get("X-ModelRelay-Chat-Request-Id") || response.headers.get("X-Request-Id") || void 0;
@@ -347,7 +374,7 @@ function isTokenReusable(token) {
347
374
  // package.json
348
375
  var package_default = {
349
376
  name: "@modelrelay/sdk",
350
- version: "0.19.0",
377
+ version: "0.20.0",
351
378
  description: "TypeScript SDK for the ModelRelay API",
352
379
  type: "module",
353
380
  main: "dist/index.cjs",
package/dist/index.d.cts CHANGED
@@ -977,6 +977,10 @@ declare const ErrorCodes: {
977
977
  readonly INVALID_INPUT: "INVALID_INPUT";
978
978
  readonly PAYMENT_REQUIRED: "PAYMENT_REQUIRED";
979
979
  readonly METHOD_NOT_ALLOWED: "METHOD_NOT_ALLOWED";
980
+ /** No tiers configured for the project - create a tier first. */
981
+ readonly NO_TIERS: "NO_TIERS";
982
+ /** No free tier available for auto-provisioning - create a free tier or use checkout flow. */
983
+ readonly NO_FREE_TIER: "NO_FREE_TIER";
980
984
  };
981
985
  type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
982
986
  type ErrorCategory = "config" | "transport" | "api";
@@ -1032,6 +1036,23 @@ declare class APIError extends ModelRelayError {
1032
1036
  isForbidden(): boolean;
1033
1037
  /** Returns true if the error is a service unavailable error. */
1034
1038
  isUnavailable(): boolean;
1039
+ /**
1040
+ * Returns true if the error indicates no tiers are configured.
1041
+ * To resolve: create at least one tier in your project dashboard.
1042
+ */
1043
+ isNoTiers(): boolean;
1044
+ /**
1045
+ * Returns true if the error indicates no free tier is available for auto-provisioning.
1046
+ * To resolve: either create a free tier for automatic customer creation,
1047
+ * or use the checkout flow to create paying customers first.
1048
+ */
1049
+ isNoFreeTier(): boolean;
1050
+ /**
1051
+ * Returns true if this is a customer provisioning error (NO_TIERS or NO_FREE_TIER).
1052
+ * These errors occur when calling frontendToken() with a customer that doesn't exist
1053
+ * and automatic provisioning cannot complete.
1054
+ */
1055
+ isProvisioningError(): boolean;
1035
1056
  }
1036
1057
  declare function parseErrorResponse(response: Response, retries?: RetryMetadata): Promise<APIError>;
1037
1058
 
package/dist/index.d.ts CHANGED
@@ -977,6 +977,10 @@ declare const ErrorCodes: {
977
977
  readonly INVALID_INPUT: "INVALID_INPUT";
978
978
  readonly PAYMENT_REQUIRED: "PAYMENT_REQUIRED";
979
979
  readonly METHOD_NOT_ALLOWED: "METHOD_NOT_ALLOWED";
980
+ /** No tiers configured for the project - create a tier first. */
981
+ readonly NO_TIERS: "NO_TIERS";
982
+ /** No free tier available for auto-provisioning - create a free tier or use checkout flow. */
983
+ readonly NO_FREE_TIER: "NO_FREE_TIER";
980
984
  };
981
985
  type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
982
986
  type ErrorCategory = "config" | "transport" | "api";
@@ -1032,6 +1036,23 @@ declare class APIError extends ModelRelayError {
1032
1036
  isForbidden(): boolean;
1033
1037
  /** Returns true if the error is a service unavailable error. */
1034
1038
  isUnavailable(): boolean;
1039
+ /**
1040
+ * Returns true if the error indicates no tiers are configured.
1041
+ * To resolve: create at least one tier in your project dashboard.
1042
+ */
1043
+ isNoTiers(): boolean;
1044
+ /**
1045
+ * Returns true if the error indicates no free tier is available for auto-provisioning.
1046
+ * To resolve: either create a free tier for automatic customer creation,
1047
+ * or use the checkout flow to create paying customers first.
1048
+ */
1049
+ isNoFreeTier(): boolean;
1050
+ /**
1051
+ * Returns true if this is a customer provisioning error (NO_TIERS or NO_FREE_TIER).
1052
+ * These errors occur when calling frontendToken() with a customer that doesn't exist
1053
+ * and automatic provisioning cannot complete.
1054
+ */
1055
+ isProvisioningError(): boolean;
1035
1056
  }
1036
1057
  declare function parseErrorResponse(response: Response, retries?: RetryMetadata): Promise<APIError>;
1037
1058
 
package/dist/index.js CHANGED
@@ -10,7 +10,11 @@ var ErrorCodes = {
10
10
  SERVICE_UNAVAILABLE: "SERVICE_UNAVAILABLE",
11
11
  INVALID_INPUT: "INVALID_INPUT",
12
12
  PAYMENT_REQUIRED: "PAYMENT_REQUIRED",
13
- METHOD_NOT_ALLOWED: "METHOD_NOT_ALLOWED"
13
+ METHOD_NOT_ALLOWED: "METHOD_NOT_ALLOWED",
14
+ /** No tiers configured for the project - create a tier first. */
15
+ NO_TIERS: "NO_TIERS",
16
+ /** No free tier available for auto-provisioning - create a free tier or use checkout flow. */
17
+ NO_FREE_TIER: "NO_FREE_TIER"
14
18
  };
15
19
  var ModelRelayError = class extends Error {
16
20
  constructor(message, opts) {
@@ -79,6 +83,29 @@ var APIError = class extends ModelRelayError {
79
83
  isUnavailable() {
80
84
  return this.code === ErrorCodes.SERVICE_UNAVAILABLE;
81
85
  }
86
+ /**
87
+ * Returns true if the error indicates no tiers are configured.
88
+ * To resolve: create at least one tier in your project dashboard.
89
+ */
90
+ isNoTiers() {
91
+ return this.code === ErrorCodes.NO_TIERS;
92
+ }
93
+ /**
94
+ * Returns true if the error indicates no free tier is available for auto-provisioning.
95
+ * To resolve: either create a free tier for automatic customer creation,
96
+ * or use the checkout flow to create paying customers first.
97
+ */
98
+ isNoFreeTier() {
99
+ return this.code === ErrorCodes.NO_FREE_TIER;
100
+ }
101
+ /**
102
+ * Returns true if this is a customer provisioning error (NO_TIERS or NO_FREE_TIER).
103
+ * These errors occur when calling frontendToken() with a customer that doesn't exist
104
+ * and automatic provisioning cannot complete.
105
+ */
106
+ isProvisioningError() {
107
+ return this.isNoTiers() || this.isNoFreeTier();
108
+ }
82
109
  };
83
110
  async function parseErrorResponse(response, retries) {
84
111
  const requestId = response.headers.get("X-ModelRelay-Chat-Request-Id") || response.headers.get("X-Request-Id") || void 0;
@@ -261,7 +288,7 @@ function isTokenReusable(token) {
261
288
  // package.json
262
289
  var package_default = {
263
290
  name: "@modelrelay/sdk",
264
- version: "0.19.0",
291
+ version: "0.20.0",
265
292
  description: "TypeScript SDK for the ModelRelay API",
266
293
  type: "module",
267
294
  main: "dist/index.cjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modelrelay/sdk",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "description": "TypeScript SDK for the ModelRelay API",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",