@onyx.dev/onyx-database 2.0.1 → 2.1.1
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/README.md +42 -14
- package/dist/{aggregates-BPpzRHGH.d.cts → aggregates-BFOBBZkW.d.cts} +1 -1
- package/dist/{aggregates-BPpzRHGH.d.ts → aggregates-BFOBBZkW.d.ts} +1 -1
- package/dist/edge.cjs +25 -8
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.d.cts +2 -2
- package/dist/edge.d.ts +2 -2
- package/dist/edge.js +25 -8
- package/dist/edge.js.map +1 -1
- package/dist/gen/cli/generate.cjs +29 -13
- package/dist/gen/cli/generate.cjs.map +1 -1
- package/dist/index.cjs +25 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +25 -8
- package/dist/index.js.map +1 -1
- package/dist/schema/cli/schema.cjs +24 -7
- package/dist/schema/cli/schema.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -233,7 +233,6 @@ async function resolveConfig(input) {
|
|
|
233
233
|
const maxRetries = retryConfig.maxRetries ?? 3;
|
|
234
234
|
const retryInitialDelayMs = retryConfig.initialDelayMs ?? 300;
|
|
235
235
|
const missing = [];
|
|
236
|
-
if (!databaseId) missing.push("databaseId");
|
|
237
236
|
if (!apiKey) missing.push("apiKey");
|
|
238
237
|
if (!apiSecret) missing.push("apiSecret");
|
|
239
238
|
if (missing.length) {
|
|
@@ -2256,20 +2255,38 @@ var AiChatClientImpl = class {
|
|
|
2256
2255
|
}
|
|
2257
2256
|
};
|
|
2258
2257
|
function createOnyxFacade(resolveConfig2) {
|
|
2259
|
-
|
|
2258
|
+
const cachedCfgs = /* @__PURE__ */ new Map();
|
|
2259
|
+
const cacheKey = (databaseId, apiKey) => {
|
|
2260
|
+
const id = typeof databaseId === "string" && databaseId.trim() !== "" ? databaseId.trim() : null;
|
|
2261
|
+
const key = typeof apiKey === "string" && apiKey.trim() !== "" ? apiKey.trim() : null;
|
|
2262
|
+
return id && key ? `${id}-${key}` : null;
|
|
2263
|
+
};
|
|
2260
2264
|
function resolveConfigWithCache(config) {
|
|
2261
2265
|
const ttl = config?.ttl ?? DEFAULT_CACHE_TTL;
|
|
2262
2266
|
const now = Date.now();
|
|
2263
|
-
|
|
2264
|
-
|
|
2267
|
+
const hintKey = cacheKey(config?.databaseId, config?.apiKey) ?? "__default__";
|
|
2268
|
+
const existing = cachedCfgs.get(hintKey);
|
|
2269
|
+
if (existing && existing.expires > now) {
|
|
2270
|
+
return existing.promise;
|
|
2265
2271
|
}
|
|
2272
|
+
if (existing) cachedCfgs.delete(hintKey);
|
|
2266
2273
|
const { ttl: _ttl, requestLoggingEnabled: _reqLog, responseLoggingEnabled: _resLog, ...rest } = config ?? {};
|
|
2267
|
-
const
|
|
2268
|
-
|
|
2274
|
+
const expires = now + ttl;
|
|
2275
|
+
const promise = resolveConfig2(rest).then((resolved) => {
|
|
2276
|
+
const resolvedKey = cacheKey(resolved.databaseId, resolved.apiKey) ?? hintKey;
|
|
2277
|
+
const nextExpires = Date.now() + ttl;
|
|
2278
|
+
cachedCfgs.set(resolvedKey, { promise, expires: nextExpires });
|
|
2279
|
+
if (resolvedKey !== hintKey) {
|
|
2280
|
+
const stale = cachedCfgs.get(hintKey);
|
|
2281
|
+
if (stale && stale.promise === promise) cachedCfgs.delete(hintKey);
|
|
2282
|
+
}
|
|
2283
|
+
return resolved;
|
|
2284
|
+
});
|
|
2285
|
+
cachedCfgs.set(hintKey, { promise, expires });
|
|
2269
2286
|
return promise;
|
|
2270
2287
|
}
|
|
2271
2288
|
function clearCacheConfig() {
|
|
2272
|
-
|
|
2289
|
+
cachedCfgs.clear();
|
|
2273
2290
|
}
|
|
2274
2291
|
return {
|
|
2275
2292
|
init(config) {
|