1
0
mirror of synced 2026-02-04 03:01:17 -05:00

Compare commits

...

20 Commits

Author SHA1 Message Date
github-actions[bot]
474b5494ac Version Packages (beta) (#3977)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-11-22 16:09:29 -05:00
Dillon Raphael
b33db08286 Ensure superjson registers error classes once (#3982)
* bump superjson version & ensure superjson register

* update changeset & use error name as property for check if class has been registered

* refactor
2022-11-22 16:04:42 -05:00
Brandon Bayer
c1e0040639 transpile packages to es2015 to support older browsers (#3983) 2022-11-22 13:39:11 -05:00
Blitz.js Bot
5a7e6e0bb8 (meta) updated @medihack contributions 2022-11-21 14:30:17 -05:00
Kai Schlamp
a6f32d1d0b Export enhancePrisma for client again (#3965)
* Export enhancePrisma for client again
2022-11-21 14:30:11 -05:00
Selçuk Fatih Sevinç
c126b8191b Fix builder execute command hangs up (#3958)
* fix: builder execute command hangs up

* using "blitz install" inside recipe with addRunCommandStep causes hangs up

Co-authored-by: Selçuk Fatih Sevinç <selcuk@hub.studio>
2022-11-21 10:20:46 -05:00
Blitz.js Bot
775004f23e (meta) added @selcukfatihsevinc as contributor 2022-11-21 09:43:43 -05:00
Selçuk Fatih Sevinç
696f48c4e8 some providers need extra attributes, update for wrapAppWithProvider (#3959)
Co-authored-by: Dillon Raphael <dillon@creatorsneverdie.com>
2022-11-21 09:43:36 -05:00
Paul
942536d9ad Extend paginate.ts to support more complex pagination object (#3970)
* Extend paginate.ts to support more complex pagination object

* change pagination object based on reviewer suggestion

* changest inclusion

* update paginate test

Co-authored-by: Paul Moss <paulmoss06@gmail.com>
2022-11-18 09:50:10 -05:00
Brandon Bayer
b493c93f8b fix resolverPath:root and make it work with monorepo resolvers (#3978) 2022-11-17 21:47:17 -05:00
Dillon Raphael
b80c3d92ca Fix form paths when running blitz generate all (#3961)
* Update form paths when running blitz generate all

* pnpmlock & update changeset

* Update changeset

* pnpmlock

* update playwright
2022-11-17 17:41:11 -05:00
github-actions[bot]
4c0024c468 Version Packages (beta) (#3967)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-11-16 18:56:59 -05:00
Brandon Bayer
72a4e594ae internal: remove unneeded useSession from useQuery hooks (#3968) 2022-11-14 18:00:20 -05:00
Blitz.js Bot
62212bcc78 (meta) added @paulm17 as contributor 2022-11-14 14:51:47 -05:00
Paul
ed2b0e22c5 Add feature for resolvers to exist outside of Blitz root (#3953)
Co-authored-by: Paul Moss <paulmoss06@gmail.com>
Co-authored-by: Brandon Bayer <b@bayer.ws>
Co-authored-by: Dillon Raphael <dillon@creatorsneverdie.com>
2022-11-14 14:51:42 -05:00
Blitz.js Bot
d250346d8b (meta) updated @tmcw contributions 2022-11-14 14:23:27 -05:00
Tom MacWright
c0a3b1ee36 Fix runaway mutability bug in httpMethod (#3963)
Co-authored-by: Brandon Bayer <b@bayer.ws>
Closes https://github.com/blitz-js/blitz/issues/3962
2022-11-14 14:23:22 -05:00
Brandon Bayer
aaed9caa82 CI - upgrade pnpm version (#3966) 2022-11-14 14:14:16 -05:00
Brandon Bayer
0020db295d Revert "try fix"
This reverts commit 9fd032106e.
2022-11-14 13:00:59 -05:00
Brandon Bayer
9fd032106e try fix 2022-11-14 13:00:35 -05:00
99 changed files with 1219 additions and 324 deletions

View File

@@ -2314,7 +2314,9 @@
"avatar_url": "https://avatars.githubusercontent.com/u/32314?v=4",
"profile": "https://macwright.com/",
"contributions": [
"doc"
"doc",
"test",
"code"
]
},
{
@@ -2911,7 +2913,8 @@
"avatar_url": "https://avatars.githubusercontent.com/u/120626?v=4",
"profile": "https://github.com/medihack",
"contributions": [
"doc"
"doc",
"code"
]
},
{
@@ -3742,6 +3745,27 @@
"contributions": [
"doc"
]
},
{
"login": "paulm17",
"name": "Paul",
"avatar_url": "https://avatars.githubusercontent.com/u/387463?v=4",
"profile": "https://github.com/paulm17",
"contributions": [
"doc",
"code",
"test"
]
},
{
"login": "selcukfatihsevinc",
"name": "Selçuk Fatih Sevinç",
"avatar_url": "https://avatars.githubusercontent.com/u/384836?v=4",
"profile": "https://github.com/selcukfatihsevinc",
"contributions": [
"doc",
"code"
]
}
],
"contributorsPerLine": 7,

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/rpc": minor
---
internal: remove unneeed useSession from useQuery hooks

View File

@@ -0,0 +1,8 @@
---
"blitz": minor
"@blitzjs/auth": minor
"@blitzjs/next": minor
"@blitzjs/rpc": minor
---
transpile packages to es2015 to support older browsers

View File

@@ -0,0 +1,5 @@
---
"blitz": minor
---
some providers need extra attributes, update for wrapAppWithProvider

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/generator": patch
---
Fix form paths when running blitz generate all

View File

@@ -0,0 +1,5 @@
---
"blitz": major
---
update paginate.ts, return more params for more complex pagination control

View File

@@ -0,0 +1,5 @@
---
"blitz": patch
---
Export enhancePrisma for client again (Fixes #3964)

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/rpc": patch
---
Add ability to put your query and mutation resolvers in a separate monorepo folder, allowing you to use them in multiple apps.

View File

@@ -44,7 +44,8 @@
"@blitzjs/recipe-styled-components": "0.34.0-canary.0",
"@blitzjs/recipe-tailwind": "0.34.0-canary.0",
"@blitzjs/recipe-theme-ui": "0.34.0-canary.0",
"@blitzjs/recipe-vanilla-extract": "0.34.0-canary.0"
"@blitzjs/recipe-vanilla-extract": "0.34.0-canary.0",
"test-rpc-path-root": "0.0.0"
},
"changesets": [
"afraid-dancers-juggle",
@@ -52,11 +53,13 @@
"big-phones-bow",
"blue-flowers-peel",
"blue-pigs-tan",
"brave-zebras-deny",
"breezy-bees-beg",
"breezy-cameras-double",
"breezy-moose-behave",
"bright-mangos-run",
"brown-avocados-wink",
"calm-books-push",
"calm-carpets-deny",
"calm-horses-tie",
"calm-nails-wait",
@@ -89,6 +92,7 @@
"fast-papayas-grow",
"fast-trainers-kneel",
"few-dogs-fetch",
"few-hounds-worry",
"few-shrimps-leave",
"flat-bees-approve",
"fluffy-mangos-begin",
@@ -104,6 +108,7 @@
"gentle-dogs-reply",
"gentle-lions-explode",
"giant-mails-tap",
"giant-students-carry",
"gold-horses-punch",
"good-apes-drum",
"good-insects-wink",
@@ -145,6 +150,7 @@
"little-pears-ring",
"long-bees-hope",
"long-dancers-jog",
"long-hounds-melt",
"long-lobsters-drop",
"lovely-berries-sell",
"lovely-colts-share",
@@ -153,6 +159,7 @@
"lucky-years-turn",
"mean-gorillas-reply",
"modern-cameras-pull",
"modern-games-dream",
"modern-ligers-behave",
"moody-bags-walk",
"moody-spoons-rhyme",
@@ -171,6 +178,7 @@
"ninety-rice-tickle",
"odd-bears-run",
"olive-bees-buy",
"olive-dragons-drum",
"olive-feet-rhyme",
"olive-kings-invent",
"olive-sheep-rhyme",
@@ -189,6 +197,7 @@
"purple-donkeys-smash",
"purple-singers-greet",
"quick-cycles-confess",
"quick-dots-fetch",
"quiet-feet-travel",
"quiet-pans-hunt",
"quiet-sloths-rule",
@@ -204,6 +213,7 @@
"sharp-olives-sip",
"shy-olives-hang",
"shy-pumpkins-try",
"shy-socks-eat",
"silent-colts-reply",
"silent-lies-run",
"silly-apricots-share",
@@ -241,12 +251,14 @@
"tasty-news-collect",
"ten-hairs-listen",
"ten-rivers-burn",
"tender-cooks-tie",
"tender-pianos-check",
"thick-parrots-float",
"thirty-countries-build",
"thirty-spies-applaud",
"three-lies-pull",
"tidy-clouds-smoke",
"tidy-llamas-compare",
"tough-toes-pull",
"twelve-hornets-sip",
"twelve-lemons-smile",

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/rpc": minor
---
Fix mutability bug in RPC configuration

View File

@@ -0,0 +1,5 @@
---
"blitz": patch
---
using "blitz install" inside recipe with addRunCommandStep causes hangs up

View File

@@ -0,0 +1,7 @@
---
"blitz": patch
"@blitzjs/next": patch
"@blitzjs/rpc": patch
---
Fix ambigious class warning log & upgrade superjson from 1.9.1 to 1.11.0

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/rpc": minor
---
fix resolverPath:root and make it work with monorepo resolvers

View File

@@ -20,7 +20,7 @@ jobs:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
with:
version: 6.32.6
version: 7.11.0
- name: Setup node
uses: actions/setup-node@v2
with:
@@ -35,9 +35,9 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
server-token: ${{ env.TURBO_TOKEN }}
- name: Build
run: pnpm build -- --api="http://127.0.0.1:9080"
run: pnpm build
- name: Lint
run: pnpm lint -- --api="http://127.0.0.1:9080"
run: pnpm lint
build:
runs-on: ubuntu-latest
@@ -46,23 +46,22 @@ jobs:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
with:
version: 6.32.6
version: 7.11.0
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 16
cache: "pnpm"
- run: pnpm install --frozen-lockfile
- run: pnpm manypkg check
- name: Turborepo local server
uses: felixmosh/turborepo-gh-artifacts@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
server-token: ${{ env.TURBO_TOKEN }}
- run: pnpm install --frozen-lockfile
- name: Build
run: pnpm build -- --api="http://127.0.0.1:9080"
run: pnpm build
- name: Build Apps
run: pnpm build:apps -- --api="http://127.0.0.1:9080"
run: pnpm build:apps
Unit-Tests:
name: "Unit Test: ${{ matrix.os }} (node@16)"
@@ -82,7 +81,7 @@ jobs:
- name: Setup PNPM
uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
with:
version: 6.32.6
version: 7.11.0
- name: Setup node@16
uses: actions/setup-node@v2
@@ -90,21 +89,18 @@ jobs:
node-version: 16
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
shell: bash
- run: pnpm manypkg check
shell: bash
- name: Turborepo local server
uses: felixmosh/turborepo-gh-artifacts@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
server-token: ${{ env.TURBO_TOKEN }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
shell: bash
- name: Build
run: pnpm build -- --api="http://127.0.0.1:9080"
run: pnpm build
shell: bash
- name: Test Packages
@@ -150,7 +146,7 @@ jobs:
- name: Setup PNPM
uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
with:
version: 6.32.6
version: 7.11.0
- name: Setup node@${{ matrix.NODE_VERSION }}
uses: actions/setup-node@v2
@@ -158,25 +154,22 @@ jobs:
node-version: ${{ matrix.NODE_VERSION }}
cache: "pnpm"
- name: Link Blitz CLI
run: pnpm link ./packages/blitz
shell: bash
- name: Install dependencies
run: pnpm install --frozen-lockfile
shell: bash
- run: pnpm manypkg check
shell: bash
- name: Turborepo local server
uses: felixmosh/turborepo-gh-artifacts@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
server-token: ${{ env.TURBO_TOKEN }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
shell: bash
- name: Install playwright
run: npx playwright install --with-deps
shell: bash
- name: Build
run: pnpm build -- --api="http://127.0.0.1:9080"
run: pnpm build
shell: bash
- name: Test Packages

View File

@@ -6,7 +6,7 @@
<img alt="" src="https://img.shields.io/badge/Join%20our%20community-6700EB.svg?style=for-the-badge&labelColor=000000&logoWidth=20&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAQ9SURBVHgB7d3dVdtAEIbhcSpICUoH0IEogQqSVBBSAU4FSSpIOoAORAfQgSghHXzZ1U/YcMD4R9rZmf2ec3y448LyiNf27iLiGIAmPLrweC9Un3DhrzG6EarLNP09nlwJ1SOZ/lQr5N80/S/p2QMVCBf5N17XCfm1Y/rBHqjAG9PPHvBsz+mf9WAP+HLA9M/YA14cOP2payH7jpj+VCtk1wnTP+vj7xCy6cTpn7EHLMLp059iD1iD8eveJbVCNsSLheX1YA/YgOWnf8YeKB3Wmf7Ud6Fy4f/FHmtpxbl3YlC4MJ/Cj0bWdwPnPbARg+L0S54XQHS32WwuxClzd4CM0z9rPfeAuTtA5ulPXYQ7wZ04Y+oOoDD9KZc9YOoOoDj9s4dwFzgXR6w1wIPoOvPWA9buAHEJ173o3gWiy3AnuBUHLEbgmYwvAk1/wuM8vAgexThzbwPDkx7/DHwVXfFOxP2GmsKd4Ab6zPeAyU8CI7AHFmH2BRCBPXAyk18GzUrqAXCTiR4ssyj0VFw/oCU8+e+RZ33AWz6KMaYbIIWxB+JSLs1bsbkeMN0AqakHvoku9oA2sAfqBvbAQdw0QArsgb25aYBUQT3QgT2gB+yBuqGcHij2UCqXDZACe2Anlw2QYg/QAOyBuoE98CL3DZDCuK4/rh/Q7oGL6U+TOvcNkJoijN8X1C48+T+g75eQDrAH/qmqAVJgDwyqaoAUe4AGYA/UDZX3QLUNkEIZPRCd5+6BahsgVUgPROwBTSijB7jpVAvGHriHvmw9wAZ4BpX1ABvgmakHtPcbRuwBTWAPULgAV9D/jKDY9YRvwvgEaurD44uQHvAol7qBW7WKluVtIHiUS7GyvA0s6CiXDnxrpQfsgbqBS7GKk/2jYHCrVlGyfxTMrVo0ALdq1Q3sgSKofh0M9oA61a+D2QM0AHugbmAPqClmSRjK2apVVQ8UsySsoK1aHdgDesCtWnUDeyCrIpeFg1u3sylyWTi3btMA7IG6gT2wuuK3hoE9sKrit4YVslWLPaAN7IG6ocKt2zmY2h4O9sDiTG0PZw/QANy6XTewBxZj9ogYVHy025LMHhEz9cBn0We6B0yfERReBLfhx0/R1YQHPx/QBPbA0VwcEwf2wNFcHBPHHjiem3MC2QPHcXdSaJjA+KfgTPQ8hhfjBzHC40mhlzJ+Xq9lK4a4PCs43AVaGTed5mZq+iOXZwWHi3AnOj2wFWNcnxYe7gTxLtBKHuamP/J+Wnh8a5irB7ZC5Yk9gPX1QuXC+usHWqGyhYvUYR0a7zboUOFCNVhnk0krZAOW7wFOvzXhom2xnEbIHizTA1wEYhWW6YFGyC6c1gOcfg9wfA80Qj7g8B7g9HuCww+haIR8wf49wOn3Cvv9k8tGyC/s7gFOv3fY3QONkH+v9MBWqB7PeqDn9FcIT//kcitUn6kHOu/T/xfWzlQy3dEHhwAAAABJRU5ErkJggg==">
</a>
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
<a aria-label="All Contributors" href="#contributors-"><img alt="" src="https://img.shields.io/badge/all_contributors-396-17BB8A.svg?style=for-the-badge&labelColor=000000"></a>
<a aria-label="All Contributors" href="#contributors-"><img alt="" src="https://img.shields.io/badge/all_contributors-398-17BB8A.svg?style=for-the-badge&labelColor=000000"></a>
<!-- ALL-CONTRIBUTORS-BADGE:END -->
<a aria-label="License" href="https://github.com/blitz-js/blitz/blob/main/LICENSE">
<img alt="" src="https://img.shields.io/npm/l/blitz.svg?style=for-the-badge&labelColor=000000&color=blue">
@@ -535,7 +535,7 @@ Thanks to these wonderful people ([emoji key](https://allcontributors.org/docs/e
<td align="center"><a href="https://bhanuteja.dev/"><img src="https://avatars.githubusercontent.com/u/17903466?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Bhanu Teja Pachipulusu</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=pbteja1998" title="Code">💻</a></td>
<td align="center"><a href="https://twitter.com/pavestru"><img src="https://avatars.githubusercontent.com/u/10186479?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Pavel Struhar</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=pavestru" title="Code">💻</a></td>
<td align="center"><a href="https://in-thepink.com/"><img src="https://avatars.githubusercontent.com/u/42126368?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Reo Ishiyama</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=reo777" title="Code">💻</a></td>
<td align="center"><a href="https://macwright.com/"><img src="https://avatars.githubusercontent.com/u/32314?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tom MacWright</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=tmcw" title="Documentation">📖</a></td>
<td align="center"><a href="https://macwright.com/"><img src="https://avatars.githubusercontent.com/u/32314?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tom MacWright</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=tmcw" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=tmcw" title="Tests">⚠️</a> <a href="https://github.com/blitz-js/blitz/commits?author=tmcw" title="Code">💻</a></td>
<td align="center"><a href="https://francoisbest.com"><img src="https://avatars.githubusercontent.com/u/1174092?v=4?s=100" width="100px;" alt=""/><br /><sub><b>François Best</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=franky47" title="Code">💻</a></td>
</tr>
<tr>
@@ -617,7 +617,7 @@ Thanks to these wonderful people ([emoji key](https://allcontributors.org/docs/e
<td align="center"><a href="https://github.com/ricardo-rp"><img src="https://avatars.githubusercontent.com/u/30808767?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ricardo Romero</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=ricardo-rp" title="Documentation">📖</a></td>
<td align="center"><a href="exocortex.anothernode.com"><img src="https://avatars.githubusercontent.com/u/3286144?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Moritz Reiter</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=anothernode" title="Documentation">📖</a></td>
<td align="center"><a href="https://msich.dev"><img src="https://avatars.githubusercontent.com/u/38794918?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Matt Sichterman</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=msichterman" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/medihack"><img src="https://avatars.githubusercontent.com/u/120626?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kai Schlamp</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=medihack" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/medihack"><img src="https://avatars.githubusercontent.com/u/120626?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kai Schlamp</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=medihack" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=medihack" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://muyiwa.me"><img src="https://avatars.githubusercontent.com/u/6832244?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Muyiwa Olu</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=muyiwaolu" title="Code">💻</a></td>
@@ -732,6 +732,8 @@ Thanks to these wonderful people ([emoji key](https://allcontributors.org/docs/e
<td align="center"><a href="https://github.com/oloost"><img src="https://avatars.githubusercontent.com/u/72395941?v=4?s=100" width="100px;" alt=""/><br /><sub><b>oloost</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=oloost" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/janvennemann"><img src="https://avatars.githubusercontent.com/u/1406024?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jan Vennemann</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=janvennemann" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=janvennemann" title="Code">💻</a></td>
<td align="center"><a href="https://kevinjones.engineer"><img src="https://avatars.githubusercontent.com/u/20748598?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kevin Jones</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=joneskj55" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/paulm17"><img src="https://avatars.githubusercontent.com/u/387463?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Paul</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=paulm17" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=paulm17" title="Code">💻</a> <a href="https://github.com/blitz-js/blitz/commits?author=paulm17" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/selcukfatihsevinc"><img src="https://avatars.githubusercontent.com/u/384836?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Selçuk Fatih Sevinç</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=selcukfatihsevinc" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=selcukfatihsevinc" title="Code">💻</a></td>
</tr>
</table>

View File

@@ -30,7 +30,7 @@
"@hookform/error-message": "2.0.0",
"@hookform/resolvers": "2.9.10",
"@prisma/client": "4.6.0",
"blitz": "workspace:2.0.0-beta.17",
"blitz": "workspace:2.0.0-beta.19",
"next": "12.2.5",
"openid-client": "5.2.1",
"prisma": "4.6.0",

View File

@@ -30,7 +30,7 @@
"@hookform/error-message": "2.0.0",
"@hookform/resolvers": "2.9.10",
"@prisma/client": "4.6.0",
"blitz": "workspace:2.0.0-beta.17",
"blitz": "workspace:2.0.0-beta.19",
"next": "12.2.5",
"prisma": "4.6.0",
"react": "18.2.0",

View File

@@ -21,7 +21,7 @@
"@blitzjs/config": "workspace:*",
"@blitzjs/next": "workspace:*",
"@prisma/client": "4.6.0",
"blitz": "workspace:2.0.0-beta.17",
"blitz": "workspace:2.0.0-beta.19",
"lowdb": "3.0.0",
"next": "12.2.5",
"prisma": "4.6.0",

View File

@@ -0,0 +1,3 @@
export default async function getNoSuspenseBasic() {
return "basic-result"
}

View File

@@ -1,9 +1,9 @@
import getBasic from "../app/queries/getBasic"
import getNoSuspenseBasic from "../app/queries/getNoSuspenseBasic"
import {useQuery} from "@blitzjs/rpc"
import React from "react"
function Content() {
const [result, {isFetching}] = useQuery(getBasic, undefined)
const [result, {isFetching}] = useQuery(getNoSuspenseBasic, undefined)
if (isFetching) {
return <>Loading...</>

View File

@@ -1,2 +1,6 @@
const {withBlitz} = require("@blitzjs/next")
module.exports = withBlitz({})
module.exports = withBlitz({
blitz: {
includeRPCFolders: ["../no-suspense/app"],
},
})

View File

@@ -0,0 +1,35 @@
import {getQueryData, useQuery} from "@blitzjs/rpc"
import {Suspense, useState} from "react"
import getNoSuspenseBasic from "../../no-suspense/app/queries/getNoSuspenseBasic"
function Content() {
const [data] = useQuery(getNoSuspenseBasic, undefined)
const [newData, setNewData] = useState<string>()
return (
<div>
<div>{data}</div>
{newData && <div id="new-data">{newData}</div>}
<button
id="button"
onClick={async () => {
const newData = getQueryData(getNoSuspenseBasic, undefined)
setNewData(newData)
}}
>
Call getQueryData
</button>
</div>
)
}
function PageWithGetQueryData() {
return (
<div id="page">
<Suspense fallback={"Loading..."}>
<Content />
</Suspense>
</div>
)
}
export default PageWithGetQueryData

View File

@@ -32,6 +32,25 @@ const runTests = () => {
)
})
describe("get query data from monorepo", () => {
it(
"should work",
async () => {
const browser = await webdriver(appPort, "/page-with-monorepo-query")
browser.waitForElementByCss("#button", 0)
await browser.elementByCss("#button").click()
browser.waitForElementByCss("#new-data", 0)
const newText = await browser.elementByCss("#new-data").text()
expect(newText).toMatch(/basic-result/)
if (browser) await browser.close()
},
5000 * 60 * 2,
)
})
describe("prefetch infinite query", () => {
it(
"should work",

View File

@@ -0,0 +1,4 @@
export default async function setBasic(input, ctx) {
global.basic = input
return global.basic
}

View File

@@ -0,0 +1,12 @@
if (typeof window !== "undefined") {
throw new Error("This should not be loaded on the client")
}
export default async function getBasic() {
if (typeof window !== "undefined") {
throw new Error("This should not be loaded on the client")
}
global.basic ??= "basic-result"
return global.basic
}

View File

@@ -1,3 +1,3 @@
export default async function getBasic() {
return "basic-result"
return "nested-basic"
}

View File

@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.

View File

@@ -0,0 +1,7 @@
const {withBlitz} = require("@blitzjs/next")
module.exports = withBlitz({
blitz: {
resolverPath: "root",
includeRPCFolders: ["../no-suspense/app"],
},
})

View File

@@ -0,0 +1,29 @@
{
"name": "test-rpc-path-root",
"version": "0.0.0",
"private": true,
"scripts": {
"test": "vitest --config ./vitest.config.ts run",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next"
},
"dependencies": {
"@blitzjs/auth": "workspace:*",
"@blitzjs/config": "workspace:*",
"@blitzjs/next": "workspace:*",
"@blitzjs/rpc": "workspace:*",
"blitz": "workspace:*",
"next": "12.2.5",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@types/express": "4.17.13",
"@types/fs-extra": "9.0.13",
"@types/node-fetch": "2.6.1",
"@types/react": "18.0.25",
"b64-lite": "1.4.0",
"eslint": "8.27.0",
"fs-extra": "10.0.1",
"typescript": "^4.8.4"
}
}

View File

@@ -0,0 +1,3 @@
import {rpcHandler} from "@blitzjs/rpc"
export default rpcHandler({onError: console.log})

View File

@@ -0,0 +1,4 @@
const Page = () => {
return <div id="page-container">Hello World</div>
}
export default Page

View File

@@ -0,0 +1,7 @@
import getBasic from "../app/queries/getBasic"
const Page = () => {
getBasic().then(console.log)
return <div id="page-container">Hello World</div>
}
export default Page

View File

@@ -0,0 +1,125 @@
import {describe, it, expect, beforeAll, afterAll} from "vitest"
import fs from "fs-extra"
import {join} from "path"
import {
killApp,
findPort,
launchApp,
fetchViaHTTP,
nextBuild,
nextStart,
} from "../../utils/next-test-utils"
// jest.setTimeout(1000 * 60 * 2)
const appDir = join(__dirname, "../")
let appPort
let mode
let app
function runTests(dev = false) {
describe("api requests", () => {
it(
"regular query works",
async () => {
const data = await fetchViaHTTP(appPort, "/api/rpc/app/queries/getBasic", null, {
method: "POST",
headers: {"Content-Type": "application/json; charset=utf-8"},
body: JSON.stringify({params: {}}),
}).then((res) => res.ok && res.json())
expect(data).toEqual({result: "basic-result", error: null, meta: {}})
},
5000 * 60 * 2,
)
it(
"nested query works",
async () => {
const data = await fetchViaHTTP(appPort, "/api/rpc/app/queries/v2/getBasic", null, {
method: "POST",
headers: {"Content-Type": "application/json; charset=utf-8"},
body: JSON.stringify({params: {}}),
}).then((res) => res.ok && res.json())
expect(data).toEqual({result: "nested-basic", error: null, meta: {}})
},
5000 * 60 * 2,
)
it(
"monorepo query works",
async () => {
const data = await fetchViaHTTP(appPort, "/api/rpc/queries/getNoSuspenseBasic", null, {
method: "POST",
headers: {"Content-Type": "application/json; charset=utf-8"},
body: JSON.stringify({params: {}}),
}).then((res) => res.ok && res.json())
expect(data).toEqual({result: "basic-result", error: null, meta: {}})
},
5000 * 60 * 2,
)
})
}
describe("RPC", () => {
describe(
"dev mode",
() => {
beforeAll(async () => {
try {
appPort = await findPort()
app = await launchApp(appDir, appPort, {cwd: process.cwd()})
} catch (err) {
console.log(err)
}
})
afterAll(() => killApp(app))
runTests(true)
},
5000 * 60 * 2,
)
describe(
"server mode",
() => {
beforeAll(async () => {
await nextBuild(appDir)
mode = "server"
appPort = await findPort()
app = await nextStart(appDir, appPort, {cwd: process.cwd()})
})
afterAll(() => killApp(app))
runTests()
},
5000 * 60 * 2,
)
describe(
"serverless mode",
() => {
let nextConfigContent = ""
const nextConfigPath = join(appDir, "next.config.js")
beforeAll(async () => {
nextConfigContent = await fs.readFile(nextConfigPath, "utf8")
await fs.writeFile(
nextConfigPath,
nextConfigContent.replace("// update me", `target: 'experimental-serverless-trace',`),
)
await nextBuild(appDir)
mode = "serverless"
appPort = await findPort()
app = await nextStart(appDir, appPort, {cwd: process.cwd()})
})
afterAll(async () => {
await killApp(app)
await fs.writeFile(nextConfigPath, nextConfigContent)
})
runTests()
},
5000 * 60 * 2,
)
})

View File

@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "types"],
"exclude": ["node_modules"]
}

View File

@@ -0,0 +1,8 @@
import {defineConfig} from "vitest/config"
export default defineConfig({
test: {
testTimeout: 5000 * 60 * 2,
hookTimeout: 5000 * 60 * 2,
},
})

View File

@@ -21,7 +21,7 @@
"get-port": "6.1.2",
"node-fetch": "3.2.3",
"pkg-dir": "5.0.0",
"playwright-chromium": "1.14.1",
"playwright-chromium": "1.28.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"resolve-cwd": "3.0.0",

View File

@@ -1,5 +1,27 @@
# @blitzjs/auth
## 2.0.0-beta.19
### Minor Changes
- c1e00406: transpile packages to es2015 to support older browsers
### Patch Changes
- Updated dependencies [c1e00406]
- Updated dependencies [696f48c4]
- Updated dependencies [942536d9]
- Updated dependencies [a6f32d1d]
- Updated dependencies [c126b819]
- Updated dependencies [b33db082]
- blitz@2.0.0-beta.19
## 2.0.0-beta.18
### Patch Changes
- blitz@2.0.0-beta.18
## 2.0.0-beta.17
### Patch Changes

View File

@@ -6,6 +6,9 @@ const config: BuildConfig = {
declaration: true,
rollup: {
emitCJS: true,
esbuild: {
target: ["es2015"],
},
},
}
export default config

View File

@@ -1,10 +1,10 @@
{
"name": "@blitzjs/auth",
"version": "2.0.0-beta.17",
"version": "2.0.0-beta.19",
"scripts": {
"build": "unbuild",
"predev": "wait-on -d 250 ../blitz/dist/index-server.d.ts",
"dev": "pnpm run predev && watch unbuild src --wait=0.2",
"dev": "rm -rf dist && pnpm run predev && watch unbuild src --wait=0.2",
"lint": "eslint . --fix",
"test": "vitest run",
"test-watch": "vitest",
@@ -26,7 +26,7 @@
"@types/secure-password": "3.1.1",
"b64-lite": "1.4.0",
"bad-behavior": "1.0.1",
"blitz": "2.0.0-beta.17",
"blitz": "2.0.0-beta.19",
"cookie": "0.4.1",
"cookie-session": "2.0.0",
"debug": "4.3.3",
@@ -40,7 +40,7 @@
"url": "0.11.0"
},
"devDependencies": {
"@blitzjs/config": "workspace:2.0.0-beta.17",
"@blitzjs/config": "workspace:2.0.0-beta.19",
"@testing-library/react": "13.4.0",
"@testing-library/react-hooks": "8.0.1",
"@types/cookie": "0.4.1",

View File

@@ -1,5 +1,28 @@
# @blitzjs/next
## 2.0.0-beta.19
### Minor Changes
- c1e00406: transpile packages to es2015 to support older browsers
### Patch Changes
- b33db082: Fix ambigious class warning log & upgrade superjson from 1.9.1 to 1.11.0
- Updated dependencies [c1e00406]
- Updated dependencies [b33db082]
- Updated dependencies [b493c93f]
- @blitzjs/rpc@2.0.0-beta.19
## 2.0.0-beta.18
### Patch Changes
- Updated dependencies [72a4e594]
- Updated dependencies [ed2b0e22]
- Updated dependencies [c0a3b1ee]
- @blitzjs/rpc@2.0.0-beta.18
## 2.0.0-beta.17
### Patch Changes

View File

@@ -2,10 +2,23 @@ import {BuildConfig} from "unbuild"
const config: BuildConfig = {
entries: ["./src/index-browser", "./src/index-server"],
externals: ["index-browser.cjs", "index-browser.mjs", "blitz", ".blitz", "next", "react"],
externals: [
"index-browser.cjs",
"index-browser.mjs",
"blitz",
".blitz",
"react",
"next",
"next/head",
"next/router",
"next/dist/shared/lib/router/router",
],
declaration: true,
rollup: {
emitCJS: true,
esbuild: {
target: ["es2015"],
},
},
}
export default config

View File

@@ -1,6 +1,6 @@
{
"name": "@blitzjs/next",
"version": "2.0.0-beta.17",
"version": "2.0.0-beta.19",
"scripts": {
"build": "unbuild",
"dev": "pnpm predev && pnpm watch unbuild src --wait=0.2",
@@ -24,17 +24,17 @@
"eslint.js"
],
"dependencies": {
"@blitzjs/rpc": "2.0.0-beta.17",
"@blitzjs/rpc": "2.0.0-beta.19",
"@tanstack/react-query": "4.0.10",
"@types/hoist-non-react-statics": "3.3.1",
"debug": "4.3.3",
"fs-extra": "10.0.1",
"hoist-non-react-statics": "3.3.2",
"superjson": "1.9.1",
"superjson": "1.11.0",
"supports-color": "8.1.1"
},
"devDependencies": {
"@blitzjs/config": "workspace:2.0.0-beta.17",
"@blitzjs/config": "workspace:2.0.0-beta.19",
"@testing-library/dom": "8.13.0",
"@testing-library/jest-dom": "5.16.3",
"@testing-library/react": "13.4.0",
@@ -44,7 +44,7 @@
"@types/react": "18.0.25",
"@types/react-dom": "17.0.14",
"@types/testing-library__react-hooks": "4.0.0",
"blitz": "2.0.0-beta.17",
"blitz": "2.0.0-beta.19",
"cross-spawn": "7.0.3",
"find-up": "4.1.0",
"next": "12.2.5",

View File

@@ -222,6 +222,7 @@ export const setupBlitzServer = ({plugins, onError, logger}: SetupBlitzOptions)
export interface BlitzConfig extends NextConfig {
blitz?: {
resolverPath?: ResolverPathOptions
includeRPCFolders?: string[]
customServer?: {
hotReload?: boolean
}
@@ -252,6 +253,7 @@ export function withBlitz(nextConfig: BlitzConfig = {}) {
webpackConfig: config,
webpackRuleOptions: {
resolverPath: nextConfig.blitz?.resolverPath,
includeRPCFolders: nextConfig.blitz?.includeRPCFolders,
},
})
if (typeof nextConfig.webpack === "function") {

View File

@@ -1,5 +1,30 @@
# @blitzjs/rpc
## 2.0.0-beta.19
### Minor Changes
- c1e00406: transpile packages to es2015 to support older browsers
- b493c93f: fix resolverPath:root and make it work with monorepo resolvers
### Patch Changes
- b33db082: Fix ambigious class warning log & upgrade superjson from 1.9.1 to 1.11.0
- Updated dependencies [c1e00406]
- @blitzjs/auth@2.0.0-beta.19
## 2.0.0-beta.18
### Minor Changes
- 72a4e594: internal: remove unneeed useSession from useQuery hooks
- c0a3b1ee: Fix mutability bug in RPC configuration
### Patch Changes
- ed2b0e22: Add ability to put your query and mutation resolvers in a separate monorepo folder, allowing you to use them in multiple apps.
- @blitzjs/auth@2.0.0-beta.18
## 2.0.0-beta.17
### Patch Changes

View File

@@ -17,10 +17,17 @@ const config: BuildConfig = {
"blitz",
"next",
"zod",
"next",
"next/router",
"next/dist/client/normalize-trailing-slash",
"next/dist/client/add-base-path",
],
declaration: true,
rollup: {
emitCJS: true,
esbuild: {
target: ["es2015"],
},
},
}
export default config

View File

@@ -1,6 +1,6 @@
{
"name": "@blitzjs/rpc",
"version": "2.0.0-beta.17",
"version": "2.0.0-beta.19",
"scripts": {
"build": "unbuild",
"predev": "wait-on -d 400 ../blitz/dist/index-server.d.ts && wait-on -d 400 ../blitz-auth/dist/index-browser.d.ts",
@@ -20,22 +20,22 @@
"dist/**"
],
"dependencies": {
"@blitzjs/auth": "2.0.0-beta.17",
"@blitzjs/auth": "2.0.0-beta.19",
"@swc/core": "1.3.7",
"@tanstack/react-query": "4.0.10",
"b64-lite": "1.4.0",
"bad-behavior": "1.0.1",
"chalk": "^4.1.0",
"debug": "4.3.3",
"superjson": "1.9.1",
"superjson": "1.11.0",
"supports-color": "8.1.1"
},
"devDependencies": {
"@blitzjs/config": "workspace:2.0.0-beta.17",
"@blitzjs/config": "workspace:2.0.0-beta.19",
"@types/debug": "4.1.7",
"@types/react": "18.0.25",
"@types/react-dom": "17.0.14",
"blitz": "2.0.0-beta.17",
"blitz": "2.0.0-beta.19",
"next": "12.2.5",
"react": "18.2.0",
"react-dom": "18.2.0",

View File

@@ -10,7 +10,6 @@ import {
UseMutationOptions,
UseMutationResult,
} from "@tanstack/react-query"
import {useSession} from "@blitzjs/auth"
import {isServer, FirstParam, PromiseReturnType, AsyncFunc} from "blitz"
import {
emptyQueryFn,
@@ -73,11 +72,6 @@ export function useQuery<
const suspenseEnabled = Boolean(globalThis.__BLITZ_SUSPENSE_ENABLED)
let enabled = isServer && suspenseEnabled ? false : options?.enabled ?? options?.enabled !== null
const suspense = enabled === false ? false : options?.suspense
const session = useSession({suspense})
if (session.isLoading) {
enabled = false
}
const routerIsReady = useRouter().isReady || (isServer && suspenseEnabled)
const enhancedResolverRpcClient = sanitizeQuery(queryFn)
const queryKey = getQueryKey(queryFn, params)
@@ -157,12 +151,6 @@ export function usePaginatedQuery<
const suspenseEnabled = Boolean(globalThis.__BLITZ_SUSPENSE_ENABLED)
let enabled = isServer && suspenseEnabled ? false : options?.enabled ?? options?.enabled !== null
const suspense = enabled === false ? false : options?.suspense
const session = useSession({suspense})
if (session.isLoading) {
enabled = false
}
const routerIsReady = useRouter().isReady || (isServer && suspenseEnabled)
const enhancedResolverRpcClient = sanitizeQuery(queryFn)
const queryKey = getQueryKey(queryFn, params)
@@ -252,11 +240,6 @@ export function useInfiniteQuery<
const suspenseEnabled = Boolean(globalThis.__BLITZ_SUSPENSE_ENABLED)
let enabled = isServer && suspenseEnabled ? false : options?.enabled ?? options?.enabled !== null
const suspense = enabled === false ? false : options?.suspense
const session = useSession({suspense})
if (session.isLoading) {
enabled = false
}
const routerIsReady = useRouter().isReady || (isServer && suspenseEnabled)
const enhancedResolverRpcClient = sanitizeQuery(queryFn)
const queryKey = getInfiniteQueryKey(queryFn, getQueryParams)

View File

@@ -61,6 +61,7 @@ const loaderServerResolvers = resolve(dir, "./loader-server-resolvers.cjs")
interface WebpackRuleOptions {
resolverPath: ResolverPathOptions | undefined
includeRPCFolders: string[] | undefined
}
interface WebpackRule {

View File

@@ -43,7 +43,12 @@ export async function transformBlitzRpcResolverClient(
assertPosixPath(root)
const resolverFilePath = "/" + posix.relative(root, id)
assertPosixPath(resolverFilePath)
const routePath = convertPageFilePathToRoutePath(resolverFilePath, options?.resolverPath)
const routePath = convertPageFilePathToRoutePath({
appRoot: root,
absoluteFilePath: resolverFilePath,
resolverBasePath: options?.resolverPath,
extraRpcBasePaths: options?.includeRPCFolders,
})
const resolverName = convertFilePathToResolverName(resolverFilePath)
const resolverType = convertFilePathToResolverType(resolverFilePath)
const resolverConfig: ResolverConfig = {

View File

@@ -43,7 +43,12 @@ export async function transformBlitzRpcResolverServer(
const resolverFilePath = "/" + posix.relative(root, id)
assertPosixPath(resolverFilePath)
const routePath = convertPageFilePathToRoutePath(resolverFilePath, options?.resolverPath)
const routePath = convertPageFilePathToRoutePath({
appRoot: root,
absoluteFilePath: resolverFilePath,
resolverBasePath: options?.resolverPath,
extraRpcBasePaths: options?.includeRPCFolders,
})
const resolverName = convertFilePathToResolverName(resolverFilePath)
const resolverType = convertFilePathToResolverType(resolverFilePath)

View File

@@ -17,12 +17,13 @@ export async function loader(this: Loader, input: string): Promise<string> {
const compiler = this._compiler!
const id = this.resource
const root = this._compiler!.context
const rpcFolders = this.query.includeRPCFolders ? this.query.includeRPCFolders : []
const isSSR = compiler.name === "server"
if (isSSR) {
this.cacheable(false)
const resolvers = await collectResolvers(root, ["ts", "js"])
const resolvers = await collectResolvers(root, rpcFolders, ["ts", "js"])
return await transformBlitzRpcServer(
input,
toPosixPath(id),
@@ -56,17 +57,35 @@ export async function transformBlitzRpcServer(
let code = blitzImport + src
code += "\n\n"
for (let resolverFilePath of resolvers) {
const relativeResolverPath = slash(relative(dirname(id), join(root, resolverFilePath)))
const routePath = convertPageFilePathToRoutePath(resolverFilePath, options?.resolverPath)
code += `__internal_addBlitzRpcResolver('${routePath}',() => import('${relativeResolverPath}'));`
const routePath = convertPageFilePathToRoutePath({
appRoot: root,
absoluteFilePath: resolverFilePath,
resolverBasePath: options?.resolverPath,
extraRpcBasePaths: options?.includeRPCFolders,
})
code += `__internal_addBlitzRpcResolver('${routePath}',() => import('${slash(
resolverFilePath,
)}'));`
code += "\n"
}
// console.log("NEW CODE", code)
return code
}
export function collectResolvers(directory: string, pageExtensions: string[]): Promise<string[]> {
return recursiveFindResolvers(directory, buildPageExtensionRegex(pageExtensions))
export function collectResolvers(
directory: string,
rpcFolders: string[],
pageExtensions: string[],
): Promise<string[]> {
return recursiveFindResolvers(
directory,
buildPageExtensionRegex(pageExtensions),
undefined,
[],
directory,
rpcFolders,
)
}
export async function recursiveFindResolvers(
@@ -75,11 +94,13 @@ export async function recursiveFindResolvers(
ignore?: RegExp,
arr: string[] = [],
rootDir: string = dir,
rpcFolders: string[] = [],
): Promise<string[]> {
let folders = await promises.readdir(dir)
if (dir === rootDir) {
folders = folders.filter((folder) => topLevelFoldersThatMayContainResolvers.includes(folder))
folders.push(...rpcFolders)
}
await Promise.all(
@@ -90,17 +111,18 @@ export async function recursiveFindResolvers(
const pathStat = await promises.stat(absolutePath)
if (pathStat.isDirectory()) {
await recursiveFindResolvers(absolutePath, filter, ignore, arr, rootDir)
return
if (!absolutePath.includes("node_modules")) {
await recursiveFindResolvers(absolutePath, filter, ignore, arr, rootDir)
return
}
}
if (!filter.test(part)) {
return
}
const relativeFromRoot = absolutePath.replace(rootDir, "")
if (getIsRpcFile(relativeFromRoot)) {
arr.push(relativeFromRoot)
if (getIsRpcFile(absolutePath)) {
arr.push(absolutePath)
return
}
}),

View File

@@ -1,24 +1,52 @@
import {describe, expect, it} from "vitest"
import {convertPageFilePathToRoutePath} from "./loader-utils"
const FILE_PATH = "app/queries/getData.ts"
const APP_ROOT = "/Users/blitz/project"
const FILE_PATH = "/Users/blitz/project/app/queries/getData.ts"
const WIN_APP_ROOT = `D:a\\blitz\\project`
const WIN_FILE_PATH = `D:a\\blitz\\project\\app\\queries\\getData.ts`
describe("convertPageFilePathToRoutePath", () => {
it("should return the full path when resolverBasePath is set to root", () => {
const res = convertPageFilePathToRoutePath(FILE_PATH, "root")
const res = convertPageFilePathToRoutePath({
absoluteFilePath: FILE_PATH,
resolverBasePath: "root",
appRoot: APP_ROOT,
})
expect(res).toEqual("app/queries/getData")
expect(res).toEqual("/app/queries/getData")
})
it("should return the relative path when resolverBasePath is set to queries|mutations", () => {
const res = convertPageFilePathToRoutePath(FILE_PATH, "queries|mutations")
const res = convertPageFilePathToRoutePath({
absoluteFilePath: FILE_PATH,
resolverBasePath: "queries|mutations",
appRoot: APP_ROOT,
})
expect(res).toEqual("/getData")
})
it("should return the relative path when resolverBasePath is set to undefined", () => {
const res = convertPageFilePathToRoutePath(FILE_PATH, undefined)
const res = convertPageFilePathToRoutePath({
absoluteFilePath: FILE_PATH,
resolverBasePath: undefined,
appRoot: APP_ROOT,
})
expect(res).toEqual("/getData")
})
describe("windwos", () => {
it("should return the full path when resolverBasePath is set to root", () => {
const res = convertPageFilePathToRoutePath({
absoluteFilePath: WIN_FILE_PATH,
resolverBasePath: "root",
appRoot: WIN_APP_ROOT,
})
expect(res).toEqual("/app/queries/getData")
})
})
})

View File

@@ -1,9 +1,10 @@
import {assert} from "blitz"
import {posix, sep, win32} from "path"
import {posix, sep, win32, join, normalize} from "path"
import {ResolverPathOptions} from "./index-server"
export interface LoaderOptions {
resolverPath: ResolverPathOptions
includeRPCFolders?: string[]
}
export interface Loader {
@@ -49,23 +50,31 @@ export function buildPageExtensionRegex(pageExtensions: string[]) {
const fileExtensionRegex = /\.([a-z]+)$/
export function convertPageFilePathToRoutePath(
filePath: string,
resolverPath?: ResolverPathOptions,
) {
if (typeof resolverPath === "function") {
return resolverPath(filePath)
export function convertPageFilePathToRoutePath({
absoluteFilePath,
resolverBasePath,
appRoot,
extraRpcBasePaths = [],
}: {
appRoot: string
absoluteFilePath: string
resolverBasePath?: ResolverPathOptions
extraRpcBasePaths?: string[]
}) {
let path = normalize(absoluteFilePath)
if (typeof resolverBasePath === "function") {
path = resolverBasePath(path)
} else if (resolverBasePath === "root") {
path = path.replace(normalize(appRoot), "")
for (const extraPath of extraRpcBasePaths) {
path = path.replace(join(normalize(appRoot), extraPath.replace("/", sep)), "")
}
} else {
path = path.replace(/^.*?[\\/]queries[\\/]/, "/").replace(/^.*?[\\/]mutations[\\/]/, "/")
}
if (resolverPath === "root") {
return filePath.replace(fileExtensionRegex, "")
}
return filePath
.replace(/^.*?[\\/]queries[\\/]/, "/")
.replace(/^.*?[\\/]mutations[\\/]/, "/")
.replace(/\\/g, "/")
.replace(fileExtensionRegex, "")
return path.replace(/\\/g, "/").replace(fileExtensionRegex, "")
}
export function convertFilePathToResolverName(filePathFromAppRoot: string) {

View File

@@ -0,0 +1,30 @@
import {describe, expect, it} from "vitest"
import {getResolverConfig} from "./parse-rpc-config"
describe("getResolverConfig", () => {
it("base case: no configuration", async () => {
const result = getResolverConfig("")
expect(result).toHaveProperty("httpMethod", "POST")
})
it("customized to get", async () => {
const result = getResolverConfig(`
export const config = {
httpMethod: 'GET'
}
`)
expect(result).toHaveProperty("httpMethod", "GET")
})
it("evaluation is hermetic", async () => {
expect(
getResolverConfig(`
export const config = {
httpMethod: 'GET'
}
`),
).toHaveProperty("httpMethod", "GET")
expect(getResolverConfig(``)).toHaveProperty("httpMethod", "POST")
})
})

View File

@@ -3,12 +3,10 @@ import {ResolverConfig} from "blitz"
type _ResolverType = "GET" | "POST"
const defaultResolverConfig: ResolverConfig = {
httpMethod: "POST",
}
export function getResolverConfig(content: string): ResolverConfig {
const resolverConfig = defaultResolverConfig
const resolverConfig: ResolverConfig = {
httpMethod: "POST",
}
const resolver = parseSync(content, {
syntax: "typescript",
target: "es2020",

View File

@@ -1,5 +1,30 @@
# blitz
## 2.0.0-beta.19
### Major Changes
- 942536d9: update paginate.ts, return more params for more complex pagination control
### Minor Changes
- c1e00406: transpile packages to es2015 to support older browsers
- 696f48c4: some providers need extra attributes, update for wrapAppWithProvider
### Patch Changes
- a6f32d1d: Export enhancePrisma for client again (Fixes #3964)
- c126b819: using "blitz install" inside recipe with addRunCommandStep causes hangs up
- b33db082: Fix ambigious class warning log & upgrade superjson from 1.9.1 to 1.11.0
- Updated dependencies [b80c3d92]
- @blitzjs/generator@2.0.0-beta.19
## 2.0.0-beta.18
### Patch Changes
- @blitzjs/generator@2.0.0-beta.18
## 2.0.0-beta.17
### Patch Changes

View File

@@ -1,2 +1,2 @@
#!/usr/bin/env node
require("blitz/dist/index.cjs")
require("../dist/index.cjs")

View File

@@ -6,6 +6,9 @@ const config: BuildConfig = {
declaration: true,
rollup: {
emitCJS: true,
esbuild: {
target: ["es2015"],
},
},
}
export default config

View File

@@ -1,9 +1,9 @@
{
"name": "blitz",
"version": "2.0.0-beta.17",
"version": "2.0.0-beta.19",
"scripts": {
"build": "unbuild",
"dev": "pnpm run predev && watch unbuild src --wait=0.2",
"dev": "rm -rf dist && pnpm run predev && watch unbuild src --wait=0.2",
"lint": "eslint . --fix",
"test": "vitest run",
"test-watch": "vitest",
@@ -25,7 +25,7 @@
"blitz": "bin/blitz"
},
"dependencies": {
"@blitzjs/generator": "2.0.0-beta.17",
"@blitzjs/generator": "2.0.0-beta.19",
"@mrleebo/prisma-ast": "0.2.6",
"@types/global-agent": "2.1.1",
"arg": "5.0.1",
@@ -64,7 +64,7 @@
"resolve-cwd": "3.0.0",
"resolve-from": "5.0.0",
"rimraf": "3.0.2",
"superjson": "1.9.1",
"superjson": "1.11.0",
"supports-color": "8.1.1",
"tar": "6.1.11",
"ts-node": "10.9.1",
@@ -73,7 +73,7 @@
"watchpack": "2.1.1"
},
"devDependencies": {
"@blitzjs/config": "workspace:2.0.0-beta.17",
"@blitzjs/config": "workspace:2.0.0-beta.19",
"@types/cookie": "0.4.1",
"@types/cross-spawn": "6.0.2",
"@types/debug": "4.1.7",

View File

@@ -1,6 +1,10 @@
import _SuperJson from "superjson"
import type {UrlObject} from "url"
declare module globalThis {
let _BLITZ_ERROR_CLASS_REGISTERED: boolean
}
const SuperJson: typeof _SuperJson =
"default" in _SuperJson ? (_SuperJson as any).default : _SuperJson
@@ -19,12 +23,6 @@ export class AuthenticationError extends Error {
return true
}
}
if (process.env.JEST_WORKER_ID === undefined) {
SuperJson.registerClass(AuthenticationError, {
identifier: "BlitzAuthenticationError",
allowProps: errorProps,
})
}
export class CSRFTokenMismatchError extends Error {
name = "CSRFTokenMismatchError"
@@ -33,12 +31,6 @@ export class CSRFTokenMismatchError extends Error {
return true
}
}
if (process.env.JEST_WORKER_ID === undefined) {
SuperJson.registerClass(CSRFTokenMismatchError, {
identifier: "BlitzCSRFTokenMismatchError",
allowProps: errorProps,
})
}
export class AuthorizationError extends Error {
name = "AuthorizationError"
@@ -50,12 +42,6 @@ export class AuthorizationError extends Error {
return true
}
}
if (process.env.JEST_WORKER_ID === undefined) {
SuperJson.registerClass(AuthorizationError, {
identifier: "BlitzAuthorizationError",
allowProps: errorProps,
})
}
export class NotFoundError extends Error {
name = "NotFoundError"
@@ -67,12 +53,6 @@ export class NotFoundError extends Error {
return true
}
}
if (process.env.JEST_WORKER_ID === undefined) {
SuperJson.registerClass(NotFoundError, {
identifier: "BlitzNotFoundError",
allowProps: errorProps,
})
}
export class RedirectError extends Error {
name = "RedirectError"
@@ -86,12 +66,6 @@ export class RedirectError extends Error {
return true
}
}
if (process.env.JEST_WORKER_ID === undefined) {
SuperJson.registerClass(RedirectError, {
identifier: "BlitzRedirectError",
allowProps: errorProps,
})
}
export class PaginationArgumentError extends Error {
name = "PaginationArgumentError"
@@ -100,9 +74,37 @@ export class PaginationArgumentError extends Error {
super(message)
}
}
if (process.env.JEST_WORKER_ID === undefined) {
if (process.env.JEST_WORKER_ID === undefined && !globalThis._BLITZ_ERROR_CLASS_REGISTERED) {
SuperJson.registerClass(AuthenticationError, {
identifier: "BlitzAuthenticationError",
allowProps: errorProps,
})
SuperJson.registerClass(CSRFTokenMismatchError, {
identifier: "BlitzCSRFTokenMismatchError",
allowProps: errorProps,
})
SuperJson.registerClass(AuthorizationError, {
identifier: "BlitzAuthorizationError",
allowProps: errorProps,
})
SuperJson.registerClass(NotFoundError, {
identifier: "BlitzNotFoundError",
allowProps: errorProps,
})
SuperJson.registerClass(RedirectError, {
identifier: "BlitzRedirectError",
allowProps: errorProps,
})
SuperJson.registerClass(PaginationArgumentError, {
identifier: "BlitzPaginationArgumentError",
allowProps: errorProps,
})
globalThis._BLITZ_ERROR_CLASS_REGISTERED = true
}

View File

@@ -95,4 +95,5 @@ if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
export * from "./utils"
export * from "./types"
export * from "./utils/enhance-prisma"
export * from "./utils/zod"

View File

@@ -79,7 +79,8 @@ export async function executeCommand(input: CliCommand): Promise<void> {
const cp = spawn(`${command[0]}`, command.slice(1), {
stdio: ["inherit", "pipe", "pipe"],
})
cp.on("exit", resolve)
cp.on("exit", resolve);
cp.stdout.on('data', () => {});
})
}

View File

@@ -1,9 +1,13 @@
import {NodePath} from "ast-types/lib/node-path"
import j from "jscodeshift"
import j, {JSXAttribute} from "jscodeshift"
import {assert} from "../../index-server"
import {Program} from "../types"
export function wrapAppWithProvider(program: Program, element: string): Program {
export function wrapAppWithProvider(
program: Program,
element: string,
attributes?: string[],
): Program {
const findMyApp = program.find(j.FunctionDeclaration, (node) => node.id.name === "MyApp")
assert(findMyApp.length, "MyApp function not found")
@@ -13,8 +17,13 @@ export function wrapAppWithProvider(program: Program, element: string): Program
)[0]
const argument = statement.argument
let attrs: JSXAttribute[] = []
if (attributes) {
attrs = attributes.map((i) => j.jsxAttribute(j.jsxIdentifier(i)))
}
statement.argument = j.jsxElement(
j.jsxOpeningElement(j.jsxIdentifier(element)),
j.jsxOpeningElement(j.jsxIdentifier(element), attrs),
j.jsxClosingElement(j.jsxIdentifier(element)),
[j.jsxText("\n"), argument, j.jsxText("\n")],
)

View File

@@ -48,11 +48,18 @@ export async function paginate<QueryResult>({
const hasMore = skip + take < count
const nextPage = hasMore ? {take, skip: skip + take} : null
const pageCount = Math.floor((count + take - 1) / take)
const from = skip + 1
const to = skip + take
return {
items,
nextPage,
hasMore,
pageCount: pageCount,
pageSize: take,
from,
to,
count,
}
}

View File

@@ -74,6 +74,10 @@ describe("paginate", () => {
nextPage: null,
hasMore: false,
count: 3,
from: 2,
pageCount: 2,
pageSize: 2,
to: 3,
},
},
{
@@ -88,6 +92,10 @@ describe("paginate", () => {
nextPage: {skip: 3, take: 2},
hasMore: true,
count: 4,
from: 2,
pageCount: 2,
pageSize: 2,
to: 3,
},
},
]

View File

@@ -1,5 +1,26 @@
# @blitzjs/codemod
## 2.0.0-beta.19
### Patch Changes
- Updated dependencies [c1e00406]
- Updated dependencies [696f48c4]
- Updated dependencies [b80c3d92]
- Updated dependencies [942536d9]
- Updated dependencies [a6f32d1d]
- Updated dependencies [c126b819]
- Updated dependencies [b33db082]
- blitz@2.0.0-beta.19
- @blitzjs/generator@2.0.0-beta.19
## 2.0.0-beta.18
### Patch Changes
- @blitzjs/generator@2.0.0-beta.18
- blitz@2.0.0-beta.18
## 2.0.0-beta.17
### Patch Changes

View File

@@ -6,6 +6,9 @@ const config: BuildConfig = {
declaration: true,
rollup: {
emitCJS: true,
esbuild: {
target: ["es2015"],
},
},
}
export default config

View File

@@ -1,6 +1,6 @@
{
"name": "@blitzjs/codemod",
"version": "2.0.0-beta.17",
"version": "2.0.0-beta.19",
"scripts": {
"build": "unbuild",
"dev": "watch unbuild src --wait=0.2",
@@ -25,9 +25,9 @@
"@babel/plugin-proposal-class-properties": "7.17.12",
"@babel/plugin-syntax-jsx": "7.17.12",
"@babel/plugin-syntax-typescript": "7.17.12",
"@blitzjs/generator": "2.0.0-beta.17",
"@blitzjs/generator": "2.0.0-beta.19",
"arg": "5.0.1",
"blitz": "2.0.0-beta.17",
"blitz": "2.0.0-beta.19",
"chalk": "^4.1.0",
"cross-spawn": "7.0.3",
"debug": "4.3.3",

View File

@@ -1,5 +1,9 @@
# @blitzjs/config
## 2.0.0-beta.19
## 2.0.0-beta.18
## 2.0.0-beta.17
## 2.0.0-beta.16

View File

@@ -1,7 +1,7 @@
{
"name": "@blitzjs/config",
"private": true,
"version": "2.0.0-beta.17",
"version": "2.0.0-beta.19",
"license": "MIT",
"dependencies": {
"@typescript-eslint/eslint-plugin": "5.42.1",

View File

@@ -1,5 +1,13 @@
# @blitzjs/generator
## 2.0.0-beta.19
### Patch Changes
- b80c3d92: Fix form paths when running blitz generate all
## 2.0.0-beta.18
## 2.0.0-beta.17
### Patch Changes

View File

@@ -6,6 +6,9 @@ const config: BuildConfig = {
declaration: true,
rollup: {
emitCJS: true,
esbuild: {
target: ["es2015"],
},
},
}
export default config

View File

@@ -1,6 +1,6 @@
{
"name": "@blitzjs/generator",
"version": "2.0.0-beta.17",
"version": "2.0.0-beta.19",
"scripts": {
"dev": "watch unbuild src --wait=0.2",
"build": "unbuild && pnpm build:templates",
@@ -47,7 +47,7 @@
"vinyl": "2.2.1"
},
"devDependencies": {
"@blitzjs/config": "2.0.0-beta.17",
"@blitzjs/config": "2.0.0-beta.19",
"@juanm04/cpx": "2.0.1",
"@types/babel__core": "7.1.19",
"@types/diff": "5.0.2",

View File

@@ -1,7 +1,7 @@
import {Form, FormProps} from "app/core/components/Form"
import {LabeledTextField} from "app/core/components/LabeledTextField"
import {Form, FormProps} from "src/core/components/Form"
import {LabeledTextField} from "src/core/components/LabeledTextField"
import {z} from "zod"
export {FORM_ERROR} from "app/core/components/Form"
export {FORM_ERROR} from "src/core/components/Form"
export function __ModelName__Form<S extends z.ZodType<any, any>>(props: FormProps<S>) {
return (

View File

@@ -6,6 +6,9 @@ const config: BuildConfig = {
declaration: true,
rollup: {
emitCJS: true,
esbuild: {
target: ["es2015"],
},
},
}
export default config

View File

@@ -25,7 +25,7 @@
"@typescript-eslint/parser": "5.9.1"
},
"devDependencies": {
"@blitzjs/config": "2.0.0-beta.17",
"@blitzjs/config": "2.0.0-beta.19",
"@types/react": "18.0.25",
"@types/react-dom": "17.0.14",
"react": "18.2.0",

517
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -23,7 +23,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17",
"blitz": "2.0.0-beta.19",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -22,7 +22,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17",
"blitz": "2.0.0-beta.19",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -24,7 +24,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17",
"blitz": "2.0.0-beta.19",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -24,7 +24,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17",
"blitz": "2.0.0-beta.19",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -22,7 +22,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17",
"blitz": "2.0.0-beta.19",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -24,6 +24,6 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17"
"blitz": "2.0.0-beta.19"
}
}

View File

@@ -24,6 +24,6 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17"
"blitz": "2.0.0-beta.19"
}
}

View File

@@ -23,7 +23,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17",
"blitz": "2.0.0-beta.19",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -22,7 +22,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17",
"blitz": "2.0.0-beta.19",
"jscodeshift": "0.13.0",
"uuid": "^8.3.1"
},

View File

@@ -23,7 +23,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17",
"blitz": "2.0.0-beta.19",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -23,7 +23,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17",
"blitz": "2.0.0-beta.19",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -23,7 +23,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17",
"blitz": "2.0.0-beta.19",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -23,6 +23,6 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17"
"blitz": "2.0.0-beta.19"
}
}

View File

@@ -22,6 +22,6 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17"
"blitz": "2.0.0-beta.19"
}
}

View File

@@ -23,7 +23,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17",
"blitz": "2.0.0-beta.19",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -22,6 +22,6 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17"
"blitz": "2.0.0-beta.19"
}
}

View File

@@ -22,7 +22,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17",
"blitz": "2.0.0-beta.19",
"jscodeshift": "0.13.0",
"uuid": "^8.3.1"
},

View File

@@ -24,7 +24,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17",
"blitz": "2.0.0-beta.19",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -24,7 +24,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17",
"blitz": "2.0.0-beta.19",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -22,7 +22,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17",
"blitz": "2.0.0-beta.19",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -23,7 +23,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17",
"blitz": "2.0.0-beta.19",
"jscodeshift": "0.13.0"
},
"devDependencies": {

View File

@@ -25,7 +25,7 @@
},
"homepage": "https://github.com/blitz-js/blitz#readme",
"dependencies": {
"blitz": "2.0.0-beta.17",
"blitz": "2.0.0-beta.19",
"jscodeshift": "0.13.0"
},
"devDependencies": {