@gigadrive/network-config 4.3.7 → 4.5.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.mjs CHANGED
@@ -1,3 +1,60 @@
1
+ // src/asset-manifest.ts
2
+ import { Schema as Schema2 } from "effect";
3
+
4
+ // src/manifest-schema.ts
5
+ import { Option, Schema } from "effect";
6
+ var HTTP_HEADER_NAME = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
7
+ var HTTP_HEADER_VALUE = /^[\t\x20-\x7e\x80-\xff]*$/;
8
+ var URL_PATHNAME_FORBIDDEN_CHARACTER = /[\x00-\x1f\x7f?#\\]/;
9
+ var isUrlDotSegment = (segment) => {
10
+ const decodedDots = segment.replace(/%2e/gi, ".");
11
+ return decodedDots === "." || decodedDots === "..";
12
+ };
13
+ var isPortableRelativePath = (value, allowCurrentDirectory = false) => {
14
+ const normalized = value.replaceAll("\\", "/").replace(/^\.\//, "").replace(/\/+$/, "");
15
+ return (allowCurrentDirectory || normalized !== "" && normalized !== ".") && !normalized.startsWith("/") && !/^[A-Za-z]:/.test(normalized) && !normalized.includes(":") && !normalized.split("/").includes("..");
16
+ };
17
+ var PortableRelativePathSchema = Schema.String.pipe(Schema.filter((value) => isPortableRelativePath(value)));
18
+ var RepositoryRelativePathSchema = Schema.String.pipe(
19
+ Schema.filter((value) => isPortableRelativePath(value, true))
20
+ );
21
+ var UrlPathnameSchema = Schema.String.pipe(
22
+ Schema.filter(
23
+ (value) => value.startsWith("/") && !URL_PATHNAME_FORBIDDEN_CHARACTER.test(value) && !value.split("/").some(isUrlDotSegment)
24
+ )
25
+ );
26
+ var HttpHeaderValueSchema = Schema.String.pipe(Schema.pattern(HTTP_HEADER_VALUE));
27
+ var HttpHeadersSchema = Schema.mutable(
28
+ Schema.Record({
29
+ key: Schema.String,
30
+ value: Schema.Union(HttpHeaderValueSchema, Schema.mutable(Schema.Array(HttpHeaderValueSchema)))
31
+ })
32
+ ).pipe(Schema.filter((headers) => Object.keys(headers).every((name) => HTTP_HEADER_NAME.test(name))));
33
+ var HttpSingleValueHeadersSchema = Schema.mutable(
34
+ Schema.Record({ key: Schema.String, value: HttpHeaderValueSchema })
35
+ ).pipe(Schema.filter((headers) => Object.keys(headers).every((name) => HTTP_HEADER_NAME.test(name))));
36
+ var decodeUnknown = (schema, value) => Schema.decodeUnknownOption(schema, { onExcessProperty: "preserve" })(value).pipe(Option.getOrUndefined);
37
+ var decodeJson = (schema, content) => decodeUnknown(Schema.parseJson(schema), content);
38
+
39
+ // src/asset-manifest.ts
40
+ var StaticAssetHeadersSchema = HttpHeadersSchema;
41
+ var StaticAssetManifestEntrySchema = Schema2.mutable(
42
+ Schema2.Struct({
43
+ source: PortableRelativePathSchema,
44
+ path: UrlPathnameSchema,
45
+ status: Schema2.optional(Schema2.Int.pipe(Schema2.between(100, 599))),
46
+ headers: Schema2.optional(StaticAssetHeadersSchema),
47
+ immutable: Schema2.optional(Schema2.Boolean)
48
+ })
49
+ );
50
+ var StaticAssetManifestV1Schema = Schema2.mutable(
51
+ Schema2.Struct({
52
+ version: Schema2.Literal(1),
53
+ assets: Schema2.mutable(Schema2.Array(StaticAssetManifestEntrySchema))
54
+ })
55
+ ).pipe(Schema2.filter(({ assets }) => new Set(assets.map(({ path: path2 }) => path2)).size === assets.length));
56
+ var parseStaticAssetManifest = (content) => decodeJson(StaticAssetManifestV1Schema, content);
57
+
1
58
  // src/detection/detect-framework.ts
2
59
  import { FileSystem as FileSystem8, Path as Path6 } from "@effect/platform";
3
60
  import { Effect as Effect10 } from "effect";
@@ -335,54 +392,189 @@ var getDefaultPathMap = Effect4.fn("getDefaultPathMap")(function* (directory) {
335
392
  return result;
336
393
  });
337
394
 
395
+ // src/nextjs-constants.ts
396
+ var MAXIMUM_ENTRY_PAGE_PATHS = 50;
397
+
338
398
  // src/nextjs-manifest.ts
339
- var isRecord3 = (value) => typeof value === "object" && value !== null;
340
- var isPortableRelativePath = (value, allowCurrentDirectory = false) => {
341
- if (typeof value !== "string") return false;
342
- const normalized = value.replaceAll("\\", "/").replace(/^\.\//, "").replace(/\/+$/, "");
343
- return (allowCurrentDirectory || normalized !== "" && normalized !== ".") && !normalized.startsWith("/") && !/^[A-Za-z]:/.test(normalized) && !normalized.includes(":") && !normalized.split("/").some((segment) => segment === "..");
344
- };
345
- var isStringRecord = (value) => isRecord3(value) && Object.values(value).every((item) => typeof item === "string");
346
- var isJsonValue = (value) => {
347
- if (value === null || typeof value === "string" || typeof value === "boolean") return true;
348
- if (typeof value === "number") return Number.isFinite(value);
349
- if (Array.isArray(value)) return value.every(isJsonValue);
350
- return isRecord3(value) && Object.values(value).every(isJsonValue);
351
- };
352
- var isPrerenderOutput = (value) => isRecord3(value) && value.type === "PRERENDER" && typeof value.id === "string" && typeof value.pathname === "string" && typeof value.parentOutputId === "string" && typeof value.groupId === "number" && isRecord3(value.config) && (value.fallback === void 0 || isRecord3(value.fallback) && (value.fallback.filePath === void 0 || isPortableRelativePath(value.fallback.filePath)));
353
- var isStaticAssetPrefix = (value) => isRecord3(value) && isPortableRelativePath(value.sourceDir) && isPortableRelativePath(value.urlPrefix) && typeof value.immutable === "boolean";
354
- var isServerDescriptor = (value) => isRecord3(value) && (value.maxDuration === void 0 || typeof value.maxDuration === "number") && (value.preferredRegion === void 0 || typeof value.preferredRegion === "string" || Array.isArray(value.preferredRegion) && value.preferredRegion.every((region) => typeof region === "string")) && (value.env === void 0 || isStringRecord(value.env));
355
- var isImagePolicy = (value) => isRecord3(value) && Array.isArray(value.localPatterns) && Array.isArray(value.remotePatterns) && value.remotePatterns.every((pattern) => isRecord3(pattern) && typeof pattern.hostname === "string") && Array.isArray(value.widths) && value.widths.every((item) => typeof item === "number" && Number.isInteger(item) && item > 0) && Array.isArray(value.heights) && value.heights.every((item) => typeof item === "number" && Number.isInteger(item) && item > 0) && Array.isArray(value.qualities) && value.qualities.every((item) => typeof item === "number" && item >= 1 && item <= 100) && Array.isArray(value.formats) && value.formats.every((item) => ["image/avif", "image/webp", "image/jpeg", "image/png"].includes(String(item))) && typeof value.minimumCacheTTL === "number" && typeof value.dangerouslyAllowSVG === "boolean" && typeof value.contentSecurityPolicy === "string" && (value.contentDispositionType === "inline" || value.contentDispositionType === "attachment") && typeof value.maximumRedirects === "number" && typeof value.maximumResponseBody === "number" && isRecord3(value.variants);
356
- var parseGigadriveNextBuildManifest = (content) => {
357
- try {
358
- const value = JSON.parse(content);
359
- if (!isRecord3(value)) return void 0;
360
- if (value.version === 1) {
361
- if (value.output !== "standalone" && value.output !== "export" || !isPortableRelativePath(value.distDir) || !isPortableRelativePath(value.repoRootToProject, true) || typeof value.nextVersion !== "string" || typeof value.buildId !== "string") {
362
- return void 0;
363
- }
364
- return value;
365
- }
366
- if (value.version === 2) {
367
- if (!isPortableRelativePath(value.distDir) || !isPortableRelativePath(value.repoRootToProject, true) || typeof value.nextVersion !== "string" || typeof value.buildId !== "string") {
368
- return void 0;
369
- }
370
- if (value.mode === "export") {
371
- return value;
372
- }
373
- if (value.mode === "standalone-v2") {
374
- if (!isServerDescriptor(value.server) || !isRecord3(value.config) || typeof value.config.basePath !== "string" || typeof value.config.trailingSlash !== "boolean" || typeof value.config.cacheComponents !== "boolean" || value.config.images !== void 0 && !isImagePolicy(value.config.images) || !isRecord3(value.routing) || !isJsonValue(value.routing) || !isRecord3(value.outputs) || !Array.isArray(value.outputs.prerenders) || !value.outputs.prerenders.every(isPrerenderOutput) || !Array.isArray(value.outputs.staticAssets) || !value.outputs.staticAssets.every(isStaticAssetPrefix)) {
375
- return void 0;
376
- }
377
- return value;
378
- }
379
- return void 0;
380
- }
381
- return void 0;
382
- } catch {
383
- return void 0;
384
- }
385
- };
399
+ import { Schema as Schema3 } from "effect";
400
+ var StringArraySchema = Schema3.mutable(Schema3.Array(Schema3.String));
401
+ var StringRecordSchema = Schema3.mutable(Schema3.Record({ key: Schema3.String, value: Schema3.String }));
402
+ var JsonValueSchema = Schema3.suspend(
403
+ () => Schema3.Union(
404
+ Schema3.Null,
405
+ Schema3.Boolean,
406
+ Schema3.Number,
407
+ Schema3.String,
408
+ Schema3.mutable(Schema3.Array(JsonValueSchema)),
409
+ Schema3.mutable(Schema3.Record({ key: Schema3.String, value: JsonValueSchema }))
410
+ )
411
+ );
412
+ var ImageLocalPatternSchema = Schema3.mutable(
413
+ Schema3.Struct({
414
+ pathname: Schema3.optional(Schema3.String),
415
+ search: Schema3.optional(Schema3.String)
416
+ })
417
+ );
418
+ var ImageRemotePatternSchema = Schema3.mutable(
419
+ Schema3.Struct({
420
+ protocol: Schema3.optional(Schema3.Literal("http", "https")),
421
+ hostname: Schema3.String,
422
+ port: Schema3.optional(Schema3.String),
423
+ pathname: Schema3.optional(Schema3.String),
424
+ search: Schema3.optional(Schema3.String)
425
+ })
426
+ );
427
+ var ImageVariantSchema = Schema3.mutable(
428
+ Schema3.Struct({
429
+ width: Schema3.optional(Schema3.Number),
430
+ height: Schema3.optional(Schema3.Number),
431
+ quality: Schema3.optional(Schema3.Number),
432
+ format: Schema3.optional(Schema3.Literal("image/avif", "image/webp", "image/jpeg", "image/png")),
433
+ fit: Schema3.optional(Schema3.Literal("contain", "cover", "fill", "inside", "outside"))
434
+ })
435
+ );
436
+ var PositiveIntSchema = Schema3.Int.pipe(Schema3.greaterThan(0));
437
+ var ImagePolicySchema = Schema3.mutable(
438
+ Schema3.Struct({
439
+ localPatterns: Schema3.mutable(Schema3.Array(ImageLocalPatternSchema)),
440
+ remotePatterns: Schema3.mutable(Schema3.Array(ImageRemotePatternSchema)),
441
+ widths: Schema3.mutable(Schema3.Array(PositiveIntSchema)),
442
+ heights: Schema3.mutable(Schema3.Array(PositiveIntSchema)),
443
+ qualities: Schema3.mutable(Schema3.Array(Schema3.Number.pipe(Schema3.between(1, 100)))),
444
+ formats: Schema3.mutable(Schema3.Array(Schema3.Literal("image/avif", "image/webp", "image/jpeg", "image/png"))),
445
+ minimumCacheTTL: Schema3.Number,
446
+ dangerouslyAllowSVG: Schema3.Boolean,
447
+ contentSecurityPolicy: Schema3.String,
448
+ contentDispositionType: Schema3.Literal("inline", "attachment"),
449
+ maximumRedirects: Schema3.Number,
450
+ maximumResponseBody: Schema3.Number,
451
+ variants: Schema3.mutable(Schema3.Record({ key: Schema3.String, value: ImageVariantSchema }))
452
+ })
453
+ );
454
+ var GigadriveNextPrerenderOutputSchema = Schema3.mutable(
455
+ Schema3.Struct({
456
+ id: Schema3.String,
457
+ type: Schema3.Literal("PRERENDER"),
458
+ pathname: UrlPathnameSchema,
459
+ parentOutputId: Schema3.String,
460
+ groupId: Schema3.Number,
461
+ pprChain: Schema3.optional(Schema3.mutable(Schema3.Struct({ headers: HttpSingleValueHeadersSchema }))),
462
+ parentFallbackMode: Schema3.optional(JsonValueSchema),
463
+ fallback: Schema3.optional(
464
+ Schema3.mutable(
465
+ Schema3.Struct({
466
+ filePath: Schema3.optional(PortableRelativePathSchema),
467
+ initialStatus: Schema3.optional(Schema3.Int.pipe(Schema3.between(100, 599))),
468
+ initialHeaders: Schema3.optional(HttpHeadersSchema),
469
+ initialExpiration: Schema3.optional(Schema3.Number),
470
+ initialRevalidate: Schema3.optional(Schema3.Union(Schema3.Number, Schema3.Literal(false))),
471
+ postponedState: Schema3.optional(Schema3.String)
472
+ })
473
+ )
474
+ ),
475
+ config: Schema3.mutable(
476
+ Schema3.Struct({
477
+ allowQuery: Schema3.optional(StringArraySchema),
478
+ allowHeader: Schema3.optional(StringArraySchema),
479
+ bypassFor: Schema3.optional(Schema3.mutable(Schema3.Array(JsonValueSchema))),
480
+ renderingMode: Schema3.optional(Schema3.String),
481
+ partialFallback: Schema3.optional(Schema3.Boolean),
482
+ bypassToken: Schema3.optional(Schema3.String)
483
+ })
484
+ )
485
+ })
486
+ );
487
+ var GigadriveNextStaticAssetPrefixSchema = Schema3.mutable(
488
+ Schema3.Struct({
489
+ sourceDir: PortableRelativePathSchema,
490
+ urlPrefix: PortableRelativePathSchema,
491
+ immutable: Schema3.Boolean
492
+ })
493
+ );
494
+ var GigadriveNextServerDescriptorSchema = Schema3.mutable(
495
+ Schema3.Struct({
496
+ maxDuration: Schema3.optional(Schema3.Number),
497
+ preferredRegion: Schema3.optional(Schema3.Union(Schema3.String, StringArraySchema)),
498
+ env: Schema3.optional(StringRecordSchema)
499
+ })
500
+ );
501
+ var PrerenderArraySchema = Schema3.mutable(Schema3.Array(GigadriveNextPrerenderOutputSchema));
502
+ var StaticAssetArraySchema = Schema3.mutable(Schema3.Array(GigadriveNextStaticAssetPrefixSchema));
503
+ var JsonValueArraySchema = Schema3.mutable(Schema3.Array(JsonValueSchema));
504
+ var GigadriveNextBuildManifestV1Schema = Schema3.mutable(
505
+ Schema3.Struct({
506
+ version: Schema3.Literal(1),
507
+ output: Schema3.Literal("standalone", "export"),
508
+ distDir: PortableRelativePathSchema,
509
+ repoRootToProject: RepositoryRelativePathSchema,
510
+ nextVersion: Schema3.String,
511
+ buildId: Schema3.String
512
+ })
513
+ );
514
+ var GigadriveNextBuildManifestV2ExportSchema = Schema3.mutable(
515
+ Schema3.Struct({
516
+ version: Schema3.Literal(2),
517
+ mode: Schema3.Literal("export"),
518
+ distDir: PortableRelativePathSchema,
519
+ repoRootToProject: RepositoryRelativePathSchema,
520
+ nextVersion: Schema3.String,
521
+ buildId: Schema3.String
522
+ })
523
+ );
524
+ var GigadriveNextBuildManifestV2StandaloneSchema = Schema3.mutable(
525
+ Schema3.Struct({
526
+ version: Schema3.Literal(2),
527
+ mode: Schema3.Literal("standalone-v2"),
528
+ distDir: PortableRelativePathSchema,
529
+ repoRootToProject: RepositoryRelativePathSchema,
530
+ nextVersion: Schema3.String,
531
+ buildId: Schema3.String,
532
+ server: GigadriveNextServerDescriptorSchema,
533
+ config: Schema3.mutable(
534
+ Schema3.Struct({
535
+ basePath: Schema3.String,
536
+ trailingSlash: Schema3.Boolean,
537
+ cacheComponents: Schema3.Boolean,
538
+ i18n: Schema3.optional(JsonValueSchema),
539
+ images: Schema3.optional(ImagePolicySchema)
540
+ })
541
+ ),
542
+ routing: Schema3.mutable(
543
+ Schema3.Struct({
544
+ beforeMiddleware: JsonValueArraySchema,
545
+ beforeFiles: JsonValueArraySchema,
546
+ afterFiles: JsonValueArraySchema,
547
+ dynamicRoutes: JsonValueArraySchema,
548
+ onMatch: JsonValueArraySchema,
549
+ fallback: JsonValueArraySchema,
550
+ shouldNormalizeNextData: Schema3.Boolean,
551
+ rsc: JsonValueSchema
552
+ })
553
+ ),
554
+ outputs: Schema3.mutable(
555
+ Schema3.Struct({
556
+ prerenders: PrerenderArraySchema,
557
+ prerenderManifest: Schema3.optional(PortableRelativePathSchema),
558
+ assetManifest: Schema3.optional(PortableRelativePathSchema),
559
+ entryPagePaths: Schema3.optional(Schema3.mutable(Schema3.Array(UrlPathnameSchema))),
560
+ staticAssets: StaticAssetArraySchema
561
+ })
562
+ )
563
+ })
564
+ );
565
+ var GigadriveNextBuildManifestSchema = Schema3.Union(
566
+ GigadriveNextBuildManifestV1Schema,
567
+ GigadriveNextBuildManifestV2ExportSchema,
568
+ GigadriveNextBuildManifestV2StandaloneSchema
569
+ );
570
+ var GigadriveNextPrerenderManifestV1Schema = Schema3.mutable(
571
+ Schema3.Struct({
572
+ version: Schema3.Literal(1),
573
+ prerenders: PrerenderArraySchema
574
+ })
575
+ );
576
+ var parseGigadriveNextBuildManifest = (content) => decodeJson(GigadriveNextBuildManifestSchema, content);
577
+ var parseGigadriveNextPrerenderManifest = (content) => decodeJson(GigadriveNextPrerenderManifestV1Schema, content);
386
578
 
387
579
  // src/regions.ts
388
580
  var REGION_DEFINITIONS = [
@@ -408,7 +600,6 @@ var AVAILABLE_REGIONS = [...REGION_DEFINITIONS];
408
600
 
409
601
  // src/detection/frameworks/nextjs.ts
410
602
  var toPortablePath = (value) => value.replaceAll("\\", "/");
411
- var MAXIMUM_ENTRY_PAGE_PATHS = 50;
412
603
  var STANDALONE_SERVER_MEMORY_MB = 1024;
413
604
  var resolveStandaloneServer = Effect5.fn("nextjs.resolveStandaloneServer")(function* (projectFolder, distDir, repoRootToProject) {
414
605
  const fs = yield* FileSystem5.FileSystem;
@@ -513,9 +704,11 @@ var createStandaloneV2Config = Effect5.fn("nextjs.createStandaloneV2Config")(fun
513
704
  immutable: staticAsset.immutable,
514
705
  populateCache: true
515
706
  }));
516
- const entryPagePaths = [
707
+ const assetManifests = manifest.outputs.assetManifest ? [{ source: manifest.outputs.assetManifest }] : void 0;
708
+ const { entryPagePaths: manifestEntryPagePaths, ...manifestOutputs } = manifest.outputs;
709
+ const entryPagePaths = manifestEntryPagePaths?.slice(0, MAXIMUM_ENTRY_PAGE_PATHS) ?? [
517
710
  ...new Set(
518
- manifest.outputs.prerenders.filter((output) => !output.fallback?.postponedState).map((output) => output.pathname).filter((pathname) => pathname.startsWith("/") && !pathname.includes("["))
711
+ manifest.outputs.prerenders.filter((output) => output.fallback?.postponedState === void 0).map((output) => output.pathname).filter((pathname) => pathname.startsWith("/") && !pathname.includes("["))
519
712
  )
520
713
  ].sort((left, right) => left.split("/").length - right.split("/").length || left.localeCompare(right)).slice(0, MAXIMUM_ENTRY_PAGE_PATHS);
521
714
  const singleEntrypoint = {
@@ -544,10 +737,9 @@ var createStandaloneV2Config = Effect5.fn("nextjs.createStandaloneV2Config")(fun
544
737
  server: manifest.server,
545
738
  config: manifest.config,
546
739
  routing: manifest.routing,
547
- // The prerender table is deliberately not forwarded: the standalone server
548
- // serves build-time prerenders from its own bundle, so the platform only
549
- // needs the warming sample below.
550
- outputs: { prerenders: [], staticAssets: manifest.outputs.staticAssets },
740
+ // Keep high-cardinality output metadata in portable sidecars rather than
741
+ // expanding it into normalized deployment configuration.
742
+ outputs: { ...manifestOutputs, prerenders: [] },
551
743
  entryPagePaths,
552
744
  type: "nextjs",
553
745
  schemaVersion: 2
@@ -559,6 +751,7 @@ var createStandaloneV2Config = Effect5.fn("nextjs.createStandaloneV2Config")(fun
559
751
  assetPaths,
560
752
  assetOverrides,
561
753
  assetPrefixes,
754
+ assetManifests,
562
755
  assetsDir: manifest.distDir,
563
756
  assetsPrefixToStrip: "",
564
757
  populateAssetCache: true,
@@ -820,12 +1013,13 @@ var generateConfig = Effect7.fn("generateConfig")(function* (framework, packageM
820
1013
  errors: [],
821
1014
  ...defaults.normalizedConfig
822
1015
  };
823
- if (defaults.assetsDir || defaults.assetPaths || defaults.assetPrefixes) {
1016
+ if (defaults.assetsDir || defaults.assetPaths || defaults.assetPrefixes || defaults.assetManifests) {
824
1017
  config.assets = {
825
1018
  paths: defaults.assetPaths ? [...defaults.assetPaths] : [],
826
1019
  prefixToStrip: defaults.assetsPrefixToStrip ?? (defaults.assetsDir ? defaults.assetsDir + "/" : ""),
827
1020
  overrides: defaults.assetOverrides ? { ...defaults.assetOverrides } : void 0,
828
1021
  prefixes: defaults.assetPrefixes ? defaults.assetPrefixes.map((prefix) => ({ ...prefix })) : void 0,
1022
+ manifests: defaults.assetManifests ? defaults.assetManifests.map((manifest) => ({ ...manifest })) : void 0,
829
1023
  dynamicRoutes: true,
830
1024
  populateCache: defaults.populateAssetCache ?? false
831
1025
  };
@@ -838,27 +1032,27 @@ import { FileSystem as FileSystem7, Path as Path5 } from "@effect/platform";
838
1032
  import { Effect as Effect9 } from "effect";
839
1033
 
840
1034
  // src/detection/types.ts
841
- import { Schema } from "effect";
842
- var ManifestNotFoundError = class extends Schema.TaggedError()("ManifestNotFoundError", {
843
- message: Schema.String,
844
- filePath: Schema.String
1035
+ import { Schema as Schema4 } from "effect";
1036
+ var ManifestNotFoundError = class extends Schema4.TaggedError()("ManifestNotFoundError", {
1037
+ message: Schema4.String,
1038
+ filePath: Schema4.String
845
1039
  }) {
846
1040
  };
847
- var ManifestReadError = class extends Schema.TaggedError()("ManifestReadError", {
848
- message: Schema.String,
849
- filePath: Schema.String
1041
+ var ManifestReadError = class extends Schema4.TaggedError()("ManifestReadError", {
1042
+ message: Schema4.String,
1043
+ filePath: Schema4.String
850
1044
  }) {
851
1045
  };
852
- var ManifestParseError = class extends Schema.TaggedError()("ManifestParseError", {
853
- message: Schema.String,
854
- filePath: Schema.String
1046
+ var ManifestParseError = class extends Schema4.TaggedError()("ManifestParseError", {
1047
+ message: Schema4.String,
1048
+ filePath: Schema4.String
855
1049
  }) {
856
1050
  };
857
- var FrameworkNotDetectedError = class extends Schema.TaggedError()(
1051
+ var FrameworkNotDetectedError = class extends Schema4.TaggedError()(
858
1052
  "FrameworkNotDetectedError",
859
1053
  {
860
- message: Schema.String,
861
- directory: Schema.String
1054
+ message: Schema4.String,
1055
+ directory: Schema4.String
862
1056
  }
863
1057
  ) {
864
1058
  };
@@ -974,12 +1168,13 @@ var detectFramework = Effect10.fn("detectFramework")(function* (projectFolder) {
974
1168
  import { Effect as Effect11 } from "effect";
975
1169
  var mergeWithFrameworkDefaults = Effect11.fn("mergeWithFrameworkDefaults")(function* (userConfig, frameworkConfig) {
976
1170
  yield* Effect11.logDebug("Merging user config with framework defaults");
1171
+ const userHasAssets = (userConfig.assets?.paths?.length ?? 0) > 0 || (userConfig.assets?.prefixes?.length ?? 0) > 0 || (userConfig.assets?.manifests?.length ?? 0) > 0;
977
1172
  const merged = {
978
1173
  regions: userConfig.regions,
979
1174
  commands: userConfig.commands.length > 0 ? userConfig.commands : frameworkConfig.commands,
980
1175
  entrypoints: userConfig.entrypoints.length > 0 ? userConfig.entrypoints : frameworkConfig.entrypoints,
981
1176
  routes: userConfig.routes.length > 0 ? userConfig.routes : frameworkConfig.routes,
982
- assets: userConfig.assets?.paths && userConfig.assets.paths.length > 0 ? userConfig.assets : frameworkConfig.assets,
1177
+ assets: userHasAssets ? userConfig.assets : frameworkConfig.assets,
983
1178
  environmentVariables: {
984
1179
  ...frameworkConfig.environmentVariables,
985
1180
  ...userConfig.environmentVariables
@@ -994,41 +1189,41 @@ var mergeWithFrameworkDefaults = Effect11.fn("mergeWithFrameworkDefaults")(funct
994
1189
  });
995
1190
 
996
1191
  // src/errors.ts
997
- import { Schema as Schema2 } from "effect";
998
- var ConfigFileNotFoundError = class extends Schema2.TaggedError()("ConfigFileNotFoundError", {
999
- message: Schema2.String,
1000
- filePath: Schema2.String
1192
+ import { Schema as Schema5 } from "effect";
1193
+ var ConfigFileNotFoundError = class extends Schema5.TaggedError()("ConfigFileNotFoundError", {
1194
+ message: Schema5.String,
1195
+ filePath: Schema5.String
1001
1196
  }) {
1002
1197
  };
1003
- var ConfigFileEmptyError = class extends Schema2.TaggedError()("ConfigFileEmptyError", {
1004
- message: Schema2.String,
1005
- filePath: Schema2.String
1198
+ var ConfigFileEmptyError = class extends Schema5.TaggedError()("ConfigFileEmptyError", {
1199
+ message: Schema5.String,
1200
+ filePath: Schema5.String
1006
1201
  }) {
1007
1202
  };
1008
- var ConfigFileParseError = class extends Schema2.TaggedError()("ConfigFileParseError", {
1009
- message: Schema2.String,
1010
- filePath: Schema2.String,
1011
- cause: Schema2.optional(Schema2.String)
1203
+ var ConfigFileParseError = class extends Schema5.TaggedError()("ConfigFileParseError", {
1204
+ message: Schema5.String,
1205
+ filePath: Schema5.String,
1206
+ cause: Schema5.optional(Schema5.String)
1012
1207
  }) {
1013
1208
  };
1014
- var ConfigVersionError = class extends Schema2.TaggedError()("ConfigVersionError", {
1015
- message: Schema2.String,
1016
- filePath: Schema2.String,
1017
- version: Schema2.optional(Schema2.Number)
1209
+ var ConfigVersionError = class extends Schema5.TaggedError()("ConfigVersionError", {
1210
+ message: Schema5.String,
1211
+ filePath: Schema5.String,
1212
+ version: Schema5.optional(Schema5.Number)
1018
1213
  }) {
1019
1214
  };
1020
- var ConfigSchemaValidationError = class extends Schema2.TaggedError()(
1215
+ var ConfigSchemaValidationError = class extends Schema5.TaggedError()(
1021
1216
  "ConfigSchemaValidationError",
1022
1217
  {
1023
- message: Schema2.String,
1024
- filePath: Schema2.String,
1025
- validationErrors: Schema2.Array(Schema2.String)
1218
+ message: Schema5.String,
1219
+ filePath: Schema5.String,
1220
+ validationErrors: Schema5.Array(Schema5.String)
1026
1221
  }
1027
1222
  ) {
1028
1223
  };
1029
- var FunctionConfigError = class extends Schema2.TaggedError()("FunctionConfigError", {
1030
- message: Schema2.String,
1031
- functionPath: Schema2.String
1224
+ var FunctionConfigError = class extends Schema5.TaggedError()("FunctionConfigError", {
1225
+ message: Schema5.String,
1226
+ functionPath: Schema5.String
1032
1227
  }) {
1033
1228
  };
1034
1229
 
@@ -1199,6 +1394,23 @@ var normalizeImagePolicy = (images) => {
1199
1394
  variants: images.variants ?? {}
1200
1395
  };
1201
1396
  };
1397
+ var normalizeServices = (services) => {
1398
+ if (services == null) return void 0;
1399
+ const normalized = [];
1400
+ if (services.redis !== void 0) {
1401
+ normalized.push({ type: "redis", ...services.redis ?? {} });
1402
+ }
1403
+ if (services.postgres !== void 0) {
1404
+ normalized.push({ type: "postgres", ...services.postgres ?? {} });
1405
+ }
1406
+ if (services.storage !== void 0) {
1407
+ normalized.push({
1408
+ type: "storage",
1409
+ buckets: Object.entries(services.storage.buckets).map(([name, bucket]) => ({ name, visibility: bucket?.visibility ?? "private" })).sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0)
1410
+ });
1411
+ }
1412
+ return normalized.length > 0 ? normalized : void 0;
1413
+ };
1202
1414
  var normalizeRouteDestination = (destination) => {
1203
1415
  const [withoutHash] = destination.split("#", 1);
1204
1416
  const [withoutQuery] = withoutHash.split("?", 1);
@@ -1362,6 +1574,7 @@ var V4ConfigParser = class extends Effect14.Service()("V4ConfigParser", {
1362
1574
  environmentVariables: config.env ?? {},
1363
1575
  commands: config.build_commands ?? [],
1364
1576
  images: normalizeImagePolicy(config.images),
1577
+ services: normalizeServices(config.services),
1365
1578
  entrypoints,
1366
1579
  errors: [],
1367
1580
  warnings: [],
@@ -1879,7 +2092,8 @@ var schema_default = {
1879
2092
  },
1880
2093
  services: {
1881
2094
  type: "object",
1882
- description: "Optionally, specify additional services like databases to deploy.",
2095
+ description: "Managed services to provision for the deployment environment.",
2096
+ additionalProperties: false,
1883
2097
  properties: {
1884
2098
  redis: {
1885
2099
  oneOf: [
@@ -1993,6 +2207,39 @@ var schema_default = {
1993
2207
  }
1994
2208
  }
1995
2209
  ]
2210
+ },
2211
+ storage: {
2212
+ type: "object",
2213
+ required: ["buckets"],
2214
+ additionalProperties: false,
2215
+ description: "File Storage buckets to provision in the deployment environment. The environment and global delivery/S3 slug are assigned by the platform.",
2216
+ properties: {
2217
+ buckets: {
2218
+ type: "object",
2219
+ description: "Buckets keyed by immutable environment-scoped name. Use null or an empty object for the default private visibility.",
2220
+ propertyNames: {
2221
+ minLength: 3,
2222
+ maxLength: 63,
2223
+ pattern: "^(?![0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$)[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$"
2224
+ },
2225
+ additionalProperties: {
2226
+ oneOf: [
2227
+ { type: "null" },
2228
+ {
2229
+ type: "object",
2230
+ additionalProperties: false,
2231
+ properties: {
2232
+ visibility: {
2233
+ type: "string",
2234
+ enum: ["public", "private"],
2235
+ description: "Bucket access policy. Defaults to private when omitted. Public buckets can serve objects through their CDN hostname."
2236
+ }
2237
+ }
2238
+ }
2239
+ ]
2240
+ }
2241
+ }
2242
+ }
1996
2243
  }
1997
2244
  }
1998
2245
  }
@@ -2083,11 +2330,12 @@ var parseConfig = Effect16.fn("parseConfig")(function* (filePath, projectFolder)
2083
2330
  var postProcessConfig = Effect16.fn("postProcessConfig")(function* (config, projectFolder) {
2084
2331
  const vercelParser = yield* VercelBuildOutputParser;
2085
2332
  let result = yield* vercelParser.parse(config, projectFolder);
2086
- if (result.entrypoints.length === 0 && (result.assets?.paths?.length || 0) === 0 && result.routes.length === 0) {
2333
+ const hasAssets = (result.assets?.paths?.length ?? 0) > 0 || (result.assets?.prefixes?.length ?? 0) > 0 || (result.assets?.manifests?.length ?? 0) > 0;
2334
+ if (result.entrypoints.length === 0 && !hasAssets && result.routes.length === 0) {
2087
2335
  result.errors.push(
2088
2336
  "The current project config does not resolve to any functions, assets or routes and can not be deployed."
2089
2337
  );
2090
- } else if (result.entrypoints.length === 0 && (result.assets?.paths?.length || 0) === 0) {
2338
+ } else if (result.entrypoints.length === 0 && !hasAssets) {
2091
2339
  result.warnings.push("The current project does not have any functions or assets to deploy.");
2092
2340
  }
2093
2341
  result = filterFunctionsFromAssets(result);
@@ -2124,6 +2372,14 @@ export {
2124
2372
  FRAMEWORK_DEFINITIONS,
2125
2373
  FrameworkNotDetectedError,
2126
2374
  FunctionConfigError,
2375
+ GigadriveNextBuildManifestSchema,
2376
+ GigadriveNextBuildManifestV1Schema,
2377
+ GigadriveNextBuildManifestV2ExportSchema,
2378
+ GigadriveNextBuildManifestV2StandaloneSchema,
2379
+ GigadriveNextPrerenderManifestV1Schema,
2380
+ GigadriveNextPrerenderOutputSchema,
2381
+ GigadriveNextServerDescriptorSchema,
2382
+ GigadriveNextStaticAssetPrefixSchema,
2127
2383
  MAX_FUNCTION_DURATION_SECONDS,
2128
2384
  ManifestNotFoundError,
2129
2385
  ManifestParseError,
@@ -2131,6 +2387,9 @@ export {
2131
2387
  NetworkConfigLive,
2132
2388
  RawConfigReader,
2133
2389
  SchemaValidator,
2390
+ StaticAssetHeadersSchema,
2391
+ StaticAssetManifestEntrySchema,
2392
+ StaticAssetManifestV1Schema,
2134
2393
  V4ConfigParser,
2135
2394
  VercelBuildOutputParser,
2136
2395
  detectFramework,
@@ -2142,6 +2401,8 @@ export {
2142
2401
  parseConfig,
2143
2402
  parseConfigRaw,
2144
2403
  parseGigadriveNextBuildManifest,
2404
+ parseGigadriveNextPrerenderManifest,
2405
+ parseStaticAssetManifest,
2145
2406
  postProcessConfig,
2146
2407
  readDependencies
2147
2408
  };