Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e89116a52 | ||
|
|
d2b24452e8 | ||
|
|
6dd7e23a97 | ||
|
|
3fbc5013c3 |
No files matched your search
@@ -5,7 +5,6 @@ node_modules
|
|||||||
npm-debug.log
|
npm-debug.log
|
||||||
README.md
|
README.md
|
||||||
.next
|
.next
|
||||||
.turbo
|
|
||||||
.git
|
.git
|
||||||
dev
|
dev
|
||||||
.build
|
.build
|
||||||
|
|||||||
@@ -33,16 +33,6 @@ body:
|
|||||||
options:
|
options:
|
||||||
# The below comment is used to insert a new version with on-release.yml
|
# The below comment is used to insert a new version with on-release.yml
|
||||||
#NEXT_VERSION#
|
#NEXT_VERSION#
|
||||||
- 1.56.1
|
|
||||||
- 1.56.0
|
|
||||||
- 1.55.0
|
|
||||||
- 1.54.0
|
|
||||||
- 1.53.0
|
|
||||||
- 1.52.0
|
|
||||||
- 1.51.0
|
|
||||||
- 1.50.1
|
|
||||||
- 1.50.0
|
|
||||||
- 1.49.1
|
|
||||||
- 1.49.0
|
- 1.49.0
|
||||||
- 1.48.0
|
- 1.48.0
|
||||||
- 1.47.0
|
- 1.47.0
|
||||||
|
|||||||
@@ -19,11 +19,6 @@ inputs:
|
|||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
- name: Prebuilt debian dependencies
|
|
||||||
uses: homarr-labs/homarr/.github/actions/prebuilt-debian@dev
|
|
||||||
id: prebuilt-debian
|
|
||||||
with:
|
|
||||||
architecture: ${{ inputs.architecture }}
|
|
||||||
- name: Start docker container for ${{ inputs.architecture }}
|
- name: Start docker container for ${{ inputs.architecture }}
|
||||||
run: |
|
run: |
|
||||||
docker run --name homarr \
|
docker run --name homarr \
|
||||||
@@ -41,12 +36,9 @@ runs:
|
|||||||
docker cp homarr:/app/extraction-alpine.tar.gz ${{ runner.temp }}/extraction/${{ inputs.architecture }}/build-alpine-${{ inputs.architecture }}.tar.gz && \
|
docker cp homarr:/app/extraction-alpine.tar.gz ${{ runner.temp }}/extraction/${{ inputs.architecture }}/build-alpine-${{ inputs.architecture }}.tar.gz && \
|
||||||
docker exec homarr rm /app/extraction-alpine.tar.gz
|
docker exec homarr rm /app/extraction-alpine.tar.gz
|
||||||
shell: bash
|
shell: bash
|
||||||
- name: Extract source from ${{ inputs.architecture }} container (debian)
|
- name: Copy source for debian build artifact
|
||||||
run: |
|
run: |
|
||||||
docker cp ${{ steps.prebuilt-debian.outputs.path }}/. homarr:/app/build && \
|
cp ${{ runner.temp }}/extraction/${{ inputs.architecture }}/build-alpine-${{ inputs.architecture }}.tar.gz ${{ runner.temp }}/extraction/${{ inputs.architecture }}/build-debian-${{ inputs.architecture }}.tar.gz
|
||||||
docker cp ${{ steps.prebuilt-debian.outputs.path }}/. homarr:/app/node_modules/better-sqlite3/build/Release && \
|
|
||||||
docker exec homarr tar -czf extraction-debian.tar.gz -C /app . && \
|
|
||||||
docker cp homarr:/app/extraction-debian.tar.gz ${{ runner.temp }}/extraction/${{ inputs.architecture }}/build-debian-${{ inputs.architecture }}.tar.gz
|
|
||||||
shell: bash
|
shell: bash
|
||||||
- name: Stop ${{ inputs.architecture }} container
|
- name: Stop ${{ inputs.architecture }} container
|
||||||
if: always()
|
if: always()
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
name: Prebuilt dependencies for debian
|
|
||||||
description: Provides prebuilt dependencies for debian based docker images
|
|
||||||
inputs:
|
|
||||||
architecture:
|
|
||||||
description: Name of architecture, will be used to build docker image (e.g. amd64, arm64)
|
|
||||||
required: true
|
|
||||||
outputs:
|
|
||||||
path:
|
|
||||||
description: Path to extracted prebuilt dependencies
|
|
||||||
value: ${{ runner.temp }}/prebuilts
|
|
||||||
runs:
|
|
||||||
using: "composite"
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Build docker image for ${{ inputs.architecture }}
|
|
||||||
id: build
|
|
||||||
uses: docker/build-push-action@v6
|
|
||||||
with:
|
|
||||||
push: false
|
|
||||||
load: true
|
|
||||||
context: ./deployments/prebuilt-debian
|
|
||||||
platforms: linux/${{ inputs.architecture }}
|
|
||||||
tags: prebuilt-debian
|
|
||||||
- name: Start docker container for ${{ inputs.architecture }}
|
|
||||||
run: |
|
|
||||||
docker run --name prebuilt-debian \
|
|
||||||
--detach --rm prebuilt-debian
|
|
||||||
shell: bash
|
|
||||||
- name: Extract prebuilt dependencies from ${{ inputs.architecture }} container
|
|
||||||
run: |
|
|
||||||
mkdir -p ${{ runner.temp }}/prebuilts && \
|
|
||||||
docker cp prebuilt-debian:/app/node_modules/better-sqlite3/build/Release/better_sqlite3.node ${{ runner.temp }}/prebuilts/better_sqlite3.node
|
|
||||||
shell: bash
|
|
||||||
- name: Stop ${{ inputs.architecture }} container
|
|
||||||
if: always()
|
|
||||||
run: docker container remove --force --volumes prebuilt-debian
|
|
||||||
shell: bash
|
|
||||||
@@ -20,7 +20,6 @@
|
|||||||
matchPackageNames: [
|
matchPackageNames: [
|
||||||
"@tree-sitter-grammars/tree-sitter-yaml",
|
"@tree-sitter-grammars/tree-sitter-yaml",
|
||||||
"bcrypt",
|
"bcrypt",
|
||||||
"better-sqlite3",
|
|
||||||
"cpu-features",
|
"cpu-features",
|
||||||
"esbuild",
|
"esbuild",
|
||||||
"sharp",
|
"sharp",
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ jobs:
|
|||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v6
|
||||||
if: env.SKIP_RELEASE == 'false'
|
if: env.SKIP_RELEASE == 'false'
|
||||||
with:
|
with:
|
||||||
node-version: 24.14.0
|
node-version: 24.12.0
|
||||||
cache: "pnpm"
|
cache: "pnpm"
|
||||||
- run: npm i -g pnpm
|
- run: npm i -g pnpm
|
||||||
if: env.SKIP_RELEASE == 'false'
|
if: env.SKIP_RELEASE == 'false'
|
||||||
@@ -128,7 +128,7 @@ jobs:
|
|||||||
images: "${{ env.GHCR_REPO }}"
|
images: "${{ env.GHCR_REPO }}"
|
||||||
|
|
||||||
- name: Log in to the Container registry
|
- name: Log in to the Container registry
|
||||||
uses: docker/login-action@v4
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
@@ -167,7 +167,7 @@ jobs:
|
|||||||
images: "${{ env.GHCR_REPO }}"
|
images: "${{ env.GHCR_REPO }}"
|
||||||
|
|
||||||
- name: Log in to the Container registry
|
- name: Log in to the Container registry
|
||||||
uses: docker/login-action@v4
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
@@ -228,17 +228,8 @@ jobs:
|
|||||||
DEPLOY_LATEST: ${{ github.ref_name == 'main' }}
|
DEPLOY_LATEST: ${{ github.ref_name == 'main' }}
|
||||||
DEPLOY_BETA: ${{ github.ref_name == 'beta' }}
|
DEPLOY_BETA: ${{ github.ref_name == 'beta' }}
|
||||||
steps:
|
steps:
|
||||||
- name: Obtain token
|
|
||||||
if: needs.release.outputs.skipped == 'false'
|
|
||||||
id: obtainToken
|
|
||||||
uses: actions/create-github-app-token@v2
|
|
||||||
with:
|
|
||||||
private-key: ${{ secrets.RENOVATE_MERGE_PRIVATE_KEY }}
|
|
||||||
app-id: ${{ secrets.RENOVATE_MERGE_APP_ID }}
|
|
||||||
permission-contents: write # required to publish the release
|
|
||||||
|
|
||||||
- name: Log in to the Container registry
|
- name: Log in to the Container registry
|
||||||
uses: docker/login-action@v4
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
@@ -267,7 +258,7 @@ jobs:
|
|||||||
- name: Publish release
|
- name: Publish release
|
||||||
if: needs.release.outputs.skipped == 'false'
|
if: needs.release.outputs.skipped == 'false'
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ steps.obtainToken.outputs.token }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
gh release edit --repo ${{ github.repository }} ${{ needs.release.outputs.version }} --draft=false
|
gh release edit --repo ${{ github.repository }} ${{ needs.release.outputs.version }} --draft=false
|
||||||
|
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
name: "[Deployments] Validate prebuilt debian dependencies"
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches: ["*"]
|
|
||||||
paths: [".github/actions/prebuilt-debian/**", "deployments/prebuilt-debian/**"]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
prebuilt-debian-validate-amd64:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
timeout-minutes: 5
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- name: Validate prebuilt dependencies for amd64
|
|
||||||
id: validate-amd64
|
|
||||||
uses: ./.github/actions/prebuilt-debian
|
|
||||||
with:
|
|
||||||
architecture: amd64
|
|
||||||
|
|
||||||
- name: Check extracted files for amd64
|
|
||||||
run: |
|
|
||||||
if [ ! -f "${{ steps.validate-amd64.outputs.path }}/better_sqlite3.node" ]; then
|
|
||||||
echo "better_sqlite3.node not found for amd64!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
prebuilt-debian-validate-arm64:
|
|
||||||
runs-on: ubuntu-24.04-arm
|
|
||||||
timeout-minutes: 5
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- name: Validate prebuilt dependencies for arm64
|
|
||||||
id: validate-arm64
|
|
||||||
uses: ./.github/actions/prebuilt-debian
|
|
||||||
with:
|
|
||||||
architecture: arm64
|
|
||||||
|
|
||||||
- name: Check extracted files for arm64
|
|
||||||
run: |
|
|
||||||
if [ ! -f "${{ steps.validate-arm64.outputs.path }}/better_sqlite3.node" ]; then
|
|
||||||
echo "better_sqlite3.node not found for arm64!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
@@ -2,7 +2,7 @@ permissions: {}
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
types: [released]
|
types: [published]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
trigger-docs-release:
|
trigger-docs-release:
|
||||||
@@ -37,7 +37,6 @@ jobs:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
update-bug-report-template:
|
update-bug-report-template:
|
||||||
name: Update Bug Report Template
|
name: Update Bug Report Template
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -55,20 +54,23 @@ jobs:
|
|||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
token: ${{ steps.obtainToken.outputs.token }}
|
token: ${{ steps.obtainToken.outputs.token }}
|
||||||
ref: dev
|
|
||||||
- name: Setup
|
- name: Setup
|
||||||
uses: ./tooling/github/setup
|
uses: ./tooling/github/setup
|
||||||
- run: pnpm run scripts:update-bug-report-template
|
- run: pnpm run scripts:update-bug-report-template
|
||||||
env:
|
env:
|
||||||
NEXT_VERSION: ${{ github.event.release.tag_name }}
|
NEXT_VERSION: ${{ github.event.release.tag_name }}
|
||||||
|
- name: Commit changes
|
||||||
|
run: |
|
||||||
|
git config --global user.email "175486441+homarr-releases[bot]@users.noreply.github.com"
|
||||||
|
git config --global user.name "Releases Homarr"
|
||||||
|
git checkout -b update-bug-report-template
|
||||||
|
git add .
|
||||||
|
git commit -m "chore: update bug report template"
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
id: create-pull-request
|
id: create-pull-request
|
||||||
uses: peter-evans/create-pull-request@v8
|
uses: peter-evans/create-pull-request@v8
|
||||||
with:
|
with:
|
||||||
add-paths: .github/ISSUE_TEMPLATE/bug_report.yml
|
|
||||||
commit-message: "chore: update bug report template"
|
|
||||||
author: Releases Homarr <175486441+homarr-releases[bot]@users.noreply.github.com>
|
|
||||||
token: ${{ steps.obtainToken.outputs.token }}
|
token: ${{ steps.obtainToken.outputs.token }}
|
||||||
branch: update-bug-report-template
|
branch: update-bug-report-template
|
||||||
base: dev
|
base: dev
|
||||||
|
|||||||
-239
@@ -1,242 +1,3 @@
|
|||||||
## [1.56.1](https://github.com/homarr-labs/homarr/compare/v1.56.0...v1.56.1) (2026-03-20)
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* **deps:** update dependency dayjs to ^1.11.20 ([#5253](https://github.com/homarr-labs/homarr/issues/5253)) ([615062c](https://github.com/homarr-labs/homarr/commit/615062c6b141fa1e4bc91d2fab505fa1652608d2))
|
|
||||||
* **deps:** update dependency fast-xml-parser to ^5.5.1 ([#5246](https://github.com/homarr-labs/homarr/issues/5246)) ([91a9b6b](https://github.com/homarr-labs/homarr/commit/91a9b6bec9438e9a812960b829cea343e8478c63))
|
|
||||||
* **deps:** update dependency fast-xml-parser to ^5.5.3 ([#5251](https://github.com/homarr-labs/homarr/issues/5251)) ([d1d8659](https://github.com/homarr-labs/homarr/commit/d1d8659f951cdd22bf4a22b407a4f3027f036ec2))
|
|
||||||
* **deps:** update dependency fast-xml-parser to ^5.5.5 ([#5270](https://github.com/homarr-labs/homarr/issues/5270)) ([2423ecd](https://github.com/homarr-labs/homarr/commit/2423ecdce57353dd50d678444da800c02a246223))
|
|
||||||
* **deps:** update dependency isomorphic-dompurify to ^3.1.0 ([#5239](https://github.com/homarr-labs/homarr/issues/5239)) ([63f91b6](https://github.com/homarr-labs/homarr/commit/63f91b6352e9ba58a0823434d86915371f1c1d30))
|
|
||||||
* **deps:** update dependency isomorphic-dompurify to ^3.3.0 ([#5252](https://github.com/homarr-labs/homarr/issues/5252)) ([e8f6876](https://github.com/homarr-labs/homarr/commit/e8f6876d2477fb0e1936006b81f7324b90b6eb33))
|
|
||||||
* **deps:** update dependency jotai to ^2.18.1 ([#5238](https://github.com/homarr-labs/homarr/issues/5238)) ([729b49f](https://github.com/homarr-labs/homarr/commit/729b49ffa9b1f91ebd7bcd2300febba4d9d0fbb9))
|
|
||||||
* **deps:** update dependency mysql2 to v3.19.1 ([#5240](https://github.com/homarr-labs/homarr/issues/5240)) ([1040eca](https://github.com/homarr-labs/homarr/commit/1040ecac04fd0b10e101495d5230a3fa4898097a))
|
|
||||||
* **deps:** update dependency next to v16.1.7 [security] ([#5263](https://github.com/homarr-labs/homarr/issues/5263)) ([3bbde3c](https://github.com/homarr-labs/homarr/commit/3bbde3cbb8eb3aa528485f17d40817cb982a8687))
|
|
||||||
* **deps:** update dependency sass to ^1.98.0 ([#5247](https://github.com/homarr-labs/homarr/issues/5247)) ([f995cba](https://github.com/homarr-labs/homarr/commit/f995cba157c9954b6f266bd5b2bb8d60a08f51f1))
|
|
||||||
* **deps:** update dependency typescript-eslint to ^8.57.0 ([#5241](https://github.com/homarr-labs/homarr/issues/5241)) ([7841b58](https://github.com/homarr-labs/homarr/commit/7841b58f0fdd4a4494b6f3d61881a1efb4c9eba3))
|
|
||||||
* **deps:** update mantine monorepo to ^8.3.17 ([#5271](https://github.com/homarr-labs/homarr/issues/5271)) ([6fa9087](https://github.com/homarr-labs/homarr/commit/6fa9087a119334dee63e4ca4ed51276b25c4564a))
|
|
||||||
* **deps:** update tiptap monorepo to v3.20.2 ([#5279](https://github.com/homarr-labs/homarr/issues/5279)) ([55cf3c7](https://github.com/homarr-labs/homarr/commit/55cf3c72a3d9cd9f702e802716d549d7d2644105))
|
|
||||||
* **deps:** update trpc monorepo to ^11.13.2 ([#5273](https://github.com/homarr-labs/homarr/issues/5273)) ([7d93b10](https://github.com/homarr-labs/homarr/commit/7d93b1003245ab89fdba7175b0b4f745041cd1fe))
|
|
||||||
* **deps:** update trpc monorepo to ^11.13.3 ([#5276](https://github.com/homarr-labs/homarr/issues/5276)) ([0e0b857](https://github.com/homarr-labs/homarr/commit/0e0b857905a7b5196dbf529520f86467aa94d8ce))
|
|
||||||
* **deps:** update trpc monorepo to ^11.13.4 ([#5278](https://github.com/homarr-labs/homarr/issues/5278)) ([9648d9e](https://github.com/homarr-labs/homarr/commit/9648d9e99f02be8ba16a5238bd47866f7303724d))
|
|
||||||
* **deps:** update turbo monorepo to ^2.8.15 ([#5243](https://github.com/homarr-labs/homarr/issues/5243)) ([1bd924e](https://github.com/homarr-labs/homarr/commit/1bd924ea9917949ac64ab754d97964b12c083b82))
|
|
||||||
* **deps:** update turbo monorepo to ^2.8.16 ([#5250](https://github.com/homarr-labs/homarr/issues/5250)) ([ac80008](https://github.com/homarr-labs/homarr/commit/ac80008ce0796cb6927642c83ff2e667f6e9d24c))
|
|
||||||
* **deps:** update turbo monorepo to ^2.8.17 ([#5265](https://github.com/homarr-labs/homarr/issues/5265)) ([d2f438f](https://github.com/homarr-labs/homarr/commit/d2f438f294df3093b249213ac0a018b770705e3b))
|
|
||||||
|
|
||||||
## [1.56.0](https://github.com/homarr-labs/homarr/compare/v1.55.0...v1.56.0) (2026-03-13)
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* add immich integration and widget ([#5165](https://github.com/homarr-labs/homarr/issues/5165)) ([cdd90b8](https://github.com/homarr-labs/homarr/commit/cdd90b8aa091e4d05a40af35ea87486b83bf4182))
|
|
||||||
* **boards:** show supported integrations in widget selection ([#5187](https://github.com/homarr-labs/homarr/issues/5187)) ([dabe96b](https://github.com/homarr-labs/homarr/commit/dabe96bd5ea52110812934b1ec9c8dc9ecd77603))
|
|
||||||
* expand cli ([#5159](https://github.com/homarr-labs/homarr/issues/5159)) ([aa36ce3](https://github.com/homarr-labs/homarr/commit/aa36ce3c4784c91024c4e8001c236e28f02396e7))
|
|
||||||
* Tracearr integration ([#5060](https://github.com/homarr-labs/homarr/issues/5060)) ([f686001](https://github.com/homarr-labs/homarr/commit/f68600150ab1985d56f1bed45d8ac158a74ec443))
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* **boards:** duplication of boards fails with postgresql / mysql ([#5228](https://github.com/homarr-labs/homarr/issues/5228)) ([ba9c3f3](https://github.com/homarr-labs/homarr/commit/ba9c3f3e27659a5c06604d06192ccb8316658937))
|
|
||||||
* **deps:** update dependency @tabler/icons-react to ^3.38.0 ([#5182](https://github.com/homarr-labs/homarr/issues/5182)) ([6aaaf31](https://github.com/homarr-labs/homarr/commit/6aaaf31d8b5495090081f8795844db00a7b0a2ed))
|
|
||||||
* **deps:** update dependency @tabler/icons-react to ^3.39.0 ([#5209](https://github.com/homarr-labs/homarr/issues/5209)) ([22fd8e9](https://github.com/homarr-labs/homarr/commit/22fd8e9b95bcddd9a9a1fa599f1a42f4d502f205))
|
|
||||||
* **deps:** update dependency @tabler/icons-react to ^3.40.0 ([#5220](https://github.com/homarr-labs/homarr/issues/5220)) ([12ad241](https://github.com/homarr-labs/homarr/commit/12ad241406d581c98826ed270d71faf50779c601))
|
|
||||||
* **deps:** update dependency fast-xml-parser to ^5.4.2 ([#5190](https://github.com/homarr-labs/homarr/issues/5190)) ([5159d9f](https://github.com/homarr-labs/homarr/commit/5159d9f0e7263166f26ec770c55dd4e2944dfd72))
|
|
||||||
* **deps:** update dependency fastify to ^5.8.1 ([#5202](https://github.com/homarr-labs/homarr/issues/5202)) ([b02e8cc](https://github.com/homarr-labs/homarr/commit/b02e8cc875df20ff4d007c527bb5682db960fae6))
|
|
||||||
* **deps:** update dependency fastify to ^5.8.2 ([#5221](https://github.com/homarr-labs/homarr/issues/5221)) ([5c4f394](https://github.com/homarr-labs/homarr/commit/5c4f39450148fd91e2cecf70c20c8ec78ecebfd6))
|
|
||||||
* **deps:** update dependency mysql2 to v3.19.0 ([#5206](https://github.com/homarr-labs/homarr/issues/5206)) ([324bfd9](https://github.com/homarr-labs/homarr/commit/324bfd90d1a2c6ca80610c549b84d93f4a695cab))
|
|
||||||
* **deps:** update dependency pg to ^8.20.0 ([#5198](https://github.com/homarr-labs/homarr/issues/5198)) ([1c6e23a](https://github.com/homarr-labs/homarr/commit/1c6e23a4b6509e83667396a392b23655f8b614dd))
|
|
||||||
* **deps:** update mantine monorepo to ^8.3.16 ([#5201](https://github.com/homarr-labs/homarr/issues/5201)) ([c7fa5cd](https://github.com/homarr-labs/homarr/commit/c7fa5cdbb3ffdf90dbc9c9dbef0551e2b0edfb4c))
|
|
||||||
* **deps:** update tiptap monorepo to v3.20.1 ([#5215](https://github.com/homarr-labs/homarr/issues/5215)) ([d941ed5](https://github.com/homarr-labs/homarr/commit/d941ed58fa482f2e41d27b6b5088146a608b236e))
|
|
||||||
* **deps:** update trpc monorepo to ^11.12.0 ([#5213](https://github.com/homarr-labs/homarr/issues/5213)) ([00dd32b](https://github.com/homarr-labs/homarr/commit/00dd32bbe124f02ad7ae5ecb4e298a6d3fb4f0b8))
|
|
||||||
* **deps:** update turbo monorepo to ^2.8.14 ([#5113](https://github.com/homarr-labs/homarr/issues/5113)) ([8ee05e0](https://github.com/homarr-labs/homarr/commit/8ee05e0d491bfec9f768a3a915ad1c8abf433b5b))
|
|
||||||
* **glances:** unable to parse uptime of 1 day ([#5226](https://github.com/homarr-labs/homarr/issues/5226)) ([3091ed6](https://github.com/homarr-labs/homarr/commit/3091ed6358d83249a94827f55a812323c1e80497))
|
|
||||||
* **image-proxy:** hash full URL and headers deterministically ([#5184](https://github.com/homarr-labs/homarr/issues/5184)) ([9a878af](https://github.com/homarr-labs/homarr/commit/9a878af414e12691420edb945ed6f9f6255c7eae))
|
|
||||||
* language changes when searching for some icons ([#5224](https://github.com/homarr-labs/homarr/issues/5224)) ([21225c9](https://github.com/homarr-labs/homarr/commit/21225c979edb9a2c9cc00c4649363c0aab8058f1))
|
|
||||||
* **releases:** allow any icon url for repositories ([#5229](https://github.com/homarr-labs/homarr/issues/5229)) ([d3c2ad1](https://github.com/homarr-labs/homarr/commit/d3c2ad134f7a9972118abcfff5482ca6d6105406))
|
|
||||||
* **security:** harden hashing in image-proxy ([#5188](https://github.com/homarr-labs/homarr/issues/5188)) ([5723da2](https://github.com/homarr-labs/homarr/commit/5723da21aae8b69642a39e4b5a05ad84fa8dd8ef))
|
|
||||||
* **stock-price:** align sparkline color with displayed price change ([#5181](https://github.com/homarr-labs/homarr/issues/5181)) ([bbf0adf](https://github.com/homarr-labs/homarr/commit/bbf0adf31a1f08f3ca09b709efd1daa15cb8498c))
|
|
||||||
* **system-disks:** format absolute denominator with human-readable size ([#5183](https://github.com/homarr-labs/homarr/issues/5183)) ([85c4601](https://github.com/homarr-labs/homarr/commit/85c460190ceedad83c40af81d5efa270bc464b94))
|
|
||||||
* **true-nas:** ignore offline/exported pools ([#5225](https://github.com/homarr-labs/homarr/issues/5225)) ([451602d](https://github.com/homarr-labs/homarr/commit/451602d1e61256696f6bcb0cd76f09748345a940))
|
|
||||||
|
|
||||||
## [1.55.0](https://github.com/homarr-labs/homarr/compare/v1.54.0...v1.55.0) (2026-03-06)
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* add seerr integration ([#5139](https://github.com/homarr-labs/homarr/issues/5139)) ([0e29a2f](https://github.com/homarr-labs/homarr/commit/0e29a2fce172cbfda083b899c01b92bd8b6210b7))
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* **deps:** update dependency fast-xml-parser to ^5.4.1 ([#5150](https://github.com/homarr-labs/homarr/issues/5150)) ([eb2f85f](https://github.com/homarr-labs/homarr/commit/eb2f85f6f8c9d7d90c1aeec079225678dfef4dd0))
|
|
||||||
* **deps:** update dependency ioredis to v5.10.0 ([#5169](https://github.com/homarr-labs/homarr/issues/5169)) ([1c06e56](https://github.com/homarr-labs/homarr/commit/1c06e562c33bd9f1387cb05a3dece7beedfe43c2))
|
|
||||||
* **deps:** update dependency ldapts to v8.1.7 ([#5168](https://github.com/homarr-labs/homarr/issues/5168)) ([ec45aac](https://github.com/homarr-labs/homarr/commit/ec45aacc63766c51a99ead6130bade442124e70d))
|
|
||||||
* **deps:** update dependency mysql2 to v3.17.5 ([#5140](https://github.com/homarr-labs/homarr/issues/5140)) ([66ad67e](https://github.com/homarr-labs/homarr/commit/66ad67eced587fd49a470395298477dc09cdd225))
|
|
||||||
* **deps:** update dependency mysql2 to v3.18.0 ([#5141](https://github.com/homarr-labs/homarr/issues/5141)) ([52792af](https://github.com/homarr-labs/homarr/commit/52792af186a6eb3519aafdee5a7c0dd03a86a461))
|
|
||||||
* **deps:** update dependency mysql2 to v3.18.1 ([#5152](https://github.com/homarr-labs/homarr/issues/5152)) ([8bf2a43](https://github.com/homarr-labs/homarr/commit/8bf2a43e065671c7c119ef1da5aa09d284db0ede))
|
|
||||||
* **deps:** update dependency mysql2 to v3.18.2 ([#5164](https://github.com/homarr-labs/homarr/issues/5164)) ([4717a57](https://github.com/homarr-labs/homarr/commit/4717a5724d4a6286c0f2bb92cf1e1fe17903a13a))
|
|
||||||
* **deps:** update dependency pg to ^8.19.0 ([#5153](https://github.com/homarr-labs/homarr/issues/5153)) ([0b0fb1c](https://github.com/homarr-labs/homarr/commit/0b0fb1c5798357d7bc847dfe577b26529be8aa5c))
|
|
||||||
* **deps:** update dependency swagger-ui-react to ^5.32.0 ([#5167](https://github.com/homarr-labs/homarr/issues/5167)) ([ff11599](https://github.com/homarr-labs/homarr/commit/ff1159943c967b6fea44894765c2210c3cdd44cc))
|
|
||||||
* **deps:** update dependency typescript-eslint to ^8.56.1 ([#5142](https://github.com/homarr-labs/homarr/issues/5142)) ([ac3b4e7](https://github.com/homarr-labs/homarr/commit/ac3b4e7de0460cab7723dcc1a5a8e14072a37d25))
|
|
||||||
* **deps:** update trpc monorepo to ^11.11.0 ([#5174](https://github.com/homarr-labs/homarr/issues/5174)) ([bc2a532](https://github.com/homarr-labs/homarr/commit/bc2a532a03d8cb76270f52b766f1a7f46d704096))
|
|
||||||
|
|
||||||
## [1.54.0](https://github.com/homarr-labs/homarr/compare/v1.53.2...v1.54.0) (2026-02-27)
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* add glances integration ([#5102](https://github.com/homarr-labs/homarr/issues/5102)) ([91846bc](https://github.com/homarr-labs/homarr/commit/91846bc000b419b03925acc4b447efcc696ff009))
|
|
||||||
* add slskd integration ([#5088](https://github.com/homarr-labs/homarr/issues/5088)) ([d999f37](https://github.com/homarr-labs/homarr/commit/d999f3797562a4c1d07a08b10ef4821c12390d2f))
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* **deps:** update dependency @ctrl/deluge to ^7.5.1 ([#5098](https://github.com/homarr-labs/homarr/issues/5098)) ([53d4625](https://github.com/homarr-labs/homarr/commit/53d46257ce2c257f2e083d0645178823afd45227))
|
|
||||||
* **deps:** update dependency @ctrl/deluge to ^7.5.2 ([#5105](https://github.com/homarr-labs/homarr/issues/5105)) ([dacbcce](https://github.com/homarr-labs/homarr/commit/dacbcce179c21f8858f61633c4a72b248ec437b7))
|
|
||||||
* **deps:** update dependency @ctrl/qbittorrent to ^9.11.1 ([#5097](https://github.com/homarr-labs/homarr/issues/5097)) ([193d4d2](https://github.com/homarr-labs/homarr/commit/193d4d2e2aabaffb019108c3150de3f92d84efe8))
|
|
||||||
* **deps:** update dependency @ctrl/qbittorrent to ^9.11.2 ([#5106](https://github.com/homarr-labs/homarr/issues/5106)) ([ee62667](https://github.com/homarr-labs/homarr/commit/ee6266707f779e7a080b40b4ed3e0a8679bb2910))
|
|
||||||
* **deps:** update dependency @tabler/icons-react to ^3.37.0 ([#5119](https://github.com/homarr-labs/homarr/issues/5119)) ([ba86019](https://github.com/homarr-labs/homarr/commit/ba860193d78f84fa9326a006caba4b3cc7c195c2))
|
|
||||||
* **deps:** update dependency @tabler/icons-react to ^3.37.1 ([#5121](https://github.com/homarr-labs/homarr/issues/5121)) ([c3a4051](https://github.com/homarr-labs/homarr/commit/c3a40510075f56d7f156c877e1041b7bf36677b5))
|
|
||||||
* **deps:** update dependency fast-xml-parser to ^5.3.7 ([#5122](https://github.com/homarr-labs/homarr/issues/5122)) ([6861839](https://github.com/homarr-labs/homarr/commit/6861839b65fffb0c8030ae7a6fd24105fdad6b95))
|
|
||||||
* **deps:** update dependency glob to ^13.0.4 ([#5107](https://github.com/homarr-labs/homarr/issues/5107)) ([ea0a411](https://github.com/homarr-labs/homarr/commit/ea0a411c813c8dfcb17493e6a41d2ab96077adb6))
|
|
||||||
* **deps:** update dependency glob to ^13.0.5 ([#5109](https://github.com/homarr-labs/homarr/issues/5109)) ([02ec089](https://github.com/homarr-labs/homarr/commit/02ec0898ef32f8b6ac540a9c005130f3e7312e65))
|
|
||||||
* **deps:** update dependency glob to ^13.0.6 ([#5117](https://github.com/homarr-labs/homarr/issues/5117)) ([908bced](https://github.com/homarr-labs/homarr/commit/908bced0dfb158a9da155c97dbf982c2d544fc20))
|
|
||||||
* **deps:** update dependency isomorphic-dompurify to v3 ([#5130](https://github.com/homarr-labs/homarr/issues/5130)) ([cfaf82c](https://github.com/homarr-labs/homarr/commit/cfaf82cd04e4659db50e6074fce4cc739ee2aaf8))
|
|
||||||
* **deps:** update dependency jotai to ^2.18.0 ([#5115](https://github.com/homarr-labs/homarr/issues/5115)) ([4aad087](https://github.com/homarr-labs/homarr/commit/4aad0873baec97167460bad1c69c770aecb38bd0))
|
|
||||||
* **deps:** update dependency mysql2 to v3.17.2 ([#5104](https://github.com/homarr-labs/homarr/issues/5104)) ([15c7fc5](https://github.com/homarr-labs/homarr/commit/15c7fc5ae809b671c8d774d39b7a7fdf893db611))
|
|
||||||
* **deps:** update dependency mysql2 to v3.17.3 ([#5116](https://github.com/homarr-labs/homarr/issues/5116)) ([42e5326](https://github.com/homarr-labs/homarr/commit/42e53261ef956a0f5ad60ac45c623d3acd3d9530))
|
|
||||||
* **deps:** update dependency mysql2 to v3.17.4 ([#5123](https://github.com/homarr-labs/homarr/issues/5123)) ([7ca38c3](https://github.com/homarr-labs/homarr/commit/7ca38c3a781d54f91d01844e077528345a9b190b))
|
|
||||||
* **deps:** update dependency next-intl to v4.8.3 ([#5100](https://github.com/homarr-labs/homarr/issues/5100)) ([d67c2db](https://github.com/homarr-labs/homarr/commit/d67c2db886b92e7d0973bf17ff5059b8328acdf6))
|
|
||||||
* **deps:** update dependency swagger-ui-react to ^5.31.1 ([#5101](https://github.com/homarr-labs/homarr/issues/5101)) ([210d46b](https://github.com/homarr-labs/homarr/commit/210d46b43ffeb956af3f983a82772609e42f08df))
|
|
||||||
* **deps:** update dependency swagger-ui-react to ^5.31.2 ([#5124](https://github.com/homarr-labs/homarr/issues/5124)) ([51585c6](https://github.com/homarr-labs/homarr/commit/51585c6413ab3841f0bee1e736d726081912ab08))
|
|
||||||
* **deps:** update dependency typescript-eslint to ^8.56.0 ([#5103](https://github.com/homarr-labs/homarr/issues/5103)) ([8bac6e1](https://github.com/homarr-labs/homarr/commit/8bac6e1c5a239108bc48fd877b3fc1ec8b445109))
|
|
||||||
* **deps:** update mantine monorepo to ^8.3.15 ([#5099](https://github.com/homarr-labs/homarr/issues/5099)) ([b8f9b4c](https://github.com/homarr-labs/homarr/commit/b8f9b4cf1d870956806a68ad78a95af60c99975f))
|
|
||||||
* **deps:** update testcontainers-node monorepo to ^11.12.0 ([#5110](https://github.com/homarr-labs/homarr/issues/5110)) ([e3c8174](https://github.com/homarr-labs/homarr/commit/e3c8174bdcb95de8e731c79c2b4bebce98d6dbce))
|
|
||||||
* **deps:** update tiptap monorepo to v3.20.0 ([#5112](https://github.com/homarr-labs/homarr/issues/5112)) ([3d2bc82](https://github.com/homarr-labs/homarr/commit/3d2bc82a33a88a8f2d60fd61112f1f712e956670))
|
|
||||||
|
|
||||||
## [1.53.2](https://github.com/homarr-labs/homarr/compare/v1.53.1...v1.53.2) (2026-02-20)
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* **analytics:** restrict publishing to every week ([#5028](https://github.com/homarr-labs/homarr/issues/5028)) ([8c4be2f](https://github.com/homarr-labs/homarr/commit/8c4be2fbe80e42472b8b17542a4282ec26d1fefe))
|
|
||||||
* **deps:** update dependency @tanstack/react-query to ^5.90.21 ([#5067](https://github.com/homarr-labs/homarr/issues/5067)) ([1b8dde9](https://github.com/homarr-labs/homarr/commit/1b8dde98d2518d3d82895a26a58db7f42abf2a6e))
|
|
||||||
* **deps:** update dependency dotenv to ^17.3.0 ([#5079](https://github.com/homarr-labs/homarr/issues/5079)) ([1e822fb](https://github.com/homarr-labs/homarr/commit/1e822fbe0c8224e6ba5b99e6516ea4437c9f36bb))
|
|
||||||
* **deps:** update dependency dotenv to ^17.3.1 ([#5081](https://github.com/homarr-labs/homarr/issues/5081)) ([46ba48f](https://github.com/homarr-labs/homarr/commit/46ba48fb20b69b2876fc42ee862a64717e6428f7))
|
|
||||||
* **deps:** update dependency drizzle-kit to ^0.31.9 ([#5059](https://github.com/homarr-labs/homarr/issues/5059)) ([db14d98](https://github.com/homarr-labs/homarr/commit/db14d98d1966dada5d74507e64e90f34fb4eee60))
|
|
||||||
* **deps:** update dependency fast-xml-parser to ^5.3.6 ([#5089](https://github.com/homarr-labs/homarr/issues/5089)) ([ac5bc70](https://github.com/homarr-labs/homarr/commit/ac5bc70a5de9a4307c4165203ff26ee1a112ca81))
|
|
||||||
* **deps:** update dependency glob to ^13.0.2 ([#5065](https://github.com/homarr-labs/homarr/issues/5065)) ([50601d5](https://github.com/homarr-labs/homarr/commit/50601d53792baae5a259adb4e4d3fefcc35d25df))
|
|
||||||
* **deps:** update dependency glob to ^13.0.3 ([#5078](https://github.com/homarr-labs/homarr/issues/5078)) ([ba0ed77](https://github.com/homarr-labs/homarr/commit/ba0ed77bb036dd0e35db08ce9df98f133f835d53))
|
|
||||||
* **deps:** update dependency ioredis to v5.9.3 ([#5076](https://github.com/homarr-labs/homarr/issues/5076)) ([4e1baa5](https://github.com/homarr-labs/homarr/commit/4e1baa570324be06eb442f2db08a8b152d9b416b))
|
|
||||||
* **deps:** update dependency mysql2 to v3.17.0 ([#5066](https://github.com/homarr-labs/homarr/issues/5066)) ([fcb020c](https://github.com/homarr-labs/homarr/commit/fcb020c191b98a729508b7660fb484f29208c51c))
|
|
||||||
* **deps:** update dependency mysql2 to v3.17.1 ([#5082](https://github.com/homarr-labs/homarr/issues/5082)) ([475f14d](https://github.com/homarr-labs/homarr/commit/475f14dc312c1b8cffbabe607c17be8b2d1d294c))
|
|
||||||
* **deps:** update dependency react-error-boundary to ^6.1.1 ([#5086](https://github.com/homarr-labs/homarr/issues/5086)) ([bb9da30](https://github.com/homarr-labs/homarr/commit/bb9da3007e4f29fd7993bd9960e80e316a17bbf0))
|
|
||||||
* **deps:** update dependency tsdav to ^2.1.8 ([#5090](https://github.com/homarr-labs/homarr/issues/5090)) ([840d110](https://github.com/homarr-labs/homarr/commit/840d1107ec3392b4581c931ef1efe2d9816ededd))
|
|
||||||
* **deps:** update dependency typescript-eslint to ^8.55.0 ([#5061](https://github.com/homarr-labs/homarr/issues/5061)) ([56ecce2](https://github.com/homarr-labs/homarr/commit/56ecce254195c480eef9cefefd7bad98c49b9175))
|
|
||||||
* **deps:** update trpc monorepo to ^11.10.0 ([#5062](https://github.com/homarr-labs/homarr/issues/5062)) ([bc7ec63](https://github.com/homarr-labs/homarr/commit/bc7ec63f8547e8f868ef5d56a1a8c5c893fda1e3))
|
|
||||||
* **deps:** update turbo monorepo to ^2.8.5 ([#5064](https://github.com/homarr-labs/homarr/issues/5064)) ([c36e947](https://github.com/homarr-labs/homarr/commit/c36e947935246761cac26049ac24c56c8cc0990a))
|
|
||||||
* **deps:** update turbo monorepo to ^2.8.7 ([#5071](https://github.com/homarr-labs/homarr/issues/5071)) ([c6c48ea](https://github.com/homarr-labs/homarr/commit/c6c48ea6e5f76303fd93022fd566a99af1ad829f))
|
|
||||||
* **deps:** update turbo monorepo to ^2.8.8 ([#5084](https://github.com/homarr-labs/homarr/issues/5084)) ([dcae437](https://github.com/homarr-labs/homarr/commit/dcae437fc5cadc2e112037fa26f8351111c69869))
|
|
||||||
* **deps:** update turbo monorepo to ^2.8.9 ([#5092](https://github.com/homarr-labs/homarr/issues/5092)) ([24560cb](https://github.com/homarr-labs/homarr/commit/24560cb93f17767b5ab8047c07f81a165e0fb769))
|
|
||||||
|
|
||||||
## [1.53.1](https://github.com/homarr-labs/homarr/compare/v1.53.0...v1.53.1) (2026-02-13)
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* **deps:** update dependency @ianvs/prettier-plugin-sort-imports to ^4.7.1 ([#5021](https://github.com/homarr-labs/homarr/issues/5021)) ([5946e6c](https://github.com/homarr-labs/homarr/commit/5946e6c7193eded77b98c76aedff71a7bb912574))
|
|
||||||
* **deps:** update dependency @octokit/auth-app to ^8.2.0 ([#5009](https://github.com/homarr-labs/homarr/issues/5009)) ([4a86361](https://github.com/homarr-labs/homarr/commit/4a86361134da404462b1a9f8ff98fe3504fade0d))
|
|
||||||
* **deps:** update dependency dotenv to ^17.2.4 ([#5029](https://github.com/homarr-labs/homarr/issues/5029)) ([e8c7f45](https://github.com/homarr-labs/homarr/commit/e8c7f454768044540ee37d75fc73654b74315390))
|
|
||||||
* **deps:** update dependency fast-xml-parser to ^5.3.5 ([#5050](https://github.com/homarr-labs/homarr/issues/5050)) ([30f561f](https://github.com/homarr-labs/homarr/commit/30f561f85ad2abb90ccb9fa3292155d51f1f379b))
|
|
||||||
* **deps:** update dependency fastify to ^5.7.4 ([#5027](https://github.com/homarr-labs/homarr/issues/5027)) ([18e16d6](https://github.com/homarr-labs/homarr/commit/18e16d687f8137e5b5c55cf2385436b714a2d27b))
|
|
||||||
* **deps:** update dependency glob to ^13.0.1 ([#5013](https://github.com/homarr-labs/homarr/issues/5013)) ([3b21c3e](https://github.com/homarr-labs/homarr/commit/3b21c3ef765add0f7cdc8f66ae8f1b7aac3cf51e))
|
|
||||||
* **deps:** update dependency isomorphic-dompurify to ^2.36.0 ([#5041](https://github.com/homarr-labs/homarr/issues/5041)) ([e561fc5](https://github.com/homarr-labs/homarr/commit/e561fc550fab2207212ae108a5177a248795cf66))
|
|
||||||
* **deps:** update dependency jotai to ^2.17.1 ([#5019](https://github.com/homarr-labs/homarr/issues/5019)) ([da96566](https://github.com/homarr-labs/homarr/commit/da965668d021ebebd8c8a7e2a4560577a6b0828b))
|
|
||||||
* **deps:** update dependency ldapts to v8.1.5 ([#5004](https://github.com/homarr-labs/homarr/issues/5004)) ([c3932b1](https://github.com/homarr-labs/homarr/commit/c3932b18f03b86e8ee049c14ace63119fd2ab0d6))
|
|
||||||
* **deps:** update dependency ldapts to v8.1.6 ([#5018](https://github.com/homarr-labs/homarr/issues/5018)) ([c92d487](https://github.com/homarr-labs/homarr/commit/c92d487ceaa9159579ef4352d763429887953bb5))
|
|
||||||
* **deps:** update dependency mysql2 to v3.16.3 ([#5014](https://github.com/homarr-labs/homarr/issues/5014)) ([04b3598](https://github.com/homarr-labs/homarr/commit/04b35980f5997e744a455a847f28b1a676f9861e))
|
|
||||||
* **deps:** update dependency next-intl to v4.8.2 ([#5005](https://github.com/homarr-labs/homarr/issues/5005)) ([b67fecd](https://github.com/homarr-labs/homarr/commit/b67fecd3963bc3112ab8ecd91385bbe13c982290))
|
|
||||||
* **deps:** update dependency tsdav to ^2.1.7 ([#5033](https://github.com/homarr-labs/homarr/issues/5033)) ([d694b1a](https://github.com/homarr-labs/homarr/commit/d694b1a5410833a791d57fb3dd4650003510140e))
|
|
||||||
* **deps:** update dependency video.js to ^8.23.7 ([#5034](https://github.com/homarr-labs/homarr/issues/5034)) ([6efabd4](https://github.com/homarr-labs/homarr/commit/6efabd436849b9fdea0d060fe7beaa9c67424c29))
|
|
||||||
* **deps:** update tiptap monorepo to v3.19.0 ([#5012](https://github.com/homarr-labs/homarr/issues/5012)) ([ad41a91](https://github.com/homarr-labs/homarr/commit/ad41a918ef72f322015a02e9601c43728e680b34))
|
|
||||||
* **deps:** update turbo monorepo to ^2.8.2 ([#5010](https://github.com/homarr-labs/homarr/issues/5010)) ([b479fea](https://github.com/homarr-labs/homarr/commit/b479fea6eb0b025b55668201160a5e57267de2e7))
|
|
||||||
* **deps:** update turbo monorepo to ^2.8.3 ([#5016](https://github.com/homarr-labs/homarr/issues/5016)) ([f1d2f07](https://github.com/homarr-labs/homarr/commit/f1d2f07f3888e7567b56ae61a9d137255a2b8529))
|
|
||||||
* **sections:** dynamic sections vanish when adding category ([#5046](https://github.com/homarr-labs/homarr/issues/5046)) ([60fcb71](https://github.com/homarr-labs/homarr/commit/60fcb71bd2616af3e99b20cbbcd1b0417a0fff76))
|
|
||||||
* **seerr:** use reasonable limits for amount of returned entries ([#5001](https://github.com/homarr-labs/homarr/issues/5001)) ([be1a26a](https://github.com/homarr-labs/homarr/commit/be1a26a98d2ed9d25969ded5ae64705c001f71dd))
|
|
||||||
|
|
||||||
## [1.53.0](https://github.com/homarr-labs/homarr/compare/v1.52.0...v1.53.0) (2026-02-06)
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* **analytics:** consolidate server analytics into single comprehensive Umami event ([#4938](https://github.com/homarr-labs/homarr/issues/4938)) ([10848db](https://github.com/homarr-labs/homarr/commit/10848db595b2254b1485ea168d1c327b907d9ff8))
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* **deps:** update dependency @next/eslint-plugin-next to v16.1.5 ([#4959](https://github.com/homarr-labs/homarr/issues/4959)) ([ec40309](https://github.com/homarr-labs/homarr/commit/ec40309cde2280cf689856d4f78fb1500b583130))
|
|
||||||
* **deps:** update dependency @paralleldrive/cuid2 to ^3.3.0 ([#4952](https://github.com/homarr-labs/homarr/issues/4952)) ([a9db68b](https://github.com/homarr-labs/homarr/commit/a9db68bd3eaea6a4564cd6842054ea60cc45e3a3))
|
|
||||||
* **deps:** update dependency @tanstack/react-query-devtools to ^5.91.3 ([#4985](https://github.com/homarr-labs/homarr/issues/4985)) ([1115ad1](https://github.com/homarr-labs/homarr/commit/1115ad1364bca84dee33aa42499c986bdad2c528))
|
|
||||||
* **deps:** update dependency fast-xml-parser to ^5.3.4 ([#4982](https://github.com/homarr-labs/homarr/issues/4982)) ([460d53c](https://github.com/homarr-labs/homarr/commit/460d53cafa1abeebf4dea7b1bb1e920267c2f9fe))
|
|
||||||
* **deps:** update dependency fastify to ^5.7.2 ([#4955](https://github.com/homarr-labs/homarr/issues/4955)) ([0eab26c](https://github.com/homarr-labs/homarr/commit/0eab26cdace47c0b19519372a3daa6998e0c8207))
|
|
||||||
* **deps:** update dependency jotai to ^2.17.0 ([#4972](https://github.com/homarr-labs/homarr/issues/4972)) ([e67483f](https://github.com/homarr-labs/homarr/commit/e67483fea56f0b06fa54e68b8dd62fd0b5dedadd))
|
|
||||||
* **deps:** update dependency ldapts to v8.1.4 ([#4993](https://github.com/homarr-labs/homarr/issues/4993)) ([c2d9f18](https://github.com/homarr-labs/homarr/commit/c2d9f18e4ef28f063e4abf1175cd90ba746410b7))
|
|
||||||
* **deps:** update dependency mysql2 to v3.16.2 ([#4961](https://github.com/homarr-labs/homarr/issues/4961)) ([5c6eafb](https://github.com/homarr-labs/homarr/commit/5c6eafb272436b78d4668d562d50001bca48e6d3))
|
|
||||||
* **deps:** update dependency next-intl to v4.8.0 ([#4977](https://github.com/homarr-labs/homarr/issues/4977)) ([c3a7ab5](https://github.com/homarr-labs/homarr/commit/c3a7ab52ee3acbcf47255d5813317c3cf67ea49f))
|
|
||||||
* **deps:** update dependency next-intl to v4.8.1 ([#4986](https://github.com/homarr-labs/homarr/issues/4986)) ([62b6939](https://github.com/homarr-labs/homarr/commit/62b6939b92f29618cc6d13a189b65df1922779ba))
|
|
||||||
* **deps:** update dependency pg to ^8.18.0 ([#4989](https://github.com/homarr-labs/homarr/issues/4989)) ([c3071a3](https://github.com/homarr-labs/homarr/commit/c3071a3c95f3a30438050aa37c65950cccabf681))
|
|
||||||
* **deps:** update dependency typescript-eslint to ^8.54.0 ([#4958](https://github.com/homarr-labs/homarr/issues/4958)) ([e88d126](https://github.com/homarr-labs/homarr/commit/e88d126355b96ac5060b552047c191f8b284461c))
|
|
||||||
* **deps:** update dependency video.js to ^8.23.6 ([#4992](https://github.com/homarr-labs/homarr/issues/4992)) ([4209f7c](https://github.com/homarr-labs/homarr/commit/4209f7c70e75870f56b93a97f3b6053962ee3ff7))
|
|
||||||
* **deps:** update mantine monorepo to ^8.3.14 ([#4998](https://github.com/homarr-labs/homarr/issues/4998)) ([0fafa50](https://github.com/homarr-labs/homarr/commit/0fafa505ac1c7f4ddb33ee5e8dedca9a883164ba))
|
|
||||||
* **deps:** update nextjs monorepo to v16.1.6 ([#4969](https://github.com/homarr-labs/homarr/issues/4969)) ([7c3fe3d](https://github.com/homarr-labs/homarr/commit/7c3fe3d6d47879c67950b3dc4d7e39adbc06c146))
|
|
||||||
* **deps:** update react monorepo to v19.2.4 ([#4960](https://github.com/homarr-labs/homarr/issues/4960)) ([d3e0b47](https://github.com/homarr-labs/homarr/commit/d3e0b47875998fc766e1c5f0481244fc659b0c49))
|
|
||||||
* **deps:** update tiptap monorepo to v3.18.0 ([#4975](https://github.com/homarr-labs/homarr/issues/4975)) ([24e24dc](https://github.com/homarr-labs/homarr/commit/24e24dc634a9e5a25ab934541225996e62ac31be))
|
|
||||||
* **deps:** update trpc monorepo to ^11.9.0 ([#4970](https://github.com/homarr-labs/homarr/issues/4970)) ([aeb6e0f](https://github.com/homarr-labs/homarr/commit/aeb6e0f40659bf1c514380a6c96858afdaf7e6db))
|
|
||||||
* **deps:** update turbo monorepo to ^2.8.0 ([#4978](https://github.com/homarr-labs/homarr/issues/4978)) ([054ca57](https://github.com/homarr-labs/homarr/commit/054ca57188656ddac7aaa16f792269eaa2ef319b))
|
|
||||||
* **deps:** update turbo monorepo to ^2.8.1 ([#4991](https://github.com/homarr-labs/homarr/issues/4991)) ([43b6246](https://github.com/homarr-labs/homarr/commit/43b6246876debccbe7239c8ee67753e17527e469))
|
|
||||||
|
|
||||||
## [1.52.0](https://github.com/homarr-labs/homarr/compare/v1.51.0...v1.52.0) (2026-01-30)
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* **installations:** support docker secrets file for encryption key ([#4946](https://github.com/homarr-labs/homarr/issues/4946)) ([9ba8213](https://github.com/homarr-labs/homarr/commit/9ba82133da2ae472952358f84d8ee1758c0f108a))
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* **deps:** update dependency @tanstack/react-query to ^5.90.20 ([#4939](https://github.com/homarr-labs/homarr/issues/4939)) ([840940b](https://github.com/homarr-labs/homarr/commit/840940bab663e728b8516ac48f913fef2b5c61b7))
|
|
||||||
* **deps:** update dependency next to v16.1.5 [security] ([#4937](https://github.com/homarr-labs/homarr/issues/4937)) ([aeb1df1](https://github.com/homarr-labs/homarr/commit/aeb1df122926c7bed71bea9b21f1c42c45cc9b3e))
|
|
||||||
* **deps:** update dependency pg to ^8.17.2 ([#4916](https://github.com/homarr-labs/homarr/issues/4916)) ([a50a29a](https://github.com/homarr-labs/homarr/commit/a50a29a778689efcca0afc2b640fdb497e6e7d98))
|
|
||||||
* **deps:** update dependency prettier to ^3.8.1 ([#4925](https://github.com/homarr-labs/homarr/issues/4925)) ([a727b8e](https://github.com/homarr-labs/homarr/commit/a727b8e323b9fb7cba536909a51fabde0a992a69))
|
|
||||||
* **deps:** update dependency sass to ^1.97.3 ([#4927](https://github.com/homarr-labs/homarr/issues/4927)) ([b1658a5](https://github.com/homarr-labs/homarr/commit/b1658a5d01b5c12f391af9d326ec98b3da000f9e))
|
|
||||||
* **deps:** update dependency typescript-eslint to ^8.53.1 ([#4904](https://github.com/homarr-labs/homarr/issues/4904)) ([c58da00](https://github.com/homarr-labs/homarr/commit/c58da0095738352515d6d8c5e81b3c34c8726ffe))
|
|
||||||
* **deps:** update mantine monorepo to ^8.3.13 ([#4911](https://github.com/homarr-labs/homarr/issues/4911)) ([f2eec74](https://github.com/homarr-labs/homarr/commit/f2eec748494480e773b45a309aa89ae3862e2b05))
|
|
||||||
* **deps:** update nextjs monorepo to v16.1.4 ([#4909](https://github.com/homarr-labs/homarr/issues/4909)) ([99a2574](https://github.com/homarr-labs/homarr/commit/99a2574d80ad5a7dfe3b9c92d43bd4b9423bf22d))
|
|
||||||
* **deps:** update tiptap monorepo to v3.16.0 ([#4912](https://github.com/homarr-labs/homarr/issues/4912)) ([2354510](https://github.com/homarr-labs/homarr/commit/23545101b61e456fd886eedb4b3d86b8cc606639))
|
|
||||||
* **deps:** update tiptap monorepo to v3.17.0 ([#4940](https://github.com/homarr-labs/homarr/issues/4940)) ([d030261](https://github.com/homarr-labs/homarr/commit/d03026187cb6451d727167b02ac138f9c7ccc754))
|
|
||||||
* **deps:** update tiptap monorepo to v3.17.1 ([#4945](https://github.com/homarr-labs/homarr/issues/4945)) ([b354085](https://github.com/homarr-labs/homarr/commit/b354085c7adfb6e5f3cad51b5b825426e072e874))
|
|
||||||
* **deps:** update turbo monorepo to ^2.7.6 ([#4947](https://github.com/homarr-labs/homarr/issues/4947)) ([e078237](https://github.com/homarr-labs/homarr/commit/e078237e31d11029987c6c4370fd8f65023b87bc))
|
|
||||||
|
|
||||||
## [1.51.0](https://github.com/homarr-labs/homarr/compare/v1.50.1...v1.51.0) (2026-01-23)
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* **integrations:** add Coolify integration and widget ([#4789](https://github.com/homarr-labs/homarr/issues/4789)) ([81dac58](https://github.com/homarr-labs/homarr/commit/81dac580050a86e34135beef09b876089777f1c7))
|
|
||||||
* **widgets:** add disks widget ([#4445](https://github.com/homarr-labs/homarr/issues/4445)) ([62caa71](https://github.com/homarr-labs/homarr/commit/62caa71a48c38f59f109666e83f26019586a5ca0))
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* **deps:** update dependency @tanstack/react-query to ^5.90.17 ([#4873](https://github.com/homarr-labs/homarr/issues/4873)) ([624bd55](https://github.com/homarr-labs/homarr/commit/624bd55b117b2b9f9109aecdeabf1515c567656e))
|
|
||||||
* **deps:** update dependency @tanstack/react-query to ^5.90.19 ([#4888](https://github.com/homarr-labs/homarr/issues/4888)) ([fa84bd5](https://github.com/homarr-labs/homarr/commit/fa84bd569fdf6c9aecfcb9b4d8fb20d14215160b))
|
|
||||||
* **deps:** update dependency better-sqlite3 to ^12.6.0 ([#4853](https://github.com/homarr-labs/homarr/issues/4853)) ([9d4fb9e](https://github.com/homarr-labs/homarr/commit/9d4fb9eb462a0297618c70f619618f94d8857e1f))
|
|
||||||
* **deps:** update dependency better-sqlite3 to ^12.6.2 ([#4891](https://github.com/homarr-labs/homarr/issues/4891)) ([63a0793](https://github.com/homarr-labs/homarr/commit/63a0793c6ea02456a49a07635b927adf3a314ee0))
|
|
||||||
* **deps:** update dependency fastify to ^5.7.0 ([#4882](https://github.com/homarr-labs/homarr/issues/4882)) ([b9bc9dd](https://github.com/homarr-labs/homarr/commit/b9bc9dd38d22f03a0faa59a68056192c3f1519d4))
|
|
||||||
* **deps:** update dependency fastify to ^5.7.1 ([#4887](https://github.com/homarr-labs/homarr/issues/4887)) ([02e722a](https://github.com/homarr-labs/homarr/commit/02e722aa4531e816bb563628ebbb7e8b0cf93ce3))
|
|
||||||
* **deps:** update dependency ioredis to v5.9.2 ([#4881](https://github.com/homarr-labs/homarr/issues/4881)) ([e3ba1ee](https://github.com/homarr-labs/homarr/commit/e3ba1ee931b0e53fb94bf0e50fae81eecfade237))
|
|
||||||
* **deps:** update dependency jotai to ^2.16.2 ([#4869](https://github.com/homarr-labs/homarr/issues/4869)) ([2e58acc](https://github.com/homarr-labs/homarr/commit/2e58acc3bd5da474bfe0636a58b43759947ef2d2))
|
|
||||||
* **deps:** update dependency mysql2 to v3.16.1 ([#4886](https://github.com/homarr-labs/homarr/issues/4886)) ([40ee667](https://github.com/homarr-labs/homarr/commit/40ee667832124075b0730a54a4b8019365ab8794))
|
|
||||||
* **deps:** update dependency pg to ^8.17.0 ([#4874](https://github.com/homarr-labs/homarr/issues/4874)) ([b923891](https://github.com/homarr-labs/homarr/commit/b923891fac4cd61c5a1a8505d5bcfb737255196f))
|
|
||||||
* **deps:** update dependency pg to ^8.17.1 ([#4877](https://github.com/homarr-labs/homarr/issues/4877)) ([fcd4171](https://github.com/homarr-labs/homarr/commit/fcd417198f4a1afc250455bf25594a32f61b1070))
|
|
||||||
* **deps:** update dependency prettier to ^3.8.0 ([#4876](https://github.com/homarr-labs/homarr/issues/4876)) ([3ade915](https://github.com/homarr-labs/homarr/commit/3ade915d35540578a7f193baf99cbdbf89103b97))
|
|
||||||
* **deps:** update dependency react-error-boundary to ^6.1.0 ([#4884](https://github.com/homarr-labs/homarr/issues/4884)) ([41b02b6](https://github.com/homarr-labs/homarr/commit/41b02b63d9a1f9b73cc54371bbc1b6161a4d76d0))
|
|
||||||
* **deps:** update dependency typescript-eslint to ^8.53.0 ([#4863](https://github.com/homarr-labs/homarr/issues/4863)) ([e9020e6](https://github.com/homarr-labs/homarr/commit/e9020e68ecf9e33df983108e7ab239776874413c))
|
|
||||||
* **deps:** update nextjs monorepo to v16.1.2 ([#4875](https://github.com/homarr-labs/homarr/issues/4875)) ([c6be8c5](https://github.com/homarr-labs/homarr/commit/c6be8c5475722e5a6dbc886e5e7f24ef8a04c470))
|
|
||||||
* **deps:** update nextjs monorepo to v16.1.3 ([#4889](https://github.com/homarr-labs/homarr/issues/4889)) ([5a8e864](https://github.com/homarr-labs/homarr/commit/5a8e864630b61595b53a9e849973460ffdce5fd2))
|
|
||||||
* **deps:** update turbo monorepo to ^2.7.4 ([#4861](https://github.com/homarr-labs/homarr/issues/4861)) ([0c38e2f](https://github.com/homarr-labs/homarr/commit/0c38e2f290fc6dcb9608b338ee38409afb3beabe))
|
|
||||||
* **deps:** update turbo monorepo to ^2.7.5 ([#4892](https://github.com/homarr-labs/homarr/issues/4892)) ([c847f60](https://github.com/homarr-labs/homarr/commit/c847f6004dc4c166969ee1248ec64b7d27ba8362))
|
|
||||||
|
|
||||||
### Performance Improvements
|
|
||||||
|
|
||||||
* **memory:** lazy routers ([#4868](https://github.com/homarr-labs/homarr/issues/4868)) ([1623fba](https://github.com/homarr-labs/homarr/commit/1623fbaaeb41b16e13dcd401a00f70711a283bf9))
|
|
||||||
|
|
||||||
## [1.50.1](https://github.com/homarr-labs/homarr/compare/v1.50.0...v1.50.1) (2026-01-16)
|
## [1.50.1](https://github.com/homarr-labs/homarr/compare/v1.50.0...v1.50.1) (2026-01-16)
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|||||||
+2
-4
@@ -1,4 +1,4 @@
|
|||||||
FROM node:24.14.0-alpine AS base
|
FROM node:24.12.0-alpine AS base
|
||||||
|
|
||||||
FROM base AS builder
|
FROM base AS builder
|
||||||
RUN apk add --no-cache libc6-compat
|
RUN apk add --no-cache libc6-compat
|
||||||
@@ -43,10 +43,8 @@ RUN mkdir -p /var/cache/nginx && \
|
|||||||
COPY --from=builder /app/apps/nextjs/next.config.ts .
|
COPY --from=builder /app/apps/nextjs/next.config.ts .
|
||||||
COPY --from=builder /app/apps/nextjs/package.json .
|
COPY --from=builder /app/apps/nextjs/package.json .
|
||||||
|
|
||||||
|
COPY --from=builder /app/apps/tasks/tasks.cjs ./apps/tasks/tasks.cjs
|
||||||
COPY --from=builder /app/apps/websocket/wssServer.cjs ./apps/websocket/wssServer.cjs
|
COPY --from=builder /app/apps/websocket/wssServer.cjs ./apps/websocket/wssServer.cjs
|
||||||
COPY --from=builder /app/node_modules/better-sqlite3/build/Release/better_sqlite3.node /app/build/better_sqlite3.node
|
|
||||||
|
|
||||||
COPY scripts/job-scheduler.js ./scripts/job-scheduler.js
|
|
||||||
|
|
||||||
COPY --from=builder /app/packages/db/migrations ./db/migrations
|
COPY --from=builder /app/packages/db/migrations ./db/migrations
|
||||||
|
|
||||||
|
|||||||
+29
-29
@@ -48,44 +48,44 @@
|
|||||||
"@homarr/ui": "workspace:^0.1.0",
|
"@homarr/ui": "workspace:^0.1.0",
|
||||||
"@homarr/validation": "workspace:^0.1.0",
|
"@homarr/validation": "workspace:^0.1.0",
|
||||||
"@homarr/widgets": "workspace:^0.1.0",
|
"@homarr/widgets": "workspace:^0.1.0",
|
||||||
"@mantine/colors-generator": "^8.3.18",
|
"@mantine/colors-generator": "^8.3.12",
|
||||||
"@mantine/core": "^8.3.18",
|
"@mantine/core": "^8.3.12",
|
||||||
"@mantine/dropzone": "^8.3.18",
|
"@mantine/dropzone": "^8.3.12",
|
||||||
"@mantine/hooks": "^8.3.18",
|
"@mantine/hooks": "^8.3.12",
|
||||||
"@mantine/modals": "^8.3.18",
|
"@mantine/modals": "^8.3.12",
|
||||||
"@mantine/tiptap": "^8.3.18",
|
"@mantine/tiptap": "^8.3.12",
|
||||||
"@million/lint": "1.0.14",
|
"@million/lint": "1.0.14",
|
||||||
"@tabler/icons-react": "^3.40.0",
|
"@tabler/icons-react": "^3.36.1",
|
||||||
"@tanstack/react-query": "^5.91.2",
|
"@tanstack/react-query": "^5.90.16",
|
||||||
"@tanstack/react-query-devtools": "^5.91.3",
|
"@tanstack/react-query-devtools": "^5.91.2",
|
||||||
"@tanstack/react-query-next-experimental": "^5.91.0",
|
"@tanstack/react-query-next-experimental": "^5.91.0",
|
||||||
"@trpc/client": "^11.13.4",
|
"@trpc/client": "^11.8.1",
|
||||||
"@trpc/next": "^11.13.4",
|
"@trpc/next": "^11.8.1",
|
||||||
"@trpc/react-query": "^11.13.4",
|
"@trpc/react-query": "^11.8.1",
|
||||||
"@trpc/server": "^11.13.4",
|
"@trpc/server": "^11.8.1",
|
||||||
"@xterm/addon-canvas": "^0.7.0",
|
"@xterm/addon-canvas": "^0.7.0",
|
||||||
"@xterm/addon-fit": "0.11.0",
|
"@xterm/addon-fit": "0.11.0",
|
||||||
"@xterm/xterm": "^6.0.0",
|
"@xterm/xterm": "^6.0.0",
|
||||||
"babel-plugin-react-compiler": "^1.0.0",
|
"babel-plugin-react-compiler": "^1.0.0",
|
||||||
"chroma-js": "^3.2.0",
|
"chroma-js": "^3.2.0",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"dayjs": "^1.11.20",
|
"dayjs": "^1.11.19",
|
||||||
"dotenv": "^17.3.1",
|
"dotenv": "^17.2.3",
|
||||||
"flag-icons": "^7.5.0",
|
"flag-icons": "^7.5.0",
|
||||||
"glob": "^13.0.6",
|
"glob": "^13.0.0",
|
||||||
"isomorphic-dompurify": "^3.5.1",
|
"isomorphic-dompurify": "^2.35.0",
|
||||||
"jotai": "^2.18.1",
|
"jotai": "^2.16.1",
|
||||||
"mantine-react-table": "2.0.0-beta.9",
|
"mantine-react-table": "2.0.0-beta.9",
|
||||||
"next": "16.2.0",
|
"next": "16.1.1",
|
||||||
"postcss-preset-mantine": "^1.18.0",
|
"postcss-preset-mantine": "^1.18.0",
|
||||||
"prismjs": "^1.30.0",
|
"prismjs": "^1.30.0",
|
||||||
"react": "19.2.4",
|
"react": "19.2.3",
|
||||||
"react-dom": "19.2.4",
|
"react-dom": "19.2.3",
|
||||||
"react-error-boundary": "^6.1.1",
|
"react-error-boundary": "^6.0.3",
|
||||||
"react-simple-code-editor": "^0.14.1",
|
"react-simple-code-editor": "^0.14.1",
|
||||||
"sass": "^1.98.0",
|
"sass": "^1.97.2",
|
||||||
"superjson": "2.2.6",
|
"superjson": "2.2.6",
|
||||||
"swagger-ui-react": "^5.32.1",
|
"swagger-ui-react": "^5.31.0",
|
||||||
"use-deep-compare-effect": "^1.8.1",
|
"use-deep-compare-effect": "^1.8.1",
|
||||||
"zod": "^4.2.1"
|
"zod": "^4.2.1"
|
||||||
},
|
},
|
||||||
@@ -94,15 +94,15 @@
|
|||||||
"@homarr/prettier-config": "workspace:^0.1.0",
|
"@homarr/prettier-config": "workspace:^0.1.0",
|
||||||
"@homarr/tsconfig": "workspace:^0.1.0",
|
"@homarr/tsconfig": "workspace:^0.1.0",
|
||||||
"@types/chroma-js": "3.1.2",
|
"@types/chroma-js": "3.1.2",
|
||||||
"@types/node": "^24.12.0",
|
"@types/node": "^24.10.7",
|
||||||
"@types/prismjs": "^1.26.6",
|
"@types/prismjs": "^1.26.5",
|
||||||
"@types/react": "19.2.14",
|
"@types/react": "19.2.8",
|
||||||
"@types/react-dom": "19.2.3",
|
"@types/react-dom": "19.2.3",
|
||||||
"@types/swagger-ui-react": "^5.18.0",
|
"@types/swagger-ui-react": "^5.18.0",
|
||||||
"concurrently": "^9.2.1",
|
"concurrently": "^9.2.1",
|
||||||
"eslint": "^9.39.4",
|
"eslint": "^9.39.2",
|
||||||
"node-loader": "^2.1.0",
|
"node-loader": "^2.1.0",
|
||||||
"prettier": "^3.8.1",
|
"prettier": "^3.7.4",
|
||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { startTransition } from "react";
|
||||||
import { Button, Card, Group, Stack, Switch, Text } from "@mantine/core";
|
import { Button, Card, Group, Stack, Switch, Text } from "@mantine/core";
|
||||||
import { IconArrowRight } from "@tabler/icons-react";
|
import { IconArrowRight } from "@tabler/icons-react";
|
||||||
import type { z } from "zod/v4";
|
import type { z } from "zod/v4";
|
||||||
@@ -23,6 +24,16 @@ export const InitSettings = () => {
|
|||||||
});
|
});
|
||||||
const form = useZodForm(settingsInitSchema, { initialValues: defaultServerSettings });
|
const form = useZodForm(settingsInitSchema, { initialValues: defaultServerSettings });
|
||||||
|
|
||||||
|
form.watch("analytics.enableGeneral", ({ value }) => {
|
||||||
|
if (!value) {
|
||||||
|
startTransition(() => {
|
||||||
|
form.setFieldValue("analytics.enableWidgetData", false);
|
||||||
|
form.setFieldValue("analytics.enableIntegrationData", false);
|
||||||
|
form.setFieldValue("analytics.enableUserData", false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const handleSubmitAsync = async (values: z.infer<typeof settingsInitSchema>) => {
|
const handleSubmitAsync = async (values: z.infer<typeof settingsInitSchema>) => {
|
||||||
await mutateAsync(values);
|
await mutateAsync(values);
|
||||||
};
|
};
|
||||||
@@ -36,6 +47,24 @@ export const InitSettings = () => {
|
|||||||
|
|
||||||
<Stack gap="xs">
|
<Stack gap="xs">
|
||||||
<AnalyticsRow kind="general" {...form.getInputProps("analytics.enableGeneral", { type: "checkbox" })} />
|
<AnalyticsRow kind="general" {...form.getInputProps("analytics.enableGeneral", { type: "checkbox" })} />
|
||||||
|
|
||||||
|
<Stack gap="xs" ps="md" w="100%">
|
||||||
|
<AnalyticsRow
|
||||||
|
kind="integrationData"
|
||||||
|
disabled={!form.values.analytics.enableGeneral}
|
||||||
|
{...form.getInputProps("analytics.enableWidgetData", { type: "checkbox" })}
|
||||||
|
/>
|
||||||
|
<AnalyticsRow
|
||||||
|
kind="widgetData"
|
||||||
|
disabled={!form.values.analytics.enableGeneral}
|
||||||
|
{...form.getInputProps("analytics.enableIntegrationData", { type: "checkbox" })}
|
||||||
|
/>
|
||||||
|
<AnalyticsRow
|
||||||
|
kind="usersData"
|
||||||
|
disabled={!form.values.analytics.enableGeneral}
|
||||||
|
{...form.getInputProps("analytics.enableUserData", { type: "checkbox" })}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import { Analytics } from "~/components/layout/analytics";
|
|||||||
import { CrowdinLiveTranslation } from "~/components/layout/crowdin-live-translation";
|
import { CrowdinLiveTranslation } from "~/components/layout/crowdin-live-translation";
|
||||||
import { SearchEngineOptimization } from "~/components/layout/search-engine-optimization";
|
import { SearchEngineOptimization } from "~/components/layout/search-engine-optimization";
|
||||||
import { getCurrentColorSchemeAsync } from "~/theme/color-scheme";
|
import { getCurrentColorSchemeAsync } from "~/theme/color-scheme";
|
||||||
import { initializeJobManager } from "~/lib/job-manager";
|
|
||||||
import { DayJsLoader } from "./_client-providers/dayjs-loader";
|
import { DayJsLoader } from "./_client-providers/dayjs-loader";
|
||||||
import { JotaiProvider } from "./_client-providers/jotai";
|
import { JotaiProvider } from "./_client-providers/jotai";
|
||||||
import { CustomMantineProvider } from "./_client-providers/mantine";
|
import { CustomMantineProvider } from "./_client-providers/mantine";
|
||||||
@@ -84,9 +83,6 @@ export default async function Layout(props: {
|
|||||||
const colorScheme = await getCurrentColorSchemeAsync();
|
const colorScheme = await getCurrentColorSchemeAsync();
|
||||||
const direction = isLocaleRTL((await props.params).locale) ? "rtl" : "ltr";
|
const direction = isLocaleRTL((await props.params).locale) ? "rtl" : "ltr";
|
||||||
|
|
||||||
// Initialize job manager
|
|
||||||
await initializeJobManager();
|
|
||||||
|
|
||||||
const StackedProvider = composeWrappers([
|
const StackedProvider = composeWrappers([
|
||||||
(innerProps) => {
|
(innerProps) => {
|
||||||
return <AuthProvider session={session} logoutUrl={env.AUTH_LOGOUT_REDIRECT_URL} {...innerProps} />;
|
return <AuthProvider session={session} logoutUrl={env.AUTH_LOGOUT_REDIRECT_URL} {...innerProps} />;
|
||||||
|
|||||||
@@ -24,6 +24,15 @@ export const AnalyticsSettings = ({ initialData }: AnalyticsSettingsProps) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!updatedValues.enableGeneral &&
|
||||||
|
(updatedValues.enableWidgetData || updatedValues.enableIntegrationData || updatedValues.enableUserData)
|
||||||
|
) {
|
||||||
|
updatedValues.enableIntegrationData = false;
|
||||||
|
updatedValues.enableUserData = false;
|
||||||
|
updatedValues.enableWidgetData = false;
|
||||||
|
}
|
||||||
|
|
||||||
void mutateAsync({
|
void mutateAsync({
|
||||||
settingsKey: "analytics",
|
settingsKey: "analytics",
|
||||||
value: updatedValues,
|
value: updatedValues,
|
||||||
@@ -45,6 +54,30 @@ export const AnalyticsSettings = ({ initialData }: AnalyticsSettingsProps) => {
|
|||||||
<LoadingOverlay visible={isPending} zIndex={1000} overlayProps={{ radius: "sm", blur: 2 }} />
|
<LoadingOverlay visible={isPending} zIndex={1000} overlayProps={{ radius: "sm", blur: 2 }} />
|
||||||
<Stack>
|
<Stack>
|
||||||
<SwitchSetting form={form} formKey="enableGeneral" title={t("general.title")} text={t("general.text")} />
|
<SwitchSetting form={form} formKey="enableGeneral" title={t("general.title")} text={t("general.text")} />
|
||||||
|
<SwitchSetting
|
||||||
|
form={form}
|
||||||
|
formKey="enableIntegrationData"
|
||||||
|
ms="xl"
|
||||||
|
title={t("integrationData.title")}
|
||||||
|
text={t("integrationData.text")}
|
||||||
|
disabled={!form.values.enableGeneral}
|
||||||
|
/>
|
||||||
|
<SwitchSetting
|
||||||
|
form={form}
|
||||||
|
formKey="enableWidgetData"
|
||||||
|
ms="xl"
|
||||||
|
title={t("widgetData.title")}
|
||||||
|
text={t("widgetData.text")}
|
||||||
|
disabled={!form.values.enableGeneral}
|
||||||
|
/>
|
||||||
|
<SwitchSetting
|
||||||
|
form={form}
|
||||||
|
formKey="enableUserData"
|
||||||
|
ms="xl"
|
||||||
|
title={t("usersData.title")}
|
||||||
|
text={t("usersData.text")}
|
||||||
|
disabled={!form.values.enableGeneral}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Card>
|
</Card>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -117,8 +117,6 @@ const createColumns = (
|
|||||||
header: tTasks("field.interval.label"),
|
header: tTasks("field.interval.label"),
|
||||||
size: 200,
|
size: 200,
|
||||||
Cell({ row }) {
|
Cell({ row }) {
|
||||||
if (row.original.preventCustomInterval) return null;
|
|
||||||
|
|
||||||
const handleIntervalChange = (newCron: string | null) => {
|
const handleIntervalChange = (newCron: string | null) => {
|
||||||
if (!newCron || newCron === row.original.cron) return;
|
if (!newCron || newCron === row.original.cron) return;
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ export const WidgetPreviewPageContent = ({ kind, integrationData }: WidgetPrevie
|
|||||||
<ErrorBoundary
|
<ErrorBoundary
|
||||||
onReset={reset}
|
onReset={reset}
|
||||||
fallbackRender={({ resetErrorBoundary, error }) => (
|
fallbackRender={({ resetErrorBoundary, error }) => (
|
||||||
<WidgetError kind={kind} error={error} resetErrorBoundary={resetErrorBoundary} />
|
<WidgetError kind={kind} error={error as unknown} resetErrorBoundary={resetErrorBoundary} />
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Comp
|
<Comp
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
|
||||||
|
|
||||||
import { getJobManager } from "~/lib/job-manager";
|
|
||||||
|
|
||||||
export async function POST(request: NextRequest) {
|
|
||||||
// Only allow internal requests
|
|
||||||
const internalHeader = request.headers.get("x-internal-request");
|
|
||||||
if (internalHeader !== "true") {
|
|
||||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const jobManager = getJobManager();
|
|
||||||
await jobManager.triggerJobsAsync();
|
|
||||||
return NextResponse.json({ success: true });
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error triggering jobs:", error);
|
|
||||||
return NextResponse.json({ error: "Internal server error" }, { status: 500 });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,6 @@ import { ipAddressFromHeaders } from "@homarr/common/server";
|
|||||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||||
import { ErrorWithMetadata } from "@homarr/core/infrastructure/logs/error";
|
import { ErrorWithMetadata } from "@homarr/core/infrastructure/logs/error";
|
||||||
import { db } from "@homarr/db";
|
import { db } from "@homarr/db";
|
||||||
import { getJobManager } from "~/lib/job-manager";
|
|
||||||
|
|
||||||
const logger = createLogger({ module: "trpcRoute" });
|
const logger = createLogger({ module: "trpcRoute" });
|
||||||
|
|
||||||
@@ -46,7 +45,7 @@ const handler = auth(async (req) => {
|
|||||||
endpoint: trpcPath,
|
endpoint: trpcPath,
|
||||||
router: appRouter,
|
router: appRouter,
|
||||||
req,
|
req,
|
||||||
createContext: () => createTRPCContext({ session, headers: req.headers, jobManager: getJobManager() }),
|
createContext: () => createTRPCContext({ session, headers: req.headers }),
|
||||||
onError({ error, path, type }) {
|
onError({ error, path, type }) {
|
||||||
logger.error(new ErrorWithMetadata("tRPC Error occured", { path, type }, { cause: error }));
|
logger.error(new ErrorWithMetadata("tRPC Error occured", { path, type }, { cause: error }));
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ const InnerContent = ({ item, ...dimensions }: InnerContentProps) => {
|
|||||||
fallbackRender={({ resetErrorBoundary, error }) => (
|
fallbackRender={({ resetErrorBoundary, error }) => (
|
||||||
<>
|
<>
|
||||||
<BoardItemMenu offset={4} item={newItem} resetErrorBoundary={resetErrorBoundary} />
|
<BoardItemMenu offset={4} item={newItem} resetErrorBoundary={resetErrorBoundary} />
|
||||||
<WidgetError kind={item.kind} error={error} resetErrorBoundary={resetErrorBoundary} />
|
<WidgetError kind={item.kind} error={error as unknown} resetErrorBoundary={resetErrorBoundary} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { ActionIcon, Menu } from "@mantine/core";
|
|||||||
import { IconCopy, IconDotsVertical, IconLayoutKanban, IconPencil, IconTrash } from "@tabler/icons-react";
|
import { IconCopy, IconDotsVertical, IconLayoutKanban, IconPencil, IconTrash } from "@tabler/icons-react";
|
||||||
|
|
||||||
import { clientApi } from "@homarr/api/client";
|
import { clientApi } from "@homarr/api/client";
|
||||||
import { useSession } from "@homarr/auth/client";
|
|
||||||
import { useEditMode } from "@homarr/boards/edit-mode";
|
import { useEditMode } from "@homarr/boards/edit-mode";
|
||||||
import { useConfirmModal, useModalAction } from "@homarr/modals";
|
import { useConfirmModal, useModalAction } from "@homarr/modals";
|
||||||
import { useSettings } from "@homarr/settings";
|
import { useSettings } from "@homarr/settings";
|
||||||
@@ -16,20 +15,15 @@ import { useSectionContext } from "../sections/section-context";
|
|||||||
import { useItemActions } from "./item-actions";
|
import { useItemActions } from "./item-actions";
|
||||||
import { ItemMoveModal } from "./item-move-modal";
|
import { ItemMoveModal } from "./item-move-modal";
|
||||||
|
|
||||||
interface BoardItemMenuProps {
|
export const BoardItemMenu = ({
|
||||||
|
offset,
|
||||||
|
item,
|
||||||
|
resetErrorBoundary,
|
||||||
|
}: {
|
||||||
offset: number;
|
offset: number;
|
||||||
item: SectionItem;
|
item: SectionItem;
|
||||||
resetErrorBoundary?: () => void;
|
resetErrorBoundary?: () => void;
|
||||||
}
|
}) => {
|
||||||
|
|
||||||
export const BoardItemMenu = (props: BoardItemMenuProps) => {
|
|
||||||
const { data: session } = useSession();
|
|
||||||
if (!session) return null;
|
|
||||||
|
|
||||||
return <BoardItemMenuInner {...props} />;
|
|
||||||
};
|
|
||||||
|
|
||||||
const BoardItemMenuInner = ({ offset, item, resetErrorBoundary }: BoardItemMenuProps) => {
|
|
||||||
const refResetErrorBoundaryOnNextRender = useRef(false);
|
const refResetErrorBoundaryOnNextRender = useRef(false);
|
||||||
const tItem = useScopedI18n("item");
|
const tItem = useScopedI18n("item");
|
||||||
const t = useI18n();
|
const t = useI18n();
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { Avatar, Button, Card, Center, Grid, Group, Input, Stack, Text, Tooltip } from "@mantine/core";
|
import { Button, Card, Center, Grid, Input, Stack, Text } from "@mantine/core";
|
||||||
import { IconSearch } from "@tabler/icons-react";
|
import { IconSearch } from "@tabler/icons-react";
|
||||||
|
|
||||||
import { objectEntries } from "@homarr/common";
|
import { objectEntries } from "@homarr/common";
|
||||||
import { getIconUrl, getIntegrationName } from "@homarr/definitions";
|
import type { WidgetKind } from "@homarr/definitions";
|
||||||
import type { IntegrationKind, WidgetKind } from "@homarr/definitions";
|
|
||||||
import { createModal } from "@homarr/modals";
|
import { createModal } from "@homarr/modals";
|
||||||
import { useI18n } from "@homarr/translation/client";
|
import { useI18n } from "@homarr/translation/client";
|
||||||
import type { TablerIcon } from "@homarr/ui";
|
import type { TablerIcon } from "@homarr/ui";
|
||||||
@@ -22,10 +21,6 @@ export const ItemSelectModal = createModal<void>(({ actions }) => {
|
|||||||
objectEntries(widgetImports)
|
objectEntries(widgetImports)
|
||||||
.map(([kind, value]) => ({
|
.map(([kind, value]) => ({
|
||||||
kind,
|
kind,
|
||||||
supportedIntegrations:
|
|
||||||
"supportedIntegrations" in value.definition
|
|
||||||
? value.definition.supportedIntegrations.filter((integration) => integration !== "mock")
|
|
||||||
: [],
|
|
||||||
icon: value.definition.icon,
|
icon: value.definition.icon,
|
||||||
name: t(`widget.${kind}.name`),
|
name: t(`widget.${kind}.name`),
|
||||||
description: t(`widget.${kind}.description`),
|
description: t(`widget.${kind}.description`),
|
||||||
@@ -79,7 +74,6 @@ const WidgetItem = ({
|
|||||||
}: {
|
}: {
|
||||||
item: {
|
item: {
|
||||||
kind: WidgetKind;
|
kind: WidgetKind;
|
||||||
supportedIntegrations: IntegrationKind[];
|
|
||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
icon: TablerIcon;
|
icon: TablerIcon;
|
||||||
@@ -103,8 +97,7 @@ const WidgetItem = ({
|
|||||||
{item.description}
|
{item.description}
|
||||||
</Text>
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
<SupportedIntegrations mt="auto" integrations={item.supportedIntegrations} />
|
<Button onClick={onSelect} variant="light" size="xs" mt="auto" radius="md" fullWidth>
|
||||||
<Button onClick={onSelect} variant="light" size="xs" radius="md" fullWidth>
|
|
||||||
{t(`item.create.addToBoard`)}
|
{t(`item.create.addToBoard`)}
|
||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
@@ -112,48 +105,3 @@ const WidgetItem = ({
|
|||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
interface SupportedIntegrationsProps {
|
|
||||||
integrations: IntegrationKind[];
|
|
||||||
mt: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const SupportedIntegrations = ({ integrations, mt }: SupportedIntegrationsProps) => {
|
|
||||||
if (integrations.length === 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// When there are 8 or more integrations, we show 6 and a "+X" avatar. Otherwise, we show all integrations.
|
|
||||||
const countToShow = integrations.length >= 8 ? 6 : 7;
|
|
||||||
const moreCount = integrations.length - countToShow;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Center mt={mt}>
|
|
||||||
<Tooltip.Group openDelay={300} closeDelay={100}>
|
|
||||||
<Group gap={2}>
|
|
||||||
{integrations.slice(0, countToShow).map((integration) => (
|
|
||||||
<Tooltip key={integration} label={getIntegrationName(integration)} withArrow>
|
|
||||||
<Avatar src={getIconUrl(integration)} size="xs" radius="xl" />
|
|
||||||
</Tooltip>
|
|
||||||
))}
|
|
||||||
{moreCount > 0 && (
|
|
||||||
<Tooltip
|
|
||||||
withArrow
|
|
||||||
label={
|
|
||||||
<>
|
|
||||||
{integrations.slice(countToShow).map((integration) => (
|
|
||||||
<div key={integration}>{getIntegrationName(integration)}</div>
|
|
||||||
))}
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Avatar radius="xl" size="xs">
|
|
||||||
+{moreCount}
|
|
||||||
</Avatar>
|
|
||||||
</Tooltip>
|
|
||||||
)}
|
|
||||||
</Group>
|
|
||||||
</Tooltip.Group>
|
|
||||||
</Center>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -58,7 +58,6 @@ export const useCategoryActions = () => {
|
|||||||
...section,
|
...section,
|
||||||
yOffset: section.yOffset + 2,
|
yOffset: section.yOffset + 2,
|
||||||
})),
|
})),
|
||||||
...previous.sections.filter((section) => section.kind !== "category" && section.kind !== "empty"),
|
|
||||||
] satisfies Section[],
|
] satisfies Section[],
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
import { JobManager } from "@homarr/job-scheduler";
|
|
||||||
import { jobGroup } from "@homarr/cron-jobs";
|
|
||||||
import { db } from "@homarr/db";
|
|
||||||
|
|
||||||
let jobManagerInstance: JobManager | null = null;
|
|
||||||
|
|
||||||
export function getJobManager(): JobManager {
|
|
||||||
if (!jobManagerInstance) {
|
|
||||||
jobManagerInstance = new JobManager(db, jobGroup);
|
|
||||||
}
|
|
||||||
return jobManagerInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function initializeJobManager(): Promise<void> {
|
|
||||||
const manager = getJobManager();
|
|
||||||
await jobGroup.initializeAsync();
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import baseConfig from "@homarr/eslint-config/base";
|
||||||
|
|
||||||
|
/** @type {import('typescript-eslint').Config} */
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
ignores: ["tasks.cjs"],
|
||||||
|
},
|
||||||
|
...baseConfig,
|
||||||
|
];
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
{
|
||||||
|
"name": "@homarr/tasks",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"type": "module",
|
||||||
|
"exports": {
|
||||||
|
".": "./src/index.ts"
|
||||||
|
},
|
||||||
|
"main": "./src/main.ts",
|
||||||
|
"types": "./src/main.ts",
|
||||||
|
"scripts": {
|
||||||
|
"build": "esbuild src/main.ts --bundle --platform=node --loader:.scss=text --external:*.node --external:@opentelemetry/api --external:deasync --external:bcrypt --outfile=tasks.cjs",
|
||||||
|
"clean": "rm -rf .turbo node_modules",
|
||||||
|
"dev": "pnpm with-env tsx ./src/main.ts",
|
||||||
|
"format": "prettier --check . --ignore-path ../../.gitignore",
|
||||||
|
"lint": "eslint",
|
||||||
|
"typecheck": "tsc --noEmit",
|
||||||
|
"with-env": "dotenv -e ../../.env --"
|
||||||
|
},
|
||||||
|
"prettier": "@homarr/prettier-config",
|
||||||
|
"dependencies": {
|
||||||
|
"@homarr/analytics": "workspace:^0.1.0",
|
||||||
|
"@homarr/auth": "workspace:^0.1.0",
|
||||||
|
"@homarr/common": "workspace:^0.1.0",
|
||||||
|
"@homarr/core": "workspace:^",
|
||||||
|
"@homarr/cron-job-api": "workspace:^0.1.0",
|
||||||
|
"@homarr/cron-jobs": "workspace:^0.1.0",
|
||||||
|
"@homarr/cron-jobs-core": "workspace:^0.1.0",
|
||||||
|
"@homarr/db": "workspace:^0.1.0",
|
||||||
|
"@homarr/definitions": "workspace:^0.1.0",
|
||||||
|
"@homarr/icons": "workspace:^0.1.0",
|
||||||
|
"@homarr/integrations": "workspace:^0.1.0",
|
||||||
|
"@homarr/ping": "workspace:^0.1.0",
|
||||||
|
"@homarr/redis": "workspace:^0.1.0",
|
||||||
|
"@homarr/request-handler": "workspace:^0.1.0",
|
||||||
|
"@homarr/server-settings": "workspace:^0.1.0",
|
||||||
|
"@homarr/validation": "workspace:^0.1.0",
|
||||||
|
"@homarr/widgets": "workspace:^0.1.0",
|
||||||
|
"dayjs": "^1.11.19",
|
||||||
|
"dotenv": "^17.2.3",
|
||||||
|
"fastify": "^5.6.2",
|
||||||
|
"superjson": "2.2.6",
|
||||||
|
"undici": "7.18.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@homarr/eslint-config": "workspace:^0.2.0",
|
||||||
|
"@homarr/prettier-config": "workspace:^0.1.0",
|
||||||
|
"@homarr/tsconfig": "workspace:^0.1.0",
|
||||||
|
"@types/node": "^24.10.7",
|
||||||
|
"dotenv-cli": "^11.0.0",
|
||||||
|
"esbuild": "^0.27.2",
|
||||||
|
"eslint": "^9.39.2",
|
||||||
|
"prettier": "^3.7.4",
|
||||||
|
"tsx": "4.20.4",
|
||||||
|
"typescript": "^5.9.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { parseExpression } from "cron-parser";
|
import { schedule, validate as validateCron } from "node-cron";
|
||||||
|
|
||||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||||
import type { IJobManager } from "@homarr/cron-job-api";
|
import type { IJobManager } from "@homarr/cron-job-api";
|
||||||
@@ -10,103 +10,54 @@ import { cronJobConfigurations } from "@homarr/db/schema";
|
|||||||
const logger = createLogger({ module: "jobManager" });
|
const logger = createLogger({ module: "jobManager" });
|
||||||
|
|
||||||
export class JobManager implements IJobManager {
|
export class JobManager implements IJobManager {
|
||||||
private runningJobs = new Set<string>();
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private db: Database,
|
private db: Database,
|
||||||
private jobGroup: typeof cronJobGroup,
|
private jobGroup: typeof cronJobGroup,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public async startAsync(name: JobGroupKeys): Promise<void> {
|
public async startAsync(name: JobGroupKeys): Promise<void> {
|
||||||
// In the new system, start just means enable
|
await this.jobGroup.startAsync(name);
|
||||||
await this.enableAsync(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async triggerAsync(name: JobGroupKeys): Promise<void> {
|
public async triggerAsync(name: JobGroupKeys): Promise<void> {
|
||||||
await this.jobGroup.runManuallyAsync(name);
|
await this.jobGroup.runManuallyAsync(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async stopAsync(name: JobGroupKeys): Promise<void> {
|
public async stopAsync(name: JobGroupKeys): Promise<void> {
|
||||||
// In the new system, stop means disable
|
await this.jobGroup.stopAsync(name);
|
||||||
await this.disableAsync(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async updateIntervalAsync(name: JobGroupKeys, cron: string): Promise<void> {
|
public async updateIntervalAsync(name: JobGroupKeys, cron: string): Promise<void> {
|
||||||
logger.info("Updating cron job interval", { name, expression: cron });
|
logger.info("Updating cron job interval", { name, expression: cron });
|
||||||
const job = this.jobGroup.getJobRegistry().get(name);
|
const job = this.jobGroup.getJobRegistry().get(name);
|
||||||
if (!job) throw new Error(`Job ${name} not found`);
|
if (!job) throw new Error(`Job ${name} not found`);
|
||||||
|
if (!validateCron(cron)) {
|
||||||
// Validate cron expression
|
|
||||||
try {
|
|
||||||
parseExpression(cron);
|
|
||||||
} catch {
|
|
||||||
throw new Error(`Invalid cron expression: ${cron}`);
|
throw new Error(`Invalid cron expression: ${cron}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (job.preventCustomInterval && cron !== job.cronExpression) {
|
|
||||||
throw new Error(`Custom cron expressions are not allowed for job ${name}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.updateConfigurationAsync(name, { cronExpression: cron });
|
await this.updateConfigurationAsync(name, { cronExpression: cron });
|
||||||
|
await this.jobGroup.getTask(name)?.destroy();
|
||||||
|
|
||||||
|
this.jobGroup.setTask(
|
||||||
|
name,
|
||||||
|
schedule(cron, () => void job.executeAsync(), {
|
||||||
|
name,
|
||||||
|
}),
|
||||||
|
);
|
||||||
logger.info("Cron job interval updated", { name, expression: cron });
|
logger.info("Cron job interval updated", { name, expression: cron });
|
||||||
}
|
}
|
||||||
|
|
||||||
public async disableAsync(name: JobGroupKeys): Promise<void> {
|
public async disableAsync(name: JobGroupKeys): Promise<void> {
|
||||||
logger.info("Disabling cron job", { name });
|
logger.info("Disabling cron job", { name });
|
||||||
const job = this.jobGroup.getJobRegistry().get(name);
|
const job = this.jobGroup.getJobRegistry().get(name);
|
||||||
if (!job) throw new Error(`Job ${name} not found`);
|
if (!job) throw new Error(`Job ${name} not found`);
|
||||||
|
|
||||||
await this.updateConfigurationAsync(name, { isEnabled: false });
|
await this.updateConfigurationAsync(name, { isEnabled: false });
|
||||||
|
await this.jobGroup.stopAsync(name);
|
||||||
logger.info("Cron job disabled", { name });
|
logger.info("Cron job disabled", { name });
|
||||||
}
|
}
|
||||||
|
|
||||||
public async enableAsync(name: JobGroupKeys): Promise<void> {
|
public async enableAsync(name: JobGroupKeys): Promise<void> {
|
||||||
logger.info("Enabling cron job", { name });
|
logger.info("Enabling cron job", { name });
|
||||||
await this.updateConfigurationAsync(name, { isEnabled: true });
|
await this.updateConfigurationAsync(name, { isEnabled: true });
|
||||||
|
await this.jobGroup.startAsync(name);
|
||||||
logger.info("Cron job enabled", { name });
|
logger.info("Cron job enabled", { name });
|
||||||
}
|
}
|
||||||
|
|
||||||
// New method to trigger jobs based on current time
|
|
||||||
public async triggerJobsAsync(): Promise<void> {
|
|
||||||
const jobs = await this.getAllAsync();
|
|
||||||
const now = new Date();
|
|
||||||
|
|
||||||
for (const jobInfo of jobs) {
|
|
||||||
if (!jobInfo.isEnabled) continue;
|
|
||||||
if (this.runningJobs.has(jobInfo.name)) continue; // Prevent parallel execution
|
|
||||||
|
|
||||||
try {
|
|
||||||
const cronExpression = jobInfo.cron;
|
|
||||||
const interval = parseExpression(cronExpression);
|
|
||||||
const nextRun = interval.next();
|
|
||||||
const prevRun = interval.prev();
|
|
||||||
|
|
||||||
// Check if current time matches the cron (within a small tolerance)
|
|
||||||
const timeDiff = Math.abs(now.getTime() - nextRun.getTime());
|
|
||||||
if (timeDiff < 1000) { // Within 1 second
|
|
||||||
await this.executeJobAsync(jobInfo.name);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
logger.error("Error checking job schedule", { name: jobInfo.name, error });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async executeJobAsync(name: string): Promise<void> {
|
|
||||||
if (this.runningJobs.has(name)) return;
|
|
||||||
|
|
||||||
this.runningJobs.add(name);
|
|
||||||
try {
|
|
||||||
logger.info("Executing scheduled job", { name });
|
|
||||||
await this.jobGroup.runManuallyAsync(name as JobGroupKeys);
|
|
||||||
logger.info("Job executed successfully", { name });
|
|
||||||
} catch (error) {
|
|
||||||
logger.error("Job execution failed", { name, error });
|
|
||||||
} finally {
|
|
||||||
this.runningJobs.delete(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async updateConfigurationAsync(
|
private async updateConfigurationAsync(
|
||||||
name: JobGroupKeys,
|
name: JobGroupKeys,
|
||||||
configuration: Omit<Partial<InferInsertModel<typeof cronJobConfigurations>>, "name">,
|
configuration: Omit<Partial<InferInsertModel<typeof cronJobConfigurations>>, "name">,
|
||||||
@@ -124,6 +75,7 @@ export class JobManager implements IJobManager {
|
|||||||
if (existingConfig) {
|
if (existingConfig) {
|
||||||
await this.db
|
await this.db
|
||||||
.update(cronJobConfigurations)
|
.update(cronJobConfigurations)
|
||||||
|
// prevent updating the name, as it is the primary key
|
||||||
.set({ ...configuration, name: undefined })
|
.set({ ...configuration, name: undefined })
|
||||||
.where(eq(cronJobConfigurations.name, name));
|
.where(eq(cronJobConfigurations.name, name));
|
||||||
logger.debug("Cron job configuration updated", {
|
logger.debug("Cron job configuration updated", {
|
||||||
@@ -141,20 +93,14 @@ export class JobManager implements IJobManager {
|
|||||||
cronExpression: configuration.cronExpression ?? job.cronExpression,
|
cronExpression: configuration.cronExpression ?? job.cronExpression,
|
||||||
isEnabled: configuration.isEnabled ?? true,
|
isEnabled: configuration.isEnabled ?? true,
|
||||||
});
|
});
|
||||||
logger.debug("Cron job configuration created", {
|
logger.debug("Cron job configuration updated", {
|
||||||
name,
|
name,
|
||||||
configuration: JSON.stringify(configuration),
|
configuration: JSON.stringify(configuration),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getAllAsync(): Promise<
|
public async getAllAsync(): Promise<
|
||||||
{
|
{ name: JobGroupKeys; cron: string; preventManualExecution: boolean; isEnabled: boolean }[]
|
||||||
name: JobGroupKeys;
|
|
||||||
cron: string;
|
|
||||||
preventManualExecution: boolean;
|
|
||||||
preventCustomInterval: boolean;
|
|
||||||
isEnabled: boolean;
|
|
||||||
}[]
|
|
||||||
> {
|
> {
|
||||||
const configurations = await this.db.query.cronJobConfigurations.findMany();
|
const configurations = await this.db.query.cronJobConfigurations.findMany();
|
||||||
|
|
||||||
@@ -164,7 +110,6 @@ export class JobManager implements IJobManager {
|
|||||||
name,
|
name,
|
||||||
cron: config?.cronExpression ?? job.cronExpression,
|
cron: config?.cronExpression ?? job.cronExpression,
|
||||||
preventManualExecution: job.preventManualExecution,
|
preventManualExecution: job.preventManualExecution,
|
||||||
preventCustomInterval: job.preventCustomInterval,
|
|
||||||
isEnabled: config?.isEnabled ?? true,
|
isEnabled: config?.isEnabled ?? true,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
// This import has to be the first import in the file so that the agent is overridden before any other modules are imported.
|
||||||
|
import "./overrides";
|
||||||
|
|
||||||
|
import type { FastifyTRPCPluginOptions } from "@trpc/server/adapters/fastify";
|
||||||
|
import { fastifyTRPCPlugin } from "@trpc/server/adapters/fastify";
|
||||||
|
import fastify from "fastify";
|
||||||
|
|
||||||
|
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||||
|
import { ErrorWithMetadata } from "@homarr/core/infrastructure/logs/error";
|
||||||
|
import type { JobRouter } from "@homarr/cron-job-api";
|
||||||
|
import { jobRouter } from "@homarr/cron-job-api";
|
||||||
|
import { CRON_JOB_API_KEY_HEADER, CRON_JOB_API_PATH, CRON_JOB_API_PORT } from "@homarr/cron-job-api/constants";
|
||||||
|
import { jobGroup } from "@homarr/cron-jobs";
|
||||||
|
import { db } from "@homarr/db";
|
||||||
|
|
||||||
|
import { JobManager } from "./job-manager";
|
||||||
|
import { onStartAsync } from "./on-start";
|
||||||
|
|
||||||
|
const logger = createLogger({ module: "tasksMain" });
|
||||||
|
|
||||||
|
const server = fastify({
|
||||||
|
maxParamLength: 5000,
|
||||||
|
});
|
||||||
|
server.register(fastifyTRPCPlugin, {
|
||||||
|
prefix: CRON_JOB_API_PATH,
|
||||||
|
trpcOptions: {
|
||||||
|
router: jobRouter,
|
||||||
|
createContext: ({ req }) => ({
|
||||||
|
manager: new JobManager(db, jobGroup),
|
||||||
|
apiKey: req.headers[CRON_JOB_API_KEY_HEADER] as string | undefined,
|
||||||
|
}),
|
||||||
|
onError({ path, error }) {
|
||||||
|
logger.error(new ErrorWithMetadata("Error in tasks tRPC handler", { path }, { cause: error }));
|
||||||
|
},
|
||||||
|
} satisfies FastifyTRPCPluginOptions<JobRouter>["trpcOptions"],
|
||||||
|
});
|
||||||
|
|
||||||
|
void (async () => {
|
||||||
|
await onStartAsync();
|
||||||
|
await jobGroup.initializeAsync();
|
||||||
|
await jobGroup.startAllAsync();
|
||||||
|
|
||||||
|
try {
|
||||||
|
await server.listen({ port: CRON_JOB_API_PORT });
|
||||||
|
logger.info("Tasks web server started successfully", { port: CRON_JOB_API_PORT });
|
||||||
|
} catch (err) {
|
||||||
|
logger.error(
|
||||||
|
new ErrorWithMetadata("Failed to start tasks web server", { port: CRON_JOB_API_PORT }, { cause: err }),
|
||||||
|
);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
})();
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { invalidateUpdateCheckerCacheAsync } from "./invalidate-update-checker-cache";
|
||||||
|
import { cleanupSessionsAsync } from "./session-cleanup";
|
||||||
|
|
||||||
|
export async function onStartAsync() {
|
||||||
|
await cleanupSessionsAsync();
|
||||||
|
await invalidateUpdateCheckerCacheAsync();
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||||
|
import { updateCheckerRequestHandler } from "@homarr/request-handler/update-checker";
|
||||||
|
|
||||||
|
const logger = createLogger({ module: "invalidateUpdateCheckerCache" });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalidates the update checker cache on startup to ensure fresh data.
|
||||||
|
* It is important as we want to avoid showing pending updates after the update to latest version.
|
||||||
|
*/
|
||||||
|
export async function invalidateUpdateCheckerCacheAsync() {
|
||||||
|
try {
|
||||||
|
const handler = updateCheckerRequestHandler.handler({});
|
||||||
|
await handler.invalidateAsync();
|
||||||
|
logger.debug("Update checker cache invalidated");
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(new Error("Failed to invalidate update checker cache", { cause: error }));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import { env } from "@homarr/auth/env";
|
||||||
|
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||||
|
import { db, eq, inArray } from "@homarr/db";
|
||||||
|
import { sessions, users } from "@homarr/db/schema";
|
||||||
|
import { supportedAuthProviders } from "@homarr/definitions";
|
||||||
|
|
||||||
|
const logger = createLogger({ module: "sessionCleanup" });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes sessions for users that have inactive auth providers.
|
||||||
|
* Sessions from other providers are deleted so they can no longer be used.
|
||||||
|
*/
|
||||||
|
export async function cleanupSessionsAsync() {
|
||||||
|
try {
|
||||||
|
const currentAuthProviders = env.AUTH_PROVIDERS;
|
||||||
|
|
||||||
|
const inactiveAuthProviders = supportedAuthProviders.filter((provider) => !currentAuthProviders.includes(provider));
|
||||||
|
const subQuery = db
|
||||||
|
.select({ id: users.id })
|
||||||
|
.from(users)
|
||||||
|
.where(inArray(users.provider, inactiveAuthProviders))
|
||||||
|
.as("sq");
|
||||||
|
const sessionsWithInactiveProviders = await db
|
||||||
|
.select({ userId: sessions.userId })
|
||||||
|
.from(sessions)
|
||||||
|
.rightJoin(subQuery, eq(sessions.userId, subQuery.id));
|
||||||
|
|
||||||
|
const userIds = sessionsWithInactiveProviders.map(({ userId }) => userId).filter((value) => value !== null);
|
||||||
|
await db.delete(sessions).where(inArray(sessions.userId, userIds));
|
||||||
|
|
||||||
|
if (sessionsWithInactiveProviders.length > 0) {
|
||||||
|
logger.info("Deleted sessions for inactive providers", {
|
||||||
|
count: userIds.length,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
logger.debug("No sessions to delete");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(new Error("Failed to clean up sessions", { cause: error }));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import { setGlobalDispatcher } from "undici";
|
||||||
|
|
||||||
|
import { UndiciHttpAgent } from "@homarr/core/infrastructure/http";
|
||||||
|
|
||||||
|
setGlobalDispatcher(new UndiciHttpAgent());
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"extends": "@homarr/tsconfig/base.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"~/*": ["src/*"],
|
||||||
|
"@homarr/node-unifi": ["../../node_modules/@types/node-unifi"]
|
||||||
|
},
|
||||||
|
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
|
||||||
|
},
|
||||||
|
"include": ["."],
|
||||||
|
"exclude": ["node_modules"]
|
||||||
|
}
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
"@homarr/definitions": "workspace:^0.1.0",
|
"@homarr/definitions": "workspace:^0.1.0",
|
||||||
"@homarr/redis": "workspace:^0.1.0",
|
"@homarr/redis": "workspace:^0.1.0",
|
||||||
"@homarr/validation": "workspace:^0.1.0",
|
"@homarr/validation": "workspace:^0.1.0",
|
||||||
"dotenv": "^17.3.1",
|
"dotenv": "^17.2.3",
|
||||||
"tsx": "4.20.4",
|
"tsx": "4.20.4",
|
||||||
"ws": "^8.19.0"
|
"ws": "^8.19.0"
|
||||||
},
|
},
|
||||||
@@ -34,9 +34,9 @@
|
|||||||
"@homarr/prettier-config": "workspace:^0.1.0",
|
"@homarr/prettier-config": "workspace:^0.1.0",
|
||||||
"@homarr/tsconfig": "workspace:^0.1.0",
|
"@homarr/tsconfig": "workspace:^0.1.0",
|
||||||
"@types/ws": "^8.18.1",
|
"@types/ws": "^8.18.1",
|
||||||
"esbuild": "^0.27.4",
|
"esbuild": "^0.27.2",
|
||||||
"eslint": "^9.39.4",
|
"eslint": "^9.39.2",
|
||||||
"prettier": "^3.8.1",
|
"prettier": "^3.7.4",
|
||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
FROM node:24.14.0-trixie AS base
|
|
||||||
WORKDIR /app
|
|
||||||
COPY package.json .
|
|
||||||
COPY pnpm-lock.yaml .
|
|
||||||
RUN corepack enable pnpm && pnpm install --frozen-lockfile
|
|
||||||
CMD ["sleep", "60s"]
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "homarr-prebuilt-debian",
|
|
||||||
"private": true,
|
|
||||||
"dependencies": {
|
|
||||||
"better-sqlite3": "^12.6.2"
|
|
||||||
},
|
|
||||||
"packageManager": "pnpm@10.32.1",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=24.14.0",
|
|
||||||
"pnpm": ">=10.32.1"
|
|
||||||
},
|
|
||||||
"pnpm": {
|
|
||||||
"onlyBuiltDependencies": [
|
|
||||||
"better-sqlite3"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-286
@@ -1,286 +0,0 @@
|
|||||||
lockfileVersion: '9.0'
|
|
||||||
|
|
||||||
settings:
|
|
||||||
autoInstallPeers: true
|
|
||||||
excludeLinksFromLockfile: false
|
|
||||||
|
|
||||||
importers:
|
|
||||||
|
|
||||||
.:
|
|
||||||
dependencies:
|
|
||||||
better-sqlite3:
|
|
||||||
specifier: ^12.6.2
|
|
||||||
version: 12.6.2
|
|
||||||
|
|
||||||
packages:
|
|
||||||
|
|
||||||
base64-js@1.5.1:
|
|
||||||
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
|
|
||||||
|
|
||||||
better-sqlite3@12.6.2:
|
|
||||||
resolution: {integrity: sha512-8VYKM3MjCa9WcaSAI3hzwhmyHVlH8tiGFwf0RlTsZPWJ1I5MkzjiudCo4KC4DxOaL/53A5B1sI/IbldNFDbsKA==}
|
|
||||||
engines: {node: 20.x || 22.x || 23.x || 24.x || 25.x}
|
|
||||||
|
|
||||||
bindings@1.5.0:
|
|
||||||
resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==}
|
|
||||||
|
|
||||||
bl@4.1.0:
|
|
||||||
resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==}
|
|
||||||
|
|
||||||
buffer@5.7.1:
|
|
||||||
resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==}
|
|
||||||
|
|
||||||
chownr@1.1.4:
|
|
||||||
resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==}
|
|
||||||
|
|
||||||
decompress-response@6.0.0:
|
|
||||||
resolution: {integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==}
|
|
||||||
engines: {node: '>=10'}
|
|
||||||
|
|
||||||
deep-extend@0.6.0:
|
|
||||||
resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==}
|
|
||||||
engines: {node: '>=4.0.0'}
|
|
||||||
|
|
||||||
detect-libc@2.1.2:
|
|
||||||
resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==}
|
|
||||||
engines: {node: '>=8'}
|
|
||||||
|
|
||||||
end-of-stream@1.4.5:
|
|
||||||
resolution: {integrity: sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==}
|
|
||||||
|
|
||||||
expand-template@2.0.3:
|
|
||||||
resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==}
|
|
||||||
engines: {node: '>=6'}
|
|
||||||
|
|
||||||
file-uri-to-path@1.0.0:
|
|
||||||
resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==}
|
|
||||||
|
|
||||||
fs-constants@1.0.0:
|
|
||||||
resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==}
|
|
||||||
|
|
||||||
github-from-package@0.0.0:
|
|
||||||
resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==}
|
|
||||||
|
|
||||||
ieee754@1.2.1:
|
|
||||||
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
|
|
||||||
|
|
||||||
inherits@2.0.4:
|
|
||||||
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
|
|
||||||
|
|
||||||
ini@1.3.8:
|
|
||||||
resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==}
|
|
||||||
|
|
||||||
mimic-response@3.1.0:
|
|
||||||
resolution: {integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==}
|
|
||||||
engines: {node: '>=10'}
|
|
||||||
|
|
||||||
minimist@1.2.8:
|
|
||||||
resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==}
|
|
||||||
|
|
||||||
mkdirp-classic@0.5.3:
|
|
||||||
resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==}
|
|
||||||
|
|
||||||
napi-build-utils@2.0.0:
|
|
||||||
resolution: {integrity: sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==}
|
|
||||||
|
|
||||||
node-abi@3.85.0:
|
|
||||||
resolution: {integrity: sha512-zsFhmbkAzwhTft6nd3VxcG0cvJsT70rL+BIGHWVq5fi6MwGrHwzqKaxXE+Hl2GmnGItnDKPPkO5/LQqjVkIdFg==}
|
|
||||||
engines: {node: '>=10'}
|
|
||||||
|
|
||||||
once@1.4.0:
|
|
||||||
resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==}
|
|
||||||
|
|
||||||
prebuild-install@7.1.3:
|
|
||||||
resolution: {integrity: sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==}
|
|
||||||
engines: {node: '>=10'}
|
|
||||||
hasBin: true
|
|
||||||
|
|
||||||
pump@3.0.3:
|
|
||||||
resolution: {integrity: sha512-todwxLMY7/heScKmntwQG8CXVkWUOdYxIvY2s0VWAAMh/nd8SoYiRaKjlr7+iCs984f2P8zvrfWcDDYVb73NfA==}
|
|
||||||
|
|
||||||
rc@1.2.8:
|
|
||||||
resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==}
|
|
||||||
hasBin: true
|
|
||||||
|
|
||||||
readable-stream@3.6.2:
|
|
||||||
resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==}
|
|
||||||
engines: {node: '>= 6'}
|
|
||||||
|
|
||||||
safe-buffer@5.2.1:
|
|
||||||
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
|
|
||||||
|
|
||||||
semver@7.7.3:
|
|
||||||
resolution: {integrity: sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==}
|
|
||||||
engines: {node: '>=10'}
|
|
||||||
hasBin: true
|
|
||||||
|
|
||||||
simple-concat@1.0.1:
|
|
||||||
resolution: {integrity: sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==}
|
|
||||||
|
|
||||||
simple-get@4.0.1:
|
|
||||||
resolution: {integrity: sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==}
|
|
||||||
|
|
||||||
string_decoder@1.3.0:
|
|
||||||
resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==}
|
|
||||||
|
|
||||||
strip-json-comments@2.0.1:
|
|
||||||
resolution: {integrity: sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==}
|
|
||||||
engines: {node: '>=0.10.0'}
|
|
||||||
|
|
||||||
tar-fs@2.1.4:
|
|
||||||
resolution: {integrity: sha512-mDAjwmZdh7LTT6pNleZ05Yt65HC3E+NiQzl672vQG38jIrehtJk/J3mNwIg+vShQPcLF/LV7CMnDW6vjj6sfYQ==}
|
|
||||||
|
|
||||||
tar-stream@2.2.0:
|
|
||||||
resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==}
|
|
||||||
engines: {node: '>=6'}
|
|
||||||
|
|
||||||
tunnel-agent@0.6.0:
|
|
||||||
resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==}
|
|
||||||
|
|
||||||
util-deprecate@1.0.2:
|
|
||||||
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
|
|
||||||
|
|
||||||
wrappy@1.0.2:
|
|
||||||
resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
|
|
||||||
|
|
||||||
snapshots:
|
|
||||||
|
|
||||||
base64-js@1.5.1: {}
|
|
||||||
|
|
||||||
better-sqlite3@12.6.2:
|
|
||||||
dependencies:
|
|
||||||
bindings: 1.5.0
|
|
||||||
prebuild-install: 7.1.3
|
|
||||||
|
|
||||||
bindings@1.5.0:
|
|
||||||
dependencies:
|
|
||||||
file-uri-to-path: 1.0.0
|
|
||||||
|
|
||||||
bl@4.1.0:
|
|
||||||
dependencies:
|
|
||||||
buffer: 5.7.1
|
|
||||||
inherits: 2.0.4
|
|
||||||
readable-stream: 3.6.2
|
|
||||||
|
|
||||||
buffer@5.7.1:
|
|
||||||
dependencies:
|
|
||||||
base64-js: 1.5.1
|
|
||||||
ieee754: 1.2.1
|
|
||||||
|
|
||||||
chownr@1.1.4: {}
|
|
||||||
|
|
||||||
decompress-response@6.0.0:
|
|
||||||
dependencies:
|
|
||||||
mimic-response: 3.1.0
|
|
||||||
|
|
||||||
deep-extend@0.6.0: {}
|
|
||||||
|
|
||||||
detect-libc@2.1.2: {}
|
|
||||||
|
|
||||||
end-of-stream@1.4.5:
|
|
||||||
dependencies:
|
|
||||||
once: 1.4.0
|
|
||||||
|
|
||||||
expand-template@2.0.3: {}
|
|
||||||
|
|
||||||
file-uri-to-path@1.0.0: {}
|
|
||||||
|
|
||||||
fs-constants@1.0.0: {}
|
|
||||||
|
|
||||||
github-from-package@0.0.0: {}
|
|
||||||
|
|
||||||
ieee754@1.2.1: {}
|
|
||||||
|
|
||||||
inherits@2.0.4: {}
|
|
||||||
|
|
||||||
ini@1.3.8: {}
|
|
||||||
|
|
||||||
mimic-response@3.1.0: {}
|
|
||||||
|
|
||||||
minimist@1.2.8: {}
|
|
||||||
|
|
||||||
mkdirp-classic@0.5.3: {}
|
|
||||||
|
|
||||||
napi-build-utils@2.0.0: {}
|
|
||||||
|
|
||||||
node-abi@3.85.0:
|
|
||||||
dependencies:
|
|
||||||
semver: 7.7.3
|
|
||||||
|
|
||||||
once@1.4.0:
|
|
||||||
dependencies:
|
|
||||||
wrappy: 1.0.2
|
|
||||||
|
|
||||||
prebuild-install@7.1.3:
|
|
||||||
dependencies:
|
|
||||||
detect-libc: 2.1.2
|
|
||||||
expand-template: 2.0.3
|
|
||||||
github-from-package: 0.0.0
|
|
||||||
minimist: 1.2.8
|
|
||||||
mkdirp-classic: 0.5.3
|
|
||||||
napi-build-utils: 2.0.0
|
|
||||||
node-abi: 3.85.0
|
|
||||||
pump: 3.0.3
|
|
||||||
rc: 1.2.8
|
|
||||||
simple-get: 4.0.1
|
|
||||||
tar-fs: 2.1.4
|
|
||||||
tunnel-agent: 0.6.0
|
|
||||||
|
|
||||||
pump@3.0.3:
|
|
||||||
dependencies:
|
|
||||||
end-of-stream: 1.4.5
|
|
||||||
once: 1.4.0
|
|
||||||
|
|
||||||
rc@1.2.8:
|
|
||||||
dependencies:
|
|
||||||
deep-extend: 0.6.0
|
|
||||||
ini: 1.3.8
|
|
||||||
minimist: 1.2.8
|
|
||||||
strip-json-comments: 2.0.1
|
|
||||||
|
|
||||||
readable-stream@3.6.2:
|
|
||||||
dependencies:
|
|
||||||
inherits: 2.0.4
|
|
||||||
string_decoder: 1.3.0
|
|
||||||
util-deprecate: 1.0.2
|
|
||||||
|
|
||||||
safe-buffer@5.2.1: {}
|
|
||||||
|
|
||||||
semver@7.7.3: {}
|
|
||||||
|
|
||||||
simple-concat@1.0.1: {}
|
|
||||||
|
|
||||||
simple-get@4.0.1:
|
|
||||||
dependencies:
|
|
||||||
decompress-response: 6.0.0
|
|
||||||
once: 1.4.0
|
|
||||||
simple-concat: 1.0.1
|
|
||||||
|
|
||||||
string_decoder@1.3.0:
|
|
||||||
dependencies:
|
|
||||||
safe-buffer: 5.2.1
|
|
||||||
|
|
||||||
strip-json-comments@2.0.1: {}
|
|
||||||
|
|
||||||
tar-fs@2.1.4:
|
|
||||||
dependencies:
|
|
||||||
chownr: 1.1.4
|
|
||||||
mkdirp-classic: 0.5.3
|
|
||||||
pump: 3.0.3
|
|
||||||
tar-stream: 2.2.0
|
|
||||||
|
|
||||||
tar-stream@2.2.0:
|
|
||||||
dependencies:
|
|
||||||
bl: 4.1.0
|
|
||||||
end-of-stream: 1.4.5
|
|
||||||
fs-constants: 1.0.0
|
|
||||||
inherits: 2.0.4
|
|
||||||
readable-stream: 3.6.2
|
|
||||||
|
|
||||||
tunnel-agent@0.6.0:
|
|
||||||
dependencies:
|
|
||||||
safe-buffer: 5.2.1
|
|
||||||
|
|
||||||
util-deprecate@1.0.2: {}
|
|
||||||
|
|
||||||
wrappy@1.0.2: {}
|
|
||||||
+18
-60
@@ -78,13 +78,6 @@
|
|||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td align="center">
|
<td align="center">
|
||||||
<a href="https://homarr.dev/docs/integrations/coolify" target="_blank" rel="noreferrer noopener">
|
|
||||||
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/coolify.svg" alt="Coolify" width="90" height="90" />
|
|
||||||
<br/>
|
|
||||||
<p align="center">Coolify</p>
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td align="center">
|
|
||||||
<a href="https://homarr.dev/docs/integrations/dash-dot" target="_blank" rel="noreferrer noopener">
|
<a href="https://homarr.dev/docs/integrations/dash-dot" target="_blank" rel="noreferrer noopener">
|
||||||
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/png/dashdot.png" alt="Dash." width="90" height="90" />
|
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/png/dashdot.png" alt="Dash." width="90" height="90" />
|
||||||
<br/>
|
<br/>
|
||||||
@@ -104,15 +97,15 @@
|
|||||||
<br/>
|
<br/>
|
||||||
<p align="center">Docker<br/>Hub</p>
|
<p align="center">Docker<br/>Hub</p>
|
||||||
</a>
|
</a>
|
||||||
</td></tr>
|
</td>
|
||||||
<tr><td align="center">
|
<td align="center">
|
||||||
<a href="https://homarr.dev/docs/integrations/emby" target="_blank" rel="noreferrer noopener">
|
<a href="https://homarr.dev/docs/integrations/emby" target="_blank" rel="noreferrer noopener">
|
||||||
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/emby.svg" alt="Emby" width="90" height="90" />
|
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/emby.svg" alt="Emby" width="90" height="90" />
|
||||||
<br/>
|
<br/>
|
||||||
<p align="center">Emby</p>
|
<p align="center">Emby</p>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td></tr>
|
||||||
<td align="center">
|
<tr><td align="center">
|
||||||
<a href="https://homarr.dev/docs/integrations/github" target="_blank" rel="noreferrer noopener">
|
<a href="https://homarr.dev/docs/integrations/github" target="_blank" rel="noreferrer noopener">
|
||||||
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/github.svg" alt="Github" width="90" height="90" />
|
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/github.svg" alt="Github" width="90" height="90" />
|
||||||
<br/>
|
<br/>
|
||||||
@@ -134,13 +127,6 @@
|
|||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td align="center">
|
<td align="center">
|
||||||
<a href="null" target="_blank" rel="noreferrer noopener">
|
|
||||||
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/glances.svg" alt="Glances" width="90" height="90" />
|
|
||||||
<br/>
|
|
||||||
<p align="center">Glances</p>
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td align="center">
|
|
||||||
<a href="https://homarr.dev/docs/integrations/home-assistant" target="_blank" rel="noreferrer noopener">
|
<a href="https://homarr.dev/docs/integrations/home-assistant" target="_blank" rel="noreferrer noopener">
|
||||||
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/home-assistant.svg" alt="Home Assistant" width="90" height="90" />
|
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/home-assistant.svg" alt="Home Assistant" width="90" height="90" />
|
||||||
<br/>
|
<br/>
|
||||||
@@ -153,13 +139,6 @@
|
|||||||
<br/>
|
<br/>
|
||||||
<p align="center">iCal</p>
|
<p align="center">iCal</p>
|
||||||
</a>
|
</a>
|
||||||
</td></tr>
|
|
||||||
<tr><td align="center">
|
|
||||||
<a href="https://homarr.dev/docs/integrations/immich" target="_blank" rel="noreferrer noopener">
|
|
||||||
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/immich.svg" alt="Immich" width="90" height="90" />
|
|
||||||
<br/>
|
|
||||||
<p align="center">Immich</p>
|
|
||||||
</a>
|
|
||||||
</td>
|
</td>
|
||||||
<td align="center">
|
<td align="center">
|
||||||
<a href="https://homarr.dev/docs/integrations/jellyfin" target="_blank" rel="noreferrer noopener">
|
<a href="https://homarr.dev/docs/integrations/jellyfin" target="_blank" rel="noreferrer noopener">
|
||||||
@@ -174,8 +153,8 @@
|
|||||||
<br/>
|
<br/>
|
||||||
<p align="center">Jellyseerr</p>
|
<p align="center">Jellyseerr</p>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td></tr>
|
||||||
<td align="center">
|
<tr><td align="center">
|
||||||
<a href="https://homarr.dev/docs/integrations/lidarr" target="_blank" rel="noreferrer noopener">
|
<a href="https://homarr.dev/docs/integrations/lidarr" target="_blank" rel="noreferrer noopener">
|
||||||
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/lidarr.svg" alt="Lidarr" width="90" height="90" />
|
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/lidarr.svg" alt="Lidarr" width="90" height="90" />
|
||||||
<br/>
|
<br/>
|
||||||
@@ -202,8 +181,8 @@
|
|||||||
<br/>
|
<br/>
|
||||||
<p align="center">NPM</p>
|
<p align="center">NPM</p>
|
||||||
</a>
|
</a>
|
||||||
</td></tr>
|
</td>
|
||||||
<tr><td align="center">
|
<td align="center">
|
||||||
<a href="https://homarr.dev/docs/integrations/ntfy" target="_blank" rel="noreferrer noopener">
|
<a href="https://homarr.dev/docs/integrations/ntfy" target="_blank" rel="noreferrer noopener">
|
||||||
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/ntfy.svg" alt="ntfy" width="90" height="90" />
|
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/ntfy.svg" alt="ntfy" width="90" height="90" />
|
||||||
<br/>
|
<br/>
|
||||||
@@ -223,8 +202,8 @@
|
|||||||
<br/>
|
<br/>
|
||||||
<p align="center">OpenMediaVault</p>
|
<p align="center">OpenMediaVault</p>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td></tr>
|
||||||
<td align="center">
|
<tr><td align="center">
|
||||||
<a href="https://homarr.dev/docs/integrations/opnsense" target="_blank" rel="noreferrer noopener">
|
<a href="https://homarr.dev/docs/integrations/opnsense" target="_blank" rel="noreferrer noopener">
|
||||||
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/opnsense.svg" alt="OPNsense" width="90" height="90" />
|
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/opnsense.svg" alt="OPNsense" width="90" height="90" />
|
||||||
<br/>
|
<br/>
|
||||||
@@ -251,8 +230,8 @@
|
|||||||
<br/>
|
<br/>
|
||||||
<p align="center">Plex</p>
|
<p align="center">Plex</p>
|
||||||
</a>
|
</a>
|
||||||
</td></tr>
|
</td>
|
||||||
<tr><td align="center">
|
<td align="center">
|
||||||
<a href="https://homarr.dev/docs/integrations/prowlarr" target="_blank" rel="noreferrer noopener">
|
<a href="https://homarr.dev/docs/integrations/prowlarr" target="_blank" rel="noreferrer noopener">
|
||||||
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/prowlarr.svg" alt="Prowlarr" width="90" height="90" />
|
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/prowlarr.svg" alt="Prowlarr" width="90" height="90" />
|
||||||
<br/>
|
<br/>
|
||||||
@@ -272,8 +251,8 @@
|
|||||||
<br/>
|
<br/>
|
||||||
<p align="center">qBittorrent</p>
|
<p align="center">qBittorrent</p>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td></tr>
|
||||||
<td align="center">
|
<tr><td align="center">
|
||||||
<a href="https://homarr.dev/docs/integrations/quay" target="_blank" rel="noreferrer noopener">
|
<a href="https://homarr.dev/docs/integrations/quay" target="_blank" rel="noreferrer noopener">
|
||||||
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/png/quay.png" alt="Quay" width="90" height="90" />
|
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/png/quay.png" alt="Quay" width="90" height="90" />
|
||||||
<br/>
|
<br/>
|
||||||
@@ -300,20 +279,6 @@
|
|||||||
<br/>
|
<br/>
|
||||||
<p align="center">SABnzbd</p>
|
<p align="center">SABnzbd</p>
|
||||||
</a>
|
</a>
|
||||||
</td></tr>
|
|
||||||
<tr><td align="center">
|
|
||||||
<a href="https://homarr.dev/docs/integrations/seerr" target="_blank" rel="noreferrer noopener">
|
|
||||||
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/seerr.svg" alt="Seerr" width="90" height="90" />
|
|
||||||
<br/>
|
|
||||||
<p align="center">Seerr</p>
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td align="center">
|
|
||||||
<a href="https://homarr.dev/docs/integrations/slskd" target="_blank" rel="noreferrer noopener">
|
|
||||||
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/slskd.svg" alt="Slskd" width="90" height="90" />
|
|
||||||
<br/>
|
|
||||||
<p align="center">Slskd</p>
|
|
||||||
</a>
|
|
||||||
</td>
|
</td>
|
||||||
<td align="center">
|
<td align="center">
|
||||||
<a href="https://homarr.dev/docs/integrations/sonarr" target="_blank" rel="noreferrer noopener">
|
<a href="https://homarr.dev/docs/integrations/sonarr" target="_blank" rel="noreferrer noopener">
|
||||||
@@ -330,27 +295,20 @@
|
|||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td align="center">
|
<td align="center">
|
||||||
<a href="https://homarr.dev/docs/integrations/tracearr" target="_blank" rel="noreferrer noopener">
|
|
||||||
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/tracearr.svg" alt="Tracearr" width="90" height="90" />
|
|
||||||
<br/>
|
|
||||||
<p align="center">Tracearr</p>
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td align="center">
|
|
||||||
<a href="https://homarr.dev/docs/integrations/transmission" target="_blank" rel="noreferrer noopener">
|
<a href="https://homarr.dev/docs/integrations/transmission" target="_blank" rel="noreferrer noopener">
|
||||||
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/transmission.svg" alt="Transmission" width="90" height="90" />
|
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/transmission.svg" alt="Transmission" width="90" height="90" />
|
||||||
<br/>
|
<br/>
|
||||||
<p align="center">Transmission</p>
|
<p align="center">Transmission</p>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td></tr>
|
||||||
<td align="center">
|
<tr><td align="center">
|
||||||
<a href="https://homarr.dev/docs/integrations/truenas" target="_blank" rel="noreferrer noopener">
|
<a href="https://homarr.dev/docs/integrations/truenas" target="_blank" rel="noreferrer noopener">
|
||||||
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/truenas.svg" alt="TrueNAS" width="90" height="90" />
|
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/truenas.svg" alt="TrueNAS" width="90" height="90" />
|
||||||
<br/>
|
<br/>
|
||||||
<p align="center">TrueNAS</p>
|
<p align="center">TrueNAS</p>
|
||||||
</a>
|
</a>
|
||||||
</td></tr>
|
</td>
|
||||||
<tr><td align="center">
|
<td align="center">
|
||||||
<a href="https://homarr.dev/docs/integrations/unifi-controller" target="_blank" rel="noreferrer noopener">
|
<a href="https://homarr.dev/docs/integrations/unifi-controller" target="_blank" rel="noreferrer noopener">
|
||||||
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/png/unifi.png" alt="Unifi Controller" width="90" height="90" />
|
<img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/png/unifi.png" alt="Unifi Controller" width="90" height="90" />
|
||||||
<br/>
|
<br/>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ describe("Health checks", () => {
|
|||||||
// Assert
|
// Assert
|
||||||
expect(readyResponse.status).toBe(200);
|
expect(readyResponse.status).toBe(200);
|
||||||
expect(liveResponse.status).toBe(200);
|
expect(liveResponse.status).toBe(200);
|
||||||
}, 60_000);
|
}, 20_000);
|
||||||
|
|
||||||
test("ready and live should return 200 OK with external redis", async () => {
|
test("ready and live should return 200 OK with external redis", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
@@ -42,5 +42,5 @@ describe("Health checks", () => {
|
|||||||
liveResponse.status,
|
liveResponse.status,
|
||||||
`Expected live to return OK statusCode=${liveResponse.status} content=${await liveResponse.text()}`,
|
`Expected live to return OK statusCode=${liveResponse.status} content=${await liveResponse.text()}`,
|
||||||
).toBe(200);
|
).toBe(200);
|
||||||
}, 60_000);
|
}, 20_000);
|
||||||
});
|
});
|
||||||
+1
-1
@@ -12,5 +12,5 @@ describe("Home", () => {
|
|||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(homeResponse.status).toBe(200);
|
expect(homeResponse.status).toBe(200);
|
||||||
}, 60_000);
|
}, 20_000);
|
||||||
});
|
});
|
||||||
@@ -18,11 +18,6 @@ export const createHomarrContainer = (
|
|||||||
.withExposedPorts(7575)
|
.withExposedPorts(7575)
|
||||||
.withEnvironment({
|
.withEnvironment({
|
||||||
...options.environment,
|
...options.environment,
|
||||||
// We disable external connections due to the following reasons:
|
|
||||||
// - No icons have to be downloaded (11k)
|
|
||||||
// - No analytics data is sent
|
|
||||||
// - It is just faster and makes the tests more reliable (better performance)
|
|
||||||
NO_EXTERNAL_CONNECTION: true.toString(),
|
|
||||||
SECRET_ENCRYPTION_KEY: "0".repeat(64),
|
SECRET_ENCRYPTION_KEY: "0".repeat(64),
|
||||||
})
|
})
|
||||||
.withBindMounts(
|
.withBindMounts(
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { mkdir } from "fs/promises";
|
import { mkdir } from "fs/promises";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
import { createClient } from "@libsql/client/node";
|
||||||
import { createId } from "@paralleldrive/cuid2";
|
import { createId } from "@paralleldrive/cuid2";
|
||||||
import Database from "better-sqlite3";
|
import { drizzle, LibSQLDatabase } from "drizzle-orm/libsql";
|
||||||
import { BetterSQLite3Database, drizzle } from "drizzle-orm/better-sqlite3";
|
import { migrate } from "drizzle-orm/libsql/migrator";
|
||||||
import { migrate } from "drizzle-orm/better-sqlite3/migrator";
|
|
||||||
|
|
||||||
import { DB_CASING } from "../../packages/core/src/infrastructure/db/constants";
|
import { DB_CASING } from "../../packages/core/src/infrastructure/db/constants";
|
||||||
import * as sqliteSchema from "../../packages/db/schema/sqlite";
|
import * as sqliteSchema from "../../packages/db/schema/sqlite";
|
||||||
@@ -14,7 +14,10 @@ export const createSqliteDbFileAsync = async () => {
|
|||||||
|
|
||||||
const localDbUrl = path.join(localMountPath, "db", "db.sqlite");
|
const localDbUrl = path.join(localMountPath, "db", "db.sqlite");
|
||||||
|
|
||||||
const connection = new Database(localDbUrl);
|
const connection = createClient({
|
||||||
|
url: `file:${localDbUrl}`,
|
||||||
|
});
|
||||||
|
|
||||||
const db = drizzle(connection, {
|
const db = drizzle(connection, {
|
||||||
schema: sqliteSchema,
|
schema: sqliteSchema,
|
||||||
casing: DB_CASING,
|
casing: DB_CASING,
|
||||||
@@ -30,4 +33,4 @@ export const createSqliteDbFileAsync = async () => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export type SqliteDatabase = BetterSQLite3Database<typeof sqliteSchema>;
|
export type SqliteDatabase = LibSQLDatabase<typeof sqliteSchema>;
|
||||||
+33
-34
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "homarr",
|
"name": "homarr",
|
||||||
"version": "1.56.1",
|
"version": "1.50.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cross-env CI=true turbo build",
|
"build": "cross-env CI=true turbo build",
|
||||||
@@ -39,36 +39,35 @@
|
|||||||
"@semantic-release/changelog": "^6.0.3",
|
"@semantic-release/changelog": "^6.0.3",
|
||||||
"@semantic-release/commit-analyzer": "^13.0.1",
|
"@semantic-release/commit-analyzer": "^13.0.1",
|
||||||
"@semantic-release/git": "^10.0.1",
|
"@semantic-release/git": "^10.0.1",
|
||||||
"@semantic-release/github": "^12.0.6",
|
"@semantic-release/github": "^12.0.2",
|
||||||
"@semantic-release/npm": "^13.1.5",
|
"@semantic-release/npm": "^13.1.3",
|
||||||
"@semantic-release/release-notes-generator": "^14.1.0",
|
"@semantic-release/release-notes-generator": "^14.1.0",
|
||||||
"@testcontainers/redis": "^11.13.0",
|
"@testcontainers/redis": "^11.11.0",
|
||||||
"@turbo/gen": "^2.8.20",
|
"@turbo/gen": "^2.7.4",
|
||||||
"@vitejs/plugin-react": "^5.2.0",
|
"@vitejs/plugin-react": "^5.1.2",
|
||||||
"@vitest/coverage-v8": "^4.1.0",
|
"@vitest/coverage-v8": "^4.0.17",
|
||||||
"@vitest/ui": "^4.1.0",
|
"@vitest/ui": "^4.0.17",
|
||||||
"conventional-changelog-conventionalcommits": "^9.3.0",
|
"conventional-changelog-conventionalcommits": "^9.1.0",
|
||||||
"cross-env": "^10.1.0",
|
"cross-env": "^10.1.0",
|
||||||
"jsdom": "^28.1.0",
|
"jsdom": "^27.4.0",
|
||||||
"json5": "^2.2.3",
|
"json5": "^2.2.3",
|
||||||
"prettier": "^3.8.1",
|
"prettier": "^3.7.4",
|
||||||
"semantic-release": "^25.0.3",
|
"semantic-release": "^25.0.2",
|
||||||
"testcontainers": "^11.13.0",
|
"testcontainers": "^11.11.0",
|
||||||
"turbo": "^2.8.20",
|
"turbo": "^2.7.4",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"vite-tsconfig-paths": "^6.1.1",
|
"vite-tsconfig-paths": "^6.0.4",
|
||||||
"vitest": "^4.1.0"
|
"vitest": "^4.0.17"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@10.32.1",
|
"packageManager": "pnpm@10.28.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=24.14.0",
|
"node": ">=24.12.0",
|
||||||
"pnpm": ">=10.32.1"
|
"pnpm": ">=10.28.0"
|
||||||
},
|
},
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
"onlyBuiltDependencies": [
|
"onlyBuiltDependencies": [
|
||||||
"@tree-sitter-grammars/tree-sitter-yaml",
|
"@tree-sitter-grammars/tree-sitter-yaml",
|
||||||
"bcrypt",
|
"bcrypt",
|
||||||
"better-sqlite3",
|
|
||||||
"cpu-features",
|
"cpu-features",
|
||||||
"esbuild",
|
"esbuild",
|
||||||
"sharp",
|
"sharp",
|
||||||
@@ -77,25 +76,25 @@
|
|||||||
"tree-sitter-json"
|
"tree-sitter-json"
|
||||||
],
|
],
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"@babel/helpers@<7.26.10": ">=7.29.2",
|
"@babel/helpers@<7.26.10": ">=7.28.6",
|
||||||
"@babel/runtime@<7.26.10": ">=7.29.2",
|
"@babel/runtime@<7.26.10": ">=7.28.6",
|
||||||
"axios@>=1.0.0 <1.8.2": ">=1.13.6",
|
"axios@>=1.0.0 <1.8.2": ">=1.13.2",
|
||||||
"brace-expansion@>=2.0.0 <=2.0.1": ">=5.0.4",
|
"brace-expansion@>=2.0.0 <=2.0.1": ">=4.0.1",
|
||||||
"brace-expansion@>=1.0.0 <=1.1.11": ">=5.0.4",
|
"brace-expansion@>=1.0.0 <=1.1.11": ">=4.0.1",
|
||||||
"esbuild@<=0.24.2": ">=0.27.4",
|
"esbuild@<=0.24.2": ">=0.27.2",
|
||||||
"form-data@>=4.0.0 <4.0.4": ">=4.0.5",
|
"form-data@>=4.0.0 <4.0.4": ">=4.0.5",
|
||||||
"hono@<4.6.5": ">=4.12.8",
|
"hono@<4.6.5": ">=4.11.4",
|
||||||
"linkifyjs@<4.3.2": ">=4.3.2",
|
"linkifyjs@<4.3.2": ">=4.3.2",
|
||||||
"nanoid@>=4.0.0 <5.0.9": ">=5.1.7",
|
"nanoid@>=4.0.0 <5.0.9": ">=5.1.6",
|
||||||
"prismjs@<1.30.0": ">=1.30.0",
|
"prismjs@<1.30.0": ">=1.30.0",
|
||||||
"proxmox-api>undici": "7.24.0",
|
"proxmox-api>undici": "7.18.2",
|
||||||
"react-is": "^19.2.4",
|
"react-is": "^19.2.3",
|
||||||
"rollup@>=4.0.0 <4.22.4": ">=4.59.0",
|
"rollup@>=4.0.0 <4.22.4": ">=4.55.1",
|
||||||
"sha.js@<=2.4.11": ">=2.4.12",
|
"sha.js@<=2.4.11": ">=2.4.12",
|
||||||
"tar-fs@>=3.0.0 <3.0.9": ">=3.1.2",
|
"tar-fs@>=3.0.0 <3.0.9": ">=3.1.1",
|
||||||
"tar-fs@>=2.0.0 <2.1.3": ">=3.1.2",
|
"tar-fs@>=2.0.0 <2.1.3": ">=3.1.1",
|
||||||
"tmp@<=0.2.3": ">=0.2.5",
|
"tmp@<=0.2.3": ">=0.2.5",
|
||||||
"vite@>=5.0.0 <=5.4.18": ">=8.0.1"
|
"vite@>=5.0.0 <=5.4.18": ">=7.3.1"
|
||||||
},
|
},
|
||||||
"patchedDependencies": {
|
"patchedDependencies": {
|
||||||
"@types/node-unifi": "patches/@types__node-unifi.patch",
|
"@types/node-unifi": "patches/@types__node-unifi.patch",
|
||||||
|
|||||||
@@ -22,11 +22,8 @@
|
|||||||
},
|
},
|
||||||
"prettier": "@homarr/prettier-config",
|
"prettier": "@homarr/prettier-config",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@homarr/auth": "workspace:^0.1.0",
|
|
||||||
"@homarr/common": "workspace:^0.1.0",
|
|
||||||
"@homarr/core": "workspace:^0.1.0",
|
"@homarr/core": "workspace:^0.1.0",
|
||||||
"@homarr/db": "workspace:^0.1.0",
|
"@homarr/db": "workspace:^0.1.0",
|
||||||
"@homarr/docker": "workspace:^0.1.0",
|
|
||||||
"@homarr/server-settings": "workspace:^0.1.0",
|
"@homarr/server-settings": "workspace:^0.1.0",
|
||||||
"@umami/node": "^0.4.0",
|
"@umami/node": "^0.4.0",
|
||||||
"superjson": "2.2.6"
|
"superjson": "2.2.6"
|
||||||
@@ -35,7 +32,7 @@
|
|||||||
"@homarr/eslint-config": "workspace:^0.2.0",
|
"@homarr/eslint-config": "workspace:^0.2.0",
|
||||||
"@homarr/prettier-config": "workspace:^0.1.0",
|
"@homarr/prettier-config": "workspace:^0.1.0",
|
||||||
"@homarr/tsconfig": "workspace:^0.1.0",
|
"@homarr/tsconfig": "workspace:^0.1.0",
|
||||||
"eslint": "^9.39.4",
|
"eslint": "^9.39.2",
|
||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,52 +1,17 @@
|
|||||||
import type { UmamiEventData } from "@umami/node";
|
import type { UmamiEventData } from "@umami/node";
|
||||||
import { Umami } from "@umami/node";
|
import { Umami } from "@umami/node";
|
||||||
|
|
||||||
import { isProviderEnabled } from "@homarr/auth/server";
|
|
||||||
import { Stopwatch } from "@homarr/common";
|
|
||||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||||
import { count, db } from "@homarr/db";
|
import { count, db } from "@homarr/db";
|
||||||
import { isMysql, isPostgresql } from "@homarr/db/collection";
|
|
||||||
import { getServerSettingByKeyAsync } from "@homarr/db/queries";
|
import { getServerSettingByKeyAsync } from "@homarr/db/queries";
|
||||||
import {
|
import { integrations, items, users } from "@homarr/db/schema";
|
||||||
apiKeys,
|
import type { defaultServerSettings } from "@homarr/server-settings";
|
||||||
apps,
|
|
||||||
boards,
|
|
||||||
cronJobConfigurations,
|
|
||||||
groups,
|
|
||||||
iconRepositories,
|
|
||||||
icons,
|
|
||||||
integrations,
|
|
||||||
invites,
|
|
||||||
itemLayouts,
|
|
||||||
items,
|
|
||||||
layouts,
|
|
||||||
medias,
|
|
||||||
searchEngines,
|
|
||||||
sectionLayouts,
|
|
||||||
sections,
|
|
||||||
users,
|
|
||||||
} from "@homarr/db/schema";
|
|
||||||
import { env as dockerEnv } from "@homarr/docker/env";
|
|
||||||
|
|
||||||
import packageJson from "../../../package.json";
|
import { Stopwatch } from "../../common/src";
|
||||||
import { UMAMI_HOST_URL, UMAMI_WEBSITE_ID } from "./constants";
|
import { UMAMI_HOST_URL, UMAMI_WEBSITE_ID } from "./constants";
|
||||||
|
|
||||||
const logger = createLogger({ module: "analytics" });
|
const logger = createLogger({ module: "analytics" });
|
||||||
|
|
||||||
const getDatabaseType = (): "mysql" | "postgresql" | "sqlite" => {
|
|
||||||
if (isMysql()) return "mysql";
|
|
||||||
if (isPostgresql()) return "postgresql";
|
|
||||||
return "sqlite";
|
|
||||||
};
|
|
||||||
|
|
||||||
const getEnabledAuthProviders = (): string[] => {
|
|
||||||
const providers: string[] = [];
|
|
||||||
if (isProviderEnabled("credentials")) providers.push("credentials");
|
|
||||||
if (isProviderEnabled("oidc")) providers.push("oidc");
|
|
||||||
if (isProviderEnabled("ldap")) providers.push("ldap");
|
|
||||||
return providers;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const sendServerAnalyticsAsync = async () => {
|
export const sendServerAnalyticsAsync = async () => {
|
||||||
const stopWatch = new Stopwatch();
|
const stopWatch = new Stopwatch();
|
||||||
const analyticsSettings = await getServerSettingByKeyAsync(db, "analytics");
|
const analyticsSettings = await getServerSettingByKeyAsync(db, "analytics");
|
||||||
@@ -62,48 +27,67 @@ export const sendServerAnalyticsAsync = async () => {
|
|||||||
websiteId: UMAMI_WEBSITE_ID,
|
websiteId: UMAMI_WEBSITE_ID,
|
||||||
});
|
});
|
||||||
|
|
||||||
const enabledAuthProviders = getEnabledAuthProviders();
|
await sendIntegrationDataAsync(umamiInstance, analyticsSettings);
|
||||||
|
await sendWidgetDataAsync(umamiInstance, analyticsSettings);
|
||||||
|
await sendUserDataAsync(umamiInstance, analyticsSettings);
|
||||||
|
|
||||||
const analyticsData: UmamiEventData = {
|
logger.info(`Sent all analytics in ${stopWatch.getElapsedInHumanWords()}`);
|
||||||
homarrVersion: packageJson.version,
|
};
|
||||||
databaseType: getDatabaseType(),
|
|
||||||
dockerEnabled: dockerEnv.ENABLE_DOCKER ? 1 : 0,
|
|
||||||
kubernetesEnabled: dockerEnv.ENABLE_KUBERNETES ? 1 : 0,
|
|
||||||
authCredentials: enabledAuthProviders.includes("credentials") ? 1 : 0,
|
|
||||||
authOidc: enabledAuthProviders.includes("oidc") ? 1 : 0,
|
|
||||||
authLdap: enabledAuthProviders.includes("ldap") ? 1 : 0,
|
|
||||||
countUsers: await db.$count(users),
|
|
||||||
countBoards: await db.$count(boards),
|
|
||||||
countGroups: await db.$count(groups),
|
|
||||||
countApps: await db.$count(apps),
|
|
||||||
countWidgets: await db.$count(items),
|
|
||||||
countSections: await db.$count(sections),
|
|
||||||
countIntegrations: await db.$count(integrations),
|
|
||||||
countSearchEngines: await db.$count(searchEngines),
|
|
||||||
countIconRepositories: await db.$count(iconRepositories),
|
|
||||||
countIcons: await db.$count(icons),
|
|
||||||
countApiKeys: await db.$count(apiKeys),
|
|
||||||
countInvites: await db.$count(invites),
|
|
||||||
countMedias: await db.$count(medias),
|
|
||||||
countLayouts: await db.$count(layouts),
|
|
||||||
countItemLayouts: await db.$count(itemLayouts),
|
|
||||||
countSectionLayouts: await db.$count(sectionLayouts),
|
|
||||||
countCronJobConfigs: await db.$count(cronJobConfigurations),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
const sendWidgetDataAsync = async (umamiInstance: Umami, analyticsSettings: typeof defaultServerSettings.analytics) => {
|
||||||
|
if (!analyticsSettings.enableWidgetData) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const widgetCount = await db.$count(items);
|
||||||
|
|
||||||
|
const response = await umamiInstance.track("server-widget-data", {
|
||||||
|
countWidgets: widgetCount,
|
||||||
|
});
|
||||||
|
if (response.ok) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.warn("Unable to send track event data to Umami instance");
|
||||||
|
};
|
||||||
|
|
||||||
|
const sendUserDataAsync = async (umamiInstance: Umami, analyticsSettings: typeof defaultServerSettings.analytics) => {
|
||||||
|
if (!analyticsSettings.enableUserData) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const userCount = await db.$count(users);
|
||||||
|
|
||||||
|
const response = await umamiInstance.track("server-user-data", {
|
||||||
|
countUsers: userCount,
|
||||||
|
});
|
||||||
|
if (response.ok) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.warn("Unable to send track event data to Umami instance");
|
||||||
|
};
|
||||||
|
|
||||||
|
const sendIntegrationDataAsync = async (
|
||||||
|
umamiInstance: Umami,
|
||||||
|
analyticsSettings: typeof defaultServerSettings.analytics,
|
||||||
|
) => {
|
||||||
|
if (!analyticsSettings.enableIntegrationData) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const integrationKinds = await db
|
const integrationKinds = await db
|
||||||
.select({ kind: integrations.kind, count: count(integrations.id) })
|
.select({ kind: integrations.kind, count: count(integrations.id) })
|
||||||
.from(integrations)
|
.from(integrations)
|
||||||
.groupBy(integrations.kind);
|
.groupBy(integrations.kind);
|
||||||
|
|
||||||
|
const map: UmamiEventData = {};
|
||||||
|
|
||||||
integrationKinds.forEach((integrationKind) => {
|
integrationKinds.forEach((integrationKind) => {
|
||||||
analyticsData[`integration_${integrationKind.kind}`] = integrationKind.count;
|
map[integrationKind.kind] = integrationKind.count;
|
||||||
});
|
});
|
||||||
|
|
||||||
const response = await umamiInstance.track("server-analytics-v2", analyticsData);
|
const response = await umamiInstance.track("server-integration-data-kind", map);
|
||||||
if (!response.ok) {
|
if (response.ok) {
|
||||||
logger.warn("Unable to send analytics to Umami instance");
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`Sent analytics in ${stopWatch.getElapsedInHumanWords()}`);
|
logger.warn("Unable to send track event data to Umami instance");
|
||||||
};
|
};
|
||||||
+10
-10
@@ -41,15 +41,15 @@
|
|||||||
"@homarr/translation": "workspace:^0.1.0",
|
"@homarr/translation": "workspace:^0.1.0",
|
||||||
"@homarr/validation": "workspace:^0.1.0",
|
"@homarr/validation": "workspace:^0.1.0",
|
||||||
"@kubernetes/client-node": "^1.4.0",
|
"@kubernetes/client-node": "^1.4.0",
|
||||||
"@tanstack/react-query": "^5.91.2",
|
"@tanstack/react-query": "^5.90.16",
|
||||||
"@trpc/client": "^11.13.4",
|
"@trpc/client": "^11.8.1",
|
||||||
"@trpc/react-query": "^11.13.4",
|
"@trpc/react-query": "^11.8.1",
|
||||||
"@trpc/server": "^11.13.4",
|
"@trpc/server": "^11.8.1",
|
||||||
"@trpc/tanstack-react-query": "^11.13.4",
|
"@trpc/tanstack-react-query": "^11.8.1",
|
||||||
"lodash.clonedeep": "^4.5.0",
|
"lodash.clonedeep": "^4.5.0",
|
||||||
"next": "16.2.0",
|
"next": "16.1.1",
|
||||||
"react": "19.2.4",
|
"react": "19.2.3",
|
||||||
"react-dom": "19.2.4",
|
"react-dom": "19.2.3",
|
||||||
"superjson": "2.2.6",
|
"superjson": "2.2.6",
|
||||||
"trpc-to-openapi": "^3.1.0",
|
"trpc-to-openapi": "^3.1.0",
|
||||||
"zod": "^4.2.1"
|
"zod": "^4.2.1"
|
||||||
@@ -58,8 +58,8 @@
|
|||||||
"@homarr/eslint-config": "workspace:^0.2.0",
|
"@homarr/eslint-config": "workspace:^0.2.0",
|
||||||
"@homarr/prettier-config": "workspace:^0.1.0",
|
"@homarr/prettier-config": "workspace:^0.1.0",
|
||||||
"@homarr/tsconfig": "workspace:^0.1.0",
|
"@homarr/tsconfig": "workspace:^0.1.0",
|
||||||
"eslint": "^9.39.4",
|
"eslint": "^9.39.2",
|
||||||
"prettier": "^3.8.1",
|
"prettier": "^3.7.4",
|
||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+48
-26
@@ -1,32 +1,54 @@
|
|||||||
import { lazy } from "@trpc/server";
|
import { apiKeysRouter } from "./router/apiKeys";
|
||||||
|
import { appRouter as innerAppRouter } from "./router/app";
|
||||||
|
import { boardRouter } from "./router/board";
|
||||||
|
import { certificateRouter } from "./router/certificates/certificate-router";
|
||||||
|
import { cronJobsRouter } from "./router/cron-jobs";
|
||||||
|
import { dockerRouter } from "./router/docker/docker-router";
|
||||||
|
import { groupRouter } from "./router/group";
|
||||||
|
import { homeRouter } from "./router/home";
|
||||||
|
import { iconsRouter } from "./router/icons";
|
||||||
|
import { importRouter } from "./router/import/import-router";
|
||||||
|
import { infoRouter } from "./router/info";
|
||||||
|
import { integrationRouter } from "./router/integration/integration-router";
|
||||||
|
import { inviteRouter } from "./router/invite";
|
||||||
|
import { kubernetesRouter } from "./router/kubernetes/router/kubernetes-router";
|
||||||
|
import { locationRouter } from "./router/location";
|
||||||
|
import { logRouter } from "./router/log";
|
||||||
|
import { mediaRouter } from "./router/medias/media-router";
|
||||||
|
import { onboardRouter } from "./router/onboard/onboard-router";
|
||||||
|
import { searchEngineRouter } from "./router/search-engine/search-engine-router";
|
||||||
|
import { sectionRouter } from "./router/section/section-router";
|
||||||
|
import { serverSettingsRouter } from "./router/serverSettings";
|
||||||
|
import { updateCheckerRouter } from "./router/update-checker";
|
||||||
|
import { userRouter } from "./router/user";
|
||||||
|
import { widgetRouter } from "./router/widgets";
|
||||||
import { createTRPCRouter } from "./trpc";
|
import { createTRPCRouter } from "./trpc";
|
||||||
|
|
||||||
export const appRouter = createTRPCRouter({
|
export const appRouter = createTRPCRouter({
|
||||||
user: lazy(() => import("./router/user").then((mod) => mod.userRouter)),
|
user: userRouter,
|
||||||
group: lazy(() => import("./router/group").then((mod) => mod.groupRouter)),
|
group: groupRouter,
|
||||||
invite: lazy(() => import("./router/invite").then((mod) => mod.inviteRouter)),
|
invite: inviteRouter,
|
||||||
integration: lazy(() => import("./router/integration/integration-router").then((mod) => mod.integrationRouter)),
|
integration: integrationRouter,
|
||||||
board: lazy(() => import("./router/board").then((mod) => mod.boardRouter)),
|
board: boardRouter,
|
||||||
section: lazy(() => import("./router/section/section-router").then((mod) => mod.sectionRouter)),
|
section: sectionRouter,
|
||||||
app: lazy(() => import("./router/app").then((mod) => mod.appRouter)),
|
app: innerAppRouter,
|
||||||
searchEngine: lazy(() => import("./router/search-engine/search-engine-router").then((mod) => mod.searchEngineRouter)),
|
searchEngine: searchEngineRouter,
|
||||||
widget: lazy(() => import("./router/widgets").then((mod) => mod.widgetRouter)),
|
widget: widgetRouter,
|
||||||
location: lazy(() => import("./router/location").then((mod) => mod.locationRouter)),
|
location: locationRouter,
|
||||||
log: lazy(() => import("./router/log").then((mod) => mod.logRouter)),
|
log: logRouter,
|
||||||
icon: lazy(() => import("./router/icons").then((mod) => mod.iconsRouter)),
|
icon: iconsRouter,
|
||||||
import: lazy(() => import("./router/import/import-router").then((mod) => mod.importRouter)),
|
import: importRouter,
|
||||||
onboard: lazy(() => import("./router/onboard/onboard-router").then((mod) => mod.onboardRouter)),
|
onboard: onboardRouter,
|
||||||
home: lazy(() => import("./router/home").then((mod) => mod.homeRouter)),
|
home: homeRouter,
|
||||||
docker: lazy(() => import("./router/docker/docker-router").then((mod) => mod.dockerRouter)),
|
docker: dockerRouter,
|
||||||
kubernetes: lazy(() => import("./router/kubernetes/router/kubernetes-router").then((mod) => mod.kubernetesRouter)),
|
kubernetes: kubernetesRouter,
|
||||||
serverSettings: lazy(() => import("./router/serverSettings").then((mod) => mod.serverSettingsRouter)),
|
serverSettings: serverSettingsRouter,
|
||||||
cronJobs: lazy(() => import("./router/cron-jobs").then((mod) => mod.cronJobsRouter)),
|
cronJobs: cronJobsRouter,
|
||||||
apiKeys: lazy(() => import("./router/apiKeys").then((mod) => mod.apiKeysRouter)),
|
apiKeys: apiKeysRouter,
|
||||||
media: lazy(() => import("./router/medias/media-router").then((mod) => mod.mediaRouter)),
|
media: mediaRouter,
|
||||||
updateChecker: lazy(() => import("./router/update-checker").then((mod) => mod.updateCheckerRouter)),
|
updateChecker: updateCheckerRouter,
|
||||||
certificates: lazy(() => import("./router/certificates/certificate-router").then((mod) => mod.certificateRouter)),
|
certificates: certificateRouter,
|
||||||
info: lazy(() => import("./router/info").then((mod) => mod.infoRouter)),
|
info: infoRouter,
|
||||||
});
|
});
|
||||||
|
|
||||||
// export type definition of API
|
// export type definition of API
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import { TRPCError } from "@trpc/server";
|
import { TRPCError } from "@trpc/server";
|
||||||
import { z } from "zod/v4";
|
import { z } from "zod/v4";
|
||||||
|
|
||||||
import type { Session } from "@homarr/auth";
|
|
||||||
import { createId } from "@homarr/common";
|
import { createId } from "@homarr/common";
|
||||||
import type { Database, InferSelectModel } from "@homarr/db";
|
|
||||||
import { asc, eq, inArray, like } from "@homarr/db";
|
import { asc, eq, inArray, like } from "@homarr/db";
|
||||||
import { apps } from "@homarr/db/schema";
|
import { apps } from "@homarr/db/schema";
|
||||||
import { selectAppSchema } from "@homarr/db/validationSchemas";
|
import { selectAppSchema } from "@homarr/db/validationSchemas";
|
||||||
@@ -13,7 +11,7 @@ import { byIdSchema, paginatedSchema } from "@homarr/validation/common";
|
|||||||
|
|
||||||
import { convertIntersectionToZodObject } from "../schema-merger";
|
import { convertIntersectionToZodObject } from "../schema-merger";
|
||||||
import { createTRPCRouter, permissionRequiredProcedure, protectedProcedure, publicProcedure } from "../trpc";
|
import { createTRPCRouter, permissionRequiredProcedure, protectedProcedure, publicProcedure } from "../trpc";
|
||||||
import { AppAccessControl } from "./app/app-access-control";
|
import { canUserSeeAppAsync } from "./app/app-access-control";
|
||||||
|
|
||||||
const defaultIcon = "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/homarr.svg";
|
const defaultIcon = "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/homarr.svg";
|
||||||
|
|
||||||
@@ -91,8 +89,9 @@ export const appRouter = createTRPCRouter({
|
|||||||
.output(selectAppSchema)
|
.output(selectAppSchema)
|
||||||
.meta({ openapi: { method: "GET", path: "/api/apps/{id}", tags: ["apps"], protect: true } })
|
.meta({ openapi: { method: "GET", path: "/api/apps/{id}", tags: ["apps"], protect: true } })
|
||||||
.query(async ({ ctx, input }) => {
|
.query(async ({ ctx, input }) => {
|
||||||
const repository = new AppRepository(ctx.db, ctx.session?.user ?? null);
|
const app = await ctx.db.query.apps.findFirst({
|
||||||
const app = await repository.getByIdAsync(input.id);
|
where: eq(apps.id, input.id),
|
||||||
|
});
|
||||||
|
|
||||||
if (!app) {
|
if (!app) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
@@ -101,11 +100,20 @@ export const appRouter = createTRPCRouter({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const canUserSeeApp = await canUserSeeAppAsync(ctx.session?.user ?? null, app.id);
|
||||||
|
if (!canUserSeeApp) {
|
||||||
|
throw new TRPCError({
|
||||||
|
code: "NOT_FOUND",
|
||||||
|
message: "App not found",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
}),
|
}),
|
||||||
byIds: publicProcedure.input(z.array(z.string())).query(async ({ ctx, input }) => {
|
byIds: publicProcedure.input(z.array(z.string())).query(async ({ ctx, input }) => {
|
||||||
const repository = new AppRepository(ctx.db, ctx.session?.user ?? null);
|
return await ctx.db.query.apps.findMany({
|
||||||
return await repository.getByIdsAsync(input);
|
where: inArray(apps.id, input),
|
||||||
|
});
|
||||||
}),
|
}),
|
||||||
create: permissionRequiredProcedure
|
create: permissionRequiredProcedure
|
||||||
.requiresPermission("app-create")
|
.requiresPermission("app-create")
|
||||||
@@ -133,13 +141,15 @@ export const appRouter = createTRPCRouter({
|
|||||||
.output(z.void())
|
.output(z.void())
|
||||||
.mutation(async ({ ctx, input }) => {
|
.mutation(async ({ ctx, input }) => {
|
||||||
await ctx.db.insert(apps).values(
|
await ctx.db.insert(apps).values(
|
||||||
input.map((app) => ({
|
await Promise.all(
|
||||||
|
input.map(async (app) => ({
|
||||||
id: createId(),
|
id: createId(),
|
||||||
name: app.name,
|
name: app.name,
|
||||||
description: app.description,
|
description: app.description,
|
||||||
iconUrl: app.iconUrl ?? getIconForName(ctx.db, app.name).sync()?.url ?? defaultIcon,
|
iconUrl: app.iconUrl ?? (await getIconForName(ctx.db, app.name))?.url ?? defaultIcon,
|
||||||
href: app.href,
|
href: app.href,
|
||||||
})),
|
})),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
update: permissionRequiredProcedure
|
update: permissionRequiredProcedure
|
||||||
@@ -179,30 +189,3 @@ export const appRouter = createTRPCRouter({
|
|||||||
await ctx.db.delete(apps).where(eq(apps.id, input.id));
|
await ctx.db.delete(apps).where(eq(apps.id, input.id));
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
type App = InferSelectModel<typeof apps>;
|
|
||||||
|
|
||||||
export class AppRepository {
|
|
||||||
private readonly accessControl: AppAccessControl;
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private db: Database,
|
|
||||||
user: Session["user"] | null,
|
|
||||||
) {
|
|
||||||
this.accessControl = new AppAccessControl(db, user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async getByIdAsync(id: string): Promise<App | null> {
|
|
||||||
const apps = await this.getByIdsAsync([id]);
|
|
||||||
return apps[0] ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async getByIdsAsync(ids: string[]): Promise<App[]> {
|
|
||||||
const canUserSeeApps = await this.accessControl.canUserSeeAppsAsync(ids);
|
|
||||||
const dbApps = await this.db.query.apps.findMany({
|
|
||||||
where: inArray(apps.id, ids),
|
|
||||||
});
|
|
||||||
|
|
||||||
return canUserSeeApps ? dbApps : [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +1,24 @@
|
|||||||
import SuperJSON from "superjson";
|
import SuperJSON from "superjson";
|
||||||
|
|
||||||
import type { Session } from "@homarr/auth";
|
import type { Session } from "@homarr/auth";
|
||||||
import type { Database } from "@homarr/db";
|
import { db, eq, or } from "@homarr/db";
|
||||||
import { eq, or } from "@homarr/db";
|
|
||||||
import { items } from "@homarr/db/schema";
|
import { items } from "@homarr/db/schema";
|
||||||
|
|
||||||
import type { WidgetComponentProps } from "../../../../widgets/src";
|
import type { WidgetComponentProps } from "../../../../widgets/src";
|
||||||
|
|
||||||
export class AppAccessControl {
|
export const canUserSeeAppAsync = async (user: Session["user"] | null, appId: string) => {
|
||||||
constructor(
|
return await canUserSeeAppsAsync(user, [appId]);
|
||||||
private db: Database,
|
};
|
||||||
private user: Session["user"] | null,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
async canUserSeeAppAsync(appId: string) {
|
export const canUserSeeAppsAsync = async (user: Session["user"] | null, appIds: string[]) => {
|
||||||
return await this.canUserSeeAppsAsync([appId]);
|
if (user) return true;
|
||||||
}
|
|
||||||
|
|
||||||
async canUserSeeAppsAsync(appIds: string[]) {
|
const appIdsOnPublicBoards = await getAllAppIdsOnPublicBoardsAsync();
|
||||||
// Currently any user can see all apps if they are logged in
|
|
||||||
if (this.user) return true;
|
|
||||||
|
|
||||||
const appIdsOnPublicBoards = await this.getAllAppIdsOnPublicBoardsAsync();
|
|
||||||
return appIds.every((appId) => appIdsOnPublicBoards.includes(appId));
|
return appIds.every((appId) => appIdsOnPublicBoards.includes(appId));
|
||||||
}
|
};
|
||||||
|
|
||||||
private async getAllAppIdsOnPublicBoardsAsync() {
|
const getAllAppIdsOnPublicBoardsAsync = async () => {
|
||||||
const itemsWithApps = await this.db.query.items.findMany({
|
const itemsWithApps = await db.query.items.findMany({
|
||||||
where: or(eq(items.kind, "app"), eq(items.kind, "bookmarks")),
|
where: or(eq(items.kind, "app"), eq(items.kind, "bookmarks")),
|
||||||
with: {
|
with: {
|
||||||
board: {
|
board: {
|
||||||
@@ -43,10 +35,11 @@ export class AppAccessControl {
|
|||||||
if (item.kind === "app") {
|
if (item.kind === "app") {
|
||||||
const parsedOptions = SuperJSON.parse<WidgetComponentProps<"app">["options"]>(item.options);
|
const parsedOptions = SuperJSON.parse<WidgetComponentProps<"app">["options"]>(item.options);
|
||||||
return [parsedOptions.appId];
|
return [parsedOptions.appId];
|
||||||
}
|
} else if (item.kind === "bookmarks") {
|
||||||
|
|
||||||
const parsedOptions = SuperJSON.parse<WidgetComponentProps<"bookmarks">["options"]>(item.options);
|
const parsedOptions = SuperJSON.parse<WidgetComponentProps<"bookmarks">["options"]>(item.options);
|
||||||
return parsedOptions.items;
|
return parsedOptions.items;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
throw new Error("Failed to get app ids from board. Invalid item kind: 'test'");
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -6,8 +6,8 @@ import { constructBoardPermissions } from "@homarr/auth/shared";
|
|||||||
import { createId } from "@homarr/common";
|
import { createId } from "@homarr/common";
|
||||||
import type { DeviceType } from "@homarr/common/server";
|
import type { DeviceType } from "@homarr/common/server";
|
||||||
import type { Database, InferInsertModel, InferSelectModel, SQL } from "@homarr/db";
|
import type { Database, InferInsertModel, InferSelectModel, SQL } from "@homarr/db";
|
||||||
import { and, asc, eq, handleTransactionsAsync, inArray, isNull, like, not, or, sql } from "@homarr/db";
|
import { and, asc, eq, inArray, isNull, like, not, or, sql } from "@homarr/db";
|
||||||
import { createDbInsertCollectionWithoutTransaction } from "@homarr/db/collection";
|
import { createDbInsertCollection } from "@homarr/db/collection";
|
||||||
import { getServerSettingByKeyAsync } from "@homarr/db/queries";
|
import { getServerSettingByKeyAsync } from "@homarr/db/queries";
|
||||||
import {
|
import {
|
||||||
boardGroupPermissions,
|
boardGroupPermissions,
|
||||||
@@ -273,7 +273,7 @@ export const boardRouter = createTRPCRouter({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const createBoardCollection = createDbInsertCollectionWithoutTransaction(["boards", "sections", "layouts"]);
|
const createBoardCollection = createDbInsertCollection(["boards", "sections", "layouts"]);
|
||||||
|
|
||||||
createBoardCollection.boards.push({
|
createBoardCollection.boards.push({
|
||||||
id: boardId,
|
id: boardId,
|
||||||
@@ -439,10 +439,8 @@ export const boardRouter = createTRPCRouter({
|
|||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
await handleTransactionsAsync(ctx.db, {
|
await ctx.db.transaction(async (transaction) => {
|
||||||
async handleAsync(db, schema) {
|
transaction.insert(boards).values({
|
||||||
await db.transaction(async (transaction) => {
|
|
||||||
await transaction.insert(schema.boards).values({
|
|
||||||
...boardProps,
|
...boardProps,
|
||||||
id: newBoardId,
|
id: newBoardId,
|
||||||
name: input.name,
|
name: input.name,
|
||||||
@@ -450,76 +448,33 @@ export const boardRouter = createTRPCRouter({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (layoutsToInsert.length > 0) {
|
if (layoutsToInsert.length > 0) {
|
||||||
await transaction.insert(schema.layouts).values(layoutsToInsert);
|
await transaction.insert(layouts).values(layoutsToInsert);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sectionsToInsert.length > 0) {
|
if (sectionsToInsert.length > 0) {
|
||||||
await transaction.insert(schema.sections).values(sectionsToInsert);
|
await transaction.insert(sections).values(sectionsToInsert);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sectionLayoutsToInsert.length > 0) {
|
if (sectionLayoutsToInsert.length > 0) {
|
||||||
await transaction.insert(schema.sectionLayouts).values(sectionLayoutsToInsert);
|
await transaction.insert(sectionLayouts).values(sectionLayoutsToInsert);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sectionCollapseStatesToInsert.length > 0) {
|
if (sectionCollapseStatesToInsert.length > 0) {
|
||||||
await transaction.insert(schema.sectionCollapseStates).values(sectionCollapseStatesToInsert);
|
await transaction.insert(sectionCollapseStates).values(sectionCollapseStatesToInsert);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemsToInsert.length > 0) {
|
if (itemsToInsert.length > 0) {
|
||||||
await transaction.insert(schema.items).values(itemsToInsert);
|
await transaction.insert(items).values(itemsToInsert);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemLayoutsToInsert.length > 0) {
|
if (itemLayoutsToInsert.length > 0) {
|
||||||
await transaction.insert(schema.itemLayouts).values(itemLayoutsToInsert);
|
await transaction.insert(itemLayouts).values(itemLayoutsToInsert);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemIntegrationsToInsert.length > 0) {
|
if (itemIntegrationsToInsert.length > 0) {
|
||||||
await transaction.insert(schema.integrationItems).values(itemIntegrationsToInsert);
|
await transaction.insert(integrationItems).values(itemIntegrationsToInsert);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
|
||||||
handleSync(db) {
|
|
||||||
db.transaction((transaction) => {
|
|
||||||
transaction
|
|
||||||
.insert(boards)
|
|
||||||
.values({
|
|
||||||
...boardProps,
|
|
||||||
id: newBoardId,
|
|
||||||
name: input.name,
|
|
||||||
creatorId: ctx.session.user.id,
|
|
||||||
})
|
|
||||||
.run();
|
|
||||||
|
|
||||||
if (layoutsToInsert.length > 0) {
|
|
||||||
transaction.insert(layouts).values(layoutsToInsert).run();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sectionsToInsert.length > 0) {
|
|
||||||
transaction.insert(sections).values(sectionsToInsert).run();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sectionLayoutsToInsert.length > 0) {
|
|
||||||
transaction.insert(sectionLayouts).values(sectionLayoutsToInsert).run();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sectionCollapseStatesToInsert.length > 0) {
|
|
||||||
transaction.insert(sectionCollapseStates).values(sectionCollapseStatesToInsert).run();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (itemsToInsert.length > 0) {
|
|
||||||
transaction.insert(items).values(itemsToInsert).run();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (itemLayoutsToInsert.length > 0) {
|
|
||||||
transaction.insert(itemLayouts).values(itemLayoutsToInsert).run();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (itemIntegrationsToInsert.length > 0) {
|
|
||||||
transaction.insert(integrationItems).values(itemIntegrationsToInsert).run();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}),
|
}),
|
||||||
renameBoard: protectedProcedure.input(boardRenameSchema).mutation(async ({ ctx, input }) => {
|
renameBoard: protectedProcedure.input(boardRenameSchema).mutation(async ({ ctx, input }) => {
|
||||||
await throwIfActionForbiddenAsync(ctx, eq(boards.id, input.id), "full");
|
await throwIfActionForbiddenAsync(ctx, eq(boards.id, input.id), "full");
|
||||||
@@ -756,13 +711,11 @@ export const boardRouter = createTRPCRouter({
|
|||||||
|
|
||||||
const dbBoard = await getFullBoardWithWhereAsync(ctx.db, eq(boards.id, input.id), ctx.session.user.id);
|
const dbBoard = await getFullBoardWithWhereAsync(ctx.db, eq(boards.id, input.id), ctx.session.user.id);
|
||||||
|
|
||||||
await handleTransactionsAsync(ctx.db, {
|
await ctx.db.transaction(async (transaction) => {
|
||||||
async handleAsync(db, schema) {
|
|
||||||
await db.transaction(async (transaction) => {
|
|
||||||
const addedSections = filterAddedItems(input.sections, dbBoard.sections);
|
const addedSections = filterAddedItems(input.sections, dbBoard.sections);
|
||||||
|
|
||||||
if (addedSections.length > 0) {
|
if (addedSections.length > 0) {
|
||||||
await transaction.insert(schema.sections).values(
|
await transaction.insert(sections).values(
|
||||||
addedSections.map((section) => ({
|
addedSections.map((section) => ({
|
||||||
id: section.id,
|
id: section.id,
|
||||||
kind: section.kind,
|
kind: section.kind,
|
||||||
@@ -775,210 +728,7 @@ export const boardRouter = createTRPCRouter({
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (addedSections.some((section) => section.kind === "dynamic")) {
|
if (addedSections.some((section) => section.kind === "dynamic")) {
|
||||||
await transaction.insert(schema.sectionLayouts).values(
|
await transaction.insert(sectionLayouts).values(
|
||||||
addedSections
|
|
||||||
.filter((section) => section.kind === "dynamic")
|
|
||||||
.flatMap((section) =>
|
|
||||||
section.layouts.map(
|
|
||||||
(sectionLayout): InferInsertModel<typeof schema.sectionLayouts> => ({
|
|
||||||
layoutId: sectionLayout.layoutId,
|
|
||||||
sectionId: section.id,
|
|
||||||
parentSectionId: sectionLayout.parentSectionId,
|
|
||||||
height: sectionLayout.height,
|
|
||||||
width: sectionLayout.width,
|
|
||||||
xOffset: sectionLayout.xOffset,
|
|
||||||
yOffset: sectionLayout.yOffset,
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const addedItems = filterAddedItems(input.items, dbBoard.items);
|
|
||||||
|
|
||||||
if (addedItems.length > 0) {
|
|
||||||
await transaction.insert(schema.items).values(
|
|
||||||
addedItems.map((item) => ({
|
|
||||||
id: item.id,
|
|
||||||
kind: item.kind,
|
|
||||||
options: superjson.stringify(item.options),
|
|
||||||
advancedOptions: superjson.stringify(item.advancedOptions),
|
|
||||||
boardId: dbBoard.id,
|
|
||||||
})),
|
|
||||||
);
|
|
||||||
await transaction.insert(schema.itemLayouts).values(
|
|
||||||
addedItems.flatMap((item) =>
|
|
||||||
item.layouts.map(
|
|
||||||
(layoutSection): InferInsertModel<typeof schema.itemLayouts> => ({
|
|
||||||
layoutId: layoutSection.layoutId,
|
|
||||||
sectionId: layoutSection.sectionId,
|
|
||||||
itemId: item.id,
|
|
||||||
height: layoutSection.height,
|
|
||||||
width: layoutSection.width,
|
|
||||||
xOffset: layoutSection.xOffset,
|
|
||||||
yOffset: layoutSection.yOffset,
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const inputIntegrationRelations = input.items.flatMap(({ integrationIds, id: itemId }) =>
|
|
||||||
integrationIds.map((integrationId) => ({
|
|
||||||
integrationId,
|
|
||||||
itemId,
|
|
||||||
})),
|
|
||||||
);
|
|
||||||
const dbIntegrationRelations = dbBoard.items.flatMap(({ integrationIds, id: itemId }) =>
|
|
||||||
integrationIds.map((integrationId) => ({
|
|
||||||
integrationId,
|
|
||||||
itemId,
|
|
||||||
})),
|
|
||||||
);
|
|
||||||
const addedIntegrationRelations = inputIntegrationRelations.filter(
|
|
||||||
(inputRelation) =>
|
|
||||||
!dbIntegrationRelations.some(
|
|
||||||
(dbRelation) =>
|
|
||||||
dbRelation.itemId === inputRelation.itemId &&
|
|
||||||
dbRelation.integrationId === inputRelation.integrationId,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (addedIntegrationRelations.length > 0) {
|
|
||||||
await transaction.insert(schema.integrationItems).values(
|
|
||||||
addedIntegrationRelations.map((relation) => ({
|
|
||||||
itemId: relation.itemId,
|
|
||||||
integrationId: relation.integrationId,
|
|
||||||
})),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const updatedItems = filterUpdatedItems(input.items, dbBoard.items);
|
|
||||||
|
|
||||||
for (const item of updatedItems) {
|
|
||||||
await transaction
|
|
||||||
.update(schema.items)
|
|
||||||
.set({
|
|
||||||
kind: item.kind,
|
|
||||||
options: superjson.stringify(item.options),
|
|
||||||
advancedOptions: superjson.stringify(item.advancedOptions),
|
|
||||||
})
|
|
||||||
.where(eq(schema.items.id, item.id));
|
|
||||||
|
|
||||||
for (const itemSectionLayout of item.layouts) {
|
|
||||||
await transaction
|
|
||||||
.update(schema.itemLayouts)
|
|
||||||
.set({
|
|
||||||
height: itemSectionLayout.height,
|
|
||||||
width: itemSectionLayout.width,
|
|
||||||
xOffset: itemSectionLayout.xOffset,
|
|
||||||
yOffset: itemSectionLayout.yOffset,
|
|
||||||
sectionId: itemSectionLayout.sectionId,
|
|
||||||
})
|
|
||||||
.where(
|
|
||||||
and(
|
|
||||||
eq(schema.itemLayouts.itemId, item.id),
|
|
||||||
eq(schema.itemLayouts.layoutId, itemSectionLayout.layoutId),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const updatedSections = filterUpdatedItems(input.sections, dbBoard.sections);
|
|
||||||
|
|
||||||
for (const section of updatedSections) {
|
|
||||||
const prev = dbBoard.sections.find((dbSection) => dbSection.id === section.id);
|
|
||||||
await transaction
|
|
||||||
.update(schema.sections)
|
|
||||||
.set({
|
|
||||||
yOffset: prev?.kind !== "dynamic" && "yOffset" in section ? section.yOffset : null,
|
|
||||||
xOffset: prev?.kind !== "dynamic" && "yOffset" in section ? 0 : null,
|
|
||||||
options: section.kind === "dynamic" ? superjson.stringify(section.options) : emptySuperJSON,
|
|
||||||
name: prev?.kind === "category" && "name" in section ? section.name : null,
|
|
||||||
})
|
|
||||||
.where(eq(schema.sections.id, section.id));
|
|
||||||
|
|
||||||
if (section.kind !== "dynamic") continue;
|
|
||||||
|
|
||||||
for (const sectionLayout of section.layouts) {
|
|
||||||
await transaction
|
|
||||||
.update(schema.sectionLayouts)
|
|
||||||
.set({
|
|
||||||
height: sectionLayout.height,
|
|
||||||
width: sectionLayout.width,
|
|
||||||
xOffset: sectionLayout.xOffset,
|
|
||||||
yOffset: sectionLayout.yOffset,
|
|
||||||
parentSectionId: sectionLayout.parentSectionId,
|
|
||||||
})
|
|
||||||
.where(
|
|
||||||
and(
|
|
||||||
eq(schema.sectionLayouts.sectionId, section.id),
|
|
||||||
eq(schema.sectionLayouts.layoutId, sectionLayout.layoutId),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const removedIntegrationRelations = dbIntegrationRelations.filter(
|
|
||||||
(dbRelation) =>
|
|
||||||
!inputIntegrationRelations.some(
|
|
||||||
(inputRelation) =>
|
|
||||||
dbRelation.itemId === inputRelation.itemId &&
|
|
||||||
dbRelation.integrationId === inputRelation.integrationId,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
for (const relation of removedIntegrationRelations) {
|
|
||||||
await transaction
|
|
||||||
.delete(schema.integrationItems)
|
|
||||||
.where(
|
|
||||||
and(
|
|
||||||
eq(integrationItems.itemId, relation.itemId),
|
|
||||||
eq(integrationItems.integrationId, relation.integrationId),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const removedItems = filterRemovedItems(input.items, dbBoard.items);
|
|
||||||
|
|
||||||
const itemIds = removedItems.map((item) => item.id);
|
|
||||||
if (itemIds.length > 0) {
|
|
||||||
await transaction.delete(schema.items).where(inArray(schema.items.id, itemIds));
|
|
||||||
}
|
|
||||||
|
|
||||||
const removedSections = filterRemovedItems(input.sections, dbBoard.sections);
|
|
||||||
const sectionIds = removedSections.map((section) => section.id);
|
|
||||||
|
|
||||||
if (sectionIds.length > 0) {
|
|
||||||
await transaction.delete(schema.sections).where(inArray(schema.sections.id, sectionIds));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
handleSync(db) {
|
|
||||||
db.transaction((transaction) => {
|
|
||||||
const addedSections = filterAddedItems(input.sections, dbBoard.sections);
|
|
||||||
|
|
||||||
if (addedSections.length > 0) {
|
|
||||||
transaction
|
|
||||||
.insert(sections)
|
|
||||||
.values(
|
|
||||||
addedSections.map((section) => ({
|
|
||||||
id: section.id,
|
|
||||||
kind: section.kind,
|
|
||||||
yOffset: section.kind !== "dynamic" ? section.yOffset : null,
|
|
||||||
xOffset: section.kind === "dynamic" ? null : 0,
|
|
||||||
options: section.kind === "dynamic" ? superjson.stringify(section.options) : emptySuperJSON,
|
|
||||||
name: "name" in section ? section.name : null,
|
|
||||||
boardId: dbBoard.id,
|
|
||||||
})),
|
|
||||||
)
|
|
||||||
.run();
|
|
||||||
|
|
||||||
if (addedSections.some((section) => section.kind === "dynamic")) {
|
|
||||||
transaction
|
|
||||||
.insert(sectionLayouts)
|
|
||||||
.values(
|
|
||||||
addedSections
|
addedSections
|
||||||
.filter((section) => section.kind === "dynamic")
|
.filter((section) => section.kind === "dynamic")
|
||||||
.flatMap((section) =>
|
.flatMap((section) =>
|
||||||
@@ -994,17 +744,14 @@ export const boardRouter = createTRPCRouter({
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
);
|
||||||
.run();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const addedItems = filterAddedItems(input.items, dbBoard.items);
|
const addedItems = filterAddedItems(input.items, dbBoard.items);
|
||||||
|
|
||||||
if (addedItems.length > 0) {
|
if (addedItems.length > 0) {
|
||||||
transaction
|
await transaction.insert(items).values(
|
||||||
.insert(items)
|
|
||||||
.values(
|
|
||||||
addedItems.map((item) => ({
|
addedItems.map((item) => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
kind: item.kind,
|
kind: item.kind,
|
||||||
@@ -1012,11 +759,8 @@ export const boardRouter = createTRPCRouter({
|
|||||||
advancedOptions: superjson.stringify(item.advancedOptions),
|
advancedOptions: superjson.stringify(item.advancedOptions),
|
||||||
boardId: dbBoard.id,
|
boardId: dbBoard.id,
|
||||||
})),
|
})),
|
||||||
)
|
);
|
||||||
.run();
|
await transaction.insert(itemLayouts).values(
|
||||||
transaction
|
|
||||||
.insert(itemLayouts)
|
|
||||||
.values(
|
|
||||||
addedItems.flatMap((item) =>
|
addedItems.flatMap((item) =>
|
||||||
item.layouts.map(
|
item.layouts.map(
|
||||||
(layoutSection): InferInsertModel<typeof itemLayouts> => ({
|
(layoutSection): InferInsertModel<typeof itemLayouts> => ({
|
||||||
@@ -1030,8 +774,7 @@ export const boardRouter = createTRPCRouter({
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
);
|
||||||
.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const inputIntegrationRelations = input.items.flatMap(({ integrationIds, id: itemId }) =>
|
const inputIntegrationRelations = input.items.flatMap(({ integrationIds, id: itemId }) =>
|
||||||
@@ -1050,38 +793,33 @@ export const boardRouter = createTRPCRouter({
|
|||||||
(inputRelation) =>
|
(inputRelation) =>
|
||||||
!dbIntegrationRelations.some(
|
!dbIntegrationRelations.some(
|
||||||
(dbRelation) =>
|
(dbRelation) =>
|
||||||
dbRelation.itemId === inputRelation.itemId &&
|
dbRelation.itemId === inputRelation.itemId && dbRelation.integrationId === inputRelation.integrationId,
|
||||||
dbRelation.integrationId === inputRelation.integrationId,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (addedIntegrationRelations.length > 0) {
|
if (addedIntegrationRelations.length > 0) {
|
||||||
transaction
|
await transaction.insert(integrationItems).values(
|
||||||
.insert(integrationItems)
|
|
||||||
.values(
|
|
||||||
addedIntegrationRelations.map((relation) => ({
|
addedIntegrationRelations.map((relation) => ({
|
||||||
itemId: relation.itemId,
|
itemId: relation.itemId,
|
||||||
integrationId: relation.integrationId,
|
integrationId: relation.integrationId,
|
||||||
})),
|
})),
|
||||||
)
|
);
|
||||||
.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatedItems = filterUpdatedItems(input.items, dbBoard.items);
|
const updatedItems = filterUpdatedItems(input.items, dbBoard.items);
|
||||||
|
|
||||||
for (const item of updatedItems) {
|
for (const item of updatedItems) {
|
||||||
transaction
|
await transaction
|
||||||
.update(items)
|
.update(items)
|
||||||
.set({
|
.set({
|
||||||
kind: item.kind,
|
kind: item.kind,
|
||||||
options: superjson.stringify(item.options),
|
options: superjson.stringify(item.options),
|
||||||
advancedOptions: superjson.stringify(item.advancedOptions),
|
advancedOptions: superjson.stringify(item.advancedOptions),
|
||||||
})
|
})
|
||||||
.where(eq(items.id, item.id))
|
.where(eq(items.id, item.id));
|
||||||
.run();
|
|
||||||
|
|
||||||
for (const itemSectionLayout of item.layouts) {
|
for (const itemSectionLayout of item.layouts) {
|
||||||
transaction
|
await transaction
|
||||||
.update(itemLayouts)
|
.update(itemLayouts)
|
||||||
.set({
|
.set({
|
||||||
height: itemSectionLayout.height,
|
height: itemSectionLayout.height,
|
||||||
@@ -1090,8 +828,7 @@ export const boardRouter = createTRPCRouter({
|
|||||||
yOffset: itemSectionLayout.yOffset,
|
yOffset: itemSectionLayout.yOffset,
|
||||||
sectionId: itemSectionLayout.sectionId,
|
sectionId: itemSectionLayout.sectionId,
|
||||||
})
|
})
|
||||||
.where(and(eq(itemLayouts.itemId, item.id), eq(itemLayouts.layoutId, itemSectionLayout.layoutId)))
|
.where(and(eq(itemLayouts.itemId, item.id), eq(itemLayouts.layoutId, itemSectionLayout.layoutId)));
|
||||||
.run();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1099,7 +836,7 @@ export const boardRouter = createTRPCRouter({
|
|||||||
|
|
||||||
for (const section of updatedSections) {
|
for (const section of updatedSections) {
|
||||||
const prev = dbBoard.sections.find((dbSection) => dbSection.id === section.id);
|
const prev = dbBoard.sections.find((dbSection) => dbSection.id === section.id);
|
||||||
transaction
|
await transaction
|
||||||
.update(sections)
|
.update(sections)
|
||||||
.set({
|
.set({
|
||||||
yOffset: prev?.kind !== "dynamic" && "yOffset" in section ? section.yOffset : null,
|
yOffset: prev?.kind !== "dynamic" && "yOffset" in section ? section.yOffset : null,
|
||||||
@@ -1107,13 +844,12 @@ export const boardRouter = createTRPCRouter({
|
|||||||
options: section.kind === "dynamic" ? superjson.stringify(section.options) : emptySuperJSON,
|
options: section.kind === "dynamic" ? superjson.stringify(section.options) : emptySuperJSON,
|
||||||
name: prev?.kind === "category" && "name" in section ? section.name : null,
|
name: prev?.kind === "category" && "name" in section ? section.name : null,
|
||||||
})
|
})
|
||||||
.where(eq(sections.id, section.id))
|
.where(eq(sections.id, section.id));
|
||||||
.run();
|
|
||||||
|
|
||||||
if (section.kind !== "dynamic") continue;
|
if (section.kind !== "dynamic") continue;
|
||||||
|
|
||||||
for (const sectionLayout of section.layouts) {
|
for (const sectionLayout of section.layouts) {
|
||||||
transaction
|
await transaction
|
||||||
.update(sectionLayouts)
|
.update(sectionLayouts)
|
||||||
.set({
|
.set({
|
||||||
height: sectionLayout.height,
|
height: sectionLayout.height,
|
||||||
@@ -1122,10 +858,7 @@ export const boardRouter = createTRPCRouter({
|
|||||||
yOffset: sectionLayout.yOffset,
|
yOffset: sectionLayout.yOffset,
|
||||||
parentSectionId: sectionLayout.parentSectionId,
|
parentSectionId: sectionLayout.parentSectionId,
|
||||||
})
|
})
|
||||||
.where(
|
.where(and(eq(sectionLayouts.sectionId, section.id), eq(sectionLayouts.layoutId, sectionLayout.layoutId)));
|
||||||
and(eq(sectionLayouts.sectionId, section.id), eq(sectionLayouts.layoutId, sectionLayout.layoutId)),
|
|
||||||
)
|
|
||||||
.run();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1133,39 +866,35 @@ export const boardRouter = createTRPCRouter({
|
|||||||
(dbRelation) =>
|
(dbRelation) =>
|
||||||
!inputIntegrationRelations.some(
|
!inputIntegrationRelations.some(
|
||||||
(inputRelation) =>
|
(inputRelation) =>
|
||||||
dbRelation.itemId === inputRelation.itemId &&
|
dbRelation.itemId === inputRelation.itemId && dbRelation.integrationId === inputRelation.integrationId,
|
||||||
dbRelation.integrationId === inputRelation.integrationId,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const relation of removedIntegrationRelations) {
|
for (const relation of removedIntegrationRelations) {
|
||||||
transaction
|
await transaction
|
||||||
.delete(integrationItems)
|
.delete(integrationItems)
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
eq(integrationItems.itemId, relation.itemId),
|
eq(integrationItems.itemId, relation.itemId),
|
||||||
eq(integrationItems.integrationId, relation.integrationId),
|
eq(integrationItems.integrationId, relation.integrationId),
|
||||||
),
|
),
|
||||||
)
|
);
|
||||||
.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const removedItems = filterRemovedItems(input.items, dbBoard.items);
|
const removedItems = filterRemovedItems(input.items, dbBoard.items);
|
||||||
|
|
||||||
const itemIds = removedItems.map((item) => item.id);
|
const itemIds = removedItems.map((item) => item.id);
|
||||||
if (itemIds.length > 0) {
|
if (itemIds.length > 0) {
|
||||||
transaction.delete(items).where(inArray(items.id, itemIds)).run();
|
await transaction.delete(items).where(inArray(items.id, itemIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
const removedSections = filterRemovedItems(input.sections, dbBoard.sections);
|
const removedSections = filterRemovedItems(input.sections, dbBoard.sections);
|
||||||
const sectionIds = removedSections.map((section) => section.id);
|
const sectionIds = removedSections.map((section) => section.id);
|
||||||
|
|
||||||
if (sectionIds.length > 0) {
|
if (sectionIds.length > 0) {
|
||||||
transaction.delete(sections).where(inArray(sections.id, sectionIds)).run();
|
await transaction.delete(sections).where(inArray(sections.id, sectionIds));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
|
||||||
});
|
|
||||||
}),
|
}),
|
||||||
getBoardPermissions: protectedProcedure.input(byIdSchema).query(async ({ input, ctx }) => {
|
getBoardPermissions: protectedProcedure.input(byIdSchema).query(async ({ input, ctx }) => {
|
||||||
await throwIfActionForbiddenAsync(ctx, eq(boards.id, input.id), "full");
|
await throwIfActionForbiddenAsync(ctx, eq(boards.id, input.id), "full");
|
||||||
@@ -1242,14 +971,12 @@ export const boardRouter = createTRPCRouter({
|
|||||||
saveUserBoardPermissions: protectedProcedure.input(boardSavePermissionsSchema).mutation(async ({ input, ctx }) => {
|
saveUserBoardPermissions: protectedProcedure.input(boardSavePermissionsSchema).mutation(async ({ input, ctx }) => {
|
||||||
await throwIfActionForbiddenAsync(ctx, eq(boards.id, input.entityId), "full");
|
await throwIfActionForbiddenAsync(ctx, eq(boards.id, input.entityId), "full");
|
||||||
|
|
||||||
await handleTransactionsAsync(ctx.db, {
|
await ctx.db.transaction(async (transaction) => {
|
||||||
async handleAsync(db, schema) {
|
await transaction.delete(boardUserPermissions).where(eq(boardUserPermissions.boardId, input.entityId));
|
||||||
await db.transaction(async (transaction) => {
|
|
||||||
await transaction.delete(schema.boardUserPermissions).where(eq(boardUserPermissions.boardId, input.entityId));
|
|
||||||
if (input.permissions.length === 0) {
|
if (input.permissions.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await transaction.insert(schema.boardUserPermissions).values(
|
await transaction.insert(boardUserPermissions).values(
|
||||||
input.permissions.map((permission) => ({
|
input.permissions.map((permission) => ({
|
||||||
userId: permission.principalId,
|
userId: permission.principalId,
|
||||||
permission: permission.permission,
|
permission: permission.permission,
|
||||||
@@ -1257,40 +984,16 @@ export const boardRouter = createTRPCRouter({
|
|||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
},
|
|
||||||
handleSync(db) {
|
|
||||||
db.transaction((transaction) => {
|
|
||||||
transaction.delete(boardUserPermissions).where(eq(boardUserPermissions.boardId, input.entityId)).run();
|
|
||||||
if (input.permissions.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
transaction
|
|
||||||
.insert(boardUserPermissions)
|
|
||||||
.values(
|
|
||||||
input.permissions.map((permission) => ({
|
|
||||||
userId: permission.principalId,
|
|
||||||
permission: permission.permission,
|
|
||||||
boardId: input.entityId,
|
|
||||||
})),
|
|
||||||
)
|
|
||||||
.run();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}),
|
}),
|
||||||
saveGroupBoardPermissions: protectedProcedure.input(boardSavePermissionsSchema).mutation(async ({ input, ctx }) => {
|
saveGroupBoardPermissions: protectedProcedure.input(boardSavePermissionsSchema).mutation(async ({ input, ctx }) => {
|
||||||
await throwIfActionForbiddenAsync(ctx, eq(boards.id, input.entityId), "full");
|
await throwIfActionForbiddenAsync(ctx, eq(boards.id, input.entityId), "full");
|
||||||
|
|
||||||
await handleTransactionsAsync(ctx.db, {
|
await ctx.db.transaction(async (transaction) => {
|
||||||
async handleAsync(db, schema) {
|
await transaction.delete(boardGroupPermissions).where(eq(boardGroupPermissions.boardId, input.entityId));
|
||||||
await db.transaction(async (transaction) => {
|
|
||||||
await transaction
|
|
||||||
.delete(schema.boardGroupPermissions)
|
|
||||||
.where(eq(boardGroupPermissions.boardId, input.entityId));
|
|
||||||
if (input.permissions.length === 0) {
|
if (input.permissions.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await transaction.insert(schema.boardGroupPermissions).values(
|
await transaction.insert(boardGroupPermissions).values(
|
||||||
input.permissions.map((permission) => ({
|
input.permissions.map((permission) => ({
|
||||||
groupId: permission.principalId,
|
groupId: permission.principalId,
|
||||||
permission: permission.permission,
|
permission: permission.permission,
|
||||||
@@ -1298,26 +1001,6 @@ export const boardRouter = createTRPCRouter({
|
|||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
},
|
|
||||||
handleSync(db) {
|
|
||||||
db.transaction((transaction) => {
|
|
||||||
transaction.delete(boardGroupPermissions).where(eq(boardGroupPermissions.boardId, input.entityId)).run();
|
|
||||||
if (input.permissions.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
transaction
|
|
||||||
.insert(boardGroupPermissions)
|
|
||||||
.values(
|
|
||||||
input.permissions.map((permission) => ({
|
|
||||||
groupId: permission.principalId,
|
|
||||||
permission: permission.permission,
|
|
||||||
boardId: input.entityId,
|
|
||||||
})),
|
|
||||||
)
|
|
||||||
.run();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}),
|
}),
|
||||||
importOldmarrConfig: permissionRequiredProcedure
|
importOldmarrConfig: permissionRequiredProcedure
|
||||||
.requiresPermission("board-create")
|
.requiresPermission("board-create")
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ export const certificateRouter = createTRPCRouter({
|
|||||||
hostname: input.hostname,
|
hostname: input.hostname,
|
||||||
thumbprint: input.thumbprint,
|
thumbprint: input.thumbprint,
|
||||||
});
|
});
|
||||||
const dbResult = await ctx.db
|
await ctx.db
|
||||||
.delete(trustedCertificateHostnames)
|
.delete(trustedCertificateHostnames)
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
@@ -103,7 +103,6 @@ export const certificateRouter = createTRPCRouter({
|
|||||||
logger.info("Removed trusted hostname", {
|
logger.info("Removed trusted hostname", {
|
||||||
hostname: input.hostname,
|
hostname: input.hostname,
|
||||||
thumbprint: input.thumbprint,
|
thumbprint: input.thumbprint,
|
||||||
count: dbResult.changes,
|
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
removeCertificate: permissionRequiredProcedure
|
removeCertificate: permissionRequiredProcedure
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import z from "zod/v4";
|
|||||||
|
|
||||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||||
import { cronExpressionSchema, jobGroupKeys, jobNameSchema } from "@homarr/cron-job-api";
|
import { cronExpressionSchema, jobGroupKeys, jobNameSchema } from "@homarr/cron-job-api";
|
||||||
|
import { cronJobApi } from "@homarr/cron-job-api/client";
|
||||||
import type { TaskStatus } from "@homarr/cron-job-status";
|
import type { TaskStatus } from "@homarr/cron-job-status";
|
||||||
import { createCronJobStatusChannel } from "@homarr/cron-job-status";
|
import { createCronJobStatusChannel } from "@homarr/cron-job-status";
|
||||||
|
|
||||||
@@ -14,20 +15,20 @@ export const cronJobsRouter = createTRPCRouter({
|
|||||||
triggerJob: permissionRequiredProcedure
|
triggerJob: permissionRequiredProcedure
|
||||||
.requiresPermission("admin")
|
.requiresPermission("admin")
|
||||||
.input(jobNameSchema)
|
.input(jobNameSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input }) => {
|
||||||
await ctx.jobManager.triggerAsync(input);
|
await cronJobApi.trigger.mutate(input);
|
||||||
}),
|
}),
|
||||||
startJob: permissionRequiredProcedure
|
startJob: permissionRequiredProcedure
|
||||||
.requiresPermission("admin")
|
.requiresPermission("admin")
|
||||||
.input(jobNameSchema)
|
.input(jobNameSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input }) => {
|
||||||
await ctx.jobManager.startAsync(input);
|
await cronJobApi.start.mutate(input);
|
||||||
}),
|
}),
|
||||||
stopJob: permissionRequiredProcedure
|
stopJob: permissionRequiredProcedure
|
||||||
.requiresPermission("admin")
|
.requiresPermission("admin")
|
||||||
.input(jobNameSchema)
|
.input(jobNameSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input }) => {
|
||||||
await ctx.jobManager.stopAsync(input);
|
await cronJobApi.stop.mutate(input);
|
||||||
}),
|
}),
|
||||||
updateJobInterval: permissionRequiredProcedure
|
updateJobInterval: permissionRequiredProcedure
|
||||||
.requiresPermission("admin")
|
.requiresPermission("admin")
|
||||||
@@ -37,23 +38,23 @@ export const cronJobsRouter = createTRPCRouter({
|
|||||||
cron: cronExpressionSchema,
|
cron: cronExpressionSchema,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input }) => {
|
||||||
await ctx.jobManager.updateIntervalAsync(input.name, input.cron);
|
await cronJobApi.updateInterval.mutate(input);
|
||||||
}),
|
}),
|
||||||
disableJob: permissionRequiredProcedure
|
disableJob: permissionRequiredProcedure
|
||||||
.requiresPermission("admin")
|
.requiresPermission("admin")
|
||||||
.input(jobNameSchema)
|
.input(jobNameSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input }) => {
|
||||||
await ctx.jobManager.disableAsync(input);
|
await cronJobApi.disable.mutate(input);
|
||||||
}),
|
}),
|
||||||
enableJob: permissionRequiredProcedure
|
enableJob: permissionRequiredProcedure
|
||||||
.requiresPermission("admin")
|
.requiresPermission("admin")
|
||||||
.input(jobNameSchema)
|
.input(jobNameSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input }) => {
|
||||||
await ctx.jobManager.enableAsync(input);
|
await cronJobApi.enable.mutate(input);
|
||||||
}),
|
}),
|
||||||
getJobs: permissionRequiredProcedure.requiresPermission("admin").query(async ({ ctx }) => {
|
getJobs: permissionRequiredProcedure.requiresPermission("admin").query(async () => {
|
||||||
return await ctx.jobManager.getAllAsync();
|
return await cronJobApi.getAll.query();
|
||||||
}),
|
}),
|
||||||
subscribeToStatusUpdates: permissionRequiredProcedure.requiresPermission("admin").subscription(() => {
|
subscribeToStatusUpdates: permissionRequiredProcedure.requiresPermission("admin").subscription(() => {
|
||||||
return observable<TaskStatus>((emit) => {
|
return observable<TaskStatus>((emit) => {
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
import { TRPCError } from "@trpc/server";
|
|
||||||
import { z } from "zod/v4";
|
|
||||||
|
|
||||||
import { createTRPCRouter, protectedProcedure } from "../trpc";
|
|
||||||
import type { JobGroupKeys } from "@homarr/cron-jobs";
|
|
||||||
import { jobGroup } from "@homarr/cron-jobs";
|
|
||||||
import { cronExpressionSchema } from "@homarr/cron-job-api";
|
|
||||||
|
|
||||||
const jobNameSchema = z.enum(jobGroup.getKeys());
|
|
||||||
|
|
||||||
export const cronJobsRouter = createTRPCRouter({
|
|
||||||
start: protectedProcedure
|
|
||||||
.meta({ requiredPermission: "admin" })
|
|
||||||
.input(jobNameSchema)
|
|
||||||
.mutation(async ({ input, ctx }) => {
|
|
||||||
// Use the job manager from context
|
|
||||||
await ctx.jobManager.startAsync(input);
|
|
||||||
}),
|
|
||||||
trigger: protectedProcedure
|
|
||||||
.meta({ requiredPermission: "admin" })
|
|
||||||
.input(jobNameSchema)
|
|
||||||
.mutation(async ({ input, ctx }) => {
|
|
||||||
await ctx.jobManager.triggerAsync(input);
|
|
||||||
}),
|
|
||||||
stop: protectedProcedure
|
|
||||||
.meta({ requiredPermission: "admin" })
|
|
||||||
.input(jobNameSchema)
|
|
||||||
.mutation(async ({ input, ctx }) => {
|
|
||||||
await ctx.jobManager.stopAsync(input);
|
|
||||||
}),
|
|
||||||
updateInterval: protectedProcedure
|
|
||||||
.meta({ requiredPermission: "admin" })
|
|
||||||
.input(
|
|
||||||
z.object({
|
|
||||||
name: jobNameSchema,
|
|
||||||
cron: cronExpressionSchema,
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.mutation(async ({ input, ctx }) => {
|
|
||||||
await ctx.jobManager.updateIntervalAsync(input.name, input.cron);
|
|
||||||
}),
|
|
||||||
disable: protectedProcedure
|
|
||||||
.meta({ requiredPermission: "admin" })
|
|
||||||
.input(jobNameSchema)
|
|
||||||
.mutation(async ({ input, ctx }) => {
|
|
||||||
await ctx.jobManager.disableAsync(input);
|
|
||||||
}),
|
|
||||||
enable: protectedProcedure
|
|
||||||
.meta({ requiredPermission: "admin" })
|
|
||||||
.input(jobNameSchema)
|
|
||||||
.mutation(async ({ input, ctx }) => {
|
|
||||||
await ctx.jobManager.enableAsync(input);
|
|
||||||
}),
|
|
||||||
getAll: protectedProcedure
|
|
||||||
.meta({ requiredPermission: "admin" })
|
|
||||||
.query(async ({ ctx }) => {
|
|
||||||
return ctx.jobManager.getAllAsync();
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
@@ -3,7 +3,7 @@ import { z } from "zod/v4";
|
|||||||
|
|
||||||
import { createId } from "@homarr/common";
|
import { createId } from "@homarr/common";
|
||||||
import type { Database } from "@homarr/db";
|
import type { Database } from "@homarr/db";
|
||||||
import { and, eq, handleTransactionsAsync, like, not } from "@homarr/db";
|
import { and, eq, like, not } from "@homarr/db";
|
||||||
import { getMaxGroupPositionAsync } from "@homarr/db/queries";
|
import { getMaxGroupPositionAsync } from "@homarr/db/queries";
|
||||||
import { groupMembers, groupPermissions, groups } from "@homarr/db/schema";
|
import { groupMembers, groupPermissions, groups } from "@homarr/db/schema";
|
||||||
import { everyoneGroup } from "@homarr/definitions";
|
import { everyoneGroup } from "@homarr/definitions";
|
||||||
@@ -252,22 +252,11 @@ export const groupRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const positions = input.positions.map((id, index) => ({ id, position: index + 1 }));
|
const positions = input.positions.map((id, index) => ({ id, position: index + 1 }));
|
||||||
|
|
||||||
await handleTransactionsAsync(ctx.db, {
|
await ctx.db.transaction(async (trx) => {
|
||||||
handleAsync: async (db, schema) => {
|
|
||||||
await db.transaction(async (trx) => {
|
|
||||||
for (const { id, position } of positions) {
|
for (const { id, position } of positions) {
|
||||||
await trx.update(schema.groups).set({ position }).where(eq(groups.id, id));
|
await trx.update(groups).set({ position }).where(eq(groups.id, id));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
|
||||||
handleSync: (db) => {
|
|
||||||
db.transaction((trx) => {
|
|
||||||
for (const { id, position } of positions) {
|
|
||||||
trx.update(groups).set({ position }).where(eq(groups.id, id)).run();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}),
|
}),
|
||||||
savePermissions: permissionRequiredProcedure
|
savePermissions: permissionRequiredProcedure
|
||||||
.requiresPermission("admin")
|
.requiresPermission("admin")
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { createId, objectEntries } from "@homarr/common";
|
|||||||
import { decryptSecret, encryptSecret } from "@homarr/common/server";
|
import { decryptSecret, encryptSecret } from "@homarr/common/server";
|
||||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||||
import type { Database } from "@homarr/db";
|
import type { Database } from "@homarr/db";
|
||||||
import { and, asc, eq, handleTransactionsAsync, inArray, like, or } from "@homarr/db";
|
import { and, asc, eq, inArray, like, or } from "@homarr/db";
|
||||||
import {
|
import {
|
||||||
apps,
|
apps,
|
||||||
groupMembers,
|
groupMembers,
|
||||||
@@ -43,15 +43,15 @@ import { mapTestConnectionError } from "./map-test-connection-error";
|
|||||||
const logger = createLogger({ module: "integrationRouter" });
|
const logger = createLogger({ module: "integrationRouter" });
|
||||||
|
|
||||||
export const integrationRouter = createTRPCRouter({
|
export const integrationRouter = createTRPCRouter({
|
||||||
all: protectedProcedure.query(async ({ ctx }) => {
|
all: publicProcedure.query(async ({ ctx }) => {
|
||||||
const groupsOfCurrentUser = await ctx.db.query.groupMembers.findMany({
|
const groupsOfCurrentUser = await ctx.db.query.groupMembers.findMany({
|
||||||
where: eq(groupMembers.userId, ctx.session.user.id),
|
where: eq(groupMembers.userId, ctx.session?.user.id ?? ""),
|
||||||
});
|
});
|
||||||
|
|
||||||
const integrations = await ctx.db.query.integrations.findMany({
|
const integrations = await ctx.db.query.integrations.findMany({
|
||||||
with: {
|
with: {
|
||||||
userPermissions: {
|
userPermissions: {
|
||||||
where: eq(integrationUserPermissions.userId, ctx.session.user.id),
|
where: eq(integrationUserPermissions.userId, ctx.session?.user.id ?? ""),
|
||||||
},
|
},
|
||||||
groupPermissions: {
|
groupPermissions: {
|
||||||
where: inArray(
|
where: inArray(
|
||||||
@@ -85,15 +85,15 @@ export const integrationRouter = createTRPCRouter({
|
|||||||
integrationKinds.indexOf(integrationA.kind) - integrationKinds.indexOf(integrationB.kind),
|
integrationKinds.indexOf(integrationA.kind) - integrationKinds.indexOf(integrationB.kind),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
allThatSupportSearch: protectedProcedure.query(async ({ ctx }) => {
|
allThatSupportSearch: publicProcedure.query(async ({ ctx }) => {
|
||||||
const groupsOfCurrentUser = await ctx.db.query.groupMembers.findMany({
|
const groupsOfCurrentUser = await ctx.db.query.groupMembers.findMany({
|
||||||
where: eq(groupMembers.userId, ctx.session.user.id),
|
where: eq(groupMembers.userId, ctx.session?.user.id ?? ""),
|
||||||
});
|
});
|
||||||
|
|
||||||
const integrationsFromDb = await ctx.db.query.integrations.findMany({
|
const integrationsFromDb = await ctx.db.query.integrations.findMany({
|
||||||
with: {
|
with: {
|
||||||
userPermissions: {
|
userPermissions: {
|
||||||
where: eq(integrationUserPermissions.userId, ctx.session.user.id),
|
where: eq(integrationUserPermissions.userId, ctx.session?.user.id ?? ""),
|
||||||
},
|
},
|
||||||
groupPermissions: {
|
groupPermissions: {
|
||||||
where: inArray(
|
where: inArray(
|
||||||
@@ -133,7 +133,7 @@ export const integrationRouter = createTRPCRouter({
|
|||||||
integrationKinds.indexOf(integrationA.kind) - integrationKinds.indexOf(integrationB.kind),
|
integrationKinds.indexOf(integrationA.kind) - integrationKinds.indexOf(integrationB.kind),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
allOfGivenCategory: protectedProcedure
|
allOfGivenCategory: publicProcedure
|
||||||
.input(
|
.input(
|
||||||
z.object({
|
z.object({
|
||||||
category: z.enum(integrationCategories),
|
category: z.enum(integrationCategories),
|
||||||
@@ -141,7 +141,7 @@ export const integrationRouter = createTRPCRouter({
|
|||||||
)
|
)
|
||||||
.query(async ({ ctx, input }) => {
|
.query(async ({ ctx, input }) => {
|
||||||
const groupsOfCurrentUser = await ctx.db.query.groupMembers.findMany({
|
const groupsOfCurrentUser = await ctx.db.query.groupMembers.findMany({
|
||||||
where: eq(groupMembers.userId, ctx.session.user.id),
|
where: eq(groupMembers.userId, ctx.session?.user.id ?? ""),
|
||||||
});
|
});
|
||||||
|
|
||||||
const intergrationKinds = getIntegrationKindsByCategory(input.category);
|
const intergrationKinds = getIntegrationKindsByCategory(input.category);
|
||||||
@@ -149,7 +149,7 @@ export const integrationRouter = createTRPCRouter({
|
|||||||
const integrationsFromDb = await ctx.db.query.integrations.findMany({
|
const integrationsFromDb = await ctx.db.query.integrations.findMany({
|
||||||
with: {
|
with: {
|
||||||
userPermissions: {
|
userPermissions: {
|
||||||
where: eq(integrationUserPermissions.userId, ctx.session.user.id),
|
where: eq(integrationUserPermissions.userId, ctx.session?.user.id ?? ""),
|
||||||
},
|
},
|
||||||
groupPermissions: {
|
groupPermissions: {
|
||||||
where: inArray(
|
where: inArray(
|
||||||
@@ -524,16 +524,14 @@ export const integrationRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
await throwIfActionForbiddenAsync(ctx, eq(integrations.id, input.entityId), "full");
|
await throwIfActionForbiddenAsync(ctx, eq(integrations.id, input.entityId), "full");
|
||||||
|
|
||||||
await handleTransactionsAsync(ctx.db, {
|
|
||||||
async handleAsync(db, schema) {
|
|
||||||
await ctx.db.transaction(async (transaction) => {
|
await ctx.db.transaction(async (transaction) => {
|
||||||
await transaction
|
await transaction
|
||||||
.delete(schema.integrationUserPermissions)
|
.delete(integrationUserPermissions)
|
||||||
.where(eq(schema.integrationUserPermissions.integrationId, input.entityId));
|
.where(eq(integrationUserPermissions.integrationId, input.entityId));
|
||||||
if (input.permissions.length === 0) {
|
if (input.permissions.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await transaction.insert(schema.integrationUserPermissions).values(
|
await transaction.insert(integrationUserPermissions).values(
|
||||||
input.permissions.map((permission) => ({
|
input.permissions.map((permission) => ({
|
||||||
userId: permission.principalId,
|
userId: permission.principalId,
|
||||||
permission: permission.permission,
|
permission: permission.permission,
|
||||||
@@ -541,45 +539,20 @@ export const integrationRouter = createTRPCRouter({
|
|||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
},
|
|
||||||
handleSync(db) {
|
|
||||||
db.transaction((transaction) => {
|
|
||||||
transaction
|
|
||||||
.delete(integrationUserPermissions)
|
|
||||||
.where(eq(integrationUserPermissions.integrationId, input.entityId))
|
|
||||||
.run();
|
|
||||||
if (input.permissions.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
transaction
|
|
||||||
.insert(integrationUserPermissions)
|
|
||||||
.values(
|
|
||||||
input.permissions.map((permission) => ({
|
|
||||||
userId: permission.principalId,
|
|
||||||
permission: permission.permission,
|
|
||||||
integrationId: input.entityId,
|
|
||||||
})),
|
|
||||||
)
|
|
||||||
.run();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}),
|
}),
|
||||||
saveGroupIntegrationPermissions: protectedProcedure
|
saveGroupIntegrationPermissions: protectedProcedure
|
||||||
.input(integrationSavePermissionsSchema)
|
.input(integrationSavePermissionsSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
await throwIfActionForbiddenAsync(ctx, eq(integrations.id, input.entityId), "full");
|
await throwIfActionForbiddenAsync(ctx, eq(integrations.id, input.entityId), "full");
|
||||||
|
|
||||||
await handleTransactionsAsync(ctx.db, {
|
await ctx.db.transaction(async (transaction) => {
|
||||||
async handleAsync(db, schema) {
|
|
||||||
await db.transaction(async (transaction) => {
|
|
||||||
await transaction
|
await transaction
|
||||||
.delete(schema.integrationGroupPermissions)
|
.delete(integrationGroupPermissions)
|
||||||
.where(eq(schema.integrationGroupPermissions.integrationId, input.entityId));
|
.where(eq(integrationGroupPermissions.integrationId, input.entityId));
|
||||||
if (input.permissions.length === 0) {
|
if (input.permissions.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await transaction.insert(schema.integrationGroupPermissions).values(
|
await transaction.insert(integrationGroupPermissions).values(
|
||||||
input.permissions.map((permission) => ({
|
input.permissions.map((permission) => ({
|
||||||
groupId: permission.principalId,
|
groupId: permission.principalId,
|
||||||
permission: permission.permission,
|
permission: permission.permission,
|
||||||
@@ -587,29 +560,6 @@ export const integrationRouter = createTRPCRouter({
|
|||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
},
|
|
||||||
handleSync(db) {
|
|
||||||
db.transaction((transaction) => {
|
|
||||||
transaction
|
|
||||||
.delete(integrationGroupPermissions)
|
|
||||||
.where(eq(integrationGroupPermissions.integrationId, input.entityId))
|
|
||||||
.run();
|
|
||||||
if (input.permissions.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
transaction
|
|
||||||
.insert(integrationGroupPermissions)
|
|
||||||
.values(
|
|
||||||
input.permissions.map((permission) => ({
|
|
||||||
groupId: permission.principalId,
|
|
||||||
permission: permission.permission,
|
|
||||||
integrationId: input.entityId,
|
|
||||||
})),
|
|
||||||
)
|
|
||||||
.run();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}),
|
}),
|
||||||
searchInIntegration: protectedProcedure
|
searchInIntegration: protectedProcedure
|
||||||
.concat(createOneIntegrationMiddleware("query", ...getIntegrationKindsByCategory("search")))
|
.concat(createOneIntegrationMiddleware("query", ...getIntegrationKindsByCategory("search")))
|
||||||
|
|||||||
@@ -1,15 +1,22 @@
|
|||||||
import { lazy } from "@trpc/server";
|
|
||||||
|
|
||||||
import { createTRPCRouter } from "../../../trpc";
|
import { createTRPCRouter } from "../../../trpc";
|
||||||
|
import { clusterRouter } from "./cluster";
|
||||||
|
import { configMapsRouter } from "./configMaps";
|
||||||
|
import { ingressesRouter } from "./ingresses";
|
||||||
|
import { namespacesRouter } from "./namespaces";
|
||||||
|
import { nodesRouter } from "./nodes";
|
||||||
|
import { podsRouter } from "./pods";
|
||||||
|
import { secretsRouter } from "./secrets";
|
||||||
|
import { servicesRouter } from "./services";
|
||||||
|
import { volumesRouter } from "./volumes";
|
||||||
|
|
||||||
export const kubernetesRouter = createTRPCRouter({
|
export const kubernetesRouter = createTRPCRouter({
|
||||||
nodes: lazy(() => import("./nodes").then((mod) => mod.nodesRouter)),
|
nodes: nodesRouter,
|
||||||
cluster: lazy(() => import("./cluster").then((mod) => mod.clusterRouter)),
|
cluster: clusterRouter,
|
||||||
namespaces: lazy(() => import("./namespaces").then((mod) => mod.namespacesRouter)),
|
namespaces: namespacesRouter,
|
||||||
ingresses: lazy(() => import("./ingresses").then((mod) => mod.ingressesRouter)),
|
ingresses: ingressesRouter,
|
||||||
services: lazy(() => import("./services").then((mod) => mod.servicesRouter)),
|
services: servicesRouter,
|
||||||
pods: lazy(() => import("./pods").then((mod) => mod.podsRouter)),
|
pods: podsRouter,
|
||||||
secrets: lazy(() => import("./secrets").then((mod) => mod.secretsRouter)),
|
secrets: secretsRouter,
|
||||||
configMaps: lazy(() => import("./configMaps").then((mod) => mod.configMapsRouter)),
|
configMaps: configMapsRouter,
|
||||||
volumes: lazy(() => import("./volumes").then((mod) => mod.volumesRouter)),
|
volumes: volumesRouter,
|
||||||
});
|
});
|
||||||
@@ -4,7 +4,7 @@ import { describe, expect, test, vi } from "vitest";
|
|||||||
import type { Session } from "@homarr/auth";
|
import type { Session } from "@homarr/auth";
|
||||||
import { createId } from "@homarr/common";
|
import { createId } from "@homarr/common";
|
||||||
import { apps } from "@homarr/db/schema";
|
import { apps } from "@homarr/db/schema";
|
||||||
import { createDb } from "@homarr/db/test";
|
import { createDbAsync } from "@homarr/db/test";
|
||||||
import type { GroupPermissionKey } from "@homarr/definitions";
|
import type { GroupPermissionKey } from "@homarr/definitions";
|
||||||
|
|
||||||
import { appRouter } from "../app";
|
import { appRouter } from "../app";
|
||||||
@@ -13,14 +13,6 @@ import * as appAccessControl from "../app/app-access-control";
|
|||||||
// Mock the auth module to return an empty session
|
// Mock the auth module to return an empty session
|
||||||
vi.mock("@homarr/auth", () => ({ auth: () => ({}) as Session }));
|
vi.mock("@homarr/auth", () => ({ auth: () => ({}) as Session }));
|
||||||
|
|
||||||
const createFakeAccessControl = (canAccess: boolean) =>
|
|
||||||
vi.fn(
|
|
||||||
class {
|
|
||||||
canUserSeeAppAsync = async (_: string) => await Promise.resolve(canAccess);
|
|
||||||
canUserSeeAppsAsync = async (_: string[]) => await Promise.resolve(canAccess);
|
|
||||||
} as unknown as typeof appAccessControl.AppAccessControl,
|
|
||||||
);
|
|
||||||
|
|
||||||
const createDefaultSession = (permissions: GroupPermissionKey[] = []): Session => ({
|
const createDefaultSession = (permissions: GroupPermissionKey[] = []): Session => ({
|
||||||
user: { id: createId(), permissions, colorScheme: "light" },
|
user: { id: createId(), permissions, colorScheme: "light" },
|
||||||
expires: new Date().toISOString(),
|
expires: new Date().toISOString(),
|
||||||
@@ -29,7 +21,7 @@ const createDefaultSession = (permissions: GroupPermissionKey[] = []): Session =
|
|||||||
describe("all should return all apps", () => {
|
describe("all should return all apps", () => {
|
||||||
test("should return all apps with session", async () => {
|
test("should return all apps with session", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = appRouter.createCaller({
|
const caller = appRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -63,7 +55,7 @@ describe("all should return all apps", () => {
|
|||||||
test("should throw UNAUTHORIZED if the user is not authenticated", async () => {
|
test("should throw UNAUTHORIZED if the user is not authenticated", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const caller = appRouter.createCaller({
|
const caller = appRouter.createCaller({
|
||||||
db: createDb(),
|
db: await createDbAsync(),
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
session: null,
|
session: null,
|
||||||
});
|
});
|
||||||
@@ -79,13 +71,13 @@ describe("all should return all apps", () => {
|
|||||||
describe("byId should return an app by id", () => {
|
describe("byId should return an app by id", () => {
|
||||||
test("should return an app by id when canUserSeeAppAsync returns true", async () => {
|
test("should return an app by id when canUserSeeAppAsync returns true", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = appRouter.createCaller({
|
const caller = appRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
session: null,
|
session: null,
|
||||||
});
|
});
|
||||||
vi.spyOn(appAccessControl, "AppAccessControl").mockImplementation(createFakeAccessControl(true));
|
vi.spyOn(appAccessControl, "canUserSeeAppAsync").mockReturnValue(Promise.resolve(true));
|
||||||
|
|
||||||
await db.insert(apps).values([
|
await db.insert(apps).values([
|
||||||
{
|
{
|
||||||
@@ -111,7 +103,7 @@ describe("byId should return an app by id", () => {
|
|||||||
|
|
||||||
test("should throw NOT_FOUND error when canUserSeeAppAsync returns false", async () => {
|
test("should throw NOT_FOUND error when canUserSeeAppAsync returns false", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = appRouter.createCaller({
|
const caller = appRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -126,7 +118,7 @@ describe("byId should return an app by id", () => {
|
|||||||
href: "https://mantine.dev",
|
href: "https://mantine.dev",
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
vi.spyOn(appAccessControl, "AppAccessControl").mockImplementation(createFakeAccessControl(false));
|
vi.spyOn(appAccessControl, "canUserSeeAppAsync").mockReturnValue(Promise.resolve(false));
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const actAsync = async () => await caller.byId({ id: "2" });
|
const actAsync = async () => await caller.byId({ id: "2" });
|
||||||
@@ -137,7 +129,7 @@ describe("byId should return an app by id", () => {
|
|||||||
|
|
||||||
test("should throw an error if the app does not exist", async () => {
|
test("should throw an error if the app does not exist", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = appRouter.createCaller({
|
const caller = appRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -155,7 +147,7 @@ describe("byId should return an app by id", () => {
|
|||||||
describe("create should create a new app with all arguments", () => {
|
describe("create should create a new app with all arguments", () => {
|
||||||
test("should create a new app", async () => {
|
test("should create a new app", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = appRouter.createCaller({
|
const caller = appRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -184,7 +176,7 @@ describe("create should create a new app with all arguments", () => {
|
|||||||
|
|
||||||
test("should create a new app only with required arguments", async () => {
|
test("should create a new app only with required arguments", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = appRouter.createCaller({
|
const caller = appRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -215,7 +207,7 @@ describe("create should create a new app with all arguments", () => {
|
|||||||
describe("update should update an app", () => {
|
describe("update should update an app", () => {
|
||||||
test("should update an app", async () => {
|
test("should update an app", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = appRouter.createCaller({
|
const caller = appRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -255,7 +247,7 @@ describe("update should update an app", () => {
|
|||||||
|
|
||||||
test("should throw an error if the app does not exist", async () => {
|
test("should throw an error if the app does not exist", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = appRouter.createCaller({
|
const caller = appRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -281,7 +273,7 @@ describe("update should update an app", () => {
|
|||||||
describe("delete should delete an app", () => {
|
describe("delete should delete an app", () => {
|
||||||
test("should delete an app", async () => {
|
test("should delete an app", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = appRouter.createCaller({
|
const caller = appRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import {
|
|||||||
serverSettings,
|
serverSettings,
|
||||||
users,
|
users,
|
||||||
} from "@homarr/db/schema";
|
} from "@homarr/db/schema";
|
||||||
import { createDb } from "@homarr/db/test";
|
import { createDbAsync } from "@homarr/db/test";
|
||||||
import type { BoardPermission, GroupPermissionKey } from "@homarr/definitions";
|
import type { BoardPermission, GroupPermissionKey } from "@homarr/definitions";
|
||||||
|
|
||||||
import type { RouterOutputs } from "../..";
|
import type { RouterOutputs } from "../..";
|
||||||
@@ -55,7 +55,7 @@ const createRandomUserAsync = async (db: Database) => {
|
|||||||
describe("getAllBoards should return all boards accessable to the current user", () => {
|
describe("getAllBoards should return all boards accessable to the current user", () => {
|
||||||
test("without session it should return only public boards", async () => {
|
test("without session it should return only public boards", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: null });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: null });
|
||||||
|
|
||||||
const user1 = await createRandomUserAsync(db);
|
const user1 = await createRandomUserAsync(db);
|
||||||
@@ -86,7 +86,7 @@ describe("getAllBoards should return all boards accessable to the current user",
|
|||||||
|
|
||||||
test("with session containing board-view-all permission it should return all boards", async () => {
|
test("with session containing board-view-all permission it should return all boards", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({
|
const caller = boardRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -128,7 +128,7 @@ describe("getAllBoards should return all boards accessable to the current user",
|
|||||||
|
|
||||||
test("with session user beeing creator it should return all private boards of them", async () => {
|
test("with session user beeing creator it should return all private boards of them", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
const user1 = await createRandomUserAsync(db);
|
const user1 = await createRandomUserAsync(db);
|
||||||
@@ -170,7 +170,7 @@ describe("getAllBoards should return all boards accessable to the current user",
|
|||||||
"with %s group board permission it should show board",
|
"with %s group board permission it should show board",
|
||||||
async (permission) => {
|
async (permission) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({
|
const caller = boardRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -236,7 +236,7 @@ describe("getAllBoards should return all boards accessable to the current user",
|
|||||||
"with %s user board permission it should show board",
|
"with %s user board permission it should show board",
|
||||||
async (permission) => {
|
async (permission) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({
|
const caller = boardRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -290,7 +290,7 @@ describe("getAllBoards should return all boards accessable to the current user",
|
|||||||
describe("createBoard should create a new board", () => {
|
describe("createBoard should create a new board", () => {
|
||||||
test("should create a new board with permission board-create", async () => {
|
test("should create a new board with permission board-create", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const session = {
|
const session = {
|
||||||
...defaultSession,
|
...defaultSession,
|
||||||
user: {
|
user: {
|
||||||
@@ -333,7 +333,7 @@ describe("createBoard should create a new board", () => {
|
|||||||
|
|
||||||
test("should throw error when user has no board-create permission", async () => {
|
test("should throw error when user has no board-create permission", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -347,7 +347,7 @@ describe("createBoard should create a new board", () => {
|
|||||||
describe("rename board should rename board", () => {
|
describe("rename board should rename board", () => {
|
||||||
test("should rename board", async () => {
|
test("should rename board", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
||||||
|
|
||||||
@@ -375,7 +375,7 @@ describe("rename board should rename board", () => {
|
|||||||
|
|
||||||
test("should throw error when similar board name exists", async () => {
|
test("should throw error when similar board name exists", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
await db.insert(users).values({
|
await db.insert(users).values({
|
||||||
@@ -402,7 +402,7 @@ describe("rename board should rename board", () => {
|
|||||||
|
|
||||||
test("should throw error when board not found", async () => {
|
test("should throw error when board not found", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -418,7 +418,7 @@ describe("changeBoardVisibility should change board visibility", () => {
|
|||||||
"should change board visibility to %s",
|
"should change board visibility to %s",
|
||||||
async (visibility) => {
|
async (visibility) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
||||||
|
|
||||||
@@ -453,7 +453,7 @@ describe("changeBoardVisibility should change board visibility", () => {
|
|||||||
describe("deleteBoard should delete board", () => {
|
describe("deleteBoard should delete board", () => {
|
||||||
test("should delete board", async () => {
|
test("should delete board", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
||||||
|
|
||||||
@@ -480,7 +480,7 @@ describe("deleteBoard should delete board", () => {
|
|||||||
|
|
||||||
test("should throw error when board not found", async () => {
|
test("should throw error when board not found", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -495,7 +495,7 @@ describe("getHomeBoard should return home board", () => {
|
|||||||
test("should return user home board when user has one", async () => {
|
test("should return user home board when user has one", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
const fullBoardProps = await createFullBoardAsync(db, "home");
|
const fullBoardProps = await createFullBoardAsync(db, "home");
|
||||||
@@ -519,7 +519,7 @@ describe("getHomeBoard should return home board", () => {
|
|||||||
test("should return global home board when user doesn't have one", async () => {
|
test("should return global home board when user doesn't have one", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
const fullBoardProps = await createFullBoardAsync(db, "home");
|
const fullBoardProps = await createFullBoardAsync(db, "home");
|
||||||
@@ -540,7 +540,7 @@ describe("getHomeBoard should return home board", () => {
|
|||||||
});
|
});
|
||||||
test("should throw error when home board not configured in serverSettings", async () => {
|
test("should throw error when home board not configured in serverSettings", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
await createFullBoardAsync(db, "home");
|
await createFullBoardAsync(db, "home");
|
||||||
|
|
||||||
@@ -556,7 +556,7 @@ describe("getBoardByName should return board by name", () => {
|
|||||||
it.each([["default"], ["something"]])("should return board by name %s when present", async (name) => {
|
it.each([["default"], ["something"]])("should return board by name %s when present", async (name) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
const fullBoardProps = await createFullBoardAsync(db, name);
|
const fullBoardProps = await createFullBoardAsync(db, name);
|
||||||
@@ -574,7 +574,7 @@ describe("getBoardByName should return board by name", () => {
|
|||||||
|
|
||||||
it("should throw error when not present", async () => {
|
it("should throw error when not present", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
await createFullBoardAsync(db, "default");
|
await createFullBoardAsync(db, "default");
|
||||||
|
|
||||||
@@ -590,7 +590,7 @@ describe("savePartialBoardSettings should save general settings", () => {
|
|||||||
it("should save general settings", async () => {
|
it("should save general settings", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
const newPageTitle = "newPageTitle";
|
const newPageTitle = "newPageTitle";
|
||||||
@@ -647,7 +647,7 @@ describe("savePartialBoardSettings should save general settings", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should throw error when board not found", async () => {
|
it("should throw error when board not found", async () => {
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
const actAsync = async () =>
|
const actAsync = async () =>
|
||||||
@@ -666,7 +666,7 @@ describe("savePartialBoardSettings should save general settings", () => {
|
|||||||
describe("saveBoard should save full board", () => {
|
describe("saveBoard should save full board", () => {
|
||||||
it("should remove section when not present in input", async () => {
|
it("should remove section when not present in input", async () => {
|
||||||
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
const { boardId, sectionId } = await createFullBoardAsync(db, "default");
|
const { boardId, sectionId } = await createFullBoardAsync(db, "default");
|
||||||
@@ -703,7 +703,7 @@ describe("saveBoard should save full board", () => {
|
|||||||
});
|
});
|
||||||
it("should remove item when not present in input", async () => {
|
it("should remove item when not present in input", async () => {
|
||||||
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
const { boardId, itemId, sectionId, layoutId } = await createFullBoardAsync(db, "default");
|
const { boardId, itemId, sectionId, layoutId } = await createFullBoardAsync(db, "default");
|
||||||
@@ -760,7 +760,7 @@ describe("saveBoard should save full board", () => {
|
|||||||
});
|
});
|
||||||
it("should remove integration reference when not present in input", async () => {
|
it("should remove integration reference when not present in input", async () => {
|
||||||
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
const anotherIntegration = {
|
const anotherIntegration = {
|
||||||
id: createId(),
|
id: createId(),
|
||||||
@@ -832,7 +832,7 @@ describe("saveBoard should save full board", () => {
|
|||||||
"should add section when present in input",
|
"should add section when present in input",
|
||||||
async (partialSection) => {
|
async (partialSection) => {
|
||||||
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
const { boardId, sectionId } = await createFullBoardAsync(db, "default");
|
const { boardId, sectionId } = await createFullBoardAsync(db, "default");
|
||||||
@@ -884,7 +884,7 @@ describe("saveBoard should save full board", () => {
|
|||||||
);
|
);
|
||||||
it("should add item when present in input", async () => {
|
it("should add item when present in input", async () => {
|
||||||
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
const { boardId, sectionId, layoutId } = await createFullBoardAsync(db, "default");
|
const { boardId, sectionId, layoutId } = await createFullBoardAsync(db, "default");
|
||||||
@@ -956,7 +956,7 @@ describe("saveBoard should save full board", () => {
|
|||||||
});
|
});
|
||||||
it("should add integration reference when present in input", async () => {
|
it("should add integration reference when present in input", async () => {
|
||||||
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
const integration = {
|
const integration = {
|
||||||
id: createId(),
|
id: createId(),
|
||||||
@@ -1024,7 +1024,7 @@ describe("saveBoard should save full board", () => {
|
|||||||
expect(spy).toHaveBeenCalledWith(expect.anything(), expect.anything(), "modify");
|
expect(spy).toHaveBeenCalledWith(expect.anything(), expect.anything(), "modify");
|
||||||
});
|
});
|
||||||
it("should update section when present in input", async () => {
|
it("should update section when present in input", async () => {
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
const { boardId, sectionId } = await createFullBoardAsync(db, "default");
|
const { boardId, sectionId } = await createFullBoardAsync(db, "default");
|
||||||
@@ -1083,7 +1083,7 @@ describe("saveBoard should save full board", () => {
|
|||||||
});
|
});
|
||||||
it("should update item when present in input", async () => {
|
it("should update item when present in input", async () => {
|
||||||
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
const { boardId, itemId, sectionId, layoutId } = await createFullBoardAsync(db, "default");
|
const { boardId, itemId, sectionId, layoutId } = await createFullBoardAsync(db, "default");
|
||||||
@@ -1147,7 +1147,7 @@ describe("saveBoard should save full board", () => {
|
|||||||
expect(spy).toHaveBeenCalledWith(expect.anything(), expect.anything(), "modify");
|
expect(spy).toHaveBeenCalledWith(expect.anything(), expect.anything(), "modify");
|
||||||
});
|
});
|
||||||
it("should fail when board not found", async () => {
|
it("should fail when board not found", async () => {
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
const actAsync = async () =>
|
const actAsync = async () =>
|
||||||
@@ -1164,7 +1164,7 @@ describe("saveBoard should save full board", () => {
|
|||||||
describe("getBoardPermissions should return board permissions", () => {
|
describe("getBoardPermissions should return board permissions", () => {
|
||||||
test("should return board permissions", async () => {
|
test("should return board permissions", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
||||||
|
|
||||||
@@ -1239,7 +1239,7 @@ describe("saveUserBoardPermissions should save user board permissions", () => {
|
|||||||
"should save user board permissions",
|
"should save user board permissions",
|
||||||
async (permission) => {
|
async (permission) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
||||||
|
|
||||||
@@ -1281,7 +1281,7 @@ describe("saveGroupBoardPermissions should save group board permissions", () =>
|
|||||||
"should save group board permissions",
|
"should save group board permissions",
|
||||||
async (permission) => {
|
async (permission) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
const spy = vi.spyOn(boardAccess, "throwIfActionForbiddenAsync");
|
||||||
|
|
||||||
@@ -1339,7 +1339,7 @@ const createNewLayout = (columnCount: number) => ({
|
|||||||
describe("saveLayouts should save layout changes", () => {
|
describe("saveLayouts should save layout changes", () => {
|
||||||
test("should add layout when not present in database", async () => {
|
test("should add layout when not present in database", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
const { boardId, layoutId } = await createFullBoardAsync(db, "default");
|
const { boardId, layoutId } = await createFullBoardAsync(db, "default");
|
||||||
@@ -1363,7 +1363,7 @@ describe("saveLayouts should save layout changes", () => {
|
|||||||
});
|
});
|
||||||
test("should add items and dynamic sections generated from grid-algorithm when new layout is added", async () => {
|
test("should add items and dynamic sections generated from grid-algorithm when new layout is added", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
const { boardId, layoutId, sectionId, itemId } = await createFullBoardAsync(db, "default");
|
const { boardId, layoutId, sectionId, itemId } = await createFullBoardAsync(db, "default");
|
||||||
@@ -1394,7 +1394,7 @@ describe("saveLayouts should save layout changes", () => {
|
|||||||
});
|
});
|
||||||
test("should update layout when present in input", async () => {
|
test("should update layout when present in input", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
const { boardId, layoutId } = await createFullBoardAsync(db, "default");
|
const { boardId, layoutId } = await createFullBoardAsync(db, "default");
|
||||||
@@ -1420,7 +1420,7 @@ describe("saveLayouts should save layout changes", () => {
|
|||||||
});
|
});
|
||||||
test("should update position of items when column count changes", async () => {
|
test("should update position of items when column count changes", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
const { boardId, layoutId, sectionId, itemId } = await createFullBoardAsync(db, "default");
|
const { boardId, layoutId, sectionId, itemId } = await createFullBoardAsync(db, "default");
|
||||||
@@ -1447,7 +1447,7 @@ describe("saveLayouts should save layout changes", () => {
|
|||||||
});
|
});
|
||||||
test("should remove layout when not present in input", async () => {
|
test("should remove layout when not present in input", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
const { boardId, layoutId } = await createFullBoardAsync(db, "default");
|
const { boardId, layoutId } = await createFullBoardAsync(db, "default");
|
||||||
@@ -1466,7 +1466,7 @@ describe("saveLayouts should save layout changes", () => {
|
|||||||
});
|
});
|
||||||
test("should fail when board not found", async () => {
|
test("should fail when board not found", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
const { layoutId } = await createFullBoardAsync(db, "default");
|
const { layoutId } = await createFullBoardAsync(db, "default");
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import * as authShared from "@homarr/auth/shared";
|
|||||||
import { createId } from "@homarr/common";
|
import { createId } from "@homarr/common";
|
||||||
import { eq } from "@homarr/db";
|
import { eq } from "@homarr/db";
|
||||||
import { boards, users } from "@homarr/db/schema";
|
import { boards, users } from "@homarr/db/schema";
|
||||||
import { createDb } from "@homarr/db/test";
|
import { createDbAsync } from "@homarr/db/test";
|
||||||
|
|
||||||
import { throwIfActionForbiddenAsync } from "../../board/board-access";
|
import { throwIfActionForbiddenAsync } from "../../board/board-access";
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ describe("throwIfActionForbiddenAsync should check access to board and return bo
|
|||||||
["view" as const, true],
|
["view" as const, true],
|
||||||
])("with permission %s should return %s when hasFullAccess is true", async (permission, expectedResult) => {
|
])("with permission %s should return %s when hasFullAccess is true", async (permission, expectedResult) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const spy = vi.spyOn(authShared, "constructBoardPermissions");
|
const spy = vi.spyOn(authShared, "constructBoardPermissions");
|
||||||
spy.mockReturnValue({
|
spy.mockReturnValue({
|
||||||
hasFullAccess: true,
|
hasFullAccess: true,
|
||||||
@@ -55,7 +55,7 @@ describe("throwIfActionForbiddenAsync should check access to board and return bo
|
|||||||
["view" as const, true],
|
["view" as const, true],
|
||||||
])("with permission %s should return %s when hasChangeAccess is true", async (permission, expectedResult) => {
|
])("with permission %s should return %s when hasChangeAccess is true", async (permission, expectedResult) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const spy = vi.spyOn(authShared, "constructBoardPermissions");
|
const spy = vi.spyOn(authShared, "constructBoardPermissions");
|
||||||
spy.mockReturnValue({
|
spy.mockReturnValue({
|
||||||
hasFullAccess: false,
|
hasFullAccess: false,
|
||||||
@@ -84,7 +84,7 @@ describe("throwIfActionForbiddenAsync should check access to board and return bo
|
|||||||
["view" as const, true],
|
["view" as const, true],
|
||||||
])("with permission %s should return %s when hasViewAccess is true", async (permission, expectedResult) => {
|
])("with permission %s should return %s when hasViewAccess is true", async (permission, expectedResult) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const spy = vi.spyOn(authShared, "constructBoardPermissions");
|
const spy = vi.spyOn(authShared, "constructBoardPermissions");
|
||||||
spy.mockReturnValue({
|
spy.mockReturnValue({
|
||||||
hasFullAccess: false,
|
hasFullAccess: false,
|
||||||
@@ -113,7 +113,7 @@ describe("throwIfActionForbiddenAsync should check access to board and return bo
|
|||||||
["view" as const, false],
|
["view" as const, false],
|
||||||
])("with permission %s should return %s when hasViewAccess is false", async (permission, expectedResult) => {
|
])("with permission %s should return %s when hasViewAccess is false", async (permission, expectedResult) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const spy = vi.spyOn(authShared, "constructBoardPermissions");
|
const spy = vi.spyOn(authShared, "constructBoardPermissions");
|
||||||
spy.mockReturnValue({
|
spy.mockReturnValue({
|
||||||
hasFullAccess: false,
|
hasFullAccess: false,
|
||||||
@@ -138,7 +138,7 @@ describe("throwIfActionForbiddenAsync should check access to board and return bo
|
|||||||
|
|
||||||
test("should throw when board is not found", async () => {
|
test("should throw when board is not found", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const act = () => throwIfActionForbiddenAsync({ db, session: null }, eq(boards.id, createId()), "full");
|
const act = () => throwIfActionForbiddenAsync({ db, session: null }, eq(boards.id, createId()), "full");
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import * as env from "@homarr/auth/env";
|
|||||||
import { createId } from "@homarr/common";
|
import { createId } from "@homarr/common";
|
||||||
import { eq } from "@homarr/db";
|
import { eq } from "@homarr/db";
|
||||||
import { groupMembers, groupPermissions, groups, users } from "@homarr/db/schema";
|
import { groupMembers, groupPermissions, groups, users } from "@homarr/db/schema";
|
||||||
import { createDb } from "@homarr/db/test";
|
import { createDbAsync } from "@homarr/db/test";
|
||||||
import type { GroupPermissionKey } from "@homarr/definitions";
|
import type { GroupPermissionKey } from "@homarr/definitions";
|
||||||
|
|
||||||
import { groupRouter } from "../group";
|
import { groupRouter } from "../group";
|
||||||
@@ -37,7 +37,7 @@ describe("paginated should return a list of groups with pagination", () => {
|
|||||||
"with 5 groups in database and pageSize set to 3 on page %s it should return %s groups",
|
"with 5 groups in database and pageSize set to 3 on page %s it should return %s groups",
|
||||||
async (page, expectedCount) => {
|
async (page, expectedCount) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
|
|
||||||
await db.insert(groups).values(
|
await db.insert(groups).values(
|
||||||
@@ -61,7 +61,7 @@ describe("paginated should return a list of groups with pagination", () => {
|
|||||||
|
|
||||||
test("with 5 groups in database and pagesize set to 3 it should return total count 5", async () => {
|
test("with 5 groups in database and pagesize set to 3 it should return total count 5", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
|
|
||||||
await db.insert(groups).values(
|
await db.insert(groups).values(
|
||||||
@@ -83,7 +83,7 @@ describe("paginated should return a list of groups with pagination", () => {
|
|||||||
|
|
||||||
test("groups should contain id, name, email and image of members", async () => {
|
test("groups should contain id, name, email and image of members", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
|
|
||||||
const user = createDummyUser();
|
const user = createDummyUser();
|
||||||
@@ -120,7 +120,7 @@ describe("paginated should return a list of groups with pagination", () => {
|
|||||||
"groups should be searchable by name with contains pattern, query %s should result in %s results",
|
"groups should be searchable by name with contains pattern, query %s should result in %s results",
|
||||||
async (query, expectedCount, firstKey) => {
|
async (query, expectedCount, firstKey) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
|
|
||||||
await db.insert(groups).values(
|
await db.insert(groups).values(
|
||||||
@@ -144,7 +144,7 @@ describe("paginated should return a list of groups with pagination", () => {
|
|||||||
|
|
||||||
test("without admin permissions it should throw unauthorized error", async () => {
|
test("without admin permissions it should throw unauthorized error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -158,7 +158,7 @@ describe("paginated should return a list of groups with pagination", () => {
|
|||||||
describe("byId should return group by id including members and permissions", () => {
|
describe("byId should return group by id including members and permissions", () => {
|
||||||
test('should return group with id "1" with members and permissions', async () => {
|
test('should return group with id "1" with members and permissions', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
|
|
||||||
const user = createDummyUser();
|
const user = createDummyUser();
|
||||||
@@ -203,7 +203,7 @@ describe("byId should return group by id including members and permissions", ()
|
|||||||
|
|
||||||
test("with group id 1 and group 2 in database it should throw NOT_FOUND error", async () => {
|
test("with group id 1 and group 2 in database it should throw NOT_FOUND error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
|
|
||||||
await db.insert(groups).values({
|
await db.insert(groups).values({
|
||||||
@@ -221,7 +221,7 @@ describe("byId should return group by id including members and permissions", ()
|
|||||||
|
|
||||||
test("without admin permissions it should throw unauthorized error", async () => {
|
test("without admin permissions it should throw unauthorized error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -235,7 +235,7 @@ describe("byId should return group by id including members and permissions", ()
|
|||||||
describe("create should create group in database", () => {
|
describe("create should create group in database", () => {
|
||||||
test("with valid input (64 character name) and non existing name it should be successful", async () => {
|
test("with valid input (64 character name) and non existing name it should be successful", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
|
|
||||||
const name = "a".repeat(64);
|
const name = "a".repeat(64);
|
||||||
@@ -259,7 +259,7 @@ describe("create should create group in database", () => {
|
|||||||
|
|
||||||
test("with more than 64 characters name it should fail while validation", async () => {
|
test("with more than 64 characters name it should fail while validation", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
const longName = "a".repeat(65);
|
const longName = "a".repeat(65);
|
||||||
|
|
||||||
@@ -280,7 +280,7 @@ describe("create should create group in database", () => {
|
|||||||
["test", " TeSt"],
|
["test", " TeSt"],
|
||||||
])("with similar name %s it should fail to create %s", async (similarName, nameToCreate) => {
|
])("with similar name %s it should fail to create %s", async (similarName, nameToCreate) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
|
|
||||||
await db.insert(groups).values({
|
await db.insert(groups).values({
|
||||||
@@ -298,7 +298,7 @@ describe("create should create group in database", () => {
|
|||||||
|
|
||||||
test("without admin permissions it should throw unauthorized error", async () => {
|
test("without admin permissions it should throw unauthorized error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -315,7 +315,7 @@ describe("update should update name with value that is no duplicate", () => {
|
|||||||
["first", " first", "first"],
|
["first", " first", "first"],
|
||||||
])("update should update name from %s to %s normalized", async (initialValue, updateValue, expectedValue) => {
|
])("update should update name from %s to %s normalized", async (initialValue, updateValue, expectedValue) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
|
|
||||||
const groupId = createId();
|
const groupId = createId();
|
||||||
@@ -350,7 +350,7 @@ describe("update should update name with value that is no duplicate", () => {
|
|||||||
[" seCond", "second"],
|
[" seCond", "second"],
|
||||||
])("with similar name %s it should fail to update %s", async (updateValue, initialDuplicate) => {
|
])("with similar name %s it should fail to update %s", async (updateValue, initialDuplicate) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
|
|
||||||
const groupId = createId();
|
const groupId = createId();
|
||||||
@@ -380,7 +380,7 @@ describe("update should update name with value that is no duplicate", () => {
|
|||||||
|
|
||||||
test("with non existing id it should throw not found error", async () => {
|
test("with non existing id it should throw not found error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
|
|
||||||
await db.insert(groups).values({
|
await db.insert(groups).values({
|
||||||
@@ -402,7 +402,7 @@ describe("update should update name with value that is no duplicate", () => {
|
|||||||
|
|
||||||
test("without admin permissions it should throw unauthorized error", async () => {
|
test("without admin permissions it should throw unauthorized error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -420,7 +420,7 @@ describe("update should update name with value that is no duplicate", () => {
|
|||||||
describe("savePermissions should save permissions for group", () => {
|
describe("savePermissions should save permissions for group", () => {
|
||||||
test("with existing group and permissions it should save permissions", async () => {
|
test("with existing group and permissions it should save permissions", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
|
|
||||||
const groupId = createId();
|
const groupId = createId();
|
||||||
@@ -451,7 +451,7 @@ describe("savePermissions should save permissions for group", () => {
|
|||||||
|
|
||||||
test("with non existing group it should throw not found error", async () => {
|
test("with non existing group it should throw not found error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
|
|
||||||
await db.insert(groups).values({
|
await db.insert(groups).values({
|
||||||
@@ -473,7 +473,7 @@ describe("savePermissions should save permissions for group", () => {
|
|||||||
|
|
||||||
test("without admin permissions it should throw unauthorized error", async () => {
|
test("without admin permissions it should throw unauthorized error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -491,7 +491,7 @@ describe("savePermissions should save permissions for group", () => {
|
|||||||
describe("transferOwnership should transfer ownership of group", () => {
|
describe("transferOwnership should transfer ownership of group", () => {
|
||||||
test("with existing group and user it should transfer ownership", async () => {
|
test("with existing group and user it should transfer ownership", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
|
|
||||||
const groupId = createId();
|
const groupId = createId();
|
||||||
@@ -529,7 +529,7 @@ describe("transferOwnership should transfer ownership of group", () => {
|
|||||||
|
|
||||||
test("with non existing group it should throw not found error", async () => {
|
test("with non existing group it should throw not found error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
|
|
||||||
await db.insert(groups).values({
|
await db.insert(groups).values({
|
||||||
@@ -551,7 +551,7 @@ describe("transferOwnership should transfer ownership of group", () => {
|
|||||||
|
|
||||||
test("without admin permissions it should throw unauthorized error", async () => {
|
test("without admin permissions it should throw unauthorized error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -569,7 +569,7 @@ describe("transferOwnership should transfer ownership of group", () => {
|
|||||||
describe("deleteGroup should delete group", () => {
|
describe("deleteGroup should delete group", () => {
|
||||||
test("with existing group it should delete group", async () => {
|
test("with existing group it should delete group", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
|
|
||||||
const groupId = createId();
|
const groupId = createId();
|
||||||
@@ -600,7 +600,7 @@ describe("deleteGroup should delete group", () => {
|
|||||||
|
|
||||||
test("with non existing group it should throw not found error", async () => {
|
test("with non existing group it should throw not found error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
|
|
||||||
await db.insert(groups).values({
|
await db.insert(groups).values({
|
||||||
@@ -621,7 +621,7 @@ describe("deleteGroup should delete group", () => {
|
|||||||
|
|
||||||
test("without admin permissions it should throw unauthorized error", async () => {
|
test("without admin permissions it should throw unauthorized error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -638,7 +638,7 @@ describe("deleteGroup should delete group", () => {
|
|||||||
describe("addMember should add member to group", () => {
|
describe("addMember should add member to group", () => {
|
||||||
test("with existing group and user it should add member", async () => {
|
test("with existing group and user it should add member", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const spy = vi.spyOn(env, "env", "get");
|
const spy = vi.spyOn(env, "env", "get");
|
||||||
spy.mockReturnValue({ AUTH_PROVIDERS: ["credentials"] } as never);
|
spy.mockReturnValue({ AUTH_PROVIDERS: ["credentials"] } as never);
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
@@ -679,7 +679,7 @@ describe("addMember should add member to group", () => {
|
|||||||
|
|
||||||
test("with non existing group it should throw not found error", async () => {
|
test("with non existing group it should throw not found error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
|
|
||||||
await db.insert(users).values({
|
await db.insert(users).values({
|
||||||
@@ -700,7 +700,7 @@ describe("addMember should add member to group", () => {
|
|||||||
|
|
||||||
test("without admin permissions it should throw unauthorized error", async () => {
|
test("without admin permissions it should throw unauthorized error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -716,7 +716,7 @@ describe("addMember should add member to group", () => {
|
|||||||
|
|
||||||
test("without credentials provider it should throw FORBIDDEN error", async () => {
|
test("without credentials provider it should throw FORBIDDEN error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const spy = vi.spyOn(env, "env", "get");
|
const spy = vi.spyOn(env, "env", "get");
|
||||||
spy.mockReturnValue({ AUTH_PROVIDERS: ["ldap"] } as never);
|
spy.mockReturnValue({ AUTH_PROVIDERS: ["ldap"] } as never);
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
@@ -755,7 +755,7 @@ describe("addMember should add member to group", () => {
|
|||||||
describe("removeMember should remove member from group", () => {
|
describe("removeMember should remove member from group", () => {
|
||||||
test("with existing group and user it should remove member", async () => {
|
test("with existing group and user it should remove member", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const spy = vi.spyOn(env, "env", "get");
|
const spy = vi.spyOn(env, "env", "get");
|
||||||
spy.mockReturnValue({ AUTH_PROVIDERS: ["credentials"] } as never);
|
spy.mockReturnValue({ AUTH_PROVIDERS: ["credentials"] } as never);
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
@@ -799,7 +799,7 @@ describe("removeMember should remove member from group", () => {
|
|||||||
|
|
||||||
test("with non existing group it should throw not found error", async () => {
|
test("with non existing group it should throw not found error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
|
|
||||||
await db.insert(users).values({
|
await db.insert(users).values({
|
||||||
@@ -820,7 +820,7 @@ describe("removeMember should remove member from group", () => {
|
|||||||
|
|
||||||
test("without admin permissions it should throw unauthorized error", async () => {
|
test("without admin permissions it should throw unauthorized error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -836,7 +836,7 @@ describe("removeMember should remove member from group", () => {
|
|||||||
|
|
||||||
test("without credentials provider it should throw FORBIDDEN error", async () => {
|
test("without credentials provider it should throw FORBIDDEN error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const spy = vi.spyOn(env, "env", "get");
|
const spy = vi.spyOn(env, "env", "get");
|
||||||
spy.mockReturnValue({ AUTH_PROVIDERS: ["ldap"] } as never);
|
spy.mockReturnValue({ AUTH_PROVIDERS: ["ldap"] } as never);
|
||||||
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
const caller = groupRouter.createCaller({ db, deviceType: undefined, session: adminSession });
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import * as authShared from "@homarr/auth/shared";
|
|||||||
import { createId } from "@homarr/common";
|
import { createId } from "@homarr/common";
|
||||||
import { eq } from "@homarr/db";
|
import { eq } from "@homarr/db";
|
||||||
import { integrations, users } from "@homarr/db/schema";
|
import { integrations, users } from "@homarr/db/schema";
|
||||||
import { createDb } from "@homarr/db/test";
|
import { createDbAsync } from "@homarr/db/test";
|
||||||
|
|
||||||
import { throwIfActionForbiddenAsync } from "../../integration/integration-access";
|
import { throwIfActionForbiddenAsync } from "../../integration/integration-access";
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ describe("throwIfActionForbiddenAsync should check access to integration and ret
|
|||||||
["use" as const, true],
|
["use" as const, true],
|
||||||
])("with permission %s should return %s when hasFullAccess is true", async (permission, expectedResult) => {
|
])("with permission %s should return %s when hasFullAccess is true", async (permission, expectedResult) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const spy = vi.spyOn(authShared, "constructIntegrationPermissions");
|
const spy = vi.spyOn(authShared, "constructIntegrationPermissions");
|
||||||
spy.mockReturnValue({
|
spy.mockReturnValue({
|
||||||
hasFullAccess: true,
|
hasFullAccess: true,
|
||||||
@@ -56,7 +56,7 @@ describe("throwIfActionForbiddenAsync should check access to integration and ret
|
|||||||
["use" as const, true],
|
["use" as const, true],
|
||||||
])("with permission %s should return %s when hasInteractAccess is true", async (permission, expectedResult) => {
|
])("with permission %s should return %s when hasInteractAccess is true", async (permission, expectedResult) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const spy = vi.spyOn(authShared, "constructIntegrationPermissions");
|
const spy = vi.spyOn(authShared, "constructIntegrationPermissions");
|
||||||
spy.mockReturnValue({
|
spy.mockReturnValue({
|
||||||
hasFullAccess: false,
|
hasFullAccess: false,
|
||||||
@@ -87,7 +87,7 @@ describe("throwIfActionForbiddenAsync should check access to integration and ret
|
|||||||
["use" as const, true],
|
["use" as const, true],
|
||||||
])("with permission %s should return %s when hasUseAccess is true", async (permission, expectedResult) => {
|
])("with permission %s should return %s when hasUseAccess is true", async (permission, expectedResult) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const spy = vi.spyOn(authShared, "constructIntegrationPermissions");
|
const spy = vi.spyOn(authShared, "constructIntegrationPermissions");
|
||||||
spy.mockReturnValue({
|
spy.mockReturnValue({
|
||||||
hasFullAccess: false,
|
hasFullAccess: false,
|
||||||
@@ -118,7 +118,7 @@ describe("throwIfActionForbiddenAsync should check access to integration and ret
|
|||||||
["use" as const, false],
|
["use" as const, false],
|
||||||
])("with permission %s should return %s when hasUseAccess is false", async (permission, expectedResult) => {
|
])("with permission %s should return %s when hasUseAccess is false", async (permission, expectedResult) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const spy = vi.spyOn(authShared, "constructIntegrationPermissions");
|
const spy = vi.spyOn(authShared, "constructIntegrationPermissions");
|
||||||
spy.mockReturnValue({
|
spy.mockReturnValue({
|
||||||
hasFullAccess: false,
|
hasFullAccess: false,
|
||||||
@@ -145,7 +145,7 @@ describe("throwIfActionForbiddenAsync should check access to integration and ret
|
|||||||
|
|
||||||
test("should throw when integration is not found", async () => {
|
test("should throw when integration is not found", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const act = () => throwIfActionForbiddenAsync({ db, session: null }, eq(integrations.id, createId()), "full");
|
const act = () => throwIfActionForbiddenAsync({ db, session: null }, eq(integrations.id, createId()), "full");
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import type { Session } from "@homarr/auth";
|
|||||||
import { createId } from "@homarr/common";
|
import { createId } from "@homarr/common";
|
||||||
import { encryptSecret } from "@homarr/common/server";
|
import { encryptSecret } from "@homarr/common/server";
|
||||||
import { apps, integrations, integrationSecrets } from "@homarr/db/schema";
|
import { apps, integrations, integrationSecrets } from "@homarr/db/schema";
|
||||||
import { createDb } from "@homarr/db/test";
|
import { createDbAsync } from "@homarr/db/test";
|
||||||
import type { GroupPermissionKey } from "@homarr/definitions";
|
import type { GroupPermissionKey } from "@homarr/definitions";
|
||||||
|
|
||||||
import { integrationRouter } from "../../integration/integration-router";
|
import { integrationRouter } from "../../integration/integration-router";
|
||||||
@@ -30,7 +30,7 @@ vi.mock("../../integration/integration-test-connection", () => ({
|
|||||||
|
|
||||||
describe("all should return all integrations", () => {
|
describe("all should return all integrations", () => {
|
||||||
test("with any session should return all integrations", async () => {
|
test("with any session should return all integrations", async () => {
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = integrationRouter.createCaller({
|
const caller = integrationRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -61,7 +61,7 @@ describe("all should return all integrations", () => {
|
|||||||
|
|
||||||
describe("byId should return an integration by id", () => {
|
describe("byId should return an integration by id", () => {
|
||||||
test("with full access should return an integration by id", async () => {
|
test("with full access should return an integration by id", async () => {
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = integrationRouter.createCaller({
|
const caller = integrationRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -88,7 +88,7 @@ describe("byId should return an integration by id", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("with full access should throw an error if the integration does not exist", async () => {
|
test("with full access should throw an error if the integration does not exist", async () => {
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = integrationRouter.createCaller({
|
const caller = integrationRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -100,7 +100,7 @@ describe("byId should return an integration by id", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("with full access should only return the public secret values", async () => {
|
test("with full access should only return the public secret values", async () => {
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = integrationRouter.createCaller({
|
const caller = integrationRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -148,7 +148,7 @@ describe("byId should return an integration by id", () => {
|
|||||||
|
|
||||||
test("without full access should throw integration not found error", async () => {
|
test("without full access should throw integration not found error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = integrationRouter.createCaller({
|
const caller = integrationRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -174,7 +174,7 @@ describe("byId should return an integration by id", () => {
|
|||||||
|
|
||||||
describe("create should create a new integration", () => {
|
describe("create should create a new integration", () => {
|
||||||
test("with create integration access should create a new integration", async () => {
|
test("with create integration access should create a new integration", async () => {
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = integrationRouter.createCaller({
|
const caller = integrationRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -209,7 +209,7 @@ describe("create should create a new integration", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("with create integration access should create a new integration when creating search engine", async () => {
|
test("with create integration access should create a new integration when creating search engine", async () => {
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = integrationRouter.createCaller({
|
const caller = integrationRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -252,7 +252,7 @@ describe("create should create a new integration", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("with create integration access should create a new integration with new linked app", async () => {
|
test("with create integration access should create a new integration with new linked app", async () => {
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = integrationRouter.createCaller({
|
const caller = integrationRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -302,7 +302,7 @@ describe("create should create a new integration", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("with create integration access should create a new integration with existing linked app", async () => {
|
test("with create integration access should create a new integration with existing linked app", async () => {
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const appId = createId();
|
const appId = createId();
|
||||||
await db.insert(apps).values({
|
await db.insert(apps).values({
|
||||||
id: appId,
|
id: appId,
|
||||||
@@ -349,7 +349,7 @@ describe("create should create a new integration", () => {
|
|||||||
|
|
||||||
test("without create integration access should throw permission error", async () => {
|
test("without create integration access should throw permission error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = integrationRouter.createCaller({
|
const caller = integrationRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -372,7 +372,7 @@ describe("create should create a new integration", () => {
|
|||||||
|
|
||||||
test("without create app access should throw permission error with new linked app", async () => {
|
test("without create app access should throw permission error with new linked app", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = integrationRouter.createCaller({
|
const caller = integrationRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -403,7 +403,7 @@ describe("create should create a new integration", () => {
|
|||||||
|
|
||||||
describe("update should update an integration", () => {
|
describe("update should update an integration", () => {
|
||||||
test("with full access should update an integration", async () => {
|
test("with full access should update an integration", async () => {
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = integrationRouter.createCaller({
|
const caller = integrationRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -486,7 +486,7 @@ describe("update should update an integration", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("with full access should throw an error if the integration does not exist", async () => {
|
test("with full access should throw an error if the integration does not exist", async () => {
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = integrationRouter.createCaller({
|
const caller = integrationRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -506,7 +506,7 @@ describe("update should update an integration", () => {
|
|||||||
|
|
||||||
test("without full access should throw permission error", async () => {
|
test("without full access should throw permission error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = integrationRouter.createCaller({
|
const caller = integrationRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -530,7 +530,7 @@ describe("update should update an integration", () => {
|
|||||||
|
|
||||||
describe("delete should delete an integration", () => {
|
describe("delete should delete an integration", () => {
|
||||||
test("with full access should delete an integration", async () => {
|
test("with full access should delete an integration", async () => {
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = integrationRouter.createCaller({
|
const caller = integrationRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -564,7 +564,7 @@ describe("delete should delete an integration", () => {
|
|||||||
|
|
||||||
test("without full access should throw permission error", async () => {
|
test("without full access should throw permission error", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = integrationRouter.createCaller({
|
const caller = integrationRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { describe, expect, test, vi } from "vitest";
|
|||||||
import type { Session } from "@homarr/auth";
|
import type { Session } from "@homarr/auth";
|
||||||
import { createId } from "@homarr/common";
|
import { createId } from "@homarr/common";
|
||||||
import { invites, users } from "@homarr/db/schema";
|
import { invites, users } from "@homarr/db/schema";
|
||||||
import { createDb } from "@homarr/db/test";
|
import { createDbAsync } from "@homarr/db/test";
|
||||||
|
|
||||||
import { inviteRouter } from "../invite";
|
import { inviteRouter } from "../invite";
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ vi.mock("@homarr/auth/env", () => {
|
|||||||
describe("all should return all existing invites without sensitive informations", () => {
|
describe("all should return all existing invites without sensitive informations", () => {
|
||||||
test("invites should not contain sensitive informations", async () => {
|
test("invites should not contain sensitive informations", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = inviteRouter.createCaller({
|
const caller = inviteRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -70,7 +70,7 @@ describe("all should return all existing invites without sensitive informations"
|
|||||||
|
|
||||||
test("invites should be sorted ascending by expiration date", async () => {
|
test("invites should be sorted ascending by expiration date", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = inviteRouter.createCaller({
|
const caller = inviteRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -110,7 +110,7 @@ describe("all should return all existing invites without sensitive informations"
|
|||||||
describe("create should create a new invite expiring on the specified date with a token and id returned to generate url", () => {
|
describe("create should create a new invite expiring on the specified date with a token and id returned to generate url", () => {
|
||||||
test("creation should work with a date in the future, but less than 6 months.", async () => {
|
test("creation should work with a date in the future, but less than 6 months.", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = inviteRouter.createCaller({
|
const caller = inviteRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -142,7 +142,7 @@ describe("create should create a new invite expiring on the specified date with
|
|||||||
describe("delete should remove invite by id", () => {
|
describe("delete should remove invite by id", () => {
|
||||||
test("deletion should remove present invite", async () => {
|
test("deletion should remove present invite", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = inviteRouter.createCaller({
|
const caller = inviteRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -180,7 +180,7 @@ describe("delete should remove invite by id", () => {
|
|||||||
|
|
||||||
test("deletion should throw with NOT_FOUND code when specified invite not present", async () => {
|
test("deletion should throw with NOT_FOUND code when specified invite not present", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = inviteRouter.createCaller({
|
const caller = inviteRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { describe, expect, test, vi } from "vitest";
|
|||||||
import type { Session } from "@homarr/auth";
|
import type { Session } from "@homarr/auth";
|
||||||
import { createId } from "@homarr/common";
|
import { createId } from "@homarr/common";
|
||||||
import { serverSettings } from "@homarr/db/schema";
|
import { serverSettings } from "@homarr/db/schema";
|
||||||
import { createDb } from "@homarr/db/test";
|
import { createDbAsync } from "@homarr/db/test";
|
||||||
import { defaultServerSettings, defaultServerSettingsKeys } from "@homarr/server-settings";
|
import { defaultServerSettings, defaultServerSettingsKeys } from "@homarr/server-settings";
|
||||||
|
|
||||||
import { serverSettingsRouter } from "../serverSettings";
|
import { serverSettingsRouter } from "../serverSettings";
|
||||||
@@ -23,7 +23,7 @@ const defaultSession = {
|
|||||||
|
|
||||||
describe("getAll server settings", () => {
|
describe("getAll server settings", () => {
|
||||||
test("getAll should throw error when unauthorized", async () => {
|
test("getAll should throw error when unauthorized", async () => {
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = serverSettingsRouter.createCaller({
|
const caller = serverSettingsRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -42,7 +42,7 @@ describe("getAll server settings", () => {
|
|||||||
await expect(actAsync()).rejects.toThrow();
|
await expect(actAsync()).rejects.toThrow();
|
||||||
});
|
});
|
||||||
test("getAll should return default server settings when nothing in database", async () => {
|
test("getAll should return default server settings when nothing in database", async () => {
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = serverSettingsRouter.createCaller({
|
const caller = serverSettingsRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -57,7 +57,7 @@ describe("getAll server settings", () => {
|
|||||||
|
|
||||||
describe("saveSettings", () => {
|
describe("saveSettings", () => {
|
||||||
test("saveSettings should update settings and return true when it updated only one", async () => {
|
test("saveSettings should update settings and return true when it updated only one", async () => {
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = serverSettingsRouter.createCaller({
|
const caller = serverSettingsRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { createId } from "@homarr/common";
|
|||||||
import type { Database } from "@homarr/db";
|
import type { Database } from "@homarr/db";
|
||||||
import { eq } from "@homarr/db";
|
import { eq } from "@homarr/db";
|
||||||
import { invites, onboarding, users } from "@homarr/db/schema";
|
import { invites, onboarding, users } from "@homarr/db/schema";
|
||||||
import { createDb } from "@homarr/db/test";
|
import { createDbAsync } from "@homarr/db/test";
|
||||||
import type { GroupPermissionKey, OnboardingStep } from "@homarr/definitions";
|
import type { GroupPermissionKey, OnboardingStep } from "@homarr/definitions";
|
||||||
|
|
||||||
import { userRouter } from "../user";
|
import { userRouter } from "../user";
|
||||||
@@ -39,7 +39,7 @@ vi.mock("@homarr/auth/env", () => {
|
|||||||
|
|
||||||
describe("initUser should initialize the first user", () => {
|
describe("initUser should initialize the first user", () => {
|
||||||
it("should create a user if none exists", async () => {
|
it("should create a user if none exists", async () => {
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
await createOnboardingStepAsync(db, "user");
|
await createOnboardingStepAsync(db, "user");
|
||||||
const caller = userRouter.createCaller({
|
const caller = userRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
@@ -63,7 +63,7 @@ describe("initUser should initialize the first user", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should not create a user if the password and confirmPassword do not match", async () => {
|
it("should not create a user if the password and confirmPassword do not match", async () => {
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
await createOnboardingStepAsync(db, "user");
|
await createOnboardingStepAsync(db, "user");
|
||||||
const caller = userRouter.createCaller({
|
const caller = userRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
@@ -88,7 +88,7 @@ describe("initUser should initialize the first user", () => {
|
|||||||
["ABC123+/-"], // does not contain lowercase
|
["ABC123+/-"], // does not contain lowercase
|
||||||
["abc123+/-"], // does not contain uppercase
|
["abc123+/-"], // does not contain uppercase
|
||||||
])("should throw error that password requirements do not match for '%s' as password", async (password) => {
|
])("should throw error that password requirements do not match for '%s' as password", async (password) => {
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
await createOnboardingStepAsync(db, "user");
|
await createOnboardingStepAsync(db, "user");
|
||||||
const caller = userRouter.createCaller({
|
const caller = userRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
@@ -110,7 +110,7 @@ describe("initUser should initialize the first user", () => {
|
|||||||
describe("register should create a user with valid invitation", () => {
|
describe("register should create a user with valid invitation", () => {
|
||||||
test("register should create a user with valid invitation", async () => {
|
test("register should create a user with valid invitation", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = userRouter.createCaller({
|
const caller = userRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -166,7 +166,7 @@ describe("register should create a user with valid invitation", () => {
|
|||||||
"register should throw an error with input %s and date %s if the invitation is invalid",
|
"register should throw an error with input %s and date %s if the invitation is invalid",
|
||||||
async (partialInput, systemTime) => {
|
async (partialInput, systemTime) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = userRouter.createCaller({
|
const caller = userRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -209,7 +209,7 @@ describe("register should create a user with valid invitation", () => {
|
|||||||
describe("editProfile shoud update user", () => {
|
describe("editProfile shoud update user", () => {
|
||||||
test("editProfile should update users and not update emailVerified when email not dirty", async () => {
|
test("editProfile should update users and not update emailVerified when email not dirty", async () => {
|
||||||
// arrange
|
// arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = userRouter.createCaller({
|
const caller = userRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -246,7 +246,7 @@ describe("editProfile shoud update user", () => {
|
|||||||
|
|
||||||
test("editProfile should update users and update emailVerified when email dirty", async () => {
|
test("editProfile should update users and update emailVerified when email dirty", async () => {
|
||||||
// arrange
|
// arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = userRouter.createCaller({
|
const caller = userRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
@@ -282,7 +282,7 @@ describe("editProfile shoud update user", () => {
|
|||||||
|
|
||||||
describe("delete should delete user", () => {
|
describe("delete should delete user", () => {
|
||||||
test("delete should delete user", async () => {
|
test("delete should delete user", async () => {
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const caller = userRouter.createCaller({
|
const caller = userRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
import { describe, expect, test, vi } from "vitest";
|
import { describe, expect, test, vi } from "vitest";
|
||||||
|
|
||||||
import type { Session } from "@homarr/auth";
|
import type { Session } from "@homarr/auth";
|
||||||
import { createId } from "@homarr/common";
|
import { createDbAsync } from "@homarr/db/test";
|
||||||
import type { InferInsertModel } from "@homarr/db";
|
|
||||||
import { apps } from "@homarr/db/schema";
|
|
||||||
import { createDb } from "@homarr/db/test";
|
|
||||||
import * as ping from "@homarr/ping";
|
import * as ping from "@homarr/ping";
|
||||||
|
|
||||||
import { appRouter } from "../../widgets/app";
|
import { appRouter } from "../../widgets/app";
|
||||||
@@ -12,31 +9,22 @@ import { appRouter } from "../../widgets/app";
|
|||||||
// Mock the auth module to return an empty session
|
// Mock the auth module to return an empty session
|
||||||
vi.mock("@homarr/auth", () => ({ auth: () => ({}) as Session }));
|
vi.mock("@homarr/auth", () => ({ auth: () => ({}) as Session }));
|
||||||
vi.mock("@homarr/ping", () => ({ sendPingRequestAsync: async () => await Promise.resolve(null) }));
|
vi.mock("@homarr/ping", () => ({ sendPingRequestAsync: async () => await Promise.resolve(null) }));
|
||||||
vi.mock("../../app/app-access-control", () => ({
|
|
||||||
AppAccessControl: vi.fn(
|
|
||||||
class {
|
|
||||||
canUserSeeAppAsync = async (_: string) => await Promise.resolve(true);
|
|
||||||
canUserSeeAppsAsync = async (_: string[]) => await Promise.resolve(true);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe("ping should call sendPingRequestAsync with url and return result", () => {
|
describe("ping should call sendPingRequestAsync with url and return result", () => {
|
||||||
test("ping with error response should return error and url", async () => {
|
test("ping with error response should return error and url", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
vi.spyOn(ping, "sendPingRequestAsync").mockImplementation(() => Promise.resolve({ error: "error" }));
|
const spy = vi.spyOn(ping, "sendPingRequestAsync");
|
||||||
const url = "http://localhost";
|
const url = "http://localhost";
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const app = createApp({ url });
|
|
||||||
await db.insert(apps).values(app);
|
|
||||||
const caller = appRouter.createCaller({
|
const caller = appRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
session: null,
|
session: null,
|
||||||
});
|
});
|
||||||
|
spy.mockImplementation(() => Promise.resolve({ error: "error" }));
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = await caller.ping({ id: app.id });
|
const result = await caller.ping({ url });
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(result.url).toBe(url);
|
expect(result.url).toBe(url);
|
||||||
@@ -45,32 +33,21 @@ describe("ping should call sendPingRequestAsync with url and return result", ()
|
|||||||
|
|
||||||
test("ping with success response should return statusCode and url", async () => {
|
test("ping with success response should return statusCode and url", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
vi.spyOn(ping, "sendPingRequestAsync").mockImplementation(() =>
|
const spy = vi.spyOn(ping, "sendPingRequestAsync");
|
||||||
Promise.resolve({ statusCode: 200, durationMs: 123 }),
|
|
||||||
);
|
|
||||||
const url = "http://localhost";
|
const url = "http://localhost";
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const app = createApp({ url });
|
|
||||||
await db.insert(apps).values(app);
|
|
||||||
const caller = appRouter.createCaller({
|
const caller = appRouter.createCaller({
|
||||||
db,
|
db,
|
||||||
deviceType: undefined,
|
deviceType: undefined,
|
||||||
session: null,
|
session: null,
|
||||||
});
|
});
|
||||||
|
spy.mockImplementation(() => Promise.resolve({ statusCode: 200, durationMs: 123 }));
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = await caller.ping({ id: app.id });
|
const result = await caller.ping({ url });
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(result.url).toBe(url);
|
expect(result.url).toBe(url);
|
||||||
expect("statusCode" in result).toBe(true);
|
expect("statusCode" in result).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const createApp = ({ url }: { url: string }) =>
|
|
||||||
({
|
|
||||||
id: createId(),
|
|
||||||
iconUrl: "",
|
|
||||||
name: "Test App",
|
|
||||||
href: url,
|
|
||||||
}) satisfies InferInsertModel<typeof apps>;
|
|
||||||
@@ -1,221 +0,0 @@
|
|||||||
import SuperJSON from "superjson";
|
|
||||||
import { describe, expect, test } from "vitest";
|
|
||||||
|
|
||||||
import type { Session } from "@homarr/auth";
|
|
||||||
import { createId } from "@homarr/common";
|
|
||||||
import type { InferInsertModel } from "@homarr/db";
|
|
||||||
import {
|
|
||||||
boardGroupPermissions,
|
|
||||||
boards,
|
|
||||||
boardUserPermissions,
|
|
||||||
groupMembers,
|
|
||||||
groups,
|
|
||||||
items,
|
|
||||||
users,
|
|
||||||
} from "@homarr/db/schema";
|
|
||||||
import { createDb } from "@homarr/db/test";
|
|
||||||
import type { GroupPermissionKey } from "@homarr/definitions";
|
|
||||||
|
|
||||||
import type { WidgetComponentProps } from "../../../../../widgets/src/definition";
|
|
||||||
import { canAccessAllFeedsAsync, restrictUrlsAsync } from "../../widgets/rssFeed";
|
|
||||||
|
|
||||||
const createSession = (permissions: GroupPermissionKey[] = []): Session => ({
|
|
||||||
user: {
|
|
||||||
id: "user-id",
|
|
||||||
colorScheme: "light",
|
|
||||||
permissions,
|
|
||||||
},
|
|
||||||
expires: new Date().toISOString(),
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("rssFeedRouter", () => {
|
|
||||||
describe("canAccessAllFeedsAsync", () => {
|
|
||||||
test("should return false for unauthenticated users", async () => {
|
|
||||||
// Arrange
|
|
||||||
const { callback } = setupAccessCheck();
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = await callback(/* session: */ null);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(result).toBe(false);
|
|
||||||
});
|
|
||||||
test.each([["board-create" as const], ["board-modify-all" as const]])(
|
|
||||||
"should return true for users with %s permission",
|
|
||||||
async (permission) => {
|
|
||||||
// Arrange
|
|
||||||
const { callback } = setupAccessCheck();
|
|
||||||
const session = createSession([permission]);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = await callback(session);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(result).toBe(true);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
test("should return false for authenticated users without any boards or permissions", async () => {
|
|
||||||
// Arrange
|
|
||||||
const { callback, db } = setupAccessCheck();
|
|
||||||
const session = createSession();
|
|
||||||
await db.insert(users).values({
|
|
||||||
id: session.user.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = await callback(session);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(result).toBe(false);
|
|
||||||
});
|
|
||||||
test("should return true for authenticated users that own at least one board", async () => {
|
|
||||||
// Arrange
|
|
||||||
const { callback, db } = setupAccessCheck();
|
|
||||||
const session = createSession();
|
|
||||||
await db.insert(users).values({
|
|
||||||
id: session.user.id,
|
|
||||||
});
|
|
||||||
await db.insert(boards).values({
|
|
||||||
id: createId(),
|
|
||||||
name: "test",
|
|
||||||
creatorId: session.user.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = await callback(session);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(result).toBe(true);
|
|
||||||
});
|
|
||||||
test.each([["modify" as const], ["full" as const]])(
|
|
||||||
"should return true for authenticated users that have %s permissions on at least one board",
|
|
||||||
async (permission) => {
|
|
||||||
// Arrange
|
|
||||||
const { callback, db } = setupAccessCheck();
|
|
||||||
const session = createSession();
|
|
||||||
await db.insert(users).values({
|
|
||||||
id: session.user.id,
|
|
||||||
});
|
|
||||||
const boardId = createId();
|
|
||||||
await db.insert(boards).values({
|
|
||||||
id: boardId,
|
|
||||||
name: "test",
|
|
||||||
});
|
|
||||||
await db.insert(boardUserPermissions).values({
|
|
||||||
boardId,
|
|
||||||
permission,
|
|
||||||
userId: session.user.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = await callback(session);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(result).toBe(true);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
test.each([["modify" as const], ["full" as const]])(
|
|
||||||
"should return true for authenticated users that have %s permissions through group on at least one board",
|
|
||||||
async (permission) => {
|
|
||||||
// Arrange
|
|
||||||
const { callback, db } = setupAccessCheck();
|
|
||||||
const session = createSession();
|
|
||||||
await db.insert(users).values({
|
|
||||||
id: session.user.id,
|
|
||||||
});
|
|
||||||
const boardId = createId();
|
|
||||||
await db.insert(boards).values({
|
|
||||||
id: boardId,
|
|
||||||
name: "test",
|
|
||||||
});
|
|
||||||
const groupId = createId();
|
|
||||||
await db.insert(groups).values({
|
|
||||||
id: groupId,
|
|
||||||
name: "test-group",
|
|
||||||
position: 0,
|
|
||||||
});
|
|
||||||
await db.insert(groupMembers).values({
|
|
||||||
groupId,
|
|
||||||
userId: session.user.id,
|
|
||||||
});
|
|
||||||
await db.insert(boardGroupPermissions).values({
|
|
||||||
boardId,
|
|
||||||
groupId,
|
|
||||||
permission,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = await callback(session);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(result).toBe(true);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("restrictUrlsAsync", () => {
|
|
||||||
test("should return empty array if there are no rss feed items in the database", async () => {
|
|
||||||
// Arrange
|
|
||||||
const { callback } = await setupUrlRestrictionAsync([]);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = await callback(["http://example.com/feed"]);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(result).toEqual([]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should return only the URLs that are present in the database", async () => {
|
|
||||||
// Arrange
|
|
||||||
const { callback } = await setupUrlRestrictionAsync(["http://example.com/feed"]);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = await callback(["http://example.com/feed", "http://not-in-db.com/feed"]);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(result).toEqual(["http://example.com/feed"]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function setupAccessCheck() {
|
|
||||||
const db = createDb();
|
|
||||||
|
|
||||||
return {
|
|
||||||
callback: (session: Session | null) => canAccessAllFeedsAsync(db, session),
|
|
||||||
db,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function setupUrlRestrictionAsync(dbUrls: string[]) {
|
|
||||||
const db = createDb();
|
|
||||||
const boardId = createId();
|
|
||||||
await db.insert(boards).values({
|
|
||||||
id: boardId,
|
|
||||||
name: "test",
|
|
||||||
});
|
|
||||||
if (dbUrls.length >= 1) {
|
|
||||||
await db.insert(items).values(
|
|
||||||
dbUrls.map(
|
|
||||||
(url) =>
|
|
||||||
({
|
|
||||||
id: createId(),
|
|
||||||
kind: "rssFeed",
|
|
||||||
boardId,
|
|
||||||
options: SuperJSON.stringify({
|
|
||||||
feedUrls: [url],
|
|
||||||
enableRtl: false,
|
|
||||||
hideDescription: false,
|
|
||||||
textLinesClamp: 3,
|
|
||||||
maximumAmountPosts: 5,
|
|
||||||
} satisfies WidgetComponentProps<"rssFeed">["options"]),
|
|
||||||
}) satisfies InferInsertModel<typeof items>,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
callback: (urls: string[]) => restrictUrlsAsync(db, urls),
|
|
||||||
db,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
import { TRPCError } from "@trpc/server";
|
import { TRPCError } from "@trpc/server";
|
||||||
import type { MySqlRawQueryResult } from "drizzle-orm/mysql2";
|
|
||||||
import type { QueryResult } from "pg";
|
|
||||||
import { z } from "zod/v4";
|
import { z } from "zod/v4";
|
||||||
|
|
||||||
import { createSaltAsync, hashPasswordAsync } from "@homarr/auth";
|
import { createSaltAsync, hashPasswordAsync } from "@homarr/auth";
|
||||||
import { createId } from "@homarr/common";
|
import { createId } from "@homarr/common";
|
||||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||||
import type { Database } from "@homarr/db";
|
import type { Database } from "@homarr/db";
|
||||||
import { and, eq, handleTransactionsAsync, like } from "@homarr/db";
|
import { and, eq, like } from "@homarr/db";
|
||||||
import { getMaxGroupPositionAsync } from "@homarr/db/queries";
|
import { getMaxGroupPositionAsync } from "@homarr/db/queries";
|
||||||
import { boards, groupMembers, groupPermissions, groups, invites, users } from "@homarr/db/schema";
|
import { boards, groupMembers, groupPermissions, groups, invites, users } from "@homarr/db/schema";
|
||||||
import { selectUserSchema } from "@homarr/db/validationSchemas";
|
import { selectUserSchema } from "@homarr/db/validationSchemas";
|
||||||
@@ -92,55 +90,10 @@ export const userRouter = createTRPCRouter({
|
|||||||
|
|
||||||
await checkUsernameAlreadyTakenAndThrowAsync(ctx.db, "credentials", input.username);
|
await checkUsernameAlreadyTakenAndThrowAsync(ctx.db, "credentials", input.username);
|
||||||
|
|
||||||
const salt = await createSaltAsync();
|
await createUserAsync(ctx.db, input);
|
||||||
const hashedPassword = await hashPasswordAsync(input.password, salt);
|
|
||||||
|
|
||||||
const userId = createId();
|
|
||||||
const user = {
|
|
||||||
id: userId,
|
|
||||||
name: input.username,
|
|
||||||
password: hashedPassword,
|
|
||||||
salt,
|
|
||||||
};
|
|
||||||
|
|
||||||
await handleTransactionsAsync(ctx.db, {
|
|
||||||
async handleAsync(db, schema) {
|
|
||||||
await db.transaction(async (trx) => {
|
|
||||||
await trx.insert(schema.users).values(user);
|
|
||||||
|
|
||||||
// Delete invite as it's used
|
// Delete invite as it's used
|
||||||
const queryResult = (await trx.delete(schema.invites).where(inviteWhere)) as
|
await ctx.db.delete(invites).where(inviteWhere);
|
||||||
| QueryResult
|
|
||||||
| MySqlRawQueryResult;
|
|
||||||
let count = 0;
|
|
||||||
if (Array.isArray(queryResult)) {
|
|
||||||
count = queryResult[0].affectedRows;
|
|
||||||
} else {
|
|
||||||
count = queryResult.rowCount ?? 0;
|
|
||||||
}
|
|
||||||
if (count === 0) {
|
|
||||||
throw new TRPCError({
|
|
||||||
code: "FORBIDDEN",
|
|
||||||
message: "Invalid invite",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
handleSync(db) {
|
|
||||||
db.transaction((trx) => {
|
|
||||||
trx.insert(users).values(user).run();
|
|
||||||
// Delete invite as it's used
|
|
||||||
const result = trx.delete(invites).where(inviteWhere).run();
|
|
||||||
|
|
||||||
if (result.changes === 0) {
|
|
||||||
throw new TRPCError({
|
|
||||||
code: "FORBIDDEN",
|
|
||||||
message: "Invalid invite",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}),
|
}),
|
||||||
create: permissionRequiredProcedure
|
create: permissionRequiredProcedure
|
||||||
.requiresPermission("admin")
|
.requiresPermission("admin")
|
||||||
|
|||||||
@@ -1,97 +1,43 @@
|
|||||||
import { TRPCError } from "@trpc/server";
|
|
||||||
import { observable } from "@trpc/server/observable";
|
import { observable } from "@trpc/server/observable";
|
||||||
import { z } from "zod/v4";
|
import { z } from "zod/v4";
|
||||||
|
|
||||||
import { getServerSettingByKeyAsync } from "@homarr/db/queries";
|
|
||||||
import { sendPingRequestAsync } from "@homarr/ping";
|
import { sendPingRequestAsync } from "@homarr/ping";
|
||||||
import { pingChannel, pingUrlChannel } from "@homarr/redis";
|
import { pingChannel, pingUrlChannel } from "@homarr/redis";
|
||||||
|
|
||||||
import { createTRPCRouter, publicProcedure } from "../../trpc";
|
import { createTRPCRouter, publicProcedure } from "../../trpc";
|
||||||
import { AppRepository } from "../app";
|
|
||||||
|
|
||||||
export const appRouter = createTRPCRouter({
|
export const appRouter = createTRPCRouter({
|
||||||
ping: publicProcedure.input(z.object({ id: z.string() })).query(async ({ ctx, input }) => {
|
ping: publicProcedure.input(z.object({ url: z.string() })).query(async ({ input }) => {
|
||||||
const boardSettings = await getServerSettingByKeyAsync(ctx.db, "board");
|
const pingResult = await sendPingRequestAsync(input.url);
|
||||||
if (boardSettings.forceDisableStatus) {
|
|
||||||
throw new TRPCError({
|
|
||||||
code: "FORBIDDEN",
|
|
||||||
message: "Ping functionality is disabled by server settings",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const repository = new AppRepository(ctx.db, ctx.session?.user ?? null);
|
|
||||||
const app = await repository.getByIdAsync(input.id);
|
|
||||||
|
|
||||||
if (!app) {
|
|
||||||
throw new TRPCError({
|
|
||||||
code: "NOT_FOUND",
|
|
||||||
message: "App not found",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const pingUrl = app.pingUrl ?? app.href;
|
|
||||||
|
|
||||||
if (!pingUrl) {
|
|
||||||
throw new TRPCError({
|
|
||||||
code: "CONFLICT",
|
|
||||||
message: "No URL to ping configured for this app",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const pingResult = await sendPingRequestAsync(pingUrl);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
url: pingUrl,
|
url: input.url,
|
||||||
...pingResult,
|
...pingResult,
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
updatedPing: publicProcedure
|
updatedPing: publicProcedure
|
||||||
.input(
|
.input(
|
||||||
z.object({
|
z.object({
|
||||||
id: z.string(),
|
url: z.string(),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.subscription(async ({ ctx, input }) => {
|
.subscription(async ({ input }) => {
|
||||||
const boardSettings = await getServerSettingByKeyAsync(ctx.db, "board");
|
await pingUrlChannel.addAsync(input.url);
|
||||||
if (boardSettings.forceDisableStatus) {
|
|
||||||
throw new TRPCError({
|
|
||||||
code: "FORBIDDEN",
|
|
||||||
message: "Ping functionality is disabled by server settings",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const repository = new AppRepository(ctx.db, ctx.session?.user ?? null);
|
const pingResult = await sendPingRequestAsync(input.url);
|
||||||
const app = await repository.getByIdAsync(input.id);
|
|
||||||
|
|
||||||
if (!app) {
|
|
||||||
throw new TRPCError({
|
|
||||||
code: "NOT_FOUND",
|
|
||||||
message: "App not found",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const pingUrl = app.pingUrl ?? app.href;
|
|
||||||
|
|
||||||
if (!pingUrl) {
|
|
||||||
throw new TRPCError({
|
|
||||||
code: "CONFLICT",
|
|
||||||
message: "No URL to ping configured for this app",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
await pingUrlChannel.addAsync(pingUrl);
|
|
||||||
|
|
||||||
return observable<{ url: string; statusCode: number; durationMs: number } | { url: string; error: string }>(
|
return observable<{ url: string; statusCode: number; durationMs: number } | { url: string; error: string }>(
|
||||||
(emit) => {
|
(emit) => {
|
||||||
|
emit.next({ url: input.url, ...pingResult });
|
||||||
const unsubscribe = pingChannel.subscribe((message) => {
|
const unsubscribe = pingChannel.subscribe((message) => {
|
||||||
// Only emit if same url
|
// Only emit if same url
|
||||||
if (message.url !== pingUrl) return;
|
if (message.url !== input.url) return;
|
||||||
emit.next(message);
|
emit.next(message);
|
||||||
});
|
});
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
unsubscribe();
|
unsubscribe();
|
||||||
void pingUrlChannel.removeAsync(pingUrl);
|
void pingUrlChannel.removeAsync(input.url);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
import { observable } from "@trpc/server/observable";
|
|
||||||
|
|
||||||
import type { CoolifyInstanceInfo } from "@homarr/integrations/types";
|
|
||||||
import { coolifyRequestHandler } from "@homarr/request-handler/coolify";
|
|
||||||
|
|
||||||
import { createManyIntegrationMiddleware } from "../../middlewares/integration";
|
|
||||||
import { createTRPCRouter, publicProcedure } from "../../trpc";
|
|
||||||
|
|
||||||
export const coolifyRouter = createTRPCRouter({
|
|
||||||
getInstancesInfo: publicProcedure
|
|
||||||
.concat(createManyIntegrationMiddleware("query", "coolify"))
|
|
||||||
.query(async ({ ctx }) => {
|
|
||||||
const results = await Promise.all(
|
|
||||||
ctx.integrations.map(async (integration) => {
|
|
||||||
const innerHandler = coolifyRequestHandler.handler(integration, {});
|
|
||||||
const { data, timestamp } = await innerHandler.getCachedOrUpdatedDataAsync({ forceUpdate: false });
|
|
||||||
|
|
||||||
return {
|
|
||||||
integrationId: integration.id,
|
|
||||||
integrationName: integration.name,
|
|
||||||
integrationUrl: integration.url,
|
|
||||||
instanceInfo: data,
|
|
||||||
updatedAt: timestamp,
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}),
|
|
||||||
subscribeInstancesInfo: publicProcedure
|
|
||||||
.concat(createManyIntegrationMiddleware("query", "coolify"))
|
|
||||||
.subscription(({ ctx }) => {
|
|
||||||
return observable<{ integrationId: string; instanceInfo: CoolifyInstanceInfo; timestamp: Date }>((emit) => {
|
|
||||||
const unsubscribes = ctx.integrations.map((integration) => {
|
|
||||||
const innerHandler = coolifyRequestHandler.handler(integration, {});
|
|
||||||
return innerHandler.subscribe((instanceInfo) => {
|
|
||||||
emit.next({
|
|
||||||
integrationId: integration.id,
|
|
||||||
instanceInfo,
|
|
||||||
timestamp: new Date(),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
unsubscribes.forEach((unsubscribe) => unsubscribe());
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
@@ -9,9 +9,7 @@ import { createTRPCRouter, publicProcedure } from "../../trpc";
|
|||||||
|
|
||||||
export const healthMonitoringRouter = createTRPCRouter({
|
export const healthMonitoringRouter = createTRPCRouter({
|
||||||
getSystemHealthStatus: publicProcedure
|
getSystemHealthStatus: publicProcedure
|
||||||
.concat(
|
.concat(createManyIntegrationMiddleware("query", "openmediavault", "dashDot", "truenas", "unraid", "mock"))
|
||||||
createManyIntegrationMiddleware("query", "openmediavault", "dashDot", "truenas", "unraid", "glances", "mock"),
|
|
||||||
)
|
|
||||||
.query(async ({ ctx }) => {
|
.query(async ({ ctx }) => {
|
||||||
return await Promise.all(
|
return await Promise.all(
|
||||||
ctx.integrations.map(async (integration) => {
|
ctx.integrations.map(async (integration) => {
|
||||||
@@ -28,9 +26,7 @@ export const healthMonitoringRouter = createTRPCRouter({
|
|||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
subscribeSystemHealthStatus: publicProcedure
|
subscribeSystemHealthStatus: publicProcedure
|
||||||
.concat(
|
.concat(createManyIntegrationMiddleware("query", "openmediavault", "dashDot", "truenas", "unraid", "mock"))
|
||||||
createManyIntegrationMiddleware("query", "openmediavault", "dashDot", "truenas", "unraid", "glances", "mock"),
|
|
||||||
)
|
|
||||||
.subscription(({ ctx }) => {
|
.subscription(({ ctx }) => {
|
||||||
return observable<{ integrationId: string; healthInfo: SystemHealthMonitoring; timestamp: Date }>((emit) => {
|
return observable<{ integrationId: string; healthInfo: SystemHealthMonitoring; timestamp: Date }>((emit) => {
|
||||||
const unsubscribes: (() => void)[] = [];
|
const unsubscribes: (() => void)[] = [];
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
import { z } from "zod/v4";
|
|
||||||
|
|
||||||
import { getIntegrationKindsByCategory } from "@homarr/definitions";
|
|
||||||
import {
|
|
||||||
immichAlbumRequestHandler,
|
|
||||||
immichAlbumsRequestHandler,
|
|
||||||
immichStatsRequestHandler,
|
|
||||||
} from "@homarr/request-handler/immich";
|
|
||||||
|
|
||||||
import type { IntegrationAction } from "../../middlewares/integration";
|
|
||||||
import { createOneIntegrationMiddleware } from "../../middlewares/integration";
|
|
||||||
import { createTRPCRouter, publicProcedure } from "../../trpc";
|
|
||||||
|
|
||||||
const createImmichIntegrationMiddleware = (action: IntegrationAction) =>
|
|
||||||
createOneIntegrationMiddleware(action, ...getIntegrationKindsByCategory("photoService"));
|
|
||||||
|
|
||||||
export const immichRouter = createTRPCRouter({
|
|
||||||
getServerStats: publicProcedure.concat(createImmichIntegrationMiddleware("query")).query(async ({ ctx }) => {
|
|
||||||
const innerHandler = immichStatsRequestHandler.handler(ctx.integration, {});
|
|
||||||
const data = await innerHandler.getCachedOrUpdatedDataAsync({ forceUpdate: false });
|
|
||||||
return data.data;
|
|
||||||
}),
|
|
||||||
|
|
||||||
getAlbum: publicProcedure
|
|
||||||
.concat(createImmichIntegrationMiddleware("query"))
|
|
||||||
.input(
|
|
||||||
z.object({
|
|
||||||
albumId: z.string(),
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.query(async ({ ctx, input }) => {
|
|
||||||
const innerHandler = immichAlbumRequestHandler.handler(ctx.integration, { albumId: input.albumId });
|
|
||||||
const data = await innerHandler.getCachedOrUpdatedDataAsync({ forceUpdate: false });
|
|
||||||
return data.data;
|
|
||||||
}),
|
|
||||||
|
|
||||||
getAlbums: publicProcedure.concat(createImmichIntegrationMiddleware("query")).query(async ({ ctx }) => {
|
|
||||||
const innerHandler = immichAlbumsRequestHandler.handler(ctx.integration, {});
|
|
||||||
const data = await innerHandler.getCachedOrUpdatedDataAsync({ forceUpdate: false });
|
|
||||||
return data.data;
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
@@ -1,30 +1,46 @@
|
|||||||
import { lazy } from "@trpc/server";
|
|
||||||
|
|
||||||
import { createTRPCRouter } from "../../trpc";
|
import { createTRPCRouter } from "../../trpc";
|
||||||
|
import { appRouter } from "./app";
|
||||||
|
import { calendarRouter } from "./calendar";
|
||||||
|
import { dnsHoleRouter } from "./dns-hole";
|
||||||
|
import { downloadsRouter } from "./downloads";
|
||||||
|
import { firewallRouter } from "./firewall";
|
||||||
|
import { healthMonitoringRouter } from "./health-monitoring";
|
||||||
|
import { indexerManagerRouter } from "./indexer-manager";
|
||||||
|
import { mediaReleaseRouter } from "./media-release";
|
||||||
|
import { mediaRequestsRouter } from "./media-requests";
|
||||||
|
import { mediaServerRouter } from "./media-server";
|
||||||
|
import { mediaTranscodingRouter } from "./media-transcoding";
|
||||||
|
import { minecraftRouter } from "./minecraft";
|
||||||
|
import { networkControllerRouter } from "./network-controller";
|
||||||
|
import { notebookRouter } from "./notebook";
|
||||||
|
import { notificationsRouter } from "./notifications";
|
||||||
|
import { optionsRouter } from "./options";
|
||||||
|
import { releasesRouter } from "./releases";
|
||||||
|
import { rssFeedRouter } from "./rssFeed";
|
||||||
|
import { smartHomeRouter } from "./smart-home";
|
||||||
|
import { stockPriceRouter } from "./stocks";
|
||||||
|
import { weatherRouter } from "./weather";
|
||||||
|
|
||||||
export const widgetRouter = createTRPCRouter({
|
export const widgetRouter = createTRPCRouter({
|
||||||
coolify: lazy(() => import("./coolify").then((mod) => mod.coolifyRouter)),
|
notebook: notebookRouter,
|
||||||
immich: lazy(() => import("./immich").then((mod) => mod.immichRouter)),
|
weather: weatherRouter,
|
||||||
notebook: lazy(() => import("./notebook").then((mod) => mod.notebookRouter)),
|
app: appRouter,
|
||||||
weather: lazy(() => import("./weather").then((mod) => mod.weatherRouter)),
|
dnsHole: dnsHoleRouter,
|
||||||
app: lazy(() => import("./app").then((mod) => mod.appRouter)),
|
smartHome: smartHomeRouter,
|
||||||
dnsHole: lazy(() => import("./dns-hole").then((mod) => mod.dnsHoleRouter)),
|
stockPrice: stockPriceRouter,
|
||||||
smartHome: lazy(() => import("./smart-home").then((mod) => mod.smartHomeRouter)),
|
mediaServer: mediaServerRouter,
|
||||||
stockPrice: lazy(() => import("./stocks").then((mod) => mod.stockPriceRouter)),
|
mediaRelease: mediaReleaseRouter,
|
||||||
mediaServer: lazy(() => import("./media-server").then((mod) => mod.mediaServerRouter)),
|
calendar: calendarRouter,
|
||||||
mediaRelease: lazy(() => import("./media-release").then((mod) => mod.mediaReleaseRouter)),
|
downloads: downloadsRouter,
|
||||||
calendar: lazy(() => import("./calendar").then((mod) => mod.calendarRouter)),
|
mediaRequests: mediaRequestsRouter,
|
||||||
downloads: lazy(() => import("./downloads").then((mod) => mod.downloadsRouter)),
|
rssFeed: rssFeedRouter,
|
||||||
mediaRequests: lazy(() => import("./media-requests").then((mod) => mod.mediaRequestsRouter)),
|
indexerManager: indexerManagerRouter,
|
||||||
rssFeed: lazy(() => import("./rssFeed").then((mod) => mod.rssFeedRouter)),
|
healthMonitoring: healthMonitoringRouter,
|
||||||
indexerManager: lazy(() => import("./indexer-manager").then((mod) => mod.indexerManagerRouter)),
|
mediaTranscoding: mediaTranscodingRouter,
|
||||||
healthMonitoring: lazy(() => import("./health-monitoring").then((mod) => mod.healthMonitoringRouter)),
|
minecraft: minecraftRouter,
|
||||||
mediaTranscoding: lazy(() => import("./media-transcoding").then((mod) => mod.mediaTranscodingRouter)),
|
options: optionsRouter,
|
||||||
minecraft: lazy(() => import("./minecraft").then((mod) => mod.minecraftRouter)),
|
releases: releasesRouter,
|
||||||
options: lazy(() => import("./options").then((mod) => mod.optionsRouter)),
|
networkController: networkControllerRouter,
|
||||||
releases: lazy(() => import("./releases").then((mod) => mod.releasesRouter)),
|
firewall: firewallRouter,
|
||||||
networkController: lazy(() => import("./network-controller").then((mod) => mod.networkControllerRouter)),
|
notifications: notificationsRouter,
|
||||||
firewall: lazy(() => import("./firewall").then((mod) => mod.firewallRouter)),
|
|
||||||
notifications: lazy(() => import("./notifications").then((mod) => mod.notificationsRouter)),
|
|
||||||
tracearr: lazy(() => import("./tracearr").then((mod) => mod.tracearrRouter)),
|
|
||||||
});
|
});
|
||||||
@@ -1,30 +1,20 @@
|
|||||||
import SuperJSON from "superjson";
|
|
||||||
import { z } from "zod/v4";
|
import { z } from "zod/v4";
|
||||||
|
|
||||||
import type { Session } from "@homarr/auth";
|
|
||||||
import type { Database } from "@homarr/db";
|
|
||||||
import { eq } from "@homarr/db";
|
|
||||||
import { items, users } from "@homarr/db/schema";
|
|
||||||
import { rssFeedsRequestHandler } from "@homarr/request-handler/rss-feeds";
|
import { rssFeedsRequestHandler } from "@homarr/request-handler/rss-feeds";
|
||||||
|
|
||||||
import type { WidgetComponentProps } from "../../../../widgets/src";
|
|
||||||
import { createTRPCRouter, publicProcedure } from "../../trpc";
|
import { createTRPCRouter, publicProcedure } from "../../trpc";
|
||||||
|
|
||||||
export const rssFeedRouter = createTRPCRouter({
|
export const rssFeedRouter = createTRPCRouter({
|
||||||
getFeeds: publicProcedure
|
getFeeds: publicProcedure
|
||||||
.input(
|
.input(
|
||||||
z.object({
|
z.object({
|
||||||
urls: z.array(z.string()).max(100),
|
urls: z.array(z.string()),
|
||||||
maximumAmountPosts: z.number(),
|
maximumAmountPosts: z.number(),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.query(async ({ ctx, input }) => {
|
.query(async ({ input }) => {
|
||||||
const urls = (await canAccessAllFeedsAsync(ctx.db, ctx.session))
|
|
||||||
? input.urls
|
|
||||||
: await restrictUrlsAsync(ctx.db, input.urls);
|
|
||||||
|
|
||||||
const rssFeeds = await Promise.all(
|
const rssFeeds = await Promise.all(
|
||||||
urls.map(async (url) => {
|
input.urls.map(async (url) => {
|
||||||
const innerHandler = rssFeedsRequestHandler.handler({
|
const innerHandler = rssFeedsRequestHandler.handler({
|
||||||
url,
|
url,
|
||||||
count: input.maximumAmountPosts,
|
count: input.maximumAmountPosts,
|
||||||
@@ -45,63 +35,3 @@ export const rssFeedRouter = createTRPCRouter({
|
|||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export async function canAccessAllFeedsAsync(db: Database, session: Session | null) {
|
|
||||||
// Unauthenticated users can never access all feeds
|
|
||||||
if (!session) return false;
|
|
||||||
// Users with those permissions can modify a board and therefore add a rss feed widget with any feed url
|
|
||||||
if (session.user.permissions.includes("board-create") || session.user.permissions.includes("board-modify-all")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const user = await db.query.users.findFirst({
|
|
||||||
where: eq(users.id, session.user.id),
|
|
||||||
with: {
|
|
||||||
boards: {
|
|
||||||
columns: { id: true },
|
|
||||||
},
|
|
||||||
boardPermissions: true,
|
|
||||||
groups: {
|
|
||||||
with: {
|
|
||||||
group: {
|
|
||||||
with: { boardPermissions: true },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Should never happen as the user is authenticated, but just in case
|
|
||||||
if (!user) return false;
|
|
||||||
|
|
||||||
// If user is owner of any board he has full access and can therefore create widgets with any feed url
|
|
||||||
if (user.boards.length >= 1) return true;
|
|
||||||
|
|
||||||
// If user has direct permissions on any board that allow modifying it, he can add a rss feed widget with any feed url
|
|
||||||
if (user.boardPermissions.some(({ permission }) => permission === "modify" || permission === "full")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If user is in a group that has permissions on any board that allow modifying it, he can add a rss feed widget with any feed url
|
|
||||||
if (
|
|
||||||
user.groups.some(({ group }) =>
|
|
||||||
group.boardPermissions.some(({ permission }) => permission === "modify" || permission === "full"),
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fallback to not allowing access to all feeds
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function restrictUrlsAsync(db: Database, urls: string[]) {
|
|
||||||
const rssFeedItems = await db.query.items.findMany({
|
|
||||||
where: eq(items.kind, "rssFeed"),
|
|
||||||
});
|
|
||||||
|
|
||||||
const configuredUrls = rssFeedItems
|
|
||||||
.map((item) => SuperJSON.parse<WidgetComponentProps<"rssFeed">["options"]>(item.options))
|
|
||||||
.flatMap((options) => options.feedUrls);
|
|
||||||
return urls.filter((url) => configuredUrls.includes(url));
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
import { observable } from "@trpc/server/observable";
|
|
||||||
|
|
||||||
import type { TracearrDashboardData } from "@homarr/integrations/types";
|
|
||||||
import { tracearrRequestHandler } from "@homarr/request-handler/tracearr";
|
|
||||||
|
|
||||||
import { createManyIntegrationMiddleware } from "../../middlewares/integration";
|
|
||||||
import { createTRPCRouter, publicProcedure } from "../../trpc";
|
|
||||||
|
|
||||||
export const tracearrRouter = createTRPCRouter({
|
|
||||||
getDashboard: publicProcedure.concat(createManyIntegrationMiddleware("query", "tracearr")).query(async ({ ctx }) => {
|
|
||||||
const results = await Promise.all(
|
|
||||||
ctx.integrations.map(async (integration) => {
|
|
||||||
const innerHandler = tracearrRequestHandler.handler(integration, {});
|
|
||||||
const { data, timestamp } = await innerHandler.getCachedOrUpdatedDataAsync({ forceUpdate: false });
|
|
||||||
|
|
||||||
return {
|
|
||||||
integrationId: integration.id,
|
|
||||||
integrationName: integration.name,
|
|
||||||
integrationUrl: integration.url,
|
|
||||||
dashboard: data,
|
|
||||||
updatedAt: timestamp,
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}),
|
|
||||||
subscribeToDashboard: publicProcedure
|
|
||||||
.concat(createManyIntegrationMiddleware("query", "tracearr"))
|
|
||||||
.subscription(({ ctx }) => {
|
|
||||||
return observable<{ integrationId: string; dashboard: TracearrDashboardData; timestamp: Date }>((emit) => {
|
|
||||||
const unsubscribes = ctx.integrations.map((integration) => {
|
|
||||||
const innerHandler = tracearrRequestHandler.handler(integration, {});
|
|
||||||
return innerHandler.subscribe((dashboard) => {
|
|
||||||
emit.next({
|
|
||||||
integrationId: integration.id,
|
|
||||||
dashboard,
|
|
||||||
timestamp: new Date(),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
unsubscribes.forEach((unsubscribe) => unsubscribe());
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
@@ -34,7 +34,7 @@ const logger = createLogger({ module: "trpc" });
|
|||||||
*
|
*
|
||||||
* @see https://trpc.io/docs/server/context
|
* @see https://trpc.io/docs/server/context
|
||||||
*/
|
*/
|
||||||
export const createTRPCContext = (opts: { headers: Headers; session: Session | null; jobManager?: any }) => {
|
export const createTRPCContext = (opts: { headers: Headers; session: Session | null }) => {
|
||||||
const session = opts.session;
|
const session = opts.session;
|
||||||
const source = opts.headers.get("x-trpc-source") ?? "unknown";
|
const source = opts.headers.get("x-trpc-source") ?? "unknown";
|
||||||
|
|
||||||
@@ -44,7 +44,6 @@ export const createTRPCContext = (opts: { headers: Headers; session: Session | n
|
|||||||
session,
|
session,
|
||||||
deviceType: userAgent(opts.headers).device.type,
|
deviceType: userAgent(opts.headers).device.type,
|
||||||
db,
|
db,
|
||||||
jobManager: opts.jobManager,
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -33,11 +33,11 @@
|
|||||||
"@homarr/validation": "workspace:^0.1.0",
|
"@homarr/validation": "workspace:^0.1.0",
|
||||||
"bcrypt": "^6.0.0",
|
"bcrypt": "^6.0.0",
|
||||||
"cookies": "^0.9.1",
|
"cookies": "^0.9.1",
|
||||||
"ldapts": "8.1.7",
|
"ldapts": "8.1.3",
|
||||||
"next": "16.2.0",
|
"next": "16.1.1",
|
||||||
"next-auth": "5.0.0-beta.30",
|
"next-auth": "5.0.0-beta.30",
|
||||||
"react": "19.2.4",
|
"react": "19.2.3",
|
||||||
"react-dom": "19.2.4",
|
"react-dom": "19.2.3",
|
||||||
"zod": "^4.2.1"
|
"zod": "^4.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -46,8 +46,8 @@
|
|||||||
"@homarr/tsconfig": "workspace:^0.1.0",
|
"@homarr/tsconfig": "workspace:^0.1.0",
|
||||||
"@types/bcrypt": "6.0.0",
|
"@types/bcrypt": "6.0.0",
|
||||||
"@types/cookies": "0.9.2",
|
"@types/cookies": "0.9.2",
|
||||||
"eslint": "^9.39.4",
|
"eslint": "^9.39.2",
|
||||||
"prettier": "^3.8.1",
|
"prettier": "^3.7.4",
|
||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ import { describe, expect, test, vi } from "vitest";
|
|||||||
import { createId } from "@homarr/common";
|
import { createId } from "@homarr/common";
|
||||||
import type { InferInsertModel } from "@homarr/db";
|
import type { InferInsertModel } from "@homarr/db";
|
||||||
import { boardGroupPermissions, boards, boardUserPermissions, groupMembers, groups, users } from "@homarr/db/schema";
|
import { boardGroupPermissions, boards, boardUserPermissions, groupMembers, groups, users } from "@homarr/db/schema";
|
||||||
import { createDb } from "@homarr/db/test";
|
import { createDbAsync } from "@homarr/db/test";
|
||||||
|
|
||||||
import * as integrationPermissions from "../integration-permissions";
|
import * as integrationPermissions from "../integration-permissions";
|
||||||
import { hasQueryAccessToIntegrationsAsync } from "../integration-query-permissions";
|
import { hasQueryAccessToIntegrationsAsync } from "../integration-query-permissions";
|
||||||
@@ -22,7 +22,7 @@ const createSession = (user: Partial<Session["user"]>): Session => ({
|
|||||||
describe("hasQueryAccessToIntegrationsAsync should check if the user has query access to the specified integrations", () => {
|
describe("hasQueryAccessToIntegrationsAsync should check if the user has query access to the specified integrations", () => {
|
||||||
test("should return true if the user has the board-view-all permission and the integrations are used anywhere", async () => {
|
test("should return true if the user has the board-view-all permission and the integrations are used anywhere", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const session = createSession({
|
const session = createSession({
|
||||||
permissions: ["board-view-all"],
|
permissions: ["board-view-all"],
|
||||||
});
|
});
|
||||||
@@ -50,7 +50,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query a
|
|||||||
|
|
||||||
test("should return true if the user has the board-view-all permission, the first integration is used and the second one he has use access", async () => {
|
test("should return true if the user has the board-view-all permission, the first integration is used and the second one he has use access", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const session = createSession({
|
const session = createSession({
|
||||||
permissions: ["board-view-all"],
|
permissions: ["board-view-all"],
|
||||||
});
|
});
|
||||||
@@ -84,7 +84,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query a
|
|||||||
|
|
||||||
test("should return true if the user has use access to all integrations", async () => {
|
test("should return true if the user has use access to all integrations", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const session = createSession({});
|
const session = createSession({});
|
||||||
const spy = vi.spyOn(integrationPermissions, "constructIntegrationPermissions");
|
const spy = vi.spyOn(integrationPermissions, "constructIntegrationPermissions");
|
||||||
spy.mockReturnValue({
|
spy.mockReturnValue({
|
||||||
@@ -116,7 +116,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query a
|
|||||||
|
|
||||||
test("should return true if the user has user permission to access to at least one board of each integration", async () => {
|
test("should return true if the user has user permission to access to at least one board of each integration", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const session = createSession({});
|
const session = createSession({});
|
||||||
await db.insert(users).values({ id: session.user.id });
|
await db.insert(users).values({ id: session.user.id });
|
||||||
const spy = vi.spyOn(integrationPermissions, "constructIntegrationPermissions");
|
const spy = vi.spyOn(integrationPermissions, "constructIntegrationPermissions");
|
||||||
@@ -168,7 +168,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query a
|
|||||||
|
|
||||||
test("should return false if the user has user permission to access board of first integration but not of second one", async () => {
|
test("should return false if the user has user permission to access board of first integration but not of second one", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const session = createSession({});
|
const session = createSession({});
|
||||||
await db.insert(users).values({ id: session.user.id });
|
await db.insert(users).values({ id: session.user.id });
|
||||||
const spy = vi.spyOn(integrationPermissions, "constructIntegrationPermissions");
|
const spy = vi.spyOn(integrationPermissions, "constructIntegrationPermissions");
|
||||||
@@ -215,7 +215,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query a
|
|||||||
|
|
||||||
test("should return true if the user has group permission to access to at least one board of each integration", async () => {
|
test("should return true if the user has group permission to access to at least one board of each integration", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const session = createSession({});
|
const session = createSession({});
|
||||||
await db.insert(users).values({ id: session.user.id });
|
await db.insert(users).values({ id: session.user.id });
|
||||||
const spy = vi.spyOn(integrationPermissions, "constructIntegrationPermissions");
|
const spy = vi.spyOn(integrationPermissions, "constructIntegrationPermissions");
|
||||||
@@ -269,7 +269,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query a
|
|||||||
|
|
||||||
test("should return false if the user has group permission to access board of first integration but not of second one", async () => {
|
test("should return false if the user has group permission to access board of first integration but not of second one", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const session = createSession({});
|
const session = createSession({});
|
||||||
await db.insert(users).values({ id: session.user.id });
|
await db.insert(users).values({ id: session.user.id });
|
||||||
const spy = vi.spyOn(integrationPermissions, "constructIntegrationPermissions");
|
const spy = vi.spyOn(integrationPermissions, "constructIntegrationPermissions");
|
||||||
@@ -318,7 +318,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query a
|
|||||||
|
|
||||||
test("should return true if the user has user permission to access first board and group permission to access second one", async () => {
|
test("should return true if the user has user permission to access first board and group permission to access second one", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const session = createSession({});
|
const session = createSession({});
|
||||||
await db.insert(users).values({ id: session.user.id });
|
await db.insert(users).values({ id: session.user.id });
|
||||||
const spy = vi.spyOn(integrationPermissions, "constructIntegrationPermissions");
|
const spy = vi.spyOn(integrationPermissions, "constructIntegrationPermissions");
|
||||||
@@ -369,7 +369,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query a
|
|||||||
|
|
||||||
test("should return true if one of the boards the integration is used is public", async () => {
|
test("should return true if one of the boards the integration is used is public", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const session = createSession({});
|
const session = createSession({});
|
||||||
const integrations = [
|
const integrations = [
|
||||||
{
|
{
|
||||||
@@ -413,7 +413,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query a
|
|||||||
|
|
||||||
test("should return true if the user is creator of the board the integration is used", async () => {
|
test("should return true if the user is creator of the board the integration is used", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const session = createSession({});
|
const session = createSession({});
|
||||||
await db.insert(users).values({ id: session.user.id });
|
await db.insert(users).values({ id: session.user.id });
|
||||||
const integrations = [
|
const integrations = [
|
||||||
@@ -458,7 +458,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query a
|
|||||||
|
|
||||||
test("should return false if the user has no access to any of the integrations", async () => {
|
test("should return false if the user has no access to any of the integrations", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const session = createSession({});
|
const session = createSession({});
|
||||||
const integrations = [
|
const integrations = [
|
||||||
{
|
{
|
||||||
@@ -496,7 +496,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query a
|
|||||||
|
|
||||||
test("should return false if the user is anonymous and the board is not public", async () => {
|
test("should return false if the user is anonymous and the board is not public", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const integrations = [
|
const integrations = [
|
||||||
{
|
{
|
||||||
id: "1",
|
id: "1",
|
||||||
@@ -534,7 +534,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query a
|
|||||||
|
|
||||||
test("should return true if the user is anonymous and the board is public", async () => {
|
test("should return true if the user is anonymous and the board is public", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const integrations = [
|
const integrations = [
|
||||||
{
|
{
|
||||||
id: "1",
|
id: "1",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { describe, expect, test } from "vitest";
|
|||||||
|
|
||||||
import { createId } from "@homarr/common";
|
import { createId } from "@homarr/common";
|
||||||
import { users } from "@homarr/db/schema";
|
import { users } from "@homarr/db/schema";
|
||||||
import { createDb } from "@homarr/db/test";
|
import { createDbAsync } from "@homarr/db/test";
|
||||||
|
|
||||||
import { createSaltAsync, hashPasswordAsync } from "../../security";
|
import { createSaltAsync, hashPasswordAsync } from "../../security";
|
||||||
import { authorizeWithBasicCredentialsAsync } from "../credentials/authorization/basic-authorization";
|
import { authorizeWithBasicCredentialsAsync } from "../credentials/authorization/basic-authorization";
|
||||||
@@ -12,7 +12,7 @@ const defaultUserId = createId();
|
|||||||
describe("authorizeWithBasicCredentials", () => {
|
describe("authorizeWithBasicCredentials", () => {
|
||||||
test("should authorize user with correct credentials", async () => {
|
test("should authorize user with correct credentials", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const salt = await createSaltAsync();
|
const salt = await createSaltAsync();
|
||||||
await db.insert(users).values({
|
await db.insert(users).values({
|
||||||
id: defaultUserId,
|
id: defaultUserId,
|
||||||
@@ -33,7 +33,7 @@ describe("authorizeWithBasicCredentials", () => {
|
|||||||
|
|
||||||
test("should not authorize user with incorrect credentials", async () => {
|
test("should not authorize user with incorrect credentials", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const salt = await createSaltAsync();
|
const salt = await createSaltAsync();
|
||||||
await db.insert(users).values({
|
await db.insert(users).values({
|
||||||
id: defaultUserId,
|
id: defaultUserId,
|
||||||
@@ -54,7 +54,7 @@ describe("authorizeWithBasicCredentials", () => {
|
|||||||
|
|
||||||
test("should not authorize user with incorrect username", async () => {
|
test("should not authorize user with incorrect username", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const salt = await createSaltAsync();
|
const salt = await createSaltAsync();
|
||||||
await db.insert(users).values({
|
await db.insert(users).values({
|
||||||
id: defaultUserId,
|
id: defaultUserId,
|
||||||
@@ -75,7 +75,7 @@ describe("authorizeWithBasicCredentials", () => {
|
|||||||
|
|
||||||
test("should not authorize user when password is not set", async () => {
|
test("should not authorize user when password is not set", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
await db.insert(users).values({
|
await db.insert(users).values({
|
||||||
id: defaultUserId,
|
id: defaultUserId,
|
||||||
name: "test",
|
name: "test",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { createId } from "@homarr/common";
|
|||||||
import type { Database } from "@homarr/db";
|
import type { Database } from "@homarr/db";
|
||||||
import { and, eq } from "@homarr/db";
|
import { and, eq } from "@homarr/db";
|
||||||
import { groups, users } from "@homarr/db/schema";
|
import { groups, users } from "@homarr/db/schema";
|
||||||
import { createDb } from "@homarr/db/test";
|
import { createDbAsync } from "@homarr/db/test";
|
||||||
|
|
||||||
import { authorizeWithLdapCredentialsAsync } from "../credentials/authorization/ldap-authorization";
|
import { authorizeWithLdapCredentialsAsync } from "../credentials/authorization/ldap-authorization";
|
||||||
import * as ldapClient from "../credentials/ldap-client";
|
import * as ldapClient from "../credentials/ldap-client";
|
||||||
@@ -123,7 +123,7 @@ describe("authorizeWithLdapCredentials", () => {
|
|||||||
|
|
||||||
test("should authorize user with correct credentials and create user", async () => {
|
test("should authorize user with correct credentials and create user", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const spy = vi.spyOn(ldapClient, "LdapClient");
|
const spy = vi.spyOn(ldapClient, "LdapClient");
|
||||||
spy.mockImplementation(function () {
|
spy.mockImplementation(function () {
|
||||||
return {
|
return {
|
||||||
@@ -161,7 +161,7 @@ describe("authorizeWithLdapCredentials", () => {
|
|||||||
|
|
||||||
test("should authorize user with correct credentials and create user with same email when credentials user already exists", async () => {
|
test("should authorize user with correct credentials and create user with same email when credentials user already exists", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const spy = vi.spyOn(ldapClient, "LdapClient");
|
const spy = vi.spyOn(ldapClient, "LdapClient");
|
||||||
spy.mockImplementation(function () {
|
spy.mockImplementation(function () {
|
||||||
return {
|
return {
|
||||||
@@ -230,7 +230,7 @@ describe("authorizeWithLdapCredentials", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const userId = createId();
|
const userId = createId();
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
await db.insert(users).values({
|
await db.insert(users).values({
|
||||||
id: userId,
|
id: userId,
|
||||||
name: "test-old",
|
name: "test-old",
|
||||||
@@ -281,7 +281,7 @@ describe("authorizeWithLdapCredentials", () => {
|
|||||||
disconnectAsync: vi.fn(),
|
disconnectAsync: vi.fn(),
|
||||||
} as unknown as ldapClient.LdapClient;
|
} as unknown as ldapClient.LdapClient;
|
||||||
});
|
});
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const userId = createId();
|
const userId = createId();
|
||||||
await db.insert(users).values({
|
await db.insert(users).values({
|
||||||
id: userId,
|
id: userId,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { describe, expect, test } from "vitest";
|
import { describe, expect, test } from "vitest";
|
||||||
|
|
||||||
import { users } from "@homarr/db/schema";
|
import { users } from "@homarr/db/schema";
|
||||||
import { createDb } from "@homarr/db/test";
|
import { createDbAsync } from "@homarr/db/test";
|
||||||
|
|
||||||
import { createAdapter } from "../adapter";
|
import { createAdapter } from "../adapter";
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ describe("createAdapter should create drizzle adapter", () => {
|
|||||||
"createAdapter getUserByEmail should return user for provider %s when this provider provided",
|
"createAdapter getUserByEmail should return user for provider %s when this provider provided",
|
||||||
async (provider) => {
|
async (provider) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const adapter = createAdapter(db, provider);
|
const adapter = createAdapter(db, provider);
|
||||||
const email = "test@example.com";
|
const email = "test@example.com";
|
||||||
await db.insert(users).values({ id: "1", name: "test", email, provider });
|
await db.insert(users).values({ id: "1", name: "test", email, provider });
|
||||||
@@ -37,7 +37,7 @@ describe("createAdapter should create drizzle adapter", () => {
|
|||||||
"createAdapter getUserByEmail should return null if only for other providers than %s exist",
|
"createAdapter getUserByEmail should return null if only for other providers than %s exist",
|
||||||
async (requestedProvider, existingProviders) => {
|
async (requestedProvider, existingProviders) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const adapter = createAdapter(db, requestedProvider);
|
const adapter = createAdapter(db, requestedProvider);
|
||||||
const email = "test@example.com";
|
const email = "test@example.com";
|
||||||
for (const provider of existingProviders) {
|
for (const provider of existingProviders) {
|
||||||
@@ -54,7 +54,7 @@ describe("createAdapter should create drizzle adapter", () => {
|
|||||||
|
|
||||||
test("createAdapter getUserByEmail should throw error if provider is unknown", async () => {
|
test("createAdapter getUserByEmail should throw error if provider is unknown", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const adapter = createAdapter(db, "unknown");
|
const adapter = createAdapter(db, "unknown");
|
||||||
const email = "test@example.com";
|
const email = "test@example.com";
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import type { JWT } from "next-auth/jwt";
|
|||||||
import { describe, expect, test, vi } from "vitest";
|
import { describe, expect, test, vi } from "vitest";
|
||||||
|
|
||||||
import { groupMembers, groupPermissions, groups, users } from "@homarr/db/schema";
|
import { groupMembers, groupPermissions, groups, users } from "@homarr/db/schema";
|
||||||
import { createDb } from "@homarr/db/test";
|
import { createDbAsync } from "@homarr/db/test";
|
||||||
import * as definitions from "@homarr/definitions";
|
import * as definitions from "@homarr/definitions";
|
||||||
|
|
||||||
import { createSessionCallback, getCurrentUserPermissionsAsync } from "../callbacks";
|
import { createSessionCallback, getCurrentUserPermissionsAsync } from "../callbacks";
|
||||||
@@ -20,7 +20,7 @@ vi.mock("next/headers", () => ({
|
|||||||
describe("getCurrentUserPermissions", () => {
|
describe("getCurrentUserPermissions", () => {
|
||||||
test("should return empty permissions when non existing user requested", async () => {
|
test("should return empty permissions when non existing user requested", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
|
|
||||||
await db.insert(groups).values({
|
await db.insert(groups).values({
|
||||||
id: "2",
|
id: "2",
|
||||||
@@ -46,7 +46,7 @@ describe("getCurrentUserPermissions", () => {
|
|||||||
|
|
||||||
test("should return empty permissions when user has no groups", async () => {
|
test("should return empty permissions when user has no groups", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const userId = "1";
|
const userId = "1";
|
||||||
|
|
||||||
await db.insert(groups).values({
|
await db.insert(groups).values({
|
||||||
@@ -71,7 +71,7 @@ describe("getCurrentUserPermissions", () => {
|
|||||||
|
|
||||||
test("should return permissions for user", async () => {
|
test("should return permissions for user", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const getPermissionsWithChildrenMock = vi
|
const getPermissionsWithChildrenMock = vi
|
||||||
.spyOn(definitions, "getPermissionsWithChildren")
|
.spyOn(definitions, "getPermissionsWithChildren")
|
||||||
.mockReturnValue(["board-create"]);
|
.mockReturnValue(["board-create"]);
|
||||||
@@ -113,7 +113,7 @@ describe("session callback", () => {
|
|||||||
emailVerified: new Date("2023-01-13"),
|
emailVerified: new Date("2023-01-13"),
|
||||||
};
|
};
|
||||||
const token: JWT = {};
|
const token: JWT = {};
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
const callback = createSessionCallback(db);
|
const callback = createSessionCallback(db);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { describe, expect, test, vi } from "vitest";
|
|||||||
import { eq } from "@homarr/db";
|
import { eq } from "@homarr/db";
|
||||||
import type { Database } from "@homarr/db";
|
import type { Database } from "@homarr/db";
|
||||||
import { groupMembers, groups, users } from "@homarr/db/schema";
|
import { groupMembers, groups, users } from "@homarr/db/schema";
|
||||||
import { createDb } from "@homarr/db/test";
|
import { createDbAsync } from "@homarr/db/test";
|
||||||
import { colorSchemeCookieKey, everyoneGroup } from "@homarr/definitions";
|
import { colorSchemeCookieKey, everyoneGroup } from "@homarr/definitions";
|
||||||
|
|
||||||
import { createSignInEventHandler } from "../events";
|
import { createSignInEventHandler } from "../events";
|
||||||
@@ -39,7 +39,7 @@ describe("createSignInEventHandler should create signInEventHandler", () => {
|
|||||||
describe("signInEventHandler should add users to everyone group", () => {
|
describe("signInEventHandler should add users to everyone group", () => {
|
||||||
test("should add user to everyone group if he isn't already", async () => {
|
test("should add user to everyone group if he isn't already", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
await createUserAsync(db);
|
await createUserAsync(db);
|
||||||
await createGroupAsync(db, everyoneGroup);
|
await createGroupAsync(db, everyoneGroup);
|
||||||
const eventHandler = createSignInEventHandler(db);
|
const eventHandler = createSignInEventHandler(db);
|
||||||
@@ -62,7 +62,7 @@ describe("createSignInEventHandler should create signInEventHandler", () => {
|
|||||||
describe("signInEventHandler should synchronize ldap groups", () => {
|
describe("signInEventHandler should synchronize ldap groups", () => {
|
||||||
test("should add missing group membership", async () => {
|
test("should add missing group membership", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
await createUserAsync(db);
|
await createUserAsync(db);
|
||||||
await createGroupAsync(db);
|
await createGroupAsync(db);
|
||||||
const eventHandler = createSignInEventHandler(db);
|
const eventHandler = createSignInEventHandler(db);
|
||||||
@@ -82,7 +82,7 @@ describe("createSignInEventHandler should create signInEventHandler", () => {
|
|||||||
});
|
});
|
||||||
test("should remove group membership", async () => {
|
test("should remove group membership", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
await createUserAsync(db);
|
await createUserAsync(db);
|
||||||
await createGroupAsync(db);
|
await createGroupAsync(db);
|
||||||
await db.insert(groupMembers).values({
|
await db.insert(groupMembers).values({
|
||||||
@@ -106,7 +106,7 @@ describe("createSignInEventHandler should create signInEventHandler", () => {
|
|||||||
});
|
});
|
||||||
test("should not remove group membership for everyone group", async () => {
|
test("should not remove group membership for everyone group", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
await createUserAsync(db);
|
await createUserAsync(db);
|
||||||
await createGroupAsync(db, everyoneGroup);
|
await createGroupAsync(db, everyoneGroup);
|
||||||
await db.insert(groupMembers).values({
|
await db.insert(groupMembers).values({
|
||||||
@@ -132,7 +132,7 @@ describe("createSignInEventHandler should create signInEventHandler", () => {
|
|||||||
describe("signInEventHandler should synchronize oidc groups", () => {
|
describe("signInEventHandler should synchronize oidc groups", () => {
|
||||||
test("should add missing group membership", async () => {
|
test("should add missing group membership", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
await createUserAsync(db);
|
await createUserAsync(db);
|
||||||
await createGroupAsync(db);
|
await createGroupAsync(db);
|
||||||
const eventHandler = createSignInEventHandler(db);
|
const eventHandler = createSignInEventHandler(db);
|
||||||
@@ -152,7 +152,7 @@ describe("createSignInEventHandler should create signInEventHandler", () => {
|
|||||||
});
|
});
|
||||||
test("should remove group membership", async () => {
|
test("should remove group membership", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
await createUserAsync(db);
|
await createUserAsync(db);
|
||||||
await createGroupAsync(db);
|
await createGroupAsync(db);
|
||||||
await db.insert(groupMembers).values({
|
await db.insert(groupMembers).values({
|
||||||
@@ -176,7 +176,7 @@ describe("createSignInEventHandler should create signInEventHandler", () => {
|
|||||||
});
|
});
|
||||||
test("should not remove group membership for everyone group", async () => {
|
test("should not remove group membership for everyone group", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
await createUserAsync(db);
|
await createUserAsync(db);
|
||||||
await createGroupAsync(db, everyoneGroup);
|
await createGroupAsync(db, everyoneGroup);
|
||||||
await db.insert(groupMembers).values({
|
await db.insert(groupMembers).values({
|
||||||
@@ -205,7 +205,7 @@ describe("createSignInEventHandler should create signInEventHandler", () => {
|
|||||||
["oidc" as const, { name: "test" }, { preferred_username: "test@example.com", name: "test-new" }],
|
["oidc" as const, { name: "test" }, { preferred_username: "test@example.com", name: "test-new" }],
|
||||||
])("signInEventHandler should update username for %s provider", async (_provider, user, profile) => {
|
])("signInEventHandler should update username for %s provider", async (_provider, user, profile) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
await createUserAsync(db);
|
await createUserAsync(db);
|
||||||
const eventHandler = createSignInEventHandler(db);
|
const eventHandler = createSignInEventHandler(db);
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ describe("createSignInEventHandler should create signInEventHandler", () => {
|
|||||||
});
|
});
|
||||||
test("signInEventHandler should set color-scheme cookie", async () => {
|
test("signInEventHandler should set color-scheme cookie", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const db = createDb();
|
const db = await createDbAsync();
|
||||||
await createUserAsync(db);
|
await createUserAsync(db);
|
||||||
const eventHandler = createSignInEventHandler(db);
|
const eventHandler = createSignInEventHandler(db);
|
||||||
|
|
||||||
|
|||||||
@@ -25,14 +25,14 @@
|
|||||||
"prettier": "@homarr/prettier-config",
|
"prettier": "@homarr/prettier-config",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@homarr/api": "workspace:^0.1.0",
|
"@homarr/api": "workspace:^0.1.0",
|
||||||
"react": "19.2.4",
|
"react": "19.2.3",
|
||||||
"react-dom": "19.2.4"
|
"react-dom": "19.2.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@homarr/eslint-config": "workspace:^0.2.0",
|
"@homarr/eslint-config": "workspace:^0.2.0",
|
||||||
"@homarr/prettier-config": "workspace:^0.1.0",
|
"@homarr/prettier-config": "workspace:^0.1.0",
|
||||||
"@homarr/tsconfig": "workspace:^0.1.0",
|
"@homarr/tsconfig": "workspace:^0.1.0",
|
||||||
"eslint": "^9.39.4",
|
"eslint": "^9.39.2",
|
||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,9 +19,7 @@
|
|||||||
"clean": "rm -rf .turbo node_modules",
|
"clean": "rm -rf .turbo node_modules",
|
||||||
"format": "prettier --check . --ignore-path ../../.gitignore",
|
"format": "prettier --check . --ignore-path ../../.gitignore",
|
||||||
"lint": "eslint",
|
"lint": "eslint",
|
||||||
"run": "pnpm with-env node cli.cjs",
|
"typecheck": "tsc --noEmit"
|
||||||
"typecheck": "tsc --noEmit",
|
|
||||||
"with-env": "dotenv -e .env --"
|
|
||||||
},
|
},
|
||||||
"prettier": "@homarr/prettier-config",
|
"prettier": "@homarr/prettier-config",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -30,14 +28,14 @@
|
|||||||
"@homarr/common": "workspace:^0.1.0",
|
"@homarr/common": "workspace:^0.1.0",
|
||||||
"@homarr/db": "workspace:^0.1.0",
|
"@homarr/db": "workspace:^0.1.0",
|
||||||
"@homarr/validation": "workspace:^0.1.0",
|
"@homarr/validation": "workspace:^0.1.0",
|
||||||
"dotenv": "^17.3.1"
|
"dotenv": "^17.2.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@homarr/eslint-config": "workspace:^0.2.0",
|
"@homarr/eslint-config": "workspace:^0.2.0",
|
||||||
"@homarr/prettier-config": "workspace:^0.1.0",
|
"@homarr/prettier-config": "workspace:^0.1.0",
|
||||||
"@homarr/tsconfig": "workspace:^0.1.0",
|
"@homarr/tsconfig": "workspace:^0.1.0",
|
||||||
"esbuild": "^0.27.4",
|
"esbuild": "^0.27.2",
|
||||||
"eslint": "^9.39.4",
|
"eslint": "^9.39.2",
|
||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
import { command, string } from "@drizzle-team/brocli";
|
|
||||||
|
|
||||||
import { db, eq } from "@homarr/db";
|
|
||||||
import { integrations } from "@homarr/db/schema";
|
|
||||||
|
|
||||||
export const integrationsDelete = command({
|
|
||||||
name: "delete",
|
|
||||||
desc: "Delete an integration by id or name",
|
|
||||||
options: {
|
|
||||||
id: string("id").alias("i").desc("ID of the integration"),
|
|
||||||
name: string("name").alias("n").desc("Name of the integration"),
|
|
||||||
},
|
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
|
||||||
handler: async (options) => {
|
|
||||||
if (!options.id && !options.name) {
|
|
||||||
console.error("Either --id or --name must be provided");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let entry;
|
|
||||||
if (options.id) {
|
|
||||||
entry = await db.query.integrations.findFirst({
|
|
||||||
where: eq(integrations.id, options.id),
|
|
||||||
});
|
|
||||||
} else if (options.name) {
|
|
||||||
entry = await db.query.integrations.findFirst({
|
|
||||||
where: eq(integrations.name, options.name),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!entry) {
|
|
||||||
console.error("Integration not found");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await db.delete(integrations).where(eq(integrations.id, entry.id));
|
|
||||||
console.log(`Integration ${entry.name} (${entry.id}) deleted`);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import { command } from "@drizzle-team/brocli";
|
|
||||||
|
|
||||||
import { db } from "@homarr/db";
|
|
||||||
|
|
||||||
export const integrationsList = command({
|
|
||||||
name: "list",
|
|
||||||
desc: "List all integrations (id and name)",
|
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
|
||||||
handler: async () => {
|
|
||||||
const all = await db.query.integrations.findMany();
|
|
||||||
if (all.length === 0) {
|
|
||||||
console.log("No integrations found");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("ID\t\t\t\tName");
|
|
||||||
for (const i of all) {
|
|
||||||
console.log(`${i.id}\t${i.name}`);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import { command } from "@drizzle-team/brocli";
|
|
||||||
|
|
||||||
import { integrationsDelete } from "./integrations-delete";
|
|
||||||
import { integrationsList } from "./integrations-list";
|
|
||||||
|
|
||||||
export const integrationsRoot = command({
|
|
||||||
name: "integrations",
|
|
||||||
desc: "Group of commands to manage integrations",
|
|
||||||
subcommands: [integrationsList, integrationsDelete],
|
|
||||||
});
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
import { command, string } from "@drizzle-team/brocli";
|
|
||||||
|
|
||||||
import { db, eq } from "@homarr/db";
|
|
||||||
import { users } from "@homarr/db/schema";
|
|
||||||
|
|
||||||
export const usersDelete = command({
|
|
||||||
name: "delete",
|
|
||||||
desc: "Delete a user by id or username",
|
|
||||||
options: {
|
|
||||||
id: string("id").alias("i").desc("ID of the user"),
|
|
||||||
username: string("username").alias("u").desc("Name of the user"),
|
|
||||||
},
|
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
|
||||||
handler: async (options) => {
|
|
||||||
if (!options.id && !options.username) {
|
|
||||||
console.error("Either --id or --username must be provided");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let user;
|
|
||||||
if (options.id) {
|
|
||||||
user = await db.query.users.findFirst({
|
|
||||||
where: eq(users.id, options.id),
|
|
||||||
});
|
|
||||||
} else if (options.username) {
|
|
||||||
user = await db.query.users.findFirst({
|
|
||||||
where: eq(users.name, options.username),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!user) {
|
|
||||||
console.error("User not found");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await db.delete(users).where(eq(users.id, user.id));
|
|
||||||
console.log(`User ${user.name ?? user.id} (${user.id}) deleted`);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
import { command } from "@drizzle-team/brocli";
|
|
||||||
|
|
||||||
import { db } from "@homarr/db";
|
|
||||||
|
|
||||||
export const usersList = command({
|
|
||||||
name: "list",
|
|
||||||
desc: "List all users (id, username, email)",
|
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
|
||||||
handler: async () => {
|
|
||||||
const allUsers = await db.query.users.findMany();
|
|
||||||
|
|
||||||
if (allUsers.length === 0) {
|
|
||||||
console.log("No users found");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("ID\t\t\t\tUsername\tEmail");
|
|
||||||
for (const user of allUsers) {
|
|
||||||
console.log(`${user.id}\t${user.name ?? ""}\t${user.email ?? ""}`);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
import { command, string } from "@drizzle-team/brocli";
|
|
||||||
|
|
||||||
import { hashPasswordAsync } from "@homarr/auth";
|
|
||||||
import { db, eq } from "@homarr/db";
|
|
||||||
import { sessions, users } from "@homarr/db/schema";
|
|
||||||
|
|
||||||
export const usersUpdatePassword = command({
|
|
||||||
name: "update-password",
|
|
||||||
desc: "Update the password for a user (credentials provider only)",
|
|
||||||
options: {
|
|
||||||
id: string("id").alias("i").desc("ID of the user"),
|
|
||||||
username: string("username").alias("u").desc("Name of the user"),
|
|
||||||
password: string("password").alias("p").required().desc("New password"),
|
|
||||||
},
|
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
|
||||||
handler: async (options) => {
|
|
||||||
if (!process.env.AUTH_PROVIDERS?.toLowerCase().includes("credentials")) {
|
|
||||||
console.error("Credentials provider is not enabled");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!options.id && !options.username) {
|
|
||||||
console.error("Either --id or --username must be provided");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const user = await db.query.users.findFirst({
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
||||||
where: options.id ? eq(users.id, options.id) : eq(users.name, options.username!),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!user?.salt) {
|
|
||||||
console.error("User not found or has no credentials record");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await db
|
|
||||||
.update(users)
|
|
||||||
.set({
|
|
||||||
password: await hashPasswordAsync(options.password, user.salt),
|
|
||||||
})
|
|
||||||
.where(eq(users.id, user.id));
|
|
||||||
|
|
||||||
// invalidate existing sessions
|
|
||||||
await db.delete(sessions).where(eq(sessions.userId, user.id));
|
|
||||||
console.log(`All sessions for user ${user.name ?? user.id} have been deleted`);
|
|
||||||
|
|
||||||
console.log("Password updated successfully");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { command } from "@drizzle-team/brocli";
|
|
||||||
|
|
||||||
import { usersDelete } from "./users-delete";
|
|
||||||
import { usersList } from "./users-list";
|
|
||||||
import { usersUpdatePassword } from "./users-update-password";
|
|
||||||
|
|
||||||
export const usersRoot = command({
|
|
||||||
name: "users",
|
|
||||||
desc: "Group of commands to manage users",
|
|
||||||
subcommands: [usersList, usersDelete, usersUpdatePassword],
|
|
||||||
});
|
|
||||||
@@ -1,12 +1,10 @@
|
|||||||
import { run } from "@drizzle-team/brocli";
|
import { run } from "@drizzle-team/brocli";
|
||||||
|
|
||||||
import { fixUsernames } from "./commands/fix-usernames";
|
import { fixUsernames } from "./commands/fix-usernames";
|
||||||
import { integrationsRoot } from "./commands/integrations";
|
|
||||||
import { recreateAdmin } from "./commands/recreate-admin";
|
import { recreateAdmin } from "./commands/recreate-admin";
|
||||||
import { resetPassword } from "./commands/reset-password";
|
import { resetPassword } from "./commands/reset-password";
|
||||||
import { usersRoot } from "./commands/users";
|
|
||||||
|
|
||||||
const commands = [usersRoot, integrationsRoot, resetPassword, fixUsernames, recreateAdmin];
|
const commands = [resetPassword, fixUsernames, recreateAdmin];
|
||||||
|
|
||||||
void run(commands, {
|
void run(commands, {
|
||||||
name: "homarr-cli",
|
name: "homarr-cli",
|
||||||
|
|||||||
@@ -27,13 +27,12 @@
|
|||||||
"prettier": "@homarr/prettier-config",
|
"prettier": "@homarr/prettier-config",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@homarr/core": "workspace:^0.1.0",
|
"@homarr/core": "workspace:^0.1.0",
|
||||||
"@paralleldrive/cuid2": "^3.3.0",
|
"@paralleldrive/cuid2": "^3.1.0",
|
||||||
"cookie": "1.1.1",
|
"dayjs": "^1.11.19",
|
||||||
"dayjs": "^1.11.20",
|
"next": "16.1.1",
|
||||||
"next": "16.2.0",
|
|
||||||
"octokit": "^5.0.5",
|
"octokit": "^5.0.5",
|
||||||
"react": "19.2.4",
|
"react": "19.2.3",
|
||||||
"react-dom": "19.2.4",
|
"react-dom": "19.2.3",
|
||||||
"undici": "7.18.2",
|
"undici": "7.18.2",
|
||||||
"zod": "^4.2.1",
|
"zod": "^4.2.1",
|
||||||
"zod-validation-error": "^5.0.0"
|
"zod-validation-error": "^5.0.0"
|
||||||
@@ -42,7 +41,7 @@
|
|||||||
"@homarr/eslint-config": "workspace:^0.2.0",
|
"@homarr/eslint-config": "workspace:^0.2.0",
|
||||||
"@homarr/prettier-config": "workspace:^0.1.0",
|
"@homarr/prettier-config": "workspace:^0.1.0",
|
||||||
"@homarr/tsconfig": "workspace:^0.1.0",
|
"@homarr/tsconfig": "workspace:^0.1.0",
|
||||||
"eslint": "^9.39.4",
|
"eslint": "^9.39.2",
|
||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
import type { SerializeOptions } from "cookie";
|
import type { SerializeOptions } from "cookie";
|
||||||
import { parseCookie, stringifySetCookie } from "cookie";
|
import { parse, serialize } from "cookie";
|
||||||
|
|
||||||
export function parseCookies(cookieString: string) {
|
export function parseCookies(cookieString: string) {
|
||||||
return parseCookie(cookieString);
|
return parse(cookieString);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setClientCookie(name: string, value: string, options: SerializeOptions = {}) {
|
export function setClientCookie(name: string, value: string, options: SerializeOptions = {}) {
|
||||||
document.cookie = stringifySetCookie(name, value, options);
|
document.cookie = serialize(name, value, options);
|
||||||
}
|
}
|
||||||
@@ -6,17 +6,6 @@ dayjs.extend(isBetween);
|
|||||||
|
|
||||||
const validUnits = ["h", "d", "w", "M", "y"] as UnitTypeShort[];
|
const validUnits = ["h", "d", "w", "M", "y"] as UnitTypeShort[];
|
||||||
|
|
||||||
export function formatDuration(milliseconds: number) {
|
|
||||||
const totalSeconds = Math.floor(milliseconds / 1000);
|
|
||||||
const hours = Math.floor(totalSeconds / 3600);
|
|
||||||
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
|
||||||
const seconds = totalSeconds % 60;
|
|
||||||
if (hours > 0) {
|
|
||||||
return `${hours}:${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}`;
|
|
||||||
}
|
|
||||||
return `${minutes}:${String(seconds).padStart(2, "0")}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const isDateWithin = (date: Date, relativeDate: string): boolean => {
|
export const isDateWithin = (date: Date, relativeDate: string): boolean => {
|
||||||
if (relativeDate.length < 2) {
|
if (relativeDate.length < 2) {
|
||||||
throw new Error("Relative date must be at least 2 characters long");
|
throw new Error("Relative date must be at least 2 characters long");
|
||||||
|
|||||||
@@ -37,13 +37,13 @@
|
|||||||
},
|
},
|
||||||
"prettier": "@homarr/prettier-config",
|
"prettier": "@homarr/prettier-config",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@libsql/client": "0.15.15",
|
||||||
"@t3-oss/env-nextjs": "^0.13.10",
|
"@t3-oss/env-nextjs": "^0.13.10",
|
||||||
"better-sqlite3": "^12.6.2",
|
|
||||||
"dns-caching": "^0.2.9",
|
"dns-caching": "^0.2.9",
|
||||||
"drizzle-orm": "^0.45.1",
|
"drizzle-orm": "^0.45.1",
|
||||||
"ioredis": "5.10.1",
|
"ioredis": "5.9.1",
|
||||||
"mysql2": "3.20.0",
|
"mysql2": "3.16.0",
|
||||||
"pg": "^8.20.0",
|
"pg": "^8.16.3",
|
||||||
"superjson": "2.2.6",
|
"superjson": "2.2.6",
|
||||||
"winston": "3.19.0",
|
"winston": "3.19.0",
|
||||||
"zod": "^4.2.1"
|
"zod": "^4.2.1"
|
||||||
@@ -52,9 +52,8 @@
|
|||||||
"@homarr/eslint-config": "workspace:^0.2.0",
|
"@homarr/eslint-config": "workspace:^0.2.0",
|
||||||
"@homarr/prettier-config": "workspace:^0.1.0",
|
"@homarr/prettier-config": "workspace:^0.1.0",
|
||||||
"@homarr/tsconfig": "workspace:^0.1.0",
|
"@homarr/tsconfig": "workspace:^0.1.0",
|
||||||
"@types/better-sqlite3": "7.6.13",
|
"@types/pg": "^8.16.0",
|
||||||
"@types/pg": "^8.18.0",
|
"eslint": "^9.39.2",
|
||||||
"eslint": "^9.39.4",
|
|
||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
import Database from "better-sqlite3";
|
import { createClient } from "@libsql/client/node";
|
||||||
import { drizzle as drizzleSqlite } from "drizzle-orm/better-sqlite3";
|
import { drizzle as drizzleSqlite } from "drizzle-orm/libsql";
|
||||||
|
|
||||||
import { dbEnv } from "../env";
|
import { dbEnv } from "../env";
|
||||||
import type { SharedDrizzleConfig } from "./shared";
|
import type { SharedDrizzleConfig } from "./shared";
|
||||||
|
|
||||||
export const createSqliteDb = <TSchema extends Record<string, unknown>>(config: SharedDrizzleConfig<TSchema>) => {
|
export const createSqliteDb = <TSchema extends Record<string, unknown>>(config: SharedDrizzleConfig<TSchema>) => {
|
||||||
const connection = new Database(dbEnv.URL);
|
const connection = createClient({
|
||||||
|
url: dbEnv.URL ? `file:${dbEnv.URL}` : ":memory:",
|
||||||
|
});
|
||||||
return drizzleSqlite<TSchema>(connection, config);
|
return drizzleSqlite<TSchema>(connection, config);
|
||||||
};
|
};
|
||||||
@@ -28,12 +28,12 @@
|
|||||||
"@homarr/common": "workspace:^0.1.0",
|
"@homarr/common": "workspace:^0.1.0",
|
||||||
"@homarr/core": "workspace:^0.1.0",
|
"@homarr/core": "workspace:^0.1.0",
|
||||||
"@homarr/cron-jobs": "workspace:^0.1.0",
|
"@homarr/cron-jobs": "workspace:^0.1.0",
|
||||||
"@tanstack/react-query": "^5.91.2",
|
"@tanstack/react-query": "^5.90.16",
|
||||||
"@trpc/client": "^11.13.4",
|
"@trpc/client": "^11.8.1",
|
||||||
"@trpc/server": "^11.13.4",
|
"@trpc/server": "^11.8.1",
|
||||||
"@trpc/tanstack-react-query": "^11.13.4",
|
"@trpc/tanstack-react-query": "^11.8.1",
|
||||||
"node-cron": "^4.2.1",
|
"node-cron": "^4.2.1",
|
||||||
"react": "19.2.4",
|
"react": "19.2.3",
|
||||||
"zod": "^4.2.1"
|
"zod": "^4.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -41,8 +41,8 @@
|
|||||||
"@homarr/prettier-config": "workspace:^0.1.0",
|
"@homarr/prettier-config": "workspace:^0.1.0",
|
||||||
"@homarr/tsconfig": "workspace:^0.1.0",
|
"@homarr/tsconfig": "workspace:^0.1.0",
|
||||||
"@types/node-cron": "^3.0.11",
|
"@types/node-cron": "^3.0.11",
|
||||||
"@types/react": "19.2.14",
|
"@types/react": "19.2.8",
|
||||||
"eslint": "^9.39.4",
|
"eslint": "^9.39.2",
|
||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,15 +17,7 @@ export interface IJobManager {
|
|||||||
updateIntervalAsync(name: JobGroupKeys, cron: string): Promise<void>;
|
updateIntervalAsync(name: JobGroupKeys, cron: string): Promise<void>;
|
||||||
disableAsync(name: JobGroupKeys): Promise<void>;
|
disableAsync(name: JobGroupKeys): Promise<void>;
|
||||||
enableAsync(name: JobGroupKeys): Promise<void>;
|
enableAsync(name: JobGroupKeys): Promise<void>;
|
||||||
getAllAsync(): Promise<
|
getAllAsync(): Promise<{ name: JobGroupKeys; cron: string; preventManualExecution: boolean; isEnabled: boolean }[]>;
|
||||||
{
|
|
||||||
name: JobGroupKeys;
|
|
||||||
cron: string;
|
|
||||||
preventManualExecution: boolean;
|
|
||||||
preventCustomInterval: boolean;
|
|
||||||
isEnabled: boolean;
|
|
||||||
}[]
|
|
||||||
>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const t = initTRPC
|
const t = initTRPC
|
||||||
|
|||||||
Loaded 100 of 256 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user