@payloadcms/db-postgres 3.0.0-canary.c27a334 → 3.0.0-canary.ce278e4
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/dist/connect.d.ts +1 -1
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js.map +1 -1
- package/dist/count.d.ts +1 -1
- package/dist/count.d.ts.map +1 -1
- package/dist/count.js.map +1 -1
- package/dist/create.d.ts +1 -1
- package/dist/create.d.ts.map +1 -1
- package/dist/create.js.map +1 -1
- package/dist/createGlobal.d.ts +1 -2
- package/dist/createGlobal.d.ts.map +1 -1
- package/dist/createGlobal.js.map +1 -1
- package/dist/createGlobalVersion.d.ts +2 -3
- package/dist/createGlobalVersion.d.ts.map +1 -1
- package/dist/createGlobalVersion.js +1 -1
- package/dist/createGlobalVersion.js.map +1 -1
- package/dist/createMigration.d.ts +1 -1
- package/dist/createMigration.d.ts.map +1 -1
- package/dist/createMigration.js +3 -3
- package/dist/createMigration.js.map +1 -1
- package/dist/createVersion.d.ts +1 -2
- package/dist/createVersion.d.ts.map +1 -1
- package/dist/createVersion.js +1 -1
- package/dist/createVersion.js.map +1 -1
- package/dist/deleteMany.d.ts +1 -1
- package/dist/deleteMany.d.ts.map +1 -1
- package/dist/deleteMany.js.map +1 -1
- package/dist/deleteOne.d.ts +1 -1
- package/dist/deleteOne.d.ts.map +1 -1
- package/dist/deleteOne.js.map +1 -1
- package/dist/deleteVersions.d.ts +1 -1
- package/dist/deleteVersions.d.ts.map +1 -1
- package/dist/deleteVersions.js +1 -1
- package/dist/deleteVersions.js.map +1 -1
- package/dist/destroy.d.ts +1 -1
- package/dist/destroy.d.ts.map +1 -1
- package/dist/destroy.js.map +1 -1
- package/dist/find/buildFindManyArgs.d.ts +1 -1
- package/dist/find/buildFindManyArgs.d.ts.map +1 -1
- package/dist/find/buildFindManyArgs.js.map +1 -1
- package/dist/find/findMany.d.ts +1 -2
- package/dist/find/findMany.d.ts.map +1 -1
- package/dist/find/findMany.js.map +1 -1
- package/dist/find/traverseFields.d.ts +1 -1
- package/dist/find/traverseFields.d.ts.map +1 -1
- package/dist/find/traverseFields.js +1 -1
- package/dist/find/traverseFields.js.map +1 -1
- package/dist/find.d.ts +1 -1
- package/dist/find.d.ts.map +1 -1
- package/dist/find.js.map +1 -1
- package/dist/findGlobal.d.ts +1 -1
- package/dist/findGlobal.d.ts.map +1 -1
- package/dist/findGlobal.js.map +1 -1
- package/dist/findGlobalVersions.d.ts +1 -1
- package/dist/findGlobalVersions.d.ts.map +1 -1
- package/dist/findGlobalVersions.js +1 -1
- package/dist/findGlobalVersions.js.map +1 -1
- package/dist/findOne.d.ts +1 -2
- package/dist/findOne.d.ts.map +1 -1
- package/dist/findOne.js.map +1 -1
- package/dist/findVersions.d.ts +1 -1
- package/dist/findVersions.d.ts.map +1 -1
- package/dist/findVersions.js +1 -1
- package/dist/findVersions.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +1 -1
- package/dist/init.js.map +1 -1
- package/dist/migrate.d.ts.map +1 -1
- package/dist/migrate.js +1 -1
- package/dist/migrate.js.map +1 -1
- package/dist/migrateDown.js +1 -1
- package/dist/migrateDown.js.map +1 -1
- package/dist/migrateFresh.d.ts.map +1 -1
- package/dist/migrateFresh.js +1 -1
- package/dist/migrateFresh.js.map +1 -1
- package/dist/migrateRefresh.js +1 -1
- package/dist/migrateRefresh.js.map +1 -1
- package/dist/migrateReset.js +1 -1
- package/dist/migrateReset.js.map +1 -1
- package/dist/migrateStatus.js +1 -1
- package/dist/migrateStatus.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +1 -2
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts +1 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +1 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/index.d.ts +1 -2
- package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/index.js +5 -5
- package/dist/predefinedMigrations/v2-v3/index.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +1 -1
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +1 -2
- package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/traverseFields.js +1 -1
- package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -1
- package/dist/queries/buildAndOrConditions.d.ts +1 -1
- package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
- package/dist/queries/buildAndOrConditions.js.map +1 -1
- package/dist/queries/buildQuery.d.ts +1 -1
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/buildQuery.js.map +1 -1
- package/dist/queries/getTableColumnFromPath.d.ts +1 -1
- package/dist/queries/getTableColumnFromPath.d.ts.map +1 -1
- package/dist/queries/getTableColumnFromPath.js +2 -3
- package/dist/queries/getTableColumnFromPath.js.map +1 -1
- package/dist/queries/parseParams.d.ts +1 -1
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +2 -2
- package/dist/queries/parseParams.js.map +1 -1
- package/dist/queries/sanitizeQueryValue.d.ts +1 -1
- package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
- package/dist/queries/sanitizeQueryValue.js +2 -3
- package/dist/queries/sanitizeQueryValue.js.map +1 -1
- package/dist/queryDrafts.d.ts +1 -1
- package/dist/queryDrafts.d.ts.map +1 -1
- package/dist/queryDrafts.js +1 -2
- package/dist/queryDrafts.js.map +1 -1
- package/dist/schema/build.d.ts +1 -1
- package/dist/schema/build.d.ts.map +1 -1
- package/dist/schema/build.js.map +1 -1
- package/dist/schema/createTableName.d.ts +1 -1
- package/dist/schema/createTableName.d.ts.map +1 -1
- package/dist/schema/createTableName.js +1 -1
- package/dist/schema/createTableName.js.map +1 -1
- package/dist/schema/idToUUID.d.ts +1 -1
- package/dist/schema/idToUUID.d.ts.map +1 -1
- package/dist/schema/idToUUID.js.map +1 -1
- package/dist/schema/setColumnID.d.ts +1 -1
- package/dist/schema/setColumnID.d.ts.map +1 -1
- package/dist/schema/setColumnID.js +2 -2
- package/dist/schema/setColumnID.js.map +1 -1
- package/dist/schema/traverseFields.d.ts +1 -1
- package/dist/schema/traverseFields.d.ts.map +1 -1
- package/dist/schema/traverseFields.js +2 -2
- package/dist/schema/traverseFields.js.map +1 -1
- package/dist/schema/validateExistingBlockIsIdentical.d.ts +1 -1
- package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +1 -1
- package/dist/schema/validateExistingBlockIsIdentical.js +2 -2
- package/dist/schema/validateExistingBlockIsIdentical.js.map +1 -1
- package/dist/transactions/beginTransaction.d.ts +1 -1
- package/dist/transactions/beginTransaction.d.ts.map +1 -1
- package/dist/transactions/beginTransaction.js.map +1 -1
- package/dist/transactions/commitTransaction.d.ts +1 -1
- package/dist/transactions/commitTransaction.d.ts.map +1 -1
- package/dist/transactions/commitTransaction.js.map +1 -1
- package/dist/transactions/rollbackTransaction.d.ts +1 -1
- package/dist/transactions/rollbackTransaction.d.ts.map +1 -1
- package/dist/transactions/rollbackTransaction.js.map +1 -1
- package/dist/transform/read/hasManyNumber.d.ts +1 -1
- package/dist/transform/read/hasManyNumber.d.ts.map +1 -1
- package/dist/transform/read/hasManyNumber.js.map +1 -1
- package/dist/transform/read/hasManyText.d.ts +1 -1
- package/dist/transform/read/hasManyText.d.ts.map +1 -1
- package/dist/transform/read/hasManyText.js.map +1 -1
- package/dist/transform/read/index.d.ts +2 -2
- package/dist/transform/read/index.d.ts.map +1 -1
- package/dist/transform/read/index.js.map +1 -1
- package/dist/transform/read/relationship.d.ts +1 -1
- package/dist/transform/read/relationship.d.ts.map +1 -1
- package/dist/transform/read/relationship.js.map +1 -1
- package/dist/transform/read/traverseFields.d.ts +2 -2
- package/dist/transform/read/traverseFields.d.ts.map +1 -1
- package/dist/transform/read/traverseFields.js +1 -1
- package/dist/transform/read/traverseFields.js.map +1 -1
- package/dist/transform/write/array.d.ts +1 -1
- package/dist/transform/write/array.d.ts.map +1 -1
- package/dist/transform/write/array.js.map +1 -1
- package/dist/transform/write/blocks.d.ts +1 -1
- package/dist/transform/write/blocks.d.ts.map +1 -1
- package/dist/transform/write/blocks.js.map +1 -1
- package/dist/transform/write/index.d.ts +1 -1
- package/dist/transform/write/index.d.ts.map +1 -1
- package/dist/transform/write/index.js.map +1 -1
- package/dist/transform/write/relationships.d.ts +1 -1
- package/dist/transform/write/relationships.d.ts.map +1 -1
- package/dist/transform/write/relationships.js +1 -1
- package/dist/transform/write/relationships.js.map +1 -1
- package/dist/transform/write/traverseFields.d.ts +1 -1
- package/dist/transform/write/traverseFields.d.ts.map +1 -1
- package/dist/transform/write/traverseFields.js +1 -1
- package/dist/transform/write/traverseFields.js.map +1 -1
- package/dist/types.d.ts +1 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/update.d.ts +1 -1
- package/dist/update.d.ts.map +1 -1
- package/dist/update.js.map +1 -1
- package/dist/updateGlobal.d.ts +1 -2
- package/dist/updateGlobal.d.ts.map +1 -1
- package/dist/updateGlobal.js.map +1 -1
- package/dist/updateGlobalVersion.d.ts +1 -2
- package/dist/updateGlobalVersion.d.ts.map +1 -1
- package/dist/updateGlobalVersion.js +1 -1
- package/dist/updateGlobalVersion.js.map +1 -1
- package/dist/updateVersion.d.ts +1 -2
- package/dist/updateVersion.d.ts.map +1 -1
- package/dist/updateVersion.js +1 -1
- package/dist/updateVersion.js.map +1 -1
- package/dist/upsertRow/index.d.ts +1 -1
- package/dist/upsertRow/index.d.ts.map +1 -1
- package/dist/upsertRow/index.js +1 -1
- package/dist/upsertRow/index.js.map +1 -1
- package/dist/upsertRow/types.d.ts +1 -1
- package/dist/upsertRow/types.d.ts.map +1 -1
- package/dist/upsertRow/types.js.map +1 -1
- package/dist/utilities/hasLocalesTable.d.ts +1 -1
- package/dist/utilities/hasLocalesTable.d.ts.map +1 -1
- package/dist/utilities/hasLocalesTable.js +1 -1
- package/dist/utilities/hasLocalesTable.js.map +1 -1
- package/dist/utilities/pushDevSchema.d.ts.map +1 -1
- package/dist/utilities/pushDevSchema.js +1 -1
- package/dist/utilities/pushDevSchema.js.map +1 -1
- package/package.json +9 -6
package/README.md
CHANGED
package/dist/connect.d.ts
CHANGED
package/dist/connect.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAW,MAAM,SAAS,CAAA;AA+C/C,eAAO,MAAM,OAAO,EAAE,OAmDrB,CAAA"}
|
package/dist/connect.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { Payload } from 'payload'\
|
1
|
+
{"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { Connect, Payload } from 'payload'\n\nimport { sql } from 'drizzle-orm'\nimport { drizzle } from 'drizzle-orm/node-postgres'\nimport pg from 'pg'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { pushDevSchema } from './utilities/pushDevSchema.js'\n\nconst connectWithReconnect = async function ({\n adapter,\n payload,\n reconnect = false,\n}: {\n adapter: PostgresAdapter\n payload: Payload\n reconnect?: boolean\n}) {\n let result\n\n if (!reconnect) {\n result = await adapter.pool.connect()\n } else {\n try {\n result = await adapter.pool.connect()\n } catch (err) {\n setTimeout(() => {\n payload.logger.info('Reconnecting to postgres')\n void connectWithReconnect({ adapter, payload, 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, payload, reconnect: true })\n }\n } catch (err) {\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 this.schema = {\n ...this.tables,\n ...this.relations,\n ...this.enums,\n }\n\n try {\n if (!this.pool) {\n this.pool = new pg.Pool(this.poolOptions)\n await connectWithReconnect({ adapter: this, payload: this.payload })\n }\n\n const logger = this.logger || false\n this.drizzle = drizzle(this.pool, { logger, schema: this.schema })\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.drizzle.execute(\n sql.raw(`\n drop schema if exists ${this.schemaName || 'public'} cascade;\n create schema ${this.schemaName || 'public'};\n `),\n )\n this.payload.logger.info('---- DROPPED TABLES ----')\n }\n }\n } catch (err) {\n this.payload.logger.error(`Error: cannot connect to Postgres. Details: ${err.message}`, err)\n if (typeof this.rejectInitializing === 'function') this.rejectInitializing()\n process.exit(1)\n }\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)\n }\n\n if (typeof this.resolveInitializing === 'function') this.resolveInitializing()\n}\n"],"names":["sql","drizzle","pg","pushDevSchema","connectWithReconnect","adapter","payload","reconnect","result","pool","connect","err","setTimeout","logger","info","prependListener","code","options","hotReload","schema","tables","relations","enums","Pool","poolOptions","process","env","PAYLOAD_DROP_DATABASE","schemaName","execute","raw","error","message","rejectInitializing","exit","NODE_ENV","PAYLOAD_MIGRATING","push","resolveInitializing"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,GAAG,QAAQ,cAAa;AACjC,SAASC,OAAO,QAAQ,4BAA2B;AACnD,OAAOC,QAAQ,KAAI;AAInB,SAASC,aAAa,QAAQ,+BAA8B;AAE5D,MAAMC,uBAAuB,eAAgB,EAC3CC,OAAO,EACPC,OAAO,EACPC,YAAY,KAAK,EAKlB;IACC,IAAIC;IAEJ,IAAI,CAACD,WAAW;QACdC,SAAS,MAAMH,QAAQI,IAAI,CAACC,OAAO;IACrC,OAAO;QACL,IAAI;YACFF,SAAS,MAAMH,QAAQI,IAAI,CAACC,OAAO;QACrC,EAAE,OAAOC,KAAK;YACZC,WAAW;gBACTN,QAAQO,MAAM,CAACC,IAAI,CAAC;gBACpB,KAAKV,qBAAqB;oBAAEC;oBAASC;oBAASC,WAAW;gBAAK;YAChE,GAAG;QACL;IACF;IACA,IAAI,CAACC,QAAQ;QACX;IACF;IACAA,OAAOO,eAAe,CAAC,SAAS,CAACJ;QAC/B,IAAI;YACF,IAAIA,IAAIK,IAAI,KAAK,cAAc;gBAC7B,KAAKZ,qBAAqB;oBAAEC;oBAASC;oBAASC,WAAW;gBAAK;YAChE;QACF,EAAE,OAAOI,KAAK;QACZ,gBAAgB;QAClB;IACF;AACF;AAEA,OAAO,MAAMD,UAAmB,eAAeA,QAE7CO,UAAU;IACRC,WAAW;AACb,CAAC;IAED,MAAM,EAAEA,SAAS,EAAE,GAAGD;IAEtB,IAAI,CAACE,MAAM,GAAG;QACZ,GAAG,IAAI,CAACC,MAAM;QACd,GAAG,IAAI,CAACC,SAAS;QACjB,GAAG,IAAI,CAACC,KAAK;IACf;IAEA,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OAAO,IAAI,CAACmC,mBAAmB,KAAK,YAAY,IAAI,CAACA,mBAAmB;AAC9E,EAAC"}
|
package/dist/count.d.ts
CHANGED
package/dist/count.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"count.d.ts","sourceRoot":"","sources":["../src/count.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,
|
1
|
+
{"version":3,"file":"count.d.ts","sourceRoot":"","sources":["../src/count.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAA6B,MAAM,SAAS,CAAA;AAW/D,eAAO,MAAM,KAAK,EAAE,KA0CnB,CAAA"}
|
package/dist/count.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/count.ts"],"sourcesContent":["import type { Count
|
1
|
+
{"version":3,"sources":["../src/count.ts"],"sourcesContent":["import type { Count, SanitizedCollectionConfig } from 'payload'\n\nimport { sql } from 'drizzle-orm'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { ChainedMethods } from './find/chainMethods.js'\nimport type { PostgresAdapter } from './types.js'\n\nimport { chainMethods } from './find/chainMethods.js'\nimport buildQuery from './queries/buildQuery.js'\n\nexport const count: Count = async function count(\n this: PostgresAdapter,\n { collection, locale, req, where: whereArg },\n) {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n\n const tableName = this.tableNameMap.get(toSnakeCase(collectionConfig.slug))\n\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const table = this.tables[tableName]\n\n const { joins, where } = await buildQuery({\n adapter: this,\n fields: collectionConfig.fields,\n locale,\n tableName,\n where: whereArg,\n })\n\n const selectCountMethods: ChainedMethods = []\n\n Object.entries(joins).forEach(([joinTable, condition]) => {\n if (joinTable) {\n selectCountMethods.push({\n args: [this.tables[joinTable], condition],\n method: 'leftJoin',\n })\n }\n })\n\n const countResult = await chainMethods({\n methods: selectCountMethods,\n query: db\n .select({\n count: sql<number>`count\n (DISTINCT ${this.tables[tableName].id})`,\n })\n .from(table)\n .where(where),\n })\n\n return { totalDocs: Number(countResult[0].count) }\n}\n"],"names":["sql","toSnakeCase","chainMethods","buildQuery","count","collection","locale","req","where","whereArg","collectionConfig","payload","collections","config","tableName","tableNameMap","get","slug","db","sessions","transactionID","drizzle","table","tables","joins","adapter","fields","selectCountMethods","Object","entries","forEach","joinTable","condition","push","args","method","countResult","methods","query","select","id","from","totalDocs","Number"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,GAAG,QAAQ,cAAa;AACjC,OAAOC,iBAAiB,gBAAe;AAKvC,SAASC,YAAY,QAAQ,yBAAwB;AACrD,OAAOC,gBAAgB,0BAAyB;AAEhD,OAAO,MAAMC,QAAe,eAAeA,MAEzC,EAAEC,UAAU,EAAEC,MAAM,EAAEC,GAAG,EAAEC,OAAOC,QAAQ,EAAE;IAE5C,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACP,WAAW,CAACQ,MAAM;IAE/F,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAACf,YAAYS,iBAAiBO,IAAI;IAEzE,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACZ,IAAIa,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,QAAQ,IAAI,CAACC,MAAM,CAACT,UAAU;IAEpC,MAAM,EAAEU,KAAK,EAAEhB,KAAK,EAAE,GAAG,MAAML,WAAW;QACxCsB,SAAS,IAAI;QACbC,QAAQhB,iBAAiBgB,MAAM;QAC/BpB;QACAQ;QACAN,OAAOC;IACT;IAEA,MAAMkB,qBAAqC,EAAE;IAE7CC,OAAOC,OAAO,CAACL,OAAOM,OAAO,CAAC,CAAC,CAACC,WAAWC,UAAU;QACnD,IAAID,WAAW;YACbJ,mBAAmBM,IAAI,CAAC;gBACtBC,MAAM;oBAAC,IAAI,CAACX,MAAM,CAACQ,UAAU;oBAAEC;iBAAU;gBACzCG,QAAQ;YACV;QACF;IACF;IAEA,MAAMC,cAAc,MAAMlC,aAAa;QACrCmC,SAASV;QACTW,OAAOpB,GACJqB,MAAM,CAAC;YACNnC,OAAOJ,GAAW,CAAC;sBACL,EAAE,IAAI,CAACuB,MAAM,CAACT,UAAU,CAAC0B,EAAE,CAAC,CAAC,CAAC;QAC9C,GACCC,IAAI,CAACnB,OACLd,KAAK,CAACA;IACX;IAEA,OAAO;QAAEkC,WAAWC,OAAOP,WAAW,CAAC,EAAE,CAAChC,KAAK;IAAE;AACnD,EAAC"}
|
package/dist/create.d.ts
CHANGED
package/dist/create.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAQrC,eAAO,MAAM,MAAM,EAAE,MAoBpB,CAAA"}
|
package/dist/create.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/create.ts"],"sourcesContent":["import type { Create } from 'payload
|
1
|
+
{"version":3,"sources":["../src/create.ts"],"sourcesContent":["import type { Create } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\n\nexport const create: Create = async function create(\n this: PostgresAdapter,\n { collection: collectionSlug, data, req },\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collection = this.payload.collections[collectionSlug].config\n\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n\n const result = await upsertRow({\n adapter: this,\n data,\n db,\n fields: collection.fields,\n operation: 'create',\n req,\n tableName,\n })\n\n return result\n}\n"],"names":["toSnakeCase","upsertRow","create","collection","collectionSlug","data","req","db","sessions","transactionID","drizzle","payload","collections","config","tableName","tableNameMap","get","slug","result","adapter","fields","operation"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,MAAMC,SAAiB,eAAeA,OAE3C,EAAEC,YAAYC,cAAc,EAAEC,IAAI,EAAEC,GAAG,EAAE;IAEzC,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACF,IAAIG,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMP,aAAa,IAAI,CAACQ,OAAO,CAACC,WAAW,CAACR,eAAe,CAACS,MAAM;IAElE,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAAChB,YAAYG,WAAWc,IAAI;IAEnE,MAAMC,SAAS,MAAMjB,UAAU;QAC7BkB,SAAS,IAAI;QACbd;QACAE;QACAa,QAAQjB,WAAWiB,MAAM;QACzBC,WAAW;QACXf;QACAQ;IACF;IAEA,OAAOI;AACT,EAAC"}
|
package/dist/createGlobal.d.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
import type { CreateGlobalArgs } from 'payload
|
2
|
-
import type { TypeWithID } from 'payload/types';
|
1
|
+
import type { CreateGlobalArgs, TypeWithID } from 'payload';
|
3
2
|
import type { PostgresAdapter } from './types.js';
|
4
3
|
export declare function createGlobal<T extends TypeWithID>(this: PostgresAdapter, { slug, data, req }: CreateGlobalArgs): Promise<T>;
|
5
4
|
//# sourceMappingURL=createGlobal.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createGlobal.d.ts","sourceRoot":"","sources":["../src/createGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,
|
1
|
+
{"version":3,"file":"createGlobal.d.ts","sourceRoot":"","sources":["../src/createGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAA0B,UAAU,EAAE,MAAM,SAAS,CAAA;AAInF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIjD,wBAAsB,YAAY,CAAC,CAAC,SAAS,UAAU,EACrD,IAAI,EAAE,eAAe,EACrB,EAAE,IAAI,EAAE,IAAI,EAAE,GAAkC,EAAE,EAAE,gBAAgB,GACnE,OAAO,CAAC,CAAC,CAAC,CAiBZ"}
|
package/dist/createGlobal.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/createGlobal.ts"],"sourcesContent":["import type { CreateGlobalArgs
|
1
|
+
{"version":3,"sources":["../src/createGlobal.ts"],"sourcesContent":["import type { CreateGlobalArgs, PayloadRequestWithData, TypeWithID } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function createGlobal<T extends TypeWithID>(\n this: PostgresAdapter,\n { slug, data, req = {} as PayloadRequestWithData }: CreateGlobalArgs,\n): Promise<T> {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const globalConfig = this.payload.globals.config.find((config) => config.slug === slug)\n\n const tableName = this.tableNameMap.get(toSnakeCase(globalConfig.slug))\n\n const result = await upsertRow<T>({\n adapter: this,\n data,\n db,\n fields: globalConfig.fields,\n operation: 'create',\n req,\n tableName,\n })\n\n return result\n}\n"],"names":["toSnakeCase","upsertRow","createGlobal","slug","data","req","db","sessions","transactionID","drizzle","globalConfig","payload","globals","config","find","tableName","tableNameMap","get","result","adapter","fields","operation"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,eAAeC,aAEpB,EAAEC,IAAI,EAAEC,IAAI,EAAEC,MAAM,CAAC,CAA2B,EAAoB;IAEpE,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACF,IAAIG,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,eAAe,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOV,IAAI,KAAKA;IAElF,MAAMY,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAACjB,YAAYU,aAAaP,IAAI;IAErE,MAAMe,SAAS,MAAMjB,UAAa;QAChCkB,SAAS,IAAI;QACbf;QACAE;QACAc,QAAQV,aAAaU,MAAM;QAC3BC,WAAW;QACXhB;QACAU;IACF;IAEA,OAAOG;AACT"}
|
@@ -1,6 +1,5 @@
|
|
1
|
-
import type { TypeWithVersion } from 'payload
|
2
|
-
import type
|
3
|
-
import { type CreateGlobalVersionArgs } from 'payload/database';
|
1
|
+
import type { TypeWithID, TypeWithVersion } from 'payload';
|
2
|
+
import { type CreateGlobalVersionArgs } from 'payload';
|
4
3
|
import type { PostgresAdapter } from './types.js';
|
5
4
|
export declare function createGlobalVersion<T extends TypeWithID>(this: PostgresAdapter, { autosave, globalSlug, req, versionData, }: CreateGlobalVersionArgs): Promise<TypeWithVersion<T>>;
|
6
5
|
//# sourceMappingURL=createGlobalVersion.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createGlobalVersion.d.ts","sourceRoot":"","sources":["../src/createGlobalVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
1
|
+
{"version":3,"file":"createGlobalVersion.d.ts","sourceRoot":"","sources":["../src/createGlobalVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA0B,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAGlF,OAAO,EAAE,KAAK,uBAAuB,EAA4B,MAAM,SAAS,CAAA;AAGhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIjD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAC5D,IAAI,EAAE,eAAe,EACrB,EACE,QAAQ,EACR,UAAU,EACV,GAAkC,EAClC,WAAW,GACZ,EAAE,uBAAuB,+BAgC3B"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { sql } from 'drizzle-orm';
|
2
|
-
import { buildVersionGlobalFields } from 'payload
|
2
|
+
import { buildVersionGlobalFields } from 'payload';
|
3
3
|
import toSnakeCase from 'to-snake-case';
|
4
4
|
import { upsertRow } from './upsertRow/index.js';
|
5
5
|
export async function createGlobalVersion({ autosave, globalSlug, req = {}, versionData }) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/createGlobalVersion.ts"],"sourcesContent":["import type {
|
1
|
+
{"version":3,"sources":["../src/createGlobalVersion.ts"],"sourcesContent":["import type { PayloadRequestWithData, TypeWithID, TypeWithVersion } from 'payload'\n\nimport { sql } from 'drizzle-orm'\nimport { type CreateGlobalVersionArgs, buildVersionGlobalFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function createGlobalVersion<T extends TypeWithID>(\n this: PostgresAdapter,\n {\n autosave,\n globalSlug,\n req = {} as PayloadRequestWithData,\n versionData,\n }: CreateGlobalVersionArgs,\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const global = this.payload.globals.config.find(({ slug }) => slug === globalSlug)\n\n const tableName = this.tableNameMap.get(`_${toSnakeCase(global.slug)}${this.versionsSuffix}`)\n\n const result = await upsertRow<TypeWithVersion<T>>({\n adapter: this,\n data: {\n autosave,\n latest: true,\n version: versionData,\n },\n db,\n fields: buildVersionGlobalFields(global),\n operation: 'create',\n req,\n tableName,\n })\n\n const table = this.tables[tableName]\n\n if (global.versions.drafts) {\n await db.execute(sql`\n UPDATE ${table}\n SET latest = false\n WHERE ${table.id} != ${result.id};\n `)\n }\n\n return result\n}\n"],"names":["sql","buildVersionGlobalFields","toSnakeCase","upsertRow","createGlobalVersion","autosave","globalSlug","req","versionData","db","sessions","transactionID","drizzle","global","payload","globals","config","find","slug","tableName","tableNameMap","get","versionsSuffix","result","adapter","data","latest","version","fields","operation","table","tables","versions","drafts","execute","id"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,GAAG,QAAQ,cAAa;AACjC,SAAuCC,wBAAwB,QAAQ,UAAS;AAChF,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,eAAeC,oBAEpB,EACEC,QAAQ,EACRC,UAAU,EACVC,MAAM,CAAC,CAA2B,EAClCC,WAAW,EACa;IAE1B,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACH,IAAII,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,SAAS,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASZ;IAEvE,MAAMa,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAAC,CAAC,CAAC,EAAEnB,YAAYW,OAAOK,IAAI,EAAE,EAAE,IAAI,CAACI,cAAc,CAAC,CAAC;IAE5F,MAAMC,SAAS,MAAMpB,UAA8B;QACjDqB,SAAS,IAAI;QACbC,MAAM;YACJpB;YACAqB,QAAQ;YACRC,SAASnB;QACX;QACAC;QACAmB,QAAQ3B,yBAAyBY;QACjCgB,WAAW;QACXtB;QACAY;IACF;IAEA,MAAMW,QAAQ,IAAI,CAACC,MAAM,CAACZ,UAAU;IAEpC,IAAIN,OAAOmB,QAAQ,CAACC,MAAM,EAAE;QAC1B,MAAMxB,GAAGyB,OAAO,CAAClC,GAAG,CAAC;aACZ,EAAE8B,MAAM;;YAET,EAAEA,MAAMK,EAAE,CAAC,IAAI,EAAEZ,OAAOY,EAAE,CAAC;IACnC,CAAC;IACH;IAEA,OAAOZ;AACT"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createMigration.d.ts","sourceRoot":"","sources":["../src/createMigration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,
|
1
|
+
{"version":3,"file":"createMigration.d.ts","sourceRoot":"","sources":["../src/createMigration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,SAAS,CAAA;AA2CrE,eAAO,MAAM,eAAe,EAAE,eA6F7B,CAAA"}
|
package/dist/createMigration.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* eslint-disable no-restricted-syntax, no-await-in-loop */ import fs from 'fs';
|
2
2
|
import { createRequire } from 'module';
|
3
3
|
import path from 'path';
|
4
|
-
import { getPredefinedMigration } from 'payload
|
4
|
+
import { getPredefinedMigration } from 'payload';
|
5
5
|
import prompts from 'prompts';
|
6
6
|
import { fileURLToPath } from 'url';
|
7
7
|
const require = createRequire(import.meta.url);
|
@@ -85,9 +85,9 @@ export const createMigration = async function createMigration({ file, forceAccep
|
|
85
85
|
process.exit(0);
|
86
86
|
}
|
87
87
|
}
|
88
|
-
// write schema
|
89
|
-
fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2));
|
90
88
|
}
|
89
|
+
// write schema
|
90
|
+
fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2));
|
91
91
|
// write migration
|
92
92
|
fs.writeFileSync(`${filePath}.ts`, migrationTemplate({
|
93
93
|
downSQL: downSQL || ` // Migration code`,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/createMigration.ts"],"sourcesContent":["/* eslint-disable no-restricted-syntax, no-await-in-loop */\nimport type { DrizzleSnapshotJSON } from 'drizzle-kit/payload'\nimport type { CreateMigration, MigrationTemplateArgs } from 'payload
|
1
|
+
{"version":3,"sources":["../src/createMigration.ts"],"sourcesContent":["/* eslint-disable no-restricted-syntax, no-await-in-loop */\nimport type { DrizzleSnapshotJSON } from 'drizzle-kit/payload'\nimport type { CreateMigration, MigrationTemplateArgs } from 'payload'\n\nimport fs from 'fs'\nimport { createRequire } from 'module'\nimport path from 'path'\nimport { getPredefinedMigration } from 'payload'\nimport prompts from 'prompts'\nimport { fileURLToPath } from 'url'\n\nimport type { PostgresAdapter } from './types.js'\n\nconst require = createRequire(import.meta.url)\n\nconst migrationTemplate = ({\n downSQL,\n imports,\n upSQL,\n}: MigrationTemplateArgs): string => `import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'\n${imports ? `${imports}\\n` : ''}\nexport async function up({ payload, req }: MigrateUpArgs): Promise<void> {\n${upSQL}\n};\n\nexport async function down({ payload, req }: MigrateDownArgs): Promise<void> {\n${downSQL}\n};\n`\n\nconst getDefaultDrizzleSnapshot = (): DrizzleSnapshotJSON => ({\n id: '00000000-0000-0000-0000-000000000000',\n _meta: {\n columns: {},\n schemas: {},\n tables: {},\n },\n dialect: 'pg',\n enums: {},\n prevId: '00000000-0000-0000-0000-00000000000',\n schemas: {},\n tables: {},\n version: '5',\n})\n\nexport const createMigration: CreateMigration = async function createMigration(\n this: PostgresAdapter,\n { file, forceAcceptWarning, migrationName, payload },\n) {\n const filename = fileURLToPath(import.meta.url)\n const dirname = path.dirname(filename)\n const dir = payload.db.migrationDir\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir)\n }\n const { generateDrizzleJson, generateMigration } = require('drizzle-kit/payload')\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 = getDefaultDrizzleSnapshot()\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(\n fs.readFileSync(`${dir}/${latestSnapshot}`, 'utf8'),\n ) as DrizzleSnapshotJSON\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 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\n // write schema\n fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2))\n\n // write migration\n fs.writeFileSync(\n `${filePath}.ts`,\n migrationTemplate({\n downSQL: downSQL || ` // Migration code`,\n imports,\n upSQL: upSQL || ` // Migration code`,\n }),\n )\n payload.logger.info({ msg: `Migration created at ${filePath}.ts` })\n}\n"],"names":["fs","createRequire","path","getPredefinedMigration","prompts","fileURLToPath","require","url","migrationTemplate","downSQL","imports","upSQL","getDefaultDrizzleSnapshot","id","_meta","columns","schemas","tables","dialect","enums","prevId","version","createMigration","file","forceAcceptWarning","migrationName","payload","filename","dirname","dir","db","migrationDir","existsSync","mkdirSync","generateDrizzleJson","generateMigration","drizzleJsonAfter","schema","yyymmdd","hhmmss","Date","toISOString","split","formattedDate","replace","formattedTime","timestamp","name","slice","join","fileName","filePath","drizzleJsonBefore","latestSnapshot","readdirSync","filter","endsWith","sort","reverse","JSON","parse","readFileSync","sqlStatementsUp","sqlStatementsDown","sqlExecute","length","confirm","shouldCreateBlankMigration","type","initial","message","onCancel","process","exit","writeFileSync","stringify","logger","info","msg"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,yDAAyD,GAIzD,OAAOA,QAAQ,KAAI;AACnB,SAASC,aAAa,QAAQ,SAAQ;AACtC,OAAOC,UAAU,OAAM;AACvB,SAASC,sBAAsB,QAAQ,UAAS;AAChD,OAAOC,aAAa,UAAS;AAC7B,SAASC,aAAa,QAAQ,MAAK;AAInC,MAAMC,UAAUL,cAAc,YAAYM,GAAG;AAE7C,MAAMC,oBAAoB,CAAC,EACzBC,OAAO,EACPC,OAAO,EACPC,KAAK,EACiB,GAAa,CAAC;AACtC,EAAED,UAAU,CAAC,EAAEA,QAAQ,EAAE,CAAC,GAAG,GAAG;;AAEhC,EAAEC,MAAM;;;;AAIR,EAAEF,QAAQ;;AAEV,CAAC;AAED,MAAMG,4BAA4B,IAA4B,CAAA;QAC5DC,IAAI;QACJC,OAAO;YACLC,SAAS,CAAC;YACVC,SAAS,CAAC;YACVC,QAAQ,CAAC;QACX;QACAC,SAAS;QACTC,OAAO,CAAC;QACRC,QAAQ;QACRJ,SAAS,CAAC;QACVC,QAAQ,CAAC;QACTI,SAAS;IACX,CAAA;AAEA,OAAO,MAAMC,kBAAmC,eAAeA,gBAE7D,EAAEC,IAAI,EAAEC,kBAAkB,EAAEC,aAAa,EAAEC,OAAO,EAAE;IAEpD,MAAMC,WAAWtB,cAAc,YAAYE,GAAG;IAC9C,MAAMqB,U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4 @@
|
|
1
|
-
import type { CreateVersionArgs, TypeWithVersion } from 'payload
|
2
|
-
import type { TypeWithID } from 'payload/types';
|
1
|
+
import type { CreateVersionArgs, TypeWithID, TypeWithVersion } from 'payload';
|
3
2
|
import type { PostgresAdapter } from './types.js';
|
4
3
|
export declare function createVersion<T extends TypeWithID>(this: PostgresAdapter, { autosave, collectionSlug, parent, req, versionData, }: CreateVersionArgs<T>): Promise<TypeWithVersion<T>>;
|
5
4
|
//# sourceMappingURL=createVersion.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createVersion.d.ts","sourceRoot":"","sources":["../src/createVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
1
|
+
{"version":3,"file":"createVersion.d.ts","sourceRoot":"","sources":["../src/createVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAEjB,UAAU,EACV,eAAe,EAChB,MAAM,SAAS,CAAA;AAMhB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIjD,wBAAsB,aAAa,CAAC,CAAC,SAAS,UAAU,EACtD,IAAI,EAAE,eAAe,EACrB,EACE,QAAQ,EACR,cAAc,EACd,MAAM,EACN,GAAkC,EAClC,WAAW,GACZ,EAAE,iBAAiB,CAAC,CAAC,CAAC,+BAsCxB"}
|
package/dist/createVersion.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { sql } from 'drizzle-orm';
|
2
|
-
import { buildVersionCollectionFields } from 'payload
|
2
|
+
import { buildVersionCollectionFields } from 'payload';
|
3
3
|
import toSnakeCase from 'to-snake-case';
|
4
4
|
import { upsertRow } from './upsertRow/index.js';
|
5
5
|
export async function createVersion({ autosave, collectionSlug, parent, req = {}, versionData }) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/createVersion.ts"],"sourcesContent":["import type {
|
1
|
+
{"version":3,"sources":["../src/createVersion.ts"],"sourcesContent":["import type {\n CreateVersionArgs,\n PayloadRequestWithData,\n TypeWithID,\n TypeWithVersion,\n} from 'payload'\n\nimport { sql } from 'drizzle-orm'\nimport { buildVersionCollectionFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function createVersion<T extends TypeWithID>(\n this: PostgresAdapter,\n {\n autosave,\n collectionSlug,\n parent,\n req = {} as PayloadRequestWithData,\n versionData,\n }: CreateVersionArgs<T>,\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collection = this.payload.collections[collectionSlug].config\n const defaultTableName = toSnakeCase(collection.slug)\n\n const tableName = this.tableNameMap.get(`_${defaultTableName}${this.versionsSuffix}`)\n\n const version = { ...versionData }\n if (version.id) delete version.id\n\n const result = await upsertRow<TypeWithVersion<T>>({\n adapter: this,\n data: {\n autosave,\n latest: true,\n parent,\n version,\n },\n db,\n fields: buildVersionCollectionFields(collection),\n operation: 'create',\n req,\n tableName,\n })\n\n const table = this.tables[tableName]\n\n if (collection.versions.drafts) {\n await db.execute(sql`\n UPDATE ${table}\n SET latest = false\n WHERE ${table.id} != ${result.id}\n AND ${table.parent} = ${parent}\n `)\n }\n\n return result\n}\n"],"names":["sql","buildVersionCollectionFields","toSnakeCase","upsertRow","createVersion","autosave","collectionSlug","parent","req","versionData","db","sessions","transactionID","drizzle","collection","payload","collections","config","defaultTableName","slug","tableName","tableNameMap","get","versionsSuffix","version","id","result","adapter","data","latest","fields","operation","table","tables","versions","drafts","execute"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAOA,SAASA,GAAG,QAAQ,cAAa;AACjC,SAASC,4BAA4B,QAAQ,UAAS;AACtD,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,eAAeC,cAEpB,EACEC,QAAQ,EACRC,cAAc,EACdC,MAAM,EACNC,MAAM,CAAC,CAA2B,EAClCC,WAAW,EACU;IAEvB,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACH,IAAII,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,aAAa,IAAI,CAACC,OAAO,CAACC,WAAW,CAACV,eAAe,CAACW,MAAM;IAClE,MAAMC,mBAAmBhB,YAAYY,WAAWK,IAAI;IAEpD,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAAC,CAAC,CAAC,EAAEJ,iBAAiB,EAAE,IAAI,CAACK,cAAc,CAAC,CAAC;IAEpF,MAAMC,UAAU;QAAE,GAAGf,WAAW;IAAC;IACjC,IAAIe,QAAQC,EAAE,EAAE,OAAOD,QAAQC,EAAE;IAEjC,MAAMC,SAAS,MAAMvB,UAA8B;QACjDwB,SAAS,IAAI;QACbC,MAAM;YACJvB;YACAwB,QAAQ;YACRtB;YACAiB;QACF;QACAd;QACAoB,QAAQ7B,6BAA6Ba;QACrCiB,WAAW;QACXvB;QACAY;IACF;IAEA,MAAMY,QAAQ,IAAI,CAACC,MAAM,CAACb,UAAU;IAEpC,IAAIN,WAAWoB,QAAQ,CAACC,MAAM,EAAE;QAC9B,MAAMzB,GAAG0B,OAAO,CAACpC,GAAG,CAAC;aACZ,EAAEgC,MAAM;;YAET,EAAEA,MAAMP,EAAE,CAAC,IAAI,EAAEC,OAAOD,EAAE,CAAC;YAC3B,EAAEO,MAAMzB,MAAM,CAAC,GAAG,EAAEA,OAAO;IACnC,CAAC;IACH;IAEA,OAAOmB;AACT"}
|
package/dist/deleteMany.d.ts
CHANGED
package/dist/deleteMany.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"deleteMany.d.ts","sourceRoot":"","sources":["../src/deleteMany.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,
|
1
|
+
{"version":3,"file":"deleteMany.d.ts","sourceRoot":"","sources":["../src/deleteMany.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA0B,MAAM,SAAS,CAAA;AASjE,eAAO,MAAM,UAAU,EAAE,UA8BxB,CAAA"}
|
package/dist/deleteMany.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/deleteMany.ts"],"sourcesContent":["import type { DeleteMany
|
1
|
+
{"version":3,"sources":["../src/deleteMany.ts"],"sourcesContent":["import type { DeleteMany, PayloadRequestWithData } from 'payload'\n\nimport { inArray } from 'drizzle-orm'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\n\nexport const deleteMany: DeleteMany = async function deleteMany(\n this: PostgresAdapter,\n { collection, req = {} as PayloadRequestWithData, where },\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collectionConfig = this.payload.collections[collection].config\n\n const tableName = this.tableNameMap.get(toSnakeCase(collectionConfig.slug))\n\n const result = await findMany({\n adapter: this,\n fields: collectionConfig.fields,\n limit: 0,\n locale: req.locale,\n page: 1,\n pagination: false,\n req,\n tableName,\n where,\n })\n\n const ids = []\n\n result.docs.forEach((data) => {\n ids.push(data.id)\n })\n\n if (ids.length > 0) {\n await db.delete(this.tables[tableName]).where(inArray(this.tables[tableName].id, ids))\n }\n}\n"],"names":["inArray","toSnakeCase","findMany","deleteMany","collection","req","where","db","sessions","transactionID","drizzle","collectionConfig","payload","collections","config","tableName","tableNameMap","get","slug","result","adapter","fields","limit","locale","page","pagination","ids","docs","forEach","data","push","id","length","delete","tables"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,OAAO,QAAQ,cAAa;AACrC,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,MAAMC,aAAyB,eAAeA,WAEnD,EAAEC,UAAU,EAAEC,MAAM,CAAC,CAA2B,EAAEC,KAAK,EAAE;IAEzD,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACH,IAAII,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,mBAAmB,IAAI,CAACC,OAAO,CAACC,WAAW,CAACT,WAAW,CAACU,MAAM;IAEpE,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAAChB,YAAYU,iBAAiBO,IAAI;IAEzE,MAAMC,SAAS,MAAMjB,SAAS;QAC5BkB,SAAS,IAAI;QACbC,QAAQV,iBAAiBU,MAAM;QAC/BC,OAAO;QACPC,QAAQlB,IAAIkB,MAAM;QAClBC,MAAM;QACNC,YAAY;QACZpB;QACAU;QACAT;IACF;IAEA,MAAMoB,MAAM,EAAE;IAEdP,OAAOQ,IAAI,CAACC,OAAO,CAAC,CAACC;QACnBH,IAAII,IAAI,CAACD,KAAKE,EAAE;IAClB;IAEA,IAAIL,IAAIM,MAAM,GAAG,GAAG;QAClB,MAAMzB,GAAG0B,MAAM,CAAC,IAAI,CAACC,MAAM,CAACnB,UAAU,EAAET,KAAK,CAACN,QAAQ,IAAI,CAACkC,MAAM,CAACnB,UAAU,CAACgB,EAAE,EAAEL;IACnF;AACF,EAAC"}
|
package/dist/deleteOne.d.ts
CHANGED
package/dist/deleteOne.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"deleteOne.d.ts","sourceRoot":"","sources":["../src/deleteOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,
|
1
|
+
{"version":3,"file":"deleteOne.d.ts","sourceRoot":"","sources":["../src/deleteOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAA0B,MAAM,SAAS,CAAA;AAYhE,eAAO,MAAM,SAAS,EAAE,SAwDvB,CAAA"}
|
package/dist/deleteOne.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/deleteOne.ts"],"sourcesContent":["import type { DeleteOne
|
1
|
+
{"version":3,"sources":["../src/deleteOne.ts"],"sourcesContent":["import type { DeleteOne, PayloadRequestWithData } from 'payload'\n\nimport { eq } from 'drizzle-orm'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { buildFindManyArgs } from './find/buildFindManyArgs.js'\nimport buildQuery from './queries/buildQuery.js'\nimport { selectDistinct } from './queries/selectDistinct.js'\nimport { transform } from './transform/read/index.js'\n\nexport const deleteOne: DeleteOne = async function deleteOne(\n this: PostgresAdapter,\n { collection: collectionSlug, req = {} as PayloadRequestWithData, where: whereArg },\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collection = this.payload.collections[collectionSlug].config\n\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n\n let docToDelete: Record<string, unknown>\n\n const { joins, selectFields, where } = await buildQuery({\n adapter: this,\n fields: collection.fields,\n locale: req.locale,\n tableName,\n where: whereArg,\n })\n\n const selectDistinctResult = await selectDistinct({\n adapter: this,\n chainedMethods: [{ args: [1], method: 'limit' }],\n db,\n joins,\n selectFields,\n tableName,\n where,\n })\n\n if (selectDistinctResult?.[0]?.id) {\n docToDelete = await db.query[tableName].findFirst({\n where: eq(this.tables[tableName].id, selectDistinctResult[0].id),\n })\n } else {\n const findManyArgs = buildFindManyArgs({\n adapter: this,\n depth: 0,\n fields: collection.fields,\n tableName,\n })\n\n findManyArgs.where = where\n\n docToDelete = await db.query[tableName].findFirst(findManyArgs)\n }\n\n const result = transform({\n adapter: this,\n config: this.payload.config,\n data: docToDelete,\n fields: collection.fields,\n })\n\n await db.delete(this.tables[tableName]).where(eq(this.tables[tableName].id, docToDelete.id))\n\n return result\n}\n"],"names":["eq","toSnakeCase","buildFindManyArgs","buildQuery","selectDistinct","transform","deleteOne","collection","collectionSlug","req","where","whereArg","db","sessions","transactionID","drizzle","payload","collections","config","tableName","tableNameMap","get","slug","docToDelete","joins","selectFields","adapter","fields","locale","selectDistinctResult","chainedMethods","args","method","id","query","findFirst","tables","findManyArgs","depth","result","data","delete"],"rangeMappings":";;;;;;;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O;QACL,MAAMI,eAAenC,kBAAkB;YACrCwB,SAAS,IAAI;YACbY,OAAO;YACPX,QAAQpB,WAAWoB,MAAM;YACzBR;QACF;QAEAkB,aAAa3B,KAAK,GAAGA;QAErBa,cAAc,MAAMX,GAAGsB,KAAK,CAACf,UAAU,CAACgB,SAAS,CAACE;IACpD;IAEA,MAAME,SAASlC,UAAU;QACvBqB,SAAS,IAAI;QACbR,QAAQ,IAAI,CAACF,OAAO,CAACE,MAAM;QAC3BsB,MAAMjB;QACNI,QAAQpB,WAAWoB,MAAM;IAC3B;IAEA,MAAMf,GAAG6B,MAAM,CAAC,IAAI,CAACL,MAAM,CAACjB,UAAU,EAAET,KAAK,CAACV,GAAG,IAAI,CAACoC,MAAM,CAACjB,UAAU,CAACc,EAAE,EAAEV,YAAYU,EAAE;IAE1F,OAAOM;AACT,EAAC"}
|
package/dist/deleteVersions.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"deleteVersions.d.ts","sourceRoot":"","sources":["../src/deleteVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,
|
1
|
+
{"version":3,"file":"deleteVersions.d.ts","sourceRoot":"","sources":["../src/deleteVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAqD,MAAM,SAAS,CAAA;AAUhG,eAAO,MAAM,cAAc,EAAE,cAoC5B,CAAA"}
|
package/dist/deleteVersions.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { inArray } from 'drizzle-orm';
|
2
|
-
import { buildVersionCollectionFields } from 'payload
|
2
|
+
import { buildVersionCollectionFields } from 'payload';
|
3
3
|
import toSnakeCase from 'to-snake-case';
|
4
4
|
import { findMany } from './find/findMany.js';
|
5
5
|
export const deleteVersions = async function deleteVersion({ collection, locale, req = {}, where: where }) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/deleteVersions.ts"],"sourcesContent":["import type { DeleteVersions
|
1
|
+
{"version":3,"sources":["../src/deleteVersions.ts"],"sourcesContent":["import type { DeleteVersions, PayloadRequestWithData, SanitizedCollectionConfig } from 'payload'\n\nimport { inArray } from 'drizzle-orm'\nimport { buildVersionCollectionFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\n\nexport const deleteVersions: DeleteVersions = async function deleteVersion(\n this: PostgresAdapter,\n { collection, locale, req = {} as PayloadRequestWithData, where: where },\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\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(collectionConfig)\n\n const { docs } = await findMany({\n adapter: this,\n fields,\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 db.delete(this.tables[tableName]).where(inArray(this.tables[tableName].id, ids))\n }\n\n return docs\n}\n"],"names":["inArray","buildVersionCollectionFields","toSnakeCase","findMany","deleteVersions","deleteVersion","collection","locale","req","where","db","sessions","transactionID","drizzle","collectionConfig","payload","collections","config","tableName","tableNameMap","get","slug","versionsSuffix","fields","docs","adapter","limit","page","pagination","ids","forEach","doc","push","id","length","delete","tables"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,OAAO,QAAQ,cAAa;AACrC,SAASC,4BAA4B,QAAQ,UAAS;AACtD,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,MAAMC,iBAAiC,eAAeC,cAE3D,EAAEC,UAAU,EAAEC,MAAM,EAAEC,MAAM,CAAC,CAA2B,EAAEC,OAAOA,KAAK,EAAE;IAExE,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACH,IAAII,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACV,WAAW,CAACW,MAAM;IAE/F,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CACrC,CAAC,CAAC,EAAElB,YAAYY,iBAAiBO,IAAI,EAAE,EAAE,IAAI,CAACC,cAAc,CAAC,CAAC;IAGhE,MAAMC,SAAStB,6BAA6Ba;IAE5C,MAAM,EAAEU,IAAI,EAAE,GAAG,MAAMrB,SAAS;QAC9BsB,SAAS,IAAI;QACbF;QACAG,OAAO;QACPnB;QACAoB,MAAM;QACNC,YAAY;QACZpB;QACAU;QACAT;IACF;IAEA,MAAMoB,MAAM,EAAE;IAEdL,KAAKM,OAAO,CAAC,CAACC;QACZF,IAAIG,IAAI,CAACD,IAAIE,EAAE;IACjB;IAEA,IAAIJ,IAAIK,MAAM,GAAG,GAAG;QAClB,MAAMxB,GAAGyB,MAAM,CAAC,IAAI,CAACC,MAAM,CAAClB,UAAU,EAAET,KAAK,CAACT,QAAQ,IAAI,CAACoC,MAAM,CAAClB,UAAU,CAACe,EAAE,EAAEJ;IACnF;IAEA,OAAOL;AACT,EAAC"}
|
package/dist/destroy.d.ts
CHANGED
package/dist/destroy.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"destroy.d.ts","sourceRoot":"","sources":["../src/destroy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"destroy.d.ts","sourceRoot":"","sources":["../src/destroy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAKtC,eAAO,MAAM,OAAO,EAAE,OAWrB,CAAA"}
|
package/dist/destroy.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/destroy.ts"],"sourcesContent":["import type { Destroy } from 'payload
|
1
|
+
{"version":3,"sources":["../src/destroy.ts"],"sourcesContent":["import type { Destroy } from 'payload'\n\nimport type { PostgresAdapter } from './types.js'\n\n// eslint-disable-next-line @typescript-eslint/require-await\nexport const destroy: Destroy = async function destroy(this: PostgresAdapter) {\n this.enums = {}\n this.schema = {}\n this.tables = {}\n this.relations = {}\n this.fieldConstraints = {}\n this.drizzle = undefined\n this.initializing = new Promise((res, rej) => {\n this.resolveInitializing = res\n this.rejectInitializing = rej\n })\n}\n"],"names":["destroy","enums","schema","tables","relations","fieldConstraints","drizzle","undefined","initializing","Promise","res","rej","resolveInitializing","rejectInitializing"],"rangeMappings":";;;;;;;;;;;;","mappings":"AAIA,4DAA4D;AAC5D,OAAO,MAAMA,UAAmB,eAAeA;IAC7C,IAAI,CAACC,KAAK,GAAG,CAAC;IACd,IAAI,CAACC,MAAM,GAAG,CAAC;IACf,IAAI,CAACC,MAAM,GAAG,CAAC;IACf,IAAI,CAACC,SAAS,GAAG,CAAC;IAClB,IAAI,CAACC,gBAAgB,GAAG,CAAC;IACzB,IAAI,CAACC,OAAO,GAAGC;IACf,IAAI,CAACC,YAAY,GAAG,IAAIC,QAAQ,CAACC,KAAKC;QACpC,IAAI,CAACC,mBAAmB,GAAGF;QAC3B,IAAI,CAACG,kBAAkB,GAAGF;IAC5B;AACF,EAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"buildFindManyArgs.d.ts","sourceRoot":"","sources":["../../src/find/buildFindManyArgs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"buildFindManyArgs.d.ts","sourceRoot":"","sources":["../../src/find/buildFindManyArgs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAIlD,KAAK,kBAAkB,GAAG;IACxB,OAAO,EAAE,eAAe,CAAA;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG;IAC3D,IAAI,CAAC,EAAE,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG;QAC7C,QAAQ,CAAC,EAAE,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;KACjD,CAAA;CACF,CAAA;AAID,eAAO,MAAM,iBAAiB,2CAK3B,kBAAkB,KAAG,OAAO,MAAM,EAAE,OAAO,CA4D7C,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/find/buildFindManyArgs.ts"],"sourcesContent":["import type { DBQueryConfig } from 'drizzle-orm'\nimport type { Field } from 'payload
|
1
|
+
{"version":3,"sources":["../../src/find/buildFindManyArgs.ts"],"sourcesContent":["import type { DBQueryConfig } from 'drizzle-orm'\nimport type { Field } from 'payload'\n\nimport type { PostgresAdapter } from '../types.js'\n\nimport { traverseFields } from './traverseFields.js'\n\ntype BuildFindQueryArgs = {\n adapter: PostgresAdapter\n depth: number\n fields: Field[]\n tableName: string\n}\n\nexport type Result = DBQueryConfig<'many', true, any, any> & {\n with?: DBQueryConfig<'many', true, any, any> & {\n _locales?: DBQueryConfig<'many', true, any, any>\n }\n}\n\n// Generate the Drizzle query for findMany based on\n// a collection field structure\nexport const buildFindManyArgs = ({\n adapter,\n depth,\n fields,\n tableName,\n}: BuildFindQueryArgs): Record<string, unknown> => {\n const result: Result = {\n with: {},\n }\n\n const _locales: Result = {\n columns: {\n id: false,\n _parentID: false,\n },\n with: {},\n }\n\n if (adapter.tables[`${tableName}_texts`]) {\n result.with._texts = {\n columns: {\n id: false,\n parent: false,\n },\n orderBy: ({ order }, { asc: ASC }) => [ASC(order)],\n }\n }\n\n if (adapter.tables[`${tableName}_numbers`]) {\n result.with._numbers = {\n columns: {\n id: false,\n parent: false,\n },\n orderBy: ({ order }, { asc: ASC }) => [ASC(order)],\n }\n }\n\n if (adapter.tables[`${tableName}${adapter.relationshipsSuffix}`]) {\n result.with._rels = {\n columns: {\n id: false,\n parent: false,\n },\n orderBy: ({ order }, { asc: ASC }) => [ASC(order)],\n }\n }\n\n if (adapter.tables[`${tableName}${adapter.localesSuffix}`]) {\n result.with._locales = _locales\n }\n\n traverseFields({\n _locales,\n adapter,\n currentArgs: result,\n currentTableName: tableName,\n depth,\n fields,\n path: '',\n topLevelArgs: result,\n topLevelTableName: tableName,\n })\n\n return result\n}\n"],"names":["traverseFields","buildFindManyArgs","adapter","depth","fields","tableName","result","with","_locales","columns","id","_parentID","tables","_texts","parent","orderBy","order","asc","ASC","_numbers","relationshipsSuffix","_rels","localesSuffix","currentArgs","currentTableName","path","topLevelArgs","topLevelTableName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,SAASA,cAAc,QAAQ,sBAAqB;AAepD,mDAAmD;AACnD,+BAA+B;AAC/B,OAAO,MAAMC,oBAAoB,CAAC,EAChCC,OAAO,EACPC,KAAK,EACLC,MAAM,EACNC,SAAS,EACU;IACnB,MAAMC,SAAiB;QACrBC,MAAM,CAAC;IACT;IAEA,MAAMC,WAAmB;QACvBC,SAAS;YACPC,IAAI;YACJC,WAAW;QACb;QACAJ,MAAM,CAAC;IACT;IAEA,IAAIL,QAAQU,MAAM,CAAC,CAAC,EAAEP,UAAU,MAAM,CAAC,CAAC,EAAE;QACxCC,OAAOC,IAAI,CAACM,MAAM,GAAG;YACnBJ,SAAS;gBACPC,IAAI;gBACJI,QAAQ;YACV;YACAC,SAAS,CAAC,EAAEC,KAAK,EAAE,EAAE,EAAEC,KAAKC,GAAG,EAAE,GAAK;oBAACA,IAAIF;iBAAO;QACpD;IACF;IAEA,IAAId,QAAQU,MAAM,CAAC,CAAC,EAAEP,UAAU,QAAQ,CAAC,CAAC,EAAE;QAC1CC,OAAOC,IAAI,CAACY,QAAQ,GAAG;YACrBV,SAAS;gBACPC,IAAI;gBACJI,QAAQ;YACV;YACAC,SAAS,CAAC,EAAEC,KAAK,EAAE,EAAE,EAAEC,KAAKC,GAAG,EAAE,GAAK;oBAACA,IAAIF;iBAAO;QACpD;IACF;IAEA,IAAId,QAAQU,MAAM,CAAC,CAAC,EAAEP,UAAU,EAAEH,QAAQkB,mBAAmB,CAAC,CAAC,CAAC,EAAE;QAChEd,OAAOC,IAAI,CAACc,KAAK,GAAG;YAClBZ,SAAS;gBACPC,IAAI;gBACJI,QAAQ;YACV;YACAC,SAAS,CAAC,EAAEC,KAAK,EAAE,EAAE,EAAEC,KAAKC,GAAG,EAAE,GAAK;oBAACA,IAAIF;iBAAO;QACpD;IACF;IAEA,IAAId,QAAQU,MAAM,CAAC,CAAC,EAAEP,UAAU,EAAEH,QAAQoB,aAAa,CAAC,CAAC,CAAC,EAAE;QAC1DhB,OAAOC,IAAI,CAACC,QAAQ,GAAGA;IACzB;IAEAR,eAAe;QACbQ;QACAN;QACAqB,aAAajB;QACbkB,kBAAkBnB;QAClBF;QACAC;QACAqB,MAAM;QACNC,cAAcpB;QACdqB,mBAAmBtB;IACrB;IAEA,OAAOC;AACT,EAAC"}
|
package/dist/find/findMany.d.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
import type { FindArgs } from 'payload
|
2
|
-
import type { Field } from 'payload/types';
|
1
|
+
import type { Field, FindArgs } from 'payload';
|
3
2
|
import type { PostgresAdapter } from '../types.js';
|
4
3
|
type Args = Omit<FindArgs, 'collection'> & {
|
5
4
|
adapter: PostgresAdapter;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"findMany.d.ts","sourceRoot":"","sources":["../../src/find/findMany.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
1
|
+
{"version":3,"file":"findMany.d.ts","sourceRoot":"","sources":["../../src/find/findMany.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAsC,MAAM,SAAS,CAAA;AAIlF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AASlD,KAAK,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,GAAG;IACzC,OAAO,EAAE,eAAe,CAAA;IACxB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,QAAQ,iHAYlB,IAAI;;;;;;;;;;;EAsJN,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/find/findMany.ts"],"sourcesContent":["import type {
|
1
|
+
{"version":3,"sources":["../../src/find/findMany.ts"],"sourcesContent":["import type { Field, FindArgs, PayloadRequestWithData, TypeWithID } from 'payload'\n\nimport { inArray, sql } from 'drizzle-orm'\n\nimport type { PostgresAdapter } from '../types.js'\nimport type { ChainedMethods } from './chainMethods.js'\n\nimport buildQuery from '../queries/buildQuery.js'\nimport { selectDistinct } from '../queries/selectDistinct.js'\nimport { transform } from '../transform/read/index.js'\nimport { buildFindManyArgs } from './buildFindManyArgs.js'\nimport { chainMethods } from './chainMethods.js'\n\ntype Args = Omit<FindArgs, 'collection'> & {\n adapter: PostgresAdapter\n fields: Field[]\n tableName: string\n}\n\nexport const findMany = async function find({\n adapter,\n fields,\n limit: limitArg,\n locale,\n page = 1,\n pagination,\n req = {} as PayloadRequestWithData,\n skip,\n sort,\n tableName,\n where: whereArg,\n}: Args) {\n const db = adapter.sessions[req.transactionID]?.db || adapter.drizzle\n const table = adapter.tables[tableName]\n\n const limit = limitArg ?? 10\n let totalDocs: number\n let totalPages: number\n let hasPrevPage: boolean\n let hasNextPage: boolean\n let pagingCounter: number\n\n const { joins, orderBy, selectFields, where } = await buildQuery({\n adapter,\n fields,\n locale,\n sort,\n tableName,\n where: whereArg,\n })\n\n const orderedIDMap: Record<number | string, number> = {}\n let orderedIDs: (number | string)[]\n\n const selectDistinctMethods: ChainedMethods = []\n\n if (orderBy?.order && orderBy?.column) {\n selectDistinctMethods.push({\n args: [orderBy.order(orderBy.column)],\n method: 'orderBy',\n })\n }\n\n const findManyArgs = buildFindManyArgs({\n adapter,\n depth: 0,\n fields,\n tableName,\n })\n\n selectDistinctMethods.push({ args: [skip || (page - 1) * limit], method: 'offset' })\n selectDistinctMethods.push({ args: [limit === 0 ? undefined : limit], method: 'limit' })\n\n const selectDistinctResult = await selectDistinct({\n adapter,\n chainedMethods: selectDistinctMethods,\n db,\n joins,\n selectFields,\n tableName,\n where,\n })\n\n if (selectDistinctResult) {\n if (selectDistinctResult.length === 0) {\n return {\n docs: [],\n hasNextPage: false,\n hasPrevPage: false,\n limit,\n nextPage: null,\n page: 1,\n pagingCounter: 0,\n prevPage: null,\n totalDocs: 0,\n totalPages: 0,\n }\n } else {\n // set the id in an object for sorting later\n selectDistinctResult.forEach(({ id }, i) => {\n orderedIDMap[id] = i\n })\n orderedIDs = Object.keys(orderedIDMap)\n findManyArgs.where = inArray(adapter.tables[tableName].id, orderedIDs)\n }\n } else {\n findManyArgs.limit = limitArg === 0 ? undefined : limitArg\n\n const offset = skip || (page - 1) * limitArg\n\n if (!Number.isNaN(offset)) findManyArgs.offset = offset\n\n if (where) {\n findManyArgs.where = where\n }\n findManyArgs.orderBy = orderBy.order(orderBy.column)\n }\n\n const findPromise = db.query[tableName].findMany(findManyArgs)\n\n if (pagination !== false && (orderedIDs ? orderedIDs?.length <= limit : true)) {\n const selectCountMethods: ChainedMethods = []\n joins.forEach(({ condition, table }) => {\n selectCountMethods.push({\n args: [table, condition],\n method: 'leftJoin',\n })\n })\n\n const countResult = await chainMethods({\n methods: selectCountMethods,\n query: db\n .select({\n count: sql<number>`count\n (DISTINCT ${adapter.tables[tableName].id})`,\n })\n .from(table)\n .where(where),\n })\n totalDocs = Number(countResult[0].count)\n totalPages = typeof limit === 'number' && limit !== 0 ? Math.ceil(totalDocs / limit) : 1\n hasPrevPage = page > 1\n hasNextPage = totalPages > page\n pagingCounter = (page - 1) * limit + 1\n }\n\n const rawDocs = await findPromise\n // sort rawDocs from selectQuery\n if (Object.keys(orderedIDMap).length > 0) {\n rawDocs.sort((a, b) => orderedIDMap[a.id] - orderedIDMap[b.id])\n }\n\n if (pagination === false || !totalDocs) {\n totalDocs = rawDocs.length\n totalPages = 1\n pagingCounter = 1\n hasPrevPage = false\n hasNextPage = false\n }\n\n const docs = rawDocs.map((data: TypeWithID) => {\n return transform({\n adapter,\n config: adapter.payload.config,\n data,\n fields,\n })\n })\n\n return {\n docs,\n hasNextPage,\n hasPrevPage,\n limit,\n nextPage: hasNextPage ? page + 1 : null,\n page,\n pagingCounter,\n prevPage: hasPrevPage ? page - 1 : null,\n totalDocs,\n totalPages,\n }\n}\n"],"names":["inArray","sql","buildQuery","selectDistinct","transform","buildFindManyArgs","chainMethods","findMany","find","adapter","fields","limit","limitArg","locale","page","pagination","req","skip","sort","tableName","where","whereArg","db","sessions","transactionID","drizzle","table","tables","totalDocs","totalPages","hasPrevPage","hasNextPage","pagingCounter","joins","orderBy","selectFields","orderedIDMap","orderedIDs","selectDistinctMethods","order","column","push","args","method","findManyArgs","depth","undefined","selectDistinctResult","chainedMethods","length","docs","nextPage","prevPage","forEach","id","i","Object","keys","offset","Number","isNaN","findPromise","query","selectCountMethods","condition","countResult","methods","select","count","from","Math","ceil","rawDocs","a","b","map","data","config","payload"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAO,IAAI;QACnCA;QACAkB;QACAoB,UAAUtB,cAAchB,OAAO,IAAI;QACnCc;QACAC;IACF;AACF,EAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../src/find/traverseFields.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../src/find/traverseFields.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAKpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,eAAe,CAAA;IACxB,WAAW,EAAE,MAAM,CAAA;IACnB,gBAAgB,EAAE,MAAM,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACrC,iBAAiB,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,cAAc,gHAUxB,iBAAiB,4BA8KnB,CAAA"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/* eslint-disable no-param-reassign */ import { fieldAffectsData, tabHasName } from 'payload/
|
1
|
+
/* eslint-disable no-param-reassign */ import { fieldAffectsData, tabHasName } from 'payload/shared';
|
2
2
|
import toSnakeCase from 'to-snake-case';
|
3
3
|
export const traverseFields = ({ _locales, adapter, currentArgs, currentTableName, depth, fields, path, topLevelArgs, topLevelTableName })=>{
|
4
4
|
fields.forEach((field)=>{
|