@payloadcms/drizzle 3.5.1-canary.e5c20f4 → 3.6.0

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.
@@ -0,0 +1,3 @@
1
+ import type { CreateMigration } from 'payload';
2
+ export declare const createMigration: CreateMigration;
3
+ //# sourceMappingURL=createMigration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createMigration.d.ts","sourceRoot":"","sources":["../../src/postgres/createMigration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAc9C,eAAO,MAAM,eAAe,EAAE,eA2G7B,CAAA"}
@@ -0,0 +1,91 @@
1
+ import fs from 'fs';
2
+ import { createRequire } from 'module';
3
+ import { getPredefinedMigration, writeMigrationIndex } from 'payload';
4
+ import prompts from 'prompts';
5
+ import { defaultDrizzleSnapshot } from './defaultSnapshot.js';
6
+ import { getMigrationTemplate } from './getMigrationTemplate.js';
7
+ const require = createRequire(import.meta.url);
8
+ export const createMigration = async function createMigration({ dirname, file, forceAcceptWarning, migrationName, payload, skipEmpty }) {
9
+ const dir = payload.db.migrationDir;
10
+ if (!fs.existsSync(dir)) {
11
+ fs.mkdirSync(dir);
12
+ }
13
+ const { generateDrizzleJson, generateMigration, upPgSnapshot } = require('drizzle-kit/api');
14
+ const drizzleJsonAfter = generateDrizzleJson(this.schema);
15
+ const [yyymmdd, hhmmss] = new Date().toISOString().split('T');
16
+ const formattedDate = yyymmdd.replace(/\D/g, '');
17
+ const formattedTime = hhmmss.split('.')[0].replace(/\D/g, '');
18
+ let imports = '';
19
+ let downSQL;
20
+ let upSQL;
21
+ ({ downSQL, imports, upSQL } = await getPredefinedMigration({
22
+ dirname,
23
+ file,
24
+ migrationName,
25
+ payload
26
+ }));
27
+ const timestamp = `${formattedDate}_${formattedTime}`;
28
+ const name = migrationName || file?.split('/').slice(2).join('/');
29
+ const fileName = `${timestamp}${name ? `_${name.replace(/\W/g, '_')}` : ''}`;
30
+ const filePath = `${dir}/${fileName}`;
31
+ let drizzleJsonBefore = defaultDrizzleSnapshot;
32
+ if (this.schemaName) {
33
+ drizzleJsonBefore.schemas = {
34
+ [this.schemaName]: this.schemaName
35
+ };
36
+ }
37
+ if (!upSQL) {
38
+ // Get latest migration snapshot
39
+ const latestSnapshot = fs.readdirSync(dir).filter((file)=>file.endsWith('.json')).sort().reverse()?.[0];
40
+ if (latestSnapshot) {
41
+ drizzleJsonBefore = JSON.parse(fs.readFileSync(`${dir}/${latestSnapshot}`, 'utf8'));
42
+ if (drizzleJsonBefore.version < drizzleJsonAfter.version) {
43
+ drizzleJsonBefore = upPgSnapshot(drizzleJsonBefore);
44
+ }
45
+ }
46
+ const sqlStatementsUp = await generateMigration(drizzleJsonBefore, drizzleJsonAfter);
47
+ const sqlStatementsDown = await generateMigration(drizzleJsonAfter, drizzleJsonBefore);
48
+ const sqlExecute = 'await payload.db.drizzle.execute(sql`';
49
+ if (sqlStatementsUp?.length) {
50
+ upSQL = `${sqlExecute}\n ${sqlStatementsUp?.join('\n')}\`)`;
51
+ }
52
+ if (sqlStatementsDown?.length) {
53
+ downSQL = `${sqlExecute}\n ${sqlStatementsDown?.join('\n')}\`)`;
54
+ }
55
+ if (!upSQL?.length && !downSQL?.length && !forceAcceptWarning) {
56
+ if (skipEmpty) {
57
+ process.exit(0);
58
+ }
59
+ const { confirm: shouldCreateBlankMigration } = await prompts({
60
+ name: 'confirm',
61
+ type: 'confirm',
62
+ initial: false,
63
+ message: 'No schema changes detected. Would you like to create a blank migration file?'
64
+ }, {
65
+ onCancel: ()=>{
66
+ process.exit(0);
67
+ }
68
+ });
69
+ if (!shouldCreateBlankMigration) {
70
+ process.exit(0);
71
+ }
72
+ }
73
+ // write schema
74
+ fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2));
75
+ }
76
+ // write migration
77
+ fs.writeFileSync(`${filePath}.ts`, getMigrationTemplate({
78
+ downSQL: downSQL || ` // Migration code`,
79
+ imports,
80
+ packageName: payload.db.packageName,
81
+ upSQL: upSQL || ` // Migration code`
82
+ }));
83
+ writeMigrationIndex({
84
+ migrationsDir: payload.db.migrationDir
85
+ });
86
+ payload.logger.info({
87
+ msg: `Migration created at ${filePath}.ts`
88
+ });
89
+ };
90
+
91
+ //# sourceMappingURL=createMigration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/postgres/createMigration.ts"],"sourcesContent":["import type { CreateMigration } from 'payload'\n\nimport fs from 'fs'\nimport { createRequire } from 'module'\nimport { getPredefinedMigration, writeMigrationIndex } from 'payload'\nimport prompts from 'prompts'\n\nimport type { BasePostgresAdapter } from './types.js'\n\nimport { defaultDrizzleSnapshot } from './defaultSnapshot.js'\nimport { getMigrationTemplate } from './getMigrationTemplate.js'\n\nconst require = createRequire(import.meta.url)\n\nexport const createMigration: CreateMigration = async function createMigration(\n this: BasePostgresAdapter,\n { dirname, file, forceAcceptWarning, migrationName, payload, skipEmpty },\n) {\n const dir = payload.db.migrationDir\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir)\n }\n const { generateDrizzleJson, generateMigration, upPgSnapshot } = require('drizzle-kit/api')\n const drizzleJsonAfter = generateDrizzleJson(this.schema)\n const [yyymmdd, hhmmss] = new Date().toISOString().split('T')\n const formattedDate = yyymmdd.replace(/\\D/g, '')\n const formattedTime = hhmmss.split('.')[0].replace(/\\D/g, '')\n let imports: string = ''\n let downSQL: string\n let upSQL: string\n ;({ downSQL, imports, upSQL } = await getPredefinedMigration({\n dirname,\n file,\n migrationName,\n payload,\n }))\n\n const timestamp = `${formattedDate}_${formattedTime}`\n\n const name = migrationName || file?.split('/').slice(2).join('/')\n const fileName = `${timestamp}${name ? `_${name.replace(/\\W/g, '_')}` : ''}`\n\n const filePath = `${dir}/${fileName}`\n\n let drizzleJsonBefore = defaultDrizzleSnapshot\n\n if (this.schemaName) {\n drizzleJsonBefore.schemas = {\n [this.schemaName]: this.schemaName,\n }\n }\n\n if (!upSQL) {\n // Get latest migration snapshot\n const latestSnapshot = fs\n .readdirSync(dir)\n .filter((file) => file.endsWith('.json'))\n .sort()\n .reverse()?.[0]\n\n if (latestSnapshot) {\n drizzleJsonBefore = JSON.parse(fs.readFileSync(`${dir}/${latestSnapshot}`, 'utf8'))\n\n if (drizzleJsonBefore.version < drizzleJsonAfter.version) {\n drizzleJsonBefore = upPgSnapshot(drizzleJsonBefore)\n }\n }\n\n const sqlStatementsUp = await generateMigration(drizzleJsonBefore, drizzleJsonAfter)\n const sqlStatementsDown = await generateMigration(drizzleJsonAfter, drizzleJsonBefore)\n const sqlExecute = 'await payload.db.drizzle.execute(sql`'\n\n if (sqlStatementsUp?.length) {\n upSQL = `${sqlExecute}\\n ${sqlStatementsUp?.join('\\n')}\\`)`\n }\n if (sqlStatementsDown?.length) {\n downSQL = `${sqlExecute}\\n ${sqlStatementsDown?.join('\\n')}\\`)`\n }\n\n if (!upSQL?.length && !downSQL?.length && !forceAcceptWarning) {\n if (skipEmpty) {\n process.exit(0)\n }\n\n const { confirm: shouldCreateBlankMigration } = await prompts(\n {\n name: 'confirm',\n type: 'confirm',\n initial: false,\n message: 'No schema changes detected. Would you like to create a blank migration file?',\n },\n {\n onCancel: () => {\n process.exit(0)\n },\n },\n )\n\n if (!shouldCreateBlankMigration) {\n process.exit(0)\n }\n }\n\n // write schema\n fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2))\n }\n\n // write migration\n fs.writeFileSync(\n `${filePath}.ts`,\n getMigrationTemplate({\n downSQL: downSQL || ` // Migration code`,\n imports,\n packageName: payload.db.packageName,\n upSQL: upSQL || ` // Migration code`,\n }),\n )\n\n writeMigrationIndex({ migrationsDir: payload.db.migrationDir })\n\n payload.logger.info({ msg: `Migration created at ${filePath}.ts` })\n}\n"],"names":["fs","createRequire","getPredefinedMigration","writeMigrationIndex","prompts","defaultDrizzleSnapshot","getMigrationTemplate","require","url","createMigration","dirname","file","forceAcceptWarning","migrationName","payload","skipEmpty","dir","db","migrationDir","existsSync","mkdirSync","generateDrizzleJson","generateMigration","upPgSnapshot","drizzleJsonAfter","schema","yyymmdd","hhmmss","Date","toISOString","split","formattedDate","replace","formattedTime","imports","downSQL","upSQL","timestamp","name","slice","join","fileName","filePath","drizzleJsonBefore","schemaName","schemas","latestSnapshot","readdirSync","filter","endsWith","sort","reverse","JSON","parse","readFileSync","version","sqlStatementsUp","sqlStatementsDown","sqlExecute","length","process","exit","confirm","shouldCreateBlankMigration","type","initial","message","onCancel","writeFileSync","stringify","packageName","migrationsDir","logger","info","msg"],"mappings":"AAEA,OAAOA,QAAQ,KAAI;AACnB,SAASC,aAAa,QAAQ,SAAQ;AACtC,SAASC,sBAAsB,EAAEC,mBAAmB,QAAQ,UAAS;AACrE,OAAOC,aAAa,UAAS;AAI7B,SAASC,sBAAsB,QAAQ,uBAAsB;AAC7D,SAASC,oBAAoB,QAAQ,4BAA2B;AAEhE,MAAMC,UAAUN,cAAc,YAAYO,GAAG;AAE7C,OAAO,MAAMC,kBAAmC,eAAeA,gBAE7D,EAAEC,OAAO,EAAEC,IAAI,EAAEC,kBAAkB,EAAEC,aAAa,EAAEC,OAAO,EAAEC,SAAS,EAAE;IAExE,MAAMC,MAAMF,QAAQG,EAAE,CAACC,YAAY;IACnC,IAAI,CAAClB,GAAGmB,UAAU,CAACH,MAAM;QACvBhB,GAAGoB,SAAS,CAACJ;IACf;IACA,MAAM,EAAEK,mBAAmB,EAAEC,iBAAiB,EAAEC,YAAY,EAAE,GAAGhB,QAAQ;IACzE,MAAMiB,mBAAmBH,oBAAoB,IAAI,CAACI,MAAM;IACxD,MAAM,CAACC,SAASC,OAAO,GAAG,IAAIC,OAAOC,WAAW,GAAGC,KAAK,CAAC;IACzD,MAAMC,gBAAgBL,QAAQM,OAAO,CAAC,OAAO;IAC7C,MAAMC,gBAAgBN,OAAOG,KAAK,CAAC,IAAI,CAAC,EAAE,CAACE,OAAO,CAAC,OAAO;IAC1D,IA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AG,CAAC;QAC7D;QACA,IAAIiB,mBAAmBE,QAAQ;YAC7BxB,UAAU,GAAGuB,WAAW,GAAG,EAAED,mBAAmBjB,KAAK,MAAM,GAAG,CAAC;QACjE;QAEA,IAAI,CAACJ,OAAOuB,UAAU,CAACxB,SAASwB,UAAU,CAAC/C,oBAAoB;YAC7D,IAAIG,WAAW;gBACb6C,QAAQC,IAAI,CAAC;YACf;YAEA,MAAM,EAAEC,SAASC,0BAA0B,EAAE,GAAG,MAAM3D,QACpD;gBACEkC,MAAM;gBACN0B,MAAM;gBACNC,SAAS;gBACTC,SAAS;YACX,GACA;gBACEC,UAAU;oBACRP,QAAQC,IAAI,CAAC;gBACf;YACF;YAGF,IAAI,CAACE,4BAA4B;gBAC/BH,QAAQC,IAAI,CAAC;YACf;QACF;QAEA,eAAe;QACf7D,GAAGoE,aAAa,CAAC,GAAG1B,SAAS,KAAK,CAAC,EAAEU,KAAKiB,SAAS,CAAC7C,kBAAkB,MAAM;IAC9E;IAEA,kBAAkB;IAClBxB,GAAGoE,aAAa,CACd,GAAG1B,SAAS,GAAG,CAAC,EAChBpC,qBAAqB;QACnB6B,SAASA,WAAW,CAAC,mBAAmB,CAAC;QACzCD;QACAoC,aAAaxD,QAAQG,EAAE,CAACqD,WAAW;QACnClC,OAAOA,SAAS,CAAC,mBAAmB,CAAC;IACvC;IAGFjC,oBAAoB;QAAEoE,eAAezD,QAAQG,EAAE,CAACC,YAAY;IAAC;IAE7DJ,QAAQ0D,MAAM,CAACC,IAAI,CAAC;QAAEC,KAAK,CAAC,qBAAqB,EAAEhC,SAAS,GAAG,CAAC;IAAC;AACnE,EAAC"}
@@ -0,0 +1,4 @@
1
+ import type { MigrationTemplateArgs } from 'payload';
2
+ export declare const indent: (text: string) => string;
3
+ export declare const getMigrationTemplate: ({ downSQL, imports, packageName, upSQL, }: MigrationTemplateArgs) => string;
4
+ //# sourceMappingURL=getMigrationTemplate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getMigrationTemplate.d.ts","sourceRoot":"","sources":["../../src/postgres/getMigrationTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,eAAO,MAAM,MAAM,SAAU,MAAM,WAIpB,CAAA;AAEf,eAAO,MAAM,oBAAoB,8CAK9B,qBAAqB,KAAG,MAS1B,CAAA"}
@@ -0,0 +1,13 @@
1
+ export const indent = (text)=>text.split('\n').map((line)=>` ${line}`).join('\n');
2
+ export const getMigrationTemplate = ({ downSQL, imports, packageName, upSQL })=>`import { MigrateUpArgs, MigrateDownArgs, sql } from '${packageName}'
3
+ ${imports ? `${imports}\n` : ''}
4
+ export async function up({ payload, req }: MigrateUpArgs): Promise<void> {
5
+ ${indent(upSQL)}
6
+ }
7
+
8
+ export async function down({ payload, req }: MigrateDownArgs): Promise<void> {
9
+ ${indent(downSQL)}
10
+ }
11
+ `;
12
+
13
+ //# sourceMappingURL=getMigrationTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/postgres/getMigrationTemplate.ts"],"sourcesContent":["import type { MigrationTemplateArgs } from 'payload'\n\nexport const indent = (text: string) =>\n text\n .split('\\n')\n .map((line) => ` ${line}`)\n .join('\\n')\n\nexport const getMigrationTemplate = ({\n downSQL,\n imports,\n packageName,\n upSQL,\n}: MigrationTemplateArgs): string => `import { MigrateUpArgs, MigrateDownArgs, sql } from '${packageName}'\n${imports ? `${imports}\\n` : ''}\nexport async function up({ payload, req }: MigrateUpArgs): Promise<void> {\n${indent(upSQL)}\n}\n\nexport async function down({ payload, req }: MigrateDownArgs): Promise<void> {\n${indent(downSQL)}\n}\n`\n"],"names":["indent","text","split","map","line","join","getMigrationTemplate","downSQL","imports","packageName","upSQL"],"mappings":"AAEA,OAAO,MAAMA,SAAS,CAACC,OACrBA,KACGC,KAAK,CAAC,MACNC,GAAG,CAAC,CAACC,OAAS,CAAC,EAAE,EAAEA,MAAM,EACzBC,IAAI,CAAC,MAAK;AAEf,OAAO,MAAMC,uBAAuB,CAAC,EACnCC,OAAO,EACPC,OAAO,EACPC,WAAW,EACXC,KAAK,EACiB,GAAa,CAAC,qDAAqD,EAAED,YAAY;AACzG,EAAED,UAAU,GAAGA,QAAQ,EAAE,CAAC,GAAG,GAAG;;AAEhC,EAAER,OAAOU,OAAO;;;;AAIhB,EAAEV,OAAOO,SAAS;;AAElB,CAAC,CAAA"}
@@ -135,6 +135,8 @@ export type MigrateUpArgs = {
135
135
  * The Postgres Drizzle instance that you can use to execute SQL directly within the current transaction.
136
136
  * @example
137
137
  * ```ts
138
+ * import { type MigrateUpArgs, sql } from '@payloadcms/db-postgres'
139
+ *
138
140
  * export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
139
141
  * const { rows: posts } = await db.execute(sql`SELECT * FROM posts`)
140
142
  * }
@@ -146,6 +148,8 @@ export type MigrateUpArgs = {
146
148
  * To use the current transaction you must pass `req` to arguments
147
149
  * @example
148
150
  * ```ts
151
+ * import { type MigrateUpArgs, sql } from '@payloadcms/db-postgres'
152
+ *
149
153
  * export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
150
154
  * const posts = await payload.find({ collection: 'posts', req })
151
155
  * }
@@ -162,7 +166,9 @@ export type MigrateDownArgs = {
162
166
  * The Postgres Drizzle instance that you can use to execute SQL directly within the current transaction.
163
167
  * @example
164
168
  * ```ts
165
- * export async function down({ db, payload, req }: MigrateUpArgs): Promise<void> {
169
+ * import { type MigrateDownArgs, sql } from '@payloadcms/db-postgres'
170
+ *
171
+ * export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
166
172
  * const { rows: posts } = await db.execute(sql`SELECT * FROM posts`)
167
173
  * }
168
174
  * ```
@@ -173,7 +179,9 @@ export type MigrateDownArgs = {
173
179
  * To use the current transaction you must pass `req` to arguments
174
180
  * @example
175
181
  * ```ts
176
- * export async function down({ db, payload, req }: MigrateUpArgs): Promise<void> {
182
+ * import { type MigrateDownArgs } from '@payloadcms/db-postgres'
183
+ *
184
+ * export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
177
185
  * const posts = await payload.find({ collection: 'posts', req })
178
186
  * }
179
187
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/postgres/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,QAAQ,EACR,SAAS,EACT,GAAG,EACJ,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,MAAM,EACN,gCAAgC,EAChC,QAAQ,EACR,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,IAAI,CAAA;AAEnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEvF,MAAM,MAAM,eAAe,GAAG,MAAM,CAClC,MAAM,EACN,CAAC,IAAI,EAAE,cAAc,KAAK,iBAAiB,GAAG,YAAY,GAAG,uBAAuB,CACrF,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,GAAG,CAC3B,MAAM,EACN;IACE,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,GA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AA;CACxB,GAAG,sBAAsB,CAAA;AAE1B,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACvC,cAAc,EACZ,eAAe,GACf,aAAa,GACb,SAAS,GACT,cAAc,GACd,SAAS,GACT,QAAQ,GACR,WAAW,GACX,WAAW,CACd,CAAA;AAED,MAAM,MAAM,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAA;AAE/D,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;;;;;;;OAUG;IACH,EAAE,EAAE,UAAU,CAAA;IACd;;;;;;;;;;;OAWG;IACH,OAAO,EAAE,OAAO,CAAA;IAChB;;OAEG;IACH,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;;;;;;OAUG;IACH,EAAE,EAAE,UAAU,CAAA;IACd;;;;;;;;;;;OAWG;IACH,OAAO,EAAE,OAAO,CAAA;IAChB;;OAEG;IACH,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/postgres/types.ts"],"sourcesContent":["import type { DrizzleSnapshotJSON } from 'drizzle-kit/api'\nimport type {\n ColumnBaseConfig,\n ColumnDataType,\n DrizzleConfig,\n Relation,\n Relations,\n SQL,\n} from 'drizzle-orm'\nimport type { NodePgDatabase } from 'drizzle-orm/node-postgres'\nimport type {\n ForeignKeyBuilder,\n IndexBuilder,\n PgColumn,\n PgEnum,\n pgEnum,\n PgInsertOnConflictDoUpdateConfig,\n PgSchema,\n PgTableWithColumns,\n UniqueConstraintBuilder,\n} from 'drizzle-orm/pg-core'\nimport type { PgTableFn } from 'drizzle-orm/pg-core/table'\nimport type { Payload, PayloadRequest } from 'payload'\nimport type { ClientConfig, QueryResult } from 'pg'\n\nimport type { extendDrizzleTable, Operators } from '../index.js'\nimport type { BuildQueryJoinAliases, DrizzleAdapter, TransactionPg } from '../types.js'\n\nexport type BaseExtraConfig = Record<\n string,\n (cols: GenericColumns) => ForeignKeyBuilder | IndexBuilder | UniqueConstraintBuilder\n>\n\nexport type RelationMap = Map<\n string,\n {\n localized: boolean\n relationName?: string\n target: string\n type: 'many' | 'one'\n }\n>\n\nexport type GenericColumn = PgColumn<\n ColumnBaseConfig<ColumnDataType, string>,\n Record<string, unknown>\n>\n\nexport type GenericColumns = {\n [x: string]: GenericColumn\n}\n\nexport type GenericTable = PgTableWithColumns<{\n columns: GenericColumns\n dialect: string\n name: string\n schema: string\n}>\n\nexport type GenericEnum = PgEnum<[string, ...string[]]>\n\nexport type GenericRelation = Relations<string, Record<string, Relation<string>>>\n\nexport type PostgresDB = NodePgDatabase<Record<string, unknown>>\n\nexport type CountDistinct = (args: {\n db: PostgresDB | TransactionPg\n joins: BuildQueryJoinAliases\n tableName: string\n where: SQL\n}) => Promise<number>\n\nexport type DeleteWhere = (args: {\n db: PostgresDB | TransactionPg\n tableName: string\n where: SQL\n}) => Promise<void>\n\nexport type DropDatabase = (args: { adapter: BasePostgresAdapter }) => Promise<void>\n\nexport type Execute<T> = (args: {\n db?: PostgresDB | TransactionPg\n drizzle?: PostgresDB\n raw?: string\n sql?: SQL<unknown>\n}) => Promise<QueryResult<Record<string, T>>>\n\nexport type Insert = (args: {\n db: PostgresDB | TransactionPg\n onConflictDoUpdate?: PgInsertOnConflictDoUpdateConfig<any>\n tableName: string\n values: Record<string, unknown> | Record<string, unknown>[]\n}) => Promise<Record<string, unknown>[]>\n\nexport type CreateDatabase = (args?: {\n /**\n * Name of a database, defaults to the current one\n */\n name?: string\n /**\n * Schema to create in addition to 'public'. Defaults from adapter.schemaName if exists.\n */\n schemaName?: string\n}) => Promise<boolean>\n\ntype Schema =\n | {\n enum: typeof pgEnum\n table: PgTableFn<string>\n }\n | PgSchema\n\ntype PostgresSchema = {\n enums: Record<string, GenericEnum>\n relations: Record<string, GenericRelation>\n tables: Record<string, PgTableWithColumns<any>>\n}\n\ntype PostgresSchemaHookArgs = {\n adapter: PostgresDrizzleAdapter\n extendTable: typeof extendDrizzleTable\n schema: PostgresSchema\n}\n\nexport type PostgresSchemaHook = (\n args: PostgresSchemaHookArgs,\n) => PostgresSchema | Promise<PostgresSchema>\n\nexport type BasePostgresAdapter = {\n afterSchemaInit: PostgresSchemaHook[]\n beforeSchemaInit: PostgresSchemaHook[]\n countDistinct: CountDistinct\n createDatabase: CreateDatabase\n createExtensions: () => Promise<void>\n defaultDrizzleSnapshot: DrizzleSnapshotJSON\n deleteWhere: DeleteWhere\n disableCreateDatabase: boolean\n drizzle: PostgresDB\n dropDatabase: DropDatabase\n enums: Record<string, GenericEnum>\n execute: Execute<unknown>\n extensions: Record<string, boolean>\n /**\n * An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name\n * Used for returning properly formed errors from unique fields\n */\n fieldConstraints: Record<string, Record<string, string>>\n idType: 'serial' | 'uuid'\n initializing: Promise<void>\n insert: Insert\n localesSuffix?: string\n logger: DrizzleConfig['logger']\n operators: Operators\n pgSchema: Schema\n poolOptions?: ClientConfig\n prodMigrations?: {\n down: (args: MigrateDownArgs) => Promise<void>\n name: string\n up: (args: MigrateUpArgs) => Promise<void>\n }[]\n push: boolean\n rejectInitializing: () => void\n relations: Record<string, GenericRelation>\n relationshipsSuffix?: string\n resolveInitializing: () => void\n schemaName?: string\n sessions: {\n [id: string]: {\n db: PostgresDB | TransactionPg\n reject: () => Promise<void>\n resolve: () => Promise<void>\n }\n }\n tableNameMap: Map<string, string>\n tables: Record<string, GenericTable>\n tablesFilter?: string[]\n versionsSuffix?: string\n} & PostgresDrizzleAdapter\n\nexport type PostgresDrizzleAdapter = Omit<\n DrizzleAdapter,\n | 'countDistinct'\n | 'deleteWhere'\n | 'drizzle'\n | 'dropDatabase'\n | 'execute'\n | 'insert'\n | 'operators'\n | 'relations'\n>\n\nexport type IDType = 'integer' | 'numeric' | 'uuid' | 'varchar'\n\nexport type MigrateUpArgs = {\n /**\n * The Postgres Drizzle instance that you can use to execute SQL directly within the current transaction.\n * @example\n * ```ts\n * export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {\n * const { rows: posts } = await db.execute(sql`SELECT * FROM posts`)\n * }\n * ```\n */\n db: PostgresDB\n /**\n * The Payload instance that you can use to execute Local API methods\n * To use the current transaction you must pass `req` to arguments\n * @example\n * ```ts\n * export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {\n * const posts = await payload.find({ collection: 'posts', req })\n * }\n * ```\n */\n payload: Payload\n /**\n * The `PayloadRequest` object that contains the current transaction\n */\n req: PayloadRequest\n}\n\nexport type MigrateDownArgs = {\n /**\n * The Postgres Drizzle instance that you can use to execute SQL directly within the current transaction.\n * @example\n * ```ts\n * export async function down({ db, payload, req }: MigrateUpArgs): Promise<void> {\n * const { rows: posts } = await db.execute(sql`SELECT * FROM posts`)\n * }\n * ```\n */\n db: PostgresDB\n /**\n * The Payload instance that you can use to execute Local API methods\n * To use the current transaction you must pass `req` to arguments\n * @example\n * ```ts\n * export async function down({ db, payload, req }: MigrateUpArgs): Promise<void> {\n * const posts = await payload.find({ collection: 'posts', req })\n * }\n * ```\n */\n payload: Payload\n /**\n * The `PayloadRequest` object that contains the current transaction\n */\n req: PayloadRequest\n}\n"],"names":[],"mappings":"AA6NA,WA0BC"}
1
+ {"version":3,"sources":["../../src/postgres/types.ts"],"sourcesContent":["import type { DrizzleSnapshotJSON } from 'drizzle-kit/api'\nimport type {\n ColumnBaseConfig,\n ColumnDataType,\n DrizzleConfig,\n Relation,\n Relations,\n SQL,\n} from 'drizzle-orm'\nimport type { NodePgDatabase } from 'drizzle-orm/node-postgres'\nimport type {\n ForeignKeyBuilder,\n IndexBuilder,\n PgColumn,\n PgEnum,\n pgEnum,\n PgInsertOnConflictDoUpdateConfig,\n PgSchema,\n PgTableWithColumns,\n UniqueConstraintBuilder,\n} from 'drizzle-orm/pg-core'\nimport type { PgTableFn } from 'drizzle-orm/pg-core/table'\nimport type { Payload, PayloadRequest } from 'payload'\nimport type { ClientConfig, QueryResult } from 'pg'\n\nimport type { extendDrizzleTable, Operators } from '../index.js'\nimport type { BuildQueryJoinAliases, DrizzleAdapter, TransactionPg } from '../types.js'\n\nexport type BaseExtraConfig = Record<\n string,\n (cols: GenericColumns) => ForeignKeyBuilder | IndexBuilder | UniqueConstraintBuilder\n>\n\nexport type RelationMap = Map<\n string,\n {\n localized: boolean\n relationName?: string\n target: string\n type: 'many' | 'one'\n }\n>\n\nexport type GenericColumn = PgColumn<\n ColumnBaseConfig<ColumnDataType, string>,\n Record<string, unknown>\n>\n\nexport type GenericColumns = {\n [x: string]: GenericColumn\n}\n\nexport type GenericTable = PgTableWithColumns<{\n columns: GenericColumns\n dialect: string\n name: string\n schema: string\n}>\n\nexport type GenericEnum = PgEnum<[string, ...string[]]>\n\nexport type GenericRelation = Relations<string, Record<string, Relation<string>>>\n\nexport type PostgresDB = NodePgDatabase<Record<string, unknown>>\n\nexport type CountDistinct = (args: {\n db: PostgresDB | TransactionPg\n joins: BuildQueryJoinAliases\n tableName: string\n where: SQL\n}) => Promise<number>\n\nexport type DeleteWhere = (args: {\n db: PostgresDB | TransactionPg\n tableName: string\n where: SQL\n}) => Promise<void>\n\nexport type DropDatabase = (args: { adapter: BasePostgresAdapter }) => Promise<void>\n\nexport type Execute<T> = (args: {\n db?: PostgresDB | TransactionPg\n drizzle?: PostgresDB\n raw?: string\n sql?: SQL<unknown>\n}) => Promise<QueryResult<Record<string, T>>>\n\nexport type Insert = (args: {\n db: PostgresDB | TransactionPg\n onConflictDoUpdate?: PgInsertOnConflictDoUpdateConfig<any>\n tableName: string\n values: Record<string, unknown> | Record<string, unknown>[]\n}) => Promise<Record<string, unknown>[]>\n\nexport type CreateDatabase = (args?: {\n /**\n * Name of a database, defaults to the current one\n */\n name?: string\n /**\n * Schema to create in addition to 'public'. Defaults from adapter.schemaName if exists.\n */\n schemaName?: string\n}) => Promise<boolean>\n\ntype Schema =\n | {\n enum: typeof pgEnum\n table: PgTableFn<string>\n }\n | PgSchema\n\ntype PostgresSchema = {\n enums: Record<string, GenericEnum>\n relations: Record<string, GenericRelation>\n tables: Record<string, PgTableWithColumns<any>>\n}\n\ntype PostgresSchemaHookArgs = {\n adapter: PostgresDrizzleAdapter\n extendTable: typeof extendDrizzleTable\n schema: PostgresSchema\n}\n\nexport type PostgresSchemaHook = (\n args: PostgresSchemaHookArgs,\n) => PostgresSchema | Promise<PostgresSchema>\n\nexport type BasePostgresAdapter = {\n afterSchemaInit: PostgresSchemaHook[]\n beforeSchemaInit: PostgresSchemaHook[]\n countDistinct: CountDistinct\n createDatabase: CreateDatabase\n createExtensions: () => Promise<void>\n defaultDrizzleSnapshot: DrizzleSnapshotJSON\n deleteWhere: DeleteWhere\n disableCreateDatabase: boolean\n drizzle: PostgresDB\n dropDatabase: DropDatabase\n enums: Record<string, GenericEnum>\n execute: Execute<unknown>\n extensions: Record<string, boolean>\n /**\n * An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name\n * Used for returning properly formed errors from unique fields\n */\n fieldConstraints: Record<string, Record<string, string>>\n idType: 'serial' | 'uuid'\n initializing: Promise<void>\n insert: Insert\n localesSuffix?: string\n logger: DrizzleConfig['logger']\n operators: Operators\n pgSchema: Schema\n poolOptions?: ClientConfig\n prodMigrations?: {\n down: (args: MigrateDownArgs) => Promise<void>\n name: string\n up: (args: MigrateUpArgs) => Promise<void>\n }[]\n push: boolean\n rejectInitializing: () => void\n relations: Record<string, GenericRelation>\n relationshipsSuffix?: string\n resolveInitializing: () => void\n schemaName?: string\n sessions: {\n [id: string]: {\n db: PostgresDB | TransactionPg\n reject: () => Promise<void>\n resolve: () => Promise<void>\n }\n }\n tableNameMap: Map<string, string>\n tables: Record<string, GenericTable>\n tablesFilter?: string[]\n versionsSuffix?: string\n} & PostgresDrizzleAdapter\n\nexport type PostgresDrizzleAdapter = Omit<\n DrizzleAdapter,\n | 'countDistinct'\n | 'deleteWhere'\n | 'drizzle'\n | 'dropDatabase'\n | 'execute'\n | 'insert'\n | 'operators'\n | 'relations'\n>\n\nexport type IDType = 'integer' | 'numeric' | 'uuid' | 'varchar'\n\nexport type MigrateUpArgs = {\n /**\n * The Postgres Drizzle instance that you can use to execute SQL directly within the current transaction.\n * @example\n * ```ts\n * import { type MigrateUpArgs, sql } from '@payloadcms/db-postgres'\n *\n * export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {\n * const { rows: posts } = await db.execute(sql`SELECT * FROM posts`)\n * }\n * ```\n */\n db: PostgresDB\n /**\n * The Payload instance that you can use to execute Local API methods\n * To use the current transaction you must pass `req` to arguments\n * @example\n * ```ts\n * import { type MigrateUpArgs, sql } from '@payloadcms/db-postgres'\n *\n * export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {\n * const posts = await payload.find({ collection: 'posts', req })\n * }\n * ```\n */\n payload: Payload\n /**\n * The `PayloadRequest` object that contains the current transaction\n */\n req: PayloadRequest\n}\n\nexport type MigrateDownArgs = {\n /**\n * The Postgres Drizzle instance that you can use to execute SQL directly within the current transaction.\n * @example\n * ```ts\n * import { type MigrateDownArgs, sql } from '@payloadcms/db-postgres'\n *\n * export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {\n * const { rows: posts } = await db.execute(sql`SELECT * FROM posts`)\n * }\n * ```\n */\n db: PostgresDB\n /**\n * The Payload instance that you can use to execute Local API methods\n * To use the current transaction you must pass `req` to arguments\n * @example\n * ```ts\n * import { type MigrateDownArgs } from '@payloadcms/db-postgres'\n *\n * export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {\n * const posts = await payload.find({ collection: 'posts', req })\n * }\n * ```\n */\n payload: Payload\n /**\n * The `PayloadRequest` object that contains the current transaction\n */\n req: PayloadRequest\n}\n"],"names":[],"mappings":"AAiOA,WA8BC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/drizzle",
3
- "version": "3.5.1-canary.e5c20f4",
3
+ "version": "3.6.0",
4
4
  "description": "A library of shared functions used by different payload database adapters",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -52,11 +52,11 @@
52
52
  "@libsql/client": "0.14.0",
53
53
  "@types/pg": "8.10.2",
54
54
  "@types/to-snake-case": "1.0.0",
55
- "@payloadcms/eslint-config": "3.0.0",
56
- "payload": "3.5.1-canary.e5c20f4"
55
+ "payload": "3.6.0",
56
+ "@payloadcms/eslint-config": "3.0.0"
57
57
  },
58
58
  "peerDependencies": {
59
- "payload": "3.5.1-canary.e5c20f4"
59
+ "payload": "3.6.0"
60
60
  },
61
61
  "scripts": {
62
62
  "build": "pnpm build:swc && pnpm build:types",