Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds session options #12450

Merged
merged 15 commits into from
Nov 17, 2024
Merged

feat: adds session options #12450

merged 15 commits into from
Nov 17, 2024

Conversation

ascorbic
Copy link
Contributor

Changes

Adds experimental flag for sessions, and top-level session options

Testing

Docs

Copy link

changeset-bot bot commented Nov 15, 2024

⚠️ No Changeset found

Latest commit: e8caa54

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) docs pr labels Nov 15, 2024
Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So many cool new features coming! 🔥

Just left some thoughts below for your consideration!

packages/astro/src/types/public/config.ts Outdated Show resolved Hide resolved
* <a href="/checkout">🛒 {cart?.length ?? 0} items</a>
*
* ```
*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link to RFC to learn more, maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll do that once I have the stage 3 PR up

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

packages/astro/src/types/public/config.ts Outdated Show resolved Hide resolved
ascorbic and others added 2 commits November 15, 2024 21:46
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
@@ -714,6 +733,13 @@ export function createRelativeSchema(cmd: string, fileProtocolRoot: string) {
});
}
}
if (session && !experimental.sessions) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to just have it under experimental, and move it to root once it becomes stable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still don't know what's the best thing there.

Copy link
Member

@sarah11918 sarah11918 Nov 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I get a say in the matter, but from a docs perspective, we prefer when everything related to an experimental feature is contained in its own experimental config. 😅

Especially going forward, each experimental feature will have its own page, separate from configuration reference. If everything is contained, it's nice to document all in one experimental feature flag, and we don't have to send people separately to configuration reference for configuring experimental things, and it's easier to know you've got the feature set up when it's all together.. (And, we get to keep experimental content separate from stable, which is more helpful for readers to keep things straight.)

And, separate page for experimental feature means you get to avoid JSDoc and just make normal docs PRs to update... so... does that tempt you??? 😄

On the other side, I think Ema said from a code maintenance or testing perspective, it's easier to work on the code separately from the flag. There's also the advantage of this showing up in the editor. (But then, it shows up for people who also don't have the flag enabled, too. Is that advertising or confusing?) So really, both sides have their benefits.

We can certainly handle documenting either way, and for sure don't want to suggest something difficult to work on or maintain. But if we got to choose, we'd keep the experimental configs within the experimental flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You absolutely do get a say! I think I am swayed towards moving it all into experimental now, and replace the boolean with the object. The fact it's a new top-level option is the difference I think.

*/ export interface AstroUserConfig<TLocales extends Locales = never> {
*/ export interface AstroUserConfig<
TLocales extends Locales = never,
TSession extends SessionDriverName = never,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm glad the generic defineConfig is used already :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it works great!

@ascorbic ascorbic merged commit 067c49b into astro-dot-session Nov 17, 2024
14 checks passed
@ascorbic ascorbic deleted the session-config branch November 17, 2024 06:34
ematipico added a commit that referenced this pull request Dec 18, 2024
* wip: experimental sessions

* feat: adds session options (#12450)

* feat: add session config

* chore: add session config docs

* Fix

* Expand doc

* Handle schema

* Remove example

* Format

* Lock

* Fix schema

* Update packages/astro/src/types/public/config.ts

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

* Update packages/astro/src/types/public/config.ts

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

* Add link to Sessions RFC in config.ts

* Move session into experimental

---------

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

* Lock

* feat: prototype session support (#12471)

* feat: add session object

* Add tests and fix logic

* Fixes

* Allow string as cookie option

* wip: implement sessions (#12478)

* feat: implement sessions

* Add middleware

* Action middleware test

* Support URLs

* Remove comment

* Changes from review

* Update test

* Ensure test file is run

* ci: changeset base

* ci: exit from changeset pre mode

* Lockfile

* Update base

* fix: use virtual import for storage drivers (#12520)

* fix: use virtual import for storage drivers

* Don't try to resolve anythign in build

* Fix test

* Polyfill node:url

* Handle custom drivers directly

* No need for path

* Update packages/astro/src/core/session.ts

Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>

---------

Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>

* Fix jsdoc

* fix: set default storage path

* Update changeset config for now

* Revert config workaround

* Lock

* Remove unneeded ts-expect-error directive

* fix: [sessions] import storage driver in manifest (#12654)

* wip

* wip

* Export manifest in middleware

* Changeset conf

* Pass session to edge middleware

* Support initial session data

* Persist edge session on redirect

* Remove middleware-related changes

* Refactor

* Remove vite plugin

* Format

* Simplify import

* Handle missing config

* Handle async resolution

* Lockfile

* feat(sessions): implement ttl and flash (#12693)

* feat(sessions): implement ttl and flash

* chore: add unit tests

* Make set arg an object

* Add more tests

* Add test fixtures

* Add comment

* Remove session.flash for now (#12745)

* Changeset

* Apply suggestions from code review

Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>

---------

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs pr pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants