kaafil-js 0.6.1 → 0.7.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/client-entry.cjs +35 -10
- package/dist/client-entry.cjs.map +1 -1
- package/dist/client-entry.js +35 -10
- package/dist/client-entry.js.map +1 -1
- package/dist/index.cjs +27 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/client-entry.cjs
CHANGED
|
@@ -1761,7 +1761,8 @@ function parseRetryAfterSeconds(headerValue) {
|
|
|
1761
1761
|
return Number.isFinite(seconds) && seconds >= 0 ? seconds : void 0;
|
|
1762
1762
|
}
|
|
1763
1763
|
function attachMeta(data, meta, facets) {
|
|
1764
|
-
const
|
|
1764
|
+
const base = data === void 0 || data === null ? {} : data;
|
|
1765
|
+
const withMeta = Object.assign(base, { meta });
|
|
1765
1766
|
return facets === void 0 ? withMeta : Object.assign(withMeta, { facets });
|
|
1766
1767
|
}
|
|
1767
1768
|
function describeCrossOriginSuspect(url) {
|
|
@@ -1980,11 +1981,35 @@ async function runWithLadder(ctx, request, send) {
|
|
|
1980
1981
|
throw error;
|
|
1981
1982
|
}
|
|
1982
1983
|
}
|
|
1984
|
+
var inFlightReads = /* @__PURE__ */ new WeakMap();
|
|
1985
|
+
function readKey(request) {
|
|
1986
|
+
return [
|
|
1987
|
+
request.operationId,
|
|
1988
|
+
request.path,
|
|
1989
|
+
JSON.stringify(request.pathParams ?? {}),
|
|
1990
|
+
JSON.stringify(request.query ?? {}),
|
|
1991
|
+
JSON.stringify(request.headers ?? {})
|
|
1992
|
+
].join("|");
|
|
1993
|
+
}
|
|
1983
1994
|
function execute(ctx, request) {
|
|
1984
|
-
|
|
1995
|
+
const run = () => runWithLadder(ctx, request, async (idempotencyKey) => {
|
|
1985
1996
|
const { data, meta, facets } = await sendOnce(ctx, request, idempotencyKey);
|
|
1986
1997
|
return attachMeta(data, meta, facets);
|
|
1987
1998
|
});
|
|
1999
|
+
if (request.method !== "GET" || request.signal !== void 0) return run();
|
|
2000
|
+
let perClient = inFlightReads.get(ctx);
|
|
2001
|
+
if (perClient === void 0) {
|
|
2002
|
+
perClient = /* @__PURE__ */ new Map();
|
|
2003
|
+
inFlightReads.set(ctx, perClient);
|
|
2004
|
+
}
|
|
2005
|
+
const key = readKey(request);
|
|
2006
|
+
const existing = perClient.get(key);
|
|
2007
|
+
if (existing !== void 0) return existing;
|
|
2008
|
+
const started = run().finally(() => {
|
|
2009
|
+
perClient.delete(key);
|
|
2010
|
+
});
|
|
2011
|
+
perClient.set(key, started);
|
|
2012
|
+
return started;
|
|
1988
2013
|
}
|
|
1989
2014
|
function executeBinary(ctx, request) {
|
|
1990
2015
|
return runWithLadder(
|
|
@@ -3145,15 +3170,15 @@ function createReadCacheStore(options) {
|
|
|
3145
3170
|
await options.storage.set(key, JSON.stringify(shape));
|
|
3146
3171
|
}
|
|
3147
3172
|
return {
|
|
3148
|
-
get(
|
|
3149
|
-
return reads.get(
|
|
3173
|
+
get(readKey2) {
|
|
3174
|
+
return reads.get(readKey2);
|
|
3150
3175
|
},
|
|
3151
|
-
async set(
|
|
3152
|
-
reads.set(
|
|
3176
|
+
async set(readKey2, value, serverTime) {
|
|
3177
|
+
reads.set(readKey2, { value, syncedAt: serverTime });
|
|
3153
3178
|
await persist();
|
|
3154
3179
|
},
|
|
3155
|
-
async purge(
|
|
3156
|
-
if (!reads.delete(
|
|
3180
|
+
async purge(readKey2) {
|
|
3181
|
+
if (!reads.delete(readKey2)) {
|
|
3157
3182
|
return;
|
|
3158
3183
|
}
|
|
3159
3184
|
await persist();
|
|
@@ -3170,9 +3195,9 @@ function createReadCacheStore(options) {
|
|
|
3170
3195
|
} catch {
|
|
3171
3196
|
return;
|
|
3172
3197
|
}
|
|
3173
|
-
for (const [
|
|
3198
|
+
for (const [readKey2, entry] of Object.entries(parsed.reads ?? {})) {
|
|
3174
3199
|
if (entry !== null && typeof entry === "object" && typeof entry.syncedAt === "string") {
|
|
3175
|
-
reads.set(
|
|
3200
|
+
reads.set(readKey2, entry);
|
|
3176
3201
|
}
|
|
3177
3202
|
}
|
|
3178
3203
|
}
|