Skip to content

Commit

Permalink
chore: releases
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Oct 27, 2024
1 parent 76569fa commit 3fdd339
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 36 deletions.
5 changes: 0 additions & 5 deletions .changeset/polite-carrots-warn.md

This file was deleted.

62 changes: 33 additions & 29 deletions packages/client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @tuyau/client

## 0.1.3

### Patch Changes

- 76569fa: Incorrect TuyauResponse typing. Fix #11

## 0.1.2

### Patch Changes
Expand All @@ -8,18 +14,18 @@

```ts
// Current window location is http://localhost:3000/users/1/posts/2, route name is users.posts.show
tuyau.$current(); // users.posts
tuyau.$current("users.posts.show"); // true
tuyau.$current("users.*"); // true
tuyau.$current("users.edit"); // false
tuyau.$current() // users.posts
tuyau.$current('users.posts.show') // true
tuyau.$current('users.*') // true
tuyau.$current('users.edit') // false
```

You can also specify route parameters or query parameters to check :

```ts
tuyau.$current("users.posts.show", { params: { id: 1, postId: 2 } }); // true
tuyau.$current("users.posts.show", { params: { id: 12 } }); // false
tuyau.$current("users.posts.show", { query: { page: 1 } }); // false
tuyau.$current('users.posts.show', { params: { id: 1, postId: 2 } }) // true
tuyau.$current('users.posts.show', { params: { id: 12 } }) // false
tuyau.$current('users.posts.show', { query: { page: 1 } }) // false
```

## 0.1.0
Expand All @@ -37,13 +43,13 @@
```ts
/// <reference path="../../adonisrc.ts" />

import { createTuyau } from "@tuyau/client";
import type { api } from "@your-monorepo/server/.adonisjs/api";
import { createTuyau } from '@tuyau/client'
import type { api } from '@your-monorepo/server/.adonisjs/api'

export const tuyau = createTuyau({
api,
baseUrl: "http://localhost:3333",
});
baseUrl: 'http://localhost:3333',
})
```

As you can see, you first need to change the import path and the imported value. Next, you need to pass this `api` object as an argument to the `createTuyau` function.
Expand All @@ -58,35 +64,33 @@

```ts
// Backend
router
.get("/posts/:id/generate-invitation", "...")
.as("posts.generateInvitation");
router.get('/posts/:id/generate-invitation', '...').as('posts.generateInvitation')
// Client
await tuyau.$route("posts.generateInvitation", { id: 1 }).$get({
await tuyau.$route('posts.generateInvitation', { id: 1 }).$get({
query: { limit: 10, page: 1 },
});
})
```

### Generating URL from route name

If you need to generate the URL of a route using the route name, you can use the `$url` method. This method is pretty similar to [Ziggy](https://github.com/tighten/ziggy) behavior :

```ts
tuyau.$url("users.posts", { id: 1, postId: 2 }); // http://localhost:3333/users/1/posts/2
tuyau.$url("venues.events.show", [1, 2]); // http://localhost:3333/venues/1/events/2
tuyau.$url("users", { query: { page: 1, limit: 10 } }); // http://localhost:3333/users?page=1&limit=10
tuyau.$url('users.posts', { id: 1, postId: 2 }) // http://localhost:3333/users/1/posts/2
tuyau.$url('venues.events.show', [1, 2]) // http://localhost:3333/venues/1/events/2
tuyau.$url('users', { query: { page: 1, limit: 10 } }) // http://localhost:3333/users?page=1&limit=10
```

If you are used to Ziggy and prefer to have a `route` method instead of `$url`, you can define a custom method in your client file pretty easily :

```ts
export const tuyau = createTuyau({
api,
baseUrl: "http://localhost:3333",
});
baseUrl: 'http://localhost:3333',
})
window.route = tuyau.$url.bind(tuyau);
window.route = tuyau.$url.bind(tuyau)
```

Then you can use the `route` method in your frontend code :
Expand All @@ -95,9 +99,9 @@
export function MyComponent() {
return (
<div>
<a href={route("users.posts", { id: 1, postId: 2 })}>Go to post</a>
<a href={route('users.posts', { id: 1, postId: 2 })}>Go to post</a>
</div>
);
)
}
```

Expand All @@ -106,11 +110,11 @@
If you need to check if a route name exists, you can use the `$has` method. You can also use wildcards in the route name :

```ts
tuyau.$has("users"); // true
tuyau.$has("users.posts"); // true
tuyau.$has("users.*.comments"); // true
tuyau.$has("users.*"); // true
tuyau.$has("non-existent"); // false
tuyau.$has('users') // true
tuyau.$has('users.posts') // true
tuyau.$has('users.*.comments') // true
tuyau.$has('users.*') // true
tuyau.$has('non-existent') // false
```

## 0.0.9
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tuyau/client",
"type": "module",
"version": "0.1.2",
"version": "0.1.3",
"description": "e2e client for AdonisJS",
"author": "Julien Ripouteau <[email protected]>",
"license": "ISC",
Expand Down
7 changes: 7 additions & 0 deletions packages/inertia/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @tuyau/inertia

## 0.0.4

### Patch Changes

- Updated dependencies [76569fa]
- @tuyau/client@0.1.3

## 0.0.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/inertia/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tuyau/inertia",
"type": "module",
"version": "0.0.3",
"version": "0.0.4",
"description": "",
"author": "Julien Ripouteau <[email protected]>",
"license": "ISC",
Expand Down

0 comments on commit 3fdd339

Please sign in to comment.