From 3e3f0215c88d3497bc5ca8ff0f718b93021998e3 Mon Sep 17 00:00:00 2001 From: Thomas Gerbet Date: Mon, 12 Feb 2024 15:55:45 +0100 Subject: [PATCH] feat: Add an artifact auto-assignment example The example comes with a minimal test pipeline. It will be extended to the other modules in another contribution. --- .github/workflows/CI.yml | 30 + artifact-post-action/auto-assign/.gitignore | 2 + artifact-post-action/auto-assign/Makefile | 14 + artifact-post-action/auto-assign/README.md | 45 + artifact-post-action/auto-assign/javy.nix | 46 + artifact-post-action/auto-assign/package.json | 24 + .../auto-assign/pnpm-lock.yaml | 1151 +++++++++++++++++ artifact-post-action/auto-assign/sample.json | 277 ++++ artifact-post-action/auto-assign/shell.nix | 11 + .../auto-assign/src/auto-assign.test.ts | 91 ++ .../auto-assign/src/auto-assign.ts | 98 ++ artifact-post-action/auto-assign/src/main.ts | 33 + .../auto-assign/tsconfig.json | 18 + 13 files changed, 1840 insertions(+) create mode 100644 .github/workflows/CI.yml create mode 100644 artifact-post-action/auto-assign/.gitignore create mode 100644 artifact-post-action/auto-assign/Makefile create mode 100644 artifact-post-action/auto-assign/README.md create mode 100644 artifact-post-action/auto-assign/javy.nix create mode 100644 artifact-post-action/auto-assign/package.json create mode 100644 artifact-post-action/auto-assign/pnpm-lock.yaml create mode 100644 artifact-post-action/auto-assign/sample.json create mode 100644 artifact-post-action/auto-assign/shell.nix create mode 100644 artifact-post-action/auto-assign/src/auto-assign.test.ts create mode 100644 artifact-post-action/auto-assign/src/auto-assign.ts create mode 100644 artifact-post-action/auto-assign/src/main.ts create mode 100644 artifact-post-action/auto-assign/tsconfig.json diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..5ee2cb6 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,30 @@ +name: Tests + +permissions: read-all + +on: + push: + branches: + - main + pull_request: + +jobs: + tests: + strategy: + matrix: + tuleap_functions: + - "artifact-post-action/auto-assign" + runs-on: ubuntu-22.04 + name: Tests (${{ matrix.tuleap_functions }}) + defaults: + run: + working-directory: ${{ matrix.tuleap_functions }} + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: cachix/install-nix-action@6004951b182f8860210c8d6f0d808ec5b1a33d28 # v25 + - name: Prepare + run: nix-shell --run "make prepare" + - name: Tests + run: nix-shell --pure --run "make tests" + - name: Build + run: nix-shell --pure --run "make build" diff --git a/artifact-post-action/auto-assign/.gitignore b/artifact-post-action/auto-assign/.gitignore new file mode 100644 index 0000000..1eae0cf --- /dev/null +++ b/artifact-post-action/auto-assign/.gitignore @@ -0,0 +1,2 @@ +dist/ +node_modules/ diff --git a/artifact-post-action/auto-assign/Makefile b/artifact-post-action/auto-assign/Makefile new file mode 100644 index 0000000..6615588 --- /dev/null +++ b/artifact-post-action/auto-assign/Makefile @@ -0,0 +1,14 @@ +SHELL=/usr/bin/env bash -euo pipefail -c + +.PHONY: prepare +prepare: + pnpm install --frozen-lockfile + +.PHONY: tests +tests: + pnpm run typecheck + pnpm run test + +.PHONY: build +build: + pnpm run build diff --git a/artifact-post-action/auto-assign/README.md b/artifact-post-action/auto-assign/README.md new file mode 100644 index 0000000..018ff39 --- /dev/null +++ b/artifact-post-action/auto-assign/README.md @@ -0,0 +1,45 @@ +# Artifact post action: automatically assign a contributor + +This Function automatically assigns the creator of an artifact as the contributor/assignee. +The contributor/assignee is only set when the artifact is created if no other contributors +have been designed. + +The code expects the tracker to have the [contributor/assignee semantic](https://docs.tuleap.org/user-guide/trackers/administration/configuration/semantics.html#contributor-assignee) set. + +## How to test + +First you need to run `nix-shell` to have all needed tools. + +Then build the Tuleap Function with: +```shell +make prepare +make build +``` + +You can then run it with: + +```shell +wasmtime run ./dist/function.wasm < sample.json +``` + +You can run the typechecking and unit tests with: + +```shell +make tests +``` + +## How to use + +Create a tracker and define the [contributor/assignee semantic](https://docs.tuleap.org/user-guide/trackers/administration/configuration/semantics.html#contributor-assignee). + +Then build the function: + +```shell +make prepare +make build +``` + +Then upload the binary result file (`dist/function.wasm`) to your Tracker +administration (Administration > Workflow > Tuleap Functions). + +And finally, create an artifact, shortly after the creation, the contributor field will automatically be set to yourself. \ No newline at end of file diff --git a/artifact-post-action/auto-assign/javy.nix b/artifact-post-action/auto-assign/javy.nix new file mode 100644 index 0000000..0f86900 --- /dev/null +++ b/artifact-post-action/auto-assign/javy.nix @@ -0,0 +1,46 @@ +# TODO: +# * build from sources +# * upstream to nixpkgs +{ stdenv +, lib +, fetchurl +, autoPatchelfHook +, gzip +}: + +stdenv.mkDerivation rec { + pname = "javy"; + version = "1.4.0"; + + src = fetchurl { + url = "https://github.com/bytecodealliance/javy/releases/download/v${version}/javy-x86_64-linux-v${version}.gz"; + hash = "sha256-NZIzT8BdtgKiE3RbePWEY1E5TWe9mr2LSRhhmxzWzd8="; + }; + + nativeBuildInputs = [ + autoPatchelfHook + gzip + ]; + + buildInputs = [ + stdenv.cc.cc.lib + ]; + + unpackPhase = '' + runHook preUnpack + gzip -cd "${src}" > javy + runHook postUnpack + ''; + + installPhase = '' + runHook preInstall + install -m755 -D javy $out/bin/javy + runHook postInstall + ''; + + meta = with lib; { + homepage = "https://github.com/bytecodealliance/javy"; + description = "JS to WebAssembly toolchain"; + license = licenses.asl20; + }; +} diff --git a/artifact-post-action/auto-assign/package.json b/artifact-post-action/auto-assign/package.json new file mode 100644 index 0000000..4869dbe --- /dev/null +++ b/artifact-post-action/auto-assign/package.json @@ -0,0 +1,24 @@ +{ + "name": "@tuleap/functions-post-action-auto-assign", + "version": "0.0.0", + "private": true, + "scripts": { + "build": "pnpm run build:bundle && pnpm run build:js2wasm && pnpm run build:wasmopt", + "build:bundle": "esbuild src/main.ts --platform=node --bundle --target=es2022 --minify --outfile=dist/function.js", + "build:js2wasm": "javy compile ./dist/function.js -o ./dist/function-unoptimized.wasm", + "build:wasmopt": "wasm-opt -O2 ./dist/function-unoptimized.wasm -o ./dist/function.wasm", + "typecheck": "tsc --noEmit", + "test": "vitest run" + }, + "keywords": [], + "author": "Enalean Team", + "license": "MIT", + "devDependencies": { + "esbuild": "^0.20.0", + "typescript": "^5.3.3", + "vitest": "^1.2.2" + }, + "dependencies": { + "javy": "^0.1.2" + } +} diff --git a/artifact-post-action/auto-assign/pnpm-lock.yaml b/artifact-post-action/auto-assign/pnpm-lock.yaml new file mode 100644 index 0000000..a858fc2 --- /dev/null +++ b/artifact-post-action/auto-assign/pnpm-lock.yaml @@ -0,0 +1,1151 @@ +lockfileVersion: '6.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +dependencies: + javy: + specifier: ^0.1.2 + version: 0.1.2 + +devDependencies: + esbuild: + specifier: ^0.20.0 + version: 0.20.0 + typescript: + specifier: ^5.3.3 + version: 5.3.3 + vitest: + specifier: ^1.2.2 + version: 1.2.2 + +packages: + + /@esbuild/aix-ppc64@0.19.12: + resolution: {integrity: sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [aix] + requiresBuild: true + dev: true + optional: true + + /@esbuild/aix-ppc64@0.20.0: + resolution: {integrity: sha512-fGFDEctNh0CcSwsiRPxiaqX0P5rq+AqE0SRhYGZ4PX46Lg1FNR6oCxJghf8YgY0WQEgQuh3lErUFE4KxLeRmmw==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [aix] + requiresBuild: true + dev: true + optional: true + + /@esbuild/android-arm64@0.19.12: + resolution: {integrity: sha512-P0UVNGIienjZv3f5zq0DP3Nt2IE/3plFzuaS96vihvD0Hd6H/q4WXUGpCxD/E8YrSXfNyRPbpTq+T8ZQioSuPA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@esbuild/android-arm64@0.20.0: + resolution: {integrity: sha512-aVpnM4lURNkp0D3qPoAzSG92VXStYmoVPOgXveAUoQBWRSuQzt51yvSju29J6AHPmwY1BjH49uR29oyfH1ra8Q==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@esbuild/android-arm@0.19.12: + resolution: {integrity: sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w==} + engines: {node: '>=12'} + cpu: [arm] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@esbuild/android-arm@0.20.0: + resolution: {integrity: sha512-3bMAfInvByLHfJwYPJRlpTeaQA75n8C/QKpEaiS4HrFWFiJlNI0vzq/zCjBrhAYcPyVPG7Eo9dMrcQXuqmNk5g==} + engines: {node: '>=12'} + cpu: [arm] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@esbuild/android-x64@0.19.12: + resolution: {integrity: sha512-3k7ZoUW6Q6YqhdhIaq/WZ7HwBpnFBlW905Fa4s4qWJyiNOgT1dOqDiVAQFwBH7gBRZr17gLrlFCRzF6jFh7Kew==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@esbuild/android-x64@0.20.0: + resolution: {integrity: sha512-uK7wAnlRvjkCPzh8jJ+QejFyrP8ObKuR5cBIsQZ+qbMunwR8sbd8krmMbxTLSrDhiPZaJYKQAU5Y3iMDcZPhyQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@esbuild/darwin-arm64@0.19.12: + resolution: {integrity: sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@esbuild/darwin-arm64@0.20.0: + resolution: {integrity: sha512-AjEcivGAlPs3UAcJedMa9qYg9eSfU6FnGHJjT8s346HSKkrcWlYezGE8VaO2xKfvvlZkgAhyvl06OJOxiMgOYQ==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@esbuild/darwin-x64@0.19.12: + resolution: {integrity: sha512-hKoVkKzFiToTgn+41qGhsUJXFlIjxI/jSYeZf3ugemDYZldIXIxhvwN6erJGlX4t5h417iFuheZ7l+YVn05N3A==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@esbuild/darwin-x64@0.20.0: + resolution: {integrity: sha512-bsgTPoyYDnPv8ER0HqnJggXK6RyFy4PH4rtsId0V7Efa90u2+EifxytE9pZnsDgExgkARy24WUQGv9irVbTvIw==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@esbuild/freebsd-arm64@0.19.12: + resolution: {integrity: sha512-4aRvFIXmwAcDBw9AueDQ2YnGmz5L6obe5kmPT8Vd+/+x/JMVKCgdcRwH6APrbpNXsPz+K653Qg8HB/oXvXVukA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/freebsd-arm64@0.20.0: + resolution: {integrity: sha512-kQ7jYdlKS335mpGbMW5tEe3IrQFIok9r84EM3PXB8qBFJPSc6dpWfrtsC/y1pyrz82xfUIn5ZrnSHQQsd6jebQ==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/freebsd-x64@0.19.12: + resolution: {integrity: sha512-EYoXZ4d8xtBoVN7CEwWY2IN4ho76xjYXqSXMNccFSx2lgqOG/1TBPW0yPx1bJZk94qu3tX0fycJeeQsKovA8gg==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/freebsd-x64@0.20.0: + resolution: {integrity: sha512-uG8B0WSepMRsBNVXAQcHf9+Ko/Tr+XqmK7Ptel9HVmnykupXdS4J7ovSQUIi0tQGIndhbqWLaIL/qO/cWhXKyQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-arm64@0.19.12: + resolution: {integrity: sha512-EoTjyYyLuVPfdPLsGVVVC8a0p1BFFvtpQDB/YLEhaXyf/5bczaGeN15QkR+O4S5LeJ92Tqotve7i1jn35qwvdA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-arm64@0.20.0: + resolution: {integrity: sha512-uTtyYAP5veqi2z9b6Gr0NUoNv9F/rOzI8tOD5jKcCvRUn7T60Bb+42NDBCWNhMjkQzI0qqwXkQGo1SY41G52nw==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-arm@0.19.12: + resolution: {integrity: sha512-J5jPms//KhSNv+LO1S1TX1UWp1ucM6N6XuL6ITdKWElCu8wXP72l9MM0zDTzzeikVyqFE6U8YAV9/tFyj0ti+w==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-arm@0.20.0: + resolution: {integrity: sha512-2ezuhdiZw8vuHf1HKSf4TIk80naTbP9At7sOqZmdVwvvMyuoDiZB49YZKLsLOfKIr77+I40dWpHVeY5JHpIEIg==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-ia32@0.19.12: + resolution: {integrity: sha512-Thsa42rrP1+UIGaWz47uydHSBOgTUnwBwNq59khgIwktK6x60Hivfbux9iNR0eHCHzOLjLMLfUMLCypBkZXMHA==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-ia32@0.20.0: + resolution: {integrity: sha512-c88wwtfs8tTffPaoJ+SQn3y+lKtgTzyjkD8NgsyCtCmtoIC8RDL7PrJU05an/e9VuAke6eJqGkoMhJK1RY6z4w==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-loong64@0.19.12: + resolution: {integrity: sha512-LiXdXA0s3IqRRjm6rV6XaWATScKAXjI4R4LoDlvO7+yQqFdlr1Bax62sRwkVvRIrwXxvtYEHHI4dm50jAXkuAA==} + engines: {node: '>=12'} + cpu: [loong64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-loong64@0.20.0: + resolution: {integrity: sha512-lR2rr/128/6svngnVta6JN4gxSXle/yZEZL3o4XZ6esOqhyR4wsKyfu6qXAL04S4S5CgGfG+GYZnjFd4YiG3Aw==} + engines: {node: '>=12'} + cpu: [loong64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-mips64el@0.19.12: + resolution: {integrity: sha512-fEnAuj5VGTanfJ07ff0gOA6IPsvrVHLVb6Lyd1g2/ed67oU1eFzL0r9WL7ZzscD+/N6i3dWumGE1Un4f7Amf+w==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-mips64el@0.20.0: + resolution: {integrity: sha512-9Sycc+1uUsDnJCelDf6ZNqgZQoK1mJvFtqf2MUz4ujTxGhvCWw+4chYfDLPepMEvVL9PDwn6HrXad5yOrNzIsQ==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-ppc64@0.19.12: + resolution: {integrity: sha512-nYJA2/QPimDQOh1rKWedNOe3Gfc8PabU7HT3iXWtNUbRzXS9+vgB0Fjaqr//XNbd82mCxHzik2qotuI89cfixg==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-ppc64@0.20.0: + resolution: {integrity: sha512-CoWSaaAXOZd+CjbUTdXIJE/t7Oz+4g90A3VBCHLbfuc5yUQU/nFDLOzQsN0cdxgXd97lYW/psIIBdjzQIwTBGw==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-riscv64@0.19.12: + resolution: {integrity: sha512-2MueBrlPQCw5dVJJpQdUYgeqIzDQgw3QtiAHUC4RBz9FXPrskyyU3VI1hw7C0BSKB9OduwSJ79FTCqtGMWqJHg==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-riscv64@0.20.0: + resolution: {integrity: sha512-mlb1hg/eYRJUpv8h/x+4ShgoNLL8wgZ64SUr26KwglTYnwAWjkhR2GpoKftDbPOCnodA9t4Y/b68H4J9XmmPzA==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-s390x@0.19.12: + resolution: {integrity: sha512-+Pil1Nv3Umes4m3AZKqA2anfhJiVmNCYkPchwFJNEJN5QxmTs1uzyy4TvmDrCRNT2ApwSari7ZIgrPeUx4UZDg==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-s390x@0.20.0: + resolution: {integrity: sha512-fgf9ubb53xSnOBqyvWEY6ukBNRl1mVX1srPNu06B6mNsNK20JfH6xV6jECzrQ69/VMiTLvHMicQR/PgTOgqJUQ==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-x64@0.19.12: + resolution: {integrity: sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-x64@0.20.0: + resolution: {integrity: sha512-H9Eu6MGse++204XZcYsse1yFHmRXEWgadk2N58O/xd50P9EvFMLJTQLg+lB4E1cF2xhLZU5luSWtGTb0l9UeSg==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/netbsd-x64@0.19.12: + resolution: {integrity: sha512-3ltjQ7n1owJgFbuC61Oj++XhtzmymoCihNFgT84UAmJnxJfm4sYCiSLTXZtE00VWYpPMYc+ZQmB6xbSdVh0JWA==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/netbsd-x64@0.20.0: + resolution: {integrity: sha512-lCT675rTN1v8Fo+RGrE5KjSnfY0x9Og4RN7t7lVrN3vMSjy34/+3na0q7RIfWDAj0e0rCh0OL+P88lu3Rt21MQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/openbsd-x64@0.19.12: + resolution: {integrity: sha512-RbrfTB9SWsr0kWmb9srfF+L933uMDdu9BIzdA7os2t0TXhCRjrQyCeOt6wVxr79CKD4c+p+YhCj31HBkYcXebw==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/openbsd-x64@0.20.0: + resolution: {integrity: sha512-HKoUGXz/TOVXKQ+67NhxyHv+aDSZf44QpWLa3I1lLvAwGq8x1k0T+e2HHSRvxWhfJrFxaaqre1+YyzQ99KixoA==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/sunos-x64@0.19.12: + resolution: {integrity: sha512-HKjJwRrW8uWtCQnQOz9qcU3mUZhTUQvi56Q8DPTLLB+DawoiQdjsYq+j+D3s9I8VFtDr+F9CjgXKKC4ss89IeA==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + requiresBuild: true + dev: true + optional: true + + /@esbuild/sunos-x64@0.20.0: + resolution: {integrity: sha512-GDwAqgHQm1mVoPppGsoq4WJwT3vhnz/2N62CzhvApFD1eJyTroob30FPpOZabN+FgCjhG+AgcZyOPIkR8dfD7g==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + requiresBuild: true + dev: true + optional: true + + /@esbuild/win32-arm64@0.19.12: + resolution: {integrity: sha512-URgtR1dJnmGvX864pn1B2YUYNzjmXkuJOIqG2HdU62MVS4EHpU2946OZoTMnRUHklGtJdJZ33QfzdjGACXhn1A==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@esbuild/win32-arm64@0.20.0: + resolution: {integrity: sha512-0vYsP8aC4TvMlOQYozoksiaxjlvUcQrac+muDqj1Fxy6jh9l9CZJzj7zmh8JGfiV49cYLTorFLxg7593pGldwQ==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@esbuild/win32-ia32@0.19.12: + resolution: {integrity: sha512-+ZOE6pUkMOJfmxmBZElNOx72NKpIa/HFOMGzu8fqzQJ5kgf6aTGrcJaFsNiVMH4JKpMipyK+7k0n2UXN7a8YKQ==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@esbuild/win32-ia32@0.20.0: + resolution: {integrity: sha512-p98u4rIgfh4gdpV00IqknBD5pC84LCub+4a3MO+zjqvU5MVXOc3hqR2UgT2jI2nh3h8s9EQxmOsVI3tyzv1iFg==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@esbuild/win32-x64@0.19.12: + resolution: {integrity: sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@esbuild/win32-x64@0.20.0: + resolution: {integrity: sha512-NgJnesu1RtWihtTtXGFMU5YSE6JyyHPMxCwBZK7a6/8d31GuSo9l0Ss7w1Jw5QnKUawG6UEehs883kcXf5fYwg==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@jest/schemas@29.6.3: + resolution: {integrity: sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dependencies: + '@sinclair/typebox': 0.27.8 + dev: true + + /@jridgewell/sourcemap-codec@1.4.15: + resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} + dev: true + + /@rollup/rollup-android-arm-eabi@4.10.0: + resolution: {integrity: sha512-/MeDQmcD96nVoRumKUljsYOLqfv1YFJps+0pTrb2Z9Nl/w5qNUysMaWQsrd1mvAlNT4yza1iVyIu4Q4AgF6V3A==} + cpu: [arm] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-android-arm64@4.10.0: + resolution: {integrity: sha512-lvu0jK97mZDJdpZKDnZI93I0Om8lSDaiPx3OiCk0RXn3E8CMPJNS/wxjAvSJJzhhZpfjXsjLWL8LnS6qET4VNQ==} + cpu: [arm64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-darwin-arm64@4.10.0: + resolution: {integrity: sha512-uFpayx8I8tyOvDkD7X6n0PriDRWxcqEjqgtlxnUA/G9oS93ur9aZ8c8BEpzFmsed1TH5WZNG5IONB8IiW90TQg==} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-darwin-x64@4.10.0: + resolution: {integrity: sha512-nIdCX03qFKoR/MwQegQBK+qZoSpO3LESurVAC6s6jazLA1Mpmgzo3Nj3H1vydXp/JM29bkCiuF7tDuToj4+U9Q==} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-arm-gnueabihf@4.10.0: + resolution: {integrity: sha512-Fz7a+y5sYhYZMQFRkOyCs4PLhICAnxRX/GnWYReaAoruUzuRtcf+Qnw+T0CoAWbHCuz2gBUwmWnUgQ67fb3FYw==} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-arm64-gnu@4.10.0: + resolution: {integrity: sha512-yPtF9jIix88orwfTi0lJiqINnlWo6p93MtZEoaehZnmCzEmLL0eqjA3eGVeyQhMtxdV+Mlsgfwhh0+M/k1/V7Q==} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-arm64-musl@4.10.0: + resolution: {integrity: sha512-9GW9yA30ib+vfFiwjX+N7PnjTnCMiUffhWj4vkG4ukYv1kJ4T9gHNg8zw+ChsOccM27G9yXrEtMScf1LaCuoWQ==} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-riscv64-gnu@4.10.0: + resolution: {integrity: sha512-X1ES+V4bMq2ws5fF4zHornxebNxMXye0ZZjUrzOrf7UMx1d6wMQtfcchZ8SqUnQPPHdOyOLW6fTcUiFgHFadRA==} + cpu: [riscv64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-x64-gnu@4.10.0: + resolution: {integrity: sha512-w/5OpT2EnI/Xvypw4FIhV34jmNqU5PZjZue2l2Y3ty1Ootm3SqhI+AmfhlUYGBTd9JnpneZCDnt3uNOiOBkMyw==} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-x64-musl@4.10.0: + resolution: {integrity: sha512-q/meftEe3QlwQiGYxD9rWwB21DoKQ9Q8wA40of/of6yGHhZuGfZO0c3WYkN9dNlopHlNT3mf5BPsUSxoPuVQaw==} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-win32-arm64-msvc@4.10.0: + resolution: {integrity: sha512-NrR6667wlUfP0BHaEIKgYM/2va+Oj+RjZSASbBMnszM9k+1AmliRjHc3lJIiOehtSSjqYiO7R6KLNrWOX+YNSQ==} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-win32-ia32-msvc@4.10.0: + resolution: {integrity: sha512-FV0Tpt84LPYDduIDcXvEC7HKtyXxdvhdAOvOeWMWbQNulxViH2O07QXkT/FffX4FqEI02jEbCJbr+YcuKdyyMg==} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-win32-x64-msvc@4.10.0: + resolution: {integrity: sha512-OZoJd+o5TaTSQeFFQ6WjFCiltiYVjIdsXxwu/XZ8qRpsvMQr4UsVrE5UyT9RIvsnuF47DqkJKhhVZ2Q9YW9IpQ==} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@sinclair/typebox@0.27.8: + resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} + dev: true + + /@types/estree@1.0.5: + resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} + dev: true + + /@vitest/expect@1.2.2: + resolution: {integrity: sha512-3jpcdPAD7LwHUUiT2pZTj2U82I2Tcgg2oVPvKxhn6mDI2On6tfvPQTjAI4628GUGDZrCm4Zna9iQHm5cEexOAg==} + dependencies: + '@vitest/spy': 1.2.2 + '@vitest/utils': 1.2.2 + chai: 4.4.1 + dev: true + + /@vitest/runner@1.2.2: + resolution: {integrity: sha512-JctG7QZ4LSDXr5CsUweFgcpEvrcxOV1Gft7uHrvkQ+fsAVylmWQvnaAr/HDp3LAH1fztGMQZugIheTWjaGzYIg==} + dependencies: + '@vitest/utils': 1.2.2 + p-limit: 5.0.0 + pathe: 1.1.2 + dev: true + + /@vitest/snapshot@1.2.2: + resolution: {integrity: sha512-SmGY4saEw1+bwE1th6S/cZmPxz/Q4JWsl7LvbQIky2tKE35US4gd0Mjzqfr84/4OD0tikGWaWdMja/nWL5NIPA==} + dependencies: + magic-string: 0.30.7 + pathe: 1.1.2 + pretty-format: 29.7.0 + dev: true + + /@vitest/spy@1.2.2: + resolution: {integrity: sha512-k9Gcahssw8d7X3pSLq3e3XEu/0L78mUkCjivUqCQeXJm9clfXR/Td8+AP+VC1O6fKPIDLcHDTAmBOINVuv6+7g==} + dependencies: + tinyspy: 2.2.1 + dev: true + + /@vitest/utils@1.2.2: + resolution: {integrity: sha512-WKITBHLsBHlpjnDQahr+XK6RE7MiAsgrIkr0pGhQ9ygoxBfUeG0lUG5iLlzqjmKSlBv3+j5EGsriBzh+C3Tq9g==} + dependencies: + diff-sequences: 29.6.3 + estree-walker: 3.0.3 + loupe: 2.3.7 + pretty-format: 29.7.0 + dev: true + + /acorn-walk@8.3.2: + resolution: {integrity: sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==} + engines: {node: '>=0.4.0'} + dev: true + + /acorn@8.11.3: + resolution: {integrity: sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==} + engines: {node: '>=0.4.0'} + hasBin: true + dev: true + + /ansi-styles@5.2.0: + resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==} + engines: {node: '>=10'} + dev: true + + /assertion-error@1.1.0: + resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==} + dev: true + + /cac@6.7.14: + resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} + engines: {node: '>=8'} + dev: true + + /chai@4.4.1: + resolution: {integrity: sha512-13sOfMv2+DWduEU+/xbun3LScLoqN17nBeTLUsmDfKdoiC1fr0n9PU4guu4AhRcOVFk/sW8LyZWHuhWtQZiF+g==} + engines: {node: '>=4'} + dependencies: + assertion-error: 1.1.0 + check-error: 1.0.3 + deep-eql: 4.1.3 + get-func-name: 2.0.2 + loupe: 2.3.7 + pathval: 1.1.1 + type-detect: 4.0.8 + dev: true + + /check-error@1.0.3: + resolution: {integrity: sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==} + dependencies: + get-func-name: 2.0.2 + dev: true + + /cross-spawn@7.0.3: + resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} + engines: {node: '>= 8'} + dependencies: + path-key: 3.1.1 + shebang-command: 2.0.0 + which: 2.0.2 + dev: true + + /debug@4.3.4: + resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + dependencies: + ms: 2.1.2 + dev: true + + /deep-eql@4.1.3: + resolution: {integrity: sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==} + engines: {node: '>=6'} + dependencies: + type-detect: 4.0.8 + dev: true + + /diff-sequences@29.6.3: + resolution: {integrity: sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dev: true + + /esbuild@0.19.12: + resolution: {integrity: sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg==} + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + optionalDependencies: + '@esbuild/aix-ppc64': 0.19.12 + '@esbuild/android-arm': 0.19.12 + '@esbuild/android-arm64': 0.19.12 + '@esbuild/android-x64': 0.19.12 + '@esbuild/darwin-arm64': 0.19.12 + '@esbuild/darwin-x64': 0.19.12 + '@esbuild/freebsd-arm64': 0.19.12 + '@esbuild/freebsd-x64': 0.19.12 + '@esbuild/linux-arm': 0.19.12 + '@esbuild/linux-arm64': 0.19.12 + '@esbuild/linux-ia32': 0.19.12 + '@esbuild/linux-loong64': 0.19.12 + '@esbuild/linux-mips64el': 0.19.12 + '@esbuild/linux-ppc64': 0.19.12 + '@esbuild/linux-riscv64': 0.19.12 + '@esbuild/linux-s390x': 0.19.12 + '@esbuild/linux-x64': 0.19.12 + '@esbuild/netbsd-x64': 0.19.12 + '@esbuild/openbsd-x64': 0.19.12 + '@esbuild/sunos-x64': 0.19.12 + '@esbuild/win32-arm64': 0.19.12 + '@esbuild/win32-ia32': 0.19.12 + '@esbuild/win32-x64': 0.19.12 + dev: true + + /esbuild@0.20.0: + resolution: {integrity: sha512-6iwE3Y2RVYCME1jLpBqq7LQWK3MW6vjV2bZy6gt/WrqkY+WE74Spyc0ThAOYpMtITvnjX09CrC6ym7A/m9mebA==} + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + optionalDependencies: + '@esbuild/aix-ppc64': 0.20.0 + '@esbuild/android-arm': 0.20.0 + '@esbuild/android-arm64': 0.20.0 + '@esbuild/android-x64': 0.20.0 + '@esbuild/darwin-arm64': 0.20.0 + '@esbuild/darwin-x64': 0.20.0 + '@esbuild/freebsd-arm64': 0.20.0 + '@esbuild/freebsd-x64': 0.20.0 + '@esbuild/linux-arm': 0.20.0 + '@esbuild/linux-arm64': 0.20.0 + '@esbuild/linux-ia32': 0.20.0 + '@esbuild/linux-loong64': 0.20.0 + '@esbuild/linux-mips64el': 0.20.0 + '@esbuild/linux-ppc64': 0.20.0 + '@esbuild/linux-riscv64': 0.20.0 + '@esbuild/linux-s390x': 0.20.0 + '@esbuild/linux-x64': 0.20.0 + '@esbuild/netbsd-x64': 0.20.0 + '@esbuild/openbsd-x64': 0.20.0 + '@esbuild/sunos-x64': 0.20.0 + '@esbuild/win32-arm64': 0.20.0 + '@esbuild/win32-ia32': 0.20.0 + '@esbuild/win32-x64': 0.20.0 + dev: true + + /estree-walker@3.0.3: + resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} + dependencies: + '@types/estree': 1.0.5 + dev: true + + /execa@8.0.1: + resolution: {integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==} + engines: {node: '>=16.17'} + dependencies: + cross-spawn: 7.0.3 + get-stream: 8.0.1 + human-signals: 5.0.0 + is-stream: 3.0.0 + merge-stream: 2.0.0 + npm-run-path: 5.2.0 + onetime: 6.0.0 + signal-exit: 4.1.0 + strip-final-newline: 3.0.0 + dev: true + + /fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /get-func-name@2.0.2: + resolution: {integrity: sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==} + dev: true + + /get-stream@8.0.1: + resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==} + engines: {node: '>=16'} + dev: true + + /human-signals@5.0.0: + resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} + engines: {node: '>=16.17.0'} + dev: true + + /is-stream@3.0.0: + resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dev: true + + /isexe@2.0.0: + resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} + dev: true + + /javy@0.1.2: + resolution: {integrity: sha512-z6Z+CV13SXBGxmY5UseWsYNVVR4SWPfOixKGluWi1Dpn594+M2JaGPBrFIIMnFFfi7kJzHCkcTn7CrhJ7JGKsA==} + dev: false + + /jsonc-parser@3.2.1: + resolution: {integrity: sha512-AilxAyFOAcK5wA1+LeaySVBrHsGQvUFCDWXKpZjzaL0PqW+xfBOttn8GNtWKFWqneyMZj41MWF9Kl6iPWLwgOA==} + dev: true + + /local-pkg@0.5.0: + resolution: {integrity: sha512-ok6z3qlYyCDS4ZEU27HaU6x/xZa9Whf8jD4ptH5UZTQYZVYeb9bnZ3ojVhiJNLiXK1Hfc0GNbLXcmZ5plLDDBg==} + engines: {node: '>=14'} + dependencies: + mlly: 1.5.0 + pkg-types: 1.0.3 + dev: true + + /loupe@2.3.7: + resolution: {integrity: sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==} + dependencies: + get-func-name: 2.0.2 + dev: true + + /magic-string@0.30.7: + resolution: {integrity: sha512-8vBuFF/I/+OSLRmdf2wwFCJCz+nSn0m6DPvGH1fS/KiQoSaR+sETbov0eIk9KhEKy8CYqIkIAnbohxT/4H0kuA==} + engines: {node: '>=12'} + dependencies: + '@jridgewell/sourcemap-codec': 1.4.15 + dev: true + + /merge-stream@2.0.0: + resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} + dev: true + + /mimic-fn@4.0.0: + resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} + engines: {node: '>=12'} + dev: true + + /mlly@1.5.0: + resolution: {integrity: sha512-NPVQvAY1xr1QoVeG0cy8yUYC7FQcOx6evl/RjT1wL5FvzPnzOysoqB/jmx/DhssT2dYa8nxECLAaFI/+gVLhDQ==} + dependencies: + acorn: 8.11.3 + pathe: 1.1.2 + pkg-types: 1.0.3 + ufo: 1.4.0 + dev: true + + /ms@2.1.2: + resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} + dev: true + + /nanoid@3.3.7: + resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true + dev: true + + /npm-run-path@5.2.0: + resolution: {integrity: sha512-W4/tgAXFqFA0iL7fk0+uQ3g7wkL8xJmx3XdK0VGb4cHW//eZTtKGvFBBoRKVTpY7n6ze4NL9ly7rgXcHufqXKg==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + path-key: 4.0.0 + dev: true + + /onetime@6.0.0: + resolution: {integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==} + engines: {node: '>=12'} + dependencies: + mimic-fn: 4.0.0 + dev: true + + /p-limit@5.0.0: + resolution: {integrity: sha512-/Eaoq+QyLSiXQ4lyYV23f14mZRQcXnxfHrN0vCai+ak9G0pp9iEQukIIZq5NccEvwRB8PUnZT0KsOoDCINS1qQ==} + engines: {node: '>=18'} + dependencies: + yocto-queue: 1.0.0 + dev: true + + /path-key@3.1.1: + resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} + engines: {node: '>=8'} + dev: true + + /path-key@4.0.0: + resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==} + engines: {node: '>=12'} + dev: true + + /pathe@1.1.2: + resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==} + dev: true + + /pathval@1.1.1: + resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==} + dev: true + + /picocolors@1.0.0: + resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} + dev: true + + /pkg-types@1.0.3: + resolution: {integrity: sha512-nN7pYi0AQqJnoLPC9eHFQ8AcyaixBUOwvqc5TDnIKCMEE6I0y8P7OKA7fPexsXGCGxQDl/cmrLAp26LhcwxZ4A==} + dependencies: + jsonc-parser: 3.2.1 + mlly: 1.5.0 + pathe: 1.1.2 + dev: true + + /postcss@8.4.35: + resolution: {integrity: sha512-u5U8qYpBCpN13BsiEB0CbR1Hhh4Gc0zLFuedrHJKMctHCHAGrMdG0PRM/KErzAL3CU6/eckEtmHNB3x6e3c0vA==} + engines: {node: ^10 || ^12 || >=14} + dependencies: + nanoid: 3.3.7 + picocolors: 1.0.0 + source-map-js: 1.0.2 + dev: true + + /pretty-format@29.7.0: + resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dependencies: + '@jest/schemas': 29.6.3 + ansi-styles: 5.2.0 + react-is: 18.2.0 + dev: true + + /react-is@18.2.0: + resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==} + dev: true + + /rollup@4.10.0: + resolution: {integrity: sha512-t2v9G2AKxcQ8yrG+WGxctBes1AomT0M4ND7jTFBCVPXQ/WFTvNSefIrNSmLKhIKBrvN8SG+CZslimJcT3W2u2g==} + engines: {node: '>=18.0.0', npm: '>=8.0.0'} + hasBin: true + dependencies: + '@types/estree': 1.0.5 + optionalDependencies: + '@rollup/rollup-android-arm-eabi': 4.10.0 + '@rollup/rollup-android-arm64': 4.10.0 + '@rollup/rollup-darwin-arm64': 4.10.0 + '@rollup/rollup-darwin-x64': 4.10.0 + '@rollup/rollup-linux-arm-gnueabihf': 4.10.0 + '@rollup/rollup-linux-arm64-gnu': 4.10.0 + '@rollup/rollup-linux-arm64-musl': 4.10.0 + '@rollup/rollup-linux-riscv64-gnu': 4.10.0 + '@rollup/rollup-linux-x64-gnu': 4.10.0 + '@rollup/rollup-linux-x64-musl': 4.10.0 + '@rollup/rollup-win32-arm64-msvc': 4.10.0 + '@rollup/rollup-win32-ia32-msvc': 4.10.0 + '@rollup/rollup-win32-x64-msvc': 4.10.0 + fsevents: 2.3.3 + dev: true + + /shebang-command@2.0.0: + resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} + engines: {node: '>=8'} + dependencies: + shebang-regex: 3.0.0 + dev: true + + /shebang-regex@3.0.0: + resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} + engines: {node: '>=8'} + dev: true + + /siginfo@2.0.0: + resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==} + dev: true + + /signal-exit@4.1.0: + resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} + engines: {node: '>=14'} + dev: true + + /source-map-js@1.0.2: + resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} + engines: {node: '>=0.10.0'} + dev: true + + /stackback@0.0.2: + resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} + dev: true + + /std-env@3.7.0: + resolution: {integrity: sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==} + dev: true + + /strip-final-newline@3.0.0: + resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} + engines: {node: '>=12'} + dev: true + + /strip-literal@1.3.0: + resolution: {integrity: sha512-PugKzOsyXpArk0yWmUwqOZecSO0GH0bPoctLcqNDH9J04pVW3lflYE0ujElBGTloevcxF5MofAOZ7C5l2b+wLg==} + dependencies: + acorn: 8.11.3 + dev: true + + /tinybench@2.6.0: + resolution: {integrity: sha512-N8hW3PG/3aOoZAN5V/NSAEDz0ZixDSSt5b/a05iqtpgfLWMSVuCo7w0k2vVvEjdrIoeGqZzweX2WlyioNIHchA==} + dev: true + + /tinypool@0.8.2: + resolution: {integrity: sha512-SUszKYe5wgsxnNOVlBYO6IC+8VGWdVGZWAqUxp3UErNBtptZvWbwyUOyzNL59zigz2rCA92QiL3wvG+JDSdJdQ==} + engines: {node: '>=14.0.0'} + dev: true + + /tinyspy@2.2.1: + resolution: {integrity: sha512-KYad6Vy5VDWV4GH3fjpseMQ/XU2BhIYP7Vzd0LG44qRWm/Yt2WCOTicFdvmgo6gWaqooMQCawTtILVQJupKu7A==} + engines: {node: '>=14.0.0'} + dev: true + + /type-detect@4.0.8: + resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==} + engines: {node: '>=4'} + dev: true + + /typescript@5.3.3: + resolution: {integrity: sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==} + engines: {node: '>=14.17'} + hasBin: true + dev: true + + /ufo@1.4.0: + resolution: {integrity: sha512-Hhy+BhRBleFjpJ2vchUNN40qgkh0366FWJGqVLYBHev0vpHTrXSA0ryT+74UiW6KWsldNurQMKGqCm1M2zBciQ==} + dev: true + + /vite-node@1.2.2: + resolution: {integrity: sha512-1as4rDTgVWJO3n1uHmUYqq7nsFgINQ9u+mRcXpjeOMJUmviqNKjcZB7UfRZrlM7MjYXMKpuWp5oGkjaFLnjawg==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + dependencies: + cac: 6.7.14 + debug: 4.3.4 + pathe: 1.1.2 + picocolors: 1.0.0 + vite: 5.1.1 + transitivePeerDependencies: + - '@types/node' + - less + - lightningcss + - sass + - stylus + - sugarss + - supports-color + - terser + dev: true + + /vite@5.1.1: + resolution: {integrity: sha512-wclpAgY3F1tR7t9LL5CcHC41YPkQIpKUGeIuT8MdNwNZr6OqOTLs7JX5vIHAtzqLWXts0T+GDrh9pN2arneKqg==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + peerDependencies: + '@types/node': ^18.0.0 || >=20.0.0 + less: '*' + lightningcss: ^1.21.0 + sass: '*' + stylus: '*' + sugarss: '*' + terser: ^5.4.0 + peerDependenciesMeta: + '@types/node': + optional: true + less: + optional: true + lightningcss: + optional: true + sass: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + dependencies: + esbuild: 0.19.12 + postcss: 8.4.35 + rollup: 4.10.0 + optionalDependencies: + fsevents: 2.3.3 + dev: true + + /vitest@1.2.2: + resolution: {integrity: sha512-d5Ouvrnms3GD9USIK36KG8OZ5bEvKEkITFtnGv56HFaSlbItJuYr7hv2Lkn903+AvRAgSixiamozUVfORUekjw==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + peerDependencies: + '@edge-runtime/vm': '*' + '@types/node': ^18.0.0 || >=20.0.0 + '@vitest/browser': ^1.0.0 + '@vitest/ui': ^1.0.0 + happy-dom: '*' + jsdom: '*' + peerDependenciesMeta: + '@edge-runtime/vm': + optional: true + '@types/node': + optional: true + '@vitest/browser': + optional: true + '@vitest/ui': + optional: true + happy-dom: + optional: true + jsdom: + optional: true + dependencies: + '@vitest/expect': 1.2.2 + '@vitest/runner': 1.2.2 + '@vitest/snapshot': 1.2.2 + '@vitest/spy': 1.2.2 + '@vitest/utils': 1.2.2 + acorn-walk: 8.3.2 + cac: 6.7.14 + chai: 4.4.1 + debug: 4.3.4 + execa: 8.0.1 + local-pkg: 0.5.0 + magic-string: 0.30.7 + pathe: 1.1.2 + picocolors: 1.0.0 + std-env: 3.7.0 + strip-literal: 1.3.0 + tinybench: 2.6.0 + tinypool: 0.8.2 + vite: 5.1.1 + vite-node: 1.2.2 + why-is-node-running: 2.2.2 + transitivePeerDependencies: + - less + - lightningcss + - sass + - stylus + - sugarss + - supports-color + - terser + dev: true + + /which@2.0.2: + resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} + engines: {node: '>= 8'} + hasBin: true + dependencies: + isexe: 2.0.0 + dev: true + + /why-is-node-running@2.2.2: + resolution: {integrity: sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==} + engines: {node: '>=8'} + hasBin: true + dependencies: + siginfo: 2.0.0 + stackback: 0.0.2 + dev: true + + /yocto-queue@1.0.0: + resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==} + engines: {node: '>=12.20'} + dev: true diff --git a/artifact-post-action/auto-assign/sample.json b/artifact-post-action/auto-assign/sample.json new file mode 100644 index 0000000..dd0f50f --- /dev/null +++ b/artifact-post-action/auto-assign/sample.json @@ -0,0 +1,277 @@ +{ + "id": 12808, + "action": "create", + "user": { + "id": 102, + "uri": "users/102", + "user_url": "/users/user1", + "real_name": " User1", + "display_name": " User1 (user1)", + "username": "user1", + "ldap_id": "102", + "avatar_url": "https://tuleap.example.com/users/user1/avatar-4033d2be3832fdd582ad3058c9be5f50be835b7fd024d6c11cbb3497a0a7f478.png", + "is_anonymous": false, + "has_avatar": true + }, + "current": { + "id": 20373, + "submitted_by": 102, + "submitted_by_details": { + "id": 102, + "uri": "users/102", + "user_url": "/users/user1", + "real_name": " User1", + "display_name": " User1 (user1)", + "username": "user1", + "ldap_id": "102", + "avatar_url": "https://tuleap.example.com/users/user1/avatar-4033d2be3832fdd582ad3058c9be5f50be835b7fd024d6c11cbb3497a0a7f478.png", + "is_anonymous": false, + "has_avatar": true + }, + "submitted_on": "2024-02-12T13:32:03+00:00", + "email": null, + "last_comment": { + "body": "", + "post_processed_body": "", + "format": "text", + "ugroups": null + }, + "last_modified_by": { + "id": 102, + "uri": "users/102", + "user_url": "/users/user1", + "real_name": " User1", + "display_name": " User1 (user1)", + "username": "user1", + "ldap_id": "102", + "avatar_url": "https://tuleap.example.com/users/user1/avatar-4033d2be3832fdd582ad3058c9be5f50be835b7fd024d6c11cbb3497a0a7f478.png", + "is_anonymous": false, + "has_avatar": true + }, + "values": [ + { + "field_id": 49548, + "label": "assigned_to", + "type": "sb", + "values": [ + { + "id": null, + "uri": null, + "user_url": null, + "real_name": null, + "display_name": "Anonymous user", + "username": null, + "ldap_id": null, + "avatar_url": "https://tuleap.example.com/themes/common/images/avatar_default.png", + "is_anonymous": true, + "has_avatar": true, + "email": null, + "status": null + } + ], + "bind_value_ids": [ + 100 + ] + } + ], + "last_modified_date": "2024-02-12T13:32:03+00:00" + }, + "previous": null, + "is_custom_code_execution": false, + "tracker": { + "id": 1998, + "uri": "trackers/1998", + "html_url": "/plugins/tracker/?tracker=1998", + "project": { + "id": 102, + "uri": "projects/102", + "label": "project1", + "icon": "" + }, + "label": "function_auto_assign", + "description": "", + "item_name": "function_auto_assign", + "fields": [ + { + "field_id": 49548, + "label": "assigned_to", + "name": "assigned_to", + "type": "sb", + "values": [ + { + "id": 102, + "label": "user1", + "user_reference": { + "id": "102", + "uri": "users/102", + "real_name": " User1 (user1)", + "username": "user1", + "avatar_url": "https://tuleap.example.com/users/user1/avatar-4033d2be3832fdd582ad3058c9be5f50be835b7fd024d6c11cbb3497a0a7f478.png" + } + }, + { + "id": 111, + "label": "muchuser3", + "user_reference": { + "id": "111", + "uri": "users/111", + "real_name": "MuchUser3 (muchuser3)", + "username": "muchuser3", + "avatar_url": "https://tuleap.example.com/users/muchuser3/avatar-81f1c07b4c2c26ce6ad7675e9ac401378a9a04855476538f51cd9a4f53a9a244.png" + } + }, + { + "id": 3109, + "label": "test_abc", + "user_reference": { + "id": "3109", + "uri": "users/3109", + "real_name": "Test ABC (test_abc)", + "username": "test_abc", + "avatar_url": "https://tuleap.example.com/users/test_abc/avatar-270ac06917a1e02ccac221c96357b558f35a84fe20363744366163c947b63be5.png" + } + }, + { + "id": 106, + "label": "user25", + "user_reference": { + "id": "106", + "uri": "users/106", + "real_name": "User25 (user25)", + "username": "user25", + "avatar_url": "https://tuleap.example.com/users/user25/avatar-7391fe3764bf187ae5e4c1cdad094894f14f03979087b22bb43efdb952fe878d.png" + } + }, + { + "id": 107, + "label": "user26", + "user_reference": { + "id": "107", + "uri": "users/107", + "real_name": "User26 (user26)", + "username": "user26", + "avatar_url": "https://tuleap.example.com/users/user26/avatar-9298d6a0b2a4f402d1a351e3b1d45efbfc9a03f2ea09839226aa619897580fa1.png" + } + }, + { + "id": 104, + "label": "user3", + "user_reference": { + "id": "104", + "uri": "users/104", + "real_name": "User3 (user3)", + "username": "user3", + "avatar_url": "https://tuleap.example.com/users/user3/avatar-9f81f06e6b580519d3d1e375ef5581946eb47998a357a3c51ecae48e4289ec19.png" + } + }, + { + "id": 103, + "label": "user2", + "user_reference": { + "id": "103", + "uri": "users/103", + "real_name": "UserAAAAAAAAAAAAAAAAAAAAAA2 (user2)", + "username": "user2", + "avatar_url": "https://tuleap.example.com/users/user2/avatar-c98e6bc9722d926ef56982bc39d0313ecc6c0a25a9bdb781dbd79737906daea8.png" + } + } + ], + "required": false, + "collapsed": false, + "bindings": { + "type": "users", + "list": [ + { + "id": 3, + "label": "project_members" + } + ] + }, + "permissions": [ + "read", + "update", + "create" + ], + "permissions_for_groups": { + "can_submit": [ + { + "id": "2", + "uri": "user_groups/2", + "label": "Registered users", + "users_uri": "user_groups/2/users", + "short_name": "registered_users", + "key": "ugroup_registered_users_name_key" + } + ], + "can_read": [ + { + "id": "1", + "uri": "user_groups/1", + "label": "Anonymous", + "users_uri": "user_groups/1/users", + "short_name": "all_users", + "key": "ugroup_anonymous_users_name_key" + } + ], + "can_update": [ + { + "id": "102_3", + "uri": "user_groups/102_3", + "label": "Project members", + "users_uri": "user_groups/102_3/users", + "short_name": "project_members", + "key": "ugroup_project_members_name_key" + } + ] + }, + "default_value": [] + } + ], + "structure": [ + { + "id": 49548, + "content": null + } + ], + "semantics": { + "contributor": { + "field_id": 49548 + } + }, + "workflow": { + "field_id": 0, + "is_used": "", + "is_legacy": false, + "is_advanced": true, + "rules": { + "dates": [], + "lists": [] + }, + "transitions": [] + }, + "permissions_for_groups": { + "can_access": [ + { + "id": "1", + "uri": "user_groups/1", + "label": "Anonymous", + "users_uri": "user_groups/1/users", + "short_name": "all_users", + "key": "ugroup_anonymous_users_name_key" + } + ], + "can_access_submitted_by_user": [], + "can_access_assigned_to_group": [], + "can_access_submitted_by_group": [], + "can_admin": [] + }, + "parent": null, + "resources": [ + { + "type": "reports", + "uri": "trackers/1998/tracker_reports" + } + ], + "color_name": "inca-silver" + } +} \ No newline at end of file diff --git a/artifact-post-action/auto-assign/shell.nix b/artifact-post-action/auto-assign/shell.nix new file mode 100644 index 0000000..c08a686 --- /dev/null +++ b/artifact-post-action/auto-assign/shell.nix @@ -0,0 +1,11 @@ +{ pkgs ? (import ../tools/pinned-nixpkgs.nix) {} }: + +pkgs.mkShellNoCC { + buildInputs = [ + pkgs.nodePackages.pnpm + (pkgs.callPackage ./javy.nix { }) + pkgs.binaryen + pkgs.wasmtime + pkgs.gnumake + ]; +} diff --git a/artifact-post-action/auto-assign/src/auto-assign.test.ts b/artifact-post-action/auto-assign/src/auto-assign.test.ts new file mode 100644 index 0000000..9a058d3 --- /dev/null +++ b/artifact-post-action/auto-assign/src/auto-assign.test.ts @@ -0,0 +1,91 @@ +/** + * MIT License + * + * Copyright (c) 2024 Enalean + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import { describe, it, expect } from "vitest"; +import { autoAssign } from "./auto-assign"; +import type { ArtifactChange } from "./auto-assign"; + +const CONTRIBUTOR_FIELD_ID = 12; +const USER_ID_DOING_THE_CHANGE = 102; +const EXPECTED_VALUE_NO_CHANGE = {values: []}; + +describe("auto-assign", () => { + it ("automatically assigns artifact creator as contributor", () => { + expect(autoAssign(createArtifactChangeNeedingAContributor())).toStrictEqual( + {values: [{field_id: CONTRIBUTOR_FIELD_ID, bind_value_ids: [USER_ID_DOING_THE_CHANGE]}]} + ); + }); + + it ("does nothing on update", () => { + const artifact_change_update: ArtifactChange = { + ...createArtifactChangeNeedingAContributor(), + action: "update", + } + expect(autoAssign(artifact_change_update)).toStrictEqual(EXPECTED_VALUE_NO_CHANGE); + }); + + + it ("does nothing when a contributor has already been set", () => { + let artifact_change_with_contributor = createArtifactChangeNeedingAContributor(); + artifact_change_with_contributor.current.values[0] = { + field_id: CONTRIBUTOR_FIELD_ID, + bind_value_ids: [789] + }; + expect(autoAssign(artifact_change_with_contributor)).toStrictEqual(EXPECTED_VALUE_NO_CHANGE); + }); + + it ("throws an error when tracker does not have a contributor semantic", () => { + let artifact_change_no_contributor_semantic = createArtifactChangeNeedingAContributor(); + delete artifact_change_no_contributor_semantic.tracker.semantics.contributor; + expect(() => autoAssign(artifact_change_no_contributor_semantic)).toThrowErrorMatchingInlineSnapshot(`[Error: The tracker does not have the contributor/assignee semantic set]`); + }); + + it ("throws an error when tracker have a contributor semantic that is not a selectbox", () => { + let artifact_change_with_broken_contributor_semantic = createArtifactChangeNeedingAContributor(); + delete artifact_change_with_broken_contributor_semantic.current.values[0].bind_value_ids; + expect(() => autoAssign(artifact_change_with_broken_contributor_semantic)).toThrowErrorMatchingInlineSnapshot(`[Error: The contributor/assignee field does not seem to be a selectbox]`); + }); +}); + +function createArtifactChangeNeedingAContributor(): ArtifactChange { + return { + action: "create", + current: { + submitted_by: USER_ID_DOING_THE_CHANGE, + values: [ + { + field_id: CONTRIBUTOR_FIELD_ID, + bind_value_ids: [100] + } + ], + }, + tracker: { + semantics: { + contributor: { + field_id: CONTRIBUTOR_FIELD_ID, + } + } + } + } +} \ No newline at end of file diff --git a/artifact-post-action/auto-assign/src/auto-assign.ts b/artifact-post-action/auto-assign/src/auto-assign.ts new file mode 100644 index 0000000..ab44a5a --- /dev/null +++ b/artifact-post-action/auto-assign/src/auto-assign.ts @@ -0,0 +1,98 @@ +/** + * MIT License + * + * Copyright (c) 2024 Enalean + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +const NONE_USER_ID = 100; +const ARTIFACT_NOTHING_TO_UPDATE: ArtifactUpdate = {values: []}; + + +export function autoAssign(input: ArtifactChange): ArtifactUpdate { + if (input.action === "update") { + return ARTIFACT_NOTHING_TO_UPDATE; + } + + const contributor_field_content = extractContributorFieldContent(input.current, input.tracker); + + if (contributor_field_content.bind_value_ids.length > 0 && contributor_field_content.bind_value_ids[0] !== NONE_USER_ID) { + return ARTIFACT_NOTHING_TO_UPDATE; + } + + return { + values: [ + { + field_id: contributor_field_content.field_id, + bind_value_ids: [input.current.submitted_by], + } + ] + } +} + +function extractContributorFieldContent(artifact_state: ArtifactState, tracker: Tracker): SelectBoxField { + const contributor_field_id = tracker.semantics.contributor?.field_id; + + for (const value of artifact_state.values) { + if (value.field_id !== contributor_field_id) { + continue; + } + const bind_value_ids = value.bind_value_ids ?? null; + if (bind_value_ids === null) { + throw new Error(`The contributor/assignee field does not seem to be a selectbox`); + } + return { + field_id: contributor_field_id, + bind_value_ids, + }; + } + throw new Error(`The tracker does not have the contributor/assignee semantic set`); +} + +export interface ArtifactChange { + action: "create"|"update"; + current: ArtifactState; + tracker: Tracker; +} + +interface ArtifactState { + submitted_by: number; + values: Array<{ + field_id: number; + bind_value_ids?: Array; + }> +} + +interface Tracker { + semantics: { + contributor?: { + field_id: number + }; + } +} + +interface ArtifactUpdate { + values: Array; +} + +interface SelectBoxField { + field_id: number; + bind_value_ids: Array; +} diff --git a/artifact-post-action/auto-assign/src/main.ts b/artifact-post-action/auto-assign/src/main.ts new file mode 100644 index 0000000..d5425ae --- /dev/null +++ b/artifact-post-action/auto-assign/src/main.ts @@ -0,0 +1,33 @@ +/** + * MIT License + * + * Copyright (c) 2024 Enalean + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// @ts-expect-error +import { readFileSync, writeFileSync, STDIO } from "javy/fs" +import { autoAssign } from "./auto-assign" +import type { ArtifactChange } from "./auto-assign"; + +const input: ArtifactChange = JSON.parse(new TextDecoder().decode(readFileSync(STDIO.Stdin))); + +const response = autoAssign(input); +writeFileSync(STDIO.Stdout, (new TextEncoder()).encode(JSON.stringify(response))); diff --git a/artifact-post-action/auto-assign/tsconfig.json b/artifact-post-action/auto-assign/tsconfig.json new file mode 100644 index 0000000..71ff1ff --- /dev/null +++ b/artifact-post-action/auto-assign/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "commonjs", + "sourceMap": false, + "esModuleInterop": true, + "strict": true, + "exactOptionalPropertyTypes": true, + "isolatedModules": true, + "noImplicitOverride": true, + "declaration": true, + "allowSyntheticDefaultImports": true, + "moduleResolution": "node", + "skipLibCheck": true, + "lib": ["ES2022", "DOM"] + }, + "include": ["src/**/*"] +}