@payloadcms/db-postgres 4.0.0-internal.5b1e7cd → 4.0.0-internal.5d5a2b2
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.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { DrizzleAdapter } from '@payloadcms/drizzle
|
|
1
|
+
{"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { DrizzleAdapter } from '@payloadcms/drizzle'\nimport type { Connect, Migration } from 'payload'\n\nimport { pushDevSchema } from '@payloadcms/drizzle'\nimport { drizzle } from 'drizzle-orm/node-postgres'\nimport { withReplicas } from 'drizzle-orm/pg-core'\n\nimport type { PostgresAdapter } from './types.js'\n\nconst connectWithReconnect = async function ({\n adapter,\n pool,\n reconnect = false,\n}: {\n adapter: PostgresAdapter\n pool: PostgresAdapter['pool']\n reconnect?: boolean\n}) {\n let result\n\n if (!reconnect) {\n result = await pool.connect()\n } else {\n try {\n result = await pool.connect()\n } catch (ignore) {\n setTimeout(() => {\n adapter.payload.logger.info('Reconnecting to postgres')\n void connectWithReconnect({ adapter, pool, reconnect: true })\n }, 1000)\n }\n }\n if (!result) {\n return\n }\n result.prependListener('error', (err) => {\n try {\n if (err.code === 'ECONNRESET') {\n void connectWithReconnect({ adapter, pool, reconnect: true })\n }\n } catch (ignore) {\n // swallow error\n }\n })\n}\n\nexport const connect: Connect = async function connect(\n this: PostgresAdapter,\n options = {\n hotReload: false,\n },\n) {\n const { hotReload } = options\n\n try {\n if (!this.pool) {\n this.pool = new this.pg.Pool(this.poolOptions)\n await connectWithReconnect({ adapter: this, pool: this.pool })\n }\n\n const logger = this.logger || false\n this.drizzle = drizzle({ client: this.pool, logger, schema: this.schema })\n\n if (this.readReplicaOptions) {\n this.primaryDrizzle = this.drizzle as any\n const readReplicas = this.readReplicaOptions.map((connectionString) => {\n const options = {\n ...this.poolOptions,\n connectionString,\n }\n const pool = new this.pg.Pool(options)\n void connectWithReconnect({\n adapter: this,\n pool,\n })\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 && this.connect) {\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 unknown as Migration[] })\n }\n}\n"],"names":["pushDevSchema","drizzle","withReplicas","connectWithReconnect","adapter","pool","reconnect","result","connect","ignore","setTimeout","payload","logger","info","prependListener","err","code","options","hotReload","pg","Pool","poolOptions","client","schema","readReplicaOptions","primaryDrizzle","readReplicas","map","connectionString","myReplicas","process","env","PAYLOAD_DROP_DATABASE","schemaName","dropDatabase","error","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,OAAO,QAAQ,4BAA2B;AACnD,SAASC,YAAY,QAAQ,sBAAqB;AAIlD,MAAMC,uBAAuB,eAAgB,EAC3CC,OAAO,EACPC,IAAI,EACJC,YAAY,KAAK,EAKlB;IACC,IAAIC;IAEJ,IAAI,CAACD,WAAW;QACdC,SAAS,MAAMF,KAAKG,OAAO;IAC7B,OAAO;QACL,IAAI;YACFD,SAAS,MAAMF,KAAKG,OAAO;QAC7B,EAAE,OAAOC,QAAQ;YACfC,WAAW;gBACTN,QAAQO,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC;gBAC5B,KAAKV,qBAAqB;oBAAEC;oBAASC;oBAAMC,WAAW;gBAAK;YAC7D,GAAG;QACL;IACF;IACA,IAAI,CAACC,QAAQ;QACX;IACF;IACAA,OAAOO,eAAe,CAAC,SAAS,CAACC;QAC/B,IAAI;YACF,IAAIA,IAAIC,IAAI,KAAK,cAAc;gBAC7B,KAAKb,qBAAqB;oBAAEC;oBAASC;oBAAMC,WAAW;gBAAK;YAC7D;QACF,EAAE,OAAOG,QAAQ;QACf,gBAAgB;QAClB;IACF;AACF;AAEA,OAAO,MAAMD,UAAmB,eAAeA,QAE7CS,UAAU;IACRC,WAAW;AACb,CAAC;IAED,MAAM,EAAEA,SAAS,EAAE,GAAGD;IAEtB,IAAI;QACF,IAAI,CAAC,IAAI,CAACZ,IAAI,EAAE;YACd,IAAI,CAACA,IAAI,GAAG,IAAI,IAAI,CAACc,EAAE,CAACC,IAAI,CAAC,IAAI,CAACC,WAAW;YAC7C,MAAMlB,qBAAqB;gBAAEC,SAAS,IAAI;gBAAEC,MAAM,IAAI,CAACA,IAAI;YAAC;QAC9D;QAEA,MAAMO,SAAS,IAAI,CAACA,MAAM,IAAI;QAC9B,IA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uB,OAAO,CAACG,MAAM,CAAC,GAAGC,WAAW,KAAK3B,IAAIuB,OAAO,CAACK,KAAK,CAAC,GAAG,aAAa,CAAC;YAE9E,MAAMC,YAAY,MAAM,IAAI,CAACC,cAAc;YAE3C,IAAID,aAAa,IAAI,CAACpC,OAAO,EAAE;gBAC7B,MAAM,IAAI,CAACA,OAAO,CAACS;gBACnB;YACF;QACF,OAAO;YACL,IAAI,CAACN,OAAO,CAACC,MAAM,CAACuB,KAAK,CAAC;gBACxBpB;gBACA+B,KAAK,CAAC,4CAA4C,EAAE/B,IAAIuB,OAAO,EAAE;YACnE;QACF;QAEA,IAAI,OAAO,IAAI,CAACS,kBAAkB,KAAK,YAAY;YACjD,IAAI,CAACA,kBAAkB;QACzB;QACA,MAAM,IAAIX,MAAM,CAAC,mCAAmC,EAAErB,IAAIuB,OAAO,EAAE;IACrE;IAEA,MAAM,IAAI,CAACU,gBAAgB;IAE3B,wCAAwC;IACxC,IACElB,QAAQC,GAAG,CAACkB,QAAQ,KAAK,gBACzBnB,QAAQC,GAAG,CAACmB,iBAAiB,KAAK,UAClC,IAAI,CAACC,IAAI,KAAK,OACd;QACA,MAAMnD,cAAc,IAAI;IAC1B;IAEA,IAAI,OAAO,IAAI,CAACoD,mBAAmB,KAAK,YAAY;QAClD,IAAI,CAACA,mBAAmB;IAC1B;IAEA,IAAItB,QAAQC,GAAG,CAACkB,QAAQ,KAAK,gBAAgB,IAAI,CAACI,cAAc,EAAE;QAChE,MAAM,IAAI,CAACC,OAAO,CAAC;YAAEC,YAAY,IAAI,CAACF,cAAc;QAA2B;IACjF;AACF,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/db-postgres",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.5d5a2b2",
|
|
4
4
|
"description": "The officially supported Postgres database adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,11 +25,6 @@
|
|
|
25
25
|
"types": "./dist/index.d.ts",
|
|
26
26
|
"default": "./dist/index.js"
|
|
27
27
|
},
|
|
28
|
-
"./types": {
|
|
29
|
-
"import": "./dist/exports/types-deprecated.js",
|
|
30
|
-
"types": "./dist/exports/types-deprecated.d.ts",
|
|
31
|
-
"default": "./dist/exports/types-deprecated.js"
|
|
32
|
-
},
|
|
33
28
|
"./migration-utils": {
|
|
34
29
|
"import": "./dist/exports/migration-utils.js",
|
|
35
30
|
"types": "./dist/exports/migration-utils.d.ts",
|
|
@@ -64,24 +59,24 @@
|
|
|
64
59
|
],
|
|
65
60
|
"dependencies": {
|
|
66
61
|
"@types/pg": "8.20.0",
|
|
67
|
-
"console-table-printer": "2.
|
|
62
|
+
"console-table-printer": "2.15.0",
|
|
68
63
|
"drizzle-kit": "0.31.7",
|
|
69
64
|
"drizzle-orm": "0.45.2",
|
|
70
65
|
"pg": "8.20.0",
|
|
71
66
|
"prompts": "2.4.2",
|
|
72
67
|
"to-snake-case": "1.0.0",
|
|
73
|
-
"uuid": "
|
|
74
|
-
"@payloadcms/drizzle": "4.0.0-internal.
|
|
68
|
+
"uuid": "14.0.0",
|
|
69
|
+
"@payloadcms/drizzle": "4.0.0-internal.5d5a2b2"
|
|
75
70
|
},
|
|
76
71
|
"devDependencies": {
|
|
77
72
|
"@hyrious/esbuild-plugin-commonjs": "0.2.6",
|
|
78
73
|
"@types/to-snake-case": "1.0.0",
|
|
79
74
|
"esbuild": "0.27.1",
|
|
80
75
|
"@payloadcms/eslint-config": "3.28.0",
|
|
81
|
-
"payload": "4.0.0-internal.
|
|
76
|
+
"payload": "4.0.0-internal.5d5a2b2"
|
|
82
77
|
},
|
|
83
78
|
"peerDependencies": {
|
|
84
|
-
"payload": "4.0.0-internal.
|
|
79
|
+
"payload": "4.0.0-internal.5d5a2b2"
|
|
85
80
|
},
|
|
86
81
|
"scripts": {
|
|
87
82
|
"build": "rimraf .dist && rimraf tsconfig.tsbuildinfo && pnpm build:types && pnpm build:swc && pnpm build:esbuild && pnpm renamePredefinedMigrations",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Args as _Args, GeneratedDatabaseSchema as _GeneratedDatabaseSchema, PostgresAdapter as _PostgresAdapter } from '../types.js';
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated - import from `@payloadcms/db-postgres` instead
|
|
4
|
-
*/
|
|
5
|
-
export type Args = _Args;
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated - import from `@payloadcms/db-postgres` instead
|
|
8
|
-
*/
|
|
9
|
-
export type GeneratedDatabaseSchema = _GeneratedDatabaseSchema;
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated - import from `@payloadcms/db-postgres` instead
|
|
12
|
-
*/
|
|
13
|
-
export type PostgresAdapter = _PostgresAdapter;
|
|
14
|
-
//# sourceMappingURL=types-deprecated.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-deprecated.d.ts","sourceRoot":"","sources":["../../src/exports/types-deprecated.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,IAAI,KAAK,EACb,uBAAuB,IAAI,wBAAwB,EACnD,eAAe,IAAI,gBAAgB,EACpC,MAAM,aAAa,CAAA;AAEpB;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG,KAAK,CAAA;AAExB;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,wBAAwB,CAAA;AAE9D;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,gBAAgB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/types-deprecated.ts"],"sourcesContent":["import type {\n Args as _Args,\n GeneratedDatabaseSchema as _GeneratedDatabaseSchema,\n PostgresAdapter as _PostgresAdapter,\n} from '../types.js'\n\n/**\n * @deprecated - import from `@payloadcms/db-postgres` instead\n */\nexport type Args = _Args\n\n/**\n * @deprecated - import from `@payloadcms/db-postgres` instead\n */\nexport type GeneratedDatabaseSchema = _GeneratedDatabaseSchema\n\n/**\n * @deprecated - import from `@payloadcms/db-postgres` instead\n */\nexport type PostgresAdapter = _PostgresAdapter\n"],"names":[],"mappings":"AAgBA;;CAEC,GACD,WAA8C"}
|