@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
|
@@ -2218,20 +2218,38 @@ var AiChatClientImpl = class {
|
|
|
2218
2218
|
}
|
|
2219
2219
|
};
|
|
2220
2220
|
function createOnyxFacade(resolveConfig2) {
|
|
2221
|
-
|
|
2221
|
+
const cachedCfgs = /* @__PURE__ */ new Map();
|
|
2222
|
+
const cacheKey = (databaseId, apiKey) => {
|
|
2223
|
+
const id = typeof databaseId === "string" && databaseId.trim() !== "" ? databaseId.trim() : null;
|
|
2224
|
+
const key = typeof apiKey === "string" && apiKey.trim() !== "" ? apiKey.trim() : null;
|
|
2225
|
+
return id && key ? `${id}-${key}` : null;
|
|
2226
|
+
};
|
|
2222
2227
|
function resolveConfigWithCache(config) {
|
|
2223
2228
|
const ttl = config?.ttl ?? DEFAULT_CACHE_TTL;
|
|
2224
2229
|
const now = Date.now();
|
|
2225
|
-
|
|
2226
|
-
|
|
2230
|
+
const hintKey = cacheKey(config?.databaseId, config?.apiKey) ?? "__default__";
|
|
2231
|
+
const existing = cachedCfgs.get(hintKey);
|
|
2232
|
+
if (existing && existing.expires > now) {
|
|
2233
|
+
return existing.promise;
|
|
2227
2234
|
}
|
|
2235
|
+
if (existing) cachedCfgs.delete(hintKey);
|
|
2228
2236
|
const { ttl: _ttl, requestLoggingEnabled: _reqLog, responseLoggingEnabled: _resLog, ...rest } = config ?? {};
|
|
2229
|
-
const
|
|
2230
|
-
|
|
2237
|
+
const expires = now + ttl;
|
|
2238
|
+
const promise = resolveConfig2(rest).then((resolved) => {
|
|
2239
|
+
const resolvedKey = cacheKey(resolved.databaseId, resolved.apiKey) ?? hintKey;
|
|
2240
|
+
const nextExpires = Date.now() + ttl;
|
|
2241
|
+
cachedCfgs.set(resolvedKey, { promise, expires: nextExpires });
|
|
2242
|
+
if (resolvedKey !== hintKey) {
|
|
2243
|
+
const stale = cachedCfgs.get(hintKey);
|
|
2244
|
+
if (stale && stale.promise === promise) cachedCfgs.delete(hintKey);
|
|
2245
|
+
}
|
|
2246
|
+
return resolved;
|
|
2247
|
+
});
|
|
2248
|
+
cachedCfgs.set(hintKey, { promise, expires });
|
|
2231
2249
|
return promise;
|
|
2232
2250
|
}
|
|
2233
2251
|
function clearCacheConfig() {
|
|
2234
|
-
|
|
2252
|
+
cachedCfgs.clear();
|
|
2235
2253
|
}
|
|
2236
2254
|
return {
|
|
2237
2255
|
init(config) {
|