@gigadrive/network-config 4.5.0 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Schema, Effect, Layer } from 'effect';
2
- import { FileSystem, Path } from '@effect/platform';
3
- import * as _effect_platform_Path from '@effect/platform/Path';
4
2
  import * as _effect_platform_FileSystem from '@effect/platform/FileSystem';
3
+ import * as _effect_platform_Path from '@effect/platform/Path';
4
+ import * as effect_Layer from 'effect/Layer';
5
+ import { Path, FileSystem } from '@effect/platform';
5
6
 
6
7
  declare const StaticAssetHeadersSchema: Schema.filter<Schema.mutable<Schema.Record$<typeof Schema.String, Schema.Union<[Schema.filter<typeof Schema.String>, Schema.mutable<Schema.Array$<Schema.filter<typeof Schema.String>>>]>>>>;
7
8
  type StaticAssetHeaders = Schema.Schema.Type<typeof StaticAssetHeadersSchema>;
@@ -582,194 +583,6 @@ type NormalizedConfigRouteMatchRequirements = [] | [
582
583
  }
583
584
  ];
584
585
 
585
- declare const ManifestNotFoundError_base: Schema.TaggedErrorClass<ManifestNotFoundError, "ManifestNotFoundError", {
586
- readonly _tag: Schema.tag<"ManifestNotFoundError">;
587
- } & {
588
- message: typeof Schema.String;
589
- filePath: typeof Schema.String;
590
- }>;
591
- declare class ManifestNotFoundError extends ManifestNotFoundError_base {
592
- }
593
- declare const ManifestReadError_base: Schema.TaggedErrorClass<ManifestReadError, "ManifestReadError", {
594
- readonly _tag: Schema.tag<"ManifestReadError">;
595
- } & {
596
- message: typeof Schema.String;
597
- filePath: typeof Schema.String;
598
- }>;
599
- declare class ManifestReadError extends ManifestReadError_base {
600
- }
601
- declare const ManifestParseError_base: Schema.TaggedErrorClass<ManifestParseError, "ManifestParseError", {
602
- readonly _tag: Schema.tag<"ManifestParseError">;
603
- } & {
604
- message: typeof Schema.String;
605
- filePath: typeof Schema.String;
606
- }>;
607
- declare class ManifestParseError extends ManifestParseError_base {
608
- }
609
- declare const FrameworkNotDetectedError_base: Schema.TaggedErrorClass<FrameworkNotDetectedError, "FrameworkNotDetectedError", {
610
- readonly _tag: Schema.tag<"FrameworkNotDetectedError">;
611
- } & {
612
- message: typeof Schema.String;
613
- directory: typeof Schema.String;
614
- }>;
615
- declare class FrameworkNotDetectedError extends FrameworkNotDetectedError_base {
616
- }
617
- interface FrameworkDetectionItem {
618
- /** Check manifest dependencies for this package (routed by framework language) */
619
- matchPackage?: string;
620
- /** Check if this file exists (relative to project root) */
621
- path?: string;
622
- /** If path is set, also check file content matches this regex */
623
- matchContent?: string;
624
- }
625
- type FrameworkLanguage = 'node' | 'php';
626
- type PackageManager = 'npm' | 'yarn' | 'pnpm' | 'bun' | 'composer';
627
- interface FrameworkDefinition {
628
- slug: string;
629
- name: string;
630
- language: FrameworkLanguage;
631
- /** ALL items must match for the framework to be detected */
632
- detectors: FrameworkDetectionItem[];
633
- /** Higher = higher priority (specific frameworks beat generic ones) */
634
- priority: number;
635
- /** Generates deployment defaults for this framework */
636
- getDefaultConfig: (packageManager: PackageManager) => FrameworkDefaultConfig;
637
- /** Refines defaults with project files after a framework match, e.g. framework CLI config. */
638
- refineDefaultConfig?: (defaults: FrameworkDefaultConfig, projectFolder: string) => Effect.Effect<FrameworkDefaultConfig, never, FileSystem.FileSystem | Path.Path>;
639
- }
640
- interface FrameworkDefaultConfig {
641
- runtime: Runtime;
642
- memory: number;
643
- maxDuration: number;
644
- streaming: boolean;
645
- /** Overrides the auto-generated install command (e.g. for custom composer flags) */
646
- installCommand?: string;
647
- /** Build commands (install command is auto-prepended by generateConfig) */
648
- commands: string[];
649
- entrypoint?: string;
650
- assetsDir?: string;
651
- assetsPrefixToStrip?: string;
652
- /** Explicit project-relative files to publish as static assets. */
653
- assetPaths?: string[];
654
- /** Public path overrides keyed by project-relative asset path. */
655
- assetOverrides?: Record<string, {
656
- path?: string;
657
- contentType?: string;
658
- }>;
659
- /** Directory subtrees to publish under a URL prefix without per-file enumeration. */
660
- assetPrefixes?: Array<{
661
- source: string;
662
- destination: string;
663
- immutable?: boolean;
664
- populateCache?: boolean;
665
- contentType?: string;
666
- }>;
667
- /** Project-relative manifests containing logical static asset entries. */
668
- assetManifests?: Array<{
669
- source: string;
670
- }>;
671
- populateAssetCache?: boolean;
672
- routes: Array<{
673
- source: string;
674
- destination: string;
675
- }>;
676
- environmentVariables: Record<string, string>;
677
- symlinks?: Record<string, string>;
678
- excludeFiles?: string[];
679
- package?: {
680
- trace?: boolean;
681
- includeProjectFiles?: boolean;
682
- preserveSymlinks?: boolean;
683
- rootOverwrite?: string;
684
- filePathMap?: Record<string, string>;
685
- includeFiles?: string[];
686
- excludeFiles?: string[];
687
- };
688
- /** Advanced framework output that replaces the one-entrypoint defaults. */
689
- normalizedConfig?: Partial<NormalizedConfig>;
690
- }
691
- interface DetectionResult {
692
- framework: FrameworkDefinition;
693
- packageManager: PackageManager;
694
- config: NormalizedConfig;
695
- }
696
-
697
- /**
698
- * Detects the framework used in a project by checking framework definitions
699
- * against the project's dependencies and file structure.
700
- *
701
- * Framework definitions are checked in priority order (highest first).
702
- * All detectors for a framework must match for it to be selected.
703
- *
704
- * @param projectFolder - Absolute path to the project root
705
- * @returns DetectionResult with framework, package manager, and generated config
706
- */
707
- declare const detectFramework: (projectFolder: string) => Effect.Effect<{
708
- framework: FrameworkDefinition;
709
- packageManager: PackageManager;
710
- config: NormalizedConfig;
711
- }, ManifestReadError | ManifestParseError | FrameworkNotDetectedError, FileSystem.FileSystem | Path.Path>;
712
-
713
- /**
714
- * Detects the package manager by checking for lockfiles in the project folder.
715
- * Falls back to `npm` if no lockfile is found.
716
- *
717
- * @param projectFolder - Absolute path to the project root
718
- * @returns The detected package manager
719
- */
720
- declare const detectPackageManager: (projectFolder: string) => Effect.Effect<PackageManager, never, FileSystem.FileSystem | Path.Path>;
721
-
722
- /**
723
- * All supported framework definitions, sorted by priority descending.
724
- * Higher priority frameworks are checked first during detection.
725
- */
726
- declare const FRAMEWORK_DEFINITIONS: FrameworkDefinition[];
727
-
728
- /**
729
- * Generates a NormalizedConfig from a framework definition and detected package manager.
730
- * Prepends the install command and builds a complete deployment configuration.
731
- *
732
- * @param framework - The detected framework definition
733
- * @param packageManager - The detected package manager
734
- * @returns A complete NormalizedConfig with framework defaults
735
- */
736
- declare const generateConfig: (framework: FrameworkDefinition, packageManager: PackageManager, refinedDefaults?: FrameworkDefaultConfig | undefined) => Effect.Effect<NormalizedConfig, never, never>;
737
-
738
- /**
739
- * Merges framework defaults with a user-provided config.
740
- * User config always takes precedence; framework defaults fill gaps.
741
- *
742
- * - commands: use user's if non-empty, otherwise framework's
743
- * - entrypoints: use user's if non-empty, otherwise framework's
744
- * - routes: use user's if non-empty, otherwise framework's
745
- * - assets: use user's if it declares any sources, otherwise framework's
746
- * - excludeFiles: use user's if non-empty, otherwise framework's
747
- * - regions: always use user's (always populated from parsing)
748
- * - environmentVariables: deep merge (framework base, user overrides)
749
- * - services: always use user's (frameworks don't define services)
750
- * - warnings/errors: concatenate both
751
- *
752
- * @param userConfig - The config parsed from the user's config file
753
- * @param frameworkConfig - The config generated from framework detection
754
- * @returns The merged config
755
- */
756
- declare const mergeWithFrameworkDefaults: (userConfig: NormalizedConfig, frameworkConfig: NormalizedConfig) => Effect.Effect<NormalizedConfig, never, never>;
757
-
758
- /**
759
- * Reads dependency names from the appropriate manifest file for a language.
760
- * Returns a set of all dependency names (production + dev).
761
- *
762
- * If the manifest file does not exist, returns an empty set (graceful).
763
- * If the file exists but cannot be read (`ManifestReadError`) or parsed
764
- * (`ManifestParseError`), the error propagates — this indicates a real
765
- * problem the user should know about.
766
- *
767
- * @param projectFolder - Absolute path to the project root
768
- * @param language - The framework language to determine which manifest to read
769
- * @returns A set of dependency package names
770
- */
771
- declare const readDependencies: (projectFolder: string, language: FrameworkLanguage) => Effect.Effect<Set<string>, ManifestReadError | ManifestParseError, FileSystem.FileSystem | Path.Path>;
772
-
773
586
  declare const ConfigFileNotFoundError_base: Schema.TaggedErrorClass<ConfigFileNotFoundError, "ConfigFileNotFoundError", {
774
587
  readonly _tag: Schema.tag<"ConfigFileNotFoundError">;
775
588
  } & {
@@ -795,6 +608,15 @@ declare const ConfigFileParseError_base: Schema.TaggedErrorClass<ConfigFileParse
795
608
  }>;
796
609
  declare class ConfigFileParseError extends ConfigFileParseError_base {
797
610
  }
611
+ declare const ConfigModuleLoadError_base: Schema.TaggedErrorClass<ConfigModuleLoadError, "ConfigModuleLoadError", {
612
+ readonly _tag: Schema.tag<"ConfigModuleLoadError">;
613
+ } & {
614
+ message: typeof Schema.String;
615
+ filePath: typeof Schema.String;
616
+ cause: Schema.optional<typeof Schema.String>;
617
+ }>;
618
+ declare class ConfigModuleLoadError extends ConfigModuleLoadError_base {
619
+ }
798
620
  declare const ConfigVersionError_base: Schema.TaggedErrorClass<ConfigVersionError, "ConfigVersionError", {
799
621
  readonly _tag: Schema.tag<"ConfigVersionError">;
800
622
  } & {
@@ -822,23 +644,24 @@ declare const FunctionConfigError_base: Schema.TaggedErrorClass<FunctionConfigEr
822
644
  declare class FunctionConfigError extends FunctionConfigError_base {
823
645
  }
824
646
 
825
- /**
826
- * Ensure a normalized config has no function files that are also defined as assets.
827
- * For example, a file `public/index.php` should not be defined as an asset, when it is a function and `public` is an asset folder.
828
- * @param config The normalized config to filter.
829
- * @returns A promise that resolves to the filtered config.
830
- */
831
- declare const filterFunctionsFromAssets: (config: NormalizedConfig) => NormalizedConfig;
647
+ declare const ConfigModuleLoader_base: Effect.Service.Class<ConfigModuleLoader, "ConfigModuleLoader", {
648
+ readonly effect: Effect.Effect<{
649
+ loadConfigModule: (filePath: string) => Effect.Effect<Record<string, unknown>, ConfigModuleLoadError, never>;
650
+ }, never, never>;
651
+ }>;
652
+ declare class ConfigModuleLoader extends ConfigModuleLoader_base {
653
+ }
832
654
 
833
- declare const ALLOWED_CONFIG_NAMES: readonly ["gigadrive.yaml", "gigadrive.yml", "nebula.yaml", "nebula.yml", "nebula.json"];
655
+ declare const ALLOWED_CONFIG_NAMES: readonly ["gigadrive.ts", "gigadrive.mts", "gigadrive.cts", "gigadrive.js", "gigadrive.mjs", "gigadrive.cjs", "gigadrive.yaml", "gigadrive.yml", "gigadrive.json", "nebula.yaml", "nebula.yml", "nebula.json"];
834
656
  declare const RawConfigReader_base: Effect.Service.Class<RawConfigReader, "RawConfigReader", {
657
+ readonly dependencies: readonly [effect_Layer.Layer<ConfigModuleLoader, never, never>];
835
658
  readonly effect: Effect.Effect<{
836
659
  findConfig: (projectFolder: string) => Effect.Effect<string | null, never, never>;
837
660
  readRawConfig: (filePath: string, options?: {
838
661
  disableVersionCheck?: boolean;
839
- } | undefined) => Effect.Effect<Record<string, unknown>, ConfigFileNotFoundError | ConfigFileEmptyError | ConfigFileParseError | ConfigVersionError, never>;
840
- readConfigFile: <T>(configFilePath: string) => Effect.Effect<T | null, ConfigFileEmptyError | ConfigFileParseError | ConfigVersionError, never>;
841
- }, never, FileSystem.FileSystem | Path.Path>;
662
+ } | undefined) => Effect.Effect<Record<string, unknown>, ConfigFileNotFoundError | ConfigFileEmptyError | ConfigFileParseError | ConfigModuleLoadError | ConfigVersionError, never>;
663
+ readConfigFile: <T>(configFilePath: string) => Effect.Effect<T | null, ConfigFileEmptyError | ConfigFileParseError | ConfigModuleLoadError | ConfigVersionError, never>;
664
+ }, never, ConfigModuleLoader | Path.Path | FileSystem.FileSystem>;
842
665
  }>;
843
666
  declare class RawConfigReader extends RawConfigReader_base {
844
667
  }
@@ -851,46 +674,143 @@ declare const SchemaValidator_base: Effect.Service.Class<SchemaValidator, "Schem
851
674
  declare class SchemaValidator extends SchemaValidator_base {
852
675
  }
853
676
 
854
- interface ConfigV4 extends Config {
855
- version: 4;
856
- /**
857
- * A list of presets to apply to the project. Each preset will be applied in order.
858
- */
859
- presets?: string[] | null;
860
- /**
861
- * The folder which holds the assets to be deployed to the edge. Defaults to none.
862
- */
863
- assets?: string | null;
864
- /**
865
- * If true, the assets will be cached at the edge during deployment. This may increase the deployment time, depending on the size of the assets. Defaults to false.
866
- */
867
- populateAssetCache?: boolean | null;
868
- /** Managed image optimization policy for this deployment. */
869
- images?: Partial<NormalizedImagePolicy> | null;
870
- /**
871
- * The regions to which the project will be deployed. Use "global" to deploy to all regions. More regions will incur higher costs.
872
- */
873
- regions?: string[] | null;
874
- /**
875
- * The commands to run to build the project. For example, `bun install` or `npm install`.
876
- */
877
- build_commands?: string[] | null;
878
- /**
879
- * The serverless functions to deploy.
880
- */
881
- functions?: {
677
+ /**
678
+ * Resolves merged function settings for a given path by iterating all function
679
+ * patterns in the config. Later patterns override earlier ones.
680
+ *
681
+ * @returns The merged settings, or undefined when no pattern matches the path.
682
+ */
683
+ declare const getFunctionSettings: (path: string, config: ConfigV4) => ConfigV4FunctionSettings | undefined;
684
+ declare const V4ConfigParser_base: Effect.Service.Class<V4ConfigParser, "V4ConfigParser", {
685
+ readonly accessors: true;
686
+ readonly effect: Effect.Effect<{
882
687
  /**
883
- * The pattern to match the file path of the function. May be a glob pattern or a regular expression.
688
+ * Parses a ConfigV4 into a NormalizedConfig.
689
+ *
690
+ * @param config - The raw V4 config object
691
+ * @param projectFolder - Absolute path to the project root
884
692
  */
885
- [pattern: string]: ConfigV4FunctionSettings;
886
- } | null;
887
- /**
888
- * A list of route definitions.
889
- *
890
- * @maxItems 1024
891
- */
892
- routes?: {
893
- /**
693
+ parse: (config: ConfigV4, projectFolder: string) => Effect.Effect<{
694
+ regions: ("us-east-1" | "us-east-2" | "us-west-1" | "us-west-2" | "ap-south-1" | "ap-northeast-3" | "ap-northeast-2" | "ap-southeast-1" | "ap-southeast-2" | "ap-northeast-1" | "ca-central-1" | "eu-central-1" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-north-1" | "sa-east-1")[];
695
+ assets: {
696
+ paths: string[];
697
+ prefixToStrip: string;
698
+ dynamicRoutes: boolean;
699
+ populateCache: boolean;
700
+ };
701
+ environmentVariables: Record<string, string>;
702
+ commands: string[];
703
+ images: NormalizedImagePolicy | undefined;
704
+ services: NormalizedConfigServiceDefinition[] | undefined;
705
+ entrypoints: NormalizedConfigEntrypoint[];
706
+ errors: never[];
707
+ warnings: never[];
708
+ routes: NormalizedConfigRoute[];
709
+ }, FunctionConfigError, Path.Path | FileSystem.FileSystem>;
710
+ }, never, never>;
711
+ }>;
712
+ declare class V4ConfigParser extends V4ConfigParser_base {
713
+ }
714
+
715
+ declare const VercelBuildOutputParser_base: Effect.Service.Class<VercelBuildOutputParser, "VercelBuildOutputParser", {
716
+ readonly effect: Effect.Effect<{
717
+ parse: (parseResult: NormalizedConfig, projectFolder: string) => Effect.Effect<NormalizedConfig, ConfigFileEmptyError | ConfigFileParseError | ConfigModuleLoadError | ConfigVersionError, Path.Path | _effect_platform_FileSystem.FileSystem>;
718
+ }, never, RawConfigReader | Path.Path>;
719
+ }>;
720
+ declare class VercelBuildOutputParser extends VercelBuildOutputParser_base {
721
+ }
722
+
723
+ interface Config {
724
+ version: number;
725
+ env?: Record<string, string>;
726
+ }
727
+ /**
728
+ * Parses a config file at the given path and validates it against the appropriate
729
+ * JSON Schema, returning a NormalizedConfig **without** post-processing.
730
+ *
731
+ * Use {@link parseConfig} when you also want Vercel BOv3 merging, empty-deployment
732
+ * checks, and function/asset deduplication applied automatically.
733
+ *
734
+ * @param filePath - Absolute path to the config file
735
+ * @param projectFolder - Absolute path to the project root
736
+ */
737
+ declare const parseConfigRaw: (filePath: string, projectFolder: string) => Effect.Effect<{
738
+ regions: ("us-east-1" | "us-east-2" | "us-west-1" | "us-west-2" | "ap-south-1" | "ap-northeast-3" | "ap-northeast-2" | "ap-southeast-1" | "ap-southeast-2" | "ap-northeast-1" | "ca-central-1" | "eu-central-1" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-north-1" | "sa-east-1")[];
739
+ assets: {
740
+ paths: string[];
741
+ prefixToStrip: string;
742
+ dynamicRoutes: boolean;
743
+ populateCache: boolean;
744
+ };
745
+ environmentVariables: Record<string, string>;
746
+ commands: string[];
747
+ images: NormalizedImagePolicy | undefined;
748
+ services: NormalizedConfigServiceDefinition[] | undefined;
749
+ entrypoints: NormalizedConfigEntrypoint[];
750
+ errors: never[];
751
+ warnings: never[];
752
+ routes: NormalizedConfigRoute[];
753
+ }, ConfigFileNotFoundError | ConfigFileEmptyError | ConfigFileParseError | ConfigModuleLoadError | ConfigVersionError | ConfigSchemaValidationError | FunctionConfigError, RawConfigReader | _effect_platform_Path.Path | _effect_platform_FileSystem.FileSystem | SchemaValidator | V4ConfigParser>;
754
+ /**
755
+ * Parses a config file at the given path, validates it against the appropriate
756
+ * JSON Schema, converts it to a NormalizedConfig, and applies post-processing.
757
+ *
758
+ * @param filePath - Absolute path to the config file
759
+ * @param projectFolder - Absolute path to the project root
760
+ */
761
+ declare const parseConfig: (filePath: string, projectFolder: string) => Effect.Effect<NormalizedConfig, ConfigFileNotFoundError | ConfigFileEmptyError | ConfigFileParseError | ConfigModuleLoadError | ConfigVersionError | ConfigSchemaValidationError | FunctionConfigError, RawConfigReader | _effect_platform_Path.Path | _effect_platform_FileSystem.FileSystem | SchemaValidator | V4ConfigParser | VercelBuildOutputParser>;
762
+ /**
763
+ * Applies post-processing transformers to a NormalizedConfig:
764
+ * - Vercel Build Output v3 (merges functions/routes from .vercel/output if present)
765
+ * - Empty deployment validation
766
+ * - Filter functions from assets
767
+ *
768
+ * @param config - The parsed NormalizedConfig
769
+ * @param projectFolder - Absolute path to the project root
770
+ * @returns The post-processed NormalizedConfig
771
+ */
772
+ declare const postProcessConfig: (config: NormalizedConfig, projectFolder: string) => Effect.Effect<NormalizedConfig, ConfigFileEmptyError | ConfigFileParseError | ConfigModuleLoadError | ConfigVersionError, _effect_platform_Path.Path | _effect_platform_FileSystem.FileSystem | VercelBuildOutputParser>;
773
+
774
+ interface ConfigV4 extends Config {
775
+ version: 4;
776
+ /**
777
+ * A list of presets to apply to the project. Each preset will be applied in order.
778
+ */
779
+ presets?: string[] | null;
780
+ /**
781
+ * The folder which holds the assets to be deployed to the edge. Defaults to none.
782
+ */
783
+ assets?: string | null;
784
+ /**
785
+ * If true, the assets will be cached at the edge during deployment. This may increase the deployment time, depending on the size of the assets. Defaults to false.
786
+ */
787
+ populateAssetCache?: boolean | null;
788
+ /** Managed image optimization policy for this deployment. */
789
+ images?: Partial<NormalizedImagePolicy> | null;
790
+ /**
791
+ * The regions to which the project will be deployed. Use "global" to deploy to all regions. More regions will incur higher costs.
792
+ */
793
+ regions?: string[] | null;
794
+ /**
795
+ * The commands to run to build the project. For example, `bun install` or `npm install`.
796
+ */
797
+ build_commands?: string[] | null;
798
+ /**
799
+ * The serverless functions to deploy.
800
+ */
801
+ functions?: {
802
+ /**
803
+ * The pattern to match the file path of the function. May be a glob pattern or a regular expression.
804
+ */
805
+ [pattern: string]: ConfigV4FunctionSettings;
806
+ } | null;
807
+ /**
808
+ * A list of route definitions.
809
+ *
810
+ * @maxItems 1024
811
+ */
812
+ routes?: {
813
+ /**
894
814
  * A pattern that matches each incoming pathname (excluding querystring).
895
815
  */
896
816
  source: string;
@@ -1054,102 +974,231 @@ interface ConfigV4FunctionSettings {
1054
974
  }
1055
975
 
1056
976
  /**
1057
- * Resolves merged function settings for a given path by iterating all function
1058
- * patterns in the config. Later patterns override earlier ones.
977
+ * Identity helper providing type inference and checking for `gigadrive.ts`
978
+ * config files. Using it is optional — a plain object default export works the
979
+ * same, but `defineConfig` gives editor autocompletion without a type
980
+ * annotation. Requires `@gigadrive/network-config` to be installed in the
981
+ * project (e.g. as a devDependency).
1059
982
  *
1060
- * @returns The merged settings, or undefined when no pattern matches the path.
983
+ * Prefer importing from the `@gigadrive/network-config/define-config` subpath:
984
+ * it is dependency-free, whereas the package root eagerly imports peer
985
+ * dependencies (`effect`, `@effect/platform`) that package managers which do
986
+ * not auto-install peers (e.g. Yarn) will not have installed.
987
+ *
988
+ * Note that a `gigadrive.ts` config is executed as code when the config is
989
+ * read — the same trust model as `build_commands`.
990
+ *
991
+ * @param config - The deployment configuration
992
+ * @returns The configuration, unchanged
993
+ * @example
994
+ * ```ts
995
+ * // gigadrive.ts
996
+ * import { defineConfig } from '@gigadrive/network-config/define-config';
997
+ *
998
+ * export default defineConfig({
999
+ * version: 4,
1000
+ * regions: ['eu-central-1'],
1001
+ * });
1002
+ * ```
1061
1003
  */
1062
- declare const getFunctionSettings: (path: string, config: ConfigV4) => ConfigV4FunctionSettings | undefined;
1063
- declare const V4ConfigParser_base: Effect.Service.Class<V4ConfigParser, "V4ConfigParser", {
1064
- readonly accessors: true;
1065
- readonly effect: Effect.Effect<{
1066
- /**
1067
- * Parses a ConfigV4 into a NormalizedConfig.
1068
- *
1069
- * @param config - The raw V4 config object
1070
- * @param projectFolder - Absolute path to the project root
1071
- */
1072
- parse: (config: ConfigV4, projectFolder: string) => Effect.Effect<{
1073
- regions: ("us-east-1" | "us-east-2" | "us-west-1" | "us-west-2" | "ap-south-1" | "ap-northeast-3" | "ap-northeast-2" | "ap-southeast-1" | "ap-southeast-2" | "ap-northeast-1" | "ca-central-1" | "eu-central-1" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-north-1" | "sa-east-1")[];
1074
- assets: {
1075
- paths: string[];
1076
- prefixToStrip: string;
1077
- dynamicRoutes: boolean;
1078
- populateCache: boolean;
1079
- };
1080
- environmentVariables: Record<string, string>;
1081
- commands: string[];
1082
- images: NormalizedImagePolicy | undefined;
1083
- services: NormalizedConfigServiceDefinition[] | undefined;
1084
- entrypoints: NormalizedConfigEntrypoint[];
1085
- errors: never[];
1086
- warnings: never[];
1087
- routes: NormalizedConfigRoute[];
1088
- }, FunctionConfigError, FileSystem.FileSystem | Path.Path>;
1089
- }, never, never>;
1004
+ declare const defineConfig: (config: ConfigV4) => ConfigV4;
1005
+
1006
+ declare const ManifestNotFoundError_base: Schema.TaggedErrorClass<ManifestNotFoundError, "ManifestNotFoundError", {
1007
+ readonly _tag: Schema.tag<"ManifestNotFoundError">;
1008
+ } & {
1009
+ message: typeof Schema.String;
1010
+ filePath: typeof Schema.String;
1090
1011
  }>;
1091
- declare class V4ConfigParser extends V4ConfigParser_base {
1012
+ declare class ManifestNotFoundError extends ManifestNotFoundError_base {
1092
1013
  }
1093
-
1094
- declare const VercelBuildOutputParser_base: Effect.Service.Class<VercelBuildOutputParser, "VercelBuildOutputParser", {
1095
- readonly effect: Effect.Effect<{
1096
- parse: (parseResult: NormalizedConfig, projectFolder: string) => Effect.Effect<NormalizedConfig, ConfigFileEmptyError | ConfigFileParseError | ConfigVersionError, _effect_platform_FileSystem.FileSystem | Path.Path>;
1097
- }, never, Path.Path | RawConfigReader>;
1014
+ declare const ManifestReadError_base: Schema.TaggedErrorClass<ManifestReadError, "ManifestReadError", {
1015
+ readonly _tag: Schema.tag<"ManifestReadError">;
1016
+ } & {
1017
+ message: typeof Schema.String;
1018
+ filePath: typeof Schema.String;
1098
1019
  }>;
1099
- declare class VercelBuildOutputParser extends VercelBuildOutputParser_base {
1020
+ declare class ManifestReadError extends ManifestReadError_base {
1100
1021
  }
1101
-
1102
- interface Config {
1103
- version: number;
1104
- env?: Record<string, string>;
1022
+ declare const ManifestParseError_base: Schema.TaggedErrorClass<ManifestParseError, "ManifestParseError", {
1023
+ readonly _tag: Schema.tag<"ManifestParseError">;
1024
+ } & {
1025
+ message: typeof Schema.String;
1026
+ filePath: typeof Schema.String;
1027
+ }>;
1028
+ declare class ManifestParseError extends ManifestParseError_base {
1029
+ }
1030
+ declare const FrameworkNotDetectedError_base: Schema.TaggedErrorClass<FrameworkNotDetectedError, "FrameworkNotDetectedError", {
1031
+ readonly _tag: Schema.tag<"FrameworkNotDetectedError">;
1032
+ } & {
1033
+ message: typeof Schema.String;
1034
+ directory: typeof Schema.String;
1035
+ }>;
1036
+ declare class FrameworkNotDetectedError extends FrameworkNotDetectedError_base {
1037
+ }
1038
+ interface FrameworkDetectionItem {
1039
+ /** Check manifest dependencies for this package (routed by framework language) */
1040
+ matchPackage?: string;
1041
+ /** Check if this file exists (relative to project root) */
1042
+ path?: string;
1043
+ /** If path is set, also check file content matches this regex */
1044
+ matchContent?: string;
1045
+ }
1046
+ type FrameworkLanguage = 'node' | 'php';
1047
+ type PackageManager = 'npm' | 'yarn' | 'pnpm' | 'bun' | 'composer';
1048
+ interface FrameworkDefinition {
1049
+ slug: string;
1050
+ name: string;
1051
+ language: FrameworkLanguage;
1052
+ /** ALL items must match for the framework to be detected */
1053
+ detectors: FrameworkDetectionItem[];
1054
+ /** Higher = higher priority (specific frameworks beat generic ones) */
1055
+ priority: number;
1056
+ /** Generates deployment defaults for this framework */
1057
+ getDefaultConfig: (packageManager: PackageManager) => FrameworkDefaultConfig;
1058
+ /** Refines defaults with project files after a framework match, e.g. framework CLI config. */
1059
+ refineDefaultConfig?: (defaults: FrameworkDefaultConfig, projectFolder: string) => Effect.Effect<FrameworkDefaultConfig, never, FileSystem.FileSystem | Path.Path>;
1105
1060
  }
1061
+ interface FrameworkDefaultConfig {
1062
+ runtime: Runtime;
1063
+ memory: number;
1064
+ maxDuration: number;
1065
+ streaming: boolean;
1066
+ /** Overrides the auto-generated install command (e.g. for custom composer flags) */
1067
+ installCommand?: string;
1068
+ /** Build commands (install command is auto-prepended by generateConfig) */
1069
+ commands: string[];
1070
+ entrypoint?: string;
1071
+ assetsDir?: string;
1072
+ assetsPrefixToStrip?: string;
1073
+ /** Explicit project-relative files to publish as static assets. */
1074
+ assetPaths?: string[];
1075
+ /** Public path overrides keyed by project-relative asset path. */
1076
+ assetOverrides?: Record<string, {
1077
+ path?: string;
1078
+ contentType?: string;
1079
+ }>;
1080
+ /** Directory subtrees to publish under a URL prefix without per-file enumeration. */
1081
+ assetPrefixes?: Array<{
1082
+ source: string;
1083
+ destination: string;
1084
+ immutable?: boolean;
1085
+ populateCache?: boolean;
1086
+ contentType?: string;
1087
+ }>;
1088
+ /** Project-relative manifests containing logical static asset entries. */
1089
+ assetManifests?: Array<{
1090
+ source: string;
1091
+ }>;
1092
+ populateAssetCache?: boolean;
1093
+ routes: Array<{
1094
+ source: string;
1095
+ destination: string;
1096
+ }>;
1097
+ environmentVariables: Record<string, string>;
1098
+ symlinks?: Record<string, string>;
1099
+ excludeFiles?: string[];
1100
+ package?: {
1101
+ trace?: boolean;
1102
+ includeProjectFiles?: boolean;
1103
+ preserveSymlinks?: boolean;
1104
+ rootOverwrite?: string;
1105
+ filePathMap?: Record<string, string>;
1106
+ includeFiles?: string[];
1107
+ excludeFiles?: string[];
1108
+ };
1109
+ /** Advanced framework output that replaces the one-entrypoint defaults. */
1110
+ normalizedConfig?: Partial<NormalizedConfig>;
1111
+ }
1112
+ interface DetectionResult {
1113
+ framework: FrameworkDefinition;
1114
+ packageManager: PackageManager;
1115
+ config: NormalizedConfig;
1116
+ }
1117
+
1106
1118
  /**
1107
- * Parses a config file at the given path and validates it against the appropriate
1108
- * JSON Schema, returning a NormalizedConfig **without** post-processing.
1119
+ * Detects the framework used in a project by checking framework definitions
1120
+ * against the project's dependencies and file structure.
1109
1121
  *
1110
- * Use {@link parseConfig} when you also want Vercel BOv3 merging, empty-deployment
1111
- * checks, and function/asset deduplication applied automatically.
1122
+ * Framework definitions are checked in priority order (highest first).
1123
+ * All detectors for a framework must match for it to be selected.
1112
1124
  *
1113
- * @param filePath - Absolute path to the config file
1114
1125
  * @param projectFolder - Absolute path to the project root
1126
+ * @returns DetectionResult with framework, package manager, and generated config
1115
1127
  */
1116
- declare const parseConfigRaw: (filePath: string, projectFolder: string) => Effect.Effect<{
1117
- regions: ("us-east-1" | "us-east-2" | "us-west-1" | "us-west-2" | "ap-south-1" | "ap-northeast-3" | "ap-northeast-2" | "ap-southeast-1" | "ap-southeast-2" | "ap-northeast-1" | "ca-central-1" | "eu-central-1" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-north-1" | "sa-east-1")[];
1118
- assets: {
1119
- paths: string[];
1120
- prefixToStrip: string;
1121
- dynamicRoutes: boolean;
1122
- populateCache: boolean;
1123
- };
1124
- environmentVariables: Record<string, string>;
1125
- commands: string[];
1126
- images: NormalizedImagePolicy | undefined;
1127
- services: NormalizedConfigServiceDefinition[] | undefined;
1128
- entrypoints: NormalizedConfigEntrypoint[];
1129
- errors: never[];
1130
- warnings: never[];
1131
- routes: NormalizedConfigRoute[];
1132
- }, ConfigFileNotFoundError | ConfigFileEmptyError | ConfigFileParseError | ConfigVersionError | ConfigSchemaValidationError | FunctionConfigError, _effect_platform_FileSystem.FileSystem | _effect_platform_Path.Path | RawConfigReader | SchemaValidator | V4ConfigParser>;
1128
+ declare const detectFramework: (projectFolder: string) => Effect.Effect<{
1129
+ framework: FrameworkDefinition;
1130
+ packageManager: PackageManager;
1131
+ config: NormalizedConfig;
1132
+ }, ManifestReadError | ManifestParseError | FrameworkNotDetectedError, Path.Path | FileSystem.FileSystem>;
1133
+
1133
1134
  /**
1134
- * Parses a config file at the given path, validates it against the appropriate
1135
- * JSON Schema, converts it to a NormalizedConfig, and applies post-processing.
1135
+ * Detects the package manager by checking for lockfiles in the project folder.
1136
+ * Falls back to `npm` if no lockfile is found.
1136
1137
  *
1137
- * @param filePath - Absolute path to the config file
1138
1138
  * @param projectFolder - Absolute path to the project root
1139
+ * @returns The detected package manager
1139
1140
  */
1140
- declare const parseConfig: (filePath: string, projectFolder: string) => Effect.Effect<NormalizedConfig, ConfigFileNotFoundError | ConfigFileEmptyError | ConfigFileParseError | ConfigVersionError | ConfigSchemaValidationError | FunctionConfigError, _effect_platform_FileSystem.FileSystem | _effect_platform_Path.Path | RawConfigReader | SchemaValidator | V4ConfigParser | VercelBuildOutputParser>;
1141
+ declare const detectPackageManager: (projectFolder: string) => Effect.Effect<PackageManager, never, Path.Path | FileSystem.FileSystem>;
1142
+
1141
1143
  /**
1142
- * Applies post-processing transformers to a NormalizedConfig:
1143
- * - Vercel Build Output v3 (merges functions/routes from .vercel/output if present)
1144
- * - Empty deployment validation
1145
- * - Filter functions from assets
1144
+ * All supported framework definitions, sorted by priority descending.
1145
+ * Higher priority frameworks are checked first during detection.
1146
+ */
1147
+ declare const FRAMEWORK_DEFINITIONS: FrameworkDefinition[];
1148
+
1149
+ /**
1150
+ * Generates a NormalizedConfig from a framework definition and detected package manager.
1151
+ * Prepends the install command and builds a complete deployment configuration.
1152
+ *
1153
+ * @param framework - The detected framework definition
1154
+ * @param packageManager - The detected package manager
1155
+ * @returns A complete NormalizedConfig with framework defaults
1156
+ */
1157
+ declare const generateConfig: (framework: FrameworkDefinition, packageManager: PackageManager, refinedDefaults?: FrameworkDefaultConfig | undefined) => Effect.Effect<NormalizedConfig, never, never>;
1158
+
1159
+ /**
1160
+ * Merges framework defaults with a user-provided config.
1161
+ * User config always takes precedence; framework defaults fill gaps.
1162
+ *
1163
+ * - commands: use user's if non-empty, otherwise framework's
1164
+ * - entrypoints: use user's if non-empty, otherwise framework's
1165
+ * - routes: use user's if non-empty, otherwise framework's
1166
+ * - assets: use user's if it declares any sources, otherwise framework's
1167
+ * - excludeFiles: use user's if non-empty, otherwise framework's
1168
+ * - regions: always use user's (always populated from parsing)
1169
+ * - environmentVariables: deep merge (framework base, user overrides)
1170
+ * - services: always use user's (frameworks don't define services)
1171
+ * - warnings/errors: concatenate both
1172
+ *
1173
+ * @param userConfig - The config parsed from the user's config file
1174
+ * @param frameworkConfig - The config generated from framework detection
1175
+ * @returns The merged config
1176
+ */
1177
+ declare const mergeWithFrameworkDefaults: (userConfig: NormalizedConfig, frameworkConfig: NormalizedConfig) => Effect.Effect<NormalizedConfig, never, never>;
1178
+
1179
+ /**
1180
+ * Reads dependency names from the appropriate manifest file for a language.
1181
+ * Returns a set of all dependency names (production + dev).
1182
+ *
1183
+ * If the manifest file does not exist, returns an empty set (graceful).
1184
+ * If the file exists but cannot be read (`ManifestReadError`) or parsed
1185
+ * (`ManifestParseError`), the error propagates — this indicates a real
1186
+ * problem the user should know about.
1146
1187
  *
1147
- * @param config - The parsed NormalizedConfig
1148
1188
  * @param projectFolder - Absolute path to the project root
1149
- * @returns The post-processed NormalizedConfig
1189
+ * @param language - The framework language to determine which manifest to read
1190
+ * @returns A set of dependency package names
1150
1191
  */
1151
- declare const postProcessConfig: (config: NormalizedConfig, projectFolder: string) => Effect.Effect<NormalizedConfig, ConfigFileEmptyError | ConfigFileParseError | ConfigVersionError, _effect_platform_FileSystem.FileSystem | _effect_platform_Path.Path | VercelBuildOutputParser>;
1192
+ declare const readDependencies: (projectFolder: string, language: FrameworkLanguage) => Effect.Effect<Set<string>, ManifestReadError | ManifestParseError, Path.Path | FileSystem.FileSystem>;
1193
+
1194
+ /**
1195
+ * Ensure a normalized config has no function files that are also defined as assets.
1196
+ * For example, a file `public/index.php` should not be defined as an asset, when it is a function and `public` is an asset folder.
1197
+ * @param config The normalized config to filter.
1198
+ * @returns A promise that resolves to the filtered config.
1199
+ */
1200
+ declare const filterFunctionsFromAssets: (config: NormalizedConfig) => NormalizedConfig;
1152
1201
 
1153
- declare const NetworkConfigLive: Layer.Layer<RawConfigReader | SchemaValidator | V4ConfigParser | VercelBuildOutputParser, never, _effect_platform_FileSystem.FileSystem | _effect_platform_Path.Path>;
1202
+ declare const NetworkConfigLive: Layer.Layer<ConfigModuleLoader | RawConfigReader | SchemaValidator | V4ConfigParser | VercelBuildOutputParser, never, _effect_platform_Path.Path | _effect_platform_FileSystem.FileSystem>;
1154
1203
 
1155
- export { ALLOWED_CONFIG_NAMES, AVAILABLE_REGIONS, AVAILABLE_RUNTIMES, type Config, ConfigFileEmptyError, ConfigFileNotFoundError, ConfigFileParseError, ConfigSchemaValidationError, type ConfigV4, type ConfigV4FunctionSettings, type ConfigV4Service, type ConfigV4ServicePostgres, type ConfigV4ServiceRedis, type ConfigV4ServiceStorage, type ConfigV4Services, type ConfigV4StorageBucket, ConfigVersionError, DEFAULT_FUNCTION_DURATION_SECONDS, type DetectionResult, FRAMEWORK_DEFINITIONS, type FilePathMap, type FrameworkDefaultConfig, type FrameworkDefinition, type FrameworkDetectionItem, type FrameworkLanguage, FrameworkNotDetectedError, FunctionConfigError, type GigadriveNextBuildManifest, GigadriveNextBuildManifestSchema, type GigadriveNextBuildManifestV1, GigadriveNextBuildManifestV1Schema, type GigadriveNextBuildManifestV2, type GigadriveNextBuildManifestV2Export, GigadriveNextBuildManifestV2ExportSchema, type GigadriveNextBuildManifestV2Standalone, GigadriveNextBuildManifestV2StandaloneSchema, type GigadriveNextPrerenderManifestV1, GigadriveNextPrerenderManifestV1Schema, type GigadriveNextPrerenderOutput, GigadriveNextPrerenderOutputSchema, type GigadriveNextServerDescriptor, GigadriveNextServerDescriptorSchema, type GigadriveNextStaticAssetPrefix, GigadriveNextStaticAssetPrefixSchema, type JsonValue, MAX_FUNCTION_DURATION_SECONDS, ManifestNotFoundError, ManifestParseError, ManifestReadError, type NeonAWSRegion, NetworkConfigLive, type NormalizedConfig, type NormalizedConfigEntrypoint, type NormalizedConfigRoute, type NormalizedConfigRouteHandler, type NormalizedConfigRouteMatchRequirements, type NormalizedConfigRouteMethod, type NormalizedConfigService, type NormalizedConfigServiceDefinition, type NormalizedConfigServicePostgres, type NormalizedConfigServiceRedis, type NormalizedConfigServiceStorage, type NormalizedConfigServiceType, type NormalizedConfigStorageBucket, type NormalizedFramework, type NormalizedImageFit, type NormalizedImageFormat, type NormalizedImageLocalPattern, type NormalizedImagePolicy, type NormalizedImageRemotePattern, type NormalizedImageVariant, type NormalizedNextjsFramework, type NormalizedSharedArtifact, type PackageManager, RawConfigReader, type Region, type Runtime, SchemaValidator, type StaticAssetHeaders, StaticAssetHeadersSchema, type StaticAssetManifest, type StaticAssetManifestEntry, StaticAssetManifestEntrySchema, type StaticAssetManifestV1, StaticAssetManifestV1Schema, type UpstashAWSRegion, V4ConfigParser, VercelBuildOutputParser, detectFramework, detectPackageManager, filterFunctionsFromAssets, generateConfig, getFunctionSettings, mergeWithFrameworkDefaults, parseConfig, parseConfigRaw, parseGigadriveNextBuildManifest, parseGigadriveNextPrerenderManifest, parseStaticAssetManifest, postProcessConfig, readDependencies };
1204
+ export { ALLOWED_CONFIG_NAMES, AVAILABLE_REGIONS, AVAILABLE_RUNTIMES, type Config, ConfigFileEmptyError, ConfigFileNotFoundError, ConfigFileParseError, ConfigModuleLoadError, ConfigModuleLoader, ConfigSchemaValidationError, type ConfigV4, type ConfigV4FunctionSettings, type ConfigV4Service, type ConfigV4ServicePostgres, type ConfigV4ServiceRedis, type ConfigV4ServiceStorage, type ConfigV4Services, type ConfigV4StorageBucket, ConfigVersionError, DEFAULT_FUNCTION_DURATION_SECONDS, type DetectionResult, FRAMEWORK_DEFINITIONS, type FilePathMap, type FrameworkDefaultConfig, type FrameworkDefinition, type FrameworkDetectionItem, type FrameworkLanguage, FrameworkNotDetectedError, FunctionConfigError, type GigadriveNextBuildManifest, GigadriveNextBuildManifestSchema, type GigadriveNextBuildManifestV1, GigadriveNextBuildManifestV1Schema, type GigadriveNextBuildManifestV2, type GigadriveNextBuildManifestV2Export, GigadriveNextBuildManifestV2ExportSchema, type GigadriveNextBuildManifestV2Standalone, GigadriveNextBuildManifestV2StandaloneSchema, type GigadriveNextPrerenderManifestV1, GigadriveNextPrerenderManifestV1Schema, type GigadriveNextPrerenderOutput, GigadriveNextPrerenderOutputSchema, type GigadriveNextServerDescriptor, GigadriveNextServerDescriptorSchema, type GigadriveNextStaticAssetPrefix, GigadriveNextStaticAssetPrefixSchema, type JsonValue, MAX_FUNCTION_DURATION_SECONDS, ManifestNotFoundError, ManifestParseError, ManifestReadError, type NeonAWSRegion, NetworkConfigLive, type NormalizedConfig, type NormalizedConfigEntrypoint, type NormalizedConfigRoute, type NormalizedConfigRouteHandler, type NormalizedConfigRouteMatchRequirements, type NormalizedConfigRouteMethod, type NormalizedConfigService, type NormalizedConfigServiceDefinition, type NormalizedConfigServicePostgres, type NormalizedConfigServiceRedis, type NormalizedConfigServiceStorage, type NormalizedConfigServiceType, type NormalizedConfigStorageBucket, type NormalizedFramework, type NormalizedImageFit, type NormalizedImageFormat, type NormalizedImageLocalPattern, type NormalizedImagePolicy, type NormalizedImageRemotePattern, type NormalizedImageVariant, type NormalizedNextjsFramework, type NormalizedSharedArtifact, type PackageManager, RawConfigReader, type Region, type Runtime, SchemaValidator, type StaticAssetHeaders, StaticAssetHeadersSchema, type StaticAssetManifest, type StaticAssetManifestEntry, StaticAssetManifestEntrySchema, type StaticAssetManifestV1, StaticAssetManifestV1Schema, type UpstashAWSRegion, V4ConfigParser, VercelBuildOutputParser, defineConfig, detectFramework, detectPackageManager, filterFunctionsFromAssets, generateConfig, getFunctionSettings, mergeWithFrameworkDefaults, parseConfig, parseConfigRaw, parseGigadriveNextBuildManifest, parseGigadriveNextPrerenderManifest, parseStaticAssetManifest, postProcessConfig, readDependencies };