diff --git a/documentation/environment_variables.md b/documentation/environment_variables.md index 54d69e5b2f1..6713b1bd1e4 100644 --- a/documentation/environment_variables.md +++ b/documentation/environment_variables.md @@ -12,7 +12,7 @@ At runtime, talawa api requires certain environment variables to be defined in i ## API_ADMINISTRATOR_USER_EMAIL_ADDRESS -This environment variable is used to configure the email address for the administrator user that talawa-api will make sure exists in the database at the time of server startup. +This environment variable is used to configure the email address for the administrator user that talawa api will make sure exists in the database at the time of server startup. ## API_ADMINISTRATOR_USER_NAME @@ -20,7 +20,7 @@ This environment variable is used to configure the name for the administrator us ## API_ADMINISTRATOR_USER_PASSWORD -This environment variable is used to configure the password for the administrator user that talawa-api will make sure exists in the database at the time of server startup. +This environment variable is used to configure the password for the administrator user that talawa api will make sure exists in the database at the time of server startup. ## API_BASE_URL diff --git a/drizzle_migrations/20250118150033_needy_tigra.sql b/drizzle_migrations/20250121200120_melted_morlun.sql similarity index 99% rename from drizzle_migrations/20250118150033_needy_tigra.sql rename to drizzle_migrations/20250121200120_melted_morlun.sql index a0229283388..a1a272ae61d 100644 --- a/drizzle_migrations/20250118150033_needy_tigra.sql +++ b/drizzle_migrations/20250121200120_melted_morlun.sql @@ -118,8 +118,7 @@ CREATE TABLE "comment_votes" ( "creator_id" uuid, "id" uuid PRIMARY KEY NOT NULL, "type" text NOT NULL, - "updated_at" timestamp (3) with time zone, - "updated_id" uuid + "updated_at" timestamp (3) with time zone ); --> statement-breakpoint CREATE TABLE "comments" ( @@ -290,8 +289,7 @@ CREATE TABLE "post_votes" ( "id" uuid PRIMARY KEY NOT NULL, "post_id" uuid NOT NULL, "type" text NOT NULL, - "updated_at" timestamp (3) with time zone, - "updated_id" uuid + "updated_at" timestamp (3) with time zone ); --> statement-breakpoint CREATE TABLE "posts" ( @@ -452,7 +450,6 @@ ALTER TABLE "chats" ADD CONSTRAINT "chats_organization_id_organizations_id_fk" F ALTER TABLE "chats" ADD CONSTRAINT "chats_updater_id_users_id_fk" FOREIGN KEY ("updater_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE cascade;--> statement-breakpoint ALTER TABLE "comment_votes" ADD CONSTRAINT "comment_votes_comment_id_comments_id_fk" FOREIGN KEY ("comment_id") REFERENCES "public"."comments"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint ALTER TABLE "comment_votes" ADD CONSTRAINT "comment_votes_creator_id_users_id_fk" FOREIGN KEY ("creator_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE cascade;--> statement-breakpoint -ALTER TABLE "comment_votes" ADD CONSTRAINT "comment_votes_updated_id_users_id_fk" FOREIGN KEY ("updated_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE cascade;--> statement-breakpoint ALTER TABLE "comments" ADD CONSTRAINT "comments_creator_id_users_id_fk" FOREIGN KEY ("creator_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE cascade;--> statement-breakpoint ALTER TABLE "comments" ADD CONSTRAINT "comments_post_id_posts_id_fk" FOREIGN KEY ("post_id") REFERENCES "public"."posts"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint ALTER TABLE "communities" ADD CONSTRAINT "communities_updater_id_users_id_fk" FOREIGN KEY ("updater_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE cascade;--> statement-breakpoint @@ -494,7 +491,6 @@ ALTER TABLE "post_attachments" ADD CONSTRAINT "post_attachments_post_id_posts_id ALTER TABLE "post_attachments" ADD CONSTRAINT "post_attachments_updater_id_users_id_fk" FOREIGN KEY ("updater_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE cascade;--> statement-breakpoint ALTER TABLE "post_votes" ADD CONSTRAINT "post_votes_creator_id_users_id_fk" FOREIGN KEY ("creator_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE cascade;--> statement-breakpoint ALTER TABLE "post_votes" ADD CONSTRAINT "post_votes_post_id_posts_id_fk" FOREIGN KEY ("post_id") REFERENCES "public"."posts"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint -ALTER TABLE "post_votes" ADD CONSTRAINT "post_votes_updated_id_users_id_fk" FOREIGN KEY ("updated_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE cascade;--> statement-breakpoint ALTER TABLE "posts" ADD CONSTRAINT "posts_creator_id_users_id_fk" FOREIGN KEY ("creator_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE cascade;--> statement-breakpoint ALTER TABLE "posts" ADD CONSTRAINT "posts_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint ALTER TABLE "posts" ADD CONSTRAINT "posts_updater_id_users_id_fk" FOREIGN KEY ("updater_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE cascade;--> statement-breakpoint diff --git a/drizzle_migrations/meta/20250118150033_snapshot.json b/drizzle_migrations/meta/20250121200120_snapshot.json similarity index 99% rename from drizzle_migrations/meta/20250118150033_snapshot.json rename to drizzle_migrations/meta/20250121200120_snapshot.json index 6c871f8ea5e..7e490d7f2aa 100644 --- a/drizzle_migrations/meta/20250118150033_snapshot.json +++ b/drizzle_migrations/meta/20250121200120_snapshot.json @@ -1,5 +1,5 @@ { - "id": "32df2a89-a895-4c5d-a4dc-cc8413ee818f", + "id": "8f027f04-270a-4d90-8653-683983016f02", "prevId": "00000000-0000-0000-0000-000000000000", "version": "7", "dialect": "postgresql", @@ -1802,12 +1802,6 @@ "type": "timestamp (3) with time zone", "primaryKey": false, "notNull": false - }, - "updated_id": { - "name": "updated_id", - "type": "uuid", - "primaryKey": false, - "notNull": false } }, "indexes": { @@ -1904,19 +1898,6 @@ ], "onDelete": "set null", "onUpdate": "cascade" - }, - "comment_votes_updated_id_users_id_fk": { - "name": "comment_votes_updated_id_users_id_fk", - "tableFrom": "comment_votes", - "tableTo": "users", - "columnsFrom": [ - "updated_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "cascade" } }, "compositePrimaryKeys": {}, @@ -4274,12 +4255,6 @@ "type": "timestamp (3) with time zone", "primaryKey": false, "notNull": false - }, - "updated_id": { - "name": "updated_id", - "type": "uuid", - "primaryKey": false, - "notNull": false } }, "indexes": { @@ -4376,19 +4351,6 @@ ], "onDelete": "cascade", "onUpdate": "cascade" - }, - "post_votes_updated_id_users_id_fk": { - "name": "post_votes_updated_id_users_id_fk", - "tableFrom": "post_votes", - "tableTo": "users", - "columnsFrom": [ - "updated_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "cascade" } }, "compositePrimaryKeys": {}, diff --git a/drizzle_migrations/meta/_journal.json b/drizzle_migrations/meta/_journal.json index 660d74f717a..3a47c70a09d 100644 --- a/drizzle_migrations/meta/_journal.json +++ b/drizzle_migrations/meta/_journal.json @@ -5,8 +5,8 @@ { "idx": 0, "version": "7", - "when": 1737212433966, - "tag": "20250118150033_needy_tigra", + "when": 1737489680166, + "tag": "20250121200120_melted_morlun", "breakpoints": true } ] diff --git a/envFiles/.env.production b/envFiles/.env.production index 6df24950e29..c0efca32979 100644 --- a/envFiles/.env.production +++ b/envFiles/.env.production @@ -40,6 +40,7 @@ CI=false NODE_ENV=production ########## docker compose `api` container service ########## + API_GID=1000 API_UID=1000 diff --git a/package.json b/package.json index 84f26ccd0bb..a7f1f49a124 100644 --- a/package.json +++ b/package.json @@ -36,19 +36,19 @@ "@biomejs/biome": "^1.9.4", "@faker-js/faker": "^9.4.0", "@swc/cli": "0.6.0", - "@swc/core": "^1.10.7", + "@swc/core": "^1.10.9", "@types/node": "^22.10.7", - "@vitest/coverage-v8": "^3.0.2", + "@vitest/coverage-v8": "^3.0.3", "drizzle-kit": "^0.30.2", "drizzle-seed": "^0.3.0", "gql.tada": "^1.8.10", - "lefthook": "^1.10.8", + "lefthook": "^1.10.10", "mercurius-integration-testing": "^9.0.1", "pino-pretty": "^13.0.0", "tsx": "^4.19.2", "typescript": "^5.7.3", "vite-tsconfig-paths": "^5.1.4", - "vitest": "^3.0.2" + "vitest": "^3.0.3" }, "engines": { "node": "22.13.0" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a85d3e00fff..545d0bf044a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -95,16 +95,16 @@ importers: version: 9.4.0 '@swc/cli': specifier: 0.6.0 - version: 0.6.0(@swc/core@1.10.7) + version: 0.6.0(@swc/core@1.10.9) '@swc/core': - specifier: ^1.10.7 - version: 1.10.7 + specifier: ^1.10.9 + version: 1.10.9 '@types/node': specifier: ^22.10.7 version: 22.10.7 '@vitest/coverage-v8': - specifier: ^3.0.2 - version: 3.0.2(vitest@3.0.2(@types/node@22.10.7)(tsx@4.19.2)) + specifier: ^3.0.3 + version: 3.0.3(vitest@3.0.3(@types/node@22.10.7)(tsx@4.19.2)) drizzle-kit: specifier: ^0.30.2 version: 0.30.2 @@ -115,8 +115,8 @@ importers: specifier: ^1.8.10 version: 1.8.10(graphql@16.10.0)(typescript@5.7.3) lefthook: - specifier: ^1.10.8 - version: 1.10.8 + specifier: ^1.10.10 + version: 1.10.10 mercurius-integration-testing: specifier: ^9.0.1 version: 9.0.1(fastify@5.2.1)(graphql@16.10.0)(mercurius@16.0.1(graphql@16.10.0)) @@ -131,10 +131,10 @@ importers: version: 5.7.3 vite-tsconfig-paths: specifier: ^5.1.4 - version: 5.1.4(typescript@5.7.3)(vite@6.0.7(@types/node@22.10.7)(tsx@4.19.2)) + version: 5.1.4(typescript@5.7.3)(vite@6.0.11(@types/node@22.10.7)(tsx@4.19.2)) vitest: - specifier: ^3.0.2 - version: 3.0.2(@types/node@22.10.7)(tsx@4.19.2) + specifier: ^3.0.3 + version: 3.0.3(@types/node@22.10.7)(tsx@4.19.2) packages: @@ -1140,98 +1140,98 @@ packages: '@pothos/core': '*' graphql: '>=16.6.0' - '@rollup/rollup-android-arm-eabi@4.30.1': - resolution: {integrity: sha512-pSWY+EVt3rJ9fQ3IqlrEUtXh3cGqGtPDH1FQlNZehO2yYxCHEX1SPsz1M//NXwYfbTlcKr9WObLnJX9FsS9K1Q==} + '@rollup/rollup-android-arm-eabi@4.31.0': + resolution: {integrity: sha512-9NrR4033uCbUBRgvLcBrJofa2KY9DzxL2UKZ1/4xA/mnTNyhZCWBuD8X3tPm1n4KxcgaraOYgrFKSgwjASfmlA==} cpu: [arm] os: [android] - '@rollup/rollup-android-arm64@4.30.1': - resolution: {integrity: sha512-/NA2qXxE3D/BRjOJM8wQblmArQq1YoBVJjrjoTSBS09jgUisq7bqxNHJ8kjCHeV21W/9WDGwJEWSN0KQ2mtD/w==} + '@rollup/rollup-android-arm64@4.31.0': + resolution: {integrity: sha512-iBbODqT86YBFHajxxF8ebj2hwKm1k8PTBQSojSt3d1FFt1gN+xf4CowE47iN0vOSdnd+5ierMHBbu/rHc7nq5g==} cpu: [arm64] os: [android] - '@rollup/rollup-darwin-arm64@4.30.1': - resolution: {integrity: sha512-r7FQIXD7gB0WJ5mokTUgUWPl0eYIH0wnxqeSAhuIwvnnpjdVB8cRRClyKLQr7lgzjctkbp5KmswWszlwYln03Q==} + '@rollup/rollup-darwin-arm64@4.31.0': + resolution: {integrity: sha512-WHIZfXgVBX30SWuTMhlHPXTyN20AXrLH4TEeH/D0Bolvx9PjgZnn4H677PlSGvU6MKNsjCQJYczkpvBbrBnG6g==} cpu: [arm64] os: [darwin] - '@rollup/rollup-darwin-x64@4.30.1': - resolution: {integrity: sha512-x78BavIwSH6sqfP2xeI1hd1GpHL8J4W2BXcVM/5KYKoAD3nNsfitQhvWSw+TFtQTLZ9OmlF+FEInEHyubut2OA==} + '@rollup/rollup-darwin-x64@4.31.0': + resolution: {integrity: sha512-hrWL7uQacTEF8gdrQAqcDy9xllQ0w0zuL1wk1HV8wKGSGbKPVjVUv/DEwT2+Asabf8Dh/As+IvfdU+H8hhzrQQ==} cpu: [x64] os: [darwin] - '@rollup/rollup-freebsd-arm64@4.30.1': - resolution: {integrity: sha512-HYTlUAjbO1z8ywxsDFWADfTRfTIIy/oUlfIDmlHYmjUP2QRDTzBuWXc9O4CXM+bo9qfiCclmHk1x4ogBjOUpUQ==} + '@rollup/rollup-freebsd-arm64@4.31.0': + resolution: {integrity: sha512-S2oCsZ4hJviG1QjPY1h6sVJLBI6ekBeAEssYKad1soRFv3SocsQCzX6cwnk6fID6UQQACTjeIMB+hyYrFacRew==} cpu: [arm64] os: [freebsd] - '@rollup/rollup-freebsd-x64@4.30.1': - resolution: {integrity: sha512-1MEdGqogQLccphhX5myCJqeGNYTNcmTyaic9S7CG3JhwuIByJ7J05vGbZxsizQthP1xpVx7kd3o31eOogfEirw==} + '@rollup/rollup-freebsd-x64@4.31.0': + resolution: {integrity: sha512-pCANqpynRS4Jirn4IKZH4tnm2+2CqCNLKD7gAdEjzdLGbH1iO0zouHz4mxqg0uEMpO030ejJ0aA6e1PJo2xrPA==} cpu: [x64] os: [freebsd] - '@rollup/rollup-linux-arm-gnueabihf@4.30.1': - resolution: {integrity: sha512-PaMRNBSqCx7K3Wc9QZkFx5+CX27WFpAMxJNiYGAXfmMIKC7jstlr32UhTgK6T07OtqR+wYlWm9IxzennjnvdJg==} + '@rollup/rollup-linux-arm-gnueabihf@4.31.0': + resolution: {integrity: sha512-0O8ViX+QcBd3ZmGlcFTnYXZKGbFu09EhgD27tgTdGnkcYXLat4KIsBBQeKLR2xZDCXdIBAlWLkiXE1+rJpCxFw==} cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm-musleabihf@4.30.1': - resolution: {integrity: sha512-B8Rcyj9AV7ZlEFqvB5BubG5iO6ANDsRKlhIxySXcF1axXYUyqwBok+XZPgIYGBgs7LDXfWfifxhw0Ik57T0Yug==} + '@rollup/rollup-linux-arm-musleabihf@4.31.0': + resolution: {integrity: sha512-w5IzG0wTVv7B0/SwDnMYmbr2uERQp999q8FMkKG1I+j8hpPX2BYFjWe69xbhbP6J9h2gId/7ogesl9hwblFwwg==} cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm64-gnu@4.30.1': - resolution: {integrity: sha512-hqVyueGxAj3cBKrAI4aFHLV+h0Lv5VgWZs9CUGqr1z0fZtlADVV1YPOij6AhcK5An33EXaxnDLmJdQikcn5NEw==} + '@rollup/rollup-linux-arm64-gnu@4.31.0': + resolution: {integrity: sha512-JyFFshbN5xwy6fulZ8B/8qOqENRmDdEkcIMF0Zz+RsfamEW+Zabl5jAb0IozP/8UKnJ7g2FtZZPEUIAlUSX8cA==} cpu: [arm64] os: [linux] - '@rollup/rollup-linux-arm64-musl@4.30.1': - resolution: {integrity: sha512-i4Ab2vnvS1AE1PyOIGp2kXni69gU2DAUVt6FSXeIqUCPIR3ZlheMW3oP2JkukDfu3PsexYRbOiJrY+yVNSk9oA==} + '@rollup/rollup-linux-arm64-musl@4.31.0': + resolution: {integrity: sha512-kpQXQ0UPFeMPmPYksiBL9WS/BDiQEjRGMfklVIsA0Sng347H8W2iexch+IEwaR7OVSKtr2ZFxggt11zVIlZ25g==} cpu: [arm64] os: [linux] - '@rollup/rollup-linux-loongarch64-gnu@4.30.1': - resolution: {integrity: sha512-fARcF5g296snX0oLGkVxPmysetwUk2zmHcca+e9ObOovBR++9ZPOhqFUM61UUZ2EYpXVPN1redgqVoBB34nTpQ==} + '@rollup/rollup-linux-loongarch64-gnu@4.31.0': + resolution: {integrity: sha512-pMlxLjt60iQTzt9iBb3jZphFIl55a70wexvo8p+vVFK+7ifTRookdoXX3bOsRdmfD+OKnMozKO6XM4zR0sHRrQ==} cpu: [loong64] os: [linux] - '@rollup/rollup-linux-powerpc64le-gnu@4.30.1': - resolution: {integrity: sha512-GLrZraoO3wVT4uFXh67ElpwQY0DIygxdv0BNW9Hkm3X34wu+BkqrDrkcsIapAY+N2ATEbvak0XQ9gxZtCIA5Rw==} + '@rollup/rollup-linux-powerpc64le-gnu@4.31.0': + resolution: {integrity: sha512-D7TXT7I/uKEuWiRkEFbed1UUYZwcJDU4vZQdPTcepK7ecPhzKOYk4Er2YR4uHKme4qDeIh6N3XrLfpuM7vzRWQ==} cpu: [ppc64] os: [linux] - '@rollup/rollup-linux-riscv64-gnu@4.30.1': - resolution: {integrity: sha512-0WKLaAUUHKBtll0wvOmh6yh3S0wSU9+yas923JIChfxOaaBarmb/lBKPF0w/+jTVozFnOXJeRGZ8NvOxvk/jcw==} + '@rollup/rollup-linux-riscv64-gnu@4.31.0': + resolution: {integrity: sha512-wal2Tc8O5lMBtoePLBYRKj2CImUCJ4UNGJlLwspx7QApYny7K1cUYlzQ/4IGQBLmm+y0RS7dwc3TDO/pmcneTw==} cpu: [riscv64] os: [linux] - '@rollup/rollup-linux-s390x-gnu@4.30.1': - resolution: {integrity: sha512-GWFs97Ruxo5Bt+cvVTQkOJ6TIx0xJDD/bMAOXWJg8TCSTEK8RnFeOeiFTxKniTc4vMIaWvCplMAFBt9miGxgkA==} + '@rollup/rollup-linux-s390x-gnu@4.31.0': + resolution: {integrity: sha512-O1o5EUI0+RRMkK9wiTVpk2tyzXdXefHtRTIjBbmFREmNMy7pFeYXCFGbhKFwISA3UOExlo5GGUuuj3oMKdK6JQ==} cpu: [s390x] os: [linux] - '@rollup/rollup-linux-x64-gnu@4.30.1': - resolution: {integrity: sha512-UtgGb7QGgXDIO+tqqJ5oZRGHsDLO8SlpE4MhqpY9Llpzi5rJMvrK6ZGhsRCST2abZdBqIBeXW6WPD5fGK5SDwg==} + '@rollup/rollup-linux-x64-gnu@4.31.0': + resolution: {integrity: sha512-zSoHl356vKnNxwOWnLd60ixHNPRBglxpv2g7q0Cd3Pmr561gf0HiAcUBRL3S1vPqRC17Zo2CX/9cPkqTIiai1g==} cpu: [x64] os: [linux] - '@rollup/rollup-linux-x64-musl@4.30.1': - resolution: {integrity: sha512-V9U8Ey2UqmQsBT+xTOeMzPzwDzyXmnAoO4edZhL7INkwQcaW1Ckv3WJX3qrrp/VHaDkEWIBWhRwP47r8cdrOow==} + '@rollup/rollup-linux-x64-musl@4.31.0': + resolution: {integrity: sha512-ypB/HMtcSGhKUQNiFwqgdclWNRrAYDH8iMYH4etw/ZlGwiTVxBz2tDrGRrPlfZu6QjXwtd+C3Zib5pFqID97ZA==} cpu: [x64] os: [linux] - '@rollup/rollup-win32-arm64-msvc@4.30.1': - resolution: {integrity: sha512-WabtHWiPaFF47W3PkHnjbmWawnX/aE57K47ZDT1BXTS5GgrBUEpvOzq0FI0V/UYzQJgdb8XlhVNH8/fwV8xDjw==} + '@rollup/rollup-win32-arm64-msvc@4.31.0': + resolution: {integrity: sha512-JuhN2xdI/m8Hr+aVO3vspO7OQfUFO6bKLIRTAy0U15vmWjnZDLrEgCZ2s6+scAYaQVpYSh9tZtRijApw9IXyMw==} cpu: [arm64] os: [win32] - '@rollup/rollup-win32-ia32-msvc@4.30.1': - resolution: {integrity: sha512-pxHAU+Zv39hLUTdQQHUVHf4P+0C47y/ZloorHpzs2SXMRqeAWmGghzAhfOlzFHHwjvgokdFAhC4V+6kC1lRRfw==} + '@rollup/rollup-win32-ia32-msvc@4.31.0': + resolution: {integrity: sha512-U1xZZXYkvdf5MIWmftU8wrM5PPXzyaY1nGCI4KI4BFfoZxHamsIe+BtnPLIvvPykvQWlVbqUXdLa4aJUuilwLQ==} cpu: [ia32] os: [win32] - '@rollup/rollup-win32-x64-msvc@4.30.1': - resolution: {integrity: sha512-D6qjsXGcvhTjv0kI4fU8tUuBDF/Ueee4SVX79VfNDXZa64TfCW1Slkb6Z7O1p7vflqZjcmOVdZlqf8gvJxc6og==} + '@rollup/rollup-win32-x64-msvc@4.31.0': + resolution: {integrity: sha512-ul8rnCsUumNln5YWwz0ted2ZHFhzhRRnkpBZ+YRuHoRAlUji9KChpOUOndY7uykrPEPXVbHLlsdo6v5yXo/TXw==} cpu: [x64] os: [win32] @@ -1256,68 +1256,68 @@ packages: chokidar: optional: true - '@swc/core-darwin-arm64@1.10.7': - resolution: {integrity: sha512-SI0OFg987P6hcyT0Dbng3YRISPS9uhLX1dzW4qRrfqQdb0i75lPJ2YWe9CN47HBazrIA5COuTzrD2Dc0TcVsSQ==} + '@swc/core-darwin-arm64@1.10.9': + resolution: {integrity: sha512-XTHLtijFervv2B+i1ngM993umhSj9K1IeMomvU/Db84Asjur2XmD4KXt9QPnGDRFgv2kLSjZ+DDL25Qk0f4r+w==} engines: {node: '>=10'} cpu: [arm64] os: [darwin] - '@swc/core-darwin-x64@1.10.7': - resolution: {integrity: sha512-RFIAmWVicD/l3RzxgHW0R/G1ya/6nyMspE2cAeDcTbjHi0I5qgdhBWd6ieXOaqwEwiCd0Mot1g2VZrLGoBLsjQ==} + '@swc/core-darwin-x64@1.10.9': + resolution: {integrity: sha512-bi3el9/FV/la8HIsolSjeDar+tM7m9AmSF1w7X6ZByW2qgc4Z1tmq0A4M4H9aH3TfHesZbfq8hgaNtc2/VtzzQ==} engines: {node: '>=10'} cpu: [x64] os: [darwin] - '@swc/core-linux-arm-gnueabihf@1.10.7': - resolution: {integrity: sha512-QP8vz7yELWfop5mM5foN6KkLylVO7ZUgWSF2cA0owwIaziactB2hCPZY5QU690coJouk9KmdFsPWDnaCFUP8tg==} + '@swc/core-linux-arm-gnueabihf@1.10.9': + resolution: {integrity: sha512-xsLHV02S+RTDuI+UJBkA2muNk/s0ETRpoc1K/gNt0i8BqTurPYkrvGDDALN9+leiUPydHvZi9P1qdExbgUJnXw==} engines: {node: '>=10'} cpu: [arm] os: [linux] - '@swc/core-linux-arm64-gnu@1.10.7': - resolution: {integrity: sha512-NgUDBGQcOeLNR+EOpmUvSDIP/F7i/OVOKxst4wOvT5FTxhnkWrW+StJGKj+DcUVSK5eWOYboSXr1y+Hlywwokw==} + '@swc/core-linux-arm64-gnu@1.10.9': + resolution: {integrity: sha512-41hJgPoGhIa12U6Tud+yLF/m64YA3mGut3TmBEkj2R7rdJdE0mljdtR0tf4J2RoQaWZPPi0DBSqGdROiAEx9dg==} engines: {node: '>=10'} cpu: [arm64] os: [linux] - '@swc/core-linux-arm64-musl@1.10.7': - resolution: {integrity: sha512-gp5Un3EbeSThBIh6oac5ZArV/CsSmTKj5jNuuUAuEsML3VF9vqPO+25VuxCvsRf/z3py+xOWRaN2HY/rjMeZog==} + '@swc/core-linux-arm64-musl@1.10.9': + resolution: {integrity: sha512-DUMRhl49b9r7bLg9oNzCdW4lLcDJKrRBn87Iq5APPvixsm1auGnsVQycGkQcDDKvVllxIFSbmCYzjagx3l8Hnw==} engines: {node: '>=10'} cpu: [arm64] os: [linux] - '@swc/core-linux-x64-gnu@1.10.7': - resolution: {integrity: sha512-k/OxLLMl/edYqbZyUNg6/bqEHTXJT15l9WGqsl/2QaIGwWGvles8YjruQYQ9d4h/thSXLT9gd8bExU2D0N+bUA==} + '@swc/core-linux-x64-gnu@1.10.9': + resolution: {integrity: sha512-xW0y88vQvmzYo3Gn7yFnY03TfHMwuca4aFH3ZmhwDNOYHmTOi6fmhAkg/13F/NrwjMYO+GnF5uJTjdjb3B6tdQ==} engines: {node: '>=10'} cpu: [x64] os: [linux] - '@swc/core-linux-x64-musl@1.10.7': - resolution: {integrity: sha512-XeDoURdWt/ybYmXLCEE8aSiTOzEn0o3Dx5l9hgt0IZEmTts7HgHHVeRgzGXbR4yDo0MfRuX5nE1dYpTmCz0uyA==} + '@swc/core-linux-x64-musl@1.10.9': + resolution: {integrity: sha512-jYs32BEx+CPVuxN6NdsWEpdehjnmAag25jyJzwjQx+NCGYwHEV3bT5y8TX4eFhaVB1rafmqJOlYQPs4+MSyGCg==} engines: {node: '>=10'} cpu: [x64] os: [linux] - '@swc/core-win32-arm64-msvc@1.10.7': - resolution: {integrity: sha512-nYAbi/uLS+CU0wFtBx8TquJw2uIMKBnl04LBmiVoFrsIhqSl+0MklaA9FVMGA35NcxSJfcm92Prl2W2LfSnTqQ==} + '@swc/core-win32-arm64-msvc@1.10.9': + resolution: {integrity: sha512-Uhh5T3Fq3Nyom96Bm3ACBNASH3iqNc76in7ewZz8PooUqeTIO8aZpsghnncjctRNE9T819/8btpiFIhHo3sKtg==} engines: {node: '>=10'} cpu: [arm64] os: [win32] - '@swc/core-win32-ia32-msvc@1.10.7': - resolution: {integrity: sha512-+aGAbsDsIxeLxw0IzyQLtvtAcI1ctlXVvVcXZMNXIXtTURM876yNrufRo4ngoXB3jnb1MLjIIjgXfFs/eZTUSw==} + '@swc/core-win32-ia32-msvc@1.10.9': + resolution: {integrity: sha512-bD5BpbojEsDfrAvT+1qjQPf5RCKLg4UL+3Uwm019+ZR02hd8qO538BlOnQdOqRqccu+75DF6aRglQ7AJ24Cs0Q==} engines: {node: '>=10'} cpu: [ia32] os: [win32] - '@swc/core-win32-x64-msvc@1.10.7': - resolution: {integrity: sha512-TBf4clpDBjF/UUnkKrT0/th76/zwvudk5wwobiTFqDywMApHip5O0VpBgZ+4raY2TM8k5+ujoy7bfHb22zu17Q==} + '@swc/core-win32-x64-msvc@1.10.9': + resolution: {integrity: sha512-NwkuUNeBBQnAaXVvcGw8Zr6RR8kylyjFUnlYZZ3G0QkQZ4rYLXYTafAmiRjrfzgVb0LcMF/sBzJvGOk7SwtIDg==} engines: {node: '>=10'} cpu: [x64] os: [win32] - '@swc/core@1.10.7': - resolution: {integrity: sha512-py91kjI1jV5D5W/Q+PurBdGsdU5TFbrzamP7zSCqLdMcHkKi3rQEM5jkQcZr0MXXSJTaayLxS3MWYTBIkzPDrg==} + '@swc/core@1.10.9': + resolution: {integrity: sha512-MQ97YSXu2oibzm7wi4GNa7hhndjLuVt/lmO2sq53+P37oZmyg/JQ/IYYtSiC6UGK3+cHoiVAykrK+glxLjJbag==} engines: {node: '>=10'} peerDependencies: '@swc/helpers': '*' @@ -1350,20 +1350,20 @@ packages: '@types/node@22.10.7': resolution: {integrity: sha512-V09KvXxFiutGp6B7XkpaDXlNadZxrzajcY50EuoLIpQ6WWYCSvf19lVIazzfIzQvhUN2HjX12spLojTnhuKlGg==} - '@vitest/coverage-v8@3.0.2': - resolution: {integrity: sha512-U+hZYb0FtgNDb6B3E9piAHzXXIuxuBw2cd6Lvepc9sYYY4KjgiwCBmo3Sird9ZRu3ggLpLBTfw1ZRr77ipiSfw==} + '@vitest/coverage-v8@3.0.3': + resolution: {integrity: sha512-uVbJ/xhImdNtzPnLyxCZJMTeTIYdgcC2nWtBBBpR1H6z0w8m7D+9/zrDIx2nNxgMg9r+X8+RY2qVpUDeW2b3nw==} peerDependencies: - '@vitest/browser': 3.0.2 - vitest: 3.0.2 + '@vitest/browser': 3.0.3 + vitest: 3.0.3 peerDependenciesMeta: '@vitest/browser': optional: true - '@vitest/expect@3.0.2': - resolution: {integrity: sha512-dKSHLBcoZI+3pmP5hiZ7I5grNru2HRtEW8Z5Zp4IXog8QYcxhlox7JUPyIIFWfN53+3HW3KPLIl6nSzUGgKSuQ==} + '@vitest/expect@3.0.3': + resolution: {integrity: sha512-SbRCHU4qr91xguu+dH3RUdI5dC86zm8aZWydbp961aIR7G8OYNN6ZiayFuf9WAngRbFOfdrLHCGgXTj3GtoMRQ==} - '@vitest/mocker@3.0.2': - resolution: {integrity: sha512-Hr09FoBf0jlwwSyzIF4Xw31OntpO3XtZjkccpcBf8FeVW3tpiyKlkeUzxS/txzHqpUCNIX157NaTySxedyZLvA==} + '@vitest/mocker@3.0.3': + resolution: {integrity: sha512-XT2XBc4AN9UdaxJAeIlcSZ0ILi/GzmG5G8XSly4gaiqIvPV3HMTSIDZWJVX6QRJ0PX1m+W8Cy0K9ByXNb/bPIA==} peerDependencies: msw: ^2.4.9 vite: ^5.0.0 || ^6.0.0 @@ -1373,20 +1373,20 @@ packages: vite: optional: true - '@vitest/pretty-format@3.0.2': - resolution: {integrity: sha512-yBohcBw/T/p0/JRgYD+IYcjCmuHzjC3WLAKsVE4/LwiubzZkE8N49/xIQ/KGQwDRA8PaviF8IRO8JMWMngdVVQ==} + '@vitest/pretty-format@3.0.3': + resolution: {integrity: sha512-gCrM9F7STYdsDoNjGgYXKPq4SkSxwwIU5nkaQvdUxiQ0EcNlez+PdKOVIsUJvh9P9IeIFmjn4IIREWblOBpP2Q==} - '@vitest/runner@3.0.2': - resolution: {integrity: sha512-GHEsWoncrGxWuW8s405fVoDfSLk6RF2LCXp6XhevbtDjdDme1WV/eNmUueDfpY1IX3MJaCRelVCEXsT9cArfEg==} + '@vitest/runner@3.0.3': + resolution: {integrity: sha512-Rgi2kOAk5ZxWZlwPguRJFOBmWs6uvvyAAR9k3MvjRvYrG7xYvKChZcmnnpJCS98311CBDMqsW9MzzRFsj2gX3g==} - '@vitest/snapshot@3.0.2': - resolution: {integrity: sha512-h9s67yD4+g+JoYG0zPCo/cLTabpDqzqNdzMawmNPzDStTiwxwkyYM1v5lWE8gmGv3SVJ2DcxA2NpQJZJv9ym3g==} + '@vitest/snapshot@3.0.3': + resolution: {integrity: sha512-kNRcHlI4txBGztuJfPEJ68VezlPAXLRT1u5UCx219TU3kOG2DplNxhWLwDf2h6emwmTPogzLnGVwP6epDaJN6Q==} - '@vitest/spy@3.0.2': - resolution: {integrity: sha512-8mI2iUn+PJFMT44e3ISA1R+K6ALVs47W6eriDTfXe6lFqlflID05MB4+rIFhmDSLBj8iBsZkzBYlgSkinxLzSQ==} + '@vitest/spy@3.0.3': + resolution: {integrity: sha512-7/dgux8ZBbF7lEIKNnEqQlyRaER9nkAL9eTmdKJkDO3hS8p59ATGwKOCUDHcBLKr7h/oi/6hP+7djQk8049T2A==} - '@vitest/utils@3.0.2': - resolution: {integrity: sha512-Qu01ZYZlgHvDP02JnMBRpX43nRaZtNpIzw3C1clDXmn8eakgX6iQVGzTQ/NjkIr64WD8ioqOjkaYRVvHQI5qiw==} + '@vitest/utils@3.0.3': + resolution: {integrity: sha512-f+s8CvyzPtMFY1eZKkIHGhPsQgYo5qCm6O8KZoim9qm1/jT64qBgGpO5tHscNH6BzRHM+edLNOP+3vO8+8pE/A==} '@xhmikosr/archive-type@7.0.0': resolution: {integrity: sha512-sIm84ZneCOJuiy3PpWR5bxkx3HaNt1pqaN+vncUBZIlPZCq8ASZH+hBVdu5H8znR7qYC6sKwx+ie2Q7qztJTxA==} @@ -1917,8 +1917,8 @@ packages: fast-uri@2.4.0: resolution: {integrity: sha512-ypuAmmMKInk5q7XcepxlnUWDLWv4GFtaJqAzWKqn62IpQ3pejtr5dTVbt3vwqVaMKmkNR55sTT+CqUKIaT21BA==} - fast-uri@3.0.5: - resolution: {integrity: sha512-5JnBCWpFlMo0a3ciDy/JckMzzv1U9coZrIhedq+HXxxUfDTAiS0LA8OKVao4G9BxmCVck/jtA5r3KAtRWEyD8Q==} + fast-uri@3.0.6: + resolution: {integrity: sha512-Atfo14OibSv5wAp4VWNsFYE1AchQRTv9cBGWET4pZWHzYshFSS9NQI6I57rdKn9croWVMbYFbLhJ+yJvmZIIHw==} fast-xml-parser@4.5.1: resolution: {integrity: sha512-y655CeyUQ+jj7KBbYMc4FG01V8ZQqjN+gDYGJ50RtfsUB8iG9AmwmwoAgeKLJdmueKKMrH1RJ7yXHTSoczdv5w==} @@ -2009,8 +2009,8 @@ packages: resolution: {integrity: sha512-kVCxPF3vQM/N0B1PmoqVUqgHP+EeVjmZSQn+1oCRPxd2P21P2F19lIgbR3HBosbB1PUhOAoctJnfEn2GbN2eZA==} engines: {node: '>=18'} - get-tsconfig@4.8.1: - resolution: {integrity: sha512-k9PN+cFBmaLWtVz29SkUoqU5O0slLuHJXt/2P+tMVFT+phsSGXGkp9t3rQIqdz0e+06EHNGs3oM6ZX1s2zHxRg==} + get-tsconfig@4.10.0: + resolution: {integrity: sha512-kGzZ3LWWQcGIAmg6iWvXn0ei6WDtV26wzHRMwDSzmAbcXrTEXxHy6IehI6/4eT6VRKyMP1eF1VqwrVUmE/LR7A==} glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} @@ -2230,58 +2230,58 @@ packages: layerr@3.0.0: resolution: {integrity: sha512-tv754Ki2dXpPVApOrjTyRo4/QegVb9eVFq4mjqp4+NM5NaX7syQvN5BBNfV/ZpAHCEHV24XdUVrBAoka4jt3pA==} - lefthook-darwin-arm64@1.10.8: - resolution: {integrity: sha512-uE5oLjWuANaAyv6KQoWWGacZgKq5zGd3UmkWLE2OSSrZbgSdTz1R6Uios2yMXrGDptBX9PDWp9SNcHPhEoQlNw==} + lefthook-darwin-arm64@1.10.10: + resolution: {integrity: sha512-hEypKdwWpmNSl4Q8eJxgmlGb2ybJj1+W5/v13Mxc+ApEmjbpNiJzPcdjC9zyaMEpPK4EybiHy8g5ZC0dLOwkpA==} cpu: [arm64] os: [darwin] - lefthook-darwin-x64@1.10.8: - resolution: {integrity: sha512-502vfNdfJIDxLQKtlS3TbnM54PrV5wcssVvbDEnkLLjyrEImOZ3lVz3cqrT42KvFYFqgarrhII9jigqUxnLuSQ==} + lefthook-darwin-x64@1.10.10: + resolution: {integrity: sha512-9xNbeE78i4Amz+uOheg9dcy7X/6X12h98SUMrYWk7fONvjW/Bp9h6nPGIGxI5krHp9iRB8rhmo33ljVDVtTlyg==} cpu: [x64] os: [darwin] - lefthook-freebsd-arm64@1.10.8: - resolution: {integrity: sha512-xkqxIxEnFK9zyN3F3Lc11/byuYAR5z7FJBH5UTb2Wnxob7BwYfB0gXBcw3gKEYZiwHFNlyJQimndc7QWZ7y4kw==} + lefthook-freebsd-arm64@1.10.10: + resolution: {integrity: sha512-GT9wYxPxkvO1rtIAmctayT9xQIVII5xUIG3Pv6gZo+r6yEyle0EFTLFDbmVje7p7rQNCsvJ8XzCNdnyDrva90g==} cpu: [arm64] os: [freebsd] - lefthook-freebsd-x64@1.10.8: - resolution: {integrity: sha512-hCErafcyykVCIMb/6hzredNQ1ogDcz07lphf0k0eGUbr94XK7IUOkQwD++XOAijOHknkzS1V9WvjV1lrhGYtUA==} + lefthook-freebsd-x64@1.10.10: + resolution: {integrity: sha512-2BB/HRhEb9wGpk5K38iNkHtMPnn+TjXDtFG6C/AmUPLXLNhGnNiYp+v2uhUE8quWzxJx7QzfnU7Ga+/gzJcIcw==} cpu: [x64] os: [freebsd] - lefthook-linux-arm64@1.10.8: - resolution: {integrity: sha512-YFqT/hj+nzTTwzaDSdmYGKvpZI6/Wt3Id6+6gEU8VMAojXOe9rWAXitfoiDXW1TNPzpHqwyGnjOCcjquF1umkw==} + lefthook-linux-arm64@1.10.10: + resolution: {integrity: sha512-GJ7GALKJ1NcMnNZG9uY+zJR3yS8q7/MgcHFWSJhBl+w4KTiiD/RAdSl5ALwEK2+UX36Eo+7iQA7AXzaRdAii4w==} cpu: [arm64] os: [linux] - lefthook-linux-x64@1.10.8: - resolution: {integrity: sha512-nOARm1gE0EeMSEHaulpFDPnIqlQFPsFnaSkmCK2gWXG5jBbRtMr4BcJLDPzsekDKxskr5mZwlPQ2fFW3B/jiCA==} + lefthook-linux-x64@1.10.10: + resolution: {integrity: sha512-dWUvPM9YTIJ3+X9dB+8iOnzoVHbnNmpscmUqEOKSeizgBrvuuIYKZJGDyjEtw65Qnmn1SJ7ouSaKK93p5c7SkQ==} cpu: [x64] os: [linux] - lefthook-openbsd-arm64@1.10.8: - resolution: {integrity: sha512-6cUokm4Dd5OMNewVWIV9bM+nebBOrImCAOjbdfCEW4hhtIRvr6XZirHu0BVJM/I5Ed0MjiAme+L6yV7LW68HAA==} + lefthook-openbsd-arm64@1.10.10: + resolution: {integrity: sha512-KnwDyxOvbvGSBTbEF/OxkynZRPLowd3mIXUKHtkg3ABcQ4UREalX+Sh0nWU2dNjQbINx7Eh6B42TxNC7h+qXEg==} cpu: [arm64] os: [openbsd] - lefthook-openbsd-x64@1.10.8: - resolution: {integrity: sha512-659TblZOM7pV9ImSRjpMQSynA5L1DTcoS37TJN7Y/84O3pXhKYAN1Lm5EJFZQ1dBMEJDeAD/L1V98RWqnFx/gw==} + lefthook-openbsd-x64@1.10.10: + resolution: {integrity: sha512-49nnG886CI3WkrzVJ71D1M2KWpUYN1BP9LMKNzN11cmZ0j6dUK4hj3nbW+NcrKXxgYzzyLU3FFwrc51OVy2eKA==} cpu: [x64] os: [openbsd] - lefthook-windows-arm64@1.10.8: - resolution: {integrity: sha512-g5O44F+Mo0n2RzXL7A9g0TM5VA60OWWw7CPNLi42qOniv1t6/43glxB7bmKalrLAznFR5UbyiLMmO6ospDXctg==} + lefthook-windows-arm64@1.10.10: + resolution: {integrity: sha512-9ni0Tsnk+O5oL7EBfKj9C5ZctD1mrTyHCtiu1zQJBbREReJtPjIM9DwWzecfbuVfrIlpbviVQvx5mjZ44bqlWw==} cpu: [arm64] os: [win32] - lefthook-windows-x64@1.10.8: - resolution: {integrity: sha512-PZ72IXi29MdOCNZZvqRrBONMfe4DZU3GVowotLfHo4U/1oTTd2LImJitm0qbFjf9kCtRHLkD4K/l7ZgV4gsxtA==} + lefthook-windows-x64@1.10.10: + resolution: {integrity: sha512-gkKWYrlay4iecFfY1Ris5VcRYa0BaNJKMk0qE/wZmIpMgu4GvNg+f9BEwTMflkQIanABduT9lrECaL1lX5ClKw==} cpu: [x64] os: [win32] - lefthook@1.10.8: - resolution: {integrity: sha512-yJM97cNPH7zYbLUJ8G2LGhJbSRd66mv5BVeryLiEsmXER3vz4wGtiLJEYRwveSEZetOMBgAlVBIZEfuxJGsjIA==} + lefthook@1.10.10: + resolution: {integrity: sha512-YW0fTONgOXsephvXq2gIFbegCW19MHCyKYX7JDWmzVF1ZiVMnDBYUL/SP3i0RtFvlCmqENl4SgKwYYQGUMnvig==} hasBin: true light-my-request@6.5.1: @@ -2600,8 +2600,8 @@ packages: rfdc@1.4.1: resolution: {integrity: sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==} - rollup@4.30.1: - resolution: {integrity: sha512-mlJ4glW020fPuLi7DkM/lN97mYEZGWeqBnrljzN0gs7GLctqX3lNWxKQ7Gl712UAX+6fog/L3jh4gb7R6aVi3w==} + rollup@4.31.0: + resolution: {integrity: sha512-9cCE8P4rZLx9+PjoyqHLs31V9a9Vpvfo4qNcs6JCiGWYhw2gijSetFbH6SSy1whnkgcefnUwr8sad7tgqsGvnw==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true @@ -2898,8 +2898,8 @@ packages: resolution: {integrity: sha512-8JQkH4ooXnm1JCIhqTMbtmdnYEn6oKukBxHn1Ic9878jMkL7daTI7anTExfY18VRCX7tcdn5quzvCb6EWrR8PA==} hasBin: true - vite-node@3.0.2: - resolution: {integrity: sha512-hsEQerBAHvVAbv40m3TFQe/lTEbOp7yDpyqMJqr2Tnd+W58+DEYOt+fluQgekOePcsNBmR77lpVAnIU2Xu4SvQ==} + vite-node@3.0.3: + resolution: {integrity: sha512-0sQcwhwAEw/UJGojbhOrnq3HtiZ3tC7BzpAa0lx3QaTX0S3YX70iGcik25UBdB96pmdwjyY2uyKNYruxCDmiEg==} engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} hasBin: true @@ -2911,8 +2911,8 @@ packages: vite: optional: true - vite@6.0.7: - resolution: {integrity: sha512-RDt8r/7qx9940f8FcOIAH9PTViRrghKaK2K1jY3RaAURrEUbm9Du1mJ72G+jlhtG3WwodnfzY8ORQZbBavZEAQ==} + vite@6.0.11: + resolution: {integrity: sha512-4VL9mQPKoHy4+FE0NnRE/kbY51TOfaknxAjt3fJbGJxhIpBZiqVzlZDEesWWsuREXHwNdAoOFZ9MkPEVXczHwg==} engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} hasBin: true peerDependencies: @@ -2951,15 +2951,15 @@ packages: yaml: optional: true - vitest@3.0.2: - resolution: {integrity: sha512-5bzaHakQ0hmVVKLhfh/jXf6oETDBtgPo8tQCHYB+wftNgFJ+Hah67IsWc8ivx4vFL025Ow8UiuTf4W57z4izvQ==} + vitest@3.0.3: + resolution: {integrity: sha512-dWdwTFUW9rcnL0LyF2F+IfvNQWB0w9DERySCk8VMG75F8k25C7LsZoh6XfCjPvcR8Nb+Lqi9JKr6vnzH7HSrpQ==} engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} hasBin: true peerDependencies: '@edge-runtime/vm': '*' '@types/node': ^18.0.0 || ^20.0.0 || >=22.0.0 - '@vitest/browser': 3.0.2 - '@vitest/ui': 3.0.2 + '@vitest/browser': 3.0.3 + '@vitest/ui': 3.0.3 happy-dom: '*' jsdom: '*' peerDependenciesMeta: @@ -3128,7 +3128,7 @@ snapshots: '@esbuild-kit/esm-loader@2.6.5': dependencies: '@esbuild-kit/core-utils': 3.3.2 - get-tsconfig: 4.8.1 + get-tsconfig: 4.10.0 '@esbuild/aix-ppc64@0.19.12': optional: true @@ -3420,7 +3420,7 @@ snapshots: dependencies: ajv: 8.17.1 ajv-formats: 3.0.1(ajv@8.17.1) - fast-uri: 3.0.5 + fast-uri: 3.0.6 '@fastify/cors@10.0.2': dependencies: @@ -3704,61 +3704,61 @@ snapshots: '@pothos/core': 4.3.0(graphql@16.10.0) graphql: 16.10.0 - '@rollup/rollup-android-arm-eabi@4.30.1': + '@rollup/rollup-android-arm-eabi@4.31.0': optional: true - '@rollup/rollup-android-arm64@4.30.1': + '@rollup/rollup-android-arm64@4.31.0': optional: true - '@rollup/rollup-darwin-arm64@4.30.1': + '@rollup/rollup-darwin-arm64@4.31.0': optional: true - '@rollup/rollup-darwin-x64@4.30.1': + '@rollup/rollup-darwin-x64@4.31.0': optional: true - '@rollup/rollup-freebsd-arm64@4.30.1': + '@rollup/rollup-freebsd-arm64@4.31.0': optional: true - '@rollup/rollup-freebsd-x64@4.30.1': + '@rollup/rollup-freebsd-x64@4.31.0': optional: true - '@rollup/rollup-linux-arm-gnueabihf@4.30.1': + '@rollup/rollup-linux-arm-gnueabihf@4.31.0': optional: true - '@rollup/rollup-linux-arm-musleabihf@4.30.1': + '@rollup/rollup-linux-arm-musleabihf@4.31.0': optional: true - '@rollup/rollup-linux-arm64-gnu@4.30.1': + '@rollup/rollup-linux-arm64-gnu@4.31.0': optional: true - '@rollup/rollup-linux-arm64-musl@4.30.1': + '@rollup/rollup-linux-arm64-musl@4.31.0': optional: true - '@rollup/rollup-linux-loongarch64-gnu@4.30.1': + '@rollup/rollup-linux-loongarch64-gnu@4.31.0': optional: true - '@rollup/rollup-linux-powerpc64le-gnu@4.30.1': + '@rollup/rollup-linux-powerpc64le-gnu@4.31.0': optional: true - '@rollup/rollup-linux-riscv64-gnu@4.30.1': + '@rollup/rollup-linux-riscv64-gnu@4.31.0': optional: true - '@rollup/rollup-linux-s390x-gnu@4.30.1': + '@rollup/rollup-linux-s390x-gnu@4.31.0': optional: true - '@rollup/rollup-linux-x64-gnu@4.30.1': + '@rollup/rollup-linux-x64-gnu@4.31.0': optional: true - '@rollup/rollup-linux-x64-musl@4.30.1': + '@rollup/rollup-linux-x64-musl@4.31.0': optional: true - '@rollup/rollup-win32-arm64-msvc@4.30.1': + '@rollup/rollup-win32-arm64-msvc@4.31.0': optional: true - '@rollup/rollup-win32-ia32-msvc@4.30.1': + '@rollup/rollup-win32-ia32-msvc@4.31.0': optional: true - '@rollup/rollup-win32-x64-msvc@4.30.1': + '@rollup/rollup-win32-x64-msvc@4.31.0': optional: true '@sec-ant/readable-stream@0.4.1': {} @@ -3767,9 +3767,9 @@ snapshots: '@sindresorhus/is@5.6.0': {} - '@swc/cli@0.6.0(@swc/core@1.10.7)': + '@swc/cli@0.6.0(@swc/core@1.10.9)': dependencies: - '@swc/core': 1.10.7 + '@swc/core': 1.10.9 '@swc/counter': 0.1.3 '@xhmikosr/bin-wrapper': 13.0.5 commander: 8.3.0 @@ -3780,51 +3780,51 @@ snapshots: slash: 3.0.0 source-map: 0.7.4 - '@swc/core-darwin-arm64@1.10.7': + '@swc/core-darwin-arm64@1.10.9': optional: true - '@swc/core-darwin-x64@1.10.7': + '@swc/core-darwin-x64@1.10.9': optional: true - '@swc/core-linux-arm-gnueabihf@1.10.7': + '@swc/core-linux-arm-gnueabihf@1.10.9': optional: true - '@swc/core-linux-arm64-gnu@1.10.7': + '@swc/core-linux-arm64-gnu@1.10.9': optional: true - '@swc/core-linux-arm64-musl@1.10.7': + '@swc/core-linux-arm64-musl@1.10.9': optional: true - '@swc/core-linux-x64-gnu@1.10.7': + '@swc/core-linux-x64-gnu@1.10.9': optional: true - '@swc/core-linux-x64-musl@1.10.7': + '@swc/core-linux-x64-musl@1.10.9': optional: true - '@swc/core-win32-arm64-msvc@1.10.7': + '@swc/core-win32-arm64-msvc@1.10.9': optional: true - '@swc/core-win32-ia32-msvc@1.10.7': + '@swc/core-win32-ia32-msvc@1.10.9': optional: true - '@swc/core-win32-x64-msvc@1.10.7': + '@swc/core-win32-x64-msvc@1.10.9': optional: true - '@swc/core@1.10.7': + '@swc/core@1.10.9': dependencies: '@swc/counter': 0.1.3 '@swc/types': 0.1.17 optionalDependencies: - '@swc/core-darwin-arm64': 1.10.7 - '@swc/core-darwin-x64': 1.10.7 - '@swc/core-linux-arm-gnueabihf': 1.10.7 - '@swc/core-linux-arm64-gnu': 1.10.7 - '@swc/core-linux-arm64-musl': 1.10.7 - '@swc/core-linux-x64-gnu': 1.10.7 - '@swc/core-linux-x64-musl': 1.10.7 - '@swc/core-win32-arm64-msvc': 1.10.7 - '@swc/core-win32-ia32-msvc': 1.10.7 - '@swc/core-win32-x64-msvc': 1.10.7 + '@swc/core-darwin-arm64': 1.10.9 + '@swc/core-darwin-x64': 1.10.9 + '@swc/core-linux-arm-gnueabihf': 1.10.9 + '@swc/core-linux-arm64-gnu': 1.10.9 + '@swc/core-linux-arm64-musl': 1.10.9 + '@swc/core-linux-x64-gnu': 1.10.9 + '@swc/core-linux-x64-musl': 1.10.9 + '@swc/core-win32-arm64-msvc': 1.10.9 + '@swc/core-win32-ia32-msvc': 1.10.9 + '@swc/core-win32-x64-msvc': 1.10.9 '@swc/counter@0.1.3': {} @@ -3851,7 +3851,7 @@ snapshots: dependencies: undici-types: 6.20.0 - '@vitest/coverage-v8@3.0.2(vitest@3.0.2(@types/node@22.10.7)(tsx@4.19.2))': + '@vitest/coverage-v8@3.0.3(vitest@3.0.3(@types/node@22.10.7)(tsx@4.19.2))': dependencies: '@ampproject/remapping': 2.3.0 '@bcoe/v8-coverage': 1.0.2 @@ -3865,47 +3865,47 @@ snapshots: std-env: 3.8.0 test-exclude: 7.0.1 tinyrainbow: 2.0.0 - vitest: 3.0.2(@types/node@22.10.7)(tsx@4.19.2) + vitest: 3.0.3(@types/node@22.10.7)(tsx@4.19.2) transitivePeerDependencies: - supports-color - '@vitest/expect@3.0.2': + '@vitest/expect@3.0.3': dependencies: - '@vitest/spy': 3.0.2 - '@vitest/utils': 3.0.2 + '@vitest/spy': 3.0.3 + '@vitest/utils': 3.0.3 chai: 5.1.2 tinyrainbow: 2.0.0 - '@vitest/mocker@3.0.2(vite@6.0.7(@types/node@22.10.7)(tsx@4.19.2))': + '@vitest/mocker@3.0.3(vite@6.0.11(@types/node@22.10.7)(tsx@4.19.2))': dependencies: - '@vitest/spy': 3.0.2 + '@vitest/spy': 3.0.3 estree-walker: 3.0.3 magic-string: 0.30.17 optionalDependencies: - vite: 6.0.7(@types/node@22.10.7)(tsx@4.19.2) + vite: 6.0.11(@types/node@22.10.7)(tsx@4.19.2) - '@vitest/pretty-format@3.0.2': + '@vitest/pretty-format@3.0.3': dependencies: tinyrainbow: 2.0.0 - '@vitest/runner@3.0.2': + '@vitest/runner@3.0.3': dependencies: - '@vitest/utils': 3.0.2 + '@vitest/utils': 3.0.3 pathe: 2.0.2 - '@vitest/snapshot@3.0.2': + '@vitest/snapshot@3.0.3': dependencies: - '@vitest/pretty-format': 3.0.2 + '@vitest/pretty-format': 3.0.3 magic-string: 0.30.17 pathe: 2.0.2 - '@vitest/spy@3.0.2': + '@vitest/spy@3.0.3': dependencies: tinyspy: 3.0.2 - '@vitest/utils@3.0.2': + '@vitest/utils@3.0.3': dependencies: - '@vitest/pretty-format': 3.0.2 + '@vitest/pretty-format': 3.0.3 loupe: 3.1.2 tinyrainbow: 2.0.0 @@ -3998,7 +3998,7 @@ snapshots: ajv@8.17.1: dependencies: fast-deep-equal: 3.1.3 - fast-uri: 3.0.5 + fast-uri: 3.0.6 json-schema-traverse: 1.0.0 require-from-string: 2.0.2 @@ -4439,7 +4439,7 @@ snapshots: '@fastify/merge-json-schemas': 0.2.1 ajv: 8.17.1 ajv-formats: 3.0.1(ajv@8.17.1) - fast-uri: 3.0.5 + fast-uri: 3.0.6 json-schema-ref-resolver: 2.0.1 rfdc: 1.4.1 @@ -4460,7 +4460,7 @@ snapshots: fast-uri@2.4.0: {} - fast-uri@3.0.5: {} + fast-uri@3.0.6: {} fast-xml-parser@4.5.1: dependencies: @@ -4578,7 +4578,7 @@ snapshots: '@sec-ant/readable-stream': 0.4.1 is-stream: 4.0.1 - get-tsconfig@4.8.1: + get-tsconfig@4.10.0: dependencies: resolve-pkg-maps: 1.0.0 @@ -4807,48 +4807,48 @@ snapshots: layerr@3.0.0: {} - lefthook-darwin-arm64@1.10.8: + lefthook-darwin-arm64@1.10.10: optional: true - lefthook-darwin-x64@1.10.8: + lefthook-darwin-x64@1.10.10: optional: true - lefthook-freebsd-arm64@1.10.8: + lefthook-freebsd-arm64@1.10.10: optional: true - lefthook-freebsd-x64@1.10.8: + lefthook-freebsd-x64@1.10.10: optional: true - lefthook-linux-arm64@1.10.8: + lefthook-linux-arm64@1.10.10: optional: true - lefthook-linux-x64@1.10.8: + lefthook-linux-x64@1.10.10: optional: true - lefthook-openbsd-arm64@1.10.8: + lefthook-openbsd-arm64@1.10.10: optional: true - lefthook-openbsd-x64@1.10.8: + lefthook-openbsd-x64@1.10.10: optional: true - lefthook-windows-arm64@1.10.8: + lefthook-windows-arm64@1.10.10: optional: true - lefthook-windows-x64@1.10.8: + lefthook-windows-x64@1.10.10: optional: true - lefthook@1.10.8: + lefthook@1.10.10: optionalDependencies: - lefthook-darwin-arm64: 1.10.8 - lefthook-darwin-x64: 1.10.8 - lefthook-freebsd-arm64: 1.10.8 - lefthook-freebsd-x64: 1.10.8 - lefthook-linux-arm64: 1.10.8 - lefthook-linux-x64: 1.10.8 - lefthook-openbsd-arm64: 1.10.8 - lefthook-openbsd-x64: 1.10.8 - lefthook-windows-arm64: 1.10.8 - lefthook-windows-x64: 1.10.8 + lefthook-darwin-arm64: 1.10.10 + lefthook-darwin-x64: 1.10.10 + lefthook-freebsd-arm64: 1.10.10 + lefthook-freebsd-x64: 1.10.10 + lefthook-linux-arm64: 1.10.10 + lefthook-linux-x64: 1.10.10 + lefthook-openbsd-arm64: 1.10.10 + lefthook-openbsd-x64: 1.10.10 + lefthook-windows-arm64: 1.10.10 + lefthook-windows-x64: 1.10.10 light-my-request@6.5.1: dependencies: @@ -5158,29 +5158,29 @@ snapshots: rfdc@1.4.1: {} - rollup@4.30.1: + rollup@4.31.0: dependencies: '@types/estree': 1.0.6 optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.30.1 - '@rollup/rollup-android-arm64': 4.30.1 - '@rollup/rollup-darwin-arm64': 4.30.1 - '@rollup/rollup-darwin-x64': 4.30.1 - '@rollup/rollup-freebsd-arm64': 4.30.1 - '@rollup/rollup-freebsd-x64': 4.30.1 - '@rollup/rollup-linux-arm-gnueabihf': 4.30.1 - '@rollup/rollup-linux-arm-musleabihf': 4.30.1 - '@rollup/rollup-linux-arm64-gnu': 4.30.1 - '@rollup/rollup-linux-arm64-musl': 4.30.1 - '@rollup/rollup-linux-loongarch64-gnu': 4.30.1 - '@rollup/rollup-linux-powerpc64le-gnu': 4.30.1 - '@rollup/rollup-linux-riscv64-gnu': 4.30.1 - '@rollup/rollup-linux-s390x-gnu': 4.30.1 - '@rollup/rollup-linux-x64-gnu': 4.30.1 - '@rollup/rollup-linux-x64-musl': 4.30.1 - '@rollup/rollup-win32-arm64-msvc': 4.30.1 - '@rollup/rollup-win32-ia32-msvc': 4.30.1 - '@rollup/rollup-win32-x64-msvc': 4.30.1 + '@rollup/rollup-android-arm-eabi': 4.31.0 + '@rollup/rollup-android-arm64': 4.31.0 + '@rollup/rollup-darwin-arm64': 4.31.0 + '@rollup/rollup-darwin-x64': 4.31.0 + '@rollup/rollup-freebsd-arm64': 4.31.0 + '@rollup/rollup-freebsd-x64': 4.31.0 + '@rollup/rollup-linux-arm-gnueabihf': 4.31.0 + '@rollup/rollup-linux-arm-musleabihf': 4.31.0 + '@rollup/rollup-linux-arm64-gnu': 4.31.0 + '@rollup/rollup-linux-arm64-musl': 4.31.0 + '@rollup/rollup-linux-loongarch64-gnu': 4.31.0 + '@rollup/rollup-linux-powerpc64le-gnu': 4.31.0 + '@rollup/rollup-linux-riscv64-gnu': 4.31.0 + '@rollup/rollup-linux-s390x-gnu': 4.31.0 + '@rollup/rollup-linux-x64-gnu': 4.31.0 + '@rollup/rollup-linux-x64-musl': 4.31.0 + '@rollup/rollup-win32-arm64-msvc': 4.31.0 + '@rollup/rollup-win32-ia32-msvc': 4.31.0 + '@rollup/rollup-win32-x64-msvc': 4.31.0 fsevents: 2.3.3 run-parallel@1.2.0: @@ -5417,7 +5417,7 @@ snapshots: tsx@4.19.2: dependencies: esbuild: 0.23.1 - get-tsconfig: 4.8.1 + get-tsconfig: 4.10.0 optionalDependencies: fsevents: 2.3.3 @@ -5448,13 +5448,13 @@ snapshots: uuidv7@1.0.2: {} - vite-node@3.0.2(@types/node@22.10.7)(tsx@4.19.2): + vite-node@3.0.3(@types/node@22.10.7)(tsx@4.19.2): dependencies: cac: 6.7.14 debug: 4.4.0 es-module-lexer: 1.6.0 pathe: 2.0.2 - vite: 6.0.7(@types/node@22.10.7)(tsx@4.19.2) + vite: 6.0.11(@types/node@22.10.7)(tsx@4.19.2) transitivePeerDependencies: - '@types/node' - jiti @@ -5469,36 +5469,36 @@ snapshots: - tsx - yaml - vite-tsconfig-paths@5.1.4(typescript@5.7.3)(vite@6.0.7(@types/node@22.10.7)(tsx@4.19.2)): + vite-tsconfig-paths@5.1.4(typescript@5.7.3)(vite@6.0.11(@types/node@22.10.7)(tsx@4.19.2)): dependencies: debug: 4.4.0 globrex: 0.1.2 tsconfck: 3.1.4(typescript@5.7.3) optionalDependencies: - vite: 6.0.7(@types/node@22.10.7)(tsx@4.19.2) + vite: 6.0.11(@types/node@22.10.7)(tsx@4.19.2) transitivePeerDependencies: - supports-color - typescript - vite@6.0.7(@types/node@22.10.7)(tsx@4.19.2): + vite@6.0.11(@types/node@22.10.7)(tsx@4.19.2): dependencies: esbuild: 0.24.2 postcss: 8.5.1 - rollup: 4.30.1 + rollup: 4.31.0 optionalDependencies: '@types/node': 22.10.7 fsevents: 2.3.3 tsx: 4.19.2 - vitest@3.0.2(@types/node@22.10.7)(tsx@4.19.2): + vitest@3.0.3(@types/node@22.10.7)(tsx@4.19.2): dependencies: - '@vitest/expect': 3.0.2 - '@vitest/mocker': 3.0.2(vite@6.0.7(@types/node@22.10.7)(tsx@4.19.2)) - '@vitest/pretty-format': 3.0.2 - '@vitest/runner': 3.0.2 - '@vitest/snapshot': 3.0.2 - '@vitest/spy': 3.0.2 - '@vitest/utils': 3.0.2 + '@vitest/expect': 3.0.3 + '@vitest/mocker': 3.0.3(vite@6.0.11(@types/node@22.10.7)(tsx@4.19.2)) + '@vitest/pretty-format': 3.0.3 + '@vitest/runner': 3.0.3 + '@vitest/snapshot': 3.0.3 + '@vitest/spy': 3.0.3 + '@vitest/utils': 3.0.3 chai: 5.1.2 debug: 4.4.0 expect-type: 1.1.0 @@ -5509,8 +5509,8 @@ snapshots: tinyexec: 0.3.2 tinypool: 1.0.2 tinyrainbow: 2.0.0 - vite: 6.0.7(@types/node@22.10.7)(tsx@4.19.2) - vite-node: 3.0.2(@types/node@22.10.7)(tsx@4.19.2) + vite: 6.0.11(@types/node@22.10.7)(tsx@4.19.2) + vite-node: 3.0.3(@types/node@22.10.7)(tsx@4.19.2) why-is-node-running: 2.3.0 optionalDependencies: '@types/node': 22.10.7 diff --git a/schema.graphql b/schema.graphql index 8b32474774e..e70f0e8bfaa 100644 --- a/schema.graphql +++ b/schema.graphql @@ -138,7 +138,7 @@ type AgendaItem { id: ID! """ - Key of the agenda item if it's type is "song". More information at [this](https://en.wikipedia.org/wiki/Key_(music)) link. + Key of the agenda item if it's of a "song" type. More information at [this](https://en.wikipedia.org/wiki/Key_(music)) link. """ key: String @@ -1101,10 +1101,7 @@ type Mutation { createTagFolder(input: MutationCreateTagFolderInput!): TagFolder """Mutation field to create a user.""" - createUser( - """Input required to create a user.""" - input: MutationCreateUserInput! - ): AuthenticationPayload + createUser(input: MutationCreateUserInput!): AuthenticationPayload """Mutation field to create a venue.""" createVenue(input: MutationCreateVenueInput!): Venue @@ -1170,22 +1167,16 @@ type Mutation { deleteTagFolder(input: MutationDeleteTagFolderInput!): TagFolder """Mutation field to delete a user.""" - deleteUser( - """Input required to delete a user.""" - input: MutationDeleteUserInput! - ): User + deleteUser(input: MutationDeleteUserInput!): User """Mutation field to delete a venue.""" deleteVenue(input: MutationDeleteVenueInput!): Venue - """Mutation field to delete an venue booking.""" + """Mutation field to delete a venue booking.""" deleteVenueBooking(input: MutationDeleteVenueBookingInput!): Venue """Mutation field to sign up to talawa.""" - signUp( - """Input required to sign up to talawa.""" - input: MutationSignUpInput! - ): AuthenticationPayload + signUp(input: MutationSignUpInput!): AuthenticationPayload """Mutation field to update an advertisement.""" updateAdvertisement(input: MutationUpdateAdvertisementInput!): Advertisement @@ -1215,10 +1206,7 @@ type Mutation { updateCommunity(input: MutationUpdateCommunityInput!): Community """Mutation field to update the current user.""" - updateCurrentUser( - """Input required to update the current user.""" - input: MutationUpdateCurrentUserInput! - ): User + updateCurrentUser(input: MutationUpdateCurrentUserInput!): User """Mutation field to update an event.""" updateEvent(input: MutationUpdateEventInput!): Event @@ -1251,10 +1239,7 @@ type Mutation { updateTagFolder(input: MutationUpdateTagFolderInput!): TagFolder """Mutation field to update a user.""" - updateUser( - """Input required to update a user.""" - input: MutationUpdateUserInput! - ): User + updateUser(input: MutationUpdateUserInput!): User """Mutation field to update a venue.""" updateVenue(input: MutationUpdateVenueInput!): Venue @@ -1290,7 +1275,7 @@ input MutationCreateAgendaFolderInput { eventId: ID! """ - Boolean to tell if the agenda folder is meant to be a folder for agenda items or a parent for agenda folders. + Boolean to tell if the agenda folder is meant to be a folder for agenda items or a parent folder for other agenda folders. """ isAgendaItemFolder: Boolean! @@ -1298,7 +1283,7 @@ input MutationCreateAgendaFolderInput { name: String! """ - Global identifier of the agenda folder the agenda folder is associated to. + Global identifier of the agenda folder the agenda folder is contained within. """ parentFolderId: ID } @@ -1317,7 +1302,7 @@ input MutationCreateAgendaItemInput { folderId: ID! """ - Key of the agenda item if it's type is "song". More information at [this](https://en.wikipedia.org/wiki/Key_(music)) link. + Key of the agenda item if it's of a "song" type. More information at [this](https://en.wikipedia.org/wiki/Key_(music)) link. """ key: String @@ -1618,10 +1603,10 @@ input MutationCreateUserInput { """""" input MutationCreateVenueBookingInput { - """Global identifier of the associated event.""" + """Global identifier of the event that the venue is to be booked for.""" eventId: ID! - """Global identifier of the associated venue.""" + """Global identifier of the venue to be booked.""" venueId: ID! } @@ -1768,10 +1753,10 @@ input MutationDeleteUserInput { """""" input MutationDeleteVenueBookingInput { - """Global identifier of the associated event.""" + """Global identifier of the event that the venue is booked for.""" eventId: ID! - """Global identifier of the associated venue.""" + """Global identifier of the venue that is booked.""" venueId: ID! } @@ -1872,7 +1857,7 @@ input MutationUpdateAgendaFolderInput { name: String """ - Global identifier of the agenda folder the agenda folder is associated to. + Global identifier of the agenda folder the agenda folder is contained within. """ parentFolderId: ID } @@ -1892,7 +1877,7 @@ input MutationUpdateAgendaItemInput { id: ID! """ - Key of the agenda item if it's type is "song". More information at [this](https://en.wikipedia.org/wiki/Key_(music)) link. + Key of the agenda item if it's of a "song" type. More information at [this](https://en.wikipedia.org/wiki/Key_(music)) link. """ key: String @@ -2678,10 +2663,7 @@ type Query { fundCampaignPledge(input: QueryFundCampaignPledgeInput!): FundCampaignPledge """Query field to read an organization.""" - organization( - """Input required to read an organization.""" - input: QueryOrganizationInput! - ): Organization + organization(input: QueryOrganizationInput!): Organization """Query field to read a post.""" post(input: QueryPostInput!): Post @@ -2692,10 +2674,7 @@ type Query { renewAuthenticationToken: String """Query field for a client to sign in to talawa.""" - signIn( - """Input required to sign in to talawa.""" - input: QuerySignInInput! - ): AuthenticationPayload + signIn(input: QuerySignInInput!): AuthenticationPayload """Query field to read a tag.""" tag(input: QueryTagInput!): Tag @@ -2817,14 +2796,14 @@ input QueryVenueInput { type Subscription { """ - Subscription field to subscribe to the event of creation of a chat message. + Subscription field to subscribe to the event of creation of a message in a chat. """ chatMessageCreate(input: SubscriptionChatMessageCreateInput!): ChatMessage } """""" input SubscriptionChatMessageCreateInput { - """Global id of the chat.""" + """Global identifier of the chat.""" id: String! } diff --git a/src/drizzle/tables/advertisements.ts b/src/drizzle/tables/advertisements.ts index 22e577c71d5..783e490dd21 100755 --- a/src/drizzle/tables/advertisements.ts +++ b/src/drizzle/tables/advertisements.ts @@ -114,13 +114,10 @@ export const advertisementsTableRelations = relations( /** * One to many relationship from `advertisements` table to `advertisement_attachments` table. */ - advertisementAttachmentsWhereAdvertisement: many( - advertisementAttachmentsTable, - { - relationName: - "advertisement_attachments.advertisement_id:advertisements.id", - }, - ), + attachmentsWhereAdvertisement: many(advertisementAttachmentsTable, { + relationName: + "advertisement_attachments.advertisement_id:advertisements.id", + }), /** * Many to one relationship from `advertisements` table to `users` table. */ @@ -151,7 +148,7 @@ export const advertisementsTableRelations = relations( export const advertisementsTableInsertSchema = createInsertSchema( advertisementsTable, { - description: (schema) => schema.min(1).max(2048), + description: (schema) => schema.min(1).max(2048).optional(), name: (schema) => schema.min(1).max(256), }, ); diff --git a/src/drizzle/tables/agendaFolders.ts b/src/drizzle/tables/agendaFolders.ts index 8290c00ed46..a9da679f9fc 100755 --- a/src/drizzle/tables/agendaFolders.ts +++ b/src/drizzle/tables/agendaFolders.ts @@ -51,7 +51,7 @@ export const agendaFoldersTable = pgTable( */ id: uuid("id").primaryKey().$default(uuidv7), /** - * Boolean to tell if the agenda folder is meant to be a folder for agenda items or a parent for agenda folders. + * Boolean to tell if the agenda folder is meant to be a folder for agenda items or a parent folder for other agenda folders. */ isAgendaItemFolder: boolean("is_agenda_item_folder").notNull(), /** @@ -59,7 +59,7 @@ export const agendaFoldersTable = pgTable( */ name: text("name", {}).notNull(), /** - * Foreign key reference to the id of the agenda folder the agenda folder is associated to. + * Foreign key reference to the id of the agenda folder the agenda folder is contained within. */ parentFolderId: uuid("parent_folder_id").references( (): AnyPgColumn => agendaFoldersTable.id, diff --git a/src/drizzle/tables/agendaItems.ts b/src/drizzle/tables/agendaItems.ts index 6da5c6de4b7..6b411a1c5b0 100755 --- a/src/drizzle/tables/agendaItems.ts +++ b/src/drizzle/tables/agendaItems.ts @@ -124,7 +124,7 @@ export const agendaItemsTableRelations = relations( export const agendaItemsTableInsertSchema = createInsertSchema( agendaItemsTable, { - description: (schema) => schema.min(1).max(2048), + description: (schema) => schema.min(1).max(2048).optional(), name: (schema) => schema.min(1).max(256), }, ); diff --git a/src/drizzle/tables/chats.ts b/src/drizzle/tables/chats.ts index a3207a8b49b..506bb8433ee 100644 --- a/src/drizzle/tables/chats.ts +++ b/src/drizzle/tables/chats.ts @@ -128,7 +128,7 @@ export const chatsTableRelations = relations(chatsTable, ({ one, many }) => ({ })); export const chatsTableInsertSchema = createInsertSchema(chatsTable, { - avatarName: (schema) => schema.min(1), - description: (schema) => schema.min(1).max(2048), + avatarName: (schema) => schema.min(1).optional(), + description: (schema) => schema.min(1).max(2048).optional(), name: (schema) => schema.min(1).max(256), }); diff --git a/src/drizzle/tables/commentVotes.ts b/src/drizzle/tables/commentVotes.ts index 450d0e36e3a..5f845ae3a39 100755 --- a/src/drizzle/tables/commentVotes.ts +++ b/src/drizzle/tables/commentVotes.ts @@ -65,13 +65,6 @@ export const commentVotesTable = pgTable( }) .$defaultFn(() => sql`${null}`) .$onUpdate(() => new Date()), - /** - * Foreign key reference to the id of the user who last updated the vote. - */ - updaterId: uuid("updated_id").references(() => usersTable.id, { - onDelete: "set null", - onUpdate: "cascade", - }), }, (self) => [ index().on(self.commentId), @@ -100,14 +93,6 @@ export const commentVotesTableRelations = relations( references: [usersTable.id], relationName: "comment_votes.creator_id:users.id", }), - /** - * Many to one relationship from `comment_votes` table to `users` table. - */ - updater: one(usersTable, { - fields: [commentVotesTable.updaterId], - references: [usersTable.id], - relationName: "comment_votes.updater_id:users.id", - }), }), ); diff --git a/src/drizzle/tables/comments.ts b/src/drizzle/tables/comments.ts index e1434143eba..cb63c47e21b 100755 --- a/src/drizzle/tables/comments.ts +++ b/src/drizzle/tables/comments.ts @@ -70,7 +70,7 @@ export const commentsTableRelations = relations( /** * One to many relationship from `comments` table to `comment_votes` table. */ - commentVotesWhereComment: many(commentVotesTable, { + votesWhereComment: many(commentVotesTable, { relationName: "comment_votes.comment_id:comments.id", }), /** diff --git a/src/drizzle/tables/events.ts b/src/drizzle/tables/events.ts index 254a7011a5d..9fb3ab96000 100755 --- a/src/drizzle/tables/events.ts +++ b/src/drizzle/tables/events.ts @@ -115,7 +115,7 @@ export const eventsTableRelations = relations(eventsTable, ({ many, one }) => ({ /** * One to many relationship from `events` table to `event_attachments` table. */ - eventAttachmentsWhereEvent: many(eventAttachmentsTable, { + attachmentsWhereEvent: many(eventAttachmentsTable, { relationName: "event_attachments.event_id:events.id", }), /** @@ -149,6 +149,6 @@ export const eventsTableRelations = relations(eventsTable, ({ many, one }) => ({ })); export const eventsTableInsertSchema = createInsertSchema(eventsTable, { - description: (schema) => schema.min(1).max(2048), + description: (schema) => schema.min(1).max(2048).optional(), name: (schema) => schema.min(1).max(256), }); diff --git a/src/drizzle/tables/fundCampaignPledges.ts b/src/drizzle/tables/fundCampaignPledges.ts index 13fd82c7f19..56492094348 100644 --- a/src/drizzle/tables/fundCampaignPledges.ts +++ b/src/drizzle/tables/fundCampaignPledges.ts @@ -135,6 +135,6 @@ export const fundCampaignPledgesTableInsertSchema = createInsertSchema( fundCampaignPledgesTable, { amount: (schema) => schema.min(1), - note: (schema) => schema.min(1).max(2048), + note: (schema) => schema.min(1).max(2048).optional(), }, ); diff --git a/src/drizzle/tables/organizationMemberships.ts b/src/drizzle/tables/organizationMemberships.ts index f538b52eb5f..c5bfb32de8d 100755 --- a/src/drizzle/tables/organizationMemberships.ts +++ b/src/drizzle/tables/organizationMemberships.ts @@ -92,24 +92,33 @@ export const organizationMembershipsTable = pgTable( export const organizationMembershipsTableRelations = relations( organizationMembershipsTable, ({ one }) => ({ + /** + * Many to one relationship from `organization_memberships` table to `users` table. + */ creator: one(usersTable, { fields: [organizationMembershipsTable.creatorId], references: [usersTable.id], relationName: "organization_memberships.creator_id:users.id", }), - + /** + * Many to one relationship from `organization_memberships` table to `users` table. + */ member: one(usersTable, { fields: [organizationMembershipsTable.memberId], references: [usersTable.id], relationName: "organization_memberships.member_id:users.id", }), - + /** + * Many to one relationship from `organization_memberships` table to `organizations` table. + */ organization: one(organizationsTable, { fields: [organizationMembershipsTable.organizationId], references: [organizationsTable.id], relationName: "organization_memberships.organization_id:organizations.id", }), - + /** + * Many to one relationship from `organization_memberships` table to `users` table. + */ updater: one(usersTable, { fields: [organizationMembershipsTable.updaterId], references: [usersTable.id], diff --git a/src/drizzle/tables/organizations.ts b/src/drizzle/tables/organizations.ts index 5554b872206..5f3f76d2544 100755 --- a/src/drizzle/tables/organizations.ts +++ b/src/drizzle/tables/organizations.ts @@ -170,13 +170,9 @@ export const organizationsTableRelations = relations( /** * One to many relationship from `organizations` table to `organization_memberships` table. */ - organizationMembershipsWhereOrganization: many( - organizationMembershipsTable, - { - relationName: - "organization_memberships.organization_id:organizations.id", - }, - ), + membershipsWhereOrganization: many(organizationMembershipsTable, { + relationName: "organization_memberships.organization_id:organizations.id", + }), /** * One to many relationship from `organizations` table to `posts` table. */ @@ -215,13 +211,13 @@ export const organizationsTableRelations = relations( export const organizationsTableInsertSchema = createInsertSchema( organizationsTable, { - addressLine1: (schema) => schema.min(1).max(1024), - addressLine2: (schema) => schema.min(1).max(1024), - avatarName: (schema) => schema.min(1), - city: (schema) => schema.min(1).max(64), - description: (schema) => schema.min(1).max(2048), + addressLine1: (schema) => schema.min(1).max(1024).optional(), + addressLine2: (schema) => schema.min(1).max(1024).optional(), + avatarName: (schema) => schema.min(1).optional(), + city: (schema) => schema.min(1).max(64).optional(), + description: (schema) => schema.min(1).max(2048).optional(), name: (schema) => schema.min(1).max(256), - postalCode: (schema) => schema.min(1).max(32), - state: (schema) => schema.min(1).max(64), + postalCode: (schema) => schema.min(1).max(32).optional(), + state: (schema) => schema.min(1).max(64).optional(), }, ); diff --git a/src/drizzle/tables/postVotes.ts b/src/drizzle/tables/postVotes.ts index 3124f1bf87d..6b5fbaf916e 100755 --- a/src/drizzle/tables/postVotes.ts +++ b/src/drizzle/tables/postVotes.ts @@ -65,13 +65,6 @@ export const postVotesTable = pgTable( }) .$defaultFn(() => sql`${null}`) .$onUpdate(() => new Date()), - /** - * Foreign key reference to the id of the user who last updated the vote. - */ - updaterId: uuid("updated_id").references(() => usersTable.id, { - onDelete: "set null", - onUpdate: "cascade", - }), }, (self) => [ index().on(self.creatorId), @@ -98,14 +91,6 @@ export const postVotesTableRelations = relations(postVotesTable, ({ one }) => ({ references: [postsTable.id], relationName: "post_votes.post_id:posts.id", }), - /** - * Many to one relationship from `post_votes` table to `users` table. - */ - updater: one(usersTable, { - fields: [postVotesTable.updaterId], - references: [usersTable.id], - relationName: "post_votes.updater_id:users.id", - }), })); export const postVotesTableInsertSchema = createInsertSchema(postVotesTable); diff --git a/src/drizzle/tables/posts.ts b/src/drizzle/tables/posts.ts index 91bb7917c3d..587bd2d85ce 100755 --- a/src/drizzle/tables/posts.ts +++ b/src/drizzle/tables/posts.ts @@ -110,13 +110,13 @@ export const postsTableRelations = relations(postsTable, ({ many, one }) => ({ /** * One to many relationship from `posts` table to `post_attachments` table. */ - postAttachmentsWherePost: many(postAttachmentsTable, { + attachmentsWherePost: many(postAttachmentsTable, { relationName: "post_attachments.post_id:posts.id", }), /** * One to many relationship from `posts` table to `post_votes` table. */ - postVotesWherePost: many(postVotesTable, { + votesWherePost: many(postVotesTable, { relationName: "post_votes.post_id:posts.id", }), /** diff --git a/src/drizzle/tables/users.ts b/src/drizzle/tables/users.ts index 6542e58f94d..29983bd0a76 100755 --- a/src/drizzle/tables/users.ts +++ b/src/drizzle/tables/users.ts @@ -529,12 +529,6 @@ export const usersTableRelations = relations(usersTable, ({ many, one }) => ({ postVotesWhereCreator: many(postVotesTable, { relationName: "post_votes.creator_id:users.id", }), - /** - * One to many relationship from `users` table to `post_votes` table. - */ - postVotesWhereUpdater: many(postVotesTable, { - relationName: "post_votes.updater_id:users.id", - }), /** * One to many relationship from `users` table to `tag_folders` table. */ @@ -648,13 +642,13 @@ export const usersTableRelations = relations(usersTable, ({ many, one }) => ({ })); export const usersTableInsertSchema = createInsertSchema(usersTable, { - addressLine1: (schema) => schema.min(1).max(1024), - addressLine2: (schema) => schema.min(1).max(1024), - avatarName: (schema) => schema.min(1), - city: (schema) => schema.min(1).max(64), - description: (schema) => schema.min(1).max(2048), + addressLine1: (schema) => schema.min(1).max(1024).optional(), + addressLine2: (schema) => schema.min(1).max(1024).optional(), + avatarName: (schema) => schema.min(1).optional(), + city: (schema) => schema.min(1).max(64).optional(), + description: (schema) => schema.min(1).max(2048).optional(), emailAddress: (schema) => schema.email(), name: (schema) => schema.min(1).max(256), - postalCode: (schema) => schema.min(1).max(32), - state: (schema) => schema.min(1).max(64), + postalCode: (schema) => schema.min(1).max(32).optional(), + state: (schema) => schema.min(1).max(64).optional(), }); diff --git a/src/drizzle/tables/venues.ts b/src/drizzle/tables/venues.ts index 4cc02aecd6a..319eba0e66b 100755 --- a/src/drizzle/tables/venues.ts +++ b/src/drizzle/tables/venues.ts @@ -113,7 +113,7 @@ export const venuesTableRelations = relations(venuesTable, ({ many, one }) => ({ /** * One to many relationship from `venues` table to `venue_attachments` table. */ - venueAttachmentsWhereVenue: many(venueAttachmentsTable, { + attachmentsWhereVenue: many(venueAttachmentsTable, { relationName: "venue_attachments.venue_id:venues.id", }), /** @@ -125,6 +125,6 @@ export const venuesTableRelations = relations(venuesTable, ({ many, one }) => ({ })); export const venuesTableInsertSchema = createInsertSchema(venuesTable, { - description: (schema) => schema.min(1).max(2048), + description: (schema) => schema.min(1).max(2048).optional(), name: (schema) => schema.min(1).max(256), }); diff --git a/src/graphql/inputs/MutationCreateAgendaFolderInput.ts b/src/graphql/inputs/MutationCreateAgendaFolderInput.ts index c86b07dfeb3..d31e937e05a 100644 --- a/src/graphql/inputs/MutationCreateAgendaFolderInput.ts +++ b/src/graphql/inputs/MutationCreateAgendaFolderInput.ts @@ -24,7 +24,7 @@ export const MutationCreateAgendaFolderInput = builder }), isAgendaItemFolder: t.boolean({ description: - "Boolean to tell if the agenda folder is meant to be a folder for agenda items or a parent for agenda folders.", + "Boolean to tell if the agenda folder is meant to be a folder for agenda items or a parent folder for other agenda folders.", required: true, }), name: t.string({ @@ -33,7 +33,7 @@ export const MutationCreateAgendaFolderInput = builder }), parentFolderId: t.id({ description: - "Global identifier of the agenda folder the agenda folder is associated to.", + "Global identifier of the agenda folder the agenda folder is contained within.", }), }), }); diff --git a/src/graphql/inputs/MutationCreateAgendaItemInput.ts b/src/graphql/inputs/MutationCreateAgendaItemInput.ts index 1e1da2ee428..e4573cb9122 100644 --- a/src/graphql/inputs/MutationCreateAgendaItemInput.ts +++ b/src/graphql/inputs/MutationCreateAgendaItemInput.ts @@ -71,7 +71,7 @@ export const MutationCreateAgendaItemInput = builder required: true, }), key: t.string({ - description: `Key of the agenda item if it's type is "song". More information at [this](https://en.wikipedia.org/wiki/Key_(music)) link.`, + description: `Key of the agenda item if it's of a "song" type. More information at [this](https://en.wikipedia.org/wiki/Key_(music)) link.`, }), name: t.string({ description: "Name of the agenda item.", diff --git a/src/graphql/inputs/MutationCreateVenueBookingInput.ts b/src/graphql/inputs/MutationCreateVenueBookingInput.ts index 20c82961bc0..57b6afe7eb0 100644 --- a/src/graphql/inputs/MutationCreateVenueBookingInput.ts +++ b/src/graphql/inputs/MutationCreateVenueBookingInput.ts @@ -16,11 +16,12 @@ export const MutationCreateVenueBookingInput = builder description: "", fields: (t) => ({ eventId: t.id({ - description: "Global identifier of the associated event.", + description: + "Global identifier of the event that the venue is to be booked for.", required: true, }), venueId: t.id({ - description: "Global identifier of the associated venue.", + description: "Global identifier of the venue to be booked.", required: true, }), }), diff --git a/src/graphql/inputs/MutationDeleteVenueBookingInput.ts b/src/graphql/inputs/MutationDeleteVenueBookingInput.ts index c7351ca1380..0d4552f9072 100644 --- a/src/graphql/inputs/MutationDeleteVenueBookingInput.ts +++ b/src/graphql/inputs/MutationDeleteVenueBookingInput.ts @@ -16,11 +16,12 @@ export const MutationDeleteVenueBookingInput = builder description: "", fields: (t) => ({ eventId: t.id({ - description: "Global identifier of the associated event.", + description: + "Global identifier of the event that the venue is booked for.", required: true, }), venueId: t.id({ - description: "Global identifier of the associated venue.", + description: "Global identifier of the venue that is booked.", required: true, }), }), diff --git a/src/graphql/inputs/MutationUpdateAgendaFolderInput.ts b/src/graphql/inputs/MutationUpdateAgendaFolderInput.ts index b864ccf2e59..8f215c42e87 100644 --- a/src/graphql/inputs/MutationUpdateAgendaFolderInput.ts +++ b/src/graphql/inputs/MutationUpdateAgendaFolderInput.ts @@ -35,7 +35,7 @@ export const MutationUpdateAgendaFolderInput = builder }), parentFolderId: t.id({ description: - "Global identifier of the agenda folder the agenda folder is associated to.", + "Global identifier of the agenda folder the agenda folder is contained within.", }), }), }); diff --git a/src/graphql/inputs/MutationUpdateAgendaItemInput.ts b/src/graphql/inputs/MutationUpdateAgendaItemInput.ts index 0a9b1c78380..5e532013faa 100644 --- a/src/graphql/inputs/MutationUpdateAgendaItemInput.ts +++ b/src/graphql/inputs/MutationUpdateAgendaItemInput.ts @@ -42,7 +42,7 @@ export const MutationUpdateAgendaItemInput = builder required: true, }), key: t.string({ - description: `Key of the agenda item if it's type is "song". More information at [this](https://en.wikipedia.org/wiki/Key_(music)) link.`, + description: `Key of the agenda item if it's of a "song" type. More information at [this](https://en.wikipedia.org/wiki/Key_(music)) link.`, }), name: t.string({ description: "Name of the agenda item.", diff --git a/src/graphql/inputs/SubscriptionChatMessageCreateInput.ts b/src/graphql/inputs/SubscriptionChatMessageCreateInput.ts index 92181d36940..a474af6378e 100644 --- a/src/graphql/inputs/SubscriptionChatMessageCreateInput.ts +++ b/src/graphql/inputs/SubscriptionChatMessageCreateInput.ts @@ -14,7 +14,7 @@ export const SubscriptionChatMessageCreateInput = builder description: "", fields: (t) => ({ id: t.string({ - description: "Global id of the chat.", + description: "Global identifier of the chat.", required: true, }), }), diff --git a/src/graphql/types/AgendaFolder/createdAt.ts b/src/graphql/types/AgendaFolder/createdAt.ts index 9ac93168dc7..1f23bde00b1 100644 --- a/src/graphql/types/AgendaFolder/createdAt.ts +++ b/src/graphql/types/AgendaFolder/createdAt.ts @@ -36,7 +36,7 @@ AgendaFolder.implement({ countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -71,8 +71,7 @@ AgendaFolder.implement({ } const currentUserOrganizationMembership = - existingEvent.organization - .organizationMembershipsWhereOrganization[0]; + existingEvent.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/AgendaFolder/creator.ts b/src/graphql/types/AgendaFolder/creator.ts index 5c761549512..de8bbc90216 100644 --- a/src/graphql/types/AgendaFolder/creator.ts +++ b/src/graphql/types/AgendaFolder/creator.ts @@ -34,7 +34,7 @@ AgendaFolder.implement({ countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -69,8 +69,7 @@ AgendaFolder.implement({ } const currentUserOrganizationMembership = - existingEvent.organization - .organizationMembershipsWhereOrganization[0]; + existingEvent.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/AgendaFolder/event.ts b/src/graphql/types/AgendaFolder/event.ts index 36cd4068eb4..0bee794dd74 100644 --- a/src/graphql/types/AgendaFolder/event.ts +++ b/src/graphql/types/AgendaFolder/event.ts @@ -13,7 +13,7 @@ AgendaFolder.implement({ where: (fields, operators) => operators.eq(fields.id, parent.eventId), with: { - eventAttachmentsWhereEvent: true, + attachmentsWhereEvent: true, }, }); @@ -31,7 +31,7 @@ AgendaFolder.implement({ } return Object.assign(existingEvent, { - attachments: existingEvent.eventAttachmentsWhereEvent, + attachments: existingEvent.attachmentsWhereEvent, }); }, type: Event, diff --git a/src/graphql/types/AgendaFolder/updatedAt.ts b/src/graphql/types/AgendaFolder/updatedAt.ts index 4428a515bcf..1208c01309b 100644 --- a/src/graphql/types/AgendaFolder/updatedAt.ts +++ b/src/graphql/types/AgendaFolder/updatedAt.ts @@ -36,7 +36,7 @@ AgendaFolder.implement({ countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -71,8 +71,7 @@ AgendaFolder.implement({ } const currentUserOrganizationMembership = - existingEvent.organization - .organizationMembershipsWhereOrganization[0]; + existingEvent.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/AgendaFolder/updater.ts b/src/graphql/types/AgendaFolder/updater.ts index ed54622c6b9..e70611dafcd 100644 --- a/src/graphql/types/AgendaFolder/updater.ts +++ b/src/graphql/types/AgendaFolder/updater.ts @@ -34,7 +34,7 @@ AgendaFolder.implement({ countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -69,8 +69,7 @@ AgendaFolder.implement({ } const currentUserOrganizationMembership = - existingEvent.organization - .organizationMembershipsWhereOrganization[0]; + existingEvent.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/AgendaItem/AgendaItem.ts b/src/graphql/types/AgendaItem/AgendaItem.ts index 99246694a18..d29881d3bd4 100644 --- a/src/graphql/types/AgendaItem/AgendaItem.ts +++ b/src/graphql/types/AgendaItem/AgendaItem.ts @@ -21,7 +21,7 @@ AgendaItem.implement({ nullable: false, }), key: t.exposeString("key", { - description: `Key of the agenda item if it's type is "song". More information at [this](https://en.wikipedia.org/wiki/Key_(music)) link.`, + description: `Key of the agenda item if it's of a "song" type. More information at [this](https://en.wikipedia.org/wiki/Key_(music)) link.`, }), name: t.exposeString("name", { description: "Name of the agenda item.", diff --git a/src/graphql/types/AgendaItem/createdAt.ts b/src/graphql/types/AgendaItem/createdAt.ts index 579527a99de..27988522f16 100644 --- a/src/graphql/types/AgendaItem/createdAt.ts +++ b/src/graphql/types/AgendaItem/createdAt.ts @@ -41,7 +41,7 @@ AgendaItem.implement({ countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -79,7 +79,7 @@ AgendaItem.implement({ const currentUserOrganizationMembership = existingAgendaFolder.event.organization - .organizationMembershipsWhereOrganization[0]; + .membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/AgendaItem/creator.ts b/src/graphql/types/AgendaItem/creator.ts index b585faeb84e..edb0bfcde13 100644 --- a/src/graphql/types/AgendaItem/creator.ts +++ b/src/graphql/types/AgendaItem/creator.ts @@ -39,7 +39,7 @@ AgendaItem.implement({ countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -77,7 +77,7 @@ AgendaItem.implement({ const currentUserOrganizationMembership = existingAgendaFolder.event.organization - .organizationMembershipsWhereOrganization[0]; + .membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/AgendaItem/updatedAt.ts b/src/graphql/types/AgendaItem/updatedAt.ts index 3ced9f1ed3d..9125c967441 100644 --- a/src/graphql/types/AgendaItem/updatedAt.ts +++ b/src/graphql/types/AgendaItem/updatedAt.ts @@ -38,7 +38,7 @@ AgendaItem.implement({ countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -76,7 +76,7 @@ AgendaItem.implement({ const currentUserOrganizationMembership = existingAgendaFolder.event.organization - .organizationMembershipsWhereOrganization[0]; + .membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/AgendaItem/updater.ts b/src/graphql/types/AgendaItem/updater.ts index 8e1f620102b..1275370a308 100644 --- a/src/graphql/types/AgendaItem/updater.ts +++ b/src/graphql/types/AgendaItem/updater.ts @@ -39,7 +39,7 @@ AgendaItem.implement({ countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -77,7 +77,7 @@ AgendaItem.implement({ const currentUserOrganizationMembership = existingAgendaFolder.event.organization - .organizationMembershipsWhereOrganization[0]; + .membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Comment/post.ts b/src/graphql/types/Comment/post.ts index 4f950c4c583..835a1b56b50 100644 --- a/src/graphql/types/Comment/post.ts +++ b/src/graphql/types/Comment/post.ts @@ -10,7 +10,7 @@ Comment.implement({ const existingPost = await ctx.drizzleClient.query.postsTable.findFirst( { with: { - postAttachmentsWherePost: true, + attachmentsWherePost: true, }, where: (fields, operators) => operators.eq(fields.id, parent.postId), @@ -31,7 +31,7 @@ Comment.implement({ } return Object.assign(existingPost, { - attachments: existingPost.postAttachmentsWherePost, + attachments: existingPost.attachmentsWherePost, }); }, type: Post, diff --git a/src/graphql/types/Event/venues.ts b/src/graphql/types/Event/venues.ts index dfe46be85ce..05220f9804d 100644 --- a/src/graphql/types/Event/venues.ts +++ b/src/graphql/types/Event/venues.ts @@ -158,7 +158,7 @@ Event.implement({ with: { venue: { with: { - venueAttachmentsWhereVenue: true, + attachmentsWhereVenue: true, }, }, }, @@ -185,9 +185,9 @@ Event.implement({ venueId: booking.venueId, }), ).toString("base64url"), - createNode: ({ venue: { venueAttachmentsWhereVenue, ...venue } }) => + createNode: ({ venue: { attachmentsWhereVenue, ...venue } }) => Object.assign(venue, { - attachments: venueAttachmentsWhereVenue, + attachments: attachmentsWhereVenue, }), parsedArgs, rawNodes: venueBookings, diff --git a/src/graphql/types/FundCampaign/createdAt.ts b/src/graphql/types/FundCampaign/createdAt.ts index e76671c595d..d49cfb576e6 100644 --- a/src/graphql/types/FundCampaign/createdAt.ts +++ b/src/graphql/types/FundCampaign/createdAt.ts @@ -35,7 +35,7 @@ FundCampaign.implement({ countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -72,7 +72,7 @@ FundCampaign.implement({ } const currentUserOrganizationMembership = - existingFund.organization.organizationMembershipsWhereOrganization[0]; + existingFund.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/FundCampaign/creator.ts b/src/graphql/types/FundCampaign/creator.ts index f2932142710..60c72d0fb73 100644 --- a/src/graphql/types/FundCampaign/creator.ts +++ b/src/graphql/types/FundCampaign/creator.ts @@ -32,7 +32,7 @@ FundCampaign.implement({ countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -69,7 +69,7 @@ FundCampaign.implement({ } const currentUserOrganizationMembership = - existingFund.organization.organizationMembershipsWhereOrganization[0]; + existingFund.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/FundCampaign/pledgedAmount.ts b/src/graphql/types/FundCampaign/pledgedAmount.ts index 557ba5dbdd5..5f16ca427c7 100644 --- a/src/graphql/types/FundCampaign/pledgedAmount.ts +++ b/src/graphql/types/FundCampaign/pledgedAmount.ts @@ -1,5 +1,6 @@ import { eq, sum } from "drizzle-orm"; import { fundCampaignPledgesTable } from "~/src/drizzle/tables/fundCampaignPledges"; +import { TalawaGraphQLError } from "~/src/utilities/TalawaGraphQLError"; import { FundCampaign } from "./FundCampaign"; FundCampaign.implement({ @@ -14,6 +15,20 @@ FundCampaign.implement({ .from(fundCampaignPledgesTable) .where(eq(fundCampaignPledgesTable.campaignId, parent.id)); + // Selected postgres aggregate not being returned is an external defect unrelated to this code. It is very unlikely for this error to occur. + if (fundCampaignPledgedAmount === undefined) { + ctx.log.error( + "Postgres aggregate select operation unexpectedly returned an empty array instead of throwing an error.", + ); + + throw new TalawaGraphQLError({ + extensions: { + code: "unexpected", + }, + message: "Something went wrong. Please try again later.", + }); + } + if (fundCampaignPledgedAmount.amount === null) { return 0n; } diff --git a/src/graphql/types/FundCampaign/updatedAt.ts b/src/graphql/types/FundCampaign/updatedAt.ts index e50e5c47068..9026f946ed5 100644 --- a/src/graphql/types/FundCampaign/updatedAt.ts +++ b/src/graphql/types/FundCampaign/updatedAt.ts @@ -35,7 +35,7 @@ FundCampaign.implement({ countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -72,7 +72,7 @@ FundCampaign.implement({ } const currentUserOrganizationMembership = - existingFund.organization.organizationMembershipsWhereOrganization[0]; + existingFund.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/FundCampaign/updater.ts b/src/graphql/types/FundCampaign/updater.ts index c7aea0a38b3..fc057b96b1f 100644 --- a/src/graphql/types/FundCampaign/updater.ts +++ b/src/graphql/types/FundCampaign/updater.ts @@ -32,7 +32,7 @@ FundCampaign.implement({ countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -69,7 +69,7 @@ FundCampaign.implement({ } const currentUserOrganizationMembership = - existingFund.organization.organizationMembershipsWhereOrganization[0]; + existingFund.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/FundCampaignPledge/createdAt.ts b/src/graphql/types/FundCampaignPledge/createdAt.ts index c7202dea7d3..9ceb73f840a 100644 --- a/src/graphql/types/FundCampaignPledge/createdAt.ts +++ b/src/graphql/types/FundCampaignPledge/createdAt.ts @@ -41,7 +41,7 @@ FundCampaignPledge.implement({ countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -81,7 +81,7 @@ FundCampaignPledge.implement({ const currentUserOrganizationMembership = existingFundCampaign.fund.organization - .organizationMembershipsWhereOrganization[0]; + .membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/FundCampaignPledge/creator.ts b/src/graphql/types/FundCampaignPledge/creator.ts index 828f2c4f553..39b2ef484ef 100644 --- a/src/graphql/types/FundCampaignPledge/creator.ts +++ b/src/graphql/types/FundCampaignPledge/creator.ts @@ -37,7 +37,7 @@ FundCampaignPledge.implement({ countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -77,7 +77,7 @@ FundCampaignPledge.implement({ const currentUserOrganizationMembership = existingFundCampaign.fund.organization - .organizationMembershipsWhereOrganization[0]; + .membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/FundCampaignPledge/pledger.ts b/src/graphql/types/FundCampaignPledge/pledger.ts index c8a967b0702..5cef45df381 100644 --- a/src/graphql/types/FundCampaignPledge/pledger.ts +++ b/src/graphql/types/FundCampaignPledge/pledger.ts @@ -37,7 +37,7 @@ FundCampaignPledge.implement({ countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -77,7 +77,7 @@ FundCampaignPledge.implement({ const currentUserOrganizationMembership = existingFundCampaign.fund.organization - .organizationMembershipsWhereOrganization[0]; + .membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/FundCampaignPledge/updatedAt.ts b/src/graphql/types/FundCampaignPledge/updatedAt.ts index fd3b5cc70c5..bfb1e0fd562 100644 --- a/src/graphql/types/FundCampaignPledge/updatedAt.ts +++ b/src/graphql/types/FundCampaignPledge/updatedAt.ts @@ -40,7 +40,7 @@ FundCampaignPledge.implement({ countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -80,7 +80,7 @@ FundCampaignPledge.implement({ const currentUserOrganizationMembership = existingFundCampaign.fund.organization - .organizationMembershipsWhereOrganization[0]; + .membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/FundCampaignPledge/updater.ts b/src/graphql/types/FundCampaignPledge/updater.ts index 976fd2584ee..1f4012249f0 100644 --- a/src/graphql/types/FundCampaignPledge/updater.ts +++ b/src/graphql/types/FundCampaignPledge/updater.ts @@ -37,7 +37,7 @@ FundCampaignPledge.implement({ countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -77,7 +77,7 @@ FundCampaignPledge.implement({ const currentUserOrganizationMembership = existingFundCampaign.fund.organization - .organizationMembershipsWhereOrganization[0]; + .membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/createAdvertisement.ts b/src/graphql/types/Mutation/createAdvertisement.ts index b557258ae8d..173a1e13457 100644 --- a/src/graphql/types/Mutation/createAdvertisement.ts +++ b/src/graphql/types/Mutation/createAdvertisement.ts @@ -38,14 +38,11 @@ const mutationCreateAdvertisementArgumentsSchema = z.object({ } } } else { - return { - ...arg, - attachments: rawAttachments.map((attachment, index) => - Object.assign(attachment, { - mimetype: data[index], - }), - ), - }; + attachments = rawAttachments.map((attachment, index) => + Object.assign(attachment, { + mimetype: data[index], + }), + ); } } @@ -100,18 +97,6 @@ builder.mutationField("createAdvertisement", (t) => columns: { role: true, }, - with: { - organizationMembershipsWhereMember: { - columns: { - role: true, - }, - where: (fields, operators) => - operators.eq( - fields.organizationId, - parsedArgs.input.organizationId, - ), - }, - }, where: (fields, operators) => operators.eq(fields.id, currentUserId), }), ctx.drizzleClient.query.organizationsTable.findFirst({ @@ -126,6 +111,13 @@ builder.mutationField("createAdvertisement", (t) => where: (fields, operators) => operators.eq(fields.name, parsedArgs.input.name), }, + membershipsWhereOrganization: { + columns: { + role: true, + }, + where: (fields, operators) => + operators.eq(fields.memberId, currentUserId), + }, }, where: (fields, operators) => operators.eq(fields.id, parsedArgs.input.organizationId), @@ -171,7 +163,7 @@ builder.mutationField("createAdvertisement", (t) => } const currentUserOrganizationMembership = - currentUser.organizationMembershipsWhereMember[0]; + existingOrganization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && @@ -232,18 +224,20 @@ builder.mutationField("createAdvertisement", (t) => ) .returning(); - Promise.all( - createdAdvertisementAttachments.map((attachment, index) => - ctx.minio.client.putObject( - ctx.minio.bucketName, - attachment.name, - attachments[index].createReadStream(), - undefined, - { - "content-type": attachment.mimeType, - }, - ), - ), + await Promise.all( + createdAdvertisementAttachments.map((attachment, index) => { + if (attachments[index] !== undefined) { + return ctx.minio.client.putObject( + ctx.minio.bucketName, + attachment.name, + attachments[index].createReadStream(), + undefined, + { + "content-type": attachment.mimeType, + }, + ); + } + }), ); return Object.assign(createdAdvertisement, { diff --git a/src/graphql/types/Mutation/createAgendaFolder.ts b/src/graphql/types/Mutation/createAgendaFolder.ts index 033c071a92f..6031e04a179 100644 --- a/src/graphql/types/Mutation/createAgendaFolder.ts +++ b/src/graphql/types/Mutation/createAgendaFolder.ts @@ -69,7 +69,7 @@ builder.mutationField("createAgendaFolder", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -120,7 +120,7 @@ builder.mutationField("createAgendaFolder", (t) => code: "arguments_associated_resources_not_found", issues: [ { - argumentPath: ["input", "folderId"], + argumentPath: ["input", "parentFolderId"], }, ], }, @@ -133,14 +133,14 @@ builder.mutationField("createAgendaFolder", (t) => code: "forbidden_action_on_arguments_associated_resources", issues: [ { - argumentPath: ["input", "folderId"], + argumentPath: ["input", "parentFolderId"], message: - "This agenda folder must be associated to the provided event.", + "This agenda folder does not belong to the provided event.", }, { argumentPath: ["input", "eventId"], message: - "This event must be associated to the provided parent agenda folder.", + "This event does not contain the provided parent agenda folder.", }, ], }, @@ -153,9 +153,9 @@ builder.mutationField("createAgendaFolder", (t) => code: "forbidden_action_on_arguments_associated_resources", issues: [ { - argumentPath: ["input", "folderId"], + argumentPath: ["input", "parentFolderId"], message: - "This agenda folder cannot be a parent to agenda folders.", + "This agenda folder cannot be a parent folder for other agenda folders.", }, ], }, @@ -164,7 +164,7 @@ builder.mutationField("createAgendaFolder", (t) => } const currentUserOrganizationMembership = - existingEvent.organization.organizationMembershipsWhereOrganization[0]; + existingEvent.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/createAgendaItem.ts b/src/graphql/types/Mutation/createAgendaItem.ts index 19947087f06..db043d3cd73 100644 --- a/src/graphql/types/Mutation/createAgendaItem.ts +++ b/src/graphql/types/Mutation/createAgendaItem.ts @@ -73,7 +73,7 @@ builder.mutationField("createAgendaItem", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -127,8 +127,7 @@ builder.mutationField("createAgendaItem", (t) => } const currentUserOrganizationMembership = - existingAgendaFolder.event.organization - .organizationMembershipsWhereOrganization[0]; + existingAgendaFolder.event.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/createChat.ts b/src/graphql/types/Mutation/createChat.ts index 2b004231c93..57c1ca55bb0 100644 --- a/src/graphql/types/Mutation/createChat.ts +++ b/src/graphql/types/Mutation/createChat.ts @@ -32,13 +32,12 @@ const mutationCreateChatArgumentsSchema = z.object({ message: `Mime type "${rawAvatar.mimetype}" is not allowed.`, }); } else { - return { - ...arg, - avatar: Object.assign(rawAvatar, { - mimetype: data, - }), - }; + avatar = Object.assign(rawAvatar, { + mimetype: data, + }); } + } else if (arg.avatar !== undefined) { + avatar = null; } return { @@ -99,7 +98,7 @@ builder.mutationField("createChat", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -134,7 +133,7 @@ builder.mutationField("createChat", (t) => } const currentUserOrganizationMembership = - existingOrganization.organizationMembershipsWhereOrganization[0]; + existingOrganization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/createChatMembership.ts b/src/graphql/types/Mutation/createChatMembership.ts index 8fa4d741cb0..6e1e17e60c1 100644 --- a/src/graphql/types/Mutation/createChatMembership.ts +++ b/src/graphql/types/Mutation/createChatMembership.ts @@ -73,7 +73,7 @@ builder.mutationField("createChatMembership", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -168,7 +168,7 @@ builder.mutationField("createChatMembership", (t) => } const currentUserOrganizationMembership = - existingChat.organization.organizationMembershipsWhereOrganization[0]; + existingChat.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/createChatMessage.ts b/src/graphql/types/Mutation/createChatMessage.ts index ca1e26bafc5..5d69c1aa2a5 100644 --- a/src/graphql/types/Mutation/createChatMessage.ts +++ b/src/graphql/types/Mutation/createChatMessage.ts @@ -75,7 +75,7 @@ builder.mutationField("createChatMessage", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -141,7 +141,7 @@ builder.mutationField("createChatMessage", (t) => } const currentUserOrganizationMembership = - existingChat.organization.organizationMembershipsWhereOrganization[0]; + existingChat.organization.membershipsWhereOrganization[0]; const currentUserChatMembership = existingChat.chatMembershipsWhereChat[0]; diff --git a/src/graphql/types/Mutation/createComment.ts b/src/graphql/types/Mutation/createComment.ts index 7f67d6d0552..9ba0ea46a57 100644 --- a/src/graphql/types/Mutation/createComment.ts +++ b/src/graphql/types/Mutation/createComment.ts @@ -68,7 +68,7 @@ builder.mutationField("createComment", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -105,7 +105,7 @@ builder.mutationField("createComment", (t) => } const currentUserOrganizationMembership = - existingPost.organization.organizationMembershipsWhereOrganization[0]; + existingPost.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/createCommentVote.ts b/src/graphql/types/Mutation/createCommentVote.ts index a3feded0702..ccc8eed1d70 100644 --- a/src/graphql/types/Mutation/createCommentVote.ts +++ b/src/graphql/types/Mutation/createCommentVote.ts @@ -51,50 +51,48 @@ builder.mutationField("createCommentVote", (t) => const currentUserId = ctx.currentClient.user.id; - const [currentUser, existingComment, existingCommentVote] = - await Promise.all([ - ctx.drizzleClient.query.usersTable.findFirst({ - columns: { - role: true, - }, - where: (fields, operators) => - operators.eq(fields.id, currentUserId), - }), - ctx.drizzleClient.query.commentsTable.findFirst({ - with: { - post: { - columns: { - pinnedAt: true, - }, - with: { - organization: { - columns: { - countryCode: true, - }, - with: { - organizationMembershipsWhereOrganization: { - columns: { - role: true, - }, - where: (fields, operators) => - operators.eq(fields.memberId, currentUserId), + const [currentUser, existingComment] = await Promise.all([ + ctx.drizzleClient.query.usersTable.findFirst({ + columns: { + role: true, + }, + where: (fields, operators) => operators.eq(fields.id, currentUserId), + }), + ctx.drizzleClient.query.commentsTable.findFirst({ + with: { + post: { + columns: { + pinnedAt: true, + }, + with: { + organization: { + columns: { + countryCode: true, + }, + with: { + membershipsWhereOrganization: { + columns: { + role: true, }, + where: (fields, operators) => + operators.eq(fields.memberId, currentUserId), }, }, }, }, }, - where: (fields, operators) => - operators.eq(fields.id, parsedArgs.input.commentId), - }), - ctx.drizzleClient.query.commentVotesTable.findFirst({ - where: (fields, operators) => - operators.and( - operators.eq(fields.commentId, parsedArgs.input.commentId), + votesWhereComment: { + columns: { + type: true, + }, + where: (fields, operators) => operators.eq(fields.creatorId, currentUserId), - ), - }), - ]); + }, + }, + where: (fields, operators) => + operators.eq(fields.id, parsedArgs.input.commentId), + }), + ]); if (currentUser === undefined) { throw new TalawaGraphQLError({ @@ -117,6 +115,8 @@ builder.mutationField("createCommentVote", (t) => }); } + const existingCommentVote = existingComment.votesWhereComment[0]; + if (existingCommentVote !== undefined) { throw new TalawaGraphQLError({ extensions: { @@ -124,15 +124,15 @@ builder.mutationField("createCommentVote", (t) => issues: [ { argumentPath: ["input", "commentId"], - message: "This comment is already voted.", + message: "You have already voted this comment.", }, ], }, }); } + const currentUserOrganizationMembership = - existingComment.post.organization - .organizationMembershipsWhereOrganization[0]; + existingComment.post.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/createEvent.ts b/src/graphql/types/Mutation/createEvent.ts index ef951437f44..e3386f5ed15 100644 --- a/src/graphql/types/Mutation/createEvent.ts +++ b/src/graphql/types/Mutation/createEvent.ts @@ -38,14 +38,11 @@ const mutationCreateEventArgumentsSchema = z.object({ } } } else { - return { - ...arg, - attachments: rawAttachments.map((attachment, index) => - Object.assign(attachment, { - mimetype: data[index], - }), - ), - }; + attachments = rawAttachments.map((attachment, index) => + Object.assign(attachment, { + mimetype: data[index], + }), + ); } } @@ -107,7 +104,7 @@ builder.mutationField("createEvent", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -142,7 +139,7 @@ builder.mutationField("createEvent", (t) => } const currentUserOrganizationMembership = - existingOrganization.organizationMembershipsWhereOrganization[0]; + existingOrganization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && @@ -202,18 +199,20 @@ builder.mutationField("createEvent", (t) => ) .returning(); - Promise.all( - createdEventAttachments.map((attachment, index) => - ctx.minio.client.putObject( - ctx.minio.bucketName, - attachment.name, - attachments[index].createReadStream(), - undefined, - { - "content-type": attachment.mimeType, - }, - ), - ), + await Promise.all( + createdEventAttachments.map((attachment, index) => { + if (attachments[index] !== undefined) { + return ctx.minio.client.putObject( + ctx.minio.bucketName, + attachment.name, + attachments[index].createReadStream(), + undefined, + { + "content-type": attachment.mimeType, + }, + ); + } + }), ); return Object.assign(createdEvent, { diff --git a/src/graphql/types/Mutation/createFund.ts b/src/graphql/types/Mutation/createFund.ts index d0b52b3471a..3d9786cdb09 100644 --- a/src/graphql/types/Mutation/createFund.ts +++ b/src/graphql/types/Mutation/createFund.ts @@ -70,7 +70,7 @@ builder.mutationField("createFund", (t) => where: (fields, operators) => operators.eq(fields.name, parsedArgs.input.name), }, - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -122,7 +122,7 @@ builder.mutationField("createFund", (t) => } const currentUserOrganizationMembership = - existingOrganization.organizationMembershipsWhereOrganization[0]; + existingOrganization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/createFundCampaign.ts b/src/graphql/types/Mutation/createFundCampaign.ts index 5c428e89473..73b09f4c9f3 100644 --- a/src/graphql/types/Mutation/createFundCampaign.ts +++ b/src/graphql/types/Mutation/createFundCampaign.ts @@ -75,7 +75,7 @@ builder.mutationField("createFundCampaign", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -129,7 +129,7 @@ builder.mutationField("createFundCampaign", (t) => } const currentUserOrganizationMembership = - existingFund.organization.organizationMembershipsWhereOrganization[0]; + existingFund.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/createFundCampaignPledge.ts b/src/graphql/types/Mutation/createFundCampaignPledge.ts index 9ca10c1befa..dfa7dbd8b39 100644 --- a/src/graphql/types/Mutation/createFundCampaignPledge.ts +++ b/src/graphql/types/Mutation/createFundCampaignPledge.ts @@ -81,7 +81,7 @@ builder.mutationField("createFundCampaignPledge", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { memberId: true, role: true, @@ -211,7 +211,7 @@ builder.mutationField("createFundCampaignPledge", (t) => const [currentUserOrganizationMembership, pledgerOrganizationMembership] = [currentUserId, parsedArgs.input.pledgerId].map((id) => - existingFundCampaign.fund.organization.organizationMembershipsWhereOrganization.find( + existingFundCampaign.fund.organization.membershipsWhereOrganization.find( (membership) => membership.memberId === id, ), ); diff --git a/src/graphql/types/Mutation/createOrganization.ts b/src/graphql/types/Mutation/createOrganization.ts index 31dc3a77644..fc494c79b5d 100644 --- a/src/graphql/types/Mutation/createOrganization.ts +++ b/src/graphql/types/Mutation/createOrganization.ts @@ -32,13 +32,12 @@ const mutationCreateOrganizationArgumentsSchema = z.object({ message: `Mime type "${rawAvatar.mimetype}" is not allowed.`, }); } else { - return { - ...arg, - avatar: Object.assign(rawAvatar, { - mimetype: data, - }), - }; + avatar = Object.assign(rawAvatar, { + mimetype: data, + }); } + } else if (arg.avatar !== undefined) { + avatar = null; } return { diff --git a/src/graphql/types/Mutation/createOrganizationMembership.ts b/src/graphql/types/Mutation/createOrganizationMembership.ts index a92c76d2782..777f86a3ace 100644 --- a/src/graphql/types/Mutation/createOrganizationMembership.ts +++ b/src/graphql/types/Mutation/createOrganizationMembership.ts @@ -52,43 +52,36 @@ builder.mutationField("createOrganizationMembership", (t) => const currentUserId = ctx.currentClient.user.id; - const [ - currentUser, - existingMember, - existingOrganization, - existingOrganizationMembership, - ] = await Promise.all([ - ctx.drizzleClient.query.usersTable.findFirst({ - columns: { - role: true, - }, - where: (fields, operators) => operators.eq(fields.id, currentUserId), - }), - ctx.drizzleClient.query.usersTable.findFirst({ - columns: { - role: true, - }, - where: (fields, operators) => - operators.eq(fields.id, parsedArgs.input.memberId), - }), - ctx.drizzleClient.query.organizationsTable.findFirst({ - where: (fields, operators) => - operators.eq(fields.id, parsedArgs.input.organizationId), - }), - ctx.drizzleClient.query.organizationMembershipsTable.findFirst({ - columns: { - role: true, - }, - where: (fields, operators) => - operators.and( - operators.eq(fields.memberId, parsedArgs.input.memberId), - operators.eq( - fields.organizationId, - parsedArgs.input.organizationId, - ), - ), - }), - ]); + const [currentUser, existingMember, existingOrganization] = + await Promise.all([ + ctx.drizzleClient.query.usersTable.findFirst({ + columns: { + role: true, + }, + where: (fields, operators) => + operators.eq(fields.id, currentUserId), + }), + ctx.drizzleClient.query.usersTable.findFirst({ + columns: { + role: true, + }, + where: (fields, operators) => + operators.eq(fields.id, parsedArgs.input.memberId), + }), + ctx.drizzleClient.query.organizationsTable.findFirst({ + where: (fields, operators) => + operators.eq(fields.id, parsedArgs.input.organizationId), + with: { + membershipsWhereOrganization: { + columns: { + role: true, + }, + where: (fields, operators) => + operators.eq(fields.memberId, parsedArgs.input.memberId), + }, + }, + }), + ]); if (currentUser === undefined) { throw new TalawaGraphQLError({ @@ -140,6 +133,9 @@ builder.mutationField("createOrganizationMembership", (t) => }); } + const existingOrganizationMembership = + existingOrganization.membershipsWhereOrganization[0]; + if (existingOrganizationMembership !== undefined) { throw new TalawaGraphQLError({ extensions: { @@ -148,11 +144,11 @@ builder.mutationField("createOrganizationMembership", (t) => { argumentPath: ["input", "memberId"], message: - "This user already has the membership of the associated organization.", + "This user already has the membership of the organization.", }, { argumentPath: ["input", "organizationId"], - message: "This organization already has the associated member.", + message: "This organization already has the user as a member.", }, ], }, @@ -160,11 +156,26 @@ builder.mutationField("createOrganizationMembership", (t) => } if (currentUser.role !== "administrator") { + // Only administrator users can create organization memberships for users other than themselves. + if (currentUserId !== parsedArgs.input.memberId) { + throw new TalawaGraphQLError({ + extensions: { + code: "unauthorized_action_on_arguments_associated_resources", + issues: [ + { + argumentPath: ["input", "memberId"], + }, + ], + }, + }); + } + const unauthorizedArgumentPaths = getKeyPathsWithNonUndefinedValues({ keyPaths: [["input", "role"]], object: parsedArgs, }); + // Only administrator users can provide the argument `input.role` for this graphql operation. if (unauthorizedArgumentPaths.length !== 0) { throw new TalawaGraphQLError({ extensions: { @@ -195,6 +206,7 @@ builder.mutationField("createOrganizationMembership", (t) => ctx.log.error( "Postgres insert operation unexpectedly returned an empty array instead of throwing an error.", ); + throw new TalawaGraphQLError({ extensions: { code: "unexpected", diff --git a/src/graphql/types/Mutation/createPost.ts b/src/graphql/types/Mutation/createPost.ts index c827a5d1bf5..b261addbbcf 100644 --- a/src/graphql/types/Mutation/createPost.ts +++ b/src/graphql/types/Mutation/createPost.ts @@ -39,14 +39,11 @@ const mutationCreatePostArgumentsSchema = z.object({ } } } else { - return { - ...arg, - attachments: rawAttachments.map((attachment, index) => - Object.assign(attachment, { - mimetype: data[index], - }), - ), - }; + attachments = rawAttachments.map((attachment, index) => + Object.assign(attachment, { + mimetype: data[index], + }), + ); } } @@ -108,7 +105,7 @@ builder.mutationField("createPost", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -144,7 +141,7 @@ builder.mutationField("createPost", (t) => if (currentUser.role !== "administrator") { const currentUserOrganizationMembership = - existingOrganization.organizationMembershipsWhereOrganization[0]; + existingOrganization.membershipsWhereOrganization[0]; if (currentUserOrganizationMembership === undefined) { throw new TalawaGraphQLError({ @@ -220,18 +217,20 @@ builder.mutationField("createPost", (t) => ) .returning(); - Promise.all( - createdPostAttachments.map((attachment, index) => - ctx.minio.client.putObject( - ctx.minio.bucketName, - attachment.name, - attachments[index].createReadStream(), - undefined, - { - "content-type": attachment.mimeType, - }, - ), - ), + await Promise.all( + createdPostAttachments.map((attachment, index) => { + if (attachments[index] !== undefined) { + return ctx.minio.client.putObject( + ctx.minio.bucketName, + attachment.name, + attachments[index].createReadStream(), + undefined, + { + "content-type": attachment.mimeType, + }, + ); + } + }), ); return Object.assign(createdPost, { diff --git a/src/graphql/types/Mutation/createPostVote.ts b/src/graphql/types/Mutation/createPostVote.ts index ef5706cbb53..2cd6daace73 100644 --- a/src/graphql/types/Mutation/createPostVote.ts +++ b/src/graphql/types/Mutation/createPostVote.ts @@ -51,7 +51,7 @@ builder.mutationField("createPostVote", (t) => const currentUserId = ctx.currentClient.user.id; - const [currentUser, existingPost, existingPostVote] = await Promise.all([ + const [currentUser, existingPost] = await Promise.all([ ctx.drizzleClient.query.usersTable.findFirst({ columns: { role: true, @@ -60,12 +60,13 @@ builder.mutationField("createPostVote", (t) => }), ctx.drizzleClient.query.postsTable.findFirst({ with: { + attachmentsWherePost: true, organization: { columns: { countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -74,7 +75,13 @@ builder.mutationField("createPostVote", (t) => }, }, }, - postAttachmentsWherePost: true, + votesWherePost: { + columns: { + type: true, + }, + where: (fields, operators) => + operators.eq(fields.creatorId, currentUserId), + }, }, where: (fields, operators) => operators.eq(fields.id, parsedArgs.input.postId), @@ -112,6 +119,8 @@ builder.mutationField("createPostVote", (t) => }); } + const existingPostVote = existingPost.votesWherePost[0]; + if (existingPostVote !== undefined) { throw new TalawaGraphQLError({ extensions: { @@ -125,8 +134,9 @@ builder.mutationField("createPostVote", (t) => }, }); } + const currentUserOrganizationMembership = - existingPost.organization.organizationMembershipsWhereOrganization[0]; + existingPost.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && @@ -158,6 +168,7 @@ builder.mutationField("createPostVote", (t) => ctx.log.error( "Postgres insert operation unexpectedly returned an empty array instead of throwing an error.", ); + throw new TalawaGraphQLError({ extensions: { code: "unexpected", @@ -166,7 +177,7 @@ builder.mutationField("createPostVote", (t) => } return Object.assign(existingPost, { - attachments: existingPost.postAttachmentsWherePost, + attachments: existingPost.attachmentsWherePost, }); }, type: Post, diff --git a/src/graphql/types/Mutation/createTag.ts b/src/graphql/types/Mutation/createTag.ts index 6e4f524c74d..2608f510c71 100644 --- a/src/graphql/types/Mutation/createTag.ts +++ b/src/graphql/types/Mutation/createTag.ts @@ -64,7 +64,7 @@ builder.mutationField("createTag", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -170,7 +170,7 @@ builder.mutationField("createTag", (t) => } const currentUserOrganizationMembership = - existingOrganization.organizationMembershipsWhereOrganization[0]; + existingOrganization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/createTagFolder.ts b/src/graphql/types/Mutation/createTagFolder.ts index 42f7bc0ced1..eee3b097b7e 100644 --- a/src/graphql/types/Mutation/createTagFolder.ts +++ b/src/graphql/types/Mutation/createTagFolder.ts @@ -64,7 +64,7 @@ builder.mutationField("createTagFolder", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -143,7 +143,7 @@ builder.mutationField("createTagFolder", (t) => } const currentUserOrganizationMembership = - existingOrganization.organizationMembershipsWhereOrganization[0]; + existingOrganization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/createUser.ts b/src/graphql/types/Mutation/createUser.ts index 9c8c208b34d..163bc56ff2d 100755 --- a/src/graphql/types/Mutation/createUser.ts +++ b/src/graphql/types/Mutation/createUser.ts @@ -33,13 +33,12 @@ const mutationCreateUserArgumentsSchema = z.object({ message: `Mime type "${rawAvatar.mimetype}" is not allowed.`, }); } else { - return { - ...arg, - avatar: Object.assign(rawAvatar, { - mimetype: data, - }), - }; + avatar = Object.assign(rawAvatar, { + mimetype: data, + }); } + } else if (arg.avatar !== undefined) { + avatar = null; } return { @@ -53,7 +52,7 @@ builder.mutationField("createUser", (t) => t.field({ args: { input: t.arg({ - description: "Input required to create a user.", + description: "", required: true, type: MutationCreateUserInput, }), @@ -138,8 +137,8 @@ builder.mutationField("createUser", (t) => let avatarName: string; if (isNotNullish(parsedArgs.input.avatar)) { - avatarName = ulid(); avatarMimeType = parsedArgs.input.avatar.mimetype; + avatarName = ulid(); } return await ctx.drizzleClient.transaction(async (tx) => { diff --git a/src/graphql/types/Mutation/createVenue.ts b/src/graphql/types/Mutation/createVenue.ts index e00102cf65f..92992e56570 100644 --- a/src/graphql/types/Mutation/createVenue.ts +++ b/src/graphql/types/Mutation/createVenue.ts @@ -38,14 +38,11 @@ const mutationCreateVenueArgumentsSchema = z.object({ } } } else { - return { - ...arg, - attachments: rawAttachments.map((attachment, index) => - Object.assign(attachment, { - mimetype: data[index], - }), - ), - }; + attachments = rawAttachments.map((attachment, index) => + Object.assign(attachment, { + mimetype: data[index], + }), + ); } } @@ -107,7 +104,7 @@ builder.mutationField("createVenue", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -116,7 +113,7 @@ builder.mutationField("createVenue", (t) => }, venuesWhereOrganization: { columns: { - updaterId: true, + updatedAt: true, }, where: (fields, operators) => operators.eq(fields.name, parsedArgs.input.name), @@ -166,7 +163,7 @@ builder.mutationField("createVenue", (t) => } const currentUserOrganizationMembership = - existingOrganization.organizationMembershipsWhereOrganization[0]; + existingOrganization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && @@ -224,18 +221,20 @@ builder.mutationField("createVenue", (t) => ) .returning(); - Promise.all( - createdVenueAttachments.map((attachment, index) => - ctx.minio.client.putObject( - ctx.minio.bucketName, - attachment.name, - attachments[index].createReadStream(), - undefined, - { - "content-type": attachment.mimeType, - }, - ), - ), + await Promise.all( + createdVenueAttachments.map((attachment, index) => { + if (attachments[index] !== undefined) { + return ctx.minio.client.putObject( + ctx.minio.bucketName, + attachment.name, + attachments[index].createReadStream(), + undefined, + { + "content-type": attachment.mimeType, + }, + ); + } + }), ); return Object.assign(createdVenue, { diff --git a/src/graphql/types/Mutation/createVenueBooking.ts b/src/graphql/types/Mutation/createVenueBooking.ts index 4a3153df4ff..9e0008d5d43 100644 --- a/src/graphql/types/Mutation/createVenueBooking.ts +++ b/src/graphql/types/Mutation/createVenueBooking.ts @@ -74,7 +74,7 @@ builder.mutationField("createVenueBooking", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -83,7 +83,7 @@ builder.mutationField("createVenueBooking", (t) => }, }, }, - venueAttachmentsWhereVenue: true, + attachmentsWhereVenue: true, venueBookingsWhereVenue: { columns: { creatorId: true, @@ -154,12 +154,11 @@ builder.mutationField("createVenueBooking", (t) => issues: [ { argumentPath: ["input", "eventId"], - message: "This event already has the associated venue booked.", + message: "This event has already the venue booked for it.", }, { argumentPath: ["input", "venueId"], - message: - "This venue is already booked by the associated event.", + message: "This venue is already booked for the event.", }, ], }, @@ -167,7 +166,7 @@ builder.mutationField("createVenueBooking", (t) => } const currentUserOrganizationMembership = - existingVenue.organization.organizationMembershipsWhereOrganization[0]; + existingVenue.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && @@ -212,7 +211,7 @@ builder.mutationField("createVenueBooking", (t) => } return Object.assign(existingVenue, { - attachments: existingVenue.venueAttachmentsWhereVenue, + attachments: existingVenue.attachmentsWhereVenue, }); }, type: Venue, diff --git a/src/graphql/types/Mutation/deleteAdvertisement.ts b/src/graphql/types/Mutation/deleteAdvertisement.ts index 056cd0f4b0c..fd4bff94b44 100644 --- a/src/graphql/types/Mutation/deleteAdvertisement.ts +++ b/src/graphql/types/Mutation/deleteAdvertisement.ts @@ -64,13 +64,13 @@ builder.mutationField("deleteAdvertisement", (t) => type: true, }, with: { - advertisementAttachmentsWhereAdvertisement: true, + attachmentsWhereAdvertisement: true, organization: { columns: { countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -107,8 +107,7 @@ builder.mutationField("deleteAdvertisement", (t) => } const currentUserOrganizationMembership = - existingAdvertisement.organization - .organizationMembershipsWhereOrganization[0]; + existingAdvertisement.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && @@ -144,14 +143,13 @@ builder.mutationField("deleteAdvertisement", (t) => await ctx.minio.client.removeObjects( ctx.minio.bucketName, - existingAdvertisement.advertisementAttachmentsWhereAdvertisement.map( + existingAdvertisement.attachmentsWhereAdvertisement.map( (attachment) => attachment.name, ), ); return Object.assign(deletedAdvertisement, { - attachments: - existingAdvertisement.advertisementAttachmentsWhereAdvertisement, + attachments: existingAdvertisement.attachmentsWhereAdvertisement, }); }); }, diff --git a/src/graphql/types/Mutation/deleteAgendaFolder.ts b/src/graphql/types/Mutation/deleteAgendaFolder.ts index e0411b161bf..75a77937331 100644 --- a/src/graphql/types/Mutation/deleteAgendaFolder.ts +++ b/src/graphql/types/Mutation/deleteAgendaFolder.ts @@ -74,7 +74,7 @@ builder.mutationField("deleteAgendaFolder", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -113,8 +113,7 @@ builder.mutationField("deleteAgendaFolder", (t) => } const currentUserOrganizationMembership = - existingAgendaFolder.event.organization - .organizationMembershipsWhereOrganization[0]; + existingAgendaFolder.event.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/deleteAgendaItem.ts b/src/graphql/types/Mutation/deleteAgendaItem.ts index 59e0a16d2b6..002562d7d26 100644 --- a/src/graphql/types/Mutation/deleteAgendaItem.ts +++ b/src/graphql/types/Mutation/deleteAgendaItem.ts @@ -79,7 +79,7 @@ builder.mutationField("deleteAgendaItem", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -121,7 +121,7 @@ builder.mutationField("deleteAgendaItem", (t) => const currentUserOrganizationMembership = existingAgendaItem.folder.event.organization - .organizationMembershipsWhereOrganization[0]; + .membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/deleteChat.ts b/src/graphql/types/Mutation/deleteChat.ts index c472aa761fb..3c4155f7cab 100644 --- a/src/graphql/types/Mutation/deleteChat.ts +++ b/src/graphql/types/Mutation/deleteChat.ts @@ -76,7 +76,7 @@ builder.mutationField("deleteChat", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -113,7 +113,7 @@ builder.mutationField("deleteChat", (t) => } const currentUserOrganizationMembership = - existingChat.organization.organizationMembershipsWhereOrganization[0]; + existingChat.organization.membershipsWhereOrganization[0]; const currentUserChatMembership = existingChat.chatMembershipsWhereChat[0]; diff --git a/src/graphql/types/Mutation/deleteChatMembership.ts b/src/graphql/types/Mutation/deleteChatMembership.ts index 15a3c1c1b6a..cf3555b6546 100644 --- a/src/graphql/types/Mutation/deleteChatMembership.ts +++ b/src/graphql/types/Mutation/deleteChatMembership.ts @@ -77,7 +77,7 @@ builder.mutationField("deleteChatMembership", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -175,7 +175,7 @@ builder.mutationField("deleteChatMembership", (t) => } const currentUserOrganizationMembership = - existingChat.organization.organizationMembershipsWhereOrganization[0]; + existingChat.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/deleteChatMessage.ts b/src/graphql/types/Mutation/deleteChatMessage.ts index 085bbc3869d..56f3374acd2 100644 --- a/src/graphql/types/Mutation/deleteChatMessage.ts +++ b/src/graphql/types/Mutation/deleteChatMessage.ts @@ -81,7 +81,7 @@ builder.mutationField("deleteChatMessage", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -120,8 +120,7 @@ builder.mutationField("deleteChatMessage", (t) => } const currentUserOrganizationMembership = - existingChatMessage.chat.organization - .organizationMembershipsWhereOrganization[0]; + existingChatMessage.chat.organization.membershipsWhereOrganization[0]; const currentUserChatMembership = existingChatMessage.chat.chatMembershipsWhereChat[0]; diff --git a/src/graphql/types/Mutation/deleteComment.ts b/src/graphql/types/Mutation/deleteComment.ts index dfb75232691..537fed85f05 100644 --- a/src/graphql/types/Mutation/deleteComment.ts +++ b/src/graphql/types/Mutation/deleteComment.ts @@ -74,7 +74,7 @@ builder.mutationField("deleteComment", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -113,8 +113,7 @@ builder.mutationField("deleteComment", (t) => } const currentUserOrganizationMembership = - existingComment.post.organization - .organizationMembershipsWhereOrganization[0]; + existingComment.post.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/deleteCommentVote.ts b/src/graphql/types/Mutation/deleteCommentVote.ts index 9f58a5cc406..a17dbf53699 100644 --- a/src/graphql/types/Mutation/deleteCommentVote.ts +++ b/src/graphql/types/Mutation/deleteCommentVote.ts @@ -52,56 +52,55 @@ builder.mutationField("deleteCommentVote", (t) => const currentUserId = ctx.currentClient.user.id; - const [ - currentUser, - existingComment, - existingCreator, - existingCommentVote, - ] = await Promise.all([ - ctx.drizzleClient.query.usersTable.findFirst({ - columns: { - role: true, - }, - where: (fields, operators) => operators.eq(fields.id, currentUserId), - }), - ctx.drizzleClient.query.commentsTable.findFirst({ - with: { - post: { - columns: { - pinnedAt: true, - }, - with: { - organization: { - columns: { - countryCode: true, - }, - with: { - organizationMembershipsWhereOrganization: { - columns: { - role: true, + const [currentUser, existingComment, existingCreator] = await Promise.all( + [ + ctx.drizzleClient.query.usersTable.findFirst({ + columns: { + role: true, + }, + where: (fields, operators) => + operators.eq(fields.id, currentUserId), + }), + ctx.drizzleClient.query.commentsTable.findFirst({ + with: { + post: { + columns: { + pinnedAt: true, + }, + with: { + organization: { + columns: { + countryCode: true, + }, + with: { + membershipsWhereOrganization: { + columns: { + role: true, + }, + where: (fields, operators) => + operators.eq(fields.memberId, currentUserId), }, - where: (fields, operators) => - operators.eq(fields.memberId, currentUserId), }, }, }, }, + votesWhereComment: { + columns: { + type: true, + }, + where: (fields, operators) => + operators.eq(fields.creatorId, currentUserId), + }, }, - }, - where: (fields, operators) => - operators.eq(fields.id, parsedArgs.input.commentId), - }), - ctx.drizzleClient.query.usersTable.findFirst({ - where: (fields, operators) => operators.eq(fields.id, currentUserId), - }), - ctx.drizzleClient.query.commentVotesTable.findFirst({ - where: (fields, operators) => - operators.and( - operators.eq(fields.commentId, parsedArgs.input.commentId), - operators.eq(fields.creatorId, currentUserId), - ), - }), - ]); + where: (fields, operators) => + operators.eq(fields.id, parsedArgs.input.commentId), + }), + ctx.drizzleClient.query.usersTable.findFirst({ + where: (fields, operators) => + operators.eq(fields.id, currentUserId), + }), + ], + ); if (currentUser === undefined) { throw new TalawaGraphQLError({ @@ -153,6 +152,8 @@ builder.mutationField("deleteCommentVote", (t) => }); } + const existingCommentVote = existingComment.votesWhereComment[0]; + if (existingCommentVote === undefined) { throw new TalawaGraphQLError({ extensions: { @@ -170,8 +171,7 @@ builder.mutationField("deleteCommentVote", (t) => } const currentUserOrganizationMembership = - existingComment.post.organization - .organizationMembershipsWhereOrganization[0]; + existingComment.post.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/deleteEvent.ts b/src/graphql/types/Mutation/deleteEvent.ts index 80639ebc510..d567a849fe5 100644 --- a/src/graphql/types/Mutation/deleteEvent.ts +++ b/src/graphql/types/Mutation/deleteEvent.ts @@ -64,13 +64,13 @@ builder.mutationField("deleteEvent", (t) => startAt: true, }, with: { - eventAttachmentsWhereEvent: true, + attachmentsWhereEvent: true, organization: { columns: { countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -107,7 +107,7 @@ builder.mutationField("deleteEvent", (t) => } const currentUserOrganizationMembership = - existingEvent.organization.organizationMembershipsWhereOrganization[0]; + existingEvent.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && @@ -143,13 +143,13 @@ builder.mutationField("deleteEvent", (t) => await ctx.minio.client.removeObjects( ctx.minio.bucketName, - existingEvent.eventAttachmentsWhereEvent.map( + existingEvent.attachmentsWhereEvent.map( (attachment) => attachment.name, ), ); return Object.assign(deletedEvent, { - attachments: existingEvent.eventAttachmentsWhereEvent, + attachments: existingEvent.attachmentsWhereEvent, }); }); }, diff --git a/src/graphql/types/Mutation/deleteFund.ts b/src/graphql/types/Mutation/deleteFund.ts index c50cb68539a..e028496628d 100644 --- a/src/graphql/types/Mutation/deleteFund.ts +++ b/src/graphql/types/Mutation/deleteFund.ts @@ -69,7 +69,7 @@ builder.mutationField("deleteFund", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -106,7 +106,7 @@ builder.mutationField("deleteFund", (t) => } const currentUserOrganizationMembership = - existingFund.organization.organizationMembershipsWhereOrganization[0]; + existingFund.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/deleteFundCampaign.ts b/src/graphql/types/Mutation/deleteFundCampaign.ts index fee3d344216..aa78efac286 100644 --- a/src/graphql/types/Mutation/deleteFundCampaign.ts +++ b/src/graphql/types/Mutation/deleteFundCampaign.ts @@ -74,7 +74,7 @@ builder.mutationField("deleteFundCampaign", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -113,8 +113,7 @@ builder.mutationField("deleteFundCampaign", (t) => } const currentUserOrganizationMembership = - existingFundCampaign.fund.organization - .organizationMembershipsWhereOrganization[0]; + existingFundCampaign.fund.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/deleteFundCampaignPledge.ts b/src/graphql/types/Mutation/deleteFundCampaignPledge.ts index 733e78b712c..469b0771f64 100644 --- a/src/graphql/types/Mutation/deleteFundCampaignPledge.ts +++ b/src/graphql/types/Mutation/deleteFundCampaignPledge.ts @@ -79,7 +79,7 @@ builder.mutationField("deleteFundCampaignPledge", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -121,7 +121,7 @@ builder.mutationField("deleteFundCampaignPledge", (t) => const currentUserOrganizationMembership = existingFundCampaignPledge.campaign.fund.organization - .organizationMembershipsWhereOrganization[0]; + .membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/deleteOrganization.ts b/src/graphql/types/Mutation/deleteOrganization.ts index 2b7585da5b2..5902c66fa3a 100644 --- a/src/graphql/types/Mutation/deleteOrganization.ts +++ b/src/graphql/types/Mutation/deleteOrganization.ts @@ -71,7 +71,7 @@ builder.mutationField("deleteOrganization", (t) => type: true, }, with: { - advertisementAttachmentsWhereAdvertisement: true, + attachmentsWhereAdvertisement: true, }, }, chatsWhereOrganization: { @@ -84,7 +84,7 @@ builder.mutationField("deleteOrganization", (t) => startAt: true, }, with: { - eventAttachmentsWhereEvent: true, + attachmentsWhereEvent: true, }, }, postsWhereOrganization: { @@ -92,7 +92,7 @@ builder.mutationField("deleteOrganization", (t) => pinnedAt: true, }, with: { - postAttachmentsWherePost: true, + attachmentsWherePost: true, }, }, venuesWhereOrganization: { @@ -100,7 +100,7 @@ builder.mutationField("deleteOrganization", (t) => updatedAt: true, }, with: { - venueAttachmentsWhereVenue: true, + attachmentsWhereVenue: true, }, }, }, @@ -163,7 +163,7 @@ builder.mutationField("deleteOrganization", (t) => } for (const advertisement of existingOrganization.advertisementsWhereOrganization) { - for (const attachment of advertisement.advertisementAttachmentsWhereAdvertisement) { + for (const attachment of advertisement.attachmentsWhereAdvertisement) { objectNames.push(attachment.name); } } @@ -175,19 +175,19 @@ builder.mutationField("deleteOrganization", (t) => } for (const event of existingOrganization.eventsWhereOrganization) { - for (const attachment of event.eventAttachmentsWhereEvent) { + for (const attachment of event.attachmentsWhereEvent) { objectNames.push(attachment.name); } } for (const post of existingOrganization.postsWhereOrganization) { - for (const attachment of post.postAttachmentsWherePost) { + for (const attachment of post.attachmentsWherePost) { objectNames.push(attachment.name); } } for (const venue of existingOrganization.venuesWhereOrganization) { - for (const attachment of venue.venueAttachmentsWhereVenue) { + for (const attachment of venue.attachmentsWhereVenue) { objectNames.push(attachment.name); } } diff --git a/src/graphql/types/Mutation/deleteOrganizationMembership.ts b/src/graphql/types/Mutation/deleteOrganizationMembership.ts index 5446581beaa..3345167813f 100644 --- a/src/graphql/types/Mutation/deleteOrganizationMembership.ts +++ b/src/graphql/types/Mutation/deleteOrganizationMembership.ts @@ -73,7 +73,7 @@ builder.mutationField("deleteOrganizationMembership", (t) => }), ctx.drizzleClient.query.organizationsTable.findFirst({ with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -165,29 +165,28 @@ builder.mutationField("deleteOrganizationMembership", (t) => }); } - if (currentUser.role !== "administrator") { - const currentUserOrganizationMembership = - existingOrganization.organizationMembershipsWhereOrganization[0]; + const currentUserOrganizationMembership = + existingOrganization.membershipsWhereOrganization[0]; - if ( - currentUserOrganizationMembership === undefined || + if ( + currentUser.role !== "administrator" && + (currentUserOrganizationMembership === undefined || (currentUserOrganizationMembership.role !== "administrator" && - currentUserId !== parsedArgs.input.memberId) - ) { - throw new TalawaGraphQLError({ - extensions: { - code: "unauthorized_action_on_arguments_associated_resources", - issues: [ - { - argumentPath: ["input", "memberId"], - }, - { - argumentPath: ["input", "organizationId"], - }, - ], - }, - }); - } + currentUserId !== parsedArgs.input.memberId)) + ) { + throw new TalawaGraphQLError({ + extensions: { + code: "unauthorized_action_on_arguments_associated_resources", + issues: [ + { + argumentPath: ["input", "memberId"], + }, + { + argumentPath: ["input", "organizationId"], + }, + ], + }, + }); } const [deletedOrganizationMembership] = await ctx.drizzleClient diff --git a/src/graphql/types/Mutation/deletePost.ts b/src/graphql/types/Mutation/deletePost.ts index 4b1299eab9d..14a32eee1ff 100644 --- a/src/graphql/types/Mutation/deletePost.ts +++ b/src/graphql/types/Mutation/deletePost.ts @@ -64,13 +64,13 @@ builder.mutationField("deletePost", (t) => creatorId: true, }, with: { - postAttachmentsWherePost: true, + attachmentsWherePost: true, organization: { columns: { countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -108,7 +108,7 @@ builder.mutationField("deletePost", (t) => if (currentUser.role !== "administrator") { const currentUserOrganizationMembership = - existingPost.organization.organizationMembershipsWhereOrganization[0]; + existingPost.organization.membershipsWhereOrganization[0]; if ( currentUserOrganizationMembership === undefined || @@ -145,13 +145,13 @@ builder.mutationField("deletePost", (t) => await ctx.minio.client.removeObjects( ctx.minio.bucketName, - existingPost.postAttachmentsWherePost.map( + existingPost.attachmentsWherePost.map( (attachment) => attachment.name, ), ); return Object.assign(deletedPost, { - attachments: existingPost.postAttachmentsWherePost, + attachments: existingPost.attachmentsWherePost, }); }); }, diff --git a/src/graphql/types/Mutation/deletePostVote.ts b/src/graphql/types/Mutation/deletePostVote.ts index 09eeaab90da..17d3f3b1046 100644 --- a/src/graphql/types/Mutation/deletePostVote.ts +++ b/src/graphql/types/Mutation/deletePostVote.ts @@ -52,51 +52,56 @@ builder.mutationField("deletePostVote", (t) => const currentUserId = ctx.currentClient.user.id; - const [currentUser, existingCreator, existingPost, existingPostVote] = - await Promise.all([ - ctx.drizzleClient.query.usersTable.findFirst({ - columns: { - role: true, - }, - where: (fields, operators) => - operators.eq(fields.id, currentUserId), - }), - ctx.drizzleClient.query.usersTable.findFirst({ - where: (fields, operators) => - operators.eq(fields.id, parsedArgs.input.creatorId), - }), - ctx.drizzleClient.query.postsTable.findFirst({ - with: { - organization: { - columns: { - countryCode: true, - }, - with: { - organizationMembershipsWhereOrganization: { - columns: { - role: true, - }, - where: (fields, operators) => - operators.eq(fields.memberId, parsedArgs.input.creatorId), + const [currentUser, existingCreator, existingPost] = await Promise.all([ + ctx.drizzleClient.query.usersTable.findFirst({ + columns: { + role: true, + }, + where: (fields, operators) => operators.eq(fields.id, currentUserId), + }), + ctx.drizzleClient.query.usersTable.findFirst({ + where: (fields, operators) => + operators.eq(fields.id, parsedArgs.input.creatorId), + }), + ctx.drizzleClient.query.postsTable.findFirst({ + with: { + attachmentsWherePost: true, + organization: { + columns: { + countryCode: true, + }, + with: { + membershipsWhereOrganization: { + columns: { + role: true, }, + where: (fields, operators) => + operators.eq(fields.memberId, parsedArgs.input.creatorId), }, }, - postAttachmentsWherePost: true, }, - where: (fields, operators) => - operators.eq(fields.id, parsedArgs.input.postId), - }), - ctx.drizzleClient.query.postVotesTable.findFirst({ - columns: { - type: true, + votesWherePost: { + columns: { + type: true, + }, + where: (fields, operators) => + operators.eq(fields.creatorId, currentUserId), }, - where: (fields, operators) => - operators.and( - operators.eq(fields.creatorId, parsedArgs.input.creatorId), - operators.eq(fields.postId, parsedArgs.input.postId), - ), - }), - ]); + }, + where: (fields, operators) => + operators.eq(fields.id, parsedArgs.input.postId), + }), + ctx.drizzleClient.query.postVotesTable.findFirst({ + columns: { + type: true, + }, + where: (fields, operators) => + operators.and( + operators.eq(fields.creatorId, parsedArgs.input.creatorId), + operators.eq(fields.postId, parsedArgs.input.postId), + ), + }), + ]); if (currentUser === undefined) { throw new TalawaGraphQLError({ @@ -112,10 +117,10 @@ builder.mutationField("deletePostVote", (t) => code: "arguments_associated_resources_not_found", issues: [ { - argumentPath: ["input", "postId"], + argumentPath: ["input", "creatorId"], }, { - argumentPath: ["input", "creatorId"], + argumentPath: ["input", "postId"], }, ], }, @@ -148,16 +153,18 @@ builder.mutationField("deletePostVote", (t) => }); } + const existingPostVote = existingPost.votesWherePost[0]; + if (existingPostVote === undefined) { throw new TalawaGraphQLError({ extensions: { code: "arguments_associated_resources_not_found", issues: [ { - argumentPath: ["input", "postId"], + argumentPath: ["input", "creatorId"], }, { - argumentPath: ["input", "creatorId"], + argumentPath: ["input", "postId"], }, ], }, @@ -165,7 +172,7 @@ builder.mutationField("deletePostVote", (t) => } const currentUserOrganizationMembership = - existingPost.organization.organizationMembershipsWhereOrganization[0]; + existingPost.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && @@ -250,7 +257,7 @@ builder.mutationField("deletePostVote", (t) => } return Object.assign(existingPost, { - attachments: existingPost.postAttachmentsWherePost, + attachments: existingPost.attachmentsWherePost, }); }, type: Post, diff --git a/src/graphql/types/Mutation/deleteTag.ts b/src/graphql/types/Mutation/deleteTag.ts index 801b9d16162..eae1e5f5d42 100644 --- a/src/graphql/types/Mutation/deleteTag.ts +++ b/src/graphql/types/Mutation/deleteTag.ts @@ -68,7 +68,7 @@ builder.mutationField("deleteTag", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -105,7 +105,7 @@ builder.mutationField("deleteTag", (t) => } const currentUserOrganizationMembership = - existingTag.organization.organizationMembershipsWhereOrganization[0]; + existingTag.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/deleteTagFolder.ts b/src/graphql/types/Mutation/deleteTagFolder.ts index b929d0e3d09..672850d3ec2 100644 --- a/src/graphql/types/Mutation/deleteTagFolder.ts +++ b/src/graphql/types/Mutation/deleteTagFolder.ts @@ -68,7 +68,7 @@ builder.mutationField("deleteTagFolder", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -105,8 +105,7 @@ builder.mutationField("deleteTagFolder", (t) => } const currentUserOrganizationMembership = - existingTagFolder.organization - .organizationMembershipsWhereOrganization[0]; + existingTagFolder.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/deleteUser.ts b/src/graphql/types/Mutation/deleteUser.ts index e8923b8dacb..ecd42c9fd22 100755 --- a/src/graphql/types/Mutation/deleteUser.ts +++ b/src/graphql/types/Mutation/deleteUser.ts @@ -15,7 +15,7 @@ builder.mutationField("deleteUser", (t) => t.field({ args: { input: t.arg({ - description: "Input required to delete a user.", + description: "", required: true, type: MutationDeleteUserInput, }), diff --git a/src/graphql/types/Mutation/deleteVenue.ts b/src/graphql/types/Mutation/deleteVenue.ts index 8351fa50fb5..d5a9287f60f 100644 --- a/src/graphql/types/Mutation/deleteVenue.ts +++ b/src/graphql/types/Mutation/deleteVenue.ts @@ -69,7 +69,7 @@ builder.mutationField("deleteVenue", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -78,7 +78,7 @@ builder.mutationField("deleteVenue", (t) => }, }, }, - venueAttachmentsWhereVenue: true, + attachmentsWhereVenue: true, }, where: (fields, operators) => operators.eq(fields.id, parsedArgs.input.id), @@ -107,7 +107,7 @@ builder.mutationField("deleteVenue", (t) => } const currentUserOrganizationMembership = - existingVenue.organization.organizationMembershipsWhereOrganization[0]; + existingVenue.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && @@ -143,13 +143,13 @@ builder.mutationField("deleteVenue", (t) => await ctx.minio.client.removeObjects( ctx.minio.bucketName, - existingVenue.venueAttachmentsWhereVenue.map( + existingVenue.attachmentsWhereVenue.map( (attachment) => attachment.name, ), ); return Object.assign(deletedVenue, { - attachments: existingVenue.venueAttachmentsWhereVenue, + attachments: existingVenue.attachmentsWhereVenue, }); }); }, diff --git a/src/graphql/types/Mutation/deleteVenueBooking.ts b/src/graphql/types/Mutation/deleteVenueBooking.ts index 021c06c6b71..26d665faedc 100644 --- a/src/graphql/types/Mutation/deleteVenueBooking.ts +++ b/src/graphql/types/Mutation/deleteVenueBooking.ts @@ -22,7 +22,7 @@ builder.mutationField("deleteVenueBooking", (t) => type: MutationDeleteVenueBookingInput, }), }, - description: "Mutation field to delete an venue booking.", + description: "Mutation field to delete a venue booking.", resolve: async (_parent, args, ctx) => { if (!ctx.currentClient.isAuthenticated) { throw new TalawaGraphQLError({ @@ -75,7 +75,7 @@ builder.mutationField("deleteVenueBooking", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -84,7 +84,7 @@ builder.mutationField("deleteVenueBooking", (t) => }, }, }, - venueAttachmentsWhereVenue: true, + attachmentsWhereVenue: true, venueBookingsWhereVenue: { columns: { creatorId: true, @@ -165,7 +165,7 @@ builder.mutationField("deleteVenueBooking", (t) => } const currentUserOrganizationMembership = - existingVenue.organization.organizationMembershipsWhereOrganization[0]; + existingVenue.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && @@ -207,7 +207,7 @@ builder.mutationField("deleteVenueBooking", (t) => } return Object.assign(existingVenue, { - attachments: existingVenue.venueAttachmentsWhereVenue, + attachments: existingVenue.attachmentsWhereVenue, }); }, type: Venue, diff --git a/src/graphql/types/Mutation/signUp.ts b/src/graphql/types/Mutation/signUp.ts index 56ba0045fd8..e89d08202bf 100755 --- a/src/graphql/types/Mutation/signUp.ts +++ b/src/graphql/types/Mutation/signUp.ts @@ -36,13 +36,12 @@ const mutationSignUpArgumentsSchema = z.object({ message: `Mime type "${rawAvatar.mimetype}" is not allowed.`, }); } else { - return { - ...arg, - avatar: Object.assign(rawAvatar, { - mimetype: data, - }), - }; + avatar = Object.assign(rawAvatar, { + mimetype: data, + }); } + } else if (arg.avatar !== undefined) { + avatar = null; } return { @@ -56,7 +55,7 @@ builder.mutationField("signUp", (t) => t.field({ args: { input: t.arg({ - description: "Input required to sign up to talawa.", + description: "", required: true, type: MutationSignUpInput, }), @@ -173,8 +172,7 @@ builder.mutationField("signUp", (t) => ); } - // The following code is necessary for continuing the expected graph traversal for an authenticated client because of absence of an authentication context for clients that triggered this operation. This should be removed when authentication flows are seperated from the graphql implementation. - + // TODO: The following code is necessary for continuing the expected graph traversal for unauthenticated clients that triggered this operation because of absence of an authentication context for those clients. This should be removed when authentication flows are seperated from the graphql implementation. ctx.currentClient.isAuthenticated = true; ctx.currentClient.user = { id: createdUser.id, diff --git a/src/graphql/types/Mutation/updateAdvertisement.ts b/src/graphql/types/Mutation/updateAdvertisement.ts index fe77c7fbbde..ad9a0fddafc 100644 --- a/src/graphql/types/Mutation/updateAdvertisement.ts +++ b/src/graphql/types/Mutation/updateAdvertisement.ts @@ -66,13 +66,13 @@ builder.mutationField("updateAdvertisement", (t) => startAt: true, }, with: { - advertisementAttachmentsWhereAdvertisement: true, + attachmentsWhereAdvertisement: true, organization: { columns: { countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -178,8 +178,7 @@ builder.mutationField("updateAdvertisement", (t) => } const currentUserOrganizationMembership = - existingAdvertisement.organization - .organizationMembershipsWhereOrganization[0]; + existingAdvertisement.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && @@ -221,8 +220,7 @@ builder.mutationField("updateAdvertisement", (t) => } return Object.assign(updatedAdvertisement, { - attachments: - existingAdvertisement.advertisementAttachmentsWhereAdvertisement, + attachments: existingAdvertisement.attachmentsWhereAdvertisement, }); }, type: Advertisement, diff --git a/src/graphql/types/Mutation/updateAgendaFolder.ts b/src/graphql/types/Mutation/updateAgendaFolder.ts index fa551d12f0d..724fd36c267 100644 --- a/src/graphql/types/Mutation/updateAgendaFolder.ts +++ b/src/graphql/types/Mutation/updateAgendaFolder.ts @@ -75,7 +75,7 @@ builder.mutationField("updateAgendaFolder", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -128,7 +128,7 @@ builder.mutationField("updateAgendaFolder", (t) => code: "arguments_associated_resources_not_found", issues: [ { - argumentPath: ["input", "folderId"], + argumentPath: ["input", "parentFolderId"], }, ], }, @@ -141,9 +141,9 @@ builder.mutationField("updateAgendaFolder", (t) => code: "forbidden_action_on_arguments_associated_resources", issues: [ { - argumentPath: ["input", "folderId"], + argumentPath: ["input", "parentFolderId"], message: - "This parent agenda folder is not associated to the event associated to the agenda folder.", + "This agenda folder does not belong to the event associated to the agenda folder being updated.", }, ], }, @@ -156,9 +156,9 @@ builder.mutationField("updateAgendaFolder", (t) => code: "forbidden_action_on_arguments_associated_resources", issues: [ { - argumentPath: ["input", "folderId"], + argumentPath: ["input", "parentFolderId"], message: - "This agenda folder cannot be a parent to agenda folders.", + "This agenda folder cannot be a parent folder for other agenda folders.", }, ], }, @@ -167,8 +167,7 @@ builder.mutationField("updateAgendaFolder", (t) => } const currentUserOrganizationMembership = - existingAgendaFolder.event.organization - .organizationMembershipsWhereOrganization[0]; + existingAgendaFolder.event.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/updateAgendaItem.ts b/src/graphql/types/Mutation/updateAgendaItem.ts index 97471a0288d..28978e5bad8 100644 --- a/src/graphql/types/Mutation/updateAgendaItem.ts +++ b/src/graphql/types/Mutation/updateAgendaItem.ts @@ -80,7 +80,7 @@ builder.mutationField("updateAgendaItem", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -224,7 +224,7 @@ builder.mutationField("updateAgendaItem", (t) => { argumentPath: ["input", "folderId"], message: - "This agenda folder is not associated to the event associated to the agenda item.", + "This agenda folder does not belong to the event to the agenda item.", }, ], }, @@ -249,7 +249,7 @@ builder.mutationField("updateAgendaItem", (t) => const currentUserOrganizationMembership = existingAgendaItem.folder.event.organization - .organizationMembershipsWhereOrganization[0]; + .membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/updateChat.ts b/src/graphql/types/Mutation/updateChat.ts index b2d980d67b9..ff754017ef0 100644 --- a/src/graphql/types/Mutation/updateChat.ts +++ b/src/graphql/types/Mutation/updateChat.ts @@ -24,9 +24,9 @@ const mutationUpdateChatArgumentsSchema = z.object({ if (isNotNullish(arg.avatar)) { const rawAvatar = await arg.avatar; - const result = imageMimeTypeEnum.safeParse(rawAvatar.mimetype); + const { data, success } = imageMimeTypeEnum.safeParse(rawAvatar.mimetype); - if (!result.success) { + if (!success) { ctx.addIssue({ code: "custom", path: ["avatar"], @@ -34,19 +34,16 @@ const mutationUpdateChatArgumentsSchema = z.object({ }); } else { avatar = Object.assign(rawAvatar, { - mimetype: result.data, + mimetype: data, }); } - - return { - ...arg, - avatar, - }; + } else if (arg.avatar !== undefined) { + avatar = null; } return { ...arg, - avatar: arg.avatar, + avatar, }; }), }); @@ -114,7 +111,7 @@ builder.mutationField("updateChat", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -151,7 +148,7 @@ builder.mutationField("updateChat", (t) => } const currentUserOrganizationMembership = - existingChat.organization.organizationMembershipsWhereOrganization[0]; + existingChat.organization.membershipsWhereOrganization[0]; const currentUserChatMembership = existingChat.chatMembershipsWhereChat[0]; diff --git a/src/graphql/types/Mutation/updateChatMembership.ts b/src/graphql/types/Mutation/updateChatMembership.ts index 4837b4f42d3..3e3aa04be5f 100644 --- a/src/graphql/types/Mutation/updateChatMembership.ts +++ b/src/graphql/types/Mutation/updateChatMembership.ts @@ -77,7 +77,7 @@ builder.mutationField("updateChatMembership", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -175,7 +175,7 @@ builder.mutationField("updateChatMembership", (t) => } const currentUserOrganizationMembership = - existingChat.organization.organizationMembershipsWhereOrganization[0]; + existingChat.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/updateChatMessage.ts b/src/graphql/types/Mutation/updateChatMessage.ts index 48f8eb08c1e..3876299226b 100644 --- a/src/graphql/types/Mutation/updateChatMessage.ts +++ b/src/graphql/types/Mutation/updateChatMessage.ts @@ -81,7 +81,7 @@ builder.mutationField("updateChatMessage", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -120,8 +120,7 @@ builder.mutationField("updateChatMessage", (t) => } const currentUserOrganizationMembership = - existingChatMessage.chat.organization - .organizationMembershipsWhereOrganization[0]; + existingChatMessage.chat.organization.membershipsWhereOrganization[0]; const currentUserChatMembership = existingChatMessage.chat.chatMembershipsWhereChat[0]; diff --git a/src/graphql/types/Mutation/updateComment.ts b/src/graphql/types/Mutation/updateComment.ts index 613c540fe31..08148bcc7e8 100644 --- a/src/graphql/types/Mutation/updateComment.ts +++ b/src/graphql/types/Mutation/updateComment.ts @@ -74,7 +74,7 @@ builder.mutationField("updateComment", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -113,8 +113,7 @@ builder.mutationField("updateComment", (t) => } const currentUserOrganizationMembership = - existingComment.post.organization - .organizationMembershipsWhereOrganization[0]; + existingComment.post.organization.membershipsWhereOrganization[0]; if ( (currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/updateCommentVote.ts b/src/graphql/types/Mutation/updateCommentVote.ts index 3253d83eb73..11a0563b6f8 100644 --- a/src/graphql/types/Mutation/updateCommentVote.ts +++ b/src/graphql/types/Mutation/updateCommentVote.ts @@ -52,53 +52,48 @@ builder.mutationField("updateCommentVote", (t) => const currentUserId = ctx.currentClient.user.id; - const [currentUser, existingComment, existingCommentVote] = - await Promise.all([ - ctx.drizzleClient.query.usersTable.findFirst({ - columns: { - role: true, - }, - where: (fields, operators) => - operators.eq(fields.id, currentUserId), - }), - ctx.drizzleClient.query.commentsTable.findFirst({ - with: { - post: { - columns: { - pinnedAt: true, - }, - with: { - organization: { - columns: { - countryCode: true, - }, - with: { - organizationMembershipsWhereOrganization: { - columns: { - role: true, - }, - where: (fields, operators) => - operators.eq(fields.memberId, currentUserId), + const [currentUser, existingComment] = await Promise.all([ + ctx.drizzleClient.query.usersTable.findFirst({ + columns: { + role: true, + }, + where: (fields, operators) => operators.eq(fields.id, currentUserId), + }), + ctx.drizzleClient.query.commentsTable.findFirst({ + with: { + post: { + columns: { + pinnedAt: true, + }, + with: { + organization: { + columns: { + countryCode: true, + }, + with: { + membershipsWhereOrganization: { + columns: { + role: true, }, + where: (fields, operators) => + operators.eq(fields.memberId, currentUserId), }, }, }, }, }, - where: (fields, operators) => - operators.eq(fields.id, parsedArgs.input.commentId), - }), - ctx.drizzleClient.query.commentVotesTable.findFirst({ - columns: { - type: true, - }, - where: (fields, operators) => - operators.and( - operators.eq(fields.commentId, parsedArgs.input.commentId), + votesWhereComment: { + columns: { + type: true, + }, + where: (fields, operators) => operators.eq(fields.creatorId, currentUserId), - ), - }), - ]); + }, + }, + where: (fields, operators) => + operators.eq(fields.id, parsedArgs.input.commentId), + }), + ]); if (currentUser === undefined) { throw new TalawaGraphQLError({ @@ -108,7 +103,22 @@ builder.mutationField("updateCommentVote", (t) => }); } - if (existingComment === undefined || existingCommentVote === undefined) { + if (existingComment === undefined) { + throw new TalawaGraphQLError({ + extensions: { + code: "arguments_associated_resources_not_found", + issues: [ + { + argumentPath: ["input", "commentId"], + }, + ], + }, + }); + } + + const existingCommentVote = existingComment.votesWhereComment[0]; + + if (existingCommentVote === undefined) { throw new TalawaGraphQLError({ extensions: { code: "arguments_associated_resources_not_found", @@ -122,8 +132,7 @@ builder.mutationField("updateCommentVote", (t) => } const currentUserOrganizationMembership = - existingComment.post.organization - .organizationMembershipsWhereOrganization[0]; + existingComment.post.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && @@ -145,7 +154,6 @@ builder.mutationField("updateCommentVote", (t) => .update(commentVotesTable) .set({ type: parsedArgs.input.type, - updaterId: currentUserId, }) .where( and( diff --git a/src/graphql/types/Mutation/updateCurrentUser.ts b/src/graphql/types/Mutation/updateCurrentUser.ts index 262a9b00ddc..1908ea76ba8 100755 --- a/src/graphql/types/Mutation/updateCurrentUser.ts +++ b/src/graphql/types/Mutation/updateCurrentUser.ts @@ -34,13 +34,12 @@ const mutationUpdateCurrentUserArgumentsSchema = z.object({ message: `Mime type "${rawAvatar.mimetype}" is not allowed.`, }); } else { - return { - ...arg, - avatar: Object.assign(rawAvatar, { - mimetype: data, - }), - }; + avatar = Object.assign(rawAvatar, { + mimetype: data, + }); } + } else if (arg.avatar !== undefined) { + avatar = null; } return { @@ -54,7 +53,7 @@ builder.mutationField("updateCurrentUser", (t) => t.field({ args: { input: t.arg({ - description: "Input required to update the current user.", + description: "", required: true, type: MutationUpdateCurrentUserInput, }), @@ -123,7 +122,7 @@ builder.mutationField("updateCurrentUser", (t) => issues: [ { argumentPath: ["input", "emailAddress"], - message: "This email address is already registered.", + message: "This email address is not available.", }, ], }, diff --git a/src/graphql/types/Mutation/updateEvent.ts b/src/graphql/types/Mutation/updateEvent.ts index 6db5cbb12cd..9b89e21c00d 100644 --- a/src/graphql/types/Mutation/updateEvent.ts +++ b/src/graphql/types/Mutation/updateEvent.ts @@ -67,13 +67,13 @@ builder.mutationField("updateEvent", (t) => startAt: true, }, with: { - eventAttachmentsWhereEvent: true, + attachmentsWhereEvent: true, organization: { columns: { countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -146,7 +146,7 @@ builder.mutationField("updateEvent", (t) => } const currentUserOrganizationMembership = - existingEvent.organization.organizationMembershipsWhereOrganization[0]; + existingEvent.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && @@ -187,7 +187,7 @@ builder.mutationField("updateEvent", (t) => } return Object.assign(updatedEvent, { - attachments: existingEvent.eventAttachmentsWhereEvent, + attachments: existingEvent.attachmentsWhereEvent, }); }, type: Event, diff --git a/src/graphql/types/Mutation/updateFund.ts b/src/graphql/types/Mutation/updateFund.ts index 8a09a9b6c52..de441391635 100644 --- a/src/graphql/types/Mutation/updateFund.ts +++ b/src/graphql/types/Mutation/updateFund.ts @@ -69,7 +69,7 @@ builder.mutationField("updateFund", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -139,7 +139,7 @@ builder.mutationField("updateFund", (t) => } const currentUserOrganizationMembership = - existingFund.organization.organizationMembershipsWhereOrganization[0]; + existingFund.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/updateFundCampaign.ts b/src/graphql/types/Mutation/updateFundCampaign.ts index d70a33fe5e0..5dfb2bf2686 100644 --- a/src/graphql/types/Mutation/updateFundCampaign.ts +++ b/src/graphql/types/Mutation/updateFundCampaign.ts @@ -76,7 +76,7 @@ builder.mutationField("updateFundCampaign", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -181,8 +181,7 @@ builder.mutationField("updateFundCampaign", (t) => } const currentUserOrganizationMembership = - existingFundCampaign.fund.organization - .organizationMembershipsWhereOrganization[0]; + existingFundCampaign.fund.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/updateFundCampaignPledge.ts b/src/graphql/types/Mutation/updateFundCampaignPledge.ts index 7b18d0eb925..805f9a323f2 100644 --- a/src/graphql/types/Mutation/updateFundCampaignPledge.ts +++ b/src/graphql/types/Mutation/updateFundCampaignPledge.ts @@ -79,7 +79,7 @@ builder.mutationField("updateFundCampaignPledge", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -121,7 +121,7 @@ builder.mutationField("updateFundCampaignPledge", (t) => const currentUserOrganizationMembership = existingFundCampaignPledge.campaign.fund.organization - .organizationMembershipsWhereOrganization[0]; + .membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/updateOrganization.ts b/src/graphql/types/Mutation/updateOrganization.ts index ee5b1bb7a3d..01bcef95c96 100644 --- a/src/graphql/types/Mutation/updateOrganization.ts +++ b/src/graphql/types/Mutation/updateOrganization.ts @@ -24,9 +24,9 @@ const mutationUpdateOrganizationArgumentsSchema = z.object({ if (isNotNullish(arg.avatar)) { const rawAvatar = await arg.avatar; - const result = imageMimeTypeEnum.safeParse(rawAvatar.mimetype); + const { data, success } = imageMimeTypeEnum.safeParse(rawAvatar.mimetype); - if (!result.success) { + if (!success) { ctx.addIssue({ code: "custom", path: ["avatar"], @@ -34,19 +34,16 @@ const mutationUpdateOrganizationArgumentsSchema = z.object({ }); } else { avatar = Object.assign(rawAvatar, { - mimetype: result.data, + mimetype: data, }); } - - return { - ...arg, - avatar, - }; + } else if (arg.avatar !== undefined) { + avatar = null; } return { ...arg, - avatar: arg.avatar, + avatar, }; }), }); diff --git a/src/graphql/types/Mutation/updateOrganizationMembership.ts b/src/graphql/types/Mutation/updateOrganizationMembership.ts index 5e18d8d952e..259fecd1594 100644 --- a/src/graphql/types/Mutation/updateOrganizationMembership.ts +++ b/src/graphql/types/Mutation/updateOrganizationMembership.ts @@ -52,53 +52,36 @@ builder.mutationField("updateOrganizationMembership", (t) => const currentUserId = ctx.currentClient.user.id; - const [ - currentUser, - existingMember, - existingOrganization, - existingOrganizationMembership, - ] = await Promise.all([ - ctx.drizzleClient.query.usersTable.findFirst({ - columns: { - role: true, - }, - where: (fields, operators) => operators.eq(fields.id, currentUserId), - }), - ctx.drizzleClient.query.usersTable.findFirst({ - columns: { - role: true, - }, - where: (fields, operators) => - operators.eq(fields.id, parsedArgs.input.memberId), - }), - ctx.drizzleClient.query.organizationsTable.findFirst({ - with: { - organizationMembershipsWhereOrganization: { - columns: { - role: true, + const [currentUser, existingMember, existingOrganization] = + await Promise.all([ + ctx.drizzleClient.query.usersTable.findFirst({ + columns: { + role: true, + }, + where: (fields, operators) => + operators.eq(fields.id, currentUserId), + }), + ctx.drizzleClient.query.usersTable.findFirst({ + columns: { + role: true, + }, + where: (fields, operators) => + operators.eq(fields.id, parsedArgs.input.memberId), + }), + ctx.drizzleClient.query.organizationsTable.findFirst({ + where: (fields, operators) => + operators.eq(fields.id, parsedArgs.input.organizationId), + with: { + membershipsWhereOrganization: { + columns: { + role: true, + }, + where: (fields, operators) => + operators.eq(fields.memberId, currentUserId), }, - where: (fields, operators) => - operators.eq(fields.memberId, currentUserId), }, - }, - where: (fields, operators) => - operators.eq(fields.id, parsedArgs.input.organizationId), - }), - ctx.drizzleClient.query.organizationMembershipsTable.findFirst({ - columns: { - role: true, - }, - - where: (fields, operators) => - operators.and( - operators.eq(fields.memberId, parsedArgs.input.memberId), - operators.eq( - fields.organizationId, - parsedArgs.input.organizationId, - ), - ), - }), - ]); + }), + ]); if (currentUser === undefined) { throw new TalawaGraphQLError({ @@ -150,6 +133,9 @@ builder.mutationField("updateOrganizationMembership", (t) => }); } + const existingOrganizationMembership = + existingOrganization.membershipsWhereOrganization[0]; + if (existingOrganizationMembership === undefined) { throw new TalawaGraphQLError({ extensions: { @@ -166,28 +152,27 @@ builder.mutationField("updateOrganizationMembership", (t) => }); } - if (currentUser.role !== "administrator") { - const currentUserOrganizationMembership = - existingOrganization.organizationMembershipsWhereOrganization[0]; - - if ( - currentUserOrganizationMembership === undefined || - currentUserOrganizationMembership.role !== "administrator" - ) { - throw new TalawaGraphQLError({ - extensions: { - code: "unauthorized_action_on_arguments_associated_resources", - issues: [ - { - argumentPath: ["input", "memberId"], - }, - { - argumentPath: ["input", "organizationId"], - }, - ], - }, - }); - } + const currentUserOrganizationMembership = + existingOrganization.membershipsWhereOrganization[0]; + + if ( + currentUser.role !== "administrator" && + (currentUserOrganizationMembership === undefined || + currentUserOrganizationMembership.role !== "administrator") + ) { + throw new TalawaGraphQLError({ + extensions: { + code: "unauthorized_action_on_arguments_associated_resources", + issues: [ + { + argumentPath: ["input", "memberId"], + }, + { + argumentPath: ["input", "organizationId"], + }, + ], + }, + }); } const [updatedOrganizationMembership] = await ctx.drizzleClient diff --git a/src/graphql/types/Mutation/updatePost.ts b/src/graphql/types/Mutation/updatePost.ts index c4d59f20775..33f0fadefba 100644 --- a/src/graphql/types/Mutation/updatePost.ts +++ b/src/graphql/types/Mutation/updatePost.ts @@ -66,13 +66,13 @@ builder.mutationField("updatePost", (t) => creatorId: true, }, with: { - postAttachmentsWherePost: true, + attachmentsWherePost: true, organization: { columns: { countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -128,7 +128,7 @@ builder.mutationField("updatePost", (t) => } } else { const currentUserOrganizationMembership = - existingPost.organization.organizationMembershipsWhereOrganization[0]; + existingPost.organization.membershipsWhereOrganization[0]; if (currentUserOrganizationMembership === undefined) { throw new TalawaGraphQLError({ @@ -222,7 +222,7 @@ builder.mutationField("updatePost", (t) => } return Object.assign(updatedPost, { - attachments: existingPost.postAttachmentsWherePost, + attachments: existingPost.attachmentsWherePost, }); }, type: Post, diff --git a/src/graphql/types/Mutation/updatePostVote.ts b/src/graphql/types/Mutation/updatePostVote.ts index e1c56231036..9a43646a776 100644 --- a/src/graphql/types/Mutation/updatePostVote.ts +++ b/src/graphql/types/Mutation/updatePostVote.ts @@ -52,7 +52,7 @@ builder.mutationField("updatePostVote", (t) => const currentUserId = ctx.currentClient.user.id; - const [currentUser, existingPost, existingPostVote] = await Promise.all([ + const [currentUser, existingPost] = await Promise.all([ ctx.drizzleClient.query.usersTable.findFirst({ columns: { role: true, @@ -61,12 +61,13 @@ builder.mutationField("updatePostVote", (t) => }), ctx.drizzleClient.query.postsTable.findFirst({ with: { + attachmentsWherePost: true, organization: { columns: { countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -75,21 +76,17 @@ builder.mutationField("updatePostVote", (t) => }, }, }, - postAttachmentsWherePost: true, + votesWherePost: { + columns: { + type: true, + }, + where: (fields, operators) => + operators.eq(fields.creatorId, currentUserId), + }, }, where: (fields, operators) => operators.eq(fields.id, parsedArgs.input.postId), }), - ctx.drizzleClient.query.postVotesTable.findFirst({ - columns: { - type: true, - }, - where: (fields, operators) => - operators.and( - operators.eq(fields.creatorId, currentUserId), - operators.eq(fields.postId, parsedArgs.input.postId), - ), - }), ]); if (currentUser === undefined) { @@ -100,7 +97,7 @@ builder.mutationField("updatePostVote", (t) => }); } - if (existingPost === undefined || existingPostVote === undefined) { + if (existingPost === undefined) { throw new TalawaGraphQLError({ extensions: { code: "arguments_associated_resources_not_found", @@ -112,8 +109,25 @@ builder.mutationField("updatePostVote", (t) => }, }); } + + const existingPostVote = existingPost.votesWherePost[0]; + + if (existingPostVote !== undefined) { + throw new TalawaGraphQLError({ + extensions: { + code: "forbidden_action_on_arguments_associated_resources", + issues: [ + { + argumentPath: ["input", "postId"], + message: "You have already voted this post.", + }, + ], + }, + }); + } + const currentUserOrganizationMembership = - existingPost.organization.organizationMembershipsWhereOrganization[0]; + existingPost.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && @@ -135,7 +149,6 @@ builder.mutationField("updatePostVote", (t) => .update(postVotesTable) .set({ type: parsedArgs.input.type, - updaterId: currentUserId, }) .where( and( @@ -155,7 +168,7 @@ builder.mutationField("updatePostVote", (t) => } return Object.assign(existingPost, { - attachments: existingPost.postAttachmentsWherePost, + attachments: existingPost.attachmentsWherePost, }); }, type: Post, diff --git a/src/graphql/types/Mutation/updateTag.ts b/src/graphql/types/Mutation/updateTag.ts index 5e713a74897..27d80cb529d 100644 --- a/src/graphql/types/Mutation/updateTag.ts +++ b/src/graphql/types/Mutation/updateTag.ts @@ -70,7 +70,7 @@ builder.mutationField("updateTag", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -177,7 +177,7 @@ builder.mutationField("updateTag", (t) => } const currentUserOrganizationMembership = - existingTag.organization.organizationMembershipsWhereOrganization[0]; + existingTag.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/updateTagFolder.ts b/src/graphql/types/Mutation/updateTagFolder.ts index 2b59d136abd..376d9b1d7a3 100644 --- a/src/graphql/types/Mutation/updateTagFolder.ts +++ b/src/graphql/types/Mutation/updateTagFolder.ts @@ -70,7 +70,7 @@ builder.mutationField("updateTagFolder", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -151,8 +151,7 @@ builder.mutationField("updateTagFolder", (t) => } const currentUserOrganizationMembership = - existingTagFolder.organization - .organizationMembershipsWhereOrganization[0]; + existingTagFolder.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Mutation/updateUser.ts b/src/graphql/types/Mutation/updateUser.ts index e3d88c0c006..21d9f40c7e4 100755 --- a/src/graphql/types/Mutation/updateUser.ts +++ b/src/graphql/types/Mutation/updateUser.ts @@ -34,13 +34,12 @@ const mutationUpdateUserArgumentsSchema = z.object({ message: `Mime type "${rawAvatar.mimetype}" is not allowed.`, }); } else { - return { - ...arg, - avatar: Object.assign(rawAvatar, { - mimetype: data, - }), - }; + avatar = Object.assign(rawAvatar, { + mimetype: data, + }); } + } else if (arg.avatar !== undefined) { + avatar = null; } return { @@ -54,7 +53,7 @@ builder.mutationField("updateUser", (t) => t.field({ args: { input: t.arg({ - description: "Input required to update a user.", + description: "", required: true, type: MutationUpdateUserInput, }), @@ -97,7 +96,10 @@ builder.mutationField("updateUser", (t) => where: (fields, operators) => operators.eq(fields.id, currentUserId), }), ctx.drizzleClient.query.usersTable.findFirst({ - columns: { avatarName: true, role: true }, + columns: { + avatarName: true, + role: true, + }, where: (fields, operators) => operators.eq(fields.id, parsedArgs.input.id), }), @@ -157,7 +159,7 @@ builder.mutationField("updateUser", (t) => } return await ctx.drizzleClient.transaction(async (tx) => { - const [updatedUser] = await ctx.drizzleClient + const [updatedUser] = await tx .update(usersTable) .set({ addressLine1: parsedArgs.input.addressLine1, diff --git a/src/graphql/types/Mutation/updateVenue.ts b/src/graphql/types/Mutation/updateVenue.ts index 1e2a8bc8f27..9360c82ecde 100644 --- a/src/graphql/types/Mutation/updateVenue.ts +++ b/src/graphql/types/Mutation/updateVenue.ts @@ -70,7 +70,7 @@ builder.mutationField("updateVenue", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -79,7 +79,7 @@ builder.mutationField("updateVenue", (t) => }, }, }, - venueAttachmentsWhereVenue: true, + attachmentsWhereVenue: true, }, where: (fields, operators) => operators.eq(fields.id, parsedArgs.input.id), @@ -113,7 +113,7 @@ builder.mutationField("updateVenue", (t) => const existingVenueWithName = await ctx.drizzleClient.query.venuesTable.findFirst({ columns: { - organizationId: true, + updatedAt: true, }, where: (fields, operators) => operators.and( @@ -141,7 +141,7 @@ builder.mutationField("updateVenue", (t) => } const currentUserOrganizationMembership = - existingVenue.organization.organizationMembershipsWhereOrganization[0]; + existingVenue.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && @@ -180,7 +180,7 @@ builder.mutationField("updateVenue", (t) => } return Object.assign(updatedVenue, { - attachments: existingVenue.venueAttachmentsWhereVenue, + attachments: existingVenue.attachmentsWhereVenue, }); }, type: Venue, diff --git a/src/graphql/types/Organization/advertisements.ts b/src/graphql/types/Organization/advertisements.ts index 42ad775f629..c06b0d24225 100644 --- a/src/graphql/types/Organization/advertisements.ts +++ b/src/graphql/types/Organization/advertisements.ts @@ -173,7 +173,7 @@ Organization.implement({ limit, orderBy, with: { - advertisementAttachmentsWhereAdvertisement: true, + attachmentsWhereAdvertisement: true, }, where, }); @@ -198,12 +198,9 @@ Organization.implement({ name: advertisement.name, }), ).toString("base64url"), - createNode: ({ - advertisementAttachmentsWhereAdvertisement, - ...advertisement - }) => + createNode: ({ attachmentsWhereAdvertisement, ...advertisement }) => Object.assign(advertisement, { - attachments: advertisementAttachmentsWhereAdvertisement, + attachments: attachmentsWhereAdvertisement, }), parsedArgs, rawNodes: advertisements, diff --git a/src/graphql/types/Organization/events.ts b/src/graphql/types/Organization/events.ts index 682fed16647..c8fe6d7c486 100644 --- a/src/graphql/types/Organization/events.ts +++ b/src/graphql/types/Organization/events.ts @@ -192,7 +192,7 @@ Organization.implement({ limit, orderBy, with: { - eventAttachmentsWhereEvent: true, + attachmentsWhereEvent: true, }, where, }); @@ -218,9 +218,9 @@ Organization.implement({ startAt: event.startAt.toISOString(), }), ).toString("base64url"), - createNode: ({ eventAttachmentsWhereEvent, ...event }) => + createNode: ({ attachmentsWhereEvent, ...event }) => Object.assign(event, { - attachments: eventAttachmentsWhereEvent, + attachments: attachmentsWhereEvent, }), parsedArgs, rawNodes: events, diff --git a/src/graphql/types/Organization/pinnedPosts.ts b/src/graphql/types/Organization/pinnedPosts.ts index 197442f3b8d..7eca4ff7740 100644 --- a/src/graphql/types/Organization/pinnedPosts.ts +++ b/src/graphql/types/Organization/pinnedPosts.ts @@ -209,7 +209,7 @@ Organization.implement({ limit, orderBy, with: { - postAttachmentsWherePost: true, + attachmentsWherePost: true, }, where, }, @@ -237,9 +237,9 @@ Organization.implement({ pinnedAt: post.pinnedAt?.toISOString(), }), ).toString("base64url"), - createNode: ({ postAttachmentsWherePost, ...post }) => + createNode: ({ attachmentsWherePost, ...post }) => Object.assign(post, { - attachments: postAttachmentsWherePost, + attachments: attachmentsWherePost, }), parsedArgs, rawNodes: pinnedPosts, diff --git a/src/graphql/types/Organization/posts.ts b/src/graphql/types/Organization/posts.ts index 294d070065e..4015111ed5d 100644 --- a/src/graphql/types/Organization/posts.ts +++ b/src/graphql/types/Organization/posts.ts @@ -169,7 +169,7 @@ Organization.implement({ limit, orderBy, with: { - postAttachmentsWherePost: true, + attachmentsWherePost: true, }, where, }); @@ -194,9 +194,9 @@ Organization.implement({ id: post.id, }), ).toString("base64url"), - createNode: ({ postAttachmentsWherePost, ...post }) => + createNode: ({ attachmentsWherePost, ...post }) => Object.assign(post, { - attachments: postAttachmentsWherePost, + attachments: attachmentsWherePost, }), parsedArgs, rawNodes: posts, diff --git a/src/graphql/types/Organization/venues.ts b/src/graphql/types/Organization/venues.ts index 095cfe46567..5e6e2afcec5 100644 --- a/src/graphql/types/Organization/venues.ts +++ b/src/graphql/types/Organization/venues.ts @@ -173,7 +173,7 @@ Organization.implement({ limit, orderBy, with: { - venueAttachmentsWhereVenue: true, + attachmentsWhereVenue: true, }, where, }); @@ -198,9 +198,9 @@ Organization.implement({ name: venue.name, }), ).toString("base64url"), - createNode: ({ venueAttachmentsWhereVenue, ...venue }) => + createNode: ({ attachmentsWhereVenue, ...venue }) => Object.assign(venue, { - attachments: venueAttachmentsWhereVenue, + attachments: attachmentsWhereVenue, }), parsedArgs, rawNodes: venues, diff --git a/src/graphql/types/Query/advertisement.ts b/src/graphql/types/Query/advertisement.ts index 20dee3abebf..7d13f3a4a80 100644 --- a/src/graphql/types/Query/advertisement.ts +++ b/src/graphql/types/Query/advertisement.ts @@ -59,13 +59,13 @@ builder.queryField("advertisement", (t) => }), ctx.drizzleClient.query.advertisementsTable.findFirst({ with: { - advertisementAttachmentsWhereAdvertisement: true, + attachmentsWhereAdvertisement: true, organization: { columns: { countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -102,8 +102,7 @@ builder.queryField("advertisement", (t) => } const currentUserOrganizationMembership = - existingAdvertisement.organization - .organizationMembershipsWhereOrganization[0]; + existingAdvertisement.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && @@ -122,8 +121,7 @@ builder.queryField("advertisement", (t) => } return Object.assign(existingAdvertisement, { - attachments: - existingAdvertisement.advertisementAttachmentsWhereAdvertisement, + attachments: existingAdvertisement.attachmentsWhereAdvertisement, }); }, type: Advertisement, diff --git a/src/graphql/types/Query/agendaFolder.ts b/src/graphql/types/Query/agendaFolder.ts index 7b34ccbec29..7149591e72b 100644 --- a/src/graphql/types/Query/agendaFolder.ts +++ b/src/graphql/types/Query/agendaFolder.ts @@ -69,7 +69,7 @@ builder.queryField("agendaFolder", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -108,8 +108,7 @@ builder.queryField("agendaFolder", (t) => } const currentUserOrganizationMembership = - existingAgendaFolder.event.organization - .organizationMembershipsWhereOrganization[0]; + existingAgendaFolder.event.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Query/agendaItem.ts b/src/graphql/types/Query/agendaItem.ts index bb58be7ccf8..4fd4c51b2cc 100644 --- a/src/graphql/types/Query/agendaItem.ts +++ b/src/graphql/types/Query/agendaItem.ts @@ -74,7 +74,7 @@ builder.queryField("agendaItem", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -116,7 +116,7 @@ builder.queryField("agendaItem", (t) => const currentUserOrganizationMembership = existingAgendaItem.folder.event.organization - .organizationMembershipsWhereOrganization[0]; + .membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Query/chat.ts b/src/graphql/types/Query/chat.ts index 9d820ceecab..c35392f6e14 100644 --- a/src/graphql/types/Query/chat.ts +++ b/src/graphql/types/Query/chat.ts @@ -64,7 +64,7 @@ builder.queryField("chat", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -101,7 +101,7 @@ builder.queryField("chat", (t) => } const currentUserOrganizationMembership = - existingChat.organization.organizationMembershipsWhereOrganization[0]; + existingChat.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Query/chatMessage.ts b/src/graphql/types/Query/chatMessage.ts index 0f00e078641..20b2323bc39 100644 --- a/src/graphql/types/Query/chatMessage.ts +++ b/src/graphql/types/Query/chatMessage.ts @@ -76,7 +76,7 @@ builder.queryField("chatMessage", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -115,8 +115,7 @@ builder.queryField("chatMessage", (t) => } const currentUserOrganizationMembership = - existingChatMessage.chat.organization - .organizationMembershipsWhereOrganization[0]; + existingChatMessage.chat.organization.membershipsWhereOrganization[0]; const currentUserChatMembership = existingChatMessage.chat.chatMembershipsWhereChat[0]; diff --git a/src/graphql/types/Query/comment.ts b/src/graphql/types/Query/comment.ts index 0b03a921fa5..45717e16136 100644 --- a/src/graphql/types/Query/comment.ts +++ b/src/graphql/types/Query/comment.ts @@ -69,7 +69,7 @@ builder.queryField("comment", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -108,8 +108,7 @@ builder.queryField("comment", (t) => } const currentUserOrganizationMembership = - existingComment.post.organization - .organizationMembershipsWhereOrganization[0]; + existingComment.post.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Query/event.ts b/src/graphql/types/Query/event.ts index 924276cf94d..a9a0ab3cc80 100644 --- a/src/graphql/types/Query/event.ts +++ b/src/graphql/types/Query/event.ts @@ -59,13 +59,13 @@ builder.queryField("event", (t) => }), ctx.drizzleClient.query.eventsTable.findFirst({ with: { - eventAttachmentsWhereEvent: true, + attachmentsWhereEvent: true, organization: { columns: { countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -102,7 +102,7 @@ builder.queryField("event", (t) => } const currentUserOrganizationMembership = - existingEvent.organization.organizationMembershipsWhereOrganization[0]; + existingEvent.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && @@ -121,7 +121,7 @@ builder.queryField("event", (t) => } return Object.assign(existingEvent, { - attachments: existingEvent.eventAttachmentsWhereEvent, + attachments: existingEvent.attachmentsWhereEvent, }); }, type: Event, diff --git a/src/graphql/types/Query/fund.ts b/src/graphql/types/Query/fund.ts index c44766a31f8..7e925e7c4bd 100644 --- a/src/graphql/types/Query/fund.ts +++ b/src/graphql/types/Query/fund.ts @@ -72,7 +72,7 @@ builder.queryField("fund", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -100,7 +100,7 @@ builder.queryField("fund", (t) => } const currentUserOrganizationMembership = - existingFund.organization.organizationMembershipsWhereOrganization[0]; + existingFund.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Query/fundCampaign.ts b/src/graphql/types/Query/fundCampaign.ts index d316c88ee5e..27272d4cf9f 100644 --- a/src/graphql/types/Query/fundCampaign.ts +++ b/src/graphql/types/Query/fundCampaign.ts @@ -75,7 +75,7 @@ builder.queryField("fundCampaign", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -105,8 +105,7 @@ builder.queryField("fundCampaign", (t) => } const currentUserOrganizationMembership = - existingFundCampaign.fund.organization - .organizationMembershipsWhereOrganization[0]; + existingFundCampaign.fund.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Query/fundCampaignPledge.ts b/src/graphql/types/Query/fundCampaignPledge.ts index ea631db46e4..3858730de22 100644 --- a/src/graphql/types/Query/fundCampaignPledge.ts +++ b/src/graphql/types/Query/fundCampaignPledge.ts @@ -80,7 +80,7 @@ builder.queryField("fundCampaignPledge", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -113,7 +113,7 @@ builder.queryField("fundCampaignPledge", (t) => const currentUserOrganizationMembership = existingFundCampaignPledge.campaign.fund.organization - .organizationMembershipsWhereOrganization[0]; + .membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Query/organization.ts b/src/graphql/types/Query/organization.ts index 5cb6930c299..ff39ab8f96a 100644 --- a/src/graphql/types/Query/organization.ts +++ b/src/graphql/types/Query/organization.ts @@ -15,7 +15,7 @@ builder.queryField("organization", (t) => t.field({ args: { input: t.arg({ - description: "Input required to read an organization.", + description: "", required: true, type: QueryOrganizationInput, }), diff --git a/src/graphql/types/Query/post.ts b/src/graphql/types/Query/post.ts index a1de6f7c60b..ba6098be5d5 100644 --- a/src/graphql/types/Query/post.ts +++ b/src/graphql/types/Query/post.ts @@ -64,7 +64,7 @@ builder.queryField("post", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -73,7 +73,7 @@ builder.queryField("post", (t) => }, }, }, - postAttachmentsWherePost: true, + attachmentsWherePost: true, }, where: (fields, operators) => operators.eq(fields.id, parsedArgs.input.id), @@ -102,7 +102,7 @@ builder.queryField("post", (t) => } const currentUserOrganizationMembership = - existingPost.organization.organizationMembershipsWhereOrganization[0]; + existingPost.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && @@ -121,7 +121,7 @@ builder.queryField("post", (t) => } return Object.assign(existingPost, { - attachments: existingPost.postAttachmentsWherePost, + attachments: existingPost.attachmentsWherePost, }); }, type: Post, diff --git a/src/graphql/types/Query/signIn.ts b/src/graphql/types/Query/signIn.ts index eb91282c45b..e6d070da732 100755 --- a/src/graphql/types/Query/signIn.ts +++ b/src/graphql/types/Query/signIn.ts @@ -17,7 +17,7 @@ builder.queryField("signIn", (t) => t.field({ args: { input: t.arg({ - description: "Input required to sign in to talawa.", + description: "", required: true, type: QuerySignInInput, }), @@ -84,7 +84,7 @@ builder.queryField("signIn", (t) => }); } - // The following code is necessary for continuing the expected graph traversal for an authenticated client because of absence of an authentication context for clients that triggered this operation. This should be removed when authentication flows are seperated from the graphql implementation. + // TODO: The following code is necessary for continuing the expected graph traversal for unauthenticated clients that triggered this operation because of absence of an authentication context for those clients. This should be removed when authentication flows are seperated from the graphql implementation. // @ts-expect-error ctx.currentClient.isAuthenticated = true; diff --git a/src/graphql/types/Query/tag.ts b/src/graphql/types/Query/tag.ts index 5e6032aebb3..62e3390234f 100644 --- a/src/graphql/types/Query/tag.ts +++ b/src/graphql/types/Query/tag.ts @@ -71,7 +71,7 @@ builder.queryField("tag", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -99,7 +99,7 @@ builder.queryField("tag", (t) => } const currentUserOrganizationMembership = - existingTag.organization.organizationMembershipsWhereOrganization[0]; + existingTag.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Query/tagFolder.ts b/src/graphql/types/Query/tagFolder.ts index 12b8bfb4c96..73f57d29c50 100644 --- a/src/graphql/types/Query/tagFolder.ts +++ b/src/graphql/types/Query/tagFolder.ts @@ -72,7 +72,7 @@ builder.queryField("tagFolder", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -100,8 +100,7 @@ builder.queryField("tagFolder", (t) => } const currentUserOrganizationMembership = - existingTagFolder.organization - .organizationMembershipsWhereOrganization[0]; + existingTagFolder.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && diff --git a/src/graphql/types/Query/venue.ts b/src/graphql/types/Query/venue.ts index 45b79ee7ab7..e2deab3de04 100644 --- a/src/graphql/types/Query/venue.ts +++ b/src/graphql/types/Query/venue.ts @@ -64,7 +64,7 @@ builder.queryField("venue", (t) => countryCode: true, }, with: { - organizationMembershipsWhereOrganization: { + membershipsWhereOrganization: { columns: { role: true, }, @@ -73,7 +73,7 @@ builder.queryField("venue", (t) => }, }, }, - venueAttachmentsWhereVenue: true, + attachmentsWhereVenue: true, }, where: (fields, operators) => operators.eq(fields.id, parsedArgs.input.id), @@ -102,7 +102,7 @@ builder.queryField("venue", (t) => } const currentUserOrganizationMembership = - existingVenue.organization.organizationMembershipsWhereOrganization[0]; + existingVenue.organization.membershipsWhereOrganization[0]; if ( currentUser.role !== "administrator" && @@ -121,7 +121,7 @@ builder.queryField("venue", (t) => } return Object.assign(existingVenue, { - attachments: existingVenue.venueAttachmentsWhereVenue, + attachments: existingVenue.attachmentsWhereVenue, }); }, type: Venue, diff --git a/src/graphql/types/Subscription/chatMessageCreate.ts b/src/graphql/types/Subscription/chatMessageCreate.ts index c80a5aabe2d..a60ee184d3b 100644 --- a/src/graphql/types/Subscription/chatMessageCreate.ts +++ b/src/graphql/types/Subscription/chatMessageCreate.ts @@ -21,8 +21,16 @@ builder.subscriptionField("chatMessageCreate", (t) => }), }, description: - "Subscription field to subscribe to the event of creation of a chat message.", + "Subscription field to subscribe to the event of creation of a message in a chat.", subscribe: async (_parent, args, ctx) => { + if (!ctx.currentClient.isAuthenticated) { + throw new TalawaGraphQLError({ + extensions: { + code: "unauthenticated", + }, + }); + } + const { success, data: parsedArgs, @@ -41,13 +49,52 @@ builder.subscriptionField("chatMessageCreate", (t) => }); } - const existingChat = await ctx.drizzleClient.query.chatsTable.findFirst({ - columns: { - avatarMimeType: true, - }, - where: (fields, operators) => - operators.eq(fields.id, parsedArgs.input.id), - }); + const currentUserId = ctx.currentClient.user.id; + + const [currentUser, existingChat] = await Promise.all([ + ctx.drizzleClient.query.usersTable.findFirst({ + columns: { + role: true, + }, + where: (fields, operators) => operators.eq(fields.id, currentUserId), + }), + ctx.drizzleClient.query.chatsTable.findFirst({ + columns: { + avatarMimeType: true, + }, + where: (fields, operators) => + operators.eq(fields.id, parsedArgs.input.id), + with: { + chatMembershipsWhereChat: { + columns: { + role: true, + }, + where: (fields, operators) => + operators.eq(fields.memberId, currentUserId), + }, + organization: { + columns: {}, + with: { + membershipsWhereOrganization: { + columns: { + role: true, + }, + where: (fields, operators) => + operators.eq(fields.memberId, currentUserId), + }, + }, + }, + }, + }), + ]); + + if (currentUser === undefined) { + throw new TalawaGraphQLError({ + extensions: { + code: "unauthenticated", + }, + }); + } if (existingChat === undefined) { throw new TalawaGraphQLError({ @@ -62,6 +109,29 @@ builder.subscriptionField("chatMessageCreate", (t) => }); } + const currentUserOrganizationMembership = + existingChat.organization.membershipsWhereOrganization[0]; + const currentUserChatMembership = + existingChat.chatMembershipsWhereChat[0]; + + if ( + currentUser.role !== "administrator" && + (currentUserOrganizationMembership === undefined || + (currentUserOrganizationMembership.role !== "administrator" && + currentUserChatMembership === undefined)) + ) { + throw new TalawaGraphQLError({ + extensions: { + code: "unauthorized_action_on_arguments_associated_resources", + issues: [ + { + argumentPath: ["input", "id"], + }, + ], + }, + }); + } + return await ctx.pubsub.subscribe( `chats.${parsedArgs.input.id}:chat_messages::create`, ); diff --git a/src/graphql/types/Venue/events.ts b/src/graphql/types/Venue/events.ts index ef85294317e..ffbdf31fbf5 100644 --- a/src/graphql/types/Venue/events.ts +++ b/src/graphql/types/Venue/events.ts @@ -208,7 +208,7 @@ Venue.implement({ with: { event: { with: { - eventAttachmentsWhereEvent: true, + attachmentsWhereEvent: true, }, }, }, @@ -236,9 +236,9 @@ Venue.implement({ eventId: booking.eventId, }), ).toString("base64url"), - createNode: ({ event: { eventAttachmentsWhereEvent, ...event } }) => + createNode: ({ event: { attachmentsWhereEvent, ...event } }) => Object.assign(event, { - attachments: eventAttachmentsWhereEvent, + attachments: attachmentsWhereEvent, }), parsedArgs, rawNodes: venueBookings, diff --git a/src/plugins/seedInitialData.ts b/src/plugins/seedInitialData.ts index 6a4d7482d16..8b134ef6b40 100644 --- a/src/plugins/seedInitialData.ts +++ b/src/plugins/seedInitialData.ts @@ -10,15 +10,13 @@ import { } from "~/src/drizzle/tables/communities"; import { usersTable, usersTableInsertSchema } from "~/src/drizzle/tables/users"; -// TODO: Will be replaced with a different implementation in the future. - /** - * This plugin handles seeding the database with data at the startup time of the talawa api. + * This plugin handles seeding the initial data into appropriate service at the startup time of the talawa api. The data must strictly only comprise of things that are required in the production environment of talawa api. This plugin shouldn't be used for seeding dummy data. * * @example - * import seedDatabasePlugin from "./plugins/seedDatabase"; + * import seedInitialDataPlugin from "./plugins/seedInitialData"; * - * fastify.register(seedDatabasePlugin, {}); + * fastify.register(seedInitialDataPlugin, {}); */ const plugin: FastifyPluginAsync = async (fastify) => { fastify.log.info( diff --git a/src/utilities/getKeyPathsWithNonUndefinedValues.ts b/src/utilities/getKeyPathsWithNonUndefinedValues.ts index f6469249f39..2add8daa540 100644 --- a/src/utilities/getKeyPathsWithNonUndefinedValues.ts +++ b/src/utilities/getKeyPathsWithNonUndefinedValues.ts @@ -4,6 +4,52 @@ type Paths = T extends object /** * This function takes in a javascript object and a list of key paths within that object as arguments and outputs all paths amongst those key paths that correspond to a non-undefined value. + * + * @example + * + * const object = { + * field1: undefined, + * field2: "value2", + * field3: undefined, + * field4: null, + * field5: { + * field6: "value6", + * }, + * field7: { + * field8: { + * field9: "value9", + * field10: undefined, + * field11: null + * } + * }, + * field12: [ + * "value12", + * undefined, + * null, + * { + * field13: "value13" + * } + * ] + * } + * + * const keyPaths = getKeyPathsWithNonUndefinedValues([ + * ["field1"], + * ["field2"], + * ["field4"] + * ]); + * const keyPaths = getKeyPathsWithNonUndefinedValues([ + * ["field3"], + * ["field5", "field6"], + * ["field7", "field8", "field9"], + * ["field7", "field8", "field10"], + * ["field7", "field8", "field11"] + * ]); + * const keyPaths = getKeyPathsWithNonUndefinedValues([ + * ["field12", 0], + * ["field12", 1], + * ["field12", 2], + * ["field12", 3, "field13"] + * ]); */ export const getKeyPathsWithNonUndefinedValues = < T extends Record, diff --git a/src/utilities/isNotNullish.ts b/src/utilities/isNotNullish.ts index cd2487abcba..02d540a1c77 100644 --- a/src/utilities/isNotNullish.ts +++ b/src/utilities/isNotNullish.ts @@ -1,14 +1,13 @@ /** * This function is used to check nullish state of a value passed to it. Nullish means the value being either `null` or `undefined`. If the value is found to be nullish, the function returns the boolean `false`, else it returns the boolean `true`. * @example - * Here's an example:- - * function print(str: string | null) \{ - * if(isNotNullish(str)) \{ - * console.log(`the string is ${str}`) - * \} else \{ - * console.log(`the string is null`) - * \} - * \} + * function print(str: string | null) { + * if (isNotNullish(str)) { + * console.log(`the string is ${str}`); + * } else { + * console.log(`the string is null`); + * } + * } */ export function isNotNullish(value: T0 | undefined | null): value is T0 { return value !== undefined && value !== null; diff --git a/tsconfig.json b/tsconfig.json index d32ecd7895c..85a0226ac27 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -28,6 +28,7 @@ "tadaTurboLocation": "./test/routes/graphql/gql.tada-cache.d.ts" /* https://gql-tada.0no.co/reference/config-format#tadaturbolocation */ } ], + "noUncheckedIndexedAccess": true, "skipLibCheck": true /* Skip type checking all .d.ts files. */, "strict": true /* Enable all strict type-checking options. */, "target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,