@farm.js/core 0.1.0-beta.14 → 0.1.0-beta.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/after.d.mts +25 -0
- package/dist/after.d.ts +25 -0
- package/dist/agent-runtime.d.mts +96 -0
- package/dist/agent-runtime.d.ts +96 -0
- package/dist/api/route-manager.cjs.map +1 -1
- package/dist/api/route-manager.d.mts +66 -0
- package/dist/api/route-manager.d.ts +66 -0
- package/dist/api/route-manager.mjs +2 -2
- package/dist/api/runtime.cjs.map +1 -1
- package/dist/api/runtime.d.mts +3 -0
- package/dist/api/runtime.d.ts +3 -0
- package/dist/api/runtime.mjs +1 -1
- package/dist/api.cjs +18 -10
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.mts +48 -0
- package/dist/api.d.ts +48 -0
- package/dist/api.mjs +3 -3
- package/dist/app-B0tE1I3o.d.ts +306 -0
- package/dist/app-Dv2JJb7X.d.mts +306 -0
- package/dist/app-markdown.d.mts +24 -0
- package/dist/app-markdown.d.ts +24 -0
- package/dist/cache.d.mts +192 -0
- package/dist/cache.d.ts +192 -0
- package/dist/{chunk-VUL55IAX.mjs → chunk-2FLBZFPG.mjs} +19 -19
- package/dist/chunk-2FLBZFPG.mjs.map +1 -0
- package/dist/{chunk-B232I2GP.mjs → chunk-3HIVDX7J.mjs} +12 -1
- package/dist/chunk-3HIVDX7J.mjs.map +1 -0
- package/dist/{chunk-JDEOUK5V.mjs → chunk-6YXKHAFU.mjs} +3 -3
- package/dist/{chunk-Z5CQMP54.mjs → chunk-ARRYKOI5.mjs} +2 -2
- package/dist/{chunk-KLA67WKG.mjs → chunk-B3FFOIWS.mjs} +2 -2
- package/dist/chunk-E257KFBU.mjs +227 -0
- package/dist/chunk-E257KFBU.mjs.map +1 -0
- package/dist/{chunk-PFE6GMNE.mjs → chunk-HMRFYJK6.mjs} +19 -11
- package/dist/chunk-HMRFYJK6.mjs.map +1 -0
- package/dist/{chunk-OPHK6OJN.mjs → chunk-JAEAE27K.mjs} +2 -2
- package/dist/{chunk-32W4QEJP.mjs → chunk-KFTGPFRD.mjs} +1 -1
- package/dist/chunk-KFTGPFRD.mjs.map +1 -0
- package/dist/{chunk-L2PE36GQ.mjs → chunk-PZXBQKCH.mjs} +15 -6
- package/dist/chunk-PZXBQKCH.mjs.map +1 -0
- package/dist/{chunk-UXUAWNO5.mjs → chunk-RIXKJPGI.mjs} +117 -55
- package/dist/chunk-RIXKJPGI.mjs.map +1 -0
- package/dist/{chunk-PNFQQSRA.mjs → chunk-T2M5QANG.mjs} +143 -41
- package/dist/chunk-T2M5QANG.mjs.map +1 -0
- package/dist/{chunk-WDU6QXNK.mjs → chunk-UCYWGN2P.mjs} +1 -1
- package/dist/chunk-UCYWGN2P.mjs.map +1 -0
- package/dist/{chunk-65A7QIKI.mjs → chunk-UMVLB3PN.mjs} +3 -3
- package/dist/chunk-UMVLB3PN.mjs.map +1 -0
- package/dist/{chunk-ARCGE2VT.mjs → chunk-VFDBC3W7.mjs} +2 -2
- package/dist/{chunk-ARCGE2VT.mjs.map → chunk-VFDBC3W7.mjs.map} +1 -1
- package/dist/{chunk-VY2UYN5R.mjs → chunk-VPCFICID.mjs} +82 -3
- package/dist/chunk-VPCFICID.mjs.map +1 -0
- package/dist/{chunk-H3TE3LOV.mjs → chunk-XMFTIVJH.mjs} +2 -2
- package/dist/{chunk-UB5UOSHB.mjs → chunk-ZVMV3THA.mjs} +71 -2
- package/dist/chunk-ZVMV3THA.mjs.map +1 -0
- package/dist/chunk-recovery-lnQFzcQP.d.mts +26 -0
- package/dist/chunk-recovery-lnQFzcQP.d.ts +26 -0
- package/dist/client-BT1mFQas.d.mts +447 -0
- package/dist/client-Nn0q4eO4.d.ts +447 -0
- package/dist/client-cache-CIlyBlmx.d.ts +6 -0
- package/dist/client-cache-D-EZ7XVW.d.mts +6 -0
- package/dist/client-plugins-278AvYHE.d.mts +2021 -0
- package/dist/client-plugins-CTQAkr7R.d.ts +2021 -0
- package/dist/client-plugins.d.mts +24 -0
- package/dist/client-plugins.d.ts +24 -0
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.mts +452 -0
- package/dist/client.d.ts +452 -0
- package/dist/client.mjs +3 -3
- package/dist/config.d.mts +31 -0
- package/dist/config.d.ts +31 -0
- package/dist/cron.d.mts +78 -0
- package/dist/cron.d.ts +78 -0
- package/dist/deferred.d.mts +42 -0
- package/dist/deferred.d.ts +42 -0
- package/dist/deployment.cjs +12 -0
- package/dist/deployment.cjs.map +1 -1
- package/dist/deployment.d.mts +36 -0
- package/dist/deployment.d.ts +36 -0
- package/dist/deployment.mjs +3 -1
- package/dist/{devtools-GAZ7F3KL.mjs → devtools-K2ERKGNI.mjs} +5 -5
- package/dist/docs.cjs.map +1 -1
- package/dist/docs.d.mts +80 -0
- package/dist/docs.d.ts +80 -0
- package/dist/docs.mjs +5 -5
- package/dist/env-types.d.mts +12 -0
- package/dist/env-types.d.ts +12 -0
- package/dist/env.d.mts +45 -0
- package/dist/env.d.ts +45 -0
- package/dist/environment/vite.d.mts +22 -0
- package/dist/environment/vite.d.ts +22 -0
- package/dist/environment.d.mts +18 -0
- package/dist/environment.d.ts +18 -0
- package/dist/font.d.mts +95 -0
- package/dist/font.d.ts +95 -0
- package/dist/headers.d.mts +22 -0
- package/dist/headers.d.ts +22 -0
- package/dist/i18n/client.d.mts +32 -0
- package/dist/i18n/client.d.ts +32 -0
- package/dist/i18n/index.d.mts +20 -0
- package/dist/i18n/index.d.ts +20 -0
- package/dist/i18n/server.d.mts +30 -0
- package/dist/i18n/server.d.ts +30 -0
- package/dist/image/server.d.mts +37 -0
- package/dist/image/server.d.ts +37 -0
- package/dist/image/sharp.d.mts +7 -0
- package/dist/image/sharp.d.ts +7 -0
- package/dist/image-config-Duob7wER.d.mts +50 -0
- package/dist/image-config-Duob7wER.d.ts +50 -0
- package/dist/image.d.mts +39 -0
- package/dist/image.d.ts +39 -0
- package/dist/index.cjs +598 -109
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +477 -0
- package/dist/index.d.ts +477 -0
- package/dist/index.mjs +45 -29
- package/dist/index.mjs.map +1 -1
- package/dist/integration-api-CHT2OKAf.d.mts +93 -0
- package/dist/integration-api-CHT2OKAf.d.ts +93 -0
- package/dist/integrations.d.mts +24 -0
- package/dist/integrations.d.ts +24 -0
- package/dist/internal/build-runtime.cjs +438 -176
- package/dist/internal/build-runtime.cjs.map +1 -1
- package/dist/internal/build-runtime.d.mts +41 -0
- package/dist/internal/build-runtime.d.ts +41 -0
- package/dist/internal/build-runtime.mjs +13 -13
- package/dist/internal/client-runtime.d.mts +17 -0
- package/dist/internal/client-runtime.d.ts +17 -0
- package/dist/internal/config-runtime.cjs +140 -1
- package/dist/internal/config-runtime.cjs.map +1 -1
- package/dist/internal/config-runtime.d.mts +41 -0
- package/dist/internal/config-runtime.d.ts +41 -0
- package/dist/internal/config-runtime.mjs +4 -4
- package/dist/internal/metadata-image-runtime.d.mts +25 -0
- package/dist/internal/metadata-image-runtime.d.ts +25 -0
- package/dist/internal/production-node-env.d.mts +12 -0
- package/dist/internal/production-node-env.d.ts +12 -0
- package/dist/internal/production-runtime.d.mts +44 -0
- package/dist/internal/production-runtime.d.ts +44 -0
- package/dist/island-CfGru1MO.d.mts +9 -0
- package/dist/island-CfGru1MO.d.ts +9 -0
- package/dist/markdown.d.mts +60 -0
- package/dist/markdown.d.ts +60 -0
- package/dist/metadata-DmCudMw_.d.mts +22 -0
- package/dist/metadata-xghtOlbR.d.ts +22 -0
- package/dist/middleware.cjs +116 -98
- package/dist/middleware.cjs.map +1 -1
- package/dist/middleware.d.mts +171 -0
- package/dist/middleware.d.ts +171 -0
- package/dist/middleware.mjs +5 -2
- package/dist/navigation-errors-Dvwpzaer.d.mts +13 -0
- package/dist/navigation-errors-Dvwpzaer.d.ts +13 -0
- package/dist/navigation.cjs.map +1 -1
- package/dist/navigation.d.mts +14 -0
- package/dist/navigation.d.ts +14 -0
- package/dist/navigation.mjs +3 -3
- package/dist/observability.d.mts +335 -0
- package/dist/observability.d.ts +335 -0
- package/dist/params-BALtrRim.d.ts +15 -0
- package/dist/params-ry-lxqmy.d.mts +15 -0
- package/dist/plugin-BJDf43dc.d.mts +165 -0
- package/dist/plugin-BJDf43dc.d.ts +165 -0
- package/dist/plugin.cjs +247 -28
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.mts +24 -0
- package/dist/plugin.d.ts +24 -0
- package/dist/plugin.mjs +10 -10
- package/dist/production-runtime-BLxSv9cU.d.ts +79 -0
- package/dist/production-runtime-DFN2_RXq.d.mts +79 -0
- package/dist/query/client.d.mts +61 -0
- package/dist/query/client.d.ts +61 -0
- package/dist/query/index.d.mts +90 -0
- package/dist/query/index.d.ts +90 -0
- package/dist/query/parsers.d.mts +25 -0
- package/dist/query/parsers.d.ts +25 -0
- package/dist/query/server.d.mts +55 -0
- package/dist/query/server.d.ts +55 -0
- package/dist/request-Cq5d6qmE.d.mts +6 -0
- package/dist/request-LoxDW3lp.d.ts +6 -0
- package/dist/request.d.mts +25 -0
- package/dist/request.d.ts +25 -0
- package/dist/resolver-DJqjLMg_.d.mts +14 -0
- package/dist/resolver-IH4RmPEl.d.ts +14 -0
- package/dist/route-runtime-DoOHzCAD.d.mts +38 -0
- package/dist/route-runtime-DoOHzCAD.d.ts +38 -0
- package/dist/router.d.mts +36 -0
- package/dist/router.d.ts +36 -0
- package/dist/routes.d.mts +226 -0
- package/dist/routes.d.ts +226 -0
- package/dist/runtime-BA9TOSu1.d.mts +231 -0
- package/dist/runtime-Cxpq6xZN.d.mts +27 -0
- package/dist/runtime-DTAQ2HDv.d.ts +231 -0
- package/dist/runtime-bv63eUiO.d.ts +27 -0
- package/dist/server-action-security.cjs +23 -1
- package/dist/server-action-security.cjs.map +1 -1
- package/dist/server-action-security.d.mts +45 -0
- package/dist/server-action-security.d.ts +45 -0
- package/dist/server-action-security.mjs +1 -1
- package/dist/server-fn-client.cjs.map +1 -1
- package/dist/server-fn-client.d.mts +33 -0
- package/dist/server-fn-client.d.ts +33 -0
- package/dist/server-fn-client.mjs +1 -1
- package/dist/server-fn-error-DDh14a0V.d.mts +26 -0
- package/dist/server-fn-error-DDh14a0V.d.ts +26 -0
- package/dist/server-fn.cjs +140 -3
- package/dist/server-fn.cjs.map +1 -1
- package/dist/server-fn.d.mts +121 -0
- package/dist/server-fn.d.ts +121 -0
- package/dist/server-fn.mjs +14 -3
- package/dist/server-plugins.d.mts +57 -0
- package/dist/server-plugins.d.ts +57 -0
- package/dist/server-query-client.d.mts +51 -0
- package/dist/server-query-client.d.ts +51 -0
- package/dist/server-query.cjs +99 -1
- package/dist/server-query.cjs.map +1 -1
- package/dist/server-query.d.mts +37 -0
- package/dist/server-query.d.ts +37 -0
- package/dist/server-query.mjs +3 -3
- package/dist/server.cjs +403 -33
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.mts +51 -0
- package/dist/server.d.ts +51 -0
- package/dist/server.mjs +14 -14
- package/dist/storage.d.mts +52 -0
- package/dist/storage.d.ts +52 -0
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.mts +103 -0
- package/dist/testing.d.ts +103 -0
- package/dist/testing.mjs +3 -3
- package/dist/transport-BmbGTXA5.d.mts +49 -0
- package/dist/transport-BmbGTXA5.d.ts +49 -0
- package/dist/types-BMxWr97v.d.mts +81 -0
- package/dist/types-BMxWr97v.d.ts +81 -0
- package/dist/types-D1A6-XvH.d.mts +73 -0
- package/dist/types-D1A6-XvH.d.ts +73 -0
- package/dist/types-DTzm4TCl.d.mts +78 -0
- package/dist/types-DTzm4TCl.d.ts +78 -0
- package/dist/utils-B6GaYNJL.d.ts +23 -0
- package/dist/utils-CKSHiip6.d.mts +23 -0
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.mts +3 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +255 -30
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.mts +24 -0
- package/dist/vite.d.ts +24 -0
- package/dist/vite.mjs +10 -10
- package/dist/workflows.d.mts +110 -0
- package/dist/workflows.d.ts +110 -0
- package/package.json +1 -1
- package/types/middleware.d.ts +36 -11
- package/dist/chunk-32W4QEJP.mjs.map +0 -1
- package/dist/chunk-65A7QIKI.mjs.map +0 -1
- package/dist/chunk-B232I2GP.mjs.map +0 -1
- package/dist/chunk-I4CUBGVF.mjs +0 -93
- package/dist/chunk-I4CUBGVF.mjs.map +0 -1
- package/dist/chunk-L2PE36GQ.mjs.map +0 -1
- package/dist/chunk-PFE6GMNE.mjs.map +0 -1
- package/dist/chunk-PNFQQSRA.mjs.map +0 -1
- package/dist/chunk-UB5UOSHB.mjs.map +0 -1
- package/dist/chunk-UXUAWNO5.mjs.map +0 -1
- package/dist/chunk-VUL55IAX.mjs.map +0 -1
- package/dist/chunk-VY2UYN5R.mjs.map +0 -1
- package/dist/chunk-WDU6QXNK.mjs.map +0 -1
- /package/dist/{chunk-JDEOUK5V.mjs.map → chunk-6YXKHAFU.mjs.map} +0 -0
- /package/dist/{chunk-Z5CQMP54.mjs.map → chunk-ARRYKOI5.mjs.map} +0 -0
- /package/dist/{chunk-KLA67WKG.mjs.map → chunk-B3FFOIWS.mjs.map} +0 -0
- /package/dist/{chunk-OPHK6OJN.mjs.map → chunk-JAEAE27K.mjs.map} +0 -0
- /package/dist/{chunk-H3TE3LOV.mjs.map → chunk-XMFTIVJH.mjs.map} +0 -0
- /package/dist/{devtools-GAZ7F3KL.mjs.map → devtools-K2ERKGNI.mjs.map} +0 -0
package/dist/plugin.cjs
CHANGED
|
@@ -2036,6 +2036,13 @@ var init_cache_invalidation = __esm({
|
|
|
2036
2036
|
}
|
|
2037
2037
|
});
|
|
2038
2038
|
|
|
2039
|
+
// src/server-fn-error.ts
|
|
2040
|
+
var init_server_fn_error = __esm({
|
|
2041
|
+
"src/server-fn-error.ts"() {
|
|
2042
|
+
"use strict";
|
|
2043
|
+
}
|
|
2044
|
+
});
|
|
2045
|
+
|
|
2039
2046
|
// src/server-action-security.ts
|
|
2040
2047
|
function resolveServerActionsConfig(config) {
|
|
2041
2048
|
const allowedOrigins = (config?.allowedOrigins ?? []).map(normalizeAllowedOriginPattern);
|
|
@@ -2129,6 +2136,7 @@ var init_server_action_security = __esm({
|
|
|
2129
2136
|
"use strict";
|
|
2130
2137
|
import_node_async_hooks = require("async_hooks");
|
|
2131
2138
|
init_cache_invalidation();
|
|
2139
|
+
init_server_fn_error();
|
|
2132
2140
|
DEFAULT_SERVER_ACTION_BODY_SIZE_LIMIT = 1e6;
|
|
2133
2141
|
SERVER_ACTION_STORAGE_KEY = /* @__PURE__ */ Symbol.for("farm.serverActionStorage");
|
|
2134
2142
|
__name(resolveServerActionsConfig, "resolveServerActionsConfig");
|
|
@@ -3947,6 +3955,135 @@ var init_preload = __esm({
|
|
|
3947
3955
|
}
|
|
3948
3956
|
});
|
|
3949
3957
|
|
|
3958
|
+
// src/security.ts
|
|
3959
|
+
function resolveFarmSecurityConfig(input) {
|
|
3960
|
+
if (input === void 0) return { csp: false };
|
|
3961
|
+
if (!isPlainRecord(input)) {
|
|
3962
|
+
throw new TypeError("security must be an object containing the csp option.");
|
|
3963
|
+
}
|
|
3964
|
+
if (Object.prototype.hasOwnProperty.call(input, "contentSecurityPolicy")) {
|
|
3965
|
+
throw new TypeError(
|
|
3966
|
+
"security.contentSecurityPolicy is not supported. Use security.csp instead."
|
|
3967
|
+
);
|
|
3968
|
+
}
|
|
3969
|
+
const csp = input.csp;
|
|
3970
|
+
if (csp === void 0 || csp === false) return { csp: false };
|
|
3971
|
+
if (typeof csp === "string") {
|
|
3972
|
+
return {
|
|
3973
|
+
csp: {
|
|
3974
|
+
value: validateSerializedCsp(csp),
|
|
3975
|
+
reportOnly: false
|
|
3976
|
+
}
|
|
3977
|
+
};
|
|
3978
|
+
}
|
|
3979
|
+
if (!isPlainRecord(csp)) {
|
|
3980
|
+
throw new TypeError("security.csp must be a policy string, false, or an options object.");
|
|
3981
|
+
}
|
|
3982
|
+
const reportOnly = validateReportOnly(csp.reportOnly);
|
|
3983
|
+
if (Object.prototype.hasOwnProperty.call(csp, "value")) {
|
|
3984
|
+
if (Object.prototype.hasOwnProperty.call(csp, "policy") || Object.prototype.hasOwnProperty.call(csp, "directives")) {
|
|
3985
|
+
throw new TypeError(
|
|
3986
|
+
"Resolved security.csp values cannot include policy or directives options."
|
|
3987
|
+
);
|
|
3988
|
+
}
|
|
3989
|
+
return {
|
|
3990
|
+
csp: {
|
|
3991
|
+
value: validateSerializedCsp(csp.value),
|
|
3992
|
+
reportOnly
|
|
3993
|
+
}
|
|
3994
|
+
};
|
|
3995
|
+
}
|
|
3996
|
+
const { policy, directives } = csp;
|
|
3997
|
+
if (policy !== void 0 && directives !== void 0) {
|
|
3998
|
+
throw new TypeError("security.csp accepts either policy or directives, not both.");
|
|
3999
|
+
}
|
|
4000
|
+
if (policy === void 0 && directives === void 0) {
|
|
4001
|
+
throw new TypeError("security.csp requires a policy string or directives object.");
|
|
4002
|
+
}
|
|
4003
|
+
return {
|
|
4004
|
+
csp: {
|
|
4005
|
+
value: policy !== void 0 ? validateSerializedCsp(policy) : serializeFarmCspDirectives(directives),
|
|
4006
|
+
reportOnly
|
|
4007
|
+
}
|
|
4008
|
+
};
|
|
4009
|
+
}
|
|
4010
|
+
function serializeFarmCspDirectives(directives) {
|
|
4011
|
+
if (!isPlainRecord(directives)) {
|
|
4012
|
+
throw new TypeError("security.csp.directives must be an object.");
|
|
4013
|
+
}
|
|
4014
|
+
const serialized = [];
|
|
4015
|
+
const normalizedNames = /* @__PURE__ */ new Set();
|
|
4016
|
+
for (const [configuredName, configuredValue] of Object.entries(directives)) {
|
|
4017
|
+
if (configuredValue === false || configuredValue === null || configuredValue === void 0) {
|
|
4018
|
+
continue;
|
|
4019
|
+
}
|
|
4020
|
+
const name = normalizeDirectiveName(configuredName);
|
|
4021
|
+
if (normalizedNames.has(name)) {
|
|
4022
|
+
throw new TypeError(`security.csp contains the duplicate directive ${JSON.stringify(name)}.`);
|
|
4023
|
+
}
|
|
4024
|
+
normalizedNames.add(name);
|
|
4025
|
+
const values = configuredValue === true ? [] : (Array.isArray(configuredValue) ? configuredValue : [configuredValue]).map(
|
|
4026
|
+
validateDirectiveValue
|
|
4027
|
+
);
|
|
4028
|
+
serialized.push(values.length > 0 ? `${name} ${values.join(" ")}` : name);
|
|
4029
|
+
}
|
|
4030
|
+
if (serialized.length === 0) {
|
|
4031
|
+
throw new TypeError("security.csp.directives must contain at least one enabled directive.");
|
|
4032
|
+
}
|
|
4033
|
+
return serialized.join("; ");
|
|
4034
|
+
}
|
|
4035
|
+
function normalizeDirectiveName(value) {
|
|
4036
|
+
const name = value.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
4037
|
+
if (!/^[a-z][a-z0-9-]*$/.test(name)) {
|
|
4038
|
+
throw new TypeError(`Invalid security.csp directive name: ${JSON.stringify(value)}.`);
|
|
4039
|
+
}
|
|
4040
|
+
return name;
|
|
4041
|
+
}
|
|
4042
|
+
function validateDirectiveValue(value) {
|
|
4043
|
+
if (typeof value !== "string") {
|
|
4044
|
+
throw new TypeError("security.csp directive values must be strings or booleans.");
|
|
4045
|
+
}
|
|
4046
|
+
const normalized = value.trim();
|
|
4047
|
+
if (!normalized || /[;\r\n]/.test(normalized) || normalized.includes("\0")) {
|
|
4048
|
+
throw new TypeError(`Invalid security.csp directive value: ${JSON.stringify(value)}.`);
|
|
4049
|
+
}
|
|
4050
|
+
return normalized;
|
|
4051
|
+
}
|
|
4052
|
+
function validateSerializedCsp(value) {
|
|
4053
|
+
if (typeof value !== "string") {
|
|
4054
|
+
throw new TypeError("security.csp policy must be a non-empty single-line string.");
|
|
4055
|
+
}
|
|
4056
|
+
const normalized = value.trim().replace(/;+$/g, "").trim();
|
|
4057
|
+
if (!normalized || /[\r\n]/.test(normalized) || normalized.includes("\0")) {
|
|
4058
|
+
throw new TypeError("security.csp policy must be a non-empty single-line string.");
|
|
4059
|
+
}
|
|
4060
|
+
return normalized;
|
|
4061
|
+
}
|
|
4062
|
+
function validateReportOnly(value) {
|
|
4063
|
+
if (value === void 0) return false;
|
|
4064
|
+
if (typeof value !== "boolean") {
|
|
4065
|
+
throw new TypeError("security.csp.reportOnly must be a boolean.");
|
|
4066
|
+
}
|
|
4067
|
+
return value;
|
|
4068
|
+
}
|
|
4069
|
+
function isPlainRecord(value) {
|
|
4070
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
4071
|
+
const prototype = Object.getPrototypeOf(value);
|
|
4072
|
+
return prototype === Object.prototype || prototype === null;
|
|
4073
|
+
}
|
|
4074
|
+
var init_security = __esm({
|
|
4075
|
+
"src/security.ts"() {
|
|
4076
|
+
"use strict";
|
|
4077
|
+
__name(resolveFarmSecurityConfig, "resolveFarmSecurityConfig");
|
|
4078
|
+
__name(serializeFarmCspDirectives, "serializeFarmCspDirectives");
|
|
4079
|
+
__name(normalizeDirectiveName, "normalizeDirectiveName");
|
|
4080
|
+
__name(validateDirectiveValue, "validateDirectiveValue");
|
|
4081
|
+
__name(validateSerializedCsp, "validateSerializedCsp");
|
|
4082
|
+
__name(validateReportOnly, "validateReportOnly");
|
|
4083
|
+
__name(isPlainRecord, "isPlainRecord");
|
|
4084
|
+
}
|
|
4085
|
+
});
|
|
4086
|
+
|
|
3950
4087
|
// src/write-file-if-changed.ts
|
|
3951
4088
|
function writeFileIfChanged(filePath, content) {
|
|
3952
4089
|
try {
|
|
@@ -8505,6 +8642,7 @@ var init_config2 = __esm({
|
|
|
8505
8642
|
init_config();
|
|
8506
8643
|
init_auth_config();
|
|
8507
8644
|
init_preload();
|
|
8645
|
+
init_security();
|
|
8508
8646
|
init_config_entry();
|
|
8509
8647
|
__name(getDeployTargetForPreset, "getDeployTargetForPreset");
|
|
8510
8648
|
DOCS_CONFIG_FILENAMES = [
|
|
@@ -19102,6 +19240,7 @@ init_devtools_config();
|
|
|
19102
19240
|
init_config();
|
|
19103
19241
|
init_auth_config();
|
|
19104
19242
|
init_preload();
|
|
19243
|
+
init_security();
|
|
19105
19244
|
var defaultDocsConfig = {
|
|
19106
19245
|
enabled: false,
|
|
19107
19246
|
entry: "/docs",
|
|
@@ -19169,6 +19308,7 @@ var _FarmApp = class _FarmApp {
|
|
|
19169
19308
|
routeRules: normalizeRouteRules(config.routeRules),
|
|
19170
19309
|
context: config.context || (() => void 0),
|
|
19171
19310
|
serverActions: resolveServerActionsConfig(config.serverActions),
|
|
19311
|
+
security: resolveFarmSecurityConfig(config.security),
|
|
19172
19312
|
images: resolveFarmImageConfig(config.images),
|
|
19173
19313
|
performance: resolveFarmPerformanceConfig(config.performance),
|
|
19174
19314
|
i18n: isResolvedI18nConfig(config.i18n) ? config.i18n : resolveFarmI18nConfig(config.i18n, {
|
|
@@ -20913,6 +21053,15 @@ function routePatternToRouteLiteral(pattern) {
|
|
|
20913
21053
|
return JSON.stringify(pattern);
|
|
20914
21054
|
}
|
|
20915
21055
|
__name(routePatternToRouteLiteral, "routePatternToRouteLiteral");
|
|
21056
|
+
function renderTypeUnion(values) {
|
|
21057
|
+
return values.length <= 1 ? values[0] || "never" : `
|
|
21058
|
+
| ${values.join("\n | ")}`;
|
|
21059
|
+
}
|
|
21060
|
+
__name(renderTypeUnion, "renderTypeUnion");
|
|
21061
|
+
function renderTypeAlias(name, value) {
|
|
21062
|
+
return `export type ${name} =${value.startsWith("\n") ? "" : " "}${value};`;
|
|
21063
|
+
}
|
|
21064
|
+
__name(renderTypeAlias, "renderTypeAlias");
|
|
20916
21065
|
function createRoutePattern(route) {
|
|
20917
21066
|
if (route.segments.length === 0) return "/";
|
|
20918
21067
|
return "/" + route.segments.map((seg) => {
|
|
@@ -20975,9 +21124,9 @@ async function createRouteTypeDeclarations(options, outPath) {
|
|
|
20975
21124
|
const typeLiterals = Array.from(new Set(sortedPatterns.flatMap(routePatternToTsTypeLiterals)));
|
|
20976
21125
|
const patternLiterals = sortedPatterns.map(routePatternToRouteLiteral);
|
|
20977
21126
|
const routeModulePatternLiterals = Array.from(routeModulePatterns).sort().map(routePatternToRouteLiteral);
|
|
20978
|
-
const routePathType = suppressLintOnLink ? "string" : typeLiterals
|
|
20979
|
-
const routePatternType = suppressLintOnLink ? "string" : patternLiterals
|
|
20980
|
-
const routeModulePatternType = routeModulePatternLiterals
|
|
21127
|
+
const routePathType = suppressLintOnLink ? "string" : renderTypeUnion(typeLiterals);
|
|
21128
|
+
const routePatternType = suppressLintOnLink ? "string" : renderTypeUnion(patternLiterals);
|
|
21129
|
+
const routeModulePatternType = renderTypeUnion(routeModulePatternLiterals);
|
|
20981
21130
|
const routeTypesImportPath = `./${path14.basename(outPath).replace(/\.d\.ts$/, "")}`;
|
|
20982
21131
|
const linkAugmentationBlock = suppressLintOnLink ? "" : `
|
|
20983
21132
|
declare module "@farm.js/core/client" {
|
|
@@ -21019,9 +21168,9 @@ declare global {
|
|
|
21019
21168
|
* Regenerated on dev start and when routes change.
|
|
21020
21169
|
* Set suppressLintOnLink: true in farm.config.ts to accept any string on Link href.
|
|
21021
21170
|
*/
|
|
21022
|
-
|
|
21023
|
-
|
|
21024
|
-
|
|
21171
|
+
${renderTypeAlias("RoutePath", routePathType)}
|
|
21172
|
+
${renderTypeAlias("RoutePattern", routePatternType)}
|
|
21173
|
+
${renderTypeAlias("RouteModulePattern", routeModulePatternType)}${linkAugmentationBlock}${routeModuleAugmentationBlock}
|
|
21025
21174
|
`;
|
|
21026
21175
|
return content;
|
|
21027
21176
|
}
|
|
@@ -21303,7 +21452,8 @@ async function generateFarmTypeArtifacts(options) {
|
|
|
21303
21452
|
const sourceRoots = getFarmSourceRoots({ root, srcDir, layers: options.layers });
|
|
21304
21453
|
const appDirs = getFarmAppDirectories({ root, srcDir, layers: options.layers });
|
|
21305
21454
|
const result = {
|
|
21306
|
-
apiRoutes: []
|
|
21455
|
+
apiRoutes: [],
|
|
21456
|
+
stalePaths: []
|
|
21307
21457
|
};
|
|
21308
21458
|
const unifiedTypesPath = (0, import_path8.join)(root, srcDir, "farm.d.ts");
|
|
21309
21459
|
const shouldRefreshUnifiedTypes = shouldGenerateRoutes && !options.routeTypesOutFile || shouldGenerateEnv && !options.envTypesOutFile || shouldGenerateI18n && !options.i18nTypesOutFile;
|
|
@@ -21319,22 +21469,29 @@ async function generateFarmTypeArtifacts(options) {
|
|
|
21319
21469
|
unifiedSections.push(await createRouteTypeDeclarations(routeOptions, unifiedTypesPath));
|
|
21320
21470
|
result.routeTypesPath = unifiedTypesPath;
|
|
21321
21471
|
} else if (shouldGenerateRoutes) {
|
|
21322
|
-
|
|
21472
|
+
const routeOptions = {
|
|
21323
21473
|
root,
|
|
21324
21474
|
srcDir,
|
|
21325
21475
|
outFile: options.routeTypesOutFile,
|
|
21326
21476
|
extraRoutes: options.extraRoutes || [],
|
|
21327
21477
|
suppressLintOnLink: options.suppressLintOnLink,
|
|
21328
21478
|
sourceRoots
|
|
21329
|
-
}
|
|
21479
|
+
};
|
|
21480
|
+
if (options.check) {
|
|
21481
|
+
const routeTypesPath = resolveGeneratedPath(root, srcDir, options.routeTypesOutFile);
|
|
21482
|
+
const content = await createRouteTypeDeclarations(routeOptions, routeTypesPath);
|
|
21483
|
+
checkGeneratedFile(routeTypesPath, content, result.stalePaths);
|
|
21484
|
+
result.routeTypesPath = routeTypesPath;
|
|
21485
|
+
} else {
|
|
21486
|
+
result.routeTypesPath = await generateRouteTypes(routeOptions);
|
|
21487
|
+
}
|
|
21330
21488
|
}
|
|
21331
21489
|
if (shouldGenerateApi) {
|
|
21332
21490
|
const generator = new APITypeGenerator(appDirs);
|
|
21333
21491
|
const apiRoutes = generator.scanAPIRoutes();
|
|
21334
21492
|
const apiTypesPath = options.apiTypesOutFile ? (0, import_path8.resolve)(root, options.apiTypesOutFile) : (0, import_path8.join)(root, srcDir, "lib", "api.generated.ts");
|
|
21335
21493
|
const content = generator.generateAPIRouter(apiRoutes, { outFile: apiTypesPath });
|
|
21336
|
-
(
|
|
21337
|
-
writeFileIfChanged(apiTypesPath, content);
|
|
21494
|
+
writeOrCheckGeneratedFile(apiTypesPath, content, options.check, result.stalePaths);
|
|
21338
21495
|
result.apiTypesPath = apiTypesPath;
|
|
21339
21496
|
result.apiRoutes = apiRoutes;
|
|
21340
21497
|
}
|
|
@@ -21352,36 +21509,63 @@ async function generateFarmTypeArtifacts(options) {
|
|
|
21352
21509
|
);
|
|
21353
21510
|
result.envTypesPath = unifiedTypesPath;
|
|
21354
21511
|
} else if (shouldGenerateEnv) {
|
|
21355
|
-
|
|
21512
|
+
const envOptions = {
|
|
21356
21513
|
root,
|
|
21357
21514
|
srcDir,
|
|
21358
21515
|
outFile: options.envTypesOutFile,
|
|
21359
21516
|
configPath: options.configPath,
|
|
21360
21517
|
layerConfigPaths: (options.layers ?? []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile))
|
|
21361
|
-
}
|
|
21518
|
+
};
|
|
21519
|
+
if (options.check) {
|
|
21520
|
+
const envTypesPath = resolveGeneratedPath(root, srcDir, options.envTypesOutFile);
|
|
21521
|
+
checkGeneratedFile(
|
|
21522
|
+
envTypesPath,
|
|
21523
|
+
createEnvTypeDeclarations(envOptions, envTypesPath),
|
|
21524
|
+
result.stalePaths
|
|
21525
|
+
);
|
|
21526
|
+
result.envTypesPath = envTypesPath;
|
|
21527
|
+
} else {
|
|
21528
|
+
result.envTypesPath = await generateEnvTypes(envOptions);
|
|
21529
|
+
}
|
|
21362
21530
|
}
|
|
21363
21531
|
if (shouldGenerateImages && options.imageTypesOutFile) {
|
|
21364
|
-
|
|
21365
|
-
|
|
21366
|
-
|
|
21367
|
-
|
|
21368
|
-
}
|
|
21532
|
+
const imageTypesPath = resolveGeneratedPath(root, srcDir, options.imageTypesOutFile, false);
|
|
21533
|
+
if (options.check) {
|
|
21534
|
+
checkGeneratedFile(imageTypesPath, createFarmImageTypeDeclarations(), result.stalePaths);
|
|
21535
|
+
result.imageTypesPath = imageTypesPath;
|
|
21536
|
+
} else {
|
|
21537
|
+
result.imageTypesPath = generateFarmImageTypes({
|
|
21538
|
+
root,
|
|
21539
|
+
srcDir,
|
|
21540
|
+
outFile: options.imageTypesOutFile
|
|
21541
|
+
});
|
|
21542
|
+
}
|
|
21369
21543
|
}
|
|
21370
21544
|
if (shouldRefreshUnifiedTypes && options.i18nConfig?.enabled && !options.i18nTypesOutFile) {
|
|
21371
21545
|
const { signatures } = await readFarmI18nCatalogs(options.i18nConfig);
|
|
21372
21546
|
unifiedSections.push(renderFarmI18nTypes(options.i18nConfig.locales, signatures));
|
|
21373
21547
|
result.i18nTypesPath = unifiedTypesPath;
|
|
21374
21548
|
} else if (shouldGenerateI18n && options.i18nConfig) {
|
|
21375
|
-
|
|
21376
|
-
root,
|
|
21377
|
-
|
|
21378
|
-
|
|
21379
|
-
|
|
21380
|
-
|
|
21549
|
+
if (options.check) {
|
|
21550
|
+
const i18nTypesPath = resolveGeneratedPath(root, srcDir, options.i18nTypesOutFile, false);
|
|
21551
|
+
const { signatures } = await readFarmI18nCatalogs(options.i18nConfig);
|
|
21552
|
+
checkGeneratedFile(
|
|
21553
|
+
i18nTypesPath,
|
|
21554
|
+
renderFarmI18nTypes(options.i18nConfig.locales, signatures),
|
|
21555
|
+
result.stalePaths
|
|
21556
|
+
);
|
|
21557
|
+
result.i18nTypesPath = i18nTypesPath;
|
|
21558
|
+
} else {
|
|
21559
|
+
result.i18nTypesPath = await generateFarmI18nTypes({
|
|
21560
|
+
root,
|
|
21561
|
+
srcDir,
|
|
21562
|
+
config: options.i18nConfig,
|
|
21563
|
+
outFile: options.i18nTypesOutFile
|
|
21564
|
+
});
|
|
21565
|
+
}
|
|
21381
21566
|
}
|
|
21382
21567
|
if (shouldRefreshUnifiedTypes) {
|
|
21383
|
-
(
|
|
21384
|
-
writeFileIfChanged(
|
|
21568
|
+
writeOrCheckGeneratedFile(
|
|
21385
21569
|
unifiedTypesPath,
|
|
21386
21570
|
`/**
|
|
21387
21571
|
* Generated by Farm.js. Do not edit.
|
|
@@ -21390,14 +21574,41 @@ async function generateFarmTypeArtifacts(options) {
|
|
|
21390
21574
|
|
|
21391
21575
|
import "@farm.js/core/image";
|
|
21392
21576
|
|
|
21393
|
-
${unifiedSections.join("\n")}
|
|
21577
|
+
${unifiedSections.map((section) => section.trimEnd()).join("\n\n")}
|
|
21578
|
+
`,
|
|
21579
|
+
options.check,
|
|
21580
|
+
result.stalePaths
|
|
21394
21581
|
);
|
|
21395
21582
|
result.typesPath = unifiedTypesPath;
|
|
21396
|
-
|
|
21583
|
+
if (options.check) {
|
|
21584
|
+
collectLegacyTypeArtifacts(root, srcDir, result.stalePaths);
|
|
21585
|
+
} else {
|
|
21586
|
+
removeLegacyTypeArtifacts(root, srcDir);
|
|
21587
|
+
}
|
|
21397
21588
|
}
|
|
21398
21589
|
return result;
|
|
21399
21590
|
}
|
|
21400
21591
|
__name(generateFarmTypeArtifacts, "generateFarmTypeArtifacts");
|
|
21592
|
+
function resolveGeneratedPath(root, srcDir, outFile, relativeToSrc = true) {
|
|
21593
|
+
if ((0, import_path8.isAbsolute)(outFile)) return (0, import_path8.resolve)(outFile);
|
|
21594
|
+
return (0, import_path8.resolve)(root, relativeToSrc ? (0, import_path8.join)(srcDir, outFile) : outFile);
|
|
21595
|
+
}
|
|
21596
|
+
__name(resolveGeneratedPath, "resolveGeneratedPath");
|
|
21597
|
+
function writeOrCheckGeneratedFile(filePath, content, check, stalePaths) {
|
|
21598
|
+
if (check) {
|
|
21599
|
+
checkGeneratedFile(filePath, content, stalePaths);
|
|
21600
|
+
return;
|
|
21601
|
+
}
|
|
21602
|
+
(0, import_fs4.mkdirSync)((0, import_path8.dirname)(filePath), { recursive: true });
|
|
21603
|
+
writeFileIfChanged(filePath, content);
|
|
21604
|
+
}
|
|
21605
|
+
__name(writeOrCheckGeneratedFile, "writeOrCheckGeneratedFile");
|
|
21606
|
+
function checkGeneratedFile(filePath, content, stalePaths) {
|
|
21607
|
+
if (!(0, import_fs4.existsSync)(filePath) || (0, import_fs4.readFileSync)(filePath, "utf8") !== content) {
|
|
21608
|
+
stalePaths.push(filePath);
|
|
21609
|
+
}
|
|
21610
|
+
}
|
|
21611
|
+
__name(checkGeneratedFile, "checkGeneratedFile");
|
|
21401
21612
|
var LEGACY_TYPE_ARTIFACTS = [
|
|
21402
21613
|
["farm-routes.d.ts", "Auto-generated route types"],
|
|
21403
21614
|
["farm-env.d.ts", "Auto-generated env types"],
|
|
@@ -21415,6 +21626,14 @@ function removeLegacyTypeArtifacts(root, srcDir) {
|
|
|
21415
21626
|
}
|
|
21416
21627
|
}
|
|
21417
21628
|
__name(removeLegacyTypeArtifacts, "removeLegacyTypeArtifacts");
|
|
21629
|
+
function collectLegacyTypeArtifacts(root, srcDir, stalePaths) {
|
|
21630
|
+
for (const [fileName, marker] of LEGACY_TYPE_ARTIFACTS) {
|
|
21631
|
+
const filePath = (0, import_path8.join)(root, srcDir, fileName);
|
|
21632
|
+
if (!(0, import_fs4.existsSync)(filePath)) continue;
|
|
21633
|
+
if ((0, import_fs4.readFileSync)(filePath, "utf8").includes(marker)) stalePaths.push(filePath);
|
|
21634
|
+
}
|
|
21635
|
+
}
|
|
21636
|
+
__name(collectLegacyTypeArtifacts, "collectLegacyTypeArtifacts");
|
|
21418
21637
|
|
|
21419
21638
|
// src/vite.ts
|
|
21420
21639
|
init_markdown();
|