diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..a485dd63 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +backend/internal/data/ent/** linguist-generated=true +backend/internal/data/ent/schema/** linguist-generated=false +frontend/lib/api/types/** linguist-generated=true \ No newline at end of file diff --git a/.github/workflows/binaries-publish.yaml b/.github/workflows/binaries-publish.yaml index 76e30646..84f2f1a8 100644 --- a/.github/workflows/binaries-publish.yaml +++ b/.github/workflows/binaries-publish.yaml @@ -43,6 +43,11 @@ jobs: run: | go install github.com/sigstore/cosign/cmd/cosign@latest + - name: Install Syft + working-directory: backend + run: | + go install github.com/anchore/syft/cmd/syft@latest + - name: Run GoReleaser id: releaser if: startsWith(github.ref, 'refs/tags/') @@ -51,7 +56,7 @@ jobs: workdir: "backend" distribution: goreleaser version: "~> v2" - args: release --rm-dist + args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} COSIGN_PWD: ${{ secrets.COSIGN_PWD }} diff --git a/.github/workflows/docker-publish-hardened.yaml b/.github/workflows/docker-publish-hardened.yaml index 6efe8579..ac8547df 100644 --- a/.github/workflows/docker-publish-hardened.yaml +++ b/.github/workflows/docker-publish-hardened.yaml @@ -95,13 +95,13 @@ jobs: - name: Set up QEMU uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 with: - image: ghcr.io/amitie10g/binfmt:latest + image: ghcr.io/sysadminsmedia/binfmt:latest - name: Set up Docker Buildx uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 with: driver-opts: | - image=ghcr.io/amitie10g/buildkit:master + image=ghcr.io/sysadminsmedia/buildkit:master - name: Build and push by digest id: build @@ -118,10 +118,18 @@ jobs: VERSION=${{ github.ref_name }} COMMIT=${{ github.sha }} BUILD_TIME=${{ env.BUILD_TIME }} - provenance: true + provenance: mode=max sbom: true annotations: ${{ steps.meta.outputs.annotations }} - + + - name: Attest platform-specific images + uses: actions/attest-build-provenance@v1 + if: github.event_name != 'pull_request' + with: + subject-name: ${{ env.GHCR_REPO }} + subject-digest: ${{ steps.build.outputs.digest }} + push-to-registry: true + - name: Export digest run: | mkdir -p /tmp/digests @@ -173,7 +181,7 @@ jobs: uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 with: driver-opts: | - image=ghcr.io/amitie10g/buildkit:master + image=ghcr.io/sysadminsmedia/buildkit:master - name: Docker meta id: meta @@ -196,13 +204,45 @@ jobs: id: push-ghcr working-directory: /tmp/digests run: | + set -euo pipefail docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf '${{ env.GHCR_REPO }}@sha256:%s ' *) + $(printf '${{ env.GHCR_REPO }}@sha256:%s ' *) 2>&1 | tee /tmp/push-ghcr.out + digest=$(grep -oE 'sha256:[a-f0-9]{64}' /tmp/push-ghcr.out | head -n1 || true) + if [ -z "$digest" ]; then + echo "No digest found in imagetools output:" + cat /tmp/push-ghcr.out + exit 1 + fi + echo "digest=$digest" >> $GITHUB_OUTPUT + + - name: Attest GHCR images + uses: actions/attest-build-provenance@v1 + if: github.event_name != 'pull_request' + with: + subject-name: ${{ env.GHCR_REPO }} + subject-digest: ${{ steps.push-ghcr.outputs.digest }} + push-to-registry: true - name: Create manifest list and push Dockerhub id: push-dockerhub working-directory: /tmp/digests if: (github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/')) run: | + set -euo pipefail docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf '${{ env.DOCKERHUB_REPO }}@sha256:%s ' *) + $(printf '${{ env.DOCKERHUB_REPO }}@sha256:%s ' *) 2>&1 | tee /tmp/push-dockerhub.out + digest=$(grep -oE 'sha256:[a-f0-9]{64}' /tmp/push-dockerhub.out | head -n1 || true) + if [ -z "$digest" ]; then + echo "No digest found in imagetools output:" + cat /tmp/push-dockerhub.out + exit 1 + fi + echo "digest=$digest" >> $GITHUB_OUTPUT + + - name: Attest Dockerhub images + uses: actions/attest-build-provenance@v1 + if: (github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/')) + with: + subject-name: docker.io/${{ env.DOCKERHUB_REPO }} + subject-digest: ${{ steps.push-dockerhub.outputs.digest }} + push-to-registry: true diff --git a/.github/workflows/docker-publish-rootless.yaml b/.github/workflows/docker-publish-rootless.yaml index 0a3d9188..004a4040 100644 --- a/.github/workflows/docker-publish-rootless.yaml +++ b/.github/workflows/docker-publish-rootless.yaml @@ -98,13 +98,13 @@ jobs: - name: Set up QEMU uses: docker/setup-qemu-action@v3 with: - image: ghcr.io/amitie10g/binfmt:latest + image: ghcr.io/sysadminsmedia/binfmt:latest - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: driver-opts: | - image=ghcr.io/amitie10g/buildkit:master + image=ghcr.io/sysadminsmedia/buildkit:master - name: Build and push by digest id: build @@ -120,10 +120,18 @@ jobs: build-args: | VERSION=${{ github.ref_name }} COMMIT=${{ github.sha }} - provenance: true + provenance: mode=max sbom: true annotations: ${{ steps.meta.outputs.annotations }} - + + - name: Attest platform-specific images + uses: actions/attest-build-provenance@v1 + if: github.event_name != 'pull_request' + with: + subject-name: ${{ env.GHCR_REPO }} + subject-digest: ${{ steps.build.outputs.digest }} + push-to-registry: true + - name: Export digest run: | mkdir -p /tmp/digests @@ -175,7 +183,7 @@ jobs: uses: docker/setup-buildx-action@v3 with: driver-opts: | - image=ghcr.io/amitie10g/buildkit:master + image=ghcr.io/sysadminsmedia/buildkit:master - name: Docker meta id: meta @@ -198,13 +206,45 @@ jobs: id: push-ghcr working-directory: /tmp/digests run: | + set -euo pipefail docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf '${{ env.GHCR_REPO }}@sha256:%s ' *) + $(printf '${{ env.GHCR_REPO }}@sha256:%s ' *) 2>&1 | tee /tmp/push-ghcr.out + digest=$(grep -oE 'sha256:[a-f0-9]{64}' /tmp/push-ghcr.out | head -n1 || true) + if [ -z "$digest" ]; then + echo "No digest found in imagetools output:" + cat /tmp/push-ghcr.out + exit 1 + fi + echo "digest=$digest" >> $GITHUB_OUTPUT + + - name: Attest GHCR images + uses: actions/attest-build-provenance@v1 + if: github.event_name != 'pull_request' + with: + subject-name: ${{ env.GHCR_REPO }} + subject-digest: ${{ steps.push-ghcr.outputs.digest }} + push-to-registry: true - name: Create manifest list and push Dockerhub id: push-dockerhub working-directory: /tmp/digests if: (github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/')) run: | + set -euo pipefail docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf '${{ env.DOCKERHUB_REPO }}@sha256:%s ' *) + $(printf '${{ env.DOCKERHUB_REPO }}@sha256:%s ' *) 2>&1 | tee /tmp/push-dockerhub.out + digest=$(grep -oE 'sha256:[a-f0-9]{64}' /tmp/push-dockerhub.out | head -n1 || true) + if [ -z "$digest" ]; then + echo "No digest found in imagetools output:" + cat /tmp/push-dockerhub.out + exit 1 + fi + echo "digest=$digest" >> $GITHUB_OUTPUT + + - name: Attest Dockerhub images + uses: actions/attest-build-provenance@v1 + if: (github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/')) + with: + subject-name: docker.io/${{ env.DOCKERHUB_REPO }} + subject-digest: ${{ steps.push-dockerhub.outputs.digest }} + push-to-registry: true diff --git a/.github/workflows/docker-publish.yaml b/.github/workflows/docker-publish.yaml index f52287cb..6fcc67d6 100644 --- a/.github/workflows/docker-publish.yaml +++ b/.github/workflows/docker-publish.yaml @@ -93,13 +93,13 @@ jobs: - name: Set up QEMU uses: docker/setup-qemu-action@v3 with: - image: ghcr.io/amitie10g/binfmt:latest + image: ghcr.io/sysadminsmedia/binfmt:latest - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: driver-opts: | - image=ghcr.io/amitie10g/buildkit:master + image=ghcr.io/sysadminsmedia/buildkit:latest - name: Build and push by digest id: build @@ -113,10 +113,18 @@ jobs: build-args: | VERSION=${{ github.ref_name }} COMMIT=${{ github.sha }} - provenance: true + provenance: mode=max sbom: true annotations: ${{ steps.meta.outputs.annotations }} + - name: Attest platform-specific images + uses: actions/attest-build-provenance@v1 + if: github.event_name != 'pull_request' + with: + subject-name: ${{ env.GHCR_REPO }} + subject-digest: ${{ steps.build.outputs.digest }} + push-to-registry: true + - name: Export digest run: | mkdir -p /tmp/digests @@ -168,7 +176,7 @@ jobs: uses: docker/setup-buildx-action@v3 with: driver-opts: | - image=ghcr.io/amitie10g/buildkit:master + image=ghcr.io/sysadminsmedia/buildkit:master - name: Docker meta id: meta @@ -189,13 +197,45 @@ jobs: id: push-ghcr working-directory: /tmp/digests run: | + set -euo pipefail docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf '${{ env.GHCR_REPO }}@sha256:%s ' *) + $(printf '${{ env.GHCR_REPO }}@sha256:%s ' *) 2>&1 | tee /tmp/push-ghcr.out + digest=$(grep -oE 'sha256:[a-f0-9]{64}' /tmp/push-ghcr.out | head -n1 || true) + if [ -z "$digest" ]; then + echo "No digest found in imagetools output:" + cat /tmp/push-ghcr.out + exit 1 + fi + echo "digest=$digest" >> $GITHUB_OUTPUT + + - name: Attest GHCR images + uses: actions/attest-build-provenance@v1 + if: github.event_name != 'pull_request' + with: + subject-name: ${{ env.GHCR_REPO }} + subject-digest: ${{ steps.push-ghcr.outputs.digest }} + push-to-registry: true - name: Create manifest list and push Dockerhub id: push-dockerhub working-directory: /tmp/digests if: (github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/')) run: | + set -euo pipefail docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf '${{ env.DOCKERHUB_REPO }}@sha256:%s ' *) + $(printf '${{ env.DOCKERHUB_REPO }}@sha256:%s ' *) 2>&1 | tee /tmp/push-dockerhub.out + digest=$(grep -oE 'sha256:[a-f0-9]{64}' /tmp/push-dockerhub.out | head -n1 || true) + if [ -z "$digest" ]; then + echo "No digest found in imagetools output:" + cat /tmp/push-dockerhub.out + exit 1 + fi + echo "digest=$digest" >> $GITHUB_OUTPUT + + - name: Attest Dockerhub images + uses: actions/attest-build-provenance@v1 + if: (github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/')) + with: + subject-name: docker.io/${{ env.DOCKERHUB_REPO }} + subject-digest: ${{ steps.push-dockerhub.outputs.digest }} + push-to-registry: true diff --git a/.gitignore b/.gitignore index b769d9a2..15a2f234 100644 --- a/.gitignore +++ b/.gitignore @@ -60,7 +60,7 @@ backend/app/api/static/public/* backend/api docs/.vitepress/cache/ -/.data/ +.data/ # Playwright frontend/test-results/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..bd1bd00b --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,603 @@ +include: + - template: Jobs/SAST.gitlab-ci.yml + - component: $CI_SERVER_FQDN/components/code-quality-oss/codequality-os-scanners-integration/codequality-oss@1.1.4 + - component: $CI_SERVER_FQDN/components/code-intelligence/golang-code-intel@v0.3.1 + - component: $CI_SERVER_FQDN/components/code-intelligence/typescript-code-intel@v0.3.1 + inputs: + node_version: 24 + - component: $CI_SERVER_FQDN/components/secret-detection/secret-detection@2.1.0 + +variables: + GITLAB_ADVANCED_SAST_ENABLED: 'true' + ADVANCED_SAST_PARTIAL_SCAN: 'differential' + DOCKER_DRIVER: overlay2 + DOCKER_TLS_CERTDIR: "/certs" + # Registry configuration - adjust as needed + CI_REGISTRY_IMAGE: $CI_REGISTRY/$CI_PROJECT_PATH + +stages: + - test + - build-binaries + - build-docker + - release + +# ========================================== +# Test Jobs +# ========================================== + +# Backend Tests (Go) +test:backend: + stage: test + image: golang:1.24 + cache: + key: + files: + - backend/go.sum + paths: + - backend/.go-pkg-cache/ + policy: pull-push + before_script: + - export GOMODCACHE=$(pwd)/backend/.go-pkg-cache + # Install Task + - sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin + script: + - cd backend + - task go:lint + - task go:build + - task go:coverage + coverage: '/coverage: \d+.\d+% of statements/' + artifacts: + reports: + coverage_report: + coverage_format: cobertura + path: backend/coverage.out + paths: + - backend/coverage.out + expire_in: 7 days + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + +# Frontend Lint and Typecheck +test:frontend:lint: + stage: test + image: node:22-alpine + cache: + key: + files: + - frontend/pnpm-lock.yaml + paths: + - frontend/node_modules/ + - .pnpm-store/ + policy: pull-push + before_script: + - npm install -g pnpm@9.15.3 + - pnpm config set store-dir $(pwd)/.pnpm-store + script: + - cd frontend + - pnpm install --frozen-lockfile + - pnpm run lint:ci + - pnpm run typecheck + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + +# Frontend Integration Tests (SQLite) +test:frontend:integration: + stage: test + image: node:22 + cache: + - key: + files: + - frontend/pnpm-lock.yaml + paths: + - frontend/node_modules/ + - .pnpm-store/ + policy: pull-push + - key: + files: + - backend/go.sum + paths: + - backend/.go-pkg-cache/ + policy: pull-push + before_script: + - npm install -g pnpm@9.15.3 + - pnpm config set store-dir $(pwd)/.pnpm-store + # Install Task + - sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin + # Install Go + - wget -q https://go.dev/dl/go1.24.0.linux-amd64.tar.gz + - tar -C /usr/local -xzf go1.24.0.linux-amd64.tar.gz + - export PATH=$PATH:/usr/local/go/bin + - export GOMODCACHE=$(pwd)/backend/.go-pkg-cache + script: + - cd frontend + - pnpm install --frozen-lockfile + - cd .. + - task test:ci + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + +# Frontend Integration Tests (PostgreSQL Matrix) +test:frontend:integration:postgresql: + stage: test + image: node:22 + services: + - name: postgres:${POSTGRES_VERSION} + alias: postgres + variables: + POSTGRES_USER: homebox + POSTGRES_PASSWORD: homebox + POSTGRES_DB: homebox + POSTGRES_HOST_AUTH_METHOD: trust + parallel: + matrix: + - POSTGRES_VERSION: ["17", "16", "15"] + cache: + - key: + files: + - frontend/pnpm-lock.yaml + paths: + - frontend/node_modules/ + - .pnpm-store/ + policy: pull-push + - key: + files: + - backend/go.sum + paths: + - backend/.go-pkg-cache/ + policy: pull-push + before_script: + - npm install -g pnpm@9.15.3 + - pnpm config set store-dir $(pwd)/.pnpm-store + # Install Task + - sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin + # Install Go + - wget -q https://go.dev/dl/go1.24.0.linux-amd64.tar.gz + - tar -C /usr/local -xzf go1.24.0.linux-amd64.tar.gz + - export PATH=$PATH:/usr/local/go/bin + - export GOMODCACHE=$(pwd)/backend/.go-pkg-cache + script: + - cd frontend + - pnpm install --frozen-lockfile + - cd .. + - task test:ci:postgresql + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + +# E2E Tests (Playwright) - Sharded +test:e2e:playwright: + stage: test + image: mcr.microsoft.com/playwright:v1.48.2-jammy + timeout: 1h + parallel: + matrix: + - SHARD_INDEX: ["1", "2", "3", "4"] + SHARD_TOTAL: "4" + cache: + - key: + files: + - frontend/pnpm-lock.yaml + paths: + - frontend/node_modules/ + - .pnpm-store/ + policy: pull-push + - key: + files: + - backend/go.sum + paths: + - backend/.go-pkg-cache/ + policy: pull-push + before_script: + - npm install -g pnpm@9.15.3 + - pnpm config set store-dir $(pwd)/.pnpm-store + # Install Task + - sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin + # Install Go + - wget -q https://go.dev/dl/go1.24.0.linux-amd64.tar.gz + - tar -C /usr/local -xzf go1.24.0.linux-amd64.tar.gz + - export PATH=$PATH:/usr/local/go/bin + - export GOMODCACHE=$(pwd)/backend/.go-pkg-cache + script: + - cd frontend + - pnpm install --frozen-lockfile + - cd .. + - cd backend && go mod download + - task test:e2e -- --shard=$SHARD_INDEX/$SHARD_TOTAL + artifacts: + when: always + paths: + - frontend/blob-report/ + expire_in: 2 days + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + +# E2E Reports Merge +test:e2e:merge-reports: + stage: test + image: mcr.microsoft.com/playwright:v1.48.2-jammy + needs: + - test:e2e:playwright + cache: + key: + files: + - frontend/pnpm-lock.yaml + paths: + - frontend/node_modules/ + - .pnpm-store/ + policy: pull + before_script: + - npm install -g pnpm@9.15.3 + - pnpm config set store-dir $(pwd)/.pnpm-store + script: + - cd frontend + - pnpm install --frozen-lockfile + # Download all blob reports + - mkdir -p all-blob-reports + # GitLab automatically downloads artifacts from dependencies + - cp -r ../frontend/blob-report/* all-blob-reports/ || true + - pnpm exec playwright merge-reports --reporter html,github ./all-blob-reports || true + artifacts: + when: always + paths: + - frontend/playwright-report/ + expire_in: 30 days + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + when: always + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + when: always + +# Update Currencies (Scheduled Job) +update:currencies: + stage: test + image: python:3.11 + cache: + key: python-currencies + paths: + - .pip-cache/ + before_script: + - pip install --cache-dir .pip-cache -r .github/workflows/update-currencies/requirements.txt + script: + - python .github/scripts/update_currencies.py + - | + if git diff --quiet -- backend/internal/core/currencies/currencies.json; then + echo "✅ currencies.json is already up-to-date" + exit 0 + else + echo "Changes detected in currencies.json" + git config user.name "GitLab CI" + git config user.email "ci@gitlab.com" + git checkout -b update-currencies-$CI_COMMIT_SHORT_SHA + git add backend/internal/core/currencies/currencies.json + git commit -m "chore: update currencies.json" + git push -o merge_request.create -o merge_request.target=$CI_DEFAULT_BRANCH -o merge_request.title="Update currencies.json" origin update-currencies-$CI_COMMIT_SHORT_SHA + fi + rules: + - if: $CI_PIPELINE_SOURCE == "schedule" && $UPDATE_CURRENCIES == "true" + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $UPDATE_CURRENCIES == "true" + +# ========================================== +# Binary Build with GoReleaser +# ========================================== +build:binaries: + stage: build-binaries + image: golang:1.24 + cache: + - key: + files: + - frontend/pnpm-lock.yaml + paths: + - frontend/node_modules/ + - .pnpm-store/ + policy: pull-push + - key: + files: + - backend/go.sum + paths: + - backend/.go-pkg-cache/ + policy: pull-push + before_script: + # Install Node.js and pnpm for frontend build + - curl -fsSL https://deb.nodesource.com/setup_22.x | bash - + - apt-get install -y nodejs + - npm install -g pnpm@9.15.3 + # Configure pnpm store + - pnpm config set store-dir $(pwd)/.pnpm-store + # Install GoReleaser + - curl -sfL https://goreleaser.com/static/run | bash -s -- check + - curl -sfL https://goreleaser.com/static/run | bash -s -- --version + # Configure Go cache + - export GOMODCACHE=$(pwd)/backend/.go-pkg-cache + script: + # Build frontend + - cd frontend + - pnpm install --frozen-lockfile + - pnpm run build + - cp -r ./.output/public ../backend/app/api/static/ + - cd .. + # Run GoReleaser + - cd backend + - | + if [ -n "$CI_COMMIT_TAG" ]; then + echo "Building release for tag: $CI_COMMIT_TAG" + curl -sfL https://goreleaser.com/static/run | bash -s -- release --clean --skip=publish + else + echo "Building snapshot" + curl -sfL https://goreleaser.com/static/run | bash -s -- release --clean --snapshot --skip=publish + fi + artifacts: + name: "homebox-binaries-$CI_COMMIT_REF_SLUG" + paths: + - backend/dist/ + expire_in: 30 days + rules: + - if: $CI_COMMIT_TAG + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + +# ========================================== +# Docker Build Jobs - Regular +# ========================================== +.docker_build_template: + stage: build-docker + image: docker:latest + services: + - docker:dind + before_script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + variables: + DOCKER_BUILDKIT: 1 + DOCKERFILE: Dockerfile + IMAGE_SUFFIX: "" + script: + - export VERSION=${CI_COMMIT_TAG:-$CI_COMMIT_REF_NAME} + - export COMMIT=$CI_COMMIT_SHA + - export BUILD_TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ) + - export CACHE_TAG=${IMAGE_SUFFIX:-regular} + # Build and push for the specific platform with layer caching + - | + docker buildx create --use --name builder-${CI_JOB_ID} || true + docker buildx build \ + --platform $PLATFORM \ + --build-arg VERSION=$VERSION \ + --build-arg COMMIT=$COMMIT \ + --build-arg BUILD_TIME=$BUILD_TIME \ + --cache-from type=registry,ref=$CI_REGISTRY_IMAGE/cache:${PLATFORM_PAIR}-${CACHE_TAG}-$CI_COMMIT_REF_SLUG \ + --cache-from type=registry,ref=$CI_REGISTRY_IMAGE/cache:${PLATFORM_PAIR}-${CACHE_TAG}-$CI_DEFAULT_BRANCH \ + --cache-to type=registry,ref=$CI_REGISTRY_IMAGE/cache:${PLATFORM_PAIR}-${CACHE_TAG}-$CI_COMMIT_REF_SLUG,mode=max \ + --file ./$DOCKERFILE \ + --tag $CI_REGISTRY_IMAGE${IMAGE_SUFFIX}:${CI_COMMIT_REF_SLUG}-${PLATFORM_PAIR} \ + --push \ + . + docker buildx rm builder-${CI_JOB_ID} || true + rules: + - if: $CI_COMMIT_TAG + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + +docker:build:amd64: + extends: .docker_build_template + variables: + PLATFORM: linux/amd64 + PLATFORM_PAIR: linux-amd64 + +docker:build:arm64: + extends: .docker_build_template + variables: + PLATFORM: linux/arm64 + PLATFORM_PAIR: linux-arm64 + +docker:build:armv7: + extends: .docker_build_template + variables: + PLATFORM: linux/arm/v7 + PLATFORM_PAIR: linux-arm-v7 + +# ========================================== +# Docker Build Jobs - Rootless +# ========================================== +docker:build:rootless:amd64: + extends: .docker_build_template + variables: + PLATFORM: linux/amd64 + PLATFORM_PAIR: linux-amd64 + DOCKERFILE: Dockerfile.rootless + IMAGE_SUFFIX: -rootless + +docker:build:rootless:arm64: + extends: .docker_build_template + variables: + PLATFORM: linux/arm64 + PLATFORM_PAIR: linux-arm64 + DOCKERFILE: Dockerfile.rootless + IMAGE_SUFFIX: -rootless + +docker:build:rootless:armv7: + extends: .docker_build_template + variables: + PLATFORM: linux/arm/v7 + PLATFORM_PAIR: linux-arm-v7 + DOCKERFILE: Dockerfile.rootless + IMAGE_SUFFIX: -rootless + +# ========================================== +# Docker Build Jobs - Hardened +# ========================================== +docker:build:hardened:amd64: + extends: .docker_build_template + variables: + PLATFORM: linux/amd64 + PLATFORM_PAIR: linux-amd64 + DOCKERFILE: Dockerfile.hardened + IMAGE_SUFFIX: -hardened + +docker:build:hardened:arm64: + extends: .docker_build_template + variables: + PLATFORM: linux/arm64 + PLATFORM_PAIR: linux-arm64 + DOCKERFILE: Dockerfile.hardened + IMAGE_SUFFIX: -hardened + +docker:build:hardened:armv7: + extends: .docker_build_template + variables: + PLATFORM: linux/arm/v7 + PLATFORM_PAIR: linux-arm-v7 + DOCKERFILE: Dockerfile.hardened + IMAGE_SUFFIX: -hardened + +# ========================================== +# Docker Manifest Creation - Regular +# ========================================== +docker:manifest: + stage: release + image: docker:latest + services: + - docker:dind + before_script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + script: + - export VERSION=${CI_COMMIT_TAG:-$CI_COMMIT_REF_NAME} + # Create manifest for regular image + - | + docker manifest create $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG \ + $CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}-linux-amd64 \ + $CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}-linux-arm64 \ + $CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}-linux-arm-v7 + docker manifest push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG + # Tag as latest on main branch or create version tags + - | + if [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ]; then + docker manifest create $CI_REGISTRY_IMAGE:latest \ + $CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}-linux-amd64 \ + $CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}-linux-arm64 \ + $CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}-linux-arm-v7 + docker manifest push $CI_REGISTRY_IMAGE:latest + fi + - | + if [ -n "$CI_COMMIT_TAG" ]; then + # Create version tag + docker manifest create $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG \ + $CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}-linux-amd64 \ + $CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}-linux-arm64 \ + $CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}-linux-arm-v7 + docker manifest push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG + + # Create major.minor tag if semantic version + MAJOR_MINOR=$(echo $CI_COMMIT_TAG | sed -E 's/^v?([0-9]+\.[0-9]+)\..*/\1/') + if [ -n "$MAJOR_MINOR" ]; then + docker manifest create $CI_REGISTRY_IMAGE:$MAJOR_MINOR \ + $CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}-linux-amd64 \ + $CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}-linux-arm64 \ + $CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}-linux-arm-v7 + docker manifest push $CI_REGISTRY_IMAGE:$MAJOR_MINOR + fi + fi + needs: + - docker:build:amd64 + - docker:build:arm64 + - docker:build:armv7 + rules: + - if: $CI_COMMIT_TAG + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + +# ========================================== +# Docker Manifest Creation - Rootless +# ========================================== +docker:manifest:rootless: + stage: release + image: docker:latest + services: + - docker:dind + before_script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + script: + - export VERSION=${CI_COMMIT_TAG:-$CI_COMMIT_REF_NAME} + # Create manifest for rootless image + - | + docker manifest create $CI_REGISTRY_IMAGE-rootless:$CI_COMMIT_REF_SLUG \ + $CI_REGISTRY_IMAGE-rootless:${CI_COMMIT_REF_SLUG}-linux-amd64 \ + $CI_REGISTRY_IMAGE-rootless:${CI_COMMIT_REF_SLUG}-linux-arm64 + docker manifest push $CI_REGISTRY_IMAGE-rootless:$CI_COMMIT_REF_SLUG + # Tag as latest on main branch or create version tags + - | + if [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ]; then + docker manifest create $CI_REGISTRY_IMAGE-rootless:latest \ + $CI_REGISTRY_IMAGE-rootless:${CI_COMMIT_REF_SLUG}-linux-amd64 \ + $CI_REGISTRY_IMAGE-rootless:${CI_COMMIT_REF_SLUG}-linux-arm64 + docker manifest push $CI_REGISTRY_IMAGE-rootless:latest + fi + - | + if [ -n "$CI_COMMIT_TAG" ]; then + docker manifest create $CI_REGISTRY_IMAGE-rootless:$CI_COMMIT_TAG \ + $CI_REGISTRY_IMAGE-rootless:${CI_COMMIT_REF_SLUG}-linux-amd64 \ + $CI_REGISTRY_IMAGE-rootless:${CI_COMMIT_REF_SLUG}-linux-arm64 + docker manifest push $CI_REGISTRY_IMAGE-rootless:$CI_COMMIT_TAG + + MAJOR_MINOR=$(echo $CI_COMMIT_TAG | sed -E 's/^v?([0-9]+\.[0-9]+)\..*/\1/') + if [ -n "$MAJOR_MINOR" ]; then + docker manifest create $CI_REGISTRY_IMAGE-rootless:$MAJOR_MINOR \ + $CI_REGISTRY_IMAGE-rootless:${CI_COMMIT_REF_SLUG}-linux-amd64 \ + $CI_REGISTRY_IMAGE-rootless:${CI_COMMIT_REF_SLUG}-linux-arm64 + docker manifest push $CI_REGISTRY_IMAGE-rootless:$MAJOR_MINOR + fi + fi + needs: + - docker:build:rootless:amd64 + - docker:build:rootless:arm64 + rules: + - if: $CI_COMMIT_TAG + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + +# ========================================== +# Docker Manifest Creation - Hardened +# ========================================== +docker:manifest:hardened: + stage: release + image: docker:latest + services: + - docker:dind + before_script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + script: + - export VERSION=${CI_COMMIT_TAG:-$CI_COMMIT_REF_NAME} + # Create manifest for hardened image + - | + docker manifest create $CI_REGISTRY_IMAGE-hardened:$CI_COMMIT_REF_SLUG \ + $CI_REGISTRY_IMAGE-hardened:${CI_COMMIT_REF_SLUG}-linux-amd64 \ + $CI_REGISTRY_IMAGE-hardened:${CI_COMMIT_REF_SLUG}-linux-arm64 + docker manifest push $CI_REGISTRY_IMAGE-hardened:$CI_COMMIT_REF_SLUG + # Tag as latest on main branch or create version tags + - | + if [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ]; then + docker manifest create $CI_REGISTRY_IMAGE-hardened:latest \ + $CI_REGISTRY_IMAGE-hardened:${CI_COMMIT_REF_SLUG}-linux-amd64 \ + $CI_REGISTRY_IMAGE-hardened:${CI_COMMIT_REF_SLUG}-linux-arm64 + docker manifest push $CI_REGISTRY_IMAGE-hardened:latest + fi + - | + if [ -n "$CI_COMMIT_TAG" ]; then + docker manifest create $CI_REGISTRY_IMAGE-hardened:$CI_COMMIT_TAG \ + $CI_REGISTRY_IMAGE-hardened:${CI_COMMIT_REF_SLUG}-linux-amd64 \ + $CI_REGISTRY_IMAGE-hardened:${CI_COMMIT_REF_SLUG}-linux-arm64 + docker manifest push $CI_REGISTRY_IMAGE-hardened:$CI_COMMIT_TAG + + MAJOR_MINOR=$(echo $CI_COMMIT_TAG | sed -E 's/^v?([0-9]+\.[0-9]+)\..*/\1/') + if [ -n "$MAJOR_MINOR" ]; then + docker manifest create $CI_REGISTRY_IMAGE-hardened:$MAJOR_MINOR \ + $CI_REGISTRY_IMAGE-hardened:${CI_COMMIT_REF_SLUG}-linux-amd64 \ + $CI_REGISTRY_IMAGE-hardened:${CI_COMMIT_REF_SLUG}-linux-arm64 + docker manifest push $CI_REGISTRY_IMAGE-hardened:$MAJOR_MINOR + fi + fi + needs: + - docker:build:hardened:amd64 + - docker:build:hardened:arm64 + rules: + - if: $CI_COMMIT_TAG + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH diff --git a/Dockerfile b/Dockerfile index 89f4249a..c2484382 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Node dependencies stage -FROM public.ecr.aws/docker/library/node:lts-alpine AS frontend-dependencies +FROM public.ecr.aws/docker/library/node:22-alpine AS frontend-dependencies WORKDIR /app # Install pnpm globally (caching layer) @@ -10,7 +10,7 @@ COPY frontend/package.json frontend/pnpm-lock.yaml ./ RUN pnpm install --frozen-lockfile # Build Nuxt (frontend) stage -FROM public.ecr.aws/docker/library/node:lts-alpine AS frontend-builder +FROM public.ecr.aws/docker/library/node:22-alpine AS frontend-builder WORKDIR /app # Install pnpm globally again (it can reuse the cache if not changed) diff --git a/Dockerfile.hardened b/Dockerfile.hardened index 1851a641..2c253d5b 100644 --- a/Dockerfile.hardened +++ b/Dockerfile.hardened @@ -1,7 +1,7 @@ # --------------------------------------- # Node dependencies stage # --------------------------------------- -FROM public.ecr.aws/docker/library/node:lts-alpine AS frontend-dependencies +FROM public.ecr.aws/docker/library/node:22-alpine AS frontend-dependencies WORKDIR /app # Install pnpm globally (caching layer) @@ -14,7 +14,7 @@ RUN pnpm install --frozen-lockfile # --------------------------------------- # Build Nuxt (frontend) stage # --------------------------------------- -FROM public.ecr.aws/docker/library/node:lts-alpine AS frontend-builder +FROM public.ecr.aws/docker/library/node:22-alpine AS frontend-builder WORKDIR /app # Install pnpm globally again (it can reuse the cache if not changed) diff --git a/Dockerfile.rootless b/Dockerfile.rootless index 06a5737d..ba7b0656 100644 --- a/Dockerfile.rootless +++ b/Dockerfile.rootless @@ -1,5 +1,5 @@ # Node dependencies stage -FROM public.ecr.aws/docker/library/node:lts-alpine AS frontend-dependencies +FROM public.ecr.aws/docker/library/node:22-alpine AS frontend-dependencies WORKDIR /app # Install pnpm globally (caching layer) @@ -10,7 +10,7 @@ COPY frontend/package.json frontend/pnpm-lock.yaml ./ RUN pnpm install --frozen-lockfile # Build Nuxt (frontend) stage -FROM public.ecr.aws/docker/library/node:lts-alpine AS frontend-builder +FROM public.ecr.aws/docker/library/node:22-alpine AS frontend-builder WORKDIR /app # Install pnpm globally again (it can reuse the cache if not changed) diff --git a/backend/.goreleaser.yaml b/backend/.goreleaser.yaml index b2ac7fa7..d6b77631 100644 --- a/backend/.goreleaser.yaml +++ b/backend/.goreleaser.yaml @@ -47,15 +47,14 @@ builds: signs: - cmd: cosign - stdin: "{{ .Env.COSIGN_PWD }}" + signature: "${artifact}.sigstore.json" args: - - "sign-blob" - - "--key=cosign.key" - - "--output-signature=${signature}" + - sign-blob + - "--bundle=${signature}" - "${artifact}" - - "--yes" # needed on cosign 2.0.0+ - artifacts: all - + - "--yes" + artifacts: checksum + output: true archives: - formats: [ 'tar.gz' ] # this name template makes the OS and Arch compatible with the results of uname. @@ -70,7 +69,8 @@ archives: format_overrides: - goos: windows formats: [ 'zip' ] - +sboms: + - artifacts: archive release: extra_files: - glob: dist/*.sig diff --git a/backend/app/api/handlers/v1/controller.go b/backend/app/api/handlers/v1/controller.go index c77cff3b..844ed8e4 100644 --- a/backend/app/api/handlers/v1/controller.go +++ b/backend/app/api/handlers/v1/controller.go @@ -10,6 +10,7 @@ import ( "github.com/hay-kot/httpkit/errchain" "github.com/hay-kot/httpkit/server" "github.com/rs/zerolog/log" + "github.com/sysadminsmedia/homebox/backend/app/api/providers" "github.com/sysadminsmedia/homebox/backend/internal/core/services" "github.com/sysadminsmedia/homebox/backend/internal/core/services/reporting/eventbus" "github.com/sysadminsmedia/homebox/backend/internal/data/repo" @@ -74,6 +75,7 @@ type V1Controller struct { bus *eventbus.EventBus url string config *config.Config + oidcProvider *providers.OIDCProvider } type ( @@ -95,6 +97,14 @@ type ( Demo bool `json:"demo"` AllowRegistration bool `json:"allowRegistration"` LabelPrinting bool `json:"labelPrinting"` + OIDC OIDCStatus `json:"oidc"` + } + + OIDCStatus struct { + Enabled bool `json:"enabled"` + ButtonText string `json:"buttonText,omitempty"` + AutoRedirect bool `json:"autoRedirect,omitempty"` + AllowLocal bool `json:"allowLocal"` } ) @@ -111,9 +121,23 @@ func NewControllerV1(svc *services.AllServices, repos *repo.AllRepos, bus *event opt(ctrl) } + ctrl.initOIDCProvider() + return ctrl } +func (ctrl *V1Controller) initOIDCProvider() { + if ctrl.config.OIDC.Enabled { + oidcProvider, err := providers.NewOIDCProvider(ctrl.svc.User, &ctrl.config.OIDC, &ctrl.config.Options, ctrl.cookieSecure) + if err != nil { + log.Err(err).Msg("failed to initialize OIDC provider at startup") + } else { + ctrl.oidcProvider = oidcProvider + log.Info().Msg("OIDC provider initialized successfully at startup") + } + } +} + // HandleBase godoc // // @Summary Application Info @@ -132,6 +156,12 @@ func (ctrl *V1Controller) HandleBase(ready ReadyFunc, build Build) errchain.Hand Demo: ctrl.isDemo, AllowRegistration: ctrl.allowRegistration, LabelPrinting: ctrl.config.LabelMaker.PrintCommand != nil, + OIDC: OIDCStatus{ + Enabled: ctrl.config.OIDC.Enabled, + ButtonText: ctrl.config.OIDC.ButtonText, + AutoRedirect: ctrl.config.OIDC.AutoRedirect, + AllowLocal: ctrl.config.Options.AllowLocalLogin, + }, }) } } diff --git a/backend/app/api/handlers/v1/v1_ctrl_auth.go b/backend/app/api/handlers/v1/v1_ctrl_auth.go index 64d556fe..defc8175 100644 --- a/backend/app/api/handlers/v1/v1_ctrl_auth.go +++ b/backend/app/api/handlers/v1/v1_ctrl_auth.go @@ -2,6 +2,7 @@ package v1 import ( "errors" + "fmt" "net/http" "strconv" "strings" @@ -106,6 +107,11 @@ func (ctrl *V1Controller) HandleAuthLogin(ps ...AuthProvider) errchain.HandlerFu provider = "local" } + // Block local only when disabled + if provider == "local" && !ctrl.config.Options.AllowLocalLogin { + return validate.NewRequestError(fmt.Errorf("local login is not enabled"), http.StatusForbidden) + } + // Get the provider p, ok := providers[provider] if !ok { @@ -114,8 +120,8 @@ func (ctrl *V1Controller) HandleAuthLogin(ps ...AuthProvider) errchain.HandlerFu newToken, err := p.Authenticate(w, r) if err != nil { - log.Err(err).Msg("failed to authenticate") - return server.JSON(w, http.StatusInternalServerError, err.Error()) + log.Warn().Err(err).Msg("authentication failed") + return validate.NewUnauthorizedError() } ctrl.setCookies(w, noPort(r.Host), newToken.Raw, newToken.ExpiresAt, true) @@ -247,3 +253,65 @@ func (ctrl *V1Controller) unsetCookies(w http.ResponseWriter, domain string) { Path: "/", }) } + +// HandleOIDCLogin godoc +// +// @Summary OIDC Login Initiation +// @Tags Authentication +// @Produce json +// @Success 302 +// @Router /v1/users/login/oidc [GET] +func (ctrl *V1Controller) HandleOIDCLogin() errchain.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) error { + // Forbidden if OIDC is not enabled + if !ctrl.config.OIDC.Enabled { + return validate.NewRequestError(fmt.Errorf("OIDC is not enabled"), http.StatusForbidden) + } + + // Check if OIDC provider is available + if ctrl.oidcProvider == nil { + log.Error().Msg("OIDC provider not initialized") + return validate.NewRequestError(errors.New("OIDC provider not available"), http.StatusInternalServerError) + } + + // Initiate OIDC flow + _, err := ctrl.oidcProvider.InitiateOIDCFlow(w, r) + return err + } +} + +// HandleOIDCCallback godoc +// +// @Summary OIDC Callback Handler +// @Tags Authentication +// @Param code query string true "Authorization code" +// @Param state query string true "State parameter" +// @Success 302 +// @Router /v1/users/login/oidc/callback [GET] +func (ctrl *V1Controller) HandleOIDCCallback() errchain.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) error { + // Forbidden if OIDC is not enabled + if !ctrl.config.OIDC.Enabled { + return validate.NewRequestError(fmt.Errorf("OIDC is not enabled"), http.StatusForbidden) + } + + // Check if OIDC provider is available + if ctrl.oidcProvider == nil { + log.Error().Msg("OIDC provider not initialized") + return validate.NewRequestError(errors.New("OIDC provider not available"), http.StatusInternalServerError) + } + + // Handle callback + newToken, err := ctrl.oidcProvider.HandleCallback(w, r) + if err != nil { + log.Err(err).Msg("OIDC callback failed") + http.Redirect(w, r, "/?oidc_error=oidc_auth_failed", http.StatusFound) + return nil + } + + // Set cookies and redirect to home + ctrl.setCookies(w, noPort(r.Host), newToken.Raw, newToken.ExpiresAt, true) + http.Redirect(w, r, "/home", http.StatusFound) + return nil + } +} diff --git a/backend/app/api/handlers/v1/v1_ctrl_item_templates.go b/backend/app/api/handlers/v1/v1_ctrl_item_templates.go new file mode 100644 index 00000000..deb4c261 --- /dev/null +++ b/backend/app/api/handlers/v1/v1_ctrl_item_templates.go @@ -0,0 +1,164 @@ +package v1 + +import ( + "net/http" + + "github.com/google/uuid" + "github.com/hay-kot/httpkit/errchain" + "github.com/sysadminsmedia/homebox/backend/internal/core/services" + "github.com/sysadminsmedia/homebox/backend/internal/data/repo" + "github.com/sysadminsmedia/homebox/backend/internal/web/adapters" +) + +// HandleItemTemplatesGetAll godoc +// +// @Summary Get All Item Templates +// @Tags Item Templates +// @Produce json +// @Success 200 {object} []repo.ItemTemplateSummary +// @Router /v1/templates [GET] +// @Security Bearer +func (ctrl *V1Controller) HandleItemTemplatesGetAll() errchain.HandlerFunc { + fn := func(r *http.Request) ([]repo.ItemTemplateSummary, error) { + auth := services.NewContext(r.Context()) + return ctrl.repo.ItemTemplates.GetAll(r.Context(), auth.GID) + } + + return adapters.Command(fn, http.StatusOK) +} + +// HandleItemTemplatesGet godoc +// +// @Summary Get Item Template +// @Tags Item Templates +// @Produce json +// @Param id path string true "Template ID" +// @Success 200 {object} repo.ItemTemplateOut +// @Router /v1/templates/{id} [GET] +// @Security Bearer +func (ctrl *V1Controller) HandleItemTemplatesGet() errchain.HandlerFunc { + fn := func(r *http.Request, ID uuid.UUID) (repo.ItemTemplateOut, error) { + auth := services.NewContext(r.Context()) + return ctrl.repo.ItemTemplates.GetOne(r.Context(), auth.GID, ID) + } + + return adapters.CommandID("id", fn, http.StatusOK) +} + +// HandleItemTemplatesCreate godoc +// +// @Summary Create Item Template +// @Tags Item Templates +// @Produce json +// @Param payload body repo.ItemTemplateCreate true "Template Data" +// @Success 201 {object} repo.ItemTemplateOut +// @Router /v1/templates [POST] +// @Security Bearer +func (ctrl *V1Controller) HandleItemTemplatesCreate() errchain.HandlerFunc { + fn := func(r *http.Request, body repo.ItemTemplateCreate) (repo.ItemTemplateOut, error) { + auth := services.NewContext(r.Context()) + return ctrl.repo.ItemTemplates.Create(r.Context(), auth.GID, body) + } + + return adapters.Action(fn, http.StatusCreated) +} + +// HandleItemTemplatesUpdate godoc +// +// @Summary Update Item Template +// @Tags Item Templates +// @Produce json +// @Param id path string true "Template ID" +// @Param payload body repo.ItemTemplateUpdate true "Template Data" +// @Success 200 {object} repo.ItemTemplateOut +// @Router /v1/templates/{id} [PUT] +// @Security Bearer +func (ctrl *V1Controller) HandleItemTemplatesUpdate() errchain.HandlerFunc { + fn := func(r *http.Request, ID uuid.UUID, body repo.ItemTemplateUpdate) (repo.ItemTemplateOut, error) { + auth := services.NewContext(r.Context()) + body.ID = ID + return ctrl.repo.ItemTemplates.Update(r.Context(), auth.GID, body) + } + + return adapters.ActionID("id", fn, http.StatusOK) +} + +// HandleItemTemplatesDelete godoc +// +// @Summary Delete Item Template +// @Tags Item Templates +// @Produce json +// @Param id path string true "Template ID" +// @Success 204 +// @Router /v1/templates/{id} [DELETE] +// @Security Bearer +func (ctrl *V1Controller) HandleItemTemplatesDelete() errchain.HandlerFunc { + fn := func(r *http.Request, ID uuid.UUID) (any, error) { + auth := services.NewContext(r.Context()) + err := ctrl.repo.ItemTemplates.Delete(r.Context(), auth.GID, ID) + return nil, err + } + + return adapters.CommandID("id", fn, http.StatusNoContent) +} + +type ItemTemplateCreateItemRequest struct { + Name string `json:"name" validate:"required,min=1,max=255"` + Description string `json:"description" validate:"max=1000"` + LocationID uuid.UUID `json:"locationId" validate:"required"` + LabelIDs []uuid.UUID `json:"labelIds"` + Quantity *int `json:"quantity"` +} + +// HandleItemTemplatesCreateItem godoc +// +// @Summary Create Item from Template +// @Tags Item Templates +// @Produce json +// @Param id path string true "Template ID" +// @Param payload body ItemTemplateCreateItemRequest true "Item Data" +// @Success 201 {object} repo.ItemOut +// @Router /v1/templates/{id}/create-item [POST] +// @Security Bearer +func (ctrl *V1Controller) HandleItemTemplatesCreateItem() errchain.HandlerFunc { + fn := func(r *http.Request, templateID uuid.UUID, body ItemTemplateCreateItemRequest) (repo.ItemOut, error) { + auth := services.NewContext(r.Context()) + + template, err := ctrl.repo.ItemTemplates.GetOne(r.Context(), auth.GID, templateID) + if err != nil { + return repo.ItemOut{}, err + } + + quantity := template.DefaultQuantity + if body.Quantity != nil { + quantity = *body.Quantity + } + + // Build custom fields from template + fields := make([]repo.ItemField, len(template.Fields)) + for i, f := range template.Fields { + fields[i] = repo.ItemField{ + Type: f.Type, + Name: f.Name, + TextValue: f.TextValue, + } + } + + // Create item with all template data in a single transaction + return ctrl.repo.Items.CreateFromTemplate(r.Context(), auth.GID, repo.ItemCreateFromTemplate{ + Name: body.Name, + Description: body.Description, + Quantity: quantity, + LocationID: body.LocationID, + LabelIDs: body.LabelIDs, + Insured: template.DefaultInsured, + Manufacturer: template.DefaultManufacturer, + ModelNumber: template.DefaultModelNumber, + LifetimeWarranty: template.DefaultLifetimeWarranty, + WarrantyDetails: template.DefaultWarrantyDetails, + Fields: fields, + }) + } + + return adapters.ActionID("id", fn, http.StatusCreated) +} diff --git a/backend/app/api/handlers/v1/v1_ctrl_user.go b/backend/app/api/handlers/v1/v1_ctrl_user.go index a99c7b86..f1dbefa2 100644 --- a/backend/app/api/handlers/v1/v1_ctrl_user.go +++ b/backend/app/api/handlers/v1/v1_ctrl_user.go @@ -20,9 +20,15 @@ import ( // @Produce json // @Param payload body services.UserRegistration true "User Data" // @Success 204 +// @Failure 403 {string} string "Local login is not enabled" // @Router /v1/users/register [Post] func (ctrl *V1Controller) HandleUserRegistration() errchain.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) error { + // Forbidden if local login is not enabled + if !ctrl.config.Options.AllowLocalLogin { + return validate.NewRequestError(fmt.Errorf("local login is not enabled"), http.StatusForbidden) + } + regData := services.UserRegistration{} if err := server.Decode(r, ®Data); err != nil { diff --git a/backend/app/api/providers/oidc.go b/backend/app/api/providers/oidc.go new file mode 100644 index 00000000..7120baea --- /dev/null +++ b/backend/app/api/providers/oidc.go @@ -0,0 +1,626 @@ +package providers + +import ( + "context" + "crypto/rand" + "crypto/sha256" + "encoding/base64" + "fmt" + "net/http" + "net/url" + "strconv" + "strings" + "time" + + "github.com/coreos/go-oidc/v3/oidc" + "github.com/rs/zerolog/log" + "github.com/sysadminsmedia/homebox/backend/internal/core/services" + "github.com/sysadminsmedia/homebox/backend/internal/sys/config" + "golang.org/x/oauth2" +) + +type OIDCProvider struct { + service *services.UserService + config *config.OIDCConf + options *config.Options + cookieSecure bool + provider *oidc.Provider + verifier *oidc.IDTokenVerifier + endpoint oauth2.Endpoint +} + +type OIDCClaims struct { + Email string + Groups []string + Name string + Subject string + Issuer string + EmailVerified *bool +} + +func NewOIDCProvider(service *services.UserService, config *config.OIDCConf, options *config.Options, cookieSecure bool) (*OIDCProvider, error) { + if !config.Enabled { + return nil, fmt.Errorf("OIDC is not enabled") + } + + // Validate required configuration + if config.ClientID == "" { + return nil, fmt.Errorf("OIDC client ID is required when OIDC is enabled (set HBOX_OIDC_CLIENT_ID)") + } + if config.ClientSecret == "" { + return nil, fmt.Errorf("OIDC client secret is required when OIDC is enabled (set HBOX_OIDC_CLIENT_SECRET)") + } + if config.IssuerURL == "" { + return nil, fmt.Errorf("OIDC issuer URL is required when OIDC is enabled (set HBOX_OIDC_ISSUER_URL)") + } + + ctx, cancel := context.WithTimeout(context.Background(), config.RequestTimeout) + defer cancel() + + provider, err := oidc.NewProvider(ctx, config.IssuerURL) + if err != nil { + return nil, fmt.Errorf("failed to create OIDC provider from issuer URL: %w", err) + } + + // Create ID token verifier + verifier := provider.Verifier(&oidc.Config{ + ClientID: config.ClientID, + }) + + log.Info(). + Str("issuer", config.IssuerURL). + Str("client_id", config.ClientID). + Str("scope", config.Scope). + Msg("OIDC provider initialized successfully with discovery") + + return &OIDCProvider{ + service: service, + config: config, + options: options, + cookieSecure: cookieSecure, + provider: provider, + verifier: verifier, + endpoint: provider.Endpoint(), + }, nil +} + +func (p *OIDCProvider) Name() string { + return "oidc" +} + +// Authenticate implements the AuthProvider interface but is not used for OIDC +// OIDC uses dedicated endpoints: GET /api/v1/users/login/oidc and GET /api/v1/users/login/oidc/callback +func (p *OIDCProvider) Authenticate(w http.ResponseWriter, r *http.Request) (services.UserAuthTokenDetail, error) { + _ = w + _ = r + return services.UserAuthTokenDetail{}, fmt.Errorf("OIDC authentication uses dedicated endpoints: /api/v1/users/login/oidc") +} + +// AuthenticateWithBaseURL is the main authentication method that requires baseURL +// Called from handleCallback after state, nonce, and PKCE verification +func (p *OIDCProvider) AuthenticateWithBaseURL(baseURL, expectedNonce, pkceVerifier string, _ http.ResponseWriter, r *http.Request) (services.UserAuthTokenDetail, error) { + code := r.URL.Query().Get("code") + if code == "" { + return services.UserAuthTokenDetail{}, fmt.Errorf("missing authorization code") + } + + // Get OAuth2 config for this request + oauth2Config := p.getOAuth2Config(baseURL) + + // Exchange code for token with timeout and PKCE verifier + ctx, cancel := context.WithTimeout(r.Context(), p.config.RequestTimeout) + defer cancel() + + token, err := oauth2Config.Exchange(ctx, code, oauth2.SetAuthURLParam("code_verifier", pkceVerifier)) + if err != nil { + log.Err(err).Msg("failed to exchange OIDC code for token") + return services.UserAuthTokenDetail{}, fmt.Errorf("failed to exchange code for token") + } + + // Extract ID token + idToken, ok := token.Extra("id_token").(string) + if !ok { + return services.UserAuthTokenDetail{}, fmt.Errorf("no id_token in response") + } + + // Parse and validate the ID token using the library's verifier with timeout + verifyCtx, verifyCancel := context.WithTimeout(r.Context(), p.config.RequestTimeout) + defer verifyCancel() + + idTokenStruct, err := p.verifier.Verify(verifyCtx, idToken) + if err != nil { + log.Err(err).Msg("failed to verify ID token") + return services.UserAuthTokenDetail{}, fmt.Errorf("failed to verify ID token") + } + + // Extract claims from the verified token using dynamic parsing + var rawClaims map[string]interface{} + if err := idTokenStruct.Claims(&rawClaims); err != nil { + log.Err(err).Msg("failed to extract claims from ID token") + return services.UserAuthTokenDetail{}, fmt.Errorf("failed to extract claims from ID token") + } + + // Attempt to retrieve UserInfo claims; use them as primary, fallback to ID token claims. + finalClaims := rawClaims + userInfoCtx, uiCancel := context.WithTimeout(r.Context(), p.config.RequestTimeout) + defer uiCancel() + + userInfo, uiErr := p.provider.UserInfo(userInfoCtx, oauth2.StaticTokenSource(token)) + if uiErr != nil { + log.Debug().Err(uiErr).Msg("OIDC UserInfo fetch failed; falling back to ID token claims") + } else { + var uiClaims map[string]interface{} + if err := userInfo.Claims(&uiClaims); err != nil { + log.Debug().Err(err).Msg("failed to decode UserInfo claims; falling back to ID token claims") + } else { + finalClaims = mergeOIDCClaims(uiClaims, rawClaims) // UserInfo first, then fill gaps from ID token + log.Debug().Int("userinfo_claims", len(uiClaims)).Int("id_token_claims", len(rawClaims)).Int("merged_claims", len(finalClaims)).Msg("merged UserInfo and ID token claims") + } + } + + // Parse claims using configurable claim names (after merge) + claims, err := p.parseOIDCClaims(finalClaims) + if err != nil { + log.Err(err).Msg("failed to parse OIDC claims") + return services.UserAuthTokenDetail{}, fmt.Errorf("failed to parse OIDC claims: %w", err) + } + + // Verify nonce claim matches expected value (nonce only from ID token; ensure preserved in merged map) + tokenNonce, exists := finalClaims["nonce"] + if !exists { + log.Warn().Msg("nonce claim missing from ID token - possible replay attack") + return services.UserAuthTokenDetail{}, fmt.Errorf("nonce claim missing from token") + } + + tokenNonceStr, ok := tokenNonce.(string) + if !ok { + log.Warn().Msg("nonce claim is not a string in ID token") + return services.UserAuthTokenDetail{}, fmt.Errorf("invalid nonce claim format") + } + + if tokenNonceStr != expectedNonce { + log.Warn().Str("received", tokenNonceStr).Str("expected", expectedNonce).Msg("OIDC nonce mismatch - possible replay attack") + return services.UserAuthTokenDetail{}, fmt.Errorf("nonce parameter mismatch") + } + + // Check if email is verified + if p.config.VerifyEmail { + if claims.EmailVerified == nil { + return services.UserAuthTokenDetail{}, fmt.Errorf("email verification status not found in token claims") + } + + if !*claims.EmailVerified { + return services.UserAuthTokenDetail{}, fmt.Errorf("email not verified") + } + } + + // Check group authorization if configured + if p.config.AllowedGroups != "" { + allowedGroups := strings.Split(p.config.AllowedGroups, ",") + if !p.hasAllowedGroup(claims.Groups, allowedGroups) { + log.Warn(). + Strs("user_groups", claims.Groups). + Strs("allowed_groups", allowedGroups). + Str("user", claims.Email). + Msg("user not in allowed groups") + return services.UserAuthTokenDetail{}, fmt.Errorf("user not in allowed groups") + } + } + + // Determine username from claims + email := claims.Email + if email == "" { + return services.UserAuthTokenDetail{}, fmt.Errorf("no email found in token claims") + } + if claims.Subject == "" { + return services.UserAuthTokenDetail{}, fmt.Errorf("no subject (sub) claim present") + } + if claims.Issuer == "" { + claims.Issuer = p.config.IssuerURL // fallback to configured issuer, though spec requires 'iss' + } + + // Use the dedicated OIDC login method (issuer + subject identity) + sessionToken, err := p.service.LoginOIDC(r.Context(), claims.Issuer, claims.Subject, email, claims.Name) + if err != nil { + log.Err(err).Str("email", email).Str("issuer", claims.Issuer).Str("subject", claims.Subject).Msg("OIDC login failed") + return services.UserAuthTokenDetail{}, fmt.Errorf("OIDC login failed: %w", err) + } + + return sessionToken, nil +} + +func (p *OIDCProvider) parseOIDCClaims(rawClaims map[string]interface{}) (OIDCClaims, error) { + var claims OIDCClaims + + // Parse email claim + key := p.config.EmailClaim + if key == "" { + key = "email" + } + if emailValue, exists := rawClaims[key]; exists { + if email, ok := emailValue.(string); ok { + claims.Email = email + } + } + + // Parse email_verified claim + if p.config.VerifyEmail { + key = p.config.EmailVerifiedClaim + if key == "" { + key = "email_verified" + } + if emailVerifiedValue, exists := rawClaims[key]; exists { + switch v := emailVerifiedValue.(type) { + case bool: + claims.EmailVerified = &v + case string: + if b, err := strconv.ParseBool(v); err == nil { + claims.EmailVerified = &b + } + } + } + } + + // Parse name claim + key = p.config.NameClaim + if key == "" { + key = "name" + } + if nameValue, exists := rawClaims[key]; exists { + if name, ok := nameValue.(string); ok { + claims.Name = name + } + } + + // Parse groups claim + key = p.config.GroupClaim + if key == "" { + key = "groups" + } + if groupsValue, exists := rawClaims[key]; exists { + switch groups := groupsValue.(type) { + case []interface{}: + for _, group := range groups { + if groupStr, ok := group.(string); ok { + claims.Groups = append(claims.Groups, groupStr) + } + } + case []string: + claims.Groups = groups + case string: + // Single group as string + claims.Groups = []string{groups} + } + } + + // Parse subject claim (always "sub") + if subValue, exists := rawClaims["sub"]; exists { + if subject, ok := subValue.(string); ok { + claims.Subject = subject + } + } + // Parse issuer claim ("iss") + if issValue, exists := rawClaims["iss"]; exists { + if iss, ok := issValue.(string); ok { + claims.Issuer = iss + } + } + + return claims, nil +} + +func (p *OIDCProvider) hasAllowedGroup(userGroups, allowedGroups []string) bool { + if len(allowedGroups) == 0 { + return true + } + + allowedGroupsMap := make(map[string]bool) + for _, group := range allowedGroups { + allowedGroupsMap[strings.TrimSpace(group)] = true + } + + for _, userGroup := range userGroups { + if allowedGroupsMap[userGroup] { + return true + } + } + + return false +} + +func (p *OIDCProvider) GetAuthURL(baseURL, state, nonce, pkceVerifier string) string { + oauth2Config := p.getOAuth2Config(baseURL) + pkceChallenge := generatePKCEChallenge(pkceVerifier) + return oauth2Config.AuthCodeURL(state, + oidc.Nonce(nonce), + oauth2.SetAuthURLParam("code_challenge", pkceChallenge), + oauth2.SetAuthURLParam("code_challenge_method", "S256")) +} + +func (p *OIDCProvider) getOAuth2Config(baseURL string) oauth2.Config { + // Construct full redirect URL with dedicated callback endpoint + redirectURL, err := url.JoinPath(baseURL, "/api/v1/users/login/oidc/callback") + if err != nil { + log.Err(err).Msg("failed to construct redirect URL") + return oauth2.Config{} + } + + return oauth2.Config{ + ClientID: p.config.ClientID, + ClientSecret: p.config.ClientSecret, + RedirectURL: redirectURL, + Endpoint: p.endpoint, + Scopes: strings.Fields(p.config.Scope), + } +} + +// initiateOIDCFlow handles the initial OIDC authentication request by redirecting to the provider +func (p *OIDCProvider) initiateOIDCFlow(w http.ResponseWriter, r *http.Request) (services.UserAuthTokenDetail, error) { + // Generate state parameter for CSRF protection + state, err := generateSecureToken() + if err != nil { + log.Err(err).Msg("failed to generate OIDC state parameter") + return services.UserAuthTokenDetail{}, fmt.Errorf("internal server error") + } + + // Generate nonce parameter for replay attack protection + nonce, err := generateSecureToken() + if err != nil { + log.Err(err).Msg("failed to generate OIDC nonce parameter") + return services.UserAuthTokenDetail{}, fmt.Errorf("internal server error") + } + + // Generate PKCE verifier for code interception protection + pkceVerifier, err := generatePKCEVerifier() + if err != nil { + log.Err(err).Msg("failed to generate OIDC PKCE verifier") + return services.UserAuthTokenDetail{}, fmt.Errorf("internal server error") + } + + // Get base URL from request + baseURL := p.getBaseURL(r) + u, _ := url.Parse(baseURL) + domain := u.Hostname() + if domain == "" { + domain = noPort(r.Host) + } + + // Store state in session cookie for validation + http.SetCookie(w, &http.Cookie{ + Name: "oidc_state", + Value: state, + Expires: time.Now().Add(p.config.StateExpiry), + Domain: domain, + Secure: p.isSecure(r), + HttpOnly: true, + Path: "/", + SameSite: http.SameSiteLaxMode, + }) + + // Store nonce in session cookie for validation + http.SetCookie(w, &http.Cookie{ + Name: "oidc_nonce", + Value: nonce, + Expires: time.Now().Add(p.config.StateExpiry), + Domain: domain, + Secure: p.isSecure(r), + HttpOnly: true, + Path: "/", + SameSite: http.SameSiteLaxMode, + }) + + // Store PKCE verifier in session cookie for token exchange + http.SetCookie(w, &http.Cookie{ + Name: "oidc_pkce_verifier", + Value: pkceVerifier, + Expires: time.Now().Add(p.config.StateExpiry), + Domain: domain, + Secure: p.isSecure(r), + HttpOnly: true, + Path: "/", + SameSite: http.SameSiteLaxMode, + }) + + // Generate auth URL and redirect + authURL := p.GetAuthURL(baseURL, state, nonce, pkceVerifier) + http.Redirect(w, r, authURL, http.StatusFound) + + // Return empty token since this is a redirect response + return services.UserAuthTokenDetail{}, nil +} + +// handleCallback processes the OAuth2 callback from the OIDC provider +func (p *OIDCProvider) handleCallback(w http.ResponseWriter, r *http.Request) (services.UserAuthTokenDetail, error) { + // Helper to clear state cookie using computed domain + baseURL := p.getBaseURL(r) + u, _ := url.Parse(baseURL) + domain := u.Hostname() + if domain == "" { + domain = noPort(r.Host) + } + clearCookies := func() { + http.SetCookie(w, &http.Cookie{ + Name: "oidc_state", + Value: "", + Expires: time.Unix(0, 0), + Domain: domain, + MaxAge: -1, + Secure: p.isSecure(r), + HttpOnly: true, + Path: "/", + SameSite: http.SameSiteLaxMode, + }) + http.SetCookie(w, &http.Cookie{ + Name: "oidc_nonce", + Value: "", + Expires: time.Unix(0, 0), + Domain: domain, + MaxAge: -1, + Secure: p.isSecure(r), + HttpOnly: true, + Path: "/", + SameSite: http.SameSiteLaxMode, + }) + http.SetCookie(w, &http.Cookie{ + Name: "oidc_pkce_verifier", + Value: "", + Expires: time.Unix(0, 0), + Domain: domain, + MaxAge: -1, + Secure: p.isSecure(r), + HttpOnly: true, + Path: "/", + SameSite: http.SameSiteLaxMode, + }) + } + + // Check for OAuth error responses first + if errCode := r.URL.Query().Get("error"); errCode != "" { + errDesc := r.URL.Query().Get("error_description") + log.Warn().Str("error", errCode).Str("description", errDesc).Msg("OIDC provider returned error") + clearCookies() + return services.UserAuthTokenDetail{}, fmt.Errorf("OIDC provider error: %s - %s", errCode, errDesc) + } + + // Verify state parameter + stateCookie, err := r.Cookie("oidc_state") + if err != nil { + log.Warn().Err(err).Msg("OIDC state cookie not found - possible CSRF attack or expired session") + clearCookies() + return services.UserAuthTokenDetail{}, fmt.Errorf("state cookie not found") + } + + stateParam := r.URL.Query().Get("state") + if stateParam == "" { + log.Warn().Msg("OIDC state parameter missing from callback") + clearCookies() + return services.UserAuthTokenDetail{}, fmt.Errorf("state parameter missing") + } + + if stateParam != stateCookie.Value { + log.Warn().Str("received", stateParam).Str("expected", stateCookie.Value).Msg("OIDC state mismatch - possible CSRF attack") + clearCookies() + return services.UserAuthTokenDetail{}, fmt.Errorf("state parameter mismatch") + } + + // Verify nonce parameter + nonceCookie, err := r.Cookie("oidc_nonce") + if err != nil { + log.Warn().Err(err).Msg("OIDC nonce cookie not found - possible replay attack or expired session") + clearCookies() + return services.UserAuthTokenDetail{}, fmt.Errorf("nonce cookie not found") + } + + // Verify PKCE verifier parameter + pkceCookie, err := r.Cookie("oidc_pkce_verifier") + if err != nil { + log.Warn().Err(err).Msg("OIDC PKCE verifier cookie not found - possible code interception attack or expired session") + clearCookies() + return services.UserAuthTokenDetail{}, fmt.Errorf("PKCE verifier cookie not found") + } + + // Clear cookies before proceeding to token verification + clearCookies() + + // Use the existing callback logic but return the token instead of redirecting + return p.AuthenticateWithBaseURL(baseURL, nonceCookie.Value, pkceCookie.Value, w, r) +} + +// Helper functions +func generateSecureToken() (string, error) { + // Generate 32 bytes of cryptographically secure random data + bytes := make([]byte, 32) + _, err := rand.Read(bytes) + if err != nil { + return "", fmt.Errorf("failed to generate secure random token: %w", err) + } + // Use URL-safe base64 encoding without padding for clean URLs + return base64.RawURLEncoding.EncodeToString(bytes), nil +} + +// generatePKCEVerifier generates a cryptographically secure code verifier for PKCE +func generatePKCEVerifier() (string, error) { + // PKCE verifier must be 43-128 characters, we'll use 43 for efficiency + // 32 bytes = 43 characters when base64url encoded without padding + bytes := make([]byte, 32) + _, err := rand.Read(bytes) + if err != nil { + return "", fmt.Errorf("failed to generate PKCE verifier: %w", err) + } + return base64.RawURLEncoding.EncodeToString(bytes), nil +} + +// generatePKCEChallenge generates a code challenge from a verifier using S256 method +func generatePKCEChallenge(verifier string) string { + hash := sha256.Sum256([]byte(verifier)) + return base64.RawURLEncoding.EncodeToString(hash[:]) +} + +func noPort(host string) string { + return strings.Split(host, ":")[0] +} + +func (p *OIDCProvider) getBaseURL(r *http.Request) string { + scheme := "http" + if r.TLS != nil { + scheme = "https" + } else if p.options.TrustProxy && r.Header.Get("X-Forwarded-Proto") == "https" { + scheme = "https" + } + + host := r.Host + if p.options.Hostname != "" { + host = p.options.Hostname + } else if p.options.TrustProxy { + if xfHost := r.Header.Get("X-Forwarded-Host"); xfHost != "" { + host = xfHost + } + } + + return scheme + "://" + host +} + +func (p *OIDCProvider) isSecure(r *http.Request) bool { + _ = r + return p.cookieSecure +} + +// InitiateOIDCFlow starts the OIDC authentication flow by redirecting to the provider +func (p *OIDCProvider) InitiateOIDCFlow(w http.ResponseWriter, r *http.Request) (services.UserAuthTokenDetail, error) { + return p.initiateOIDCFlow(w, r) +} + +// HandleCallback processes the OIDC callback and returns the authenticated user token +func (p *OIDCProvider) HandleCallback(w http.ResponseWriter, r *http.Request) (services.UserAuthTokenDetail, error) { + return p.handleCallback(w, r) +} + +func mergeOIDCClaims(primary, secondary map[string]interface{}) map[string]interface{} { + // primary has precedence; fill missing/empty values from secondary. + merged := make(map[string]interface{}, len(primary)+len(secondary)) + for k, v := range primary { + merged[k] = v + } + for k, v := range secondary { + if existing, ok := merged[k]; !ok || isEmptyClaim(existing) { + merged[k] = v + } + } + return merged +} + +func isEmptyClaim(v interface{}) bool { + if v == nil { + return true + } + switch val := v.(type) { + case string: + return val == "" + case []interface{}: + return len(val) == 0 + case []string: + return len(val) == 0 + default: + return false + } +} diff --git a/backend/app/api/routes.go b/backend/app/api/routes.go index 85a24dd6..19282143 100644 --- a/backend/app/api/routes.go +++ b/backend/app/api/routes.go @@ -75,6 +75,11 @@ func (a *app) mountRoutes(r *chi.Mux, chain *errchain.ErrChain, repos *repo.AllR r.Post("/users/register", chain.ToHandlerFunc(v1Ctrl.HandleUserRegistration())) r.Post("/users/login", chain.ToHandlerFunc(v1Ctrl.HandleAuthLogin(providers...))) + if a.conf.OIDC.Enabled { + r.Get("/users/login/oidc", chain.ToHandlerFunc(v1Ctrl.HandleOIDCLogin())) + r.Get("/users/login/oidc/callback", chain.ToHandlerFunc(v1Ctrl.HandleOIDCCallback())) + } + userMW := []errchain.Middleware{ a.mwAuthToken, a.mwRoles(RoleModeOr, authroles.RoleUser.String()), @@ -159,6 +164,14 @@ func (a *app) mountRoutes(r *chi.Mux, chain *errchain.ErrChain, repos *repo.AllR r.Get("/assets/{id}", chain.ToHandlerFunc(v1Ctrl.HandleAssetGet(), userMW...)) + // Item Templates + r.Get("/templates", chain.ToHandlerFunc(v1Ctrl.HandleItemTemplatesGetAll(), userMW...)) + r.Post("/templates", chain.ToHandlerFunc(v1Ctrl.HandleItemTemplatesCreate(), userMW...)) + r.Get("/templates/{id}", chain.ToHandlerFunc(v1Ctrl.HandleItemTemplatesGet(), userMW...)) + r.Put("/templates/{id}", chain.ToHandlerFunc(v1Ctrl.HandleItemTemplatesUpdate(), userMW...)) + r.Delete("/templates/{id}", chain.ToHandlerFunc(v1Ctrl.HandleItemTemplatesDelete(), userMW...)) + r.Post("/templates/{id}/create-item", chain.ToHandlerFunc(v1Ctrl.HandleItemTemplatesCreateItem(), userMW...)) + // Maintenance r.Get("/maintenance", chain.ToHandlerFunc(v1Ctrl.HandleMaintenanceGetAll(), userMW...)) r.Put("/maintenance/{id}", chain.ToHandlerFunc(v1Ctrl.HandleMaintenanceEntryUpdate(), userMW...)) diff --git a/backend/app/api/static/docs/docs.go b/backend/app/api/static/docs/docs.go index 4467084c..1af68fee 100644 --- a/backend/app/api/static/docs/docs.go +++ b/backend/app/api/static/docs/docs.go @@ -1,11 +1,5216 @@ -// Code generated by swaggo/swag. DO NOT EDIT. - +// Package docs Code generated by swaggo/swag. DO NOT EDIT package docs -import "github.com/swaggo/swag/v2" +import "github.com/swaggo/swag" const docTemplate = `{ - "schemes": {{ marshal .Schemes }},"swagger":"2.0","info":{"description":"{{escape .Description}}","title":"{{.Title}}","contact":{"name":"Homebox Team","url":"https://discord.homebox.software"},"version":"{{.Version}}"},"host":"{{.Host}}","basePath":"{{.BasePath}}","paths":{"/v1/actions/create-missing-thumbnails":{"post":{"security":[{"Bearer":[]}],"description":"Creates thumbnails for items that are missing them","produces":["application/json"],"tags":["Actions"],"summary":"Create Missing Thumbnails","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.ActionAmountResult"}}}}},"/v1/actions/ensure-asset-ids":{"post":{"security":[{"Bearer":[]}],"description":"Ensures all items in the database have an asset ID","produces":["application/json"],"tags":["Actions"],"summary":"Ensure Asset IDs","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.ActionAmountResult"}}}}},"/v1/actions/ensure-import-refs":{"post":{"security":[{"Bearer":[]}],"description":"Ensures all items in the database have an import ref","produces":["application/json"],"tags":["Actions"],"summary":"Ensures Import Refs","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.ActionAmountResult"}}}}},"/v1/actions/set-primary-photos":{"post":{"security":[{"Bearer":[]}],"description":"Sets the first photo of each item as the primary photo","produces":["application/json"],"tags":["Actions"],"summary":"Set Primary Photos","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.ActionAmountResult"}}}}},"/v1/actions/zero-item-time-fields":{"post":{"security":[{"Bearer":[]}],"description":"Resets all item date fields to the beginning of the day","produces":["application/json"],"tags":["Actions"],"summary":"Zero Out Time Fields","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.ActionAmountResult"}}}}},"/v1/assets/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"Get Item by Asset ID","parameters":[{"type":"string","description":"Asset ID","name":"id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.PaginationResult-repo_ItemSummary"}}}}},"/v1/currency":{"get":{"produces":["application/json"],"tags":["Base"],"summary":"Currency","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/currencies.Currency"}}}}},"/v1/entities/{id}/attachments":{"post":{"security":[{"Bearer":[]}],"consumes":["multipart/form-data"],"produces":["application/json"],"tags":["Items Attachments"],"summary":"Create Item Attachment","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"file","description":"File attachment","name":"file","in":"formData","required":true},{"type":"string","description":"Type of file","name":"type","in":"formData"},{"type":"boolean","description":"Is this the primary attachment","name":"primary","in":"formData"},{"type":"string","description":"name of the file including extension","name":"name","in":"formData","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ItemOut"}},"422":{"description":"Unprocessable Entity","schema":{"$ref":"#/definitions/validate.ErrorResponse"}}}}},"/v1/entities/{id}/attachments/{attachment_id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/octet-stream"],"tags":["Items Attachments"],"summary":"Get Item Attachment","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"string","description":"Attachment ID","name":"attachment_id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.ItemAttachmentToken"}}}},"put":{"security":[{"Bearer":[]}],"tags":["Items Attachments"],"summary":"Update Item Attachment","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"string","description":"Attachment ID","name":"attachment_id","in":"path","required":true},{"description":"Attachment Update","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.EntityAttachmentUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ItemOut"}}}},"delete":{"security":[{"Bearer":[]}],"tags":["Items Attachments"],"summary":"Delete Item Attachment","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"string","description":"Attachment ID","name":"attachment_id","in":"path","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/entities/{id}/maintenance":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Item Maintenance"],"summary":"Get Maintenance Log","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"enum":["scheduled","completed","both"],"type":"string","x-enum-varnames":["MaintenanceFilterStatusScheduled","MaintenanceFilterStatusCompleted","MaintenanceFilterStatusBoth"],"name":"status","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.MaintenanceEntryWithDetails"}}}}},"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Item Maintenance"],"summary":"Create Maintenance Entry","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"description":"Entry Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.MaintenanceEntryCreate"}}],"responses":{"201":{"description":"Created","schema":{"$ref":"#/definitions/repo.MaintenanceEntry"}}}}},"/v1/entitytype":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["EntityTypes"],"summary":"Query All Entity Types","responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.EntityType"}}}}},"post":{"security":[{"Bearer":[]}],"consumes":["application/json"],"produces":["application/json"],"tags":["EntityTypes"],"summary":"Create Entity Type","parameters":[{"description":"Entity Type Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.EntityTypeCreate"}}],"responses":{"201":{"description":"Created","schema":{"$ref":"#/definitions/repo.EntityType"}}}}},"/v1/entitytype/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["EntityTypes"],"summary":"Get One Entity Type","parameters":[{"type":"string","description":"Entity Type ID","name":"id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.EntityType"}}}},"put":{"security":[{"Bearer":[]}],"consumes":["application/json"],"produces":["application/json"],"tags":["EntityTypes"],"summary":"Update Entity Type","parameters":[{"type":"string","description":"Entity Type ID","name":"id","in":"path","required":true},{"description":"Entity Type Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.EntityTypeUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.EntityType"}}}},"delete":{"security":[{"Bearer":[]}],"tags":["EntityTypes"],"summary":"Delete Entity Type","parameters":[{"type":"string","description":"Entity Type ID","name":"id","in":"path","required":true},{"description":"Entity Type Delete Options","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.EntityTypeDelete"}}],"responses":{"204":{"description":"No Content"}}}},"/v1/groups":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Group"],"summary":"Get Group","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.Group"}}}},"put":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Group"],"summary":"Update Group","parameters":[{"description":"User Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.GroupUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.Group"}}}}},"/v1/groups/invitations":{"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Group"],"summary":"Create Group Invitation","parameters":[{"description":"User Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/v1.GroupInvitationCreate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.GroupInvitation"}}}}},"/v1/groups/statistics":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Statistics"],"summary":"Get Group Statistics","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.GroupStatistics"}}}}},"/v1/groups/statistics/labels":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Statistics"],"summary":"Get Label Statistics","responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.TotalsByOrganizer"}}}}}},"/v1/groups/statistics/locations":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Statistics"],"summary":"Get Location Statistics","responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.TotalsByOrganizer"}}}}}},"/v1/groups/statistics/purchase-price":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Statistics"],"summary":"Get Purchase Price Statistics","parameters":[{"type":"string","description":"start date","name":"start","in":"query"},{"type":"string","description":"end date","name":"end","in":"query"}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ValueOverTime"}}}}},"/v1/items":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Query All Items","deprecated":true,"parameters":[{"type":"string","description":"search string","name":"q","in":"query"},{"type":"integer","description":"page number","name":"page","in":"query"},{"type":"integer","description":"items per page","name":"pageSize","in":"query"},{"type":"array","items":{"type":"string"},"collectionFormat":"multi","description":"label Ids","name":"labels","in":"query"},{"type":"array","items":{"type":"string"},"collectionFormat":"multi","description":"location Ids","name":"locations","in":"query"},{"type":"array","items":{"type":"string"},"collectionFormat":"multi","description":"parent Ids","name":"parentIds","in":"query"}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.PaginationResult-repo_ItemSummary"}}}},"post":{"security":[{"Bearer":[]}],"consumes":["application/json"],"produces":["application/json"],"tags":["Items"],"summary":"Create Item","deprecated":true,"parameters":[{"description":"Item Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.ItemCreate"}}],"responses":{"201":{"description":"Created","schema":{"$ref":"#/definitions/repo.ItemSummary"}}}}},"/v1/items/export":{"get":{"security":[{"Bearer":[]}],"tags":["Items"],"summary":"(Deprecated) Export Items","deprecated":true,"responses":{"200":{"description":"text/csv","schema":{"type":"string"}}}}},"/v1/items/fields":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Get All Custom Field Names","deprecated":true,"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"string"}}}}}},"/v1/items/fields/values":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Get All Custom Field Values","deprecated":true,"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"string"}}}}}},"/v1/items/import":{"post":{"security":[{"Bearer":[]}],"consumes":["multipart/form-data"],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Import Items","deprecated":true,"parameters":[{"type":"file","description":"Image to upload","name":"csv","in":"formData","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/items/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Get Item","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ItemOut"}}}},"put":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Update Item","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"description":"Item Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.ItemUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ItemOut"}}}},"delete":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Delete Item","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true}],"responses":{"204":{"description":"No Content"}}},"patch":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Update Item","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"description":"Item Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.ItemPatch"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ItemOut"}}}}},"/v1/items/{id}/attachments":{"post":{"security":[{"Bearer":[]}],"consumes":["multipart/form-data"],"produces":["application/json"],"tags":["Items Attachments"],"summary":"Create Item Attachment","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"file","description":"File attachment","name":"file","in":"formData","required":true},{"type":"string","description":"Type of file","name":"type","in":"formData"},{"type":"boolean","description":"Is this the primary attachment","name":"primary","in":"formData"},{"type":"string","description":"name of the file including extension","name":"name","in":"formData","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ItemOut"}},"422":{"description":"Unprocessable Entity","schema":{"$ref":"#/definitions/validate.ErrorResponse"}}}}},"/v1/items/{id}/attachments/{attachment_id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/octet-stream"],"tags":["Items Attachments"],"summary":"Get Item Attachment","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"string","description":"Attachment ID","name":"attachment_id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.ItemAttachmentToken"}}}},"put":{"security":[{"Bearer":[]}],"tags":["Items Attachments"],"summary":"Update Item Attachment","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"string","description":"Attachment ID","name":"attachment_id","in":"path","required":true},{"description":"Attachment Update","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.EntityAttachmentUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ItemOut"}}}},"delete":{"security":[{"Bearer":[]}],"tags":["Items Attachments"],"summary":"Delete Item Attachment","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"string","description":"Attachment ID","name":"attachment_id","in":"path","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/items/{id}/duplicate":{"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"Duplicate Item","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"description":"Duplicate Options","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.DuplicateOptions"}}],"responses":{"201":{"description":"Created","schema":{"$ref":"#/definitions/repo.ItemOut"}}}}},"/v1/items/{id}/maintenance":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Item Maintenance"],"summary":"Get Maintenance Log","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"enum":["scheduled","completed","both"],"type":"string","x-enum-varnames":["MaintenanceFilterStatusScheduled","MaintenanceFilterStatusCompleted","MaintenanceFilterStatusBoth"],"name":"status","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.MaintenanceEntryWithDetails"}}}}},"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Item Maintenance"],"summary":"Create Maintenance Entry","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"description":"Entry Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.MaintenanceEntryCreate"}}],"responses":{"201":{"description":"Created","schema":{"$ref":"#/definitions/repo.MaintenanceEntry"}}}}},"/v1/items/{id}/path":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Get the full path of an item","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.ItemPath"}}}}}},"/v1/labelmaker/assets/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"Get Asset label","parameters":[{"type":"string","description":"Asset ID","name":"id","in":"path","required":true},{"type":"boolean","description":"Print this label, defaults to false","name":"print","in":"query"}],"responses":{"200":{"description":"image/png","schema":{"type":"string"}}}}},"/v1/labelmaker/item/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"Get Item label","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"boolean","description":"Print this label, defaults to false","name":"print","in":"query"}],"responses":{"200":{"description":"image/png","schema":{"type":"string"}}}}},"/v1/labelmaker/location/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Locations"],"summary":"Get Location label","parameters":[{"type":"string","description":"Location ID","name":"id","in":"path","required":true},{"type":"boolean","description":"Print this label, defaults to false","name":"print","in":"query"}],"responses":{"200":{"description":"image/png","schema":{"type":"string"}}}}},"/v1/labels":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Labels"],"summary":"Get All Labels","responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.LabelOut"}}}}},"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Labels"],"summary":"Create Label","parameters":[{"description":"Label Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.LabelCreate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.LabelSummary"}}}}},"/v1/labels/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Labels"],"summary":"Get Label","parameters":[{"type":"string","description":"Label ID","name":"id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.LabelOut"}}}},"put":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Labels"],"summary":"Update Label","parameters":[{"type":"string","description":"Label ID","name":"id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.LabelOut"}}}},"delete":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Labels"],"summary":"Delete Label","parameters":[{"type":"string","description":"Label ID","name":"id","in":"path","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/locations":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Locations"],"summary":"(Deprecated) Get All Locations","deprecated":true,"parameters":[{"type":"boolean","description":"Filter locations with parents","name":"filterChildren","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.LocationOutCount"}}}}},"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Locations"],"summary":"(Deprecated) Create Location","deprecated":true,"parameters":[{"description":"Location Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.LocationCreate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.LocationSummary"}}}}},"/v1/locations/tree":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Locations"],"summary":"(Deprecated) Get Locations Tree","deprecated":true,"parameters":[{"type":"boolean","description":"include items in response tree","name":"withItems","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.TreeItem"}}}}}},"/v1/locations/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Locations"],"summary":"(Deprecated) Get Location","deprecated":true,"parameters":[{"type":"string","description":"Location ID","name":"id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.LocationOut"}}}},"put":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Locations"],"summary":"(Deprecated) Update Location","deprecated":true,"parameters":[{"type":"string","description":"Location ID","name":"id","in":"path","required":true},{"description":"Location Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.LocationUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.LocationOut"}}}},"delete":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Locations"],"summary":"(Deprecated) Delete Location","deprecated":true,"parameters":[{"type":"string","description":"Location ID","name":"id","in":"path","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/maintenance":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Maintenance"],"summary":"Query All Maintenance","parameters":[{"enum":["scheduled","completed","both"],"type":"string","x-enum-varnames":["MaintenanceFilterStatusScheduled","MaintenanceFilterStatusCompleted","MaintenanceFilterStatusBoth"],"name":"status","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.MaintenanceEntryWithDetails"}}}}}},"/v1/maintenance/{id}":{"put":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Maintenance"],"summary":"Update Maintenance Entry","parameters":[{"type":"string","description":"Maintenance ID","name":"id","in":"path","required":true},{"description":"Entry Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.MaintenanceEntryUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.MaintenanceEntry"}}}},"delete":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Maintenance"],"summary":"Delete Maintenance Entry","parameters":[{"type":"string","description":"Maintenance ID","name":"id","in":"path","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/notifiers":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Notifiers"],"summary":"Get Notifiers","responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.NotifierOut"}}}}},"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Notifiers"],"summary":"Create Notifier","parameters":[{"description":"Notifier Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.NotifierCreate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.NotifierOut"}}}}},"/v1/notifiers/test":{"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Notifiers"],"summary":"Test Notifier","parameters":[{"type":"string","description":"URL","name":"url","in":"query","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/notifiers/{id}":{"put":{"security":[{"Bearer":[]}],"tags":["Notifiers"],"summary":"Update Notifier","parameters":[{"type":"string","description":"Notifier ID","name":"id","in":"path","required":true},{"description":"Notifier Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.NotifierUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.NotifierOut"}}}},"delete":{"security":[{"Bearer":[]}],"tags":["Notifiers"],"summary":"Delete a Notifier","parameters":[{"type":"string","description":"Notifier ID","name":"id","in":"path","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/products/search-from-barcode":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"Search EAN from Barcode","parameters":[{"type":"string","description":"barcode to be searched","name":"data","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.BarcodeProduct"}}}}}},"/v1/qrcode":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"Create QR Code","parameters":[{"type":"string","description":"data to be encoded into qrcode","name":"data","in":"query"}],"responses":{"200":{"description":"image/jpeg","schema":{"type":"string"}}}}},"/v1/reporting/bill-of-materials":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Reporting"],"summary":"Export Bill of Materials","responses":{"200":{"description":"text/csv","schema":{"type":"string"}}}}},"/v1/status":{"get":{"produces":["application/json"],"tags":["Base"],"summary":"Application Info","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.APISummary"}}}}},"/v1/users/change-password":{"put":{"security":[{"Bearer":[]}],"tags":["User"],"summary":"Change Password","parameters":[{"description":"Password Payload","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/v1.ChangePassword"}}],"responses":{"204":{"description":"No Content"}}}},"/v1/users/login":{"post":{"consumes":["application/x-www-form-urlencoded","application/json"],"produces":["application/json"],"tags":["Authentication"],"summary":"User Login","parameters":[{"description":"Login Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/v1.LoginForm"}},{"type":"string","description":"auth provider","name":"provider","in":"query"}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.TokenResponse"}}}}},"/v1/users/logout":{"post":{"security":[{"Bearer":[]}],"tags":["Authentication"],"summary":"User Logout","responses":{"204":{"description":"No Content"}}}},"/v1/users/refresh":{"get":{"security":[{"Bearer":[]}],"description":"handleAuthRefresh returns a handler that will issue a new token from an existing token.\nThis does not validate that the user still exists within the database.","tags":["Authentication"],"summary":"User Token Refresh","responses":{"200":{"description":"OK"}}}},"/v1/users/register":{"post":{"produces":["application/json"],"tags":["User"],"summary":"Register New User","parameters":[{"description":"User Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/services.UserRegistration"}}],"responses":{"204":{"description":"No Content"}}}},"/v1/users/self":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["User"],"summary":"Get User Self","responses":{"200":{"description":"OK","schema":{"allOf":[{"$ref":"#/definitions/v1.Wrapped"},{"type":"object","properties":{"item":{"$ref":"#/definitions/repo.UserOut"}}}]}}}},"put":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["User"],"summary":"Update Account","parameters":[{"description":"User Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.UserUpdate"}}],"responses":{"200":{"description":"OK","schema":{"allOf":[{"$ref":"#/definitions/v1.Wrapped"},{"type":"object","properties":{"item":{"$ref":"#/definitions/repo.UserUpdate"}}}]}}}},"delete":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["User"],"summary":"Delete Account","responses":{"204":{"description":"No Content"}}}}},"definitions":{"attachment.Type":{"type":"string","enum":["attachment","photo","manual","warranty","attachment","receipt","thumbnail"],"x-enum-varnames":["DefaultType","TypePhoto","TypeManual","TypeWarranty","TypeAttachment","TypeReceipt","TypeThumbnail"]},"authroles.Role":{"type":"string","enum":["user","admin","user","attachments"],"x-enum-varnames":["DefaultRole","RoleAdmin","RoleUser","RoleAttachments"]},"currencies.Currency":{"type":"object","properties":{"code":{"type":"string"},"decimals":{"type":"integer"},"local":{"type":"string"},"name":{"type":"string"},"symbol":{"type":"string"}}},"ent.Attachment":{"type":"object","properties":{"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AttachmentQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.AttachmentEdges"}]},"id":{"description":"ID of the ent.","type":"string"},"mime_type":{"description":"MimeType holds the value of the \"mime_type\" field.","type":"string"},"path":{"description":"Path holds the value of the \"path\" field.","type":"string"},"primary":{"description":"Primary holds the value of the \"primary\" field.","type":"boolean"},"title":{"description":"Title holds the value of the \"title\" field.","type":"string"},"type":{"description":"Type holds the value of the \"type\" field.","allOf":[{"$ref":"#/definitions/attachment.Type"}]},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.AttachmentEdges":{"type":"object","properties":{"entity":{"description":"Entity holds the value of the entity edge.","allOf":[{"$ref":"#/definitions/ent.Entity"}]},"thumbnail":{"description":"Thumbnail holds the value of the thumbnail edge.","allOf":[{"$ref":"#/definitions/ent.Attachment"}]}}},"ent.AuthRoles":{"type":"object","properties":{"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AuthRolesQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.AuthRolesEdges"}]},"id":{"description":"ID of the ent.","type":"integer"},"role":{"description":"Role holds the value of the \"role\" field.","allOf":[{"$ref":"#/definitions/authroles.Role"}]}}},"ent.AuthRolesEdges":{"type":"object","properties":{"token":{"description":"Token holds the value of the token edge.","allOf":[{"$ref":"#/definitions/ent.AuthTokens"}]}}},"ent.AuthTokens":{"type":"object","properties":{"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AuthTokensQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.AuthTokensEdges"}]},"expires_at":{"description":"ExpiresAt holds the value of the \"expires_at\" field.","type":"string"},"id":{"description":"ID of the ent.","type":"string"},"token":{"description":"Token holds the value of the \"token\" field.","type":"array","items":{"type":"integer"}},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.AuthTokensEdges":{"type":"object","properties":{"roles":{"description":"Roles holds the value of the roles edge.","allOf":[{"$ref":"#/definitions/ent.AuthRoles"}]},"user":{"description":"User holds the value of the user edge.","allOf":[{"$ref":"#/definitions/ent.User"}]}}},"ent.Entity":{"type":"object","properties":{"archived":{"description":"Archived holds the value of the \"archived\" field.","type":"boolean"},"asset_id":{"description":"AssetID holds the value of the \"asset_id\" field.","type":"integer"},"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"description":{"description":"Description holds the value of the \"description\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.EntityEdges"}]},"id":{"description":"ID of the ent.","type":"string"},"import_ref":{"description":"ImportRef holds the value of the \"import_ref\" field.","type":"string"},"insured":{"description":"Insured holds the value of the \"insured\" field.","type":"boolean"},"lifetime_warranty":{"description":"LifetimeWarranty holds the value of the \"lifetime_warranty\" field.","type":"boolean"},"manufacturer":{"description":"Manufacturer holds the value of the \"manufacturer\" field.","type":"string"},"model_number":{"description":"ModelNumber holds the value of the \"model_number\" field.","type":"string"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"notes":{"description":"Notes holds the value of the \"notes\" field.","type":"string"},"purchase_from":{"description":"PurchaseFrom holds the value of the \"purchase_from\" field.","type":"string"},"purchase_price":{"description":"PurchasePrice holds the value of the \"purchase_price\" field.","type":"number"},"purchase_time":{"description":"PurchaseTime holds the value of the \"purchase_time\" field.","type":"string"},"quantity":{"description":"Quantity holds the value of the \"quantity\" field.","type":"integer"},"serial_number":{"description":"SerialNumber holds the value of the \"serial_number\" field.","type":"string"},"sold_notes":{"description":"SoldNotes holds the value of the \"sold_notes\" field.","type":"string"},"sold_price":{"description":"SoldPrice holds the value of the \"sold_price\" field.","type":"number"},"sold_time":{"description":"SoldTime holds the value of the \"sold_time\" field.","type":"string"},"sold_to":{"description":"SoldTo holds the value of the \"sold_to\" field.","type":"string"},"sync_child_entities_locations":{"description":"SyncChildEntitiesLocations holds the value of the \"sync_child_entities_locations\" field.","type":"boolean"},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"},"warranty_details":{"description":"WarrantyDetails holds the value of the \"warranty_details\" field.","type":"string"},"warranty_expires":{"description":"WarrantyExpires holds the value of the \"warranty_expires\" field.","type":"string"}}},"ent.EntityEdges":{"type":"object","properties":{"attachments":{"description":"Attachments holds the value of the attachments edge.","type":"array","items":{"$ref":"#/definitions/ent.Attachment"}},"children":{"description":"Children holds the value of the children edge.","type":"array","items":{"$ref":"#/definitions/ent.Entity"}},"entity":{"description":"Entity holds the value of the entity edge.","type":"array","items":{"$ref":"#/definitions/ent.Entity"}},"fields":{"description":"Fields holds the value of the fields edge.","type":"array","items":{"$ref":"#/definitions/ent.EntityField"}},"group":{"description":"Group holds the value of the group edge.","allOf":[{"$ref":"#/definitions/ent.Group"}]},"label":{"description":"Label holds the value of the label edge.","type":"array","items":{"$ref":"#/definitions/ent.Label"}},"location":{"description":"Location holds the value of the location edge.","allOf":[{"$ref":"#/definitions/ent.Entity"}]},"maintenance_entries":{"description":"MaintenanceEntries holds the value of the maintenance_entries edge.","type":"array","items":{"$ref":"#/definitions/ent.MaintenanceEntry"}},"parent":{"description":"Parent holds the value of the parent edge.","allOf":[{"$ref":"#/definitions/ent.Entity"}]},"type":{"description":"Type holds the value of the type edge.","allOf":[{"$ref":"#/definitions/ent.EntityType"}]}}},"ent.EntityField":{"type":"object","properties":{"boolean_value":{"description":"BooleanValue holds the value of the \"boolean_value\" field.","type":"boolean"},"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"description":{"description":"Description holds the value of the \"description\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityFieldQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.EntityFieldEdges"}]},"id":{"description":"ID of the ent.","type":"string"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"number_value":{"description":"NumberValue holds the value of the \"number_value\" field.","type":"integer"},"text_value":{"description":"TextValue holds the value of the \"text_value\" field.","type":"string"},"time_value":{"description":"TimeValue holds the value of the \"time_value\" field.","type":"string"},"type":{"description":"Type holds the value of the \"type\" field.","allOf":[{"$ref":"#/definitions/entityfield.Type"}]},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.EntityFieldEdges":{"type":"object","properties":{"entity":{"description":"Entity holds the value of the entity edge.","allOf":[{"$ref":"#/definitions/ent.Entity"}]}}},"ent.EntityType":{"type":"object","properties":{"color":{"description":"Color holds the value of the \"color\" field.","type":"string"},"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"description":{"description":"Description holds the value of the \"description\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityTypeQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.EntityTypeEdges"}]},"icon":{"description":"Icon holds the value of the \"icon\" field.","type":"string"},"id":{"description":"ID of the ent.","type":"string"},"is_location":{"description":"IsLocation holds the value of the \"is_location\" field.","type":"boolean"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.EntityTypeEdges":{"type":"object","properties":{"entities":{"description":"Entities holds the value of the entities edge.","type":"array","items":{"$ref":"#/definitions/ent.Entity"}},"group":{"description":"Group holds the value of the group edge.","allOf":[{"$ref":"#/definitions/ent.Group"}]}}},"ent.Group":{"type":"object","properties":{"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"currency":{"description":"Currency holds the value of the \"currency\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the GroupQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.GroupEdges"}]},"id":{"description":"ID of the ent.","type":"string"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.GroupEdges":{"type":"object","properties":{"entities":{"description":"Entities holds the value of the entities edge.","type":"array","items":{"$ref":"#/definitions/ent.Entity"}},"entity_types":{"description":"EntityTypes holds the value of the entity_types edge.","type":"array","items":{"$ref":"#/definitions/ent.EntityType"}},"invitation_tokens":{"description":"InvitationTokens holds the value of the invitation_tokens edge.","type":"array","items":{"$ref":"#/definitions/ent.GroupInvitationToken"}},"labels":{"description":"Labels holds the value of the labels edge.","type":"array","items":{"$ref":"#/definitions/ent.Label"}},"notifiers":{"description":"Notifiers holds the value of the notifiers edge.","type":"array","items":{"$ref":"#/definitions/ent.Notifier"}},"users":{"description":"Users holds the value of the users edge.","type":"array","items":{"$ref":"#/definitions/ent.User"}}}},"ent.GroupInvitationToken":{"type":"object","properties":{"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the GroupInvitationTokenQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.GroupInvitationTokenEdges"}]},"expires_at":{"description":"ExpiresAt holds the value of the \"expires_at\" field.","type":"string"},"id":{"description":"ID of the ent.","type":"string"},"token":{"description":"Token holds the value of the \"token\" field.","type":"array","items":{"type":"integer"}},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"},"uses":{"description":"Uses holds the value of the \"uses\" field.","type":"integer"}}},"ent.GroupInvitationTokenEdges":{"type":"object","properties":{"group":{"description":"Group holds the value of the group edge.","allOf":[{"$ref":"#/definitions/ent.Group"}]}}},"ent.Label":{"type":"object","properties":{"color":{"description":"Color holds the value of the \"color\" field.","type":"string"},"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"description":{"description":"Description holds the value of the \"description\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LabelQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.LabelEdges"}]},"id":{"description":"ID of the ent.","type":"string"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.LabelEdges":{"type":"object","properties":{"entities":{"description":"Entities holds the value of the entities edge.","type":"array","items":{"$ref":"#/definitions/ent.Entity"}},"group":{"description":"Group holds the value of the group edge.","allOf":[{"$ref":"#/definitions/ent.Group"}]}}},"ent.MaintenanceEntry":{"type":"object","properties":{"cost":{"description":"Cost holds the value of the \"cost\" field.","type":"number"},"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"date":{"description":"Date holds the value of the \"date\" field.","type":"string"},"description":{"description":"Description holds the value of the \"description\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the MaintenanceEntryQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.MaintenanceEntryEdges"}]},"entity_id":{"description":"EntityID holds the value of the \"entity_id\" field.","type":"string"},"id":{"description":"ID of the ent.","type":"string"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"scheduled_date":{"description":"ScheduledDate holds the value of the \"scheduled_date\" field.","type":"string"},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.MaintenanceEntryEdges":{"type":"object","properties":{"entity":{"description":"Entity holds the value of the entity edge.","allOf":[{"$ref":"#/definitions/ent.Entity"}]}}},"ent.Notifier":{"type":"object","properties":{"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the NotifierQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.NotifierEdges"}]},"group_id":{"description":"GroupID holds the value of the \"group_id\" field.","type":"string"},"id":{"description":"ID of the ent.","type":"string"},"is_active":{"description":"IsActive holds the value of the \"is_active\" field.","type":"boolean"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"},"user_id":{"description":"UserID holds the value of the \"user_id\" field.","type":"string"}}},"ent.NotifierEdges":{"type":"object","properties":{"group":{"description":"Group holds the value of the group edge.","allOf":[{"$ref":"#/definitions/ent.Group"}]},"user":{"description":"User holds the value of the user edge.","allOf":[{"$ref":"#/definitions/ent.User"}]}}},"ent.User":{"type":"object","properties":{"activated_on":{"description":"ActivatedOn holds the value of the \"activated_on\" field.","type":"string"},"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the UserQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.UserEdges"}]},"email":{"description":"Email holds the value of the \"email\" field.","type":"string"},"id":{"description":"ID of the ent.","type":"string"},"is_superuser":{"description":"IsSuperuser holds the value of the \"is_superuser\" field.","type":"boolean"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"role":{"description":"Role holds the value of the \"role\" field.","allOf":[{"$ref":"#/definitions/user.Role"}]},"superuser":{"description":"Superuser holds the value of the \"superuser\" field.","type":"boolean"},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.UserEdges":{"type":"object","properties":{"auth_tokens":{"description":"AuthTokens holds the value of the auth_tokens edge.","type":"array","items":{"$ref":"#/definitions/ent.AuthTokens"}},"group":{"description":"Group holds the value of the group edge.","allOf":[{"$ref":"#/definitions/ent.Group"}]},"notifiers":{"description":"Notifiers holds the value of the notifiers edge.","type":"array","items":{"$ref":"#/definitions/ent.Notifier"}}}},"entityfield.Type":{"type":"string","enum":["text","number","boolean","time"],"x-enum-varnames":["TypeText","TypeNumber","TypeBoolean","TypeTime"]},"repo.BarcodeProduct":{"type":"object","properties":{"barcode":{"type":"string"},"imageBase64":{"type":"string"},"imageURL":{"type":"string"},"item":{"$ref":"#/definitions/repo.ItemCreate"},"manufacturer":{"type":"string"},"modelNumber":{"description":"Identifications","type":"string"},"notes":{"description":"Extras","type":"string"},"search_engine_name":{"type":"string"}}},"repo.DuplicateOptions":{"type":"object","properties":{"copyAttachments":{"type":"boolean"},"copyCustomFields":{"type":"boolean"},"copyMaintenance":{"type":"boolean"},"copyPrefix":{"type":"string"}}},"repo.EntityAttachment":{"type":"object","properties":{"createdAt":{"type":"string"},"id":{"type":"string"},"mimeType":{"type":"string"},"path":{"type":"string"},"primary":{"type":"boolean"},"thumbnail":{"$ref":"#/definitions/ent.Attachment"},"title":{"type":"string"},"type":{"type":"string"},"updatedAt":{"type":"string"}}},"repo.EntityAttachmentUpdate":{"type":"object","properties":{"primary":{"type":"boolean"},"title":{"type":"string"},"type":{"type":"string"}}},"repo.EntityType":{"type":"object","properties":{"color":{"type":"string"},"description":{"type":"string"},"icon":{"type":"string"},"isLocation":{"type":"boolean"},"name":{"type":"string"}}},"repo.EntityTypeCreate":{"type":"object","required":["isLocation","name"],"properties":{"color":{"type":"string"},"description":{"type":"string"},"icon":{"type":"string"},"isLocation":{"type":"boolean"},"name":{"type":"string"}}},"repo.EntityTypeDelete":{"type":"object","properties":{"replacementId":{"$ref":"#/definitions/uuid.NullUUID"}}},"repo.EntityTypeUpdate":{"type":"object","properties":{"color":{"type":"string"},"description":{"type":"string"},"icon":{"type":"string"},"name":{"type":"string","minLength":1}}},"repo.Group":{"type":"object","properties":{"createdAt":{"type":"string"},"currency":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"updatedAt":{"type":"string"}}},"repo.GroupStatistics":{"type":"object","properties":{"totalItemPrice":{"type":"number"},"totalItems":{"type":"integer"},"totalLabels":{"type":"integer"},"totalLocations":{"type":"integer"},"totalUsers":{"type":"integer"},"totalWithWarranty":{"type":"integer"}}},"repo.GroupUpdate":{"type":"object","properties":{"currency":{"type":"string"},"name":{"type":"string"}}},"repo.ItemCreate":{"type":"object","required":["entityType","name"],"properties":{"description":{"type":"string","maxLength":1000},"entityType":{"type":"string"},"labelIds":{"type":"array","items":{"type":"string"}},"locationId":{"description":"Edges","type":"string"},"name":{"type":"string","maxLength":255,"minLength":1},"parentId":{"type":"string","x-nullable":true},"quantity":{"type":"integer"}}},"repo.ItemField":{"type":"object","properties":{"booleanValue":{"type":"boolean"},"id":{"type":"string"},"name":{"type":"string"},"numberValue":{"type":"integer"},"textValue":{"type":"string"},"type":{"type":"string"}}},"repo.ItemOut":{"type":"object","properties":{"archived":{"type":"boolean"},"assetId":{"type":"string","example":"0"},"attachments":{"type":"array","items":{"$ref":"#/definitions/repo.EntityAttachment"}},"createdAt":{"type":"string"},"description":{"type":"string"},"entityType":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/definitions/repo.ItemField"}},"id":{"type":"string"},"imageId":{"type":"string","x-nullable":true,"x-omitempty":true},"insured":{"type":"boolean"},"labels":{"type":"array","items":{"$ref":"#/definitions/repo.LabelSummary"}},"lifetimeWarranty":{"description":"Warranty","type":"boolean"},"location":{"description":"Edges","allOf":[{"$ref":"#/definitions/repo.LocationSummary"}],"x-nullable":true,"x-omitempty":true},"manufacturer":{"type":"string"},"modelNumber":{"type":"string"},"name":{"type":"string"},"notes":{"description":"Extras","type":"string"},"parent":{"allOf":[{"$ref":"#/definitions/repo.ItemSummary"}],"x-nullable":true,"x-omitempty":true},"purchaseFrom":{"type":"string"},"purchasePrice":{"type":"number"},"purchaseTime":{"description":"Purchase","type":"string"},"quantity":{"type":"integer"},"serialNumber":{"type":"string"},"soldNotes":{"type":"string"},"soldPrice":{"type":"number"},"soldTime":{"description":"Sold","type":"string"},"soldTo":{"type":"string"},"syncChildItemsLocations":{"type":"boolean"},"thumbnailId":{"type":"string","x-nullable":true,"x-omitempty":true},"updatedAt":{"type":"string"},"warrantyDetails":{"type":"string"},"warrantyExpires":{"type":"string"}}},"repo.ItemPatch":{"type":"object","properties":{"id":{"type":"string"},"labelIds":{"type":"array","items":{"type":"string"},"x-nullable":true,"x-omitempty":true},"locationId":{"type":"string","x-nullable":true,"x-omitempty":true},"quantity":{"type":"integer","x-nullable":true,"x-omitempty":true}}},"repo.ItemPath":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"type":{"$ref":"#/definitions/repo.ItemType"}}},"repo.ItemSummary":{"type":"object","properties":{"archived":{"type":"boolean"},"assetId":{"type":"string","example":"0"},"createdAt":{"type":"string"},"description":{"type":"string"},"entityType":{"type":"string"},"id":{"type":"string"},"imageId":{"type":"string","x-nullable":true,"x-omitempty":true},"insured":{"type":"boolean"},"labels":{"type":"array","items":{"$ref":"#/definitions/repo.LabelSummary"}},"location":{"description":"Edges","allOf":[{"$ref":"#/definitions/repo.LocationSummary"}],"x-nullable":true,"x-omitempty":true},"name":{"type":"string"},"purchasePrice":{"type":"number"},"quantity":{"type":"integer"},"soldTime":{"description":"Sale details","type":"string"},"thumbnailId":{"type":"string","x-nullable":true,"x-omitempty":true},"updatedAt":{"type":"string"}}},"repo.ItemType":{"type":"string","enum":["location","item","location","item"],"x-enum-varnames":["EntityTypeLocation","EntityTypeItem","ItemTypeLocation","ItemTypeItem"]},"repo.ItemUpdate":{"type":"object","required":["entityType","name"],"properties":{"archived":{"type":"boolean"},"assetId":{"type":"string"},"description":{"type":"string","maxLength":1000},"entityType":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/definitions/repo.ItemField"}},"id":{"type":"string"},"insured":{"type":"boolean"},"labelIds":{"type":"array","items":{"type":"string"}},"lifetimeWarranty":{"description":"Warranty","type":"boolean"},"locationId":{"description":"Edges","type":"string"},"manufacturer":{"type":"string"},"modelNumber":{"type":"string"},"name":{"type":"string","maxLength":255,"minLength":1},"notes":{"description":"Extras","type":"string"},"parentId":{"type":"string","x-nullable":true,"x-omitempty":true},"purchaseFrom":{"type":"string","maxLength":255},"purchasePrice":{"type":"number","x-nullable":true,"x-omitempty":true},"purchaseTime":{"description":"Purchase","type":"string"},"quantity":{"type":"integer"},"serialNumber":{"description":"Identifications","type":"string"},"soldNotes":{"type":"string"},"soldPrice":{"type":"number","x-nullable":true,"x-omitempty":true},"soldTime":{"description":"Sold","type":"string"},"soldTo":{"type":"string","maxLength":255},"syncChildItemsLocations":{"type":"boolean"},"warrantyDetails":{"type":"string"},"warrantyExpires":{"type":"string"}}},"repo.LabelCreate":{"type":"object","required":["name"],"properties":{"color":{"type":"string"},"description":{"type":"string","maxLength":1000},"name":{"type":"string","maxLength":255,"minLength":1}}},"repo.LabelOut":{"type":"object","properties":{"color":{"type":"string"},"createdAt":{"type":"string"},"description":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"updatedAt":{"type":"string"}}},"repo.LabelSummary":{"type":"object","properties":{"color":{"type":"string"},"createdAt":{"type":"string"},"description":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"updatedAt":{"type":"string"}}},"repo.LocationCreate":{"type":"object","required":["entityType"],"properties":{"description":{"type":"string"},"entityType":{"type":"string"},"name":{"type":"string"},"parentId":{"type":"string","x-nullable":true}}},"repo.LocationOut":{"type":"object","properties":{"children":{"type":"array","items":{"$ref":"#/definitions/repo.LocationSummary"}},"createdAt":{"type":"string"},"description":{"type":"string"},"entityType":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"parent":{"$ref":"#/definitions/repo.LocationSummary"},"totalPrice":{"type":"number"},"updatedAt":{"type":"string"}}},"repo.LocationOutCount":{"type":"object","properties":{"createdAt":{"type":"string"},"description":{"type":"string"},"entityType":{"type":"string"},"id":{"type":"string"},"itemCount":{"type":"integer"},"name":{"type":"string"},"updatedAt":{"type":"string"}}},"repo.LocationSummary":{"type":"object","properties":{"createdAt":{"type":"string"},"description":{"type":"string"},"entityType":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"updatedAt":{"type":"string"}}},"repo.LocationUpdate":{"type":"object","required":["entityType"],"properties":{"description":{"type":"string"},"entityType":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"parentId":{"type":"string","x-nullable":true}}},"repo.MaintenanceEntry":{"type":"object","properties":{"completedDate":{"type":"string"},"cost":{"type":"string","example":"0"},"description":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"scheduledDate":{"type":"string"}}},"repo.MaintenanceEntryCreate":{"type":"object","required":["name"],"properties":{"completedDate":{"type":"string"},"cost":{"type":"string","example":"0"},"description":{"type":"string"},"name":{"type":"string"},"scheduledDate":{"type":"string"}}},"repo.MaintenanceEntryUpdate":{"type":"object","properties":{"completedDate":{"type":"string"},"cost":{"type":"string","example":"0"},"description":{"type":"string"},"name":{"type":"string"},"scheduledDate":{"type":"string"}}},"repo.MaintenanceEntryWithDetails":{"type":"object","properties":{"completedDate":{"type":"string"},"cost":{"type":"string","example":"0"},"description":{"type":"string"},"id":{"type":"string"},"itemID":{"type":"string"},"itemName":{"type":"string"},"name":{"type":"string"},"scheduledDate":{"type":"string"}}},"repo.MaintenanceFilterStatus":{"type":"string","enum":["scheduled","completed","both"],"x-enum-varnames":["MaintenanceFilterStatusScheduled","MaintenanceFilterStatusCompleted","MaintenanceFilterStatusBoth"]},"repo.NotifierCreate":{"type":"object","required":["name","url"],"properties":{"isActive":{"type":"boolean"},"name":{"type":"string","maxLength":255,"minLength":1},"url":{"type":"string"}}},"repo.NotifierOut":{"type":"object","properties":{"createdAt":{"type":"string"},"groupId":{"type":"string"},"id":{"type":"string"},"isActive":{"type":"boolean"},"name":{"type":"string"},"updatedAt":{"type":"string"},"url":{"type":"string"},"userId":{"type":"string"}}},"repo.NotifierUpdate":{"type":"object","required":["name"],"properties":{"isActive":{"type":"boolean"},"name":{"type":"string","maxLength":255,"minLength":1},"url":{"type":"string","x-nullable":true}}},"repo.PaginationResult-repo_ItemSummary":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/definitions/repo.ItemSummary"}},"page":{"type":"integer"},"pageSize":{"type":"integer"},"total":{"type":"integer"}}},"repo.TotalsByOrganizer":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"total":{"type":"number"}}},"repo.TreeItem":{"type":"object","properties":{"children":{"type":"array","items":{"$ref":"#/definitions/repo.TreeItem"}},"id":{"type":"string"},"name":{"type":"string"},"type":{"type":"string"}}},"repo.UserOut":{"type":"object","properties":{"email":{"type":"string"},"groupId":{"type":"string"},"groupName":{"type":"string"},"id":{"type":"string"},"isOwner":{"type":"boolean"},"isSuperuser":{"type":"boolean"},"name":{"type":"string"}}},"repo.UserUpdate":{"type":"object","properties":{"email":{"type":"string"},"name":{"type":"string"}}},"repo.ValueOverTime":{"type":"object","properties":{"end":{"type":"string"},"entries":{"type":"array","items":{"$ref":"#/definitions/repo.ValueOverTimeEntry"}},"start":{"type":"string"},"valueAtEnd":{"type":"number"},"valueAtStart":{"type":"number"}}},"repo.ValueOverTimeEntry":{"type":"object","properties":{"date":{"type":"string"},"name":{"type":"string"},"value":{"type":"number"}}},"services.Latest":{"type":"object","properties":{"date":{"type":"string"},"version":{"type":"string"}}},"services.UserRegistration":{"type":"object","properties":{"email":{"type":"string"},"name":{"type":"string"},"password":{"type":"string"},"token":{"type":"string"}}},"user.Role":{"type":"string","enum":["user","user","owner"],"x-enum-varnames":["DefaultRole","RoleUser","RoleOwner"]},"uuid.NullUUID":{"type":"object","properties":{"uuid":{"type":"string"},"valid":{"description":"Valid is true if UUID is not NULL","type":"boolean"}}},"v1.APISummary":{"type":"object","properties":{"allowRegistration":{"type":"boolean"},"build":{"$ref":"#/definitions/v1.Build"},"demo":{"type":"boolean"},"health":{"type":"boolean"},"labelPrinting":{"type":"boolean"},"latest":{"$ref":"#/definitions/services.Latest"},"message":{"type":"string"},"title":{"type":"string"},"versions":{"type":"array","items":{"type":"string"}}}},"v1.ActionAmountResult":{"type":"object","properties":{"completed":{"type":"integer"}}},"v1.Build":{"type":"object","properties":{"buildTime":{"type":"string"},"commit":{"type":"string"},"version":{"type":"string"}}},"v1.ChangePassword":{"type":"object","properties":{"current":{"type":"string"},"new":{"type":"string"}}},"v1.GroupInvitation":{"type":"object","properties":{"expiresAt":{"type":"string"},"token":{"type":"string"},"uses":{"type":"integer"}}},"v1.GroupInvitationCreate":{"type":"object","required":["uses"],"properties":{"expiresAt":{"type":"string"},"uses":{"type":"integer","maximum":100,"minimum":1}}},"v1.ItemAttachmentToken":{"type":"object","properties":{"token":{"type":"string"}}},"v1.LoginForm":{"type":"object","properties":{"password":{"type":"string","example":"admin"},"stayLoggedIn":{"type":"boolean"},"username":{"type":"string","example":"admin@admin.com"}}},"v1.TokenResponse":{"type":"object","properties":{"attachmentToken":{"type":"string"},"expiresAt":{"type":"string"},"token":{"type":"string"}}},"v1.Wrapped":{"type":"object","properties":{"item":{}}},"validate.ErrorResponse":{"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"string"}}}},"securityDefinitions":{"Bearer":{"description":"\"Type 'Bearer TOKEN' to correctly set the API Key\"","type":"apiKey","name":"Authorization","in":"header"}}}` + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{escape .Description}}", + "title": "{{.Title}}", + "contact": { + "name": "Homebox Team", + "url": "https://discord.homebox.software" + }, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/v1/actions/create-missing-thumbnails": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Creates thumbnails for items that are missing them", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Create Missing Thumbnails", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, + "/v1/actions/ensure-asset-ids": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Ensures all items in the database have an asset ID", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Ensure Asset IDs", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, + "/v1/actions/ensure-import-refs": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Ensures all items in the database have an import ref", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Ensures Import Refs", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, + "/v1/actions/set-primary-photos": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Sets the first photo of each item as the primary photo", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Set Primary Photos", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, + "/v1/actions/zero-item-time-fields": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Resets all item date fields to the beginning of the day", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Zero Out Time Fields", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, + "/v1/assets/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get Item by Asset ID", + "parameters": [ + { + "type": "string", + "description": "Asset ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.PaginationResult-repo_ItemSummary" + } + } + } + } + }, + "/v1/currency": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "Base" + ], + "summary": "Currency", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/currencies.Currency" + } + } + } + } + }, + "/v1/groups": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Group" + ], + "summary": "Get Group", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.Group" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Group" + ], + "summary": "Update Group", + "parameters": [ + { + "description": "User Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.GroupUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.Group" + } + } + } + } + }, + "/v1/groups/invitations": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Group" + ], + "summary": "Create Group Invitation", + "parameters": [ + { + "description": "User Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.GroupInvitationCreate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.GroupInvitation" + } + } + } + } + }, + "/v1/groups/statistics": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Statistics" + ], + "summary": "Get Group Statistics", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.GroupStatistics" + } + } + } + } + }, + "/v1/groups/statistics/labels": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Statistics" + ], + "summary": "Get Label Statistics", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.TotalsByOrganizer" + } + } + } + } + } + }, + "/v1/groups/statistics/locations": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Statistics" + ], + "summary": "Get Location Statistics", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.TotalsByOrganizer" + } + } + } + } + } + }, + "/v1/groups/statistics/purchase-price": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Statistics" + ], + "summary": "Get Purchase Price Statistics", + "parameters": [ + { + "type": "string", + "description": "start date", + "name": "start", + "in": "query" + }, + { + "type": "string", + "description": "end date", + "name": "end", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ValueOverTime" + } + } + } + } + }, + "/v1/items": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Query All Items", + "parameters": [ + { + "type": "string", + "description": "search string", + "name": "q", + "in": "query" + }, + { + "type": "integer", + "description": "page number", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "items per page", + "name": "pageSize", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "label Ids", + "name": "labels", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "location Ids", + "name": "locations", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "parent Ids", + "name": "parentIds", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.PaginationResult-repo_ItemSummary" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Create Item", + "parameters": [ + { + "description": "Item Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemCreate" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.ItemSummary" + } + } + } + } + }, + "/v1/items/export": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Items" + ], + "summary": "Export Items", + "responses": { + "200": { + "description": "text/csv", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/items/fields": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get All Custom Field Names", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + }, + "/v1/items/fields/values": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get All Custom Field Values", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + }, + "/v1/items/import": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Import Items", + "parameters": [ + { + "type": "file", + "description": "Image to upload", + "name": "csv", + "in": "formData", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/items/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get Item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Update Item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Item Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Delete Item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + }, + "patch": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Update Item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Item Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemPatch" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + } + }, + "/v1/items/{id}/attachments": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items Attachments" + ], + "summary": "Create Item Attachment", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "file", + "description": "File attachment", + "name": "file", + "in": "formData", + "required": true + }, + { + "type": "string", + "description": "Type of file", + "name": "type", + "in": "formData" + }, + { + "type": "boolean", + "description": "Is this the primary attachment", + "name": "primary", + "in": "formData" + }, + { + "type": "string", + "description": "name of the file including extension", + "name": "name", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + }, + "422": { + "description": "Unprocessable Entity", + "schema": { + "$ref": "#/definitions/validate.ErrorResponse" + } + } + } + } + }, + "/v1/items/{id}/attachments/{attachment_id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/octet-stream" + ], + "tags": [ + "Items Attachments" + ], + "summary": "Get Item Attachment", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Attachment ID", + "name": "attachment_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ItemAttachmentToken" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Items Attachments" + ], + "summary": "Update Item Attachment", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Attachment ID", + "name": "attachment_id", + "in": "path", + "required": true + }, + { + "description": "Attachment Update", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemAttachmentUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Items Attachments" + ], + "summary": "Delete Item Attachment", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Attachment ID", + "name": "attachment_id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/items/{id}/duplicate": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Duplicate Item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Duplicate Options", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.DuplicateOptions" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + } + }, + "/v1/items/{id}/maintenance": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Maintenance" + ], + "summary": "Get Maintenance Log", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "enum": [ + "scheduled", + "completed", + "both" + ], + "type": "string", + "x-enum-varnames": [ + "MaintenanceFilterStatusScheduled", + "MaintenanceFilterStatusCompleted", + "MaintenanceFilterStatusBoth" + ], + "name": "status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.MaintenanceEntryWithDetails" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Maintenance" + ], + "summary": "Create Maintenance Entry", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Entry Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.MaintenanceEntryCreate" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.MaintenanceEntry" + } + } + } + } + }, + "/v1/items/{id}/path": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get the full path of an item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemPath" + } + } + } + } + } + }, + "/v1/labelmaker/assets/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get Asset label", + "parameters": [ + { + "type": "string", + "description": "Asset ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "Print this label, defaults to false", + "name": "print", + "in": "query" + } + ], + "responses": { + "200": { + "description": "image/png", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/labelmaker/item/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get Item label", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "Print this label, defaults to false", + "name": "print", + "in": "query" + } + ], + "responses": { + "200": { + "description": "image/png", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/labelmaker/location/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Get Location label", + "parameters": [ + { + "type": "string", + "description": "Location ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "Print this label, defaults to false", + "name": "print", + "in": "query" + } + ], + "responses": { + "200": { + "description": "image/png", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/labels": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Labels" + ], + "summary": "Get All Labels", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.LabelOut" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Labels" + ], + "summary": "Create Label", + "parameters": [ + { + "description": "Label Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.LabelCreate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LabelSummary" + } + } + } + } + }, + "/v1/labels/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Labels" + ], + "summary": "Get Label", + "parameters": [ + { + "type": "string", + "description": "Label ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LabelOut" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Labels" + ], + "summary": "Update Label", + "parameters": [ + { + "type": "string", + "description": "Label ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LabelOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Labels" + ], + "summary": "Delete Label", + "parameters": [ + { + "type": "string", + "description": "Label ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/locations": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Get All Locations", + "parameters": [ + { + "type": "boolean", + "description": "Filter locations with parents", + "name": "filterChildren", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.LocationOutCount" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Create Location", + "parameters": [ + { + "description": "Location Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.LocationCreate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LocationSummary" + } + } + } + } + }, + "/v1/locations/tree": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Get Locations Tree", + "parameters": [ + { + "type": "boolean", + "description": "include items in response tree", + "name": "withItems", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.TreeItem" + } + } + } + } + } + }, + "/v1/locations/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Get Location", + "parameters": [ + { + "type": "string", + "description": "Location ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LocationOut" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Update Location", + "parameters": [ + { + "type": "string", + "description": "Location ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Location Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.LocationUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LocationOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Delete Location", + "parameters": [ + { + "type": "string", + "description": "Location ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/maintenance": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Maintenance" + ], + "summary": "Query All Maintenance", + "parameters": [ + { + "enum": [ + "scheduled", + "completed", + "both" + ], + "type": "string", + "x-enum-varnames": [ + "MaintenanceFilterStatusScheduled", + "MaintenanceFilterStatusCompleted", + "MaintenanceFilterStatusBoth" + ], + "name": "status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.MaintenanceEntryWithDetails" + } + } + } + } + } + }, + "/v1/maintenance/{id}": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Maintenance" + ], + "summary": "Update Maintenance Entry", + "parameters": [ + { + "type": "string", + "description": "Maintenance ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Entry Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.MaintenanceEntryUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.MaintenanceEntry" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Maintenance" + ], + "summary": "Delete Maintenance Entry", + "parameters": [ + { + "type": "string", + "description": "Maintenance ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/notifiers": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Notifiers" + ], + "summary": "Get Notifiers", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.NotifierOut" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Notifiers" + ], + "summary": "Create Notifier", + "parameters": [ + { + "description": "Notifier Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.NotifierCreate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.NotifierOut" + } + } + } + } + }, + "/v1/notifiers/test": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Notifiers" + ], + "summary": "Test Notifier", + "parameters": [ + { + "type": "string", + "description": "URL", + "name": "url", + "in": "query", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/notifiers/{id}": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Notifiers" + ], + "summary": "Update Notifier", + "parameters": [ + { + "type": "string", + "description": "Notifier ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Notifier Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.NotifierUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.NotifierOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Notifiers" + ], + "summary": "Delete a Notifier", + "parameters": [ + { + "type": "string", + "description": "Notifier ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/products/search-from-barcode": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Search EAN from Barcode", + "parameters": [ + { + "type": "string", + "description": "barcode to be searched", + "name": "data", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.BarcodeProduct" + } + } + } + } + } + }, + "/v1/qrcode": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Create QR Code", + "parameters": [ + { + "type": "string", + "description": "data to be encoded into qrcode", + "name": "data", + "in": "query" + } + ], + "responses": { + "200": { + "description": "image/jpeg", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/reporting/bill-of-materials": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Reporting" + ], + "summary": "Export Bill of Materials", + "responses": { + "200": { + "description": "text/csv", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/status": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "Base" + ], + "summary": "Application Info", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.APISummary" + } + } + } + } + }, + "/v1/templates": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Get All Item Templates", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemTemplateSummary" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Create Item Template", + "parameters": [ + { + "description": "Template Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemTemplateCreate" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.ItemTemplateOut" + } + } + } + } + }, + "/v1/templates/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Get Item Template", + "parameters": [ + { + "type": "string", + "description": "Template ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemTemplateOut" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Update Item Template", + "parameters": [ + { + "type": "string", + "description": "Template ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Template Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemTemplateUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemTemplateOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Delete Item Template", + "parameters": [ + { + "type": "string", + "description": "Template ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/templates/{id}/create-item": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Create Item from Template", + "parameters": [ + { + "type": "string", + "description": "Template ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Item Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.ItemTemplateCreateItemRequest" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + } + }, + "/v1/users/change-password": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "User" + ], + "summary": "Change Password", + "parameters": [ + { + "description": "Password Payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.ChangePassword" + } + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/users/login": { + "post": { + "consumes": [ + "application/x-www-form-urlencoded", + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Authentication" + ], + "summary": "User Login", + "parameters": [ + { + "description": "Login Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.LoginForm" + } + }, + { + "type": "string", + "description": "auth provider", + "name": "provider", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.TokenResponse" + } + } + } + } + }, + "/v1/users/login/oidc": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "Authentication" + ], + "summary": "OIDC Login Initiation", + "responses": { + "302": { + "description": "Found" + } + } + } + }, + "/v1/users/login/oidc/callback": { + "get": { + "tags": [ + "Authentication" + ], + "summary": "OIDC Callback Handler", + "parameters": [ + { + "type": "string", + "description": "Authorization code", + "name": "code", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "State parameter", + "name": "state", + "in": "query", + "required": true + } + ], + "responses": { + "302": { + "description": "Found" + } + } + } + }, + "/v1/users/logout": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Authentication" + ], + "summary": "User Logout", + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/users/refresh": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "handleAuthRefresh returns a handler that will issue a new token from an existing token.\nThis does not validate that the user still exists within the database.", + "tags": [ + "Authentication" + ], + "summary": "User Token Refresh", + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/v1/users/register": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Register New User", + "parameters": [ + { + "description": "User Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/services.UserRegistration" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "403": { + "description": "Local login is not enabled", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/users/self": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Get User Self", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/v1.Wrapped" + }, + { + "type": "object", + "properties": { + "item": { + "$ref": "#/definitions/repo.UserOut" + } + } + } + ] + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Update Account", + "parameters": [ + { + "description": "User Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.UserUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/v1.Wrapped" + }, + { + "type": "object", + "properties": { + "item": { + "$ref": "#/definitions/repo.UserUpdate" + } + } + } + ] + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Delete Account", + "responses": { + "204": { + "description": "No Content" + } + } + } + } + }, + "definitions": { + "attachment.Type": { + "type": "string", + "enum": [ + "attachment", + "photo", + "manual", + "warranty", + "attachment", + "receipt", + "thumbnail" + ], + "x-enum-varnames": [ + "DefaultType", + "TypePhoto", + "TypeManual", + "TypeWarranty", + "TypeAttachment", + "TypeReceipt", + "TypeThumbnail" + ] + }, + "authroles.Role": { + "type": "string", + "enum": [ + "user", + "admin", + "user", + "attachments" + ], + "x-enum-varnames": [ + "DefaultRole", + "RoleAdmin", + "RoleUser", + "RoleAttachments" + ] + }, + "currencies.Currency": { + "type": "object", + "properties": { + "code": { + "type": "string" + }, + "decimals": { + "type": "integer" + }, + "local": { + "type": "string" + }, + "name": { + "type": "string" + }, + "symbol": { + "type": "string" + } + } + }, + "ent.Attachment": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AttachmentQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.AttachmentEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "mime_type": { + "description": "MimeType holds the value of the \"mime_type\" field.", + "type": "string" + }, + "path": { + "description": "Path holds the value of the \"path\" field.", + "type": "string" + }, + "primary": { + "description": "Primary holds the value of the \"primary\" field.", + "type": "boolean" + }, + "title": { + "description": "Title holds the value of the \"title\" field.", + "type": "string" + }, + "type": { + "description": "Type holds the value of the \"type\" field.", + "allOf": [ + { + "$ref": "#/definitions/attachment.Type" + } + ] + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.AttachmentEdges": { + "type": "object", + "properties": { + "item": { + "description": "Item holds the value of the item edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Item" + } + ] + }, + "thumbnail": { + "description": "Thumbnail holds the value of the thumbnail edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Attachment" + } + ] + } + } + }, + "ent.AuthRoles": { + "type": "object", + "properties": { + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AuthRolesQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.AuthRolesEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "integer" + }, + "role": { + "description": "Role holds the value of the \"role\" field.", + "allOf": [ + { + "$ref": "#/definitions/authroles.Role" + } + ] + } + } + }, + "ent.AuthRolesEdges": { + "type": "object", + "properties": { + "token": { + "description": "Token holds the value of the token edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.AuthTokens" + } + ] + } + } + }, + "ent.AuthTokens": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AuthTokensQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.AuthTokensEdges" + } + ] + }, + "expires_at": { + "description": "ExpiresAt holds the value of the \"expires_at\" field.", + "type": "string" + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "token": { + "description": "Token holds the value of the \"token\" field.", + "type": "array", + "items": { + "type": "integer" + } + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.AuthTokensEdges": { + "type": "object", + "properties": { + "roles": { + "description": "Roles holds the value of the roles edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.AuthRoles" + } + ] + }, + "user": { + "description": "User holds the value of the user edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.User" + } + ] + } + } + }, + "ent.Group": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "currency": { + "description": "Currency holds the value of the \"currency\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the GroupQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.GroupEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.GroupEdges": { + "type": "object", + "properties": { + "invitation_tokens": { + "description": "InvitationTokens holds the value of the invitation_tokens edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.GroupInvitationToken" + } + }, + "item_templates": { + "description": "ItemTemplates holds the value of the item_templates edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.ItemTemplate" + } + }, + "items": { + "description": "Items holds the value of the items edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Item" + } + }, + "labels": { + "description": "Labels holds the value of the labels edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Label" + } + }, + "locations": { + "description": "Locations holds the value of the locations edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Location" + } + }, + "notifiers": { + "description": "Notifiers holds the value of the notifiers edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Notifier" + } + }, + "users": { + "description": "Users holds the value of the users edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.User" + } + } + } + }, + "ent.GroupInvitationToken": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the GroupInvitationTokenQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.GroupInvitationTokenEdges" + } + ] + }, + "expires_at": { + "description": "ExpiresAt holds the value of the \"expires_at\" field.", + "type": "string" + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "token": { + "description": "Token holds the value of the \"token\" field.", + "type": "array", + "items": { + "type": "integer" + } + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + }, + "uses": { + "description": "Uses holds the value of the \"uses\" field.", + "type": "integer" + } + } + }, + "ent.GroupInvitationTokenEdges": { + "type": "object", + "properties": { + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + } + } + }, + "ent.Item": { + "type": "object", + "properties": { + "archived": { + "description": "Archived holds the value of the \"archived\" field.", + "type": "boolean" + }, + "asset_id": { + "description": "AssetID holds the value of the \"asset_id\" field.", + "type": "integer" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.ItemEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "import_ref": { + "description": "ImportRef holds the value of the \"import_ref\" field.", + "type": "string" + }, + "insured": { + "description": "Insured holds the value of the \"insured\" field.", + "type": "boolean" + }, + "lifetime_warranty": { + "description": "LifetimeWarranty holds the value of the \"lifetime_warranty\" field.", + "type": "boolean" + }, + "manufacturer": { + "description": "Manufacturer holds the value of the \"manufacturer\" field.", + "type": "string" + }, + "model_number": { + "description": "ModelNumber holds the value of the \"model_number\" field.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "notes": { + "description": "Notes holds the value of the \"notes\" field.", + "type": "string" + }, + "purchase_from": { + "description": "PurchaseFrom holds the value of the \"purchase_from\" field.", + "type": "string" + }, + "purchase_price": { + "description": "PurchasePrice holds the value of the \"purchase_price\" field.", + "type": "number" + }, + "purchase_time": { + "description": "PurchaseTime holds the value of the \"purchase_time\" field.", + "type": "string" + }, + "quantity": { + "description": "Quantity holds the value of the \"quantity\" field.", + "type": "integer" + }, + "serial_number": { + "description": "SerialNumber holds the value of the \"serial_number\" field.", + "type": "string" + }, + "sold_notes": { + "description": "SoldNotes holds the value of the \"sold_notes\" field.", + "type": "string" + }, + "sold_price": { + "description": "SoldPrice holds the value of the \"sold_price\" field.", + "type": "number" + }, + "sold_time": { + "description": "SoldTime holds the value of the \"sold_time\" field.", + "type": "string" + }, + "sold_to": { + "description": "SoldTo holds the value of the \"sold_to\" field.", + "type": "string" + }, + "sync_child_items_locations": { + "description": "SyncChildItemsLocations holds the value of the \"sync_child_items_locations\" field.", + "type": "boolean" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + }, + "warranty_details": { + "description": "WarrantyDetails holds the value of the \"warranty_details\" field.", + "type": "string" + }, + "warranty_expires": { + "description": "WarrantyExpires holds the value of the \"warranty_expires\" field.", + "type": "string" + } + } + }, + "ent.ItemEdges": { + "type": "object", + "properties": { + "attachments": { + "description": "Attachments holds the value of the attachments edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Attachment" + } + }, + "children": { + "description": "Children holds the value of the children edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Item" + } + }, + "fields": { + "description": "Fields holds the value of the fields edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.ItemField" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "label": { + "description": "Label holds the value of the label edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Label" + } + }, + "location": { + "description": "Location holds the value of the location edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Location" + } + ] + }, + "maintenance_entries": { + "description": "MaintenanceEntries holds the value of the maintenance_entries edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.MaintenanceEntry" + } + }, + "parent": { + "description": "Parent holds the value of the parent edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Item" + } + ] + } + } + }, + "ent.ItemField": { + "type": "object", + "properties": { + "boolean_value": { + "description": "BooleanValue holds the value of the \"boolean_value\" field.", + "type": "boolean" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemFieldQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.ItemFieldEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "number_value": { + "description": "NumberValue holds the value of the \"number_value\" field.", + "type": "integer" + }, + "text_value": { + "description": "TextValue holds the value of the \"text_value\" field.", + "type": "string" + }, + "time_value": { + "description": "TimeValue holds the value of the \"time_value\" field.", + "type": "string" + }, + "type": { + "description": "Type holds the value of the \"type\" field.", + "allOf": [ + { + "$ref": "#/definitions/itemfield.Type" + } + ] + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.ItemFieldEdges": { + "type": "object", + "properties": { + "item": { + "description": "Item holds the value of the item edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Item" + } + ] + } + } + }, + "ent.ItemTemplate": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "default_description": { + "description": "Default description for items created from this template", + "type": "string" + }, + "default_insured": { + "description": "DefaultInsured holds the value of the \"default_insured\" field.", + "type": "boolean" + }, + "default_label_ids": { + "description": "Default label IDs for items created from this template", + "type": "array", + "items": { + "type": "string" + } + }, + "default_lifetime_warranty": { + "description": "DefaultLifetimeWarranty holds the value of the \"default_lifetime_warranty\" field.", + "type": "boolean" + }, + "default_manufacturer": { + "description": "DefaultManufacturer holds the value of the \"default_manufacturer\" field.", + "type": "string" + }, + "default_model_number": { + "description": "Default model number for items created from this template", + "type": "string" + }, + "default_name": { + "description": "Default name template for items (can use placeholders)", + "type": "string" + }, + "default_quantity": { + "description": "DefaultQuantity holds the value of the \"default_quantity\" field.", + "type": "integer" + }, + "default_warranty_details": { + "description": "DefaultWarrantyDetails holds the value of the \"default_warranty_details\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemTemplateQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.ItemTemplateEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "include_purchase_fields": { + "description": "Whether to include purchase fields in items created from this template", + "type": "boolean" + }, + "include_sold_fields": { + "description": "Whether to include sold fields in items created from this template", + "type": "boolean" + }, + "include_warranty_fields": { + "description": "Whether to include warranty fields in items created from this template", + "type": "boolean" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "notes": { + "description": "Notes holds the value of the \"notes\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.ItemTemplateEdges": { + "type": "object", + "properties": { + "fields": { + "description": "Fields holds the value of the fields edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.TemplateField" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "location": { + "description": "Location holds the value of the location edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Location" + } + ] + } + } + }, + "ent.Label": { + "type": "object", + "properties": { + "color": { + "description": "Color holds the value of the \"color\" field.", + "type": "string" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LabelQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.LabelEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.LabelEdges": { + "type": "object", + "properties": { + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "items": { + "description": "Items holds the value of the items edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Item" + } + } + } + }, + "ent.Location": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LocationQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.LocationEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.LocationEdges": { + "type": "object", + "properties": { + "children": { + "description": "Children holds the value of the children edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Location" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "items": { + "description": "Items holds the value of the items edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Item" + } + }, + "parent": { + "description": "Parent holds the value of the parent edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Location" + } + ] + } + } + }, + "ent.MaintenanceEntry": { + "type": "object", + "properties": { + "cost": { + "description": "Cost holds the value of the \"cost\" field.", + "type": "number" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "date": { + "description": "Date holds the value of the \"date\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the MaintenanceEntryQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.MaintenanceEntryEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "item_id": { + "description": "ItemID holds the value of the \"item_id\" field.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "scheduled_date": { + "description": "ScheduledDate holds the value of the \"scheduled_date\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.MaintenanceEntryEdges": { + "type": "object", + "properties": { + "item": { + "description": "Item holds the value of the item edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Item" + } + ] + } + } + }, + "ent.Notifier": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the NotifierQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.NotifierEdges" + } + ] + }, + "group_id": { + "description": "GroupID holds the value of the \"group_id\" field.", + "type": "string" + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "is_active": { + "description": "IsActive holds the value of the \"is_active\" field.", + "type": "boolean" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + }, + "user_id": { + "description": "UserID holds the value of the \"user_id\" field.", + "type": "string" + } + } + }, + "ent.NotifierEdges": { + "type": "object", + "properties": { + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "user": { + "description": "User holds the value of the user edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.User" + } + ] + } + } + }, + "ent.TemplateField": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the TemplateFieldQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.TemplateFieldEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "text_value": { + "description": "TextValue holds the value of the \"text_value\" field.", + "type": "string" + }, + "type": { + "description": "Type holds the value of the \"type\" field.", + "allOf": [ + { + "$ref": "#/definitions/templatefield.Type" + } + ] + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.TemplateFieldEdges": { + "type": "object", + "properties": { + "item_template": { + "description": "ItemTemplate holds the value of the item_template edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.ItemTemplate" + } + ] + } + } + }, + "ent.User": { + "type": "object", + "properties": { + "activated_on": { + "description": "ActivatedOn holds the value of the \"activated_on\" field.", + "type": "string" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the UserQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.UserEdges" + } + ] + }, + "email": { + "description": "Email holds the value of the \"email\" field.", + "type": "string" + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "is_superuser": { + "description": "IsSuperuser holds the value of the \"is_superuser\" field.", + "type": "boolean" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "oidc_issuer": { + "description": "OidcIssuer holds the value of the \"oidc_issuer\" field.", + "type": "string" + }, + "oidc_subject": { + "description": "OidcSubject holds the value of the \"oidc_subject\" field.", + "type": "string" + }, + "role": { + "description": "Role holds the value of the \"role\" field.", + "allOf": [ + { + "$ref": "#/definitions/user.Role" + } + ] + }, + "superuser": { + "description": "Superuser holds the value of the \"superuser\" field.", + "type": "boolean" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.UserEdges": { + "type": "object", + "properties": { + "auth_tokens": { + "description": "AuthTokens holds the value of the auth_tokens edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.AuthTokens" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "notifiers": { + "description": "Notifiers holds the value of the notifiers edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Notifier" + } + } + } + }, + "itemfield.Type": { + "type": "string", + "enum": [ + "text", + "number", + "boolean", + "time" + ], + "x-enum-varnames": [ + "TypeText", + "TypeNumber", + "TypeBoolean", + "TypeTime" + ] + }, + "repo.BarcodeProduct": { + "type": "object", + "properties": { + "barcode": { + "type": "string" + }, + "imageBase64": { + "type": "string" + }, + "imageURL": { + "type": "string" + }, + "item": { + "$ref": "#/definitions/repo.ItemCreate" + }, + "manufacturer": { + "type": "string" + }, + "modelNumber": { + "description": "Identifications", + "type": "string" + }, + "notes": { + "description": "Extras", + "type": "string" + }, + "search_engine_name": { + "type": "string" + } + } + }, + "repo.DuplicateOptions": { + "type": "object", + "properties": { + "copyAttachments": { + "type": "boolean" + }, + "copyCustomFields": { + "type": "boolean" + }, + "copyMaintenance": { + "type": "boolean" + }, + "copyPrefix": { + "type": "string" + } + } + }, + "repo.Group": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "currency": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.GroupStatistics": { + "type": "object", + "properties": { + "totalItemPrice": { + "type": "number" + }, + "totalItems": { + "type": "integer" + }, + "totalLabels": { + "type": "integer" + }, + "totalLocations": { + "type": "integer" + }, + "totalUsers": { + "type": "integer" + }, + "totalWithWarranty": { + "type": "integer" + } + } + }, + "repo.GroupUpdate": { + "type": "object", + "properties": { + "currency": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "repo.ItemAttachment": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "id": { + "type": "string" + }, + "mimeType": { + "type": "string" + }, + "path": { + "type": "string" + }, + "primary": { + "type": "boolean" + }, + "thumbnail": { + "$ref": "#/definitions/ent.Attachment" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemAttachmentUpdate": { + "type": "object", + "properties": { + "primary": { + "type": "boolean" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.ItemCreate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "description": { + "type": "string", + "maxLength": 1000 + }, + "labelIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "locationId": { + "description": "Edges", + "type": "string" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "parentId": { + "type": "string", + "x-nullable": true + }, + "quantity": { + "type": "integer" + } + } + }, + "repo.ItemField": { + "type": "object", + "properties": { + "booleanValue": { + "type": "boolean" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "numberValue": { + "type": "integer" + }, + "textValue": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.ItemOut": { + "type": "object", + "properties": { + "archived": { + "type": "boolean" + }, + "assetId": { + "type": "string", + "example": "0" + }, + "attachments": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemAttachment" + } + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemField" + } + }, + "id": { + "type": "string" + }, + "imageId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "insured": { + "type": "boolean" + }, + "labels": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.LabelSummary" + } + }, + "lifetimeWarranty": { + "description": "Warranty", + "type": "boolean" + }, + "location": { + "description": "Edges", + "allOf": [ + { + "$ref": "#/definitions/repo.LocationSummary" + } + ], + "x-nullable": true, + "x-omitempty": true + }, + "manufacturer": { + "type": "string" + }, + "modelNumber": { + "type": "string" + }, + "name": { + "type": "string" + }, + "notes": { + "description": "Extras", + "type": "string" + }, + "parent": { + "allOf": [ + { + "$ref": "#/definitions/repo.ItemSummary" + } + ], + "x-nullable": true, + "x-omitempty": true + }, + "purchaseFrom": { + "type": "string" + }, + "purchasePrice": { + "type": "number" + }, + "purchaseTime": { + "description": "Purchase", + "type": "string" + }, + "quantity": { + "type": "integer" + }, + "serialNumber": { + "type": "string" + }, + "soldNotes": { + "type": "string" + }, + "soldPrice": { + "type": "number" + }, + "soldTime": { + "description": "Sold", + "type": "string" + }, + "soldTo": { + "type": "string" + }, + "syncChildItemsLocations": { + "type": "boolean" + }, + "thumbnailId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "updatedAt": { + "type": "string" + }, + "warrantyDetails": { + "type": "string" + }, + "warrantyExpires": { + "type": "string" + } + } + }, + "repo.ItemPatch": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "labelIds": { + "type": "array", + "items": { + "type": "string" + }, + "x-nullable": true, + "x-omitempty": true + }, + "locationId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "quantity": { + "type": "integer", + "x-nullable": true, + "x-omitempty": true + } + } + }, + "repo.ItemPath": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "type": { + "$ref": "#/definitions/repo.ItemType" + } + } + }, + "repo.ItemSummary": { + "type": "object", + "properties": { + "archived": { + "type": "boolean" + }, + "assetId": { + "type": "string", + "example": "0" + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "imageId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "insured": { + "type": "boolean" + }, + "labels": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.LabelSummary" + } + }, + "location": { + "description": "Edges", + "allOf": [ + { + "$ref": "#/definitions/repo.LocationSummary" + } + ], + "x-nullable": true, + "x-omitempty": true + }, + "name": { + "type": "string" + }, + "purchasePrice": { + "type": "number" + }, + "quantity": { + "type": "integer" + }, + "soldTime": { + "description": "Sale details", + "type": "string" + }, + "thumbnailId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemTemplateCreate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "defaultDescription": { + "type": "string", + "maxLength": 1000, + "x-nullable": true + }, + "defaultInsured": { + "type": "boolean" + }, + "defaultLabelIds": { + "type": "array", + "items": { + "type": "string" + }, + "x-nullable": true + }, + "defaultLifetimeWarranty": { + "type": "boolean" + }, + "defaultLocationId": { + "description": "Default location and labels", + "type": "string", + "x-nullable": true + }, + "defaultManufacturer": { + "type": "string", + "maxLength": 255, + "x-nullable": true + }, + "defaultModelNumber": { + "type": "string", + "maxLength": 255, + "x-nullable": true + }, + "defaultName": { + "type": "string", + "maxLength": 255, + "x-nullable": true + }, + "defaultQuantity": { + "description": "Default values for items", + "type": "integer", + "x-nullable": true + }, + "defaultWarrantyDetails": { + "type": "string", + "maxLength": 1000, + "x-nullable": true + }, + "description": { + "type": "string", + "maxLength": 1000 + }, + "fields": { + "description": "Custom fields", + "type": "array", + "items": { + "$ref": "#/definitions/repo.TemplateField" + } + }, + "includePurchaseFields": { + "type": "boolean" + }, + "includeSoldFields": { + "type": "boolean" + }, + "includeWarrantyFields": { + "description": "Metadata flags", + "type": "boolean" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "notes": { + "type": "string", + "maxLength": 1000 + } + } + }, + "repo.ItemTemplateOut": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "defaultDescription": { + "type": "string" + }, + "defaultInsured": { + "type": "boolean" + }, + "defaultLabels": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.TemplateLabelSummary" + } + }, + "defaultLifetimeWarranty": { + "type": "boolean" + }, + "defaultLocation": { + "description": "Default location and labels", + "allOf": [ + { + "$ref": "#/definitions/repo.TemplateLocationSummary" + } + ] + }, + "defaultManufacturer": { + "type": "string" + }, + "defaultModelNumber": { + "type": "string" + }, + "defaultName": { + "type": "string" + }, + "defaultQuantity": { + "description": "Default values for items", + "type": "integer" + }, + "defaultWarrantyDetails": { + "type": "string" + }, + "description": { + "type": "string" + }, + "fields": { + "description": "Custom fields", + "type": "array", + "items": { + "$ref": "#/definitions/repo.TemplateField" + } + }, + "id": { + "type": "string" + }, + "includePurchaseFields": { + "type": "boolean" + }, + "includeSoldFields": { + "type": "boolean" + }, + "includeWarrantyFields": { + "description": "Metadata flags", + "type": "boolean" + }, + "name": { + "type": "string" + }, + "notes": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemTemplateSummary": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemTemplateUpdate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "defaultDescription": { + "type": "string", + "maxLength": 1000, + "x-nullable": true + }, + "defaultInsured": { + "type": "boolean" + }, + "defaultLabelIds": { + "type": "array", + "items": { + "type": "string" + }, + "x-nullable": true + }, + "defaultLifetimeWarranty": { + "type": "boolean" + }, + "defaultLocationId": { + "description": "Default location and labels", + "type": "string", + "x-nullable": true + }, + "defaultManufacturer": { + "type": "string", + "maxLength": 255, + "x-nullable": true + }, + "defaultModelNumber": { + "type": "string", + "maxLength": 255, + "x-nullable": true + }, + "defaultName": { + "type": "string", + "maxLength": 255, + "x-nullable": true + }, + "defaultQuantity": { + "description": "Default values for items", + "type": "integer", + "x-nullable": true + }, + "defaultWarrantyDetails": { + "type": "string", + "maxLength": 1000, + "x-nullable": true + }, + "description": { + "type": "string", + "maxLength": 1000 + }, + "fields": { + "description": "Custom fields", + "type": "array", + "items": { + "$ref": "#/definitions/repo.TemplateField" + } + }, + "id": { + "type": "string" + }, + "includePurchaseFields": { + "type": "boolean" + }, + "includeSoldFields": { + "type": "boolean" + }, + "includeWarrantyFields": { + "description": "Metadata flags", + "type": "boolean" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "notes": { + "type": "string", + "maxLength": 1000 + } + } + }, + "repo.ItemType": { + "type": "string", + "enum": [ + "location", + "item" + ], + "x-enum-varnames": [ + "ItemTypeLocation", + "ItemTypeItem" + ] + }, + "repo.ItemUpdate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "archived": { + "type": "boolean" + }, + "assetId": { + "type": "string" + }, + "description": { + "type": "string", + "maxLength": 1000 + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemField" + } + }, + "id": { + "type": "string" + }, + "insured": { + "type": "boolean" + }, + "labelIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "lifetimeWarranty": { + "description": "Warranty", + "type": "boolean" + }, + "locationId": { + "description": "Edges", + "type": "string" + }, + "manufacturer": { + "type": "string" + }, + "modelNumber": { + "type": "string" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "notes": { + "description": "Extras", + "type": "string" + }, + "parentId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "purchaseFrom": { + "type": "string", + "maxLength": 255 + }, + "purchasePrice": { + "type": "number", + "x-nullable": true, + "x-omitempty": true + }, + "purchaseTime": { + "description": "Purchase", + "type": "string" + }, + "quantity": { + "type": "integer" + }, + "serialNumber": { + "description": "Identifications", + "type": "string" + }, + "soldNotes": { + "type": "string" + }, + "soldPrice": { + "type": "number", + "x-nullable": true, + "x-omitempty": true + }, + "soldTime": { + "description": "Sold", + "type": "string" + }, + "soldTo": { + "type": "string", + "maxLength": 255 + }, + "syncChildItemsLocations": { + "type": "boolean" + }, + "warrantyDetails": { + "type": "string" + }, + "warrantyExpires": { + "type": "string" + } + } + }, + "repo.LabelCreate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "color": { + "type": "string" + }, + "description": { + "type": "string", + "maxLength": 1000 + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + } + } + }, + "repo.LabelOut": { + "type": "object", + "properties": { + "color": { + "type": "string" + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.LabelSummary": { + "type": "object", + "properties": { + "color": { + "type": "string" + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.LocationCreate": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "parentId": { + "type": "string", + "x-nullable": true + } + } + }, + "repo.LocationOut": { + "type": "object", + "properties": { + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.LocationSummary" + } + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "parent": { + "$ref": "#/definitions/repo.LocationSummary" + }, + "totalPrice": { + "type": "number" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.LocationOutCount": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "itemCount": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.LocationSummary": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.LocationUpdate": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "parentId": { + "type": "string", + "x-nullable": true + } + } + }, + "repo.MaintenanceEntry": { + "type": "object", + "properties": { + "completedDate": { + "type": "string" + }, + "cost": { + "type": "string", + "example": "0" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "scheduledDate": { + "type": "string" + } + } + }, + "repo.MaintenanceEntryCreate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "completedDate": { + "type": "string" + }, + "cost": { + "type": "string", + "example": "0" + }, + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "scheduledDate": { + "type": "string" + } + } + }, + "repo.MaintenanceEntryUpdate": { + "type": "object", + "properties": { + "completedDate": { + "type": "string" + }, + "cost": { + "type": "string", + "example": "0" + }, + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "scheduledDate": { + "type": "string" + } + } + }, + "repo.MaintenanceEntryWithDetails": { + "type": "object", + "properties": { + "completedDate": { + "type": "string" + }, + "cost": { + "type": "string", + "example": "0" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "itemID": { + "type": "string" + }, + "itemName": { + "type": "string" + }, + "name": { + "type": "string" + }, + "scheduledDate": { + "type": "string" + } + } + }, + "repo.MaintenanceFilterStatus": { + "type": "string", + "enum": [ + "scheduled", + "completed", + "both" + ], + "x-enum-varnames": [ + "MaintenanceFilterStatusScheduled", + "MaintenanceFilterStatusCompleted", + "MaintenanceFilterStatusBoth" + ] + }, + "repo.NotifierCreate": { + "type": "object", + "required": [ + "name", + "url" + ], + "properties": { + "isActive": { + "type": "boolean" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "url": { + "type": "string" + } + } + }, + "repo.NotifierOut": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "groupId": { + "type": "string" + }, + "id": { + "type": "string" + }, + "isActive": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + }, + "url": { + "type": "string" + }, + "userId": { + "type": "string" + } + } + }, + "repo.NotifierUpdate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "isActive": { + "type": "boolean" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "url": { + "type": "string", + "x-nullable": true + } + } + }, + "repo.PaginationResult-repo_ItemSummary": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemSummary" + } + }, + "page": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + }, + "total": { + "type": "integer" + } + } + }, + "repo.TemplateField": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "textValue": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.TemplateLabelSummary": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "repo.TemplateLocationSummary": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "repo.TotalsByOrganizer": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "total": { + "type": "number" + } + } + }, + "repo.TreeItem": { + "type": "object", + "properties": { + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.TreeItem" + } + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.UserOut": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "groupId": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "id": { + "type": "string" + }, + "isOwner": { + "type": "boolean" + }, + "isSuperuser": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "oidcIssuer": { + "type": "string" + }, + "oidcSubject": { + "type": "string" + } + } + }, + "repo.UserUpdate": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "repo.ValueOverTime": { + "type": "object", + "properties": { + "end": { + "type": "string" + }, + "entries": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ValueOverTimeEntry" + } + }, + "start": { + "type": "string" + }, + "valueAtEnd": { + "type": "number" + }, + "valueAtStart": { + "type": "number" + } + } + }, + "repo.ValueOverTimeEntry": { + "type": "object", + "properties": { + "date": { + "type": "string" + }, + "name": { + "type": "string" + }, + "value": { + "type": "number" + } + } + }, + "services.Latest": { + "type": "object", + "properties": { + "date": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, + "services.UserRegistration": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "name": { + "type": "string" + }, + "password": { + "type": "string" + }, + "token": { + "type": "string" + } + } + }, + "templatefield.Type": { + "type": "string", + "enum": [ + "text" + ], + "x-enum-varnames": [ + "TypeText" + ] + }, + "user.Role": { + "type": "string", + "enum": [ + "user", + "user", + "owner" + ], + "x-enum-varnames": [ + "DefaultRole", + "RoleUser", + "RoleOwner" + ] + }, + "v1.APISummary": { + "type": "object", + "properties": { + "allowRegistration": { + "type": "boolean" + }, + "build": { + "$ref": "#/definitions/v1.Build" + }, + "demo": { + "type": "boolean" + }, + "health": { + "type": "boolean" + }, + "labelPrinting": { + "type": "boolean" + }, + "latest": { + "$ref": "#/definitions/services.Latest" + }, + "message": { + "type": "string" + }, + "oidc": { + "$ref": "#/definitions/v1.OIDCStatus" + }, + "title": { + "type": "string" + }, + "versions": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "v1.ActionAmountResult": { + "type": "object", + "properties": { + "completed": { + "type": "integer" + } + } + }, + "v1.Build": { + "type": "object", + "properties": { + "buildTime": { + "type": "string" + }, + "commit": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, + "v1.ChangePassword": { + "type": "object", + "properties": { + "current": { + "type": "string" + }, + "new": { + "type": "string" + } + } + }, + "v1.GroupInvitation": { + "type": "object", + "properties": { + "expiresAt": { + "type": "string" + }, + "token": { + "type": "string" + }, + "uses": { + "type": "integer" + } + } + }, + "v1.GroupInvitationCreate": { + "type": "object", + "required": [ + "uses" + ], + "properties": { + "expiresAt": { + "type": "string" + }, + "uses": { + "type": "integer", + "maximum": 100, + "minimum": 1 + } + } + }, + "v1.ItemAttachmentToken": { + "type": "object", + "properties": { + "token": { + "type": "string" + } + } + }, + "v1.ItemTemplateCreateItemRequest": { + "type": "object", + "required": [ + "locationId", + "name" + ], + "properties": { + "description": { + "type": "string", + "maxLength": 1000 + }, + "labelIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "locationId": { + "type": "string" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "quantity": { + "type": "integer" + } + } + }, + "v1.LoginForm": { + "type": "object", + "properties": { + "password": { + "type": "string", + "example": "admin" + }, + "stayLoggedIn": { + "type": "boolean" + }, + "username": { + "type": "string", + "example": "admin@admin.com" + } + } + }, + "v1.OIDCStatus": { + "type": "object", + "properties": { + "allowLocal": { + "type": "boolean" + }, + "autoRedirect": { + "type": "boolean" + }, + "buttonText": { + "type": "string" + }, + "enabled": { + "type": "boolean" + } + } + }, + "v1.TokenResponse": { + "type": "object", + "properties": { + "attachmentToken": { + "type": "string" + }, + "expiresAt": { + "type": "string" + }, + "token": { + "type": "string" + } + } + }, + "v1.Wrapped": { + "type": "object", + "properties": { + "item": {} + } + }, + "validate.ErrorResponse": { + "type": "object", + "properties": { + "error": { + "type": "string" + }, + "fields": { + "type": "string" + } + } + } + }, + "securityDefinitions": { + "Bearer": { + "description": "\"Type 'Bearer TOKEN' to correctly set the API Key\"", + "type": "apiKey", + "name": "Authorization", + "in": "header" + } + } +}` // SwaggerInfo holds exported Swagger Info so clients can modify it var SwaggerInfo = &swag.Spec{ diff --git a/backend/app/api/static/docs/openapi-3.json b/backend/app/api/static/docs/openapi-3.json index ceb6d5dd..a80a6124 100644 --- a/backend/app/api/static/docs/openapi-3.json +++ b/backend/app/api/static/docs/openapi-3.json @@ -196,456 +196,6 @@ } } }, - "/v1/entities/{id}/attachments": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "Items Attachments" - ], - "summary": "Create Item Attachment", - "parameters": [ - { - "description": "Item ID", - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "$ref": "#/components/requestBodies/postV1Entities_id_attachments" - }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.ItemOut" - } - } - } - }, - "422": { - "description": "Unprocessable Entity", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/validate.ErrorResponse" - } - } - } - } - } - } - }, - "/v1/entities/{id}/attachments/{attachment_id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "Items Attachments" - ], - "summary": "Get Item Attachment", - "parameters": [ - { - "description": "Item ID", - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "description": "Attachment ID", - "name": "attachment_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/octet-stream": { - "schema": { - "$ref": "#/components/schemas/v1.ItemAttachmentToken" - } - } - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "Items Attachments" - ], - "summary": "Update Item Attachment", - "parameters": [ - { - "description": "Item ID", - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "description": "Attachment ID", - "name": "attachment_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "$ref": "#/components/requestBodies/repo.EntityAttachmentUpdate" - }, - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/repo.ItemOut" - } - } - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "Items Attachments" - ], - "summary": "Delete Item Attachment", - "parameters": [ - { - "description": "Item ID", - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "description": "Attachment ID", - "name": "attachment_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "No Content" - } - } - } - }, - "/v1/entities/{id}/maintenance": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "Item Maintenance" - ], - "summary": "Get Maintenance Log", - "parameters": [ - { - "description": "Item ID", - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "x-enum-varnames": [ - "MaintenanceFilterStatusScheduled", - "MaintenanceFilterStatusCompleted", - "MaintenanceFilterStatusBoth" - ], - "name": "status", - "in": "query", - "schema": { - "type": "string", - "enum": [ - "scheduled", - "completed", - "both" - ] - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/repo.MaintenanceEntryWithDetails" - } - } - } - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "Item Maintenance" - ], - "summary": "Create Maintenance Entry", - "parameters": [ - { - "description": "Item ID", - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "$ref": "#/components/requestBodies/repo.MaintenanceEntryCreate" - }, - "responses": { - "201": { - "description": "Created", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.MaintenanceEntry" - } - } - } - } - } - } - }, - "/v1/entitytype": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "EntityTypes" - ], - "summary": "Query All Entity Types", - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/repo.EntityType" - } - } - } - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "EntityTypes" - ], - "summary": "Create Entity Type", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.EntityTypeCreate" - } - } - }, - "description": "Entity Type Data", - "required": true - }, - "responses": { - "201": { - "description": "Created", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.EntityType" - } - } - } - } - } - } - }, - "/v1/entitytype/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "EntityTypes" - ], - "summary": "Get One Entity Type", - "parameters": [ - { - "description": "Entity Type ID", - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.EntityType" - } - } - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "EntityTypes" - ], - "summary": "Update Entity Type", - "parameters": [ - { - "description": "Entity Type ID", - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.EntityTypeUpdate" - } - } - }, - "description": "Entity Type Data", - "required": true - }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.EntityType" - } - } - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "EntityTypes" - ], - "summary": "Delete Entity Type", - "parameters": [ - { - "description": "Entity Type ID", - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.EntityTypeDelete" - } - } - }, - "description": "Entity Type Delete Options", - "required": true - }, - "responses": { - "204": { - "description": "No Content" - } - } - } - }, "/v1/groups": { "get": { "security": [ @@ -875,8 +425,7 @@ "tags": [ "Items" ], - "summary": "(Deprecated) Query All Items", - "deprecated": true, + "summary": "Query All Items", "parameters": [ { "description": "search string", @@ -962,7 +511,6 @@ "Items" ], "summary": "Create Item", - "deprecated": true, "requestBody": { "content": { "application/json": { @@ -998,8 +546,7 @@ "tags": [ "Items" ], - "summary": "(Deprecated) Export Items", - "deprecated": true, + "summary": "Export Items", "responses": { "200": { "description": "text/csv", @@ -1024,8 +571,7 @@ "tags": [ "Items" ], - "summary": "(Deprecated) Get All Custom Field Names", - "deprecated": true, + "summary": "Get All Custom Field Names", "responses": { "200": { "description": "OK", @@ -1053,8 +599,7 @@ "tags": [ "Items" ], - "summary": "(Deprecated) Get All Custom Field Values", - "deprecated": true, + "summary": "Get All Custom Field Values", "responses": { "200": { "description": "OK", @@ -1082,8 +627,7 @@ "tags": [ "Items" ], - "summary": "(Deprecated) Import Items", - "deprecated": true, + "summary": "Import Items", "requestBody": { "content": { "multipart/form-data": { @@ -1121,8 +665,7 @@ "tags": [ "Items" ], - "summary": "(Deprecated) Get Item", - "deprecated": true, + "summary": "Get Item", "parameters": [ { "description": "Item ID", @@ -1156,8 +699,7 @@ "tags": [ "Items" ], - "summary": "(Deprecated) Update Item", - "deprecated": true, + "summary": "Update Item", "parameters": [ { "description": "Item ID", @@ -1202,8 +744,7 @@ "tags": [ "Items" ], - "summary": "(Deprecated) Delete Item", - "deprecated": true, + "summary": "Delete Item", "parameters": [ { "description": "Item ID", @@ -1230,8 +771,7 @@ "tags": [ "Items" ], - "summary": "(Deprecated) Update Item", - "deprecated": true, + "summary": "Update Item", "parameters": [ { "description": "Item ID", @@ -1279,7 +819,6 @@ "Items Attachments" ], "summary": "Create Item Attachment", - "deprecated": true, "parameters": [ { "description": "Item ID", @@ -1292,7 +831,37 @@ } ], "requestBody": { - "$ref": "#/components/requestBodies/postV1Entities_id_attachments" + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "file": { + "description": "File attachment", + "type": "string", + "format": "binary" + }, + "type": { + "description": "Type of file", + "type": "string" + }, + "primary": { + "description": "Is this the primary attachment", + "type": "boolean" + }, + "name": { + "description": "name of the file including extension", + "type": "string" + } + }, + "required": [ + "file", + "name" + ] + } + } + }, + "required": true }, "responses": { "200": { @@ -1329,7 +898,6 @@ "Items Attachments" ], "summary": "Get Item Attachment", - "deprecated": true, "parameters": [ { "description": "Item ID", @@ -1373,7 +941,6 @@ "Items Attachments" ], "summary": "Update Item Attachment", - "deprecated": true, "parameters": [ { "description": "Item ID", @@ -1395,7 +962,15 @@ } ], "requestBody": { - "$ref": "#/components/requestBodies/repo.EntityAttachmentUpdate" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.ItemAttachmentUpdate" + } + } + }, + "description": "Attachment Update", + "required": true }, "responses": { "200": { @@ -1420,7 +995,6 @@ "Items Attachments" ], "summary": "Delete Item Attachment", - "deprecated": true, "parameters": [ { "description": "Item ID", @@ -1506,7 +1080,6 @@ "Item Maintenance" ], "summary": "Get Maintenance Log", - "deprecated": true, "parameters": [ { "description": "Item ID", @@ -1561,7 +1134,6 @@ "Item Maintenance" ], "summary": "Create Maintenance Entry", - "deprecated": true, "parameters": [ { "description": "Item ID", @@ -1574,7 +1146,15 @@ } ], "requestBody": { - "$ref": "#/components/requestBodies/repo.MaintenanceEntryCreate" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.MaintenanceEntryCreate" + } + } + }, + "description": "Entry Data", + "required": true }, "responses": { "201": { @@ -1600,8 +1180,7 @@ "tags": [ "Items" ], - "summary": "(Deprecated) Get the full path of an item", - "deprecated": true, + "summary": "Get the full path of an item", "parameters": [ { "description": "Item ID", @@ -1931,8 +1510,7 @@ "tags": [ "Locations" ], - "summary": "(Deprecated) Get All Locations", - "deprecated": true, + "summary": "Get All Locations", "parameters": [ { "description": "Filter locations with parents", @@ -1968,8 +1546,7 @@ "tags": [ "Locations" ], - "summary": "(Deprecated) Create Location", - "deprecated": true, + "summary": "Create Location", "requestBody": { "content": { "application/json": { @@ -2005,8 +1582,7 @@ "tags": [ "Locations" ], - "summary": "(Deprecated) Get Locations Tree", - "deprecated": true, + "summary": "Get Locations Tree", "parameters": [ { "description": "include items in response tree", @@ -2044,8 +1620,7 @@ "tags": [ "Locations" ], - "summary": "(Deprecated) Get Location", - "deprecated": true, + "summary": "Get Location", "parameters": [ { "description": "Location ID", @@ -2079,8 +1654,7 @@ "tags": [ "Locations" ], - "summary": "(Deprecated) Update Location", - "deprecated": true, + "summary": "Update Location", "parameters": [ { "description": "Location ID", @@ -2125,8 +1699,7 @@ "tags": [ "Locations" ], - "summary": "(Deprecated) Delete Location", - "deprecated": true, + "summary": "Delete Location", "parameters": [ { "description": "Location ID", @@ -2549,6 +2122,223 @@ } } }, + "/v1/templates": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Item Templates" + ], + "summary": "Get All Item Templates", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/repo.ItemTemplateSummary" + } + } + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Item Templates" + ], + "summary": "Create Item Template", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.ItemTemplateCreate" + } + } + }, + "description": "Template Data", + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.ItemTemplateOut" + } + } + } + } + } + } + }, + "/v1/templates/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Item Templates" + ], + "summary": "Get Item Template", + "parameters": [ + { + "description": "Template ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.ItemTemplateOut" + } + } + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Item Templates" + ], + "summary": "Update Item Template", + "parameters": [ + { + "description": "Template ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.ItemTemplateUpdate" + } + } + }, + "description": "Template Data", + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.ItemTemplateOut" + } + } + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Item Templates" + ], + "summary": "Delete Item Template", + "parameters": [ + { + "description": "Template ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/templates/{id}/create-item": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Item Templates" + ], + "summary": "Create Item from Template", + "parameters": [ + { + "description": "Template ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/v1.ItemTemplateCreateItemRequest" + } + } + }, + "description": "Item Data", + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.ItemOut" + } + } + } + } + } + } + }, "/v1/users/change-password": { "put": { "security": [ @@ -2624,6 +2414,52 @@ } } }, + "/v1/users/login/oidc": { + "get": { + "tags": [ + "Authentication" + ], + "summary": "OIDC Login Initiation", + "responses": { + "302": { + "description": "Found" + } + } + } + }, + "/v1/users/login/oidc/callback": { + "get": { + "tags": [ + "Authentication" + ], + "summary": "OIDC Callback Handler", + "parameters": [ + { + "description": "Authorization code", + "name": "code", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "State parameter", + "name": "state", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "302": { + "description": "Found" + } + } + } + }, "/v1/users/logout": { "post": { "security": [ @@ -2681,6 +2517,16 @@ "responses": { "204": { "description": "No Content" + }, + "403": { + "description": "Local login is not enabled", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } } } } @@ -2794,63 +2640,6 @@ } ], "components": { - "requestBodies": { - "postV1Entities_id_attachments": { - "content": { - "multipart/form-data": { - "schema": { - "type": "object", - "properties": { - "file": { - "description": "File attachment", - "type": "string", - "format": "binary" - }, - "type": { - "description": "Type of file", - "type": "string" - }, - "primary": { - "description": "Is this the primary attachment", - "type": "boolean" - }, - "name": { - "description": "name of the file including extension", - "type": "string" - } - }, - "required": [ - "file", - "name" - ] - } - } - }, - "required": true - }, - "repo.MaintenanceEntryCreate": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.MaintenanceEntryCreate" - } - } - }, - "description": "Entry Data", - "required": true - }, - "repo.EntityAttachmentUpdate": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.EntityAttachmentUpdate" - } - } - }, - "description": "Attachment Update", - "required": true - } - }, "securitySchemes": { "Bearer": { "description": "\"Type 'Bearer TOKEN' to correctly set the API Key\"", @@ -2968,11 +2757,11 @@ "ent.AttachmentEdges": { "type": "object", "properties": { - "entity": { - "description": "Entity holds the value of the entity edge.", + "item": { + "description": "Item holds the value of the item edge.", "allOf": [ { - "$ref": "#/components/schemas/ent.Entity" + "$ref": "#/components/schemas/ent.Item" } ] }, @@ -3081,333 +2870,6 @@ } } }, - "ent.Entity": { - "type": "object", - "properties": { - "archived": { - "description": "Archived holds the value of the \"archived\" field.", - "type": "boolean" - }, - "asset_id": { - "description": "AssetID holds the value of the \"asset_id\" field.", - "type": "integer" - }, - "created_at": { - "description": "CreatedAt holds the value of the \"created_at\" field.", - "type": "string" - }, - "description": { - "description": "Description holds the value of the \"description\" field.", - "type": "string" - }, - "edges": { - "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityQuery when eager-loading is set.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.EntityEdges" - } - ] - }, - "id": { - "description": "ID of the ent.", - "type": "string" - }, - "import_ref": { - "description": "ImportRef holds the value of the \"import_ref\" field.", - "type": "string" - }, - "insured": { - "description": "Insured holds the value of the \"insured\" field.", - "type": "boolean" - }, - "lifetime_warranty": { - "description": "LifetimeWarranty holds the value of the \"lifetime_warranty\" field.", - "type": "boolean" - }, - "manufacturer": { - "description": "Manufacturer holds the value of the \"manufacturer\" field.", - "type": "string" - }, - "model_number": { - "description": "ModelNumber holds the value of the \"model_number\" field.", - "type": "string" - }, - "name": { - "description": "Name holds the value of the \"name\" field.", - "type": "string" - }, - "notes": { - "description": "Notes holds the value of the \"notes\" field.", - "type": "string" - }, - "purchase_from": { - "description": "PurchaseFrom holds the value of the \"purchase_from\" field.", - "type": "string" - }, - "purchase_price": { - "description": "PurchasePrice holds the value of the \"purchase_price\" field.", - "type": "number" - }, - "purchase_time": { - "description": "PurchaseTime holds the value of the \"purchase_time\" field.", - "type": "string" - }, - "quantity": { - "description": "Quantity holds the value of the \"quantity\" field.", - "type": "integer" - }, - "serial_number": { - "description": "SerialNumber holds the value of the \"serial_number\" field.", - "type": "string" - }, - "sold_notes": { - "description": "SoldNotes holds the value of the \"sold_notes\" field.", - "type": "string" - }, - "sold_price": { - "description": "SoldPrice holds the value of the \"sold_price\" field.", - "type": "number" - }, - "sold_time": { - "description": "SoldTime holds the value of the \"sold_time\" field.", - "type": "string" - }, - "sold_to": { - "description": "SoldTo holds the value of the \"sold_to\" field.", - "type": "string" - }, - "sync_child_entities_locations": { - "description": "SyncChildEntitiesLocations holds the value of the \"sync_child_entities_locations\" field.", - "type": "boolean" - }, - "updated_at": { - "description": "UpdatedAt holds the value of the \"updated_at\" field.", - "type": "string" - }, - "warranty_details": { - "description": "WarrantyDetails holds the value of the \"warranty_details\" field.", - "type": "string" - }, - "warranty_expires": { - "description": "WarrantyExpires holds the value of the \"warranty_expires\" field.", - "type": "string" - } - } - }, - "ent.EntityEdges": { - "type": "object", - "properties": { - "attachments": { - "description": "Attachments holds the value of the attachments edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.Attachment" - } - }, - "children": { - "description": "Children holds the value of the children edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.Entity" - } - }, - "entity": { - "description": "Entity holds the value of the entity edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.Entity" - } - }, - "fields": { - "description": "Fields holds the value of the fields edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.EntityField" - } - }, - "group": { - "description": "Group holds the value of the group edge.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.Group" - } - ] - }, - "label": { - "description": "Label holds the value of the label edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.Label" - } - }, - "location": { - "description": "Location holds the value of the location edge.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.Entity" - } - ] - }, - "maintenance_entries": { - "description": "MaintenanceEntries holds the value of the maintenance_entries edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.MaintenanceEntry" - } - }, - "parent": { - "description": "Parent holds the value of the parent edge.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.Entity" - } - ] - }, - "type": { - "description": "Type holds the value of the type edge.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.EntityType" - } - ] - } - } - }, - "ent.EntityField": { - "type": "object", - "properties": { - "boolean_value": { - "description": "BooleanValue holds the value of the \"boolean_value\" field.", - "type": "boolean" - }, - "created_at": { - "description": "CreatedAt holds the value of the \"created_at\" field.", - "type": "string" - }, - "description": { - "description": "Description holds the value of the \"description\" field.", - "type": "string" - }, - "edges": { - "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityFieldQuery when eager-loading is set.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.EntityFieldEdges" - } - ] - }, - "id": { - "description": "ID of the ent.", - "type": "string" - }, - "name": { - "description": "Name holds the value of the \"name\" field.", - "type": "string" - }, - "number_value": { - "description": "NumberValue holds the value of the \"number_value\" field.", - "type": "integer" - }, - "text_value": { - "description": "TextValue holds the value of the \"text_value\" field.", - "type": "string" - }, - "time_value": { - "description": "TimeValue holds the value of the \"time_value\" field.", - "type": "string" - }, - "type": { - "description": "Type holds the value of the \"type\" field.", - "allOf": [ - { - "$ref": "#/components/schemas/entityfield.Type" - } - ] - }, - "updated_at": { - "description": "UpdatedAt holds the value of the \"updated_at\" field.", - "type": "string" - } - } - }, - "ent.EntityFieldEdges": { - "type": "object", - "properties": { - "entity": { - "description": "Entity holds the value of the entity edge.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.Entity" - } - ] - } - } - }, - "ent.EntityType": { - "type": "object", - "properties": { - "color": { - "description": "Color holds the value of the \"color\" field.", - "type": "string" - }, - "created_at": { - "description": "CreatedAt holds the value of the \"created_at\" field.", - "type": "string" - }, - "description": { - "description": "Description holds the value of the \"description\" field.", - "type": "string" - }, - "edges": { - "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityTypeQuery when eager-loading is set.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.EntityTypeEdges" - } - ] - }, - "icon": { - "description": "Icon holds the value of the \"icon\" field.", - "type": "string" - }, - "id": { - "description": "ID of the ent.", - "type": "string" - }, - "is_location": { - "description": "IsLocation holds the value of the \"is_location\" field.", - "type": "boolean" - }, - "name": { - "description": "Name holds the value of the \"name\" field.", - "type": "string" - }, - "updated_at": { - "description": "UpdatedAt holds the value of the \"updated_at\" field.", - "type": "string" - } - } - }, - "ent.EntityTypeEdges": { - "type": "object", - "properties": { - "entities": { - "description": "Entities holds the value of the entities edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.Entity" - } - }, - "group": { - "description": "Group holds the value of the group edge.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.Group" - } - ] - } - } - }, "ent.Group": { "type": "object", "properties": { @@ -3444,20 +2906,6 @@ "ent.GroupEdges": { "type": "object", "properties": { - "entities": { - "description": "Entities holds the value of the entities edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.Entity" - } - }, - "entity_types": { - "description": "EntityTypes holds the value of the entity_types edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.EntityType" - } - }, "invitation_tokens": { "description": "InvitationTokens holds the value of the invitation_tokens edge.", "type": "array", @@ -3465,6 +2913,20 @@ "$ref": "#/components/schemas/ent.GroupInvitationToken" } }, + "item_templates": { + "description": "ItemTemplates holds the value of the item_templates edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.ItemTemplate" + } + }, + "items": { + "description": "Items holds the value of the items edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Item" + } + }, "labels": { "description": "Labels holds the value of the labels edge.", "type": "array", @@ -3472,6 +2934,13 @@ "$ref": "#/components/schemas/ent.Label" } }, + "locations": { + "description": "Locations holds the value of the locations edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Location" + } + }, "notifiers": { "description": "Notifiers holds the value of the notifiers edge.", "type": "array", @@ -3541,6 +3010,369 @@ } } }, + "ent.Item": { + "type": "object", + "properties": { + "archived": { + "description": "Archived holds the value of the \"archived\" field.", + "type": "boolean" + }, + "asset_id": { + "description": "AssetID holds the value of the \"asset_id\" field.", + "type": "integer" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.ItemEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "import_ref": { + "description": "ImportRef holds the value of the \"import_ref\" field.", + "type": "string" + }, + "insured": { + "description": "Insured holds the value of the \"insured\" field.", + "type": "boolean" + }, + "lifetime_warranty": { + "description": "LifetimeWarranty holds the value of the \"lifetime_warranty\" field.", + "type": "boolean" + }, + "manufacturer": { + "description": "Manufacturer holds the value of the \"manufacturer\" field.", + "type": "string" + }, + "model_number": { + "description": "ModelNumber holds the value of the \"model_number\" field.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "notes": { + "description": "Notes holds the value of the \"notes\" field.", + "type": "string" + }, + "purchase_from": { + "description": "PurchaseFrom holds the value of the \"purchase_from\" field.", + "type": "string" + }, + "purchase_price": { + "description": "PurchasePrice holds the value of the \"purchase_price\" field.", + "type": "number" + }, + "purchase_time": { + "description": "PurchaseTime holds the value of the \"purchase_time\" field.", + "type": "string" + }, + "quantity": { + "description": "Quantity holds the value of the \"quantity\" field.", + "type": "integer" + }, + "serial_number": { + "description": "SerialNumber holds the value of the \"serial_number\" field.", + "type": "string" + }, + "sold_notes": { + "description": "SoldNotes holds the value of the \"sold_notes\" field.", + "type": "string" + }, + "sold_price": { + "description": "SoldPrice holds the value of the \"sold_price\" field.", + "type": "number" + }, + "sold_time": { + "description": "SoldTime holds the value of the \"sold_time\" field.", + "type": "string" + }, + "sold_to": { + "description": "SoldTo holds the value of the \"sold_to\" field.", + "type": "string" + }, + "sync_child_items_locations": { + "description": "SyncChildItemsLocations holds the value of the \"sync_child_items_locations\" field.", + "type": "boolean" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + }, + "warranty_details": { + "description": "WarrantyDetails holds the value of the \"warranty_details\" field.", + "type": "string" + }, + "warranty_expires": { + "description": "WarrantyExpires holds the value of the \"warranty_expires\" field.", + "type": "string" + } + } + }, + "ent.ItemEdges": { + "type": "object", + "properties": { + "attachments": { + "description": "Attachments holds the value of the attachments edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Attachment" + } + }, + "children": { + "description": "Children holds the value of the children edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Item" + } + }, + "fields": { + "description": "Fields holds the value of the fields edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.ItemField" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.Group" + } + ] + }, + "label": { + "description": "Label holds the value of the label edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Label" + } + }, + "location": { + "description": "Location holds the value of the location edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.Location" + } + ] + }, + "maintenance_entries": { + "description": "MaintenanceEntries holds the value of the maintenance_entries edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.MaintenanceEntry" + } + }, + "parent": { + "description": "Parent holds the value of the parent edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.Item" + } + ] + } + } + }, + "ent.ItemField": { + "type": "object", + "properties": { + "boolean_value": { + "description": "BooleanValue holds the value of the \"boolean_value\" field.", + "type": "boolean" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemFieldQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.ItemFieldEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "number_value": { + "description": "NumberValue holds the value of the \"number_value\" field.", + "type": "integer" + }, + "text_value": { + "description": "TextValue holds the value of the \"text_value\" field.", + "type": "string" + }, + "time_value": { + "description": "TimeValue holds the value of the \"time_value\" field.", + "type": "string" + }, + "type": { + "description": "Type holds the value of the \"type\" field.", + "allOf": [ + { + "$ref": "#/components/schemas/itemfield.Type" + } + ] + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.ItemFieldEdges": { + "type": "object", + "properties": { + "item": { + "description": "Item holds the value of the item edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.Item" + } + ] + } + } + }, + "ent.ItemTemplate": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "default_description": { + "description": "Default description for items created from this template", + "type": "string" + }, + "default_insured": { + "description": "DefaultInsured holds the value of the \"default_insured\" field.", + "type": "boolean" + }, + "default_label_ids": { + "description": "Default label IDs for items created from this template", + "type": "array", + "items": { + "type": "string" + } + }, + "default_lifetime_warranty": { + "description": "DefaultLifetimeWarranty holds the value of the \"default_lifetime_warranty\" field.", + "type": "boolean" + }, + "default_manufacturer": { + "description": "DefaultManufacturer holds the value of the \"default_manufacturer\" field.", + "type": "string" + }, + "default_model_number": { + "description": "Default model number for items created from this template", + "type": "string" + }, + "default_name": { + "description": "Default name template for items (can use placeholders)", + "type": "string" + }, + "default_quantity": { + "description": "DefaultQuantity holds the value of the \"default_quantity\" field.", + "type": "integer" + }, + "default_warranty_details": { + "description": "DefaultWarrantyDetails holds the value of the \"default_warranty_details\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemTemplateQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.ItemTemplateEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "include_purchase_fields": { + "description": "Whether to include purchase fields in items created from this template", + "type": "boolean" + }, + "include_sold_fields": { + "description": "Whether to include sold fields in items created from this template", + "type": "boolean" + }, + "include_warranty_fields": { + "description": "Whether to include warranty fields in items created from this template", + "type": "boolean" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "notes": { + "description": "Notes holds the value of the \"notes\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.ItemTemplateEdges": { + "type": "object", + "properties": { + "fields": { + "description": "Fields holds the value of the fields edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.TemplateField" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.Group" + } + ] + }, + "location": { + "description": "Location holds the value of the location edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.Location" + } + ] + } + } + }, "ent.Label": { "type": "object", "properties": { @@ -3581,11 +3413,64 @@ "ent.LabelEdges": { "type": "object", "properties": { - "entities": { - "description": "Entities holds the value of the entities edge.", + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.Group" + } + ] + }, + "items": { + "description": "Items holds the value of the items edge.", "type": "array", "items": { - "$ref": "#/components/schemas/ent.Entity" + "$ref": "#/components/schemas/ent.Item" + } + } + } + }, + "ent.Location": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LocationQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.LocationEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.LocationEdges": { + "type": "object", + "properties": { + "children": { + "description": "Children holds the value of the children edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Location" } }, "group": { @@ -3595,6 +3480,21 @@ "$ref": "#/components/schemas/ent.Group" } ] + }, + "items": { + "description": "Items holds the value of the items edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Item" + } + }, + "parent": { + "description": "Parent holds the value of the parent edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.Location" + } + ] } } }, @@ -3625,14 +3525,14 @@ } ] }, - "entity_id": { - "description": "EntityID holds the value of the \"entity_id\" field.", - "type": "string" - }, "id": { "description": "ID of the ent.", "type": "string" }, + "item_id": { + "description": "ItemID holds the value of the \"item_id\" field.", + "type": "string" + }, "name": { "description": "Name holds the value of the \"name\" field.", "type": "string" @@ -3650,11 +3550,11 @@ "ent.MaintenanceEntryEdges": { "type": "object", "properties": { - "entity": { - "description": "Entity holds the value of the entity edge.", + "item": { + "description": "Item holds the value of the item edge.", "allOf": [ { - "$ref": "#/components/schemas/ent.Entity" + "$ref": "#/components/schemas/ent.Item" } ] } @@ -3722,6 +3622,64 @@ } } }, + "ent.TemplateField": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the TemplateFieldQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.TemplateFieldEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "text_value": { + "description": "TextValue holds the value of the \"text_value\" field.", + "type": "string" + }, + "type": { + "description": "Type holds the value of the \"type\" field.", + "allOf": [ + { + "$ref": "#/components/schemas/templatefield.Type" + } + ] + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.TemplateFieldEdges": { + "type": "object", + "properties": { + "item_template": { + "description": "ItemTemplate holds the value of the item_template edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.ItemTemplate" + } + ] + } + } + }, "ent.User": { "type": "object", "properties": { @@ -3757,6 +3715,14 @@ "description": "Name holds the value of the \"name\" field.", "type": "string" }, + "oidc_issuer": { + "description": "OidcIssuer holds the value of the \"oidc_issuer\" field.", + "type": "string" + }, + "oidc_subject": { + "description": "OidcSubject holds the value of the \"oidc_subject\" field.", + "type": "string" + }, "role": { "description": "Role holds the value of the \"role\" field.", "allOf": [ @@ -3802,7 +3768,7 @@ } } }, - "entityfield.Type": { + "itemfield.Type": { "type": "string", "enum": [ "text", @@ -3865,122 +3831,6 @@ } } }, - "repo.EntityAttachment": { - "type": "object", - "properties": { - "createdAt": { - "type": "string" - }, - "id": { - "type": "string" - }, - "mimeType": { - "type": "string" - }, - "path": { - "type": "string" - }, - "primary": { - "type": "boolean" - }, - "thumbnail": { - "$ref": "#/components/schemas/ent.Attachment" - }, - "title": { - "type": "string" - }, - "type": { - "type": "string" - }, - "updatedAt": { - "type": "string" - } - } - }, - "repo.EntityAttachmentUpdate": { - "type": "object", - "properties": { - "primary": { - "type": "boolean" - }, - "title": { - "type": "string" - }, - "type": { - "type": "string" - } - } - }, - "repo.EntityType": { - "type": "object", - "properties": { - "color": { - "type": "string" - }, - "description": { - "type": "string" - }, - "icon": { - "type": "string" - }, - "isLocation": { - "type": "boolean" - }, - "name": { - "type": "string" - } - } - }, - "repo.EntityTypeCreate": { - "type": "object", - "required": [ - "isLocation", - "name" - ], - "properties": { - "color": { - "type": "string" - }, - "description": { - "type": "string" - }, - "icon": { - "type": "string" - }, - "isLocation": { - "type": "boolean" - }, - "name": { - "type": "string" - } - } - }, - "repo.EntityTypeDelete": { - "type": "object", - "properties": { - "replacementId": { - "$ref": "#/components/schemas/uuid.NullUUID" - } - } - }, - "repo.EntityTypeUpdate": { - "type": "object", - "properties": { - "color": { - "type": "string" - }, - "description": { - "type": "string" - }, - "icon": { - "type": "string" - }, - "name": { - "type": "string", - "minLength": 1 - } - } - }, "repo.Group": { "type": "object", "properties": { @@ -4035,10 +3885,55 @@ } } }, + "repo.ItemAttachment": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "id": { + "type": "string" + }, + "mimeType": { + "type": "string" + }, + "path": { + "type": "string" + }, + "primary": { + "type": "boolean" + }, + "thumbnail": { + "$ref": "#/components/schemas/ent.Attachment" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemAttachmentUpdate": { + "type": "object", + "properties": { + "primary": { + "type": "boolean" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, "repo.ItemCreate": { "type": "object", "required": [ - "entityType", "name" ], "properties": { @@ -4046,9 +3941,6 @@ "type": "string", "maxLength": 1000 }, - "entityType": { - "type": "string" - }, "labelIds": { "type": "array", "items": { @@ -4109,7 +4001,7 @@ "attachments": { "type": "array", "items": { - "$ref": "#/components/schemas/repo.EntityAttachment" + "$ref": "#/components/schemas/repo.ItemAttachment" } }, "createdAt": { @@ -4118,9 +4010,6 @@ "description": { "type": "string" }, - "entityType": { - "type": "string" - }, "fields": { "type": "array", "items": { @@ -4284,9 +4173,6 @@ "description": { "type": "string" }, - "entityType": { - "type": "string" - }, "id": { "type": "string" }, @@ -4337,17 +4223,287 @@ } } }, + "repo.ItemTemplateCreate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "defaultDescription": { + "type": "string", + "maxLength": 1000, + "nullable": true + }, + "defaultInsured": { + "type": "boolean" + }, + "defaultLabelIds": { + "type": "array", + "items": { + "type": "string" + }, + "nullable": true + }, + "defaultLifetimeWarranty": { + "type": "boolean" + }, + "defaultLocationId": { + "description": "Default location and labels", + "type": "string", + "nullable": true + }, + "defaultManufacturer": { + "type": "string", + "maxLength": 255, + "nullable": true + }, + "defaultModelNumber": { + "type": "string", + "maxLength": 255, + "nullable": true + }, + "defaultName": { + "type": "string", + "maxLength": 255, + "nullable": true + }, + "defaultQuantity": { + "description": "Default values for items", + "type": "integer", + "nullable": true + }, + "defaultWarrantyDetails": { + "type": "string", + "maxLength": 1000, + "nullable": true + }, + "description": { + "type": "string", + "maxLength": 1000 + }, + "fields": { + "description": "Custom fields", + "type": "array", + "items": { + "$ref": "#/components/schemas/repo.TemplateField" + } + }, + "includePurchaseFields": { + "type": "boolean" + }, + "includeSoldFields": { + "type": "boolean" + }, + "includeWarrantyFields": { + "description": "Metadata flags", + "type": "boolean" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "notes": { + "type": "string", + "maxLength": 1000 + } + } + }, + "repo.ItemTemplateOut": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "defaultDescription": { + "type": "string" + }, + "defaultInsured": { + "type": "boolean" + }, + "defaultLabels": { + "type": "array", + "items": { + "$ref": "#/components/schemas/repo.TemplateLabelSummary" + } + }, + "defaultLifetimeWarranty": { + "type": "boolean" + }, + "defaultLocation": { + "description": "Default location and labels", + "allOf": [ + { + "$ref": "#/components/schemas/repo.TemplateLocationSummary" + } + ] + }, + "defaultManufacturer": { + "type": "string" + }, + "defaultModelNumber": { + "type": "string" + }, + "defaultName": { + "type": "string" + }, + "defaultQuantity": { + "description": "Default values for items", + "type": "integer" + }, + "defaultWarrantyDetails": { + "type": "string" + }, + "description": { + "type": "string" + }, + "fields": { + "description": "Custom fields", + "type": "array", + "items": { + "$ref": "#/components/schemas/repo.TemplateField" + } + }, + "id": { + "type": "string" + }, + "includePurchaseFields": { + "type": "boolean" + }, + "includeSoldFields": { + "type": "boolean" + }, + "includeWarrantyFields": { + "description": "Metadata flags", + "type": "boolean" + }, + "name": { + "type": "string" + }, + "notes": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemTemplateSummary": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemTemplateUpdate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "defaultDescription": { + "type": "string", + "maxLength": 1000, + "nullable": true + }, + "defaultInsured": { + "type": "boolean" + }, + "defaultLabelIds": { + "type": "array", + "items": { + "type": "string" + }, + "nullable": true + }, + "defaultLifetimeWarranty": { + "type": "boolean" + }, + "defaultLocationId": { + "description": "Default location and labels", + "type": "string", + "nullable": true + }, + "defaultManufacturer": { + "type": "string", + "maxLength": 255, + "nullable": true + }, + "defaultModelNumber": { + "type": "string", + "maxLength": 255, + "nullable": true + }, + "defaultName": { + "type": "string", + "maxLength": 255, + "nullable": true + }, + "defaultQuantity": { + "description": "Default values for items", + "type": "integer", + "nullable": true + }, + "defaultWarrantyDetails": { + "type": "string", + "maxLength": 1000, + "nullable": true + }, + "description": { + "type": "string", + "maxLength": 1000 + }, + "fields": { + "description": "Custom fields", + "type": "array", + "items": { + "$ref": "#/components/schemas/repo.TemplateField" + } + }, + "id": { + "type": "string" + }, + "includePurchaseFields": { + "type": "boolean" + }, + "includeSoldFields": { + "type": "boolean" + }, + "includeWarrantyFields": { + "description": "Metadata flags", + "type": "boolean" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "notes": { + "type": "string", + "maxLength": 1000 + } + } + }, "repo.ItemType": { "type": "string", "enum": [ - "location", - "item", "location", "item" ], "x-enum-varnames": [ - "EntityTypeLocation", - "EntityTypeItem", "ItemTypeLocation", "ItemTypeItem" ] @@ -4355,7 +4511,6 @@ "repo.ItemUpdate": { "type": "object", "required": [ - "entityType", "name" ], "properties": { @@ -4369,9 +4524,6 @@ "type": "string", "maxLength": 1000 }, - "entityType": { - "type": "string" - }, "fields": { "type": "array", "items": { @@ -4533,16 +4685,10 @@ }, "repo.LocationCreate": { "type": "object", - "required": [ - "entityType" - ], "properties": { "description": { "type": "string" }, - "entityType": { - "type": "string" - }, "name": { "type": "string" }, @@ -4567,9 +4713,6 @@ "description": { "type": "string" }, - "entityType": { - "type": "string" - }, "id": { "type": "string" }, @@ -4596,9 +4739,6 @@ "description": { "type": "string" }, - "entityType": { - "type": "string" - }, "id": { "type": "string" }, @@ -4622,9 +4762,6 @@ "description": { "type": "string" }, - "entityType": { - "type": "string" - }, "id": { "type": "string" }, @@ -4638,16 +4775,10 @@ }, "repo.LocationUpdate": { "type": "object", - "required": [ - "entityType" - ], "properties": { "description": { "type": "string" }, - "entityType": { - "type": "string" - }, "id": { "type": "string" }, @@ -4861,6 +4992,45 @@ } } }, + "repo.TemplateField": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "textValue": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.TemplateLabelSummary": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "repo.TemplateLocationSummary": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, "repo.TotalsByOrganizer": { "type": "object", "properties": { @@ -4918,6 +5088,12 @@ }, "name": { "type": "string" + }, + "oidcIssuer": { + "type": "string" + }, + "oidcSubject": { + "type": "string" } } }, @@ -4997,6 +5173,15 @@ } } }, + "templatefield.Type": { + "type": "string", + "enum": [ + "text" + ], + "x-enum-varnames": [ + "TypeText" + ] + }, "user.Role": { "type": "string", "enum": [ @@ -5010,18 +5195,6 @@ "RoleOwner" ] }, - "uuid.NullUUID": { - "type": "object", - "properties": { - "uuid": { - "type": "string" - }, - "valid": { - "description": "Valid is true if UUID is not NULL", - "type": "boolean" - } - } - }, "v1.APISummary": { "type": "object", "properties": { @@ -5046,6 +5219,9 @@ "message": { "type": "string" }, + "oidc": { + "$ref": "#/components/schemas/v1.OIDCStatus" + }, "title": { "type": "string" }, @@ -5128,6 +5304,36 @@ } } }, + "v1.ItemTemplateCreateItemRequest": { + "type": "object", + "required": [ + "locationId", + "name" + ], + "properties": { + "description": { + "type": "string", + "maxLength": 1000 + }, + "labelIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "locationId": { + "type": "string" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "quantity": { + "type": "integer" + } + } + }, "v1.LoginForm": { "type": "object", "properties": { @@ -5144,6 +5350,23 @@ } } }, + "v1.OIDCStatus": { + "type": "object", + "properties": { + "allowLocal": { + "type": "boolean" + }, + "autoRedirect": { + "type": "boolean" + }, + "buttonText": { + "type": "string" + }, + "enabled": { + "type": "boolean" + } + } + }, "v1.TokenResponse": { "type": "object", "properties": { diff --git a/backend/app/api/static/docs/openapi-3.yaml b/backend/app/api/static/docs/openapi-3.yaml index baf6ad7f..0a6d2042 100644 --- a/backend/app/api/static/docs/openapi-3.yaml +++ b/backend/app/api/static/docs/openapi-3.yaml @@ -115,276 +115,6 @@ paths: application/json: schema: $ref: "#/components/schemas/currencies.Currency" - "/v1/entities/{id}/attachments": - post: - security: - - Bearer: [] - tags: - - Items Attachments - summary: Create Item Attachment - parameters: - - description: Item ID - name: id - in: path - required: true - schema: - type: string - requestBody: - $ref: "#/components/requestBodies/postV1Entities_id_attachments" - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/repo.ItemOut" - "422": - description: Unprocessable Entity - content: - application/json: - schema: - $ref: "#/components/schemas/validate.ErrorResponse" - "/v1/entities/{id}/attachments/{attachment_id}": - get: - security: - - Bearer: [] - tags: - - Items Attachments - summary: Get Item Attachment - parameters: - - description: Item ID - name: id - in: path - required: true - schema: - type: string - - description: Attachment ID - name: attachment_id - in: path - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/octet-stream: - schema: - $ref: "#/components/schemas/v1.ItemAttachmentToken" - put: - security: - - Bearer: [] - tags: - - Items Attachments - summary: Update Item Attachment - parameters: - - description: Item ID - name: id - in: path - required: true - schema: - type: string - - description: Attachment ID - name: attachment_id - in: path - required: true - schema: - type: string - requestBody: - $ref: "#/components/requestBodies/repo.EntityAttachmentUpdate" - responses: - "200": - description: OK - content: - "*/*": - schema: - $ref: "#/components/schemas/repo.ItemOut" - delete: - security: - - Bearer: [] - tags: - - Items Attachments - summary: Delete Item Attachment - parameters: - - description: Item ID - name: id - in: path - required: true - schema: - type: string - - description: Attachment ID - name: attachment_id - in: path - required: true - schema: - type: string - responses: - "204": - description: No Content - "/v1/entities/{id}/maintenance": - get: - security: - - Bearer: [] - tags: - - Item Maintenance - summary: Get Maintenance Log - parameters: - - description: Item ID - name: id - in: path - required: true - schema: - type: string - - x-enum-varnames: - - MaintenanceFilterStatusScheduled - - MaintenanceFilterStatusCompleted - - MaintenanceFilterStatusBoth - name: status - in: query - schema: - type: string - enum: - - scheduled - - completed - - both - responses: - "200": - description: OK - content: - application/json: - schema: - type: array - items: - $ref: "#/components/schemas/repo.MaintenanceEntryWithDetails" - post: - security: - - Bearer: [] - tags: - - Item Maintenance - summary: Create Maintenance Entry - parameters: - - description: Item ID - name: id - in: path - required: true - schema: - type: string - requestBody: - $ref: "#/components/requestBodies/repo.MaintenanceEntryCreate" - responses: - "201": - description: Created - content: - application/json: - schema: - $ref: "#/components/schemas/repo.MaintenanceEntry" - /v1/entitytype: - get: - security: - - Bearer: [] - tags: - - EntityTypes - summary: Query All Entity Types - responses: - "200": - description: OK - content: - application/json: - schema: - type: array - items: - $ref: "#/components/schemas/repo.EntityType" - post: - security: - - Bearer: [] - tags: - - EntityTypes - summary: Create Entity Type - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/repo.EntityTypeCreate" - description: Entity Type Data - required: true - responses: - "201": - description: Created - content: - application/json: - schema: - $ref: "#/components/schemas/repo.EntityType" - "/v1/entitytype/{id}": - get: - security: - - Bearer: [] - tags: - - EntityTypes - summary: Get One Entity Type - parameters: - - description: Entity Type ID - name: id - in: path - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/repo.EntityType" - put: - security: - - Bearer: [] - tags: - - EntityTypes - summary: Update Entity Type - parameters: - - description: Entity Type ID - name: id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/repo.EntityTypeUpdate" - description: Entity Type Data - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/repo.EntityType" - delete: - security: - - Bearer: [] - tags: - - EntityTypes - summary: Delete Entity Type - parameters: - - description: Entity Type ID - name: id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/repo.EntityTypeDelete" - description: Entity Type Delete Options - required: true - responses: - "204": - description: No Content /v1/groups: get: security: @@ -517,8 +247,7 @@ paths: - Bearer: [] tags: - Items - summary: (Deprecated) Query All Items - deprecated: true + summary: Query All Items parameters: - description: search string name: q @@ -572,7 +301,6 @@ paths: tags: - Items summary: Create Item - deprecated: true requestBody: content: application/json: @@ -593,8 +321,7 @@ paths: - Bearer: [] tags: - Items - summary: (Deprecated) Export Items - deprecated: true + summary: Export Items responses: "200": description: text/csv @@ -608,8 +335,7 @@ paths: - Bearer: [] tags: - Items - summary: (Deprecated) Get All Custom Field Names - deprecated: true + summary: Get All Custom Field Names responses: "200": description: OK @@ -625,8 +351,7 @@ paths: - Bearer: [] tags: - Items - summary: (Deprecated) Get All Custom Field Values - deprecated: true + summary: Get All Custom Field Values responses: "200": description: OK @@ -642,8 +367,7 @@ paths: - Bearer: [] tags: - Items - summary: (Deprecated) Import Items - deprecated: true + summary: Import Items requestBody: content: multipart/form-data: @@ -666,8 +390,7 @@ paths: - Bearer: [] tags: - Items - summary: (Deprecated) Get Item - deprecated: true + summary: Get Item parameters: - description: Item ID name: id @@ -687,8 +410,7 @@ paths: - Bearer: [] tags: - Items - summary: (Deprecated) Update Item - deprecated: true + summary: Update Item parameters: - description: Item ID name: id @@ -715,8 +437,7 @@ paths: - Bearer: [] tags: - Items - summary: (Deprecated) Delete Item - deprecated: true + summary: Delete Item parameters: - description: Item ID name: id @@ -732,8 +453,7 @@ paths: - Bearer: [] tags: - Items - summary: (Deprecated) Update Item - deprecated: true + summary: Update Item parameters: - description: Item ID name: id @@ -762,7 +482,6 @@ paths: tags: - Items Attachments summary: Create Item Attachment - deprecated: true parameters: - description: Item ID name: id @@ -771,7 +490,28 @@ paths: schema: type: string requestBody: - $ref: "#/components/requestBodies/postV1Entities_id_attachments" + content: + multipart/form-data: + schema: + type: object + properties: + file: + description: File attachment + type: string + format: binary + type: + description: Type of file + type: string + primary: + description: Is this the primary attachment + type: boolean + name: + description: name of the file including extension + type: string + required: + - file + - name + required: true responses: "200": description: OK @@ -792,7 +532,6 @@ paths: tags: - Items Attachments summary: Get Item Attachment - deprecated: true parameters: - description: Item ID name: id @@ -819,7 +558,6 @@ paths: tags: - Items Attachments summary: Update Item Attachment - deprecated: true parameters: - description: Item ID name: id @@ -834,7 +572,12 @@ paths: schema: type: string requestBody: - $ref: "#/components/requestBodies/repo.EntityAttachmentUpdate" + content: + application/json: + schema: + $ref: "#/components/schemas/repo.ItemAttachmentUpdate" + description: Attachment Update + required: true responses: "200": description: OK @@ -848,7 +591,6 @@ paths: tags: - Items Attachments summary: Delete Item Attachment - deprecated: true parameters: - description: Item ID name: id @@ -900,7 +642,6 @@ paths: tags: - Item Maintenance summary: Get Maintenance Log - deprecated: true parameters: - description: Item ID name: id @@ -935,7 +676,6 @@ paths: tags: - Item Maintenance summary: Create Maintenance Entry - deprecated: true parameters: - description: Item ID name: id @@ -944,7 +684,12 @@ paths: schema: type: string requestBody: - $ref: "#/components/requestBodies/repo.MaintenanceEntryCreate" + content: + application/json: + schema: + $ref: "#/components/schemas/repo.MaintenanceEntryCreate" + description: Entry Data + required: true responses: "201": description: Created @@ -958,8 +703,7 @@ paths: - Bearer: [] tags: - Items - summary: (Deprecated) Get the full path of an item - deprecated: true + summary: Get the full path of an item parameters: - description: Item ID name: id @@ -1153,8 +897,7 @@ paths: - Bearer: [] tags: - Locations - summary: (Deprecated) Get All Locations - deprecated: true + summary: Get All Locations parameters: - description: Filter locations with parents name: filterChildren @@ -1175,8 +918,7 @@ paths: - Bearer: [] tags: - Locations - summary: (Deprecated) Create Location - deprecated: true + summary: Create Location requestBody: content: application/json: @@ -1197,8 +939,7 @@ paths: - Bearer: [] tags: - Locations - summary: (Deprecated) Get Locations Tree - deprecated: true + summary: Get Locations Tree parameters: - description: include items in response tree name: withItems @@ -1220,8 +961,7 @@ paths: - Bearer: [] tags: - Locations - summary: (Deprecated) Get Location - deprecated: true + summary: Get Location parameters: - description: Location ID name: id @@ -1241,8 +981,7 @@ paths: - Bearer: [] tags: - Locations - summary: (Deprecated) Update Location - deprecated: true + summary: Update Location parameters: - description: Location ID name: id @@ -1269,8 +1008,7 @@ paths: - Bearer: [] tags: - Locations - summary: (Deprecated) Delete Location - deprecated: true + summary: Delete Location parameters: - description: Location ID name: id @@ -1519,6 +1257,134 @@ paths: application/json: schema: $ref: "#/components/schemas/v1.APISummary" + /v1/templates: + get: + security: + - Bearer: [] + tags: + - Item Templates + summary: Get All Item Templates + responses: + "200": + description: OK + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/repo.ItemTemplateSummary" + post: + security: + - Bearer: [] + tags: + - Item Templates + summary: Create Item Template + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/repo.ItemTemplateCreate" + description: Template Data + required: true + responses: + "201": + description: Created + content: + application/json: + schema: + $ref: "#/components/schemas/repo.ItemTemplateOut" + "/v1/templates/{id}": + get: + security: + - Bearer: [] + tags: + - Item Templates + summary: Get Item Template + parameters: + - description: Template ID + name: id + in: path + required: true + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/repo.ItemTemplateOut" + put: + security: + - Bearer: [] + tags: + - Item Templates + summary: Update Item Template + parameters: + - description: Template ID + name: id + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/repo.ItemTemplateUpdate" + description: Template Data + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/repo.ItemTemplateOut" + delete: + security: + - Bearer: [] + tags: + - Item Templates + summary: Delete Item Template + parameters: + - description: Template ID + name: id + in: path + required: true + schema: + type: string + responses: + "204": + description: No Content + "/v1/templates/{id}/create-item": + post: + security: + - Bearer: [] + tags: + - Item Templates + summary: Create Item from Template + parameters: + - description: Template ID + name: id + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/v1.ItemTemplateCreateItemRequest" + description: Item Data + required: true + responses: + "201": + description: Created + content: + application/json: + schema: + $ref: "#/components/schemas/repo.ItemOut" /v1/users/change-password: put: security: @@ -1564,6 +1430,35 @@ paths: application/json: schema: $ref: "#/components/schemas/v1.TokenResponse" + /v1/users/login/oidc: + get: + tags: + - Authentication + summary: OIDC Login Initiation + responses: + "302": + description: Found + /v1/users/login/oidc/callback: + get: + tags: + - Authentication + summary: OIDC Callback Handler + parameters: + - description: Authorization code + name: code + in: query + required: true + schema: + type: string + - description: State parameter + name: state + in: query + required: true + schema: + type: string + responses: + "302": + description: Found /v1/users/logout: post: security: @@ -1604,6 +1499,12 @@ paths: responses: "204": description: No Content + "403": + description: Local login is not enabled + content: + application/json: + schema: + type: string /v1/users/self: get: security: @@ -1661,44 +1562,6 @@ servers: - url: https://demo.homebox.software/api - url: http://demo.homebox.software/api components: - requestBodies: - postV1Entities_id_attachments: - content: - multipart/form-data: - schema: - type: object - properties: - file: - description: File attachment - type: string - format: binary - type: - description: Type of file - type: string - primary: - description: Is this the primary attachment - type: boolean - name: - description: name of the file including extension - type: string - required: - - file - - name - required: true - repo.MaintenanceEntryCreate: - content: - application/json: - schema: - $ref: "#/components/schemas/repo.MaintenanceEntryCreate" - description: Entry Data - required: true - repo.EntityAttachmentUpdate: - content: - application/json: - schema: - $ref: "#/components/schemas/repo.EntityAttachmentUpdate" - description: Attachment Update - required: true securitySchemes: Bearer: description: "\"Type 'Bearer TOKEN' to correctly set the API Key\"" @@ -1787,10 +1650,10 @@ components: ent.AttachmentEdges: type: object properties: - entity: - description: Entity holds the value of the entity edge. + item: + description: Item holds the value of the item edge. allOf: - - $ref: "#/components/schemas/ent.Entity" + - $ref: "#/components/schemas/ent.Item" thumbnail: description: Thumbnail holds the value of the thumbnail edge. allOf: @@ -1857,7 +1720,107 @@ components: description: User holds the value of the user edge. allOf: - $ref: "#/components/schemas/ent.User" - ent.Entity: + ent.Group: + type: object + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + currency: + description: Currency holds the value of the "currency" field. + type: string + edges: + description: >- + Edges holds the relations/edges for other nodes in the graph. + + The values are being populated by the GroupQuery when eager-loading is set. + allOf: + - $ref: "#/components/schemas/ent.GroupEdges" + id: + description: ID of the ent. + type: string + name: + description: Name holds the value of the "name" field. + type: string + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + ent.GroupEdges: + type: object + properties: + invitation_tokens: + description: InvitationTokens holds the value of the invitation_tokens edge. + type: array + items: + $ref: "#/components/schemas/ent.GroupInvitationToken" + item_templates: + description: ItemTemplates holds the value of the item_templates edge. + type: array + items: + $ref: "#/components/schemas/ent.ItemTemplate" + items: + description: Items holds the value of the items edge. + type: array + items: + $ref: "#/components/schemas/ent.Item" + labels: + description: Labels holds the value of the labels edge. + type: array + items: + $ref: "#/components/schemas/ent.Label" + locations: + description: Locations holds the value of the locations edge. + type: array + items: + $ref: "#/components/schemas/ent.Location" + notifiers: + description: Notifiers holds the value of the notifiers edge. + type: array + items: + $ref: "#/components/schemas/ent.Notifier" + users: + description: Users holds the value of the users edge. + type: array + items: + $ref: "#/components/schemas/ent.User" + ent.GroupInvitationToken: + type: object + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + edges: + description: >- + Edges holds the relations/edges for other nodes in the graph. + + The values are being populated by the GroupInvitationTokenQuery when eager-loading is set. + allOf: + - $ref: "#/components/schemas/ent.GroupInvitationTokenEdges" + expires_at: + description: ExpiresAt holds the value of the "expires_at" field. + type: string + id: + description: ID of the ent. + type: string + token: + description: Token holds the value of the "token" field. + type: array + items: + type: integer + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + uses: + description: Uses holds the value of the "uses" field. + type: integer + ent.GroupInvitationTokenEdges: + type: object + properties: + group: + description: Group holds the value of the group edge. + allOf: + - $ref: "#/components/schemas/ent.Group" + ent.Item: type: object properties: archived: @@ -1876,9 +1839,9 @@ components: description: >- Edges holds the relations/edges for other nodes in the graph. - The values are being populated by the EntityQuery when eager-loading is set. + The values are being populated by the ItemQuery when eager-loading is set. allOf: - - $ref: "#/components/schemas/ent.EntityEdges" + - $ref: "#/components/schemas/ent.ItemEdges" id: description: ID of the ent. type: string @@ -1930,9 +1893,9 @@ components: sold_to: description: SoldTo holds the value of the "sold_to" field. type: string - sync_child_entities_locations: - description: SyncChildEntitiesLocations holds the value of the - "sync_child_entities_locations" field. + sync_child_items_locations: + description: SyncChildItemsLocations holds the value of the + "sync_child_items_locations" field. type: boolean updated_at: description: UpdatedAt holds the value of the "updated_at" field. @@ -1943,7 +1906,7 @@ components: warranty_expires: description: WarrantyExpires holds the value of the "warranty_expires" field. type: string - ent.EntityEdges: + ent.ItemEdges: type: object properties: attachments: @@ -1955,17 +1918,12 @@ components: description: Children holds the value of the children edge. type: array items: - $ref: "#/components/schemas/ent.Entity" - entity: - description: Entity holds the value of the entity edge. - type: array - items: - $ref: "#/components/schemas/ent.Entity" + $ref: "#/components/schemas/ent.Item" fields: description: Fields holds the value of the fields edge. type: array items: - $ref: "#/components/schemas/ent.EntityField" + $ref: "#/components/schemas/ent.ItemField" group: description: Group holds the value of the group edge. allOf: @@ -1978,7 +1936,7 @@ components: location: description: Location holds the value of the location edge. allOf: - - $ref: "#/components/schemas/ent.Entity" + - $ref: "#/components/schemas/ent.Location" maintenance_entries: description: MaintenanceEntries holds the value of the maintenance_entries edge. type: array @@ -1987,12 +1945,8 @@ components: parent: description: Parent holds the value of the parent edge. allOf: - - $ref: "#/components/schemas/ent.Entity" - type: - description: Type holds the value of the type edge. - allOf: - - $ref: "#/components/schemas/ent.EntityType" - ent.EntityField: + - $ref: "#/components/schemas/ent.Item" + ent.ItemField: type: object properties: boolean_value: @@ -2008,9 +1962,9 @@ components: description: >- Edges holds the relations/edges for other nodes in the graph. - The values are being populated by the EntityFieldQuery when eager-loading is set. + The values are being populated by the ItemFieldQuery when eager-loading is set. allOf: - - $ref: "#/components/schemas/ent.EntityFieldEdges" + - $ref: "#/components/schemas/ent.ItemFieldEdges" id: description: ID of the ent. type: string @@ -2029,26 +1983,55 @@ components: type: description: Type holds the value of the "type" field. allOf: - - $ref: "#/components/schemas/entityfield.Type" + - $ref: "#/components/schemas/itemfield.Type" updated_at: description: UpdatedAt holds the value of the "updated_at" field. type: string - ent.EntityFieldEdges: + ent.ItemFieldEdges: type: object properties: - entity: - description: Entity holds the value of the entity edge. + item: + description: Item holds the value of the item edge. allOf: - - $ref: "#/components/schemas/ent.Entity" - ent.EntityType: + - $ref: "#/components/schemas/ent.Item" + ent.ItemTemplate: type: object properties: - color: - description: Color holds the value of the "color" field. - type: string created_at: description: CreatedAt holds the value of the "created_at" field. type: string + default_description: + description: Default description for items created from this template + type: string + default_insured: + description: DefaultInsured holds the value of the "default_insured" field. + type: boolean + default_label_ids: + description: Default label IDs for items created from this template + type: array + items: + type: string + default_lifetime_warranty: + description: DefaultLifetimeWarranty holds the value of the + "default_lifetime_warranty" field. + type: boolean + default_manufacturer: + description: DefaultManufacturer holds the value of the "default_manufacturer" + field. + type: string + default_model_number: + description: Default model number for items created from this template + type: string + default_name: + description: Default name template for items (can use placeholders) + type: string + default_quantity: + description: DefaultQuantity holds the value of the "default_quantity" field. + type: integer + default_warranty_details: + description: DefaultWarrantyDetails holds the value of the + "default_warranty_details" field. + type: string description: description: Description holds the value of the "description" field. type: string @@ -2056,131 +2039,48 @@ components: description: >- Edges holds the relations/edges for other nodes in the graph. - The values are being populated by the EntityTypeQuery when eager-loading is set. + The values are being populated by the ItemTemplateQuery when eager-loading is set. allOf: - - $ref: "#/components/schemas/ent.EntityTypeEdges" - icon: - description: Icon holds the value of the "icon" field. - type: string + - $ref: "#/components/schemas/ent.ItemTemplateEdges" id: description: ID of the ent. type: string - is_location: - description: IsLocation holds the value of the "is_location" field. + include_purchase_fields: + description: Whether to include purchase fields in items created from this + template + type: boolean + include_sold_fields: + description: Whether to include sold fields in items created from this template + type: boolean + include_warranty_fields: + description: Whether to include warranty fields in items created from this + template type: boolean name: description: Name holds the value of the "name" field. type: string + notes: + description: Notes holds the value of the "notes" field. + type: string updated_at: description: UpdatedAt holds the value of the "updated_at" field. type: string - ent.EntityTypeEdges: + ent.ItemTemplateEdges: type: object properties: - entities: - description: Entities holds the value of the entities edge. + fields: + description: Fields holds the value of the fields edge. type: array items: - $ref: "#/components/schemas/ent.Entity" + $ref: "#/components/schemas/ent.TemplateField" group: description: Group holds the value of the group edge. allOf: - $ref: "#/components/schemas/ent.Group" - ent.Group: - type: object - properties: - created_at: - description: CreatedAt holds the value of the "created_at" field. - type: string - currency: - description: Currency holds the value of the "currency" field. - type: string - edges: - description: >- - Edges holds the relations/edges for other nodes in the graph. - - The values are being populated by the GroupQuery when eager-loading is set. + location: + description: Location holds the value of the location edge. allOf: - - $ref: "#/components/schemas/ent.GroupEdges" - id: - description: ID of the ent. - type: string - name: - description: Name holds the value of the "name" field. - type: string - updated_at: - description: UpdatedAt holds the value of the "updated_at" field. - type: string - ent.GroupEdges: - type: object - properties: - entities: - description: Entities holds the value of the entities edge. - type: array - items: - $ref: "#/components/schemas/ent.Entity" - entity_types: - description: EntityTypes holds the value of the entity_types edge. - type: array - items: - $ref: "#/components/schemas/ent.EntityType" - invitation_tokens: - description: InvitationTokens holds the value of the invitation_tokens edge. - type: array - items: - $ref: "#/components/schemas/ent.GroupInvitationToken" - labels: - description: Labels holds the value of the labels edge. - type: array - items: - $ref: "#/components/schemas/ent.Label" - notifiers: - description: Notifiers holds the value of the notifiers edge. - type: array - items: - $ref: "#/components/schemas/ent.Notifier" - users: - description: Users holds the value of the users edge. - type: array - items: - $ref: "#/components/schemas/ent.User" - ent.GroupInvitationToken: - type: object - properties: - created_at: - description: CreatedAt holds the value of the "created_at" field. - type: string - edges: - description: >- - Edges holds the relations/edges for other nodes in the graph. - - The values are being populated by the GroupInvitationTokenQuery when eager-loading is set. - allOf: - - $ref: "#/components/schemas/ent.GroupInvitationTokenEdges" - expires_at: - description: ExpiresAt holds the value of the "expires_at" field. - type: string - id: - description: ID of the ent. - type: string - token: - description: Token holds the value of the "token" field. - type: array - items: - type: integer - updated_at: - description: UpdatedAt holds the value of the "updated_at" field. - type: string - uses: - description: Uses holds the value of the "uses" field. - type: integer - ent.GroupInvitationTokenEdges: - type: object - properties: - group: - description: Group holds the value of the group edge. - allOf: - - $ref: "#/components/schemas/ent.Group" + - $ref: "#/components/schemas/ent.Location" ent.Label: type: object properties: @@ -2212,15 +2112,61 @@ components: ent.LabelEdges: type: object properties: - entities: - description: Entities holds the value of the entities edge. - type: array - items: - $ref: "#/components/schemas/ent.Entity" group: description: Group holds the value of the group edge. allOf: - $ref: "#/components/schemas/ent.Group" + items: + description: Items holds the value of the items edge. + type: array + items: + $ref: "#/components/schemas/ent.Item" + ent.Location: + type: object + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + description: + description: Description holds the value of the "description" field. + type: string + edges: + description: >- + Edges holds the relations/edges for other nodes in the graph. + + The values are being populated by the LocationQuery when eager-loading is set. + allOf: + - $ref: "#/components/schemas/ent.LocationEdges" + id: + description: ID of the ent. + type: string + name: + description: Name holds the value of the "name" field. + type: string + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + ent.LocationEdges: + type: object + properties: + children: + description: Children holds the value of the children edge. + type: array + items: + $ref: "#/components/schemas/ent.Location" + group: + description: Group holds the value of the group edge. + allOf: + - $ref: "#/components/schemas/ent.Group" + items: + description: Items holds the value of the items edge. + type: array + items: + $ref: "#/components/schemas/ent.Item" + parent: + description: Parent holds the value of the parent edge. + allOf: + - $ref: "#/components/schemas/ent.Location" ent.MaintenanceEntry: type: object properties: @@ -2243,12 +2189,12 @@ components: The values are being populated by the MaintenanceEntryQuery when eager-loading is set. allOf: - $ref: "#/components/schemas/ent.MaintenanceEntryEdges" - entity_id: - description: EntityID holds the value of the "entity_id" field. - type: string id: description: ID of the ent. type: string + item_id: + description: ItemID holds the value of the "item_id" field. + type: string name: description: Name holds the value of the "name" field. type: string @@ -2261,10 +2207,10 @@ components: ent.MaintenanceEntryEdges: type: object properties: - entity: - description: Entity holds the value of the entity edge. + item: + description: Item holds the value of the item edge. allOf: - - $ref: "#/components/schemas/ent.Entity" + - $ref: "#/components/schemas/ent.Item" ent.Notifier: type: object properties: @@ -2307,6 +2253,45 @@ components: description: User holds the value of the user edge. allOf: - $ref: "#/components/schemas/ent.User" + ent.TemplateField: + type: object + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + description: + description: Description holds the value of the "description" field. + type: string + edges: + description: >- + Edges holds the relations/edges for other nodes in the graph. + + The values are being populated by the TemplateFieldQuery when eager-loading is set. + allOf: + - $ref: "#/components/schemas/ent.TemplateFieldEdges" + id: + description: ID of the ent. + type: string + name: + description: Name holds the value of the "name" field. + type: string + text_value: + description: TextValue holds the value of the "text_value" field. + type: string + type: + description: Type holds the value of the "type" field. + allOf: + - $ref: "#/components/schemas/templatefield.Type" + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + ent.TemplateFieldEdges: + type: object + properties: + item_template: + description: ItemTemplate holds the value of the item_template edge. + allOf: + - $ref: "#/components/schemas/ent.ItemTemplate" ent.User: type: object properties: @@ -2335,6 +2320,12 @@ components: name: description: Name holds the value of the "name" field. type: string + oidc_issuer: + description: OidcIssuer holds the value of the "oidc_issuer" field. + type: string + oidc_subject: + description: OidcSubject holds the value of the "oidc_subject" field. + type: string role: description: Role holds the value of the "role" field. allOf: @@ -2362,7 +2353,7 @@ components: type: array items: $ref: "#/components/schemas/ent.Notifier" - entityfield.Type: + itemfield.Type: type: string enum: - text @@ -2406,82 +2397,6 @@ components: type: boolean copyPrefix: type: string - repo.EntityAttachment: - type: object - properties: - createdAt: - type: string - id: - type: string - mimeType: - type: string - path: - type: string - primary: - type: boolean - thumbnail: - $ref: "#/components/schemas/ent.Attachment" - title: - type: string - type: - type: string - updatedAt: - type: string - repo.EntityAttachmentUpdate: - type: object - properties: - primary: - type: boolean - title: - type: string - type: - type: string - repo.EntityType: - type: object - properties: - color: - type: string - description: - type: string - icon: - type: string - isLocation: - type: boolean - name: - type: string - repo.EntityTypeCreate: - type: object - required: - - isLocation - - name - properties: - color: - type: string - description: - type: string - icon: - type: string - isLocation: - type: boolean - name: - type: string - repo.EntityTypeDelete: - type: object - properties: - replacementId: - $ref: "#/components/schemas/uuid.NullUUID" - repo.EntityTypeUpdate: - type: object - properties: - color: - type: string - description: - type: string - icon: - type: string - name: - type: string - minLength: 1 repo.Group: type: object properties: @@ -2517,17 +2432,44 @@ components: type: string name: type: string + repo.ItemAttachment: + type: object + properties: + createdAt: + type: string + id: + type: string + mimeType: + type: string + path: + type: string + primary: + type: boolean + thumbnail: + $ref: "#/components/schemas/ent.Attachment" + title: + type: string + type: + type: string + updatedAt: + type: string + repo.ItemAttachmentUpdate: + type: object + properties: + primary: + type: boolean + title: + type: string + type: + type: string repo.ItemCreate: type: object required: - - entityType - name properties: description: type: string maxLength: 1000 - entityType: - type: string labelIds: type: array items: @@ -2570,13 +2512,11 @@ components: attachments: type: array items: - $ref: "#/components/schemas/repo.EntityAttachment" + $ref: "#/components/schemas/repo.ItemAttachment" createdAt: type: string description: type: string - entityType: - type: string fields: type: array items: @@ -2688,8 +2628,6 @@ components: type: string description: type: string - entityType: - type: string id: type: string imageId: @@ -2723,22 +2661,212 @@ components: nullable: true updatedAt: type: string + repo.ItemTemplateCreate: + type: object + required: + - name + properties: + defaultDescription: + type: string + maxLength: 1000 + nullable: true + defaultInsured: + type: boolean + defaultLabelIds: + type: array + items: + type: string + nullable: true + defaultLifetimeWarranty: + type: boolean + defaultLocationId: + description: Default location and labels + type: string + nullable: true + defaultManufacturer: + type: string + maxLength: 255 + nullable: true + defaultModelNumber: + type: string + maxLength: 255 + nullable: true + defaultName: + type: string + maxLength: 255 + nullable: true + defaultQuantity: + description: Default values for items + type: integer + nullable: true + defaultWarrantyDetails: + type: string + maxLength: 1000 + nullable: true + description: + type: string + maxLength: 1000 + fields: + description: Custom fields + type: array + items: + $ref: "#/components/schemas/repo.TemplateField" + includePurchaseFields: + type: boolean + includeSoldFields: + type: boolean + includeWarrantyFields: + description: Metadata flags + type: boolean + name: + type: string + maxLength: 255 + minLength: 1 + notes: + type: string + maxLength: 1000 + repo.ItemTemplateOut: + type: object + properties: + createdAt: + type: string + defaultDescription: + type: string + defaultInsured: + type: boolean + defaultLabels: + type: array + items: + $ref: "#/components/schemas/repo.TemplateLabelSummary" + defaultLifetimeWarranty: + type: boolean + defaultLocation: + description: Default location and labels + allOf: + - $ref: "#/components/schemas/repo.TemplateLocationSummary" + defaultManufacturer: + type: string + defaultModelNumber: + type: string + defaultName: + type: string + defaultQuantity: + description: Default values for items + type: integer + defaultWarrantyDetails: + type: string + description: + type: string + fields: + description: Custom fields + type: array + items: + $ref: "#/components/schemas/repo.TemplateField" + id: + type: string + includePurchaseFields: + type: boolean + includeSoldFields: + type: boolean + includeWarrantyFields: + description: Metadata flags + type: boolean + name: + type: string + notes: + type: string + updatedAt: + type: string + repo.ItemTemplateSummary: + type: object + properties: + createdAt: + type: string + description: + type: string + id: + type: string + name: + type: string + updatedAt: + type: string + repo.ItemTemplateUpdate: + type: object + required: + - name + properties: + defaultDescription: + type: string + maxLength: 1000 + nullable: true + defaultInsured: + type: boolean + defaultLabelIds: + type: array + items: + type: string + nullable: true + defaultLifetimeWarranty: + type: boolean + defaultLocationId: + description: Default location and labels + type: string + nullable: true + defaultManufacturer: + type: string + maxLength: 255 + nullable: true + defaultModelNumber: + type: string + maxLength: 255 + nullable: true + defaultName: + type: string + maxLength: 255 + nullable: true + defaultQuantity: + description: Default values for items + type: integer + nullable: true + defaultWarrantyDetails: + type: string + maxLength: 1000 + nullable: true + description: + type: string + maxLength: 1000 + fields: + description: Custom fields + type: array + items: + $ref: "#/components/schemas/repo.TemplateField" + id: + type: string + includePurchaseFields: + type: boolean + includeSoldFields: + type: boolean + includeWarrantyFields: + description: Metadata flags + type: boolean + name: + type: string + maxLength: 255 + minLength: 1 + notes: + type: string + maxLength: 1000 repo.ItemType: type: string enum: - location - item - - location - - item x-enum-varnames: - - EntityTypeLocation - - EntityTypeItem - ItemTypeLocation - ItemTypeItem repo.ItemUpdate: type: object required: - - entityType - name properties: archived: @@ -2748,8 +2876,6 @@ components: description: type: string maxLength: 1000 - entityType: - type: string fields: type: array items: @@ -2862,13 +2988,9 @@ components: type: string repo.LocationCreate: type: object - required: - - entityType properties: description: type: string - entityType: - type: string name: type: string parentId: @@ -2885,8 +3007,6 @@ components: type: string description: type: string - entityType: - type: string id: type: string name: @@ -2904,8 +3024,6 @@ components: type: string description: type: string - entityType: - type: string id: type: string itemCount: @@ -2921,8 +3039,6 @@ components: type: string description: type: string - entityType: - type: string id: type: string name: @@ -2931,13 +3047,9 @@ components: type: string repo.LocationUpdate: type: object - required: - - entityType properties: description: type: string - entityType: - type: string id: type: string name: @@ -3081,6 +3193,31 @@ components: type: integer total: type: integer + repo.TemplateField: + type: object + properties: + id: + type: string + name: + type: string + textValue: + type: string + type: + type: string + repo.TemplateLabelSummary: + type: object + properties: + id: + type: string + name: + type: string + repo.TemplateLocationSummary: + type: object + properties: + id: + type: string + name: + type: string repo.TotalsByOrganizer: type: object properties: @@ -3120,6 +3257,10 @@ components: type: boolean name: type: string + oidcIssuer: + type: string + oidcSubject: + type: string repo.UserUpdate: type: object properties: @@ -3169,6 +3310,12 @@ components: type: string token: type: string + templatefield.Type: + type: string + enum: + - text + x-enum-varnames: + - TypeText user.Role: type: string enum: @@ -3179,14 +3326,6 @@ components: - DefaultRole - RoleUser - RoleOwner - uuid.NullUUID: - type: object - properties: - uuid: - type: string - valid: - description: Valid is true if UUID is not NULL - type: boolean v1.APISummary: type: object properties: @@ -3204,6 +3343,8 @@ components: $ref: "#/components/schemas/services.Latest" message: type: string + oidc: + $ref: "#/components/schemas/v1.OIDCStatus" title: type: string versions: @@ -3256,6 +3397,27 @@ components: properties: token: type: string + v1.ItemTemplateCreateItemRequest: + type: object + required: + - locationId + - name + properties: + description: + type: string + maxLength: 1000 + labelIds: + type: array + items: + type: string + locationId: + type: string + name: + type: string + maxLength: 255 + minLength: 1 + quantity: + type: integer v1.LoginForm: type: object properties: @@ -3267,6 +3429,17 @@ components: username: type: string example: admin@admin.com + v1.OIDCStatus: + type: object + properties: + allowLocal: + type: boolean + autoRedirect: + type: boolean + buttonText: + type: string + enabled: + type: boolean v1.TokenResponse: type: object properties: diff --git a/backend/app/api/static/docs/swagger.json b/backend/app/api/static/docs/swagger.json index ff53834e..61b8612a 100644 --- a/backend/app/api/static/docs/swagger.json +++ b/backend/app/api/static/docs/swagger.json @@ -1 +1,5211 @@ -{"schemes":["https","http"],"swagger":"2.0","info":{"description":"Track, Manage, and Organize your Things.","title":"Homebox API","contact":{"name":"Homebox Team","url":"https://discord.homebox.software"},"version":"1.0"},"host":"demo.homebox.software","basePath":"/api","paths":{"/v1/actions/create-missing-thumbnails":{"post":{"security":[{"Bearer":[]}],"description":"Creates thumbnails for items that are missing them","produces":["application/json"],"tags":["Actions"],"summary":"Create Missing Thumbnails","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.ActionAmountResult"}}}}},"/v1/actions/ensure-asset-ids":{"post":{"security":[{"Bearer":[]}],"description":"Ensures all items in the database have an asset ID","produces":["application/json"],"tags":["Actions"],"summary":"Ensure Asset IDs","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.ActionAmountResult"}}}}},"/v1/actions/ensure-import-refs":{"post":{"security":[{"Bearer":[]}],"description":"Ensures all items in the database have an import ref","produces":["application/json"],"tags":["Actions"],"summary":"Ensures Import Refs","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.ActionAmountResult"}}}}},"/v1/actions/set-primary-photos":{"post":{"security":[{"Bearer":[]}],"description":"Sets the first photo of each item as the primary photo","produces":["application/json"],"tags":["Actions"],"summary":"Set Primary Photos","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.ActionAmountResult"}}}}},"/v1/actions/zero-item-time-fields":{"post":{"security":[{"Bearer":[]}],"description":"Resets all item date fields to the beginning of the day","produces":["application/json"],"tags":["Actions"],"summary":"Zero Out Time Fields","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.ActionAmountResult"}}}}},"/v1/assets/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"Get Item by Asset ID","parameters":[{"type":"string","description":"Asset ID","name":"id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.PaginationResult-repo_ItemSummary"}}}}},"/v1/currency":{"get":{"produces":["application/json"],"tags":["Base"],"summary":"Currency","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/currencies.Currency"}}}}},"/v1/entities/{id}/attachments":{"post":{"security":[{"Bearer":[]}],"consumes":["multipart/form-data"],"produces":["application/json"],"tags":["Items Attachments"],"summary":"Create Item Attachment","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"file","description":"File attachment","name":"file","in":"formData","required":true},{"type":"string","description":"Type of file","name":"type","in":"formData"},{"type":"boolean","description":"Is this the primary attachment","name":"primary","in":"formData"},{"type":"string","description":"name of the file including extension","name":"name","in":"formData","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ItemOut"}},"422":{"description":"Unprocessable Entity","schema":{"$ref":"#/definitions/validate.ErrorResponse"}}}}},"/v1/entities/{id}/attachments/{attachment_id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/octet-stream"],"tags":["Items Attachments"],"summary":"Get Item Attachment","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"string","description":"Attachment ID","name":"attachment_id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.ItemAttachmentToken"}}}},"put":{"security":[{"Bearer":[]}],"tags":["Items Attachments"],"summary":"Update Item Attachment","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"string","description":"Attachment ID","name":"attachment_id","in":"path","required":true},{"description":"Attachment Update","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.EntityAttachmentUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ItemOut"}}}},"delete":{"security":[{"Bearer":[]}],"tags":["Items Attachments"],"summary":"Delete Item Attachment","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"string","description":"Attachment ID","name":"attachment_id","in":"path","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/entities/{id}/maintenance":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Item Maintenance"],"summary":"Get Maintenance Log","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"enum":["scheduled","completed","both"],"type":"string","x-enum-varnames":["MaintenanceFilterStatusScheduled","MaintenanceFilterStatusCompleted","MaintenanceFilterStatusBoth"],"name":"status","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.MaintenanceEntryWithDetails"}}}}},"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Item Maintenance"],"summary":"Create Maintenance Entry","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"description":"Entry Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.MaintenanceEntryCreate"}}],"responses":{"201":{"description":"Created","schema":{"$ref":"#/definitions/repo.MaintenanceEntry"}}}}},"/v1/entitytype":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["EntityTypes"],"summary":"Query All Entity Types","responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.EntityType"}}}}},"post":{"security":[{"Bearer":[]}],"consumes":["application/json"],"produces":["application/json"],"tags":["EntityTypes"],"summary":"Create Entity Type","parameters":[{"description":"Entity Type Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.EntityTypeCreate"}}],"responses":{"201":{"description":"Created","schema":{"$ref":"#/definitions/repo.EntityType"}}}}},"/v1/entitytype/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["EntityTypes"],"summary":"Get One Entity Type","parameters":[{"type":"string","description":"Entity Type ID","name":"id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.EntityType"}}}},"put":{"security":[{"Bearer":[]}],"consumes":["application/json"],"produces":["application/json"],"tags":["EntityTypes"],"summary":"Update Entity Type","parameters":[{"type":"string","description":"Entity Type ID","name":"id","in":"path","required":true},{"description":"Entity Type Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.EntityTypeUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.EntityType"}}}},"delete":{"security":[{"Bearer":[]}],"tags":["EntityTypes"],"summary":"Delete Entity Type","parameters":[{"type":"string","description":"Entity Type ID","name":"id","in":"path","required":true},{"description":"Entity Type Delete Options","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.EntityTypeDelete"}}],"responses":{"204":{"description":"No Content"}}}},"/v1/groups":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Group"],"summary":"Get Group","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.Group"}}}},"put":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Group"],"summary":"Update Group","parameters":[{"description":"User Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.GroupUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.Group"}}}}},"/v1/groups/invitations":{"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Group"],"summary":"Create Group Invitation","parameters":[{"description":"User Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/v1.GroupInvitationCreate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.GroupInvitation"}}}}},"/v1/groups/statistics":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Statistics"],"summary":"Get Group Statistics","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.GroupStatistics"}}}}},"/v1/groups/statistics/labels":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Statistics"],"summary":"Get Label Statistics","responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.TotalsByOrganizer"}}}}}},"/v1/groups/statistics/locations":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Statistics"],"summary":"Get Location Statistics","responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.TotalsByOrganizer"}}}}}},"/v1/groups/statistics/purchase-price":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Statistics"],"summary":"Get Purchase Price Statistics","parameters":[{"type":"string","description":"start date","name":"start","in":"query"},{"type":"string","description":"end date","name":"end","in":"query"}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ValueOverTime"}}}}},"/v1/items":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Query All Items","deprecated":true,"parameters":[{"type":"string","description":"search string","name":"q","in":"query"},{"type":"integer","description":"page number","name":"page","in":"query"},{"type":"integer","description":"items per page","name":"pageSize","in":"query"},{"type":"array","items":{"type":"string"},"collectionFormat":"multi","description":"label Ids","name":"labels","in":"query"},{"type":"array","items":{"type":"string"},"collectionFormat":"multi","description":"location Ids","name":"locations","in":"query"},{"type":"array","items":{"type":"string"},"collectionFormat":"multi","description":"parent Ids","name":"parentIds","in":"query"}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.PaginationResult-repo_ItemSummary"}}}},"post":{"security":[{"Bearer":[]}],"consumes":["application/json"],"produces":["application/json"],"tags":["Items"],"summary":"Create Item","deprecated":true,"parameters":[{"description":"Item Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.ItemCreate"}}],"responses":{"201":{"description":"Created","schema":{"$ref":"#/definitions/repo.ItemSummary"}}}}},"/v1/items/export":{"get":{"security":[{"Bearer":[]}],"tags":["Items"],"summary":"(Deprecated) Export Items","deprecated":true,"responses":{"200":{"description":"text/csv","schema":{"type":"string"}}}}},"/v1/items/fields":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Get All Custom Field Names","deprecated":true,"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"string"}}}}}},"/v1/items/fields/values":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Get All Custom Field Values","deprecated":true,"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"string"}}}}}},"/v1/items/import":{"post":{"security":[{"Bearer":[]}],"consumes":["multipart/form-data"],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Import Items","deprecated":true,"parameters":[{"type":"file","description":"Image to upload","name":"csv","in":"formData","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/items/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Get Item","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ItemOut"}}}},"put":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Update Item","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"description":"Item Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.ItemUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ItemOut"}}}},"delete":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Delete Item","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true}],"responses":{"204":{"description":"No Content"}}},"patch":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Update Item","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"description":"Item Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.ItemPatch"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ItemOut"}}}}},"/v1/items/{id}/attachments":{"post":{"security":[{"Bearer":[]}],"consumes":["multipart/form-data"],"produces":["application/json"],"tags":["Items Attachments"],"summary":"Create Item Attachment","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"file","description":"File attachment","name":"file","in":"formData","required":true},{"type":"string","description":"Type of file","name":"type","in":"formData"},{"type":"boolean","description":"Is this the primary attachment","name":"primary","in":"formData"},{"type":"string","description":"name of the file including extension","name":"name","in":"formData","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ItemOut"}},"422":{"description":"Unprocessable Entity","schema":{"$ref":"#/definitions/validate.ErrorResponse"}}}}},"/v1/items/{id}/attachments/{attachment_id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/octet-stream"],"tags":["Items Attachments"],"summary":"Get Item Attachment","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"string","description":"Attachment ID","name":"attachment_id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.ItemAttachmentToken"}}}},"put":{"security":[{"Bearer":[]}],"tags":["Items Attachments"],"summary":"Update Item Attachment","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"string","description":"Attachment ID","name":"attachment_id","in":"path","required":true},{"description":"Attachment Update","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.EntityAttachmentUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ItemOut"}}}},"delete":{"security":[{"Bearer":[]}],"tags":["Items Attachments"],"summary":"Delete Item Attachment","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"string","description":"Attachment ID","name":"attachment_id","in":"path","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/items/{id}/duplicate":{"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"Duplicate Item","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"description":"Duplicate Options","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.DuplicateOptions"}}],"responses":{"201":{"description":"Created","schema":{"$ref":"#/definitions/repo.ItemOut"}}}}},"/v1/items/{id}/maintenance":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Item Maintenance"],"summary":"Get Maintenance Log","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"enum":["scheduled","completed","both"],"type":"string","x-enum-varnames":["MaintenanceFilterStatusScheduled","MaintenanceFilterStatusCompleted","MaintenanceFilterStatusBoth"],"name":"status","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.MaintenanceEntryWithDetails"}}}}},"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Item Maintenance"],"summary":"Create Maintenance Entry","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"description":"Entry Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.MaintenanceEntryCreate"}}],"responses":{"201":{"description":"Created","schema":{"$ref":"#/definitions/repo.MaintenanceEntry"}}}}},"/v1/items/{id}/path":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Get the full path of an item","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.ItemPath"}}}}}},"/v1/labelmaker/assets/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"Get Asset label","parameters":[{"type":"string","description":"Asset ID","name":"id","in":"path","required":true},{"type":"boolean","description":"Print this label, defaults to false","name":"print","in":"query"}],"responses":{"200":{"description":"image/png","schema":{"type":"string"}}}}},"/v1/labelmaker/item/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"Get Item label","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"boolean","description":"Print this label, defaults to false","name":"print","in":"query"}],"responses":{"200":{"description":"image/png","schema":{"type":"string"}}}}},"/v1/labelmaker/location/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Locations"],"summary":"Get Location label","parameters":[{"type":"string","description":"Location ID","name":"id","in":"path","required":true},{"type":"boolean","description":"Print this label, defaults to false","name":"print","in":"query"}],"responses":{"200":{"description":"image/png","schema":{"type":"string"}}}}},"/v1/labels":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Labels"],"summary":"Get All Labels","responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.LabelOut"}}}}},"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Labels"],"summary":"Create Label","parameters":[{"description":"Label Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.LabelCreate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.LabelSummary"}}}}},"/v1/labels/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Labels"],"summary":"Get Label","parameters":[{"type":"string","description":"Label ID","name":"id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.LabelOut"}}}},"put":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Labels"],"summary":"Update Label","parameters":[{"type":"string","description":"Label ID","name":"id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.LabelOut"}}}},"delete":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Labels"],"summary":"Delete Label","parameters":[{"type":"string","description":"Label ID","name":"id","in":"path","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/locations":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Locations"],"summary":"(Deprecated) Get All Locations","deprecated":true,"parameters":[{"type":"boolean","description":"Filter locations with parents","name":"filterChildren","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.LocationOutCount"}}}}},"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Locations"],"summary":"(Deprecated) Create Location","deprecated":true,"parameters":[{"description":"Location Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.LocationCreate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.LocationSummary"}}}}},"/v1/locations/tree":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Locations"],"summary":"(Deprecated) Get Locations Tree","deprecated":true,"parameters":[{"type":"boolean","description":"include items in response tree","name":"withItems","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.TreeItem"}}}}}},"/v1/locations/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Locations"],"summary":"(Deprecated) Get Location","deprecated":true,"parameters":[{"type":"string","description":"Location ID","name":"id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.LocationOut"}}}},"put":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Locations"],"summary":"(Deprecated) Update Location","deprecated":true,"parameters":[{"type":"string","description":"Location ID","name":"id","in":"path","required":true},{"description":"Location Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.LocationUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.LocationOut"}}}},"delete":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Locations"],"summary":"(Deprecated) Delete Location","deprecated":true,"parameters":[{"type":"string","description":"Location ID","name":"id","in":"path","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/maintenance":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Maintenance"],"summary":"Query All Maintenance","parameters":[{"enum":["scheduled","completed","both"],"type":"string","x-enum-varnames":["MaintenanceFilterStatusScheduled","MaintenanceFilterStatusCompleted","MaintenanceFilterStatusBoth"],"name":"status","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.MaintenanceEntryWithDetails"}}}}}},"/v1/maintenance/{id}":{"put":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Maintenance"],"summary":"Update Maintenance Entry","parameters":[{"type":"string","description":"Maintenance ID","name":"id","in":"path","required":true},{"description":"Entry Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.MaintenanceEntryUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.MaintenanceEntry"}}}},"delete":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Maintenance"],"summary":"Delete Maintenance Entry","parameters":[{"type":"string","description":"Maintenance ID","name":"id","in":"path","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/notifiers":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Notifiers"],"summary":"Get Notifiers","responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.NotifierOut"}}}}},"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Notifiers"],"summary":"Create Notifier","parameters":[{"description":"Notifier Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.NotifierCreate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.NotifierOut"}}}}},"/v1/notifiers/test":{"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Notifiers"],"summary":"Test Notifier","parameters":[{"type":"string","description":"URL","name":"url","in":"query","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/notifiers/{id}":{"put":{"security":[{"Bearer":[]}],"tags":["Notifiers"],"summary":"Update Notifier","parameters":[{"type":"string","description":"Notifier ID","name":"id","in":"path","required":true},{"description":"Notifier Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.NotifierUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.NotifierOut"}}}},"delete":{"security":[{"Bearer":[]}],"tags":["Notifiers"],"summary":"Delete a Notifier","parameters":[{"type":"string","description":"Notifier ID","name":"id","in":"path","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/products/search-from-barcode":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"Search EAN from Barcode","parameters":[{"type":"string","description":"barcode to be searched","name":"data","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.BarcodeProduct"}}}}}},"/v1/qrcode":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"Create QR Code","parameters":[{"type":"string","description":"data to be encoded into qrcode","name":"data","in":"query"}],"responses":{"200":{"description":"image/jpeg","schema":{"type":"string"}}}}},"/v1/reporting/bill-of-materials":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Reporting"],"summary":"Export Bill of Materials","responses":{"200":{"description":"text/csv","schema":{"type":"string"}}}}},"/v1/status":{"get":{"produces":["application/json"],"tags":["Base"],"summary":"Application Info","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.APISummary"}}}}},"/v1/users/change-password":{"put":{"security":[{"Bearer":[]}],"tags":["User"],"summary":"Change Password","parameters":[{"description":"Password Payload","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/v1.ChangePassword"}}],"responses":{"204":{"description":"No Content"}}}},"/v1/users/login":{"post":{"consumes":["application/x-www-form-urlencoded","application/json"],"produces":["application/json"],"tags":["Authentication"],"summary":"User Login","parameters":[{"description":"Login Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/v1.LoginForm"}},{"type":"string","description":"auth provider","name":"provider","in":"query"}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.TokenResponse"}}}}},"/v1/users/logout":{"post":{"security":[{"Bearer":[]}],"tags":["Authentication"],"summary":"User Logout","responses":{"204":{"description":"No Content"}}}},"/v1/users/refresh":{"get":{"security":[{"Bearer":[]}],"description":"handleAuthRefresh returns a handler that will issue a new token from an existing token.\nThis does not validate that the user still exists within the database.","tags":["Authentication"],"summary":"User Token Refresh","responses":{"200":{"description":"OK"}}}},"/v1/users/register":{"post":{"produces":["application/json"],"tags":["User"],"summary":"Register New User","parameters":[{"description":"User Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/services.UserRegistration"}}],"responses":{"204":{"description":"No Content"}}}},"/v1/users/self":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["User"],"summary":"Get User Self","responses":{"200":{"description":"OK","schema":{"allOf":[{"$ref":"#/definitions/v1.Wrapped"},{"type":"object","properties":{"item":{"$ref":"#/definitions/repo.UserOut"}}}]}}}},"put":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["User"],"summary":"Update Account","parameters":[{"description":"User Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.UserUpdate"}}],"responses":{"200":{"description":"OK","schema":{"allOf":[{"$ref":"#/definitions/v1.Wrapped"},{"type":"object","properties":{"item":{"$ref":"#/definitions/repo.UserUpdate"}}}]}}}},"delete":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["User"],"summary":"Delete Account","responses":{"204":{"description":"No Content"}}}}},"definitions":{"attachment.Type":{"type":"string","enum":["attachment","photo","manual","warranty","attachment","receipt","thumbnail"],"x-enum-varnames":["DefaultType","TypePhoto","TypeManual","TypeWarranty","TypeAttachment","TypeReceipt","TypeThumbnail"]},"authroles.Role":{"type":"string","enum":["user","admin","user","attachments"],"x-enum-varnames":["DefaultRole","RoleAdmin","RoleUser","RoleAttachments"]},"currencies.Currency":{"type":"object","properties":{"code":{"type":"string"},"decimals":{"type":"integer"},"local":{"type":"string"},"name":{"type":"string"},"symbol":{"type":"string"}}},"ent.Attachment":{"type":"object","properties":{"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AttachmentQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.AttachmentEdges"}]},"id":{"description":"ID of the ent.","type":"string"},"mime_type":{"description":"MimeType holds the value of the \"mime_type\" field.","type":"string"},"path":{"description":"Path holds the value of the \"path\" field.","type":"string"},"primary":{"description":"Primary holds the value of the \"primary\" field.","type":"boolean"},"title":{"description":"Title holds the value of the \"title\" field.","type":"string"},"type":{"description":"Type holds the value of the \"type\" field.","allOf":[{"$ref":"#/definitions/attachment.Type"}]},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.AttachmentEdges":{"type":"object","properties":{"entity":{"description":"Entity holds the value of the entity edge.","allOf":[{"$ref":"#/definitions/ent.Entity"}]},"thumbnail":{"description":"Thumbnail holds the value of the thumbnail edge.","allOf":[{"$ref":"#/definitions/ent.Attachment"}]}}},"ent.AuthRoles":{"type":"object","properties":{"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AuthRolesQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.AuthRolesEdges"}]},"id":{"description":"ID of the ent.","type":"integer"},"role":{"description":"Role holds the value of the \"role\" field.","allOf":[{"$ref":"#/definitions/authroles.Role"}]}}},"ent.AuthRolesEdges":{"type":"object","properties":{"token":{"description":"Token holds the value of the token edge.","allOf":[{"$ref":"#/definitions/ent.AuthTokens"}]}}},"ent.AuthTokens":{"type":"object","properties":{"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AuthTokensQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.AuthTokensEdges"}]},"expires_at":{"description":"ExpiresAt holds the value of the \"expires_at\" field.","type":"string"},"id":{"description":"ID of the ent.","type":"string"},"token":{"description":"Token holds the value of the \"token\" field.","type":"array","items":{"type":"integer"}},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.AuthTokensEdges":{"type":"object","properties":{"roles":{"description":"Roles holds the value of the roles edge.","allOf":[{"$ref":"#/definitions/ent.AuthRoles"}]},"user":{"description":"User holds the value of the user edge.","allOf":[{"$ref":"#/definitions/ent.User"}]}}},"ent.Entity":{"type":"object","properties":{"archived":{"description":"Archived holds the value of the \"archived\" field.","type":"boolean"},"asset_id":{"description":"AssetID holds the value of the \"asset_id\" field.","type":"integer"},"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"description":{"description":"Description holds the value of the \"description\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.EntityEdges"}]},"id":{"description":"ID of the ent.","type":"string"},"import_ref":{"description":"ImportRef holds the value of the \"import_ref\" field.","type":"string"},"insured":{"description":"Insured holds the value of the \"insured\" field.","type":"boolean"},"lifetime_warranty":{"description":"LifetimeWarranty holds the value of the \"lifetime_warranty\" field.","type":"boolean"},"manufacturer":{"description":"Manufacturer holds the value of the \"manufacturer\" field.","type":"string"},"model_number":{"description":"ModelNumber holds the value of the \"model_number\" field.","type":"string"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"notes":{"description":"Notes holds the value of the \"notes\" field.","type":"string"},"purchase_from":{"description":"PurchaseFrom holds the value of the \"purchase_from\" field.","type":"string"},"purchase_price":{"description":"PurchasePrice holds the value of the \"purchase_price\" field.","type":"number"},"purchase_time":{"description":"PurchaseTime holds the value of the \"purchase_time\" field.","type":"string"},"quantity":{"description":"Quantity holds the value of the \"quantity\" field.","type":"integer"},"serial_number":{"description":"SerialNumber holds the value of the \"serial_number\" field.","type":"string"},"sold_notes":{"description":"SoldNotes holds the value of the \"sold_notes\" field.","type":"string"},"sold_price":{"description":"SoldPrice holds the value of the \"sold_price\" field.","type":"number"},"sold_time":{"description":"SoldTime holds the value of the \"sold_time\" field.","type":"string"},"sold_to":{"description":"SoldTo holds the value of the \"sold_to\" field.","type":"string"},"sync_child_entities_locations":{"description":"SyncChildEntitiesLocations holds the value of the \"sync_child_entities_locations\" field.","type":"boolean"},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"},"warranty_details":{"description":"WarrantyDetails holds the value of the \"warranty_details\" field.","type":"string"},"warranty_expires":{"description":"WarrantyExpires holds the value of the \"warranty_expires\" field.","type":"string"}}},"ent.EntityEdges":{"type":"object","properties":{"attachments":{"description":"Attachments holds the value of the attachments edge.","type":"array","items":{"$ref":"#/definitions/ent.Attachment"}},"children":{"description":"Children holds the value of the children edge.","type":"array","items":{"$ref":"#/definitions/ent.Entity"}},"entity":{"description":"Entity holds the value of the entity edge.","type":"array","items":{"$ref":"#/definitions/ent.Entity"}},"fields":{"description":"Fields holds the value of the fields edge.","type":"array","items":{"$ref":"#/definitions/ent.EntityField"}},"group":{"description":"Group holds the value of the group edge.","allOf":[{"$ref":"#/definitions/ent.Group"}]},"label":{"description":"Label holds the value of the label edge.","type":"array","items":{"$ref":"#/definitions/ent.Label"}},"location":{"description":"Location holds the value of the location edge.","allOf":[{"$ref":"#/definitions/ent.Entity"}]},"maintenance_entries":{"description":"MaintenanceEntries holds the value of the maintenance_entries edge.","type":"array","items":{"$ref":"#/definitions/ent.MaintenanceEntry"}},"parent":{"description":"Parent holds the value of the parent edge.","allOf":[{"$ref":"#/definitions/ent.Entity"}]},"type":{"description":"Type holds the value of the type edge.","allOf":[{"$ref":"#/definitions/ent.EntityType"}]}}},"ent.EntityField":{"type":"object","properties":{"boolean_value":{"description":"BooleanValue holds the value of the \"boolean_value\" field.","type":"boolean"},"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"description":{"description":"Description holds the value of the \"description\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityFieldQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.EntityFieldEdges"}]},"id":{"description":"ID of the ent.","type":"string"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"number_value":{"description":"NumberValue holds the value of the \"number_value\" field.","type":"integer"},"text_value":{"description":"TextValue holds the value of the \"text_value\" field.","type":"string"},"time_value":{"description":"TimeValue holds the value of the \"time_value\" field.","type":"string"},"type":{"description":"Type holds the value of the \"type\" field.","allOf":[{"$ref":"#/definitions/entityfield.Type"}]},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.EntityFieldEdges":{"type":"object","properties":{"entity":{"description":"Entity holds the value of the entity edge.","allOf":[{"$ref":"#/definitions/ent.Entity"}]}}},"ent.EntityType":{"type":"object","properties":{"color":{"description":"Color holds the value of the \"color\" field.","type":"string"},"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"description":{"description":"Description holds the value of the \"description\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityTypeQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.EntityTypeEdges"}]},"icon":{"description":"Icon holds the value of the \"icon\" field.","type":"string"},"id":{"description":"ID of the ent.","type":"string"},"is_location":{"description":"IsLocation holds the value of the \"is_location\" field.","type":"boolean"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.EntityTypeEdges":{"type":"object","properties":{"entities":{"description":"Entities holds the value of the entities edge.","type":"array","items":{"$ref":"#/definitions/ent.Entity"}},"group":{"description":"Group holds the value of the group edge.","allOf":[{"$ref":"#/definitions/ent.Group"}]}}},"ent.Group":{"type":"object","properties":{"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"currency":{"description":"Currency holds the value of the \"currency\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the GroupQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.GroupEdges"}]},"id":{"description":"ID of the ent.","type":"string"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.GroupEdges":{"type":"object","properties":{"entities":{"description":"Entities holds the value of the entities edge.","type":"array","items":{"$ref":"#/definitions/ent.Entity"}},"entity_types":{"description":"EntityTypes holds the value of the entity_types edge.","type":"array","items":{"$ref":"#/definitions/ent.EntityType"}},"invitation_tokens":{"description":"InvitationTokens holds the value of the invitation_tokens edge.","type":"array","items":{"$ref":"#/definitions/ent.GroupInvitationToken"}},"labels":{"description":"Labels holds the value of the labels edge.","type":"array","items":{"$ref":"#/definitions/ent.Label"}},"notifiers":{"description":"Notifiers holds the value of the notifiers edge.","type":"array","items":{"$ref":"#/definitions/ent.Notifier"}},"users":{"description":"Users holds the value of the users edge.","type":"array","items":{"$ref":"#/definitions/ent.User"}}}},"ent.GroupInvitationToken":{"type":"object","properties":{"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the GroupInvitationTokenQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.GroupInvitationTokenEdges"}]},"expires_at":{"description":"ExpiresAt holds the value of the \"expires_at\" field.","type":"string"},"id":{"description":"ID of the ent.","type":"string"},"token":{"description":"Token holds the value of the \"token\" field.","type":"array","items":{"type":"integer"}},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"},"uses":{"description":"Uses holds the value of the \"uses\" field.","type":"integer"}}},"ent.GroupInvitationTokenEdges":{"type":"object","properties":{"group":{"description":"Group holds the value of the group edge.","allOf":[{"$ref":"#/definitions/ent.Group"}]}}},"ent.Label":{"type":"object","properties":{"color":{"description":"Color holds the value of the \"color\" field.","type":"string"},"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"description":{"description":"Description holds the value of the \"description\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LabelQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.LabelEdges"}]},"id":{"description":"ID of the ent.","type":"string"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.LabelEdges":{"type":"object","properties":{"entities":{"description":"Entities holds the value of the entities edge.","type":"array","items":{"$ref":"#/definitions/ent.Entity"}},"group":{"description":"Group holds the value of the group edge.","allOf":[{"$ref":"#/definitions/ent.Group"}]}}},"ent.MaintenanceEntry":{"type":"object","properties":{"cost":{"description":"Cost holds the value of the \"cost\" field.","type":"number"},"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"date":{"description":"Date holds the value of the \"date\" field.","type":"string"},"description":{"description":"Description holds the value of the \"description\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the MaintenanceEntryQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.MaintenanceEntryEdges"}]},"entity_id":{"description":"EntityID holds the value of the \"entity_id\" field.","type":"string"},"id":{"description":"ID of the ent.","type":"string"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"scheduled_date":{"description":"ScheduledDate holds the value of the \"scheduled_date\" field.","type":"string"},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.MaintenanceEntryEdges":{"type":"object","properties":{"entity":{"description":"Entity holds the value of the entity edge.","allOf":[{"$ref":"#/definitions/ent.Entity"}]}}},"ent.Notifier":{"type":"object","properties":{"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the NotifierQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.NotifierEdges"}]},"group_id":{"description":"GroupID holds the value of the \"group_id\" field.","type":"string"},"id":{"description":"ID of the ent.","type":"string"},"is_active":{"description":"IsActive holds the value of the \"is_active\" field.","type":"boolean"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"},"user_id":{"description":"UserID holds the value of the \"user_id\" field.","type":"string"}}},"ent.NotifierEdges":{"type":"object","properties":{"group":{"description":"Group holds the value of the group edge.","allOf":[{"$ref":"#/definitions/ent.Group"}]},"user":{"description":"User holds the value of the user edge.","allOf":[{"$ref":"#/definitions/ent.User"}]}}},"ent.User":{"type":"object","properties":{"activated_on":{"description":"ActivatedOn holds the value of the \"activated_on\" field.","type":"string"},"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the UserQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.UserEdges"}]},"email":{"description":"Email holds the value of the \"email\" field.","type":"string"},"id":{"description":"ID of the ent.","type":"string"},"is_superuser":{"description":"IsSuperuser holds the value of the \"is_superuser\" field.","type":"boolean"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"role":{"description":"Role holds the value of the \"role\" field.","allOf":[{"$ref":"#/definitions/user.Role"}]},"superuser":{"description":"Superuser holds the value of the \"superuser\" field.","type":"boolean"},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.UserEdges":{"type":"object","properties":{"auth_tokens":{"description":"AuthTokens holds the value of the auth_tokens edge.","type":"array","items":{"$ref":"#/definitions/ent.AuthTokens"}},"group":{"description":"Group holds the value of the group edge.","allOf":[{"$ref":"#/definitions/ent.Group"}]},"notifiers":{"description":"Notifiers holds the value of the notifiers edge.","type":"array","items":{"$ref":"#/definitions/ent.Notifier"}}}},"entityfield.Type":{"type":"string","enum":["text","number","boolean","time"],"x-enum-varnames":["TypeText","TypeNumber","TypeBoolean","TypeTime"]},"repo.BarcodeProduct":{"type":"object","properties":{"barcode":{"type":"string"},"imageBase64":{"type":"string"},"imageURL":{"type":"string"},"item":{"$ref":"#/definitions/repo.ItemCreate"},"manufacturer":{"type":"string"},"modelNumber":{"description":"Identifications","type":"string"},"notes":{"description":"Extras","type":"string"},"search_engine_name":{"type":"string"}}},"repo.DuplicateOptions":{"type":"object","properties":{"copyAttachments":{"type":"boolean"},"copyCustomFields":{"type":"boolean"},"copyMaintenance":{"type":"boolean"},"copyPrefix":{"type":"string"}}},"repo.EntityAttachment":{"type":"object","properties":{"createdAt":{"type":"string"},"id":{"type":"string"},"mimeType":{"type":"string"},"path":{"type":"string"},"primary":{"type":"boolean"},"thumbnail":{"$ref":"#/definitions/ent.Attachment"},"title":{"type":"string"},"type":{"type":"string"},"updatedAt":{"type":"string"}}},"repo.EntityAttachmentUpdate":{"type":"object","properties":{"primary":{"type":"boolean"},"title":{"type":"string"},"type":{"type":"string"}}},"repo.EntityType":{"type":"object","properties":{"color":{"type":"string"},"description":{"type":"string"},"icon":{"type":"string"},"isLocation":{"type":"boolean"},"name":{"type":"string"}}},"repo.EntityTypeCreate":{"type":"object","required":["isLocation","name"],"properties":{"color":{"type":"string"},"description":{"type":"string"},"icon":{"type":"string"},"isLocation":{"type":"boolean"},"name":{"type":"string"}}},"repo.EntityTypeDelete":{"type":"object","properties":{"replacementId":{"$ref":"#/definitions/uuid.NullUUID"}}},"repo.EntityTypeUpdate":{"type":"object","properties":{"color":{"type":"string"},"description":{"type":"string"},"icon":{"type":"string"},"name":{"type":"string","minLength":1}}},"repo.Group":{"type":"object","properties":{"createdAt":{"type":"string"},"currency":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"updatedAt":{"type":"string"}}},"repo.GroupStatistics":{"type":"object","properties":{"totalItemPrice":{"type":"number"},"totalItems":{"type":"integer"},"totalLabels":{"type":"integer"},"totalLocations":{"type":"integer"},"totalUsers":{"type":"integer"},"totalWithWarranty":{"type":"integer"}}},"repo.GroupUpdate":{"type":"object","properties":{"currency":{"type":"string"},"name":{"type":"string"}}},"repo.ItemCreate":{"type":"object","required":["entityType","name"],"properties":{"description":{"type":"string","maxLength":1000},"entityType":{"type":"string"},"labelIds":{"type":"array","items":{"type":"string"}},"locationId":{"description":"Edges","type":"string"},"name":{"type":"string","maxLength":255,"minLength":1},"parentId":{"type":"string","x-nullable":true},"quantity":{"type":"integer"}}},"repo.ItemField":{"type":"object","properties":{"booleanValue":{"type":"boolean"},"id":{"type":"string"},"name":{"type":"string"},"numberValue":{"type":"integer"},"textValue":{"type":"string"},"type":{"type":"string"}}},"repo.ItemOut":{"type":"object","properties":{"archived":{"type":"boolean"},"assetId":{"type":"string","example":"0"},"attachments":{"type":"array","items":{"$ref":"#/definitions/repo.EntityAttachment"}},"createdAt":{"type":"string"},"description":{"type":"string"},"entityType":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/definitions/repo.ItemField"}},"id":{"type":"string"},"imageId":{"type":"string","x-nullable":true,"x-omitempty":true},"insured":{"type":"boolean"},"labels":{"type":"array","items":{"$ref":"#/definitions/repo.LabelSummary"}},"lifetimeWarranty":{"description":"Warranty","type":"boolean"},"location":{"description":"Edges","allOf":[{"$ref":"#/definitions/repo.LocationSummary"}],"x-nullable":true,"x-omitempty":true},"manufacturer":{"type":"string"},"modelNumber":{"type":"string"},"name":{"type":"string"},"notes":{"description":"Extras","type":"string"},"parent":{"allOf":[{"$ref":"#/definitions/repo.ItemSummary"}],"x-nullable":true,"x-omitempty":true},"purchaseFrom":{"type":"string"},"purchasePrice":{"type":"number"},"purchaseTime":{"description":"Purchase","type":"string"},"quantity":{"type":"integer"},"serialNumber":{"type":"string"},"soldNotes":{"type":"string"},"soldPrice":{"type":"number"},"soldTime":{"description":"Sold","type":"string"},"soldTo":{"type":"string"},"syncChildItemsLocations":{"type":"boolean"},"thumbnailId":{"type":"string","x-nullable":true,"x-omitempty":true},"updatedAt":{"type":"string"},"warrantyDetails":{"type":"string"},"warrantyExpires":{"type":"string"}}},"repo.ItemPatch":{"type":"object","properties":{"id":{"type":"string"},"labelIds":{"type":"array","items":{"type":"string"},"x-nullable":true,"x-omitempty":true},"locationId":{"type":"string","x-nullable":true,"x-omitempty":true},"quantity":{"type":"integer","x-nullable":true,"x-omitempty":true}}},"repo.ItemPath":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"type":{"$ref":"#/definitions/repo.ItemType"}}},"repo.ItemSummary":{"type":"object","properties":{"archived":{"type":"boolean"},"assetId":{"type":"string","example":"0"},"createdAt":{"type":"string"},"description":{"type":"string"},"entityType":{"type":"string"},"id":{"type":"string"},"imageId":{"type":"string","x-nullable":true,"x-omitempty":true},"insured":{"type":"boolean"},"labels":{"type":"array","items":{"$ref":"#/definitions/repo.LabelSummary"}},"location":{"description":"Edges","allOf":[{"$ref":"#/definitions/repo.LocationSummary"}],"x-nullable":true,"x-omitempty":true},"name":{"type":"string"},"purchasePrice":{"type":"number"},"quantity":{"type":"integer"},"soldTime":{"description":"Sale details","type":"string"},"thumbnailId":{"type":"string","x-nullable":true,"x-omitempty":true},"updatedAt":{"type":"string"}}},"repo.ItemType":{"type":"string","enum":["location","item","location","item"],"x-enum-varnames":["EntityTypeLocation","EntityTypeItem","ItemTypeLocation","ItemTypeItem"]},"repo.ItemUpdate":{"type":"object","required":["entityType","name"],"properties":{"archived":{"type":"boolean"},"assetId":{"type":"string"},"description":{"type":"string","maxLength":1000},"entityType":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/definitions/repo.ItemField"}},"id":{"type":"string"},"insured":{"type":"boolean"},"labelIds":{"type":"array","items":{"type":"string"}},"lifetimeWarranty":{"description":"Warranty","type":"boolean"},"locationId":{"description":"Edges","type":"string"},"manufacturer":{"type":"string"},"modelNumber":{"type":"string"},"name":{"type":"string","maxLength":255,"minLength":1},"notes":{"description":"Extras","type":"string"},"parentId":{"type":"string","x-nullable":true,"x-omitempty":true},"purchaseFrom":{"type":"string","maxLength":255},"purchasePrice":{"type":"number","x-nullable":true,"x-omitempty":true},"purchaseTime":{"description":"Purchase","type":"string"},"quantity":{"type":"integer"},"serialNumber":{"description":"Identifications","type":"string"},"soldNotes":{"type":"string"},"soldPrice":{"type":"number","x-nullable":true,"x-omitempty":true},"soldTime":{"description":"Sold","type":"string"},"soldTo":{"type":"string","maxLength":255},"syncChildItemsLocations":{"type":"boolean"},"warrantyDetails":{"type":"string"},"warrantyExpires":{"type":"string"}}},"repo.LabelCreate":{"type":"object","required":["name"],"properties":{"color":{"type":"string"},"description":{"type":"string","maxLength":1000},"name":{"type":"string","maxLength":255,"minLength":1}}},"repo.LabelOut":{"type":"object","properties":{"color":{"type":"string"},"createdAt":{"type":"string"},"description":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"updatedAt":{"type":"string"}}},"repo.LabelSummary":{"type":"object","properties":{"color":{"type":"string"},"createdAt":{"type":"string"},"description":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"updatedAt":{"type":"string"}}},"repo.LocationCreate":{"type":"object","required":["entityType"],"properties":{"description":{"type":"string"},"entityType":{"type":"string"},"name":{"type":"string"},"parentId":{"type":"string","x-nullable":true}}},"repo.LocationOut":{"type":"object","properties":{"children":{"type":"array","items":{"$ref":"#/definitions/repo.LocationSummary"}},"createdAt":{"type":"string"},"description":{"type":"string"},"entityType":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"parent":{"$ref":"#/definitions/repo.LocationSummary"},"totalPrice":{"type":"number"},"updatedAt":{"type":"string"}}},"repo.LocationOutCount":{"type":"object","properties":{"createdAt":{"type":"string"},"description":{"type":"string"},"entityType":{"type":"string"},"id":{"type":"string"},"itemCount":{"type":"integer"},"name":{"type":"string"},"updatedAt":{"type":"string"}}},"repo.LocationSummary":{"type":"object","properties":{"createdAt":{"type":"string"},"description":{"type":"string"},"entityType":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"updatedAt":{"type":"string"}}},"repo.LocationUpdate":{"type":"object","required":["entityType"],"properties":{"description":{"type":"string"},"entityType":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"parentId":{"type":"string","x-nullable":true}}},"repo.MaintenanceEntry":{"type":"object","properties":{"completedDate":{"type":"string"},"cost":{"type":"string","example":"0"},"description":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"scheduledDate":{"type":"string"}}},"repo.MaintenanceEntryCreate":{"type":"object","required":["name"],"properties":{"completedDate":{"type":"string"},"cost":{"type":"string","example":"0"},"description":{"type":"string"},"name":{"type":"string"},"scheduledDate":{"type":"string"}}},"repo.MaintenanceEntryUpdate":{"type":"object","properties":{"completedDate":{"type":"string"},"cost":{"type":"string","example":"0"},"description":{"type":"string"},"name":{"type":"string"},"scheduledDate":{"type":"string"}}},"repo.MaintenanceEntryWithDetails":{"type":"object","properties":{"completedDate":{"type":"string"},"cost":{"type":"string","example":"0"},"description":{"type":"string"},"id":{"type":"string"},"itemID":{"type":"string"},"itemName":{"type":"string"},"name":{"type":"string"},"scheduledDate":{"type":"string"}}},"repo.MaintenanceFilterStatus":{"type":"string","enum":["scheduled","completed","both"],"x-enum-varnames":["MaintenanceFilterStatusScheduled","MaintenanceFilterStatusCompleted","MaintenanceFilterStatusBoth"]},"repo.NotifierCreate":{"type":"object","required":["name","url"],"properties":{"isActive":{"type":"boolean"},"name":{"type":"string","maxLength":255,"minLength":1},"url":{"type":"string"}}},"repo.NotifierOut":{"type":"object","properties":{"createdAt":{"type":"string"},"groupId":{"type":"string"},"id":{"type":"string"},"isActive":{"type":"boolean"},"name":{"type":"string"},"updatedAt":{"type":"string"},"url":{"type":"string"},"userId":{"type":"string"}}},"repo.NotifierUpdate":{"type":"object","required":["name"],"properties":{"isActive":{"type":"boolean"},"name":{"type":"string","maxLength":255,"minLength":1},"url":{"type":"string","x-nullable":true}}},"repo.PaginationResult-repo_ItemSummary":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/definitions/repo.ItemSummary"}},"page":{"type":"integer"},"pageSize":{"type":"integer"},"total":{"type":"integer"}}},"repo.TotalsByOrganizer":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"total":{"type":"number"}}},"repo.TreeItem":{"type":"object","properties":{"children":{"type":"array","items":{"$ref":"#/definitions/repo.TreeItem"}},"id":{"type":"string"},"name":{"type":"string"},"type":{"type":"string"}}},"repo.UserOut":{"type":"object","properties":{"email":{"type":"string"},"groupId":{"type":"string"},"groupName":{"type":"string"},"id":{"type":"string"},"isOwner":{"type":"boolean"},"isSuperuser":{"type":"boolean"},"name":{"type":"string"}}},"repo.UserUpdate":{"type":"object","properties":{"email":{"type":"string"},"name":{"type":"string"}}},"repo.ValueOverTime":{"type":"object","properties":{"end":{"type":"string"},"entries":{"type":"array","items":{"$ref":"#/definitions/repo.ValueOverTimeEntry"}},"start":{"type":"string"},"valueAtEnd":{"type":"number"},"valueAtStart":{"type":"number"}}},"repo.ValueOverTimeEntry":{"type":"object","properties":{"date":{"type":"string"},"name":{"type":"string"},"value":{"type":"number"}}},"services.Latest":{"type":"object","properties":{"date":{"type":"string"},"version":{"type":"string"}}},"services.UserRegistration":{"type":"object","properties":{"email":{"type":"string"},"name":{"type":"string"},"password":{"type":"string"},"token":{"type":"string"}}},"user.Role":{"type":"string","enum":["user","user","owner"],"x-enum-varnames":["DefaultRole","RoleUser","RoleOwner"]},"uuid.NullUUID":{"type":"object","properties":{"uuid":{"type":"string"},"valid":{"description":"Valid is true if UUID is not NULL","type":"boolean"}}},"v1.APISummary":{"type":"object","properties":{"allowRegistration":{"type":"boolean"},"build":{"$ref":"#/definitions/v1.Build"},"demo":{"type":"boolean"},"health":{"type":"boolean"},"labelPrinting":{"type":"boolean"},"latest":{"$ref":"#/definitions/services.Latest"},"message":{"type":"string"},"title":{"type":"string"},"versions":{"type":"array","items":{"type":"string"}}}},"v1.ActionAmountResult":{"type":"object","properties":{"completed":{"type":"integer"}}},"v1.Build":{"type":"object","properties":{"buildTime":{"type":"string"},"commit":{"type":"string"},"version":{"type":"string"}}},"v1.ChangePassword":{"type":"object","properties":{"current":{"type":"string"},"new":{"type":"string"}}},"v1.GroupInvitation":{"type":"object","properties":{"expiresAt":{"type":"string"},"token":{"type":"string"},"uses":{"type":"integer"}}},"v1.GroupInvitationCreate":{"type":"object","required":["uses"],"properties":{"expiresAt":{"type":"string"},"uses":{"type":"integer","maximum":100,"minimum":1}}},"v1.ItemAttachmentToken":{"type":"object","properties":{"token":{"type":"string"}}},"v1.LoginForm":{"type":"object","properties":{"password":{"type":"string","example":"admin"},"stayLoggedIn":{"type":"boolean"},"username":{"type":"string","example":"admin@admin.com"}}},"v1.TokenResponse":{"type":"object","properties":{"attachmentToken":{"type":"string"},"expiresAt":{"type":"string"},"token":{"type":"string"}}},"v1.Wrapped":{"type":"object","properties":{"item":{}}},"validate.ErrorResponse":{"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"string"}}}},"securityDefinitions":{"Bearer":{"description":"\"Type 'Bearer TOKEN' to correctly set the API Key\"","type":"apiKey","name":"Authorization","in":"header"}}} \ No newline at end of file +{ + "schemes": [ + "https", + "http" + ], + "swagger": "2.0", + "info": { + "description": "Track, Manage, and Organize your Things.", + "title": "Homebox API", + "contact": { + "name": "Homebox Team", + "url": "https://discord.homebox.software" + }, + "version": "1.0" + }, + "host": "demo.homebox.software", + "basePath": "/api", + "paths": { + "/v1/actions/create-missing-thumbnails": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Creates thumbnails for items that are missing them", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Create Missing Thumbnails", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, + "/v1/actions/ensure-asset-ids": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Ensures all items in the database have an asset ID", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Ensure Asset IDs", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, + "/v1/actions/ensure-import-refs": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Ensures all items in the database have an import ref", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Ensures Import Refs", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, + "/v1/actions/set-primary-photos": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Sets the first photo of each item as the primary photo", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Set Primary Photos", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, + "/v1/actions/zero-item-time-fields": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Resets all item date fields to the beginning of the day", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Zero Out Time Fields", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, + "/v1/assets/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get Item by Asset ID", + "parameters": [ + { + "type": "string", + "description": "Asset ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.PaginationResult-repo_ItemSummary" + } + } + } + } + }, + "/v1/currency": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "Base" + ], + "summary": "Currency", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/currencies.Currency" + } + } + } + } + }, + "/v1/groups": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Group" + ], + "summary": "Get Group", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.Group" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Group" + ], + "summary": "Update Group", + "parameters": [ + { + "description": "User Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.GroupUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.Group" + } + } + } + } + }, + "/v1/groups/invitations": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Group" + ], + "summary": "Create Group Invitation", + "parameters": [ + { + "description": "User Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.GroupInvitationCreate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.GroupInvitation" + } + } + } + } + }, + "/v1/groups/statistics": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Statistics" + ], + "summary": "Get Group Statistics", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.GroupStatistics" + } + } + } + } + }, + "/v1/groups/statistics/labels": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Statistics" + ], + "summary": "Get Label Statistics", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.TotalsByOrganizer" + } + } + } + } + } + }, + "/v1/groups/statistics/locations": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Statistics" + ], + "summary": "Get Location Statistics", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.TotalsByOrganizer" + } + } + } + } + } + }, + "/v1/groups/statistics/purchase-price": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Statistics" + ], + "summary": "Get Purchase Price Statistics", + "parameters": [ + { + "type": "string", + "description": "start date", + "name": "start", + "in": "query" + }, + { + "type": "string", + "description": "end date", + "name": "end", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ValueOverTime" + } + } + } + } + }, + "/v1/items": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Query All Items", + "parameters": [ + { + "type": "string", + "description": "search string", + "name": "q", + "in": "query" + }, + { + "type": "integer", + "description": "page number", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "items per page", + "name": "pageSize", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "label Ids", + "name": "labels", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "location Ids", + "name": "locations", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "parent Ids", + "name": "parentIds", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.PaginationResult-repo_ItemSummary" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Create Item", + "parameters": [ + { + "description": "Item Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemCreate" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.ItemSummary" + } + } + } + } + }, + "/v1/items/export": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Items" + ], + "summary": "Export Items", + "responses": { + "200": { + "description": "text/csv", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/items/fields": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get All Custom Field Names", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + }, + "/v1/items/fields/values": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get All Custom Field Values", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + }, + "/v1/items/import": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Import Items", + "parameters": [ + { + "type": "file", + "description": "Image to upload", + "name": "csv", + "in": "formData", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/items/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get Item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Update Item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Item Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Delete Item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + }, + "patch": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Update Item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Item Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemPatch" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + } + }, + "/v1/items/{id}/attachments": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items Attachments" + ], + "summary": "Create Item Attachment", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "file", + "description": "File attachment", + "name": "file", + "in": "formData", + "required": true + }, + { + "type": "string", + "description": "Type of file", + "name": "type", + "in": "formData" + }, + { + "type": "boolean", + "description": "Is this the primary attachment", + "name": "primary", + "in": "formData" + }, + { + "type": "string", + "description": "name of the file including extension", + "name": "name", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + }, + "422": { + "description": "Unprocessable Entity", + "schema": { + "$ref": "#/definitions/validate.ErrorResponse" + } + } + } + } + }, + "/v1/items/{id}/attachments/{attachment_id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/octet-stream" + ], + "tags": [ + "Items Attachments" + ], + "summary": "Get Item Attachment", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Attachment ID", + "name": "attachment_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ItemAttachmentToken" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Items Attachments" + ], + "summary": "Update Item Attachment", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Attachment ID", + "name": "attachment_id", + "in": "path", + "required": true + }, + { + "description": "Attachment Update", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemAttachmentUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Items Attachments" + ], + "summary": "Delete Item Attachment", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Attachment ID", + "name": "attachment_id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/items/{id}/duplicate": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Duplicate Item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Duplicate Options", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.DuplicateOptions" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + } + }, + "/v1/items/{id}/maintenance": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Maintenance" + ], + "summary": "Get Maintenance Log", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "enum": [ + "scheduled", + "completed", + "both" + ], + "type": "string", + "x-enum-varnames": [ + "MaintenanceFilterStatusScheduled", + "MaintenanceFilterStatusCompleted", + "MaintenanceFilterStatusBoth" + ], + "name": "status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.MaintenanceEntryWithDetails" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Maintenance" + ], + "summary": "Create Maintenance Entry", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Entry Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.MaintenanceEntryCreate" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.MaintenanceEntry" + } + } + } + } + }, + "/v1/items/{id}/path": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get the full path of an item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemPath" + } + } + } + } + } + }, + "/v1/labelmaker/assets/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get Asset label", + "parameters": [ + { + "type": "string", + "description": "Asset ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "Print this label, defaults to false", + "name": "print", + "in": "query" + } + ], + "responses": { + "200": { + "description": "image/png", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/labelmaker/item/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get Item label", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "Print this label, defaults to false", + "name": "print", + "in": "query" + } + ], + "responses": { + "200": { + "description": "image/png", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/labelmaker/location/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Get Location label", + "parameters": [ + { + "type": "string", + "description": "Location ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "Print this label, defaults to false", + "name": "print", + "in": "query" + } + ], + "responses": { + "200": { + "description": "image/png", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/labels": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Labels" + ], + "summary": "Get All Labels", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.LabelOut" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Labels" + ], + "summary": "Create Label", + "parameters": [ + { + "description": "Label Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.LabelCreate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LabelSummary" + } + } + } + } + }, + "/v1/labels/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Labels" + ], + "summary": "Get Label", + "parameters": [ + { + "type": "string", + "description": "Label ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LabelOut" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Labels" + ], + "summary": "Update Label", + "parameters": [ + { + "type": "string", + "description": "Label ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LabelOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Labels" + ], + "summary": "Delete Label", + "parameters": [ + { + "type": "string", + "description": "Label ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/locations": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Get All Locations", + "parameters": [ + { + "type": "boolean", + "description": "Filter locations with parents", + "name": "filterChildren", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.LocationOutCount" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Create Location", + "parameters": [ + { + "description": "Location Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.LocationCreate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LocationSummary" + } + } + } + } + }, + "/v1/locations/tree": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Get Locations Tree", + "parameters": [ + { + "type": "boolean", + "description": "include items in response tree", + "name": "withItems", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.TreeItem" + } + } + } + } + } + }, + "/v1/locations/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Get Location", + "parameters": [ + { + "type": "string", + "description": "Location ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LocationOut" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Update Location", + "parameters": [ + { + "type": "string", + "description": "Location ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Location Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.LocationUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LocationOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Delete Location", + "parameters": [ + { + "type": "string", + "description": "Location ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/maintenance": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Maintenance" + ], + "summary": "Query All Maintenance", + "parameters": [ + { + "enum": [ + "scheduled", + "completed", + "both" + ], + "type": "string", + "x-enum-varnames": [ + "MaintenanceFilterStatusScheduled", + "MaintenanceFilterStatusCompleted", + "MaintenanceFilterStatusBoth" + ], + "name": "status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.MaintenanceEntryWithDetails" + } + } + } + } + } + }, + "/v1/maintenance/{id}": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Maintenance" + ], + "summary": "Update Maintenance Entry", + "parameters": [ + { + "type": "string", + "description": "Maintenance ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Entry Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.MaintenanceEntryUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.MaintenanceEntry" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Maintenance" + ], + "summary": "Delete Maintenance Entry", + "parameters": [ + { + "type": "string", + "description": "Maintenance ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/notifiers": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Notifiers" + ], + "summary": "Get Notifiers", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.NotifierOut" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Notifiers" + ], + "summary": "Create Notifier", + "parameters": [ + { + "description": "Notifier Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.NotifierCreate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.NotifierOut" + } + } + } + } + }, + "/v1/notifiers/test": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Notifiers" + ], + "summary": "Test Notifier", + "parameters": [ + { + "type": "string", + "description": "URL", + "name": "url", + "in": "query", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/notifiers/{id}": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Notifiers" + ], + "summary": "Update Notifier", + "parameters": [ + { + "type": "string", + "description": "Notifier ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Notifier Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.NotifierUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.NotifierOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Notifiers" + ], + "summary": "Delete a Notifier", + "parameters": [ + { + "type": "string", + "description": "Notifier ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/products/search-from-barcode": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Search EAN from Barcode", + "parameters": [ + { + "type": "string", + "description": "barcode to be searched", + "name": "data", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.BarcodeProduct" + } + } + } + } + } + }, + "/v1/qrcode": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Create QR Code", + "parameters": [ + { + "type": "string", + "description": "data to be encoded into qrcode", + "name": "data", + "in": "query" + } + ], + "responses": { + "200": { + "description": "image/jpeg", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/reporting/bill-of-materials": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Reporting" + ], + "summary": "Export Bill of Materials", + "responses": { + "200": { + "description": "text/csv", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/status": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "Base" + ], + "summary": "Application Info", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.APISummary" + } + } + } + } + }, + "/v1/templates": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Get All Item Templates", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemTemplateSummary" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Create Item Template", + "parameters": [ + { + "description": "Template Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemTemplateCreate" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.ItemTemplateOut" + } + } + } + } + }, + "/v1/templates/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Get Item Template", + "parameters": [ + { + "type": "string", + "description": "Template ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemTemplateOut" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Update Item Template", + "parameters": [ + { + "type": "string", + "description": "Template ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Template Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemTemplateUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemTemplateOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Delete Item Template", + "parameters": [ + { + "type": "string", + "description": "Template ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/templates/{id}/create-item": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Create Item from Template", + "parameters": [ + { + "type": "string", + "description": "Template ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Item Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.ItemTemplateCreateItemRequest" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + } + }, + "/v1/users/change-password": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "User" + ], + "summary": "Change Password", + "parameters": [ + { + "description": "Password Payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.ChangePassword" + } + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/users/login": { + "post": { + "consumes": [ + "application/x-www-form-urlencoded", + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Authentication" + ], + "summary": "User Login", + "parameters": [ + { + "description": "Login Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.LoginForm" + } + }, + { + "type": "string", + "description": "auth provider", + "name": "provider", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.TokenResponse" + } + } + } + } + }, + "/v1/users/login/oidc": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "Authentication" + ], + "summary": "OIDC Login Initiation", + "responses": { + "302": { + "description": "Found" + } + } + } + }, + "/v1/users/login/oidc/callback": { + "get": { + "tags": [ + "Authentication" + ], + "summary": "OIDC Callback Handler", + "parameters": [ + { + "type": "string", + "description": "Authorization code", + "name": "code", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "State parameter", + "name": "state", + "in": "query", + "required": true + } + ], + "responses": { + "302": { + "description": "Found" + } + } + } + }, + "/v1/users/logout": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Authentication" + ], + "summary": "User Logout", + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/users/refresh": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "handleAuthRefresh returns a handler that will issue a new token from an existing token.\nThis does not validate that the user still exists within the database.", + "tags": [ + "Authentication" + ], + "summary": "User Token Refresh", + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/v1/users/register": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Register New User", + "parameters": [ + { + "description": "User Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/services.UserRegistration" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "403": { + "description": "Local login is not enabled", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/users/self": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Get User Self", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/v1.Wrapped" + }, + { + "type": "object", + "properties": { + "item": { + "$ref": "#/definitions/repo.UserOut" + } + } + } + ] + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Update Account", + "parameters": [ + { + "description": "User Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.UserUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/v1.Wrapped" + }, + { + "type": "object", + "properties": { + "item": { + "$ref": "#/definitions/repo.UserUpdate" + } + } + } + ] + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Delete Account", + "responses": { + "204": { + "description": "No Content" + } + } + } + } + }, + "definitions": { + "attachment.Type": { + "type": "string", + "enum": [ + "attachment", + "photo", + "manual", + "warranty", + "attachment", + "receipt", + "thumbnail" + ], + "x-enum-varnames": [ + "DefaultType", + "TypePhoto", + "TypeManual", + "TypeWarranty", + "TypeAttachment", + "TypeReceipt", + "TypeThumbnail" + ] + }, + "authroles.Role": { + "type": "string", + "enum": [ + "user", + "admin", + "user", + "attachments" + ], + "x-enum-varnames": [ + "DefaultRole", + "RoleAdmin", + "RoleUser", + "RoleAttachments" + ] + }, + "currencies.Currency": { + "type": "object", + "properties": { + "code": { + "type": "string" + }, + "decimals": { + "type": "integer" + }, + "local": { + "type": "string" + }, + "name": { + "type": "string" + }, + "symbol": { + "type": "string" + } + } + }, + "ent.Attachment": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AttachmentQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.AttachmentEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "mime_type": { + "description": "MimeType holds the value of the \"mime_type\" field.", + "type": "string" + }, + "path": { + "description": "Path holds the value of the \"path\" field.", + "type": "string" + }, + "primary": { + "description": "Primary holds the value of the \"primary\" field.", + "type": "boolean" + }, + "title": { + "description": "Title holds the value of the \"title\" field.", + "type": "string" + }, + "type": { + "description": "Type holds the value of the \"type\" field.", + "allOf": [ + { + "$ref": "#/definitions/attachment.Type" + } + ] + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.AttachmentEdges": { + "type": "object", + "properties": { + "item": { + "description": "Item holds the value of the item edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Item" + } + ] + }, + "thumbnail": { + "description": "Thumbnail holds the value of the thumbnail edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Attachment" + } + ] + } + } + }, + "ent.AuthRoles": { + "type": "object", + "properties": { + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AuthRolesQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.AuthRolesEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "integer" + }, + "role": { + "description": "Role holds the value of the \"role\" field.", + "allOf": [ + { + "$ref": "#/definitions/authroles.Role" + } + ] + } + } + }, + "ent.AuthRolesEdges": { + "type": "object", + "properties": { + "token": { + "description": "Token holds the value of the token edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.AuthTokens" + } + ] + } + } + }, + "ent.AuthTokens": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AuthTokensQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.AuthTokensEdges" + } + ] + }, + "expires_at": { + "description": "ExpiresAt holds the value of the \"expires_at\" field.", + "type": "string" + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "token": { + "description": "Token holds the value of the \"token\" field.", + "type": "array", + "items": { + "type": "integer" + } + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.AuthTokensEdges": { + "type": "object", + "properties": { + "roles": { + "description": "Roles holds the value of the roles edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.AuthRoles" + } + ] + }, + "user": { + "description": "User holds the value of the user edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.User" + } + ] + } + } + }, + "ent.Group": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "currency": { + "description": "Currency holds the value of the \"currency\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the GroupQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.GroupEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.GroupEdges": { + "type": "object", + "properties": { + "invitation_tokens": { + "description": "InvitationTokens holds the value of the invitation_tokens edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.GroupInvitationToken" + } + }, + "item_templates": { + "description": "ItemTemplates holds the value of the item_templates edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.ItemTemplate" + } + }, + "items": { + "description": "Items holds the value of the items edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Item" + } + }, + "labels": { + "description": "Labels holds the value of the labels edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Label" + } + }, + "locations": { + "description": "Locations holds the value of the locations edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Location" + } + }, + "notifiers": { + "description": "Notifiers holds the value of the notifiers edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Notifier" + } + }, + "users": { + "description": "Users holds the value of the users edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.User" + } + } + } + }, + "ent.GroupInvitationToken": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the GroupInvitationTokenQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.GroupInvitationTokenEdges" + } + ] + }, + "expires_at": { + "description": "ExpiresAt holds the value of the \"expires_at\" field.", + "type": "string" + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "token": { + "description": "Token holds the value of the \"token\" field.", + "type": "array", + "items": { + "type": "integer" + } + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + }, + "uses": { + "description": "Uses holds the value of the \"uses\" field.", + "type": "integer" + } + } + }, + "ent.GroupInvitationTokenEdges": { + "type": "object", + "properties": { + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + } + } + }, + "ent.Item": { + "type": "object", + "properties": { + "archived": { + "description": "Archived holds the value of the \"archived\" field.", + "type": "boolean" + }, + "asset_id": { + "description": "AssetID holds the value of the \"asset_id\" field.", + "type": "integer" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.ItemEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "import_ref": { + "description": "ImportRef holds the value of the \"import_ref\" field.", + "type": "string" + }, + "insured": { + "description": "Insured holds the value of the \"insured\" field.", + "type": "boolean" + }, + "lifetime_warranty": { + "description": "LifetimeWarranty holds the value of the \"lifetime_warranty\" field.", + "type": "boolean" + }, + "manufacturer": { + "description": "Manufacturer holds the value of the \"manufacturer\" field.", + "type": "string" + }, + "model_number": { + "description": "ModelNumber holds the value of the \"model_number\" field.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "notes": { + "description": "Notes holds the value of the \"notes\" field.", + "type": "string" + }, + "purchase_from": { + "description": "PurchaseFrom holds the value of the \"purchase_from\" field.", + "type": "string" + }, + "purchase_price": { + "description": "PurchasePrice holds the value of the \"purchase_price\" field.", + "type": "number" + }, + "purchase_time": { + "description": "PurchaseTime holds the value of the \"purchase_time\" field.", + "type": "string" + }, + "quantity": { + "description": "Quantity holds the value of the \"quantity\" field.", + "type": "integer" + }, + "serial_number": { + "description": "SerialNumber holds the value of the \"serial_number\" field.", + "type": "string" + }, + "sold_notes": { + "description": "SoldNotes holds the value of the \"sold_notes\" field.", + "type": "string" + }, + "sold_price": { + "description": "SoldPrice holds the value of the \"sold_price\" field.", + "type": "number" + }, + "sold_time": { + "description": "SoldTime holds the value of the \"sold_time\" field.", + "type": "string" + }, + "sold_to": { + "description": "SoldTo holds the value of the \"sold_to\" field.", + "type": "string" + }, + "sync_child_items_locations": { + "description": "SyncChildItemsLocations holds the value of the \"sync_child_items_locations\" field.", + "type": "boolean" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + }, + "warranty_details": { + "description": "WarrantyDetails holds the value of the \"warranty_details\" field.", + "type": "string" + }, + "warranty_expires": { + "description": "WarrantyExpires holds the value of the \"warranty_expires\" field.", + "type": "string" + } + } + }, + "ent.ItemEdges": { + "type": "object", + "properties": { + "attachments": { + "description": "Attachments holds the value of the attachments edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Attachment" + } + }, + "children": { + "description": "Children holds the value of the children edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Item" + } + }, + "fields": { + "description": "Fields holds the value of the fields edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.ItemField" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "label": { + "description": "Label holds the value of the label edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Label" + } + }, + "location": { + "description": "Location holds the value of the location edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Location" + } + ] + }, + "maintenance_entries": { + "description": "MaintenanceEntries holds the value of the maintenance_entries edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.MaintenanceEntry" + } + }, + "parent": { + "description": "Parent holds the value of the parent edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Item" + } + ] + } + } + }, + "ent.ItemField": { + "type": "object", + "properties": { + "boolean_value": { + "description": "BooleanValue holds the value of the \"boolean_value\" field.", + "type": "boolean" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemFieldQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.ItemFieldEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "number_value": { + "description": "NumberValue holds the value of the \"number_value\" field.", + "type": "integer" + }, + "text_value": { + "description": "TextValue holds the value of the \"text_value\" field.", + "type": "string" + }, + "time_value": { + "description": "TimeValue holds the value of the \"time_value\" field.", + "type": "string" + }, + "type": { + "description": "Type holds the value of the \"type\" field.", + "allOf": [ + { + "$ref": "#/definitions/itemfield.Type" + } + ] + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.ItemFieldEdges": { + "type": "object", + "properties": { + "item": { + "description": "Item holds the value of the item edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Item" + } + ] + } + } + }, + "ent.ItemTemplate": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "default_description": { + "description": "Default description for items created from this template", + "type": "string" + }, + "default_insured": { + "description": "DefaultInsured holds the value of the \"default_insured\" field.", + "type": "boolean" + }, + "default_label_ids": { + "description": "Default label IDs for items created from this template", + "type": "array", + "items": { + "type": "string" + } + }, + "default_lifetime_warranty": { + "description": "DefaultLifetimeWarranty holds the value of the \"default_lifetime_warranty\" field.", + "type": "boolean" + }, + "default_manufacturer": { + "description": "DefaultManufacturer holds the value of the \"default_manufacturer\" field.", + "type": "string" + }, + "default_model_number": { + "description": "Default model number for items created from this template", + "type": "string" + }, + "default_name": { + "description": "Default name template for items (can use placeholders)", + "type": "string" + }, + "default_quantity": { + "description": "DefaultQuantity holds the value of the \"default_quantity\" field.", + "type": "integer" + }, + "default_warranty_details": { + "description": "DefaultWarrantyDetails holds the value of the \"default_warranty_details\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemTemplateQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.ItemTemplateEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "include_purchase_fields": { + "description": "Whether to include purchase fields in items created from this template", + "type": "boolean" + }, + "include_sold_fields": { + "description": "Whether to include sold fields in items created from this template", + "type": "boolean" + }, + "include_warranty_fields": { + "description": "Whether to include warranty fields in items created from this template", + "type": "boolean" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "notes": { + "description": "Notes holds the value of the \"notes\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.ItemTemplateEdges": { + "type": "object", + "properties": { + "fields": { + "description": "Fields holds the value of the fields edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.TemplateField" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "location": { + "description": "Location holds the value of the location edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Location" + } + ] + } + } + }, + "ent.Label": { + "type": "object", + "properties": { + "color": { + "description": "Color holds the value of the \"color\" field.", + "type": "string" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LabelQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.LabelEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.LabelEdges": { + "type": "object", + "properties": { + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "items": { + "description": "Items holds the value of the items edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Item" + } + } + } + }, + "ent.Location": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LocationQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.LocationEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.LocationEdges": { + "type": "object", + "properties": { + "children": { + "description": "Children holds the value of the children edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Location" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "items": { + "description": "Items holds the value of the items edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Item" + } + }, + "parent": { + "description": "Parent holds the value of the parent edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Location" + } + ] + } + } + }, + "ent.MaintenanceEntry": { + "type": "object", + "properties": { + "cost": { + "description": "Cost holds the value of the \"cost\" field.", + "type": "number" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "date": { + "description": "Date holds the value of the \"date\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the MaintenanceEntryQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.MaintenanceEntryEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "item_id": { + "description": "ItemID holds the value of the \"item_id\" field.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "scheduled_date": { + "description": "ScheduledDate holds the value of the \"scheduled_date\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.MaintenanceEntryEdges": { + "type": "object", + "properties": { + "item": { + "description": "Item holds the value of the item edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Item" + } + ] + } + } + }, + "ent.Notifier": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the NotifierQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.NotifierEdges" + } + ] + }, + "group_id": { + "description": "GroupID holds the value of the \"group_id\" field.", + "type": "string" + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "is_active": { + "description": "IsActive holds the value of the \"is_active\" field.", + "type": "boolean" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + }, + "user_id": { + "description": "UserID holds the value of the \"user_id\" field.", + "type": "string" + } + } + }, + "ent.NotifierEdges": { + "type": "object", + "properties": { + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "user": { + "description": "User holds the value of the user edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.User" + } + ] + } + } + }, + "ent.TemplateField": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the TemplateFieldQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.TemplateFieldEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "text_value": { + "description": "TextValue holds the value of the \"text_value\" field.", + "type": "string" + }, + "type": { + "description": "Type holds the value of the \"type\" field.", + "allOf": [ + { + "$ref": "#/definitions/templatefield.Type" + } + ] + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.TemplateFieldEdges": { + "type": "object", + "properties": { + "item_template": { + "description": "ItemTemplate holds the value of the item_template edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.ItemTemplate" + } + ] + } + } + }, + "ent.User": { + "type": "object", + "properties": { + "activated_on": { + "description": "ActivatedOn holds the value of the \"activated_on\" field.", + "type": "string" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the UserQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.UserEdges" + } + ] + }, + "email": { + "description": "Email holds the value of the \"email\" field.", + "type": "string" + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "is_superuser": { + "description": "IsSuperuser holds the value of the \"is_superuser\" field.", + "type": "boolean" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "oidc_issuer": { + "description": "OidcIssuer holds the value of the \"oidc_issuer\" field.", + "type": "string" + }, + "oidc_subject": { + "description": "OidcSubject holds the value of the \"oidc_subject\" field.", + "type": "string" + }, + "role": { + "description": "Role holds the value of the \"role\" field.", + "allOf": [ + { + "$ref": "#/definitions/user.Role" + } + ] + }, + "superuser": { + "description": "Superuser holds the value of the \"superuser\" field.", + "type": "boolean" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.UserEdges": { + "type": "object", + "properties": { + "auth_tokens": { + "description": "AuthTokens holds the value of the auth_tokens edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.AuthTokens" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "notifiers": { + "description": "Notifiers holds the value of the notifiers edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Notifier" + } + } + } + }, + "itemfield.Type": { + "type": "string", + "enum": [ + "text", + "number", + "boolean", + "time" + ], + "x-enum-varnames": [ + "TypeText", + "TypeNumber", + "TypeBoolean", + "TypeTime" + ] + }, + "repo.BarcodeProduct": { + "type": "object", + "properties": { + "barcode": { + "type": "string" + }, + "imageBase64": { + "type": "string" + }, + "imageURL": { + "type": "string" + }, + "item": { + "$ref": "#/definitions/repo.ItemCreate" + }, + "manufacturer": { + "type": "string" + }, + "modelNumber": { + "description": "Identifications", + "type": "string" + }, + "notes": { + "description": "Extras", + "type": "string" + }, + "search_engine_name": { + "type": "string" + } + } + }, + "repo.DuplicateOptions": { + "type": "object", + "properties": { + "copyAttachments": { + "type": "boolean" + }, + "copyCustomFields": { + "type": "boolean" + }, + "copyMaintenance": { + "type": "boolean" + }, + "copyPrefix": { + "type": "string" + } + } + }, + "repo.Group": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "currency": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.GroupStatistics": { + "type": "object", + "properties": { + "totalItemPrice": { + "type": "number" + }, + "totalItems": { + "type": "integer" + }, + "totalLabels": { + "type": "integer" + }, + "totalLocations": { + "type": "integer" + }, + "totalUsers": { + "type": "integer" + }, + "totalWithWarranty": { + "type": "integer" + } + } + }, + "repo.GroupUpdate": { + "type": "object", + "properties": { + "currency": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "repo.ItemAttachment": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "id": { + "type": "string" + }, + "mimeType": { + "type": "string" + }, + "path": { + "type": "string" + }, + "primary": { + "type": "boolean" + }, + "thumbnail": { + "$ref": "#/definitions/ent.Attachment" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemAttachmentUpdate": { + "type": "object", + "properties": { + "primary": { + "type": "boolean" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.ItemCreate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "description": { + "type": "string", + "maxLength": 1000 + }, + "labelIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "locationId": { + "description": "Edges", + "type": "string" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "parentId": { + "type": "string", + "x-nullable": true + }, + "quantity": { + "type": "integer" + } + } + }, + "repo.ItemField": { + "type": "object", + "properties": { + "booleanValue": { + "type": "boolean" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "numberValue": { + "type": "integer" + }, + "textValue": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.ItemOut": { + "type": "object", + "properties": { + "archived": { + "type": "boolean" + }, + "assetId": { + "type": "string", + "example": "0" + }, + "attachments": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemAttachment" + } + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemField" + } + }, + "id": { + "type": "string" + }, + "imageId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "insured": { + "type": "boolean" + }, + "labels": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.LabelSummary" + } + }, + "lifetimeWarranty": { + "description": "Warranty", + "type": "boolean" + }, + "location": { + "description": "Edges", + "allOf": [ + { + "$ref": "#/definitions/repo.LocationSummary" + } + ], + "x-nullable": true, + "x-omitempty": true + }, + "manufacturer": { + "type": "string" + }, + "modelNumber": { + "type": "string" + }, + "name": { + "type": "string" + }, + "notes": { + "description": "Extras", + "type": "string" + }, + "parent": { + "allOf": [ + { + "$ref": "#/definitions/repo.ItemSummary" + } + ], + "x-nullable": true, + "x-omitempty": true + }, + "purchaseFrom": { + "type": "string" + }, + "purchasePrice": { + "type": "number" + }, + "purchaseTime": { + "description": "Purchase", + "type": "string" + }, + "quantity": { + "type": "integer" + }, + "serialNumber": { + "type": "string" + }, + "soldNotes": { + "type": "string" + }, + "soldPrice": { + "type": "number" + }, + "soldTime": { + "description": "Sold", + "type": "string" + }, + "soldTo": { + "type": "string" + }, + "syncChildItemsLocations": { + "type": "boolean" + }, + "thumbnailId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "updatedAt": { + "type": "string" + }, + "warrantyDetails": { + "type": "string" + }, + "warrantyExpires": { + "type": "string" + } + } + }, + "repo.ItemPatch": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "labelIds": { + "type": "array", + "items": { + "type": "string" + }, + "x-nullable": true, + "x-omitempty": true + }, + "locationId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "quantity": { + "type": "integer", + "x-nullable": true, + "x-omitempty": true + } + } + }, + "repo.ItemPath": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "type": { + "$ref": "#/definitions/repo.ItemType" + } + } + }, + "repo.ItemSummary": { + "type": "object", + "properties": { + "archived": { + "type": "boolean" + }, + "assetId": { + "type": "string", + "example": "0" + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "imageId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "insured": { + "type": "boolean" + }, + "labels": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.LabelSummary" + } + }, + "location": { + "description": "Edges", + "allOf": [ + { + "$ref": "#/definitions/repo.LocationSummary" + } + ], + "x-nullable": true, + "x-omitempty": true + }, + "name": { + "type": "string" + }, + "purchasePrice": { + "type": "number" + }, + "quantity": { + "type": "integer" + }, + "soldTime": { + "description": "Sale details", + "type": "string" + }, + "thumbnailId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemTemplateCreate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "defaultDescription": { + "type": "string", + "maxLength": 1000, + "x-nullable": true + }, + "defaultInsured": { + "type": "boolean" + }, + "defaultLabelIds": { + "type": "array", + "items": { + "type": "string" + }, + "x-nullable": true + }, + "defaultLifetimeWarranty": { + "type": "boolean" + }, + "defaultLocationId": { + "description": "Default location and labels", + "type": "string", + "x-nullable": true + }, + "defaultManufacturer": { + "type": "string", + "maxLength": 255, + "x-nullable": true + }, + "defaultModelNumber": { + "type": "string", + "maxLength": 255, + "x-nullable": true + }, + "defaultName": { + "type": "string", + "maxLength": 255, + "x-nullable": true + }, + "defaultQuantity": { + "description": "Default values for items", + "type": "integer", + "x-nullable": true + }, + "defaultWarrantyDetails": { + "type": "string", + "maxLength": 1000, + "x-nullable": true + }, + "description": { + "type": "string", + "maxLength": 1000 + }, + "fields": { + "description": "Custom fields", + "type": "array", + "items": { + "$ref": "#/definitions/repo.TemplateField" + } + }, + "includePurchaseFields": { + "type": "boolean" + }, + "includeSoldFields": { + "type": "boolean" + }, + "includeWarrantyFields": { + "description": "Metadata flags", + "type": "boolean" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "notes": { + "type": "string", + "maxLength": 1000 + } + } + }, + "repo.ItemTemplateOut": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "defaultDescription": { + "type": "string" + }, + "defaultInsured": { + "type": "boolean" + }, + "defaultLabels": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.TemplateLabelSummary" + } + }, + "defaultLifetimeWarranty": { + "type": "boolean" + }, + "defaultLocation": { + "description": "Default location and labels", + "allOf": [ + { + "$ref": "#/definitions/repo.TemplateLocationSummary" + } + ] + }, + "defaultManufacturer": { + "type": "string" + }, + "defaultModelNumber": { + "type": "string" + }, + "defaultName": { + "type": "string" + }, + "defaultQuantity": { + "description": "Default values for items", + "type": "integer" + }, + "defaultWarrantyDetails": { + "type": "string" + }, + "description": { + "type": "string" + }, + "fields": { + "description": "Custom fields", + "type": "array", + "items": { + "$ref": "#/definitions/repo.TemplateField" + } + }, + "id": { + "type": "string" + }, + "includePurchaseFields": { + "type": "boolean" + }, + "includeSoldFields": { + "type": "boolean" + }, + "includeWarrantyFields": { + "description": "Metadata flags", + "type": "boolean" + }, + "name": { + "type": "string" + }, + "notes": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemTemplateSummary": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemTemplateUpdate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "defaultDescription": { + "type": "string", + "maxLength": 1000, + "x-nullable": true + }, + "defaultInsured": { + "type": "boolean" + }, + "defaultLabelIds": { + "type": "array", + "items": { + "type": "string" + }, + "x-nullable": true + }, + "defaultLifetimeWarranty": { + "type": "boolean" + }, + "defaultLocationId": { + "description": "Default location and labels", + "type": "string", + "x-nullable": true + }, + "defaultManufacturer": { + "type": "string", + "maxLength": 255, + "x-nullable": true + }, + "defaultModelNumber": { + "type": "string", + "maxLength": 255, + "x-nullable": true + }, + "defaultName": { + "type": "string", + "maxLength": 255, + "x-nullable": true + }, + "defaultQuantity": { + "description": "Default values for items", + "type": "integer", + "x-nullable": true + }, + "defaultWarrantyDetails": { + "type": "string", + "maxLength": 1000, + "x-nullable": true + }, + "description": { + "type": "string", + "maxLength": 1000 + }, + "fields": { + "description": "Custom fields", + "type": "array", + "items": { + "$ref": "#/definitions/repo.TemplateField" + } + }, + "id": { + "type": "string" + }, + "includePurchaseFields": { + "type": "boolean" + }, + "includeSoldFields": { + "type": "boolean" + }, + "includeWarrantyFields": { + "description": "Metadata flags", + "type": "boolean" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "notes": { + "type": "string", + "maxLength": 1000 + } + } + }, + "repo.ItemType": { + "type": "string", + "enum": [ + "location", + "item" + ], + "x-enum-varnames": [ + "ItemTypeLocation", + "ItemTypeItem" + ] + }, + "repo.ItemUpdate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "archived": { + "type": "boolean" + }, + "assetId": { + "type": "string" + }, + "description": { + "type": "string", + "maxLength": 1000 + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemField" + } + }, + "id": { + "type": "string" + }, + "insured": { + "type": "boolean" + }, + "labelIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "lifetimeWarranty": { + "description": "Warranty", + "type": "boolean" + }, + "locationId": { + "description": "Edges", + "type": "string" + }, + "manufacturer": { + "type": "string" + }, + "modelNumber": { + "type": "string" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "notes": { + "description": "Extras", + "type": "string" + }, + "parentId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "purchaseFrom": { + "type": "string", + "maxLength": 255 + }, + "purchasePrice": { + "type": "number", + "x-nullable": true, + "x-omitempty": true + }, + "purchaseTime": { + "description": "Purchase", + "type": "string" + }, + "quantity": { + "type": "integer" + }, + "serialNumber": { + "description": "Identifications", + "type": "string" + }, + "soldNotes": { + "type": "string" + }, + "soldPrice": { + "type": "number", + "x-nullable": true, + "x-omitempty": true + }, + "soldTime": { + "description": "Sold", + "type": "string" + }, + "soldTo": { + "type": "string", + "maxLength": 255 + }, + "syncChildItemsLocations": { + "type": "boolean" + }, + "warrantyDetails": { + "type": "string" + }, + "warrantyExpires": { + "type": "string" + } + } + }, + "repo.LabelCreate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "color": { + "type": "string" + }, + "description": { + "type": "string", + "maxLength": 1000 + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + } + } + }, + "repo.LabelOut": { + "type": "object", + "properties": { + "color": { + "type": "string" + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.LabelSummary": { + "type": "object", + "properties": { + "color": { + "type": "string" + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.LocationCreate": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "parentId": { + "type": "string", + "x-nullable": true + } + } + }, + "repo.LocationOut": { + "type": "object", + "properties": { + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.LocationSummary" + } + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "parent": { + "$ref": "#/definitions/repo.LocationSummary" + }, + "totalPrice": { + "type": "number" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.LocationOutCount": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "itemCount": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.LocationSummary": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.LocationUpdate": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "parentId": { + "type": "string", + "x-nullable": true + } + } + }, + "repo.MaintenanceEntry": { + "type": "object", + "properties": { + "completedDate": { + "type": "string" + }, + "cost": { + "type": "string", + "example": "0" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "scheduledDate": { + "type": "string" + } + } + }, + "repo.MaintenanceEntryCreate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "completedDate": { + "type": "string" + }, + "cost": { + "type": "string", + "example": "0" + }, + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "scheduledDate": { + "type": "string" + } + } + }, + "repo.MaintenanceEntryUpdate": { + "type": "object", + "properties": { + "completedDate": { + "type": "string" + }, + "cost": { + "type": "string", + "example": "0" + }, + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "scheduledDate": { + "type": "string" + } + } + }, + "repo.MaintenanceEntryWithDetails": { + "type": "object", + "properties": { + "completedDate": { + "type": "string" + }, + "cost": { + "type": "string", + "example": "0" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "itemID": { + "type": "string" + }, + "itemName": { + "type": "string" + }, + "name": { + "type": "string" + }, + "scheduledDate": { + "type": "string" + } + } + }, + "repo.MaintenanceFilterStatus": { + "type": "string", + "enum": [ + "scheduled", + "completed", + "both" + ], + "x-enum-varnames": [ + "MaintenanceFilterStatusScheduled", + "MaintenanceFilterStatusCompleted", + "MaintenanceFilterStatusBoth" + ] + }, + "repo.NotifierCreate": { + "type": "object", + "required": [ + "name", + "url" + ], + "properties": { + "isActive": { + "type": "boolean" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "url": { + "type": "string" + } + } + }, + "repo.NotifierOut": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "groupId": { + "type": "string" + }, + "id": { + "type": "string" + }, + "isActive": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + }, + "url": { + "type": "string" + }, + "userId": { + "type": "string" + } + } + }, + "repo.NotifierUpdate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "isActive": { + "type": "boolean" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "url": { + "type": "string", + "x-nullable": true + } + } + }, + "repo.PaginationResult-repo_ItemSummary": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemSummary" + } + }, + "page": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + }, + "total": { + "type": "integer" + } + } + }, + "repo.TemplateField": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "textValue": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.TemplateLabelSummary": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "repo.TemplateLocationSummary": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "repo.TotalsByOrganizer": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "total": { + "type": "number" + } + } + }, + "repo.TreeItem": { + "type": "object", + "properties": { + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.TreeItem" + } + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.UserOut": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "groupId": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "id": { + "type": "string" + }, + "isOwner": { + "type": "boolean" + }, + "isSuperuser": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "oidcIssuer": { + "type": "string" + }, + "oidcSubject": { + "type": "string" + } + } + }, + "repo.UserUpdate": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "repo.ValueOverTime": { + "type": "object", + "properties": { + "end": { + "type": "string" + }, + "entries": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ValueOverTimeEntry" + } + }, + "start": { + "type": "string" + }, + "valueAtEnd": { + "type": "number" + }, + "valueAtStart": { + "type": "number" + } + } + }, + "repo.ValueOverTimeEntry": { + "type": "object", + "properties": { + "date": { + "type": "string" + }, + "name": { + "type": "string" + }, + "value": { + "type": "number" + } + } + }, + "services.Latest": { + "type": "object", + "properties": { + "date": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, + "services.UserRegistration": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "name": { + "type": "string" + }, + "password": { + "type": "string" + }, + "token": { + "type": "string" + } + } + }, + "templatefield.Type": { + "type": "string", + "enum": [ + "text" + ], + "x-enum-varnames": [ + "TypeText" + ] + }, + "user.Role": { + "type": "string", + "enum": [ + "user", + "user", + "owner" + ], + "x-enum-varnames": [ + "DefaultRole", + "RoleUser", + "RoleOwner" + ] + }, + "v1.APISummary": { + "type": "object", + "properties": { + "allowRegistration": { + "type": "boolean" + }, + "build": { + "$ref": "#/definitions/v1.Build" + }, + "demo": { + "type": "boolean" + }, + "health": { + "type": "boolean" + }, + "labelPrinting": { + "type": "boolean" + }, + "latest": { + "$ref": "#/definitions/services.Latest" + }, + "message": { + "type": "string" + }, + "oidc": { + "$ref": "#/definitions/v1.OIDCStatus" + }, + "title": { + "type": "string" + }, + "versions": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "v1.ActionAmountResult": { + "type": "object", + "properties": { + "completed": { + "type": "integer" + } + } + }, + "v1.Build": { + "type": "object", + "properties": { + "buildTime": { + "type": "string" + }, + "commit": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, + "v1.ChangePassword": { + "type": "object", + "properties": { + "current": { + "type": "string" + }, + "new": { + "type": "string" + } + } + }, + "v1.GroupInvitation": { + "type": "object", + "properties": { + "expiresAt": { + "type": "string" + }, + "token": { + "type": "string" + }, + "uses": { + "type": "integer" + } + } + }, + "v1.GroupInvitationCreate": { + "type": "object", + "required": [ + "uses" + ], + "properties": { + "expiresAt": { + "type": "string" + }, + "uses": { + "type": "integer", + "maximum": 100, + "minimum": 1 + } + } + }, + "v1.ItemAttachmentToken": { + "type": "object", + "properties": { + "token": { + "type": "string" + } + } + }, + "v1.ItemTemplateCreateItemRequest": { + "type": "object", + "required": [ + "locationId", + "name" + ], + "properties": { + "description": { + "type": "string", + "maxLength": 1000 + }, + "labelIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "locationId": { + "type": "string" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "quantity": { + "type": "integer" + } + } + }, + "v1.LoginForm": { + "type": "object", + "properties": { + "password": { + "type": "string", + "example": "admin" + }, + "stayLoggedIn": { + "type": "boolean" + }, + "username": { + "type": "string", + "example": "admin@admin.com" + } + } + }, + "v1.OIDCStatus": { + "type": "object", + "properties": { + "allowLocal": { + "type": "boolean" + }, + "autoRedirect": { + "type": "boolean" + }, + "buttonText": { + "type": "string" + }, + "enabled": { + "type": "boolean" + } + } + }, + "v1.TokenResponse": { + "type": "object", + "properties": { + "attachmentToken": { + "type": "string" + }, + "expiresAt": { + "type": "string" + }, + "token": { + "type": "string" + } + } + }, + "v1.Wrapped": { + "type": "object", + "properties": { + "item": {} + } + }, + "validate.ErrorResponse": { + "type": "object", + "properties": { + "error": { + "type": "string" + }, + "fields": { + "type": "string" + } + } + } + }, + "securityDefinitions": { + "Bearer": { + "description": "\"Type 'Bearer TOKEN' to correctly set the API Key\"", + "type": "apiKey", + "name": "Authorization", + "in": "header" + } + } +} \ No newline at end of file diff --git a/backend/app/api/static/docs/swagger.yaml b/backend/app/api/static/docs/swagger.yaml index 2e123553..d18a8f45 100644 --- a/backend/app/api/static/docs/swagger.yaml +++ b/backend/app/api/static/docs/swagger.yaml @@ -79,10 +79,10 @@ definitions: type: object ent.AttachmentEdges: properties: - entity: + item: allOf: - - $ref: '#/definitions/ent.Entity' - description: Entity holds the value of the entity edge. + - $ref: '#/definitions/ent.Item' + description: Item holds the value of the item edge. thumbnail: allOf: - $ref: '#/definitions/ent.Attachment' @@ -148,7 +148,105 @@ definitions: - $ref: '#/definitions/ent.User' description: User holds the value of the user edge. type: object - ent.Entity: + ent.Group: + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + currency: + description: Currency holds the value of the "currency" field. + type: string + edges: + allOf: + - $ref: '#/definitions/ent.GroupEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the GroupQuery when eager-loading is set. + id: + description: ID of the ent. + type: string + name: + description: Name holds the value of the "name" field. + type: string + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + type: object + ent.GroupEdges: + properties: + invitation_tokens: + description: InvitationTokens holds the value of the invitation_tokens edge. + items: + $ref: '#/definitions/ent.GroupInvitationToken' + type: array + item_templates: + description: ItemTemplates holds the value of the item_templates edge. + items: + $ref: '#/definitions/ent.ItemTemplate' + type: array + items: + description: Items holds the value of the items edge. + items: + $ref: '#/definitions/ent.Item' + type: array + labels: + description: Labels holds the value of the labels edge. + items: + $ref: '#/definitions/ent.Label' + type: array + locations: + description: Locations holds the value of the locations edge. + items: + $ref: '#/definitions/ent.Location' + type: array + notifiers: + description: Notifiers holds the value of the notifiers edge. + items: + $ref: '#/definitions/ent.Notifier' + type: array + users: + description: Users holds the value of the users edge. + items: + $ref: '#/definitions/ent.User' + type: array + type: object + ent.GroupInvitationToken: + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + edges: + allOf: + - $ref: '#/definitions/ent.GroupInvitationTokenEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the GroupInvitationTokenQuery when eager-loading is set. + expires_at: + description: ExpiresAt holds the value of the "expires_at" field. + type: string + id: + description: ID of the ent. + type: string + token: + description: Token holds the value of the "token" field. + items: + type: integer + type: array + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + uses: + description: Uses holds the value of the "uses" field. + type: integer + type: object + ent.GroupInvitationTokenEdges: + properties: + group: + allOf: + - $ref: '#/definitions/ent.Group' + description: Group holds the value of the group edge. + type: object + ent.Item: properties: archived: description: Archived holds the value of the "archived" field. @@ -164,10 +262,10 @@ definitions: type: string edges: allOf: - - $ref: '#/definitions/ent.EntityEdges' + - $ref: '#/definitions/ent.ItemEdges' description: |- Edges holds the relations/edges for other nodes in the graph. - The values are being populated by the EntityQuery when eager-loading is set. + The values are being populated by the ItemQuery when eager-loading is set. id: description: ID of the ent. type: string @@ -219,8 +317,8 @@ definitions: sold_to: description: SoldTo holds the value of the "sold_to" field. type: string - sync_child_entities_locations: - description: SyncChildEntitiesLocations holds the value of the "sync_child_entities_locations" + sync_child_items_locations: + description: SyncChildItemsLocations holds the value of the "sync_child_items_locations" field. type: boolean updated_at: @@ -233,7 +331,7 @@ definitions: description: WarrantyExpires holds the value of the "warranty_expires" field. type: string type: object - ent.EntityEdges: + ent.ItemEdges: properties: attachments: description: Attachments holds the value of the attachments edge. @@ -243,17 +341,12 @@ definitions: children: description: Children holds the value of the children edge. items: - $ref: '#/definitions/ent.Entity' - type: array - entity: - description: Entity holds the value of the entity edge. - items: - $ref: '#/definitions/ent.Entity' + $ref: '#/definitions/ent.Item' type: array fields: description: Fields holds the value of the fields edge. items: - $ref: '#/definitions/ent.EntityField' + $ref: '#/definitions/ent.ItemField' type: array group: allOf: @@ -266,7 +359,7 @@ definitions: type: array location: allOf: - - $ref: '#/definitions/ent.Entity' + - $ref: '#/definitions/ent.Location' description: Location holds the value of the location edge. maintenance_entries: description: MaintenanceEntries holds the value of the maintenance_entries @@ -276,14 +369,10 @@ definitions: type: array parent: allOf: - - $ref: '#/definitions/ent.Entity' + - $ref: '#/definitions/ent.Item' description: Parent holds the value of the parent edge. - type: - allOf: - - $ref: '#/definitions/ent.EntityType' - description: Type holds the value of the type edge. type: object - ent.EntityField: + ent.ItemField: properties: boolean_value: description: BooleanValue holds the value of the "boolean_value" field. @@ -296,10 +385,10 @@ definitions: type: string edges: allOf: - - $ref: '#/definitions/ent.EntityFieldEdges' + - $ref: '#/definitions/ent.ItemFieldEdges' description: |- Edges holds the relations/edges for other nodes in the graph. - The values are being populated by the EntityFieldQuery when eager-loading is set. + The values are being populated by the ItemFieldQuery when eager-loading is set. id: description: ID of the ent. type: string @@ -317,156 +406,104 @@ definitions: type: string type: allOf: - - $ref: '#/definitions/entityfield.Type' + - $ref: '#/definitions/itemfield.Type' description: Type holds the value of the "type" field. updated_at: description: UpdatedAt holds the value of the "updated_at" field. type: string type: object - ent.EntityFieldEdges: + ent.ItemFieldEdges: properties: - entity: + item: allOf: - - $ref: '#/definitions/ent.Entity' - description: Entity holds the value of the entity edge. + - $ref: '#/definitions/ent.Item' + description: Item holds the value of the item edge. type: object - ent.EntityType: + ent.ItemTemplate: properties: - color: - description: Color holds the value of the "color" field. - type: string created_at: description: CreatedAt holds the value of the "created_at" field. type: string + default_description: + description: Default description for items created from this template + type: string + default_insured: + description: DefaultInsured holds the value of the "default_insured" field. + type: boolean + default_label_ids: + description: Default label IDs for items created from this template + items: + type: string + type: array + default_lifetime_warranty: + description: DefaultLifetimeWarranty holds the value of the "default_lifetime_warranty" + field. + type: boolean + default_manufacturer: + description: DefaultManufacturer holds the value of the "default_manufacturer" + field. + type: string + default_model_number: + description: Default model number for items created from this template + type: string + default_name: + description: Default name template for items (can use placeholders) + type: string + default_quantity: + description: DefaultQuantity holds the value of the "default_quantity" field. + type: integer + default_warranty_details: + description: DefaultWarrantyDetails holds the value of the "default_warranty_details" + field. + type: string description: description: Description holds the value of the "description" field. type: string edges: allOf: - - $ref: '#/definitions/ent.EntityTypeEdges' + - $ref: '#/definitions/ent.ItemTemplateEdges' description: |- Edges holds the relations/edges for other nodes in the graph. - The values are being populated by the EntityTypeQuery when eager-loading is set. - icon: - description: Icon holds the value of the "icon" field. - type: string + The values are being populated by the ItemTemplateQuery when eager-loading is set. id: description: ID of the ent. type: string - is_location: - description: IsLocation holds the value of the "is_location" field. + include_purchase_fields: + description: Whether to include purchase fields in items created from this + template + type: boolean + include_sold_fields: + description: Whether to include sold fields in items created from this template + type: boolean + include_warranty_fields: + description: Whether to include warranty fields in items created from this + template type: boolean name: description: Name holds the value of the "name" field. type: string + notes: + description: Notes holds the value of the "notes" field. + type: string updated_at: description: UpdatedAt holds the value of the "updated_at" field. type: string type: object - ent.EntityTypeEdges: + ent.ItemTemplateEdges: properties: - entities: - description: Entities holds the value of the entities edge. + fields: + description: Fields holds the value of the fields edge. items: - $ref: '#/definitions/ent.Entity' + $ref: '#/definitions/ent.TemplateField' type: array group: allOf: - $ref: '#/definitions/ent.Group' description: Group holds the value of the group edge. - type: object - ent.Group: - properties: - created_at: - description: CreatedAt holds the value of the "created_at" field. - type: string - currency: - description: Currency holds the value of the "currency" field. - type: string - edges: + location: allOf: - - $ref: '#/definitions/ent.GroupEdges' - description: |- - Edges holds the relations/edges for other nodes in the graph. - The values are being populated by the GroupQuery when eager-loading is set. - id: - description: ID of the ent. - type: string - name: - description: Name holds the value of the "name" field. - type: string - updated_at: - description: UpdatedAt holds the value of the "updated_at" field. - type: string - type: object - ent.GroupEdges: - properties: - entities: - description: Entities holds the value of the entities edge. - items: - $ref: '#/definitions/ent.Entity' - type: array - entity_types: - description: EntityTypes holds the value of the entity_types edge. - items: - $ref: '#/definitions/ent.EntityType' - type: array - invitation_tokens: - description: InvitationTokens holds the value of the invitation_tokens edge. - items: - $ref: '#/definitions/ent.GroupInvitationToken' - type: array - labels: - description: Labels holds the value of the labels edge. - items: - $ref: '#/definitions/ent.Label' - type: array - notifiers: - description: Notifiers holds the value of the notifiers edge. - items: - $ref: '#/definitions/ent.Notifier' - type: array - users: - description: Users holds the value of the users edge. - items: - $ref: '#/definitions/ent.User' - type: array - type: object - ent.GroupInvitationToken: - properties: - created_at: - description: CreatedAt holds the value of the "created_at" field. - type: string - edges: - allOf: - - $ref: '#/definitions/ent.GroupInvitationTokenEdges' - description: |- - Edges holds the relations/edges for other nodes in the graph. - The values are being populated by the GroupInvitationTokenQuery when eager-loading is set. - expires_at: - description: ExpiresAt holds the value of the "expires_at" field. - type: string - id: - description: ID of the ent. - type: string - token: - description: Token holds the value of the "token" field. - items: - type: integer - type: array - updated_at: - description: UpdatedAt holds the value of the "updated_at" field. - type: string - uses: - description: Uses holds the value of the "uses" field. - type: integer - type: object - ent.GroupInvitationTokenEdges: - properties: - group: - allOf: - - $ref: '#/definitions/ent.Group' - description: Group holds the value of the group edge. + - $ref: '#/definitions/ent.Location' + description: Location holds the value of the location edge. type: object ent.Label: properties: @@ -497,15 +534,60 @@ definitions: type: object ent.LabelEdges: properties: - entities: - description: Entities holds the value of the entities edge. + group: + allOf: + - $ref: '#/definitions/ent.Group' + description: Group holds the value of the group edge. + items: + description: Items holds the value of the items edge. items: - $ref: '#/definitions/ent.Entity' + $ref: '#/definitions/ent.Item' + type: array + type: object + ent.Location: + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + description: + description: Description holds the value of the "description" field. + type: string + edges: + allOf: + - $ref: '#/definitions/ent.LocationEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the LocationQuery when eager-loading is set. + id: + description: ID of the ent. + type: string + name: + description: Name holds the value of the "name" field. + type: string + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + type: object + ent.LocationEdges: + properties: + children: + description: Children holds the value of the children edge. + items: + $ref: '#/definitions/ent.Location' type: array group: allOf: - $ref: '#/definitions/ent.Group' description: Group holds the value of the group edge. + items: + description: Items holds the value of the items edge. + items: + $ref: '#/definitions/ent.Item' + type: array + parent: + allOf: + - $ref: '#/definitions/ent.Location' + description: Parent holds the value of the parent edge. type: object ent.MaintenanceEntry: properties: @@ -527,12 +609,12 @@ definitions: description: |- Edges holds the relations/edges for other nodes in the graph. The values are being populated by the MaintenanceEntryQuery when eager-loading is set. - entity_id: - description: EntityID holds the value of the "entity_id" field. - type: string id: description: ID of the ent. type: string + item_id: + description: ItemID holds the value of the "item_id" field. + type: string name: description: Name holds the value of the "name" field. type: string @@ -545,10 +627,10 @@ definitions: type: object ent.MaintenanceEntryEdges: properties: - entity: + item: allOf: - - $ref: '#/definitions/ent.Entity' - description: Entity holds the value of the entity edge. + - $ref: '#/definitions/ent.Item' + description: Item holds the value of the item edge. type: object ent.Notifier: properties: @@ -591,6 +673,44 @@ definitions: - $ref: '#/definitions/ent.User' description: User holds the value of the user edge. type: object + ent.TemplateField: + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + description: + description: Description holds the value of the "description" field. + type: string + edges: + allOf: + - $ref: '#/definitions/ent.TemplateFieldEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the TemplateFieldQuery when eager-loading is set. + id: + description: ID of the ent. + type: string + name: + description: Name holds the value of the "name" field. + type: string + text_value: + description: TextValue holds the value of the "text_value" field. + type: string + type: + allOf: + - $ref: '#/definitions/templatefield.Type' + description: Type holds the value of the "type" field. + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + type: object + ent.TemplateFieldEdges: + properties: + item_template: + allOf: + - $ref: '#/definitions/ent.ItemTemplate' + description: ItemTemplate holds the value of the item_template edge. + type: object ent.User: properties: activated_on: @@ -617,6 +737,12 @@ definitions: name: description: Name holds the value of the "name" field. type: string + oidc_issuer: + description: OidcIssuer holds the value of the "oidc_issuer" field. + type: string + oidc_subject: + description: OidcSubject holds the value of the "oidc_subject" field. + type: string role: allOf: - $ref: '#/definitions/user.Role' @@ -645,7 +771,7 @@ definitions: $ref: '#/definitions/ent.Notifier' type: array type: object - entityfield.Type: + itemfield.Type: enum: - text - number @@ -689,82 +815,6 @@ definitions: copyPrefix: type: string type: object - repo.EntityAttachment: - properties: - createdAt: - type: string - id: - type: string - mimeType: - type: string - path: - type: string - primary: - type: boolean - thumbnail: - $ref: '#/definitions/ent.Attachment' - title: - type: string - type: - type: string - updatedAt: - type: string - type: object - repo.EntityAttachmentUpdate: - properties: - primary: - type: boolean - title: - type: string - type: - type: string - type: object - repo.EntityType: - properties: - color: - type: string - description: - type: string - icon: - type: string - isLocation: - type: boolean - name: - type: string - type: object - repo.EntityTypeCreate: - properties: - color: - type: string - description: - type: string - icon: - type: string - isLocation: - type: boolean - name: - type: string - required: - - isLocation - - name - type: object - repo.EntityTypeDelete: - properties: - replacementId: - $ref: '#/definitions/uuid.NullUUID' - type: object - repo.EntityTypeUpdate: - properties: - color: - type: string - description: - type: string - icon: - type: string - name: - minLength: 1 - type: string - type: object repo.Group: properties: createdAt: @@ -800,13 +850,41 @@ definitions: name: type: string type: object + repo.ItemAttachment: + properties: + createdAt: + type: string + id: + type: string + mimeType: + type: string + path: + type: string + primary: + type: boolean + thumbnail: + $ref: '#/definitions/ent.Attachment' + title: + type: string + type: + type: string + updatedAt: + type: string + type: object + repo.ItemAttachmentUpdate: + properties: + primary: + type: boolean + title: + type: string + type: + type: string + type: object repo.ItemCreate: properties: description: maxLength: 1000 type: string - entityType: - type: string labelIds: items: type: string @@ -824,7 +902,6 @@ definitions: quantity: type: integer required: - - entityType - name type: object repo.ItemField: @@ -851,14 +928,12 @@ definitions: type: string attachments: items: - $ref: '#/definitions/repo.EntityAttachment' + $ref: '#/definitions/repo.ItemAttachment' type: array createdAt: type: string description: type: string - entityType: - type: string fields: items: $ref: '#/definitions/repo.ItemField' @@ -970,8 +1045,6 @@ definitions: type: string description: type: string - entityType: - type: string id: type: string imageId: @@ -1006,16 +1079,207 @@ definitions: updatedAt: type: string type: object + repo.ItemTemplateCreate: + properties: + defaultDescription: + maxLength: 1000 + type: string + x-nullable: true + defaultInsured: + type: boolean + defaultLabelIds: + items: + type: string + type: array + x-nullable: true + defaultLifetimeWarranty: + type: boolean + defaultLocationId: + description: Default location and labels + type: string + x-nullable: true + defaultManufacturer: + maxLength: 255 + type: string + x-nullable: true + defaultModelNumber: + maxLength: 255 + type: string + x-nullable: true + defaultName: + maxLength: 255 + type: string + x-nullable: true + defaultQuantity: + description: Default values for items + type: integer + x-nullable: true + defaultWarrantyDetails: + maxLength: 1000 + type: string + x-nullable: true + description: + maxLength: 1000 + type: string + fields: + description: Custom fields + items: + $ref: '#/definitions/repo.TemplateField' + type: array + includePurchaseFields: + type: boolean + includeSoldFields: + type: boolean + includeWarrantyFields: + description: Metadata flags + type: boolean + name: + maxLength: 255 + minLength: 1 + type: string + notes: + maxLength: 1000 + type: string + required: + - name + type: object + repo.ItemTemplateOut: + properties: + createdAt: + type: string + defaultDescription: + type: string + defaultInsured: + type: boolean + defaultLabels: + items: + $ref: '#/definitions/repo.TemplateLabelSummary' + type: array + defaultLifetimeWarranty: + type: boolean + defaultLocation: + allOf: + - $ref: '#/definitions/repo.TemplateLocationSummary' + description: Default location and labels + defaultManufacturer: + type: string + defaultModelNumber: + type: string + defaultName: + type: string + defaultQuantity: + description: Default values for items + type: integer + defaultWarrantyDetails: + type: string + description: + type: string + fields: + description: Custom fields + items: + $ref: '#/definitions/repo.TemplateField' + type: array + id: + type: string + includePurchaseFields: + type: boolean + includeSoldFields: + type: boolean + includeWarrantyFields: + description: Metadata flags + type: boolean + name: + type: string + notes: + type: string + updatedAt: + type: string + type: object + repo.ItemTemplateSummary: + properties: + createdAt: + type: string + description: + type: string + id: + type: string + name: + type: string + updatedAt: + type: string + type: object + repo.ItemTemplateUpdate: + properties: + defaultDescription: + maxLength: 1000 + type: string + x-nullable: true + defaultInsured: + type: boolean + defaultLabelIds: + items: + type: string + type: array + x-nullable: true + defaultLifetimeWarranty: + type: boolean + defaultLocationId: + description: Default location and labels + type: string + x-nullable: true + defaultManufacturer: + maxLength: 255 + type: string + x-nullable: true + defaultModelNumber: + maxLength: 255 + type: string + x-nullable: true + defaultName: + maxLength: 255 + type: string + x-nullable: true + defaultQuantity: + description: Default values for items + type: integer + x-nullable: true + defaultWarrantyDetails: + maxLength: 1000 + type: string + x-nullable: true + description: + maxLength: 1000 + type: string + fields: + description: Custom fields + items: + $ref: '#/definitions/repo.TemplateField' + type: array + id: + type: string + includePurchaseFields: + type: boolean + includeSoldFields: + type: boolean + includeWarrantyFields: + description: Metadata flags + type: boolean + name: + maxLength: 255 + minLength: 1 + type: string + notes: + maxLength: 1000 + type: string + required: + - name + type: object repo.ItemType: enum: - location - item - - location - - item type: string x-enum-varnames: - - EntityTypeLocation - - EntityTypeItem - ItemTypeLocation - ItemTypeItem repo.ItemUpdate: @@ -1027,8 +1291,6 @@ definitions: description: maxLength: 1000 type: string - entityType: - type: string fields: items: $ref: '#/definitions/repo.ItemField' @@ -1096,7 +1358,6 @@ definitions: warrantyExpires: type: string required: - - entityType - name type: object repo.LabelCreate: @@ -1147,15 +1408,11 @@ definitions: properties: description: type: string - entityType: - type: string name: type: string parentId: type: string x-nullable: true - required: - - entityType type: object repo.LocationOut: properties: @@ -1167,8 +1424,6 @@ definitions: type: string description: type: string - entityType: - type: string id: type: string name: @@ -1186,8 +1441,6 @@ definitions: type: string description: type: string - entityType: - type: string id: type: string itemCount: @@ -1203,8 +1456,6 @@ definitions: type: string description: type: string - entityType: - type: string id: type: string name: @@ -1216,8 +1467,6 @@ definitions: properties: description: type: string - entityType: - type: string id: type: string name: @@ -1225,8 +1474,6 @@ definitions: parentId: type: string x-nullable: true - required: - - entityType type: object repo.MaintenanceEntry: properties: @@ -1364,6 +1611,31 @@ definitions: total: type: integer type: object + repo.TemplateField: + properties: + id: + type: string + name: + type: string + textValue: + type: string + type: + type: string + type: object + repo.TemplateLabelSummary: + properties: + id: + type: string + name: + type: string + type: object + repo.TemplateLocationSummary: + properties: + id: + type: string + name: + type: string + type: object repo.TotalsByOrganizer: properties: id: @@ -1402,6 +1674,10 @@ definitions: type: boolean name: type: string + oidcIssuer: + type: string + oidcSubject: + type: string type: object repo.UserUpdate: properties: @@ -1452,6 +1728,12 @@ definitions: token: type: string type: object + templatefield.Type: + enum: + - text + type: string + x-enum-varnames: + - TypeText user.Role: enum: - user @@ -1462,14 +1744,6 @@ definitions: - DefaultRole - RoleUser - RoleOwner - uuid.NullUUID: - properties: - uuid: - type: string - valid: - description: Valid is true if UUID is not NULL - type: boolean - type: object v1.APISummary: properties: allowRegistration: @@ -1486,6 +1760,8 @@ definitions: $ref: '#/definitions/services.Latest' message: type: string + oidc: + $ref: '#/definitions/v1.OIDCStatus' title: type: string versions: @@ -1539,6 +1815,27 @@ definitions: token: type: string type: object + v1.ItemTemplateCreateItemRequest: + properties: + description: + maxLength: 1000 + type: string + labelIds: + items: + type: string + type: array + locationId: + type: string + name: + maxLength: 255 + minLength: 1 + type: string + quantity: + type: integer + required: + - locationId + - name + type: object v1.LoginForm: properties: password: @@ -1550,6 +1847,17 @@ definitions: example: admin@admin.com type: string type: object + v1.OIDCStatus: + properties: + allowLocal: + type: boolean + autoRedirect: + type: boolean + buttonText: + type: string + enabled: + type: boolean + type: object v1.TokenResponse: properties: attachmentToken: @@ -1686,287 +1994,6 @@ paths: summary: Currency tags: - Base - /v1/entities/{id}/attachments: - post: - consumes: - - multipart/form-data - parameters: - - description: Item ID - in: path - name: id - required: true - type: string - - description: File attachment - in: formData - name: file - required: true - type: file - - description: Type of file - in: formData - name: type - type: string - - description: Is this the primary attachment - in: formData - name: primary - type: boolean - - description: name of the file including extension - in: formData - name: name - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/repo.ItemOut' - "422": - description: Unprocessable Entity - schema: - $ref: '#/definitions/validate.ErrorResponse' - security: - - Bearer: [] - summary: Create Item Attachment - tags: - - Items Attachments - /v1/entities/{id}/attachments/{attachment_id}: - delete: - parameters: - - description: Item ID - in: path - name: id - required: true - type: string - - description: Attachment ID - in: path - name: attachment_id - required: true - type: string - responses: - "204": - description: No Content - security: - - Bearer: [] - summary: Delete Item Attachment - tags: - - Items Attachments - get: - parameters: - - description: Item ID - in: path - name: id - required: true - type: string - - description: Attachment ID - in: path - name: attachment_id - required: true - type: string - produces: - - application/octet-stream - responses: - "200": - description: OK - schema: - $ref: '#/definitions/v1.ItemAttachmentToken' - security: - - Bearer: [] - summary: Get Item Attachment - tags: - - Items Attachments - put: - parameters: - - description: Item ID - in: path - name: id - required: true - type: string - - description: Attachment ID - in: path - name: attachment_id - required: true - type: string - - description: Attachment Update - in: body - name: payload - required: true - schema: - $ref: '#/definitions/repo.EntityAttachmentUpdate' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/repo.ItemOut' - security: - - Bearer: [] - summary: Update Item Attachment - tags: - - Items Attachments - /v1/entities/{id}/maintenance: - get: - parameters: - - description: Item ID - in: path - name: id - required: true - type: string - - enum: - - scheduled - - completed - - both - in: query - name: status - type: string - x-enum-varnames: - - MaintenanceFilterStatusScheduled - - MaintenanceFilterStatusCompleted - - MaintenanceFilterStatusBoth - produces: - - application/json - responses: - "200": - description: OK - schema: - items: - $ref: '#/definitions/repo.MaintenanceEntryWithDetails' - type: array - security: - - Bearer: [] - summary: Get Maintenance Log - tags: - - Item Maintenance - post: - parameters: - - description: Item ID - in: path - name: id - required: true - type: string - - description: Entry Data - in: body - name: payload - required: true - schema: - $ref: '#/definitions/repo.MaintenanceEntryCreate' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/repo.MaintenanceEntry' - security: - - Bearer: [] - summary: Create Maintenance Entry - tags: - - Item Maintenance - /v1/entitytype: - get: - produces: - - application/json - responses: - "200": - description: OK - schema: - items: - $ref: '#/definitions/repo.EntityType' - type: array - security: - - Bearer: [] - summary: Query All Entity Types - tags: - - EntityTypes - post: - consumes: - - application/json - parameters: - - description: Entity Type Data - in: body - name: payload - required: true - schema: - $ref: '#/definitions/repo.EntityTypeCreate' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/repo.EntityType' - security: - - Bearer: [] - summary: Create Entity Type - tags: - - EntityTypes - /v1/entitytype/{id}: - delete: - parameters: - - description: Entity Type ID - in: path - name: id - required: true - type: string - - description: Entity Type Delete Options - in: body - name: payload - required: true - schema: - $ref: '#/definitions/repo.EntityTypeDelete' - responses: - "204": - description: No Content - security: - - Bearer: [] - summary: Delete Entity Type - tags: - - EntityTypes - get: - parameters: - - description: Entity Type ID - in: path - name: id - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/repo.EntityType' - security: - - Bearer: [] - summary: Get One Entity Type - tags: - - EntityTypes - put: - consumes: - - application/json - parameters: - - description: Entity Type ID - in: path - name: id - required: true - type: string - - description: Entity Type Data - in: body - name: payload - required: true - schema: - $ref: '#/definitions/repo.EntityTypeUpdate' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/repo.EntityType' - security: - - Bearer: [] - summary: Update Entity Type - tags: - - EntityTypes /v1/groups: get: produces: @@ -2093,7 +2120,6 @@ paths: - Statistics /v1/items: get: - deprecated: true parameters: - description: search string in: query @@ -2137,13 +2163,10 @@ paths: $ref: '#/definitions/repo.PaginationResult-repo_ItemSummary' security: - Bearer: [] - summary: (Deprecated) Query All Items + summary: Query All Items tags: - Items post: - consumes: - - application/json - deprecated: true parameters: - description: Item Data in: body @@ -2165,7 +2188,6 @@ paths: - Items /v1/items/{id}: delete: - deprecated: true parameters: - description: Item ID in: path @@ -2179,11 +2201,10 @@ paths: description: No Content security: - Bearer: [] - summary: (Deprecated) Delete Item + summary: Delete Item tags: - Items get: - deprecated: true parameters: - description: Item ID in: path @@ -2199,11 +2220,10 @@ paths: $ref: '#/definitions/repo.ItemOut' security: - Bearer: [] - summary: (Deprecated) Get Item + summary: Get Item tags: - Items patch: - deprecated: true parameters: - description: Item ID in: path @@ -2225,11 +2245,10 @@ paths: $ref: '#/definitions/repo.ItemOut' security: - Bearer: [] - summary: (Deprecated) Update Item + summary: Update Item tags: - Items put: - deprecated: true parameters: - description: Item ID in: path @@ -2251,14 +2270,13 @@ paths: $ref: '#/definitions/repo.ItemOut' security: - Bearer: [] - summary: (Deprecated) Update Item + summary: Update Item tags: - Items /v1/items/{id}/attachments: post: consumes: - multipart/form-data - deprecated: true parameters: - description: Item ID in: path @@ -2301,7 +2319,6 @@ paths: - Items Attachments /v1/items/{id}/attachments/{attachment_id}: delete: - deprecated: true parameters: - description: Item ID in: path @@ -2322,7 +2339,6 @@ paths: tags: - Items Attachments get: - deprecated: true parameters: - description: Item ID in: path @@ -2347,7 +2363,6 @@ paths: tags: - Items Attachments put: - deprecated: true parameters: - description: Item ID in: path @@ -2364,7 +2379,7 @@ paths: name: payload required: true schema: - $ref: '#/definitions/repo.EntityAttachmentUpdate' + $ref: '#/definitions/repo.ItemAttachmentUpdate' responses: "200": description: OK @@ -2403,7 +2418,6 @@ paths: - Items /v1/items/{id}/maintenance: get: - deprecated: true parameters: - description: Item ID in: path @@ -2436,7 +2450,6 @@ paths: tags: - Item Maintenance post: - deprecated: true parameters: - description: Item ID in: path @@ -2463,7 +2476,6 @@ paths: - Item Maintenance /v1/items/{id}/path: get: - deprecated: true parameters: - description: Item ID in: path @@ -2481,12 +2493,11 @@ paths: type: array security: - Bearer: [] - summary: (Deprecated) Get the full path of an item + summary: Get the full path of an item tags: - Items /v1/items/export: get: - deprecated: true responses: "200": description: text/csv @@ -2494,12 +2505,11 @@ paths: type: string security: - Bearer: [] - summary: (Deprecated) Export Items + summary: Export Items tags: - Items /v1/items/fields: get: - deprecated: true produces: - application/json responses: @@ -2511,12 +2521,11 @@ paths: type: array security: - Bearer: [] - summary: (Deprecated) Get All Custom Field Names + summary: Get All Custom Field Names tags: - Items /v1/items/fields/values: get: - deprecated: true produces: - application/json responses: @@ -2528,14 +2537,13 @@ paths: type: array security: - Bearer: [] - summary: (Deprecated) Get All Custom Field Values + summary: Get All Custom Field Values tags: - Items /v1/items/import: post: consumes: - multipart/form-data - deprecated: true parameters: - description: Image to upload in: formData @@ -2549,7 +2557,7 @@ paths: description: No Content security: - Bearer: [] - summary: (Deprecated) Import Items + summary: Import Items tags: - Items /v1/labelmaker/assets/{id}: @@ -2718,7 +2726,6 @@ paths: - Labels /v1/locations: get: - deprecated: true parameters: - description: Filter locations with parents in: query @@ -2735,11 +2742,10 @@ paths: type: array security: - Bearer: [] - summary: (Deprecated) Get All Locations + summary: Get All Locations tags: - Locations post: - deprecated: true parameters: - description: Location Data in: body @@ -2756,12 +2762,11 @@ paths: $ref: '#/definitions/repo.LocationSummary' security: - Bearer: [] - summary: (Deprecated) Create Location + summary: Create Location tags: - Locations /v1/locations/{id}: delete: - deprecated: true parameters: - description: Location ID in: path @@ -2775,11 +2780,10 @@ paths: description: No Content security: - Bearer: [] - summary: (Deprecated) Delete Location + summary: Delete Location tags: - Locations get: - deprecated: true parameters: - description: Location ID in: path @@ -2795,11 +2799,10 @@ paths: $ref: '#/definitions/repo.LocationOut' security: - Bearer: [] - summary: (Deprecated) Get Location + summary: Get Location tags: - Locations put: - deprecated: true parameters: - description: Location ID in: path @@ -2821,12 +2824,11 @@ paths: $ref: '#/definitions/repo.LocationOut' security: - Bearer: [] - summary: (Deprecated) Update Location + summary: Update Location tags: - Locations /v1/locations/tree: get: - deprecated: true parameters: - description: include items in response tree in: query @@ -2843,7 +2845,7 @@ paths: type: array security: - Bearer: [] - summary: (Deprecated) Get Locations Tree + summary: Get Locations Tree tags: - Locations /v1/maintenance: @@ -3076,6 +3078,130 @@ paths: summary: Application Info tags: - Base + /v1/templates: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/repo.ItemTemplateSummary' + type: array + security: + - Bearer: [] + summary: Get All Item Templates + tags: + - Item Templates + post: + parameters: + - description: Template Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.ItemTemplateCreate' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/repo.ItemTemplateOut' + security: + - Bearer: [] + summary: Create Item Template + tags: + - Item Templates + /v1/templates/{id}: + delete: + parameters: + - description: Template ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "204": + description: No Content + security: + - Bearer: [] + summary: Delete Item Template + tags: + - Item Templates + get: + parameters: + - description: Template ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.ItemTemplateOut' + security: + - Bearer: [] + summary: Get Item Template + tags: + - Item Templates + put: + parameters: + - description: Template ID + in: path + name: id + required: true + type: string + - description: Template Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.ItemTemplateUpdate' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.ItemTemplateOut' + security: + - Bearer: [] + summary: Update Item Template + tags: + - Item Templates + /v1/templates/{id}/create-item: + post: + parameters: + - description: Template ID + in: path + name: id + required: true + type: string + - description: Item Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/v1.ItemTemplateCreateItemRequest' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/repo.ItemOut' + security: + - Bearer: [] + summary: Create Item from Template + tags: + - Item Templates /v1/users/change-password: put: parameters: @@ -3119,6 +3245,35 @@ paths: summary: User Login tags: - Authentication + /v1/users/login/oidc: + get: + produces: + - application/json + responses: + "302": + description: Found + summary: OIDC Login Initiation + tags: + - Authentication + /v1/users/login/oidc/callback: + get: + parameters: + - description: Authorization code + in: query + name: code + required: true + type: string + - description: State parameter + in: query + name: state + required: true + type: string + responses: + "302": + description: Found + summary: OIDC Callback Handler + tags: + - Authentication /v1/users/logout: post: responses: @@ -3156,6 +3311,10 @@ paths: responses: "204": description: No Content + "403": + description: Local login is not enabled + schema: + type: string summary: Register New User tags: - User diff --git a/backend/go.mod b/backend/go.mod index 56cbd1a9..817da3d5 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -6,15 +6,16 @@ toolchain go1.24.3 require ( entgo.io/ent v0.14.5 - github.com/ardanlabs/conf/v3 v3.8.0 + github.com/ardanlabs/conf/v3 v3.9.0 github.com/containrrr/shoutrrr v0.8.0 + github.com/coreos/go-oidc/v3 v3.17.0 github.com/evanoberholster/imagemeta v0.3.1 github.com/gen2brain/avif v0.4.4 - github.com/gen2brain/heic v0.4.5 + github.com/gen2brain/heic v0.4.6 github.com/gen2brain/jpegxl v0.4.5 github.com/gen2brain/webp v0.5.5 - github.com/go-chi/chi/v5 v5.2.2 - github.com/go-playground/validator/v10 v10.27.0 + github.com/go-chi/chi/v5 v5.2.3 + github.com/go-playground/validator/v10 v10.28.0 github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 github.com/google/uuid v1.6.0 @@ -22,40 +23,42 @@ require ( github.com/hay-kot/httpkit v0.0.11 github.com/lib/pq v1.10.9 github.com/mattn/go-sqlite3 v1.14.32 - github.com/olahol/melody v1.3.0 + github.com/olahol/melody v1.4.0 github.com/pkg/errors v0.9.1 - github.com/pressly/goose/v3 v3.24.3 + github.com/pressly/goose/v3 v3.26.0 github.com/rs/zerolog v1.34.0 - github.com/shirou/gopsutil/v4 v4.25.7 + github.com/shirou/gopsutil/v4 v4.25.11 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e - github.com/stretchr/testify v1.10.0 + github.com/stretchr/testify v1.11.1 github.com/swaggo/http-swagger/v2 v2.0.2 - github.com/swaggo/swag/v2 v2.0.0-rc4 + github.com/swaggo/swag v1.16.6 github.com/yeqown/go-qrcode/v2 v2.2.5 github.com/yeqown/go-qrcode/writer/standard v1.3.0 github.com/zeebo/blake3 v0.2.4 go.balki.me/anyhttp v0.5.2 - gocloud.dev v0.43.0 - gocloud.dev/pubsub/kafkapubsub v0.43.0 - gocloud.dev/pubsub/natspubsub v0.43.0 - gocloud.dev/pubsub/rabbitpubsub v0.43.0 - golang.org/x/crypto v0.41.0 - golang.org/x/image v0.30.0 - golang.org/x/text v0.28.0 - modernc.org/sqlite v1.38.2 + gocloud.dev v0.44.0 + gocloud.dev/pubsub/kafkapubsub v0.44.0 + gocloud.dev/pubsub/natspubsub v0.44.0 + gocloud.dev/pubsub/rabbitpubsub v0.44.0 + golang.org/x/crypto v0.45.0 + golang.org/x/image v0.33.0 + golang.org/x/oauth2 v0.33.0 + golang.org/x/text v0.31.0 + modernc.org/sqlite v1.40.1 ) require ( ariga.io/atlas v0.32.1-0.20250325101103-175b25e1c1b9 // indirect cel.dev/expr v0.24.0 // indirect - cloud.google.com/go v0.121.4 // indirect - cloud.google.com/go/auth v0.16.4 // indirect + cloud.google.com/go v0.121.6 // indirect + cloud.google.com/go/auth v0.17.0 // indirect cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect - cloud.google.com/go/compute/metadata v0.8.0 // indirect + cloud.google.com/go/compute/metadata v0.9.0 // indirect cloud.google.com/go/iam v1.5.2 // indirect cloud.google.com/go/monitoring v1.24.2 // indirect - cloud.google.com/go/pubsub v1.49.0 // indirect - cloud.google.com/go/storage v1.55.0 // indirect + cloud.google.com/go/pubsub v1.50.0 // indirect + cloud.google.com/go/pubsub/v2 v2.2.1 // indirect + cloud.google.com/go/storage v1.56.0 // indirect github.com/Azure/azure-amqp-common-go/v3 v3.2.3 // indirect github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.1 // indirect github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1 // indirect @@ -66,71 +69,74 @@ require ( github.com/Azure/go-autorest v14.2.0+incompatible // indirect github.com/Azure/go-autorest/autorest/to v0.4.1 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect - github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.29.0 // indirect + github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.30.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.53.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.53.0 // indirect - github.com/IBM/sarama v1.45.2 // indirect + github.com/IBM/sarama v1.46.3 // indirect github.com/KyleBanks/depth v1.2.1 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect - github.com/aws/aws-sdk-go v1.55.7 // indirect - github.com/aws/aws-sdk-go-v2 v1.36.5 // indirect - github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.11 // indirect - github.com/aws/aws-sdk-go-v2/config v1.29.17 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.17.70 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.32 // indirect - github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.84 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.36 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.36 // indirect - github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 // indirect - github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.36 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.4 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.7.4 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.17 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.17 // indirect - github.com/aws/aws-sdk-go-v2/service/s3 v1.84.0 // indirect + github.com/aws/aws-sdk-go-v2 v1.39.6 // indirect + github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.3 // indirect + github.com/aws/aws-sdk-go-v2/config v1.31.17 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.18.21 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.13 // indirect + github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.20.3 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.13 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.13 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.8.4 // indirect + github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.13 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.3 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.4 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.13 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.13 // indirect + github.com/aws/aws-sdk-go-v2/service/s3 v1.89.2 // indirect github.com/aws/aws-sdk-go-v2/service/sns v1.34.7 // indirect github.com/aws/aws-sdk-go-v2/service/sqs v1.38.8 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.25.5 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.3 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.34.0 // indirect - github.com/aws/smithy-go v1.22.4 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.30.1 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.5 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.39.1 // indirect + github.com/aws/smithy-go v1.23.2 // indirect github.com/bmatcuk/doublestar v1.3.4 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443 // indirect + github.com/cncf/xds/go v0.0.0-20251022180443-0feb69152e9f // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/eapache/go-resiliency v1.7.0 // indirect github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect github.com/eapache/queue v1.1.0 // indirect - github.com/ebitengine/purego v0.8.4 // indirect - github.com/envoyproxy/go-control-plane/envoy v1.32.4 // indirect + github.com/ebitengine/purego v0.9.1 // indirect + github.com/envoyproxy/go-control-plane/envoy v1.35.0 // indirect github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect github.com/fatih/color v1.18.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fogleman/gg v1.3.0 // indirect - github.com/gabriel-vasile/mimetype v1.4.9 // indirect - github.com/go-jose/go-jose/v4 v4.1.1 // indirect + github.com/gabriel-vasile/mimetype v1.4.11 // indirect + github.com/go-jose/go-jose/v4 v4.1.3 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-openapi/inflect v0.19.0 // indirect - github.com/go-openapi/jsonpointer v0.21.2 // indirect - github.com/go-openapi/jsonreference v0.21.0 // indirect - github.com/go-openapi/spec v0.21.0 // indirect - github.com/go-openapi/swag v0.23.1 // indirect + github.com/go-openapi/jsonpointer v0.22.3 // indirect + github.com/go-openapi/jsonreference v0.21.3 // indirect + github.com/go-openapi/spec v0.22.1 // indirect + github.com/go-openapi/swag/conv v0.25.4 // indirect + github.com/go-openapi/swag/jsonname v0.25.4 // indirect + github.com/go-openapi/swag/jsonutils v0.25.4 // indirect + github.com/go-openapi/swag/loading v0.25.4 // indirect + github.com/go-openapi/swag/stringutils v0.25.4 // indirect + github.com/go-openapi/swag/typeutils v0.25.4 // indirect + github.com/go-openapi/swag/yamlutils v0.25.4 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/golang-jwt/jwt/v5 v5.2.3 // indirect github.com/golang/snappy v1.0.0 // indirect github.com/google/go-cmp v0.7.0 // indirect github.com/google/s2a-go v0.1.9 // indirect - github.com/google/wire v0.6.0 // indirect - github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect + github.com/google/wire v0.7.0 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.3.7 // indirect github.com/googleapis/gax-go/v2 v2.15.0 // indirect github.com/gorilla/websocket v1.5.3 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect - github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/hcl/v2 v2.18.1 // indirect github.com/jcmturner/aescts/v2 v2.0.0 // indirect @@ -138,73 +144,66 @@ require ( github.com/jcmturner/gofork v1.7.6 // indirect github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect github.com/jcmturner/rpc/v2 v2.0.3 // indirect - github.com/jmespath/go-jmespath v0.4.0 // indirect - github.com/josharian/intern v1.0.0 // indirect - github.com/klauspost/compress v1.18.0 // indirect + github.com/klauspost/compress v1.18.2 // indirect github.com/klauspost/cpuid/v2 v2.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect - github.com/mailru/easyjson v0.9.0 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mfridman/interpolate v0.0.2 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect - github.com/nats-io/nats.go v1.44.0 // indirect - github.com/nats-io/nkeys v0.4.11 // indirect + github.com/nats-io/nats.go v1.47.0 // indirect + github.com/nats-io/nkeys v0.4.12 // indirect github.com/nats-io/nuid v1.0.1 // indirect - github.com/ncruces/go-strftime v0.1.9 // indirect + github.com/ncruces/go-strftime v1.0.0 // indirect github.com/philhofer/fwd v1.2.0 // indirect github.com/pierrec/lz4/v4 v4.1.22 // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect + github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect github.com/rabbitmq/amqp091-go v1.10.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/sethvargo/go-retry v0.3.0 // indirect - github.com/spiffe/go-spiffe/v2 v2.5.0 // indirect - github.com/sv-tools/openapi v0.2.1 // indirect + github.com/spiffe/go-spiffe/v2 v2.6.0 // indirect github.com/swaggo/files/v2 v2.0.2 // indirect - github.com/swaggo/swag v1.8.1 // indirect - github.com/tetratelabs/wazero v1.9.0 // indirect - github.com/tinylib/msgp v1.3.0 // indirect - github.com/tklauser/go-sysconf v0.3.15 // indirect - github.com/tklauser/numcpus v0.10.0 // indirect + github.com/tetratelabs/wazero v1.10.1 // indirect + github.com/tinylib/msgp v1.6.1 // indirect + github.com/tklauser/go-sysconf v0.3.16 // indirect + github.com/tklauser/numcpus v0.11.0 // indirect github.com/yeqown/reedsolomon v1.0.0 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect github.com/zclconf/go-cty v1.14.4 // indirect github.com/zclconf/go-cty-yaml v1.1.0 // indirect - github.com/zeebo/errs v1.4.0 // indirect - go.opentelemetry.io/auto/sdk v1.1.0 // indirect - go.opentelemetry.io/contrib/detectors/gcp v1.37.0 // indirect + go.opentelemetry.io/auto/sdk v1.2.1 // indirect + go.opentelemetry.io/contrib/detectors/gcp v1.38.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.62.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0 // indirect - go.opentelemetry.io/otel v1.37.0 // indirect - go.opentelemetry.io/otel/metric v1.37.0 // indirect - go.opentelemetry.io/otel/sdk v1.37.0 // indirect - go.opentelemetry.io/otel/sdk/metric v1.37.0 // indirect - go.opentelemetry.io/otel/trace v1.37.0 // indirect + go.opentelemetry.io/otel v1.38.0 // indirect + go.opentelemetry.io/otel/metric v1.38.0 // indirect + go.opentelemetry.io/otel/sdk v1.38.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.38.0 // indirect + go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20250813145105-42675adae3e6 // indirect - golang.org/x/mod v0.27.0 // indirect - golang.org/x/net v0.43.0 // indirect - golang.org/x/oauth2 v0.30.0 // indirect - golang.org/x/sync v0.16.0 // indirect - golang.org/x/sys v0.35.0 // indirect - golang.org/x/time v0.12.0 // indirect - golang.org/x/tools v0.36.0 // indirect + go.yaml.in/yaml/v3 v3.0.4 // indirect + golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39 // indirect + golang.org/x/mod v0.30.0 // indirect + golang.org/x/net v0.47.0 // indirect + golang.org/x/sync v0.18.0 // indirect + golang.org/x/sys v0.38.0 // indirect + golang.org/x/time v0.14.0 // indirect + golang.org/x/tools v0.39.0 // indirect golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect - google.golang.org/api v0.247.0 // indirect + google.golang.org/api v0.257.0 // indirect google.golang.org/genproto v0.0.0-20250715232539-7130f93afb79 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20250715232539-7130f93afb79 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250811230008-5f3141c8851a // indirect - google.golang.org/grpc v1.74.2 // indirect - google.golang.org/protobuf v1.36.7 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20251022142026-3a174f9686a8 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect + google.golang.org/grpc v1.77.0 // indirect + google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - modernc.org/libc v1.66.7 // indirect + modernc.org/libc v1.67.1 // indirect modernc.org/mathutil v1.7.1 // indirect modernc.org/memory v1.11.0 // indirect ) diff --git a/backend/go.sum b/backend/go.sum index 3c18f9e9..72192aaf 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -2,14 +2,14 @@ ariga.io/atlas v0.32.1-0.20250325101103-175b25e1c1b9 h1:E0wvcUXTkgyN4wy4LGtNzMNG ariga.io/atlas v0.32.1-0.20250325101103-175b25e1c1b9/go.mod h1:Oe1xWPuu5q9LzyrWfbZmEZxFYeu4BHTyzfjeW2aZp/w= cel.dev/expr v0.24.0 h1:56OvJKSH3hDGL0ml5uSxZmz3/3Pq4tJ+fb1unVLAFcY= cel.dev/expr v0.24.0/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw= -cloud.google.com/go v0.121.4 h1:cVvUiY0sX0xwyxPwdSU2KsF9knOVmtRyAMt8xou0iTs= -cloud.google.com/go v0.121.4/go.mod h1:XEBchUiHFJbz4lKBZwYBDHV/rSyfFktk737TLDU089s= -cloud.google.com/go/auth v0.16.4 h1:fXOAIQmkApVvcIn7Pc2+5J8QTMVbUGLscnSVNl11su8= -cloud.google.com/go/auth v0.16.4/go.mod h1:j10ncYwjX/g3cdX7GpEzsdM+d+ZNsXAbb6qXA7p1Y5M= +cloud.google.com/go v0.121.6 h1:waZiuajrI28iAf40cWgycWNgaXPO06dupuS+sgibK6c= +cloud.google.com/go v0.121.6/go.mod h1:coChdst4Ea5vUpiALcYKXEpR1S9ZgXbhEzzMcMR66vI= +cloud.google.com/go/auth v0.17.0 h1:74yCm7hCj2rUyyAocqnFzsAYXgJhrG26XCFimrc/Kz4= +cloud.google.com/go/auth v0.17.0/go.mod h1:6wv/t5/6rOPAX4fJiRjKkJCvswLwdet7G8+UGXt7nCQ= cloud.google.com/go/auth/oauth2adapt v0.2.8 h1:keo8NaayQZ6wimpNSmW5OPc283g65QNIiLpZnkHRbnc= cloud.google.com/go/auth/oauth2adapt v0.2.8/go.mod h1:XQ9y31RkqZCcwJWNSx2Xvric3RrU88hAYYbjDWYDL+c= -cloud.google.com/go/compute/metadata v0.8.0 h1:HxMRIbao8w17ZX6wBnjhcDkW6lTFpgcaobyVfZWqRLA= -cloud.google.com/go/compute/metadata v0.8.0/go.mod h1:sYOGTp851OV9bOFJ9CH7elVvyzopvWQFNNghtDQ/Biw= +cloud.google.com/go/compute/metadata v0.9.0 h1:pDUj4QMoPejqq20dK0Pg2N4yG9zIkYGdBtwLoEkH9Zs= +cloud.google.com/go/compute/metadata v0.9.0/go.mod h1:E0bWwX5wTnLPedCKqk3pJmVgCBSM6qQI1yTBdEb3C10= cloud.google.com/go/iam v1.5.2 h1:qgFRAGEmd8z6dJ/qyEchAuL9jpswyODjA2lS+w234g8= cloud.google.com/go/iam v1.5.2/go.mod h1:SE1vg0N81zQqLzQEwxL2WI6yhetBdbNQuTvIKCSkUHE= cloud.google.com/go/logging v1.13.0 h1:7j0HgAp0B94o1YRDqiqm26w4q1rDMH7XNRU34lJXHYc= @@ -18,10 +18,12 @@ cloud.google.com/go/longrunning v0.6.7 h1:IGtfDWHhQCgCjwQjV9iiLnUta9LBCo8R9QmAFs cloud.google.com/go/longrunning v0.6.7/go.mod h1:EAFV3IZAKmM56TyiE6VAP3VoTzhZzySwI/YI1s/nRsY= cloud.google.com/go/monitoring v1.24.2 h1:5OTsoJ1dXYIiMiuL+sYscLc9BumrL3CarVLL7dd7lHM= cloud.google.com/go/monitoring v1.24.2/go.mod h1:x7yzPWcgDRnPEv3sI+jJGBkwl5qINf+6qY4eq0I9B4U= -cloud.google.com/go/pubsub v1.49.0 h1:5054IkbslnrMCgA2MAEPcsN3Ky+AyMpEZcii/DoySPo= -cloud.google.com/go/pubsub v1.49.0/go.mod h1:K1FswTWP+C1tI/nfi3HQecoVeFvL4HUOB1tdaNXKhUY= -cloud.google.com/go/storage v1.55.0 h1:NESjdAToN9u1tmhVqhXCaCwYBuvEhZLLv0gBr+2znf0= -cloud.google.com/go/storage v1.55.0/go.mod h1:ztSmTTwzsdXe5syLVS0YsbFxXuvEmEyZj7v7zChEmuY= +cloud.google.com/go/pubsub v1.50.0 h1:hnYpOIxVlgVD1Z8LN7est4DQZK3K6tvZNurZjIVjUe0= +cloud.google.com/go/pubsub v1.50.0/go.mod h1:Di2Y+nqXBpIS+dXUEJPQzLh8PbIQZMLE9IVUFhf2zmM= +cloud.google.com/go/pubsub/v2 v2.2.1 h1:3brZcshL3fIiD1qOxAE2QW9wxsfjioy014x4yC9XuYI= +cloud.google.com/go/pubsub/v2 v2.2.1/go.mod h1:O5f0KHG9zDheZAd3z5rlCRhxt2JQtB+t/IYLKK3Bpvw= +cloud.google.com/go/storage v1.56.0 h1:iixmq2Fse2tqxMbWhLWC9HfBj1qdxqAmiK8/eqtsLxI= +cloud.google.com/go/storage v1.56.0/go.mod h1:Tpuj6t4NweCLzlNbw9Z9iwxEkrSem20AetIeH/shgVU= cloud.google.com/go/trace v1.11.6 h1:2O2zjPzqPYAHrn3OKl029qlqG6W8ZdYaOWRyr8NgMT4= cloud.google.com/go/trace v1.11.6/go.mod h1:GA855OeDEBiBMzcckLPE2kDunIpC72N+Pq8WFieFjnI= entgo.io/ent v0.14.5 h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4= @@ -61,80 +63,78 @@ github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 h1:oygO0locgZJ github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.29.0 h1:UQUsRi8WTzhZntp5313l+CHIAT95ojUI2lpP/ExlZa4= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.29.0/go.mod h1:Cz6ft6Dkn3Et6l2v2a9/RpN7epQ1GtDlO6lj8bEcOvw= +github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.30.0 h1:sBEjpZlNHzK1voKq9695PJSX2o5NEXl7/OL3coiIY0c= +github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.30.0/go.mod h1:P4WPRUkOhJC13W//jWpyfJNDAIpvRbAUIYLX/4jtlE0= github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.53.0 h1:owcC2UnmsZycprQ5RfRgjydWhuoxg71LUfyiQdijZuM= github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.53.0/go.mod h1:ZPpqegjbE99EPKsu3iUWV22A04wzGPcAY/ziSIQEEgs= github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/cloudmock v0.53.0 h1:4LP6hvB4I5ouTbGgWtixJhgED6xdf67twf9PoY96Tbg= github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/cloudmock v0.53.0/go.mod h1:jUZ5LYlw40WMd07qxcQJD5M40aUxrfwqQX1g7zxYnrQ= github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.53.0 h1:Ron4zCA/yk6U7WOBXhTJcDpsUBG9npumK6xw2auFltQ= github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.53.0/go.mod h1:cSgYe11MCNYunTnRXrKiR/tHc0eoKjICUuWpNZoVCOo= -github.com/IBM/sarama v1.45.2 h1:8m8LcMCu3REcwpa7fCP6v2fuPuzVwXDAM2DOv3CBrKw= -github.com/IBM/sarama v1.45.2/go.mod h1:ppaoTcVdGv186/z6MEKsMm70A5fwJfRTpstI37kVn3Y= +github.com/IBM/sarama v1.46.3 h1:njRsX6jNlnR+ClJ8XmkO+CM4unbrNr/2vB5KK6UA+IE= +github.com/IBM/sarama v1.46.3/go.mod h1:GTUYiF9DMOZVe3FwyGT+dtSPceGFIgA+sPc5u6CBwko= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/agiledragon/gomonkey/v2 v2.3.1 h1:k+UnUY0EMNYUFUAQVETGY9uUTxjMdnUkP0ARyJS1zzs= -github.com/agiledragon/gomonkey/v2 v2.3.1/go.mod h1:ap1AmDzcVOAz1YpeJ3TCzIgstoaWLA6jbbgxfB4w2iY= github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= -github.com/ardanlabs/conf/v3 v3.8.0 h1:Mvv2wZJz8tIl705m5BU3ZRCP1V6TKY6qebA8i4sykrY= -github.com/ardanlabs/conf/v3 v3.8.0/go.mod h1:XlL9P0quWP4m1weOVFmlezabinbZLI05niDof/+Ochk= -github.com/aws/aws-sdk-go v1.55.7 h1:UJrkFq7es5CShfBwlWAC8DA077vp8PyVbQd3lqLiztE= -github.com/aws/aws-sdk-go v1.55.7/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU= -github.com/aws/aws-sdk-go-v2 v1.36.5 h1:0OF9RiEMEdDdZEMqF9MRjevyxAQcf6gY+E7vwBILFj0= -github.com/aws/aws-sdk-go-v2 v1.36.5/go.mod h1:EYrzvCCN9CMUTa5+6lf6MM4tq3Zjp8UhSGR/cBsjai0= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.11 h1:12SpdwU8Djs+YGklkinSSlcrPyj3H4VifVsKf78KbwA= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.11/go.mod h1:dd+Lkp6YmMryke+qxW/VnKyhMBDTYP41Q2Bb+6gNZgY= -github.com/aws/aws-sdk-go-v2/config v1.29.17 h1:jSuiQ5jEe4SAMH6lLRMY9OVC+TqJLP5655pBGjmnjr0= -github.com/aws/aws-sdk-go-v2/config v1.29.17/go.mod h1:9P4wwACpbeXs9Pm9w1QTh6BwWwJjwYvJ1iCt5QbCXh8= -github.com/aws/aws-sdk-go-v2/credentials v1.17.70 h1:ONnH5CM16RTXRkS8Z1qg7/s2eDOhHhaXVd72mmyv4/0= -github.com/aws/aws-sdk-go-v2/credentials v1.17.70/go.mod h1:M+lWhhmomVGgtuPOhO85u4pEa3SmssPTdcYpP/5J/xc= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.32 h1:KAXP9JSHO1vKGCr5f4O6WmlVKLFFXgWYAGoJosorxzU= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.32/go.mod h1:h4Sg6FQdexC1yYG9RDnOvLbW1a/P986++/Y/a+GyEM8= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.84 h1:cTXRdLkpBanlDwISl+5chq5ui1d1YWg4PWMR9c3kXyw= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.84/go.mod h1:kwSy5X7tfIHN39uucmjQVs2LvDdXEjQucgQQEqCggEo= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.36 h1:SsytQyTMHMDPspp+spo7XwXTP44aJZZAC7fBV2C5+5s= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.36/go.mod h1:Q1lnJArKRXkenyog6+Y+zr7WDpk4e6XlR6gs20bbeNo= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.36 h1:i2vNHQiXUvKhs3quBR6aqlgJaiaexz/aNvdCktW/kAM= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.36/go.mod h1:UdyGa7Q91id/sdyHPwth+043HhmP6yP9MBHgbZM0xo8= -github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 h1:bIqFDwgGXXN1Kpp99pDOdKMTTb5d2KyU5X/BZxjOkRo= -github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3/go.mod h1:H5O/EsxDWyU+LP/V8i5sm8cxoZgc2fdNR9bxlOFrQTo= -github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.36 h1:GMYy2EOWfzdP3wfVAGXBNKY5vK4K8vMET4sYOYltmqs= -github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.36/go.mod h1:gDhdAV6wL3PmPqBhiPbnlS447GoWs8HTTOYef9/9Inw= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.4 h1:CXV68E2dNqhuynZJPB80bhPQwAKqBWVer887figW6Jc= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.4/go.mod h1:/xFi9KtvBXP97ppCz1TAEvU1Uf66qvid89rbem3wCzQ= -github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.7.4 h1:nAP2GYbfh8dd2zGZqFRSMlq+/F6cMPBUuCsGAMkN074= -github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.7.4/go.mod h1:LT10DsiGjLWh4GbjInf9LQejkYEhBgBCjLG5+lvk4EE= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.17 h1:t0E6FzREdtCsiLIoLCWsYliNsRBgyGD/MCK571qk4MI= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.17/go.mod h1:ygpklyoaypuyDvOM5ujWGrYWpAK3h7ugnmKCU/76Ys4= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.17 h1:qcLWgdhq45sDM9na4cvXax9dyLitn8EYBRl8Ak4XtG4= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.17/go.mod h1:M+jkjBFZ2J6DJrjMv2+vkBbuht6kxJYtJiwoVgX4p4U= -github.com/aws/aws-sdk-go-v2/service/s3 v1.84.0 h1:0reDqfEN+tB+sozj2r92Bep8MEwBZgtAXTND1Kk9OXg= -github.com/aws/aws-sdk-go-v2/service/s3 v1.84.0/go.mod h1:kUklwasNoCn5YpyAqC/97r6dzTA1SRKJfKq16SXeoDU= +github.com/ardanlabs/conf/v3 v3.9.0 h1:aRBYHeD39/OkuaEXYIEoi4wvF3OnS7jUAPxXyLfEu20= +github.com/ardanlabs/conf/v3 v3.9.0/go.mod h1:XlL9P0quWP4m1weOVFmlezabinbZLI05niDof/+Ochk= +github.com/aws/aws-sdk-go-v2 v1.39.6 h1:2JrPCVgWJm7bm83BDwY5z8ietmeJUbh3O2ACnn+Xsqk= +github.com/aws/aws-sdk-go-v2 v1.39.6/go.mod h1:c9pm7VwuW0UPxAEYGyTmyurVcNrbF6Rt/wixFqDhcjE= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.3 h1:DHctwEM8P8iTXFxC/QK0MRjwEpWQeM9yzidCRjldUz0= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.3/go.mod h1:xdCzcZEtnSTKVDOmUZs4l/j3pSV6rpo1WXl5ugNsL8Y= +github.com/aws/aws-sdk-go-v2/config v1.31.17 h1:QFl8lL6RgakNK86vusim14P2k8BFSxjvUkcWLDjgz9Y= +github.com/aws/aws-sdk-go-v2/config v1.31.17/go.mod h1:V8P7ILjp/Uef/aX8TjGk6OHZN6IKPM5YW6S78QnRD5c= +github.com/aws/aws-sdk-go-v2/credentials v1.18.21 h1:56HGpsgnmD+2/KpG0ikvvR8+3v3COCwaF4r+oWwOeNA= +github.com/aws/aws-sdk-go-v2/credentials v1.18.21/go.mod h1:3YELwedmQbw7cXNaII2Wywd+YY58AmLPwX4LzARgmmA= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.13 h1:T1brd5dR3/fzNFAQch/iBKeX07/ffu/cLu+q+RuzEWk= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.13/go.mod h1:Peg/GBAQ6JDt+RoBf4meB1wylmAipb7Kg2ZFakZTlwk= +github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.20.3 h1:4GNV1lhyELGjMz5ILMRxDvxvOaeo3Ux9Z69S1EgVMMQ= +github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.20.3/go.mod h1:br7KA6edAAqDGUYJ+zVVPAyMrPhnN+zdt17yTUT6FPw= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.13 h1:a+8/MLcWlIxo1lF9xaGt3J/u3yOZx+CdSveSNwjhD40= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.13/go.mod h1:oGnKwIYZ4XttyU2JWxFrwvhF6YKiK/9/wmE3v3Iu9K8= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.13 h1:HBSI2kDkMdWz4ZM7FjwE7e/pWDEZ+nR95x8Ztet1ooY= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.13/go.mod h1:YE94ZoDArI7awZqJzBAZ3PDD2zSfuP7w6P2knOzIn8M= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.4 h1:WKuaxf++XKWlHWu9ECbMlha8WOEGm0OUEZqm4K/Gcfk= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.4/go.mod h1:ZWy7j6v1vWGmPReu0iSGvRiise4YI5SkR3OHKTZ6Wuc= +github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.13 h1:eg/WYAa12vqTphzIdWMzqYRVKKnCboVPRlvaybNCqPA= +github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.13/go.mod h1:/FDdxWhz1486obGrKKC1HONd7krpk38LBt+dutLcN9k= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.3 h1:x2Ibm/Af8Fi+BH+Hsn9TXGdT+hKbDd5XOTZxTMxDk7o= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.3/go.mod h1:IW1jwyrQgMdhisceG8fQLmQIydcT/jWY21rFhzgaKwo= +github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.4 h1:NvMjwvv8hpGUILarKw7Z4Q0w1H9anXKsesMxtw++MA4= +github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.4/go.mod h1:455WPHSwaGj2waRSpQp7TsnpOnBfw8iDfPfbwl7KPJE= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.13 h1:kDqdFvMY4AtKoACfzIGD8A0+hbT41KTKF//gq7jITfM= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.13/go.mod h1:lmKuogqSU3HzQCwZ9ZtcqOc5XGMqtDK7OIc2+DxiUEg= +github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.13 h1:zhBJXdhWIFZ1acfDYIhu4+LCzdUS2Vbcum7D01dXlHQ= +github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.13/go.mod h1:JaaOeCE368qn2Hzi3sEzY6FgAZVCIYcC2nwbro2QCh8= +github.com/aws/aws-sdk-go-v2/service/s3 v1.89.2 h1:xgBWsgaeUESl8A8k80p6yBdexMWDVeiDmJ/pkjohJ7c= +github.com/aws/aws-sdk-go-v2/service/s3 v1.89.2/go.mod h1:+wArOOrcHUevqdto9k1tKOF5++YTe9JEcPSc9Tx2ZSw= github.com/aws/aws-sdk-go-v2/service/sns v1.34.7 h1:OBuZE9Wt8h2imuRktu+WfjiTGrnYdCIJg8IX92aalHE= github.com/aws/aws-sdk-go-v2/service/sns v1.34.7/go.mod h1:4WYoZAhHt+dWYpoOQUgkUKfuQbE6Gg/hW4oXE0pKS9U= github.com/aws/aws-sdk-go-v2/service/sqs v1.38.8 h1:80dpSqWMwx2dAm30Ib7J6ucz1ZHfiv5OCRwN/EnCOXQ= github.com/aws/aws-sdk-go-v2/service/sqs v1.38.8/go.mod h1:IzNt/udsXlETCdvBOL0nmyMe2t9cGmXmZgsdoZGYYhI= -github.com/aws/aws-sdk-go-v2/service/sso v1.25.5 h1:AIRJ3lfb2w/1/8wOOSqYb9fUKGwQbtysJ2H1MofRUPg= -github.com/aws/aws-sdk-go-v2/service/sso v1.25.5/go.mod h1:b7SiVprpU+iGazDUqvRSLf5XmCdn+JtT1on7uNL6Ipc= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.3 h1:BpOxT3yhLwSJ77qIY3DoHAQjZsc4HEGfMCE4NGy3uFg= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.3/go.mod h1:vq/GQR1gOFLquZMSrxUK/cpvKCNVYibNyJ1m7JrU88E= -github.com/aws/aws-sdk-go-v2/service/sts v1.34.0 h1:NFOJ/NXEGV4Rq//71Hs1jC/NvPs1ezajK+yQmkwnPV0= -github.com/aws/aws-sdk-go-v2/service/sts v1.34.0/go.mod h1:7ph2tGpfQvwzgistp2+zga9f+bCjlQJPkPUmMgDSD7w= -github.com/aws/smithy-go v1.22.4 h1:uqXzVZNuNexwc/xrh6Tb56u89WDlJY6HS+KC0S4QSjw= -github.com/aws/smithy-go v1.22.4/go.mod h1:t1ufH5HMublsJYulve2RKmHDC15xu1f26kHCp/HgceI= +github.com/aws/aws-sdk-go-v2/service/sso v1.30.1 h1:0JPwLz1J+5lEOfy/g0SURC9cxhbQ1lIMHMa+AHZSzz0= +github.com/aws/aws-sdk-go-v2/service/sso v1.30.1/go.mod h1:fKvyjJcz63iL/ftA6RaM8sRCtN4r4zl4tjL3qw5ec7k= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.5 h1:OWs0/j2UYR5LOGi88sD5/lhN6TDLG6SfA7CqsQO9zF0= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.5/go.mod h1:klO+ejMvYsB4QATfEOIXk8WAEwN4N0aBfJpvC+5SZBo= +github.com/aws/aws-sdk-go-v2/service/sts v1.39.1 h1:mLlUgHn02ue8whiR4BmxxGJLR2gwU6s6ZzJ5wDamBUs= +github.com/aws/aws-sdk-go-v2/service/sts v1.39.1/go.mod h1:E19xDjpzPZC7LS2knI9E6BaRFDK43Eul7vd6rSq2HWk= +github.com/aws/smithy-go v1.23.2 h1:Crv0eatJUQhaManss33hS5r40CG3ZFH+21XSkqMrIUM= +github.com/aws/smithy-go v1.23.2/go.mod h1:LEj2LM3rBRQJxPZTB4KuzZkaZYnZPnvgIhb4pu07mx0= github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0= github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443 h1:aQ3y1lwWyqYPiWZThqv1aFbZMiM9vblcSArJRf2Irls= -github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8= +github.com/cncf/xds/go v0.0.0-20251022180443-0feb69152e9f h1:Y8xYupdHxryycyPlc9Y+bSQAYZnetRJ70VMVKm5CKI0= +github.com/cncf/xds/go v0.0.0-20251022180443-0feb69152e9f/go.mod h1:HlzOvOjVBOfTGSRXRyY0OiCS/3J1akRGQQpRO/7zyF4= github.com/coder/websocket v1.8.13 h1:f3QZdXy7uGVz+4uCJy2nTZyM0yTBj8yANEHhqlXZ9FE= github.com/coder/websocket v1.8.13/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs= github.com/containrrr/shoutrrr v0.8.0 h1:mfG2ATzIS7NR2Ec6XL+xyoHzN97H8WPjir8aYzJUSec= github.com/containrrr/shoutrrr v0.8.0/go.mod h1:ioyQAyu1LJY6sILuNyKaQaw+9Ttik5QePU8atnAdO2o= +github.com/coreos/go-oidc/v3 v3.17.0 h1:hWBGaQfbi0iVviX4ibC7bk8OKT5qNr4klBaCHVNvehc= +github.com/coreos/go-oidc/v3 v3.17.0/go.mod h1:wqPbKFrVnE90vty060SB40FCJ8fTHTxSwyXJqZH+sI8= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -151,12 +151,12 @@ github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 h1:Oy0F4A github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3/go.mod h1:YvSRo5mw33fLEx1+DlK6L2VV43tJt5Eyel9n9XBcR+0= github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= -github.com/ebitengine/purego v0.8.4 h1:CF7LEKg5FFOsASUj0+QwaXf8Ht6TlFxg09+S9wz0omw= -github.com/ebitengine/purego v0.8.4/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= -github.com/envoyproxy/go-control-plane v0.13.4 h1:zEqyPVyku6IvWCFwux4x9RxkLOMUL+1vC9xUFv5l2/M= -github.com/envoyproxy/go-control-plane v0.13.4/go.mod h1:kDfuBlDVsSj2MjrLEtRWtHlsWIFcGyB2RMO44Dc5GZA= -github.com/envoyproxy/go-control-plane/envoy v1.32.4 h1:jb83lalDRZSpPWW2Z7Mck/8kXZ5CQAFYVjQcdVIr83A= -github.com/envoyproxy/go-control-plane/envoy v1.32.4/go.mod h1:Gzjc5k8JcJswLjAx1Zm+wSYE20UrLtt7JZMWiWQXQEw= +github.com/ebitengine/purego v0.9.1 h1:a/k2f2HQU3Pi399RPW1MOaZyhKJL9w/xFpKAg4q1s0A= +github.com/ebitengine/purego v0.9.1/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= +github.com/envoyproxy/go-control-plane v0.13.5-0.20251024222203-75eaa193e329 h1:K+fnvUM0VZ7ZFJf0n4L/BRlnsb9pL/GuDG6FqaH+PwM= +github.com/envoyproxy/go-control-plane v0.13.5-0.20251024222203-75eaa193e329/go.mod h1:Alz8LEClvR7xKsrq3qzoc4N0guvVNSS8KmSChGYr9hs= +github.com/envoyproxy/go-control-plane/envoy v1.35.0 h1:ixjkELDE+ru6idPxcHLj8LBVc2bFP7iBytj353BoHUo= +github.com/envoyproxy/go-control-plane/envoy v1.35.0/go.mod h1:09qwbGVuSWWAyN5t/b3iyVfz5+z8QWGrzkoqm/8SbEs= github.com/envoyproxy/go-control-plane/ratelimit v0.1.0 h1:/G9QYbddjL25KvtKTv3an9lx6VBE2cnb8wp1vEGNYGI= github.com/envoyproxy/go-control-plane/ratelimit v0.1.0/go.mod h1:Wk+tMFAFbCXaJPzVVHnPgRKdUdwW/KdbRt94AzgRee4= github.com/envoyproxy/protoc-gen-validate v1.2.1 h1:DEo3O99U8j4hBFwbJfrz9VtgcDfUKS7KJ7spH3d86P8= @@ -172,20 +172,20 @@ github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzP github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= -github.com/gabriel-vasile/mimetype v1.4.9 h1:5k+WDwEsD9eTLL8Tz3L0VnmVh9QxGjRmjBvAG7U/oYY= -github.com/gabriel-vasile/mimetype v1.4.9/go.mod h1:WnSQhFKJuBlRyLiKohA/2DtIlPFAbguNaG7QCHcyGok= +github.com/gabriel-vasile/mimetype v1.4.11 h1:AQvxbp830wPhHTqc1u7nzoLT+ZFxGY7emj5DR5DYFik= +github.com/gabriel-vasile/mimetype v1.4.11/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s= github.com/gen2brain/avif v0.4.4 h1:Ga/ss7qcWWQm2bxFpnjYjhJsNfZrWs5RsyklgFjKRSE= github.com/gen2brain/avif v0.4.4/go.mod h1:/XCaJcjZraQwKVhpu9aEd9aLOssYOawLvhMBtmHVGqk= -github.com/gen2brain/heic v0.4.5 h1:Cq3hPu6wwlTJNv2t48ro3oWje54h82Q5pALeCBNgaSk= -github.com/gen2brain/heic v0.4.5/go.mod h1:ECnpqbqLu0qSje4KSNWUUDK47UPXPzl80T27GWGEL5I= +github.com/gen2brain/heic v0.4.6 h1:sNh3mfaEZLmDJnFc5WoLxCzh/wj5GwfJScPfvF5CNJE= +github.com/gen2brain/heic v0.4.6/go.mod h1:ECnpqbqLu0qSje4KSNWUUDK47UPXPzl80T27GWGEL5I= github.com/gen2brain/jpegxl v0.4.5 h1:TWpVEn5xkIfsswzkjHBArd0Cc9AE0tbjBSoa0jDsrbo= github.com/gen2brain/jpegxl v0.4.5/go.mod h1:4kWYJ18xCEuO2vzocYdGpeqNJ990/Gjy3uLMg5TBN6I= github.com/gen2brain/webp v0.5.5 h1:MvQR75yIPU/9nSqYT5h13k4URaJK3gf9tgz/ksRbyEg= github.com/gen2brain/webp v0.5.5/go.mod h1:xOSMzp4aROt2KFW++9qcK/RBTOVC2S9tJG66ip/9Oc0= -github.com/go-chi/chi/v5 v5.2.2 h1:CMwsvRVTbXVytCk1Wd72Zy1LAsAh9GxMmSNWLHCG618= -github.com/go-chi/chi/v5 v5.2.2/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops= -github.com/go-jose/go-jose/v4 v4.1.1 h1:JYhSgy4mXXzAdF3nUx3ygx347LRXJRrpgyU3adRmkAI= -github.com/go-jose/go-jose/v4 v4.1.1/go.mod h1:BdsZGqgdO3b6tTc6LSE56wcDbMMLuPsw5d4ZD5f94kA= +github.com/go-chi/chi/v5 v5.2.3 h1:WQIt9uxdsAbgIYgid+BpYc+liqQZGMHRaUwp0JUcvdE= +github.com/go-chi/chi/v5 v5.2.3/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops= +github.com/go-jose/go-jose/v4 v4.1.3 h1:CVLmWDhDVRa6Mi/IgCgaopNosCaHz7zrMeF9MlZRkrs= +github.com/go-jose/go-jose/v4 v4.1.3/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -195,22 +195,41 @@ github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4= github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4= -github.com/go-openapi/jsonpointer v0.21.2 h1:AqQaNADVwq/VnkCmQg6ogE+M3FOsKTytwges0JdwVuA= -github.com/go-openapi/jsonpointer v0.21.2/go.mod h1:50I1STOfbY1ycR8jGz8DaMeLCdXiI6aDteEdRNNzpdk= -github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ= -github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4= -github.com/go-openapi/spec v0.21.0 h1:LTVzPc3p/RzRnkQqLRndbAzjY0d0BCL72A6j3CdL9ZY= -github.com/go-openapi/spec v0.21.0/go.mod h1:78u6VdPw81XU44qEWGhtr982gJ5BWg2c0I5XwVMotYk= -github.com/go-openapi/swag v0.23.1 h1:lpsStH0n2ittzTnbaSloVZLuB5+fvSY/+hnagBjSNZU= -github.com/go-openapi/swag v0.23.1/go.mod h1:STZs8TbRvEQQKUA+JZNAm3EWlgaOBGpyFDqQnDHMef0= +github.com/go-openapi/jsonpointer v0.22.3 h1:dKMwfV4fmt6Ah90zloTbUKWMD+0he+12XYAsPotrkn8= +github.com/go-openapi/jsonpointer v0.22.3/go.mod h1:0lBbqeRsQ5lIanv3LHZBrmRGHLHcQoOXQnf88fHlGWo= +github.com/go-openapi/jsonreference v0.21.3 h1:96Dn+MRPa0nYAR8DR1E03SblB5FJvh7W6krPI0Z7qMc= +github.com/go-openapi/jsonreference v0.21.3/go.mod h1:RqkUP0MrLf37HqxZxrIAtTWW4ZJIK1VzduhXYBEeGc4= +github.com/go-openapi/spec v0.22.1 h1:beZMa5AVQzRspNjvhe5aG1/XyBSMeX1eEOs7dMoXh/k= +github.com/go-openapi/spec v0.22.1/go.mod h1:c7aeIQT175dVowfp7FeCvXXnjN/MrpaONStibD2WtDA= +github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= +github.com/go-openapi/swag/conv v0.25.4 h1:/Dd7p0LZXczgUcC/Ikm1+YqVzkEeCc9LnOWjfkpkfe4= +github.com/go-openapi/swag/conv v0.25.4/go.mod h1:3LXfie/lwoAv0NHoEuY1hjoFAYkvlqI/Bn5EQDD3PPU= +github.com/go-openapi/swag/jsonname v0.25.4 h1:bZH0+MsS03MbnwBXYhuTttMOqk+5KcQ9869Vye1bNHI= +github.com/go-openapi/swag/jsonname v0.25.4/go.mod h1:GPVEk9CWVhNvWhZgrnvRA6utbAltopbKwDu8mXNUMag= +github.com/go-openapi/swag/jsonutils v0.25.4 h1:VSchfbGhD4UTf4vCdR2F4TLBdLwHyUDTd1/q4i+jGZA= +github.com/go-openapi/swag/jsonutils v0.25.4/go.mod h1:7OYGXpvVFPn4PpaSdPHJBtF0iGnbEaTk8AvBkoWnaAY= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.25.4 h1:IACsSvBhiNJwlDix7wq39SS2Fh7lUOCJRmx/4SN4sVo= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.25.4/go.mod h1:Mt0Ost9l3cUzVv4OEZG+WSeoHwjWLnarzMePNDAOBiM= +github.com/go-openapi/swag/loading v0.25.4 h1:jN4MvLj0X6yhCDduRsxDDw1aHe+ZWoLjW+9ZQWIKn2s= +github.com/go-openapi/swag/loading v0.25.4/go.mod h1:rpUM1ZiyEP9+mNLIQUdMiD7dCETXvkkC30z53i+ftTE= +github.com/go-openapi/swag/stringutils v0.25.4 h1:O6dU1Rd8bej4HPA3/CLPciNBBDwZj9HiEpdVsb8B5A8= +github.com/go-openapi/swag/stringutils v0.25.4/go.mod h1:GTsRvhJW5xM5gkgiFe0fV3PUlFm0dr8vki6/VSRaZK0= +github.com/go-openapi/swag/typeutils v0.25.4 h1:1/fbZOUN472NTc39zpa+YGHn3jzHWhv42wAJSN91wRw= +github.com/go-openapi/swag/typeutils v0.25.4/go.mod h1:Ou7g//Wx8tTLS9vG0UmzfCsjZjKhpjxayRKTHXf2pTE= +github.com/go-openapi/swag/yamlutils v0.25.4 h1:6jdaeSItEUb7ioS9lFoCZ65Cne1/RZtPBZ9A56h92Sw= +github.com/go-openapi/swag/yamlutils v0.25.4/go.mod h1:MNzq1ulQu+yd8Kl7wPOut/YHAAU/H6hL91fF+E2RFwc= +github.com/go-openapi/testify/enable/yaml/v2 v2.0.2 h1:0+Y41Pz1NkbTHz8NngxTuAXxEodtNSI1WG1c/m5Akw4= +github.com/go-openapi/testify/enable/yaml/v2 v2.0.2/go.mod h1:kme83333GCtJQHXQ8UKX3IBZu6z8T5Dvy5+CW3NLUUg= +github.com/go-openapi/testify/v2 v2.0.2 h1:X999g3jeLcoY8qctY/c/Z8iBHTbwLz7R2WXd6Ub6wls= +github.com/go-openapi/testify/v2 v2.0.2/go.mod h1:HCPmvFFnheKK2BuwSA0TbbdxJ3I16pjwMkYkP4Ywn54= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.27.0 h1:w8+XrWVMhGkxOaaowyKH35gFydVHOvC0/uWoy2Fzwn4= -github.com/go-playground/validator/v10 v10.27.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo= +github.com/go-playground/validator/v10 v10.28.0 h1:Q7ibns33JjyW48gHkuFT91qX48KG0ktULL6FgHdG688= +github.com/go-playground/validator/v10 v10.28.0/go.mod h1:GoI6I1SjPBh9p7ykNE/yj3fFYbyDOpwMn5KXd+m2hUU= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= @@ -228,7 +247,6 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs= github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -243,13 +261,12 @@ github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17k github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= github.com/google/s2a-go v0.1.9 h1:LGD7gtMgezd8a/Xak7mEWL0PjoTQFvpRudN895yqKW0= github.com/google/s2a-go v0.1.9/go.mod h1:YA0Ei2ZQL3acow2O62kdp9UlnvMmU7kA6Eutn0dXayM= -github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/wire v0.6.0 h1:HBkoIh4BdSxoyo9PveV8giw7ZsaBOvzWKfcg/6MrVwI= -github.com/google/wire v0.6.0/go.mod h1:F4QhpQ9EDIdJ1Mbop/NZBRB+5yrR6qg3BnctaoUk6NA= -github.com/googleapis/enterprise-certificate-proxy v0.3.6 h1:GW/XbdyBFQ8Qe+YAmFU9uHLo7OnF5tL52HFAgMmyrf4= -github.com/googleapis/enterprise-certificate-proxy v0.3.6/go.mod h1:MkHOF77EYAE7qfSuSS9PU6g4Nt4e11cnsDUowfwewLA= +github.com/google/wire v0.7.0 h1:JxUKI6+CVBgCO2WToKy/nQk0sS+amI9z9EjVmdaocj4= +github.com/google/wire v0.7.0/go.mod h1:n6YbUQD9cPKTnHXEBN2DXlOp/mVADhVErcMFb0v3J18= +github.com/googleapis/enterprise-certificate-proxy v0.3.7 h1:zrn2Ee/nWmHulBx5sAVrGgAa0f2/R35S4DJwfFaUPFQ= +github.com/googleapis/enterprise-certificate-proxy v0.3.7/go.mod h1:MkHOF77EYAE7qfSuSS9PU6g4Nt4e11cnsDUowfwewLA= github.com/googleapis/gax-go/v2 v2.15.0 h1:SyjDc1mGgZU5LncH8gimWo9lW1DtIfPibOG81vgd/bo= github.com/googleapis/gax-go/v2 v2.15.0/go.mod h1:zVVkkxAQHa1RQpg9z2AUCMnKhi0Qld9rcmyfL1OZhoc= github.com/gorilla/schema v1.4.1 h1:jUg5hUjCSDZpNGLuXQOgIWGdlgrIdYvgQ0wZtdK1M3E= @@ -258,14 +275,11 @@ github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+ github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= -github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= -github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= +github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/hcl/v2 v2.18.1 h1:6nxnOJFku1EuSawSD81fuviYUV8DxFr3fp2dUi3ZYSo= github.com/hashicorp/hcl/v2 v2.18.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= github.com/hay-kot/httpkit v0.0.11 h1:ZdB2uqsFBSDpfUoClGK5c5orjBjQkEVSXh7fZX5FKEk= @@ -284,18 +298,12 @@ github.com/jcmturner/gokrb5/v8 v8.4.4 h1:x1Sv4HaTpepFkXbt2IkL29DXRf8sOfZXo8eRKh6 github.com/jcmturner/gokrb5/v8 v8.4.4/go.mod h1:1btQEpgT6k+unzCwX1KdWMEwPPkkgBtP+F6aCACiMrs= github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZY= github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= -github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= -github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= -github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= -github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= -github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/keybase/go-keychain v0.0.1 h1:way+bWYa6lDppZoZcgMbYsvC7GxljxrskdNInRtuthU= github.com/keybase/go-keychain v0.0.1/go.mod h1:PdEILRW3i9D8JcdM+FmY6RwkHGnhHxXwkPPMeUgOK1k= -github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= -github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= +github.com/klauspost/compress v1.18.2 h1:iiPHWW0YrcFgpBYhsA6D1+fqHssJscY/Tm/y2Uqnapk= +github.com/klauspost/compress v1.18.2/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4= github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y= github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -310,8 +318,6 @@ github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= -github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4= -github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= @@ -319,6 +325,8 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs= github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY= @@ -331,22 +339,22 @@ github.com/nats-io/jwt/v2 v2.5.0 h1:WQQ40AAlqqfx+f6ku+i0pOVm+ASirD4fUh+oQsiE9Ak= github.com/nats-io/jwt/v2 v2.5.0/go.mod h1:24BeQtRwxRV8ruvC4CojXlx/WQ/VjuwlYiH+vu/+ibI= github.com/nats-io/nats-server/v2 v2.9.23 h1:6Wj6H6QpP9FMlpCyWUaNu2yeZ/qGj+mdRkZ1wbikExU= github.com/nats-io/nats-server/v2 v2.9.23/go.mod h1:wEjrEy9vnqIGE4Pqz4/c75v9Pmaq7My2IgFmnykc4C0= -github.com/nats-io/nats.go v1.44.0 h1:ECKVrDLdh/kDPV1g0gAQ+2+m2KprqZK5O/eJAyAnH2M= -github.com/nats-io/nats.go v1.44.0/go.mod h1:iRWIPokVIFbVijxuMQq4y9ttaBTMe0SFdlZfMDd+33g= -github.com/nats-io/nkeys v0.4.11 h1:q44qGV008kYd9W1b1nEBkNzvnWxtRSQ7A8BoqRrcfa0= -github.com/nats-io/nkeys v0.4.11/go.mod h1:szDimtgmfOi9n25JpfIdGw12tZFYXqhGxjhVxsatHVE= +github.com/nats-io/nats.go v1.47.0 h1:YQdADw6J/UfGUd2Oy6tn4Hq6YHxCaJrVKayxxFqYrgM= +github.com/nats-io/nats.go v1.47.0/go.mod h1:iRWIPokVIFbVijxuMQq4y9ttaBTMe0SFdlZfMDd+33g= +github.com/nats-io/nkeys v0.4.12 h1:nssm7JKOG9/x4J8II47VWCL1Ds29avyiQDRn0ckMvDc= +github.com/nats-io/nkeys v0.4.12/go.mod h1:MT59A1HYcjIcyQDJStTfaOY6vhy9XTUjOFo+SVsvpBg= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= -github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= -github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= -github.com/olahol/melody v1.3.0 h1:n7UlKiQnxVrgxKoM0d7usZiN+Z0y2lVENtYLgKtXS6s= -github.com/olahol/melody v1.3.0/go.mod h1:GgkTl6Y7yWj/HtfD48Q5vLKPVoZOH+Qqgfa7CvJgJM4= +github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w= +github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= +github.com/olahol/melody v1.4.0 h1:Pa5SdeZL/zXPi1tJuMAPDbl4n3gQOThSL6G1p4qZ4SI= +github.com/olahol/melody v1.4.0/go.mod h1:GgkTl6Y7yWj/HtfD48Q5vLKPVoZOH+Qqgfa7CvJgJM4= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU= github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts= github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= -github.com/otiai10/copy v1.7.0 h1:hVoPiN+t+7d2nzzwMiDHPSOogsWAStewq3TwU05+clE= -github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U= github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM= github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM= github.com/pierrec/lz4/v4 v4.1.22 h1:cKFw6uJDK+/gfw5BcDL0JL5aBsAFdsIT18eRtLj7VIU= @@ -360,10 +368,10 @@ github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= -github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= -github.com/pressly/goose/v3 v3.24.3 h1:DSWWNwwggVUsYZ0X2VitiAa9sKuqtBfe+Jr9zFGwWlM= -github.com/pressly/goose/v3 v3.24.3/go.mod h1:v9zYL4xdViLHCUUJh/mhjnm6JrK7Eul8AS93IxiZM4E= +github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU= +github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= +github.com/pressly/goose/v3 v3.26.0 h1:KJakav68jdH0WDvoAcj8+n61WqOIaPGgH0bJWS6jpmM= +github.com/pressly/goose/v3 v3.26.0/go.mod h1:4hC1KrritdCxtuFsqgs1R4AU5bWtTAf+cnWvfhf2DNY= github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw= github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o= github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 h1:bsUq1dX0N8AOIL7EB/X911+m4EHsnWEHeJ0c+3TTBrg= @@ -381,12 +389,16 @@ github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah2SE= github.com/sethvargo/go-retry v0.3.0/go.mod h1:mNX17F0C/HguQMyMyJxcnU471gOZGxCLyYaFyAZraas= -github.com/shirou/gopsutil/v4 v4.25.7 h1:bNb2JuqKuAu3tRlPv5piSmBZyMfecwQ+t/ILq+1JqVM= -github.com/shirou/gopsutil/v4 v4.25.7/go.mod h1:XV/egmwJtd3ZQjBpJVY5kndsiOO4IRqy9TQnmm6VP7U= +github.com/shirou/gopsutil/v4 v4.25.11 h1:X53gB7muL9Gnwwo2evPSE+SfOrltMoR6V3xJAXZILTY= +github.com/shirou/gopsutil/v4 v4.25.11/go.mod h1:EivAfP5x2EhLp2ovdpKSozecVXn1TmuG7SMzs/Wh4PU= github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0= github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M= -github.com/spiffe/go-spiffe/v2 v2.5.0 h1:N2I01KCUkv1FAjZXJMwh95KK1ZIQLYbPfhaxw8WS0hE= -github.com/spiffe/go-spiffe/v2 v2.5.0/go.mod h1:P+NxobPc6wXhVtINNtFjNWGBTreew1GBUCwT2wPmb7g= +github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= +github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spiffe/go-spiffe/v2 v2.6.0 h1:l+DolpxNWYgruGQVV0xsfeya3CsC7m8iBzDnMpsbLuo= +github.com/spiffe/go-spiffe/v2 v2.6.0/go.mod h1:gm2SeUoMZEtpnzPNs2Csc0D/gX33k1xIx7lEzqblHEs= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= @@ -396,26 +408,22 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/sv-tools/openapi v0.2.1 h1:ES1tMQMJFGibWndMagvdoo34T1Vllxr1Nlm5wz6b1aA= -github.com/sv-tools/openapi v0.2.1/go.mod h1:k5VuZamTw1HuiS9p2Wl5YIDWzYnHG6/FgPOSFXLAhGg= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/swaggo/files/v2 v2.0.2 h1:Bq4tgS/yxLB/3nwOMcul5oLEUKa877Ykgz3CJMVbQKU= github.com/swaggo/files/v2 v2.0.2/go.mod h1:TVqetIzZsO9OhHX1Am9sRf9LdrFZqoK49N37KON/jr0= github.com/swaggo/http-swagger/v2 v2.0.2 h1:FKCdLsl+sFCx60KFsyM0rDarwiUSZ8DqbfSyIKC9OBg= github.com/swaggo/http-swagger/v2 v2.0.2/go.mod h1:r7/GBkAWIfK6E/OLnE8fXnviHiDeAHmgIyooa4xm3AQ= -github.com/swaggo/swag v1.8.1 h1:JuARzFX1Z1njbCGz+ZytBR15TFJwF2Q7fu8puJHhQYI= -github.com/swaggo/swag v1.8.1/go.mod h1:ugemnJsPZm/kRwFUnzBlbHRd0JY9zE1M4F+uy2pAaPQ= -github.com/swaggo/swag/v2 v2.0.0-rc4 h1:SZ8cK68gcV6cslwrJMIOqPkJELRwq4gmjvk77MrvHvY= -github.com/swaggo/swag/v2 v2.0.0-rc4/go.mod h1:Ow7Y8gF16BTCDn8YxZbyKn8FkMLRUHekv1kROJZpbvE= -github.com/tetratelabs/wazero v1.9.0 h1:IcZ56OuxrtaEz8UYNRHBrUa9bYeX9oVY93KspZZBf/I= -github.com/tetratelabs/wazero v1.9.0/go.mod h1:TSbcXCfFP0L2FGkRPxHphadXPjo1T6W+CseNNY7EkjM= -github.com/tinylib/msgp v1.3.0 h1:ULuf7GPooDaIlbyvgAxBV/FI7ynli6LZ1/nVUNu+0ww= -github.com/tinylib/msgp v1.3.0/go.mod h1:ykjzy2wzgrlvpDCRc4LA8UXy6D8bzMSuAF3WD57Gok0= -github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8Ol49K4= -github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4= -github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso= -github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ= +github.com/swaggo/swag v1.16.6 h1:qBNcx53ZaX+M5dxVyTrgQ0PJ/ACK+NzhwcbieTt+9yI= +github.com/swaggo/swag v1.16.6/go.mod h1:ngP2etMK5a0P3QBizic5MEwpRmluJZPHjXcMoj4Xesg= +github.com/tetratelabs/wazero v1.10.1 h1:2DugeJf6VVk58KTPszlNfeeN8AhhpwcZqkJj2wwFuH8= +github.com/tetratelabs/wazero v1.10.1/go.mod h1:DRm5twOQ5Gr1AoEdSi0CLjDQF1J9ZAuyqFIjl1KKfQU= +github.com/tinylib/msgp v1.6.1 h1:ESRv8eL3u+DNHUoSAAQRE50Hm162zqAnBoGv9PzScPY= +github.com/tinylib/msgp v1.6.1/go.mod h1:RSp0LW9oSxFut3KzESt5Voq4GVWyS+PSulT77roAqEA= +github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA= +github.com/tklauser/go-sysconf v0.3.16/go.mod h1:/qNL9xxDhc7tx3HSRsLWNnuzbVfh3e7gh/BmM179nYI= +github.com/tklauser/numcpus v0.11.0 h1:nSTwhKH5e1dMNsCdVBukSZrURJRoHbSEQjdEbY+9RXw= +github.com/tklauser/numcpus v0.11.0/go.mod h1:z+LwcLq54uWZTX0u/bGobaV34u6V7KNlTZejzM6/3MQ= github.com/yeqown/go-qrcode/v2 v2.2.5 h1:HCOe2bSjkhZyYoyyNaXNzh4DJZll6inVJQQw+8228Zk= github.com/yeqown/go-qrcode/v2 v2.2.5/go.mod h1:uHpt9CM0V1HeXLz+Wg5MN50/sI/fQhfkZlOM+cOTHxw= github.com/yeqown/go-qrcode/writer/standard v1.3.0 h1:chdyhEfRtUPgQtuPeaWVGQ/TQx4rE1PqeoW3U+53t34= @@ -433,62 +441,57 @@ github.com/zeebo/assert v1.1.0 h1:hU1L1vLTHsnO8x8c9KAR5GmM5QscxHg5RNU5z5qbUWY= github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= github.com/zeebo/blake3 v0.2.4 h1:KYQPkhpRtcqh0ssGYcKLG1JYvddkEA8QwCM/yBqhaZI= github.com/zeebo/blake3 v0.2.4/go.mod h1:7eeQ6d2iXWRGF6npfaxl2CU+xy2Fjo2gxeyZGCRUjcE= -github.com/zeebo/errs v1.4.0 h1:XNdoD/RRMKP7HD0UhJnIzUy74ISdGGxURlYG8HSWSfM= -github.com/zeebo/errs v1.4.0/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4= github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo= github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4= go.balki.me/anyhttp v0.5.2 h1:et4tCDXLeXpWfMNvRKG7ojfrnlr3du7cEaG966MLSpA= go.balki.me/anyhttp v0.5.2/go.mod h1:JhfekOIjgVODoVqUCficjpIgmB3wwlB7jhN0eN2EZ/s= -go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= -go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= -go.opentelemetry.io/contrib/detectors/gcp v1.37.0 h1:B+WbN9RPsvobe6q4vP6KgM8/9plR/HNjgGBrfcOlweA= -go.opentelemetry.io/contrib/detectors/gcp v1.37.0/go.mod h1:K5zQ3TT7p2ru9Qkzk0bKtCql0RGkPj9pRjpXgZJZ+rU= +go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= +go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= +go.opentelemetry.io/contrib/detectors/gcp v1.38.0 h1:ZoYbqX7OaA/TAikspPl3ozPI6iY6LiIY9I8cUfm+pJs= +go.opentelemetry.io/contrib/detectors/gcp v1.38.0/go.mod h1:SU+iU7nu5ud4oCb3LQOhIZ3nRLj6FNVrKgtflbaf2ts= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.62.0 h1:rbRJ8BBoVMsQShESYZ0FkvcITu8X8QNwJogcLUmDNNw= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.62.0/go.mod h1:ru6KHrNtNHxM4nD/vd6QrLVWgKhxPYgblq4VAtNawTQ= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0 h1:Hf9xI/XLML9ElpiHVDNwvqI0hIFlzV8dgIr35kV1kRU= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0/go.mod h1:NfchwuyNoMcZ5MLHwPrODwUF1HWCXWrL31s8gSAdIKY= -go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ= -go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I= +go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= +go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.37.0 h1:6VjV6Et+1Hd2iLZEPtdV7vie80Yyqf7oikJLjQ/myi0= go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.37.0/go.mod h1:u8hcp8ji5gaM/RfcOo8z9NMnf1pVLfVY7lBY2VOGuUU= -go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE= -go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E= -go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI= -go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg= -go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc= -go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps= -go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4= -go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0= +go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= +go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= +go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= +go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= +go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= +go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= +go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= +go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -gocloud.dev v0.43.0 h1:aW3eq4RMyehbJ54PMsh4hsp7iX8cO/98ZRzJJOzN/5M= -gocloud.dev v0.43.0/go.mod h1:eD8rkg7LhKUHrzkEdLTZ+Ty/vgPHPCd+yMQdfelQVu4= -gocloud.dev/pubsub/kafkapubsub v0.43.0 h1:Kgwi0na69W3RgxEffEkdrMhox6A3Q0gajoJtjHGVr/s= -gocloud.dev/pubsub/kafkapubsub v0.43.0/go.mod h1:uKI0CXuj7HJ/YnnOLQ3VkDnuUnkz+q/d+tRzmfhmOOU= -gocloud.dev/pubsub/natspubsub v0.43.0 h1:k35tFoaorvD9Fa26zVEEzyXiMOEyXNHc0pBOmRYvQI0= -gocloud.dev/pubsub/natspubsub v0.43.0/go.mod h1:xJn8TO8pGYieDn6AsRFsYfhQW8cnC+xGmG9APGNxkpQ= -gocloud.dev/pubsub/rabbitpubsub v0.43.0 h1:6nNZFSlJ1dk2GujL8PFltfLz3vC6IbrpjGS4FTduo1s= -gocloud.dev/pubsub/rabbitpubsub v0.43.0/go.mod h1:sEaueAGat+OASRoB3QDkghCtibKttgg7X6zsPTm1pl0= +go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= +gocloud.dev v0.44.0 h1:iVyMAqFl2r6xUy7M4mfqwlN+21UpJoEtgHEcfiLMUXs= +gocloud.dev v0.44.0/go.mod h1:ZmjROXGdC/eKZLF1N+RujDlFRx3D+4Av2thREKDMVxY= +gocloud.dev/pubsub/kafkapubsub v0.44.0 h1:nQvzfnEN6lCh4j2p+1t0OLS4nmC2U/Ji5aWHVwgkifg= +gocloud.dev/pubsub/kafkapubsub v0.44.0/go.mod h1:/gcNz6OG4HgcY+w2LXwwY4qaRMgtq+SXoPSQU2jOlcw= +gocloud.dev/pubsub/natspubsub v0.44.0 h1:1Us76ckkdgtiE1p1rJZ+38b9TQP051bmjAiQlFQzYrM= +gocloud.dev/pubsub/natspubsub v0.44.0/go.mod h1:PvVAGIhL14PWGwWIXX/zAK42ixr2/PKP4Q4yMiAUraQ= +gocloud.dev/pubsub/rabbitpubsub v0.44.0 h1:MpRIO6XJ/JTqrlUWt3CxwDe1LvaiXUVu4sS5cv4f/AM= +gocloud.dev/pubsub/rabbitpubsub v0.44.0/go.mod h1:BB9+qT3r6g4M5+4asiXaEeqw4QAOzsWusO5krYaqkdA= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= -golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4= -golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc= -golang.org/x/exp v0.0.0-20250813145105-42675adae3e6 h1:SbTAbRFnd5kjQXbczszQ0hdk3ctwYf3qBNH9jIsGclE= -golang.org/x/exp v0.0.0-20250813145105-42675adae3e6/go.mod h1:4QTo5u+SEIbbKW1RacMZq1YEfOBqeXa19JeshGi+zc4= -golang.org/x/image v0.30.0 h1:jD5RhkmVAnjqaCUXfbGBrn3lpxbknfN9w2UhHHU+5B4= -golang.org/x/image v0.30.0/go.mod h1:SAEUTxCCMWSrJcCy/4HwavEsfZZJlYxeHLc6tTiAe/c= +golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q= +golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4= +golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39 h1:DHNhtq3sNNzrvduZZIiFyXWOL9IWaDPHqTnLJp+rCBY= +golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39/go.mod h1:46edojNIoXTNOhySWIWdix628clX9ODXwPsQuG6hsK0= +golang.org/x/image v0.33.0 h1:LXRZRnv1+zGd5XBUVRFmYEphyyKJjQjCRiOuAP3sZfQ= +golang.org/x/image v0.33.0/go.mod h1:DD3OsTYT9chzuzTQt+zMcOlBHgfoKQb1gry8p76Y1sc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ= -golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc= +golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk= +golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -496,20 +499,14 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= -golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE= -golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg= -golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI= -golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU= +golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= +golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= +golang.org/x/oauth2 v0.33.0 h1:4Q+qn+E5z8gPRJfmRy7C2gGG3T4jIprK6aSYgTXGRpo= +golang.org/x/oauth2 v0.33.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw= -golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= +golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -522,74 +519,64 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= +golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= -golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= -golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= -golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE= -golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg= +golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= +golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= +golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI= +golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= -golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= -golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg= -golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s= +golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ= +golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhSt0ABwskkZKjD3bXGnZGpNY= golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= -google.golang.org/api v0.247.0 h1:tSd/e0QrUlLsrwMKmkbQhYVa109qIintOls2Wh6bngc= -google.golang.org/api v0.247.0/go.mod h1:r1qZOPmxXffXg6xS5uhx16Fa/UFY8QU/K4bfKrnvovM= +gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= +gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= +google.golang.org/api v0.257.0 h1:8Y0lzvHlZps53PEaw+G29SsQIkuKrumGWs9puiexNAA= +google.golang.org/api v0.257.0/go.mod h1:4eJrr+vbVaZSqs7vovFd1Jb/A6ml6iw2e6FBYf3GAO4= google.golang.org/genproto v0.0.0-20250715232539-7130f93afb79 h1:Nt6z9UHqSlIdIGJdz6KhTIs2VRx/iOsA5iE8bmQNcxs= google.golang.org/genproto v0.0.0-20250715232539-7130f93afb79/go.mod h1:kTmlBHMPqR5uCZPBvwa2B18mvubkjyY3CRLI0c6fj0s= -google.golang.org/genproto/googleapis/api v0.0.0-20250715232539-7130f93afb79 h1:iOye66xuaAK0WnkPuhQPUFy8eJcmwUXqGGP3om6IxX8= -google.golang.org/genproto/googleapis/api v0.0.0-20250715232539-7130f93afb79/go.mod h1:HKJDgKsFUnv5VAGeQjz8kxcgDP0HoE0iZNp0OdZNlhE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250811230008-5f3141c8851a h1:tPE/Kp+x9dMSwUm/uM0JKK0IfdiJkwAbSMSeZBXXJXc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250811230008-5f3141c8851a/go.mod h1:gw1tLEfykwDz2ET4a12jcXt4couGAm7IwsVaTy0Sflo= -google.golang.org/grpc v1.74.2 h1:WoosgB65DlWVC9FqI82dGsZhWFNBSLjQ84bjROOpMu4= -google.golang.org/grpc v1.74.2/go.mod h1:CtQ+BGjaAIXHs/5YS3i473GqwBBa1zGQNevxdeBEXrM= -google.golang.org/protobuf v1.36.7 h1:IgrO7UwFQGJdRNXH/sQux4R1Dj1WAKcLElzeeRaXV2A= -google.golang.org/protobuf v1.36.7/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= +google.golang.org/genproto/googleapis/api v0.0.0-20251022142026-3a174f9686a8 h1:mepRgnBZa07I4TRuomDE4sTIYieg/osKmzIf4USdWS4= +google.golang.org/genproto/googleapis/api v0.0.0-20251022142026-3a174f9686a8/go.mod h1:fDMmzKV90WSg1NbozdqrE64fkuTv6mlq2zxo9ad+3yo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 h1:gRkg/vSppuSQoDjxyiGfN4Upv/h/DQmIR10ZU8dh4Ww= +google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk= +google.golang.org/grpc v1.77.0 h1:wVVY6/8cGA6vvffn+wWK5ToddbgdU3d8MNENr4evgXM= +google.golang.org/grpc v1.77.0/go.mod h1:z0BY1iVj0q8E1uSQCjL9cppRj+gnZjzDnzV0dHhrNig= +google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= +google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -modernc.org/cc/v4 v4.26.3 h1:yEN8dzrkRFnn4PUUKXLYIqVf2PJYAEjMTFjO3BDGc3I= -modernc.org/cc/v4 v4.26.3/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0= -modernc.org/ccgo/v4 v4.28.0 h1:rjznn6WWehKq7dG4JtLRKxb52Ecv8OUGah8+Z/SfpNU= -modernc.org/ccgo/v4 v4.28.0/go.mod h1:JygV3+9AV6SmPhDasu4JgquwU81XAKLd3OKTUDNOiKE= -modernc.org/fileutil v1.3.15 h1:rJAXTP6ilMW/1+kzDiqmBlHLWszheUFXIyGQIAvjJpY= -modernc.org/fileutil v1.3.15/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc= +modernc.org/cc/v4 v4.27.1 h1:9W30zRlYrefrDV2JE2O8VDtJ1yPGownxciz5rrbQZis= +modernc.org/cc/v4 v4.27.1/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0= +modernc.org/ccgo/v4 v4.30.1 h1:4r4U1J6Fhj98NKfSjnPUN7Ze2c6MnAdL0hWw6+LrJpc= +modernc.org/ccgo/v4 v4.30.1/go.mod h1:bIOeI1JL54Utlxn+LwrFyjCx2n2RDiYEaJVSrgdrRfM= +modernc.org/fileutil v1.3.40 h1:ZGMswMNc9JOCrcrakF1HrvmergNLAmxOPjizirpfqBA= +modernc.org/fileutil v1.3.40/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc= modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI= modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito= +modernc.org/gc/v3 v3.1.1 h1:k8T3gkXWY9sEiytKhcgyiZ2L0DTyCQ/nvX+LoCljoRE= +modernc.org/gc/v3 v3.1.1/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY= modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks= modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI= -modernc.org/libc v1.66.7 h1:rjhZ8OSCybKWxS1CJr0hikpEi6Vg+944Ouyrd+bQsoY= -modernc.org/libc v1.66.7/go.mod h1:ln6tbWX0NH+mzApEoDRvilBvAWFt1HX7AUA4VDdVDPM= +modernc.org/libc v1.67.1 h1:bFaqOaa5/zbWYJo8aW0tXPX21hXsngG2M7mckCnFSVk= +modernc.org/libc v1.67.1/go.mod h1:QvvnnJ5P7aitu0ReNpVIEyesuhmDLQ8kaEoyMjIFZJA= modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU= modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg= modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI= @@ -598,8 +585,8 @@ modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8= modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns= modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w= modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE= -modernc.org/sqlite v1.38.2 h1:Aclu7+tgjgcQVShZqim41Bbw9Cho0y/7WzYptXqkEek= -modernc.org/sqlite v1.38.2/go.mod h1:cPTJYSlgg3Sfg046yBShXENNtPrWrDX8bsbAQBzgQ5E= +modernc.org/sqlite v1.40.1 h1:VfuXcxcUWWKRBuP8+BR9L7VnmusMgBNNnBYGEe9w/iY= +modernc.org/sqlite v1.40.1/go.mod h1:9fjQZ0mB1LLP0GYrp39oOJXx/I2sxEnZtzCmEQIKvGE= modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0= modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A= modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= diff --git a/backend/internal/core/services/main_test.go b/backend/internal/core/services/main_test.go index b792ab37..43d5921a 100644 --- a/backend/internal/core/services/main_test.go +++ b/backend/internal/core/services/main_test.go @@ -38,10 +38,11 @@ func bootstrap() { log.Fatal(err) } + password := fk.Str(10) tUser, err = tRepos.Users.Create(ctx, repo.UserCreate{ Name: fk.Str(10), Email: fk.Email(), - Password: fk.Str(10), + Password: &password, IsSuperuser: fk.Bool(), GroupID: tGroup.ID, }) diff --git a/backend/internal/core/services/service_items_attachments.go b/backend/internal/core/services/service_items_attachments.go index 563d9688..54520dfe 100644 --- a/backend/internal/core/services/service_items_attachments.go +++ b/backend/internal/core/services/service_items_attachments.go @@ -50,6 +50,7 @@ func (svc *ItemService) AttachmentAdd(ctx Context, itemID uuid.UUID, filename st _, err = svc.repo.Attachments.Create(ctx, itemID, repo.EntityCreateAttachment{Title: filename, Content: file}, attachmentType, primary) if err != nil { log.Err(err).Msg("failed to create attachment") + return repo.ItemOut{}, err } return svc.repo.Items.GetOneByGroup(ctx, ctx.GID, itemID) diff --git a/backend/internal/core/services/service_items_attachments_test.go b/backend/internal/core/services/service_items_attachments_test.go index 16560fd3..1b7cb416 100644 --- a/backend/internal/core/services/service_items_attachments_test.go +++ b/backend/internal/core/services/service_items_attachments_test.go @@ -10,6 +10,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/sysadminsmedia/homebox/backend/internal/data/repo" + "github.com/sysadminsmedia/homebox/backend/internal/sys/config" ) func TestItemService_AddAttachment(t *testing.T) { @@ -60,3 +61,53 @@ func TestItemService_AddAttachment(t *testing.T) { require.NoError(t, err) assert.Equal(t, contents, string(bts)) } + +func TestItemService_AddAttachment_InvalidStorage(t *testing.T) { + // Create a service with an invalid storage path to simulate the issue + svc := &ItemService{ + repo: tRepos, + filepath: "/nonexistent/path/that/should/not/exist", + } + + // Create a temporary repo with invalid storage config + invalidRepos := repo.New(tClient, tbus, config.Storage{ + PrefixPath: "/", + ConnString: "file:///nonexistent/directory/that/does/not/exist", + }, "mem://{{ .Topic }}", config.Thumbnail{ + Enabled: false, + Width: 0, + Height: 0, + }) + + svc.repo = invalidRepos + + loc, err := invalidRepos.Locations.Create(context.Background(), tGroup.ID, repo.LocationCreate{ + Description: "test", + Name: "test-invalid", + }) + require.NoError(t, err) + assert.NotNil(t, loc) + + itmC := repo.ItemCreate{ + Name: fk.Str(10), + Description: fk.Str(10), + LocationID: loc.ID, + } + + itm, err := invalidRepos.Items.Create(context.Background(), tGroup.ID, itmC) + require.NoError(t, err) + assert.NotNil(t, itm) + t.Cleanup(func() { + err := invalidRepos.Items.Delete(context.Background(), itm.ID) + require.NoError(t, err) + }) + + contents := fk.Str(1000) + reader := strings.NewReader(contents) + + // Attempt to add attachment with invalid storage - should return an error + _, err = svc.AttachmentAdd(tCtx, itm.ID, "testfile.txt", "attachment", false, reader) + + // This should return an error now (after the fix) + assert.Error(t, err, "AttachmentAdd should return an error when storage is invalid") +} diff --git a/backend/internal/core/services/service_user.go b/backend/internal/core/services/service_user.go index 5b7b6f23..8c68105b 100644 --- a/backend/internal/core/services/service_user.go +++ b/backend/internal/core/services/service_user.go @@ -3,20 +3,21 @@ package services import ( "context" "errors" + "strings" "time" "github.com/google/uuid" "github.com/rs/zerolog/log" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/authroles" "github.com/sysadminsmedia/homebox/backend/internal/data/repo" "github.com/sysadminsmedia/homebox/backend/pkgs/hasher" ) var ( - oneWeek = time.Hour * 24 * 7 - ErrorInvalidLogin = errors.New("invalid username or password") - ErrorInvalidToken = errors.New("invalid token") - ErrorTokenIDMismatch = errors.New("token id mismatch") + oneWeek = time.Hour * 24 * 7 + ErrorInvalidLogin = errors.New("invalid username or password") + ErrorInvalidToken = errors.New("invalid token") ) type UserService struct { @@ -82,7 +83,7 @@ func (svc *UserService) RegisterUser(ctx context.Context, data UserRegistration) usrCreate := repo.UserCreate{ Name: data.Name, Email: data.Email, - Password: hashed, + Password: &hashed, IsSuperuser: false, GroupID: group.ID, IsOwner: creatingGroup, @@ -196,6 +197,14 @@ func (svc *UserService) Login(ctx context.Context, username, password string, ex return UserAuthTokenDetail{}, ErrorInvalidLogin } + // SECURITY: Deny login for users with null or empty password (OIDC users) + if usr.PasswordHash == "" { + log.Warn().Str("email", username).Msg("Login attempt blocked for user with null password (likely OIDC user)") + // SECURITY: Perform hash to ensure response times are the same + hasher.CheckPasswordHash("not-a-real-password", "not-a-real-password") + return UserAuthTokenDetail{}, ErrorInvalidLogin + } + check, rehash := hasher.CheckPasswordHash(password, usr.PasswordHash) if !check { @@ -216,6 +225,106 @@ func (svc *UserService) Login(ctx context.Context, username, password string, ex return svc.createSessionToken(ctx, usr.ID, extendedSession) } +// LoginOIDC creates a session token for a user authenticated via OIDC. +// It now uses issuer + subject for identity association (OIDC spec compliance). +// If the user doesn't exist, it will create one. +func (svc *UserService) LoginOIDC(ctx context.Context, issuer, subject, email, name string) (UserAuthTokenDetail, error) { + issuer = strings.TrimSpace(issuer) + subject = strings.TrimSpace(subject) + email = strings.ToLower(strings.TrimSpace(email)) + name = strings.TrimSpace(name) + + if issuer == "" || subject == "" { + log.Warn().Str("issuer", issuer).Str("subject", subject).Msg("OIDC login missing issuer or subject") + return UserAuthTokenDetail{}, ErrorInvalidLogin + } + + // Try to get existing user by OIDC identity + usr, err := svc.repos.Users.GetOneOIDC(ctx, issuer, subject) + if err != nil { + if !ent.IsNotFound(err) { + log.Err(err).Str("issuer", issuer).Str("subject", subject).Msg("failed to lookup user by OIDC identity") + return UserAuthTokenDetail{}, err + } + // Not found: attempt migration path by email (legacy) if email provided + if email != "" { + legacyUsr, lerr := svc.repos.Users.GetOneEmail(ctx, email) + if lerr == nil { + log.Info().Str("email", email).Str("issuer", issuer).Str("subject", subject).Msg("migrating legacy email-based OIDC user to issuer+subject") + // Update user with OIDC identity fields + if uerr := svc.repos.Users.SetOIDCIdentity(ctx, legacyUsr.ID, issuer, subject); uerr == nil { + usr = legacyUsr + } else { + log.Err(uerr).Str("email", email).Msg("failed to set OIDC identity on legacy user") + } + } + } + } + + // Create user if still not resolved + if usr.ID == uuid.Nil { + log.Debug().Str("issuer", issuer).Str("subject", subject).Msg("OIDC user not found, creating new user") + usr, err = svc.registerOIDCUser(ctx, issuer, subject, email, name) + if err != nil { + if ent.IsConstraintError(err) { + if usr2, gerr := svc.repos.Users.GetOneOIDC(ctx, issuer, subject); gerr == nil { + log.Info().Str("issuer", issuer).Str("subject", subject).Msg("OIDC user created concurrently; proceeding") + usr = usr2 + } else { + log.Err(gerr).Str("issuer", issuer).Str("subject", subject).Msg("failed to fetch user after constraint error") + return UserAuthTokenDetail{}, gerr + } + } else { + log.Err(err).Str("issuer", issuer).Str("subject", subject).Msg("failed to create OIDC user") + return UserAuthTokenDetail{}, err + } + } + } + + return svc.createSessionToken(ctx, usr.ID, true) +} + +// registerOIDCUser creates a new user for OIDC authentication with issuer+subject identity. +func (svc *UserService) registerOIDCUser(ctx context.Context, issuer, subject, email, name string) (repo.UserOut, error) { + group, err := svc.repos.Groups.GroupCreate(ctx, "Home") + if err != nil { + log.Err(err).Msg("Failed to create group for OIDC user") + return repo.UserOut{}, err + } + + usrCreate := repo.UserCreate{ + Name: name, + Email: email, + Password: nil, + IsSuperuser: false, + GroupID: group.ID, + IsOwner: true, + } + + entUser, err := svc.repos.Users.CreateWithOIDC(ctx, usrCreate, issuer, subject) + if err != nil { + return repo.UserOut{}, err + } + + log.Debug().Str("issuer", issuer).Str("subject", subject).Msg("creating default labels for OIDC user") + for _, label := range defaultLabels() { + _, err := svc.repos.Labels.Create(ctx, group.ID, label) + if err != nil { + log.Err(err).Msg("Failed to create default label") + } + } + + log.Debug().Str("issuer", issuer).Str("subject", subject).Msg("creating default locations for OIDC user") + for _, location := range defaultLocations() { + _, err := svc.repos.Locations.Create(ctx, group.ID, location) + if err != nil { + log.Err(err).Msg("Failed to create default location") + } + } + + return entUser, nil +} + func (svc *UserService) Logout(ctx context.Context, token string) error { hash := hasher.HashToken(token) err := svc.repos.AuthTokens.DeleteToken(ctx, hash) diff --git a/backend/internal/data/ent/attachment.go b/backend/internal/data/ent/attachment.go index cc8f2017..c7fbdf3b 100644 --- a/backend/internal/data/ent/attachment.go +++ b/backend/internal/data/ent/attachment.go @@ -11,7 +11,7 @@ import ( "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" ) // Attachment is the model entity for the Attachment schema. @@ -37,14 +37,14 @@ type Attachment struct { // The values are being populated by the AttachmentQuery when eager-loading is set. Edges AttachmentEdges `json:"edges"` attachment_thumbnail *uuid.UUID - entity_attachments *uuid.UUID + item_attachments *uuid.UUID selectValues sql.SelectValues } // AttachmentEdges holds the relations/edges for other nodes in the graph. type AttachmentEdges struct { - // Entity holds the value of the entity edge. - Entity *Entity `json:"entity,omitempty"` + // Item holds the value of the item edge. + Item *Item `json:"item,omitempty"` // Thumbnail holds the value of the thumbnail edge. Thumbnail *Attachment `json:"thumbnail,omitempty"` // loadedTypes holds the information for reporting if a @@ -52,15 +52,15 @@ type AttachmentEdges struct { loadedTypes [2]bool } -// EntityOrErr returns the Entity value or an error if the edge +// ItemOrErr returns the Item value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. -func (e AttachmentEdges) EntityOrErr() (*Entity, error) { - if e.Entity != nil { - return e.Entity, nil +func (e AttachmentEdges) ItemOrErr() (*Item, error) { + if e.Item != nil { + return e.Item, nil } else if e.loadedTypes[0] { - return nil, &NotFoundError{label: entity.Label} + return nil, &NotFoundError{label: item.Label} } - return nil, &NotLoadedError{edge: "entity"} + return nil, &NotLoadedError{edge: "item"} } // ThumbnailOrErr returns the Thumbnail value or an error if the edge @@ -89,7 +89,7 @@ func (*Attachment) scanValues(columns []string) ([]any, error) { values[i] = new(uuid.UUID) case attachment.ForeignKeys[0]: // attachment_thumbnail values[i] = &sql.NullScanner{S: new(uuid.UUID)} - case attachment.ForeignKeys[1]: // entity_attachments + case attachment.ForeignKeys[1]: // item_attachments values[i] = &sql.NullScanner{S: new(uuid.UUID)} default: values[i] = new(sql.UnknownType) @@ -163,10 +163,10 @@ func (_m *Attachment) assignValues(columns []string, values []any) error { } case attachment.ForeignKeys[1]: if value, ok := values[i].(*sql.NullScanner); !ok { - return fmt.Errorf("unexpected type %T for field entity_attachments", values[i]) + return fmt.Errorf("unexpected type %T for field item_attachments", values[i]) } else if value.Valid { - _m.entity_attachments = new(uuid.UUID) - *_m.entity_attachments = *value.S.(*uuid.UUID) + _m.item_attachments = new(uuid.UUID) + *_m.item_attachments = *value.S.(*uuid.UUID) } default: _m.selectValues.Set(columns[i], values[i]) @@ -181,9 +181,9 @@ func (_m *Attachment) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } -// QueryEntity queries the "entity" edge of the Attachment entity. -func (_m *Attachment) QueryEntity() *EntityQuery { - return NewAttachmentClient(_m.config).QueryEntity(_m) +// QueryItem queries the "item" edge of the Attachment entity. +func (_m *Attachment) QueryItem() *ItemQuery { + return NewAttachmentClient(_m.config).QueryItem(_m) } // QueryThumbnail queries the "thumbnail" edge of the Attachment entity. diff --git a/backend/internal/data/ent/attachment_create.go b/backend/internal/data/ent/attachment_create.go index 25eb6ec4..d46a71f9 100644 --- a/backend/internal/data/ent/attachment_create.go +++ b/backend/internal/data/ent/attachment_create.go @@ -12,7 +12,7 @@ import ( "entgo.io/ent/schema/field" "github.com/google/uuid" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" ) // AttachmentCreate is the builder for creating a Attachment entity. @@ -134,23 +134,23 @@ func (_c *AttachmentCreate) SetNillableID(v *uuid.UUID) *AttachmentCreate { return _c } -// SetEntityID sets the "entity" edge to the Entity entity by ID. -func (_c *AttachmentCreate) SetEntityID(id uuid.UUID) *AttachmentCreate { - _c.mutation.SetEntityID(id) +// SetItemID sets the "item" edge to the Item entity by ID. +func (_c *AttachmentCreate) SetItemID(id uuid.UUID) *AttachmentCreate { + _c.mutation.SetItemID(id) return _c } -// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil. -func (_c *AttachmentCreate) SetNillableEntityID(id *uuid.UUID) *AttachmentCreate { +// SetNillableItemID sets the "item" edge to the Item entity by ID if the given value is not nil. +func (_c *AttachmentCreate) SetNillableItemID(id *uuid.UUID) *AttachmentCreate { if id != nil { - _c = _c.SetEntityID(*id) + _c = _c.SetItemID(*id) } return _c } -// SetEntity sets the "entity" edge to the Entity entity. -func (_c *AttachmentCreate) SetEntity(v *Entity) *AttachmentCreate { - return _c.SetEntityID(v.ID) +// SetItem sets the "item" edge to the Item entity. +func (_c *AttachmentCreate) SetItem(v *Item) *AttachmentCreate { + return _c.SetItemID(v.ID) } // SetThumbnailID sets the "thumbnail" edge to the Attachment entity by ID. @@ -332,21 +332,21 @@ func (_c *AttachmentCreate) createSpec() (*Attachment, *sqlgraph.CreateSpec) { _spec.SetField(attachment.FieldMimeType, field.TypeString, value) _node.MimeType = value } - if nodes := _c.mutation.EntityIDs(); len(nodes) > 0 { + if nodes := _c.mutation.ItemIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: attachment.EntityTable, - Columns: []string{attachment.EntityColumn}, + Table: attachment.ItemTable, + Columns: []string{attachment.ItemColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } - _node.entity_attachments = &nodes[0] + _node.item_attachments = &nodes[0] _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.ThumbnailIDs(); len(nodes) > 0 { diff --git a/backend/internal/data/ent/attachment_query.go b/backend/internal/data/ent/attachment_query.go index d69eeb24..8eea544c 100644 --- a/backend/internal/data/ent/attachment_query.go +++ b/backend/internal/data/ent/attachment_query.go @@ -13,7 +13,7 @@ import ( "entgo.io/ent/schema/field" "github.com/google/uuid" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" ) @@ -24,7 +24,7 @@ type AttachmentQuery struct { order []attachment.OrderOption inters []Interceptor predicates []predicate.Attachment - withEntity *EntityQuery + withItem *ItemQuery withThumbnail *AttachmentQuery withFKs bool // intermediate query (i.e. traversal path). @@ -63,9 +63,9 @@ func (_q *AttachmentQuery) Order(o ...attachment.OrderOption) *AttachmentQuery { return _q } -// QueryEntity chains the current query on the "entity" edge. -func (_q *AttachmentQuery) QueryEntity() *EntityQuery { - query := (&EntityClient{config: _q.config}).Query() +// QueryItem chains the current query on the "item" edge. +func (_q *AttachmentQuery) QueryItem() *ItemQuery { + query := (&ItemClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err @@ -76,8 +76,8 @@ func (_q *AttachmentQuery) QueryEntity() *EntityQuery { } step := sqlgraph.NewStep( sqlgraph.From(attachment.Table, attachment.FieldID, selector), - sqlgraph.To(entity.Table, entity.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, attachment.EntityTable, attachment.EntityColumn), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, attachment.ItemTable, attachment.ItemColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil @@ -299,7 +299,7 @@ func (_q *AttachmentQuery) Clone() *AttachmentQuery { order: append([]attachment.OrderOption{}, _q.order...), inters: append([]Interceptor{}, _q.inters...), predicates: append([]predicate.Attachment{}, _q.predicates...), - withEntity: _q.withEntity.Clone(), + withItem: _q.withItem.Clone(), withThumbnail: _q.withThumbnail.Clone(), // clone intermediate query. sql: _q.sql.Clone(), @@ -307,14 +307,14 @@ func (_q *AttachmentQuery) Clone() *AttachmentQuery { } } -// WithEntity tells the query-builder to eager-load the nodes that are connected to -// the "entity" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *AttachmentQuery) WithEntity(opts ...func(*EntityQuery)) *AttachmentQuery { - query := (&EntityClient{config: _q.config}).Query() +// WithItem tells the query-builder to eager-load the nodes that are connected to +// the "item" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *AttachmentQuery) WithItem(opts ...func(*ItemQuery)) *AttachmentQuery { + query := (&ItemClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - _q.withEntity = query + _q.withItem = query return _q } @@ -409,11 +409,11 @@ func (_q *AttachmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*A withFKs = _q.withFKs _spec = _q.querySpec() loadedTypes = [2]bool{ - _q.withEntity != nil, + _q.withItem != nil, _q.withThumbnail != nil, } ) - if _q.withEntity != nil || _q.withThumbnail != nil { + if _q.withItem != nil || _q.withThumbnail != nil { withFKs = true } if withFKs { @@ -437,9 +437,9 @@ func (_q *AttachmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*A if len(nodes) == 0 { return nodes, nil } - if query := _q.withEntity; query != nil { - if err := _q.loadEntity(ctx, query, nodes, nil, - func(n *Attachment, e *Entity) { n.Edges.Entity = e }); err != nil { + if query := _q.withItem; query != nil { + if err := _q.loadItem(ctx, query, nodes, nil, + func(n *Attachment, e *Item) { n.Edges.Item = e }); err != nil { return nil, err } } @@ -452,14 +452,14 @@ func (_q *AttachmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*A return nodes, nil } -func (_q *AttachmentQuery) loadEntity(ctx context.Context, query *EntityQuery, nodes []*Attachment, init func(*Attachment), assign func(*Attachment, *Entity)) error { +func (_q *AttachmentQuery) loadItem(ctx context.Context, query *ItemQuery, nodes []*Attachment, init func(*Attachment), assign func(*Attachment, *Item)) error { ids := make([]uuid.UUID, 0, len(nodes)) nodeids := make(map[uuid.UUID][]*Attachment) for i := range nodes { - if nodes[i].entity_attachments == nil { + if nodes[i].item_attachments == nil { continue } - fk := *nodes[i].entity_attachments + fk := *nodes[i].item_attachments if _, ok := nodeids[fk]; !ok { ids = append(ids, fk) } @@ -468,7 +468,7 @@ func (_q *AttachmentQuery) loadEntity(ctx context.Context, query *EntityQuery, n if len(ids) == 0 { return nil } - query.Where(entity.IDIn(ids...)) + query.Where(item.IDIn(ids...)) neighbors, err := query.All(ctx) if err != nil { return err @@ -476,7 +476,7 @@ func (_q *AttachmentQuery) loadEntity(ctx context.Context, query *EntityQuery, n for _, n := range neighbors { nodes, ok := nodeids[n.ID] if !ok { - return fmt.Errorf(`unexpected foreign-key "entity_attachments" returned %v`, n.ID) + return fmt.Errorf(`unexpected foreign-key "item_attachments" returned %v`, n.ID) } for i := range nodes { assign(nodes[i], n) diff --git a/backend/internal/data/ent/attachment_update.go b/backend/internal/data/ent/attachment_update.go index 0009a29f..6b2cdd35 100644 --- a/backend/internal/data/ent/attachment_update.go +++ b/backend/internal/data/ent/attachment_update.go @@ -13,7 +13,7 @@ import ( "entgo.io/ent/schema/field" "github.com/google/uuid" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" ) @@ -106,23 +106,23 @@ func (_u *AttachmentUpdate) SetNillableMimeType(v *string) *AttachmentUpdate { return _u } -// SetEntityID sets the "entity" edge to the Entity entity by ID. -func (_u *AttachmentUpdate) SetEntityID(id uuid.UUID) *AttachmentUpdate { - _u.mutation.SetEntityID(id) +// SetItemID sets the "item" edge to the Item entity by ID. +func (_u *AttachmentUpdate) SetItemID(id uuid.UUID) *AttachmentUpdate { + _u.mutation.SetItemID(id) return _u } -// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil. -func (_u *AttachmentUpdate) SetNillableEntityID(id *uuid.UUID) *AttachmentUpdate { +// SetNillableItemID sets the "item" edge to the Item entity by ID if the given value is not nil. +func (_u *AttachmentUpdate) SetNillableItemID(id *uuid.UUID) *AttachmentUpdate { if id != nil { - _u = _u.SetEntityID(*id) + _u = _u.SetItemID(*id) } return _u } -// SetEntity sets the "entity" edge to the Entity entity. -func (_u *AttachmentUpdate) SetEntity(v *Entity) *AttachmentUpdate { - return _u.SetEntityID(v.ID) +// SetItem sets the "item" edge to the Item entity. +func (_u *AttachmentUpdate) SetItem(v *Item) *AttachmentUpdate { + return _u.SetItemID(v.ID) } // SetThumbnailID sets the "thumbnail" edge to the Attachment entity by ID. @@ -149,9 +149,9 @@ func (_u *AttachmentUpdate) Mutation() *AttachmentMutation { return _u.mutation } -// ClearEntity clears the "entity" edge to the Entity entity. -func (_u *AttachmentUpdate) ClearEntity() *AttachmentUpdate { - _u.mutation.ClearEntity() +// ClearItem clears the "item" edge to the Item entity. +func (_u *AttachmentUpdate) ClearItem() *AttachmentUpdate { + _u.mutation.ClearItem() return _u } @@ -237,28 +237,28 @@ func (_u *AttachmentUpdate) sqlSave(ctx context.Context) (_node int, err error) if value, ok := _u.mutation.MimeType(); ok { _spec.SetField(attachment.FieldMimeType, field.TypeString, value) } - if _u.mutation.EntityCleared() { + if _u.mutation.ItemCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: attachment.EntityTable, - Columns: []string{attachment.EntityColumn}, + Table: attachment.ItemTable, + Columns: []string{attachment.ItemColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: attachment.EntityTable, - Columns: []string{attachment.EntityColumn}, + Table: attachment.ItemTable, + Columns: []string{attachment.ItemColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -391,23 +391,23 @@ func (_u *AttachmentUpdateOne) SetNillableMimeType(v *string) *AttachmentUpdateO return _u } -// SetEntityID sets the "entity" edge to the Entity entity by ID. -func (_u *AttachmentUpdateOne) SetEntityID(id uuid.UUID) *AttachmentUpdateOne { - _u.mutation.SetEntityID(id) +// SetItemID sets the "item" edge to the Item entity by ID. +func (_u *AttachmentUpdateOne) SetItemID(id uuid.UUID) *AttachmentUpdateOne { + _u.mutation.SetItemID(id) return _u } -// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil. -func (_u *AttachmentUpdateOne) SetNillableEntityID(id *uuid.UUID) *AttachmentUpdateOne { +// SetNillableItemID sets the "item" edge to the Item entity by ID if the given value is not nil. +func (_u *AttachmentUpdateOne) SetNillableItemID(id *uuid.UUID) *AttachmentUpdateOne { if id != nil { - _u = _u.SetEntityID(*id) + _u = _u.SetItemID(*id) } return _u } -// SetEntity sets the "entity" edge to the Entity entity. -func (_u *AttachmentUpdateOne) SetEntity(v *Entity) *AttachmentUpdateOne { - return _u.SetEntityID(v.ID) +// SetItem sets the "item" edge to the Item entity. +func (_u *AttachmentUpdateOne) SetItem(v *Item) *AttachmentUpdateOne { + return _u.SetItemID(v.ID) } // SetThumbnailID sets the "thumbnail" edge to the Attachment entity by ID. @@ -434,9 +434,9 @@ func (_u *AttachmentUpdateOne) Mutation() *AttachmentMutation { return _u.mutation } -// ClearEntity clears the "entity" edge to the Entity entity. -func (_u *AttachmentUpdateOne) ClearEntity() *AttachmentUpdateOne { - _u.mutation.ClearEntity() +// ClearItem clears the "item" edge to the Item entity. +func (_u *AttachmentUpdateOne) ClearItem() *AttachmentUpdateOne { + _u.mutation.ClearItem() return _u } @@ -552,28 +552,28 @@ func (_u *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment, if value, ok := _u.mutation.MimeType(); ok { _spec.SetField(attachment.FieldMimeType, field.TypeString, value) } - if _u.mutation.EntityCleared() { + if _u.mutation.ItemCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: attachment.EntityTable, - Columns: []string{attachment.EntityColumn}, + Table: attachment.ItemTable, + Columns: []string{attachment.ItemColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: attachment.EntityTable, - Columns: []string{attachment.EntityColumn}, + Table: attachment.ItemTable, + Columns: []string{attachment.ItemColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/backend/internal/data/ent/client.go b/backend/internal/data/ent/client.go index 2c6f484a..7cd5830c 100644 --- a/backend/internal/data/ent/client.go +++ b/backend/internal/data/ent/client.go @@ -19,14 +19,16 @@ import ( "github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/authroles" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/authtokens" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/label" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/user" ) @@ -41,22 +43,26 @@ type Client struct { AuthRoles *AuthRolesClient // AuthTokens is the client for interacting with the AuthTokens builders. AuthTokens *AuthTokensClient - // Entity is the client for interacting with the Entity builders. - Entity *EntityClient - // EntityField is the client for interacting with the EntityField builders. - EntityField *EntityFieldClient - // EntityType is the client for interacting with the EntityType builders. - EntityType *EntityTypeClient // Group is the client for interacting with the Group builders. Group *GroupClient // GroupInvitationToken is the client for interacting with the GroupInvitationToken builders. GroupInvitationToken *GroupInvitationTokenClient + // Item is the client for interacting with the Item builders. + Item *ItemClient + // ItemField is the client for interacting with the ItemField builders. + ItemField *ItemFieldClient + // ItemTemplate is the client for interacting with the ItemTemplate builders. + ItemTemplate *ItemTemplateClient // Label is the client for interacting with the Label builders. Label *LabelClient + // Location is the client for interacting with the Location builders. + Location *LocationClient // MaintenanceEntry is the client for interacting with the MaintenanceEntry builders. MaintenanceEntry *MaintenanceEntryClient // Notifier is the client for interacting with the Notifier builders. Notifier *NotifierClient + // TemplateField is the client for interacting with the TemplateField builders. + TemplateField *TemplateFieldClient // User is the client for interacting with the User builders. User *UserClient } @@ -73,14 +79,16 @@ func (c *Client) init() { c.Attachment = NewAttachmentClient(c.config) c.AuthRoles = NewAuthRolesClient(c.config) c.AuthTokens = NewAuthTokensClient(c.config) - c.Entity = NewEntityClient(c.config) - c.EntityField = NewEntityFieldClient(c.config) - c.EntityType = NewEntityTypeClient(c.config) c.Group = NewGroupClient(c.config) c.GroupInvitationToken = NewGroupInvitationTokenClient(c.config) + c.Item = NewItemClient(c.config) + c.ItemField = NewItemFieldClient(c.config) + c.ItemTemplate = NewItemTemplateClient(c.config) c.Label = NewLabelClient(c.config) + c.Location = NewLocationClient(c.config) c.MaintenanceEntry = NewMaintenanceEntryClient(c.config) c.Notifier = NewNotifierClient(c.config) + c.TemplateField = NewTemplateFieldClient(c.config) c.User = NewUserClient(c.config) } @@ -177,14 +185,16 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { Attachment: NewAttachmentClient(cfg), AuthRoles: NewAuthRolesClient(cfg), AuthTokens: NewAuthTokensClient(cfg), - Entity: NewEntityClient(cfg), - EntityField: NewEntityFieldClient(cfg), - EntityType: NewEntityTypeClient(cfg), Group: NewGroupClient(cfg), GroupInvitationToken: NewGroupInvitationTokenClient(cfg), + Item: NewItemClient(cfg), + ItemField: NewItemFieldClient(cfg), + ItemTemplate: NewItemTemplateClient(cfg), Label: NewLabelClient(cfg), + Location: NewLocationClient(cfg), MaintenanceEntry: NewMaintenanceEntryClient(cfg), Notifier: NewNotifierClient(cfg), + TemplateField: NewTemplateFieldClient(cfg), User: NewUserClient(cfg), }, nil } @@ -208,14 +218,16 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) Attachment: NewAttachmentClient(cfg), AuthRoles: NewAuthRolesClient(cfg), AuthTokens: NewAuthTokensClient(cfg), - Entity: NewEntityClient(cfg), - EntityField: NewEntityFieldClient(cfg), - EntityType: NewEntityTypeClient(cfg), Group: NewGroupClient(cfg), GroupInvitationToken: NewGroupInvitationTokenClient(cfg), + Item: NewItemClient(cfg), + ItemField: NewItemFieldClient(cfg), + ItemTemplate: NewItemTemplateClient(cfg), Label: NewLabelClient(cfg), + Location: NewLocationClient(cfg), MaintenanceEntry: NewMaintenanceEntryClient(cfg), Notifier: NewNotifierClient(cfg), + TemplateField: NewTemplateFieldClient(cfg), User: NewUserClient(cfg), }, nil } @@ -246,9 +258,9 @@ func (c *Client) Close() error { // In order to add hooks to a specific client, call: `client.Node.Use(...)`. func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ - c.Attachment, c.AuthRoles, c.AuthTokens, c.Entity, c.EntityField, c.EntityType, - c.Group, c.GroupInvitationToken, c.Label, c.MaintenanceEntry, c.Notifier, - c.User, + c.Attachment, c.AuthRoles, c.AuthTokens, c.Group, c.GroupInvitationToken, + c.Item, c.ItemField, c.ItemTemplate, c.Label, c.Location, c.MaintenanceEntry, + c.Notifier, c.TemplateField, c.User, } { n.Use(hooks...) } @@ -258,9 +270,9 @@ func (c *Client) Use(hooks ...Hook) { // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ - c.Attachment, c.AuthRoles, c.AuthTokens, c.Entity, c.EntityField, c.EntityType, - c.Group, c.GroupInvitationToken, c.Label, c.MaintenanceEntry, c.Notifier, - c.User, + c.Attachment, c.AuthRoles, c.AuthTokens, c.Group, c.GroupInvitationToken, + c.Item, c.ItemField, c.ItemTemplate, c.Label, c.Location, c.MaintenanceEntry, + c.Notifier, c.TemplateField, c.User, } { n.Intercept(interceptors...) } @@ -275,22 +287,26 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.AuthRoles.mutate(ctx, m) case *AuthTokensMutation: return c.AuthTokens.mutate(ctx, m) - case *EntityMutation: - return c.Entity.mutate(ctx, m) - case *EntityFieldMutation: - return c.EntityField.mutate(ctx, m) - case *EntityTypeMutation: - return c.EntityType.mutate(ctx, m) case *GroupMutation: return c.Group.mutate(ctx, m) case *GroupInvitationTokenMutation: return c.GroupInvitationToken.mutate(ctx, m) + case *ItemMutation: + return c.Item.mutate(ctx, m) + case *ItemFieldMutation: + return c.ItemField.mutate(ctx, m) + case *ItemTemplateMutation: + return c.ItemTemplate.mutate(ctx, m) case *LabelMutation: return c.Label.mutate(ctx, m) + case *LocationMutation: + return c.Location.mutate(ctx, m) case *MaintenanceEntryMutation: return c.MaintenanceEntry.mutate(ctx, m) case *NotifierMutation: return c.Notifier.mutate(ctx, m) + case *TemplateFieldMutation: + return c.TemplateField.mutate(ctx, m) case *UserMutation: return c.User.mutate(ctx, m) default: @@ -406,15 +422,15 @@ func (c *AttachmentClient) GetX(ctx context.Context, id uuid.UUID) *Attachment { return obj } -// QueryEntity queries the entity edge of a Attachment. -func (c *AttachmentClient) QueryEntity(_m *Attachment) *EntityQuery { - query := (&EntityClient{config: c.config}).Query() +// QueryItem queries the item edge of a Attachment. +func (c *AttachmentClient) QueryItem(_m *Attachment) *ItemQuery { + query := (&ItemClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(attachment.Table, attachment.FieldID, id), - sqlgraph.To(entity.Table, entity.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, attachment.EntityTable, attachment.EntityColumn), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, attachment.ItemTable, attachment.ItemColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil @@ -777,613 +793,6 @@ func (c *AuthTokensClient) mutate(ctx context.Context, m *AuthTokensMutation) (V } } -// EntityClient is a client for the Entity schema. -type EntityClient struct { - config -} - -// NewEntityClient returns a client for the Entity from the given config. -func NewEntityClient(c config) *EntityClient { - return &EntityClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `entity.Hooks(f(g(h())))`. -func (c *EntityClient) Use(hooks ...Hook) { - c.hooks.Entity = append(c.hooks.Entity, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `entity.Intercept(f(g(h())))`. -func (c *EntityClient) Intercept(interceptors ...Interceptor) { - c.inters.Entity = append(c.inters.Entity, interceptors...) -} - -// Create returns a builder for creating a Entity entity. -func (c *EntityClient) Create() *EntityCreate { - mutation := newEntityMutation(c.config, OpCreate) - return &EntityCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of Entity entities. -func (c *EntityClient) CreateBulk(builders ...*EntityCreate) *EntityCreateBulk { - return &EntityCreateBulk{config: c.config, builders: builders} -} - -// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates -// a builder and applies setFunc on it. -func (c *EntityClient) MapCreateBulk(slice any, setFunc func(*EntityCreate, int)) *EntityCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &EntityCreateBulk{err: fmt.Errorf("calling to EntityClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*EntityCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &EntityCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for Entity. -func (c *EntityClient) Update() *EntityUpdate { - mutation := newEntityMutation(c.config, OpUpdate) - return &EntityUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *EntityClient) UpdateOne(_m *Entity) *EntityUpdateOne { - mutation := newEntityMutation(c.config, OpUpdateOne, withEntity(_m)) - return &EntityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *EntityClient) UpdateOneID(id uuid.UUID) *EntityUpdateOne { - mutation := newEntityMutation(c.config, OpUpdateOne, withEntityID(id)) - return &EntityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for Entity. -func (c *EntityClient) Delete() *EntityDelete { - mutation := newEntityMutation(c.config, OpDelete) - return &EntityDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *EntityClient) DeleteOne(_m *Entity) *EntityDeleteOne { - return c.DeleteOneID(_m.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *EntityClient) DeleteOneID(id uuid.UUID) *EntityDeleteOne { - builder := c.Delete().Where(entity.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &EntityDeleteOne{builder} -} - -// Query returns a query builder for Entity. -func (c *EntityClient) Query() *EntityQuery { - return &EntityQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeEntity}, - inters: c.Interceptors(), - } -} - -// Get returns a Entity entity by its id. -func (c *EntityClient) Get(ctx context.Context, id uuid.UUID) (*Entity, error) { - return c.Query().Where(entity.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *EntityClient) GetX(ctx context.Context, id uuid.UUID) *Entity { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryGroup queries the group edge of a Entity. -func (c *EntityClient) QueryGroup(_m *Entity) *GroupQuery { - query := (&GroupClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(entity.Table, entity.FieldID, id), - sqlgraph.To(group.Table, group.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, entity.GroupTable, entity.GroupColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryChildren queries the children edge of a Entity. -func (c *EntityClient) QueryChildren(_m *Entity) *EntityQuery { - query := (&EntityClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(entity.Table, entity.FieldID, id), - sqlgraph.To(entity.Table, entity.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, entity.ChildrenTable, entity.ChildrenColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryParent queries the parent edge of a Entity. -func (c *EntityClient) QueryParent(_m *Entity) *EntityQuery { - query := (&EntityClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(entity.Table, entity.FieldID, id), - sqlgraph.To(entity.Table, entity.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, entity.ParentTable, entity.ParentColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryEntity queries the entity edge of a Entity. -func (c *EntityClient) QueryEntity(_m *Entity) *EntityQuery { - query := (&EntityClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(entity.Table, entity.FieldID, id), - sqlgraph.To(entity.Table, entity.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, entity.EntityTable, entity.EntityColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryLocation queries the location edge of a Entity. -func (c *EntityClient) QueryLocation(_m *Entity) *EntityQuery { - query := (&EntityClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(entity.Table, entity.FieldID, id), - sqlgraph.To(entity.Table, entity.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, entity.LocationTable, entity.LocationColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryLabel queries the label edge of a Entity. -func (c *EntityClient) QueryLabel(_m *Entity) *LabelQuery { - query := (&LabelClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(entity.Table, entity.FieldID, id), - sqlgraph.To(label.Table, label.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, entity.LabelTable, entity.LabelPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryType queries the type edge of a Entity. -func (c *EntityClient) QueryType(_m *Entity) *EntityTypeQuery { - query := (&EntityTypeClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(entity.Table, entity.FieldID, id), - sqlgraph.To(entitytype.Table, entitytype.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, entity.TypeTable, entity.TypeColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryFields queries the fields edge of a Entity. -func (c *EntityClient) QueryFields(_m *Entity) *EntityFieldQuery { - query := (&EntityFieldClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(entity.Table, entity.FieldID, id), - sqlgraph.To(entityfield.Table, entityfield.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, entity.FieldsTable, entity.FieldsColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryMaintenanceEntries queries the maintenance_entries edge of a Entity. -func (c *EntityClient) QueryMaintenanceEntries(_m *Entity) *MaintenanceEntryQuery { - query := (&MaintenanceEntryClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(entity.Table, entity.FieldID, id), - sqlgraph.To(maintenanceentry.Table, maintenanceentry.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, entity.MaintenanceEntriesTable, entity.MaintenanceEntriesColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryAttachments queries the attachments edge of a Entity. -func (c *EntityClient) QueryAttachments(_m *Entity) *AttachmentQuery { - query := (&AttachmentClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(entity.Table, entity.FieldID, id), - sqlgraph.To(attachment.Table, attachment.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, entity.AttachmentsTable, entity.AttachmentsColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *EntityClient) Hooks() []Hook { - return c.hooks.Entity -} - -// Interceptors returns the client interceptors. -func (c *EntityClient) Interceptors() []Interceptor { - return c.inters.Entity -} - -func (c *EntityClient) mutate(ctx context.Context, m *EntityMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&EntityCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&EntityUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&EntityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&EntityDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown Entity mutation op: %q", m.Op()) - } -} - -// EntityFieldClient is a client for the EntityField schema. -type EntityFieldClient struct { - config -} - -// NewEntityFieldClient returns a client for the EntityField from the given config. -func NewEntityFieldClient(c config) *EntityFieldClient { - return &EntityFieldClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `entityfield.Hooks(f(g(h())))`. -func (c *EntityFieldClient) Use(hooks ...Hook) { - c.hooks.EntityField = append(c.hooks.EntityField, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `entityfield.Intercept(f(g(h())))`. -func (c *EntityFieldClient) Intercept(interceptors ...Interceptor) { - c.inters.EntityField = append(c.inters.EntityField, interceptors...) -} - -// Create returns a builder for creating a EntityField entity. -func (c *EntityFieldClient) Create() *EntityFieldCreate { - mutation := newEntityFieldMutation(c.config, OpCreate) - return &EntityFieldCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of EntityField entities. -func (c *EntityFieldClient) CreateBulk(builders ...*EntityFieldCreate) *EntityFieldCreateBulk { - return &EntityFieldCreateBulk{config: c.config, builders: builders} -} - -// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates -// a builder and applies setFunc on it. -func (c *EntityFieldClient) MapCreateBulk(slice any, setFunc func(*EntityFieldCreate, int)) *EntityFieldCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &EntityFieldCreateBulk{err: fmt.Errorf("calling to EntityFieldClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*EntityFieldCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &EntityFieldCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for EntityField. -func (c *EntityFieldClient) Update() *EntityFieldUpdate { - mutation := newEntityFieldMutation(c.config, OpUpdate) - return &EntityFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *EntityFieldClient) UpdateOne(_m *EntityField) *EntityFieldUpdateOne { - mutation := newEntityFieldMutation(c.config, OpUpdateOne, withEntityField(_m)) - return &EntityFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *EntityFieldClient) UpdateOneID(id uuid.UUID) *EntityFieldUpdateOne { - mutation := newEntityFieldMutation(c.config, OpUpdateOne, withEntityFieldID(id)) - return &EntityFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for EntityField. -func (c *EntityFieldClient) Delete() *EntityFieldDelete { - mutation := newEntityFieldMutation(c.config, OpDelete) - return &EntityFieldDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *EntityFieldClient) DeleteOne(_m *EntityField) *EntityFieldDeleteOne { - return c.DeleteOneID(_m.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *EntityFieldClient) DeleteOneID(id uuid.UUID) *EntityFieldDeleteOne { - builder := c.Delete().Where(entityfield.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &EntityFieldDeleteOne{builder} -} - -// Query returns a query builder for EntityField. -func (c *EntityFieldClient) Query() *EntityFieldQuery { - return &EntityFieldQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeEntityField}, - inters: c.Interceptors(), - } -} - -// Get returns a EntityField entity by its id. -func (c *EntityFieldClient) Get(ctx context.Context, id uuid.UUID) (*EntityField, error) { - return c.Query().Where(entityfield.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *EntityFieldClient) GetX(ctx context.Context, id uuid.UUID) *EntityField { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryEntity queries the entity edge of a EntityField. -func (c *EntityFieldClient) QueryEntity(_m *EntityField) *EntityQuery { - query := (&EntityClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(entityfield.Table, entityfield.FieldID, id), - sqlgraph.To(entity.Table, entity.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, entityfield.EntityTable, entityfield.EntityColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *EntityFieldClient) Hooks() []Hook { - return c.hooks.EntityField -} - -// Interceptors returns the client interceptors. -func (c *EntityFieldClient) Interceptors() []Interceptor { - return c.inters.EntityField -} - -func (c *EntityFieldClient) mutate(ctx context.Context, m *EntityFieldMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&EntityFieldCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&EntityFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&EntityFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&EntityFieldDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown EntityField mutation op: %q", m.Op()) - } -} - -// EntityTypeClient is a client for the EntityType schema. -type EntityTypeClient struct { - config -} - -// NewEntityTypeClient returns a client for the EntityType from the given config. -func NewEntityTypeClient(c config) *EntityTypeClient { - return &EntityTypeClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `entitytype.Hooks(f(g(h())))`. -func (c *EntityTypeClient) Use(hooks ...Hook) { - c.hooks.EntityType = append(c.hooks.EntityType, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `entitytype.Intercept(f(g(h())))`. -func (c *EntityTypeClient) Intercept(interceptors ...Interceptor) { - c.inters.EntityType = append(c.inters.EntityType, interceptors...) -} - -// Create returns a builder for creating a EntityType entity. -func (c *EntityTypeClient) Create() *EntityTypeCreate { - mutation := newEntityTypeMutation(c.config, OpCreate) - return &EntityTypeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of EntityType entities. -func (c *EntityTypeClient) CreateBulk(builders ...*EntityTypeCreate) *EntityTypeCreateBulk { - return &EntityTypeCreateBulk{config: c.config, builders: builders} -} - -// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates -// a builder and applies setFunc on it. -func (c *EntityTypeClient) MapCreateBulk(slice any, setFunc func(*EntityTypeCreate, int)) *EntityTypeCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &EntityTypeCreateBulk{err: fmt.Errorf("calling to EntityTypeClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*EntityTypeCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &EntityTypeCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for EntityType. -func (c *EntityTypeClient) Update() *EntityTypeUpdate { - mutation := newEntityTypeMutation(c.config, OpUpdate) - return &EntityTypeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *EntityTypeClient) UpdateOne(_m *EntityType) *EntityTypeUpdateOne { - mutation := newEntityTypeMutation(c.config, OpUpdateOne, withEntityType(_m)) - return &EntityTypeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *EntityTypeClient) UpdateOneID(id uuid.UUID) *EntityTypeUpdateOne { - mutation := newEntityTypeMutation(c.config, OpUpdateOne, withEntityTypeID(id)) - return &EntityTypeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for EntityType. -func (c *EntityTypeClient) Delete() *EntityTypeDelete { - mutation := newEntityTypeMutation(c.config, OpDelete) - return &EntityTypeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *EntityTypeClient) DeleteOne(_m *EntityType) *EntityTypeDeleteOne { - return c.DeleteOneID(_m.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *EntityTypeClient) DeleteOneID(id uuid.UUID) *EntityTypeDeleteOne { - builder := c.Delete().Where(entitytype.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &EntityTypeDeleteOne{builder} -} - -// Query returns a query builder for EntityType. -func (c *EntityTypeClient) Query() *EntityTypeQuery { - return &EntityTypeQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeEntityType}, - inters: c.Interceptors(), - } -} - -// Get returns a EntityType entity by its id. -func (c *EntityTypeClient) Get(ctx context.Context, id uuid.UUID) (*EntityType, error) { - return c.Query().Where(entitytype.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *EntityTypeClient) GetX(ctx context.Context, id uuid.UUID) *EntityType { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryGroup queries the group edge of a EntityType. -func (c *EntityTypeClient) QueryGroup(_m *EntityType) *GroupQuery { - query := (&GroupClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(entitytype.Table, entitytype.FieldID, id), - sqlgraph.To(group.Table, group.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, entitytype.GroupTable, entitytype.GroupColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryEntities queries the entities edge of a EntityType. -func (c *EntityTypeClient) QueryEntities(_m *EntityType) *EntityQuery { - query := (&EntityClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(entitytype.Table, entitytype.FieldID, id), - sqlgraph.To(entity.Table, entity.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, entitytype.EntitiesTable, entitytype.EntitiesColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *EntityTypeClient) Hooks() []Hook { - return c.hooks.EntityType -} - -// Interceptors returns the client interceptors. -func (c *EntityTypeClient) Interceptors() []Interceptor { - return c.inters.EntityType -} - -func (c *EntityTypeClient) mutate(ctx context.Context, m *EntityTypeMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&EntityTypeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&EntityTypeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&EntityTypeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&EntityTypeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown EntityType mutation op: %q", m.Op()) - } -} - // GroupClient is a client for the Group schema. type GroupClient struct { config @@ -1508,15 +917,31 @@ func (c *GroupClient) QueryUsers(_m *Group) *UserQuery { return query } -// QueryEntities queries the entities edge of a Group. -func (c *GroupClient) QueryEntities(_m *Group) *EntityQuery { - query := (&EntityClient{config: c.config}).Query() +// QueryLocations queries the locations edge of a Group. +func (c *GroupClient) QueryLocations(_m *Group) *LocationQuery { + query := (&LocationClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(group.Table, group.FieldID, id), - sqlgraph.To(entity.Table, entity.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, group.EntitiesTable, group.EntitiesColumn), + sqlgraph.To(location.Table, location.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, group.LocationsTable, group.LocationsColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryItems queries the items edge of a Group. +func (c *GroupClient) QueryItems(_m *Group) *ItemQuery { + query := (&ItemClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(group.Table, group.FieldID, id), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, group.ItemsTable, group.ItemsColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil @@ -1572,15 +997,15 @@ func (c *GroupClient) QueryNotifiers(_m *Group) *NotifierQuery { return query } -// QueryEntityTypes queries the entity_types edge of a Group. -func (c *GroupClient) QueryEntityTypes(_m *Group) *EntityTypeQuery { - query := (&EntityTypeClient{config: c.config}).Query() +// QueryItemTemplates queries the item_templates edge of a Group. +func (c *GroupClient) QueryItemTemplates(_m *Group) *ItemTemplateQuery { + query := (&ItemTemplateClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(group.Table, group.FieldID, id), - sqlgraph.To(entitytype.Table, entitytype.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, group.EntityTypesTable, group.EntityTypesColumn), + sqlgraph.To(itemtemplate.Table, itemtemplate.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, group.ItemTemplatesTable, group.ItemTemplatesColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil @@ -1762,6 +1187,597 @@ func (c *GroupInvitationTokenClient) mutate(ctx context.Context, m *GroupInvitat } } +// ItemClient is a client for the Item schema. +type ItemClient struct { + config +} + +// NewItemClient returns a client for the Item from the given config. +func NewItemClient(c config) *ItemClient { + return &ItemClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `item.Hooks(f(g(h())))`. +func (c *ItemClient) Use(hooks ...Hook) { + c.hooks.Item = append(c.hooks.Item, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `item.Intercept(f(g(h())))`. +func (c *ItemClient) Intercept(interceptors ...Interceptor) { + c.inters.Item = append(c.inters.Item, interceptors...) +} + +// Create returns a builder for creating a Item entity. +func (c *ItemClient) Create() *ItemCreate { + mutation := newItemMutation(c.config, OpCreate) + return &ItemCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Item entities. +func (c *ItemClient) CreateBulk(builders ...*ItemCreate) *ItemCreateBulk { + return &ItemCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *ItemClient) MapCreateBulk(slice any, setFunc func(*ItemCreate, int)) *ItemCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ItemCreateBulk{err: fmt.Errorf("calling to ItemClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ItemCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ItemCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Item. +func (c *ItemClient) Update() *ItemUpdate { + mutation := newItemMutation(c.config, OpUpdate) + return &ItemUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ItemClient) UpdateOne(_m *Item) *ItemUpdateOne { + mutation := newItemMutation(c.config, OpUpdateOne, withItem(_m)) + return &ItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ItemClient) UpdateOneID(id uuid.UUID) *ItemUpdateOne { + mutation := newItemMutation(c.config, OpUpdateOne, withItemID(id)) + return &ItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Item. +func (c *ItemClient) Delete() *ItemDelete { + mutation := newItemMutation(c.config, OpDelete) + return &ItemDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ItemClient) DeleteOne(_m *Item) *ItemDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ItemClient) DeleteOneID(id uuid.UUID) *ItemDeleteOne { + builder := c.Delete().Where(item.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ItemDeleteOne{builder} +} + +// Query returns a query builder for Item. +func (c *ItemClient) Query() *ItemQuery { + return &ItemQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeItem}, + inters: c.Interceptors(), + } +} + +// Get returns a Item entity by its id. +func (c *ItemClient) Get(ctx context.Context, id uuid.UUID) (*Item, error) { + return c.Query().Where(item.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ItemClient) GetX(ctx context.Context, id uuid.UUID) *Item { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryGroup queries the group edge of a Item. +func (c *ItemClient) QueryGroup(_m *Item) *GroupQuery { + query := (&GroupClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, id), + sqlgraph.To(group.Table, group.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, item.GroupTable, item.GroupColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryParent queries the parent edge of a Item. +func (c *ItemClient) QueryParent(_m *Item) *ItemQuery { + query := (&ItemClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, id), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, item.ParentTable, item.ParentColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryChildren queries the children edge of a Item. +func (c *ItemClient) QueryChildren(_m *Item) *ItemQuery { + query := (&ItemClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, id), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, item.ChildrenTable, item.ChildrenColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryLabel queries the label edge of a Item. +func (c *ItemClient) QueryLabel(_m *Item) *LabelQuery { + query := (&LabelClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, id), + sqlgraph.To(label.Table, label.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, item.LabelTable, item.LabelPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryLocation queries the location edge of a Item. +func (c *ItemClient) QueryLocation(_m *Item) *LocationQuery { + query := (&LocationClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, id), + sqlgraph.To(location.Table, location.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, item.LocationTable, item.LocationColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryFields queries the fields edge of a Item. +func (c *ItemClient) QueryFields(_m *Item) *ItemFieldQuery { + query := (&ItemFieldClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, id), + sqlgraph.To(itemfield.Table, itemfield.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, item.FieldsTable, item.FieldsColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryMaintenanceEntries queries the maintenance_entries edge of a Item. +func (c *ItemClient) QueryMaintenanceEntries(_m *Item) *MaintenanceEntryQuery { + query := (&MaintenanceEntryClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, id), + sqlgraph.To(maintenanceentry.Table, maintenanceentry.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, item.MaintenanceEntriesTable, item.MaintenanceEntriesColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryAttachments queries the attachments edge of a Item. +func (c *ItemClient) QueryAttachments(_m *Item) *AttachmentQuery { + query := (&AttachmentClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, id), + sqlgraph.To(attachment.Table, attachment.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, item.AttachmentsTable, item.AttachmentsColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *ItemClient) Hooks() []Hook { + return c.hooks.Item +} + +// Interceptors returns the client interceptors. +func (c *ItemClient) Interceptors() []Interceptor { + return c.inters.Item +} + +func (c *ItemClient) mutate(ctx context.Context, m *ItemMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ItemCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ItemUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ItemDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Item mutation op: %q", m.Op()) + } +} + +// ItemFieldClient is a client for the ItemField schema. +type ItemFieldClient struct { + config +} + +// NewItemFieldClient returns a client for the ItemField from the given config. +func NewItemFieldClient(c config) *ItemFieldClient { + return &ItemFieldClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `itemfield.Hooks(f(g(h())))`. +func (c *ItemFieldClient) Use(hooks ...Hook) { + c.hooks.ItemField = append(c.hooks.ItemField, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `itemfield.Intercept(f(g(h())))`. +func (c *ItemFieldClient) Intercept(interceptors ...Interceptor) { + c.inters.ItemField = append(c.inters.ItemField, interceptors...) +} + +// Create returns a builder for creating a ItemField entity. +func (c *ItemFieldClient) Create() *ItemFieldCreate { + mutation := newItemFieldMutation(c.config, OpCreate) + return &ItemFieldCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of ItemField entities. +func (c *ItemFieldClient) CreateBulk(builders ...*ItemFieldCreate) *ItemFieldCreateBulk { + return &ItemFieldCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *ItemFieldClient) MapCreateBulk(slice any, setFunc func(*ItemFieldCreate, int)) *ItemFieldCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ItemFieldCreateBulk{err: fmt.Errorf("calling to ItemFieldClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ItemFieldCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ItemFieldCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for ItemField. +func (c *ItemFieldClient) Update() *ItemFieldUpdate { + mutation := newItemFieldMutation(c.config, OpUpdate) + return &ItemFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ItemFieldClient) UpdateOne(_m *ItemField) *ItemFieldUpdateOne { + mutation := newItemFieldMutation(c.config, OpUpdateOne, withItemField(_m)) + return &ItemFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ItemFieldClient) UpdateOneID(id uuid.UUID) *ItemFieldUpdateOne { + mutation := newItemFieldMutation(c.config, OpUpdateOne, withItemFieldID(id)) + return &ItemFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for ItemField. +func (c *ItemFieldClient) Delete() *ItemFieldDelete { + mutation := newItemFieldMutation(c.config, OpDelete) + return &ItemFieldDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ItemFieldClient) DeleteOne(_m *ItemField) *ItemFieldDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ItemFieldClient) DeleteOneID(id uuid.UUID) *ItemFieldDeleteOne { + builder := c.Delete().Where(itemfield.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ItemFieldDeleteOne{builder} +} + +// Query returns a query builder for ItemField. +func (c *ItemFieldClient) Query() *ItemFieldQuery { + return &ItemFieldQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeItemField}, + inters: c.Interceptors(), + } +} + +// Get returns a ItemField entity by its id. +func (c *ItemFieldClient) Get(ctx context.Context, id uuid.UUID) (*ItemField, error) { + return c.Query().Where(itemfield.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ItemFieldClient) GetX(ctx context.Context, id uuid.UUID) *ItemField { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryItem queries the item edge of a ItemField. +func (c *ItemFieldClient) QueryItem(_m *ItemField) *ItemQuery { + query := (&ItemClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(itemfield.Table, itemfield.FieldID, id), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, itemfield.ItemTable, itemfield.ItemColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *ItemFieldClient) Hooks() []Hook { + return c.hooks.ItemField +} + +// Interceptors returns the client interceptors. +func (c *ItemFieldClient) Interceptors() []Interceptor { + return c.inters.ItemField +} + +func (c *ItemFieldClient) mutate(ctx context.Context, m *ItemFieldMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ItemFieldCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ItemFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ItemFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ItemFieldDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown ItemField mutation op: %q", m.Op()) + } +} + +// ItemTemplateClient is a client for the ItemTemplate schema. +type ItemTemplateClient struct { + config +} + +// NewItemTemplateClient returns a client for the ItemTemplate from the given config. +func NewItemTemplateClient(c config) *ItemTemplateClient { + return &ItemTemplateClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `itemtemplate.Hooks(f(g(h())))`. +func (c *ItemTemplateClient) Use(hooks ...Hook) { + c.hooks.ItemTemplate = append(c.hooks.ItemTemplate, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `itemtemplate.Intercept(f(g(h())))`. +func (c *ItemTemplateClient) Intercept(interceptors ...Interceptor) { + c.inters.ItemTemplate = append(c.inters.ItemTemplate, interceptors...) +} + +// Create returns a builder for creating a ItemTemplate entity. +func (c *ItemTemplateClient) Create() *ItemTemplateCreate { + mutation := newItemTemplateMutation(c.config, OpCreate) + return &ItemTemplateCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of ItemTemplate entities. +func (c *ItemTemplateClient) CreateBulk(builders ...*ItemTemplateCreate) *ItemTemplateCreateBulk { + return &ItemTemplateCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *ItemTemplateClient) MapCreateBulk(slice any, setFunc func(*ItemTemplateCreate, int)) *ItemTemplateCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ItemTemplateCreateBulk{err: fmt.Errorf("calling to ItemTemplateClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ItemTemplateCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ItemTemplateCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for ItemTemplate. +func (c *ItemTemplateClient) Update() *ItemTemplateUpdate { + mutation := newItemTemplateMutation(c.config, OpUpdate) + return &ItemTemplateUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ItemTemplateClient) UpdateOne(_m *ItemTemplate) *ItemTemplateUpdateOne { + mutation := newItemTemplateMutation(c.config, OpUpdateOne, withItemTemplate(_m)) + return &ItemTemplateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ItemTemplateClient) UpdateOneID(id uuid.UUID) *ItemTemplateUpdateOne { + mutation := newItemTemplateMutation(c.config, OpUpdateOne, withItemTemplateID(id)) + return &ItemTemplateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for ItemTemplate. +func (c *ItemTemplateClient) Delete() *ItemTemplateDelete { + mutation := newItemTemplateMutation(c.config, OpDelete) + return &ItemTemplateDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ItemTemplateClient) DeleteOne(_m *ItemTemplate) *ItemTemplateDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ItemTemplateClient) DeleteOneID(id uuid.UUID) *ItemTemplateDeleteOne { + builder := c.Delete().Where(itemtemplate.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ItemTemplateDeleteOne{builder} +} + +// Query returns a query builder for ItemTemplate. +func (c *ItemTemplateClient) Query() *ItemTemplateQuery { + return &ItemTemplateQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeItemTemplate}, + inters: c.Interceptors(), + } +} + +// Get returns a ItemTemplate entity by its id. +func (c *ItemTemplateClient) Get(ctx context.Context, id uuid.UUID) (*ItemTemplate, error) { + return c.Query().Where(itemtemplate.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ItemTemplateClient) GetX(ctx context.Context, id uuid.UUID) *ItemTemplate { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryGroup queries the group edge of a ItemTemplate. +func (c *ItemTemplateClient) QueryGroup(_m *ItemTemplate) *GroupQuery { + query := (&GroupClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, id), + sqlgraph.To(group.Table, group.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, itemtemplate.GroupTable, itemtemplate.GroupColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryFields queries the fields edge of a ItemTemplate. +func (c *ItemTemplateClient) QueryFields(_m *ItemTemplate) *TemplateFieldQuery { + query := (&TemplateFieldClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, id), + sqlgraph.To(templatefield.Table, templatefield.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, itemtemplate.FieldsTable, itemtemplate.FieldsColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryLocation queries the location edge of a ItemTemplate. +func (c *ItemTemplateClient) QueryLocation(_m *ItemTemplate) *LocationQuery { + query := (&LocationClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, id), + sqlgraph.To(location.Table, location.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, itemtemplate.LocationTable, itemtemplate.LocationColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *ItemTemplateClient) Hooks() []Hook { + return c.hooks.ItemTemplate +} + +// Interceptors returns the client interceptors. +func (c *ItemTemplateClient) Interceptors() []Interceptor { + return c.inters.ItemTemplate +} + +func (c *ItemTemplateClient) mutate(ctx context.Context, m *ItemTemplateMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ItemTemplateCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ItemTemplateUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ItemTemplateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ItemTemplateDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown ItemTemplate mutation op: %q", m.Op()) + } +} + // LabelClient is a client for the Label schema. type LabelClient struct { config @@ -1886,15 +1902,15 @@ func (c *LabelClient) QueryGroup(_m *Label) *GroupQuery { return query } -// QueryEntities queries the entities edge of a Label. -func (c *LabelClient) QueryEntities(_m *Label) *EntityQuery { - query := (&EntityClient{config: c.config}).Query() +// QueryItems queries the items edge of a Label. +func (c *LabelClient) QueryItems(_m *Label) *ItemQuery { + query := (&ItemClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(label.Table, label.FieldID, id), - sqlgraph.To(entity.Table, entity.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, label.EntitiesTable, label.EntitiesPrimaryKey...), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, label.ItemsTable, label.ItemsPrimaryKey...), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil @@ -1927,6 +1943,203 @@ func (c *LabelClient) mutate(ctx context.Context, m *LabelMutation) (Value, erro } } +// LocationClient is a client for the Location schema. +type LocationClient struct { + config +} + +// NewLocationClient returns a client for the Location from the given config. +func NewLocationClient(c config) *LocationClient { + return &LocationClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `location.Hooks(f(g(h())))`. +func (c *LocationClient) Use(hooks ...Hook) { + c.hooks.Location = append(c.hooks.Location, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `location.Intercept(f(g(h())))`. +func (c *LocationClient) Intercept(interceptors ...Interceptor) { + c.inters.Location = append(c.inters.Location, interceptors...) +} + +// Create returns a builder for creating a Location entity. +func (c *LocationClient) Create() *LocationCreate { + mutation := newLocationMutation(c.config, OpCreate) + return &LocationCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Location entities. +func (c *LocationClient) CreateBulk(builders ...*LocationCreate) *LocationCreateBulk { + return &LocationCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *LocationClient) MapCreateBulk(slice any, setFunc func(*LocationCreate, int)) *LocationCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &LocationCreateBulk{err: fmt.Errorf("calling to LocationClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*LocationCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &LocationCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Location. +func (c *LocationClient) Update() *LocationUpdate { + mutation := newLocationMutation(c.config, OpUpdate) + return &LocationUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *LocationClient) UpdateOne(_m *Location) *LocationUpdateOne { + mutation := newLocationMutation(c.config, OpUpdateOne, withLocation(_m)) + return &LocationUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *LocationClient) UpdateOneID(id uuid.UUID) *LocationUpdateOne { + mutation := newLocationMutation(c.config, OpUpdateOne, withLocationID(id)) + return &LocationUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Location. +func (c *LocationClient) Delete() *LocationDelete { + mutation := newLocationMutation(c.config, OpDelete) + return &LocationDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *LocationClient) DeleteOne(_m *Location) *LocationDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *LocationClient) DeleteOneID(id uuid.UUID) *LocationDeleteOne { + builder := c.Delete().Where(location.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &LocationDeleteOne{builder} +} + +// Query returns a query builder for Location. +func (c *LocationClient) Query() *LocationQuery { + return &LocationQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeLocation}, + inters: c.Interceptors(), + } +} + +// Get returns a Location entity by its id. +func (c *LocationClient) Get(ctx context.Context, id uuid.UUID) (*Location, error) { + return c.Query().Where(location.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *LocationClient) GetX(ctx context.Context, id uuid.UUID) *Location { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryGroup queries the group edge of a Location. +func (c *LocationClient) QueryGroup(_m *Location) *GroupQuery { + query := (&GroupClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(location.Table, location.FieldID, id), + sqlgraph.To(group.Table, group.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, location.GroupTable, location.GroupColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryParent queries the parent edge of a Location. +func (c *LocationClient) QueryParent(_m *Location) *LocationQuery { + query := (&LocationClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(location.Table, location.FieldID, id), + sqlgraph.To(location.Table, location.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, location.ParentTable, location.ParentColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryChildren queries the children edge of a Location. +func (c *LocationClient) QueryChildren(_m *Location) *LocationQuery { + query := (&LocationClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(location.Table, location.FieldID, id), + sqlgraph.To(location.Table, location.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, location.ChildrenTable, location.ChildrenColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryItems queries the items edge of a Location. +func (c *LocationClient) QueryItems(_m *Location) *ItemQuery { + query := (&ItemClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(location.Table, location.FieldID, id), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, location.ItemsTable, location.ItemsColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *LocationClient) Hooks() []Hook { + return c.hooks.Location +} + +// Interceptors returns the client interceptors. +func (c *LocationClient) Interceptors() []Interceptor { + return c.inters.Location +} + +func (c *LocationClient) mutate(ctx context.Context, m *LocationMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&LocationCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&LocationUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&LocationUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&LocationDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Location mutation op: %q", m.Op()) + } +} + // MaintenanceEntryClient is a client for the MaintenanceEntry schema. type MaintenanceEntryClient struct { config @@ -2035,15 +2248,15 @@ func (c *MaintenanceEntryClient) GetX(ctx context.Context, id uuid.UUID) *Mainte return obj } -// QueryEntity queries the entity edge of a MaintenanceEntry. -func (c *MaintenanceEntryClient) QueryEntity(_m *MaintenanceEntry) *EntityQuery { - query := (&EntityClient{config: c.config}).Query() +// QueryItem queries the item edge of a MaintenanceEntry. +func (c *MaintenanceEntryClient) QueryItem(_m *MaintenanceEntry) *ItemQuery { + query := (&ItemClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(maintenanceentry.Table, maintenanceentry.FieldID, id), - sqlgraph.To(entity.Table, entity.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, maintenanceentry.EntityTable, maintenanceentry.EntityColumn), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, maintenanceentry.ItemTable, maintenanceentry.ItemColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil @@ -2241,6 +2454,155 @@ func (c *NotifierClient) mutate(ctx context.Context, m *NotifierMutation) (Value } } +// TemplateFieldClient is a client for the TemplateField schema. +type TemplateFieldClient struct { + config +} + +// NewTemplateFieldClient returns a client for the TemplateField from the given config. +func NewTemplateFieldClient(c config) *TemplateFieldClient { + return &TemplateFieldClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `templatefield.Hooks(f(g(h())))`. +func (c *TemplateFieldClient) Use(hooks ...Hook) { + c.hooks.TemplateField = append(c.hooks.TemplateField, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `templatefield.Intercept(f(g(h())))`. +func (c *TemplateFieldClient) Intercept(interceptors ...Interceptor) { + c.inters.TemplateField = append(c.inters.TemplateField, interceptors...) +} + +// Create returns a builder for creating a TemplateField entity. +func (c *TemplateFieldClient) Create() *TemplateFieldCreate { + mutation := newTemplateFieldMutation(c.config, OpCreate) + return &TemplateFieldCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of TemplateField entities. +func (c *TemplateFieldClient) CreateBulk(builders ...*TemplateFieldCreate) *TemplateFieldCreateBulk { + return &TemplateFieldCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *TemplateFieldClient) MapCreateBulk(slice any, setFunc func(*TemplateFieldCreate, int)) *TemplateFieldCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &TemplateFieldCreateBulk{err: fmt.Errorf("calling to TemplateFieldClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*TemplateFieldCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &TemplateFieldCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for TemplateField. +func (c *TemplateFieldClient) Update() *TemplateFieldUpdate { + mutation := newTemplateFieldMutation(c.config, OpUpdate) + return &TemplateFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *TemplateFieldClient) UpdateOne(_m *TemplateField) *TemplateFieldUpdateOne { + mutation := newTemplateFieldMutation(c.config, OpUpdateOne, withTemplateField(_m)) + return &TemplateFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *TemplateFieldClient) UpdateOneID(id uuid.UUID) *TemplateFieldUpdateOne { + mutation := newTemplateFieldMutation(c.config, OpUpdateOne, withTemplateFieldID(id)) + return &TemplateFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for TemplateField. +func (c *TemplateFieldClient) Delete() *TemplateFieldDelete { + mutation := newTemplateFieldMutation(c.config, OpDelete) + return &TemplateFieldDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *TemplateFieldClient) DeleteOne(_m *TemplateField) *TemplateFieldDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *TemplateFieldClient) DeleteOneID(id uuid.UUID) *TemplateFieldDeleteOne { + builder := c.Delete().Where(templatefield.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &TemplateFieldDeleteOne{builder} +} + +// Query returns a query builder for TemplateField. +func (c *TemplateFieldClient) Query() *TemplateFieldQuery { + return &TemplateFieldQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeTemplateField}, + inters: c.Interceptors(), + } +} + +// Get returns a TemplateField entity by its id. +func (c *TemplateFieldClient) Get(ctx context.Context, id uuid.UUID) (*TemplateField, error) { + return c.Query().Where(templatefield.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *TemplateFieldClient) GetX(ctx context.Context, id uuid.UUID) *TemplateField { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryItemTemplate queries the item_template edge of a TemplateField. +func (c *TemplateFieldClient) QueryItemTemplate(_m *TemplateField) *ItemTemplateQuery { + query := (&ItemTemplateClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(templatefield.Table, templatefield.FieldID, id), + sqlgraph.To(itemtemplate.Table, itemtemplate.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, templatefield.ItemTemplateTable, templatefield.ItemTemplateColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *TemplateFieldClient) Hooks() []Hook { + return c.hooks.TemplateField +} + +// Interceptors returns the client interceptors. +func (c *TemplateFieldClient) Interceptors() []Interceptor { + return c.inters.TemplateField +} + +func (c *TemplateFieldClient) mutate(ctx context.Context, m *TemplateFieldMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&TemplateFieldCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&TemplateFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&TemplateFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&TemplateFieldDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown TemplateField mutation op: %q", m.Op()) + } +} + // UserClient is a client for the User schema. type UserClient struct { config @@ -2425,11 +2787,13 @@ func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) // hooks and interceptors per client, for fast access. type ( hooks struct { - Attachment, AuthRoles, AuthTokens, Entity, EntityField, EntityType, Group, - GroupInvitationToken, Label, MaintenanceEntry, Notifier, User []ent.Hook + Attachment, AuthRoles, AuthTokens, Group, GroupInvitationToken, Item, ItemField, + ItemTemplate, Label, Location, MaintenanceEntry, Notifier, TemplateField, + User []ent.Hook } inters struct { - Attachment, AuthRoles, AuthTokens, Entity, EntityField, EntityType, Group, - GroupInvitationToken, Label, MaintenanceEntry, Notifier, User []ent.Interceptor + Attachment, AuthRoles, AuthTokens, Group, GroupInvitationToken, Item, ItemField, + ItemTemplate, Label, Location, MaintenanceEntry, Notifier, TemplateField, + User []ent.Interceptor } ) diff --git a/backend/internal/data/ent/ent.go b/backend/internal/data/ent/ent.go index 3b8c9dca..ee3abfa7 100644 --- a/backend/internal/data/ent/ent.go +++ b/backend/internal/data/ent/ent.go @@ -15,14 +15,16 @@ import ( "github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/authroles" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/authtokens" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/label" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/user" ) @@ -87,14 +89,16 @@ func checkColumn(t, c string) error { attachment.Table: attachment.ValidColumn, authroles.Table: authroles.ValidColumn, authtokens.Table: authtokens.ValidColumn, - entity.Table: entity.ValidColumn, - entityfield.Table: entityfield.ValidColumn, - entitytype.Table: entitytype.ValidColumn, group.Table: group.ValidColumn, groupinvitationtoken.Table: groupinvitationtoken.ValidColumn, + item.Table: item.ValidColumn, + itemfield.Table: itemfield.ValidColumn, + itemtemplate.Table: itemtemplate.ValidColumn, label.Table: label.ValidColumn, + location.Table: location.ValidColumn, maintenanceentry.Table: maintenanceentry.ValidColumn, notifier.Table: notifier.ValidColumn, + templatefield.Table: templatefield.ValidColumn, user.Table: user.ValidColumn, }) }) diff --git a/backend/internal/data/ent/entityfield.go b/backend/internal/data/ent/entityfield.go index 186fc4de..72342ef1 100644 --- a/backend/internal/data/ent/entityfield.go +++ b/backend/internal/data/ent/entityfield.go @@ -10,12 +10,12 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/google/uuid" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield" ) -// EntityField is the model entity for the EntityField schema. -type EntityField struct { +// ItemField is the model entity for the ItemField schema. +type ItemField struct { config `json:"-"` // ID of the ent. ID uuid.UUID `json:"id,omitempty"` @@ -28,7 +28,7 @@ type EntityField struct { // Description holds the value of the "description" field. Description string `json:"description,omitempty"` // Type holds the value of the "type" field. - Type entityfield.Type `json:"type,omitempty"` + Type itemfield.Type `json:"type,omitempty"` // TextValue holds the value of the "text_value" field. TextValue string `json:"text_value,omitempty"` // NumberValue holds the value of the "number_value" field. @@ -38,48 +38,48 @@ type EntityField struct { // TimeValue holds the value of the "time_value" field. TimeValue time.Time `json:"time_value,omitempty"` // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the EntityFieldQuery when eager-loading is set. - Edges EntityFieldEdges `json:"edges"` - entity_fields *uuid.UUID - selectValues sql.SelectValues + // The values are being populated by the ItemFieldQuery when eager-loading is set. + Edges ItemFieldEdges `json:"edges"` + item_fields *uuid.UUID + selectValues sql.SelectValues } -// EntityFieldEdges holds the relations/edges for other nodes in the graph. -type EntityFieldEdges struct { - // Entity holds the value of the entity edge. - Entity *Entity `json:"entity,omitempty"` +// ItemFieldEdges holds the relations/edges for other nodes in the graph. +type ItemFieldEdges struct { + // Item holds the value of the item edge. + Item *Item `json:"item,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [1]bool } -// EntityOrErr returns the Entity value or an error if the edge +// ItemOrErr returns the Item value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. -func (e EntityFieldEdges) EntityOrErr() (*Entity, error) { - if e.Entity != nil { - return e.Entity, nil +func (e ItemFieldEdges) ItemOrErr() (*Item, error) { + if e.Item != nil { + return e.Item, nil } else if e.loadedTypes[0] { - return nil, &NotFoundError{label: entity.Label} + return nil, &NotFoundError{label: item.Label} } - return nil, &NotLoadedError{edge: "entity"} + return nil, &NotLoadedError{edge: "item"} } // scanValues returns the types for scanning values from sql.Rows. -func (*EntityField) scanValues(columns []string) ([]any, error) { +func (*ItemField) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case entityfield.FieldBooleanValue: + case itemfield.FieldBooleanValue: values[i] = new(sql.NullBool) - case entityfield.FieldNumberValue: + case itemfield.FieldNumberValue: values[i] = new(sql.NullInt64) - case entityfield.FieldName, entityfield.FieldDescription, entityfield.FieldType, entityfield.FieldTextValue: + case itemfield.FieldName, itemfield.FieldDescription, itemfield.FieldType, itemfield.FieldTextValue: values[i] = new(sql.NullString) - case entityfield.FieldCreatedAt, entityfield.FieldUpdatedAt, entityfield.FieldTimeValue: + case itemfield.FieldCreatedAt, itemfield.FieldUpdatedAt, itemfield.FieldTimeValue: values[i] = new(sql.NullTime) - case entityfield.FieldID: + case itemfield.FieldID: values[i] = new(uuid.UUID) - case entityfield.ForeignKeys[0]: // entity_fields + case itemfield.ForeignKeys[0]: // item_fields values[i] = &sql.NullScanner{S: new(uuid.UUID)} default: values[i] = new(sql.UnknownType) @@ -89,79 +89,79 @@ func (*EntityField) scanValues(columns []string) ([]any, error) { } // assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the EntityField fields. -func (_m *EntityField) assignValues(columns []string, values []any) error { +// to the ItemField fields. +func (_m *ItemField) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } for i := range columns { switch columns[i] { - case entityfield.FieldID: + case itemfield.FieldID: if value, ok := values[i].(*uuid.UUID); !ok { return fmt.Errorf("unexpected type %T for field id", values[i]) } else if value != nil { _m.ID = *value } - case entityfield.FieldCreatedAt: + case itemfield.FieldCreatedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field created_at", values[i]) } else if value.Valid { _m.CreatedAt = value.Time } - case entityfield.FieldUpdatedAt: + case itemfield.FieldUpdatedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field updated_at", values[i]) } else if value.Valid { _m.UpdatedAt = value.Time } - case entityfield.FieldName: + case itemfield.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) } else if value.Valid { _m.Name = value.String } - case entityfield.FieldDescription: + case itemfield.FieldDescription: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field description", values[i]) } else if value.Valid { _m.Description = value.String } - case entityfield.FieldType: + case itemfield.FieldType: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field type", values[i]) } else if value.Valid { - _m.Type = entityfield.Type(value.String) + _m.Type = itemfield.Type(value.String) } - case entityfield.FieldTextValue: + case itemfield.FieldTextValue: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field text_value", values[i]) } else if value.Valid { _m.TextValue = value.String } - case entityfield.FieldNumberValue: + case itemfield.FieldNumberValue: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field number_value", values[i]) } else if value.Valid { _m.NumberValue = int(value.Int64) } - case entityfield.FieldBooleanValue: + case itemfield.FieldBooleanValue: if value, ok := values[i].(*sql.NullBool); !ok { return fmt.Errorf("unexpected type %T for field boolean_value", values[i]) } else if value.Valid { _m.BooleanValue = value.Bool } - case entityfield.FieldTimeValue: + case itemfield.FieldTimeValue: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field time_value", values[i]) } else if value.Valid { _m.TimeValue = value.Time } - case entityfield.ForeignKeys[0]: + case itemfield.ForeignKeys[0]: if value, ok := values[i].(*sql.NullScanner); !ok { - return fmt.Errorf("unexpected type %T for field entity_fields", values[i]) + return fmt.Errorf("unexpected type %T for field item_fields", values[i]) } else if value.Valid { - _m.entity_fields = new(uuid.UUID) - *_m.entity_fields = *value.S.(*uuid.UUID) + _m.item_fields = new(uuid.UUID) + *_m.item_fields = *value.S.(*uuid.UUID) } default: _m.selectValues.Set(columns[i], values[i]) @@ -170,39 +170,39 @@ func (_m *EntityField) assignValues(columns []string, values []any) error { return nil } -// Value returns the ent.Value that was dynamically selected and assigned to the EntityField. +// Value returns the ent.Value that was dynamically selected and assigned to the ItemField. // This includes values selected through modifiers, order, etc. -func (_m *EntityField) Value(name string) (ent.Value, error) { +func (_m *ItemField) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } -// QueryEntity queries the "entity" edge of the EntityField entity. -func (_m *EntityField) QueryEntity() *EntityQuery { - return NewEntityFieldClient(_m.config).QueryEntity(_m) +// QueryItem queries the "item" edge of the ItemField entity. +func (_m *ItemField) QueryItem() *ItemQuery { + return NewItemFieldClient(_m.config).QueryItem(_m) } -// Update returns a builder for updating this EntityField. -// Note that you need to call EntityField.Unwrap() before calling this method if this EntityField +// Update returns a builder for updating this ItemField. +// Note that you need to call ItemField.Unwrap() before calling this method if this ItemField // was returned from a transaction, and the transaction was committed or rolled back. -func (_m *EntityField) Update() *EntityFieldUpdateOne { - return NewEntityFieldClient(_m.config).UpdateOne(_m) +func (_m *ItemField) Update() *ItemFieldUpdateOne { + return NewItemFieldClient(_m.config).UpdateOne(_m) } -// Unwrap unwraps the EntityField entity that was returned from a transaction after it was closed, +// Unwrap unwraps the ItemField entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. -func (_m *EntityField) Unwrap() *EntityField { +func (_m *ItemField) Unwrap() *ItemField { _tx, ok := _m.config.driver.(*txDriver) if !ok { - panic("ent: EntityField is not a transactional entity") + panic("ent: ItemField is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. -func (_m *EntityField) String() string { +func (_m *ItemField) String() string { var builder strings.Builder - builder.WriteString("EntityField(") + builder.WriteString("ItemField(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("created_at=") builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) @@ -234,5 +234,5 @@ func (_m *EntityField) String() string { return builder.String() } -// EntityFields is a parsable slice of EntityField. -type EntityFields []*EntityField +// ItemFields is a parsable slice of ItemField. +type ItemFields []*ItemField diff --git a/backend/internal/data/ent/group.go b/backend/internal/data/ent/group.go index 3ccced4b..d20782b9 100644 --- a/backend/internal/data/ent/group.go +++ b/backend/internal/data/ent/group.go @@ -36,19 +36,21 @@ type Group struct { type GroupEdges struct { // Users holds the value of the users edge. Users []*User `json:"users,omitempty"` - // Entities holds the value of the entities edge. - Entities []*Entity `json:"entities,omitempty"` + // Locations holds the value of the locations edge. + Locations []*Location `json:"locations,omitempty"` + // Items holds the value of the items edge. + Items []*Item `json:"items,omitempty"` // Labels holds the value of the labels edge. Labels []*Label `json:"labels,omitempty"` // InvitationTokens holds the value of the invitation_tokens edge. InvitationTokens []*GroupInvitationToken `json:"invitation_tokens,omitempty"` // Notifiers holds the value of the notifiers edge. Notifiers []*Notifier `json:"notifiers,omitempty"` - // EntityTypes holds the value of the entity_types edge. - EntityTypes []*EntityType `json:"entity_types,omitempty"` + // ItemTemplates holds the value of the item_templates edge. + ItemTemplates []*ItemTemplate `json:"item_templates,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [6]bool + loadedTypes [7]bool } // UsersOrErr returns the Users value or an error if the edge @@ -60,19 +62,28 @@ func (e GroupEdges) UsersOrErr() ([]*User, error) { return nil, &NotLoadedError{edge: "users"} } -// EntitiesOrErr returns the Entities value or an error if the edge +// LocationsOrErr returns the Locations value or an error if the edge // was not loaded in eager-loading. -func (e GroupEdges) EntitiesOrErr() ([]*Entity, error) { +func (e GroupEdges) LocationsOrErr() ([]*Location, error) { if e.loadedTypes[1] { - return e.Entities, nil + return e.Locations, nil } - return nil, &NotLoadedError{edge: "entities"} + return nil, &NotLoadedError{edge: "locations"} +} + +// ItemsOrErr returns the Items value or an error if the edge +// was not loaded in eager-loading. +func (e GroupEdges) ItemsOrErr() ([]*Item, error) { + if e.loadedTypes[2] { + return e.Items, nil + } + return nil, &NotLoadedError{edge: "items"} } // LabelsOrErr returns the Labels value or an error if the edge // was not loaded in eager-loading. func (e GroupEdges) LabelsOrErr() ([]*Label, error) { - if e.loadedTypes[2] { + if e.loadedTypes[3] { return e.Labels, nil } return nil, &NotLoadedError{edge: "labels"} @@ -81,7 +92,7 @@ func (e GroupEdges) LabelsOrErr() ([]*Label, error) { // InvitationTokensOrErr returns the InvitationTokens value or an error if the edge // was not loaded in eager-loading. func (e GroupEdges) InvitationTokensOrErr() ([]*GroupInvitationToken, error) { - if e.loadedTypes[3] { + if e.loadedTypes[4] { return e.InvitationTokens, nil } return nil, &NotLoadedError{edge: "invitation_tokens"} @@ -90,19 +101,19 @@ func (e GroupEdges) InvitationTokensOrErr() ([]*GroupInvitationToken, error) { // NotifiersOrErr returns the Notifiers value or an error if the edge // was not loaded in eager-loading. func (e GroupEdges) NotifiersOrErr() ([]*Notifier, error) { - if e.loadedTypes[4] { + if e.loadedTypes[5] { return e.Notifiers, nil } return nil, &NotLoadedError{edge: "notifiers"} } -// EntityTypesOrErr returns the EntityTypes value or an error if the edge +// ItemTemplatesOrErr returns the ItemTemplates value or an error if the edge // was not loaded in eager-loading. -func (e GroupEdges) EntityTypesOrErr() ([]*EntityType, error) { - if e.loadedTypes[5] { - return e.EntityTypes, nil +func (e GroupEdges) ItemTemplatesOrErr() ([]*ItemTemplate, error) { + if e.loadedTypes[6] { + return e.ItemTemplates, nil } - return nil, &NotLoadedError{edge: "entity_types"} + return nil, &NotLoadedError{edge: "item_templates"} } // scanValues returns the types for scanning values from sql.Rows. @@ -179,9 +190,14 @@ func (_m *Group) QueryUsers() *UserQuery { return NewGroupClient(_m.config).QueryUsers(_m) } -// QueryEntities queries the "entities" edge of the Group entity. -func (_m *Group) QueryEntities() *EntityQuery { - return NewGroupClient(_m.config).QueryEntities(_m) +// QueryLocations queries the "locations" edge of the Group entity. +func (_m *Group) QueryLocations() *LocationQuery { + return NewGroupClient(_m.config).QueryLocations(_m) +} + +// QueryItems queries the "items" edge of the Group entity. +func (_m *Group) QueryItems() *ItemQuery { + return NewGroupClient(_m.config).QueryItems(_m) } // QueryLabels queries the "labels" edge of the Group entity. @@ -199,9 +215,9 @@ func (_m *Group) QueryNotifiers() *NotifierQuery { return NewGroupClient(_m.config).QueryNotifiers(_m) } -// QueryEntityTypes queries the "entity_types" edge of the Group entity. -func (_m *Group) QueryEntityTypes() *EntityTypeQuery { - return NewGroupClient(_m.config).QueryEntityTypes(_m) +// QueryItemTemplates queries the "item_templates" edge of the Group entity. +func (_m *Group) QueryItemTemplates() *ItemTemplateQuery { + return NewGroupClient(_m.config).QueryItemTemplates(_m) } // Update returns a builder for updating this Group. diff --git a/backend/internal/data/ent/group/group.go b/backend/internal/data/ent/group/group.go index 44fe0434..80dc3398 100644 --- a/backend/internal/data/ent/group/group.go +++ b/backend/internal/data/ent/group/group.go @@ -25,16 +25,18 @@ const ( FieldCurrency = "currency" // EdgeUsers holds the string denoting the users edge name in mutations. EdgeUsers = "users" - // EdgeEntities holds the string denoting the entities edge name in mutations. - EdgeEntities = "entities" + // EdgeLocations holds the string denoting the locations edge name in mutations. + EdgeLocations = "locations" + // EdgeItems holds the string denoting the items edge name in mutations. + EdgeItems = "items" // EdgeLabels holds the string denoting the labels edge name in mutations. EdgeLabels = "labels" // EdgeInvitationTokens holds the string denoting the invitation_tokens edge name in mutations. EdgeInvitationTokens = "invitation_tokens" // EdgeNotifiers holds the string denoting the notifiers edge name in mutations. EdgeNotifiers = "notifiers" - // EdgeEntityTypes holds the string denoting the entity_types edge name in mutations. - EdgeEntityTypes = "entity_types" + // EdgeItemTemplates holds the string denoting the item_templates edge name in mutations. + EdgeItemTemplates = "item_templates" // Table holds the table name of the group in the database. Table = "groups" // UsersTable is the table that holds the users relation/edge. @@ -44,13 +46,20 @@ const ( UsersInverseTable = "users" // UsersColumn is the table column denoting the users relation/edge. UsersColumn = "group_users" - // EntitiesTable is the table that holds the entities relation/edge. - EntitiesTable = "entities" - // EntitiesInverseTable is the table name for the Entity entity. - // It exists in this package in order to avoid circular dependency with the "entity" package. - EntitiesInverseTable = "entities" - // EntitiesColumn is the table column denoting the entities relation/edge. - EntitiesColumn = "group_entities" + // LocationsTable is the table that holds the locations relation/edge. + LocationsTable = "locations" + // LocationsInverseTable is the table name for the Location entity. + // It exists in this package in order to avoid circular dependency with the "location" package. + LocationsInverseTable = "locations" + // LocationsColumn is the table column denoting the locations relation/edge. + LocationsColumn = "group_locations" + // ItemsTable is the table that holds the items relation/edge. + ItemsTable = "items" + // ItemsInverseTable is the table name for the Item entity. + // It exists in this package in order to avoid circular dependency with the "item" package. + ItemsInverseTable = "items" + // ItemsColumn is the table column denoting the items relation/edge. + ItemsColumn = "group_items" // LabelsTable is the table that holds the labels relation/edge. LabelsTable = "labels" // LabelsInverseTable is the table name for the Label entity. @@ -72,13 +81,13 @@ const ( NotifiersInverseTable = "notifiers" // NotifiersColumn is the table column denoting the notifiers relation/edge. NotifiersColumn = "group_id" - // EntityTypesTable is the table that holds the entity_types relation/edge. - EntityTypesTable = "entity_types" - // EntityTypesInverseTable is the table name for the EntityType entity. - // It exists in this package in order to avoid circular dependency with the "entitytype" package. - EntityTypesInverseTable = "entity_types" - // EntityTypesColumn is the table column denoting the entity_types relation/edge. - EntityTypesColumn = "group_entity_types" + // ItemTemplatesTable is the table that holds the item_templates relation/edge. + ItemTemplatesTable = "item_templates" + // ItemTemplatesInverseTable is the table name for the ItemTemplate entity. + // It exists in this package in order to avoid circular dependency with the "itemtemplate" package. + ItemTemplatesInverseTable = "item_templates" + // ItemTemplatesColumn is the table column denoting the item_templates relation/edge. + ItemTemplatesColumn = "group_item_templates" ) // Columns holds all SQL columns for group fields. @@ -157,17 +166,31 @@ func ByUsers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { } } -// ByEntitiesCount orders the results by entities count. -func ByEntitiesCount(opts ...sql.OrderTermOption) OrderOption { +// ByLocationsCount orders the results by locations count. +func ByLocationsCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newEntitiesStep(), opts...) + sqlgraph.OrderByNeighborsCount(s, newLocationsStep(), opts...) } } -// ByEntities orders the results by entities terms. -func ByEntities(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { +// ByLocations orders the results by locations terms. +func ByLocations(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newEntitiesStep(), append([]sql.OrderTerm{term}, terms...)...) + sqlgraph.OrderByNeighborTerms(s, newLocationsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByItemsCount orders the results by items count. +func ByItemsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newItemsStep(), opts...) + } +} + +// ByItems orders the results by items terms. +func ByItems(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newItemsStep(), append([]sql.OrderTerm{term}, terms...)...) } } @@ -213,17 +236,17 @@ func ByNotifiers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { } } -// ByEntityTypesCount orders the results by entity_types count. -func ByEntityTypesCount(opts ...sql.OrderTermOption) OrderOption { +// ByItemTemplatesCount orders the results by item_templates count. +func ByItemTemplatesCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newEntityTypesStep(), opts...) + sqlgraph.OrderByNeighborsCount(s, newItemTemplatesStep(), opts...) } } -// ByEntityTypes orders the results by entity_types terms. -func ByEntityTypes(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { +// ByItemTemplates orders the results by item_templates terms. +func ByItemTemplates(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newEntityTypesStep(), append([]sql.OrderTerm{term}, terms...)...) + sqlgraph.OrderByNeighborTerms(s, newItemTemplatesStep(), append([]sql.OrderTerm{term}, terms...)...) } } func newUsersStep() *sqlgraph.Step { @@ -233,11 +256,18 @@ func newUsersStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, false, UsersTable, UsersColumn), ) } -func newEntitiesStep() *sqlgraph.Step { +func newLocationsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(EntitiesInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, EntitiesTable, EntitiesColumn), + sqlgraph.To(LocationsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, LocationsTable, LocationsColumn), + ) +} +func newItemsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ItemsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ItemsTable, ItemsColumn), ) } func newLabelsStep() *sqlgraph.Step { @@ -261,10 +291,10 @@ func newNotifiersStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, false, NotifiersTable, NotifiersColumn), ) } -func newEntityTypesStep() *sqlgraph.Step { +func newItemTemplatesStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(EntityTypesInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, EntityTypesTable, EntityTypesColumn), + sqlgraph.To(ItemTemplatesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ItemTemplatesTable, ItemTemplatesColumn), ) } diff --git a/backend/internal/data/ent/group/where.go b/backend/internal/data/ent/group/where.go index e247a291..fec4b27c 100644 --- a/backend/internal/data/ent/group/where.go +++ b/backend/internal/data/ent/group/where.go @@ -309,21 +309,44 @@ func HasUsersWith(preds ...predicate.User) predicate.Group { }) } -// HasEntities applies the HasEdge predicate on the "entities" edge. -func HasEntities() predicate.Group { +// HasLocations applies the HasEdge predicate on the "locations" edge. +func HasLocations() predicate.Group { return predicate.Group(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, EntitiesTable, EntitiesColumn), + sqlgraph.Edge(sqlgraph.O2M, false, LocationsTable, LocationsColumn), ) sqlgraph.HasNeighbors(s, step) }) } -// HasEntitiesWith applies the HasEdge predicate on the "entities" edge with a given conditions (other predicates). -func HasEntitiesWith(preds ...predicate.Entity) predicate.Group { +// HasLocationsWith applies the HasEdge predicate on the "locations" edge with a given conditions (other predicates). +func HasLocationsWith(preds ...predicate.Location) predicate.Group { return predicate.Group(func(s *sql.Selector) { - step := newEntitiesStep() + step := newLocationsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasItems applies the HasEdge predicate on the "items" edge. +func HasItems() predicate.Group { + return predicate.Group(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ItemsTable, ItemsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasItemsWith applies the HasEdge predicate on the "items" edge with a given conditions (other predicates). +func HasItemsWith(preds ...predicate.Item) predicate.Group { + return predicate.Group(func(s *sql.Selector) { + step := newItemsStep() sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { for _, p := range preds { p(s) @@ -401,21 +424,21 @@ func HasNotifiersWith(preds ...predicate.Notifier) predicate.Group { }) } -// HasEntityTypes applies the HasEdge predicate on the "entity_types" edge. -func HasEntityTypes() predicate.Group { +// HasItemTemplates applies the HasEdge predicate on the "item_templates" edge. +func HasItemTemplates() predicate.Group { return predicate.Group(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, EntityTypesTable, EntityTypesColumn), + sqlgraph.Edge(sqlgraph.O2M, false, ItemTemplatesTable, ItemTemplatesColumn), ) sqlgraph.HasNeighbors(s, step) }) } -// HasEntityTypesWith applies the HasEdge predicate on the "entity_types" edge with a given conditions (other predicates). -func HasEntityTypesWith(preds ...predicate.EntityType) predicate.Group { +// HasItemTemplatesWith applies the HasEdge predicate on the "item_templates" edge with a given conditions (other predicates). +func HasItemTemplatesWith(preds ...predicate.ItemTemplate) predicate.Group { return predicate.Group(func(s *sql.Selector) { - step := newEntityTypesStep() + step := newItemTemplatesStep() sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { for _, p := range preds { p(s) diff --git a/backend/internal/data/ent/group_create.go b/backend/internal/data/ent/group_create.go index 7c4cf124..9eb4bac1 100644 --- a/backend/internal/data/ent/group_create.go +++ b/backend/internal/data/ent/group_create.go @@ -11,11 +11,12 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/label" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/user" ) @@ -104,19 +105,34 @@ func (_c *GroupCreate) AddUsers(v ...*User) *GroupCreate { return _c.AddUserIDs(ids...) } -// AddEntityIDs adds the "entities" edge to the Entity entity by IDs. -func (_c *GroupCreate) AddEntityIDs(ids ...uuid.UUID) *GroupCreate { - _c.mutation.AddEntityIDs(ids...) +// AddLocationIDs adds the "locations" edge to the Location entity by IDs. +func (_c *GroupCreate) AddLocationIDs(ids ...uuid.UUID) *GroupCreate { + _c.mutation.AddLocationIDs(ids...) return _c } -// AddEntities adds the "entities" edges to the Entity entity. -func (_c *GroupCreate) AddEntities(v ...*Entity) *GroupCreate { +// AddLocations adds the "locations" edges to the Location entity. +func (_c *GroupCreate) AddLocations(v ...*Location) *GroupCreate { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _c.AddEntityIDs(ids...) + return _c.AddLocationIDs(ids...) +} + +// AddItemIDs adds the "items" edge to the Item entity by IDs. +func (_c *GroupCreate) AddItemIDs(ids ...uuid.UUID) *GroupCreate { + _c.mutation.AddItemIDs(ids...) + return _c +} + +// AddItems adds the "items" edges to the Item entity. +func (_c *GroupCreate) AddItems(v ...*Item) *GroupCreate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddItemIDs(ids...) } // AddLabelIDs adds the "labels" edge to the Label entity by IDs. @@ -164,19 +180,19 @@ func (_c *GroupCreate) AddNotifiers(v ...*Notifier) *GroupCreate { return _c.AddNotifierIDs(ids...) } -// AddEntityTypeIDs adds the "entity_types" edge to the EntityType entity by IDs. -func (_c *GroupCreate) AddEntityTypeIDs(ids ...uuid.UUID) *GroupCreate { - _c.mutation.AddEntityTypeIDs(ids...) +// AddItemTemplateIDs adds the "item_templates" edge to the ItemTemplate entity by IDs. +func (_c *GroupCreate) AddItemTemplateIDs(ids ...uuid.UUID) *GroupCreate { + _c.mutation.AddItemTemplateIDs(ids...) return _c } -// AddEntityTypes adds the "entity_types" edges to the EntityType entity. -func (_c *GroupCreate) AddEntityTypes(v ...*EntityType) *GroupCreate { +// AddItemTemplates adds the "item_templates" edges to the ItemTemplate entity. +func (_c *GroupCreate) AddItemTemplates(v ...*ItemTemplate) *GroupCreate { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _c.AddEntityTypeIDs(ids...) + return _c.AddItemTemplateIDs(ids...) } // Mutation returns the GroupMutation object of the builder. @@ -318,15 +334,31 @@ func (_c *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := _c.mutation.EntitiesIDs(); len(nodes) > 0 { + if nodes := _c.mutation.LocationsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: group.EntitiesTable, - Columns: []string{group.EntitiesColumn}, + Table: group.LocationsTable, + Columns: []string{group.LocationsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.ItemsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: group.ItemsTable, + Columns: []string{group.ItemsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -382,15 +414,15 @@ func (_c *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := _c.mutation.EntityTypesIDs(); len(nodes) > 0 { + if nodes := _c.mutation.ItemTemplatesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: group.EntityTypesTable, - Columns: []string{group.EntityTypesColumn}, + Table: group.ItemTemplatesTable, + Columns: []string{group.ItemTemplatesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/backend/internal/data/ent/group_query.go b/backend/internal/data/ent/group_query.go index 3c3d26a8..20124988 100644 --- a/backend/internal/data/ent/group_query.go +++ b/backend/internal/data/ent/group_query.go @@ -13,11 +13,12 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/label" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/user" @@ -31,11 +32,12 @@ type GroupQuery struct { inters []Interceptor predicates []predicate.Group withUsers *UserQuery - withEntities *EntityQuery + withLocations *LocationQuery + withItems *ItemQuery withLabels *LabelQuery withInvitationTokens *GroupInvitationTokenQuery withNotifiers *NotifierQuery - withEntityTypes *EntityTypeQuery + withItemTemplates *ItemTemplateQuery // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -94,9 +96,9 @@ func (_q *GroupQuery) QueryUsers() *UserQuery { return query } -// QueryEntities chains the current query on the "entities" edge. -func (_q *GroupQuery) QueryEntities() *EntityQuery { - query := (&EntityClient{config: _q.config}).Query() +// QueryLocations chains the current query on the "locations" edge. +func (_q *GroupQuery) QueryLocations() *LocationQuery { + query := (&LocationClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err @@ -107,8 +109,30 @@ func (_q *GroupQuery) QueryEntities() *EntityQuery { } step := sqlgraph.NewStep( sqlgraph.From(group.Table, group.FieldID, selector), - sqlgraph.To(entity.Table, entity.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, group.EntitiesTable, group.EntitiesColumn), + sqlgraph.To(location.Table, location.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, group.LocationsTable, group.LocationsColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryItems chains the current query on the "items" edge. +func (_q *GroupQuery) QueryItems() *ItemQuery { + query := (&ItemClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(group.Table, group.FieldID, selector), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, group.ItemsTable, group.ItemsColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil @@ -182,9 +206,9 @@ func (_q *GroupQuery) QueryNotifiers() *NotifierQuery { return query } -// QueryEntityTypes chains the current query on the "entity_types" edge. -func (_q *GroupQuery) QueryEntityTypes() *EntityTypeQuery { - query := (&EntityTypeClient{config: _q.config}).Query() +// QueryItemTemplates chains the current query on the "item_templates" edge. +func (_q *GroupQuery) QueryItemTemplates() *ItemTemplateQuery { + query := (&ItemTemplateClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err @@ -195,8 +219,8 @@ func (_q *GroupQuery) QueryEntityTypes() *EntityTypeQuery { } step := sqlgraph.NewStep( sqlgraph.From(group.Table, group.FieldID, selector), - sqlgraph.To(entitytype.Table, entitytype.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, group.EntityTypesTable, group.EntityTypesColumn), + sqlgraph.To(itemtemplate.Table, itemtemplate.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, group.ItemTemplatesTable, group.ItemTemplatesColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil @@ -397,11 +421,12 @@ func (_q *GroupQuery) Clone() *GroupQuery { inters: append([]Interceptor{}, _q.inters...), predicates: append([]predicate.Group{}, _q.predicates...), withUsers: _q.withUsers.Clone(), - withEntities: _q.withEntities.Clone(), + withLocations: _q.withLocations.Clone(), + withItems: _q.withItems.Clone(), withLabels: _q.withLabels.Clone(), withInvitationTokens: _q.withInvitationTokens.Clone(), withNotifiers: _q.withNotifiers.Clone(), - withEntityTypes: _q.withEntityTypes.Clone(), + withItemTemplates: _q.withItemTemplates.Clone(), // clone intermediate query. sql: _q.sql.Clone(), path: _q.path, @@ -419,14 +444,25 @@ func (_q *GroupQuery) WithUsers(opts ...func(*UserQuery)) *GroupQuery { return _q } -// WithEntities tells the query-builder to eager-load the nodes that are connected to -// the "entities" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *GroupQuery) WithEntities(opts ...func(*EntityQuery)) *GroupQuery { - query := (&EntityClient{config: _q.config}).Query() +// WithLocations tells the query-builder to eager-load the nodes that are connected to +// the "locations" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *GroupQuery) WithLocations(opts ...func(*LocationQuery)) *GroupQuery { + query := (&LocationClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - _q.withEntities = query + _q.withLocations = query + return _q +} + +// WithItems tells the query-builder to eager-load the nodes that are connected to +// the "items" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *GroupQuery) WithItems(opts ...func(*ItemQuery)) *GroupQuery { + query := (&ItemClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withItems = query return _q } @@ -463,14 +499,14 @@ func (_q *GroupQuery) WithNotifiers(opts ...func(*NotifierQuery)) *GroupQuery { return _q } -// WithEntityTypes tells the query-builder to eager-load the nodes that are connected to -// the "entity_types" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *GroupQuery) WithEntityTypes(opts ...func(*EntityTypeQuery)) *GroupQuery { - query := (&EntityTypeClient{config: _q.config}).Query() +// WithItemTemplates tells the query-builder to eager-load the nodes that are connected to +// the "item_templates" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *GroupQuery) WithItemTemplates(opts ...func(*ItemTemplateQuery)) *GroupQuery { + query := (&ItemTemplateClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - _q.withEntityTypes = query + _q.withItemTemplates = query return _q } @@ -552,13 +588,14 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group, var ( nodes = []*Group{} _spec = _q.querySpec() - loadedTypes = [6]bool{ + loadedTypes = [7]bool{ _q.withUsers != nil, - _q.withEntities != nil, + _q.withLocations != nil, + _q.withItems != nil, _q.withLabels != nil, _q.withInvitationTokens != nil, _q.withNotifiers != nil, - _q.withEntityTypes != nil, + _q.withItemTemplates != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { @@ -586,10 +623,17 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group, return nil, err } } - if query := _q.withEntities; query != nil { - if err := _q.loadEntities(ctx, query, nodes, - func(n *Group) { n.Edges.Entities = []*Entity{} }, - func(n *Group, e *Entity) { n.Edges.Entities = append(n.Edges.Entities, e) }); err != nil { + if query := _q.withLocations; query != nil { + if err := _q.loadLocations(ctx, query, nodes, + func(n *Group) { n.Edges.Locations = []*Location{} }, + func(n *Group, e *Location) { n.Edges.Locations = append(n.Edges.Locations, e) }); err != nil { + return nil, err + } + } + if query := _q.withItems; query != nil { + if err := _q.loadItems(ctx, query, nodes, + func(n *Group) { n.Edges.Items = []*Item{} }, + func(n *Group, e *Item) { n.Edges.Items = append(n.Edges.Items, e) }); err != nil { return nil, err } } @@ -616,10 +660,10 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group, return nil, err } } - if query := _q.withEntityTypes; query != nil { - if err := _q.loadEntityTypes(ctx, query, nodes, - func(n *Group) { n.Edges.EntityTypes = []*EntityType{} }, - func(n *Group, e *EntityType) { n.Edges.EntityTypes = append(n.Edges.EntityTypes, e) }); err != nil { + if query := _q.withItemTemplates; query != nil { + if err := _q.loadItemTemplates(ctx, query, nodes, + func(n *Group) { n.Edges.ItemTemplates = []*ItemTemplate{} }, + func(n *Group, e *ItemTemplate) { n.Edges.ItemTemplates = append(n.Edges.ItemTemplates, e) }); err != nil { return nil, err } } @@ -657,7 +701,7 @@ func (_q *GroupQuery) loadUsers(ctx context.Context, query *UserQuery, nodes []* } return nil } -func (_q *GroupQuery) loadEntities(ctx context.Context, query *EntityQuery, nodes []*Group, init func(*Group), assign func(*Group, *Entity)) error { +func (_q *GroupQuery) loadLocations(ctx context.Context, query *LocationQuery, nodes []*Group, init func(*Group), assign func(*Group, *Location)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[uuid.UUID]*Group) for i := range nodes { @@ -668,21 +712,52 @@ func (_q *GroupQuery) loadEntities(ctx context.Context, query *EntityQuery, node } } query.withFKs = true - query.Where(predicate.Entity(func(s *sql.Selector) { - s.Where(sql.InValues(s.C(group.EntitiesColumn), fks...)) + query.Where(predicate.Location(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(group.LocationsColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { - fk := n.group_entities + fk := n.group_locations if fk == nil { - return fmt.Errorf(`foreign-key "group_entities" is nil for node %v`, n.ID) + return fmt.Errorf(`foreign-key "group_locations" is nil for node %v`, n.ID) } node, ok := nodeids[*fk] if !ok { - return fmt.Errorf(`unexpected referenced foreign-key "group_entities" returned %v for node %v`, *fk, n.ID) + return fmt.Errorf(`unexpected referenced foreign-key "group_locations" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} +func (_q *GroupQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*Group, init func(*Group), assign func(*Group, *Item)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uuid.UUID]*Group) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.Item(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(group.ItemsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.group_items + if fk == nil { + return fmt.Errorf(`foreign-key "group_items" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "group_items" returned %v for node %v`, *fk, n.ID) } assign(node, n) } @@ -780,7 +855,7 @@ func (_q *GroupQuery) loadNotifiers(ctx context.Context, query *NotifierQuery, n } return nil } -func (_q *GroupQuery) loadEntityTypes(ctx context.Context, query *EntityTypeQuery, nodes []*Group, init func(*Group), assign func(*Group, *EntityType)) error { +func (_q *GroupQuery) loadItemTemplates(ctx context.Context, query *ItemTemplateQuery, nodes []*Group, init func(*Group), assign func(*Group, *ItemTemplate)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[uuid.UUID]*Group) for i := range nodes { @@ -791,21 +866,21 @@ func (_q *GroupQuery) loadEntityTypes(ctx context.Context, query *EntityTypeQuer } } query.withFKs = true - query.Where(predicate.EntityType(func(s *sql.Selector) { - s.Where(sql.InValues(s.C(group.EntityTypesColumn), fks...)) + query.Where(predicate.ItemTemplate(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(group.ItemTemplatesColumn), fks...)) })) neighbors, err := query.All(ctx) if err != nil { return err } for _, n := range neighbors { - fk := n.group_entity_types + fk := n.group_item_templates if fk == nil { - return fmt.Errorf(`foreign-key "group_entity_types" is nil for node %v`, n.ID) + return fmt.Errorf(`foreign-key "group_item_templates" is nil for node %v`, n.ID) } node, ok := nodeids[*fk] if !ok { - return fmt.Errorf(`unexpected referenced foreign-key "group_entity_types" returned %v for node %v`, *fk, n.ID) + return fmt.Errorf(`unexpected referenced foreign-key "group_item_templates" returned %v for node %v`, *fk, n.ID) } assign(node, n) } diff --git a/backend/internal/data/ent/group_update.go b/backend/internal/data/ent/group_update.go index 6f137f0a..d0190d49 100644 --- a/backend/internal/data/ent/group_update.go +++ b/backend/internal/data/ent/group_update.go @@ -12,11 +12,12 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/label" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/user" @@ -84,19 +85,34 @@ func (_u *GroupUpdate) AddUsers(v ...*User) *GroupUpdate { return _u.AddUserIDs(ids...) } -// AddEntityIDs adds the "entities" edge to the Entity entity by IDs. -func (_u *GroupUpdate) AddEntityIDs(ids ...uuid.UUID) *GroupUpdate { - _u.mutation.AddEntityIDs(ids...) +// AddLocationIDs adds the "locations" edge to the Location entity by IDs. +func (_u *GroupUpdate) AddLocationIDs(ids ...uuid.UUID) *GroupUpdate { + _u.mutation.AddLocationIDs(ids...) return _u } -// AddEntities adds the "entities" edges to the Entity entity. -func (_u *GroupUpdate) AddEntities(v ...*Entity) *GroupUpdate { +// AddLocations adds the "locations" edges to the Location entity. +func (_u *GroupUpdate) AddLocations(v ...*Location) *GroupUpdate { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.AddEntityIDs(ids...) + return _u.AddLocationIDs(ids...) +} + +// AddItemIDs adds the "items" edge to the Item entity by IDs. +func (_u *GroupUpdate) AddItemIDs(ids ...uuid.UUID) *GroupUpdate { + _u.mutation.AddItemIDs(ids...) + return _u +} + +// AddItems adds the "items" edges to the Item entity. +func (_u *GroupUpdate) AddItems(v ...*Item) *GroupUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddItemIDs(ids...) } // AddLabelIDs adds the "labels" edge to the Label entity by IDs. @@ -144,19 +160,19 @@ func (_u *GroupUpdate) AddNotifiers(v ...*Notifier) *GroupUpdate { return _u.AddNotifierIDs(ids...) } -// AddEntityTypeIDs adds the "entity_types" edge to the EntityType entity by IDs. -func (_u *GroupUpdate) AddEntityTypeIDs(ids ...uuid.UUID) *GroupUpdate { - _u.mutation.AddEntityTypeIDs(ids...) +// AddItemTemplateIDs adds the "item_templates" edge to the ItemTemplate entity by IDs. +func (_u *GroupUpdate) AddItemTemplateIDs(ids ...uuid.UUID) *GroupUpdate { + _u.mutation.AddItemTemplateIDs(ids...) return _u } -// AddEntityTypes adds the "entity_types" edges to the EntityType entity. -func (_u *GroupUpdate) AddEntityTypes(v ...*EntityType) *GroupUpdate { +// AddItemTemplates adds the "item_templates" edges to the ItemTemplate entity. +func (_u *GroupUpdate) AddItemTemplates(v ...*ItemTemplate) *GroupUpdate { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.AddEntityTypeIDs(ids...) + return _u.AddItemTemplateIDs(ids...) } // Mutation returns the GroupMutation object of the builder. @@ -185,25 +201,46 @@ func (_u *GroupUpdate) RemoveUsers(v ...*User) *GroupUpdate { return _u.RemoveUserIDs(ids...) } -// ClearEntities clears all "entities" edges to the Entity entity. -func (_u *GroupUpdate) ClearEntities() *GroupUpdate { - _u.mutation.ClearEntities() +// ClearLocations clears all "locations" edges to the Location entity. +func (_u *GroupUpdate) ClearLocations() *GroupUpdate { + _u.mutation.ClearLocations() return _u } -// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs. -func (_u *GroupUpdate) RemoveEntityIDs(ids ...uuid.UUID) *GroupUpdate { - _u.mutation.RemoveEntityIDs(ids...) +// RemoveLocationIDs removes the "locations" edge to Location entities by IDs. +func (_u *GroupUpdate) RemoveLocationIDs(ids ...uuid.UUID) *GroupUpdate { + _u.mutation.RemoveLocationIDs(ids...) return _u } -// RemoveEntities removes "entities" edges to Entity entities. -func (_u *GroupUpdate) RemoveEntities(v ...*Entity) *GroupUpdate { +// RemoveLocations removes "locations" edges to Location entities. +func (_u *GroupUpdate) RemoveLocations(v ...*Location) *GroupUpdate { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.RemoveEntityIDs(ids...) + return _u.RemoveLocationIDs(ids...) +} + +// ClearItems clears all "items" edges to the Item entity. +func (_u *GroupUpdate) ClearItems() *GroupUpdate { + _u.mutation.ClearItems() + return _u +} + +// RemoveItemIDs removes the "items" edge to Item entities by IDs. +func (_u *GroupUpdate) RemoveItemIDs(ids ...uuid.UUID) *GroupUpdate { + _u.mutation.RemoveItemIDs(ids...) + return _u +} + +// RemoveItems removes "items" edges to Item entities. +func (_u *GroupUpdate) RemoveItems(v ...*Item) *GroupUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveItemIDs(ids...) } // ClearLabels clears all "labels" edges to the Label entity. @@ -269,25 +306,25 @@ func (_u *GroupUpdate) RemoveNotifiers(v ...*Notifier) *GroupUpdate { return _u.RemoveNotifierIDs(ids...) } -// ClearEntityTypes clears all "entity_types" edges to the EntityType entity. -func (_u *GroupUpdate) ClearEntityTypes() *GroupUpdate { - _u.mutation.ClearEntityTypes() +// ClearItemTemplates clears all "item_templates" edges to the ItemTemplate entity. +func (_u *GroupUpdate) ClearItemTemplates() *GroupUpdate { + _u.mutation.ClearItemTemplates() return _u } -// RemoveEntityTypeIDs removes the "entity_types" edge to EntityType entities by IDs. -func (_u *GroupUpdate) RemoveEntityTypeIDs(ids ...uuid.UUID) *GroupUpdate { - _u.mutation.RemoveEntityTypeIDs(ids...) +// RemoveItemTemplateIDs removes the "item_templates" edge to ItemTemplate entities by IDs. +func (_u *GroupUpdate) RemoveItemTemplateIDs(ids ...uuid.UUID) *GroupUpdate { + _u.mutation.RemoveItemTemplateIDs(ids...) return _u } -// RemoveEntityTypes removes "entity_types" edges to EntityType entities. -func (_u *GroupUpdate) RemoveEntityTypes(v ...*EntityType) *GroupUpdate { +// RemoveItemTemplates removes "item_templates" edges to ItemTemplate entities. +func (_u *GroupUpdate) RemoveItemTemplates(v ...*ItemTemplate) *GroupUpdate { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.RemoveEntityTypeIDs(ids...) + return _u.RemoveItemTemplateIDs(ids...) } // Save executes the query and returns the number of nodes affected by the update operation. @@ -402,28 +439,28 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.EntitiesCleared() { + if _u.mutation.LocationsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: group.EntitiesTable, - Columns: []string{group.EntitiesColumn}, + Table: group.LocationsTable, + Columns: []string{group.LocationsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() { + if nodes := _u.mutation.RemovedLocationsIDs(); len(nodes) > 0 && !_u.mutation.LocationsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: group.EntitiesTable, - Columns: []string{group.EntitiesColumn}, + Table: group.LocationsTable, + Columns: []string{group.LocationsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -431,15 +468,60 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.LocationsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: group.EntitiesTable, - Columns: []string{group.EntitiesColumn}, + Table: group.LocationsTable, + Columns: []string{group.LocationsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: group.ItemsTable, + Columns: []string{group.ItemsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: group.ItemsTable, + Columns: []string{group.ItemsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ItemsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: group.ItemsTable, + Columns: []string{group.ItemsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -582,28 +664,28 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.EntityTypesCleared() { + if _u.mutation.ItemTemplatesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: group.EntityTypesTable, - Columns: []string{group.EntityTypesColumn}, + Table: group.ItemTemplatesTable, + Columns: []string{group.ItemTemplatesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.RemovedEntityTypesIDs(); len(nodes) > 0 && !_u.mutation.EntityTypesCleared() { + if nodes := _u.mutation.RemovedItemTemplatesIDs(); len(nodes) > 0 && !_u.mutation.ItemTemplatesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: group.EntityTypesTable, - Columns: []string{group.EntityTypesColumn}, + Table: group.ItemTemplatesTable, + Columns: []string{group.ItemTemplatesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -611,15 +693,15 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.EntityTypesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ItemTemplatesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: group.EntityTypesTable, - Columns: []string{group.EntityTypesColumn}, + Table: group.ItemTemplatesTable, + Columns: []string{group.ItemTemplatesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -696,19 +778,34 @@ func (_u *GroupUpdateOne) AddUsers(v ...*User) *GroupUpdateOne { return _u.AddUserIDs(ids...) } -// AddEntityIDs adds the "entities" edge to the Entity entity by IDs. -func (_u *GroupUpdateOne) AddEntityIDs(ids ...uuid.UUID) *GroupUpdateOne { - _u.mutation.AddEntityIDs(ids...) +// AddLocationIDs adds the "locations" edge to the Location entity by IDs. +func (_u *GroupUpdateOne) AddLocationIDs(ids ...uuid.UUID) *GroupUpdateOne { + _u.mutation.AddLocationIDs(ids...) return _u } -// AddEntities adds the "entities" edges to the Entity entity. -func (_u *GroupUpdateOne) AddEntities(v ...*Entity) *GroupUpdateOne { +// AddLocations adds the "locations" edges to the Location entity. +func (_u *GroupUpdateOne) AddLocations(v ...*Location) *GroupUpdateOne { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.AddEntityIDs(ids...) + return _u.AddLocationIDs(ids...) +} + +// AddItemIDs adds the "items" edge to the Item entity by IDs. +func (_u *GroupUpdateOne) AddItemIDs(ids ...uuid.UUID) *GroupUpdateOne { + _u.mutation.AddItemIDs(ids...) + return _u +} + +// AddItems adds the "items" edges to the Item entity. +func (_u *GroupUpdateOne) AddItems(v ...*Item) *GroupUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddItemIDs(ids...) } // AddLabelIDs adds the "labels" edge to the Label entity by IDs. @@ -756,19 +853,19 @@ func (_u *GroupUpdateOne) AddNotifiers(v ...*Notifier) *GroupUpdateOne { return _u.AddNotifierIDs(ids...) } -// AddEntityTypeIDs adds the "entity_types" edge to the EntityType entity by IDs. -func (_u *GroupUpdateOne) AddEntityTypeIDs(ids ...uuid.UUID) *GroupUpdateOne { - _u.mutation.AddEntityTypeIDs(ids...) +// AddItemTemplateIDs adds the "item_templates" edge to the ItemTemplate entity by IDs. +func (_u *GroupUpdateOne) AddItemTemplateIDs(ids ...uuid.UUID) *GroupUpdateOne { + _u.mutation.AddItemTemplateIDs(ids...) return _u } -// AddEntityTypes adds the "entity_types" edges to the EntityType entity. -func (_u *GroupUpdateOne) AddEntityTypes(v ...*EntityType) *GroupUpdateOne { +// AddItemTemplates adds the "item_templates" edges to the ItemTemplate entity. +func (_u *GroupUpdateOne) AddItemTemplates(v ...*ItemTemplate) *GroupUpdateOne { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.AddEntityTypeIDs(ids...) + return _u.AddItemTemplateIDs(ids...) } // Mutation returns the GroupMutation object of the builder. @@ -797,25 +894,46 @@ func (_u *GroupUpdateOne) RemoveUsers(v ...*User) *GroupUpdateOne { return _u.RemoveUserIDs(ids...) } -// ClearEntities clears all "entities" edges to the Entity entity. -func (_u *GroupUpdateOne) ClearEntities() *GroupUpdateOne { - _u.mutation.ClearEntities() +// ClearLocations clears all "locations" edges to the Location entity. +func (_u *GroupUpdateOne) ClearLocations() *GroupUpdateOne { + _u.mutation.ClearLocations() return _u } -// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs. -func (_u *GroupUpdateOne) RemoveEntityIDs(ids ...uuid.UUID) *GroupUpdateOne { - _u.mutation.RemoveEntityIDs(ids...) +// RemoveLocationIDs removes the "locations" edge to Location entities by IDs. +func (_u *GroupUpdateOne) RemoveLocationIDs(ids ...uuid.UUID) *GroupUpdateOne { + _u.mutation.RemoveLocationIDs(ids...) return _u } -// RemoveEntities removes "entities" edges to Entity entities. -func (_u *GroupUpdateOne) RemoveEntities(v ...*Entity) *GroupUpdateOne { +// RemoveLocations removes "locations" edges to Location entities. +func (_u *GroupUpdateOne) RemoveLocations(v ...*Location) *GroupUpdateOne { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.RemoveEntityIDs(ids...) + return _u.RemoveLocationIDs(ids...) +} + +// ClearItems clears all "items" edges to the Item entity. +func (_u *GroupUpdateOne) ClearItems() *GroupUpdateOne { + _u.mutation.ClearItems() + return _u +} + +// RemoveItemIDs removes the "items" edge to Item entities by IDs. +func (_u *GroupUpdateOne) RemoveItemIDs(ids ...uuid.UUID) *GroupUpdateOne { + _u.mutation.RemoveItemIDs(ids...) + return _u +} + +// RemoveItems removes "items" edges to Item entities. +func (_u *GroupUpdateOne) RemoveItems(v ...*Item) *GroupUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveItemIDs(ids...) } // ClearLabels clears all "labels" edges to the Label entity. @@ -881,25 +999,25 @@ func (_u *GroupUpdateOne) RemoveNotifiers(v ...*Notifier) *GroupUpdateOne { return _u.RemoveNotifierIDs(ids...) } -// ClearEntityTypes clears all "entity_types" edges to the EntityType entity. -func (_u *GroupUpdateOne) ClearEntityTypes() *GroupUpdateOne { - _u.mutation.ClearEntityTypes() +// ClearItemTemplates clears all "item_templates" edges to the ItemTemplate entity. +func (_u *GroupUpdateOne) ClearItemTemplates() *GroupUpdateOne { + _u.mutation.ClearItemTemplates() return _u } -// RemoveEntityTypeIDs removes the "entity_types" edge to EntityType entities by IDs. -func (_u *GroupUpdateOne) RemoveEntityTypeIDs(ids ...uuid.UUID) *GroupUpdateOne { - _u.mutation.RemoveEntityTypeIDs(ids...) +// RemoveItemTemplateIDs removes the "item_templates" edge to ItemTemplate entities by IDs. +func (_u *GroupUpdateOne) RemoveItemTemplateIDs(ids ...uuid.UUID) *GroupUpdateOne { + _u.mutation.RemoveItemTemplateIDs(ids...) return _u } -// RemoveEntityTypes removes "entity_types" edges to EntityType entities. -func (_u *GroupUpdateOne) RemoveEntityTypes(v ...*EntityType) *GroupUpdateOne { +// RemoveItemTemplates removes "item_templates" edges to ItemTemplate entities. +func (_u *GroupUpdateOne) RemoveItemTemplates(v ...*ItemTemplate) *GroupUpdateOne { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.RemoveEntityTypeIDs(ids...) + return _u.RemoveItemTemplateIDs(ids...) } // Where appends a list predicates to the GroupUpdate builder. @@ -1044,28 +1162,28 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.EntitiesCleared() { + if _u.mutation.LocationsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: group.EntitiesTable, - Columns: []string{group.EntitiesColumn}, + Table: group.LocationsTable, + Columns: []string{group.LocationsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() { + if nodes := _u.mutation.RemovedLocationsIDs(); len(nodes) > 0 && !_u.mutation.LocationsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: group.EntitiesTable, - Columns: []string{group.EntitiesColumn}, + Table: group.LocationsTable, + Columns: []string{group.LocationsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -1073,15 +1191,60 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.LocationsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: group.EntitiesTable, - Columns: []string{group.EntitiesColumn}, + Table: group.LocationsTable, + Columns: []string{group.LocationsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: group.ItemsTable, + Columns: []string{group.ItemsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: group.ItemsTable, + Columns: []string{group.ItemsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ItemsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: group.ItemsTable, + Columns: []string{group.ItemsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -1224,28 +1387,28 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.EntityTypesCleared() { + if _u.mutation.ItemTemplatesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: group.EntityTypesTable, - Columns: []string{group.EntityTypesColumn}, + Table: group.ItemTemplatesTable, + Columns: []string{group.ItemTemplatesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.RemovedEntityTypesIDs(); len(nodes) > 0 && !_u.mutation.EntityTypesCleared() { + if nodes := _u.mutation.RemovedItemTemplatesIDs(); len(nodes) > 0 && !_u.mutation.ItemTemplatesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: group.EntityTypesTable, - Columns: []string{group.EntityTypesColumn}, + Table: group.ItemTemplatesTable, + Columns: []string{group.ItemTemplatesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -1253,15 +1416,15 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.EntityTypesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ItemTemplatesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, - Table: group.EntityTypesTable, - Columns: []string{group.EntityTypesColumn}, + Table: group.ItemTemplatesTable, + Columns: []string{group.ItemTemplatesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/backend/internal/data/ent/has_id.go b/backend/internal/data/ent/has_id.go index 78401ea4..faf28d4e 100644 --- a/backend/internal/data/ent/has_id.go +++ b/backend/internal/data/ent/has_id.go @@ -16,18 +16,6 @@ func (_m *AuthTokens) GetID() uuid.UUID { return _m.ID } -func (_m *Entity) GetID() uuid.UUID { - return _m.ID -} - -func (_m *EntityField) GetID() uuid.UUID { - return _m.ID -} - -func (_m *EntityType) GetID() uuid.UUID { - return _m.ID -} - func (_m *Group) GetID() uuid.UUID { return _m.ID } @@ -36,10 +24,26 @@ func (_m *GroupInvitationToken) GetID() uuid.UUID { return _m.ID } +func (_m *Item) GetID() uuid.UUID { + return _m.ID +} + +func (_m *ItemField) GetID() uuid.UUID { + return _m.ID +} + +func (_m *ItemTemplate) GetID() uuid.UUID { + return _m.ID +} + func (_m *Label) GetID() uuid.UUID { return _m.ID } +func (_m *Location) GetID() uuid.UUID { + return _m.ID +} + func (_m *MaintenanceEntry) GetID() uuid.UUID { return _m.ID } @@ -48,6 +52,10 @@ func (_m *Notifier) GetID() uuid.UUID { return _m.ID } +func (_m *TemplateField) GetID() uuid.UUID { + return _m.ID +} + func (_m *User) GetID() uuid.UUID { return _m.ID } diff --git a/backend/internal/data/ent/hook/hook.go b/backend/internal/data/ent/hook/hook.go index 185e6b5d..6859da52 100644 --- a/backend/internal/data/ent/hook/hook.go +++ b/backend/internal/data/ent/hook/hook.go @@ -45,42 +45,6 @@ func (f AuthTokensFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AuthTokensMutation", m) } -// The EntityFunc type is an adapter to allow the use of ordinary -// function as Entity mutator. -type EntityFunc func(context.Context, *ent.EntityMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f EntityFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.EntityMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EntityMutation", m) -} - -// The EntityFieldFunc type is an adapter to allow the use of ordinary -// function as EntityField mutator. -type EntityFieldFunc func(context.Context, *ent.EntityFieldMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f EntityFieldFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.EntityFieldMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EntityFieldMutation", m) -} - -// The EntityTypeFunc type is an adapter to allow the use of ordinary -// function as EntityType mutator. -type EntityTypeFunc func(context.Context, *ent.EntityTypeMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f EntityTypeFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.EntityTypeMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EntityTypeMutation", m) -} - // The GroupFunc type is an adapter to allow the use of ordinary // function as Group mutator. type GroupFunc func(context.Context, *ent.GroupMutation) (ent.Value, error) @@ -105,6 +69,42 @@ func (f GroupInvitationTokenFunc) Mutate(ctx context.Context, m ent.Mutation) (e return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.GroupInvitationTokenMutation", m) } +// The ItemFunc type is an adapter to allow the use of ordinary +// function as Item mutator. +type ItemFunc func(context.Context, *ent.ItemMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ItemFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ItemMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ItemMutation", m) +} + +// The ItemFieldFunc type is an adapter to allow the use of ordinary +// function as ItemField mutator. +type ItemFieldFunc func(context.Context, *ent.ItemFieldMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ItemFieldFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ItemFieldMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ItemFieldMutation", m) +} + +// The ItemTemplateFunc type is an adapter to allow the use of ordinary +// function as ItemTemplate mutator. +type ItemTemplateFunc func(context.Context, *ent.ItemTemplateMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ItemTemplateFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ItemTemplateMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ItemTemplateMutation", m) +} + // The LabelFunc type is an adapter to allow the use of ordinary // function as Label mutator. type LabelFunc func(context.Context, *ent.LabelMutation) (ent.Value, error) @@ -117,6 +117,18 @@ func (f LabelFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.LabelMutation", m) } +// The LocationFunc type is an adapter to allow the use of ordinary +// function as Location mutator. +type LocationFunc func(context.Context, *ent.LocationMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f LocationFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.LocationMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.LocationMutation", m) +} + // The MaintenanceEntryFunc type is an adapter to allow the use of ordinary // function as MaintenanceEntry mutator. type MaintenanceEntryFunc func(context.Context, *ent.MaintenanceEntryMutation) (ent.Value, error) @@ -141,6 +153,18 @@ func (f NotifierFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, er return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.NotifierMutation", m) } +// The TemplateFieldFunc type is an adapter to allow the use of ordinary +// function as TemplateField mutator. +type TemplateFieldFunc func(context.Context, *ent.TemplateFieldMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f TemplateFieldFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.TemplateFieldMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.TemplateFieldMutation", m) +} + // The UserFunc type is an adapter to allow the use of ordinary // function as User mutator. type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error) diff --git a/backend/internal/data/ent/item.go b/backend/internal/data/ent/item.go new file mode 100644 index 00000000..27c4f38d --- /dev/null +++ b/backend/internal/data/ent/item.go @@ -0,0 +1,542 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location" +) + +// Item is the model entity for the Item schema. +type Item struct { + config `json:"-"` + // ID of the ent. + ID uuid.UUID `json:"id,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // UpdatedAt holds the value of the "updated_at" field. + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Name holds the value of the "name" field. + Name string `json:"name,omitempty"` + // Description holds the value of the "description" field. + Description string `json:"description,omitempty"` + // ImportRef holds the value of the "import_ref" field. + ImportRef string `json:"import_ref,omitempty"` + // Notes holds the value of the "notes" field. + Notes string `json:"notes,omitempty"` + // Quantity holds the value of the "quantity" field. + Quantity int `json:"quantity,omitempty"` + // Insured holds the value of the "insured" field. + Insured bool `json:"insured,omitempty"` + // Archived holds the value of the "archived" field. + Archived bool `json:"archived,omitempty"` + // AssetID holds the value of the "asset_id" field. + AssetID int `json:"asset_id,omitempty"` + // SyncChildItemsLocations holds the value of the "sync_child_items_locations" field. + SyncChildItemsLocations bool `json:"sync_child_items_locations,omitempty"` + // SerialNumber holds the value of the "serial_number" field. + SerialNumber string `json:"serial_number,omitempty"` + // ModelNumber holds the value of the "model_number" field. + ModelNumber string `json:"model_number,omitempty"` + // Manufacturer holds the value of the "manufacturer" field. + Manufacturer string `json:"manufacturer,omitempty"` + // LifetimeWarranty holds the value of the "lifetime_warranty" field. + LifetimeWarranty bool `json:"lifetime_warranty,omitempty"` + // WarrantyExpires holds the value of the "warranty_expires" field. + WarrantyExpires time.Time `json:"warranty_expires,omitempty"` + // WarrantyDetails holds the value of the "warranty_details" field. + WarrantyDetails string `json:"warranty_details,omitempty"` + // PurchaseTime holds the value of the "purchase_time" field. + PurchaseTime time.Time `json:"purchase_time,omitempty"` + // PurchaseFrom holds the value of the "purchase_from" field. + PurchaseFrom string `json:"purchase_from,omitempty"` + // PurchasePrice holds the value of the "purchase_price" field. + PurchasePrice float64 `json:"purchase_price,omitempty"` + // SoldTime holds the value of the "sold_time" field. + SoldTime time.Time `json:"sold_time,omitempty"` + // SoldTo holds the value of the "sold_to" field. + SoldTo string `json:"sold_to,omitempty"` + // SoldPrice holds the value of the "sold_price" field. + SoldPrice float64 `json:"sold_price,omitempty"` + // SoldNotes holds the value of the "sold_notes" field. + SoldNotes string `json:"sold_notes,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ItemQuery when eager-loading is set. + Edges ItemEdges `json:"edges"` + group_items *uuid.UUID + item_children *uuid.UUID + location_items *uuid.UUID + selectValues sql.SelectValues +} + +// ItemEdges holds the relations/edges for other nodes in the graph. +type ItemEdges struct { + // Group holds the value of the group edge. + Group *Group `json:"group,omitempty"` + // Parent holds the value of the parent edge. + Parent *Item `json:"parent,omitempty"` + // Children holds the value of the children edge. + Children []*Item `json:"children,omitempty"` + // Label holds the value of the label edge. + Label []*Label `json:"label,omitempty"` + // Location holds the value of the location edge. + Location *Location `json:"location,omitempty"` + // Fields holds the value of the fields edge. + Fields []*ItemField `json:"fields,omitempty"` + // MaintenanceEntries holds the value of the maintenance_entries edge. + MaintenanceEntries []*MaintenanceEntry `json:"maintenance_entries,omitempty"` + // Attachments holds the value of the attachments edge. + Attachments []*Attachment `json:"attachments,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [8]bool +} + +// GroupOrErr returns the Group value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ItemEdges) GroupOrErr() (*Group, error) { + if e.Group != nil { + return e.Group, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: group.Label} + } + return nil, &NotLoadedError{edge: "group"} +} + +// ParentOrErr returns the Parent value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ItemEdges) ParentOrErr() (*Item, error) { + if e.Parent != nil { + return e.Parent, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: item.Label} + } + return nil, &NotLoadedError{edge: "parent"} +} + +// ChildrenOrErr returns the Children value or an error if the edge +// was not loaded in eager-loading. +func (e ItemEdges) ChildrenOrErr() ([]*Item, error) { + if e.loadedTypes[2] { + return e.Children, nil + } + return nil, &NotLoadedError{edge: "children"} +} + +// LabelOrErr returns the Label value or an error if the edge +// was not loaded in eager-loading. +func (e ItemEdges) LabelOrErr() ([]*Label, error) { + if e.loadedTypes[3] { + return e.Label, nil + } + return nil, &NotLoadedError{edge: "label"} +} + +// LocationOrErr returns the Location value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ItemEdges) LocationOrErr() (*Location, error) { + if e.Location != nil { + return e.Location, nil + } else if e.loadedTypes[4] { + return nil, &NotFoundError{label: location.Label} + } + return nil, &NotLoadedError{edge: "location"} +} + +// FieldsOrErr returns the Fields value or an error if the edge +// was not loaded in eager-loading. +func (e ItemEdges) FieldsOrErr() ([]*ItemField, error) { + if e.loadedTypes[5] { + return e.Fields, nil + } + return nil, &NotLoadedError{edge: "fields"} +} + +// MaintenanceEntriesOrErr returns the MaintenanceEntries value or an error if the edge +// was not loaded in eager-loading. +func (e ItemEdges) MaintenanceEntriesOrErr() ([]*MaintenanceEntry, error) { + if e.loadedTypes[6] { + return e.MaintenanceEntries, nil + } + return nil, &NotLoadedError{edge: "maintenance_entries"} +} + +// AttachmentsOrErr returns the Attachments value or an error if the edge +// was not loaded in eager-loading. +func (e ItemEdges) AttachmentsOrErr() ([]*Attachment, error) { + if e.loadedTypes[7] { + return e.Attachments, nil + } + return nil, &NotLoadedError{edge: "attachments"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Item) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case item.FieldInsured, item.FieldArchived, item.FieldSyncChildItemsLocations, item.FieldLifetimeWarranty: + values[i] = new(sql.NullBool) + case item.FieldPurchasePrice, item.FieldSoldPrice: + values[i] = new(sql.NullFloat64) + case item.FieldQuantity, item.FieldAssetID: + values[i] = new(sql.NullInt64) + case item.FieldName, item.FieldDescription, item.FieldImportRef, item.FieldNotes, item.FieldSerialNumber, item.FieldModelNumber, item.FieldManufacturer, item.FieldWarrantyDetails, item.FieldPurchaseFrom, item.FieldSoldTo, item.FieldSoldNotes: + values[i] = new(sql.NullString) + case item.FieldCreatedAt, item.FieldUpdatedAt, item.FieldWarrantyExpires, item.FieldPurchaseTime, item.FieldSoldTime: + values[i] = new(sql.NullTime) + case item.FieldID: + values[i] = new(uuid.UUID) + case item.ForeignKeys[0]: // group_items + values[i] = &sql.NullScanner{S: new(uuid.UUID)} + case item.ForeignKeys[1]: // item_children + values[i] = &sql.NullScanner{S: new(uuid.UUID)} + case item.ForeignKeys[2]: // location_items + values[i] = &sql.NullScanner{S: new(uuid.UUID)} + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Item fields. +func (_m *Item) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case item.FieldID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + _m.ID = *value + } + case item.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + _m.CreatedAt = value.Time + } + case item.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + _m.UpdatedAt = value.Time + } + case item.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + _m.Name = value.String + } + case item.FieldDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field description", values[i]) + } else if value.Valid { + _m.Description = value.String + } + case item.FieldImportRef: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field import_ref", values[i]) + } else if value.Valid { + _m.ImportRef = value.String + } + case item.FieldNotes: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field notes", values[i]) + } else if value.Valid { + _m.Notes = value.String + } + case item.FieldQuantity: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field quantity", values[i]) + } else if value.Valid { + _m.Quantity = int(value.Int64) + } + case item.FieldInsured: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field insured", values[i]) + } else if value.Valid { + _m.Insured = value.Bool + } + case item.FieldArchived: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field archived", values[i]) + } else if value.Valid { + _m.Archived = value.Bool + } + case item.FieldAssetID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field asset_id", values[i]) + } else if value.Valid { + _m.AssetID = int(value.Int64) + } + case item.FieldSyncChildItemsLocations: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field sync_child_items_locations", values[i]) + } else if value.Valid { + _m.SyncChildItemsLocations = value.Bool + } + case item.FieldSerialNumber: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field serial_number", values[i]) + } else if value.Valid { + _m.SerialNumber = value.String + } + case item.FieldModelNumber: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field model_number", values[i]) + } else if value.Valid { + _m.ModelNumber = value.String + } + case item.FieldManufacturer: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field manufacturer", values[i]) + } else if value.Valid { + _m.Manufacturer = value.String + } + case item.FieldLifetimeWarranty: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field lifetime_warranty", values[i]) + } else if value.Valid { + _m.LifetimeWarranty = value.Bool + } + case item.FieldWarrantyExpires: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field warranty_expires", values[i]) + } else if value.Valid { + _m.WarrantyExpires = value.Time + } + case item.FieldWarrantyDetails: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field warranty_details", values[i]) + } else if value.Valid { + _m.WarrantyDetails = value.String + } + case item.FieldPurchaseTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field purchase_time", values[i]) + } else if value.Valid { + _m.PurchaseTime = value.Time + } + case item.FieldPurchaseFrom: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field purchase_from", values[i]) + } else if value.Valid { + _m.PurchaseFrom = value.String + } + case item.FieldPurchasePrice: + if value, ok := values[i].(*sql.NullFloat64); !ok { + return fmt.Errorf("unexpected type %T for field purchase_price", values[i]) + } else if value.Valid { + _m.PurchasePrice = value.Float64 + } + case item.FieldSoldTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field sold_time", values[i]) + } else if value.Valid { + _m.SoldTime = value.Time + } + case item.FieldSoldTo: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field sold_to", values[i]) + } else if value.Valid { + _m.SoldTo = value.String + } + case item.FieldSoldPrice: + if value, ok := values[i].(*sql.NullFloat64); !ok { + return fmt.Errorf("unexpected type %T for field sold_price", values[i]) + } else if value.Valid { + _m.SoldPrice = value.Float64 + } + case item.FieldSoldNotes: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field sold_notes", values[i]) + } else if value.Valid { + _m.SoldNotes = value.String + } + case item.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field group_items", values[i]) + } else if value.Valid { + _m.group_items = new(uuid.UUID) + *_m.group_items = *value.S.(*uuid.UUID) + } + case item.ForeignKeys[1]: + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field item_children", values[i]) + } else if value.Valid { + _m.item_children = new(uuid.UUID) + *_m.item_children = *value.S.(*uuid.UUID) + } + case item.ForeignKeys[2]: + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field location_items", values[i]) + } else if value.Valid { + _m.location_items = new(uuid.UUID) + *_m.location_items = *value.S.(*uuid.UUID) + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Item. +// This includes values selected through modifiers, order, etc. +func (_m *Item) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryGroup queries the "group" edge of the Item entity. +func (_m *Item) QueryGroup() *GroupQuery { + return NewItemClient(_m.config).QueryGroup(_m) +} + +// QueryParent queries the "parent" edge of the Item entity. +func (_m *Item) QueryParent() *ItemQuery { + return NewItemClient(_m.config).QueryParent(_m) +} + +// QueryChildren queries the "children" edge of the Item entity. +func (_m *Item) QueryChildren() *ItemQuery { + return NewItemClient(_m.config).QueryChildren(_m) +} + +// QueryLabel queries the "label" edge of the Item entity. +func (_m *Item) QueryLabel() *LabelQuery { + return NewItemClient(_m.config).QueryLabel(_m) +} + +// QueryLocation queries the "location" edge of the Item entity. +func (_m *Item) QueryLocation() *LocationQuery { + return NewItemClient(_m.config).QueryLocation(_m) +} + +// QueryFields queries the "fields" edge of the Item entity. +func (_m *Item) QueryFields() *ItemFieldQuery { + return NewItemClient(_m.config).QueryFields(_m) +} + +// QueryMaintenanceEntries queries the "maintenance_entries" edge of the Item entity. +func (_m *Item) QueryMaintenanceEntries() *MaintenanceEntryQuery { + return NewItemClient(_m.config).QueryMaintenanceEntries(_m) +} + +// QueryAttachments queries the "attachments" edge of the Item entity. +func (_m *Item) QueryAttachments() *AttachmentQuery { + return NewItemClient(_m.config).QueryAttachments(_m) +} + +// Update returns a builder for updating this Item. +// Note that you need to call Item.Unwrap() before calling this method if this Item +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *Item) Update() *ItemUpdateOne { + return NewItemClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the Item entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *Item) Unwrap() *Item { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: Item is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *Item) String() string { + var builder strings.Builder + builder.WriteString("Item(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("created_at=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(_m.Name) + builder.WriteString(", ") + builder.WriteString("description=") + builder.WriteString(_m.Description) + builder.WriteString(", ") + builder.WriteString("import_ref=") + builder.WriteString(_m.ImportRef) + builder.WriteString(", ") + builder.WriteString("notes=") + builder.WriteString(_m.Notes) + builder.WriteString(", ") + builder.WriteString("quantity=") + builder.WriteString(fmt.Sprintf("%v", _m.Quantity)) + builder.WriteString(", ") + builder.WriteString("insured=") + builder.WriteString(fmt.Sprintf("%v", _m.Insured)) + builder.WriteString(", ") + builder.WriteString("archived=") + builder.WriteString(fmt.Sprintf("%v", _m.Archived)) + builder.WriteString(", ") + builder.WriteString("asset_id=") + builder.WriteString(fmt.Sprintf("%v", _m.AssetID)) + builder.WriteString(", ") + builder.WriteString("sync_child_items_locations=") + builder.WriteString(fmt.Sprintf("%v", _m.SyncChildItemsLocations)) + builder.WriteString(", ") + builder.WriteString("serial_number=") + builder.WriteString(_m.SerialNumber) + builder.WriteString(", ") + builder.WriteString("model_number=") + builder.WriteString(_m.ModelNumber) + builder.WriteString(", ") + builder.WriteString("manufacturer=") + builder.WriteString(_m.Manufacturer) + builder.WriteString(", ") + builder.WriteString("lifetime_warranty=") + builder.WriteString(fmt.Sprintf("%v", _m.LifetimeWarranty)) + builder.WriteString(", ") + builder.WriteString("warranty_expires=") + builder.WriteString(_m.WarrantyExpires.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("warranty_details=") + builder.WriteString(_m.WarrantyDetails) + builder.WriteString(", ") + builder.WriteString("purchase_time=") + builder.WriteString(_m.PurchaseTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("purchase_from=") + builder.WriteString(_m.PurchaseFrom) + builder.WriteString(", ") + builder.WriteString("purchase_price=") + builder.WriteString(fmt.Sprintf("%v", _m.PurchasePrice)) + builder.WriteString(", ") + builder.WriteString("sold_time=") + builder.WriteString(_m.SoldTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("sold_to=") + builder.WriteString(_m.SoldTo) + builder.WriteString(", ") + builder.WriteString("sold_price=") + builder.WriteString(fmt.Sprintf("%v", _m.SoldPrice)) + builder.WriteString(", ") + builder.WriteString("sold_notes=") + builder.WriteString(_m.SoldNotes) + builder.WriteByte(')') + return builder.String() +} + +// Items is a parsable slice of Item. +type Items []*Item diff --git a/backend/internal/data/ent/item_create.go b/backend/internal/data/ent/item_create.go new file mode 100644 index 00000000..48a77a8e --- /dev/null +++ b/backend/internal/data/ent/item_create.go @@ -0,0 +1,1007 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/label" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry" +) + +// ItemCreate is the builder for creating a Item entity. +type ItemCreate struct { + config + mutation *ItemMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (_c *ItemCreate) SetCreatedAt(v time.Time) *ItemCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *ItemCreate) SetNillableCreatedAt(v *time.Time) *ItemCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *ItemCreate) SetUpdatedAt(v time.Time) *ItemCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *ItemCreate) SetNillableUpdatedAt(v *time.Time) *ItemCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetName sets the "name" field. +func (_c *ItemCreate) SetName(v string) *ItemCreate { + _c.mutation.SetName(v) + return _c +} + +// SetDescription sets the "description" field. +func (_c *ItemCreate) SetDescription(v string) *ItemCreate { + _c.mutation.SetDescription(v) + return _c +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_c *ItemCreate) SetNillableDescription(v *string) *ItemCreate { + if v != nil { + _c.SetDescription(*v) + } + return _c +} + +// SetImportRef sets the "import_ref" field. +func (_c *ItemCreate) SetImportRef(v string) *ItemCreate { + _c.mutation.SetImportRef(v) + return _c +} + +// SetNillableImportRef sets the "import_ref" field if the given value is not nil. +func (_c *ItemCreate) SetNillableImportRef(v *string) *ItemCreate { + if v != nil { + _c.SetImportRef(*v) + } + return _c +} + +// SetNotes sets the "notes" field. +func (_c *ItemCreate) SetNotes(v string) *ItemCreate { + _c.mutation.SetNotes(v) + return _c +} + +// SetNillableNotes sets the "notes" field if the given value is not nil. +func (_c *ItemCreate) SetNillableNotes(v *string) *ItemCreate { + if v != nil { + _c.SetNotes(*v) + } + return _c +} + +// SetQuantity sets the "quantity" field. +func (_c *ItemCreate) SetQuantity(v int) *ItemCreate { + _c.mutation.SetQuantity(v) + return _c +} + +// SetNillableQuantity sets the "quantity" field if the given value is not nil. +func (_c *ItemCreate) SetNillableQuantity(v *int) *ItemCreate { + if v != nil { + _c.SetQuantity(*v) + } + return _c +} + +// SetInsured sets the "insured" field. +func (_c *ItemCreate) SetInsured(v bool) *ItemCreate { + _c.mutation.SetInsured(v) + return _c +} + +// SetNillableInsured sets the "insured" field if the given value is not nil. +func (_c *ItemCreate) SetNillableInsured(v *bool) *ItemCreate { + if v != nil { + _c.SetInsured(*v) + } + return _c +} + +// SetArchived sets the "archived" field. +func (_c *ItemCreate) SetArchived(v bool) *ItemCreate { + _c.mutation.SetArchived(v) + return _c +} + +// SetNillableArchived sets the "archived" field if the given value is not nil. +func (_c *ItemCreate) SetNillableArchived(v *bool) *ItemCreate { + if v != nil { + _c.SetArchived(*v) + } + return _c +} + +// SetAssetID sets the "asset_id" field. +func (_c *ItemCreate) SetAssetID(v int) *ItemCreate { + _c.mutation.SetAssetID(v) + return _c +} + +// SetNillableAssetID sets the "asset_id" field if the given value is not nil. +func (_c *ItemCreate) SetNillableAssetID(v *int) *ItemCreate { + if v != nil { + _c.SetAssetID(*v) + } + return _c +} + +// SetSyncChildItemsLocations sets the "sync_child_items_locations" field. +func (_c *ItemCreate) SetSyncChildItemsLocations(v bool) *ItemCreate { + _c.mutation.SetSyncChildItemsLocations(v) + return _c +} + +// SetNillableSyncChildItemsLocations sets the "sync_child_items_locations" field if the given value is not nil. +func (_c *ItemCreate) SetNillableSyncChildItemsLocations(v *bool) *ItemCreate { + if v != nil { + _c.SetSyncChildItemsLocations(*v) + } + return _c +} + +// SetSerialNumber sets the "serial_number" field. +func (_c *ItemCreate) SetSerialNumber(v string) *ItemCreate { + _c.mutation.SetSerialNumber(v) + return _c +} + +// SetNillableSerialNumber sets the "serial_number" field if the given value is not nil. +func (_c *ItemCreate) SetNillableSerialNumber(v *string) *ItemCreate { + if v != nil { + _c.SetSerialNumber(*v) + } + return _c +} + +// SetModelNumber sets the "model_number" field. +func (_c *ItemCreate) SetModelNumber(v string) *ItemCreate { + _c.mutation.SetModelNumber(v) + return _c +} + +// SetNillableModelNumber sets the "model_number" field if the given value is not nil. +func (_c *ItemCreate) SetNillableModelNumber(v *string) *ItemCreate { + if v != nil { + _c.SetModelNumber(*v) + } + return _c +} + +// SetManufacturer sets the "manufacturer" field. +func (_c *ItemCreate) SetManufacturer(v string) *ItemCreate { + _c.mutation.SetManufacturer(v) + return _c +} + +// SetNillableManufacturer sets the "manufacturer" field if the given value is not nil. +func (_c *ItemCreate) SetNillableManufacturer(v *string) *ItemCreate { + if v != nil { + _c.SetManufacturer(*v) + } + return _c +} + +// SetLifetimeWarranty sets the "lifetime_warranty" field. +func (_c *ItemCreate) SetLifetimeWarranty(v bool) *ItemCreate { + _c.mutation.SetLifetimeWarranty(v) + return _c +} + +// SetNillableLifetimeWarranty sets the "lifetime_warranty" field if the given value is not nil. +func (_c *ItemCreate) SetNillableLifetimeWarranty(v *bool) *ItemCreate { + if v != nil { + _c.SetLifetimeWarranty(*v) + } + return _c +} + +// SetWarrantyExpires sets the "warranty_expires" field. +func (_c *ItemCreate) SetWarrantyExpires(v time.Time) *ItemCreate { + _c.mutation.SetWarrantyExpires(v) + return _c +} + +// SetNillableWarrantyExpires sets the "warranty_expires" field if the given value is not nil. +func (_c *ItemCreate) SetNillableWarrantyExpires(v *time.Time) *ItemCreate { + if v != nil { + _c.SetWarrantyExpires(*v) + } + return _c +} + +// SetWarrantyDetails sets the "warranty_details" field. +func (_c *ItemCreate) SetWarrantyDetails(v string) *ItemCreate { + _c.mutation.SetWarrantyDetails(v) + return _c +} + +// SetNillableWarrantyDetails sets the "warranty_details" field if the given value is not nil. +func (_c *ItemCreate) SetNillableWarrantyDetails(v *string) *ItemCreate { + if v != nil { + _c.SetWarrantyDetails(*v) + } + return _c +} + +// SetPurchaseTime sets the "purchase_time" field. +func (_c *ItemCreate) SetPurchaseTime(v time.Time) *ItemCreate { + _c.mutation.SetPurchaseTime(v) + return _c +} + +// SetNillablePurchaseTime sets the "purchase_time" field if the given value is not nil. +func (_c *ItemCreate) SetNillablePurchaseTime(v *time.Time) *ItemCreate { + if v != nil { + _c.SetPurchaseTime(*v) + } + return _c +} + +// SetPurchaseFrom sets the "purchase_from" field. +func (_c *ItemCreate) SetPurchaseFrom(v string) *ItemCreate { + _c.mutation.SetPurchaseFrom(v) + return _c +} + +// SetNillablePurchaseFrom sets the "purchase_from" field if the given value is not nil. +func (_c *ItemCreate) SetNillablePurchaseFrom(v *string) *ItemCreate { + if v != nil { + _c.SetPurchaseFrom(*v) + } + return _c +} + +// SetPurchasePrice sets the "purchase_price" field. +func (_c *ItemCreate) SetPurchasePrice(v float64) *ItemCreate { + _c.mutation.SetPurchasePrice(v) + return _c +} + +// SetNillablePurchasePrice sets the "purchase_price" field if the given value is not nil. +func (_c *ItemCreate) SetNillablePurchasePrice(v *float64) *ItemCreate { + if v != nil { + _c.SetPurchasePrice(*v) + } + return _c +} + +// SetSoldTime sets the "sold_time" field. +func (_c *ItemCreate) SetSoldTime(v time.Time) *ItemCreate { + _c.mutation.SetSoldTime(v) + return _c +} + +// SetNillableSoldTime sets the "sold_time" field if the given value is not nil. +func (_c *ItemCreate) SetNillableSoldTime(v *time.Time) *ItemCreate { + if v != nil { + _c.SetSoldTime(*v) + } + return _c +} + +// SetSoldTo sets the "sold_to" field. +func (_c *ItemCreate) SetSoldTo(v string) *ItemCreate { + _c.mutation.SetSoldTo(v) + return _c +} + +// SetNillableSoldTo sets the "sold_to" field if the given value is not nil. +func (_c *ItemCreate) SetNillableSoldTo(v *string) *ItemCreate { + if v != nil { + _c.SetSoldTo(*v) + } + return _c +} + +// SetSoldPrice sets the "sold_price" field. +func (_c *ItemCreate) SetSoldPrice(v float64) *ItemCreate { + _c.mutation.SetSoldPrice(v) + return _c +} + +// SetNillableSoldPrice sets the "sold_price" field if the given value is not nil. +func (_c *ItemCreate) SetNillableSoldPrice(v *float64) *ItemCreate { + if v != nil { + _c.SetSoldPrice(*v) + } + return _c +} + +// SetSoldNotes sets the "sold_notes" field. +func (_c *ItemCreate) SetSoldNotes(v string) *ItemCreate { + _c.mutation.SetSoldNotes(v) + return _c +} + +// SetNillableSoldNotes sets the "sold_notes" field if the given value is not nil. +func (_c *ItemCreate) SetNillableSoldNotes(v *string) *ItemCreate { + if v != nil { + _c.SetSoldNotes(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *ItemCreate) SetID(v uuid.UUID) *ItemCreate { + _c.mutation.SetID(v) + return _c +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (_c *ItemCreate) SetNillableID(v *uuid.UUID) *ItemCreate { + if v != nil { + _c.SetID(*v) + } + return _c +} + +// SetGroupID sets the "group" edge to the Group entity by ID. +func (_c *ItemCreate) SetGroupID(id uuid.UUID) *ItemCreate { + _c.mutation.SetGroupID(id) + return _c +} + +// SetGroup sets the "group" edge to the Group entity. +func (_c *ItemCreate) SetGroup(v *Group) *ItemCreate { + return _c.SetGroupID(v.ID) +} + +// SetParentID sets the "parent" edge to the Item entity by ID. +func (_c *ItemCreate) SetParentID(id uuid.UUID) *ItemCreate { + _c.mutation.SetParentID(id) + return _c +} + +// SetNillableParentID sets the "parent" edge to the Item entity by ID if the given value is not nil. +func (_c *ItemCreate) SetNillableParentID(id *uuid.UUID) *ItemCreate { + if id != nil { + _c = _c.SetParentID(*id) + } + return _c +} + +// SetParent sets the "parent" edge to the Item entity. +func (_c *ItemCreate) SetParent(v *Item) *ItemCreate { + return _c.SetParentID(v.ID) +} + +// AddChildIDs adds the "children" edge to the Item entity by IDs. +func (_c *ItemCreate) AddChildIDs(ids ...uuid.UUID) *ItemCreate { + _c.mutation.AddChildIDs(ids...) + return _c +} + +// AddChildren adds the "children" edges to the Item entity. +func (_c *ItemCreate) AddChildren(v ...*Item) *ItemCreate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddChildIDs(ids...) +} + +// AddLabelIDs adds the "label" edge to the Label entity by IDs. +func (_c *ItemCreate) AddLabelIDs(ids ...uuid.UUID) *ItemCreate { + _c.mutation.AddLabelIDs(ids...) + return _c +} + +// AddLabel adds the "label" edges to the Label entity. +func (_c *ItemCreate) AddLabel(v ...*Label) *ItemCreate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddLabelIDs(ids...) +} + +// SetLocationID sets the "location" edge to the Location entity by ID. +func (_c *ItemCreate) SetLocationID(id uuid.UUID) *ItemCreate { + _c.mutation.SetLocationID(id) + return _c +} + +// SetNillableLocationID sets the "location" edge to the Location entity by ID if the given value is not nil. +func (_c *ItemCreate) SetNillableLocationID(id *uuid.UUID) *ItemCreate { + if id != nil { + _c = _c.SetLocationID(*id) + } + return _c +} + +// SetLocation sets the "location" edge to the Location entity. +func (_c *ItemCreate) SetLocation(v *Location) *ItemCreate { + return _c.SetLocationID(v.ID) +} + +// AddFieldIDs adds the "fields" edge to the ItemField entity by IDs. +func (_c *ItemCreate) AddFieldIDs(ids ...uuid.UUID) *ItemCreate { + _c.mutation.AddFieldIDs(ids...) + return _c +} + +// AddFields adds the "fields" edges to the ItemField entity. +func (_c *ItemCreate) AddFields(v ...*ItemField) *ItemCreate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddFieldIDs(ids...) +} + +// AddMaintenanceEntryIDs adds the "maintenance_entries" edge to the MaintenanceEntry entity by IDs. +func (_c *ItemCreate) AddMaintenanceEntryIDs(ids ...uuid.UUID) *ItemCreate { + _c.mutation.AddMaintenanceEntryIDs(ids...) + return _c +} + +// AddMaintenanceEntries adds the "maintenance_entries" edges to the MaintenanceEntry entity. +func (_c *ItemCreate) AddMaintenanceEntries(v ...*MaintenanceEntry) *ItemCreate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddMaintenanceEntryIDs(ids...) +} + +// AddAttachmentIDs adds the "attachments" edge to the Attachment entity by IDs. +func (_c *ItemCreate) AddAttachmentIDs(ids ...uuid.UUID) *ItemCreate { + _c.mutation.AddAttachmentIDs(ids...) + return _c +} + +// AddAttachments adds the "attachments" edges to the Attachment entity. +func (_c *ItemCreate) AddAttachments(v ...*Attachment) *ItemCreate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddAttachmentIDs(ids...) +} + +// Mutation returns the ItemMutation object of the builder. +func (_c *ItemCreate) Mutation() *ItemMutation { + return _c.mutation +} + +// Save creates the Item in the database. +func (_c *ItemCreate) Save(ctx context.Context) (*Item, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *ItemCreate) SaveX(ctx context.Context) *Item { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *ItemCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *ItemCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *ItemCreate) defaults() { + if _, ok := _c.mutation.CreatedAt(); !ok { + v := item.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := item.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.Quantity(); !ok { + v := item.DefaultQuantity + _c.mutation.SetQuantity(v) + } + if _, ok := _c.mutation.Insured(); !ok { + v := item.DefaultInsured + _c.mutation.SetInsured(v) + } + if _, ok := _c.mutation.Archived(); !ok { + v := item.DefaultArchived + _c.mutation.SetArchived(v) + } + if _, ok := _c.mutation.AssetID(); !ok { + v := item.DefaultAssetID + _c.mutation.SetAssetID(v) + } + if _, ok := _c.mutation.SyncChildItemsLocations(); !ok { + v := item.DefaultSyncChildItemsLocations + _c.mutation.SetSyncChildItemsLocations(v) + } + if _, ok := _c.mutation.LifetimeWarranty(); !ok { + v := item.DefaultLifetimeWarranty + _c.mutation.SetLifetimeWarranty(v) + } + if _, ok := _c.mutation.PurchasePrice(); !ok { + v := item.DefaultPurchasePrice + _c.mutation.SetPurchasePrice(v) + } + if _, ok := _c.mutation.SoldPrice(); !ok { + v := item.DefaultSoldPrice + _c.mutation.SetSoldPrice(v) + } + if _, ok := _c.mutation.ID(); !ok { + v := item.DefaultID() + _c.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *ItemCreate) check() error { + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Item.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Item.updated_at"`)} + } + if _, ok := _c.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Item.name"`)} + } + if v, ok := _c.mutation.Name(); ok { + if err := item.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Item.name": %w`, err)} + } + } + if v, ok := _c.mutation.Description(); ok { + if err := item.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Item.description": %w`, err)} + } + } + if v, ok := _c.mutation.ImportRef(); ok { + if err := item.ImportRefValidator(v); err != nil { + return &ValidationError{Name: "import_ref", err: fmt.Errorf(`ent: validator failed for field "Item.import_ref": %w`, err)} + } + } + if v, ok := _c.mutation.Notes(); ok { + if err := item.NotesValidator(v); err != nil { + return &ValidationError{Name: "notes", err: fmt.Errorf(`ent: validator failed for field "Item.notes": %w`, err)} + } + } + if _, ok := _c.mutation.Quantity(); !ok { + return &ValidationError{Name: "quantity", err: errors.New(`ent: missing required field "Item.quantity"`)} + } + if _, ok := _c.mutation.Insured(); !ok { + return &ValidationError{Name: "insured", err: errors.New(`ent: missing required field "Item.insured"`)} + } + if _, ok := _c.mutation.Archived(); !ok { + return &ValidationError{Name: "archived", err: errors.New(`ent: missing required field "Item.archived"`)} + } + if _, ok := _c.mutation.AssetID(); !ok { + return &ValidationError{Name: "asset_id", err: errors.New(`ent: missing required field "Item.asset_id"`)} + } + if _, ok := _c.mutation.SyncChildItemsLocations(); !ok { + return &ValidationError{Name: "sync_child_items_locations", err: errors.New(`ent: missing required field "Item.sync_child_items_locations"`)} + } + if v, ok := _c.mutation.SerialNumber(); ok { + if err := item.SerialNumberValidator(v); err != nil { + return &ValidationError{Name: "serial_number", err: fmt.Errorf(`ent: validator failed for field "Item.serial_number": %w`, err)} + } + } + if v, ok := _c.mutation.ModelNumber(); ok { + if err := item.ModelNumberValidator(v); err != nil { + return &ValidationError{Name: "model_number", err: fmt.Errorf(`ent: validator failed for field "Item.model_number": %w`, err)} + } + } + if v, ok := _c.mutation.Manufacturer(); ok { + if err := item.ManufacturerValidator(v); err != nil { + return &ValidationError{Name: "manufacturer", err: fmt.Errorf(`ent: validator failed for field "Item.manufacturer": %w`, err)} + } + } + if _, ok := _c.mutation.LifetimeWarranty(); !ok { + return &ValidationError{Name: "lifetime_warranty", err: errors.New(`ent: missing required field "Item.lifetime_warranty"`)} + } + if v, ok := _c.mutation.WarrantyDetails(); ok { + if err := item.WarrantyDetailsValidator(v); err != nil { + return &ValidationError{Name: "warranty_details", err: fmt.Errorf(`ent: validator failed for field "Item.warranty_details": %w`, err)} + } + } + if _, ok := _c.mutation.PurchasePrice(); !ok { + return &ValidationError{Name: "purchase_price", err: errors.New(`ent: missing required field "Item.purchase_price"`)} + } + if _, ok := _c.mutation.SoldPrice(); !ok { + return &ValidationError{Name: "sold_price", err: errors.New(`ent: missing required field "Item.sold_price"`)} + } + if v, ok := _c.mutation.SoldNotes(); ok { + if err := item.SoldNotesValidator(v); err != nil { + return &ValidationError{Name: "sold_notes", err: fmt.Errorf(`ent: validator failed for field "Item.sold_notes": %w`, err)} + } + } + if len(_c.mutation.GroupIDs()) == 0 { + return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "Item.group"`)} + } + return nil +} + +func (_c *ItemCreate) sqlSave(ctx context.Context) (*Item, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *ItemCreate) createSpec() (*Item, *sqlgraph.CreateSpec) { + var ( + _node = &Item{config: _c.config} + _spec = sqlgraph.NewCreateSpec(item.Table, sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(item.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(item.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := _c.mutation.Name(); ok { + _spec.SetField(item.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := _c.mutation.Description(); ok { + _spec.SetField(item.FieldDescription, field.TypeString, value) + _node.Description = value + } + if value, ok := _c.mutation.ImportRef(); ok { + _spec.SetField(item.FieldImportRef, field.TypeString, value) + _node.ImportRef = value + } + if value, ok := _c.mutation.Notes(); ok { + _spec.SetField(item.FieldNotes, field.TypeString, value) + _node.Notes = value + } + if value, ok := _c.mutation.Quantity(); ok { + _spec.SetField(item.FieldQuantity, field.TypeInt, value) + _node.Quantity = value + } + if value, ok := _c.mutation.Insured(); ok { + _spec.SetField(item.FieldInsured, field.TypeBool, value) + _node.Insured = value + } + if value, ok := _c.mutation.Archived(); ok { + _spec.SetField(item.FieldArchived, field.TypeBool, value) + _node.Archived = value + } + if value, ok := _c.mutation.AssetID(); ok { + _spec.SetField(item.FieldAssetID, field.TypeInt, value) + _node.AssetID = value + } + if value, ok := _c.mutation.SyncChildItemsLocations(); ok { + _spec.SetField(item.FieldSyncChildItemsLocations, field.TypeBool, value) + _node.SyncChildItemsLocations = value + } + if value, ok := _c.mutation.SerialNumber(); ok { + _spec.SetField(item.FieldSerialNumber, field.TypeString, value) + _node.SerialNumber = value + } + if value, ok := _c.mutation.ModelNumber(); ok { + _spec.SetField(item.FieldModelNumber, field.TypeString, value) + _node.ModelNumber = value + } + if value, ok := _c.mutation.Manufacturer(); ok { + _spec.SetField(item.FieldManufacturer, field.TypeString, value) + _node.Manufacturer = value + } + if value, ok := _c.mutation.LifetimeWarranty(); ok { + _spec.SetField(item.FieldLifetimeWarranty, field.TypeBool, value) + _node.LifetimeWarranty = value + } + if value, ok := _c.mutation.WarrantyExpires(); ok { + _spec.SetField(item.FieldWarrantyExpires, field.TypeTime, value) + _node.WarrantyExpires = value + } + if value, ok := _c.mutation.WarrantyDetails(); ok { + _spec.SetField(item.FieldWarrantyDetails, field.TypeString, value) + _node.WarrantyDetails = value + } + if value, ok := _c.mutation.PurchaseTime(); ok { + _spec.SetField(item.FieldPurchaseTime, field.TypeTime, value) + _node.PurchaseTime = value + } + if value, ok := _c.mutation.PurchaseFrom(); ok { + _spec.SetField(item.FieldPurchaseFrom, field.TypeString, value) + _node.PurchaseFrom = value + } + if value, ok := _c.mutation.PurchasePrice(); ok { + _spec.SetField(item.FieldPurchasePrice, field.TypeFloat64, value) + _node.PurchasePrice = value + } + if value, ok := _c.mutation.SoldTime(); ok { + _spec.SetField(item.FieldSoldTime, field.TypeTime, value) + _node.SoldTime = value + } + if value, ok := _c.mutation.SoldTo(); ok { + _spec.SetField(item.FieldSoldTo, field.TypeString, value) + _node.SoldTo = value + } + if value, ok := _c.mutation.SoldPrice(); ok { + _spec.SetField(item.FieldSoldPrice, field.TypeFloat64, value) + _node.SoldPrice = value + } + if value, ok := _c.mutation.SoldNotes(); ok { + _spec.SetField(item.FieldSoldNotes, field.TypeString, value) + _node.SoldNotes = value + } + if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: item.GroupTable, + Columns: []string{item.GroupColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.group_items = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.ParentIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: item.ParentTable, + Columns: []string{item.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.item_children = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.ChildrenIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.ChildrenTable, + Columns: []string{item.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.LabelIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: item.LabelTable, + Columns: item.LabelPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.LocationIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: item.LocationTable, + Columns: []string{item.LocationColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.location_items = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.FieldsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.FieldsTable, + Columns: []string{item.FieldsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.MaintenanceEntriesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.MaintenanceEntriesTable, + Columns: []string{item.MaintenanceEntriesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.AttachmentsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.AttachmentsTable, + Columns: []string{item.AttachmentsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// ItemCreateBulk is the builder for creating many Item entities in bulk. +type ItemCreateBulk struct { + config + err error + builders []*ItemCreate +} + +// Save creates the Item entities in the database. +func (_c *ItemCreateBulk) Save(ctx context.Context) ([]*Item, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*Item, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ItemMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *ItemCreateBulk) SaveX(ctx context.Context) []*Item { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *ItemCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *ItemCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/internal/data/ent/item_delete.go b/backend/internal/data/ent/item_delete.go new file mode 100644 index 00000000..7a01bffe --- /dev/null +++ b/backend/internal/data/ent/item_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" +) + +// ItemDelete is the builder for deleting a Item entity. +type ItemDelete struct { + config + hooks []Hook + mutation *ItemMutation +} + +// Where appends a list predicates to the ItemDelete builder. +func (_d *ItemDelete) Where(ps ...predicate.Item) *ItemDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *ItemDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *ItemDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *ItemDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(item.Table, sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// ItemDeleteOne is the builder for deleting a single Item entity. +type ItemDeleteOne struct { + _d *ItemDelete +} + +// Where appends a list predicates to the ItemDelete builder. +func (_d *ItemDeleteOne) Where(ps ...predicate.Item) *ItemDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *ItemDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{item.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *ItemDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/internal/data/ent/item_query.go b/backend/internal/data/ent/item_query.go new file mode 100644 index 00000000..8cb32410 --- /dev/null +++ b/backend/internal/data/ent/item_query.go @@ -0,0 +1,1168 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/label" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" +) + +// ItemQuery is the builder for querying Item entities. +type ItemQuery struct { + config + ctx *QueryContext + order []item.OrderOption + inters []Interceptor + predicates []predicate.Item + withGroup *GroupQuery + withParent *ItemQuery + withChildren *ItemQuery + withLabel *LabelQuery + withLocation *LocationQuery + withFields *ItemFieldQuery + withMaintenanceEntries *MaintenanceEntryQuery + withAttachments *AttachmentQuery + withFKs bool + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ItemQuery builder. +func (_q *ItemQuery) Where(ps ...predicate.Item) *ItemQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *ItemQuery) Limit(limit int) *ItemQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *ItemQuery) Offset(offset int) *ItemQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *ItemQuery) Unique(unique bool) *ItemQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *ItemQuery) Order(o ...item.OrderOption) *ItemQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryGroup chains the current query on the "group" edge. +func (_q *ItemQuery) QueryGroup() *GroupQuery { + query := (&GroupClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, selector), + sqlgraph.To(group.Table, group.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, item.GroupTable, item.GroupColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryParent chains the current query on the "parent" edge. +func (_q *ItemQuery) QueryParent() *ItemQuery { + query := (&ItemClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, selector), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, item.ParentTable, item.ParentColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryChildren chains the current query on the "children" edge. +func (_q *ItemQuery) QueryChildren() *ItemQuery { + query := (&ItemClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, selector), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, item.ChildrenTable, item.ChildrenColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryLabel chains the current query on the "label" edge. +func (_q *ItemQuery) QueryLabel() *LabelQuery { + query := (&LabelClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, selector), + sqlgraph.To(label.Table, label.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, item.LabelTable, item.LabelPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryLocation chains the current query on the "location" edge. +func (_q *ItemQuery) QueryLocation() *LocationQuery { + query := (&LocationClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, selector), + sqlgraph.To(location.Table, location.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, item.LocationTable, item.LocationColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryFields chains the current query on the "fields" edge. +func (_q *ItemQuery) QueryFields() *ItemFieldQuery { + query := (&ItemFieldClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, selector), + sqlgraph.To(itemfield.Table, itemfield.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, item.FieldsTable, item.FieldsColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryMaintenanceEntries chains the current query on the "maintenance_entries" edge. +func (_q *ItemQuery) QueryMaintenanceEntries() *MaintenanceEntryQuery { + query := (&MaintenanceEntryClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, selector), + sqlgraph.To(maintenanceentry.Table, maintenanceentry.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, item.MaintenanceEntriesTable, item.MaintenanceEntriesColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryAttachments chains the current query on the "attachments" edge. +func (_q *ItemQuery) QueryAttachments() *AttachmentQuery { + query := (&AttachmentClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(item.Table, item.FieldID, selector), + sqlgraph.To(attachment.Table, attachment.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, item.AttachmentsTable, item.AttachmentsColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Item entity from the query. +// Returns a *NotFoundError when no Item was found. +func (_q *ItemQuery) First(ctx context.Context) (*Item, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{item.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *ItemQuery) FirstX(ctx context.Context) *Item { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Item ID from the query. +// Returns a *NotFoundError when no Item ID was found. +func (_q *ItemQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{item.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *ItemQuery) FirstIDX(ctx context.Context) uuid.UUID { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Item entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Item entity is found. +// Returns a *NotFoundError when no Item entities are found. +func (_q *ItemQuery) Only(ctx context.Context) (*Item, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{item.Label} + default: + return nil, &NotSingularError{item.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *ItemQuery) OnlyX(ctx context.Context) *Item { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Item ID in the query. +// Returns a *NotSingularError when more than one Item ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *ItemQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{item.Label} + default: + err = &NotSingularError{item.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *ItemQuery) OnlyIDX(ctx context.Context) uuid.UUID { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Items. +func (_q *ItemQuery) All(ctx context.Context) ([]*Item, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Item, *ItemQuery]() + return withInterceptors[[]*Item](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *ItemQuery) AllX(ctx context.Context) []*Item { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Item IDs. +func (_q *ItemQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(item.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *ItemQuery) IDsX(ctx context.Context) []uuid.UUID { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *ItemQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*ItemQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *ItemQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *ItemQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *ItemQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ItemQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *ItemQuery) Clone() *ItemQuery { + if _q == nil { + return nil + } + return &ItemQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]item.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Item{}, _q.predicates...), + withGroup: _q.withGroup.Clone(), + withParent: _q.withParent.Clone(), + withChildren: _q.withChildren.Clone(), + withLabel: _q.withLabel.Clone(), + withLocation: _q.withLocation.Clone(), + withFields: _q.withFields.Clone(), + withMaintenanceEntries: _q.withMaintenanceEntries.Clone(), + withAttachments: _q.withAttachments.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// WithGroup tells the query-builder to eager-load the nodes that are connected to +// the "group" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ItemQuery) WithGroup(opts ...func(*GroupQuery)) *ItemQuery { + query := (&GroupClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withGroup = query + return _q +} + +// WithParent tells the query-builder to eager-load the nodes that are connected to +// the "parent" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ItemQuery) WithParent(opts ...func(*ItemQuery)) *ItemQuery { + query := (&ItemClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withParent = query + return _q +} + +// WithChildren tells the query-builder to eager-load the nodes that are connected to +// the "children" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ItemQuery) WithChildren(opts ...func(*ItemQuery)) *ItemQuery { + query := (&ItemClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withChildren = query + return _q +} + +// WithLabel tells the query-builder to eager-load the nodes that are connected to +// the "label" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ItemQuery) WithLabel(opts ...func(*LabelQuery)) *ItemQuery { + query := (&LabelClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withLabel = query + return _q +} + +// WithLocation tells the query-builder to eager-load the nodes that are connected to +// the "location" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ItemQuery) WithLocation(opts ...func(*LocationQuery)) *ItemQuery { + query := (&LocationClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withLocation = query + return _q +} + +// WithFields tells the query-builder to eager-load the nodes that are connected to +// the "fields" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ItemQuery) WithFields(opts ...func(*ItemFieldQuery)) *ItemQuery { + query := (&ItemFieldClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withFields = query + return _q +} + +// WithMaintenanceEntries tells the query-builder to eager-load the nodes that are connected to +// the "maintenance_entries" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ItemQuery) WithMaintenanceEntries(opts ...func(*MaintenanceEntryQuery)) *ItemQuery { + query := (&MaintenanceEntryClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withMaintenanceEntries = query + return _q +} + +// WithAttachments tells the query-builder to eager-load the nodes that are connected to +// the "attachments" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ItemQuery) WithAttachments(opts ...func(*AttachmentQuery)) *ItemQuery { + query := (&AttachmentClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withAttachments = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Item.Query(). +// GroupBy(item.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *ItemQuery) GroupBy(field string, fields ...string) *ItemGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &ItemGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = item.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.Item.Query(). +// Select(item.FieldCreatedAt). +// Scan(ctx, &v) +func (_q *ItemQuery) Select(fields ...string) *ItemSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &ItemSelect{ItemQuery: _q} + sbuild.label = item.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ItemSelect configured with the given aggregations. +func (_q *ItemQuery) Aggregate(fns ...AggregateFunc) *ItemSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *ItemQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !item.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *ItemQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Item, error) { + var ( + nodes = []*Item{} + withFKs = _q.withFKs + _spec = _q.querySpec() + loadedTypes = [8]bool{ + _q.withGroup != nil, + _q.withParent != nil, + _q.withChildren != nil, + _q.withLabel != nil, + _q.withLocation != nil, + _q.withFields != nil, + _q.withMaintenanceEntries != nil, + _q.withAttachments != nil, + } + ) + if _q.withGroup != nil || _q.withParent != nil || _q.withLocation != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, item.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Item).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Item{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withGroup; query != nil { + if err := _q.loadGroup(ctx, query, nodes, nil, + func(n *Item, e *Group) { n.Edges.Group = e }); err != nil { + return nil, err + } + } + if query := _q.withParent; query != nil { + if err := _q.loadParent(ctx, query, nodes, nil, + func(n *Item, e *Item) { n.Edges.Parent = e }); err != nil { + return nil, err + } + } + if query := _q.withChildren; query != nil { + if err := _q.loadChildren(ctx, query, nodes, + func(n *Item) { n.Edges.Children = []*Item{} }, + func(n *Item, e *Item) { n.Edges.Children = append(n.Edges.Children, e) }); err != nil { + return nil, err + } + } + if query := _q.withLabel; query != nil { + if err := _q.loadLabel(ctx, query, nodes, + func(n *Item) { n.Edges.Label = []*Label{} }, + func(n *Item, e *Label) { n.Edges.Label = append(n.Edges.Label, e) }); err != nil { + return nil, err + } + } + if query := _q.withLocation; query != nil { + if err := _q.loadLocation(ctx, query, nodes, nil, + func(n *Item, e *Location) { n.Edges.Location = e }); err != nil { + return nil, err + } + } + if query := _q.withFields; query != nil { + if err := _q.loadFields(ctx, query, nodes, + func(n *Item) { n.Edges.Fields = []*ItemField{} }, + func(n *Item, e *ItemField) { n.Edges.Fields = append(n.Edges.Fields, e) }); err != nil { + return nil, err + } + } + if query := _q.withMaintenanceEntries; query != nil { + if err := _q.loadMaintenanceEntries(ctx, query, nodes, + func(n *Item) { n.Edges.MaintenanceEntries = []*MaintenanceEntry{} }, + func(n *Item, e *MaintenanceEntry) { n.Edges.MaintenanceEntries = append(n.Edges.MaintenanceEntries, e) }); err != nil { + return nil, err + } + } + if query := _q.withAttachments; query != nil { + if err := _q.loadAttachments(ctx, query, nodes, + func(n *Item) { n.Edges.Attachments = []*Attachment{} }, + func(n *Item, e *Attachment) { n.Edges.Attachments = append(n.Edges.Attachments, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *ItemQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*Item, init func(*Item), assign func(*Item, *Group)) error { + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*Item) + for i := range nodes { + if nodes[i].group_items == nil { + continue + } + fk := *nodes[i].group_items + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(group.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "group_items" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *ItemQuery) loadParent(ctx context.Context, query *ItemQuery, nodes []*Item, init func(*Item), assign func(*Item, *Item)) error { + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*Item) + for i := range nodes { + if nodes[i].item_children == nil { + continue + } + fk := *nodes[i].item_children + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(item.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "item_children" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *ItemQuery) loadChildren(ctx context.Context, query *ItemQuery, nodes []*Item, init func(*Item), assign func(*Item, *Item)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uuid.UUID]*Item) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.Item(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(item.ChildrenColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.item_children + if fk == nil { + return fmt.Errorf(`foreign-key "item_children" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "item_children" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} +func (_q *ItemQuery) loadLabel(ctx context.Context, query *LabelQuery, nodes []*Item, init func(*Item), assign func(*Item, *Label)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[uuid.UUID]*Item) + nids := make(map[uuid.UUID]map[*Item]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(item.LabelTable) + s.Join(joinT).On(s.C(label.FieldID), joinT.C(item.LabelPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(item.LabelPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(item.LabelPrimaryKey[1])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(uuid.UUID)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := *values[0].(*uuid.UUID) + inValue := *values[1].(*uuid.UUID) + if nids[inValue] == nil { + nids[inValue] = map[*Item]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Label](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "label" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (_q *ItemQuery) loadLocation(ctx context.Context, query *LocationQuery, nodes []*Item, init func(*Item), assign func(*Item, *Location)) error { + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*Item) + for i := range nodes { + if nodes[i].location_items == nil { + continue + } + fk := *nodes[i].location_items + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(location.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "location_items" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *ItemQuery) loadFields(ctx context.Context, query *ItemFieldQuery, nodes []*Item, init func(*Item), assign func(*Item, *ItemField)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uuid.UUID]*Item) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.ItemField(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(item.FieldsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.item_fields + if fk == nil { + return fmt.Errorf(`foreign-key "item_fields" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "item_fields" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} +func (_q *ItemQuery) loadMaintenanceEntries(ctx context.Context, query *MaintenanceEntryQuery, nodes []*Item, init func(*Item), assign func(*Item, *MaintenanceEntry)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uuid.UUID]*Item) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(maintenanceentry.FieldItemID) + } + query.Where(predicate.MaintenanceEntry(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(item.MaintenanceEntriesColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.ItemID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "item_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} +func (_q *ItemQuery) loadAttachments(ctx context.Context, query *AttachmentQuery, nodes []*Item, init func(*Item), assign func(*Item, *Attachment)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uuid.UUID]*Item) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.Attachment(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(item.AttachmentsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.item_attachments + if fk == nil { + return fmt.Errorf(`foreign-key "item_attachments" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "item_attachments" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (_q *ItemQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *ItemQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(item.Table, item.Columns, sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, item.FieldID) + for i := range fields { + if fields[i] != item.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *ItemQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(item.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = item.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ItemGroupBy is the group-by builder for Item entities. +type ItemGroupBy struct { + selector + build *ItemQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *ItemGroupBy) Aggregate(fns ...AggregateFunc) *ItemGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *ItemGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ItemQuery, *ItemGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *ItemGroupBy) sqlScan(ctx context.Context, root *ItemQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ItemSelect is the builder for selecting fields of Item entities. +type ItemSelect struct { + *ItemQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *ItemSelect) Aggregate(fns ...AggregateFunc) *ItemSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *ItemSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ItemQuery, *ItemSelect](ctx, _s.ItemQuery, _s, _s.inters, v) +} + +func (_s *ItemSelect) sqlScan(ctx context.Context, root *ItemQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/backend/internal/data/ent/item_update.go b/backend/internal/data/ent/item_update.go new file mode 100644 index 00000000..1ff6c01b --- /dev/null +++ b/backend/internal/data/ent/item_update.go @@ -0,0 +1,2511 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/label" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" +) + +// ItemUpdate is the builder for updating Item entities. +type ItemUpdate struct { + config + hooks []Hook + mutation *ItemMutation +} + +// Where appends a list predicates to the ItemUpdate builder. +func (_u *ItemUpdate) Where(ps ...predicate.Item) *ItemUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *ItemUpdate) SetUpdatedAt(v time.Time) *ItemUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetName sets the "name" field. +func (_u *ItemUpdate) SetName(v string) *ItemUpdate { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *ItemUpdate) SetNillableName(v *string) *ItemUpdate { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetDescription sets the "description" field. +func (_u *ItemUpdate) SetDescription(v string) *ItemUpdate { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *ItemUpdate) SetNillableDescription(v *string) *ItemUpdate { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// ClearDescription clears the value of the "description" field. +func (_u *ItemUpdate) ClearDescription() *ItemUpdate { + _u.mutation.ClearDescription() + return _u +} + +// SetImportRef sets the "import_ref" field. +func (_u *ItemUpdate) SetImportRef(v string) *ItemUpdate { + _u.mutation.SetImportRef(v) + return _u +} + +// SetNillableImportRef sets the "import_ref" field if the given value is not nil. +func (_u *ItemUpdate) SetNillableImportRef(v *string) *ItemUpdate { + if v != nil { + _u.SetImportRef(*v) + } + return _u +} + +// ClearImportRef clears the value of the "import_ref" field. +func (_u *ItemUpdate) ClearImportRef() *ItemUpdate { + _u.mutation.ClearImportRef() + return _u +} + +// SetNotes sets the "notes" field. +func (_u *ItemUpdate) SetNotes(v string) *ItemUpdate { + _u.mutation.SetNotes(v) + return _u +} + +// SetNillableNotes sets the "notes" field if the given value is not nil. +func (_u *ItemUpdate) SetNillableNotes(v *string) *ItemUpdate { + if v != nil { + _u.SetNotes(*v) + } + return _u +} + +// ClearNotes clears the value of the "notes" field. +func (_u *ItemUpdate) ClearNotes() *ItemUpdate { + _u.mutation.ClearNotes() + return _u +} + +// SetQuantity sets the "quantity" field. +func (_u *ItemUpdate) SetQuantity(v int) *ItemUpdate { + _u.mutation.ResetQuantity() + _u.mutation.SetQuantity(v) + return _u +} + +// SetNillableQuantity sets the "quantity" field if the given value is not nil. +func (_u *ItemUpdate) SetNillableQuantity(v *int) *ItemUpdate { + if v != nil { + _u.SetQuantity(*v) + } + return _u +} + +// AddQuantity adds value to the "quantity" field. +func (_u *ItemUpdate) AddQuantity(v int) *ItemUpdate { + _u.mutation.AddQuantity(v) + return _u +} + +// SetInsured sets the "insured" field. +func (_u *ItemUpdate) SetInsured(v bool) *ItemUpdate { + _u.mutation.SetInsured(v) + return _u +} + +// SetNillableInsured sets the "insured" field if the given value is not nil. +func (_u *ItemUpdate) SetNillableInsured(v *bool) *ItemUpdate { + if v != nil { + _u.SetInsured(*v) + } + return _u +} + +// SetArchived sets the "archived" field. +func (_u *ItemUpdate) SetArchived(v bool) *ItemUpdate { + _u.mutation.SetArchived(v) + return _u +} + +// SetNillableArchived sets the "archived" field if the given value is not nil. +func (_u *ItemUpdate) SetNillableArchived(v *bool) *ItemUpdate { + if v != nil { + _u.SetArchived(*v) + } + return _u +} + +// SetAssetID sets the "asset_id" field. +func (_u *ItemUpdate) SetAssetID(v int) *ItemUpdate { + _u.mutation.ResetAssetID() + _u.mutation.SetAssetID(v) + return _u +} + +// SetNillableAssetID sets the "asset_id" field if the given value is not nil. +func (_u *ItemUpdate) SetNillableAssetID(v *int) *ItemUpdate { + if v != nil { + _u.SetAssetID(*v) + } + return _u +} + +// AddAssetID adds value to the "asset_id" field. +func (_u *ItemUpdate) AddAssetID(v int) *ItemUpdate { + _u.mutation.AddAssetID(v) + return _u +} + +// SetSyncChildItemsLocations sets the "sync_child_items_locations" field. +func (_u *ItemUpdate) SetSyncChildItemsLocations(v bool) *ItemUpdate { + _u.mutation.SetSyncChildItemsLocations(v) + return _u +} + +// SetNillableSyncChildItemsLocations sets the "sync_child_items_locations" field if the given value is not nil. +func (_u *ItemUpdate) SetNillableSyncChildItemsLocations(v *bool) *ItemUpdate { + if v != nil { + _u.SetSyncChildItemsLocations(*v) + } + return _u +} + +// SetSerialNumber sets the "serial_number" field. +func (_u *ItemUpdate) SetSerialNumber(v string) *ItemUpdate { + _u.mutation.SetSerialNumber(v) + return _u +} + +// SetNillableSerialNumber sets the "serial_number" field if the given value is not nil. +func (_u *ItemUpdate) SetNillableSerialNumber(v *string) *ItemUpdate { + if v != nil { + _u.SetSerialNumber(*v) + } + return _u +} + +// ClearSerialNumber clears the value of the "serial_number" field. +func (_u *ItemUpdate) ClearSerialNumber() *ItemUpdate { + _u.mutation.ClearSerialNumber() + return _u +} + +// SetModelNumber sets the "model_number" field. +func (_u *ItemUpdate) SetModelNumber(v string) *ItemUpdate { + _u.mutation.SetModelNumber(v) + return _u +} + +// SetNillableModelNumber sets the "model_number" field if the given value is not nil. +func (_u *ItemUpdate) SetNillableModelNumber(v *string) *ItemUpdate { + if v != nil { + _u.SetModelNumber(*v) + } + return _u +} + +// ClearModelNumber clears the value of the "model_number" field. +func (_u *ItemUpdate) ClearModelNumber() *ItemUpdate { + _u.mutation.ClearModelNumber() + return _u +} + +// SetManufacturer sets the "manufacturer" field. +func (_u *ItemUpdate) SetManufacturer(v string) *ItemUpdate { + _u.mutation.SetManufacturer(v) + return _u +} + +// SetNillableManufacturer sets the "manufacturer" field if the given value is not nil. +func (_u *ItemUpdate) SetNillableManufacturer(v *string) *ItemUpdate { + if v != nil { + _u.SetManufacturer(*v) + } + return _u +} + +// ClearManufacturer clears the value of the "manufacturer" field. +func (_u *ItemUpdate) ClearManufacturer() *ItemUpdate { + _u.mutation.ClearManufacturer() + return _u +} + +// SetLifetimeWarranty sets the "lifetime_warranty" field. +func (_u *ItemUpdate) SetLifetimeWarranty(v bool) *ItemUpdate { + _u.mutation.SetLifetimeWarranty(v) + return _u +} + +// SetNillableLifetimeWarranty sets the "lifetime_warranty" field if the given value is not nil. +func (_u *ItemUpdate) SetNillableLifetimeWarranty(v *bool) *ItemUpdate { + if v != nil { + _u.SetLifetimeWarranty(*v) + } + return _u +} + +// SetWarrantyExpires sets the "warranty_expires" field. +func (_u *ItemUpdate) SetWarrantyExpires(v time.Time) *ItemUpdate { + _u.mutation.SetWarrantyExpires(v) + return _u +} + +// SetNillableWarrantyExpires sets the "warranty_expires" field if the given value is not nil. +func (_u *ItemUpdate) SetNillableWarrantyExpires(v *time.Time) *ItemUpdate { + if v != nil { + _u.SetWarrantyExpires(*v) + } + return _u +} + +// ClearWarrantyExpires clears the value of the "warranty_expires" field. +func (_u *ItemUpdate) ClearWarrantyExpires() *ItemUpdate { + _u.mutation.ClearWarrantyExpires() + return _u +} + +// SetWarrantyDetails sets the "warranty_details" field. +func (_u *ItemUpdate) SetWarrantyDetails(v string) *ItemUpdate { + _u.mutation.SetWarrantyDetails(v) + return _u +} + +// SetNillableWarrantyDetails sets the "warranty_details" field if the given value is not nil. +func (_u *ItemUpdate) SetNillableWarrantyDetails(v *string) *ItemUpdate { + if v != nil { + _u.SetWarrantyDetails(*v) + } + return _u +} + +// ClearWarrantyDetails clears the value of the "warranty_details" field. +func (_u *ItemUpdate) ClearWarrantyDetails() *ItemUpdate { + _u.mutation.ClearWarrantyDetails() + return _u +} + +// SetPurchaseTime sets the "purchase_time" field. +func (_u *ItemUpdate) SetPurchaseTime(v time.Time) *ItemUpdate { + _u.mutation.SetPurchaseTime(v) + return _u +} + +// SetNillablePurchaseTime sets the "purchase_time" field if the given value is not nil. +func (_u *ItemUpdate) SetNillablePurchaseTime(v *time.Time) *ItemUpdate { + if v != nil { + _u.SetPurchaseTime(*v) + } + return _u +} + +// ClearPurchaseTime clears the value of the "purchase_time" field. +func (_u *ItemUpdate) ClearPurchaseTime() *ItemUpdate { + _u.mutation.ClearPurchaseTime() + return _u +} + +// SetPurchaseFrom sets the "purchase_from" field. +func (_u *ItemUpdate) SetPurchaseFrom(v string) *ItemUpdate { + _u.mutation.SetPurchaseFrom(v) + return _u +} + +// SetNillablePurchaseFrom sets the "purchase_from" field if the given value is not nil. +func (_u *ItemUpdate) SetNillablePurchaseFrom(v *string) *ItemUpdate { + if v != nil { + _u.SetPurchaseFrom(*v) + } + return _u +} + +// ClearPurchaseFrom clears the value of the "purchase_from" field. +func (_u *ItemUpdate) ClearPurchaseFrom() *ItemUpdate { + _u.mutation.ClearPurchaseFrom() + return _u +} + +// SetPurchasePrice sets the "purchase_price" field. +func (_u *ItemUpdate) SetPurchasePrice(v float64) *ItemUpdate { + _u.mutation.ResetPurchasePrice() + _u.mutation.SetPurchasePrice(v) + return _u +} + +// SetNillablePurchasePrice sets the "purchase_price" field if the given value is not nil. +func (_u *ItemUpdate) SetNillablePurchasePrice(v *float64) *ItemUpdate { + if v != nil { + _u.SetPurchasePrice(*v) + } + return _u +} + +// AddPurchasePrice adds value to the "purchase_price" field. +func (_u *ItemUpdate) AddPurchasePrice(v float64) *ItemUpdate { + _u.mutation.AddPurchasePrice(v) + return _u +} + +// SetSoldTime sets the "sold_time" field. +func (_u *ItemUpdate) SetSoldTime(v time.Time) *ItemUpdate { + _u.mutation.SetSoldTime(v) + return _u +} + +// SetNillableSoldTime sets the "sold_time" field if the given value is not nil. +func (_u *ItemUpdate) SetNillableSoldTime(v *time.Time) *ItemUpdate { + if v != nil { + _u.SetSoldTime(*v) + } + return _u +} + +// ClearSoldTime clears the value of the "sold_time" field. +func (_u *ItemUpdate) ClearSoldTime() *ItemUpdate { + _u.mutation.ClearSoldTime() + return _u +} + +// SetSoldTo sets the "sold_to" field. +func (_u *ItemUpdate) SetSoldTo(v string) *ItemUpdate { + _u.mutation.SetSoldTo(v) + return _u +} + +// SetNillableSoldTo sets the "sold_to" field if the given value is not nil. +func (_u *ItemUpdate) SetNillableSoldTo(v *string) *ItemUpdate { + if v != nil { + _u.SetSoldTo(*v) + } + return _u +} + +// ClearSoldTo clears the value of the "sold_to" field. +func (_u *ItemUpdate) ClearSoldTo() *ItemUpdate { + _u.mutation.ClearSoldTo() + return _u +} + +// SetSoldPrice sets the "sold_price" field. +func (_u *ItemUpdate) SetSoldPrice(v float64) *ItemUpdate { + _u.mutation.ResetSoldPrice() + _u.mutation.SetSoldPrice(v) + return _u +} + +// SetNillableSoldPrice sets the "sold_price" field if the given value is not nil. +func (_u *ItemUpdate) SetNillableSoldPrice(v *float64) *ItemUpdate { + if v != nil { + _u.SetSoldPrice(*v) + } + return _u +} + +// AddSoldPrice adds value to the "sold_price" field. +func (_u *ItemUpdate) AddSoldPrice(v float64) *ItemUpdate { + _u.mutation.AddSoldPrice(v) + return _u +} + +// SetSoldNotes sets the "sold_notes" field. +func (_u *ItemUpdate) SetSoldNotes(v string) *ItemUpdate { + _u.mutation.SetSoldNotes(v) + return _u +} + +// SetNillableSoldNotes sets the "sold_notes" field if the given value is not nil. +func (_u *ItemUpdate) SetNillableSoldNotes(v *string) *ItemUpdate { + if v != nil { + _u.SetSoldNotes(*v) + } + return _u +} + +// ClearSoldNotes clears the value of the "sold_notes" field. +func (_u *ItemUpdate) ClearSoldNotes() *ItemUpdate { + _u.mutation.ClearSoldNotes() + return _u +} + +// SetGroupID sets the "group" edge to the Group entity by ID. +func (_u *ItemUpdate) SetGroupID(id uuid.UUID) *ItemUpdate { + _u.mutation.SetGroupID(id) + return _u +} + +// SetGroup sets the "group" edge to the Group entity. +func (_u *ItemUpdate) SetGroup(v *Group) *ItemUpdate { + return _u.SetGroupID(v.ID) +} + +// SetParentID sets the "parent" edge to the Item entity by ID. +func (_u *ItemUpdate) SetParentID(id uuid.UUID) *ItemUpdate { + _u.mutation.SetParentID(id) + return _u +} + +// SetNillableParentID sets the "parent" edge to the Item entity by ID if the given value is not nil. +func (_u *ItemUpdate) SetNillableParentID(id *uuid.UUID) *ItemUpdate { + if id != nil { + _u = _u.SetParentID(*id) + } + return _u +} + +// SetParent sets the "parent" edge to the Item entity. +func (_u *ItemUpdate) SetParent(v *Item) *ItemUpdate { + return _u.SetParentID(v.ID) +} + +// AddChildIDs adds the "children" edge to the Item entity by IDs. +func (_u *ItemUpdate) AddChildIDs(ids ...uuid.UUID) *ItemUpdate { + _u.mutation.AddChildIDs(ids...) + return _u +} + +// AddChildren adds the "children" edges to the Item entity. +func (_u *ItemUpdate) AddChildren(v ...*Item) *ItemUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddChildIDs(ids...) +} + +// AddLabelIDs adds the "label" edge to the Label entity by IDs. +func (_u *ItemUpdate) AddLabelIDs(ids ...uuid.UUID) *ItemUpdate { + _u.mutation.AddLabelIDs(ids...) + return _u +} + +// AddLabel adds the "label" edges to the Label entity. +func (_u *ItemUpdate) AddLabel(v ...*Label) *ItemUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddLabelIDs(ids...) +} + +// SetLocationID sets the "location" edge to the Location entity by ID. +func (_u *ItemUpdate) SetLocationID(id uuid.UUID) *ItemUpdate { + _u.mutation.SetLocationID(id) + return _u +} + +// SetNillableLocationID sets the "location" edge to the Location entity by ID if the given value is not nil. +func (_u *ItemUpdate) SetNillableLocationID(id *uuid.UUID) *ItemUpdate { + if id != nil { + _u = _u.SetLocationID(*id) + } + return _u +} + +// SetLocation sets the "location" edge to the Location entity. +func (_u *ItemUpdate) SetLocation(v *Location) *ItemUpdate { + return _u.SetLocationID(v.ID) +} + +// AddFieldIDs adds the "fields" edge to the ItemField entity by IDs. +func (_u *ItemUpdate) AddFieldIDs(ids ...uuid.UUID) *ItemUpdate { + _u.mutation.AddFieldIDs(ids...) + return _u +} + +// AddFields adds the "fields" edges to the ItemField entity. +func (_u *ItemUpdate) AddFields(v ...*ItemField) *ItemUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddFieldIDs(ids...) +} + +// AddMaintenanceEntryIDs adds the "maintenance_entries" edge to the MaintenanceEntry entity by IDs. +func (_u *ItemUpdate) AddMaintenanceEntryIDs(ids ...uuid.UUID) *ItemUpdate { + _u.mutation.AddMaintenanceEntryIDs(ids...) + return _u +} + +// AddMaintenanceEntries adds the "maintenance_entries" edges to the MaintenanceEntry entity. +func (_u *ItemUpdate) AddMaintenanceEntries(v ...*MaintenanceEntry) *ItemUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddMaintenanceEntryIDs(ids...) +} + +// AddAttachmentIDs adds the "attachments" edge to the Attachment entity by IDs. +func (_u *ItemUpdate) AddAttachmentIDs(ids ...uuid.UUID) *ItemUpdate { + _u.mutation.AddAttachmentIDs(ids...) + return _u +} + +// AddAttachments adds the "attachments" edges to the Attachment entity. +func (_u *ItemUpdate) AddAttachments(v ...*Attachment) *ItemUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddAttachmentIDs(ids...) +} + +// Mutation returns the ItemMutation object of the builder. +func (_u *ItemUpdate) Mutation() *ItemMutation { + return _u.mutation +} + +// ClearGroup clears the "group" edge to the Group entity. +func (_u *ItemUpdate) ClearGroup() *ItemUpdate { + _u.mutation.ClearGroup() + return _u +} + +// ClearParent clears the "parent" edge to the Item entity. +func (_u *ItemUpdate) ClearParent() *ItemUpdate { + _u.mutation.ClearParent() + return _u +} + +// ClearChildren clears all "children" edges to the Item entity. +func (_u *ItemUpdate) ClearChildren() *ItemUpdate { + _u.mutation.ClearChildren() + return _u +} + +// RemoveChildIDs removes the "children" edge to Item entities by IDs. +func (_u *ItemUpdate) RemoveChildIDs(ids ...uuid.UUID) *ItemUpdate { + _u.mutation.RemoveChildIDs(ids...) + return _u +} + +// RemoveChildren removes "children" edges to Item entities. +func (_u *ItemUpdate) RemoveChildren(v ...*Item) *ItemUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveChildIDs(ids...) +} + +// ClearLabel clears all "label" edges to the Label entity. +func (_u *ItemUpdate) ClearLabel() *ItemUpdate { + _u.mutation.ClearLabel() + return _u +} + +// RemoveLabelIDs removes the "label" edge to Label entities by IDs. +func (_u *ItemUpdate) RemoveLabelIDs(ids ...uuid.UUID) *ItemUpdate { + _u.mutation.RemoveLabelIDs(ids...) + return _u +} + +// RemoveLabel removes "label" edges to Label entities. +func (_u *ItemUpdate) RemoveLabel(v ...*Label) *ItemUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveLabelIDs(ids...) +} + +// ClearLocation clears the "location" edge to the Location entity. +func (_u *ItemUpdate) ClearLocation() *ItemUpdate { + _u.mutation.ClearLocation() + return _u +} + +// ClearFields clears all "fields" edges to the ItemField entity. +func (_u *ItemUpdate) ClearFields() *ItemUpdate { + _u.mutation.ClearFields() + return _u +} + +// RemoveFieldIDs removes the "fields" edge to ItemField entities by IDs. +func (_u *ItemUpdate) RemoveFieldIDs(ids ...uuid.UUID) *ItemUpdate { + _u.mutation.RemoveFieldIDs(ids...) + return _u +} + +// RemoveFields removes "fields" edges to ItemField entities. +func (_u *ItemUpdate) RemoveFields(v ...*ItemField) *ItemUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveFieldIDs(ids...) +} + +// ClearMaintenanceEntries clears all "maintenance_entries" edges to the MaintenanceEntry entity. +func (_u *ItemUpdate) ClearMaintenanceEntries() *ItemUpdate { + _u.mutation.ClearMaintenanceEntries() + return _u +} + +// RemoveMaintenanceEntryIDs removes the "maintenance_entries" edge to MaintenanceEntry entities by IDs. +func (_u *ItemUpdate) RemoveMaintenanceEntryIDs(ids ...uuid.UUID) *ItemUpdate { + _u.mutation.RemoveMaintenanceEntryIDs(ids...) + return _u +} + +// RemoveMaintenanceEntries removes "maintenance_entries" edges to MaintenanceEntry entities. +func (_u *ItemUpdate) RemoveMaintenanceEntries(v ...*MaintenanceEntry) *ItemUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveMaintenanceEntryIDs(ids...) +} + +// ClearAttachments clears all "attachments" edges to the Attachment entity. +func (_u *ItemUpdate) ClearAttachments() *ItemUpdate { + _u.mutation.ClearAttachments() + return _u +} + +// RemoveAttachmentIDs removes the "attachments" edge to Attachment entities by IDs. +func (_u *ItemUpdate) RemoveAttachmentIDs(ids ...uuid.UUID) *ItemUpdate { + _u.mutation.RemoveAttachmentIDs(ids...) + return _u +} + +// RemoveAttachments removes "attachments" edges to Attachment entities. +func (_u *ItemUpdate) RemoveAttachments(v ...*Attachment) *ItemUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveAttachmentIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *ItemUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *ItemUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *ItemUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *ItemUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *ItemUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := item.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *ItemUpdate) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := item.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Item.name": %w`, err)} + } + } + if v, ok := _u.mutation.Description(); ok { + if err := item.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Item.description": %w`, err)} + } + } + if v, ok := _u.mutation.ImportRef(); ok { + if err := item.ImportRefValidator(v); err != nil { + return &ValidationError{Name: "import_ref", err: fmt.Errorf(`ent: validator failed for field "Item.import_ref": %w`, err)} + } + } + if v, ok := _u.mutation.Notes(); ok { + if err := item.NotesValidator(v); err != nil { + return &ValidationError{Name: "notes", err: fmt.Errorf(`ent: validator failed for field "Item.notes": %w`, err)} + } + } + if v, ok := _u.mutation.SerialNumber(); ok { + if err := item.SerialNumberValidator(v); err != nil { + return &ValidationError{Name: "serial_number", err: fmt.Errorf(`ent: validator failed for field "Item.serial_number": %w`, err)} + } + } + if v, ok := _u.mutation.ModelNumber(); ok { + if err := item.ModelNumberValidator(v); err != nil { + return &ValidationError{Name: "model_number", err: fmt.Errorf(`ent: validator failed for field "Item.model_number": %w`, err)} + } + } + if v, ok := _u.mutation.Manufacturer(); ok { + if err := item.ManufacturerValidator(v); err != nil { + return &ValidationError{Name: "manufacturer", err: fmt.Errorf(`ent: validator failed for field "Item.manufacturer": %w`, err)} + } + } + if v, ok := _u.mutation.WarrantyDetails(); ok { + if err := item.WarrantyDetailsValidator(v); err != nil { + return &ValidationError{Name: "warranty_details", err: fmt.Errorf(`ent: validator failed for field "Item.warranty_details": %w`, err)} + } + } + if v, ok := _u.mutation.SoldNotes(); ok { + if err := item.SoldNotesValidator(v); err != nil { + return &ValidationError{Name: "sold_notes", err: fmt.Errorf(`ent: validator failed for field "Item.sold_notes": %w`, err)} + } + } + if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "Item.group"`) + } + return nil +} + +func (_u *ItemUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(item.Table, item.Columns, sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(item.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(item.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(item.FieldDescription, field.TypeString, value) + } + if _u.mutation.DescriptionCleared() { + _spec.ClearField(item.FieldDescription, field.TypeString) + } + if value, ok := _u.mutation.ImportRef(); ok { + _spec.SetField(item.FieldImportRef, field.TypeString, value) + } + if _u.mutation.ImportRefCleared() { + _spec.ClearField(item.FieldImportRef, field.TypeString) + } + if value, ok := _u.mutation.Notes(); ok { + _spec.SetField(item.FieldNotes, field.TypeString, value) + } + if _u.mutation.NotesCleared() { + _spec.ClearField(item.FieldNotes, field.TypeString) + } + if value, ok := _u.mutation.Quantity(); ok { + _spec.SetField(item.FieldQuantity, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedQuantity(); ok { + _spec.AddField(item.FieldQuantity, field.TypeInt, value) + } + if value, ok := _u.mutation.Insured(); ok { + _spec.SetField(item.FieldInsured, field.TypeBool, value) + } + if value, ok := _u.mutation.Archived(); ok { + _spec.SetField(item.FieldArchived, field.TypeBool, value) + } + if value, ok := _u.mutation.AssetID(); ok { + _spec.SetField(item.FieldAssetID, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedAssetID(); ok { + _spec.AddField(item.FieldAssetID, field.TypeInt, value) + } + if value, ok := _u.mutation.SyncChildItemsLocations(); ok { + _spec.SetField(item.FieldSyncChildItemsLocations, field.TypeBool, value) + } + if value, ok := _u.mutation.SerialNumber(); ok { + _spec.SetField(item.FieldSerialNumber, field.TypeString, value) + } + if _u.mutation.SerialNumberCleared() { + _spec.ClearField(item.FieldSerialNumber, field.TypeString) + } + if value, ok := _u.mutation.ModelNumber(); ok { + _spec.SetField(item.FieldModelNumber, field.TypeString, value) + } + if _u.mutation.ModelNumberCleared() { + _spec.ClearField(item.FieldModelNumber, field.TypeString) + } + if value, ok := _u.mutation.Manufacturer(); ok { + _spec.SetField(item.FieldManufacturer, field.TypeString, value) + } + if _u.mutation.ManufacturerCleared() { + _spec.ClearField(item.FieldManufacturer, field.TypeString) + } + if value, ok := _u.mutation.LifetimeWarranty(); ok { + _spec.SetField(item.FieldLifetimeWarranty, field.TypeBool, value) + } + if value, ok := _u.mutation.WarrantyExpires(); ok { + _spec.SetField(item.FieldWarrantyExpires, field.TypeTime, value) + } + if _u.mutation.WarrantyExpiresCleared() { + _spec.ClearField(item.FieldWarrantyExpires, field.TypeTime) + } + if value, ok := _u.mutation.WarrantyDetails(); ok { + _spec.SetField(item.FieldWarrantyDetails, field.TypeString, value) + } + if _u.mutation.WarrantyDetailsCleared() { + _spec.ClearField(item.FieldWarrantyDetails, field.TypeString) + } + if value, ok := _u.mutation.PurchaseTime(); ok { + _spec.SetField(item.FieldPurchaseTime, field.TypeTime, value) + } + if _u.mutation.PurchaseTimeCleared() { + _spec.ClearField(item.FieldPurchaseTime, field.TypeTime) + } + if value, ok := _u.mutation.PurchaseFrom(); ok { + _spec.SetField(item.FieldPurchaseFrom, field.TypeString, value) + } + if _u.mutation.PurchaseFromCleared() { + _spec.ClearField(item.FieldPurchaseFrom, field.TypeString) + } + if value, ok := _u.mutation.PurchasePrice(); ok { + _spec.SetField(item.FieldPurchasePrice, field.TypeFloat64, value) + } + if value, ok := _u.mutation.AddedPurchasePrice(); ok { + _spec.AddField(item.FieldPurchasePrice, field.TypeFloat64, value) + } + if value, ok := _u.mutation.SoldTime(); ok { + _spec.SetField(item.FieldSoldTime, field.TypeTime, value) + } + if _u.mutation.SoldTimeCleared() { + _spec.ClearField(item.FieldSoldTime, field.TypeTime) + } + if value, ok := _u.mutation.SoldTo(); ok { + _spec.SetField(item.FieldSoldTo, field.TypeString, value) + } + if _u.mutation.SoldToCleared() { + _spec.ClearField(item.FieldSoldTo, field.TypeString) + } + if value, ok := _u.mutation.SoldPrice(); ok { + _spec.SetField(item.FieldSoldPrice, field.TypeFloat64, value) + } + if value, ok := _u.mutation.AddedSoldPrice(); ok { + _spec.AddField(item.FieldSoldPrice, field.TypeFloat64, value) + } + if value, ok := _u.mutation.SoldNotes(); ok { + _spec.SetField(item.FieldSoldNotes, field.TypeString, value) + } + if _u.mutation.SoldNotesCleared() { + _spec.ClearField(item.FieldSoldNotes, field.TypeString) + } + if _u.mutation.GroupCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: item.GroupTable, + Columns: []string{item.GroupColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: item.GroupTable, + Columns: []string{item.GroupColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ParentCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: item.ParentTable, + Columns: []string{item.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: item.ParentTable, + Columns: []string{item.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.ChildrenTable, + Columns: []string{item.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.ChildrenTable, + Columns: []string{item.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.ChildrenTable, + Columns: []string{item.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.LabelCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: item.LabelTable, + Columns: item.LabelPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedLabelIDs(); len(nodes) > 0 && !_u.mutation.LabelCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: item.LabelTable, + Columns: item.LabelPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.LabelIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: item.LabelTable, + Columns: item.LabelPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.LocationCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: item.LocationTable, + Columns: []string{item.LocationColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.LocationIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: item.LocationTable, + Columns: []string{item.LocationColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.FieldsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.FieldsTable, + Columns: []string{item.FieldsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedFieldsIDs(); len(nodes) > 0 && !_u.mutation.FieldsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.FieldsTable, + Columns: []string{item.FieldsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.FieldsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.FieldsTable, + Columns: []string{item.FieldsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.MaintenanceEntriesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.MaintenanceEntriesTable, + Columns: []string{item.MaintenanceEntriesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedMaintenanceEntriesIDs(); len(nodes) > 0 && !_u.mutation.MaintenanceEntriesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.MaintenanceEntriesTable, + Columns: []string{item.MaintenanceEntriesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.MaintenanceEntriesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.MaintenanceEntriesTable, + Columns: []string{item.MaintenanceEntriesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.AttachmentsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.AttachmentsTable, + Columns: []string{item.AttachmentsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedAttachmentsIDs(); len(nodes) > 0 && !_u.mutation.AttachmentsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.AttachmentsTable, + Columns: []string{item.AttachmentsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.AttachmentsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.AttachmentsTable, + Columns: []string{item.AttachmentsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{item.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// ItemUpdateOne is the builder for updating a single Item entity. +type ItemUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ItemMutation +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *ItemUpdateOne) SetUpdatedAt(v time.Time) *ItemUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetName sets the "name" field. +func (_u *ItemUpdateOne) SetName(v string) *ItemUpdateOne { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillableName(v *string) *ItemUpdateOne { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetDescription sets the "description" field. +func (_u *ItemUpdateOne) SetDescription(v string) *ItemUpdateOne { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillableDescription(v *string) *ItemUpdateOne { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// ClearDescription clears the value of the "description" field. +func (_u *ItemUpdateOne) ClearDescription() *ItemUpdateOne { + _u.mutation.ClearDescription() + return _u +} + +// SetImportRef sets the "import_ref" field. +func (_u *ItemUpdateOne) SetImportRef(v string) *ItemUpdateOne { + _u.mutation.SetImportRef(v) + return _u +} + +// SetNillableImportRef sets the "import_ref" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillableImportRef(v *string) *ItemUpdateOne { + if v != nil { + _u.SetImportRef(*v) + } + return _u +} + +// ClearImportRef clears the value of the "import_ref" field. +func (_u *ItemUpdateOne) ClearImportRef() *ItemUpdateOne { + _u.mutation.ClearImportRef() + return _u +} + +// SetNotes sets the "notes" field. +func (_u *ItemUpdateOne) SetNotes(v string) *ItemUpdateOne { + _u.mutation.SetNotes(v) + return _u +} + +// SetNillableNotes sets the "notes" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillableNotes(v *string) *ItemUpdateOne { + if v != nil { + _u.SetNotes(*v) + } + return _u +} + +// ClearNotes clears the value of the "notes" field. +func (_u *ItemUpdateOne) ClearNotes() *ItemUpdateOne { + _u.mutation.ClearNotes() + return _u +} + +// SetQuantity sets the "quantity" field. +func (_u *ItemUpdateOne) SetQuantity(v int) *ItemUpdateOne { + _u.mutation.ResetQuantity() + _u.mutation.SetQuantity(v) + return _u +} + +// SetNillableQuantity sets the "quantity" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillableQuantity(v *int) *ItemUpdateOne { + if v != nil { + _u.SetQuantity(*v) + } + return _u +} + +// AddQuantity adds value to the "quantity" field. +func (_u *ItemUpdateOne) AddQuantity(v int) *ItemUpdateOne { + _u.mutation.AddQuantity(v) + return _u +} + +// SetInsured sets the "insured" field. +func (_u *ItemUpdateOne) SetInsured(v bool) *ItemUpdateOne { + _u.mutation.SetInsured(v) + return _u +} + +// SetNillableInsured sets the "insured" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillableInsured(v *bool) *ItemUpdateOne { + if v != nil { + _u.SetInsured(*v) + } + return _u +} + +// SetArchived sets the "archived" field. +func (_u *ItemUpdateOne) SetArchived(v bool) *ItemUpdateOne { + _u.mutation.SetArchived(v) + return _u +} + +// SetNillableArchived sets the "archived" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillableArchived(v *bool) *ItemUpdateOne { + if v != nil { + _u.SetArchived(*v) + } + return _u +} + +// SetAssetID sets the "asset_id" field. +func (_u *ItemUpdateOne) SetAssetID(v int) *ItemUpdateOne { + _u.mutation.ResetAssetID() + _u.mutation.SetAssetID(v) + return _u +} + +// SetNillableAssetID sets the "asset_id" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillableAssetID(v *int) *ItemUpdateOne { + if v != nil { + _u.SetAssetID(*v) + } + return _u +} + +// AddAssetID adds value to the "asset_id" field. +func (_u *ItemUpdateOne) AddAssetID(v int) *ItemUpdateOne { + _u.mutation.AddAssetID(v) + return _u +} + +// SetSyncChildItemsLocations sets the "sync_child_items_locations" field. +func (_u *ItemUpdateOne) SetSyncChildItemsLocations(v bool) *ItemUpdateOne { + _u.mutation.SetSyncChildItemsLocations(v) + return _u +} + +// SetNillableSyncChildItemsLocations sets the "sync_child_items_locations" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillableSyncChildItemsLocations(v *bool) *ItemUpdateOne { + if v != nil { + _u.SetSyncChildItemsLocations(*v) + } + return _u +} + +// SetSerialNumber sets the "serial_number" field. +func (_u *ItemUpdateOne) SetSerialNumber(v string) *ItemUpdateOne { + _u.mutation.SetSerialNumber(v) + return _u +} + +// SetNillableSerialNumber sets the "serial_number" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillableSerialNumber(v *string) *ItemUpdateOne { + if v != nil { + _u.SetSerialNumber(*v) + } + return _u +} + +// ClearSerialNumber clears the value of the "serial_number" field. +func (_u *ItemUpdateOne) ClearSerialNumber() *ItemUpdateOne { + _u.mutation.ClearSerialNumber() + return _u +} + +// SetModelNumber sets the "model_number" field. +func (_u *ItemUpdateOne) SetModelNumber(v string) *ItemUpdateOne { + _u.mutation.SetModelNumber(v) + return _u +} + +// SetNillableModelNumber sets the "model_number" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillableModelNumber(v *string) *ItemUpdateOne { + if v != nil { + _u.SetModelNumber(*v) + } + return _u +} + +// ClearModelNumber clears the value of the "model_number" field. +func (_u *ItemUpdateOne) ClearModelNumber() *ItemUpdateOne { + _u.mutation.ClearModelNumber() + return _u +} + +// SetManufacturer sets the "manufacturer" field. +func (_u *ItemUpdateOne) SetManufacturer(v string) *ItemUpdateOne { + _u.mutation.SetManufacturer(v) + return _u +} + +// SetNillableManufacturer sets the "manufacturer" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillableManufacturer(v *string) *ItemUpdateOne { + if v != nil { + _u.SetManufacturer(*v) + } + return _u +} + +// ClearManufacturer clears the value of the "manufacturer" field. +func (_u *ItemUpdateOne) ClearManufacturer() *ItemUpdateOne { + _u.mutation.ClearManufacturer() + return _u +} + +// SetLifetimeWarranty sets the "lifetime_warranty" field. +func (_u *ItemUpdateOne) SetLifetimeWarranty(v bool) *ItemUpdateOne { + _u.mutation.SetLifetimeWarranty(v) + return _u +} + +// SetNillableLifetimeWarranty sets the "lifetime_warranty" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillableLifetimeWarranty(v *bool) *ItemUpdateOne { + if v != nil { + _u.SetLifetimeWarranty(*v) + } + return _u +} + +// SetWarrantyExpires sets the "warranty_expires" field. +func (_u *ItemUpdateOne) SetWarrantyExpires(v time.Time) *ItemUpdateOne { + _u.mutation.SetWarrantyExpires(v) + return _u +} + +// SetNillableWarrantyExpires sets the "warranty_expires" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillableWarrantyExpires(v *time.Time) *ItemUpdateOne { + if v != nil { + _u.SetWarrantyExpires(*v) + } + return _u +} + +// ClearWarrantyExpires clears the value of the "warranty_expires" field. +func (_u *ItemUpdateOne) ClearWarrantyExpires() *ItemUpdateOne { + _u.mutation.ClearWarrantyExpires() + return _u +} + +// SetWarrantyDetails sets the "warranty_details" field. +func (_u *ItemUpdateOne) SetWarrantyDetails(v string) *ItemUpdateOne { + _u.mutation.SetWarrantyDetails(v) + return _u +} + +// SetNillableWarrantyDetails sets the "warranty_details" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillableWarrantyDetails(v *string) *ItemUpdateOne { + if v != nil { + _u.SetWarrantyDetails(*v) + } + return _u +} + +// ClearWarrantyDetails clears the value of the "warranty_details" field. +func (_u *ItemUpdateOne) ClearWarrantyDetails() *ItemUpdateOne { + _u.mutation.ClearWarrantyDetails() + return _u +} + +// SetPurchaseTime sets the "purchase_time" field. +func (_u *ItemUpdateOne) SetPurchaseTime(v time.Time) *ItemUpdateOne { + _u.mutation.SetPurchaseTime(v) + return _u +} + +// SetNillablePurchaseTime sets the "purchase_time" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillablePurchaseTime(v *time.Time) *ItemUpdateOne { + if v != nil { + _u.SetPurchaseTime(*v) + } + return _u +} + +// ClearPurchaseTime clears the value of the "purchase_time" field. +func (_u *ItemUpdateOne) ClearPurchaseTime() *ItemUpdateOne { + _u.mutation.ClearPurchaseTime() + return _u +} + +// SetPurchaseFrom sets the "purchase_from" field. +func (_u *ItemUpdateOne) SetPurchaseFrom(v string) *ItemUpdateOne { + _u.mutation.SetPurchaseFrom(v) + return _u +} + +// SetNillablePurchaseFrom sets the "purchase_from" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillablePurchaseFrom(v *string) *ItemUpdateOne { + if v != nil { + _u.SetPurchaseFrom(*v) + } + return _u +} + +// ClearPurchaseFrom clears the value of the "purchase_from" field. +func (_u *ItemUpdateOne) ClearPurchaseFrom() *ItemUpdateOne { + _u.mutation.ClearPurchaseFrom() + return _u +} + +// SetPurchasePrice sets the "purchase_price" field. +func (_u *ItemUpdateOne) SetPurchasePrice(v float64) *ItemUpdateOne { + _u.mutation.ResetPurchasePrice() + _u.mutation.SetPurchasePrice(v) + return _u +} + +// SetNillablePurchasePrice sets the "purchase_price" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillablePurchasePrice(v *float64) *ItemUpdateOne { + if v != nil { + _u.SetPurchasePrice(*v) + } + return _u +} + +// AddPurchasePrice adds value to the "purchase_price" field. +func (_u *ItemUpdateOne) AddPurchasePrice(v float64) *ItemUpdateOne { + _u.mutation.AddPurchasePrice(v) + return _u +} + +// SetSoldTime sets the "sold_time" field. +func (_u *ItemUpdateOne) SetSoldTime(v time.Time) *ItemUpdateOne { + _u.mutation.SetSoldTime(v) + return _u +} + +// SetNillableSoldTime sets the "sold_time" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillableSoldTime(v *time.Time) *ItemUpdateOne { + if v != nil { + _u.SetSoldTime(*v) + } + return _u +} + +// ClearSoldTime clears the value of the "sold_time" field. +func (_u *ItemUpdateOne) ClearSoldTime() *ItemUpdateOne { + _u.mutation.ClearSoldTime() + return _u +} + +// SetSoldTo sets the "sold_to" field. +func (_u *ItemUpdateOne) SetSoldTo(v string) *ItemUpdateOne { + _u.mutation.SetSoldTo(v) + return _u +} + +// SetNillableSoldTo sets the "sold_to" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillableSoldTo(v *string) *ItemUpdateOne { + if v != nil { + _u.SetSoldTo(*v) + } + return _u +} + +// ClearSoldTo clears the value of the "sold_to" field. +func (_u *ItemUpdateOne) ClearSoldTo() *ItemUpdateOne { + _u.mutation.ClearSoldTo() + return _u +} + +// SetSoldPrice sets the "sold_price" field. +func (_u *ItemUpdateOne) SetSoldPrice(v float64) *ItemUpdateOne { + _u.mutation.ResetSoldPrice() + _u.mutation.SetSoldPrice(v) + return _u +} + +// SetNillableSoldPrice sets the "sold_price" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillableSoldPrice(v *float64) *ItemUpdateOne { + if v != nil { + _u.SetSoldPrice(*v) + } + return _u +} + +// AddSoldPrice adds value to the "sold_price" field. +func (_u *ItemUpdateOne) AddSoldPrice(v float64) *ItemUpdateOne { + _u.mutation.AddSoldPrice(v) + return _u +} + +// SetSoldNotes sets the "sold_notes" field. +func (_u *ItemUpdateOne) SetSoldNotes(v string) *ItemUpdateOne { + _u.mutation.SetSoldNotes(v) + return _u +} + +// SetNillableSoldNotes sets the "sold_notes" field if the given value is not nil. +func (_u *ItemUpdateOne) SetNillableSoldNotes(v *string) *ItemUpdateOne { + if v != nil { + _u.SetSoldNotes(*v) + } + return _u +} + +// ClearSoldNotes clears the value of the "sold_notes" field. +func (_u *ItemUpdateOne) ClearSoldNotes() *ItemUpdateOne { + _u.mutation.ClearSoldNotes() + return _u +} + +// SetGroupID sets the "group" edge to the Group entity by ID. +func (_u *ItemUpdateOne) SetGroupID(id uuid.UUID) *ItemUpdateOne { + _u.mutation.SetGroupID(id) + return _u +} + +// SetGroup sets the "group" edge to the Group entity. +func (_u *ItemUpdateOne) SetGroup(v *Group) *ItemUpdateOne { + return _u.SetGroupID(v.ID) +} + +// SetParentID sets the "parent" edge to the Item entity by ID. +func (_u *ItemUpdateOne) SetParentID(id uuid.UUID) *ItemUpdateOne { + _u.mutation.SetParentID(id) + return _u +} + +// SetNillableParentID sets the "parent" edge to the Item entity by ID if the given value is not nil. +func (_u *ItemUpdateOne) SetNillableParentID(id *uuid.UUID) *ItemUpdateOne { + if id != nil { + _u = _u.SetParentID(*id) + } + return _u +} + +// SetParent sets the "parent" edge to the Item entity. +func (_u *ItemUpdateOne) SetParent(v *Item) *ItemUpdateOne { + return _u.SetParentID(v.ID) +} + +// AddChildIDs adds the "children" edge to the Item entity by IDs. +func (_u *ItemUpdateOne) AddChildIDs(ids ...uuid.UUID) *ItemUpdateOne { + _u.mutation.AddChildIDs(ids...) + return _u +} + +// AddChildren adds the "children" edges to the Item entity. +func (_u *ItemUpdateOne) AddChildren(v ...*Item) *ItemUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddChildIDs(ids...) +} + +// AddLabelIDs adds the "label" edge to the Label entity by IDs. +func (_u *ItemUpdateOne) AddLabelIDs(ids ...uuid.UUID) *ItemUpdateOne { + _u.mutation.AddLabelIDs(ids...) + return _u +} + +// AddLabel adds the "label" edges to the Label entity. +func (_u *ItemUpdateOne) AddLabel(v ...*Label) *ItemUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddLabelIDs(ids...) +} + +// SetLocationID sets the "location" edge to the Location entity by ID. +func (_u *ItemUpdateOne) SetLocationID(id uuid.UUID) *ItemUpdateOne { + _u.mutation.SetLocationID(id) + return _u +} + +// SetNillableLocationID sets the "location" edge to the Location entity by ID if the given value is not nil. +func (_u *ItemUpdateOne) SetNillableLocationID(id *uuid.UUID) *ItemUpdateOne { + if id != nil { + _u = _u.SetLocationID(*id) + } + return _u +} + +// SetLocation sets the "location" edge to the Location entity. +func (_u *ItemUpdateOne) SetLocation(v *Location) *ItemUpdateOne { + return _u.SetLocationID(v.ID) +} + +// AddFieldIDs adds the "fields" edge to the ItemField entity by IDs. +func (_u *ItemUpdateOne) AddFieldIDs(ids ...uuid.UUID) *ItemUpdateOne { + _u.mutation.AddFieldIDs(ids...) + return _u +} + +// AddFields adds the "fields" edges to the ItemField entity. +func (_u *ItemUpdateOne) AddFields(v ...*ItemField) *ItemUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddFieldIDs(ids...) +} + +// AddMaintenanceEntryIDs adds the "maintenance_entries" edge to the MaintenanceEntry entity by IDs. +func (_u *ItemUpdateOne) AddMaintenanceEntryIDs(ids ...uuid.UUID) *ItemUpdateOne { + _u.mutation.AddMaintenanceEntryIDs(ids...) + return _u +} + +// AddMaintenanceEntries adds the "maintenance_entries" edges to the MaintenanceEntry entity. +func (_u *ItemUpdateOne) AddMaintenanceEntries(v ...*MaintenanceEntry) *ItemUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddMaintenanceEntryIDs(ids...) +} + +// AddAttachmentIDs adds the "attachments" edge to the Attachment entity by IDs. +func (_u *ItemUpdateOne) AddAttachmentIDs(ids ...uuid.UUID) *ItemUpdateOne { + _u.mutation.AddAttachmentIDs(ids...) + return _u +} + +// AddAttachments adds the "attachments" edges to the Attachment entity. +func (_u *ItemUpdateOne) AddAttachments(v ...*Attachment) *ItemUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddAttachmentIDs(ids...) +} + +// Mutation returns the ItemMutation object of the builder. +func (_u *ItemUpdateOne) Mutation() *ItemMutation { + return _u.mutation +} + +// ClearGroup clears the "group" edge to the Group entity. +func (_u *ItemUpdateOne) ClearGroup() *ItemUpdateOne { + _u.mutation.ClearGroup() + return _u +} + +// ClearParent clears the "parent" edge to the Item entity. +func (_u *ItemUpdateOne) ClearParent() *ItemUpdateOne { + _u.mutation.ClearParent() + return _u +} + +// ClearChildren clears all "children" edges to the Item entity. +func (_u *ItemUpdateOne) ClearChildren() *ItemUpdateOne { + _u.mutation.ClearChildren() + return _u +} + +// RemoveChildIDs removes the "children" edge to Item entities by IDs. +func (_u *ItemUpdateOne) RemoveChildIDs(ids ...uuid.UUID) *ItemUpdateOne { + _u.mutation.RemoveChildIDs(ids...) + return _u +} + +// RemoveChildren removes "children" edges to Item entities. +func (_u *ItemUpdateOne) RemoveChildren(v ...*Item) *ItemUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveChildIDs(ids...) +} + +// ClearLabel clears all "label" edges to the Label entity. +func (_u *ItemUpdateOne) ClearLabel() *ItemUpdateOne { + _u.mutation.ClearLabel() + return _u +} + +// RemoveLabelIDs removes the "label" edge to Label entities by IDs. +func (_u *ItemUpdateOne) RemoveLabelIDs(ids ...uuid.UUID) *ItemUpdateOne { + _u.mutation.RemoveLabelIDs(ids...) + return _u +} + +// RemoveLabel removes "label" edges to Label entities. +func (_u *ItemUpdateOne) RemoveLabel(v ...*Label) *ItemUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveLabelIDs(ids...) +} + +// ClearLocation clears the "location" edge to the Location entity. +func (_u *ItemUpdateOne) ClearLocation() *ItemUpdateOne { + _u.mutation.ClearLocation() + return _u +} + +// ClearFields clears all "fields" edges to the ItemField entity. +func (_u *ItemUpdateOne) ClearFields() *ItemUpdateOne { + _u.mutation.ClearFields() + return _u +} + +// RemoveFieldIDs removes the "fields" edge to ItemField entities by IDs. +func (_u *ItemUpdateOne) RemoveFieldIDs(ids ...uuid.UUID) *ItemUpdateOne { + _u.mutation.RemoveFieldIDs(ids...) + return _u +} + +// RemoveFields removes "fields" edges to ItemField entities. +func (_u *ItemUpdateOne) RemoveFields(v ...*ItemField) *ItemUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveFieldIDs(ids...) +} + +// ClearMaintenanceEntries clears all "maintenance_entries" edges to the MaintenanceEntry entity. +func (_u *ItemUpdateOne) ClearMaintenanceEntries() *ItemUpdateOne { + _u.mutation.ClearMaintenanceEntries() + return _u +} + +// RemoveMaintenanceEntryIDs removes the "maintenance_entries" edge to MaintenanceEntry entities by IDs. +func (_u *ItemUpdateOne) RemoveMaintenanceEntryIDs(ids ...uuid.UUID) *ItemUpdateOne { + _u.mutation.RemoveMaintenanceEntryIDs(ids...) + return _u +} + +// RemoveMaintenanceEntries removes "maintenance_entries" edges to MaintenanceEntry entities. +func (_u *ItemUpdateOne) RemoveMaintenanceEntries(v ...*MaintenanceEntry) *ItemUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveMaintenanceEntryIDs(ids...) +} + +// ClearAttachments clears all "attachments" edges to the Attachment entity. +func (_u *ItemUpdateOne) ClearAttachments() *ItemUpdateOne { + _u.mutation.ClearAttachments() + return _u +} + +// RemoveAttachmentIDs removes the "attachments" edge to Attachment entities by IDs. +func (_u *ItemUpdateOne) RemoveAttachmentIDs(ids ...uuid.UUID) *ItemUpdateOne { + _u.mutation.RemoveAttachmentIDs(ids...) + return _u +} + +// RemoveAttachments removes "attachments" edges to Attachment entities. +func (_u *ItemUpdateOne) RemoveAttachments(v ...*Attachment) *ItemUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveAttachmentIDs(ids...) +} + +// Where appends a list predicates to the ItemUpdate builder. +func (_u *ItemUpdateOne) Where(ps ...predicate.Item) *ItemUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *ItemUpdateOne) Select(field string, fields ...string) *ItemUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated Item entity. +func (_u *ItemUpdateOne) Save(ctx context.Context) (*Item, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *ItemUpdateOne) SaveX(ctx context.Context) *Item { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *ItemUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *ItemUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *ItemUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := item.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *ItemUpdateOne) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := item.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Item.name": %w`, err)} + } + } + if v, ok := _u.mutation.Description(); ok { + if err := item.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Item.description": %w`, err)} + } + } + if v, ok := _u.mutation.ImportRef(); ok { + if err := item.ImportRefValidator(v); err != nil { + return &ValidationError{Name: "import_ref", err: fmt.Errorf(`ent: validator failed for field "Item.import_ref": %w`, err)} + } + } + if v, ok := _u.mutation.Notes(); ok { + if err := item.NotesValidator(v); err != nil { + return &ValidationError{Name: "notes", err: fmt.Errorf(`ent: validator failed for field "Item.notes": %w`, err)} + } + } + if v, ok := _u.mutation.SerialNumber(); ok { + if err := item.SerialNumberValidator(v); err != nil { + return &ValidationError{Name: "serial_number", err: fmt.Errorf(`ent: validator failed for field "Item.serial_number": %w`, err)} + } + } + if v, ok := _u.mutation.ModelNumber(); ok { + if err := item.ModelNumberValidator(v); err != nil { + return &ValidationError{Name: "model_number", err: fmt.Errorf(`ent: validator failed for field "Item.model_number": %w`, err)} + } + } + if v, ok := _u.mutation.Manufacturer(); ok { + if err := item.ManufacturerValidator(v); err != nil { + return &ValidationError{Name: "manufacturer", err: fmt.Errorf(`ent: validator failed for field "Item.manufacturer": %w`, err)} + } + } + if v, ok := _u.mutation.WarrantyDetails(); ok { + if err := item.WarrantyDetailsValidator(v); err != nil { + return &ValidationError{Name: "warranty_details", err: fmt.Errorf(`ent: validator failed for field "Item.warranty_details": %w`, err)} + } + } + if v, ok := _u.mutation.SoldNotes(); ok { + if err := item.SoldNotesValidator(v); err != nil { + return &ValidationError{Name: "sold_notes", err: fmt.Errorf(`ent: validator failed for field "Item.sold_notes": %w`, err)} + } + } + if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "Item.group"`) + } + return nil +} + +func (_u *ItemUpdateOne) sqlSave(ctx context.Context) (_node *Item, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(item.Table, item.Columns, sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Item.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, item.FieldID) + for _, f := range fields { + if !item.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != item.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(item.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(item.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(item.FieldDescription, field.TypeString, value) + } + if _u.mutation.DescriptionCleared() { + _spec.ClearField(item.FieldDescription, field.TypeString) + } + if value, ok := _u.mutation.ImportRef(); ok { + _spec.SetField(item.FieldImportRef, field.TypeString, value) + } + if _u.mutation.ImportRefCleared() { + _spec.ClearField(item.FieldImportRef, field.TypeString) + } + if value, ok := _u.mutation.Notes(); ok { + _spec.SetField(item.FieldNotes, field.TypeString, value) + } + if _u.mutation.NotesCleared() { + _spec.ClearField(item.FieldNotes, field.TypeString) + } + if value, ok := _u.mutation.Quantity(); ok { + _spec.SetField(item.FieldQuantity, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedQuantity(); ok { + _spec.AddField(item.FieldQuantity, field.TypeInt, value) + } + if value, ok := _u.mutation.Insured(); ok { + _spec.SetField(item.FieldInsured, field.TypeBool, value) + } + if value, ok := _u.mutation.Archived(); ok { + _spec.SetField(item.FieldArchived, field.TypeBool, value) + } + if value, ok := _u.mutation.AssetID(); ok { + _spec.SetField(item.FieldAssetID, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedAssetID(); ok { + _spec.AddField(item.FieldAssetID, field.TypeInt, value) + } + if value, ok := _u.mutation.SyncChildItemsLocations(); ok { + _spec.SetField(item.FieldSyncChildItemsLocations, field.TypeBool, value) + } + if value, ok := _u.mutation.SerialNumber(); ok { + _spec.SetField(item.FieldSerialNumber, field.TypeString, value) + } + if _u.mutation.SerialNumberCleared() { + _spec.ClearField(item.FieldSerialNumber, field.TypeString) + } + if value, ok := _u.mutation.ModelNumber(); ok { + _spec.SetField(item.FieldModelNumber, field.TypeString, value) + } + if _u.mutation.ModelNumberCleared() { + _spec.ClearField(item.FieldModelNumber, field.TypeString) + } + if value, ok := _u.mutation.Manufacturer(); ok { + _spec.SetField(item.FieldManufacturer, field.TypeString, value) + } + if _u.mutation.ManufacturerCleared() { + _spec.ClearField(item.FieldManufacturer, field.TypeString) + } + if value, ok := _u.mutation.LifetimeWarranty(); ok { + _spec.SetField(item.FieldLifetimeWarranty, field.TypeBool, value) + } + if value, ok := _u.mutation.WarrantyExpires(); ok { + _spec.SetField(item.FieldWarrantyExpires, field.TypeTime, value) + } + if _u.mutation.WarrantyExpiresCleared() { + _spec.ClearField(item.FieldWarrantyExpires, field.TypeTime) + } + if value, ok := _u.mutation.WarrantyDetails(); ok { + _spec.SetField(item.FieldWarrantyDetails, field.TypeString, value) + } + if _u.mutation.WarrantyDetailsCleared() { + _spec.ClearField(item.FieldWarrantyDetails, field.TypeString) + } + if value, ok := _u.mutation.PurchaseTime(); ok { + _spec.SetField(item.FieldPurchaseTime, field.TypeTime, value) + } + if _u.mutation.PurchaseTimeCleared() { + _spec.ClearField(item.FieldPurchaseTime, field.TypeTime) + } + if value, ok := _u.mutation.PurchaseFrom(); ok { + _spec.SetField(item.FieldPurchaseFrom, field.TypeString, value) + } + if _u.mutation.PurchaseFromCleared() { + _spec.ClearField(item.FieldPurchaseFrom, field.TypeString) + } + if value, ok := _u.mutation.PurchasePrice(); ok { + _spec.SetField(item.FieldPurchasePrice, field.TypeFloat64, value) + } + if value, ok := _u.mutation.AddedPurchasePrice(); ok { + _spec.AddField(item.FieldPurchasePrice, field.TypeFloat64, value) + } + if value, ok := _u.mutation.SoldTime(); ok { + _spec.SetField(item.FieldSoldTime, field.TypeTime, value) + } + if _u.mutation.SoldTimeCleared() { + _spec.ClearField(item.FieldSoldTime, field.TypeTime) + } + if value, ok := _u.mutation.SoldTo(); ok { + _spec.SetField(item.FieldSoldTo, field.TypeString, value) + } + if _u.mutation.SoldToCleared() { + _spec.ClearField(item.FieldSoldTo, field.TypeString) + } + if value, ok := _u.mutation.SoldPrice(); ok { + _spec.SetField(item.FieldSoldPrice, field.TypeFloat64, value) + } + if value, ok := _u.mutation.AddedSoldPrice(); ok { + _spec.AddField(item.FieldSoldPrice, field.TypeFloat64, value) + } + if value, ok := _u.mutation.SoldNotes(); ok { + _spec.SetField(item.FieldSoldNotes, field.TypeString, value) + } + if _u.mutation.SoldNotesCleared() { + _spec.ClearField(item.FieldSoldNotes, field.TypeString) + } + if _u.mutation.GroupCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: item.GroupTable, + Columns: []string{item.GroupColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: item.GroupTable, + Columns: []string{item.GroupColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ParentCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: item.ParentTable, + Columns: []string{item.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: item.ParentTable, + Columns: []string{item.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.ChildrenTable, + Columns: []string{item.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.ChildrenTable, + Columns: []string{item.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.ChildrenTable, + Columns: []string{item.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.LabelCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: item.LabelTable, + Columns: item.LabelPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedLabelIDs(); len(nodes) > 0 && !_u.mutation.LabelCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: item.LabelTable, + Columns: item.LabelPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.LabelIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: item.LabelTable, + Columns: item.LabelPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.LocationCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: item.LocationTable, + Columns: []string{item.LocationColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.LocationIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: item.LocationTable, + Columns: []string{item.LocationColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.FieldsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.FieldsTable, + Columns: []string{item.FieldsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedFieldsIDs(); len(nodes) > 0 && !_u.mutation.FieldsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.FieldsTable, + Columns: []string{item.FieldsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.FieldsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.FieldsTable, + Columns: []string{item.FieldsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.MaintenanceEntriesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.MaintenanceEntriesTable, + Columns: []string{item.MaintenanceEntriesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedMaintenanceEntriesIDs(); len(nodes) > 0 && !_u.mutation.MaintenanceEntriesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.MaintenanceEntriesTable, + Columns: []string{item.MaintenanceEntriesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.MaintenanceEntriesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.MaintenanceEntriesTable, + Columns: []string{item.MaintenanceEntriesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.AttachmentsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.AttachmentsTable, + Columns: []string{item.AttachmentsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedAttachmentsIDs(); len(nodes) > 0 && !_u.mutation.AttachmentsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.AttachmentsTable, + Columns: []string{item.AttachmentsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.AttachmentsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: item.AttachmentsTable, + Columns: []string{item.AttachmentsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &Item{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{item.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/backend/internal/data/ent/itemfield_create.go b/backend/internal/data/ent/itemfield_create.go new file mode 100644 index 00000000..1daf082b --- /dev/null +++ b/backend/internal/data/ent/itemfield_create.go @@ -0,0 +1,438 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield" +) + +// ItemFieldCreate is the builder for creating a ItemField entity. +type ItemFieldCreate struct { + config + mutation *ItemFieldMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (_c *ItemFieldCreate) SetCreatedAt(v time.Time) *ItemFieldCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *ItemFieldCreate) SetNillableCreatedAt(v *time.Time) *ItemFieldCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *ItemFieldCreate) SetUpdatedAt(v time.Time) *ItemFieldCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *ItemFieldCreate) SetNillableUpdatedAt(v *time.Time) *ItemFieldCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetName sets the "name" field. +func (_c *ItemFieldCreate) SetName(v string) *ItemFieldCreate { + _c.mutation.SetName(v) + return _c +} + +// SetDescription sets the "description" field. +func (_c *ItemFieldCreate) SetDescription(v string) *ItemFieldCreate { + _c.mutation.SetDescription(v) + return _c +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_c *ItemFieldCreate) SetNillableDescription(v *string) *ItemFieldCreate { + if v != nil { + _c.SetDescription(*v) + } + return _c +} + +// SetType sets the "type" field. +func (_c *ItemFieldCreate) SetType(v itemfield.Type) *ItemFieldCreate { + _c.mutation.SetType(v) + return _c +} + +// SetTextValue sets the "text_value" field. +func (_c *ItemFieldCreate) SetTextValue(v string) *ItemFieldCreate { + _c.mutation.SetTextValue(v) + return _c +} + +// SetNillableTextValue sets the "text_value" field if the given value is not nil. +func (_c *ItemFieldCreate) SetNillableTextValue(v *string) *ItemFieldCreate { + if v != nil { + _c.SetTextValue(*v) + } + return _c +} + +// SetNumberValue sets the "number_value" field. +func (_c *ItemFieldCreate) SetNumberValue(v int) *ItemFieldCreate { + _c.mutation.SetNumberValue(v) + return _c +} + +// SetNillableNumberValue sets the "number_value" field if the given value is not nil. +func (_c *ItemFieldCreate) SetNillableNumberValue(v *int) *ItemFieldCreate { + if v != nil { + _c.SetNumberValue(*v) + } + return _c +} + +// SetBooleanValue sets the "boolean_value" field. +func (_c *ItemFieldCreate) SetBooleanValue(v bool) *ItemFieldCreate { + _c.mutation.SetBooleanValue(v) + return _c +} + +// SetNillableBooleanValue sets the "boolean_value" field if the given value is not nil. +func (_c *ItemFieldCreate) SetNillableBooleanValue(v *bool) *ItemFieldCreate { + if v != nil { + _c.SetBooleanValue(*v) + } + return _c +} + +// SetTimeValue sets the "time_value" field. +func (_c *ItemFieldCreate) SetTimeValue(v time.Time) *ItemFieldCreate { + _c.mutation.SetTimeValue(v) + return _c +} + +// SetNillableTimeValue sets the "time_value" field if the given value is not nil. +func (_c *ItemFieldCreate) SetNillableTimeValue(v *time.Time) *ItemFieldCreate { + if v != nil { + _c.SetTimeValue(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *ItemFieldCreate) SetID(v uuid.UUID) *ItemFieldCreate { + _c.mutation.SetID(v) + return _c +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (_c *ItemFieldCreate) SetNillableID(v *uuid.UUID) *ItemFieldCreate { + if v != nil { + _c.SetID(*v) + } + return _c +} + +// SetItemID sets the "item" edge to the Item entity by ID. +func (_c *ItemFieldCreate) SetItemID(id uuid.UUID) *ItemFieldCreate { + _c.mutation.SetItemID(id) + return _c +} + +// SetNillableItemID sets the "item" edge to the Item entity by ID if the given value is not nil. +func (_c *ItemFieldCreate) SetNillableItemID(id *uuid.UUID) *ItemFieldCreate { + if id != nil { + _c = _c.SetItemID(*id) + } + return _c +} + +// SetItem sets the "item" edge to the Item entity. +func (_c *ItemFieldCreate) SetItem(v *Item) *ItemFieldCreate { + return _c.SetItemID(v.ID) +} + +// Mutation returns the ItemFieldMutation object of the builder. +func (_c *ItemFieldCreate) Mutation() *ItemFieldMutation { + return _c.mutation +} + +// Save creates the ItemField in the database. +func (_c *ItemFieldCreate) Save(ctx context.Context) (*ItemField, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *ItemFieldCreate) SaveX(ctx context.Context) *ItemField { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *ItemFieldCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *ItemFieldCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *ItemFieldCreate) defaults() { + if _, ok := _c.mutation.CreatedAt(); !ok { + v := itemfield.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := itemfield.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.BooleanValue(); !ok { + v := itemfield.DefaultBooleanValue + _c.mutation.SetBooleanValue(v) + } + if _, ok := _c.mutation.TimeValue(); !ok { + v := itemfield.DefaultTimeValue() + _c.mutation.SetTimeValue(v) + } + if _, ok := _c.mutation.ID(); !ok { + v := itemfield.DefaultID() + _c.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *ItemFieldCreate) check() error { + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ItemField.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "ItemField.updated_at"`)} + } + if _, ok := _c.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "ItemField.name"`)} + } + if v, ok := _c.mutation.Name(); ok { + if err := itemfield.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ItemField.name": %w`, err)} + } + } + if v, ok := _c.mutation.Description(); ok { + if err := itemfield.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "ItemField.description": %w`, err)} + } + } + if _, ok := _c.mutation.GetType(); !ok { + return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "ItemField.type"`)} + } + if v, ok := _c.mutation.GetType(); ok { + if err := itemfield.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "ItemField.type": %w`, err)} + } + } + if v, ok := _c.mutation.TextValue(); ok { + if err := itemfield.TextValueValidator(v); err != nil { + return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "ItemField.text_value": %w`, err)} + } + } + if _, ok := _c.mutation.BooleanValue(); !ok { + return &ValidationError{Name: "boolean_value", err: errors.New(`ent: missing required field "ItemField.boolean_value"`)} + } + if _, ok := _c.mutation.TimeValue(); !ok { + return &ValidationError{Name: "time_value", err: errors.New(`ent: missing required field "ItemField.time_value"`)} + } + return nil +} + +func (_c *ItemFieldCreate) sqlSave(ctx context.Context) (*ItemField, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *ItemFieldCreate) createSpec() (*ItemField, *sqlgraph.CreateSpec) { + var ( + _node = &ItemField{config: _c.config} + _spec = sqlgraph.NewCreateSpec(itemfield.Table, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(itemfield.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(itemfield.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := _c.mutation.Name(); ok { + _spec.SetField(itemfield.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := _c.mutation.Description(); ok { + _spec.SetField(itemfield.FieldDescription, field.TypeString, value) + _node.Description = value + } + if value, ok := _c.mutation.GetType(); ok { + _spec.SetField(itemfield.FieldType, field.TypeEnum, value) + _node.Type = value + } + if value, ok := _c.mutation.TextValue(); ok { + _spec.SetField(itemfield.FieldTextValue, field.TypeString, value) + _node.TextValue = value + } + if value, ok := _c.mutation.NumberValue(); ok { + _spec.SetField(itemfield.FieldNumberValue, field.TypeInt, value) + _node.NumberValue = value + } + if value, ok := _c.mutation.BooleanValue(); ok { + _spec.SetField(itemfield.FieldBooleanValue, field.TypeBool, value) + _node.BooleanValue = value + } + if value, ok := _c.mutation.TimeValue(); ok { + _spec.SetField(itemfield.FieldTimeValue, field.TypeTime, value) + _node.TimeValue = value + } + if nodes := _c.mutation.ItemIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: itemfield.ItemTable, + Columns: []string{itemfield.ItemColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.item_fields = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// ItemFieldCreateBulk is the builder for creating many ItemField entities in bulk. +type ItemFieldCreateBulk struct { + config + err error + builders []*ItemFieldCreate +} + +// Save creates the ItemField entities in the database. +func (_c *ItemFieldCreateBulk) Save(ctx context.Context) ([]*ItemField, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*ItemField, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ItemFieldMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *ItemFieldCreateBulk) SaveX(ctx context.Context) []*ItemField { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *ItemFieldCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *ItemFieldCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/internal/data/ent/itemfield_delete.go b/backend/internal/data/ent/itemfield_delete.go new file mode 100644 index 00000000..048cb13d --- /dev/null +++ b/backend/internal/data/ent/itemfield_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" +) + +// ItemFieldDelete is the builder for deleting a ItemField entity. +type ItemFieldDelete struct { + config + hooks []Hook + mutation *ItemFieldMutation +} + +// Where appends a list predicates to the ItemFieldDelete builder. +func (_d *ItemFieldDelete) Where(ps ...predicate.ItemField) *ItemFieldDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *ItemFieldDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *ItemFieldDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *ItemFieldDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(itemfield.Table, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// ItemFieldDeleteOne is the builder for deleting a single ItemField entity. +type ItemFieldDeleteOne struct { + _d *ItemFieldDelete +} + +// Where appends a list predicates to the ItemFieldDelete builder. +func (_d *ItemFieldDeleteOne) Where(ps ...predicate.ItemField) *ItemFieldDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *ItemFieldDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{itemfield.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *ItemFieldDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/internal/data/ent/itemfield_query.go b/backend/internal/data/ent/itemfield_query.go new file mode 100644 index 00000000..39a85914 --- /dev/null +++ b/backend/internal/data/ent/itemfield_query.go @@ -0,0 +1,615 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" +) + +// ItemFieldQuery is the builder for querying ItemField entities. +type ItemFieldQuery struct { + config + ctx *QueryContext + order []itemfield.OrderOption + inters []Interceptor + predicates []predicate.ItemField + withItem *ItemQuery + withFKs bool + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ItemFieldQuery builder. +func (_q *ItemFieldQuery) Where(ps ...predicate.ItemField) *ItemFieldQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *ItemFieldQuery) Limit(limit int) *ItemFieldQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *ItemFieldQuery) Offset(offset int) *ItemFieldQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *ItemFieldQuery) Unique(unique bool) *ItemFieldQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *ItemFieldQuery) Order(o ...itemfield.OrderOption) *ItemFieldQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryItem chains the current query on the "item" edge. +func (_q *ItemFieldQuery) QueryItem() *ItemQuery { + query := (&ItemClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(itemfield.Table, itemfield.FieldID, selector), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, itemfield.ItemTable, itemfield.ItemColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first ItemField entity from the query. +// Returns a *NotFoundError when no ItemField was found. +func (_q *ItemFieldQuery) First(ctx context.Context) (*ItemField, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{itemfield.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *ItemFieldQuery) FirstX(ctx context.Context) *ItemField { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first ItemField ID from the query. +// Returns a *NotFoundError when no ItemField ID was found. +func (_q *ItemFieldQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{itemfield.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *ItemFieldQuery) FirstIDX(ctx context.Context) uuid.UUID { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single ItemField entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one ItemField entity is found. +// Returns a *NotFoundError when no ItemField entities are found. +func (_q *ItemFieldQuery) Only(ctx context.Context) (*ItemField, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{itemfield.Label} + default: + return nil, &NotSingularError{itemfield.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *ItemFieldQuery) OnlyX(ctx context.Context) *ItemField { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only ItemField ID in the query. +// Returns a *NotSingularError when more than one ItemField ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *ItemFieldQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{itemfield.Label} + default: + err = &NotSingularError{itemfield.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *ItemFieldQuery) OnlyIDX(ctx context.Context) uuid.UUID { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of ItemFields. +func (_q *ItemFieldQuery) All(ctx context.Context) ([]*ItemField, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*ItemField, *ItemFieldQuery]() + return withInterceptors[[]*ItemField](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *ItemFieldQuery) AllX(ctx context.Context) []*ItemField { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of ItemField IDs. +func (_q *ItemFieldQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(itemfield.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *ItemFieldQuery) IDsX(ctx context.Context) []uuid.UUID { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *ItemFieldQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*ItemFieldQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *ItemFieldQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *ItemFieldQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *ItemFieldQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ItemFieldQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *ItemFieldQuery) Clone() *ItemFieldQuery { + if _q == nil { + return nil + } + return &ItemFieldQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]itemfield.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.ItemField{}, _q.predicates...), + withItem: _q.withItem.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// WithItem tells the query-builder to eager-load the nodes that are connected to +// the "item" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ItemFieldQuery) WithItem(opts ...func(*ItemQuery)) *ItemFieldQuery { + query := (&ItemClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withItem = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.ItemField.Query(). +// GroupBy(itemfield.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *ItemFieldQuery) GroupBy(field string, fields ...string) *ItemFieldGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &ItemFieldGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = itemfield.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.ItemField.Query(). +// Select(itemfield.FieldCreatedAt). +// Scan(ctx, &v) +func (_q *ItemFieldQuery) Select(fields ...string) *ItemFieldSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &ItemFieldSelect{ItemFieldQuery: _q} + sbuild.label = itemfield.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ItemFieldSelect configured with the given aggregations. +func (_q *ItemFieldQuery) Aggregate(fns ...AggregateFunc) *ItemFieldSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *ItemFieldQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !itemfield.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *ItemFieldQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ItemField, error) { + var ( + nodes = []*ItemField{} + withFKs = _q.withFKs + _spec = _q.querySpec() + loadedTypes = [1]bool{ + _q.withItem != nil, + } + ) + if _q.withItem != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, itemfield.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*ItemField).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &ItemField{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withItem; query != nil { + if err := _q.loadItem(ctx, query, nodes, nil, + func(n *ItemField, e *Item) { n.Edges.Item = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *ItemFieldQuery) loadItem(ctx context.Context, query *ItemQuery, nodes []*ItemField, init func(*ItemField), assign func(*ItemField, *Item)) error { + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*ItemField) + for i := range nodes { + if nodes[i].item_fields == nil { + continue + } + fk := *nodes[i].item_fields + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(item.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "item_fields" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (_q *ItemFieldQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *ItemFieldQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(itemfield.Table, itemfield.Columns, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, itemfield.FieldID) + for i := range fields { + if fields[i] != itemfield.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *ItemFieldQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(itemfield.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = itemfield.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ItemFieldGroupBy is the group-by builder for ItemField entities. +type ItemFieldGroupBy struct { + selector + build *ItemFieldQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *ItemFieldGroupBy) Aggregate(fns ...AggregateFunc) *ItemFieldGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *ItemFieldGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ItemFieldQuery, *ItemFieldGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *ItemFieldGroupBy) sqlScan(ctx context.Context, root *ItemFieldQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ItemFieldSelect is the builder for selecting fields of ItemField entities. +type ItemFieldSelect struct { + *ItemFieldQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *ItemFieldSelect) Aggregate(fns ...AggregateFunc) *ItemFieldSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *ItemFieldSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ItemFieldQuery, *ItemFieldSelect](ctx, _s.ItemFieldQuery, _s, _s.inters, v) +} + +func (_s *ItemFieldSelect) sqlScan(ctx context.Context, root *ItemFieldQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/backend/internal/data/ent/itemfield_update.go b/backend/internal/data/ent/itemfield_update.go new file mode 100644 index 00000000..941c4328 --- /dev/null +++ b/backend/internal/data/ent/itemfield_update.go @@ -0,0 +1,690 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" +) + +// ItemFieldUpdate is the builder for updating ItemField entities. +type ItemFieldUpdate struct { + config + hooks []Hook + mutation *ItemFieldMutation +} + +// Where appends a list predicates to the ItemFieldUpdate builder. +func (_u *ItemFieldUpdate) Where(ps ...predicate.ItemField) *ItemFieldUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *ItemFieldUpdate) SetUpdatedAt(v time.Time) *ItemFieldUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetName sets the "name" field. +func (_u *ItemFieldUpdate) SetName(v string) *ItemFieldUpdate { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *ItemFieldUpdate) SetNillableName(v *string) *ItemFieldUpdate { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetDescription sets the "description" field. +func (_u *ItemFieldUpdate) SetDescription(v string) *ItemFieldUpdate { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *ItemFieldUpdate) SetNillableDescription(v *string) *ItemFieldUpdate { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// ClearDescription clears the value of the "description" field. +func (_u *ItemFieldUpdate) ClearDescription() *ItemFieldUpdate { + _u.mutation.ClearDescription() + return _u +} + +// SetType sets the "type" field. +func (_u *ItemFieldUpdate) SetType(v itemfield.Type) *ItemFieldUpdate { + _u.mutation.SetType(v) + return _u +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_u *ItemFieldUpdate) SetNillableType(v *itemfield.Type) *ItemFieldUpdate { + if v != nil { + _u.SetType(*v) + } + return _u +} + +// SetTextValue sets the "text_value" field. +func (_u *ItemFieldUpdate) SetTextValue(v string) *ItemFieldUpdate { + _u.mutation.SetTextValue(v) + return _u +} + +// SetNillableTextValue sets the "text_value" field if the given value is not nil. +func (_u *ItemFieldUpdate) SetNillableTextValue(v *string) *ItemFieldUpdate { + if v != nil { + _u.SetTextValue(*v) + } + return _u +} + +// ClearTextValue clears the value of the "text_value" field. +func (_u *ItemFieldUpdate) ClearTextValue() *ItemFieldUpdate { + _u.mutation.ClearTextValue() + return _u +} + +// SetNumberValue sets the "number_value" field. +func (_u *ItemFieldUpdate) SetNumberValue(v int) *ItemFieldUpdate { + _u.mutation.ResetNumberValue() + _u.mutation.SetNumberValue(v) + return _u +} + +// SetNillableNumberValue sets the "number_value" field if the given value is not nil. +func (_u *ItemFieldUpdate) SetNillableNumberValue(v *int) *ItemFieldUpdate { + if v != nil { + _u.SetNumberValue(*v) + } + return _u +} + +// AddNumberValue adds value to the "number_value" field. +func (_u *ItemFieldUpdate) AddNumberValue(v int) *ItemFieldUpdate { + _u.mutation.AddNumberValue(v) + return _u +} + +// ClearNumberValue clears the value of the "number_value" field. +func (_u *ItemFieldUpdate) ClearNumberValue() *ItemFieldUpdate { + _u.mutation.ClearNumberValue() + return _u +} + +// SetBooleanValue sets the "boolean_value" field. +func (_u *ItemFieldUpdate) SetBooleanValue(v bool) *ItemFieldUpdate { + _u.mutation.SetBooleanValue(v) + return _u +} + +// SetNillableBooleanValue sets the "boolean_value" field if the given value is not nil. +func (_u *ItemFieldUpdate) SetNillableBooleanValue(v *bool) *ItemFieldUpdate { + if v != nil { + _u.SetBooleanValue(*v) + } + return _u +} + +// SetTimeValue sets the "time_value" field. +func (_u *ItemFieldUpdate) SetTimeValue(v time.Time) *ItemFieldUpdate { + _u.mutation.SetTimeValue(v) + return _u +} + +// SetNillableTimeValue sets the "time_value" field if the given value is not nil. +func (_u *ItemFieldUpdate) SetNillableTimeValue(v *time.Time) *ItemFieldUpdate { + if v != nil { + _u.SetTimeValue(*v) + } + return _u +} + +// SetItemID sets the "item" edge to the Item entity by ID. +func (_u *ItemFieldUpdate) SetItemID(id uuid.UUID) *ItemFieldUpdate { + _u.mutation.SetItemID(id) + return _u +} + +// SetNillableItemID sets the "item" edge to the Item entity by ID if the given value is not nil. +func (_u *ItemFieldUpdate) SetNillableItemID(id *uuid.UUID) *ItemFieldUpdate { + if id != nil { + _u = _u.SetItemID(*id) + } + return _u +} + +// SetItem sets the "item" edge to the Item entity. +func (_u *ItemFieldUpdate) SetItem(v *Item) *ItemFieldUpdate { + return _u.SetItemID(v.ID) +} + +// Mutation returns the ItemFieldMutation object of the builder. +func (_u *ItemFieldUpdate) Mutation() *ItemFieldMutation { + return _u.mutation +} + +// ClearItem clears the "item" edge to the Item entity. +func (_u *ItemFieldUpdate) ClearItem() *ItemFieldUpdate { + _u.mutation.ClearItem() + return _u +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *ItemFieldUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *ItemFieldUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *ItemFieldUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *ItemFieldUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *ItemFieldUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := itemfield.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *ItemFieldUpdate) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := itemfield.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ItemField.name": %w`, err)} + } + } + if v, ok := _u.mutation.Description(); ok { + if err := itemfield.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "ItemField.description": %w`, err)} + } + } + if v, ok := _u.mutation.GetType(); ok { + if err := itemfield.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "ItemField.type": %w`, err)} + } + } + if v, ok := _u.mutation.TextValue(); ok { + if err := itemfield.TextValueValidator(v); err != nil { + return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "ItemField.text_value": %w`, err)} + } + } + return nil +} + +func (_u *ItemFieldUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(itemfield.Table, itemfield.Columns, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(itemfield.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(itemfield.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(itemfield.FieldDescription, field.TypeString, value) + } + if _u.mutation.DescriptionCleared() { + _spec.ClearField(itemfield.FieldDescription, field.TypeString) + } + if value, ok := _u.mutation.GetType(); ok { + _spec.SetField(itemfield.FieldType, field.TypeEnum, value) + } + if value, ok := _u.mutation.TextValue(); ok { + _spec.SetField(itemfield.FieldTextValue, field.TypeString, value) + } + if _u.mutation.TextValueCleared() { + _spec.ClearField(itemfield.FieldTextValue, field.TypeString) + } + if value, ok := _u.mutation.NumberValue(); ok { + _spec.SetField(itemfield.FieldNumberValue, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedNumberValue(); ok { + _spec.AddField(itemfield.FieldNumberValue, field.TypeInt, value) + } + if _u.mutation.NumberValueCleared() { + _spec.ClearField(itemfield.FieldNumberValue, field.TypeInt) + } + if value, ok := _u.mutation.BooleanValue(); ok { + _spec.SetField(itemfield.FieldBooleanValue, field.TypeBool, value) + } + if value, ok := _u.mutation.TimeValue(); ok { + _spec.SetField(itemfield.FieldTimeValue, field.TypeTime, value) + } + if _u.mutation.ItemCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: itemfield.ItemTable, + Columns: []string{itemfield.ItemColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: itemfield.ItemTable, + Columns: []string{itemfield.ItemColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{itemfield.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// ItemFieldUpdateOne is the builder for updating a single ItemField entity. +type ItemFieldUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ItemFieldMutation +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *ItemFieldUpdateOne) SetUpdatedAt(v time.Time) *ItemFieldUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetName sets the "name" field. +func (_u *ItemFieldUpdateOne) SetName(v string) *ItemFieldUpdateOne { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *ItemFieldUpdateOne) SetNillableName(v *string) *ItemFieldUpdateOne { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetDescription sets the "description" field. +func (_u *ItemFieldUpdateOne) SetDescription(v string) *ItemFieldUpdateOne { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *ItemFieldUpdateOne) SetNillableDescription(v *string) *ItemFieldUpdateOne { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// ClearDescription clears the value of the "description" field. +func (_u *ItemFieldUpdateOne) ClearDescription() *ItemFieldUpdateOne { + _u.mutation.ClearDescription() + return _u +} + +// SetType sets the "type" field. +func (_u *ItemFieldUpdateOne) SetType(v itemfield.Type) *ItemFieldUpdateOne { + _u.mutation.SetType(v) + return _u +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_u *ItemFieldUpdateOne) SetNillableType(v *itemfield.Type) *ItemFieldUpdateOne { + if v != nil { + _u.SetType(*v) + } + return _u +} + +// SetTextValue sets the "text_value" field. +func (_u *ItemFieldUpdateOne) SetTextValue(v string) *ItemFieldUpdateOne { + _u.mutation.SetTextValue(v) + return _u +} + +// SetNillableTextValue sets the "text_value" field if the given value is not nil. +func (_u *ItemFieldUpdateOne) SetNillableTextValue(v *string) *ItemFieldUpdateOne { + if v != nil { + _u.SetTextValue(*v) + } + return _u +} + +// ClearTextValue clears the value of the "text_value" field. +func (_u *ItemFieldUpdateOne) ClearTextValue() *ItemFieldUpdateOne { + _u.mutation.ClearTextValue() + return _u +} + +// SetNumberValue sets the "number_value" field. +func (_u *ItemFieldUpdateOne) SetNumberValue(v int) *ItemFieldUpdateOne { + _u.mutation.ResetNumberValue() + _u.mutation.SetNumberValue(v) + return _u +} + +// SetNillableNumberValue sets the "number_value" field if the given value is not nil. +func (_u *ItemFieldUpdateOne) SetNillableNumberValue(v *int) *ItemFieldUpdateOne { + if v != nil { + _u.SetNumberValue(*v) + } + return _u +} + +// AddNumberValue adds value to the "number_value" field. +func (_u *ItemFieldUpdateOne) AddNumberValue(v int) *ItemFieldUpdateOne { + _u.mutation.AddNumberValue(v) + return _u +} + +// ClearNumberValue clears the value of the "number_value" field. +func (_u *ItemFieldUpdateOne) ClearNumberValue() *ItemFieldUpdateOne { + _u.mutation.ClearNumberValue() + return _u +} + +// SetBooleanValue sets the "boolean_value" field. +func (_u *ItemFieldUpdateOne) SetBooleanValue(v bool) *ItemFieldUpdateOne { + _u.mutation.SetBooleanValue(v) + return _u +} + +// SetNillableBooleanValue sets the "boolean_value" field if the given value is not nil. +func (_u *ItemFieldUpdateOne) SetNillableBooleanValue(v *bool) *ItemFieldUpdateOne { + if v != nil { + _u.SetBooleanValue(*v) + } + return _u +} + +// SetTimeValue sets the "time_value" field. +func (_u *ItemFieldUpdateOne) SetTimeValue(v time.Time) *ItemFieldUpdateOne { + _u.mutation.SetTimeValue(v) + return _u +} + +// SetNillableTimeValue sets the "time_value" field if the given value is not nil. +func (_u *ItemFieldUpdateOne) SetNillableTimeValue(v *time.Time) *ItemFieldUpdateOne { + if v != nil { + _u.SetTimeValue(*v) + } + return _u +} + +// SetItemID sets the "item" edge to the Item entity by ID. +func (_u *ItemFieldUpdateOne) SetItemID(id uuid.UUID) *ItemFieldUpdateOne { + _u.mutation.SetItemID(id) + return _u +} + +// SetNillableItemID sets the "item" edge to the Item entity by ID if the given value is not nil. +func (_u *ItemFieldUpdateOne) SetNillableItemID(id *uuid.UUID) *ItemFieldUpdateOne { + if id != nil { + _u = _u.SetItemID(*id) + } + return _u +} + +// SetItem sets the "item" edge to the Item entity. +func (_u *ItemFieldUpdateOne) SetItem(v *Item) *ItemFieldUpdateOne { + return _u.SetItemID(v.ID) +} + +// Mutation returns the ItemFieldMutation object of the builder. +func (_u *ItemFieldUpdateOne) Mutation() *ItemFieldMutation { + return _u.mutation +} + +// ClearItem clears the "item" edge to the Item entity. +func (_u *ItemFieldUpdateOne) ClearItem() *ItemFieldUpdateOne { + _u.mutation.ClearItem() + return _u +} + +// Where appends a list predicates to the ItemFieldUpdate builder. +func (_u *ItemFieldUpdateOne) Where(ps ...predicate.ItemField) *ItemFieldUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *ItemFieldUpdateOne) Select(field string, fields ...string) *ItemFieldUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated ItemField entity. +func (_u *ItemFieldUpdateOne) Save(ctx context.Context) (*ItemField, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *ItemFieldUpdateOne) SaveX(ctx context.Context) *ItemField { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *ItemFieldUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *ItemFieldUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *ItemFieldUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := itemfield.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *ItemFieldUpdateOne) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := itemfield.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ItemField.name": %w`, err)} + } + } + if v, ok := _u.mutation.Description(); ok { + if err := itemfield.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "ItemField.description": %w`, err)} + } + } + if v, ok := _u.mutation.GetType(); ok { + if err := itemfield.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "ItemField.type": %w`, err)} + } + } + if v, ok := _u.mutation.TextValue(); ok { + if err := itemfield.TextValueValidator(v); err != nil { + return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "ItemField.text_value": %w`, err)} + } + } + return nil +} + +func (_u *ItemFieldUpdateOne) sqlSave(ctx context.Context) (_node *ItemField, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(itemfield.Table, itemfield.Columns, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ItemField.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, itemfield.FieldID) + for _, f := range fields { + if !itemfield.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != itemfield.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(itemfield.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(itemfield.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(itemfield.FieldDescription, field.TypeString, value) + } + if _u.mutation.DescriptionCleared() { + _spec.ClearField(itemfield.FieldDescription, field.TypeString) + } + if value, ok := _u.mutation.GetType(); ok { + _spec.SetField(itemfield.FieldType, field.TypeEnum, value) + } + if value, ok := _u.mutation.TextValue(); ok { + _spec.SetField(itemfield.FieldTextValue, field.TypeString, value) + } + if _u.mutation.TextValueCleared() { + _spec.ClearField(itemfield.FieldTextValue, field.TypeString) + } + if value, ok := _u.mutation.NumberValue(); ok { + _spec.SetField(itemfield.FieldNumberValue, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedNumberValue(); ok { + _spec.AddField(itemfield.FieldNumberValue, field.TypeInt, value) + } + if _u.mutation.NumberValueCleared() { + _spec.ClearField(itemfield.FieldNumberValue, field.TypeInt) + } + if value, ok := _u.mutation.BooleanValue(); ok { + _spec.SetField(itemfield.FieldBooleanValue, field.TypeBool, value) + } + if value, ok := _u.mutation.TimeValue(); ok { + _spec.SetField(itemfield.FieldTimeValue, field.TypeTime, value) + } + if _u.mutation.ItemCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: itemfield.ItemTable, + Columns: []string{itemfield.ItemColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: itemfield.ItemTable, + Columns: []string{itemfield.ItemColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &ItemField{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{itemfield.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/backend/internal/data/ent/itemtemplate.go b/backend/internal/data/ent/itemtemplate.go new file mode 100644 index 00000000..0d9f1f2f --- /dev/null +++ b/backend/internal/data/ent/itemtemplate.go @@ -0,0 +1,376 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "encoding/json" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location" +) + +// ItemTemplate is the model entity for the ItemTemplate schema. +type ItemTemplate struct { + config `json:"-"` + // ID of the ent. + ID uuid.UUID `json:"id,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // UpdatedAt holds the value of the "updated_at" field. + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Name holds the value of the "name" field. + Name string `json:"name,omitempty"` + // Description holds the value of the "description" field. + Description string `json:"description,omitempty"` + // Notes holds the value of the "notes" field. + Notes string `json:"notes,omitempty"` + // DefaultQuantity holds the value of the "default_quantity" field. + DefaultQuantity int `json:"default_quantity,omitempty"` + // DefaultInsured holds the value of the "default_insured" field. + DefaultInsured bool `json:"default_insured,omitempty"` + // Default name template for items (can use placeholders) + DefaultName string `json:"default_name,omitempty"` + // Default description for items created from this template + DefaultDescription string `json:"default_description,omitempty"` + // DefaultManufacturer holds the value of the "default_manufacturer" field. + DefaultManufacturer string `json:"default_manufacturer,omitempty"` + // Default model number for items created from this template + DefaultModelNumber string `json:"default_model_number,omitempty"` + // DefaultLifetimeWarranty holds the value of the "default_lifetime_warranty" field. + DefaultLifetimeWarranty bool `json:"default_lifetime_warranty,omitempty"` + // DefaultWarrantyDetails holds the value of the "default_warranty_details" field. + DefaultWarrantyDetails string `json:"default_warranty_details,omitempty"` + // Whether to include warranty fields in items created from this template + IncludeWarrantyFields bool `json:"include_warranty_fields,omitempty"` + // Whether to include purchase fields in items created from this template + IncludePurchaseFields bool `json:"include_purchase_fields,omitempty"` + // Whether to include sold fields in items created from this template + IncludeSoldFields bool `json:"include_sold_fields,omitempty"` + // Default label IDs for items created from this template + DefaultLabelIds []uuid.UUID `json:"default_label_ids,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ItemTemplateQuery when eager-loading is set. + Edges ItemTemplateEdges `json:"edges"` + group_item_templates *uuid.UUID + item_template_location *uuid.UUID + selectValues sql.SelectValues +} + +// ItemTemplateEdges holds the relations/edges for other nodes in the graph. +type ItemTemplateEdges struct { + // Group holds the value of the group edge. + Group *Group `json:"group,omitempty"` + // Fields holds the value of the fields edge. + Fields []*TemplateField `json:"fields,omitempty"` + // Location holds the value of the location edge. + Location *Location `json:"location,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [3]bool +} + +// GroupOrErr returns the Group value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ItemTemplateEdges) GroupOrErr() (*Group, error) { + if e.Group != nil { + return e.Group, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: group.Label} + } + return nil, &NotLoadedError{edge: "group"} +} + +// FieldsOrErr returns the Fields value or an error if the edge +// was not loaded in eager-loading. +func (e ItemTemplateEdges) FieldsOrErr() ([]*TemplateField, error) { + if e.loadedTypes[1] { + return e.Fields, nil + } + return nil, &NotLoadedError{edge: "fields"} +} + +// LocationOrErr returns the Location value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ItemTemplateEdges) LocationOrErr() (*Location, error) { + if e.Location != nil { + return e.Location, nil + } else if e.loadedTypes[2] { + return nil, &NotFoundError{label: location.Label} + } + return nil, &NotLoadedError{edge: "location"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*ItemTemplate) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case itemtemplate.FieldDefaultLabelIds: + values[i] = new([]byte) + case itemtemplate.FieldDefaultInsured, itemtemplate.FieldDefaultLifetimeWarranty, itemtemplate.FieldIncludeWarrantyFields, itemtemplate.FieldIncludePurchaseFields, itemtemplate.FieldIncludeSoldFields: + values[i] = new(sql.NullBool) + case itemtemplate.FieldDefaultQuantity: + values[i] = new(sql.NullInt64) + case itemtemplate.FieldName, itemtemplate.FieldDescription, itemtemplate.FieldNotes, itemtemplate.FieldDefaultName, itemtemplate.FieldDefaultDescription, itemtemplate.FieldDefaultManufacturer, itemtemplate.FieldDefaultModelNumber, itemtemplate.FieldDefaultWarrantyDetails: + values[i] = new(sql.NullString) + case itemtemplate.FieldCreatedAt, itemtemplate.FieldUpdatedAt: + values[i] = new(sql.NullTime) + case itemtemplate.FieldID: + values[i] = new(uuid.UUID) + case itemtemplate.ForeignKeys[0]: // group_item_templates + values[i] = &sql.NullScanner{S: new(uuid.UUID)} + case itemtemplate.ForeignKeys[1]: // item_template_location + values[i] = &sql.NullScanner{S: new(uuid.UUID)} + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the ItemTemplate fields. +func (_m *ItemTemplate) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case itemtemplate.FieldID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + _m.ID = *value + } + case itemtemplate.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + _m.CreatedAt = value.Time + } + case itemtemplate.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + _m.UpdatedAt = value.Time + } + case itemtemplate.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + _m.Name = value.String + } + case itemtemplate.FieldDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field description", values[i]) + } else if value.Valid { + _m.Description = value.String + } + case itemtemplate.FieldNotes: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field notes", values[i]) + } else if value.Valid { + _m.Notes = value.String + } + case itemtemplate.FieldDefaultQuantity: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field default_quantity", values[i]) + } else if value.Valid { + _m.DefaultQuantity = int(value.Int64) + } + case itemtemplate.FieldDefaultInsured: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field default_insured", values[i]) + } else if value.Valid { + _m.DefaultInsured = value.Bool + } + case itemtemplate.FieldDefaultName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field default_name", values[i]) + } else if value.Valid { + _m.DefaultName = value.String + } + case itemtemplate.FieldDefaultDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field default_description", values[i]) + } else if value.Valid { + _m.DefaultDescription = value.String + } + case itemtemplate.FieldDefaultManufacturer: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field default_manufacturer", values[i]) + } else if value.Valid { + _m.DefaultManufacturer = value.String + } + case itemtemplate.FieldDefaultModelNumber: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field default_model_number", values[i]) + } else if value.Valid { + _m.DefaultModelNumber = value.String + } + case itemtemplate.FieldDefaultLifetimeWarranty: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field default_lifetime_warranty", values[i]) + } else if value.Valid { + _m.DefaultLifetimeWarranty = value.Bool + } + case itemtemplate.FieldDefaultWarrantyDetails: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field default_warranty_details", values[i]) + } else if value.Valid { + _m.DefaultWarrantyDetails = value.String + } + case itemtemplate.FieldIncludeWarrantyFields: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field include_warranty_fields", values[i]) + } else if value.Valid { + _m.IncludeWarrantyFields = value.Bool + } + case itemtemplate.FieldIncludePurchaseFields: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field include_purchase_fields", values[i]) + } else if value.Valid { + _m.IncludePurchaseFields = value.Bool + } + case itemtemplate.FieldIncludeSoldFields: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field include_sold_fields", values[i]) + } else if value.Valid { + _m.IncludeSoldFields = value.Bool + } + case itemtemplate.FieldDefaultLabelIds: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field default_label_ids", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &_m.DefaultLabelIds); err != nil { + return fmt.Errorf("unmarshal field default_label_ids: %w", err) + } + } + case itemtemplate.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field group_item_templates", values[i]) + } else if value.Valid { + _m.group_item_templates = new(uuid.UUID) + *_m.group_item_templates = *value.S.(*uuid.UUID) + } + case itemtemplate.ForeignKeys[1]: + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field item_template_location", values[i]) + } else if value.Valid { + _m.item_template_location = new(uuid.UUID) + *_m.item_template_location = *value.S.(*uuid.UUID) + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the ItemTemplate. +// This includes values selected through modifiers, order, etc. +func (_m *ItemTemplate) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryGroup queries the "group" edge of the ItemTemplate entity. +func (_m *ItemTemplate) QueryGroup() *GroupQuery { + return NewItemTemplateClient(_m.config).QueryGroup(_m) +} + +// QueryFields queries the "fields" edge of the ItemTemplate entity. +func (_m *ItemTemplate) QueryFields() *TemplateFieldQuery { + return NewItemTemplateClient(_m.config).QueryFields(_m) +} + +// QueryLocation queries the "location" edge of the ItemTemplate entity. +func (_m *ItemTemplate) QueryLocation() *LocationQuery { + return NewItemTemplateClient(_m.config).QueryLocation(_m) +} + +// Update returns a builder for updating this ItemTemplate. +// Note that you need to call ItemTemplate.Unwrap() before calling this method if this ItemTemplate +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *ItemTemplate) Update() *ItemTemplateUpdateOne { + return NewItemTemplateClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the ItemTemplate entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *ItemTemplate) Unwrap() *ItemTemplate { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: ItemTemplate is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *ItemTemplate) String() string { + var builder strings.Builder + builder.WriteString("ItemTemplate(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("created_at=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(_m.Name) + builder.WriteString(", ") + builder.WriteString("description=") + builder.WriteString(_m.Description) + builder.WriteString(", ") + builder.WriteString("notes=") + builder.WriteString(_m.Notes) + builder.WriteString(", ") + builder.WriteString("default_quantity=") + builder.WriteString(fmt.Sprintf("%v", _m.DefaultQuantity)) + builder.WriteString(", ") + builder.WriteString("default_insured=") + builder.WriteString(fmt.Sprintf("%v", _m.DefaultInsured)) + builder.WriteString(", ") + builder.WriteString("default_name=") + builder.WriteString(_m.DefaultName) + builder.WriteString(", ") + builder.WriteString("default_description=") + builder.WriteString(_m.DefaultDescription) + builder.WriteString(", ") + builder.WriteString("default_manufacturer=") + builder.WriteString(_m.DefaultManufacturer) + builder.WriteString(", ") + builder.WriteString("default_model_number=") + builder.WriteString(_m.DefaultModelNumber) + builder.WriteString(", ") + builder.WriteString("default_lifetime_warranty=") + builder.WriteString(fmt.Sprintf("%v", _m.DefaultLifetimeWarranty)) + builder.WriteString(", ") + builder.WriteString("default_warranty_details=") + builder.WriteString(_m.DefaultWarrantyDetails) + builder.WriteString(", ") + builder.WriteString("include_warranty_fields=") + builder.WriteString(fmt.Sprintf("%v", _m.IncludeWarrantyFields)) + builder.WriteString(", ") + builder.WriteString("include_purchase_fields=") + builder.WriteString(fmt.Sprintf("%v", _m.IncludePurchaseFields)) + builder.WriteString(", ") + builder.WriteString("include_sold_fields=") + builder.WriteString(fmt.Sprintf("%v", _m.IncludeSoldFields)) + builder.WriteString(", ") + builder.WriteString("default_label_ids=") + builder.WriteString(fmt.Sprintf("%v", _m.DefaultLabelIds)) + builder.WriteByte(')') + return builder.String() +} + +// ItemTemplates is a parsable slice of ItemTemplate. +type ItemTemplates []*ItemTemplate diff --git a/backend/internal/data/ent/itemtemplate/itemtemplate.go b/backend/internal/data/ent/itemtemplate/itemtemplate.go new file mode 100644 index 00000000..ac308b9d --- /dev/null +++ b/backend/internal/data/ent/itemtemplate/itemtemplate.go @@ -0,0 +1,301 @@ +// Code generated by ent, DO NOT EDIT. + +package itemtemplate + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" +) + +const ( + // Label holds the string label denoting the itemtemplate type in the database. + Label = "item_template" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldNotes holds the string denoting the notes field in the database. + FieldNotes = "notes" + // FieldDefaultQuantity holds the string denoting the default_quantity field in the database. + FieldDefaultQuantity = "default_quantity" + // FieldDefaultInsured holds the string denoting the default_insured field in the database. + FieldDefaultInsured = "default_insured" + // FieldDefaultName holds the string denoting the default_name field in the database. + FieldDefaultName = "default_name" + // FieldDefaultDescription holds the string denoting the default_description field in the database. + FieldDefaultDescription = "default_description" + // FieldDefaultManufacturer holds the string denoting the default_manufacturer field in the database. + FieldDefaultManufacturer = "default_manufacturer" + // FieldDefaultModelNumber holds the string denoting the default_model_number field in the database. + FieldDefaultModelNumber = "default_model_number" + // FieldDefaultLifetimeWarranty holds the string denoting the default_lifetime_warranty field in the database. + FieldDefaultLifetimeWarranty = "default_lifetime_warranty" + // FieldDefaultWarrantyDetails holds the string denoting the default_warranty_details field in the database. + FieldDefaultWarrantyDetails = "default_warranty_details" + // FieldIncludeWarrantyFields holds the string denoting the include_warranty_fields field in the database. + FieldIncludeWarrantyFields = "include_warranty_fields" + // FieldIncludePurchaseFields holds the string denoting the include_purchase_fields field in the database. + FieldIncludePurchaseFields = "include_purchase_fields" + // FieldIncludeSoldFields holds the string denoting the include_sold_fields field in the database. + FieldIncludeSoldFields = "include_sold_fields" + // FieldDefaultLabelIds holds the string denoting the default_label_ids field in the database. + FieldDefaultLabelIds = "default_label_ids" + // EdgeGroup holds the string denoting the group edge name in mutations. + EdgeGroup = "group" + // EdgeFields holds the string denoting the fields edge name in mutations. + EdgeFields = "fields" + // EdgeLocation holds the string denoting the location edge name in mutations. + EdgeLocation = "location" + // Table holds the table name of the itemtemplate in the database. + Table = "item_templates" + // GroupTable is the table that holds the group relation/edge. + GroupTable = "item_templates" + // GroupInverseTable is the table name for the Group entity. + // It exists in this package in order to avoid circular dependency with the "group" package. + GroupInverseTable = "groups" + // GroupColumn is the table column denoting the group relation/edge. + GroupColumn = "group_item_templates" + // FieldsTable is the table that holds the fields relation/edge. + FieldsTable = "template_fields" + // FieldsInverseTable is the table name for the TemplateField entity. + // It exists in this package in order to avoid circular dependency with the "templatefield" package. + FieldsInverseTable = "template_fields" + // FieldsColumn is the table column denoting the fields relation/edge. + FieldsColumn = "item_template_fields" + // LocationTable is the table that holds the location relation/edge. + LocationTable = "item_templates" + // LocationInverseTable is the table name for the Location entity. + // It exists in this package in order to avoid circular dependency with the "location" package. + LocationInverseTable = "locations" + // LocationColumn is the table column denoting the location relation/edge. + LocationColumn = "item_template_location" +) + +// Columns holds all SQL columns for itemtemplate fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldName, + FieldDescription, + FieldNotes, + FieldDefaultQuantity, + FieldDefaultInsured, + FieldDefaultName, + FieldDefaultDescription, + FieldDefaultManufacturer, + FieldDefaultModelNumber, + FieldDefaultLifetimeWarranty, + FieldDefaultWarrantyDetails, + FieldIncludeWarrantyFields, + FieldIncludePurchaseFields, + FieldIncludeSoldFields, + FieldDefaultLabelIds, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "item_templates" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "group_item_templates", + "item_template_location", +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + for i := range ForeignKeys { + if column == ForeignKeys[i] { + return true + } + } + return false +} + +var ( + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + DescriptionValidator func(string) error + // NotesValidator is a validator for the "notes" field. It is called by the builders before save. + NotesValidator func(string) error + // DefaultDefaultQuantity holds the default value on creation for the "default_quantity" field. + DefaultDefaultQuantity int + // DefaultDefaultInsured holds the default value on creation for the "default_insured" field. + DefaultDefaultInsured bool + // DefaultNameValidator is a validator for the "default_name" field. It is called by the builders before save. + DefaultNameValidator func(string) error + // DefaultDescriptionValidator is a validator for the "default_description" field. It is called by the builders before save. + DefaultDescriptionValidator func(string) error + // DefaultManufacturerValidator is a validator for the "default_manufacturer" field. It is called by the builders before save. + DefaultManufacturerValidator func(string) error + // DefaultModelNumberValidator is a validator for the "default_model_number" field. It is called by the builders before save. + DefaultModelNumberValidator func(string) error + // DefaultDefaultLifetimeWarranty holds the default value on creation for the "default_lifetime_warranty" field. + DefaultDefaultLifetimeWarranty bool + // DefaultWarrantyDetailsValidator is a validator for the "default_warranty_details" field. It is called by the builders before save. + DefaultWarrantyDetailsValidator func(string) error + // DefaultIncludeWarrantyFields holds the default value on creation for the "include_warranty_fields" field. + DefaultIncludeWarrantyFields bool + // DefaultIncludePurchaseFields holds the default value on creation for the "include_purchase_fields" field. + DefaultIncludePurchaseFields bool + // DefaultIncludeSoldFields holds the default value on creation for the "include_sold_fields" field. + DefaultIncludeSoldFields bool + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID +) + +// OrderOption defines the ordering options for the ItemTemplate queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdatedAt orders the results by the updated_at field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + +// ByNotes orders the results by the notes field. +func ByNotes(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNotes, opts...).ToFunc() +} + +// ByDefaultQuantity orders the results by the default_quantity field. +func ByDefaultQuantity(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDefaultQuantity, opts...).ToFunc() +} + +// ByDefaultInsured orders the results by the default_insured field. +func ByDefaultInsured(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDefaultInsured, opts...).ToFunc() +} + +// ByDefaultName orders the results by the default_name field. +func ByDefaultName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDefaultName, opts...).ToFunc() +} + +// ByDefaultDescription orders the results by the default_description field. +func ByDefaultDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDefaultDescription, opts...).ToFunc() +} + +// ByDefaultManufacturer orders the results by the default_manufacturer field. +func ByDefaultManufacturer(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDefaultManufacturer, opts...).ToFunc() +} + +// ByDefaultModelNumber orders the results by the default_model_number field. +func ByDefaultModelNumber(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDefaultModelNumber, opts...).ToFunc() +} + +// ByDefaultLifetimeWarranty orders the results by the default_lifetime_warranty field. +func ByDefaultLifetimeWarranty(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDefaultLifetimeWarranty, opts...).ToFunc() +} + +// ByDefaultWarrantyDetails orders the results by the default_warranty_details field. +func ByDefaultWarrantyDetails(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDefaultWarrantyDetails, opts...).ToFunc() +} + +// ByIncludeWarrantyFields orders the results by the include_warranty_fields field. +func ByIncludeWarrantyFields(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIncludeWarrantyFields, opts...).ToFunc() +} + +// ByIncludePurchaseFields orders the results by the include_purchase_fields field. +func ByIncludePurchaseFields(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIncludePurchaseFields, opts...).ToFunc() +} + +// ByIncludeSoldFields orders the results by the include_sold_fields field. +func ByIncludeSoldFields(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIncludeSoldFields, opts...).ToFunc() +} + +// ByGroupField orders the results by group field. +func ByGroupField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newGroupStep(), sql.OrderByField(field, opts...)) + } +} + +// ByFieldsCount orders the results by fields count. +func ByFieldsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newFieldsStep(), opts...) + } +} + +// ByFields orders the results by fields terms. +func ByFields(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newFieldsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByLocationField orders the results by location field. +func ByLocationField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newLocationStep(), sql.OrderByField(field, opts...)) + } +} +func newGroupStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(GroupInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn), + ) +} +func newFieldsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(FieldsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, FieldsTable, FieldsColumn), + ) +} +func newLocationStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(LocationInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, LocationTable, LocationColumn), + ) +} diff --git a/backend/internal/data/ent/itemtemplate/where.go b/backend/internal/data/ent/itemtemplate/where.go new file mode 100644 index 00000000..1ade7376 --- /dev/null +++ b/backend/internal/data/ent/itemtemplate/where.go @@ -0,0 +1,991 @@ +// Code generated by ent, DO NOT EDIT. + +package itemtemplate + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id uuid.UUID) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uuid.UUID) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uuid.UUID) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uuid.UUID) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uuid.UUID) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uuid.UUID) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uuid.UUID) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uuid.UUID) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uuid.UUID) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLTE(FieldID, id)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldName, v)) +} + +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldDescription, v)) +} + +// Notes applies equality check predicate on the "notes" field. It's identical to NotesEQ. +func Notes(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldNotes, v)) +} + +// DefaultQuantity applies equality check predicate on the "default_quantity" field. It's identical to DefaultQuantityEQ. +func DefaultQuantity(v int) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultQuantity, v)) +} + +// DefaultInsured applies equality check predicate on the "default_insured" field. It's identical to DefaultInsuredEQ. +func DefaultInsured(v bool) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultInsured, v)) +} + +// DefaultName applies equality check predicate on the "default_name" field. It's identical to DefaultNameEQ. +func DefaultName(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultName, v)) +} + +// DefaultDescription applies equality check predicate on the "default_description" field. It's identical to DefaultDescriptionEQ. +func DefaultDescription(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultDescription, v)) +} + +// DefaultManufacturer applies equality check predicate on the "default_manufacturer" field. It's identical to DefaultManufacturerEQ. +func DefaultManufacturer(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultManufacturer, v)) +} + +// DefaultModelNumber applies equality check predicate on the "default_model_number" field. It's identical to DefaultModelNumberEQ. +func DefaultModelNumber(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultModelNumber, v)) +} + +// DefaultLifetimeWarranty applies equality check predicate on the "default_lifetime_warranty" field. It's identical to DefaultLifetimeWarrantyEQ. +func DefaultLifetimeWarranty(v bool) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultLifetimeWarranty, v)) +} + +// DefaultWarrantyDetails applies equality check predicate on the "default_warranty_details" field. It's identical to DefaultWarrantyDetailsEQ. +func DefaultWarrantyDetails(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultWarrantyDetails, v)) +} + +// IncludeWarrantyFields applies equality check predicate on the "include_warranty_fields" field. It's identical to IncludeWarrantyFieldsEQ. +func IncludeWarrantyFields(v bool) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldIncludeWarrantyFields, v)) +} + +// IncludePurchaseFields applies equality check predicate on the "include_purchase_fields" field. It's identical to IncludePurchaseFieldsEQ. +func IncludePurchaseFields(v bool) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldIncludePurchaseFields, v)) +} + +// IncludeSoldFields applies equality check predicate on the "include_sold_fields" field. It's identical to IncludeSoldFieldsEQ. +func IncludeSoldFields(v bool) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldIncludeSoldFields, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldContainsFold(FieldName, v)) +} + +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionIsNil applies the IsNil predicate on the "description" field. +func DescriptionIsNil() predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldIsNull(FieldDescription)) +} + +// DescriptionNotNil applies the NotNil predicate on the "description" field. +func DescriptionNotNil() predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNotNull(FieldDescription)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldContainsFold(FieldDescription, v)) +} + +// NotesEQ applies the EQ predicate on the "notes" field. +func NotesEQ(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldNotes, v)) +} + +// NotesNEQ applies the NEQ predicate on the "notes" field. +func NotesNEQ(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNEQ(FieldNotes, v)) +} + +// NotesIn applies the In predicate on the "notes" field. +func NotesIn(vs ...string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldIn(FieldNotes, vs...)) +} + +// NotesNotIn applies the NotIn predicate on the "notes" field. +func NotesNotIn(vs ...string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNotIn(FieldNotes, vs...)) +} + +// NotesGT applies the GT predicate on the "notes" field. +func NotesGT(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGT(FieldNotes, v)) +} + +// NotesGTE applies the GTE predicate on the "notes" field. +func NotesGTE(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGTE(FieldNotes, v)) +} + +// NotesLT applies the LT predicate on the "notes" field. +func NotesLT(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLT(FieldNotes, v)) +} + +// NotesLTE applies the LTE predicate on the "notes" field. +func NotesLTE(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLTE(FieldNotes, v)) +} + +// NotesContains applies the Contains predicate on the "notes" field. +func NotesContains(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldContains(FieldNotes, v)) +} + +// NotesHasPrefix applies the HasPrefix predicate on the "notes" field. +func NotesHasPrefix(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldHasPrefix(FieldNotes, v)) +} + +// NotesHasSuffix applies the HasSuffix predicate on the "notes" field. +func NotesHasSuffix(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldHasSuffix(FieldNotes, v)) +} + +// NotesIsNil applies the IsNil predicate on the "notes" field. +func NotesIsNil() predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldIsNull(FieldNotes)) +} + +// NotesNotNil applies the NotNil predicate on the "notes" field. +func NotesNotNil() predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNotNull(FieldNotes)) +} + +// NotesEqualFold applies the EqualFold predicate on the "notes" field. +func NotesEqualFold(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEqualFold(FieldNotes, v)) +} + +// NotesContainsFold applies the ContainsFold predicate on the "notes" field. +func NotesContainsFold(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldContainsFold(FieldNotes, v)) +} + +// DefaultQuantityEQ applies the EQ predicate on the "default_quantity" field. +func DefaultQuantityEQ(v int) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultQuantity, v)) +} + +// DefaultQuantityNEQ applies the NEQ predicate on the "default_quantity" field. +func DefaultQuantityNEQ(v int) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultQuantity, v)) +} + +// DefaultQuantityIn applies the In predicate on the "default_quantity" field. +func DefaultQuantityIn(vs ...int) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldIn(FieldDefaultQuantity, vs...)) +} + +// DefaultQuantityNotIn applies the NotIn predicate on the "default_quantity" field. +func DefaultQuantityNotIn(vs ...int) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNotIn(FieldDefaultQuantity, vs...)) +} + +// DefaultQuantityGT applies the GT predicate on the "default_quantity" field. +func DefaultQuantityGT(v int) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGT(FieldDefaultQuantity, v)) +} + +// DefaultQuantityGTE applies the GTE predicate on the "default_quantity" field. +func DefaultQuantityGTE(v int) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGTE(FieldDefaultQuantity, v)) +} + +// DefaultQuantityLT applies the LT predicate on the "default_quantity" field. +func DefaultQuantityLT(v int) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLT(FieldDefaultQuantity, v)) +} + +// DefaultQuantityLTE applies the LTE predicate on the "default_quantity" field. +func DefaultQuantityLTE(v int) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLTE(FieldDefaultQuantity, v)) +} + +// DefaultInsuredEQ applies the EQ predicate on the "default_insured" field. +func DefaultInsuredEQ(v bool) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultInsured, v)) +} + +// DefaultInsuredNEQ applies the NEQ predicate on the "default_insured" field. +func DefaultInsuredNEQ(v bool) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultInsured, v)) +} + +// DefaultNameEQ applies the EQ predicate on the "default_name" field. +func DefaultNameEQ(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultName, v)) +} + +// DefaultNameNEQ applies the NEQ predicate on the "default_name" field. +func DefaultNameNEQ(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultName, v)) +} + +// DefaultNameIn applies the In predicate on the "default_name" field. +func DefaultNameIn(vs ...string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldIn(FieldDefaultName, vs...)) +} + +// DefaultNameNotIn applies the NotIn predicate on the "default_name" field. +func DefaultNameNotIn(vs ...string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNotIn(FieldDefaultName, vs...)) +} + +// DefaultNameGT applies the GT predicate on the "default_name" field. +func DefaultNameGT(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGT(FieldDefaultName, v)) +} + +// DefaultNameGTE applies the GTE predicate on the "default_name" field. +func DefaultNameGTE(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGTE(FieldDefaultName, v)) +} + +// DefaultNameLT applies the LT predicate on the "default_name" field. +func DefaultNameLT(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLT(FieldDefaultName, v)) +} + +// DefaultNameLTE applies the LTE predicate on the "default_name" field. +func DefaultNameLTE(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLTE(FieldDefaultName, v)) +} + +// DefaultNameContains applies the Contains predicate on the "default_name" field. +func DefaultNameContains(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldContains(FieldDefaultName, v)) +} + +// DefaultNameHasPrefix applies the HasPrefix predicate on the "default_name" field. +func DefaultNameHasPrefix(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldHasPrefix(FieldDefaultName, v)) +} + +// DefaultNameHasSuffix applies the HasSuffix predicate on the "default_name" field. +func DefaultNameHasSuffix(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldHasSuffix(FieldDefaultName, v)) +} + +// DefaultNameIsNil applies the IsNil predicate on the "default_name" field. +func DefaultNameIsNil() predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldIsNull(FieldDefaultName)) +} + +// DefaultNameNotNil applies the NotNil predicate on the "default_name" field. +func DefaultNameNotNil() predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNotNull(FieldDefaultName)) +} + +// DefaultNameEqualFold applies the EqualFold predicate on the "default_name" field. +func DefaultNameEqualFold(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEqualFold(FieldDefaultName, v)) +} + +// DefaultNameContainsFold applies the ContainsFold predicate on the "default_name" field. +func DefaultNameContainsFold(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldContainsFold(FieldDefaultName, v)) +} + +// DefaultDescriptionEQ applies the EQ predicate on the "default_description" field. +func DefaultDescriptionEQ(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultDescription, v)) +} + +// DefaultDescriptionNEQ applies the NEQ predicate on the "default_description" field. +func DefaultDescriptionNEQ(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultDescription, v)) +} + +// DefaultDescriptionIn applies the In predicate on the "default_description" field. +func DefaultDescriptionIn(vs ...string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldIn(FieldDefaultDescription, vs...)) +} + +// DefaultDescriptionNotIn applies the NotIn predicate on the "default_description" field. +func DefaultDescriptionNotIn(vs ...string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNotIn(FieldDefaultDescription, vs...)) +} + +// DefaultDescriptionGT applies the GT predicate on the "default_description" field. +func DefaultDescriptionGT(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGT(FieldDefaultDescription, v)) +} + +// DefaultDescriptionGTE applies the GTE predicate on the "default_description" field. +func DefaultDescriptionGTE(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGTE(FieldDefaultDescription, v)) +} + +// DefaultDescriptionLT applies the LT predicate on the "default_description" field. +func DefaultDescriptionLT(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLT(FieldDefaultDescription, v)) +} + +// DefaultDescriptionLTE applies the LTE predicate on the "default_description" field. +func DefaultDescriptionLTE(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLTE(FieldDefaultDescription, v)) +} + +// DefaultDescriptionContains applies the Contains predicate on the "default_description" field. +func DefaultDescriptionContains(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldContains(FieldDefaultDescription, v)) +} + +// DefaultDescriptionHasPrefix applies the HasPrefix predicate on the "default_description" field. +func DefaultDescriptionHasPrefix(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldHasPrefix(FieldDefaultDescription, v)) +} + +// DefaultDescriptionHasSuffix applies the HasSuffix predicate on the "default_description" field. +func DefaultDescriptionHasSuffix(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldHasSuffix(FieldDefaultDescription, v)) +} + +// DefaultDescriptionIsNil applies the IsNil predicate on the "default_description" field. +func DefaultDescriptionIsNil() predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldIsNull(FieldDefaultDescription)) +} + +// DefaultDescriptionNotNil applies the NotNil predicate on the "default_description" field. +func DefaultDescriptionNotNil() predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNotNull(FieldDefaultDescription)) +} + +// DefaultDescriptionEqualFold applies the EqualFold predicate on the "default_description" field. +func DefaultDescriptionEqualFold(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEqualFold(FieldDefaultDescription, v)) +} + +// DefaultDescriptionContainsFold applies the ContainsFold predicate on the "default_description" field. +func DefaultDescriptionContainsFold(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldContainsFold(FieldDefaultDescription, v)) +} + +// DefaultManufacturerEQ applies the EQ predicate on the "default_manufacturer" field. +func DefaultManufacturerEQ(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultManufacturer, v)) +} + +// DefaultManufacturerNEQ applies the NEQ predicate on the "default_manufacturer" field. +func DefaultManufacturerNEQ(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultManufacturer, v)) +} + +// DefaultManufacturerIn applies the In predicate on the "default_manufacturer" field. +func DefaultManufacturerIn(vs ...string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldIn(FieldDefaultManufacturer, vs...)) +} + +// DefaultManufacturerNotIn applies the NotIn predicate on the "default_manufacturer" field. +func DefaultManufacturerNotIn(vs ...string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNotIn(FieldDefaultManufacturer, vs...)) +} + +// DefaultManufacturerGT applies the GT predicate on the "default_manufacturer" field. +func DefaultManufacturerGT(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGT(FieldDefaultManufacturer, v)) +} + +// DefaultManufacturerGTE applies the GTE predicate on the "default_manufacturer" field. +func DefaultManufacturerGTE(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGTE(FieldDefaultManufacturer, v)) +} + +// DefaultManufacturerLT applies the LT predicate on the "default_manufacturer" field. +func DefaultManufacturerLT(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLT(FieldDefaultManufacturer, v)) +} + +// DefaultManufacturerLTE applies the LTE predicate on the "default_manufacturer" field. +func DefaultManufacturerLTE(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLTE(FieldDefaultManufacturer, v)) +} + +// DefaultManufacturerContains applies the Contains predicate on the "default_manufacturer" field. +func DefaultManufacturerContains(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldContains(FieldDefaultManufacturer, v)) +} + +// DefaultManufacturerHasPrefix applies the HasPrefix predicate on the "default_manufacturer" field. +func DefaultManufacturerHasPrefix(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldHasPrefix(FieldDefaultManufacturer, v)) +} + +// DefaultManufacturerHasSuffix applies the HasSuffix predicate on the "default_manufacturer" field. +func DefaultManufacturerHasSuffix(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldHasSuffix(FieldDefaultManufacturer, v)) +} + +// DefaultManufacturerIsNil applies the IsNil predicate on the "default_manufacturer" field. +func DefaultManufacturerIsNil() predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldIsNull(FieldDefaultManufacturer)) +} + +// DefaultManufacturerNotNil applies the NotNil predicate on the "default_manufacturer" field. +func DefaultManufacturerNotNil() predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNotNull(FieldDefaultManufacturer)) +} + +// DefaultManufacturerEqualFold applies the EqualFold predicate on the "default_manufacturer" field. +func DefaultManufacturerEqualFold(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEqualFold(FieldDefaultManufacturer, v)) +} + +// DefaultManufacturerContainsFold applies the ContainsFold predicate on the "default_manufacturer" field. +func DefaultManufacturerContainsFold(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldContainsFold(FieldDefaultManufacturer, v)) +} + +// DefaultModelNumberEQ applies the EQ predicate on the "default_model_number" field. +func DefaultModelNumberEQ(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultModelNumber, v)) +} + +// DefaultModelNumberNEQ applies the NEQ predicate on the "default_model_number" field. +func DefaultModelNumberNEQ(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultModelNumber, v)) +} + +// DefaultModelNumberIn applies the In predicate on the "default_model_number" field. +func DefaultModelNumberIn(vs ...string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldIn(FieldDefaultModelNumber, vs...)) +} + +// DefaultModelNumberNotIn applies the NotIn predicate on the "default_model_number" field. +func DefaultModelNumberNotIn(vs ...string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNotIn(FieldDefaultModelNumber, vs...)) +} + +// DefaultModelNumberGT applies the GT predicate on the "default_model_number" field. +func DefaultModelNumberGT(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGT(FieldDefaultModelNumber, v)) +} + +// DefaultModelNumberGTE applies the GTE predicate on the "default_model_number" field. +func DefaultModelNumberGTE(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGTE(FieldDefaultModelNumber, v)) +} + +// DefaultModelNumberLT applies the LT predicate on the "default_model_number" field. +func DefaultModelNumberLT(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLT(FieldDefaultModelNumber, v)) +} + +// DefaultModelNumberLTE applies the LTE predicate on the "default_model_number" field. +func DefaultModelNumberLTE(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLTE(FieldDefaultModelNumber, v)) +} + +// DefaultModelNumberContains applies the Contains predicate on the "default_model_number" field. +func DefaultModelNumberContains(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldContains(FieldDefaultModelNumber, v)) +} + +// DefaultModelNumberHasPrefix applies the HasPrefix predicate on the "default_model_number" field. +func DefaultModelNumberHasPrefix(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldHasPrefix(FieldDefaultModelNumber, v)) +} + +// DefaultModelNumberHasSuffix applies the HasSuffix predicate on the "default_model_number" field. +func DefaultModelNumberHasSuffix(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldHasSuffix(FieldDefaultModelNumber, v)) +} + +// DefaultModelNumberIsNil applies the IsNil predicate on the "default_model_number" field. +func DefaultModelNumberIsNil() predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldIsNull(FieldDefaultModelNumber)) +} + +// DefaultModelNumberNotNil applies the NotNil predicate on the "default_model_number" field. +func DefaultModelNumberNotNil() predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNotNull(FieldDefaultModelNumber)) +} + +// DefaultModelNumberEqualFold applies the EqualFold predicate on the "default_model_number" field. +func DefaultModelNumberEqualFold(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEqualFold(FieldDefaultModelNumber, v)) +} + +// DefaultModelNumberContainsFold applies the ContainsFold predicate on the "default_model_number" field. +func DefaultModelNumberContainsFold(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldContainsFold(FieldDefaultModelNumber, v)) +} + +// DefaultLifetimeWarrantyEQ applies the EQ predicate on the "default_lifetime_warranty" field. +func DefaultLifetimeWarrantyEQ(v bool) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultLifetimeWarranty, v)) +} + +// DefaultLifetimeWarrantyNEQ applies the NEQ predicate on the "default_lifetime_warranty" field. +func DefaultLifetimeWarrantyNEQ(v bool) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultLifetimeWarranty, v)) +} + +// DefaultWarrantyDetailsEQ applies the EQ predicate on the "default_warranty_details" field. +func DefaultWarrantyDetailsEQ(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultWarrantyDetails, v)) +} + +// DefaultWarrantyDetailsNEQ applies the NEQ predicate on the "default_warranty_details" field. +func DefaultWarrantyDetailsNEQ(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultWarrantyDetails, v)) +} + +// DefaultWarrantyDetailsIn applies the In predicate on the "default_warranty_details" field. +func DefaultWarrantyDetailsIn(vs ...string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldIn(FieldDefaultWarrantyDetails, vs...)) +} + +// DefaultWarrantyDetailsNotIn applies the NotIn predicate on the "default_warranty_details" field. +func DefaultWarrantyDetailsNotIn(vs ...string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNotIn(FieldDefaultWarrantyDetails, vs...)) +} + +// DefaultWarrantyDetailsGT applies the GT predicate on the "default_warranty_details" field. +func DefaultWarrantyDetailsGT(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGT(FieldDefaultWarrantyDetails, v)) +} + +// DefaultWarrantyDetailsGTE applies the GTE predicate on the "default_warranty_details" field. +func DefaultWarrantyDetailsGTE(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldGTE(FieldDefaultWarrantyDetails, v)) +} + +// DefaultWarrantyDetailsLT applies the LT predicate on the "default_warranty_details" field. +func DefaultWarrantyDetailsLT(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLT(FieldDefaultWarrantyDetails, v)) +} + +// DefaultWarrantyDetailsLTE applies the LTE predicate on the "default_warranty_details" field. +func DefaultWarrantyDetailsLTE(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldLTE(FieldDefaultWarrantyDetails, v)) +} + +// DefaultWarrantyDetailsContains applies the Contains predicate on the "default_warranty_details" field. +func DefaultWarrantyDetailsContains(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldContains(FieldDefaultWarrantyDetails, v)) +} + +// DefaultWarrantyDetailsHasPrefix applies the HasPrefix predicate on the "default_warranty_details" field. +func DefaultWarrantyDetailsHasPrefix(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldHasPrefix(FieldDefaultWarrantyDetails, v)) +} + +// DefaultWarrantyDetailsHasSuffix applies the HasSuffix predicate on the "default_warranty_details" field. +func DefaultWarrantyDetailsHasSuffix(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldHasSuffix(FieldDefaultWarrantyDetails, v)) +} + +// DefaultWarrantyDetailsIsNil applies the IsNil predicate on the "default_warranty_details" field. +func DefaultWarrantyDetailsIsNil() predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldIsNull(FieldDefaultWarrantyDetails)) +} + +// DefaultWarrantyDetailsNotNil applies the NotNil predicate on the "default_warranty_details" field. +func DefaultWarrantyDetailsNotNil() predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNotNull(FieldDefaultWarrantyDetails)) +} + +// DefaultWarrantyDetailsEqualFold applies the EqualFold predicate on the "default_warranty_details" field. +func DefaultWarrantyDetailsEqualFold(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEqualFold(FieldDefaultWarrantyDetails, v)) +} + +// DefaultWarrantyDetailsContainsFold applies the ContainsFold predicate on the "default_warranty_details" field. +func DefaultWarrantyDetailsContainsFold(v string) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldContainsFold(FieldDefaultWarrantyDetails, v)) +} + +// IncludeWarrantyFieldsEQ applies the EQ predicate on the "include_warranty_fields" field. +func IncludeWarrantyFieldsEQ(v bool) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldIncludeWarrantyFields, v)) +} + +// IncludeWarrantyFieldsNEQ applies the NEQ predicate on the "include_warranty_fields" field. +func IncludeWarrantyFieldsNEQ(v bool) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNEQ(FieldIncludeWarrantyFields, v)) +} + +// IncludePurchaseFieldsEQ applies the EQ predicate on the "include_purchase_fields" field. +func IncludePurchaseFieldsEQ(v bool) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldIncludePurchaseFields, v)) +} + +// IncludePurchaseFieldsNEQ applies the NEQ predicate on the "include_purchase_fields" field. +func IncludePurchaseFieldsNEQ(v bool) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNEQ(FieldIncludePurchaseFields, v)) +} + +// IncludeSoldFieldsEQ applies the EQ predicate on the "include_sold_fields" field. +func IncludeSoldFieldsEQ(v bool) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldEQ(FieldIncludeSoldFields, v)) +} + +// IncludeSoldFieldsNEQ applies the NEQ predicate on the "include_sold_fields" field. +func IncludeSoldFieldsNEQ(v bool) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNEQ(FieldIncludeSoldFields, v)) +} + +// DefaultLabelIdsIsNil applies the IsNil predicate on the "default_label_ids" field. +func DefaultLabelIdsIsNil() predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldIsNull(FieldDefaultLabelIds)) +} + +// DefaultLabelIdsNotNil applies the NotNil predicate on the "default_label_ids" field. +func DefaultLabelIdsNotNil() predicate.ItemTemplate { + return predicate.ItemTemplate(sql.FieldNotNull(FieldDefaultLabelIds)) +} + +// HasGroup applies the HasEdge predicate on the "group" edge. +func HasGroup() predicate.ItemTemplate { + return predicate.ItemTemplate(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasGroupWith applies the HasEdge predicate on the "group" edge with a given conditions (other predicates). +func HasGroupWith(preds ...predicate.Group) predicate.ItemTemplate { + return predicate.ItemTemplate(func(s *sql.Selector) { + step := newGroupStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasFields applies the HasEdge predicate on the "fields" edge. +func HasFields() predicate.ItemTemplate { + return predicate.ItemTemplate(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, FieldsTable, FieldsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasFieldsWith applies the HasEdge predicate on the "fields" edge with a given conditions (other predicates). +func HasFieldsWith(preds ...predicate.TemplateField) predicate.ItemTemplate { + return predicate.ItemTemplate(func(s *sql.Selector) { + step := newFieldsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasLocation applies the HasEdge predicate on the "location" edge. +func HasLocation() predicate.ItemTemplate { + return predicate.ItemTemplate(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, LocationTable, LocationColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasLocationWith applies the HasEdge predicate on the "location" edge with a given conditions (other predicates). +func HasLocationWith(preds ...predicate.Location) predicate.ItemTemplate { + return predicate.ItemTemplate(func(s *sql.Selector) { + step := newLocationStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.ItemTemplate) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.ItemTemplate) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.ItemTemplate) predicate.ItemTemplate { + return predicate.ItemTemplate(sql.NotPredicates(p)) +} diff --git a/backend/internal/data/ent/itemtemplate_create.go b/backend/internal/data/ent/itemtemplate_create.go new file mode 100644 index 00000000..30abd074 --- /dev/null +++ b/backend/internal/data/ent/itemtemplate_create.go @@ -0,0 +1,691 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield" +) + +// ItemTemplateCreate is the builder for creating a ItemTemplate entity. +type ItemTemplateCreate struct { + config + mutation *ItemTemplateMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (_c *ItemTemplateCreate) SetCreatedAt(v time.Time) *ItemTemplateCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *ItemTemplateCreate) SetNillableCreatedAt(v *time.Time) *ItemTemplateCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *ItemTemplateCreate) SetUpdatedAt(v time.Time) *ItemTemplateCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *ItemTemplateCreate) SetNillableUpdatedAt(v *time.Time) *ItemTemplateCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetName sets the "name" field. +func (_c *ItemTemplateCreate) SetName(v string) *ItemTemplateCreate { + _c.mutation.SetName(v) + return _c +} + +// SetDescription sets the "description" field. +func (_c *ItemTemplateCreate) SetDescription(v string) *ItemTemplateCreate { + _c.mutation.SetDescription(v) + return _c +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_c *ItemTemplateCreate) SetNillableDescription(v *string) *ItemTemplateCreate { + if v != nil { + _c.SetDescription(*v) + } + return _c +} + +// SetNotes sets the "notes" field. +func (_c *ItemTemplateCreate) SetNotes(v string) *ItemTemplateCreate { + _c.mutation.SetNotes(v) + return _c +} + +// SetNillableNotes sets the "notes" field if the given value is not nil. +func (_c *ItemTemplateCreate) SetNillableNotes(v *string) *ItemTemplateCreate { + if v != nil { + _c.SetNotes(*v) + } + return _c +} + +// SetDefaultQuantity sets the "default_quantity" field. +func (_c *ItemTemplateCreate) SetDefaultQuantity(v int) *ItemTemplateCreate { + _c.mutation.SetDefaultQuantity(v) + return _c +} + +// SetNillableDefaultQuantity sets the "default_quantity" field if the given value is not nil. +func (_c *ItemTemplateCreate) SetNillableDefaultQuantity(v *int) *ItemTemplateCreate { + if v != nil { + _c.SetDefaultQuantity(*v) + } + return _c +} + +// SetDefaultInsured sets the "default_insured" field. +func (_c *ItemTemplateCreate) SetDefaultInsured(v bool) *ItemTemplateCreate { + _c.mutation.SetDefaultInsured(v) + return _c +} + +// SetNillableDefaultInsured sets the "default_insured" field if the given value is not nil. +func (_c *ItemTemplateCreate) SetNillableDefaultInsured(v *bool) *ItemTemplateCreate { + if v != nil { + _c.SetDefaultInsured(*v) + } + return _c +} + +// SetDefaultName sets the "default_name" field. +func (_c *ItemTemplateCreate) SetDefaultName(v string) *ItemTemplateCreate { + _c.mutation.SetDefaultName(v) + return _c +} + +// SetNillableDefaultName sets the "default_name" field if the given value is not nil. +func (_c *ItemTemplateCreate) SetNillableDefaultName(v *string) *ItemTemplateCreate { + if v != nil { + _c.SetDefaultName(*v) + } + return _c +} + +// SetDefaultDescription sets the "default_description" field. +func (_c *ItemTemplateCreate) SetDefaultDescription(v string) *ItemTemplateCreate { + _c.mutation.SetDefaultDescription(v) + return _c +} + +// SetNillableDefaultDescription sets the "default_description" field if the given value is not nil. +func (_c *ItemTemplateCreate) SetNillableDefaultDescription(v *string) *ItemTemplateCreate { + if v != nil { + _c.SetDefaultDescription(*v) + } + return _c +} + +// SetDefaultManufacturer sets the "default_manufacturer" field. +func (_c *ItemTemplateCreate) SetDefaultManufacturer(v string) *ItemTemplateCreate { + _c.mutation.SetDefaultManufacturer(v) + return _c +} + +// SetNillableDefaultManufacturer sets the "default_manufacturer" field if the given value is not nil. +func (_c *ItemTemplateCreate) SetNillableDefaultManufacturer(v *string) *ItemTemplateCreate { + if v != nil { + _c.SetDefaultManufacturer(*v) + } + return _c +} + +// SetDefaultModelNumber sets the "default_model_number" field. +func (_c *ItemTemplateCreate) SetDefaultModelNumber(v string) *ItemTemplateCreate { + _c.mutation.SetDefaultModelNumber(v) + return _c +} + +// SetNillableDefaultModelNumber sets the "default_model_number" field if the given value is not nil. +func (_c *ItemTemplateCreate) SetNillableDefaultModelNumber(v *string) *ItemTemplateCreate { + if v != nil { + _c.SetDefaultModelNumber(*v) + } + return _c +} + +// SetDefaultLifetimeWarranty sets the "default_lifetime_warranty" field. +func (_c *ItemTemplateCreate) SetDefaultLifetimeWarranty(v bool) *ItemTemplateCreate { + _c.mutation.SetDefaultLifetimeWarranty(v) + return _c +} + +// SetNillableDefaultLifetimeWarranty sets the "default_lifetime_warranty" field if the given value is not nil. +func (_c *ItemTemplateCreate) SetNillableDefaultLifetimeWarranty(v *bool) *ItemTemplateCreate { + if v != nil { + _c.SetDefaultLifetimeWarranty(*v) + } + return _c +} + +// SetDefaultWarrantyDetails sets the "default_warranty_details" field. +func (_c *ItemTemplateCreate) SetDefaultWarrantyDetails(v string) *ItemTemplateCreate { + _c.mutation.SetDefaultWarrantyDetails(v) + return _c +} + +// SetNillableDefaultWarrantyDetails sets the "default_warranty_details" field if the given value is not nil. +func (_c *ItemTemplateCreate) SetNillableDefaultWarrantyDetails(v *string) *ItemTemplateCreate { + if v != nil { + _c.SetDefaultWarrantyDetails(*v) + } + return _c +} + +// SetIncludeWarrantyFields sets the "include_warranty_fields" field. +func (_c *ItemTemplateCreate) SetIncludeWarrantyFields(v bool) *ItemTemplateCreate { + _c.mutation.SetIncludeWarrantyFields(v) + return _c +} + +// SetNillableIncludeWarrantyFields sets the "include_warranty_fields" field if the given value is not nil. +func (_c *ItemTemplateCreate) SetNillableIncludeWarrantyFields(v *bool) *ItemTemplateCreate { + if v != nil { + _c.SetIncludeWarrantyFields(*v) + } + return _c +} + +// SetIncludePurchaseFields sets the "include_purchase_fields" field. +func (_c *ItemTemplateCreate) SetIncludePurchaseFields(v bool) *ItemTemplateCreate { + _c.mutation.SetIncludePurchaseFields(v) + return _c +} + +// SetNillableIncludePurchaseFields sets the "include_purchase_fields" field if the given value is not nil. +func (_c *ItemTemplateCreate) SetNillableIncludePurchaseFields(v *bool) *ItemTemplateCreate { + if v != nil { + _c.SetIncludePurchaseFields(*v) + } + return _c +} + +// SetIncludeSoldFields sets the "include_sold_fields" field. +func (_c *ItemTemplateCreate) SetIncludeSoldFields(v bool) *ItemTemplateCreate { + _c.mutation.SetIncludeSoldFields(v) + return _c +} + +// SetNillableIncludeSoldFields sets the "include_sold_fields" field if the given value is not nil. +func (_c *ItemTemplateCreate) SetNillableIncludeSoldFields(v *bool) *ItemTemplateCreate { + if v != nil { + _c.SetIncludeSoldFields(*v) + } + return _c +} + +// SetDefaultLabelIds sets the "default_label_ids" field. +func (_c *ItemTemplateCreate) SetDefaultLabelIds(v []uuid.UUID) *ItemTemplateCreate { + _c.mutation.SetDefaultLabelIds(v) + return _c +} + +// SetID sets the "id" field. +func (_c *ItemTemplateCreate) SetID(v uuid.UUID) *ItemTemplateCreate { + _c.mutation.SetID(v) + return _c +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (_c *ItemTemplateCreate) SetNillableID(v *uuid.UUID) *ItemTemplateCreate { + if v != nil { + _c.SetID(*v) + } + return _c +} + +// SetGroupID sets the "group" edge to the Group entity by ID. +func (_c *ItemTemplateCreate) SetGroupID(id uuid.UUID) *ItemTemplateCreate { + _c.mutation.SetGroupID(id) + return _c +} + +// SetGroup sets the "group" edge to the Group entity. +func (_c *ItemTemplateCreate) SetGroup(v *Group) *ItemTemplateCreate { + return _c.SetGroupID(v.ID) +} + +// AddFieldIDs adds the "fields" edge to the TemplateField entity by IDs. +func (_c *ItemTemplateCreate) AddFieldIDs(ids ...uuid.UUID) *ItemTemplateCreate { + _c.mutation.AddFieldIDs(ids...) + return _c +} + +// AddFields adds the "fields" edges to the TemplateField entity. +func (_c *ItemTemplateCreate) AddFields(v ...*TemplateField) *ItemTemplateCreate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddFieldIDs(ids...) +} + +// SetLocationID sets the "location" edge to the Location entity by ID. +func (_c *ItemTemplateCreate) SetLocationID(id uuid.UUID) *ItemTemplateCreate { + _c.mutation.SetLocationID(id) + return _c +} + +// SetNillableLocationID sets the "location" edge to the Location entity by ID if the given value is not nil. +func (_c *ItemTemplateCreate) SetNillableLocationID(id *uuid.UUID) *ItemTemplateCreate { + if id != nil { + _c = _c.SetLocationID(*id) + } + return _c +} + +// SetLocation sets the "location" edge to the Location entity. +func (_c *ItemTemplateCreate) SetLocation(v *Location) *ItemTemplateCreate { + return _c.SetLocationID(v.ID) +} + +// Mutation returns the ItemTemplateMutation object of the builder. +func (_c *ItemTemplateCreate) Mutation() *ItemTemplateMutation { + return _c.mutation +} + +// Save creates the ItemTemplate in the database. +func (_c *ItemTemplateCreate) Save(ctx context.Context) (*ItemTemplate, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *ItemTemplateCreate) SaveX(ctx context.Context) *ItemTemplate { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *ItemTemplateCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *ItemTemplateCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *ItemTemplateCreate) defaults() { + if _, ok := _c.mutation.CreatedAt(); !ok { + v := itemtemplate.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := itemtemplate.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.DefaultQuantity(); !ok { + v := itemtemplate.DefaultDefaultQuantity + _c.mutation.SetDefaultQuantity(v) + } + if _, ok := _c.mutation.DefaultInsured(); !ok { + v := itemtemplate.DefaultDefaultInsured + _c.mutation.SetDefaultInsured(v) + } + if _, ok := _c.mutation.DefaultLifetimeWarranty(); !ok { + v := itemtemplate.DefaultDefaultLifetimeWarranty + _c.mutation.SetDefaultLifetimeWarranty(v) + } + if _, ok := _c.mutation.IncludeWarrantyFields(); !ok { + v := itemtemplate.DefaultIncludeWarrantyFields + _c.mutation.SetIncludeWarrantyFields(v) + } + if _, ok := _c.mutation.IncludePurchaseFields(); !ok { + v := itemtemplate.DefaultIncludePurchaseFields + _c.mutation.SetIncludePurchaseFields(v) + } + if _, ok := _c.mutation.IncludeSoldFields(); !ok { + v := itemtemplate.DefaultIncludeSoldFields + _c.mutation.SetIncludeSoldFields(v) + } + if _, ok := _c.mutation.ID(); !ok { + v := itemtemplate.DefaultID() + _c.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *ItemTemplateCreate) check() error { + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ItemTemplate.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "ItemTemplate.updated_at"`)} + } + if _, ok := _c.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "ItemTemplate.name"`)} + } + if v, ok := _c.mutation.Name(); ok { + if err := itemtemplate.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.name": %w`, err)} + } + } + if v, ok := _c.mutation.Description(); ok { + if err := itemtemplate.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.description": %w`, err)} + } + } + if v, ok := _c.mutation.Notes(); ok { + if err := itemtemplate.NotesValidator(v); err != nil { + return &ValidationError{Name: "notes", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.notes": %w`, err)} + } + } + if _, ok := _c.mutation.DefaultQuantity(); !ok { + return &ValidationError{Name: "default_quantity", err: errors.New(`ent: missing required field "ItemTemplate.default_quantity"`)} + } + if _, ok := _c.mutation.DefaultInsured(); !ok { + return &ValidationError{Name: "default_insured", err: errors.New(`ent: missing required field "ItemTemplate.default_insured"`)} + } + if v, ok := _c.mutation.DefaultName(); ok { + if err := itemtemplate.DefaultNameValidator(v); err != nil { + return &ValidationError{Name: "default_name", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_name": %w`, err)} + } + } + if v, ok := _c.mutation.DefaultDescription(); ok { + if err := itemtemplate.DefaultDescriptionValidator(v); err != nil { + return &ValidationError{Name: "default_description", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_description": %w`, err)} + } + } + if v, ok := _c.mutation.DefaultManufacturer(); ok { + if err := itemtemplate.DefaultManufacturerValidator(v); err != nil { + return &ValidationError{Name: "default_manufacturer", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_manufacturer": %w`, err)} + } + } + if v, ok := _c.mutation.DefaultModelNumber(); ok { + if err := itemtemplate.DefaultModelNumberValidator(v); err != nil { + return &ValidationError{Name: "default_model_number", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_model_number": %w`, err)} + } + } + if _, ok := _c.mutation.DefaultLifetimeWarranty(); !ok { + return &ValidationError{Name: "default_lifetime_warranty", err: errors.New(`ent: missing required field "ItemTemplate.default_lifetime_warranty"`)} + } + if v, ok := _c.mutation.DefaultWarrantyDetails(); ok { + if err := itemtemplate.DefaultWarrantyDetailsValidator(v); err != nil { + return &ValidationError{Name: "default_warranty_details", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_warranty_details": %w`, err)} + } + } + if _, ok := _c.mutation.IncludeWarrantyFields(); !ok { + return &ValidationError{Name: "include_warranty_fields", err: errors.New(`ent: missing required field "ItemTemplate.include_warranty_fields"`)} + } + if _, ok := _c.mutation.IncludePurchaseFields(); !ok { + return &ValidationError{Name: "include_purchase_fields", err: errors.New(`ent: missing required field "ItemTemplate.include_purchase_fields"`)} + } + if _, ok := _c.mutation.IncludeSoldFields(); !ok { + return &ValidationError{Name: "include_sold_fields", err: errors.New(`ent: missing required field "ItemTemplate.include_sold_fields"`)} + } + if len(_c.mutation.GroupIDs()) == 0 { + return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "ItemTemplate.group"`)} + } + return nil +} + +func (_c *ItemTemplateCreate) sqlSave(ctx context.Context) (*ItemTemplate, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *ItemTemplateCreate) createSpec() (*ItemTemplate, *sqlgraph.CreateSpec) { + var ( + _node = &ItemTemplate{config: _c.config} + _spec = sqlgraph.NewCreateSpec(itemtemplate.Table, sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(itemtemplate.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(itemtemplate.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := _c.mutation.Name(); ok { + _spec.SetField(itemtemplate.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := _c.mutation.Description(); ok { + _spec.SetField(itemtemplate.FieldDescription, field.TypeString, value) + _node.Description = value + } + if value, ok := _c.mutation.Notes(); ok { + _spec.SetField(itemtemplate.FieldNotes, field.TypeString, value) + _node.Notes = value + } + if value, ok := _c.mutation.DefaultQuantity(); ok { + _spec.SetField(itemtemplate.FieldDefaultQuantity, field.TypeInt, value) + _node.DefaultQuantity = value + } + if value, ok := _c.mutation.DefaultInsured(); ok { + _spec.SetField(itemtemplate.FieldDefaultInsured, field.TypeBool, value) + _node.DefaultInsured = value + } + if value, ok := _c.mutation.DefaultName(); ok { + _spec.SetField(itemtemplate.FieldDefaultName, field.TypeString, value) + _node.DefaultName = value + } + if value, ok := _c.mutation.DefaultDescription(); ok { + _spec.SetField(itemtemplate.FieldDefaultDescription, field.TypeString, value) + _node.DefaultDescription = value + } + if value, ok := _c.mutation.DefaultManufacturer(); ok { + _spec.SetField(itemtemplate.FieldDefaultManufacturer, field.TypeString, value) + _node.DefaultManufacturer = value + } + if value, ok := _c.mutation.DefaultModelNumber(); ok { + _spec.SetField(itemtemplate.FieldDefaultModelNumber, field.TypeString, value) + _node.DefaultModelNumber = value + } + if value, ok := _c.mutation.DefaultLifetimeWarranty(); ok { + _spec.SetField(itemtemplate.FieldDefaultLifetimeWarranty, field.TypeBool, value) + _node.DefaultLifetimeWarranty = value + } + if value, ok := _c.mutation.DefaultWarrantyDetails(); ok { + _spec.SetField(itemtemplate.FieldDefaultWarrantyDetails, field.TypeString, value) + _node.DefaultWarrantyDetails = value + } + if value, ok := _c.mutation.IncludeWarrantyFields(); ok { + _spec.SetField(itemtemplate.FieldIncludeWarrantyFields, field.TypeBool, value) + _node.IncludeWarrantyFields = value + } + if value, ok := _c.mutation.IncludePurchaseFields(); ok { + _spec.SetField(itemtemplate.FieldIncludePurchaseFields, field.TypeBool, value) + _node.IncludePurchaseFields = value + } + if value, ok := _c.mutation.IncludeSoldFields(); ok { + _spec.SetField(itemtemplate.FieldIncludeSoldFields, field.TypeBool, value) + _node.IncludeSoldFields = value + } + if value, ok := _c.mutation.DefaultLabelIds(); ok { + _spec.SetField(itemtemplate.FieldDefaultLabelIds, field.TypeJSON, value) + _node.DefaultLabelIds = value + } + if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: itemtemplate.GroupTable, + Columns: []string{itemtemplate.GroupColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.group_item_templates = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.FieldsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: itemtemplate.FieldsTable, + Columns: []string{itemtemplate.FieldsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.LocationIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: itemtemplate.LocationTable, + Columns: []string{itemtemplate.LocationColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.item_template_location = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// ItemTemplateCreateBulk is the builder for creating many ItemTemplate entities in bulk. +type ItemTemplateCreateBulk struct { + config + err error + builders []*ItemTemplateCreate +} + +// Save creates the ItemTemplate entities in the database. +func (_c *ItemTemplateCreateBulk) Save(ctx context.Context) ([]*ItemTemplate, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*ItemTemplate, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ItemTemplateMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *ItemTemplateCreateBulk) SaveX(ctx context.Context) []*ItemTemplate { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *ItemTemplateCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *ItemTemplateCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/internal/data/ent/itemtemplate_delete.go b/backend/internal/data/ent/itemtemplate_delete.go new file mode 100644 index 00000000..843804df --- /dev/null +++ b/backend/internal/data/ent/itemtemplate_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" +) + +// ItemTemplateDelete is the builder for deleting a ItemTemplate entity. +type ItemTemplateDelete struct { + config + hooks []Hook + mutation *ItemTemplateMutation +} + +// Where appends a list predicates to the ItemTemplateDelete builder. +func (_d *ItemTemplateDelete) Where(ps ...predicate.ItemTemplate) *ItemTemplateDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *ItemTemplateDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *ItemTemplateDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *ItemTemplateDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(itemtemplate.Table, sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// ItemTemplateDeleteOne is the builder for deleting a single ItemTemplate entity. +type ItemTemplateDeleteOne struct { + _d *ItemTemplateDelete +} + +// Where appends a list predicates to the ItemTemplateDelete builder. +func (_d *ItemTemplateDeleteOne) Where(ps ...predicate.ItemTemplate) *ItemTemplateDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *ItemTemplateDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{itemtemplate.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *ItemTemplateDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/internal/data/ent/itemtemplate_query.go b/backend/internal/data/ent/itemtemplate_query.go new file mode 100644 index 00000000..5e339f1f --- /dev/null +++ b/backend/internal/data/ent/itemtemplate_query.go @@ -0,0 +1,766 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield" +) + +// ItemTemplateQuery is the builder for querying ItemTemplate entities. +type ItemTemplateQuery struct { + config + ctx *QueryContext + order []itemtemplate.OrderOption + inters []Interceptor + predicates []predicate.ItemTemplate + withGroup *GroupQuery + withFields *TemplateFieldQuery + withLocation *LocationQuery + withFKs bool + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ItemTemplateQuery builder. +func (_q *ItemTemplateQuery) Where(ps ...predicate.ItemTemplate) *ItemTemplateQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *ItemTemplateQuery) Limit(limit int) *ItemTemplateQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *ItemTemplateQuery) Offset(offset int) *ItemTemplateQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *ItemTemplateQuery) Unique(unique bool) *ItemTemplateQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *ItemTemplateQuery) Order(o ...itemtemplate.OrderOption) *ItemTemplateQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryGroup chains the current query on the "group" edge. +func (_q *ItemTemplateQuery) QueryGroup() *GroupQuery { + query := (&GroupClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, selector), + sqlgraph.To(group.Table, group.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, itemtemplate.GroupTable, itemtemplate.GroupColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryFields chains the current query on the "fields" edge. +func (_q *ItemTemplateQuery) QueryFields() *TemplateFieldQuery { + query := (&TemplateFieldClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, selector), + sqlgraph.To(templatefield.Table, templatefield.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, itemtemplate.FieldsTable, itemtemplate.FieldsColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryLocation chains the current query on the "location" edge. +func (_q *ItemTemplateQuery) QueryLocation() *LocationQuery { + query := (&LocationClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, selector), + sqlgraph.To(location.Table, location.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, itemtemplate.LocationTable, itemtemplate.LocationColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first ItemTemplate entity from the query. +// Returns a *NotFoundError when no ItemTemplate was found. +func (_q *ItemTemplateQuery) First(ctx context.Context) (*ItemTemplate, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{itemtemplate.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *ItemTemplateQuery) FirstX(ctx context.Context) *ItemTemplate { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first ItemTemplate ID from the query. +// Returns a *NotFoundError when no ItemTemplate ID was found. +func (_q *ItemTemplateQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{itemtemplate.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *ItemTemplateQuery) FirstIDX(ctx context.Context) uuid.UUID { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single ItemTemplate entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one ItemTemplate entity is found. +// Returns a *NotFoundError when no ItemTemplate entities are found. +func (_q *ItemTemplateQuery) Only(ctx context.Context) (*ItemTemplate, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{itemtemplate.Label} + default: + return nil, &NotSingularError{itemtemplate.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *ItemTemplateQuery) OnlyX(ctx context.Context) *ItemTemplate { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only ItemTemplate ID in the query. +// Returns a *NotSingularError when more than one ItemTemplate ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *ItemTemplateQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{itemtemplate.Label} + default: + err = &NotSingularError{itemtemplate.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *ItemTemplateQuery) OnlyIDX(ctx context.Context) uuid.UUID { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of ItemTemplates. +func (_q *ItemTemplateQuery) All(ctx context.Context) ([]*ItemTemplate, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*ItemTemplate, *ItemTemplateQuery]() + return withInterceptors[[]*ItemTemplate](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *ItemTemplateQuery) AllX(ctx context.Context) []*ItemTemplate { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of ItemTemplate IDs. +func (_q *ItemTemplateQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(itemtemplate.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *ItemTemplateQuery) IDsX(ctx context.Context) []uuid.UUID { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *ItemTemplateQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*ItemTemplateQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *ItemTemplateQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *ItemTemplateQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *ItemTemplateQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ItemTemplateQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *ItemTemplateQuery) Clone() *ItemTemplateQuery { + if _q == nil { + return nil + } + return &ItemTemplateQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]itemtemplate.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.ItemTemplate{}, _q.predicates...), + withGroup: _q.withGroup.Clone(), + withFields: _q.withFields.Clone(), + withLocation: _q.withLocation.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// WithGroup tells the query-builder to eager-load the nodes that are connected to +// the "group" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ItemTemplateQuery) WithGroup(opts ...func(*GroupQuery)) *ItemTemplateQuery { + query := (&GroupClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withGroup = query + return _q +} + +// WithFields tells the query-builder to eager-load the nodes that are connected to +// the "fields" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ItemTemplateQuery) WithFields(opts ...func(*TemplateFieldQuery)) *ItemTemplateQuery { + query := (&TemplateFieldClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withFields = query + return _q +} + +// WithLocation tells the query-builder to eager-load the nodes that are connected to +// the "location" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ItemTemplateQuery) WithLocation(opts ...func(*LocationQuery)) *ItemTemplateQuery { + query := (&LocationClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withLocation = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.ItemTemplate.Query(). +// GroupBy(itemtemplate.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *ItemTemplateQuery) GroupBy(field string, fields ...string) *ItemTemplateGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &ItemTemplateGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = itemtemplate.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.ItemTemplate.Query(). +// Select(itemtemplate.FieldCreatedAt). +// Scan(ctx, &v) +func (_q *ItemTemplateQuery) Select(fields ...string) *ItemTemplateSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &ItemTemplateSelect{ItemTemplateQuery: _q} + sbuild.label = itemtemplate.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ItemTemplateSelect configured with the given aggregations. +func (_q *ItemTemplateQuery) Aggregate(fns ...AggregateFunc) *ItemTemplateSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *ItemTemplateQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !itemtemplate.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *ItemTemplateQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ItemTemplate, error) { + var ( + nodes = []*ItemTemplate{} + withFKs = _q.withFKs + _spec = _q.querySpec() + loadedTypes = [3]bool{ + _q.withGroup != nil, + _q.withFields != nil, + _q.withLocation != nil, + } + ) + if _q.withGroup != nil || _q.withLocation != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, itemtemplate.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*ItemTemplate).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &ItemTemplate{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withGroup; query != nil { + if err := _q.loadGroup(ctx, query, nodes, nil, + func(n *ItemTemplate, e *Group) { n.Edges.Group = e }); err != nil { + return nil, err + } + } + if query := _q.withFields; query != nil { + if err := _q.loadFields(ctx, query, nodes, + func(n *ItemTemplate) { n.Edges.Fields = []*TemplateField{} }, + func(n *ItemTemplate, e *TemplateField) { n.Edges.Fields = append(n.Edges.Fields, e) }); err != nil { + return nil, err + } + } + if query := _q.withLocation; query != nil { + if err := _q.loadLocation(ctx, query, nodes, nil, + func(n *ItemTemplate, e *Location) { n.Edges.Location = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *ItemTemplateQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*ItemTemplate, init func(*ItemTemplate), assign func(*ItemTemplate, *Group)) error { + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*ItemTemplate) + for i := range nodes { + if nodes[i].group_item_templates == nil { + continue + } + fk := *nodes[i].group_item_templates + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(group.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "group_item_templates" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *ItemTemplateQuery) loadFields(ctx context.Context, query *TemplateFieldQuery, nodes []*ItemTemplate, init func(*ItemTemplate), assign func(*ItemTemplate, *TemplateField)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uuid.UUID]*ItemTemplate) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.TemplateField(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(itemtemplate.FieldsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.item_template_fields + if fk == nil { + return fmt.Errorf(`foreign-key "item_template_fields" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "item_template_fields" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} +func (_q *ItemTemplateQuery) loadLocation(ctx context.Context, query *LocationQuery, nodes []*ItemTemplate, init func(*ItemTemplate), assign func(*ItemTemplate, *Location)) error { + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*ItemTemplate) + for i := range nodes { + if nodes[i].item_template_location == nil { + continue + } + fk := *nodes[i].item_template_location + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(location.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "item_template_location" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (_q *ItemTemplateQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *ItemTemplateQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(itemtemplate.Table, itemtemplate.Columns, sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, itemtemplate.FieldID) + for i := range fields { + if fields[i] != itemtemplate.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *ItemTemplateQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(itemtemplate.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = itemtemplate.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ItemTemplateGroupBy is the group-by builder for ItemTemplate entities. +type ItemTemplateGroupBy struct { + selector + build *ItemTemplateQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *ItemTemplateGroupBy) Aggregate(fns ...AggregateFunc) *ItemTemplateGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *ItemTemplateGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ItemTemplateQuery, *ItemTemplateGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *ItemTemplateGroupBy) sqlScan(ctx context.Context, root *ItemTemplateQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ItemTemplateSelect is the builder for selecting fields of ItemTemplate entities. +type ItemTemplateSelect struct { + *ItemTemplateQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *ItemTemplateSelect) Aggregate(fns ...AggregateFunc) *ItemTemplateSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *ItemTemplateSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ItemTemplateQuery, *ItemTemplateSelect](ctx, _s.ItemTemplateQuery, _s, _s.inters, v) +} + +func (_s *ItemTemplateSelect) sqlScan(ctx context.Context, root *ItemTemplateQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/backend/internal/data/ent/itemtemplate_update.go b/backend/internal/data/ent/itemtemplate_update.go new file mode 100644 index 00000000..768505ba --- /dev/null +++ b/backend/internal/data/ent/itemtemplate_update.go @@ -0,0 +1,1361 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/dialect/sql/sqljson" + "entgo.io/ent/schema/field" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield" +) + +// ItemTemplateUpdate is the builder for updating ItemTemplate entities. +type ItemTemplateUpdate struct { + config + hooks []Hook + mutation *ItemTemplateMutation +} + +// Where appends a list predicates to the ItemTemplateUpdate builder. +func (_u *ItemTemplateUpdate) Where(ps ...predicate.ItemTemplate) *ItemTemplateUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *ItemTemplateUpdate) SetUpdatedAt(v time.Time) *ItemTemplateUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetName sets the "name" field. +func (_u *ItemTemplateUpdate) SetName(v string) *ItemTemplateUpdate { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *ItemTemplateUpdate) SetNillableName(v *string) *ItemTemplateUpdate { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetDescription sets the "description" field. +func (_u *ItemTemplateUpdate) SetDescription(v string) *ItemTemplateUpdate { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *ItemTemplateUpdate) SetNillableDescription(v *string) *ItemTemplateUpdate { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// ClearDescription clears the value of the "description" field. +func (_u *ItemTemplateUpdate) ClearDescription() *ItemTemplateUpdate { + _u.mutation.ClearDescription() + return _u +} + +// SetNotes sets the "notes" field. +func (_u *ItemTemplateUpdate) SetNotes(v string) *ItemTemplateUpdate { + _u.mutation.SetNotes(v) + return _u +} + +// SetNillableNotes sets the "notes" field if the given value is not nil. +func (_u *ItemTemplateUpdate) SetNillableNotes(v *string) *ItemTemplateUpdate { + if v != nil { + _u.SetNotes(*v) + } + return _u +} + +// ClearNotes clears the value of the "notes" field. +func (_u *ItemTemplateUpdate) ClearNotes() *ItemTemplateUpdate { + _u.mutation.ClearNotes() + return _u +} + +// SetDefaultQuantity sets the "default_quantity" field. +func (_u *ItemTemplateUpdate) SetDefaultQuantity(v int) *ItemTemplateUpdate { + _u.mutation.ResetDefaultQuantity() + _u.mutation.SetDefaultQuantity(v) + return _u +} + +// SetNillableDefaultQuantity sets the "default_quantity" field if the given value is not nil. +func (_u *ItemTemplateUpdate) SetNillableDefaultQuantity(v *int) *ItemTemplateUpdate { + if v != nil { + _u.SetDefaultQuantity(*v) + } + return _u +} + +// AddDefaultQuantity adds value to the "default_quantity" field. +func (_u *ItemTemplateUpdate) AddDefaultQuantity(v int) *ItemTemplateUpdate { + _u.mutation.AddDefaultQuantity(v) + return _u +} + +// SetDefaultInsured sets the "default_insured" field. +func (_u *ItemTemplateUpdate) SetDefaultInsured(v bool) *ItemTemplateUpdate { + _u.mutation.SetDefaultInsured(v) + return _u +} + +// SetNillableDefaultInsured sets the "default_insured" field if the given value is not nil. +func (_u *ItemTemplateUpdate) SetNillableDefaultInsured(v *bool) *ItemTemplateUpdate { + if v != nil { + _u.SetDefaultInsured(*v) + } + return _u +} + +// SetDefaultName sets the "default_name" field. +func (_u *ItemTemplateUpdate) SetDefaultName(v string) *ItemTemplateUpdate { + _u.mutation.SetDefaultName(v) + return _u +} + +// SetNillableDefaultName sets the "default_name" field if the given value is not nil. +func (_u *ItemTemplateUpdate) SetNillableDefaultName(v *string) *ItemTemplateUpdate { + if v != nil { + _u.SetDefaultName(*v) + } + return _u +} + +// ClearDefaultName clears the value of the "default_name" field. +func (_u *ItemTemplateUpdate) ClearDefaultName() *ItemTemplateUpdate { + _u.mutation.ClearDefaultName() + return _u +} + +// SetDefaultDescription sets the "default_description" field. +func (_u *ItemTemplateUpdate) SetDefaultDescription(v string) *ItemTemplateUpdate { + _u.mutation.SetDefaultDescription(v) + return _u +} + +// SetNillableDefaultDescription sets the "default_description" field if the given value is not nil. +func (_u *ItemTemplateUpdate) SetNillableDefaultDescription(v *string) *ItemTemplateUpdate { + if v != nil { + _u.SetDefaultDescription(*v) + } + return _u +} + +// ClearDefaultDescription clears the value of the "default_description" field. +func (_u *ItemTemplateUpdate) ClearDefaultDescription() *ItemTemplateUpdate { + _u.mutation.ClearDefaultDescription() + return _u +} + +// SetDefaultManufacturer sets the "default_manufacturer" field. +func (_u *ItemTemplateUpdate) SetDefaultManufacturer(v string) *ItemTemplateUpdate { + _u.mutation.SetDefaultManufacturer(v) + return _u +} + +// SetNillableDefaultManufacturer sets the "default_manufacturer" field if the given value is not nil. +func (_u *ItemTemplateUpdate) SetNillableDefaultManufacturer(v *string) *ItemTemplateUpdate { + if v != nil { + _u.SetDefaultManufacturer(*v) + } + return _u +} + +// ClearDefaultManufacturer clears the value of the "default_manufacturer" field. +func (_u *ItemTemplateUpdate) ClearDefaultManufacturer() *ItemTemplateUpdate { + _u.mutation.ClearDefaultManufacturer() + return _u +} + +// SetDefaultModelNumber sets the "default_model_number" field. +func (_u *ItemTemplateUpdate) SetDefaultModelNumber(v string) *ItemTemplateUpdate { + _u.mutation.SetDefaultModelNumber(v) + return _u +} + +// SetNillableDefaultModelNumber sets the "default_model_number" field if the given value is not nil. +func (_u *ItemTemplateUpdate) SetNillableDefaultModelNumber(v *string) *ItemTemplateUpdate { + if v != nil { + _u.SetDefaultModelNumber(*v) + } + return _u +} + +// ClearDefaultModelNumber clears the value of the "default_model_number" field. +func (_u *ItemTemplateUpdate) ClearDefaultModelNumber() *ItemTemplateUpdate { + _u.mutation.ClearDefaultModelNumber() + return _u +} + +// SetDefaultLifetimeWarranty sets the "default_lifetime_warranty" field. +func (_u *ItemTemplateUpdate) SetDefaultLifetimeWarranty(v bool) *ItemTemplateUpdate { + _u.mutation.SetDefaultLifetimeWarranty(v) + return _u +} + +// SetNillableDefaultLifetimeWarranty sets the "default_lifetime_warranty" field if the given value is not nil. +func (_u *ItemTemplateUpdate) SetNillableDefaultLifetimeWarranty(v *bool) *ItemTemplateUpdate { + if v != nil { + _u.SetDefaultLifetimeWarranty(*v) + } + return _u +} + +// SetDefaultWarrantyDetails sets the "default_warranty_details" field. +func (_u *ItemTemplateUpdate) SetDefaultWarrantyDetails(v string) *ItemTemplateUpdate { + _u.mutation.SetDefaultWarrantyDetails(v) + return _u +} + +// SetNillableDefaultWarrantyDetails sets the "default_warranty_details" field if the given value is not nil. +func (_u *ItemTemplateUpdate) SetNillableDefaultWarrantyDetails(v *string) *ItemTemplateUpdate { + if v != nil { + _u.SetDefaultWarrantyDetails(*v) + } + return _u +} + +// ClearDefaultWarrantyDetails clears the value of the "default_warranty_details" field. +func (_u *ItemTemplateUpdate) ClearDefaultWarrantyDetails() *ItemTemplateUpdate { + _u.mutation.ClearDefaultWarrantyDetails() + return _u +} + +// SetIncludeWarrantyFields sets the "include_warranty_fields" field. +func (_u *ItemTemplateUpdate) SetIncludeWarrantyFields(v bool) *ItemTemplateUpdate { + _u.mutation.SetIncludeWarrantyFields(v) + return _u +} + +// SetNillableIncludeWarrantyFields sets the "include_warranty_fields" field if the given value is not nil. +func (_u *ItemTemplateUpdate) SetNillableIncludeWarrantyFields(v *bool) *ItemTemplateUpdate { + if v != nil { + _u.SetIncludeWarrantyFields(*v) + } + return _u +} + +// SetIncludePurchaseFields sets the "include_purchase_fields" field. +func (_u *ItemTemplateUpdate) SetIncludePurchaseFields(v bool) *ItemTemplateUpdate { + _u.mutation.SetIncludePurchaseFields(v) + return _u +} + +// SetNillableIncludePurchaseFields sets the "include_purchase_fields" field if the given value is not nil. +func (_u *ItemTemplateUpdate) SetNillableIncludePurchaseFields(v *bool) *ItemTemplateUpdate { + if v != nil { + _u.SetIncludePurchaseFields(*v) + } + return _u +} + +// SetIncludeSoldFields sets the "include_sold_fields" field. +func (_u *ItemTemplateUpdate) SetIncludeSoldFields(v bool) *ItemTemplateUpdate { + _u.mutation.SetIncludeSoldFields(v) + return _u +} + +// SetNillableIncludeSoldFields sets the "include_sold_fields" field if the given value is not nil. +func (_u *ItemTemplateUpdate) SetNillableIncludeSoldFields(v *bool) *ItemTemplateUpdate { + if v != nil { + _u.SetIncludeSoldFields(*v) + } + return _u +} + +// SetDefaultLabelIds sets the "default_label_ids" field. +func (_u *ItemTemplateUpdate) SetDefaultLabelIds(v []uuid.UUID) *ItemTemplateUpdate { + _u.mutation.SetDefaultLabelIds(v) + return _u +} + +// AppendDefaultLabelIds appends value to the "default_label_ids" field. +func (_u *ItemTemplateUpdate) AppendDefaultLabelIds(v []uuid.UUID) *ItemTemplateUpdate { + _u.mutation.AppendDefaultLabelIds(v) + return _u +} + +// ClearDefaultLabelIds clears the value of the "default_label_ids" field. +func (_u *ItemTemplateUpdate) ClearDefaultLabelIds() *ItemTemplateUpdate { + _u.mutation.ClearDefaultLabelIds() + return _u +} + +// SetGroupID sets the "group" edge to the Group entity by ID. +func (_u *ItemTemplateUpdate) SetGroupID(id uuid.UUID) *ItemTemplateUpdate { + _u.mutation.SetGroupID(id) + return _u +} + +// SetGroup sets the "group" edge to the Group entity. +func (_u *ItemTemplateUpdate) SetGroup(v *Group) *ItemTemplateUpdate { + return _u.SetGroupID(v.ID) +} + +// AddFieldIDs adds the "fields" edge to the TemplateField entity by IDs. +func (_u *ItemTemplateUpdate) AddFieldIDs(ids ...uuid.UUID) *ItemTemplateUpdate { + _u.mutation.AddFieldIDs(ids...) + return _u +} + +// AddFields adds the "fields" edges to the TemplateField entity. +func (_u *ItemTemplateUpdate) AddFields(v ...*TemplateField) *ItemTemplateUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddFieldIDs(ids...) +} + +// SetLocationID sets the "location" edge to the Location entity by ID. +func (_u *ItemTemplateUpdate) SetLocationID(id uuid.UUID) *ItemTemplateUpdate { + _u.mutation.SetLocationID(id) + return _u +} + +// SetNillableLocationID sets the "location" edge to the Location entity by ID if the given value is not nil. +func (_u *ItemTemplateUpdate) SetNillableLocationID(id *uuid.UUID) *ItemTemplateUpdate { + if id != nil { + _u = _u.SetLocationID(*id) + } + return _u +} + +// SetLocation sets the "location" edge to the Location entity. +func (_u *ItemTemplateUpdate) SetLocation(v *Location) *ItemTemplateUpdate { + return _u.SetLocationID(v.ID) +} + +// Mutation returns the ItemTemplateMutation object of the builder. +func (_u *ItemTemplateUpdate) Mutation() *ItemTemplateMutation { + return _u.mutation +} + +// ClearGroup clears the "group" edge to the Group entity. +func (_u *ItemTemplateUpdate) ClearGroup() *ItemTemplateUpdate { + _u.mutation.ClearGroup() + return _u +} + +// ClearFields clears all "fields" edges to the TemplateField entity. +func (_u *ItemTemplateUpdate) ClearFields() *ItemTemplateUpdate { + _u.mutation.ClearFields() + return _u +} + +// RemoveFieldIDs removes the "fields" edge to TemplateField entities by IDs. +func (_u *ItemTemplateUpdate) RemoveFieldIDs(ids ...uuid.UUID) *ItemTemplateUpdate { + _u.mutation.RemoveFieldIDs(ids...) + return _u +} + +// RemoveFields removes "fields" edges to TemplateField entities. +func (_u *ItemTemplateUpdate) RemoveFields(v ...*TemplateField) *ItemTemplateUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveFieldIDs(ids...) +} + +// ClearLocation clears the "location" edge to the Location entity. +func (_u *ItemTemplateUpdate) ClearLocation() *ItemTemplateUpdate { + _u.mutation.ClearLocation() + return _u +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *ItemTemplateUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *ItemTemplateUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *ItemTemplateUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *ItemTemplateUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *ItemTemplateUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := itemtemplate.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *ItemTemplateUpdate) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := itemtemplate.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.name": %w`, err)} + } + } + if v, ok := _u.mutation.Description(); ok { + if err := itemtemplate.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.description": %w`, err)} + } + } + if v, ok := _u.mutation.Notes(); ok { + if err := itemtemplate.NotesValidator(v); err != nil { + return &ValidationError{Name: "notes", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.notes": %w`, err)} + } + } + if v, ok := _u.mutation.DefaultName(); ok { + if err := itemtemplate.DefaultNameValidator(v); err != nil { + return &ValidationError{Name: "default_name", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_name": %w`, err)} + } + } + if v, ok := _u.mutation.DefaultDescription(); ok { + if err := itemtemplate.DefaultDescriptionValidator(v); err != nil { + return &ValidationError{Name: "default_description", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_description": %w`, err)} + } + } + if v, ok := _u.mutation.DefaultManufacturer(); ok { + if err := itemtemplate.DefaultManufacturerValidator(v); err != nil { + return &ValidationError{Name: "default_manufacturer", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_manufacturer": %w`, err)} + } + } + if v, ok := _u.mutation.DefaultModelNumber(); ok { + if err := itemtemplate.DefaultModelNumberValidator(v); err != nil { + return &ValidationError{Name: "default_model_number", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_model_number": %w`, err)} + } + } + if v, ok := _u.mutation.DefaultWarrantyDetails(); ok { + if err := itemtemplate.DefaultWarrantyDetailsValidator(v); err != nil { + return &ValidationError{Name: "default_warranty_details", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_warranty_details": %w`, err)} + } + } + if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ItemTemplate.group"`) + } + return nil +} + +func (_u *ItemTemplateUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(itemtemplate.Table, itemtemplate.Columns, sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(itemtemplate.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(itemtemplate.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(itemtemplate.FieldDescription, field.TypeString, value) + } + if _u.mutation.DescriptionCleared() { + _spec.ClearField(itemtemplate.FieldDescription, field.TypeString) + } + if value, ok := _u.mutation.Notes(); ok { + _spec.SetField(itemtemplate.FieldNotes, field.TypeString, value) + } + if _u.mutation.NotesCleared() { + _spec.ClearField(itemtemplate.FieldNotes, field.TypeString) + } + if value, ok := _u.mutation.DefaultQuantity(); ok { + _spec.SetField(itemtemplate.FieldDefaultQuantity, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedDefaultQuantity(); ok { + _spec.AddField(itemtemplate.FieldDefaultQuantity, field.TypeInt, value) + } + if value, ok := _u.mutation.DefaultInsured(); ok { + _spec.SetField(itemtemplate.FieldDefaultInsured, field.TypeBool, value) + } + if value, ok := _u.mutation.DefaultName(); ok { + _spec.SetField(itemtemplate.FieldDefaultName, field.TypeString, value) + } + if _u.mutation.DefaultNameCleared() { + _spec.ClearField(itemtemplate.FieldDefaultName, field.TypeString) + } + if value, ok := _u.mutation.DefaultDescription(); ok { + _spec.SetField(itemtemplate.FieldDefaultDescription, field.TypeString, value) + } + if _u.mutation.DefaultDescriptionCleared() { + _spec.ClearField(itemtemplate.FieldDefaultDescription, field.TypeString) + } + if value, ok := _u.mutation.DefaultManufacturer(); ok { + _spec.SetField(itemtemplate.FieldDefaultManufacturer, field.TypeString, value) + } + if _u.mutation.DefaultManufacturerCleared() { + _spec.ClearField(itemtemplate.FieldDefaultManufacturer, field.TypeString) + } + if value, ok := _u.mutation.DefaultModelNumber(); ok { + _spec.SetField(itemtemplate.FieldDefaultModelNumber, field.TypeString, value) + } + if _u.mutation.DefaultModelNumberCleared() { + _spec.ClearField(itemtemplate.FieldDefaultModelNumber, field.TypeString) + } + if value, ok := _u.mutation.DefaultLifetimeWarranty(); ok { + _spec.SetField(itemtemplate.FieldDefaultLifetimeWarranty, field.TypeBool, value) + } + if value, ok := _u.mutation.DefaultWarrantyDetails(); ok { + _spec.SetField(itemtemplate.FieldDefaultWarrantyDetails, field.TypeString, value) + } + if _u.mutation.DefaultWarrantyDetailsCleared() { + _spec.ClearField(itemtemplate.FieldDefaultWarrantyDetails, field.TypeString) + } + if value, ok := _u.mutation.IncludeWarrantyFields(); ok { + _spec.SetField(itemtemplate.FieldIncludeWarrantyFields, field.TypeBool, value) + } + if value, ok := _u.mutation.IncludePurchaseFields(); ok { + _spec.SetField(itemtemplate.FieldIncludePurchaseFields, field.TypeBool, value) + } + if value, ok := _u.mutation.IncludeSoldFields(); ok { + _spec.SetField(itemtemplate.FieldIncludeSoldFields, field.TypeBool, value) + } + if value, ok := _u.mutation.DefaultLabelIds(); ok { + _spec.SetField(itemtemplate.FieldDefaultLabelIds, field.TypeJSON, value) + } + if value, ok := _u.mutation.AppendedDefaultLabelIds(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, itemtemplate.FieldDefaultLabelIds, value) + }) + } + if _u.mutation.DefaultLabelIdsCleared() { + _spec.ClearField(itemtemplate.FieldDefaultLabelIds, field.TypeJSON) + } + if _u.mutation.GroupCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: itemtemplate.GroupTable, + Columns: []string{itemtemplate.GroupColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: itemtemplate.GroupTable, + Columns: []string{itemtemplate.GroupColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.FieldsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: itemtemplate.FieldsTable, + Columns: []string{itemtemplate.FieldsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedFieldsIDs(); len(nodes) > 0 && !_u.mutation.FieldsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: itemtemplate.FieldsTable, + Columns: []string{itemtemplate.FieldsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.FieldsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: itemtemplate.FieldsTable, + Columns: []string{itemtemplate.FieldsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.LocationCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: itemtemplate.LocationTable, + Columns: []string{itemtemplate.LocationColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.LocationIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: itemtemplate.LocationTable, + Columns: []string{itemtemplate.LocationColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{itemtemplate.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// ItemTemplateUpdateOne is the builder for updating a single ItemTemplate entity. +type ItemTemplateUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ItemTemplateMutation +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *ItemTemplateUpdateOne) SetUpdatedAt(v time.Time) *ItemTemplateUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetName sets the "name" field. +func (_u *ItemTemplateUpdateOne) SetName(v string) *ItemTemplateUpdateOne { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *ItemTemplateUpdateOne) SetNillableName(v *string) *ItemTemplateUpdateOne { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetDescription sets the "description" field. +func (_u *ItemTemplateUpdateOne) SetDescription(v string) *ItemTemplateUpdateOne { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *ItemTemplateUpdateOne) SetNillableDescription(v *string) *ItemTemplateUpdateOne { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// ClearDescription clears the value of the "description" field. +func (_u *ItemTemplateUpdateOne) ClearDescription() *ItemTemplateUpdateOne { + _u.mutation.ClearDescription() + return _u +} + +// SetNotes sets the "notes" field. +func (_u *ItemTemplateUpdateOne) SetNotes(v string) *ItemTemplateUpdateOne { + _u.mutation.SetNotes(v) + return _u +} + +// SetNillableNotes sets the "notes" field if the given value is not nil. +func (_u *ItemTemplateUpdateOne) SetNillableNotes(v *string) *ItemTemplateUpdateOne { + if v != nil { + _u.SetNotes(*v) + } + return _u +} + +// ClearNotes clears the value of the "notes" field. +func (_u *ItemTemplateUpdateOne) ClearNotes() *ItemTemplateUpdateOne { + _u.mutation.ClearNotes() + return _u +} + +// SetDefaultQuantity sets the "default_quantity" field. +func (_u *ItemTemplateUpdateOne) SetDefaultQuantity(v int) *ItemTemplateUpdateOne { + _u.mutation.ResetDefaultQuantity() + _u.mutation.SetDefaultQuantity(v) + return _u +} + +// SetNillableDefaultQuantity sets the "default_quantity" field if the given value is not nil. +func (_u *ItemTemplateUpdateOne) SetNillableDefaultQuantity(v *int) *ItemTemplateUpdateOne { + if v != nil { + _u.SetDefaultQuantity(*v) + } + return _u +} + +// AddDefaultQuantity adds value to the "default_quantity" field. +func (_u *ItemTemplateUpdateOne) AddDefaultQuantity(v int) *ItemTemplateUpdateOne { + _u.mutation.AddDefaultQuantity(v) + return _u +} + +// SetDefaultInsured sets the "default_insured" field. +func (_u *ItemTemplateUpdateOne) SetDefaultInsured(v bool) *ItemTemplateUpdateOne { + _u.mutation.SetDefaultInsured(v) + return _u +} + +// SetNillableDefaultInsured sets the "default_insured" field if the given value is not nil. +func (_u *ItemTemplateUpdateOne) SetNillableDefaultInsured(v *bool) *ItemTemplateUpdateOne { + if v != nil { + _u.SetDefaultInsured(*v) + } + return _u +} + +// SetDefaultName sets the "default_name" field. +func (_u *ItemTemplateUpdateOne) SetDefaultName(v string) *ItemTemplateUpdateOne { + _u.mutation.SetDefaultName(v) + return _u +} + +// SetNillableDefaultName sets the "default_name" field if the given value is not nil. +func (_u *ItemTemplateUpdateOne) SetNillableDefaultName(v *string) *ItemTemplateUpdateOne { + if v != nil { + _u.SetDefaultName(*v) + } + return _u +} + +// ClearDefaultName clears the value of the "default_name" field. +func (_u *ItemTemplateUpdateOne) ClearDefaultName() *ItemTemplateUpdateOne { + _u.mutation.ClearDefaultName() + return _u +} + +// SetDefaultDescription sets the "default_description" field. +func (_u *ItemTemplateUpdateOne) SetDefaultDescription(v string) *ItemTemplateUpdateOne { + _u.mutation.SetDefaultDescription(v) + return _u +} + +// SetNillableDefaultDescription sets the "default_description" field if the given value is not nil. +func (_u *ItemTemplateUpdateOne) SetNillableDefaultDescription(v *string) *ItemTemplateUpdateOne { + if v != nil { + _u.SetDefaultDescription(*v) + } + return _u +} + +// ClearDefaultDescription clears the value of the "default_description" field. +func (_u *ItemTemplateUpdateOne) ClearDefaultDescription() *ItemTemplateUpdateOne { + _u.mutation.ClearDefaultDescription() + return _u +} + +// SetDefaultManufacturer sets the "default_manufacturer" field. +func (_u *ItemTemplateUpdateOne) SetDefaultManufacturer(v string) *ItemTemplateUpdateOne { + _u.mutation.SetDefaultManufacturer(v) + return _u +} + +// SetNillableDefaultManufacturer sets the "default_manufacturer" field if the given value is not nil. +func (_u *ItemTemplateUpdateOne) SetNillableDefaultManufacturer(v *string) *ItemTemplateUpdateOne { + if v != nil { + _u.SetDefaultManufacturer(*v) + } + return _u +} + +// ClearDefaultManufacturer clears the value of the "default_manufacturer" field. +func (_u *ItemTemplateUpdateOne) ClearDefaultManufacturer() *ItemTemplateUpdateOne { + _u.mutation.ClearDefaultManufacturer() + return _u +} + +// SetDefaultModelNumber sets the "default_model_number" field. +func (_u *ItemTemplateUpdateOne) SetDefaultModelNumber(v string) *ItemTemplateUpdateOne { + _u.mutation.SetDefaultModelNumber(v) + return _u +} + +// SetNillableDefaultModelNumber sets the "default_model_number" field if the given value is not nil. +func (_u *ItemTemplateUpdateOne) SetNillableDefaultModelNumber(v *string) *ItemTemplateUpdateOne { + if v != nil { + _u.SetDefaultModelNumber(*v) + } + return _u +} + +// ClearDefaultModelNumber clears the value of the "default_model_number" field. +func (_u *ItemTemplateUpdateOne) ClearDefaultModelNumber() *ItemTemplateUpdateOne { + _u.mutation.ClearDefaultModelNumber() + return _u +} + +// SetDefaultLifetimeWarranty sets the "default_lifetime_warranty" field. +func (_u *ItemTemplateUpdateOne) SetDefaultLifetimeWarranty(v bool) *ItemTemplateUpdateOne { + _u.mutation.SetDefaultLifetimeWarranty(v) + return _u +} + +// SetNillableDefaultLifetimeWarranty sets the "default_lifetime_warranty" field if the given value is not nil. +func (_u *ItemTemplateUpdateOne) SetNillableDefaultLifetimeWarranty(v *bool) *ItemTemplateUpdateOne { + if v != nil { + _u.SetDefaultLifetimeWarranty(*v) + } + return _u +} + +// SetDefaultWarrantyDetails sets the "default_warranty_details" field. +func (_u *ItemTemplateUpdateOne) SetDefaultWarrantyDetails(v string) *ItemTemplateUpdateOne { + _u.mutation.SetDefaultWarrantyDetails(v) + return _u +} + +// SetNillableDefaultWarrantyDetails sets the "default_warranty_details" field if the given value is not nil. +func (_u *ItemTemplateUpdateOne) SetNillableDefaultWarrantyDetails(v *string) *ItemTemplateUpdateOne { + if v != nil { + _u.SetDefaultWarrantyDetails(*v) + } + return _u +} + +// ClearDefaultWarrantyDetails clears the value of the "default_warranty_details" field. +func (_u *ItemTemplateUpdateOne) ClearDefaultWarrantyDetails() *ItemTemplateUpdateOne { + _u.mutation.ClearDefaultWarrantyDetails() + return _u +} + +// SetIncludeWarrantyFields sets the "include_warranty_fields" field. +func (_u *ItemTemplateUpdateOne) SetIncludeWarrantyFields(v bool) *ItemTemplateUpdateOne { + _u.mutation.SetIncludeWarrantyFields(v) + return _u +} + +// SetNillableIncludeWarrantyFields sets the "include_warranty_fields" field if the given value is not nil. +func (_u *ItemTemplateUpdateOne) SetNillableIncludeWarrantyFields(v *bool) *ItemTemplateUpdateOne { + if v != nil { + _u.SetIncludeWarrantyFields(*v) + } + return _u +} + +// SetIncludePurchaseFields sets the "include_purchase_fields" field. +func (_u *ItemTemplateUpdateOne) SetIncludePurchaseFields(v bool) *ItemTemplateUpdateOne { + _u.mutation.SetIncludePurchaseFields(v) + return _u +} + +// SetNillableIncludePurchaseFields sets the "include_purchase_fields" field if the given value is not nil. +func (_u *ItemTemplateUpdateOne) SetNillableIncludePurchaseFields(v *bool) *ItemTemplateUpdateOne { + if v != nil { + _u.SetIncludePurchaseFields(*v) + } + return _u +} + +// SetIncludeSoldFields sets the "include_sold_fields" field. +func (_u *ItemTemplateUpdateOne) SetIncludeSoldFields(v bool) *ItemTemplateUpdateOne { + _u.mutation.SetIncludeSoldFields(v) + return _u +} + +// SetNillableIncludeSoldFields sets the "include_sold_fields" field if the given value is not nil. +func (_u *ItemTemplateUpdateOne) SetNillableIncludeSoldFields(v *bool) *ItemTemplateUpdateOne { + if v != nil { + _u.SetIncludeSoldFields(*v) + } + return _u +} + +// SetDefaultLabelIds sets the "default_label_ids" field. +func (_u *ItemTemplateUpdateOne) SetDefaultLabelIds(v []uuid.UUID) *ItemTemplateUpdateOne { + _u.mutation.SetDefaultLabelIds(v) + return _u +} + +// AppendDefaultLabelIds appends value to the "default_label_ids" field. +func (_u *ItemTemplateUpdateOne) AppendDefaultLabelIds(v []uuid.UUID) *ItemTemplateUpdateOne { + _u.mutation.AppendDefaultLabelIds(v) + return _u +} + +// ClearDefaultLabelIds clears the value of the "default_label_ids" field. +func (_u *ItemTemplateUpdateOne) ClearDefaultLabelIds() *ItemTemplateUpdateOne { + _u.mutation.ClearDefaultLabelIds() + return _u +} + +// SetGroupID sets the "group" edge to the Group entity by ID. +func (_u *ItemTemplateUpdateOne) SetGroupID(id uuid.UUID) *ItemTemplateUpdateOne { + _u.mutation.SetGroupID(id) + return _u +} + +// SetGroup sets the "group" edge to the Group entity. +func (_u *ItemTemplateUpdateOne) SetGroup(v *Group) *ItemTemplateUpdateOne { + return _u.SetGroupID(v.ID) +} + +// AddFieldIDs adds the "fields" edge to the TemplateField entity by IDs. +func (_u *ItemTemplateUpdateOne) AddFieldIDs(ids ...uuid.UUID) *ItemTemplateUpdateOne { + _u.mutation.AddFieldIDs(ids...) + return _u +} + +// AddFields adds the "fields" edges to the TemplateField entity. +func (_u *ItemTemplateUpdateOne) AddFields(v ...*TemplateField) *ItemTemplateUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddFieldIDs(ids...) +} + +// SetLocationID sets the "location" edge to the Location entity by ID. +func (_u *ItemTemplateUpdateOne) SetLocationID(id uuid.UUID) *ItemTemplateUpdateOne { + _u.mutation.SetLocationID(id) + return _u +} + +// SetNillableLocationID sets the "location" edge to the Location entity by ID if the given value is not nil. +func (_u *ItemTemplateUpdateOne) SetNillableLocationID(id *uuid.UUID) *ItemTemplateUpdateOne { + if id != nil { + _u = _u.SetLocationID(*id) + } + return _u +} + +// SetLocation sets the "location" edge to the Location entity. +func (_u *ItemTemplateUpdateOne) SetLocation(v *Location) *ItemTemplateUpdateOne { + return _u.SetLocationID(v.ID) +} + +// Mutation returns the ItemTemplateMutation object of the builder. +func (_u *ItemTemplateUpdateOne) Mutation() *ItemTemplateMutation { + return _u.mutation +} + +// ClearGroup clears the "group" edge to the Group entity. +func (_u *ItemTemplateUpdateOne) ClearGroup() *ItemTemplateUpdateOne { + _u.mutation.ClearGroup() + return _u +} + +// ClearFields clears all "fields" edges to the TemplateField entity. +func (_u *ItemTemplateUpdateOne) ClearFields() *ItemTemplateUpdateOne { + _u.mutation.ClearFields() + return _u +} + +// RemoveFieldIDs removes the "fields" edge to TemplateField entities by IDs. +func (_u *ItemTemplateUpdateOne) RemoveFieldIDs(ids ...uuid.UUID) *ItemTemplateUpdateOne { + _u.mutation.RemoveFieldIDs(ids...) + return _u +} + +// RemoveFields removes "fields" edges to TemplateField entities. +func (_u *ItemTemplateUpdateOne) RemoveFields(v ...*TemplateField) *ItemTemplateUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveFieldIDs(ids...) +} + +// ClearLocation clears the "location" edge to the Location entity. +func (_u *ItemTemplateUpdateOne) ClearLocation() *ItemTemplateUpdateOne { + _u.mutation.ClearLocation() + return _u +} + +// Where appends a list predicates to the ItemTemplateUpdate builder. +func (_u *ItemTemplateUpdateOne) Where(ps ...predicate.ItemTemplate) *ItemTemplateUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *ItemTemplateUpdateOne) Select(field string, fields ...string) *ItemTemplateUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated ItemTemplate entity. +func (_u *ItemTemplateUpdateOne) Save(ctx context.Context) (*ItemTemplate, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *ItemTemplateUpdateOne) SaveX(ctx context.Context) *ItemTemplate { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *ItemTemplateUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *ItemTemplateUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *ItemTemplateUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := itemtemplate.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *ItemTemplateUpdateOne) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := itemtemplate.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.name": %w`, err)} + } + } + if v, ok := _u.mutation.Description(); ok { + if err := itemtemplate.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.description": %w`, err)} + } + } + if v, ok := _u.mutation.Notes(); ok { + if err := itemtemplate.NotesValidator(v); err != nil { + return &ValidationError{Name: "notes", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.notes": %w`, err)} + } + } + if v, ok := _u.mutation.DefaultName(); ok { + if err := itemtemplate.DefaultNameValidator(v); err != nil { + return &ValidationError{Name: "default_name", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_name": %w`, err)} + } + } + if v, ok := _u.mutation.DefaultDescription(); ok { + if err := itemtemplate.DefaultDescriptionValidator(v); err != nil { + return &ValidationError{Name: "default_description", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_description": %w`, err)} + } + } + if v, ok := _u.mutation.DefaultManufacturer(); ok { + if err := itemtemplate.DefaultManufacturerValidator(v); err != nil { + return &ValidationError{Name: "default_manufacturer", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_manufacturer": %w`, err)} + } + } + if v, ok := _u.mutation.DefaultModelNumber(); ok { + if err := itemtemplate.DefaultModelNumberValidator(v); err != nil { + return &ValidationError{Name: "default_model_number", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_model_number": %w`, err)} + } + } + if v, ok := _u.mutation.DefaultWarrantyDetails(); ok { + if err := itemtemplate.DefaultWarrantyDetailsValidator(v); err != nil { + return &ValidationError{Name: "default_warranty_details", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_warranty_details": %w`, err)} + } + } + if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ItemTemplate.group"`) + } + return nil +} + +func (_u *ItemTemplateUpdateOne) sqlSave(ctx context.Context) (_node *ItemTemplate, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(itemtemplate.Table, itemtemplate.Columns, sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ItemTemplate.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, itemtemplate.FieldID) + for _, f := range fields { + if !itemtemplate.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != itemtemplate.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(itemtemplate.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(itemtemplate.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(itemtemplate.FieldDescription, field.TypeString, value) + } + if _u.mutation.DescriptionCleared() { + _spec.ClearField(itemtemplate.FieldDescription, field.TypeString) + } + if value, ok := _u.mutation.Notes(); ok { + _spec.SetField(itemtemplate.FieldNotes, field.TypeString, value) + } + if _u.mutation.NotesCleared() { + _spec.ClearField(itemtemplate.FieldNotes, field.TypeString) + } + if value, ok := _u.mutation.DefaultQuantity(); ok { + _spec.SetField(itemtemplate.FieldDefaultQuantity, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedDefaultQuantity(); ok { + _spec.AddField(itemtemplate.FieldDefaultQuantity, field.TypeInt, value) + } + if value, ok := _u.mutation.DefaultInsured(); ok { + _spec.SetField(itemtemplate.FieldDefaultInsured, field.TypeBool, value) + } + if value, ok := _u.mutation.DefaultName(); ok { + _spec.SetField(itemtemplate.FieldDefaultName, field.TypeString, value) + } + if _u.mutation.DefaultNameCleared() { + _spec.ClearField(itemtemplate.FieldDefaultName, field.TypeString) + } + if value, ok := _u.mutation.DefaultDescription(); ok { + _spec.SetField(itemtemplate.FieldDefaultDescription, field.TypeString, value) + } + if _u.mutation.DefaultDescriptionCleared() { + _spec.ClearField(itemtemplate.FieldDefaultDescription, field.TypeString) + } + if value, ok := _u.mutation.DefaultManufacturer(); ok { + _spec.SetField(itemtemplate.FieldDefaultManufacturer, field.TypeString, value) + } + if _u.mutation.DefaultManufacturerCleared() { + _spec.ClearField(itemtemplate.FieldDefaultManufacturer, field.TypeString) + } + if value, ok := _u.mutation.DefaultModelNumber(); ok { + _spec.SetField(itemtemplate.FieldDefaultModelNumber, field.TypeString, value) + } + if _u.mutation.DefaultModelNumberCleared() { + _spec.ClearField(itemtemplate.FieldDefaultModelNumber, field.TypeString) + } + if value, ok := _u.mutation.DefaultLifetimeWarranty(); ok { + _spec.SetField(itemtemplate.FieldDefaultLifetimeWarranty, field.TypeBool, value) + } + if value, ok := _u.mutation.DefaultWarrantyDetails(); ok { + _spec.SetField(itemtemplate.FieldDefaultWarrantyDetails, field.TypeString, value) + } + if _u.mutation.DefaultWarrantyDetailsCleared() { + _spec.ClearField(itemtemplate.FieldDefaultWarrantyDetails, field.TypeString) + } + if value, ok := _u.mutation.IncludeWarrantyFields(); ok { + _spec.SetField(itemtemplate.FieldIncludeWarrantyFields, field.TypeBool, value) + } + if value, ok := _u.mutation.IncludePurchaseFields(); ok { + _spec.SetField(itemtemplate.FieldIncludePurchaseFields, field.TypeBool, value) + } + if value, ok := _u.mutation.IncludeSoldFields(); ok { + _spec.SetField(itemtemplate.FieldIncludeSoldFields, field.TypeBool, value) + } + if value, ok := _u.mutation.DefaultLabelIds(); ok { + _spec.SetField(itemtemplate.FieldDefaultLabelIds, field.TypeJSON, value) + } + if value, ok := _u.mutation.AppendedDefaultLabelIds(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, itemtemplate.FieldDefaultLabelIds, value) + }) + } + if _u.mutation.DefaultLabelIdsCleared() { + _spec.ClearField(itemtemplate.FieldDefaultLabelIds, field.TypeJSON) + } + if _u.mutation.GroupCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: itemtemplate.GroupTable, + Columns: []string{itemtemplate.GroupColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: itemtemplate.GroupTable, + Columns: []string{itemtemplate.GroupColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.FieldsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: itemtemplate.FieldsTable, + Columns: []string{itemtemplate.FieldsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedFieldsIDs(); len(nodes) > 0 && !_u.mutation.FieldsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: itemtemplate.FieldsTable, + Columns: []string{itemtemplate.FieldsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.FieldsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: itemtemplate.FieldsTable, + Columns: []string{itemtemplate.FieldsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.LocationCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: itemtemplate.LocationTable, + Columns: []string{itemtemplate.LocationColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.LocationIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: itemtemplate.LocationTable, + Columns: []string{itemtemplate.LocationColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &ItemTemplate{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{itemtemplate.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/backend/internal/data/ent/label.go b/backend/internal/data/ent/label.go index 92eccd32..8203bd5d 100644 --- a/backend/internal/data/ent/label.go +++ b/backend/internal/data/ent/label.go @@ -40,8 +40,8 @@ type Label struct { type LabelEdges struct { // Group holds the value of the group edge. Group *Group `json:"group,omitempty"` - // Entities holds the value of the entities edge. - Entities []*Entity `json:"entities,omitempty"` + // Items holds the value of the items edge. + Items []*Item `json:"items,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [2]bool @@ -58,13 +58,13 @@ func (e LabelEdges) GroupOrErr() (*Group, error) { return nil, &NotLoadedError{edge: "group"} } -// EntitiesOrErr returns the Entities value or an error if the edge +// ItemsOrErr returns the Items value or an error if the edge // was not loaded in eager-loading. -func (e LabelEdges) EntitiesOrErr() ([]*Entity, error) { +func (e LabelEdges) ItemsOrErr() ([]*Item, error) { if e.loadedTypes[1] { - return e.Entities, nil + return e.Items, nil } - return nil, &NotLoadedError{edge: "entities"} + return nil, &NotLoadedError{edge: "items"} } // scanValues returns the types for scanning values from sql.Rows. @@ -156,9 +156,9 @@ func (_m *Label) QueryGroup() *GroupQuery { return NewLabelClient(_m.config).QueryGroup(_m) } -// QueryEntities queries the "entities" edge of the Label entity. -func (_m *Label) QueryEntities() *EntityQuery { - return NewLabelClient(_m.config).QueryEntities(_m) +// QueryItems queries the "items" edge of the Label entity. +func (_m *Label) QueryItems() *ItemQuery { + return NewLabelClient(_m.config).QueryItems(_m) } // Update returns a builder for updating this Label. diff --git a/backend/internal/data/ent/label_create.go b/backend/internal/data/ent/label_create.go index d2fa95f6..a1cdf28c 100644 --- a/backend/internal/data/ent/label_create.go +++ b/backend/internal/data/ent/label_create.go @@ -11,8 +11,8 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/label" ) @@ -110,19 +110,19 @@ func (_c *LabelCreate) SetGroup(v *Group) *LabelCreate { return _c.SetGroupID(v.ID) } -// AddEntityIDs adds the "entities" edge to the Entity entity by IDs. -func (_c *LabelCreate) AddEntityIDs(ids ...uuid.UUID) *LabelCreate { - _c.mutation.AddEntityIDs(ids...) +// AddItemIDs adds the "items" edge to the Item entity by IDs. +func (_c *LabelCreate) AddItemIDs(ids ...uuid.UUID) *LabelCreate { + _c.mutation.AddItemIDs(ids...) return _c } -// AddEntities adds the "entities" edges to the Entity entity. -func (_c *LabelCreate) AddEntities(v ...*Entity) *LabelCreate { +// AddItems adds the "items" edges to the Item entity. +func (_c *LabelCreate) AddItems(v ...*Item) *LabelCreate { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _c.AddEntityIDs(ids...) + return _c.AddItemIDs(ids...) } // Mutation returns the LabelMutation object of the builder. @@ -275,15 +275,15 @@ func (_c *LabelCreate) createSpec() (*Label, *sqlgraph.CreateSpec) { _node.group_labels = &nodes[0] _spec.Edges = append(_spec.Edges, edge) } - if nodes := _c.mutation.EntitiesIDs(); len(nodes) > 0 { + if nodes := _c.mutation.ItemsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, - Table: label.EntitiesTable, - Columns: label.EntitiesPrimaryKey, + Table: label.ItemsTable, + Columns: label.ItemsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/backend/internal/data/ent/label_query.go b/backend/internal/data/ent/label_query.go index ada911cd..f3661691 100644 --- a/backend/internal/data/ent/label_query.go +++ b/backend/internal/data/ent/label_query.go @@ -13,8 +13,8 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/label" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" ) @@ -22,13 +22,13 @@ import ( // LabelQuery is the builder for querying Label entities. type LabelQuery struct { config - ctx *QueryContext - order []label.OrderOption - inters []Interceptor - predicates []predicate.Label - withGroup *GroupQuery - withEntities *EntityQuery - withFKs bool + ctx *QueryContext + order []label.OrderOption + inters []Interceptor + predicates []predicate.Label + withGroup *GroupQuery + withItems *ItemQuery + withFKs bool // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -87,9 +87,9 @@ func (_q *LabelQuery) QueryGroup() *GroupQuery { return query } -// QueryEntities chains the current query on the "entities" edge. -func (_q *LabelQuery) QueryEntities() *EntityQuery { - query := (&EntityClient{config: _q.config}).Query() +// QueryItems chains the current query on the "items" edge. +func (_q *LabelQuery) QueryItems() *ItemQuery { + query := (&ItemClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err @@ -100,8 +100,8 @@ func (_q *LabelQuery) QueryEntities() *EntityQuery { } step := sqlgraph.NewStep( sqlgraph.From(label.Table, label.FieldID, selector), - sqlgraph.To(entity.Table, entity.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, label.EntitiesTable, label.EntitiesPrimaryKey...), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, label.ItemsTable, label.ItemsPrimaryKey...), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil @@ -296,13 +296,13 @@ func (_q *LabelQuery) Clone() *LabelQuery { return nil } return &LabelQuery{ - config: _q.config, - ctx: _q.ctx.Clone(), - order: append([]label.OrderOption{}, _q.order...), - inters: append([]Interceptor{}, _q.inters...), - predicates: append([]predicate.Label{}, _q.predicates...), - withGroup: _q.withGroup.Clone(), - withEntities: _q.withEntities.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]label.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Label{}, _q.predicates...), + withGroup: _q.withGroup.Clone(), + withItems: _q.withItems.Clone(), // clone intermediate query. sql: _q.sql.Clone(), path: _q.path, @@ -320,14 +320,14 @@ func (_q *LabelQuery) WithGroup(opts ...func(*GroupQuery)) *LabelQuery { return _q } -// WithEntities tells the query-builder to eager-load the nodes that are connected to -// the "entities" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *LabelQuery) WithEntities(opts ...func(*EntityQuery)) *LabelQuery { - query := (&EntityClient{config: _q.config}).Query() +// WithItems tells the query-builder to eager-load the nodes that are connected to +// the "items" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *LabelQuery) WithItems(opts ...func(*ItemQuery)) *LabelQuery { + query := (&ItemClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - _q.withEntities = query + _q.withItems = query return _q } @@ -412,7 +412,7 @@ func (_q *LabelQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Label, _spec = _q.querySpec() loadedTypes = [2]bool{ _q.withGroup != nil, - _q.withEntities != nil, + _q.withItems != nil, } ) if _q.withGroup != nil { @@ -445,10 +445,10 @@ func (_q *LabelQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Label, return nil, err } } - if query := _q.withEntities; query != nil { - if err := _q.loadEntities(ctx, query, nodes, - func(n *Label) { n.Edges.Entities = []*Entity{} }, - func(n *Label, e *Entity) { n.Edges.Entities = append(n.Edges.Entities, e) }); err != nil { + if query := _q.withItems; query != nil { + if err := _q.loadItems(ctx, query, nodes, + func(n *Label) { n.Edges.Items = []*Item{} }, + func(n *Label, e *Item) { n.Edges.Items = append(n.Edges.Items, e) }); err != nil { return nil, err } } @@ -487,7 +487,7 @@ func (_q *LabelQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes [] } return nil } -func (_q *LabelQuery) loadEntities(ctx context.Context, query *EntityQuery, nodes []*Label, init func(*Label), assign func(*Label, *Entity)) error { +func (_q *LabelQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*Label, init func(*Label), assign func(*Label, *Item)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[uuid.UUID]*Label) nids := make(map[uuid.UUID]map[*Label]struct{}) @@ -499,11 +499,11 @@ func (_q *LabelQuery) loadEntities(ctx context.Context, query *EntityQuery, node } } query.Where(func(s *sql.Selector) { - joinT := sql.Table(label.EntitiesTable) - s.Join(joinT).On(s.C(entity.FieldID), joinT.C(label.EntitiesPrimaryKey[1])) - s.Where(sql.InValues(joinT.C(label.EntitiesPrimaryKey[0]), edgeIDs...)) + joinT := sql.Table(label.ItemsTable) + s.Join(joinT).On(s.C(item.FieldID), joinT.C(label.ItemsPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(label.ItemsPrimaryKey[0]), edgeIDs...)) columns := s.SelectedColumns() - s.Select(joinT.C(label.EntitiesPrimaryKey[0])) + s.Select(joinT.C(label.ItemsPrimaryKey[0])) s.AppendSelect(columns...) s.SetDistinct(false) }) @@ -533,14 +533,14 @@ func (_q *LabelQuery) loadEntities(ctx context.Context, query *EntityQuery, node } }) }) - neighbors, err := withInterceptors[[]*Entity](ctx, query, qr, query.inters) + neighbors, err := withInterceptors[[]*Item](ctx, query, qr, query.inters) if err != nil { return err } for _, n := range neighbors { nodes, ok := nids[n.ID] if !ok { - return fmt.Errorf(`unexpected "entities" node returned %v`, n.ID) + return fmt.Errorf(`unexpected "items" node returned %v`, n.ID) } for kn := range nodes { assign(kn, n) diff --git a/backend/internal/data/ent/label_update.go b/backend/internal/data/ent/label_update.go index 3fd6120f..b9beb1ae 100644 --- a/backend/internal/data/ent/label_update.go +++ b/backend/internal/data/ent/label_update.go @@ -12,8 +12,8 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/label" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" ) @@ -102,19 +102,19 @@ func (_u *LabelUpdate) SetGroup(v *Group) *LabelUpdate { return _u.SetGroupID(v.ID) } -// AddEntityIDs adds the "entities" edge to the Entity entity by IDs. -func (_u *LabelUpdate) AddEntityIDs(ids ...uuid.UUID) *LabelUpdate { - _u.mutation.AddEntityIDs(ids...) +// AddItemIDs adds the "items" edge to the Item entity by IDs. +func (_u *LabelUpdate) AddItemIDs(ids ...uuid.UUID) *LabelUpdate { + _u.mutation.AddItemIDs(ids...) return _u } -// AddEntities adds the "entities" edges to the Entity entity. -func (_u *LabelUpdate) AddEntities(v ...*Entity) *LabelUpdate { +// AddItems adds the "items" edges to the Item entity. +func (_u *LabelUpdate) AddItems(v ...*Item) *LabelUpdate { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.AddEntityIDs(ids...) + return _u.AddItemIDs(ids...) } // Mutation returns the LabelMutation object of the builder. @@ -128,25 +128,25 @@ func (_u *LabelUpdate) ClearGroup() *LabelUpdate { return _u } -// ClearEntities clears all "entities" edges to the Entity entity. -func (_u *LabelUpdate) ClearEntities() *LabelUpdate { - _u.mutation.ClearEntities() +// ClearItems clears all "items" edges to the Item entity. +func (_u *LabelUpdate) ClearItems() *LabelUpdate { + _u.mutation.ClearItems() return _u } -// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs. -func (_u *LabelUpdate) RemoveEntityIDs(ids ...uuid.UUID) *LabelUpdate { - _u.mutation.RemoveEntityIDs(ids...) +// RemoveItemIDs removes the "items" edge to Item entities by IDs. +func (_u *LabelUpdate) RemoveItemIDs(ids ...uuid.UUID) *LabelUpdate { + _u.mutation.RemoveItemIDs(ids...) return _u } -// RemoveEntities removes "entities" edges to Entity entities. -func (_u *LabelUpdate) RemoveEntities(v ...*Entity) *LabelUpdate { +// RemoveItems removes "items" edges to Item entities. +func (_u *LabelUpdate) RemoveItems(v ...*Item) *LabelUpdate { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.RemoveEntityIDs(ids...) + return _u.RemoveItemIDs(ids...) } // Save executes the query and returns the number of nodes affected by the update operation. @@ -267,28 +267,28 @@ func (_u *LabelUpdate) sqlSave(ctx context.Context) (_node int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.EntitiesCleared() { + if _u.mutation.ItemsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, - Table: label.EntitiesTable, - Columns: label.EntitiesPrimaryKey, + Table: label.ItemsTable, + Columns: label.ItemsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() { + if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, - Table: label.EntitiesTable, - Columns: label.EntitiesPrimaryKey, + Table: label.ItemsTable, + Columns: label.ItemsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -296,15 +296,15 @@ func (_u *LabelUpdate) sqlSave(ctx context.Context) (_node int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ItemsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, - Table: label.EntitiesTable, - Columns: label.EntitiesPrimaryKey, + Table: label.ItemsTable, + Columns: label.ItemsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -403,19 +403,19 @@ func (_u *LabelUpdateOne) SetGroup(v *Group) *LabelUpdateOne { return _u.SetGroupID(v.ID) } -// AddEntityIDs adds the "entities" edge to the Entity entity by IDs. -func (_u *LabelUpdateOne) AddEntityIDs(ids ...uuid.UUID) *LabelUpdateOne { - _u.mutation.AddEntityIDs(ids...) +// AddItemIDs adds the "items" edge to the Item entity by IDs. +func (_u *LabelUpdateOne) AddItemIDs(ids ...uuid.UUID) *LabelUpdateOne { + _u.mutation.AddItemIDs(ids...) return _u } -// AddEntities adds the "entities" edges to the Entity entity. -func (_u *LabelUpdateOne) AddEntities(v ...*Entity) *LabelUpdateOne { +// AddItems adds the "items" edges to the Item entity. +func (_u *LabelUpdateOne) AddItems(v ...*Item) *LabelUpdateOne { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.AddEntityIDs(ids...) + return _u.AddItemIDs(ids...) } // Mutation returns the LabelMutation object of the builder. @@ -429,25 +429,25 @@ func (_u *LabelUpdateOne) ClearGroup() *LabelUpdateOne { return _u } -// ClearEntities clears all "entities" edges to the Entity entity. -func (_u *LabelUpdateOne) ClearEntities() *LabelUpdateOne { - _u.mutation.ClearEntities() +// ClearItems clears all "items" edges to the Item entity. +func (_u *LabelUpdateOne) ClearItems() *LabelUpdateOne { + _u.mutation.ClearItems() return _u } -// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs. -func (_u *LabelUpdateOne) RemoveEntityIDs(ids ...uuid.UUID) *LabelUpdateOne { - _u.mutation.RemoveEntityIDs(ids...) +// RemoveItemIDs removes the "items" edge to Item entities by IDs. +func (_u *LabelUpdateOne) RemoveItemIDs(ids ...uuid.UUID) *LabelUpdateOne { + _u.mutation.RemoveItemIDs(ids...) return _u } -// RemoveEntities removes "entities" edges to Entity entities. -func (_u *LabelUpdateOne) RemoveEntities(v ...*Entity) *LabelUpdateOne { +// RemoveItems removes "items" edges to Item entities. +func (_u *LabelUpdateOne) RemoveItems(v ...*Item) *LabelUpdateOne { ids := make([]uuid.UUID, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.RemoveEntityIDs(ids...) + return _u.RemoveItemIDs(ids...) } // Where appends a list predicates to the LabelUpdate builder. @@ -598,28 +598,28 @@ func (_u *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.EntitiesCleared() { + if _u.mutation.ItemsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, - Table: label.EntitiesTable, - Columns: label.EntitiesPrimaryKey, + Table: label.ItemsTable, + Columns: label.ItemsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() { + if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, - Table: label.EntitiesTable, - Columns: label.EntitiesPrimaryKey, + Table: label.ItemsTable, + Columns: label.ItemsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -627,15 +627,15 @@ func (_u *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ItemsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, - Table: label.EntitiesTable, - Columns: label.EntitiesPrimaryKey, + Table: label.ItemsTable, + Columns: label.ItemsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/backend/internal/data/ent/location.go b/backend/internal/data/ent/location.go new file mode 100644 index 00000000..e0e24001 --- /dev/null +++ b/backend/internal/data/ent/location.go @@ -0,0 +1,239 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location" +) + +// Location is the model entity for the Location schema. +type Location struct { + config `json:"-"` + // ID of the ent. + ID uuid.UUID `json:"id,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // UpdatedAt holds the value of the "updated_at" field. + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Name holds the value of the "name" field. + Name string `json:"name,omitempty"` + // Description holds the value of the "description" field. + Description string `json:"description,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the LocationQuery when eager-loading is set. + Edges LocationEdges `json:"edges"` + group_locations *uuid.UUID + location_children *uuid.UUID + selectValues sql.SelectValues +} + +// LocationEdges holds the relations/edges for other nodes in the graph. +type LocationEdges struct { + // Group holds the value of the group edge. + Group *Group `json:"group,omitempty"` + // Parent holds the value of the parent edge. + Parent *Location `json:"parent,omitempty"` + // Children holds the value of the children edge. + Children []*Location `json:"children,omitempty"` + // Items holds the value of the items edge. + Items []*Item `json:"items,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [4]bool +} + +// GroupOrErr returns the Group value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e LocationEdges) GroupOrErr() (*Group, error) { + if e.Group != nil { + return e.Group, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: group.Label} + } + return nil, &NotLoadedError{edge: "group"} +} + +// ParentOrErr returns the Parent value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e LocationEdges) ParentOrErr() (*Location, error) { + if e.Parent != nil { + return e.Parent, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: location.Label} + } + return nil, &NotLoadedError{edge: "parent"} +} + +// ChildrenOrErr returns the Children value or an error if the edge +// was not loaded in eager-loading. +func (e LocationEdges) ChildrenOrErr() ([]*Location, error) { + if e.loadedTypes[2] { + return e.Children, nil + } + return nil, &NotLoadedError{edge: "children"} +} + +// ItemsOrErr returns the Items value or an error if the edge +// was not loaded in eager-loading. +func (e LocationEdges) ItemsOrErr() ([]*Item, error) { + if e.loadedTypes[3] { + return e.Items, nil + } + return nil, &NotLoadedError{edge: "items"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Location) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case location.FieldName, location.FieldDescription: + values[i] = new(sql.NullString) + case location.FieldCreatedAt, location.FieldUpdatedAt: + values[i] = new(sql.NullTime) + case location.FieldID: + values[i] = new(uuid.UUID) + case location.ForeignKeys[0]: // group_locations + values[i] = &sql.NullScanner{S: new(uuid.UUID)} + case location.ForeignKeys[1]: // location_children + values[i] = &sql.NullScanner{S: new(uuid.UUID)} + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Location fields. +func (_m *Location) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case location.FieldID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + _m.ID = *value + } + case location.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + _m.CreatedAt = value.Time + } + case location.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + _m.UpdatedAt = value.Time + } + case location.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + _m.Name = value.String + } + case location.FieldDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field description", values[i]) + } else if value.Valid { + _m.Description = value.String + } + case location.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field group_locations", values[i]) + } else if value.Valid { + _m.group_locations = new(uuid.UUID) + *_m.group_locations = *value.S.(*uuid.UUID) + } + case location.ForeignKeys[1]: + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field location_children", values[i]) + } else if value.Valid { + _m.location_children = new(uuid.UUID) + *_m.location_children = *value.S.(*uuid.UUID) + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Location. +// This includes values selected through modifiers, order, etc. +func (_m *Location) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryGroup queries the "group" edge of the Location entity. +func (_m *Location) QueryGroup() *GroupQuery { + return NewLocationClient(_m.config).QueryGroup(_m) +} + +// QueryParent queries the "parent" edge of the Location entity. +func (_m *Location) QueryParent() *LocationQuery { + return NewLocationClient(_m.config).QueryParent(_m) +} + +// QueryChildren queries the "children" edge of the Location entity. +func (_m *Location) QueryChildren() *LocationQuery { + return NewLocationClient(_m.config).QueryChildren(_m) +} + +// QueryItems queries the "items" edge of the Location entity. +func (_m *Location) QueryItems() *ItemQuery { + return NewLocationClient(_m.config).QueryItems(_m) +} + +// Update returns a builder for updating this Location. +// Note that you need to call Location.Unwrap() before calling this method if this Location +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *Location) Update() *LocationUpdateOne { + return NewLocationClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the Location entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *Location) Unwrap() *Location { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: Location is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *Location) String() string { + var builder strings.Builder + builder.WriteString("Location(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("created_at=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(_m.Name) + builder.WriteString(", ") + builder.WriteString("description=") + builder.WriteString(_m.Description) + builder.WriteByte(')') + return builder.String() +} + +// Locations is a parsable slice of Location. +type Locations []*Location diff --git a/backend/internal/data/ent/location_create.go b/backend/internal/data/ent/location_create.go new file mode 100644 index 00000000..901925be --- /dev/null +++ b/backend/internal/data/ent/location_create.go @@ -0,0 +1,423 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location" +) + +// LocationCreate is the builder for creating a Location entity. +type LocationCreate struct { + config + mutation *LocationMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (_c *LocationCreate) SetCreatedAt(v time.Time) *LocationCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *LocationCreate) SetNillableCreatedAt(v *time.Time) *LocationCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *LocationCreate) SetUpdatedAt(v time.Time) *LocationCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *LocationCreate) SetNillableUpdatedAt(v *time.Time) *LocationCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetName sets the "name" field. +func (_c *LocationCreate) SetName(v string) *LocationCreate { + _c.mutation.SetName(v) + return _c +} + +// SetDescription sets the "description" field. +func (_c *LocationCreate) SetDescription(v string) *LocationCreate { + _c.mutation.SetDescription(v) + return _c +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_c *LocationCreate) SetNillableDescription(v *string) *LocationCreate { + if v != nil { + _c.SetDescription(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *LocationCreate) SetID(v uuid.UUID) *LocationCreate { + _c.mutation.SetID(v) + return _c +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (_c *LocationCreate) SetNillableID(v *uuid.UUID) *LocationCreate { + if v != nil { + _c.SetID(*v) + } + return _c +} + +// SetGroupID sets the "group" edge to the Group entity by ID. +func (_c *LocationCreate) SetGroupID(id uuid.UUID) *LocationCreate { + _c.mutation.SetGroupID(id) + return _c +} + +// SetGroup sets the "group" edge to the Group entity. +func (_c *LocationCreate) SetGroup(v *Group) *LocationCreate { + return _c.SetGroupID(v.ID) +} + +// SetParentID sets the "parent" edge to the Location entity by ID. +func (_c *LocationCreate) SetParentID(id uuid.UUID) *LocationCreate { + _c.mutation.SetParentID(id) + return _c +} + +// SetNillableParentID sets the "parent" edge to the Location entity by ID if the given value is not nil. +func (_c *LocationCreate) SetNillableParentID(id *uuid.UUID) *LocationCreate { + if id != nil { + _c = _c.SetParentID(*id) + } + return _c +} + +// SetParent sets the "parent" edge to the Location entity. +func (_c *LocationCreate) SetParent(v *Location) *LocationCreate { + return _c.SetParentID(v.ID) +} + +// AddChildIDs adds the "children" edge to the Location entity by IDs. +func (_c *LocationCreate) AddChildIDs(ids ...uuid.UUID) *LocationCreate { + _c.mutation.AddChildIDs(ids...) + return _c +} + +// AddChildren adds the "children" edges to the Location entity. +func (_c *LocationCreate) AddChildren(v ...*Location) *LocationCreate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddChildIDs(ids...) +} + +// AddItemIDs adds the "items" edge to the Item entity by IDs. +func (_c *LocationCreate) AddItemIDs(ids ...uuid.UUID) *LocationCreate { + _c.mutation.AddItemIDs(ids...) + return _c +} + +// AddItems adds the "items" edges to the Item entity. +func (_c *LocationCreate) AddItems(v ...*Item) *LocationCreate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddItemIDs(ids...) +} + +// Mutation returns the LocationMutation object of the builder. +func (_c *LocationCreate) Mutation() *LocationMutation { + return _c.mutation +} + +// Save creates the Location in the database. +func (_c *LocationCreate) Save(ctx context.Context) (*Location, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *LocationCreate) SaveX(ctx context.Context) *Location { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *LocationCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *LocationCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *LocationCreate) defaults() { + if _, ok := _c.mutation.CreatedAt(); !ok { + v := location.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := location.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.ID(); !ok { + v := location.DefaultID() + _c.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *LocationCreate) check() error { + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Location.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Location.updated_at"`)} + } + if _, ok := _c.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Location.name"`)} + } + if v, ok := _c.mutation.Name(); ok { + if err := location.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Location.name": %w`, err)} + } + } + if v, ok := _c.mutation.Description(); ok { + if err := location.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Location.description": %w`, err)} + } + } + if len(_c.mutation.GroupIDs()) == 0 { + return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "Location.group"`)} + } + return nil +} + +func (_c *LocationCreate) sqlSave(ctx context.Context) (*Location, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *LocationCreate) createSpec() (*Location, *sqlgraph.CreateSpec) { + var ( + _node = &Location{config: _c.config} + _spec = sqlgraph.NewCreateSpec(location.Table, sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(location.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(location.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := _c.mutation.Name(); ok { + _spec.SetField(location.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := _c.mutation.Description(); ok { + _spec.SetField(location.FieldDescription, field.TypeString, value) + _node.Description = value + } + if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: location.GroupTable, + Columns: []string{location.GroupColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.group_locations = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.ParentIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: location.ParentTable, + Columns: []string{location.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.location_children = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.ChildrenIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: location.ChildrenTable, + Columns: []string{location.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.ItemsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: location.ItemsTable, + Columns: []string{location.ItemsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// LocationCreateBulk is the builder for creating many Location entities in bulk. +type LocationCreateBulk struct { + config + err error + builders []*LocationCreate +} + +// Save creates the Location entities in the database. +func (_c *LocationCreateBulk) Save(ctx context.Context) ([]*Location, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*Location, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*LocationMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *LocationCreateBulk) SaveX(ctx context.Context) []*Location { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *LocationCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *LocationCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/internal/data/ent/location_delete.go b/backend/internal/data/ent/location_delete.go new file mode 100644 index 00000000..4292d82e --- /dev/null +++ b/backend/internal/data/ent/location_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" +) + +// LocationDelete is the builder for deleting a Location entity. +type LocationDelete struct { + config + hooks []Hook + mutation *LocationMutation +} + +// Where appends a list predicates to the LocationDelete builder. +func (_d *LocationDelete) Where(ps ...predicate.Location) *LocationDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *LocationDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *LocationDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *LocationDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(location.Table, sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// LocationDeleteOne is the builder for deleting a single Location entity. +type LocationDeleteOne struct { + _d *LocationDelete +} + +// Where appends a list predicates to the LocationDelete builder. +func (_d *LocationDeleteOne) Where(ps ...predicate.Location) *LocationDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *LocationDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{location.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *LocationDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/internal/data/ent/location_query.go b/backend/internal/data/ent/location_query.go new file mode 100644 index 00000000..4e226d27 --- /dev/null +++ b/backend/internal/data/ent/location_query.go @@ -0,0 +1,839 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" +) + +// LocationQuery is the builder for querying Location entities. +type LocationQuery struct { + config + ctx *QueryContext + order []location.OrderOption + inters []Interceptor + predicates []predicate.Location + withGroup *GroupQuery + withParent *LocationQuery + withChildren *LocationQuery + withItems *ItemQuery + withFKs bool + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the LocationQuery builder. +func (_q *LocationQuery) Where(ps ...predicate.Location) *LocationQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *LocationQuery) Limit(limit int) *LocationQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *LocationQuery) Offset(offset int) *LocationQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *LocationQuery) Unique(unique bool) *LocationQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *LocationQuery) Order(o ...location.OrderOption) *LocationQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryGroup chains the current query on the "group" edge. +func (_q *LocationQuery) QueryGroup() *GroupQuery { + query := (&GroupClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(location.Table, location.FieldID, selector), + sqlgraph.To(group.Table, group.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, location.GroupTable, location.GroupColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryParent chains the current query on the "parent" edge. +func (_q *LocationQuery) QueryParent() *LocationQuery { + query := (&LocationClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(location.Table, location.FieldID, selector), + sqlgraph.To(location.Table, location.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, location.ParentTable, location.ParentColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryChildren chains the current query on the "children" edge. +func (_q *LocationQuery) QueryChildren() *LocationQuery { + query := (&LocationClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(location.Table, location.FieldID, selector), + sqlgraph.To(location.Table, location.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, location.ChildrenTable, location.ChildrenColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryItems chains the current query on the "items" edge. +func (_q *LocationQuery) QueryItems() *ItemQuery { + query := (&ItemClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(location.Table, location.FieldID, selector), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, location.ItemsTable, location.ItemsColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Location entity from the query. +// Returns a *NotFoundError when no Location was found. +func (_q *LocationQuery) First(ctx context.Context) (*Location, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{location.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *LocationQuery) FirstX(ctx context.Context) *Location { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Location ID from the query. +// Returns a *NotFoundError when no Location ID was found. +func (_q *LocationQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{location.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *LocationQuery) FirstIDX(ctx context.Context) uuid.UUID { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Location entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Location entity is found. +// Returns a *NotFoundError when no Location entities are found. +func (_q *LocationQuery) Only(ctx context.Context) (*Location, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{location.Label} + default: + return nil, &NotSingularError{location.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *LocationQuery) OnlyX(ctx context.Context) *Location { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Location ID in the query. +// Returns a *NotSingularError when more than one Location ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *LocationQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{location.Label} + default: + err = &NotSingularError{location.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *LocationQuery) OnlyIDX(ctx context.Context) uuid.UUID { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Locations. +func (_q *LocationQuery) All(ctx context.Context) ([]*Location, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Location, *LocationQuery]() + return withInterceptors[[]*Location](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *LocationQuery) AllX(ctx context.Context) []*Location { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Location IDs. +func (_q *LocationQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(location.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *LocationQuery) IDsX(ctx context.Context) []uuid.UUID { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *LocationQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*LocationQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *LocationQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *LocationQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *LocationQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the LocationQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *LocationQuery) Clone() *LocationQuery { + if _q == nil { + return nil + } + return &LocationQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]location.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Location{}, _q.predicates...), + withGroup: _q.withGroup.Clone(), + withParent: _q.withParent.Clone(), + withChildren: _q.withChildren.Clone(), + withItems: _q.withItems.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// WithGroup tells the query-builder to eager-load the nodes that are connected to +// the "group" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *LocationQuery) WithGroup(opts ...func(*GroupQuery)) *LocationQuery { + query := (&GroupClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withGroup = query + return _q +} + +// WithParent tells the query-builder to eager-load the nodes that are connected to +// the "parent" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *LocationQuery) WithParent(opts ...func(*LocationQuery)) *LocationQuery { + query := (&LocationClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withParent = query + return _q +} + +// WithChildren tells the query-builder to eager-load the nodes that are connected to +// the "children" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *LocationQuery) WithChildren(opts ...func(*LocationQuery)) *LocationQuery { + query := (&LocationClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withChildren = query + return _q +} + +// WithItems tells the query-builder to eager-load the nodes that are connected to +// the "items" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *LocationQuery) WithItems(opts ...func(*ItemQuery)) *LocationQuery { + query := (&ItemClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withItems = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Location.Query(). +// GroupBy(location.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *LocationQuery) GroupBy(field string, fields ...string) *LocationGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &LocationGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = location.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.Location.Query(). +// Select(location.FieldCreatedAt). +// Scan(ctx, &v) +func (_q *LocationQuery) Select(fields ...string) *LocationSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &LocationSelect{LocationQuery: _q} + sbuild.label = location.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a LocationSelect configured with the given aggregations. +func (_q *LocationQuery) Aggregate(fns ...AggregateFunc) *LocationSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *LocationQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !location.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *LocationQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Location, error) { + var ( + nodes = []*Location{} + withFKs = _q.withFKs + _spec = _q.querySpec() + loadedTypes = [4]bool{ + _q.withGroup != nil, + _q.withParent != nil, + _q.withChildren != nil, + _q.withItems != nil, + } + ) + if _q.withGroup != nil || _q.withParent != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, location.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Location).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Location{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withGroup; query != nil { + if err := _q.loadGroup(ctx, query, nodes, nil, + func(n *Location, e *Group) { n.Edges.Group = e }); err != nil { + return nil, err + } + } + if query := _q.withParent; query != nil { + if err := _q.loadParent(ctx, query, nodes, nil, + func(n *Location, e *Location) { n.Edges.Parent = e }); err != nil { + return nil, err + } + } + if query := _q.withChildren; query != nil { + if err := _q.loadChildren(ctx, query, nodes, + func(n *Location) { n.Edges.Children = []*Location{} }, + func(n *Location, e *Location) { n.Edges.Children = append(n.Edges.Children, e) }); err != nil { + return nil, err + } + } + if query := _q.withItems; query != nil { + if err := _q.loadItems(ctx, query, nodes, + func(n *Location) { n.Edges.Items = []*Item{} }, + func(n *Location, e *Item) { n.Edges.Items = append(n.Edges.Items, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *LocationQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*Location, init func(*Location), assign func(*Location, *Group)) error { + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*Location) + for i := range nodes { + if nodes[i].group_locations == nil { + continue + } + fk := *nodes[i].group_locations + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(group.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "group_locations" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *LocationQuery) loadParent(ctx context.Context, query *LocationQuery, nodes []*Location, init func(*Location), assign func(*Location, *Location)) error { + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*Location) + for i := range nodes { + if nodes[i].location_children == nil { + continue + } + fk := *nodes[i].location_children + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(location.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "location_children" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *LocationQuery) loadChildren(ctx context.Context, query *LocationQuery, nodes []*Location, init func(*Location), assign func(*Location, *Location)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uuid.UUID]*Location) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.Location(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(location.ChildrenColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.location_children + if fk == nil { + return fmt.Errorf(`foreign-key "location_children" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "location_children" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} +func (_q *LocationQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*Location, init func(*Location), assign func(*Location, *Item)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uuid.UUID]*Location) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.Item(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(location.ItemsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.location_items + if fk == nil { + return fmt.Errorf(`foreign-key "location_items" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "location_items" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (_q *LocationQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *LocationQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(location.Table, location.Columns, sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, location.FieldID) + for i := range fields { + if fields[i] != location.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *LocationQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(location.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = location.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// LocationGroupBy is the group-by builder for Location entities. +type LocationGroupBy struct { + selector + build *LocationQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *LocationGroupBy) Aggregate(fns ...AggregateFunc) *LocationGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *LocationGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*LocationQuery, *LocationGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *LocationGroupBy) sqlScan(ctx context.Context, root *LocationQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// LocationSelect is the builder for selecting fields of Location entities. +type LocationSelect struct { + *LocationQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *LocationSelect) Aggregate(fns ...AggregateFunc) *LocationSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *LocationSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*LocationQuery, *LocationSelect](ctx, _s.LocationQuery, _s, _s.inters, v) +} + +func (_s *LocationSelect) sqlScan(ctx context.Context, root *LocationQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/backend/internal/data/ent/location_update.go b/backend/internal/data/ent/location_update.go new file mode 100644 index 00000000..badd8bd0 --- /dev/null +++ b/backend/internal/data/ent/location_update.go @@ -0,0 +1,867 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" +) + +// LocationUpdate is the builder for updating Location entities. +type LocationUpdate struct { + config + hooks []Hook + mutation *LocationMutation +} + +// Where appends a list predicates to the LocationUpdate builder. +func (_u *LocationUpdate) Where(ps ...predicate.Location) *LocationUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *LocationUpdate) SetUpdatedAt(v time.Time) *LocationUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetName sets the "name" field. +func (_u *LocationUpdate) SetName(v string) *LocationUpdate { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *LocationUpdate) SetNillableName(v *string) *LocationUpdate { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetDescription sets the "description" field. +func (_u *LocationUpdate) SetDescription(v string) *LocationUpdate { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *LocationUpdate) SetNillableDescription(v *string) *LocationUpdate { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// ClearDescription clears the value of the "description" field. +func (_u *LocationUpdate) ClearDescription() *LocationUpdate { + _u.mutation.ClearDescription() + return _u +} + +// SetGroupID sets the "group" edge to the Group entity by ID. +func (_u *LocationUpdate) SetGroupID(id uuid.UUID) *LocationUpdate { + _u.mutation.SetGroupID(id) + return _u +} + +// SetGroup sets the "group" edge to the Group entity. +func (_u *LocationUpdate) SetGroup(v *Group) *LocationUpdate { + return _u.SetGroupID(v.ID) +} + +// SetParentID sets the "parent" edge to the Location entity by ID. +func (_u *LocationUpdate) SetParentID(id uuid.UUID) *LocationUpdate { + _u.mutation.SetParentID(id) + return _u +} + +// SetNillableParentID sets the "parent" edge to the Location entity by ID if the given value is not nil. +func (_u *LocationUpdate) SetNillableParentID(id *uuid.UUID) *LocationUpdate { + if id != nil { + _u = _u.SetParentID(*id) + } + return _u +} + +// SetParent sets the "parent" edge to the Location entity. +func (_u *LocationUpdate) SetParent(v *Location) *LocationUpdate { + return _u.SetParentID(v.ID) +} + +// AddChildIDs adds the "children" edge to the Location entity by IDs. +func (_u *LocationUpdate) AddChildIDs(ids ...uuid.UUID) *LocationUpdate { + _u.mutation.AddChildIDs(ids...) + return _u +} + +// AddChildren adds the "children" edges to the Location entity. +func (_u *LocationUpdate) AddChildren(v ...*Location) *LocationUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddChildIDs(ids...) +} + +// AddItemIDs adds the "items" edge to the Item entity by IDs. +func (_u *LocationUpdate) AddItemIDs(ids ...uuid.UUID) *LocationUpdate { + _u.mutation.AddItemIDs(ids...) + return _u +} + +// AddItems adds the "items" edges to the Item entity. +func (_u *LocationUpdate) AddItems(v ...*Item) *LocationUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddItemIDs(ids...) +} + +// Mutation returns the LocationMutation object of the builder. +func (_u *LocationUpdate) Mutation() *LocationMutation { + return _u.mutation +} + +// ClearGroup clears the "group" edge to the Group entity. +func (_u *LocationUpdate) ClearGroup() *LocationUpdate { + _u.mutation.ClearGroup() + return _u +} + +// ClearParent clears the "parent" edge to the Location entity. +func (_u *LocationUpdate) ClearParent() *LocationUpdate { + _u.mutation.ClearParent() + return _u +} + +// ClearChildren clears all "children" edges to the Location entity. +func (_u *LocationUpdate) ClearChildren() *LocationUpdate { + _u.mutation.ClearChildren() + return _u +} + +// RemoveChildIDs removes the "children" edge to Location entities by IDs. +func (_u *LocationUpdate) RemoveChildIDs(ids ...uuid.UUID) *LocationUpdate { + _u.mutation.RemoveChildIDs(ids...) + return _u +} + +// RemoveChildren removes "children" edges to Location entities. +func (_u *LocationUpdate) RemoveChildren(v ...*Location) *LocationUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveChildIDs(ids...) +} + +// ClearItems clears all "items" edges to the Item entity. +func (_u *LocationUpdate) ClearItems() *LocationUpdate { + _u.mutation.ClearItems() + return _u +} + +// RemoveItemIDs removes the "items" edge to Item entities by IDs. +func (_u *LocationUpdate) RemoveItemIDs(ids ...uuid.UUID) *LocationUpdate { + _u.mutation.RemoveItemIDs(ids...) + return _u +} + +// RemoveItems removes "items" edges to Item entities. +func (_u *LocationUpdate) RemoveItems(v ...*Item) *LocationUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveItemIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *LocationUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *LocationUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *LocationUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *LocationUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *LocationUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := location.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *LocationUpdate) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := location.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Location.name": %w`, err)} + } + } + if v, ok := _u.mutation.Description(); ok { + if err := location.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Location.description": %w`, err)} + } + } + if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "Location.group"`) + } + return nil +} + +func (_u *LocationUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(location.Table, location.Columns, sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(location.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(location.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(location.FieldDescription, field.TypeString, value) + } + if _u.mutation.DescriptionCleared() { + _spec.ClearField(location.FieldDescription, field.TypeString) + } + if _u.mutation.GroupCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: location.GroupTable, + Columns: []string{location.GroupColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: location.GroupTable, + Columns: []string{location.GroupColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ParentCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: location.ParentTable, + Columns: []string{location.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: location.ParentTable, + Columns: []string{location.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: location.ChildrenTable, + Columns: []string{location.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: location.ChildrenTable, + Columns: []string{location.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: location.ChildrenTable, + Columns: []string{location.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: location.ItemsTable, + Columns: []string{location.ItemsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: location.ItemsTable, + Columns: []string{location.ItemsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ItemsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: location.ItemsTable, + Columns: []string{location.ItemsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{location.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// LocationUpdateOne is the builder for updating a single Location entity. +type LocationUpdateOne struct { + config + fields []string + hooks []Hook + mutation *LocationMutation +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *LocationUpdateOne) SetUpdatedAt(v time.Time) *LocationUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetName sets the "name" field. +func (_u *LocationUpdateOne) SetName(v string) *LocationUpdateOne { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *LocationUpdateOne) SetNillableName(v *string) *LocationUpdateOne { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetDescription sets the "description" field. +func (_u *LocationUpdateOne) SetDescription(v string) *LocationUpdateOne { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *LocationUpdateOne) SetNillableDescription(v *string) *LocationUpdateOne { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// ClearDescription clears the value of the "description" field. +func (_u *LocationUpdateOne) ClearDescription() *LocationUpdateOne { + _u.mutation.ClearDescription() + return _u +} + +// SetGroupID sets the "group" edge to the Group entity by ID. +func (_u *LocationUpdateOne) SetGroupID(id uuid.UUID) *LocationUpdateOne { + _u.mutation.SetGroupID(id) + return _u +} + +// SetGroup sets the "group" edge to the Group entity. +func (_u *LocationUpdateOne) SetGroup(v *Group) *LocationUpdateOne { + return _u.SetGroupID(v.ID) +} + +// SetParentID sets the "parent" edge to the Location entity by ID. +func (_u *LocationUpdateOne) SetParentID(id uuid.UUID) *LocationUpdateOne { + _u.mutation.SetParentID(id) + return _u +} + +// SetNillableParentID sets the "parent" edge to the Location entity by ID if the given value is not nil. +func (_u *LocationUpdateOne) SetNillableParentID(id *uuid.UUID) *LocationUpdateOne { + if id != nil { + _u = _u.SetParentID(*id) + } + return _u +} + +// SetParent sets the "parent" edge to the Location entity. +func (_u *LocationUpdateOne) SetParent(v *Location) *LocationUpdateOne { + return _u.SetParentID(v.ID) +} + +// AddChildIDs adds the "children" edge to the Location entity by IDs. +func (_u *LocationUpdateOne) AddChildIDs(ids ...uuid.UUID) *LocationUpdateOne { + _u.mutation.AddChildIDs(ids...) + return _u +} + +// AddChildren adds the "children" edges to the Location entity. +func (_u *LocationUpdateOne) AddChildren(v ...*Location) *LocationUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddChildIDs(ids...) +} + +// AddItemIDs adds the "items" edge to the Item entity by IDs. +func (_u *LocationUpdateOne) AddItemIDs(ids ...uuid.UUID) *LocationUpdateOne { + _u.mutation.AddItemIDs(ids...) + return _u +} + +// AddItems adds the "items" edges to the Item entity. +func (_u *LocationUpdateOne) AddItems(v ...*Item) *LocationUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddItemIDs(ids...) +} + +// Mutation returns the LocationMutation object of the builder. +func (_u *LocationUpdateOne) Mutation() *LocationMutation { + return _u.mutation +} + +// ClearGroup clears the "group" edge to the Group entity. +func (_u *LocationUpdateOne) ClearGroup() *LocationUpdateOne { + _u.mutation.ClearGroup() + return _u +} + +// ClearParent clears the "parent" edge to the Location entity. +func (_u *LocationUpdateOne) ClearParent() *LocationUpdateOne { + _u.mutation.ClearParent() + return _u +} + +// ClearChildren clears all "children" edges to the Location entity. +func (_u *LocationUpdateOne) ClearChildren() *LocationUpdateOne { + _u.mutation.ClearChildren() + return _u +} + +// RemoveChildIDs removes the "children" edge to Location entities by IDs. +func (_u *LocationUpdateOne) RemoveChildIDs(ids ...uuid.UUID) *LocationUpdateOne { + _u.mutation.RemoveChildIDs(ids...) + return _u +} + +// RemoveChildren removes "children" edges to Location entities. +func (_u *LocationUpdateOne) RemoveChildren(v ...*Location) *LocationUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveChildIDs(ids...) +} + +// ClearItems clears all "items" edges to the Item entity. +func (_u *LocationUpdateOne) ClearItems() *LocationUpdateOne { + _u.mutation.ClearItems() + return _u +} + +// RemoveItemIDs removes the "items" edge to Item entities by IDs. +func (_u *LocationUpdateOne) RemoveItemIDs(ids ...uuid.UUID) *LocationUpdateOne { + _u.mutation.RemoveItemIDs(ids...) + return _u +} + +// RemoveItems removes "items" edges to Item entities. +func (_u *LocationUpdateOne) RemoveItems(v ...*Item) *LocationUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveItemIDs(ids...) +} + +// Where appends a list predicates to the LocationUpdate builder. +func (_u *LocationUpdateOne) Where(ps ...predicate.Location) *LocationUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *LocationUpdateOne) Select(field string, fields ...string) *LocationUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated Location entity. +func (_u *LocationUpdateOne) Save(ctx context.Context) (*Location, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *LocationUpdateOne) SaveX(ctx context.Context) *Location { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *LocationUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *LocationUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *LocationUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := location.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *LocationUpdateOne) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := location.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Location.name": %w`, err)} + } + } + if v, ok := _u.mutation.Description(); ok { + if err := location.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Location.description": %w`, err)} + } + } + if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "Location.group"`) + } + return nil +} + +func (_u *LocationUpdateOne) sqlSave(ctx context.Context) (_node *Location, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(location.Table, location.Columns, sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Location.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, location.FieldID) + for _, f := range fields { + if !location.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != location.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(location.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(location.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(location.FieldDescription, field.TypeString, value) + } + if _u.mutation.DescriptionCleared() { + _spec.ClearField(location.FieldDescription, field.TypeString) + } + if _u.mutation.GroupCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: location.GroupTable, + Columns: []string{location.GroupColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: location.GroupTable, + Columns: []string{location.GroupColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ParentCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: location.ParentTable, + Columns: []string{location.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: location.ParentTable, + Columns: []string{location.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: location.ChildrenTable, + Columns: []string{location.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: location.ChildrenTable, + Columns: []string{location.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: location.ChildrenTable, + Columns: []string{location.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: location.ItemsTable, + Columns: []string{location.ItemsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: location.ItemsTable, + Columns: []string{location.ItemsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ItemsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: location.ItemsTable, + Columns: []string{location.ItemsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &Location{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{location.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/backend/internal/data/ent/maintenanceentry.go b/backend/internal/data/ent/maintenanceentry.go index 700de400..9d870b78 100644 --- a/backend/internal/data/ent/maintenanceentry.go +++ b/backend/internal/data/ent/maintenanceentry.go @@ -10,7 +10,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/google/uuid" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry" ) @@ -23,8 +23,8 @@ type MaintenanceEntry struct { CreatedAt time.Time `json:"created_at,omitempty"` // UpdatedAt holds the value of the "updated_at" field. UpdatedAt time.Time `json:"updated_at,omitempty"` - // EntityID holds the value of the "entity_id" field. - EntityID uuid.UUID `json:"entity_id,omitempty"` + // ItemID holds the value of the "item_id" field. + ItemID uuid.UUID `json:"item_id,omitempty"` // Date holds the value of the "date" field. Date time.Time `json:"date,omitempty"` // ScheduledDate holds the value of the "scheduled_date" field. @@ -43,22 +43,22 @@ type MaintenanceEntry struct { // MaintenanceEntryEdges holds the relations/edges for other nodes in the graph. type MaintenanceEntryEdges struct { - // Entity holds the value of the entity edge. - Entity *Entity `json:"entity,omitempty"` + // Item holds the value of the item edge. + Item *Item `json:"item,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [1]bool } -// EntityOrErr returns the Entity value or an error if the edge +// ItemOrErr returns the Item value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. -func (e MaintenanceEntryEdges) EntityOrErr() (*Entity, error) { - if e.Entity != nil { - return e.Entity, nil +func (e MaintenanceEntryEdges) ItemOrErr() (*Item, error) { + if e.Item != nil { + return e.Item, nil } else if e.loadedTypes[0] { - return nil, &NotFoundError{label: entity.Label} + return nil, &NotFoundError{label: item.Label} } - return nil, &NotLoadedError{edge: "entity"} + return nil, &NotLoadedError{edge: "item"} } // scanValues returns the types for scanning values from sql.Rows. @@ -72,7 +72,7 @@ func (*MaintenanceEntry) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullString) case maintenanceentry.FieldCreatedAt, maintenanceentry.FieldUpdatedAt, maintenanceentry.FieldDate, maintenanceentry.FieldScheduledDate: values[i] = new(sql.NullTime) - case maintenanceentry.FieldID, maintenanceentry.FieldEntityID: + case maintenanceentry.FieldID, maintenanceentry.FieldItemID: values[i] = new(uuid.UUID) default: values[i] = new(sql.UnknownType) @@ -107,11 +107,11 @@ func (_m *MaintenanceEntry) assignValues(columns []string, values []any) error { } else if value.Valid { _m.UpdatedAt = value.Time } - case maintenanceentry.FieldEntityID: + case maintenanceentry.FieldItemID: if value, ok := values[i].(*uuid.UUID); !ok { - return fmt.Errorf("unexpected type %T for field entity_id", values[i]) + return fmt.Errorf("unexpected type %T for field item_id", values[i]) } else if value != nil { - _m.EntityID = *value + _m.ItemID = *value } case maintenanceentry.FieldDate: if value, ok := values[i].(*sql.NullTime); !ok { @@ -156,9 +156,9 @@ func (_m *MaintenanceEntry) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } -// QueryEntity queries the "entity" edge of the MaintenanceEntry entity. -func (_m *MaintenanceEntry) QueryEntity() *EntityQuery { - return NewMaintenanceEntryClient(_m.config).QueryEntity(_m) +// QueryItem queries the "item" edge of the MaintenanceEntry entity. +func (_m *MaintenanceEntry) QueryItem() *ItemQuery { + return NewMaintenanceEntryClient(_m.config).QueryItem(_m) } // Update returns a builder for updating this MaintenanceEntry. @@ -190,8 +190,8 @@ func (_m *MaintenanceEntry) String() string { builder.WriteString("updated_at=") builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) builder.WriteString(", ") - builder.WriteString("entity_id=") - builder.WriteString(fmt.Sprintf("%v", _m.EntityID)) + builder.WriteString("item_id=") + builder.WriteString(fmt.Sprintf("%v", _m.ItemID)) builder.WriteString(", ") builder.WriteString("date=") builder.WriteString(_m.Date.Format(time.ANSIC)) diff --git a/backend/internal/data/ent/maintenanceentry_create.go b/backend/internal/data/ent/maintenanceentry_create.go index 8cb472eb..75d3bb82 100644 --- a/backend/internal/data/ent/maintenanceentry_create.go +++ b/backend/internal/data/ent/maintenanceentry_create.go @@ -11,7 +11,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry" ) @@ -50,9 +50,9 @@ func (_c *MaintenanceEntryCreate) SetNillableUpdatedAt(v *time.Time) *Maintenanc return _c } -// SetEntityID sets the "entity_id" field. -func (_c *MaintenanceEntryCreate) SetEntityID(v uuid.UUID) *MaintenanceEntryCreate { - _c.mutation.SetEntityID(v) +// SetItemID sets the "item_id" field. +func (_c *MaintenanceEntryCreate) SetItemID(v uuid.UUID) *MaintenanceEntryCreate { + _c.mutation.SetItemID(v) return _c } @@ -132,9 +132,9 @@ func (_c *MaintenanceEntryCreate) SetNillableID(v *uuid.UUID) *MaintenanceEntryC return _c } -// SetEntity sets the "entity" edge to the Entity entity. -func (_c *MaintenanceEntryCreate) SetEntity(v *Entity) *MaintenanceEntryCreate { - return _c.SetEntityID(v.ID) +// SetItem sets the "item" edge to the Item entity. +func (_c *MaintenanceEntryCreate) SetItem(v *Item) *MaintenanceEntryCreate { + return _c.SetItemID(v.ID) } // Mutation returns the MaintenanceEntryMutation object of the builder. @@ -198,8 +198,8 @@ func (_c *MaintenanceEntryCreate) check() error { if _, ok := _c.mutation.UpdatedAt(); !ok { return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "MaintenanceEntry.updated_at"`)} } - if _, ok := _c.mutation.EntityID(); !ok { - return &ValidationError{Name: "entity_id", err: errors.New(`ent: missing required field "MaintenanceEntry.entity_id"`)} + if _, ok := _c.mutation.ItemID(); !ok { + return &ValidationError{Name: "item_id", err: errors.New(`ent: missing required field "MaintenanceEntry.item_id"`)} } if _, ok := _c.mutation.Name(); !ok { return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "MaintenanceEntry.name"`)} @@ -217,8 +217,8 @@ func (_c *MaintenanceEntryCreate) check() error { if _, ok := _c.mutation.Cost(); !ok { return &ValidationError{Name: "cost", err: errors.New(`ent: missing required field "MaintenanceEntry.cost"`)} } - if len(_c.mutation.EntityIDs()) == 0 { - return &ValidationError{Name: "entity", err: errors.New(`ent: missing required edge "MaintenanceEntry.entity"`)} + if len(_c.mutation.ItemIDs()) == 0 { + return &ValidationError{Name: "item", err: errors.New(`ent: missing required edge "MaintenanceEntry.item"`)} } return nil } @@ -283,21 +283,21 @@ func (_c *MaintenanceEntryCreate) createSpec() (*MaintenanceEntry, *sqlgraph.Cre _spec.SetField(maintenanceentry.FieldCost, field.TypeFloat64, value) _node.Cost = value } - if nodes := _c.mutation.EntityIDs(); len(nodes) > 0 { + if nodes := _c.mutation.ItemIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: maintenanceentry.EntityTable, - Columns: []string{maintenanceentry.EntityColumn}, + Table: maintenanceentry.ItemTable, + Columns: []string{maintenanceentry.ItemColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } - _node.EntityID = nodes[0] + _node.ItemID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } return _node, _spec diff --git a/backend/internal/data/ent/maintenanceentry_query.go b/backend/internal/data/ent/maintenanceentry_query.go index 6b9eaabb..99f60218 100644 --- a/backend/internal/data/ent/maintenanceentry_query.go +++ b/backend/internal/data/ent/maintenanceentry_query.go @@ -12,7 +12,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" ) @@ -24,7 +24,7 @@ type MaintenanceEntryQuery struct { order []maintenanceentry.OrderOption inters []Interceptor predicates []predicate.MaintenanceEntry - withEntity *EntityQuery + withItem *ItemQuery // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -61,9 +61,9 @@ func (_q *MaintenanceEntryQuery) Order(o ...maintenanceentry.OrderOption) *Maint return _q } -// QueryEntity chains the current query on the "entity" edge. -func (_q *MaintenanceEntryQuery) QueryEntity() *EntityQuery { - query := (&EntityClient{config: _q.config}).Query() +// QueryItem chains the current query on the "item" edge. +func (_q *MaintenanceEntryQuery) QueryItem() *ItemQuery { + query := (&ItemClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err @@ -74,8 +74,8 @@ func (_q *MaintenanceEntryQuery) QueryEntity() *EntityQuery { } step := sqlgraph.NewStep( sqlgraph.From(maintenanceentry.Table, maintenanceentry.FieldID, selector), - sqlgraph.To(entity.Table, entity.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, maintenanceentry.EntityTable, maintenanceentry.EntityColumn), + sqlgraph.To(item.Table, item.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, maintenanceentry.ItemTable, maintenanceentry.ItemColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil @@ -275,21 +275,21 @@ func (_q *MaintenanceEntryQuery) Clone() *MaintenanceEntryQuery { order: append([]maintenanceentry.OrderOption{}, _q.order...), inters: append([]Interceptor{}, _q.inters...), predicates: append([]predicate.MaintenanceEntry{}, _q.predicates...), - withEntity: _q.withEntity.Clone(), + withItem: _q.withItem.Clone(), // clone intermediate query. sql: _q.sql.Clone(), path: _q.path, } } -// WithEntity tells the query-builder to eager-load the nodes that are connected to -// the "entity" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *MaintenanceEntryQuery) WithEntity(opts ...func(*EntityQuery)) *MaintenanceEntryQuery { - query := (&EntityClient{config: _q.config}).Query() +// WithItem tells the query-builder to eager-load the nodes that are connected to +// the "item" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *MaintenanceEntryQuery) WithItem(opts ...func(*ItemQuery)) *MaintenanceEntryQuery { + query := (&ItemClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - _q.withEntity = query + _q.withItem = query return _q } @@ -372,7 +372,7 @@ func (_q *MaintenanceEntryQuery) sqlAll(ctx context.Context, hooks ...queryHook) nodes = []*MaintenanceEntry{} _spec = _q.querySpec() loadedTypes = [1]bool{ - _q.withEntity != nil, + _q.withItem != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { @@ -393,20 +393,20 @@ func (_q *MaintenanceEntryQuery) sqlAll(ctx context.Context, hooks ...queryHook) if len(nodes) == 0 { return nodes, nil } - if query := _q.withEntity; query != nil { - if err := _q.loadEntity(ctx, query, nodes, nil, - func(n *MaintenanceEntry, e *Entity) { n.Edges.Entity = e }); err != nil { + if query := _q.withItem; query != nil { + if err := _q.loadItem(ctx, query, nodes, nil, + func(n *MaintenanceEntry, e *Item) { n.Edges.Item = e }); err != nil { return nil, err } } return nodes, nil } -func (_q *MaintenanceEntryQuery) loadEntity(ctx context.Context, query *EntityQuery, nodes []*MaintenanceEntry, init func(*MaintenanceEntry), assign func(*MaintenanceEntry, *Entity)) error { +func (_q *MaintenanceEntryQuery) loadItem(ctx context.Context, query *ItemQuery, nodes []*MaintenanceEntry, init func(*MaintenanceEntry), assign func(*MaintenanceEntry, *Item)) error { ids := make([]uuid.UUID, 0, len(nodes)) nodeids := make(map[uuid.UUID][]*MaintenanceEntry) for i := range nodes { - fk := nodes[i].EntityID + fk := nodes[i].ItemID if _, ok := nodeids[fk]; !ok { ids = append(ids, fk) } @@ -415,7 +415,7 @@ func (_q *MaintenanceEntryQuery) loadEntity(ctx context.Context, query *EntityQu if len(ids) == 0 { return nil } - query.Where(entity.IDIn(ids...)) + query.Where(item.IDIn(ids...)) neighbors, err := query.All(ctx) if err != nil { return err @@ -423,7 +423,7 @@ func (_q *MaintenanceEntryQuery) loadEntity(ctx context.Context, query *EntityQu for _, n := range neighbors { nodes, ok := nodeids[n.ID] if !ok { - return fmt.Errorf(`unexpected foreign-key "entity_id" returned %v`, n.ID) + return fmt.Errorf(`unexpected foreign-key "item_id" returned %v`, n.ID) } for i := range nodes { assign(nodes[i], n) @@ -457,8 +457,8 @@ func (_q *MaintenanceEntryQuery) querySpec() *sqlgraph.QuerySpec { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } - if _q.withEntity != nil { - _spec.Node.AddColumnOnce(maintenanceentry.FieldEntityID) + if _q.withItem != nil { + _spec.Node.AddColumnOnce(maintenanceentry.FieldItemID) } } if ps := _q.predicates; len(ps) > 0 { diff --git a/backend/internal/data/ent/maintenanceentry_update.go b/backend/internal/data/ent/maintenanceentry_update.go index c57d688b..bd27b50c 100644 --- a/backend/internal/data/ent/maintenanceentry_update.go +++ b/backend/internal/data/ent/maintenanceentry_update.go @@ -12,7 +12,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/google/uuid" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" ) @@ -36,16 +36,16 @@ func (_u *MaintenanceEntryUpdate) SetUpdatedAt(v time.Time) *MaintenanceEntryUpd return _u } -// SetEntityID sets the "entity_id" field. -func (_u *MaintenanceEntryUpdate) SetEntityID(v uuid.UUID) *MaintenanceEntryUpdate { - _u.mutation.SetEntityID(v) +// SetItemID sets the "item_id" field. +func (_u *MaintenanceEntryUpdate) SetItemID(v uuid.UUID) *MaintenanceEntryUpdate { + _u.mutation.SetItemID(v) return _u } -// SetNillableEntityID sets the "entity_id" field if the given value is not nil. -func (_u *MaintenanceEntryUpdate) SetNillableEntityID(v *uuid.UUID) *MaintenanceEntryUpdate { +// SetNillableItemID sets the "item_id" field if the given value is not nil. +func (_u *MaintenanceEntryUpdate) SetNillableItemID(v *uuid.UUID) *MaintenanceEntryUpdate { if v != nil { - _u.SetEntityID(*v) + _u.SetItemID(*v) } return _u } @@ -145,9 +145,9 @@ func (_u *MaintenanceEntryUpdate) AddCost(v float64) *MaintenanceEntryUpdate { return _u } -// SetEntity sets the "entity" edge to the Entity entity. -func (_u *MaintenanceEntryUpdate) SetEntity(v *Entity) *MaintenanceEntryUpdate { - return _u.SetEntityID(v.ID) +// SetItem sets the "item" edge to the Item entity. +func (_u *MaintenanceEntryUpdate) SetItem(v *Item) *MaintenanceEntryUpdate { + return _u.SetItemID(v.ID) } // Mutation returns the MaintenanceEntryMutation object of the builder. @@ -155,9 +155,9 @@ func (_u *MaintenanceEntryUpdate) Mutation() *MaintenanceEntryMutation { return _u.mutation } -// ClearEntity clears the "entity" edge to the Entity entity. -func (_u *MaintenanceEntryUpdate) ClearEntity() *MaintenanceEntryUpdate { - _u.mutation.ClearEntity() +// ClearItem clears the "item" edge to the Item entity. +func (_u *MaintenanceEntryUpdate) ClearItem() *MaintenanceEntryUpdate { + _u.mutation.ClearItem() return _u } @@ -209,8 +209,8 @@ func (_u *MaintenanceEntryUpdate) check() error { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "MaintenanceEntry.description": %w`, err)} } } - if _u.mutation.EntityCleared() && len(_u.mutation.EntityIDs()) > 0 { - return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.entity"`) + if _u.mutation.ItemCleared() && len(_u.mutation.ItemIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.item"`) } return nil } @@ -257,28 +257,28 @@ func (_u *MaintenanceEntryUpdate) sqlSave(ctx context.Context) (_node int, err e if value, ok := _u.mutation.AddedCost(); ok { _spec.AddField(maintenanceentry.FieldCost, field.TypeFloat64, value) } - if _u.mutation.EntityCleared() { + if _u.mutation.ItemCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: maintenanceentry.EntityTable, - Columns: []string{maintenanceentry.EntityColumn}, + Table: maintenanceentry.ItemTable, + Columns: []string{maintenanceentry.ItemColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: maintenanceentry.EntityTable, - Columns: []string{maintenanceentry.EntityColumn}, + Table: maintenanceentry.ItemTable, + Columns: []string{maintenanceentry.ItemColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -312,16 +312,16 @@ func (_u *MaintenanceEntryUpdateOne) SetUpdatedAt(v time.Time) *MaintenanceEntry return _u } -// SetEntityID sets the "entity_id" field. -func (_u *MaintenanceEntryUpdateOne) SetEntityID(v uuid.UUID) *MaintenanceEntryUpdateOne { - _u.mutation.SetEntityID(v) +// SetItemID sets the "item_id" field. +func (_u *MaintenanceEntryUpdateOne) SetItemID(v uuid.UUID) *MaintenanceEntryUpdateOne { + _u.mutation.SetItemID(v) return _u } -// SetNillableEntityID sets the "entity_id" field if the given value is not nil. -func (_u *MaintenanceEntryUpdateOne) SetNillableEntityID(v *uuid.UUID) *MaintenanceEntryUpdateOne { +// SetNillableItemID sets the "item_id" field if the given value is not nil. +func (_u *MaintenanceEntryUpdateOne) SetNillableItemID(v *uuid.UUID) *MaintenanceEntryUpdateOne { if v != nil { - _u.SetEntityID(*v) + _u.SetItemID(*v) } return _u } @@ -421,9 +421,9 @@ func (_u *MaintenanceEntryUpdateOne) AddCost(v float64) *MaintenanceEntryUpdateO return _u } -// SetEntity sets the "entity" edge to the Entity entity. -func (_u *MaintenanceEntryUpdateOne) SetEntity(v *Entity) *MaintenanceEntryUpdateOne { - return _u.SetEntityID(v.ID) +// SetItem sets the "item" edge to the Item entity. +func (_u *MaintenanceEntryUpdateOne) SetItem(v *Item) *MaintenanceEntryUpdateOne { + return _u.SetItemID(v.ID) } // Mutation returns the MaintenanceEntryMutation object of the builder. @@ -431,9 +431,9 @@ func (_u *MaintenanceEntryUpdateOne) Mutation() *MaintenanceEntryMutation { return _u.mutation } -// ClearEntity clears the "entity" edge to the Entity entity. -func (_u *MaintenanceEntryUpdateOne) ClearEntity() *MaintenanceEntryUpdateOne { - _u.mutation.ClearEntity() +// ClearItem clears the "item" edge to the Item entity. +func (_u *MaintenanceEntryUpdateOne) ClearItem() *MaintenanceEntryUpdateOne { + _u.mutation.ClearItem() return _u } @@ -498,8 +498,8 @@ func (_u *MaintenanceEntryUpdateOne) check() error { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "MaintenanceEntry.description": %w`, err)} } } - if _u.mutation.EntityCleared() && len(_u.mutation.EntityIDs()) > 0 { - return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.entity"`) + if _u.mutation.ItemCleared() && len(_u.mutation.ItemIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.item"`) } return nil } @@ -563,28 +563,28 @@ func (_u *MaintenanceEntryUpdateOne) sqlSave(ctx context.Context) (_node *Mainte if value, ok := _u.mutation.AddedCost(); ok { _spec.AddField(maintenanceentry.FieldCost, field.TypeFloat64, value) } - if _u.mutation.EntityCleared() { + if _u.mutation.ItemCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: maintenanceentry.EntityTable, - Columns: []string{maintenanceentry.EntityColumn}, + Table: maintenanceentry.ItemTable, + Columns: []string{maintenanceentry.ItemColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, - Table: maintenanceentry.EntityTable, - Columns: []string{maintenanceentry.EntityColumn}, + Table: maintenanceentry.ItemTable, + Columns: []string{maintenanceentry.ItemColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/backend/internal/data/ent/migrate/schema.go b/backend/internal/data/ent/migrate/schema.go index adacbe77..ef6161d8 100644 --- a/backend/internal/data/ent/migrate/schema.go +++ b/backend/internal/data/ent/migrate/schema.go @@ -19,7 +19,7 @@ var ( {Name: "path", Type: field.TypeString, Default: ""}, {Name: "mime_type", Type: field.TypeString, Default: "application/octet-stream"}, {Name: "attachment_thumbnail", Type: field.TypeUUID, Unique: true, Nullable: true}, - {Name: "entity_attachments", Type: field.TypeUUID, Nullable: true}, + {Name: "item_attachments", Type: field.TypeUUID, Nullable: true}, } // AttachmentsTable holds the schema information for the "attachments" table. AttachmentsTable = &schema.Table{ @@ -34,9 +34,9 @@ var ( OnDelete: schema.SetNull, }, { - Symbol: "attachments_entities_attachments", + Symbol: "attachments_items_attachments", Columns: []*schema.Column{AttachmentsColumns[9]}, - RefColumns: []*schema.Column{EntitiesColumns[0]}, + RefColumns: []*schema.Column{ItemsColumns[0]}, OnDelete: schema.Cascade, }, }, @@ -91,168 +91,6 @@ var ( }, }, } - // EntitiesColumns holds the columns for the "entities" table. - EntitiesColumns = []*schema.Column{ - {Name: "id", Type: field.TypeUUID}, - {Name: "created_at", Type: field.TypeTime}, - {Name: "updated_at", Type: field.TypeTime}, - {Name: "name", Type: field.TypeString, Size: 255}, - {Name: "description", Type: field.TypeString, Nullable: true, Size: 1000}, - {Name: "import_ref", Type: field.TypeString, Nullable: true, Size: 100}, - {Name: "notes", Type: field.TypeString, Nullable: true, Size: 1000}, - {Name: "quantity", Type: field.TypeInt, Default: 1}, - {Name: "insured", Type: field.TypeBool, Default: false}, - {Name: "archived", Type: field.TypeBool, Default: false}, - {Name: "asset_id", Type: field.TypeInt, Default: 0}, - {Name: "sync_child_entities_locations", Type: field.TypeBool, Default: false}, - {Name: "serial_number", Type: field.TypeString, Nullable: true, Size: 255}, - {Name: "model_number", Type: field.TypeString, Nullable: true, Size: 255}, - {Name: "manufacturer", Type: field.TypeString, Nullable: true, Size: 255}, - {Name: "lifetime_warranty", Type: field.TypeBool, Default: false}, - {Name: "warranty_expires", Type: field.TypeTime, Nullable: true}, - {Name: "warranty_details", Type: field.TypeString, Nullable: true, Size: 1000}, - {Name: "purchase_time", Type: field.TypeTime, Nullable: true}, - {Name: "purchase_from", Type: field.TypeString, Nullable: true}, - {Name: "purchase_price", Type: field.TypeFloat64, Default: 0}, - {Name: "sold_time", Type: field.TypeTime, Nullable: true}, - {Name: "sold_to", Type: field.TypeString, Nullable: true}, - {Name: "sold_price", Type: field.TypeFloat64, Default: 0}, - {Name: "sold_notes", Type: field.TypeString, Nullable: true, Size: 1000}, - {Name: "entity_parent", Type: field.TypeUUID, Nullable: true}, - {Name: "entity_location", Type: field.TypeUUID, Nullable: true}, - {Name: "entity_type_entities", Type: field.TypeUUID, Nullable: true}, - {Name: "group_entities", Type: field.TypeUUID}, - } - // EntitiesTable holds the schema information for the "entities" table. - EntitiesTable = &schema.Table{ - Name: "entities", - Columns: EntitiesColumns, - PrimaryKey: []*schema.Column{EntitiesColumns[0]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "entities_entities_parent", - Columns: []*schema.Column{EntitiesColumns[25]}, - RefColumns: []*schema.Column{EntitiesColumns[0]}, - OnDelete: schema.SetNull, - }, - { - Symbol: "entities_entities_location", - Columns: []*schema.Column{EntitiesColumns[26]}, - RefColumns: []*schema.Column{EntitiesColumns[0]}, - OnDelete: schema.SetNull, - }, - { - Symbol: "entities_entity_types_entities", - Columns: []*schema.Column{EntitiesColumns[27]}, - RefColumns: []*schema.Column{EntityTypesColumns[0]}, - OnDelete: schema.SetNull, - }, - { - Symbol: "entities_groups_entities", - Columns: []*schema.Column{EntitiesColumns[28]}, - RefColumns: []*schema.Column{GroupsColumns[0]}, - OnDelete: schema.Cascade, - }, - }, - Indexes: []*schema.Index{ - { - Name: "entity_name", - Unique: false, - Columns: []*schema.Column{EntitiesColumns[3]}, - }, - { - Name: "entity_manufacturer", - Unique: false, - Columns: []*schema.Column{EntitiesColumns[14]}, - }, - { - Name: "entity_model_number", - Unique: false, - Columns: []*schema.Column{EntitiesColumns[13]}, - }, - { - Name: "entity_serial_number", - Unique: false, - Columns: []*schema.Column{EntitiesColumns[12]}, - }, - { - Name: "entity_archived", - Unique: false, - Columns: []*schema.Column{EntitiesColumns[9]}, - }, - { - Name: "entity_asset_id", - Unique: false, - Columns: []*schema.Column{EntitiesColumns[10]}, - }, - }, - } - // EntityFieldsColumns holds the columns for the "entity_fields" table. - EntityFieldsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeUUID}, - {Name: "created_at", Type: field.TypeTime}, - {Name: "updated_at", Type: field.TypeTime}, - {Name: "name", Type: field.TypeString, Size: 255}, - {Name: "description", Type: field.TypeString, Nullable: true, Size: 1000}, - {Name: "type", Type: field.TypeEnum, Enums: []string{"text", "number", "boolean", "time"}}, - {Name: "text_value", Type: field.TypeString, Nullable: true, Size: 500}, - {Name: "number_value", Type: field.TypeInt, Nullable: true}, - {Name: "boolean_value", Type: field.TypeBool, Default: false}, - {Name: "time_value", Type: field.TypeTime}, - {Name: "entity_fields", Type: field.TypeUUID, Nullable: true}, - } - // EntityFieldsTable holds the schema information for the "entity_fields" table. - EntityFieldsTable = &schema.Table{ - Name: "entity_fields", - Columns: EntityFieldsColumns, - PrimaryKey: []*schema.Column{EntityFieldsColumns[0]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "entity_fields_entities_fields", - Columns: []*schema.Column{EntityFieldsColumns[10]}, - RefColumns: []*schema.Column{EntitiesColumns[0]}, - OnDelete: schema.Cascade, - }, - }, - } - // EntityTypesColumns holds the columns for the "entity_types" table. - EntityTypesColumns = []*schema.Column{ - {Name: "id", Type: field.TypeUUID}, - {Name: "created_at", Type: field.TypeTime}, - {Name: "updated_at", Type: field.TypeTime}, - {Name: "name", Type: field.TypeString, Size: 255}, - {Name: "description", Type: field.TypeString, Nullable: true, Size: 1000}, - {Name: "icon", Type: field.TypeString, Nullable: true, Size: 255}, - {Name: "color", Type: field.TypeString, Nullable: true, Size: 255}, - {Name: "is_location", Type: field.TypeBool, Default: false}, - {Name: "group_entity_types", Type: field.TypeUUID}, - } - // EntityTypesTable holds the schema information for the "entity_types" table. - EntityTypesTable = &schema.Table{ - Name: "entity_types", - Columns: EntityTypesColumns, - PrimaryKey: []*schema.Column{EntityTypesColumns[0]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "entity_types_groups_entity_types", - Columns: []*schema.Column{EntityTypesColumns[8]}, - RefColumns: []*schema.Column{GroupsColumns[0]}, - OnDelete: schema.Cascade, - }, - }, - Indexes: []*schema.Index{ - { - Name: "entitytype_name", - Unique: false, - Columns: []*schema.Column{EntityTypesColumns[3]}, - }, - { - Name: "entitytype_is_location", - Unique: false, - Columns: []*schema.Column{EntityTypesColumns[7]}, - }, - }, - } // GroupsColumns holds the columns for the "groups" table. GroupsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, @@ -291,6 +129,173 @@ var ( }, }, } + // ItemsColumns holds the columns for the "items" table. + ItemsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUUID}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "name", Type: field.TypeString, Size: 255}, + {Name: "description", Type: field.TypeString, Nullable: true, Size: 1000}, + {Name: "import_ref", Type: field.TypeString, Nullable: true, Size: 100}, + {Name: "notes", Type: field.TypeString, Nullable: true, Size: 1000}, + {Name: "quantity", Type: field.TypeInt, Default: 1}, + {Name: "insured", Type: field.TypeBool, Default: false}, + {Name: "archived", Type: field.TypeBool, Default: false}, + {Name: "asset_id", Type: field.TypeInt, Default: 0}, + {Name: "sync_child_items_locations", Type: field.TypeBool, Default: false}, + {Name: "serial_number", Type: field.TypeString, Nullable: true, Size: 255}, + {Name: "model_number", Type: field.TypeString, Nullable: true, Size: 255}, + {Name: "manufacturer", Type: field.TypeString, Nullable: true, Size: 255}, + {Name: "lifetime_warranty", Type: field.TypeBool, Default: false}, + {Name: "warranty_expires", Type: field.TypeTime, Nullable: true}, + {Name: "warranty_details", Type: field.TypeString, Nullable: true, Size: 1000}, + {Name: "purchase_time", Type: field.TypeTime, Nullable: true}, + {Name: "purchase_from", Type: field.TypeString, Nullable: true}, + {Name: "purchase_price", Type: field.TypeFloat64, Default: 0}, + {Name: "sold_time", Type: field.TypeTime, Nullable: true}, + {Name: "sold_to", Type: field.TypeString, Nullable: true}, + {Name: "sold_price", Type: field.TypeFloat64, Default: 0}, + {Name: "sold_notes", Type: field.TypeString, Nullable: true, Size: 1000}, + {Name: "group_items", Type: field.TypeUUID}, + {Name: "item_children", Type: field.TypeUUID, Nullable: true}, + {Name: "location_items", Type: field.TypeUUID, Nullable: true}, + } + // ItemsTable holds the schema information for the "items" table. + ItemsTable = &schema.Table{ + Name: "items", + Columns: ItemsColumns, + PrimaryKey: []*schema.Column{ItemsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "items_groups_items", + Columns: []*schema.Column{ItemsColumns[25]}, + RefColumns: []*schema.Column{GroupsColumns[0]}, + OnDelete: schema.Cascade, + }, + { + Symbol: "items_items_children", + Columns: []*schema.Column{ItemsColumns[26]}, + RefColumns: []*schema.Column{ItemsColumns[0]}, + OnDelete: schema.SetNull, + }, + { + Symbol: "items_locations_items", + Columns: []*schema.Column{ItemsColumns[27]}, + RefColumns: []*schema.Column{LocationsColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + Indexes: []*schema.Index{ + { + Name: "item_name", + Unique: false, + Columns: []*schema.Column{ItemsColumns[3]}, + }, + { + Name: "item_manufacturer", + Unique: false, + Columns: []*schema.Column{ItemsColumns[14]}, + }, + { + Name: "item_model_number", + Unique: false, + Columns: []*schema.Column{ItemsColumns[13]}, + }, + { + Name: "item_serial_number", + Unique: false, + Columns: []*schema.Column{ItemsColumns[12]}, + }, + { + Name: "item_archived", + Unique: false, + Columns: []*schema.Column{ItemsColumns[9]}, + }, + { + Name: "item_asset_id", + Unique: false, + Columns: []*schema.Column{ItemsColumns[10]}, + }, + }, + } + // ItemFieldsColumns holds the columns for the "item_fields" table. + ItemFieldsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUUID}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "name", Type: field.TypeString, Size: 255}, + {Name: "description", Type: field.TypeString, Nullable: true, Size: 1000}, + {Name: "type", Type: field.TypeEnum, Enums: []string{"text", "number", "boolean", "time"}}, + {Name: "text_value", Type: field.TypeString, Nullable: true, Size: 500}, + {Name: "number_value", Type: field.TypeInt, Nullable: true}, + {Name: "boolean_value", Type: field.TypeBool, Default: false}, + {Name: "time_value", Type: field.TypeTime}, + {Name: "item_fields", Type: field.TypeUUID, Nullable: true}, + } + // ItemFieldsTable holds the schema information for the "item_fields" table. + ItemFieldsTable = &schema.Table{ + Name: "item_fields", + Columns: ItemFieldsColumns, + PrimaryKey: []*schema.Column{ItemFieldsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "item_fields_items_fields", + Columns: []*schema.Column{ItemFieldsColumns[10]}, + RefColumns: []*schema.Column{ItemsColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + } + // ItemTemplatesColumns holds the columns for the "item_templates" table. + ItemTemplatesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUUID}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "name", Type: field.TypeString, Size: 255}, + {Name: "description", Type: field.TypeString, Nullable: true, Size: 1000}, + {Name: "notes", Type: field.TypeString, Nullable: true, Size: 1000}, + {Name: "default_quantity", Type: field.TypeInt, Default: 1}, + {Name: "default_insured", Type: field.TypeBool, Default: false}, + {Name: "default_name", Type: field.TypeString, Nullable: true, Size: 255}, + {Name: "default_description", Type: field.TypeString, Nullable: true, Size: 1000}, + {Name: "default_manufacturer", Type: field.TypeString, Nullable: true, Size: 255}, + {Name: "default_model_number", Type: field.TypeString, Nullable: true, Size: 255}, + {Name: "default_lifetime_warranty", Type: field.TypeBool, Default: false}, + {Name: "default_warranty_details", Type: field.TypeString, Nullable: true, Size: 1000}, + {Name: "include_warranty_fields", Type: field.TypeBool, Default: false}, + {Name: "include_purchase_fields", Type: field.TypeBool, Default: false}, + {Name: "include_sold_fields", Type: field.TypeBool, Default: false}, + {Name: "default_label_ids", Type: field.TypeJSON, Nullable: true}, + {Name: "group_item_templates", Type: field.TypeUUID}, + {Name: "item_template_location", Type: field.TypeUUID, Nullable: true}, + } + // ItemTemplatesTable holds the schema information for the "item_templates" table. + ItemTemplatesTable = &schema.Table{ + Name: "item_templates", + Columns: ItemTemplatesColumns, + PrimaryKey: []*schema.Column{ItemTemplatesColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "item_templates_groups_item_templates", + Columns: []*schema.Column{ItemTemplatesColumns[18]}, + RefColumns: []*schema.Column{GroupsColumns[0]}, + OnDelete: schema.Cascade, + }, + { + Symbol: "item_templates_locations_location", + Columns: []*schema.Column{ItemTemplatesColumns[19]}, + RefColumns: []*schema.Column{LocationsColumns[0]}, + OnDelete: schema.SetNull, + }, + }, + Indexes: []*schema.Index{ + { + Name: "itemtemplate_name", + Unique: false, + Columns: []*schema.Column{ItemTemplatesColumns[3]}, + }, + }, + } // LabelsColumns holds the columns for the "labels" table. LabelsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, @@ -315,6 +320,36 @@ var ( }, }, } + // LocationsColumns holds the columns for the "locations" table. + LocationsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUUID}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "name", Type: field.TypeString, Size: 255}, + {Name: "description", Type: field.TypeString, Nullable: true, Size: 1000}, + {Name: "group_locations", Type: field.TypeUUID}, + {Name: "location_children", Type: field.TypeUUID, Nullable: true}, + } + // LocationsTable holds the schema information for the "locations" table. + LocationsTable = &schema.Table{ + Name: "locations", + Columns: LocationsColumns, + PrimaryKey: []*schema.Column{LocationsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "locations_groups_locations", + Columns: []*schema.Column{LocationsColumns[5]}, + RefColumns: []*schema.Column{GroupsColumns[0]}, + OnDelete: schema.Cascade, + }, + { + Symbol: "locations_locations_children", + Columns: []*schema.Column{LocationsColumns[6]}, + RefColumns: []*schema.Column{LocationsColumns[0]}, + OnDelete: schema.SetNull, + }, + }, + } // MaintenanceEntriesColumns holds the columns for the "maintenance_entries" table. MaintenanceEntriesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, @@ -325,7 +360,7 @@ var ( {Name: "name", Type: field.TypeString, Size: 255}, {Name: "description", Type: field.TypeString, Nullable: true, Size: 2500}, {Name: "cost", Type: field.TypeFloat64, Default: 0}, - {Name: "entity_id", Type: field.TypeUUID}, + {Name: "item_id", Type: field.TypeUUID}, } // MaintenanceEntriesTable holds the schema information for the "maintenance_entries" table. MaintenanceEntriesTable = &schema.Table{ @@ -334,9 +369,9 @@ var ( PrimaryKey: []*schema.Column{MaintenanceEntriesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { - Symbol: "maintenance_entries_entities_maintenance_entries", + Symbol: "maintenance_entries_items_maintenance_entries", Columns: []*schema.Column{MaintenanceEntriesColumns[8]}, - RefColumns: []*schema.Column{EntitiesColumns[0]}, + RefColumns: []*schema.Column{ItemsColumns[0]}, OnDelete: schema.Cascade, }, }, @@ -394,6 +429,31 @@ var ( }, }, } + // TemplateFieldsColumns holds the columns for the "template_fields" table. + TemplateFieldsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUUID}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "name", Type: field.TypeString, Size: 255}, + {Name: "description", Type: field.TypeString, Nullable: true, Size: 1000}, + {Name: "type", Type: field.TypeEnum, Enums: []string{"text"}}, + {Name: "text_value", Type: field.TypeString, Nullable: true, Size: 500}, + {Name: "item_template_fields", Type: field.TypeUUID, Nullable: true}, + } + // TemplateFieldsTable holds the schema information for the "template_fields" table. + TemplateFieldsTable = &schema.Table{ + Name: "template_fields", + Columns: TemplateFieldsColumns, + PrimaryKey: []*schema.Column{TemplateFieldsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "template_fields_item_templates_fields", + Columns: []*schema.Column{TemplateFieldsColumns[7]}, + RefColumns: []*schema.Column{ItemTemplatesColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + } // UsersColumns holds the columns for the "users" table. UsersColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, @@ -401,11 +461,13 @@ var ( {Name: "updated_at", Type: field.TypeTime}, {Name: "name", Type: field.TypeString, Size: 255}, {Name: "email", Type: field.TypeString, Unique: true, Size: 255}, - {Name: "password", Type: field.TypeString, Size: 255}, + {Name: "password", Type: field.TypeString, Nullable: true, Size: 255}, {Name: "is_superuser", Type: field.TypeBool, Default: false}, {Name: "superuser", Type: field.TypeBool, Default: false}, {Name: "role", Type: field.TypeEnum, Enums: []string{"user", "owner"}, Default: "user"}, {Name: "activated_on", Type: field.TypeTime, Nullable: true}, + {Name: "oidc_issuer", Type: field.TypeString, Nullable: true}, + {Name: "oidc_subject", Type: field.TypeString, Nullable: true}, {Name: "group_users", Type: field.TypeUUID}, } // UsersTable holds the schema information for the "users" table. @@ -416,33 +478,40 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "users_groups_users", - Columns: []*schema.Column{UsersColumns[10]}, + Columns: []*schema.Column{UsersColumns[12]}, RefColumns: []*schema.Column{GroupsColumns[0]}, OnDelete: schema.Cascade, }, }, + Indexes: []*schema.Index{ + { + Name: "user_oidc_issuer_oidc_subject", + Unique: true, + Columns: []*schema.Column{UsersColumns[10], UsersColumns[11]}, + }, + }, } - // LabelEntitiesColumns holds the columns for the "label_entities" table. - LabelEntitiesColumns = []*schema.Column{ + // LabelItemsColumns holds the columns for the "label_items" table. + LabelItemsColumns = []*schema.Column{ {Name: "label_id", Type: field.TypeUUID}, - {Name: "entity_id", Type: field.TypeUUID}, + {Name: "item_id", Type: field.TypeUUID}, } - // LabelEntitiesTable holds the schema information for the "label_entities" table. - LabelEntitiesTable = &schema.Table{ - Name: "label_entities", - Columns: LabelEntitiesColumns, - PrimaryKey: []*schema.Column{LabelEntitiesColumns[0], LabelEntitiesColumns[1]}, + // LabelItemsTable holds the schema information for the "label_items" table. + LabelItemsTable = &schema.Table{ + Name: "label_items", + Columns: LabelItemsColumns, + PrimaryKey: []*schema.Column{LabelItemsColumns[0], LabelItemsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { - Symbol: "label_entities_label_id", - Columns: []*schema.Column{LabelEntitiesColumns[0]}, + Symbol: "label_items_label_id", + Columns: []*schema.Column{LabelItemsColumns[0]}, RefColumns: []*schema.Column{LabelsColumns[0]}, OnDelete: schema.Cascade, }, { - Symbol: "label_entities_entity_id", - Columns: []*schema.Column{LabelEntitiesColumns[1]}, - RefColumns: []*schema.Column{EntitiesColumns[0]}, + Symbol: "label_items_item_id", + Columns: []*schema.Column{LabelItemsColumns[1]}, + RefColumns: []*schema.Column{ItemsColumns[0]}, OnDelete: schema.Cascade, }, }, @@ -452,36 +521,41 @@ var ( AttachmentsTable, AuthRolesTable, AuthTokensTable, - EntitiesTable, - EntityFieldsTable, - EntityTypesTable, GroupsTable, GroupInvitationTokensTable, + ItemsTable, + ItemFieldsTable, + ItemTemplatesTable, LabelsTable, + LocationsTable, MaintenanceEntriesTable, NotifiersTable, + TemplateFieldsTable, UsersTable, - LabelEntitiesTable, + LabelItemsTable, } ) func init() { AttachmentsTable.ForeignKeys[0].RefTable = AttachmentsTable - AttachmentsTable.ForeignKeys[1].RefTable = EntitiesTable + AttachmentsTable.ForeignKeys[1].RefTable = ItemsTable AuthRolesTable.ForeignKeys[0].RefTable = AuthTokensTable AuthTokensTable.ForeignKeys[0].RefTable = UsersTable - EntitiesTable.ForeignKeys[0].RefTable = EntitiesTable - EntitiesTable.ForeignKeys[1].RefTable = EntitiesTable - EntitiesTable.ForeignKeys[2].RefTable = EntityTypesTable - EntitiesTable.ForeignKeys[3].RefTable = GroupsTable - EntityFieldsTable.ForeignKeys[0].RefTable = EntitiesTable - EntityTypesTable.ForeignKeys[0].RefTable = GroupsTable GroupInvitationTokensTable.ForeignKeys[0].RefTable = GroupsTable + ItemsTable.ForeignKeys[0].RefTable = GroupsTable + ItemsTable.ForeignKeys[1].RefTable = ItemsTable + ItemsTable.ForeignKeys[2].RefTable = LocationsTable + ItemFieldsTable.ForeignKeys[0].RefTable = ItemsTable + ItemTemplatesTable.ForeignKeys[0].RefTable = GroupsTable + ItemTemplatesTable.ForeignKeys[1].RefTable = LocationsTable LabelsTable.ForeignKeys[0].RefTable = GroupsTable - MaintenanceEntriesTable.ForeignKeys[0].RefTable = EntitiesTable + LocationsTable.ForeignKeys[0].RefTable = GroupsTable + LocationsTable.ForeignKeys[1].RefTable = LocationsTable + MaintenanceEntriesTable.ForeignKeys[0].RefTable = ItemsTable NotifiersTable.ForeignKeys[0].RefTable = GroupsTable NotifiersTable.ForeignKeys[1].RefTable = UsersTable + TemplateFieldsTable.ForeignKeys[0].RefTable = ItemTemplatesTable UsersTable.ForeignKeys[0].RefTable = GroupsTable - LabelEntitiesTable.ForeignKeys[0].RefTable = LabelsTable - LabelEntitiesTable.ForeignKeys[1].RefTable = EntitiesTable + LabelItemsTable.ForeignKeys[0].RefTable = LabelsTable + LabelItemsTable.ForeignKeys[1].RefTable = ItemsTable } diff --git a/backend/internal/data/ent/mutation.go b/backend/internal/data/ent/mutation.go index 2ce5efc3..f5a1b13d 100644 --- a/backend/internal/data/ent/mutation.go +++ b/backend/internal/data/ent/mutation.go @@ -15,15 +15,17 @@ import ( "github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/authroles" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/authtokens" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/label" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/user" ) @@ -39,14 +41,16 @@ const ( TypeAttachment = "Attachment" TypeAuthRoles = "AuthRoles" TypeAuthTokens = "AuthTokens" - TypeEntity = "Entity" - TypeEntityField = "EntityField" - TypeEntityType = "EntityType" TypeGroup = "Group" TypeGroupInvitationToken = "GroupInvitationToken" + TypeItem = "Item" + TypeItemField = "ItemField" + TypeItemTemplate = "ItemTemplate" TypeLabel = "Label" + TypeLocation = "Location" TypeMaintenanceEntry = "MaintenanceEntry" TypeNotifier = "Notifier" + TypeTemplateField = "TemplateField" TypeUser = "User" ) @@ -64,8 +68,8 @@ type AttachmentMutation struct { _path *string mime_type *string clearedFields map[string]struct{} - entity *uuid.UUID - clearedentity bool + item *uuid.UUID + cleareditem bool thumbnail *uuid.UUID clearedthumbnail bool done bool @@ -429,43 +433,43 @@ func (m *AttachmentMutation) ResetMimeType() { m.mime_type = nil } -// SetEntityID sets the "entity" edge to the Entity entity by id. -func (m *AttachmentMutation) SetEntityID(id uuid.UUID) { - m.entity = &id +// SetItemID sets the "item" edge to the Item entity by id. +func (m *AttachmentMutation) SetItemID(id uuid.UUID) { + m.item = &id } -// ClearEntity clears the "entity" edge to the Entity entity. -func (m *AttachmentMutation) ClearEntity() { - m.clearedentity = true +// ClearItem clears the "item" edge to the Item entity. +func (m *AttachmentMutation) ClearItem() { + m.cleareditem = true } -// EntityCleared reports if the "entity" edge to the Entity entity was cleared. -func (m *AttachmentMutation) EntityCleared() bool { - return m.clearedentity +// ItemCleared reports if the "item" edge to the Item entity was cleared. +func (m *AttachmentMutation) ItemCleared() bool { + return m.cleareditem } -// EntityID returns the "entity" edge ID in the mutation. -func (m *AttachmentMutation) EntityID() (id uuid.UUID, exists bool) { - if m.entity != nil { - return *m.entity, true +// ItemID returns the "item" edge ID in the mutation. +func (m *AttachmentMutation) ItemID() (id uuid.UUID, exists bool) { + if m.item != nil { + return *m.item, true } return } -// EntityIDs returns the "entity" edge IDs in the mutation. +// ItemIDs returns the "item" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// EntityID instead. It exists only for internal usage by the builders. -func (m *AttachmentMutation) EntityIDs() (ids []uuid.UUID) { - if id := m.entity; id != nil { +// ItemID instead. It exists only for internal usage by the builders. +func (m *AttachmentMutation) ItemIDs() (ids []uuid.UUID) { + if id := m.item; id != nil { ids = append(ids, *id) } return } -// ResetEntity resets all changes to the "entity" edge. -func (m *AttachmentMutation) ResetEntity() { - m.entity = nil - m.clearedentity = false +// ResetItem resets all changes to the "item" edge. +func (m *AttachmentMutation) ResetItem() { + m.item = nil + m.cleareditem = false } // SetThumbnailID sets the "thumbnail" edge to the Attachment entity by id. @@ -743,8 +747,8 @@ func (m *AttachmentMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *AttachmentMutation) AddedEdges() []string { edges := make([]string, 0, 2) - if m.entity != nil { - edges = append(edges, attachment.EdgeEntity) + if m.item != nil { + edges = append(edges, attachment.EdgeItem) } if m.thumbnail != nil { edges = append(edges, attachment.EdgeThumbnail) @@ -756,8 +760,8 @@ func (m *AttachmentMutation) AddedEdges() []string { // name in this mutation. func (m *AttachmentMutation) AddedIDs(name string) []ent.Value { switch name { - case attachment.EdgeEntity: - if id := m.entity; id != nil { + case attachment.EdgeItem: + if id := m.item; id != nil { return []ent.Value{*id} } case attachment.EdgeThumbnail: @@ -783,8 +787,8 @@ func (m *AttachmentMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *AttachmentMutation) ClearedEdges() []string { edges := make([]string, 0, 2) - if m.clearedentity { - edges = append(edges, attachment.EdgeEntity) + if m.cleareditem { + edges = append(edges, attachment.EdgeItem) } if m.clearedthumbnail { edges = append(edges, attachment.EdgeThumbnail) @@ -796,8 +800,8 @@ func (m *AttachmentMutation) ClearedEdges() []string { // was cleared in this mutation. func (m *AttachmentMutation) EdgeCleared(name string) bool { switch name { - case attachment.EdgeEntity: - return m.clearedentity + case attachment.EdgeItem: + return m.cleareditem case attachment.EdgeThumbnail: return m.clearedthumbnail } @@ -808,8 +812,8 @@ func (m *AttachmentMutation) EdgeCleared(name string) bool { // if that edge is not defined in the schema. func (m *AttachmentMutation) ClearEdge(name string) error { switch name { - case attachment.EdgeEntity: - m.ClearEntity() + case attachment.EdgeItem: + m.ClearItem() return nil case attachment.EdgeThumbnail: m.ClearThumbnail() @@ -822,8 +826,8 @@ func (m *AttachmentMutation) ClearEdge(name string) error { // It returns an error if the edge is not defined in the schema. func (m *AttachmentMutation) ResetEdge(name string) error { switch name { - case attachment.EdgeEntity: - m.ResetEntity() + case attachment.EdgeItem: + m.ResetItem() return nil case attachment.EdgeThumbnail: m.ResetThumbnail() @@ -1845,4505 +1849,6 @@ func (m *AuthTokensMutation) ResetEdge(name string) error { return fmt.Errorf("unknown AuthTokens edge %s", name) } -// EntityMutation represents an operation that mutates the Entity nodes in the graph. -type EntityMutation struct { - config - op Op - typ string - id *uuid.UUID - created_at *time.Time - updated_at *time.Time - name *string - description *string - import_ref *string - notes *string - quantity *int - addquantity *int - insured *bool - archived *bool - asset_id *int - addasset_id *int - sync_child_entities_locations *bool - serial_number *string - model_number *string - manufacturer *string - lifetime_warranty *bool - warranty_expires *time.Time - warranty_details *string - purchase_time *time.Time - purchase_from *string - purchase_price *float64 - addpurchase_price *float64 - sold_time *time.Time - sold_to *string - sold_price *float64 - addsold_price *float64 - sold_notes *string - clearedFields map[string]struct{} - group *uuid.UUID - clearedgroup bool - children map[uuid.UUID]struct{} - removedchildren map[uuid.UUID]struct{} - clearedchildren bool - parent *uuid.UUID - clearedparent bool - entity map[uuid.UUID]struct{} - removedentity map[uuid.UUID]struct{} - clearedentity bool - location *uuid.UUID - clearedlocation bool - label map[uuid.UUID]struct{} - removedlabel map[uuid.UUID]struct{} - clearedlabel bool - _type *uuid.UUID - cleared_type bool - fields map[uuid.UUID]struct{} - removedfields map[uuid.UUID]struct{} - clearedfields bool - maintenance_entries map[uuid.UUID]struct{} - removedmaintenance_entries map[uuid.UUID]struct{} - clearedmaintenance_entries bool - attachments map[uuid.UUID]struct{} - removedattachments map[uuid.UUID]struct{} - clearedattachments bool - done bool - oldValue func(context.Context) (*Entity, error) - predicates []predicate.Entity -} - -var _ ent.Mutation = (*EntityMutation)(nil) - -// entityOption allows management of the mutation configuration using functional options. -type entityOption func(*EntityMutation) - -// newEntityMutation creates new mutation for the Entity entity. -func newEntityMutation(c config, op Op, opts ...entityOption) *EntityMutation { - m := &EntityMutation{ - config: c, - op: op, - typ: TypeEntity, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withEntityID sets the ID field of the mutation. -func withEntityID(id uuid.UUID) entityOption { - return func(m *EntityMutation) { - var ( - err error - once sync.Once - value *Entity - ) - m.oldValue = func(ctx context.Context) (*Entity, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().Entity.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withEntity sets the old Entity of the mutation. -func withEntity(node *Entity) entityOption { - return func(m *EntityMutation) { - m.oldValue = func(context.Context) (*Entity, error) { - return node, nil - } - m.id = &node.ID - } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m EntityMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m EntityMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Entity entities. -func (m *EntityMutation) SetID(id uuid.UUID) { - m.id = &id -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *EntityMutation) ID() (id uuid.UUID, exists bool) { - if m.id == nil { - return - } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *EntityMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []uuid.UUID{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().Entity.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetCreatedAt sets the "created_at" field. -func (m *EntityMutation) SetCreatedAt(t time.Time) { - m.created_at = &t -} - -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *EntityMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at - if v == nil { - return - } - return *v, true -} - -// OldCreatedAt returns the old "created_at" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) - } - return oldValue.CreatedAt, nil -} - -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *EntityMutation) ResetCreatedAt() { - m.created_at = nil -} - -// SetUpdatedAt sets the "updated_at" field. -func (m *EntityMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t -} - -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *EntityMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at - if v == nil { - return - } - return *v, true -} - -// OldUpdatedAt returns the old "updated_at" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) - } - return oldValue.UpdatedAt, nil -} - -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *EntityMutation) ResetUpdatedAt() { - m.updated_at = nil -} - -// SetName sets the "name" field. -func (m *EntityMutation) SetName(s string) { - m.name = &s -} - -// Name returns the value of the "name" field in the mutation. -func (m *EntityMutation) Name() (r string, exists bool) { - v := m.name - if v == nil { - return - } - return *v, true -} - -// OldName returns the old "name" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) - } - return oldValue.Name, nil -} - -// ResetName resets all changes to the "name" field. -func (m *EntityMutation) ResetName() { - m.name = nil -} - -// SetDescription sets the "description" field. -func (m *EntityMutation) SetDescription(s string) { - m.description = &s -} - -// Description returns the value of the "description" field in the mutation. -func (m *EntityMutation) Description() (r string, exists bool) { - v := m.description - if v == nil { - return - } - return *v, true -} - -// OldDescription returns the old "description" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldDescription(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) - } - return oldValue.Description, nil -} - -// ClearDescription clears the value of the "description" field. -func (m *EntityMutation) ClearDescription() { - m.description = nil - m.clearedFields[entity.FieldDescription] = struct{}{} -} - -// DescriptionCleared returns if the "description" field was cleared in this mutation. -func (m *EntityMutation) DescriptionCleared() bool { - _, ok := m.clearedFields[entity.FieldDescription] - return ok -} - -// ResetDescription resets all changes to the "description" field. -func (m *EntityMutation) ResetDescription() { - m.description = nil - delete(m.clearedFields, entity.FieldDescription) -} - -// SetImportRef sets the "import_ref" field. -func (m *EntityMutation) SetImportRef(s string) { - m.import_ref = &s -} - -// ImportRef returns the value of the "import_ref" field in the mutation. -func (m *EntityMutation) ImportRef() (r string, exists bool) { - v := m.import_ref - if v == nil { - return - } - return *v, true -} - -// OldImportRef returns the old "import_ref" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldImportRef(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldImportRef is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldImportRef requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldImportRef: %w", err) - } - return oldValue.ImportRef, nil -} - -// ClearImportRef clears the value of the "import_ref" field. -func (m *EntityMutation) ClearImportRef() { - m.import_ref = nil - m.clearedFields[entity.FieldImportRef] = struct{}{} -} - -// ImportRefCleared returns if the "import_ref" field was cleared in this mutation. -func (m *EntityMutation) ImportRefCleared() bool { - _, ok := m.clearedFields[entity.FieldImportRef] - return ok -} - -// ResetImportRef resets all changes to the "import_ref" field. -func (m *EntityMutation) ResetImportRef() { - m.import_ref = nil - delete(m.clearedFields, entity.FieldImportRef) -} - -// SetNotes sets the "notes" field. -func (m *EntityMutation) SetNotes(s string) { - m.notes = &s -} - -// Notes returns the value of the "notes" field in the mutation. -func (m *EntityMutation) Notes() (r string, exists bool) { - v := m.notes - if v == nil { - return - } - return *v, true -} - -// OldNotes returns the old "notes" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldNotes(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldNotes is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldNotes requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldNotes: %w", err) - } - return oldValue.Notes, nil -} - -// ClearNotes clears the value of the "notes" field. -func (m *EntityMutation) ClearNotes() { - m.notes = nil - m.clearedFields[entity.FieldNotes] = struct{}{} -} - -// NotesCleared returns if the "notes" field was cleared in this mutation. -func (m *EntityMutation) NotesCleared() bool { - _, ok := m.clearedFields[entity.FieldNotes] - return ok -} - -// ResetNotes resets all changes to the "notes" field. -func (m *EntityMutation) ResetNotes() { - m.notes = nil - delete(m.clearedFields, entity.FieldNotes) -} - -// SetQuantity sets the "quantity" field. -func (m *EntityMutation) SetQuantity(i int) { - m.quantity = &i - m.addquantity = nil -} - -// Quantity returns the value of the "quantity" field in the mutation. -func (m *EntityMutation) Quantity() (r int, exists bool) { - v := m.quantity - if v == nil { - return - } - return *v, true -} - -// OldQuantity returns the old "quantity" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldQuantity(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldQuantity is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldQuantity requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldQuantity: %w", err) - } - return oldValue.Quantity, nil -} - -// AddQuantity adds i to the "quantity" field. -func (m *EntityMutation) AddQuantity(i int) { - if m.addquantity != nil { - *m.addquantity += i - } else { - m.addquantity = &i - } -} - -// AddedQuantity returns the value that was added to the "quantity" field in this mutation. -func (m *EntityMutation) AddedQuantity() (r int, exists bool) { - v := m.addquantity - if v == nil { - return - } - return *v, true -} - -// ResetQuantity resets all changes to the "quantity" field. -func (m *EntityMutation) ResetQuantity() { - m.quantity = nil - m.addquantity = nil -} - -// SetInsured sets the "insured" field. -func (m *EntityMutation) SetInsured(b bool) { - m.insured = &b -} - -// Insured returns the value of the "insured" field in the mutation. -func (m *EntityMutation) Insured() (r bool, exists bool) { - v := m.insured - if v == nil { - return - } - return *v, true -} - -// OldInsured returns the old "insured" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldInsured(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInsured is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInsured requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldInsured: %w", err) - } - return oldValue.Insured, nil -} - -// ResetInsured resets all changes to the "insured" field. -func (m *EntityMutation) ResetInsured() { - m.insured = nil -} - -// SetArchived sets the "archived" field. -func (m *EntityMutation) SetArchived(b bool) { - m.archived = &b -} - -// Archived returns the value of the "archived" field in the mutation. -func (m *EntityMutation) Archived() (r bool, exists bool) { - v := m.archived - if v == nil { - return - } - return *v, true -} - -// OldArchived returns the old "archived" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldArchived(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldArchived is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldArchived requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldArchived: %w", err) - } - return oldValue.Archived, nil -} - -// ResetArchived resets all changes to the "archived" field. -func (m *EntityMutation) ResetArchived() { - m.archived = nil -} - -// SetAssetID sets the "asset_id" field. -func (m *EntityMutation) SetAssetID(i int) { - m.asset_id = &i - m.addasset_id = nil -} - -// AssetID returns the value of the "asset_id" field in the mutation. -func (m *EntityMutation) AssetID() (r int, exists bool) { - v := m.asset_id - if v == nil { - return - } - return *v, true -} - -// OldAssetID returns the old "asset_id" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldAssetID(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAssetID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAssetID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldAssetID: %w", err) - } - return oldValue.AssetID, nil -} - -// AddAssetID adds i to the "asset_id" field. -func (m *EntityMutation) AddAssetID(i int) { - if m.addasset_id != nil { - *m.addasset_id += i - } else { - m.addasset_id = &i - } -} - -// AddedAssetID returns the value that was added to the "asset_id" field in this mutation. -func (m *EntityMutation) AddedAssetID() (r int, exists bool) { - v := m.addasset_id - if v == nil { - return - } - return *v, true -} - -// ResetAssetID resets all changes to the "asset_id" field. -func (m *EntityMutation) ResetAssetID() { - m.asset_id = nil - m.addasset_id = nil -} - -// SetSyncChildEntitiesLocations sets the "sync_child_entities_locations" field. -func (m *EntityMutation) SetSyncChildEntitiesLocations(b bool) { - m.sync_child_entities_locations = &b -} - -// SyncChildEntitiesLocations returns the value of the "sync_child_entities_locations" field in the mutation. -func (m *EntityMutation) SyncChildEntitiesLocations() (r bool, exists bool) { - v := m.sync_child_entities_locations - if v == nil { - return - } - return *v, true -} - -// OldSyncChildEntitiesLocations returns the old "sync_child_entities_locations" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldSyncChildEntitiesLocations(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSyncChildEntitiesLocations is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSyncChildEntitiesLocations requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSyncChildEntitiesLocations: %w", err) - } - return oldValue.SyncChildEntitiesLocations, nil -} - -// ResetSyncChildEntitiesLocations resets all changes to the "sync_child_entities_locations" field. -func (m *EntityMutation) ResetSyncChildEntitiesLocations() { - m.sync_child_entities_locations = nil -} - -// SetSerialNumber sets the "serial_number" field. -func (m *EntityMutation) SetSerialNumber(s string) { - m.serial_number = &s -} - -// SerialNumber returns the value of the "serial_number" field in the mutation. -func (m *EntityMutation) SerialNumber() (r string, exists bool) { - v := m.serial_number - if v == nil { - return - } - return *v, true -} - -// OldSerialNumber returns the old "serial_number" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldSerialNumber(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSerialNumber is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSerialNumber requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSerialNumber: %w", err) - } - return oldValue.SerialNumber, nil -} - -// ClearSerialNumber clears the value of the "serial_number" field. -func (m *EntityMutation) ClearSerialNumber() { - m.serial_number = nil - m.clearedFields[entity.FieldSerialNumber] = struct{}{} -} - -// SerialNumberCleared returns if the "serial_number" field was cleared in this mutation. -func (m *EntityMutation) SerialNumberCleared() bool { - _, ok := m.clearedFields[entity.FieldSerialNumber] - return ok -} - -// ResetSerialNumber resets all changes to the "serial_number" field. -func (m *EntityMutation) ResetSerialNumber() { - m.serial_number = nil - delete(m.clearedFields, entity.FieldSerialNumber) -} - -// SetModelNumber sets the "model_number" field. -func (m *EntityMutation) SetModelNumber(s string) { - m.model_number = &s -} - -// ModelNumber returns the value of the "model_number" field in the mutation. -func (m *EntityMutation) ModelNumber() (r string, exists bool) { - v := m.model_number - if v == nil { - return - } - return *v, true -} - -// OldModelNumber returns the old "model_number" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldModelNumber(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldModelNumber is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldModelNumber requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldModelNumber: %w", err) - } - return oldValue.ModelNumber, nil -} - -// ClearModelNumber clears the value of the "model_number" field. -func (m *EntityMutation) ClearModelNumber() { - m.model_number = nil - m.clearedFields[entity.FieldModelNumber] = struct{}{} -} - -// ModelNumberCleared returns if the "model_number" field was cleared in this mutation. -func (m *EntityMutation) ModelNumberCleared() bool { - _, ok := m.clearedFields[entity.FieldModelNumber] - return ok -} - -// ResetModelNumber resets all changes to the "model_number" field. -func (m *EntityMutation) ResetModelNumber() { - m.model_number = nil - delete(m.clearedFields, entity.FieldModelNumber) -} - -// SetManufacturer sets the "manufacturer" field. -func (m *EntityMutation) SetManufacturer(s string) { - m.manufacturer = &s -} - -// Manufacturer returns the value of the "manufacturer" field in the mutation. -func (m *EntityMutation) Manufacturer() (r string, exists bool) { - v := m.manufacturer - if v == nil { - return - } - return *v, true -} - -// OldManufacturer returns the old "manufacturer" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldManufacturer(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldManufacturer is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldManufacturer requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldManufacturer: %w", err) - } - return oldValue.Manufacturer, nil -} - -// ClearManufacturer clears the value of the "manufacturer" field. -func (m *EntityMutation) ClearManufacturer() { - m.manufacturer = nil - m.clearedFields[entity.FieldManufacturer] = struct{}{} -} - -// ManufacturerCleared returns if the "manufacturer" field was cleared in this mutation. -func (m *EntityMutation) ManufacturerCleared() bool { - _, ok := m.clearedFields[entity.FieldManufacturer] - return ok -} - -// ResetManufacturer resets all changes to the "manufacturer" field. -func (m *EntityMutation) ResetManufacturer() { - m.manufacturer = nil - delete(m.clearedFields, entity.FieldManufacturer) -} - -// SetLifetimeWarranty sets the "lifetime_warranty" field. -func (m *EntityMutation) SetLifetimeWarranty(b bool) { - m.lifetime_warranty = &b -} - -// LifetimeWarranty returns the value of the "lifetime_warranty" field in the mutation. -func (m *EntityMutation) LifetimeWarranty() (r bool, exists bool) { - v := m.lifetime_warranty - if v == nil { - return - } - return *v, true -} - -// OldLifetimeWarranty returns the old "lifetime_warranty" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldLifetimeWarranty(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLifetimeWarranty is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLifetimeWarranty requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldLifetimeWarranty: %w", err) - } - return oldValue.LifetimeWarranty, nil -} - -// ResetLifetimeWarranty resets all changes to the "lifetime_warranty" field. -func (m *EntityMutation) ResetLifetimeWarranty() { - m.lifetime_warranty = nil -} - -// SetWarrantyExpires sets the "warranty_expires" field. -func (m *EntityMutation) SetWarrantyExpires(t time.Time) { - m.warranty_expires = &t -} - -// WarrantyExpires returns the value of the "warranty_expires" field in the mutation. -func (m *EntityMutation) WarrantyExpires() (r time.Time, exists bool) { - v := m.warranty_expires - if v == nil { - return - } - return *v, true -} - -// OldWarrantyExpires returns the old "warranty_expires" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldWarrantyExpires(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldWarrantyExpires is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldWarrantyExpires requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldWarrantyExpires: %w", err) - } - return oldValue.WarrantyExpires, nil -} - -// ClearWarrantyExpires clears the value of the "warranty_expires" field. -func (m *EntityMutation) ClearWarrantyExpires() { - m.warranty_expires = nil - m.clearedFields[entity.FieldWarrantyExpires] = struct{}{} -} - -// WarrantyExpiresCleared returns if the "warranty_expires" field was cleared in this mutation. -func (m *EntityMutation) WarrantyExpiresCleared() bool { - _, ok := m.clearedFields[entity.FieldWarrantyExpires] - return ok -} - -// ResetWarrantyExpires resets all changes to the "warranty_expires" field. -func (m *EntityMutation) ResetWarrantyExpires() { - m.warranty_expires = nil - delete(m.clearedFields, entity.FieldWarrantyExpires) -} - -// SetWarrantyDetails sets the "warranty_details" field. -func (m *EntityMutation) SetWarrantyDetails(s string) { - m.warranty_details = &s -} - -// WarrantyDetails returns the value of the "warranty_details" field in the mutation. -func (m *EntityMutation) WarrantyDetails() (r string, exists bool) { - v := m.warranty_details - if v == nil { - return - } - return *v, true -} - -// OldWarrantyDetails returns the old "warranty_details" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldWarrantyDetails(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldWarrantyDetails is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldWarrantyDetails requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldWarrantyDetails: %w", err) - } - return oldValue.WarrantyDetails, nil -} - -// ClearWarrantyDetails clears the value of the "warranty_details" field. -func (m *EntityMutation) ClearWarrantyDetails() { - m.warranty_details = nil - m.clearedFields[entity.FieldWarrantyDetails] = struct{}{} -} - -// WarrantyDetailsCleared returns if the "warranty_details" field was cleared in this mutation. -func (m *EntityMutation) WarrantyDetailsCleared() bool { - _, ok := m.clearedFields[entity.FieldWarrantyDetails] - return ok -} - -// ResetWarrantyDetails resets all changes to the "warranty_details" field. -func (m *EntityMutation) ResetWarrantyDetails() { - m.warranty_details = nil - delete(m.clearedFields, entity.FieldWarrantyDetails) -} - -// SetPurchaseTime sets the "purchase_time" field. -func (m *EntityMutation) SetPurchaseTime(t time.Time) { - m.purchase_time = &t -} - -// PurchaseTime returns the value of the "purchase_time" field in the mutation. -func (m *EntityMutation) PurchaseTime() (r time.Time, exists bool) { - v := m.purchase_time - if v == nil { - return - } - return *v, true -} - -// OldPurchaseTime returns the old "purchase_time" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldPurchaseTime(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPurchaseTime is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPurchaseTime requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPurchaseTime: %w", err) - } - return oldValue.PurchaseTime, nil -} - -// ClearPurchaseTime clears the value of the "purchase_time" field. -func (m *EntityMutation) ClearPurchaseTime() { - m.purchase_time = nil - m.clearedFields[entity.FieldPurchaseTime] = struct{}{} -} - -// PurchaseTimeCleared returns if the "purchase_time" field was cleared in this mutation. -func (m *EntityMutation) PurchaseTimeCleared() bool { - _, ok := m.clearedFields[entity.FieldPurchaseTime] - return ok -} - -// ResetPurchaseTime resets all changes to the "purchase_time" field. -func (m *EntityMutation) ResetPurchaseTime() { - m.purchase_time = nil - delete(m.clearedFields, entity.FieldPurchaseTime) -} - -// SetPurchaseFrom sets the "purchase_from" field. -func (m *EntityMutation) SetPurchaseFrom(s string) { - m.purchase_from = &s -} - -// PurchaseFrom returns the value of the "purchase_from" field in the mutation. -func (m *EntityMutation) PurchaseFrom() (r string, exists bool) { - v := m.purchase_from - if v == nil { - return - } - return *v, true -} - -// OldPurchaseFrom returns the old "purchase_from" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldPurchaseFrom(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPurchaseFrom is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPurchaseFrom requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPurchaseFrom: %w", err) - } - return oldValue.PurchaseFrom, nil -} - -// ClearPurchaseFrom clears the value of the "purchase_from" field. -func (m *EntityMutation) ClearPurchaseFrom() { - m.purchase_from = nil - m.clearedFields[entity.FieldPurchaseFrom] = struct{}{} -} - -// PurchaseFromCleared returns if the "purchase_from" field was cleared in this mutation. -func (m *EntityMutation) PurchaseFromCleared() bool { - _, ok := m.clearedFields[entity.FieldPurchaseFrom] - return ok -} - -// ResetPurchaseFrom resets all changes to the "purchase_from" field. -func (m *EntityMutation) ResetPurchaseFrom() { - m.purchase_from = nil - delete(m.clearedFields, entity.FieldPurchaseFrom) -} - -// SetPurchasePrice sets the "purchase_price" field. -func (m *EntityMutation) SetPurchasePrice(f float64) { - m.purchase_price = &f - m.addpurchase_price = nil -} - -// PurchasePrice returns the value of the "purchase_price" field in the mutation. -func (m *EntityMutation) PurchasePrice() (r float64, exists bool) { - v := m.purchase_price - if v == nil { - return - } - return *v, true -} - -// OldPurchasePrice returns the old "purchase_price" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldPurchasePrice(ctx context.Context) (v float64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPurchasePrice is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPurchasePrice requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPurchasePrice: %w", err) - } - return oldValue.PurchasePrice, nil -} - -// AddPurchasePrice adds f to the "purchase_price" field. -func (m *EntityMutation) AddPurchasePrice(f float64) { - if m.addpurchase_price != nil { - *m.addpurchase_price += f - } else { - m.addpurchase_price = &f - } -} - -// AddedPurchasePrice returns the value that was added to the "purchase_price" field in this mutation. -func (m *EntityMutation) AddedPurchasePrice() (r float64, exists bool) { - v := m.addpurchase_price - if v == nil { - return - } - return *v, true -} - -// ResetPurchasePrice resets all changes to the "purchase_price" field. -func (m *EntityMutation) ResetPurchasePrice() { - m.purchase_price = nil - m.addpurchase_price = nil -} - -// SetSoldTime sets the "sold_time" field. -func (m *EntityMutation) SetSoldTime(t time.Time) { - m.sold_time = &t -} - -// SoldTime returns the value of the "sold_time" field in the mutation. -func (m *EntityMutation) SoldTime() (r time.Time, exists bool) { - v := m.sold_time - if v == nil { - return - } - return *v, true -} - -// OldSoldTime returns the old "sold_time" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldSoldTime(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSoldTime is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSoldTime requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSoldTime: %w", err) - } - return oldValue.SoldTime, nil -} - -// ClearSoldTime clears the value of the "sold_time" field. -func (m *EntityMutation) ClearSoldTime() { - m.sold_time = nil - m.clearedFields[entity.FieldSoldTime] = struct{}{} -} - -// SoldTimeCleared returns if the "sold_time" field was cleared in this mutation. -func (m *EntityMutation) SoldTimeCleared() bool { - _, ok := m.clearedFields[entity.FieldSoldTime] - return ok -} - -// ResetSoldTime resets all changes to the "sold_time" field. -func (m *EntityMutation) ResetSoldTime() { - m.sold_time = nil - delete(m.clearedFields, entity.FieldSoldTime) -} - -// SetSoldTo sets the "sold_to" field. -func (m *EntityMutation) SetSoldTo(s string) { - m.sold_to = &s -} - -// SoldTo returns the value of the "sold_to" field in the mutation. -func (m *EntityMutation) SoldTo() (r string, exists bool) { - v := m.sold_to - if v == nil { - return - } - return *v, true -} - -// OldSoldTo returns the old "sold_to" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldSoldTo(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSoldTo is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSoldTo requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSoldTo: %w", err) - } - return oldValue.SoldTo, nil -} - -// ClearSoldTo clears the value of the "sold_to" field. -func (m *EntityMutation) ClearSoldTo() { - m.sold_to = nil - m.clearedFields[entity.FieldSoldTo] = struct{}{} -} - -// SoldToCleared returns if the "sold_to" field was cleared in this mutation. -func (m *EntityMutation) SoldToCleared() bool { - _, ok := m.clearedFields[entity.FieldSoldTo] - return ok -} - -// ResetSoldTo resets all changes to the "sold_to" field. -func (m *EntityMutation) ResetSoldTo() { - m.sold_to = nil - delete(m.clearedFields, entity.FieldSoldTo) -} - -// SetSoldPrice sets the "sold_price" field. -func (m *EntityMutation) SetSoldPrice(f float64) { - m.sold_price = &f - m.addsold_price = nil -} - -// SoldPrice returns the value of the "sold_price" field in the mutation. -func (m *EntityMutation) SoldPrice() (r float64, exists bool) { - v := m.sold_price - if v == nil { - return - } - return *v, true -} - -// OldSoldPrice returns the old "sold_price" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldSoldPrice(ctx context.Context) (v float64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSoldPrice is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSoldPrice requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSoldPrice: %w", err) - } - return oldValue.SoldPrice, nil -} - -// AddSoldPrice adds f to the "sold_price" field. -func (m *EntityMutation) AddSoldPrice(f float64) { - if m.addsold_price != nil { - *m.addsold_price += f - } else { - m.addsold_price = &f - } -} - -// AddedSoldPrice returns the value that was added to the "sold_price" field in this mutation. -func (m *EntityMutation) AddedSoldPrice() (r float64, exists bool) { - v := m.addsold_price - if v == nil { - return - } - return *v, true -} - -// ResetSoldPrice resets all changes to the "sold_price" field. -func (m *EntityMutation) ResetSoldPrice() { - m.sold_price = nil - m.addsold_price = nil -} - -// SetSoldNotes sets the "sold_notes" field. -func (m *EntityMutation) SetSoldNotes(s string) { - m.sold_notes = &s -} - -// SoldNotes returns the value of the "sold_notes" field in the mutation. -func (m *EntityMutation) SoldNotes() (r string, exists bool) { - v := m.sold_notes - if v == nil { - return - } - return *v, true -} - -// OldSoldNotes returns the old "sold_notes" field's value of the Entity entity. -// If the Entity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityMutation) OldSoldNotes(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSoldNotes is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSoldNotes requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSoldNotes: %w", err) - } - return oldValue.SoldNotes, nil -} - -// ClearSoldNotes clears the value of the "sold_notes" field. -func (m *EntityMutation) ClearSoldNotes() { - m.sold_notes = nil - m.clearedFields[entity.FieldSoldNotes] = struct{}{} -} - -// SoldNotesCleared returns if the "sold_notes" field was cleared in this mutation. -func (m *EntityMutation) SoldNotesCleared() bool { - _, ok := m.clearedFields[entity.FieldSoldNotes] - return ok -} - -// ResetSoldNotes resets all changes to the "sold_notes" field. -func (m *EntityMutation) ResetSoldNotes() { - m.sold_notes = nil - delete(m.clearedFields, entity.FieldSoldNotes) -} - -// SetGroupID sets the "group" edge to the Group entity by id. -func (m *EntityMutation) SetGroupID(id uuid.UUID) { - m.group = &id -} - -// ClearGroup clears the "group" edge to the Group entity. -func (m *EntityMutation) ClearGroup() { - m.clearedgroup = true -} - -// GroupCleared reports if the "group" edge to the Group entity was cleared. -func (m *EntityMutation) GroupCleared() bool { - return m.clearedgroup -} - -// GroupID returns the "group" edge ID in the mutation. -func (m *EntityMutation) GroupID() (id uuid.UUID, exists bool) { - if m.group != nil { - return *m.group, true - } - return -} - -// GroupIDs returns the "group" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// GroupID instead. It exists only for internal usage by the builders. -func (m *EntityMutation) GroupIDs() (ids []uuid.UUID) { - if id := m.group; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetGroup resets all changes to the "group" edge. -func (m *EntityMutation) ResetGroup() { - m.group = nil - m.clearedgroup = false -} - -// AddChildIDs adds the "children" edge to the Entity entity by ids. -func (m *EntityMutation) AddChildIDs(ids ...uuid.UUID) { - if m.children == nil { - m.children = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.children[ids[i]] = struct{}{} - } -} - -// ClearChildren clears the "children" edge to the Entity entity. -func (m *EntityMutation) ClearChildren() { - m.clearedchildren = true -} - -// ChildrenCleared reports if the "children" edge to the Entity entity was cleared. -func (m *EntityMutation) ChildrenCleared() bool { - return m.clearedchildren -} - -// RemoveChildIDs removes the "children" edge to the Entity entity by IDs. -func (m *EntityMutation) RemoveChildIDs(ids ...uuid.UUID) { - if m.removedchildren == nil { - m.removedchildren = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.children, ids[i]) - m.removedchildren[ids[i]] = struct{}{} - } -} - -// RemovedChildren returns the removed IDs of the "children" edge to the Entity entity. -func (m *EntityMutation) RemovedChildrenIDs() (ids []uuid.UUID) { - for id := range m.removedchildren { - ids = append(ids, id) - } - return -} - -// ChildrenIDs returns the "children" edge IDs in the mutation. -func (m *EntityMutation) ChildrenIDs() (ids []uuid.UUID) { - for id := range m.children { - ids = append(ids, id) - } - return -} - -// ResetChildren resets all changes to the "children" edge. -func (m *EntityMutation) ResetChildren() { - m.children = nil - m.clearedchildren = false - m.removedchildren = nil -} - -// SetParentID sets the "parent" edge to the Entity entity by id. -func (m *EntityMutation) SetParentID(id uuid.UUID) { - m.parent = &id -} - -// ClearParent clears the "parent" edge to the Entity entity. -func (m *EntityMutation) ClearParent() { - m.clearedparent = true -} - -// ParentCleared reports if the "parent" edge to the Entity entity was cleared. -func (m *EntityMutation) ParentCleared() bool { - return m.clearedparent -} - -// ParentID returns the "parent" edge ID in the mutation. -func (m *EntityMutation) ParentID() (id uuid.UUID, exists bool) { - if m.parent != nil { - return *m.parent, true - } - return -} - -// ParentIDs returns the "parent" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// ParentID instead. It exists only for internal usage by the builders. -func (m *EntityMutation) ParentIDs() (ids []uuid.UUID) { - if id := m.parent; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetParent resets all changes to the "parent" edge. -func (m *EntityMutation) ResetParent() { - m.parent = nil - m.clearedparent = false -} - -// AddEntityIDs adds the "entity" edge to the Entity entity by ids. -func (m *EntityMutation) AddEntityIDs(ids ...uuid.UUID) { - if m.entity == nil { - m.entity = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.entity[ids[i]] = struct{}{} - } -} - -// ClearEntity clears the "entity" edge to the Entity entity. -func (m *EntityMutation) ClearEntity() { - m.clearedentity = true -} - -// EntityCleared reports if the "entity" edge to the Entity entity was cleared. -func (m *EntityMutation) EntityCleared() bool { - return m.clearedentity -} - -// RemoveEntityIDs removes the "entity" edge to the Entity entity by IDs. -func (m *EntityMutation) RemoveEntityIDs(ids ...uuid.UUID) { - if m.removedentity == nil { - m.removedentity = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.entity, ids[i]) - m.removedentity[ids[i]] = struct{}{} - } -} - -// RemovedEntity returns the removed IDs of the "entity" edge to the Entity entity. -func (m *EntityMutation) RemovedEntityIDs() (ids []uuid.UUID) { - for id := range m.removedentity { - ids = append(ids, id) - } - return -} - -// EntityIDs returns the "entity" edge IDs in the mutation. -func (m *EntityMutation) EntityIDs() (ids []uuid.UUID) { - for id := range m.entity { - ids = append(ids, id) - } - return -} - -// ResetEntity resets all changes to the "entity" edge. -func (m *EntityMutation) ResetEntity() { - m.entity = nil - m.clearedentity = false - m.removedentity = nil -} - -// SetLocationID sets the "location" edge to the Entity entity by id. -func (m *EntityMutation) SetLocationID(id uuid.UUID) { - m.location = &id -} - -// ClearLocation clears the "location" edge to the Entity entity. -func (m *EntityMutation) ClearLocation() { - m.clearedlocation = true -} - -// LocationCleared reports if the "location" edge to the Entity entity was cleared. -func (m *EntityMutation) LocationCleared() bool { - return m.clearedlocation -} - -// LocationID returns the "location" edge ID in the mutation. -func (m *EntityMutation) LocationID() (id uuid.UUID, exists bool) { - if m.location != nil { - return *m.location, true - } - return -} - -// LocationIDs returns the "location" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// LocationID instead. It exists only for internal usage by the builders. -func (m *EntityMutation) LocationIDs() (ids []uuid.UUID) { - if id := m.location; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetLocation resets all changes to the "location" edge. -func (m *EntityMutation) ResetLocation() { - m.location = nil - m.clearedlocation = false -} - -// AddLabelIDs adds the "label" edge to the Label entity by ids. -func (m *EntityMutation) AddLabelIDs(ids ...uuid.UUID) { - if m.label == nil { - m.label = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.label[ids[i]] = struct{}{} - } -} - -// ClearLabel clears the "label" edge to the Label entity. -func (m *EntityMutation) ClearLabel() { - m.clearedlabel = true -} - -// LabelCleared reports if the "label" edge to the Label entity was cleared. -func (m *EntityMutation) LabelCleared() bool { - return m.clearedlabel -} - -// RemoveLabelIDs removes the "label" edge to the Label entity by IDs. -func (m *EntityMutation) RemoveLabelIDs(ids ...uuid.UUID) { - if m.removedlabel == nil { - m.removedlabel = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.label, ids[i]) - m.removedlabel[ids[i]] = struct{}{} - } -} - -// RemovedLabel returns the removed IDs of the "label" edge to the Label entity. -func (m *EntityMutation) RemovedLabelIDs() (ids []uuid.UUID) { - for id := range m.removedlabel { - ids = append(ids, id) - } - return -} - -// LabelIDs returns the "label" edge IDs in the mutation. -func (m *EntityMutation) LabelIDs() (ids []uuid.UUID) { - for id := range m.label { - ids = append(ids, id) - } - return -} - -// ResetLabel resets all changes to the "label" edge. -func (m *EntityMutation) ResetLabel() { - m.label = nil - m.clearedlabel = false - m.removedlabel = nil -} - -// SetTypeID sets the "type" edge to the EntityType entity by id. -func (m *EntityMutation) SetTypeID(id uuid.UUID) { - m._type = &id -} - -// ClearType clears the "type" edge to the EntityType entity. -func (m *EntityMutation) ClearType() { - m.cleared_type = true -} - -// TypeCleared reports if the "type" edge to the EntityType entity was cleared. -func (m *EntityMutation) TypeCleared() bool { - return m.cleared_type -} - -// TypeID returns the "type" edge ID in the mutation. -func (m *EntityMutation) TypeID() (id uuid.UUID, exists bool) { - if m._type != nil { - return *m._type, true - } - return -} - -// TypeIDs returns the "type" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// TypeID instead. It exists only for internal usage by the builders. -func (m *EntityMutation) TypeIDs() (ids []uuid.UUID) { - if id := m._type; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetType resets all changes to the "type" edge. -func (m *EntityMutation) ResetType() { - m._type = nil - m.cleared_type = false -} - -// AddFieldIDs adds the "fields" edge to the EntityField entity by ids. -func (m *EntityMutation) AddFieldIDs(ids ...uuid.UUID) { - if m.fields == nil { - m.fields = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.fields[ids[i]] = struct{}{} - } -} - -// ClearFields clears the "fields" edge to the EntityField entity. -func (m *EntityMutation) ClearFields() { - m.clearedfields = true -} - -// FieldsCleared reports if the "fields" edge to the EntityField entity was cleared. -func (m *EntityMutation) FieldsCleared() bool { - return m.clearedfields -} - -// RemoveFieldIDs removes the "fields" edge to the EntityField entity by IDs. -func (m *EntityMutation) RemoveFieldIDs(ids ...uuid.UUID) { - if m.removedfields == nil { - m.removedfields = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.fields, ids[i]) - m.removedfields[ids[i]] = struct{}{} - } -} - -// RemovedFields returns the removed IDs of the "fields" edge to the EntityField entity. -func (m *EntityMutation) RemovedFieldsIDs() (ids []uuid.UUID) { - for id := range m.removedfields { - ids = append(ids, id) - } - return -} - -// FieldsIDs returns the "fields" edge IDs in the mutation. -func (m *EntityMutation) FieldsIDs() (ids []uuid.UUID) { - for id := range m.fields { - ids = append(ids, id) - } - return -} - -// ResetFields resets all changes to the "fields" edge. -func (m *EntityMutation) ResetFields() { - m.fields = nil - m.clearedfields = false - m.removedfields = nil -} - -// AddMaintenanceEntryIDs adds the "maintenance_entries" edge to the MaintenanceEntry entity by ids. -func (m *EntityMutation) AddMaintenanceEntryIDs(ids ...uuid.UUID) { - if m.maintenance_entries == nil { - m.maintenance_entries = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.maintenance_entries[ids[i]] = struct{}{} - } -} - -// ClearMaintenanceEntries clears the "maintenance_entries" edge to the MaintenanceEntry entity. -func (m *EntityMutation) ClearMaintenanceEntries() { - m.clearedmaintenance_entries = true -} - -// MaintenanceEntriesCleared reports if the "maintenance_entries" edge to the MaintenanceEntry entity was cleared. -func (m *EntityMutation) MaintenanceEntriesCleared() bool { - return m.clearedmaintenance_entries -} - -// RemoveMaintenanceEntryIDs removes the "maintenance_entries" edge to the MaintenanceEntry entity by IDs. -func (m *EntityMutation) RemoveMaintenanceEntryIDs(ids ...uuid.UUID) { - if m.removedmaintenance_entries == nil { - m.removedmaintenance_entries = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.maintenance_entries, ids[i]) - m.removedmaintenance_entries[ids[i]] = struct{}{} - } -} - -// RemovedMaintenanceEntries returns the removed IDs of the "maintenance_entries" edge to the MaintenanceEntry entity. -func (m *EntityMutation) RemovedMaintenanceEntriesIDs() (ids []uuid.UUID) { - for id := range m.removedmaintenance_entries { - ids = append(ids, id) - } - return -} - -// MaintenanceEntriesIDs returns the "maintenance_entries" edge IDs in the mutation. -func (m *EntityMutation) MaintenanceEntriesIDs() (ids []uuid.UUID) { - for id := range m.maintenance_entries { - ids = append(ids, id) - } - return -} - -// ResetMaintenanceEntries resets all changes to the "maintenance_entries" edge. -func (m *EntityMutation) ResetMaintenanceEntries() { - m.maintenance_entries = nil - m.clearedmaintenance_entries = false - m.removedmaintenance_entries = nil -} - -// AddAttachmentIDs adds the "attachments" edge to the Attachment entity by ids. -func (m *EntityMutation) AddAttachmentIDs(ids ...uuid.UUID) { - if m.attachments == nil { - m.attachments = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.attachments[ids[i]] = struct{}{} - } -} - -// ClearAttachments clears the "attachments" edge to the Attachment entity. -func (m *EntityMutation) ClearAttachments() { - m.clearedattachments = true -} - -// AttachmentsCleared reports if the "attachments" edge to the Attachment entity was cleared. -func (m *EntityMutation) AttachmentsCleared() bool { - return m.clearedattachments -} - -// RemoveAttachmentIDs removes the "attachments" edge to the Attachment entity by IDs. -func (m *EntityMutation) RemoveAttachmentIDs(ids ...uuid.UUID) { - if m.removedattachments == nil { - m.removedattachments = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.attachments, ids[i]) - m.removedattachments[ids[i]] = struct{}{} - } -} - -// RemovedAttachments returns the removed IDs of the "attachments" edge to the Attachment entity. -func (m *EntityMutation) RemovedAttachmentsIDs() (ids []uuid.UUID) { - for id := range m.removedattachments { - ids = append(ids, id) - } - return -} - -// AttachmentsIDs returns the "attachments" edge IDs in the mutation. -func (m *EntityMutation) AttachmentsIDs() (ids []uuid.UUID) { - for id := range m.attachments { - ids = append(ids, id) - } - return -} - -// ResetAttachments resets all changes to the "attachments" edge. -func (m *EntityMutation) ResetAttachments() { - m.attachments = nil - m.clearedattachments = false - m.removedattachments = nil -} - -// Where appends a list predicates to the EntityMutation builder. -func (m *EntityMutation) Where(ps ...predicate.Entity) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the EntityMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *EntityMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Entity, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *EntityMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *EntityMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (Entity). -func (m *EntityMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *EntityMutation) Fields() []string { - fields := make([]string, 0, 24) - if m.created_at != nil { - fields = append(fields, entity.FieldCreatedAt) - } - if m.updated_at != nil { - fields = append(fields, entity.FieldUpdatedAt) - } - if m.name != nil { - fields = append(fields, entity.FieldName) - } - if m.description != nil { - fields = append(fields, entity.FieldDescription) - } - if m.import_ref != nil { - fields = append(fields, entity.FieldImportRef) - } - if m.notes != nil { - fields = append(fields, entity.FieldNotes) - } - if m.quantity != nil { - fields = append(fields, entity.FieldQuantity) - } - if m.insured != nil { - fields = append(fields, entity.FieldInsured) - } - if m.archived != nil { - fields = append(fields, entity.FieldArchived) - } - if m.asset_id != nil { - fields = append(fields, entity.FieldAssetID) - } - if m.sync_child_entities_locations != nil { - fields = append(fields, entity.FieldSyncChildEntitiesLocations) - } - if m.serial_number != nil { - fields = append(fields, entity.FieldSerialNumber) - } - if m.model_number != nil { - fields = append(fields, entity.FieldModelNumber) - } - if m.manufacturer != nil { - fields = append(fields, entity.FieldManufacturer) - } - if m.lifetime_warranty != nil { - fields = append(fields, entity.FieldLifetimeWarranty) - } - if m.warranty_expires != nil { - fields = append(fields, entity.FieldWarrantyExpires) - } - if m.warranty_details != nil { - fields = append(fields, entity.FieldWarrantyDetails) - } - if m.purchase_time != nil { - fields = append(fields, entity.FieldPurchaseTime) - } - if m.purchase_from != nil { - fields = append(fields, entity.FieldPurchaseFrom) - } - if m.purchase_price != nil { - fields = append(fields, entity.FieldPurchasePrice) - } - if m.sold_time != nil { - fields = append(fields, entity.FieldSoldTime) - } - if m.sold_to != nil { - fields = append(fields, entity.FieldSoldTo) - } - if m.sold_price != nil { - fields = append(fields, entity.FieldSoldPrice) - } - if m.sold_notes != nil { - fields = append(fields, entity.FieldSoldNotes) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *EntityMutation) Field(name string) (ent.Value, bool) { - switch name { - case entity.FieldCreatedAt: - return m.CreatedAt() - case entity.FieldUpdatedAt: - return m.UpdatedAt() - case entity.FieldName: - return m.Name() - case entity.FieldDescription: - return m.Description() - case entity.FieldImportRef: - return m.ImportRef() - case entity.FieldNotes: - return m.Notes() - case entity.FieldQuantity: - return m.Quantity() - case entity.FieldInsured: - return m.Insured() - case entity.FieldArchived: - return m.Archived() - case entity.FieldAssetID: - return m.AssetID() - case entity.FieldSyncChildEntitiesLocations: - return m.SyncChildEntitiesLocations() - case entity.FieldSerialNumber: - return m.SerialNumber() - case entity.FieldModelNumber: - return m.ModelNumber() - case entity.FieldManufacturer: - return m.Manufacturer() - case entity.FieldLifetimeWarranty: - return m.LifetimeWarranty() - case entity.FieldWarrantyExpires: - return m.WarrantyExpires() - case entity.FieldWarrantyDetails: - return m.WarrantyDetails() - case entity.FieldPurchaseTime: - return m.PurchaseTime() - case entity.FieldPurchaseFrom: - return m.PurchaseFrom() - case entity.FieldPurchasePrice: - return m.PurchasePrice() - case entity.FieldSoldTime: - return m.SoldTime() - case entity.FieldSoldTo: - return m.SoldTo() - case entity.FieldSoldPrice: - return m.SoldPrice() - case entity.FieldSoldNotes: - return m.SoldNotes() - } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *EntityMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case entity.FieldCreatedAt: - return m.OldCreatedAt(ctx) - case entity.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) - case entity.FieldName: - return m.OldName(ctx) - case entity.FieldDescription: - return m.OldDescription(ctx) - case entity.FieldImportRef: - return m.OldImportRef(ctx) - case entity.FieldNotes: - return m.OldNotes(ctx) - case entity.FieldQuantity: - return m.OldQuantity(ctx) - case entity.FieldInsured: - return m.OldInsured(ctx) - case entity.FieldArchived: - return m.OldArchived(ctx) - case entity.FieldAssetID: - return m.OldAssetID(ctx) - case entity.FieldSyncChildEntitiesLocations: - return m.OldSyncChildEntitiesLocations(ctx) - case entity.FieldSerialNumber: - return m.OldSerialNumber(ctx) - case entity.FieldModelNumber: - return m.OldModelNumber(ctx) - case entity.FieldManufacturer: - return m.OldManufacturer(ctx) - case entity.FieldLifetimeWarranty: - return m.OldLifetimeWarranty(ctx) - case entity.FieldWarrantyExpires: - return m.OldWarrantyExpires(ctx) - case entity.FieldWarrantyDetails: - return m.OldWarrantyDetails(ctx) - case entity.FieldPurchaseTime: - return m.OldPurchaseTime(ctx) - case entity.FieldPurchaseFrom: - return m.OldPurchaseFrom(ctx) - case entity.FieldPurchasePrice: - return m.OldPurchasePrice(ctx) - case entity.FieldSoldTime: - return m.OldSoldTime(ctx) - case entity.FieldSoldTo: - return m.OldSoldTo(ctx) - case entity.FieldSoldPrice: - return m.OldSoldPrice(ctx) - case entity.FieldSoldNotes: - return m.OldSoldNotes(ctx) - } - return nil, fmt.Errorf("unknown Entity field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *EntityMutation) SetField(name string, value ent.Value) error { - switch name { - case entity.FieldCreatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreatedAt(v) - return nil - case entity.FieldUpdatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdatedAt(v) - return nil - case entity.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case entity.FieldDescription: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDescription(v) - return nil - case entity.FieldImportRef: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetImportRef(v) - return nil - case entity.FieldNotes: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetNotes(v) - return nil - case entity.FieldQuantity: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetQuantity(v) - return nil - case entity.FieldInsured: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetInsured(v) - return nil - case entity.FieldArchived: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetArchived(v) - return nil - case entity.FieldAssetID: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAssetID(v) - return nil - case entity.FieldSyncChildEntitiesLocations: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSyncChildEntitiesLocations(v) - return nil - case entity.FieldSerialNumber: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSerialNumber(v) - return nil - case entity.FieldModelNumber: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetModelNumber(v) - return nil - case entity.FieldManufacturer: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetManufacturer(v) - return nil - case entity.FieldLifetimeWarranty: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLifetimeWarranty(v) - return nil - case entity.FieldWarrantyExpires: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetWarrantyExpires(v) - return nil - case entity.FieldWarrantyDetails: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetWarrantyDetails(v) - return nil - case entity.FieldPurchaseTime: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPurchaseTime(v) - return nil - case entity.FieldPurchaseFrom: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPurchaseFrom(v) - return nil - case entity.FieldPurchasePrice: - v, ok := value.(float64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPurchasePrice(v) - return nil - case entity.FieldSoldTime: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSoldTime(v) - return nil - case entity.FieldSoldTo: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSoldTo(v) - return nil - case entity.FieldSoldPrice: - v, ok := value.(float64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSoldPrice(v) - return nil - case entity.FieldSoldNotes: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSoldNotes(v) - return nil - } - return fmt.Errorf("unknown Entity field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *EntityMutation) AddedFields() []string { - var fields []string - if m.addquantity != nil { - fields = append(fields, entity.FieldQuantity) - } - if m.addasset_id != nil { - fields = append(fields, entity.FieldAssetID) - } - if m.addpurchase_price != nil { - fields = append(fields, entity.FieldPurchasePrice) - } - if m.addsold_price != nil { - fields = append(fields, entity.FieldSoldPrice) - } - return fields -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *EntityMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case entity.FieldQuantity: - return m.AddedQuantity() - case entity.FieldAssetID: - return m.AddedAssetID() - case entity.FieldPurchasePrice: - return m.AddedPurchasePrice() - case entity.FieldSoldPrice: - return m.AddedSoldPrice() - } - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *EntityMutation) AddField(name string, value ent.Value) error { - switch name { - case entity.FieldQuantity: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddQuantity(v) - return nil - case entity.FieldAssetID: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddAssetID(v) - return nil - case entity.FieldPurchasePrice: - v, ok := value.(float64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddPurchasePrice(v) - return nil - case entity.FieldSoldPrice: - v, ok := value.(float64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddSoldPrice(v) - return nil - } - return fmt.Errorf("unknown Entity numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *EntityMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(entity.FieldDescription) { - fields = append(fields, entity.FieldDescription) - } - if m.FieldCleared(entity.FieldImportRef) { - fields = append(fields, entity.FieldImportRef) - } - if m.FieldCleared(entity.FieldNotes) { - fields = append(fields, entity.FieldNotes) - } - if m.FieldCleared(entity.FieldSerialNumber) { - fields = append(fields, entity.FieldSerialNumber) - } - if m.FieldCleared(entity.FieldModelNumber) { - fields = append(fields, entity.FieldModelNumber) - } - if m.FieldCleared(entity.FieldManufacturer) { - fields = append(fields, entity.FieldManufacturer) - } - if m.FieldCleared(entity.FieldWarrantyExpires) { - fields = append(fields, entity.FieldWarrantyExpires) - } - if m.FieldCleared(entity.FieldWarrantyDetails) { - fields = append(fields, entity.FieldWarrantyDetails) - } - if m.FieldCleared(entity.FieldPurchaseTime) { - fields = append(fields, entity.FieldPurchaseTime) - } - if m.FieldCleared(entity.FieldPurchaseFrom) { - fields = append(fields, entity.FieldPurchaseFrom) - } - if m.FieldCleared(entity.FieldSoldTime) { - fields = append(fields, entity.FieldSoldTime) - } - if m.FieldCleared(entity.FieldSoldTo) { - fields = append(fields, entity.FieldSoldTo) - } - if m.FieldCleared(entity.FieldSoldNotes) { - fields = append(fields, entity.FieldSoldNotes) - } - return fields -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *EntityMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok -} - -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *EntityMutation) ClearField(name string) error { - switch name { - case entity.FieldDescription: - m.ClearDescription() - return nil - case entity.FieldImportRef: - m.ClearImportRef() - return nil - case entity.FieldNotes: - m.ClearNotes() - return nil - case entity.FieldSerialNumber: - m.ClearSerialNumber() - return nil - case entity.FieldModelNumber: - m.ClearModelNumber() - return nil - case entity.FieldManufacturer: - m.ClearManufacturer() - return nil - case entity.FieldWarrantyExpires: - m.ClearWarrantyExpires() - return nil - case entity.FieldWarrantyDetails: - m.ClearWarrantyDetails() - return nil - case entity.FieldPurchaseTime: - m.ClearPurchaseTime() - return nil - case entity.FieldPurchaseFrom: - m.ClearPurchaseFrom() - return nil - case entity.FieldSoldTime: - m.ClearSoldTime() - return nil - case entity.FieldSoldTo: - m.ClearSoldTo() - return nil - case entity.FieldSoldNotes: - m.ClearSoldNotes() - return nil - } - return fmt.Errorf("unknown Entity nullable field %s", name) -} - -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *EntityMutation) ResetField(name string) error { - switch name { - case entity.FieldCreatedAt: - m.ResetCreatedAt() - return nil - case entity.FieldUpdatedAt: - m.ResetUpdatedAt() - return nil - case entity.FieldName: - m.ResetName() - return nil - case entity.FieldDescription: - m.ResetDescription() - return nil - case entity.FieldImportRef: - m.ResetImportRef() - return nil - case entity.FieldNotes: - m.ResetNotes() - return nil - case entity.FieldQuantity: - m.ResetQuantity() - return nil - case entity.FieldInsured: - m.ResetInsured() - return nil - case entity.FieldArchived: - m.ResetArchived() - return nil - case entity.FieldAssetID: - m.ResetAssetID() - return nil - case entity.FieldSyncChildEntitiesLocations: - m.ResetSyncChildEntitiesLocations() - return nil - case entity.FieldSerialNumber: - m.ResetSerialNumber() - return nil - case entity.FieldModelNumber: - m.ResetModelNumber() - return nil - case entity.FieldManufacturer: - m.ResetManufacturer() - return nil - case entity.FieldLifetimeWarranty: - m.ResetLifetimeWarranty() - return nil - case entity.FieldWarrantyExpires: - m.ResetWarrantyExpires() - return nil - case entity.FieldWarrantyDetails: - m.ResetWarrantyDetails() - return nil - case entity.FieldPurchaseTime: - m.ResetPurchaseTime() - return nil - case entity.FieldPurchaseFrom: - m.ResetPurchaseFrom() - return nil - case entity.FieldPurchasePrice: - m.ResetPurchasePrice() - return nil - case entity.FieldSoldTime: - m.ResetSoldTime() - return nil - case entity.FieldSoldTo: - m.ResetSoldTo() - return nil - case entity.FieldSoldPrice: - m.ResetSoldPrice() - return nil - case entity.FieldSoldNotes: - m.ResetSoldNotes() - return nil - } - return fmt.Errorf("unknown Entity field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *EntityMutation) AddedEdges() []string { - edges := make([]string, 0, 10) - if m.group != nil { - edges = append(edges, entity.EdgeGroup) - } - if m.children != nil { - edges = append(edges, entity.EdgeChildren) - } - if m.parent != nil { - edges = append(edges, entity.EdgeParent) - } - if m.entity != nil { - edges = append(edges, entity.EdgeEntity) - } - if m.location != nil { - edges = append(edges, entity.EdgeLocation) - } - if m.label != nil { - edges = append(edges, entity.EdgeLabel) - } - if m._type != nil { - edges = append(edges, entity.EdgeType) - } - if m.fields != nil { - edges = append(edges, entity.EdgeFields) - } - if m.maintenance_entries != nil { - edges = append(edges, entity.EdgeMaintenanceEntries) - } - if m.attachments != nil { - edges = append(edges, entity.EdgeAttachments) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *EntityMutation) AddedIDs(name string) []ent.Value { - switch name { - case entity.EdgeGroup: - if id := m.group; id != nil { - return []ent.Value{*id} - } - case entity.EdgeChildren: - ids := make([]ent.Value, 0, len(m.children)) - for id := range m.children { - ids = append(ids, id) - } - return ids - case entity.EdgeParent: - if id := m.parent; id != nil { - return []ent.Value{*id} - } - case entity.EdgeEntity: - ids := make([]ent.Value, 0, len(m.entity)) - for id := range m.entity { - ids = append(ids, id) - } - return ids - case entity.EdgeLocation: - if id := m.location; id != nil { - return []ent.Value{*id} - } - case entity.EdgeLabel: - ids := make([]ent.Value, 0, len(m.label)) - for id := range m.label { - ids = append(ids, id) - } - return ids - case entity.EdgeType: - if id := m._type; id != nil { - return []ent.Value{*id} - } - case entity.EdgeFields: - ids := make([]ent.Value, 0, len(m.fields)) - for id := range m.fields { - ids = append(ids, id) - } - return ids - case entity.EdgeMaintenanceEntries: - ids := make([]ent.Value, 0, len(m.maintenance_entries)) - for id := range m.maintenance_entries { - ids = append(ids, id) - } - return ids - case entity.EdgeAttachments: - ids := make([]ent.Value, 0, len(m.attachments)) - for id := range m.attachments { - ids = append(ids, id) - } - return ids - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *EntityMutation) RemovedEdges() []string { - edges := make([]string, 0, 10) - if m.removedchildren != nil { - edges = append(edges, entity.EdgeChildren) - } - if m.removedentity != nil { - edges = append(edges, entity.EdgeEntity) - } - if m.removedlabel != nil { - edges = append(edges, entity.EdgeLabel) - } - if m.removedfields != nil { - edges = append(edges, entity.EdgeFields) - } - if m.removedmaintenance_entries != nil { - edges = append(edges, entity.EdgeMaintenanceEntries) - } - if m.removedattachments != nil { - edges = append(edges, entity.EdgeAttachments) - } - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *EntityMutation) RemovedIDs(name string) []ent.Value { - switch name { - case entity.EdgeChildren: - ids := make([]ent.Value, 0, len(m.removedchildren)) - for id := range m.removedchildren { - ids = append(ids, id) - } - return ids - case entity.EdgeEntity: - ids := make([]ent.Value, 0, len(m.removedentity)) - for id := range m.removedentity { - ids = append(ids, id) - } - return ids - case entity.EdgeLabel: - ids := make([]ent.Value, 0, len(m.removedlabel)) - for id := range m.removedlabel { - ids = append(ids, id) - } - return ids - case entity.EdgeFields: - ids := make([]ent.Value, 0, len(m.removedfields)) - for id := range m.removedfields { - ids = append(ids, id) - } - return ids - case entity.EdgeMaintenanceEntries: - ids := make([]ent.Value, 0, len(m.removedmaintenance_entries)) - for id := range m.removedmaintenance_entries { - ids = append(ids, id) - } - return ids - case entity.EdgeAttachments: - ids := make([]ent.Value, 0, len(m.removedattachments)) - for id := range m.removedattachments { - ids = append(ids, id) - } - return ids - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *EntityMutation) ClearedEdges() []string { - edges := make([]string, 0, 10) - if m.clearedgroup { - edges = append(edges, entity.EdgeGroup) - } - if m.clearedchildren { - edges = append(edges, entity.EdgeChildren) - } - if m.clearedparent { - edges = append(edges, entity.EdgeParent) - } - if m.clearedentity { - edges = append(edges, entity.EdgeEntity) - } - if m.clearedlocation { - edges = append(edges, entity.EdgeLocation) - } - if m.clearedlabel { - edges = append(edges, entity.EdgeLabel) - } - if m.cleared_type { - edges = append(edges, entity.EdgeType) - } - if m.clearedfields { - edges = append(edges, entity.EdgeFields) - } - if m.clearedmaintenance_entries { - edges = append(edges, entity.EdgeMaintenanceEntries) - } - if m.clearedattachments { - edges = append(edges, entity.EdgeAttachments) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *EntityMutation) EdgeCleared(name string) bool { - switch name { - case entity.EdgeGroup: - return m.clearedgroup - case entity.EdgeChildren: - return m.clearedchildren - case entity.EdgeParent: - return m.clearedparent - case entity.EdgeEntity: - return m.clearedentity - case entity.EdgeLocation: - return m.clearedlocation - case entity.EdgeLabel: - return m.clearedlabel - case entity.EdgeType: - return m.cleared_type - case entity.EdgeFields: - return m.clearedfields - case entity.EdgeMaintenanceEntries: - return m.clearedmaintenance_entries - case entity.EdgeAttachments: - return m.clearedattachments - } - return false -} - -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *EntityMutation) ClearEdge(name string) error { - switch name { - case entity.EdgeGroup: - m.ClearGroup() - return nil - case entity.EdgeParent: - m.ClearParent() - return nil - case entity.EdgeLocation: - m.ClearLocation() - return nil - case entity.EdgeType: - m.ClearType() - return nil - } - return fmt.Errorf("unknown Entity unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *EntityMutation) ResetEdge(name string) error { - switch name { - case entity.EdgeGroup: - m.ResetGroup() - return nil - case entity.EdgeChildren: - m.ResetChildren() - return nil - case entity.EdgeParent: - m.ResetParent() - return nil - case entity.EdgeEntity: - m.ResetEntity() - return nil - case entity.EdgeLocation: - m.ResetLocation() - return nil - case entity.EdgeLabel: - m.ResetLabel() - return nil - case entity.EdgeType: - m.ResetType() - return nil - case entity.EdgeFields: - m.ResetFields() - return nil - case entity.EdgeMaintenanceEntries: - m.ResetMaintenanceEntries() - return nil - case entity.EdgeAttachments: - m.ResetAttachments() - return nil - } - return fmt.Errorf("unknown Entity edge %s", name) -} - -// EntityFieldMutation represents an operation that mutates the EntityField nodes in the graph. -type EntityFieldMutation struct { - config - op Op - typ string - id *uuid.UUID - created_at *time.Time - updated_at *time.Time - name *string - description *string - _type *entityfield.Type - text_value *string - number_value *int - addnumber_value *int - boolean_value *bool - time_value *time.Time - clearedFields map[string]struct{} - entity *uuid.UUID - clearedentity bool - done bool - oldValue func(context.Context) (*EntityField, error) - predicates []predicate.EntityField -} - -var _ ent.Mutation = (*EntityFieldMutation)(nil) - -// entityfieldOption allows management of the mutation configuration using functional options. -type entityfieldOption func(*EntityFieldMutation) - -// newEntityFieldMutation creates new mutation for the EntityField entity. -func newEntityFieldMutation(c config, op Op, opts ...entityfieldOption) *EntityFieldMutation { - m := &EntityFieldMutation{ - config: c, - op: op, - typ: TypeEntityField, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withEntityFieldID sets the ID field of the mutation. -func withEntityFieldID(id uuid.UUID) entityfieldOption { - return func(m *EntityFieldMutation) { - var ( - err error - once sync.Once - value *EntityField - ) - m.oldValue = func(ctx context.Context) (*EntityField, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().EntityField.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withEntityField sets the old EntityField of the mutation. -func withEntityField(node *EntityField) entityfieldOption { - return func(m *EntityFieldMutation) { - m.oldValue = func(context.Context) (*EntityField, error) { - return node, nil - } - m.id = &node.ID - } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m EntityFieldMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m EntityFieldMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of EntityField entities. -func (m *EntityFieldMutation) SetID(id uuid.UUID) { - m.id = &id -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *EntityFieldMutation) ID() (id uuid.UUID, exists bool) { - if m.id == nil { - return - } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *EntityFieldMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []uuid.UUID{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().EntityField.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetCreatedAt sets the "created_at" field. -func (m *EntityFieldMutation) SetCreatedAt(t time.Time) { - m.created_at = &t -} - -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *EntityFieldMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at - if v == nil { - return - } - return *v, true -} - -// OldCreatedAt returns the old "created_at" field's value of the EntityField entity. -// If the EntityField object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityFieldMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) - } - return oldValue.CreatedAt, nil -} - -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *EntityFieldMutation) ResetCreatedAt() { - m.created_at = nil -} - -// SetUpdatedAt sets the "updated_at" field. -func (m *EntityFieldMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t -} - -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *EntityFieldMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at - if v == nil { - return - } - return *v, true -} - -// OldUpdatedAt returns the old "updated_at" field's value of the EntityField entity. -// If the EntityField object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityFieldMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) - } - return oldValue.UpdatedAt, nil -} - -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *EntityFieldMutation) ResetUpdatedAt() { - m.updated_at = nil -} - -// SetName sets the "name" field. -func (m *EntityFieldMutation) SetName(s string) { - m.name = &s -} - -// Name returns the value of the "name" field in the mutation. -func (m *EntityFieldMutation) Name() (r string, exists bool) { - v := m.name - if v == nil { - return - } - return *v, true -} - -// OldName returns the old "name" field's value of the EntityField entity. -// If the EntityField object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityFieldMutation) OldName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) - } - return oldValue.Name, nil -} - -// ResetName resets all changes to the "name" field. -func (m *EntityFieldMutation) ResetName() { - m.name = nil -} - -// SetDescription sets the "description" field. -func (m *EntityFieldMutation) SetDescription(s string) { - m.description = &s -} - -// Description returns the value of the "description" field in the mutation. -func (m *EntityFieldMutation) Description() (r string, exists bool) { - v := m.description - if v == nil { - return - } - return *v, true -} - -// OldDescription returns the old "description" field's value of the EntityField entity. -// If the EntityField object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityFieldMutation) OldDescription(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) - } - return oldValue.Description, nil -} - -// ClearDescription clears the value of the "description" field. -func (m *EntityFieldMutation) ClearDescription() { - m.description = nil - m.clearedFields[entityfield.FieldDescription] = struct{}{} -} - -// DescriptionCleared returns if the "description" field was cleared in this mutation. -func (m *EntityFieldMutation) DescriptionCleared() bool { - _, ok := m.clearedFields[entityfield.FieldDescription] - return ok -} - -// ResetDescription resets all changes to the "description" field. -func (m *EntityFieldMutation) ResetDescription() { - m.description = nil - delete(m.clearedFields, entityfield.FieldDescription) -} - -// SetType sets the "type" field. -func (m *EntityFieldMutation) SetType(e entityfield.Type) { - m._type = &e -} - -// GetType returns the value of the "type" field in the mutation. -func (m *EntityFieldMutation) GetType() (r entityfield.Type, exists bool) { - v := m._type - if v == nil { - return - } - return *v, true -} - -// OldType returns the old "type" field's value of the EntityField entity. -// If the EntityField object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityFieldMutation) OldType(ctx context.Context) (v entityfield.Type, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldType is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldType requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldType: %w", err) - } - return oldValue.Type, nil -} - -// ResetType resets all changes to the "type" field. -func (m *EntityFieldMutation) ResetType() { - m._type = nil -} - -// SetTextValue sets the "text_value" field. -func (m *EntityFieldMutation) SetTextValue(s string) { - m.text_value = &s -} - -// TextValue returns the value of the "text_value" field in the mutation. -func (m *EntityFieldMutation) TextValue() (r string, exists bool) { - v := m.text_value - if v == nil { - return - } - return *v, true -} - -// OldTextValue returns the old "text_value" field's value of the EntityField entity. -// If the EntityField object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityFieldMutation) OldTextValue(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTextValue is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTextValue requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldTextValue: %w", err) - } - return oldValue.TextValue, nil -} - -// ClearTextValue clears the value of the "text_value" field. -func (m *EntityFieldMutation) ClearTextValue() { - m.text_value = nil - m.clearedFields[entityfield.FieldTextValue] = struct{}{} -} - -// TextValueCleared returns if the "text_value" field was cleared in this mutation. -func (m *EntityFieldMutation) TextValueCleared() bool { - _, ok := m.clearedFields[entityfield.FieldTextValue] - return ok -} - -// ResetTextValue resets all changes to the "text_value" field. -func (m *EntityFieldMutation) ResetTextValue() { - m.text_value = nil - delete(m.clearedFields, entityfield.FieldTextValue) -} - -// SetNumberValue sets the "number_value" field. -func (m *EntityFieldMutation) SetNumberValue(i int) { - m.number_value = &i - m.addnumber_value = nil -} - -// NumberValue returns the value of the "number_value" field in the mutation. -func (m *EntityFieldMutation) NumberValue() (r int, exists bool) { - v := m.number_value - if v == nil { - return - } - return *v, true -} - -// OldNumberValue returns the old "number_value" field's value of the EntityField entity. -// If the EntityField object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityFieldMutation) OldNumberValue(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldNumberValue is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldNumberValue requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldNumberValue: %w", err) - } - return oldValue.NumberValue, nil -} - -// AddNumberValue adds i to the "number_value" field. -func (m *EntityFieldMutation) AddNumberValue(i int) { - if m.addnumber_value != nil { - *m.addnumber_value += i - } else { - m.addnumber_value = &i - } -} - -// AddedNumberValue returns the value that was added to the "number_value" field in this mutation. -func (m *EntityFieldMutation) AddedNumberValue() (r int, exists bool) { - v := m.addnumber_value - if v == nil { - return - } - return *v, true -} - -// ClearNumberValue clears the value of the "number_value" field. -func (m *EntityFieldMutation) ClearNumberValue() { - m.number_value = nil - m.addnumber_value = nil - m.clearedFields[entityfield.FieldNumberValue] = struct{}{} -} - -// NumberValueCleared returns if the "number_value" field was cleared in this mutation. -func (m *EntityFieldMutation) NumberValueCleared() bool { - _, ok := m.clearedFields[entityfield.FieldNumberValue] - return ok -} - -// ResetNumberValue resets all changes to the "number_value" field. -func (m *EntityFieldMutation) ResetNumberValue() { - m.number_value = nil - m.addnumber_value = nil - delete(m.clearedFields, entityfield.FieldNumberValue) -} - -// SetBooleanValue sets the "boolean_value" field. -func (m *EntityFieldMutation) SetBooleanValue(b bool) { - m.boolean_value = &b -} - -// BooleanValue returns the value of the "boolean_value" field in the mutation. -func (m *EntityFieldMutation) BooleanValue() (r bool, exists bool) { - v := m.boolean_value - if v == nil { - return - } - return *v, true -} - -// OldBooleanValue returns the old "boolean_value" field's value of the EntityField entity. -// If the EntityField object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityFieldMutation) OldBooleanValue(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldBooleanValue is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldBooleanValue requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldBooleanValue: %w", err) - } - return oldValue.BooleanValue, nil -} - -// ResetBooleanValue resets all changes to the "boolean_value" field. -func (m *EntityFieldMutation) ResetBooleanValue() { - m.boolean_value = nil -} - -// SetTimeValue sets the "time_value" field. -func (m *EntityFieldMutation) SetTimeValue(t time.Time) { - m.time_value = &t -} - -// TimeValue returns the value of the "time_value" field in the mutation. -func (m *EntityFieldMutation) TimeValue() (r time.Time, exists bool) { - v := m.time_value - if v == nil { - return - } - return *v, true -} - -// OldTimeValue returns the old "time_value" field's value of the EntityField entity. -// If the EntityField object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityFieldMutation) OldTimeValue(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTimeValue is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTimeValue requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldTimeValue: %w", err) - } - return oldValue.TimeValue, nil -} - -// ResetTimeValue resets all changes to the "time_value" field. -func (m *EntityFieldMutation) ResetTimeValue() { - m.time_value = nil -} - -// SetEntityID sets the "entity" edge to the Entity entity by id. -func (m *EntityFieldMutation) SetEntityID(id uuid.UUID) { - m.entity = &id -} - -// ClearEntity clears the "entity" edge to the Entity entity. -func (m *EntityFieldMutation) ClearEntity() { - m.clearedentity = true -} - -// EntityCleared reports if the "entity" edge to the Entity entity was cleared. -func (m *EntityFieldMutation) EntityCleared() bool { - return m.clearedentity -} - -// EntityID returns the "entity" edge ID in the mutation. -func (m *EntityFieldMutation) EntityID() (id uuid.UUID, exists bool) { - if m.entity != nil { - return *m.entity, true - } - return -} - -// EntityIDs returns the "entity" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// EntityID instead. It exists only for internal usage by the builders. -func (m *EntityFieldMutation) EntityIDs() (ids []uuid.UUID) { - if id := m.entity; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetEntity resets all changes to the "entity" edge. -func (m *EntityFieldMutation) ResetEntity() { - m.entity = nil - m.clearedentity = false -} - -// Where appends a list predicates to the EntityFieldMutation builder. -func (m *EntityFieldMutation) Where(ps ...predicate.EntityField) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the EntityFieldMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *EntityFieldMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.EntityField, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *EntityFieldMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *EntityFieldMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (EntityField). -func (m *EntityFieldMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *EntityFieldMutation) Fields() []string { - fields := make([]string, 0, 9) - if m.created_at != nil { - fields = append(fields, entityfield.FieldCreatedAt) - } - if m.updated_at != nil { - fields = append(fields, entityfield.FieldUpdatedAt) - } - if m.name != nil { - fields = append(fields, entityfield.FieldName) - } - if m.description != nil { - fields = append(fields, entityfield.FieldDescription) - } - if m._type != nil { - fields = append(fields, entityfield.FieldType) - } - if m.text_value != nil { - fields = append(fields, entityfield.FieldTextValue) - } - if m.number_value != nil { - fields = append(fields, entityfield.FieldNumberValue) - } - if m.boolean_value != nil { - fields = append(fields, entityfield.FieldBooleanValue) - } - if m.time_value != nil { - fields = append(fields, entityfield.FieldTimeValue) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *EntityFieldMutation) Field(name string) (ent.Value, bool) { - switch name { - case entityfield.FieldCreatedAt: - return m.CreatedAt() - case entityfield.FieldUpdatedAt: - return m.UpdatedAt() - case entityfield.FieldName: - return m.Name() - case entityfield.FieldDescription: - return m.Description() - case entityfield.FieldType: - return m.GetType() - case entityfield.FieldTextValue: - return m.TextValue() - case entityfield.FieldNumberValue: - return m.NumberValue() - case entityfield.FieldBooleanValue: - return m.BooleanValue() - case entityfield.FieldTimeValue: - return m.TimeValue() - } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *EntityFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case entityfield.FieldCreatedAt: - return m.OldCreatedAt(ctx) - case entityfield.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) - case entityfield.FieldName: - return m.OldName(ctx) - case entityfield.FieldDescription: - return m.OldDescription(ctx) - case entityfield.FieldType: - return m.OldType(ctx) - case entityfield.FieldTextValue: - return m.OldTextValue(ctx) - case entityfield.FieldNumberValue: - return m.OldNumberValue(ctx) - case entityfield.FieldBooleanValue: - return m.OldBooleanValue(ctx) - case entityfield.FieldTimeValue: - return m.OldTimeValue(ctx) - } - return nil, fmt.Errorf("unknown EntityField field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *EntityFieldMutation) SetField(name string, value ent.Value) error { - switch name { - case entityfield.FieldCreatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreatedAt(v) - return nil - case entityfield.FieldUpdatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdatedAt(v) - return nil - case entityfield.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case entityfield.FieldDescription: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDescription(v) - return nil - case entityfield.FieldType: - v, ok := value.(entityfield.Type) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetType(v) - return nil - case entityfield.FieldTextValue: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTextValue(v) - return nil - case entityfield.FieldNumberValue: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetNumberValue(v) - return nil - case entityfield.FieldBooleanValue: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetBooleanValue(v) - return nil - case entityfield.FieldTimeValue: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTimeValue(v) - return nil - } - return fmt.Errorf("unknown EntityField field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *EntityFieldMutation) AddedFields() []string { - var fields []string - if m.addnumber_value != nil { - fields = append(fields, entityfield.FieldNumberValue) - } - return fields -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *EntityFieldMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case entityfield.FieldNumberValue: - return m.AddedNumberValue() - } - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *EntityFieldMutation) AddField(name string, value ent.Value) error { - switch name { - case entityfield.FieldNumberValue: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddNumberValue(v) - return nil - } - return fmt.Errorf("unknown EntityField numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *EntityFieldMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(entityfield.FieldDescription) { - fields = append(fields, entityfield.FieldDescription) - } - if m.FieldCleared(entityfield.FieldTextValue) { - fields = append(fields, entityfield.FieldTextValue) - } - if m.FieldCleared(entityfield.FieldNumberValue) { - fields = append(fields, entityfield.FieldNumberValue) - } - return fields -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *EntityFieldMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok -} - -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *EntityFieldMutation) ClearField(name string) error { - switch name { - case entityfield.FieldDescription: - m.ClearDescription() - return nil - case entityfield.FieldTextValue: - m.ClearTextValue() - return nil - case entityfield.FieldNumberValue: - m.ClearNumberValue() - return nil - } - return fmt.Errorf("unknown EntityField nullable field %s", name) -} - -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *EntityFieldMutation) ResetField(name string) error { - switch name { - case entityfield.FieldCreatedAt: - m.ResetCreatedAt() - return nil - case entityfield.FieldUpdatedAt: - m.ResetUpdatedAt() - return nil - case entityfield.FieldName: - m.ResetName() - return nil - case entityfield.FieldDescription: - m.ResetDescription() - return nil - case entityfield.FieldType: - m.ResetType() - return nil - case entityfield.FieldTextValue: - m.ResetTextValue() - return nil - case entityfield.FieldNumberValue: - m.ResetNumberValue() - return nil - case entityfield.FieldBooleanValue: - m.ResetBooleanValue() - return nil - case entityfield.FieldTimeValue: - m.ResetTimeValue() - return nil - } - return fmt.Errorf("unknown EntityField field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *EntityFieldMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.entity != nil { - edges = append(edges, entityfield.EdgeEntity) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *EntityFieldMutation) AddedIDs(name string) []ent.Value { - switch name { - case entityfield.EdgeEntity: - if id := m.entity; id != nil { - return []ent.Value{*id} - } - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *EntityFieldMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *EntityFieldMutation) RemovedIDs(name string) []ent.Value { - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *EntityFieldMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.clearedentity { - edges = append(edges, entityfield.EdgeEntity) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *EntityFieldMutation) EdgeCleared(name string) bool { - switch name { - case entityfield.EdgeEntity: - return m.clearedentity - } - return false -} - -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *EntityFieldMutation) ClearEdge(name string) error { - switch name { - case entityfield.EdgeEntity: - m.ClearEntity() - return nil - } - return fmt.Errorf("unknown EntityField unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *EntityFieldMutation) ResetEdge(name string) error { - switch name { - case entityfield.EdgeEntity: - m.ResetEntity() - return nil - } - return fmt.Errorf("unknown EntityField edge %s", name) -} - -// EntityTypeMutation represents an operation that mutates the EntityType nodes in the graph. -type EntityTypeMutation struct { - config - op Op - typ string - id *uuid.UUID - created_at *time.Time - updated_at *time.Time - name *string - description *string - icon *string - color *string - is_location *bool - clearedFields map[string]struct{} - group *uuid.UUID - clearedgroup bool - entities map[uuid.UUID]struct{} - removedentities map[uuid.UUID]struct{} - clearedentities bool - done bool - oldValue func(context.Context) (*EntityType, error) - predicates []predicate.EntityType -} - -var _ ent.Mutation = (*EntityTypeMutation)(nil) - -// entitytypeOption allows management of the mutation configuration using functional options. -type entitytypeOption func(*EntityTypeMutation) - -// newEntityTypeMutation creates new mutation for the EntityType entity. -func newEntityTypeMutation(c config, op Op, opts ...entitytypeOption) *EntityTypeMutation { - m := &EntityTypeMutation{ - config: c, - op: op, - typ: TypeEntityType, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withEntityTypeID sets the ID field of the mutation. -func withEntityTypeID(id uuid.UUID) entitytypeOption { - return func(m *EntityTypeMutation) { - var ( - err error - once sync.Once - value *EntityType - ) - m.oldValue = func(ctx context.Context) (*EntityType, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().EntityType.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withEntityType sets the old EntityType of the mutation. -func withEntityType(node *EntityType) entitytypeOption { - return func(m *EntityTypeMutation) { - m.oldValue = func(context.Context) (*EntityType, error) { - return node, nil - } - m.id = &node.ID - } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m EntityTypeMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m EntityTypeMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of EntityType entities. -func (m *EntityTypeMutation) SetID(id uuid.UUID) { - m.id = &id -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *EntityTypeMutation) ID() (id uuid.UUID, exists bool) { - if m.id == nil { - return - } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *EntityTypeMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []uuid.UUID{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().EntityType.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetCreatedAt sets the "created_at" field. -func (m *EntityTypeMutation) SetCreatedAt(t time.Time) { - m.created_at = &t -} - -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *EntityTypeMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at - if v == nil { - return - } - return *v, true -} - -// OldCreatedAt returns the old "created_at" field's value of the EntityType entity. -// If the EntityType object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityTypeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) - } - return oldValue.CreatedAt, nil -} - -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *EntityTypeMutation) ResetCreatedAt() { - m.created_at = nil -} - -// SetUpdatedAt sets the "updated_at" field. -func (m *EntityTypeMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t -} - -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *EntityTypeMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at - if v == nil { - return - } - return *v, true -} - -// OldUpdatedAt returns the old "updated_at" field's value of the EntityType entity. -// If the EntityType object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityTypeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) - } - return oldValue.UpdatedAt, nil -} - -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *EntityTypeMutation) ResetUpdatedAt() { - m.updated_at = nil -} - -// SetName sets the "name" field. -func (m *EntityTypeMutation) SetName(s string) { - m.name = &s -} - -// Name returns the value of the "name" field in the mutation. -func (m *EntityTypeMutation) Name() (r string, exists bool) { - v := m.name - if v == nil { - return - } - return *v, true -} - -// OldName returns the old "name" field's value of the EntityType entity. -// If the EntityType object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityTypeMutation) OldName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) - } - return oldValue.Name, nil -} - -// ResetName resets all changes to the "name" field. -func (m *EntityTypeMutation) ResetName() { - m.name = nil -} - -// SetDescription sets the "description" field. -func (m *EntityTypeMutation) SetDescription(s string) { - m.description = &s -} - -// Description returns the value of the "description" field in the mutation. -func (m *EntityTypeMutation) Description() (r string, exists bool) { - v := m.description - if v == nil { - return - } - return *v, true -} - -// OldDescription returns the old "description" field's value of the EntityType entity. -// If the EntityType object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityTypeMutation) OldDescription(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) - } - return oldValue.Description, nil -} - -// ClearDescription clears the value of the "description" field. -func (m *EntityTypeMutation) ClearDescription() { - m.description = nil - m.clearedFields[entitytype.FieldDescription] = struct{}{} -} - -// DescriptionCleared returns if the "description" field was cleared in this mutation. -func (m *EntityTypeMutation) DescriptionCleared() bool { - _, ok := m.clearedFields[entitytype.FieldDescription] - return ok -} - -// ResetDescription resets all changes to the "description" field. -func (m *EntityTypeMutation) ResetDescription() { - m.description = nil - delete(m.clearedFields, entitytype.FieldDescription) -} - -// SetIcon sets the "icon" field. -func (m *EntityTypeMutation) SetIcon(s string) { - m.icon = &s -} - -// Icon returns the value of the "icon" field in the mutation. -func (m *EntityTypeMutation) Icon() (r string, exists bool) { - v := m.icon - if v == nil { - return - } - return *v, true -} - -// OldIcon returns the old "icon" field's value of the EntityType entity. -// If the EntityType object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityTypeMutation) OldIcon(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIcon is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIcon requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldIcon: %w", err) - } - return oldValue.Icon, nil -} - -// ClearIcon clears the value of the "icon" field. -func (m *EntityTypeMutation) ClearIcon() { - m.icon = nil - m.clearedFields[entitytype.FieldIcon] = struct{}{} -} - -// IconCleared returns if the "icon" field was cleared in this mutation. -func (m *EntityTypeMutation) IconCleared() bool { - _, ok := m.clearedFields[entitytype.FieldIcon] - return ok -} - -// ResetIcon resets all changes to the "icon" field. -func (m *EntityTypeMutation) ResetIcon() { - m.icon = nil - delete(m.clearedFields, entitytype.FieldIcon) -} - -// SetColor sets the "color" field. -func (m *EntityTypeMutation) SetColor(s string) { - m.color = &s -} - -// Color returns the value of the "color" field in the mutation. -func (m *EntityTypeMutation) Color() (r string, exists bool) { - v := m.color - if v == nil { - return - } - return *v, true -} - -// OldColor returns the old "color" field's value of the EntityType entity. -// If the EntityType object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityTypeMutation) OldColor(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldColor is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldColor requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldColor: %w", err) - } - return oldValue.Color, nil -} - -// ClearColor clears the value of the "color" field. -func (m *EntityTypeMutation) ClearColor() { - m.color = nil - m.clearedFields[entitytype.FieldColor] = struct{}{} -} - -// ColorCleared returns if the "color" field was cleared in this mutation. -func (m *EntityTypeMutation) ColorCleared() bool { - _, ok := m.clearedFields[entitytype.FieldColor] - return ok -} - -// ResetColor resets all changes to the "color" field. -func (m *EntityTypeMutation) ResetColor() { - m.color = nil - delete(m.clearedFields, entitytype.FieldColor) -} - -// SetIsLocation sets the "is_location" field. -func (m *EntityTypeMutation) SetIsLocation(b bool) { - m.is_location = &b -} - -// IsLocation returns the value of the "is_location" field in the mutation. -func (m *EntityTypeMutation) IsLocation() (r bool, exists bool) { - v := m.is_location - if v == nil { - return - } - return *v, true -} - -// OldIsLocation returns the old "is_location" field's value of the EntityType entity. -// If the EntityType object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *EntityTypeMutation) OldIsLocation(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIsLocation is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIsLocation requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldIsLocation: %w", err) - } - return oldValue.IsLocation, nil -} - -// ResetIsLocation resets all changes to the "is_location" field. -func (m *EntityTypeMutation) ResetIsLocation() { - m.is_location = nil -} - -// SetGroupID sets the "group" edge to the Group entity by id. -func (m *EntityTypeMutation) SetGroupID(id uuid.UUID) { - m.group = &id -} - -// ClearGroup clears the "group" edge to the Group entity. -func (m *EntityTypeMutation) ClearGroup() { - m.clearedgroup = true -} - -// GroupCleared reports if the "group" edge to the Group entity was cleared. -func (m *EntityTypeMutation) GroupCleared() bool { - return m.clearedgroup -} - -// GroupID returns the "group" edge ID in the mutation. -func (m *EntityTypeMutation) GroupID() (id uuid.UUID, exists bool) { - if m.group != nil { - return *m.group, true - } - return -} - -// GroupIDs returns the "group" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// GroupID instead. It exists only for internal usage by the builders. -func (m *EntityTypeMutation) GroupIDs() (ids []uuid.UUID) { - if id := m.group; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetGroup resets all changes to the "group" edge. -func (m *EntityTypeMutation) ResetGroup() { - m.group = nil - m.clearedgroup = false -} - -// AddEntityIDs adds the "entities" edge to the Entity entity by ids. -func (m *EntityTypeMutation) AddEntityIDs(ids ...uuid.UUID) { - if m.entities == nil { - m.entities = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.entities[ids[i]] = struct{}{} - } -} - -// ClearEntities clears the "entities" edge to the Entity entity. -func (m *EntityTypeMutation) ClearEntities() { - m.clearedentities = true -} - -// EntitiesCleared reports if the "entities" edge to the Entity entity was cleared. -func (m *EntityTypeMutation) EntitiesCleared() bool { - return m.clearedentities -} - -// RemoveEntityIDs removes the "entities" edge to the Entity entity by IDs. -func (m *EntityTypeMutation) RemoveEntityIDs(ids ...uuid.UUID) { - if m.removedentities == nil { - m.removedentities = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.entities, ids[i]) - m.removedentities[ids[i]] = struct{}{} - } -} - -// RemovedEntities returns the removed IDs of the "entities" edge to the Entity entity. -func (m *EntityTypeMutation) RemovedEntitiesIDs() (ids []uuid.UUID) { - for id := range m.removedentities { - ids = append(ids, id) - } - return -} - -// EntitiesIDs returns the "entities" edge IDs in the mutation. -func (m *EntityTypeMutation) EntitiesIDs() (ids []uuid.UUID) { - for id := range m.entities { - ids = append(ids, id) - } - return -} - -// ResetEntities resets all changes to the "entities" edge. -func (m *EntityTypeMutation) ResetEntities() { - m.entities = nil - m.clearedentities = false - m.removedentities = nil -} - -// Where appends a list predicates to the EntityTypeMutation builder. -func (m *EntityTypeMutation) Where(ps ...predicate.EntityType) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the EntityTypeMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *EntityTypeMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.EntityType, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *EntityTypeMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *EntityTypeMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (EntityType). -func (m *EntityTypeMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *EntityTypeMutation) Fields() []string { - fields := make([]string, 0, 7) - if m.created_at != nil { - fields = append(fields, entitytype.FieldCreatedAt) - } - if m.updated_at != nil { - fields = append(fields, entitytype.FieldUpdatedAt) - } - if m.name != nil { - fields = append(fields, entitytype.FieldName) - } - if m.description != nil { - fields = append(fields, entitytype.FieldDescription) - } - if m.icon != nil { - fields = append(fields, entitytype.FieldIcon) - } - if m.color != nil { - fields = append(fields, entitytype.FieldColor) - } - if m.is_location != nil { - fields = append(fields, entitytype.FieldIsLocation) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *EntityTypeMutation) Field(name string) (ent.Value, bool) { - switch name { - case entitytype.FieldCreatedAt: - return m.CreatedAt() - case entitytype.FieldUpdatedAt: - return m.UpdatedAt() - case entitytype.FieldName: - return m.Name() - case entitytype.FieldDescription: - return m.Description() - case entitytype.FieldIcon: - return m.Icon() - case entitytype.FieldColor: - return m.Color() - case entitytype.FieldIsLocation: - return m.IsLocation() - } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *EntityTypeMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case entitytype.FieldCreatedAt: - return m.OldCreatedAt(ctx) - case entitytype.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) - case entitytype.FieldName: - return m.OldName(ctx) - case entitytype.FieldDescription: - return m.OldDescription(ctx) - case entitytype.FieldIcon: - return m.OldIcon(ctx) - case entitytype.FieldColor: - return m.OldColor(ctx) - case entitytype.FieldIsLocation: - return m.OldIsLocation(ctx) - } - return nil, fmt.Errorf("unknown EntityType field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *EntityTypeMutation) SetField(name string, value ent.Value) error { - switch name { - case entitytype.FieldCreatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreatedAt(v) - return nil - case entitytype.FieldUpdatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdatedAt(v) - return nil - case entitytype.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case entitytype.FieldDescription: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDescription(v) - return nil - case entitytype.FieldIcon: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetIcon(v) - return nil - case entitytype.FieldColor: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetColor(v) - return nil - case entitytype.FieldIsLocation: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetIsLocation(v) - return nil - } - return fmt.Errorf("unknown EntityType field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *EntityTypeMutation) AddedFields() []string { - return nil -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *EntityTypeMutation) AddedField(name string) (ent.Value, bool) { - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *EntityTypeMutation) AddField(name string, value ent.Value) error { - switch name { - } - return fmt.Errorf("unknown EntityType numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *EntityTypeMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(entitytype.FieldDescription) { - fields = append(fields, entitytype.FieldDescription) - } - if m.FieldCleared(entitytype.FieldIcon) { - fields = append(fields, entitytype.FieldIcon) - } - if m.FieldCleared(entitytype.FieldColor) { - fields = append(fields, entitytype.FieldColor) - } - return fields -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *EntityTypeMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok -} - -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *EntityTypeMutation) ClearField(name string) error { - switch name { - case entitytype.FieldDescription: - m.ClearDescription() - return nil - case entitytype.FieldIcon: - m.ClearIcon() - return nil - case entitytype.FieldColor: - m.ClearColor() - return nil - } - return fmt.Errorf("unknown EntityType nullable field %s", name) -} - -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *EntityTypeMutation) ResetField(name string) error { - switch name { - case entitytype.FieldCreatedAt: - m.ResetCreatedAt() - return nil - case entitytype.FieldUpdatedAt: - m.ResetUpdatedAt() - return nil - case entitytype.FieldName: - m.ResetName() - return nil - case entitytype.FieldDescription: - m.ResetDescription() - return nil - case entitytype.FieldIcon: - m.ResetIcon() - return nil - case entitytype.FieldColor: - m.ResetColor() - return nil - case entitytype.FieldIsLocation: - m.ResetIsLocation() - return nil - } - return fmt.Errorf("unknown EntityType field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *EntityTypeMutation) AddedEdges() []string { - edges := make([]string, 0, 2) - if m.group != nil { - edges = append(edges, entitytype.EdgeGroup) - } - if m.entities != nil { - edges = append(edges, entitytype.EdgeEntities) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *EntityTypeMutation) AddedIDs(name string) []ent.Value { - switch name { - case entitytype.EdgeGroup: - if id := m.group; id != nil { - return []ent.Value{*id} - } - case entitytype.EdgeEntities: - ids := make([]ent.Value, 0, len(m.entities)) - for id := range m.entities { - ids = append(ids, id) - } - return ids - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *EntityTypeMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) - if m.removedentities != nil { - edges = append(edges, entitytype.EdgeEntities) - } - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *EntityTypeMutation) RemovedIDs(name string) []ent.Value { - switch name { - case entitytype.EdgeEntities: - ids := make([]ent.Value, 0, len(m.removedentities)) - for id := range m.removedentities { - ids = append(ids, id) - } - return ids - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *EntityTypeMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) - if m.clearedgroup { - edges = append(edges, entitytype.EdgeGroup) - } - if m.clearedentities { - edges = append(edges, entitytype.EdgeEntities) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *EntityTypeMutation) EdgeCleared(name string) bool { - switch name { - case entitytype.EdgeGroup: - return m.clearedgroup - case entitytype.EdgeEntities: - return m.clearedentities - } - return false -} - -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *EntityTypeMutation) ClearEdge(name string) error { - switch name { - case entitytype.EdgeGroup: - m.ClearGroup() - return nil - } - return fmt.Errorf("unknown EntityType unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *EntityTypeMutation) ResetEdge(name string) error { - switch name { - case entitytype.EdgeGroup: - m.ResetGroup() - return nil - case entitytype.EdgeEntities: - m.ResetEntities() - return nil - } - return fmt.Errorf("unknown EntityType edge %s", name) -} - // GroupMutation represents an operation that mutates the Group nodes in the graph. type GroupMutation struct { config @@ -6358,9 +1863,12 @@ type GroupMutation struct { users map[uuid.UUID]struct{} removedusers map[uuid.UUID]struct{} clearedusers bool - entities map[uuid.UUID]struct{} - removedentities map[uuid.UUID]struct{} - clearedentities bool + locations map[uuid.UUID]struct{} + removedlocations map[uuid.UUID]struct{} + clearedlocations bool + items map[uuid.UUID]struct{} + removeditems map[uuid.UUID]struct{} + cleareditems bool labels map[uuid.UUID]struct{} removedlabels map[uuid.UUID]struct{} clearedlabels bool @@ -6370,9 +1878,9 @@ type GroupMutation struct { notifiers map[uuid.UUID]struct{} removednotifiers map[uuid.UUID]struct{} clearednotifiers bool - entity_types map[uuid.UUID]struct{} - removedentity_types map[uuid.UUID]struct{} - clearedentity_types bool + item_templates map[uuid.UUID]struct{} + removeditem_templates map[uuid.UUID]struct{} + cleareditem_templates bool done bool oldValue func(context.Context) (*Group, error) predicates []predicate.Group @@ -6680,58 +2188,112 @@ func (m *GroupMutation) ResetUsers() { m.removedusers = nil } -// AddEntityIDs adds the "entities" edge to the Entity entity by ids. -func (m *GroupMutation) AddEntityIDs(ids ...uuid.UUID) { - if m.entities == nil { - m.entities = make(map[uuid.UUID]struct{}) +// AddLocationIDs adds the "locations" edge to the Location entity by ids. +func (m *GroupMutation) AddLocationIDs(ids ...uuid.UUID) { + if m.locations == nil { + m.locations = make(map[uuid.UUID]struct{}) } for i := range ids { - m.entities[ids[i]] = struct{}{} + m.locations[ids[i]] = struct{}{} } } -// ClearEntities clears the "entities" edge to the Entity entity. -func (m *GroupMutation) ClearEntities() { - m.clearedentities = true +// ClearLocations clears the "locations" edge to the Location entity. +func (m *GroupMutation) ClearLocations() { + m.clearedlocations = true } -// EntitiesCleared reports if the "entities" edge to the Entity entity was cleared. -func (m *GroupMutation) EntitiesCleared() bool { - return m.clearedentities +// LocationsCleared reports if the "locations" edge to the Location entity was cleared. +func (m *GroupMutation) LocationsCleared() bool { + return m.clearedlocations } -// RemoveEntityIDs removes the "entities" edge to the Entity entity by IDs. -func (m *GroupMutation) RemoveEntityIDs(ids ...uuid.UUID) { - if m.removedentities == nil { - m.removedentities = make(map[uuid.UUID]struct{}) +// RemoveLocationIDs removes the "locations" edge to the Location entity by IDs. +func (m *GroupMutation) RemoveLocationIDs(ids ...uuid.UUID) { + if m.removedlocations == nil { + m.removedlocations = make(map[uuid.UUID]struct{}) } for i := range ids { - delete(m.entities, ids[i]) - m.removedentities[ids[i]] = struct{}{} + delete(m.locations, ids[i]) + m.removedlocations[ids[i]] = struct{}{} } } -// RemovedEntities returns the removed IDs of the "entities" edge to the Entity entity. -func (m *GroupMutation) RemovedEntitiesIDs() (ids []uuid.UUID) { - for id := range m.removedentities { +// RemovedLocations returns the removed IDs of the "locations" edge to the Location entity. +func (m *GroupMutation) RemovedLocationsIDs() (ids []uuid.UUID) { + for id := range m.removedlocations { ids = append(ids, id) } return } -// EntitiesIDs returns the "entities" edge IDs in the mutation. -func (m *GroupMutation) EntitiesIDs() (ids []uuid.UUID) { - for id := range m.entities { +// LocationsIDs returns the "locations" edge IDs in the mutation. +func (m *GroupMutation) LocationsIDs() (ids []uuid.UUID) { + for id := range m.locations { ids = append(ids, id) } return } -// ResetEntities resets all changes to the "entities" edge. -func (m *GroupMutation) ResetEntities() { - m.entities = nil - m.clearedentities = false - m.removedentities = nil +// ResetLocations resets all changes to the "locations" edge. +func (m *GroupMutation) ResetLocations() { + m.locations = nil + m.clearedlocations = false + m.removedlocations = nil +} + +// AddItemIDs adds the "items" edge to the Item entity by ids. +func (m *GroupMutation) AddItemIDs(ids ...uuid.UUID) { + if m.items == nil { + m.items = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.items[ids[i]] = struct{}{} + } +} + +// ClearItems clears the "items" edge to the Item entity. +func (m *GroupMutation) ClearItems() { + m.cleareditems = true +} + +// ItemsCleared reports if the "items" edge to the Item entity was cleared. +func (m *GroupMutation) ItemsCleared() bool { + return m.cleareditems +} + +// RemoveItemIDs removes the "items" edge to the Item entity by IDs. +func (m *GroupMutation) RemoveItemIDs(ids ...uuid.UUID) { + if m.removeditems == nil { + m.removeditems = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.items, ids[i]) + m.removeditems[ids[i]] = struct{}{} + } +} + +// RemovedItems returns the removed IDs of the "items" edge to the Item entity. +func (m *GroupMutation) RemovedItemsIDs() (ids []uuid.UUID) { + for id := range m.removeditems { + ids = append(ids, id) + } + return +} + +// ItemsIDs returns the "items" edge IDs in the mutation. +func (m *GroupMutation) ItemsIDs() (ids []uuid.UUID) { + for id := range m.items { + ids = append(ids, id) + } + return +} + +// ResetItems resets all changes to the "items" edge. +func (m *GroupMutation) ResetItems() { + m.items = nil + m.cleareditems = false + m.removeditems = nil } // AddLabelIDs adds the "labels" edge to the Label entity by ids. @@ -6896,58 +2458,58 @@ func (m *GroupMutation) ResetNotifiers() { m.removednotifiers = nil } -// AddEntityTypeIDs adds the "entity_types" edge to the EntityType entity by ids. -func (m *GroupMutation) AddEntityTypeIDs(ids ...uuid.UUID) { - if m.entity_types == nil { - m.entity_types = make(map[uuid.UUID]struct{}) +// AddItemTemplateIDs adds the "item_templates" edge to the ItemTemplate entity by ids. +func (m *GroupMutation) AddItemTemplateIDs(ids ...uuid.UUID) { + if m.item_templates == nil { + m.item_templates = make(map[uuid.UUID]struct{}) } for i := range ids { - m.entity_types[ids[i]] = struct{}{} + m.item_templates[ids[i]] = struct{}{} } } -// ClearEntityTypes clears the "entity_types" edge to the EntityType entity. -func (m *GroupMutation) ClearEntityTypes() { - m.clearedentity_types = true +// ClearItemTemplates clears the "item_templates" edge to the ItemTemplate entity. +func (m *GroupMutation) ClearItemTemplates() { + m.cleareditem_templates = true } -// EntityTypesCleared reports if the "entity_types" edge to the EntityType entity was cleared. -func (m *GroupMutation) EntityTypesCleared() bool { - return m.clearedentity_types +// ItemTemplatesCleared reports if the "item_templates" edge to the ItemTemplate entity was cleared. +func (m *GroupMutation) ItemTemplatesCleared() bool { + return m.cleareditem_templates } -// RemoveEntityTypeIDs removes the "entity_types" edge to the EntityType entity by IDs. -func (m *GroupMutation) RemoveEntityTypeIDs(ids ...uuid.UUID) { - if m.removedentity_types == nil { - m.removedentity_types = make(map[uuid.UUID]struct{}) +// RemoveItemTemplateIDs removes the "item_templates" edge to the ItemTemplate entity by IDs. +func (m *GroupMutation) RemoveItemTemplateIDs(ids ...uuid.UUID) { + if m.removeditem_templates == nil { + m.removeditem_templates = make(map[uuid.UUID]struct{}) } for i := range ids { - delete(m.entity_types, ids[i]) - m.removedentity_types[ids[i]] = struct{}{} + delete(m.item_templates, ids[i]) + m.removeditem_templates[ids[i]] = struct{}{} } } -// RemovedEntityTypes returns the removed IDs of the "entity_types" edge to the EntityType entity. -func (m *GroupMutation) RemovedEntityTypesIDs() (ids []uuid.UUID) { - for id := range m.removedentity_types { +// RemovedItemTemplates returns the removed IDs of the "item_templates" edge to the ItemTemplate entity. +func (m *GroupMutation) RemovedItemTemplatesIDs() (ids []uuid.UUID) { + for id := range m.removeditem_templates { ids = append(ids, id) } return } -// EntityTypesIDs returns the "entity_types" edge IDs in the mutation. -func (m *GroupMutation) EntityTypesIDs() (ids []uuid.UUID) { - for id := range m.entity_types { +// ItemTemplatesIDs returns the "item_templates" edge IDs in the mutation. +func (m *GroupMutation) ItemTemplatesIDs() (ids []uuid.UUID) { + for id := range m.item_templates { ids = append(ids, id) } return } -// ResetEntityTypes resets all changes to the "entity_types" edge. -func (m *GroupMutation) ResetEntityTypes() { - m.entity_types = nil - m.clearedentity_types = false - m.removedentity_types = nil +// ResetItemTemplates resets all changes to the "item_templates" edge. +func (m *GroupMutation) ResetItemTemplates() { + m.item_templates = nil + m.cleareditem_templates = false + m.removeditem_templates = nil } // Where appends a list predicates to the GroupMutation builder. @@ -7134,12 +2696,15 @@ func (m *GroupMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *GroupMutation) AddedEdges() []string { - edges := make([]string, 0, 6) + edges := make([]string, 0, 7) if m.users != nil { edges = append(edges, group.EdgeUsers) } - if m.entities != nil { - edges = append(edges, group.EdgeEntities) + if m.locations != nil { + edges = append(edges, group.EdgeLocations) + } + if m.items != nil { + edges = append(edges, group.EdgeItems) } if m.labels != nil { edges = append(edges, group.EdgeLabels) @@ -7150,8 +2715,8 @@ func (m *GroupMutation) AddedEdges() []string { if m.notifiers != nil { edges = append(edges, group.EdgeNotifiers) } - if m.entity_types != nil { - edges = append(edges, group.EdgeEntityTypes) + if m.item_templates != nil { + edges = append(edges, group.EdgeItemTemplates) } return edges } @@ -7166,9 +2731,15 @@ func (m *GroupMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case group.EdgeEntities: - ids := make([]ent.Value, 0, len(m.entities)) - for id := range m.entities { + case group.EdgeLocations: + ids := make([]ent.Value, 0, len(m.locations)) + for id := range m.locations { + ids = append(ids, id) + } + return ids + case group.EdgeItems: + ids := make([]ent.Value, 0, len(m.items)) + for id := range m.items { ids = append(ids, id) } return ids @@ -7190,9 +2761,9 @@ func (m *GroupMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case group.EdgeEntityTypes: - ids := make([]ent.Value, 0, len(m.entity_types)) - for id := range m.entity_types { + case group.EdgeItemTemplates: + ids := make([]ent.Value, 0, len(m.item_templates)) + for id := range m.item_templates { ids = append(ids, id) } return ids @@ -7202,12 +2773,15 @@ func (m *GroupMutation) AddedIDs(name string) []ent.Value { // RemovedEdges returns all edge names that were removed in this mutation. func (m *GroupMutation) RemovedEdges() []string { - edges := make([]string, 0, 6) + edges := make([]string, 0, 7) if m.removedusers != nil { edges = append(edges, group.EdgeUsers) } - if m.removedentities != nil { - edges = append(edges, group.EdgeEntities) + if m.removedlocations != nil { + edges = append(edges, group.EdgeLocations) + } + if m.removeditems != nil { + edges = append(edges, group.EdgeItems) } if m.removedlabels != nil { edges = append(edges, group.EdgeLabels) @@ -7218,8 +2792,8 @@ func (m *GroupMutation) RemovedEdges() []string { if m.removednotifiers != nil { edges = append(edges, group.EdgeNotifiers) } - if m.removedentity_types != nil { - edges = append(edges, group.EdgeEntityTypes) + if m.removeditem_templates != nil { + edges = append(edges, group.EdgeItemTemplates) } return edges } @@ -7234,9 +2808,15 @@ func (m *GroupMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case group.EdgeEntities: - ids := make([]ent.Value, 0, len(m.removedentities)) - for id := range m.removedentities { + case group.EdgeLocations: + ids := make([]ent.Value, 0, len(m.removedlocations)) + for id := range m.removedlocations { + ids = append(ids, id) + } + return ids + case group.EdgeItems: + ids := make([]ent.Value, 0, len(m.removeditems)) + for id := range m.removeditems { ids = append(ids, id) } return ids @@ -7258,9 +2838,9 @@ func (m *GroupMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case group.EdgeEntityTypes: - ids := make([]ent.Value, 0, len(m.removedentity_types)) - for id := range m.removedentity_types { + case group.EdgeItemTemplates: + ids := make([]ent.Value, 0, len(m.removeditem_templates)) + for id := range m.removeditem_templates { ids = append(ids, id) } return ids @@ -7270,12 +2850,15 @@ func (m *GroupMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *GroupMutation) ClearedEdges() []string { - edges := make([]string, 0, 6) + edges := make([]string, 0, 7) if m.clearedusers { edges = append(edges, group.EdgeUsers) } - if m.clearedentities { - edges = append(edges, group.EdgeEntities) + if m.clearedlocations { + edges = append(edges, group.EdgeLocations) + } + if m.cleareditems { + edges = append(edges, group.EdgeItems) } if m.clearedlabels { edges = append(edges, group.EdgeLabels) @@ -7286,8 +2869,8 @@ func (m *GroupMutation) ClearedEdges() []string { if m.clearednotifiers { edges = append(edges, group.EdgeNotifiers) } - if m.clearedentity_types { - edges = append(edges, group.EdgeEntityTypes) + if m.cleareditem_templates { + edges = append(edges, group.EdgeItemTemplates) } return edges } @@ -7298,16 +2881,18 @@ func (m *GroupMutation) EdgeCleared(name string) bool { switch name { case group.EdgeUsers: return m.clearedusers - case group.EdgeEntities: - return m.clearedentities + case group.EdgeLocations: + return m.clearedlocations + case group.EdgeItems: + return m.cleareditems case group.EdgeLabels: return m.clearedlabels case group.EdgeInvitationTokens: return m.clearedinvitation_tokens case group.EdgeNotifiers: return m.clearednotifiers - case group.EdgeEntityTypes: - return m.clearedentity_types + case group.EdgeItemTemplates: + return m.cleareditem_templates } return false } @@ -7327,8 +2912,11 @@ func (m *GroupMutation) ResetEdge(name string) error { case group.EdgeUsers: m.ResetUsers() return nil - case group.EdgeEntities: - m.ResetEntities() + case group.EdgeLocations: + m.ResetLocations() + return nil + case group.EdgeItems: + m.ResetItems() return nil case group.EdgeLabels: m.ResetLabels() @@ -7339,8 +2927,8 @@ func (m *GroupMutation) ResetEdge(name string) error { case group.EdgeNotifiers: m.ResetNotifiers() return nil - case group.EdgeEntityTypes: - m.ResetEntityTypes() + case group.EdgeItemTemplates: + m.ResetItemTemplates() return nil } return fmt.Errorf("unknown Group edge %s", name) @@ -7997,8 +3585,2569 @@ func (m *GroupInvitationTokenMutation) ResetEdge(name string) error { return fmt.Errorf("unknown GroupInvitationToken edge %s", name) } -// LabelMutation represents an operation that mutates the Label nodes in the graph. -type LabelMutation struct { +// ItemMutation represents an operation that mutates the Item nodes in the graph. +type ItemMutation struct { + config + op Op + typ string + id *uuid.UUID + created_at *time.Time + updated_at *time.Time + name *string + description *string + import_ref *string + notes *string + quantity *int + addquantity *int + insured *bool + archived *bool + asset_id *int + addasset_id *int + sync_child_items_locations *bool + serial_number *string + model_number *string + manufacturer *string + lifetime_warranty *bool + warranty_expires *time.Time + warranty_details *string + purchase_time *time.Time + purchase_from *string + purchase_price *float64 + addpurchase_price *float64 + sold_time *time.Time + sold_to *string + sold_price *float64 + addsold_price *float64 + sold_notes *string + clearedFields map[string]struct{} + group *uuid.UUID + clearedgroup bool + parent *uuid.UUID + clearedparent bool + children map[uuid.UUID]struct{} + removedchildren map[uuid.UUID]struct{} + clearedchildren bool + label map[uuid.UUID]struct{} + removedlabel map[uuid.UUID]struct{} + clearedlabel bool + location *uuid.UUID + clearedlocation bool + fields map[uuid.UUID]struct{} + removedfields map[uuid.UUID]struct{} + clearedfields bool + maintenance_entries map[uuid.UUID]struct{} + removedmaintenance_entries map[uuid.UUID]struct{} + clearedmaintenance_entries bool + attachments map[uuid.UUID]struct{} + removedattachments map[uuid.UUID]struct{} + clearedattachments bool + done bool + oldValue func(context.Context) (*Item, error) + predicates []predicate.Item +} + +var _ ent.Mutation = (*ItemMutation)(nil) + +// itemOption allows management of the mutation configuration using functional options. +type itemOption func(*ItemMutation) + +// newItemMutation creates new mutation for the Item entity. +func newItemMutation(c config, op Op, opts ...itemOption) *ItemMutation { + m := &ItemMutation{ + config: c, + op: op, + typ: TypeItem, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withItemID sets the ID field of the mutation. +func withItemID(id uuid.UUID) itemOption { + return func(m *ItemMutation) { + var ( + err error + once sync.Once + value *Item + ) + m.oldValue = func(ctx context.Context) (*Item, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Item.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withItem sets the old Item of the mutation. +func withItem(node *Item) itemOption { + return func(m *ItemMutation) { + m.oldValue = func(context.Context) (*Item, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m ItemMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m ItemMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Item entities. +func (m *ItemMutation) SetID(id uuid.UUID) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *ItemMutation) ID() (id uuid.UUID, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *ItemMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uuid.UUID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Item.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *ItemMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *ItemMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *ItemMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *ItemMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *ItemMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *ItemMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetName sets the "name" field. +func (m *ItemMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *ItemMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *ItemMutation) ResetName() { + m.name = nil +} + +// SetDescription sets the "description" field. +func (m *ItemMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *ItemMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ClearDescription clears the value of the "description" field. +func (m *ItemMutation) ClearDescription() { + m.description = nil + m.clearedFields[item.FieldDescription] = struct{}{} +} + +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *ItemMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[item.FieldDescription] + return ok +} + +// ResetDescription resets all changes to the "description" field. +func (m *ItemMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, item.FieldDescription) +} + +// SetImportRef sets the "import_ref" field. +func (m *ItemMutation) SetImportRef(s string) { + m.import_ref = &s +} + +// ImportRef returns the value of the "import_ref" field in the mutation. +func (m *ItemMutation) ImportRef() (r string, exists bool) { + v := m.import_ref + if v == nil { + return + } + return *v, true +} + +// OldImportRef returns the old "import_ref" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldImportRef(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldImportRef is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldImportRef requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldImportRef: %w", err) + } + return oldValue.ImportRef, nil +} + +// ClearImportRef clears the value of the "import_ref" field. +func (m *ItemMutation) ClearImportRef() { + m.import_ref = nil + m.clearedFields[item.FieldImportRef] = struct{}{} +} + +// ImportRefCleared returns if the "import_ref" field was cleared in this mutation. +func (m *ItemMutation) ImportRefCleared() bool { + _, ok := m.clearedFields[item.FieldImportRef] + return ok +} + +// ResetImportRef resets all changes to the "import_ref" field. +func (m *ItemMutation) ResetImportRef() { + m.import_ref = nil + delete(m.clearedFields, item.FieldImportRef) +} + +// SetNotes sets the "notes" field. +func (m *ItemMutation) SetNotes(s string) { + m.notes = &s +} + +// Notes returns the value of the "notes" field in the mutation. +func (m *ItemMutation) Notes() (r string, exists bool) { + v := m.notes + if v == nil { + return + } + return *v, true +} + +// OldNotes returns the old "notes" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldNotes(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNotes is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNotes requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNotes: %w", err) + } + return oldValue.Notes, nil +} + +// ClearNotes clears the value of the "notes" field. +func (m *ItemMutation) ClearNotes() { + m.notes = nil + m.clearedFields[item.FieldNotes] = struct{}{} +} + +// NotesCleared returns if the "notes" field was cleared in this mutation. +func (m *ItemMutation) NotesCleared() bool { + _, ok := m.clearedFields[item.FieldNotes] + return ok +} + +// ResetNotes resets all changes to the "notes" field. +func (m *ItemMutation) ResetNotes() { + m.notes = nil + delete(m.clearedFields, item.FieldNotes) +} + +// SetQuantity sets the "quantity" field. +func (m *ItemMutation) SetQuantity(i int) { + m.quantity = &i + m.addquantity = nil +} + +// Quantity returns the value of the "quantity" field in the mutation. +func (m *ItemMutation) Quantity() (r int, exists bool) { + v := m.quantity + if v == nil { + return + } + return *v, true +} + +// OldQuantity returns the old "quantity" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldQuantity(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldQuantity is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldQuantity requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldQuantity: %w", err) + } + return oldValue.Quantity, nil +} + +// AddQuantity adds i to the "quantity" field. +func (m *ItemMutation) AddQuantity(i int) { + if m.addquantity != nil { + *m.addquantity += i + } else { + m.addquantity = &i + } +} + +// AddedQuantity returns the value that was added to the "quantity" field in this mutation. +func (m *ItemMutation) AddedQuantity() (r int, exists bool) { + v := m.addquantity + if v == nil { + return + } + return *v, true +} + +// ResetQuantity resets all changes to the "quantity" field. +func (m *ItemMutation) ResetQuantity() { + m.quantity = nil + m.addquantity = nil +} + +// SetInsured sets the "insured" field. +func (m *ItemMutation) SetInsured(b bool) { + m.insured = &b +} + +// Insured returns the value of the "insured" field in the mutation. +func (m *ItemMutation) Insured() (r bool, exists bool) { + v := m.insured + if v == nil { + return + } + return *v, true +} + +// OldInsured returns the old "insured" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldInsured(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldInsured is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldInsured requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldInsured: %w", err) + } + return oldValue.Insured, nil +} + +// ResetInsured resets all changes to the "insured" field. +func (m *ItemMutation) ResetInsured() { + m.insured = nil +} + +// SetArchived sets the "archived" field. +func (m *ItemMutation) SetArchived(b bool) { + m.archived = &b +} + +// Archived returns the value of the "archived" field in the mutation. +func (m *ItemMutation) Archived() (r bool, exists bool) { + v := m.archived + if v == nil { + return + } + return *v, true +} + +// OldArchived returns the old "archived" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldArchived(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldArchived is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldArchived requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldArchived: %w", err) + } + return oldValue.Archived, nil +} + +// ResetArchived resets all changes to the "archived" field. +func (m *ItemMutation) ResetArchived() { + m.archived = nil +} + +// SetAssetID sets the "asset_id" field. +func (m *ItemMutation) SetAssetID(i int) { + m.asset_id = &i + m.addasset_id = nil +} + +// AssetID returns the value of the "asset_id" field in the mutation. +func (m *ItemMutation) AssetID() (r int, exists bool) { + v := m.asset_id + if v == nil { + return + } + return *v, true +} + +// OldAssetID returns the old "asset_id" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldAssetID(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAssetID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAssetID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAssetID: %w", err) + } + return oldValue.AssetID, nil +} + +// AddAssetID adds i to the "asset_id" field. +func (m *ItemMutation) AddAssetID(i int) { + if m.addasset_id != nil { + *m.addasset_id += i + } else { + m.addasset_id = &i + } +} + +// AddedAssetID returns the value that was added to the "asset_id" field in this mutation. +func (m *ItemMutation) AddedAssetID() (r int, exists bool) { + v := m.addasset_id + if v == nil { + return + } + return *v, true +} + +// ResetAssetID resets all changes to the "asset_id" field. +func (m *ItemMutation) ResetAssetID() { + m.asset_id = nil + m.addasset_id = nil +} + +// SetSyncChildItemsLocations sets the "sync_child_items_locations" field. +func (m *ItemMutation) SetSyncChildItemsLocations(b bool) { + m.sync_child_items_locations = &b +} + +// SyncChildItemsLocations returns the value of the "sync_child_items_locations" field in the mutation. +func (m *ItemMutation) SyncChildItemsLocations() (r bool, exists bool) { + v := m.sync_child_items_locations + if v == nil { + return + } + return *v, true +} + +// OldSyncChildItemsLocations returns the old "sync_child_items_locations" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldSyncChildItemsLocations(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSyncChildItemsLocations is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSyncChildItemsLocations requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSyncChildItemsLocations: %w", err) + } + return oldValue.SyncChildItemsLocations, nil +} + +// ResetSyncChildItemsLocations resets all changes to the "sync_child_items_locations" field. +func (m *ItemMutation) ResetSyncChildItemsLocations() { + m.sync_child_items_locations = nil +} + +// SetSerialNumber sets the "serial_number" field. +func (m *ItemMutation) SetSerialNumber(s string) { + m.serial_number = &s +} + +// SerialNumber returns the value of the "serial_number" field in the mutation. +func (m *ItemMutation) SerialNumber() (r string, exists bool) { + v := m.serial_number + if v == nil { + return + } + return *v, true +} + +// OldSerialNumber returns the old "serial_number" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldSerialNumber(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSerialNumber is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSerialNumber requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSerialNumber: %w", err) + } + return oldValue.SerialNumber, nil +} + +// ClearSerialNumber clears the value of the "serial_number" field. +func (m *ItemMutation) ClearSerialNumber() { + m.serial_number = nil + m.clearedFields[item.FieldSerialNumber] = struct{}{} +} + +// SerialNumberCleared returns if the "serial_number" field was cleared in this mutation. +func (m *ItemMutation) SerialNumberCleared() bool { + _, ok := m.clearedFields[item.FieldSerialNumber] + return ok +} + +// ResetSerialNumber resets all changes to the "serial_number" field. +func (m *ItemMutation) ResetSerialNumber() { + m.serial_number = nil + delete(m.clearedFields, item.FieldSerialNumber) +} + +// SetModelNumber sets the "model_number" field. +func (m *ItemMutation) SetModelNumber(s string) { + m.model_number = &s +} + +// ModelNumber returns the value of the "model_number" field in the mutation. +func (m *ItemMutation) ModelNumber() (r string, exists bool) { + v := m.model_number + if v == nil { + return + } + return *v, true +} + +// OldModelNumber returns the old "model_number" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldModelNumber(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldModelNumber is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldModelNumber requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldModelNumber: %w", err) + } + return oldValue.ModelNumber, nil +} + +// ClearModelNumber clears the value of the "model_number" field. +func (m *ItemMutation) ClearModelNumber() { + m.model_number = nil + m.clearedFields[item.FieldModelNumber] = struct{}{} +} + +// ModelNumberCleared returns if the "model_number" field was cleared in this mutation. +func (m *ItemMutation) ModelNumberCleared() bool { + _, ok := m.clearedFields[item.FieldModelNumber] + return ok +} + +// ResetModelNumber resets all changes to the "model_number" field. +func (m *ItemMutation) ResetModelNumber() { + m.model_number = nil + delete(m.clearedFields, item.FieldModelNumber) +} + +// SetManufacturer sets the "manufacturer" field. +func (m *ItemMutation) SetManufacturer(s string) { + m.manufacturer = &s +} + +// Manufacturer returns the value of the "manufacturer" field in the mutation. +func (m *ItemMutation) Manufacturer() (r string, exists bool) { + v := m.manufacturer + if v == nil { + return + } + return *v, true +} + +// OldManufacturer returns the old "manufacturer" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldManufacturer(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldManufacturer is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldManufacturer requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldManufacturer: %w", err) + } + return oldValue.Manufacturer, nil +} + +// ClearManufacturer clears the value of the "manufacturer" field. +func (m *ItemMutation) ClearManufacturer() { + m.manufacturer = nil + m.clearedFields[item.FieldManufacturer] = struct{}{} +} + +// ManufacturerCleared returns if the "manufacturer" field was cleared in this mutation. +func (m *ItemMutation) ManufacturerCleared() bool { + _, ok := m.clearedFields[item.FieldManufacturer] + return ok +} + +// ResetManufacturer resets all changes to the "manufacturer" field. +func (m *ItemMutation) ResetManufacturer() { + m.manufacturer = nil + delete(m.clearedFields, item.FieldManufacturer) +} + +// SetLifetimeWarranty sets the "lifetime_warranty" field. +func (m *ItemMutation) SetLifetimeWarranty(b bool) { + m.lifetime_warranty = &b +} + +// LifetimeWarranty returns the value of the "lifetime_warranty" field in the mutation. +func (m *ItemMutation) LifetimeWarranty() (r bool, exists bool) { + v := m.lifetime_warranty + if v == nil { + return + } + return *v, true +} + +// OldLifetimeWarranty returns the old "lifetime_warranty" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldLifetimeWarranty(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLifetimeWarranty is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLifetimeWarranty requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLifetimeWarranty: %w", err) + } + return oldValue.LifetimeWarranty, nil +} + +// ResetLifetimeWarranty resets all changes to the "lifetime_warranty" field. +func (m *ItemMutation) ResetLifetimeWarranty() { + m.lifetime_warranty = nil +} + +// SetWarrantyExpires sets the "warranty_expires" field. +func (m *ItemMutation) SetWarrantyExpires(t time.Time) { + m.warranty_expires = &t +} + +// WarrantyExpires returns the value of the "warranty_expires" field in the mutation. +func (m *ItemMutation) WarrantyExpires() (r time.Time, exists bool) { + v := m.warranty_expires + if v == nil { + return + } + return *v, true +} + +// OldWarrantyExpires returns the old "warranty_expires" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldWarrantyExpires(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldWarrantyExpires is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldWarrantyExpires requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldWarrantyExpires: %w", err) + } + return oldValue.WarrantyExpires, nil +} + +// ClearWarrantyExpires clears the value of the "warranty_expires" field. +func (m *ItemMutation) ClearWarrantyExpires() { + m.warranty_expires = nil + m.clearedFields[item.FieldWarrantyExpires] = struct{}{} +} + +// WarrantyExpiresCleared returns if the "warranty_expires" field was cleared in this mutation. +func (m *ItemMutation) WarrantyExpiresCleared() bool { + _, ok := m.clearedFields[item.FieldWarrantyExpires] + return ok +} + +// ResetWarrantyExpires resets all changes to the "warranty_expires" field. +func (m *ItemMutation) ResetWarrantyExpires() { + m.warranty_expires = nil + delete(m.clearedFields, item.FieldWarrantyExpires) +} + +// SetWarrantyDetails sets the "warranty_details" field. +func (m *ItemMutation) SetWarrantyDetails(s string) { + m.warranty_details = &s +} + +// WarrantyDetails returns the value of the "warranty_details" field in the mutation. +func (m *ItemMutation) WarrantyDetails() (r string, exists bool) { + v := m.warranty_details + if v == nil { + return + } + return *v, true +} + +// OldWarrantyDetails returns the old "warranty_details" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldWarrantyDetails(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldWarrantyDetails is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldWarrantyDetails requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldWarrantyDetails: %w", err) + } + return oldValue.WarrantyDetails, nil +} + +// ClearWarrantyDetails clears the value of the "warranty_details" field. +func (m *ItemMutation) ClearWarrantyDetails() { + m.warranty_details = nil + m.clearedFields[item.FieldWarrantyDetails] = struct{}{} +} + +// WarrantyDetailsCleared returns if the "warranty_details" field was cleared in this mutation. +func (m *ItemMutation) WarrantyDetailsCleared() bool { + _, ok := m.clearedFields[item.FieldWarrantyDetails] + return ok +} + +// ResetWarrantyDetails resets all changes to the "warranty_details" field. +func (m *ItemMutation) ResetWarrantyDetails() { + m.warranty_details = nil + delete(m.clearedFields, item.FieldWarrantyDetails) +} + +// SetPurchaseTime sets the "purchase_time" field. +func (m *ItemMutation) SetPurchaseTime(t time.Time) { + m.purchase_time = &t +} + +// PurchaseTime returns the value of the "purchase_time" field in the mutation. +func (m *ItemMutation) PurchaseTime() (r time.Time, exists bool) { + v := m.purchase_time + if v == nil { + return + } + return *v, true +} + +// OldPurchaseTime returns the old "purchase_time" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldPurchaseTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPurchaseTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPurchaseTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPurchaseTime: %w", err) + } + return oldValue.PurchaseTime, nil +} + +// ClearPurchaseTime clears the value of the "purchase_time" field. +func (m *ItemMutation) ClearPurchaseTime() { + m.purchase_time = nil + m.clearedFields[item.FieldPurchaseTime] = struct{}{} +} + +// PurchaseTimeCleared returns if the "purchase_time" field was cleared in this mutation. +func (m *ItemMutation) PurchaseTimeCleared() bool { + _, ok := m.clearedFields[item.FieldPurchaseTime] + return ok +} + +// ResetPurchaseTime resets all changes to the "purchase_time" field. +func (m *ItemMutation) ResetPurchaseTime() { + m.purchase_time = nil + delete(m.clearedFields, item.FieldPurchaseTime) +} + +// SetPurchaseFrom sets the "purchase_from" field. +func (m *ItemMutation) SetPurchaseFrom(s string) { + m.purchase_from = &s +} + +// PurchaseFrom returns the value of the "purchase_from" field in the mutation. +func (m *ItemMutation) PurchaseFrom() (r string, exists bool) { + v := m.purchase_from + if v == nil { + return + } + return *v, true +} + +// OldPurchaseFrom returns the old "purchase_from" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldPurchaseFrom(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPurchaseFrom is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPurchaseFrom requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPurchaseFrom: %w", err) + } + return oldValue.PurchaseFrom, nil +} + +// ClearPurchaseFrom clears the value of the "purchase_from" field. +func (m *ItemMutation) ClearPurchaseFrom() { + m.purchase_from = nil + m.clearedFields[item.FieldPurchaseFrom] = struct{}{} +} + +// PurchaseFromCleared returns if the "purchase_from" field was cleared in this mutation. +func (m *ItemMutation) PurchaseFromCleared() bool { + _, ok := m.clearedFields[item.FieldPurchaseFrom] + return ok +} + +// ResetPurchaseFrom resets all changes to the "purchase_from" field. +func (m *ItemMutation) ResetPurchaseFrom() { + m.purchase_from = nil + delete(m.clearedFields, item.FieldPurchaseFrom) +} + +// SetPurchasePrice sets the "purchase_price" field. +func (m *ItemMutation) SetPurchasePrice(f float64) { + m.purchase_price = &f + m.addpurchase_price = nil +} + +// PurchasePrice returns the value of the "purchase_price" field in the mutation. +func (m *ItemMutation) PurchasePrice() (r float64, exists bool) { + v := m.purchase_price + if v == nil { + return + } + return *v, true +} + +// OldPurchasePrice returns the old "purchase_price" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldPurchasePrice(ctx context.Context) (v float64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPurchasePrice is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPurchasePrice requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPurchasePrice: %w", err) + } + return oldValue.PurchasePrice, nil +} + +// AddPurchasePrice adds f to the "purchase_price" field. +func (m *ItemMutation) AddPurchasePrice(f float64) { + if m.addpurchase_price != nil { + *m.addpurchase_price += f + } else { + m.addpurchase_price = &f + } +} + +// AddedPurchasePrice returns the value that was added to the "purchase_price" field in this mutation. +func (m *ItemMutation) AddedPurchasePrice() (r float64, exists bool) { + v := m.addpurchase_price + if v == nil { + return + } + return *v, true +} + +// ResetPurchasePrice resets all changes to the "purchase_price" field. +func (m *ItemMutation) ResetPurchasePrice() { + m.purchase_price = nil + m.addpurchase_price = nil +} + +// SetSoldTime sets the "sold_time" field. +func (m *ItemMutation) SetSoldTime(t time.Time) { + m.sold_time = &t +} + +// SoldTime returns the value of the "sold_time" field in the mutation. +func (m *ItemMutation) SoldTime() (r time.Time, exists bool) { + v := m.sold_time + if v == nil { + return + } + return *v, true +} + +// OldSoldTime returns the old "sold_time" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldSoldTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSoldTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSoldTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSoldTime: %w", err) + } + return oldValue.SoldTime, nil +} + +// ClearSoldTime clears the value of the "sold_time" field. +func (m *ItemMutation) ClearSoldTime() { + m.sold_time = nil + m.clearedFields[item.FieldSoldTime] = struct{}{} +} + +// SoldTimeCleared returns if the "sold_time" field was cleared in this mutation. +func (m *ItemMutation) SoldTimeCleared() bool { + _, ok := m.clearedFields[item.FieldSoldTime] + return ok +} + +// ResetSoldTime resets all changes to the "sold_time" field. +func (m *ItemMutation) ResetSoldTime() { + m.sold_time = nil + delete(m.clearedFields, item.FieldSoldTime) +} + +// SetSoldTo sets the "sold_to" field. +func (m *ItemMutation) SetSoldTo(s string) { + m.sold_to = &s +} + +// SoldTo returns the value of the "sold_to" field in the mutation. +func (m *ItemMutation) SoldTo() (r string, exists bool) { + v := m.sold_to + if v == nil { + return + } + return *v, true +} + +// OldSoldTo returns the old "sold_to" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldSoldTo(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSoldTo is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSoldTo requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSoldTo: %w", err) + } + return oldValue.SoldTo, nil +} + +// ClearSoldTo clears the value of the "sold_to" field. +func (m *ItemMutation) ClearSoldTo() { + m.sold_to = nil + m.clearedFields[item.FieldSoldTo] = struct{}{} +} + +// SoldToCleared returns if the "sold_to" field was cleared in this mutation. +func (m *ItemMutation) SoldToCleared() bool { + _, ok := m.clearedFields[item.FieldSoldTo] + return ok +} + +// ResetSoldTo resets all changes to the "sold_to" field. +func (m *ItemMutation) ResetSoldTo() { + m.sold_to = nil + delete(m.clearedFields, item.FieldSoldTo) +} + +// SetSoldPrice sets the "sold_price" field. +func (m *ItemMutation) SetSoldPrice(f float64) { + m.sold_price = &f + m.addsold_price = nil +} + +// SoldPrice returns the value of the "sold_price" field in the mutation. +func (m *ItemMutation) SoldPrice() (r float64, exists bool) { + v := m.sold_price + if v == nil { + return + } + return *v, true +} + +// OldSoldPrice returns the old "sold_price" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldSoldPrice(ctx context.Context) (v float64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSoldPrice is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSoldPrice requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSoldPrice: %w", err) + } + return oldValue.SoldPrice, nil +} + +// AddSoldPrice adds f to the "sold_price" field. +func (m *ItemMutation) AddSoldPrice(f float64) { + if m.addsold_price != nil { + *m.addsold_price += f + } else { + m.addsold_price = &f + } +} + +// AddedSoldPrice returns the value that was added to the "sold_price" field in this mutation. +func (m *ItemMutation) AddedSoldPrice() (r float64, exists bool) { + v := m.addsold_price + if v == nil { + return + } + return *v, true +} + +// ResetSoldPrice resets all changes to the "sold_price" field. +func (m *ItemMutation) ResetSoldPrice() { + m.sold_price = nil + m.addsold_price = nil +} + +// SetSoldNotes sets the "sold_notes" field. +func (m *ItemMutation) SetSoldNotes(s string) { + m.sold_notes = &s +} + +// SoldNotes returns the value of the "sold_notes" field in the mutation. +func (m *ItemMutation) SoldNotes() (r string, exists bool) { + v := m.sold_notes + if v == nil { + return + } + return *v, true +} + +// OldSoldNotes returns the old "sold_notes" field's value of the Item entity. +// If the Item object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemMutation) OldSoldNotes(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSoldNotes is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSoldNotes requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSoldNotes: %w", err) + } + return oldValue.SoldNotes, nil +} + +// ClearSoldNotes clears the value of the "sold_notes" field. +func (m *ItemMutation) ClearSoldNotes() { + m.sold_notes = nil + m.clearedFields[item.FieldSoldNotes] = struct{}{} +} + +// SoldNotesCleared returns if the "sold_notes" field was cleared in this mutation. +func (m *ItemMutation) SoldNotesCleared() bool { + _, ok := m.clearedFields[item.FieldSoldNotes] + return ok +} + +// ResetSoldNotes resets all changes to the "sold_notes" field. +func (m *ItemMutation) ResetSoldNotes() { + m.sold_notes = nil + delete(m.clearedFields, item.FieldSoldNotes) +} + +// SetGroupID sets the "group" edge to the Group entity by id. +func (m *ItemMutation) SetGroupID(id uuid.UUID) { + m.group = &id +} + +// ClearGroup clears the "group" edge to the Group entity. +func (m *ItemMutation) ClearGroup() { + m.clearedgroup = true +} + +// GroupCleared reports if the "group" edge to the Group entity was cleared. +func (m *ItemMutation) GroupCleared() bool { + return m.clearedgroup +} + +// GroupID returns the "group" edge ID in the mutation. +func (m *ItemMutation) GroupID() (id uuid.UUID, exists bool) { + if m.group != nil { + return *m.group, true + } + return +} + +// GroupIDs returns the "group" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// GroupID instead. It exists only for internal usage by the builders. +func (m *ItemMutation) GroupIDs() (ids []uuid.UUID) { + if id := m.group; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetGroup resets all changes to the "group" edge. +func (m *ItemMutation) ResetGroup() { + m.group = nil + m.clearedgroup = false +} + +// SetParentID sets the "parent" edge to the Item entity by id. +func (m *ItemMutation) SetParentID(id uuid.UUID) { + m.parent = &id +} + +// ClearParent clears the "parent" edge to the Item entity. +func (m *ItemMutation) ClearParent() { + m.clearedparent = true +} + +// ParentCleared reports if the "parent" edge to the Item entity was cleared. +func (m *ItemMutation) ParentCleared() bool { + return m.clearedparent +} + +// ParentID returns the "parent" edge ID in the mutation. +func (m *ItemMutation) ParentID() (id uuid.UUID, exists bool) { + if m.parent != nil { + return *m.parent, true + } + return +} + +// ParentIDs returns the "parent" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ParentID instead. It exists only for internal usage by the builders. +func (m *ItemMutation) ParentIDs() (ids []uuid.UUID) { + if id := m.parent; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetParent resets all changes to the "parent" edge. +func (m *ItemMutation) ResetParent() { + m.parent = nil + m.clearedparent = false +} + +// AddChildIDs adds the "children" edge to the Item entity by ids. +func (m *ItemMutation) AddChildIDs(ids ...uuid.UUID) { + if m.children == nil { + m.children = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.children[ids[i]] = struct{}{} + } +} + +// ClearChildren clears the "children" edge to the Item entity. +func (m *ItemMutation) ClearChildren() { + m.clearedchildren = true +} + +// ChildrenCleared reports if the "children" edge to the Item entity was cleared. +func (m *ItemMutation) ChildrenCleared() bool { + return m.clearedchildren +} + +// RemoveChildIDs removes the "children" edge to the Item entity by IDs. +func (m *ItemMutation) RemoveChildIDs(ids ...uuid.UUID) { + if m.removedchildren == nil { + m.removedchildren = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.children, ids[i]) + m.removedchildren[ids[i]] = struct{}{} + } +} + +// RemovedChildren returns the removed IDs of the "children" edge to the Item entity. +func (m *ItemMutation) RemovedChildrenIDs() (ids []uuid.UUID) { + for id := range m.removedchildren { + ids = append(ids, id) + } + return +} + +// ChildrenIDs returns the "children" edge IDs in the mutation. +func (m *ItemMutation) ChildrenIDs() (ids []uuid.UUID) { + for id := range m.children { + ids = append(ids, id) + } + return +} + +// ResetChildren resets all changes to the "children" edge. +func (m *ItemMutation) ResetChildren() { + m.children = nil + m.clearedchildren = false + m.removedchildren = nil +} + +// AddLabelIDs adds the "label" edge to the Label entity by ids. +func (m *ItemMutation) AddLabelIDs(ids ...uuid.UUID) { + if m.label == nil { + m.label = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.label[ids[i]] = struct{}{} + } +} + +// ClearLabel clears the "label" edge to the Label entity. +func (m *ItemMutation) ClearLabel() { + m.clearedlabel = true +} + +// LabelCleared reports if the "label" edge to the Label entity was cleared. +func (m *ItemMutation) LabelCleared() bool { + return m.clearedlabel +} + +// RemoveLabelIDs removes the "label" edge to the Label entity by IDs. +func (m *ItemMutation) RemoveLabelIDs(ids ...uuid.UUID) { + if m.removedlabel == nil { + m.removedlabel = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.label, ids[i]) + m.removedlabel[ids[i]] = struct{}{} + } +} + +// RemovedLabel returns the removed IDs of the "label" edge to the Label entity. +func (m *ItemMutation) RemovedLabelIDs() (ids []uuid.UUID) { + for id := range m.removedlabel { + ids = append(ids, id) + } + return +} + +// LabelIDs returns the "label" edge IDs in the mutation. +func (m *ItemMutation) LabelIDs() (ids []uuid.UUID) { + for id := range m.label { + ids = append(ids, id) + } + return +} + +// ResetLabel resets all changes to the "label" edge. +func (m *ItemMutation) ResetLabel() { + m.label = nil + m.clearedlabel = false + m.removedlabel = nil +} + +// SetLocationID sets the "location" edge to the Location entity by id. +func (m *ItemMutation) SetLocationID(id uuid.UUID) { + m.location = &id +} + +// ClearLocation clears the "location" edge to the Location entity. +func (m *ItemMutation) ClearLocation() { + m.clearedlocation = true +} + +// LocationCleared reports if the "location" edge to the Location entity was cleared. +func (m *ItemMutation) LocationCleared() bool { + return m.clearedlocation +} + +// LocationID returns the "location" edge ID in the mutation. +func (m *ItemMutation) LocationID() (id uuid.UUID, exists bool) { + if m.location != nil { + return *m.location, true + } + return +} + +// LocationIDs returns the "location" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// LocationID instead. It exists only for internal usage by the builders. +func (m *ItemMutation) LocationIDs() (ids []uuid.UUID) { + if id := m.location; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetLocation resets all changes to the "location" edge. +func (m *ItemMutation) ResetLocation() { + m.location = nil + m.clearedlocation = false +} + +// AddFieldIDs adds the "fields" edge to the ItemField entity by ids. +func (m *ItemMutation) AddFieldIDs(ids ...uuid.UUID) { + if m.fields == nil { + m.fields = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.fields[ids[i]] = struct{}{} + } +} + +// ClearFields clears the "fields" edge to the ItemField entity. +func (m *ItemMutation) ClearFields() { + m.clearedfields = true +} + +// FieldsCleared reports if the "fields" edge to the ItemField entity was cleared. +func (m *ItemMutation) FieldsCleared() bool { + return m.clearedfields +} + +// RemoveFieldIDs removes the "fields" edge to the ItemField entity by IDs. +func (m *ItemMutation) RemoveFieldIDs(ids ...uuid.UUID) { + if m.removedfields == nil { + m.removedfields = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.fields, ids[i]) + m.removedfields[ids[i]] = struct{}{} + } +} + +// RemovedFields returns the removed IDs of the "fields" edge to the ItemField entity. +func (m *ItemMutation) RemovedFieldsIDs() (ids []uuid.UUID) { + for id := range m.removedfields { + ids = append(ids, id) + } + return +} + +// FieldsIDs returns the "fields" edge IDs in the mutation. +func (m *ItemMutation) FieldsIDs() (ids []uuid.UUID) { + for id := range m.fields { + ids = append(ids, id) + } + return +} + +// ResetFields resets all changes to the "fields" edge. +func (m *ItemMutation) ResetFields() { + m.fields = nil + m.clearedfields = false + m.removedfields = nil +} + +// AddMaintenanceEntryIDs adds the "maintenance_entries" edge to the MaintenanceEntry entity by ids. +func (m *ItemMutation) AddMaintenanceEntryIDs(ids ...uuid.UUID) { + if m.maintenance_entries == nil { + m.maintenance_entries = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.maintenance_entries[ids[i]] = struct{}{} + } +} + +// ClearMaintenanceEntries clears the "maintenance_entries" edge to the MaintenanceEntry entity. +func (m *ItemMutation) ClearMaintenanceEntries() { + m.clearedmaintenance_entries = true +} + +// MaintenanceEntriesCleared reports if the "maintenance_entries" edge to the MaintenanceEntry entity was cleared. +func (m *ItemMutation) MaintenanceEntriesCleared() bool { + return m.clearedmaintenance_entries +} + +// RemoveMaintenanceEntryIDs removes the "maintenance_entries" edge to the MaintenanceEntry entity by IDs. +func (m *ItemMutation) RemoveMaintenanceEntryIDs(ids ...uuid.UUID) { + if m.removedmaintenance_entries == nil { + m.removedmaintenance_entries = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.maintenance_entries, ids[i]) + m.removedmaintenance_entries[ids[i]] = struct{}{} + } +} + +// RemovedMaintenanceEntries returns the removed IDs of the "maintenance_entries" edge to the MaintenanceEntry entity. +func (m *ItemMutation) RemovedMaintenanceEntriesIDs() (ids []uuid.UUID) { + for id := range m.removedmaintenance_entries { + ids = append(ids, id) + } + return +} + +// MaintenanceEntriesIDs returns the "maintenance_entries" edge IDs in the mutation. +func (m *ItemMutation) MaintenanceEntriesIDs() (ids []uuid.UUID) { + for id := range m.maintenance_entries { + ids = append(ids, id) + } + return +} + +// ResetMaintenanceEntries resets all changes to the "maintenance_entries" edge. +func (m *ItemMutation) ResetMaintenanceEntries() { + m.maintenance_entries = nil + m.clearedmaintenance_entries = false + m.removedmaintenance_entries = nil +} + +// AddAttachmentIDs adds the "attachments" edge to the Attachment entity by ids. +func (m *ItemMutation) AddAttachmentIDs(ids ...uuid.UUID) { + if m.attachments == nil { + m.attachments = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.attachments[ids[i]] = struct{}{} + } +} + +// ClearAttachments clears the "attachments" edge to the Attachment entity. +func (m *ItemMutation) ClearAttachments() { + m.clearedattachments = true +} + +// AttachmentsCleared reports if the "attachments" edge to the Attachment entity was cleared. +func (m *ItemMutation) AttachmentsCleared() bool { + return m.clearedattachments +} + +// RemoveAttachmentIDs removes the "attachments" edge to the Attachment entity by IDs. +func (m *ItemMutation) RemoveAttachmentIDs(ids ...uuid.UUID) { + if m.removedattachments == nil { + m.removedattachments = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.attachments, ids[i]) + m.removedattachments[ids[i]] = struct{}{} + } +} + +// RemovedAttachments returns the removed IDs of the "attachments" edge to the Attachment entity. +func (m *ItemMutation) RemovedAttachmentsIDs() (ids []uuid.UUID) { + for id := range m.removedattachments { + ids = append(ids, id) + } + return +} + +// AttachmentsIDs returns the "attachments" edge IDs in the mutation. +func (m *ItemMutation) AttachmentsIDs() (ids []uuid.UUID) { + for id := range m.attachments { + ids = append(ids, id) + } + return +} + +// ResetAttachments resets all changes to the "attachments" edge. +func (m *ItemMutation) ResetAttachments() { + m.attachments = nil + m.clearedattachments = false + m.removedattachments = nil +} + +// Where appends a list predicates to the ItemMutation builder. +func (m *ItemMutation) Where(ps ...predicate.Item) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ItemMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ItemMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Item, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ItemMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ItemMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Item). +func (m *ItemMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *ItemMutation) Fields() []string { + fields := make([]string, 0, 24) + if m.created_at != nil { + fields = append(fields, item.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, item.FieldUpdatedAt) + } + if m.name != nil { + fields = append(fields, item.FieldName) + } + if m.description != nil { + fields = append(fields, item.FieldDescription) + } + if m.import_ref != nil { + fields = append(fields, item.FieldImportRef) + } + if m.notes != nil { + fields = append(fields, item.FieldNotes) + } + if m.quantity != nil { + fields = append(fields, item.FieldQuantity) + } + if m.insured != nil { + fields = append(fields, item.FieldInsured) + } + if m.archived != nil { + fields = append(fields, item.FieldArchived) + } + if m.asset_id != nil { + fields = append(fields, item.FieldAssetID) + } + if m.sync_child_items_locations != nil { + fields = append(fields, item.FieldSyncChildItemsLocations) + } + if m.serial_number != nil { + fields = append(fields, item.FieldSerialNumber) + } + if m.model_number != nil { + fields = append(fields, item.FieldModelNumber) + } + if m.manufacturer != nil { + fields = append(fields, item.FieldManufacturer) + } + if m.lifetime_warranty != nil { + fields = append(fields, item.FieldLifetimeWarranty) + } + if m.warranty_expires != nil { + fields = append(fields, item.FieldWarrantyExpires) + } + if m.warranty_details != nil { + fields = append(fields, item.FieldWarrantyDetails) + } + if m.purchase_time != nil { + fields = append(fields, item.FieldPurchaseTime) + } + if m.purchase_from != nil { + fields = append(fields, item.FieldPurchaseFrom) + } + if m.purchase_price != nil { + fields = append(fields, item.FieldPurchasePrice) + } + if m.sold_time != nil { + fields = append(fields, item.FieldSoldTime) + } + if m.sold_to != nil { + fields = append(fields, item.FieldSoldTo) + } + if m.sold_price != nil { + fields = append(fields, item.FieldSoldPrice) + } + if m.sold_notes != nil { + fields = append(fields, item.FieldSoldNotes) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *ItemMutation) Field(name string) (ent.Value, bool) { + switch name { + case item.FieldCreatedAt: + return m.CreatedAt() + case item.FieldUpdatedAt: + return m.UpdatedAt() + case item.FieldName: + return m.Name() + case item.FieldDescription: + return m.Description() + case item.FieldImportRef: + return m.ImportRef() + case item.FieldNotes: + return m.Notes() + case item.FieldQuantity: + return m.Quantity() + case item.FieldInsured: + return m.Insured() + case item.FieldArchived: + return m.Archived() + case item.FieldAssetID: + return m.AssetID() + case item.FieldSyncChildItemsLocations: + return m.SyncChildItemsLocations() + case item.FieldSerialNumber: + return m.SerialNumber() + case item.FieldModelNumber: + return m.ModelNumber() + case item.FieldManufacturer: + return m.Manufacturer() + case item.FieldLifetimeWarranty: + return m.LifetimeWarranty() + case item.FieldWarrantyExpires: + return m.WarrantyExpires() + case item.FieldWarrantyDetails: + return m.WarrantyDetails() + case item.FieldPurchaseTime: + return m.PurchaseTime() + case item.FieldPurchaseFrom: + return m.PurchaseFrom() + case item.FieldPurchasePrice: + return m.PurchasePrice() + case item.FieldSoldTime: + return m.SoldTime() + case item.FieldSoldTo: + return m.SoldTo() + case item.FieldSoldPrice: + return m.SoldPrice() + case item.FieldSoldNotes: + return m.SoldNotes() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *ItemMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case item.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case item.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case item.FieldName: + return m.OldName(ctx) + case item.FieldDescription: + return m.OldDescription(ctx) + case item.FieldImportRef: + return m.OldImportRef(ctx) + case item.FieldNotes: + return m.OldNotes(ctx) + case item.FieldQuantity: + return m.OldQuantity(ctx) + case item.FieldInsured: + return m.OldInsured(ctx) + case item.FieldArchived: + return m.OldArchived(ctx) + case item.FieldAssetID: + return m.OldAssetID(ctx) + case item.FieldSyncChildItemsLocations: + return m.OldSyncChildItemsLocations(ctx) + case item.FieldSerialNumber: + return m.OldSerialNumber(ctx) + case item.FieldModelNumber: + return m.OldModelNumber(ctx) + case item.FieldManufacturer: + return m.OldManufacturer(ctx) + case item.FieldLifetimeWarranty: + return m.OldLifetimeWarranty(ctx) + case item.FieldWarrantyExpires: + return m.OldWarrantyExpires(ctx) + case item.FieldWarrantyDetails: + return m.OldWarrantyDetails(ctx) + case item.FieldPurchaseTime: + return m.OldPurchaseTime(ctx) + case item.FieldPurchaseFrom: + return m.OldPurchaseFrom(ctx) + case item.FieldPurchasePrice: + return m.OldPurchasePrice(ctx) + case item.FieldSoldTime: + return m.OldSoldTime(ctx) + case item.FieldSoldTo: + return m.OldSoldTo(ctx) + case item.FieldSoldPrice: + return m.OldSoldPrice(ctx) + case item.FieldSoldNotes: + return m.OldSoldNotes(ctx) + } + return nil, fmt.Errorf("unknown Item field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ItemMutation) SetField(name string, value ent.Value) error { + switch name { + case item.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case item.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case item.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case item.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case item.FieldImportRef: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetImportRef(v) + return nil + case item.FieldNotes: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNotes(v) + return nil + case item.FieldQuantity: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetQuantity(v) + return nil + case item.FieldInsured: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetInsured(v) + return nil + case item.FieldArchived: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetArchived(v) + return nil + case item.FieldAssetID: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAssetID(v) + return nil + case item.FieldSyncChildItemsLocations: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSyncChildItemsLocations(v) + return nil + case item.FieldSerialNumber: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSerialNumber(v) + return nil + case item.FieldModelNumber: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModelNumber(v) + return nil + case item.FieldManufacturer: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetManufacturer(v) + return nil + case item.FieldLifetimeWarranty: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLifetimeWarranty(v) + return nil + case item.FieldWarrantyExpires: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetWarrantyExpires(v) + return nil + case item.FieldWarrantyDetails: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetWarrantyDetails(v) + return nil + case item.FieldPurchaseTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPurchaseTime(v) + return nil + case item.FieldPurchaseFrom: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPurchaseFrom(v) + return nil + case item.FieldPurchasePrice: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPurchasePrice(v) + return nil + case item.FieldSoldTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSoldTime(v) + return nil + case item.FieldSoldTo: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSoldTo(v) + return nil + case item.FieldSoldPrice: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSoldPrice(v) + return nil + case item.FieldSoldNotes: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSoldNotes(v) + return nil + } + return fmt.Errorf("unknown Item field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ItemMutation) AddedFields() []string { + var fields []string + if m.addquantity != nil { + fields = append(fields, item.FieldQuantity) + } + if m.addasset_id != nil { + fields = append(fields, item.FieldAssetID) + } + if m.addpurchase_price != nil { + fields = append(fields, item.FieldPurchasePrice) + } + if m.addsold_price != nil { + fields = append(fields, item.FieldSoldPrice) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *ItemMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case item.FieldQuantity: + return m.AddedQuantity() + case item.FieldAssetID: + return m.AddedAssetID() + case item.FieldPurchasePrice: + return m.AddedPurchasePrice() + case item.FieldSoldPrice: + return m.AddedSoldPrice() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ItemMutation) AddField(name string, value ent.Value) error { + switch name { + case item.FieldQuantity: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddQuantity(v) + return nil + case item.FieldAssetID: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddAssetID(v) + return nil + case item.FieldPurchasePrice: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddPurchasePrice(v) + return nil + case item.FieldSoldPrice: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSoldPrice(v) + return nil + } + return fmt.Errorf("unknown Item numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ItemMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(item.FieldDescription) { + fields = append(fields, item.FieldDescription) + } + if m.FieldCleared(item.FieldImportRef) { + fields = append(fields, item.FieldImportRef) + } + if m.FieldCleared(item.FieldNotes) { + fields = append(fields, item.FieldNotes) + } + if m.FieldCleared(item.FieldSerialNumber) { + fields = append(fields, item.FieldSerialNumber) + } + if m.FieldCleared(item.FieldModelNumber) { + fields = append(fields, item.FieldModelNumber) + } + if m.FieldCleared(item.FieldManufacturer) { + fields = append(fields, item.FieldManufacturer) + } + if m.FieldCleared(item.FieldWarrantyExpires) { + fields = append(fields, item.FieldWarrantyExpires) + } + if m.FieldCleared(item.FieldWarrantyDetails) { + fields = append(fields, item.FieldWarrantyDetails) + } + if m.FieldCleared(item.FieldPurchaseTime) { + fields = append(fields, item.FieldPurchaseTime) + } + if m.FieldCleared(item.FieldPurchaseFrom) { + fields = append(fields, item.FieldPurchaseFrom) + } + if m.FieldCleared(item.FieldSoldTime) { + fields = append(fields, item.FieldSoldTime) + } + if m.FieldCleared(item.FieldSoldTo) { + fields = append(fields, item.FieldSoldTo) + } + if m.FieldCleared(item.FieldSoldNotes) { + fields = append(fields, item.FieldSoldNotes) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ItemMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *ItemMutation) ClearField(name string) error { + switch name { + case item.FieldDescription: + m.ClearDescription() + return nil + case item.FieldImportRef: + m.ClearImportRef() + return nil + case item.FieldNotes: + m.ClearNotes() + return nil + case item.FieldSerialNumber: + m.ClearSerialNumber() + return nil + case item.FieldModelNumber: + m.ClearModelNumber() + return nil + case item.FieldManufacturer: + m.ClearManufacturer() + return nil + case item.FieldWarrantyExpires: + m.ClearWarrantyExpires() + return nil + case item.FieldWarrantyDetails: + m.ClearWarrantyDetails() + return nil + case item.FieldPurchaseTime: + m.ClearPurchaseTime() + return nil + case item.FieldPurchaseFrom: + m.ClearPurchaseFrom() + return nil + case item.FieldSoldTime: + m.ClearSoldTime() + return nil + case item.FieldSoldTo: + m.ClearSoldTo() + return nil + case item.FieldSoldNotes: + m.ClearSoldNotes() + return nil + } + return fmt.Errorf("unknown Item nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *ItemMutation) ResetField(name string) error { + switch name { + case item.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case item.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case item.FieldName: + m.ResetName() + return nil + case item.FieldDescription: + m.ResetDescription() + return nil + case item.FieldImportRef: + m.ResetImportRef() + return nil + case item.FieldNotes: + m.ResetNotes() + return nil + case item.FieldQuantity: + m.ResetQuantity() + return nil + case item.FieldInsured: + m.ResetInsured() + return nil + case item.FieldArchived: + m.ResetArchived() + return nil + case item.FieldAssetID: + m.ResetAssetID() + return nil + case item.FieldSyncChildItemsLocations: + m.ResetSyncChildItemsLocations() + return nil + case item.FieldSerialNumber: + m.ResetSerialNumber() + return nil + case item.FieldModelNumber: + m.ResetModelNumber() + return nil + case item.FieldManufacturer: + m.ResetManufacturer() + return nil + case item.FieldLifetimeWarranty: + m.ResetLifetimeWarranty() + return nil + case item.FieldWarrantyExpires: + m.ResetWarrantyExpires() + return nil + case item.FieldWarrantyDetails: + m.ResetWarrantyDetails() + return nil + case item.FieldPurchaseTime: + m.ResetPurchaseTime() + return nil + case item.FieldPurchaseFrom: + m.ResetPurchaseFrom() + return nil + case item.FieldPurchasePrice: + m.ResetPurchasePrice() + return nil + case item.FieldSoldTime: + m.ResetSoldTime() + return nil + case item.FieldSoldTo: + m.ResetSoldTo() + return nil + case item.FieldSoldPrice: + m.ResetSoldPrice() + return nil + case item.FieldSoldNotes: + m.ResetSoldNotes() + return nil + } + return fmt.Errorf("unknown Item field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ItemMutation) AddedEdges() []string { + edges := make([]string, 0, 8) + if m.group != nil { + edges = append(edges, item.EdgeGroup) + } + if m.parent != nil { + edges = append(edges, item.EdgeParent) + } + if m.children != nil { + edges = append(edges, item.EdgeChildren) + } + if m.label != nil { + edges = append(edges, item.EdgeLabel) + } + if m.location != nil { + edges = append(edges, item.EdgeLocation) + } + if m.fields != nil { + edges = append(edges, item.EdgeFields) + } + if m.maintenance_entries != nil { + edges = append(edges, item.EdgeMaintenanceEntries) + } + if m.attachments != nil { + edges = append(edges, item.EdgeAttachments) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ItemMutation) AddedIDs(name string) []ent.Value { + switch name { + case item.EdgeGroup: + if id := m.group; id != nil { + return []ent.Value{*id} + } + case item.EdgeParent: + if id := m.parent; id != nil { + return []ent.Value{*id} + } + case item.EdgeChildren: + ids := make([]ent.Value, 0, len(m.children)) + for id := range m.children { + ids = append(ids, id) + } + return ids + case item.EdgeLabel: + ids := make([]ent.Value, 0, len(m.label)) + for id := range m.label { + ids = append(ids, id) + } + return ids + case item.EdgeLocation: + if id := m.location; id != nil { + return []ent.Value{*id} + } + case item.EdgeFields: + ids := make([]ent.Value, 0, len(m.fields)) + for id := range m.fields { + ids = append(ids, id) + } + return ids + case item.EdgeMaintenanceEntries: + ids := make([]ent.Value, 0, len(m.maintenance_entries)) + for id := range m.maintenance_entries { + ids = append(ids, id) + } + return ids + case item.EdgeAttachments: + ids := make([]ent.Value, 0, len(m.attachments)) + for id := range m.attachments { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ItemMutation) RemovedEdges() []string { + edges := make([]string, 0, 8) + if m.removedchildren != nil { + edges = append(edges, item.EdgeChildren) + } + if m.removedlabel != nil { + edges = append(edges, item.EdgeLabel) + } + if m.removedfields != nil { + edges = append(edges, item.EdgeFields) + } + if m.removedmaintenance_entries != nil { + edges = append(edges, item.EdgeMaintenanceEntries) + } + if m.removedattachments != nil { + edges = append(edges, item.EdgeAttachments) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ItemMutation) RemovedIDs(name string) []ent.Value { + switch name { + case item.EdgeChildren: + ids := make([]ent.Value, 0, len(m.removedchildren)) + for id := range m.removedchildren { + ids = append(ids, id) + } + return ids + case item.EdgeLabel: + ids := make([]ent.Value, 0, len(m.removedlabel)) + for id := range m.removedlabel { + ids = append(ids, id) + } + return ids + case item.EdgeFields: + ids := make([]ent.Value, 0, len(m.removedfields)) + for id := range m.removedfields { + ids = append(ids, id) + } + return ids + case item.EdgeMaintenanceEntries: + ids := make([]ent.Value, 0, len(m.removedmaintenance_entries)) + for id := range m.removedmaintenance_entries { + ids = append(ids, id) + } + return ids + case item.EdgeAttachments: + ids := make([]ent.Value, 0, len(m.removedattachments)) + for id := range m.removedattachments { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ItemMutation) ClearedEdges() []string { + edges := make([]string, 0, 8) + if m.clearedgroup { + edges = append(edges, item.EdgeGroup) + } + if m.clearedparent { + edges = append(edges, item.EdgeParent) + } + if m.clearedchildren { + edges = append(edges, item.EdgeChildren) + } + if m.clearedlabel { + edges = append(edges, item.EdgeLabel) + } + if m.clearedlocation { + edges = append(edges, item.EdgeLocation) + } + if m.clearedfields { + edges = append(edges, item.EdgeFields) + } + if m.clearedmaintenance_entries { + edges = append(edges, item.EdgeMaintenanceEntries) + } + if m.clearedattachments { + edges = append(edges, item.EdgeAttachments) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ItemMutation) EdgeCleared(name string) bool { + switch name { + case item.EdgeGroup: + return m.clearedgroup + case item.EdgeParent: + return m.clearedparent + case item.EdgeChildren: + return m.clearedchildren + case item.EdgeLabel: + return m.clearedlabel + case item.EdgeLocation: + return m.clearedlocation + case item.EdgeFields: + return m.clearedfields + case item.EdgeMaintenanceEntries: + return m.clearedmaintenance_entries + case item.EdgeAttachments: + return m.clearedattachments + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *ItemMutation) ClearEdge(name string) error { + switch name { + case item.EdgeGroup: + m.ClearGroup() + return nil + case item.EdgeParent: + m.ClearParent() + return nil + case item.EdgeLocation: + m.ClearLocation() + return nil + } + return fmt.Errorf("unknown Item unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *ItemMutation) ResetEdge(name string) error { + switch name { + case item.EdgeGroup: + m.ResetGroup() + return nil + case item.EdgeParent: + m.ResetParent() + return nil + case item.EdgeChildren: + m.ResetChildren() + return nil + case item.EdgeLabel: + m.ResetLabel() + return nil + case item.EdgeLocation: + m.ResetLocation() + return nil + case item.EdgeFields: + m.ResetFields() + return nil + case item.EdgeMaintenanceEntries: + m.ResetMaintenanceEntries() + return nil + case item.EdgeAttachments: + m.ResetAttachments() + return nil + } + return fmt.Errorf("unknown Item edge %s", name) +} + +// ItemFieldMutation represents an operation that mutates the ItemField nodes in the graph. +type ItemFieldMutation struct { config op Op typ string @@ -8007,16 +6156,2559 @@ type LabelMutation struct { updated_at *time.Time name *string description *string - color *string + _type *itemfield.Type + text_value *string + number_value *int + addnumber_value *int + boolean_value *bool + time_value *time.Time clearedFields map[string]struct{} - group *uuid.UUID - clearedgroup bool - entities map[uuid.UUID]struct{} - removedentities map[uuid.UUID]struct{} - clearedentities bool + item *uuid.UUID + cleareditem bool done bool - oldValue func(context.Context) (*Label, error) - predicates []predicate.Label + oldValue func(context.Context) (*ItemField, error) + predicates []predicate.ItemField +} + +var _ ent.Mutation = (*ItemFieldMutation)(nil) + +// itemfieldOption allows management of the mutation configuration using functional options. +type itemfieldOption func(*ItemFieldMutation) + +// newItemFieldMutation creates new mutation for the ItemField entity. +func newItemFieldMutation(c config, op Op, opts ...itemfieldOption) *ItemFieldMutation { + m := &ItemFieldMutation{ + config: c, + op: op, + typ: TypeItemField, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withItemFieldID sets the ID field of the mutation. +func withItemFieldID(id uuid.UUID) itemfieldOption { + return func(m *ItemFieldMutation) { + var ( + err error + once sync.Once + value *ItemField + ) + m.oldValue = func(ctx context.Context) (*ItemField, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().ItemField.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withItemField sets the old ItemField of the mutation. +func withItemField(node *ItemField) itemfieldOption { + return func(m *ItemFieldMutation) { + m.oldValue = func(context.Context) (*ItemField, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m ItemFieldMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m ItemFieldMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of ItemField entities. +func (m *ItemFieldMutation) SetID(id uuid.UUID) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *ItemFieldMutation) ID() (id uuid.UUID, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *ItemFieldMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uuid.UUID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().ItemField.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *ItemFieldMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *ItemFieldMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the ItemField entity. +// If the ItemField object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemFieldMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *ItemFieldMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *ItemFieldMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *ItemFieldMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the ItemField entity. +// If the ItemField object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemFieldMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *ItemFieldMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetName sets the "name" field. +func (m *ItemFieldMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *ItemFieldMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the ItemField entity. +// If the ItemField object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemFieldMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *ItemFieldMutation) ResetName() { + m.name = nil +} + +// SetDescription sets the "description" field. +func (m *ItemFieldMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *ItemFieldMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the ItemField entity. +// If the ItemField object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemFieldMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ClearDescription clears the value of the "description" field. +func (m *ItemFieldMutation) ClearDescription() { + m.description = nil + m.clearedFields[itemfield.FieldDescription] = struct{}{} +} + +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *ItemFieldMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[itemfield.FieldDescription] + return ok +} + +// ResetDescription resets all changes to the "description" field. +func (m *ItemFieldMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, itemfield.FieldDescription) +} + +// SetType sets the "type" field. +func (m *ItemFieldMutation) SetType(i itemfield.Type) { + m._type = &i +} + +// GetType returns the value of the "type" field in the mutation. +func (m *ItemFieldMutation) GetType() (r itemfield.Type, exists bool) { + v := m._type + if v == nil { + return + } + return *v, true +} + +// OldType returns the old "type" field's value of the ItemField entity. +// If the ItemField object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemFieldMutation) OldType(ctx context.Context) (v itemfield.Type, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldType: %w", err) + } + return oldValue.Type, nil +} + +// ResetType resets all changes to the "type" field. +func (m *ItemFieldMutation) ResetType() { + m._type = nil +} + +// SetTextValue sets the "text_value" field. +func (m *ItemFieldMutation) SetTextValue(s string) { + m.text_value = &s +} + +// TextValue returns the value of the "text_value" field in the mutation. +func (m *ItemFieldMutation) TextValue() (r string, exists bool) { + v := m.text_value + if v == nil { + return + } + return *v, true +} + +// OldTextValue returns the old "text_value" field's value of the ItemField entity. +// If the ItemField object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemFieldMutation) OldTextValue(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTextValue is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTextValue requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTextValue: %w", err) + } + return oldValue.TextValue, nil +} + +// ClearTextValue clears the value of the "text_value" field. +func (m *ItemFieldMutation) ClearTextValue() { + m.text_value = nil + m.clearedFields[itemfield.FieldTextValue] = struct{}{} +} + +// TextValueCleared returns if the "text_value" field was cleared in this mutation. +func (m *ItemFieldMutation) TextValueCleared() bool { + _, ok := m.clearedFields[itemfield.FieldTextValue] + return ok +} + +// ResetTextValue resets all changes to the "text_value" field. +func (m *ItemFieldMutation) ResetTextValue() { + m.text_value = nil + delete(m.clearedFields, itemfield.FieldTextValue) +} + +// SetNumberValue sets the "number_value" field. +func (m *ItemFieldMutation) SetNumberValue(i int) { + m.number_value = &i + m.addnumber_value = nil +} + +// NumberValue returns the value of the "number_value" field in the mutation. +func (m *ItemFieldMutation) NumberValue() (r int, exists bool) { + v := m.number_value + if v == nil { + return + } + return *v, true +} + +// OldNumberValue returns the old "number_value" field's value of the ItemField entity. +// If the ItemField object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemFieldMutation) OldNumberValue(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNumberValue is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNumberValue requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNumberValue: %w", err) + } + return oldValue.NumberValue, nil +} + +// AddNumberValue adds i to the "number_value" field. +func (m *ItemFieldMutation) AddNumberValue(i int) { + if m.addnumber_value != nil { + *m.addnumber_value += i + } else { + m.addnumber_value = &i + } +} + +// AddedNumberValue returns the value that was added to the "number_value" field in this mutation. +func (m *ItemFieldMutation) AddedNumberValue() (r int, exists bool) { + v := m.addnumber_value + if v == nil { + return + } + return *v, true +} + +// ClearNumberValue clears the value of the "number_value" field. +func (m *ItemFieldMutation) ClearNumberValue() { + m.number_value = nil + m.addnumber_value = nil + m.clearedFields[itemfield.FieldNumberValue] = struct{}{} +} + +// NumberValueCleared returns if the "number_value" field was cleared in this mutation. +func (m *ItemFieldMutation) NumberValueCleared() bool { + _, ok := m.clearedFields[itemfield.FieldNumberValue] + return ok +} + +// ResetNumberValue resets all changes to the "number_value" field. +func (m *ItemFieldMutation) ResetNumberValue() { + m.number_value = nil + m.addnumber_value = nil + delete(m.clearedFields, itemfield.FieldNumberValue) +} + +// SetBooleanValue sets the "boolean_value" field. +func (m *ItemFieldMutation) SetBooleanValue(b bool) { + m.boolean_value = &b +} + +// BooleanValue returns the value of the "boolean_value" field in the mutation. +func (m *ItemFieldMutation) BooleanValue() (r bool, exists bool) { + v := m.boolean_value + if v == nil { + return + } + return *v, true +} + +// OldBooleanValue returns the old "boolean_value" field's value of the ItemField entity. +// If the ItemField object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemFieldMutation) OldBooleanValue(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBooleanValue is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBooleanValue requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBooleanValue: %w", err) + } + return oldValue.BooleanValue, nil +} + +// ResetBooleanValue resets all changes to the "boolean_value" field. +func (m *ItemFieldMutation) ResetBooleanValue() { + m.boolean_value = nil +} + +// SetTimeValue sets the "time_value" field. +func (m *ItemFieldMutation) SetTimeValue(t time.Time) { + m.time_value = &t +} + +// TimeValue returns the value of the "time_value" field in the mutation. +func (m *ItemFieldMutation) TimeValue() (r time.Time, exists bool) { + v := m.time_value + if v == nil { + return + } + return *v, true +} + +// OldTimeValue returns the old "time_value" field's value of the ItemField entity. +// If the ItemField object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemFieldMutation) OldTimeValue(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTimeValue is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTimeValue requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTimeValue: %w", err) + } + return oldValue.TimeValue, nil +} + +// ResetTimeValue resets all changes to the "time_value" field. +func (m *ItemFieldMutation) ResetTimeValue() { + m.time_value = nil +} + +// SetItemID sets the "item" edge to the Item entity by id. +func (m *ItemFieldMutation) SetItemID(id uuid.UUID) { + m.item = &id +} + +// ClearItem clears the "item" edge to the Item entity. +func (m *ItemFieldMutation) ClearItem() { + m.cleareditem = true +} + +// ItemCleared reports if the "item" edge to the Item entity was cleared. +func (m *ItemFieldMutation) ItemCleared() bool { + return m.cleareditem +} + +// ItemID returns the "item" edge ID in the mutation. +func (m *ItemFieldMutation) ItemID() (id uuid.UUID, exists bool) { + if m.item != nil { + return *m.item, true + } + return +} + +// ItemIDs returns the "item" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ItemID instead. It exists only for internal usage by the builders. +func (m *ItemFieldMutation) ItemIDs() (ids []uuid.UUID) { + if id := m.item; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetItem resets all changes to the "item" edge. +func (m *ItemFieldMutation) ResetItem() { + m.item = nil + m.cleareditem = false +} + +// Where appends a list predicates to the ItemFieldMutation builder. +func (m *ItemFieldMutation) Where(ps ...predicate.ItemField) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ItemFieldMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ItemFieldMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ItemField, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ItemFieldMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ItemFieldMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (ItemField). +func (m *ItemFieldMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *ItemFieldMutation) Fields() []string { + fields := make([]string, 0, 9) + if m.created_at != nil { + fields = append(fields, itemfield.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, itemfield.FieldUpdatedAt) + } + if m.name != nil { + fields = append(fields, itemfield.FieldName) + } + if m.description != nil { + fields = append(fields, itemfield.FieldDescription) + } + if m._type != nil { + fields = append(fields, itemfield.FieldType) + } + if m.text_value != nil { + fields = append(fields, itemfield.FieldTextValue) + } + if m.number_value != nil { + fields = append(fields, itemfield.FieldNumberValue) + } + if m.boolean_value != nil { + fields = append(fields, itemfield.FieldBooleanValue) + } + if m.time_value != nil { + fields = append(fields, itemfield.FieldTimeValue) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *ItemFieldMutation) Field(name string) (ent.Value, bool) { + switch name { + case itemfield.FieldCreatedAt: + return m.CreatedAt() + case itemfield.FieldUpdatedAt: + return m.UpdatedAt() + case itemfield.FieldName: + return m.Name() + case itemfield.FieldDescription: + return m.Description() + case itemfield.FieldType: + return m.GetType() + case itemfield.FieldTextValue: + return m.TextValue() + case itemfield.FieldNumberValue: + return m.NumberValue() + case itemfield.FieldBooleanValue: + return m.BooleanValue() + case itemfield.FieldTimeValue: + return m.TimeValue() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *ItemFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case itemfield.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case itemfield.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case itemfield.FieldName: + return m.OldName(ctx) + case itemfield.FieldDescription: + return m.OldDescription(ctx) + case itemfield.FieldType: + return m.OldType(ctx) + case itemfield.FieldTextValue: + return m.OldTextValue(ctx) + case itemfield.FieldNumberValue: + return m.OldNumberValue(ctx) + case itemfield.FieldBooleanValue: + return m.OldBooleanValue(ctx) + case itemfield.FieldTimeValue: + return m.OldTimeValue(ctx) + } + return nil, fmt.Errorf("unknown ItemField field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ItemFieldMutation) SetField(name string, value ent.Value) error { + switch name { + case itemfield.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case itemfield.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case itemfield.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case itemfield.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case itemfield.FieldType: + v, ok := value.(itemfield.Type) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetType(v) + return nil + case itemfield.FieldTextValue: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTextValue(v) + return nil + case itemfield.FieldNumberValue: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNumberValue(v) + return nil + case itemfield.FieldBooleanValue: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBooleanValue(v) + return nil + case itemfield.FieldTimeValue: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTimeValue(v) + return nil + } + return fmt.Errorf("unknown ItemField field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ItemFieldMutation) AddedFields() []string { + var fields []string + if m.addnumber_value != nil { + fields = append(fields, itemfield.FieldNumberValue) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *ItemFieldMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case itemfield.FieldNumberValue: + return m.AddedNumberValue() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ItemFieldMutation) AddField(name string, value ent.Value) error { + switch name { + case itemfield.FieldNumberValue: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddNumberValue(v) + return nil + } + return fmt.Errorf("unknown ItemField numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ItemFieldMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(itemfield.FieldDescription) { + fields = append(fields, itemfield.FieldDescription) + } + if m.FieldCleared(itemfield.FieldTextValue) { + fields = append(fields, itemfield.FieldTextValue) + } + if m.FieldCleared(itemfield.FieldNumberValue) { + fields = append(fields, itemfield.FieldNumberValue) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ItemFieldMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *ItemFieldMutation) ClearField(name string) error { + switch name { + case itemfield.FieldDescription: + m.ClearDescription() + return nil + case itemfield.FieldTextValue: + m.ClearTextValue() + return nil + case itemfield.FieldNumberValue: + m.ClearNumberValue() + return nil + } + return fmt.Errorf("unknown ItemField nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *ItemFieldMutation) ResetField(name string) error { + switch name { + case itemfield.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case itemfield.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case itemfield.FieldName: + m.ResetName() + return nil + case itemfield.FieldDescription: + m.ResetDescription() + return nil + case itemfield.FieldType: + m.ResetType() + return nil + case itemfield.FieldTextValue: + m.ResetTextValue() + return nil + case itemfield.FieldNumberValue: + m.ResetNumberValue() + return nil + case itemfield.FieldBooleanValue: + m.ResetBooleanValue() + return nil + case itemfield.FieldTimeValue: + m.ResetTimeValue() + return nil + } + return fmt.Errorf("unknown ItemField field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ItemFieldMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.item != nil { + edges = append(edges, itemfield.EdgeItem) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ItemFieldMutation) AddedIDs(name string) []ent.Value { + switch name { + case itemfield.EdgeItem: + if id := m.item; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ItemFieldMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ItemFieldMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ItemFieldMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.cleareditem { + edges = append(edges, itemfield.EdgeItem) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ItemFieldMutation) EdgeCleared(name string) bool { + switch name { + case itemfield.EdgeItem: + return m.cleareditem + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *ItemFieldMutation) ClearEdge(name string) error { + switch name { + case itemfield.EdgeItem: + m.ClearItem() + return nil + } + return fmt.Errorf("unknown ItemField unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *ItemFieldMutation) ResetEdge(name string) error { + switch name { + case itemfield.EdgeItem: + m.ResetItem() + return nil + } + return fmt.Errorf("unknown ItemField edge %s", name) +} + +// ItemTemplateMutation represents an operation that mutates the ItemTemplate nodes in the graph. +type ItemTemplateMutation struct { + config + op Op + typ string + id *uuid.UUID + created_at *time.Time + updated_at *time.Time + name *string + description *string + notes *string + default_quantity *int + adddefault_quantity *int + default_insured *bool + default_name *string + default_description *string + default_manufacturer *string + default_model_number *string + default_lifetime_warranty *bool + default_warranty_details *string + include_warranty_fields *bool + include_purchase_fields *bool + include_sold_fields *bool + default_label_ids *[]uuid.UUID + appenddefault_label_ids []uuid.UUID + clearedFields map[string]struct{} + group *uuid.UUID + clearedgroup bool + fields map[uuid.UUID]struct{} + removedfields map[uuid.UUID]struct{} + clearedfields bool + location *uuid.UUID + clearedlocation bool + done bool + oldValue func(context.Context) (*ItemTemplate, error) + predicates []predicate.ItemTemplate +} + +var _ ent.Mutation = (*ItemTemplateMutation)(nil) + +// itemtemplateOption allows management of the mutation configuration using functional options. +type itemtemplateOption func(*ItemTemplateMutation) + +// newItemTemplateMutation creates new mutation for the ItemTemplate entity. +func newItemTemplateMutation(c config, op Op, opts ...itemtemplateOption) *ItemTemplateMutation { + m := &ItemTemplateMutation{ + config: c, + op: op, + typ: TypeItemTemplate, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withItemTemplateID sets the ID field of the mutation. +func withItemTemplateID(id uuid.UUID) itemtemplateOption { + return func(m *ItemTemplateMutation) { + var ( + err error + once sync.Once + value *ItemTemplate + ) + m.oldValue = func(ctx context.Context) (*ItemTemplate, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().ItemTemplate.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withItemTemplate sets the old ItemTemplate of the mutation. +func withItemTemplate(node *ItemTemplate) itemtemplateOption { + return func(m *ItemTemplateMutation) { + m.oldValue = func(context.Context) (*ItemTemplate, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m ItemTemplateMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m ItemTemplateMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of ItemTemplate entities. +func (m *ItemTemplateMutation) SetID(id uuid.UUID) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *ItemTemplateMutation) ID() (id uuid.UUID, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *ItemTemplateMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uuid.UUID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().ItemTemplate.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *ItemTemplateMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *ItemTemplateMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the ItemTemplate entity. +// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemTemplateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *ItemTemplateMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *ItemTemplateMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *ItemTemplateMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the ItemTemplate entity. +// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemTemplateMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *ItemTemplateMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetName sets the "name" field. +func (m *ItemTemplateMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *ItemTemplateMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the ItemTemplate entity. +// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemTemplateMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *ItemTemplateMutation) ResetName() { + m.name = nil +} + +// SetDescription sets the "description" field. +func (m *ItemTemplateMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *ItemTemplateMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the ItemTemplate entity. +// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemTemplateMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ClearDescription clears the value of the "description" field. +func (m *ItemTemplateMutation) ClearDescription() { + m.description = nil + m.clearedFields[itemtemplate.FieldDescription] = struct{}{} +} + +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *ItemTemplateMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[itemtemplate.FieldDescription] + return ok +} + +// ResetDescription resets all changes to the "description" field. +func (m *ItemTemplateMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, itemtemplate.FieldDescription) +} + +// SetNotes sets the "notes" field. +func (m *ItemTemplateMutation) SetNotes(s string) { + m.notes = &s +} + +// Notes returns the value of the "notes" field in the mutation. +func (m *ItemTemplateMutation) Notes() (r string, exists bool) { + v := m.notes + if v == nil { + return + } + return *v, true +} + +// OldNotes returns the old "notes" field's value of the ItemTemplate entity. +// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemTemplateMutation) OldNotes(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNotes is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNotes requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNotes: %w", err) + } + return oldValue.Notes, nil +} + +// ClearNotes clears the value of the "notes" field. +func (m *ItemTemplateMutation) ClearNotes() { + m.notes = nil + m.clearedFields[itemtemplate.FieldNotes] = struct{}{} +} + +// NotesCleared returns if the "notes" field was cleared in this mutation. +func (m *ItemTemplateMutation) NotesCleared() bool { + _, ok := m.clearedFields[itemtemplate.FieldNotes] + return ok +} + +// ResetNotes resets all changes to the "notes" field. +func (m *ItemTemplateMutation) ResetNotes() { + m.notes = nil + delete(m.clearedFields, itemtemplate.FieldNotes) +} + +// SetDefaultQuantity sets the "default_quantity" field. +func (m *ItemTemplateMutation) SetDefaultQuantity(i int) { + m.default_quantity = &i + m.adddefault_quantity = nil +} + +// DefaultQuantity returns the value of the "default_quantity" field in the mutation. +func (m *ItemTemplateMutation) DefaultQuantity() (r int, exists bool) { + v := m.default_quantity + if v == nil { + return + } + return *v, true +} + +// OldDefaultQuantity returns the old "default_quantity" field's value of the ItemTemplate entity. +// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemTemplateMutation) OldDefaultQuantity(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDefaultQuantity is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDefaultQuantity requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDefaultQuantity: %w", err) + } + return oldValue.DefaultQuantity, nil +} + +// AddDefaultQuantity adds i to the "default_quantity" field. +func (m *ItemTemplateMutation) AddDefaultQuantity(i int) { + if m.adddefault_quantity != nil { + *m.adddefault_quantity += i + } else { + m.adddefault_quantity = &i + } +} + +// AddedDefaultQuantity returns the value that was added to the "default_quantity" field in this mutation. +func (m *ItemTemplateMutation) AddedDefaultQuantity() (r int, exists bool) { + v := m.adddefault_quantity + if v == nil { + return + } + return *v, true +} + +// ResetDefaultQuantity resets all changes to the "default_quantity" field. +func (m *ItemTemplateMutation) ResetDefaultQuantity() { + m.default_quantity = nil + m.adddefault_quantity = nil +} + +// SetDefaultInsured sets the "default_insured" field. +func (m *ItemTemplateMutation) SetDefaultInsured(b bool) { + m.default_insured = &b +} + +// DefaultInsured returns the value of the "default_insured" field in the mutation. +func (m *ItemTemplateMutation) DefaultInsured() (r bool, exists bool) { + v := m.default_insured + if v == nil { + return + } + return *v, true +} + +// OldDefaultInsured returns the old "default_insured" field's value of the ItemTemplate entity. +// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemTemplateMutation) OldDefaultInsured(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDefaultInsured is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDefaultInsured requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDefaultInsured: %w", err) + } + return oldValue.DefaultInsured, nil +} + +// ResetDefaultInsured resets all changes to the "default_insured" field. +func (m *ItemTemplateMutation) ResetDefaultInsured() { + m.default_insured = nil +} + +// SetDefaultName sets the "default_name" field. +func (m *ItemTemplateMutation) SetDefaultName(s string) { + m.default_name = &s +} + +// DefaultName returns the value of the "default_name" field in the mutation. +func (m *ItemTemplateMutation) DefaultName() (r string, exists bool) { + v := m.default_name + if v == nil { + return + } + return *v, true +} + +// OldDefaultName returns the old "default_name" field's value of the ItemTemplate entity. +// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemTemplateMutation) OldDefaultName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDefaultName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDefaultName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDefaultName: %w", err) + } + return oldValue.DefaultName, nil +} + +// ClearDefaultName clears the value of the "default_name" field. +func (m *ItemTemplateMutation) ClearDefaultName() { + m.default_name = nil + m.clearedFields[itemtemplate.FieldDefaultName] = struct{}{} +} + +// DefaultNameCleared returns if the "default_name" field was cleared in this mutation. +func (m *ItemTemplateMutation) DefaultNameCleared() bool { + _, ok := m.clearedFields[itemtemplate.FieldDefaultName] + return ok +} + +// ResetDefaultName resets all changes to the "default_name" field. +func (m *ItemTemplateMutation) ResetDefaultName() { + m.default_name = nil + delete(m.clearedFields, itemtemplate.FieldDefaultName) +} + +// SetDefaultDescription sets the "default_description" field. +func (m *ItemTemplateMutation) SetDefaultDescription(s string) { + m.default_description = &s +} + +// DefaultDescription returns the value of the "default_description" field in the mutation. +func (m *ItemTemplateMutation) DefaultDescription() (r string, exists bool) { + v := m.default_description + if v == nil { + return + } + return *v, true +} + +// OldDefaultDescription returns the old "default_description" field's value of the ItemTemplate entity. +// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemTemplateMutation) OldDefaultDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDefaultDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDefaultDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDefaultDescription: %w", err) + } + return oldValue.DefaultDescription, nil +} + +// ClearDefaultDescription clears the value of the "default_description" field. +func (m *ItemTemplateMutation) ClearDefaultDescription() { + m.default_description = nil + m.clearedFields[itemtemplate.FieldDefaultDescription] = struct{}{} +} + +// DefaultDescriptionCleared returns if the "default_description" field was cleared in this mutation. +func (m *ItemTemplateMutation) DefaultDescriptionCleared() bool { + _, ok := m.clearedFields[itemtemplate.FieldDefaultDescription] + return ok +} + +// ResetDefaultDescription resets all changes to the "default_description" field. +func (m *ItemTemplateMutation) ResetDefaultDescription() { + m.default_description = nil + delete(m.clearedFields, itemtemplate.FieldDefaultDescription) +} + +// SetDefaultManufacturer sets the "default_manufacturer" field. +func (m *ItemTemplateMutation) SetDefaultManufacturer(s string) { + m.default_manufacturer = &s +} + +// DefaultManufacturer returns the value of the "default_manufacturer" field in the mutation. +func (m *ItemTemplateMutation) DefaultManufacturer() (r string, exists bool) { + v := m.default_manufacturer + if v == nil { + return + } + return *v, true +} + +// OldDefaultManufacturer returns the old "default_manufacturer" field's value of the ItemTemplate entity. +// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemTemplateMutation) OldDefaultManufacturer(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDefaultManufacturer is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDefaultManufacturer requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDefaultManufacturer: %w", err) + } + return oldValue.DefaultManufacturer, nil +} + +// ClearDefaultManufacturer clears the value of the "default_manufacturer" field. +func (m *ItemTemplateMutation) ClearDefaultManufacturer() { + m.default_manufacturer = nil + m.clearedFields[itemtemplate.FieldDefaultManufacturer] = struct{}{} +} + +// DefaultManufacturerCleared returns if the "default_manufacturer" field was cleared in this mutation. +func (m *ItemTemplateMutation) DefaultManufacturerCleared() bool { + _, ok := m.clearedFields[itemtemplate.FieldDefaultManufacturer] + return ok +} + +// ResetDefaultManufacturer resets all changes to the "default_manufacturer" field. +func (m *ItemTemplateMutation) ResetDefaultManufacturer() { + m.default_manufacturer = nil + delete(m.clearedFields, itemtemplate.FieldDefaultManufacturer) +} + +// SetDefaultModelNumber sets the "default_model_number" field. +func (m *ItemTemplateMutation) SetDefaultModelNumber(s string) { + m.default_model_number = &s +} + +// DefaultModelNumber returns the value of the "default_model_number" field in the mutation. +func (m *ItemTemplateMutation) DefaultModelNumber() (r string, exists bool) { + v := m.default_model_number + if v == nil { + return + } + return *v, true +} + +// OldDefaultModelNumber returns the old "default_model_number" field's value of the ItemTemplate entity. +// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemTemplateMutation) OldDefaultModelNumber(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDefaultModelNumber is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDefaultModelNumber requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDefaultModelNumber: %w", err) + } + return oldValue.DefaultModelNumber, nil +} + +// ClearDefaultModelNumber clears the value of the "default_model_number" field. +func (m *ItemTemplateMutation) ClearDefaultModelNumber() { + m.default_model_number = nil + m.clearedFields[itemtemplate.FieldDefaultModelNumber] = struct{}{} +} + +// DefaultModelNumberCleared returns if the "default_model_number" field was cleared in this mutation. +func (m *ItemTemplateMutation) DefaultModelNumberCleared() bool { + _, ok := m.clearedFields[itemtemplate.FieldDefaultModelNumber] + return ok +} + +// ResetDefaultModelNumber resets all changes to the "default_model_number" field. +func (m *ItemTemplateMutation) ResetDefaultModelNumber() { + m.default_model_number = nil + delete(m.clearedFields, itemtemplate.FieldDefaultModelNumber) +} + +// SetDefaultLifetimeWarranty sets the "default_lifetime_warranty" field. +func (m *ItemTemplateMutation) SetDefaultLifetimeWarranty(b bool) { + m.default_lifetime_warranty = &b +} + +// DefaultLifetimeWarranty returns the value of the "default_lifetime_warranty" field in the mutation. +func (m *ItemTemplateMutation) DefaultLifetimeWarranty() (r bool, exists bool) { + v := m.default_lifetime_warranty + if v == nil { + return + } + return *v, true +} + +// OldDefaultLifetimeWarranty returns the old "default_lifetime_warranty" field's value of the ItemTemplate entity. +// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemTemplateMutation) OldDefaultLifetimeWarranty(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDefaultLifetimeWarranty is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDefaultLifetimeWarranty requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDefaultLifetimeWarranty: %w", err) + } + return oldValue.DefaultLifetimeWarranty, nil +} + +// ResetDefaultLifetimeWarranty resets all changes to the "default_lifetime_warranty" field. +func (m *ItemTemplateMutation) ResetDefaultLifetimeWarranty() { + m.default_lifetime_warranty = nil +} + +// SetDefaultWarrantyDetails sets the "default_warranty_details" field. +func (m *ItemTemplateMutation) SetDefaultWarrantyDetails(s string) { + m.default_warranty_details = &s +} + +// DefaultWarrantyDetails returns the value of the "default_warranty_details" field in the mutation. +func (m *ItemTemplateMutation) DefaultWarrantyDetails() (r string, exists bool) { + v := m.default_warranty_details + if v == nil { + return + } + return *v, true +} + +// OldDefaultWarrantyDetails returns the old "default_warranty_details" field's value of the ItemTemplate entity. +// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemTemplateMutation) OldDefaultWarrantyDetails(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDefaultWarrantyDetails is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDefaultWarrantyDetails requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDefaultWarrantyDetails: %w", err) + } + return oldValue.DefaultWarrantyDetails, nil +} + +// ClearDefaultWarrantyDetails clears the value of the "default_warranty_details" field. +func (m *ItemTemplateMutation) ClearDefaultWarrantyDetails() { + m.default_warranty_details = nil + m.clearedFields[itemtemplate.FieldDefaultWarrantyDetails] = struct{}{} +} + +// DefaultWarrantyDetailsCleared returns if the "default_warranty_details" field was cleared in this mutation. +func (m *ItemTemplateMutation) DefaultWarrantyDetailsCleared() bool { + _, ok := m.clearedFields[itemtemplate.FieldDefaultWarrantyDetails] + return ok +} + +// ResetDefaultWarrantyDetails resets all changes to the "default_warranty_details" field. +func (m *ItemTemplateMutation) ResetDefaultWarrantyDetails() { + m.default_warranty_details = nil + delete(m.clearedFields, itemtemplate.FieldDefaultWarrantyDetails) +} + +// SetIncludeWarrantyFields sets the "include_warranty_fields" field. +func (m *ItemTemplateMutation) SetIncludeWarrantyFields(b bool) { + m.include_warranty_fields = &b +} + +// IncludeWarrantyFields returns the value of the "include_warranty_fields" field in the mutation. +func (m *ItemTemplateMutation) IncludeWarrantyFields() (r bool, exists bool) { + v := m.include_warranty_fields + if v == nil { + return + } + return *v, true +} + +// OldIncludeWarrantyFields returns the old "include_warranty_fields" field's value of the ItemTemplate entity. +// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemTemplateMutation) OldIncludeWarrantyFields(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIncludeWarrantyFields is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIncludeWarrantyFields requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIncludeWarrantyFields: %w", err) + } + return oldValue.IncludeWarrantyFields, nil +} + +// ResetIncludeWarrantyFields resets all changes to the "include_warranty_fields" field. +func (m *ItemTemplateMutation) ResetIncludeWarrantyFields() { + m.include_warranty_fields = nil +} + +// SetIncludePurchaseFields sets the "include_purchase_fields" field. +func (m *ItemTemplateMutation) SetIncludePurchaseFields(b bool) { + m.include_purchase_fields = &b +} + +// IncludePurchaseFields returns the value of the "include_purchase_fields" field in the mutation. +func (m *ItemTemplateMutation) IncludePurchaseFields() (r bool, exists bool) { + v := m.include_purchase_fields + if v == nil { + return + } + return *v, true +} + +// OldIncludePurchaseFields returns the old "include_purchase_fields" field's value of the ItemTemplate entity. +// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemTemplateMutation) OldIncludePurchaseFields(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIncludePurchaseFields is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIncludePurchaseFields requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIncludePurchaseFields: %w", err) + } + return oldValue.IncludePurchaseFields, nil +} + +// ResetIncludePurchaseFields resets all changes to the "include_purchase_fields" field. +func (m *ItemTemplateMutation) ResetIncludePurchaseFields() { + m.include_purchase_fields = nil +} + +// SetIncludeSoldFields sets the "include_sold_fields" field. +func (m *ItemTemplateMutation) SetIncludeSoldFields(b bool) { + m.include_sold_fields = &b +} + +// IncludeSoldFields returns the value of the "include_sold_fields" field in the mutation. +func (m *ItemTemplateMutation) IncludeSoldFields() (r bool, exists bool) { + v := m.include_sold_fields + if v == nil { + return + } + return *v, true +} + +// OldIncludeSoldFields returns the old "include_sold_fields" field's value of the ItemTemplate entity. +// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemTemplateMutation) OldIncludeSoldFields(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIncludeSoldFields is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIncludeSoldFields requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIncludeSoldFields: %w", err) + } + return oldValue.IncludeSoldFields, nil +} + +// ResetIncludeSoldFields resets all changes to the "include_sold_fields" field. +func (m *ItemTemplateMutation) ResetIncludeSoldFields() { + m.include_sold_fields = nil +} + +// SetDefaultLabelIds sets the "default_label_ids" field. +func (m *ItemTemplateMutation) SetDefaultLabelIds(u []uuid.UUID) { + m.default_label_ids = &u + m.appenddefault_label_ids = nil +} + +// DefaultLabelIds returns the value of the "default_label_ids" field in the mutation. +func (m *ItemTemplateMutation) DefaultLabelIds() (r []uuid.UUID, exists bool) { + v := m.default_label_ids + if v == nil { + return + } + return *v, true +} + +// OldDefaultLabelIds returns the old "default_label_ids" field's value of the ItemTemplate entity. +// If the ItemTemplate object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ItemTemplateMutation) OldDefaultLabelIds(ctx context.Context) (v []uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDefaultLabelIds is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDefaultLabelIds requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDefaultLabelIds: %w", err) + } + return oldValue.DefaultLabelIds, nil +} + +// AppendDefaultLabelIds adds u to the "default_label_ids" field. +func (m *ItemTemplateMutation) AppendDefaultLabelIds(u []uuid.UUID) { + m.appenddefault_label_ids = append(m.appenddefault_label_ids, u...) +} + +// AppendedDefaultLabelIds returns the list of values that were appended to the "default_label_ids" field in this mutation. +func (m *ItemTemplateMutation) AppendedDefaultLabelIds() ([]uuid.UUID, bool) { + if len(m.appenddefault_label_ids) == 0 { + return nil, false + } + return m.appenddefault_label_ids, true +} + +// ClearDefaultLabelIds clears the value of the "default_label_ids" field. +func (m *ItemTemplateMutation) ClearDefaultLabelIds() { + m.default_label_ids = nil + m.appenddefault_label_ids = nil + m.clearedFields[itemtemplate.FieldDefaultLabelIds] = struct{}{} +} + +// DefaultLabelIdsCleared returns if the "default_label_ids" field was cleared in this mutation. +func (m *ItemTemplateMutation) DefaultLabelIdsCleared() bool { + _, ok := m.clearedFields[itemtemplate.FieldDefaultLabelIds] + return ok +} + +// ResetDefaultLabelIds resets all changes to the "default_label_ids" field. +func (m *ItemTemplateMutation) ResetDefaultLabelIds() { + m.default_label_ids = nil + m.appenddefault_label_ids = nil + delete(m.clearedFields, itemtemplate.FieldDefaultLabelIds) +} + +// SetGroupID sets the "group" edge to the Group entity by id. +func (m *ItemTemplateMutation) SetGroupID(id uuid.UUID) { + m.group = &id +} + +// ClearGroup clears the "group" edge to the Group entity. +func (m *ItemTemplateMutation) ClearGroup() { + m.clearedgroup = true +} + +// GroupCleared reports if the "group" edge to the Group entity was cleared. +func (m *ItemTemplateMutation) GroupCleared() bool { + return m.clearedgroup +} + +// GroupID returns the "group" edge ID in the mutation. +func (m *ItemTemplateMutation) GroupID() (id uuid.UUID, exists bool) { + if m.group != nil { + return *m.group, true + } + return +} + +// GroupIDs returns the "group" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// GroupID instead. It exists only for internal usage by the builders. +func (m *ItemTemplateMutation) GroupIDs() (ids []uuid.UUID) { + if id := m.group; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetGroup resets all changes to the "group" edge. +func (m *ItemTemplateMutation) ResetGroup() { + m.group = nil + m.clearedgroup = false +} + +// AddFieldIDs adds the "fields" edge to the TemplateField entity by ids. +func (m *ItemTemplateMutation) AddFieldIDs(ids ...uuid.UUID) { + if m.fields == nil { + m.fields = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.fields[ids[i]] = struct{}{} + } +} + +// ClearFields clears the "fields" edge to the TemplateField entity. +func (m *ItemTemplateMutation) ClearFields() { + m.clearedfields = true +} + +// FieldsCleared reports if the "fields" edge to the TemplateField entity was cleared. +func (m *ItemTemplateMutation) FieldsCleared() bool { + return m.clearedfields +} + +// RemoveFieldIDs removes the "fields" edge to the TemplateField entity by IDs. +func (m *ItemTemplateMutation) RemoveFieldIDs(ids ...uuid.UUID) { + if m.removedfields == nil { + m.removedfields = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.fields, ids[i]) + m.removedfields[ids[i]] = struct{}{} + } +} + +// RemovedFields returns the removed IDs of the "fields" edge to the TemplateField entity. +func (m *ItemTemplateMutation) RemovedFieldsIDs() (ids []uuid.UUID) { + for id := range m.removedfields { + ids = append(ids, id) + } + return +} + +// FieldsIDs returns the "fields" edge IDs in the mutation. +func (m *ItemTemplateMutation) FieldsIDs() (ids []uuid.UUID) { + for id := range m.fields { + ids = append(ids, id) + } + return +} + +// ResetFields resets all changes to the "fields" edge. +func (m *ItemTemplateMutation) ResetFields() { + m.fields = nil + m.clearedfields = false + m.removedfields = nil +} + +// SetLocationID sets the "location" edge to the Location entity by id. +func (m *ItemTemplateMutation) SetLocationID(id uuid.UUID) { + m.location = &id +} + +// ClearLocation clears the "location" edge to the Location entity. +func (m *ItemTemplateMutation) ClearLocation() { + m.clearedlocation = true +} + +// LocationCleared reports if the "location" edge to the Location entity was cleared. +func (m *ItemTemplateMutation) LocationCleared() bool { + return m.clearedlocation +} + +// LocationID returns the "location" edge ID in the mutation. +func (m *ItemTemplateMutation) LocationID() (id uuid.UUID, exists bool) { + if m.location != nil { + return *m.location, true + } + return +} + +// LocationIDs returns the "location" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// LocationID instead. It exists only for internal usage by the builders. +func (m *ItemTemplateMutation) LocationIDs() (ids []uuid.UUID) { + if id := m.location; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetLocation resets all changes to the "location" edge. +func (m *ItemTemplateMutation) ResetLocation() { + m.location = nil + m.clearedlocation = false +} + +// Where appends a list predicates to the ItemTemplateMutation builder. +func (m *ItemTemplateMutation) Where(ps ...predicate.ItemTemplate) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ItemTemplateMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ItemTemplateMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ItemTemplate, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ItemTemplateMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ItemTemplateMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (ItemTemplate). +func (m *ItemTemplateMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *ItemTemplateMutation) Fields() []string { + fields := make([]string, 0, 17) + if m.created_at != nil { + fields = append(fields, itemtemplate.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, itemtemplate.FieldUpdatedAt) + } + if m.name != nil { + fields = append(fields, itemtemplate.FieldName) + } + if m.description != nil { + fields = append(fields, itemtemplate.FieldDescription) + } + if m.notes != nil { + fields = append(fields, itemtemplate.FieldNotes) + } + if m.default_quantity != nil { + fields = append(fields, itemtemplate.FieldDefaultQuantity) + } + if m.default_insured != nil { + fields = append(fields, itemtemplate.FieldDefaultInsured) + } + if m.default_name != nil { + fields = append(fields, itemtemplate.FieldDefaultName) + } + if m.default_description != nil { + fields = append(fields, itemtemplate.FieldDefaultDescription) + } + if m.default_manufacturer != nil { + fields = append(fields, itemtemplate.FieldDefaultManufacturer) + } + if m.default_model_number != nil { + fields = append(fields, itemtemplate.FieldDefaultModelNumber) + } + if m.default_lifetime_warranty != nil { + fields = append(fields, itemtemplate.FieldDefaultLifetimeWarranty) + } + if m.default_warranty_details != nil { + fields = append(fields, itemtemplate.FieldDefaultWarrantyDetails) + } + if m.include_warranty_fields != nil { + fields = append(fields, itemtemplate.FieldIncludeWarrantyFields) + } + if m.include_purchase_fields != nil { + fields = append(fields, itemtemplate.FieldIncludePurchaseFields) + } + if m.include_sold_fields != nil { + fields = append(fields, itemtemplate.FieldIncludeSoldFields) + } + if m.default_label_ids != nil { + fields = append(fields, itemtemplate.FieldDefaultLabelIds) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *ItemTemplateMutation) Field(name string) (ent.Value, bool) { + switch name { + case itemtemplate.FieldCreatedAt: + return m.CreatedAt() + case itemtemplate.FieldUpdatedAt: + return m.UpdatedAt() + case itemtemplate.FieldName: + return m.Name() + case itemtemplate.FieldDescription: + return m.Description() + case itemtemplate.FieldNotes: + return m.Notes() + case itemtemplate.FieldDefaultQuantity: + return m.DefaultQuantity() + case itemtemplate.FieldDefaultInsured: + return m.DefaultInsured() + case itemtemplate.FieldDefaultName: + return m.DefaultName() + case itemtemplate.FieldDefaultDescription: + return m.DefaultDescription() + case itemtemplate.FieldDefaultManufacturer: + return m.DefaultManufacturer() + case itemtemplate.FieldDefaultModelNumber: + return m.DefaultModelNumber() + case itemtemplate.FieldDefaultLifetimeWarranty: + return m.DefaultLifetimeWarranty() + case itemtemplate.FieldDefaultWarrantyDetails: + return m.DefaultWarrantyDetails() + case itemtemplate.FieldIncludeWarrantyFields: + return m.IncludeWarrantyFields() + case itemtemplate.FieldIncludePurchaseFields: + return m.IncludePurchaseFields() + case itemtemplate.FieldIncludeSoldFields: + return m.IncludeSoldFields() + case itemtemplate.FieldDefaultLabelIds: + return m.DefaultLabelIds() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *ItemTemplateMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case itemtemplate.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case itemtemplate.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case itemtemplate.FieldName: + return m.OldName(ctx) + case itemtemplate.FieldDescription: + return m.OldDescription(ctx) + case itemtemplate.FieldNotes: + return m.OldNotes(ctx) + case itemtemplate.FieldDefaultQuantity: + return m.OldDefaultQuantity(ctx) + case itemtemplate.FieldDefaultInsured: + return m.OldDefaultInsured(ctx) + case itemtemplate.FieldDefaultName: + return m.OldDefaultName(ctx) + case itemtemplate.FieldDefaultDescription: + return m.OldDefaultDescription(ctx) + case itemtemplate.FieldDefaultManufacturer: + return m.OldDefaultManufacturer(ctx) + case itemtemplate.FieldDefaultModelNumber: + return m.OldDefaultModelNumber(ctx) + case itemtemplate.FieldDefaultLifetimeWarranty: + return m.OldDefaultLifetimeWarranty(ctx) + case itemtemplate.FieldDefaultWarrantyDetails: + return m.OldDefaultWarrantyDetails(ctx) + case itemtemplate.FieldIncludeWarrantyFields: + return m.OldIncludeWarrantyFields(ctx) + case itemtemplate.FieldIncludePurchaseFields: + return m.OldIncludePurchaseFields(ctx) + case itemtemplate.FieldIncludeSoldFields: + return m.OldIncludeSoldFields(ctx) + case itemtemplate.FieldDefaultLabelIds: + return m.OldDefaultLabelIds(ctx) + } + return nil, fmt.Errorf("unknown ItemTemplate field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ItemTemplateMutation) SetField(name string, value ent.Value) error { + switch name { + case itemtemplate.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case itemtemplate.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case itemtemplate.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case itemtemplate.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case itemtemplate.FieldNotes: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNotes(v) + return nil + case itemtemplate.FieldDefaultQuantity: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDefaultQuantity(v) + return nil + case itemtemplate.FieldDefaultInsured: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDefaultInsured(v) + return nil + case itemtemplate.FieldDefaultName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDefaultName(v) + return nil + case itemtemplate.FieldDefaultDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDefaultDescription(v) + return nil + case itemtemplate.FieldDefaultManufacturer: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDefaultManufacturer(v) + return nil + case itemtemplate.FieldDefaultModelNumber: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDefaultModelNumber(v) + return nil + case itemtemplate.FieldDefaultLifetimeWarranty: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDefaultLifetimeWarranty(v) + return nil + case itemtemplate.FieldDefaultWarrantyDetails: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDefaultWarrantyDetails(v) + return nil + case itemtemplate.FieldIncludeWarrantyFields: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIncludeWarrantyFields(v) + return nil + case itemtemplate.FieldIncludePurchaseFields: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIncludePurchaseFields(v) + return nil + case itemtemplate.FieldIncludeSoldFields: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIncludeSoldFields(v) + return nil + case itemtemplate.FieldDefaultLabelIds: + v, ok := value.([]uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDefaultLabelIds(v) + return nil + } + return fmt.Errorf("unknown ItemTemplate field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ItemTemplateMutation) AddedFields() []string { + var fields []string + if m.adddefault_quantity != nil { + fields = append(fields, itemtemplate.FieldDefaultQuantity) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *ItemTemplateMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case itemtemplate.FieldDefaultQuantity: + return m.AddedDefaultQuantity() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ItemTemplateMutation) AddField(name string, value ent.Value) error { + switch name { + case itemtemplate.FieldDefaultQuantity: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddDefaultQuantity(v) + return nil + } + return fmt.Errorf("unknown ItemTemplate numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ItemTemplateMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(itemtemplate.FieldDescription) { + fields = append(fields, itemtemplate.FieldDescription) + } + if m.FieldCleared(itemtemplate.FieldNotes) { + fields = append(fields, itemtemplate.FieldNotes) + } + if m.FieldCleared(itemtemplate.FieldDefaultName) { + fields = append(fields, itemtemplate.FieldDefaultName) + } + if m.FieldCleared(itemtemplate.FieldDefaultDescription) { + fields = append(fields, itemtemplate.FieldDefaultDescription) + } + if m.FieldCleared(itemtemplate.FieldDefaultManufacturer) { + fields = append(fields, itemtemplate.FieldDefaultManufacturer) + } + if m.FieldCleared(itemtemplate.FieldDefaultModelNumber) { + fields = append(fields, itemtemplate.FieldDefaultModelNumber) + } + if m.FieldCleared(itemtemplate.FieldDefaultWarrantyDetails) { + fields = append(fields, itemtemplate.FieldDefaultWarrantyDetails) + } + if m.FieldCleared(itemtemplate.FieldDefaultLabelIds) { + fields = append(fields, itemtemplate.FieldDefaultLabelIds) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ItemTemplateMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *ItemTemplateMutation) ClearField(name string) error { + switch name { + case itemtemplate.FieldDescription: + m.ClearDescription() + return nil + case itemtemplate.FieldNotes: + m.ClearNotes() + return nil + case itemtemplate.FieldDefaultName: + m.ClearDefaultName() + return nil + case itemtemplate.FieldDefaultDescription: + m.ClearDefaultDescription() + return nil + case itemtemplate.FieldDefaultManufacturer: + m.ClearDefaultManufacturer() + return nil + case itemtemplate.FieldDefaultModelNumber: + m.ClearDefaultModelNumber() + return nil + case itemtemplate.FieldDefaultWarrantyDetails: + m.ClearDefaultWarrantyDetails() + return nil + case itemtemplate.FieldDefaultLabelIds: + m.ClearDefaultLabelIds() + return nil + } + return fmt.Errorf("unknown ItemTemplate nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *ItemTemplateMutation) ResetField(name string) error { + switch name { + case itemtemplate.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case itemtemplate.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case itemtemplate.FieldName: + m.ResetName() + return nil + case itemtemplate.FieldDescription: + m.ResetDescription() + return nil + case itemtemplate.FieldNotes: + m.ResetNotes() + return nil + case itemtemplate.FieldDefaultQuantity: + m.ResetDefaultQuantity() + return nil + case itemtemplate.FieldDefaultInsured: + m.ResetDefaultInsured() + return nil + case itemtemplate.FieldDefaultName: + m.ResetDefaultName() + return nil + case itemtemplate.FieldDefaultDescription: + m.ResetDefaultDescription() + return nil + case itemtemplate.FieldDefaultManufacturer: + m.ResetDefaultManufacturer() + return nil + case itemtemplate.FieldDefaultModelNumber: + m.ResetDefaultModelNumber() + return nil + case itemtemplate.FieldDefaultLifetimeWarranty: + m.ResetDefaultLifetimeWarranty() + return nil + case itemtemplate.FieldDefaultWarrantyDetails: + m.ResetDefaultWarrantyDetails() + return nil + case itemtemplate.FieldIncludeWarrantyFields: + m.ResetIncludeWarrantyFields() + return nil + case itemtemplate.FieldIncludePurchaseFields: + m.ResetIncludePurchaseFields() + return nil + case itemtemplate.FieldIncludeSoldFields: + m.ResetIncludeSoldFields() + return nil + case itemtemplate.FieldDefaultLabelIds: + m.ResetDefaultLabelIds() + return nil + } + return fmt.Errorf("unknown ItemTemplate field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ItemTemplateMutation) AddedEdges() []string { + edges := make([]string, 0, 3) + if m.group != nil { + edges = append(edges, itemtemplate.EdgeGroup) + } + if m.fields != nil { + edges = append(edges, itemtemplate.EdgeFields) + } + if m.location != nil { + edges = append(edges, itemtemplate.EdgeLocation) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ItemTemplateMutation) AddedIDs(name string) []ent.Value { + switch name { + case itemtemplate.EdgeGroup: + if id := m.group; id != nil { + return []ent.Value{*id} + } + case itemtemplate.EdgeFields: + ids := make([]ent.Value, 0, len(m.fields)) + for id := range m.fields { + ids = append(ids, id) + } + return ids + case itemtemplate.EdgeLocation: + if id := m.location; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ItemTemplateMutation) RemovedEdges() []string { + edges := make([]string, 0, 3) + if m.removedfields != nil { + edges = append(edges, itemtemplate.EdgeFields) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ItemTemplateMutation) RemovedIDs(name string) []ent.Value { + switch name { + case itemtemplate.EdgeFields: + ids := make([]ent.Value, 0, len(m.removedfields)) + for id := range m.removedfields { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ItemTemplateMutation) ClearedEdges() []string { + edges := make([]string, 0, 3) + if m.clearedgroup { + edges = append(edges, itemtemplate.EdgeGroup) + } + if m.clearedfields { + edges = append(edges, itemtemplate.EdgeFields) + } + if m.clearedlocation { + edges = append(edges, itemtemplate.EdgeLocation) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ItemTemplateMutation) EdgeCleared(name string) bool { + switch name { + case itemtemplate.EdgeGroup: + return m.clearedgroup + case itemtemplate.EdgeFields: + return m.clearedfields + case itemtemplate.EdgeLocation: + return m.clearedlocation + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *ItemTemplateMutation) ClearEdge(name string) error { + switch name { + case itemtemplate.EdgeGroup: + m.ClearGroup() + return nil + case itemtemplate.EdgeLocation: + m.ClearLocation() + return nil + } + return fmt.Errorf("unknown ItemTemplate unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *ItemTemplateMutation) ResetEdge(name string) error { + switch name { + case itemtemplate.EdgeGroup: + m.ResetGroup() + return nil + case itemtemplate.EdgeFields: + m.ResetFields() + return nil + case itemtemplate.EdgeLocation: + m.ResetLocation() + return nil + } + return fmt.Errorf("unknown ItemTemplate edge %s", name) +} + +// LabelMutation represents an operation that mutates the Label nodes in the graph. +type LabelMutation struct { + config + op Op + typ string + id *uuid.UUID + created_at *time.Time + updated_at *time.Time + name *string + description *string + color *string + clearedFields map[string]struct{} + group *uuid.UUID + clearedgroup bool + items map[uuid.UUID]struct{} + removeditems map[uuid.UUID]struct{} + cleareditems bool + done bool + oldValue func(context.Context) (*Label, error) + predicates []predicate.Label } var _ ent.Mutation = (*LabelMutation)(nil) @@ -8368,58 +9060,58 @@ func (m *LabelMutation) ResetGroup() { m.clearedgroup = false } -// AddEntityIDs adds the "entities" edge to the Entity entity by ids. -func (m *LabelMutation) AddEntityIDs(ids ...uuid.UUID) { - if m.entities == nil { - m.entities = make(map[uuid.UUID]struct{}) +// AddItemIDs adds the "items" edge to the Item entity by ids. +func (m *LabelMutation) AddItemIDs(ids ...uuid.UUID) { + if m.items == nil { + m.items = make(map[uuid.UUID]struct{}) } for i := range ids { - m.entities[ids[i]] = struct{}{} + m.items[ids[i]] = struct{}{} } } -// ClearEntities clears the "entities" edge to the Entity entity. -func (m *LabelMutation) ClearEntities() { - m.clearedentities = true +// ClearItems clears the "items" edge to the Item entity. +func (m *LabelMutation) ClearItems() { + m.cleareditems = true } -// EntitiesCleared reports if the "entities" edge to the Entity entity was cleared. -func (m *LabelMutation) EntitiesCleared() bool { - return m.clearedentities +// ItemsCleared reports if the "items" edge to the Item entity was cleared. +func (m *LabelMutation) ItemsCleared() bool { + return m.cleareditems } -// RemoveEntityIDs removes the "entities" edge to the Entity entity by IDs. -func (m *LabelMutation) RemoveEntityIDs(ids ...uuid.UUID) { - if m.removedentities == nil { - m.removedentities = make(map[uuid.UUID]struct{}) +// RemoveItemIDs removes the "items" edge to the Item entity by IDs. +func (m *LabelMutation) RemoveItemIDs(ids ...uuid.UUID) { + if m.removeditems == nil { + m.removeditems = make(map[uuid.UUID]struct{}) } for i := range ids { - delete(m.entities, ids[i]) - m.removedentities[ids[i]] = struct{}{} + delete(m.items, ids[i]) + m.removeditems[ids[i]] = struct{}{} } } -// RemovedEntities returns the removed IDs of the "entities" edge to the Entity entity. -func (m *LabelMutation) RemovedEntitiesIDs() (ids []uuid.UUID) { - for id := range m.removedentities { +// RemovedItems returns the removed IDs of the "items" edge to the Item entity. +func (m *LabelMutation) RemovedItemsIDs() (ids []uuid.UUID) { + for id := range m.removeditems { ids = append(ids, id) } return } -// EntitiesIDs returns the "entities" edge IDs in the mutation. -func (m *LabelMutation) EntitiesIDs() (ids []uuid.UUID) { - for id := range m.entities { +// ItemsIDs returns the "items" edge IDs in the mutation. +func (m *LabelMutation) ItemsIDs() (ids []uuid.UUID) { + for id := range m.items { ids = append(ids, id) } return } -// ResetEntities resets all changes to the "entities" edge. -func (m *LabelMutation) ResetEntities() { - m.entities = nil - m.clearedentities = false - m.removedentities = nil +// ResetItems resets all changes to the "items" edge. +func (m *LabelMutation) ResetItems() { + m.items = nil + m.cleareditems = false + m.removeditems = nil } // Where appends a list predicates to the LabelMutation builder. @@ -8642,8 +9334,8 @@ func (m *LabelMutation) AddedEdges() []string { if m.group != nil { edges = append(edges, label.EdgeGroup) } - if m.entities != nil { - edges = append(edges, label.EdgeEntities) + if m.items != nil { + edges = append(edges, label.EdgeItems) } return edges } @@ -8656,9 +9348,9 @@ func (m *LabelMutation) AddedIDs(name string) []ent.Value { if id := m.group; id != nil { return []ent.Value{*id} } - case label.EdgeEntities: - ids := make([]ent.Value, 0, len(m.entities)) - for id := range m.entities { + case label.EdgeItems: + ids := make([]ent.Value, 0, len(m.items)) + for id := range m.items { ids = append(ids, id) } return ids @@ -8669,8 +9361,8 @@ func (m *LabelMutation) AddedIDs(name string) []ent.Value { // RemovedEdges returns all edge names that were removed in this mutation. func (m *LabelMutation) RemovedEdges() []string { edges := make([]string, 0, 2) - if m.removedentities != nil { - edges = append(edges, label.EdgeEntities) + if m.removeditems != nil { + edges = append(edges, label.EdgeItems) } return edges } @@ -8679,9 +9371,9 @@ func (m *LabelMutation) RemovedEdges() []string { // the given name in this mutation. func (m *LabelMutation) RemovedIDs(name string) []ent.Value { switch name { - case label.EdgeEntities: - ids := make([]ent.Value, 0, len(m.removedentities)) - for id := range m.removedentities { + case label.EdgeItems: + ids := make([]ent.Value, 0, len(m.removeditems)) + for id := range m.removeditems { ids = append(ids, id) } return ids @@ -8695,8 +9387,8 @@ func (m *LabelMutation) ClearedEdges() []string { if m.clearedgroup { edges = append(edges, label.EdgeGroup) } - if m.clearedentities { - edges = append(edges, label.EdgeEntities) + if m.cleareditems { + edges = append(edges, label.EdgeItems) } return edges } @@ -8707,8 +9399,8 @@ func (m *LabelMutation) EdgeCleared(name string) bool { switch name { case label.EdgeGroup: return m.clearedgroup - case label.EdgeEntities: - return m.clearedentities + case label.EdgeItems: + return m.cleareditems } return false } @@ -8731,13 +9423,823 @@ func (m *LabelMutation) ResetEdge(name string) error { case label.EdgeGroup: m.ResetGroup() return nil - case label.EdgeEntities: - m.ResetEntities() + case label.EdgeItems: + m.ResetItems() return nil } return fmt.Errorf("unknown Label edge %s", name) } +// LocationMutation represents an operation that mutates the Location nodes in the graph. +type LocationMutation struct { + config + op Op + typ string + id *uuid.UUID + created_at *time.Time + updated_at *time.Time + name *string + description *string + clearedFields map[string]struct{} + group *uuid.UUID + clearedgroup bool + parent *uuid.UUID + clearedparent bool + children map[uuid.UUID]struct{} + removedchildren map[uuid.UUID]struct{} + clearedchildren bool + items map[uuid.UUID]struct{} + removeditems map[uuid.UUID]struct{} + cleareditems bool + done bool + oldValue func(context.Context) (*Location, error) + predicates []predicate.Location +} + +var _ ent.Mutation = (*LocationMutation)(nil) + +// locationOption allows management of the mutation configuration using functional options. +type locationOption func(*LocationMutation) + +// newLocationMutation creates new mutation for the Location entity. +func newLocationMutation(c config, op Op, opts ...locationOption) *LocationMutation { + m := &LocationMutation{ + config: c, + op: op, + typ: TypeLocation, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withLocationID sets the ID field of the mutation. +func withLocationID(id uuid.UUID) locationOption { + return func(m *LocationMutation) { + var ( + err error + once sync.Once + value *Location + ) + m.oldValue = func(ctx context.Context) (*Location, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Location.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withLocation sets the old Location of the mutation. +func withLocation(node *Location) locationOption { + return func(m *LocationMutation) { + m.oldValue = func(context.Context) (*Location, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m LocationMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m LocationMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Location entities. +func (m *LocationMutation) SetID(id uuid.UUID) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *LocationMutation) ID() (id uuid.UUID, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *LocationMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uuid.UUID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Location.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *LocationMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *LocationMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the Location entity. +// If the Location object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *LocationMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *LocationMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *LocationMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *LocationMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the Location entity. +// If the Location object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *LocationMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *LocationMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetName sets the "name" field. +func (m *LocationMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *LocationMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the Location entity. +// If the Location object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *LocationMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *LocationMutation) ResetName() { + m.name = nil +} + +// SetDescription sets the "description" field. +func (m *LocationMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *LocationMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the Location entity. +// If the Location object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *LocationMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ClearDescription clears the value of the "description" field. +func (m *LocationMutation) ClearDescription() { + m.description = nil + m.clearedFields[location.FieldDescription] = struct{}{} +} + +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *LocationMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[location.FieldDescription] + return ok +} + +// ResetDescription resets all changes to the "description" field. +func (m *LocationMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, location.FieldDescription) +} + +// SetGroupID sets the "group" edge to the Group entity by id. +func (m *LocationMutation) SetGroupID(id uuid.UUID) { + m.group = &id +} + +// ClearGroup clears the "group" edge to the Group entity. +func (m *LocationMutation) ClearGroup() { + m.clearedgroup = true +} + +// GroupCleared reports if the "group" edge to the Group entity was cleared. +func (m *LocationMutation) GroupCleared() bool { + return m.clearedgroup +} + +// GroupID returns the "group" edge ID in the mutation. +func (m *LocationMutation) GroupID() (id uuid.UUID, exists bool) { + if m.group != nil { + return *m.group, true + } + return +} + +// GroupIDs returns the "group" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// GroupID instead. It exists only for internal usage by the builders. +func (m *LocationMutation) GroupIDs() (ids []uuid.UUID) { + if id := m.group; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetGroup resets all changes to the "group" edge. +func (m *LocationMutation) ResetGroup() { + m.group = nil + m.clearedgroup = false +} + +// SetParentID sets the "parent" edge to the Location entity by id. +func (m *LocationMutation) SetParentID(id uuid.UUID) { + m.parent = &id +} + +// ClearParent clears the "parent" edge to the Location entity. +func (m *LocationMutation) ClearParent() { + m.clearedparent = true +} + +// ParentCleared reports if the "parent" edge to the Location entity was cleared. +func (m *LocationMutation) ParentCleared() bool { + return m.clearedparent +} + +// ParentID returns the "parent" edge ID in the mutation. +func (m *LocationMutation) ParentID() (id uuid.UUID, exists bool) { + if m.parent != nil { + return *m.parent, true + } + return +} + +// ParentIDs returns the "parent" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ParentID instead. It exists only for internal usage by the builders. +func (m *LocationMutation) ParentIDs() (ids []uuid.UUID) { + if id := m.parent; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetParent resets all changes to the "parent" edge. +func (m *LocationMutation) ResetParent() { + m.parent = nil + m.clearedparent = false +} + +// AddChildIDs adds the "children" edge to the Location entity by ids. +func (m *LocationMutation) AddChildIDs(ids ...uuid.UUID) { + if m.children == nil { + m.children = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.children[ids[i]] = struct{}{} + } +} + +// ClearChildren clears the "children" edge to the Location entity. +func (m *LocationMutation) ClearChildren() { + m.clearedchildren = true +} + +// ChildrenCleared reports if the "children" edge to the Location entity was cleared. +func (m *LocationMutation) ChildrenCleared() bool { + return m.clearedchildren +} + +// RemoveChildIDs removes the "children" edge to the Location entity by IDs. +func (m *LocationMutation) RemoveChildIDs(ids ...uuid.UUID) { + if m.removedchildren == nil { + m.removedchildren = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.children, ids[i]) + m.removedchildren[ids[i]] = struct{}{} + } +} + +// RemovedChildren returns the removed IDs of the "children" edge to the Location entity. +func (m *LocationMutation) RemovedChildrenIDs() (ids []uuid.UUID) { + for id := range m.removedchildren { + ids = append(ids, id) + } + return +} + +// ChildrenIDs returns the "children" edge IDs in the mutation. +func (m *LocationMutation) ChildrenIDs() (ids []uuid.UUID) { + for id := range m.children { + ids = append(ids, id) + } + return +} + +// ResetChildren resets all changes to the "children" edge. +func (m *LocationMutation) ResetChildren() { + m.children = nil + m.clearedchildren = false + m.removedchildren = nil +} + +// AddItemIDs adds the "items" edge to the Item entity by ids. +func (m *LocationMutation) AddItemIDs(ids ...uuid.UUID) { + if m.items == nil { + m.items = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.items[ids[i]] = struct{}{} + } +} + +// ClearItems clears the "items" edge to the Item entity. +func (m *LocationMutation) ClearItems() { + m.cleareditems = true +} + +// ItemsCleared reports if the "items" edge to the Item entity was cleared. +func (m *LocationMutation) ItemsCleared() bool { + return m.cleareditems +} + +// RemoveItemIDs removes the "items" edge to the Item entity by IDs. +func (m *LocationMutation) RemoveItemIDs(ids ...uuid.UUID) { + if m.removeditems == nil { + m.removeditems = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.items, ids[i]) + m.removeditems[ids[i]] = struct{}{} + } +} + +// RemovedItems returns the removed IDs of the "items" edge to the Item entity. +func (m *LocationMutation) RemovedItemsIDs() (ids []uuid.UUID) { + for id := range m.removeditems { + ids = append(ids, id) + } + return +} + +// ItemsIDs returns the "items" edge IDs in the mutation. +func (m *LocationMutation) ItemsIDs() (ids []uuid.UUID) { + for id := range m.items { + ids = append(ids, id) + } + return +} + +// ResetItems resets all changes to the "items" edge. +func (m *LocationMutation) ResetItems() { + m.items = nil + m.cleareditems = false + m.removeditems = nil +} + +// Where appends a list predicates to the LocationMutation builder. +func (m *LocationMutation) Where(ps ...predicate.Location) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the LocationMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *LocationMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Location, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *LocationMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *LocationMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Location). +func (m *LocationMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *LocationMutation) Fields() []string { + fields := make([]string, 0, 4) + if m.created_at != nil { + fields = append(fields, location.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, location.FieldUpdatedAt) + } + if m.name != nil { + fields = append(fields, location.FieldName) + } + if m.description != nil { + fields = append(fields, location.FieldDescription) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *LocationMutation) Field(name string) (ent.Value, bool) { + switch name { + case location.FieldCreatedAt: + return m.CreatedAt() + case location.FieldUpdatedAt: + return m.UpdatedAt() + case location.FieldName: + return m.Name() + case location.FieldDescription: + return m.Description() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *LocationMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case location.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case location.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case location.FieldName: + return m.OldName(ctx) + case location.FieldDescription: + return m.OldDescription(ctx) + } + return nil, fmt.Errorf("unknown Location field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *LocationMutation) SetField(name string, value ent.Value) error { + switch name { + case location.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case location.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case location.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case location.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + } + return fmt.Errorf("unknown Location field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *LocationMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *LocationMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *LocationMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Location numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *LocationMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(location.FieldDescription) { + fields = append(fields, location.FieldDescription) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *LocationMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *LocationMutation) ClearField(name string) error { + switch name { + case location.FieldDescription: + m.ClearDescription() + return nil + } + return fmt.Errorf("unknown Location nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *LocationMutation) ResetField(name string) error { + switch name { + case location.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case location.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case location.FieldName: + m.ResetName() + return nil + case location.FieldDescription: + m.ResetDescription() + return nil + } + return fmt.Errorf("unknown Location field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *LocationMutation) AddedEdges() []string { + edges := make([]string, 0, 4) + if m.group != nil { + edges = append(edges, location.EdgeGroup) + } + if m.parent != nil { + edges = append(edges, location.EdgeParent) + } + if m.children != nil { + edges = append(edges, location.EdgeChildren) + } + if m.items != nil { + edges = append(edges, location.EdgeItems) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *LocationMutation) AddedIDs(name string) []ent.Value { + switch name { + case location.EdgeGroup: + if id := m.group; id != nil { + return []ent.Value{*id} + } + case location.EdgeParent: + if id := m.parent; id != nil { + return []ent.Value{*id} + } + case location.EdgeChildren: + ids := make([]ent.Value, 0, len(m.children)) + for id := range m.children { + ids = append(ids, id) + } + return ids + case location.EdgeItems: + ids := make([]ent.Value, 0, len(m.items)) + for id := range m.items { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *LocationMutation) RemovedEdges() []string { + edges := make([]string, 0, 4) + if m.removedchildren != nil { + edges = append(edges, location.EdgeChildren) + } + if m.removeditems != nil { + edges = append(edges, location.EdgeItems) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *LocationMutation) RemovedIDs(name string) []ent.Value { + switch name { + case location.EdgeChildren: + ids := make([]ent.Value, 0, len(m.removedchildren)) + for id := range m.removedchildren { + ids = append(ids, id) + } + return ids + case location.EdgeItems: + ids := make([]ent.Value, 0, len(m.removeditems)) + for id := range m.removeditems { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *LocationMutation) ClearedEdges() []string { + edges := make([]string, 0, 4) + if m.clearedgroup { + edges = append(edges, location.EdgeGroup) + } + if m.clearedparent { + edges = append(edges, location.EdgeParent) + } + if m.clearedchildren { + edges = append(edges, location.EdgeChildren) + } + if m.cleareditems { + edges = append(edges, location.EdgeItems) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *LocationMutation) EdgeCleared(name string) bool { + switch name { + case location.EdgeGroup: + return m.clearedgroup + case location.EdgeParent: + return m.clearedparent + case location.EdgeChildren: + return m.clearedchildren + case location.EdgeItems: + return m.cleareditems + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *LocationMutation) ClearEdge(name string) error { + switch name { + case location.EdgeGroup: + m.ClearGroup() + return nil + case location.EdgeParent: + m.ClearParent() + return nil + } + return fmt.Errorf("unknown Location unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *LocationMutation) ResetEdge(name string) error { + switch name { + case location.EdgeGroup: + m.ResetGroup() + return nil + case location.EdgeParent: + m.ResetParent() + return nil + case location.EdgeChildren: + m.ResetChildren() + return nil + case location.EdgeItems: + m.ResetItems() + return nil + } + return fmt.Errorf("unknown Location edge %s", name) +} + // MaintenanceEntryMutation represents an operation that mutates the MaintenanceEntry nodes in the graph. type MaintenanceEntryMutation struct { config @@ -8753,8 +10255,8 @@ type MaintenanceEntryMutation struct { cost *float64 addcost *float64 clearedFields map[string]struct{} - entity *uuid.UUID - clearedentity bool + item *uuid.UUID + cleareditem bool done bool oldValue func(context.Context) (*MaintenanceEntry, error) predicates []predicate.MaintenanceEntry @@ -8936,40 +10438,40 @@ func (m *MaintenanceEntryMutation) ResetUpdatedAt() { m.updated_at = nil } -// SetEntityID sets the "entity_id" field. -func (m *MaintenanceEntryMutation) SetEntityID(u uuid.UUID) { - m.entity = &u +// SetItemID sets the "item_id" field. +func (m *MaintenanceEntryMutation) SetItemID(u uuid.UUID) { + m.item = &u } -// EntityID returns the value of the "entity_id" field in the mutation. -func (m *MaintenanceEntryMutation) EntityID() (r uuid.UUID, exists bool) { - v := m.entity +// ItemID returns the value of the "item_id" field in the mutation. +func (m *MaintenanceEntryMutation) ItemID() (r uuid.UUID, exists bool) { + v := m.item if v == nil { return } return *v, true } -// OldEntityID returns the old "entity_id" field's value of the MaintenanceEntry entity. +// OldItemID returns the old "item_id" field's value of the MaintenanceEntry entity. // If the MaintenanceEntry object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MaintenanceEntryMutation) OldEntityID(ctx context.Context) (v uuid.UUID, err error) { +func (m *MaintenanceEntryMutation) OldItemID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEntityID is only allowed on UpdateOne operations") + return v, errors.New("OldItemID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEntityID requires an ID field in the mutation") + return v, errors.New("OldItemID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldEntityID: %w", err) + return v, fmt.Errorf("querying old value for OldItemID: %w", err) } - return oldValue.EntityID, nil + return oldValue.ItemID, nil } -// ResetEntityID resets all changes to the "entity_id" field. -func (m *MaintenanceEntryMutation) ResetEntityID() { - m.entity = nil +// ResetItemID resets all changes to the "item_id" field. +func (m *MaintenanceEntryMutation) ResetItemID() { + m.item = nil } // SetDate sets the "date" field. @@ -9211,31 +10713,31 @@ func (m *MaintenanceEntryMutation) ResetCost() { m.addcost = nil } -// ClearEntity clears the "entity" edge to the Entity entity. -func (m *MaintenanceEntryMutation) ClearEntity() { - m.clearedentity = true - m.clearedFields[maintenanceentry.FieldEntityID] = struct{}{} +// ClearItem clears the "item" edge to the Item entity. +func (m *MaintenanceEntryMutation) ClearItem() { + m.cleareditem = true + m.clearedFields[maintenanceentry.FieldItemID] = struct{}{} } -// EntityCleared reports if the "entity" edge to the Entity entity was cleared. -func (m *MaintenanceEntryMutation) EntityCleared() bool { - return m.clearedentity +// ItemCleared reports if the "item" edge to the Item entity was cleared. +func (m *MaintenanceEntryMutation) ItemCleared() bool { + return m.cleareditem } -// EntityIDs returns the "entity" edge IDs in the mutation. +// ItemIDs returns the "item" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// EntityID instead. It exists only for internal usage by the builders. -func (m *MaintenanceEntryMutation) EntityIDs() (ids []uuid.UUID) { - if id := m.entity; id != nil { +// ItemID instead. It exists only for internal usage by the builders. +func (m *MaintenanceEntryMutation) ItemIDs() (ids []uuid.UUID) { + if id := m.item; id != nil { ids = append(ids, *id) } return } -// ResetEntity resets all changes to the "entity" edge. -func (m *MaintenanceEntryMutation) ResetEntity() { - m.entity = nil - m.clearedentity = false +// ResetItem resets all changes to the "item" edge. +func (m *MaintenanceEntryMutation) ResetItem() { + m.item = nil + m.cleareditem = false } // Where appends a list predicates to the MaintenanceEntryMutation builder. @@ -9279,8 +10781,8 @@ func (m *MaintenanceEntryMutation) Fields() []string { if m.updated_at != nil { fields = append(fields, maintenanceentry.FieldUpdatedAt) } - if m.entity != nil { - fields = append(fields, maintenanceentry.FieldEntityID) + if m.item != nil { + fields = append(fields, maintenanceentry.FieldItemID) } if m.date != nil { fields = append(fields, maintenanceentry.FieldDate) @@ -9309,8 +10811,8 @@ func (m *MaintenanceEntryMutation) Field(name string) (ent.Value, bool) { return m.CreatedAt() case maintenanceentry.FieldUpdatedAt: return m.UpdatedAt() - case maintenanceentry.FieldEntityID: - return m.EntityID() + case maintenanceentry.FieldItemID: + return m.ItemID() case maintenanceentry.FieldDate: return m.Date() case maintenanceentry.FieldScheduledDate: @@ -9334,8 +10836,8 @@ func (m *MaintenanceEntryMutation) OldField(ctx context.Context, name string) (e return m.OldCreatedAt(ctx) case maintenanceentry.FieldUpdatedAt: return m.OldUpdatedAt(ctx) - case maintenanceentry.FieldEntityID: - return m.OldEntityID(ctx) + case maintenanceentry.FieldItemID: + return m.OldItemID(ctx) case maintenanceentry.FieldDate: return m.OldDate(ctx) case maintenanceentry.FieldScheduledDate: @@ -9369,12 +10871,12 @@ func (m *MaintenanceEntryMutation) SetField(name string, value ent.Value) error } m.SetUpdatedAt(v) return nil - case maintenanceentry.FieldEntityID: + case maintenanceentry.FieldItemID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetEntityID(v) + m.SetItemID(v) return nil case maintenanceentry.FieldDate: v, ok := value.(time.Time) @@ -9502,8 +11004,8 @@ func (m *MaintenanceEntryMutation) ResetField(name string) error { case maintenanceentry.FieldUpdatedAt: m.ResetUpdatedAt() return nil - case maintenanceentry.FieldEntityID: - m.ResetEntityID() + case maintenanceentry.FieldItemID: + m.ResetItemID() return nil case maintenanceentry.FieldDate: m.ResetDate() @@ -9527,8 +11029,8 @@ func (m *MaintenanceEntryMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *MaintenanceEntryMutation) AddedEdges() []string { edges := make([]string, 0, 1) - if m.entity != nil { - edges = append(edges, maintenanceentry.EdgeEntity) + if m.item != nil { + edges = append(edges, maintenanceentry.EdgeItem) } return edges } @@ -9537,8 +11039,8 @@ func (m *MaintenanceEntryMutation) AddedEdges() []string { // name in this mutation. func (m *MaintenanceEntryMutation) AddedIDs(name string) []ent.Value { switch name { - case maintenanceentry.EdgeEntity: - if id := m.entity; id != nil { + case maintenanceentry.EdgeItem: + if id := m.item; id != nil { return []ent.Value{*id} } } @@ -9560,8 +11062,8 @@ func (m *MaintenanceEntryMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *MaintenanceEntryMutation) ClearedEdges() []string { edges := make([]string, 0, 1) - if m.clearedentity { - edges = append(edges, maintenanceentry.EdgeEntity) + if m.cleareditem { + edges = append(edges, maintenanceentry.EdgeItem) } return edges } @@ -9570,8 +11072,8 @@ func (m *MaintenanceEntryMutation) ClearedEdges() []string { // was cleared in this mutation. func (m *MaintenanceEntryMutation) EdgeCleared(name string) bool { switch name { - case maintenanceentry.EdgeEntity: - return m.clearedentity + case maintenanceentry.EdgeItem: + return m.cleareditem } return false } @@ -9580,8 +11082,8 @@ func (m *MaintenanceEntryMutation) EdgeCleared(name string) bool { // if that edge is not defined in the schema. func (m *MaintenanceEntryMutation) ClearEdge(name string) error { switch name { - case maintenanceentry.EdgeEntity: - m.ClearEntity() + case maintenanceentry.EdgeItem: + m.ClearItem() return nil } return fmt.Errorf("unknown MaintenanceEntry unique edge %s", name) @@ -9591,8 +11093,8 @@ func (m *MaintenanceEntryMutation) ClearEdge(name string) error { // It returns an error if the edge is not defined in the schema. func (m *MaintenanceEntryMutation) ResetEdge(name string) error { switch name { - case maintenanceentry.EdgeEntity: - m.ResetEntity() + case maintenanceentry.EdgeItem: + m.ResetItem() return nil } return fmt.Errorf("unknown MaintenanceEntry edge %s", name) @@ -10354,6 +11856,716 @@ func (m *NotifierMutation) ResetEdge(name string) error { return fmt.Errorf("unknown Notifier edge %s", name) } +// TemplateFieldMutation represents an operation that mutates the TemplateField nodes in the graph. +type TemplateFieldMutation struct { + config + op Op + typ string + id *uuid.UUID + created_at *time.Time + updated_at *time.Time + name *string + description *string + _type *templatefield.Type + text_value *string + clearedFields map[string]struct{} + item_template *uuid.UUID + cleareditem_template bool + done bool + oldValue func(context.Context) (*TemplateField, error) + predicates []predicate.TemplateField +} + +var _ ent.Mutation = (*TemplateFieldMutation)(nil) + +// templatefieldOption allows management of the mutation configuration using functional options. +type templatefieldOption func(*TemplateFieldMutation) + +// newTemplateFieldMutation creates new mutation for the TemplateField entity. +func newTemplateFieldMutation(c config, op Op, opts ...templatefieldOption) *TemplateFieldMutation { + m := &TemplateFieldMutation{ + config: c, + op: op, + typ: TypeTemplateField, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withTemplateFieldID sets the ID field of the mutation. +func withTemplateFieldID(id uuid.UUID) templatefieldOption { + return func(m *TemplateFieldMutation) { + var ( + err error + once sync.Once + value *TemplateField + ) + m.oldValue = func(ctx context.Context) (*TemplateField, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().TemplateField.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withTemplateField sets the old TemplateField of the mutation. +func withTemplateField(node *TemplateField) templatefieldOption { + return func(m *TemplateFieldMutation) { + m.oldValue = func(context.Context) (*TemplateField, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m TemplateFieldMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m TemplateFieldMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of TemplateField entities. +func (m *TemplateFieldMutation) SetID(id uuid.UUID) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *TemplateFieldMutation) ID() (id uuid.UUID, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *TemplateFieldMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uuid.UUID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().TemplateField.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *TemplateFieldMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *TemplateFieldMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the TemplateField entity. +// If the TemplateField object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TemplateFieldMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *TemplateFieldMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *TemplateFieldMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *TemplateFieldMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the TemplateField entity. +// If the TemplateField object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TemplateFieldMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *TemplateFieldMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetName sets the "name" field. +func (m *TemplateFieldMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *TemplateFieldMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the TemplateField entity. +// If the TemplateField object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TemplateFieldMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *TemplateFieldMutation) ResetName() { + m.name = nil +} + +// SetDescription sets the "description" field. +func (m *TemplateFieldMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *TemplateFieldMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the TemplateField entity. +// If the TemplateField object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TemplateFieldMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ClearDescription clears the value of the "description" field. +func (m *TemplateFieldMutation) ClearDescription() { + m.description = nil + m.clearedFields[templatefield.FieldDescription] = struct{}{} +} + +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *TemplateFieldMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[templatefield.FieldDescription] + return ok +} + +// ResetDescription resets all changes to the "description" field. +func (m *TemplateFieldMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, templatefield.FieldDescription) +} + +// SetType sets the "type" field. +func (m *TemplateFieldMutation) SetType(t templatefield.Type) { + m._type = &t +} + +// GetType returns the value of the "type" field in the mutation. +func (m *TemplateFieldMutation) GetType() (r templatefield.Type, exists bool) { + v := m._type + if v == nil { + return + } + return *v, true +} + +// OldType returns the old "type" field's value of the TemplateField entity. +// If the TemplateField object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TemplateFieldMutation) OldType(ctx context.Context) (v templatefield.Type, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldType: %w", err) + } + return oldValue.Type, nil +} + +// ResetType resets all changes to the "type" field. +func (m *TemplateFieldMutation) ResetType() { + m._type = nil +} + +// SetTextValue sets the "text_value" field. +func (m *TemplateFieldMutation) SetTextValue(s string) { + m.text_value = &s +} + +// TextValue returns the value of the "text_value" field in the mutation. +func (m *TemplateFieldMutation) TextValue() (r string, exists bool) { + v := m.text_value + if v == nil { + return + } + return *v, true +} + +// OldTextValue returns the old "text_value" field's value of the TemplateField entity. +// If the TemplateField object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TemplateFieldMutation) OldTextValue(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTextValue is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTextValue requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTextValue: %w", err) + } + return oldValue.TextValue, nil +} + +// ClearTextValue clears the value of the "text_value" field. +func (m *TemplateFieldMutation) ClearTextValue() { + m.text_value = nil + m.clearedFields[templatefield.FieldTextValue] = struct{}{} +} + +// TextValueCleared returns if the "text_value" field was cleared in this mutation. +func (m *TemplateFieldMutation) TextValueCleared() bool { + _, ok := m.clearedFields[templatefield.FieldTextValue] + return ok +} + +// ResetTextValue resets all changes to the "text_value" field. +func (m *TemplateFieldMutation) ResetTextValue() { + m.text_value = nil + delete(m.clearedFields, templatefield.FieldTextValue) +} + +// SetItemTemplateID sets the "item_template" edge to the ItemTemplate entity by id. +func (m *TemplateFieldMutation) SetItemTemplateID(id uuid.UUID) { + m.item_template = &id +} + +// ClearItemTemplate clears the "item_template" edge to the ItemTemplate entity. +func (m *TemplateFieldMutation) ClearItemTemplate() { + m.cleareditem_template = true +} + +// ItemTemplateCleared reports if the "item_template" edge to the ItemTemplate entity was cleared. +func (m *TemplateFieldMutation) ItemTemplateCleared() bool { + return m.cleareditem_template +} + +// ItemTemplateID returns the "item_template" edge ID in the mutation. +func (m *TemplateFieldMutation) ItemTemplateID() (id uuid.UUID, exists bool) { + if m.item_template != nil { + return *m.item_template, true + } + return +} + +// ItemTemplateIDs returns the "item_template" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ItemTemplateID instead. It exists only for internal usage by the builders. +func (m *TemplateFieldMutation) ItemTemplateIDs() (ids []uuid.UUID) { + if id := m.item_template; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetItemTemplate resets all changes to the "item_template" edge. +func (m *TemplateFieldMutation) ResetItemTemplate() { + m.item_template = nil + m.cleareditem_template = false +} + +// Where appends a list predicates to the TemplateFieldMutation builder. +func (m *TemplateFieldMutation) Where(ps ...predicate.TemplateField) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the TemplateFieldMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *TemplateFieldMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.TemplateField, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *TemplateFieldMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *TemplateFieldMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (TemplateField). +func (m *TemplateFieldMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *TemplateFieldMutation) Fields() []string { + fields := make([]string, 0, 6) + if m.created_at != nil { + fields = append(fields, templatefield.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, templatefield.FieldUpdatedAt) + } + if m.name != nil { + fields = append(fields, templatefield.FieldName) + } + if m.description != nil { + fields = append(fields, templatefield.FieldDescription) + } + if m._type != nil { + fields = append(fields, templatefield.FieldType) + } + if m.text_value != nil { + fields = append(fields, templatefield.FieldTextValue) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *TemplateFieldMutation) Field(name string) (ent.Value, bool) { + switch name { + case templatefield.FieldCreatedAt: + return m.CreatedAt() + case templatefield.FieldUpdatedAt: + return m.UpdatedAt() + case templatefield.FieldName: + return m.Name() + case templatefield.FieldDescription: + return m.Description() + case templatefield.FieldType: + return m.GetType() + case templatefield.FieldTextValue: + return m.TextValue() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *TemplateFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case templatefield.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case templatefield.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case templatefield.FieldName: + return m.OldName(ctx) + case templatefield.FieldDescription: + return m.OldDescription(ctx) + case templatefield.FieldType: + return m.OldType(ctx) + case templatefield.FieldTextValue: + return m.OldTextValue(ctx) + } + return nil, fmt.Errorf("unknown TemplateField field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *TemplateFieldMutation) SetField(name string, value ent.Value) error { + switch name { + case templatefield.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case templatefield.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case templatefield.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case templatefield.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case templatefield.FieldType: + v, ok := value.(templatefield.Type) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetType(v) + return nil + case templatefield.FieldTextValue: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTextValue(v) + return nil + } + return fmt.Errorf("unknown TemplateField field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *TemplateFieldMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *TemplateFieldMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *TemplateFieldMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown TemplateField numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *TemplateFieldMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(templatefield.FieldDescription) { + fields = append(fields, templatefield.FieldDescription) + } + if m.FieldCleared(templatefield.FieldTextValue) { + fields = append(fields, templatefield.FieldTextValue) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *TemplateFieldMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *TemplateFieldMutation) ClearField(name string) error { + switch name { + case templatefield.FieldDescription: + m.ClearDescription() + return nil + case templatefield.FieldTextValue: + m.ClearTextValue() + return nil + } + return fmt.Errorf("unknown TemplateField nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *TemplateFieldMutation) ResetField(name string) error { + switch name { + case templatefield.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case templatefield.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case templatefield.FieldName: + m.ResetName() + return nil + case templatefield.FieldDescription: + m.ResetDescription() + return nil + case templatefield.FieldType: + m.ResetType() + return nil + case templatefield.FieldTextValue: + m.ResetTextValue() + return nil + } + return fmt.Errorf("unknown TemplateField field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *TemplateFieldMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.item_template != nil { + edges = append(edges, templatefield.EdgeItemTemplate) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *TemplateFieldMutation) AddedIDs(name string) []ent.Value { + switch name { + case templatefield.EdgeItemTemplate: + if id := m.item_template; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *TemplateFieldMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *TemplateFieldMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *TemplateFieldMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.cleareditem_template { + edges = append(edges, templatefield.EdgeItemTemplate) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *TemplateFieldMutation) EdgeCleared(name string) bool { + switch name { + case templatefield.EdgeItemTemplate: + return m.cleareditem_template + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *TemplateFieldMutation) ClearEdge(name string) error { + switch name { + case templatefield.EdgeItemTemplate: + m.ClearItemTemplate() + return nil + } + return fmt.Errorf("unknown TemplateField unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *TemplateFieldMutation) ResetEdge(name string) error { + switch name { + case templatefield.EdgeItemTemplate: + m.ResetItemTemplate() + return nil + } + return fmt.Errorf("unknown TemplateField edge %s", name) +} + // UserMutation represents an operation that mutates the User nodes in the graph. type UserMutation struct { config @@ -10369,6 +12581,8 @@ type UserMutation struct { superuser *bool role *user.Role activated_on *time.Time + oidc_issuer *string + oidc_subject *string clearedFields map[string]struct{} group *uuid.UUID clearedgroup bool @@ -10648,7 +12862,7 @@ func (m *UserMutation) Password() (r string, exists bool) { // OldPassword returns the old "password" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldPassword(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldPassword(ctx context.Context) (v *string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldPassword is only allowed on UpdateOne operations") } @@ -10662,9 +12876,22 @@ func (m *UserMutation) OldPassword(ctx context.Context) (v string, err error) { return oldValue.Password, nil } +// ClearPassword clears the value of the "password" field. +func (m *UserMutation) ClearPassword() { + m.password = nil + m.clearedFields[user.FieldPassword] = struct{}{} +} + +// PasswordCleared returns if the "password" field was cleared in this mutation. +func (m *UserMutation) PasswordCleared() bool { + _, ok := m.clearedFields[user.FieldPassword] + return ok +} + // ResetPassword resets all changes to the "password" field. func (m *UserMutation) ResetPassword() { m.password = nil + delete(m.clearedFields, user.FieldPassword) } // SetIsSuperuser sets the "is_superuser" field. @@ -10824,6 +13051,104 @@ func (m *UserMutation) ResetActivatedOn() { delete(m.clearedFields, user.FieldActivatedOn) } +// SetOidcIssuer sets the "oidc_issuer" field. +func (m *UserMutation) SetOidcIssuer(s string) { + m.oidc_issuer = &s +} + +// OidcIssuer returns the value of the "oidc_issuer" field in the mutation. +func (m *UserMutation) OidcIssuer() (r string, exists bool) { + v := m.oidc_issuer + if v == nil { + return + } + return *v, true +} + +// OldOidcIssuer returns the old "oidc_issuer" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldOidcIssuer(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOidcIssuer is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOidcIssuer requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOidcIssuer: %w", err) + } + return oldValue.OidcIssuer, nil +} + +// ClearOidcIssuer clears the value of the "oidc_issuer" field. +func (m *UserMutation) ClearOidcIssuer() { + m.oidc_issuer = nil + m.clearedFields[user.FieldOidcIssuer] = struct{}{} +} + +// OidcIssuerCleared returns if the "oidc_issuer" field was cleared in this mutation. +func (m *UserMutation) OidcIssuerCleared() bool { + _, ok := m.clearedFields[user.FieldOidcIssuer] + return ok +} + +// ResetOidcIssuer resets all changes to the "oidc_issuer" field. +func (m *UserMutation) ResetOidcIssuer() { + m.oidc_issuer = nil + delete(m.clearedFields, user.FieldOidcIssuer) +} + +// SetOidcSubject sets the "oidc_subject" field. +func (m *UserMutation) SetOidcSubject(s string) { + m.oidc_subject = &s +} + +// OidcSubject returns the value of the "oidc_subject" field in the mutation. +func (m *UserMutation) OidcSubject() (r string, exists bool) { + v := m.oidc_subject + if v == nil { + return + } + return *v, true +} + +// OldOidcSubject returns the old "oidc_subject" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldOidcSubject(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOidcSubject is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOidcSubject requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOidcSubject: %w", err) + } + return oldValue.OidcSubject, nil +} + +// ClearOidcSubject clears the value of the "oidc_subject" field. +func (m *UserMutation) ClearOidcSubject() { + m.oidc_subject = nil + m.clearedFields[user.FieldOidcSubject] = struct{}{} +} + +// OidcSubjectCleared returns if the "oidc_subject" field was cleared in this mutation. +func (m *UserMutation) OidcSubjectCleared() bool { + _, ok := m.clearedFields[user.FieldOidcSubject] + return ok +} + +// ResetOidcSubject resets all changes to the "oidc_subject" field. +func (m *UserMutation) ResetOidcSubject() { + m.oidc_subject = nil + delete(m.clearedFields, user.FieldOidcSubject) +} + // SetGroupID sets the "group" edge to the Group entity by id. func (m *UserMutation) SetGroupID(id uuid.UUID) { m.group = &id @@ -11005,7 +13330,7 @@ func (m *UserMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *UserMutation) Fields() []string { - fields := make([]string, 0, 9) + fields := make([]string, 0, 11) if m.created_at != nil { fields = append(fields, user.FieldCreatedAt) } @@ -11033,6 +13358,12 @@ func (m *UserMutation) Fields() []string { if m.activated_on != nil { fields = append(fields, user.FieldActivatedOn) } + if m.oidc_issuer != nil { + fields = append(fields, user.FieldOidcIssuer) + } + if m.oidc_subject != nil { + fields = append(fields, user.FieldOidcSubject) + } return fields } @@ -11059,6 +13390,10 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) { return m.Role() case user.FieldActivatedOn: return m.ActivatedOn() + case user.FieldOidcIssuer: + return m.OidcIssuer() + case user.FieldOidcSubject: + return m.OidcSubject() } return nil, false } @@ -11086,6 +13421,10 @@ func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, er return m.OldRole(ctx) case user.FieldActivatedOn: return m.OldActivatedOn(ctx) + case user.FieldOidcIssuer: + return m.OldOidcIssuer(ctx) + case user.FieldOidcSubject: + return m.OldOidcSubject(ctx) } return nil, fmt.Errorf("unknown User field %s", name) } @@ -11158,6 +13497,20 @@ func (m *UserMutation) SetField(name string, value ent.Value) error { } m.SetActivatedOn(v) return nil + case user.FieldOidcIssuer: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOidcIssuer(v) + return nil + case user.FieldOidcSubject: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOidcSubject(v) + return nil } return fmt.Errorf("unknown User field %s", name) } @@ -11188,9 +13541,18 @@ func (m *UserMutation) AddField(name string, value ent.Value) error { // mutation. func (m *UserMutation) ClearedFields() []string { var fields []string + if m.FieldCleared(user.FieldPassword) { + fields = append(fields, user.FieldPassword) + } if m.FieldCleared(user.FieldActivatedOn) { fields = append(fields, user.FieldActivatedOn) } + if m.FieldCleared(user.FieldOidcIssuer) { + fields = append(fields, user.FieldOidcIssuer) + } + if m.FieldCleared(user.FieldOidcSubject) { + fields = append(fields, user.FieldOidcSubject) + } return fields } @@ -11205,9 +13567,18 @@ func (m *UserMutation) FieldCleared(name string) bool { // error if the field is not defined in the schema. func (m *UserMutation) ClearField(name string) error { switch name { + case user.FieldPassword: + m.ClearPassword() + return nil case user.FieldActivatedOn: m.ClearActivatedOn() return nil + case user.FieldOidcIssuer: + m.ClearOidcIssuer() + return nil + case user.FieldOidcSubject: + m.ClearOidcSubject() + return nil } return fmt.Errorf("unknown User nullable field %s", name) } @@ -11243,6 +13614,12 @@ func (m *UserMutation) ResetField(name string) error { case user.FieldActivatedOn: m.ResetActivatedOn() return nil + case user.FieldOidcIssuer: + m.ResetOidcIssuer() + return nil + case user.FieldOidcSubject: + m.ResetOidcSubject() + return nil } return fmt.Errorf("unknown User field %s", name) } diff --git a/backend/internal/data/ent/predicate/predicate.go b/backend/internal/data/ent/predicate/predicate.go index b6dff28c..0d9d47f5 100644 --- a/backend/internal/data/ent/predicate/predicate.go +++ b/backend/internal/data/ent/predicate/predicate.go @@ -15,29 +15,35 @@ type AuthRoles func(*sql.Selector) // AuthTokens is the predicate function for authtokens builders. type AuthTokens func(*sql.Selector) -// Entity is the predicate function for entity builders. -type Entity func(*sql.Selector) - -// EntityField is the predicate function for entityfield builders. -type EntityField func(*sql.Selector) - -// EntityType is the predicate function for entitytype builders. -type EntityType func(*sql.Selector) - // Group is the predicate function for group builders. type Group func(*sql.Selector) // GroupInvitationToken is the predicate function for groupinvitationtoken builders. type GroupInvitationToken func(*sql.Selector) +// Item is the predicate function for item builders. +type Item func(*sql.Selector) + +// ItemField is the predicate function for itemfield builders. +type ItemField func(*sql.Selector) + +// ItemTemplate is the predicate function for itemtemplate builders. +type ItemTemplate func(*sql.Selector) + // Label is the predicate function for label builders. type Label func(*sql.Selector) +// Location is the predicate function for location builders. +type Location func(*sql.Selector) + // MaintenanceEntry is the predicate function for maintenanceentry builders. type MaintenanceEntry func(*sql.Selector) // Notifier is the predicate function for notifier builders. type Notifier func(*sql.Selector) +// TemplateField is the predicate function for templatefield builders. +type TemplateField func(*sql.Selector) + // User is the predicate function for user builders. type User func(*sql.Selector) diff --git a/backend/internal/data/ent/runtime.go b/backend/internal/data/ent/runtime.go index bf2f8792..0476c5c6 100644 --- a/backend/internal/data/ent/runtime.go +++ b/backend/internal/data/ent/runtime.go @@ -8,15 +8,17 @@ import ( "github.com/google/uuid" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/authtokens" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield" - "github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/item" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/label" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/location" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/user" ) @@ -84,219 +86,6 @@ func init() { authtokensDescID := authtokensMixinFields0[0].Descriptor() // authtokens.DefaultID holds the default value on creation for the id field. authtokens.DefaultID = authtokensDescID.Default.(func() uuid.UUID) - entityMixin := schema.Entity{}.Mixin() - entityMixinFields0 := entityMixin[0].Fields() - _ = entityMixinFields0 - entityMixinFields1 := entityMixin[1].Fields() - _ = entityMixinFields1 - entityFields := schema.Entity{}.Fields() - _ = entityFields - // entityDescCreatedAt is the schema descriptor for created_at field. - entityDescCreatedAt := entityMixinFields0[1].Descriptor() - // entity.DefaultCreatedAt holds the default value on creation for the created_at field. - entity.DefaultCreatedAt = entityDescCreatedAt.Default.(func() time.Time) - // entityDescUpdatedAt is the schema descriptor for updated_at field. - entityDescUpdatedAt := entityMixinFields0[2].Descriptor() - // entity.DefaultUpdatedAt holds the default value on creation for the updated_at field. - entity.DefaultUpdatedAt = entityDescUpdatedAt.Default.(func() time.Time) - // entity.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. - entity.UpdateDefaultUpdatedAt = entityDescUpdatedAt.UpdateDefault.(func() time.Time) - // entityDescName is the schema descriptor for name field. - entityDescName := entityMixinFields1[0].Descriptor() - // entity.NameValidator is a validator for the "name" field. It is called by the builders before save. - entity.NameValidator = func() func(string) error { - validators := entityDescName.Validators - fns := [...]func(string) error{ - validators[0].(func(string) error), - validators[1].(func(string) error), - } - return func(name string) error { - for _, fn := range fns { - if err := fn(name); err != nil { - return err - } - } - return nil - } - }() - // entityDescDescription is the schema descriptor for description field. - entityDescDescription := entityMixinFields1[1].Descriptor() - // entity.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. - entity.DescriptionValidator = entityDescDescription.Validators[0].(func(string) error) - // entityDescImportRef is the schema descriptor for import_ref field. - entityDescImportRef := entityFields[0].Descriptor() - // entity.ImportRefValidator is a validator for the "import_ref" field. It is called by the builders before save. - entity.ImportRefValidator = entityDescImportRef.Validators[0].(func(string) error) - // entityDescNotes is the schema descriptor for notes field. - entityDescNotes := entityFields[1].Descriptor() - // entity.NotesValidator is a validator for the "notes" field. It is called by the builders before save. - entity.NotesValidator = entityDescNotes.Validators[0].(func(string) error) - // entityDescQuantity is the schema descriptor for quantity field. - entityDescQuantity := entityFields[2].Descriptor() - // entity.DefaultQuantity holds the default value on creation for the quantity field. - entity.DefaultQuantity = entityDescQuantity.Default.(int) - // entityDescInsured is the schema descriptor for insured field. - entityDescInsured := entityFields[3].Descriptor() - // entity.DefaultInsured holds the default value on creation for the insured field. - entity.DefaultInsured = entityDescInsured.Default.(bool) - // entityDescArchived is the schema descriptor for archived field. - entityDescArchived := entityFields[4].Descriptor() - // entity.DefaultArchived holds the default value on creation for the archived field. - entity.DefaultArchived = entityDescArchived.Default.(bool) - // entityDescAssetID is the schema descriptor for asset_id field. - entityDescAssetID := entityFields[5].Descriptor() - // entity.DefaultAssetID holds the default value on creation for the asset_id field. - entity.DefaultAssetID = entityDescAssetID.Default.(int) - // entityDescSyncChildEntitiesLocations is the schema descriptor for sync_child_entities_locations field. - entityDescSyncChildEntitiesLocations := entityFields[6].Descriptor() - // entity.DefaultSyncChildEntitiesLocations holds the default value on creation for the sync_child_entities_locations field. - entity.DefaultSyncChildEntitiesLocations = entityDescSyncChildEntitiesLocations.Default.(bool) - // entityDescSerialNumber is the schema descriptor for serial_number field. - entityDescSerialNumber := entityFields[7].Descriptor() - // entity.SerialNumberValidator is a validator for the "serial_number" field. It is called by the builders before save. - entity.SerialNumberValidator = entityDescSerialNumber.Validators[0].(func(string) error) - // entityDescModelNumber is the schema descriptor for model_number field. - entityDescModelNumber := entityFields[8].Descriptor() - // entity.ModelNumberValidator is a validator for the "model_number" field. It is called by the builders before save. - entity.ModelNumberValidator = entityDescModelNumber.Validators[0].(func(string) error) - // entityDescManufacturer is the schema descriptor for manufacturer field. - entityDescManufacturer := entityFields[9].Descriptor() - // entity.ManufacturerValidator is a validator for the "manufacturer" field. It is called by the builders before save. - entity.ManufacturerValidator = entityDescManufacturer.Validators[0].(func(string) error) - // entityDescLifetimeWarranty is the schema descriptor for lifetime_warranty field. - entityDescLifetimeWarranty := entityFields[10].Descriptor() - // entity.DefaultLifetimeWarranty holds the default value on creation for the lifetime_warranty field. - entity.DefaultLifetimeWarranty = entityDescLifetimeWarranty.Default.(bool) - // entityDescWarrantyDetails is the schema descriptor for warranty_details field. - entityDescWarrantyDetails := entityFields[12].Descriptor() - // entity.WarrantyDetailsValidator is a validator for the "warranty_details" field. It is called by the builders before save. - entity.WarrantyDetailsValidator = entityDescWarrantyDetails.Validators[0].(func(string) error) - // entityDescPurchasePrice is the schema descriptor for purchase_price field. - entityDescPurchasePrice := entityFields[15].Descriptor() - // entity.DefaultPurchasePrice holds the default value on creation for the purchase_price field. - entity.DefaultPurchasePrice = entityDescPurchasePrice.Default.(float64) - // entityDescSoldPrice is the schema descriptor for sold_price field. - entityDescSoldPrice := entityFields[18].Descriptor() - // entity.DefaultSoldPrice holds the default value on creation for the sold_price field. - entity.DefaultSoldPrice = entityDescSoldPrice.Default.(float64) - // entityDescSoldNotes is the schema descriptor for sold_notes field. - entityDescSoldNotes := entityFields[19].Descriptor() - // entity.SoldNotesValidator is a validator for the "sold_notes" field. It is called by the builders before save. - entity.SoldNotesValidator = entityDescSoldNotes.Validators[0].(func(string) error) - // entityDescID is the schema descriptor for id field. - entityDescID := entityMixinFields0[0].Descriptor() - // entity.DefaultID holds the default value on creation for the id field. - entity.DefaultID = entityDescID.Default.(func() uuid.UUID) - entityfieldMixin := schema.EntityField{}.Mixin() - entityfieldMixinFields0 := entityfieldMixin[0].Fields() - _ = entityfieldMixinFields0 - entityfieldMixinFields1 := entityfieldMixin[1].Fields() - _ = entityfieldMixinFields1 - entityfieldFields := schema.EntityField{}.Fields() - _ = entityfieldFields - // entityfieldDescCreatedAt is the schema descriptor for created_at field. - entityfieldDescCreatedAt := entityfieldMixinFields0[1].Descriptor() - // entityfield.DefaultCreatedAt holds the default value on creation for the created_at field. - entityfield.DefaultCreatedAt = entityfieldDescCreatedAt.Default.(func() time.Time) - // entityfieldDescUpdatedAt is the schema descriptor for updated_at field. - entityfieldDescUpdatedAt := entityfieldMixinFields0[2].Descriptor() - // entityfield.DefaultUpdatedAt holds the default value on creation for the updated_at field. - entityfield.DefaultUpdatedAt = entityfieldDescUpdatedAt.Default.(func() time.Time) - // entityfield.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. - entityfield.UpdateDefaultUpdatedAt = entityfieldDescUpdatedAt.UpdateDefault.(func() time.Time) - // entityfieldDescName is the schema descriptor for name field. - entityfieldDescName := entityfieldMixinFields1[0].Descriptor() - // entityfield.NameValidator is a validator for the "name" field. It is called by the builders before save. - entityfield.NameValidator = func() func(string) error { - validators := entityfieldDescName.Validators - fns := [...]func(string) error{ - validators[0].(func(string) error), - validators[1].(func(string) error), - } - return func(name string) error { - for _, fn := range fns { - if err := fn(name); err != nil { - return err - } - } - return nil - } - }() - // entityfieldDescDescription is the schema descriptor for description field. - entityfieldDescDescription := entityfieldMixinFields1[1].Descriptor() - // entityfield.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. - entityfield.DescriptionValidator = entityfieldDescDescription.Validators[0].(func(string) error) - // entityfieldDescTextValue is the schema descriptor for text_value field. - entityfieldDescTextValue := entityfieldFields[1].Descriptor() - // entityfield.TextValueValidator is a validator for the "text_value" field. It is called by the builders before save. - entityfield.TextValueValidator = entityfieldDescTextValue.Validators[0].(func(string) error) - // entityfieldDescBooleanValue is the schema descriptor for boolean_value field. - entityfieldDescBooleanValue := entityfieldFields[3].Descriptor() - // entityfield.DefaultBooleanValue holds the default value on creation for the boolean_value field. - entityfield.DefaultBooleanValue = entityfieldDescBooleanValue.Default.(bool) - // entityfieldDescTimeValue is the schema descriptor for time_value field. - entityfieldDescTimeValue := entityfieldFields[4].Descriptor() - // entityfield.DefaultTimeValue holds the default value on creation for the time_value field. - entityfield.DefaultTimeValue = entityfieldDescTimeValue.Default.(func() time.Time) - // entityfieldDescID is the schema descriptor for id field. - entityfieldDescID := entityfieldMixinFields0[0].Descriptor() - // entityfield.DefaultID holds the default value on creation for the id field. - entityfield.DefaultID = entityfieldDescID.Default.(func() uuid.UUID) - entitytypeMixin := schema.EntityType{}.Mixin() - entitytypeMixinFields0 := entitytypeMixin[0].Fields() - _ = entitytypeMixinFields0 - entitytypeMixinFields1 := entitytypeMixin[1].Fields() - _ = entitytypeMixinFields1 - entitytypeFields := schema.EntityType{}.Fields() - _ = entitytypeFields - // entitytypeDescCreatedAt is the schema descriptor for created_at field. - entitytypeDescCreatedAt := entitytypeMixinFields0[1].Descriptor() - // entitytype.DefaultCreatedAt holds the default value on creation for the created_at field. - entitytype.DefaultCreatedAt = entitytypeDescCreatedAt.Default.(func() time.Time) - // entitytypeDescUpdatedAt is the schema descriptor for updated_at field. - entitytypeDescUpdatedAt := entitytypeMixinFields0[2].Descriptor() - // entitytype.DefaultUpdatedAt holds the default value on creation for the updated_at field. - entitytype.DefaultUpdatedAt = entitytypeDescUpdatedAt.Default.(func() time.Time) - // entitytype.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. - entitytype.UpdateDefaultUpdatedAt = entitytypeDescUpdatedAt.UpdateDefault.(func() time.Time) - // entitytypeDescName is the schema descriptor for name field. - entitytypeDescName := entitytypeMixinFields1[0].Descriptor() - // entitytype.NameValidator is a validator for the "name" field. It is called by the builders before save. - entitytype.NameValidator = func() func(string) error { - validators := entitytypeDescName.Validators - fns := [...]func(string) error{ - validators[0].(func(string) error), - validators[1].(func(string) error), - } - return func(name string) error { - for _, fn := range fns { - if err := fn(name); err != nil { - return err - } - } - return nil - } - }() - // entitytypeDescDescription is the schema descriptor for description field. - entitytypeDescDescription := entitytypeMixinFields1[1].Descriptor() - // entitytype.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. - entitytype.DescriptionValidator = entitytypeDescDescription.Validators[0].(func(string) error) - // entitytypeDescIcon is the schema descriptor for icon field. - entitytypeDescIcon := entitytypeFields[0].Descriptor() - // entitytype.IconValidator is a validator for the "icon" field. It is called by the builders before save. - entitytype.IconValidator = entitytypeDescIcon.Validators[0].(func(string) error) - // entitytypeDescColor is the schema descriptor for color field. - entitytypeDescColor := entitytypeFields[1].Descriptor() - // entitytype.ColorValidator is a validator for the "color" field. It is called by the builders before save. - entitytype.ColorValidator = entitytypeDescColor.Validators[0].(func(string) error) - // entitytypeDescIsLocation is the schema descriptor for is_location field. - entitytypeDescIsLocation := entitytypeFields[2].Descriptor() - // entitytype.DefaultIsLocation holds the default value on creation for the is_location field. - entitytype.DefaultIsLocation = entitytypeDescIsLocation.Default.(bool) - // entitytypeDescID is the schema descriptor for id field. - entitytypeDescID := entitytypeMixinFields0[0].Descriptor() - // entitytype.DefaultID holds the default value on creation for the id field. - entitytype.DefaultID = entitytypeDescID.Default.(func() uuid.UUID) groupMixin := schema.Group{}.Mixin() groupMixinFields0 := groupMixin[0].Fields() _ = groupMixinFields0 @@ -365,6 +154,255 @@ func init() { groupinvitationtokenDescID := groupinvitationtokenMixinFields0[0].Descriptor() // groupinvitationtoken.DefaultID holds the default value on creation for the id field. groupinvitationtoken.DefaultID = groupinvitationtokenDescID.Default.(func() uuid.UUID) + itemMixin := schema.Item{}.Mixin() + itemMixinFields0 := itemMixin[0].Fields() + _ = itemMixinFields0 + itemMixinFields1 := itemMixin[1].Fields() + _ = itemMixinFields1 + itemFields := schema.Item{}.Fields() + _ = itemFields + // itemDescCreatedAt is the schema descriptor for created_at field. + itemDescCreatedAt := itemMixinFields0[1].Descriptor() + // item.DefaultCreatedAt holds the default value on creation for the created_at field. + item.DefaultCreatedAt = itemDescCreatedAt.Default.(func() time.Time) + // itemDescUpdatedAt is the schema descriptor for updated_at field. + itemDescUpdatedAt := itemMixinFields0[2].Descriptor() + // item.DefaultUpdatedAt holds the default value on creation for the updated_at field. + item.DefaultUpdatedAt = itemDescUpdatedAt.Default.(func() time.Time) + // item.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + item.UpdateDefaultUpdatedAt = itemDescUpdatedAt.UpdateDefault.(func() time.Time) + // itemDescName is the schema descriptor for name field. + itemDescName := itemMixinFields1[0].Descriptor() + // item.NameValidator is a validator for the "name" field. It is called by the builders before save. + item.NameValidator = func() func(string) error { + validators := itemDescName.Validators + fns := [...]func(string) error{ + validators[0].(func(string) error), + validators[1].(func(string) error), + } + return func(name string) error { + for _, fn := range fns { + if err := fn(name); err != nil { + return err + } + } + return nil + } + }() + // itemDescDescription is the schema descriptor for description field. + itemDescDescription := itemMixinFields1[1].Descriptor() + // item.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + item.DescriptionValidator = itemDescDescription.Validators[0].(func(string) error) + // itemDescImportRef is the schema descriptor for import_ref field. + itemDescImportRef := itemFields[0].Descriptor() + // item.ImportRefValidator is a validator for the "import_ref" field. It is called by the builders before save. + item.ImportRefValidator = itemDescImportRef.Validators[0].(func(string) error) + // itemDescNotes is the schema descriptor for notes field. + itemDescNotes := itemFields[1].Descriptor() + // item.NotesValidator is a validator for the "notes" field. It is called by the builders before save. + item.NotesValidator = itemDescNotes.Validators[0].(func(string) error) + // itemDescQuantity is the schema descriptor for quantity field. + itemDescQuantity := itemFields[2].Descriptor() + // item.DefaultQuantity holds the default value on creation for the quantity field. + item.DefaultQuantity = itemDescQuantity.Default.(int) + // itemDescInsured is the schema descriptor for insured field. + itemDescInsured := itemFields[3].Descriptor() + // item.DefaultInsured holds the default value on creation for the insured field. + item.DefaultInsured = itemDescInsured.Default.(bool) + // itemDescArchived is the schema descriptor for archived field. + itemDescArchived := itemFields[4].Descriptor() + // item.DefaultArchived holds the default value on creation for the archived field. + item.DefaultArchived = itemDescArchived.Default.(bool) + // itemDescAssetID is the schema descriptor for asset_id field. + itemDescAssetID := itemFields[5].Descriptor() + // item.DefaultAssetID holds the default value on creation for the asset_id field. + item.DefaultAssetID = itemDescAssetID.Default.(int) + // itemDescSyncChildItemsLocations is the schema descriptor for sync_child_items_locations field. + itemDescSyncChildItemsLocations := itemFields[6].Descriptor() + // item.DefaultSyncChildItemsLocations holds the default value on creation for the sync_child_items_locations field. + item.DefaultSyncChildItemsLocations = itemDescSyncChildItemsLocations.Default.(bool) + // itemDescSerialNumber is the schema descriptor for serial_number field. + itemDescSerialNumber := itemFields[7].Descriptor() + // item.SerialNumberValidator is a validator for the "serial_number" field. It is called by the builders before save. + item.SerialNumberValidator = itemDescSerialNumber.Validators[0].(func(string) error) + // itemDescModelNumber is the schema descriptor for model_number field. + itemDescModelNumber := itemFields[8].Descriptor() + // item.ModelNumberValidator is a validator for the "model_number" field. It is called by the builders before save. + item.ModelNumberValidator = itemDescModelNumber.Validators[0].(func(string) error) + // itemDescManufacturer is the schema descriptor for manufacturer field. + itemDescManufacturer := itemFields[9].Descriptor() + // item.ManufacturerValidator is a validator for the "manufacturer" field. It is called by the builders before save. + item.ManufacturerValidator = itemDescManufacturer.Validators[0].(func(string) error) + // itemDescLifetimeWarranty is the schema descriptor for lifetime_warranty field. + itemDescLifetimeWarranty := itemFields[10].Descriptor() + // item.DefaultLifetimeWarranty holds the default value on creation for the lifetime_warranty field. + item.DefaultLifetimeWarranty = itemDescLifetimeWarranty.Default.(bool) + // itemDescWarrantyDetails is the schema descriptor for warranty_details field. + itemDescWarrantyDetails := itemFields[12].Descriptor() + // item.WarrantyDetailsValidator is a validator for the "warranty_details" field. It is called by the builders before save. + item.WarrantyDetailsValidator = itemDescWarrantyDetails.Validators[0].(func(string) error) + // itemDescPurchasePrice is the schema descriptor for purchase_price field. + itemDescPurchasePrice := itemFields[15].Descriptor() + // item.DefaultPurchasePrice holds the default value on creation for the purchase_price field. + item.DefaultPurchasePrice = itemDescPurchasePrice.Default.(float64) + // itemDescSoldPrice is the schema descriptor for sold_price field. + itemDescSoldPrice := itemFields[18].Descriptor() + // item.DefaultSoldPrice holds the default value on creation for the sold_price field. + item.DefaultSoldPrice = itemDescSoldPrice.Default.(float64) + // itemDescSoldNotes is the schema descriptor for sold_notes field. + itemDescSoldNotes := itemFields[19].Descriptor() + // item.SoldNotesValidator is a validator for the "sold_notes" field. It is called by the builders before save. + item.SoldNotesValidator = itemDescSoldNotes.Validators[0].(func(string) error) + // itemDescID is the schema descriptor for id field. + itemDescID := itemMixinFields0[0].Descriptor() + // item.DefaultID holds the default value on creation for the id field. + item.DefaultID = itemDescID.Default.(func() uuid.UUID) + itemfieldMixin := schema.ItemField{}.Mixin() + itemfieldMixinFields0 := itemfieldMixin[0].Fields() + _ = itemfieldMixinFields0 + itemfieldMixinFields1 := itemfieldMixin[1].Fields() + _ = itemfieldMixinFields1 + itemfieldFields := schema.ItemField{}.Fields() + _ = itemfieldFields + // itemfieldDescCreatedAt is the schema descriptor for created_at field. + itemfieldDescCreatedAt := itemfieldMixinFields0[1].Descriptor() + // itemfield.DefaultCreatedAt holds the default value on creation for the created_at field. + itemfield.DefaultCreatedAt = itemfieldDescCreatedAt.Default.(func() time.Time) + // itemfieldDescUpdatedAt is the schema descriptor for updated_at field. + itemfieldDescUpdatedAt := itemfieldMixinFields0[2].Descriptor() + // itemfield.DefaultUpdatedAt holds the default value on creation for the updated_at field. + itemfield.DefaultUpdatedAt = itemfieldDescUpdatedAt.Default.(func() time.Time) + // itemfield.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + itemfield.UpdateDefaultUpdatedAt = itemfieldDescUpdatedAt.UpdateDefault.(func() time.Time) + // itemfieldDescName is the schema descriptor for name field. + itemfieldDescName := itemfieldMixinFields1[0].Descriptor() + // itemfield.NameValidator is a validator for the "name" field. It is called by the builders before save. + itemfield.NameValidator = func() func(string) error { + validators := itemfieldDescName.Validators + fns := [...]func(string) error{ + validators[0].(func(string) error), + validators[1].(func(string) error), + } + return func(name string) error { + for _, fn := range fns { + if err := fn(name); err != nil { + return err + } + } + return nil + } + }() + // itemfieldDescDescription is the schema descriptor for description field. + itemfieldDescDescription := itemfieldMixinFields1[1].Descriptor() + // itemfield.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + itemfield.DescriptionValidator = itemfieldDescDescription.Validators[0].(func(string) error) + // itemfieldDescTextValue is the schema descriptor for text_value field. + itemfieldDescTextValue := itemfieldFields[1].Descriptor() + // itemfield.TextValueValidator is a validator for the "text_value" field. It is called by the builders before save. + itemfield.TextValueValidator = itemfieldDescTextValue.Validators[0].(func(string) error) + // itemfieldDescBooleanValue is the schema descriptor for boolean_value field. + itemfieldDescBooleanValue := itemfieldFields[3].Descriptor() + // itemfield.DefaultBooleanValue holds the default value on creation for the boolean_value field. + itemfield.DefaultBooleanValue = itemfieldDescBooleanValue.Default.(bool) + // itemfieldDescTimeValue is the schema descriptor for time_value field. + itemfieldDescTimeValue := itemfieldFields[4].Descriptor() + // itemfield.DefaultTimeValue holds the default value on creation for the time_value field. + itemfield.DefaultTimeValue = itemfieldDescTimeValue.Default.(func() time.Time) + // itemfieldDescID is the schema descriptor for id field. + itemfieldDescID := itemfieldMixinFields0[0].Descriptor() + // itemfield.DefaultID holds the default value on creation for the id field. + itemfield.DefaultID = itemfieldDescID.Default.(func() uuid.UUID) + itemtemplateMixin := schema.ItemTemplate{}.Mixin() + itemtemplateMixinFields0 := itemtemplateMixin[0].Fields() + _ = itemtemplateMixinFields0 + itemtemplateMixinFields1 := itemtemplateMixin[1].Fields() + _ = itemtemplateMixinFields1 + itemtemplateFields := schema.ItemTemplate{}.Fields() + _ = itemtemplateFields + // itemtemplateDescCreatedAt is the schema descriptor for created_at field. + itemtemplateDescCreatedAt := itemtemplateMixinFields0[1].Descriptor() + // itemtemplate.DefaultCreatedAt holds the default value on creation for the created_at field. + itemtemplate.DefaultCreatedAt = itemtemplateDescCreatedAt.Default.(func() time.Time) + // itemtemplateDescUpdatedAt is the schema descriptor for updated_at field. + itemtemplateDescUpdatedAt := itemtemplateMixinFields0[2].Descriptor() + // itemtemplate.DefaultUpdatedAt holds the default value on creation for the updated_at field. + itemtemplate.DefaultUpdatedAt = itemtemplateDescUpdatedAt.Default.(func() time.Time) + // itemtemplate.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + itemtemplate.UpdateDefaultUpdatedAt = itemtemplateDescUpdatedAt.UpdateDefault.(func() time.Time) + // itemtemplateDescName is the schema descriptor for name field. + itemtemplateDescName := itemtemplateMixinFields1[0].Descriptor() + // itemtemplate.NameValidator is a validator for the "name" field. It is called by the builders before save. + itemtemplate.NameValidator = func() func(string) error { + validators := itemtemplateDescName.Validators + fns := [...]func(string) error{ + validators[0].(func(string) error), + validators[1].(func(string) error), + } + return func(name string) error { + for _, fn := range fns { + if err := fn(name); err != nil { + return err + } + } + return nil + } + }() + // itemtemplateDescDescription is the schema descriptor for description field. + itemtemplateDescDescription := itemtemplateMixinFields1[1].Descriptor() + // itemtemplate.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + itemtemplate.DescriptionValidator = itemtemplateDescDescription.Validators[0].(func(string) error) + // itemtemplateDescNotes is the schema descriptor for notes field. + itemtemplateDescNotes := itemtemplateFields[0].Descriptor() + // itemtemplate.NotesValidator is a validator for the "notes" field. It is called by the builders before save. + itemtemplate.NotesValidator = itemtemplateDescNotes.Validators[0].(func(string) error) + // itemtemplateDescDefaultQuantity is the schema descriptor for default_quantity field. + itemtemplateDescDefaultQuantity := itemtemplateFields[1].Descriptor() + // itemtemplate.DefaultDefaultQuantity holds the default value on creation for the default_quantity field. + itemtemplate.DefaultDefaultQuantity = itemtemplateDescDefaultQuantity.Default.(int) + // itemtemplateDescDefaultInsured is the schema descriptor for default_insured field. + itemtemplateDescDefaultInsured := itemtemplateFields[2].Descriptor() + // itemtemplate.DefaultDefaultInsured holds the default value on creation for the default_insured field. + itemtemplate.DefaultDefaultInsured = itemtemplateDescDefaultInsured.Default.(bool) + // itemtemplateDescDefaultName is the schema descriptor for default_name field. + itemtemplateDescDefaultName := itemtemplateFields[3].Descriptor() + // itemtemplate.DefaultNameValidator is a validator for the "default_name" field. It is called by the builders before save. + itemtemplate.DefaultNameValidator = itemtemplateDescDefaultName.Validators[0].(func(string) error) + // itemtemplateDescDefaultDescription is the schema descriptor for default_description field. + itemtemplateDescDefaultDescription := itemtemplateFields[4].Descriptor() + // itemtemplate.DefaultDescriptionValidator is a validator for the "default_description" field. It is called by the builders before save. + itemtemplate.DefaultDescriptionValidator = itemtemplateDescDefaultDescription.Validators[0].(func(string) error) + // itemtemplateDescDefaultManufacturer is the schema descriptor for default_manufacturer field. + itemtemplateDescDefaultManufacturer := itemtemplateFields[5].Descriptor() + // itemtemplate.DefaultManufacturerValidator is a validator for the "default_manufacturer" field. It is called by the builders before save. + itemtemplate.DefaultManufacturerValidator = itemtemplateDescDefaultManufacturer.Validators[0].(func(string) error) + // itemtemplateDescDefaultModelNumber is the schema descriptor for default_model_number field. + itemtemplateDescDefaultModelNumber := itemtemplateFields[6].Descriptor() + // itemtemplate.DefaultModelNumberValidator is a validator for the "default_model_number" field. It is called by the builders before save. + itemtemplate.DefaultModelNumberValidator = itemtemplateDescDefaultModelNumber.Validators[0].(func(string) error) + // itemtemplateDescDefaultLifetimeWarranty is the schema descriptor for default_lifetime_warranty field. + itemtemplateDescDefaultLifetimeWarranty := itemtemplateFields[7].Descriptor() + // itemtemplate.DefaultDefaultLifetimeWarranty holds the default value on creation for the default_lifetime_warranty field. + itemtemplate.DefaultDefaultLifetimeWarranty = itemtemplateDescDefaultLifetimeWarranty.Default.(bool) + // itemtemplateDescDefaultWarrantyDetails is the schema descriptor for default_warranty_details field. + itemtemplateDescDefaultWarrantyDetails := itemtemplateFields[8].Descriptor() + // itemtemplate.DefaultWarrantyDetailsValidator is a validator for the "default_warranty_details" field. It is called by the builders before save. + itemtemplate.DefaultWarrantyDetailsValidator = itemtemplateDescDefaultWarrantyDetails.Validators[0].(func(string) error) + // itemtemplateDescIncludeWarrantyFields is the schema descriptor for include_warranty_fields field. + itemtemplateDescIncludeWarrantyFields := itemtemplateFields[9].Descriptor() + // itemtemplate.DefaultIncludeWarrantyFields holds the default value on creation for the include_warranty_fields field. + itemtemplate.DefaultIncludeWarrantyFields = itemtemplateDescIncludeWarrantyFields.Default.(bool) + // itemtemplateDescIncludePurchaseFields is the schema descriptor for include_purchase_fields field. + itemtemplateDescIncludePurchaseFields := itemtemplateFields[10].Descriptor() + // itemtemplate.DefaultIncludePurchaseFields holds the default value on creation for the include_purchase_fields field. + itemtemplate.DefaultIncludePurchaseFields = itemtemplateDescIncludePurchaseFields.Default.(bool) + // itemtemplateDescIncludeSoldFields is the schema descriptor for include_sold_fields field. + itemtemplateDescIncludeSoldFields := itemtemplateFields[11].Descriptor() + // itemtemplate.DefaultIncludeSoldFields holds the default value on creation for the include_sold_fields field. + itemtemplate.DefaultIncludeSoldFields = itemtemplateDescIncludeSoldFields.Default.(bool) + // itemtemplateDescID is the schema descriptor for id field. + itemtemplateDescID := itemtemplateMixinFields0[0].Descriptor() + // itemtemplate.DefaultID holds the default value on creation for the id field. + itemtemplate.DefaultID = itemtemplateDescID.Default.(func() uuid.UUID) labelMixin := schema.Label{}.Mixin() labelMixinFields0 := labelMixin[0].Fields() _ = labelMixinFields0 @@ -412,6 +450,49 @@ func init() { labelDescID := labelMixinFields0[0].Descriptor() // label.DefaultID holds the default value on creation for the id field. label.DefaultID = labelDescID.Default.(func() uuid.UUID) + locationMixin := schema.Location{}.Mixin() + locationMixinFields0 := locationMixin[0].Fields() + _ = locationMixinFields0 + locationMixinFields1 := locationMixin[1].Fields() + _ = locationMixinFields1 + locationFields := schema.Location{}.Fields() + _ = locationFields + // locationDescCreatedAt is the schema descriptor for created_at field. + locationDescCreatedAt := locationMixinFields0[1].Descriptor() + // location.DefaultCreatedAt holds the default value on creation for the created_at field. + location.DefaultCreatedAt = locationDescCreatedAt.Default.(func() time.Time) + // locationDescUpdatedAt is the schema descriptor for updated_at field. + locationDescUpdatedAt := locationMixinFields0[2].Descriptor() + // location.DefaultUpdatedAt holds the default value on creation for the updated_at field. + location.DefaultUpdatedAt = locationDescUpdatedAt.Default.(func() time.Time) + // location.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + location.UpdateDefaultUpdatedAt = locationDescUpdatedAt.UpdateDefault.(func() time.Time) + // locationDescName is the schema descriptor for name field. + locationDescName := locationMixinFields1[0].Descriptor() + // location.NameValidator is a validator for the "name" field. It is called by the builders before save. + location.NameValidator = func() func(string) error { + validators := locationDescName.Validators + fns := [...]func(string) error{ + validators[0].(func(string) error), + validators[1].(func(string) error), + } + return func(name string) error { + for _, fn := range fns { + if err := fn(name); err != nil { + return err + } + } + return nil + } + }() + // locationDescDescription is the schema descriptor for description field. + locationDescDescription := locationMixinFields1[1].Descriptor() + // location.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + location.DescriptionValidator = locationDescDescription.Validators[0].(func(string) error) + // locationDescID is the schema descriptor for id field. + locationDescID := locationMixinFields0[0].Descriptor() + // location.DefaultID holds the default value on creation for the id field. + location.DefaultID = locationDescID.Default.(func() uuid.UUID) maintenanceentryMixin := schema.MaintenanceEntry{}.Mixin() maintenanceentryMixinFields0 := maintenanceentryMixin[0].Fields() _ = maintenanceentryMixinFields0 @@ -516,6 +597,53 @@ func init() { notifierDescID := notifierMixinFields0[0].Descriptor() // notifier.DefaultID holds the default value on creation for the id field. notifier.DefaultID = notifierDescID.Default.(func() uuid.UUID) + templatefieldMixin := schema.TemplateField{}.Mixin() + templatefieldMixinFields0 := templatefieldMixin[0].Fields() + _ = templatefieldMixinFields0 + templatefieldMixinFields1 := templatefieldMixin[1].Fields() + _ = templatefieldMixinFields1 + templatefieldFields := schema.TemplateField{}.Fields() + _ = templatefieldFields + // templatefieldDescCreatedAt is the schema descriptor for created_at field. + templatefieldDescCreatedAt := templatefieldMixinFields0[1].Descriptor() + // templatefield.DefaultCreatedAt holds the default value on creation for the created_at field. + templatefield.DefaultCreatedAt = templatefieldDescCreatedAt.Default.(func() time.Time) + // templatefieldDescUpdatedAt is the schema descriptor for updated_at field. + templatefieldDescUpdatedAt := templatefieldMixinFields0[2].Descriptor() + // templatefield.DefaultUpdatedAt holds the default value on creation for the updated_at field. + templatefield.DefaultUpdatedAt = templatefieldDescUpdatedAt.Default.(func() time.Time) + // templatefield.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + templatefield.UpdateDefaultUpdatedAt = templatefieldDescUpdatedAt.UpdateDefault.(func() time.Time) + // templatefieldDescName is the schema descriptor for name field. + templatefieldDescName := templatefieldMixinFields1[0].Descriptor() + // templatefield.NameValidator is a validator for the "name" field. It is called by the builders before save. + templatefield.NameValidator = func() func(string) error { + validators := templatefieldDescName.Validators + fns := [...]func(string) error{ + validators[0].(func(string) error), + validators[1].(func(string) error), + } + return func(name string) error { + for _, fn := range fns { + if err := fn(name); err != nil { + return err + } + } + return nil + } + }() + // templatefieldDescDescription is the schema descriptor for description field. + templatefieldDescDescription := templatefieldMixinFields1[1].Descriptor() + // templatefield.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + templatefield.DescriptionValidator = templatefieldDescDescription.Validators[0].(func(string) error) + // templatefieldDescTextValue is the schema descriptor for text_value field. + templatefieldDescTextValue := templatefieldFields[1].Descriptor() + // templatefield.TextValueValidator is a validator for the "text_value" field. It is called by the builders before save. + templatefield.TextValueValidator = templatefieldDescTextValue.Validators[0].(func(string) error) + // templatefieldDescID is the schema descriptor for id field. + templatefieldDescID := templatefieldMixinFields0[0].Descriptor() + // templatefield.DefaultID holds the default value on creation for the id field. + templatefield.DefaultID = templatefieldDescID.Default.(func() uuid.UUID) userMixin := schema.User{}.Mixin() userMixinFields0 := userMixin[0].Fields() _ = userMixinFields0 @@ -570,21 +698,7 @@ func init() { // userDescPassword is the schema descriptor for password field. userDescPassword := userFields[2].Descriptor() // user.PasswordValidator is a validator for the "password" field. It is called by the builders before save. - user.PasswordValidator = func() func(string) error { - validators := userDescPassword.Validators - fns := [...]func(string) error{ - validators[0].(func(string) error), - validators[1].(func(string) error), - } - return func(password string) error { - for _, fn := range fns { - if err := fn(password); err != nil { - return err - } - } - return nil - } - }() + user.PasswordValidator = userDescPassword.Validators[0].(func(string) error) // userDescIsSuperuser is the schema descriptor for is_superuser field. userDescIsSuperuser := userFields[3].Descriptor() // user.DefaultIsSuperuser holds the default value on creation for the is_superuser field. diff --git a/backend/internal/data/ent/schema/group.go b/backend/internal/data/ent/schema/group.go index 6a65f3aa..2ba5ba7a 100644 --- a/backend/internal/data/ent/schema/group.go +++ b/backend/internal/data/ent/schema/group.go @@ -43,11 +43,13 @@ func (Group) Edges() []ent.Edge { return []ent.Edge{ owned("users", User.Type), - owned("entities", Entity.Type), + owned("locations", Location.Type), + owned("items", Item.Type), owned("labels", Label.Type), owned("invitation_tokens", GroupInvitationToken.Type), owned("notifiers", Notifier.Type), owned("entity_types", EntityType.Type), + owned("item_templates", ItemTemplate.Type), // $scaffold_edge } } diff --git a/backend/internal/data/ent/schema/item_template.go b/backend/internal/data/ent/schema/item_template.go new file mode 100644 index 00000000..bb86170a --- /dev/null +++ b/backend/internal/data/ent/schema/item_template.go @@ -0,0 +1,111 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema/mixins" +) + +// ItemTemplate holds the schema definition for the ItemTemplate entity. +type ItemTemplate struct { + ent.Schema +} + +func (ItemTemplate) Mixin() []ent.Mixin { + return []ent.Mixin{ + mixins.BaseMixin{}, + mixins.DetailsMixin{}, + GroupMixin{ref: "item_templates"}, + } +} + +func (ItemTemplate) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("name"), + } +} + +// Fields of the ItemTemplate. +func (ItemTemplate) Fields() []ent.Field { + return []ent.Field{ + // Notes for the template (instructions, hints, etc.) + field.String("notes"). + MaxLen(1000). + Optional(), + + // ------------------------------------ + // Default values for item fields + field.Int("default_quantity"). + Default(1), + field.Bool("default_insured"). + Default(false), + + // ------------------------------------ + // Default item name/description (templates for item identity) + field.String("default_name"). + MaxLen(255). + Optional(). + Comment("Default name template for items (can use placeholders)"), + field.Text("default_description"). + MaxLen(1000). + Optional(). + Comment("Default description for items created from this template"), + + // ------------------------------------ + // Default item identification + field.String("default_manufacturer"). + MaxLen(255). + Optional(), + field.String("default_model_number"). + MaxLen(255). + Optional(). + Comment("Default model number for items created from this template"), + + // ------------------------------------ + // Default warranty settings + field.Bool("default_lifetime_warranty"). + Default(false), + field.Text("default_warranty_details"). + MaxLen(1000). + Optional(), + + // ------------------------------------ + // Template metadata + field.Bool("include_warranty_fields"). + Default(false). + Comment("Whether to include warranty fields in items created from this template"), + field.Bool("include_purchase_fields"). + Default(false). + Comment("Whether to include purchase fields in items created from this template"), + field.Bool("include_sold_fields"). + Default(false). + Comment("Whether to include sold fields in items created from this template"), + + // ------------------------------------ + // Default labels (stored as JSON array of UUIDs to allow reuse across templates) + field.JSON("default_label_ids", []uuid.UUID{}). + Optional(). + Comment("Default label IDs for items created from this template"), + } +} + +// Edges of the ItemTemplate. +func (ItemTemplate) Edges() []ent.Edge { + owned := func(s string, t any) ent.Edge { + return edge.To(s, t). + Annotations(entsql.Annotation{ + OnDelete: entsql.Cascade, + }) + } + + return []ent.Edge{ + owned("fields", TemplateField.Type), + // Default location for items created from this template + edge.To("location", Location.Type). + Unique(), + } +} diff --git a/backend/internal/data/ent/schema/template_field.go b/backend/internal/data/ent/schema/template_field.go new file mode 100644 index 00000000..8c82d43b --- /dev/null +++ b/backend/internal/data/ent/schema/template_field.go @@ -0,0 +1,41 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema/mixins" +) + +// TemplateField holds the schema definition for the TemplateField entity. +// Template fields define custom fields that will be added to items created from a template. +type TemplateField struct { + ent.Schema +} + +func (TemplateField) Mixin() []ent.Mixin { + return []ent.Mixin{ + mixins.BaseMixin{}, + mixins.DetailsMixin{}, + } +} + +// Fields of the TemplateField. +func (TemplateField) Fields() []ent.Field { + return []ent.Field{ + field.Enum("type"). + Values("text"), + field.String("text_value"). + MaxLen(500). + Optional(), + } +} + +// Edges of the TemplateField. +func (TemplateField) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("item_template", ItemTemplate.Type). + Ref("fields"). + Unique(), + } +} diff --git a/backend/internal/data/ent/schema/user.go b/backend/internal/data/ent/schema/user.go index bd747aea..c1ff9c29 100644 --- a/backend/internal/data/ent/schema/user.go +++ b/backend/internal/data/ent/schema/user.go @@ -5,6 +5,7 @@ import ( "entgo.io/ent/dialect/entsql" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" "entgo.io/ent/schema/mixin" "github.com/google/uuid" "github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema/mixins" @@ -34,7 +35,8 @@ func (User) Fields() []ent.Field { Unique(), field.String("password"). MaxLen(255). - NotEmpty(). + Nillable(). + Optional(). Sensitive(), field.Bool("is_superuser"). Default(false), @@ -45,6 +47,19 @@ func (User) Fields() []ent.Field { Values("user", "owner"), field.Time("activated_on"). Optional(), + // OIDC identity mapping fields (issuer + subject) + field.String("oidc_issuer"). + Optional(). + Nillable(), + field.String("oidc_subject"). + Optional(). + Nillable(), + } +} + +func (User) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("oidc_issuer", "oidc_subject").Unique(), } } @@ -81,14 +96,14 @@ func (g UserMixin) Fields() []ent.Field { } func (g UserMixin) Edges() []ent.Edge { - edge := edge.From("user", User.Type). + e := edge.From("user", User.Type). Ref(g.ref). Unique(). Required() if g.field != "" { - edge = edge.Field(g.field) + e = e.Field(g.field) } - return []ent.Edge{edge} + return []ent.Edge{e} } diff --git a/backend/internal/data/ent/templatefield.go b/backend/internal/data/ent/templatefield.go new file mode 100644 index 00000000..3ba3a489 --- /dev/null +++ b/backend/internal/data/ent/templatefield.go @@ -0,0 +1,201 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield" +) + +// TemplateField is the model entity for the TemplateField schema. +type TemplateField struct { + config `json:"-"` + // ID of the ent. + ID uuid.UUID `json:"id,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // UpdatedAt holds the value of the "updated_at" field. + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Name holds the value of the "name" field. + Name string `json:"name,omitempty"` + // Description holds the value of the "description" field. + Description string `json:"description,omitempty"` + // Type holds the value of the "type" field. + Type templatefield.Type `json:"type,omitempty"` + // TextValue holds the value of the "text_value" field. + TextValue string `json:"text_value,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the TemplateFieldQuery when eager-loading is set. + Edges TemplateFieldEdges `json:"edges"` + item_template_fields *uuid.UUID + selectValues sql.SelectValues +} + +// TemplateFieldEdges holds the relations/edges for other nodes in the graph. +type TemplateFieldEdges struct { + // ItemTemplate holds the value of the item_template edge. + ItemTemplate *ItemTemplate `json:"item_template,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// ItemTemplateOrErr returns the ItemTemplate value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e TemplateFieldEdges) ItemTemplateOrErr() (*ItemTemplate, error) { + if e.ItemTemplate != nil { + return e.ItemTemplate, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: itemtemplate.Label} + } + return nil, &NotLoadedError{edge: "item_template"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*TemplateField) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case templatefield.FieldName, templatefield.FieldDescription, templatefield.FieldType, templatefield.FieldTextValue: + values[i] = new(sql.NullString) + case templatefield.FieldCreatedAt, templatefield.FieldUpdatedAt: + values[i] = new(sql.NullTime) + case templatefield.FieldID: + values[i] = new(uuid.UUID) + case templatefield.ForeignKeys[0]: // item_template_fields + values[i] = &sql.NullScanner{S: new(uuid.UUID)} + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the TemplateField fields. +func (_m *TemplateField) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case templatefield.FieldID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + _m.ID = *value + } + case templatefield.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + _m.CreatedAt = value.Time + } + case templatefield.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + _m.UpdatedAt = value.Time + } + case templatefield.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + _m.Name = value.String + } + case templatefield.FieldDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field description", values[i]) + } else if value.Valid { + _m.Description = value.String + } + case templatefield.FieldType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field type", values[i]) + } else if value.Valid { + _m.Type = templatefield.Type(value.String) + } + case templatefield.FieldTextValue: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field text_value", values[i]) + } else if value.Valid { + _m.TextValue = value.String + } + case templatefield.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field item_template_fields", values[i]) + } else if value.Valid { + _m.item_template_fields = new(uuid.UUID) + *_m.item_template_fields = *value.S.(*uuid.UUID) + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the TemplateField. +// This includes values selected through modifiers, order, etc. +func (_m *TemplateField) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryItemTemplate queries the "item_template" edge of the TemplateField entity. +func (_m *TemplateField) QueryItemTemplate() *ItemTemplateQuery { + return NewTemplateFieldClient(_m.config).QueryItemTemplate(_m) +} + +// Update returns a builder for updating this TemplateField. +// Note that you need to call TemplateField.Unwrap() before calling this method if this TemplateField +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *TemplateField) Update() *TemplateFieldUpdateOne { + return NewTemplateFieldClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the TemplateField entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *TemplateField) Unwrap() *TemplateField { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: TemplateField is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *TemplateField) String() string { + var builder strings.Builder + builder.WriteString("TemplateField(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("created_at=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(_m.Name) + builder.WriteString(", ") + builder.WriteString("description=") + builder.WriteString(_m.Description) + builder.WriteString(", ") + builder.WriteString("type=") + builder.WriteString(fmt.Sprintf("%v", _m.Type)) + builder.WriteString(", ") + builder.WriteString("text_value=") + builder.WriteString(_m.TextValue) + builder.WriteByte(')') + return builder.String() +} + +// TemplateFields is a parsable slice of TemplateField. +type TemplateFields []*TemplateField diff --git a/backend/internal/data/ent/templatefield/templatefield.go b/backend/internal/data/ent/templatefield/templatefield.go new file mode 100644 index 00000000..6dbde586 --- /dev/null +++ b/backend/internal/data/ent/templatefield/templatefield.go @@ -0,0 +1,165 @@ +// Code generated by ent, DO NOT EDIT. + +package templatefield + +import ( + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" +) + +const ( + // Label holds the string label denoting the templatefield type in the database. + Label = "template_field" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldType holds the string denoting the type field in the database. + FieldType = "type" + // FieldTextValue holds the string denoting the text_value field in the database. + FieldTextValue = "text_value" + // EdgeItemTemplate holds the string denoting the item_template edge name in mutations. + EdgeItemTemplate = "item_template" + // Table holds the table name of the templatefield in the database. + Table = "template_fields" + // ItemTemplateTable is the table that holds the item_template relation/edge. + ItemTemplateTable = "template_fields" + // ItemTemplateInverseTable is the table name for the ItemTemplate entity. + // It exists in this package in order to avoid circular dependency with the "itemtemplate" package. + ItemTemplateInverseTable = "item_templates" + // ItemTemplateColumn is the table column denoting the item_template relation/edge. + ItemTemplateColumn = "item_template_fields" +) + +// Columns holds all SQL columns for templatefield fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldName, + FieldDescription, + FieldType, + FieldTextValue, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "template_fields" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "item_template_fields", +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + for i := range ForeignKeys { + if column == ForeignKeys[i] { + return true + } + } + return false +} + +var ( + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + DescriptionValidator func(string) error + // TextValueValidator is a validator for the "text_value" field. It is called by the builders before save. + TextValueValidator func(string) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID +) + +// Type defines the type for the "type" enum field. +type Type string + +// Type values. +const ( + TypeText Type = "text" +) + +func (_type Type) String() string { + return string(_type) +} + +// TypeValidator is a validator for the "type" field enum values. It is called by the builders before save. +func TypeValidator(_type Type) error { + switch _type { + case TypeText: + return nil + default: + return fmt.Errorf("templatefield: invalid enum value for type field: %q", _type) + } +} + +// OrderOption defines the ordering options for the TemplateField queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdatedAt orders the results by the updated_at field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + +// ByType orders the results by the type field. +func ByType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldType, opts...).ToFunc() +} + +// ByTextValue orders the results by the text_value field. +func ByTextValue(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTextValue, opts...).ToFunc() +} + +// ByItemTemplateField orders the results by item_template field. +func ByItemTemplateField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newItemTemplateStep(), sql.OrderByField(field, opts...)) + } +} +func newItemTemplateStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ItemTemplateInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ItemTemplateTable, ItemTemplateColumn), + ) +} diff --git a/backend/internal/data/ent/templatefield/where.go b/backend/internal/data/ent/templatefield/where.go new file mode 100644 index 00000000..98021a2a --- /dev/null +++ b/backend/internal/data/ent/templatefield/where.go @@ -0,0 +1,435 @@ +// Code generated by ent, DO NOT EDIT. + +package templatefield + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id uuid.UUID) predicate.TemplateField { + return predicate.TemplateField(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uuid.UUID) predicate.TemplateField { + return predicate.TemplateField(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uuid.UUID) predicate.TemplateField { + return predicate.TemplateField(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uuid.UUID) predicate.TemplateField { + return predicate.TemplateField(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uuid.UUID) predicate.TemplateField { + return predicate.TemplateField(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uuid.UUID) predicate.TemplateField { + return predicate.TemplateField(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uuid.UUID) predicate.TemplateField { + return predicate.TemplateField(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uuid.UUID) predicate.TemplateField { + return predicate.TemplateField(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uuid.UUID) predicate.TemplateField { + return predicate.TemplateField(sql.FieldLTE(FieldID, id)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.TemplateField { + return predicate.TemplateField(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.TemplateField { + return predicate.TemplateField(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldEQ(FieldName, v)) +} + +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldEQ(FieldDescription, v)) +} + +// TextValue applies equality check predicate on the "text_value" field. It's identical to TextValueEQ. +func TextValue(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldEQ(FieldTextValue, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.TemplateField { + return predicate.TemplateField(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.TemplateField { + return predicate.TemplateField(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.TemplateField { + return predicate.TemplateField(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.TemplateField { + return predicate.TemplateField(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.TemplateField { + return predicate.TemplateField(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.TemplateField { + return predicate.TemplateField(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.TemplateField { + return predicate.TemplateField(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.TemplateField { + return predicate.TemplateField(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.TemplateField { + return predicate.TemplateField(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.TemplateField { + return predicate.TemplateField(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.TemplateField { + return predicate.TemplateField(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.TemplateField { + return predicate.TemplateField(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.TemplateField { + return predicate.TemplateField(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.TemplateField { + return predicate.TemplateField(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.TemplateField { + return predicate.TemplateField(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.TemplateField { + return predicate.TemplateField(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldContainsFold(FieldName, v)) +} + +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionIsNil applies the IsNil predicate on the "description" field. +func DescriptionIsNil() predicate.TemplateField { + return predicate.TemplateField(sql.FieldIsNull(FieldDescription)) +} + +// DescriptionNotNil applies the NotNil predicate on the "description" field. +func DescriptionNotNil() predicate.TemplateField { + return predicate.TemplateField(sql.FieldNotNull(FieldDescription)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldContainsFold(FieldDescription, v)) +} + +// TypeEQ applies the EQ predicate on the "type" field. +func TypeEQ(v Type) predicate.TemplateField { + return predicate.TemplateField(sql.FieldEQ(FieldType, v)) +} + +// TypeNEQ applies the NEQ predicate on the "type" field. +func TypeNEQ(v Type) predicate.TemplateField { + return predicate.TemplateField(sql.FieldNEQ(FieldType, v)) +} + +// TypeIn applies the In predicate on the "type" field. +func TypeIn(vs ...Type) predicate.TemplateField { + return predicate.TemplateField(sql.FieldIn(FieldType, vs...)) +} + +// TypeNotIn applies the NotIn predicate on the "type" field. +func TypeNotIn(vs ...Type) predicate.TemplateField { + return predicate.TemplateField(sql.FieldNotIn(FieldType, vs...)) +} + +// TextValueEQ applies the EQ predicate on the "text_value" field. +func TextValueEQ(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldEQ(FieldTextValue, v)) +} + +// TextValueNEQ applies the NEQ predicate on the "text_value" field. +func TextValueNEQ(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldNEQ(FieldTextValue, v)) +} + +// TextValueIn applies the In predicate on the "text_value" field. +func TextValueIn(vs ...string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldIn(FieldTextValue, vs...)) +} + +// TextValueNotIn applies the NotIn predicate on the "text_value" field. +func TextValueNotIn(vs ...string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldNotIn(FieldTextValue, vs...)) +} + +// TextValueGT applies the GT predicate on the "text_value" field. +func TextValueGT(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldGT(FieldTextValue, v)) +} + +// TextValueGTE applies the GTE predicate on the "text_value" field. +func TextValueGTE(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldGTE(FieldTextValue, v)) +} + +// TextValueLT applies the LT predicate on the "text_value" field. +func TextValueLT(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldLT(FieldTextValue, v)) +} + +// TextValueLTE applies the LTE predicate on the "text_value" field. +func TextValueLTE(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldLTE(FieldTextValue, v)) +} + +// TextValueContains applies the Contains predicate on the "text_value" field. +func TextValueContains(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldContains(FieldTextValue, v)) +} + +// TextValueHasPrefix applies the HasPrefix predicate on the "text_value" field. +func TextValueHasPrefix(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldHasPrefix(FieldTextValue, v)) +} + +// TextValueHasSuffix applies the HasSuffix predicate on the "text_value" field. +func TextValueHasSuffix(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldHasSuffix(FieldTextValue, v)) +} + +// TextValueIsNil applies the IsNil predicate on the "text_value" field. +func TextValueIsNil() predicate.TemplateField { + return predicate.TemplateField(sql.FieldIsNull(FieldTextValue)) +} + +// TextValueNotNil applies the NotNil predicate on the "text_value" field. +func TextValueNotNil() predicate.TemplateField { + return predicate.TemplateField(sql.FieldNotNull(FieldTextValue)) +} + +// TextValueEqualFold applies the EqualFold predicate on the "text_value" field. +func TextValueEqualFold(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldEqualFold(FieldTextValue, v)) +} + +// TextValueContainsFold applies the ContainsFold predicate on the "text_value" field. +func TextValueContainsFold(v string) predicate.TemplateField { + return predicate.TemplateField(sql.FieldContainsFold(FieldTextValue, v)) +} + +// HasItemTemplate applies the HasEdge predicate on the "item_template" edge. +func HasItemTemplate() predicate.TemplateField { + return predicate.TemplateField(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ItemTemplateTable, ItemTemplateColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasItemTemplateWith applies the HasEdge predicate on the "item_template" edge with a given conditions (other predicates). +func HasItemTemplateWith(preds ...predicate.ItemTemplate) predicate.TemplateField { + return predicate.TemplateField(func(s *sql.Selector) { + step := newItemTemplateStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.TemplateField) predicate.TemplateField { + return predicate.TemplateField(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.TemplateField) predicate.TemplateField { + return predicate.TemplateField(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.TemplateField) predicate.TemplateField { + return predicate.TemplateField(sql.NotPredicates(p)) +} diff --git a/backend/internal/data/ent/templatefield_create.go b/backend/internal/data/ent/templatefield_create.go new file mode 100644 index 00000000..fa42ba87 --- /dev/null +++ b/backend/internal/data/ent/templatefield_create.go @@ -0,0 +1,370 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield" +) + +// TemplateFieldCreate is the builder for creating a TemplateField entity. +type TemplateFieldCreate struct { + config + mutation *TemplateFieldMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (_c *TemplateFieldCreate) SetCreatedAt(v time.Time) *TemplateFieldCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *TemplateFieldCreate) SetNillableCreatedAt(v *time.Time) *TemplateFieldCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *TemplateFieldCreate) SetUpdatedAt(v time.Time) *TemplateFieldCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *TemplateFieldCreate) SetNillableUpdatedAt(v *time.Time) *TemplateFieldCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetName sets the "name" field. +func (_c *TemplateFieldCreate) SetName(v string) *TemplateFieldCreate { + _c.mutation.SetName(v) + return _c +} + +// SetDescription sets the "description" field. +func (_c *TemplateFieldCreate) SetDescription(v string) *TemplateFieldCreate { + _c.mutation.SetDescription(v) + return _c +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_c *TemplateFieldCreate) SetNillableDescription(v *string) *TemplateFieldCreate { + if v != nil { + _c.SetDescription(*v) + } + return _c +} + +// SetType sets the "type" field. +func (_c *TemplateFieldCreate) SetType(v templatefield.Type) *TemplateFieldCreate { + _c.mutation.SetType(v) + return _c +} + +// SetTextValue sets the "text_value" field. +func (_c *TemplateFieldCreate) SetTextValue(v string) *TemplateFieldCreate { + _c.mutation.SetTextValue(v) + return _c +} + +// SetNillableTextValue sets the "text_value" field if the given value is not nil. +func (_c *TemplateFieldCreate) SetNillableTextValue(v *string) *TemplateFieldCreate { + if v != nil { + _c.SetTextValue(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *TemplateFieldCreate) SetID(v uuid.UUID) *TemplateFieldCreate { + _c.mutation.SetID(v) + return _c +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (_c *TemplateFieldCreate) SetNillableID(v *uuid.UUID) *TemplateFieldCreate { + if v != nil { + _c.SetID(*v) + } + return _c +} + +// SetItemTemplateID sets the "item_template" edge to the ItemTemplate entity by ID. +func (_c *TemplateFieldCreate) SetItemTemplateID(id uuid.UUID) *TemplateFieldCreate { + _c.mutation.SetItemTemplateID(id) + return _c +} + +// SetNillableItemTemplateID sets the "item_template" edge to the ItemTemplate entity by ID if the given value is not nil. +func (_c *TemplateFieldCreate) SetNillableItemTemplateID(id *uuid.UUID) *TemplateFieldCreate { + if id != nil { + _c = _c.SetItemTemplateID(*id) + } + return _c +} + +// SetItemTemplate sets the "item_template" edge to the ItemTemplate entity. +func (_c *TemplateFieldCreate) SetItemTemplate(v *ItemTemplate) *TemplateFieldCreate { + return _c.SetItemTemplateID(v.ID) +} + +// Mutation returns the TemplateFieldMutation object of the builder. +func (_c *TemplateFieldCreate) Mutation() *TemplateFieldMutation { + return _c.mutation +} + +// Save creates the TemplateField in the database. +func (_c *TemplateFieldCreate) Save(ctx context.Context) (*TemplateField, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *TemplateFieldCreate) SaveX(ctx context.Context) *TemplateField { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *TemplateFieldCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *TemplateFieldCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *TemplateFieldCreate) defaults() { + if _, ok := _c.mutation.CreatedAt(); !ok { + v := templatefield.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := templatefield.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.ID(); !ok { + v := templatefield.DefaultID() + _c.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *TemplateFieldCreate) check() error { + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "TemplateField.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "TemplateField.updated_at"`)} + } + if _, ok := _c.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "TemplateField.name"`)} + } + if v, ok := _c.mutation.Name(); ok { + if err := templatefield.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "TemplateField.name": %w`, err)} + } + } + if v, ok := _c.mutation.Description(); ok { + if err := templatefield.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "TemplateField.description": %w`, err)} + } + } + if _, ok := _c.mutation.GetType(); !ok { + return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "TemplateField.type"`)} + } + if v, ok := _c.mutation.GetType(); ok { + if err := templatefield.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "TemplateField.type": %w`, err)} + } + } + if v, ok := _c.mutation.TextValue(); ok { + if err := templatefield.TextValueValidator(v); err != nil { + return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "TemplateField.text_value": %w`, err)} + } + } + return nil +} + +func (_c *TemplateFieldCreate) sqlSave(ctx context.Context) (*TemplateField, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *TemplateFieldCreate) createSpec() (*TemplateField, *sqlgraph.CreateSpec) { + var ( + _node = &TemplateField{config: _c.config} + _spec = sqlgraph.NewCreateSpec(templatefield.Table, sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(templatefield.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(templatefield.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := _c.mutation.Name(); ok { + _spec.SetField(templatefield.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := _c.mutation.Description(); ok { + _spec.SetField(templatefield.FieldDescription, field.TypeString, value) + _node.Description = value + } + if value, ok := _c.mutation.GetType(); ok { + _spec.SetField(templatefield.FieldType, field.TypeEnum, value) + _node.Type = value + } + if value, ok := _c.mutation.TextValue(); ok { + _spec.SetField(templatefield.FieldTextValue, field.TypeString, value) + _node.TextValue = value + } + if nodes := _c.mutation.ItemTemplateIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: templatefield.ItemTemplateTable, + Columns: []string{templatefield.ItemTemplateColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.item_template_fields = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// TemplateFieldCreateBulk is the builder for creating many TemplateField entities in bulk. +type TemplateFieldCreateBulk struct { + config + err error + builders []*TemplateFieldCreate +} + +// Save creates the TemplateField entities in the database. +func (_c *TemplateFieldCreateBulk) Save(ctx context.Context) ([]*TemplateField, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*TemplateField, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*TemplateFieldMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *TemplateFieldCreateBulk) SaveX(ctx context.Context) []*TemplateField { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *TemplateFieldCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *TemplateFieldCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/internal/data/ent/templatefield_delete.go b/backend/internal/data/ent/templatefield_delete.go new file mode 100644 index 00000000..4e2df011 --- /dev/null +++ b/backend/internal/data/ent/templatefield_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield" +) + +// TemplateFieldDelete is the builder for deleting a TemplateField entity. +type TemplateFieldDelete struct { + config + hooks []Hook + mutation *TemplateFieldMutation +} + +// Where appends a list predicates to the TemplateFieldDelete builder. +func (_d *TemplateFieldDelete) Where(ps ...predicate.TemplateField) *TemplateFieldDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *TemplateFieldDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *TemplateFieldDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *TemplateFieldDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(templatefield.Table, sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// TemplateFieldDeleteOne is the builder for deleting a single TemplateField entity. +type TemplateFieldDeleteOne struct { + _d *TemplateFieldDelete +} + +// Where appends a list predicates to the TemplateFieldDelete builder. +func (_d *TemplateFieldDeleteOne) Where(ps ...predicate.TemplateField) *TemplateFieldDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *TemplateFieldDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{templatefield.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *TemplateFieldDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/internal/data/ent/templatefield_query.go b/backend/internal/data/ent/templatefield_query.go new file mode 100644 index 00000000..7cf4aa2a --- /dev/null +++ b/backend/internal/data/ent/templatefield_query.go @@ -0,0 +1,615 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield" +) + +// TemplateFieldQuery is the builder for querying TemplateField entities. +type TemplateFieldQuery struct { + config + ctx *QueryContext + order []templatefield.OrderOption + inters []Interceptor + predicates []predicate.TemplateField + withItemTemplate *ItemTemplateQuery + withFKs bool + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the TemplateFieldQuery builder. +func (_q *TemplateFieldQuery) Where(ps ...predicate.TemplateField) *TemplateFieldQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *TemplateFieldQuery) Limit(limit int) *TemplateFieldQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *TemplateFieldQuery) Offset(offset int) *TemplateFieldQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *TemplateFieldQuery) Unique(unique bool) *TemplateFieldQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *TemplateFieldQuery) Order(o ...templatefield.OrderOption) *TemplateFieldQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryItemTemplate chains the current query on the "item_template" edge. +func (_q *TemplateFieldQuery) QueryItemTemplate() *ItemTemplateQuery { + query := (&ItemTemplateClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(templatefield.Table, templatefield.FieldID, selector), + sqlgraph.To(itemtemplate.Table, itemtemplate.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, templatefield.ItemTemplateTable, templatefield.ItemTemplateColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first TemplateField entity from the query. +// Returns a *NotFoundError when no TemplateField was found. +func (_q *TemplateFieldQuery) First(ctx context.Context) (*TemplateField, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{templatefield.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *TemplateFieldQuery) FirstX(ctx context.Context) *TemplateField { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first TemplateField ID from the query. +// Returns a *NotFoundError when no TemplateField ID was found. +func (_q *TemplateFieldQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{templatefield.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *TemplateFieldQuery) FirstIDX(ctx context.Context) uuid.UUID { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single TemplateField entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one TemplateField entity is found. +// Returns a *NotFoundError when no TemplateField entities are found. +func (_q *TemplateFieldQuery) Only(ctx context.Context) (*TemplateField, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{templatefield.Label} + default: + return nil, &NotSingularError{templatefield.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *TemplateFieldQuery) OnlyX(ctx context.Context) *TemplateField { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only TemplateField ID in the query. +// Returns a *NotSingularError when more than one TemplateField ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *TemplateFieldQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{templatefield.Label} + default: + err = &NotSingularError{templatefield.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *TemplateFieldQuery) OnlyIDX(ctx context.Context) uuid.UUID { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of TemplateFields. +func (_q *TemplateFieldQuery) All(ctx context.Context) ([]*TemplateField, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*TemplateField, *TemplateFieldQuery]() + return withInterceptors[[]*TemplateField](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *TemplateFieldQuery) AllX(ctx context.Context) []*TemplateField { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of TemplateField IDs. +func (_q *TemplateFieldQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(templatefield.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *TemplateFieldQuery) IDsX(ctx context.Context) []uuid.UUID { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *TemplateFieldQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*TemplateFieldQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *TemplateFieldQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *TemplateFieldQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *TemplateFieldQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the TemplateFieldQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *TemplateFieldQuery) Clone() *TemplateFieldQuery { + if _q == nil { + return nil + } + return &TemplateFieldQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]templatefield.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.TemplateField{}, _q.predicates...), + withItemTemplate: _q.withItemTemplate.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// WithItemTemplate tells the query-builder to eager-load the nodes that are connected to +// the "item_template" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *TemplateFieldQuery) WithItemTemplate(opts ...func(*ItemTemplateQuery)) *TemplateFieldQuery { + query := (&ItemTemplateClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withItemTemplate = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.TemplateField.Query(). +// GroupBy(templatefield.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *TemplateFieldQuery) GroupBy(field string, fields ...string) *TemplateFieldGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &TemplateFieldGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = templatefield.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.TemplateField.Query(). +// Select(templatefield.FieldCreatedAt). +// Scan(ctx, &v) +func (_q *TemplateFieldQuery) Select(fields ...string) *TemplateFieldSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &TemplateFieldSelect{TemplateFieldQuery: _q} + sbuild.label = templatefield.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a TemplateFieldSelect configured with the given aggregations. +func (_q *TemplateFieldQuery) Aggregate(fns ...AggregateFunc) *TemplateFieldSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *TemplateFieldQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !templatefield.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *TemplateFieldQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*TemplateField, error) { + var ( + nodes = []*TemplateField{} + withFKs = _q.withFKs + _spec = _q.querySpec() + loadedTypes = [1]bool{ + _q.withItemTemplate != nil, + } + ) + if _q.withItemTemplate != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, templatefield.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*TemplateField).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &TemplateField{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withItemTemplate; query != nil { + if err := _q.loadItemTemplate(ctx, query, nodes, nil, + func(n *TemplateField, e *ItemTemplate) { n.Edges.ItemTemplate = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *TemplateFieldQuery) loadItemTemplate(ctx context.Context, query *ItemTemplateQuery, nodes []*TemplateField, init func(*TemplateField), assign func(*TemplateField, *ItemTemplate)) error { + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*TemplateField) + for i := range nodes { + if nodes[i].item_template_fields == nil { + continue + } + fk := *nodes[i].item_template_fields + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(itemtemplate.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "item_template_fields" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (_q *TemplateFieldQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *TemplateFieldQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(templatefield.Table, templatefield.Columns, sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, templatefield.FieldID) + for i := range fields { + if fields[i] != templatefield.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *TemplateFieldQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(templatefield.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = templatefield.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// TemplateFieldGroupBy is the group-by builder for TemplateField entities. +type TemplateFieldGroupBy struct { + selector + build *TemplateFieldQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *TemplateFieldGroupBy) Aggregate(fns ...AggregateFunc) *TemplateFieldGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *TemplateFieldGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*TemplateFieldQuery, *TemplateFieldGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *TemplateFieldGroupBy) sqlScan(ctx context.Context, root *TemplateFieldQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// TemplateFieldSelect is the builder for selecting fields of TemplateField entities. +type TemplateFieldSelect struct { + *TemplateFieldQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *TemplateFieldSelect) Aggregate(fns ...AggregateFunc) *TemplateFieldSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *TemplateFieldSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*TemplateFieldQuery, *TemplateFieldSelect](ctx, _s.TemplateFieldQuery, _s, _s.inters, v) +} + +func (_s *TemplateFieldSelect) sqlScan(ctx context.Context, root *TemplateFieldQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/backend/internal/data/ent/templatefield_update.go b/backend/internal/data/ent/templatefield_update.go new file mode 100644 index 00000000..521659c0 --- /dev/null +++ b/backend/internal/data/ent/templatefield_update.go @@ -0,0 +1,550 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/google/uuid" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield" +) + +// TemplateFieldUpdate is the builder for updating TemplateField entities. +type TemplateFieldUpdate struct { + config + hooks []Hook + mutation *TemplateFieldMutation +} + +// Where appends a list predicates to the TemplateFieldUpdate builder. +func (_u *TemplateFieldUpdate) Where(ps ...predicate.TemplateField) *TemplateFieldUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *TemplateFieldUpdate) SetUpdatedAt(v time.Time) *TemplateFieldUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetName sets the "name" field. +func (_u *TemplateFieldUpdate) SetName(v string) *TemplateFieldUpdate { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *TemplateFieldUpdate) SetNillableName(v *string) *TemplateFieldUpdate { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetDescription sets the "description" field. +func (_u *TemplateFieldUpdate) SetDescription(v string) *TemplateFieldUpdate { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *TemplateFieldUpdate) SetNillableDescription(v *string) *TemplateFieldUpdate { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// ClearDescription clears the value of the "description" field. +func (_u *TemplateFieldUpdate) ClearDescription() *TemplateFieldUpdate { + _u.mutation.ClearDescription() + return _u +} + +// SetType sets the "type" field. +func (_u *TemplateFieldUpdate) SetType(v templatefield.Type) *TemplateFieldUpdate { + _u.mutation.SetType(v) + return _u +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_u *TemplateFieldUpdate) SetNillableType(v *templatefield.Type) *TemplateFieldUpdate { + if v != nil { + _u.SetType(*v) + } + return _u +} + +// SetTextValue sets the "text_value" field. +func (_u *TemplateFieldUpdate) SetTextValue(v string) *TemplateFieldUpdate { + _u.mutation.SetTextValue(v) + return _u +} + +// SetNillableTextValue sets the "text_value" field if the given value is not nil. +func (_u *TemplateFieldUpdate) SetNillableTextValue(v *string) *TemplateFieldUpdate { + if v != nil { + _u.SetTextValue(*v) + } + return _u +} + +// ClearTextValue clears the value of the "text_value" field. +func (_u *TemplateFieldUpdate) ClearTextValue() *TemplateFieldUpdate { + _u.mutation.ClearTextValue() + return _u +} + +// SetItemTemplateID sets the "item_template" edge to the ItemTemplate entity by ID. +func (_u *TemplateFieldUpdate) SetItemTemplateID(id uuid.UUID) *TemplateFieldUpdate { + _u.mutation.SetItemTemplateID(id) + return _u +} + +// SetNillableItemTemplateID sets the "item_template" edge to the ItemTemplate entity by ID if the given value is not nil. +func (_u *TemplateFieldUpdate) SetNillableItemTemplateID(id *uuid.UUID) *TemplateFieldUpdate { + if id != nil { + _u = _u.SetItemTemplateID(*id) + } + return _u +} + +// SetItemTemplate sets the "item_template" edge to the ItemTemplate entity. +func (_u *TemplateFieldUpdate) SetItemTemplate(v *ItemTemplate) *TemplateFieldUpdate { + return _u.SetItemTemplateID(v.ID) +} + +// Mutation returns the TemplateFieldMutation object of the builder. +func (_u *TemplateFieldUpdate) Mutation() *TemplateFieldMutation { + return _u.mutation +} + +// ClearItemTemplate clears the "item_template" edge to the ItemTemplate entity. +func (_u *TemplateFieldUpdate) ClearItemTemplate() *TemplateFieldUpdate { + _u.mutation.ClearItemTemplate() + return _u +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *TemplateFieldUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *TemplateFieldUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *TemplateFieldUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *TemplateFieldUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *TemplateFieldUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := templatefield.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *TemplateFieldUpdate) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := templatefield.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "TemplateField.name": %w`, err)} + } + } + if v, ok := _u.mutation.Description(); ok { + if err := templatefield.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "TemplateField.description": %w`, err)} + } + } + if v, ok := _u.mutation.GetType(); ok { + if err := templatefield.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "TemplateField.type": %w`, err)} + } + } + if v, ok := _u.mutation.TextValue(); ok { + if err := templatefield.TextValueValidator(v); err != nil { + return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "TemplateField.text_value": %w`, err)} + } + } + return nil +} + +func (_u *TemplateFieldUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(templatefield.Table, templatefield.Columns, sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(templatefield.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(templatefield.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(templatefield.FieldDescription, field.TypeString, value) + } + if _u.mutation.DescriptionCleared() { + _spec.ClearField(templatefield.FieldDescription, field.TypeString) + } + if value, ok := _u.mutation.GetType(); ok { + _spec.SetField(templatefield.FieldType, field.TypeEnum, value) + } + if value, ok := _u.mutation.TextValue(); ok { + _spec.SetField(templatefield.FieldTextValue, field.TypeString, value) + } + if _u.mutation.TextValueCleared() { + _spec.ClearField(templatefield.FieldTextValue, field.TypeString) + } + if _u.mutation.ItemTemplateCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: templatefield.ItemTemplateTable, + Columns: []string{templatefield.ItemTemplateColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ItemTemplateIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: templatefield.ItemTemplateTable, + Columns: []string{templatefield.ItemTemplateColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{templatefield.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// TemplateFieldUpdateOne is the builder for updating a single TemplateField entity. +type TemplateFieldUpdateOne struct { + config + fields []string + hooks []Hook + mutation *TemplateFieldMutation +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *TemplateFieldUpdateOne) SetUpdatedAt(v time.Time) *TemplateFieldUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetName sets the "name" field. +func (_u *TemplateFieldUpdateOne) SetName(v string) *TemplateFieldUpdateOne { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *TemplateFieldUpdateOne) SetNillableName(v *string) *TemplateFieldUpdateOne { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetDescription sets the "description" field. +func (_u *TemplateFieldUpdateOne) SetDescription(v string) *TemplateFieldUpdateOne { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *TemplateFieldUpdateOne) SetNillableDescription(v *string) *TemplateFieldUpdateOne { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// ClearDescription clears the value of the "description" field. +func (_u *TemplateFieldUpdateOne) ClearDescription() *TemplateFieldUpdateOne { + _u.mutation.ClearDescription() + return _u +} + +// SetType sets the "type" field. +func (_u *TemplateFieldUpdateOne) SetType(v templatefield.Type) *TemplateFieldUpdateOne { + _u.mutation.SetType(v) + return _u +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_u *TemplateFieldUpdateOne) SetNillableType(v *templatefield.Type) *TemplateFieldUpdateOne { + if v != nil { + _u.SetType(*v) + } + return _u +} + +// SetTextValue sets the "text_value" field. +func (_u *TemplateFieldUpdateOne) SetTextValue(v string) *TemplateFieldUpdateOne { + _u.mutation.SetTextValue(v) + return _u +} + +// SetNillableTextValue sets the "text_value" field if the given value is not nil. +func (_u *TemplateFieldUpdateOne) SetNillableTextValue(v *string) *TemplateFieldUpdateOne { + if v != nil { + _u.SetTextValue(*v) + } + return _u +} + +// ClearTextValue clears the value of the "text_value" field. +func (_u *TemplateFieldUpdateOne) ClearTextValue() *TemplateFieldUpdateOne { + _u.mutation.ClearTextValue() + return _u +} + +// SetItemTemplateID sets the "item_template" edge to the ItemTemplate entity by ID. +func (_u *TemplateFieldUpdateOne) SetItemTemplateID(id uuid.UUID) *TemplateFieldUpdateOne { + _u.mutation.SetItemTemplateID(id) + return _u +} + +// SetNillableItemTemplateID sets the "item_template" edge to the ItemTemplate entity by ID if the given value is not nil. +func (_u *TemplateFieldUpdateOne) SetNillableItemTemplateID(id *uuid.UUID) *TemplateFieldUpdateOne { + if id != nil { + _u = _u.SetItemTemplateID(*id) + } + return _u +} + +// SetItemTemplate sets the "item_template" edge to the ItemTemplate entity. +func (_u *TemplateFieldUpdateOne) SetItemTemplate(v *ItemTemplate) *TemplateFieldUpdateOne { + return _u.SetItemTemplateID(v.ID) +} + +// Mutation returns the TemplateFieldMutation object of the builder. +func (_u *TemplateFieldUpdateOne) Mutation() *TemplateFieldMutation { + return _u.mutation +} + +// ClearItemTemplate clears the "item_template" edge to the ItemTemplate entity. +func (_u *TemplateFieldUpdateOne) ClearItemTemplate() *TemplateFieldUpdateOne { + _u.mutation.ClearItemTemplate() + return _u +} + +// Where appends a list predicates to the TemplateFieldUpdate builder. +func (_u *TemplateFieldUpdateOne) Where(ps ...predicate.TemplateField) *TemplateFieldUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *TemplateFieldUpdateOne) Select(field string, fields ...string) *TemplateFieldUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated TemplateField entity. +func (_u *TemplateFieldUpdateOne) Save(ctx context.Context) (*TemplateField, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *TemplateFieldUpdateOne) SaveX(ctx context.Context) *TemplateField { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *TemplateFieldUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *TemplateFieldUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *TemplateFieldUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := templatefield.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *TemplateFieldUpdateOne) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := templatefield.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "TemplateField.name": %w`, err)} + } + } + if v, ok := _u.mutation.Description(); ok { + if err := templatefield.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "TemplateField.description": %w`, err)} + } + } + if v, ok := _u.mutation.GetType(); ok { + if err := templatefield.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "TemplateField.type": %w`, err)} + } + } + if v, ok := _u.mutation.TextValue(); ok { + if err := templatefield.TextValueValidator(v); err != nil { + return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "TemplateField.text_value": %w`, err)} + } + } + return nil +} + +func (_u *TemplateFieldUpdateOne) sqlSave(ctx context.Context) (_node *TemplateField, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(templatefield.Table, templatefield.Columns, sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "TemplateField.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, templatefield.FieldID) + for _, f := range fields { + if !templatefield.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != templatefield.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(templatefield.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(templatefield.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(templatefield.FieldDescription, field.TypeString, value) + } + if _u.mutation.DescriptionCleared() { + _spec.ClearField(templatefield.FieldDescription, field.TypeString) + } + if value, ok := _u.mutation.GetType(); ok { + _spec.SetField(templatefield.FieldType, field.TypeEnum, value) + } + if value, ok := _u.mutation.TextValue(); ok { + _spec.SetField(templatefield.FieldTextValue, field.TypeString, value) + } + if _u.mutation.TextValueCleared() { + _spec.ClearField(templatefield.FieldTextValue, field.TypeString) + } + if _u.mutation.ItemTemplateCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: templatefield.ItemTemplateTable, + Columns: []string{templatefield.ItemTemplateColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ItemTemplateIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: templatefield.ItemTemplateTable, + Columns: []string{templatefield.ItemTemplateColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &TemplateField{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{templatefield.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/backend/internal/data/ent/tx.go b/backend/internal/data/ent/tx.go index 90dfae46..f8561a0b 100644 --- a/backend/internal/data/ent/tx.go +++ b/backend/internal/data/ent/tx.go @@ -18,22 +18,26 @@ type Tx struct { AuthRoles *AuthRolesClient // AuthTokens is the client for interacting with the AuthTokens builders. AuthTokens *AuthTokensClient - // Entity is the client for interacting with the Entity builders. - Entity *EntityClient - // EntityField is the client for interacting with the EntityField builders. - EntityField *EntityFieldClient - // EntityType is the client for interacting with the EntityType builders. - EntityType *EntityTypeClient // Group is the client for interacting with the Group builders. Group *GroupClient // GroupInvitationToken is the client for interacting with the GroupInvitationToken builders. GroupInvitationToken *GroupInvitationTokenClient + // Item is the client for interacting with the Item builders. + Item *ItemClient + // ItemField is the client for interacting with the ItemField builders. + ItemField *ItemFieldClient + // ItemTemplate is the client for interacting with the ItemTemplate builders. + ItemTemplate *ItemTemplateClient // Label is the client for interacting with the Label builders. Label *LabelClient + // Location is the client for interacting with the Location builders. + Location *LocationClient // MaintenanceEntry is the client for interacting with the MaintenanceEntry builders. MaintenanceEntry *MaintenanceEntryClient // Notifier is the client for interacting with the Notifier builders. Notifier *NotifierClient + // TemplateField is the client for interacting with the TemplateField builders. + TemplateField *TemplateFieldClient // User is the client for interacting with the User builders. User *UserClient @@ -170,14 +174,16 @@ func (tx *Tx) init() { tx.Attachment = NewAttachmentClient(tx.config) tx.AuthRoles = NewAuthRolesClient(tx.config) tx.AuthTokens = NewAuthTokensClient(tx.config) - tx.Entity = NewEntityClient(tx.config) - tx.EntityField = NewEntityFieldClient(tx.config) - tx.EntityType = NewEntityTypeClient(tx.config) tx.Group = NewGroupClient(tx.config) tx.GroupInvitationToken = NewGroupInvitationTokenClient(tx.config) + tx.Item = NewItemClient(tx.config) + tx.ItemField = NewItemFieldClient(tx.config) + tx.ItemTemplate = NewItemTemplateClient(tx.config) tx.Label = NewLabelClient(tx.config) + tx.Location = NewLocationClient(tx.config) tx.MaintenanceEntry = NewMaintenanceEntryClient(tx.config) tx.Notifier = NewNotifierClient(tx.config) + tx.TemplateField = NewTemplateFieldClient(tx.config) tx.User = NewUserClient(tx.config) } diff --git a/backend/internal/data/ent/user.go b/backend/internal/data/ent/user.go index 2940a33c..9d7d4866 100644 --- a/backend/internal/data/ent/user.go +++ b/backend/internal/data/ent/user.go @@ -28,7 +28,7 @@ type User struct { // Email holds the value of the "email" field. Email string `json:"email,omitempty"` // Password holds the value of the "password" field. - Password string `json:"-"` + Password *string `json:"-"` // IsSuperuser holds the value of the "is_superuser" field. IsSuperuser bool `json:"is_superuser,omitempty"` // Superuser holds the value of the "superuser" field. @@ -37,6 +37,10 @@ type User struct { Role user.Role `json:"role,omitempty"` // ActivatedOn holds the value of the "activated_on" field. ActivatedOn time.Time `json:"activated_on,omitempty"` + // OidcIssuer holds the value of the "oidc_issuer" field. + OidcIssuer *string `json:"oidc_issuer,omitempty"` + // OidcSubject holds the value of the "oidc_subject" field. + OidcSubject *string `json:"oidc_subject,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the UserQuery when eager-loading is set. Edges UserEdges `json:"edges"` @@ -93,7 +97,7 @@ func (*User) scanValues(columns []string) ([]any, error) { switch columns[i] { case user.FieldIsSuperuser, user.FieldSuperuser: values[i] = new(sql.NullBool) - case user.FieldName, user.FieldEmail, user.FieldPassword, user.FieldRole: + case user.FieldName, user.FieldEmail, user.FieldPassword, user.FieldRole, user.FieldOidcIssuer, user.FieldOidcSubject: values[i] = new(sql.NullString) case user.FieldCreatedAt, user.FieldUpdatedAt, user.FieldActivatedOn: values[i] = new(sql.NullTime) @@ -150,7 +154,8 @@ func (_m *User) assignValues(columns []string, values []any) error { if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field password", values[i]) } else if value.Valid { - _m.Password = value.String + _m.Password = new(string) + *_m.Password = value.String } case user.FieldIsSuperuser: if value, ok := values[i].(*sql.NullBool); !ok { @@ -176,6 +181,20 @@ func (_m *User) assignValues(columns []string, values []any) error { } else if value.Valid { _m.ActivatedOn = value.Time } + case user.FieldOidcIssuer: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field oidc_issuer", values[i]) + } else if value.Valid { + _m.OidcIssuer = new(string) + *_m.OidcIssuer = value.String + } + case user.FieldOidcSubject: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field oidc_subject", values[i]) + } else if value.Valid { + _m.OidcSubject = new(string) + *_m.OidcSubject = value.String + } case user.ForeignKeys[0]: if value, ok := values[i].(*sql.NullScanner); !ok { return fmt.Errorf("unexpected type %T for field group_users", values[i]) @@ -259,6 +278,16 @@ func (_m *User) String() string { builder.WriteString(", ") builder.WriteString("activated_on=") builder.WriteString(_m.ActivatedOn.Format(time.ANSIC)) + builder.WriteString(", ") + if v := _m.OidcIssuer; v != nil { + builder.WriteString("oidc_issuer=") + builder.WriteString(*v) + } + builder.WriteString(", ") + if v := _m.OidcSubject; v != nil { + builder.WriteString("oidc_subject=") + builder.WriteString(*v) + } builder.WriteByte(')') return builder.String() } diff --git a/backend/internal/data/ent/user/user.go b/backend/internal/data/ent/user/user.go index 33b657bd..473d1d7f 100644 --- a/backend/internal/data/ent/user/user.go +++ b/backend/internal/data/ent/user/user.go @@ -34,6 +34,10 @@ const ( FieldRole = "role" // FieldActivatedOn holds the string denoting the activated_on field in the database. FieldActivatedOn = "activated_on" + // FieldOidcIssuer holds the string denoting the oidc_issuer field in the database. + FieldOidcIssuer = "oidc_issuer" + // FieldOidcSubject holds the string denoting the oidc_subject field in the database. + FieldOidcSubject = "oidc_subject" // EdgeGroup holds the string denoting the group edge name in mutations. EdgeGroup = "group" // EdgeAuthTokens holds the string denoting the auth_tokens edge name in mutations. @@ -77,6 +81,8 @@ var Columns = []string{ FieldSuperuser, FieldRole, FieldActivatedOn, + FieldOidcIssuer, + FieldOidcSubject, } // ForeignKeys holds the SQL foreign-keys that are owned by the "users" @@ -200,6 +206,16 @@ func ByActivatedOn(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldActivatedOn, opts...).ToFunc() } +// ByOidcIssuer orders the results by the oidc_issuer field. +func ByOidcIssuer(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOidcIssuer, opts...).ToFunc() +} + +// ByOidcSubject orders the results by the oidc_subject field. +func ByOidcSubject(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOidcSubject, opts...).ToFunc() +} + // ByGroupField orders the results by group field. func ByGroupField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { diff --git a/backend/internal/data/ent/user/where.go b/backend/internal/data/ent/user/where.go index f70676bc..0d4ed5cd 100644 --- a/backend/internal/data/ent/user/where.go +++ b/backend/internal/data/ent/user/where.go @@ -96,6 +96,16 @@ func ActivatedOn(v time.Time) predicate.User { return predicate.User(sql.FieldEQ(FieldActivatedOn, v)) } +// OidcIssuer applies equality check predicate on the "oidc_issuer" field. It's identical to OidcIssuerEQ. +func OidcIssuer(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldOidcIssuer, v)) +} + +// OidcSubject applies equality check predicate on the "oidc_subject" field. It's identical to OidcSubjectEQ. +func OidcSubject(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldOidcSubject, v)) +} + // CreatedAtEQ applies the EQ predicate on the "created_at" field. func CreatedAtEQ(v time.Time) predicate.User { return predicate.User(sql.FieldEQ(FieldCreatedAt, v)) @@ -361,6 +371,16 @@ func PasswordHasSuffix(v string) predicate.User { return predicate.User(sql.FieldHasSuffix(FieldPassword, v)) } +// PasswordIsNil applies the IsNil predicate on the "password" field. +func PasswordIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldPassword)) +} + +// PasswordNotNil applies the NotNil predicate on the "password" field. +func PasswordNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldPassword)) +} + // PasswordEqualFold applies the EqualFold predicate on the "password" field. func PasswordEqualFold(v string) predicate.User { return predicate.User(sql.FieldEqualFold(FieldPassword, v)) @@ -461,6 +481,156 @@ func ActivatedOnNotNil() predicate.User { return predicate.User(sql.FieldNotNull(FieldActivatedOn)) } +// OidcIssuerEQ applies the EQ predicate on the "oidc_issuer" field. +func OidcIssuerEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldOidcIssuer, v)) +} + +// OidcIssuerNEQ applies the NEQ predicate on the "oidc_issuer" field. +func OidcIssuerNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldOidcIssuer, v)) +} + +// OidcIssuerIn applies the In predicate on the "oidc_issuer" field. +func OidcIssuerIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldOidcIssuer, vs...)) +} + +// OidcIssuerNotIn applies the NotIn predicate on the "oidc_issuer" field. +func OidcIssuerNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldOidcIssuer, vs...)) +} + +// OidcIssuerGT applies the GT predicate on the "oidc_issuer" field. +func OidcIssuerGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldOidcIssuer, v)) +} + +// OidcIssuerGTE applies the GTE predicate on the "oidc_issuer" field. +func OidcIssuerGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldOidcIssuer, v)) +} + +// OidcIssuerLT applies the LT predicate on the "oidc_issuer" field. +func OidcIssuerLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldOidcIssuer, v)) +} + +// OidcIssuerLTE applies the LTE predicate on the "oidc_issuer" field. +func OidcIssuerLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldOidcIssuer, v)) +} + +// OidcIssuerContains applies the Contains predicate on the "oidc_issuer" field. +func OidcIssuerContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldOidcIssuer, v)) +} + +// OidcIssuerHasPrefix applies the HasPrefix predicate on the "oidc_issuer" field. +func OidcIssuerHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldOidcIssuer, v)) +} + +// OidcIssuerHasSuffix applies the HasSuffix predicate on the "oidc_issuer" field. +func OidcIssuerHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldOidcIssuer, v)) +} + +// OidcIssuerIsNil applies the IsNil predicate on the "oidc_issuer" field. +func OidcIssuerIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldOidcIssuer)) +} + +// OidcIssuerNotNil applies the NotNil predicate on the "oidc_issuer" field. +func OidcIssuerNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldOidcIssuer)) +} + +// OidcIssuerEqualFold applies the EqualFold predicate on the "oidc_issuer" field. +func OidcIssuerEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldOidcIssuer, v)) +} + +// OidcIssuerContainsFold applies the ContainsFold predicate on the "oidc_issuer" field. +func OidcIssuerContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldOidcIssuer, v)) +} + +// OidcSubjectEQ applies the EQ predicate on the "oidc_subject" field. +func OidcSubjectEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldOidcSubject, v)) +} + +// OidcSubjectNEQ applies the NEQ predicate on the "oidc_subject" field. +func OidcSubjectNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldOidcSubject, v)) +} + +// OidcSubjectIn applies the In predicate on the "oidc_subject" field. +func OidcSubjectIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldOidcSubject, vs...)) +} + +// OidcSubjectNotIn applies the NotIn predicate on the "oidc_subject" field. +func OidcSubjectNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldOidcSubject, vs...)) +} + +// OidcSubjectGT applies the GT predicate on the "oidc_subject" field. +func OidcSubjectGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldOidcSubject, v)) +} + +// OidcSubjectGTE applies the GTE predicate on the "oidc_subject" field. +func OidcSubjectGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldOidcSubject, v)) +} + +// OidcSubjectLT applies the LT predicate on the "oidc_subject" field. +func OidcSubjectLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldOidcSubject, v)) +} + +// OidcSubjectLTE applies the LTE predicate on the "oidc_subject" field. +func OidcSubjectLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldOidcSubject, v)) +} + +// OidcSubjectContains applies the Contains predicate on the "oidc_subject" field. +func OidcSubjectContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldOidcSubject, v)) +} + +// OidcSubjectHasPrefix applies the HasPrefix predicate on the "oidc_subject" field. +func OidcSubjectHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldOidcSubject, v)) +} + +// OidcSubjectHasSuffix applies the HasSuffix predicate on the "oidc_subject" field. +func OidcSubjectHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldOidcSubject, v)) +} + +// OidcSubjectIsNil applies the IsNil predicate on the "oidc_subject" field. +func OidcSubjectIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldOidcSubject)) +} + +// OidcSubjectNotNil applies the NotNil predicate on the "oidc_subject" field. +func OidcSubjectNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldOidcSubject)) +} + +// OidcSubjectEqualFold applies the EqualFold predicate on the "oidc_subject" field. +func OidcSubjectEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldOidcSubject, v)) +} + +// OidcSubjectContainsFold applies the ContainsFold predicate on the "oidc_subject" field. +func OidcSubjectContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldOidcSubject, v)) +} + // HasGroup applies the HasEdge predicate on the "group" edge. func HasGroup() predicate.User { return predicate.User(func(s *sql.Selector) { diff --git a/backend/internal/data/ent/user_create.go b/backend/internal/data/ent/user_create.go index 03ead475..3269f609 100644 --- a/backend/internal/data/ent/user_create.go +++ b/backend/internal/data/ent/user_create.go @@ -70,6 +70,14 @@ func (_c *UserCreate) SetPassword(v string) *UserCreate { return _c } +// SetNillablePassword sets the "password" field if the given value is not nil. +func (_c *UserCreate) SetNillablePassword(v *string) *UserCreate { + if v != nil { + _c.SetPassword(*v) + } + return _c +} + // SetIsSuperuser sets the "is_superuser" field. func (_c *UserCreate) SetIsSuperuser(v bool) *UserCreate { _c.mutation.SetIsSuperuser(v) @@ -126,6 +134,34 @@ func (_c *UserCreate) SetNillableActivatedOn(v *time.Time) *UserCreate { return _c } +// SetOidcIssuer sets the "oidc_issuer" field. +func (_c *UserCreate) SetOidcIssuer(v string) *UserCreate { + _c.mutation.SetOidcIssuer(v) + return _c +} + +// SetNillableOidcIssuer sets the "oidc_issuer" field if the given value is not nil. +func (_c *UserCreate) SetNillableOidcIssuer(v *string) *UserCreate { + if v != nil { + _c.SetOidcIssuer(*v) + } + return _c +} + +// SetOidcSubject sets the "oidc_subject" field. +func (_c *UserCreate) SetOidcSubject(v string) *UserCreate { + _c.mutation.SetOidcSubject(v) + return _c +} + +// SetNillableOidcSubject sets the "oidc_subject" field if the given value is not nil. +func (_c *UserCreate) SetNillableOidcSubject(v *string) *UserCreate { + if v != nil { + _c.SetOidcSubject(*v) + } + return _c +} + // SetID sets the "id" field. func (_c *UserCreate) SetID(v uuid.UUID) *UserCreate { _c.mutation.SetID(v) @@ -266,9 +302,6 @@ func (_c *UserCreate) check() error { return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} } } - if _, ok := _c.mutation.Password(); !ok { - return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "User.password"`)} - } if v, ok := _c.mutation.Password(); ok { if err := user.PasswordValidator(v); err != nil { return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "User.password": %w`, err)} @@ -344,7 +377,7 @@ func (_c *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { } if value, ok := _c.mutation.Password(); ok { _spec.SetField(user.FieldPassword, field.TypeString, value) - _node.Password = value + _node.Password = &value } if value, ok := _c.mutation.IsSuperuser(); ok { _spec.SetField(user.FieldIsSuperuser, field.TypeBool, value) @@ -362,6 +395,14 @@ func (_c *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { _spec.SetField(user.FieldActivatedOn, field.TypeTime, value) _node.ActivatedOn = value } + if value, ok := _c.mutation.OidcIssuer(); ok { + _spec.SetField(user.FieldOidcIssuer, field.TypeString, value) + _node.OidcIssuer = &value + } + if value, ok := _c.mutation.OidcSubject(); ok { + _spec.SetField(user.FieldOidcSubject, field.TypeString, value) + _node.OidcSubject = &value + } if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, diff --git a/backend/internal/data/ent/user_update.go b/backend/internal/data/ent/user_update.go index 61437748..c13f4057 100644 --- a/backend/internal/data/ent/user_update.go +++ b/backend/internal/data/ent/user_update.go @@ -80,6 +80,12 @@ func (_u *UserUpdate) SetNillablePassword(v *string) *UserUpdate { return _u } +// ClearPassword clears the value of the "password" field. +func (_u *UserUpdate) ClearPassword() *UserUpdate { + _u.mutation.ClearPassword() + return _u +} + // SetIsSuperuser sets the "is_superuser" field. func (_u *UserUpdate) SetIsSuperuser(v bool) *UserUpdate { _u.mutation.SetIsSuperuser(v) @@ -142,6 +148,46 @@ func (_u *UserUpdate) ClearActivatedOn() *UserUpdate { return _u } +// SetOidcIssuer sets the "oidc_issuer" field. +func (_u *UserUpdate) SetOidcIssuer(v string) *UserUpdate { + _u.mutation.SetOidcIssuer(v) + return _u +} + +// SetNillableOidcIssuer sets the "oidc_issuer" field if the given value is not nil. +func (_u *UserUpdate) SetNillableOidcIssuer(v *string) *UserUpdate { + if v != nil { + _u.SetOidcIssuer(*v) + } + return _u +} + +// ClearOidcIssuer clears the value of the "oidc_issuer" field. +func (_u *UserUpdate) ClearOidcIssuer() *UserUpdate { + _u.mutation.ClearOidcIssuer() + return _u +} + +// SetOidcSubject sets the "oidc_subject" field. +func (_u *UserUpdate) SetOidcSubject(v string) *UserUpdate { + _u.mutation.SetOidcSubject(v) + return _u +} + +// SetNillableOidcSubject sets the "oidc_subject" field if the given value is not nil. +func (_u *UserUpdate) SetNillableOidcSubject(v *string) *UserUpdate { + if v != nil { + _u.SetOidcSubject(*v) + } + return _u +} + +// ClearOidcSubject clears the value of the "oidc_subject" field. +func (_u *UserUpdate) ClearOidcSubject() *UserUpdate { + _u.mutation.ClearOidcSubject() + return _u +} + // SetGroupID sets the "group" edge to the Group entity by ID. func (_u *UserUpdate) SetGroupID(id uuid.UUID) *UserUpdate { _u.mutation.SetGroupID(id) @@ -324,6 +370,9 @@ func (_u *UserUpdate) sqlSave(ctx context.Context) (_node int, err error) { if value, ok := _u.mutation.Password(); ok { _spec.SetField(user.FieldPassword, field.TypeString, value) } + if _u.mutation.PasswordCleared() { + _spec.ClearField(user.FieldPassword, field.TypeString) + } if value, ok := _u.mutation.IsSuperuser(); ok { _spec.SetField(user.FieldIsSuperuser, field.TypeBool, value) } @@ -339,6 +388,18 @@ func (_u *UserUpdate) sqlSave(ctx context.Context) (_node int, err error) { if _u.mutation.ActivatedOnCleared() { _spec.ClearField(user.FieldActivatedOn, field.TypeTime) } + if value, ok := _u.mutation.OidcIssuer(); ok { + _spec.SetField(user.FieldOidcIssuer, field.TypeString, value) + } + if _u.mutation.OidcIssuerCleared() { + _spec.ClearField(user.FieldOidcIssuer, field.TypeString) + } + if value, ok := _u.mutation.OidcSubject(); ok { + _spec.SetField(user.FieldOidcSubject, field.TypeString, value) + } + if _u.mutation.OidcSubjectCleared() { + _spec.ClearField(user.FieldOidcSubject, field.TypeString) + } if _u.mutation.GroupCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, @@ -526,6 +587,12 @@ func (_u *UserUpdateOne) SetNillablePassword(v *string) *UserUpdateOne { return _u } +// ClearPassword clears the value of the "password" field. +func (_u *UserUpdateOne) ClearPassword() *UserUpdateOne { + _u.mutation.ClearPassword() + return _u +} + // SetIsSuperuser sets the "is_superuser" field. func (_u *UserUpdateOne) SetIsSuperuser(v bool) *UserUpdateOne { _u.mutation.SetIsSuperuser(v) @@ -588,6 +655,46 @@ func (_u *UserUpdateOne) ClearActivatedOn() *UserUpdateOne { return _u } +// SetOidcIssuer sets the "oidc_issuer" field. +func (_u *UserUpdateOne) SetOidcIssuer(v string) *UserUpdateOne { + _u.mutation.SetOidcIssuer(v) + return _u +} + +// SetNillableOidcIssuer sets the "oidc_issuer" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableOidcIssuer(v *string) *UserUpdateOne { + if v != nil { + _u.SetOidcIssuer(*v) + } + return _u +} + +// ClearOidcIssuer clears the value of the "oidc_issuer" field. +func (_u *UserUpdateOne) ClearOidcIssuer() *UserUpdateOne { + _u.mutation.ClearOidcIssuer() + return _u +} + +// SetOidcSubject sets the "oidc_subject" field. +func (_u *UserUpdateOne) SetOidcSubject(v string) *UserUpdateOne { + _u.mutation.SetOidcSubject(v) + return _u +} + +// SetNillableOidcSubject sets the "oidc_subject" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableOidcSubject(v *string) *UserUpdateOne { + if v != nil { + _u.SetOidcSubject(*v) + } + return _u +} + +// ClearOidcSubject clears the value of the "oidc_subject" field. +func (_u *UserUpdateOne) ClearOidcSubject() *UserUpdateOne { + _u.mutation.ClearOidcSubject() + return _u +} + // SetGroupID sets the "group" edge to the Group entity by ID. func (_u *UserUpdateOne) SetGroupID(id uuid.UUID) *UserUpdateOne { _u.mutation.SetGroupID(id) @@ -800,6 +907,9 @@ func (_u *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { if value, ok := _u.mutation.Password(); ok { _spec.SetField(user.FieldPassword, field.TypeString, value) } + if _u.mutation.PasswordCleared() { + _spec.ClearField(user.FieldPassword, field.TypeString) + } if value, ok := _u.mutation.IsSuperuser(); ok { _spec.SetField(user.FieldIsSuperuser, field.TypeBool, value) } @@ -815,6 +925,18 @@ func (_u *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { if _u.mutation.ActivatedOnCleared() { _spec.ClearField(user.FieldActivatedOn, field.TypeTime) } + if value, ok := _u.mutation.OidcIssuer(); ok { + _spec.SetField(user.FieldOidcIssuer, field.TypeString, value) + } + if _u.mutation.OidcIssuerCleared() { + _spec.ClearField(user.FieldOidcIssuer, field.TypeString) + } + if value, ok := _u.mutation.OidcSubject(); ok { + _spec.SetField(user.FieldOidcSubject, field.TypeString, value) + } + if _u.mutation.OidcSubjectCleared() { + _spec.ClearField(user.FieldOidcSubject, field.TypeString) + } if _u.mutation.GroupCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, diff --git a/backend/internal/data/migrations/postgres/20250826000000_make_attachment_paths_relative.sql b/backend/internal/data/migrations/postgres/20250826000000_make_attachment_paths_relative.sql index 58221abc..75ac28b5 100644 --- a/backend/internal/data/migrations/postgres/20250826000000_make_attachment_paths_relative.sql +++ b/backend/internal/data/migrations/postgres/20250826000000_make_attachment_paths_relative.sql @@ -13,13 +13,9 @@ WHERE path LIKE '%/documents/%' -- Update Windows-style paths that contain "\documents\" by extracting the part starting from the UUID -- Convert backslashes to forward slashes in the process for consistency UPDATE attachments -SET path = REPLACE(SUBSTRING(path FROM POSITION('\documents\' IN path) - 36), '\', '/') -WHERE path LIKE '%\documents\%' - AND POSITION('\documents\' IN path) > 36; +SET path = REPLACE(SUBSTRING(path FROM POSITION(E'\\documents\\' IN path) - 36), E'\\', '/') +WHERE path LIKE E'%\\documents\\%' + AND POSITION(E'\\documents\\' IN path) > 36; -- For paths that already look like relative paths (start with UUID), leave them unchanged --- This handles cases where the migration might be run multiple times - --- +goose Down --- Note: This down migration cannot be safely implemented because we don't know --- what the original prefix paths were. This is a one-way migration. \ No newline at end of file +-- This handles cases where the migration might be run multiple times \ No newline at end of file diff --git a/backend/internal/data/migrations/postgres/20251123000000_add_oidc_identity.sql b/backend/internal/data/migrations/postgres/20251123000000_add_oidc_identity.sql new file mode 100644 index 00000000..8c8d87e8 --- /dev/null +++ b/backend/internal/data/migrations/postgres/20251123000000_add_oidc_identity.sql @@ -0,0 +1,8 @@ +-- +goose Up +-- Add OIDC identity mapping columns and unique composite index (issuer + subject) +ALTER TABLE public.users ADD COLUMN oidc_issuer VARCHAR; +ALTER TABLE public.users ADD COLUMN oidc_subject VARCHAR; +-- Partial unique index so multiple NULL pairs are allowed, enforcing uniqueness only when both present. +CREATE UNIQUE INDEX users_oidc_issuer_subject_key ON public.users(oidc_issuer, oidc_subject) + WHERE oidc_issuer IS NOT NULL AND oidc_subject IS NOT NULL; + diff --git a/backend/internal/data/migrations/postgres/20251128120201_recreate_item_templates.sql b/backend/internal/data/migrations/postgres/20251128120201_recreate_item_templates.sql new file mode 100644 index 00000000..6dd35a5f --- /dev/null +++ b/backend/internal/data/migrations/postgres/20251128120201_recreate_item_templates.sql @@ -0,0 +1,29 @@ +-- +goose Up +-- Create "item_templates" table +CREATE TABLE IF NOT EXISTS "item_templates" ( + "id" uuid NOT NULL, + "created_at" timestamptz NOT NULL, + "updated_at" timestamptz NOT NULL, + "name" character varying NOT NULL, + "description" character varying NULL, + "notes" character varying NULL, + "default_quantity" bigint NOT NULL DEFAULT 1, + "default_insured" boolean NOT NULL DEFAULT false, + "default_name" character varying NULL, + "default_description" character varying NULL, + "default_manufacturer" character varying NULL, + "default_model_number" character varying NULL, + "default_lifetime_warranty" boolean NOT NULL DEFAULT false, + "default_warranty_details" character varying NULL, + "include_warranty_fields" boolean NOT NULL DEFAULT false, + "include_purchase_fields" boolean NOT NULL DEFAULT false, + "include_sold_fields" boolean NOT NULL DEFAULT false, + "default_label_ids" jsonb NULL, + "item_template_location" uuid NULL, + "group_item_templates" uuid NOT NULL, + PRIMARY KEY ("id"), + CONSTRAINT "item_templates_groups_item_templates" FOREIGN KEY ("group_item_templates") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, + CONSTRAINT "item_templates_locations_location" FOREIGN KEY ("item_template_location") REFERENCES "locations" ("id") ON UPDATE NO ACTION ON DELETE SET NULL +); +-- Create "template_fields" table +CREATE TABLE IF NOT EXISTS "template_fields" ("id" uuid NOT NULL, "created_at" timestamptz NOT NULL, "updated_at" timestamptz NOT NULL, "name" character varying NOT NULL, "description" character varying NULL, "type" character varying NOT NULL, "text_value" character varying NULL, "item_template_fields" uuid NULL, PRIMARY KEY ("id"), CONSTRAINT "template_fields_item_templates_fields" FOREIGN KEY ("item_template_fields") REFERENCES "item_templates" ("id") ON UPDATE NO ACTION ON DELETE CASCADE); diff --git a/backend/internal/data/migrations/postgres/20251129000000_make_password_nullable.sql b/backend/internal/data/migrations/postgres/20251129000000_make_password_nullable.sql new file mode 100644 index 00000000..47e27f72 --- /dev/null +++ b/backend/internal/data/migrations/postgres/20251129000000_make_password_nullable.sql @@ -0,0 +1,2 @@ +-- +goose Up +ALTER TABLE users ALTER COLUMN password DROP NOT NULL; diff --git a/backend/internal/data/migrations/sqlite3/20250907000000_make_password_nullable.sql b/backend/internal/data/migrations/sqlite3/20250907000000_make_password_nullable.sql new file mode 100644 index 00000000..90679de5 --- /dev/null +++ b/backend/internal/data/migrations/sqlite3/20250907000000_make_password_nullable.sql @@ -0,0 +1,68 @@ +-- +goose Up +-- +goose StatementBegin +-- SQLite doesn't support ALTER COLUMN directly, so we need to recreate the table +-- Create a temporary table with the new schema +CREATE TABLE users_temp ( + id uuid not null + primary key, + created_at datetime not null, + updated_at datetime not null, + name text not null, + email text not null, + password text, + is_superuser bool default false not null, + superuser bool default false not null, + role text default 'user' not null, + activated_on datetime, + group_users uuid not null + constraint users_groups_users + references groups + on delete cascade +); + +-- Copy data from the original table +INSERT INTO users_temp SELECT * FROM users; + +-- Drop the original table +DROP TABLE users; + +-- Rename the temporary table +ALTER TABLE users_temp RENAME TO users; + +-- Recreate the unique index +CREATE UNIQUE INDEX users_email_key on users (email); +-- +goose StatementEnd + +-- +goose Down +-- +goose StatementBegin +-- Create the original table structure +CREATE TABLE users_temp ( + id uuid not null + primary key, + created_at datetime not null, + updated_at datetime not null, + name text not null, + email text not null, + password text not null, + is_superuser bool default false not null, + superuser bool default false not null, + role text default 'user' not null, + activated_on datetime, + group_users uuid not null + constraint users_groups_users + references groups + on delete cascade +); + +-- Copy data from the current table (this will fail if there are NULL passwords) +INSERT INTO users_temp SELECT * FROM users; + +-- Drop the current table +DROP TABLE users; + +-- Rename the temporary table +ALTER TABLE users_temp RENAME TO users; + +-- Recreate the unique index +CREATE UNIQUE INDEX users_email_key on users (email); +-- +goose StatementEnd \ No newline at end of file diff --git a/backend/internal/data/migrations/sqlite3/20251123000000_add_oidc_identity.sql b/backend/internal/data/migrations/sqlite3/20251123000000_add_oidc_identity.sql new file mode 100644 index 00000000..2bee5a62 --- /dev/null +++ b/backend/internal/data/migrations/sqlite3/20251123000000_add_oidc_identity.sql @@ -0,0 +1,6 @@ +-- +goose Up +-- Add OIDC identity mapping columns and unique composite index (issuer + subject) +ALTER TABLE users ADD COLUMN oidc_issuer TEXT; +ALTER TABLE users ADD COLUMN oidc_subject TEXT; +CREATE UNIQUE INDEX users_oidc_issuer_subject_key ON users(oidc_issuer, oidc_subject); + diff --git a/backend/internal/data/migrations/sqlite3/20251128120200_recreate_item_templates.sql b/backend/internal/data/migrations/sqlite3/20251128120200_recreate_item_templates.sql new file mode 100644 index 00000000..6a7adf3c --- /dev/null +++ b/backend/internal/data/migrations/sqlite3/20251128120200_recreate_item_templates.sql @@ -0,0 +1,46 @@ +-- +goose Up +create table if not exists item_templates +( + id uuid not null + primary key, + created_at datetime not null, + updated_at datetime not null, + name text not null, + description text, + notes text, + default_quantity integer default 1 not null, + default_insured bool default false not null, + default_name text, + default_description text, + default_manufacturer text, + default_model_number text, + default_lifetime_warranty bool default false not null, + default_warranty_details text, + include_warranty_fields bool default false not null, + include_purchase_fields bool default false not null, + include_sold_fields bool default false not null, + default_label_ids json, + item_template_location uuid + references locations(id) + on delete set null, + group_item_templates uuid not null + constraint item_templates_groups_item_templates + references groups + on delete cascade +); + +create table if not exists template_fields +( + id uuid not null + primary key, + created_at datetime not null, + updated_at datetime not null, + name text not null, + description text, + type text not null, + text_value text, + item_template_fields uuid + constraint template_fields_item_templates_fields + references item_templates + on delete cascade +); diff --git a/backend/internal/data/repo/repo_entity_attachments.go b/backend/internal/data/repo/repo_entity_attachments.go index b3ed073b..ac6803bf 100644 --- a/backend/internal/data/repo/repo_entity_attachments.go +++ b/backend/internal/data/repo/repo_entity_attachments.go @@ -218,10 +218,8 @@ func (r *AttachmentRepo) Create(ctx context.Context, itemID uuid.UUID, doc Entit // Upload the file to the storage bucket path, err := r.UploadFile(ctx, itemGroup, doc) if err != nil { - log.Err(err).Msg("failed to create parent directory") - err := tx.Rollback() - if err != nil { - return nil, err + if rollbackErr := tx.Rollback(); rollbackErr != nil { + return nil, rollbackErr } return nil, err } diff --git a/backend/internal/data/repo/repo_item_templates.go b/backend/internal/data/repo/repo_item_templates.go new file mode 100644 index 00000000..532c6fe5 --- /dev/null +++ b/backend/internal/data/repo/repo_item_templates.go @@ -0,0 +1,451 @@ +package repo + +import ( + "context" + "time" + + "github.com/google/uuid" + "github.com/rs/zerolog/log" + "github.com/sysadminsmedia/homebox/backend/internal/core/services/reporting/eventbus" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/group" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/label" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield" +) + +type ItemTemplatesRepository struct { + db *ent.Client + bus *eventbus.EventBus +} + +type ( + TemplateField struct { + ID *uuid.UUID `json:"id,omitempty"` + Type string `json:"type"` + Name string `json:"name"` + TextValue string `json:"textValue"` + } + + TemplateLabelSummary struct { + ID uuid.UUID `json:"id"` + Name string `json:"name"` + } + + TemplateLocationSummary struct { + ID uuid.UUID `json:"id"` + Name string `json:"name"` + } + + ItemTemplateCreate struct { + Name string `json:"name" validate:"required,min=1,max=255"` + Description string `json:"description" validate:"max=1000"` + Notes string `json:"notes" validate:"max=1000"` + + // Default values for items + DefaultQuantity *int `json:"defaultQuantity,omitempty" extensions:"x-nullable"` + DefaultInsured bool `json:"defaultInsured"` + DefaultName *string `json:"defaultName,omitempty" extensions:"x-nullable" validate:"omitempty,max=255"` + DefaultDescription *string `json:"defaultDescription,omitempty" extensions:"x-nullable" validate:"omitempty,max=1000"` + DefaultManufacturer *string `json:"defaultManufacturer,omitempty" extensions:"x-nullable" validate:"omitempty,max=255"` + DefaultModelNumber *string `json:"defaultModelNumber,omitempty" extensions:"x-nullable" validate:"omitempty,max=255"` + DefaultLifetimeWarranty bool `json:"defaultLifetimeWarranty"` + DefaultWarrantyDetails *string `json:"defaultWarrantyDetails,omitempty" extensions:"x-nullable" validate:"omitempty,max=1000"` + + // Default location and labels + DefaultLocationID *uuid.UUID `json:"defaultLocationId,omitempty" extensions:"x-nullable"` + DefaultLabelIDs *[]uuid.UUID `json:"defaultLabelIds,omitempty" extensions:"x-nullable"` + + // Metadata flags + IncludeWarrantyFields bool `json:"includeWarrantyFields"` + IncludePurchaseFields bool `json:"includePurchaseFields"` + IncludeSoldFields bool `json:"includeSoldFields"` + + // Custom fields + Fields []TemplateField `json:"fields"` + } + + ItemTemplateUpdate struct { + ID uuid.UUID `json:"id"` + Name string `json:"name" validate:"required,min=1,max=255"` + Description string `json:"description" validate:"max=1000"` + Notes string `json:"notes" validate:"max=1000"` + + // Default values for items + DefaultQuantity *int `json:"defaultQuantity,omitempty" extensions:"x-nullable"` + DefaultInsured bool `json:"defaultInsured"` + DefaultName *string `json:"defaultName,omitempty" extensions:"x-nullable" validate:"omitempty,max=255"` + DefaultDescription *string `json:"defaultDescription,omitempty" extensions:"x-nullable" validate:"omitempty,max=1000"` + DefaultManufacturer *string `json:"defaultManufacturer,omitempty" extensions:"x-nullable" validate:"omitempty,max=255"` + DefaultModelNumber *string `json:"defaultModelNumber,omitempty" extensions:"x-nullable" validate:"omitempty,max=255"` + DefaultLifetimeWarranty bool `json:"defaultLifetimeWarranty"` + DefaultWarrantyDetails *string `json:"defaultWarrantyDetails,omitempty" extensions:"x-nullable" validate:"omitempty,max=1000"` + + // Default location and labels + DefaultLocationID *uuid.UUID `json:"defaultLocationId,omitempty" extensions:"x-nullable"` + DefaultLabelIDs *[]uuid.UUID `json:"defaultLabelIds,omitempty" extensions:"x-nullable"` + + // Metadata flags + IncludeWarrantyFields bool `json:"includeWarrantyFields"` + IncludePurchaseFields bool `json:"includePurchaseFields"` + IncludeSoldFields bool `json:"includeSoldFields"` + + // Custom fields + Fields []TemplateField `json:"fields"` + } + + ItemTemplateSummary struct { + ID uuid.UUID `json:"id"` + Name string `json:"name"` + Description string `json:"description"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + } + + ItemTemplateOut struct { + ID uuid.UUID `json:"id"` + Name string `json:"name"` + Description string `json:"description"` + Notes string `json:"notes"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + + // Default values for items + DefaultQuantity int `json:"defaultQuantity"` + DefaultInsured bool `json:"defaultInsured"` + DefaultName string `json:"defaultName"` + DefaultDescription string `json:"defaultDescription"` + DefaultManufacturer string `json:"defaultManufacturer"` + DefaultModelNumber string `json:"defaultModelNumber"` + DefaultLifetimeWarranty bool `json:"defaultLifetimeWarranty"` + DefaultWarrantyDetails string `json:"defaultWarrantyDetails"` + + // Default location and labels + DefaultLocation *TemplateLocationSummary `json:"defaultLocation"` + DefaultLabels []TemplateLabelSummary `json:"defaultLabels"` + + // Metadata flags + IncludeWarrantyFields bool `json:"includeWarrantyFields"` + IncludePurchaseFields bool `json:"includePurchaseFields"` + IncludeSoldFields bool `json:"includeSoldFields"` + + // Custom fields + Fields []TemplateField `json:"fields"` + } +) + +func mapTemplateField(field *ent.TemplateField) TemplateField { + id := field.ID + return TemplateField{ + ID: &id, + Type: string(field.Type), + Name: field.Name, + TextValue: field.TextValue, + } +} + +func mapTemplateFieldSlice(fields []*ent.TemplateField) []TemplateField { + result := make([]TemplateField, len(fields)) + for i, field := range fields { + result[i] = mapTemplateField(field) + } + return result +} + +func mapTemplateSummary(template *ent.ItemTemplate) ItemTemplateSummary { + return ItemTemplateSummary{ + ID: template.ID, + Name: template.Name, + Description: template.Description, + CreatedAt: template.CreatedAt, + UpdatedAt: template.UpdatedAt, + } +} + +func (r *ItemTemplatesRepository) mapTemplateOut(ctx context.Context, template *ent.ItemTemplate) ItemTemplateOut { + fields := make([]TemplateField, 0) + if template.Edges.Fields != nil { + fields = mapTemplateFieldSlice(template.Edges.Fields) + } + + // Map location if present + var location *TemplateLocationSummary + if template.Edges.Location != nil { + location = &TemplateLocationSummary{ + ID: template.Edges.Location.ID, + Name: template.Edges.Location.Name, + } + } + + // Fetch labels from database using stored IDs + labels := make([]TemplateLabelSummary, 0) + if len(template.DefaultLabelIds) > 0 { + labelEntities, err := r.db.Label.Query(). + Where(label.IDIn(template.DefaultLabelIds...)). + All(ctx) + if err == nil { + for _, l := range labelEntities { + labels = append(labels, TemplateLabelSummary{ + ID: l.ID, + Name: l.Name, + }) + } + } + } + + return ItemTemplateOut{ + ID: template.ID, + Name: template.Name, + Description: template.Description, + Notes: template.Notes, + CreatedAt: template.CreatedAt, + UpdatedAt: template.UpdatedAt, + DefaultQuantity: template.DefaultQuantity, + DefaultInsured: template.DefaultInsured, + DefaultName: template.DefaultName, + DefaultDescription: template.DefaultDescription, + DefaultManufacturer: template.DefaultManufacturer, + DefaultModelNumber: template.DefaultModelNumber, + DefaultLifetimeWarranty: template.DefaultLifetimeWarranty, + DefaultWarrantyDetails: template.DefaultWarrantyDetails, + DefaultLocation: location, + DefaultLabels: labels, + IncludeWarrantyFields: template.IncludeWarrantyFields, + IncludePurchaseFields: template.IncludePurchaseFields, + IncludeSoldFields: template.IncludeSoldFields, + Fields: fields, + } +} + +func (r *ItemTemplatesRepository) publishMutationEvent(gid uuid.UUID) { + if r.bus != nil { + r.bus.Publish(eventbus.EventItemMutation, eventbus.GroupMutationEvent{GID: gid}) + } +} + +// GetAll returns all templates for a group +func (r *ItemTemplatesRepository) GetAll(ctx context.Context, gid uuid.UUID) ([]ItemTemplateSummary, error) { + templates, err := r.db.ItemTemplate.Query(). + Where(itemtemplate.HasGroupWith(group.ID(gid))). + Order(ent.Asc(itemtemplate.FieldName)). + All(ctx) + + if err != nil { + return nil, err + } + + result := make([]ItemTemplateSummary, len(templates)) + for i, template := range templates { + result[i] = mapTemplateSummary(template) + } + + return result, nil +} + +// GetOne returns a single template by ID, verified to belong to the specified group +func (r *ItemTemplatesRepository) GetOne(ctx context.Context, gid uuid.UUID, id uuid.UUID) (ItemTemplateOut, error) { + template, err := r.db.ItemTemplate.Query(). + Where( + itemtemplate.ID(id), + itemtemplate.HasGroupWith(group.ID(gid)), + ). + WithFields(). + WithLocation(). + Only(ctx) + + if err != nil { + return ItemTemplateOut{}, err + } + + return r.mapTemplateOut(ctx, template), nil +} + +// Create creates a new template +func (r *ItemTemplatesRepository) Create(ctx context.Context, gid uuid.UUID, data ItemTemplateCreate) (ItemTemplateOut, error) { + q := r.db.ItemTemplate.Create(). + SetName(data.Name). + SetDescription(data.Description). + SetNotes(data.Notes). + SetNillableDefaultQuantity(data.DefaultQuantity). + SetDefaultInsured(data.DefaultInsured). + SetNillableDefaultName(data.DefaultName). + SetNillableDefaultDescription(data.DefaultDescription). + SetNillableDefaultManufacturer(data.DefaultManufacturer). + SetNillableDefaultModelNumber(data.DefaultModelNumber). + SetDefaultLifetimeWarranty(data.DefaultLifetimeWarranty). + SetNillableDefaultWarrantyDetails(data.DefaultWarrantyDetails). + SetIncludeWarrantyFields(data.IncludeWarrantyFields). + SetIncludePurchaseFields(data.IncludePurchaseFields). + SetIncludeSoldFields(data.IncludeSoldFields). + SetGroupID(gid). + SetNillableLocationID(data.DefaultLocationID) + + // Set default label IDs (stored as JSON) + if data.DefaultLabelIDs != nil && len(*data.DefaultLabelIDs) > 0 { + q.SetDefaultLabelIds(*data.DefaultLabelIDs) + } + + template, err := q.Save(ctx) + if err != nil { + return ItemTemplateOut{}, err + } + + // Create template fields + for _, field := range data.Fields { + _, err = r.db.TemplateField.Create(). + SetItemTemplateID(template.ID). + SetType(templatefield.Type(field.Type)). + SetName(field.Name). + SetTextValue(field.TextValue). + Save(ctx) + + if err != nil { + log.Err(err).Msg("failed to create template field") + return ItemTemplateOut{}, err + } + } + + r.publishMutationEvent(gid) + return r.GetOne(ctx, gid, template.ID) +} + +// Update updates an existing template +func (r *ItemTemplatesRepository) Update(ctx context.Context, gid uuid.UUID, data ItemTemplateUpdate) (ItemTemplateOut, error) { + // Verify template belongs to group + template, err := r.db.ItemTemplate.Query(). + Where( + itemtemplate.ID(data.ID), + itemtemplate.HasGroupWith(group.ID(gid)), + ). + Only(ctx) + + if err != nil { + return ItemTemplateOut{}, err + } + + // Update template + updateQ := template.Update(). + SetName(data.Name). + SetDescription(data.Description). + SetNotes(data.Notes). + SetNillableDefaultQuantity(data.DefaultQuantity). + SetDefaultInsured(data.DefaultInsured). + SetNillableDefaultName(data.DefaultName). + SetNillableDefaultDescription(data.DefaultDescription). + SetNillableDefaultManufacturer(data.DefaultManufacturer). + SetNillableDefaultModelNumber(data.DefaultModelNumber). + SetDefaultLifetimeWarranty(data.DefaultLifetimeWarranty). + SetNillableDefaultWarrantyDetails(data.DefaultWarrantyDetails). + SetIncludeWarrantyFields(data.IncludeWarrantyFields). + SetIncludePurchaseFields(data.IncludePurchaseFields). + SetIncludeSoldFields(data.IncludeSoldFields) + + // Update location + if data.DefaultLocationID != nil { + updateQ.SetLocationID(*data.DefaultLocationID) + } else { + updateQ.ClearLocation() + } + + // Update default label IDs (stored as JSON) + if data.DefaultLabelIDs != nil && len(*data.DefaultLabelIDs) > 0 { + updateQ.SetDefaultLabelIds(*data.DefaultLabelIDs) + } else { + updateQ.ClearDefaultLabelIds() + } + + _, err = updateQ.Save(ctx) + if err != nil { + return ItemTemplateOut{}, err + } + + // Get existing fields + existingFields, err := r.db.TemplateField.Query(). + Where(templatefield.HasItemTemplateWith(itemtemplate.ID(data.ID))). + All(ctx) + + if err != nil { + return ItemTemplateOut{}, err + } + + // Create a map of existing field IDs for quick lookup + existingFieldMap := make(map[uuid.UUID]bool) + for _, field := range existingFields { + existingFieldMap[field.ID] = true + } + + // Track which fields are being updated + updatedFieldIDs := make(map[uuid.UUID]bool) + + // Create or update fields + for _, field := range data.Fields { + if field.ID == nil || *field.ID == uuid.Nil { + // Create new field + _, err = r.db.TemplateField.Create(). + SetItemTemplateID(data.ID). + SetType(templatefield.Type(field.Type)). + SetName(field.Name). + SetTextValue(field.TextValue). + Save(ctx) + + if err != nil { + log.Err(err).Msg("failed to create template field") + return ItemTemplateOut{}, err + } + } else { + // Update existing field + updatedFieldIDs[*field.ID] = true + _, err = r.db.TemplateField.Update(). + Where( + templatefield.ID(*field.ID), + templatefield.HasItemTemplateWith(itemtemplate.ID(data.ID)), + ). + SetType(templatefield.Type(field.Type)). + SetName(field.Name). + SetTextValue(field.TextValue). + Save(ctx) + + if err != nil { + log.Err(err).Msg("failed to update template field") + return ItemTemplateOut{}, err + } + } + } + + // Delete fields that are no longer present + for _, field := range existingFields { + if !updatedFieldIDs[field.ID] { + err = r.db.TemplateField.DeleteOne(field).Exec(ctx) + if err != nil { + log.Err(err).Msg("failed to delete template field") + } + } + } + + r.publishMutationEvent(gid) + return r.GetOne(ctx, gid, template.ID) +} + +// Delete deletes a template +func (r *ItemTemplatesRepository) Delete(ctx context.Context, gid uuid.UUID, id uuid.UUID) error { + // Verify template belongs to group + _, err := r.db.ItemTemplate.Query(). + Where( + itemtemplate.ID(id), + itemtemplate.HasGroupWith(group.ID(gid)), + ). + Only(ctx) + + if err != nil { + return err + } + + // Delete template (fields will be cascade deleted) + err = r.db.ItemTemplate.DeleteOneID(id).Exec(ctx) + if err != nil { + return err + } + + r.publishMutationEvent(gid) + return nil +} diff --git a/backend/internal/data/repo/repo_item_templates_test.go b/backend/internal/data/repo/repo_item_templates_test.go new file mode 100644 index 00000000..dab5627d --- /dev/null +++ b/backend/internal/data/repo/repo_item_templates_test.go @@ -0,0 +1,337 @@ +package repo + +import ( + "context" + "testing" + + "github.com/google/uuid" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func templateFactory() ItemTemplateCreate { + qty := 1 + name := fk.Str(20) + desc := fk.Str(50) + mfr := fk.Str(15) + model := fk.Str(10) + warranty := "" + + return ItemTemplateCreate{ + Name: fk.Str(10), + Description: fk.Str(100), + Notes: fk.Str(50), + DefaultQuantity: &qty, + DefaultInsured: false, + DefaultName: &name, + DefaultDescription: &desc, + DefaultManufacturer: &mfr, + DefaultModelNumber: &model, + DefaultLifetimeWarranty: false, + DefaultWarrantyDetails: &warranty, + IncludeWarrantyFields: false, + IncludePurchaseFields: false, + IncludeSoldFields: false, + Fields: []TemplateField{}, + } +} + +func useTemplates(t *testing.T, count int) []ItemTemplateOut { + t.Helper() + + templates := make([]ItemTemplateOut, count) + for i := 0; i < count; i++ { + data := templateFactory() + + template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data) + require.NoError(t, err) + templates[i] = template + } + + t.Cleanup(func() { + for _, template := range templates { + _ = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID) + } + }) + + return templates +} + +func TestItemTemplatesRepository_GetAll(t *testing.T) { + useTemplates(t, 5) + + all, err := tRepos.ItemTemplates.GetAll(context.Background(), tGroup.ID) + require.NoError(t, err) + assert.GreaterOrEqual(t, len(all), 5) +} + +func TestItemTemplatesRepository_GetOne(t *testing.T) { + templates := useTemplates(t, 1) + template := templates[0] + + found, err := tRepos.ItemTemplates.GetOne(context.Background(), tGroup.ID, template.ID) + require.NoError(t, err) + assert.Equal(t, template.ID, found.ID) + assert.Equal(t, template.Name, found.Name) + assert.Equal(t, template.Description, found.Description) +} + +func TestItemTemplatesRepository_Create(t *testing.T) { + data := templateFactory() + + template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data) + require.NoError(t, err) + + assert.NotEqual(t, uuid.Nil, template.ID) + assert.Equal(t, data.Name, template.Name) + assert.Equal(t, data.Description, template.Description) + assert.Equal(t, *data.DefaultQuantity, template.DefaultQuantity) + assert.Equal(t, data.DefaultInsured, template.DefaultInsured) + assert.Equal(t, *data.DefaultName, template.DefaultName) + assert.Equal(t, *data.DefaultDescription, template.DefaultDescription) + assert.Equal(t, *data.DefaultManufacturer, template.DefaultManufacturer) + assert.Equal(t, *data.DefaultModelNumber, template.DefaultModelNumber) + + // Cleanup + err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID) + require.NoError(t, err) +} + +func TestItemTemplatesRepository_CreateWithFields(t *testing.T) { + data := templateFactory() + data.Fields = []TemplateField{ + {Name: "Field 1", Type: "text", TextValue: "Value 1"}, + {Name: "Field 2", Type: "text", TextValue: "Value 2"}, + } + + template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data) + require.NoError(t, err) + + assert.Len(t, template.Fields, 2) + assert.Equal(t, "Field 1", template.Fields[0].Name) + assert.Equal(t, "Value 1", template.Fields[0].TextValue) + assert.Equal(t, "Field 2", template.Fields[1].Name) + assert.Equal(t, "Value 2", template.Fields[1].TextValue) + + // Cleanup + err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID) + require.NoError(t, err) +} + +func TestItemTemplatesRepository_Update(t *testing.T) { + templates := useTemplates(t, 1) + template := templates[0] + + qty := 5 + defaultName := "Default Item Name" + defaultDesc := "Default Item Description" + defaultMfr := "Updated Manufacturer" + defaultModel := "MODEL-123" + defaultWarranty := "Lifetime coverage" + + updateData := ItemTemplateUpdate{ + ID: template.ID, + Name: "Updated Name", + Description: "Updated Description", + Notes: "Updated Notes", + DefaultQuantity: &qty, + DefaultInsured: true, + DefaultName: &defaultName, + DefaultDescription: &defaultDesc, + DefaultManufacturer: &defaultMfr, + DefaultModelNumber: &defaultModel, + DefaultLifetimeWarranty: true, + DefaultWarrantyDetails: &defaultWarranty, + IncludeWarrantyFields: true, + IncludePurchaseFields: true, + IncludeSoldFields: false, + Fields: []TemplateField{}, + } + + updated, err := tRepos.ItemTemplates.Update(context.Background(), tGroup.ID, updateData) + require.NoError(t, err) + + assert.Equal(t, template.ID, updated.ID) + assert.Equal(t, "Updated Name", updated.Name) + assert.Equal(t, "Updated Description", updated.Description) + assert.Equal(t, "Updated Notes", updated.Notes) + assert.Equal(t, 5, updated.DefaultQuantity) + assert.True(t, updated.DefaultInsured) + assert.Equal(t, "Default Item Name", updated.DefaultName) + assert.Equal(t, "Default Item Description", updated.DefaultDescription) + assert.Equal(t, "Updated Manufacturer", updated.DefaultManufacturer) + assert.Equal(t, "MODEL-123", updated.DefaultModelNumber) + assert.True(t, updated.DefaultLifetimeWarranty) + assert.Equal(t, "Lifetime coverage", updated.DefaultWarrantyDetails) + assert.True(t, updated.IncludeWarrantyFields) + assert.True(t, updated.IncludePurchaseFields) + assert.False(t, updated.IncludeSoldFields) +} + +func TestItemTemplatesRepository_UpdateWithFields(t *testing.T) { + data := templateFactory() + data.Fields = []TemplateField{ + {Name: "Original Field", Type: "text", TextValue: "Original Value"}, + } + + template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data) + require.NoError(t, err) + require.Len(t, template.Fields, 1) + + // Update with new fields + qty := template.DefaultQuantity + updateData := ItemTemplateUpdate{ + ID: template.ID, + Name: template.Name, + Description: template.Description, + DefaultQuantity: &qty, + Fields: []TemplateField{ + {ID: template.Fields[0].ID, Name: "Updated Field", Type: "text", TextValue: "Updated Value"}, + {Name: "New Field", Type: "text", TextValue: "New Value"}, + }, + } + + updated, err := tRepos.ItemTemplates.Update(context.Background(), tGroup.ID, updateData) + require.NoError(t, err) + + assert.Len(t, updated.Fields, 2) + + // Cleanup + err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID) + require.NoError(t, err) +} + +func TestItemTemplatesRepository_Delete(t *testing.T) { + data := templateFactory() + + template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data) + require.NoError(t, err) + + err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID) + require.NoError(t, err) + + // Verify it's deleted + _, err = tRepos.ItemTemplates.GetOne(context.Background(), tGroup.ID, template.ID) + require.Error(t, err) +} + +func TestItemTemplatesRepository_DeleteCascadesFields(t *testing.T) { + data := templateFactory() + data.Fields = []TemplateField{ + {Name: "Field 1", Type: "text", TextValue: "Value 1"}, + {Name: "Field 2", Type: "text", TextValue: "Value 2"}, + } + + template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data) + require.NoError(t, err) + require.Len(t, template.Fields, 2) + + // Delete template - fields should be cascade deleted + err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID) + require.NoError(t, err) + + // Verify template is deleted + _, err = tRepos.ItemTemplates.GetOne(context.Background(), tGroup.ID, template.ID) + require.Error(t, err) +} + +func TestItemTemplatesRepository_CreateWithLocation(t *testing.T) { + // First create a location + loc, err := tRepos.Locations.Create(context.Background(), tGroup.ID, LocationCreate{ + Name: fk.Str(10), + Description: fk.Str(50), + }) + require.NoError(t, err) + + t.Cleanup(func() { + _ = tRepos.Locations.delete(context.Background(), loc.ID) + }) + + // Create template with location + data := templateFactory() + data.DefaultLocationID = &loc.ID + + template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data) + require.NoError(t, err) + + assert.NotNil(t, template.DefaultLocation) + assert.Equal(t, loc.ID, template.DefaultLocation.ID) + assert.Equal(t, loc.Name, template.DefaultLocation.Name) + + // Cleanup + err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID) + require.NoError(t, err) +} + +func TestItemTemplatesRepository_CreateWithLabels(t *testing.T) { + // Create some labels + label1, err := tRepos.Labels.Create(context.Background(), tGroup.ID, LabelCreate{ + Name: fk.Str(10), + Description: fk.Str(50), + }) + require.NoError(t, err) + + label2, err := tRepos.Labels.Create(context.Background(), tGroup.ID, LabelCreate{ + Name: fk.Str(10), + Description: fk.Str(50), + }) + require.NoError(t, err) + + t.Cleanup(func() { + _ = tRepos.Labels.delete(context.Background(), label1.ID) + _ = tRepos.Labels.delete(context.Background(), label2.ID) + }) + + // Create template with labels + data := templateFactory() + labelIDs := []uuid.UUID{label1.ID, label2.ID} + data.DefaultLabelIDs = &labelIDs + + template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data) + require.NoError(t, err) + + assert.Len(t, template.DefaultLabels, 2) + + // Cleanup + err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID) + require.NoError(t, err) +} + +func TestItemTemplatesRepository_UpdateRemoveLocation(t *testing.T) { + // First create a location + loc, err := tRepos.Locations.Create(context.Background(), tGroup.ID, LocationCreate{ + Name: fk.Str(10), + Description: fk.Str(50), + }) + require.NoError(t, err) + + t.Cleanup(func() { + _ = tRepos.Locations.delete(context.Background(), loc.ID) + }) + + // Create template with location + data := templateFactory() + data.DefaultLocationID = &loc.ID + + template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data) + require.NoError(t, err) + require.NotNil(t, template.DefaultLocation) + + // Update to remove location + qty := template.DefaultQuantity + updateData := ItemTemplateUpdate{ + ID: template.ID, + Name: template.Name, + DefaultQuantity: &qty, + DefaultLocationID: nil, // Remove location + } + + updated, err := tRepos.ItemTemplates.Update(context.Background(), tGroup.ID, updateData) + require.NoError(t, err) + + assert.Nil(t, updated.DefaultLocation) + + // Cleanup + err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID) + require.NoError(t, err) +} diff --git a/backend/internal/data/repo/repo_items.go b/backend/internal/data/repo/repo_items.go index acfb963d..4339dda6 100644 --- a/backend/internal/data/repo/repo_items.go +++ b/backend/internal/data/repo/repo_items.go @@ -22,8 +22,9 @@ import ( ) type ItemsRepository struct { - db *ent.Client - bus *eventbus.EventBus + db *ent.Client + bus *eventbus.EventBus + attachments *AttachmentRepo } type ( @@ -328,8 +329,13 @@ func (e *ItemsRepository) publishMutationEvent(gid uuid.UUID) { } } -func (e *ItemsRepository) getOne(ctx context.Context, where ...predicate.Entity) (ItemOut, error) { - q := e.db.Entity.Query().Where(where...).Where(entity.HasTypeWith(entitytype.IsLocationEQ(false))) +func (e *ItemsRepository) getOneTx(ctx context.Context, tx *ent.Tx, where ...predicate.Item) (ItemOut, error) { + var q *ent.ItemQuery + if tx != nil { + q = tx.Item.Query().Where(where...) + } else { + q = e.db.Item.Query().Where(where...) + } return mapItemOutErr(q. WithFields(). @@ -343,6 +349,10 @@ func (e *ItemsRepository) getOne(ctx context.Context, where ...predicate.Entity) ) } +func (e *ItemsRepository) getOne(ctx context.Context, where ...predicate.Item) (ItemOut, error) { + return e.getOneTx(ctx, nil, where...) +} + // GetOne returns a single item by ID. If the item does not exist, an error is returned. // See also: GetOneByGroup to ensure that the item belongs to a specific group. func (e *ItemsRepository) GetOne(ctx context.Context, id uuid.UUID) (ItemOut, error) { @@ -592,12 +602,21 @@ func (e *ItemsRepository) GetAllZeroAssetID(ctx context.Context, gid uuid.UUID) return mapItemsSummaryErr(q.All(ctx)) } -func (e *ItemsRepository) GetHighestAssetID(ctx context.Context, gid uuid.UUID) (AssetID, error) { - q := e.db.Entity.Query().Where( - entity.HasGroupWith(group.ID(gid)), - ).Order( - ent.Desc(entity.FieldAssetID), - ).Limit(1) +func (e *ItemsRepository) GetHighestAssetIDTx(ctx context.Context, tx *ent.Tx, gid uuid.UUID) (AssetID, error) { + var q *ent.ItemQuery + if tx != nil { + q = tx.Item.Query().Where( + item.HasGroupWith(group.ID(gid)), + ).Order( + ent.Desc(item.FieldAssetID), + ).Limit(1) + } else { + q = e.db.Item.Query().Where( + item.HasGroupWith(group.ID(gid)), + ).Order( + ent.Desc(item.FieldAssetID), + ).Limit(1) + } result, err := q.First(ctx) if err != nil { @@ -610,6 +629,10 @@ func (e *ItemsRepository) GetHighestAssetID(ctx context.Context, gid uuid.UUID) return AssetID(result.AssetID), nil } +func (e *ItemsRepository) GetHighestAssetID(ctx context.Context, gid uuid.UUID) (AssetID, error) { + return e.GetHighestAssetIDTx(ctx, nil, gid) +} + func (e *ItemsRepository) SetAssetID(ctx context.Context, gid uuid.UUID, id uuid.UUID, assetID AssetID) error { q := e.db.Entity.Update().Where( entity.HasGroupWith(group.ID(gid)), @@ -648,8 +671,117 @@ func (e *ItemsRepository) Create(ctx context.Context, gid uuid.UUID, data ItemCr return e.GetOne(ctx, result.ID) } +// ItemCreateFromTemplate contains all data needed to create an item from a template. +type ItemCreateFromTemplate struct { + Name string + Description string + Quantity int + LocationID uuid.UUID + LabelIDs []uuid.UUID + Insured bool + Manufacturer string + ModelNumber string + LifetimeWarranty bool + WarrantyDetails string + Fields []ItemField +} + +// CreateFromTemplate creates an item with all template data in a single transaction. +func (e *ItemsRepository) CreateFromTemplate(ctx context.Context, gid uuid.UUID, data ItemCreateFromTemplate) (ItemOut, error) { + tx, err := e.db.Tx(ctx) + if err != nil { + return ItemOut{}, err + } + committed := false + defer func() { + if !committed { + if err := tx.Rollback(); err != nil { + log.Warn().Err(err).Msg("failed to rollback transaction during template item creation") + } + } + }() + + // Get next asset ID within transaction + nextAssetID, err := e.GetHighestAssetIDTx(ctx, tx, gid) + if err != nil { + return ItemOut{}, err + } + nextAssetID++ + + // Create item with all template data + newItemID := uuid.New() + itemBuilder := tx.Item.Create(). + SetID(newItemID). + SetName(data.Name). + SetDescription(data.Description). + SetQuantity(data.Quantity). + SetLocationID(data.LocationID). + SetGroupID(gid). + SetAssetID(int(nextAssetID)). + SetInsured(data.Insured). + SetManufacturer(data.Manufacturer). + SetModelNumber(data.ModelNumber). + SetLifetimeWarranty(data.LifetimeWarranty). + SetWarrantyDetails(data.WarrantyDetails) + + if len(data.LabelIDs) > 0 { + itemBuilder.AddLabelIDs(data.LabelIDs...) + } + + _, err = itemBuilder.Save(ctx) + if err != nil { + return ItemOut{}, err + } + + // Create custom fields + for _, field := range data.Fields { + _, err = tx.ItemField.Create(). + SetItemID(newItemID). + SetType(itemfield.Type(field.Type)). + SetName(field.Name). + SetTextValue(field.TextValue). + Save(ctx) + if err != nil { + return ItemOut{}, fmt.Errorf("failed to create field %s: %w", field.Name, err) + } + } + + if err = tx.Commit(); err != nil { + return ItemOut{}, err + } + committed = true + + e.publishMutationEvent(gid) + return e.GetOne(ctx, newItemID) +} + func (e *ItemsRepository) Delete(ctx context.Context, id uuid.UUID) error { - err := e.db.Entity.DeleteOneID(id).Exec(ctx) + // Get the item with its group and attachments before deletion + itm, err := e.db.Item.Query(). + Where(item.ID(id)). + WithGroup(). + WithAttachments(). + Only(ctx) + if err != nil { + return err + } + + // Get the group ID for attachment deletion + var gid uuid.UUID + if itm.Edges.Group != nil { + gid = itm.Edges.Group.ID + } + + // Delete all attachments (and their files) before deleting the item + for _, att := range itm.Edges.Attachments { + err := e.attachments.Delete(ctx, gid, id, att.ID) + if err != nil { + log.Err(err).Str("attachment_id", att.ID.String()).Msg("failed to delete attachment during item deletion") + // Continue with other attachments even if one fails + } + } + + err = e.db.Item.DeleteOneID(id).Exec(ctx) if err != nil { return err } @@ -659,7 +791,28 @@ func (e *ItemsRepository) Delete(ctx context.Context, id uuid.UUID) error { } func (e *ItemsRepository) DeleteByGroup(ctx context.Context, gid, id uuid.UUID) error { - _, err := e.db.Entity. + // Get the item with its attachments before deletion + itm, err := e.db.Item.Query(). + Where( + item.ID(id), + item.HasGroupWith(group.ID(gid)), + ). + WithAttachments(). + Only(ctx) + if err != nil { + return err + } + + // Delete all attachments (and their files) before deleting the item + for _, att := range itm.Edges.Attachments { + err := e.attachments.Delete(ctx, gid, id, att.ID) + if err != nil { + log.Err(err).Str("attachment_id", att.ID.String()).Msg("failed to delete attachment during item deletion") + // Continue with other attachments even if one fails + } + } + + _, err = e.db.Item. Delete(). Where( entity.ID(id), @@ -1142,12 +1295,12 @@ func (e *ItemsRepository) Duplicate(ctx context.Context, gid, id uuid.UUID, opti }() // Get the original item with all its data - originalItem, err := e.getOne(ctx, entity.ID(id), entity.HasGroupWith(group.ID(gid))) + originalItem, err := e.getOneTx(ctx, tx, item.ID(id), item.HasGroupWith(group.ID(gid))) if err != nil { return ItemOut{}, err } - nextAssetID, err := e.GetHighestAssetID(ctx, gid) + nextAssetID, err := e.GetHighestAssetIDTx(ctx, tx, gid) if err != nil { return ItemOut{}, err } diff --git a/backend/internal/data/repo/repo_items_search_test.go b/backend/internal/data/repo/repo_items_search_test.go index 76019a61..e2156815 100644 --- a/backend/internal/data/repo/repo_items_search_test.go +++ b/backend/internal/data/repo/repo_items_search_test.go @@ -164,7 +164,7 @@ func TestItemsRepository_AccentInsensitiveSearch(t *testing.T) { if tc.shouldMatch { // If it should match, then either the original query should match // or the normalized query should match when applied to the stored data - assert.NotEmpty(t, normalizedSearch, "Normalized search should not be empty") + assert.NotEqual(t, "", normalizedSearch, "Normalized search should not be empty") // The key insight is that we're searching with both the original and normalized queries // So "electrónica" will be found when searching for "electronica" because: diff --git a/backend/internal/data/repo/repo_items_test.go b/backend/internal/data/repo/repo_items_test.go index 870bcd0c..b2f29440 100644 --- a/backend/internal/data/repo/repo_items_test.go +++ b/backend/internal/data/repo/repo_items_test.go @@ -2,12 +2,14 @@ package repo import ( "context" + "strings" "testing" "time" "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment" "github.com/sysadminsmedia/homebox/backend/internal/data/types" ) @@ -317,3 +319,83 @@ func TestItemRepository_GetAllCustomFields(t *testing.T) { assert.ElementsMatch(t, values[:1], results) } } + +func TestItemsRepository_DeleteWithAttachments(t *testing.T) { + // Create an item with an attachment + item := useItems(t, 1)[0] + + // Add an attachment to the item + attachment, err := tRepos.Attachments.Create( + context.Background(), + item.ID, + ItemCreateAttachment{ + Title: "test-attachment.txt", + Content: strings.NewReader("test content for attachment deletion"), + }, + attachment.TypePhoto, + true, + ) + require.NoError(t, err) + assert.NotNil(t, attachment) + + // Verify the attachment exists + retrievedAttachment, err := tRepos.Attachments.Get(context.Background(), tGroup.ID, attachment.ID) + require.NoError(t, err) + assert.Equal(t, attachment.ID, retrievedAttachment.ID) + + // Verify the attachment is linked to the item + itemWithAttachments, err := tRepos.Items.GetOne(context.Background(), item.ID) + require.NoError(t, err) + assert.Len(t, itemWithAttachments.Attachments, 1) + assert.Equal(t, attachment.ID, itemWithAttachments.Attachments[0].ID) + + // Delete the item + err = tRepos.Items.Delete(context.Background(), item.ID) + require.NoError(t, err) + + // Verify the item is deleted + _, err = tRepos.Items.GetOne(context.Background(), item.ID) + require.Error(t, err) + + // Verify the attachment is also deleted + _, err = tRepos.Attachments.Get(context.Background(), tGroup.ID, attachment.ID) + require.Error(t, err) +} + +func TestItemsRepository_DeleteByGroupWithAttachments(t *testing.T) { + // Create an item with an attachment + item := useItems(t, 1)[0] + + // Add an attachment to the item + attachment, err := tRepos.Attachments.Create( + context.Background(), + item.ID, + ItemCreateAttachment{ + Title: "test-attachment-by-group.txt", + Content: strings.NewReader("test content for attachment deletion by group"), + }, + attachment.TypePhoto, + true, + ) + require.NoError(t, err) + assert.NotNil(t, attachment) + + // Verify the attachment exists + retrievedAttachment, err := tRepos.Attachments.Get(context.Background(), tGroup.ID, attachment.ID) + require.NoError(t, err) + assert.Equal(t, attachment.ID, retrievedAttachment.ID) + + // Delete the item using DeleteByGroup + err = tRepos.Items.DeleteByGroup(context.Background(), tGroup.ID, item.ID) + require.NoError(t, err) + + // Verify the item is deleted + _, err = tRepos.Items.GetOneByGroup(context.Background(), tGroup.ID, item.ID) + require.Error(t, err) + + // Verify the attachment is also deleted + _, err = tRepos.Attachments.Get(context.Background(), tGroup.ID, attachment.ID) + require.Error(t, err) +} + + diff --git a/backend/internal/data/repo/repo_users.go b/backend/internal/data/repo/repo_users.go index 8007fbc0..9af394fa 100644 --- a/backend/internal/data/repo/repo_users.go +++ b/backend/internal/data/repo/repo_users.go @@ -19,7 +19,7 @@ type ( UserCreate struct { Name string `json:"name"` Email string `json:"email"` - Password string `json:"password"` + Password *string `json:"password"` IsSuperuser bool `json:"isSuperuser"` GroupID uuid.UUID `json:"groupID"` IsOwner bool `json:"isOwner"` @@ -39,6 +39,8 @@ type ( GroupName string `json:"groupName"` PasswordHash string `json:"-"` IsOwner bool `json:"isOwner"` + OidcIssuer *string `json:"oidcIssuer"` + OidcSubject *string `json:"oidcSubject"` } ) @@ -48,6 +50,11 @@ var ( ) func mapUserOut(user *ent.User) UserOut { + var passwordHash string + if user.Password != nil { + passwordHash = *user.Password + } + return UserOut{ ID: user.ID, Name: user.Name, @@ -55,8 +62,10 @@ func mapUserOut(user *ent.User) UserOut { IsSuperuser: user.IsSuperuser, GroupID: user.Edges.Group.ID, GroupName: user.Edges.Group.Name, - PasswordHash: user.Password, + PasswordHash: passwordHash, IsOwner: user.Role == "owner", + OidcIssuer: user.OidcIssuer, + OidcSubject: user.OidcSubject, } } @@ -85,15 +94,48 @@ func (r *UserRepository) Create(ctx context.Context, usr UserCreate) (UserOut, e role = user.RoleOwner } - entUser, err := r.db.User. + createQuery := r.db.User. + Create(). + SetName(usr.Name). + SetEmail(usr.Email). + SetIsSuperuser(usr.IsSuperuser). + SetGroupID(usr.GroupID). + SetRole(role) + + // Only set password if provided (non-nil) + if usr.Password != nil { + createQuery = createQuery.SetPassword(*usr.Password) + } + + entUser, err := createQuery.Save(ctx) + if err != nil { + return UserOut{}, err + } + + return r.GetOneID(ctx, entUser.ID) +} + +func (r *UserRepository) CreateWithOIDC(ctx context.Context, usr UserCreate, issuer, subject string) (UserOut, error) { + role := user.RoleUser + if usr.IsOwner { + role = user.RoleOwner + } + + createQuery := r.db.User. Create(). SetName(usr.Name). SetEmail(usr.Email). - SetPassword(usr.Password). SetIsSuperuser(usr.IsSuperuser). SetGroupID(usr.GroupID). SetRole(role). - Save(ctx) + SetOidcIssuer(issuer). + SetOidcSubject(subject) + + if usr.Password != nil { + createQuery = createQuery.SetPassword(*usr.Password) + } + + entUser, err := createQuery.Save(ctx) if err != nil { return UserOut{}, err } @@ -133,3 +175,14 @@ func (r *UserRepository) GetSuperusers(ctx context.Context) ([]*ent.User, error) func (r *UserRepository) ChangePassword(ctx context.Context, uid uuid.UUID, pw string) error { return r.db.User.UpdateOneID(uid).SetPassword(pw).Exec(ctx) } + +func (r *UserRepository) SetOIDCIdentity(ctx context.Context, uid uuid.UUID, issuer, subject string) error { + return r.db.User.UpdateOneID(uid).SetOidcIssuer(issuer).SetOidcSubject(subject).Exec(ctx) +} + +func (r *UserRepository) GetOneOIDC(ctx context.Context, issuer, subject string) (UserOut, error) { + return mapUserOutErr(r.db.User.Query(). + Where(user.OidcIssuerEQ(issuer), user.OidcSubjectEQ(subject)). + WithGroup(). + Only(ctx)) +} diff --git a/backend/internal/data/repo/repo_users_test.go b/backend/internal/data/repo/repo_users_test.go index abf62580..65de5e0b 100644 --- a/backend/internal/data/repo/repo_users_test.go +++ b/backend/internal/data/repo/repo_users_test.go @@ -9,10 +9,11 @@ import ( ) func userFactory() UserCreate { + password := fk.Str(10) return UserCreate{ Name: fk.Str(10), Email: fk.Email(), - Password: fk.Str(10), + Password: &password, IsSuperuser: fk.Bool(), GroupID: tGroup.ID, } diff --git a/backend/internal/data/repo/repos_all.go b/backend/internal/data/repo/repos_all.go index 15103aed..af95091e 100644 --- a/backend/internal/data/repo/repos_all.go +++ b/backend/internal/data/repo/repos_all.go @@ -20,9 +20,11 @@ type AllRepos struct { Notifiers *NotifierRepository EntityType *EntityTypeRepository Entities *EntitiesRepository + ItemTemplates *ItemTemplatesRepository } func New(db *ent.Client, bus *eventbus.EventBus, storage config.Storage, pubSubConn string, thumbnail config.Thumbnail) *AllRepos { + attachments := &AttachmentRepo{db, storage, pubSubConn, thumbnail} return &AllRepos{ Users: &UserRepository{db}, AuthTokens: &TokenRepository{db}, @@ -35,5 +37,6 @@ func New(db *ent.Client, bus *eventbus.EventBus, storage config.Storage, pubSubC Notifiers: NewNotifierRepository(db), EntityType: &EntityTypeRepository{db, bus}, Entities: &EntitiesRepository{db, bus}, + ItemTemplates: &ItemTemplatesRepository{db, bus}, } } diff --git a/backend/internal/sys/config/conf.go b/backend/internal/sys/config/conf.go index a2b52351..9b6b560d 100644 --- a/backend/internal/sys/config/conf.go +++ b/backend/internal/sys/config/conf.go @@ -27,6 +27,7 @@ type Config struct { Demo bool `yaml:"demo"` Debug DebugConf `yaml:"debug"` Options Options `yaml:"options"` + OIDC OIDCConf `yaml:"oidc"` LabelMaker LabelMakerConf `yaml:"labelmaker"` Thumbnail Thumbnail `yaml:"thumbnail"` Barcode BarcodeAPIConf `yaml:"barcode"` @@ -38,6 +39,9 @@ type Options struct { CurrencyConfig string `yaml:"currencies"` GithubReleaseCheck bool `yaml:"check_github_release" conf:"default:true"` AllowAnalytics bool `yaml:"allow_analytics" conf:"default:false"` + AllowLocalLogin bool `yaml:"allow_local_login" conf:"default:true"` + TrustProxy bool `yaml:"trust_proxy" conf:"default:false"` + Hostname string `yaml:"hostname"` } type Thumbnail struct { @@ -71,6 +75,26 @@ type LabelMakerConf struct { DynamicLength bool `yaml:"bool" conf:"default:true"` LabelServiceUrl *string `yaml:"label_service_url"` LabelServiceTimeout *time.Duration `yaml:"label_service_timeout"` + RegularFontPath *string `yaml:"regular_font_path"` + BoldFontPath *string `yaml:"bold_font_path"` +} + +type OIDCConf struct { + Enabled bool `yaml:"enabled" conf:"default:false"` + IssuerURL string `yaml:"issuer_url"` + ClientID string `yaml:"client_id"` + ClientSecret string `yaml:"client_secret"` + Scope string `yaml:"scope" conf:"default:openid profile email"` + AllowedGroups string `yaml:"allowed_groups"` + AutoRedirect bool `yaml:"auto_redirect" conf:"default:false"` + VerifyEmail bool `yaml:"verify_email" conf:"default:false"` + GroupClaim string `yaml:"group_claim" conf:"default:groups"` + EmailClaim string `yaml:"email_claim" conf:"default:email"` + NameClaim string `yaml:"name_claim" conf:"default:name"` + EmailVerifiedClaim string `yaml:"email_verified_claim" conf:"default:email_verified"` + ButtonText string `yaml:"button_text" conf:"default:Sign in with OIDC"` + StateExpiry time.Duration `yaml:"state_expiry" conf:"default:10m"` + RequestTimeout time.Duration `yaml:"request_timeout" conf:"default:30s"` } type BarcodeAPIConf struct { diff --git a/backend/pkgs/labelmaker/labelmaker.go b/backend/pkgs/labelmaker/labelmaker.go index a28bb72a..49dc3f0d 100644 --- a/backend/pkgs/labelmaker/labelmaker.go +++ b/backend/pkgs/labelmaker/labelmaker.go @@ -27,6 +27,13 @@ import ( "golang.org/x/image/font/gofont/gomedium" ) +type FontType int + +const ( + FontTypeRegular FontType = iota + FontTypeBold +) + type GenerateParameters struct { Width int Height int @@ -140,6 +147,48 @@ func wrapText(text string, face font.Face, maxWidth int, maxHeight int, lineHeig return wrappedLines, "" } +func loadFont(cfg *config.Config, fontType FontType) (*truetype.Font, error) { + var fontPath *string + var fallbackData []byte + + switch fontType { + case FontTypeRegular: + if cfg != nil && cfg.LabelMaker.RegularFontPath != nil { + fontPath = cfg.LabelMaker.RegularFontPath + } + fallbackData = gomedium.TTF + case FontTypeBold: + if cfg != nil && cfg.LabelMaker.BoldFontPath != nil { + fontPath = cfg.LabelMaker.BoldFontPath + } + fallbackData = gobold.TTF + default: + return nil, fmt.Errorf("unknown font type: %d", fontType) + } + + if fontPath != nil && *fontPath != "" { + data, err := os.ReadFile(*fontPath) + if err != nil { + log.Printf("Failed to load font from %s: %v, using fallback font", *fontPath, err) + } else { + font, err := truetype.Parse(data) + if err != nil { + log.Printf("Failed to parse font from %s: %v, using fallback font", *fontPath, err) + } else { + log.Printf("Successfully loaded font from %s", *fontPath) + return font, nil + } + } + } + + font, err := truetype.Parse(fallbackData) + if err != nil { + return nil, err + } + + return font, nil +} + func GenerateLabel(w io.Writer, params *GenerateParameters, cfg *config.Config) error { if err := params.Validate(); err != nil { return err @@ -165,12 +214,12 @@ func GenerateLabel(w io.Writer, params *GenerateParameters, cfg *config.Config) qr.DisableBorder = true qrImage := qr.Image(params.QrSize) - regularFont, err := truetype.Parse(gomedium.TTF) + regularFont, err := loadFont(cfg, FontTypeRegular) if err != nil { return err } - boldFont, err := truetype.Parse(gobold.TTF) + boldFont, err := loadFont(cfg, FontTypeBold) if err != nil { return err } diff --git a/backend/pkgs/labelmaker/labelmaker_test.go b/backend/pkgs/labelmaker/labelmaker_test.go new file mode 100644 index 00000000..3ee3d73c --- /dev/null +++ b/backend/pkgs/labelmaker/labelmaker_test.go @@ -0,0 +1,187 @@ +package labelmaker + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/sysadminsmedia/homebox/backend/internal/sys/config" + "golang.org/x/image/font/gofont/gobold" + "golang.org/x/image/font/gofont/gomedium" +) + +func TestLoadFont_WithNilConfig(t *testing.T) { + font, err := loadFont(nil, FontTypeRegular) + require.NoError(t, err) + assert.NotNil(t, font) + + font, err = loadFont(nil, FontTypeBold) + require.NoError(t, err) + assert.NotNil(t, font) +} + +func TestLoadFont_WithEmptyConfig(t *testing.T) { + cfg := &config.Config{} + + font, err := loadFont(cfg, FontTypeRegular) + require.NoError(t, err) + assert.NotNil(t, font) + + font, err = loadFont(cfg, FontTypeBold) + require.NoError(t, err) + assert.NotNil(t, font) +} + +func TestLoadFont_WithCustomFontPath(t *testing.T) { + tempDir := t.TempDir() + fontPath := filepath.Join(tempDir, "test-font.ttf") + + err := os.WriteFile(fontPath, gomedium.TTF, 0644) + require.NoError(t, err) + + cfg := &config.Config{ + LabelMaker: config.LabelMakerConf{ + RegularFontPath: &fontPath, + }, + } + + font, err := loadFont(cfg, FontTypeRegular) + require.NoError(t, err) + assert.NotNil(t, font) +} + +func TestLoadFont_WithNonExistentFontPath(t *testing.T) { + nonExistentPath := "/non/existent/path/font.ttf" + cfg := &config.Config{ + LabelMaker: config.LabelMakerConf{ + RegularFontPath: &nonExistentPath, + }, + } + + font, err := loadFont(cfg, FontTypeRegular) + require.NoError(t, err) + assert.NotNil(t, font) +} + +func TestLoadFont_UnknownFontType(t *testing.T) { + cfg := &config.Config{} + + _, err := loadFont(cfg, FontType(999)) + require.Error(t, err) + assert.Contains(t, err.Error(), "unknown font type") +} + +func TestLoadFont_BoldFontWithCustomPath(t *testing.T) { + tempDir := t.TempDir() + fontPath := filepath.Join(tempDir, "test-bold-font.ttf") + + err := os.WriteFile(fontPath, gobold.TTF, 0644) + require.NoError(t, err) + + cfg := &config.Config{ + LabelMaker: config.LabelMakerConf{ + BoldFontPath: &fontPath, + }, + } + + font, err := loadFont(cfg, FontTypeBold) + require.NoError(t, err) + assert.NotNil(t, font) +} + +func TestLoadFont_EmptyStringPath(t *testing.T) { + emptyPath := "" + cfg := &config.Config{ + LabelMaker: config.LabelMakerConf{ + RegularFontPath: &emptyPath, + }, + } + + font, err := loadFont(cfg, FontTypeRegular) + require.NoError(t, err) + assert.NotNil(t, font) +} + +func TestLoadFont_CJKRendering(t *testing.T) { + cjkFontPath := filepath.Join("testdata", "NotoSansKR-VF.ttf") + + tests := []struct { + name string + text string + fontPath string + shouldHaveGlyph bool + }{ + { + name: "Korean with default font", + text: "한글", + fontPath: "", + shouldHaveGlyph: false, + }, + { + name: "Chinese with default font", + text: "中文", + fontPath: "", + shouldHaveGlyph: false, + }, + { + name: "Japanese with default font", + text: "ひらがなカタカナ", + fontPath: "", + shouldHaveGlyph: false, + }, + { + name: "Korean with Noto Sans CJK", + text: "한글", + fontPath: cjkFontPath, + shouldHaveGlyph: true, + }, + { + name: "Chinese with Noto Sans CJK", + text: "中文", + fontPath: cjkFontPath, + shouldHaveGlyph: true, + }, + { + name: "Japanese with Noto Sans CJK", + text: "ひらがなカタカナ", + fontPath: cjkFontPath, + shouldHaveGlyph: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + var cfg *config.Config + if tt.fontPath != "" { + if _, err := os.Stat(tt.fontPath); os.IsNotExist(err) { + t.Skipf("Font file not found: %s", tt.fontPath) + } + cfg = &config.Config{ + LabelMaker: config.LabelMakerConf{ + RegularFontPath: &tt.fontPath, + }, + } + } + + font, err := loadFont(cfg, FontTypeRegular) + require.NoError(t, err) + require.NotNil(t, font) + + hasAllGlyphs := true + for _, r := range tt.text { + if font.Index(r) == 0 { + hasAllGlyphs = false + break + } + } + + if tt.shouldHaveGlyph { + assert.True(t, hasAllGlyphs, "Font should render %s characters", tt.name) + } else { + assert.False(t, hasAllGlyphs, "Default font should not render %s characters", tt.name) + } + }) + } +} diff --git a/backend/pkgs/labelmaker/testdata/NotoSans-LICENSE b/backend/pkgs/labelmaker/testdata/NotoSans-LICENSE new file mode 100644 index 00000000..d952d62c --- /dev/null +++ b/backend/pkgs/labelmaker/testdata/NotoSans-LICENSE @@ -0,0 +1,92 @@ +This Font Software is licensed under the SIL Open Font License, +Version 1.1. + +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font +creation efforts of academic and linguistic communities, and to +provide a free and open framework in which fonts may be shared and +improved in partnership with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply to +any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software +components as distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, +deleting, or substituting -- in part or in whole -- any of the +components of the Original Version, by changing formats or by porting +the Font Software to a new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, +modify, redistribute, and sell modified and unmodified copies of the +Font Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, in +Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the +corresponding Copyright Holder. This restriction only applies to the +primary font name as presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created using +the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/backend/pkgs/labelmaker/testdata/NotoSansKR-VF.ttf b/backend/pkgs/labelmaker/testdata/NotoSansKR-VF.ttf new file mode 100644 index 00000000..15b3f19b Binary files /dev/null and b/backend/pkgs/labelmaker/testdata/NotoSansKR-VF.ttf differ diff --git a/backend/pkgs/labelmaker/testdata/README.md b/backend/pkgs/labelmaker/testdata/README.md new file mode 100644 index 00000000..b37ff888 --- /dev/null +++ b/backend/pkgs/labelmaker/testdata/README.md @@ -0,0 +1,15 @@ +# Test Data + +This directory contains font files used only for testing purposes. + +## Fonts + +- **NotoSansKR-VF.ttf**: Noto Sans CJK Korean Variable Font + - Used for testing CJK (Chinese, Japanese, Korean) character rendering + - License: See `NotoSans-LICENSE` file + +## Notes + +- These fonts are **only used during testing** and are **not included in production builds** +- Go's build system automatically excludes `testdata` directories from production builds +- The fonts support rendering of Korean, Chinese, and Japanese characters diff --git a/docker-compose.yml b/docker-compose.yml index e0240c29..4f7fa53e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ services: image: homebox build: context: . - dockerfile: ./Dockerfile.hardened + dockerfile: ./Dockerfile args: - COMMIT=head - BUILD_TIME=0001-01-01T00:00:00Z @@ -11,7 +11,7 @@ services: platforms: - linux/amd64 - linux/arm64 - - linux/arm/v7 + - linux/arm environment: - HBOX_DEBUG=true - HBOX_LOGGER_LEVEL=-1 diff --git a/docs/en/api/openapi-2.0.json b/docs/en/api/openapi-2.0.json new file mode 100644 index 00000000..cd4721fa --- /dev/null +++ b/docs/en/api/openapi-2.0.json @@ -0,0 +1,5195 @@ +{ + "schemes": [ + "https", + "http" + ], + "swagger": "2.0", + "info": { + "description": "Track, Manage, and Organize your Things.", + "title": "Homebox API", + "contact": { + "name": "Homebox Team", + "url": "https://discord.homebox.software" + }, + "version": "1.0" + }, + "host": "demo.homebox.software", + "basePath": "/api", + "paths": { + "/v1/actions/create-missing-thumbnails": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Creates thumbnails for items that are missing them", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Create Missing Thumbnails", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, + "/v1/actions/ensure-asset-ids": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Ensures all items in the database have an asset ID", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Ensure Asset IDs", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, + "/v1/actions/ensure-import-refs": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Ensures all items in the database have an import ref", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Ensures Import Refs", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, + "/v1/actions/set-primary-photos": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Sets the first photo of each item as the primary photo", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Set Primary Photos", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, + "/v1/actions/zero-item-time-fields": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Resets all item date fields to the beginning of the day", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Zero Out Time Fields", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, + "/v1/assets/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get Item by Asset ID", + "parameters": [ + { + "type": "string", + "description": "Asset ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.PaginationResult-repo_ItemSummary" + } + } + } + } + }, + "/v1/currency": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "Base" + ], + "summary": "Currency", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/currencies.Currency" + } + } + } + } + }, + "/v1/groups": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Group" + ], + "summary": "Get Group", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.Group" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Group" + ], + "summary": "Update Group", + "parameters": [ + { + "description": "User Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.GroupUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.Group" + } + } + } + } + }, + "/v1/groups/invitations": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Group" + ], + "summary": "Create Group Invitation", + "parameters": [ + { + "description": "User Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.GroupInvitationCreate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.GroupInvitation" + } + } + } + } + }, + "/v1/groups/statistics": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Statistics" + ], + "summary": "Get Group Statistics", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.GroupStatistics" + } + } + } + } + }, + "/v1/groups/statistics/labels": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Statistics" + ], + "summary": "Get Label Statistics", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.TotalsByOrganizer" + } + } + } + } + } + }, + "/v1/groups/statistics/locations": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Statistics" + ], + "summary": "Get Location Statistics", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.TotalsByOrganizer" + } + } + } + } + } + }, + "/v1/groups/statistics/purchase-price": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Statistics" + ], + "summary": "Get Purchase Price Statistics", + "parameters": [ + { + "type": "string", + "description": "start date", + "name": "start", + "in": "query" + }, + { + "type": "string", + "description": "end date", + "name": "end", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ValueOverTime" + } + } + } + } + }, + "/v1/items": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Query All Items", + "parameters": [ + { + "type": "string", + "description": "search string", + "name": "q", + "in": "query" + }, + { + "type": "integer", + "description": "page number", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "items per page", + "name": "pageSize", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "label Ids", + "name": "labels", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "location Ids", + "name": "locations", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "parent Ids", + "name": "parentIds", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.PaginationResult-repo_ItemSummary" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Create Item", + "parameters": [ + { + "description": "Item Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemCreate" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.ItemSummary" + } + } + } + } + }, + "/v1/items/export": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Items" + ], + "summary": "Export Items", + "responses": { + "200": { + "description": "text/csv", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/items/fields": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get All Custom Field Names", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + }, + "/v1/items/fields/values": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get All Custom Field Values", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + }, + "/v1/items/import": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Import Items", + "parameters": [ + { + "type": "file", + "description": "Image to upload", + "name": "csv", + "in": "formData", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/items/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get Item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Update Item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Item Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Delete Item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + }, + "patch": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Update Item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Item Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemPatch" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + } + }, + "/v1/items/{id}/attachments": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items Attachments" + ], + "summary": "Create Item Attachment", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "file", + "description": "File attachment", + "name": "file", + "in": "formData", + "required": true + }, + { + "type": "string", + "description": "Type of file", + "name": "type", + "in": "formData" + }, + { + "type": "boolean", + "description": "Is this the primary attachment", + "name": "primary", + "in": "formData" + }, + { + "type": "string", + "description": "name of the file including extension", + "name": "name", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + }, + "422": { + "description": "Unprocessable Entity", + "schema": { + "$ref": "#/definitions/validate.ErrorResponse" + } + } + } + } + }, + "/v1/items/{id}/attachments/{attachment_id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/octet-stream" + ], + "tags": [ + "Items Attachments" + ], + "summary": "Get Item Attachment", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Attachment ID", + "name": "attachment_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ItemAttachmentToken" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Items Attachments" + ], + "summary": "Update Item Attachment", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Attachment ID", + "name": "attachment_id", + "in": "path", + "required": true + }, + { + "description": "Attachment Update", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemAttachmentUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Items Attachments" + ], + "summary": "Delete Item Attachment", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Attachment ID", + "name": "attachment_id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/items/{id}/duplicate": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Duplicate Item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Duplicate Options", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.DuplicateOptions" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + } + }, + "/v1/items/{id}/maintenance": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Maintenance" + ], + "summary": "Get Maintenance Log", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "enum": [ + "scheduled", + "completed", + "both" + ], + "type": "string", + "x-enum-varnames": [ + "MaintenanceFilterStatusScheduled", + "MaintenanceFilterStatusCompleted", + "MaintenanceFilterStatusBoth" + ], + "name": "status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.MaintenanceEntryWithDetails" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Maintenance" + ], + "summary": "Create Maintenance Entry", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Entry Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.MaintenanceEntryCreate" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.MaintenanceEntry" + } + } + } + } + }, + "/v1/items/{id}/path": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get the full path of an item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemPath" + } + } + } + } + } + }, + "/v1/labelmaker/assets/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get Asset label", + "parameters": [ + { + "type": "string", + "description": "Asset ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "Print this label, defaults to false", + "name": "print", + "in": "query" + } + ], + "responses": { + "200": { + "description": "image/png", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/labelmaker/item/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get Item label", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "Print this label, defaults to false", + "name": "print", + "in": "query" + } + ], + "responses": { + "200": { + "description": "image/png", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/labelmaker/location/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Get Location label", + "parameters": [ + { + "type": "string", + "description": "Location ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "Print this label, defaults to false", + "name": "print", + "in": "query" + } + ], + "responses": { + "200": { + "description": "image/png", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/labels": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Labels" + ], + "summary": "Get All Labels", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.LabelOut" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Labels" + ], + "summary": "Create Label", + "parameters": [ + { + "description": "Label Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.LabelCreate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LabelSummary" + } + } + } + } + }, + "/v1/labels/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Labels" + ], + "summary": "Get Label", + "parameters": [ + { + "type": "string", + "description": "Label ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LabelOut" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Labels" + ], + "summary": "Update Label", + "parameters": [ + { + "type": "string", + "description": "Label ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LabelOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Labels" + ], + "summary": "Delete Label", + "parameters": [ + { + "type": "string", + "description": "Label ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/locations": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Get All Locations", + "parameters": [ + { + "type": "boolean", + "description": "Filter locations with parents", + "name": "filterChildren", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.LocationOutCount" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Create Location", + "parameters": [ + { + "description": "Location Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.LocationCreate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LocationSummary" + } + } + } + } + }, + "/v1/locations/tree": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Get Locations Tree", + "parameters": [ + { + "type": "boolean", + "description": "include items in response tree", + "name": "withItems", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.TreeItem" + } + } + } + } + } + }, + "/v1/locations/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Get Location", + "parameters": [ + { + "type": "string", + "description": "Location ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LocationOut" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Update Location", + "parameters": [ + { + "type": "string", + "description": "Location ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Location Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.LocationUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LocationOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Delete Location", + "parameters": [ + { + "type": "string", + "description": "Location ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/maintenance": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Maintenance" + ], + "summary": "Query All Maintenance", + "parameters": [ + { + "enum": [ + "scheduled", + "completed", + "both" + ], + "type": "string", + "x-enum-varnames": [ + "MaintenanceFilterStatusScheduled", + "MaintenanceFilterStatusCompleted", + "MaintenanceFilterStatusBoth" + ], + "name": "status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.MaintenanceEntryWithDetails" + } + } + } + } + } + }, + "/v1/maintenance/{id}": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Maintenance" + ], + "summary": "Update Maintenance Entry", + "parameters": [ + { + "type": "string", + "description": "Maintenance ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Entry Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.MaintenanceEntryUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.MaintenanceEntry" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Maintenance" + ], + "summary": "Delete Maintenance Entry", + "parameters": [ + { + "type": "string", + "description": "Maintenance ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/notifiers": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Notifiers" + ], + "summary": "Get Notifiers", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.NotifierOut" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Notifiers" + ], + "summary": "Create Notifier", + "parameters": [ + { + "description": "Notifier Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.NotifierCreate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.NotifierOut" + } + } + } + } + }, + "/v1/notifiers/test": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Notifiers" + ], + "summary": "Test Notifier", + "parameters": [ + { + "type": "string", + "description": "URL", + "name": "url", + "in": "query", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/notifiers/{id}": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Notifiers" + ], + "summary": "Update Notifier", + "parameters": [ + { + "type": "string", + "description": "Notifier ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Notifier Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.NotifierUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.NotifierOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Notifiers" + ], + "summary": "Delete a Notifier", + "parameters": [ + { + "type": "string", + "description": "Notifier ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/products/search-from-barcode": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Search EAN from Barcode", + "parameters": [ + { + "type": "string", + "description": "barcode to be searched", + "name": "data", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.BarcodeProduct" + } + } + } + } + } + }, + "/v1/qrcode": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Create QR Code", + "parameters": [ + { + "type": "string", + "description": "data to be encoded into qrcode", + "name": "data", + "in": "query" + } + ], + "responses": { + "200": { + "description": "image/jpeg", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/reporting/bill-of-materials": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Reporting" + ], + "summary": "Export Bill of Materials", + "responses": { + "200": { + "description": "text/csv", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/status": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "Base" + ], + "summary": "Application Info", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.APISummary" + } + } + } + } + }, + "/v1/templates": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Get All Item Templates", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemTemplateSummary" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Create Item Template", + "parameters": [ + { + "description": "Template Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemTemplateCreate" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.ItemTemplateOut" + } + } + } + } + }, + "/v1/templates/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Get Item Template", + "parameters": [ + { + "type": "string", + "description": "Template ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemTemplateOut" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Update Item Template", + "parameters": [ + { + "type": "string", + "description": "Template ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Template Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemTemplateUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemTemplateOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Delete Item Template", + "parameters": [ + { + "type": "string", + "description": "Template ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/templates/{id}/create-item": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Create Item from Template", + "parameters": [ + { + "type": "string", + "description": "Template ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Item Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.ItemTemplateCreateItemRequest" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + } + }, + "/v1/users/change-password": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "User" + ], + "summary": "Change Password", + "parameters": [ + { + "description": "Password Payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.ChangePassword" + } + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/users/login": { + "post": { + "consumes": [ + "application/x-www-form-urlencoded", + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Authentication" + ], + "summary": "User Login", + "parameters": [ + { + "description": "Login Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.LoginForm" + } + }, + { + "type": "string", + "description": "auth provider", + "name": "provider", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.TokenResponse" + } + } + } + } + }, + "/v1/users/login/oidc": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "Authentication" + ], + "summary": "OIDC Login Initiation", + "responses": { + "302": { + "description": "Found" + } + } + } + }, + "/v1/users/login/oidc/callback": { + "get": { + "tags": [ + "Authentication" + ], + "summary": "OIDC Callback Handler", + "parameters": [ + { + "type": "string", + "description": "Authorization code", + "name": "code", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "State parameter", + "name": "state", + "in": "query", + "required": true + } + ], + "responses": { + "302": { + "description": "Found" + } + } + } + }, + "/v1/users/logout": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Authentication" + ], + "summary": "User Logout", + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/users/refresh": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "handleAuthRefresh returns a handler that will issue a new token from an existing token.\nThis does not validate that the user still exists within the database.", + "tags": [ + "Authentication" + ], + "summary": "User Token Refresh", + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/v1/users/register": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Register New User", + "parameters": [ + { + "description": "User Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/services.UserRegistration" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "403": { + "description": "Local login is not enabled", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/users/self": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Get User Self", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/v1.Wrapped" + }, + { + "type": "object", + "properties": { + "item": { + "$ref": "#/definitions/repo.UserOut" + } + } + } + ] + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Update Account", + "parameters": [ + { + "description": "User Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.UserUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/v1.Wrapped" + }, + { + "type": "object", + "properties": { + "item": { + "$ref": "#/definitions/repo.UserUpdate" + } + } + } + ] + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Delete Account", + "responses": { + "204": { + "description": "No Content" + } + } + } + } + }, + "definitions": { + "attachment.Type": { + "type": "string", + "enum": [ + "attachment", + "photo", + "manual", + "warranty", + "attachment", + "receipt", + "thumbnail" + ], + "x-enum-varnames": [ + "DefaultType", + "TypePhoto", + "TypeManual", + "TypeWarranty", + "TypeAttachment", + "TypeReceipt", + "TypeThumbnail" + ] + }, + "authroles.Role": { + "type": "string", + "enum": [ + "user", + "admin", + "user", + "attachments" + ], + "x-enum-varnames": [ + "DefaultRole", + "RoleAdmin", + "RoleUser", + "RoleAttachments" + ] + }, + "currencies.Currency": { + "type": "object", + "properties": { + "code": { + "type": "string" + }, + "decimals": { + "type": "integer" + }, + "local": { + "type": "string" + }, + "name": { + "type": "string" + }, + "symbol": { + "type": "string" + } + } + }, + "ent.Attachment": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AttachmentQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.AttachmentEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "mime_type": { + "description": "MimeType holds the value of the \"mime_type\" field.", + "type": "string" + }, + "path": { + "description": "Path holds the value of the \"path\" field.", + "type": "string" + }, + "primary": { + "description": "Primary holds the value of the \"primary\" field.", + "type": "boolean" + }, + "title": { + "description": "Title holds the value of the \"title\" field.", + "type": "string" + }, + "type": { + "description": "Type holds the value of the \"type\" field.", + "allOf": [ + { + "$ref": "#/definitions/attachment.Type" + } + ] + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.AttachmentEdges": { + "type": "object", + "properties": { + "item": { + "description": "Item holds the value of the item edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Item" + } + ] + }, + "thumbnail": { + "description": "Thumbnail holds the value of the thumbnail edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Attachment" + } + ] + } + } + }, + "ent.AuthRoles": { + "type": "object", + "properties": { + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AuthRolesQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.AuthRolesEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "integer" + }, + "role": { + "description": "Role holds the value of the \"role\" field.", + "allOf": [ + { + "$ref": "#/definitions/authroles.Role" + } + ] + } + } + }, + "ent.AuthRolesEdges": { + "type": "object", + "properties": { + "token": { + "description": "Token holds the value of the token edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.AuthTokens" + } + ] + } + } + }, + "ent.AuthTokens": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AuthTokensQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.AuthTokensEdges" + } + ] + }, + "expires_at": { + "description": "ExpiresAt holds the value of the \"expires_at\" field.", + "type": "string" + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "token": { + "description": "Token holds the value of the \"token\" field.", + "type": "array", + "items": { + "type": "integer" + } + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.AuthTokensEdges": { + "type": "object", + "properties": { + "roles": { + "description": "Roles holds the value of the roles edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.AuthRoles" + } + ] + }, + "user": { + "description": "User holds the value of the user edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.User" + } + ] + } + } + }, + "ent.Group": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "currency": { + "description": "Currency holds the value of the \"currency\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the GroupQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.GroupEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.GroupEdges": { + "type": "object", + "properties": { + "invitation_tokens": { + "description": "InvitationTokens holds the value of the invitation_tokens edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.GroupInvitationToken" + } + }, + "item_templates": { + "description": "ItemTemplates holds the value of the item_templates edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.ItemTemplate" + } + }, + "items": { + "description": "Items holds the value of the items edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Item" + } + }, + "labels": { + "description": "Labels holds the value of the labels edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Label" + } + }, + "locations": { + "description": "Locations holds the value of the locations edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Location" + } + }, + "notifiers": { + "description": "Notifiers holds the value of the notifiers edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Notifier" + } + }, + "users": { + "description": "Users holds the value of the users edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.User" + } + } + } + }, + "ent.GroupInvitationToken": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the GroupInvitationTokenQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.GroupInvitationTokenEdges" + } + ] + }, + "expires_at": { + "description": "ExpiresAt holds the value of the \"expires_at\" field.", + "type": "string" + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "token": { + "description": "Token holds the value of the \"token\" field.", + "type": "array", + "items": { + "type": "integer" + } + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + }, + "uses": { + "description": "Uses holds the value of the \"uses\" field.", + "type": "integer" + } + } + }, + "ent.GroupInvitationTokenEdges": { + "type": "object", + "properties": { + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + } + } + }, + "ent.Item": { + "type": "object", + "properties": { + "archived": { + "description": "Archived holds the value of the \"archived\" field.", + "type": "boolean" + }, + "asset_id": { + "description": "AssetID holds the value of the \"asset_id\" field.", + "type": "integer" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.ItemEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "import_ref": { + "description": "ImportRef holds the value of the \"import_ref\" field.", + "type": "string" + }, + "insured": { + "description": "Insured holds the value of the \"insured\" field.", + "type": "boolean" + }, + "lifetime_warranty": { + "description": "LifetimeWarranty holds the value of the \"lifetime_warranty\" field.", + "type": "boolean" + }, + "manufacturer": { + "description": "Manufacturer holds the value of the \"manufacturer\" field.", + "type": "string" + }, + "model_number": { + "description": "ModelNumber holds the value of the \"model_number\" field.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "notes": { + "description": "Notes holds the value of the \"notes\" field.", + "type": "string" + }, + "purchase_from": { + "description": "PurchaseFrom holds the value of the \"purchase_from\" field.", + "type": "string" + }, + "purchase_price": { + "description": "PurchasePrice holds the value of the \"purchase_price\" field.", + "type": "number" + }, + "purchase_time": { + "description": "PurchaseTime holds the value of the \"purchase_time\" field.", + "type": "string" + }, + "quantity": { + "description": "Quantity holds the value of the \"quantity\" field.", + "type": "integer" + }, + "serial_number": { + "description": "SerialNumber holds the value of the \"serial_number\" field.", + "type": "string" + }, + "sold_notes": { + "description": "SoldNotes holds the value of the \"sold_notes\" field.", + "type": "string" + }, + "sold_price": { + "description": "SoldPrice holds the value of the \"sold_price\" field.", + "type": "number" + }, + "sold_time": { + "description": "SoldTime holds the value of the \"sold_time\" field.", + "type": "string" + }, + "sold_to": { + "description": "SoldTo holds the value of the \"sold_to\" field.", + "type": "string" + }, + "sync_child_items_locations": { + "description": "SyncChildItemsLocations holds the value of the \"sync_child_items_locations\" field.", + "type": "boolean" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + }, + "warranty_details": { + "description": "WarrantyDetails holds the value of the \"warranty_details\" field.", + "type": "string" + }, + "warranty_expires": { + "description": "WarrantyExpires holds the value of the \"warranty_expires\" field.", + "type": "string" + } + } + }, + "ent.ItemEdges": { + "type": "object", + "properties": { + "attachments": { + "description": "Attachments holds the value of the attachments edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Attachment" + } + }, + "children": { + "description": "Children holds the value of the children edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Item" + } + }, + "fields": { + "description": "Fields holds the value of the fields edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.ItemField" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "label": { + "description": "Label holds the value of the label edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Label" + } + }, + "location": { + "description": "Location holds the value of the location edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Location" + } + ] + }, + "maintenance_entries": { + "description": "MaintenanceEntries holds the value of the maintenance_entries edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.MaintenanceEntry" + } + }, + "parent": { + "description": "Parent holds the value of the parent edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Item" + } + ] + } + } + }, + "ent.ItemField": { + "type": "object", + "properties": { + "boolean_value": { + "description": "BooleanValue holds the value of the \"boolean_value\" field.", + "type": "boolean" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemFieldQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.ItemFieldEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "number_value": { + "description": "NumberValue holds the value of the \"number_value\" field.", + "type": "integer" + }, + "text_value": { + "description": "TextValue holds the value of the \"text_value\" field.", + "type": "string" + }, + "time_value": { + "description": "TimeValue holds the value of the \"time_value\" field.", + "type": "string" + }, + "type": { + "description": "Type holds the value of the \"type\" field.", + "allOf": [ + { + "$ref": "#/definitions/itemfield.Type" + } + ] + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.ItemFieldEdges": { + "type": "object", + "properties": { + "item": { + "description": "Item holds the value of the item edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Item" + } + ] + } + } + }, + "ent.ItemTemplate": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "default_description": { + "description": "Default description for items created from this template", + "type": "string" + }, + "default_insured": { + "description": "DefaultInsured holds the value of the \"default_insured\" field.", + "type": "boolean" + }, + "default_label_ids": { + "description": "Default label IDs for items created from this template", + "type": "array", + "items": { + "type": "string" + } + }, + "default_lifetime_warranty": { + "description": "DefaultLifetimeWarranty holds the value of the \"default_lifetime_warranty\" field.", + "type": "boolean" + }, + "default_manufacturer": { + "description": "DefaultManufacturer holds the value of the \"default_manufacturer\" field.", + "type": "string" + }, + "default_model_number": { + "description": "Default model number for items created from this template", + "type": "string" + }, + "default_name": { + "description": "Default name template for items (can use placeholders)", + "type": "string" + }, + "default_quantity": { + "description": "DefaultQuantity holds the value of the \"default_quantity\" field.", + "type": "integer" + }, + "default_warranty_details": { + "description": "DefaultWarrantyDetails holds the value of the \"default_warranty_details\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemTemplateQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.ItemTemplateEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "include_purchase_fields": { + "description": "Whether to include purchase fields in items created from this template", + "type": "boolean" + }, + "include_sold_fields": { + "description": "Whether to include sold fields in items created from this template", + "type": "boolean" + }, + "include_warranty_fields": { + "description": "Whether to include warranty fields in items created from this template", + "type": "boolean" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "notes": { + "description": "Notes holds the value of the \"notes\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.ItemTemplateEdges": { + "type": "object", + "properties": { + "fields": { + "description": "Fields holds the value of the fields edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.TemplateField" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "location": { + "description": "Location holds the value of the location edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Location" + } + ] + } + } + }, + "ent.Label": { + "type": "object", + "properties": { + "color": { + "description": "Color holds the value of the \"color\" field.", + "type": "string" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LabelQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.LabelEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.LabelEdges": { + "type": "object", + "properties": { + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "items": { + "description": "Items holds the value of the items edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Item" + } + } + } + }, + "ent.Location": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LocationQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.LocationEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.LocationEdges": { + "type": "object", + "properties": { + "children": { + "description": "Children holds the value of the children edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Location" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "items": { + "description": "Items holds the value of the items edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Item" + } + }, + "parent": { + "description": "Parent holds the value of the parent edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Location" + } + ] + } + } + }, + "ent.MaintenanceEntry": { + "type": "object", + "properties": { + "cost": { + "description": "Cost holds the value of the \"cost\" field.", + "type": "number" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "date": { + "description": "Date holds the value of the \"date\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the MaintenanceEntryQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.MaintenanceEntryEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "item_id": { + "description": "ItemID holds the value of the \"item_id\" field.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "scheduled_date": { + "description": "ScheduledDate holds the value of the \"scheduled_date\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.MaintenanceEntryEdges": { + "type": "object", + "properties": { + "item": { + "description": "Item holds the value of the item edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Item" + } + ] + } + } + }, + "ent.Notifier": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the NotifierQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.NotifierEdges" + } + ] + }, + "group_id": { + "description": "GroupID holds the value of the \"group_id\" field.", + "type": "string" + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "is_active": { + "description": "IsActive holds the value of the \"is_active\" field.", + "type": "boolean" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + }, + "user_id": { + "description": "UserID holds the value of the \"user_id\" field.", + "type": "string" + } + } + }, + "ent.NotifierEdges": { + "type": "object", + "properties": { + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "user": { + "description": "User holds the value of the user edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.User" + } + ] + } + } + }, + "ent.TemplateField": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the TemplateFieldQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.TemplateFieldEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "text_value": { + "description": "TextValue holds the value of the \"text_value\" field.", + "type": "string" + }, + "type": { + "description": "Type holds the value of the \"type\" field.", + "allOf": [ + { + "$ref": "#/definitions/templatefield.Type" + } + ] + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.TemplateFieldEdges": { + "type": "object", + "properties": { + "item_template": { + "description": "ItemTemplate holds the value of the item_template edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.ItemTemplate" + } + ] + } + } + }, + "ent.User": { + "type": "object", + "properties": { + "activated_on": { + "description": "ActivatedOn holds the value of the \"activated_on\" field.", + "type": "string" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the UserQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.UserEdges" + } + ] + }, + "email": { + "description": "Email holds the value of the \"email\" field.", + "type": "string" + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "is_superuser": { + "description": "IsSuperuser holds the value of the \"is_superuser\" field.", + "type": "boolean" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "oidc_issuer": { + "description": "OidcIssuer holds the value of the \"oidc_issuer\" field.", + "type": "string" + }, + "oidc_subject": { + "description": "OidcSubject holds the value of the \"oidc_subject\" field.", + "type": "string" + }, + "role": { + "description": "Role holds the value of the \"role\" field.", + "allOf": [ + { + "$ref": "#/definitions/user.Role" + } + ] + }, + "superuser": { + "description": "Superuser holds the value of the \"superuser\" field.", + "type": "boolean" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.UserEdges": { + "type": "object", + "properties": { + "auth_tokens": { + "description": "AuthTokens holds the value of the auth_tokens edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.AuthTokens" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "notifiers": { + "description": "Notifiers holds the value of the notifiers edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Notifier" + } + } + } + }, + "itemfield.Type": { + "type": "string", + "enum": [ + "text", + "number", + "boolean", + "time" + ], + "x-enum-varnames": [ + "TypeText", + "TypeNumber", + "TypeBoolean", + "TypeTime" + ] + }, + "repo.BarcodeProduct": { + "type": "object", + "properties": { + "barcode": { + "type": "string" + }, + "imageBase64": { + "type": "string" + }, + "imageURL": { + "type": "string" + }, + "item": { + "$ref": "#/definitions/repo.ItemCreate" + }, + "manufacturer": { + "type": "string" + }, + "modelNumber": { + "description": "Identifications", + "type": "string" + }, + "notes": { + "description": "Extras", + "type": "string" + }, + "search_engine_name": { + "type": "string" + } + } + }, + "repo.DuplicateOptions": { + "type": "object", + "properties": { + "copyAttachments": { + "type": "boolean" + }, + "copyCustomFields": { + "type": "boolean" + }, + "copyMaintenance": { + "type": "boolean" + }, + "copyPrefix": { + "type": "string" + } + } + }, + "repo.Group": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "currency": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.GroupStatistics": { + "type": "object", + "properties": { + "totalItemPrice": { + "type": "number" + }, + "totalItems": { + "type": "integer" + }, + "totalLabels": { + "type": "integer" + }, + "totalLocations": { + "type": "integer" + }, + "totalUsers": { + "type": "integer" + }, + "totalWithWarranty": { + "type": "integer" + } + } + }, + "repo.GroupUpdate": { + "type": "object", + "properties": { + "currency": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "repo.ItemAttachment": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "id": { + "type": "string" + }, + "mimeType": { + "type": "string" + }, + "path": { + "type": "string" + }, + "primary": { + "type": "boolean" + }, + "thumbnail": { + "$ref": "#/definitions/ent.Attachment" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemAttachmentUpdate": { + "type": "object", + "properties": { + "primary": { + "type": "boolean" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.ItemCreate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "description": { + "type": "string", + "maxLength": 1000 + }, + "labelIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "locationId": { + "description": "Edges", + "type": "string" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "parentId": { + "type": "string", + "x-nullable": true + }, + "quantity": { + "type": "integer" + } + } + }, + "repo.ItemField": { + "type": "object", + "properties": { + "booleanValue": { + "type": "boolean" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "numberValue": { + "type": "integer" + }, + "textValue": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.ItemOut": { + "type": "object", + "properties": { + "archived": { + "type": "boolean" + }, + "assetId": { + "type": "string", + "example": "0" + }, + "attachments": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemAttachment" + } + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemField" + } + }, + "id": { + "type": "string" + }, + "imageId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "insured": { + "type": "boolean" + }, + "labels": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.LabelSummary" + } + }, + "lifetimeWarranty": { + "description": "Warranty", + "type": "boolean" + }, + "location": { + "description": "Edges", + "allOf": [ + { + "$ref": "#/definitions/repo.LocationSummary" + } + ], + "x-nullable": true, + "x-omitempty": true + }, + "manufacturer": { + "type": "string" + }, + "modelNumber": { + "type": "string" + }, + "name": { + "type": "string" + }, + "notes": { + "description": "Extras", + "type": "string" + }, + "parent": { + "allOf": [ + { + "$ref": "#/definitions/repo.ItemSummary" + } + ], + "x-nullable": true, + "x-omitempty": true + }, + "purchaseFrom": { + "type": "string" + }, + "purchasePrice": { + "type": "number" + }, + "purchaseTime": { + "description": "Purchase", + "type": "string" + }, + "quantity": { + "type": "integer" + }, + "serialNumber": { + "type": "string" + }, + "soldNotes": { + "type": "string" + }, + "soldPrice": { + "type": "number" + }, + "soldTime": { + "description": "Sold", + "type": "string" + }, + "soldTo": { + "type": "string" + }, + "syncChildItemsLocations": { + "type": "boolean" + }, + "thumbnailId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "updatedAt": { + "type": "string" + }, + "warrantyDetails": { + "type": "string" + }, + "warrantyExpires": { + "type": "string" + } + } + }, + "repo.ItemPatch": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "labelIds": { + "type": "array", + "items": { + "type": "string" + }, + "x-nullable": true, + "x-omitempty": true + }, + "locationId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "quantity": { + "type": "integer", + "x-nullable": true, + "x-omitempty": true + } + } + }, + "repo.ItemPath": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "type": { + "$ref": "#/definitions/repo.ItemType" + } + } + }, + "repo.ItemSummary": { + "type": "object", + "properties": { + "archived": { + "type": "boolean" + }, + "assetId": { + "type": "string", + "example": "0" + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "imageId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "insured": { + "type": "boolean" + }, + "labels": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.LabelSummary" + } + }, + "location": { + "description": "Edges", + "allOf": [ + { + "$ref": "#/definitions/repo.LocationSummary" + } + ], + "x-nullable": true, + "x-omitempty": true + }, + "name": { + "type": "string" + }, + "purchasePrice": { + "type": "number" + }, + "quantity": { + "type": "integer" + }, + "soldTime": { + "description": "Sale details", + "type": "string" + }, + "thumbnailId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemTemplateCreate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "defaultDescription": { + "type": "string", + "maxLength": 1000 + }, + "defaultInsured": { + "type": "boolean" + }, + "defaultLabelIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "defaultLifetimeWarranty": { + "type": "boolean" + }, + "defaultLocationId": { + "description": "Default location and labels", + "type": "string" + }, + "defaultManufacturer": { + "type": "string", + "maxLength": 255 + }, + "defaultModelNumber": { + "type": "string", + "maxLength": 255 + }, + "defaultName": { + "type": "string", + "maxLength": 255 + }, + "defaultQuantity": { + "description": "Default values for items", + "type": "integer" + }, + "defaultWarrantyDetails": { + "type": "string", + "maxLength": 1000 + }, + "description": { + "type": "string", + "maxLength": 1000 + }, + "fields": { + "description": "Custom fields", + "type": "array", + "items": { + "$ref": "#/definitions/repo.TemplateField" + } + }, + "includePurchaseFields": { + "type": "boolean" + }, + "includeSoldFields": { + "type": "boolean" + }, + "includeWarrantyFields": { + "description": "Metadata flags", + "type": "boolean" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "notes": { + "type": "string", + "maxLength": 1000 + } + } + }, + "repo.ItemTemplateOut": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "defaultDescription": { + "type": "string" + }, + "defaultInsured": { + "type": "boolean" + }, + "defaultLabels": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.TemplateLabelSummary" + } + }, + "defaultLifetimeWarranty": { + "type": "boolean" + }, + "defaultLocation": { + "description": "Default location and labels", + "allOf": [ + { + "$ref": "#/definitions/repo.TemplateLocationSummary" + } + ] + }, + "defaultManufacturer": { + "type": "string" + }, + "defaultModelNumber": { + "type": "string" + }, + "defaultName": { + "type": "string" + }, + "defaultQuantity": { + "description": "Default values for items", + "type": "integer" + }, + "defaultWarrantyDetails": { + "type": "string" + }, + "description": { + "type": "string" + }, + "fields": { + "description": "Custom fields", + "type": "array", + "items": { + "$ref": "#/definitions/repo.TemplateField" + } + }, + "id": { + "type": "string" + }, + "includePurchaseFields": { + "type": "boolean" + }, + "includeSoldFields": { + "type": "boolean" + }, + "includeWarrantyFields": { + "description": "Metadata flags", + "type": "boolean" + }, + "name": { + "type": "string" + }, + "notes": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemTemplateSummary": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemTemplateUpdate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "defaultDescription": { + "type": "string", + "maxLength": 1000 + }, + "defaultInsured": { + "type": "boolean" + }, + "defaultLabelIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "defaultLifetimeWarranty": { + "type": "boolean" + }, + "defaultLocationId": { + "description": "Default location and labels", + "type": "string" + }, + "defaultManufacturer": { + "type": "string", + "maxLength": 255 + }, + "defaultModelNumber": { + "type": "string", + "maxLength": 255 + }, + "defaultName": { + "type": "string", + "maxLength": 255 + }, + "defaultQuantity": { + "description": "Default values for items", + "type": "integer" + }, + "defaultWarrantyDetails": { + "type": "string", + "maxLength": 1000 + }, + "description": { + "type": "string", + "maxLength": 1000 + }, + "fields": { + "description": "Custom fields", + "type": "array", + "items": { + "$ref": "#/definitions/repo.TemplateField" + } + }, + "id": { + "type": "string" + }, + "includePurchaseFields": { + "type": "boolean" + }, + "includeSoldFields": { + "type": "boolean" + }, + "includeWarrantyFields": { + "description": "Metadata flags", + "type": "boolean" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "notes": { + "type": "string", + "maxLength": 1000 + } + } + }, + "repo.ItemType": { + "type": "string", + "enum": [ + "location", + "item" + ], + "x-enum-varnames": [ + "ItemTypeLocation", + "ItemTypeItem" + ] + }, + "repo.ItemUpdate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "archived": { + "type": "boolean" + }, + "assetId": { + "type": "string" + }, + "description": { + "type": "string", + "maxLength": 1000 + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemField" + } + }, + "id": { + "type": "string" + }, + "insured": { + "type": "boolean" + }, + "labelIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "lifetimeWarranty": { + "description": "Warranty", + "type": "boolean" + }, + "locationId": { + "description": "Edges", + "type": "string" + }, + "manufacturer": { + "type": "string" + }, + "modelNumber": { + "type": "string" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "notes": { + "description": "Extras", + "type": "string" + }, + "parentId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "purchaseFrom": { + "type": "string", + "maxLength": 255 + }, + "purchasePrice": { + "type": "number", + "x-nullable": true, + "x-omitempty": true + }, + "purchaseTime": { + "description": "Purchase", + "type": "string" + }, + "quantity": { + "type": "integer" + }, + "serialNumber": { + "description": "Identifications", + "type": "string" + }, + "soldNotes": { + "type": "string" + }, + "soldPrice": { + "type": "number", + "x-nullable": true, + "x-omitempty": true + }, + "soldTime": { + "description": "Sold", + "type": "string" + }, + "soldTo": { + "type": "string", + "maxLength": 255 + }, + "syncChildItemsLocations": { + "type": "boolean" + }, + "warrantyDetails": { + "type": "string" + }, + "warrantyExpires": { + "type": "string" + } + } + }, + "repo.LabelCreate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "color": { + "type": "string" + }, + "description": { + "type": "string", + "maxLength": 1000 + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + } + } + }, + "repo.LabelOut": { + "type": "object", + "properties": { + "color": { + "type": "string" + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.LabelSummary": { + "type": "object", + "properties": { + "color": { + "type": "string" + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.LocationCreate": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "parentId": { + "type": "string", + "x-nullable": true + } + } + }, + "repo.LocationOut": { + "type": "object", + "properties": { + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.LocationSummary" + } + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "parent": { + "$ref": "#/definitions/repo.LocationSummary" + }, + "totalPrice": { + "type": "number" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.LocationOutCount": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "itemCount": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.LocationSummary": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.LocationUpdate": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "parentId": { + "type": "string", + "x-nullable": true + } + } + }, + "repo.MaintenanceEntry": { + "type": "object", + "properties": { + "completedDate": { + "type": "string" + }, + "cost": { + "type": "string", + "example": "0" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "scheduledDate": { + "type": "string" + } + } + }, + "repo.MaintenanceEntryCreate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "completedDate": { + "type": "string" + }, + "cost": { + "type": "string", + "example": "0" + }, + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "scheduledDate": { + "type": "string" + } + } + }, + "repo.MaintenanceEntryUpdate": { + "type": "object", + "properties": { + "completedDate": { + "type": "string" + }, + "cost": { + "type": "string", + "example": "0" + }, + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "scheduledDate": { + "type": "string" + } + } + }, + "repo.MaintenanceEntryWithDetails": { + "type": "object", + "properties": { + "completedDate": { + "type": "string" + }, + "cost": { + "type": "string", + "example": "0" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "itemID": { + "type": "string" + }, + "itemName": { + "type": "string" + }, + "name": { + "type": "string" + }, + "scheduledDate": { + "type": "string" + } + } + }, + "repo.MaintenanceFilterStatus": { + "type": "string", + "enum": [ + "scheduled", + "completed", + "both" + ], + "x-enum-varnames": [ + "MaintenanceFilterStatusScheduled", + "MaintenanceFilterStatusCompleted", + "MaintenanceFilterStatusBoth" + ] + }, + "repo.NotifierCreate": { + "type": "object", + "required": [ + "name", + "url" + ], + "properties": { + "isActive": { + "type": "boolean" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "url": { + "type": "string" + } + } + }, + "repo.NotifierOut": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "groupId": { + "type": "string" + }, + "id": { + "type": "string" + }, + "isActive": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + }, + "url": { + "type": "string" + }, + "userId": { + "type": "string" + } + } + }, + "repo.NotifierUpdate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "isActive": { + "type": "boolean" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "url": { + "type": "string", + "x-nullable": true + } + } + }, + "repo.PaginationResult-repo_ItemSummary": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemSummary" + } + }, + "page": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + }, + "total": { + "type": "integer" + } + } + }, + "repo.TemplateField": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "textValue": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.TemplateLabelSummary": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "repo.TemplateLocationSummary": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "repo.TotalsByOrganizer": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "total": { + "type": "number" + } + } + }, + "repo.TreeItem": { + "type": "object", + "properties": { + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.TreeItem" + } + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.UserOut": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "groupId": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "id": { + "type": "string" + }, + "isOwner": { + "type": "boolean" + }, + "isSuperuser": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "oidcIssuer": { + "type": "string" + }, + "oidcSubject": { + "type": "string" + } + } + }, + "repo.UserUpdate": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "repo.ValueOverTime": { + "type": "object", + "properties": { + "end": { + "type": "string" + }, + "entries": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ValueOverTimeEntry" + } + }, + "start": { + "type": "string" + }, + "valueAtEnd": { + "type": "number" + }, + "valueAtStart": { + "type": "number" + } + } + }, + "repo.ValueOverTimeEntry": { + "type": "object", + "properties": { + "date": { + "type": "string" + }, + "name": { + "type": "string" + }, + "value": { + "type": "number" + } + } + }, + "services.Latest": { + "type": "object", + "properties": { + "date": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, + "services.UserRegistration": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "name": { + "type": "string" + }, + "password": { + "type": "string" + }, + "token": { + "type": "string" + } + } + }, + "templatefield.Type": { + "type": "string", + "enum": [ + "text" + ], + "x-enum-varnames": [ + "TypeText" + ] + }, + "user.Role": { + "type": "string", + "enum": [ + "user", + "user", + "owner" + ], + "x-enum-varnames": [ + "DefaultRole", + "RoleUser", + "RoleOwner" + ] + }, + "v1.APISummary": { + "type": "object", + "properties": { + "allowRegistration": { + "type": "boolean" + }, + "build": { + "$ref": "#/definitions/v1.Build" + }, + "demo": { + "type": "boolean" + }, + "health": { + "type": "boolean" + }, + "labelPrinting": { + "type": "boolean" + }, + "latest": { + "$ref": "#/definitions/services.Latest" + }, + "message": { + "type": "string" + }, + "oidc": { + "$ref": "#/definitions/v1.OIDCStatus" + }, + "title": { + "type": "string" + }, + "versions": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "v1.ActionAmountResult": { + "type": "object", + "properties": { + "completed": { + "type": "integer" + } + } + }, + "v1.Build": { + "type": "object", + "properties": { + "buildTime": { + "type": "string" + }, + "commit": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, + "v1.ChangePassword": { + "type": "object", + "properties": { + "current": { + "type": "string" + }, + "new": { + "type": "string" + } + } + }, + "v1.GroupInvitation": { + "type": "object", + "properties": { + "expiresAt": { + "type": "string" + }, + "token": { + "type": "string" + }, + "uses": { + "type": "integer" + } + } + }, + "v1.GroupInvitationCreate": { + "type": "object", + "required": [ + "uses" + ], + "properties": { + "expiresAt": { + "type": "string" + }, + "uses": { + "type": "integer", + "maximum": 100, + "minimum": 1 + } + } + }, + "v1.ItemAttachmentToken": { + "type": "object", + "properties": { + "token": { + "type": "string" + } + } + }, + "v1.ItemTemplateCreateItemRequest": { + "type": "object", + "required": [ + "locationId", + "name" + ], + "properties": { + "description": { + "type": "string", + "maxLength": 1000 + }, + "labelIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "locationId": { + "type": "string" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "quantity": { + "type": "integer" + } + } + }, + "v1.LoginForm": { + "type": "object", + "properties": { + "password": { + "type": "string", + "example": "admin" + }, + "stayLoggedIn": { + "type": "boolean" + }, + "username": { + "type": "string", + "example": "admin@admin.com" + } + } + }, + "v1.OIDCStatus": { + "type": "object", + "properties": { + "allowLocal": { + "type": "boolean" + }, + "autoRedirect": { + "type": "boolean" + }, + "buttonText": { + "type": "string" + }, + "enabled": { + "type": "boolean" + } + } + }, + "v1.TokenResponse": { + "type": "object", + "properties": { + "attachmentToken": { + "type": "string" + }, + "expiresAt": { + "type": "string" + }, + "token": { + "type": "string" + } + } + }, + "v1.Wrapped": { + "type": "object", + "properties": { + "item": {} + } + }, + "validate.ErrorResponse": { + "type": "object", + "properties": { + "error": { + "type": "string" + }, + "fields": { + "type": "string" + } + } + } + }, + "securityDefinitions": { + "Bearer": { + "description": "\"Type 'Bearer TOKEN' to correctly set the API Key\"", + "type": "apiKey", + "name": "Authorization", + "in": "header" + } + } +} \ No newline at end of file diff --git a/docs/en/api/openapi-2.0.yaml b/docs/en/api/openapi-2.0.yaml new file mode 100644 index 00000000..8926c617 --- /dev/null +++ b/docs/en/api/openapi-2.0.yaml @@ -0,0 +1,3369 @@ +basePath: /api +definitions: + attachment.Type: + enum: + - attachment + - photo + - manual + - warranty + - attachment + - receipt + - thumbnail + type: string + x-enum-varnames: + - DefaultType + - TypePhoto + - TypeManual + - TypeWarranty + - TypeAttachment + - TypeReceipt + - TypeThumbnail + authroles.Role: + enum: + - user + - admin + - user + - attachments + type: string + x-enum-varnames: + - DefaultRole + - RoleAdmin + - RoleUser + - RoleAttachments + currencies.Currency: + properties: + code: + type: string + decimals: + type: integer + local: + type: string + name: + type: string + symbol: + type: string + type: object + ent.Attachment: + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + edges: + allOf: + - $ref: '#/definitions/ent.AttachmentEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the AttachmentQuery when eager-loading is set. + id: + description: ID of the ent. + type: string + mime_type: + description: MimeType holds the value of the "mime_type" field. + type: string + path: + description: Path holds the value of the "path" field. + type: string + primary: + description: Primary holds the value of the "primary" field. + type: boolean + title: + description: Title holds the value of the "title" field. + type: string + type: + allOf: + - $ref: '#/definitions/attachment.Type' + description: Type holds the value of the "type" field. + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + type: object + ent.AttachmentEdges: + properties: + item: + allOf: + - $ref: '#/definitions/ent.Item' + description: Item holds the value of the item edge. + thumbnail: + allOf: + - $ref: '#/definitions/ent.Attachment' + description: Thumbnail holds the value of the thumbnail edge. + type: object + ent.AuthRoles: + properties: + edges: + allOf: + - $ref: '#/definitions/ent.AuthRolesEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the AuthRolesQuery when eager-loading is set. + id: + description: ID of the ent. + type: integer + role: + allOf: + - $ref: '#/definitions/authroles.Role' + description: Role holds the value of the "role" field. + type: object + ent.AuthRolesEdges: + properties: + token: + allOf: + - $ref: '#/definitions/ent.AuthTokens' + description: Token holds the value of the token edge. + type: object + ent.AuthTokens: + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + edges: + allOf: + - $ref: '#/definitions/ent.AuthTokensEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the AuthTokensQuery when eager-loading is set. + expires_at: + description: ExpiresAt holds the value of the "expires_at" field. + type: string + id: + description: ID of the ent. + type: string + token: + description: Token holds the value of the "token" field. + items: + type: integer + type: array + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + type: object + ent.AuthTokensEdges: + properties: + roles: + allOf: + - $ref: '#/definitions/ent.AuthRoles' + description: Roles holds the value of the roles edge. + user: + allOf: + - $ref: '#/definitions/ent.User' + description: User holds the value of the user edge. + type: object + ent.Group: + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + currency: + description: Currency holds the value of the "currency" field. + type: string + edges: + allOf: + - $ref: '#/definitions/ent.GroupEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the GroupQuery when eager-loading is set. + id: + description: ID of the ent. + type: string + name: + description: Name holds the value of the "name" field. + type: string + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + type: object + ent.GroupEdges: + properties: + invitation_tokens: + description: InvitationTokens holds the value of the invitation_tokens edge. + items: + $ref: '#/definitions/ent.GroupInvitationToken' + type: array + item_templates: + description: ItemTemplates holds the value of the item_templates edge. + items: + $ref: '#/definitions/ent.ItemTemplate' + type: array + items: + description: Items holds the value of the items edge. + items: + $ref: '#/definitions/ent.Item' + type: array + labels: + description: Labels holds the value of the labels edge. + items: + $ref: '#/definitions/ent.Label' + type: array + locations: + description: Locations holds the value of the locations edge. + items: + $ref: '#/definitions/ent.Location' + type: array + notifiers: + description: Notifiers holds the value of the notifiers edge. + items: + $ref: '#/definitions/ent.Notifier' + type: array + users: + description: Users holds the value of the users edge. + items: + $ref: '#/definitions/ent.User' + type: array + type: object + ent.GroupInvitationToken: + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + edges: + allOf: + - $ref: '#/definitions/ent.GroupInvitationTokenEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the GroupInvitationTokenQuery when eager-loading is set. + expires_at: + description: ExpiresAt holds the value of the "expires_at" field. + type: string + id: + description: ID of the ent. + type: string + token: + description: Token holds the value of the "token" field. + items: + type: integer + type: array + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + uses: + description: Uses holds the value of the "uses" field. + type: integer + type: object + ent.GroupInvitationTokenEdges: + properties: + group: + allOf: + - $ref: '#/definitions/ent.Group' + description: Group holds the value of the group edge. + type: object + ent.Item: + properties: + archived: + description: Archived holds the value of the "archived" field. + type: boolean + asset_id: + description: AssetID holds the value of the "asset_id" field. + type: integer + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + description: + description: Description holds the value of the "description" field. + type: string + edges: + allOf: + - $ref: '#/definitions/ent.ItemEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the ItemQuery when eager-loading is set. + id: + description: ID of the ent. + type: string + import_ref: + description: ImportRef holds the value of the "import_ref" field. + type: string + insured: + description: Insured holds the value of the "insured" field. + type: boolean + lifetime_warranty: + description: LifetimeWarranty holds the value of the "lifetime_warranty" field. + type: boolean + manufacturer: + description: Manufacturer holds the value of the "manufacturer" field. + type: string + model_number: + description: ModelNumber holds the value of the "model_number" field. + type: string + name: + description: Name holds the value of the "name" field. + type: string + notes: + description: Notes holds the value of the "notes" field. + type: string + purchase_from: + description: PurchaseFrom holds the value of the "purchase_from" field. + type: string + purchase_price: + description: PurchasePrice holds the value of the "purchase_price" field. + type: number + purchase_time: + description: PurchaseTime holds the value of the "purchase_time" field. + type: string + quantity: + description: Quantity holds the value of the "quantity" field. + type: integer + serial_number: + description: SerialNumber holds the value of the "serial_number" field. + type: string + sold_notes: + description: SoldNotes holds the value of the "sold_notes" field. + type: string + sold_price: + description: SoldPrice holds the value of the "sold_price" field. + type: number + sold_time: + description: SoldTime holds the value of the "sold_time" field. + type: string + sold_to: + description: SoldTo holds the value of the "sold_to" field. + type: string + sync_child_items_locations: + description: SyncChildItemsLocations holds the value of the "sync_child_items_locations" + field. + type: boolean + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + warranty_details: + description: WarrantyDetails holds the value of the "warranty_details" field. + type: string + warranty_expires: + description: WarrantyExpires holds the value of the "warranty_expires" field. + type: string + type: object + ent.ItemEdges: + properties: + attachments: + description: Attachments holds the value of the attachments edge. + items: + $ref: '#/definitions/ent.Attachment' + type: array + children: + description: Children holds the value of the children edge. + items: + $ref: '#/definitions/ent.Item' + type: array + fields: + description: Fields holds the value of the fields edge. + items: + $ref: '#/definitions/ent.ItemField' + type: array + group: + allOf: + - $ref: '#/definitions/ent.Group' + description: Group holds the value of the group edge. + label: + description: Label holds the value of the label edge. + items: + $ref: '#/definitions/ent.Label' + type: array + location: + allOf: + - $ref: '#/definitions/ent.Location' + description: Location holds the value of the location edge. + maintenance_entries: + description: MaintenanceEntries holds the value of the maintenance_entries + edge. + items: + $ref: '#/definitions/ent.MaintenanceEntry' + type: array + parent: + allOf: + - $ref: '#/definitions/ent.Item' + description: Parent holds the value of the parent edge. + type: object + ent.ItemField: + properties: + boolean_value: + description: BooleanValue holds the value of the "boolean_value" field. + type: boolean + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + description: + description: Description holds the value of the "description" field. + type: string + edges: + allOf: + - $ref: '#/definitions/ent.ItemFieldEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the ItemFieldQuery when eager-loading is set. + id: + description: ID of the ent. + type: string + name: + description: Name holds the value of the "name" field. + type: string + number_value: + description: NumberValue holds the value of the "number_value" field. + type: integer + text_value: + description: TextValue holds the value of the "text_value" field. + type: string + time_value: + description: TimeValue holds the value of the "time_value" field. + type: string + type: + allOf: + - $ref: '#/definitions/itemfield.Type' + description: Type holds the value of the "type" field. + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + type: object + ent.ItemFieldEdges: + properties: + item: + allOf: + - $ref: '#/definitions/ent.Item' + description: Item holds the value of the item edge. + type: object + ent.ItemTemplate: + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + default_description: + description: Default description for items created from this template + type: string + default_insured: + description: DefaultInsured holds the value of the "default_insured" field. + type: boolean + default_label_ids: + description: Default label IDs for items created from this template + items: + type: string + type: array + default_lifetime_warranty: + description: DefaultLifetimeWarranty holds the value of the "default_lifetime_warranty" + field. + type: boolean + default_manufacturer: + description: DefaultManufacturer holds the value of the "default_manufacturer" + field. + type: string + default_model_number: + description: Default model number for items created from this template + type: string + default_name: + description: Default name template for items (can use placeholders) + type: string + default_quantity: + description: DefaultQuantity holds the value of the "default_quantity" field. + type: integer + default_warranty_details: + description: DefaultWarrantyDetails holds the value of the "default_warranty_details" + field. + type: string + description: + description: Description holds the value of the "description" field. + type: string + edges: + allOf: + - $ref: '#/definitions/ent.ItemTemplateEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the ItemTemplateQuery when eager-loading is set. + id: + description: ID of the ent. + type: string + include_purchase_fields: + description: Whether to include purchase fields in items created from this + template + type: boolean + include_sold_fields: + description: Whether to include sold fields in items created from this template + type: boolean + include_warranty_fields: + description: Whether to include warranty fields in items created from this + template + type: boolean + name: + description: Name holds the value of the "name" field. + type: string + notes: + description: Notes holds the value of the "notes" field. + type: string + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + type: object + ent.ItemTemplateEdges: + properties: + fields: + description: Fields holds the value of the fields edge. + items: + $ref: '#/definitions/ent.TemplateField' + type: array + group: + allOf: + - $ref: '#/definitions/ent.Group' + description: Group holds the value of the group edge. + location: + allOf: + - $ref: '#/definitions/ent.Location' + description: Location holds the value of the location edge. + type: object + ent.Label: + properties: + color: + description: Color holds the value of the "color" field. + type: string + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + description: + description: Description holds the value of the "description" field. + type: string + edges: + allOf: + - $ref: '#/definitions/ent.LabelEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the LabelQuery when eager-loading is set. + id: + description: ID of the ent. + type: string + name: + description: Name holds the value of the "name" field. + type: string + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + type: object + ent.LabelEdges: + properties: + group: + allOf: + - $ref: '#/definitions/ent.Group' + description: Group holds the value of the group edge. + items: + description: Items holds the value of the items edge. + items: + $ref: '#/definitions/ent.Item' + type: array + type: object + ent.Location: + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + description: + description: Description holds the value of the "description" field. + type: string + edges: + allOf: + - $ref: '#/definitions/ent.LocationEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the LocationQuery when eager-loading is set. + id: + description: ID of the ent. + type: string + name: + description: Name holds the value of the "name" field. + type: string + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + type: object + ent.LocationEdges: + properties: + children: + description: Children holds the value of the children edge. + items: + $ref: '#/definitions/ent.Location' + type: array + group: + allOf: + - $ref: '#/definitions/ent.Group' + description: Group holds the value of the group edge. + items: + description: Items holds the value of the items edge. + items: + $ref: '#/definitions/ent.Item' + type: array + parent: + allOf: + - $ref: '#/definitions/ent.Location' + description: Parent holds the value of the parent edge. + type: object + ent.MaintenanceEntry: + properties: + cost: + description: Cost holds the value of the "cost" field. + type: number + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + date: + description: Date holds the value of the "date" field. + type: string + description: + description: Description holds the value of the "description" field. + type: string + edges: + allOf: + - $ref: '#/definitions/ent.MaintenanceEntryEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the MaintenanceEntryQuery when eager-loading is set. + id: + description: ID of the ent. + type: string + item_id: + description: ItemID holds the value of the "item_id" field. + type: string + name: + description: Name holds the value of the "name" field. + type: string + scheduled_date: + description: ScheduledDate holds the value of the "scheduled_date" field. + type: string + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + type: object + ent.MaintenanceEntryEdges: + properties: + item: + allOf: + - $ref: '#/definitions/ent.Item' + description: Item holds the value of the item edge. + type: object + ent.Notifier: + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + edges: + allOf: + - $ref: '#/definitions/ent.NotifierEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the NotifierQuery when eager-loading is set. + group_id: + description: GroupID holds the value of the "group_id" field. + type: string + id: + description: ID of the ent. + type: string + is_active: + description: IsActive holds the value of the "is_active" field. + type: boolean + name: + description: Name holds the value of the "name" field. + type: string + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + user_id: + description: UserID holds the value of the "user_id" field. + type: string + type: object + ent.NotifierEdges: + properties: + group: + allOf: + - $ref: '#/definitions/ent.Group' + description: Group holds the value of the group edge. + user: + allOf: + - $ref: '#/definitions/ent.User' + description: User holds the value of the user edge. + type: object + ent.TemplateField: + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + description: + description: Description holds the value of the "description" field. + type: string + edges: + allOf: + - $ref: '#/definitions/ent.TemplateFieldEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the TemplateFieldQuery when eager-loading is set. + id: + description: ID of the ent. + type: string + name: + description: Name holds the value of the "name" field. + type: string + text_value: + description: TextValue holds the value of the "text_value" field. + type: string + type: + allOf: + - $ref: '#/definitions/templatefield.Type' + description: Type holds the value of the "type" field. + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + type: object + ent.TemplateFieldEdges: + properties: + item_template: + allOf: + - $ref: '#/definitions/ent.ItemTemplate' + description: ItemTemplate holds the value of the item_template edge. + type: object + ent.User: + properties: + activated_on: + description: ActivatedOn holds the value of the "activated_on" field. + type: string + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + edges: + allOf: + - $ref: '#/definitions/ent.UserEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the UserQuery when eager-loading is set. + email: + description: Email holds the value of the "email" field. + type: string + id: + description: ID of the ent. + type: string + is_superuser: + description: IsSuperuser holds the value of the "is_superuser" field. + type: boolean + name: + description: Name holds the value of the "name" field. + type: string + oidc_issuer: + description: OidcIssuer holds the value of the "oidc_issuer" field. + type: string + oidc_subject: + description: OidcSubject holds the value of the "oidc_subject" field. + type: string + role: + allOf: + - $ref: '#/definitions/user.Role' + description: Role holds the value of the "role" field. + superuser: + description: Superuser holds the value of the "superuser" field. + type: boolean + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + type: object + ent.UserEdges: + properties: + auth_tokens: + description: AuthTokens holds the value of the auth_tokens edge. + items: + $ref: '#/definitions/ent.AuthTokens' + type: array + group: + allOf: + - $ref: '#/definitions/ent.Group' + description: Group holds the value of the group edge. + notifiers: + description: Notifiers holds the value of the notifiers edge. + items: + $ref: '#/definitions/ent.Notifier' + type: array + type: object + itemfield.Type: + enum: + - text + - number + - boolean + - time + type: string + x-enum-varnames: + - TypeText + - TypeNumber + - TypeBoolean + - TypeTime + repo.BarcodeProduct: + properties: + barcode: + type: string + imageBase64: + type: string + imageURL: + type: string + item: + $ref: '#/definitions/repo.ItemCreate' + manufacturer: + type: string + modelNumber: + description: Identifications + type: string + notes: + description: Extras + type: string + search_engine_name: + type: string + type: object + repo.DuplicateOptions: + properties: + copyAttachments: + type: boolean + copyCustomFields: + type: boolean + copyMaintenance: + type: boolean + copyPrefix: + type: string + type: object + repo.Group: + properties: + createdAt: + type: string + currency: + type: string + id: + type: string + name: + type: string + updatedAt: + type: string + type: object + repo.GroupStatistics: + properties: + totalItemPrice: + type: number + totalItems: + type: integer + totalLabels: + type: integer + totalLocations: + type: integer + totalUsers: + type: integer + totalWithWarranty: + type: integer + type: object + repo.GroupUpdate: + properties: + currency: + type: string + name: + type: string + type: object + repo.ItemAttachment: + properties: + createdAt: + type: string + id: + type: string + mimeType: + type: string + path: + type: string + primary: + type: boolean + thumbnail: + $ref: '#/definitions/ent.Attachment' + title: + type: string + type: + type: string + updatedAt: + type: string + type: object + repo.ItemAttachmentUpdate: + properties: + primary: + type: boolean + title: + type: string + type: + type: string + type: object + repo.ItemCreate: + properties: + description: + maxLength: 1000 + type: string + labelIds: + items: + type: string + type: array + locationId: + description: Edges + type: string + name: + maxLength: 255 + minLength: 1 + type: string + parentId: + type: string + x-nullable: true + quantity: + type: integer + required: + - name + type: object + repo.ItemField: + properties: + booleanValue: + type: boolean + id: + type: string + name: + type: string + numberValue: + type: integer + textValue: + type: string + type: + type: string + type: object + repo.ItemOut: + properties: + archived: + type: boolean + assetId: + example: "0" + type: string + attachments: + items: + $ref: '#/definitions/repo.ItemAttachment' + type: array + createdAt: + type: string + description: + type: string + fields: + items: + $ref: '#/definitions/repo.ItemField' + type: array + id: + type: string + imageId: + type: string + x-nullable: true + x-omitempty: true + insured: + type: boolean + labels: + items: + $ref: '#/definitions/repo.LabelSummary' + type: array + lifetimeWarranty: + description: Warranty + type: boolean + location: + allOf: + - $ref: '#/definitions/repo.LocationSummary' + description: Edges + x-nullable: true + x-omitempty: true + manufacturer: + type: string + modelNumber: + type: string + name: + type: string + notes: + description: Extras + type: string + parent: + allOf: + - $ref: '#/definitions/repo.ItemSummary' + x-nullable: true + x-omitempty: true + purchaseFrom: + type: string + purchasePrice: + type: number + purchaseTime: + description: Purchase + type: string + quantity: + type: integer + serialNumber: + type: string + soldNotes: + type: string + soldPrice: + type: number + soldTime: + description: Sold + type: string + soldTo: + type: string + syncChildItemsLocations: + type: boolean + thumbnailId: + type: string + x-nullable: true + x-omitempty: true + updatedAt: + type: string + warrantyDetails: + type: string + warrantyExpires: + type: string + type: object + repo.ItemPatch: + properties: + id: + type: string + labelIds: + items: + type: string + type: array + x-nullable: true + x-omitempty: true + locationId: + type: string + x-nullable: true + x-omitempty: true + quantity: + type: integer + x-nullable: true + x-omitempty: true + type: object + repo.ItemPath: + properties: + id: + type: string + name: + type: string + type: + $ref: '#/definitions/repo.ItemType' + type: object + repo.ItemSummary: + properties: + archived: + type: boolean + assetId: + example: "0" + type: string + createdAt: + type: string + description: + type: string + id: + type: string + imageId: + type: string + x-nullable: true + x-omitempty: true + insured: + type: boolean + labels: + items: + $ref: '#/definitions/repo.LabelSummary' + type: array + location: + allOf: + - $ref: '#/definitions/repo.LocationSummary' + description: Edges + x-nullable: true + x-omitempty: true + name: + type: string + purchasePrice: + type: number + quantity: + type: integer + soldTime: + description: Sale details + type: string + thumbnailId: + type: string + x-nullable: true + x-omitempty: true + updatedAt: + type: string + type: object + repo.ItemTemplateCreate: + properties: + defaultDescription: + maxLength: 1000 + type: string + defaultInsured: + type: boolean + defaultLabelIds: + items: + type: string + type: array + defaultLifetimeWarranty: + type: boolean + defaultLocationId: + description: Default location and labels + type: string + defaultManufacturer: + maxLength: 255 + type: string + defaultModelNumber: + maxLength: 255 + type: string + defaultName: + maxLength: 255 + type: string + defaultQuantity: + description: Default values for items + type: integer + defaultWarrantyDetails: + maxLength: 1000 + type: string + description: + maxLength: 1000 + type: string + fields: + description: Custom fields + items: + $ref: '#/definitions/repo.TemplateField' + type: array + includePurchaseFields: + type: boolean + includeSoldFields: + type: boolean + includeWarrantyFields: + description: Metadata flags + type: boolean + name: + maxLength: 255 + minLength: 1 + type: string + notes: + maxLength: 1000 + type: string + required: + - name + type: object + repo.ItemTemplateOut: + properties: + createdAt: + type: string + defaultDescription: + type: string + defaultInsured: + type: boolean + defaultLabels: + items: + $ref: '#/definitions/repo.TemplateLabelSummary' + type: array + defaultLifetimeWarranty: + type: boolean + defaultLocation: + allOf: + - $ref: '#/definitions/repo.TemplateLocationSummary' + description: Default location and labels + defaultManufacturer: + type: string + defaultModelNumber: + type: string + defaultName: + type: string + defaultQuantity: + description: Default values for items + type: integer + defaultWarrantyDetails: + type: string + description: + type: string + fields: + description: Custom fields + items: + $ref: '#/definitions/repo.TemplateField' + type: array + id: + type: string + includePurchaseFields: + type: boolean + includeSoldFields: + type: boolean + includeWarrantyFields: + description: Metadata flags + type: boolean + name: + type: string + notes: + type: string + updatedAt: + type: string + type: object + repo.ItemTemplateSummary: + properties: + createdAt: + type: string + description: + type: string + id: + type: string + name: + type: string + updatedAt: + type: string + type: object + repo.ItemTemplateUpdate: + properties: + defaultDescription: + maxLength: 1000 + type: string + defaultInsured: + type: boolean + defaultLabelIds: + items: + type: string + type: array + defaultLifetimeWarranty: + type: boolean + defaultLocationId: + description: Default location and labels + type: string + defaultManufacturer: + maxLength: 255 + type: string + defaultModelNumber: + maxLength: 255 + type: string + defaultName: + maxLength: 255 + type: string + defaultQuantity: + description: Default values for items + type: integer + defaultWarrantyDetails: + maxLength: 1000 + type: string + description: + maxLength: 1000 + type: string + fields: + description: Custom fields + items: + $ref: '#/definitions/repo.TemplateField' + type: array + id: + type: string + includePurchaseFields: + type: boolean + includeSoldFields: + type: boolean + includeWarrantyFields: + description: Metadata flags + type: boolean + name: + maxLength: 255 + minLength: 1 + type: string + notes: + maxLength: 1000 + type: string + required: + - name + type: object + repo.ItemType: + enum: + - location + - item + type: string + x-enum-varnames: + - ItemTypeLocation + - ItemTypeItem + repo.ItemUpdate: + properties: + archived: + type: boolean + assetId: + type: string + description: + maxLength: 1000 + type: string + fields: + items: + $ref: '#/definitions/repo.ItemField' + type: array + id: + type: string + insured: + type: boolean + labelIds: + items: + type: string + type: array + lifetimeWarranty: + description: Warranty + type: boolean + locationId: + description: Edges + type: string + manufacturer: + type: string + modelNumber: + type: string + name: + maxLength: 255 + minLength: 1 + type: string + notes: + description: Extras + type: string + parentId: + type: string + x-nullable: true + x-omitempty: true + purchaseFrom: + maxLength: 255 + type: string + purchasePrice: + type: number + x-nullable: true + x-omitempty: true + purchaseTime: + description: Purchase + type: string + quantity: + type: integer + serialNumber: + description: Identifications + type: string + soldNotes: + type: string + soldPrice: + type: number + x-nullable: true + x-omitempty: true + soldTime: + description: Sold + type: string + soldTo: + maxLength: 255 + type: string + syncChildItemsLocations: + type: boolean + warrantyDetails: + type: string + warrantyExpires: + type: string + required: + - name + type: object + repo.LabelCreate: + properties: + color: + type: string + description: + maxLength: 1000 + type: string + name: + maxLength: 255 + minLength: 1 + type: string + required: + - name + type: object + repo.LabelOut: + properties: + color: + type: string + createdAt: + type: string + description: + type: string + id: + type: string + name: + type: string + updatedAt: + type: string + type: object + repo.LabelSummary: + properties: + color: + type: string + createdAt: + type: string + description: + type: string + id: + type: string + name: + type: string + updatedAt: + type: string + type: object + repo.LocationCreate: + properties: + description: + type: string + name: + type: string + parentId: + type: string + x-nullable: true + type: object + repo.LocationOut: + properties: + children: + items: + $ref: '#/definitions/repo.LocationSummary' + type: array + createdAt: + type: string + description: + type: string + id: + type: string + name: + type: string + parent: + $ref: '#/definitions/repo.LocationSummary' + totalPrice: + type: number + updatedAt: + type: string + type: object + repo.LocationOutCount: + properties: + createdAt: + type: string + description: + type: string + id: + type: string + itemCount: + type: integer + name: + type: string + updatedAt: + type: string + type: object + repo.LocationSummary: + properties: + createdAt: + type: string + description: + type: string + id: + type: string + name: + type: string + updatedAt: + type: string + type: object + repo.LocationUpdate: + properties: + description: + type: string + id: + type: string + name: + type: string + parentId: + type: string + x-nullable: true + type: object + repo.MaintenanceEntry: + properties: + completedDate: + type: string + cost: + example: "0" + type: string + description: + type: string + id: + type: string + name: + type: string + scheduledDate: + type: string + type: object + repo.MaintenanceEntryCreate: + properties: + completedDate: + type: string + cost: + example: "0" + type: string + description: + type: string + name: + type: string + scheduledDate: + type: string + required: + - name + type: object + repo.MaintenanceEntryUpdate: + properties: + completedDate: + type: string + cost: + example: "0" + type: string + description: + type: string + name: + type: string + scheduledDate: + type: string + type: object + repo.MaintenanceEntryWithDetails: + properties: + completedDate: + type: string + cost: + example: "0" + type: string + description: + type: string + id: + type: string + itemID: + type: string + itemName: + type: string + name: + type: string + scheduledDate: + type: string + type: object + repo.MaintenanceFilterStatus: + enum: + - scheduled + - completed + - both + type: string + x-enum-varnames: + - MaintenanceFilterStatusScheduled + - MaintenanceFilterStatusCompleted + - MaintenanceFilterStatusBoth + repo.NotifierCreate: + properties: + isActive: + type: boolean + name: + maxLength: 255 + minLength: 1 + type: string + url: + type: string + required: + - name + - url + type: object + repo.NotifierOut: + properties: + createdAt: + type: string + groupId: + type: string + id: + type: string + isActive: + type: boolean + name: + type: string + updatedAt: + type: string + url: + type: string + userId: + type: string + type: object + repo.NotifierUpdate: + properties: + isActive: + type: boolean + name: + maxLength: 255 + minLength: 1 + type: string + url: + type: string + x-nullable: true + required: + - name + type: object + repo.PaginationResult-repo_ItemSummary: + properties: + items: + items: + $ref: '#/definitions/repo.ItemSummary' + type: array + page: + type: integer + pageSize: + type: integer + total: + type: integer + type: object + repo.TemplateField: + properties: + id: + type: string + name: + type: string + textValue: + type: string + type: + type: string + type: object + repo.TemplateLabelSummary: + properties: + id: + type: string + name: + type: string + type: object + repo.TemplateLocationSummary: + properties: + id: + type: string + name: + type: string + type: object + repo.TotalsByOrganizer: + properties: + id: + type: string + name: + type: string + total: + type: number + type: object + repo.TreeItem: + properties: + children: + items: + $ref: '#/definitions/repo.TreeItem' + type: array + id: + type: string + name: + type: string + type: + type: string + type: object + repo.UserOut: + properties: + email: + type: string + groupId: + type: string + groupName: + type: string + id: + type: string + isOwner: + type: boolean + isSuperuser: + type: boolean + name: + type: string + oidcIssuer: + type: string + oidcSubject: + type: string + type: object + repo.UserUpdate: + properties: + email: + type: string + name: + type: string + type: object + repo.ValueOverTime: + properties: + end: + type: string + entries: + items: + $ref: '#/definitions/repo.ValueOverTimeEntry' + type: array + start: + type: string + valueAtEnd: + type: number + valueAtStart: + type: number + type: object + repo.ValueOverTimeEntry: + properties: + date: + type: string + name: + type: string + value: + type: number + type: object + services.Latest: + properties: + date: + type: string + version: + type: string + type: object + services.UserRegistration: + properties: + email: + type: string + name: + type: string + password: + type: string + token: + type: string + type: object + templatefield.Type: + enum: + - text + type: string + x-enum-varnames: + - TypeText + user.Role: + enum: + - user + - user + - owner + type: string + x-enum-varnames: + - DefaultRole + - RoleUser + - RoleOwner + v1.APISummary: + properties: + allowRegistration: + type: boolean + build: + $ref: '#/definitions/v1.Build' + demo: + type: boolean + health: + type: boolean + labelPrinting: + type: boolean + latest: + $ref: '#/definitions/services.Latest' + message: + type: string + oidc: + $ref: '#/definitions/v1.OIDCStatus' + title: + type: string + versions: + items: + type: string + type: array + type: object + v1.ActionAmountResult: + properties: + completed: + type: integer + type: object + v1.Build: + properties: + buildTime: + type: string + commit: + type: string + version: + type: string + type: object + v1.ChangePassword: + properties: + current: + type: string + new: + type: string + type: object + v1.GroupInvitation: + properties: + expiresAt: + type: string + token: + type: string + uses: + type: integer + type: object + v1.GroupInvitationCreate: + properties: + expiresAt: + type: string + uses: + maximum: 100 + minimum: 1 + type: integer + required: + - uses + type: object + v1.ItemAttachmentToken: + properties: + token: + type: string + type: object + v1.ItemTemplateCreateItemRequest: + properties: + description: + maxLength: 1000 + type: string + labelIds: + items: + type: string + type: array + locationId: + type: string + name: + maxLength: 255 + minLength: 1 + type: string + quantity: + type: integer + required: + - locationId + - name + type: object + v1.LoginForm: + properties: + password: + example: admin + type: string + stayLoggedIn: + type: boolean + username: + example: admin@admin.com + type: string + type: object + v1.OIDCStatus: + properties: + allowLocal: + type: boolean + autoRedirect: + type: boolean + buttonText: + type: string + enabled: + type: boolean + type: object + v1.TokenResponse: + properties: + attachmentToken: + type: string + expiresAt: + type: string + token: + type: string + type: object + v1.Wrapped: + properties: + item: {} + type: object + validate.ErrorResponse: + properties: + error: + type: string + fields: + type: string + type: object +host: demo.homebox.software +info: + contact: + name: Homebox Team + url: https://discord.homebox.software + description: Track, Manage, and Organize your Things. + title: Homebox API + version: "1.0" +paths: + /v1/actions/create-missing-thumbnails: + post: + description: Creates thumbnails for items that are missing them + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/v1.ActionAmountResult' + security: + - Bearer: [] + summary: Create Missing Thumbnails + tags: + - Actions + /v1/actions/ensure-asset-ids: + post: + description: Ensures all items in the database have an asset ID + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/v1.ActionAmountResult' + security: + - Bearer: [] + summary: Ensure Asset IDs + tags: + - Actions + /v1/actions/ensure-import-refs: + post: + description: Ensures all items in the database have an import ref + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/v1.ActionAmountResult' + security: + - Bearer: [] + summary: Ensures Import Refs + tags: + - Actions + /v1/actions/set-primary-photos: + post: + description: Sets the first photo of each item as the primary photo + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/v1.ActionAmountResult' + security: + - Bearer: [] + summary: Set Primary Photos + tags: + - Actions + /v1/actions/zero-item-time-fields: + post: + description: Resets all item date fields to the beginning of the day + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/v1.ActionAmountResult' + security: + - Bearer: [] + summary: Zero Out Time Fields + tags: + - Actions + /v1/assets/{id}: + get: + parameters: + - description: Asset ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.PaginationResult-repo_ItemSummary' + security: + - Bearer: [] + summary: Get Item by Asset ID + tags: + - Items + /v1/currency: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/currencies.Currency' + summary: Currency + tags: + - Base + /v1/groups: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.Group' + security: + - Bearer: [] + summary: Get Group + tags: + - Group + put: + parameters: + - description: User Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.GroupUpdate' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.Group' + security: + - Bearer: [] + summary: Update Group + tags: + - Group + /v1/groups/invitations: + post: + parameters: + - description: User Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/v1.GroupInvitationCreate' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/v1.GroupInvitation' + security: + - Bearer: [] + summary: Create Group Invitation + tags: + - Group + /v1/groups/statistics: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.GroupStatistics' + security: + - Bearer: [] + summary: Get Group Statistics + tags: + - Statistics + /v1/groups/statistics/labels: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/repo.TotalsByOrganizer' + type: array + security: + - Bearer: [] + summary: Get Label Statistics + tags: + - Statistics + /v1/groups/statistics/locations: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/repo.TotalsByOrganizer' + type: array + security: + - Bearer: [] + summary: Get Location Statistics + tags: + - Statistics + /v1/groups/statistics/purchase-price: + get: + parameters: + - description: start date + in: query + name: start + type: string + - description: end date + in: query + name: end + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.ValueOverTime' + security: + - Bearer: [] + summary: Get Purchase Price Statistics + tags: + - Statistics + /v1/items: + get: + parameters: + - description: search string + in: query + name: q + type: string + - description: page number + in: query + name: page + type: integer + - description: items per page + in: query + name: pageSize + type: integer + - collectionFormat: multi + description: label Ids + in: query + items: + type: string + name: labels + type: array + - collectionFormat: multi + description: location Ids + in: query + items: + type: string + name: locations + type: array + - collectionFormat: multi + description: parent Ids + in: query + items: + type: string + name: parentIds + type: array + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.PaginationResult-repo_ItemSummary' + security: + - Bearer: [] + summary: Query All Items + tags: + - Items + post: + parameters: + - description: Item Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.ItemCreate' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/repo.ItemSummary' + security: + - Bearer: [] + summary: Create Item + tags: + - Items + /v1/items/{id}: + delete: + parameters: + - description: Item ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "204": + description: No Content + security: + - Bearer: [] + summary: Delete Item + tags: + - Items + get: + parameters: + - description: Item ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.ItemOut' + security: + - Bearer: [] + summary: Get Item + tags: + - Items + patch: + parameters: + - description: Item ID + in: path + name: id + required: true + type: string + - description: Item Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.ItemPatch' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.ItemOut' + security: + - Bearer: [] + summary: Update Item + tags: + - Items + put: + parameters: + - description: Item ID + in: path + name: id + required: true + type: string + - description: Item Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.ItemUpdate' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.ItemOut' + security: + - Bearer: [] + summary: Update Item + tags: + - Items + /v1/items/{id}/attachments: + post: + consumes: + - multipart/form-data + parameters: + - description: Item ID + in: path + name: id + required: true + type: string + - description: File attachment + in: formData + name: file + required: true + type: file + - description: Type of file + in: formData + name: type + type: string + - description: Is this the primary attachment + in: formData + name: primary + type: boolean + - description: name of the file including extension + in: formData + name: name + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.ItemOut' + "422": + description: Unprocessable Entity + schema: + $ref: '#/definitions/validate.ErrorResponse' + security: + - Bearer: [] + summary: Create Item Attachment + tags: + - Items Attachments + /v1/items/{id}/attachments/{attachment_id}: + delete: + parameters: + - description: Item ID + in: path + name: id + required: true + type: string + - description: Attachment ID + in: path + name: attachment_id + required: true + type: string + responses: + "204": + description: No Content + security: + - Bearer: [] + summary: Delete Item Attachment + tags: + - Items Attachments + get: + parameters: + - description: Item ID + in: path + name: id + required: true + type: string + - description: Attachment ID + in: path + name: attachment_id + required: true + type: string + produces: + - application/octet-stream + responses: + "200": + description: OK + schema: + $ref: '#/definitions/v1.ItemAttachmentToken' + security: + - Bearer: [] + summary: Get Item Attachment + tags: + - Items Attachments + put: + parameters: + - description: Item ID + in: path + name: id + required: true + type: string + - description: Attachment ID + in: path + name: attachment_id + required: true + type: string + - description: Attachment Update + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.ItemAttachmentUpdate' + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.ItemOut' + security: + - Bearer: [] + summary: Update Item Attachment + tags: + - Items Attachments + /v1/items/{id}/duplicate: + post: + parameters: + - description: Item ID + in: path + name: id + required: true + type: string + - description: Duplicate Options + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.DuplicateOptions' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/repo.ItemOut' + security: + - Bearer: [] + summary: Duplicate Item + tags: + - Items + /v1/items/{id}/maintenance: + get: + parameters: + - description: Item ID + in: path + name: id + required: true + type: string + - enum: + - scheduled + - completed + - both + in: query + name: status + type: string + x-enum-varnames: + - MaintenanceFilterStatusScheduled + - MaintenanceFilterStatusCompleted + - MaintenanceFilterStatusBoth + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/repo.MaintenanceEntryWithDetails' + type: array + security: + - Bearer: [] + summary: Get Maintenance Log + tags: + - Item Maintenance + post: + parameters: + - description: Item ID + in: path + name: id + required: true + type: string + - description: Entry Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.MaintenanceEntryCreate' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/repo.MaintenanceEntry' + security: + - Bearer: [] + summary: Create Maintenance Entry + tags: + - Item Maintenance + /v1/items/{id}/path: + get: + parameters: + - description: Item ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/repo.ItemPath' + type: array + security: + - Bearer: [] + summary: Get the full path of an item + tags: + - Items + /v1/items/export: + get: + responses: + "200": + description: text/csv + schema: + type: string + security: + - Bearer: [] + summary: Export Items + tags: + - Items + /v1/items/fields: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + type: string + type: array + security: + - Bearer: [] + summary: Get All Custom Field Names + tags: + - Items + /v1/items/fields/values: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + type: string + type: array + security: + - Bearer: [] + summary: Get All Custom Field Values + tags: + - Items + /v1/items/import: + post: + consumes: + - multipart/form-data + parameters: + - description: Image to upload + in: formData + name: csv + required: true + type: file + produces: + - application/json + responses: + "204": + description: No Content + security: + - Bearer: [] + summary: Import Items + tags: + - Items + /v1/labelmaker/assets/{id}: + get: + parameters: + - description: Asset ID + in: path + name: id + required: true + type: string + - description: Print this label, defaults to false + in: query + name: print + type: boolean + produces: + - application/json + responses: + "200": + description: image/png + schema: + type: string + security: + - Bearer: [] + summary: Get Asset label + tags: + - Items + /v1/labelmaker/item/{id}: + get: + parameters: + - description: Item ID + in: path + name: id + required: true + type: string + - description: Print this label, defaults to false + in: query + name: print + type: boolean + produces: + - application/json + responses: + "200": + description: image/png + schema: + type: string + security: + - Bearer: [] + summary: Get Item label + tags: + - Items + /v1/labelmaker/location/{id}: + get: + parameters: + - description: Location ID + in: path + name: id + required: true + type: string + - description: Print this label, defaults to false + in: query + name: print + type: boolean + produces: + - application/json + responses: + "200": + description: image/png + schema: + type: string + security: + - Bearer: [] + summary: Get Location label + tags: + - Locations + /v1/labels: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/repo.LabelOut' + type: array + security: + - Bearer: [] + summary: Get All Labels + tags: + - Labels + post: + parameters: + - description: Label Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.LabelCreate' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.LabelSummary' + security: + - Bearer: [] + summary: Create Label + tags: + - Labels + /v1/labels/{id}: + delete: + parameters: + - description: Label ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "204": + description: No Content + security: + - Bearer: [] + summary: Delete Label + tags: + - Labels + get: + parameters: + - description: Label ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.LabelOut' + security: + - Bearer: [] + summary: Get Label + tags: + - Labels + put: + parameters: + - description: Label ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.LabelOut' + security: + - Bearer: [] + summary: Update Label + tags: + - Labels + /v1/locations: + get: + parameters: + - description: Filter locations with parents + in: query + name: filterChildren + type: boolean + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/repo.LocationOutCount' + type: array + security: + - Bearer: [] + summary: Get All Locations + tags: + - Locations + post: + parameters: + - description: Location Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.LocationCreate' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.LocationSummary' + security: + - Bearer: [] + summary: Create Location + tags: + - Locations + /v1/locations/{id}: + delete: + parameters: + - description: Location ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "204": + description: No Content + security: + - Bearer: [] + summary: Delete Location + tags: + - Locations + get: + parameters: + - description: Location ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.LocationOut' + security: + - Bearer: [] + summary: Get Location + tags: + - Locations + put: + parameters: + - description: Location ID + in: path + name: id + required: true + type: string + - description: Location Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.LocationUpdate' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.LocationOut' + security: + - Bearer: [] + summary: Update Location + tags: + - Locations + /v1/locations/tree: + get: + parameters: + - description: include items in response tree + in: query + name: withItems + type: boolean + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/repo.TreeItem' + type: array + security: + - Bearer: [] + summary: Get Locations Tree + tags: + - Locations + /v1/maintenance: + get: + parameters: + - enum: + - scheduled + - completed + - both + in: query + name: status + type: string + x-enum-varnames: + - MaintenanceFilterStatusScheduled + - MaintenanceFilterStatusCompleted + - MaintenanceFilterStatusBoth + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/repo.MaintenanceEntryWithDetails' + type: array + security: + - Bearer: [] + summary: Query All Maintenance + tags: + - Maintenance + /v1/maintenance/{id}: + delete: + parameters: + - description: Maintenance ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "204": + description: No Content + security: + - Bearer: [] + summary: Delete Maintenance Entry + tags: + - Maintenance + put: + parameters: + - description: Maintenance ID + in: path + name: id + required: true + type: string + - description: Entry Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.MaintenanceEntryUpdate' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.MaintenanceEntry' + security: + - Bearer: [] + summary: Update Maintenance Entry + tags: + - Maintenance + /v1/notifiers: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/repo.NotifierOut' + type: array + security: + - Bearer: [] + summary: Get Notifiers + tags: + - Notifiers + post: + parameters: + - description: Notifier Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.NotifierCreate' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.NotifierOut' + security: + - Bearer: [] + summary: Create Notifier + tags: + - Notifiers + /v1/notifiers/{id}: + delete: + parameters: + - description: Notifier ID + in: path + name: id + required: true + type: string + responses: + "204": + description: No Content + security: + - Bearer: [] + summary: Delete a Notifier + tags: + - Notifiers + put: + parameters: + - description: Notifier ID + in: path + name: id + required: true + type: string + - description: Notifier Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.NotifierUpdate' + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.NotifierOut' + security: + - Bearer: [] + summary: Update Notifier + tags: + - Notifiers + /v1/notifiers/test: + post: + parameters: + - description: URL + in: query + name: url + required: true + type: string + produces: + - application/json + responses: + "204": + description: No Content + security: + - Bearer: [] + summary: Test Notifier + tags: + - Notifiers + /v1/products/search-from-barcode: + get: + parameters: + - description: barcode to be searched + in: query + name: data + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/repo.BarcodeProduct' + type: array + security: + - Bearer: [] + summary: Search EAN from Barcode + tags: + - Items + /v1/qrcode: + get: + parameters: + - description: data to be encoded into qrcode + in: query + name: data + type: string + produces: + - application/json + responses: + "200": + description: image/jpeg + schema: + type: string + security: + - Bearer: [] + summary: Create QR Code + tags: + - Items + /v1/reporting/bill-of-materials: + get: + produces: + - application/json + responses: + "200": + description: text/csv + schema: + type: string + security: + - Bearer: [] + summary: Export Bill of Materials + tags: + - Reporting + /v1/status: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/v1.APISummary' + summary: Application Info + tags: + - Base + /v1/templates: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/repo.ItemTemplateSummary' + type: array + security: + - Bearer: [] + summary: Get All Item Templates + tags: + - Item Templates + post: + parameters: + - description: Template Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.ItemTemplateCreate' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/repo.ItemTemplateOut' + security: + - Bearer: [] + summary: Create Item Template + tags: + - Item Templates + /v1/templates/{id}: + delete: + parameters: + - description: Template ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "204": + description: No Content + security: + - Bearer: [] + summary: Delete Item Template + tags: + - Item Templates + get: + parameters: + - description: Template ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.ItemTemplateOut' + security: + - Bearer: [] + summary: Get Item Template + tags: + - Item Templates + put: + parameters: + - description: Template ID + in: path + name: id + required: true + type: string + - description: Template Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.ItemTemplateUpdate' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.ItemTemplateOut' + security: + - Bearer: [] + summary: Update Item Template + tags: + - Item Templates + /v1/templates/{id}/create-item: + post: + parameters: + - description: Template ID + in: path + name: id + required: true + type: string + - description: Item Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/v1.ItemTemplateCreateItemRequest' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/repo.ItemOut' + security: + - Bearer: [] + summary: Create Item from Template + tags: + - Item Templates + /v1/users/change-password: + put: + parameters: + - description: Password Payload + in: body + name: payload + required: true + schema: + $ref: '#/definitions/v1.ChangePassword' + responses: + "204": + description: No Content + security: + - Bearer: [] + summary: Change Password + tags: + - User + /v1/users/login: + post: + consumes: + - application/x-www-form-urlencoded + - application/json + parameters: + - description: Login Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/v1.LoginForm' + - description: auth provider + in: query + name: provider + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/v1.TokenResponse' + summary: User Login + tags: + - Authentication + /v1/users/login/oidc: + get: + produces: + - application/json + responses: + "302": + description: Found + summary: OIDC Login Initiation + tags: + - Authentication + /v1/users/login/oidc/callback: + get: + parameters: + - description: Authorization code + in: query + name: code + required: true + type: string + - description: State parameter + in: query + name: state + required: true + type: string + responses: + "302": + description: Found + summary: OIDC Callback Handler + tags: + - Authentication + /v1/users/logout: + post: + responses: + "204": + description: No Content + security: + - Bearer: [] + summary: User Logout + tags: + - Authentication + /v1/users/refresh: + get: + description: |- + handleAuthRefresh returns a handler that will issue a new token from an existing token. + This does not validate that the user still exists within the database. + responses: + "200": + description: OK + security: + - Bearer: [] + summary: User Token Refresh + tags: + - Authentication + /v1/users/register: + post: + parameters: + - description: User Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/services.UserRegistration' + produces: + - application/json + responses: + "204": + description: No Content + "403": + description: Local login is not enabled + schema: + type: string + summary: Register New User + tags: + - User + /v1/users/self: + delete: + produces: + - application/json + responses: + "204": + description: No Content + security: + - Bearer: [] + summary: Delete Account + tags: + - User + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/v1.Wrapped' + - properties: + item: + $ref: '#/definitions/repo.UserOut' + type: object + security: + - Bearer: [] + summary: Get User Self + tags: + - User + put: + parameters: + - description: User Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.UserUpdate' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/v1.Wrapped' + - properties: + item: + $ref: '#/definitions/repo.UserUpdate' + type: object + security: + - Bearer: [] + summary: Update Account + tags: + - User +schemes: +- https +- http +securityDefinitions: + Bearer: + description: '"Type ''Bearer TOKEN'' to correctly set the API Key"' + in: header + name: Authorization + type: apiKey +swagger: "2.0" diff --git a/docs/en/api/openapi-3.0.json b/docs/en/api/openapi-3.0.json index ceb6d5dd..a80a6124 100644 --- a/docs/en/api/openapi-3.0.json +++ b/docs/en/api/openapi-3.0.json @@ -196,456 +196,6 @@ } } }, - "/v1/entities/{id}/attachments": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "Items Attachments" - ], - "summary": "Create Item Attachment", - "parameters": [ - { - "description": "Item ID", - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "$ref": "#/components/requestBodies/postV1Entities_id_attachments" - }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.ItemOut" - } - } - } - }, - "422": { - "description": "Unprocessable Entity", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/validate.ErrorResponse" - } - } - } - } - } - } - }, - "/v1/entities/{id}/attachments/{attachment_id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "Items Attachments" - ], - "summary": "Get Item Attachment", - "parameters": [ - { - "description": "Item ID", - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "description": "Attachment ID", - "name": "attachment_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/octet-stream": { - "schema": { - "$ref": "#/components/schemas/v1.ItemAttachmentToken" - } - } - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "Items Attachments" - ], - "summary": "Update Item Attachment", - "parameters": [ - { - "description": "Item ID", - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "description": "Attachment ID", - "name": "attachment_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "$ref": "#/components/requestBodies/repo.EntityAttachmentUpdate" - }, - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/repo.ItemOut" - } - } - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "Items Attachments" - ], - "summary": "Delete Item Attachment", - "parameters": [ - { - "description": "Item ID", - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "description": "Attachment ID", - "name": "attachment_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "No Content" - } - } - } - }, - "/v1/entities/{id}/maintenance": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "Item Maintenance" - ], - "summary": "Get Maintenance Log", - "parameters": [ - { - "description": "Item ID", - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "x-enum-varnames": [ - "MaintenanceFilterStatusScheduled", - "MaintenanceFilterStatusCompleted", - "MaintenanceFilterStatusBoth" - ], - "name": "status", - "in": "query", - "schema": { - "type": "string", - "enum": [ - "scheduled", - "completed", - "both" - ] - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/repo.MaintenanceEntryWithDetails" - } - } - } - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "Item Maintenance" - ], - "summary": "Create Maintenance Entry", - "parameters": [ - { - "description": "Item ID", - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "$ref": "#/components/requestBodies/repo.MaintenanceEntryCreate" - }, - "responses": { - "201": { - "description": "Created", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.MaintenanceEntry" - } - } - } - } - } - } - }, - "/v1/entitytype": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "EntityTypes" - ], - "summary": "Query All Entity Types", - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/repo.EntityType" - } - } - } - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "EntityTypes" - ], - "summary": "Create Entity Type", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.EntityTypeCreate" - } - } - }, - "description": "Entity Type Data", - "required": true - }, - "responses": { - "201": { - "description": "Created", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.EntityType" - } - } - } - } - } - } - }, - "/v1/entitytype/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "EntityTypes" - ], - "summary": "Get One Entity Type", - "parameters": [ - { - "description": "Entity Type ID", - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.EntityType" - } - } - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "EntityTypes" - ], - "summary": "Update Entity Type", - "parameters": [ - { - "description": "Entity Type ID", - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.EntityTypeUpdate" - } - } - }, - "description": "Entity Type Data", - "required": true - }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.EntityType" - } - } - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "tags": [ - "EntityTypes" - ], - "summary": "Delete Entity Type", - "parameters": [ - { - "description": "Entity Type ID", - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.EntityTypeDelete" - } - } - }, - "description": "Entity Type Delete Options", - "required": true - }, - "responses": { - "204": { - "description": "No Content" - } - } - } - }, "/v1/groups": { "get": { "security": [ @@ -875,8 +425,7 @@ "tags": [ "Items" ], - "summary": "(Deprecated) Query All Items", - "deprecated": true, + "summary": "Query All Items", "parameters": [ { "description": "search string", @@ -962,7 +511,6 @@ "Items" ], "summary": "Create Item", - "deprecated": true, "requestBody": { "content": { "application/json": { @@ -998,8 +546,7 @@ "tags": [ "Items" ], - "summary": "(Deprecated) Export Items", - "deprecated": true, + "summary": "Export Items", "responses": { "200": { "description": "text/csv", @@ -1024,8 +571,7 @@ "tags": [ "Items" ], - "summary": "(Deprecated) Get All Custom Field Names", - "deprecated": true, + "summary": "Get All Custom Field Names", "responses": { "200": { "description": "OK", @@ -1053,8 +599,7 @@ "tags": [ "Items" ], - "summary": "(Deprecated) Get All Custom Field Values", - "deprecated": true, + "summary": "Get All Custom Field Values", "responses": { "200": { "description": "OK", @@ -1082,8 +627,7 @@ "tags": [ "Items" ], - "summary": "(Deprecated) Import Items", - "deprecated": true, + "summary": "Import Items", "requestBody": { "content": { "multipart/form-data": { @@ -1121,8 +665,7 @@ "tags": [ "Items" ], - "summary": "(Deprecated) Get Item", - "deprecated": true, + "summary": "Get Item", "parameters": [ { "description": "Item ID", @@ -1156,8 +699,7 @@ "tags": [ "Items" ], - "summary": "(Deprecated) Update Item", - "deprecated": true, + "summary": "Update Item", "parameters": [ { "description": "Item ID", @@ -1202,8 +744,7 @@ "tags": [ "Items" ], - "summary": "(Deprecated) Delete Item", - "deprecated": true, + "summary": "Delete Item", "parameters": [ { "description": "Item ID", @@ -1230,8 +771,7 @@ "tags": [ "Items" ], - "summary": "(Deprecated) Update Item", - "deprecated": true, + "summary": "Update Item", "parameters": [ { "description": "Item ID", @@ -1279,7 +819,6 @@ "Items Attachments" ], "summary": "Create Item Attachment", - "deprecated": true, "parameters": [ { "description": "Item ID", @@ -1292,7 +831,37 @@ } ], "requestBody": { - "$ref": "#/components/requestBodies/postV1Entities_id_attachments" + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "file": { + "description": "File attachment", + "type": "string", + "format": "binary" + }, + "type": { + "description": "Type of file", + "type": "string" + }, + "primary": { + "description": "Is this the primary attachment", + "type": "boolean" + }, + "name": { + "description": "name of the file including extension", + "type": "string" + } + }, + "required": [ + "file", + "name" + ] + } + } + }, + "required": true }, "responses": { "200": { @@ -1329,7 +898,6 @@ "Items Attachments" ], "summary": "Get Item Attachment", - "deprecated": true, "parameters": [ { "description": "Item ID", @@ -1373,7 +941,6 @@ "Items Attachments" ], "summary": "Update Item Attachment", - "deprecated": true, "parameters": [ { "description": "Item ID", @@ -1395,7 +962,15 @@ } ], "requestBody": { - "$ref": "#/components/requestBodies/repo.EntityAttachmentUpdate" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.ItemAttachmentUpdate" + } + } + }, + "description": "Attachment Update", + "required": true }, "responses": { "200": { @@ -1420,7 +995,6 @@ "Items Attachments" ], "summary": "Delete Item Attachment", - "deprecated": true, "parameters": [ { "description": "Item ID", @@ -1506,7 +1080,6 @@ "Item Maintenance" ], "summary": "Get Maintenance Log", - "deprecated": true, "parameters": [ { "description": "Item ID", @@ -1561,7 +1134,6 @@ "Item Maintenance" ], "summary": "Create Maintenance Entry", - "deprecated": true, "parameters": [ { "description": "Item ID", @@ -1574,7 +1146,15 @@ } ], "requestBody": { - "$ref": "#/components/requestBodies/repo.MaintenanceEntryCreate" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.MaintenanceEntryCreate" + } + } + }, + "description": "Entry Data", + "required": true }, "responses": { "201": { @@ -1600,8 +1180,7 @@ "tags": [ "Items" ], - "summary": "(Deprecated) Get the full path of an item", - "deprecated": true, + "summary": "Get the full path of an item", "parameters": [ { "description": "Item ID", @@ -1931,8 +1510,7 @@ "tags": [ "Locations" ], - "summary": "(Deprecated) Get All Locations", - "deprecated": true, + "summary": "Get All Locations", "parameters": [ { "description": "Filter locations with parents", @@ -1968,8 +1546,7 @@ "tags": [ "Locations" ], - "summary": "(Deprecated) Create Location", - "deprecated": true, + "summary": "Create Location", "requestBody": { "content": { "application/json": { @@ -2005,8 +1582,7 @@ "tags": [ "Locations" ], - "summary": "(Deprecated) Get Locations Tree", - "deprecated": true, + "summary": "Get Locations Tree", "parameters": [ { "description": "include items in response tree", @@ -2044,8 +1620,7 @@ "tags": [ "Locations" ], - "summary": "(Deprecated) Get Location", - "deprecated": true, + "summary": "Get Location", "parameters": [ { "description": "Location ID", @@ -2079,8 +1654,7 @@ "tags": [ "Locations" ], - "summary": "(Deprecated) Update Location", - "deprecated": true, + "summary": "Update Location", "parameters": [ { "description": "Location ID", @@ -2125,8 +1699,7 @@ "tags": [ "Locations" ], - "summary": "(Deprecated) Delete Location", - "deprecated": true, + "summary": "Delete Location", "parameters": [ { "description": "Location ID", @@ -2549,6 +2122,223 @@ } } }, + "/v1/templates": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Item Templates" + ], + "summary": "Get All Item Templates", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/repo.ItemTemplateSummary" + } + } + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Item Templates" + ], + "summary": "Create Item Template", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.ItemTemplateCreate" + } + } + }, + "description": "Template Data", + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.ItemTemplateOut" + } + } + } + } + } + } + }, + "/v1/templates/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Item Templates" + ], + "summary": "Get Item Template", + "parameters": [ + { + "description": "Template ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.ItemTemplateOut" + } + } + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Item Templates" + ], + "summary": "Update Item Template", + "parameters": [ + { + "description": "Template ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.ItemTemplateUpdate" + } + } + }, + "description": "Template Data", + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.ItemTemplateOut" + } + } + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Item Templates" + ], + "summary": "Delete Item Template", + "parameters": [ + { + "description": "Template ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/templates/{id}/create-item": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Item Templates" + ], + "summary": "Create Item from Template", + "parameters": [ + { + "description": "Template ID", + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/v1.ItemTemplateCreateItemRequest" + } + } + }, + "description": "Item Data", + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/repo.ItemOut" + } + } + } + } + } + } + }, "/v1/users/change-password": { "put": { "security": [ @@ -2624,6 +2414,52 @@ } } }, + "/v1/users/login/oidc": { + "get": { + "tags": [ + "Authentication" + ], + "summary": "OIDC Login Initiation", + "responses": { + "302": { + "description": "Found" + } + } + } + }, + "/v1/users/login/oidc/callback": { + "get": { + "tags": [ + "Authentication" + ], + "summary": "OIDC Callback Handler", + "parameters": [ + { + "description": "Authorization code", + "name": "code", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "State parameter", + "name": "state", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "302": { + "description": "Found" + } + } + } + }, "/v1/users/logout": { "post": { "security": [ @@ -2681,6 +2517,16 @@ "responses": { "204": { "description": "No Content" + }, + "403": { + "description": "Local login is not enabled", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } } } } @@ -2794,63 +2640,6 @@ } ], "components": { - "requestBodies": { - "postV1Entities_id_attachments": { - "content": { - "multipart/form-data": { - "schema": { - "type": "object", - "properties": { - "file": { - "description": "File attachment", - "type": "string", - "format": "binary" - }, - "type": { - "description": "Type of file", - "type": "string" - }, - "primary": { - "description": "Is this the primary attachment", - "type": "boolean" - }, - "name": { - "description": "name of the file including extension", - "type": "string" - } - }, - "required": [ - "file", - "name" - ] - } - } - }, - "required": true - }, - "repo.MaintenanceEntryCreate": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.MaintenanceEntryCreate" - } - } - }, - "description": "Entry Data", - "required": true - }, - "repo.EntityAttachmentUpdate": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/repo.EntityAttachmentUpdate" - } - } - }, - "description": "Attachment Update", - "required": true - } - }, "securitySchemes": { "Bearer": { "description": "\"Type 'Bearer TOKEN' to correctly set the API Key\"", @@ -2968,11 +2757,11 @@ "ent.AttachmentEdges": { "type": "object", "properties": { - "entity": { - "description": "Entity holds the value of the entity edge.", + "item": { + "description": "Item holds the value of the item edge.", "allOf": [ { - "$ref": "#/components/schemas/ent.Entity" + "$ref": "#/components/schemas/ent.Item" } ] }, @@ -3081,333 +2870,6 @@ } } }, - "ent.Entity": { - "type": "object", - "properties": { - "archived": { - "description": "Archived holds the value of the \"archived\" field.", - "type": "boolean" - }, - "asset_id": { - "description": "AssetID holds the value of the \"asset_id\" field.", - "type": "integer" - }, - "created_at": { - "description": "CreatedAt holds the value of the \"created_at\" field.", - "type": "string" - }, - "description": { - "description": "Description holds the value of the \"description\" field.", - "type": "string" - }, - "edges": { - "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityQuery when eager-loading is set.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.EntityEdges" - } - ] - }, - "id": { - "description": "ID of the ent.", - "type": "string" - }, - "import_ref": { - "description": "ImportRef holds the value of the \"import_ref\" field.", - "type": "string" - }, - "insured": { - "description": "Insured holds the value of the \"insured\" field.", - "type": "boolean" - }, - "lifetime_warranty": { - "description": "LifetimeWarranty holds the value of the \"lifetime_warranty\" field.", - "type": "boolean" - }, - "manufacturer": { - "description": "Manufacturer holds the value of the \"manufacturer\" field.", - "type": "string" - }, - "model_number": { - "description": "ModelNumber holds the value of the \"model_number\" field.", - "type": "string" - }, - "name": { - "description": "Name holds the value of the \"name\" field.", - "type": "string" - }, - "notes": { - "description": "Notes holds the value of the \"notes\" field.", - "type": "string" - }, - "purchase_from": { - "description": "PurchaseFrom holds the value of the \"purchase_from\" field.", - "type": "string" - }, - "purchase_price": { - "description": "PurchasePrice holds the value of the \"purchase_price\" field.", - "type": "number" - }, - "purchase_time": { - "description": "PurchaseTime holds the value of the \"purchase_time\" field.", - "type": "string" - }, - "quantity": { - "description": "Quantity holds the value of the \"quantity\" field.", - "type": "integer" - }, - "serial_number": { - "description": "SerialNumber holds the value of the \"serial_number\" field.", - "type": "string" - }, - "sold_notes": { - "description": "SoldNotes holds the value of the \"sold_notes\" field.", - "type": "string" - }, - "sold_price": { - "description": "SoldPrice holds the value of the \"sold_price\" field.", - "type": "number" - }, - "sold_time": { - "description": "SoldTime holds the value of the \"sold_time\" field.", - "type": "string" - }, - "sold_to": { - "description": "SoldTo holds the value of the \"sold_to\" field.", - "type": "string" - }, - "sync_child_entities_locations": { - "description": "SyncChildEntitiesLocations holds the value of the \"sync_child_entities_locations\" field.", - "type": "boolean" - }, - "updated_at": { - "description": "UpdatedAt holds the value of the \"updated_at\" field.", - "type": "string" - }, - "warranty_details": { - "description": "WarrantyDetails holds the value of the \"warranty_details\" field.", - "type": "string" - }, - "warranty_expires": { - "description": "WarrantyExpires holds the value of the \"warranty_expires\" field.", - "type": "string" - } - } - }, - "ent.EntityEdges": { - "type": "object", - "properties": { - "attachments": { - "description": "Attachments holds the value of the attachments edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.Attachment" - } - }, - "children": { - "description": "Children holds the value of the children edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.Entity" - } - }, - "entity": { - "description": "Entity holds the value of the entity edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.Entity" - } - }, - "fields": { - "description": "Fields holds the value of the fields edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.EntityField" - } - }, - "group": { - "description": "Group holds the value of the group edge.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.Group" - } - ] - }, - "label": { - "description": "Label holds the value of the label edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.Label" - } - }, - "location": { - "description": "Location holds the value of the location edge.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.Entity" - } - ] - }, - "maintenance_entries": { - "description": "MaintenanceEntries holds the value of the maintenance_entries edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.MaintenanceEntry" - } - }, - "parent": { - "description": "Parent holds the value of the parent edge.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.Entity" - } - ] - }, - "type": { - "description": "Type holds the value of the type edge.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.EntityType" - } - ] - } - } - }, - "ent.EntityField": { - "type": "object", - "properties": { - "boolean_value": { - "description": "BooleanValue holds the value of the \"boolean_value\" field.", - "type": "boolean" - }, - "created_at": { - "description": "CreatedAt holds the value of the \"created_at\" field.", - "type": "string" - }, - "description": { - "description": "Description holds the value of the \"description\" field.", - "type": "string" - }, - "edges": { - "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityFieldQuery when eager-loading is set.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.EntityFieldEdges" - } - ] - }, - "id": { - "description": "ID of the ent.", - "type": "string" - }, - "name": { - "description": "Name holds the value of the \"name\" field.", - "type": "string" - }, - "number_value": { - "description": "NumberValue holds the value of the \"number_value\" field.", - "type": "integer" - }, - "text_value": { - "description": "TextValue holds the value of the \"text_value\" field.", - "type": "string" - }, - "time_value": { - "description": "TimeValue holds the value of the \"time_value\" field.", - "type": "string" - }, - "type": { - "description": "Type holds the value of the \"type\" field.", - "allOf": [ - { - "$ref": "#/components/schemas/entityfield.Type" - } - ] - }, - "updated_at": { - "description": "UpdatedAt holds the value of the \"updated_at\" field.", - "type": "string" - } - } - }, - "ent.EntityFieldEdges": { - "type": "object", - "properties": { - "entity": { - "description": "Entity holds the value of the entity edge.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.Entity" - } - ] - } - } - }, - "ent.EntityType": { - "type": "object", - "properties": { - "color": { - "description": "Color holds the value of the \"color\" field.", - "type": "string" - }, - "created_at": { - "description": "CreatedAt holds the value of the \"created_at\" field.", - "type": "string" - }, - "description": { - "description": "Description holds the value of the \"description\" field.", - "type": "string" - }, - "edges": { - "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityTypeQuery when eager-loading is set.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.EntityTypeEdges" - } - ] - }, - "icon": { - "description": "Icon holds the value of the \"icon\" field.", - "type": "string" - }, - "id": { - "description": "ID of the ent.", - "type": "string" - }, - "is_location": { - "description": "IsLocation holds the value of the \"is_location\" field.", - "type": "boolean" - }, - "name": { - "description": "Name holds the value of the \"name\" field.", - "type": "string" - }, - "updated_at": { - "description": "UpdatedAt holds the value of the \"updated_at\" field.", - "type": "string" - } - } - }, - "ent.EntityTypeEdges": { - "type": "object", - "properties": { - "entities": { - "description": "Entities holds the value of the entities edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.Entity" - } - }, - "group": { - "description": "Group holds the value of the group edge.", - "allOf": [ - { - "$ref": "#/components/schemas/ent.Group" - } - ] - } - } - }, "ent.Group": { "type": "object", "properties": { @@ -3444,20 +2906,6 @@ "ent.GroupEdges": { "type": "object", "properties": { - "entities": { - "description": "Entities holds the value of the entities edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.Entity" - } - }, - "entity_types": { - "description": "EntityTypes holds the value of the entity_types edge.", - "type": "array", - "items": { - "$ref": "#/components/schemas/ent.EntityType" - } - }, "invitation_tokens": { "description": "InvitationTokens holds the value of the invitation_tokens edge.", "type": "array", @@ -3465,6 +2913,20 @@ "$ref": "#/components/schemas/ent.GroupInvitationToken" } }, + "item_templates": { + "description": "ItemTemplates holds the value of the item_templates edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.ItemTemplate" + } + }, + "items": { + "description": "Items holds the value of the items edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Item" + } + }, "labels": { "description": "Labels holds the value of the labels edge.", "type": "array", @@ -3472,6 +2934,13 @@ "$ref": "#/components/schemas/ent.Label" } }, + "locations": { + "description": "Locations holds the value of the locations edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Location" + } + }, "notifiers": { "description": "Notifiers holds the value of the notifiers edge.", "type": "array", @@ -3541,6 +3010,369 @@ } } }, + "ent.Item": { + "type": "object", + "properties": { + "archived": { + "description": "Archived holds the value of the \"archived\" field.", + "type": "boolean" + }, + "asset_id": { + "description": "AssetID holds the value of the \"asset_id\" field.", + "type": "integer" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.ItemEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "import_ref": { + "description": "ImportRef holds the value of the \"import_ref\" field.", + "type": "string" + }, + "insured": { + "description": "Insured holds the value of the \"insured\" field.", + "type": "boolean" + }, + "lifetime_warranty": { + "description": "LifetimeWarranty holds the value of the \"lifetime_warranty\" field.", + "type": "boolean" + }, + "manufacturer": { + "description": "Manufacturer holds the value of the \"manufacturer\" field.", + "type": "string" + }, + "model_number": { + "description": "ModelNumber holds the value of the \"model_number\" field.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "notes": { + "description": "Notes holds the value of the \"notes\" field.", + "type": "string" + }, + "purchase_from": { + "description": "PurchaseFrom holds the value of the \"purchase_from\" field.", + "type": "string" + }, + "purchase_price": { + "description": "PurchasePrice holds the value of the \"purchase_price\" field.", + "type": "number" + }, + "purchase_time": { + "description": "PurchaseTime holds the value of the \"purchase_time\" field.", + "type": "string" + }, + "quantity": { + "description": "Quantity holds the value of the \"quantity\" field.", + "type": "integer" + }, + "serial_number": { + "description": "SerialNumber holds the value of the \"serial_number\" field.", + "type": "string" + }, + "sold_notes": { + "description": "SoldNotes holds the value of the \"sold_notes\" field.", + "type": "string" + }, + "sold_price": { + "description": "SoldPrice holds the value of the \"sold_price\" field.", + "type": "number" + }, + "sold_time": { + "description": "SoldTime holds the value of the \"sold_time\" field.", + "type": "string" + }, + "sold_to": { + "description": "SoldTo holds the value of the \"sold_to\" field.", + "type": "string" + }, + "sync_child_items_locations": { + "description": "SyncChildItemsLocations holds the value of the \"sync_child_items_locations\" field.", + "type": "boolean" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + }, + "warranty_details": { + "description": "WarrantyDetails holds the value of the \"warranty_details\" field.", + "type": "string" + }, + "warranty_expires": { + "description": "WarrantyExpires holds the value of the \"warranty_expires\" field.", + "type": "string" + } + } + }, + "ent.ItemEdges": { + "type": "object", + "properties": { + "attachments": { + "description": "Attachments holds the value of the attachments edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Attachment" + } + }, + "children": { + "description": "Children holds the value of the children edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Item" + } + }, + "fields": { + "description": "Fields holds the value of the fields edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.ItemField" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.Group" + } + ] + }, + "label": { + "description": "Label holds the value of the label edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Label" + } + }, + "location": { + "description": "Location holds the value of the location edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.Location" + } + ] + }, + "maintenance_entries": { + "description": "MaintenanceEntries holds the value of the maintenance_entries edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.MaintenanceEntry" + } + }, + "parent": { + "description": "Parent holds the value of the parent edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.Item" + } + ] + } + } + }, + "ent.ItemField": { + "type": "object", + "properties": { + "boolean_value": { + "description": "BooleanValue holds the value of the \"boolean_value\" field.", + "type": "boolean" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemFieldQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.ItemFieldEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "number_value": { + "description": "NumberValue holds the value of the \"number_value\" field.", + "type": "integer" + }, + "text_value": { + "description": "TextValue holds the value of the \"text_value\" field.", + "type": "string" + }, + "time_value": { + "description": "TimeValue holds the value of the \"time_value\" field.", + "type": "string" + }, + "type": { + "description": "Type holds the value of the \"type\" field.", + "allOf": [ + { + "$ref": "#/components/schemas/itemfield.Type" + } + ] + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.ItemFieldEdges": { + "type": "object", + "properties": { + "item": { + "description": "Item holds the value of the item edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.Item" + } + ] + } + } + }, + "ent.ItemTemplate": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "default_description": { + "description": "Default description for items created from this template", + "type": "string" + }, + "default_insured": { + "description": "DefaultInsured holds the value of the \"default_insured\" field.", + "type": "boolean" + }, + "default_label_ids": { + "description": "Default label IDs for items created from this template", + "type": "array", + "items": { + "type": "string" + } + }, + "default_lifetime_warranty": { + "description": "DefaultLifetimeWarranty holds the value of the \"default_lifetime_warranty\" field.", + "type": "boolean" + }, + "default_manufacturer": { + "description": "DefaultManufacturer holds the value of the \"default_manufacturer\" field.", + "type": "string" + }, + "default_model_number": { + "description": "Default model number for items created from this template", + "type": "string" + }, + "default_name": { + "description": "Default name template for items (can use placeholders)", + "type": "string" + }, + "default_quantity": { + "description": "DefaultQuantity holds the value of the \"default_quantity\" field.", + "type": "integer" + }, + "default_warranty_details": { + "description": "DefaultWarrantyDetails holds the value of the \"default_warranty_details\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemTemplateQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.ItemTemplateEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "include_purchase_fields": { + "description": "Whether to include purchase fields in items created from this template", + "type": "boolean" + }, + "include_sold_fields": { + "description": "Whether to include sold fields in items created from this template", + "type": "boolean" + }, + "include_warranty_fields": { + "description": "Whether to include warranty fields in items created from this template", + "type": "boolean" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "notes": { + "description": "Notes holds the value of the \"notes\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.ItemTemplateEdges": { + "type": "object", + "properties": { + "fields": { + "description": "Fields holds the value of the fields edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.TemplateField" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.Group" + } + ] + }, + "location": { + "description": "Location holds the value of the location edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.Location" + } + ] + } + } + }, "ent.Label": { "type": "object", "properties": { @@ -3581,11 +3413,64 @@ "ent.LabelEdges": { "type": "object", "properties": { - "entities": { - "description": "Entities holds the value of the entities edge.", + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.Group" + } + ] + }, + "items": { + "description": "Items holds the value of the items edge.", "type": "array", "items": { - "$ref": "#/components/schemas/ent.Entity" + "$ref": "#/components/schemas/ent.Item" + } + } + } + }, + "ent.Location": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LocationQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.LocationEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.LocationEdges": { + "type": "object", + "properties": { + "children": { + "description": "Children holds the value of the children edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Location" } }, "group": { @@ -3595,6 +3480,21 @@ "$ref": "#/components/schemas/ent.Group" } ] + }, + "items": { + "description": "Items holds the value of the items edge.", + "type": "array", + "items": { + "$ref": "#/components/schemas/ent.Item" + } + }, + "parent": { + "description": "Parent holds the value of the parent edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.Location" + } + ] } } }, @@ -3625,14 +3525,14 @@ } ] }, - "entity_id": { - "description": "EntityID holds the value of the \"entity_id\" field.", - "type": "string" - }, "id": { "description": "ID of the ent.", "type": "string" }, + "item_id": { + "description": "ItemID holds the value of the \"item_id\" field.", + "type": "string" + }, "name": { "description": "Name holds the value of the \"name\" field.", "type": "string" @@ -3650,11 +3550,11 @@ "ent.MaintenanceEntryEdges": { "type": "object", "properties": { - "entity": { - "description": "Entity holds the value of the entity edge.", + "item": { + "description": "Item holds the value of the item edge.", "allOf": [ { - "$ref": "#/components/schemas/ent.Entity" + "$ref": "#/components/schemas/ent.Item" } ] } @@ -3722,6 +3622,64 @@ } } }, + "ent.TemplateField": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the TemplateFieldQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.TemplateFieldEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "text_value": { + "description": "TextValue holds the value of the \"text_value\" field.", + "type": "string" + }, + "type": { + "description": "Type holds the value of the \"type\" field.", + "allOf": [ + { + "$ref": "#/components/schemas/templatefield.Type" + } + ] + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.TemplateFieldEdges": { + "type": "object", + "properties": { + "item_template": { + "description": "ItemTemplate holds the value of the item_template edge.", + "allOf": [ + { + "$ref": "#/components/schemas/ent.ItemTemplate" + } + ] + } + } + }, "ent.User": { "type": "object", "properties": { @@ -3757,6 +3715,14 @@ "description": "Name holds the value of the \"name\" field.", "type": "string" }, + "oidc_issuer": { + "description": "OidcIssuer holds the value of the \"oidc_issuer\" field.", + "type": "string" + }, + "oidc_subject": { + "description": "OidcSubject holds the value of the \"oidc_subject\" field.", + "type": "string" + }, "role": { "description": "Role holds the value of the \"role\" field.", "allOf": [ @@ -3802,7 +3768,7 @@ } } }, - "entityfield.Type": { + "itemfield.Type": { "type": "string", "enum": [ "text", @@ -3865,122 +3831,6 @@ } } }, - "repo.EntityAttachment": { - "type": "object", - "properties": { - "createdAt": { - "type": "string" - }, - "id": { - "type": "string" - }, - "mimeType": { - "type": "string" - }, - "path": { - "type": "string" - }, - "primary": { - "type": "boolean" - }, - "thumbnail": { - "$ref": "#/components/schemas/ent.Attachment" - }, - "title": { - "type": "string" - }, - "type": { - "type": "string" - }, - "updatedAt": { - "type": "string" - } - } - }, - "repo.EntityAttachmentUpdate": { - "type": "object", - "properties": { - "primary": { - "type": "boolean" - }, - "title": { - "type": "string" - }, - "type": { - "type": "string" - } - } - }, - "repo.EntityType": { - "type": "object", - "properties": { - "color": { - "type": "string" - }, - "description": { - "type": "string" - }, - "icon": { - "type": "string" - }, - "isLocation": { - "type": "boolean" - }, - "name": { - "type": "string" - } - } - }, - "repo.EntityTypeCreate": { - "type": "object", - "required": [ - "isLocation", - "name" - ], - "properties": { - "color": { - "type": "string" - }, - "description": { - "type": "string" - }, - "icon": { - "type": "string" - }, - "isLocation": { - "type": "boolean" - }, - "name": { - "type": "string" - } - } - }, - "repo.EntityTypeDelete": { - "type": "object", - "properties": { - "replacementId": { - "$ref": "#/components/schemas/uuid.NullUUID" - } - } - }, - "repo.EntityTypeUpdate": { - "type": "object", - "properties": { - "color": { - "type": "string" - }, - "description": { - "type": "string" - }, - "icon": { - "type": "string" - }, - "name": { - "type": "string", - "minLength": 1 - } - } - }, "repo.Group": { "type": "object", "properties": { @@ -4035,10 +3885,55 @@ } } }, + "repo.ItemAttachment": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "id": { + "type": "string" + }, + "mimeType": { + "type": "string" + }, + "path": { + "type": "string" + }, + "primary": { + "type": "boolean" + }, + "thumbnail": { + "$ref": "#/components/schemas/ent.Attachment" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemAttachmentUpdate": { + "type": "object", + "properties": { + "primary": { + "type": "boolean" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, "repo.ItemCreate": { "type": "object", "required": [ - "entityType", "name" ], "properties": { @@ -4046,9 +3941,6 @@ "type": "string", "maxLength": 1000 }, - "entityType": { - "type": "string" - }, "labelIds": { "type": "array", "items": { @@ -4109,7 +4001,7 @@ "attachments": { "type": "array", "items": { - "$ref": "#/components/schemas/repo.EntityAttachment" + "$ref": "#/components/schemas/repo.ItemAttachment" } }, "createdAt": { @@ -4118,9 +4010,6 @@ "description": { "type": "string" }, - "entityType": { - "type": "string" - }, "fields": { "type": "array", "items": { @@ -4284,9 +4173,6 @@ "description": { "type": "string" }, - "entityType": { - "type": "string" - }, "id": { "type": "string" }, @@ -4337,17 +4223,287 @@ } } }, + "repo.ItemTemplateCreate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "defaultDescription": { + "type": "string", + "maxLength": 1000, + "nullable": true + }, + "defaultInsured": { + "type": "boolean" + }, + "defaultLabelIds": { + "type": "array", + "items": { + "type": "string" + }, + "nullable": true + }, + "defaultLifetimeWarranty": { + "type": "boolean" + }, + "defaultLocationId": { + "description": "Default location and labels", + "type": "string", + "nullable": true + }, + "defaultManufacturer": { + "type": "string", + "maxLength": 255, + "nullable": true + }, + "defaultModelNumber": { + "type": "string", + "maxLength": 255, + "nullable": true + }, + "defaultName": { + "type": "string", + "maxLength": 255, + "nullable": true + }, + "defaultQuantity": { + "description": "Default values for items", + "type": "integer", + "nullable": true + }, + "defaultWarrantyDetails": { + "type": "string", + "maxLength": 1000, + "nullable": true + }, + "description": { + "type": "string", + "maxLength": 1000 + }, + "fields": { + "description": "Custom fields", + "type": "array", + "items": { + "$ref": "#/components/schemas/repo.TemplateField" + } + }, + "includePurchaseFields": { + "type": "boolean" + }, + "includeSoldFields": { + "type": "boolean" + }, + "includeWarrantyFields": { + "description": "Metadata flags", + "type": "boolean" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "notes": { + "type": "string", + "maxLength": 1000 + } + } + }, + "repo.ItemTemplateOut": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "defaultDescription": { + "type": "string" + }, + "defaultInsured": { + "type": "boolean" + }, + "defaultLabels": { + "type": "array", + "items": { + "$ref": "#/components/schemas/repo.TemplateLabelSummary" + } + }, + "defaultLifetimeWarranty": { + "type": "boolean" + }, + "defaultLocation": { + "description": "Default location and labels", + "allOf": [ + { + "$ref": "#/components/schemas/repo.TemplateLocationSummary" + } + ] + }, + "defaultManufacturer": { + "type": "string" + }, + "defaultModelNumber": { + "type": "string" + }, + "defaultName": { + "type": "string" + }, + "defaultQuantity": { + "description": "Default values for items", + "type": "integer" + }, + "defaultWarrantyDetails": { + "type": "string" + }, + "description": { + "type": "string" + }, + "fields": { + "description": "Custom fields", + "type": "array", + "items": { + "$ref": "#/components/schemas/repo.TemplateField" + } + }, + "id": { + "type": "string" + }, + "includePurchaseFields": { + "type": "boolean" + }, + "includeSoldFields": { + "type": "boolean" + }, + "includeWarrantyFields": { + "description": "Metadata flags", + "type": "boolean" + }, + "name": { + "type": "string" + }, + "notes": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemTemplateSummary": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemTemplateUpdate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "defaultDescription": { + "type": "string", + "maxLength": 1000, + "nullable": true + }, + "defaultInsured": { + "type": "boolean" + }, + "defaultLabelIds": { + "type": "array", + "items": { + "type": "string" + }, + "nullable": true + }, + "defaultLifetimeWarranty": { + "type": "boolean" + }, + "defaultLocationId": { + "description": "Default location and labels", + "type": "string", + "nullable": true + }, + "defaultManufacturer": { + "type": "string", + "maxLength": 255, + "nullable": true + }, + "defaultModelNumber": { + "type": "string", + "maxLength": 255, + "nullable": true + }, + "defaultName": { + "type": "string", + "maxLength": 255, + "nullable": true + }, + "defaultQuantity": { + "description": "Default values for items", + "type": "integer", + "nullable": true + }, + "defaultWarrantyDetails": { + "type": "string", + "maxLength": 1000, + "nullable": true + }, + "description": { + "type": "string", + "maxLength": 1000 + }, + "fields": { + "description": "Custom fields", + "type": "array", + "items": { + "$ref": "#/components/schemas/repo.TemplateField" + } + }, + "id": { + "type": "string" + }, + "includePurchaseFields": { + "type": "boolean" + }, + "includeSoldFields": { + "type": "boolean" + }, + "includeWarrantyFields": { + "description": "Metadata flags", + "type": "boolean" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "notes": { + "type": "string", + "maxLength": 1000 + } + } + }, "repo.ItemType": { "type": "string", "enum": [ - "location", - "item", "location", "item" ], "x-enum-varnames": [ - "EntityTypeLocation", - "EntityTypeItem", "ItemTypeLocation", "ItemTypeItem" ] @@ -4355,7 +4511,6 @@ "repo.ItemUpdate": { "type": "object", "required": [ - "entityType", "name" ], "properties": { @@ -4369,9 +4524,6 @@ "type": "string", "maxLength": 1000 }, - "entityType": { - "type": "string" - }, "fields": { "type": "array", "items": { @@ -4533,16 +4685,10 @@ }, "repo.LocationCreate": { "type": "object", - "required": [ - "entityType" - ], "properties": { "description": { "type": "string" }, - "entityType": { - "type": "string" - }, "name": { "type": "string" }, @@ -4567,9 +4713,6 @@ "description": { "type": "string" }, - "entityType": { - "type": "string" - }, "id": { "type": "string" }, @@ -4596,9 +4739,6 @@ "description": { "type": "string" }, - "entityType": { - "type": "string" - }, "id": { "type": "string" }, @@ -4622,9 +4762,6 @@ "description": { "type": "string" }, - "entityType": { - "type": "string" - }, "id": { "type": "string" }, @@ -4638,16 +4775,10 @@ }, "repo.LocationUpdate": { "type": "object", - "required": [ - "entityType" - ], "properties": { "description": { "type": "string" }, - "entityType": { - "type": "string" - }, "id": { "type": "string" }, @@ -4861,6 +4992,45 @@ } } }, + "repo.TemplateField": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "textValue": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.TemplateLabelSummary": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "repo.TemplateLocationSummary": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, "repo.TotalsByOrganizer": { "type": "object", "properties": { @@ -4918,6 +5088,12 @@ }, "name": { "type": "string" + }, + "oidcIssuer": { + "type": "string" + }, + "oidcSubject": { + "type": "string" } } }, @@ -4997,6 +5173,15 @@ } } }, + "templatefield.Type": { + "type": "string", + "enum": [ + "text" + ], + "x-enum-varnames": [ + "TypeText" + ] + }, "user.Role": { "type": "string", "enum": [ @@ -5010,18 +5195,6 @@ "RoleOwner" ] }, - "uuid.NullUUID": { - "type": "object", - "properties": { - "uuid": { - "type": "string" - }, - "valid": { - "description": "Valid is true if UUID is not NULL", - "type": "boolean" - } - } - }, "v1.APISummary": { "type": "object", "properties": { @@ -5046,6 +5219,9 @@ "message": { "type": "string" }, + "oidc": { + "$ref": "#/components/schemas/v1.OIDCStatus" + }, "title": { "type": "string" }, @@ -5128,6 +5304,36 @@ } } }, + "v1.ItemTemplateCreateItemRequest": { + "type": "object", + "required": [ + "locationId", + "name" + ], + "properties": { + "description": { + "type": "string", + "maxLength": 1000 + }, + "labelIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "locationId": { + "type": "string" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "quantity": { + "type": "integer" + } + } + }, "v1.LoginForm": { "type": "object", "properties": { @@ -5144,6 +5350,23 @@ } } }, + "v1.OIDCStatus": { + "type": "object", + "properties": { + "allowLocal": { + "type": "boolean" + }, + "autoRedirect": { + "type": "boolean" + }, + "buttonText": { + "type": "string" + }, + "enabled": { + "type": "boolean" + } + } + }, "v1.TokenResponse": { "type": "object", "properties": { diff --git a/docs/en/api/openapi-3.0.yaml b/docs/en/api/openapi-3.0.yaml index baf6ad7f..0a6d2042 100644 --- a/docs/en/api/openapi-3.0.yaml +++ b/docs/en/api/openapi-3.0.yaml @@ -115,276 +115,6 @@ paths: application/json: schema: $ref: "#/components/schemas/currencies.Currency" - "/v1/entities/{id}/attachments": - post: - security: - - Bearer: [] - tags: - - Items Attachments - summary: Create Item Attachment - parameters: - - description: Item ID - name: id - in: path - required: true - schema: - type: string - requestBody: - $ref: "#/components/requestBodies/postV1Entities_id_attachments" - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/repo.ItemOut" - "422": - description: Unprocessable Entity - content: - application/json: - schema: - $ref: "#/components/schemas/validate.ErrorResponse" - "/v1/entities/{id}/attachments/{attachment_id}": - get: - security: - - Bearer: [] - tags: - - Items Attachments - summary: Get Item Attachment - parameters: - - description: Item ID - name: id - in: path - required: true - schema: - type: string - - description: Attachment ID - name: attachment_id - in: path - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/octet-stream: - schema: - $ref: "#/components/schemas/v1.ItemAttachmentToken" - put: - security: - - Bearer: [] - tags: - - Items Attachments - summary: Update Item Attachment - parameters: - - description: Item ID - name: id - in: path - required: true - schema: - type: string - - description: Attachment ID - name: attachment_id - in: path - required: true - schema: - type: string - requestBody: - $ref: "#/components/requestBodies/repo.EntityAttachmentUpdate" - responses: - "200": - description: OK - content: - "*/*": - schema: - $ref: "#/components/schemas/repo.ItemOut" - delete: - security: - - Bearer: [] - tags: - - Items Attachments - summary: Delete Item Attachment - parameters: - - description: Item ID - name: id - in: path - required: true - schema: - type: string - - description: Attachment ID - name: attachment_id - in: path - required: true - schema: - type: string - responses: - "204": - description: No Content - "/v1/entities/{id}/maintenance": - get: - security: - - Bearer: [] - tags: - - Item Maintenance - summary: Get Maintenance Log - parameters: - - description: Item ID - name: id - in: path - required: true - schema: - type: string - - x-enum-varnames: - - MaintenanceFilterStatusScheduled - - MaintenanceFilterStatusCompleted - - MaintenanceFilterStatusBoth - name: status - in: query - schema: - type: string - enum: - - scheduled - - completed - - both - responses: - "200": - description: OK - content: - application/json: - schema: - type: array - items: - $ref: "#/components/schemas/repo.MaintenanceEntryWithDetails" - post: - security: - - Bearer: [] - tags: - - Item Maintenance - summary: Create Maintenance Entry - parameters: - - description: Item ID - name: id - in: path - required: true - schema: - type: string - requestBody: - $ref: "#/components/requestBodies/repo.MaintenanceEntryCreate" - responses: - "201": - description: Created - content: - application/json: - schema: - $ref: "#/components/schemas/repo.MaintenanceEntry" - /v1/entitytype: - get: - security: - - Bearer: [] - tags: - - EntityTypes - summary: Query All Entity Types - responses: - "200": - description: OK - content: - application/json: - schema: - type: array - items: - $ref: "#/components/schemas/repo.EntityType" - post: - security: - - Bearer: [] - tags: - - EntityTypes - summary: Create Entity Type - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/repo.EntityTypeCreate" - description: Entity Type Data - required: true - responses: - "201": - description: Created - content: - application/json: - schema: - $ref: "#/components/schemas/repo.EntityType" - "/v1/entitytype/{id}": - get: - security: - - Bearer: [] - tags: - - EntityTypes - summary: Get One Entity Type - parameters: - - description: Entity Type ID - name: id - in: path - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/repo.EntityType" - put: - security: - - Bearer: [] - tags: - - EntityTypes - summary: Update Entity Type - parameters: - - description: Entity Type ID - name: id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/repo.EntityTypeUpdate" - description: Entity Type Data - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/repo.EntityType" - delete: - security: - - Bearer: [] - tags: - - EntityTypes - summary: Delete Entity Type - parameters: - - description: Entity Type ID - name: id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/repo.EntityTypeDelete" - description: Entity Type Delete Options - required: true - responses: - "204": - description: No Content /v1/groups: get: security: @@ -517,8 +247,7 @@ paths: - Bearer: [] tags: - Items - summary: (Deprecated) Query All Items - deprecated: true + summary: Query All Items parameters: - description: search string name: q @@ -572,7 +301,6 @@ paths: tags: - Items summary: Create Item - deprecated: true requestBody: content: application/json: @@ -593,8 +321,7 @@ paths: - Bearer: [] tags: - Items - summary: (Deprecated) Export Items - deprecated: true + summary: Export Items responses: "200": description: text/csv @@ -608,8 +335,7 @@ paths: - Bearer: [] tags: - Items - summary: (Deprecated) Get All Custom Field Names - deprecated: true + summary: Get All Custom Field Names responses: "200": description: OK @@ -625,8 +351,7 @@ paths: - Bearer: [] tags: - Items - summary: (Deprecated) Get All Custom Field Values - deprecated: true + summary: Get All Custom Field Values responses: "200": description: OK @@ -642,8 +367,7 @@ paths: - Bearer: [] tags: - Items - summary: (Deprecated) Import Items - deprecated: true + summary: Import Items requestBody: content: multipart/form-data: @@ -666,8 +390,7 @@ paths: - Bearer: [] tags: - Items - summary: (Deprecated) Get Item - deprecated: true + summary: Get Item parameters: - description: Item ID name: id @@ -687,8 +410,7 @@ paths: - Bearer: [] tags: - Items - summary: (Deprecated) Update Item - deprecated: true + summary: Update Item parameters: - description: Item ID name: id @@ -715,8 +437,7 @@ paths: - Bearer: [] tags: - Items - summary: (Deprecated) Delete Item - deprecated: true + summary: Delete Item parameters: - description: Item ID name: id @@ -732,8 +453,7 @@ paths: - Bearer: [] tags: - Items - summary: (Deprecated) Update Item - deprecated: true + summary: Update Item parameters: - description: Item ID name: id @@ -762,7 +482,6 @@ paths: tags: - Items Attachments summary: Create Item Attachment - deprecated: true parameters: - description: Item ID name: id @@ -771,7 +490,28 @@ paths: schema: type: string requestBody: - $ref: "#/components/requestBodies/postV1Entities_id_attachments" + content: + multipart/form-data: + schema: + type: object + properties: + file: + description: File attachment + type: string + format: binary + type: + description: Type of file + type: string + primary: + description: Is this the primary attachment + type: boolean + name: + description: name of the file including extension + type: string + required: + - file + - name + required: true responses: "200": description: OK @@ -792,7 +532,6 @@ paths: tags: - Items Attachments summary: Get Item Attachment - deprecated: true parameters: - description: Item ID name: id @@ -819,7 +558,6 @@ paths: tags: - Items Attachments summary: Update Item Attachment - deprecated: true parameters: - description: Item ID name: id @@ -834,7 +572,12 @@ paths: schema: type: string requestBody: - $ref: "#/components/requestBodies/repo.EntityAttachmentUpdate" + content: + application/json: + schema: + $ref: "#/components/schemas/repo.ItemAttachmentUpdate" + description: Attachment Update + required: true responses: "200": description: OK @@ -848,7 +591,6 @@ paths: tags: - Items Attachments summary: Delete Item Attachment - deprecated: true parameters: - description: Item ID name: id @@ -900,7 +642,6 @@ paths: tags: - Item Maintenance summary: Get Maintenance Log - deprecated: true parameters: - description: Item ID name: id @@ -935,7 +676,6 @@ paths: tags: - Item Maintenance summary: Create Maintenance Entry - deprecated: true parameters: - description: Item ID name: id @@ -944,7 +684,12 @@ paths: schema: type: string requestBody: - $ref: "#/components/requestBodies/repo.MaintenanceEntryCreate" + content: + application/json: + schema: + $ref: "#/components/schemas/repo.MaintenanceEntryCreate" + description: Entry Data + required: true responses: "201": description: Created @@ -958,8 +703,7 @@ paths: - Bearer: [] tags: - Items - summary: (Deprecated) Get the full path of an item - deprecated: true + summary: Get the full path of an item parameters: - description: Item ID name: id @@ -1153,8 +897,7 @@ paths: - Bearer: [] tags: - Locations - summary: (Deprecated) Get All Locations - deprecated: true + summary: Get All Locations parameters: - description: Filter locations with parents name: filterChildren @@ -1175,8 +918,7 @@ paths: - Bearer: [] tags: - Locations - summary: (Deprecated) Create Location - deprecated: true + summary: Create Location requestBody: content: application/json: @@ -1197,8 +939,7 @@ paths: - Bearer: [] tags: - Locations - summary: (Deprecated) Get Locations Tree - deprecated: true + summary: Get Locations Tree parameters: - description: include items in response tree name: withItems @@ -1220,8 +961,7 @@ paths: - Bearer: [] tags: - Locations - summary: (Deprecated) Get Location - deprecated: true + summary: Get Location parameters: - description: Location ID name: id @@ -1241,8 +981,7 @@ paths: - Bearer: [] tags: - Locations - summary: (Deprecated) Update Location - deprecated: true + summary: Update Location parameters: - description: Location ID name: id @@ -1269,8 +1008,7 @@ paths: - Bearer: [] tags: - Locations - summary: (Deprecated) Delete Location - deprecated: true + summary: Delete Location parameters: - description: Location ID name: id @@ -1519,6 +1257,134 @@ paths: application/json: schema: $ref: "#/components/schemas/v1.APISummary" + /v1/templates: + get: + security: + - Bearer: [] + tags: + - Item Templates + summary: Get All Item Templates + responses: + "200": + description: OK + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/repo.ItemTemplateSummary" + post: + security: + - Bearer: [] + tags: + - Item Templates + summary: Create Item Template + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/repo.ItemTemplateCreate" + description: Template Data + required: true + responses: + "201": + description: Created + content: + application/json: + schema: + $ref: "#/components/schemas/repo.ItemTemplateOut" + "/v1/templates/{id}": + get: + security: + - Bearer: [] + tags: + - Item Templates + summary: Get Item Template + parameters: + - description: Template ID + name: id + in: path + required: true + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/repo.ItemTemplateOut" + put: + security: + - Bearer: [] + tags: + - Item Templates + summary: Update Item Template + parameters: + - description: Template ID + name: id + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/repo.ItemTemplateUpdate" + description: Template Data + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/repo.ItemTemplateOut" + delete: + security: + - Bearer: [] + tags: + - Item Templates + summary: Delete Item Template + parameters: + - description: Template ID + name: id + in: path + required: true + schema: + type: string + responses: + "204": + description: No Content + "/v1/templates/{id}/create-item": + post: + security: + - Bearer: [] + tags: + - Item Templates + summary: Create Item from Template + parameters: + - description: Template ID + name: id + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/v1.ItemTemplateCreateItemRequest" + description: Item Data + required: true + responses: + "201": + description: Created + content: + application/json: + schema: + $ref: "#/components/schemas/repo.ItemOut" /v1/users/change-password: put: security: @@ -1564,6 +1430,35 @@ paths: application/json: schema: $ref: "#/components/schemas/v1.TokenResponse" + /v1/users/login/oidc: + get: + tags: + - Authentication + summary: OIDC Login Initiation + responses: + "302": + description: Found + /v1/users/login/oidc/callback: + get: + tags: + - Authentication + summary: OIDC Callback Handler + parameters: + - description: Authorization code + name: code + in: query + required: true + schema: + type: string + - description: State parameter + name: state + in: query + required: true + schema: + type: string + responses: + "302": + description: Found /v1/users/logout: post: security: @@ -1604,6 +1499,12 @@ paths: responses: "204": description: No Content + "403": + description: Local login is not enabled + content: + application/json: + schema: + type: string /v1/users/self: get: security: @@ -1661,44 +1562,6 @@ servers: - url: https://demo.homebox.software/api - url: http://demo.homebox.software/api components: - requestBodies: - postV1Entities_id_attachments: - content: - multipart/form-data: - schema: - type: object - properties: - file: - description: File attachment - type: string - format: binary - type: - description: Type of file - type: string - primary: - description: Is this the primary attachment - type: boolean - name: - description: name of the file including extension - type: string - required: - - file - - name - required: true - repo.MaintenanceEntryCreate: - content: - application/json: - schema: - $ref: "#/components/schemas/repo.MaintenanceEntryCreate" - description: Entry Data - required: true - repo.EntityAttachmentUpdate: - content: - application/json: - schema: - $ref: "#/components/schemas/repo.EntityAttachmentUpdate" - description: Attachment Update - required: true securitySchemes: Bearer: description: "\"Type 'Bearer TOKEN' to correctly set the API Key\"" @@ -1787,10 +1650,10 @@ components: ent.AttachmentEdges: type: object properties: - entity: - description: Entity holds the value of the entity edge. + item: + description: Item holds the value of the item edge. allOf: - - $ref: "#/components/schemas/ent.Entity" + - $ref: "#/components/schemas/ent.Item" thumbnail: description: Thumbnail holds the value of the thumbnail edge. allOf: @@ -1857,7 +1720,107 @@ components: description: User holds the value of the user edge. allOf: - $ref: "#/components/schemas/ent.User" - ent.Entity: + ent.Group: + type: object + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + currency: + description: Currency holds the value of the "currency" field. + type: string + edges: + description: >- + Edges holds the relations/edges for other nodes in the graph. + + The values are being populated by the GroupQuery when eager-loading is set. + allOf: + - $ref: "#/components/schemas/ent.GroupEdges" + id: + description: ID of the ent. + type: string + name: + description: Name holds the value of the "name" field. + type: string + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + ent.GroupEdges: + type: object + properties: + invitation_tokens: + description: InvitationTokens holds the value of the invitation_tokens edge. + type: array + items: + $ref: "#/components/schemas/ent.GroupInvitationToken" + item_templates: + description: ItemTemplates holds the value of the item_templates edge. + type: array + items: + $ref: "#/components/schemas/ent.ItemTemplate" + items: + description: Items holds the value of the items edge. + type: array + items: + $ref: "#/components/schemas/ent.Item" + labels: + description: Labels holds the value of the labels edge. + type: array + items: + $ref: "#/components/schemas/ent.Label" + locations: + description: Locations holds the value of the locations edge. + type: array + items: + $ref: "#/components/schemas/ent.Location" + notifiers: + description: Notifiers holds the value of the notifiers edge. + type: array + items: + $ref: "#/components/schemas/ent.Notifier" + users: + description: Users holds the value of the users edge. + type: array + items: + $ref: "#/components/schemas/ent.User" + ent.GroupInvitationToken: + type: object + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + edges: + description: >- + Edges holds the relations/edges for other nodes in the graph. + + The values are being populated by the GroupInvitationTokenQuery when eager-loading is set. + allOf: + - $ref: "#/components/schemas/ent.GroupInvitationTokenEdges" + expires_at: + description: ExpiresAt holds the value of the "expires_at" field. + type: string + id: + description: ID of the ent. + type: string + token: + description: Token holds the value of the "token" field. + type: array + items: + type: integer + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + uses: + description: Uses holds the value of the "uses" field. + type: integer + ent.GroupInvitationTokenEdges: + type: object + properties: + group: + description: Group holds the value of the group edge. + allOf: + - $ref: "#/components/schemas/ent.Group" + ent.Item: type: object properties: archived: @@ -1876,9 +1839,9 @@ components: description: >- Edges holds the relations/edges for other nodes in the graph. - The values are being populated by the EntityQuery when eager-loading is set. + The values are being populated by the ItemQuery when eager-loading is set. allOf: - - $ref: "#/components/schemas/ent.EntityEdges" + - $ref: "#/components/schemas/ent.ItemEdges" id: description: ID of the ent. type: string @@ -1930,9 +1893,9 @@ components: sold_to: description: SoldTo holds the value of the "sold_to" field. type: string - sync_child_entities_locations: - description: SyncChildEntitiesLocations holds the value of the - "sync_child_entities_locations" field. + sync_child_items_locations: + description: SyncChildItemsLocations holds the value of the + "sync_child_items_locations" field. type: boolean updated_at: description: UpdatedAt holds the value of the "updated_at" field. @@ -1943,7 +1906,7 @@ components: warranty_expires: description: WarrantyExpires holds the value of the "warranty_expires" field. type: string - ent.EntityEdges: + ent.ItemEdges: type: object properties: attachments: @@ -1955,17 +1918,12 @@ components: description: Children holds the value of the children edge. type: array items: - $ref: "#/components/schemas/ent.Entity" - entity: - description: Entity holds the value of the entity edge. - type: array - items: - $ref: "#/components/schemas/ent.Entity" + $ref: "#/components/schemas/ent.Item" fields: description: Fields holds the value of the fields edge. type: array items: - $ref: "#/components/schemas/ent.EntityField" + $ref: "#/components/schemas/ent.ItemField" group: description: Group holds the value of the group edge. allOf: @@ -1978,7 +1936,7 @@ components: location: description: Location holds the value of the location edge. allOf: - - $ref: "#/components/schemas/ent.Entity" + - $ref: "#/components/schemas/ent.Location" maintenance_entries: description: MaintenanceEntries holds the value of the maintenance_entries edge. type: array @@ -1987,12 +1945,8 @@ components: parent: description: Parent holds the value of the parent edge. allOf: - - $ref: "#/components/schemas/ent.Entity" - type: - description: Type holds the value of the type edge. - allOf: - - $ref: "#/components/schemas/ent.EntityType" - ent.EntityField: + - $ref: "#/components/schemas/ent.Item" + ent.ItemField: type: object properties: boolean_value: @@ -2008,9 +1962,9 @@ components: description: >- Edges holds the relations/edges for other nodes in the graph. - The values are being populated by the EntityFieldQuery when eager-loading is set. + The values are being populated by the ItemFieldQuery when eager-loading is set. allOf: - - $ref: "#/components/schemas/ent.EntityFieldEdges" + - $ref: "#/components/schemas/ent.ItemFieldEdges" id: description: ID of the ent. type: string @@ -2029,26 +1983,55 @@ components: type: description: Type holds the value of the "type" field. allOf: - - $ref: "#/components/schemas/entityfield.Type" + - $ref: "#/components/schemas/itemfield.Type" updated_at: description: UpdatedAt holds the value of the "updated_at" field. type: string - ent.EntityFieldEdges: + ent.ItemFieldEdges: type: object properties: - entity: - description: Entity holds the value of the entity edge. + item: + description: Item holds the value of the item edge. allOf: - - $ref: "#/components/schemas/ent.Entity" - ent.EntityType: + - $ref: "#/components/schemas/ent.Item" + ent.ItemTemplate: type: object properties: - color: - description: Color holds the value of the "color" field. - type: string created_at: description: CreatedAt holds the value of the "created_at" field. type: string + default_description: + description: Default description for items created from this template + type: string + default_insured: + description: DefaultInsured holds the value of the "default_insured" field. + type: boolean + default_label_ids: + description: Default label IDs for items created from this template + type: array + items: + type: string + default_lifetime_warranty: + description: DefaultLifetimeWarranty holds the value of the + "default_lifetime_warranty" field. + type: boolean + default_manufacturer: + description: DefaultManufacturer holds the value of the "default_manufacturer" + field. + type: string + default_model_number: + description: Default model number for items created from this template + type: string + default_name: + description: Default name template for items (can use placeholders) + type: string + default_quantity: + description: DefaultQuantity holds the value of the "default_quantity" field. + type: integer + default_warranty_details: + description: DefaultWarrantyDetails holds the value of the + "default_warranty_details" field. + type: string description: description: Description holds the value of the "description" field. type: string @@ -2056,131 +2039,48 @@ components: description: >- Edges holds the relations/edges for other nodes in the graph. - The values are being populated by the EntityTypeQuery when eager-loading is set. + The values are being populated by the ItemTemplateQuery when eager-loading is set. allOf: - - $ref: "#/components/schemas/ent.EntityTypeEdges" - icon: - description: Icon holds the value of the "icon" field. - type: string + - $ref: "#/components/schemas/ent.ItemTemplateEdges" id: description: ID of the ent. type: string - is_location: - description: IsLocation holds the value of the "is_location" field. + include_purchase_fields: + description: Whether to include purchase fields in items created from this + template + type: boolean + include_sold_fields: + description: Whether to include sold fields in items created from this template + type: boolean + include_warranty_fields: + description: Whether to include warranty fields in items created from this + template type: boolean name: description: Name holds the value of the "name" field. type: string + notes: + description: Notes holds the value of the "notes" field. + type: string updated_at: description: UpdatedAt holds the value of the "updated_at" field. type: string - ent.EntityTypeEdges: + ent.ItemTemplateEdges: type: object properties: - entities: - description: Entities holds the value of the entities edge. + fields: + description: Fields holds the value of the fields edge. type: array items: - $ref: "#/components/schemas/ent.Entity" + $ref: "#/components/schemas/ent.TemplateField" group: description: Group holds the value of the group edge. allOf: - $ref: "#/components/schemas/ent.Group" - ent.Group: - type: object - properties: - created_at: - description: CreatedAt holds the value of the "created_at" field. - type: string - currency: - description: Currency holds the value of the "currency" field. - type: string - edges: - description: >- - Edges holds the relations/edges for other nodes in the graph. - - The values are being populated by the GroupQuery when eager-loading is set. + location: + description: Location holds the value of the location edge. allOf: - - $ref: "#/components/schemas/ent.GroupEdges" - id: - description: ID of the ent. - type: string - name: - description: Name holds the value of the "name" field. - type: string - updated_at: - description: UpdatedAt holds the value of the "updated_at" field. - type: string - ent.GroupEdges: - type: object - properties: - entities: - description: Entities holds the value of the entities edge. - type: array - items: - $ref: "#/components/schemas/ent.Entity" - entity_types: - description: EntityTypes holds the value of the entity_types edge. - type: array - items: - $ref: "#/components/schemas/ent.EntityType" - invitation_tokens: - description: InvitationTokens holds the value of the invitation_tokens edge. - type: array - items: - $ref: "#/components/schemas/ent.GroupInvitationToken" - labels: - description: Labels holds the value of the labels edge. - type: array - items: - $ref: "#/components/schemas/ent.Label" - notifiers: - description: Notifiers holds the value of the notifiers edge. - type: array - items: - $ref: "#/components/schemas/ent.Notifier" - users: - description: Users holds the value of the users edge. - type: array - items: - $ref: "#/components/schemas/ent.User" - ent.GroupInvitationToken: - type: object - properties: - created_at: - description: CreatedAt holds the value of the "created_at" field. - type: string - edges: - description: >- - Edges holds the relations/edges for other nodes in the graph. - - The values are being populated by the GroupInvitationTokenQuery when eager-loading is set. - allOf: - - $ref: "#/components/schemas/ent.GroupInvitationTokenEdges" - expires_at: - description: ExpiresAt holds the value of the "expires_at" field. - type: string - id: - description: ID of the ent. - type: string - token: - description: Token holds the value of the "token" field. - type: array - items: - type: integer - updated_at: - description: UpdatedAt holds the value of the "updated_at" field. - type: string - uses: - description: Uses holds the value of the "uses" field. - type: integer - ent.GroupInvitationTokenEdges: - type: object - properties: - group: - description: Group holds the value of the group edge. - allOf: - - $ref: "#/components/schemas/ent.Group" + - $ref: "#/components/schemas/ent.Location" ent.Label: type: object properties: @@ -2212,15 +2112,61 @@ components: ent.LabelEdges: type: object properties: - entities: - description: Entities holds the value of the entities edge. - type: array - items: - $ref: "#/components/schemas/ent.Entity" group: description: Group holds the value of the group edge. allOf: - $ref: "#/components/schemas/ent.Group" + items: + description: Items holds the value of the items edge. + type: array + items: + $ref: "#/components/schemas/ent.Item" + ent.Location: + type: object + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + description: + description: Description holds the value of the "description" field. + type: string + edges: + description: >- + Edges holds the relations/edges for other nodes in the graph. + + The values are being populated by the LocationQuery when eager-loading is set. + allOf: + - $ref: "#/components/schemas/ent.LocationEdges" + id: + description: ID of the ent. + type: string + name: + description: Name holds the value of the "name" field. + type: string + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + ent.LocationEdges: + type: object + properties: + children: + description: Children holds the value of the children edge. + type: array + items: + $ref: "#/components/schemas/ent.Location" + group: + description: Group holds the value of the group edge. + allOf: + - $ref: "#/components/schemas/ent.Group" + items: + description: Items holds the value of the items edge. + type: array + items: + $ref: "#/components/schemas/ent.Item" + parent: + description: Parent holds the value of the parent edge. + allOf: + - $ref: "#/components/schemas/ent.Location" ent.MaintenanceEntry: type: object properties: @@ -2243,12 +2189,12 @@ components: The values are being populated by the MaintenanceEntryQuery when eager-loading is set. allOf: - $ref: "#/components/schemas/ent.MaintenanceEntryEdges" - entity_id: - description: EntityID holds the value of the "entity_id" field. - type: string id: description: ID of the ent. type: string + item_id: + description: ItemID holds the value of the "item_id" field. + type: string name: description: Name holds the value of the "name" field. type: string @@ -2261,10 +2207,10 @@ components: ent.MaintenanceEntryEdges: type: object properties: - entity: - description: Entity holds the value of the entity edge. + item: + description: Item holds the value of the item edge. allOf: - - $ref: "#/components/schemas/ent.Entity" + - $ref: "#/components/schemas/ent.Item" ent.Notifier: type: object properties: @@ -2307,6 +2253,45 @@ components: description: User holds the value of the user edge. allOf: - $ref: "#/components/schemas/ent.User" + ent.TemplateField: + type: object + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + description: + description: Description holds the value of the "description" field. + type: string + edges: + description: >- + Edges holds the relations/edges for other nodes in the graph. + + The values are being populated by the TemplateFieldQuery when eager-loading is set. + allOf: + - $ref: "#/components/schemas/ent.TemplateFieldEdges" + id: + description: ID of the ent. + type: string + name: + description: Name holds the value of the "name" field. + type: string + text_value: + description: TextValue holds the value of the "text_value" field. + type: string + type: + description: Type holds the value of the "type" field. + allOf: + - $ref: "#/components/schemas/templatefield.Type" + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + ent.TemplateFieldEdges: + type: object + properties: + item_template: + description: ItemTemplate holds the value of the item_template edge. + allOf: + - $ref: "#/components/schemas/ent.ItemTemplate" ent.User: type: object properties: @@ -2335,6 +2320,12 @@ components: name: description: Name holds the value of the "name" field. type: string + oidc_issuer: + description: OidcIssuer holds the value of the "oidc_issuer" field. + type: string + oidc_subject: + description: OidcSubject holds the value of the "oidc_subject" field. + type: string role: description: Role holds the value of the "role" field. allOf: @@ -2362,7 +2353,7 @@ components: type: array items: $ref: "#/components/schemas/ent.Notifier" - entityfield.Type: + itemfield.Type: type: string enum: - text @@ -2406,82 +2397,6 @@ components: type: boolean copyPrefix: type: string - repo.EntityAttachment: - type: object - properties: - createdAt: - type: string - id: - type: string - mimeType: - type: string - path: - type: string - primary: - type: boolean - thumbnail: - $ref: "#/components/schemas/ent.Attachment" - title: - type: string - type: - type: string - updatedAt: - type: string - repo.EntityAttachmentUpdate: - type: object - properties: - primary: - type: boolean - title: - type: string - type: - type: string - repo.EntityType: - type: object - properties: - color: - type: string - description: - type: string - icon: - type: string - isLocation: - type: boolean - name: - type: string - repo.EntityTypeCreate: - type: object - required: - - isLocation - - name - properties: - color: - type: string - description: - type: string - icon: - type: string - isLocation: - type: boolean - name: - type: string - repo.EntityTypeDelete: - type: object - properties: - replacementId: - $ref: "#/components/schemas/uuid.NullUUID" - repo.EntityTypeUpdate: - type: object - properties: - color: - type: string - description: - type: string - icon: - type: string - name: - type: string - minLength: 1 repo.Group: type: object properties: @@ -2517,17 +2432,44 @@ components: type: string name: type: string + repo.ItemAttachment: + type: object + properties: + createdAt: + type: string + id: + type: string + mimeType: + type: string + path: + type: string + primary: + type: boolean + thumbnail: + $ref: "#/components/schemas/ent.Attachment" + title: + type: string + type: + type: string + updatedAt: + type: string + repo.ItemAttachmentUpdate: + type: object + properties: + primary: + type: boolean + title: + type: string + type: + type: string repo.ItemCreate: type: object required: - - entityType - name properties: description: type: string maxLength: 1000 - entityType: - type: string labelIds: type: array items: @@ -2570,13 +2512,11 @@ components: attachments: type: array items: - $ref: "#/components/schemas/repo.EntityAttachment" + $ref: "#/components/schemas/repo.ItemAttachment" createdAt: type: string description: type: string - entityType: - type: string fields: type: array items: @@ -2688,8 +2628,6 @@ components: type: string description: type: string - entityType: - type: string id: type: string imageId: @@ -2723,22 +2661,212 @@ components: nullable: true updatedAt: type: string + repo.ItemTemplateCreate: + type: object + required: + - name + properties: + defaultDescription: + type: string + maxLength: 1000 + nullable: true + defaultInsured: + type: boolean + defaultLabelIds: + type: array + items: + type: string + nullable: true + defaultLifetimeWarranty: + type: boolean + defaultLocationId: + description: Default location and labels + type: string + nullable: true + defaultManufacturer: + type: string + maxLength: 255 + nullable: true + defaultModelNumber: + type: string + maxLength: 255 + nullable: true + defaultName: + type: string + maxLength: 255 + nullable: true + defaultQuantity: + description: Default values for items + type: integer + nullable: true + defaultWarrantyDetails: + type: string + maxLength: 1000 + nullable: true + description: + type: string + maxLength: 1000 + fields: + description: Custom fields + type: array + items: + $ref: "#/components/schemas/repo.TemplateField" + includePurchaseFields: + type: boolean + includeSoldFields: + type: boolean + includeWarrantyFields: + description: Metadata flags + type: boolean + name: + type: string + maxLength: 255 + minLength: 1 + notes: + type: string + maxLength: 1000 + repo.ItemTemplateOut: + type: object + properties: + createdAt: + type: string + defaultDescription: + type: string + defaultInsured: + type: boolean + defaultLabels: + type: array + items: + $ref: "#/components/schemas/repo.TemplateLabelSummary" + defaultLifetimeWarranty: + type: boolean + defaultLocation: + description: Default location and labels + allOf: + - $ref: "#/components/schemas/repo.TemplateLocationSummary" + defaultManufacturer: + type: string + defaultModelNumber: + type: string + defaultName: + type: string + defaultQuantity: + description: Default values for items + type: integer + defaultWarrantyDetails: + type: string + description: + type: string + fields: + description: Custom fields + type: array + items: + $ref: "#/components/schemas/repo.TemplateField" + id: + type: string + includePurchaseFields: + type: boolean + includeSoldFields: + type: boolean + includeWarrantyFields: + description: Metadata flags + type: boolean + name: + type: string + notes: + type: string + updatedAt: + type: string + repo.ItemTemplateSummary: + type: object + properties: + createdAt: + type: string + description: + type: string + id: + type: string + name: + type: string + updatedAt: + type: string + repo.ItemTemplateUpdate: + type: object + required: + - name + properties: + defaultDescription: + type: string + maxLength: 1000 + nullable: true + defaultInsured: + type: boolean + defaultLabelIds: + type: array + items: + type: string + nullable: true + defaultLifetimeWarranty: + type: boolean + defaultLocationId: + description: Default location and labels + type: string + nullable: true + defaultManufacturer: + type: string + maxLength: 255 + nullable: true + defaultModelNumber: + type: string + maxLength: 255 + nullable: true + defaultName: + type: string + maxLength: 255 + nullable: true + defaultQuantity: + description: Default values for items + type: integer + nullable: true + defaultWarrantyDetails: + type: string + maxLength: 1000 + nullable: true + description: + type: string + maxLength: 1000 + fields: + description: Custom fields + type: array + items: + $ref: "#/components/schemas/repo.TemplateField" + id: + type: string + includePurchaseFields: + type: boolean + includeSoldFields: + type: boolean + includeWarrantyFields: + description: Metadata flags + type: boolean + name: + type: string + maxLength: 255 + minLength: 1 + notes: + type: string + maxLength: 1000 repo.ItemType: type: string enum: - location - item - - location - - item x-enum-varnames: - - EntityTypeLocation - - EntityTypeItem - ItemTypeLocation - ItemTypeItem repo.ItemUpdate: type: object required: - - entityType - name properties: archived: @@ -2748,8 +2876,6 @@ components: description: type: string maxLength: 1000 - entityType: - type: string fields: type: array items: @@ -2862,13 +2988,9 @@ components: type: string repo.LocationCreate: type: object - required: - - entityType properties: description: type: string - entityType: - type: string name: type: string parentId: @@ -2885,8 +3007,6 @@ components: type: string description: type: string - entityType: - type: string id: type: string name: @@ -2904,8 +3024,6 @@ components: type: string description: type: string - entityType: - type: string id: type: string itemCount: @@ -2921,8 +3039,6 @@ components: type: string description: type: string - entityType: - type: string id: type: string name: @@ -2931,13 +3047,9 @@ components: type: string repo.LocationUpdate: type: object - required: - - entityType properties: description: type: string - entityType: - type: string id: type: string name: @@ -3081,6 +3193,31 @@ components: type: integer total: type: integer + repo.TemplateField: + type: object + properties: + id: + type: string + name: + type: string + textValue: + type: string + type: + type: string + repo.TemplateLabelSummary: + type: object + properties: + id: + type: string + name: + type: string + repo.TemplateLocationSummary: + type: object + properties: + id: + type: string + name: + type: string repo.TotalsByOrganizer: type: object properties: @@ -3120,6 +3257,10 @@ components: type: boolean name: type: string + oidcIssuer: + type: string + oidcSubject: + type: string repo.UserUpdate: type: object properties: @@ -3169,6 +3310,12 @@ components: type: string token: type: string + templatefield.Type: + type: string + enum: + - text + x-enum-varnames: + - TypeText user.Role: type: string enum: @@ -3179,14 +3326,6 @@ components: - DefaultRole - RoleUser - RoleOwner - uuid.NullUUID: - type: object - properties: - uuid: - type: string - valid: - description: Valid is true if UUID is not NULL - type: boolean v1.APISummary: type: object properties: @@ -3204,6 +3343,8 @@ components: $ref: "#/components/schemas/services.Latest" message: type: string + oidc: + $ref: "#/components/schemas/v1.OIDCStatus" title: type: string versions: @@ -3256,6 +3397,27 @@ components: properties: token: type: string + v1.ItemTemplateCreateItemRequest: + type: object + required: + - locationId + - name + properties: + description: + type: string + maxLength: 1000 + labelIds: + type: array + items: + type: string + locationId: + type: string + name: + type: string + maxLength: 255 + minLength: 1 + quantity: + type: integer v1.LoginForm: type: object properties: @@ -3267,6 +3429,17 @@ components: username: type: string example: admin@admin.com + v1.OIDCStatus: + type: object + properties: + allowLocal: + type: boolean + autoRedirect: + type: boolean + buttonText: + type: string + enabled: + type: boolean v1.TokenResponse: type: object properties: diff --git a/docs/en/api/swagger-2.0.json b/docs/en/api/swagger-2.0.json index ff53834e..61b8612a 100644 --- a/docs/en/api/swagger-2.0.json +++ b/docs/en/api/swagger-2.0.json @@ -1 +1,5211 @@ -{"schemes":["https","http"],"swagger":"2.0","info":{"description":"Track, Manage, and Organize your Things.","title":"Homebox API","contact":{"name":"Homebox Team","url":"https://discord.homebox.software"},"version":"1.0"},"host":"demo.homebox.software","basePath":"/api","paths":{"/v1/actions/create-missing-thumbnails":{"post":{"security":[{"Bearer":[]}],"description":"Creates thumbnails for items that are missing them","produces":["application/json"],"tags":["Actions"],"summary":"Create Missing Thumbnails","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.ActionAmountResult"}}}}},"/v1/actions/ensure-asset-ids":{"post":{"security":[{"Bearer":[]}],"description":"Ensures all items in the database have an asset ID","produces":["application/json"],"tags":["Actions"],"summary":"Ensure Asset IDs","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.ActionAmountResult"}}}}},"/v1/actions/ensure-import-refs":{"post":{"security":[{"Bearer":[]}],"description":"Ensures all items in the database have an import ref","produces":["application/json"],"tags":["Actions"],"summary":"Ensures Import Refs","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.ActionAmountResult"}}}}},"/v1/actions/set-primary-photos":{"post":{"security":[{"Bearer":[]}],"description":"Sets the first photo of each item as the primary photo","produces":["application/json"],"tags":["Actions"],"summary":"Set Primary Photos","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.ActionAmountResult"}}}}},"/v1/actions/zero-item-time-fields":{"post":{"security":[{"Bearer":[]}],"description":"Resets all item date fields to the beginning of the day","produces":["application/json"],"tags":["Actions"],"summary":"Zero Out Time Fields","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.ActionAmountResult"}}}}},"/v1/assets/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"Get Item by Asset ID","parameters":[{"type":"string","description":"Asset ID","name":"id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.PaginationResult-repo_ItemSummary"}}}}},"/v1/currency":{"get":{"produces":["application/json"],"tags":["Base"],"summary":"Currency","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/currencies.Currency"}}}}},"/v1/entities/{id}/attachments":{"post":{"security":[{"Bearer":[]}],"consumes":["multipart/form-data"],"produces":["application/json"],"tags":["Items Attachments"],"summary":"Create Item Attachment","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"file","description":"File attachment","name":"file","in":"formData","required":true},{"type":"string","description":"Type of file","name":"type","in":"formData"},{"type":"boolean","description":"Is this the primary attachment","name":"primary","in":"formData"},{"type":"string","description":"name of the file including extension","name":"name","in":"formData","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ItemOut"}},"422":{"description":"Unprocessable Entity","schema":{"$ref":"#/definitions/validate.ErrorResponse"}}}}},"/v1/entities/{id}/attachments/{attachment_id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/octet-stream"],"tags":["Items Attachments"],"summary":"Get Item Attachment","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"string","description":"Attachment ID","name":"attachment_id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.ItemAttachmentToken"}}}},"put":{"security":[{"Bearer":[]}],"tags":["Items Attachments"],"summary":"Update Item Attachment","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"string","description":"Attachment ID","name":"attachment_id","in":"path","required":true},{"description":"Attachment Update","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.EntityAttachmentUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ItemOut"}}}},"delete":{"security":[{"Bearer":[]}],"tags":["Items Attachments"],"summary":"Delete Item Attachment","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"string","description":"Attachment ID","name":"attachment_id","in":"path","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/entities/{id}/maintenance":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Item Maintenance"],"summary":"Get Maintenance Log","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"enum":["scheduled","completed","both"],"type":"string","x-enum-varnames":["MaintenanceFilterStatusScheduled","MaintenanceFilterStatusCompleted","MaintenanceFilterStatusBoth"],"name":"status","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.MaintenanceEntryWithDetails"}}}}},"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Item Maintenance"],"summary":"Create Maintenance Entry","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"description":"Entry Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.MaintenanceEntryCreate"}}],"responses":{"201":{"description":"Created","schema":{"$ref":"#/definitions/repo.MaintenanceEntry"}}}}},"/v1/entitytype":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["EntityTypes"],"summary":"Query All Entity Types","responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.EntityType"}}}}},"post":{"security":[{"Bearer":[]}],"consumes":["application/json"],"produces":["application/json"],"tags":["EntityTypes"],"summary":"Create Entity Type","parameters":[{"description":"Entity Type Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.EntityTypeCreate"}}],"responses":{"201":{"description":"Created","schema":{"$ref":"#/definitions/repo.EntityType"}}}}},"/v1/entitytype/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["EntityTypes"],"summary":"Get One Entity Type","parameters":[{"type":"string","description":"Entity Type ID","name":"id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.EntityType"}}}},"put":{"security":[{"Bearer":[]}],"consumes":["application/json"],"produces":["application/json"],"tags":["EntityTypes"],"summary":"Update Entity Type","parameters":[{"type":"string","description":"Entity Type ID","name":"id","in":"path","required":true},{"description":"Entity Type Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.EntityTypeUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.EntityType"}}}},"delete":{"security":[{"Bearer":[]}],"tags":["EntityTypes"],"summary":"Delete Entity Type","parameters":[{"type":"string","description":"Entity Type ID","name":"id","in":"path","required":true},{"description":"Entity Type Delete Options","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.EntityTypeDelete"}}],"responses":{"204":{"description":"No Content"}}}},"/v1/groups":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Group"],"summary":"Get Group","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.Group"}}}},"put":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Group"],"summary":"Update Group","parameters":[{"description":"User Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.GroupUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.Group"}}}}},"/v1/groups/invitations":{"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Group"],"summary":"Create Group Invitation","parameters":[{"description":"User Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/v1.GroupInvitationCreate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.GroupInvitation"}}}}},"/v1/groups/statistics":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Statistics"],"summary":"Get Group Statistics","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.GroupStatistics"}}}}},"/v1/groups/statistics/labels":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Statistics"],"summary":"Get Label Statistics","responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.TotalsByOrganizer"}}}}}},"/v1/groups/statistics/locations":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Statistics"],"summary":"Get Location Statistics","responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.TotalsByOrganizer"}}}}}},"/v1/groups/statistics/purchase-price":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Statistics"],"summary":"Get Purchase Price Statistics","parameters":[{"type":"string","description":"start date","name":"start","in":"query"},{"type":"string","description":"end date","name":"end","in":"query"}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ValueOverTime"}}}}},"/v1/items":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Query All Items","deprecated":true,"parameters":[{"type":"string","description":"search string","name":"q","in":"query"},{"type":"integer","description":"page number","name":"page","in":"query"},{"type":"integer","description":"items per page","name":"pageSize","in":"query"},{"type":"array","items":{"type":"string"},"collectionFormat":"multi","description":"label Ids","name":"labels","in":"query"},{"type":"array","items":{"type":"string"},"collectionFormat":"multi","description":"location Ids","name":"locations","in":"query"},{"type":"array","items":{"type":"string"},"collectionFormat":"multi","description":"parent Ids","name":"parentIds","in":"query"}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.PaginationResult-repo_ItemSummary"}}}},"post":{"security":[{"Bearer":[]}],"consumes":["application/json"],"produces":["application/json"],"tags":["Items"],"summary":"Create Item","deprecated":true,"parameters":[{"description":"Item Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.ItemCreate"}}],"responses":{"201":{"description":"Created","schema":{"$ref":"#/definitions/repo.ItemSummary"}}}}},"/v1/items/export":{"get":{"security":[{"Bearer":[]}],"tags":["Items"],"summary":"(Deprecated) Export Items","deprecated":true,"responses":{"200":{"description":"text/csv","schema":{"type":"string"}}}}},"/v1/items/fields":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Get All Custom Field Names","deprecated":true,"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"string"}}}}}},"/v1/items/fields/values":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Get All Custom Field Values","deprecated":true,"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"string"}}}}}},"/v1/items/import":{"post":{"security":[{"Bearer":[]}],"consumes":["multipart/form-data"],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Import Items","deprecated":true,"parameters":[{"type":"file","description":"Image to upload","name":"csv","in":"formData","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/items/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Get Item","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ItemOut"}}}},"put":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Update Item","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"description":"Item Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.ItemUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ItemOut"}}}},"delete":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Delete Item","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true}],"responses":{"204":{"description":"No Content"}}},"patch":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Update Item","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"description":"Item Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.ItemPatch"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ItemOut"}}}}},"/v1/items/{id}/attachments":{"post":{"security":[{"Bearer":[]}],"consumes":["multipart/form-data"],"produces":["application/json"],"tags":["Items Attachments"],"summary":"Create Item Attachment","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"file","description":"File attachment","name":"file","in":"formData","required":true},{"type":"string","description":"Type of file","name":"type","in":"formData"},{"type":"boolean","description":"Is this the primary attachment","name":"primary","in":"formData"},{"type":"string","description":"name of the file including extension","name":"name","in":"formData","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ItemOut"}},"422":{"description":"Unprocessable Entity","schema":{"$ref":"#/definitions/validate.ErrorResponse"}}}}},"/v1/items/{id}/attachments/{attachment_id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/octet-stream"],"tags":["Items Attachments"],"summary":"Get Item Attachment","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"string","description":"Attachment ID","name":"attachment_id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.ItemAttachmentToken"}}}},"put":{"security":[{"Bearer":[]}],"tags":["Items Attachments"],"summary":"Update Item Attachment","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"string","description":"Attachment ID","name":"attachment_id","in":"path","required":true},{"description":"Attachment Update","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.EntityAttachmentUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.ItemOut"}}}},"delete":{"security":[{"Bearer":[]}],"tags":["Items Attachments"],"summary":"Delete Item Attachment","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"string","description":"Attachment ID","name":"attachment_id","in":"path","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/items/{id}/duplicate":{"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"Duplicate Item","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"description":"Duplicate Options","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.DuplicateOptions"}}],"responses":{"201":{"description":"Created","schema":{"$ref":"#/definitions/repo.ItemOut"}}}}},"/v1/items/{id}/maintenance":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Item Maintenance"],"summary":"Get Maintenance Log","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"enum":["scheduled","completed","both"],"type":"string","x-enum-varnames":["MaintenanceFilterStatusScheduled","MaintenanceFilterStatusCompleted","MaintenanceFilterStatusBoth"],"name":"status","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.MaintenanceEntryWithDetails"}}}}},"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Item Maintenance"],"summary":"Create Maintenance Entry","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"description":"Entry Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.MaintenanceEntryCreate"}}],"responses":{"201":{"description":"Created","schema":{"$ref":"#/definitions/repo.MaintenanceEntry"}}}}},"/v1/items/{id}/path":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"(Deprecated) Get the full path of an item","deprecated":true,"parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.ItemPath"}}}}}},"/v1/labelmaker/assets/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"Get Asset label","parameters":[{"type":"string","description":"Asset ID","name":"id","in":"path","required":true},{"type":"boolean","description":"Print this label, defaults to false","name":"print","in":"query"}],"responses":{"200":{"description":"image/png","schema":{"type":"string"}}}}},"/v1/labelmaker/item/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"Get Item label","parameters":[{"type":"string","description":"Item ID","name":"id","in":"path","required":true},{"type":"boolean","description":"Print this label, defaults to false","name":"print","in":"query"}],"responses":{"200":{"description":"image/png","schema":{"type":"string"}}}}},"/v1/labelmaker/location/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Locations"],"summary":"Get Location label","parameters":[{"type":"string","description":"Location ID","name":"id","in":"path","required":true},{"type":"boolean","description":"Print this label, defaults to false","name":"print","in":"query"}],"responses":{"200":{"description":"image/png","schema":{"type":"string"}}}}},"/v1/labels":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Labels"],"summary":"Get All Labels","responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.LabelOut"}}}}},"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Labels"],"summary":"Create Label","parameters":[{"description":"Label Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.LabelCreate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.LabelSummary"}}}}},"/v1/labels/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Labels"],"summary":"Get Label","parameters":[{"type":"string","description":"Label ID","name":"id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.LabelOut"}}}},"put":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Labels"],"summary":"Update Label","parameters":[{"type":"string","description":"Label ID","name":"id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.LabelOut"}}}},"delete":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Labels"],"summary":"Delete Label","parameters":[{"type":"string","description":"Label ID","name":"id","in":"path","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/locations":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Locations"],"summary":"(Deprecated) Get All Locations","deprecated":true,"parameters":[{"type":"boolean","description":"Filter locations with parents","name":"filterChildren","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.LocationOutCount"}}}}},"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Locations"],"summary":"(Deprecated) Create Location","deprecated":true,"parameters":[{"description":"Location Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.LocationCreate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.LocationSummary"}}}}},"/v1/locations/tree":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Locations"],"summary":"(Deprecated) Get Locations Tree","deprecated":true,"parameters":[{"type":"boolean","description":"include items in response tree","name":"withItems","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.TreeItem"}}}}}},"/v1/locations/{id}":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Locations"],"summary":"(Deprecated) Get Location","deprecated":true,"parameters":[{"type":"string","description":"Location ID","name":"id","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.LocationOut"}}}},"put":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Locations"],"summary":"(Deprecated) Update Location","deprecated":true,"parameters":[{"type":"string","description":"Location ID","name":"id","in":"path","required":true},{"description":"Location Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.LocationUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.LocationOut"}}}},"delete":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Locations"],"summary":"(Deprecated) Delete Location","deprecated":true,"parameters":[{"type":"string","description":"Location ID","name":"id","in":"path","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/maintenance":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Maintenance"],"summary":"Query All Maintenance","parameters":[{"enum":["scheduled","completed","both"],"type":"string","x-enum-varnames":["MaintenanceFilterStatusScheduled","MaintenanceFilterStatusCompleted","MaintenanceFilterStatusBoth"],"name":"status","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.MaintenanceEntryWithDetails"}}}}}},"/v1/maintenance/{id}":{"put":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Maintenance"],"summary":"Update Maintenance Entry","parameters":[{"type":"string","description":"Maintenance ID","name":"id","in":"path","required":true},{"description":"Entry Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.MaintenanceEntryUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.MaintenanceEntry"}}}},"delete":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Maintenance"],"summary":"Delete Maintenance Entry","parameters":[{"type":"string","description":"Maintenance ID","name":"id","in":"path","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/notifiers":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Notifiers"],"summary":"Get Notifiers","responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.NotifierOut"}}}}},"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Notifiers"],"summary":"Create Notifier","parameters":[{"description":"Notifier Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.NotifierCreate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.NotifierOut"}}}}},"/v1/notifiers/test":{"post":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Notifiers"],"summary":"Test Notifier","parameters":[{"type":"string","description":"URL","name":"url","in":"query","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/notifiers/{id}":{"put":{"security":[{"Bearer":[]}],"tags":["Notifiers"],"summary":"Update Notifier","parameters":[{"type":"string","description":"Notifier ID","name":"id","in":"path","required":true},{"description":"Notifier Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.NotifierUpdate"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/repo.NotifierOut"}}}},"delete":{"security":[{"Bearer":[]}],"tags":["Notifiers"],"summary":"Delete a Notifier","parameters":[{"type":"string","description":"Notifier ID","name":"id","in":"path","required":true}],"responses":{"204":{"description":"No Content"}}}},"/v1/products/search-from-barcode":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"Search EAN from Barcode","parameters":[{"type":"string","description":"barcode to be searched","name":"data","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/repo.BarcodeProduct"}}}}}},"/v1/qrcode":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Items"],"summary":"Create QR Code","parameters":[{"type":"string","description":"data to be encoded into qrcode","name":"data","in":"query"}],"responses":{"200":{"description":"image/jpeg","schema":{"type":"string"}}}}},"/v1/reporting/bill-of-materials":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["Reporting"],"summary":"Export Bill of Materials","responses":{"200":{"description":"text/csv","schema":{"type":"string"}}}}},"/v1/status":{"get":{"produces":["application/json"],"tags":["Base"],"summary":"Application Info","responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.APISummary"}}}}},"/v1/users/change-password":{"put":{"security":[{"Bearer":[]}],"tags":["User"],"summary":"Change Password","parameters":[{"description":"Password Payload","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/v1.ChangePassword"}}],"responses":{"204":{"description":"No Content"}}}},"/v1/users/login":{"post":{"consumes":["application/x-www-form-urlencoded","application/json"],"produces":["application/json"],"tags":["Authentication"],"summary":"User Login","parameters":[{"description":"Login Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/v1.LoginForm"}},{"type":"string","description":"auth provider","name":"provider","in":"query"}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/v1.TokenResponse"}}}}},"/v1/users/logout":{"post":{"security":[{"Bearer":[]}],"tags":["Authentication"],"summary":"User Logout","responses":{"204":{"description":"No Content"}}}},"/v1/users/refresh":{"get":{"security":[{"Bearer":[]}],"description":"handleAuthRefresh returns a handler that will issue a new token from an existing token.\nThis does not validate that the user still exists within the database.","tags":["Authentication"],"summary":"User Token Refresh","responses":{"200":{"description":"OK"}}}},"/v1/users/register":{"post":{"produces":["application/json"],"tags":["User"],"summary":"Register New User","parameters":[{"description":"User Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/services.UserRegistration"}}],"responses":{"204":{"description":"No Content"}}}},"/v1/users/self":{"get":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["User"],"summary":"Get User Self","responses":{"200":{"description":"OK","schema":{"allOf":[{"$ref":"#/definitions/v1.Wrapped"},{"type":"object","properties":{"item":{"$ref":"#/definitions/repo.UserOut"}}}]}}}},"put":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["User"],"summary":"Update Account","parameters":[{"description":"User Data","name":"payload","in":"body","required":true,"schema":{"$ref":"#/definitions/repo.UserUpdate"}}],"responses":{"200":{"description":"OK","schema":{"allOf":[{"$ref":"#/definitions/v1.Wrapped"},{"type":"object","properties":{"item":{"$ref":"#/definitions/repo.UserUpdate"}}}]}}}},"delete":{"security":[{"Bearer":[]}],"produces":["application/json"],"tags":["User"],"summary":"Delete Account","responses":{"204":{"description":"No Content"}}}}},"definitions":{"attachment.Type":{"type":"string","enum":["attachment","photo","manual","warranty","attachment","receipt","thumbnail"],"x-enum-varnames":["DefaultType","TypePhoto","TypeManual","TypeWarranty","TypeAttachment","TypeReceipt","TypeThumbnail"]},"authroles.Role":{"type":"string","enum":["user","admin","user","attachments"],"x-enum-varnames":["DefaultRole","RoleAdmin","RoleUser","RoleAttachments"]},"currencies.Currency":{"type":"object","properties":{"code":{"type":"string"},"decimals":{"type":"integer"},"local":{"type":"string"},"name":{"type":"string"},"symbol":{"type":"string"}}},"ent.Attachment":{"type":"object","properties":{"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AttachmentQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.AttachmentEdges"}]},"id":{"description":"ID of the ent.","type":"string"},"mime_type":{"description":"MimeType holds the value of the \"mime_type\" field.","type":"string"},"path":{"description":"Path holds the value of the \"path\" field.","type":"string"},"primary":{"description":"Primary holds the value of the \"primary\" field.","type":"boolean"},"title":{"description":"Title holds the value of the \"title\" field.","type":"string"},"type":{"description":"Type holds the value of the \"type\" field.","allOf":[{"$ref":"#/definitions/attachment.Type"}]},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.AttachmentEdges":{"type":"object","properties":{"entity":{"description":"Entity holds the value of the entity edge.","allOf":[{"$ref":"#/definitions/ent.Entity"}]},"thumbnail":{"description":"Thumbnail holds the value of the thumbnail edge.","allOf":[{"$ref":"#/definitions/ent.Attachment"}]}}},"ent.AuthRoles":{"type":"object","properties":{"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AuthRolesQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.AuthRolesEdges"}]},"id":{"description":"ID of the ent.","type":"integer"},"role":{"description":"Role holds the value of the \"role\" field.","allOf":[{"$ref":"#/definitions/authroles.Role"}]}}},"ent.AuthRolesEdges":{"type":"object","properties":{"token":{"description":"Token holds the value of the token edge.","allOf":[{"$ref":"#/definitions/ent.AuthTokens"}]}}},"ent.AuthTokens":{"type":"object","properties":{"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AuthTokensQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.AuthTokensEdges"}]},"expires_at":{"description":"ExpiresAt holds the value of the \"expires_at\" field.","type":"string"},"id":{"description":"ID of the ent.","type":"string"},"token":{"description":"Token holds the value of the \"token\" field.","type":"array","items":{"type":"integer"}},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.AuthTokensEdges":{"type":"object","properties":{"roles":{"description":"Roles holds the value of the roles edge.","allOf":[{"$ref":"#/definitions/ent.AuthRoles"}]},"user":{"description":"User holds the value of the user edge.","allOf":[{"$ref":"#/definitions/ent.User"}]}}},"ent.Entity":{"type":"object","properties":{"archived":{"description":"Archived holds the value of the \"archived\" field.","type":"boolean"},"asset_id":{"description":"AssetID holds the value of the \"asset_id\" field.","type":"integer"},"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"description":{"description":"Description holds the value of the \"description\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.EntityEdges"}]},"id":{"description":"ID of the ent.","type":"string"},"import_ref":{"description":"ImportRef holds the value of the \"import_ref\" field.","type":"string"},"insured":{"description":"Insured holds the value of the \"insured\" field.","type":"boolean"},"lifetime_warranty":{"description":"LifetimeWarranty holds the value of the \"lifetime_warranty\" field.","type":"boolean"},"manufacturer":{"description":"Manufacturer holds the value of the \"manufacturer\" field.","type":"string"},"model_number":{"description":"ModelNumber holds the value of the \"model_number\" field.","type":"string"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"notes":{"description":"Notes holds the value of the \"notes\" field.","type":"string"},"purchase_from":{"description":"PurchaseFrom holds the value of the \"purchase_from\" field.","type":"string"},"purchase_price":{"description":"PurchasePrice holds the value of the \"purchase_price\" field.","type":"number"},"purchase_time":{"description":"PurchaseTime holds the value of the \"purchase_time\" field.","type":"string"},"quantity":{"description":"Quantity holds the value of the \"quantity\" field.","type":"integer"},"serial_number":{"description":"SerialNumber holds the value of the \"serial_number\" field.","type":"string"},"sold_notes":{"description":"SoldNotes holds the value of the \"sold_notes\" field.","type":"string"},"sold_price":{"description":"SoldPrice holds the value of the \"sold_price\" field.","type":"number"},"sold_time":{"description":"SoldTime holds the value of the \"sold_time\" field.","type":"string"},"sold_to":{"description":"SoldTo holds the value of the \"sold_to\" field.","type":"string"},"sync_child_entities_locations":{"description":"SyncChildEntitiesLocations holds the value of the \"sync_child_entities_locations\" field.","type":"boolean"},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"},"warranty_details":{"description":"WarrantyDetails holds the value of the \"warranty_details\" field.","type":"string"},"warranty_expires":{"description":"WarrantyExpires holds the value of the \"warranty_expires\" field.","type":"string"}}},"ent.EntityEdges":{"type":"object","properties":{"attachments":{"description":"Attachments holds the value of the attachments edge.","type":"array","items":{"$ref":"#/definitions/ent.Attachment"}},"children":{"description":"Children holds the value of the children edge.","type":"array","items":{"$ref":"#/definitions/ent.Entity"}},"entity":{"description":"Entity holds the value of the entity edge.","type":"array","items":{"$ref":"#/definitions/ent.Entity"}},"fields":{"description":"Fields holds the value of the fields edge.","type":"array","items":{"$ref":"#/definitions/ent.EntityField"}},"group":{"description":"Group holds the value of the group edge.","allOf":[{"$ref":"#/definitions/ent.Group"}]},"label":{"description":"Label holds the value of the label edge.","type":"array","items":{"$ref":"#/definitions/ent.Label"}},"location":{"description":"Location holds the value of the location edge.","allOf":[{"$ref":"#/definitions/ent.Entity"}]},"maintenance_entries":{"description":"MaintenanceEntries holds the value of the maintenance_entries edge.","type":"array","items":{"$ref":"#/definitions/ent.MaintenanceEntry"}},"parent":{"description":"Parent holds the value of the parent edge.","allOf":[{"$ref":"#/definitions/ent.Entity"}]},"type":{"description":"Type holds the value of the type edge.","allOf":[{"$ref":"#/definitions/ent.EntityType"}]}}},"ent.EntityField":{"type":"object","properties":{"boolean_value":{"description":"BooleanValue holds the value of the \"boolean_value\" field.","type":"boolean"},"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"description":{"description":"Description holds the value of the \"description\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityFieldQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.EntityFieldEdges"}]},"id":{"description":"ID of the ent.","type":"string"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"number_value":{"description":"NumberValue holds the value of the \"number_value\" field.","type":"integer"},"text_value":{"description":"TextValue holds the value of the \"text_value\" field.","type":"string"},"time_value":{"description":"TimeValue holds the value of the \"time_value\" field.","type":"string"},"type":{"description":"Type holds the value of the \"type\" field.","allOf":[{"$ref":"#/definitions/entityfield.Type"}]},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.EntityFieldEdges":{"type":"object","properties":{"entity":{"description":"Entity holds the value of the entity edge.","allOf":[{"$ref":"#/definitions/ent.Entity"}]}}},"ent.EntityType":{"type":"object","properties":{"color":{"description":"Color holds the value of the \"color\" field.","type":"string"},"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"description":{"description":"Description holds the value of the \"description\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the EntityTypeQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.EntityTypeEdges"}]},"icon":{"description":"Icon holds the value of the \"icon\" field.","type":"string"},"id":{"description":"ID of the ent.","type":"string"},"is_location":{"description":"IsLocation holds the value of the \"is_location\" field.","type":"boolean"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.EntityTypeEdges":{"type":"object","properties":{"entities":{"description":"Entities holds the value of the entities edge.","type":"array","items":{"$ref":"#/definitions/ent.Entity"}},"group":{"description":"Group holds the value of the group edge.","allOf":[{"$ref":"#/definitions/ent.Group"}]}}},"ent.Group":{"type":"object","properties":{"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"currency":{"description":"Currency holds the value of the \"currency\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the GroupQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.GroupEdges"}]},"id":{"description":"ID of the ent.","type":"string"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.GroupEdges":{"type":"object","properties":{"entities":{"description":"Entities holds the value of the entities edge.","type":"array","items":{"$ref":"#/definitions/ent.Entity"}},"entity_types":{"description":"EntityTypes holds the value of the entity_types edge.","type":"array","items":{"$ref":"#/definitions/ent.EntityType"}},"invitation_tokens":{"description":"InvitationTokens holds the value of the invitation_tokens edge.","type":"array","items":{"$ref":"#/definitions/ent.GroupInvitationToken"}},"labels":{"description":"Labels holds the value of the labels edge.","type":"array","items":{"$ref":"#/definitions/ent.Label"}},"notifiers":{"description":"Notifiers holds the value of the notifiers edge.","type":"array","items":{"$ref":"#/definitions/ent.Notifier"}},"users":{"description":"Users holds the value of the users edge.","type":"array","items":{"$ref":"#/definitions/ent.User"}}}},"ent.GroupInvitationToken":{"type":"object","properties":{"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the GroupInvitationTokenQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.GroupInvitationTokenEdges"}]},"expires_at":{"description":"ExpiresAt holds the value of the \"expires_at\" field.","type":"string"},"id":{"description":"ID of the ent.","type":"string"},"token":{"description":"Token holds the value of the \"token\" field.","type":"array","items":{"type":"integer"}},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"},"uses":{"description":"Uses holds the value of the \"uses\" field.","type":"integer"}}},"ent.GroupInvitationTokenEdges":{"type":"object","properties":{"group":{"description":"Group holds the value of the group edge.","allOf":[{"$ref":"#/definitions/ent.Group"}]}}},"ent.Label":{"type":"object","properties":{"color":{"description":"Color holds the value of the \"color\" field.","type":"string"},"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"description":{"description":"Description holds the value of the \"description\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LabelQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.LabelEdges"}]},"id":{"description":"ID of the ent.","type":"string"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.LabelEdges":{"type":"object","properties":{"entities":{"description":"Entities holds the value of the entities edge.","type":"array","items":{"$ref":"#/definitions/ent.Entity"}},"group":{"description":"Group holds the value of the group edge.","allOf":[{"$ref":"#/definitions/ent.Group"}]}}},"ent.MaintenanceEntry":{"type":"object","properties":{"cost":{"description":"Cost holds the value of the \"cost\" field.","type":"number"},"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"date":{"description":"Date holds the value of the \"date\" field.","type":"string"},"description":{"description":"Description holds the value of the \"description\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the MaintenanceEntryQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.MaintenanceEntryEdges"}]},"entity_id":{"description":"EntityID holds the value of the \"entity_id\" field.","type":"string"},"id":{"description":"ID of the ent.","type":"string"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"scheduled_date":{"description":"ScheduledDate holds the value of the \"scheduled_date\" field.","type":"string"},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.MaintenanceEntryEdges":{"type":"object","properties":{"entity":{"description":"Entity holds the value of the entity edge.","allOf":[{"$ref":"#/definitions/ent.Entity"}]}}},"ent.Notifier":{"type":"object","properties":{"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the NotifierQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.NotifierEdges"}]},"group_id":{"description":"GroupID holds the value of the \"group_id\" field.","type":"string"},"id":{"description":"ID of the ent.","type":"string"},"is_active":{"description":"IsActive holds the value of the \"is_active\" field.","type":"boolean"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"},"user_id":{"description":"UserID holds the value of the \"user_id\" field.","type":"string"}}},"ent.NotifierEdges":{"type":"object","properties":{"group":{"description":"Group holds the value of the group edge.","allOf":[{"$ref":"#/definitions/ent.Group"}]},"user":{"description":"User holds the value of the user edge.","allOf":[{"$ref":"#/definitions/ent.User"}]}}},"ent.User":{"type":"object","properties":{"activated_on":{"description":"ActivatedOn holds the value of the \"activated_on\" field.","type":"string"},"created_at":{"description":"CreatedAt holds the value of the \"created_at\" field.","type":"string"},"edges":{"description":"Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the UserQuery when eager-loading is set.","allOf":[{"$ref":"#/definitions/ent.UserEdges"}]},"email":{"description":"Email holds the value of the \"email\" field.","type":"string"},"id":{"description":"ID of the ent.","type":"string"},"is_superuser":{"description":"IsSuperuser holds the value of the \"is_superuser\" field.","type":"boolean"},"name":{"description":"Name holds the value of the \"name\" field.","type":"string"},"role":{"description":"Role holds the value of the \"role\" field.","allOf":[{"$ref":"#/definitions/user.Role"}]},"superuser":{"description":"Superuser holds the value of the \"superuser\" field.","type":"boolean"},"updated_at":{"description":"UpdatedAt holds the value of the \"updated_at\" field.","type":"string"}}},"ent.UserEdges":{"type":"object","properties":{"auth_tokens":{"description":"AuthTokens holds the value of the auth_tokens edge.","type":"array","items":{"$ref":"#/definitions/ent.AuthTokens"}},"group":{"description":"Group holds the value of the group edge.","allOf":[{"$ref":"#/definitions/ent.Group"}]},"notifiers":{"description":"Notifiers holds the value of the notifiers edge.","type":"array","items":{"$ref":"#/definitions/ent.Notifier"}}}},"entityfield.Type":{"type":"string","enum":["text","number","boolean","time"],"x-enum-varnames":["TypeText","TypeNumber","TypeBoolean","TypeTime"]},"repo.BarcodeProduct":{"type":"object","properties":{"barcode":{"type":"string"},"imageBase64":{"type":"string"},"imageURL":{"type":"string"},"item":{"$ref":"#/definitions/repo.ItemCreate"},"manufacturer":{"type":"string"},"modelNumber":{"description":"Identifications","type":"string"},"notes":{"description":"Extras","type":"string"},"search_engine_name":{"type":"string"}}},"repo.DuplicateOptions":{"type":"object","properties":{"copyAttachments":{"type":"boolean"},"copyCustomFields":{"type":"boolean"},"copyMaintenance":{"type":"boolean"},"copyPrefix":{"type":"string"}}},"repo.EntityAttachment":{"type":"object","properties":{"createdAt":{"type":"string"},"id":{"type":"string"},"mimeType":{"type":"string"},"path":{"type":"string"},"primary":{"type":"boolean"},"thumbnail":{"$ref":"#/definitions/ent.Attachment"},"title":{"type":"string"},"type":{"type":"string"},"updatedAt":{"type":"string"}}},"repo.EntityAttachmentUpdate":{"type":"object","properties":{"primary":{"type":"boolean"},"title":{"type":"string"},"type":{"type":"string"}}},"repo.EntityType":{"type":"object","properties":{"color":{"type":"string"},"description":{"type":"string"},"icon":{"type":"string"},"isLocation":{"type":"boolean"},"name":{"type":"string"}}},"repo.EntityTypeCreate":{"type":"object","required":["isLocation","name"],"properties":{"color":{"type":"string"},"description":{"type":"string"},"icon":{"type":"string"},"isLocation":{"type":"boolean"},"name":{"type":"string"}}},"repo.EntityTypeDelete":{"type":"object","properties":{"replacementId":{"$ref":"#/definitions/uuid.NullUUID"}}},"repo.EntityTypeUpdate":{"type":"object","properties":{"color":{"type":"string"},"description":{"type":"string"},"icon":{"type":"string"},"name":{"type":"string","minLength":1}}},"repo.Group":{"type":"object","properties":{"createdAt":{"type":"string"},"currency":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"updatedAt":{"type":"string"}}},"repo.GroupStatistics":{"type":"object","properties":{"totalItemPrice":{"type":"number"},"totalItems":{"type":"integer"},"totalLabels":{"type":"integer"},"totalLocations":{"type":"integer"},"totalUsers":{"type":"integer"},"totalWithWarranty":{"type":"integer"}}},"repo.GroupUpdate":{"type":"object","properties":{"currency":{"type":"string"},"name":{"type":"string"}}},"repo.ItemCreate":{"type":"object","required":["entityType","name"],"properties":{"description":{"type":"string","maxLength":1000},"entityType":{"type":"string"},"labelIds":{"type":"array","items":{"type":"string"}},"locationId":{"description":"Edges","type":"string"},"name":{"type":"string","maxLength":255,"minLength":1},"parentId":{"type":"string","x-nullable":true},"quantity":{"type":"integer"}}},"repo.ItemField":{"type":"object","properties":{"booleanValue":{"type":"boolean"},"id":{"type":"string"},"name":{"type":"string"},"numberValue":{"type":"integer"},"textValue":{"type":"string"},"type":{"type":"string"}}},"repo.ItemOut":{"type":"object","properties":{"archived":{"type":"boolean"},"assetId":{"type":"string","example":"0"},"attachments":{"type":"array","items":{"$ref":"#/definitions/repo.EntityAttachment"}},"createdAt":{"type":"string"},"description":{"type":"string"},"entityType":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/definitions/repo.ItemField"}},"id":{"type":"string"},"imageId":{"type":"string","x-nullable":true,"x-omitempty":true},"insured":{"type":"boolean"},"labels":{"type":"array","items":{"$ref":"#/definitions/repo.LabelSummary"}},"lifetimeWarranty":{"description":"Warranty","type":"boolean"},"location":{"description":"Edges","allOf":[{"$ref":"#/definitions/repo.LocationSummary"}],"x-nullable":true,"x-omitempty":true},"manufacturer":{"type":"string"},"modelNumber":{"type":"string"},"name":{"type":"string"},"notes":{"description":"Extras","type":"string"},"parent":{"allOf":[{"$ref":"#/definitions/repo.ItemSummary"}],"x-nullable":true,"x-omitempty":true},"purchaseFrom":{"type":"string"},"purchasePrice":{"type":"number"},"purchaseTime":{"description":"Purchase","type":"string"},"quantity":{"type":"integer"},"serialNumber":{"type":"string"},"soldNotes":{"type":"string"},"soldPrice":{"type":"number"},"soldTime":{"description":"Sold","type":"string"},"soldTo":{"type":"string"},"syncChildItemsLocations":{"type":"boolean"},"thumbnailId":{"type":"string","x-nullable":true,"x-omitempty":true},"updatedAt":{"type":"string"},"warrantyDetails":{"type":"string"},"warrantyExpires":{"type":"string"}}},"repo.ItemPatch":{"type":"object","properties":{"id":{"type":"string"},"labelIds":{"type":"array","items":{"type":"string"},"x-nullable":true,"x-omitempty":true},"locationId":{"type":"string","x-nullable":true,"x-omitempty":true},"quantity":{"type":"integer","x-nullable":true,"x-omitempty":true}}},"repo.ItemPath":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"type":{"$ref":"#/definitions/repo.ItemType"}}},"repo.ItemSummary":{"type":"object","properties":{"archived":{"type":"boolean"},"assetId":{"type":"string","example":"0"},"createdAt":{"type":"string"},"description":{"type":"string"},"entityType":{"type":"string"},"id":{"type":"string"},"imageId":{"type":"string","x-nullable":true,"x-omitempty":true},"insured":{"type":"boolean"},"labels":{"type":"array","items":{"$ref":"#/definitions/repo.LabelSummary"}},"location":{"description":"Edges","allOf":[{"$ref":"#/definitions/repo.LocationSummary"}],"x-nullable":true,"x-omitempty":true},"name":{"type":"string"},"purchasePrice":{"type":"number"},"quantity":{"type":"integer"},"soldTime":{"description":"Sale details","type":"string"},"thumbnailId":{"type":"string","x-nullable":true,"x-omitempty":true},"updatedAt":{"type":"string"}}},"repo.ItemType":{"type":"string","enum":["location","item","location","item"],"x-enum-varnames":["EntityTypeLocation","EntityTypeItem","ItemTypeLocation","ItemTypeItem"]},"repo.ItemUpdate":{"type":"object","required":["entityType","name"],"properties":{"archived":{"type":"boolean"},"assetId":{"type":"string"},"description":{"type":"string","maxLength":1000},"entityType":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/definitions/repo.ItemField"}},"id":{"type":"string"},"insured":{"type":"boolean"},"labelIds":{"type":"array","items":{"type":"string"}},"lifetimeWarranty":{"description":"Warranty","type":"boolean"},"locationId":{"description":"Edges","type":"string"},"manufacturer":{"type":"string"},"modelNumber":{"type":"string"},"name":{"type":"string","maxLength":255,"minLength":1},"notes":{"description":"Extras","type":"string"},"parentId":{"type":"string","x-nullable":true,"x-omitempty":true},"purchaseFrom":{"type":"string","maxLength":255},"purchasePrice":{"type":"number","x-nullable":true,"x-omitempty":true},"purchaseTime":{"description":"Purchase","type":"string"},"quantity":{"type":"integer"},"serialNumber":{"description":"Identifications","type":"string"},"soldNotes":{"type":"string"},"soldPrice":{"type":"number","x-nullable":true,"x-omitempty":true},"soldTime":{"description":"Sold","type":"string"},"soldTo":{"type":"string","maxLength":255},"syncChildItemsLocations":{"type":"boolean"},"warrantyDetails":{"type":"string"},"warrantyExpires":{"type":"string"}}},"repo.LabelCreate":{"type":"object","required":["name"],"properties":{"color":{"type":"string"},"description":{"type":"string","maxLength":1000},"name":{"type":"string","maxLength":255,"minLength":1}}},"repo.LabelOut":{"type":"object","properties":{"color":{"type":"string"},"createdAt":{"type":"string"},"description":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"updatedAt":{"type":"string"}}},"repo.LabelSummary":{"type":"object","properties":{"color":{"type":"string"},"createdAt":{"type":"string"},"description":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"updatedAt":{"type":"string"}}},"repo.LocationCreate":{"type":"object","required":["entityType"],"properties":{"description":{"type":"string"},"entityType":{"type":"string"},"name":{"type":"string"},"parentId":{"type":"string","x-nullable":true}}},"repo.LocationOut":{"type":"object","properties":{"children":{"type":"array","items":{"$ref":"#/definitions/repo.LocationSummary"}},"createdAt":{"type":"string"},"description":{"type":"string"},"entityType":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"parent":{"$ref":"#/definitions/repo.LocationSummary"},"totalPrice":{"type":"number"},"updatedAt":{"type":"string"}}},"repo.LocationOutCount":{"type":"object","properties":{"createdAt":{"type":"string"},"description":{"type":"string"},"entityType":{"type":"string"},"id":{"type":"string"},"itemCount":{"type":"integer"},"name":{"type":"string"},"updatedAt":{"type":"string"}}},"repo.LocationSummary":{"type":"object","properties":{"createdAt":{"type":"string"},"description":{"type":"string"},"entityType":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"updatedAt":{"type":"string"}}},"repo.LocationUpdate":{"type":"object","required":["entityType"],"properties":{"description":{"type":"string"},"entityType":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"parentId":{"type":"string","x-nullable":true}}},"repo.MaintenanceEntry":{"type":"object","properties":{"completedDate":{"type":"string"},"cost":{"type":"string","example":"0"},"description":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"scheduledDate":{"type":"string"}}},"repo.MaintenanceEntryCreate":{"type":"object","required":["name"],"properties":{"completedDate":{"type":"string"},"cost":{"type":"string","example":"0"},"description":{"type":"string"},"name":{"type":"string"},"scheduledDate":{"type":"string"}}},"repo.MaintenanceEntryUpdate":{"type":"object","properties":{"completedDate":{"type":"string"},"cost":{"type":"string","example":"0"},"description":{"type":"string"},"name":{"type":"string"},"scheduledDate":{"type":"string"}}},"repo.MaintenanceEntryWithDetails":{"type":"object","properties":{"completedDate":{"type":"string"},"cost":{"type":"string","example":"0"},"description":{"type":"string"},"id":{"type":"string"},"itemID":{"type":"string"},"itemName":{"type":"string"},"name":{"type":"string"},"scheduledDate":{"type":"string"}}},"repo.MaintenanceFilterStatus":{"type":"string","enum":["scheduled","completed","both"],"x-enum-varnames":["MaintenanceFilterStatusScheduled","MaintenanceFilterStatusCompleted","MaintenanceFilterStatusBoth"]},"repo.NotifierCreate":{"type":"object","required":["name","url"],"properties":{"isActive":{"type":"boolean"},"name":{"type":"string","maxLength":255,"minLength":1},"url":{"type":"string"}}},"repo.NotifierOut":{"type":"object","properties":{"createdAt":{"type":"string"},"groupId":{"type":"string"},"id":{"type":"string"},"isActive":{"type":"boolean"},"name":{"type":"string"},"updatedAt":{"type":"string"},"url":{"type":"string"},"userId":{"type":"string"}}},"repo.NotifierUpdate":{"type":"object","required":["name"],"properties":{"isActive":{"type":"boolean"},"name":{"type":"string","maxLength":255,"minLength":1},"url":{"type":"string","x-nullable":true}}},"repo.PaginationResult-repo_ItemSummary":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/definitions/repo.ItemSummary"}},"page":{"type":"integer"},"pageSize":{"type":"integer"},"total":{"type":"integer"}}},"repo.TotalsByOrganizer":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"total":{"type":"number"}}},"repo.TreeItem":{"type":"object","properties":{"children":{"type":"array","items":{"$ref":"#/definitions/repo.TreeItem"}},"id":{"type":"string"},"name":{"type":"string"},"type":{"type":"string"}}},"repo.UserOut":{"type":"object","properties":{"email":{"type":"string"},"groupId":{"type":"string"},"groupName":{"type":"string"},"id":{"type":"string"},"isOwner":{"type":"boolean"},"isSuperuser":{"type":"boolean"},"name":{"type":"string"}}},"repo.UserUpdate":{"type":"object","properties":{"email":{"type":"string"},"name":{"type":"string"}}},"repo.ValueOverTime":{"type":"object","properties":{"end":{"type":"string"},"entries":{"type":"array","items":{"$ref":"#/definitions/repo.ValueOverTimeEntry"}},"start":{"type":"string"},"valueAtEnd":{"type":"number"},"valueAtStart":{"type":"number"}}},"repo.ValueOverTimeEntry":{"type":"object","properties":{"date":{"type":"string"},"name":{"type":"string"},"value":{"type":"number"}}},"services.Latest":{"type":"object","properties":{"date":{"type":"string"},"version":{"type":"string"}}},"services.UserRegistration":{"type":"object","properties":{"email":{"type":"string"},"name":{"type":"string"},"password":{"type":"string"},"token":{"type":"string"}}},"user.Role":{"type":"string","enum":["user","user","owner"],"x-enum-varnames":["DefaultRole","RoleUser","RoleOwner"]},"uuid.NullUUID":{"type":"object","properties":{"uuid":{"type":"string"},"valid":{"description":"Valid is true if UUID is not NULL","type":"boolean"}}},"v1.APISummary":{"type":"object","properties":{"allowRegistration":{"type":"boolean"},"build":{"$ref":"#/definitions/v1.Build"},"demo":{"type":"boolean"},"health":{"type":"boolean"},"labelPrinting":{"type":"boolean"},"latest":{"$ref":"#/definitions/services.Latest"},"message":{"type":"string"},"title":{"type":"string"},"versions":{"type":"array","items":{"type":"string"}}}},"v1.ActionAmountResult":{"type":"object","properties":{"completed":{"type":"integer"}}},"v1.Build":{"type":"object","properties":{"buildTime":{"type":"string"},"commit":{"type":"string"},"version":{"type":"string"}}},"v1.ChangePassword":{"type":"object","properties":{"current":{"type":"string"},"new":{"type":"string"}}},"v1.GroupInvitation":{"type":"object","properties":{"expiresAt":{"type":"string"},"token":{"type":"string"},"uses":{"type":"integer"}}},"v1.GroupInvitationCreate":{"type":"object","required":["uses"],"properties":{"expiresAt":{"type":"string"},"uses":{"type":"integer","maximum":100,"minimum":1}}},"v1.ItemAttachmentToken":{"type":"object","properties":{"token":{"type":"string"}}},"v1.LoginForm":{"type":"object","properties":{"password":{"type":"string","example":"admin"},"stayLoggedIn":{"type":"boolean"},"username":{"type":"string","example":"admin@admin.com"}}},"v1.TokenResponse":{"type":"object","properties":{"attachmentToken":{"type":"string"},"expiresAt":{"type":"string"},"token":{"type":"string"}}},"v1.Wrapped":{"type":"object","properties":{"item":{}}},"validate.ErrorResponse":{"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"string"}}}},"securityDefinitions":{"Bearer":{"description":"\"Type 'Bearer TOKEN' to correctly set the API Key\"","type":"apiKey","name":"Authorization","in":"header"}}} \ No newline at end of file +{ + "schemes": [ + "https", + "http" + ], + "swagger": "2.0", + "info": { + "description": "Track, Manage, and Organize your Things.", + "title": "Homebox API", + "contact": { + "name": "Homebox Team", + "url": "https://discord.homebox.software" + }, + "version": "1.0" + }, + "host": "demo.homebox.software", + "basePath": "/api", + "paths": { + "/v1/actions/create-missing-thumbnails": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Creates thumbnails for items that are missing them", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Create Missing Thumbnails", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, + "/v1/actions/ensure-asset-ids": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Ensures all items in the database have an asset ID", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Ensure Asset IDs", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, + "/v1/actions/ensure-import-refs": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Ensures all items in the database have an import ref", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Ensures Import Refs", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, + "/v1/actions/set-primary-photos": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Sets the first photo of each item as the primary photo", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Set Primary Photos", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, + "/v1/actions/zero-item-time-fields": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Resets all item date fields to the beginning of the day", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Zero Out Time Fields", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, + "/v1/assets/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get Item by Asset ID", + "parameters": [ + { + "type": "string", + "description": "Asset ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.PaginationResult-repo_ItemSummary" + } + } + } + } + }, + "/v1/currency": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "Base" + ], + "summary": "Currency", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/currencies.Currency" + } + } + } + } + }, + "/v1/groups": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Group" + ], + "summary": "Get Group", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.Group" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Group" + ], + "summary": "Update Group", + "parameters": [ + { + "description": "User Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.GroupUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.Group" + } + } + } + } + }, + "/v1/groups/invitations": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Group" + ], + "summary": "Create Group Invitation", + "parameters": [ + { + "description": "User Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.GroupInvitationCreate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.GroupInvitation" + } + } + } + } + }, + "/v1/groups/statistics": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Statistics" + ], + "summary": "Get Group Statistics", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.GroupStatistics" + } + } + } + } + }, + "/v1/groups/statistics/labels": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Statistics" + ], + "summary": "Get Label Statistics", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.TotalsByOrganizer" + } + } + } + } + } + }, + "/v1/groups/statistics/locations": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Statistics" + ], + "summary": "Get Location Statistics", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.TotalsByOrganizer" + } + } + } + } + } + }, + "/v1/groups/statistics/purchase-price": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Statistics" + ], + "summary": "Get Purchase Price Statistics", + "parameters": [ + { + "type": "string", + "description": "start date", + "name": "start", + "in": "query" + }, + { + "type": "string", + "description": "end date", + "name": "end", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ValueOverTime" + } + } + } + } + }, + "/v1/items": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Query All Items", + "parameters": [ + { + "type": "string", + "description": "search string", + "name": "q", + "in": "query" + }, + { + "type": "integer", + "description": "page number", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "items per page", + "name": "pageSize", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "label Ids", + "name": "labels", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "location Ids", + "name": "locations", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "parent Ids", + "name": "parentIds", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.PaginationResult-repo_ItemSummary" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Create Item", + "parameters": [ + { + "description": "Item Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemCreate" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.ItemSummary" + } + } + } + } + }, + "/v1/items/export": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Items" + ], + "summary": "Export Items", + "responses": { + "200": { + "description": "text/csv", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/items/fields": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get All Custom Field Names", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + }, + "/v1/items/fields/values": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get All Custom Field Values", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + }, + "/v1/items/import": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Import Items", + "parameters": [ + { + "type": "file", + "description": "Image to upload", + "name": "csv", + "in": "formData", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/items/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get Item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Update Item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Item Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Delete Item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + }, + "patch": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Update Item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Item Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemPatch" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + } + }, + "/v1/items/{id}/attachments": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items Attachments" + ], + "summary": "Create Item Attachment", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "file", + "description": "File attachment", + "name": "file", + "in": "formData", + "required": true + }, + { + "type": "string", + "description": "Type of file", + "name": "type", + "in": "formData" + }, + { + "type": "boolean", + "description": "Is this the primary attachment", + "name": "primary", + "in": "formData" + }, + { + "type": "string", + "description": "name of the file including extension", + "name": "name", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + }, + "422": { + "description": "Unprocessable Entity", + "schema": { + "$ref": "#/definitions/validate.ErrorResponse" + } + } + } + } + }, + "/v1/items/{id}/attachments/{attachment_id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/octet-stream" + ], + "tags": [ + "Items Attachments" + ], + "summary": "Get Item Attachment", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Attachment ID", + "name": "attachment_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ItemAttachmentToken" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Items Attachments" + ], + "summary": "Update Item Attachment", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Attachment ID", + "name": "attachment_id", + "in": "path", + "required": true + }, + { + "description": "Attachment Update", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemAttachmentUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Items Attachments" + ], + "summary": "Delete Item Attachment", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Attachment ID", + "name": "attachment_id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/items/{id}/duplicate": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Duplicate Item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Duplicate Options", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.DuplicateOptions" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + } + }, + "/v1/items/{id}/maintenance": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Maintenance" + ], + "summary": "Get Maintenance Log", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "enum": [ + "scheduled", + "completed", + "both" + ], + "type": "string", + "x-enum-varnames": [ + "MaintenanceFilterStatusScheduled", + "MaintenanceFilterStatusCompleted", + "MaintenanceFilterStatusBoth" + ], + "name": "status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.MaintenanceEntryWithDetails" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Maintenance" + ], + "summary": "Create Maintenance Entry", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Entry Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.MaintenanceEntryCreate" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.MaintenanceEntry" + } + } + } + } + }, + "/v1/items/{id}/path": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get the full path of an item", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemPath" + } + } + } + } + } + }, + "/v1/labelmaker/assets/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get Asset label", + "parameters": [ + { + "type": "string", + "description": "Asset ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "Print this label, defaults to false", + "name": "print", + "in": "query" + } + ], + "responses": { + "200": { + "description": "image/png", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/labelmaker/item/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Get Item label", + "parameters": [ + { + "type": "string", + "description": "Item ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "Print this label, defaults to false", + "name": "print", + "in": "query" + } + ], + "responses": { + "200": { + "description": "image/png", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/labelmaker/location/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Get Location label", + "parameters": [ + { + "type": "string", + "description": "Location ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "Print this label, defaults to false", + "name": "print", + "in": "query" + } + ], + "responses": { + "200": { + "description": "image/png", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/labels": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Labels" + ], + "summary": "Get All Labels", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.LabelOut" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Labels" + ], + "summary": "Create Label", + "parameters": [ + { + "description": "Label Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.LabelCreate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LabelSummary" + } + } + } + } + }, + "/v1/labels/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Labels" + ], + "summary": "Get Label", + "parameters": [ + { + "type": "string", + "description": "Label ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LabelOut" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Labels" + ], + "summary": "Update Label", + "parameters": [ + { + "type": "string", + "description": "Label ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LabelOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Labels" + ], + "summary": "Delete Label", + "parameters": [ + { + "type": "string", + "description": "Label ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/locations": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Get All Locations", + "parameters": [ + { + "type": "boolean", + "description": "Filter locations with parents", + "name": "filterChildren", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.LocationOutCount" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Create Location", + "parameters": [ + { + "description": "Location Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.LocationCreate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LocationSummary" + } + } + } + } + }, + "/v1/locations/tree": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Get Locations Tree", + "parameters": [ + { + "type": "boolean", + "description": "include items in response tree", + "name": "withItems", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.TreeItem" + } + } + } + } + } + }, + "/v1/locations/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Get Location", + "parameters": [ + { + "type": "string", + "description": "Location ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LocationOut" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Update Location", + "parameters": [ + { + "type": "string", + "description": "Location ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Location Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.LocationUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.LocationOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Locations" + ], + "summary": "Delete Location", + "parameters": [ + { + "type": "string", + "description": "Location ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/maintenance": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Maintenance" + ], + "summary": "Query All Maintenance", + "parameters": [ + { + "enum": [ + "scheduled", + "completed", + "both" + ], + "type": "string", + "x-enum-varnames": [ + "MaintenanceFilterStatusScheduled", + "MaintenanceFilterStatusCompleted", + "MaintenanceFilterStatusBoth" + ], + "name": "status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.MaintenanceEntryWithDetails" + } + } + } + } + } + }, + "/v1/maintenance/{id}": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Maintenance" + ], + "summary": "Update Maintenance Entry", + "parameters": [ + { + "type": "string", + "description": "Maintenance ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Entry Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.MaintenanceEntryUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.MaintenanceEntry" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Maintenance" + ], + "summary": "Delete Maintenance Entry", + "parameters": [ + { + "type": "string", + "description": "Maintenance ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/notifiers": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Notifiers" + ], + "summary": "Get Notifiers", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.NotifierOut" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Notifiers" + ], + "summary": "Create Notifier", + "parameters": [ + { + "description": "Notifier Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.NotifierCreate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.NotifierOut" + } + } + } + } + }, + "/v1/notifiers/test": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Notifiers" + ], + "summary": "Test Notifier", + "parameters": [ + { + "type": "string", + "description": "URL", + "name": "url", + "in": "query", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/notifiers/{id}": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Notifiers" + ], + "summary": "Update Notifier", + "parameters": [ + { + "type": "string", + "description": "Notifier ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Notifier Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.NotifierUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.NotifierOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Notifiers" + ], + "summary": "Delete a Notifier", + "parameters": [ + { + "type": "string", + "description": "Notifier ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/products/search-from-barcode": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Search EAN from Barcode", + "parameters": [ + { + "type": "string", + "description": "barcode to be searched", + "name": "data", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.BarcodeProduct" + } + } + } + } + } + }, + "/v1/qrcode": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Items" + ], + "summary": "Create QR Code", + "parameters": [ + { + "type": "string", + "description": "data to be encoded into qrcode", + "name": "data", + "in": "query" + } + ], + "responses": { + "200": { + "description": "image/jpeg", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/reporting/bill-of-materials": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Reporting" + ], + "summary": "Export Bill of Materials", + "responses": { + "200": { + "description": "text/csv", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/status": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "Base" + ], + "summary": "Application Info", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.APISummary" + } + } + } + } + }, + "/v1/templates": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Get All Item Templates", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemTemplateSummary" + } + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Create Item Template", + "parameters": [ + { + "description": "Template Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemTemplateCreate" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.ItemTemplateOut" + } + } + } + } + }, + "/v1/templates/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Get Item Template", + "parameters": [ + { + "type": "string", + "description": "Template ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemTemplateOut" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Update Item Template", + "parameters": [ + { + "type": "string", + "description": "Template ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Template Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.ItemTemplateUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ItemTemplateOut" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Delete Item Template", + "parameters": [ + { + "type": "string", + "description": "Template ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/templates/{id}/create-item": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Item Templates" + ], + "summary": "Create Item from Template", + "parameters": [ + { + "type": "string", + "description": "Template ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Item Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.ItemTemplateCreateItemRequest" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/repo.ItemOut" + } + } + } + } + }, + "/v1/users/change-password": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "User" + ], + "summary": "Change Password", + "parameters": [ + { + "description": "Password Payload", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.ChangePassword" + } + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/users/login": { + "post": { + "consumes": [ + "application/x-www-form-urlencoded", + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Authentication" + ], + "summary": "User Login", + "parameters": [ + { + "description": "Login Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.LoginForm" + } + }, + { + "type": "string", + "description": "auth provider", + "name": "provider", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.TokenResponse" + } + } + } + } + }, + "/v1/users/login/oidc": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "Authentication" + ], + "summary": "OIDC Login Initiation", + "responses": { + "302": { + "description": "Found" + } + } + } + }, + "/v1/users/login/oidc/callback": { + "get": { + "tags": [ + "Authentication" + ], + "summary": "OIDC Callback Handler", + "parameters": [ + { + "type": "string", + "description": "Authorization code", + "name": "code", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "State parameter", + "name": "state", + "in": "query", + "required": true + } + ], + "responses": { + "302": { + "description": "Found" + } + } + } + }, + "/v1/users/logout": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "Authentication" + ], + "summary": "User Logout", + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/v1/users/refresh": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "handleAuthRefresh returns a handler that will issue a new token from an existing token.\nThis does not validate that the user still exists within the database.", + "tags": [ + "Authentication" + ], + "summary": "User Token Refresh", + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/v1/users/register": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Register New User", + "parameters": [ + { + "description": "User Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/services.UserRegistration" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "403": { + "description": "Local login is not enabled", + "schema": { + "type": "string" + } + } + } + } + }, + "/v1/users/self": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Get User Self", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/v1.Wrapped" + }, + { + "type": "object", + "properties": { + "item": { + "$ref": "#/definitions/repo.UserOut" + } + } + } + ] + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Update Account", + "parameters": [ + { + "description": "User Data", + "name": "payload", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repo.UserUpdate" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/v1.Wrapped" + }, + { + "type": "object", + "properties": { + "item": { + "$ref": "#/definitions/repo.UserUpdate" + } + } + } + ] + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Delete Account", + "responses": { + "204": { + "description": "No Content" + } + } + } + } + }, + "definitions": { + "attachment.Type": { + "type": "string", + "enum": [ + "attachment", + "photo", + "manual", + "warranty", + "attachment", + "receipt", + "thumbnail" + ], + "x-enum-varnames": [ + "DefaultType", + "TypePhoto", + "TypeManual", + "TypeWarranty", + "TypeAttachment", + "TypeReceipt", + "TypeThumbnail" + ] + }, + "authroles.Role": { + "type": "string", + "enum": [ + "user", + "admin", + "user", + "attachments" + ], + "x-enum-varnames": [ + "DefaultRole", + "RoleAdmin", + "RoleUser", + "RoleAttachments" + ] + }, + "currencies.Currency": { + "type": "object", + "properties": { + "code": { + "type": "string" + }, + "decimals": { + "type": "integer" + }, + "local": { + "type": "string" + }, + "name": { + "type": "string" + }, + "symbol": { + "type": "string" + } + } + }, + "ent.Attachment": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AttachmentQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.AttachmentEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "mime_type": { + "description": "MimeType holds the value of the \"mime_type\" field.", + "type": "string" + }, + "path": { + "description": "Path holds the value of the \"path\" field.", + "type": "string" + }, + "primary": { + "description": "Primary holds the value of the \"primary\" field.", + "type": "boolean" + }, + "title": { + "description": "Title holds the value of the \"title\" field.", + "type": "string" + }, + "type": { + "description": "Type holds the value of the \"type\" field.", + "allOf": [ + { + "$ref": "#/definitions/attachment.Type" + } + ] + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.AttachmentEdges": { + "type": "object", + "properties": { + "item": { + "description": "Item holds the value of the item edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Item" + } + ] + }, + "thumbnail": { + "description": "Thumbnail holds the value of the thumbnail edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Attachment" + } + ] + } + } + }, + "ent.AuthRoles": { + "type": "object", + "properties": { + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AuthRolesQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.AuthRolesEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "integer" + }, + "role": { + "description": "Role holds the value of the \"role\" field.", + "allOf": [ + { + "$ref": "#/definitions/authroles.Role" + } + ] + } + } + }, + "ent.AuthRolesEdges": { + "type": "object", + "properties": { + "token": { + "description": "Token holds the value of the token edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.AuthTokens" + } + ] + } + } + }, + "ent.AuthTokens": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the AuthTokensQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.AuthTokensEdges" + } + ] + }, + "expires_at": { + "description": "ExpiresAt holds the value of the \"expires_at\" field.", + "type": "string" + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "token": { + "description": "Token holds the value of the \"token\" field.", + "type": "array", + "items": { + "type": "integer" + } + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.AuthTokensEdges": { + "type": "object", + "properties": { + "roles": { + "description": "Roles holds the value of the roles edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.AuthRoles" + } + ] + }, + "user": { + "description": "User holds the value of the user edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.User" + } + ] + } + } + }, + "ent.Group": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "currency": { + "description": "Currency holds the value of the \"currency\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the GroupQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.GroupEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.GroupEdges": { + "type": "object", + "properties": { + "invitation_tokens": { + "description": "InvitationTokens holds the value of the invitation_tokens edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.GroupInvitationToken" + } + }, + "item_templates": { + "description": "ItemTemplates holds the value of the item_templates edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.ItemTemplate" + } + }, + "items": { + "description": "Items holds the value of the items edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Item" + } + }, + "labels": { + "description": "Labels holds the value of the labels edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Label" + } + }, + "locations": { + "description": "Locations holds the value of the locations edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Location" + } + }, + "notifiers": { + "description": "Notifiers holds the value of the notifiers edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Notifier" + } + }, + "users": { + "description": "Users holds the value of the users edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.User" + } + } + } + }, + "ent.GroupInvitationToken": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the GroupInvitationTokenQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.GroupInvitationTokenEdges" + } + ] + }, + "expires_at": { + "description": "ExpiresAt holds the value of the \"expires_at\" field.", + "type": "string" + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "token": { + "description": "Token holds the value of the \"token\" field.", + "type": "array", + "items": { + "type": "integer" + } + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + }, + "uses": { + "description": "Uses holds the value of the \"uses\" field.", + "type": "integer" + } + } + }, + "ent.GroupInvitationTokenEdges": { + "type": "object", + "properties": { + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + } + } + }, + "ent.Item": { + "type": "object", + "properties": { + "archived": { + "description": "Archived holds the value of the \"archived\" field.", + "type": "boolean" + }, + "asset_id": { + "description": "AssetID holds the value of the \"asset_id\" field.", + "type": "integer" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.ItemEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "import_ref": { + "description": "ImportRef holds the value of the \"import_ref\" field.", + "type": "string" + }, + "insured": { + "description": "Insured holds the value of the \"insured\" field.", + "type": "boolean" + }, + "lifetime_warranty": { + "description": "LifetimeWarranty holds the value of the \"lifetime_warranty\" field.", + "type": "boolean" + }, + "manufacturer": { + "description": "Manufacturer holds the value of the \"manufacturer\" field.", + "type": "string" + }, + "model_number": { + "description": "ModelNumber holds the value of the \"model_number\" field.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "notes": { + "description": "Notes holds the value of the \"notes\" field.", + "type": "string" + }, + "purchase_from": { + "description": "PurchaseFrom holds the value of the \"purchase_from\" field.", + "type": "string" + }, + "purchase_price": { + "description": "PurchasePrice holds the value of the \"purchase_price\" field.", + "type": "number" + }, + "purchase_time": { + "description": "PurchaseTime holds the value of the \"purchase_time\" field.", + "type": "string" + }, + "quantity": { + "description": "Quantity holds the value of the \"quantity\" field.", + "type": "integer" + }, + "serial_number": { + "description": "SerialNumber holds the value of the \"serial_number\" field.", + "type": "string" + }, + "sold_notes": { + "description": "SoldNotes holds the value of the \"sold_notes\" field.", + "type": "string" + }, + "sold_price": { + "description": "SoldPrice holds the value of the \"sold_price\" field.", + "type": "number" + }, + "sold_time": { + "description": "SoldTime holds the value of the \"sold_time\" field.", + "type": "string" + }, + "sold_to": { + "description": "SoldTo holds the value of the \"sold_to\" field.", + "type": "string" + }, + "sync_child_items_locations": { + "description": "SyncChildItemsLocations holds the value of the \"sync_child_items_locations\" field.", + "type": "boolean" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + }, + "warranty_details": { + "description": "WarrantyDetails holds the value of the \"warranty_details\" field.", + "type": "string" + }, + "warranty_expires": { + "description": "WarrantyExpires holds the value of the \"warranty_expires\" field.", + "type": "string" + } + } + }, + "ent.ItemEdges": { + "type": "object", + "properties": { + "attachments": { + "description": "Attachments holds the value of the attachments edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Attachment" + } + }, + "children": { + "description": "Children holds the value of the children edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Item" + } + }, + "fields": { + "description": "Fields holds the value of the fields edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.ItemField" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "label": { + "description": "Label holds the value of the label edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Label" + } + }, + "location": { + "description": "Location holds the value of the location edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Location" + } + ] + }, + "maintenance_entries": { + "description": "MaintenanceEntries holds the value of the maintenance_entries edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.MaintenanceEntry" + } + }, + "parent": { + "description": "Parent holds the value of the parent edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Item" + } + ] + } + } + }, + "ent.ItemField": { + "type": "object", + "properties": { + "boolean_value": { + "description": "BooleanValue holds the value of the \"boolean_value\" field.", + "type": "boolean" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemFieldQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.ItemFieldEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "number_value": { + "description": "NumberValue holds the value of the \"number_value\" field.", + "type": "integer" + }, + "text_value": { + "description": "TextValue holds the value of the \"text_value\" field.", + "type": "string" + }, + "time_value": { + "description": "TimeValue holds the value of the \"time_value\" field.", + "type": "string" + }, + "type": { + "description": "Type holds the value of the \"type\" field.", + "allOf": [ + { + "$ref": "#/definitions/itemfield.Type" + } + ] + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.ItemFieldEdges": { + "type": "object", + "properties": { + "item": { + "description": "Item holds the value of the item edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Item" + } + ] + } + } + }, + "ent.ItemTemplate": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "default_description": { + "description": "Default description for items created from this template", + "type": "string" + }, + "default_insured": { + "description": "DefaultInsured holds the value of the \"default_insured\" field.", + "type": "boolean" + }, + "default_label_ids": { + "description": "Default label IDs for items created from this template", + "type": "array", + "items": { + "type": "string" + } + }, + "default_lifetime_warranty": { + "description": "DefaultLifetimeWarranty holds the value of the \"default_lifetime_warranty\" field.", + "type": "boolean" + }, + "default_manufacturer": { + "description": "DefaultManufacturer holds the value of the \"default_manufacturer\" field.", + "type": "string" + }, + "default_model_number": { + "description": "Default model number for items created from this template", + "type": "string" + }, + "default_name": { + "description": "Default name template for items (can use placeholders)", + "type": "string" + }, + "default_quantity": { + "description": "DefaultQuantity holds the value of the \"default_quantity\" field.", + "type": "integer" + }, + "default_warranty_details": { + "description": "DefaultWarrantyDetails holds the value of the \"default_warranty_details\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemTemplateQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.ItemTemplateEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "include_purchase_fields": { + "description": "Whether to include purchase fields in items created from this template", + "type": "boolean" + }, + "include_sold_fields": { + "description": "Whether to include sold fields in items created from this template", + "type": "boolean" + }, + "include_warranty_fields": { + "description": "Whether to include warranty fields in items created from this template", + "type": "boolean" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "notes": { + "description": "Notes holds the value of the \"notes\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.ItemTemplateEdges": { + "type": "object", + "properties": { + "fields": { + "description": "Fields holds the value of the fields edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.TemplateField" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "location": { + "description": "Location holds the value of the location edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Location" + } + ] + } + } + }, + "ent.Label": { + "type": "object", + "properties": { + "color": { + "description": "Color holds the value of the \"color\" field.", + "type": "string" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LabelQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.LabelEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.LabelEdges": { + "type": "object", + "properties": { + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "items": { + "description": "Items holds the value of the items edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Item" + } + } + } + }, + "ent.Location": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the LocationQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.LocationEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.LocationEdges": { + "type": "object", + "properties": { + "children": { + "description": "Children holds the value of the children edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Location" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "items": { + "description": "Items holds the value of the items edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Item" + } + }, + "parent": { + "description": "Parent holds the value of the parent edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Location" + } + ] + } + } + }, + "ent.MaintenanceEntry": { + "type": "object", + "properties": { + "cost": { + "description": "Cost holds the value of the \"cost\" field.", + "type": "number" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "date": { + "description": "Date holds the value of the \"date\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the MaintenanceEntryQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.MaintenanceEntryEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "item_id": { + "description": "ItemID holds the value of the \"item_id\" field.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "scheduled_date": { + "description": "ScheduledDate holds the value of the \"scheduled_date\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.MaintenanceEntryEdges": { + "type": "object", + "properties": { + "item": { + "description": "Item holds the value of the item edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Item" + } + ] + } + } + }, + "ent.Notifier": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the NotifierQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.NotifierEdges" + } + ] + }, + "group_id": { + "description": "GroupID holds the value of the \"group_id\" field.", + "type": "string" + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "is_active": { + "description": "IsActive holds the value of the \"is_active\" field.", + "type": "boolean" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + }, + "user_id": { + "description": "UserID holds the value of the \"user_id\" field.", + "type": "string" + } + } + }, + "ent.NotifierEdges": { + "type": "object", + "properties": { + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "user": { + "description": "User holds the value of the user edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.User" + } + ] + } + } + }, + "ent.TemplateField": { + "type": "object", + "properties": { + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "description": { + "description": "Description holds the value of the \"description\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the TemplateFieldQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.TemplateFieldEdges" + } + ] + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "text_value": { + "description": "TextValue holds the value of the \"text_value\" field.", + "type": "string" + }, + "type": { + "description": "Type holds the value of the \"type\" field.", + "allOf": [ + { + "$ref": "#/definitions/templatefield.Type" + } + ] + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.TemplateFieldEdges": { + "type": "object", + "properties": { + "item_template": { + "description": "ItemTemplate holds the value of the item_template edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.ItemTemplate" + } + ] + } + } + }, + "ent.User": { + "type": "object", + "properties": { + "activated_on": { + "description": "ActivatedOn holds the value of the \"activated_on\" field.", + "type": "string" + }, + "created_at": { + "description": "CreatedAt holds the value of the \"created_at\" field.", + "type": "string" + }, + "edges": { + "description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the UserQuery when eager-loading is set.", + "allOf": [ + { + "$ref": "#/definitions/ent.UserEdges" + } + ] + }, + "email": { + "description": "Email holds the value of the \"email\" field.", + "type": "string" + }, + "id": { + "description": "ID of the ent.", + "type": "string" + }, + "is_superuser": { + "description": "IsSuperuser holds the value of the \"is_superuser\" field.", + "type": "boolean" + }, + "name": { + "description": "Name holds the value of the \"name\" field.", + "type": "string" + }, + "oidc_issuer": { + "description": "OidcIssuer holds the value of the \"oidc_issuer\" field.", + "type": "string" + }, + "oidc_subject": { + "description": "OidcSubject holds the value of the \"oidc_subject\" field.", + "type": "string" + }, + "role": { + "description": "Role holds the value of the \"role\" field.", + "allOf": [ + { + "$ref": "#/definitions/user.Role" + } + ] + }, + "superuser": { + "description": "Superuser holds the value of the \"superuser\" field.", + "type": "boolean" + }, + "updated_at": { + "description": "UpdatedAt holds the value of the \"updated_at\" field.", + "type": "string" + } + } + }, + "ent.UserEdges": { + "type": "object", + "properties": { + "auth_tokens": { + "description": "AuthTokens holds the value of the auth_tokens edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.AuthTokens" + } + }, + "group": { + "description": "Group holds the value of the group edge.", + "allOf": [ + { + "$ref": "#/definitions/ent.Group" + } + ] + }, + "notifiers": { + "description": "Notifiers holds the value of the notifiers edge.", + "type": "array", + "items": { + "$ref": "#/definitions/ent.Notifier" + } + } + } + }, + "itemfield.Type": { + "type": "string", + "enum": [ + "text", + "number", + "boolean", + "time" + ], + "x-enum-varnames": [ + "TypeText", + "TypeNumber", + "TypeBoolean", + "TypeTime" + ] + }, + "repo.BarcodeProduct": { + "type": "object", + "properties": { + "barcode": { + "type": "string" + }, + "imageBase64": { + "type": "string" + }, + "imageURL": { + "type": "string" + }, + "item": { + "$ref": "#/definitions/repo.ItemCreate" + }, + "manufacturer": { + "type": "string" + }, + "modelNumber": { + "description": "Identifications", + "type": "string" + }, + "notes": { + "description": "Extras", + "type": "string" + }, + "search_engine_name": { + "type": "string" + } + } + }, + "repo.DuplicateOptions": { + "type": "object", + "properties": { + "copyAttachments": { + "type": "boolean" + }, + "copyCustomFields": { + "type": "boolean" + }, + "copyMaintenance": { + "type": "boolean" + }, + "copyPrefix": { + "type": "string" + } + } + }, + "repo.Group": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "currency": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.GroupStatistics": { + "type": "object", + "properties": { + "totalItemPrice": { + "type": "number" + }, + "totalItems": { + "type": "integer" + }, + "totalLabels": { + "type": "integer" + }, + "totalLocations": { + "type": "integer" + }, + "totalUsers": { + "type": "integer" + }, + "totalWithWarranty": { + "type": "integer" + } + } + }, + "repo.GroupUpdate": { + "type": "object", + "properties": { + "currency": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "repo.ItemAttachment": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "id": { + "type": "string" + }, + "mimeType": { + "type": "string" + }, + "path": { + "type": "string" + }, + "primary": { + "type": "boolean" + }, + "thumbnail": { + "$ref": "#/definitions/ent.Attachment" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemAttachmentUpdate": { + "type": "object", + "properties": { + "primary": { + "type": "boolean" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.ItemCreate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "description": { + "type": "string", + "maxLength": 1000 + }, + "labelIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "locationId": { + "description": "Edges", + "type": "string" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "parentId": { + "type": "string", + "x-nullable": true + }, + "quantity": { + "type": "integer" + } + } + }, + "repo.ItemField": { + "type": "object", + "properties": { + "booleanValue": { + "type": "boolean" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "numberValue": { + "type": "integer" + }, + "textValue": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.ItemOut": { + "type": "object", + "properties": { + "archived": { + "type": "boolean" + }, + "assetId": { + "type": "string", + "example": "0" + }, + "attachments": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemAttachment" + } + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemField" + } + }, + "id": { + "type": "string" + }, + "imageId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "insured": { + "type": "boolean" + }, + "labels": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.LabelSummary" + } + }, + "lifetimeWarranty": { + "description": "Warranty", + "type": "boolean" + }, + "location": { + "description": "Edges", + "allOf": [ + { + "$ref": "#/definitions/repo.LocationSummary" + } + ], + "x-nullable": true, + "x-omitempty": true + }, + "manufacturer": { + "type": "string" + }, + "modelNumber": { + "type": "string" + }, + "name": { + "type": "string" + }, + "notes": { + "description": "Extras", + "type": "string" + }, + "parent": { + "allOf": [ + { + "$ref": "#/definitions/repo.ItemSummary" + } + ], + "x-nullable": true, + "x-omitempty": true + }, + "purchaseFrom": { + "type": "string" + }, + "purchasePrice": { + "type": "number" + }, + "purchaseTime": { + "description": "Purchase", + "type": "string" + }, + "quantity": { + "type": "integer" + }, + "serialNumber": { + "type": "string" + }, + "soldNotes": { + "type": "string" + }, + "soldPrice": { + "type": "number" + }, + "soldTime": { + "description": "Sold", + "type": "string" + }, + "soldTo": { + "type": "string" + }, + "syncChildItemsLocations": { + "type": "boolean" + }, + "thumbnailId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "updatedAt": { + "type": "string" + }, + "warrantyDetails": { + "type": "string" + }, + "warrantyExpires": { + "type": "string" + } + } + }, + "repo.ItemPatch": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "labelIds": { + "type": "array", + "items": { + "type": "string" + }, + "x-nullable": true, + "x-omitempty": true + }, + "locationId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "quantity": { + "type": "integer", + "x-nullable": true, + "x-omitempty": true + } + } + }, + "repo.ItemPath": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "type": { + "$ref": "#/definitions/repo.ItemType" + } + } + }, + "repo.ItemSummary": { + "type": "object", + "properties": { + "archived": { + "type": "boolean" + }, + "assetId": { + "type": "string", + "example": "0" + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "imageId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "insured": { + "type": "boolean" + }, + "labels": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.LabelSummary" + } + }, + "location": { + "description": "Edges", + "allOf": [ + { + "$ref": "#/definitions/repo.LocationSummary" + } + ], + "x-nullable": true, + "x-omitempty": true + }, + "name": { + "type": "string" + }, + "purchasePrice": { + "type": "number" + }, + "quantity": { + "type": "integer" + }, + "soldTime": { + "description": "Sale details", + "type": "string" + }, + "thumbnailId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemTemplateCreate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "defaultDescription": { + "type": "string", + "maxLength": 1000, + "x-nullable": true + }, + "defaultInsured": { + "type": "boolean" + }, + "defaultLabelIds": { + "type": "array", + "items": { + "type": "string" + }, + "x-nullable": true + }, + "defaultLifetimeWarranty": { + "type": "boolean" + }, + "defaultLocationId": { + "description": "Default location and labels", + "type": "string", + "x-nullable": true + }, + "defaultManufacturer": { + "type": "string", + "maxLength": 255, + "x-nullable": true + }, + "defaultModelNumber": { + "type": "string", + "maxLength": 255, + "x-nullable": true + }, + "defaultName": { + "type": "string", + "maxLength": 255, + "x-nullable": true + }, + "defaultQuantity": { + "description": "Default values for items", + "type": "integer", + "x-nullable": true + }, + "defaultWarrantyDetails": { + "type": "string", + "maxLength": 1000, + "x-nullable": true + }, + "description": { + "type": "string", + "maxLength": 1000 + }, + "fields": { + "description": "Custom fields", + "type": "array", + "items": { + "$ref": "#/definitions/repo.TemplateField" + } + }, + "includePurchaseFields": { + "type": "boolean" + }, + "includeSoldFields": { + "type": "boolean" + }, + "includeWarrantyFields": { + "description": "Metadata flags", + "type": "boolean" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "notes": { + "type": "string", + "maxLength": 1000 + } + } + }, + "repo.ItemTemplateOut": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "defaultDescription": { + "type": "string" + }, + "defaultInsured": { + "type": "boolean" + }, + "defaultLabels": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.TemplateLabelSummary" + } + }, + "defaultLifetimeWarranty": { + "type": "boolean" + }, + "defaultLocation": { + "description": "Default location and labels", + "allOf": [ + { + "$ref": "#/definitions/repo.TemplateLocationSummary" + } + ] + }, + "defaultManufacturer": { + "type": "string" + }, + "defaultModelNumber": { + "type": "string" + }, + "defaultName": { + "type": "string" + }, + "defaultQuantity": { + "description": "Default values for items", + "type": "integer" + }, + "defaultWarrantyDetails": { + "type": "string" + }, + "description": { + "type": "string" + }, + "fields": { + "description": "Custom fields", + "type": "array", + "items": { + "$ref": "#/definitions/repo.TemplateField" + } + }, + "id": { + "type": "string" + }, + "includePurchaseFields": { + "type": "boolean" + }, + "includeSoldFields": { + "type": "boolean" + }, + "includeWarrantyFields": { + "description": "Metadata flags", + "type": "boolean" + }, + "name": { + "type": "string" + }, + "notes": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemTemplateSummary": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.ItemTemplateUpdate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "defaultDescription": { + "type": "string", + "maxLength": 1000, + "x-nullable": true + }, + "defaultInsured": { + "type": "boolean" + }, + "defaultLabelIds": { + "type": "array", + "items": { + "type": "string" + }, + "x-nullable": true + }, + "defaultLifetimeWarranty": { + "type": "boolean" + }, + "defaultLocationId": { + "description": "Default location and labels", + "type": "string", + "x-nullable": true + }, + "defaultManufacturer": { + "type": "string", + "maxLength": 255, + "x-nullable": true + }, + "defaultModelNumber": { + "type": "string", + "maxLength": 255, + "x-nullable": true + }, + "defaultName": { + "type": "string", + "maxLength": 255, + "x-nullable": true + }, + "defaultQuantity": { + "description": "Default values for items", + "type": "integer", + "x-nullable": true + }, + "defaultWarrantyDetails": { + "type": "string", + "maxLength": 1000, + "x-nullable": true + }, + "description": { + "type": "string", + "maxLength": 1000 + }, + "fields": { + "description": "Custom fields", + "type": "array", + "items": { + "$ref": "#/definitions/repo.TemplateField" + } + }, + "id": { + "type": "string" + }, + "includePurchaseFields": { + "type": "boolean" + }, + "includeSoldFields": { + "type": "boolean" + }, + "includeWarrantyFields": { + "description": "Metadata flags", + "type": "boolean" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "notes": { + "type": "string", + "maxLength": 1000 + } + } + }, + "repo.ItemType": { + "type": "string", + "enum": [ + "location", + "item" + ], + "x-enum-varnames": [ + "ItemTypeLocation", + "ItemTypeItem" + ] + }, + "repo.ItemUpdate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "archived": { + "type": "boolean" + }, + "assetId": { + "type": "string" + }, + "description": { + "type": "string", + "maxLength": 1000 + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemField" + } + }, + "id": { + "type": "string" + }, + "insured": { + "type": "boolean" + }, + "labelIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "lifetimeWarranty": { + "description": "Warranty", + "type": "boolean" + }, + "locationId": { + "description": "Edges", + "type": "string" + }, + "manufacturer": { + "type": "string" + }, + "modelNumber": { + "type": "string" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "notes": { + "description": "Extras", + "type": "string" + }, + "parentId": { + "type": "string", + "x-nullable": true, + "x-omitempty": true + }, + "purchaseFrom": { + "type": "string", + "maxLength": 255 + }, + "purchasePrice": { + "type": "number", + "x-nullable": true, + "x-omitempty": true + }, + "purchaseTime": { + "description": "Purchase", + "type": "string" + }, + "quantity": { + "type": "integer" + }, + "serialNumber": { + "description": "Identifications", + "type": "string" + }, + "soldNotes": { + "type": "string" + }, + "soldPrice": { + "type": "number", + "x-nullable": true, + "x-omitempty": true + }, + "soldTime": { + "description": "Sold", + "type": "string" + }, + "soldTo": { + "type": "string", + "maxLength": 255 + }, + "syncChildItemsLocations": { + "type": "boolean" + }, + "warrantyDetails": { + "type": "string" + }, + "warrantyExpires": { + "type": "string" + } + } + }, + "repo.LabelCreate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "color": { + "type": "string" + }, + "description": { + "type": "string", + "maxLength": 1000 + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + } + } + }, + "repo.LabelOut": { + "type": "object", + "properties": { + "color": { + "type": "string" + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.LabelSummary": { + "type": "object", + "properties": { + "color": { + "type": "string" + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.LocationCreate": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "parentId": { + "type": "string", + "x-nullable": true + } + } + }, + "repo.LocationOut": { + "type": "object", + "properties": { + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.LocationSummary" + } + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "parent": { + "$ref": "#/definitions/repo.LocationSummary" + }, + "totalPrice": { + "type": "number" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.LocationOutCount": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "itemCount": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.LocationSummary": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "repo.LocationUpdate": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "parentId": { + "type": "string", + "x-nullable": true + } + } + }, + "repo.MaintenanceEntry": { + "type": "object", + "properties": { + "completedDate": { + "type": "string" + }, + "cost": { + "type": "string", + "example": "0" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "scheduledDate": { + "type": "string" + } + } + }, + "repo.MaintenanceEntryCreate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "completedDate": { + "type": "string" + }, + "cost": { + "type": "string", + "example": "0" + }, + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "scheduledDate": { + "type": "string" + } + } + }, + "repo.MaintenanceEntryUpdate": { + "type": "object", + "properties": { + "completedDate": { + "type": "string" + }, + "cost": { + "type": "string", + "example": "0" + }, + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "scheduledDate": { + "type": "string" + } + } + }, + "repo.MaintenanceEntryWithDetails": { + "type": "object", + "properties": { + "completedDate": { + "type": "string" + }, + "cost": { + "type": "string", + "example": "0" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "itemID": { + "type": "string" + }, + "itemName": { + "type": "string" + }, + "name": { + "type": "string" + }, + "scheduledDate": { + "type": "string" + } + } + }, + "repo.MaintenanceFilterStatus": { + "type": "string", + "enum": [ + "scheduled", + "completed", + "both" + ], + "x-enum-varnames": [ + "MaintenanceFilterStatusScheduled", + "MaintenanceFilterStatusCompleted", + "MaintenanceFilterStatusBoth" + ] + }, + "repo.NotifierCreate": { + "type": "object", + "required": [ + "name", + "url" + ], + "properties": { + "isActive": { + "type": "boolean" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "url": { + "type": "string" + } + } + }, + "repo.NotifierOut": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "groupId": { + "type": "string" + }, + "id": { + "type": "string" + }, + "isActive": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "updatedAt": { + "type": "string" + }, + "url": { + "type": "string" + }, + "userId": { + "type": "string" + } + } + }, + "repo.NotifierUpdate": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "isActive": { + "type": "boolean" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "url": { + "type": "string", + "x-nullable": true + } + } + }, + "repo.PaginationResult-repo_ItemSummary": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ItemSummary" + } + }, + "page": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + }, + "total": { + "type": "integer" + } + } + }, + "repo.TemplateField": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "textValue": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.TemplateLabelSummary": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "repo.TemplateLocationSummary": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "repo.TotalsByOrganizer": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "total": { + "type": "number" + } + } + }, + "repo.TreeItem": { + "type": "object", + "properties": { + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.TreeItem" + } + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repo.UserOut": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "groupId": { + "type": "string" + }, + "groupName": { + "type": "string" + }, + "id": { + "type": "string" + }, + "isOwner": { + "type": "boolean" + }, + "isSuperuser": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "oidcIssuer": { + "type": "string" + }, + "oidcSubject": { + "type": "string" + } + } + }, + "repo.UserUpdate": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "repo.ValueOverTime": { + "type": "object", + "properties": { + "end": { + "type": "string" + }, + "entries": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ValueOverTimeEntry" + } + }, + "start": { + "type": "string" + }, + "valueAtEnd": { + "type": "number" + }, + "valueAtStart": { + "type": "number" + } + } + }, + "repo.ValueOverTimeEntry": { + "type": "object", + "properties": { + "date": { + "type": "string" + }, + "name": { + "type": "string" + }, + "value": { + "type": "number" + } + } + }, + "services.Latest": { + "type": "object", + "properties": { + "date": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, + "services.UserRegistration": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "name": { + "type": "string" + }, + "password": { + "type": "string" + }, + "token": { + "type": "string" + } + } + }, + "templatefield.Type": { + "type": "string", + "enum": [ + "text" + ], + "x-enum-varnames": [ + "TypeText" + ] + }, + "user.Role": { + "type": "string", + "enum": [ + "user", + "user", + "owner" + ], + "x-enum-varnames": [ + "DefaultRole", + "RoleUser", + "RoleOwner" + ] + }, + "v1.APISummary": { + "type": "object", + "properties": { + "allowRegistration": { + "type": "boolean" + }, + "build": { + "$ref": "#/definitions/v1.Build" + }, + "demo": { + "type": "boolean" + }, + "health": { + "type": "boolean" + }, + "labelPrinting": { + "type": "boolean" + }, + "latest": { + "$ref": "#/definitions/services.Latest" + }, + "message": { + "type": "string" + }, + "oidc": { + "$ref": "#/definitions/v1.OIDCStatus" + }, + "title": { + "type": "string" + }, + "versions": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "v1.ActionAmountResult": { + "type": "object", + "properties": { + "completed": { + "type": "integer" + } + } + }, + "v1.Build": { + "type": "object", + "properties": { + "buildTime": { + "type": "string" + }, + "commit": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, + "v1.ChangePassword": { + "type": "object", + "properties": { + "current": { + "type": "string" + }, + "new": { + "type": "string" + } + } + }, + "v1.GroupInvitation": { + "type": "object", + "properties": { + "expiresAt": { + "type": "string" + }, + "token": { + "type": "string" + }, + "uses": { + "type": "integer" + } + } + }, + "v1.GroupInvitationCreate": { + "type": "object", + "required": [ + "uses" + ], + "properties": { + "expiresAt": { + "type": "string" + }, + "uses": { + "type": "integer", + "maximum": 100, + "minimum": 1 + } + } + }, + "v1.ItemAttachmentToken": { + "type": "object", + "properties": { + "token": { + "type": "string" + } + } + }, + "v1.ItemTemplateCreateItemRequest": { + "type": "object", + "required": [ + "locationId", + "name" + ], + "properties": { + "description": { + "type": "string", + "maxLength": 1000 + }, + "labelIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "locationId": { + "type": "string" + }, + "name": { + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "quantity": { + "type": "integer" + } + } + }, + "v1.LoginForm": { + "type": "object", + "properties": { + "password": { + "type": "string", + "example": "admin" + }, + "stayLoggedIn": { + "type": "boolean" + }, + "username": { + "type": "string", + "example": "admin@admin.com" + } + } + }, + "v1.OIDCStatus": { + "type": "object", + "properties": { + "allowLocal": { + "type": "boolean" + }, + "autoRedirect": { + "type": "boolean" + }, + "buttonText": { + "type": "string" + }, + "enabled": { + "type": "boolean" + } + } + }, + "v1.TokenResponse": { + "type": "object", + "properties": { + "attachmentToken": { + "type": "string" + }, + "expiresAt": { + "type": "string" + }, + "token": { + "type": "string" + } + } + }, + "v1.Wrapped": { + "type": "object", + "properties": { + "item": {} + } + }, + "validate.ErrorResponse": { + "type": "object", + "properties": { + "error": { + "type": "string" + }, + "fields": { + "type": "string" + } + } + } + }, + "securityDefinitions": { + "Bearer": { + "description": "\"Type 'Bearer TOKEN' to correctly set the API Key\"", + "type": "apiKey", + "name": "Authorization", + "in": "header" + } + } +} \ No newline at end of file diff --git a/docs/en/api/swagger-2.0.yaml b/docs/en/api/swagger-2.0.yaml index 2e123553..d18a8f45 100644 --- a/docs/en/api/swagger-2.0.yaml +++ b/docs/en/api/swagger-2.0.yaml @@ -79,10 +79,10 @@ definitions: type: object ent.AttachmentEdges: properties: - entity: + item: allOf: - - $ref: '#/definitions/ent.Entity' - description: Entity holds the value of the entity edge. + - $ref: '#/definitions/ent.Item' + description: Item holds the value of the item edge. thumbnail: allOf: - $ref: '#/definitions/ent.Attachment' @@ -148,7 +148,105 @@ definitions: - $ref: '#/definitions/ent.User' description: User holds the value of the user edge. type: object - ent.Entity: + ent.Group: + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + currency: + description: Currency holds the value of the "currency" field. + type: string + edges: + allOf: + - $ref: '#/definitions/ent.GroupEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the GroupQuery when eager-loading is set. + id: + description: ID of the ent. + type: string + name: + description: Name holds the value of the "name" field. + type: string + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + type: object + ent.GroupEdges: + properties: + invitation_tokens: + description: InvitationTokens holds the value of the invitation_tokens edge. + items: + $ref: '#/definitions/ent.GroupInvitationToken' + type: array + item_templates: + description: ItemTemplates holds the value of the item_templates edge. + items: + $ref: '#/definitions/ent.ItemTemplate' + type: array + items: + description: Items holds the value of the items edge. + items: + $ref: '#/definitions/ent.Item' + type: array + labels: + description: Labels holds the value of the labels edge. + items: + $ref: '#/definitions/ent.Label' + type: array + locations: + description: Locations holds the value of the locations edge. + items: + $ref: '#/definitions/ent.Location' + type: array + notifiers: + description: Notifiers holds the value of the notifiers edge. + items: + $ref: '#/definitions/ent.Notifier' + type: array + users: + description: Users holds the value of the users edge. + items: + $ref: '#/definitions/ent.User' + type: array + type: object + ent.GroupInvitationToken: + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + edges: + allOf: + - $ref: '#/definitions/ent.GroupInvitationTokenEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the GroupInvitationTokenQuery when eager-loading is set. + expires_at: + description: ExpiresAt holds the value of the "expires_at" field. + type: string + id: + description: ID of the ent. + type: string + token: + description: Token holds the value of the "token" field. + items: + type: integer + type: array + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + uses: + description: Uses holds the value of the "uses" field. + type: integer + type: object + ent.GroupInvitationTokenEdges: + properties: + group: + allOf: + - $ref: '#/definitions/ent.Group' + description: Group holds the value of the group edge. + type: object + ent.Item: properties: archived: description: Archived holds the value of the "archived" field. @@ -164,10 +262,10 @@ definitions: type: string edges: allOf: - - $ref: '#/definitions/ent.EntityEdges' + - $ref: '#/definitions/ent.ItemEdges' description: |- Edges holds the relations/edges for other nodes in the graph. - The values are being populated by the EntityQuery when eager-loading is set. + The values are being populated by the ItemQuery when eager-loading is set. id: description: ID of the ent. type: string @@ -219,8 +317,8 @@ definitions: sold_to: description: SoldTo holds the value of the "sold_to" field. type: string - sync_child_entities_locations: - description: SyncChildEntitiesLocations holds the value of the "sync_child_entities_locations" + sync_child_items_locations: + description: SyncChildItemsLocations holds the value of the "sync_child_items_locations" field. type: boolean updated_at: @@ -233,7 +331,7 @@ definitions: description: WarrantyExpires holds the value of the "warranty_expires" field. type: string type: object - ent.EntityEdges: + ent.ItemEdges: properties: attachments: description: Attachments holds the value of the attachments edge. @@ -243,17 +341,12 @@ definitions: children: description: Children holds the value of the children edge. items: - $ref: '#/definitions/ent.Entity' - type: array - entity: - description: Entity holds the value of the entity edge. - items: - $ref: '#/definitions/ent.Entity' + $ref: '#/definitions/ent.Item' type: array fields: description: Fields holds the value of the fields edge. items: - $ref: '#/definitions/ent.EntityField' + $ref: '#/definitions/ent.ItemField' type: array group: allOf: @@ -266,7 +359,7 @@ definitions: type: array location: allOf: - - $ref: '#/definitions/ent.Entity' + - $ref: '#/definitions/ent.Location' description: Location holds the value of the location edge. maintenance_entries: description: MaintenanceEntries holds the value of the maintenance_entries @@ -276,14 +369,10 @@ definitions: type: array parent: allOf: - - $ref: '#/definitions/ent.Entity' + - $ref: '#/definitions/ent.Item' description: Parent holds the value of the parent edge. - type: - allOf: - - $ref: '#/definitions/ent.EntityType' - description: Type holds the value of the type edge. type: object - ent.EntityField: + ent.ItemField: properties: boolean_value: description: BooleanValue holds the value of the "boolean_value" field. @@ -296,10 +385,10 @@ definitions: type: string edges: allOf: - - $ref: '#/definitions/ent.EntityFieldEdges' + - $ref: '#/definitions/ent.ItemFieldEdges' description: |- Edges holds the relations/edges for other nodes in the graph. - The values are being populated by the EntityFieldQuery when eager-loading is set. + The values are being populated by the ItemFieldQuery when eager-loading is set. id: description: ID of the ent. type: string @@ -317,156 +406,104 @@ definitions: type: string type: allOf: - - $ref: '#/definitions/entityfield.Type' + - $ref: '#/definitions/itemfield.Type' description: Type holds the value of the "type" field. updated_at: description: UpdatedAt holds the value of the "updated_at" field. type: string type: object - ent.EntityFieldEdges: + ent.ItemFieldEdges: properties: - entity: + item: allOf: - - $ref: '#/definitions/ent.Entity' - description: Entity holds the value of the entity edge. + - $ref: '#/definitions/ent.Item' + description: Item holds the value of the item edge. type: object - ent.EntityType: + ent.ItemTemplate: properties: - color: - description: Color holds the value of the "color" field. - type: string created_at: description: CreatedAt holds the value of the "created_at" field. type: string + default_description: + description: Default description for items created from this template + type: string + default_insured: + description: DefaultInsured holds the value of the "default_insured" field. + type: boolean + default_label_ids: + description: Default label IDs for items created from this template + items: + type: string + type: array + default_lifetime_warranty: + description: DefaultLifetimeWarranty holds the value of the "default_lifetime_warranty" + field. + type: boolean + default_manufacturer: + description: DefaultManufacturer holds the value of the "default_manufacturer" + field. + type: string + default_model_number: + description: Default model number for items created from this template + type: string + default_name: + description: Default name template for items (can use placeholders) + type: string + default_quantity: + description: DefaultQuantity holds the value of the "default_quantity" field. + type: integer + default_warranty_details: + description: DefaultWarrantyDetails holds the value of the "default_warranty_details" + field. + type: string description: description: Description holds the value of the "description" field. type: string edges: allOf: - - $ref: '#/definitions/ent.EntityTypeEdges' + - $ref: '#/definitions/ent.ItemTemplateEdges' description: |- Edges holds the relations/edges for other nodes in the graph. - The values are being populated by the EntityTypeQuery when eager-loading is set. - icon: - description: Icon holds the value of the "icon" field. - type: string + The values are being populated by the ItemTemplateQuery when eager-loading is set. id: description: ID of the ent. type: string - is_location: - description: IsLocation holds the value of the "is_location" field. + include_purchase_fields: + description: Whether to include purchase fields in items created from this + template + type: boolean + include_sold_fields: + description: Whether to include sold fields in items created from this template + type: boolean + include_warranty_fields: + description: Whether to include warranty fields in items created from this + template type: boolean name: description: Name holds the value of the "name" field. type: string + notes: + description: Notes holds the value of the "notes" field. + type: string updated_at: description: UpdatedAt holds the value of the "updated_at" field. type: string type: object - ent.EntityTypeEdges: + ent.ItemTemplateEdges: properties: - entities: - description: Entities holds the value of the entities edge. + fields: + description: Fields holds the value of the fields edge. items: - $ref: '#/definitions/ent.Entity' + $ref: '#/definitions/ent.TemplateField' type: array group: allOf: - $ref: '#/definitions/ent.Group' description: Group holds the value of the group edge. - type: object - ent.Group: - properties: - created_at: - description: CreatedAt holds the value of the "created_at" field. - type: string - currency: - description: Currency holds the value of the "currency" field. - type: string - edges: + location: allOf: - - $ref: '#/definitions/ent.GroupEdges' - description: |- - Edges holds the relations/edges for other nodes in the graph. - The values are being populated by the GroupQuery when eager-loading is set. - id: - description: ID of the ent. - type: string - name: - description: Name holds the value of the "name" field. - type: string - updated_at: - description: UpdatedAt holds the value of the "updated_at" field. - type: string - type: object - ent.GroupEdges: - properties: - entities: - description: Entities holds the value of the entities edge. - items: - $ref: '#/definitions/ent.Entity' - type: array - entity_types: - description: EntityTypes holds the value of the entity_types edge. - items: - $ref: '#/definitions/ent.EntityType' - type: array - invitation_tokens: - description: InvitationTokens holds the value of the invitation_tokens edge. - items: - $ref: '#/definitions/ent.GroupInvitationToken' - type: array - labels: - description: Labels holds the value of the labels edge. - items: - $ref: '#/definitions/ent.Label' - type: array - notifiers: - description: Notifiers holds the value of the notifiers edge. - items: - $ref: '#/definitions/ent.Notifier' - type: array - users: - description: Users holds the value of the users edge. - items: - $ref: '#/definitions/ent.User' - type: array - type: object - ent.GroupInvitationToken: - properties: - created_at: - description: CreatedAt holds the value of the "created_at" field. - type: string - edges: - allOf: - - $ref: '#/definitions/ent.GroupInvitationTokenEdges' - description: |- - Edges holds the relations/edges for other nodes in the graph. - The values are being populated by the GroupInvitationTokenQuery when eager-loading is set. - expires_at: - description: ExpiresAt holds the value of the "expires_at" field. - type: string - id: - description: ID of the ent. - type: string - token: - description: Token holds the value of the "token" field. - items: - type: integer - type: array - updated_at: - description: UpdatedAt holds the value of the "updated_at" field. - type: string - uses: - description: Uses holds the value of the "uses" field. - type: integer - type: object - ent.GroupInvitationTokenEdges: - properties: - group: - allOf: - - $ref: '#/definitions/ent.Group' - description: Group holds the value of the group edge. + - $ref: '#/definitions/ent.Location' + description: Location holds the value of the location edge. type: object ent.Label: properties: @@ -497,15 +534,60 @@ definitions: type: object ent.LabelEdges: properties: - entities: - description: Entities holds the value of the entities edge. + group: + allOf: + - $ref: '#/definitions/ent.Group' + description: Group holds the value of the group edge. + items: + description: Items holds the value of the items edge. items: - $ref: '#/definitions/ent.Entity' + $ref: '#/definitions/ent.Item' + type: array + type: object + ent.Location: + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + description: + description: Description holds the value of the "description" field. + type: string + edges: + allOf: + - $ref: '#/definitions/ent.LocationEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the LocationQuery when eager-loading is set. + id: + description: ID of the ent. + type: string + name: + description: Name holds the value of the "name" field. + type: string + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + type: object + ent.LocationEdges: + properties: + children: + description: Children holds the value of the children edge. + items: + $ref: '#/definitions/ent.Location' type: array group: allOf: - $ref: '#/definitions/ent.Group' description: Group holds the value of the group edge. + items: + description: Items holds the value of the items edge. + items: + $ref: '#/definitions/ent.Item' + type: array + parent: + allOf: + - $ref: '#/definitions/ent.Location' + description: Parent holds the value of the parent edge. type: object ent.MaintenanceEntry: properties: @@ -527,12 +609,12 @@ definitions: description: |- Edges holds the relations/edges for other nodes in the graph. The values are being populated by the MaintenanceEntryQuery when eager-loading is set. - entity_id: - description: EntityID holds the value of the "entity_id" field. - type: string id: description: ID of the ent. type: string + item_id: + description: ItemID holds the value of the "item_id" field. + type: string name: description: Name holds the value of the "name" field. type: string @@ -545,10 +627,10 @@ definitions: type: object ent.MaintenanceEntryEdges: properties: - entity: + item: allOf: - - $ref: '#/definitions/ent.Entity' - description: Entity holds the value of the entity edge. + - $ref: '#/definitions/ent.Item' + description: Item holds the value of the item edge. type: object ent.Notifier: properties: @@ -591,6 +673,44 @@ definitions: - $ref: '#/definitions/ent.User' description: User holds the value of the user edge. type: object + ent.TemplateField: + properties: + created_at: + description: CreatedAt holds the value of the "created_at" field. + type: string + description: + description: Description holds the value of the "description" field. + type: string + edges: + allOf: + - $ref: '#/definitions/ent.TemplateFieldEdges' + description: |- + Edges holds the relations/edges for other nodes in the graph. + The values are being populated by the TemplateFieldQuery when eager-loading is set. + id: + description: ID of the ent. + type: string + name: + description: Name holds the value of the "name" field. + type: string + text_value: + description: TextValue holds the value of the "text_value" field. + type: string + type: + allOf: + - $ref: '#/definitions/templatefield.Type' + description: Type holds the value of the "type" field. + updated_at: + description: UpdatedAt holds the value of the "updated_at" field. + type: string + type: object + ent.TemplateFieldEdges: + properties: + item_template: + allOf: + - $ref: '#/definitions/ent.ItemTemplate' + description: ItemTemplate holds the value of the item_template edge. + type: object ent.User: properties: activated_on: @@ -617,6 +737,12 @@ definitions: name: description: Name holds the value of the "name" field. type: string + oidc_issuer: + description: OidcIssuer holds the value of the "oidc_issuer" field. + type: string + oidc_subject: + description: OidcSubject holds the value of the "oidc_subject" field. + type: string role: allOf: - $ref: '#/definitions/user.Role' @@ -645,7 +771,7 @@ definitions: $ref: '#/definitions/ent.Notifier' type: array type: object - entityfield.Type: + itemfield.Type: enum: - text - number @@ -689,82 +815,6 @@ definitions: copyPrefix: type: string type: object - repo.EntityAttachment: - properties: - createdAt: - type: string - id: - type: string - mimeType: - type: string - path: - type: string - primary: - type: boolean - thumbnail: - $ref: '#/definitions/ent.Attachment' - title: - type: string - type: - type: string - updatedAt: - type: string - type: object - repo.EntityAttachmentUpdate: - properties: - primary: - type: boolean - title: - type: string - type: - type: string - type: object - repo.EntityType: - properties: - color: - type: string - description: - type: string - icon: - type: string - isLocation: - type: boolean - name: - type: string - type: object - repo.EntityTypeCreate: - properties: - color: - type: string - description: - type: string - icon: - type: string - isLocation: - type: boolean - name: - type: string - required: - - isLocation - - name - type: object - repo.EntityTypeDelete: - properties: - replacementId: - $ref: '#/definitions/uuid.NullUUID' - type: object - repo.EntityTypeUpdate: - properties: - color: - type: string - description: - type: string - icon: - type: string - name: - minLength: 1 - type: string - type: object repo.Group: properties: createdAt: @@ -800,13 +850,41 @@ definitions: name: type: string type: object + repo.ItemAttachment: + properties: + createdAt: + type: string + id: + type: string + mimeType: + type: string + path: + type: string + primary: + type: boolean + thumbnail: + $ref: '#/definitions/ent.Attachment' + title: + type: string + type: + type: string + updatedAt: + type: string + type: object + repo.ItemAttachmentUpdate: + properties: + primary: + type: boolean + title: + type: string + type: + type: string + type: object repo.ItemCreate: properties: description: maxLength: 1000 type: string - entityType: - type: string labelIds: items: type: string @@ -824,7 +902,6 @@ definitions: quantity: type: integer required: - - entityType - name type: object repo.ItemField: @@ -851,14 +928,12 @@ definitions: type: string attachments: items: - $ref: '#/definitions/repo.EntityAttachment' + $ref: '#/definitions/repo.ItemAttachment' type: array createdAt: type: string description: type: string - entityType: - type: string fields: items: $ref: '#/definitions/repo.ItemField' @@ -970,8 +1045,6 @@ definitions: type: string description: type: string - entityType: - type: string id: type: string imageId: @@ -1006,16 +1079,207 @@ definitions: updatedAt: type: string type: object + repo.ItemTemplateCreate: + properties: + defaultDescription: + maxLength: 1000 + type: string + x-nullable: true + defaultInsured: + type: boolean + defaultLabelIds: + items: + type: string + type: array + x-nullable: true + defaultLifetimeWarranty: + type: boolean + defaultLocationId: + description: Default location and labels + type: string + x-nullable: true + defaultManufacturer: + maxLength: 255 + type: string + x-nullable: true + defaultModelNumber: + maxLength: 255 + type: string + x-nullable: true + defaultName: + maxLength: 255 + type: string + x-nullable: true + defaultQuantity: + description: Default values for items + type: integer + x-nullable: true + defaultWarrantyDetails: + maxLength: 1000 + type: string + x-nullable: true + description: + maxLength: 1000 + type: string + fields: + description: Custom fields + items: + $ref: '#/definitions/repo.TemplateField' + type: array + includePurchaseFields: + type: boolean + includeSoldFields: + type: boolean + includeWarrantyFields: + description: Metadata flags + type: boolean + name: + maxLength: 255 + minLength: 1 + type: string + notes: + maxLength: 1000 + type: string + required: + - name + type: object + repo.ItemTemplateOut: + properties: + createdAt: + type: string + defaultDescription: + type: string + defaultInsured: + type: boolean + defaultLabels: + items: + $ref: '#/definitions/repo.TemplateLabelSummary' + type: array + defaultLifetimeWarranty: + type: boolean + defaultLocation: + allOf: + - $ref: '#/definitions/repo.TemplateLocationSummary' + description: Default location and labels + defaultManufacturer: + type: string + defaultModelNumber: + type: string + defaultName: + type: string + defaultQuantity: + description: Default values for items + type: integer + defaultWarrantyDetails: + type: string + description: + type: string + fields: + description: Custom fields + items: + $ref: '#/definitions/repo.TemplateField' + type: array + id: + type: string + includePurchaseFields: + type: boolean + includeSoldFields: + type: boolean + includeWarrantyFields: + description: Metadata flags + type: boolean + name: + type: string + notes: + type: string + updatedAt: + type: string + type: object + repo.ItemTemplateSummary: + properties: + createdAt: + type: string + description: + type: string + id: + type: string + name: + type: string + updatedAt: + type: string + type: object + repo.ItemTemplateUpdate: + properties: + defaultDescription: + maxLength: 1000 + type: string + x-nullable: true + defaultInsured: + type: boolean + defaultLabelIds: + items: + type: string + type: array + x-nullable: true + defaultLifetimeWarranty: + type: boolean + defaultLocationId: + description: Default location and labels + type: string + x-nullable: true + defaultManufacturer: + maxLength: 255 + type: string + x-nullable: true + defaultModelNumber: + maxLength: 255 + type: string + x-nullable: true + defaultName: + maxLength: 255 + type: string + x-nullable: true + defaultQuantity: + description: Default values for items + type: integer + x-nullable: true + defaultWarrantyDetails: + maxLength: 1000 + type: string + x-nullable: true + description: + maxLength: 1000 + type: string + fields: + description: Custom fields + items: + $ref: '#/definitions/repo.TemplateField' + type: array + id: + type: string + includePurchaseFields: + type: boolean + includeSoldFields: + type: boolean + includeWarrantyFields: + description: Metadata flags + type: boolean + name: + maxLength: 255 + minLength: 1 + type: string + notes: + maxLength: 1000 + type: string + required: + - name + type: object repo.ItemType: enum: - location - item - - location - - item type: string x-enum-varnames: - - EntityTypeLocation - - EntityTypeItem - ItemTypeLocation - ItemTypeItem repo.ItemUpdate: @@ -1027,8 +1291,6 @@ definitions: description: maxLength: 1000 type: string - entityType: - type: string fields: items: $ref: '#/definitions/repo.ItemField' @@ -1096,7 +1358,6 @@ definitions: warrantyExpires: type: string required: - - entityType - name type: object repo.LabelCreate: @@ -1147,15 +1408,11 @@ definitions: properties: description: type: string - entityType: - type: string name: type: string parentId: type: string x-nullable: true - required: - - entityType type: object repo.LocationOut: properties: @@ -1167,8 +1424,6 @@ definitions: type: string description: type: string - entityType: - type: string id: type: string name: @@ -1186,8 +1441,6 @@ definitions: type: string description: type: string - entityType: - type: string id: type: string itemCount: @@ -1203,8 +1456,6 @@ definitions: type: string description: type: string - entityType: - type: string id: type: string name: @@ -1216,8 +1467,6 @@ definitions: properties: description: type: string - entityType: - type: string id: type: string name: @@ -1225,8 +1474,6 @@ definitions: parentId: type: string x-nullable: true - required: - - entityType type: object repo.MaintenanceEntry: properties: @@ -1364,6 +1611,31 @@ definitions: total: type: integer type: object + repo.TemplateField: + properties: + id: + type: string + name: + type: string + textValue: + type: string + type: + type: string + type: object + repo.TemplateLabelSummary: + properties: + id: + type: string + name: + type: string + type: object + repo.TemplateLocationSummary: + properties: + id: + type: string + name: + type: string + type: object repo.TotalsByOrganizer: properties: id: @@ -1402,6 +1674,10 @@ definitions: type: boolean name: type: string + oidcIssuer: + type: string + oidcSubject: + type: string type: object repo.UserUpdate: properties: @@ -1452,6 +1728,12 @@ definitions: token: type: string type: object + templatefield.Type: + enum: + - text + type: string + x-enum-varnames: + - TypeText user.Role: enum: - user @@ -1462,14 +1744,6 @@ definitions: - DefaultRole - RoleUser - RoleOwner - uuid.NullUUID: - properties: - uuid: - type: string - valid: - description: Valid is true if UUID is not NULL - type: boolean - type: object v1.APISummary: properties: allowRegistration: @@ -1486,6 +1760,8 @@ definitions: $ref: '#/definitions/services.Latest' message: type: string + oidc: + $ref: '#/definitions/v1.OIDCStatus' title: type: string versions: @@ -1539,6 +1815,27 @@ definitions: token: type: string type: object + v1.ItemTemplateCreateItemRequest: + properties: + description: + maxLength: 1000 + type: string + labelIds: + items: + type: string + type: array + locationId: + type: string + name: + maxLength: 255 + minLength: 1 + type: string + quantity: + type: integer + required: + - locationId + - name + type: object v1.LoginForm: properties: password: @@ -1550,6 +1847,17 @@ definitions: example: admin@admin.com type: string type: object + v1.OIDCStatus: + properties: + allowLocal: + type: boolean + autoRedirect: + type: boolean + buttonText: + type: string + enabled: + type: boolean + type: object v1.TokenResponse: properties: attachmentToken: @@ -1686,287 +1994,6 @@ paths: summary: Currency tags: - Base - /v1/entities/{id}/attachments: - post: - consumes: - - multipart/form-data - parameters: - - description: Item ID - in: path - name: id - required: true - type: string - - description: File attachment - in: formData - name: file - required: true - type: file - - description: Type of file - in: formData - name: type - type: string - - description: Is this the primary attachment - in: formData - name: primary - type: boolean - - description: name of the file including extension - in: formData - name: name - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/repo.ItemOut' - "422": - description: Unprocessable Entity - schema: - $ref: '#/definitions/validate.ErrorResponse' - security: - - Bearer: [] - summary: Create Item Attachment - tags: - - Items Attachments - /v1/entities/{id}/attachments/{attachment_id}: - delete: - parameters: - - description: Item ID - in: path - name: id - required: true - type: string - - description: Attachment ID - in: path - name: attachment_id - required: true - type: string - responses: - "204": - description: No Content - security: - - Bearer: [] - summary: Delete Item Attachment - tags: - - Items Attachments - get: - parameters: - - description: Item ID - in: path - name: id - required: true - type: string - - description: Attachment ID - in: path - name: attachment_id - required: true - type: string - produces: - - application/octet-stream - responses: - "200": - description: OK - schema: - $ref: '#/definitions/v1.ItemAttachmentToken' - security: - - Bearer: [] - summary: Get Item Attachment - tags: - - Items Attachments - put: - parameters: - - description: Item ID - in: path - name: id - required: true - type: string - - description: Attachment ID - in: path - name: attachment_id - required: true - type: string - - description: Attachment Update - in: body - name: payload - required: true - schema: - $ref: '#/definitions/repo.EntityAttachmentUpdate' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/repo.ItemOut' - security: - - Bearer: [] - summary: Update Item Attachment - tags: - - Items Attachments - /v1/entities/{id}/maintenance: - get: - parameters: - - description: Item ID - in: path - name: id - required: true - type: string - - enum: - - scheduled - - completed - - both - in: query - name: status - type: string - x-enum-varnames: - - MaintenanceFilterStatusScheduled - - MaintenanceFilterStatusCompleted - - MaintenanceFilterStatusBoth - produces: - - application/json - responses: - "200": - description: OK - schema: - items: - $ref: '#/definitions/repo.MaintenanceEntryWithDetails' - type: array - security: - - Bearer: [] - summary: Get Maintenance Log - tags: - - Item Maintenance - post: - parameters: - - description: Item ID - in: path - name: id - required: true - type: string - - description: Entry Data - in: body - name: payload - required: true - schema: - $ref: '#/definitions/repo.MaintenanceEntryCreate' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/repo.MaintenanceEntry' - security: - - Bearer: [] - summary: Create Maintenance Entry - tags: - - Item Maintenance - /v1/entitytype: - get: - produces: - - application/json - responses: - "200": - description: OK - schema: - items: - $ref: '#/definitions/repo.EntityType' - type: array - security: - - Bearer: [] - summary: Query All Entity Types - tags: - - EntityTypes - post: - consumes: - - application/json - parameters: - - description: Entity Type Data - in: body - name: payload - required: true - schema: - $ref: '#/definitions/repo.EntityTypeCreate' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/repo.EntityType' - security: - - Bearer: [] - summary: Create Entity Type - tags: - - EntityTypes - /v1/entitytype/{id}: - delete: - parameters: - - description: Entity Type ID - in: path - name: id - required: true - type: string - - description: Entity Type Delete Options - in: body - name: payload - required: true - schema: - $ref: '#/definitions/repo.EntityTypeDelete' - responses: - "204": - description: No Content - security: - - Bearer: [] - summary: Delete Entity Type - tags: - - EntityTypes - get: - parameters: - - description: Entity Type ID - in: path - name: id - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/repo.EntityType' - security: - - Bearer: [] - summary: Get One Entity Type - tags: - - EntityTypes - put: - consumes: - - application/json - parameters: - - description: Entity Type ID - in: path - name: id - required: true - type: string - - description: Entity Type Data - in: body - name: payload - required: true - schema: - $ref: '#/definitions/repo.EntityTypeUpdate' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/repo.EntityType' - security: - - Bearer: [] - summary: Update Entity Type - tags: - - EntityTypes /v1/groups: get: produces: @@ -2093,7 +2120,6 @@ paths: - Statistics /v1/items: get: - deprecated: true parameters: - description: search string in: query @@ -2137,13 +2163,10 @@ paths: $ref: '#/definitions/repo.PaginationResult-repo_ItemSummary' security: - Bearer: [] - summary: (Deprecated) Query All Items + summary: Query All Items tags: - Items post: - consumes: - - application/json - deprecated: true parameters: - description: Item Data in: body @@ -2165,7 +2188,6 @@ paths: - Items /v1/items/{id}: delete: - deprecated: true parameters: - description: Item ID in: path @@ -2179,11 +2201,10 @@ paths: description: No Content security: - Bearer: [] - summary: (Deprecated) Delete Item + summary: Delete Item tags: - Items get: - deprecated: true parameters: - description: Item ID in: path @@ -2199,11 +2220,10 @@ paths: $ref: '#/definitions/repo.ItemOut' security: - Bearer: [] - summary: (Deprecated) Get Item + summary: Get Item tags: - Items patch: - deprecated: true parameters: - description: Item ID in: path @@ -2225,11 +2245,10 @@ paths: $ref: '#/definitions/repo.ItemOut' security: - Bearer: [] - summary: (Deprecated) Update Item + summary: Update Item tags: - Items put: - deprecated: true parameters: - description: Item ID in: path @@ -2251,14 +2270,13 @@ paths: $ref: '#/definitions/repo.ItemOut' security: - Bearer: [] - summary: (Deprecated) Update Item + summary: Update Item tags: - Items /v1/items/{id}/attachments: post: consumes: - multipart/form-data - deprecated: true parameters: - description: Item ID in: path @@ -2301,7 +2319,6 @@ paths: - Items Attachments /v1/items/{id}/attachments/{attachment_id}: delete: - deprecated: true parameters: - description: Item ID in: path @@ -2322,7 +2339,6 @@ paths: tags: - Items Attachments get: - deprecated: true parameters: - description: Item ID in: path @@ -2347,7 +2363,6 @@ paths: tags: - Items Attachments put: - deprecated: true parameters: - description: Item ID in: path @@ -2364,7 +2379,7 @@ paths: name: payload required: true schema: - $ref: '#/definitions/repo.EntityAttachmentUpdate' + $ref: '#/definitions/repo.ItemAttachmentUpdate' responses: "200": description: OK @@ -2403,7 +2418,6 @@ paths: - Items /v1/items/{id}/maintenance: get: - deprecated: true parameters: - description: Item ID in: path @@ -2436,7 +2450,6 @@ paths: tags: - Item Maintenance post: - deprecated: true parameters: - description: Item ID in: path @@ -2463,7 +2476,6 @@ paths: - Item Maintenance /v1/items/{id}/path: get: - deprecated: true parameters: - description: Item ID in: path @@ -2481,12 +2493,11 @@ paths: type: array security: - Bearer: [] - summary: (Deprecated) Get the full path of an item + summary: Get the full path of an item tags: - Items /v1/items/export: get: - deprecated: true responses: "200": description: text/csv @@ -2494,12 +2505,11 @@ paths: type: string security: - Bearer: [] - summary: (Deprecated) Export Items + summary: Export Items tags: - Items /v1/items/fields: get: - deprecated: true produces: - application/json responses: @@ -2511,12 +2521,11 @@ paths: type: array security: - Bearer: [] - summary: (Deprecated) Get All Custom Field Names + summary: Get All Custom Field Names tags: - Items /v1/items/fields/values: get: - deprecated: true produces: - application/json responses: @@ -2528,14 +2537,13 @@ paths: type: array security: - Bearer: [] - summary: (Deprecated) Get All Custom Field Values + summary: Get All Custom Field Values tags: - Items /v1/items/import: post: consumes: - multipart/form-data - deprecated: true parameters: - description: Image to upload in: formData @@ -2549,7 +2557,7 @@ paths: description: No Content security: - Bearer: [] - summary: (Deprecated) Import Items + summary: Import Items tags: - Items /v1/labelmaker/assets/{id}: @@ -2718,7 +2726,6 @@ paths: - Labels /v1/locations: get: - deprecated: true parameters: - description: Filter locations with parents in: query @@ -2735,11 +2742,10 @@ paths: type: array security: - Bearer: [] - summary: (Deprecated) Get All Locations + summary: Get All Locations tags: - Locations post: - deprecated: true parameters: - description: Location Data in: body @@ -2756,12 +2762,11 @@ paths: $ref: '#/definitions/repo.LocationSummary' security: - Bearer: [] - summary: (Deprecated) Create Location + summary: Create Location tags: - Locations /v1/locations/{id}: delete: - deprecated: true parameters: - description: Location ID in: path @@ -2775,11 +2780,10 @@ paths: description: No Content security: - Bearer: [] - summary: (Deprecated) Delete Location + summary: Delete Location tags: - Locations get: - deprecated: true parameters: - description: Location ID in: path @@ -2795,11 +2799,10 @@ paths: $ref: '#/definitions/repo.LocationOut' security: - Bearer: [] - summary: (Deprecated) Get Location + summary: Get Location tags: - Locations put: - deprecated: true parameters: - description: Location ID in: path @@ -2821,12 +2824,11 @@ paths: $ref: '#/definitions/repo.LocationOut' security: - Bearer: [] - summary: (Deprecated) Update Location + summary: Update Location tags: - Locations /v1/locations/tree: get: - deprecated: true parameters: - description: include items in response tree in: query @@ -2843,7 +2845,7 @@ paths: type: array security: - Bearer: [] - summary: (Deprecated) Get Locations Tree + summary: Get Locations Tree tags: - Locations /v1/maintenance: @@ -3076,6 +3078,130 @@ paths: summary: Application Info tags: - Base + /v1/templates: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/repo.ItemTemplateSummary' + type: array + security: + - Bearer: [] + summary: Get All Item Templates + tags: + - Item Templates + post: + parameters: + - description: Template Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.ItemTemplateCreate' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/repo.ItemTemplateOut' + security: + - Bearer: [] + summary: Create Item Template + tags: + - Item Templates + /v1/templates/{id}: + delete: + parameters: + - description: Template ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "204": + description: No Content + security: + - Bearer: [] + summary: Delete Item Template + tags: + - Item Templates + get: + parameters: + - description: Template ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.ItemTemplateOut' + security: + - Bearer: [] + summary: Get Item Template + tags: + - Item Templates + put: + parameters: + - description: Template ID + in: path + name: id + required: true + type: string + - description: Template Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/repo.ItemTemplateUpdate' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.ItemTemplateOut' + security: + - Bearer: [] + summary: Update Item Template + tags: + - Item Templates + /v1/templates/{id}/create-item: + post: + parameters: + - description: Template ID + in: path + name: id + required: true + type: string + - description: Item Data + in: body + name: payload + required: true + schema: + $ref: '#/definitions/v1.ItemTemplateCreateItemRequest' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/repo.ItemOut' + security: + - Bearer: [] + summary: Create Item from Template + tags: + - Item Templates /v1/users/change-password: put: parameters: @@ -3119,6 +3245,35 @@ paths: summary: User Login tags: - Authentication + /v1/users/login/oidc: + get: + produces: + - application/json + responses: + "302": + description: Found + summary: OIDC Login Initiation + tags: + - Authentication + /v1/users/login/oidc/callback: + get: + parameters: + - description: Authorization code + in: query + name: code + required: true + type: string + - description: State parameter + in: query + name: state + required: true + type: string + responses: + "302": + description: Found + summary: OIDC Callback Handler + tags: + - Authentication /v1/users/logout: post: responses: @@ -3156,6 +3311,10 @@ paths: responses: "204": description: No Content + "403": + description: Local login is not enabled + schema: + type: string summary: Register New User tags: - User diff --git a/docs/en/configure/index.md b/docs/en/configure/index.md index d3fc2cde..aefd460d 100644 --- a/docs/en/configure/index.md +++ b/docs/en/configure/index.md @@ -22,7 +22,7 @@ aside: false | HBOX_WEB_IDLE_TIMEOUT | 30s | Idle timeout of HTTP server | | HBOX_STORAGE_CONN_STRING | file:///./ | path to the data directory, do not change this if you're using docker | | HBOX_STORAGE_PREFIX_PATH | .data | prefix path for the storage, if not set the storage will be used as is | -| HBOX_LOG_LEVEL | `info` | log level to use, can be one of `trace`, `debug`, `info`, `warn`, `error`, `critical` | +| HBOX_LOG_LEVEL | `info` | log level to use, can be one of `trace`, `debug`, `info`, `warn`, `error`, `fatal`, `panic` | | HBOX_LOG_FORMAT | `text` | log format to use, can be one of: `text`, `json` | | HBOX_MAILER_HOST | | email host to use, if not set no email provider will be used | | HBOX_MAILER_PORT | 587 | email port to use | @@ -41,6 +41,24 @@ aside: false | HBOX_DATABASE_SSL_KEY | | sets the sslkey for a postgres connection (should be a path) | | HBOX_DATABASE_SSL_ROOT_CERT | | sets the sslrootcert for a postgres connection (should be a path) | | HBOX_OPTIONS_GITHUB_RELEASE_CHECK | true | check for new github releases | +| HBOX_OPTIONS_ALLOW_LOCAL_LOGIN | true | allow users to login with username/password when OIDC is enabled | +| HBOX_OPTIONS_TRUST_PROXY | false | trust proxy headers for determining request scheme (X-Forwarded-Proto) | +| HBOX_OPTIONS_HOSTNAME | | override hostname used for OIDC redirect URLs and other absolute URLs | +| HBOX_OIDC_ENABLED | false | enable OpenID Connect (OIDC) authentication | +| HBOX_OIDC_ISSUER_URL | | OIDC provider issuer URL (required when OIDC is enabled) | +| HBOX_OIDC_CLIENT_ID | | OIDC client ID (required when OIDC is enabled) | +| HBOX_OIDC_CLIENT_SECRET | | OIDC client secret (required when OIDC is enabled) | +| HBOX_OIDC_SCOPE | openid profile email | OIDC scopes to request from the provider | +| HBOX_OIDC_ALLOWED_GROUPS | | comma-separated list of groups that are allowed to login (empty means all groups allowed) | +| HBOX_OIDC_AUTO_REDIRECT | false | auto redirect to OIDC authentication (automatically redirects to OIDC provider, but does not disable local login. See HBOX_OPTIONS_ALLOW_LOCAL_LOGIN) | +| HBOX_OIDC_VERIFY_EMAIL | false | require email verification from OIDC provider | +| HBOX_OIDC_GROUP_CLAIM | groups | name of the claim in the ID token that contains user groups | +| HBOX_OIDC_EMAIL_CLAIM | email | name of the claim in the ID token that contains user email | +| HBOX_OIDC_NAME_CLAIM | name | name of the claim in the ID token that contains user display name | +| HBOX_OIDC_EMAIL_VERIFIED_CLAIM | email_verified | name of the claim in the ID token that contains user email verification status | +| HBOX_OIDC_BUTTON_TEXT | Sign in with OIDC | text displayed on the OIDC login button | +| HBOX_OIDC_STATE_EXPIRY | 10m | how long OIDC state parameters are valid (for CSRF protection) | +| HBOX_OIDC_REQUEST_TIMEOUT | 30s | timeout for OIDC provider requests (token exchange, userinfo, etc.) | | HBOX_LABEL_MAKER_WIDTH | 526 | width for generated labels in pixels | | HBOX_LABEL_MAKER_HEIGHT | 200 | height for generated labels in pixels | | HBOX_LABEL_MAKER_PADDING | 32 | space between elements on label | @@ -48,9 +66,12 @@ aside: false | HBOX_LABEL_MAKER_PRINT_COMMAND | | the command to use for printing labels. if empty, label printing is disabled. `{{.FileName}}` in the command will be replaced with the png filename of the label | | HBOX_LABEL_MAKER_DYNAMIC_LENGTH | true | allow label generation with open length. `HBOX_LABEL_MAKER_HEIGHT` is still used for layout and minimal height. If not used, long text may be cut off, but all labels have the same size. | | HBOX_LABEL_MAKER_ADDITIONAL_INFORMATION | | Additional information added to the label like name or phone number | +| HBOX_LABEL_MAKER_REGULAR_FONT_PATH | | path to regular font file for label generation (e.g., `/fonts/NotoSansKR-Regular.ttf`). If not set, uses embedded font. Supports TTF format. | +| HBOX_LABEL_MAKER_BOLD_FONT_PATH | | path to bold font file for label generation (e.g., `/fonts/NotoSansKR-Bold.ttf`). If not set, uses embedded font. Supports TTF format. | | HBOX_THUMBNAIL_ENABLED | true | enable thumbnail generation for images, supports PNG, JPEG, AVIF, WEBP, GIF file types | | HBOX_THUMBNAIL_WIDTH | 500 | width for generated thumbnails in pixels | | HBOX_THUMBNAIL_HEIGHT | 500 | height for generated thumbnails in pixels | +| HBOX_BARCODE_TOKEN_BARCODESPIDER | | API token for BarcodeSpider.com service used for barcode product lookups. If not set, barcode product lookups will not be performed. | ### HBOX_WEB_HOST examples @@ -147,55 +168,116 @@ For SQLite in production: - Monitor the file size and consider using a different database for large installations ::: +## OIDC Configuration + +HomeBox supports OpenID Connect (OIDC) authentication, allowing users to login using external identity providers like Keycloak, Authentik, Google, Microsoft, etc. + +### Basic OIDC Setup + +1. **Enable OIDC**: Set `HBOX_OIDC_ENABLED=true` +2. **Provider Configuration**: Set the required provider details: + - `HBOX_OIDC_ISSUER_URL`: Your OIDC provider's issuer URL + - `HBOX_OIDC_CLIENT_ID`: Client ID from your OIDC provider + - `HBOX_OIDC_CLIENT_SECRET`: Client secret from your OIDC provider + +3. **Configure Redirect URI**: In your OIDC provider, set the redirect URI to: + `https://your-homebox-domain.com/api/v1/users/login/oidc/callback` + +### Advanced OIDC Configuration + +- **Group Authorization**: Use `HBOX_OIDC_ALLOWED_GROUPS` to restrict access to specific groups +- **Custom Claims**: Configure `HBOX_OIDC_GROUP_CLAIM`, `HBOX_OIDC_EMAIL_CLAIM`, and `HBOX_OIDC_NAME_CLAIM` if your provider uses different claim names +- **Auto Redirect to OIDC**: Set `HBOX_OIDC_AUTO_REDIRECT=true` to automatically redirect users directly to OIDC +- **Local Login**: Set `HBOX_OPTIONS_ALLOW_LOCAL_LOGIN=false` to completely disable username/password login +- **Email Verification**: Set `HBOX_OIDC_VERIFY_EMAIL=true` to require email verification from the OIDC provider + +### Security Considerations + +::: warning OIDC Security +- Store `HBOX_OIDC_CLIENT_SECRET` securely (use environment variables, not config files) +- Use HTTPS for production deployments +- Configure proper redirect URIs in your OIDC provider +- Consider setting `HBOX_OIDC_ALLOWED_GROUPS` for group-based access control +::: + ::: tip CLI Arguments If you're deploying without docker you can use command line arguments to configure the application. Run `homebox --help` for more information. ```sh -Usage: api [options] [arguments] - -OPTIONS ---mode/$HBOX_MODE (default: development) ---web-port/$HBOX_WEB_PORT (default: 7745) ---web-host/$HBOX_WEB_HOST ---web-max-upload-size/$HBOX_WEB_MAX_UPLOAD_SIZE (default: 10) ---storage-conn-string/$HBOX_STORAGE_CONN_STRING (default: file:///./) ---storage-prefix-path/$HBOX_STORAGE_PREFIX_PATH (default: .data) ---log-level/$HBOX_LOG_LEVEL (default: info) ---log-format/$HBOX_LOG_FORMAT (default: text) ---mailer-host/$HBOX_MAILER_HOST ---mailer-port/$HBOX_MAILER_PORT ---mailer-username/$HBOX_MAILER_USERNAME ---mailer-password/$HBOX_MAILER_PASSWORD ---mailer-from/$HBOX_MAILER_FROM ---demo/$HBOX_DEMO ---debug-enabled/$HBOX_DEBUG_ENABLED (default: false) ---debug-port/$HBOX_DEBUG_PORT (default: 4000) ---database-driver/$HBOX_DATABASE_DRIVER (default: sqlite3) ---database-sqlite-path/$HBOX_DATABASE_SQLITE_PATH (default: ./.data/homebox.db?_pragma=busy_timeout=999&_pragma=journal_mode=WAL&_fk=1&_time_format=sqlite) ---database-host/$HBOX_DATABASE_HOST ---database-port/$HBOX_DATABASE_PORT ---database-username/$HBOX_DATABASE_USERNAME ---database-password/$HBOX_DATABASE_PASSWORD ---database-database/$HBOX_DATABASE_DATABASE ---database-ssl-mode/$HBOX_DATABASE_SSL_MODE (default: prefer) ---options-allow-registration/$HBOX_OPTIONS_ALLOW_REGISTRATION (default: true) ---options-auto-increment-asset-id/$HBOX_OPTIONS_AUTO_INCREMENT_ASSET_ID (default: true) ---options-currency-config/$HBOX_OPTIONS_CURRENCY_CONFIG ---options-github-release-check/$HBOX_OPTIONS_GITHUB_RELEASE_CHECK (default: true) ---options-allow-analytics/$HBOX_OPTIONS_ALLOW_ANALYTICS (default: false) ---label-maker-width/$HBOX_LABEL_MAKER_WIDTH (default: 526) ---label-maker-height/$HBOX_LABEL_MAKER_HEIGHT (default: 200) ---label-maker-padding/$HBOX_LABEL_MAKER_PADDING (default: 32) ---label-maker-margin/$HBOX_LABEL_MAKER_MARGIN (default: 32) ---label-maker-font-size/$HBOX_LABEL_MAKER_FONT_SIZE (default: 32.0) ---label-maker-print-command/$HBOX_LABEL_MAKER_PRINT_COMMAND ---label-maker-dynamic-length/$HBOX_LABEL_MAKER_DYNAMIC_LENGTH (default: true) ---label-maker-additional-information/$HBOX_LABEL_MAKER_ADDITIONAL_INFORMATION ---thumbnail-enabled/$HBOX_THUMBNAIL_ENABLED (default: true) ---thumbnail-width/$HBOX_THUMBNAIL_WIDTH (default: 500) ---thumbnail-height/$HBOX_THUMBNAIL_HEIGHT (default: 500) ---help/-h display this help message +Options: + --barcode-token-barcodespider + --database-database + --database-driver (default: sqlite3) + --database-host + --database-password + --database-port + --database-pub-sub-conn-string (default: mem://{{ .Topic }}) + --database-sqlite-path (default: ./.data/homebox.db?_pragma=busy_timeout=999&_pragma=journal_mode=WAL&_fk=1&_time_format=sqlite) + --database-ssl-cert + --database-ssl-key + --database-ssl-mode (default: require) + --database-ssl-root-cert + --database-username + --debug-enabled (default: false) + --debug-port (default: 4000) + --demo + -h, --help display this help message + --label-maker-additional-information + --label-maker-bold-font-path + --label-maker-dynamic-length (default: true) + --label-maker-font-size (default: 32.0) + --label-maker-height (default: 200) + --label-maker-label-service-timeout + --label-maker-label-service-url + --label-maker-margin (default: 32) + --label-maker-padding (default: 32) + --label-maker-print-command + --label-maker-regular-font-path + --label-maker-width (default: 526) + --log-format (default: text) + --log-level (default: info) + --mailer-from + --mailer-host + --mailer-password + --mailer-port + --mailer-username + --mode (default: development) + --oidc-allowed-groups + --oidc-auto-redirect (default: false) + --oidc-button-text (default: Sign in with OIDC) + --oidc-client-id + --oidc-client-secret + --oidc-email-claim (default: email) + --oidc-email-verified-claim (default: email_verified) + --oidc-enabled (default: false) + --oidc-group-claim (default: groups) + --oidc-issuer-url + --oidc-name-claim (default: name) + --oidc-request-timeout (default: 30s) + --oidc-scope (default: openid profile email) + --oidc-state-expiry (default: 10m) + --oidc-verify-email (default: false) + --options-allow-analytics (default: false) + --options-allow-local-login (default: true) + --options-allow-registration (default: true) + --options-auto-increment-asset-id (default: true) + --options-currency-config + --options-github-release-check (default: true) + --options-hostname + --options-trust-proxy (default: false) + --storage-conn-string (default: file:///./) + --storage-prefix-path (default: .data) + --thumbnail-enabled (default: true) + --thumbnail-height (default: 500) + --thumbnail-width (default: 500) + -v, --version display version + --web-host + --web-idle-timeout (default: 30s) + --web-max-upload-size (default: 10) + --web-port (default: 7745) + --web-read-timeout (default: 10s) + --web-write-timeout (default: 10s) ``` ::: diff --git a/docs/en/configure/storage.md b/docs/en/configure/storage.md index 8268378d..d024cd16 100644 --- a/docs/en/configure/storage.md +++ b/docs/en/configure/storage.md @@ -30,19 +30,19 @@ the bucket name in the connection string. ### S3-Compatible Storage You can also use S3-compatible storage by setting the `HBOX_STORAGE_CONN_STRING` to -`s3://my-bucket?awssdk=v2&endpoint=http://my-s3-compatible-endpoint.tld&disableSSL=true&s3ForcePathStyle=true`. +`s3://my-bucket?awssdk=v2&endpoint=http://my-s3-compatible-endpoint.tld&disable_https=true&s3ForcePathStyle=true`. This allows you to connect to S3-compatible services like MinIO, DigitalOcean Spaces, or any other service that supports -the S3 API. Configure the `disableSSL`, `s3ForcePathStyle`, and `endpoint` parameters as needed for your specific +the S3 API. Configure the `disable_https`, `s3ForcePathStyle`, and `endpoint` parameters as needed for your specific service. #### Tested S3-Compatible Storage | Service | Working | Connection String | |---------------------|---------|--------------------------------------------------------------------------------------------------------------------------| -| MinIO | Yes | `s3://my-bucket?awssdk=v2&endpoint=http://minio:9000&disableSSL=true&s3ForcePathStyle=true` | -| Cloudflare R2 | Yes | `s3://my-bucket?awssdk=v2&endpoint=https://.r2.cloudflarestorage.com&disableSSL=false&s3ForcePathStyle=true` | -| Backblaze B2 | Yes | `s3://my-bucket?awssdk=v2&endpoint=https://s3.us-west-004.backblazeb2.com&disableSSL=false&s3ForcePathStyle=true` | +| MinIO | Yes | `s3://my-bucket?awssdk=v2&endpoint=http://minio:9000&disable_https=true&s3ForcePathStyle=true` | +| Cloudflare R2 | Yes | `s3://my-bucket?awssdk=v2&endpoint=https://.r2.cloudflarestorage.com&disable_https=false&s3ForcePathStyle=true` | +| Backblaze B2 | Yes | `s3://my-bucket?awssdk=v2&endpoint=https://s3.us-west-004.backblazeb2.com&disable_https=false&s3ForcePathStyle=true` | ::: info If you know of any other S3-compatible storage that works with Homebox, please let us know or create a pull request to update the table. @@ -57,7 +57,7 @@ Additionally, the parameters in the URL can be used to configure specific S3 set features.) - `endpoint`: The custom endpoint for S3-compatible storage services. - `s3ForcePathStyle`: Whether to force path-style access (set to `true` or `false`). -- `disableSSL`: Whether to disable SSL (set to `true` or `false`). +- `disable_https`: Whether to disable SSL (set to `true` or `false`). - `sseType`: The server-side encryption type (e.g., `AES256` or `aws:kms` or `aws:kms:dsse`). - `kmskeyid`: The KMS key ID for server-side encryption. - `fips`: Whether to use FIPS endpoints (set to `true` or `false`). diff --git a/docs/en/custom-font-setup.md b/docs/en/custom-font-setup.md new file mode 100644 index 00000000..69f0023c --- /dev/null +++ b/docs/en/custom-font-setup.md @@ -0,0 +1,80 @@ +# External Font Support for Label Maker + +Label maker supports external font files. + +## Quick Start + +### Docker/Podman Setup + +1. **Download external fonts** (e.g., Noto Sans KR): + - Download from [Google Fonts](https://fonts.google.com/noto/specimen/Noto+Sans+KR) + - Or use the Variable Font from [GitHub](https://github.com/notofonts/noto-cjk) + +2. **Create a fonts directory**: +```bash +mkdir -p ./fonts +# Place your font files in this directory +# e.g., NotoSansKR-VF.ttf +``` + +3. **Mount the fonts directory and set environment variables**: +```yaml +# docker-compose.yml +services: + homebox: + image: homebox:latest + volumes: + - ./data:/data + - ./fonts:/fonts:ro # Mount fonts directory as read-only + environment: + - HBOX_LABEL_MAKER_REGULAR_FONT_PATH=/fonts/NotoSansKR-VF.ttf + - HBOX_LABEL_MAKER_BOLD_FONT_PATH=/fonts/NotoSansKR-VF.ttf + ports: + - 3100:7745 +``` + +Or with podman: +```bash +podman run -d \ + --name homebox \ + -p 3100:7745 \ + -v ./data:/data \ + -v ./fonts:/fonts:ro \ + -e HBOX_LABEL_MAKER_REGULAR_FONT_PATH=/fonts/NotoSansKR-VF.ttf \ + -e HBOX_LABEL_MAKER_BOLD_FONT_PATH=/fonts/NotoSansKR-VF.ttf \ + homebox:latest +``` + +4. **Restart the container** and test label generation with Chinese, Japanese, Korean text! + +## Supported Fonts + +- **Format**: TTF (TrueType Font) +- **Recommended Fonts**: + - Noto Sans KR (Korean) + - Noto Sans CJK (Chinese, Japanese, Korean) + - Noto Sans SC (Simplified Chinese) + - Noto Sans JP (Japanese) + +## Fallback Behavior + +1. **External font specified** → Tries to load from `HBOX_LABEL_MAKER_*_FONT_PATH` +2. **External font fails or not specified** → Falls back to bundled Go fonts (Latin-only, **does not support CJK characters**) + +## Troubleshooting + +### Labels still show squares (□□□) +- Check if the font file exists at the specified path +- Verify the font file format (must be TTF, not OTF) +- Check container logs: `podman logs homebox | grep -i font` + +### Font file not found +- Ensure the volume is correctly mounted +- Check file permissions (font files should be readable) +- Use absolute paths in environment variables + +## Why External Fonts? + +- **Smaller base image**: No need to embed large font files (~10MB per font) +- **Flexibility**: Easily switch fonts without rebuilding the image +- **Multi-language support**: Add support for any language by mounting appropriate fonts diff --git a/frontend/assets/css/main.css b/frontend/assets/css/main.css index 917afa20..186e4b4d 100644 --- a/frontend/assets/css/main.css +++ b/frontend/assets/css/main.css @@ -1005,12 +1005,12 @@ .markdown :where(ul) { list-style: disc; - margin-left: 2rem; + margin-left: 1rem; } .markdown :where(ol) { list-style: decimal; - margin-left: 2rem; + margin-left: 1rem; } /* Heading Styles */ .markdown :where(h1) { diff --git a/frontend/components/Form/MarkdownEditor.vue b/frontend/components/Form/MarkdownEditor.vue new file mode 100644 index 00000000..c5e9177a --- /dev/null +++ b/frontend/components/Form/MarkdownEditor.vue @@ -0,0 +1,83 @@ + + +