astro 5.0.9 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -662,6 +662,71 @@ export declare const AstroConfigSchema: z.ZodObject<{
662
662
  clientPrerender: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
663
663
  contentIntellisense: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
664
664
  responsiveImages: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
665
+ session: z.ZodOptional<z.ZodObject<{
666
+ driver: z.ZodString;
667
+ options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
668
+ cookie: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodObject<{
669
+ name: z.ZodOptional<z.ZodString>;
670
+ domain: z.ZodOptional<z.ZodString>;
671
+ path: z.ZodOptional<z.ZodString>;
672
+ maxAge: z.ZodOptional<z.ZodNumber>;
673
+ sameSite: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["strict", "lax", "none"]>, z.ZodBoolean]>>;
674
+ secure: z.ZodOptional<z.ZodBoolean>;
675
+ }, "strip", z.ZodTypeAny, {
676
+ domain?: string | undefined;
677
+ path?: string | undefined;
678
+ maxAge?: number | undefined;
679
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
680
+ secure?: boolean | undefined;
681
+ name?: string | undefined;
682
+ }, {
683
+ domain?: string | undefined;
684
+ path?: string | undefined;
685
+ maxAge?: number | undefined;
686
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
687
+ secure?: boolean | undefined;
688
+ name?: string | undefined;
689
+ }>, z.ZodString]>, {
690
+ domain?: string | undefined;
691
+ path?: string | undefined;
692
+ maxAge?: number | undefined;
693
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
694
+ secure?: boolean | undefined;
695
+ name?: string | undefined;
696
+ }, string | {
697
+ domain?: string | undefined;
698
+ path?: string | undefined;
699
+ maxAge?: number | undefined;
700
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
701
+ secure?: boolean | undefined;
702
+ name?: string | undefined;
703
+ }>>;
704
+ ttl: z.ZodOptional<z.ZodNumber>;
705
+ }, "strip", z.ZodTypeAny, {
706
+ driver: string;
707
+ cookie?: {
708
+ domain?: string | undefined;
709
+ path?: string | undefined;
710
+ maxAge?: number | undefined;
711
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
712
+ secure?: boolean | undefined;
713
+ name?: string | undefined;
714
+ } | undefined;
715
+ options?: Record<string, any> | undefined;
716
+ ttl?: number | undefined;
717
+ }, {
718
+ driver: string;
719
+ cookie?: string | {
720
+ domain?: string | undefined;
721
+ path?: string | undefined;
722
+ maxAge?: number | undefined;
723
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
724
+ secure?: boolean | undefined;
725
+ name?: string | undefined;
726
+ } | undefined;
727
+ options?: Record<string, any> | undefined;
728
+ ttl?: number | undefined;
729
+ }>>;
665
730
  svg: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodOptional<z.ZodObject<{
666
731
  mode: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"inline">, z.ZodLiteral<"sprite">]>>;
667
732
  }, "strip", z.ZodTypeAny, {
@@ -680,6 +745,19 @@ export declare const AstroConfigSchema: z.ZodObject<{
680
745
  svg?: {
681
746
  mode?: "inline" | "sprite" | undefined;
682
747
  } | undefined;
748
+ session?: {
749
+ driver: string;
750
+ cookie?: {
751
+ domain?: string | undefined;
752
+ path?: string | undefined;
753
+ maxAge?: number | undefined;
754
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
755
+ secure?: boolean | undefined;
756
+ name?: string | undefined;
757
+ } | undefined;
758
+ options?: Record<string, any> | undefined;
759
+ ttl?: number | undefined;
760
+ } | undefined;
683
761
  }, {
684
762
  clientPrerender?: boolean | undefined;
685
763
  contentIntellisense?: boolean | undefined;
@@ -687,6 +765,19 @@ export declare const AstroConfigSchema: z.ZodObject<{
687
765
  svg?: boolean | {
688
766
  mode?: "inline" | "sprite" | undefined;
689
767
  } | undefined;
768
+ session?: {
769
+ driver: string;
770
+ cookie?: string | {
771
+ domain?: string | undefined;
772
+ path?: string | undefined;
773
+ maxAge?: number | undefined;
774
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
775
+ secure?: boolean | undefined;
776
+ name?: string | undefined;
777
+ } | undefined;
778
+ options?: Record<string, any> | undefined;
779
+ ttl?: number | undefined;
780
+ } | undefined;
690
781
  }>>;
691
782
  legacy: z.ZodDefault<z.ZodObject<{
692
783
  collections: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
@@ -829,6 +920,19 @@ export declare const AstroConfigSchema: z.ZodObject<{
829
920
  svg?: {
830
921
  mode?: "inline" | "sprite" | undefined;
831
922
  } | undefined;
923
+ session?: {
924
+ driver: string;
925
+ cookie?: {
926
+ domain?: string | undefined;
927
+ path?: string | undefined;
928
+ maxAge?: number | undefined;
929
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
930
+ secure?: boolean | undefined;
931
+ name?: string | undefined;
932
+ } | undefined;
933
+ options?: Record<string, any> | undefined;
934
+ ttl?: number | undefined;
935
+ } | undefined;
832
936
  };
833
937
  legacy: {
834
938
  collections: boolean;
@@ -1005,6 +1109,19 @@ export declare const AstroConfigSchema: z.ZodObject<{
1005
1109
  svg?: boolean | {
1006
1110
  mode?: "inline" | "sprite" | undefined;
1007
1111
  } | undefined;
1112
+ session?: {
1113
+ driver: string;
1114
+ cookie?: string | {
1115
+ domain?: string | undefined;
1116
+ path?: string | undefined;
1117
+ maxAge?: number | undefined;
1118
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
1119
+ secure?: boolean | undefined;
1120
+ name?: string | undefined;
1121
+ } | undefined;
1122
+ options?: Record<string, any> | undefined;
1123
+ ttl?: number | undefined;
1124
+ } | undefined;
1008
1125
  } | undefined;
1009
1126
  legacy?: {
1010
1127
  collections?: boolean | undefined;
@@ -1603,6 +1720,71 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1603
1720
  clientPrerender: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1604
1721
  contentIntellisense: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1605
1722
  responsiveImages: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1723
+ session: z.ZodOptional<z.ZodObject<{
1724
+ driver: z.ZodString;
1725
+ options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1726
+ cookie: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodObject<{
1727
+ name: z.ZodOptional<z.ZodString>;
1728
+ domain: z.ZodOptional<z.ZodString>;
1729
+ path: z.ZodOptional<z.ZodString>;
1730
+ maxAge: z.ZodOptional<z.ZodNumber>;
1731
+ sameSite: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["strict", "lax", "none"]>, z.ZodBoolean]>>;
1732
+ secure: z.ZodOptional<z.ZodBoolean>;
1733
+ }, "strip", z.ZodTypeAny, {
1734
+ domain?: string | undefined;
1735
+ path?: string | undefined;
1736
+ maxAge?: number | undefined;
1737
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
1738
+ secure?: boolean | undefined;
1739
+ name?: string | undefined;
1740
+ }, {
1741
+ domain?: string | undefined;
1742
+ path?: string | undefined;
1743
+ maxAge?: number | undefined;
1744
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
1745
+ secure?: boolean | undefined;
1746
+ name?: string | undefined;
1747
+ }>, z.ZodString]>, {
1748
+ domain?: string | undefined;
1749
+ path?: string | undefined;
1750
+ maxAge?: number | undefined;
1751
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
1752
+ secure?: boolean | undefined;
1753
+ name?: string | undefined;
1754
+ }, string | {
1755
+ domain?: string | undefined;
1756
+ path?: string | undefined;
1757
+ maxAge?: number | undefined;
1758
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
1759
+ secure?: boolean | undefined;
1760
+ name?: string | undefined;
1761
+ }>>;
1762
+ ttl: z.ZodOptional<z.ZodNumber>;
1763
+ }, "strip", z.ZodTypeAny, {
1764
+ driver: string;
1765
+ cookie?: {
1766
+ domain?: string | undefined;
1767
+ path?: string | undefined;
1768
+ maxAge?: number | undefined;
1769
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
1770
+ secure?: boolean | undefined;
1771
+ name?: string | undefined;
1772
+ } | undefined;
1773
+ options?: Record<string, any> | undefined;
1774
+ ttl?: number | undefined;
1775
+ }, {
1776
+ driver: string;
1777
+ cookie?: string | {
1778
+ domain?: string | undefined;
1779
+ path?: string | undefined;
1780
+ maxAge?: number | undefined;
1781
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
1782
+ secure?: boolean | undefined;
1783
+ name?: string | undefined;
1784
+ } | undefined;
1785
+ options?: Record<string, any> | undefined;
1786
+ ttl?: number | undefined;
1787
+ }>>;
1606
1788
  svg: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodOptional<z.ZodObject<{
1607
1789
  mode: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"inline">, z.ZodLiteral<"sprite">]>>;
1608
1790
  }, "strip", z.ZodTypeAny, {
@@ -1621,6 +1803,19 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1621
1803
  svg?: {
1622
1804
  mode?: "inline" | "sprite" | undefined;
1623
1805
  } | undefined;
1806
+ session?: {
1807
+ driver: string;
1808
+ cookie?: {
1809
+ domain?: string | undefined;
1810
+ path?: string | undefined;
1811
+ maxAge?: number | undefined;
1812
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
1813
+ secure?: boolean | undefined;
1814
+ name?: string | undefined;
1815
+ } | undefined;
1816
+ options?: Record<string, any> | undefined;
1817
+ ttl?: number | undefined;
1818
+ } | undefined;
1624
1819
  }, {
1625
1820
  clientPrerender?: boolean | undefined;
1626
1821
  contentIntellisense?: boolean | undefined;
@@ -1628,6 +1823,19 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1628
1823
  svg?: boolean | {
1629
1824
  mode?: "inline" | "sprite" | undefined;
1630
1825
  } | undefined;
1826
+ session?: {
1827
+ driver: string;
1828
+ cookie?: string | {
1829
+ domain?: string | undefined;
1830
+ path?: string | undefined;
1831
+ maxAge?: number | undefined;
1832
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
1833
+ secure?: boolean | undefined;
1834
+ name?: string | undefined;
1835
+ } | undefined;
1836
+ options?: Record<string, any> | undefined;
1837
+ ttl?: number | undefined;
1838
+ } | undefined;
1631
1839
  }>>;
1632
1840
  legacy: z.ZodDefault<z.ZodObject<{
1633
1841
  collections: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
@@ -1848,6 +2056,19 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1848
2056
  svg?: {
1849
2057
  mode?: "inline" | "sprite" | undefined;
1850
2058
  } | undefined;
2059
+ session?: {
2060
+ driver: string;
2061
+ cookie?: {
2062
+ domain?: string | undefined;
2063
+ path?: string | undefined;
2064
+ maxAge?: number | undefined;
2065
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
2066
+ secure?: boolean | undefined;
2067
+ name?: string | undefined;
2068
+ } | undefined;
2069
+ options?: Record<string, any> | undefined;
2070
+ ttl?: number | undefined;
2071
+ } | undefined;
1851
2072
  };
1852
2073
  legacy: {
1853
2074
  collections: boolean;
@@ -2024,6 +2245,19 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
2024
2245
  svg?: boolean | {
2025
2246
  mode?: "inline" | "sprite" | undefined;
2026
2247
  } | undefined;
2248
+ session?: {
2249
+ driver: string;
2250
+ cookie?: string | {
2251
+ domain?: string | undefined;
2252
+ path?: string | undefined;
2253
+ maxAge?: number | undefined;
2254
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
2255
+ secure?: boolean | undefined;
2256
+ name?: string | undefined;
2257
+ } | undefined;
2258
+ options?: Record<string, any> | undefined;
2259
+ ttl?: number | undefined;
2260
+ } | undefined;
2027
2261
  } | undefined;
2028
2262
  legacy?: {
2029
2263
  collections?: boolean | undefined;
@@ -2163,6 +2397,19 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
2163
2397
  svg?: {
2164
2398
  mode?: "inline" | "sprite" | undefined;
2165
2399
  } | undefined;
2400
+ session?: {
2401
+ driver: string;
2402
+ cookie?: {
2403
+ domain?: string | undefined;
2404
+ path?: string | undefined;
2405
+ maxAge?: number | undefined;
2406
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
2407
+ secure?: boolean | undefined;
2408
+ name?: string | undefined;
2409
+ } | undefined;
2410
+ options?: Record<string, any> | undefined;
2411
+ ttl?: number | undefined;
2412
+ } | undefined;
2166
2413
  };
2167
2414
  legacy: {
2168
2415
  collections: boolean;
@@ -2339,6 +2586,19 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
2339
2586
  svg?: boolean | {
2340
2587
  mode?: "inline" | "sprite" | undefined;
2341
2588
  } | undefined;
2589
+ session?: {
2590
+ driver: string;
2591
+ cookie?: string | {
2592
+ domain?: string | undefined;
2593
+ path?: string | undefined;
2594
+ maxAge?: number | undefined;
2595
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
2596
+ secure?: boolean | undefined;
2597
+ name?: string | undefined;
2598
+ } | undefined;
2599
+ options?: Record<string, any> | undefined;
2600
+ ttl?: number | undefined;
2601
+ } | undefined;
2342
2602
  } | undefined;
2343
2603
  legacy?: {
2344
2604
  collections?: boolean | undefined;
@@ -2478,6 +2738,19 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
2478
2738
  svg?: {
2479
2739
  mode?: "inline" | "sprite" | undefined;
2480
2740
  } | undefined;
2741
+ session?: {
2742
+ driver: string;
2743
+ cookie?: {
2744
+ domain?: string | undefined;
2745
+ path?: string | undefined;
2746
+ maxAge?: number | undefined;
2747
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
2748
+ secure?: boolean | undefined;
2749
+ name?: string | undefined;
2750
+ } | undefined;
2751
+ options?: Record<string, any> | undefined;
2752
+ ttl?: number | undefined;
2753
+ } | undefined;
2481
2754
  };
2482
2755
  legacy: {
2483
2756
  collections: boolean;
@@ -2654,6 +2927,19 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
2654
2927
  svg?: boolean | {
2655
2928
  mode?: "inline" | "sprite" | undefined;
2656
2929
  } | undefined;
2930
+ session?: {
2931
+ driver: string;
2932
+ cookie?: string | {
2933
+ domain?: string | undefined;
2934
+ path?: string | undefined;
2935
+ maxAge?: number | undefined;
2936
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
2937
+ secure?: boolean | undefined;
2938
+ name?: string | undefined;
2939
+ } | undefined;
2940
+ options?: Record<string, any> | undefined;
2941
+ ttl?: number | undefined;
2942
+ } | undefined;
2657
2943
  } | undefined;
2658
2944
  legacy?: {
2659
2945
  collections?: boolean | undefined;
@@ -2793,6 +3079,19 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
2793
3079
  svg?: {
2794
3080
  mode?: "inline" | "sprite" | undefined;
2795
3081
  } | undefined;
3082
+ session?: {
3083
+ driver: string;
3084
+ cookie?: {
3085
+ domain?: string | undefined;
3086
+ path?: string | undefined;
3087
+ maxAge?: number | undefined;
3088
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
3089
+ secure?: boolean | undefined;
3090
+ name?: string | undefined;
3091
+ } | undefined;
3092
+ options?: Record<string, any> | undefined;
3093
+ ttl?: number | undefined;
3094
+ } | undefined;
2796
3095
  };
2797
3096
  legacy: {
2798
3097
  collections: boolean;
@@ -2969,6 +3268,19 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
2969
3268
  svg?: boolean | {
2970
3269
  mode?: "inline" | "sprite" | undefined;
2971
3270
  } | undefined;
3271
+ session?: {
3272
+ driver: string;
3273
+ cookie?: string | {
3274
+ domain?: string | undefined;
3275
+ path?: string | undefined;
3276
+ maxAge?: number | undefined;
3277
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
3278
+ secure?: boolean | undefined;
3279
+ name?: string | undefined;
3280
+ } | undefined;
3281
+ options?: Record<string, any> | undefined;
3282
+ ttl?: number | undefined;
3283
+ } | undefined;
2972
3284
  } | undefined;
2973
3285
  legacy?: {
2974
3286
  collections?: boolean | undefined;
@@ -334,6 +334,27 @@ const AstroConfigSchema = z.object({
334
334
  clientPrerender: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.clientPrerender),
335
335
  contentIntellisense: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.contentIntellisense),
336
336
  responsiveImages: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.responsiveImages),
337
+ session: z.object({
338
+ driver: z.string(),
339
+ options: z.record(z.any()).optional(),
340
+ cookie: z.union([
341
+ z.object({
342
+ name: z.string().optional(),
343
+ domain: z.string().optional(),
344
+ path: z.string().optional(),
345
+ maxAge: z.number().optional(),
346
+ sameSite: z.union([z.enum(["strict", "lax", "none"]), z.boolean()]).optional(),
347
+ secure: z.boolean().optional()
348
+ }),
349
+ z.string()
350
+ ]).transform((val) => {
351
+ if (typeof val === "string") {
352
+ return { name: val };
353
+ }
354
+ return val;
355
+ }).optional(),
356
+ ttl: z.number().optional()
357
+ }).optional(),
337
358
  svg: z.union([
338
359
  z.boolean(),
339
360
  z.object({
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "5.0.9";
1
+ const ASTRO_VERSION = "5.1.1";
2
2
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
3
3
  const REWRITE_DIRECTIVE_HEADER_KEY = "X-Astro-Rewrite";
4
4
  const REWRITE_DIRECTIVE_HEADER_VALUE = "yes";
@@ -22,7 +22,7 @@ async function dev(inlineConfig) {
22
22
  await telemetry.record([]);
23
23
  const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
24
24
  const logger = restart.container.logger;
25
- const currentVersion = "5.0.9";
25
+ const currentVersion = "5.1.1";
26
26
  const isPrerelease = currentVersion.includes("-");
27
27
  if (!isPrerelease) {
28
28
  try {
@@ -774,6 +774,32 @@ export declare const AstroResponseHeadersReassigned: {
774
774
  message: string;
775
775
  hint: string;
776
776
  };
777
+ /**
778
+ * @docs
779
+ * @see
780
+ * - [experimental.session](https://docs.astro.build/en/reference/experimental-flags/sessions/)
781
+ * @description
782
+ * Thrown when the session storage could not be initialized.
783
+ */
784
+ export declare const SessionStorageInitError: {
785
+ name: string;
786
+ title: string;
787
+ message: (error: string, driver?: string) => string;
788
+ hint: string;
789
+ };
790
+ /**
791
+ * @docs
792
+ * @see
793
+ * - [experimental.session](https://docs.astro.build/en/reference/experimental-flags/sessions/)
794
+ * @description
795
+ * Thrown when the session data could not be saved.
796
+ */
797
+ export declare const SessionStorageSaveError: {
798
+ name: string;
799
+ title: string;
800
+ message: (error: string, driver?: string) => string;
801
+ hint: string;
802
+ };
777
803
  /**
778
804
  * @docs
779
805
  * @description
@@ -275,6 +275,18 @@ const AstroResponseHeadersReassigned = {
275
275
  message: "Individual headers can be added to and removed from `Astro.response.headers`, but it must not be replaced with another instance of `Headers` altogether.",
276
276
  hint: "Consider using `Astro.response.headers.add()`, and `Astro.response.headers.delete()`."
277
277
  };
278
+ const SessionStorageInitError = {
279
+ name: "SessionStorageInitError",
280
+ title: "Session storage could not be initialized.",
281
+ message: (error, driver) => `Error when initializing session storage${driver ? ` with driver ${driver}` : ""}. ${error ?? ""}`,
282
+ hint: "For more information, see https://docs.astro.build/en/reference/experimental-flags/sessions/"
283
+ };
284
+ const SessionStorageSaveError = {
285
+ name: "SessionStorageSaveError",
286
+ title: "Session data could not be saved.",
287
+ message: (error, driver) => `Error when saving session data${driver ? ` with driver ${driver}` : ""}. ${error ?? ""}`,
288
+ hint: "For more information, see https://docs.astro.build/en/reference/experimental-flags/sessions/"
289
+ };
278
290
  const MiddlewareCantBeLoaded = {
279
291
  name: "MiddlewareCantBeLoaded",
280
292
  title: "Can't load the middleware.",
@@ -698,6 +710,8 @@ export {
698
710
  RewriteWithBodyUsed,
699
711
  RouteNotFound,
700
712
  ServerOnlyModule,
713
+ SessionStorageInitError,
714
+ SessionStorageSaveError,
701
715
  StaticClientAddressNotAvailable,
702
716
  UnhandledRejection,
703
717
  UnknownCLIError,
@@ -38,7 +38,7 @@ function serverStart({
38
38
  host,
39
39
  base
40
40
  }) {
41
- const version = "5.0.9";
41
+ const version = "5.1.1";
42
42
  const localPrefix = `${dim("\u2503")} Local `;
43
43
  const networkPrefix = `${dim("\u2503")} Network `;
44
44
  const emptyPrefix = " ".repeat(11);
@@ -276,7 +276,7 @@ function printHelp({
276
276
  message.push(
277
277
  linebreak(),
278
278
  ` ${bgGreen(black(` ${commandName} `))} ${green(
279
- `v${"5.0.9"}`
279
+ `v${"5.1.1"}`
280
280
  )} ${headline}`
281
281
  );
282
282
  }
@@ -5,6 +5,7 @@ import type { APIContext, AstroGlobal, AstroGlobalPartial } from '../types/publi
5
5
  import type { RouteData, SSRResult } from '../types/public/internal.js';
6
6
  import { AstroCookies } from './cookies/index.js';
7
7
  import { type Pipeline } from './render/index.js';
8
+ import { AstroSession } from './session.js';
8
9
  export declare const apiContextRoutesSymbol: unique symbol;
9
10
  /**
10
11
  * Each request is rendered using a `RenderContext`.
@@ -25,6 +26,7 @@ export declare class RenderContext {
25
26
  protected url: URL;
26
27
  props: Props;
27
28
  partial: undefined | boolean;
29
+ session: AstroSession | undefined;
28
30
  private constructor();
29
31
  /**
30
32
  * A flag that tells the render content if the rewriting was triggered
@@ -27,9 +27,10 @@ import { Slots, getParams, getProps } from "./render/index.js";
27
27
  import { isRoute404or500 } from "./routing/match.js";
28
28
  import { copyRequest, getOriginPathname, setOriginPathname } from "./routing/rewrite.js";
29
29
  import { SERVER_ISLAND_COMPONENT } from "./server-islands/endpoint.js";
30
+ import { AstroSession } from "./session.js";
30
31
  const apiContextRoutesSymbol = Symbol.for("context.routes");
31
32
  class RenderContext {
32
- constructor(pipeline, locals, middleware, pathname, request, routeData, status, clientAddress, cookies = new AstroCookies(request), params = getParams(routeData, pathname), url = new URL(request.url), props = {}, partial = void 0) {
33
+ constructor(pipeline, locals, middleware, pathname, request, routeData, status, clientAddress, cookies = new AstroCookies(request), params = getParams(routeData, pathname), url = new URL(request.url), props = {}, partial = void 0, session = pipeline.manifest.sessionConfig ? new AstroSession(cookies, pipeline.manifest.sessionConfig) : void 0) {
33
34
  this.pipeline = pipeline;
34
35
  this.locals = locals;
35
36
  this.middleware = middleware;
@@ -43,6 +44,7 @@ class RenderContext {
43
44
  this.url = url;
44
45
  this.props = props;
45
46
  this.partial = partial;
47
+ this.session = session;
46
48
  }
47
49
  /**
48
50
  * A flag that tells the render content if the rewriting was triggered
@@ -238,7 +240,7 @@ class RenderContext {
238
240
  }
239
241
  createActionAPIContext() {
240
242
  const renderContext = this;
241
- const { cookies, params, pipeline, url } = this;
243
+ const { cookies, params, pipeline, url, session } = this;
242
244
  const generator = `Astro v${ASTRO_VERSION}`;
243
245
  const rewrite = async (reroutePayload) => {
244
246
  return await this.#executeRewrite(reroutePayload);
@@ -273,7 +275,8 @@ class RenderContext {
273
275
  url,
274
276
  get originPathname() {
275
277
  return getOriginPathname(renderContext.request);
276
- }
278
+ },
279
+ session
277
280
  };
278
281
  }
279
282
  async createResult(mod) {
@@ -376,7 +379,7 @@ class RenderContext {
376
379
  }
377
380
  createAstroPagePartial(result, astroStaticPartial) {
378
381
  const renderContext = this;
379
- const { cookies, locals, params, pipeline, url } = this;
382
+ const { cookies, locals, params, pipeline, url, session } = this;
380
383
  const { response } = result;
381
384
  const redirect = (path, status = 302) => {
382
385
  if (this.request[responseSentSymbol]) {
@@ -395,6 +398,7 @@ class RenderContext {
395
398
  routePattern: this.routeData.route,
396
399
  isPrerendered: this.routeData.prerender,
397
400
  cookies,
401
+ session,
398
402
  get clientAddress() {
399
403
  return renderContext.getClientAddress();
400
404
  },
@@ -0,0 +1,48 @@
1
+ import type { ResolvedSessionConfig, SessionDriverName } from '../types/public/config.js';
2
+ import type { AstroCookies } from './cookies/cookies.js';
3
+ export declare const PERSIST_SYMBOL: unique symbol;
4
+ export declare class AstroSession<TDriver extends SessionDriverName = any> {
5
+ #private;
6
+ constructor(cookies: AstroCookies, { cookie: cookieConfig, ...config }: Exclude<ResolvedSessionConfig<TDriver>, undefined>);
7
+ /**
8
+ * Gets a session value. Returns `undefined` if the session or value does not exist.
9
+ */
10
+ get<T = any>(key: string): Promise<T | undefined>;
11
+ /**
12
+ * Checks if a session value exists.
13
+ */
14
+ has(key: string): Promise<boolean>;
15
+ /**
16
+ * Gets all session values.
17
+ */
18
+ keys(): Promise<MapIterator<string>>;
19
+ /**
20
+ * Gets all session values.
21
+ */
22
+ values(): Promise<any[]>;
23
+ /**
24
+ * Gets all session entries.
25
+ */
26
+ entries(): Promise<any[][]>;
27
+ /**
28
+ * Deletes a session value.
29
+ */
30
+ delete(key: string): void;
31
+ /**
32
+ * Sets a session value. The session is created if it does not exist.
33
+ */
34
+ set<T = any>(key: string, value: T, { ttl }?: {
35
+ ttl?: number;
36
+ }): void;
37
+ /**
38
+ * Destroys the session, clearing the cookie and storage if it exists.
39
+ */
40
+ destroy(): void;
41
+ /**
42
+ * Regenerates the session, creating a new session ID. The existing session data is preserved.
43
+ */
44
+ regenerate(): Promise<void>;
45
+ [PERSIST_SYMBOL](): Promise<void>;
46
+ get sessionID(): string | undefined;
47
+ }
48
+ export declare function resolveSessionDriver(driver: string | undefined): Promise<string> | string | null;