@gigadrive/network-config 4.6.0 → 4.6.1

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.mjs CHANGED
@@ -454,38 +454,60 @@ var ImagePolicySchema = Schema3.mutable(
454
454
  variants: Schema3.mutable(Schema3.Record({ key: Schema3.String, value: ImageVariantSchema }))
455
455
  })
456
456
  );
457
- var GigadriveNextPrerenderOutputSchema = Schema3.mutable(
458
- Schema3.Struct({
459
- id: Schema3.String,
460
- type: Schema3.Literal("PRERENDER"),
461
- pathname: UrlPathnameSchema,
462
- parentOutputId: Schema3.String,
463
- groupId: Schema3.Number,
464
- pprChain: Schema3.optional(Schema3.mutable(Schema3.Struct({ headers: HttpSingleValueHeadersSchema }))),
465
- parentFallbackMode: Schema3.optional(JsonValueSchema),
466
- fallback: Schema3.optional(
467
- Schema3.mutable(
468
- Schema3.Struct({
469
- filePath: Schema3.optional(PortableRelativePathSchema),
470
- initialStatus: Schema3.optional(Schema3.Int.pipe(Schema3.between(100, 599))),
471
- initialHeaders: Schema3.optional(HttpHeadersSchema),
472
- initialExpiration: Schema3.optional(Schema3.Number),
473
- initialRevalidate: Schema3.optional(Schema3.Union(Schema3.Number, Schema3.Literal(false))),
474
- postponedState: Schema3.optional(Schema3.String)
475
- })
476
- )
477
- ),
478
- config: Schema3.mutable(
457
+ var GigadriveNextPrerenderOutputFields = {
458
+ id: Schema3.String,
459
+ type: Schema3.Literal("PRERENDER"),
460
+ pathname: UrlPathnameSchema,
461
+ route: Schema3.optional(UrlPathnameSchema),
462
+ parentOutputId: Schema3.String,
463
+ groupId: Schema3.Number,
464
+ pprChain: Schema3.optional(Schema3.mutable(Schema3.Struct({ headers: HttpSingleValueHeadersSchema }))),
465
+ parentFallbackMode: Schema3.optional(JsonValueSchema),
466
+ fallback: Schema3.optional(
467
+ Schema3.mutable(
479
468
  Schema3.Struct({
480
- allowQuery: Schema3.optional(StringArraySchema),
481
- allowHeader: Schema3.optional(StringArraySchema),
482
- bypassFor: Schema3.optional(Schema3.mutable(Schema3.Array(JsonValueSchema))),
483
- renderingMode: Schema3.optional(Schema3.String),
484
- partialFallback: Schema3.optional(Schema3.Boolean),
485
- bypassToken: Schema3.optional(Schema3.String)
469
+ filePath: Schema3.optional(PortableRelativePathSchema),
470
+ initialStatus: Schema3.optional(Schema3.Int.pipe(Schema3.between(100, 599))),
471
+ initialHeaders: Schema3.optional(HttpHeadersSchema),
472
+ initialExpiration: Schema3.optional(Schema3.Number),
473
+ initialRevalidate: Schema3.optional(Schema3.Union(Schema3.Number, Schema3.Literal(false))),
474
+ postponedState: Schema3.optional(Schema3.String)
486
475
  })
487
476
  )
488
- })
477
+ ),
478
+ config: Schema3.mutable(
479
+ Schema3.Struct({
480
+ allowQuery: Schema3.optional(StringArraySchema),
481
+ allowHeader: Schema3.optional(StringArraySchema),
482
+ bypassFor: Schema3.optional(Schema3.mutable(Schema3.Array(JsonValueSchema))),
483
+ renderingMode: Schema3.optional(Schema3.String),
484
+ partialFallback: Schema3.optional(Schema3.Boolean),
485
+ bypassToken: Schema3.optional(Schema3.String)
486
+ })
487
+ )
488
+ };
489
+ var GigadriveNextPrerenderClassificationSchema = Schema3.Struct({
490
+ routeType: Schema3.Literal("route", "fallback", "shell", "page"),
491
+ response: Schema3.Literal("empty", "initial", "complete"),
492
+ compute: Schema3.Literal("blocking", "resuming", "static"),
493
+ htmlSize: Schema3.optional(Schema3.Number)
494
+ });
495
+ var GigadriveNextPrerenderWithoutClassificationSchema = Schema3.Struct({
496
+ routeType: Schema3.optional(Schema3.Never),
497
+ response: Schema3.optional(Schema3.Never),
498
+ compute: Schema3.optional(Schema3.Never),
499
+ htmlSize: Schema3.optional(Schema3.Never)
500
+ });
501
+ var GigadriveNextPrerenderOutputSchema = Schema3.Union(
502
+ Schema3.mutable(
503
+ Schema3.Struct({ ...GigadriveNextPrerenderOutputFields, ...GigadriveNextPrerenderClassificationSchema.fields })
504
+ ),
505
+ Schema3.mutable(
506
+ Schema3.Struct({
507
+ ...GigadriveNextPrerenderOutputFields,
508
+ ...GigadriveNextPrerenderWithoutClassificationSchema.fields
509
+ })
510
+ )
489
511
  );
490
512
  var GigadriveNextStaticAssetPrefixSchema = Schema3.mutable(
491
513
  Schema3.Struct({
@@ -494,6 +516,43 @@ var GigadriveNextStaticAssetPrefixSchema = Schema3.mutable(
494
516
  immutable: Schema3.Boolean
495
517
  })
496
518
  );
519
+ var GigadriveNextRouteConditionSchema = Schema3.Union(
520
+ Schema3.mutable(
521
+ Schema3.Struct({
522
+ type: Schema3.Literal("header", "cookie", "query"),
523
+ key: Schema3.String,
524
+ value: Schema3.optional(Schema3.String)
525
+ })
526
+ ),
527
+ Schema3.mutable(
528
+ Schema3.Struct({
529
+ type: Schema3.Literal("host"),
530
+ value: Schema3.String
531
+ })
532
+ )
533
+ );
534
+ var GigadriveNextMiddlewareMatcherSchema = Schema3.mutable(
535
+ Schema3.Struct({
536
+ source: Schema3.String,
537
+ sourceRegex: Schema3.String,
538
+ has: Schema3.optional(Schema3.mutable(Schema3.Array(GigadriveNextRouteConditionSchema))),
539
+ missing: Schema3.optional(Schema3.mutable(Schema3.Array(GigadriveNextRouteConditionSchema)))
540
+ })
541
+ );
542
+ var GigadriveNextMiddlewareDescriptorSchema = Schema3.Union(
543
+ Schema3.mutable(
544
+ Schema3.Struct({
545
+ present: Schema3.Literal(true),
546
+ matchers: Schema3.mutable(Schema3.Array(GigadriveNextMiddlewareMatcherSchema))
547
+ })
548
+ ),
549
+ Schema3.mutable(
550
+ Schema3.Struct({
551
+ present: Schema3.Literal(false),
552
+ matchers: Schema3.mutable(Schema3.Tuple())
553
+ })
554
+ )
555
+ );
497
556
  var GigadriveNextServerDescriptorSchema = Schema3.mutable(
498
557
  Schema3.Struct({
499
558
  maxDuration: Schema3.optional(Schema3.Number),
@@ -504,6 +563,9 @@ var GigadriveNextServerDescriptorSchema = Schema3.mutable(
504
563
  var PrerenderArraySchema = Schema3.mutable(Schema3.Array(GigadriveNextPrerenderOutputSchema));
505
564
  var StaticAssetArraySchema = Schema3.mutable(Schema3.Array(GigadriveNextStaticAssetPrefixSchema));
506
565
  var JsonValueArraySchema = Schema3.mutable(Schema3.Array(JsonValueSchema));
566
+ var GigadriveNextPrerenderSeedMethodsSchema = Schema3.mutable(
567
+ Schema3.Tuple(Schema3.Literal("GET"), Schema3.Literal("HEAD"))
568
+ );
507
569
  var GigadriveNextBuildManifestV1Schema = Schema3.mutable(
508
570
  Schema3.Struct({
509
571
  version: Schema3.Literal(1),
@@ -560,7 +622,8 @@ var GigadriveNextBuildManifestV2StandaloneSchema = Schema3.mutable(
560
622
  prerenderManifest: Schema3.optional(PortableRelativePathSchema),
561
623
  assetManifest: Schema3.optional(PortableRelativePathSchema),
562
624
  entryPagePaths: Schema3.optional(Schema3.mutable(Schema3.Array(UrlPathnameSchema))),
563
- staticAssets: StaticAssetArraySchema
625
+ staticAssets: StaticAssetArraySchema,
626
+ middleware: Schema3.optional(GigadriveNextMiddlewareDescriptorSchema)
564
627
  })
565
628
  )
566
629
  })
@@ -573,6 +636,7 @@ var GigadriveNextBuildManifestSchema = Schema3.Union(
573
636
  var GigadriveNextPrerenderManifestV1Schema = Schema3.mutable(
574
637
  Schema3.Struct({
575
638
  version: Schema3.Literal(1),
639
+ seedMethods: Schema3.optional(GigadriveNextPrerenderSeedMethodsSchema),
576
640
  prerenders: PrerenderArraySchema
577
641
  })
578
642
  );
@@ -1438,9 +1502,51 @@ var SchemaValidator = class extends Effect14.Service()("SchemaValidator", {
1438
1502
 
1439
1503
  // src/services/v4-config-parser.ts
1440
1504
  import { FileSystem as FileSystem10, Path as Path8 } from "@effect/platform";
1441
- import { getFilesForPattern } from "@gigadrive/build-utils";
1442
- import { Effect as Effect15 } from "effect";
1505
+
1506
+ // ../build-utils/src/get-files-for-pattern.ts
1443
1507
  import { minimatch } from "minimatch";
1508
+ import { readdir } from "fs/promises";
1509
+ var getFilesForPattern = async (pattern, projectFolder, excludeFiles = []) => {
1510
+ const files = [];
1511
+ const filesInFolder = await readdir(projectFolder, { recursive: true });
1512
+ const exactFiles = new Set(filesInFolder.filter((file) => typeof file === "string"));
1513
+ let regex = null;
1514
+ if (!exactFiles.has(pattern)) {
1515
+ try {
1516
+ regex = new RegExp(`^(?:${pattern})$`);
1517
+ } catch {
1518
+ }
1519
+ }
1520
+ const finalExclusions = Array.isArray(excludeFiles) ? excludeFiles : [excludeFiles];
1521
+ for (const file of filesInFolder) {
1522
+ if (typeof file !== "string") {
1523
+ continue;
1524
+ }
1525
+ if (finalExclusions.some((excludeFile) => {
1526
+ if (minimatch(file, excludeFile)) {
1527
+ return true;
1528
+ }
1529
+ if (!exactFiles.has(excludeFile)) {
1530
+ try {
1531
+ return new RegExp(`^(?:${excludeFile})$`).test(file);
1532
+ } catch {
1533
+ return false;
1534
+ }
1535
+ }
1536
+ return false;
1537
+ })) {
1538
+ continue;
1539
+ }
1540
+ if (minimatch(file, pattern) || regex != null && regex.test(file)) {
1541
+ files.push(file);
1542
+ }
1543
+ }
1544
+ return files;
1545
+ };
1546
+
1547
+ // src/services/v4-config-parser.ts
1548
+ import { Effect as Effect15 } from "effect";
1549
+ import { minimatch as minimatch2 } from "minimatch";
1444
1550
  import safeRegex from "safe-regex2";
1445
1551
  var MAX_ASSET_DEPTH = 100;
1446
1552
  var DISALLOWED_ASSET_EXTENSIONS = [".htaccess", ".htpasswd"];
@@ -1505,7 +1611,7 @@ var destinationMatchesEntrypoint = (destination, entrypointPath) => {
1505
1611
  return new RegExp(`^${pattern}$`).test(entrypointPath);
1506
1612
  };
1507
1613
  var matchesPattern = (path2, pattern) => {
1508
- if (minimatch(path2, pattern)) return true;
1614
+ if (minimatch2(path2, pattern)) return true;
1509
1615
  try {
1510
1616
  if (safeRegex(pattern)) {
1511
1617
  return new RegExp(pattern).test(path2);
@@ -1668,8 +1774,34 @@ var V4ConfigParser = class extends Effect15.Service()("V4ConfigParser", {
1668
1774
 
1669
1775
  // src/services/vercel-build-output-parser.ts
1670
1776
  import { Path as Path9 } from "@effect/platform";
1671
- import { getFilesForPattern as getFilesForPattern2 } from "@gigadrive/build-utils";
1672
- import { deepMerge } from "@gigadrive/commons";
1777
+
1778
+ // ../commons/src/deep-merge.ts
1779
+ var deepMerge = (target, ...partials) => {
1780
+ const isObject = (item) => item !== null && typeof item === "object";
1781
+ if (!isObject(target)) {
1782
+ return target;
1783
+ }
1784
+ for (const partial of partials) {
1785
+ if (!isObject(partial)) {
1786
+ continue;
1787
+ }
1788
+ Object.keys(partial).forEach((key) => {
1789
+ if (key === "__proto__" || key === "constructor") return;
1790
+ const targetValue = target[key];
1791
+ const sourceValue = partial[key];
1792
+ if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
1793
+ targetValue.push(...sourceValue);
1794
+ } else if (isObject(targetValue) && isObject(sourceValue)) {
1795
+ deepMerge(targetValue, sourceValue);
1796
+ } else {
1797
+ target[key] = sourceValue;
1798
+ }
1799
+ });
1800
+ }
1801
+ return target;
1802
+ };
1803
+
1804
+ // src/services/vercel-build-output-parser.ts
1673
1805
  import { Effect as Effect16 } from "effect";
1674
1806
 
1675
1807
  // src/build-output-v3/determine-repo-root.ts
@@ -1784,7 +1916,7 @@ var VercelBuildOutputParser = class extends Effect16.Service()("VercelBuildOutpu
1784
1916
  });
1785
1917
  const loadFunctions = Effect16.fn("VercelBuildOutputParser.loadFunctions")(function* (config, parseResult, projectFolder) {
1786
1918
  const functionConfigs = yield* Effect16.tryPromise({
1787
- try: () => getFilesForPattern2(FUNCTION_CONFIGS_PATTERN, projectFolder),
1919
+ try: () => getFilesForPattern(FUNCTION_CONFIGS_PATTERN, projectFolder),
1788
1920
  catch: (error) => new ConfigFileParseError({
1789
1921
  message: `Failed to scan for function configs: ${error instanceof Error ? error.message : String(error)}`,
1790
1922
  filePath: projectFolder
@@ -2464,8 +2596,12 @@ export {
2464
2596
  GigadriveNextBuildManifestV1Schema,
2465
2597
  GigadriveNextBuildManifestV2ExportSchema,
2466
2598
  GigadriveNextBuildManifestV2StandaloneSchema,
2599
+ GigadriveNextMiddlewareDescriptorSchema,
2600
+ GigadriveNextMiddlewareMatcherSchema,
2467
2601
  GigadriveNextPrerenderManifestV1Schema,
2468
2602
  GigadriveNextPrerenderOutputSchema,
2603
+ GigadriveNextPrerenderSeedMethodsSchema,
2604
+ GigadriveNextRouteConditionSchema,
2469
2605
  GigadriveNextServerDescriptorSchema,
2470
2606
  GigadriveNextStaticAssetPrefixSchema,
2471
2607
  MAX_FUNCTION_DURATION_SECONDS,