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

Version Packages (beta) #4083

Merged
merged 2 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
"@blitzjs/recipe-theme-ui": "0.34.0-canary.0",
"@blitzjs/recipe-vanilla-extract": "0.34.0-canary.0",
"test-rpc-path-root": "0.0.0",
"test-full-auth-with-rpc": "0.0.0"
"test-full-auth-with-rpc": "0.0.0",
"next-blitz-auth": "0.1.0",
"test-app-dir": "0.0.0"
},
"changesets": [
"afraid-dancers-juggle",
Expand All @@ -67,6 +69,7 @@
"calm-nails-wait",
"calm-papayas-protect",
"calm-tomatoes-drive",
"chatty-fireants-leave",
"chilled-carrots-own",
"chilly-candles-care",
"chilly-nails-nail",
Expand All @@ -77,6 +80,7 @@
"cool-doors-invent",
"cool-horses-check",
"cuddly-pugs-crash",
"cuddly-singers-perform",
"curly-rules-speak",
"curly-seas-serve",
"curvy-days-attend",
Expand All @@ -91,13 +95,17 @@
"eleven-lobsters-drop",
"empty-berries-rule",
"empty-pants-search",
"empty-spiders-lay",
"empty-turkeys-wave",
"fair-carrots-guess",
"fair-kangaroos-clean",
"fair-wombats-sneeze",
"famous-kings-explain",
"fast-adults-guess",
"fast-clocks-push",
"fast-pans-impress",
"fast-papayas-grow",
"fast-toys-wash",
"fast-trainers-kneel",
"few-dogs-fetch",
"few-hounds-worry",
Expand All @@ -109,6 +117,7 @@
"forty-timers-rhyme",
"four-brooms-juggle",
"four-meals-fry",
"four-radios-tickle",
"four-sheep-judge",
"funny-cups-pay",
"fuzzy-bees-warn",
Expand Down Expand Up @@ -169,6 +178,7 @@
"lucky-cows-try",
"lucky-months-guess",
"lucky-years-turn",
"mean-ears-speak",
"mean-gorillas-reply",
"modern-cameras-pull",
"modern-games-dream",
Expand Down Expand Up @@ -234,6 +244,7 @@
"silent-colts-reply",
"silent-lies-run",
"silly-apricots-share",
"silly-peas-work",
"silly-shoes-agree",
"six-apricots-kick",
"slimy-humans-impress",
Expand All @@ -258,6 +269,7 @@
"stale-jobs-drum",
"stale-parents-yawn",
"strong-apes-reply",
"strong-chicken-study",
"strong-keys-lie",
"stupid-rabbits-jump",
"stupid-walls-sell",
Expand All @@ -266,6 +278,7 @@
"swift-glasses-laugh",
"swift-poets-travel",
"tall-meals-learn",
"tall-radios-clean",
"tame-keys-reply",
"tame-pumpkins-nail",
"tasty-maps-fetch",
Expand Down
9 changes: 6 additions & 3 deletions .changeset/tall-radios-clean.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
"next-blitz-auth": patch
"@blitzjs/auth": patch
"@blitzjs/rpc": patch
"blitz": patch
Expand All @@ -11,9 +10,10 @@ feature: Nextjs 13 App Directory Utility Methods

This hook is implemented as the replacement of the [`BlitzPage` seurity auth utilities](https://blitzjs.com/docs/authorization#secure-your-pages) provided for the pages directory to work with React Server Components in the Nextjs 13 app directory
It can be used in any asynchronous server component be it in `page.ts` or in the layouts in `layout.ts`
It uses the new [`redirect` function](https://beta.nextjs.org/docs/api-reference/redirect) to provide the required authorization in server side
It uses the new [`redirect` function](https://beta.nextjs.org/docs/api-reference/redirect) to provide the required authorization in server side

#### API

```ts
useAuthenticatedBlitzContext({
redirectTo,
Expand All @@ -27,7 +27,9 @@ useAuthenticatedBlitzContext({
```

#### Usage

**Example Usage in React Server Component in `app` directory in Next 13**

```ts
import {getAppSession, useAuthenticatedBlitzContext} from "src/blitz-server"
...
Expand All @@ -41,11 +43,12 @@ await useAuthenticatedBlitzContext({
### 🔧 New Blitz RPC Hook `invokeResolver`

#### API

```ts
invokeResolver<T extends (...args: any) => any, TInput = FirstParam<T>>(
queryFn: T,
params: TInput,
): Promise<PromiseReturnType<T>>
): Promise<PromiseReturnType<T>>
```

#### Example Usage
Expand Down
81 changes: 81 additions & 0 deletions apps/next13/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# next-blitz-auth

## 0.1.1-beta.0

### Patch Changes

- 37aeaa7fa: feature: Nextjs 13 App Directory Utility Methods

### 🔧 New Blitz Auth Hook `useAuthenticatedBlitzContext`

This hook is implemented as the replacement of the [`BlitzPage` seurity auth utilities](https://blitzjs.com/docs/authorization#secure-your-pages) provided for the pages directory to work with React Server Components in the Nextjs 13 app directory
It can be used in any asynchronous server component be it in `page.ts` or in the layouts in `layout.ts`
It uses the new [`redirect` function](https://beta.nextjs.org/docs/api-reference/redirect) to provide the required authorization in server side

#### API

```ts
useAuthenticatedBlitzContext({
redirectTo,
redirectAuthenticatedTo,
role,
}: {
redirectTo?: string | RouteUrlObject
redirectAuthenticatedTo?: string | RouteUrlObject | ((ctx: Ctx) => string | RouteUrlObject)
role?: string | string[]
}): Promise<void>
```

#### Usage

**Example Usage in React Server Component in `app` directory in Next 13**

```ts
import {getAppSession, useAuthenticatedBlitzContext} from "src/blitz-server"
...
await useAuthenticatedBlitzContext({
redirectTo: "/auth/login",
role: ["admin"],
redirectAuthenticatedTo: "/dashboard",
})
```

### 🔧 New Blitz RPC Hook `invokeResolver`

#### API

```ts
invokeResolver<T extends (...args: any) => any, TInput = FirstParam<T>>(
queryFn: T,
params: TInput,
): Promise<PromiseReturnType<T>>
```

#### Example Usage

```ts
...
import {invokeResolver, useAuthenticatedBlitzContext} from "../src/blitz-server"
import getCurrentUser from "../src/users/queries/getCurrentUser"

export default async function Home() {
await useAuthenticatedBlitzContext({
redirectTo: "/auth/login",
})
const user = await invokeResolver(getCurrentUser, null)
...
```

- Updated dependencies [cadefb88e]
- Updated dependencies [6f18cbdc9]
- Updated dependencies [acc07ce94]
- Updated dependencies [ea7561b8e]
- Updated dependencies [9529dbd6f]
- Updated dependencies [ea7561b8e]
- Updated dependencies [6e88a847f]
- Updated dependencies [37aeaa7fa]
- blitz@2.0.0-beta.24
- @blitzjs/auth@2.0.0-beta.24
- @blitzjs/next@2.0.0-beta.24
- @blitzjs/rpc@2.0.0-beta.24
- @blitzjs/config@2.0.0-beta.24
2 changes: 1 addition & 1 deletion apps/next13/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-blitz-auth",
"version": "0.1.0",
"version": "0.1.1-beta.0",
"private": true,
"scripts": {
"blitz:dev": "next dev",
Expand Down
2 changes: 1 addition & 1 deletion apps/toolkit-app-passportjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@hookform/error-message": "2.0.0",
"@hookform/resolvers": "2.9.10",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.23",
"blitz": "workspace:2.0.0-beta.24",
"next": "13.2.4",
"openid-client": "5.2.1",
"prisma": "4.6.1",
Expand Down
2 changes: 1 addition & 1 deletion apps/toolkit-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@hookform/error-message": "2.0.0",
"@hookform/resolvers": "2.9.10",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.23",
"blitz": "workspace:2.0.0-beta.24",
"next": "13.2.4",
"next-auth": "4.18.7",
"prisma": "4.6.1",
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/auth-with-rpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
"prisma:studio": "prisma studio"
},
"dependencies": {
"@blitzjs/auth": "workspace:2.0.0-beta.23",
"@blitzjs/config": "workspace:2.0.0-beta.23",
"@blitzjs/next": "workspace:2.0.0-beta.23",
"@blitzjs/rpc": "workspace:2.0.0-beta.23",
"@blitzjs/auth": "workspace:2.0.0-beta.24",
"@blitzjs/config": "workspace:2.0.0-beta.24",
"@blitzjs/next": "workspace:2.0.0-beta.24",
"@blitzjs/rpc": "workspace:2.0.0-beta.24",
"@hookform/error-message": "2.0.0",
"@hookform/resolvers": "2.9.10",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.23",
"blitz": "workspace:2.0.0-beta.24",
"delay": "5.0.0",
"next": "13.2.4",
"prisma": "4.6.1",
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
"prisma:studio": "prisma studio"
},
"dependencies": {
"@blitzjs/auth": "workspace:2.0.0-beta.23",
"@blitzjs/config": "workspace:2.0.0-beta.23",
"@blitzjs/next": "workspace:2.0.0-beta.23",
"@blitzjs/auth": "workspace:2.0.0-beta.24",
"@blitzjs/config": "workspace:2.0.0-beta.24",
"@blitzjs/next": "workspace:2.0.0-beta.24",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.23",
"blitz": "workspace:2.0.0-beta.24",
"lowdb": "3.0.0",
"next": "13.2.4",
"prisma": "4.6.1",
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/get-initial-props/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
"schema": "db/schema.prisma"
},
"dependencies": {
"@blitzjs/auth": "workspace:2.0.0-beta.23",
"@blitzjs/next": "workspace:2.0.0-beta.23",
"@blitzjs/rpc": "workspace:2.0.0-beta.23",
"@blitzjs/auth": "workspace:2.0.0-beta.24",
"@blitzjs/next": "workspace:2.0.0-beta.24",
"@blitzjs/rpc": "workspace:2.0.0-beta.24",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.23",
"blitz": "workspace:2.0.0-beta.24",
"lowdb": "3.0.0",
"next": "13.2.4",
"prisma": "4.6.1",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@blitzjs/config": "workspace:2.0.0-beta.23",
"@blitzjs/config": "workspace:2.0.0-beta.24",
"@next/bundle-analyzer": "12.0.8",
"@types/express": "4.17.13",
"@types/fs-extra": "9.0.13",
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next"
},
"dependencies": {
"@blitzjs/config": "workspace:2.0.0-beta.23",
"@blitzjs/next": "workspace:2.0.0-beta.23",
"@blitzjs/rpc": "workspace:2.0.0-beta.23",
"blitz": "workspace:2.0.0-beta.23",
"@blitzjs/config": "workspace:2.0.0-beta.24",
"@blitzjs/next": "workspace:2.0.0-beta.24",
"@blitzjs/rpc": "workspace:2.0.0-beta.24",
"blitz": "workspace:2.0.0-beta.24",
"next": "13.2.4",
"react": "18.2.0",
"react-dom": "18.2.0"
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/next-13-app-dir/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
"prisma:studio": "prisma studio"
},
"dependencies": {
"@blitzjs/auth": "workspace:2.0.0-beta.23",
"@blitzjs/config": "workspace:2.0.0-beta.23",
"@blitzjs/next": "workspace:2.0.0-beta.23",
"@blitzjs/rpc": "workspace:2.0.0-beta.23",
"@blitzjs/auth": "workspace:2.0.0-beta.24",
"@blitzjs/config": "workspace:2.0.0-beta.24",
"@blitzjs/next": "workspace:2.0.0-beta.24",
"@blitzjs/rpc": "workspace:2.0.0-beta.24",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.23",
"blitz": "workspace:2.0.0-beta.24",
"lowdb": "3.0.0",
"next": "13.2.4",
"prisma": "4.6.1",
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/no-suspense/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
"prisma:studio": "prisma studio"
},
"dependencies": {
"@blitzjs/auth": "workspace:2.0.0-beta.23",
"@blitzjs/next": "workspace:2.0.0-beta.23",
"@blitzjs/rpc": "workspace:2.0.0-beta.23",
"@blitzjs/auth": "workspace:2.0.0-beta.24",
"@blitzjs/next": "workspace:2.0.0-beta.24",
"@blitzjs/rpc": "workspace:2.0.0-beta.24",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.23",
"blitz": "workspace:2.0.0-beta.24",
"lowdb": "3.0.0",
"next": "13.2.4",
"prisma": "4.6.1",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@blitzjs/config": "workspace:2.0.0-beta.23",
"@blitzjs/config": "workspace:2.0.0-beta.24",
"@next/bundle-analyzer": "12.0.8",
"@types/express": "4.17.13",
"@types/fs-extra": "9.0.13",
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/qm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"clean": "rm -rf .turbo && rm -rf node_modules"
},
"dependencies": {
"@blitzjs/auth": "workspace:2.0.0-beta.23",
"@blitzjs/config": "workspace:2.0.0-beta.23",
"@blitzjs/next": "workspace:2.0.0-beta.23",
"@blitzjs/rpc": "workspace:2.0.0-beta.23",
"@blitzjs/auth": "workspace:2.0.0-beta.24",
"@blitzjs/config": "workspace:2.0.0-beta.24",
"@blitzjs/next": "workspace:2.0.0-beta.24",
"@blitzjs/rpc": "workspace:2.0.0-beta.24",
"@prisma/client": "4.6.1",
"@tanstack/react-query": "4.0.10",
"blitz": "workspace:2.0.0-beta.23",
"blitz": "workspace:2.0.0-beta.24",
"next": "13.2.4",
"prisma": "4.6.1",
"react": "18.2.0",
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/react-query-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
"schema": "db/schema.prisma"
},
"dependencies": {
"@blitzjs/next": "workspace:2.0.0-beta.23",
"@blitzjs/rpc": "workspace:2.0.0-beta.23",
"@blitzjs/next": "workspace:2.0.0-beta.24",
"@blitzjs/rpc": "workspace:2.0.0-beta.24",
"@prisma/client": "4.6.1",
"blitz": "workspace:2.0.0-beta.23",
"blitz": "workspace:2.0.0-beta.24",
"lowdb": "3.0.0",
"next": "13.2.4",
"prisma": "4.6.1",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@blitzjs/config": "workspace:2.0.0-beta.23",
"@blitzjs/config": "workspace:2.0.0-beta.24",
"@next/bundle-analyzer": "12.0.8",
"@types/express": "4.17.13",
"@types/fs-extra": "9.0.13",
Expand Down