@payloadcms/drizzle 3.42.0-internal.f9d0258 → 3.42.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.
@@ -1 +1 @@
1
- {"version":3,"file":"deleteVersions.d.ts","sourceRoot":"","sources":["../src/deleteVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAA6B,MAAM,SAAS,CAAA;AAWxE,eAAO,MAAM,cAAc,EAAE,cAyC5B,CAAA"}
1
+ {"version":3,"file":"deleteVersions.d.ts","sourceRoot":"","sources":["../src/deleteVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAA6C,MAAM,SAAS,CAAA;AAWxF,eAAO,MAAM,cAAc,EAAE,cAoD5B,CAAA"}
@@ -1,13 +1,23 @@
1
1
  import { inArray } from 'drizzle-orm';
2
- import { buildVersionCollectionFields } from 'payload';
2
+ import { APIError, buildVersionCollectionFields, buildVersionGlobalFields } from 'payload';
3
3
  import toSnakeCase from 'to-snake-case';
4
4
  import { findMany } from './find/findMany.js';
5
5
  import { getTransaction } from './utilities/getTransaction.js';
6
- export const deleteVersions = async function deleteVersion({ collection, locale, req, where: where }) {
6
+ export const deleteVersions = async function deleteVersion({ collection: collectionSlug, globalSlug, locale, req, where: where }) {
7
7
  const db = await getTransaction(this, req);
8
- const collectionConfig = this.payload.collections[collection].config;
9
- const tableName = this.tableNameMap.get(`_${toSnakeCase(collectionConfig.slug)}${this.versionsSuffix}`);
10
- const fields = buildVersionCollectionFields(this.payload.config, collectionConfig, true);
8
+ let tableName;
9
+ let fields;
10
+ if (globalSlug) {
11
+ const globalConfig = this.payload.globals.config.find(({ slug })=>slug === globalSlug);
12
+ tableName = this.tableNameMap.get(`_${toSnakeCase(globalSlug)}${this.versionsSuffix}`);
13
+ fields = buildVersionGlobalFields(this.payload.config, globalConfig, true);
14
+ } else if (collectionSlug) {
15
+ const collectionConfig = this.payload.collections[collectionSlug].config;
16
+ tableName = this.tableNameMap.get(`_${toSnakeCase(collectionConfig.slug)}${this.versionsSuffix}`);
17
+ fields = buildVersionCollectionFields(this.payload.config, collectionConfig, true);
18
+ } else {
19
+ throw new APIError('Either collection or globalSlug must be passed.');
20
+ }
11
21
  const { docs } = await findMany({
12
22
  adapter: this,
13
23
  fields,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/deleteVersions.ts"],"sourcesContent":["import type { DeleteVersions, SanitizedCollectionConfig } from 'payload'\n\nimport { inArray } from 'drizzle-orm'\nimport { buildVersionCollectionFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport const deleteVersions: DeleteVersions = async function deleteVersion(\n this: DrizzleAdapter,\n { collection, locale, req, where: where },\n) {\n const db = await getTransaction(this, req)\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n\n const tableName = this.tableNameMap.get(\n `_${toSnakeCase(collectionConfig.slug)}${this.versionsSuffix}`,\n )\n\n const fields = buildVersionCollectionFields(this.payload.config, collectionConfig, true)\n\n const { docs } = await findMany({\n adapter: this,\n fields,\n joins: false,\n limit: 0,\n locale,\n page: 1,\n pagination: false,\n req,\n tableName,\n where,\n })\n\n const ids = []\n\n docs.forEach((doc) => {\n ids.push(doc.id)\n })\n\n if (ids.length > 0) {\n await this.deleteWhere({\n db,\n tableName,\n where: inArray(this.tables[tableName].id, ids),\n })\n }\n\n return docs\n}\n"],"names":["inArray","buildVersionCollectionFields","toSnakeCase","findMany","getTransaction","deleteVersions","deleteVersion","collection","locale","req","where","db","collectionConfig","payload","collections","config","tableName","tableNameMap","get","slug","versionsSuffix","fields","docs","adapter","joins","limit","page","pagination","ids","forEach","doc","push","id","length","deleteWhere","tables"],"mappings":"AAEA,SAASA,OAAO,QAAQ,cAAa;AACrC,SAASC,4BAA4B,QAAQ,UAAS;AACtD,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,cAAc,QAAQ,gCAA+B;AAE9D,OAAO,MAAMC,iBAAiC,eAAeC,cAE3D,EAAEC,UAAU,EAAEC,MAAM,EAAEC,GAAG,EAAEC,OAAOA,KAAK,EAAE;IAEzC,MAAMC,KAAK,MAAMP,eAAe,IAAI,EAAEK;IACtC,MAAMG,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACP,WAAW,CAACQ,MAAM;IAE/F,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CACrC,CAAC,CAAC,EAAEhB,YAAYU,iBAAiBO,IAAI,IAAI,IAAI,CAACC,cAAc,EAAE;IAGhE,MAAMC,SAASpB,6BAA6B,IAAI,CAACY,OAAO,CAACE,MAAM,EAAEH,kBAAkB;IAEnF,MAAM,EAAEU,IAAI,EAAE,GAAG,MAAMnB,SAAS;QAC9BoB,SAAS,IAAI;QACbF;QACAG,OAAO;QACPC,OAAO;QACPjB;QACAkB,MAAM;QACNC,YAAY;QACZlB;QACAO;QACAN;IACF;IAEA,MAAMkB,MAAM,EAAE;IAEdN,KAAKO,OAAO,CAAC,CAACC;QACZF,IAAIG,IAAI,CAACD,IAAIE,EAAE;IACjB;IAEA,IAAIJ,IAAIK,MAAM,GAAG,GAAG;QAClB,MAAM,IAAI,CAACC,WAAW,CAAC;YACrBvB;YACAK;YACAN,OAAOV,QAAQ,IAAI,CAACmC,MAAM,CAACnB,UAAU,CAACgB,EAAE,EAAEJ;QAC5C;IACF;IAEA,OAAON;AACT,EAAC"}
1
+ {"version":3,"sources":["../src/deleteVersions.ts"],"sourcesContent":["import type { DeleteVersions, FlattenedField, SanitizedCollectionConfig } from 'payload'\n\nimport { inArray } from 'drizzle-orm'\nimport { APIError, buildVersionCollectionFields, buildVersionGlobalFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport const deleteVersions: DeleteVersions = async function deleteVersion(\n this: DrizzleAdapter,\n { collection: collectionSlug, globalSlug, locale, req, where: where },\n) {\n const db = await getTransaction(this, req)\n\n let tableName: string\n let fields: FlattenedField[]\n\n if (globalSlug) {\n const globalConfig = this.payload.globals.config.find(({ slug }) => slug === globalSlug)\n tableName = this.tableNameMap.get(`_${toSnakeCase(globalSlug)}${this.versionsSuffix}`)\n fields = buildVersionGlobalFields(this.payload.config, globalConfig, true)\n } else if (collectionSlug) {\n const collectionConfig: SanitizedCollectionConfig =\n this.payload.collections[collectionSlug].config\n tableName = this.tableNameMap.get(\n `_${toSnakeCase(collectionConfig.slug)}${this.versionsSuffix}`,\n )\n fields = buildVersionCollectionFields(this.payload.config, collectionConfig, true)\n } else {\n throw new APIError('Either collection or globalSlug must be passed.')\n }\n\n const { docs } = await findMany({\n adapter: this,\n fields,\n joins: false,\n limit: 0,\n locale,\n page: 1,\n pagination: false,\n req,\n tableName,\n where,\n })\n\n const ids = []\n\n docs.forEach((doc) => {\n ids.push(doc.id)\n })\n\n if (ids.length > 0) {\n await this.deleteWhere({\n db,\n tableName,\n where: inArray(this.tables[tableName].id, ids),\n })\n }\n\n return docs\n}\n"],"names":["inArray","APIError","buildVersionCollectionFields","buildVersionGlobalFields","toSnakeCase","findMany","getTransaction","deleteVersions","deleteVersion","collection","collectionSlug","globalSlug","locale","req","where","db","tableName","fields","globalConfig","payload","globals","config","find","slug","tableNameMap","get","versionsSuffix","collectionConfig","collections","docs","adapter","joins","limit","page","pagination","ids","forEach","doc","push","id","length","deleteWhere","tables"],"mappings":"AAEA,SAASA,OAAO,QAAQ,cAAa;AACrC,SAASC,QAAQ,EAAEC,4BAA4B,EAAEC,wBAAwB,QAAQ,UAAS;AAC1F,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,cAAc,QAAQ,gCAA+B;AAE9D,OAAO,MAAMC,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AM,CAAC1B,UAAU,CAACuB,EAAE,EAAEJ;QAC5C;IACF;IAEA,OAAON;AACT,EAAC"}
@@ -111,7 +111,6 @@ export type BasePostgresAdapter = {
111
111
  up: (args: MigrateUpArgs) => Promise<void>;
112
112
  }[];
113
113
  push: boolean;
114
- readReplicaOptions?: string[];
115
114
  rejectInitializing: () => void;
116
115
  relations: Record<string, GenericRelation>;
117
116
  relationshipsSuffix?: string;
@@ -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,WAA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CAAA;KACF,CAAA;IACD,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IACpC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,CAAA;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 readReplicaOptions?: string[]\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":"AAkOA,WA8BC"}
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.42.0-internal.f9d0258",
3
+ "version": "3.42.0",
4
4
  "description": "A library of shared functions used by different payload database adapters",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -54,11 +54,11 @@
54
54
  "@libsql/client": "0.14.0",
55
55
  "@types/pg": "8.10.2",
56
56
  "@types/to-snake-case": "1.0.0",
57
- "payload": "3.42.0-internal.f9d0258",
58
- "@payloadcms/eslint-config": "3.28.0"
57
+ "@payloadcms/eslint-config": "3.28.0",
58
+ "payload": "3.42.0"
59
59
  },
60
60
  "peerDependencies": {
61
- "payload": "3.42.0-internal.f9d0258"
61
+ "payload": "3.42.0"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "pnpm build:swc && pnpm build:types",