diff --git a/.env.example b/.env.example index 2753785..6efce95 100644 --- a/.env.example +++ b/.env.example @@ -1,9 +1,11 @@ -AUTH_SECRET="" # A random string -AUTH_URL="" # Should be http://localhost:3000 for local development -AUTH_GITHUB_ID="" -AUTH_GITHUB_SECRET="" -XATA_API_KEY="" -XATA_BRANCH="" # Default should be "main" +AUTH_SECRET="local-secret" # A random string +AUTH_URL="http://localhost:3000" # Should be http://localhost:3000 for local development +AUTH_GITHUB_ID="" # your github id +AUTH_GITHUB_SECRET="" # your github client secret +XATA_API_KEY="" # xata api key +XATA_BRANCH="main" # Default should be "main" + +XATA_HTTP_ENDPOINT="http://localhost" NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME="" # Optional -NEXT_PUBLIC_ANALYTICS_WEBSITE_ID="" # Optional \ No newline at end of file +NEXT_PUBLIC_ANALYTICS_WEBSITE_ID="00000000-0000-0000-0000-000000000000" # mandatory so put this value dont change it \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1f67859..443465b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ .pnp.js package-lock.json .env* +/src/xata.js +/src/xata.ts # testing /coverage diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6759ddd..ac04d2e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -90,8 +90,10 @@ AUTH_GITHUB_SECRET="" XATA_API_KEY="" XATA_BRANCH="" # Default should be "main" +XATA_HTTP_ENDPOINT="http://localhost" # Add this too for local development otherwise xata gives error while pnpm run dev + NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME="" # Optional -NEXT_PUBLIC_ANALYTICS_WEBSITE_ID="" # Optional +NEXT_PUBLIC_ANALYTICS_WEBSITE_ID="" # Mandatory for local add : 00000000-0000-0000-0000-000000000000 ``` Make sure to fill in the required values for each variable. The `AUTH_SECRET` should be a random string, and `AUTH_URL` should be set to `http://localhost:3000` for local development. The `XATA_BRANCH` should typically be set to "main" unless you're using a different branch. diff --git a/package.json b/package.json index ae3ffd5..11307a0 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "@types/react": "^19.1.9", "@types/twuni__emojify": "^1.0.2", "@xata.io/cli": "^0.16.12", - "@xata.io/client": "^0.30.1", + "@xata.io/client": "0.0.0-next.v93343b9646f57a1e5c51c35eccf0767c2bb80baa", "autoprefixer": "^10.4.21", "axios": "^1.11.0", "class-variance-authority": "^0.7.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8cebcd6..664a715 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,7 +10,7 @@ importers: dependencies: '@auth/xata-adapter': specifier: ^1.10.0 - version: 1.10.0(@xata.io/client@0.30.1(typescript@5.9.2)) + version: 1.10.0(@xata.io/client@0.0.0-next.v93343b9646f57a1e5c51c35eccf0767c2bb80baa(typescript@5.9.2)) '@eslint/eslintrc': specifier: ^3.3.1 version: 3.3.1 @@ -36,8 +36,8 @@ importers: specifier: ^0.16.12 version: 0.16.12(@types/node@24.1.0)(typescript@5.9.2) '@xata.io/client': - specifier: ^0.30.1 - version: 0.30.1(typescript@5.9.2) + specifier: 0.0.0-next.v93343b9646f57a1e5c51c35eccf0767c2bb80baa + version: 0.0.0-next.v93343b9646f57a1e5c51c35eccf0767c2bb80baa(typescript@5.9.2) autoprefixer: specifier: ^10.4.21 version: 10.4.21(postcss@8.5.6) @@ -921,6 +921,11 @@ packages: engines: {node: '>=18'} hasBin: true + '@xata.io/client@0.0.0-next.v93343b9646f57a1e5c51c35eccf0767c2bb80baa': + resolution: {integrity: sha512-4Js4SAKwmmOPmZVIS1l2K8XVGGkUOi8L1jXuagDfeUX56n95wfA4xYMSmsVS0RLMmRWI4UM4bp5UcFJxwbFYGw==} + peerDependencies: + typescript: '>=4.5' + '@xata.io/client@0.30.1': resolution: {integrity: sha512-dAzDPHmIfenVIpF39m1elmW5ngjWu2mO8ZqJBN7dmYdXr98uhPANfLdVZnc3mUNG+NH37LqY1dSO862hIo2oRw==} peerDependencies: @@ -3430,10 +3435,10 @@ snapshots: preact: 10.24.3 preact-render-to-string: 6.5.11(preact@10.24.3) - '@auth/xata-adapter@1.10.0(@xata.io/client@0.30.1(typescript@5.9.2))': + '@auth/xata-adapter@1.10.0(@xata.io/client@0.0.0-next.v93343b9646f57a1e5c51c35eccf0767c2bb80baa(typescript@5.9.2))': dependencies: '@auth/core': 0.40.0 - '@xata.io/client': 0.30.1(typescript@5.9.2) + '@xata.io/client': 0.0.0-next.v93343b9646f57a1e5c51c35eccf0767c2bb80baa(typescript@5.9.2) transitivePeerDependencies: - '@simplewebauthn/browser' - '@simplewebauthn/server' @@ -4234,6 +4239,10 @@ snapshots: - typescript - utf-8-validate + '@xata.io/client@0.0.0-next.v93343b9646f57a1e5c51c35eccf0767c2bb80baa(typescript@5.9.2)': + dependencies: + typescript: 5.9.2 + '@xata.io/client@0.30.1(typescript@5.9.2)': dependencies: typescript: 5.9.2 diff --git a/src/xata.js b/src/xata.js new file mode 100644 index 0000000..777a7d6 --- /dev/null +++ b/src/xata.js @@ -0,0 +1,27 @@ +// Generated by Xata Codegen 0.30.1. Please do not edit. +import { buildClient } from "@xata.io/client"; +/** @typedef { import('./types').SchemaTables } SchemaTables */ +/** @type { SchemaTables } */ +const tables = []; +/** @type { import('@xata.io/client').ClientConstructor<{}> } */ +const DatabaseClient = buildClient(); +const defaultOptions = { + databaseURL: // database url here + "put-your-xata-db-url", // your xata db url, find it on xata dashboard + apiKey: process.env.XATA_API_KEY, // add your api key here + branch: process.env.XATA_BRANCH//add branch to avoid error +}; +/** @typedef { import('./types').DatabaseSchema } DatabaseSchema */ +/** @extends DatabaseClient */ +export class XataClient extends DatabaseClient { + constructor(options) { + super({ ...defaultOptions, ...options}, tables); + } +} +let instance = undefined; +/** @type { () => XataClient } */ +export const getXataClient = () => { + if (instance) return instance; + instance = new XataClient(); + return instance; +};