@payloadcms/db-vercel-postgres 3.65.0-canary.3 → 3.65.0-internal.ef3958a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connect.js +1 -1
- package/dist/connect.js.map +1 -1
- package/package.json +4 -4
package/dist/connect.js
CHANGED
|
@@ -73,7 +73,7 @@ export const connect = async function connect(options = {
|
|
|
73
73
|
if (typeof this.rejectInitializing === 'function') {
|
|
74
74
|
this.rejectInitializing();
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
throw new Error(`Error: cannot connect to Postgres: ${err.message}`);
|
|
77
77
|
}
|
|
78
78
|
await this.createExtensions();
|
|
79
79
|
// Only push schema if not in production
|
package/dist/connect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { DrizzleAdapter } from '@payloadcms/drizzle/types'\nimport type { Connect, Migration } from 'payload'\n\nimport { pushDevSchema } from '@payloadcms/drizzle'\nimport { sql, VercelPool } from '@vercel/postgres'\nimport { drizzle } from 'drizzle-orm/node-postgres'\nimport { withReplicas } from 'drizzle-orm/pg-core'\nimport pg from 'pg'\n\nimport type { VercelPostgresAdapter } from './types.js'\n\nexport const connect: Connect = async function connect(\n this: VercelPostgresAdapter,\n options = {\n hotReload: false,\n },\n) {\n const { hotReload } = options\n\n try {\n const logger = this.logger || false\n\n let client: pg.Pool | VercelPool\n\n const connectionString = this.poolOptions?.connectionString ?? process.env.POSTGRES_URL\n\n // Use non-vercel postgres for local database\n if (\n !this.forceUseVercelPostgres &&\n connectionString &&\n ['127.0.0.1', 'localhost'].includes(new URL(connectionString).hostname)\n ) {\n client = new pg.Pool(\n this.poolOptions ?? {\n connectionString,\n },\n )\n } else {\n client = this.poolOptions ? new VercelPool(this.poolOptions) : sql\n }\n\n // Passed the poolOptions if provided,\n // else have vercel/postgres detect the connection string from the environment\n this.drizzle = drizzle({\n client,\n logger,\n schema: this.schema,\n })\n\n if (this.readReplicaOptions) {\n const readReplicas = this.readReplicaOptions.map((connectionString) => {\n const options = {\n ...this.poolOptions,\n connectionString,\n }\n const pool = new VercelPool(options)\n return drizzle({ client: pool, logger, schema: this.schema })\n })\n const myReplicas = withReplicas(this.drizzle, readReplicas as any)\n this.drizzle = myReplicas\n }\n\n if (!hotReload) {\n if (process.env.PAYLOAD_DROP_DATABASE === 'true') {\n this.payload.logger.info(`---- DROPPING TABLES SCHEMA(${this.schemaName || 'public'}) ----`)\n await this.dropDatabase({ adapter: this })\n this.payload.logger.info('---- DROPPED TABLES ----')\n }\n }\n } catch (error) {\n const err = error instanceof Error ? error : new Error(String(error))\n if (err.message?.match(/database .* does not exist/i) && !this.disableCreateDatabase) {\n // capitalize first char of the err msg\n this.payload.logger.info(\n `${err.message.charAt(0).toUpperCase() + err.message.slice(1)}, creating...`,\n )\n const isCreated = await this.createDatabase()\n\n if (isCreated) {\n await this.connect?.(options)\n return\n }\n } else {\n this.payload.logger.error({\n err,\n msg: `Error: cannot connect to Postgres. Details: ${err.message}`,\n })\n }\n\n if (typeof this.rejectInitializing === 'function') {\n this.rejectInitializing()\n }\n
|
|
1
|
+
{"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { DrizzleAdapter } from '@payloadcms/drizzle/types'\nimport type { Connect, Migration } from 'payload'\n\nimport { pushDevSchema } from '@payloadcms/drizzle'\nimport { sql, VercelPool } from '@vercel/postgres'\nimport { drizzle } from 'drizzle-orm/node-postgres'\nimport { withReplicas } from 'drizzle-orm/pg-core'\nimport pg from 'pg'\n\nimport type { VercelPostgresAdapter } from './types.js'\n\nexport const connect: Connect = async function connect(\n this: VercelPostgresAdapter,\n options = {\n hotReload: false,\n },\n) {\n const { hotReload } = options\n\n try {\n const logger = this.logger || false\n\n let client: pg.Pool | VercelPool\n\n const connectionString = this.poolOptions?.connectionString ?? process.env.POSTGRES_URL\n\n // Use non-vercel postgres for local database\n if (\n !this.forceUseVercelPostgres &&\n connectionString &&\n ['127.0.0.1', 'localhost'].includes(new URL(connectionString).hostname)\n ) {\n client = new pg.Pool(\n this.poolOptions ?? {\n connectionString,\n },\n )\n } else {\n client = this.poolOptions ? new VercelPool(this.poolOptions) : sql\n }\n\n // Passed the poolOptions if provided,\n // else have vercel/postgres detect the connection string from the environment\n this.drizzle = drizzle({\n client,\n logger,\n schema: this.schema,\n })\n\n if (this.readReplicaOptions) {\n const readReplicas = this.readReplicaOptions.map((connectionString) => {\n const options = {\n ...this.poolOptions,\n connectionString,\n }\n const pool = new VercelPool(options)\n return drizzle({ client: pool, logger, schema: this.schema })\n })\n const myReplicas = withReplicas(this.drizzle, readReplicas as any)\n this.drizzle = myReplicas\n }\n\n if (!hotReload) {\n if (process.env.PAYLOAD_DROP_DATABASE === 'true') {\n this.payload.logger.info(`---- DROPPING TABLES SCHEMA(${this.schemaName || 'public'}) ----`)\n await this.dropDatabase({ adapter: this })\n this.payload.logger.info('---- DROPPED TABLES ----')\n }\n }\n } catch (error) {\n const err = error instanceof Error ? error : new Error(String(error))\n if (err.message?.match(/database .* does not exist/i) && !this.disableCreateDatabase) {\n // capitalize first char of the err msg\n this.payload.logger.info(\n `${err.message.charAt(0).toUpperCase() + err.message.slice(1)}, creating...`,\n )\n const isCreated = await this.createDatabase()\n\n if (isCreated) {\n await this.connect?.(options)\n return\n }\n } else {\n this.payload.logger.error({\n err,\n msg: `Error: cannot connect to Postgres. Details: ${err.message}`,\n })\n }\n\n if (typeof this.rejectInitializing === 'function') {\n this.rejectInitializing()\n }\n throw new Error(`Error: cannot connect to Postgres: ${err.message}`)\n }\n\n await this.createExtensions()\n\n // Only push schema if not in production\n if (\n process.env.NODE_ENV !== 'production' &&\n process.env.PAYLOAD_MIGRATING !== 'true' &&\n this.push !== false\n ) {\n await pushDevSchema(this as unknown as DrizzleAdapter)\n }\n\n if (typeof this.resolveInitializing === 'function') {\n this.resolveInitializing()\n }\n\n if (process.env.NODE_ENV === 'production' && this.prodMigrations) {\n await this.migrate({ migrations: this.prodMigrations as Migration[] })\n }\n}\n"],"names":["pushDevSchema","sql","VercelPool","drizzle","withReplicas","pg","connect","options","hotReload","logger","client","connectionString","poolOptions","process","env","POSTGRES_URL","forceUseVercelPostgres","includes","URL","hostname","Pool","schema","readReplicaOptions","readReplicas","map","pool","myReplicas","PAYLOAD_DROP_DATABASE","payload","info","schemaName","dropDatabase","adapter","error","err","Error","String","message","match","disableCreateDatabase","charAt","toUpperCase","slice","isCreated","createDatabase","msg","rejectInitializing","createExtensions","NODE_ENV","PAYLOAD_MIGRATING","push","resolveInitializing","prodMigrations","migrate","migrations"],"mappings":"AAGA,SAASA,aAAa,QAAQ,sBAAqB;AACnD,SAASC,GAAG,EAAEC,UAAU,QAAQ,mBAAkB;AAClD,SAASC,OAAO,QAAQ,4BAA2B;AACnD,SAASC,YAAY,QAAQ,sBAAqB;AAClD,OAAOC,QAAQ,KAAI;AAInB,OAAO,MAAMC,UAAmB,eAAeA,QAE7CC,UAAU;IACRC,WAAW;AACb,CAAC;IAED,MAAM,EAAEA,SAAS,EAAE,GAAGD;IAEtB,IAAI;QACF,MAAME,SAAS,IAAI,CAACA,MAAM,IAAI;QAE9B,IAAIC;QAEJ,MAAMC,mBAAmB,IAAI,CAACC,WAAW,EAAED,oBAAoBE,QAAQC,GAAG,CAACC,YAAY;QAEvF,6CAA6C;QAC7C,IACE,CAAC,IAAI,CAACC,sBAAsB,IAC5BL,oBACA;YAAC;YAAa;SAAY,CAACM,QAAQ,CAAC,IAAIC,IAAIP,kBAAkBQ,QAAQ,GACtE;YACAT,SAAS,IAAIL,GAAGe,IAAI,CAClB,IAAI,CAACR,WAAW,IAAI;gBAClBD;YACF;QAEJ,OAAO;YACLD,SAAS,IAAI,CAACE,WAAW,GAAG,IAAIV,WAAW,IAAI,CAACU,WAAW,IAAIX;QACjE;QAEA,sCAAsC;QACtC,8EAA8E;QAC9E,IAAI,CAACE,OAAO,GAAGA,QAAQ;YACrBO;YACAD;YACAY,QAAQ,IAAI,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I,CAACqB,OAAO,CAACnB,MAAM,CAACwB,KAAK,CAAC;gBACxBC;gBACAW,KAAK,CAAC,4CAA4C,EAAEX,IAAIG,OAAO,EAAE;YACnE;QACF;QAEA,IAAI,OAAO,IAAI,CAACS,kBAAkB,KAAK,YAAY;YACjD,IAAI,CAACA,kBAAkB;QACzB;QACA,MAAM,IAAIX,MAAM,CAAC,mCAAmC,EAAED,IAAIG,OAAO,EAAE;IACrE;IAEA,MAAM,IAAI,CAACU,gBAAgB;IAE3B,wCAAwC;IACxC,IACElC,QAAQC,GAAG,CAACkC,QAAQ,KAAK,gBACzBnC,QAAQC,GAAG,CAACmC,iBAAiB,KAAK,UAClC,IAAI,CAACC,IAAI,KAAK,OACd;QACA,MAAMlD,cAAc,IAAI;IAC1B;IAEA,IAAI,OAAO,IAAI,CAACmD,mBAAmB,KAAK,YAAY;QAClD,IAAI,CAACA,mBAAmB;IAC1B;IAEA,IAAItC,QAAQC,GAAG,CAACkC,QAAQ,KAAK,gBAAgB,IAAI,CAACI,cAAc,EAAE;QAChE,MAAM,IAAI,CAACC,OAAO,CAAC;YAAEC,YAAY,IAAI,CAACF,cAAc;QAAgB;IACtE;AACF,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/db-vercel-postgres",
|
|
3
|
-
"version": "3.65.0-
|
|
3
|
+
"version": "3.65.0-internal.ef3958a",
|
|
4
4
|
"description": "Vercel Postgres adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"prompts": "2.4.2",
|
|
72
72
|
"to-snake-case": "1.0.0",
|
|
73
73
|
"uuid": "10.0.0",
|
|
74
|
-
"@payloadcms/drizzle": "3.65.0-
|
|
74
|
+
"@payloadcms/drizzle": "3.65.0-internal.ef3958a"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@hyrious/esbuild-plugin-commonjs": "0.2.6",
|
|
@@ -79,10 +79,10 @@
|
|
|
79
79
|
"@types/to-snake-case": "1.0.0",
|
|
80
80
|
"esbuild": "0.25.5",
|
|
81
81
|
"@payloadcms/eslint-config": "3.28.0",
|
|
82
|
-
"payload": "3.65.0-
|
|
82
|
+
"payload": "3.65.0-internal.ef3958a"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
|
-
"payload": "3.65.0-
|
|
85
|
+
"payload": "3.65.0-internal.ef3958a"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
88
|
"build": "rimraf .dist && rimraf tsconfig.tsbuildinfo && pnpm build:types && pnpm build:swc && pnpm build:esbuild && pnpm renamePredefinedMigrations",
|