@merit-systems/echo-react-sdk 1.0.35-test.1521dfa8.0 → 1.0.35
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 +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -23133,6 +23133,19 @@ var AppsResource = class extends BaseResource {
|
|
|
23133
23133
|
return `${this.baseUrl}/app/${appId}`;
|
|
23134
23134
|
}
|
|
23135
23135
|
};
|
|
23136
|
+
var UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
23137
|
+
function validateAppId(appId, context) {
|
|
23138
|
+
if (!appId || typeof appId !== "string") {
|
|
23139
|
+
throw new Error(
|
|
23140
|
+
`Invalid Echo App ID${context ? ` in ${context}` : ""}: App ID must be a non-empty string. Received: ${typeof appId === "string" ? `"${appId}"` : typeof appId}`
|
|
23141
|
+
);
|
|
23142
|
+
}
|
|
23143
|
+
if (!UUID_REGEX.test(appId)) {
|
|
23144
|
+
throw new Error(
|
|
23145
|
+
`Invalid Echo App ID${context ? ` in ${context}` : ""}: App ID must be a valid UUID v4 format. Received: "${appId}". Expected format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx (e.g., "60601628-cdb7-481e-8f7e-921981220348")`
|
|
23146
|
+
);
|
|
23147
|
+
}
|
|
23148
|
+
}
|
|
23136
23149
|
var BalanceResource = class extends BaseResource {
|
|
23137
23150
|
constructor(http) {
|
|
23138
23151
|
super(http);
|
|
@@ -23152,6 +23165,7 @@ var BalanceResource = class extends BaseResource {
|
|
|
23152
23165
|
* @param echoAppId The Echo app ID to get free tier balance for
|
|
23153
23166
|
*/
|
|
23154
23167
|
async getFreeBalance(echoAppId) {
|
|
23168
|
+
validateAppId(echoAppId, "getFreeBalance");
|
|
23155
23169
|
return this.handleRequest(
|
|
23156
23170
|
() => this.http.get(`/api/v1/balance/${echoAppId}/free`),
|
|
23157
23171
|
"fetching free tier balance",
|
|
@@ -25628,6 +25642,7 @@ var UsersResource = class extends BaseResource {
|
|
|
25628
25642
|
* @param code The referral code to register
|
|
25629
25643
|
*/
|
|
25630
25644
|
async registerReferralCode(echoAppId, code) {
|
|
25645
|
+
validateAppId(echoAppId, "registerReferralCode");
|
|
25631
25646
|
const request = {
|
|
25632
25647
|
echoAppId,
|
|
25633
25648
|
code
|
|
@@ -25669,6 +25684,7 @@ var EchoClient = class {
|
|
|
25669
25684
|
}
|
|
25670
25685
|
};
|
|
25671
25686
|
function createEchoAnthropic({ appId, baseRouterUrl = ROUTER_BASE_URL }, getTokenFn, onInsufficientFunds) {
|
|
25687
|
+
validateAppId(appId, "createEchoAnthropic");
|
|
25672
25688
|
return createAnthropic({
|
|
25673
25689
|
baseURL: baseRouterUrl,
|
|
25674
25690
|
apiKey: "placeholder_replaced_by_echoFetch",
|
|
@@ -25685,6 +25701,7 @@ function createEchoAnthropic({ appId, baseRouterUrl = ROUTER_BASE_URL }, getToke
|
|
|
25685
25701
|
});
|
|
25686
25702
|
}
|
|
25687
25703
|
function createEchoGoogle({ appId, baseRouterUrl = ROUTER_BASE_URL }, getTokenFn, onInsufficientFunds) {
|
|
25704
|
+
validateAppId(appId, "createEchoGoogle");
|
|
25688
25705
|
return createGoogleGenerativeAI({
|
|
25689
25706
|
baseURL: baseRouterUrl,
|
|
25690
25707
|
apiKey: "placeholder_replaced_by_echoFetch",
|
|
@@ -25696,6 +25713,7 @@ function createEchoGoogle({ appId, baseRouterUrl = ROUTER_BASE_URL }, getTokenFn
|
|
|
25696
25713
|
});
|
|
25697
25714
|
}
|
|
25698
25715
|
function createEchoOpenAI({ appId, baseRouterUrl = ROUTER_BASE_URL }, getTokenFn, onInsufficientFunds) {
|
|
25716
|
+
validateAppId(appId, "createEchoOpenAI");
|
|
25699
25717
|
return createOpenAI({
|
|
25700
25718
|
baseURL: baseRouterUrl,
|
|
25701
25719
|
apiKey: "placeholder_replaced_by_echoFetch",
|
|
@@ -25707,6 +25725,7 @@ function createEchoOpenAI({ appId, baseRouterUrl = ROUTER_BASE_URL }, getTokenFn
|
|
|
25707
25725
|
});
|
|
25708
25726
|
}
|
|
25709
25727
|
function createEchoOpenRouter({ appId, baseRouterUrl = ROUTER_BASE_URL }, getTokenFn, onInsufficientFunds) {
|
|
25728
|
+
validateAppId(appId, "createEchoOpenRouter");
|
|
25710
25729
|
return createOpenRouter({
|
|
25711
25730
|
baseURL: baseRouterUrl,
|
|
25712
25731
|
apiKey: "placeholder_replaced_by_echoFetch",
|
|
@@ -26013,6 +26032,7 @@ function EchoProviderWithAuth({ config: config2, children }) {
|
|
|
26013
26032
|
);
|
|
26014
26033
|
}
|
|
26015
26034
|
function EchoProvider({ config: config2, children }) {
|
|
26035
|
+
validateAppId(config2.appId, "EchoProvider");
|
|
26016
26036
|
const [isClient, setIsClient] = useState(false);
|
|
26017
26037
|
useEffect(() => {
|
|
26018
26038
|
setIsClient(true);
|