Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
run: pnpm build

- name: Bump version with release tag name
if: ${{ github.event_name == 'release' }}
run: pnpm version --no-git-tag-version ${{ github.event.release.tag_name }}

- name: Pack package
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
name: package
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 24
registry-url: https://registry.npmjs.org/
- run: npm publish $(ls *.tgz) --access=public --tag ${{ github.event.release.prerelease && 'next' || 'latest'}}
env:
Expand All @@ -46,7 +46,7 @@ jobs:
name: package
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 24
registry-url: https://npm.pkg.github.com/
- run: npm publish $(ls *.tgz) --access=public --tag ${{ github.event.release.prerelease && 'next' || 'latest'}}
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 24

- uses: pnpm/action-setup@v4

Expand Down
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@

All notable changes to this project will be documented in this file.

## [3.0.0] - Unreleased

### Changed

- **BREAKING:** upgraded `ky` to `2.x`, which renames the `HttpClient` option `prefixUrl` to `prefix`. Update every `new HttpClient({ prefixUrl })`, `createHttpClient({ prefixUrl })` and `httpClientOptions: { prefixUrl }` usage to `prefix`.

## [2.0.5] - 2026-06-15

### Fixed

- TypeScript 6 compatibility: removed deprecated `baseUrl`, updated `moduleResolution` to `Bundler`.
- Updated `ky` imports to use the public entry point only, removing internal path dependencies.
- Fixed relative import paths and implicit `any` types in `src/vue/index.ts`.
- `RepositoryHttp` default metadata adapter no longer drops `contentLanguage` when both `Content-Language` and `Accept-Language` response headers are present.
- `useRepositoryHttp` `create()` and `update()` now expose the `item` ref, consistently with `read()`.
- `HttpClientInstance.setBearerToken` type signature now matches the implementation (nullable token and options).

### Added

- `item` ref returned by the `create()` and `update()` Vue composables.

### Internal

- `RepositoryHttp.create()`/`update()` and the Vue repository composables refactored to remove duplication.
- Type-check and tests now cover the `test/` folder; declaration emit moved to a dedicated `tsconfig.build.json`.

## [2.0.4] - 2025-10-09

### Fixed
Expand Down Expand Up @@ -117,6 +143,8 @@ All notable changes to this project will be documented in this file.
- `UrlBuilder` a class to build URLs through a template;
- `RepositoryHttp` an implementation of `Repository` interface to fetch data through `HttpClient`.

[3.0.0]: https://github.com/volverjs/data/compare/v2.0.5...v3.0.0
[2.0.5]: https://github.com/volverjs/data/compare/v2.0.4...v2.0.5
[2.0.4]: https://github.com/volverjs/data/compare/v2.0.3...v2.0.4
[2.0.3]: https://github.com/volverjs/data/compare/v2.0.2...v2.0.3
[2.0.2]: https://github.com/volverjs/data/compare/v2.0.1...v2.0.2
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class User {
constructor(data: { id: number, name: string, surname: string }) {
this.id = data.id
this.name = data.name
this.email = data.email
this.surname = data.surname
}

get fullName() {
Expand Down Expand Up @@ -228,7 +228,7 @@ async function execute() {
</template>
```

`useHttpClient()` also exposes `request()`, `requestGet()`, `requestPost()`, `requestPut()`, `requestPatch()` and `requestDelete()` methods. These methods are wrappers around the `HttpClient` methods with reactivity.
`useHttpClient()` also exposes `request()`, `requestGet()`, `requestPost()`, `requestPut()`, `requestPatch()`, `requestHead()` and `requestDelete()` methods. These methods are wrappers around the `HttpClient` methods with reactivity.

```vue
<script lang="ts" setup>
Expand Down Expand Up @@ -442,8 +442,8 @@ async function execute() {
<div v-if="isError">
{{ error }}
</div>
<div v-if="data">
{{ data.name }}
<div v-if="item">
{{ item?.name }}
</div>
</div>
</template>
Expand Down Expand Up @@ -559,7 +559,7 @@ The `HttpClientPlugin` can manage a `Map` of `httpClient` instances.

With `scope` parameter on `createHttpClient()` multiple `httpClient` instances can be created. If the `httpClient` `scope` instance already exist an error is throwed: `httpClient with scope ${scope} already exist`.

##### Parameters:
#### Parameters:

`options?`: `HttpClientInstanceOptions & { scope: string }`

Expand All @@ -582,17 +582,17 @@ const { isLoading, isError, data } = requestGet<User>('users')
With this composable the `httpClient` instance can be removed from Map instances.
The `global` `httpClient` instance cannot be removed.

##### Parameters:
#### Parameters:

`scope`: `string`,

##### Example:

```vue
<script lang="ts" setup>
import { addHttpClient, removeHttpClient } from '@volverjs/data/vue'
import { createHttpClient, removeHttpClient } from '@volverjs/data/vue'

createHttpClient('v2Api', { prefixUrl: 'https://my.api.com/v2' })
createHttpClient({ scope: 'v2Api', prefixUrl: 'https://my.api.com/v2' })

const { requestGet } = useHttpClient('v2Api')

Expand Down
45 changes: 20 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@volverjs/data",
"type": "module",
"version": "0.0.0",
"packageManager": "pnpm@10.18.1",
"packageManager": "pnpm@11.7.0",
"description": "Repository pattern implementation with a tiny HttpClient based on Fetch API.",
"author": "8 Wave S.r.l.",
"license": "MIT",
Expand Down Expand Up @@ -96,44 +96,39 @@
"lint:fix": "eslint --fix",
"type-check": "tsc --noEmit",
"dev": "vite build --watch",
"build": "vite build && vue-tsc --declaration --emitDeclarationOnly && copy src/**/*.d.ts dist",
"build": "vite build && vue-tsc --declaration --emitDeclarationOnly -p tsconfig.build.json && copy src/**/*.d.ts dist",
"test": "pnpm run test-vitest",
"test-vitest": "vitest run",
"test-vitest-watch": "vitest watch",
"credits": "npx @opengovsg/credits-generator"
},
"dependencies": {
"abort-controller": "^3.0.0",
"ky": "^1.11.0",
"ky": "^1.14.3",
"node-fetch": "^3.3.2",
"qs": "^6.14.0",
"web-streams-polyfill": "^4.2.0"
"qs": "^6.15.2",
"web-streams-polyfill": "^4.3.0"
},
"optionalDependencies": {
"vue": "^3.5.22"
"vue": "^3.5.38"
},
"devDependencies": {
"@antfu/eslint-config": "^5.4.1",
"@nabla/vite-plugin-eslint": "^2.0.6",
"@types/node": "^24.7.0",
"@types/qs": "^6.14.0",
"@vitejs/plugin-vue": "^6.0.1",
"@vue/test-utils": "^2.4.6",
"@antfu/eslint-config": "^9.0.0",
"@nabla/vite-plugin-eslint": "^3.0.1",
"@types/node": "^25.9.3",
"@types/qs": "^6.15.1",
"@vitejs/plugin-vue": "^6.0.7",
"@vue/test-utils": "^2.4.11",
"copy": "^0.3.2",
"eslint": "^9.37.0",
"globals": "^16.4.0",
"happy-dom": "^19.0.2",
"typescript": "^5.9.3",
"vite": "^7.1.9",
"eslint": "^10.5.0",
"globals": "^17.6.0",
"happy-dom": "^20.10.3",
"typescript": "^6.0.3",
"vite": "^8.0.16",
"vite-plugin-externalize-deps": "^0.10.0",
"vitest": "^3.2.4",
"vitest": "^4.1.9",
"vitest-fetch-mock": "^0.4.5",
"vue": "^3.5.22",
"vue-tsc": "^3.1.1"
},
"pnpm": {
"onlyBuiltDependencies": [
"esbuild"
]
"vue": "^3.5.38",
"vue-tsc": "^3.3.5"
}
}
Loading
Loading