@farm.js/core 0.1.15 → 0.1.17
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/agent-runtime.d.mts +5 -2
- package/dist/agent-runtime.d.ts +5 -2
- package/dist/api/client.cjs +62 -28
- package/dist/api/client.d.mts +3 -2
- package/dist/api/client.d.ts +3 -2
- package/dist/api/client.mjs +3 -3
- package/dist/api/route-manager.cjs +69 -32
- package/dist/api/route-manager.d.mts +5 -2
- package/dist/api/route-manager.d.ts +5 -2
- package/dist/api/route-manager.mjs +5 -5
- package/dist/api/runtime.cjs +65 -29
- package/dist/api/runtime.d.mts +3 -2
- package/dist/api/runtime.d.ts +3 -2
- package/dist/api/runtime.mjs +6 -3
- package/dist/{api-client-C8d7BZNp.d.mts → api-client-Cx54IR5g.d.mts} +2 -1
- package/dist/{api-client-BWrEbxfO.d.ts → api-client-DykpaKcY.d.ts} +2 -1
- package/dist/api.cjs +106 -33
- package/dist/api.d.mts +7 -4
- package/dist/api.d.ts +7 -4
- package/dist/api.mjs +8 -8
- package/dist/{app-wIYse61b.d.ts → app-BHY_10Lm.d.ts} +3 -3
- package/dist/{app-B3nVSjen.d.mts → app-BMk0do23.d.mts} +3 -3
- package/dist/app-markdown.d.mts +6 -3
- package/dist/app-markdown.d.ts +6 -3
- package/dist/app-markdown.mjs +3 -3
- package/dist/cache.cjs +62 -28
- package/dist/cache.d.mts +11 -1
- package/dist/cache.d.ts +11 -1
- package/dist/cache.mjs +1 -1
- package/dist/{chunk-FOGLGRDS.mjs → chunk-4OOBRCJX.mjs} +122 -8
- package/dist/{chunk-JRF3C33L.mjs → chunk-56DAX2BE.mjs} +172 -53
- package/dist/{chunk-B76DT5Y6.mjs → chunk-57J3Y7Y3.mjs} +1 -1
- package/dist/{chunk-MOQNHLTS.mjs → chunk-5QOEPUYE.mjs} +5 -2
- package/dist/{chunk-HKLRP3BN.mjs → chunk-5SPPCN5J.mjs} +1 -1
- package/dist/{chunk-LUC2FAGW.mjs → chunk-6VQIKZZO.mjs} +1 -1
- package/dist/{chunk-7ZWL7XOU.mjs → chunk-76DG3LF3.mjs} +1 -1
- package/dist/{chunk-EWDK36MM.mjs → chunk-A72YEUZ3.mjs} +1 -1
- package/dist/{chunk-ZHOIQC6U.mjs → chunk-ATERBVHQ.mjs} +2 -2
- package/dist/{chunk-27JNCYEK.mjs → chunk-EN7WTEAY.mjs} +2 -2
- package/dist/{chunk-IGO2HEV7.mjs → chunk-F6SJAKFJ.mjs} +62 -28
- package/dist/{chunk-GSDIZACQ.mjs → chunk-FG5H2VCJ.mjs} +2 -2
- package/dist/{chunk-LZK5CXDW.mjs → chunk-KLSSO6YD.mjs} +2 -2
- package/dist/{chunk-KUO3GBPK.mjs → chunk-L6V3P73N.mjs} +1 -1
- package/dist/{chunk-FBHGHMOA.mjs → chunk-MVIWBEJF.mjs} +37 -27
- package/dist/{chunk-KTGFMHET.mjs → chunk-N6UROPT7.mjs} +1 -1
- package/dist/{chunk-NDD2YVGU.mjs → chunk-NRVGEI5I.mjs} +10 -3
- package/dist/{chunk-GNTPTTLA.mjs → chunk-QGVJVSNX.mjs} +5 -5
- package/dist/{chunk-6SCB2MXB.mjs → chunk-SXHV42UQ.mjs} +16 -1
- package/dist/{chunk-OWTIOHON.mjs → chunk-SYGGPS4A.mjs} +2 -2
- package/dist/{chunk-NC333MFA.mjs → chunk-TSWW5BVH.mjs} +7 -4
- package/dist/{chunk-LK6FGAQR.mjs → chunk-UDBJCUPA.mjs} +7 -4
- package/dist/{chunk-NJ47VORC.mjs → chunk-UTBVHYS3.mjs} +2 -2
- package/dist/{chunk-76MNRHTS.mjs → chunk-UUYF3CHN.mjs} +2 -2
- package/dist/{chunk-S3QW3BIS.mjs → chunk-WD4YXVLV.mjs} +99 -6
- package/dist/{chunk-W7IVHTOP.mjs → chunk-WD5PNSOB.mjs} +16 -3
- package/dist/{chunk-DPZUDPVJ.mjs → chunk-XP777LRD.mjs} +1 -1
- package/dist/{chunk-KATQ6I56.mjs → chunk-XWAYMDLB.mjs} +1 -1
- package/dist/{chunk-UE75PB52.mjs → chunk-YD4J4XCI.mjs} +1 -1
- package/dist/{chunk-Q3MDL7TM.mjs → chunk-ZCNJKLA2.mjs} +30 -11
- package/dist/{client-plugins-CslwYp3E.d.ts → client-plugins-C089bQhN.d.ts} +16 -4
- package/dist/{client-plugins-C1EgdoJM.d.mts → client-plugins-JXXmZliS.d.mts} +16 -4
- package/dist/client-plugins.d.mts +5 -2
- package/dist/client-plugins.d.ts +5 -2
- package/dist/client.cjs +62 -28
- package/dist/client.d.mts +8 -7
- package/dist/client.d.ts +8 -7
- package/dist/client.mjs +6 -6
- package/dist/config.d.mts +5 -2
- package/dist/config.d.ts +5 -2
- package/dist/cron.mjs +2 -2
- package/dist/{devtools-PCGEBRSC.mjs → devtools-UFVTMQX5.mjs} +7 -7
- package/dist/docs.cjs +83 -4
- package/dist/docs.mjs +9 -9
- package/dist/{route-CHBaW55F.d.ts → endpoint-1zA994xL.d.ts} +3 -128
- package/dist/{route-C6UClI1z.d.mts → endpoint-DAc96i93.d.mts} +3 -128
- package/dist/env.cjs +135 -8
- package/dist/env.d.mts +22 -2
- package/dist/env.d.ts +22 -2
- package/dist/env.mjs +4 -1
- package/dist/index.cjs +516 -105
- package/dist/index.d.mts +16 -15
- package/dist/index.d.ts +16 -15
- package/dist/index.mjs +46 -34
- package/dist/integrations.d.mts +5 -2
- package/dist/integrations.d.ts +5 -2
- package/dist/internal/app-markdown-runtime.d.mts +5 -2
- package/dist/internal/app-markdown-runtime.d.ts +5 -2
- package/dist/internal/app-markdown-runtime.mjs +2 -2
- package/dist/internal/build-runtime.cjs +600 -284
- package/dist/internal/build-runtime.d.mts +7 -4
- package/dist/internal/build-runtime.d.ts +7 -4
- package/dist/internal/build-runtime.mjs +23 -23
- package/dist/internal/cli-runtime.cjs +143 -33
- package/dist/internal/cli-runtime.mjs +13 -13
- package/dist/internal/client-error-overlay.cjs +1 -1
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/compression-runtime.d.mts +5 -2
- package/dist/internal/compression-runtime.d.ts +5 -2
- package/dist/internal/config-runtime.cjs +80 -4
- package/dist/internal/config-runtime.d.mts +6 -3
- package/dist/internal/config-runtime.d.ts +6 -3
- package/dist/internal/config-runtime.mjs +7 -7
- package/dist/internal/product-telemetry-runtime.cjs +1 -1
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-runtime.cjs +101 -41
- package/dist/internal/production-runtime.d.mts +11 -8
- package/dist/internal/production-runtime.d.ts +11 -8
- package/dist/internal/production-runtime.mjs +6 -6
- package/dist/markdown.cjs +16 -1
- package/dist/markdown.mjs +1 -1
- package/dist/{metadata-BsUcOEXg.d.ts → metadata-BcNJP4fq.d.ts} +1 -1
- package/dist/{metadata-B1bxCPUY.d.mts → metadata-C1Z9vLbb.d.mts} +1 -1
- package/dist/middleware.cjs +10 -3
- package/dist/middleware.d.mts +7 -4
- package/dist/middleware.d.ts +7 -4
- package/dist/middleware.mjs +4 -4
- package/dist/{nitro-ICBP5APY.mjs → nitro-CVZ36JM5.mjs} +8 -5
- package/dist/plugin.cjs +358 -106
- package/dist/plugin.d.mts +5 -2
- package/dist/plugin.d.ts +5 -2
- package/dist/plugin.mjs +19 -19
- package/dist/{production-runtime-BDllolVh.d.mts → production-runtime-jcrTlRTb.d.mts} +1 -1
- package/dist/{production-runtime-CsNn2-zx.d.ts → production-runtime-oKmC0WU-.d.ts} +1 -1
- package/dist/{render-plan-CNUlzylR.d.mts → render-plan-BLIfc4jt.d.mts} +1 -1
- package/dist/{render-plan-EG4hNFjy.d.ts → render-plan-DOB9cV-h.d.ts} +1 -1
- package/dist/renderer-client.cjs +62 -28
- package/dist/renderer-client.d.mts +5 -4
- package/dist/renderer-client.d.ts +5 -4
- package/dist/renderer-client.mjs +3 -3
- package/dist/{request-Blh_f7Z3.d.mts → request-Cr53NRHr.d.mts} +1 -1
- package/dist/{request-DsVSQVfD.d.ts → request-Dt2gNuQD.d.ts} +1 -1
- package/dist/request.d.mts +6 -3
- package/dist/request.d.ts +6 -3
- package/dist/route-B0XrsrFk.d.mts +128 -0
- package/dist/route-DOEpbyWZ.d.ts +128 -0
- package/dist/{route-rendering-hUETRCbM.d.ts → route-rendering-CWYd8Mv1.d.ts} +1 -1
- package/dist/{route-rendering-LT4XSoQK.d.mts → route-rendering-CeFBEAoZ.d.mts} +1 -1
- package/dist/routes.cjs +68 -31
- package/dist/routes.d.mts +5 -3
- package/dist/routes.d.ts +5 -3
- package/dist/routes.mjs +2 -2
- package/dist/server-fn-client.d.mts +3 -2
- package/dist/server-fn-client.d.ts +3 -2
- package/dist/server-fn.cjs +212 -32
- package/dist/server-fn.d.mts +72 -1
- package/dist/server-fn.d.ts +72 -1
- package/dist/server-fn.mjs +13 -2
- package/dist/server-plugins.d.mts +6 -3
- package/dist/server-plugins.d.ts +6 -3
- package/dist/server-query-client.cjs +62 -28
- package/dist/server-query-client.d.mts +1 -0
- package/dist/server-query-client.d.ts +1 -0
- package/dist/server-query-client.mjs +4 -4
- package/dist/server-query.cjs +131 -32
- package/dist/server-query.d.mts +6 -1
- package/dist/server-query.d.ts +6 -1
- package/dist/server-query.mjs +4 -3
- package/dist/server.cjs +393 -84
- package/dist/server.d.mts +9 -8
- package/dist/server.d.ts +9 -8
- package/dist/server.mjs +22 -22
- package/dist/{spa-router-csKR9Ebj.d.mts → spa-router-CQWiYGxS.d.mts} +2 -2
- package/dist/{spa-router-Y_2FSJQK.d.ts → spa-router-Wjiw-8hB.d.ts} +2 -2
- package/dist/testing.cjs +73 -32
- package/dist/testing.d.mts +5 -3
- package/dist/testing.d.ts +5 -3
- package/dist/testing.mjs +11 -7
- package/dist/{utils-jISOE9SD.d.ts → utils-B0XJmG_b.d.ts} +1 -1
- package/dist/{utils-DR2wfZAn.d.mts → utils-uUxF0K0P.d.mts} +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +500 -252
- package/dist/vite.d.mts +5 -2
- package/dist/vite.d.ts +5 -2
- package/dist/vite.mjs +19 -19
- package/dist/workflows.mjs +2 -2
- package/package.json +2 -2
- package/dist/{chunk-VO5SCWF5.mjs → chunk-BNGS6KJ6.mjs} +0 -0
- package/dist/{chunk-MUUZJLCI.mjs → chunk-EGJDUF4Q.mjs} +3 -3
- package/dist/{chunk-4L7SZOHZ.mjs → chunk-YHOCRI4H.mjs} +3 -3
package/dist/server-fn.mjs
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FARM_SERVER_FN_SYMBOL,
|
|
3
|
+
_attachServerFunctionDescriptor,
|
|
4
|
+
_describeServerFunction,
|
|
5
|
+
_invokeServerFunction,
|
|
3
6
|
_parseServerFnSchema,
|
|
7
|
+
_runServerFunctionForCaller,
|
|
4
8
|
createServerFn,
|
|
9
|
+
createServerFunctionDescriptor,
|
|
5
10
|
createServerMiddleware
|
|
6
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-WD4YXVLV.mjs";
|
|
7
12
|
import {
|
|
8
13
|
FARM_SERVER_FN_FAILURE_SYMBOL,
|
|
9
14
|
ServerActionError,
|
|
@@ -13,10 +18,11 @@ import {
|
|
|
13
18
|
} from "./chunk-QCFFHV5H.mjs";
|
|
14
19
|
import "./chunk-FP2INE7H.mjs";
|
|
15
20
|
import "./chunk-XF7Q24PF.mjs";
|
|
16
|
-
import "./chunk-
|
|
21
|
+
import "./chunk-F6SJAKFJ.mjs";
|
|
17
22
|
import "./chunk-4SIYUGRY.mjs";
|
|
18
23
|
import "./chunk-C4NCTZLM.mjs";
|
|
19
24
|
import "./chunk-FUZEBRP3.mjs";
|
|
25
|
+
import "./chunk-CBBLJMR5.mjs";
|
|
20
26
|
import "./chunk-IZY3V5XW.mjs";
|
|
21
27
|
import "./chunk-55YI3RRB.mjs";
|
|
22
28
|
import "./chunk-LPEX4YW6.mjs";
|
|
@@ -25,9 +31,14 @@ export {
|
|
|
25
31
|
FARM_SERVER_FN_SYMBOL,
|
|
26
32
|
ServerActionError,
|
|
27
33
|
ServerFnFailure,
|
|
34
|
+
_attachServerFunctionDescriptor,
|
|
35
|
+
_describeServerFunction,
|
|
36
|
+
_invokeServerFunction,
|
|
28
37
|
_parseServerFnSchema,
|
|
38
|
+
_runServerFunctionForCaller,
|
|
29
39
|
createServerFn,
|
|
30
40
|
createServerFnTransportError,
|
|
41
|
+
createServerFunctionDescriptor,
|
|
31
42
|
createServerMiddleware,
|
|
32
43
|
isServerFnFailure
|
|
33
44
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { ch as RedirectConfig, b as FarmRequest, c as FarmResponse, d as FarmPluginContext, a as FarmPlugin, ci as HeaderConfig, cj as RewriteConfig } from './client-plugins-JXXmZliS.mjs';
|
|
2
|
+
export { bF as FarmPluginLifecycle, bO as FarmPluginRuntimeEndpoint, bP as FarmPluginRuntimeEndpointEvent, bG as FarmRequestPluginContext, bH as FarmRequestStore } from './client-plugins-JXXmZliS.mjs';
|
|
3
3
|
import { R as ResolvedFarmI18nConfig } from './types-Z0aotQ8w.mjs';
|
|
4
4
|
export { createCompressionPlugin } from './internal/compression-runtime.mjs';
|
|
5
5
|
import './lifecycle-DK06VuKP.mjs';
|
|
6
|
-
import './route-
|
|
6
|
+
import './route-B0XrsrFk.mjs';
|
|
7
|
+
import './endpoint-DAc96i93.mjs';
|
|
7
8
|
import './cache.mjs';
|
|
8
9
|
import './renderer.mjs';
|
|
9
10
|
import './deployment.mjs';
|
|
@@ -29,6 +30,8 @@ import './server-action-security.mjs';
|
|
|
29
30
|
import './server-fn-error-DDh14a0V.mjs';
|
|
30
31
|
import 'esbuild';
|
|
31
32
|
import './image-config-Duob7wER.mjs';
|
|
33
|
+
import './server-fn.mjs';
|
|
34
|
+
import './server-query.mjs';
|
|
32
35
|
import './types-DQnyD3VD.mjs';
|
|
33
36
|
import './font.mjs';
|
|
34
37
|
import './after.mjs';
|
package/dist/server-plugins.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { ch as RedirectConfig, b as FarmRequest, c as FarmResponse, d as FarmPluginContext, a as FarmPlugin, ci as HeaderConfig, cj as RewriteConfig } from './client-plugins-C089bQhN.js';
|
|
2
|
+
export { bF as FarmPluginLifecycle, bO as FarmPluginRuntimeEndpoint, bP as FarmPluginRuntimeEndpointEvent, bG as FarmRequestPluginContext, bH as FarmRequestStore } from './client-plugins-C089bQhN.js';
|
|
3
3
|
import { R as ResolvedFarmI18nConfig } from './types-Z0aotQ8w.js';
|
|
4
4
|
export { createCompressionPlugin } from './internal/compression-runtime.js';
|
|
5
5
|
import './lifecycle-DK06VuKP.js';
|
|
6
|
-
import './route-
|
|
6
|
+
import './route-DOEpbyWZ.js';
|
|
7
|
+
import './endpoint-1zA994xL.js';
|
|
7
8
|
import './cache.js';
|
|
8
9
|
import './renderer.js';
|
|
9
10
|
import './deployment.js';
|
|
@@ -29,6 +30,8 @@ import './server-action-security.js';
|
|
|
29
30
|
import './server-fn-error-DDh14a0V.js';
|
|
30
31
|
import 'esbuild';
|
|
31
32
|
import './image-config-Duob7wER.js';
|
|
33
|
+
import './server-fn.js';
|
|
34
|
+
import './server-query.js';
|
|
32
35
|
import './types-DQnyD3VD.js';
|
|
33
36
|
import './font.js';
|
|
34
37
|
import './after.js';
|
|
@@ -433,6 +433,8 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
433
433
|
constructor(config = {}) {
|
|
434
434
|
this.entries = /* @__PURE__ */ new Map();
|
|
435
435
|
this.inflight = /* @__PURE__ */ new Map();
|
|
436
|
+
/** Local entries by tag, so tag counts and pruning never scan unrelated entries. */
|
|
437
|
+
this.entriesByTag = /* @__PURE__ */ new Map();
|
|
436
438
|
this.invalidatedTagVersions = /* @__PURE__ */ new Map();
|
|
437
439
|
this.activeGenerations = /* @__PURE__ */ new Set();
|
|
438
440
|
this.version = 0;
|
|
@@ -451,6 +453,7 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
451
453
|
configure(config = {}) {
|
|
452
454
|
this.generation++;
|
|
453
455
|
this.entries.clear();
|
|
456
|
+
this.entriesByTag.clear();
|
|
454
457
|
this.inflight.clear();
|
|
455
458
|
this.invalidatedTagVersions.clear();
|
|
456
459
|
this.activeGenerations.clear();
|
|
@@ -617,14 +620,12 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
617
620
|
return entry;
|
|
618
621
|
}
|
|
619
622
|
delete(key) {
|
|
620
|
-
const deleted = this.
|
|
621
|
-
if (deleted) this.pruneInvalidatedTagVersions();
|
|
623
|
+
const deleted = this.deleteLocalEntry(key);
|
|
622
624
|
emitFarmEvent({ type: "cache.delete", key, deleted });
|
|
623
625
|
return deleted;
|
|
624
626
|
}
|
|
625
627
|
async deleteAsync(key) {
|
|
626
|
-
const deleted = this.
|
|
627
|
-
if (deleted) this.pruneInvalidatedTagVersions();
|
|
628
|
+
const deleted = this.deleteLocalEntry(key);
|
|
628
629
|
if (this.adapter) {
|
|
629
630
|
await this.adapter.delete(this.createAdapterKey(key));
|
|
630
631
|
}
|
|
@@ -635,6 +636,7 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
635
636
|
const count = this.entries.size;
|
|
636
637
|
this.generation++;
|
|
637
638
|
this.entries.clear();
|
|
639
|
+
this.entriesByTag.clear();
|
|
638
640
|
this.inflight.clear();
|
|
639
641
|
this.invalidatedTagVersions.clear();
|
|
640
642
|
this.activeGenerations.clear();
|
|
@@ -720,23 +722,32 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
720
722
|
return cached.value;
|
|
721
723
|
}
|
|
722
724
|
const inflight = this.inflight.get(key);
|
|
723
|
-
if (inflight) {
|
|
725
|
+
if (inflight && !this.wasInvalidatedSince(inflight.tags, inflight.startVersion)) {
|
|
724
726
|
emitFarmEvent({ type: "cache.dedupe", key });
|
|
725
|
-
return inflight;
|
|
727
|
+
return inflight.promise;
|
|
726
728
|
}
|
|
727
729
|
const tags = Array.from(normalizeCacheOptionsTags(options));
|
|
728
730
|
const generation = this.generation;
|
|
731
|
+
const startVersion = this.version;
|
|
729
732
|
const promise = this.fillCacheEntry(key, producer, options, tags, generation).catch((error) => {
|
|
730
733
|
emitFarmEvent({ type: "cache.error", key, operation: "set", error });
|
|
731
734
|
throw error;
|
|
732
735
|
}).finally(() => {
|
|
733
|
-
if (this.inflight.get(key) === promise) {
|
|
736
|
+
if (this.inflight.get(key)?.promise === promise) {
|
|
734
737
|
this.inflight.delete(key);
|
|
735
738
|
}
|
|
736
739
|
});
|
|
737
|
-
this.inflight.set(key, promise);
|
|
740
|
+
this.inflight.set(key, { promise, tags, startVersion });
|
|
738
741
|
return promise;
|
|
739
742
|
}
|
|
743
|
+
/** A fill that started before one of its tags was invalidated cannot satisfy later readers. */
|
|
744
|
+
wasInvalidatedSince(tags, version) {
|
|
745
|
+
for (const tag of tags) {
|
|
746
|
+
const invalidatedVersion = this.invalidatedTagVersions.get(tag);
|
|
747
|
+
if (invalidatedVersion !== void 0 && invalidatedVersion > version) return true;
|
|
748
|
+
}
|
|
749
|
+
return false;
|
|
750
|
+
}
|
|
740
751
|
async fillCacheEntry(key, producer, options, tags, generation) {
|
|
741
752
|
const adapter = this.adapter;
|
|
742
753
|
const namespace = this.namespace;
|
|
@@ -777,7 +788,7 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
777
788
|
return value;
|
|
778
789
|
} finally {
|
|
779
790
|
this.activeGenerations.delete(activeGeneration);
|
|
780
|
-
this.pruneInvalidatedTagVersions();
|
|
791
|
+
this.pruneInvalidatedTagVersions(activeGeneration.tags);
|
|
781
792
|
if (leaseToken && adapter?.releaseLease) {
|
|
782
793
|
try {
|
|
783
794
|
await adapter.releaseLease(leaseKey, leaseToken);
|
|
@@ -822,18 +833,9 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
822
833
|
}
|
|
823
834
|
return void 0;
|
|
824
835
|
}
|
|
825
|
-
countEntriesForTag(tag) {
|
|
826
|
-
let count = 0;
|
|
827
|
-
for (const entry of this.entries.values()) {
|
|
828
|
-
if (entry.tags.has(tag)) {
|
|
829
|
-
count++;
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
return count;
|
|
833
|
-
}
|
|
834
836
|
countEntriesForTags(tags) {
|
|
835
837
|
let count = 0;
|
|
836
|
-
for (const entry of this.
|
|
838
|
+
for (const entry of this.entriesByTag.get(tags[0]) ?? []) {
|
|
837
839
|
if (tags.every((tag) => entry.tags.has(tag))) {
|
|
838
840
|
count++;
|
|
839
841
|
}
|
|
@@ -841,10 +843,10 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
841
843
|
return count;
|
|
842
844
|
}
|
|
843
845
|
invalidateTag(normalizedTag) {
|
|
844
|
-
const count = this.
|
|
846
|
+
const count = this.entriesByTag.get(normalizedTag)?.size ?? 0;
|
|
845
847
|
this.invalidatedTagVersions.delete(normalizedTag);
|
|
846
848
|
this.invalidatedTagVersions.set(normalizedTag, ++this.version);
|
|
847
|
-
this.pruneInvalidatedTagVersions();
|
|
849
|
+
this.pruneInvalidatedTagVersions([normalizedTag]);
|
|
848
850
|
return count;
|
|
849
851
|
}
|
|
850
852
|
toPublicEntry(entry) {
|
|
@@ -874,19 +876,51 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
874
876
|
this.entries.set(key, entry);
|
|
875
877
|
}
|
|
876
878
|
storeLocalEntry(entry) {
|
|
877
|
-
|
|
879
|
+
const removed = [];
|
|
880
|
+
const replaced = this.detachLocalEntry(entry.key);
|
|
881
|
+
if (replaced) removed.push(replaced);
|
|
878
882
|
this.entries.set(entry.key, entry);
|
|
883
|
+
for (const tag of entry.tags) {
|
|
884
|
+
let tagged = this.entriesByTag.get(tag);
|
|
885
|
+
if (!tagged) this.entriesByTag.set(tag, tagged = /* @__PURE__ */ new Set());
|
|
886
|
+
tagged.add(entry);
|
|
887
|
+
}
|
|
879
888
|
while (this.entries.size > this.maxEntries) {
|
|
880
889
|
const oldestKey = this.entries.keys().next().value;
|
|
881
890
|
if (oldestKey === void 0) break;
|
|
882
|
-
this.
|
|
891
|
+
removed.push(this.detachLocalEntry(oldestKey));
|
|
883
892
|
}
|
|
884
|
-
this.pruneInvalidatedTagVersions();
|
|
893
|
+
for (const removedEntry of removed) this.pruneInvalidatedTagVersions(removedEntry.tags);
|
|
885
894
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
895
|
+
deleteLocalEntry(key) {
|
|
896
|
+
const entry = this.detachLocalEntry(key);
|
|
897
|
+
if (!entry) return false;
|
|
898
|
+
this.pruneInvalidatedTagVersions(entry.tags);
|
|
899
|
+
return true;
|
|
900
|
+
}
|
|
901
|
+
detachLocalEntry(key) {
|
|
902
|
+
const entry = this.entries.get(key);
|
|
903
|
+
if (!entry) return void 0;
|
|
904
|
+
this.entries.delete(key);
|
|
905
|
+
for (const tag of entry.tags) {
|
|
906
|
+
const tagged = this.entriesByTag.get(tag);
|
|
907
|
+
if (!tagged) continue;
|
|
908
|
+
tagged.delete(entry);
|
|
909
|
+
if (tagged.size === 0) this.entriesByTag.delete(tag);
|
|
910
|
+
}
|
|
911
|
+
return entry;
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* Drop invalidation versions that no local entry or active fill can be stale against.
|
|
915
|
+
* Callers pass only the tags whose dependents just changed, so the cost is bounded by
|
|
916
|
+
* the entries sharing those tags rather than by the whole cache.
|
|
917
|
+
*/
|
|
918
|
+
pruneInvalidatedTagVersions(tags) {
|
|
919
|
+
tags: for (const tag of tags) {
|
|
920
|
+
const invalidatedVersion = this.invalidatedTagVersions.get(tag);
|
|
921
|
+
if (invalidatedVersion === void 0) continue;
|
|
922
|
+
for (const entry of this.entriesByTag.get(tag) ?? []) {
|
|
923
|
+
if (entry.createdVersion < invalidatedVersion) continue tags;
|
|
890
924
|
}
|
|
891
925
|
for (const generation of this.activeGenerations) {
|
|
892
926
|
if (generation.tags.has(tag) && generation.createdVersion < invalidatedVersion)
|
|
@@ -5,6 +5,7 @@ export { F as FarmServerQueryActionInvocation, b as beginFarmServerQueryAction,
|
|
|
5
5
|
import './cache.mjs';
|
|
6
6
|
import './server-fn.mjs';
|
|
7
7
|
import './server-fn-error-DDh14a0V.mjs';
|
|
8
|
+
import './endpoint-DAc96i93.mjs';
|
|
8
9
|
|
|
9
10
|
type UseServerQueryOptions = ServerQueryFetchOptions & {
|
|
10
11
|
enabled?: boolean;
|
|
@@ -5,6 +5,7 @@ export { F as FarmServerQueryActionInvocation, b as beginFarmServerQueryAction,
|
|
|
5
5
|
import './cache.js';
|
|
6
6
|
import './server-fn.js';
|
|
7
7
|
import './server-fn-error-DDh14a0V.js';
|
|
8
|
+
import './endpoint-1zA994xL.js';
|
|
8
9
|
|
|
9
10
|
type UseServerQueryOptions = ServerQueryFetchOptions & {
|
|
10
11
|
enabled?: boolean;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
useServerQuery
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-FG5H2VCJ.mjs";
|
|
5
5
|
import {
|
|
6
6
|
beginFarmServerQueryAction,
|
|
7
7
|
completeFarmServerQueryAction,
|
|
8
8
|
fetchServerQuery,
|
|
9
9
|
prefetchServerQuery,
|
|
10
10
|
shouldApplyFarmServerQueryActionResult
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-UUYF3CHN.mjs";
|
|
12
|
+
import "./chunk-5SPPCN5J.mjs";
|
|
13
13
|
import "./chunk-KGB5UXJJ.mjs";
|
|
14
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-F6SJAKFJ.mjs";
|
|
15
15
|
import "./chunk-4SIYUGRY.mjs";
|
|
16
16
|
import "./chunk-C4NCTZLM.mjs";
|
|
17
17
|
import "./chunk-FUZEBRP3.mjs";
|
package/dist/server-query.cjs
CHANGED
|
@@ -459,6 +459,8 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
459
459
|
constructor(config = {}) {
|
|
460
460
|
this.entries = /* @__PURE__ */ new Map();
|
|
461
461
|
this.inflight = /* @__PURE__ */ new Map();
|
|
462
|
+
/** Local entries by tag, so tag counts and pruning never scan unrelated entries. */
|
|
463
|
+
this.entriesByTag = /* @__PURE__ */ new Map();
|
|
462
464
|
this.invalidatedTagVersions = /* @__PURE__ */ new Map();
|
|
463
465
|
this.activeGenerations = /* @__PURE__ */ new Set();
|
|
464
466
|
this.version = 0;
|
|
@@ -477,6 +479,7 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
477
479
|
configure(config = {}) {
|
|
478
480
|
this.generation++;
|
|
479
481
|
this.entries.clear();
|
|
482
|
+
this.entriesByTag.clear();
|
|
480
483
|
this.inflight.clear();
|
|
481
484
|
this.invalidatedTagVersions.clear();
|
|
482
485
|
this.activeGenerations.clear();
|
|
@@ -643,14 +646,12 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
643
646
|
return entry;
|
|
644
647
|
}
|
|
645
648
|
delete(key) {
|
|
646
|
-
const deleted = this.
|
|
647
|
-
if (deleted) this.pruneInvalidatedTagVersions();
|
|
649
|
+
const deleted = this.deleteLocalEntry(key);
|
|
648
650
|
emitFarmEvent({ type: "cache.delete", key, deleted });
|
|
649
651
|
return deleted;
|
|
650
652
|
}
|
|
651
653
|
async deleteAsync(key) {
|
|
652
|
-
const deleted = this.
|
|
653
|
-
if (deleted) this.pruneInvalidatedTagVersions();
|
|
654
|
+
const deleted = this.deleteLocalEntry(key);
|
|
654
655
|
if (this.adapter) {
|
|
655
656
|
await this.adapter.delete(this.createAdapterKey(key));
|
|
656
657
|
}
|
|
@@ -661,6 +662,7 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
661
662
|
const count = this.entries.size;
|
|
662
663
|
this.generation++;
|
|
663
664
|
this.entries.clear();
|
|
665
|
+
this.entriesByTag.clear();
|
|
664
666
|
this.inflight.clear();
|
|
665
667
|
this.invalidatedTagVersions.clear();
|
|
666
668
|
this.activeGenerations.clear();
|
|
@@ -746,23 +748,32 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
746
748
|
return cached.value;
|
|
747
749
|
}
|
|
748
750
|
const inflight = this.inflight.get(key);
|
|
749
|
-
if (inflight) {
|
|
751
|
+
if (inflight && !this.wasInvalidatedSince(inflight.tags, inflight.startVersion)) {
|
|
750
752
|
emitFarmEvent({ type: "cache.dedupe", key });
|
|
751
|
-
return inflight;
|
|
753
|
+
return inflight.promise;
|
|
752
754
|
}
|
|
753
755
|
const tags = Array.from(normalizeCacheOptionsTags(options));
|
|
754
756
|
const generation = this.generation;
|
|
757
|
+
const startVersion = this.version;
|
|
755
758
|
const promise = this.fillCacheEntry(key, producer, options, tags, generation).catch((error) => {
|
|
756
759
|
emitFarmEvent({ type: "cache.error", key, operation: "set", error });
|
|
757
760
|
throw error;
|
|
758
761
|
}).finally(() => {
|
|
759
|
-
if (this.inflight.get(key) === promise) {
|
|
762
|
+
if (this.inflight.get(key)?.promise === promise) {
|
|
760
763
|
this.inflight.delete(key);
|
|
761
764
|
}
|
|
762
765
|
});
|
|
763
|
-
this.inflight.set(key, promise);
|
|
766
|
+
this.inflight.set(key, { promise, tags, startVersion });
|
|
764
767
|
return promise;
|
|
765
768
|
}
|
|
769
|
+
/** A fill that started before one of its tags was invalidated cannot satisfy later readers. */
|
|
770
|
+
wasInvalidatedSince(tags, version) {
|
|
771
|
+
for (const tag of tags) {
|
|
772
|
+
const invalidatedVersion = this.invalidatedTagVersions.get(tag);
|
|
773
|
+
if (invalidatedVersion !== void 0 && invalidatedVersion > version) return true;
|
|
774
|
+
}
|
|
775
|
+
return false;
|
|
776
|
+
}
|
|
766
777
|
async fillCacheEntry(key, producer, options, tags, generation) {
|
|
767
778
|
const adapter = this.adapter;
|
|
768
779
|
const namespace = this.namespace;
|
|
@@ -803,7 +814,7 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
803
814
|
return value;
|
|
804
815
|
} finally {
|
|
805
816
|
this.activeGenerations.delete(activeGeneration);
|
|
806
|
-
this.pruneInvalidatedTagVersions();
|
|
817
|
+
this.pruneInvalidatedTagVersions(activeGeneration.tags);
|
|
807
818
|
if (leaseToken && adapter?.releaseLease) {
|
|
808
819
|
try {
|
|
809
820
|
await adapter.releaseLease(leaseKey, leaseToken);
|
|
@@ -848,18 +859,9 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
848
859
|
}
|
|
849
860
|
return void 0;
|
|
850
861
|
}
|
|
851
|
-
countEntriesForTag(tag) {
|
|
852
|
-
let count = 0;
|
|
853
|
-
for (const entry of this.entries.values()) {
|
|
854
|
-
if (entry.tags.has(tag)) {
|
|
855
|
-
count++;
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
return count;
|
|
859
|
-
}
|
|
860
862
|
countEntriesForTags(tags) {
|
|
861
863
|
let count = 0;
|
|
862
|
-
for (const entry of this.
|
|
864
|
+
for (const entry of this.entriesByTag.get(tags[0]) ?? []) {
|
|
863
865
|
if (tags.every((tag) => entry.tags.has(tag))) {
|
|
864
866
|
count++;
|
|
865
867
|
}
|
|
@@ -867,10 +869,10 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
867
869
|
return count;
|
|
868
870
|
}
|
|
869
871
|
invalidateTag(normalizedTag) {
|
|
870
|
-
const count = this.
|
|
872
|
+
const count = this.entriesByTag.get(normalizedTag)?.size ?? 0;
|
|
871
873
|
this.invalidatedTagVersions.delete(normalizedTag);
|
|
872
874
|
this.invalidatedTagVersions.set(normalizedTag, ++this.version);
|
|
873
|
-
this.pruneInvalidatedTagVersions();
|
|
875
|
+
this.pruneInvalidatedTagVersions([normalizedTag]);
|
|
874
876
|
return count;
|
|
875
877
|
}
|
|
876
878
|
toPublicEntry(entry) {
|
|
@@ -900,19 +902,51 @@ var _FarmDataCache = class _FarmDataCache {
|
|
|
900
902
|
this.entries.set(key, entry);
|
|
901
903
|
}
|
|
902
904
|
storeLocalEntry(entry) {
|
|
903
|
-
|
|
905
|
+
const removed = [];
|
|
906
|
+
const replaced = this.detachLocalEntry(entry.key);
|
|
907
|
+
if (replaced) removed.push(replaced);
|
|
904
908
|
this.entries.set(entry.key, entry);
|
|
909
|
+
for (const tag of entry.tags) {
|
|
910
|
+
let tagged = this.entriesByTag.get(tag);
|
|
911
|
+
if (!tagged) this.entriesByTag.set(tag, tagged = /* @__PURE__ */ new Set());
|
|
912
|
+
tagged.add(entry);
|
|
913
|
+
}
|
|
905
914
|
while (this.entries.size > this.maxEntries) {
|
|
906
915
|
const oldestKey = this.entries.keys().next().value;
|
|
907
916
|
if (oldestKey === void 0) break;
|
|
908
|
-
this.
|
|
917
|
+
removed.push(this.detachLocalEntry(oldestKey));
|
|
918
|
+
}
|
|
919
|
+
for (const removedEntry of removed) this.pruneInvalidatedTagVersions(removedEntry.tags);
|
|
920
|
+
}
|
|
921
|
+
deleteLocalEntry(key) {
|
|
922
|
+
const entry = this.detachLocalEntry(key);
|
|
923
|
+
if (!entry) return false;
|
|
924
|
+
this.pruneInvalidatedTagVersions(entry.tags);
|
|
925
|
+
return true;
|
|
926
|
+
}
|
|
927
|
+
detachLocalEntry(key) {
|
|
928
|
+
const entry = this.entries.get(key);
|
|
929
|
+
if (!entry) return void 0;
|
|
930
|
+
this.entries.delete(key);
|
|
931
|
+
for (const tag of entry.tags) {
|
|
932
|
+
const tagged = this.entriesByTag.get(tag);
|
|
933
|
+
if (!tagged) continue;
|
|
934
|
+
tagged.delete(entry);
|
|
935
|
+
if (tagged.size === 0) this.entriesByTag.delete(tag);
|
|
909
936
|
}
|
|
910
|
-
|
|
937
|
+
return entry;
|
|
911
938
|
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
939
|
+
/**
|
|
940
|
+
* Drop invalidation versions that no local entry or active fill can be stale against.
|
|
941
|
+
* Callers pass only the tags whose dependents just changed, so the cost is bounded by
|
|
942
|
+
* the entries sharing those tags rather than by the whole cache.
|
|
943
|
+
*/
|
|
944
|
+
pruneInvalidatedTagVersions(tags) {
|
|
945
|
+
tags: for (const tag of tags) {
|
|
946
|
+
const invalidatedVersion = this.invalidatedTagVersions.get(tag);
|
|
947
|
+
if (invalidatedVersion === void 0) continue;
|
|
948
|
+
for (const entry of this.entriesByTag.get(tag) ?? []) {
|
|
949
|
+
if (entry.createdVersion < invalidatedVersion) continue tags;
|
|
916
950
|
}
|
|
917
951
|
for (const generation of this.activeGenerations) {
|
|
918
952
|
if (generation.tags.has(tag) && generation.createdVersion < invalidatedVersion)
|
|
@@ -1343,6 +1377,43 @@ __name(_resolveCurrentRequest, "_resolveCurrentRequest");
|
|
|
1343
1377
|
|
|
1344
1378
|
// src/server-fn.ts
|
|
1345
1379
|
var FARM_SERVER_FN_SYMBOL = /* @__PURE__ */ Symbol.for("farm.server-fn");
|
|
1380
|
+
var FARM_SERVER_FUNCTION_DESCRIPTOR = /* @__PURE__ */ Symbol.for("farm.server-function.descriptor");
|
|
1381
|
+
var _ServerFnInputError = class _ServerFnInputError extends Error {
|
|
1382
|
+
constructor(cause) {
|
|
1383
|
+
super("Server function input is invalid");
|
|
1384
|
+
this.cause = cause;
|
|
1385
|
+
}
|
|
1386
|
+
};
|
|
1387
|
+
__name(_ServerFnInputError, "ServerFnInputError");
|
|
1388
|
+
var ServerFnInputError = _ServerFnInputError;
|
|
1389
|
+
function createServerFunctionDescriptor(kind, options, run) {
|
|
1390
|
+
return Object.freeze({
|
|
1391
|
+
kind,
|
|
1392
|
+
input: options.input,
|
|
1393
|
+
output: options.output,
|
|
1394
|
+
mcp: options.mcp === void 0 ? void 0 : Object.freeze({ ...options.mcp }),
|
|
1395
|
+
run
|
|
1396
|
+
});
|
|
1397
|
+
}
|
|
1398
|
+
__name(createServerFunctionDescriptor, "createServerFunctionDescriptor");
|
|
1399
|
+
function _attachServerFunctionDescriptor(target, descriptor) {
|
|
1400
|
+
Object.defineProperty(target, FARM_SERVER_FUNCTION_DESCRIPTOR, {
|
|
1401
|
+
value: descriptor,
|
|
1402
|
+
enumerable: false
|
|
1403
|
+
});
|
|
1404
|
+
}
|
|
1405
|
+
__name(_attachServerFunctionDescriptor, "_attachServerFunctionDescriptor");
|
|
1406
|
+
function getServerFunctionRunner(value) {
|
|
1407
|
+
if (typeof value !== "function") return void 0;
|
|
1408
|
+
return value[FARM_SERVER_FUNCTION_DESCRIPTOR];
|
|
1409
|
+
}
|
|
1410
|
+
__name(getServerFunctionRunner, "getServerFunctionRunner");
|
|
1411
|
+
function _runServerFunctionForCaller(value, input) {
|
|
1412
|
+
const runner = getServerFunctionRunner(value);
|
|
1413
|
+
if (!runner) throw new TypeError("Expected a function created with createServerFn");
|
|
1414
|
+
return runner.run(input);
|
|
1415
|
+
}
|
|
1416
|
+
__name(_runServerFunctionForCaller, "_runServerFunctionForCaller");
|
|
1346
1417
|
var UNSAFE_FORM_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
1347
1418
|
function createServerFn(options) {
|
|
1348
1419
|
if (!options || typeof options.handler !== "function") {
|
|
@@ -1351,10 +1422,15 @@ function createServerFn(options) {
|
|
|
1351
1422
|
const middleware = resolveServerFnMiddleware(options.middleware);
|
|
1352
1423
|
const errors = normalizeServerFnErrors(options.errors);
|
|
1353
1424
|
const error = createServerFnErrorHandler(errors);
|
|
1354
|
-
const
|
|
1425
|
+
const run = /* @__PURE__ */ __name(async (value, labelInputErrors) => {
|
|
1355
1426
|
const formData = isFormData(value) ? value : void 0;
|
|
1356
1427
|
const rawInput = formData ? formDataToObject(formData) : value;
|
|
1357
|
-
|
|
1428
|
+
let input;
|
|
1429
|
+
try {
|
|
1430
|
+
input = await _parseServerFnSchema(options.input, rawInput, "input");
|
|
1431
|
+
} catch (cause) {
|
|
1432
|
+
throw labelInputErrors && isSchemaValidationFailure(cause) ? new ServerFnInputError(cause) : cause;
|
|
1433
|
+
}
|
|
1358
1434
|
const executionContext = getServerActionExecutionContext();
|
|
1359
1435
|
const request = executionContext?.request ?? _resolveCurrentRequest();
|
|
1360
1436
|
const signal = executionContext?.signal ?? request?.signal ?? getServerActionSignal();
|
|
@@ -1380,7 +1456,8 @@ function createServerFn(options) {
|
|
|
1380
1456
|
await applyFarmCacheInvalidationTargets(declaration);
|
|
1381
1457
|
}
|
|
1382
1458
|
return parsedResult;
|
|
1383
|
-
}, "
|
|
1459
|
+
}, "run");
|
|
1460
|
+
const serverFn = /* @__PURE__ */ __name((value) => run(value, false), "serverFn");
|
|
1384
1461
|
Object.defineProperties(serverFn, {
|
|
1385
1462
|
[FARM_SERVER_FN_SYMBOL]: {
|
|
1386
1463
|
value: true,
|
|
@@ -1411,6 +1488,10 @@ function createServerFn(options) {
|
|
|
1411
1488
|
enumerable: false
|
|
1412
1489
|
}
|
|
1413
1490
|
});
|
|
1491
|
+
_attachServerFunctionDescriptor(
|
|
1492
|
+
serverFn,
|
|
1493
|
+
createServerFunctionDescriptor("action", options, (value) => run(value, true))
|
|
1494
|
+
);
|
|
1414
1495
|
return serverFn;
|
|
1415
1496
|
}
|
|
1416
1497
|
__name(createServerFn, "createServerFn");
|
|
@@ -1568,9 +1649,17 @@ async function _parseServerFnSchema(schema, value, contract, owner = "createServ
|
|
|
1568
1649
|
throw new TypeError(`${owner} ${contract} must provide parse, parseAsync, or safeParse`);
|
|
1569
1650
|
}
|
|
1570
1651
|
__name(_parseServerFnSchema, "_parseServerFnSchema");
|
|
1652
|
+
var schemaValidationFailures = /* @__PURE__ */ new WeakSet();
|
|
1653
|
+
function isSchemaValidationFailure(error) {
|
|
1654
|
+
if (!error || typeof error !== "object") return false;
|
|
1655
|
+
return schemaValidationFailures.has(error) || Array.isArray(error.issues);
|
|
1656
|
+
}
|
|
1657
|
+
__name(isSchemaValidationFailure, "isSchemaValidationFailure");
|
|
1571
1658
|
function unwrapSafeParseResult(result) {
|
|
1572
1659
|
if (result && typeof result === "object" && "success" in result && result.success === false) {
|
|
1573
|
-
|
|
1660
|
+
const error = result.error;
|
|
1661
|
+
if (error && typeof error === "object") schemaValidationFailures.add(error);
|
|
1662
|
+
throw error;
|
|
1574
1663
|
}
|
|
1575
1664
|
if (result && typeof result === "object" && "success" in result && result.success === true) {
|
|
1576
1665
|
return result.data;
|
|
@@ -1687,6 +1776,16 @@ function createServerQuery(options) {
|
|
|
1687
1776
|
enumerable: false
|
|
1688
1777
|
}
|
|
1689
1778
|
});
|
|
1779
|
+
_attachServerFunctionDescriptor(
|
|
1780
|
+
query,
|
|
1781
|
+
createServerFunctionDescriptor("query", options, async (value) => {
|
|
1782
|
+
const result = await _runServerFunctionForCaller(
|
|
1783
|
+
execute,
|
|
1784
|
+
value
|
|
1785
|
+
);
|
|
1786
|
+
return result.data;
|
|
1787
|
+
})
|
|
1788
|
+
);
|
|
1690
1789
|
return query;
|
|
1691
1790
|
}
|
|
1692
1791
|
__name(createServerQuery, "createServerQuery");
|
package/dist/server-query.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RouteDataCacheKey } from './cache.mjs';
|
|
2
|
-
import { ServerFnContext, ServerFnSchema, AnyServerFnMiddleware, InferServerFnSchemaOutput, ServerFnMiddlewareContext, ServerFnHandler, InferServerFnSchemaInput } from './server-fn.mjs';
|
|
2
|
+
import { ServerFnContext, ServerFnSchema, AnyServerFnMiddleware, InferServerFnSchemaOutput, ServerFnMiddlewareContext, ServerFnMCPMetadata, ServerFnHandler, InferServerFnSchemaInput } from './server-fn.mjs';
|
|
3
3
|
import './server-fn-error-DDh14a0V.mjs';
|
|
4
|
+
import './endpoint-DAc96i93.mjs';
|
|
4
5
|
|
|
5
6
|
type MaybePromise<T> = T | Promise<T>;
|
|
6
7
|
type ServerQueryStaleTime = number | false | `${number}${"ms" | "s" | "m" | "h"}`;
|
|
@@ -14,6 +15,8 @@ type ServerQueryOptions<TSchema extends ServerFnSchema | undefined, TResult, TMi
|
|
|
14
15
|
staleTime?: ServerQueryStaleTime;
|
|
15
16
|
/** Allow the configured client cache persistence adapter to store results on the device. */
|
|
16
17
|
persist?: boolean;
|
|
18
|
+
/** Expose this query as a read-only MCP tool when it is listed in `mcp.tools`. `name` is required. */
|
|
19
|
+
mcp?: ServerFnMCPMetadata;
|
|
17
20
|
handler: ServerFnHandler<TSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TSchema> : unknown, TResult, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
18
21
|
};
|
|
19
22
|
type ServerQueryOutputOptions<TInputSchema extends ServerFnSchema | undefined, TOutputSchema extends ServerFnSchema, TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly []> = {
|
|
@@ -25,6 +28,8 @@ type ServerQueryOutputOptions<TInputSchema extends ServerFnSchema | undefined, T
|
|
|
25
28
|
staleTime?: ServerQueryStaleTime;
|
|
26
29
|
/** Allow the configured client cache persistence adapter to store results on the device. */
|
|
27
30
|
persist?: boolean;
|
|
31
|
+
/** Expose this query as a read-only MCP tool when it is listed in `mcp.tools`. `name` is required. */
|
|
32
|
+
mcp?: ServerFnMCPMetadata;
|
|
28
33
|
handler: ServerFnHandler<TInputSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TInputSchema> : unknown, unknown, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
29
34
|
};
|
|
30
35
|
type ServerQuery<TInput, TResult> = ([unknown] extends [TInput] ? (input?: TInput) => Promise<TResult> : (input: TInput) => Promise<TResult>) & {
|
package/dist/server-query.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RouteDataCacheKey } from './cache.js';
|
|
2
|
-
import { ServerFnContext, ServerFnSchema, AnyServerFnMiddleware, InferServerFnSchemaOutput, ServerFnMiddlewareContext, ServerFnHandler, InferServerFnSchemaInput } from './server-fn.js';
|
|
2
|
+
import { ServerFnContext, ServerFnSchema, AnyServerFnMiddleware, InferServerFnSchemaOutput, ServerFnMiddlewareContext, ServerFnMCPMetadata, ServerFnHandler, InferServerFnSchemaInput } from './server-fn.js';
|
|
3
3
|
import './server-fn-error-DDh14a0V.js';
|
|
4
|
+
import './endpoint-1zA994xL.js';
|
|
4
5
|
|
|
5
6
|
type MaybePromise<T> = T | Promise<T>;
|
|
6
7
|
type ServerQueryStaleTime = number | false | `${number}${"ms" | "s" | "m" | "h"}`;
|
|
@@ -14,6 +15,8 @@ type ServerQueryOptions<TSchema extends ServerFnSchema | undefined, TResult, TMi
|
|
|
14
15
|
staleTime?: ServerQueryStaleTime;
|
|
15
16
|
/** Allow the configured client cache persistence adapter to store results on the device. */
|
|
16
17
|
persist?: boolean;
|
|
18
|
+
/** Expose this query as a read-only MCP tool when it is listed in `mcp.tools`. `name` is required. */
|
|
19
|
+
mcp?: ServerFnMCPMetadata;
|
|
17
20
|
handler: ServerFnHandler<TSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TSchema> : unknown, TResult, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
18
21
|
};
|
|
19
22
|
type ServerQueryOutputOptions<TInputSchema extends ServerFnSchema | undefined, TOutputSchema extends ServerFnSchema, TMiddlewares extends readonly AnyServerFnMiddleware[] = readonly []> = {
|
|
@@ -25,6 +28,8 @@ type ServerQueryOutputOptions<TInputSchema extends ServerFnSchema | undefined, T
|
|
|
25
28
|
staleTime?: ServerQueryStaleTime;
|
|
26
29
|
/** Allow the configured client cache persistence adapter to store results on the device. */
|
|
27
30
|
persist?: boolean;
|
|
31
|
+
/** Expose this query as a read-only MCP tool when it is listed in `mcp.tools`. `name` is required. */
|
|
32
|
+
mcp?: ServerFnMCPMetadata;
|
|
28
33
|
handler: ServerFnHandler<TInputSchema extends ServerFnSchema ? InferServerFnSchemaOutput<TInputSchema> : unknown, unknown, ServerFnMiddlewareContext<TMiddlewares>>;
|
|
29
34
|
};
|
|
30
35
|
type ServerQuery<TInput, TResult> = ([unknown] extends [TInput] ? (input?: TInput) => Promise<TResult> : (input: TInput) => Promise<TResult>) & {
|