@gigadrive/network-config 3.1.0 → 3.1.2
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/index.d.mts +40 -4
- package/dist/index.d.ts +40 -4
- package/dist/index.js +766 -618
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -20
- package/dist/index.mjs.map +1 -1
- package/dist/v4/schema.json +4 -0
- package/package.json +5 -5
- package/src/v4/schema.json +4 -0
package/dist/index.mjs
CHANGED
|
@@ -801,6 +801,19 @@ var toArray = (value) => {
|
|
|
801
801
|
if (value == null) return void 0;
|
|
802
802
|
return Array.isArray(value) ? value : [value];
|
|
803
803
|
};
|
|
804
|
+
var runtimeStreamsByDefault = (runtime) => runtime == null || runtime.startsWith("node-") || runtime.startsWith("bun-");
|
|
805
|
+
var normalizeRouteDestination = (destination) => {
|
|
806
|
+
const [withoutHash] = destination.split("#", 1);
|
|
807
|
+
const [withoutQuery] = withoutHash.split("?", 1);
|
|
808
|
+
return withoutQuery.replace(/^\/+/, "");
|
|
809
|
+
};
|
|
810
|
+
var destinationMatchesEntrypoint = (destination, entrypointPath) => {
|
|
811
|
+
const normalizedDestination = normalizeRouteDestination(destination);
|
|
812
|
+
if (normalizedDestination === entrypointPath) return true;
|
|
813
|
+
if (!normalizedDestination.includes("$")) return false;
|
|
814
|
+
const pattern = normalizedDestination.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/\\\$[\w]+/g, ".+");
|
|
815
|
+
return new RegExp(`^${pattern}$`).test(entrypointPath);
|
|
816
|
+
};
|
|
804
817
|
var matchesPattern = (path2, pattern) => {
|
|
805
818
|
if (minimatch(path2, pattern)) return true;
|
|
806
819
|
try {
|
|
@@ -819,10 +832,12 @@ var getFunctionSettings = (path2, config) => {
|
|
|
819
832
|
}
|
|
820
833
|
return settings;
|
|
821
834
|
};
|
|
822
|
-
var resolveRouteHandler = (destination, redirect) => {
|
|
835
|
+
var resolveRouteHandler = (destination, redirect, entrypoints = []) => {
|
|
823
836
|
const isExternal = destination.toLowerCase().startsWith("http://") || destination.toLowerCase().startsWith("https://");
|
|
824
837
|
if (redirect === true) return "HTTP_REDIRECT";
|
|
825
|
-
|
|
838
|
+
if (isExternal) return "HTTP_PROXY";
|
|
839
|
+
const matchingEntrypoints = entrypoints.filter((item) => destinationMatchesEntrypoint(destination, item.path));
|
|
840
|
+
return matchingEntrypoints.length > 0 && matchingEntrypoints.every((entrypoint) => entrypoint.streaming === true) ? "SERVERLESS_FUNCTION_STREAMING" : "SERVERLESS_FUNCTION";
|
|
826
841
|
};
|
|
827
842
|
var isRegion = (r) => AVAILABLE_REGIONS.includes(r);
|
|
828
843
|
var resolveRegions = (configRegions) => {
|
|
@@ -830,10 +845,10 @@ var resolveRegions = (configRegions) => {
|
|
|
830
845
|
const valid = configRegions?.filter(isRegion);
|
|
831
846
|
return valid && valid.length > 0 ? valid : AVAILABLE_REGIONS;
|
|
832
847
|
};
|
|
833
|
-
var mapRoute = (route) => ({
|
|
848
|
+
var mapRoute = (route, entrypoints) => ({
|
|
834
849
|
path: route.source,
|
|
835
850
|
destination: route.destination,
|
|
836
|
-
handler: resolveRouteHandler(route.destination, route.redirect),
|
|
851
|
+
handler: resolveRouteHandler(route.destination, route.redirect, entrypoints),
|
|
837
852
|
headers: route.headers ?? {},
|
|
838
853
|
methods: route.methods ?? ["ANY"],
|
|
839
854
|
positiveRequirements: route.has,
|
|
@@ -844,9 +859,8 @@ var parseEntrypoints = Effect10.fn("parseEntrypoints")(function* (config, projec
|
|
|
844
859
|
const entrypoints = [];
|
|
845
860
|
if (config.functions == null) return entrypoints;
|
|
846
861
|
for (const [fnPath, func] of Object.entries(config.functions)) {
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
yield* new FunctionConfigError({
|
|
862
|
+
if (getFunctionSettings(fnPath, config) == null) {
|
|
863
|
+
return yield* new FunctionConfigError({
|
|
850
864
|
message: `Settings invalid for function at path '${fnPath}'`,
|
|
851
865
|
functionPath: fnPath
|
|
852
866
|
});
|
|
@@ -861,14 +875,23 @@ var parseEntrypoints = Effect10.fn("parseEntrypoints")(function* (config, projec
|
|
|
861
875
|
for (const file of matchedFiles) {
|
|
862
876
|
if (entrypoints.some((ep) => ep.path === file)) continue;
|
|
863
877
|
if (Object.keys(config.functions).some((f) => f === file && f !== fnPath)) continue;
|
|
878
|
+
const settings = getFunctionSettings(file, config);
|
|
879
|
+
if (settings == null) {
|
|
880
|
+
return yield* new FunctionConfigError({
|
|
881
|
+
message: `Settings invalid for function at path '${file}'`,
|
|
882
|
+
functionPath: file
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
const runtime = settings.runtime ?? "node-20";
|
|
886
|
+
const streaming = settings.streaming ?? runtimeStreamsByDefault(runtime);
|
|
864
887
|
entrypoints.push({
|
|
865
888
|
path: file,
|
|
866
|
-
runtime
|
|
889
|
+
runtime,
|
|
867
890
|
memory: settings.memory ?? 128,
|
|
868
891
|
maxDuration: settings.max_duration ?? 30,
|
|
869
892
|
schedule: func.schedule,
|
|
870
893
|
symlinks: func.symlinks,
|
|
871
|
-
streaming
|
|
894
|
+
streaming,
|
|
872
895
|
package: settings.includeFiles != null || settings.excludeFiles != null ? {
|
|
873
896
|
includeFiles: toArray(settings.includeFiles),
|
|
874
897
|
excludeFiles: toArray(settings.excludeFiles)
|
|
@@ -944,7 +967,7 @@ var V4ConfigParser = class extends Effect10.Service()("V4ConfigParser", {
|
|
|
944
967
|
entrypoints,
|
|
945
968
|
errors: [],
|
|
946
969
|
warnings: [],
|
|
947
|
-
routes: (config.routes ?? []).map(mapRoute)
|
|
970
|
+
routes: (config.routes ?? []).map((route) => mapRoute(route, entrypoints))
|
|
948
971
|
};
|
|
949
972
|
})
|
|
950
973
|
})
|
|
@@ -1144,7 +1167,7 @@ var VercelBuildOutputParser = class extends Effect12.Service()("VercelBuildOutpu
|
|
|
1144
1167
|
Object.assign(environmentVariables, env);
|
|
1145
1168
|
}
|
|
1146
1169
|
}
|
|
1147
|
-
const streaming =
|
|
1170
|
+
const streaming = functionConfig.supportsResponseStreaming ?? functionConfig.experimentalResponseStreaming ?? runtime.startsWith("node-");
|
|
1148
1171
|
let filePathMap = {};
|
|
1149
1172
|
for (const [key, value] of Object.entries(configFilePathMap)) {
|
|
1150
1173
|
filePathMap[pathService.join(projectFolder, key)] = value;
|
|
@@ -1175,15 +1198,13 @@ var VercelBuildOutputParser = class extends Effect12.Service()("VercelBuildOutpu
|
|
|
1175
1198
|
destination: functionEntrypointPath,
|
|
1176
1199
|
handler: handlerType
|
|
1177
1200
|
};
|
|
1178
|
-
const configRoutes = config.routes?.filter((r) => "dest" in r && r.dest === `/${functionName}`).map(
|
|
1179
|
-
(r)
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
})
|
|
1186
|
-
) ?? [];
|
|
1201
|
+
const configRoutes = config.routes?.filter((r) => "dest" in r && r.dest === `/${functionName}`).map((r) => ({
|
|
1202
|
+
path: ("src" in r ? r.src : void 0) ?? `/${functionName}`,
|
|
1203
|
+
methods: ["ANY"],
|
|
1204
|
+
headers: {},
|
|
1205
|
+
destination: functionEntrypointPath,
|
|
1206
|
+
handler: handlerType
|
|
1207
|
+
})) ?? [];
|
|
1187
1208
|
if (!result.routes) {
|
|
1188
1209
|
result.routes = [];
|
|
1189
1210
|
}
|
|
@@ -1280,6 +1301,10 @@ var schema_default = {
|
|
|
1280
1301
|
$ref: "#/$defs/runtimes",
|
|
1281
1302
|
description: "The runtime to use for the function."
|
|
1282
1303
|
},
|
|
1304
|
+
streaming: {
|
|
1305
|
+
type: "boolean",
|
|
1306
|
+
description: "Enable function response streaming. When omitted, Node and Bun runtimes stream by default."
|
|
1307
|
+
},
|
|
1283
1308
|
schedule: {
|
|
1284
1309
|
type: "string",
|
|
1285
1310
|
description: "An expression to schedule the function to run at specific times.",
|