@merit-systems/echo-react-sdk 1.0.35-test.2c287a77.0 → 1.0.36-test-pr517.a48439fc.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 +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +48 -26
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2070,7 +2070,7 @@ class Doc {
|
|
|
2070
2070
|
const version = {
|
|
2071
2071
|
major: 4,
|
|
2072
2072
|
minor: 1,
|
|
2073
|
-
patch:
|
|
2073
|
+
patch: 11
|
|
2074
2074
|
};
|
|
2075
2075
|
const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
2076
2076
|
var _a15;
|
|
@@ -2788,6 +2788,19 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
2788
2788
|
}
|
|
2789
2789
|
const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
2790
2790
|
$ZodType.init(inst, def);
|
|
2791
|
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
2792
|
+
if (!(desc == null ? void 0 : desc.get)) {
|
|
2793
|
+
const sh = def.shape;
|
|
2794
|
+
Object.defineProperty(def, "shape", {
|
|
2795
|
+
get: () => {
|
|
2796
|
+
const newSh = { ...sh };
|
|
2797
|
+
Object.defineProperty(def, "shape", {
|
|
2798
|
+
value: newSh
|
|
2799
|
+
});
|
|
2800
|
+
return newSh;
|
|
2801
|
+
}
|
|
2802
|
+
});
|
|
2803
|
+
}
|
|
2791
2804
|
const _normalized = cached(() => normalizeDef(def));
|
|
2792
2805
|
defineLazy(inst._zod, "propValues", () => {
|
|
2793
2806
|
const shape = def.shape;
|
|
@@ -9357,7 +9370,7 @@ const $output = Symbol("ZodOutput");
|
|
|
9357
9370
|
const $input = Symbol("ZodInput");
|
|
9358
9371
|
class $ZodRegistry {
|
|
9359
9372
|
constructor() {
|
|
9360
|
-
this._map = /* @__PURE__ */ new
|
|
9373
|
+
this._map = /* @__PURE__ */ new WeakMap();
|
|
9361
9374
|
this._idmap = /* @__PURE__ */ new Map();
|
|
9362
9375
|
}
|
|
9363
9376
|
add(schema, ..._meta) {
|
|
@@ -9372,7 +9385,7 @@ class $ZodRegistry {
|
|
|
9372
9385
|
return this;
|
|
9373
9386
|
}
|
|
9374
9387
|
clear() {
|
|
9375
|
-
this._map = /* @__PURE__ */ new
|
|
9388
|
+
this._map = /* @__PURE__ */ new WeakMap();
|
|
9376
9389
|
this._idmap = /* @__PURE__ */ new Map();
|
|
9377
9390
|
return this;
|
|
9378
9391
|
}
|
|
@@ -11457,16 +11470,12 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
11457
11470
|
inst.type = def.type;
|
|
11458
11471
|
Object.defineProperty(inst, "_def", { value: def });
|
|
11459
11472
|
inst.check = (...checks) => {
|
|
11460
|
-
return inst.clone(
|
|
11461
|
-
|
|
11462
|
-
...def,
|
|
11463
|
-
checks: [
|
|
11464
|
-
|
|
11465
|
-
|
|
11466
|
-
]
|
|
11467
|
-
}
|
|
11468
|
-
// { parent: true }
|
|
11469
|
-
);
|
|
11473
|
+
return inst.clone(mergeDefs(def, {
|
|
11474
|
+
checks: [
|
|
11475
|
+
...def.checks ?? [],
|
|
11476
|
+
...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
|
|
11477
|
+
]
|
|
11478
|
+
}));
|
|
11470
11479
|
};
|
|
11471
11480
|
inst.clone = (def2, params) => clone$1(inst, def2, params);
|
|
11472
11481
|
inst.brand = () => inst;
|
|
@@ -11926,7 +11935,9 @@ function keyof(schema) {
|
|
|
11926
11935
|
const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
11927
11936
|
$ZodObjectJIT.init(inst, def);
|
|
11928
11937
|
ZodType.init(inst, def);
|
|
11929
|
-
defineLazy(inst, "shape", () =>
|
|
11938
|
+
defineLazy(inst, "shape", () => {
|
|
11939
|
+
return def.shape;
|
|
11940
|
+
});
|
|
11930
11941
|
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
11931
11942
|
inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
|
|
11932
11943
|
inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
@@ -11948,10 +11959,7 @@ const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
|
11948
11959
|
function object(shape, params) {
|
|
11949
11960
|
const def = {
|
|
11950
11961
|
type: "object",
|
|
11951
|
-
|
|
11952
|
-
assignProp(this, "shape", shape ? objectClone(shape) : {});
|
|
11953
|
-
return this.shape;
|
|
11954
|
-
},
|
|
11962
|
+
shape: shape ?? {},
|
|
11955
11963
|
...normalizeParams(params)
|
|
11956
11964
|
};
|
|
11957
11965
|
return new ZodObject(def);
|
|
@@ -11959,10 +11967,7 @@ function object(shape, params) {
|
|
|
11959
11967
|
function strictObject(shape, params) {
|
|
11960
11968
|
return new ZodObject({
|
|
11961
11969
|
type: "object",
|
|
11962
|
-
|
|
11963
|
-
assignProp(this, "shape", objectClone(shape));
|
|
11964
|
-
return this.shape;
|
|
11965
|
-
},
|
|
11970
|
+
shape,
|
|
11966
11971
|
catchall: never(),
|
|
11967
11972
|
...normalizeParams(params)
|
|
11968
11973
|
});
|
|
@@ -11970,10 +11975,7 @@ function strictObject(shape, params) {
|
|
|
11970
11975
|
function looseObject(shape, params) {
|
|
11971
11976
|
return new ZodObject({
|
|
11972
11977
|
type: "object",
|
|
11973
|
-
|
|
11974
|
-
assignProp(this, "shape", objectClone(shape));
|
|
11975
|
-
return this.shape;
|
|
11976
|
-
},
|
|
11978
|
+
shape,
|
|
11977
11979
|
catchall: unknown(),
|
|
11978
11980
|
...normalizeParams(params)
|
|
11979
11981
|
});
|
|
@@ -23131,6 +23133,19 @@ var AppsResource = class extends BaseResource {
|
|
|
23131
23133
|
return `${this.baseUrl}/app/${appId}`;
|
|
23132
23134
|
}
|
|
23133
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
|
+
}
|
|
23134
23149
|
var BalanceResource = class extends BaseResource {
|
|
23135
23150
|
constructor(http) {
|
|
23136
23151
|
super(http);
|
|
@@ -23150,6 +23165,7 @@ var BalanceResource = class extends BaseResource {
|
|
|
23150
23165
|
* @param echoAppId The Echo app ID to get free tier balance for
|
|
23151
23166
|
*/
|
|
23152
23167
|
async getFreeBalance(echoAppId) {
|
|
23168
|
+
validateAppId(echoAppId, "getFreeBalance");
|
|
23153
23169
|
return this.handleRequest(
|
|
23154
23170
|
() => this.http.get(`/api/v1/balance/${echoAppId}/free`),
|
|
23155
23171
|
"fetching free tier balance",
|
|
@@ -25626,6 +25642,7 @@ var UsersResource = class extends BaseResource {
|
|
|
25626
25642
|
* @param code The referral code to register
|
|
25627
25643
|
*/
|
|
25628
25644
|
async registerReferralCode(echoAppId, code) {
|
|
25645
|
+
validateAppId(echoAppId, "registerReferralCode");
|
|
25629
25646
|
const request = {
|
|
25630
25647
|
echoAppId,
|
|
25631
25648
|
code
|
|
@@ -25667,6 +25684,7 @@ var EchoClient = class {
|
|
|
25667
25684
|
}
|
|
25668
25685
|
};
|
|
25669
25686
|
function createEchoAnthropic({ appId, baseRouterUrl = ROUTER_BASE_URL }, getTokenFn, onInsufficientFunds) {
|
|
25687
|
+
validateAppId(appId, "createEchoAnthropic");
|
|
25670
25688
|
return createAnthropic({
|
|
25671
25689
|
baseURL: baseRouterUrl,
|
|
25672
25690
|
apiKey: "placeholder_replaced_by_echoFetch",
|
|
@@ -25683,6 +25701,7 @@ function createEchoAnthropic({ appId, baseRouterUrl = ROUTER_BASE_URL }, getToke
|
|
|
25683
25701
|
});
|
|
25684
25702
|
}
|
|
25685
25703
|
function createEchoGoogle({ appId, baseRouterUrl = ROUTER_BASE_URL }, getTokenFn, onInsufficientFunds) {
|
|
25704
|
+
validateAppId(appId, "createEchoGoogle");
|
|
25686
25705
|
return createGoogleGenerativeAI({
|
|
25687
25706
|
baseURL: baseRouterUrl,
|
|
25688
25707
|
apiKey: "placeholder_replaced_by_echoFetch",
|
|
@@ -25694,6 +25713,7 @@ function createEchoGoogle({ appId, baseRouterUrl = ROUTER_BASE_URL }, getTokenFn
|
|
|
25694
25713
|
});
|
|
25695
25714
|
}
|
|
25696
25715
|
function createEchoOpenAI({ appId, baseRouterUrl = ROUTER_BASE_URL }, getTokenFn, onInsufficientFunds) {
|
|
25716
|
+
validateAppId(appId, "createEchoOpenAI");
|
|
25697
25717
|
return createOpenAI({
|
|
25698
25718
|
baseURL: baseRouterUrl,
|
|
25699
25719
|
apiKey: "placeholder_replaced_by_echoFetch",
|
|
@@ -25705,6 +25725,7 @@ function createEchoOpenAI({ appId, baseRouterUrl = ROUTER_BASE_URL }, getTokenFn
|
|
|
25705
25725
|
});
|
|
25706
25726
|
}
|
|
25707
25727
|
function createEchoOpenRouter({ appId, baseRouterUrl = ROUTER_BASE_URL }, getTokenFn, onInsufficientFunds) {
|
|
25728
|
+
validateAppId(appId, "createEchoOpenRouter");
|
|
25708
25729
|
return createOpenRouter({
|
|
25709
25730
|
baseURL: baseRouterUrl,
|
|
25710
25731
|
apiKey: "placeholder_replaced_by_echoFetch",
|
|
@@ -26011,6 +26032,7 @@ function EchoProviderWithAuth({ config: config2, children }) {
|
|
|
26011
26032
|
);
|
|
26012
26033
|
}
|
|
26013
26034
|
function EchoProvider({ config: config2, children }) {
|
|
26035
|
+
validateAppId(config2.appId, "EchoProvider");
|
|
26014
26036
|
const [isClient, setIsClient] = useState(false);
|
|
26015
26037
|
useEffect(() => {
|
|
26016
26038
|
setIsClient(true);
|