Compare commits
104 Commits
release/20
...
improve/pl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
019c2cec46 | ||
|
|
40b9508361 | ||
|
|
85285a5204 | ||
|
|
c0c0c37a67 | ||
|
|
4ac8a117ef | ||
|
|
c1bc430ee6 | ||
|
|
9201aa7d7d | ||
|
|
87395a4553 | ||
|
|
6063c633ee | ||
|
|
7481feb366 | ||
|
|
bdfa14fa54 | ||
|
|
0a61ec2bfe | ||
|
|
2bf0106aa2 | ||
|
|
ab7c29d228 | ||
|
|
d9c75ed79e | ||
|
|
6fa722df7b | ||
|
|
18864bfecf | ||
|
|
95754cb2b4 | ||
|
|
ed2a461dc5 | ||
|
|
8d5a456dbd | ||
|
|
2528bbb92f | ||
|
|
259cd48dbb | ||
|
|
b43531f200 | ||
|
|
26da3e18a9 | ||
|
|
bb4b640e58 | ||
|
|
1cc845e17d | ||
|
|
60bfb6fe2c | ||
|
|
144d14ab5b | ||
|
|
8f1ca6e282 | ||
|
|
a93758c6b7 | ||
|
|
1829c088cc | ||
|
|
ee1425d0dd | ||
|
|
24ae090916 | ||
|
|
a3aa9b68fc | ||
|
|
50f475334e | ||
|
|
7b18526f24 | ||
|
|
23afc201a1 | ||
|
|
b1982d74a6 | ||
|
|
e93a37c711 | ||
|
|
8d7509cdea | ||
|
|
e24d0ce605 | ||
|
|
f5d2e4f11f | ||
|
|
de725337d6 | ||
|
|
9d1d369f37 | ||
|
|
2bd925d441 | ||
|
|
bb8dc6f7eb | ||
|
|
be3e5ba7e7 | ||
|
|
663134839f | ||
|
|
736f83a70c | ||
|
|
05d2175f43 | ||
|
|
4caf0053cd | ||
|
|
97bd808431 | ||
|
|
a13c2fd4c1 | ||
|
|
16044b5840 | ||
|
|
93ce86f32d | ||
|
|
4ebf850cb6 | ||
|
|
76af7d5e10 | ||
|
|
507fe69efe | ||
|
|
23e3739718 | ||
|
|
5428a73811 | ||
|
|
4a154e6569 | ||
|
|
0aa5825d8b | ||
|
|
bdb63e99d5 | ||
|
|
6daa043a1b | ||
|
|
8175ec640a | ||
|
|
b5307e4a89 | ||
|
|
19294802be | ||
|
|
cbe3e14b47 | ||
|
|
9dcbc4a126 | ||
|
|
01df1663ad | ||
|
|
a215860782 | ||
|
|
abd5288da8 | ||
|
|
a89bc473f6 | ||
|
|
59b5a50a97 | ||
|
|
57cb59027b | ||
|
|
d1c9c3583f | ||
|
|
2462492c86 | ||
|
|
7a9f0c8756 | ||
|
|
46caf9b198 | ||
|
|
f5db54484c | ||
|
|
8deb6471b9 | ||
|
|
73b3ff8e41 | ||
|
|
016a18d3b2 | ||
|
|
ba31cdabea | ||
|
|
51510566bc | ||
|
|
cabee0ecc8 | ||
|
|
2c2b39a236 | ||
|
|
78450c9316 | ||
|
|
b18fd90b64 | ||
|
|
0188a8d7db | ||
|
|
6c63a8dc28 | ||
|
|
17d6ae15a5 | ||
|
|
40f72278a9 | ||
|
|
f717704731 | ||
|
|
185c225297 | ||
|
|
2694731c36 | ||
|
|
ae89af9978 | ||
|
|
87d617012f | ||
|
|
2420b3fa42 | ||
|
|
175a991ec4 | ||
|
|
0301649aff | ||
|
|
544b045300 | ||
|
|
65884293be | ||
|
|
3cb4861bac |
@@ -5,5 +5,5 @@
|
|||||||
"features": {
|
"features": {
|
||||||
"ghcr.io/NicoVIII/devcontainer-features/pnpm:1": {}
|
"ghcr.io/NicoVIII/devcontainer-features/pnpm:1": {}
|
||||||
},
|
},
|
||||||
"postCreateCommand": "mv .env.example .env && pnpm i"
|
"postCreateCommand": "cp .env.example .env && pnpm i"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ SESSION_SECRET='add some secret here'
|
|||||||
|
|
||||||
# Hoppscotch App Domain Config
|
# Hoppscotch App Domain Config
|
||||||
REDIRECT_URL="http://localhost:3000"
|
REDIRECT_URL="http://localhost:3000"
|
||||||
WHITELISTED_ORIGINS = "http://localhost:3170,http://localhost:3000,http://localhost:3100"
|
WHITELISTED_ORIGINS="http://localhost:3170,http://localhost:3000,http://localhost:3100"
|
||||||
VITE_ALLOWED_AUTH_PROVIDERS = GOOGLE,GITHUB,MICROSOFT,EMAIL
|
VITE_ALLOWED_AUTH_PROVIDERS=GOOGLE,GITHUB,MICROSOFT,EMAIL
|
||||||
|
|
||||||
# Google Auth Config
|
# Google Auth Config
|
||||||
GOOGLE_CLIENT_ID="************************************************"
|
GOOGLE_CLIENT_ID="************************************************"
|
||||||
@@ -59,3 +59,6 @@ VITE_BACKEND_API_URL=http://localhost:3170/v1
|
|||||||
# Terms Of Service And Privacy Policy Links (Optional)
|
# Terms Of Service And Privacy Policy Links (Optional)
|
||||||
VITE_APP_TOS_LINK=https://docs.hoppscotch.io/support/terms
|
VITE_APP_TOS_LINK=https://docs.hoppscotch.io/support/terms
|
||||||
VITE_APP_PRIVACY_POLICY_LINK=https://docs.hoppscotch.io/support/privacy
|
VITE_APP_PRIVACY_POLICY_LINK=https://docs.hoppscotch.io/support/privacy
|
||||||
|
|
||||||
|
# Set to `true` for subpath based access
|
||||||
|
ENABLE_SUBPATH_BASED_ACCESS=false
|
||||||
|
|||||||
3
.github/workflows/release-push-docker.yml
vendored
@@ -18,6 +18,9 @@ jobs:
|
|||||||
- name: Setup QEMU
|
- name: Setup QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Setup Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
|
|||||||
2
.github/workflows/ui.yml
vendored
@@ -36,7 +36,7 @@ jobs:
|
|||||||
|
|
||||||
# Deploy the ui site with netlify-cli
|
# Deploy the ui site with netlify-cli
|
||||||
- name: Deploy to Netlify (ui)
|
- name: Deploy to Netlify (ui)
|
||||||
run: npx netlify-cli deploy --dir=packages/hoppscotch-ui/.histoire/dist --prod
|
run: npx netlify-cli@15.11.0 deploy --dir=packages/hoppscotch-ui/.histoire/dist --prod
|
||||||
env:
|
env:
|
||||||
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_UI_SITE_ID }}
|
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_UI_SITE_ID }}
|
||||||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
||||||
|
|||||||
14
.vscode/extensions.json
vendored
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"recommendations": [
|
|
||||||
"antfu.iconify",
|
|
||||||
"vue.volar",
|
|
||||||
"esbenp.prettier-vscode",
|
|
||||||
"dbaeumer.vscode-eslint",
|
|
||||||
"editorconfig.editorconfig",
|
|
||||||
"csstools.postcss",
|
|
||||||
"folke.vscode-monorepo-workspace"
|
|
||||||
],
|
|
||||||
"unwantedRecommendations": [
|
|
||||||
"octref.vetur"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
19
aio-multiport-setup.Caddyfile
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
:3000 {
|
||||||
|
try_files {path} /
|
||||||
|
root * /site/selfhost-web
|
||||||
|
file_server
|
||||||
|
}
|
||||||
|
|
||||||
|
:3100 {
|
||||||
|
try_files {path} /
|
||||||
|
root * /site/sh-admin-multiport-setup
|
||||||
|
file_server
|
||||||
|
}
|
||||||
|
|
||||||
|
:3170 {
|
||||||
|
reverse_proxy localhost:8080
|
||||||
|
}
|
||||||
|
|
||||||
|
:80 {
|
||||||
|
respond 404
|
||||||
|
}
|
||||||
37
aio-subpath-access.Caddyfile
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
:3000 {
|
||||||
|
respond 404
|
||||||
|
}
|
||||||
|
|
||||||
|
:3100 {
|
||||||
|
respond 404
|
||||||
|
}
|
||||||
|
|
||||||
|
:3170 {
|
||||||
|
reverse_proxy localhost:8080
|
||||||
|
}
|
||||||
|
|
||||||
|
:80 {
|
||||||
|
# Serve the `selfhost-web` SPA by default
|
||||||
|
root * /site/selfhost-web
|
||||||
|
file_server
|
||||||
|
|
||||||
|
handle_path /admin* {
|
||||||
|
root * /site/sh-admin-subpath-access
|
||||||
|
file_server
|
||||||
|
|
||||||
|
# Ensures any non-existent file in the server is routed to the SPA
|
||||||
|
try_files {path} /
|
||||||
|
}
|
||||||
|
|
||||||
|
# Handle requests under `/backend*` path
|
||||||
|
handle_path /backend* {
|
||||||
|
reverse_proxy localhost:8080
|
||||||
|
}
|
||||||
|
|
||||||
|
# Catch-all route for unknown paths, serves `selfhost-web` SPA
|
||||||
|
handle {
|
||||||
|
root * /site/selfhost-web
|
||||||
|
file_server
|
||||||
|
try_files {path} /
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
:3000 {
|
|
||||||
try_files {path} /
|
|
||||||
root * /site/selfhost-web
|
|
||||||
file_server
|
|
||||||
}
|
|
||||||
|
|
||||||
:3100 {
|
|
||||||
try_files {path} /
|
|
||||||
root * /site/sh-admin
|
|
||||||
file_server
|
|
||||||
}
|
|
||||||
@@ -49,7 +49,8 @@ execSync(`npx import-meta-env -x build.env -e build.env -p "/site/**/*"`)
|
|||||||
|
|
||||||
fs.rmSync("build.env")
|
fs.rmSync("build.env")
|
||||||
|
|
||||||
const caddyProcess = runChildProcessWithPrefix("caddy", ["run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"], "App/Admin Dashboard Caddy")
|
const caddyFileName = process.env.ENABLE_SUBPATH_BASED_ACCESS === 'true' ? 'aio-subpath-access.Caddyfile' : 'aio-multiport-setup.Caddyfile'
|
||||||
|
const caddyProcess = runChildProcessWithPrefix("caddy", ["run", "--config", `/etc/caddy/${caddyFileName}`, "--adapter", "caddyfile"], "App/Admin Dashboard Caddy")
|
||||||
const backendProcess = runChildProcessWithPrefix("pnpm", ["run", "start:prod"], "Backend Server")
|
const backendProcess = runChildProcessWithPrefix("pnpm", ["run", "start:prod"], "Backend Server")
|
||||||
|
|
||||||
caddyProcess.on("exit", (code) => {
|
caddyProcess.on("exit", (code) => {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
# Edit the below line to match your PostgresDB URL if you have an outside DB (make sure to update the .env file as well)
|
# Edit the below line to match your PostgresDB URL if you have an outside DB (make sure to update the .env file as well)
|
||||||
- DATABASE_URL=postgresql://postgres:testpass@hoppscotch-db:5432/hoppscotch?connect_timeout=300
|
- DATABASE_URL=postgresql://postgres:testpass@hoppscotch-db:5432/hoppscotch?connect_timeout=300
|
||||||
- PORT=3170
|
- PORT=8080
|
||||||
volumes:
|
volumes:
|
||||||
# Uncomment the line below when modifying code. Only applicable when using the "dev" target.
|
# Uncomment the line below when modifying code. Only applicable when using the "dev" target.
|
||||||
# - ./packages/hoppscotch-backend/:/usr/src/app
|
# - ./packages/hoppscotch-backend/:/usr/src/app
|
||||||
@@ -26,6 +26,7 @@ services:
|
|||||||
hoppscotch-db:
|
hoppscotch-db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
ports:
|
ports:
|
||||||
|
- "3180:80"
|
||||||
- "3170:3170"
|
- "3170:3170"
|
||||||
|
|
||||||
# The main hoppscotch app. This will be hosted at port 3000
|
# The main hoppscotch app. This will be hosted at port 3000
|
||||||
@@ -42,7 +43,8 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- hoppscotch-backend
|
- hoppscotch-backend
|
||||||
ports:
|
ports:
|
||||||
- "3000:8080"
|
- "3080:80"
|
||||||
|
- "3000:3000"
|
||||||
|
|
||||||
# The Self Host dashboard for managing the app. This will be hosted at port 3100
|
# The Self Host dashboard for managing the app. This will be hosted at port 3100
|
||||||
# NOTE: To do TLS or play around with how the app is hosted, you can look into the Caddyfile for
|
# NOTE: To do TLS or play around with how the app is hosted, you can look into the Caddyfile for
|
||||||
@@ -58,7 +60,8 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- hoppscotch-backend
|
- hoppscotch-backend
|
||||||
ports:
|
ports:
|
||||||
- "3100:8080"
|
- "3280:80"
|
||||||
|
- "3100:3100"
|
||||||
|
|
||||||
# The service that spins up all 3 services at once in one container
|
# The service that spins up all 3 services at once in one container
|
||||||
hoppscotch-aio:
|
hoppscotch-aio:
|
||||||
@@ -76,6 +79,7 @@ services:
|
|||||||
- "3000:3000"
|
- "3000:3000"
|
||||||
- "3100:3100"
|
- "3100:3100"
|
||||||
- "3170:3170"
|
- "3170:3170"
|
||||||
|
- "3080:80"
|
||||||
|
|
||||||
# The preset DB service, you can delete/comment the below lines if
|
# The preset DB service, you can delete/comment the below lines if
|
||||||
# you are using an external postgres instance
|
# you are using an external postgres instance
|
||||||
|
|||||||
13
package.json
@@ -22,18 +22,19 @@
|
|||||||
"workspaces": [
|
"workspaces": [
|
||||||
"./packages/*"
|
"./packages/*"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
|
||||||
"husky": "^7.0.4",
|
|
||||||
"lint-staged": "^12.3.8"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "^16.2.3",
|
"@commitlint/cli": "^16.2.3",
|
||||||
"@commitlint/config-conventional": "^16.2.1",
|
"@commitlint/config-conventional": "^16.2.1",
|
||||||
"@types/node": "^17.0.24",
|
"@types/node": "17.0.27",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"http-server": "^14.1.1"
|
"http-server": "^14.1.1",
|
||||||
|
"husky": "^7.0.4",
|
||||||
|
"lint-staged": "12.4.0"
|
||||||
},
|
},
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
|
"overrides": {
|
||||||
|
"vue": "3.3.9"
|
||||||
|
},
|
||||||
"packageExtensions": {
|
"packageExtensions": {
|
||||||
"httpsnippet@^3.0.1": {
|
"httpsnippet@^3.0.1": {
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|||||||
@@ -17,16 +17,16 @@
|
|||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@codemirror/language": "^6.9.0",
|
"@codemirror/language": "6.9.0",
|
||||||
"@lezer/highlight": "^1.1.6",
|
"@lezer/highlight": "1.1.4",
|
||||||
"@lezer/lr": "^1.3.10"
|
"@lezer/lr": "^1.3.13"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@lezer/generator": "^1.5.0",
|
"@lezer/generator": "^1.5.1",
|
||||||
"mocha": "^9.2.2",
|
"mocha": "^9.2.2",
|
||||||
"rollup": "^2.70.2",
|
"rollup": "^3.29.3",
|
||||||
"rollup-plugin-dts": "^4.2.1",
|
"rollup-plugin-dts": "^6.0.2",
|
||||||
"rollup-plugin-ts": "^2.0.7",
|
"rollup-plugin-ts": "^3.4.5",
|
||||||
"typescript": "^4.6.3"
|
"typescript": "^5.2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3
packages/hoppscotch-backend/backend.Caddyfile
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
:80 :3170 {
|
||||||
|
reverse_proxy localhost:8080
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hoppscotch-backend",
|
"name": "hoppscotch-backend",
|
||||||
"version": "2023.8.1",
|
"version": "2023.8.4-1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"author": "",
|
"author": "",
|
||||||
"private": true,
|
"private": true,
|
||||||
@@ -24,18 +24,17 @@
|
|||||||
"do-test": "pnpm run test"
|
"do-test": "pnpm run test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nestjs-modules/mailer": "^1.8.1",
|
"@apollo/server": "^4.9.4",
|
||||||
"@nestjs/apollo": "^10.1.6",
|
"@nestjs-modules/mailer": "^1.9.1",
|
||||||
"@nestjs/common": "^9.2.1",
|
"@nestjs/apollo": "^12.0.9",
|
||||||
"@nestjs/core": "^9.2.1",
|
"@nestjs/common": "^10.2.6",
|
||||||
"@nestjs/graphql": "^10.1.6",
|
"@nestjs/core": "^10.2.6",
|
||||||
"@nestjs/jwt": "^10.0.1",
|
"@nestjs/graphql": "^12.0.9",
|
||||||
"@nestjs/passport": "^9.0.0",
|
"@nestjs/jwt": "^10.1.1",
|
||||||
"@nestjs/platform-express": "^9.2.1",
|
"@nestjs/passport": "^10.0.2",
|
||||||
"@nestjs/throttler": "^4.0.0",
|
"@nestjs/platform-express": "^10.2.6",
|
||||||
|
"@nestjs/throttler": "^5.0.0",
|
||||||
"@prisma/client": "^4.16.2",
|
"@prisma/client": "^4.16.2",
|
||||||
"apollo-server-express": "^3.11.1",
|
|
||||||
"apollo-server-plugin-base": "^3.7.1",
|
|
||||||
"argon2": "^0.30.3",
|
"argon2": "^0.30.3",
|
||||||
"bcrypt": "^5.1.0",
|
"bcrypt": "^5.1.0",
|
||||||
"cookie": "^0.5.0",
|
"cookie": "^0.5.0",
|
||||||
@@ -43,9 +42,9 @@
|
|||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"express-session": "^1.17.3",
|
"express-session": "^1.17.3",
|
||||||
"fp-ts": "^2.13.1",
|
"fp-ts": "^2.13.1",
|
||||||
"graphql": "^15.5.0",
|
"graphql": "^16.8.1",
|
||||||
"graphql-query-complexity": "^0.12.0",
|
"graphql-query-complexity": "^0.12.0",
|
||||||
"graphql-redis-subscriptions": "^2.5.0",
|
"graphql-redis-subscriptions": "^2.6.0",
|
||||||
"graphql-subscriptions": "^2.0.0",
|
"graphql-subscriptions": "^2.0.0",
|
||||||
"handlebars": "^4.7.7",
|
"handlebars": "^4.7.7",
|
||||||
"io-ts": "^2.2.16",
|
"io-ts": "^2.2.16",
|
||||||
@@ -63,9 +62,9 @@
|
|||||||
"rxjs": "^7.6.0"
|
"rxjs": "^7.6.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@nestjs/cli": "^9.1.5",
|
"@nestjs/cli": "^10.1.18",
|
||||||
"@nestjs/schematics": "^9.0.3",
|
"@nestjs/schematics": "^10.0.2",
|
||||||
"@nestjs/testing": "^9.2.1",
|
"@nestjs/testing": "^10.2.6",
|
||||||
"@relmify/jest-fp-ts": "^2.0.2",
|
"@relmify/jest-fp-ts": "^2.0.2",
|
||||||
"@types/argon2": "^0.15.0",
|
"@types/argon2": "^0.15.0",
|
||||||
"@types/bcrypt": "^5.0.0",
|
"@types/bcrypt": "^5.0.0",
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- A unique constraint covering the columns `[id]` on the table `Shortcode` will be added. If there are existing duplicate values, this will fail.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Shortcode" ADD COLUMN "embedProperties" JSONB,
|
||||||
|
ADD COLUMN "updatedOn" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "Shortcode_id_key" ON "Shortcode"("id");
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Shortcode" ADD CONSTRAINT "Shortcode_creatorUid_fkey" FOREIGN KEY ("creatorUid") REFERENCES "User"("uid") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "TeamCollection" ADD COLUMN "data" JSONB;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "UserCollection" ADD COLUMN "data" JSONB;
|
||||||
@@ -43,6 +43,7 @@ model TeamInvitation {
|
|||||||
model TeamCollection {
|
model TeamCollection {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
parentID String?
|
parentID String?
|
||||||
|
data Json?
|
||||||
parent TeamCollection? @relation("TeamCollectionChildParent", fields: [parentID], references: [id])
|
parent TeamCollection? @relation("TeamCollectionChildParent", fields: [parentID], references: [id])
|
||||||
children TeamCollection[] @relation("TeamCollectionChildParent")
|
children TeamCollection[] @relation("TeamCollectionChildParent")
|
||||||
requests TeamRequest[]
|
requests TeamRequest[]
|
||||||
@@ -68,10 +69,13 @@ model TeamRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model Shortcode {
|
model Shortcode {
|
||||||
id String @id
|
id String @id @unique
|
||||||
request Json
|
request Json
|
||||||
creatorUid String?
|
embedProperties Json?
|
||||||
createdOn DateTime @default(now())
|
creatorUid String?
|
||||||
|
User User? @relation(fields: [creatorUid], references: [uid])
|
||||||
|
createdOn DateTime @default(now())
|
||||||
|
updatedOn DateTime @default(now()) @updatedAt
|
||||||
|
|
||||||
@@unique(fields: [id, creatorUid], name: "creator_uid_shortcode_unique")
|
@@unique(fields: [id, creatorUid], name: "creator_uid_shortcode_unique")
|
||||||
}
|
}
|
||||||
@@ -102,6 +106,7 @@ model User {
|
|||||||
currentGQLSession Json?
|
currentGQLSession Json?
|
||||||
createdOn DateTime @default(now()) @db.Timestamp(3)
|
createdOn DateTime @default(now()) @db.Timestamp(3)
|
||||||
invitedUsers InvitedUsers[]
|
invitedUsers InvitedUsers[]
|
||||||
|
shortcodes Shortcode[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model Account {
|
model Account {
|
||||||
@@ -192,6 +197,7 @@ model UserCollection {
|
|||||||
userUid String
|
userUid String
|
||||||
user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
|
user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
|
||||||
title String
|
title String
|
||||||
|
data Json?
|
||||||
orderIndex Int
|
orderIndex Int
|
||||||
type ReqType
|
type ReqType
|
||||||
createdOn DateTime @default(now()) @db.Timestamp(3)
|
createdOn DateTime @default(now()) @db.Timestamp(3)
|
||||||
|
|||||||
66
packages/hoppscotch-backend/prod_run.mjs
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
#!/usr/local/bin/node
|
||||||
|
// @ts-check
|
||||||
|
|
||||||
|
import { spawn } from 'child_process';
|
||||||
|
import process from 'process';
|
||||||
|
|
||||||
|
function runChildProcessWithPrefix(command, args, prefix) {
|
||||||
|
const childProcess = spawn(command, args);
|
||||||
|
|
||||||
|
childProcess.stdout.on('data', (data) => {
|
||||||
|
const output = data.toString().trim().split('\n');
|
||||||
|
output.forEach((line) => {
|
||||||
|
console.log(`${prefix} | ${line}`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
childProcess.stderr.on('data', (data) => {
|
||||||
|
const error = data.toString().trim().split('\n');
|
||||||
|
error.forEach((line) => {
|
||||||
|
console.error(`${prefix} | ${line}`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
childProcess.on('close', (code) => {
|
||||||
|
console.log(`${prefix} Child process exited with code ${code}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
childProcess.on('error', (stuff) => {
|
||||||
|
console.error('error');
|
||||||
|
console.error(stuff);
|
||||||
|
});
|
||||||
|
|
||||||
|
return childProcess;
|
||||||
|
}
|
||||||
|
|
||||||
|
const caddyProcess = runChildProcessWithPrefix(
|
||||||
|
'caddy',
|
||||||
|
['run', '--config', '/etc/caddy/backend.Caddyfile', '--adapter', 'caddyfile'],
|
||||||
|
'App/Admin Dashboard Caddy',
|
||||||
|
);
|
||||||
|
const backendProcess = runChildProcessWithPrefix(
|
||||||
|
'pnpm',
|
||||||
|
['run', 'start:prod'],
|
||||||
|
'Backend Server',
|
||||||
|
);
|
||||||
|
|
||||||
|
caddyProcess.on('exit', (code) => {
|
||||||
|
console.log(`Exiting process because Caddy Server exited with code ${code}`);
|
||||||
|
process.exit(code);
|
||||||
|
});
|
||||||
|
|
||||||
|
backendProcess.on('exit', (code) => {
|
||||||
|
console.log(
|
||||||
|
`Exiting process because Backend Server exited with code ${code}`,
|
||||||
|
);
|
||||||
|
process.exit(code);
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('SIGINT', () => {
|
||||||
|
console.log('SIGINT received, exiting...');
|
||||||
|
|
||||||
|
caddyProcess.kill('SIGINT');
|
||||||
|
backendProcess.kill('SIGINT');
|
||||||
|
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
@@ -1,4 +1,9 @@
|
|||||||
import { ObjectType } from '@nestjs/graphql';
|
import { ObjectType, OmitType } from '@nestjs/graphql';
|
||||||
|
import { User } from 'src/user/user.model';
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
export class Admin {}
|
export class Admin extends OmitType(User, [
|
||||||
|
'isAdmin',
|
||||||
|
'currentRESTSession',
|
||||||
|
'currentGQLSession',
|
||||||
|
]) {}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import { TeamInvitationModule } from '../team-invitation/team-invitation.module'
|
|||||||
import { TeamEnvironmentsModule } from '../team-environments/team-environments.module';
|
import { TeamEnvironmentsModule } from '../team-environments/team-environments.module';
|
||||||
import { TeamCollectionModule } from '../team-collection/team-collection.module';
|
import { TeamCollectionModule } from '../team-collection/team-collection.module';
|
||||||
import { TeamRequestModule } from '../team-request/team-request.module';
|
import { TeamRequestModule } from '../team-request/team-request.module';
|
||||||
|
import { InfraResolver } from './infra.resolver';
|
||||||
|
import { ShortcodeModule } from 'src/shortcode/shortcode.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -22,8 +24,9 @@ import { TeamRequestModule } from '../team-request/team-request.module';
|
|||||||
TeamEnvironmentsModule,
|
TeamEnvironmentsModule,
|
||||||
TeamCollectionModule,
|
TeamCollectionModule,
|
||||||
TeamRequestModule,
|
TeamRequestModule,
|
||||||
|
ShortcodeModule,
|
||||||
],
|
],
|
||||||
providers: [AdminResolver, AdminService],
|
providers: [InfraResolver, AdminResolver, AdminService],
|
||||||
exports: [AdminService],
|
exports: [AdminService],
|
||||||
})
|
})
|
||||||
export class AdminModule {}
|
export class AdminModule {}
|
||||||
|
|||||||
@@ -21,15 +21,15 @@ import { InvitedUser } from './invited-user.model';
|
|||||||
import { GqlUser } from '../decorators/gql-user.decorator';
|
import { GqlUser } from '../decorators/gql-user.decorator';
|
||||||
import { PubSubService } from '../pubsub/pubsub.service';
|
import { PubSubService } from '../pubsub/pubsub.service';
|
||||||
import { Team, TeamMember } from '../team/team.model';
|
import { Team, TeamMember } from '../team/team.model';
|
||||||
import { User } from '../user/user.model';
|
|
||||||
import { TeamInvitation } from '../team-invitation/team-invitation.model';
|
|
||||||
import { PaginationArgs } from '../types/input-types.args';
|
|
||||||
import {
|
import {
|
||||||
AddUserToTeamArgs,
|
AddUserToTeamArgs,
|
||||||
ChangeUserRoleInTeamArgs,
|
ChangeUserRoleInTeamArgs,
|
||||||
} from './input-types.args';
|
} from './input-types.args';
|
||||||
import { GqlThrottlerGuard } from 'src/guards/gql-throttler.guard';
|
import { GqlThrottlerGuard } from 'src/guards/gql-throttler.guard';
|
||||||
import { SkipThrottle } from '@nestjs/throttler';
|
import { SkipThrottle } from '@nestjs/throttler';
|
||||||
|
import { User } from 'src/user/user.model';
|
||||||
|
import { PaginationArgs } from 'src/types/input-types.args';
|
||||||
|
import { TeamInvitation } from 'src/team-invitation/team-invitation.model';
|
||||||
|
|
||||||
@UseGuards(GqlThrottlerGuard)
|
@UseGuards(GqlThrottlerGuard)
|
||||||
@Resolver(() => Admin)
|
@Resolver(() => Admin)
|
||||||
@@ -51,6 +51,7 @@ export class AdminResolver {
|
|||||||
|
|
||||||
@ResolveField(() => [User], {
|
@ResolveField(() => [User], {
|
||||||
description: 'Returns a list of all admin users in infra',
|
description: 'Returns a list of all admin users in infra',
|
||||||
|
deprecationReason: 'Use `infra` query instead',
|
||||||
})
|
})
|
||||||
@UseGuards(GqlAuthGuard, GqlAdminGuard)
|
@UseGuards(GqlAuthGuard, GqlAdminGuard)
|
||||||
async admins() {
|
async admins() {
|
||||||
@@ -59,6 +60,7 @@ export class AdminResolver {
|
|||||||
}
|
}
|
||||||
@ResolveField(() => User, {
|
@ResolveField(() => User, {
|
||||||
description: 'Returns a user info by UID',
|
description: 'Returns a user info by UID',
|
||||||
|
deprecationReason: 'Use `infra` query instead',
|
||||||
})
|
})
|
||||||
@UseGuards(GqlAuthGuard, GqlAdminGuard)
|
@UseGuards(GqlAuthGuard, GqlAdminGuard)
|
||||||
async userInfo(
|
async userInfo(
|
||||||
@@ -76,6 +78,7 @@ export class AdminResolver {
|
|||||||
|
|
||||||
@ResolveField(() => [User], {
|
@ResolveField(() => [User], {
|
||||||
description: 'Returns a list of all the users in infra',
|
description: 'Returns a list of all the users in infra',
|
||||||
|
deprecationReason: 'Use `infra` query instead',
|
||||||
})
|
})
|
||||||
@UseGuards(GqlAuthGuard, GqlAdminGuard)
|
@UseGuards(GqlAuthGuard, GqlAdminGuard)
|
||||||
async allUsers(
|
async allUsers(
|
||||||
@@ -88,6 +91,7 @@ export class AdminResolver {
|
|||||||
|
|
||||||
@ResolveField(() => [InvitedUser], {
|
@ResolveField(() => [InvitedUser], {
|
||||||
description: 'Returns a list of all the invited users',
|
description: 'Returns a list of all the invited users',
|
||||||
|
deprecationReason: 'Use `infra` query instead',
|
||||||
})
|
})
|
||||||
async invitedUsers(@Parent() admin: Admin): Promise<InvitedUser[]> {
|
async invitedUsers(@Parent() admin: Admin): Promise<InvitedUser[]> {
|
||||||
const users = await this.adminService.fetchInvitedUsers();
|
const users = await this.adminService.fetchInvitedUsers();
|
||||||
@@ -96,6 +100,7 @@ export class AdminResolver {
|
|||||||
|
|
||||||
@ResolveField(() => [Team], {
|
@ResolveField(() => [Team], {
|
||||||
description: 'Returns a list of all the teams in the infra',
|
description: 'Returns a list of all the teams in the infra',
|
||||||
|
deprecationReason: 'Use `infra` query instead',
|
||||||
})
|
})
|
||||||
async allTeams(
|
async allTeams(
|
||||||
@Parent() admin: Admin,
|
@Parent() admin: Admin,
|
||||||
@@ -106,6 +111,7 @@ export class AdminResolver {
|
|||||||
}
|
}
|
||||||
@ResolveField(() => Team, {
|
@ResolveField(() => Team, {
|
||||||
description: 'Returns a team info by ID when requested by Admin',
|
description: 'Returns a team info by ID when requested by Admin',
|
||||||
|
deprecationReason: 'Use `infra` query instead',
|
||||||
})
|
})
|
||||||
async teamInfo(
|
async teamInfo(
|
||||||
@Parent() admin: Admin,
|
@Parent() admin: Admin,
|
||||||
@@ -123,6 +129,7 @@ export class AdminResolver {
|
|||||||
|
|
||||||
@ResolveField(() => Number, {
|
@ResolveField(() => Number, {
|
||||||
description: 'Return count of all the members in a team',
|
description: 'Return count of all the members in a team',
|
||||||
|
deprecationReason: 'Use `infra` query instead',
|
||||||
})
|
})
|
||||||
async membersCountInTeam(
|
async membersCountInTeam(
|
||||||
@Parent() admin: Admin,
|
@Parent() admin: Admin,
|
||||||
@@ -140,6 +147,7 @@ export class AdminResolver {
|
|||||||
|
|
||||||
@ResolveField(() => Number, {
|
@ResolveField(() => Number, {
|
||||||
description: 'Return count of all the stored collections in a team',
|
description: 'Return count of all the stored collections in a team',
|
||||||
|
deprecationReason: 'Use `infra` query instead',
|
||||||
})
|
})
|
||||||
async collectionCountInTeam(
|
async collectionCountInTeam(
|
||||||
@Parent() admin: Admin,
|
@Parent() admin: Admin,
|
||||||
@@ -155,6 +163,7 @@ export class AdminResolver {
|
|||||||
}
|
}
|
||||||
@ResolveField(() => Number, {
|
@ResolveField(() => Number, {
|
||||||
description: 'Return count of all the stored requests in a team',
|
description: 'Return count of all the stored requests in a team',
|
||||||
|
deprecationReason: 'Use `infra` query instead',
|
||||||
})
|
})
|
||||||
async requestCountInTeam(
|
async requestCountInTeam(
|
||||||
@Parent() admin: Admin,
|
@Parent() admin: Admin,
|
||||||
@@ -171,6 +180,7 @@ export class AdminResolver {
|
|||||||
|
|
||||||
@ResolveField(() => Number, {
|
@ResolveField(() => Number, {
|
||||||
description: 'Return count of all the stored environments in a team',
|
description: 'Return count of all the stored environments in a team',
|
||||||
|
deprecationReason: 'Use `infra` query instead',
|
||||||
})
|
})
|
||||||
async environmentCountInTeam(
|
async environmentCountInTeam(
|
||||||
@Parent() admin: Admin,
|
@Parent() admin: Admin,
|
||||||
@@ -187,6 +197,7 @@ export class AdminResolver {
|
|||||||
|
|
||||||
@ResolveField(() => [TeamInvitation], {
|
@ResolveField(() => [TeamInvitation], {
|
||||||
description: 'Return all the pending invitations in a team',
|
description: 'Return all the pending invitations in a team',
|
||||||
|
deprecationReason: 'Use `infra` query instead',
|
||||||
})
|
})
|
||||||
async pendingInvitationCountInTeam(
|
async pendingInvitationCountInTeam(
|
||||||
@Parent() admin: Admin,
|
@Parent() admin: Admin,
|
||||||
@@ -205,6 +216,7 @@ export class AdminResolver {
|
|||||||
|
|
||||||
@ResolveField(() => Number, {
|
@ResolveField(() => Number, {
|
||||||
description: 'Return total number of Users in organization',
|
description: 'Return total number of Users in organization',
|
||||||
|
deprecationReason: 'Use `infra` query instead',
|
||||||
})
|
})
|
||||||
async usersCount() {
|
async usersCount() {
|
||||||
return this.adminService.getUsersCount();
|
return this.adminService.getUsersCount();
|
||||||
@@ -212,6 +224,7 @@ export class AdminResolver {
|
|||||||
|
|
||||||
@ResolveField(() => Number, {
|
@ResolveField(() => Number, {
|
||||||
description: 'Return total number of Teams in organization',
|
description: 'Return total number of Teams in organization',
|
||||||
|
deprecationReason: 'Use `infra` query instead',
|
||||||
})
|
})
|
||||||
async teamsCount() {
|
async teamsCount() {
|
||||||
return this.adminService.getTeamsCount();
|
return this.adminService.getTeamsCount();
|
||||||
@@ -219,6 +232,7 @@ export class AdminResolver {
|
|||||||
|
|
||||||
@ResolveField(() => Number, {
|
@ResolveField(() => Number, {
|
||||||
description: 'Return total number of Team Collections in organization',
|
description: 'Return total number of Team Collections in organization',
|
||||||
|
deprecationReason: 'Use `infra` query instead',
|
||||||
})
|
})
|
||||||
async teamCollectionsCount() {
|
async teamCollectionsCount() {
|
||||||
return this.adminService.getTeamCollectionsCount();
|
return this.adminService.getTeamCollectionsCount();
|
||||||
@@ -226,6 +240,7 @@ export class AdminResolver {
|
|||||||
|
|
||||||
@ResolveField(() => Number, {
|
@ResolveField(() => Number, {
|
||||||
description: 'Return total number of Team Requests in organization',
|
description: 'Return total number of Team Requests in organization',
|
||||||
|
deprecationReason: 'Use `infra` query instead',
|
||||||
})
|
})
|
||||||
async teamRequestsCount() {
|
async teamRequestsCount() {
|
||||||
return this.adminService.getTeamRequestsCount();
|
return this.adminService.getTeamRequestsCount();
|
||||||
@@ -428,6 +443,23 @@ export class AdminResolver {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Mutation(() => Boolean, {
|
||||||
|
description: 'Revoke Shortcode by ID',
|
||||||
|
})
|
||||||
|
@UseGuards(GqlAuthGuard, GqlAdminGuard)
|
||||||
|
async revokeShortcodeByAdmin(
|
||||||
|
@Args({
|
||||||
|
name: 'code',
|
||||||
|
description: 'The shortcode to delete',
|
||||||
|
type: () => ID,
|
||||||
|
})
|
||||||
|
code: string,
|
||||||
|
): Promise<boolean> {
|
||||||
|
const res = await this.adminService.deleteShortcode(code);
|
||||||
|
if (E.isLeft(res)) throwErr(res.left);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Subscriptions */
|
/* Subscriptions */
|
||||||
|
|
||||||
@Subscription(() => InvitedUser, {
|
@Subscription(() => InvitedUser, {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
INVALID_EMAIL,
|
INVALID_EMAIL,
|
||||||
USER_ALREADY_INVITED,
|
USER_ALREADY_INVITED,
|
||||||
} from '../errors';
|
} from '../errors';
|
||||||
|
import { ShortcodeService } from 'src/shortcode/shortcode.service';
|
||||||
|
|
||||||
const mockPrisma = mockDeep<PrismaService>();
|
const mockPrisma = mockDeep<PrismaService>();
|
||||||
const mockPubSub = mockDeep<PubSubService>();
|
const mockPubSub = mockDeep<PubSubService>();
|
||||||
@@ -25,6 +26,7 @@ const mockTeamRequestService = mockDeep<TeamRequestService>();
|
|||||||
const mockTeamInvitationService = mockDeep<TeamInvitationService>();
|
const mockTeamInvitationService = mockDeep<TeamInvitationService>();
|
||||||
const mockTeamCollectionService = mockDeep<TeamCollectionService>();
|
const mockTeamCollectionService = mockDeep<TeamCollectionService>();
|
||||||
const mockMailerService = mockDeep<MailerService>();
|
const mockMailerService = mockDeep<MailerService>();
|
||||||
|
const mockShortcodeService = mockDeep<ShortcodeService>();
|
||||||
|
|
||||||
const adminService = new AdminService(
|
const adminService = new AdminService(
|
||||||
mockUserService,
|
mockUserService,
|
||||||
@@ -36,6 +38,7 @@ const adminService = new AdminService(
|
|||||||
mockPubSub as any,
|
mockPubSub as any,
|
||||||
mockPrisma as any,
|
mockPrisma as any,
|
||||||
mockMailerService,
|
mockMailerService,
|
||||||
|
mockShortcodeService,
|
||||||
);
|
);
|
||||||
|
|
||||||
const invitedUsers: InvitedUsers[] = [
|
const invitedUsers: InvitedUsers[] = [
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import { TeamRequestService } from '../team-request/team-request.service';
|
|||||||
import { TeamEnvironmentsService } from '../team-environments/team-environments.service';
|
import { TeamEnvironmentsService } from '../team-environments/team-environments.service';
|
||||||
import { TeamInvitationService } from '../team-invitation/team-invitation.service';
|
import { TeamInvitationService } from '../team-invitation/team-invitation.service';
|
||||||
import { TeamMemberRole } from '../team/team.model';
|
import { TeamMemberRole } from '../team/team.model';
|
||||||
|
import { ShortcodeService } from 'src/shortcode/shortcode.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AdminService {
|
export class AdminService {
|
||||||
@@ -37,6 +38,7 @@ export class AdminService {
|
|||||||
private readonly pubsub: PubSubService,
|
private readonly pubsub: PubSubService,
|
||||||
private readonly prisma: PrismaService,
|
private readonly prisma: PrismaService,
|
||||||
private readonly mailerService: MailerService,
|
private readonly mailerService: MailerService,
|
||||||
|
private readonly shortcodeService: ShortcodeService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,7 +76,7 @@ export class AdminService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await this.mailerService.sendUserInvitationEmail(inviteeEmail, {
|
await this.mailerService.sendUserInvitationEmail(inviteeEmail, {
|
||||||
template: 'code-your-own',
|
template: 'user-invitation',
|
||||||
variables: {
|
variables: {
|
||||||
inviteeEmail: inviteeEmail,
|
inviteeEmail: inviteeEmail,
|
||||||
magicLink: `${process.env.VITE_BASE_URL}`,
|
magicLink: `${process.env.VITE_BASE_URL}`,
|
||||||
@@ -432,4 +434,35 @@ export class AdminService {
|
|||||||
|
|
||||||
return E.right(teamInvite.right);
|
return E.right(teamInvite.right);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch all created ShortCodes
|
||||||
|
*
|
||||||
|
* @param args Pagination arguments
|
||||||
|
* @param userEmail User email
|
||||||
|
* @returns ShortcodeWithUserEmail
|
||||||
|
*/
|
||||||
|
async fetchAllShortcodes(
|
||||||
|
cursorID: string,
|
||||||
|
take: number,
|
||||||
|
userEmail: string = null,
|
||||||
|
) {
|
||||||
|
return this.shortcodeService.fetchAllShortcodes(
|
||||||
|
{ cursor: cursorID, take },
|
||||||
|
userEmail,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a Shortcode
|
||||||
|
*
|
||||||
|
* @param shortcodeID ID of Shortcode being deleted
|
||||||
|
* @returns Boolean on successful deletion
|
||||||
|
*/
|
||||||
|
async deleteShortcode(shortcodeID: string) {
|
||||||
|
const result = await this.shortcodeService.deleteShortcode(shortcodeID);
|
||||||
|
|
||||||
|
if (E.isLeft(result)) return E.left(result.left);
|
||||||
|
return E.right(result.right);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10
packages/hoppscotch-backend/src/admin/infra.model.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { Field, ObjectType } from '@nestjs/graphql';
|
||||||
|
import { Admin } from './admin.model';
|
||||||
|
|
||||||
|
@ObjectType()
|
||||||
|
export class Infra {
|
||||||
|
@Field(() => Admin, {
|
||||||
|
description: 'Admin who executed the action',
|
||||||
|
})
|
||||||
|
executedBy: Admin;
|
||||||
|
}
|
||||||
225
packages/hoppscotch-backend/src/admin/infra.resolver.ts
Normal file
@@ -0,0 +1,225 @@
|
|||||||
|
import { UseGuards } from '@nestjs/common';
|
||||||
|
import { Args, ID, Query, ResolveField, Resolver } from '@nestjs/graphql';
|
||||||
|
import { GqlThrottlerGuard } from 'src/guards/gql-throttler.guard';
|
||||||
|
import { Infra } from './infra.model';
|
||||||
|
import { AdminService } from './admin.service';
|
||||||
|
import { GqlAuthGuard } from 'src/guards/gql-auth.guard';
|
||||||
|
import { GqlAdminGuard } from './guards/gql-admin.guard';
|
||||||
|
import { User } from 'src/user/user.model';
|
||||||
|
import { AuthUser } from 'src/types/AuthUser';
|
||||||
|
import { throwErr } from 'src/utils';
|
||||||
|
import * as E from 'fp-ts/Either';
|
||||||
|
import { Admin } from './admin.model';
|
||||||
|
import { PaginationArgs } from 'src/types/input-types.args';
|
||||||
|
import { InvitedUser } from './invited-user.model';
|
||||||
|
import { Team } from 'src/team/team.model';
|
||||||
|
import { TeamInvitation } from 'src/team-invitation/team-invitation.model';
|
||||||
|
import { GqlAdmin } from './decorators/gql-admin.decorator';
|
||||||
|
import { ShortcodeWithUserEmail } from 'src/shortcode/shortcode.model';
|
||||||
|
|
||||||
|
@UseGuards(GqlThrottlerGuard)
|
||||||
|
@Resolver(() => Infra)
|
||||||
|
export class InfraResolver {
|
||||||
|
constructor(private adminService: AdminService) {}
|
||||||
|
|
||||||
|
@Query(() => Infra, {
|
||||||
|
description: 'Fetch details of the Infrastructure',
|
||||||
|
})
|
||||||
|
@UseGuards(GqlAuthGuard, GqlAdminGuard)
|
||||||
|
infra(@GqlAdmin() admin: Admin) {
|
||||||
|
const infra: Infra = { executedBy: admin };
|
||||||
|
return infra;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResolveField(() => [User], {
|
||||||
|
description: 'Returns a list of all admin users in infra',
|
||||||
|
})
|
||||||
|
@UseGuards(GqlAuthGuard, GqlAdminGuard)
|
||||||
|
async admins() {
|
||||||
|
const admins = await this.adminService.fetchAdmins();
|
||||||
|
return admins;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResolveField(() => User, {
|
||||||
|
description: 'Returns a user info by UID',
|
||||||
|
})
|
||||||
|
@UseGuards(GqlAuthGuard, GqlAdminGuard)
|
||||||
|
async userInfo(
|
||||||
|
@Args({
|
||||||
|
name: 'userUid',
|
||||||
|
type: () => ID,
|
||||||
|
description: 'The user UID',
|
||||||
|
})
|
||||||
|
userUid: string,
|
||||||
|
): Promise<AuthUser> {
|
||||||
|
const user = await this.adminService.fetchUserInfo(userUid);
|
||||||
|
if (E.isLeft(user)) throwErr(user.left);
|
||||||
|
return user.right;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResolveField(() => [User], {
|
||||||
|
description: 'Returns a list of all the users in infra',
|
||||||
|
})
|
||||||
|
@UseGuards(GqlAuthGuard, GqlAdminGuard)
|
||||||
|
async allUsers(@Args() args: PaginationArgs): Promise<AuthUser[]> {
|
||||||
|
const users = await this.adminService.fetchUsers(args.cursor, args.take);
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResolveField(() => [InvitedUser], {
|
||||||
|
description: 'Returns a list of all the invited users',
|
||||||
|
})
|
||||||
|
async invitedUsers(): Promise<InvitedUser[]> {
|
||||||
|
const users = await this.adminService.fetchInvitedUsers();
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResolveField(() => [Team], {
|
||||||
|
description: 'Returns a list of all the teams in the infra',
|
||||||
|
})
|
||||||
|
async allTeams(@Args() args: PaginationArgs): Promise<Team[]> {
|
||||||
|
const teams = await this.adminService.fetchAllTeams(args.cursor, args.take);
|
||||||
|
return teams;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResolveField(() => Team, {
|
||||||
|
description: 'Returns a team info by ID when requested by Admin',
|
||||||
|
})
|
||||||
|
async teamInfo(
|
||||||
|
@Args({
|
||||||
|
name: 'teamID',
|
||||||
|
type: () => ID,
|
||||||
|
description: 'Team ID for which info to fetch',
|
||||||
|
})
|
||||||
|
teamID: string,
|
||||||
|
): Promise<Team> {
|
||||||
|
const team = await this.adminService.getTeamInfo(teamID);
|
||||||
|
if (E.isLeft(team)) throwErr(team.left);
|
||||||
|
return team.right;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResolveField(() => Number, {
|
||||||
|
description: 'Return count of all the members in a team',
|
||||||
|
})
|
||||||
|
async membersCountInTeam(
|
||||||
|
@Args({
|
||||||
|
name: 'teamID',
|
||||||
|
type: () => ID,
|
||||||
|
description: 'Team ID for which team members to fetch',
|
||||||
|
nullable: false,
|
||||||
|
})
|
||||||
|
teamID: string,
|
||||||
|
): Promise<number> {
|
||||||
|
const teamMembersCount = await this.adminService.membersCountInTeam(teamID);
|
||||||
|
return teamMembersCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResolveField(() => Number, {
|
||||||
|
description: 'Return count of all the stored collections in a team',
|
||||||
|
})
|
||||||
|
async collectionCountInTeam(
|
||||||
|
@Args({
|
||||||
|
name: 'teamID',
|
||||||
|
type: () => ID,
|
||||||
|
description: 'Team ID for which team members to fetch',
|
||||||
|
})
|
||||||
|
teamID: string,
|
||||||
|
): Promise<number> {
|
||||||
|
const teamCollCount = await this.adminService.collectionCountInTeam(teamID);
|
||||||
|
return teamCollCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResolveField(() => Number, {
|
||||||
|
description: 'Return count of all the stored requests in a team',
|
||||||
|
})
|
||||||
|
async requestCountInTeam(
|
||||||
|
@Args({
|
||||||
|
name: 'teamID',
|
||||||
|
type: () => ID,
|
||||||
|
description: 'Team ID for which team members to fetch',
|
||||||
|
})
|
||||||
|
teamID: string,
|
||||||
|
): Promise<number> {
|
||||||
|
const teamReqCount = await this.adminService.requestCountInTeam(teamID);
|
||||||
|
return teamReqCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResolveField(() => Number, {
|
||||||
|
description: 'Return count of all the stored environments in a team',
|
||||||
|
})
|
||||||
|
async environmentCountInTeam(
|
||||||
|
@Args({
|
||||||
|
name: 'teamID',
|
||||||
|
type: () => ID,
|
||||||
|
description: 'Team ID for which team members to fetch',
|
||||||
|
})
|
||||||
|
teamID: string,
|
||||||
|
): Promise<number> {
|
||||||
|
const envsCount = await this.adminService.environmentCountInTeam(teamID);
|
||||||
|
return envsCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResolveField(() => [TeamInvitation], {
|
||||||
|
description: 'Return all the pending invitations in a team',
|
||||||
|
})
|
||||||
|
async pendingInvitationCountInTeam(
|
||||||
|
@Args({
|
||||||
|
name: 'teamID',
|
||||||
|
type: () => ID,
|
||||||
|
description: 'Team ID for which team members to fetch',
|
||||||
|
})
|
||||||
|
teamID: string,
|
||||||
|
) {
|
||||||
|
const invitations = await this.adminService.pendingInvitationCountInTeam(
|
||||||
|
teamID,
|
||||||
|
);
|
||||||
|
return invitations;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResolveField(() => Number, {
|
||||||
|
description: 'Return total number of Users in organization',
|
||||||
|
})
|
||||||
|
async usersCount() {
|
||||||
|
return this.adminService.getUsersCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResolveField(() => Number, {
|
||||||
|
description: 'Return total number of Teams in organization',
|
||||||
|
})
|
||||||
|
async teamsCount() {
|
||||||
|
return this.adminService.getTeamsCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResolveField(() => Number, {
|
||||||
|
description: 'Return total number of Team Collections in organization',
|
||||||
|
})
|
||||||
|
async teamCollectionsCount() {
|
||||||
|
return this.adminService.getTeamCollectionsCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResolveField(() => Number, {
|
||||||
|
description: 'Return total number of Team Requests in organization',
|
||||||
|
})
|
||||||
|
async teamRequestsCount() {
|
||||||
|
return this.adminService.getTeamRequestsCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResolveField(() => [ShortcodeWithUserEmail], {
|
||||||
|
description: 'Returns a list of all the shortcodes in the infra',
|
||||||
|
})
|
||||||
|
async allShortcodes(
|
||||||
|
@Args() args: PaginationArgs,
|
||||||
|
@Args({
|
||||||
|
name: 'userEmail',
|
||||||
|
nullable: true,
|
||||||
|
description: 'Users email to filter shortcodes by',
|
||||||
|
})
|
||||||
|
userEmail: string,
|
||||||
|
) {
|
||||||
|
return await this.adminService.fetchAllShortcodes(
|
||||||
|
args.cursor,
|
||||||
|
args.take,
|
||||||
|
userEmail,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,12 +27,7 @@ import { AppController } from './app.controller';
|
|||||||
buildSchemaOptions: {
|
buildSchemaOptions: {
|
||||||
numberScalarMode: 'integer',
|
numberScalarMode: 'integer',
|
||||||
},
|
},
|
||||||
cors: {
|
|
||||||
origin: process.env.WHITELISTED_ORIGINS.split(','),
|
|
||||||
credentials: true,
|
|
||||||
},
|
|
||||||
playground: process.env.PRODUCTION !== 'true',
|
playground: process.env.PRODUCTION !== 'true',
|
||||||
debug: process.env.PRODUCTION !== 'true',
|
|
||||||
autoSchemaFile: true,
|
autoSchemaFile: true,
|
||||||
installSubscriptionHandlers: true,
|
installSubscriptionHandlers: true,
|
||||||
subscriptions: {
|
subscriptions: {
|
||||||
@@ -62,10 +57,12 @@ import { AppController } from './app.controller';
|
|||||||
}),
|
}),
|
||||||
driver: ApolloDriver,
|
driver: ApolloDriver,
|
||||||
}),
|
}),
|
||||||
ThrottlerModule.forRoot({
|
ThrottlerModule.forRoot([
|
||||||
ttl: +process.env.RATE_LIMIT_TTL,
|
{
|
||||||
limit: +process.env.RATE_LIMIT_MAX,
|
ttl: +process.env.RATE_LIMIT_TTL,
|
||||||
}),
|
limit: +process.env.RATE_LIMIT_MAX,
|
||||||
|
},
|
||||||
|
]),
|
||||||
UserModule,
|
UserModule,
|
||||||
AuthModule,
|
AuthModule,
|
||||||
AdminModule,
|
AdminModule,
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ export class AuthService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await this.mailerService.sendEmail(email, {
|
await this.mailerService.sendEmail(email, {
|
||||||
template: 'code-your-own',
|
template: 'user-invitation',
|
||||||
variables: {
|
variables: {
|
||||||
inviteeEmail: email,
|
inviteeEmail: email,
|
||||||
magicLink: `${url}/enter?token=${generatedTokens.token}`,
|
magicLink: `${url}/enter?token=${generatedTokens.token}`,
|
||||||
|
|||||||
@@ -254,6 +254,13 @@ export const TEAM_COLL_INVALID_JSON = 'team_coll/invalid_json';
|
|||||||
*/
|
*/
|
||||||
export const TEAM_NOT_OWNER = 'team_coll/team_not_owner' as const;
|
export const TEAM_NOT_OWNER = 'team_coll/team_not_owner' as const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Team Collection data is not valid
|
||||||
|
* (TeamCollectionService)
|
||||||
|
*/
|
||||||
|
export const TEAM_COLL_DATA_INVALID =
|
||||||
|
'team_coll/team_coll_data_invalid' as const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tried to perform an action on a request that doesn't accept their member role level
|
* Tried to perform an action on a request that doesn't accept their member role level
|
||||||
* (GqlRequestTeamMemberGuard)
|
* (GqlRequestTeamMemberGuard)
|
||||||
@@ -318,18 +325,6 @@ export const TEAM_INVITATION_NOT_FOUND =
|
|||||||
*/
|
*/
|
||||||
export const SHORTCODE_NOT_FOUND = 'shortcode/not_found' as const;
|
export const SHORTCODE_NOT_FOUND = 'shortcode/not_found' as const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Invalid ShortCode format
|
|
||||||
* (ShortcodeService)
|
|
||||||
*/
|
|
||||||
export const SHORTCODE_INVALID_JSON = 'shortcode/invalid_json' as const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ShortCode already exists in DB
|
|
||||||
* (ShortcodeService)
|
|
||||||
*/
|
|
||||||
export const SHORTCODE_ALREADY_EXISTS = 'shortcode/already_exists' as const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalid or non-existent TEAM ENVIRONMENT ID
|
* Invalid or non-existent TEAM ENVIRONMENT ID
|
||||||
* (TeamEnvironmentsService)
|
* (TeamEnvironmentsService)
|
||||||
@@ -597,6 +592,13 @@ export const USER_COLL_REORDERING_FAILED =
|
|||||||
export const USER_COLL_SAME_NEXT_COLL =
|
export const USER_COLL_SAME_NEXT_COLL =
|
||||||
'user_coll/user_collection_and_next_user_collection_are_same' as const;
|
'user_coll/user_collection_and_next_user_collection_are_same' as const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The User Collection data is not valid
|
||||||
|
* (UserCollectionService)
|
||||||
|
*/
|
||||||
|
export const USER_COLL_DATA_INVALID =
|
||||||
|
'user_coll/user_coll_data_invalid' as const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The User Collection does not belong to the logged-in user
|
* The User Collection does not belong to the logged-in user
|
||||||
* (UserCollectionService)
|
* (UserCollectionService)
|
||||||
@@ -621,3 +623,24 @@ export const MAILER_SMTP_URL_UNDEFINED = 'mailer/smtp_url_undefined' as const;
|
|||||||
*/
|
*/
|
||||||
export const MAILER_FROM_ADDRESS_UNDEFINED =
|
export const MAILER_FROM_ADDRESS_UNDEFINED =
|
||||||
'mailer/from_address_undefined' as const;
|
'mailer/from_address_undefined' as const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SharedRequest invalid request JSON format
|
||||||
|
* (ShortcodeService)
|
||||||
|
*/
|
||||||
|
export const SHORTCODE_INVALID_REQUEST_JSON =
|
||||||
|
'shortcode/request_invalid_format' as const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SharedRequest invalid properties JSON format
|
||||||
|
* (ShortcodeService)
|
||||||
|
*/
|
||||||
|
export const SHORTCODE_INVALID_PROPERTIES_JSON =
|
||||||
|
'shortcode/properties_invalid_format' as const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SharedRequest invalid properties not found
|
||||||
|
* (ShortcodeService)
|
||||||
|
*/
|
||||||
|
export const SHORTCODE_PROPERTIES_NOT_FOUND =
|
||||||
|
'shortcode/properties_not_found' as const;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import { UserRequestUserCollectionResolver } from './user-request/resolvers/user
|
|||||||
import { UserEnvsUserResolver } from './user-environment/user.resolver';
|
import { UserEnvsUserResolver } from './user-environment/user.resolver';
|
||||||
import { UserHistoryUserResolver } from './user-history/user.resolver';
|
import { UserHistoryUserResolver } from './user-history/user.resolver';
|
||||||
import { UserSettingsUserResolver } from './user-settings/user.resolver';
|
import { UserSettingsUserResolver } from './user-settings/user.resolver';
|
||||||
|
import { InfraResolver } from './admin/infra.resolver';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All the resolvers present in the application.
|
* All the resolvers present in the application.
|
||||||
@@ -34,6 +35,7 @@ import { UserSettingsUserResolver } from './user-settings/user.resolver';
|
|||||||
* NOTE: This needs to be KEPT UP-TO-DATE to keep the schema accurate
|
* NOTE: This needs to be KEPT UP-TO-DATE to keep the schema accurate
|
||||||
*/
|
*/
|
||||||
const RESOLVERS = [
|
const RESOLVERS = [
|
||||||
|
InfraResolver,
|
||||||
AdminResolver,
|
AdminResolver,
|
||||||
ShortcodeResolver,
|
ShortcodeResolver,
|
||||||
TeamResolver,
|
TeamResolver,
|
||||||
@@ -93,9 +95,7 @@ export async function emitGQLSchemaFile() {
|
|||||||
numberScalarMode: 'integer',
|
numberScalarMode: 'integer',
|
||||||
});
|
});
|
||||||
|
|
||||||
const schemaString = printSchema(schema, {
|
const schemaString = printSchema(schema);
|
||||||
commentDescriptions: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
logger.log(`Writing schema to GQL_SCHEMA_EMIT_LOCATION (${destination})`);
|
logger.log(`Writing schema to GQL_SCHEMA_EMIT_LOCATION (${destination})`);
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ import { Injectable } from '@nestjs/common';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ThrottlerBehindProxyGuard extends ThrottlerGuard {
|
export class ThrottlerBehindProxyGuard extends ThrottlerGuard {
|
||||||
protected getTracker(req: Record<string, any>): string {
|
protected async getTracker(req: Record<string, any>): Promise<string> {
|
||||||
return req.ips.length ? req.ips[0] : req.ip; // individualize IP extraction to meet your own needs
|
return req.ips.length ? req.ips[0] : req.ip; // individualize IP extraction to meet your own needs
|
||||||
// learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For#directives
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export type MailDescription = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type UserMagicLinkMailDescription = {
|
export type UserMagicLinkMailDescription = {
|
||||||
template: 'code-your-own';
|
template: 'user-invitation';
|
||||||
variables: {
|
variables: {
|
||||||
inviteeEmail: string;
|
inviteeEmail: string;
|
||||||
magicLink: string;
|
magicLink: string;
|
||||||
@@ -16,7 +16,7 @@ export type UserMagicLinkMailDescription = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type AdminUserInvitationMailDescription = {
|
export type AdminUserInvitationMailDescription = {
|
||||||
template: 'code-your-own';
|
template: 'user-invitation';
|
||||||
variables: {
|
variables: {
|
||||||
inviteeEmail: string;
|
inviteeEmail: string;
|
||||||
magicLink: string;
|
magicLink: string;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export class MailerService {
|
|||||||
case 'team-invitation':
|
case 'team-invitation':
|
||||||
return `${mailDesc.variables.invitee} invited you to join ${mailDesc.variables.invite_team_name} in Hoppscotch`;
|
return `${mailDesc.variables.invitee} invited you to join ${mailDesc.variables.invite_team_name} in Hoppscotch`;
|
||||||
|
|
||||||
case 'code-your-own':
|
case 'user-invitation':
|
||||||
return 'Sign in to Hoppscotch';
|
return 'Sign in to Hoppscotch';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
-->
|
-->
|
||||||
<style type="text/css" rel="stylesheet" media="all">
|
<style type="text/css" rel="stylesheet" media="all">
|
||||||
/* Base ------------------------------ */
|
/* Base ------------------------------ */
|
||||||
|
|
||||||
@import url("https://fonts.googleapis.com/css?family=Nunito+Sans:400,700&display=swap");
|
@import url("https://fonts.googleapis.com/css?family=Nunito+Sans:400,700&display=swap");
|
||||||
body {
|
body {
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
@@ -22,19 +22,19 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
-webkit-text-size-adjust: none;
|
-webkit-text-size-adjust: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: #3869D4;
|
color: #3869D4;
|
||||||
}
|
}
|
||||||
|
|
||||||
a img {
|
a img {
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
td {
|
td {
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
.preheader {
|
.preheader {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
@@ -47,13 +47,13 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
/* Type ------------------------------ */
|
/* Type ------------------------------ */
|
||||||
|
|
||||||
body,
|
body,
|
||||||
td,
|
td,
|
||||||
th {
|
th {
|
||||||
font-family: "Nunito Sans", Helvetica, Arial, sans-serif;
|
font-family: "Nunito Sans", Helvetica, Arial, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
color: #333333;
|
color: #333333;
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
color: #333333;
|
color: #333333;
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
h3 {
|
h3 {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
color: #333333;
|
color: #333333;
|
||||||
@@ -77,12 +77,12 @@
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
td,
|
td,
|
||||||
th {
|
th {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
p,
|
p,
|
||||||
ul,
|
ul,
|
||||||
ol,
|
ol,
|
||||||
@@ -91,25 +91,25 @@
|
|||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
line-height: 1.625;
|
line-height: 1.625;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.sub {
|
p.sub {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
/* Utilities ------------------------------ */
|
/* Utilities ------------------------------ */
|
||||||
|
|
||||||
.align-right {
|
.align-right {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.align-left {
|
.align-left {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.align-center {
|
.align-center {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
/* Buttons ------------------------------ */
|
/* Buttons ------------------------------ */
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
background-color: #3869D4;
|
background-color: #3869D4;
|
||||||
border-top: 10px solid #3869D4;
|
border-top: 10px solid #3869D4;
|
||||||
@@ -124,7 +124,7 @@
|
|||||||
-webkit-text-size-adjust: none;
|
-webkit-text-size-adjust: none;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button--green {
|
.button--green {
|
||||||
background-color: #22BC66;
|
background-color: #22BC66;
|
||||||
border-top: 10px solid #22BC66;
|
border-top: 10px solid #22BC66;
|
||||||
@@ -132,7 +132,7 @@
|
|||||||
border-bottom: 10px solid #22BC66;
|
border-bottom: 10px solid #22BC66;
|
||||||
border-left: 18px solid #22BC66;
|
border-left: 18px solid #22BC66;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button--red {
|
.button--red {
|
||||||
background-color: #FF6136;
|
background-color: #FF6136;
|
||||||
border-top: 10px solid #FF6136;
|
border-top: 10px solid #FF6136;
|
||||||
@@ -140,7 +140,7 @@
|
|||||||
border-bottom: 10px solid #FF6136;
|
border-bottom: 10px solid #FF6136;
|
||||||
border-left: 18px solid #FF6136;
|
border-left: 18px solid #FF6136;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media only screen and (max-width: 500px) {
|
@media only screen and (max-width: 500px) {
|
||||||
.button {
|
.button {
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
@@ -148,21 +148,21 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Attribute list ------------------------------ */
|
/* Attribute list ------------------------------ */
|
||||||
|
|
||||||
.attributes {
|
.attributes {
|
||||||
margin: 0 0 21px;
|
margin: 0 0 21px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.attributes_content {
|
.attributes_content {
|
||||||
background-color: #F4F4F7;
|
background-color: #F4F4F7;
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.attributes_item {
|
.attributes_item {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
/* Related Items ------------------------------ */
|
/* Related Items ------------------------------ */
|
||||||
|
|
||||||
.related {
|
.related {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -171,31 +171,31 @@
|
|||||||
-premailer-cellpadding: 0;
|
-premailer-cellpadding: 0;
|
||||||
-premailer-cellspacing: 0;
|
-premailer-cellspacing: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.related_item {
|
.related_item {
|
||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
color: #CBCCCF;
|
color: #CBCCCF;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
line-height: 18px;
|
line-height: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.related_item-title {
|
.related_item-title {
|
||||||
display: block;
|
display: block;
|
||||||
margin: .5em 0 0;
|
margin: .5em 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.related_item-thumb {
|
.related_item-thumb {
|
||||||
display: block;
|
display: block;
|
||||||
padding-bottom: 10px;
|
padding-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.related_heading {
|
.related_heading {
|
||||||
border-top: 1px solid #CBCCCF;
|
border-top: 1px solid #CBCCCF;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 25px 0 10px;
|
padding: 25px 0 10px;
|
||||||
}
|
}
|
||||||
/* Discount Code ------------------------------ */
|
/* Discount Code ------------------------------ */
|
||||||
|
|
||||||
.discount {
|
.discount {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -206,33 +206,33 @@
|
|||||||
background-color: #F4F4F7;
|
background-color: #F4F4F7;
|
||||||
border: 2px dashed #CBCCCF;
|
border: 2px dashed #CBCCCF;
|
||||||
}
|
}
|
||||||
|
|
||||||
.discount_heading {
|
.discount_heading {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.discount_body {
|
.discount_body {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
}
|
}
|
||||||
/* Social Icons ------------------------------ */
|
/* Social Icons ------------------------------ */
|
||||||
|
|
||||||
.social {
|
.social {
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.social td {
|
.social td {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.social_icon {
|
.social_icon {
|
||||||
height: 20px;
|
height: 20px;
|
||||||
margin: 0 8px 10px 8px;
|
margin: 0 8px 10px 8px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
/* Data table ------------------------------ */
|
/* Data table ------------------------------ */
|
||||||
|
|
||||||
.purchase {
|
.purchase {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -241,7 +241,7 @@
|
|||||||
-premailer-cellpadding: 0;
|
-premailer-cellpadding: 0;
|
||||||
-premailer-cellspacing: 0;
|
-premailer-cellspacing: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.purchase_content {
|
.purchase_content {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -250,50 +250,50 @@
|
|||||||
-premailer-cellpadding: 0;
|
-premailer-cellpadding: 0;
|
||||||
-premailer-cellspacing: 0;
|
-premailer-cellspacing: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.purchase_item {
|
.purchase_item {
|
||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
color: #51545E;
|
color: #51545E;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
line-height: 18px;
|
line-height: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.purchase_heading {
|
.purchase_heading {
|
||||||
padding-bottom: 8px;
|
padding-bottom: 8px;
|
||||||
border-bottom: 1px solid #EAEAEC;
|
border-bottom: 1px solid #EAEAEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
.purchase_heading p {
|
.purchase_heading p {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
color: #85878E;
|
color: #85878E;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.purchase_footer {
|
.purchase_footer {
|
||||||
padding-top: 15px;
|
padding-top: 15px;
|
||||||
border-top: 1px solid #EAEAEC;
|
border-top: 1px solid #EAEAEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
.purchase_total {
|
.purchase_total {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: #333333;
|
color: #333333;
|
||||||
}
|
}
|
||||||
|
|
||||||
.purchase_total--label {
|
.purchase_total--label {
|
||||||
padding: 0 15px 0 0;
|
padding: 0 15px 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
background-color: #F2F4F6;
|
background-color: #F2F4F6;
|
||||||
color: #51545E;
|
color: #51545E;
|
||||||
}
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
color: #51545E;
|
color: #51545E;
|
||||||
}
|
}
|
||||||
|
|
||||||
.email-wrapper {
|
.email-wrapper {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -303,7 +303,7 @@
|
|||||||
-premailer-cellspacing: 0;
|
-premailer-cellspacing: 0;
|
||||||
background-color: #F2F4F6;
|
background-color: #F2F4F6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.email-content {
|
.email-content {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -313,16 +313,16 @@
|
|||||||
-premailer-cellspacing: 0;
|
-premailer-cellspacing: 0;
|
||||||
}
|
}
|
||||||
/* Masthead ----------------------- */
|
/* Masthead ----------------------- */
|
||||||
|
|
||||||
.email-masthead {
|
.email-masthead {
|
||||||
padding: 25px 0;
|
padding: 25px 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.email-masthead_logo {
|
.email-masthead_logo {
|
||||||
width: 94px;
|
width: 94px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.email-masthead_name {
|
.email-masthead_name {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
@@ -331,7 +331,7 @@
|
|||||||
text-shadow: 0 1px 0 white;
|
text-shadow: 0 1px 0 white;
|
||||||
}
|
}
|
||||||
/* Body ------------------------------ */
|
/* Body ------------------------------ */
|
||||||
|
|
||||||
.email-body {
|
.email-body {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -340,7 +340,7 @@
|
|||||||
-premailer-cellpadding: 0;
|
-premailer-cellpadding: 0;
|
||||||
-premailer-cellspacing: 0;
|
-premailer-cellspacing: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.email-body_inner {
|
.email-body_inner {
|
||||||
width: 570px;
|
width: 570px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
@@ -350,7 +350,7 @@
|
|||||||
-premailer-cellspacing: 0;
|
-premailer-cellspacing: 0;
|
||||||
background-color: #FFFFFF;
|
background-color: #FFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
.email-footer {
|
.email-footer {
|
||||||
width: 570px;
|
width: 570px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
@@ -360,11 +360,11 @@
|
|||||||
-premailer-cellspacing: 0;
|
-premailer-cellspacing: 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.email-footer p {
|
.email-footer p {
|
||||||
color: #A8AAAF;
|
color: #A8AAAF;
|
||||||
}
|
}
|
||||||
|
|
||||||
.body-action {
|
.body-action {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 30px auto;
|
margin: 30px auto;
|
||||||
@@ -374,25 +374,25 @@
|
|||||||
-premailer-cellspacing: 0;
|
-premailer-cellspacing: 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.body-sub {
|
.body-sub {
|
||||||
margin-top: 25px;
|
margin-top: 25px;
|
||||||
padding-top: 25px;
|
padding-top: 25px;
|
||||||
border-top: 1px solid #EAEAEC;
|
border-top: 1px solid #EAEAEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content-cell {
|
.content-cell {
|
||||||
padding: 45px;
|
padding: 45px;
|
||||||
}
|
}
|
||||||
/*Media Queries ------------------------------ */
|
/*Media Queries ------------------------------ */
|
||||||
|
|
||||||
@media only screen and (max-width: 600px) {
|
@media only screen and (max-width: 600px) {
|
||||||
.email-body_inner,
|
.email-body_inner,
|
||||||
.email-footer {
|
.email-footer {
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
body,
|
body,
|
||||||
.email-body,
|
.email-body,
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { GraphQLSchemaHost } from '@nestjs/graphql';
|
import { GraphQLSchemaHost } from '@nestjs/graphql';
|
||||||
import {
|
import {
|
||||||
ApolloServerPlugin,
|
ApolloServerPlugin,
|
||||||
|
BaseContext,
|
||||||
GraphQLRequestListener,
|
GraphQLRequestListener,
|
||||||
} from 'apollo-server-plugin-base';
|
} from '@apollo/server';
|
||||||
import { Plugin } from '@nestjs/apollo';
|
import { Plugin } from '@nestjs/apollo';
|
||||||
import { GraphQLError } from 'graphql';
|
import { GraphQLError } from 'graphql';
|
||||||
import {
|
import {
|
||||||
@@ -17,7 +18,7 @@ const COMPLEXITY_LIMIT = 50;
|
|||||||
export class GQLComplexityPlugin implements ApolloServerPlugin {
|
export class GQLComplexityPlugin implements ApolloServerPlugin {
|
||||||
constructor(private gqlSchemaHost: GraphQLSchemaHost) {}
|
constructor(private gqlSchemaHost: GraphQLSchemaHost) {}
|
||||||
|
|
||||||
async requestDidStart(): Promise<GraphQLRequestListener> {
|
async requestDidStart(): Promise<GraphQLRequestListener<BaseContext>> {
|
||||||
const { schema } = this.gqlSchemaHost;
|
const { schema } = this.gqlSchemaHost;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ import {
|
|||||||
} from 'src/team-request/team-request.model';
|
} from 'src/team-request/team-request.model';
|
||||||
import { TeamInvitation } from 'src/team-invitation/team-invitation.model';
|
import { TeamInvitation } from 'src/team-invitation/team-invitation.model';
|
||||||
import { InvitedUser } from '../admin/invited-user.model';
|
import { InvitedUser } from '../admin/invited-user.model';
|
||||||
import { UserCollection } from '@prisma/client';
|
|
||||||
import {
|
import {
|
||||||
|
UserCollection,
|
||||||
UserCollectionRemovedData,
|
UserCollectionRemovedData,
|
||||||
UserCollectionReorderData,
|
UserCollectionReorderData,
|
||||||
} from 'src/user-collection/user-collections.model';
|
} from 'src/user-collection/user-collections.model';
|
||||||
@@ -69,5 +69,7 @@ export type TopicDef = {
|
|||||||
[topic: `team_req/${string}/req_deleted`]: string;
|
[topic: `team_req/${string}/req_deleted`]: string;
|
||||||
[topic: `team/${string}/invite_added`]: TeamInvitation;
|
[topic: `team/${string}/invite_added`]: TeamInvitation;
|
||||||
[topic: `team/${string}/invite_removed`]: string;
|
[topic: `team/${string}/invite_removed`]: string;
|
||||||
[topic: `shortcode/${string}/${'created' | 'revoked'}`]: Shortcode;
|
[
|
||||||
|
topic: `shortcode/${string}/${'created' | 'revoked' | 'updated'}`
|
||||||
|
]: Shortcode;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { Field, ID, ObjectType } from '@nestjs/graphql';
|
import { Field, ID, ObjectType } from '@nestjs/graphql';
|
||||||
|
import { User } from 'src/user/user.model';
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
export class Shortcode {
|
export class Shortcode {
|
||||||
@Field(() => ID, {
|
@Field(() => ID, {
|
||||||
description: 'The shortcode. 12 digit alphanumeric.',
|
description: 'The 12 digit alphanumeric code',
|
||||||
})
|
})
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
@@ -12,8 +13,57 @@ export class Shortcode {
|
|||||||
})
|
})
|
||||||
request: string;
|
request: string;
|
||||||
|
|
||||||
|
@Field({
|
||||||
|
description: 'JSON string representing the properties for an embed',
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
properties: string;
|
||||||
|
|
||||||
@Field({
|
@Field({
|
||||||
description: 'Timestamp of when the Shortcode was created',
|
description: 'Timestamp of when the Shortcode was created',
|
||||||
})
|
})
|
||||||
createdOn: Date;
|
createdOn: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ObjectType()
|
||||||
|
export class ShortcodeCreator {
|
||||||
|
@Field({
|
||||||
|
description: 'Uid of user who created the shortcode',
|
||||||
|
})
|
||||||
|
uid: string;
|
||||||
|
|
||||||
|
@Field({
|
||||||
|
description: 'Email of user who created the shortcode',
|
||||||
|
})
|
||||||
|
email: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ObjectType()
|
||||||
|
export class ShortcodeWithUserEmail {
|
||||||
|
@Field(() => ID, {
|
||||||
|
description: 'The 12 digit alphanumeric code',
|
||||||
|
})
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
@Field({
|
||||||
|
description: 'JSON string representing the request data',
|
||||||
|
})
|
||||||
|
request: string;
|
||||||
|
|
||||||
|
@Field({
|
||||||
|
description: 'JSON string representing the properties for an embed',
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
properties: string;
|
||||||
|
|
||||||
|
@Field({
|
||||||
|
description: 'Timestamp of when the Shortcode was created',
|
||||||
|
})
|
||||||
|
createdOn: Date;
|
||||||
|
|
||||||
|
@Field({
|
||||||
|
description: 'Details of user who created the shortcode',
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
creator: ShortcodeCreator;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { JwtModule } from '@nestjs/jwt';
|
|
||||||
import { PrismaModule } from 'src/prisma/prisma.module';
|
import { PrismaModule } from 'src/prisma/prisma.module';
|
||||||
import { PubSubModule } from 'src/pubsub/pubsub.module';
|
import { PubSubModule } from 'src/pubsub/pubsub.module';
|
||||||
import { UserModule } from 'src/user/user.module';
|
import { UserModule } from 'src/user/user.module';
|
||||||
@@ -7,14 +6,7 @@ import { ShortcodeResolver } from './shortcode.resolver';
|
|||||||
import { ShortcodeService } from './shortcode.service';
|
import { ShortcodeService } from './shortcode.service';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [PrismaModule, UserModule, PubSubModule],
|
||||||
PrismaModule,
|
|
||||||
UserModule,
|
|
||||||
PubSubModule,
|
|
||||||
JwtModule.register({
|
|
||||||
secret: process.env.JWT_SECRET,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
providers: [ShortcodeService, ShortcodeResolver],
|
providers: [ShortcodeService, ShortcodeResolver],
|
||||||
exports: [ShortcodeService],
|
exports: [ShortcodeService],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
Args,
|
Args,
|
||||||
Context,
|
|
||||||
ID,
|
ID,
|
||||||
Mutation,
|
Mutation,
|
||||||
Query,
|
Query,
|
||||||
@@ -9,28 +8,25 @@ import {
|
|||||||
} from '@nestjs/graphql';
|
} from '@nestjs/graphql';
|
||||||
import * as E from 'fp-ts/Either';
|
import * as E from 'fp-ts/Either';
|
||||||
import { UseGuards } from '@nestjs/common';
|
import { UseGuards } from '@nestjs/common';
|
||||||
import { Shortcode } from './shortcode.model';
|
import { Shortcode, ShortcodeWithUserEmail } from './shortcode.model';
|
||||||
import { ShortcodeService } from './shortcode.service';
|
import { ShortcodeService } from './shortcode.service';
|
||||||
import { UserService } from 'src/user/user.service';
|
|
||||||
import { throwErr } from 'src/utils';
|
import { throwErr } from 'src/utils';
|
||||||
import { GqlUser } from 'src/decorators/gql-user.decorator';
|
import { GqlUser } from 'src/decorators/gql-user.decorator';
|
||||||
import { GqlAuthGuard } from 'src/guards/gql-auth.guard';
|
import { GqlAuthGuard } from 'src/guards/gql-auth.guard';
|
||||||
import { User } from 'src/user/user.model';
|
import { User } from 'src/user/user.model';
|
||||||
import { PubSubService } from 'src/pubsub/pubsub.service';
|
import { PubSubService } from 'src/pubsub/pubsub.service';
|
||||||
import { AuthUser } from '../types/AuthUser';
|
import { AuthUser } from '../types/AuthUser';
|
||||||
import { JwtService } from '@nestjs/jwt';
|
|
||||||
import { PaginationArgs } from 'src/types/input-types.args';
|
import { PaginationArgs } from 'src/types/input-types.args';
|
||||||
import { GqlThrottlerGuard } from 'src/guards/gql-throttler.guard';
|
import { GqlThrottlerGuard } from 'src/guards/gql-throttler.guard';
|
||||||
import { SkipThrottle } from '@nestjs/throttler';
|
import { SkipThrottle } from '@nestjs/throttler';
|
||||||
|
import { GqlAdminGuard } from 'src/admin/guards/gql-admin.guard';
|
||||||
|
|
||||||
@UseGuards(GqlThrottlerGuard)
|
@UseGuards(GqlThrottlerGuard)
|
||||||
@Resolver(() => Shortcode)
|
@Resolver(() => Shortcode)
|
||||||
export class ShortcodeResolver {
|
export class ShortcodeResolver {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly shortcodeService: ShortcodeService,
|
private readonly shortcodeService: ShortcodeService,
|
||||||
private readonly userService: UserService,
|
|
||||||
private readonly pubsub: PubSubService,
|
private readonly pubsub: PubSubService,
|
||||||
private jwtService: JwtService,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/* Queries */
|
/* Queries */
|
||||||
@@ -64,20 +60,53 @@ export class ShortcodeResolver {
|
|||||||
@Mutation(() => Shortcode, {
|
@Mutation(() => Shortcode, {
|
||||||
description: 'Create a shortcode for the given request.',
|
description: 'Create a shortcode for the given request.',
|
||||||
})
|
})
|
||||||
|
@UseGuards(GqlAuthGuard)
|
||||||
async createShortcode(
|
async createShortcode(
|
||||||
|
@GqlUser() user: AuthUser,
|
||||||
@Args({
|
@Args({
|
||||||
name: 'request',
|
name: 'request',
|
||||||
description: 'JSON string of the request object',
|
description: 'JSON string of the request object',
|
||||||
})
|
})
|
||||||
request: string,
|
request: string,
|
||||||
@Context() ctx: any,
|
@Args({
|
||||||
|
name: 'properties',
|
||||||
|
description: 'JSON string of the properties of the embed',
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
properties: string,
|
||||||
) {
|
) {
|
||||||
const decodedAccessToken = this.jwtService.verify(
|
|
||||||
ctx.req.cookies['access_token'],
|
|
||||||
);
|
|
||||||
const result = await this.shortcodeService.createShortcode(
|
const result = await this.shortcodeService.createShortcode(
|
||||||
request,
|
request,
|
||||||
decodedAccessToken?.sub,
|
properties,
|
||||||
|
user,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (E.isLeft(result)) throwErr(result.left);
|
||||||
|
return result.right;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Mutation(() => Shortcode, {
|
||||||
|
description: 'Update a user generated Shortcode',
|
||||||
|
})
|
||||||
|
@UseGuards(GqlAuthGuard)
|
||||||
|
async updateEmbedProperties(
|
||||||
|
@GqlUser() user: AuthUser,
|
||||||
|
@Args({
|
||||||
|
name: 'code',
|
||||||
|
type: () => ID,
|
||||||
|
description: 'The Shortcode to update',
|
||||||
|
})
|
||||||
|
code: string,
|
||||||
|
@Args({
|
||||||
|
name: 'properties',
|
||||||
|
description: 'JSON string of the properties of the embed',
|
||||||
|
})
|
||||||
|
properties: string,
|
||||||
|
) {
|
||||||
|
const result = await this.shortcodeService.updateEmbedProperties(
|
||||||
|
code,
|
||||||
|
user.uid,
|
||||||
|
properties,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (E.isLeft(result)) throwErr(result.left);
|
if (E.isLeft(result)) throwErr(result.left);
|
||||||
@@ -93,7 +122,7 @@ export class ShortcodeResolver {
|
|||||||
@Args({
|
@Args({
|
||||||
name: 'code',
|
name: 'code',
|
||||||
type: () => ID,
|
type: () => ID,
|
||||||
description: 'The shortcode to resolve',
|
description: 'The shortcode to remove',
|
||||||
})
|
})
|
||||||
code: string,
|
code: string,
|
||||||
) {
|
) {
|
||||||
@@ -114,6 +143,16 @@ export class ShortcodeResolver {
|
|||||||
return this.pubsub.asyncIterator(`shortcode/${user.uid}/created`);
|
return this.pubsub.asyncIterator(`shortcode/${user.uid}/created`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscription(() => Shortcode, {
|
||||||
|
description: 'Listen for Shortcode updates',
|
||||||
|
resolve: (value) => value,
|
||||||
|
})
|
||||||
|
@SkipThrottle()
|
||||||
|
@UseGuards(GqlAuthGuard)
|
||||||
|
myShortcodesUpdated(@GqlUser() user: AuthUser) {
|
||||||
|
return this.pubsub.asyncIterator(`shortcode/${user.uid}/updated`);
|
||||||
|
}
|
||||||
|
|
||||||
@Subscription(() => Shortcode, {
|
@Subscription(() => Shortcode, {
|
||||||
description: 'Listen for shortcode deletion',
|
description: 'Listen for shortcode deletion',
|
||||||
resolve: (value) => value,
|
resolve: (value) => value,
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
import { mockDeep, mockReset } from 'jest-mock-extended';
|
import { mockDeep, mockReset } from 'jest-mock-extended';
|
||||||
import { PrismaService } from '../prisma/prisma.service';
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
import {
|
import {
|
||||||
SHORTCODE_ALREADY_EXISTS,
|
INVALID_EMAIL,
|
||||||
SHORTCODE_INVALID_JSON,
|
SHORTCODE_INVALID_PROPERTIES_JSON,
|
||||||
|
SHORTCODE_INVALID_REQUEST_JSON,
|
||||||
SHORTCODE_NOT_FOUND,
|
SHORTCODE_NOT_FOUND,
|
||||||
|
SHORTCODE_PROPERTIES_NOT_FOUND,
|
||||||
} from 'src/errors';
|
} from 'src/errors';
|
||||||
import { Shortcode } from './shortcode.model';
|
import { Shortcode, ShortcodeWithUserEmail } from './shortcode.model';
|
||||||
import { ShortcodeService } from './shortcode.service';
|
import { ShortcodeService } from './shortcode.service';
|
||||||
import { UserService } from 'src/user/user.service';
|
import { UserService } from 'src/user/user.service';
|
||||||
|
import { AuthUser } from 'src/types/AuthUser';
|
||||||
|
|
||||||
const mockPrisma = mockDeep<PrismaService>();
|
const mockPrisma = mockDeep<PrismaService>();
|
||||||
|
|
||||||
@@ -22,7 +25,7 @@ const mockFB = {
|
|||||||
doc: mockDocFunc,
|
doc: mockDocFunc,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const mockUserService = new UserService(mockFB as any, mockPubSub as any);
|
const mockUserService = new UserService(mockPrisma as any, mockPubSub as any);
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@@ -38,18 +41,34 @@ beforeEach(() => {
|
|||||||
});
|
});
|
||||||
const createdOn = new Date();
|
const createdOn = new Date();
|
||||||
|
|
||||||
const shortCodeWithOutUser = {
|
const user: AuthUser = {
|
||||||
id: '123',
|
uid: '123344',
|
||||||
request: '{}',
|
email: 'dwight@dundermifflin.com',
|
||||||
|
displayName: 'Dwight Schrute',
|
||||||
|
photoURL: 'https://en.wikipedia.org/wiki/Dwight_Schrute',
|
||||||
|
isAdmin: false,
|
||||||
|
refreshToken: 'hbfvdkhjbvkdvdfjvbnkhjb',
|
||||||
createdOn: createdOn,
|
createdOn: createdOn,
|
||||||
creatorUid: null,
|
currentGQLSession: {},
|
||||||
|
currentRESTSession: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
const shortCodeWithUser = {
|
const mockEmbed = {
|
||||||
id: '123',
|
id: '123',
|
||||||
request: '{}',
|
request: '{}',
|
||||||
|
embedProperties: '{}',
|
||||||
createdOn: createdOn,
|
createdOn: createdOn,
|
||||||
creatorUid: 'user_uid_1',
|
creatorUid: user.uid,
|
||||||
|
updatedOn: createdOn,
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockShortcode = {
|
||||||
|
id: '123',
|
||||||
|
request: '{}',
|
||||||
|
embedProperties: null,
|
||||||
|
createdOn: createdOn,
|
||||||
|
creatorUid: user.uid,
|
||||||
|
updatedOn: createdOn,
|
||||||
};
|
};
|
||||||
|
|
||||||
const shortcodes = [
|
const shortcodes = [
|
||||||
@@ -58,33 +77,67 @@ const shortcodes = [
|
|||||||
request: {
|
request: {
|
||||||
hello: 'there',
|
hello: 'there',
|
||||||
},
|
},
|
||||||
creatorUid: 'testuser',
|
embedProperties: {
|
||||||
|
foo: 'bar',
|
||||||
|
},
|
||||||
|
creatorUid: user.uid,
|
||||||
createdOn: new Date(),
|
createdOn: new Date(),
|
||||||
|
updatedOn: createdOn,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'blablabla1',
|
id: 'blablabla1',
|
||||||
request: {
|
request: {
|
||||||
hello: 'there',
|
hello: 'there',
|
||||||
},
|
},
|
||||||
creatorUid: 'testuser',
|
embedProperties: {
|
||||||
|
foo: 'bar',
|
||||||
|
},
|
||||||
|
creatorUid: user.uid,
|
||||||
createdOn: new Date(),
|
createdOn: new Date(),
|
||||||
|
updatedOn: createdOn,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const shortcodesWithUserEmail = [
|
||||||
|
{
|
||||||
|
id: 'blablabla',
|
||||||
|
request: {
|
||||||
|
hello: 'there',
|
||||||
|
},
|
||||||
|
embedProperties: {
|
||||||
|
foo: 'bar',
|
||||||
|
},
|
||||||
|
creatorUid: user.uid,
|
||||||
|
createdOn: new Date(),
|
||||||
|
updatedOn: createdOn,
|
||||||
|
User: user,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'blablabla1',
|
||||||
|
request: {
|
||||||
|
hello: 'there',
|
||||||
|
},
|
||||||
|
embedProperties: {
|
||||||
|
foo: 'bar',
|
||||||
|
},
|
||||||
|
creatorUid: user.uid,
|
||||||
|
createdOn: new Date(),
|
||||||
|
updatedOn: createdOn,
|
||||||
|
User: user,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
describe('ShortcodeService', () => {
|
describe('ShortcodeService', () => {
|
||||||
describe('getShortCode', () => {
|
describe('getShortCode', () => {
|
||||||
test('should return a valid shortcode with valid shortcode ID', async () => {
|
test('should return a valid Shortcode with valid Shortcode ID', async () => {
|
||||||
mockPrisma.shortcode.findFirstOrThrow.mockResolvedValueOnce(
|
mockPrisma.shortcode.findFirstOrThrow.mockResolvedValueOnce(mockEmbed);
|
||||||
shortCodeWithOutUser,
|
|
||||||
);
|
|
||||||
|
|
||||||
const result = await shortcodeService.getShortCode(
|
const result = await shortcodeService.getShortCode(mockEmbed.id);
|
||||||
shortCodeWithOutUser.id,
|
|
||||||
);
|
|
||||||
expect(result).toEqualRight(<Shortcode>{
|
expect(result).toEqualRight(<Shortcode>{
|
||||||
id: shortCodeWithOutUser.id,
|
id: mockEmbed.id,
|
||||||
createdOn: shortCodeWithOutUser.createdOn,
|
createdOn: mockEmbed.createdOn,
|
||||||
request: JSON.stringify(shortCodeWithOutUser.request),
|
request: JSON.stringify(mockEmbed.request),
|
||||||
|
properties: JSON.stringify(mockEmbed.embedProperties),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -99,10 +152,10 @@ describe('ShortcodeService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('fetchUserShortCodes', () => {
|
describe('fetchUserShortCodes', () => {
|
||||||
test('should return list of shortcodes with valid inputs and no cursor', async () => {
|
test('should return list of Shortcode with valid inputs and no cursor', async () => {
|
||||||
mockPrisma.shortcode.findMany.mockResolvedValueOnce(shortcodes);
|
mockPrisma.shortcode.findMany.mockResolvedValueOnce(shortcodes);
|
||||||
|
|
||||||
const result = await shortcodeService.fetchUserShortCodes('testuser', {
|
const result = await shortcodeService.fetchUserShortCodes(user.uid, {
|
||||||
cursor: null,
|
cursor: null,
|
||||||
take: 10,
|
take: 10,
|
||||||
});
|
});
|
||||||
@@ -110,20 +163,22 @@ describe('ShortcodeService', () => {
|
|||||||
{
|
{
|
||||||
id: shortcodes[0].id,
|
id: shortcodes[0].id,
|
||||||
request: JSON.stringify(shortcodes[0].request),
|
request: JSON.stringify(shortcodes[0].request),
|
||||||
|
properties: JSON.stringify(shortcodes[0].embedProperties),
|
||||||
createdOn: shortcodes[0].createdOn,
|
createdOn: shortcodes[0].createdOn,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: shortcodes[1].id,
|
id: shortcodes[1].id,
|
||||||
request: JSON.stringify(shortcodes[1].request),
|
request: JSON.stringify(shortcodes[1].request),
|
||||||
|
properties: JSON.stringify(shortcodes[1].embedProperties),
|
||||||
createdOn: shortcodes[1].createdOn,
|
createdOn: shortcodes[1].createdOn,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return list of shortcodes with valid inputs and cursor', async () => {
|
test('should return list of Shortcode with valid inputs and cursor', async () => {
|
||||||
mockPrisma.shortcode.findMany.mockResolvedValue([shortcodes[1]]);
|
mockPrisma.shortcode.findMany.mockResolvedValue([shortcodes[1]]);
|
||||||
|
|
||||||
const result = await shortcodeService.fetchUserShortCodes('testuser', {
|
const result = await shortcodeService.fetchUserShortCodes(user.uid, {
|
||||||
cursor: 'blablabla',
|
cursor: 'blablabla',
|
||||||
take: 10,
|
take: 10,
|
||||||
});
|
});
|
||||||
@@ -131,6 +186,7 @@ describe('ShortcodeService', () => {
|
|||||||
{
|
{
|
||||||
id: shortcodes[1].id,
|
id: shortcodes[1].id,
|
||||||
request: JSON.stringify(shortcodes[1].request),
|
request: JSON.stringify(shortcodes[1].request),
|
||||||
|
properties: JSON.stringify(shortcodes[1].embedProperties),
|
||||||
createdOn: shortcodes[1].createdOn,
|
createdOn: shortcodes[1].createdOn,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -139,7 +195,7 @@ describe('ShortcodeService', () => {
|
|||||||
test('should return an empty array for an invalid cursor', async () => {
|
test('should return an empty array for an invalid cursor', async () => {
|
||||||
mockPrisma.shortcode.findMany.mockResolvedValue([]);
|
mockPrisma.shortcode.findMany.mockResolvedValue([]);
|
||||||
|
|
||||||
const result = await shortcodeService.fetchUserShortCodes('testuser', {
|
const result = await shortcodeService.fetchUserShortCodes(user.uid, {
|
||||||
cursor: 'invalidcursor',
|
cursor: 'invalidcursor',
|
||||||
take: 10,
|
take: 10,
|
||||||
});
|
});
|
||||||
@@ -171,77 +227,111 @@ describe('ShortcodeService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('createShortcode', () => {
|
describe('createShortcode', () => {
|
||||||
test('should throw SHORTCODE_INVALID_JSON error if incoming request data is invalid', async () => {
|
test('should throw SHORTCODE_INVALID_REQUEST_JSON error if incoming request data is invalid', async () => {
|
||||||
const result = await shortcodeService.createShortcode(
|
const result = await shortcodeService.createShortcode(
|
||||||
'invalidRequest',
|
'invalidRequest',
|
||||||
'user_uid_1',
|
null,
|
||||||
|
user,
|
||||||
);
|
);
|
||||||
expect(result).toEqualLeft(SHORTCODE_INVALID_JSON);
|
expect(result).toEqualLeft(SHORTCODE_INVALID_REQUEST_JSON);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should successfully create a new shortcode with valid user uid', async () => {
|
test('should throw SHORTCODE_INVALID_PROPERTIES_JSON error if incoming properties data is invalid', async () => {
|
||||||
// generateUniqueShortCodeID --> getShortCode
|
const result = await shortcodeService.createShortcode(
|
||||||
|
'{}',
|
||||||
|
'invalid_data',
|
||||||
|
user,
|
||||||
|
);
|
||||||
|
expect(result).toEqualLeft(SHORTCODE_INVALID_PROPERTIES_JSON);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should successfully create a new Embed with valid user uid', async () => {
|
||||||
|
// generateUniqueShortCodeID --> getShortcode
|
||||||
mockPrisma.shortcode.findFirstOrThrow.mockRejectedValueOnce(
|
mockPrisma.shortcode.findFirstOrThrow.mockRejectedValueOnce(
|
||||||
'NotFoundError',
|
'NotFoundError',
|
||||||
);
|
);
|
||||||
mockPrisma.shortcode.create.mockResolvedValueOnce(shortCodeWithUser);
|
mockPrisma.shortcode.create.mockResolvedValueOnce(mockEmbed);
|
||||||
|
|
||||||
const result = await shortcodeService.createShortcode('{}', 'user_uid_1');
|
const result = await shortcodeService.createShortcode('{}', '{}', user);
|
||||||
expect(result).toEqualRight({
|
expect(result).toEqualRight(<Shortcode>{
|
||||||
id: shortCodeWithUser.id,
|
id: mockEmbed.id,
|
||||||
createdOn: shortCodeWithUser.createdOn,
|
createdOn: mockEmbed.createdOn,
|
||||||
request: JSON.stringify(shortCodeWithUser.request),
|
request: JSON.stringify(mockEmbed.request),
|
||||||
|
properties: JSON.stringify(mockEmbed.embedProperties),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should successfully create a new shortcode with null user uid', async () => {
|
test('should successfully create a new ShortCode with valid user uid', async () => {
|
||||||
// generateUniqueShortCodeID --> getShortCode
|
// generateUniqueShortCodeID --> getShortcode
|
||||||
mockPrisma.shortcode.findFirstOrThrow.mockRejectedValueOnce(
|
mockPrisma.shortcode.findFirstOrThrow.mockRejectedValueOnce(
|
||||||
'NotFoundError',
|
'NotFoundError',
|
||||||
);
|
);
|
||||||
mockPrisma.shortcode.create.mockResolvedValueOnce(shortCodeWithUser);
|
mockPrisma.shortcode.create.mockResolvedValueOnce(mockShortcode);
|
||||||
|
|
||||||
const result = await shortcodeService.createShortcode('{}', null);
|
const result = await shortcodeService.createShortcode('{}', null, user);
|
||||||
expect(result).toEqualRight({
|
expect(result).toEqualRight(<Shortcode>{
|
||||||
id: shortCodeWithUser.id,
|
id: mockShortcode.id,
|
||||||
createdOn: shortCodeWithUser.createdOn,
|
createdOn: mockShortcode.createdOn,
|
||||||
request: JSON.stringify(shortCodeWithOutUser.request),
|
request: JSON.stringify(mockShortcode.request),
|
||||||
|
properties: mockShortcode.embedProperties,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should send pubsub message to `shortcode/{uid}/created` on successful creation of shortcode', async () => {
|
test('should send pubsub message to `shortcode/{uid}/created` on successful creation of a Shortcode', async () => {
|
||||||
// generateUniqueShortCodeID --> getShortCode
|
// generateUniqueShortCodeID --> getShortcode
|
||||||
mockPrisma.shortcode.findFirstOrThrow.mockRejectedValueOnce(
|
mockPrisma.shortcode.findFirstOrThrow.mockRejectedValueOnce(
|
||||||
'NotFoundError',
|
'NotFoundError',
|
||||||
);
|
);
|
||||||
mockPrisma.shortcode.create.mockResolvedValueOnce(shortCodeWithUser);
|
mockPrisma.shortcode.create.mockResolvedValueOnce(mockShortcode);
|
||||||
|
|
||||||
|
const result = await shortcodeService.createShortcode('{}', null, user);
|
||||||
|
|
||||||
const result = await shortcodeService.createShortcode('{}', 'user_uid_1');
|
|
||||||
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
||||||
`shortcode/${shortCodeWithUser.creatorUid}/created`,
|
`shortcode/${mockShortcode.creatorUid}/created`,
|
||||||
{
|
<Shortcode>{
|
||||||
id: shortCodeWithUser.id,
|
id: mockShortcode.id,
|
||||||
createdOn: shortCodeWithUser.createdOn,
|
createdOn: mockShortcode.createdOn,
|
||||||
request: JSON.stringify(shortCodeWithUser.request),
|
request: JSON.stringify(mockShortcode.request),
|
||||||
|
properties: mockShortcode.embedProperties,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should send pubsub message to `shortcode/{uid}/created` on successful creation of an Embed', async () => {
|
||||||
|
// generateUniqueShortCodeID --> getShortcode
|
||||||
|
mockPrisma.shortcode.findFirstOrThrow.mockRejectedValueOnce(
|
||||||
|
'NotFoundError',
|
||||||
|
);
|
||||||
|
mockPrisma.shortcode.create.mockResolvedValueOnce(mockEmbed);
|
||||||
|
|
||||||
|
const result = await shortcodeService.createShortcode('{}', '{}', user);
|
||||||
|
|
||||||
|
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
||||||
|
`shortcode/${mockEmbed.creatorUid}/created`,
|
||||||
|
<Shortcode>{
|
||||||
|
id: mockEmbed.id,
|
||||||
|
createdOn: mockEmbed.createdOn,
|
||||||
|
request: JSON.stringify(mockEmbed.request),
|
||||||
|
properties: JSON.stringify(mockEmbed.embedProperties),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('revokeShortCode', () => {
|
describe('revokeShortCode', () => {
|
||||||
test('should return true on successful deletion of shortcode with valid inputs', async () => {
|
test('should return true on successful deletion of Shortcode with valid inputs', async () => {
|
||||||
mockPrisma.shortcode.delete.mockResolvedValueOnce(shortCodeWithUser);
|
mockPrisma.shortcode.delete.mockResolvedValueOnce(mockEmbed);
|
||||||
|
|
||||||
const result = await shortcodeService.revokeShortCode(
|
const result = await shortcodeService.revokeShortCode(
|
||||||
shortCodeWithUser.id,
|
mockEmbed.id,
|
||||||
shortCodeWithUser.creatorUid,
|
mockEmbed.creatorUid,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(mockPrisma.shortcode.delete).toHaveBeenCalledWith({
|
expect(mockPrisma.shortcode.delete).toHaveBeenCalledWith({
|
||||||
where: {
|
where: {
|
||||||
creator_uid_shortcode_unique: {
|
creator_uid_shortcode_unique: {
|
||||||
creatorUid: shortCodeWithUser.creatorUid,
|
creatorUid: mockEmbed.creatorUid,
|
||||||
id: shortCodeWithUser.id,
|
id: mockEmbed.id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -249,52 +339,53 @@ describe('ShortcodeService', () => {
|
|||||||
expect(result).toEqualRight(true);
|
expect(result).toEqualRight(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return SHORTCODE_NOT_FOUND error when shortcode is invalid and user uid is valid', async () => {
|
test('should return SHORTCODE_NOT_FOUND error when Shortcode is invalid and user uid is valid', async () => {
|
||||||
mockPrisma.shortcode.delete.mockRejectedValue('RecordNotFound');
|
mockPrisma.shortcode.delete.mockRejectedValue('RecordNotFound');
|
||||||
expect(
|
expect(
|
||||||
shortcodeService.revokeShortCode('invalid', 'testuser'),
|
shortcodeService.revokeShortCode('invalid', 'testuser'),
|
||||||
).resolves.toEqualLeft(SHORTCODE_NOT_FOUND);
|
).resolves.toEqualLeft(SHORTCODE_NOT_FOUND);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return SHORTCODE_NOT_FOUND error when shortcode is valid and user uid is invalid', async () => {
|
test('should return SHORTCODE_NOT_FOUND error when Shortcode is valid and user uid is invalid', async () => {
|
||||||
mockPrisma.shortcode.delete.mockRejectedValue('RecordNotFound');
|
mockPrisma.shortcode.delete.mockRejectedValue('RecordNotFound');
|
||||||
expect(
|
expect(
|
||||||
shortcodeService.revokeShortCode('blablablabla', 'invalidUser'),
|
shortcodeService.revokeShortCode('blablablabla', 'invalidUser'),
|
||||||
).resolves.toEqualLeft(SHORTCODE_NOT_FOUND);
|
).resolves.toEqualLeft(SHORTCODE_NOT_FOUND);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return SHORTCODE_NOT_FOUND error when both shortcode and user uid are invalid', async () => {
|
test('should return SHORTCODE_NOT_FOUND error when both Shortcode and user uid are invalid', async () => {
|
||||||
mockPrisma.shortcode.delete.mockRejectedValue('RecordNotFound');
|
mockPrisma.shortcode.delete.mockRejectedValue('RecordNotFound');
|
||||||
expect(
|
expect(
|
||||||
shortcodeService.revokeShortCode('invalid', 'invalid'),
|
shortcodeService.revokeShortCode('invalid', 'invalid'),
|
||||||
).resolves.toEqualLeft(SHORTCODE_NOT_FOUND);
|
).resolves.toEqualLeft(SHORTCODE_NOT_FOUND);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should send pubsub message to `shortcode/{uid}/revoked` on successful deletion of shortcode', async () => {
|
test('should send pubsub message to `shortcode/{uid}/revoked` on successful deletion of Shortcode', async () => {
|
||||||
mockPrisma.shortcode.delete.mockResolvedValueOnce(shortCodeWithUser);
|
mockPrisma.shortcode.delete.mockResolvedValueOnce(mockEmbed);
|
||||||
|
|
||||||
const result = await shortcodeService.revokeShortCode(
|
const result = await shortcodeService.revokeShortCode(
|
||||||
shortCodeWithUser.id,
|
mockEmbed.id,
|
||||||
shortCodeWithUser.creatorUid,
|
mockEmbed.creatorUid,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
||||||
`shortcode/${shortCodeWithUser.creatorUid}/revoked`,
|
`shortcode/${mockEmbed.creatorUid}/revoked`,
|
||||||
{
|
{
|
||||||
id: shortCodeWithUser.id,
|
id: mockEmbed.id,
|
||||||
createdOn: shortCodeWithUser.createdOn,
|
createdOn: mockEmbed.createdOn,
|
||||||
request: JSON.stringify(shortCodeWithUser.request),
|
request: JSON.stringify(mockEmbed.request),
|
||||||
|
properties: JSON.stringify(mockEmbed.embedProperties),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('deleteUserShortCodes', () => {
|
describe('deleteUserShortCodes', () => {
|
||||||
test('should successfully delete all users shortcodes with valid user uid', async () => {
|
test('should successfully delete all users Shortcodes with valid user uid', async () => {
|
||||||
mockPrisma.shortcode.deleteMany.mockResolvedValueOnce({ count: 1 });
|
mockPrisma.shortcode.deleteMany.mockResolvedValueOnce({ count: 1 });
|
||||||
|
|
||||||
const result = await shortcodeService.deleteUserShortCodes(
|
const result = await shortcodeService.deleteUserShortCodes(
|
||||||
shortCodeWithUser.creatorUid,
|
mockEmbed.creatorUid,
|
||||||
);
|
);
|
||||||
expect(result).toEqual(1);
|
expect(result).toEqual(1);
|
||||||
});
|
});
|
||||||
@@ -303,9 +394,176 @@ describe('ShortcodeService', () => {
|
|||||||
mockPrisma.shortcode.deleteMany.mockResolvedValueOnce({ count: 0 });
|
mockPrisma.shortcode.deleteMany.mockResolvedValueOnce({ count: 0 });
|
||||||
|
|
||||||
const result = await shortcodeService.deleteUserShortCodes(
|
const result = await shortcodeService.deleteUserShortCodes(
|
||||||
shortCodeWithUser.creatorUid,
|
mockEmbed.creatorUid,
|
||||||
);
|
);
|
||||||
expect(result).toEqual(0);
|
expect(result).toEqual(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('updateShortcode', () => {
|
||||||
|
test('should return SHORTCODE_PROPERTIES_NOT_FOUND error when updatedProps in invalid', async () => {
|
||||||
|
const result = await shortcodeService.updateEmbedProperties(
|
||||||
|
mockEmbed.id,
|
||||||
|
user.uid,
|
||||||
|
'',
|
||||||
|
);
|
||||||
|
expect(result).toEqualLeft(SHORTCODE_PROPERTIES_NOT_FOUND);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should return SHORTCODE_PROPERTIES_NOT_FOUND error when updatedProps in invalid JSON format', async () => {
|
||||||
|
const result = await shortcodeService.updateEmbedProperties(
|
||||||
|
mockEmbed.id,
|
||||||
|
user.uid,
|
||||||
|
'{kk',
|
||||||
|
);
|
||||||
|
expect(result).toEqualLeft(SHORTCODE_INVALID_PROPERTIES_JSON);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should return SHORTCODE_NOT_FOUND error when Shortcode ID is invalid', async () => {
|
||||||
|
mockPrisma.shortcode.update.mockRejectedValue('RecordNotFound');
|
||||||
|
const result = await shortcodeService.updateEmbedProperties(
|
||||||
|
'invalidID',
|
||||||
|
user.uid,
|
||||||
|
'{}',
|
||||||
|
);
|
||||||
|
expect(result).toEqualLeft(SHORTCODE_NOT_FOUND);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should successfully update a Shortcodes with valid inputs', async () => {
|
||||||
|
mockPrisma.shortcode.update.mockResolvedValueOnce({
|
||||||
|
...mockEmbed,
|
||||||
|
embedProperties: '{"foo":"bar"}',
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await shortcodeService.updateEmbedProperties(
|
||||||
|
mockEmbed.id,
|
||||||
|
user.uid,
|
||||||
|
'{"foo":"bar"}',
|
||||||
|
);
|
||||||
|
expect(result).toEqualRight({
|
||||||
|
id: mockEmbed.id,
|
||||||
|
createdOn: mockEmbed.createdOn,
|
||||||
|
request: JSON.stringify(mockEmbed.request),
|
||||||
|
properties: JSON.stringify('{"foo":"bar"}'),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should send pubsub message to `shortcode/{uid}/updated` on successful Update of Shortcode', async () => {
|
||||||
|
mockPrisma.shortcode.update.mockResolvedValueOnce({
|
||||||
|
...mockEmbed,
|
||||||
|
embedProperties: '{"foo":"bar"}',
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await shortcodeService.updateEmbedProperties(
|
||||||
|
mockEmbed.id,
|
||||||
|
user.uid,
|
||||||
|
'{"foo":"bar"}',
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
||||||
|
`shortcode/${mockEmbed.creatorUid}/updated`,
|
||||||
|
{
|
||||||
|
id: mockEmbed.id,
|
||||||
|
createdOn: mockEmbed.createdOn,
|
||||||
|
request: JSON.stringify(mockEmbed.request),
|
||||||
|
properties: JSON.stringify('{"foo":"bar"}'),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('deleteShortcode', () => {
|
||||||
|
test('should return true on successful deletion of Shortcode with valid inputs', async () => {
|
||||||
|
mockPrisma.shortcode.delete.mockResolvedValueOnce(mockEmbed);
|
||||||
|
|
||||||
|
const result = await shortcodeService.deleteShortcode(mockEmbed.id);
|
||||||
|
expect(result).toEqualRight(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should return SHORTCODE_NOT_FOUND error when Shortcode is invalid', async () => {
|
||||||
|
mockPrisma.shortcode.delete.mockRejectedValue('RecordNotFound');
|
||||||
|
|
||||||
|
expect(shortcodeService.deleteShortcode('invalid')).resolves.toEqualLeft(
|
||||||
|
SHORTCODE_NOT_FOUND,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('fetchAllShortcodes', () => {
|
||||||
|
test('should return list of Shortcodes with valid inputs and no cursor', async () => {
|
||||||
|
mockPrisma.shortcode.findMany.mockResolvedValueOnce(
|
||||||
|
shortcodesWithUserEmail,
|
||||||
|
);
|
||||||
|
|
||||||
|
const result = await shortcodeService.fetchAllShortcodes(
|
||||||
|
{
|
||||||
|
cursor: null,
|
||||||
|
take: 10,
|
||||||
|
},
|
||||||
|
user.email,
|
||||||
|
);
|
||||||
|
expect(result).toEqual(<ShortcodeWithUserEmail[]>[
|
||||||
|
{
|
||||||
|
id: shortcodes[0].id,
|
||||||
|
request: JSON.stringify(shortcodes[0].request),
|
||||||
|
properties: JSON.stringify(shortcodes[0].embedProperties),
|
||||||
|
createdOn: shortcodes[0].createdOn,
|
||||||
|
creator: {
|
||||||
|
uid: user.uid,
|
||||||
|
email: user.email,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: shortcodes[1].id,
|
||||||
|
request: JSON.stringify(shortcodes[1].request),
|
||||||
|
properties: JSON.stringify(shortcodes[1].embedProperties),
|
||||||
|
createdOn: shortcodes[1].createdOn,
|
||||||
|
creator: {
|
||||||
|
uid: user.uid,
|
||||||
|
email: user.email,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should return list of Shortcode with valid inputs and cursor', async () => {
|
||||||
|
mockPrisma.shortcode.findMany.mockResolvedValue([
|
||||||
|
shortcodesWithUserEmail[1],
|
||||||
|
]);
|
||||||
|
|
||||||
|
const result = await shortcodeService.fetchAllShortcodes(
|
||||||
|
{
|
||||||
|
cursor: 'blablabla',
|
||||||
|
take: 10,
|
||||||
|
},
|
||||||
|
user.email,
|
||||||
|
);
|
||||||
|
expect(result).toEqual(<ShortcodeWithUserEmail[]>[
|
||||||
|
{
|
||||||
|
id: shortcodes[1].id,
|
||||||
|
request: JSON.stringify(shortcodes[1].request),
|
||||||
|
properties: JSON.stringify(shortcodes[1].embedProperties),
|
||||||
|
createdOn: shortcodes[1].createdOn,
|
||||||
|
creator: {
|
||||||
|
uid: user.uid,
|
||||||
|
email: user.email,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should return an empty array for an invalid cursor', async () => {
|
||||||
|
mockPrisma.shortcode.findMany.mockResolvedValue([]);
|
||||||
|
|
||||||
|
const result = await shortcodeService.fetchAllShortcodes(
|
||||||
|
{
|
||||||
|
cursor: 'invalidcursor',
|
||||||
|
take: 10,
|
||||||
|
},
|
||||||
|
user.email,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result).toHaveLength(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
import { Injectable, OnModuleInit } from '@nestjs/common';
|
import { Injectable, OnModuleInit } from '@nestjs/common';
|
||||||
import * as T from 'fp-ts/Task';
|
import * as T from 'fp-ts/Task';
|
||||||
import * as O from 'fp-ts/Option';
|
|
||||||
import * as TO from 'fp-ts/TaskOption';
|
import * as TO from 'fp-ts/TaskOption';
|
||||||
import * as E from 'fp-ts/Either';
|
import * as E from 'fp-ts/Either';
|
||||||
import { PrismaService } from 'src/prisma/prisma.service';
|
import { PrismaService } from 'src/prisma/prisma.service';
|
||||||
import { SHORTCODE_INVALID_JSON, SHORTCODE_NOT_FOUND } from 'src/errors';
|
import {
|
||||||
|
SHORTCODE_INVALID_PROPERTIES_JSON,
|
||||||
|
SHORTCODE_INVALID_REQUEST_JSON,
|
||||||
|
SHORTCODE_NOT_FOUND,
|
||||||
|
SHORTCODE_PROPERTIES_NOT_FOUND,
|
||||||
|
} from 'src/errors';
|
||||||
import { UserDataHandler } from 'src/user/user.data.handler';
|
import { UserDataHandler } from 'src/user/user.data.handler';
|
||||||
import { Shortcode } from './shortcode.model';
|
import { Shortcode, ShortcodeWithUserEmail } from './shortcode.model';
|
||||||
import { Shortcode as DBShortCode } from '@prisma/client';
|
import { Shortcode as DBShortCode } from '@prisma/client';
|
||||||
import { PubSubService } from 'src/pubsub/pubsub.service';
|
import { PubSubService } from 'src/pubsub/pubsub.service';
|
||||||
import { UserService } from 'src/user/user.service';
|
import { UserService } from 'src/user/user.service';
|
||||||
@@ -46,10 +50,14 @@ export class ShortcodeService implements UserDataHandler, OnModuleInit {
|
|||||||
* @param shortcodeInfo Prisma Shortcode type
|
* @param shortcodeInfo Prisma Shortcode type
|
||||||
* @returns GQL Shortcode
|
* @returns GQL Shortcode
|
||||||
*/
|
*/
|
||||||
private returnShortCode(shortcodeInfo: DBShortCode): Shortcode {
|
private cast(shortcodeInfo: DBShortCode): Shortcode {
|
||||||
return <Shortcode>{
|
return <Shortcode>{
|
||||||
id: shortcodeInfo.id,
|
id: shortcodeInfo.id,
|
||||||
request: JSON.stringify(shortcodeInfo.request),
|
request: JSON.stringify(shortcodeInfo.request),
|
||||||
|
properties:
|
||||||
|
shortcodeInfo.embedProperties != null
|
||||||
|
? JSON.stringify(shortcodeInfo.embedProperties)
|
||||||
|
: null,
|
||||||
createdOn: shortcodeInfo.createdOn,
|
createdOn: shortcodeInfo.createdOn,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -94,7 +102,7 @@ export class ShortcodeService implements UserDataHandler, OnModuleInit {
|
|||||||
const shortcodeInfo = await this.prisma.shortcode.findFirstOrThrow({
|
const shortcodeInfo = await this.prisma.shortcode.findFirstOrThrow({
|
||||||
where: { id: shortcode },
|
where: { id: shortcode },
|
||||||
});
|
});
|
||||||
return E.right(this.returnShortCode(shortcodeInfo));
|
return E.right(this.cast(shortcodeInfo));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return E.left(SHORTCODE_NOT_FOUND);
|
return E.left(SHORTCODE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
@@ -104,14 +112,22 @@ export class ShortcodeService implements UserDataHandler, OnModuleInit {
|
|||||||
* Create a new ShortCode
|
* Create a new ShortCode
|
||||||
*
|
*
|
||||||
* @param request JSON string of request details
|
* @param request JSON string of request details
|
||||||
* @param userUID user UID, if present
|
* @param userInfo user UI
|
||||||
|
* @param properties JSON string of embed properties, if present
|
||||||
* @returns Either of ShortCode or error
|
* @returns Either of ShortCode or error
|
||||||
*/
|
*/
|
||||||
async createShortcode(request: string, userUID: string | null) {
|
async createShortcode(
|
||||||
const shortcodeData = stringToJson(request);
|
request: string,
|
||||||
if (E.isLeft(shortcodeData)) return E.left(SHORTCODE_INVALID_JSON);
|
properties: string | null = null,
|
||||||
|
userInfo: AuthUser,
|
||||||
|
) {
|
||||||
|
const requestData = stringToJson(request);
|
||||||
|
if (E.isLeft(requestData) || !requestData.right)
|
||||||
|
return E.left(SHORTCODE_INVALID_REQUEST_JSON);
|
||||||
|
|
||||||
const user = await this.userService.findUserById(userUID);
|
const parsedProperties = stringToJson(properties);
|
||||||
|
if (E.isLeft(parsedProperties))
|
||||||
|
return E.left(SHORTCODE_INVALID_PROPERTIES_JSON);
|
||||||
|
|
||||||
const generatedShortCode = await this.generateUniqueShortCodeID();
|
const generatedShortCode = await this.generateUniqueShortCodeID();
|
||||||
if (E.isLeft(generatedShortCode)) return E.left(generatedShortCode.left);
|
if (E.isLeft(generatedShortCode)) return E.left(generatedShortCode.left);
|
||||||
@@ -119,8 +135,9 @@ export class ShortcodeService implements UserDataHandler, OnModuleInit {
|
|||||||
const createdShortCode = await this.prisma.shortcode.create({
|
const createdShortCode = await this.prisma.shortcode.create({
|
||||||
data: {
|
data: {
|
||||||
id: generatedShortCode.right,
|
id: generatedShortCode.right,
|
||||||
request: shortcodeData.right,
|
request: requestData.right,
|
||||||
creatorUid: O.isNone(user) ? null : user.value.uid,
|
embedProperties: parsedProperties.right ?? undefined,
|
||||||
|
creatorUid: userInfo.uid,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -128,11 +145,11 @@ export class ShortcodeService implements UserDataHandler, OnModuleInit {
|
|||||||
if (createdShortCode.creatorUid) {
|
if (createdShortCode.creatorUid) {
|
||||||
this.pubsub.publish(
|
this.pubsub.publish(
|
||||||
`shortcode/${createdShortCode.creatorUid}/created`,
|
`shortcode/${createdShortCode.creatorUid}/created`,
|
||||||
this.returnShortCode(createdShortCode),
|
this.cast(createdShortCode),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return E.right(this.returnShortCode(createdShortCode));
|
return E.right(this.cast(createdShortCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -156,14 +173,14 @@ export class ShortcodeService implements UserDataHandler, OnModuleInit {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const fetchedShortCodes: Shortcode[] = shortCodes.map((code) =>
|
const fetchedShortCodes: Shortcode[] = shortCodes.map((code) =>
|
||||||
this.returnShortCode(code),
|
this.cast(code),
|
||||||
);
|
);
|
||||||
|
|
||||||
return fetchedShortCodes;
|
return fetchedShortCodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a ShortCode
|
* Delete a ShortCode created by User of uid
|
||||||
*
|
*
|
||||||
* @param shortcode ShortCode
|
* @param shortcode ShortCode
|
||||||
* @param uid User Uid
|
* @param uid User Uid
|
||||||
@@ -182,7 +199,7 @@ export class ShortcodeService implements UserDataHandler, OnModuleInit {
|
|||||||
|
|
||||||
this.pubsub.publish(
|
this.pubsub.publish(
|
||||||
`shortcode/${deletedShortCodes.creatorUid}/revoked`,
|
`shortcode/${deletedShortCodes.creatorUid}/revoked`,
|
||||||
this.returnShortCode(deletedShortCodes),
|
this.cast(deletedShortCodes),
|
||||||
);
|
);
|
||||||
|
|
||||||
return E.right(true);
|
return E.right(true);
|
||||||
@@ -205,4 +222,118 @@ export class ShortcodeService implements UserDataHandler, OnModuleInit {
|
|||||||
|
|
||||||
return deletedShortCodes.count;
|
return deletedShortCodes.count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a Shortcode
|
||||||
|
*
|
||||||
|
* @param shortcodeID ID of Shortcode being deleted
|
||||||
|
* @returns Boolean on successful deletion
|
||||||
|
*/
|
||||||
|
async deleteShortcode(shortcodeID: string) {
|
||||||
|
try {
|
||||||
|
await this.prisma.shortcode.delete({
|
||||||
|
where: {
|
||||||
|
id: shortcodeID,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return E.right(true);
|
||||||
|
} catch (error) {
|
||||||
|
return E.left(SHORTCODE_NOT_FOUND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a created Shortcode
|
||||||
|
* @param shortcodeID Shortcode ID
|
||||||
|
* @param uid User Uid
|
||||||
|
* @returns Updated Shortcode
|
||||||
|
*/
|
||||||
|
async updateEmbedProperties(
|
||||||
|
shortcodeID: string,
|
||||||
|
uid: string,
|
||||||
|
updatedProps: string,
|
||||||
|
) {
|
||||||
|
if (!updatedProps) return E.left(SHORTCODE_PROPERTIES_NOT_FOUND);
|
||||||
|
|
||||||
|
const parsedProperties = stringToJson(updatedProps);
|
||||||
|
if (E.isLeft(parsedProperties) || !parsedProperties.right)
|
||||||
|
return E.left(SHORTCODE_INVALID_PROPERTIES_JSON);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const updatedShortcode = await this.prisma.shortcode.update({
|
||||||
|
where: {
|
||||||
|
creator_uid_shortcode_unique: {
|
||||||
|
creatorUid: uid,
|
||||||
|
id: shortcodeID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
embedProperties: parsedProperties.right,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
this.pubsub.publish(
|
||||||
|
`shortcode/${updatedShortcode.creatorUid}/updated`,
|
||||||
|
this.cast(updatedShortcode),
|
||||||
|
);
|
||||||
|
|
||||||
|
return E.right(this.cast(updatedShortcode));
|
||||||
|
} catch (error) {
|
||||||
|
return E.left(SHORTCODE_NOT_FOUND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch all created ShortCodes
|
||||||
|
*
|
||||||
|
* @param args Pagination arguments
|
||||||
|
* @param userEmail User email
|
||||||
|
* @returns ShortcodeWithUserEmail
|
||||||
|
*/
|
||||||
|
async fetchAllShortcodes(
|
||||||
|
args: PaginationArgs,
|
||||||
|
userEmail: string | null = null,
|
||||||
|
) {
|
||||||
|
const shortCodes = await this.prisma.shortcode.findMany({
|
||||||
|
where: userEmail
|
||||||
|
? {
|
||||||
|
User: {
|
||||||
|
email: userEmail,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
|
orderBy: {
|
||||||
|
createdOn: 'desc',
|
||||||
|
},
|
||||||
|
skip: args.cursor ? 1 : 0,
|
||||||
|
take: args.take,
|
||||||
|
cursor: args.cursor ? { id: args.cursor } : undefined,
|
||||||
|
include: {
|
||||||
|
User: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const fetchedShortCodes: ShortcodeWithUserEmail[] = shortCodes.map(
|
||||||
|
(code) => {
|
||||||
|
return <ShortcodeWithUserEmail>{
|
||||||
|
id: code.id,
|
||||||
|
request: JSON.stringify(code.request),
|
||||||
|
properties:
|
||||||
|
code.embedProperties != null
|
||||||
|
? JSON.stringify(code.embedProperties)
|
||||||
|
: null,
|
||||||
|
createdOn: code.createdOn,
|
||||||
|
creator: code.User
|
||||||
|
? {
|
||||||
|
uid: code.User.uid,
|
||||||
|
email: code.User.email,
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return fetchedShortCodes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,13 @@ export class CreateRootTeamCollectionArgs {
|
|||||||
|
|
||||||
@Field({ name: 'title', description: 'Title of the new collection' })
|
@Field({ name: 'title', description: 'Title of the new collection' })
|
||||||
title: string;
|
title: string;
|
||||||
|
|
||||||
|
@Field({
|
||||||
|
name: 'data',
|
||||||
|
description: 'JSON string representing the collection data',
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
data: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ArgsType()
|
@ArgsType()
|
||||||
@@ -26,6 +33,13 @@ export class CreateChildTeamCollectionArgs {
|
|||||||
|
|
||||||
@Field({ name: 'childTitle', description: 'Title of the new collection' })
|
@Field({ name: 'childTitle', description: 'Title of the new collection' })
|
||||||
childTitle: string;
|
childTitle: string;
|
||||||
|
|
||||||
|
@Field({
|
||||||
|
name: 'data',
|
||||||
|
description: 'JSON string representing the collection data',
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
data: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ArgsType()
|
@ArgsType()
|
||||||
@@ -33,12 +47,14 @@ export class RenameTeamCollectionArgs {
|
|||||||
@Field(() => ID, {
|
@Field(() => ID, {
|
||||||
name: 'collectionID',
|
name: 'collectionID',
|
||||||
description: 'ID of the collection',
|
description: 'ID of the collection',
|
||||||
|
deprecationReason: 'Switch to updateTeamCollection mutation instead',
|
||||||
})
|
})
|
||||||
collectionID: string;
|
collectionID: string;
|
||||||
|
|
||||||
@Field({
|
@Field({
|
||||||
name: 'newTitle',
|
name: 'newTitle',
|
||||||
description: 'The updated title of the collection',
|
description: 'The updated title of the collection',
|
||||||
|
deprecationReason: 'Switch to updateTeamCollection mutation instead',
|
||||||
})
|
})
|
||||||
newTitle: string;
|
newTitle: string;
|
||||||
}
|
}
|
||||||
@@ -98,3 +114,26 @@ export class ReplaceTeamCollectionArgs {
|
|||||||
})
|
})
|
||||||
parentCollectionID?: string;
|
parentCollectionID?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ArgsType()
|
||||||
|
export class UpdateTeamCollectionArgs {
|
||||||
|
@Field(() => ID, {
|
||||||
|
name: 'collectionID',
|
||||||
|
description: 'ID of the collection',
|
||||||
|
})
|
||||||
|
collectionID: string;
|
||||||
|
|
||||||
|
@Field({
|
||||||
|
name: 'newTitle',
|
||||||
|
description: 'The updated title of the collection',
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
newTitle: string;
|
||||||
|
|
||||||
|
@Field({
|
||||||
|
name: 'data',
|
||||||
|
description: 'JSON string representing the collection data',
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
data: string;
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,12 +12,17 @@ export class TeamCollection {
|
|||||||
})
|
})
|
||||||
title: string;
|
title: string;
|
||||||
|
|
||||||
|
@Field({
|
||||||
|
description: 'JSON string representing the collection data',
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
data: string;
|
||||||
|
|
||||||
@Field(() => ID, {
|
@Field(() => ID, {
|
||||||
description: 'ID of the collection',
|
description: 'ID of the collection',
|
||||||
nullable: true,
|
nullable: true,
|
||||||
})
|
})
|
||||||
parentID: string;
|
parentID: string;
|
||||||
teamID: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import {
|
|||||||
MoveTeamCollectionArgs,
|
MoveTeamCollectionArgs,
|
||||||
RenameTeamCollectionArgs,
|
RenameTeamCollectionArgs,
|
||||||
ReplaceTeamCollectionArgs,
|
ReplaceTeamCollectionArgs,
|
||||||
|
UpdateTeamCollectionArgs,
|
||||||
UpdateTeamCollectionOrderArgs,
|
UpdateTeamCollectionOrderArgs,
|
||||||
} from './input-type.args';
|
} from './input-type.args';
|
||||||
import * as E from 'fp-ts/Either';
|
import * as E from 'fp-ts/Either';
|
||||||
@@ -141,7 +142,14 @@ export class TeamCollectionResolver {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (E.isLeft(teamCollections)) throwErr(teamCollections.left);
|
if (E.isLeft(teamCollections)) throwErr(teamCollections.left);
|
||||||
return teamCollections.right;
|
return <TeamCollection>{
|
||||||
|
id: teamCollections.right.id,
|
||||||
|
title: teamCollections.right.title,
|
||||||
|
parentID: teamCollections.right.parentID,
|
||||||
|
data: !teamCollections.right.data
|
||||||
|
? null
|
||||||
|
: JSON.stringify(teamCollections.right.data),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mutations
|
// Mutations
|
||||||
@@ -155,6 +163,7 @@ export class TeamCollectionResolver {
|
|||||||
const teamCollection = await this.teamCollectionService.createCollection(
|
const teamCollection = await this.teamCollectionService.createCollection(
|
||||||
args.teamID,
|
args.teamID,
|
||||||
args.title,
|
args.title,
|
||||||
|
args.data,
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -230,6 +239,7 @@ export class TeamCollectionResolver {
|
|||||||
const teamCollection = await this.teamCollectionService.createCollection(
|
const teamCollection = await this.teamCollectionService.createCollection(
|
||||||
team.right.id,
|
team.right.id,
|
||||||
args.childTitle,
|
args.childTitle,
|
||||||
|
args.data,
|
||||||
args.collectionID,
|
args.collectionID,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -239,6 +249,7 @@ export class TeamCollectionResolver {
|
|||||||
|
|
||||||
@Mutation(() => TeamCollection, {
|
@Mutation(() => TeamCollection, {
|
||||||
description: 'Rename a collection',
|
description: 'Rename a collection',
|
||||||
|
deprecationReason: 'Switch to updateTeamCollection mutation instead',
|
||||||
})
|
})
|
||||||
@UseGuards(GqlAuthGuard, GqlCollectionTeamMemberGuard)
|
@UseGuards(GqlAuthGuard, GqlCollectionTeamMemberGuard)
|
||||||
@RequiresTeamRole(TeamMemberRole.OWNER, TeamMemberRole.EDITOR)
|
@RequiresTeamRole(TeamMemberRole.OWNER, TeamMemberRole.EDITOR)
|
||||||
@@ -303,6 +314,23 @@ export class TeamCollectionResolver {
|
|||||||
return request.right;
|
return request.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Mutation(() => TeamCollection, {
|
||||||
|
description: 'Update Team Collection details',
|
||||||
|
})
|
||||||
|
@UseGuards(GqlAuthGuard, GqlCollectionTeamMemberGuard)
|
||||||
|
@RequiresTeamRole(TeamMemberRole.OWNER, TeamMemberRole.EDITOR)
|
||||||
|
async updateTeamCollection(@Args() args: UpdateTeamCollectionArgs) {
|
||||||
|
const updatedTeamCollection =
|
||||||
|
await this.teamCollectionService.updateTeamCollection(
|
||||||
|
args.collectionID,
|
||||||
|
args.data,
|
||||||
|
args.newTitle,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (E.isLeft(updatedTeamCollection)) throwErr(updatedTeamCollection.left);
|
||||||
|
return updatedTeamCollection.right;
|
||||||
|
}
|
||||||
|
|
||||||
// Subscriptions
|
// Subscriptions
|
||||||
|
|
||||||
@Subscription(() => TeamCollection, {
|
@Subscription(() => TeamCollection, {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Team, TeamCollection as DBTeamCollection } from '@prisma/client';
|
import { Team, TeamCollection as DBTeamCollection } from '@prisma/client';
|
||||||
import { mock, mockDeep, mockReset } from 'jest-mock-extended';
|
import { mockDeep, mockReset } from 'jest-mock-extended';
|
||||||
import {
|
import {
|
||||||
|
TEAM_COLL_DATA_INVALID,
|
||||||
TEAM_COLL_DEST_SAME,
|
TEAM_COLL_DEST_SAME,
|
||||||
TEAM_COLL_INVALID_JSON,
|
TEAM_COLL_INVALID_JSON,
|
||||||
TEAM_COLL_IS_PARENT_COLL,
|
TEAM_COLL_IS_PARENT_COLL,
|
||||||
@@ -18,8 +19,6 @@ import { PubSubService } from 'src/pubsub/pubsub.service';
|
|||||||
import { AuthUser } from 'src/types/AuthUser';
|
import { AuthUser } from 'src/types/AuthUser';
|
||||||
import { TeamCollectionService } from './team-collection.service';
|
import { TeamCollectionService } from './team-collection.service';
|
||||||
import { TeamCollection } from './team-collection.model';
|
import { TeamCollection } from './team-collection.model';
|
||||||
import { TeamCollectionModule } from './team-collection.module';
|
|
||||||
import * as E from 'fp-ts/Either';
|
|
||||||
|
|
||||||
const mockPrisma = mockDeep<PrismaService>();
|
const mockPrisma = mockDeep<PrismaService>();
|
||||||
const mockPubSub = mockDeep<PubSubService>();
|
const mockPubSub = mockDeep<PubSubService>();
|
||||||
@@ -54,35 +53,60 @@ const rootTeamCollection: DBTeamCollection = {
|
|||||||
id: '123',
|
id: '123',
|
||||||
orderIndex: 1,
|
orderIndex: 1,
|
||||||
parentID: null,
|
parentID: null,
|
||||||
|
data: {},
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
updatedOn: currentTime,
|
updatedOn: currentTime,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const rootTeamCollectionsCasted: TeamCollection = {
|
||||||
|
id: rootTeamCollection.id,
|
||||||
|
title: rootTeamCollection.title,
|
||||||
|
parentID: rootTeamCollection.parentID,
|
||||||
|
data: JSON.stringify(rootTeamCollection.data),
|
||||||
|
};
|
||||||
|
|
||||||
const rootTeamCollection_2: DBTeamCollection = {
|
const rootTeamCollection_2: DBTeamCollection = {
|
||||||
id: 'erv',
|
id: 'erv',
|
||||||
orderIndex: 2,
|
orderIndex: 2,
|
||||||
parentID: null,
|
parentID: null,
|
||||||
|
data: {},
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
updatedOn: currentTime,
|
updatedOn: currentTime,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const rootTeamCollection_2Casted: TeamCollection = {
|
||||||
|
id: 'erv',
|
||||||
|
parentID: null,
|
||||||
|
data: JSON.stringify(rootTeamCollection_2.data),
|
||||||
|
title: 'Root Collection 1',
|
||||||
|
};
|
||||||
|
|
||||||
const childTeamCollection: DBTeamCollection = {
|
const childTeamCollection: DBTeamCollection = {
|
||||||
id: 'rfe',
|
id: 'rfe',
|
||||||
orderIndex: 1,
|
orderIndex: 1,
|
||||||
parentID: rootTeamCollection.id,
|
parentID: rootTeamCollection.id,
|
||||||
|
data: {},
|
||||||
title: 'Child Collection 1',
|
title: 'Child Collection 1',
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
updatedOn: currentTime,
|
updatedOn: currentTime,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const childTeamCollectionCasted: TeamCollection = {
|
||||||
|
id: 'rfe',
|
||||||
|
parentID: rootTeamCollection.id,
|
||||||
|
data: JSON.stringify(childTeamCollection.data),
|
||||||
|
title: 'Child Collection 1',
|
||||||
|
};
|
||||||
|
|
||||||
const childTeamCollection_2: DBTeamCollection = {
|
const childTeamCollection_2: DBTeamCollection = {
|
||||||
id: 'bgdz',
|
id: 'bgdz',
|
||||||
orderIndex: 1,
|
orderIndex: 1,
|
||||||
|
data: {},
|
||||||
parentID: rootTeamCollection_2.id,
|
parentID: rootTeamCollection_2.id,
|
||||||
title: 'Child Collection 1',
|
title: 'Child Collection 1',
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
@@ -90,11 +114,20 @@ const childTeamCollection_2: DBTeamCollection = {
|
|||||||
updatedOn: currentTime,
|
updatedOn: currentTime,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const childTeamCollection_2Casted: TeamCollection = {
|
||||||
|
id: 'bgdz',
|
||||||
|
data: JSON.stringify(childTeamCollection_2.data),
|
||||||
|
parentID: rootTeamCollection_2.id,
|
||||||
|
title: 'Child Collection 1',
|
||||||
|
};
|
||||||
|
|
||||||
const rootTeamCollectionList: DBTeamCollection[] = [
|
const rootTeamCollectionList: DBTeamCollection[] = [
|
||||||
{
|
{
|
||||||
id: 'fdv',
|
id: 'fdv',
|
||||||
orderIndex: 1,
|
orderIndex: 1,
|
||||||
parentID: null,
|
parentID: null,
|
||||||
|
data: {},
|
||||||
|
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
@@ -105,6 +138,8 @@ const rootTeamCollectionList: DBTeamCollection[] = [
|
|||||||
orderIndex: 2,
|
orderIndex: 2,
|
||||||
parentID: null,
|
parentID: null,
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
|
data: {},
|
||||||
|
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
updatedOn: currentTime,
|
updatedOn: currentTime,
|
||||||
@@ -114,6 +149,8 @@ const rootTeamCollectionList: DBTeamCollection[] = [
|
|||||||
orderIndex: 3,
|
orderIndex: 3,
|
||||||
parentID: null,
|
parentID: null,
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
|
data: {},
|
||||||
|
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
updatedOn: currentTime,
|
updatedOn: currentTime,
|
||||||
@@ -122,6 +159,8 @@ const rootTeamCollectionList: DBTeamCollection[] = [
|
|||||||
id: 'bre3',
|
id: 'bre3',
|
||||||
orderIndex: 4,
|
orderIndex: 4,
|
||||||
parentID: null,
|
parentID: null,
|
||||||
|
data: {},
|
||||||
|
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
@@ -132,6 +171,8 @@ const rootTeamCollectionList: DBTeamCollection[] = [
|
|||||||
orderIndex: 5,
|
orderIndex: 5,
|
||||||
parentID: null,
|
parentID: null,
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
|
data: {},
|
||||||
|
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
updatedOn: currentTime,
|
updatedOn: currentTime,
|
||||||
@@ -142,6 +183,8 @@ const rootTeamCollectionList: DBTeamCollection[] = [
|
|||||||
parentID: null,
|
parentID: null,
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
|
data: {},
|
||||||
|
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
updatedOn: currentTime,
|
updatedOn: currentTime,
|
||||||
},
|
},
|
||||||
@@ -151,6 +194,8 @@ const rootTeamCollectionList: DBTeamCollection[] = [
|
|||||||
parentID: null,
|
parentID: null,
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
|
data: {},
|
||||||
|
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
updatedOn: currentTime,
|
updatedOn: currentTime,
|
||||||
},
|
},
|
||||||
@@ -159,6 +204,7 @@ const rootTeamCollectionList: DBTeamCollection[] = [
|
|||||||
orderIndex: 8,
|
orderIndex: 8,
|
||||||
parentID: null,
|
parentID: null,
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
|
data: {},
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
updatedOn: currentTime,
|
updatedOn: currentTime,
|
||||||
@@ -168,6 +214,7 @@ const rootTeamCollectionList: DBTeamCollection[] = [
|
|||||||
orderIndex: 9,
|
orderIndex: 9,
|
||||||
parentID: null,
|
parentID: null,
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
|
data: {},
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
updatedOn: currentTime,
|
updatedOn: currentTime,
|
||||||
@@ -178,17 +225,83 @@ const rootTeamCollectionList: DBTeamCollection[] = [
|
|||||||
parentID: null,
|
parentID: null,
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
|
data: {},
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
updatedOn: currentTime,
|
updatedOn: currentTime,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const rootTeamCollectionListCasted: TeamCollection[] = [
|
||||||
|
{
|
||||||
|
id: 'fdv',
|
||||||
|
parentID: null,
|
||||||
|
title: 'Root Collection 1',
|
||||||
|
data: JSON.stringify(rootTeamCollection.data),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'fbbg',
|
||||||
|
parentID: null,
|
||||||
|
title: 'Root Collection 1',
|
||||||
|
data: JSON.stringify(rootTeamCollection.data),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'fgbfg',
|
||||||
|
parentID: null,
|
||||||
|
title: 'Root Collection 1',
|
||||||
|
data: JSON.stringify(rootTeamCollection.data),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'bre3',
|
||||||
|
parentID: null,
|
||||||
|
data: JSON.stringify(rootTeamCollection.data),
|
||||||
|
title: 'Root Collection 1',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'hghgf',
|
||||||
|
parentID: null,
|
||||||
|
title: 'Root Collection 1',
|
||||||
|
data: JSON.stringify(rootTeamCollection.data),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '123',
|
||||||
|
parentID: null,
|
||||||
|
title: 'Root Collection 1',
|
||||||
|
data: JSON.stringify(rootTeamCollection.data),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '54tyh',
|
||||||
|
parentID: null,
|
||||||
|
title: 'Root Collection 1',
|
||||||
|
data: JSON.stringify(rootTeamCollection.data),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '234re',
|
||||||
|
parentID: null,
|
||||||
|
title: 'Root Collection 1',
|
||||||
|
data: JSON.stringify(rootTeamCollection.data),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '34rtg',
|
||||||
|
parentID: null,
|
||||||
|
title: 'Root Collection 1',
|
||||||
|
data: JSON.stringify(rootTeamCollection.data),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '45tgh',
|
||||||
|
parentID: null,
|
||||||
|
title: 'Root Collection 1',
|
||||||
|
data: JSON.stringify(rootTeamCollection.data),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const childTeamCollectionList: DBTeamCollection[] = [
|
const childTeamCollectionList: DBTeamCollection[] = [
|
||||||
{
|
{
|
||||||
id: '123',
|
id: '123',
|
||||||
orderIndex: 1,
|
orderIndex: 1,
|
||||||
parentID: rootTeamCollection.id,
|
parentID: rootTeamCollection.id,
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
|
data: {},
|
||||||
|
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
updatedOn: currentTime,
|
updatedOn: currentTime,
|
||||||
@@ -198,6 +311,8 @@ const childTeamCollectionList: DBTeamCollection[] = [
|
|||||||
orderIndex: 2,
|
orderIndex: 2,
|
||||||
parentID: rootTeamCollection.id,
|
parentID: rootTeamCollection.id,
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
|
data: {},
|
||||||
|
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
updatedOn: currentTime,
|
updatedOn: currentTime,
|
||||||
@@ -207,6 +322,8 @@ const childTeamCollectionList: DBTeamCollection[] = [
|
|||||||
orderIndex: 3,
|
orderIndex: 3,
|
||||||
parentID: rootTeamCollection.id,
|
parentID: rootTeamCollection.id,
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
|
data: {},
|
||||||
|
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
updatedOn: currentTime,
|
updatedOn: currentTime,
|
||||||
@@ -215,6 +332,8 @@ const childTeamCollectionList: DBTeamCollection[] = [
|
|||||||
id: '567',
|
id: '567',
|
||||||
orderIndex: 4,
|
orderIndex: 4,
|
||||||
parentID: rootTeamCollection.id,
|
parentID: rootTeamCollection.id,
|
||||||
|
data: {},
|
||||||
|
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
@@ -224,6 +343,8 @@ const childTeamCollectionList: DBTeamCollection[] = [
|
|||||||
id: '123',
|
id: '123',
|
||||||
orderIndex: 5,
|
orderIndex: 5,
|
||||||
parentID: rootTeamCollection.id,
|
parentID: rootTeamCollection.id,
|
||||||
|
data: {},
|
||||||
|
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
@@ -233,6 +354,8 @@ const childTeamCollectionList: DBTeamCollection[] = [
|
|||||||
id: '678',
|
id: '678',
|
||||||
orderIndex: 6,
|
orderIndex: 6,
|
||||||
parentID: rootTeamCollection.id,
|
parentID: rootTeamCollection.id,
|
||||||
|
data: {},
|
||||||
|
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
@@ -242,6 +365,8 @@ const childTeamCollectionList: DBTeamCollection[] = [
|
|||||||
id: '789',
|
id: '789',
|
||||||
orderIndex: 7,
|
orderIndex: 7,
|
||||||
parentID: rootTeamCollection.id,
|
parentID: rootTeamCollection.id,
|
||||||
|
data: {},
|
||||||
|
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
@@ -251,6 +376,8 @@ const childTeamCollectionList: DBTeamCollection[] = [
|
|||||||
id: '890',
|
id: '890',
|
||||||
orderIndex: 8,
|
orderIndex: 8,
|
||||||
parentID: rootTeamCollection.id,
|
parentID: rootTeamCollection.id,
|
||||||
|
data: {},
|
||||||
|
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
@@ -260,6 +387,7 @@ const childTeamCollectionList: DBTeamCollection[] = [
|
|||||||
id: '012',
|
id: '012',
|
||||||
orderIndex: 9,
|
orderIndex: 9,
|
||||||
parentID: rootTeamCollection.id,
|
parentID: rootTeamCollection.id,
|
||||||
|
data: {},
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
@@ -269,6 +397,8 @@ const childTeamCollectionList: DBTeamCollection[] = [
|
|||||||
id: '0bhu',
|
id: '0bhu',
|
||||||
orderIndex: 10,
|
orderIndex: 10,
|
||||||
parentID: rootTeamCollection.id,
|
parentID: rootTeamCollection.id,
|
||||||
|
data: {},
|
||||||
|
|
||||||
title: 'Root Collection 1',
|
title: 'Root Collection 1',
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
createdOn: currentTime,
|
createdOn: currentTime,
|
||||||
@@ -276,6 +406,75 @@ const childTeamCollectionList: DBTeamCollection[] = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const childTeamCollectionListCasted: TeamCollection[] = [
|
||||||
|
{
|
||||||
|
id: '123',
|
||||||
|
parentID: rootTeamCollection.id,
|
||||||
|
title: 'Root Collection 1',
|
||||||
|
data: JSON.stringify({}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '345',
|
||||||
|
parentID: rootTeamCollection.id,
|
||||||
|
title: 'Root Collection 1',
|
||||||
|
data: JSON.stringify({}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '456',
|
||||||
|
parentID: rootTeamCollection.id,
|
||||||
|
title: 'Root Collection 1',
|
||||||
|
data: JSON.stringify({}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '567',
|
||||||
|
parentID: rootTeamCollection.id,
|
||||||
|
data: JSON.stringify({}),
|
||||||
|
|
||||||
|
title: 'Root Collection 1',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '123',
|
||||||
|
parentID: rootTeamCollection.id,
|
||||||
|
data: JSON.stringify({}),
|
||||||
|
|
||||||
|
title: 'Root Collection 1',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '678',
|
||||||
|
parentID: rootTeamCollection.id,
|
||||||
|
data: JSON.stringify({}),
|
||||||
|
|
||||||
|
title: 'Root Collection 1',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '789',
|
||||||
|
parentID: rootTeamCollection.id,
|
||||||
|
data: JSON.stringify({}),
|
||||||
|
|
||||||
|
title: 'Root Collection 1',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '890',
|
||||||
|
parentID: rootTeamCollection.id,
|
||||||
|
data: JSON.stringify({}),
|
||||||
|
|
||||||
|
title: 'Root Collection 1',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '012',
|
||||||
|
parentID: rootTeamCollection.id,
|
||||||
|
data: JSON.stringify({}),
|
||||||
|
title: 'Root Collection 1',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '0bhu',
|
||||||
|
parentID: rootTeamCollection.id,
|
||||||
|
data: JSON.stringify({}),
|
||||||
|
|
||||||
|
title: 'Root Collection 1',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockReset(mockPrisma);
|
mockReset(mockPrisma);
|
||||||
mockPubSub.publish.mockClear();
|
mockPubSub.publish.mockClear();
|
||||||
@@ -314,7 +513,7 @@ describe('getParentOfCollection', () => {
|
|||||||
const result = await teamCollectionService.getParentOfCollection(
|
const result = await teamCollectionService.getParentOfCollection(
|
||||||
childTeamCollection.id,
|
childTeamCollection.id,
|
||||||
);
|
);
|
||||||
expect(result).toEqual(rootTeamCollection);
|
expect(result).toEqual(rootTeamCollectionsCasted);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return null successfully for a root collection with valid collectionID', async () => {
|
test('should return null successfully for a root collection with valid collectionID', async () => {
|
||||||
@@ -350,7 +549,7 @@ describe('getChildrenOfCollection', () => {
|
|||||||
null,
|
null,
|
||||||
10,
|
10,
|
||||||
);
|
);
|
||||||
expect(result).toEqual(childTeamCollectionList);
|
expect(result).toEqual(childTeamCollectionListCasted);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return a list of 3 child collections successfully with cursor being equal to the 7th item in the list', async () => {
|
test('should return a list of 3 child collections successfully with cursor being equal to the 7th item in the list', async () => {
|
||||||
@@ -366,9 +565,9 @@ describe('getChildrenOfCollection', () => {
|
|||||||
10,
|
10,
|
||||||
);
|
);
|
||||||
expect(result).toEqual([
|
expect(result).toEqual([
|
||||||
{ ...childTeamCollectionList[7] },
|
{ ...childTeamCollectionListCasted[7] },
|
||||||
{ ...childTeamCollectionList[8] },
|
{ ...childTeamCollectionListCasted[8] },
|
||||||
{ ...childTeamCollectionList[9] },
|
{ ...childTeamCollectionListCasted[9] },
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -395,7 +594,7 @@ describe('getTeamRootCollections', () => {
|
|||||||
null,
|
null,
|
||||||
10,
|
10,
|
||||||
);
|
);
|
||||||
expect(result).toEqual(rootTeamCollectionList);
|
expect(result).toEqual(rootTeamCollectionListCasted);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return a list of 3 root collections successfully with cursor being equal to the 7th item in the list', async () => {
|
test('should return a list of 3 root collections successfully with cursor being equal to the 7th item in the list', async () => {
|
||||||
@@ -411,9 +610,9 @@ describe('getTeamRootCollections', () => {
|
|||||||
10,
|
10,
|
||||||
);
|
);
|
||||||
expect(result).toEqual([
|
expect(result).toEqual([
|
||||||
{ ...rootTeamCollectionList[7] },
|
{ ...rootTeamCollectionListCasted[7] },
|
||||||
{ ...rootTeamCollectionList[8] },
|
{ ...rootTeamCollectionListCasted[8] },
|
||||||
{ ...rootTeamCollectionList[9] },
|
{ ...rootTeamCollectionListCasted[9] },
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -467,6 +666,7 @@ describe('createCollection', () => {
|
|||||||
const result = await teamCollectionService.createCollection(
|
const result = await teamCollectionService.createCollection(
|
||||||
rootTeamCollection.teamID,
|
rootTeamCollection.teamID,
|
||||||
'ab',
|
'ab',
|
||||||
|
JSON.stringify(rootTeamCollection.data),
|
||||||
rootTeamCollection.id,
|
rootTeamCollection.id,
|
||||||
);
|
);
|
||||||
expect(result).toEqualLeft(TEAM_COLL_SHORT_TITLE);
|
expect(result).toEqualLeft(TEAM_COLL_SHORT_TITLE);
|
||||||
@@ -481,11 +681,27 @@ describe('createCollection', () => {
|
|||||||
const result = await teamCollectionService.createCollection(
|
const result = await teamCollectionService.createCollection(
|
||||||
rootTeamCollection.teamID,
|
rootTeamCollection.teamID,
|
||||||
'abcd',
|
'abcd',
|
||||||
|
JSON.stringify(rootTeamCollection.data),
|
||||||
rootTeamCollection.id,
|
rootTeamCollection.id,
|
||||||
);
|
);
|
||||||
expect(result).toEqualLeft(TEAM_NOT_OWNER);
|
expect(result).toEqualLeft(TEAM_NOT_OWNER);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should throw TEAM_COLL_DATA_INVALID when parent TeamCollection does not belong to the team', async () => {
|
||||||
|
// isOwnerCheck
|
||||||
|
mockPrisma.teamCollection.findFirstOrThrow.mockResolvedValueOnce(
|
||||||
|
rootTeamCollection,
|
||||||
|
);
|
||||||
|
|
||||||
|
const result = await teamCollectionService.createCollection(
|
||||||
|
rootTeamCollection.teamID,
|
||||||
|
'abcd',
|
||||||
|
'{',
|
||||||
|
rootTeamCollection.id,
|
||||||
|
);
|
||||||
|
expect(result).toEqualLeft(TEAM_COLL_DATA_INVALID);
|
||||||
|
});
|
||||||
|
|
||||||
test('should successfully create a new root TeamCollection with valid inputs', async () => {
|
test('should successfully create a new root TeamCollection with valid inputs', async () => {
|
||||||
// isOwnerCheck
|
// isOwnerCheck
|
||||||
mockPrisma.teamCollection.findFirstOrThrow.mockResolvedValueOnce(
|
mockPrisma.teamCollection.findFirstOrThrow.mockResolvedValueOnce(
|
||||||
@@ -499,9 +715,10 @@ describe('createCollection', () => {
|
|||||||
const result = await teamCollectionService.createCollection(
|
const result = await teamCollectionService.createCollection(
|
||||||
rootTeamCollection.teamID,
|
rootTeamCollection.teamID,
|
||||||
'abcdefg',
|
'abcdefg',
|
||||||
|
JSON.stringify(rootTeamCollection.data),
|
||||||
rootTeamCollection.id,
|
rootTeamCollection.id,
|
||||||
);
|
);
|
||||||
expect(result).toEqualRight(rootTeamCollection);
|
expect(result).toEqualRight(rootTeamCollectionsCasted);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should successfully create a new child TeamCollection with valid inputs', async () => {
|
test('should successfully create a new child TeamCollection with valid inputs', async () => {
|
||||||
@@ -517,9 +734,10 @@ describe('createCollection', () => {
|
|||||||
const result = await teamCollectionService.createCollection(
|
const result = await teamCollectionService.createCollection(
|
||||||
childTeamCollection.teamID,
|
childTeamCollection.teamID,
|
||||||
childTeamCollection.title,
|
childTeamCollection.title,
|
||||||
|
JSON.stringify(rootTeamCollection.data),
|
||||||
rootTeamCollection.id,
|
rootTeamCollection.id,
|
||||||
);
|
);
|
||||||
expect(result).toEqualRight(childTeamCollection);
|
expect(result).toEqualRight(childTeamCollectionCasted);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should send pubsub message to "team_coll/<teamID>/coll_added" if child TeamCollection is created successfully', async () => {
|
test('should send pubsub message to "team_coll/<teamID>/coll_added" if child TeamCollection is created successfully', async () => {
|
||||||
@@ -535,11 +753,13 @@ describe('createCollection', () => {
|
|||||||
const result = await teamCollectionService.createCollection(
|
const result = await teamCollectionService.createCollection(
|
||||||
childTeamCollection.teamID,
|
childTeamCollection.teamID,
|
||||||
childTeamCollection.title,
|
childTeamCollection.title,
|
||||||
|
JSON.stringify(rootTeamCollection.data),
|
||||||
|
|
||||||
rootTeamCollection.id,
|
rootTeamCollection.id,
|
||||||
);
|
);
|
||||||
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
||||||
`team_coll/${childTeamCollection.teamID}/coll_added`,
|
`team_coll/${childTeamCollection.teamID}/coll_added`,
|
||||||
childTeamCollection,
|
childTeamCollectionCasted,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -556,11 +776,13 @@ describe('createCollection', () => {
|
|||||||
const result = await teamCollectionService.createCollection(
|
const result = await teamCollectionService.createCollection(
|
||||||
rootTeamCollection.teamID,
|
rootTeamCollection.teamID,
|
||||||
'abcdefg',
|
'abcdefg',
|
||||||
|
JSON.stringify(rootTeamCollection.data),
|
||||||
|
|
||||||
rootTeamCollection.id,
|
rootTeamCollection.id,
|
||||||
);
|
);
|
||||||
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
||||||
`team_coll/${rootTeamCollection.teamID}/coll_added`,
|
`team_coll/${rootTeamCollection.teamID}/coll_added`,
|
||||||
rootTeamCollection,
|
rootTeamCollectionsCasted,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -590,7 +812,7 @@ describe('renameCollection', () => {
|
|||||||
'NewTitle',
|
'NewTitle',
|
||||||
);
|
);
|
||||||
expect(result).toEqualRight({
|
expect(result).toEqualRight({
|
||||||
...rootTeamCollection,
|
...rootTeamCollectionsCasted,
|
||||||
title: 'NewTitle',
|
title: 'NewTitle',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -628,7 +850,7 @@ describe('renameCollection', () => {
|
|||||||
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
||||||
`team_coll/${rootTeamCollection.teamID}/coll_updated`,
|
`team_coll/${rootTeamCollection.teamID}/coll_updated`,
|
||||||
{
|
{
|
||||||
...rootTeamCollection,
|
...rootTeamCollectionsCasted,
|
||||||
title: 'NewTitle',
|
title: 'NewTitle',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -835,9 +1057,8 @@ describe('moveCollection', () => {
|
|||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
expect(result).toEqualRight({
|
expect(result).toEqualRight({
|
||||||
...childTeamCollection,
|
...childTeamCollectionCasted,
|
||||||
parentID: null,
|
parentID: null,
|
||||||
orderIndex: 2,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -893,9 +1114,8 @@ describe('moveCollection', () => {
|
|||||||
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
||||||
`team_coll/${childTeamCollection.teamID}/coll_moved`,
|
`team_coll/${childTeamCollection.teamID}/coll_moved`,
|
||||||
{
|
{
|
||||||
...childTeamCollection,
|
...childTeamCollectionCasted,
|
||||||
parentID: null,
|
parentID: null,
|
||||||
orderIndex: 2,
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -934,9 +1154,8 @@ describe('moveCollection', () => {
|
|||||||
childTeamCollection_2.id,
|
childTeamCollection_2.id,
|
||||||
);
|
);
|
||||||
expect(result).toEqualRight({
|
expect(result).toEqualRight({
|
||||||
...rootTeamCollection,
|
...rootTeamCollectionsCasted,
|
||||||
parentID: childTeamCollection_2.id,
|
parentID: childTeamCollection_2Casted.id,
|
||||||
orderIndex: 1,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -976,9 +1195,8 @@ describe('moveCollection', () => {
|
|||||||
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
||||||
`team_coll/${childTeamCollection_2.teamID}/coll_moved`,
|
`team_coll/${childTeamCollection_2.teamID}/coll_moved`,
|
||||||
{
|
{
|
||||||
...rootTeamCollection,
|
...rootTeamCollectionsCasted,
|
||||||
parentID: childTeamCollection_2.id,
|
parentID: childTeamCollection_2Casted.id,
|
||||||
orderIndex: 1,
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -1017,9 +1235,8 @@ describe('moveCollection', () => {
|
|||||||
childTeamCollection_2.id,
|
childTeamCollection_2.id,
|
||||||
);
|
);
|
||||||
expect(result).toEqualRight({
|
expect(result).toEqualRight({
|
||||||
...childTeamCollection,
|
...childTeamCollectionCasted,
|
||||||
parentID: childTeamCollection_2.id,
|
parentID: childTeamCollection_2Casted.id,
|
||||||
orderIndex: 1,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1059,9 +1276,8 @@ describe('moveCollection', () => {
|
|||||||
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
||||||
`team_coll/${childTeamCollection.teamID}/coll_moved`,
|
`team_coll/${childTeamCollection.teamID}/coll_moved`,
|
||||||
{
|
{
|
||||||
...childTeamCollection,
|
...childTeamCollectionCasted,
|
||||||
parentID: childTeamCollection_2.id,
|
parentID: childTeamCollection_2Casted.id,
|
||||||
orderIndex: 1,
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -1157,7 +1373,7 @@ describe('updateCollectionOrder', () => {
|
|||||||
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
||||||
`team_coll/${childTeamCollectionList[4].teamID}/coll_order_updated`,
|
`team_coll/${childTeamCollectionList[4].teamID}/coll_order_updated`,
|
||||||
{
|
{
|
||||||
collection: rootTeamCollectionList[4],
|
collection: rootTeamCollectionListCasted[4],
|
||||||
nextCollection: null,
|
nextCollection: null,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -1238,8 +1454,8 @@ describe('updateCollectionOrder', () => {
|
|||||||
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
||||||
`team_coll/${childTeamCollectionList[2].teamID}/coll_order_updated`,
|
`team_coll/${childTeamCollectionList[2].teamID}/coll_order_updated`,
|
||||||
{
|
{
|
||||||
collection: childTeamCollectionList[4],
|
collection: childTeamCollectionListCasted[4],
|
||||||
nextCollection: childTeamCollectionList[2],
|
nextCollection: childTeamCollectionListCasted[2],
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -1305,7 +1521,7 @@ describe('importCollectionsFromJSON', () => {
|
|||||||
);
|
);
|
||||||
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
||||||
`team_coll/${rootTeamCollection.teamID}/coll_added`,
|
`team_coll/${rootTeamCollection.teamID}/coll_added`,
|
||||||
rootTeamCollection,
|
rootTeamCollectionsCasted,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1424,7 +1640,7 @@ describe('replaceCollectionsWithJSON', () => {
|
|||||||
);
|
);
|
||||||
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
||||||
`team_coll/${rootTeamCollection.teamID}/coll_added`,
|
`team_coll/${rootTeamCollection.teamID}/coll_added`,
|
||||||
rootTeamCollection,
|
rootTeamCollectionsCasted,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1461,4 +1677,64 @@ describe('totalCollectionsInTeam', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('updateTeamCollection', () => {
|
||||||
|
test('should throw TEAM_COLL_SHORT_TITLE if title is invalid', async () => {
|
||||||
|
const result = await teamCollectionService.updateTeamCollection(
|
||||||
|
rootTeamCollection.id,
|
||||||
|
JSON.stringify(rootTeamCollection.data),
|
||||||
|
'de',
|
||||||
|
);
|
||||||
|
expect(result).toEqualLeft(TEAM_COLL_SHORT_TITLE);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should throw TEAM_COLL_DATA_INVALID is collection data is invalid', async () => {
|
||||||
|
const result = await teamCollectionService.updateTeamCollection(
|
||||||
|
rootTeamCollection.id,
|
||||||
|
'{',
|
||||||
|
rootTeamCollection.title,
|
||||||
|
);
|
||||||
|
expect(result).toEqualLeft(TEAM_COLL_DATA_INVALID);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should throw TEAM_COLL_NOT_FOUND is collectionID is invalid', async () => {
|
||||||
|
mockPrisma.teamCollection.update.mockRejectedValueOnce('RecordNotFound');
|
||||||
|
|
||||||
|
const result = await teamCollectionService.updateTeamCollection(
|
||||||
|
'invalid_id',
|
||||||
|
JSON.stringify(rootTeamCollection.data),
|
||||||
|
rootTeamCollection.title,
|
||||||
|
);
|
||||||
|
expect(result).toEqualLeft(TEAM_COLL_NOT_FOUND);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should successfully update a collection', async () => {
|
||||||
|
mockPrisma.teamCollection.update.mockResolvedValueOnce(rootTeamCollection);
|
||||||
|
|
||||||
|
const result = await teamCollectionService.updateTeamCollection(
|
||||||
|
rootTeamCollection.id,
|
||||||
|
JSON.stringify({ foo: 'bar' }),
|
||||||
|
'new_title',
|
||||||
|
);
|
||||||
|
expect(result).toEqualRight({
|
||||||
|
data: JSON.stringify({ foo: 'bar' }),
|
||||||
|
title: 'new_title',
|
||||||
|
...rootTeamCollectionsCasted,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should send pubsub message to "team_coll/<teamID>/coll_updated" if TeamCollection is updated successfully', async () => {
|
||||||
|
mockPrisma.teamCollection.update.mockResolvedValueOnce(rootTeamCollection);
|
||||||
|
|
||||||
|
const result = await teamCollectionService.updateTeamCollection(
|
||||||
|
rootTeamCollection.id,
|
||||||
|
JSON.stringify(rootTeamCollection.data),
|
||||||
|
rootTeamCollection.title,
|
||||||
|
);
|
||||||
|
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
||||||
|
`team_coll/${rootTeamCollection.teamID}/coll_updated`,
|
||||||
|
rootTeamCollectionsCasted,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
//ToDo: write test cases for exportCollectionsToJSON
|
//ToDo: write test cases for exportCollectionsToJSON
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
TEAM_COLL_IS_PARENT_COLL,
|
TEAM_COLL_IS_PARENT_COLL,
|
||||||
TEAM_COL_SAME_NEXT_COLL,
|
TEAM_COL_SAME_NEXT_COLL,
|
||||||
TEAM_COL_REORDERING_FAILED,
|
TEAM_COL_REORDERING_FAILED,
|
||||||
|
TEAM_COLL_DATA_INVALID,
|
||||||
} from '../errors';
|
} from '../errors';
|
||||||
import { PubSubService } from '../pubsub/pubsub.service';
|
import { PubSubService } from '../pubsub/pubsub.service';
|
||||||
import { isValidLength } from 'src/utils';
|
import { isValidLength } from 'src/utils';
|
||||||
@@ -69,6 +70,7 @@ export class TeamCollectionService {
|
|||||||
this.generatePrismaQueryObjForFBCollFolder(f, teamID, index + 1),
|
this.generatePrismaQueryObjForFBCollFolder(f, teamID, index + 1),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
data: folder.data ?? undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,6 +120,7 @@ export class TeamCollectionService {
|
|||||||
name: collection.right.title,
|
name: collection.right.title,
|
||||||
folders: childrenCollectionObjects,
|
folders: childrenCollectionObjects,
|
||||||
requests: requests.map((x) => x.request),
|
requests: requests.map((x) => x.request),
|
||||||
|
data: JSON.stringify(collection.right.data),
|
||||||
};
|
};
|
||||||
|
|
||||||
return E.right(result);
|
return E.right(result);
|
||||||
@@ -198,8 +201,11 @@ export class TeamCollectionService {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
teamCollections.forEach((x) =>
|
teamCollections.forEach((collection) =>
|
||||||
this.pubsub.publish(`team_coll/${destTeamID}/coll_added`, x),
|
this.pubsub.publish(
|
||||||
|
`team_coll/${destTeamID}/coll_added`,
|
||||||
|
this.cast(collection),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
return E.right(true);
|
return E.right(true);
|
||||||
@@ -268,8 +274,11 @@ export class TeamCollectionService {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
teamCollections.forEach((x) =>
|
teamCollections.forEach((collections) =>
|
||||||
this.pubsub.publish(`team_coll/${destTeamID}/coll_added`, x),
|
this.pubsub.publish(
|
||||||
|
`team_coll/${destTeamID}/coll_added`,
|
||||||
|
this.cast(collections),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
return E.right(true);
|
return E.right(true);
|
||||||
@@ -277,11 +286,17 @@ export class TeamCollectionService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Typecast a database TeamCollection to a TeamCollection model
|
* Typecast a database TeamCollection to a TeamCollection model
|
||||||
|
*
|
||||||
* @param teamCollection database TeamCollection
|
* @param teamCollection database TeamCollection
|
||||||
* @returns TeamCollection model
|
* @returns TeamCollection model
|
||||||
*/
|
*/
|
||||||
private cast(teamCollection: DBTeamCollection): TeamCollection {
|
private cast(teamCollection: DBTeamCollection): TeamCollection {
|
||||||
return <TeamCollection>{ ...teamCollection };
|
return <TeamCollection>{
|
||||||
|
id: teamCollection.id,
|
||||||
|
title: teamCollection.title,
|
||||||
|
parentID: teamCollection.parentID,
|
||||||
|
data: !teamCollection.data ? null : JSON.stringify(teamCollection.data),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -324,7 +339,7 @@ export class TeamCollectionService {
|
|||||||
});
|
});
|
||||||
if (!teamCollection) return null;
|
if (!teamCollection) return null;
|
||||||
|
|
||||||
return teamCollection.parent;
|
return !teamCollection.parent ? null : this.cast(teamCollection.parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -335,12 +350,12 @@ export class TeamCollectionService {
|
|||||||
* @param take Number of items we want returned
|
* @param take Number of items we want returned
|
||||||
* @returns A list of child collections
|
* @returns A list of child collections
|
||||||
*/
|
*/
|
||||||
getChildrenOfCollection(
|
async getChildrenOfCollection(
|
||||||
collectionID: string,
|
collectionID: string,
|
||||||
cursor: string | null,
|
cursor: string | null,
|
||||||
take: number,
|
take: number,
|
||||||
) {
|
) {
|
||||||
return this.prisma.teamCollection.findMany({
|
const res = await this.prisma.teamCollection.findMany({
|
||||||
where: {
|
where: {
|
||||||
parentID: collectionID,
|
parentID: collectionID,
|
||||||
},
|
},
|
||||||
@@ -351,6 +366,12 @@ export class TeamCollectionService {
|
|||||||
skip: cursor ? 1 : 0,
|
skip: cursor ? 1 : 0,
|
||||||
cursor: cursor ? { id: cursor } : undefined,
|
cursor: cursor ? { id: cursor } : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const childCollections = res.map((teamCollection) =>
|
||||||
|
this.cast(teamCollection),
|
||||||
|
);
|
||||||
|
|
||||||
|
return childCollections;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -366,7 +387,7 @@ export class TeamCollectionService {
|
|||||||
cursor: string | null,
|
cursor: string | null,
|
||||||
take: number,
|
take: number,
|
||||||
) {
|
) {
|
||||||
return this.prisma.teamCollection.findMany({
|
const res = await this.prisma.teamCollection.findMany({
|
||||||
where: {
|
where: {
|
||||||
teamID,
|
teamID,
|
||||||
parentID: null,
|
parentID: null,
|
||||||
@@ -378,6 +399,12 @@ export class TeamCollectionService {
|
|||||||
skip: cursor ? 1 : 0,
|
skip: cursor ? 1 : 0,
|
||||||
cursor: cursor ? { id: cursor } : undefined,
|
cursor: cursor ? { id: cursor } : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const teamCollections = res.map((teamCollection) =>
|
||||||
|
this.cast(teamCollection),
|
||||||
|
);
|
||||||
|
|
||||||
|
return teamCollections;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -470,6 +497,7 @@ export class TeamCollectionService {
|
|||||||
async createCollection(
|
async createCollection(
|
||||||
teamID: string,
|
teamID: string,
|
||||||
title: string,
|
title: string,
|
||||||
|
data: string | null = null,
|
||||||
parentTeamCollectionID: string | null,
|
parentTeamCollectionID: string | null,
|
||||||
) {
|
) {
|
||||||
const isTitleValid = isValidLength(title, this.TITLE_LENGTH);
|
const isTitleValid = isValidLength(title, this.TITLE_LENGTH);
|
||||||
@@ -481,6 +509,13 @@ export class TeamCollectionService {
|
|||||||
if (O.isNone(isOwner)) return E.left(TEAM_NOT_OWNER);
|
if (O.isNone(isOwner)) return E.left(TEAM_NOT_OWNER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data === '') return E.left(TEAM_COLL_DATA_INVALID);
|
||||||
|
if (data) {
|
||||||
|
const jsonReq = stringToJson(data);
|
||||||
|
if (E.isLeft(jsonReq)) return E.left(TEAM_COLL_DATA_INVALID);
|
||||||
|
data = jsonReq.right;
|
||||||
|
}
|
||||||
|
|
||||||
const isParent = parentTeamCollectionID
|
const isParent = parentTeamCollectionID
|
||||||
? {
|
? {
|
||||||
connect: {
|
connect: {
|
||||||
@@ -498,18 +533,23 @@ export class TeamCollectionService {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
parent: isParent,
|
parent: isParent,
|
||||||
|
data: data ?? undefined,
|
||||||
orderIndex: !parentTeamCollectionID
|
orderIndex: !parentTeamCollectionID
|
||||||
? (await this.getRootCollectionsCount(teamID)) + 1
|
? (await this.getRootCollectionsCount(teamID)) + 1
|
||||||
: (await this.getChildCollectionsCount(parentTeamCollectionID)) + 1,
|
: (await this.getChildCollectionsCount(parentTeamCollectionID)) + 1,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
this.pubsub.publish(`team_coll/${teamID}/coll_added`, teamCollection);
|
this.pubsub.publish(
|
||||||
|
`team_coll/${teamID}/coll_added`,
|
||||||
|
this.cast(teamCollection),
|
||||||
|
);
|
||||||
|
|
||||||
return E.right(this.cast(teamCollection));
|
return E.right(this.cast(teamCollection));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @deprecated Use updateTeamCollection method instead
|
||||||
* Update the title of a TeamCollection
|
* Update the title of a TeamCollection
|
||||||
*
|
*
|
||||||
* @param collectionID The Collection ID
|
* @param collectionID The Collection ID
|
||||||
@@ -532,10 +572,10 @@ export class TeamCollectionService {
|
|||||||
|
|
||||||
this.pubsub.publish(
|
this.pubsub.publish(
|
||||||
`team_coll/${updatedTeamCollection.teamID}/coll_updated`,
|
`team_coll/${updatedTeamCollection.teamID}/coll_updated`,
|
||||||
updatedTeamCollection,
|
this.cast(updatedTeamCollection),
|
||||||
);
|
);
|
||||||
|
|
||||||
return E.right(updatedTeamCollection);
|
return E.right(this.cast(updatedTeamCollection));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return E.left(TEAM_COLL_NOT_FOUND);
|
return E.left(TEAM_COLL_NOT_FOUND);
|
||||||
}
|
}
|
||||||
@@ -694,8 +734,8 @@ export class TeamCollectionService {
|
|||||||
* @returns An Option of boolean, is parent or not
|
* @returns An Option of boolean, is parent or not
|
||||||
*/
|
*/
|
||||||
private async isParent(
|
private async isParent(
|
||||||
collection: TeamCollection,
|
collection: DBTeamCollection,
|
||||||
destCollection: TeamCollection,
|
destCollection: DBTeamCollection,
|
||||||
): Promise<O.Option<boolean>> {
|
): Promise<O.Option<boolean>> {
|
||||||
//* Recursively check if collection is a parent by going up the tree of child-parent collections until we reach a root collection i.e parentID === null
|
//* Recursively check if collection is a parent by going up the tree of child-parent collections until we reach a root collection i.e parentID === null
|
||||||
//* Valid condition, isParent returns false
|
//* Valid condition, isParent returns false
|
||||||
@@ -971,4 +1011,49 @@ export class TeamCollectionService {
|
|||||||
const teamCollectionsCount = this.prisma.teamCollection.count();
|
const teamCollectionsCount = this.prisma.teamCollection.count();
|
||||||
return teamCollectionsCount;
|
return teamCollectionsCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Team Collection details
|
||||||
|
*
|
||||||
|
* @param collectionID Collection ID
|
||||||
|
* @param collectionData new header data in a JSONified string form
|
||||||
|
* @param newTitle New title of the collection
|
||||||
|
* @returns Updated TeamCollection
|
||||||
|
*/
|
||||||
|
async updateTeamCollection(
|
||||||
|
collectionID: string,
|
||||||
|
collectionData: string = null,
|
||||||
|
newTitle: string = null,
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
if (newTitle != null) {
|
||||||
|
const isTitleValid = isValidLength(newTitle, this.TITLE_LENGTH);
|
||||||
|
if (!isTitleValid) return E.left(TEAM_COLL_SHORT_TITLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (collectionData === '') return E.left(TEAM_COLL_DATA_INVALID);
|
||||||
|
if (collectionData) {
|
||||||
|
const jsonReq = stringToJson(collectionData);
|
||||||
|
if (E.isLeft(jsonReq)) return E.left(TEAM_COLL_DATA_INVALID);
|
||||||
|
collectionData = jsonReq.right;
|
||||||
|
}
|
||||||
|
|
||||||
|
const updatedTeamCollection = await this.prisma.teamCollection.update({
|
||||||
|
where: { id: collectionID },
|
||||||
|
data: {
|
||||||
|
data: collectionData ?? undefined,
|
||||||
|
title: newTitle ?? undefined,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
this.pubsub.publish(
|
||||||
|
`team_coll/${updatedTeamCollection.teamID}/coll_updated`,
|
||||||
|
this.cast(updatedTeamCollection),
|
||||||
|
);
|
||||||
|
|
||||||
|
return E.right(this.cast(updatedTeamCollection));
|
||||||
|
} catch (e) {
|
||||||
|
return E.left(TEAM_COLL_NOT_FOUND);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -301,7 +301,7 @@ describe('TeamEnvironmentsService', () => {
|
|||||||
|
|
||||||
describe('createDuplicateEnvironment', () => {
|
describe('createDuplicateEnvironment', () => {
|
||||||
test('should successfully duplicate an existing team environment', async () => {
|
test('should successfully duplicate an existing team environment', async () => {
|
||||||
mockPrisma.teamEnvironment.findFirst.mockResolvedValueOnce(
|
mockPrisma.teamEnvironment.findFirstOrThrow.mockResolvedValueOnce(
|
||||||
teamEnvironment,
|
teamEnvironment,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -322,7 +322,9 @@ describe('TeamEnvironmentsService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should throw TEAM_ENVIRONMMENT_NOT_FOUND if provided id is invalid', async () => {
|
test('should throw TEAM_ENVIRONMMENT_NOT_FOUND if provided id is invalid', async () => {
|
||||||
mockPrisma.teamEnvironment.findFirst.mockRejectedValue('NotFoundError');
|
mockPrisma.teamEnvironment.findFirstOrThrow.mockRejectedValue(
|
||||||
|
'NotFoundError',
|
||||||
|
);
|
||||||
|
|
||||||
const result = await teamEnvironmentsService.createDuplicateEnvironment(
|
const result = await teamEnvironmentsService.createDuplicateEnvironment(
|
||||||
teamEnvironment.id,
|
teamEnvironment.id,
|
||||||
@@ -332,7 +334,7 @@ describe('TeamEnvironmentsService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should send pubsub message to "team_environment/<teamID>/created" if team environment is updated successfully', async () => {
|
test('should send pubsub message to "team_environment/<teamID>/created" if team environment is updated successfully', async () => {
|
||||||
mockPrisma.teamEnvironment.findFirst.mockResolvedValueOnce(
|
mockPrisma.teamEnvironment.findFirstOrThrow.mockResolvedValueOnce(
|
||||||
teamEnvironment,
|
teamEnvironment,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -183,11 +183,10 @@ export class TeamEnvironmentsService {
|
|||||||
*/
|
*/
|
||||||
async createDuplicateEnvironment(id: string) {
|
async createDuplicateEnvironment(id: string) {
|
||||||
try {
|
try {
|
||||||
const environment = await this.prisma.teamEnvironment.findFirst({
|
const environment = await this.prisma.teamEnvironment.findFirstOrThrow({
|
||||||
where: {
|
where: {
|
||||||
id: id,
|
id: id,
|
||||||
},
|
},
|
||||||
rejectOnNotFound: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await this.prisma.teamEnvironment.create({
|
const result = await this.prisma.teamEnvironment.create({
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ const teamCollection: DbTeamCollection = {
|
|||||||
id: 'team-coll-1',
|
id: 'team-coll-1',
|
||||||
parentID: null,
|
parentID: null,
|
||||||
teamID: team.id,
|
teamID: team.id,
|
||||||
|
data: {},
|
||||||
title: 'Team Collection 1',
|
title: 'Team Collection 1',
|
||||||
orderIndex: 1,
|
orderIndex: 1,
|
||||||
createdOn: new Date(),
|
createdOn: new Date(),
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
// This interface defines how data will be received from the app when we are importing Hoppscotch collections
|
||||||
export interface CollectionFolder {
|
export interface CollectionFolder {
|
||||||
id?: string;
|
id?: string;
|
||||||
folders: CollectionFolder[];
|
folders: CollectionFolder[];
|
||||||
requests: any[];
|
requests: any[];
|
||||||
name: string;
|
name: string;
|
||||||
|
data?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,13 @@ import { PaginationArgs } from 'src/types/input-types.args';
|
|||||||
export class CreateRootUserCollectionArgs {
|
export class CreateRootUserCollectionArgs {
|
||||||
@Field({ name: 'title', description: 'Title of the new user collection' })
|
@Field({ name: 'title', description: 'Title of the new user collection' })
|
||||||
title: string;
|
title: string;
|
||||||
|
|
||||||
|
@Field({
|
||||||
|
name: 'data',
|
||||||
|
description: 'JSON string representing the collection data',
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
data: string;
|
||||||
}
|
}
|
||||||
@ArgsType()
|
@ArgsType()
|
||||||
export class CreateChildUserCollectionArgs {
|
export class CreateChildUserCollectionArgs {
|
||||||
@@ -17,6 +24,13 @@ export class CreateChildUserCollectionArgs {
|
|||||||
description: 'ID of the parent to the new user collection',
|
description: 'ID of the parent to the new user collection',
|
||||||
})
|
})
|
||||||
parentUserCollectionID: string;
|
parentUserCollectionID: string;
|
||||||
|
|
||||||
|
@Field({
|
||||||
|
name: 'data',
|
||||||
|
description: 'JSON string representing the collection data',
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
data: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ArgsType()
|
@ArgsType()
|
||||||
@@ -95,3 +109,26 @@ export class ImportUserCollectionsFromJSONArgs {
|
|||||||
})
|
})
|
||||||
parentCollectionID?: string;
|
parentCollectionID?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ArgsType()
|
||||||
|
export class UpdateUserCollectionsArgs {
|
||||||
|
@Field(() => ID, {
|
||||||
|
name: 'userCollectionID',
|
||||||
|
description: 'ID of the user collection',
|
||||||
|
})
|
||||||
|
userCollectionID: string;
|
||||||
|
|
||||||
|
@Field({
|
||||||
|
name: 'newTitle',
|
||||||
|
description: 'The updated title of the user collection',
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
newTitle: string;
|
||||||
|
|
||||||
|
@Field({
|
||||||
|
name: 'data',
|
||||||
|
description: 'JSON string representing the collection data',
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
data: string;
|
||||||
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import {
|
|||||||
MoveUserCollectionArgs,
|
MoveUserCollectionArgs,
|
||||||
RenameUserCollectionsArgs,
|
RenameUserCollectionsArgs,
|
||||||
UpdateUserCollectionArgs,
|
UpdateUserCollectionArgs,
|
||||||
|
UpdateUserCollectionsArgs,
|
||||||
} from './input-type.args';
|
} from './input-type.args';
|
||||||
import { ReqType } from 'src/types/RequestTypes';
|
import { ReqType } from 'src/types/RequestTypes';
|
||||||
import * as E from 'fp-ts/Either';
|
import * as E from 'fp-ts/Either';
|
||||||
@@ -142,7 +143,13 @@ export class UserCollectionResolver {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (E.isLeft(userCollection)) throwErr(userCollection.left);
|
if (E.isLeft(userCollection)) throwErr(userCollection.left);
|
||||||
return userCollection.right;
|
return <UserCollection>{
|
||||||
|
...userCollection.right,
|
||||||
|
userID: userCollection.right.userUid,
|
||||||
|
data: !userCollection.right.data
|
||||||
|
? null
|
||||||
|
: JSON.stringify(userCollection.right.data),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Query(() => UserCollectionExportJSONData, {
|
@Query(() => UserCollectionExportJSONData, {
|
||||||
@@ -191,6 +198,7 @@ export class UserCollectionResolver {
|
|||||||
await this.userCollectionService.createUserCollection(
|
await this.userCollectionService.createUserCollection(
|
||||||
user,
|
user,
|
||||||
args.title,
|
args.title,
|
||||||
|
args.data,
|
||||||
null,
|
null,
|
||||||
ReqType.REST,
|
ReqType.REST,
|
||||||
);
|
);
|
||||||
@@ -212,6 +220,7 @@ export class UserCollectionResolver {
|
|||||||
await this.userCollectionService.createUserCollection(
|
await this.userCollectionService.createUserCollection(
|
||||||
user,
|
user,
|
||||||
args.title,
|
args.title,
|
||||||
|
args.data,
|
||||||
null,
|
null,
|
||||||
ReqType.GQL,
|
ReqType.GQL,
|
||||||
);
|
);
|
||||||
@@ -232,6 +241,7 @@ export class UserCollectionResolver {
|
|||||||
await this.userCollectionService.createUserCollection(
|
await this.userCollectionService.createUserCollection(
|
||||||
user,
|
user,
|
||||||
args.title,
|
args.title,
|
||||||
|
args.data,
|
||||||
args.parentUserCollectionID,
|
args.parentUserCollectionID,
|
||||||
ReqType.GQL,
|
ReqType.GQL,
|
||||||
);
|
);
|
||||||
@@ -252,6 +262,7 @@ export class UserCollectionResolver {
|
|||||||
await this.userCollectionService.createUserCollection(
|
await this.userCollectionService.createUserCollection(
|
||||||
user,
|
user,
|
||||||
args.title,
|
args.title,
|
||||||
|
args.data,
|
||||||
args.parentUserCollectionID,
|
args.parentUserCollectionID,
|
||||||
ReqType.REST,
|
ReqType.REST,
|
||||||
);
|
);
|
||||||
@@ -359,6 +370,26 @@ export class UserCollectionResolver {
|
|||||||
return importedCollection.right;
|
return importedCollection.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Mutation(() => UserCollection, {
|
||||||
|
description: 'Update a UserCollection',
|
||||||
|
})
|
||||||
|
@UseGuards(GqlAuthGuard)
|
||||||
|
async updateUserCollection(
|
||||||
|
@GqlUser() user: AuthUser,
|
||||||
|
@Args() args: UpdateUserCollectionsArgs,
|
||||||
|
) {
|
||||||
|
const updatedUserCollection =
|
||||||
|
await this.userCollectionService.updateUserCollection(
|
||||||
|
args.newTitle,
|
||||||
|
args.data,
|
||||||
|
args.userCollectionID,
|
||||||
|
user.uid,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (E.isLeft(updatedUserCollection)) throwErr(updatedUserCollection.left);
|
||||||
|
return updatedUserCollection.right;
|
||||||
|
}
|
||||||
|
|
||||||
// Subscriptions
|
// Subscriptions
|
||||||
@Subscription(() => UserCollection, {
|
@Subscription(() => UserCollection, {
|
||||||
description: 'Listen for User Collection Creation',
|
description: 'Listen for User Collection Creation',
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
USER_NOT_FOUND,
|
USER_NOT_FOUND,
|
||||||
USER_NOT_OWNER,
|
USER_NOT_OWNER,
|
||||||
USER_COLL_INVALID_JSON,
|
USER_COLL_INVALID_JSON,
|
||||||
|
USER_COLL_DATA_INVALID,
|
||||||
} from 'src/errors';
|
} from 'src/errors';
|
||||||
import { PrismaService } from 'src/prisma/prisma.service';
|
import { PrismaService } from 'src/prisma/prisma.service';
|
||||||
import { AuthUser } from 'src/types/AuthUser';
|
import { AuthUser } from 'src/types/AuthUser';
|
||||||
@@ -43,8 +44,12 @@ export class UserCollectionService {
|
|||||||
*/
|
*/
|
||||||
private cast(collection: UserCollection) {
|
private cast(collection: UserCollection) {
|
||||||
return <UserCollectionModel>{
|
return <UserCollectionModel>{
|
||||||
...collection,
|
id: collection.id,
|
||||||
|
title: collection.title,
|
||||||
|
type: collection.type,
|
||||||
|
parentID: collection.parentID,
|
||||||
userID: collection.userUid,
|
userID: collection.userUid,
|
||||||
|
data: !collection.data ? null : JSON.stringify(collection.data),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +151,7 @@ export class UserCollectionService {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return parent;
|
return !parent ? null : this.cast(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -164,7 +169,7 @@ export class UserCollectionService {
|
|||||||
take: number,
|
take: number,
|
||||||
type: ReqType,
|
type: ReqType,
|
||||||
) {
|
) {
|
||||||
return this.prisma.userCollection.findMany({
|
const res = await this.prisma.userCollection.findMany({
|
||||||
where: {
|
where: {
|
||||||
parentID: collectionID,
|
parentID: collectionID,
|
||||||
type: type,
|
type: type,
|
||||||
@@ -176,6 +181,12 @@ export class UserCollectionService {
|
|||||||
skip: cursor ? 1 : 0,
|
skip: cursor ? 1 : 0,
|
||||||
cursor: cursor ? { id: cursor } : undefined,
|
cursor: cursor ? { id: cursor } : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const childCollections = res.map((childCollection) =>
|
||||||
|
this.cast(childCollection),
|
||||||
|
);
|
||||||
|
|
||||||
|
return childCollections;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -211,12 +222,20 @@ export class UserCollectionService {
|
|||||||
async createUserCollection(
|
async createUserCollection(
|
||||||
user: AuthUser,
|
user: AuthUser,
|
||||||
title: string,
|
title: string,
|
||||||
|
data: string | null = null,
|
||||||
parentUserCollectionID: string | null,
|
parentUserCollectionID: string | null,
|
||||||
type: ReqType,
|
type: ReqType,
|
||||||
) {
|
) {
|
||||||
const isTitleValid = isValidLength(title, this.TITLE_LENGTH);
|
const isTitleValid = isValidLength(title, this.TITLE_LENGTH);
|
||||||
if (!isTitleValid) return E.left(USER_COLL_SHORT_TITLE);
|
if (!isTitleValid) return E.left(USER_COLL_SHORT_TITLE);
|
||||||
|
|
||||||
|
if (data === '') return E.left(USER_COLL_DATA_INVALID);
|
||||||
|
if (data) {
|
||||||
|
const jsonReq = stringToJson(data);
|
||||||
|
if (E.isLeft(jsonReq)) return E.left(USER_COLL_DATA_INVALID);
|
||||||
|
data = jsonReq.right;
|
||||||
|
}
|
||||||
|
|
||||||
// If creating a child collection
|
// If creating a child collection
|
||||||
if (parentUserCollectionID !== null) {
|
if (parentUserCollectionID !== null) {
|
||||||
const parentCollection = await this.getUserCollection(
|
const parentCollection = await this.getUserCollection(
|
||||||
@@ -251,15 +270,19 @@ export class UserCollectionService {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
parent: isParent,
|
parent: isParent,
|
||||||
|
data: data ?? undefined,
|
||||||
orderIndex: !parentUserCollectionID
|
orderIndex: !parentUserCollectionID
|
||||||
? (await this.getRootCollectionsCount(user.uid)) + 1
|
? (await this.getRootCollectionsCount(user.uid)) + 1
|
||||||
: (await this.getChildCollectionsCount(parentUserCollectionID)) + 1,
|
: (await this.getChildCollectionsCount(parentUserCollectionID)) + 1,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.pubsub.publish(`user_coll/${user.uid}/created`, userCollection);
|
await this.pubsub.publish(
|
||||||
|
`user_coll/${user.uid}/created`,
|
||||||
|
this.cast(userCollection),
|
||||||
|
);
|
||||||
|
|
||||||
return E.right(userCollection);
|
return E.right(this.cast(userCollection));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -276,7 +299,7 @@ export class UserCollectionService {
|
|||||||
take: number,
|
take: number,
|
||||||
type: ReqType,
|
type: ReqType,
|
||||||
) {
|
) {
|
||||||
return this.prisma.userCollection.findMany({
|
const res = await this.prisma.userCollection.findMany({
|
||||||
where: {
|
where: {
|
||||||
userUid: user.uid,
|
userUid: user.uid,
|
||||||
parentID: null,
|
parentID: null,
|
||||||
@@ -289,6 +312,12 @@ export class UserCollectionService {
|
|||||||
skip: cursor ? 1 : 0,
|
skip: cursor ? 1 : 0,
|
||||||
cursor: cursor ? { id: cursor } : undefined,
|
cursor: cursor ? { id: cursor } : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const userCollections = res.map((childCollection) =>
|
||||||
|
this.cast(childCollection),
|
||||||
|
);
|
||||||
|
|
||||||
|
return userCollections;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -307,7 +336,7 @@ export class UserCollectionService {
|
|||||||
take: number,
|
take: number,
|
||||||
type: ReqType,
|
type: ReqType,
|
||||||
) {
|
) {
|
||||||
return this.prisma.userCollection.findMany({
|
const res = await this.prisma.userCollection.findMany({
|
||||||
where: {
|
where: {
|
||||||
userUid: user.uid,
|
userUid: user.uid,
|
||||||
parentID: userCollectionID,
|
parentID: userCollectionID,
|
||||||
@@ -317,9 +346,16 @@ export class UserCollectionService {
|
|||||||
skip: cursor ? 1 : 0,
|
skip: cursor ? 1 : 0,
|
||||||
cursor: cursor ? { id: cursor } : undefined,
|
cursor: cursor ? { id: cursor } : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const childCollections = res.map((childCollection) =>
|
||||||
|
this.cast(childCollection),
|
||||||
|
);
|
||||||
|
|
||||||
|
return childCollections;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @deprecated Use updateUserCollection method instead
|
||||||
* Update the title of a UserCollection
|
* Update the title of a UserCollection
|
||||||
*
|
*
|
||||||
* @param newTitle The new title of collection
|
* @param newTitle The new title of collection
|
||||||
@@ -351,10 +387,10 @@ export class UserCollectionService {
|
|||||||
|
|
||||||
this.pubsub.publish(
|
this.pubsub.publish(
|
||||||
`user_coll/${updatedUserCollection.userUid}/updated`,
|
`user_coll/${updatedUserCollection.userUid}/updated`,
|
||||||
updatedUserCollection,
|
this.cast(updatedUserCollection),
|
||||||
);
|
);
|
||||||
|
|
||||||
return E.right(updatedUserCollection);
|
return E.right(this.cast(updatedUserCollection));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return E.left(USER_COLL_NOT_FOUND);
|
return E.left(USER_COLL_NOT_FOUND);
|
||||||
}
|
}
|
||||||
@@ -591,10 +627,10 @@ export class UserCollectionService {
|
|||||||
|
|
||||||
this.pubsub.publish(
|
this.pubsub.publish(
|
||||||
`user_coll/${collection.right.userUid}/moved`,
|
`user_coll/${collection.right.userUid}/moved`,
|
||||||
updatedCollection.right,
|
this.cast(updatedCollection.right),
|
||||||
);
|
);
|
||||||
|
|
||||||
return E.right(updatedCollection.right);
|
return E.right(this.cast(updatedCollection.right));
|
||||||
}
|
}
|
||||||
|
|
||||||
// destCollectionID != null i.e move into another collection
|
// destCollectionID != null i.e move into another collection
|
||||||
@@ -642,10 +678,10 @@ export class UserCollectionService {
|
|||||||
|
|
||||||
this.pubsub.publish(
|
this.pubsub.publish(
|
||||||
`user_coll/${collection.right.userUid}/moved`,
|
`user_coll/${collection.right.userUid}/moved`,
|
||||||
updatedCollection.right,
|
this.cast(updatedCollection.right),
|
||||||
);
|
);
|
||||||
|
|
||||||
return E.right(updatedCollection.right);
|
return E.right(this.cast(updatedCollection.right));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -846,6 +882,7 @@ export class UserCollectionService {
|
|||||||
...(x.request as Record<string, unknown>), // type casting x.request of type Prisma.JSONValue to an object to enable spread
|
...(x.request as Record<string, unknown>), // type casting x.request of type Prisma.JSONValue to an object to enable spread
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
|
data: JSON.stringify(collection.right.data),
|
||||||
};
|
};
|
||||||
|
|
||||||
return E.right(result);
|
return E.right(result);
|
||||||
@@ -918,6 +955,7 @@ export class UserCollectionService {
|
|||||||
...(x.request as Record<string, unknown>), // type casting x.request of type Prisma.JSONValue to an object to enable spread
|
...(x.request as Record<string, unknown>), // type casting x.request of type Prisma.JSONValue to an object to enable spread
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
|
data: JSON.stringify(parentCollection.right.data),
|
||||||
}),
|
}),
|
||||||
collectionType: parentCollection.right.type,
|
collectionType: parentCollection.right.type,
|
||||||
});
|
});
|
||||||
@@ -971,6 +1009,7 @@ export class UserCollectionService {
|
|||||||
this.generatePrismaQueryObj(f, userID, index + 1, reqType),
|
this.generatePrismaQueryObj(f, userID, index + 1, reqType),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
data: folder.data ?? undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1040,10 +1079,63 @@ export class UserCollectionService {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
userCollections.forEach((x) =>
|
userCollections.forEach((collection) =>
|
||||||
this.pubsub.publish(`user_coll/${userID}/created`, x),
|
this.pubsub.publish(`user_coll/${userID}/created`, this.cast(collection)),
|
||||||
);
|
);
|
||||||
|
|
||||||
return E.right(true);
|
return E.right(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a UserCollection
|
||||||
|
*
|
||||||
|
* @param newTitle The new title of collection
|
||||||
|
* @param userCollectionID The Collection Id
|
||||||
|
* @param userID The User UID
|
||||||
|
* @returns An Either of the updated UserCollection
|
||||||
|
*/
|
||||||
|
async updateUserCollection(
|
||||||
|
newTitle: string = null,
|
||||||
|
collectionData: string | null = null,
|
||||||
|
userCollectionID: string,
|
||||||
|
userID: string,
|
||||||
|
) {
|
||||||
|
if (collectionData === '') return E.left(USER_COLL_DATA_INVALID);
|
||||||
|
|
||||||
|
if (collectionData) {
|
||||||
|
const jsonReq = stringToJson(collectionData);
|
||||||
|
if (E.isLeft(jsonReq)) return E.left(USER_COLL_DATA_INVALID);
|
||||||
|
collectionData = jsonReq.right;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newTitle != null) {
|
||||||
|
const isTitleValid = isValidLength(newTitle, this.TITLE_LENGTH);
|
||||||
|
if (!isTitleValid) return E.left(USER_COLL_SHORT_TITLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check to see is the collection belongs to the user
|
||||||
|
const isOwner = await this.isOwnerCheck(userCollectionID, userID);
|
||||||
|
if (O.isNone(isOwner)) return E.left(USER_NOT_OWNER);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const updatedUserCollection = await this.prisma.userCollection.update({
|
||||||
|
where: {
|
||||||
|
id: userCollectionID,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
data: collectionData ?? undefined,
|
||||||
|
title: newTitle ?? undefined,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
this.pubsub.publish(
|
||||||
|
`user_coll/${updatedUserCollection.userUid}/updated`,
|
||||||
|
this.cast(updatedUserCollection),
|
||||||
|
);
|
||||||
|
|
||||||
|
return E.right(this.cast(updatedUserCollection));
|
||||||
|
} catch (error) {
|
||||||
|
return E.left(USER_COLL_NOT_FOUND);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,12 @@ export class UserCollection {
|
|||||||
})
|
})
|
||||||
title: string;
|
title: string;
|
||||||
|
|
||||||
|
@Field({
|
||||||
|
description: 'JSON string representing the collection data',
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
data: string;
|
||||||
|
|
||||||
@Field(() => ReqType, {
|
@Field(() => ReqType, {
|
||||||
description: 'Type of the user collection',
|
description: 'Type of the user collection',
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -142,13 +142,15 @@ describe('UserHistoryService', () => {
|
|||||||
});
|
});
|
||||||
describe('createUserHistory', () => {
|
describe('createUserHistory', () => {
|
||||||
test('Should resolve right and create a REST request to users history and return a `UserHistory` object', async () => {
|
test('Should resolve right and create a REST request to users history and return a `UserHistory` object', async () => {
|
||||||
|
const executedOn = new Date();
|
||||||
|
|
||||||
mockPrisma.userHistory.create.mockResolvedValueOnce({
|
mockPrisma.userHistory.create.mockResolvedValueOnce({
|
||||||
userUid: 'abc',
|
userUid: 'abc',
|
||||||
id: '1',
|
id: '1',
|
||||||
request: [{}],
|
request: [{}],
|
||||||
responseMetadata: [{}],
|
responseMetadata: [{}],
|
||||||
reqType: ReqType.REST,
|
reqType: ReqType.REST,
|
||||||
executedOn: new Date(),
|
executedOn,
|
||||||
isStarred: false,
|
isStarred: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -158,7 +160,7 @@ describe('UserHistoryService', () => {
|
|||||||
request: JSON.stringify([{}]),
|
request: JSON.stringify([{}]),
|
||||||
responseMetadata: JSON.stringify([{}]),
|
responseMetadata: JSON.stringify([{}]),
|
||||||
reqType: ReqType.REST,
|
reqType: ReqType.REST,
|
||||||
executedOn: new Date(),
|
executedOn,
|
||||||
isStarred: false,
|
isStarred: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -172,13 +174,15 @@ describe('UserHistoryService', () => {
|
|||||||
).toEqualRight(userHistory);
|
).toEqualRight(userHistory);
|
||||||
});
|
});
|
||||||
test('Should resolve right and create a GQL request to users history and return a `UserHistory` object', async () => {
|
test('Should resolve right and create a GQL request to users history and return a `UserHistory` object', async () => {
|
||||||
|
const executedOn = new Date();
|
||||||
|
|
||||||
mockPrisma.userHistory.create.mockResolvedValueOnce({
|
mockPrisma.userHistory.create.mockResolvedValueOnce({
|
||||||
userUid: 'abc',
|
userUid: 'abc',
|
||||||
id: '1',
|
id: '1',
|
||||||
request: [{}],
|
request: [{}],
|
||||||
responseMetadata: [{}],
|
responseMetadata: [{}],
|
||||||
reqType: ReqType.GQL,
|
reqType: ReqType.GQL,
|
||||||
executedOn: new Date(),
|
executedOn,
|
||||||
isStarred: false,
|
isStarred: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -188,7 +192,7 @@ describe('UserHistoryService', () => {
|
|||||||
request: JSON.stringify([{}]),
|
request: JSON.stringify([{}]),
|
||||||
responseMetadata: JSON.stringify([{}]),
|
responseMetadata: JSON.stringify([{}]),
|
||||||
reqType: ReqType.GQL,
|
reqType: ReqType.GQL,
|
||||||
executedOn: new Date(),
|
executedOn,
|
||||||
isStarred: false,
|
isStarred: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -212,13 +216,15 @@ describe('UserHistoryService', () => {
|
|||||||
).toEqualLeft(USER_HISTORY_INVALID_REQ_TYPE);
|
).toEqualLeft(USER_HISTORY_INVALID_REQ_TYPE);
|
||||||
});
|
});
|
||||||
test('Should create a GQL request to users history and publish a created subscription', async () => {
|
test('Should create a GQL request to users history and publish a created subscription', async () => {
|
||||||
|
const executedOn = new Date();
|
||||||
|
|
||||||
mockPrisma.userHistory.create.mockResolvedValueOnce({
|
mockPrisma.userHistory.create.mockResolvedValueOnce({
|
||||||
userUid: 'abc',
|
userUid: 'abc',
|
||||||
id: '1',
|
id: '1',
|
||||||
request: [{}],
|
request: [{}],
|
||||||
responseMetadata: [{}],
|
responseMetadata: [{}],
|
||||||
reqType: ReqType.GQL,
|
reqType: ReqType.GQL,
|
||||||
executedOn: new Date(),
|
executedOn,
|
||||||
isStarred: false,
|
isStarred: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -228,7 +234,7 @@ describe('UserHistoryService', () => {
|
|||||||
request: JSON.stringify([{}]),
|
request: JSON.stringify([{}]),
|
||||||
responseMetadata: JSON.stringify([{}]),
|
responseMetadata: JSON.stringify([{}]),
|
||||||
reqType: ReqType.GQL,
|
reqType: ReqType.GQL,
|
||||||
executedOn: new Date(),
|
executedOn,
|
||||||
isStarred: false,
|
isStarred: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -245,13 +251,15 @@ describe('UserHistoryService', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
test('Should create a REST request to users history and publish a created subscription', async () => {
|
test('Should create a REST request to users history and publish a created subscription', async () => {
|
||||||
|
const executedOn = new Date();
|
||||||
|
|
||||||
mockPrisma.userHistory.create.mockResolvedValueOnce({
|
mockPrisma.userHistory.create.mockResolvedValueOnce({
|
||||||
userUid: 'abc',
|
userUid: 'abc',
|
||||||
id: '1',
|
id: '1',
|
||||||
request: [{}],
|
request: [{}],
|
||||||
responseMetadata: [{}],
|
responseMetadata: [{}],
|
||||||
reqType: ReqType.REST,
|
reqType: ReqType.REST,
|
||||||
executedOn: new Date(),
|
executedOn,
|
||||||
isStarred: false,
|
isStarred: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -261,7 +269,7 @@ describe('UserHistoryService', () => {
|
|||||||
request: JSON.stringify([{}]),
|
request: JSON.stringify([{}]),
|
||||||
responseMetadata: JSON.stringify([{}]),
|
responseMetadata: JSON.stringify([{}]),
|
||||||
reqType: ReqType.REST,
|
reqType: ReqType.REST,
|
||||||
executedOn: new Date(),
|
executedOn,
|
||||||
isStarred: false,
|
isStarred: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -323,13 +331,15 @@ describe('UserHistoryService', () => {
|
|||||||
).toEqualLeft(USER_HISTORY_NOT_FOUND);
|
).toEqualLeft(USER_HISTORY_NOT_FOUND);
|
||||||
});
|
});
|
||||||
test('Should star/unstar a request in the history and publish a updated subscription', async () => {
|
test('Should star/unstar a request in the history and publish a updated subscription', async () => {
|
||||||
|
const executedOn = new Date();
|
||||||
|
|
||||||
mockPrisma.userHistory.findFirst.mockResolvedValueOnce({
|
mockPrisma.userHistory.findFirst.mockResolvedValueOnce({
|
||||||
userUid: 'abc',
|
userUid: 'abc',
|
||||||
id: '1',
|
id: '1',
|
||||||
request: [{}],
|
request: [{}],
|
||||||
responseMetadata: [{}],
|
responseMetadata: [{}],
|
||||||
reqType: ReqType.REST,
|
reqType: ReqType.REST,
|
||||||
executedOn: new Date(),
|
executedOn,
|
||||||
isStarred: false,
|
isStarred: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -339,7 +349,7 @@ describe('UserHistoryService', () => {
|
|||||||
request: [{}],
|
request: [{}],
|
||||||
responseMetadata: [{}],
|
responseMetadata: [{}],
|
||||||
reqType: ReqType.REST,
|
reqType: ReqType.REST,
|
||||||
executedOn: new Date(),
|
executedOn,
|
||||||
isStarred: true,
|
isStarred: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -349,7 +359,7 @@ describe('UserHistoryService', () => {
|
|||||||
request: JSON.stringify([{}]),
|
request: JSON.stringify([{}]),
|
||||||
responseMetadata: JSON.stringify([{}]),
|
responseMetadata: JSON.stringify([{}]),
|
||||||
reqType: ReqType.REST,
|
reqType: ReqType.REST,
|
||||||
executedOn: new Date(),
|
executedOn,
|
||||||
isStarred: true,
|
isStarred: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ module.exports = {
|
|||||||
// The glob patterns Jest uses to detect test files
|
// The glob patterns Jest uses to detect test files
|
||||||
testMatch: [
|
testMatch: [
|
||||||
// "**/__tests__/**/*.[jt]s?(x)",
|
// "**/__tests__/**/*.[jt]s?(x)",
|
||||||
"**/src/__tests__/**/*.*.ts",
|
"**/src/__tests__/commands/**/*.*.ts",
|
||||||
],
|
],
|
||||||
|
|
||||||
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hoppscotch/cli",
|
"name": "@hoppscotch/cli",
|
||||||
"version": "0.3.2",
|
"version": "0.4.0",
|
||||||
"description": "A CLI to run Hoppscotch test scripts in CI environments.",
|
"description": "A CLI to run Hoppscotch test scripts in CI environments.",
|
||||||
"homepage": "https://hoppscotch.io",
|
"homepage": "https://hoppscotch.io",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@@ -10,14 +10,18 @@
|
|||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "pnpm exec tsup",
|
"build": "pnpm exec tsup",
|
||||||
"dev": "pnpm exec tsup --watch",
|
"dev": "pnpm exec tsup --watch",
|
||||||
"debugger": "node debugger.js 9999",
|
"debugger": "node debugger.js 9999",
|
||||||
"prepublish": "pnpm exec tsup",
|
"prepublish": "pnpm exec tsup",
|
||||||
"prettier-format": "prettier --config .prettierrc 'src/**/*.ts' --write",
|
"prettier-format": "prettier --config .prettierrc 'src/**/*.ts' --write",
|
||||||
|
"test": "pnpm run build && jest && rm -rf dist",
|
||||||
"do-typecheck": "pnpm exec tsc --noEmit",
|
"do-typecheck": "pnpm exec tsc --noEmit",
|
||||||
"test": "pnpm run build && jest && rm -rf dist"
|
"do-test": "pnpm test"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"cli",
|
"cli",
|
||||||
@@ -38,26 +42,24 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@hoppscotch/data": "workspace:^",
|
"@hoppscotch/data": "workspace:^",
|
||||||
"@hoppscotch/js-sandbox": "workspace:^",
|
"@hoppscotch/js-sandbox": "workspace:^",
|
||||||
"@relmify/jest-fp-ts": "^2.0.2",
|
"@relmify/jest-fp-ts": "^2.1.1",
|
||||||
"@swc/core": "^1.2.181",
|
"@swc/core": "^1.3.92",
|
||||||
"@types/axios": "^0.14.0",
|
"@types/jest": "^29.5.5",
|
||||||
"@types/chalk": "^2.2.0",
|
"@types/lodash": "^4.14.199",
|
||||||
"@types/commander": "^2.12.2",
|
"@types/qs": "^6.9.8",
|
||||||
"@types/jest": "^27.4.1",
|
|
||||||
"@types/lodash": "^4.14.181",
|
|
||||||
"@types/qs": "^6.9.7",
|
|
||||||
"axios": "^0.21.4",
|
"axios": "^0.21.4",
|
||||||
"chalk": "^4.1.1",
|
"chalk": "^4.1.2",
|
||||||
"commander": "^8.0.0",
|
"commander": "^11.0.0",
|
||||||
"esm": "^3.2.25",
|
"esm": "^3.2.25",
|
||||||
"fp-ts": "^2.12.1",
|
"fp-ts": "^2.16.1",
|
||||||
"io-ts": "^2.2.16",
|
"io-ts": "^2.2.20",
|
||||||
"jest": "^27.5.1",
|
"jest": "^29.7.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"prettier": "^2.8.4",
|
"prettier": "^3.0.3",
|
||||||
"qs": "^6.10.3",
|
"qs": "^6.11.2",
|
||||||
"ts-jest": "^27.1.4",
|
"ts-jest": "^29.1.1",
|
||||||
"tsup": "^5.12.7",
|
"tsup": "^7.2.0",
|
||||||
"typescript": "^4.6.4"
|
"typescript": "^5.2.2",
|
||||||
|
"zod": "^3.22.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ describe("Test 'hopp test <file>' command:", () => {
|
|||||||
|
|
||||||
expect(out).toBe<HoppErrorCode>("UNKNOWN_ERROR");
|
expect(out).toBe<HoppErrorCode>("UNKNOWN_ERROR");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Malformed collection file.", async () => {
|
test("Malformed collection file.", async () => {
|
||||||
const cmd = `node ./bin/hopp test ${getTestJsonFilePath(
|
const cmd = `node ./bin/hopp test ${getTestJsonFilePath(
|
||||||
"malformed-collection2.json"
|
"malformed-collection2.json"
|
||||||
@@ -106,7 +106,7 @@ describe("Test 'hopp test <file> --env <file>' command:", () => {
|
|||||||
const TESTS_PATH = getTestJsonFilePath("env-flag-tests.json");
|
const TESTS_PATH = getTestJsonFilePath("env-flag-tests.json");
|
||||||
const ENV_PATH = getTestJsonFilePath("env-flag-envs.json");
|
const ENV_PATH = getTestJsonFilePath("env-flag-envs.json");
|
||||||
const cmd = `node ./bin/hopp test ${TESTS_PATH} --env ${ENV_PATH}`;
|
const cmd = `node ./bin/hopp test ${TESTS_PATH} --env ${ENV_PATH}`;
|
||||||
const { error } = await execAsync(cmd);
|
const { error, stdout } = await execAsync(cmd);
|
||||||
|
|
||||||
expect(error).toBeNull();
|
expect(error).toBeNull();
|
||||||
});
|
});
|
||||||
@@ -129,7 +129,6 @@ describe("Test 'hopp test <file> --delay <delay_in_ms>' command:", () => {
|
|||||||
const cmd = `${VALID_TEST_CMD} --delay 'NaN'`;
|
const cmd = `${VALID_TEST_CMD} --delay 'NaN'`;
|
||||||
const { stderr } = await execAsync(cmd);
|
const { stderr } = await execAsync(cmd);
|
||||||
const out = getErrorCode(stderr);
|
const out = getErrorCode(stderr);
|
||||||
console.log("invalid value thing", out)
|
|
||||||
expect(out).toBe<HoppErrorCode>("INVALID_ARGUMENT");
|
expect(out).toBe<HoppErrorCode>("INVALID_ARGUMENT");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"URL": "https://echo.hoppscotch.io",
|
"URL": "https://echo.hoppscotch.io",
|
||||||
"HOST": "echo.hoppscotch.io",
|
"HOST": "echo.hoppscotch.io",
|
||||||
"X-COUNTRY": "IN",
|
|
||||||
"BODY_VALUE": "body_value",
|
"BODY_VALUE": "body_value",
|
||||||
"BODY_KEY": "body_key"
|
"BODY_KEY": "body_key"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
"method": "POST",
|
"method": "POST",
|
||||||
"auth": { "authType": "none", "authActive": true },
|
"auth": { "authType": "none", "authActive": true },
|
||||||
"preRequestScript": "",
|
"preRequestScript": "",
|
||||||
"testScript": "const HOST = pw.env.get(\"HOST\");\nconst UNSET_ENV = pw.env.get(\"UNSET_ENV\");\nconst EXPECTED_URL = \"https://echo.hoppscotch.io\";\nconst URL = pw.env.get(\"URL\");\nconst X_COUNTRY = pw.env.get(\"X-COUNTRY\");\nconst BODY_VALUE = pw.env.get(\"BODY_VALUE\");\n\n// Check JSON response property\npw.test(\"Check headers properties.\", ()=> {\n pw.expect(pw.response.body.headers.host).toBe(HOST);\n\t pw.expect(pw.response.body.headers[\"x-country\"]).toBe(X_COUNTRY); \n});\n\npw.test(\"Check data properties.\", () => {\n\tconst DATA = pw.response.body.data;\n \n pw.expect(DATA).toBeType(\"string\");\n pw.expect(JSON.parse(DATA).body_key).toBe(BODY_VALUE);\n});\n\npw.test(\"Check request URL.\", () => {\n pw.expect(URL).toBe(EXPECTED_URL);\n})\n\npw.test(\"Check unset ENV.\", () => {\n pw.expect(UNSET_ENV).toBeType(\"undefined\");\n})",
|
"testScript": "const HOST = pw.env.get(\"HOST\");\nconst UNSET_ENV = pw.env.get(\"UNSET_ENV\");\nconst EXPECTED_URL = \"https://echo.hoppscotch.io\";\nconst URL = pw.env.get(\"URL\");\nconst BODY_VALUE = pw.env.get(\"BODY_VALUE\");\n\n// Check JSON response property\npw.test(\"Check headers properties.\", ()=> {\n pw.expect(pw.response.body.headers.host).toBe(HOST);\n});\n\npw.test(\"Check data properties.\", () => {\n\tconst DATA = pw.response.body.data;\n \n pw.expect(DATA).toBeType(\"string\");\n pw.expect(JSON.parse(DATA).body_key).toBe(BODY_VALUE);\n});\n\npw.test(\"Check request URL.\", () => {\n pw.expect(URL).toBe(EXPECTED_URL);\n})\n\npw.test(\"Check unset ENV.\", () => {\n pw.expect(UNSET_ENV).toBeType(\"undefined\");\n})",
|
||||||
"body": {
|
"body": {
|
||||||
"contentType": "application/json",
|
"contentType": "application/json",
|
||||||
"body": "{\n \"<<BODY_KEY>>\":\"<<BODY_VALUE>>\"\n}"
|
"body": "{\n \"<<BODY_KEY>>\":\"<<BODY_VALUE>>\"\n}"
|
||||||
|
|||||||
@@ -48,6 +48,11 @@ export const handleError = <T extends HoppErrorCode>(error: HoppError<T>) => {
|
|||||||
ERROR_MSG = `Unavailable command: ${error.command}`;
|
ERROR_MSG = `Unavailable command: ${error.command}`;
|
||||||
break;
|
break;
|
||||||
case "MALFORMED_ENV_FILE":
|
case "MALFORMED_ENV_FILE":
|
||||||
|
ERROR_MSG = `The environment file is not of the correct format.`;
|
||||||
|
break;
|
||||||
|
case "BULK_ENV_FILE":
|
||||||
|
ERROR_MSG = `CLI doesn't support bulk environments export.`;
|
||||||
|
break;
|
||||||
case "MALFORMED_COLLECTION":
|
case "MALFORMED_COLLECTION":
|
||||||
ERROR_MSG = `${error.path}\n${parseErrorData(error.data)}`;
|
ERROR_MSG = `${error.path}\n${parseErrorData(error.data)}`;
|
||||||
break;
|
break;
|
||||||
@@ -82,4 +87,4 @@ export const handleError = <T extends HoppErrorCode>(error: HoppError<T>) => {
|
|||||||
if (!S.isEmpty(ERROR_MSG)) {
|
if (!S.isEmpty(ERROR_MSG)) {
|
||||||
console.error(ERROR_CODE, ERROR_MSG);
|
console.error(ERROR_CODE, ERROR_MSG);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,27 +1,45 @@
|
|||||||
import { error } from "../../types/errors";
|
import { error } from "../../types/errors";
|
||||||
import { HoppEnvs, HoppEnvPair } from "../../types/request";
|
import {
|
||||||
|
HoppEnvs,
|
||||||
|
HoppEnvPair,
|
||||||
|
HoppEnvKeyPairObject,
|
||||||
|
HoppEnvExportObject,
|
||||||
|
HoppBulkEnvExportObject,
|
||||||
|
} from "../../types/request";
|
||||||
import { readJsonFile } from "../../utils/mutators";
|
import { readJsonFile } from "../../utils/mutators";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses env json file for given path and validates the parsed env json object.
|
* Parses env json file for given path and validates the parsed env json object.
|
||||||
* @param path Path of env.json file to be parsed.
|
* @param path Path of env.json file to be parsed.
|
||||||
* @returns For successful parsing we get HoppEnvs object.
|
* @returns For successful parsing we get HoppEnvs object.
|
||||||
*/
|
*/
|
||||||
export async function parseEnvsData(path: string) {
|
export async function parseEnvsData(path: string) {
|
||||||
const contents = await readJsonFile(path)
|
const contents = await readJsonFile(path);
|
||||||
|
const envPairs: Array<HoppEnvPair> = [];
|
||||||
|
const HoppEnvKeyPairResult = HoppEnvKeyPairObject.safeParse(contents);
|
||||||
|
const HoppEnvExportObjectResult = HoppEnvExportObject.safeParse(contents);
|
||||||
|
const HoppBulkEnvExportObjectResult =
|
||||||
|
HoppBulkEnvExportObject.safeParse(contents);
|
||||||
|
|
||||||
if(!(contents && typeof contents === "object" && !Array.isArray(contents))) {
|
// CLI doesnt support bulk environments export.
|
||||||
throw error({ code: "MALFORMED_ENV_FILE", path, data: null })
|
// Hence we check for this case and throw an error if it matches the format.
|
||||||
|
if (HoppBulkEnvExportObjectResult.success) {
|
||||||
|
throw error({ code: "BULK_ENV_FILE", path, data: error });
|
||||||
}
|
}
|
||||||
|
|
||||||
const envPairs: Array<HoppEnvPair> = []
|
// Checks if the environment file is of the correct format.
|
||||||
|
// If it doesnt match either of them, we throw an error.
|
||||||
|
if (!(HoppEnvKeyPairResult.success || HoppEnvExportObjectResult.success)) {
|
||||||
|
throw error({ code: "MALFORMED_ENV_FILE", path, data: error });
|
||||||
|
}
|
||||||
|
|
||||||
for( const [key,value] of Object.entries(contents)) {
|
if (HoppEnvKeyPairResult.success) {
|
||||||
if(typeof value !== "string") {
|
for (const [key, value] of Object.entries(HoppEnvKeyPairResult.data)) {
|
||||||
throw error({ code: "MALFORMED_ENV_FILE", path, data: {value: value} })
|
envPairs.push({ key, value });
|
||||||
}
|
}
|
||||||
|
} else if (HoppEnvExportObjectResult.success) {
|
||||||
envPairs.push({key, value})
|
const { key, value } = HoppEnvExportObjectResult.data.variables[0];
|
||||||
|
envPairs.push({ key, value });
|
||||||
}
|
}
|
||||||
return <HoppEnvs>{ global: [], selected: envPairs }
|
|
||||||
|
return <HoppEnvs>{ global: [], selected: envPairs };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ type HoppErrors = {
|
|||||||
REQUEST_ERROR: HoppErrorData;
|
REQUEST_ERROR: HoppErrorData;
|
||||||
INVALID_ARGUMENT: HoppErrorData;
|
INVALID_ARGUMENT: HoppErrorData;
|
||||||
MALFORMED_ENV_FILE: HoppErrorPath & HoppErrorData;
|
MALFORMED_ENV_FILE: HoppErrorPath & HoppErrorData;
|
||||||
|
BULK_ENV_FILE: HoppErrorPath & HoppErrorData;
|
||||||
INVALID_FILE_TYPE: HoppErrorData;
|
INVALID_FILE_TYPE: HoppErrorData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { HoppCollection, HoppRESTRequest } from "@hoppscotch/data";
|
import { HoppCollection, HoppRESTRequest } from "@hoppscotch/data";
|
||||||
import { TestReport } from "../interfaces/response";
|
import { TestReport } from "../interfaces/response";
|
||||||
import { HoppCLIError } from "./errors";
|
import { HoppCLIError } from "./errors";
|
||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
export type FormDataEntry = {
|
export type FormDataEntry = {
|
||||||
key: string;
|
key: string;
|
||||||
@@ -9,6 +10,22 @@ export type FormDataEntry = {
|
|||||||
|
|
||||||
export type HoppEnvPair = { key: string; value: string };
|
export type HoppEnvPair = { key: string; value: string };
|
||||||
|
|
||||||
|
export const HoppEnvKeyPairObject = z.record(z.string(), z.string());
|
||||||
|
|
||||||
|
// Shape of the single environment export object that is exported from the app.
|
||||||
|
export const HoppEnvExportObject = z.object({
|
||||||
|
name: z.string(),
|
||||||
|
variables: z.array(
|
||||||
|
z.object({
|
||||||
|
key: z.string(),
|
||||||
|
value: z.string(),
|
||||||
|
})
|
||||||
|
),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Shape of the bulk environment export object that is exported from the app.
|
||||||
|
export const HoppBulkEnvExportObject = z.array(HoppEnvExportObject);
|
||||||
|
|
||||||
export type HoppEnvs = {
|
export type HoppEnvs = {
|
||||||
global: HoppEnvPair[];
|
global: HoppEnvPair[];
|
||||||
selected: HoppEnvPair[];
|
selected: HoppEnvPair[];
|
||||||
|
|||||||
@@ -6,23 +6,24 @@ import {
|
|||||||
parseTemplateString,
|
parseTemplateString,
|
||||||
parseTemplateStringE,
|
parseTemplateStringE,
|
||||||
} from "@hoppscotch/data";
|
} from "@hoppscotch/data";
|
||||||
import { runPreRequestScript } from "@hoppscotch/js-sandbox";
|
import { runPreRequestScript } from "@hoppscotch/js-sandbox/node";
|
||||||
import { flow, pipe } from "fp-ts/function";
|
|
||||||
import * as TE from "fp-ts/TaskEither";
|
|
||||||
import * as E from "fp-ts/Either";
|
|
||||||
import * as RA from "fp-ts/ReadonlyArray";
|
|
||||||
import * as A from "fp-ts/Array";
|
import * as A from "fp-ts/Array";
|
||||||
|
import * as E from "fp-ts/Either";
|
||||||
import * as O from "fp-ts/Option";
|
import * as O from "fp-ts/Option";
|
||||||
|
import * as RA from "fp-ts/ReadonlyArray";
|
||||||
|
import * as TE from "fp-ts/TaskEither";
|
||||||
|
import { flow, pipe } from "fp-ts/function";
|
||||||
import * as S from "fp-ts/string";
|
import * as S from "fp-ts/string";
|
||||||
import qs from "qs";
|
import qs from "qs";
|
||||||
|
|
||||||
import { EffectiveHoppRESTRequest } from "../interfaces/request";
|
import { EffectiveHoppRESTRequest } from "../interfaces/request";
|
||||||
import { error, HoppCLIError } from "../types/errors";
|
import { HoppCLIError, error } from "../types/errors";
|
||||||
import { HoppEnvs } from "../types/request";
|
import { HoppEnvs } from "../types/request";
|
||||||
import { isHoppCLIError } from "./checks";
|
|
||||||
import { tupleToRecord, arraySort, arrayFlatMap } from "./functions/array";
|
|
||||||
import { toFormData } from "./mutators";
|
|
||||||
import { getEffectiveFinalMetaData } from "./getters";
|
|
||||||
import { PreRequestMetrics } from "../types/response";
|
import { PreRequestMetrics } from "../types/response";
|
||||||
|
import { isHoppCLIError } from "./checks";
|
||||||
|
import { arrayFlatMap, arraySort, tupleToRecord } from "./functions/array";
|
||||||
|
import { getEffectiveFinalMetaData } from "./getters";
|
||||||
|
import { toFormData } from "./mutators";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs pre-request-script runner over given request which extracts set ENVs and
|
* Runs pre-request-script runner over given request which extracts set ENVs and
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
import { HoppRESTRequest } from "@hoppscotch/data";
|
import { HoppRESTRequest } from "@hoppscotch/data";
|
||||||
import { execTestScript, TestDescriptor } from "@hoppscotch/js-sandbox";
|
import { TestDescriptor } from "@hoppscotch/js-sandbox";
|
||||||
import { hrtime } from "process";
|
import { runTestScript } from "@hoppscotch/js-sandbox/node";
|
||||||
import { flow, pipe } from "fp-ts/function";
|
|
||||||
import * as RA from "fp-ts/ReadonlyArray";
|
|
||||||
import * as A from "fp-ts/Array";
|
import * as A from "fp-ts/Array";
|
||||||
import * as TE from "fp-ts/TaskEither";
|
import * as RA from "fp-ts/ReadonlyArray";
|
||||||
import * as T from "fp-ts/Task";
|
import * as T from "fp-ts/Task";
|
||||||
|
import * as TE from "fp-ts/TaskEither";
|
||||||
|
import { flow, pipe } from "fp-ts/function";
|
||||||
|
import { hrtime } from "process";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
RequestRunnerResponse,
|
RequestRunnerResponse,
|
||||||
TestReport,
|
TestReport,
|
||||||
TestScriptParams,
|
TestScriptParams,
|
||||||
} from "../interfaces/response";
|
} from "../interfaces/response";
|
||||||
import { error, HoppCLIError } from "../types/errors";
|
import { HoppCLIError, error } from "../types/errors";
|
||||||
import { HoppEnvs } from "../types/request";
|
import { HoppEnvs } from "../types/request";
|
||||||
import { ExpectResult, TestMetrics, TestRunnerRes } from "../types/response";
|
import { ExpectResult, TestMetrics, TestRunnerRes } from "../types/response";
|
||||||
import { getDurationInSeconds } from "./getters";
|
import { getDurationInSeconds } from "./getters";
|
||||||
@@ -36,7 +38,7 @@ export const testRunner = (
|
|||||||
pipe(
|
pipe(
|
||||||
TE.of(testScriptData),
|
TE.of(testScriptData),
|
||||||
TE.chain(({ testScript, response, envs }) =>
|
TE.chain(({ testScript, response, envs }) =>
|
||||||
execTestScript(testScript, envs, response)
|
runTestScript(testScript, envs, response)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
name: "localStorage",
|
name: "localStorage",
|
||||||
message:
|
message:
|
||||||
"Do not use 'localStorage' directly. Please use localpersistence.ts functions or stores",
|
"Do not use 'localStorage' directly. Please use the PersistenceService",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
// window.localStorage block
|
// window.localStorage block
|
||||||
@@ -66,8 +66,10 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
selector: "CallExpression[callee.object.property.name='localStorage']",
|
selector: "CallExpression[callee.object.property.name='localStorage']",
|
||||||
message:
|
message:
|
||||||
"Do not use 'localStorage' directly. Please use localpersistence.ts functions or stores",
|
"Do not use 'localStorage' directly. Please use the PersistenceService",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
eqeqeq: 1,
|
||||||
|
"no-else-return": 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ module.exports = {
|
|||||||
singleQuote: false,
|
singleQuote: false,
|
||||||
printWidth: 80,
|
printWidth: 80,
|
||||||
useTabs: false,
|
useTabs: false,
|
||||||
tabWidth: 2
|
tabWidth: 2,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width=".88em" height="1em" viewBox="0 0 21 24" class="iconify iconify--fontisto"><path fill="currentColor" d="M12.731 2.751 17.666 5.6a2.138 2.138 0 1 1 2.07 3.548l-.015.003v5.7a2.14 2.14 0 1 1-2.098 3.502l-.002-.002-4.905 2.832a2.14 2.14 0 1 1-4.079.054l-.004.015-4.941-2.844a2.14 2.14 0 1 1-2.067-3.556l.015-.003V9.15a2.14 2.14 0 1 1 1.58-3.926l-.01-.005c.184.106.342.231.479.376l.001.001 4.938-2.85a2.14 2.14 0 1 1 4.096.021l.004-.015zm-.515.877a.766.766 0 0 1-.057.057l-.001.001 6.461 11.19c.026-.009.056-.016.082-.023V9.146a2.14 2.14 0 0 1-1.555-2.603l-.003.015.019-.072zm-3.015.059-.06-.06-4.946 2.852A2.137 2.137 0 0 1 2.749 9.12l-.015.004-.076.021v5.708l.084.023 6.461-11.19zm2.076.507a2.164 2.164 0 0 1-1.207-.004l.015.004-6.46 11.189c.286.276.496.629.597 1.026l.003.015h12.911c.102-.413.313-.768.599-1.043l.001-.001L11.28 4.194zm.986 16.227 4.917-2.838a1.748 1.748 0 0 1-.038-.142H4.222l-.021.083 4.939 2.852c.39-.403.936-.653 1.54-.653.626 0 1.189.268 1.581.696l.001.002z"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width=".88em" height="1em" viewBox="0 0 21 24"><path fill="currentColor" d="M12.731 2.751 17.666 5.6a2.138 2.138 0 1 1 2.07 3.548l-.015.003v5.7a2.14 2.14 0 1 1-2.098 3.502l-.002-.002-4.905 2.832a2.14 2.14 0 1 1-4.079.054l-.004.015-4.941-2.844a2.14 2.14 0 1 1-2.067-3.556l.015-.003V9.15a2.14 2.14 0 1 1 1.58-3.926l-.01-.005c.184.106.342.231.479.376l.001.001 4.938-2.85a2.14 2.14 0 1 1 4.096.021l.004-.015zm-.515.877a.766.766 0 0 1-.057.057l-.001.001 6.461 11.19c.026-.009.056-.016.082-.023V9.146a2.14 2.14 0 0 1-1.555-2.603l-.003.015.019-.072zm-3.015.059-.06-.06-4.946 2.852A2.137 2.137 0 0 1 2.749 9.12l-.015.004-.076.021v5.708l.084.023 6.461-11.19zm2.076.507a2.164 2.164 0 0 1-1.207-.004l.015.004-6.46 11.189c.286.276.496.629.597 1.026l.003.015h12.911c.102-.413.313-.768.599-1.043l.001-.001L11.28 4.194zm.986 16.227 4.917-2.838a1.748 1.748 0 0 1-.038-.142H4.222l-.021.083 4.939 2.852c.39-.403.936-.653 1.54-.653.626 0 1.189.268 1.581.696l.001.002z"/></svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1017 B |
1
packages/hoppscotch-common/assets/icons/mqtt.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M10.133 1h4.409a.5.5 0 0 1 .5.5v4.422c0 .026-.035.033-.045.01l-.048-.112a9.095 9.095 0 0 0-4.825-4.776c-.023-.01-.016-.044.01-.044Zm-8.588.275h-.5v1h.5c7.027 0 12.229 5.199 12.229 12.226v.5h1v-.5c0-7.58-5.65-13.226-13.229-13.226Zm.034 4.22h-.5v1h.5c2.361 0 4.348.837 5.744 2.238 1.395 1.401 2.227 3.395 2.227 5.758v.5h1v-.5c0-2.604-.921-4.859-2.52-6.463-1.596-1.605-3.845-2.532-6.45-2.532Zm-.528 8.996v-4.423c0-.041.033-.074.074-.074a4.923 4.923 0 0 1 4.923 4.922.074.074 0 0 1-.074.074H1.551a.5.5 0 0 1-.5-.5Z" clip-rule="evenodd"/></svg>
|
||||||
|
After Width: | Height: | Size: 684 B |
1
packages/hoppscotch-common/assets/icons/socketio.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M9.277 2.084a.5.5 0 0 1 .185.607l-2.269 5.5a.5.5 0 0 1-.462.309H3.5a.5.5 0 0 1-.354-.854l5.5-5.5a.5.5 0 0 1 .631-.062ZM4.707 7.5h1.69l1.186-2.875L4.707 7.5Zm2.016 6.416a.5.5 0 0 1-.185-.607l2.269-5.5a.5.5 0 0 1 .462-.309H12.5a.5.5 0 0 1 .354.854l-5.5 5.5a.5.5 0 0 1-.631.062Zm4.57-5.416h-1.69l-1.186 2.875L11.293 8.5Z" clip-rule="evenodd"/><path fill="currentColor" fill-rule="evenodd" d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0Zm-1 0A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z" clip-rule="evenodd"/></svg>
|
||||||
|
After Width: | Height: | Size: 633 B |
1
packages/hoppscotch-common/assets/icons/websocket.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 16 16"><path fill="currentColor" d="M1 2h4.257a2.5 2.5 0 0 1 1.768.732L9.293 5 5 9.293 3.732 8.025A2.5 2.5 0 0 1 3 6.257V4H2v2.257a3.5 3.5 0 0 0 1.025 2.475L5 10.707l1.25-1.25 2.396 2.397.708-.708L6.957 8.75 8.75 6.957l2.396 2.397.708-.708L9.457 6.25 10.707 5 7.732 2.025A3.5 3.5 0 0 0 5.257 1H1v1ZM10.646 2.354l2.622 2.62A2.5 2.5 0 0 1 14 6.744V12h1V6.743a3.5 3.5 0 0 0-1.025-2.475l-2.621-2.622-.707.708ZM4.268 13.975l-2.622-2.621.708-.708 2.62 2.622A2.5 2.5 0 0 0 6.744 14H15v1H6.743a3.5 3.5 0 0 1-2.475-1.025Z"/></svg>
|
||||||
|
After Width: | Height: | Size: 610 B |
@@ -1,7 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Write hoppscotch-common related custom styles in this file.
|
||||||
|
* If styles are sharable across all package then write into hoppscotch-ui/assets/scss/styles.scss file.
|
||||||
|
*/
|
||||||
|
|
||||||
* {
|
* {
|
||||||
@apply backface-hidden;
|
backface-visibility: hidden;
|
||||||
@apply before:backface-hidden;
|
-moz-backface-visibility: hidden;
|
||||||
@apply after:backface-hidden;
|
-webkit-backface-visibility: hidden;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
backface-visibility: hidden;
|
||||||
|
-moz-backface-visibility: hidden;
|
||||||
|
-webkit-backface-visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
backface-visibility: hidden;
|
||||||
|
-moz-backface-visibility: hidden;
|
||||||
|
-webkit-backface-visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
@apply selection:bg-accentDark;
|
@apply selection:bg-accentDark;
|
||||||
@apply selection:text-accentContrast;
|
@apply selection:text-accentContrast;
|
||||||
@apply overscroll-none;
|
@apply overscroll-none;
|
||||||
@@ -15,13 +33,13 @@
|
|||||||
|
|
||||||
::-webkit-scrollbar-track {
|
::-webkit-scrollbar-track {
|
||||||
@apply bg-transparent;
|
@apply bg-transparent;
|
||||||
@apply border-solid border-l border-dividerLight border-t-0 border-b-0 border-r-0;
|
@apply border-b-0 border-l border-r-0 border-t-0 border-solid border-dividerLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
::-webkit-scrollbar-thumb {
|
::-webkit-scrollbar-thumb {
|
||||||
@apply bg-divider bg-clip-content;
|
@apply bg-divider bg-clip-content;
|
||||||
@apply rounded-full;
|
@apply rounded-full;
|
||||||
@apply border-solid border-transparent border-4;
|
@apply border-4 border-solid border-transparent;
|
||||||
@apply hover:bg-dividerDark;
|
@apply hover:bg-dividerDark;
|
||||||
@apply hover:bg-clip-content;
|
@apply hover:bg-clip-content;
|
||||||
}
|
}
|
||||||
@@ -39,7 +57,7 @@ input::placeholder,
|
|||||||
textarea::placeholder,
|
textarea::placeholder,
|
||||||
.cm-placeholder {
|
.cm-placeholder {
|
||||||
@apply text-secondary;
|
@apply text-secondary;
|
||||||
@apply opacity-50;
|
@apply opacity-50 #{!important};
|
||||||
}
|
}
|
||||||
|
|
||||||
input,
|
input,
|
||||||
@@ -54,11 +72,11 @@ html {
|
|||||||
|
|
||||||
body {
|
body {
|
||||||
@apply bg-primary;
|
@apply bg-primary;
|
||||||
@apply text-secondary text-body;
|
@apply text-body text-secondary;
|
||||||
@apply font-medium;
|
@apply font-medium;
|
||||||
@apply select-none;
|
@apply select-none;
|
||||||
@apply overflow-x-hidden;
|
@apply overflow-x-hidden;
|
||||||
@apply leading-body;
|
@apply leading-body #{!important};
|
||||||
animation: fade 300ms forwards;
|
animation: fade 300ms forwards;
|
||||||
-webkit-tap-highlight-color: transparent;
|
-webkit-tap-highlight-color: transparent;
|
||||||
-webkit-touch-callout: none;
|
-webkit-touch-callout: none;
|
||||||
@@ -124,8 +142,8 @@ a {
|
|||||||
|
|
||||||
&.link {
|
&.link {
|
||||||
@apply items-center;
|
@apply items-center;
|
||||||
@apply py-0.5 px-1;
|
@apply px-1 py-0.5;
|
||||||
@apply -my-0.5 -mx-1;
|
@apply -mx-1 -my-0.5;
|
||||||
@apply text-accent;
|
@apply text-accent;
|
||||||
@apply rounded;
|
@apply rounded;
|
||||||
@apply hover:text-accentDark;
|
@apply hover:text-accentDark;
|
||||||
@@ -137,7 +155,7 @@ a {
|
|||||||
|
|
||||||
.cm-tooltip {
|
.cm-tooltip {
|
||||||
.tippy-box {
|
.tippy-box {
|
||||||
@apply shadow-none;
|
@apply shadow-none #{!important};
|
||||||
@apply fixed;
|
@apply fixed;
|
||||||
@apply inline-flex;
|
@apply inline-flex;
|
||||||
@apply -mt-8;
|
@apply -mt-8;
|
||||||
@@ -154,15 +172,15 @@ a {
|
|||||||
@apply flex;
|
@apply flex;
|
||||||
@apply text-tiny text-primary;
|
@apply text-tiny text-primary;
|
||||||
@apply font-semibold;
|
@apply font-semibold;
|
||||||
@apply py-1 px-2;
|
@apply px-2 py-1;
|
||||||
@apply truncate;
|
@apply truncate;
|
||||||
@apply leading-normal;
|
@apply leading-body;
|
||||||
@apply items-center;
|
@apply items-center;
|
||||||
|
|
||||||
kbd {
|
kbd {
|
||||||
@apply hidden;
|
@apply hidden;
|
||||||
@apply font-sans;
|
@apply font-sans;
|
||||||
@apply bg-gray-500/45;
|
background-color: rgba(107, 114, 128, 0.45);
|
||||||
@apply text-primaryLight;
|
@apply text-primaryLight;
|
||||||
@apply rounded-sm;
|
@apply rounded-sm;
|
||||||
@apply px-1;
|
@apply px-1;
|
||||||
@@ -170,6 +188,12 @@ a {
|
|||||||
@apply truncate;
|
@apply truncate;
|
||||||
@apply sm:inline-flex;
|
@apply sm:inline-flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.env-icon {
|
||||||
|
@apply transition;
|
||||||
|
@apply inline-flex;
|
||||||
|
@apply items-center;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.tippy-svg-arrow {
|
.tippy-svg-arrow {
|
||||||
@@ -195,9 +219,9 @@ a {
|
|||||||
@apply max-h-[45vh];
|
@apply max-h-[45vh];
|
||||||
@apply items-stretch;
|
@apply items-stretch;
|
||||||
@apply overflow-y-auto;
|
@apply overflow-y-auto;
|
||||||
@apply text-secondary text-body;
|
@apply text-body text-secondary;
|
||||||
@apply p-2;
|
@apply p-2;
|
||||||
@apply leading-normal;
|
@apply leading-body;
|
||||||
@apply focus:outline-none;
|
@apply focus:outline-none;
|
||||||
scroll-behavior: smooth;
|
scroll-behavior: smooth;
|
||||||
|
|
||||||
@@ -229,12 +253,12 @@ a {
|
|||||||
|
|
||||||
hr {
|
hr {
|
||||||
@apply border-b border-dividerLight;
|
@apply border-b border-dividerLight;
|
||||||
@apply my-2;
|
@apply my-2 #{!important};
|
||||||
}
|
}
|
||||||
|
|
||||||
.heading {
|
.heading {
|
||||||
@apply font-bold;
|
@apply font-bold;
|
||||||
@apply text-secondaryDark text-lg;
|
@apply text-lg text-secondaryDark;
|
||||||
@apply tracking-tight;
|
@apply tracking-tight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,7 +267,7 @@ hr {
|
|||||||
.textarea {
|
.textarea {
|
||||||
@apply flex;
|
@apply flex;
|
||||||
@apply w-full;
|
@apply w-full;
|
||||||
@apply py-2 px-4;
|
@apply px-4 py-2;
|
||||||
@apply bg-transparent;
|
@apply bg-transparent;
|
||||||
@apply rounded;
|
@apply rounded;
|
||||||
@apply text-secondaryDark;
|
@apply text-secondaryDark;
|
||||||
@@ -284,7 +308,7 @@ button {
|
|||||||
@apply transform;
|
@apply transform;
|
||||||
@apply origin-top-left;
|
@apply origin-top-left;
|
||||||
@apply scale-75;
|
@apply scale-75;
|
||||||
@apply translate-x-1 -translate-y-4;
|
@apply -translate-y-4 translate-x-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.floating-input:focus-within ~ label {
|
.floating-input:focus-within ~ label {
|
||||||
@@ -293,7 +317,7 @@ button {
|
|||||||
|
|
||||||
.floating-input ~ .end-actions {
|
.floating-input ~ .end-actions {
|
||||||
@apply absolute;
|
@apply absolute;
|
||||||
@apply right-0.2;
|
@apply right-[.05rem];
|
||||||
@apply inset-y-0;
|
@apply inset-y-0;
|
||||||
@apply flex;
|
@apply flex;
|
||||||
@apply items-center;
|
@apply items-center;
|
||||||
@@ -318,44 +342,28 @@ pre.ace_editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.select-wrapper {
|
|
||||||
@apply flex flex-1;
|
|
||||||
@apply relative;
|
|
||||||
@apply after:absolute;
|
|
||||||
@apply after:flex;
|
|
||||||
@apply after:inset-y-0;
|
|
||||||
@apply after:items-center;
|
|
||||||
@apply after:justify-center;
|
|
||||||
@apply after:pointer-events-none;
|
|
||||||
@apply after:font-icon;
|
|
||||||
@apply after:text-current;
|
|
||||||
@apply after:right-3;
|
|
||||||
@apply after:content-["\e5cf"];
|
|
||||||
@apply after:text-lg;
|
|
||||||
}
|
|
||||||
|
|
||||||
.info-response {
|
.info-response {
|
||||||
@apply text-pink-500;
|
color: var(--status-info-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.success-response {
|
.success-response {
|
||||||
@apply text-green-500;
|
color: var(--status-success-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.redir-response {
|
.redirect-response {
|
||||||
@apply text-yellow-500;
|
color: var(--status-redirect-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.cl-error-response {
|
.critical-error-response {
|
||||||
@apply text-red-500;
|
color: var(--status-critical-error-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.sv-error-response {
|
.server-error-response {
|
||||||
@apply text-red-600;
|
color: var(--status-server-error-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.missing-data-response {
|
.missing-data-response {
|
||||||
@apply text-secondaryLight;
|
color: var(--status-missing-data-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.toasted-container {
|
.toasted-container {
|
||||||
@@ -366,7 +374,7 @@ pre.ace_editor {
|
|||||||
@apply px-4 py-2;
|
@apply px-4 py-2;
|
||||||
@apply bg-tooltip;
|
@apply bg-tooltip;
|
||||||
@apply border-secondaryDark;
|
@apply border-secondaryDark;
|
||||||
@apply text-primary text-body;
|
@apply text-body text-primary;
|
||||||
@apply justify-between;
|
@apply justify-between;
|
||||||
@apply shadow-lg;
|
@apply shadow-lg;
|
||||||
@apply font-semibold;
|
@apply font-semibold;
|
||||||
@@ -394,7 +402,7 @@ pre.ace_editor {
|
|||||||
@apply before:opacity-10;
|
@apply before:opacity-10;
|
||||||
@apply before:inset-0;
|
@apply before:inset-0;
|
||||||
@apply before:transition;
|
@apply before:transition;
|
||||||
@apply before:content-DEFAULT;
|
@apply before:content-[''];
|
||||||
@apply hover:no-underline;
|
@apply hover:no-underline;
|
||||||
@apply hover:before:opacity-20;
|
@apply hover:before:opacity-20;
|
||||||
}
|
}
|
||||||
@@ -428,7 +436,7 @@ pre.ace_editor {
|
|||||||
@apply before:opacity-0;
|
@apply before:opacity-0;
|
||||||
@apply before:z-20;
|
@apply before:z-20;
|
||||||
@apply before:transition;
|
@apply before:transition;
|
||||||
@apply before:content-DEFAULT;
|
@apply before:content-[''];
|
||||||
@apply hover:before:opacity-100;
|
@apply hover:before:opacity-100;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -501,32 +509,16 @@ pre.ace_editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.cm-panel.cm-search [name="close"] {
|
|
||||||
@apply flex;
|
|
||||||
@apply items-center;
|
|
||||||
@apply justify-center;
|
|
||||||
@apply min-h-5;
|
|
||||||
@apply min-w-5;
|
|
||||||
@apply bg-primaryDark #{!important};
|
|
||||||
@apply sticky #{!important};
|
|
||||||
@apply right-0 #{!important};
|
|
||||||
@apply ml-auto #{!important};
|
|
||||||
@apply my-auto #{!important};
|
|
||||||
@apply rounded #{!important};
|
|
||||||
@apply outline #{!important};
|
|
||||||
@apply outline-divider #{!important};
|
|
||||||
}
|
|
||||||
|
|
||||||
.shortcut-key {
|
.shortcut-key {
|
||||||
@apply inline-flex;
|
@apply inline-flex;
|
||||||
@apply font-sans;
|
@apply font-sans;
|
||||||
@apply text-tiny;
|
@apply text-tiny;
|
||||||
@apply bg-divider;
|
@apply bg-dividerLight;
|
||||||
@apply rounded;
|
@apply rounded;
|
||||||
@apply ml-2;
|
@apply ml-2;
|
||||||
@apply px-1;
|
@apply px-1;
|
||||||
@apply min-w-5;
|
@apply min-w-[1.25rem];
|
||||||
@apply min-h-5;
|
@apply min-h-[1.25rem];
|
||||||
@apply items-center;
|
@apply items-center;
|
||||||
@apply justify-center;
|
@apply justify-center;
|
||||||
@apply border border-dividerDark;
|
@apply border border-dividerDark;
|
||||||
|
|||||||
3
packages/hoppscotch-common/assets/scss/tailwind.scss
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
@tailwind base;
|
||||||
|
@tailwind components;
|
||||||
|
@tailwind utilities;
|
||||||
@@ -1,274 +0,0 @@
|
|||||||
@mixin base-theme {
|
|
||||||
--font-sans: "Inter Variable", sans-serif;
|
|
||||||
--font-icon: "Material Symbols Rounded Variable";
|
|
||||||
--font-mono: "Roboto Mono Variable", monospace;
|
|
||||||
--font-size-body: 0.75rem;
|
|
||||||
--font-size-tiny: 0.688rem;
|
|
||||||
--line-height-body: 1rem;
|
|
||||||
--upper-primary-sticky-fold: 4.125rem;
|
|
||||||
--upper-secondary-sticky-fold: 6.188rem;
|
|
||||||
--upper-tertiary-sticky-fold: 8.25rem;
|
|
||||||
--upper-fourth-sticky-fold: 10.2rem;
|
|
||||||
--upper-mobile-primary-sticky-fold: 6.625rem;
|
|
||||||
--upper-mobile-secondary-sticky-fold: 8.688rem;
|
|
||||||
--upper-mobile-sticky-fold: 10.75rem;
|
|
||||||
--upper-mobile-tertiary-sticky-fold: 8.25rem;
|
|
||||||
--lower-primary-sticky-fold: 3rem;
|
|
||||||
--lower-secondary-sticky-fold: 5.063rem;
|
|
||||||
--lower-tertiary-sticky-fold: 7.125rem;
|
|
||||||
--lower-fourth-sticky-fold: 9.188rem;
|
|
||||||
--sidebar-primary-sticky-fold: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin dark-theme {
|
|
||||||
--primary-color: theme("colors.dark.800");
|
|
||||||
--primary-light-color: theme("colors.dark.600");
|
|
||||||
--primary-dark-color: theme("colors.neutral.800");
|
|
||||||
--primary-contrast-color: theme("colors.neutral.900");
|
|
||||||
|
|
||||||
--secondary-color: theme("colors.neutral.400");
|
|
||||||
--secondary-light-color: theme("colors.neutral.500");
|
|
||||||
--secondary-dark-color: theme("colors.neutral.50");
|
|
||||||
|
|
||||||
--divider-color: theme("colors.neutral.800");
|
|
||||||
--divider-light-color: theme("colors.dark.500");
|
|
||||||
--divider-dark-color: theme("colors.dark.300");
|
|
||||||
|
|
||||||
--error-color: theme("colors.stone.800");
|
|
||||||
--tooltip-color: theme("colors.neutral.100");
|
|
||||||
--popover-color: theme("colors.dark.700");
|
|
||||||
--editor-theme: "merbivore_soft";
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin light-theme {
|
|
||||||
--primary-color: theme("colors.white");
|
|
||||||
--primary-light-color: theme("colors.gray.50");
|
|
||||||
--primary-dark-color: theme("colors.gray.100");
|
|
||||||
--primary-contrast-color: theme("colors.light.50");
|
|
||||||
|
|
||||||
--secondary-color: theme("colors.gray.500");
|
|
||||||
--secondary-light-color: theme("colors.gray.400");
|
|
||||||
--secondary-dark-color: theme("colors.gray.900");
|
|
||||||
|
|
||||||
--divider-color: theme("colors.gray.100");
|
|
||||||
--divider-light-color: theme("colors.gray.100");
|
|
||||||
--divider-dark-color: theme("colors.gray.300");
|
|
||||||
|
|
||||||
--error-color: theme("colors.yellow.100");
|
|
||||||
--tooltip-color: theme("colors.neutral.800");
|
|
||||||
--popover-color: theme("colors.white");
|
|
||||||
--editor-theme: "textmate";
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin black-theme {
|
|
||||||
--primary-color: theme("colors.dark.900");
|
|
||||||
--primary-light-color: theme("colors.neutral.900");
|
|
||||||
--primary-dark-color: theme("colors.dark.800");
|
|
||||||
--primary-contrast-color: theme("colors.dark.900");
|
|
||||||
|
|
||||||
--secondary-color: theme("colors.neutral.400");
|
|
||||||
--secondary-light-color: theme("colors.neutral.500");
|
|
||||||
--secondary-dark-color: theme("colors.neutral.100");
|
|
||||||
|
|
||||||
--divider-color: theme("colors.dark.600");
|
|
||||||
--divider-light-color: theme("colors.dark.800");
|
|
||||||
--divider-dark-color: theme("colors.dark.200");
|
|
||||||
|
|
||||||
--error-color: theme("colors.stone.900");
|
|
||||||
--tooltip-color: theme("colors.neutral.100");
|
|
||||||
--popover-color: theme("colors.dark.900");
|
|
||||||
--editor-theme: "twilight";
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin dark-editor-theme {
|
|
||||||
--editor-type-color: theme("colors.purple.400");
|
|
||||||
--editor-name-color: theme("colors.blue.400");
|
|
||||||
--editor-operator-color: theme("colors.indigo.400");
|
|
||||||
--editor-invalid-color: theme("colors.red.400");
|
|
||||||
--editor-separator-color: theme("colors.gray.400");
|
|
||||||
--editor-meta-color: theme("colors.gray.400");
|
|
||||||
--editor-variable-color: theme("colors.green.400");
|
|
||||||
--editor-link-color: theme("colors.cyan.400");
|
|
||||||
--editor-process-color: theme("colors.fuchsia.400");
|
|
||||||
--editor-constant-color: theme("colors.violet.400");
|
|
||||||
--editor-keyword-color: theme("colors.pink.400");
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin light-editor-theme {
|
|
||||||
--editor-type-color: theme("colors.purple.600");
|
|
||||||
--editor-name-color: theme("colors.red.600");
|
|
||||||
--editor-operator-color: theme("colors.indigo.600");
|
|
||||||
--editor-invalid-color: theme("colors.red.600");
|
|
||||||
--editor-separator-color: theme("colors.gray.600");
|
|
||||||
--editor-meta-color: theme("colors.gray.600");
|
|
||||||
--editor-variable-color: theme("colors.green.600");
|
|
||||||
--editor-link-color: theme("colors.cyan.600");
|
|
||||||
--editor-process-color: theme("colors.blue.600");
|
|
||||||
--editor-constant-color: theme("colors.fuchsia.600");
|
|
||||||
--editor-keyword-color: theme("colors.pink.600");
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin black-editor-theme {
|
|
||||||
--editor-type-color: theme("colors.purple.400");
|
|
||||||
--editor-name-color: theme("colors.fuchsia.400");
|
|
||||||
--editor-operator-color: theme("colors.indigo.400");
|
|
||||||
--editor-invalid-color: theme("colors.red.400");
|
|
||||||
--editor-separator-color: theme("colors.gray.400");
|
|
||||||
--editor-meta-color: theme("colors.gray.400");
|
|
||||||
--editor-variable-color: theme("colors.green.400");
|
|
||||||
--editor-link-color: theme("colors.cyan.400");
|
|
||||||
--editor-process-color: theme("colors.violet.400");
|
|
||||||
--editor-constant-color: theme("colors.blue.400");
|
|
||||||
--editor-keyword-color: theme("colors.pink.400");
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin green-theme {
|
|
||||||
--accent-color: theme("colors.green.500");
|
|
||||||
--accent-light-color: theme("colors.green.400");
|
|
||||||
--accent-dark-color: theme("colors.green.600");
|
|
||||||
--accent-contrast-color: theme("colors.white");
|
|
||||||
--gradient-from-color: theme("colors.green.200");
|
|
||||||
--gradient-via-color: theme("colors.green.400");
|
|
||||||
--gradient-to-color: theme("colors.green.600");
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin teal-theme {
|
|
||||||
--accent-color: theme("colors.teal.500");
|
|
||||||
--accent-light-color: theme("colors.teal.400");
|
|
||||||
--accent-dark-color: theme("colors.teal.600");
|
|
||||||
--accent-contrast-color: theme("colors.white");
|
|
||||||
--gradient-from-color: theme("colors.teal.200");
|
|
||||||
--gradient-via-color: theme("colors.teal.400");
|
|
||||||
--gradient-to-color: theme("colors.teal.600");
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin blue-theme {
|
|
||||||
--accent-color: theme("colors.blue.500");
|
|
||||||
--accent-light-color: theme("colors.blue.400");
|
|
||||||
--accent-dark-color: theme("colors.blue.600");
|
|
||||||
--accent-contrast-color: theme("colors.white");
|
|
||||||
--gradient-from-color: theme("colors.blue.200");
|
|
||||||
--gradient-via-color: theme("colors.blue.400");
|
|
||||||
--gradient-to-color: theme("colors.blue.600");
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin indigo-theme {
|
|
||||||
--accent-color: theme("colors.indigo.500");
|
|
||||||
--accent-light-color: theme("colors.indigo.400");
|
|
||||||
--accent-dark-color: theme("colors.indigo.600");
|
|
||||||
--accent-contrast-color: theme("colors.white");
|
|
||||||
--gradient-from-color: theme("colors.indigo.200");
|
|
||||||
--gradient-via-color: theme("colors.indigo.400");
|
|
||||||
--gradient-to-color: theme("colors.indigo.600");
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin purple-theme {
|
|
||||||
--accent-color: theme("colors.purple.500");
|
|
||||||
--accent-light-color: theme("colors.purple.400");
|
|
||||||
--accent-dark-color: theme("colors.purple.600");
|
|
||||||
--accent-contrast-color: theme("colors.white");
|
|
||||||
--gradient-from-color: theme("colors.purple.200");
|
|
||||||
--gradient-via-color: theme("colors.purple.400");
|
|
||||||
--gradient-to-color: theme("colors.purple.600");
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin yellow-theme {
|
|
||||||
--accent-color: theme("colors.yellow.500");
|
|
||||||
--accent-light-color: theme("colors.yellow.400");
|
|
||||||
--accent-dark-color: theme("colors.yellow.600");
|
|
||||||
--accent-contrast-color: theme("colors.white");
|
|
||||||
--gradient-from-color: theme("colors.yellow.200");
|
|
||||||
--gradient-via-color: theme("colors.yellow.400");
|
|
||||||
--gradient-to-color: theme("colors.yellow.600");
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin orange-theme {
|
|
||||||
--accent-color: theme("colors.orange.500");
|
|
||||||
--accent-light-color: theme("colors.orange.400");
|
|
||||||
--accent-dark-color: theme("colors.orange.600");
|
|
||||||
--accent-contrast-color: theme("colors.white");
|
|
||||||
--gradient-from-color: theme("colors.orange.200");
|
|
||||||
--gradient-via-color: theme("colors.orange.400");
|
|
||||||
--gradient-to-color: theme("colors.orange.600");
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin red-theme {
|
|
||||||
--accent-color: theme("colors.red.500");
|
|
||||||
--accent-light-color: theme("colors.red.400");
|
|
||||||
--accent-dark-color: theme("colors.red.600");
|
|
||||||
--accent-contrast-color: theme("colors.white");
|
|
||||||
--gradient-from-color: theme("colors.red.200");
|
|
||||||
--gradient-via-color: theme("colors.red.400");
|
|
||||||
--gradient-to-color: theme("colors.red.600");
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin pink-theme {
|
|
||||||
--accent-color: theme("colors.pink.500");
|
|
||||||
--accent-light-color: theme("colors.pink.400");
|
|
||||||
--accent-dark-color: theme("colors.pink.600");
|
|
||||||
--accent-contrast-color: theme("colors.white");
|
|
||||||
--gradient-from-color: theme("colors.pink.200");
|
|
||||||
--gradient-via-color: theme("colors.pink.400");
|
|
||||||
--gradient-to-color: theme("colors.pink.600");
|
|
||||||
}
|
|
||||||
|
|
||||||
:root {
|
|
||||||
@include base-theme;
|
|
||||||
@include dark-theme;
|
|
||||||
@include dark-editor-theme;
|
|
||||||
@include green-theme;
|
|
||||||
}
|
|
||||||
|
|
||||||
:root.light {
|
|
||||||
@include light-theme;
|
|
||||||
@include light-editor-theme;
|
|
||||||
color-scheme: light;
|
|
||||||
}
|
|
||||||
|
|
||||||
:root.dark {
|
|
||||||
@include dark-theme;
|
|
||||||
@include dark-editor-theme;
|
|
||||||
color-scheme: dark;
|
|
||||||
}
|
|
||||||
|
|
||||||
:root.black {
|
|
||||||
@include black-theme;
|
|
||||||
@include black-editor-theme;
|
|
||||||
color-scheme: dark;
|
|
||||||
}
|
|
||||||
|
|
||||||
:root[data-accent="blue"] {
|
|
||||||
@include blue-theme;
|
|
||||||
}
|
|
||||||
|
|
||||||
:root[data-accent="green"] {
|
|
||||||
@include green-theme;
|
|
||||||
}
|
|
||||||
|
|
||||||
:root[data-accent="teal"] {
|
|
||||||
@include teal-theme;
|
|
||||||
}
|
|
||||||
|
|
||||||
:root[data-accent="indigo"] {
|
|
||||||
@include indigo-theme;
|
|
||||||
}
|
|
||||||
|
|
||||||
:root[data-accent="purple"] {
|
|
||||||
@include purple-theme;
|
|
||||||
}
|
|
||||||
|
|
||||||
:root[data-accent="orange"] {
|
|
||||||
@include orange-theme;
|
|
||||||
}
|
|
||||||
|
|
||||||
:root[data-accent="pink"] {
|
|
||||||
@include pink-theme;
|
|
||||||
}
|
|
||||||
|
|
||||||
:root[data-accent="red"] {
|
|
||||||
@include red-theme;
|
|
||||||
}
|
|
||||||
|
|
||||||
:root[data-accent="yellow"] {
|
|
||||||
@include yellow-theme;
|
|
||||||
}
|
|
||||||
89
packages/hoppscotch-common/assets/themes/accent-themes.scss
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
@mixin green-theme {
|
||||||
|
--accent-color: theme("colors.emerald.500");
|
||||||
|
--accent-light-color: theme("colors.emerald.400");
|
||||||
|
--accent-dark-color: theme("colors.emerald.600");
|
||||||
|
--accent-contrast-color: theme("colors.white");
|
||||||
|
--gradient-from-color: theme("colors.emerald.400");
|
||||||
|
--gradient-via-color: theme("colors.emerald.500");
|
||||||
|
--gradient-to-color: theme("colors.emerald.600");
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin teal-theme {
|
||||||
|
--accent-color: theme("colors.teal.500");
|
||||||
|
--accent-light-color: theme("colors.teal.400");
|
||||||
|
--accent-dark-color: theme("colors.teal.600");
|
||||||
|
--accent-contrast-color: theme("colors.white");
|
||||||
|
--gradient-from-color: theme("colors.teal.400");
|
||||||
|
--gradient-via-color: theme("colors.teal.500");
|
||||||
|
--gradient-to-color: theme("colors.teal.600");
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin blue-theme {
|
||||||
|
--accent-color: theme("colors.blue.500");
|
||||||
|
--accent-light-color: theme("colors.blue.400");
|
||||||
|
--accent-dark-color: theme("colors.blue.600");
|
||||||
|
--accent-contrast-color: theme("colors.white");
|
||||||
|
--gradient-from-color: theme("colors.blue.400");
|
||||||
|
--gradient-via-color: theme("colors.blue.500");
|
||||||
|
--gradient-to-color: theme("colors.blue.600");
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin indigo-theme {
|
||||||
|
--accent-color: theme("colors.indigo.500");
|
||||||
|
--accent-light-color: theme("colors.indigo.400");
|
||||||
|
--accent-dark-color: theme("colors.indigo.600");
|
||||||
|
--accent-contrast-color: theme("colors.white");
|
||||||
|
--gradient-from-color: theme("colors.indigo.400");
|
||||||
|
--gradient-via-color: theme("colors.indigo.500");
|
||||||
|
--gradient-to-color: theme("colors.indigo.600");
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin purple-theme {
|
||||||
|
--accent-color: theme("colors.purple.500");
|
||||||
|
--accent-light-color: theme("colors.purple.400");
|
||||||
|
--accent-dark-color: theme("colors.purple.600");
|
||||||
|
--accent-contrast-color: theme("colors.white");
|
||||||
|
--gradient-from-color: theme("colors.purple.400");
|
||||||
|
--gradient-via-color: theme("colors.purple.500");
|
||||||
|
--gradient-to-color: theme("colors.purple.600");
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin yellow-theme {
|
||||||
|
--accent-color: theme("colors.amber.500");
|
||||||
|
--accent-light-color: theme("colors.amber.400");
|
||||||
|
--accent-dark-color: theme("colors.amber.600");
|
||||||
|
--accent-contrast-color: theme("colors.white");
|
||||||
|
--gradient-from-color: theme("colors.amber.400");
|
||||||
|
--gradient-via-color: theme("colors.amber.500");
|
||||||
|
--gradient-to-color: theme("colors.amber.600");
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin orange-theme {
|
||||||
|
--accent-color: theme("colors.orange.500");
|
||||||
|
--accent-light-color: theme("colors.orange.400");
|
||||||
|
--accent-dark-color: theme("colors.orange.600");
|
||||||
|
--accent-contrast-color: theme("colors.white");
|
||||||
|
--gradient-from-color: theme("colors.orange.400");
|
||||||
|
--gradient-via-color: theme("colors.orange.500");
|
||||||
|
--gradient-to-color: theme("colors.orange.600");
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin red-theme {
|
||||||
|
--accent-color: theme("colors.red.500");
|
||||||
|
--accent-light-color: theme("colors.red.400");
|
||||||
|
--accent-dark-color: theme("colors.red.600");
|
||||||
|
--accent-contrast-color: theme("colors.white");
|
||||||
|
--gradient-from-color: theme("colors.red.400");
|
||||||
|
--gradient-via-color: theme("colors.red.500");
|
||||||
|
--gradient-to-color: theme("colors.red.600");
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin pink-theme {
|
||||||
|
--accent-color: theme("colors.pink.500");
|
||||||
|
--accent-light-color: theme("colors.pink.400");
|
||||||
|
--accent-dark-color: theme("colors.pink.600");
|
||||||
|
--accent-contrast-color: theme("colors.white");
|
||||||
|
--gradient-from-color: theme("colors.pink.400");
|
||||||
|
--gradient-via-color: theme("colors.pink.500");
|
||||||
|
--gradient-to-color: theme("colors.pink.600");
|
||||||
|
}
|
||||||
140
packages/hoppscotch-common/assets/themes/base-themes.scss
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
@mixin base-theme {
|
||||||
|
--font-sans: "Inter Variable", sans-serif;
|
||||||
|
--font-mono: "Roboto Mono Variable", monospace;
|
||||||
|
--font-size-body: 0.75rem;
|
||||||
|
--font-size-tiny: 0.625rem;
|
||||||
|
--line-height-body: 1rem;
|
||||||
|
--upper-primary-sticky-fold: 4.125rem;
|
||||||
|
--upper-secondary-sticky-fold: 6.188rem;
|
||||||
|
--upper-tertiary-sticky-fold: 8.25rem;
|
||||||
|
--upper-fourth-sticky-fold: 10.2rem;
|
||||||
|
--upper-mobile-primary-sticky-fold: 6.75rem;
|
||||||
|
--upper-mobile-secondary-sticky-fold: 8.813rem;
|
||||||
|
--upper-mobile-sticky-fold: 10.875rem;
|
||||||
|
--upper-mobile-tertiary-sticky-fold: 8.25rem;
|
||||||
|
--lower-primary-sticky-fold: 3rem;
|
||||||
|
--lower-secondary-sticky-fold: 5.063rem;
|
||||||
|
--lower-tertiary-sticky-fold: 7.125rem;
|
||||||
|
--lower-fourth-sticky-fold: 9.188rem;
|
||||||
|
--sidebar-primary-sticky-fold: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin light-theme {
|
||||||
|
--primary-color: theme("colors.white");
|
||||||
|
--primary-light-color: theme("colors.gray.50");
|
||||||
|
--primary-dark-color: theme("colors.gray.100");
|
||||||
|
--primary-contrast-color: #fdfdfd;
|
||||||
|
|
||||||
|
--secondary-color: theme("colors.gray.500");
|
||||||
|
--secondary-light-color: theme("colors.gray.400");
|
||||||
|
--secondary-dark-color: theme("colors.gray.900");
|
||||||
|
|
||||||
|
--divider-color: theme("colors.gray.100");
|
||||||
|
--divider-light-color: theme("colors.gray.100");
|
||||||
|
--divider-dark-color: theme("colors.gray.300");
|
||||||
|
|
||||||
|
--banner-info-color: theme("colors.stone.100");
|
||||||
|
--banner-warning-color: theme("colors.yellow.100");
|
||||||
|
--banner-error-color: theme("colors.red.100");
|
||||||
|
|
||||||
|
--tooltip-color: theme("colors.neutral.800");
|
||||||
|
--popover-color: theme("colors.white");
|
||||||
|
|
||||||
|
--method-get-color: theme("colors.green.500");
|
||||||
|
--method-post-color: theme("colors.amber.500");
|
||||||
|
--method-put-color: theme("colors.blue.500");
|
||||||
|
--method-patch-color: theme("colors.purple.500");
|
||||||
|
--method-delete-color: theme("colors.red.500");
|
||||||
|
--method-head-color: theme("colors.lime.500");
|
||||||
|
--method-options-color: theme("colors.pink.500");
|
||||||
|
--method-default-color: theme("colors.gray.500");
|
||||||
|
|
||||||
|
--status-info-color: theme("colors.blue.500");
|
||||||
|
--status-success-color: theme("colors.green.500");
|
||||||
|
--status-redirect-color: theme("colors.amber.500");
|
||||||
|
--status-critical-error-color: theme("colors.red.500");
|
||||||
|
--status-server-error-color: theme("colors.rose.500");
|
||||||
|
--status-missing-data-color: theme("colors.slate.500");
|
||||||
|
|
||||||
|
--editor-theme: "textmate";
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin dark-theme {
|
||||||
|
--primary-color: #181818;
|
||||||
|
--primary-light-color: #1c1c1e;
|
||||||
|
--primary-dark-color: theme("colors.neutral.800");
|
||||||
|
--primary-contrast-color: theme("colors.neutral.900");
|
||||||
|
|
||||||
|
--secondary-color: theme("colors.neutral.400");
|
||||||
|
--secondary-light-color: theme("colors.neutral.500");
|
||||||
|
--secondary-dark-color: theme("colors.zinc.50");
|
||||||
|
|
||||||
|
--divider-color: #1f1f1f;
|
||||||
|
--divider-light-color: #1f1f1f;
|
||||||
|
--divider-dark-color: theme("colors.zinc.800");
|
||||||
|
|
||||||
|
--banner-info-color: theme("colors.stone.800");
|
||||||
|
--banner-warning-color: theme("colors.yellow.800");
|
||||||
|
--banner-error-color: theme("colors.red.800");
|
||||||
|
|
||||||
|
--tooltip-color: theme("colors.neutral.100");
|
||||||
|
--popover-color: #1b1b1b;
|
||||||
|
|
||||||
|
--method-get-color: theme("colors.emerald.500");
|
||||||
|
--method-post-color: theme("colors.yellow.500");
|
||||||
|
--method-put-color: theme("colors.sky.500");
|
||||||
|
--method-patch-color: theme("colors.violet.500");
|
||||||
|
--method-delete-color: theme("colors.rose.500");
|
||||||
|
--method-head-color: theme("colors.teal.500");
|
||||||
|
--method-options-color: theme("colors.indigo.500");
|
||||||
|
--method-default-color: theme("colors.neutral.500");
|
||||||
|
|
||||||
|
--status-info-color: theme("colors.blue.500");
|
||||||
|
--status-success-color: theme("colors.green.500");
|
||||||
|
--status-redirect-color: theme("colors.amber.500");
|
||||||
|
--status-critical-error-color: theme("colors.red.500");
|
||||||
|
--status-server-error-color: theme("colors.rose.500");
|
||||||
|
--status-missing-data-color: theme("colors.slate.500");
|
||||||
|
|
||||||
|
--editor-theme: "merbivore_soft";
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin black-theme {
|
||||||
|
--primary-color: #0f0f0f;
|
||||||
|
--primary-light-color: theme("colors.neutral.900");
|
||||||
|
--primary-dark-color: #181818;
|
||||||
|
--primary-contrast-color: #0f0f0f;
|
||||||
|
|
||||||
|
--secondary-color: theme("colors.neutral.400");
|
||||||
|
--secondary-light-color: theme("colors.neutral.500");
|
||||||
|
--secondary-dark-color: theme("colors.neutral.50");
|
||||||
|
|
||||||
|
--divider-color: theme("colors.neutral.900");
|
||||||
|
--divider-light-color: theme("colors.neutral.900");
|
||||||
|
--divider-dark-color: theme("colors.zinc.800");
|
||||||
|
|
||||||
|
--banner-info-color: theme("colors.stone.900");
|
||||||
|
--banner-warning-color: theme("colors.yellow.900");
|
||||||
|
--banner-error-color: theme("colors.red.900");
|
||||||
|
|
||||||
|
--tooltip-color: theme("colors.neutral.100");
|
||||||
|
--popover-color: theme("colors.stone.950");
|
||||||
|
|
||||||
|
--method-get-color: theme("colors.emerald.500");
|
||||||
|
--method-post-color: theme("colors.yellow.500");
|
||||||
|
--method-put-color: theme("colors.sky.500");
|
||||||
|
--method-patch-color: theme("colors.violet.500");
|
||||||
|
--method-delete-color: theme("colors.rose.500");
|
||||||
|
--method-head-color: theme("colors.teal.500");
|
||||||
|
--method-options-color: theme("colors.indigo.500");
|
||||||
|
--method-default-color: theme("colors.zinc.500");
|
||||||
|
|
||||||
|
--status-info-color: theme("colors.blue.500");
|
||||||
|
--status-success-color: theme("colors.green.500");
|
||||||
|
--status-redirect-color: theme("colors.amber.500");
|
||||||
|
--status-critical-error-color: theme("colors.red.500");
|
||||||
|
--status-server-error-color: theme("colors.rose.500");
|
||||||
|
--status-missing-data-color: theme("colors.slate.500");
|
||||||
|
|
||||||
|
--editor-theme: "twilight";
|
||||||
|
}
|
||||||
41
packages/hoppscotch-common/assets/themes/editor-themes.scss
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
@mixin light-editor-theme {
|
||||||
|
--editor-type-color: theme("colors.violet.600");
|
||||||
|
--editor-name-color: theme("colors.red.600");
|
||||||
|
--editor-operator-color: theme("colors.indigo.600");
|
||||||
|
--editor-invalid-color: theme("colors.red.600");
|
||||||
|
--editor-separator-color: theme("colors.gray.600");
|
||||||
|
--editor-meta-color: theme("colors.gray.600");
|
||||||
|
--editor-variable-color: theme("colors.emerald.600");
|
||||||
|
--editor-link-color: theme("colors.cyan.600");
|
||||||
|
--editor-process-color: theme("colors.blue.600");
|
||||||
|
--editor-constant-color: theme("colors.fuchsia.600");
|
||||||
|
--editor-keyword-color: theme("colors.pink.600");
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin dark-editor-theme {
|
||||||
|
--editor-type-color: theme("colors.violet.400");
|
||||||
|
--editor-name-color: theme("colors.blue.400");
|
||||||
|
--editor-operator-color: theme("colors.indigo.400");
|
||||||
|
--editor-invalid-color: theme("colors.red.400");
|
||||||
|
--editor-separator-color: theme("colors.gray.400");
|
||||||
|
--editor-meta-color: theme("colors.gray.400");
|
||||||
|
--editor-variable-color: theme("colors.emerald.400");
|
||||||
|
--editor-link-color: theme("colors.cyan.400");
|
||||||
|
--editor-process-color: theme("colors.fuchsia.400");
|
||||||
|
--editor-constant-color: theme("colors.violet.400");
|
||||||
|
--editor-keyword-color: theme("colors.pink.400");
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin black-editor-theme {
|
||||||
|
--editor-type-color: theme("colors.violet.400");
|
||||||
|
--editor-name-color: theme("colors.fuchsia.400");
|
||||||
|
--editor-operator-color: theme("colors.indigo.400");
|
||||||
|
--editor-invalid-color: theme("colors.red.400");
|
||||||
|
--editor-separator-color: theme("colors.gray.400");
|
||||||
|
--editor-meta-color: theme("colors.gray.400");
|
||||||
|
--editor-variable-color: theme("colors.emerald.400");
|
||||||
|
--editor-link-color: theme("colors.cyan.400");
|
||||||
|
--editor-process-color: theme("colors.violet.400");
|
||||||
|
--editor-constant-color: theme("colors.blue.400");
|
||||||
|
--editor-keyword-color: theme("colors.pink.400");
|
||||||
|
}
|
||||||
64
packages/hoppscotch-common/assets/themes/themes.scss
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
@import "./base-themes.scss";
|
||||||
|
@import "./editor-themes.scss";
|
||||||
|
@import "./accent-themes.scss";
|
||||||
|
|
||||||
|
:root {
|
||||||
|
@include base-theme;
|
||||||
|
@include dark-theme;
|
||||||
|
@include green-theme;
|
||||||
|
@include dark-editor-theme;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root.light {
|
||||||
|
@include light-theme;
|
||||||
|
@include light-editor-theme;
|
||||||
|
color-scheme: light;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root.dark {
|
||||||
|
@include dark-theme;
|
||||||
|
@include dark-editor-theme;
|
||||||
|
color-scheme: dark;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root.black {
|
||||||
|
@include black-theme;
|
||||||
|
@include black-editor-theme;
|
||||||
|
color-scheme: dark;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[data-accent="blue"] {
|
||||||
|
@include blue-theme;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[data-accent="green"] {
|
||||||
|
@include green-theme;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[data-accent="teal"] {
|
||||||
|
@include teal-theme;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[data-accent="indigo"] {
|
||||||
|
@include indigo-theme;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[data-accent="purple"] {
|
||||||
|
@include purple-theme;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[data-accent="orange"] {
|
||||||
|
@include orange-theme;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[data-accent="pink"] {
|
||||||
|
@include pink-theme;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[data-accent="red"] {
|
||||||
|
@include red-theme;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[data-accent="yellow"] {
|
||||||
|
@include yellow-theme;
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"action": {
|
"action": {
|
||||||
|
"add": "Add",
|
||||||
"autoscroll": "Autoscroll",
|
"autoscroll": "Autoscroll",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
"choose_file": "Choose a file",
|
"choose_file": "Choose a file",
|
||||||
@@ -10,6 +11,7 @@
|
|||||||
"connect": "Connect",
|
"connect": "Connect",
|
||||||
"connecting": "Connecting",
|
"connecting": "Connecting",
|
||||||
"copy": "Copy",
|
"copy": "Copy",
|
||||||
|
"create": "Create",
|
||||||
"delete": "Delete",
|
"delete": "Delete",
|
||||||
"disconnect": "Disconnect",
|
"disconnect": "Disconnect",
|
||||||
"dismiss": "Dismiss",
|
"dismiss": "Dismiss",
|
||||||
@@ -39,6 +41,7 @@
|
|||||||
"scroll_to_top": "Scroll to top",
|
"scroll_to_top": "Scroll to top",
|
||||||
"search": "Search",
|
"search": "Search",
|
||||||
"send": "Send",
|
"send": "Send",
|
||||||
|
"share": "Share",
|
||||||
"start": "Start",
|
"start": "Start",
|
||||||
"starting": "Starting",
|
"starting": "Starting",
|
||||||
"stop": "Stop",
|
"stop": "Stop",
|
||||||
@@ -54,10 +57,30 @@
|
|||||||
"new": "Add new",
|
"new": "Add new",
|
||||||
"star": "Add star"
|
"star": "Add star"
|
||||||
},
|
},
|
||||||
|
"cookies": {
|
||||||
|
"modal": {
|
||||||
|
"new_domain_name": "New domain name",
|
||||||
|
"set": "Set a cookie",
|
||||||
|
"cookie_string": "Cookie string",
|
||||||
|
"enter_cookie_string": "Enter cookie string",
|
||||||
|
"cookie_name": "Name",
|
||||||
|
"cookie_value": "Value",
|
||||||
|
"cookie_path": "Path",
|
||||||
|
"cookie_expires": "Expires",
|
||||||
|
"managed_tab": "Managed",
|
||||||
|
"raw_tab": "Raw",
|
||||||
|
"interceptor_no_support": "Your currently selected interceptor does not support cookies. Select a different Interceptor and try again.",
|
||||||
|
"empty_domains": "Domain list is empty",
|
||||||
|
"empty_domain": "Domain is empty",
|
||||||
|
"no_cookies_in_domain": "No cookies set for this domain"
|
||||||
|
}
|
||||||
|
},
|
||||||
"app": {
|
"app": {
|
||||||
"chat_with_us": "Chat with us",
|
"chat_with_us": "Chat with us",
|
||||||
"contact_us": "Contact us",
|
"contact_us": "Contact us",
|
||||||
|
"cookies": "Cookies",
|
||||||
"copy": "Copy",
|
"copy": "Copy",
|
||||||
|
"copy_interface_type": "Copy interface type",
|
||||||
"copy_user_id": "Copy User Auth Token",
|
"copy_user_id": "Copy User Auth Token",
|
||||||
"developer_option": "Developer options",
|
"developer_option": "Developer options",
|
||||||
"developer_option_description": "Developer tools which helps in development and maintenance of Hoppscotch.",
|
"developer_option_description": "Developer tools which helps in development and maintenance of Hoppscotch.",
|
||||||
@@ -73,6 +96,7 @@
|
|||||||
"keyboard_shortcuts": "Keyboard shortcuts",
|
"keyboard_shortcuts": "Keyboard shortcuts",
|
||||||
"name": "Hoppscotch",
|
"name": "Hoppscotch",
|
||||||
"new_version_found": "New version found. Refresh to update.",
|
"new_version_found": "New version found. Refresh to update.",
|
||||||
|
"open_in_hoppscotch": "Open in Hoppscotch",
|
||||||
"options": "Options",
|
"options": "Options",
|
||||||
"proxy_privacy_policy": "Proxy privacy policy",
|
"proxy_privacy_policy": "Proxy privacy policy",
|
||||||
"reload": "Reload",
|
"reload": "Reload",
|
||||||
@@ -112,18 +136,34 @@
|
|||||||
},
|
},
|
||||||
"authorization": {
|
"authorization": {
|
||||||
"generate_token": "Generate Token",
|
"generate_token": "Generate Token",
|
||||||
|
"graphql_headers": "Authorization Headers are sent as part of the payload to connection_init",
|
||||||
"include_in_url": "Include in URL",
|
"include_in_url": "Include in URL",
|
||||||
"learn": "Learn how",
|
"learn": "Learn how",
|
||||||
"pass_key_by": "Pass by",
|
"pass_key_by": "Pass by",
|
||||||
"password": "Password",
|
"password": "Password",
|
||||||
"token": "Token",
|
"token": "Token",
|
||||||
"type": "Authorization Type",
|
"type": "Authorization Type",
|
||||||
"username": "Username"
|
"username": "Username",
|
||||||
|
"oauth": {
|
||||||
|
"token_generation_oidc_discovery_failed": "Failure on token generation: OpenID Connect Discovery Failed",
|
||||||
|
"something_went_wrong_on_token_generation": "Something went wrong on token generation",
|
||||||
|
"redirect_auth_server_returned_error": "Auth Server returned an error state",
|
||||||
|
"redirect_no_auth_code": "No Authorization Code present in the redirect",
|
||||||
|
"redirect_invalid_state": "Invalid State value present in the redirect",
|
||||||
|
"redirect_no_token_endpoint": "No Token Endpoint Defined",
|
||||||
|
"redirect_no_client_id": "No Client ID defined",
|
||||||
|
"redirect_no_client_secret": "No Client Secret Defined",
|
||||||
|
"redirect_no_code_verifier": "No Code Verifier Defined",
|
||||||
|
"redirect_auth_token_request_failed": "Request to get the auth token failed",
|
||||||
|
"redirect_auth_token_request_invalid_response": "Invalid Response from the Token Endpoint when requesting for an auth token",
|
||||||
|
"something_went_wrong_on_oauth_redirect": "Something went wrong during OAuth Redirect"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"collection": {
|
"collection": {
|
||||||
"created": "Collection created",
|
"created": "Collection created",
|
||||||
"different_parent": "Cannot reorder collection with different parent",
|
"different_parent": "Cannot reorder collection with different parent",
|
||||||
"edit": "Edit Collection",
|
"edit": "Edit Collection",
|
||||||
|
"import_or_create": "Import or create a collection",
|
||||||
"invalid_name": "Please provide a name for the collection",
|
"invalid_name": "Please provide a name for the collection",
|
||||||
"invalid_root_move": "Collection already in the root",
|
"invalid_root_move": "Collection already in the root",
|
||||||
"moved": "Moved Successfully",
|
"moved": "Moved Successfully",
|
||||||
@@ -151,6 +191,7 @@
|
|||||||
"remove_folder": "Are you sure you want to permanently delete this folder?",
|
"remove_folder": "Are you sure you want to permanently delete this folder?",
|
||||||
"remove_history": "Are you sure you want to permanently delete all history?",
|
"remove_history": "Are you sure you want to permanently delete all history?",
|
||||||
"remove_request": "Are you sure you want to permanently delete this request?",
|
"remove_request": "Are you sure you want to permanently delete this request?",
|
||||||
|
"remove_shared_request": "Are you sure you want to permanently delete this shared request?",
|
||||||
"remove_team": "Are you sure you want to delete this team?",
|
"remove_team": "Are you sure you want to delete this team?",
|
||||||
"remove_telemetry": "Are you sure you want to opt-out of Telemetry?",
|
"remove_telemetry": "Are you sure you want to opt-out of Telemetry?",
|
||||||
"request_change": "Are you sure you want to discard current request, unsaved changes will be lost.",
|
"request_change": "Are you sure you want to discard current request, unsaved changes will be lost.",
|
||||||
@@ -192,7 +233,8 @@
|
|||||||
"profile": "Login to view your profile",
|
"profile": "Login to view your profile",
|
||||||
"protocols": "Protocols are empty",
|
"protocols": "Protocols are empty",
|
||||||
"schema": "Connect to a GraphQL endpoint to view schema",
|
"schema": "Connect to a GraphQL endpoint to view schema",
|
||||||
"shortcodes": "Shortcodes are empty",
|
"shared_requests_logout": "Login to view your shared requests or create a new one",
|
||||||
|
"shared_requests": "Shared requests are empty",
|
||||||
"subscription": "Subscriptions are empty",
|
"subscription": "Subscriptions are empty",
|
||||||
"team_name": "Team name empty",
|
"team_name": "Team name empty",
|
||||||
"teams": "You don't belong to any teams",
|
"teams": "You don't belong to any teams",
|
||||||
@@ -209,6 +251,7 @@
|
|||||||
"empty_variables": "No variables",
|
"empty_variables": "No variables",
|
||||||
"global": "Global",
|
"global": "Global",
|
||||||
"global_variables": "Global variables",
|
"global_variables": "Global variables",
|
||||||
|
"import_or_create": "Import or create a environment",
|
||||||
"invalid_name": "Please provide a name for the environment",
|
"invalid_name": "Please provide a name for the environment",
|
||||||
"list": "Environment variables",
|
"list": "Environment variables",
|
||||||
"my_environments": "My Environments",
|
"my_environments": "My Environments",
|
||||||
@@ -231,9 +274,13 @@
|
|||||||
"variable": "Variable",
|
"variable": "Variable",
|
||||||
"variable_list": "Variable List"
|
"variable_list": "Variable List"
|
||||||
},
|
},
|
||||||
|
"graphql_collections": {
|
||||||
|
"title": "GraphQL Collections"
|
||||||
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"browser_support_sse": "This browser doesn't seems to have Server Sent Events support.",
|
"browser_support_sse": "This browser doesn't seems to have Server Sent Events support.",
|
||||||
"check_console_details": "Check console log for details.",
|
"check_console_details": "Check console log for details.",
|
||||||
|
"check_how_to_add_origin": "Check how you can add an origin",
|
||||||
"curl_invalid_format": "cURL is not formatted properly",
|
"curl_invalid_format": "cURL is not formatted properly",
|
||||||
"danger_zone": "Danger zone",
|
"danger_zone": "Danger zone",
|
||||||
"delete_account": "Your account is currently an owner in these teams:",
|
"delete_account": "Your account is currently an owner in these teams:",
|
||||||
@@ -249,9 +296,12 @@
|
|||||||
"json_prettify_invalid_body": "Couldn't prettify an invalid body, solve json syntax errors and try again",
|
"json_prettify_invalid_body": "Couldn't prettify an invalid body, solve json syntax errors and try again",
|
||||||
"network_error": "There seems to be a network error. Please try again.",
|
"network_error": "There seems to be a network error. Please try again.",
|
||||||
"network_fail": "Could not send request",
|
"network_fail": "Could not send request",
|
||||||
|
"no_collections_to_export": "No collections to export. Please create a collection to get started.",
|
||||||
"no_duration": "No duration",
|
"no_duration": "No duration",
|
||||||
|
"no_environments_to_export": "No environments to export. Please create an environment to get started.",
|
||||||
"no_results_found": "No matches found",
|
"no_results_found": "No matches found",
|
||||||
"page_not_found": "This page could not be found",
|
"page_not_found": "This page could not be found",
|
||||||
|
"please_install_extension": "Please install the extension and add origin to the extension.",
|
||||||
"proxy_error": "Proxy error",
|
"proxy_error": "Proxy error",
|
||||||
"script_fail": "Could not execute pre-request script",
|
"script_fail": "Could not execute pre-request script",
|
||||||
"something_went_wrong": "Something went wrong",
|
"something_went_wrong": "Something went wrong",
|
||||||
@@ -262,7 +312,8 @@
|
|||||||
"create_secret_gist": "Create secret Gist",
|
"create_secret_gist": "Create secret Gist",
|
||||||
"gist_created": "Gist created",
|
"gist_created": "Gist created",
|
||||||
"require_github": "Login with GitHub to create secret gist",
|
"require_github": "Login with GitHub to create secret gist",
|
||||||
"title": "Export"
|
"title": "Export",
|
||||||
|
"failed": "Something went wrong while exporting"
|
||||||
},
|
},
|
||||||
"filter": {
|
"filter": {
|
||||||
"all": "All",
|
"all": "All",
|
||||||
@@ -299,8 +350,8 @@
|
|||||||
"authorization": "The authorization header will be automatically generated when you send the request.",
|
"authorization": "The authorization header will be automatically generated when you send the request.",
|
||||||
"generate_documentation_first": "Generate documentation first",
|
"generate_documentation_first": "Generate documentation first",
|
||||||
"network_fail": "Unable to reach the API endpoint. Check your network connection or select a different Interceptor and try again.",
|
"network_fail": "Unable to reach the API endpoint. Check your network connection or select a different Interceptor and try again.",
|
||||||
"offline": "You seem to be offline. Data in this workspace might not be up to date.",
|
"offline": "You're using Hoppscotch offline. Updates will sync when you're online, based on workspace settings.",
|
||||||
"offline_short": "You seem to be offline.",
|
"offline_short": "You're using Hoppscotch offline.",
|
||||||
"post_request_tests": "Test scripts are written in JavaScript, and are run after the response is received.",
|
"post_request_tests": "Test scripts are written in JavaScript, and are run after the response is received.",
|
||||||
"pre_request_script": "Pre-request scripts are written in JavaScript, and are run before the request is sent.",
|
"pre_request_script": "Pre-request scripts are written in JavaScript, and are run before the request is sent.",
|
||||||
"script_fail": "It seems there is a glitch in the pre-request script. Check the error below and fix the script accordingly.",
|
"script_fail": "It seems there is a glitch in the pre-request script. Check the error below and fix the script accordingly.",
|
||||||
@@ -329,6 +380,7 @@
|
|||||||
"from_openapi_description": "Import from OpenAPI specification file (YML/JSON)",
|
"from_openapi_description": "Import from OpenAPI specification file (YML/JSON)",
|
||||||
"from_postman": "Import from Postman",
|
"from_postman": "Import from Postman",
|
||||||
"from_postman_description": "Import from Postman collection",
|
"from_postman_description": "Import from Postman collection",
|
||||||
|
"from_file": "Import from File",
|
||||||
"from_url": "Import from URL",
|
"from_url": "Import from URL",
|
||||||
"gist_url": "Enter Gist URL",
|
"gist_url": "Enter Gist URL",
|
||||||
"import_from_url_invalid_fetch": "Couldn't get data from the url",
|
"import_from_url_invalid_fetch": "Couldn't get data from the url",
|
||||||
@@ -336,7 +388,14 @@
|
|||||||
"import_from_url_invalid_type": "Unsupported type. accepted values are 'hoppscotch', 'openapi', 'postman', 'insomnia'",
|
"import_from_url_invalid_type": "Unsupported type. accepted values are 'hoppscotch', 'openapi', 'postman', 'insomnia'",
|
||||||
"import_from_url_success": "Collections Imported",
|
"import_from_url_success": "Collections Imported",
|
||||||
"json_description": "Import collections from a Hoppscotch Collections JSON file",
|
"json_description": "Import collections from a Hoppscotch Collections JSON file",
|
||||||
"title": "Import"
|
"title": "Import",
|
||||||
|
"hoppscotch_environment": "Hoppscotch Environment",
|
||||||
|
"hoppscotch_environment_description": "Import Hoppscotch Environment JSON file",
|
||||||
|
"postman_environment": "Postman Environment",
|
||||||
|
"postman_environment_description": "Import Postman Environment JSON file",
|
||||||
|
"environments_from_gist": "Import From Gist",
|
||||||
|
"environments_from_gist_description": "Import Hoppscotch Environments From Gist",
|
||||||
|
"gql_collections_from_gist_description": "Import GraphQL Collections From Gist"
|
||||||
},
|
},
|
||||||
"inspections": {
|
"inspections": {
|
||||||
"description": "Inspect possible errors",
|
"description": "Inspect possible errors",
|
||||||
@@ -373,7 +432,9 @@
|
|||||||
"close_unsaved_tab": "You have unsaved changes",
|
"close_unsaved_tab": "You have unsaved changes",
|
||||||
"collections": "Collections",
|
"collections": "Collections",
|
||||||
"confirm": "Confirm",
|
"confirm": "Confirm",
|
||||||
|
"customize_request": "Customize Request",
|
||||||
"edit_request": "Edit Request",
|
"edit_request": "Edit Request",
|
||||||
|
"share_request": "Share Request",
|
||||||
"import_export": "Import / Export"
|
"import_export": "Import / Export"
|
||||||
},
|
},
|
||||||
"mqtt": {
|
"mqtt": {
|
||||||
@@ -449,13 +510,14 @@
|
|||||||
"structured": "Structured",
|
"structured": "Structured",
|
||||||
"text": "Text"
|
"text": "Text"
|
||||||
},
|
},
|
||||||
"copy_link": "Copy link",
|
|
||||||
"different_collection": "Cannot reorder requests from different collections",
|
"different_collection": "Cannot reorder requests from different collections",
|
||||||
"duplicated": "Request duplicated",
|
"duplicated": "Request duplicated",
|
||||||
"duration": "Duration",
|
"duration": "Duration",
|
||||||
"enter_curl": "Enter cURL command",
|
"enter_curl": "Enter cURL command",
|
||||||
"generate_code": "Generate code",
|
"generate_code": "Generate code",
|
||||||
"generated_code": "Generated code",
|
"generated_code": "Generated code",
|
||||||
|
"go_to_authorization_tab": "Go to Authorization tab",
|
||||||
|
"go_to_body_tab": "Go to Body tab",
|
||||||
"header_list": "Header List",
|
"header_list": "Header List",
|
||||||
"invalid_name": "Please provide a name for the request",
|
"invalid_name": "Please provide a name for the request",
|
||||||
"method": "Method",
|
"method": "Method",
|
||||||
@@ -480,6 +542,7 @@
|
|||||||
"saved": "Request saved",
|
"saved": "Request saved",
|
||||||
"share": "Share",
|
"share": "Share",
|
||||||
"share_description": "Share Hoppscotch with your friends",
|
"share_description": "Share Hoppscotch with your friends",
|
||||||
|
"share_request": "Share Request",
|
||||||
"stop": "Stop",
|
"stop": "Stop",
|
||||||
"title": "Request",
|
"title": "Request",
|
||||||
"type": "Request type",
|
"type": "Request type",
|
||||||
@@ -557,16 +620,34 @@
|
|||||||
"use_experimental_url_bar": "Use experimental URL bar with environment highlighting",
|
"use_experimental_url_bar": "Use experimental URL bar with environment highlighting",
|
||||||
"user": "User",
|
"user": "User",
|
||||||
"verified_email": "Verified email",
|
"verified_email": "Verified email",
|
||||||
|
"additional": "Additional Settings",
|
||||||
"verify_email": "Verify email"
|
"verify_email": "Verify email"
|
||||||
},
|
},
|
||||||
"shortcodes": {
|
"shared_requests": {
|
||||||
"actions": "Actions",
|
"button": "Button",
|
||||||
"created_on": "Created on",
|
"button_info": "Create a 'Run in Hoppscotch' button for your website, blog or a README.",
|
||||||
"deleted": "Shortcode deleted",
|
"customize": "Customize",
|
||||||
"method": "Method",
|
"creating_widget": "Creating widget",
|
||||||
"not_found": "Shortcode not found",
|
"copy_html": "Copy HTML",
|
||||||
"short_code": "Short code",
|
"copy_link": "Copy Link",
|
||||||
"url": "URL"
|
"copy_markdown": "Copy Markdown",
|
||||||
|
"deleted": "Shared request deleted",
|
||||||
|
"description": "Select a widget, you can change and customize this later",
|
||||||
|
"embed": "Embed",
|
||||||
|
"embed_info": "Add a mini 'Hoppscotch API Playground' to your website, blog or documentation.",
|
||||||
|
"link": "Link",
|
||||||
|
"link_info": "Create a shareable link to share with anyone on the internet with view access.",
|
||||||
|
"modified": "Shared request modified",
|
||||||
|
"not_found": "Shared request not found",
|
||||||
|
"open_new_tab": "Open in new tab",
|
||||||
|
"preview": "Preview",
|
||||||
|
"run_in_hoppscotch": "Run in Hoppscotch",
|
||||||
|
"theme": {
|
||||||
|
"dark": "Dark",
|
||||||
|
"light": "Light",
|
||||||
|
"system": "System",
|
||||||
|
"title": "Theme"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"shortcut": {
|
"shortcut": {
|
||||||
"general": {
|
"general": {
|
||||||
@@ -596,7 +677,6 @@
|
|||||||
"title": "Others"
|
"title": "Others"
|
||||||
},
|
},
|
||||||
"request": {
|
"request": {
|
||||||
"copy_request_link": "Copy Request Link",
|
|
||||||
"delete_method": "Select DELETE method",
|
"delete_method": "Select DELETE method",
|
||||||
"get_method": "Select GET method",
|
"get_method": "Select GET method",
|
||||||
"head_method": "Select HEAD method",
|
"head_method": "Select HEAD method",
|
||||||
@@ -612,6 +692,7 @@
|
|||||||
"save_to_collections": "Save to Collections",
|
"save_to_collections": "Save to Collections",
|
||||||
"send_request": "Send Request",
|
"send_request": "Send Request",
|
||||||
"show_code": "Generate code snippet",
|
"show_code": "Generate code snippet",
|
||||||
|
"share_request": "Share Request",
|
||||||
"title": "Request"
|
"title": "Request"
|
||||||
},
|
},
|
||||||
"response": {
|
"response": {
|
||||||
@@ -736,6 +817,7 @@
|
|||||||
"connection_failed": "Connection failed",
|
"connection_failed": "Connection failed",
|
||||||
"connection_lost": "Connection lost",
|
"connection_lost": "Connection lost",
|
||||||
"copied_to_clipboard": "Copied to clipboard",
|
"copied_to_clipboard": "Copied to clipboard",
|
||||||
|
"copied_interface_to_clipboard": "Copied {language} interface type to clipboard",
|
||||||
"deleted": "Deleted",
|
"deleted": "Deleted",
|
||||||
"deprecated": "DEPRECATED",
|
"deprecated": "DEPRECATED",
|
||||||
"disabled": "Disabled",
|
"disabled": "Disabled",
|
||||||
@@ -743,9 +825,11 @@
|
|||||||
"disconnected_from": "Disconnected from {name}",
|
"disconnected_from": "Disconnected from {name}",
|
||||||
"docs_generated": "Documentation generated",
|
"docs_generated": "Documentation generated",
|
||||||
"download_started": "Download started",
|
"download_started": "Download started",
|
||||||
|
"download_failed": "Download failed",
|
||||||
"enabled": "Enabled",
|
"enabled": "Enabled",
|
||||||
"file_imported": "File imported",
|
"file_imported": "File imported",
|
||||||
"finished_in": "Finished in {duration} ms",
|
"finished_in": "Finished in {duration} ms",
|
||||||
|
"hide": "Hide",
|
||||||
"history_deleted": "History deleted",
|
"history_deleted": "History deleted",
|
||||||
"linewrap": "Wrap lines",
|
"linewrap": "Wrap lines",
|
||||||
"loading": "Loading...",
|
"loading": "Loading...",
|
||||||
@@ -756,6 +840,7 @@
|
|||||||
"published_error": "Something went wrong while publishing msg: {topic} to topic: {message}",
|
"published_error": "Something went wrong while publishing msg: {topic} to topic: {message}",
|
||||||
"published_message": "Published message: {message} to topic: {topic}",
|
"published_message": "Published message: {message} to topic: {topic}",
|
||||||
"reconnection_error": "Failed to reconnect",
|
"reconnection_error": "Failed to reconnect",
|
||||||
|
"show": "Show",
|
||||||
"subscribed_failed": "Failed to subscribe to topic: {topic}",
|
"subscribed_failed": "Failed to subscribe to topic: {topic}",
|
||||||
"subscribed_success": "Successfully subscribed to topic: {topic}",
|
"subscribed_success": "Successfully subscribed to topic: {topic}",
|
||||||
"unsubscribed_failed": "Failed to unsubscribe from topic: {topic}",
|
"unsubscribed_failed": "Failed to unsubscribe from topic: {topic}",
|
||||||
@@ -791,6 +876,7 @@
|
|||||||
"queries": "Queries",
|
"queries": "Queries",
|
||||||
"query": "Query",
|
"query": "Query",
|
||||||
"schema": "Schema",
|
"schema": "Schema",
|
||||||
|
"shared_requests": "Shared Requests",
|
||||||
"socketio": "Socket.IO",
|
"socketio": "Socket.IO",
|
||||||
"sse": "SSE",
|
"sse": "SSE",
|
||||||
"tests": "Tests",
|
"tests": "Tests",
|
||||||
@@ -837,7 +923,7 @@
|
|||||||
"new": "New Team",
|
"new": "New Team",
|
||||||
"new_created": "New team created",
|
"new_created": "New team created",
|
||||||
"new_name": "My New Team",
|
"new_name": "My New Team",
|
||||||
"no_access": "You do not have edit access to these collections",
|
"no_access": "You do not have edit access to this team",
|
||||||
"no_invite_found": "Invitation not found. Contact your team owner.",
|
"no_invite_found": "Invitation not found. Contact your team owner.",
|
||||||
"no_request_found": "Request not found.",
|
"no_request_found": "Request not found.",
|
||||||
"not_found": "Team not found. Contact your team owner.",
|
"not_found": "Team not found. Contact your team owner.",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"choose_file": "選擇一個檔案",
|
"choose_file": "選擇一個檔案",
|
||||||
"clear": "清除",
|
"clear": "清除",
|
||||||
"clear_all": "全部清除",
|
"clear_all": "全部清除",
|
||||||
"clear_history": "Clear all History",
|
"clear_history": "清除所有歷史記錄",
|
||||||
"close": "關閉",
|
"close": "關閉",
|
||||||
"connect": "連線",
|
"connect": "連線",
|
||||||
"connecting": "正在連接",
|
"connecting": "正在連接",
|
||||||
@@ -79,8 +79,8 @@
|
|||||||
"search": "搜尋",
|
"search": "搜尋",
|
||||||
"share": "分享",
|
"share": "分享",
|
||||||
"shortcuts": "快捷方式",
|
"shortcuts": "快捷方式",
|
||||||
"social_description": "Follow us on social media to stay updated with the latest news, updates and releases.",
|
"social_description": "在社交媒體上追蹤我們即可在第一時間得知新聞、更新、以及新版本的消息。",
|
||||||
"social_links": "Social links",
|
"social_links": "社群連結",
|
||||||
"spotlight": "聚光燈",
|
"spotlight": "聚光燈",
|
||||||
"status": "狀態",
|
"status": "狀態",
|
||||||
"status_description": "檢查網站狀態",
|
"status_description": "檢查網站狀態",
|
||||||
@@ -135,15 +135,15 @@
|
|||||||
"renamed": "集合已重新命名",
|
"renamed": "集合已重新命名",
|
||||||
"request_in_use": "請求正在使用中",
|
"request_in_use": "請求正在使用中",
|
||||||
"save_as": "另存為",
|
"save_as": "另存為",
|
||||||
"save_to_collection": "Save to Collection",
|
"save_to_collection": "儲存到集合",
|
||||||
"select": "選擇一個集合",
|
"select": "選擇一個集合",
|
||||||
"select_location": "選擇位置",
|
"select_location": "選擇位置",
|
||||||
"select_team": "選擇一個團隊",
|
"select_team": "選擇一個團隊",
|
||||||
"team_collections": "團隊集合"
|
"team_collections": "團隊集合"
|
||||||
},
|
},
|
||||||
"confirm": {
|
"confirm": {
|
||||||
"close_unsaved_tab": "Are you sure you want to close this tab?",
|
"close_unsaved_tab": "您確定要關閉此分頁嗎?",
|
||||||
"close_unsaved_tabs": "Are you sure you want to close all tabs? {count} unsaved tabs will be lost.",
|
"close_unsaved_tabs": "您確定要關閉所有分頁嗎?{count} 個未儲存的分頁將會遺失。",
|
||||||
"exit_team": "您確定要離開此團隊嗎?",
|
"exit_team": "您確定要離開此團隊嗎?",
|
||||||
"logout": "您確定要登出嗎?",
|
"logout": "您確定要登出嗎?",
|
||||||
"remove_collection": "您確定要永久刪除該集合嗎?",
|
"remove_collection": "您確定要永久刪除該集合嗎?",
|
||||||
@@ -158,9 +158,9 @@
|
|||||||
"sync": "您想從雲端恢復您的工作區嗎?這將丟棄您的本地進度。"
|
"sync": "您想從雲端恢復您的工作區嗎?這將丟棄您的本地進度。"
|
||||||
},
|
},
|
||||||
"context_menu": {
|
"context_menu": {
|
||||||
"add_parameters": "Add to parameters",
|
"add_parameters": "新增至參數",
|
||||||
"open_request_in_new_tab": "Open request in new tab",
|
"open_request_in_new_tab": "在新分頁開啟請求",
|
||||||
"set_environment_variable": "Set as variable"
|
"set_environment_variable": "設為變數"
|
||||||
},
|
},
|
||||||
"count": {
|
"count": {
|
||||||
"header": "請求標頭 {count}",
|
"header": "請求標頭 {count}",
|
||||||
@@ -204,31 +204,31 @@
|
|||||||
"create_new": "建立新環境",
|
"create_new": "建立新環境",
|
||||||
"created": "已建立環境",
|
"created": "已建立環境",
|
||||||
"deleted": "刪除環境",
|
"deleted": "刪除環境",
|
||||||
"duplicated": "Environment duplicated",
|
"duplicated": "已複製環境",
|
||||||
"edit": "編輯環境",
|
"edit": "編輯環境",
|
||||||
"empty_variables": "No variables",
|
"empty_variables": "無變數",
|
||||||
"global": "Global",
|
"global": "全域",
|
||||||
"global_variables": "Global variables",
|
"global_variables": "全域變數",
|
||||||
"invalid_name": "請提供有效的環境名稱",
|
"invalid_name": "請提供有效的環境名稱",
|
||||||
"list": "Environment variables",
|
"list": "環境變數",
|
||||||
"my_environments": "我的環境",
|
"my_environments": "我的環境",
|
||||||
"name": "Name",
|
"name": "名稱",
|
||||||
"nested_overflow": "巢狀環境變數不得大於 10 層",
|
"nested_overflow": "巢狀環境變數不得大於 10 層",
|
||||||
"new": "建立環境",
|
"new": "建立環境",
|
||||||
"no_active_environment": "No active environment",
|
"no_active_environment": "無使用中的環境",
|
||||||
"no_environment": "無環境",
|
"no_environment": "無環境",
|
||||||
"no_environment_description": "未選取任何環境。請選擇要對以下變數進行的動作。",
|
"no_environment_description": "未選取任何環境。請選擇要對以下變數進行的動作。",
|
||||||
"quick_peek": "Environment Quick Peek",
|
"quick_peek": "快速預覽環境",
|
||||||
"replace_with_variable": "Replace with variable",
|
"replace_with_variable": "以變數替代",
|
||||||
"scope": "Scope",
|
"scope": "範圍",
|
||||||
"select": "選擇環境",
|
"select": "選擇環境",
|
||||||
"set": "Set environment",
|
"set": "設定環境",
|
||||||
"set_as_environment": "Set as environment",
|
"set_as_environment": "設為環境",
|
||||||
"team_environments": "團隊環境",
|
"team_environments": "團隊環境",
|
||||||
"title": "環境",
|
"title": "環境",
|
||||||
"updated": "更新環境",
|
"updated": "更新環境",
|
||||||
"value": "Value",
|
"value": "數值",
|
||||||
"variable": "Variable",
|
"variable": "變數",
|
||||||
"variable_list": "變數列表"
|
"variable_list": "變數列表"
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
@@ -252,7 +252,7 @@
|
|||||||
"no_duration": "無持續時間",
|
"no_duration": "無持續時間",
|
||||||
"no_results_found": "找不到結果",
|
"no_results_found": "找不到結果",
|
||||||
"page_not_found": "找不到此頁面",
|
"page_not_found": "找不到此頁面",
|
||||||
"proxy_error": "Proxy error",
|
"proxy_error": "Proxy 錯誤",
|
||||||
"script_fail": "無法執行預請求指令碼",
|
"script_fail": "無法執行預請求指令碼",
|
||||||
"something_went_wrong": "發生了一些錯誤",
|
"something_went_wrong": "發生了一些錯誤",
|
||||||
"test_script_fail": "無法執行測試指令碼"
|
"test_script_fail": "無法執行測試指令碼"
|
||||||
@@ -278,13 +278,13 @@
|
|||||||
"renamed": "資料夾已重新命名"
|
"renamed": "資料夾已重新命名"
|
||||||
},
|
},
|
||||||
"graphql": {
|
"graphql": {
|
||||||
"connection_switch_confirm": "Do you want to connect with the latest GraphQL endpoint?",
|
"connection_switch_confirm": "您要使用最新的 GraphQL 端點連線嗎?",
|
||||||
"connection_switch_new_url": "Switching to a tab will disconnected you from the active GraphQL connection. New connection URL is",
|
"connection_switch_new_url": "切換至分頁將斷開使用中的 GraphQL 連線。新的連線網址為 ",
|
||||||
"connection_switch_url": "You're connected to a GraphQL endpoint the connection URL is",
|
"connection_switch_url": "您已連接至 GraphQL 端點。連線網址為 ",
|
||||||
"mutations": "變體",
|
"mutations": "變體",
|
||||||
"schema": "綱要",
|
"schema": "綱要",
|
||||||
"subscriptions": "訂閱",
|
"subscriptions": "訂閱",
|
||||||
"switch_connection": "Switch connection"
|
"switch_connection": "切換連線"
|
||||||
},
|
},
|
||||||
"group": {
|
"group": {
|
||||||
"time": "時間",
|
"time": "時間",
|
||||||
@@ -339,27 +339,27 @@
|
|||||||
"title": "匯入"
|
"title": "匯入"
|
||||||
},
|
},
|
||||||
"inspections": {
|
"inspections": {
|
||||||
"description": "Inspect possible errors",
|
"description": "檢查潛在錯誤",
|
||||||
"environment": {
|
"environment": {
|
||||||
"add_environment": "Add to Environment",
|
"add_environment": "新增至環境",
|
||||||
"not_found": "Environment variable “{environment}” not found."
|
"not_found": "找不到環境變數 “{environment}”。"
|
||||||
},
|
},
|
||||||
"header": {
|
"header": {
|
||||||
"cookie": "The browser doesn't allow Hoppscotch to set the Cookie Header. While we're working on the Hoppscotch Desktop App (coming soon), please use the Authorization Header instead."
|
"cookie": "瀏覽器不允許 Hoppscotch 設定 Cookie 標頭。在我們推出 Hoppscotch 桌面版前,請先使用 Authorization 標頭。"
|
||||||
},
|
},
|
||||||
"response": {
|
"response": {
|
||||||
"401_error": "Please check your authentication credentials.",
|
"401_error": "請檢查您的授權認證。",
|
||||||
"404_error": "Please check your request URL and method type.",
|
"404_error": "請檢查您的請求網址和方式類型。",
|
||||||
"cors_error": "Please check your Cross-Origin Resource Sharing configuration.",
|
"cors_error": "請檢查您的跨來源資源共用設定。",
|
||||||
"default_error": "Please check your request.",
|
"default_error": "請檢查您的請求。",
|
||||||
"network_error": "Please check your network connection."
|
"network_error": "請檢查您的網路連線。"
|
||||||
},
|
},
|
||||||
"title": "Inspector",
|
"title": "檢查工具",
|
||||||
"url": {
|
"url": {
|
||||||
"extension_not_installed": "Extension not installed.",
|
"extension_not_installed": "未安裝擴充套件。",
|
||||||
"extension_unknown_origin": "Make sure you've added the API endpoint's origin to the Hoppscotch Browser Extension list.",
|
"extension_unknown_origin": "請確認您是否已將 API 端點的來源加入 Hoppscotch 擴充套件的清單。",
|
||||||
"extention_enable_action": "Enable Browser Extension",
|
"extention_enable_action": "啟用瀏覽器擴充套件",
|
||||||
"extention_not_enabled": "Extension not enabled."
|
"extention_not_enabled": "未啟用擴充套件。"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"layout": {
|
"layout": {
|
||||||
@@ -472,7 +472,7 @@
|
|||||||
"payload": "負載",
|
"payload": "負載",
|
||||||
"query": "查詢",
|
"query": "查詢",
|
||||||
"raw_body": "原始請求本體",
|
"raw_body": "原始請求本體",
|
||||||
"rename": "Rename Request",
|
"rename": "重新命名請求",
|
||||||
"renamed": "請求已重新命名",
|
"renamed": "請求已重新命名",
|
||||||
"run": "執行",
|
"run": "執行",
|
||||||
"save": "儲存",
|
"save": "儲存",
|
||||||
@@ -510,7 +510,7 @@
|
|||||||
"accent_color": "強調色",
|
"accent_color": "強調色",
|
||||||
"account": "帳號",
|
"account": "帳號",
|
||||||
"account_deleted": "已刪除您的帳號",
|
"account_deleted": "已刪除您的帳號",
|
||||||
"account_description": "自定義您的帳號設定。",
|
"account_description": "自訂您的帳號設定。",
|
||||||
"account_email_description": "您的主要電子郵件地址。",
|
"account_email_description": "您的主要電子郵件地址。",
|
||||||
"account_name_description": "這是您的顯示名稱。",
|
"account_name_description": "這是您的顯示名稱。",
|
||||||
"background": "背景",
|
"background": "背景",
|
||||||
@@ -542,7 +542,7 @@
|
|||||||
"read_the": "閱讀",
|
"read_the": "閱讀",
|
||||||
"reset_default": "重置為預設",
|
"reset_default": "重置為預設",
|
||||||
"short_codes": "快捷碼",
|
"short_codes": "快捷碼",
|
||||||
"short_codes_description": "我們為您打造的快捷碼。",
|
"short_codes_description": "您建立的快捷碼。",
|
||||||
"sidebar_on_left": "左側邊欄",
|
"sidebar_on_left": "左側邊欄",
|
||||||
"sync": "同步",
|
"sync": "同步",
|
||||||
"sync_collections": "集合",
|
"sync_collections": "集合",
|
||||||
@@ -551,9 +551,9 @@
|
|||||||
"sync_history": "歷史",
|
"sync_history": "歷史",
|
||||||
"system_mode": "系統",
|
"system_mode": "系統",
|
||||||
"telemetry": "遙測服務",
|
"telemetry": "遙測服務",
|
||||||
"telemetry_helps_us": "遙測服務幫助我們進行個性化操作,為您提供最佳體驗。",
|
"telemetry_helps_us": "遙測服務能夠幫助我們進行個人化操作,為您提供最佳體驗。",
|
||||||
"theme": "主題",
|
"theme": "主題",
|
||||||
"theme_description": "自定義您的應用程式主題。",
|
"theme_description": "自訂您的應用程式主題。",
|
||||||
"use_experimental_url_bar": "使用帶有環境醒目標示的實驗性網址欄",
|
"use_experimental_url_bar": "使用帶有環境醒目標示的實驗性網址欄",
|
||||||
"user": "使用者",
|
"user": "使用者",
|
||||||
"verified_email": "已確認電子郵件地址",
|
"verified_email": "已確認電子郵件地址",
|
||||||
@@ -592,26 +592,26 @@
|
|||||||
"title": "導航"
|
"title": "導航"
|
||||||
},
|
},
|
||||||
"others": {
|
"others": {
|
||||||
"prettify": "Prettify Editor's Content",
|
"prettify": "美化編輯器的內容",
|
||||||
"title": "Others"
|
"title": "其他"
|
||||||
},
|
},
|
||||||
"request": {
|
"request": {
|
||||||
"copy_request_link": "複製請求連結",
|
"copy_request_link": "複製請求連結",
|
||||||
"delete_method": "選擇 DELETE 方法",
|
"delete_method": "選擇 DELETE 方法",
|
||||||
"get_method": "選擇 GET 方法",
|
"get_method": "選擇 GET 方法",
|
||||||
"head_method": "選擇 HEAD 方法",
|
"head_method": "選擇 HEAD 方法",
|
||||||
"import_curl": "Import cURL",
|
"import_curl": "匯入 cURL",
|
||||||
"method": "方法",
|
"method": "方法",
|
||||||
"next_method": "選擇下一個方法",
|
"next_method": "選擇下一個方法",
|
||||||
"post_method": "選擇 POST 方法",
|
"post_method": "選擇 POST 方法",
|
||||||
"previous_method": "選擇上一個方法",
|
"previous_method": "選擇上一個方法",
|
||||||
"put_method": "選擇 PUT 方法",
|
"put_method": "選擇 PUT 方法",
|
||||||
"rename": "Rename Request",
|
"rename": "重新命名請求",
|
||||||
"reset_request": "重置請求",
|
"reset_request": "重置請求",
|
||||||
"save_request": "Save Request",
|
"save_request": "儲存請求",
|
||||||
"save_to_collections": "儲存到集合",
|
"save_to_collections": "儲存到集合",
|
||||||
"send_request": "傳送請求",
|
"send_request": "傳送請求",
|
||||||
"show_code": "Generate code snippet",
|
"show_code": "產生程式碼片段",
|
||||||
"title": "請求"
|
"title": "請求"
|
||||||
},
|
},
|
||||||
"response": {
|
"response": {
|
||||||
@@ -642,82 +642,82 @@
|
|||||||
"url": "網址"
|
"url": "網址"
|
||||||
},
|
},
|
||||||
"spotlight": {
|
"spotlight": {
|
||||||
"change_language": "Change Language",
|
"change_language": "變更語言",
|
||||||
"environments": {
|
"environments": {
|
||||||
"delete": "Delete current environment",
|
"delete": "刪除目前環境",
|
||||||
"duplicate": "Duplicate current environment",
|
"duplicate": "複製目前環境",
|
||||||
"duplicate_global": "Duplicate global environment",
|
"duplicate_global": "複製全域環境",
|
||||||
"edit": "Edit current environment",
|
"edit": "編輯目前環境",
|
||||||
"edit_global": "Edit global environment",
|
"edit_global": "編輯全域環境",
|
||||||
"new": "Create new environment",
|
"new": "建立新環境",
|
||||||
"new_variable": "Create a new environment variable",
|
"new_variable": "建立新環境變數",
|
||||||
"title": "Environments"
|
"title": "環境"
|
||||||
},
|
},
|
||||||
"general": {
|
"general": {
|
||||||
"chat": "Chat with support",
|
"chat": "與客服對話",
|
||||||
"help_menu": "Help and support",
|
"help_menu": "幫助與支援",
|
||||||
"open_docs": "Read Documentation",
|
"open_docs": "閱讀說明文件",
|
||||||
"open_github": "Open GitHub repository",
|
"open_github": "開啟 GitHub 儲存庫",
|
||||||
"open_keybindings": "Keyboard shortcuts",
|
"open_keybindings": "鍵盤快捷鍵",
|
||||||
"social": "Social",
|
"social": "社交",
|
||||||
"title": "General"
|
"title": "一般"
|
||||||
},
|
},
|
||||||
"graphql": {
|
"graphql": {
|
||||||
"connect": "Connect to server",
|
"connect": "連接至伺服器",
|
||||||
"disconnect": "Disconnect from server"
|
"disconnect": "斷開與伺服器的連線"
|
||||||
},
|
},
|
||||||
"miscellaneous": {
|
"miscellaneous": {
|
||||||
"invite": "Invite your friends to Hoppscotch",
|
"invite": "邀請您的朋友使用 Hoppscotch",
|
||||||
"title": "Miscellaneous"
|
"title": "雜項"
|
||||||
},
|
},
|
||||||
"request": {
|
"request": {
|
||||||
"save_as_new": "Save as new request",
|
"save_as_new": "儲存為新請求",
|
||||||
"select_method": "Select method",
|
"select_method": "選擇方法",
|
||||||
"switch_to": "Switch to",
|
"switch_to": "切換至",
|
||||||
"tab_authorization": "Authorization tab",
|
"tab_authorization": "授權分頁",
|
||||||
"tab_body": "Body tab",
|
"tab_body": "本體分頁",
|
||||||
"tab_headers": "Headers tab",
|
"tab_headers": "標頭分頁",
|
||||||
"tab_parameters": "Parameters tab",
|
"tab_parameters": "參數分頁",
|
||||||
"tab_pre_request_script": "Pre-request script tab",
|
"tab_pre_request_script": "預請求腳本分頁",
|
||||||
"tab_query": "Query tab",
|
"tab_query": "查詢分頁",
|
||||||
"tab_tests": "Tests tab",
|
"tab_tests": "測試分頁",
|
||||||
"tab_variables": "Variables tab"
|
"tab_variables": "變數分頁"
|
||||||
},
|
},
|
||||||
"response": {
|
"response": {
|
||||||
"copy": "Copy response",
|
"copy": "複製回應",
|
||||||
"download": "Download response as file",
|
"download": "下載回應",
|
||||||
"title": "Response"
|
"title": "回應"
|
||||||
},
|
},
|
||||||
"section": {
|
"section": {
|
||||||
"interceptor": "Interceptor",
|
"interceptor": "攔截器",
|
||||||
"interface": "Interface",
|
"interface": "介面",
|
||||||
"theme": "Theme",
|
"theme": "主題",
|
||||||
"user": "User"
|
"user": "使用者"
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
"change_interceptor": "Change Interceptor",
|
"change_interceptor": "變更攔截器",
|
||||||
"change_language": "Change Language",
|
"change_language": "變更語言",
|
||||||
"theme": {
|
"theme": {
|
||||||
"black": "Black",
|
"black": "黑色",
|
||||||
"dark": "Dark",
|
"dark": "暗色",
|
||||||
"light": "Light",
|
"light": "亮色",
|
||||||
"system": "System preference"
|
"system": "跟隨系統"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tab": {
|
"tab": {
|
||||||
"close_current": "Close current tab",
|
"close_current": "關閉目前分頁",
|
||||||
"close_others": "Close all other tabs",
|
"close_others": "關閉所有其他分頁",
|
||||||
"duplicate": "Duplicate current tab",
|
"duplicate": "複製目前分頁",
|
||||||
"new_tab": "Open a new tab",
|
"new_tab": "開啟新分頁",
|
||||||
"title": "Tabs"
|
"title": "分頁"
|
||||||
},
|
},
|
||||||
"workspace": {
|
"workspace": {
|
||||||
"delete": "Delete current team",
|
"delete": "刪除目前團隊",
|
||||||
"edit": "Edit current team",
|
"edit": "編輯目前團隊",
|
||||||
"invite": "Invite people to team",
|
"invite": "邀請他人加入團隊",
|
||||||
"new": "Create new team",
|
"new": "建立新團隊",
|
||||||
"switch_to_personal": "Switch to your personal workspace",
|
"switch_to_personal": "切換至您的個人工作區",
|
||||||
"title": "Teams"
|
"title": "團隊"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sse": {
|
"sse": {
|
||||||
@@ -777,11 +777,11 @@
|
|||||||
"tab": {
|
"tab": {
|
||||||
"authorization": "授權",
|
"authorization": "授權",
|
||||||
"body": "請求本體",
|
"body": "請求本體",
|
||||||
"close": "Close Tab",
|
"close": "關閉分頁",
|
||||||
"close_others": "Close other Tabs",
|
"close_others": "關閉其他分頁",
|
||||||
"collections": "集合",
|
"collections": "集合",
|
||||||
"documentation": "幫助文件",
|
"documentation": "幫助文件",
|
||||||
"duplicate": "Duplicate Tab",
|
"duplicate": "複製分頁",
|
||||||
"environments": "環境",
|
"environments": "環境",
|
||||||
"headers": "請求標頭",
|
"headers": "請求標頭",
|
||||||
"history": "歷史記錄",
|
"history": "歷史記錄",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@hoppscotch/common",
|
"name": "@hoppscotch/common",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "2023.8.1",
|
"version": "2023.8.4-1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "pnpm exec npm-run-all -p -l dev:*",
|
"dev": "pnpm exec npm-run-all -p -l dev:*",
|
||||||
"test": "vitest --run",
|
"test": "vitest --run",
|
||||||
@@ -17,51 +17,46 @@
|
|||||||
"postinstall": "pnpm run gql-codegen",
|
"postinstall": "pnpm run gql-codegen",
|
||||||
"do-test": "pnpm run test",
|
"do-test": "pnpm run test",
|
||||||
"do-lint": "pnpm run prod-lint",
|
"do-lint": "pnpm run prod-lint",
|
||||||
"do-typecheck": "pnpm run lint",
|
"do-typecheck": "node type-check.mjs",
|
||||||
"do-lintfix": "pnpm run lintfix"
|
"do-lintfix": "pnpm run lintfix"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apidevtools/swagger-parser": "^10.1.0",
|
"@apidevtools/swagger-parser": "^10.1.0",
|
||||||
"@codemirror/autocomplete": "^6.9.0",
|
"@codemirror/autocomplete": "^6.11.0",
|
||||||
"@codemirror/commands": "^6.2.4",
|
"@codemirror/commands": "^6.3.0",
|
||||||
"@codemirror/lang-javascript": "^6.1.9",
|
"@codemirror/lang-javascript": "^6.2.1",
|
||||||
"@codemirror/lang-json": "^6.0.1",
|
"@codemirror/lang-json": "^6.0.1",
|
||||||
"@codemirror/lang-xml": "^6.0.2",
|
"@codemirror/lang-xml": "^6.0.2",
|
||||||
"@codemirror/language": "^6.9.0",
|
"@codemirror/language": "6.9.2",
|
||||||
"@codemirror/legacy-modes": "^6.3.3",
|
"@codemirror/legacy-modes": "^6.3.3",
|
||||||
"@codemirror/lint": "^6.4.0",
|
"@codemirror/lint": "^6.4.2",
|
||||||
"@codemirror/search": "^6.5.1",
|
"@codemirror/search": "^6.5.4",
|
||||||
"@codemirror/state": "^6.2.1",
|
"@codemirror/state": "^6.3.1",
|
||||||
"@codemirror/view": "^6.16.0",
|
"@codemirror/view": "^6.22.0",
|
||||||
"@fontsource-variable/inter": "^5.0.8",
|
|
||||||
"@fontsource-variable/material-symbols-rounded": "^5.0.7",
|
|
||||||
"@fontsource-variable/roboto-mono": "^5.0.9",
|
|
||||||
"@hoppscotch/codemirror-lang-graphql": "workspace:^",
|
"@hoppscotch/codemirror-lang-graphql": "workspace:^",
|
||||||
"@hoppscotch/data": "workspace:^",
|
"@hoppscotch/data": "workspace:^",
|
||||||
"@hoppscotch/js-sandbox": "workspace:^",
|
"@hoppscotch/js-sandbox": "workspace:^",
|
||||||
"@hoppscotch/ui": "workspace:^",
|
"@hoppscotch/ui": "workspace:^",
|
||||||
"@hoppscotch/vue-toasted": "^0.1.0",
|
"@hoppscotch/vue-toasted": "^0.1.0",
|
||||||
"@lezer/highlight": "^1.1.6",
|
"@lezer/highlight": "1.2.0",
|
||||||
"@sentry/tracing": "^7.64.0",
|
"@unhead/vue": "^1.8.8",
|
||||||
"@sentry/vue": "^7.64.0",
|
"@urql/core": "^4.2.0",
|
||||||
"@urql/core": "^4.1.1",
|
|
||||||
"@urql/devtools": "^2.0.3",
|
"@urql/devtools": "^2.0.3",
|
||||||
"@urql/exchange-auth": "^2.1.6",
|
"@urql/exchange-auth": "^2.1.6",
|
||||||
"@urql/exchange-graphcache": "^6.3.2",
|
"@urql/exchange-graphcache": "^6.3.3",
|
||||||
"@vitejs/plugin-legacy": "^4.1.1",
|
"@vitejs/plugin-legacy": "^4.1.1",
|
||||||
"@vueuse/core": "^10.3.0",
|
"@vueuse/core": "^10.6.1",
|
||||||
"@vueuse/head": "^1.3.1",
|
"acorn-walk": "^8.3.0",
|
||||||
"acorn-walk": "^8.2.0",
|
"axios": "^1.6.2",
|
||||||
"axios": "^1.4.0",
|
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
|
"cookie-es": "^1.0.0",
|
||||||
"dioc": "workspace:^",
|
"dioc": "workspace:^",
|
||||||
"esprima": "^4.0.1",
|
"esprima": "^4.0.1",
|
||||||
"events": "^3.3.0",
|
"events": "^3.3.0",
|
||||||
"fp-ts": "^2.16.1",
|
"fp-ts": "^2.16.1",
|
||||||
"fuse.js": "^6.6.2",
|
|
||||||
"globalthis": "^1.0.3",
|
"globalthis": "^1.0.3",
|
||||||
"graphql": "^16.8.0",
|
"graphql": "^16.8.1",
|
||||||
"graphql-language-service-interface": "^2.9.1",
|
"graphql-language-service-interface": "^2.10.2",
|
||||||
"graphql-tag": "^2.12.6",
|
"graphql-tag": "^2.12.6",
|
||||||
"httpsnippet": "^3.0.1",
|
"httpsnippet": "^3.0.1",
|
||||||
"insomnia-importers": "^3.6.0",
|
"insomnia-importers": "^3.6.0",
|
||||||
@@ -69,15 +64,18 @@
|
|||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"jsonpath-plus": "^7.2.0",
|
"jsonpath-plus": "^7.2.0",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"lossless-json": "^2.0.11",
|
"lossless-json": "^3.0.2",
|
||||||
"minisearch": "^6.1.0",
|
"minisearch": "^6.3.0",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
"paho-mqtt": "^1.1.0",
|
"paho-mqtt": "^1.1.0",
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
"postman-collection": "^4.2.0",
|
"postman-collection": "^4.3.0",
|
||||||
"process": "^0.11.10",
|
"process": "^0.11.10",
|
||||||
"qs": "^6.11.2",
|
"qs": "^6.11.2",
|
||||||
|
"quicktype-core": "^23.0.79",
|
||||||
"rxjs": "^7.8.1",
|
"rxjs": "^7.8.1",
|
||||||
|
"set-cookie-parser": "^2.6.0",
|
||||||
|
"set-cookie-parser-es": "^1.0.5",
|
||||||
"socket.io-client-v2": "npm:socket.io-client@^2.4.0",
|
"socket.io-client-v2": "npm:socket.io-client@^2.4.0",
|
||||||
"socket.io-client-v3": "npm:socket.io-client@^3.1.3",
|
"socket.io-client-v3": "npm:socket.io-client@^3.1.3",
|
||||||
"socket.io-client-v4": "npm:socket.io-client@^4.4.1",
|
"socket.io-client-v4": "npm:socket.io-client@^4.4.1",
|
||||||
@@ -88,19 +86,21 @@
|
|||||||
"tern": "^0.24.3",
|
"tern": "^0.24.3",
|
||||||
"timers": "^0.1.1",
|
"timers": "^0.1.1",
|
||||||
"tippy.js": "^6.3.7",
|
"tippy.js": "^6.3.7",
|
||||||
"url": "^0.11.1",
|
"url": "^0.11.3",
|
||||||
"util": "^0.12.5",
|
"util": "^0.12.5",
|
||||||
"uuid": "^9.0.0",
|
"verzod": "^0.2.0",
|
||||||
"vue": "^3.3.4",
|
"uuid": "^9.0.1",
|
||||||
"vue-i18n": "^9.2.2",
|
"vue": "^3.3.8",
|
||||||
"vue-pdf-embed": "^1.1.6",
|
"vue-i18n": "^9.7.1",
|
||||||
"vue-router": "^4.2.4",
|
"vue-pdf-embed": "^1.2.1",
|
||||||
|
"vue-router": "^4.2.5",
|
||||||
"vue-tippy": "6.3.1",
|
"vue-tippy": "6.3.1",
|
||||||
"vuedraggable-es": "^4.1.1",
|
"vuedraggable-es": "^4.1.1",
|
||||||
"wonka": "^6.3.4",
|
"wonka": "^6.3.4",
|
||||||
"workbox-window": "^7.0.0",
|
"workbox-window": "^7.0.0",
|
||||||
"xml-formatter": "^3.5.0",
|
"xml-formatter": "^3.6.0",
|
||||||
"yargs-parser": "^21.1.1"
|
"yargs-parser": "^21.1.1",
|
||||||
|
"zod": "^3.22.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
|
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
|
||||||
@@ -110,53 +110,58 @@
|
|||||||
"@graphql-codegen/typed-document-node": "^5.0.1",
|
"@graphql-codegen/typed-document-node": "^5.0.1",
|
||||||
"@graphql-codegen/typescript": "^4.0.1",
|
"@graphql-codegen/typescript": "^4.0.1",
|
||||||
"@graphql-codegen/typescript-operations": "^4.0.1",
|
"@graphql-codegen/typescript-operations": "^4.0.1",
|
||||||
"@graphql-codegen/typescript-urql-graphcache": "^2.4.5",
|
"@graphql-codegen/typescript-urql-graphcache": "^3.0.0",
|
||||||
"@graphql-codegen/urql-introspection": "^2.2.1",
|
"@graphql-codegen/urql-introspection": "^3.0.0",
|
||||||
"@graphql-typed-document-node/core": "^3.2.0",
|
"@graphql-typed-document-node/core": "^3.2.0",
|
||||||
"@iconify-json/lucide": "^1.1.119",
|
"@iconify-json/lucide": "^1.1.141",
|
||||||
"@intlify/vite-plugin-vue-i18n": "^7.0.0",
|
"@intlify/vite-plugin-vue-i18n": "^7.0.0",
|
||||||
"@relmify/jest-fp-ts": "^2.1.1",
|
"@relmify/jest-fp-ts": "^2.1.1",
|
||||||
"@rushstack/eslint-patch": "^1.3.3",
|
"@rushstack/eslint-patch": "^1.6.0",
|
||||||
"@types/har-format": "^1.2.12",
|
"@types/har-format": "^1.2.15",
|
||||||
"@types/js-yaml": "^4.0.5",
|
"@types/js-yaml": "^4.0.9",
|
||||||
"@types/lodash-es": "^4.17.8",
|
"@types/lodash-es": "^4.17.12",
|
||||||
"@types/lossless-json": "^1.0.1",
|
"@types/lossless-json": "^1.0.4",
|
||||||
"@types/nprogress": "^0.2.0",
|
"@types/nprogress": "^0.2.3",
|
||||||
"@types/paho-mqtt": "^1.0.7",
|
"@types/paho-mqtt": "^1.0.10",
|
||||||
"@types/postman-collection": "^3.5.7",
|
"@types/postman-collection": "^3.5.10",
|
||||||
"@types/splitpanes": "^2.2.1",
|
"@types/splitpanes": "^2.2.6",
|
||||||
"@types/uuid": "^9.0.2",
|
"@types/uuid": "^9.0.7",
|
||||||
"@types/yargs-parser": "^21.0.0",
|
"@types/yargs-parser": "^21.0.3",
|
||||||
"@typescript-eslint/eslint-plugin": "^6.4.0",
|
"@typescript-eslint/eslint-plugin": "^6.12.0",
|
||||||
"@typescript-eslint/parser": "^6.4.0",
|
"@typescript-eslint/parser": "^6.12.0",
|
||||||
"@vitejs/plugin-vue": "^4.3.1",
|
"@vitejs/plugin-vue": "^4.5.0",
|
||||||
"@vue/compiler-sfc": "^3.3.4",
|
"@vue/compiler-sfc": "^3.3.8",
|
||||||
"@vue/eslint-config-typescript": "^11.0.3",
|
"@vue/eslint-config-typescript": "^12.0.0",
|
||||||
"@vue/runtime-core": "^3.3.4",
|
"@vue/runtime-core": "^3.3.8",
|
||||||
|
"autoprefixer": "^10.4.14",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"dotenv": "^16.3.1",
|
"dotenv": "^16.3.1",
|
||||||
"eslint": "^8.47.0",
|
"eslint": "^8.54.0",
|
||||||
"eslint-plugin-prettier": "^5.0.0",
|
"eslint-plugin-prettier": "^5.0.1",
|
||||||
"eslint-plugin-vue": "^9.17.0",
|
"eslint-plugin-vue": "^9.18.1",
|
||||||
|
"glob": "^10.3.10",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"openapi-types": "^12.1.3",
|
"openapi-types": "^12.1.3",
|
||||||
"rollup-plugin-polyfill-node": "^0.12.0",
|
"postcss": "^8.4.23",
|
||||||
"sass": "^1.66.0",
|
"prettier": "^3.1.0",
|
||||||
"typescript": "^5.1.6",
|
"prettier-plugin-tailwindcss": "^0.5.7",
|
||||||
"unplugin-fonts": "^1.0.3",
|
"rollup-plugin-polyfill-node": "^0.13.0",
|
||||||
"unplugin-icons": "^0.16.5",
|
"sass": "^1.69.5",
|
||||||
"unplugin-vue-components": "^0.25.1",
|
"tailwindcss": "^3.3.2",
|
||||||
"vite": "^4.4.9",
|
"typescript": "^5.3.2",
|
||||||
"vite-plugin-checker": "^0.6.1",
|
"unplugin-fonts": "^1.1.1",
|
||||||
|
"unplugin-icons": "^0.17.4",
|
||||||
|
"unplugin-vue-components": "^0.25.2",
|
||||||
|
"vite": "^4.5.0",
|
||||||
|
"vite-plugin-checker": "^0.6.2",
|
||||||
|
"vite-plugin-fonts": "^0.7.0",
|
||||||
"vite-plugin-html-config": "^1.0.11",
|
"vite-plugin-html-config": "^1.0.11",
|
||||||
"vite-plugin-inspect": "^0.7.38",
|
"vite-plugin-inspect": "^0.7.42",
|
||||||
"vite-plugin-pages": "^0.31.0",
|
"vite-plugin-pages": "^0.31.0",
|
||||||
"vite-plugin-pages-sitemap": "^1.6.1",
|
"vite-plugin-pages-sitemap": "^1.6.1",
|
||||||
"vite-plugin-pwa": "^0.16.4",
|
"vite-plugin-pwa": "^0.17.0",
|
||||||
"vite-plugin-vue-layouts": "^0.8.0",
|
"vite-plugin-vue-layouts": "^0.8.0",
|
||||||
"vite-plugin-windicss": "^1.9.1",
|
"vitest": "^0.34.6",
|
||||||
"vitest": "^0.34.2",
|
"vue-tsc": "^1.8.22"
|
||||||
"vue-tsc": "^1.8.8",
|
|
||||||
"windicss": "^3.5.6"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
1
packages/hoppscotch-common/public/badge-dark.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="156" height="32" fill="none"><rect width="156" height="32" fill="#000" rx="4"/><text xmlns="http://www.w3.org/2000/svg" x="50%" y="50%" fill="#fff" dominant-baseline="central" font-family="Helvetica,sans-serif" font-size="12" font-weight="bold" text-anchor="middle" text-rendering="geometricPrecision">▶ Run in Hoppscotch</text></svg>
|
||||||
|
After Width: | Height: | Size: 386 B |
1
packages/hoppscotch-common/public/badge-light.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="156" height="32" fill="none"><rect width="156" height="32" fill="#fff" rx="4"/><text xmlns="http://www.w3.org/2000/svg" x="50%" y="50%" fill="#000" dominant-baseline="central" font-family="Helvetica,sans-serif" font-size="12" font-weight="bold" text-anchor="middle" text-rendering="geometricPrecision">▶ Run in Hoppscotch</text></svg>
|
||||||
|
After Width: | Height: | Size: 386 B |
|
Before Width: | Height: | Size: 926 KiB After Width: | Height: | Size: 354 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 124 KiB |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 462 KiB |
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 400 B After Width: | Height: | Size: 624 B |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 871 B After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 124 KiB |
|
Before Width: | Height: | Size: 510 KiB After Width: | Height: | Size: 360 KiB |
|
Before Width: | Height: | Size: 535 KiB After Width: | Height: | Size: 385 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 178 KiB |
@@ -1 +1,50 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" fill="none"><path fill="#10B981" d="M0 0h512v512H0z"/><circle cx="197.76" cy="157.84" r="10" fill="#fff" fill-opacity=".75"/><circle cx="259.76" cy="161.84" r="12" fill="#fff" fill-opacity=".75"/><circle cx="319.76" cy="177.84" r="10" fill="#fff" fill-opacity=".75"/><path d="M344.963 235.676c2.075-12.698-38.872-29.804-90.967-38.094-52.09-8.296-96.404-4.665-98.48 8.033-.257 1.035 0 1.812.263 2.853-1.298-.521-76.714 211.212-76.714 211.212H364.14s-17.621-181.414-20.211-181.414c.515-.772 1.035-1.549 1.035-2.59Z" fill="url(#a)"/><path d="M314.902 227.386c-1.298 8.033-30.839 9.845-66.343 4.402-35.247-5.7-62.982-16.843-61.684-24.618.521-2.59 3.888-4.665 9.331-5.7-18.141.777-30.062 4.145-31.096 9.845-1.555 10.628 34.726 25.139 81.373 32.657 46.647 7.512 85.782 4.665 87.594-5.7 1.041-6.226-9.33-12.961-26.431-19.439 4.923 2.847 7.513 5.957 7.256 8.553Z" fill="#A7F3D0" fill-opacity=".5"/><path d="M333.557 157.413c-3.104-32.137-27.729-59.351-60.9-64.53-33.172-5.186-64.531 12.954-77.749 42.238 21.251 1.298 44.057 3.631 67.904 7.518 25.396 3.888 49.237 9.074 70.745 14.774Z" fill="url(#b)"/><path d="M74.142 158.002c-2.59 15.808 30.319 35.247 81.894 51.055-.257-1.04-.257-1.818-.257-2.853 2.07-12.698 46.127-16.328 98.48-8.032 52.347 8.29 93.037 25.396 90.961 38.094-.257 1.04-.514 1.818-1.035 2.589 53.645.778 90.968-7.512 93.557-23.32 3.625-24.104-74.638-56.498-174.93-72.306-100.555-15.808-185.045-9.331-188.67 14.773Zm115.586-1.298c.778-4.145 4.665-7.255 8.81-6.477 4.145.777 7.256 4.665 6.478 8.81-.52 4.145-4.665 6.998-8.81 6.478-4.145-.778-7.255-4.666-6.478-8.811Zm59.866 4.145c.777-5.7 6.22-9.587 11.92-8.547 5.7.778 9.588 6.215 8.553 11.921-1.041 5.442-6.478 9.33-11.92 8.553-5.706-.778-9.594-6.221-8.553-11.927Zm62.975 15.294c.778-4.145 4.665-7.255 8.81-6.478 4.145.778 7.255 4.666 6.478 8.811-.515 4.145-4.665 7.255-8.81 6.477-4.145-.777-7.256-4.665-6.478-8.81Z" fill="url(#c)"/><defs><radialGradient id="b" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0 32.7063 -69.3245 0 264.232 124.706)"><stop stop-color="#047857"/><stop offset="1" stop-color="#064E3B"/></radialGradient><radialGradient id="c" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(255.837 186.754) scale(1389.61)"><stop stop-color="#047857"/><stop offset=".115" stop-color="#064E3B"/></radialGradient><linearGradient id="a" x1="224.998" y1="157.606" x2="224.998" y2="403.696" gradientUnits="userSpaceOnUse"><stop stop-color="#86EFAC" stop-opacity=".75"/><stop offset=".635" stop-color="#fff" stop-opacity=".2"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></linearGradient></defs></svg>
|
<svg width="824" height="824" viewBox="0 0 824 824" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<rect width="824" height="824" rx="184" fill="#08110F"/>
|
||||||
|
<rect width="824" height="824" rx="184" fill="url(#paint0_radial_0_21)" fill-opacity="0.5"/>
|
||||||
|
<path d="M435.425 463.217C429.441 476.657 411.033 481.515 394.309 474.07C377.585 466.624 368.879 449.693 374.863 436.253C380.846 422.813 399.254 417.954 415.978 425.4C432.702 432.846 441.409 449.777 435.425 463.217Z" fill="url(#paint1_linear_0_21)"/>
|
||||||
|
<path d="M435.425 463.217C429.441 476.657 411.033 481.515 394.309 474.07C377.585 466.624 368.879 449.693 374.863 436.253C380.846 422.813 399.254 417.954 415.978 425.4C432.702 432.846 441.409 449.777 435.425 463.217Z" fill="url(#paint2_radial_0_21)" style="mix-blend-mode:soft-light"/>
|
||||||
|
<path d="M535.563 521.172C553.071 526.191 570.536 518.856 574.571 504.789C578.606 490.722 567.684 475.251 550.175 470.232C532.666 465.213 515.201 472.548 511.166 486.615C507.131 500.682 518.054 516.153 535.563 521.172Z" fill="url(#paint3_linear_0_21)"/>
|
||||||
|
<path d="M535.563 521.172C553.071 526.191 570.536 518.856 574.571 504.789C578.606 490.722 567.684 475.251 550.175 470.232C532.666 465.213 515.201 472.548 511.166 486.615C507.131 500.682 518.054 516.153 535.563 521.172Z" fill="url(#paint4_radial_0_21)" style="mix-blend-mode:soft-light"/>
|
||||||
|
<path d="M292.782 355.633C308.227 365.286 314.462 383.173 306.709 395.584C298.955 407.995 280.149 410.231 264.704 400.578C249.258 390.924 243.023 373.037 250.777 360.626C258.53 348.215 277.337 345.98 292.782 355.633Z" fill="url(#paint5_linear_0_21)"/>
|
||||||
|
<path d="M292.782 355.633C308.227 365.286 314.462 383.173 306.709 395.584C298.955 407.995 280.149 410.231 264.704 400.578C249.258 390.924 243.023 373.037 250.777 360.626C258.53 348.215 277.337 345.98 292.782 355.633Z" fill="url(#paint6_radial_0_21)" style="mix-blend-mode:soft-light"/>
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M502.355 231.325C581.373 266.506 632.095 343.263 634.119 429.03C680.633 465.639 726.858 516.883 705.36 565.168C681.25 619.319 595.382 617.091 497.781 589.689C450.767 615.718 392.444 620.168 339.689 596.68C286.934 573.192 251.229 526.908 239.1 474.517C153.428 420.321 94.3151 357.999 118.425 303.847C139.923 255.562 208.935 255.626 267.265 265.697C332.356 209.81 423.338 196.144 502.355 231.325ZM159.38 322.082C147.667 348.389 210.578 423.052 382.845 499.751C555.111 576.449 652.693 573.241 664.405 546.934C674.099 525.16 634.213 483.308 588.537 450.878C553.009 425.484 504.344 397.494 440.864 369.231C423.586 361.538 416.839 341.008 424.104 324.691C431.369 308.374 447.329 297.463 480.93 295.91C496.747 295.862 498.823 291.476 499.546 287.716C500.442 281.915 492.401 276.002 484.108 272.31C418.17 242.953 337.453 255.265 281.503 314.178C226.84 301.933 169.074 300.309 159.38 322.082Z" fill="url(#paint7_linear_0_21)"/>
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M502.355 231.325C581.373 266.506 632.095 343.263 634.119 429.03C680.633 465.639 726.858 516.883 705.36 565.168C681.25 619.319 595.382 617.091 497.781 589.689C450.767 615.718 392.444 620.168 339.689 596.68C286.934 573.192 251.229 526.908 239.1 474.517C153.428 420.321 94.3151 357.999 118.425 303.847C139.923 255.562 208.935 255.626 267.265 265.697C332.356 209.81 423.338 196.144 502.355 231.325ZM159.38 322.082C147.667 348.389 210.578 423.052 382.845 499.751C555.111 576.449 652.693 573.241 664.405 546.934C674.099 525.16 634.213 483.308 588.537 450.878C553.009 425.484 504.344 397.494 440.864 369.231C423.586 361.538 416.839 341.008 424.104 324.691C431.369 308.374 447.329 297.463 480.93 295.91C496.747 295.862 498.823 291.476 499.546 287.716C500.442 281.915 492.401 276.002 484.108 272.31C418.17 242.953 337.453 255.265 281.503 314.178C226.84 301.933 169.074 300.309 159.38 322.082Z" fill="url(#paint8_radial_0_21)" style="mix-blend-mode:soft-light"/>
|
||||||
|
<defs>
|
||||||
|
<radialGradient id="paint0_radial_0_21" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(814.524 12.36) rotate(125.613) scale(1089.59 1210.34)">
|
||||||
|
<stop stop-color="#00D196" stop-opacity="0.5"/>
|
||||||
|
<stop offset="0.996771" stop-color="#00D196" stop-opacity="0"/>
|
||||||
|
</radialGradient>
|
||||||
|
<linearGradient id="paint1_linear_0_21" x1="411.893" y1="212" x2="411.893" y2="612" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#00D196"/>
|
||||||
|
<stop offset="1" stop-color="#00B381"/>
|
||||||
|
</linearGradient>
|
||||||
|
<radialGradient id="paint2_radial_0_21" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(644.721 344.481) rotate(159.984) scale(631.37 385.135)">
|
||||||
|
<stop stop-color="white"/>
|
||||||
|
<stop offset="1" stop-color="white" stop-opacity="0"/>
|
||||||
|
</radialGradient>
|
||||||
|
<linearGradient id="paint3_linear_0_21" x1="411.893" y1="212" x2="411.893" y2="612" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#00D196"/>
|
||||||
|
<stop offset="1" stop-color="#00B381"/>
|
||||||
|
</linearGradient>
|
||||||
|
<radialGradient id="paint4_radial_0_21" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(644.721 344.481) rotate(159.984) scale(631.37 385.135)">
|
||||||
|
<stop stop-color="white"/>
|
||||||
|
<stop offset="1" stop-color="white" stop-opacity="0"/>
|
||||||
|
</radialGradient>
|
||||||
|
<linearGradient id="paint5_linear_0_21" x1="411.893" y1="212" x2="411.893" y2="612" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#00D196"/>
|
||||||
|
<stop offset="1" stop-color="#00B381"/>
|
||||||
|
</linearGradient>
|
||||||
|
<radialGradient id="paint6_radial_0_21" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(644.721 344.481) rotate(159.984) scale(631.37 385.135)">
|
||||||
|
<stop stop-color="white"/>
|
||||||
|
<stop offset="1" stop-color="white" stop-opacity="0"/>
|
||||||
|
</radialGradient>
|
||||||
|
<linearGradient id="paint7_linear_0_21" x1="411.893" y1="212" x2="411.893" y2="612" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#00D196"/>
|
||||||
|
<stop offset="1" stop-color="#00B381"/>
|
||||||
|
</linearGradient>
|
||||||
|
<radialGradient id="paint8_radial_0_21" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(644.721 344.481) rotate(159.984) scale(631.37 385.135)">
|
||||||
|
<stop stop-color="white"/>
|
||||||
|
<stop offset="1" stop-color="white" stop-opacity="0"/>
|
||||||
|
</radialGradient>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 5.9 KiB |
@@ -2,7 +2,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<div
|
<div
|
||||||
v-if="isLoadingInitialRoute"
|
v-if="isLoadingInitialRoute"
|
||||||
class="flex flex-col items-center justify-center min-h-screen"
|
class="flex min-h-screen flex-col items-center justify-center"
|
||||||
>
|
>
|
||||||
<HoppSmartSpinner />
|
<HoppSmartSpinner />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||