@onyx.dev/onyx-database 2.0.0 → 2.1.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/README.md +100 -57
- package/dist/{aggregates-BJT5DGGX.d.cts → aggregates-DREvey7b.d.cts} +5 -1
- package/dist/{aggregates-BJT5DGGX.d.ts → aggregates-DREvey7b.d.ts} +5 -1
- package/dist/edge.cjs +65 -45
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.d.cts +3 -6
- package/dist/edge.d.ts +3 -6
- package/dist/edge.js +63 -44
- package/dist/edge.js.map +1 -1
- package/dist/gen/cli/generate.cjs +24 -6
- package/dist/gen/cli/generate.cjs.map +1 -1
- package/dist/index.cjs +65 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -6
- package/dist/index.d.ts +3 -6
- package/dist/index.js +63 -44
- package/dist/index.js.map +1 -1
- package/dist/schema/cli/schema.cjs +24 -6
- package/dist/schema/cli/schema.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -2256,20 +2256,38 @@ var AiChatClientImpl = class {
|
|
|
2256
2256
|
}
|
|
2257
2257
|
};
|
|
2258
2258
|
function createOnyxFacade(resolveConfig2) {
|
|
2259
|
-
|
|
2259
|
+
const cachedCfgs = /* @__PURE__ */ new Map();
|
|
2260
|
+
const cacheKey = (databaseId, apiKey) => {
|
|
2261
|
+
const id = typeof databaseId === "string" && databaseId.trim() !== "" ? databaseId.trim() : null;
|
|
2262
|
+
const key = typeof apiKey === "string" && apiKey.trim() !== "" ? apiKey.trim() : null;
|
|
2263
|
+
return id && key ? `${id}-${key}` : null;
|
|
2264
|
+
};
|
|
2260
2265
|
function resolveConfigWithCache(config) {
|
|
2261
2266
|
const ttl = config?.ttl ?? DEFAULT_CACHE_TTL;
|
|
2262
2267
|
const now = Date.now();
|
|
2263
|
-
|
|
2264
|
-
|
|
2268
|
+
const hintKey = cacheKey(config?.databaseId, config?.apiKey) ?? "__default__";
|
|
2269
|
+
const existing = cachedCfgs.get(hintKey);
|
|
2270
|
+
if (existing && existing.expires > now) {
|
|
2271
|
+
return existing.promise;
|
|
2265
2272
|
}
|
|
2273
|
+
if (existing) cachedCfgs.delete(hintKey);
|
|
2266
2274
|
const { ttl: _ttl, requestLoggingEnabled: _reqLog, responseLoggingEnabled: _resLog, ...rest } = config ?? {};
|
|
2267
|
-
const
|
|
2268
|
-
|
|
2275
|
+
const expires = now + ttl;
|
|
2276
|
+
const promise = resolveConfig2(rest).then((resolved) => {
|
|
2277
|
+
const resolvedKey = cacheKey(resolved.databaseId, resolved.apiKey) ?? hintKey;
|
|
2278
|
+
const nextExpires = Date.now() + ttl;
|
|
2279
|
+
cachedCfgs.set(resolvedKey, { promise, expires: nextExpires });
|
|
2280
|
+
if (resolvedKey !== hintKey) {
|
|
2281
|
+
const stale = cachedCfgs.get(hintKey);
|
|
2282
|
+
if (stale && stale.promise === promise) cachedCfgs.delete(hintKey);
|
|
2283
|
+
}
|
|
2284
|
+
return resolved;
|
|
2285
|
+
});
|
|
2286
|
+
cachedCfgs.set(hintKey, { promise, expires });
|
|
2269
2287
|
return promise;
|
|
2270
2288
|
}
|
|
2271
2289
|
function clearCacheConfig() {
|
|
2272
|
-
|
|
2290
|
+
cachedCfgs.clear();
|
|
2273
2291
|
}
|
|
2274
2292
|
return {
|
|
2275
2293
|
init(config) {
|