feat: add typed immich api adapter
This commit is contained in:
1 parent
b84562ad52
commit
a5973bfaf1
7 files changed
+735
-7
No files matched your search
@@ -42,6 +42,7 @@
|
||||
"eslint": "^9.39.5",
|
||||
"eslint-config-next": "^16.3.0",
|
||||
"jsdom": "^30.0.1",
|
||||
"msw": "^2.15.0",
|
||||
"tailwindcss": "^4.3.3",
|
||||
"testcontainers": "^12.1.0",
|
||||
"typescript": "^5.9.3",
|
||||
|
||||
Generated
+257
-7
@@ -13,7 +13,7 @@ importers:
|
||||
version: 1.6.26(@better-auth/core@1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2))(@better-auth/utils@0.4.2)(drizzle-orm@0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0))
|
||||
better-auth:
|
||||
specifier: ^1.6.26
|
||||
version: 1.6.26(drizzle-kit@0.31.10)(drizzle-orm@0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0))(next@16.3.0(@babel/core@7.29.7(supports-color@7.2.0))(@types/node@24.13.3)(react-dom@19.2.8(react@19.2.8))(react@19.2.8))(pg@8.22.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)))
|
||||
version: 1.6.26(drizzle-kit@0.31.10)(drizzle-orm@0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0))(next@16.3.0(@babel/core@7.29.7(supports-color@7.2.0))(@types/node@24.13.3)(react-dom@19.2.8(react@19.2.8))(react@19.2.8))(pg@8.22.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(msw@2.15.0(@types/node@24.13.3)(typescript@5.9.3))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)))
|
||||
drizzle-orm:
|
||||
specifier: ^0.45.2
|
||||
version: 0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0)
|
||||
@@ -81,6 +81,9 @@ importers:
|
||||
jsdom:
|
||||
specifier: ^30.0.1
|
||||
version: 30.0.1(@noble/hashes@2.3.0)
|
||||
msw:
|
||||
specifier: ^2.15.0
|
||||
version: 2.15.0(@types/node@24.13.3)(typescript@5.9.3)
|
||||
tailwindcss:
|
||||
specifier: ^4.3.3
|
||||
version: 4.3.3
|
||||
@@ -92,7 +95,7 @@ importers:
|
||||
version: 5.9.3
|
||||
vitest:
|
||||
specifier: ^4.1.10
|
||||
version: 4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0))
|
||||
version: 4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(msw@2.15.0(@types/node@24.13.3)(typescript@5.9.3))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0))
|
||||
|
||||
packages:
|
||||
|
||||
@@ -1023,6 +1026,41 @@ packages:
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@inquirer/ansi@2.0.7':
|
||||
resolution: {integrity: sha512-3eTuUO1vH2cZm2ZKHeQxnOqlTi9EfZDGgIe3BL3I4u+rJHocr9Fz86M4fjYABPvFnQG/gGK551HqDiIcETwU6Q==}
|
||||
engines: {node: '>=23.5.0 || ^22.13.0 || ^20.17.0'}
|
||||
|
||||
'@inquirer/confirm@6.1.1':
|
||||
resolution: {integrity: sha512-eb8DBZcz/2qHWQda4rk2JiQk5h9QV/cVHi1yjt0f69WFZMRFn0sJTye3EAP8icut8UDMjQPsaH5KbcOogefrFQ==}
|
||||
engines: {node: '>=23.5.0 || ^22.13.0 || ^20.17.0'}
|
||||
peerDependencies:
|
||||
'@types/node': '>=18'
|
||||
peerDependenciesMeta:
|
||||
'@types/node':
|
||||
optional: true
|
||||
|
||||
'@inquirer/core@11.2.1':
|
||||
resolution: {integrity: sha512-Qd6GJT1yVyrZZCfN8W2qKF5ApmqryXRhRKCuip8h01x2w/esJQ2XIYc6f9abMIHgKQdBfFTSOdbHRLAhuM09UA==}
|
||||
engines: {node: '>=23.5.0 || ^22.13.0 || ^20.17.0'}
|
||||
peerDependencies:
|
||||
'@types/node': '>=18'
|
||||
peerDependenciesMeta:
|
||||
'@types/node':
|
||||
optional: true
|
||||
|
||||
'@inquirer/figures@2.0.7':
|
||||
resolution: {integrity: sha512-aJ8TBPOGB6f/2qziPfElISTCEd5XOYTFckA2SGjhNmiKzfK/u4ot3v0DUzGVdUnKjN10EqnnEPck36BkyfLnJw==}
|
||||
engines: {node: '>=23.5.0 || ^22.13.0 || ^20.17.0'}
|
||||
|
||||
'@inquirer/type@4.0.7':
|
||||
resolution: {integrity: sha512-t28inv14nMQ1PhKpsJPY+kEs/c00qzeCOS2gTNRyTjG5d6qsVA2fItxW4hkvGZ5lvanGLdtCzVIx5dwdRpN1+g==}
|
||||
engines: {node: '>=23.5.0 || ^22.13.0 || ^20.17.0'}
|
||||
peerDependencies:
|
||||
'@types/node': '>=18'
|
||||
peerDependenciesMeta:
|
||||
'@types/node':
|
||||
optional: true
|
||||
|
||||
'@isaacs/cliui@8.0.2':
|
||||
resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -1049,6 +1087,10 @@ packages:
|
||||
'@kwsites/file-exists@1.1.1':
|
||||
resolution: {integrity: sha512-m9/5YGR18lIwxSFDwfE3oA7bWuq9kdau6ugN4H2rJeyhFQZcG9AgSHkQtSD15a8WvTgfz9aikZMrKPHvbpqFiw==}
|
||||
|
||||
'@mswjs/interceptors@0.41.9':
|
||||
resolution: {integrity: sha512-VVPPgHyQ6ShqnrmDWuxjmUIsO9gWyOZFmuOfLd9LfBGQJwZfy0gvv9pbHSJuoFNIYC7ZDX9aoFwowjcdSC4E8w==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
'@napi-rs/wasm-runtime@1.2.2':
|
||||
resolution: {integrity: sha512-JfB4kuJQjaoHuCTseIINHtHWeJnvgEcxjwA5t/Y00ZgaOO1Crz3fjT/p8kT28zA/Caz7oiUMn3d6H2yOVCVwuw==}
|
||||
engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0}
|
||||
@@ -1138,6 +1180,18 @@ packages:
|
||||
resolution: {integrity: sha512-nn5ozdjYQpUCZlWGuxcJY/KpxkWQs4DcbMCmKojjyrYDEAGy4Ce19NN4v5MduafTwJlbKc99UA8YhSVqq9yPZA==}
|
||||
engines: {node: '>=12.4.0'}
|
||||
|
||||
'@open-draft/deferred-promise@2.2.0':
|
||||
resolution: {integrity: sha512-CecwLWx3rhxVQF6V4bAgPS5t+So2sTbPgAzafKkVizyi7tlwpcFpdFqq+wqF2OwNBmqFuu6tOyouTuxgpMfzmA==}
|
||||
|
||||
'@open-draft/deferred-promise@3.0.0':
|
||||
resolution: {integrity: sha512-XW375UK8/9SqUVNVa6M0yEy8+iTi4QN5VZ7aZuRFQmy76LRwI9wy5F4YIBU6T+eTe2/DNDo8tqu8RHlwLHM6RA==}
|
||||
|
||||
'@open-draft/logger@0.3.0':
|
||||
resolution: {integrity: sha512-X2g45fzhxH238HKO4xbSr7+wBS8Fvw6ixhTDuvLd5mqh6bJJCFAPwU9mPDxbcrRtfxv4u5IHCEH77BmxvXmmxQ==}
|
||||
|
||||
'@open-draft/until@2.1.0':
|
||||
resolution: {integrity: sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==}
|
||||
|
||||
'@opentelemetry/semantic-conventions@1.43.0':
|
||||
resolution: {integrity: sha512-eSYWTm620tTk45EKSedaUL8MFYI8hW164hIXsgIHyxu3VobUB3fFCu5t0hQby6OoWRPsG1KkKUG2M5UadiLiVg==}
|
||||
engines: {node: '>=14'}
|
||||
@@ -1445,6 +1499,9 @@ packages:
|
||||
'@types/react@19.2.18':
|
||||
resolution: {integrity: sha512-AnzbBERsrLKtk2XSfTbYRLjQPdy116Sty4q+T+Bp3IC4l6jNBvreVPAHmpq9qhXQM7CXZPjLVmGMw9sy+hxQ3w==}
|
||||
|
||||
'@types/set-cookie-parser@2.4.10':
|
||||
resolution: {integrity: sha512-GGmQVGpQWUe5qglJozEjZV/5dyxbOOZ0LHe/lqyWssB88Y4svNfst0uqBVscdDeIKl5Jy5+aPSvy7mI9tYRguw==}
|
||||
|
||||
'@types/ssh2-streams@0.1.13':
|
||||
resolution: {integrity: sha512-faHyY3brO9oLEA0QlcO8N2wT7R0+1sHWZvQ+y3rMLwdY1ZyS1z0W3t65j9PqT4HmQ6ALzNe7RZlNuCNE0wBSWA==}
|
||||
|
||||
@@ -1454,6 +1511,9 @@ packages:
|
||||
'@types/ssh2@1.15.5':
|
||||
resolution: {integrity: sha512-N1ASjp/nXH3ovBHddRJpli4ozpk6UdDYIX4RJWFa9L1YKnzdhTlVmiGHm4DZnj/jLbqZpes4aeR30EFGQtvhQQ==}
|
||||
|
||||
'@types/statuses@2.0.6':
|
||||
resolution: {integrity: sha512-xMAgYwceFhRA2zY+XbEA7mxYbA093wdiW8Vu6gZPGWy9cmOyU9XesH1tNcEWsKFd5Vzrqx5T3D38PWx1FIIXkA==}
|
||||
|
||||
'@typescript-eslint/eslint-plugin@8.66.0':
|
||||
resolution: {integrity: sha512-p088eaGrzYz1s+7cov0aMOCkNGTJlVxF4jgubf28c8L0Cv9Rloj8YBHnv4hXLq6IIEE1AsjNWavO+k+8kP2Y0A==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
@@ -2003,6 +2063,10 @@ packages:
|
||||
chownr@1.1.4:
|
||||
resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==}
|
||||
|
||||
cli-width@4.1.0:
|
||||
resolution: {integrity: sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==}
|
||||
engines: {node: '>= 12'}
|
||||
|
||||
client-only@0.0.1:
|
||||
resolution: {integrity: sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==}
|
||||
|
||||
@@ -2027,6 +2091,10 @@ packages:
|
||||
convert-source-map@2.0.0:
|
||||
resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==}
|
||||
|
||||
cookie@1.1.1:
|
||||
resolution: {integrity: sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
core-util-is@1.0.3:
|
||||
resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==}
|
||||
|
||||
@@ -2479,6 +2547,15 @@ packages:
|
||||
fast-levenshtein@2.0.6:
|
||||
resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==}
|
||||
|
||||
fast-string-truncated-width@3.0.3:
|
||||
resolution: {integrity: sha512-0jjjIEL6+0jag3l2XWWizO64/aZVtpiGE3t0Zgqxv0DPuxiMjvB3M24fCyhZUO4KomJQPj3LTSUnDP3GpdwC0g==}
|
||||
|
||||
fast-string-width@3.0.2:
|
||||
resolution: {integrity: sha512-gX8LrtNEI5hq8DVUfRQMbr5lpaS4nMIWV+7XEbXk2b8kiQIizgnlr12B4dA3ZEx3308ze0O4Q1R+cHts8kyUJg==}
|
||||
|
||||
fast-wrap-ansi@0.2.2:
|
||||
resolution: {integrity: sha512-7F2Fl+TjRSenLqlU3UjSH0iyqopqoZIu7eZVpEirP2g1GtWa2G/ecEmBdgz31+Mxr+ELclgg6sokpSFIQiZ02Q==}
|
||||
|
||||
fastq@1.20.1:
|
||||
resolution: {integrity: sha512-GGToxJ/w1x32s/D2EKND7kTil4n8OVk/9mycTc4VDza13lOvpUZTGX3mFSCtV9ksdGBVzvsyAVLM6mHFThxXxw==}
|
||||
|
||||
@@ -2599,6 +2676,10 @@ packages:
|
||||
graceful-fs@4.2.11:
|
||||
resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==}
|
||||
|
||||
graphql@16.14.2:
|
||||
resolution: {integrity: sha512-Chq1s4CY7jmh8gO2qvLIJyfCDIN+EHLFW/9iShnp1z8FjBQMoodWP1kDC36VAMXXIvAjj4ARa7ntfAV2BrjsbA==}
|
||||
engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0}
|
||||
|
||||
has-bigints@1.1.0:
|
||||
resolution: {integrity: sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@@ -2626,6 +2707,9 @@ packages:
|
||||
resolution: {integrity: sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
headers-polyfill@5.0.1:
|
||||
resolution: {integrity: sha512-1TJ6Fih/b8h5TIcv+1+Hw0PDQWJTKDKzFZzcKOiW1wJza3XoAQlkCuXLbymPYB8+ZQyw8mHvdw560e8zVFIWyA==}
|
||||
|
||||
hermes-estree@0.25.1:
|
||||
resolution: {integrity: sha512-0wUoCcLp+5Ev5pDW2OriHC2MJCbwLwuRx+gAqMTOkGKJJiBCLjtrvy4PWUGn6MIVefecRpzoOZ/UV6iGdOr+Cw==}
|
||||
|
||||
@@ -2733,6 +2817,9 @@ packages:
|
||||
resolution: {integrity: sha512-5KoIu2Ngpyek75jXodFvnafB6DJgr3u8uuK0LEZJjrU19DrMD3EVERaR8sjz8CCGgpZvxPl9SuE1GMVPFHx1mw==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
is-node-process@1.2.0:
|
||||
resolution: {integrity: sha512-Vg4o6/fqPxIjtxgUH5QLJhwZ7gW5diGCVlXpuUfELC62CuxM1iHcRe51f2W1FDy04Ai4KJkagKjx3XaqyfRKXw==}
|
||||
|
||||
is-number-object@1.1.1:
|
||||
resolution: {integrity: sha512-lZhclumE1G6VYD8VHe35wFaIif+CTy5SJIi5+3y4psDgWu4wPDoBhF8NxUOinEc7pHgiTsT6MaBb92rKhhD+Xw==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@@ -3109,6 +3196,20 @@ packages:
|
||||
ms@2.1.3:
|
||||
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
|
||||
|
||||
msw@2.15.0:
|
||||
resolution: {integrity: sha512-2wQAmKkQKxRuXvYJxVhPGG0wZNBQyD06oJvxqw90XqLvptdqxdlHrFUfEteKkpaNORX3Xzc+HtEl/q0nfmN2wQ==}
|
||||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
typescript: '>= 4.8.x'
|
||||
peerDependenciesMeta:
|
||||
typescript:
|
||||
optional: true
|
||||
|
||||
mute-stream@3.0.0:
|
||||
resolution: {integrity: sha512-dkEJPVvun4FryqBmZ5KhDo0K9iDXAwn08tMLDinNdRBNPcYEDiWYysLcc6k3mjTMlbP9KyylvRpd4wFtwrT9rw==}
|
||||
engines: {node: ^20.17.0 || >=22.9.0}
|
||||
|
||||
nan@2.28.0:
|
||||
resolution: {integrity: sha512-fTsDz99OTq2sVePhGdp4qQhggZFtKr64ZNVyVajRKtMOkJxYekplBh577PiJB12v/D3s2E5cGtOI45LWp6rnLQ==}
|
||||
|
||||
@@ -3209,6 +3310,9 @@ packages:
|
||||
resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==}
|
||||
engines: {node: '>= 0.8.0'}
|
||||
|
||||
outvariant@1.4.3:
|
||||
resolution: {integrity: sha512-+Sl2UErvtsoajRDKCE5/dBz4DIvHXQQnAxtQTF04OJxY0+DyZXSo5P5Bb7XYWOh81syohlYL24hbDwxedPUJCA==}
|
||||
|
||||
own-keys@1.0.2:
|
||||
resolution: {integrity: sha512-19YVAg7T+WTrxggPukVq7DjTv6+PJ867TmhCvBsYwmbFCsZd344rq2Ld1p0wo8f8Qrrhgp82c6FJRqdXWtSEhg==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@@ -3246,6 +3350,9 @@ packages:
|
||||
resolution: {integrity: sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==}
|
||||
engines: {node: '>=16 || 14 >=14.18'}
|
||||
|
||||
path-to-regexp@6.3.0:
|
||||
resolution: {integrity: sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==}
|
||||
|
||||
pathe@2.0.3:
|
||||
resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==}
|
||||
|
||||
@@ -3426,6 +3533,9 @@ packages:
|
||||
resolution: {integrity: sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==}
|
||||
engines: {node: '>= 4'}
|
||||
|
||||
rettime@0.11.11:
|
||||
resolution: {integrity: sha512-ILJRqVWBCTlg9r42fFgwVZx1gnFAcQF8mRoMkbgQfIrjEDf9nbBFDFx00oloOa+Q869FUtaYDXZvEfnecQSCoQ==}
|
||||
|
||||
reusify@1.1.0:
|
||||
resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==}
|
||||
engines: {iojs: '>=1.0.0', node: '>=0.10.0'}
|
||||
@@ -3570,6 +3680,10 @@ packages:
|
||||
stackback@0.0.2:
|
||||
resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}
|
||||
|
||||
statuses@2.0.2:
|
||||
resolution: {integrity: sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
std-env@4.2.0:
|
||||
resolution: {integrity: sha512-oCUKSupKTHX53EyjDtuZQ64pjLJ6yYCtpmEw0goYxtjG9KpbRe8KAsl2tBUGU9DyMcJ0RwJ8GqJAFzMXcXW1Rw==}
|
||||
|
||||
@@ -3580,6 +3694,9 @@ packages:
|
||||
streamx@2.28.0:
|
||||
resolution: {integrity: sha512-1Yowhzjf0ivGMrTIkY9hav5TxobO9qIVqUE41fiCGMGgc3CLlf4MY+9AHmZqBWgDTue0fY9zWjYFVyf6Diuobw==}
|
||||
|
||||
strict-event-emitter@0.5.1:
|
||||
resolution: {integrity: sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==}
|
||||
|
||||
string-width@4.2.3:
|
||||
resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==}
|
||||
engines: {node: '>=8'}
|
||||
@@ -3661,6 +3778,10 @@ packages:
|
||||
symbol-tree@3.2.4:
|
||||
resolution: {integrity: sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==}
|
||||
|
||||
tagged-tag@1.0.0:
|
||||
resolution: {integrity: sha512-yEFYrVhod+hdNyx7g5Bnkkb0G6si8HJurOoOEgC8B/O0uXLHlaey/65KRv6cuWBNhBgHKAROVpc7QyYqE5gFng==}
|
||||
engines: {node: '>=20'}
|
||||
|
||||
tailwindcss@4.3.3:
|
||||
resolution: {integrity: sha512-gOhV3P7ufE62QDGg1zVaTgCR+EtPv92k2nIhVcVKcLmxT1sUBsQGhnZj175j+MqRt4zLF7ic+sCYjfhxMxj7YQ==}
|
||||
|
||||
@@ -3753,6 +3874,10 @@ packages:
|
||||
resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==}
|
||||
engines: {node: '>= 0.8.0'}
|
||||
|
||||
type-fest@5.8.0:
|
||||
resolution: {integrity: sha512-YGYEVz3Fm5iy/AybuA0oyNFq7H4CgQNfRp/qfe8nurE1kuCeNm3/vfm9X4Mtl+qLyaKJUh5xrFZwogr41SMjYA==}
|
||||
engines: {node: '>=20'}
|
||||
|
||||
typed-array-buffer@1.0.3:
|
||||
resolution: {integrity: sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@@ -3798,6 +3923,9 @@ packages:
|
||||
unrs-resolver@1.12.2:
|
||||
resolution: {integrity: sha512-dmlRxBJJayXjqTwC+JtF1HhJmgf3ftQ3YejFcZrf4+KKtJv0qDsK1pjqaaVjG7wJ5NJ6UVP1OqRMQ71Z4C3rxQ==}
|
||||
|
||||
until-async@3.0.2:
|
||||
resolution: {integrity: sha512-IiSk4HlzAMqTUseHHe3VhIGyuFmN90zMTpD3Z3y8jeQbzLIq500MVM7Jq2vUAnTKAFPJrqwkzr6PoTcPhGcOiw==}
|
||||
|
||||
update-browserslist-db@1.3.0:
|
||||
resolution: {integrity: sha512-x/M6q3w4Ybp91CNaS4S69UnliqR3BzRpOT6LWbksjth0S/+jhfaPJsWjt/TewpT8j9eLIojUf5jr29WextHroA==}
|
||||
hasBin: true
|
||||
@@ -4665,6 +4793,33 @@ snapshots:
|
||||
'@img/sharp-win32-x64@0.35.3':
|
||||
optional: true
|
||||
|
||||
'@inquirer/ansi@2.0.7': {}
|
||||
|
||||
'@inquirer/confirm@6.1.1(@types/node@24.13.3)':
|
||||
dependencies:
|
||||
'@inquirer/core': 11.2.1(@types/node@24.13.3)
|
||||
'@inquirer/type': 4.0.7(@types/node@24.13.3)
|
||||
optionalDependencies:
|
||||
'@types/node': 24.13.3
|
||||
|
||||
'@inquirer/core@11.2.1(@types/node@24.13.3)':
|
||||
dependencies:
|
||||
'@inquirer/ansi': 2.0.7
|
||||
'@inquirer/figures': 2.0.7
|
||||
'@inquirer/type': 4.0.7(@types/node@24.13.3)
|
||||
cli-width: 4.1.0
|
||||
fast-wrap-ansi: 0.2.2
|
||||
mute-stream: 3.0.0
|
||||
signal-exit: 4.1.0
|
||||
optionalDependencies:
|
||||
'@types/node': 24.13.3
|
||||
|
||||
'@inquirer/figures@2.0.7': {}
|
||||
|
||||
'@inquirer/type@4.0.7(@types/node@24.13.3)':
|
||||
optionalDependencies:
|
||||
'@types/node': 24.13.3
|
||||
|
||||
'@isaacs/cliui@8.0.2':
|
||||
dependencies:
|
||||
string-width: 5.1.2
|
||||
@@ -4701,6 +4856,15 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@mswjs/interceptors@0.41.9':
|
||||
dependencies:
|
||||
'@open-draft/deferred-promise': 2.2.0
|
||||
'@open-draft/logger': 0.3.0
|
||||
'@open-draft/until': 2.1.0
|
||||
is-node-process: 1.2.0
|
||||
outvariant: 1.4.3
|
||||
strict-event-emitter: 0.5.1
|
||||
|
||||
'@napi-rs/wasm-runtime@1.2.2(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)':
|
||||
dependencies:
|
||||
'@emnapi/core': 1.10.0
|
||||
@@ -4759,6 +4923,17 @@ snapshots:
|
||||
|
||||
'@nolyfill/is-core-module@1.0.39': {}
|
||||
|
||||
'@open-draft/deferred-promise@2.2.0': {}
|
||||
|
||||
'@open-draft/deferred-promise@3.0.0': {}
|
||||
|
||||
'@open-draft/logger@0.3.0':
|
||||
dependencies:
|
||||
is-node-process: 1.2.0
|
||||
outvariant: 1.4.3
|
||||
|
||||
'@open-draft/until@2.1.0': {}
|
||||
|
||||
'@opentelemetry/semantic-conventions@1.43.0': {}
|
||||
|
||||
'@oxc-project/types@0.143.0': {}
|
||||
@@ -5004,6 +5179,10 @@ snapshots:
|
||||
dependencies:
|
||||
csstype: 3.2.3
|
||||
|
||||
'@types/set-cookie-parser@2.4.10':
|
||||
dependencies:
|
||||
'@types/node': 24.13.3
|
||||
|
||||
'@types/ssh2-streams@0.1.13':
|
||||
dependencies:
|
||||
'@types/node': 24.13.3
|
||||
@@ -5017,6 +5196,8 @@ snapshots:
|
||||
dependencies:
|
||||
'@types/node': 18.19.130
|
||||
|
||||
'@types/statuses@2.0.6': {}
|
||||
|
||||
'@typescript-eslint/eslint-plugin@8.66.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)':
|
||||
dependencies:
|
||||
'@eslint-community/regexpp': 4.12.2
|
||||
@@ -5192,12 +5373,13 @@ snapshots:
|
||||
chai: 6.2.2
|
||||
tinyrainbow: 3.1.1
|
||||
|
||||
'@vitest/mocker@4.1.10(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0))':
|
||||
'@vitest/mocker@4.1.10(msw@2.15.0(@types/node@24.13.3)(typescript@5.9.3))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0))':
|
||||
dependencies:
|
||||
'@vitest/spy': 4.1.10
|
||||
estree-walker: 3.0.3
|
||||
magic-string: 0.30.21
|
||||
optionalDependencies:
|
||||
msw: 2.15.0(@types/node@24.13.3)(typescript@5.9.3)
|
||||
vite: 8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)
|
||||
|
||||
'@vitest/pretty-format@4.1.10':
|
||||
@@ -5417,7 +5599,7 @@ snapshots:
|
||||
dependencies:
|
||||
tweetnacl: 0.14.5
|
||||
|
||||
better-auth@1.6.26(drizzle-kit@0.31.10)(drizzle-orm@0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0))(next@16.3.0(@babel/core@7.29.7(supports-color@7.2.0))(@types/node@24.13.3)(react-dom@19.2.8(react@19.2.8))(react@19.2.8))(pg@8.22.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0))):
|
||||
better-auth@1.6.26(drizzle-kit@0.31.10)(drizzle-orm@0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0))(next@16.3.0(@babel/core@7.29.7(supports-color@7.2.0))(@types/node@24.13.3)(react-dom@19.2.8(react@19.2.8))(react@19.2.8))(pg@8.22.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(msw@2.15.0(@types/node@24.13.3)(typescript@5.9.3))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0))):
|
||||
dependencies:
|
||||
'@better-auth/core': 1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2)
|
||||
'@better-auth/drizzle-adapter': 1.6.26(@better-auth/core@1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2))(@better-auth/utils@0.4.2)(drizzle-orm@0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0))
|
||||
@@ -5443,7 +5625,7 @@ snapshots:
|
||||
pg: 8.22.0
|
||||
react: 19.2.8
|
||||
react-dom: 19.2.8(react@19.2.8)
|
||||
vitest: 4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0))
|
||||
vitest: 4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(msw@2.15.0(@types/node@24.13.3)(typescript@5.9.3))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0))
|
||||
transitivePeerDependencies:
|
||||
- '@cloudflare/workers-types'
|
||||
- '@opentelemetry/api'
|
||||
@@ -5541,6 +5723,8 @@ snapshots:
|
||||
|
||||
chownr@1.1.4: {}
|
||||
|
||||
cli-width@4.1.0: {}
|
||||
|
||||
client-only@0.0.1: {}
|
||||
|
||||
cliui@8.0.1:
|
||||
@@ -5567,6 +5751,8 @@ snapshots:
|
||||
|
||||
convert-source-map@2.0.0: {}
|
||||
|
||||
cookie@1.1.1: {}
|
||||
|
||||
core-util-is@1.0.3: {}
|
||||
|
||||
cpu-features@0.0.10:
|
||||
@@ -6165,6 +6351,16 @@ snapshots:
|
||||
|
||||
fast-levenshtein@2.0.6: {}
|
||||
|
||||
fast-string-truncated-width@3.0.3: {}
|
||||
|
||||
fast-string-width@3.0.2:
|
||||
dependencies:
|
||||
fast-string-truncated-width: 3.0.3
|
||||
|
||||
fast-wrap-ansi@0.2.2:
|
||||
dependencies:
|
||||
fast-string-width: 3.0.2
|
||||
|
||||
fastq@1.20.1:
|
||||
dependencies:
|
||||
reusify: 1.1.0
|
||||
@@ -6289,6 +6485,8 @@ snapshots:
|
||||
|
||||
graceful-fs@4.2.11: {}
|
||||
|
||||
graphql@16.14.2: {}
|
||||
|
||||
has-bigints@1.1.0: {}
|
||||
|
||||
has-flag@4.0.0: {}
|
||||
@@ -6311,6 +6509,11 @@ snapshots:
|
||||
dependencies:
|
||||
function-bind: 1.1.2
|
||||
|
||||
headers-polyfill@5.0.1:
|
||||
dependencies:
|
||||
'@types/set-cookie-parser': 2.4.10
|
||||
set-cookie-parser: 3.1.2
|
||||
|
||||
hermes-estree@0.25.1: {}
|
||||
|
||||
hermes-parser@0.25.1:
|
||||
@@ -6418,6 +6621,8 @@ snapshots:
|
||||
|
||||
is-negative-zero@2.0.3: {}
|
||||
|
||||
is-node-process@1.2.0: {}
|
||||
|
||||
is-number-object@1.1.1:
|
||||
dependencies:
|
||||
call-bound: 1.0.4
|
||||
@@ -6734,6 +6939,33 @@ snapshots:
|
||||
|
||||
ms@2.1.3: {}
|
||||
|
||||
msw@2.15.0(@types/node@24.13.3)(typescript@5.9.3):
|
||||
dependencies:
|
||||
'@inquirer/confirm': 6.1.1(@types/node@24.13.3)
|
||||
'@mswjs/interceptors': 0.41.9
|
||||
'@open-draft/deferred-promise': 3.0.0
|
||||
'@types/statuses': 2.0.6
|
||||
cookie: 1.1.1
|
||||
graphql: 16.14.2
|
||||
headers-polyfill: 5.0.1
|
||||
is-node-process: 1.2.0
|
||||
outvariant: 1.4.3
|
||||
path-to-regexp: 6.3.0
|
||||
picocolors: 1.1.1
|
||||
rettime: 0.11.11
|
||||
statuses: 2.0.2
|
||||
strict-event-emitter: 0.5.1
|
||||
tough-cookie: 6.0.2
|
||||
type-fest: 5.8.0
|
||||
until-async: 3.0.2
|
||||
yargs: 17.7.3
|
||||
optionalDependencies:
|
||||
typescript: 5.9.3
|
||||
transitivePeerDependencies:
|
||||
- '@types/node'
|
||||
|
||||
mute-stream@3.0.0: {}
|
||||
|
||||
nan@2.28.0:
|
||||
optional: true
|
||||
|
||||
@@ -6840,6 +7072,8 @@ snapshots:
|
||||
type-check: 0.4.0
|
||||
word-wrap: 1.2.5
|
||||
|
||||
outvariant@1.4.3: {}
|
||||
|
||||
own-keys@1.0.2:
|
||||
dependencies:
|
||||
call-bound: 1.0.4
|
||||
@@ -6876,6 +7110,8 @@ snapshots:
|
||||
lru-cache: 10.4.3
|
||||
minipass: 7.1.3
|
||||
|
||||
path-to-regexp@6.3.0: {}
|
||||
|
||||
pathe@2.0.3: {}
|
||||
|
||||
pg-cloudflare@1.4.0:
|
||||
@@ -7080,6 +7316,8 @@ snapshots:
|
||||
|
||||
retry@0.12.0: {}
|
||||
|
||||
rettime@0.11.11: {}
|
||||
|
||||
reusify@1.1.0: {}
|
||||
|
||||
rolldown@1.2.3:
|
||||
@@ -7273,6 +7511,8 @@ snapshots:
|
||||
|
||||
stackback@0.0.2: {}
|
||||
|
||||
statuses@2.0.2: {}
|
||||
|
||||
std-env@4.2.0: {}
|
||||
|
||||
stop-iteration-iterator@1.1.0:
|
||||
@@ -7289,6 +7529,8 @@ snapshots:
|
||||
- bare-abort-controller
|
||||
- react-native-b4a
|
||||
|
||||
strict-event-emitter@0.5.1: {}
|
||||
|
||||
string-width@4.2.3:
|
||||
dependencies:
|
||||
emoji-regex: 8.0.0
|
||||
@@ -7391,6 +7633,8 @@ snapshots:
|
||||
|
||||
symbol-tree@3.2.4: {}
|
||||
|
||||
tagged-tag@1.0.0: {}
|
||||
|
||||
tailwindcss@4.3.3: {}
|
||||
|
||||
tapable@2.3.3: {}
|
||||
@@ -7525,6 +7769,10 @@ snapshots:
|
||||
dependencies:
|
||||
prelude-ls: 1.2.1
|
||||
|
||||
type-fest@5.8.0:
|
||||
dependencies:
|
||||
tagged-tag: 1.0.0
|
||||
|
||||
typed-array-buffer@1.0.3:
|
||||
dependencies:
|
||||
call-bound: 1.0.4
|
||||
@@ -7611,6 +7859,8 @@ snapshots:
|
||||
'@unrs/resolver-binding-win32-ia32-msvc': 1.12.2
|
||||
'@unrs/resolver-binding-win32-x64-msvc': 1.12.2
|
||||
|
||||
until-async@3.0.2: {}
|
||||
|
||||
update-browserslist-db@1.3.0(browserslist@4.28.7):
|
||||
dependencies:
|
||||
browserslist: 4.28.7
|
||||
@@ -7638,10 +7888,10 @@ snapshots:
|
||||
tsx: 4.23.11
|
||||
yaml: 2.9.0
|
||||
|
||||
vitest@4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)):
|
||||
vitest@4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(msw@2.15.0(@types/node@24.13.3)(typescript@5.9.3))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)):
|
||||
dependencies:
|
||||
'@vitest/expect': 4.1.10
|
||||
'@vitest/mocker': 4.1.10(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0))
|
||||
'@vitest/mocker': 4.1.10(msw@2.15.0(@types/node@24.13.3)(typescript@5.9.3))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0))
|
||||
'@vitest/pretty-format': 4.1.10
|
||||
'@vitest/runner': 4.1.10
|
||||
'@vitest/snapshot': 4.1.10
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
import { afterEach, beforeEach, expect, test } from "vitest";
|
||||
import { HttpResponse, http } from "msw";
|
||||
import { setupServer } from "msw/node";
|
||||
|
||||
import { createImmichClient } from "./client";
|
||||
import {
|
||||
immichAlbum,
|
||||
immichAlbumDetail,
|
||||
immichMetadataSearchResponse,
|
||||
} from "../../../tests/fixtures/immich";
|
||||
|
||||
const baseUrl = "http://immich.test";
|
||||
const apiKey = "test-api-key";
|
||||
const server = setupServer();
|
||||
const client = createImmichClient({ baseUrl, apiKey, timeoutMs: 1_000 });
|
||||
|
||||
beforeEach(() => server.listen({ onUnhandledRequest: "error" }));
|
||||
afterEach(() => server.resetHandlers());
|
||||
afterEach(() => server.close());
|
||||
|
||||
test("lists albums through the documented API with server-side authentication", async () => {
|
||||
server.use(
|
||||
http.get(`${baseUrl}/api/albums`, ({ request }) => {
|
||||
expect(request.headers.get("x-api-key")).toBe(apiKey);
|
||||
expect(request.headers.get("authorization")).toBeNull();
|
||||
return HttpResponse.json([immichAlbum]);
|
||||
}),
|
||||
);
|
||||
|
||||
await expect(client.listAlbums()).resolves.toEqual([immichAlbum]);
|
||||
});
|
||||
|
||||
test("gets album details from the documented album endpoint", async () => {
|
||||
server.use(
|
||||
http.get(`${baseUrl}/api/albums/album-1`, ({ request }) => {
|
||||
expect(request.method).toBe("GET");
|
||||
expect(request.headers.get("x-api-key")).toBe(apiKey);
|
||||
return HttpResponse.json(immichAlbumDetail);
|
||||
}),
|
||||
);
|
||||
|
||||
await expect(client.getAlbum("album-1")).resolves.toEqual(immichAlbumDetail);
|
||||
});
|
||||
|
||||
test("forces IMAGE and authorized album IDs in metadata search", async () => {
|
||||
server.use(
|
||||
http.post(`${baseUrl}/api/search/metadata`, async ({ request }) => {
|
||||
expect(request.method).toBe("POST");
|
||||
expect(request.headers.get("x-api-key")).toBe(apiKey);
|
||||
expect(request.headers.get("content-type")).toBe("application/json");
|
||||
await expect(request.json()).resolves.toEqual({
|
||||
albumIds: ["album-1"],
|
||||
description: "jubel",
|
||||
type: "IMAGE",
|
||||
page: 1,
|
||||
size: 60,
|
||||
});
|
||||
return HttpResponse.json(immichMetadataSearchResponse);
|
||||
}),
|
||||
);
|
||||
|
||||
await expect(
|
||||
client.searchPhotos({ albumIds: ["album-1"], description: "jubel", page: 1, size: 60 }),
|
||||
).resolves.toEqual({
|
||||
items: immichMetadataSearchResponse.assets.items,
|
||||
total: 1,
|
||||
nextPage: null,
|
||||
previousPage: null,
|
||||
});
|
||||
});
|
||||
|
||||
test("maps an Immich outage to IMMICH_UNAVAILABLE", async () => {
|
||||
server.use(http.get(`${baseUrl}/api/albums`, () => HttpResponse.error()));
|
||||
|
||||
await expect(client.listAlbums()).rejects.toMatchObject({ code: "IMMICH_UNAVAILABLE" });
|
||||
});
|
||||
|
||||
test("maps upstream authorization, missing, rate-limit, server, and malformed failures", async () => {
|
||||
server.use(http.get(`${baseUrl}/api/albums`, () => new HttpResponse(null, { status: 401 })));
|
||||
await expect(client.listAlbums()).rejects.toMatchObject({ code: "IMMICH_AUTH_FAILED" });
|
||||
|
||||
server.use(http.get(`${baseUrl}/api/albums`, () => new HttpResponse(null, { status: 403 })));
|
||||
await expect(client.listAlbums()).rejects.toMatchObject({ code: "IMMICH_AUTH_FAILED" });
|
||||
|
||||
server.use(http.get(`${baseUrl}/api/albums/hidden`, () => new HttpResponse(null, { status: 404 })));
|
||||
await expect(client.getAlbum("hidden")).rejects.toMatchObject({ code: "IMMICH_NOT_FOUND" });
|
||||
|
||||
server.use(http.get(`${baseUrl}/api/albums`, () => new HttpResponse(null, { status: 429 })));
|
||||
await expect(client.listAlbums()).rejects.toMatchObject({ code: "IMMICH_RATE_LIMITED" });
|
||||
|
||||
server.use(http.get(`${baseUrl}/api/albums`, () => new HttpResponse(null, { status: 503 })));
|
||||
await expect(client.listAlbums()).rejects.toMatchObject({ code: "IMMICH_UNAVAILABLE" });
|
||||
|
||||
server.use(http.get(`${baseUrl}/api/albums`, () => HttpResponse.json([{ id: "malformed" }])));
|
||||
await expect(client.listAlbums()).rejects.toMatchObject({ code: "IMMICH_INVALID_RESPONSE" });
|
||||
});
|
||||
|
||||
test("maps an aborted timeout signal to IMMICH_TIMEOUT", async () => {
|
||||
const timedOutClient = createImmichClient({
|
||||
baseUrl,
|
||||
apiKey,
|
||||
timeoutMs: 1,
|
||||
fetch: (_input, init) =>
|
||||
new Promise((_resolve, reject) => {
|
||||
init?.signal?.addEventListener("abort", () => reject(init.signal?.reason));
|
||||
}),
|
||||
});
|
||||
|
||||
await expect(timedOutClient.listAlbums()).rejects.toMatchObject({ code: "IMMICH_TIMEOUT" });
|
||||
});
|
||||
|
||||
test("streams binary endpoints without buffering and preserves safe response metadata", async () => {
|
||||
const bytes = new Uint8Array([1, 2, 3]);
|
||||
server.use(
|
||||
http.get(`${baseUrl}/api/assets/asset-1/thumbnail`, ({ request }) => {
|
||||
expect(request.method).toBe("GET");
|
||||
expect(request.headers.get("x-api-key")).toBe(apiKey);
|
||||
return new HttpResponse(bytes, {
|
||||
headers: {
|
||||
"content-type": "image/jpeg",
|
||||
"content-length": "3",
|
||||
"content-disposition": 'inline; filename="jubel.jpg"',
|
||||
},
|
||||
});
|
||||
}),
|
||||
http.get(`${baseUrl}/api/assets/asset-1/original`, ({ request }) => {
|
||||
expect(request.method).toBe("GET");
|
||||
expect(request.headers.get("x-api-key")).toBe(apiKey);
|
||||
return new HttpResponse(bytes, {
|
||||
headers: {
|
||||
"content-type": "image/jpeg",
|
||||
"content-length": "3",
|
||||
"content-disposition": 'attachment; filename="jubel.jpg"',
|
||||
},
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
const thumbnail = await client.getThumbnail("asset-1");
|
||||
expect(thumbnail).toMatchObject({ contentType: "image/jpeg", contentLength: 3, filename: "jubel.jpg" });
|
||||
await expect(new Response(thumbnail.body).arrayBuffer()).resolves.toEqual(bytes.buffer);
|
||||
|
||||
const original = await client.getOriginal("asset-1");
|
||||
expect(original).toMatchObject({ contentType: "image/jpeg", contentLength: 3, filename: "jubel.jpg" });
|
||||
await expect(new Response(original.body).arrayBuffer()).resolves.toEqual(bytes.buffer);
|
||||
});
|
||||
@@ -0,0 +1,220 @@
|
||||
import "server-only";
|
||||
|
||||
import { z } from "zod";
|
||||
|
||||
import { env } from "@/config/env";
|
||||
|
||||
import { ImmichClientError, type ImmichErrorCode } from "./errors";
|
||||
import type {
|
||||
ImmichAlbum,
|
||||
ImmichAlbumSummary,
|
||||
ImmichAsset,
|
||||
ImmichBinary,
|
||||
ImmichClient,
|
||||
ImmichSearchPage,
|
||||
} from "./types";
|
||||
|
||||
const nullableString = z.string().nullable().optional().transform((value) => value ?? null);
|
||||
|
||||
const assetSchema = z
|
||||
.object({
|
||||
id: z.string(),
|
||||
type: z.literal("IMAGE"),
|
||||
originalFileName: z.string(),
|
||||
originalMimeType: z.string(),
|
||||
localDateTime: nullableString,
|
||||
fileCreatedAt: nullableString,
|
||||
albums: z.array(z.object({ id: z.string() }).passthrough()).optional().default([]),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
const albumSummarySchema = z
|
||||
.object({
|
||||
id: z.string(),
|
||||
albumName: z.string(),
|
||||
description: nullableString,
|
||||
albumThumbnailAssetId: nullableString,
|
||||
assetCount: z.number().int().nonnegative(),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
const albumSchema = albumSummarySchema.extend({
|
||||
assets: z.array(assetSchema),
|
||||
});
|
||||
|
||||
const metadataSearchSchema = z
|
||||
.object({
|
||||
assets: z
|
||||
.object({
|
||||
items: z.array(assetSchema),
|
||||
total: z.number().int().nonnegative(),
|
||||
nextPage: z.number().int().nullable().optional().transform((value) => value ?? null),
|
||||
previousPage: z.number().int().nullable().optional().transform((value) => value ?? null),
|
||||
})
|
||||
.passthrough(),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
type FetchLike = typeof globalThis.fetch;
|
||||
|
||||
export type CreateImmichClientOptions = {
|
||||
baseUrl?: string;
|
||||
apiKey?: string;
|
||||
fetch?: FetchLike;
|
||||
timeoutMs?: number;
|
||||
};
|
||||
|
||||
function errorForStatus(status: number): ImmichClientError {
|
||||
const code: ImmichErrorCode =
|
||||
status === 401 || status === 403
|
||||
? "IMMICH_AUTH_FAILED"
|
||||
: status === 404
|
||||
? "IMMICH_NOT_FOUND"
|
||||
: status === 429
|
||||
? "IMMICH_RATE_LIMITED"
|
||||
: status >= 500
|
||||
? "IMMICH_UNAVAILABLE"
|
||||
: "IMMICH_REQUEST_FAILED";
|
||||
|
||||
return new ImmichClientError(code, status);
|
||||
}
|
||||
|
||||
function responseFilename(response: Response, fallback: string): string {
|
||||
const contentDisposition = response.headers.get("content-disposition");
|
||||
const match = contentDisposition?.match(/filename\*?=(?:UTF-8''|\")(.*?)(?:\"|;|$)/i);
|
||||
const filename = match?.[1]?.trim();
|
||||
|
||||
if (!filename) {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
try {
|
||||
return decodeURIComponent(filename);
|
||||
} catch {
|
||||
return filename;
|
||||
}
|
||||
}
|
||||
|
||||
function contentLength(response: Response): number | null {
|
||||
const value = response.headers.get("content-length");
|
||||
if (!value || !/^\d+$/.test(value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const length = Number(value);
|
||||
return Number.isSafeInteger(length) ? length : null;
|
||||
}
|
||||
|
||||
export function createImmichClient({
|
||||
baseUrl = env.IMMICH_BASE_URL,
|
||||
apiKey = env.IMMICH_API_KEY,
|
||||
fetch: fetchImpl,
|
||||
timeoutMs = 15_000,
|
||||
}: CreateImmichClientOptions = {}): ImmichClient {
|
||||
const apiBaseUrl = `${baseUrl.replace(/\/+$/, "")}/api`;
|
||||
|
||||
async function request(path: string, init: RequestInit, signal?: AbortSignal): Promise<Response> {
|
||||
const timeoutSignal = AbortSignal.timeout(timeoutMs);
|
||||
const requestSignal = signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal;
|
||||
|
||||
let response: Response;
|
||||
try {
|
||||
response = await (fetchImpl ?? globalThis.fetch)(`${apiBaseUrl}${path}`, {
|
||||
...init,
|
||||
headers: {
|
||||
"x-api-key": apiKey,
|
||||
...init.headers,
|
||||
},
|
||||
signal: requestSignal,
|
||||
});
|
||||
} catch {
|
||||
if (timeoutSignal.aborted) {
|
||||
throw new ImmichClientError("IMMICH_TIMEOUT");
|
||||
}
|
||||
if (signal?.aborted) {
|
||||
throw new ImmichClientError("IMMICH_ABORTED");
|
||||
}
|
||||
throw new ImmichClientError("IMMICH_UNAVAILABLE");
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
throw errorForStatus(response.status);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
async function requestJson<T>(
|
||||
path: string,
|
||||
init: RequestInit,
|
||||
schema: z.ZodType<T>,
|
||||
signal?: AbortSignal,
|
||||
): Promise<T> {
|
||||
const response = await request(path, init, signal);
|
||||
|
||||
try {
|
||||
return schema.parse(await response.json());
|
||||
} catch {
|
||||
throw new ImmichClientError("IMMICH_INVALID_RESPONSE");
|
||||
}
|
||||
}
|
||||
|
||||
async function requestBinary(path: string, signal?: AbortSignal): Promise<ImmichBinary> {
|
||||
const response = await request(path, { method: "GET" }, signal);
|
||||
if (!response.body) {
|
||||
throw new ImmichClientError("IMMICH_INVALID_RESPONSE");
|
||||
}
|
||||
|
||||
return {
|
||||
body: response.body,
|
||||
contentType: response.headers.get("content-type") ?? "application/octet-stream",
|
||||
contentLength: contentLength(response),
|
||||
filename: responseFilename(response, "asset"),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
listAlbums(signal) {
|
||||
return requestJson<ImmichAlbumSummary[]>("/albums", { method: "GET" }, z.array(albumSummarySchema), signal);
|
||||
},
|
||||
getAlbum(albumId, signal) {
|
||||
return requestJson<ImmichAlbum>(
|
||||
`/albums/${encodeURIComponent(albumId)}`,
|
||||
{ method: "GET" },
|
||||
albumSchema,
|
||||
signal,
|
||||
);
|
||||
},
|
||||
searchPhotos(input, signal) {
|
||||
return requestJson<ImmichSearchPage>(
|
||||
"/search/metadata",
|
||||
{
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
albumIds: input.albumIds,
|
||||
...(input.description === undefined ? {} : { description: input.description }),
|
||||
type: "IMAGE",
|
||||
page: input.page,
|
||||
size: input.size,
|
||||
}),
|
||||
},
|
||||
metadataSearchSchema.transform(({ assets }) => ({
|
||||
items: assets.items,
|
||||
total: assets.total,
|
||||
nextPage: assets.nextPage,
|
||||
previousPage: assets.previousPage,
|
||||
})),
|
||||
signal,
|
||||
);
|
||||
},
|
||||
getThumbnail(assetId, signal) {
|
||||
return requestBinary(`/assets/${encodeURIComponent(assetId)}/thumbnail`, signal);
|
||||
},
|
||||
getOriginal(assetId, signal) {
|
||||
return requestBinary(`/assets/${encodeURIComponent(assetId)}/original`, signal);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export const immichClient = createImmichClient();
|
||||
@@ -0,0 +1,34 @@
|
||||
export const IMMICH_ERROR_CODES = [
|
||||
"IMMICH_AUTH_FAILED",
|
||||
"IMMICH_NOT_FOUND",
|
||||
"IMMICH_RATE_LIMITED",
|
||||
"IMMICH_TIMEOUT",
|
||||
"IMMICH_ABORTED",
|
||||
"IMMICH_UNAVAILABLE",
|
||||
"IMMICH_INVALID_RESPONSE",
|
||||
"IMMICH_REQUEST_FAILED",
|
||||
] as const;
|
||||
|
||||
export type ImmichErrorCode = (typeof IMMICH_ERROR_CODES)[number];
|
||||
|
||||
const errorMessages: Record<ImmichErrorCode, string> = {
|
||||
IMMICH_AUTH_FAILED: "Immich authentication failed",
|
||||
IMMICH_NOT_FOUND: "Immich resource not found",
|
||||
IMMICH_RATE_LIMITED: "Immich rate limit exceeded",
|
||||
IMMICH_TIMEOUT: "Immich request timed out",
|
||||
IMMICH_ABORTED: "Immich request aborted",
|
||||
IMMICH_UNAVAILABLE: "Immich is unavailable",
|
||||
IMMICH_INVALID_RESPONSE: "Immich returned an invalid response",
|
||||
IMMICH_REQUEST_FAILED: "Immich request failed",
|
||||
};
|
||||
|
||||
export class ImmichClientError extends Error {
|
||||
readonly name = "ImmichClientError";
|
||||
|
||||
constructor(
|
||||
readonly code: ImmichErrorCode,
|
||||
readonly status?: number,
|
||||
) {
|
||||
super(errorMessages[code]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
export type ImmichAlbumSummary = {
|
||||
id: string;
|
||||
albumName: string;
|
||||
description: string | null;
|
||||
albumThumbnailAssetId: string | null;
|
||||
assetCount: number;
|
||||
};
|
||||
|
||||
export type ImmichAsset = {
|
||||
id: string;
|
||||
type: "IMAGE";
|
||||
originalFileName: string;
|
||||
originalMimeType: string;
|
||||
localDateTime: string | null;
|
||||
fileCreatedAt: string | null;
|
||||
albums: Array<{ id: string }>;
|
||||
};
|
||||
|
||||
export type ImmichAlbum = ImmichAlbumSummary & {
|
||||
assets: ImmichAsset[];
|
||||
};
|
||||
|
||||
export type ImmichSearchPage = {
|
||||
items: ImmichAsset[];
|
||||
total: number;
|
||||
nextPage: number | null;
|
||||
previousPage: number | null;
|
||||
};
|
||||
|
||||
export type ImmichBinary = {
|
||||
body: ReadableStream<Uint8Array>;
|
||||
contentType: string;
|
||||
contentLength: number | null;
|
||||
filename: string;
|
||||
};
|
||||
|
||||
export interface ImmichClient {
|
||||
listAlbums(signal?: AbortSignal): Promise<ImmichAlbumSummary[]>;
|
||||
getAlbum(albumId: string, signal?: AbortSignal): Promise<ImmichAlbum>;
|
||||
searchPhotos(
|
||||
input: { albumIds: string[]; description?: string; page: number; size: number },
|
||||
signal?: AbortSignal,
|
||||
): Promise<ImmichSearchPage>;
|
||||
getThumbnail(assetId: string, signal?: AbortSignal): Promise<ImmichBinary>;
|
||||
getOriginal(assetId: string, signal?: AbortSignal): Promise<ImmichBinary>;
|
||||
}
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
export const immichAlbum = {
|
||||
id: "album-1",
|
||||
albumName: "Jubel",
|
||||
description: "Bilder vom Jubel",
|
||||
albumThumbnailAssetId: "asset-1",
|
||||
assetCount: 1,
|
||||
};
|
||||
|
||||
export const immichAsset = {
|
||||
id: "asset-1",
|
||||
type: "IMAGE",
|
||||
originalFileName: "jubel.jpg",
|
||||
originalMimeType: "image/jpeg",
|
||||
localDateTime: "2026-08-08T12:00:00.000Z",
|
||||
fileCreatedAt: "2026-08-08T12:00:00.000Z",
|
||||
albums: [{ id: "album-1" }],
|
||||
};
|
||||
|
||||
export const immichAlbumDetail = {
|
||||
...immichAlbum,
|
||||
assets: [immichAsset],
|
||||
};
|
||||
|
||||
export const immichMetadataSearchResponse = {
|
||||
assets: {
|
||||
items: [immichAsset],
|
||||
total: 1,
|
||||
nextPage: null,
|
||||
previousPage: null,
|
||||
},
|
||||
};
|
||||
Reference in new issue
Block a user