fix: enforce universal appwrite instance patch and downgrade sdk to v17

This commit is contained in:
Carlos (Almeira) 2026-07-10 08:03:24 -05:00
parent 7113ba706b
commit 9993a76f57
5 changed files with 14 additions and 11 deletions

12
package-lock.json generated
View File

@ -3235,9 +3235,9 @@
} }
}, },
"node_modules/appwrite": { "node_modules/appwrite": {
"version": "17.0.0", "version": "17.0.2",
"resolved": "https://registry.npmjs.org/appwrite/-/appwrite-17.0.0.tgz", "resolved": "https://registry.npmjs.org/appwrite/-/appwrite-17.0.2.tgz",
"integrity": "sha512-R5+jMh6dVsKC5BdcO9G3wQPxqlU048zxj/Hahq2SU86XIxb0jWThQqS7MtyLUg7tz27SrwO2JvpwUrT9SOStDA==", "integrity": "sha512-h8frLDRYzFDLS9xA2s8ZSlH/prPFq/ma5477fgQHHLcE/t9RDxNImpq9AleRUb9Oh1YJiP49HCObxgSTGW5AQA==",
"license": "BSD-3-Clause" "license": "BSD-3-Clause"
}, },
"node_modules/argparse": { "node_modules/argparse": {
@ -6976,9 +6976,9 @@
} }
}, },
"node_modules/node-appwrite": { "node_modules/node-appwrite": {
"version": "17.0.0", "version": "17.2.0",
"resolved": "https://registry.npmjs.org/node-appwrite/-/node-appwrite-17.0.0.tgz", "resolved": "https://registry.npmjs.org/node-appwrite/-/node-appwrite-17.2.0.tgz",
"integrity": "sha512-5Moi5ENPnoAfU1/6CZP9K2NTuB6Nm3dSyhokno+24RDuP7czjXCdwzfeyjmyHieggbrLkN89AYSOv9W1XkCL9w==", "integrity": "sha512-naYUsVZEdF6YKF/q/s0DBQkAHJj2RhEWwmcXrkbfAAPc3Bn+D3CCftBqyNWeo17JBCoYWqQEgT2Od9xOVQR26A==",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"dependencies": { "dependencies": {
"node-fetch-native-with-agent": "1.7.2" "node-fetch-native-with-agent": "1.7.2"

View File

@ -25,7 +25,7 @@
"@tiptap/starter-kit": "^3.21.0", "@tiptap/starter-kit": "^3.21.0",
"@types/dompurify": "^3.0.5", "@types/dompurify": "^3.0.5",
"@types/video.js": "^7.3.58", "@types/video.js": "^7.3.58",
"appwrite": "^26.1.0", "appwrite": "^17.0.0",
"axios": "^1.18.0", "axios": "^1.18.0",
"cheerio": "^1.2.0", "cheerio": "^1.2.0",
"clsx": "^2.1.1", "clsx": "^2.1.1",
@ -36,7 +36,7 @@
"livekit-server-sdk": "^2.16.0", "livekit-server-sdk": "^2.16.0",
"lucide-react": "^0.577.0", "lucide-react": "^0.577.0",
"next": "^16.2.6", "next": "^16.2.6",
"node-appwrite": "^26.2.0", "node-appwrite": "^17.0.0",
"react": "19.2.3", "react": "19.2.3",
"react-dom": "19.2.3", "react-dom": "19.2.3",
"string-similarity": "^4.0.4", "string-similarity": "^4.0.4",

View File

@ -2,6 +2,7 @@
import { Client, Databases, Storage, ID } from 'node-appwrite'; import { Client, Databases, Storage, ID } from 'node-appwrite';
import { APPWRITE_ALMEIRA_CONFIG, databaseId } from '@/lib/appwrite'; import { APPWRITE_ALMEIRA_CONFIG, databaseId } from '@/lib/appwrite';
import { patchClientInstance } from '@/lib/appwrite.server';
import { revalidatePath } from 'next/cache'; import { revalidatePath } from 'next/cache';
import { InputFile } from 'node-appwrite/file'; import { InputFile } from 'node-appwrite/file';
@ -10,10 +11,11 @@ const PROJECT_ID = process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID || '69b84df5003bd
const DATABASE_ID = databaseId; const DATABASE_ID = databaseId;
function getAdminClient() { function getAdminClient() {
return new Client() const client = new Client()
.setEndpoint(ENDPOINT) .setEndpoint(ENDPOINT)
.setProject(PROJECT_ID) .setProject(PROJECT_ID)
.setKey(process.env.APPWRITE_API_KEY || ''); .setKey(process.env.APPWRITE_API_KEY || '');
return patchClientInstance(client);
} }
export async function createDocumentServer(collectionId: string, data: any) { export async function createDocumentServer(collectionId: string, data: any) {

View File

@ -2,6 +2,7 @@
import { Client, Databases, ID, Query } from 'node-appwrite'; import { Client, Databases, ID, Query } from 'node-appwrite';
import { databaseId } from '@/lib/appwrite'; import { databaseId } from '@/lib/appwrite';
import { patchClientInstance } from '@/lib/appwrite.server';
import { revalidatePath } from 'next/cache'; import { revalidatePath } from 'next/cache';
const ENDPOINT = process.env.NEXT_PUBLIC_APPWRITE_ENDPOINT || 'https://appwrite.almeira.com.co/v1'; const ENDPOINT = process.env.NEXT_PUBLIC_APPWRITE_ENDPOINT || 'https://appwrite.almeira.com.co/v1';
@ -14,7 +15,7 @@ async function getAdminClient() {
.setEndpoint(ENDPOINT) .setEndpoint(ENDPOINT)
.setProject(PROJECT_ID) .setProject(PROJECT_ID)
.setKey(process.env.APPWRITE_API_KEY || ''); .setKey(process.env.APPWRITE_API_KEY || '');
return new Databases(client); return new Databases(patchClientInstance(client));
} }
export async function getEntityConfig() { export async function getEntityConfig() {

View File

@ -2,7 +2,7 @@ import { Client, Account, Databases } from 'node-appwrite';
import { cookies } from 'next/headers'; import { cookies } from 'next/headers';
// Robust instance-level patch for Appwrite Next.js Server Components // Robust instance-level patch for Appwrite Next.js Server Components
function patchClientInstance(client: any) { export function patchClientInstance(client: any) {
if (client._isPatched) return client; if (client._isPatched) return client;
const originalCall = client.call.bind(client); const originalCall = client.call.bind(client);
client.call = async function (...args: any[]) { client.call = async function (...args: any[]) {