kaafil-js 0.6.2 → 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 +33 -9
- package/dist/client-entry.cjs.map +1 -1
- package/dist/client-entry.js +33 -9
- package/dist/client-entry.js.map +1 -1
- package/dist/index.cjs +25 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1978,11 +1978,35 @@ async function runWithLadder(ctx, request, send) {
|
|
|
1978
1978
|
throw error;
|
|
1979
1979
|
}
|
|
1980
1980
|
}
|
|
1981
|
+
var inFlightReads = /* @__PURE__ */ new WeakMap();
|
|
1982
|
+
function readKey(request) {
|
|
1983
|
+
return [
|
|
1984
|
+
request.operationId,
|
|
1985
|
+
request.path,
|
|
1986
|
+
JSON.stringify(request.pathParams ?? {}),
|
|
1987
|
+
JSON.stringify(request.query ?? {}),
|
|
1988
|
+
JSON.stringify(request.headers ?? {})
|
|
1989
|
+
].join("|");
|
|
1990
|
+
}
|
|
1981
1991
|
function execute(ctx, request) {
|
|
1982
|
-
|
|
1992
|
+
const run = () => runWithLadder(ctx, request, async (idempotencyKey) => {
|
|
1983
1993
|
const { data, meta, facets } = await sendOnce(ctx, request, idempotencyKey);
|
|
1984
1994
|
return attachMeta(data, meta, facets);
|
|
1985
1995
|
});
|
|
1996
|
+
if (request.method !== "GET" || request.signal !== void 0) return run();
|
|
1997
|
+
let perClient = inFlightReads.get(ctx);
|
|
1998
|
+
if (perClient === void 0) {
|
|
1999
|
+
perClient = /* @__PURE__ */ new Map();
|
|
2000
|
+
inFlightReads.set(ctx, perClient);
|
|
2001
|
+
}
|
|
2002
|
+
const key = readKey(request);
|
|
2003
|
+
const existing = perClient.get(key);
|
|
2004
|
+
if (existing !== void 0) return existing;
|
|
2005
|
+
const started = run().finally(() => {
|
|
2006
|
+
perClient.delete(key);
|
|
2007
|
+
});
|
|
2008
|
+
perClient.set(key, started);
|
|
2009
|
+
return started;
|
|
1986
2010
|
}
|
|
1987
2011
|
function executeBinary(ctx, request) {
|
|
1988
2012
|
return runWithLadder(
|