@gigadrive/network-config 5.0.0 → 5.1.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
@@ -51,6 +51,77 @@ declare const parseStaticAssetManifest: (content: string) => StaticAssetManifest
51
51
  */
52
52
  declare const collectAssetFiles: (projectFolder: string, assetsDir: string) => Effect.Effect<string[], never, FileSystem.FileSystem | Path.Path>;
53
53
 
54
+ declare const ConfigFileNotFoundError_base: Schema.TaggedErrorClass<ConfigFileNotFoundError, "ConfigFileNotFoundError", {
55
+ readonly _tag: Schema.tag<"ConfigFileNotFoundError">;
56
+ } & {
57
+ message: typeof Schema.String;
58
+ filePath: typeof Schema.String;
59
+ }>;
60
+ declare class ConfigFileNotFoundError extends ConfigFileNotFoundError_base {
61
+ }
62
+ declare const ConfigFileEmptyError_base: Schema.TaggedErrorClass<ConfigFileEmptyError, "ConfigFileEmptyError", {
63
+ readonly _tag: Schema.tag<"ConfigFileEmptyError">;
64
+ } & {
65
+ message: typeof Schema.String;
66
+ filePath: typeof Schema.String;
67
+ }>;
68
+ declare class ConfigFileEmptyError extends ConfigFileEmptyError_base {
69
+ }
70
+ declare const ConfigFileParseError_base: Schema.TaggedErrorClass<ConfigFileParseError, "ConfigFileParseError", {
71
+ readonly _tag: Schema.tag<"ConfigFileParseError">;
72
+ } & {
73
+ message: typeof Schema.String;
74
+ filePath: typeof Schema.String;
75
+ cause: Schema.optional<typeof Schema.String>;
76
+ }>;
77
+ declare class ConfigFileParseError extends ConfigFileParseError_base {
78
+ }
79
+ declare const ConfigModuleLoadError_base: Schema.TaggedErrorClass<ConfigModuleLoadError, "ConfigModuleLoadError", {
80
+ readonly _tag: Schema.tag<"ConfigModuleLoadError">;
81
+ } & {
82
+ message: typeof Schema.String;
83
+ filePath: typeof Schema.String;
84
+ cause: Schema.optional<typeof Schema.String>;
85
+ }>;
86
+ declare class ConfigModuleLoadError extends ConfigModuleLoadError_base {
87
+ }
88
+ declare const ConfigVersionError_base: Schema.TaggedErrorClass<ConfigVersionError, "ConfigVersionError", {
89
+ readonly _tag: Schema.tag<"ConfigVersionError">;
90
+ } & {
91
+ message: typeof Schema.String;
92
+ filePath: typeof Schema.String;
93
+ version: Schema.optional<typeof Schema.Number>;
94
+ }>;
95
+ declare class ConfigVersionError extends ConfigVersionError_base {
96
+ }
97
+ declare const ConfigSchemaValidationError_base: Schema.TaggedErrorClass<ConfigSchemaValidationError, "ConfigSchemaValidationError", {
98
+ readonly _tag: Schema.tag<"ConfigSchemaValidationError">;
99
+ } & {
100
+ message: typeof Schema.String;
101
+ filePath: typeof Schema.String;
102
+ validationErrors: Schema.Array$<typeof Schema.String>;
103
+ }>;
104
+ declare class ConfigSchemaValidationError extends ConfigSchemaValidationError_base {
105
+ }
106
+ declare const FunctionConfigError_base: Schema.TaggedErrorClass<FunctionConfigError, "FunctionConfigError", {
107
+ readonly _tag: Schema.tag<"FunctionConfigError">;
108
+ } & {
109
+ message: typeof Schema.String;
110
+ functionPath: typeof Schema.String;
111
+ }>;
112
+ declare class FunctionConfigError extends FunctionConfigError_base {
113
+ }
114
+ declare const ContainerConfigError_base: Schema.TaggedErrorClass<ContainerConfigError, "ContainerConfigError", {
115
+ readonly _tag: Schema.tag<"ContainerConfigError">;
116
+ } & {
117
+ message: typeof Schema.String;
118
+ containerName: Schema.optional<typeof Schema.String>;
119
+ filePath: Schema.optional<typeof Schema.String>;
120
+ }>;
121
+ /** A `containers` entry, or a Compose file imported into one, cannot be deployed as written. */
122
+ declare class ContainerConfigError extends ContainerConfigError_base {
123
+ }
124
+
54
125
  interface NormalizedImageLocalPattern {
55
126
  pathname?: string;
56
127
  search?: string;
@@ -711,6 +782,15 @@ interface NormalizedConfig {
711
782
  routes: Array<NormalizedConfigRoute>;
712
783
  /** Managed infrastructure declarations supplied through `gigadrive.yaml`. */
713
784
  services?: NormalizedConfigService[];
785
+ /**
786
+ * Container images that run inside the microVM of every function instance of
787
+ * the deployment, next to the function. Each one is reachable from the
788
+ * function, and from every other sidecar, at `<name>:<port>`.
789
+ *
790
+ * Sidecar state belongs to one instance: it is lost when the instance is
791
+ * retired, and two replicas of a function never share a sidecar.
792
+ */
793
+ sidecars?: NormalizedSidecar[];
714
794
  /**
715
795
  * Settings related to the archive the user uploads to the build workers.
716
796
  */
@@ -745,9 +825,9 @@ interface NormalizedConfigService {
745
825
  type: NormalizedConfigServiceType;
746
826
  }
747
827
  /** Service kinds supported by the normalized deployment configuration. */
748
- type NormalizedConfigServiceType = 'redis' | 'postgres' | 'storage';
828
+ type NormalizedConfigServiceType = 'redis' | 'postgres' | 'storage' | 'queues';
749
829
  /** Fully normalized managed-service declaration consumed by provisioning. */
750
- type NormalizedConfigServiceDefinition = NormalizedConfigServiceRedis | NormalizedConfigServicePostgres | NormalizedConfigServiceStorage;
830
+ type NormalizedConfigServiceDefinition = NormalizedConfigServiceRedis | NormalizedConfigServicePostgres | NormalizedConfigServiceStorage | NormalizedConfigServiceQueues;
751
831
  type UpstashAWSRegion = 'us-east-1' | 'us-east-2' | 'us-west-1' | 'us-west-2' | 'eu-central-1' | 'eu-west-1' | 'eu-west-2' | 'sa-east-1' | 'ap-south-1' | 'ap-northeast-1' | 'ap-southeast-1' | 'ap-southeast-2';
752
832
  interface NormalizedConfigServiceRedis extends NormalizedConfigService {
753
833
  type: 'redis';
@@ -782,14 +862,123 @@ interface NormalizedConfigStorageBucket {
782
862
  /** Access policy to apply when the bucket is first provisioned. */
783
863
  visibility: 'public' | 'private';
784
864
  }
865
+ /**
866
+ * Declarative queues provisioned in the deployment environment.
867
+ *
868
+ * Durations are resolved to seconds and schedule bodies to strings, so the
869
+ * platform receives one canonical shape. Settings the config omits stay
870
+ * absent and keep the platform's defaults.
871
+ */
872
+ interface NormalizedConfigServiceQueues extends NormalizedConfigService {
873
+ type: 'queues';
874
+ /** Queues sorted by name for deterministic deployment plans. */
875
+ queues: NormalizedConfigQueue[];
876
+ }
877
+ /** Desired state for one environment-scoped queue. */
878
+ interface NormalizedConfigQueue {
879
+ name: string;
880
+ /** Push consumer path; absent or `null` declares a pull queue. */
881
+ consumer?: string | null;
882
+ visibilityTimeoutSeconds?: number;
883
+ retentionSeconds?: number;
884
+ maxAttempts?: number;
885
+ retryBackoffMinSeconds?: number;
886
+ retryBackoffMaxSeconds?: number;
887
+ deduplicationWindowSeconds?: number;
888
+ concurrency?: number | null;
889
+ rateLimit?: {
890
+ count: number;
891
+ periodSeconds: number;
892
+ } | null;
893
+ deadLetter?: boolean;
894
+ /** Schedules sorted by name. */
895
+ schedules?: NormalizedConfigQueueSchedule[];
896
+ }
897
+ /** One cron schedule that sends into a declared queue. */
898
+ interface NormalizedConfigQueueSchedule {
899
+ name: string;
900
+ cron: string;
901
+ timezone?: string;
902
+ body?: string;
903
+ contentType?: string;
904
+ headers?: Record<string, string>;
905
+ enabled?: boolean;
906
+ }
785
907
  /** Default maximum lifetime of one function invocation, in seconds. */
786
908
  declare const DEFAULT_FUNCTION_DURATION_SECONDS = 30;
787
909
  /** Maximum configurable lifetime of one function invocation, in seconds (eight hours). */
788
910
  declare const MAX_FUNCTION_DURATION_SECONDS = 28800;
911
+ /**
912
+ * Runtime tag of an entrypoint that runs a container image instead of a
913
+ * managed language runtime. Such an entrypoint always carries a
914
+ * {@link NormalizedConfigEntrypoint.container} spec.
915
+ */
916
+ declare const CONTAINER_RUNTIME = "docker";
917
+ /** Runtime tag of a container entrypoint. */
918
+ type ContainerRuntime = typeof CONTAINER_RUNTIME;
919
+ /**
920
+ * Prefix of the synthetic `path` a container entrypoint carries. Routes target a
921
+ * container function with `destination: container:<name>`.
922
+ */
923
+ declare const CONTAINER_ENTRYPOINT_PREFIX = "container:";
924
+ /** Default memory of a container function, in MB. */
925
+ declare const DEFAULT_CONTAINER_MEMORY_MB = 512;
926
+ /** Default memory of a sidecar, in MB. It is added to the memory of every function it runs next to. */
927
+ declare const DEFAULT_SIDECAR_MEMORY_MB = 256;
928
+ /** Most sidecars one deployment may declare. */
929
+ declare const MAX_SIDECARS = 4;
930
+ /** Where the root filesystem of a container comes from. */
931
+ type NormalizedContainerImageSource = {
932
+ type: 'registry';
933
+ /** Image reference as written, e.g. `redis:7-alpine` or `ghcr.io/acme/api@sha256:...`. */
934
+ reference: string;
935
+ } | {
936
+ type: 'dockerfile';
937
+ /** Project-relative build context directory, `.` for the project root. */
938
+ context: string;
939
+ /** Dockerfile path relative to {@link context}. */
940
+ dockerfile: string;
941
+ /** Build stage to stop at, for multi-stage Dockerfiles. */
942
+ target?: string;
943
+ /** `--build-arg` values. */
944
+ buildArgs?: Record<string, string>;
945
+ };
946
+ /**
947
+ * A container image plus the settings that override its image config. The
948
+ * overrides are baked into the signed launch metadata at build time.
949
+ */
950
+ interface NormalizedContainerSpec {
951
+ /** Name from the `containers` map. Also the hostname a sidecar answers to. */
952
+ name: string;
953
+ source: NormalizedContainerImageSource;
954
+ /** TCP port the process listens on. Defaults to the image's first exposed port, then 8080. */
955
+ port?: number;
956
+ /** Replaces the image `ENTRYPOINT`. */
957
+ entrypoint?: string[];
958
+ /** Replaces the image `CMD`. */
959
+ command?: string[];
960
+ /** Replaces the image `WORKDIR`. */
961
+ workingDirectory?: string;
962
+ /** Replaces the image `USER`: a name, a uid, `name:group` or `uid:gid`. */
963
+ user?: string;
964
+ /** Merged over the image `ENV`. */
965
+ environmentVariables?: Record<string, string>;
966
+ }
967
+ /** A container that runs next to every function instance of the deployment. */
968
+ interface NormalizedSidecar extends NormalizedContainerSpec {
969
+ /** Memory reserved for the sidecar, in MB. Added to each function's memory. */
970
+ memory: number;
971
+ }
789
972
  interface NormalizedConfigEntrypoint {
790
973
  displayName?: string;
974
+ /**
975
+ * Project-relative file of the function, or `container:<name>` for a
976
+ * container function.
977
+ */
791
978
  path: string;
792
- runtime: Runtime;
979
+ runtime: Runtime | ContainerRuntime;
980
+ /** Image to run, present exactly when {@link runtime} is `docker`. */
981
+ container?: NormalizedContainerSpec;
793
982
  memory: number;
794
983
  /**
795
984
  * Maximum lifetime of one HTTP request, response stream, or WebSocket connection, in seconds.
@@ -877,67 +1066,6 @@ type NormalizedConfigRouteMatchRequirements = [] | [
877
1066
  }
878
1067
  ];
879
1068
 
880
- declare const ConfigFileNotFoundError_base: Schema.TaggedErrorClass<ConfigFileNotFoundError, "ConfigFileNotFoundError", {
881
- readonly _tag: Schema.tag<"ConfigFileNotFoundError">;
882
- } & {
883
- message: typeof Schema.String;
884
- filePath: typeof Schema.String;
885
- }>;
886
- declare class ConfigFileNotFoundError extends ConfigFileNotFoundError_base {
887
- }
888
- declare const ConfigFileEmptyError_base: Schema.TaggedErrorClass<ConfigFileEmptyError, "ConfigFileEmptyError", {
889
- readonly _tag: Schema.tag<"ConfigFileEmptyError">;
890
- } & {
891
- message: typeof Schema.String;
892
- filePath: typeof Schema.String;
893
- }>;
894
- declare class ConfigFileEmptyError extends ConfigFileEmptyError_base {
895
- }
896
- declare const ConfigFileParseError_base: Schema.TaggedErrorClass<ConfigFileParseError, "ConfigFileParseError", {
897
- readonly _tag: Schema.tag<"ConfigFileParseError">;
898
- } & {
899
- message: typeof Schema.String;
900
- filePath: typeof Schema.String;
901
- cause: Schema.optional<typeof Schema.String>;
902
- }>;
903
- declare class ConfigFileParseError extends ConfigFileParseError_base {
904
- }
905
- declare const ConfigModuleLoadError_base: Schema.TaggedErrorClass<ConfigModuleLoadError, "ConfigModuleLoadError", {
906
- readonly _tag: Schema.tag<"ConfigModuleLoadError">;
907
- } & {
908
- message: typeof Schema.String;
909
- filePath: typeof Schema.String;
910
- cause: Schema.optional<typeof Schema.String>;
911
- }>;
912
- declare class ConfigModuleLoadError extends ConfigModuleLoadError_base {
913
- }
914
- declare const ConfigVersionError_base: Schema.TaggedErrorClass<ConfigVersionError, "ConfigVersionError", {
915
- readonly _tag: Schema.tag<"ConfigVersionError">;
916
- } & {
917
- message: typeof Schema.String;
918
- filePath: typeof Schema.String;
919
- version: Schema.optional<typeof Schema.Number>;
920
- }>;
921
- declare class ConfigVersionError extends ConfigVersionError_base {
922
- }
923
- declare const ConfigSchemaValidationError_base: Schema.TaggedErrorClass<ConfigSchemaValidationError, "ConfigSchemaValidationError", {
924
- readonly _tag: Schema.tag<"ConfigSchemaValidationError">;
925
- } & {
926
- message: typeof Schema.String;
927
- filePath: typeof Schema.String;
928
- validationErrors: Schema.Array$<typeof Schema.String>;
929
- }>;
930
- declare class ConfigSchemaValidationError extends ConfigSchemaValidationError_base {
931
- }
932
- declare const FunctionConfigError_base: Schema.TaggedErrorClass<FunctionConfigError, "FunctionConfigError", {
933
- readonly _tag: Schema.tag<"FunctionConfigError">;
934
- } & {
935
- message: typeof Schema.String;
936
- functionPath: typeof Schema.String;
937
- }>;
938
- declare class FunctionConfigError extends FunctionConfigError_base {
939
- }
940
-
941
1069
  declare const ConfigModuleLoader_base: Effect.Service.Class<ConfigModuleLoader, "ConfigModuleLoader", {
942
1070
  readonly effect: Effect.Effect<{
943
1071
  loadConfigModule: (filePath: string) => Effect.Effect<Record<string, unknown>, ConfigModuleLoadError, never>;
@@ -985,6 +1113,11 @@ declare const V4ConfigParser_base: Effect.Service.Class<V4ConfigParser, "V4Confi
985
1113
  * @param projectFolder - Absolute path to the project root
986
1114
  */
987
1115
  parse: (config: ConfigV4, projectFolder: string) => Effect.Effect<{
1116
+ entrypoints: NormalizedConfigEntrypoint[];
1117
+ errors: never[];
1118
+ warnings: string[];
1119
+ routes: NormalizedConfigRoute[];
1120
+ sidecars?: NormalizedSidecar[] | undefined;
988
1121
  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")[];
989
1122
  assets: {
990
1123
  paths: string[];
@@ -996,11 +1129,7 @@ declare const V4ConfigParser_base: Effect.Service.Class<V4ConfigParser, "V4Confi
996
1129
  commands: string[];
997
1130
  images: NormalizedImagePolicy | undefined;
998
1131
  services: NormalizedConfigServiceDefinition[] | undefined;
999
- entrypoints: NormalizedConfigEntrypoint[];
1000
- errors: never[];
1001
- warnings: never[];
1002
- routes: NormalizedConfigRoute[];
1003
- }, FunctionConfigError, _effect_platform_FileSystem.FileSystem | _effect_platform_Path.Path>;
1132
+ }, FunctionConfigError | ContainerConfigError, _effect_platform_FileSystem.FileSystem | _effect_platform_Path.Path>;
1004
1133
  }, never, never>;
1005
1134
  }>;
1006
1135
  declare class V4ConfigParser extends V4ConfigParser_base {
@@ -1029,6 +1158,11 @@ interface Config {
1029
1158
  * @param projectFolder - Absolute path to the project root
1030
1159
  */
1031
1160
  declare const parseConfigRaw: (filePath: string, projectFolder: string) => Effect.Effect<{
1161
+ entrypoints: NormalizedConfigEntrypoint[];
1162
+ errors: never[];
1163
+ warnings: string[];
1164
+ routes: NormalizedConfigRoute[];
1165
+ sidecars?: NormalizedSidecar[] | undefined;
1032
1166
  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")[];
1033
1167
  assets: {
1034
1168
  paths: string[];
@@ -1040,11 +1174,7 @@ declare const parseConfigRaw: (filePath: string, projectFolder: string) => Effec
1040
1174
  commands: string[];
1041
1175
  images: NormalizedImagePolicy | undefined;
1042
1176
  services: NormalizedConfigServiceDefinition[] | undefined;
1043
- entrypoints: NormalizedConfigEntrypoint[];
1044
- errors: never[];
1045
- warnings: never[];
1046
- routes: NormalizedConfigRoute[];
1047
- }, ConfigFileNotFoundError | ConfigFileEmptyError | ConfigFileParseError | ConfigModuleLoadError | ConfigVersionError | ConfigSchemaValidationError | FunctionConfigError, _effect_platform_FileSystem.FileSystem | _effect_platform_Path.Path | RawConfigReader | SchemaValidator | V4ConfigParser>;
1177
+ }, ConfigFileNotFoundError | ConfigFileEmptyError | ConfigFileParseError | ConfigModuleLoadError | ConfigVersionError | ConfigSchemaValidationError | FunctionConfigError | ContainerConfigError, _effect_platform_FileSystem.FileSystem | _effect_platform_Path.Path | RawConfigReader | SchemaValidator | V4ConfigParser>;
1048
1178
  /**
1049
1179
  * Parses a config file at the given path, validates it against the appropriate
1050
1180
  * JSON Schema, converts it to a NormalizedConfig, and applies post-processing.
@@ -1052,7 +1182,7 @@ declare const parseConfigRaw: (filePath: string, projectFolder: string) => Effec
1052
1182
  * @param filePath - Absolute path to the config file
1053
1183
  * @param projectFolder - Absolute path to the project root
1054
1184
  */
1055
- declare const parseConfig: (filePath: string, projectFolder: string) => Effect.Effect<NormalizedConfig, ConfigFileNotFoundError | ConfigFileEmptyError | ConfigFileParseError | ConfigModuleLoadError | ConfigVersionError | ConfigSchemaValidationError | FunctionConfigError, _effect_platform_FileSystem.FileSystem | _effect_platform_Path.Path | RawConfigReader | SchemaValidator | V4ConfigParser | VercelBuildOutputParser>;
1185
+ declare const parseConfig: (filePath: string, projectFolder: string) => Effect.Effect<NormalizedConfig, ConfigFileNotFoundError | ConfigFileEmptyError | ConfigFileParseError | ConfigModuleLoadError | ConfigVersionError | ConfigSchemaValidationError | FunctionConfigError | ContainerConfigError, _effect_platform_FileSystem.FileSystem | _effect_platform_Path.Path | RawConfigReader | SchemaValidator | V4ConfigParser | VercelBuildOutputParser>;
1056
1186
  /**
1057
1187
  * Applies post-processing transformers to a NormalizedConfig:
1058
1188
  * - Vercel Build Output v3 (merges functions/routes from .vercel/output if present)
@@ -1149,6 +1279,75 @@ interface ConfigV4 extends Config {
1149
1279
  env?: Record<string, string>;
1150
1280
  /** Declares managed services to provision for the deployment environment. */
1151
1281
  services?: ConfigV4Services;
1282
+ /**
1283
+ * Container images to run, keyed by name. A container without `sidecar: true`
1284
+ * runs as a function that routes target with `destination: container:<name>`.
1285
+ * A sidecar runs next to every function instance and answers at `<name>:<port>`.
1286
+ * A name is 1 to 63 lowercase letters, digits, `-` or `_`, starts with a
1287
+ * letter (so it never reads as an IP address), and is not `localhost`.
1288
+ *
1289
+ * @example
1290
+ * ```yaml
1291
+ * containers:
1292
+ * web:
1293
+ * build: .
1294
+ * port: 3000
1295
+ * redis:
1296
+ * image: redis:7-alpine
1297
+ * sidecar: true
1298
+ * ```
1299
+ */
1300
+ containers?: Record<string, ConfigV4Container> | null;
1301
+ /**
1302
+ * Project-relative path of a Compose file whose services are imported as
1303
+ * `containers`. Entries in `containers` win over imported services of the
1304
+ * same name.
1305
+ */
1306
+ compose?: string | null;
1307
+ }
1308
+ /** One entry of the v4 `containers` map. Exactly one of `image` and `build` is required. */
1309
+ interface ConfigV4Container {
1310
+ /** Registry image reference, e.g. `redis:7-alpine` or `ghcr.io/acme/api:1.4`. */
1311
+ image?: string;
1312
+ /** Build context directory, or the full build settings, for a Dockerfile in the repository. */
1313
+ build?: string | ConfigV4ContainerBuild;
1314
+ /** Run next to every function instance instead of serving routes. Defaults to `false`. */
1315
+ sidecar?: boolean;
1316
+ /** TCP port the container listens on. Defaults to the image's first exposed port, then 8080. */
1317
+ port?: number;
1318
+ /** Replaces the image `ENTRYPOINT`. A string is split into words the way Compose splits it. */
1319
+ entrypoint?: string | string[];
1320
+ /** Replaces the image `CMD`. A string is split into words the way Compose splits it. */
1321
+ command?: string | string[];
1322
+ /** Environment variables baked into the container, merged over the image `ENV`. */
1323
+ env?: Record<string, string>;
1324
+ /** Replaces the image `WORKDIR`. Must be absolute. */
1325
+ working_dir?: string;
1326
+ /**
1327
+ * Replaces the image `USER`: a name, a uid, `name:group` or `uid:gid`. A bare
1328
+ * uid may be written as a number. Root is never used: a root image runs as a
1329
+ * dedicated non-root user.
1330
+ */
1331
+ user?: string | number;
1332
+ /** Memory in MB, a whole number from 128 to 3009. Defaults to 512 for a container function and 256 for a sidecar. */
1333
+ memory?: number;
1334
+ /** Maximum lifetime of one request, in seconds. Container functions only. */
1335
+ max_duration?: number;
1336
+ /** Stream responses. Defaults to `true`. Container functions only. */
1337
+ streaming?: boolean;
1338
+ /** Run on a timer, like a function `schedule`. Container functions only. */
1339
+ schedule?: string;
1340
+ }
1341
+ /** Dockerfile build settings for a container. */
1342
+ interface ConfigV4ContainerBuild {
1343
+ /** Project-relative build context. Defaults to `.`. */
1344
+ context?: string;
1345
+ /** Dockerfile path relative to the context. Defaults to `Dockerfile`. */
1346
+ dockerfile?: string;
1347
+ /** Build stage to stop at. */
1348
+ target?: string;
1349
+ /** Build arguments. */
1350
+ args?: Record<string, string>;
1152
1351
  }
1153
1352
  interface ConfigV4Service {
1154
1353
  }
@@ -1196,6 +1395,75 @@ interface ConfigV4Services {
1196
1395
  postgres?: ConfigV4ServicePostgres | null;
1197
1396
  /** Declarative File Storage buckets for the deployment environment. */
1198
1397
  storage?: ConfigV4ServiceStorage;
1398
+ /**
1399
+ * Queues for the deployment environment, keyed by name. `null` declares a
1400
+ * pull queue with default settings.
1401
+ *
1402
+ * @example
1403
+ * ```yaml
1404
+ * services:
1405
+ * queues:
1406
+ * emails:
1407
+ * consumer: /api/queues/emails
1408
+ * maxAttempts: 5
1409
+ * schedules:
1410
+ * daily-digest:
1411
+ * cron: '0 8 * * MON-FRI'
1412
+ * timezone: Europe/Berlin
1413
+ * body: { kind: digest }
1414
+ * jobs: null
1415
+ * ```
1416
+ */
1417
+ queues?: Record<string, ConfigV4Queue | null>;
1418
+ }
1419
+ /** A duration in seconds, or a string such as `30s`, `10m`, `1.5h` or `4d`. */
1420
+ type ConfigV4QueueDuration = number | `${number}${'s' | 'm' | 'h' | 'd'}`;
1421
+ /** Settings for a declaratively provisioned queue. Omitted settings keep the platform defaults. */
1422
+ interface ConfigV4Queue {
1423
+ /**
1424
+ * Deployment-relative path that receives each message as a signed POST, for
1425
+ * example `/api/queues/emails`. Omit it for a pull queue.
1426
+ */
1427
+ consumer?: string | null;
1428
+ /** How long a push delivery may run, or how long a received message stays leased. Defaults to 60 seconds. */
1429
+ visibilityTimeout?: ConfigV4QueueDuration;
1430
+ /** How long an undelivered message is kept. Defaults to 4 days, at most 14 days. */
1431
+ retention?: ConfigV4QueueDuration;
1432
+ /** Deliveries per message before it moves to the dead-letter list. Defaults to 10. */
1433
+ maxAttempts?: number;
1434
+ /** Exponential backoff between failed deliveries. Defaults to 5 seconds up to 15 minutes. */
1435
+ retryBackoff?: {
1436
+ min?: ConfigV4QueueDuration;
1437
+ max?: ConfigV4QueueDuration;
1438
+ };
1439
+ /** How long a deduplication key is remembered. Defaults to 24 hours. */
1440
+ deduplicationWindow?: ConfigV4QueueDuration;
1441
+ /** Most push deliveries in flight at once. Defaults to 100. */
1442
+ concurrency?: number | null;
1443
+ /** Most deliveries started per period. The period defaults to one second. */
1444
+ rateLimit?: {
1445
+ count: number;
1446
+ period?: ConfigV4QueueDuration;
1447
+ } | null;
1448
+ /** Keep messages that run out of attempts for inspection and redrive. Defaults to `true`. */
1449
+ deadLetter?: boolean;
1450
+ /** Cron schedules that send a message into this queue, keyed by schedule name. */
1451
+ schedules?: Record<string, ConfigV4QueueSchedule>;
1452
+ }
1453
+ /** A recurring send into a queue. */
1454
+ interface ConfigV4QueueSchedule {
1455
+ /** Five-field cron expression, or a macro such as `@hourly`. */
1456
+ cron: string;
1457
+ /** IANA time zone the expression is evaluated in. Defaults to `UTC`. */
1458
+ timezone?: string;
1459
+ /** Message body. Strings are sent as is; any other value is serialized as JSON. */
1460
+ body?: unknown;
1461
+ /** Content type of the body. Defaults to `text/plain` for a string body and `application/json` otherwise. */
1462
+ contentType?: string;
1463
+ /** Headers delivered with every message from this schedule. */
1464
+ headers?: Record<string, string>;
1465
+ /** Set to `false` to keep the schedule without sending. Defaults to `true`. */
1466
+ enabled?: boolean;
1199
1467
  }
1200
1468
  /** Declarative File Storage configuration for one deployment environment. */
1201
1469
  interface ConfigV4ServiceStorage extends ConfigV4Service {
@@ -1237,9 +1505,17 @@ interface ConfigV4FunctionSettings {
1237
1505
  */
1238
1506
  max_duration?: number;
1239
1507
  /**
1240
- * The runtime to use for the function.
1508
+ * The runtime to use for the function. `docker` builds the matched file as a
1509
+ * Dockerfile, with its directory as the build context, and runs the image as
1510
+ * the function. Routes target it by the Dockerfile's path, like any other
1511
+ * function file.
1512
+ */
1513
+ runtime?: Runtime | ContainerRuntime;
1514
+ /**
1515
+ * TCP port the image listens on. Only for `runtime: docker`. Defaults to the
1516
+ * image's first exposed port, then 8080.
1241
1517
  */
1242
- runtime?: Runtime;
1518
+ port?: number;
1243
1519
  /**
1244
1520
  * Enable function response streaming. When omitted, Node and Bun runtimes stream by default.
1245
1521
  */
@@ -1267,6 +1543,98 @@ interface ConfigV4FunctionSettings {
1267
1543
  schedule?: string;
1268
1544
  }
1269
1545
 
1546
+ /** Compose file names, in the order `docker compose` looks for them. */
1547
+ declare const COMPOSE_FILE_NAMES: readonly ["compose.yaml", "compose.yml", "docker-compose.yaml", "docker-compose.yml"];
1548
+ /**
1549
+ * Returns the synthetic entrypoint path of a container function, which routes
1550
+ * use as their `destination`.
1551
+ *
1552
+ * @example
1553
+ * ```ts
1554
+ * containerEntrypointPath('web'); // 'container:web'
1555
+ * ```
1556
+ */
1557
+ declare const containerEntrypointPath: (name: string) => string;
1558
+ /**
1559
+ * Derives the container name of a `functions` entry that runs a Dockerfile
1560
+ * (`runtime: docker`): the directory the Dockerfile sits in, plus any suffix
1561
+ * or prefix around `Dockerfile` in its file name. A root `Dockerfile` is `app`,
1562
+ * and a name that would not start with a letter gets an `app-` prefix.
1563
+ *
1564
+ * @param file - Project-relative path of the Dockerfile
1565
+ * @returns A valid container name
1566
+ * @example
1567
+ * ```ts
1568
+ * dockerFunctionContainerName('Dockerfile'); // 'app'
1569
+ * dockerFunctionContainerName('services/api/Dockerfile'); // 'api'
1570
+ * dockerFunctionContainerName('docker/worker.Dockerfile'); // 'docker-worker'
1571
+ * dockerFunctionContainerName('services/1/Dockerfile'); // 'app-1'
1572
+ * ```
1573
+ */
1574
+ declare const dockerFunctionContainerName: (file: string) => string;
1575
+ /**
1576
+ * Splits a command string into words the way Compose does: whitespace
1577
+ * separates words, single and double quotes group them, and a backslash
1578
+ * escapes the next character outside single quotes. No shell runs.
1579
+ *
1580
+ * @param input - Command as written, e.g. `redis-server --save ""`
1581
+ * @returns The argv words
1582
+ * @throws Error when a quote is left open
1583
+ * @example
1584
+ * ```ts
1585
+ * splitCommandWords('sh -c "echo hi"'); // ['sh', '-c', 'echo hi']
1586
+ * ```
1587
+ */
1588
+ declare const splitCommandWords: (input: string) => string[];
1589
+ /**
1590
+ * Turns the `containers` map into container-function entrypoints and sidecars.
1591
+ *
1592
+ * Validates names, the bounds the v4 schema sets (so Compose-imported entries
1593
+ * fail as early as written ones), the sidecar count, and explicitly declared
1594
+ * ports that would collide inside one microVM. Ports an image only exposes are
1595
+ * checked later, once the image config is known.
1596
+ *
1597
+ * @param containers - The `containers` map, after any Compose import
1598
+ * @param projectFolder - Absolute path to the project root
1599
+ */
1600
+ declare const normalizeContainers: (containers: Readonly<Record<string, ConfigV4Container>>, projectFolder: string) => Effect.Effect<{
1601
+ entrypoints: NormalizedConfigEntrypoint[];
1602
+ sidecars: NormalizedSidecar[];
1603
+ warnings: string[];
1604
+ }, ContainerConfigError, FileSystem.FileSystem | Path.Path>;
1605
+ /**
1606
+ * Tells whether a Compose file names an application to deploy: a service
1607
+ * marked `x-gigadrive: { public: true }`, or one that builds from source.
1608
+ * Auto-detection skips a Compose file without one, such as one that only runs
1609
+ * a database for local development.
1610
+ *
1611
+ * @param composePath - Project-relative path of the Compose file
1612
+ * @param projectFolder - Absolute path to the project root
1613
+ */
1614
+ declare const composeDeclaresApp: (composePath: string, projectFolder: string) => Effect.Effect<boolean, ContainerConfigError, FileSystem.FileSystem | Path.Path>;
1615
+ /**
1616
+ * Reads a Compose file and maps its services onto `containers` entries.
1617
+ *
1618
+ * The container function is the service marked `x-gigadrive: { public: true }`,
1619
+ * or else the only service that builds from source; anything else is
1620
+ * ambiguous and fails. Every other service becomes a sidecar that the function
1621
+ * reaches by its service name, the way Compose's default network resolves it.
1622
+ * Services behind a profile are skipped, as `docker compose up` skips them.
1623
+ * Volumes, networks, health checks and restart policies have no equivalent and
1624
+ * are dropped; volumes, `extends` and override files are reported.
1625
+ *
1626
+ * Every file read (the Compose file, `.env`, `env_file`) must resolve inside
1627
+ * the project after following symbolic links.
1628
+ *
1629
+ * @param composePath - Project-relative path of the Compose file
1630
+ * @param projectFolder - Absolute path to the project root
1631
+ */
1632
+ declare const readComposeContainers: (composePath: string, projectFolder: string) => Effect.Effect<{
1633
+ containers: Record<string, ConfigV4Container>;
1634
+ publicService: string;
1635
+ warnings: string[];
1636
+ }, ContainerConfigError, FileSystem.FileSystem | Path.Path>;
1637
+
1270
1638
  /**
1271
1639
  * Identity helper providing type inference and checking for `gigadrive.ts`
1272
1640
  * config files. Using it is optional — a plain object default export works the
@@ -1297,6 +1665,36 @@ interface ConfigV4FunctionSettings {
1297
1665
  */
1298
1666
  declare const defineConfig: (config: ConfigV4) => ConfigV4;
1299
1667
 
1668
+ /** How a container project was recognized. */
1669
+ interface ContainerProjectDetection {
1670
+ /** `compose` for a Compose file, `dockerfile` for a lone root `Dockerfile`. */
1671
+ kind: 'compose' | 'dockerfile';
1672
+ /** Project-relative file the configuration came from. */
1673
+ file: string;
1674
+ /** Deployable configuration: one container function behind a catch-all route, plus any sidecars. */
1675
+ config: NormalizedConfig;
1676
+ }
1677
+ /**
1678
+ * Recognizes a project that ships as container images: a Compose file first,
1679
+ * then a `Dockerfile` at the project root.
1680
+ *
1681
+ * Callers try this only after finding neither a `gigadrive.yaml` nor a
1682
+ * framework. A framework project often carries a Compose file for local
1683
+ * databases, and deploying that file instead of the framework would change
1684
+ * what an existing project deploys. For the same reason a Compose file counts
1685
+ * only when it names an application: a service that builds from source or is
1686
+ * marked `x-gigadrive: { public: true }`. One that only runs, say, a database
1687
+ * for local development is ignored, and the root `Dockerfile` check follows.
1688
+ *
1689
+ * @param projectFolder - Absolute path to the project root
1690
+ * @returns The detection, or `undefined` when the project has neither file
1691
+ */
1692
+ declare const detectContainerProject: (projectFolder: string) => Effect.Effect<{
1693
+ kind: "dockerfile" | "compose";
1694
+ file: string;
1695
+ config: NormalizedConfig;
1696
+ } | undefined, ContainerConfigError, FileSystem.FileSystem | Path.Path>;
1697
+
1300
1698
  declare const ManifestNotFoundError_base: Schema.TaggedErrorClass<ManifestNotFoundError, "ManifestNotFoundError", {
1301
1699
  readonly _tag: Schema.tag<"ManifestNotFoundError">;
1302
1700
  } & {
@@ -1459,13 +1857,18 @@ declare const generateConfig: (framework: FrameworkDefinition, packageManager: P
1459
1857
  * User config always takes precedence; framework defaults fill gaps.
1460
1858
  *
1461
1859
  * - commands: use user's if non-empty, otherwise framework's
1462
- * - entrypoints: use user's if non-empty, otherwise framework's
1463
- * - routes: use user's if non-empty, otherwise framework's
1860
+ * - entrypoints: use user's if non-empty, otherwise framework's. Container
1861
+ * functions (`runtime: docker`) do not count: they are always kept, next to
1862
+ * whichever file functions win, because a framework never declares them.
1863
+ * - routes: use user's if any of them targets something other than a container
1864
+ * function, otherwise the framework's, preceded by the user's routes to
1865
+ * container functions so that e.g. `/api/*` wins over a framework catch-all.
1464
1866
  * - assets: use user's if it declares any sources, otherwise framework's
1465
1867
  * - excludeFiles: use user's if non-empty, otherwise framework's
1466
1868
  * - regions: always use user's (always populated from parsing)
1467
1869
  * - environmentVariables: deep merge (framework base, user overrides)
1468
1870
  * - services: always use user's (frameworks don't define services)
1871
+ * - sidecars: always use user's (frameworks don't define sidecars)
1469
1872
  * - warnings/errors: concatenate both
1470
1873
  *
1471
1874
  * @param userConfig - The config parsed from the user's config file
@@ -1499,4 +1902,4 @@ declare const filterFunctionsFromAssets: (config: NormalizedConfig) => Normalize
1499
1902
 
1500
1903
  declare const NetworkConfigLive: Layer.Layer<ConfigModuleLoader | RawConfigReader | SchemaValidator | V4ConfigParser | VercelBuildOutputParser, never, _effect_platform_FileSystem.FileSystem | _effect_platform_Path.Path>;
1501
1904
 
1502
- 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 GigadriveNextMiddlewareDescriptor, GigadriveNextMiddlewareDescriptorSchema, type GigadriveNextMiddlewareMatcher, GigadriveNextMiddlewareMatcherSchema, type GigadriveNextPrerenderManifestV1, GigadriveNextPrerenderManifestV1Schema, type GigadriveNextPrerenderOutput, GigadriveNextPrerenderOutputSchema, type GigadriveNextPrerenderSeedMethods, GigadriveNextPrerenderSeedMethodsSchema, type GigadriveNextRouteCondition, GigadriveNextRouteConditionSchema, 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, collectAssetFiles, defineConfig, detectFramework, detectPackageManager, filterFunctionsFromAssets, generateConfig, getFunctionSettings, mergeWithFrameworkDefaults, parseConfig, parseConfigRaw, parseGigadriveNextBuildManifest, parseGigadriveNextPrerenderManifest, parseStaticAssetManifest, postProcessConfig, readDependencies };
1905
+ export { ALLOWED_CONFIG_NAMES, AVAILABLE_REGIONS, AVAILABLE_RUNTIMES, COMPOSE_FILE_NAMES, CONTAINER_ENTRYPOINT_PREFIX, CONTAINER_RUNTIME, type Config, ConfigFileEmptyError, ConfigFileNotFoundError, ConfigFileParseError, ConfigModuleLoadError, ConfigModuleLoader, ConfigSchemaValidationError, type ConfigV4, type ConfigV4Container, type ConfigV4ContainerBuild, type ConfigV4FunctionSettings, type ConfigV4Queue, type ConfigV4QueueDuration, type ConfigV4QueueSchedule, type ConfigV4Service, type ConfigV4ServicePostgres, type ConfigV4ServiceRedis, type ConfigV4ServiceStorage, type ConfigV4Services, type ConfigV4StorageBucket, ConfigVersionError, ContainerConfigError, type ContainerProjectDetection, type ContainerRuntime, DEFAULT_CONTAINER_MEMORY_MB, DEFAULT_FUNCTION_DURATION_SECONDS, DEFAULT_SIDECAR_MEMORY_MB, 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 GigadriveNextMiddlewareDescriptor, GigadriveNextMiddlewareDescriptorSchema, type GigadriveNextMiddlewareMatcher, GigadriveNextMiddlewareMatcherSchema, type GigadriveNextPrerenderManifestV1, GigadriveNextPrerenderManifestV1Schema, type GigadriveNextPrerenderOutput, GigadriveNextPrerenderOutputSchema, type GigadriveNextPrerenderSeedMethods, GigadriveNextPrerenderSeedMethodsSchema, type GigadriveNextRouteCondition, GigadriveNextRouteConditionSchema, type GigadriveNextServerDescriptor, GigadriveNextServerDescriptorSchema, type GigadriveNextStaticAssetPrefix, GigadriveNextStaticAssetPrefixSchema, type JsonValue, MAX_FUNCTION_DURATION_SECONDS, MAX_SIDECARS, ManifestNotFoundError, ManifestParseError, ManifestReadError, type NeonAWSRegion, NetworkConfigLive, type NormalizedConfig, type NormalizedConfigEntrypoint, type NormalizedConfigQueue, type NormalizedConfigQueueSchedule, type NormalizedConfigRoute, type NormalizedConfigRouteHandler, type NormalizedConfigRouteMatchRequirements, type NormalizedConfigRouteMethod, type NormalizedConfigService, type NormalizedConfigServiceDefinition, type NormalizedConfigServicePostgres, type NormalizedConfigServiceQueues, type NormalizedConfigServiceRedis, type NormalizedConfigServiceStorage, type NormalizedConfigServiceType, type NormalizedConfigStorageBucket, type NormalizedContainerImageSource, type NormalizedContainerSpec, type NormalizedFramework, type NormalizedImageFit, type NormalizedImageFormat, type NormalizedImageLocalPattern, type NormalizedImagePolicy, type NormalizedImageRemotePattern, type NormalizedImageVariant, type NormalizedNextjsFramework, type NormalizedSharedArtifact, type NormalizedSidecar, type PackageManager, RawConfigReader, type Region, type Runtime, SchemaValidator, type StaticAssetHeaders, StaticAssetHeadersSchema, type StaticAssetManifest, type StaticAssetManifestEntry, StaticAssetManifestEntrySchema, type StaticAssetManifestV1, StaticAssetManifestV1Schema, type UpstashAWSRegion, V4ConfigParser, VercelBuildOutputParser, collectAssetFiles, composeDeclaresApp, containerEntrypointPath, defineConfig, detectContainerProject, detectFramework, detectPackageManager, dockerFunctionContainerName, filterFunctionsFromAssets, generateConfig, getFunctionSettings, mergeWithFrameworkDefaults, normalizeContainers, parseConfig, parseConfigRaw, parseGigadriveNextBuildManifest, parseGigadriveNextPrerenderManifest, parseStaticAssetManifest, postProcessConfig, readComposeContainers, readDependencies, splitCommandWords };