@payloadcms/db-postgres 3.0.0-canary.f1db24e → 3.0.0-canary.f83d96a
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 +1 -10
- 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 +2 -3
- 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 +56 -35
- 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 +3 -7
- 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 +2 -2
- 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/exports/migration-utils.d.ts +2 -0
- package/dist/exports/migration-utils.d.ts.map +1 -0
- package/dist/exports/migration-utils.js +3 -0
- package/dist/exports/migration-utils.js.map +1 -0
- package/dist/find/buildFindManyArgs.d.ts +6 -2
- package/dist/find/buildFindManyArgs.d.ts.map +1 -1
- package/dist/find/buildFindManyArgs.js +2 -1
- package/dist/find/buildFindManyArgs.js.map +1 -1
- package/dist/find/chainMethods.d.ts.map +1 -1
- package/dist/find/chainMethods.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 +4 -15
- package/dist/find/findMany.js.map +1 -1
- package/dist/find/traverseFields.d.ts +4 -3
- package/dist/find/traverseFields.d.ts.map +1 -1
- package/dist/find/traverseFields.js +23 -5
- 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 +15 -20
- 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/relationships-v2-v3.d.ts +4 -0
- package/dist/predefinedMigrations/relationships-v2-v3.d.ts.map +1 -0
- package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -0
- package/dist/predefinedMigrations/relationships-v2-v3.mjs +11 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +19 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +169 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts +11 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +191 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts +3 -0
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js +56 -0
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/index.d.ts +23 -0
- package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/index.js +211 -0
- package/dist/predefinedMigrations/v2-v3/index.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +19 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.js +57 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +22 -0
- package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/traverseFields.js +85 -0
- package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/types.d.ts +9 -0
- package/dist/predefinedMigrations/v2-v3/types.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/types.js +6 -0
- package/dist/predefinedMigrations/v2-v3/types.js.map +1 -0
- package/dist/queries/buildAndOrConditions.d.ts +4 -5
- package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
- package/dist/queries/buildAndOrConditions.js +1 -2
- package/dist/queries/buildAndOrConditions.js.map +1 -1
- package/dist/queries/buildQuery.d.ts +2 -3
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/buildQuery.js +1 -5
- package/dist/queries/buildQuery.js.map +1 -1
- package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +1 -1
- package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +1 -1
- package/dist/queries/createJSONQuery/index.js.map +1 -1
- package/dist/queries/getTableColumnFromPath.d.ts +4 -5
- package/dist/queries/getTableColumnFromPath.d.ts.map +1 -1
- package/dist/queries/getTableColumnFromPath.js +170 -99
- package/dist/queries/getTableColumnFromPath.js.map +1 -1
- package/dist/queries/operatorMap.js.map +1 -1
- package/dist/queries/parseParams.d.ts +4 -5
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +3 -5
- 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/queries/selectDistinct.d.ts +3 -4
- package/dist/queries/selectDistinct.d.ts.map +1 -1
- package/dist/queries/selectDistinct.js +3 -14
- package/dist/queries/selectDistinct.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 +9 -5
- package/dist/schema/build.d.ts.map +1 -1
- package/dist/schema/build.js +161 -112
- package/dist/schema/build.js.map +1 -1
- package/dist/schema/createIndex.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/parentIDColumnMap.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 +5 -7
- package/dist/schema/traverseFields.d.ts.map +1 -1
- package/dist/schema/traverseFields.js +105 -42
- 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 +4 -3
- package/dist/transform/read/index.d.ts.map +1 -1
- package/dist/transform/read/index.js +2 -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 +0 -4
- package/dist/transform/read/relationship.js.map +1 -1
- package/dist/transform/read/traverseFields.d.ts +8 -3
- package/dist/transform/read/traverseFields.d.ts.map +1 -1
- package/dist/transform/read/traverseFields.js +70 -56
- 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/numbers.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/selects.js.map +1 -1
- package/dist/transform/write/texts.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 +21 -4
- package/dist/transform/write/traverseFields.js.map +1 -1
- package/dist/transform/write/types.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 +1 -2
- package/dist/update.js.map +1 -1
- package/dist/updateGlobal.d.ts +2 -3
- 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/deleteExistingArrayRows.d.ts.map +1 -1
- package/dist/upsertRow/deleteExistingArrayRows.js.map +1 -1
- package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +1 -1
- package/dist/upsertRow/deleteExistingRowsByPath.js.map +1 -1
- package/dist/upsertRow/index.d.ts +2 -2
- package/dist/upsertRow/index.d.ts.map +1 -1
- package/dist/upsertRow/index.js +12 -8
- package/dist/upsertRow/index.js.map +1 -1
- package/dist/upsertRow/insertArrays.d.ts.map +1 -1
- package/dist/upsertRow/insertArrays.js.map +1 -1
- package/dist/upsertRow/types.d.ts +6 -1
- package/dist/upsertRow/types.d.ts.map +1 -1
- package/dist/upsertRow/types.js.map +1 -1
- package/dist/utilities/appendPrefixToKeys.d.ts.map +1 -1
- package/dist/utilities/appendPrefixToKeys.js.map +1 -1
- package/dist/utilities/createBlocksMap.d.ts.map +1 -1
- package/dist/utilities/createBlocksMap.js.map +1 -1
- package/dist/utilities/createMigrationTable.d.ts.map +1 -1
- package/dist/utilities/createMigrationTable.js.map +1 -1
- package/dist/utilities/createRelationshipMap.d.ts.map +1 -1
- package/dist/utilities/createRelationshipMap.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/isArrayOfRows.js.map +1 -1
- package/dist/utilities/migrationTableExists.d.ts.map +1 -1
- package/dist/utilities/migrationTableExists.js.map +1 -1
- package/dist/utilities/parseError.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 +20 -11
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/predefinedMigrations/v2-v3/migrateRelationships.ts"],"sourcesContent":["import type { Field, Payload, PayloadRequestWithData } from 'payload'\n\nimport { sql } from 'drizzle-orm'\n\nimport type { DrizzleTransaction, PostgresAdapter } from '../../types.js'\nimport type { DocsToResave, PathsToQuery } from './types.js'\n\nimport { fetchAndResave } from './fetchAndResave/index.js'\n\ntype Args = {\n adapter: PostgresAdapter\n collectionSlug?: string\n db: DrizzleTransaction\n debug: boolean\n fields: Field[]\n globalSlug?: string\n isVersions: boolean\n pathsToQuery: PathsToQuery\n payload: Payload\n req?: Partial<PayloadRequestWithData>\n tableName: string\n}\n\nexport const migrateRelationships = async ({\n adapter,\n collectionSlug,\n db,\n debug,\n fields,\n globalSlug,\n isVersions,\n pathsToQuery,\n payload,\n req,\n tableName,\n}: Args) => {\n if (pathsToQuery.size === 0) return\n\n let offset = 0\n\n let paginationResult\n\n const where = Array.from(pathsToQuery).reduce((statement, path, i) => {\n return (statement += `\n\"${tableName}${adapter.relationshipsSuffix}\".\"path\" LIKE '${path}'${pathsToQuery.size !== i + 1 ? ' OR' : ''}\n`)\n }, '')\n\n while (typeof paginationResult === 'undefined' || paginationResult.rows.length > 0) {\n const paginationStatement = `SELECT DISTINCT parent_id FROM ${tableName}${adapter.relationshipsSuffix} WHERE\n ${where} ORDER BY parent_id LIMIT 500 OFFSET ${offset * 500};\n `\n\n paginationResult = await adapter.drizzle.execute(sql.raw(`${paginationStatement}`))\n\n if (paginationResult.rows.length === 0) return\n\n offset += 1\n\n const statement = `SELECT * FROM ${tableName}${adapter.relationshipsSuffix} WHERE\n (${where}) AND parent_id IN (${paginationResult.rows.map((row) => row.parent_id).join(', ')});\n`\n if (debug) {\n payload.logger.info('FINDING ROWS TO MIGRATE')\n payload.logger.info(statement)\n }\n\n const result = await adapter.drizzle.execute(sql.raw(`${statement}`))\n\n const docsToResave: DocsToResave = {}\n\n result.rows.forEach((row) => {\n const parentID = row.parent_id\n\n if (typeof parentID === 'string' || typeof parentID === 'number') {\n if (!docsToResave[parentID]) docsToResave[parentID] = []\n docsToResave[parentID].push(row)\n }\n })\n\n await fetchAndResave({\n adapter,\n collectionSlug,\n db,\n debug,\n docsToResave,\n fields,\n globalSlug,\n isVersions,\n payload,\n req: req as unknown as PayloadRequestWithData,\n tableName,\n })\n }\n\n const deleteStatement = `DELETE FROM ${tableName}${adapter.relationshipsSuffix} WHERE ${where}`\n if (debug) {\n payload.logger.info('DELETING ROWS')\n payload.logger.info(deleteStatement)\n }\n await db.execute(sql.raw(`${deleteStatement}`))\n}\n"],"names":["sql","fetchAndResave","migrateRelationships","adapter","collectionSlug","db","debug","fields","globalSlug","isVersions","pathsToQuery","payload","req","tableName","size","offset","paginationResult","where","Array","from","reduce","statement","path","i","relationshipsSuffix","rows","length","paginationStatement","drizzle","execute","raw","map","row","parent_id","join","logger","info","result","docsToResave","forEach","parentID","push","deleteStatement"],"mappings":"AAEA,SAASA,GAAG,QAAQ,cAAa;AAKjC,SAASC,cAAc,QAAQ,4BAA2B;AAgB1D,OAAO,MAAMC,uBAAuB,OAAO,EACzCC,OAAO,EACPC,cAAc,EACdC,EAAE,EACFC,KAAK,EACLC,MAAM,EACNC,UAAU,EACVC,UAAU,EACVC,YAAY,EACZC,OAAO,EACPC,GAAG,EACHC,SAAS,EACJ;IACL,IAAIH,aAAaI,IAAI,KAAK,GAAG;IAE7B,IAAIC,SAAS;IAEb,IAAIC;IAEJ,MAAMC,QAAQC,MAAMC,IAAI,CAACT,cAAcU,MAAM,CAAC,CAACC,WAAWC,MAAMC;QAC9D,OAAQF,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CAACC,IAAI,CAACT;YAC9B;QACF;QAEA,MAAM/B,eAAe;YACnBE;YACAC;YACAC;YACAC;YACAgC;YACA/B;YACAC;YACAC;YACAE;YACAC,KAAKA;YACLC;QACF;IACF;IAEA,MAAM6B,kBAAkB,CAAC,YAAY,EAAE7B,UAAU,EAAEV,QAAQqB,mBAAmB,CAAC,OAAO,EAAEP,MAAM,CAAC;IAC/F,IAAIX,OAAO;QACTK,QAAQwB,MAAM,CAACC,IAAI,CAAC;QACpBzB,QAAQwB,MAAM,CAACC,IAAI,CAACM;IACtB;IACA,MAAMrC,GAAGwB,OAAO,CAAC7B,IAAI8B,GAAG,CAAC,CAAC,EAAEY,gBAAgB,CAAC;AAC/C,EAAC"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import type { Field, Payload } from 'payload';
|
2
|
+
import type { DrizzleTransaction, PostgresAdapter } from '../../types.js';
|
3
|
+
import type { PathsToQuery } from './types.js';
|
4
|
+
type Args = {
|
5
|
+
adapter: PostgresAdapter;
|
6
|
+
collectionSlug?: string;
|
7
|
+
columnPrefix: string;
|
8
|
+
db: DrizzleTransaction;
|
9
|
+
disableNotNull: boolean;
|
10
|
+
fields: Field[];
|
11
|
+
globalSlug?: string;
|
12
|
+
isVersions: boolean;
|
13
|
+
newTableName: string;
|
14
|
+
parentTableName: string;
|
15
|
+
path: string;
|
16
|
+
pathsToQuery: PathsToQuery;
|
17
|
+
payload: Payload;
|
18
|
+
rootTableName: string;
|
19
|
+
};
|
20
|
+
export declare const traverseFields: (args: Args) => void;
|
21
|
+
export {};
|
22
|
+
//# sourceMappingURL=traverseFields.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../src/predefinedMigrations/v2-v3/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAK7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,EAAE,EAAE,kBAAkB,CAAA;IACtB,cAAc,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,YAAY,CAAA;IAC1B,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,cAAc,SAAU,IAAI,SA0FxC,CAAA"}
|
@@ -0,0 +1,85 @@
|
|
1
|
+
import { tabHasName } from 'payload/shared';
|
2
|
+
import toSnakeCase from 'to-snake-case';
|
3
|
+
export const traverseFields = (args)=>{
|
4
|
+
args.fields.forEach((field)=>{
|
5
|
+
switch(field.type){
|
6
|
+
case 'group':
|
7
|
+
{
|
8
|
+
let newTableName = `${args.newTableName}_${toSnakeCase(field.name)}`;
|
9
|
+
if (field.localized && args.payload.config.localization) {
|
10
|
+
newTableName += args.adapter.localesSuffix;
|
11
|
+
}
|
12
|
+
return traverseFields({
|
13
|
+
...args,
|
14
|
+
columnPrefix: `${args.columnPrefix}${toSnakeCase(field.name)}_`,
|
15
|
+
fields: field.fields,
|
16
|
+
newTableName,
|
17
|
+
path: `${args.path ? `${args.path}.` : ''}${field.name}`
|
18
|
+
});
|
19
|
+
}
|
20
|
+
case 'row':
|
21
|
+
case 'collapsible':
|
22
|
+
{
|
23
|
+
return traverseFields({
|
24
|
+
...args,
|
25
|
+
fields: field.fields
|
26
|
+
});
|
27
|
+
}
|
28
|
+
case 'array':
|
29
|
+
{
|
30
|
+
const newTableName = args.adapter.tableNameMap.get(`${args.newTableName}_${toSnakeCase(field.name)}`);
|
31
|
+
return traverseFields({
|
32
|
+
...args,
|
33
|
+
columnPrefix: '',
|
34
|
+
fields: field.fields,
|
35
|
+
newTableName,
|
36
|
+
parentTableName: newTableName,
|
37
|
+
path: `${args.path ? `${args.path}.` : ''}${field.name}.%`
|
38
|
+
});
|
39
|
+
}
|
40
|
+
case 'blocks':
|
41
|
+
{
|
42
|
+
return field.blocks.forEach((block)=>{
|
43
|
+
const newTableName = args.adapter.tableNameMap.get(`${args.rootTableName}_blocks_${toSnakeCase(block.slug)}`);
|
44
|
+
traverseFields({
|
45
|
+
...args,
|
46
|
+
columnPrefix: '',
|
47
|
+
fields: block.fields,
|
48
|
+
newTableName,
|
49
|
+
parentTableName: newTableName,
|
50
|
+
path: `${args.path ? `${args.path}.` : ''}${field.name}.%`
|
51
|
+
});
|
52
|
+
});
|
53
|
+
}
|
54
|
+
case 'tabs':
|
55
|
+
{
|
56
|
+
return field.tabs.forEach((tab)=>{
|
57
|
+
if (tabHasName(tab)) {
|
58
|
+
args.columnPrefix = `${args.columnPrefix}_${toSnakeCase(tab.name)}_`;
|
59
|
+
args.path = `${args.path ? `${args.path}.` : ''}${tab.name}`;
|
60
|
+
args.newTableName = `${args.newTableName}_${toSnakeCase(tab.name)}`;
|
61
|
+
if (tab.localized && args.payload.config.localization) {
|
62
|
+
args.newTableName += args.adapter.localesSuffix;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
traverseFields({
|
66
|
+
...args,
|
67
|
+
fields: tab.fields
|
68
|
+
});
|
69
|
+
});
|
70
|
+
}
|
71
|
+
case 'relationship':
|
72
|
+
case 'upload':
|
73
|
+
{
|
74
|
+
if (typeof field.relationTo === 'string') {
|
75
|
+
if (field.type === 'upload' || !field.hasMany) {
|
76
|
+
args.pathsToQuery.add(`${args.path ? `${args.path}.` : ''}${field.name}`);
|
77
|
+
}
|
78
|
+
}
|
79
|
+
return null;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
});
|
83
|
+
};
|
84
|
+
|
85
|
+
//# sourceMappingURL=traverseFields.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/predefinedMigrations/v2-v3/traverseFields.ts"],"sourcesContent":["import type { Field, Payload } from 'payload'\n\nimport { tabHasName } from 'payload/shared'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleTransaction, PostgresAdapter } from '../../types.js'\nimport type { PathsToQuery } from './types.js'\n\ntype Args = {\n adapter: PostgresAdapter\n collectionSlug?: string\n columnPrefix: string\n db: DrizzleTransaction\n disableNotNull: boolean\n fields: Field[]\n globalSlug?: string\n isVersions: boolean\n newTableName: string\n parentTableName: string\n path: string\n pathsToQuery: PathsToQuery\n payload: Payload\n rootTableName: string\n}\n\nexport const traverseFields = (args: Args) => {\n args.fields.forEach((field) => {\n switch (field.type) {\n case 'group': {\n let newTableName = `${args.newTableName}_${toSnakeCase(field.name)}`\n\n if (field.localized && args.payload.config.localization) {\n newTableName += args.adapter.localesSuffix\n }\n\n return traverseFields({\n ...args,\n columnPrefix: `${args.columnPrefix}${toSnakeCase(field.name)}_`,\n fields: field.fields,\n newTableName,\n path: `${args.path ? `${args.path}.` : ''}${field.name}`,\n })\n }\n\n case 'row':\n case 'collapsible': {\n return traverseFields({\n ...args,\n fields: field.fields,\n })\n }\n\n case 'array': {\n const newTableName = args.adapter.tableNameMap.get(\n `${args.newTableName}_${toSnakeCase(field.name)}`,\n )\n\n return traverseFields({\n ...args,\n columnPrefix: '',\n fields: field.fields,\n newTableName,\n parentTableName: newTableName,\n path: `${args.path ? `${args.path}.` : ''}${field.name}.%`,\n })\n }\n\n case 'blocks': {\n return field.blocks.forEach((block) => {\n const newTableName = args.adapter.tableNameMap.get(\n `${args.rootTableName}_blocks_${toSnakeCase(block.slug)}`,\n )\n\n traverseFields({\n ...args,\n columnPrefix: '',\n fields: block.fields,\n newTableName,\n parentTableName: newTableName,\n path: `${args.path ? `${args.path}.` : ''}${field.name}.%`,\n })\n })\n }\n\n case 'tabs': {\n return field.tabs.forEach((tab) => {\n if (tabHasName(tab)) {\n args.columnPrefix = `${args.columnPrefix}_${toSnakeCase(tab.name)}_`\n args.path = `${args.path ? `${args.path}.` : ''}${tab.name}`\n args.newTableName = `${args.newTableName}_${toSnakeCase(tab.name)}`\n\n if (tab.localized && args.payload.config.localization) {\n args.newTableName += args.adapter.localesSuffix\n }\n }\n\n traverseFields({\n ...args,\n fields: tab.fields,\n })\n })\n }\n\n case 'relationship':\n case 'upload': {\n if (typeof field.relationTo === 'string') {\n if (field.type === 'upload' || !field.hasMany) {\n args.pathsToQuery.add(`${args.path ? `${args.path}.` : ''}${field.name}`)\n }\n }\n\n return null\n }\n }\n })\n}\n"],"names":["tabHasName","toSnakeCase","traverseFields","args","fields","forEach","field","type","newTableName","name","localized","payload","config","localization","adapter","localesSuffix","columnPrefix","path","tableNameMap","get","parentTableName","blocks","block","rootTableName","slug","tabs","tab","relationTo","hasMany","pathsToQuery","add"],"mappings":"AAEA,SAASA,UAAU,QAAQ,iBAAgB;AAC3C,OAAOC,iBAAiB,gBAAe;AAsBvC,OAAO,MAAMC,iBAAiB,CAACC;IAC7BA,KAAKC,MAAM,CAACC,OAAO,CAAC,CAACC;QACnB,OAAQA,MAAMC,IAAI;YAChB,KAAK;gBAAS;oBACZ,IAAIC,eAAe,CAAC,EAAEL,KAAKK,YAAY,CAAC,CAAC,EAAEP,YAAYK,MAAMG,IAAI,EAAE,CAAC;oBAEpE,IAAIH,MAAMI,SAAS,IAAIP,KAAKQ,OAAO,CAACC,MAAM,CAACC,YAAY,EAAE;wBACvDL,gBAAgBL,KAAKW,OAAO,CAACC,aAAa;oBAC5C;oBAEA,OAAOb,eAAe;wBACpB,GAAGC,IAAI;wBACPa,cAAc,CAAC,EAAEb,KAAKa,YAAY,CAAC,EAAEf,YAAYK,MAAMG,IAAI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F;gBACF;YAEA,KAAK;gBAAQ;oBACX,OAAOH,MAAMmB,IAAI,CAACpB,OAAO,CAAC,CAACqB;wBACzB,IAAI1B,WAAW0B,MAAM;4BACnBvB,KAAKa,YAAY,GAAG,CAAC,EAAEb,KAAKa,YAAY,CAAC,CAAC,EAAEf,YAAYyB,IAAIjB,IAAI,EAAE,CAAC,CAAC;4BACpEN,KAAKc,IAAI,GAAG,CAAC,EAAEd,KAAKc,IAAI,GAAG,CAAC,EAAEd,KAAKc,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,EAAES,IAAIjB,IAAI,CAAC,CAAC;4BAC5DN,KAAKK,YAAY,GAAG,CAAC,EAAEL,KAAKK,YAAY,CAAC,CAAC,EAAEP,YAAYyB,IAAIjB,IAAI,EAAE,CAAC;4BAEnE,IAAIiB,IAAIhB,SAAS,IAAIP,KAAKQ,OAAO,CAACC,MAAM,CAACC,YAAY,EAAE;gCACrDV,KAAKK,YAAY,IAAIL,KAAKW,OAAO,CAACC,aAAa;4BACjD;wBACF;wBAEAb,eAAe;4BACb,GAAGC,IAAI;4BACPC,QAAQsB,IAAItB,MAAM;wBACpB;oBACF;gBACF;YAEA,KAAK;YACL,KAAK;gBAAU;oBACb,IAAI,OAAOE,MAAMqB,UAAU,KAAK,UAAU;wBACxC,IAAIrB,MAAMC,IAAI,KAAK,YAAY,CAACD,MAAMsB,OAAO,EAAE;4BAC7CzB,KAAK0B,YAAY,CAACC,GAAG,CAAC,CAAC,EAAE3B,KAAKc,IAAI,GAAG,CAAC,EAAEd,KAAKc,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,EAAEX,MAAMG,IAAI,CAAC,CAAC;wBAC1E;oBACF;oBAEA,OAAO;gBACT;QACF;IACF;AACF,EAAC"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* Set of all paths which should be moved
|
3
|
+
* This will be built up into one WHERE query
|
4
|
+
*/
|
5
|
+
export type PathsToQuery = Set<string>;
|
6
|
+
export type DocsToResave = {
|
7
|
+
[id: number | string]: Record<string, unknown>[];
|
8
|
+
};
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/predefinedMigrations/v2-v3/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,GAAG,CAAC,MAAM,CAAC,CAAA;AAEtC,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CACjD,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/predefinedMigrations/v2-v3/types.ts"],"sourcesContent":["/**\n * Set of all paths which should be moved\n * This will be built up into one WHERE query\n */\nexport type PathsToQuery = Set<string>\n\nexport type DocsToResave = {\n [id: number | string]: Record<string, unknown>[]\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAGD,WAEC"}
|
@@ -1,14 +1,13 @@
|
|
1
1
|
import type { SQL } from 'drizzle-orm';
|
2
|
-
import type { Field, Where } from 'payload
|
2
|
+
import type { Field, Where } from 'payload';
|
3
3
|
import type { GenericColumn, PostgresAdapter } from '../types.js';
|
4
|
-
import type { BuildQueryJoinAliases
|
5
|
-
export declare function buildAndOrConditions({ adapter, fields,
|
4
|
+
import type { BuildQueryJoinAliases } from './buildQuery.js';
|
5
|
+
export declare function buildAndOrConditions({ adapter, fields, joins, locale, selectFields, tableName, where, }: {
|
6
6
|
adapter: PostgresAdapter;
|
7
7
|
collectionSlug?: string;
|
8
8
|
fields: Field[];
|
9
9
|
globalSlug?: string;
|
10
|
-
|
11
|
-
joins: BuildQueryJoins;
|
10
|
+
joins: BuildQueryJoinAliases;
|
12
11
|
locale?: string;
|
13
12
|
selectFields: Record<string, GenericColumn>;
|
14
13
|
tableName: string;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"buildAndOrConditions.d.ts","sourceRoot":"","sources":["../../src/queries/buildAndOrConditions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"buildAndOrConditions.d.ts","sourceRoot":"","sources":["../../src/queries/buildAndOrConditions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE3C,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAI5D,wBAAsB,oBAAoB,CAAC,EACzC,OAAO,EACP,MAAM,EACN,KAAK,EACL,MAAM,EACN,YAAY,EACZ,SAAS,EACT,KAAK,GACN,EAAE;IACD,OAAO,EAAE,eAAe,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,qBAAqB,CAAA;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC3C,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,KAAK,EAAE,CAAA;CACf,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAwBjB"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { parseParams } from './parseParams.js';
|
2
|
-
export async function buildAndOrConditions({ adapter, fields,
|
2
|
+
export async function buildAndOrConditions({ adapter, fields, joins, locale, selectFields, tableName, where }) {
|
3
3
|
const completedConditions = [];
|
4
4
|
// Loop over all AND / OR operations and add them to the AND / OR query param
|
5
5
|
// Operations should come through as an array
|
@@ -11,7 +11,6 @@ export async function buildAndOrConditions({ adapter, fields, joinAliases, joins
|
|
11
11
|
const result = await parseParams({
|
12
12
|
adapter,
|
13
13
|
fields,
|
14
|
-
joinAliases,
|
15
14
|
joins,
|
16
15
|
locale,
|
17
16
|
selectFields,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/queries/buildAndOrConditions.ts"],"sourcesContent":["import type { SQL } from 'drizzle-orm'\nimport type { Field, Where } from 'payload
|
1
|
+
{"version":3,"sources":["../../src/queries/buildAndOrConditions.ts"],"sourcesContent":["import type { SQL } from 'drizzle-orm'\nimport type { Field, Where } from 'payload'\n\nimport type { GenericColumn, PostgresAdapter } from '../types.js'\nimport type { BuildQueryJoinAliases } from './buildQuery.js'\n\nimport { parseParams } from './parseParams.js'\n\nexport async function buildAndOrConditions({\n adapter,\n fields,\n joins,\n locale,\n selectFields,\n tableName,\n where,\n}: {\n adapter: PostgresAdapter\n collectionSlug?: string\n fields: Field[]\n globalSlug?: string\n joins: BuildQueryJoinAliases\n locale?: string\n selectFields: Record<string, GenericColumn>\n tableName: string\n where: Where[]\n}): Promise<SQL[]> {\n const completedConditions = []\n // Loop over all AND / OR operations and add them to the AND / OR query param\n // Operations should come through as an array\n // eslint-disable-next-line no-restricted-syntax\n for (const condition of where) {\n // If the operation is properly formatted as an object\n if (typeof condition === 'object') {\n // eslint-disable-next-line no-await-in-loop\n const result = await parseParams({\n adapter,\n fields,\n joins,\n locale,\n selectFields,\n tableName,\n where: condition,\n })\n if (result && Object.keys(result).length > 0) {\n completedConditions.push(result)\n }\n }\n }\n return completedConditions\n}\n"],"names":["parseParams","buildAndOrConditions","adapter","fields","joins","locale","selectFields","tableName","where","completedConditions","condition","result","Object","keys","length","push"],"mappings":"AAMA,SAASA,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,eAAeC,qBAAqB,EACzCC,OAAO,EACPC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,YAAY,EACZC,SAAS,EACTC,KAAK,EAWN;IACC,MAAMC,sBAAsB,EAAE;IAC9B,6EAA6E;IAC7E,6CAA6C;IAC7C,gDAAgD;IAChD,KAAK,MAAMC,aAAaF,MAAO;QAC7B,sDAAsD;QACtD,IAAI,OAAOE,cAAc,UAAU;YACjC,4CAA4C;YAC5C,MAAMC,SAAS,MAAMX,YAAY;gBAC/BE;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC,OAAOE;YACT;YACA,IAAIC,UAAUC,OAAOC,IAAI,CAACF,QAAQG,MAAM,GAAG,GAAG;gBAC5CL,oBAAoBM,IAAI,CAACJ;YAC3B;QACF;IACF;IACA,OAAOF;AACT"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { SQL } from 'drizzle-orm';
|
2
2
|
import type { PgTableWithColumns } from 'drizzle-orm/pg-core';
|
3
|
-
import type { Field, Where } from 'payload
|
3
|
+
import type { Field, Where } from 'payload';
|
4
4
|
import { asc, desc } from 'drizzle-orm';
|
5
5
|
import type { GenericColumn, GenericTable, PostgresAdapter } from '../types.js';
|
6
6
|
export type BuildQueryJoins = Record<string, SQL>;
|
@@ -17,8 +17,7 @@ type BuildQueryArgs = {
|
|
17
17
|
where: Where;
|
18
18
|
};
|
19
19
|
type Result = {
|
20
|
-
|
21
|
-
joins: BuildQueryJoins;
|
20
|
+
joins: BuildQueryJoinAliases;
|
22
21
|
orderBy: {
|
23
22
|
column: GenericColumn;
|
24
23
|
order: typeof asc | typeof desc;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"buildQuery.d.ts","sourceRoot":"","sources":["../../src/queries/buildQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,
|
1
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5,7 @@ const buildQuery = async function buildQuery({ adapter, fields, locale, sort, ta
|
|
5
5
|
const selectFields = {
|
6
6
|
id: adapter.tables[tableName].id
|
7
7
|
};
|
8
|
-
const joins =
|
9
|
-
const joinAliases = [];
|
8
|
+
const joins = [];
|
10
9
|
const orderBy = {
|
11
10
|
column: null,
|
12
11
|
order: null
|
@@ -25,7 +24,6 @@ const buildQuery = async function buildQuery({ adapter, fields, locale, sort, ta
|
|
25
24
|
adapter,
|
26
25
|
collectionPath: sortPath,
|
27
26
|
fields,
|
28
|
-
joinAliases,
|
29
27
|
joins,
|
30
28
|
locale,
|
31
29
|
pathSegments: sortPath.replace(/__/g, '.').split('.'),
|
@@ -55,7 +53,6 @@ const buildQuery = async function buildQuery({ adapter, fields, locale, sort, ta
|
|
55
53
|
where = await parseParams({
|
56
54
|
adapter,
|
57
55
|
fields,
|
58
|
-
joinAliases,
|
59
56
|
joins,
|
60
57
|
locale,
|
61
58
|
selectFields,
|
@@ -64,7 +61,6 @@ const buildQuery = async function buildQuery({ adapter, fields, locale, sort, ta
|
|
64
61
|
});
|
65
62
|
}
|
66
63
|
return {
|
67
|
-
joinAliases,
|
68
64
|
joins,
|
69
65
|
orderBy,
|
70
66
|
selectFields,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/queries/buildQuery.ts"],"sourcesContent":["import type { SQL } from 'drizzle-orm'\nimport type { PgTableWithColumns } from 'drizzle-orm/pg-core'\nimport type { Field, Where } from 'payload
|
1
|
+
{"version":3,"sources":["../../src/queries/buildQuery.ts"],"sourcesContent":["import type { SQL } from 'drizzle-orm'\nimport type { PgTableWithColumns } from 'drizzle-orm/pg-core'\nimport type { Field, Where } from 'payload'\n\nimport { asc, desc } from 'drizzle-orm'\n\nimport type { GenericColumn, GenericTable, PostgresAdapter } from '../types.js'\n\nimport { getTableColumnFromPath } from './getTableColumnFromPath.js'\nimport { parseParams } from './parseParams.js'\n\nexport type BuildQueryJoins = Record<string, SQL>\n\nexport type BuildQueryJoinAliases = {\n condition: SQL\n table: GenericTable | PgTableWithColumns<any>\n}[]\n\ntype BuildQueryArgs = {\n adapter: PostgresAdapter\n fields: Field[]\n locale?: string\n sort?: string\n tableName: string\n where: Where\n}\n\ntype Result = {\n joins: BuildQueryJoinAliases\n orderBy: {\n column: GenericColumn\n order: typeof asc | typeof desc\n }\n selectFields: Record<string, GenericColumn>\n where: SQL\n}\nconst buildQuery = async function buildQuery({\n adapter,\n fields,\n locale,\n sort,\n tableName,\n where: incomingWhere,\n}: BuildQueryArgs): Promise<Result> {\n const selectFields: Record<string, GenericColumn> = {\n id: adapter.tables[tableName].id,\n }\n const joins: BuildQueryJoinAliases = []\n\n const orderBy: Result['orderBy'] = {\n column: null,\n order: null,\n }\n\n if (sort) {\n let sortPath\n\n if (sort[0] === '-') {\n sortPath = sort.substring(1)\n orderBy.order = desc\n } else {\n sortPath = sort\n orderBy.order = asc\n }\n\n try {\n const { columnName: sortTableColumnName, table: sortTable } = getTableColumnFromPath({\n adapter,\n collectionPath: sortPath,\n fields,\n joins,\n locale,\n pathSegments: sortPath.replace(/__/g, '.').split('.'),\n selectFields,\n tableName,\n value: sortPath,\n })\n orderBy.column = sortTable?.[sortTableColumnName]\n } catch (err) {\n // continue\n }\n }\n\n if (!orderBy?.column) {\n orderBy.order = desc\n const createdAt = adapter.tables[tableName]?.createdAt\n\n if (createdAt) {\n orderBy.column = createdAt\n } else {\n orderBy.column = adapter.tables[tableName].id\n }\n }\n\n if (orderBy.column) {\n selectFields.sort = orderBy.column\n }\n\n let where: SQL\n\n if (incomingWhere && Object.keys(incomingWhere).length > 0) {\n where = await parseParams({\n adapter,\n fields,\n joins,\n locale,\n selectFields,\n tableName,\n where: incomingWhere,\n })\n }\n\n return {\n joins,\n orderBy,\n selectFields,\n where,\n }\n}\n\nexport default buildQuery\n"],"names":["asc","desc","getTableColumnFromPath","parseParams","buildQuery","adapter","fields","locale","sort","tableName","where","incomingWhere","selectFields","id","tables","joins","orderBy","column","order","sortPath","substring","columnName","sortTableColumnName","table","sortTable","collectionPath","pathSegments","replace","split","value","err","createdAt","Object","keys","length"],"mappings":"AAIA,SAASA,GAAG,EAAEC,IAAI,QAAQ,cAAa;AAIvC,SAASC,sBAAsB,QAAQ,8BAA6B;AACpE,SAASC,WAAW,QAAQ,mBAAkB;AA2B9C,MAAMC,aAAa,eAAeA,WAAW,EAC3CC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,IAAI,EACJC,SAAS,EACTC,OAAOC,aAAa,EACL;IACf,MAAMC,eAA8C;QAClDC,IAAIR,QAAQS,MAAM,CAACL,UAAU,CAACI,EAAE;IAClC;IACA,MAAME,QAA+B,EAAE;IAEvC,MAAMC,UAA6B;QACjCC,QAAQ;QACRC,OAAO;IACT;IAEA,IAAIV,MAAM;QACR,IAAIW;QAEJ,IAAIX,IAAI,CAAC,EAAE,KAAK,KAAK;YACnBW,WAAWX,KAAKY,SAAS,CAAC;YAC1BJ,QAAQE,KAAK,GAAGjB;QAClB,OAAO;YACLkB,WAAWX;YACXQ,QAAQE,KAAK,GAAGlB;QAClB;QAEA,IAAI;YACF,MAAM,EAAEqB,YAAYC,mBAAmB,EAAEC,OAAOC,SAAS,EAAE,GAAGtB,uBAAuB;gBACnFG;gBACAoB,gBAAgBN;gBAChBb;gBACAS;gBACAR;gBACAmB,cAAcP,SAASQ,OAAO,CAAC,OAAO,KAAKC,KAAK,CAAC;gBACjDhB;gBACAH;gBACAoB,OAAOV;YACT;YACAH,QAAQC,MAAM,GAAGO,WAAW,CAACF,oBAAoB;QACnD,EAAE,OAAOQ,KAAK;QACZ,WAAW;QACb;IACF;IAEA,IAAI,CAACd,SAASC,QAAQ;QACpBD,QAAQE,KAAK,GAAGjB;QAChB,MAAM8B,YAAY1B,QAAQS,MAAM,CAACL,UAAU,EAAEsB;QAE7C,IAAIA,WAAW;YACbf,QAAQC,MAAM,GAAGc;QACnB,OAAO;YACLf,QAAQC,MAAM,GAAGZ,QAAQS,MAAM,CAACL,UAAU,CAACI,EAAE;QAC/C;IACF;IAEA,IAAIG,QAAQC,MAAM,EAAE;QAClBL,aAAaJ,IAAI,GAAGQ,QAAQC,MAAM;IACpC;IAEA,IAAIP;IAEJ,IAAIC,iBAAiBqB,OAAOC,IAAI,CAACtB,eAAeuB,MAAM,GAAG,GAAG;QAC1DxB,QAAQ,MAAMP,YAAY;YACxBE;YACAC;YACAS;YACAR;YACAK;YACAH;YACAC,OAAOC;QACT;IACF;IAEA,OAAO;QACLI;QACAC;QACAJ;QACAF;IACF;AACF;AAEA,eAAeN,WAAU"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/queries/createJSONQuery/convertPathToJSONTraversal.ts"],"sourcesContent":["import { formatJSONPathSegment } from './formatJSONPathSegment.js'\n\nexport const convertPathToJSONTraversal = (incomingSegments: string[]) => {\n const segments = [...incomingSegments]\n segments.shift()\n\n return segments.reduce((res, segment, i) => {\n const formattedSegment = formatJSONPathSegment(segment)\n\n if (i + 1 === segments.length) return `${res}->>${formattedSegment}`\n return `${res}->${formattedSegment}`\n }, '')\n}\n"],"names":["formatJSONPathSegment","convertPathToJSONTraversal","incomingSegments","segments","shift","reduce","res","segment","i","formattedSegment","length"],"
|
1
|
+
{"version":3,"sources":["../../../src/queries/createJSONQuery/convertPathToJSONTraversal.ts"],"sourcesContent":["import { formatJSONPathSegment } from './formatJSONPathSegment.js'\n\nexport const convertPathToJSONTraversal = (incomingSegments: string[]) => {\n const segments = [...incomingSegments]\n segments.shift()\n\n return segments.reduce((res, segment, i) => {\n const formattedSegment = formatJSONPathSegment(segment)\n\n if (i + 1 === segments.length) return `${res}->>${formattedSegment}`\n return `${res}->${formattedSegment}`\n }, '')\n}\n"],"names":["formatJSONPathSegment","convertPathToJSONTraversal","incomingSegments","segments","shift","reduce","res","segment","i","formattedSegment","length"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,6BAA4B;AAElE,OAAO,MAAMC,6BAA6B,CAACC;IACzC,MAAMC,WAAW;WAAID;KAAiB;IACtCC,SAASC,KAAK;IAEd,OAAOD,SAASE,MAAM,CAAC,CAACC,KAAKC,SAASC;QACpC,MAAMC,mBAAmBT,sBAAsBO;QAE/C,IAAIC,IAAI,MAAML,SAASO,MAAM,EAAE,OAAO,CAAC,EAAEJ,IAAI,GAAG,EAAEG,iBAAiB,CAAC;QACpE,OAAO,CAAC,EAAEH,IAAI,EAAE,EAAEG,iBAAiB,CAAC;IACtC,GAAG;AACL,EAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/queries/createJSONQuery/formatJSONPathSegment.ts"],"sourcesContent":["export const formatJSONPathSegment = (segment: string) => {\n return Number.isNaN(parseInt(segment)) ? `'${segment}'` : segment\n}\n"],"names":["formatJSONPathSegment","segment","Number","isNaN","parseInt"],"
|
1
|
+
{"version":3,"sources":["../../../src/queries/createJSONQuery/formatJSONPathSegment.ts"],"sourcesContent":["export const formatJSONPathSegment = (segment: string) => {\n return Number.isNaN(parseInt(segment)) ? `'${segment}'` : segment\n}\n"],"names":["formatJSONPathSegment","segment","Number","isNaN","parseInt"],"mappings":"AAAA,OAAO,MAAMA,wBAAwB,CAACC;IACpC,OAAOC,OAAOC,KAAK,CAACC,SAASH,YAAY,CAAC,CAAC,EAAEA,QAAQ,CAAC,CAAC,GAAGA;AAC5D,EAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/queries/createJSONQuery/index.ts"],"sourcesContent":["import { convertPathToJSONTraversal } from './convertPathToJSONTraversal.js'\nimport { formatJSONPathSegment } from './formatJSONPathSegment.js'\n\nconst operatorMap = {\n contains: '~*',\n equals: '=',\n like: '~*',\n}\n\ntype FromArrayArgs = {\n isRoot?: true\n operator: string\n pathSegments: string[]\n treatAsArray?: string[]\n value: unknown\n}\n\nconst fromArray = ({ isRoot, operator, pathSegments, treatAsArray, value }: FromArrayArgs) => {\n const newPathSegments = pathSegments.slice(isRoot ? 1 : 2)\n const alias = `${pathSegments[isRoot ? 0 : 1]}_alias_${newPathSegments.length}`\n\n newPathSegments.unshift(alias)\n\n const arrayElements = isRoot\n ? pathSegments[0]\n : `${pathSegments[0]} -> ${formatJSONPathSegment(pathSegments[1])}`\n\n return `EXISTS (\n SELECT 1\n FROM jsonb_array_elements(${arrayElements}) AS ${alias}\n WHERE ${createJSONQuery({\n operator,\n pathSegments: newPathSegments,\n treatAsArray,\n value,\n })}\n )`\n}\n\ntype CreateConstraintArgs = {\n operator: string\n pathSegments: string[]\n treatAsArray?: string[]\n value: unknown\n}\n\nconst createConstraint = ({ operator, pathSegments, value }: CreateConstraintArgs): string => {\n const jsonQuery = convertPathToJSONTraversal(pathSegments)\n return `${pathSegments[0]}${jsonQuery} ${operatorMap[operator]} '${value}'`\n}\n\ntype Args = {\n operator: string\n pathSegments: string[]\n treatAsArray?: string[]\n treatRootAsArray?: boolean\n value: unknown\n}\n\nexport const createJSONQuery = ({\n operator,\n pathSegments,\n treatAsArray,\n treatRootAsArray,\n value,\n}: Args): string => {\n if (treatRootAsArray) {\n return fromArray({\n isRoot: true,\n operator,\n pathSegments,\n treatAsArray,\n value,\n })\n }\n\n if (treatAsArray.includes(pathSegments[1])) {\n return fromArray({\n operator,\n pathSegments,\n treatAsArray,\n value,\n })\n }\n\n return createConstraint({ operator, pathSegments, treatAsArray, value })\n}\n"],"names":["convertPathToJSONTraversal","formatJSONPathSegment","operatorMap","contains","equals","like","fromArray","isRoot","operator","pathSegments","treatAsArray","value","newPathSegments","slice","alias","length","unshift","arrayElements","createJSONQuery","createConstraint","jsonQuery","treatRootAsArray","includes"],"
|
1
|
+
{"version":3,"sources":["../../../src/queries/createJSONQuery/index.ts"],"sourcesContent":["import { convertPathToJSONTraversal } from './convertPathToJSONTraversal.js'\nimport { formatJSONPathSegment } from './formatJSONPathSegment.js'\n\nconst operatorMap = {\n contains: '~*',\n equals: '=',\n like: '~*',\n}\n\ntype FromArrayArgs = {\n isRoot?: true\n operator: string\n pathSegments: string[]\n treatAsArray?: string[]\n value: unknown\n}\n\nconst fromArray = ({ isRoot, operator, pathSegments, treatAsArray, value }: FromArrayArgs) => {\n const newPathSegments = pathSegments.slice(isRoot ? 1 : 2)\n const alias = `${pathSegments[isRoot ? 0 : 1]}_alias_${newPathSegments.length}`\n\n newPathSegments.unshift(alias)\n\n const arrayElements = isRoot\n ? pathSegments[0]\n : `${pathSegments[0]} -> ${formatJSONPathSegment(pathSegments[1])}`\n\n return `EXISTS (\n SELECT 1\n FROM jsonb_array_elements(${arrayElements}) AS ${alias}\n WHERE ${createJSONQuery({\n operator,\n pathSegments: newPathSegments,\n treatAsArray,\n value,\n })}\n )`\n}\n\ntype CreateConstraintArgs = {\n operator: string\n pathSegments: string[]\n treatAsArray?: string[]\n value: unknown\n}\n\nconst createConstraint = ({ operator, pathSegments, value }: CreateConstraintArgs): string => {\n const jsonQuery = convertPathToJSONTraversal(pathSegments)\n return `${pathSegments[0]}${jsonQuery} ${operatorMap[operator]} '${value}'`\n}\n\ntype Args = {\n operator: string\n pathSegments: string[]\n treatAsArray?: string[]\n treatRootAsArray?: boolean\n value: unknown\n}\n\nexport const createJSONQuery = ({\n operator,\n pathSegments,\n treatAsArray,\n treatRootAsArray,\n value,\n}: Args): string => {\n if (treatRootAsArray) {\n return fromArray({\n isRoot: true,\n operator,\n pathSegments,\n treatAsArray,\n value,\n })\n }\n\n if (treatAsArray.includes(pathSegments[1])) {\n return fromArray({\n operator,\n pathSegments,\n treatAsArray,\n value,\n })\n }\n\n return createConstraint({ operator, pathSegments, treatAsArray, value })\n}\n"],"names":["convertPathToJSONTraversal","formatJSONPathSegment","operatorMap","contains","equals","like","fromArray","isRoot","operator","pathSegments","treatAsArray","value","newPathSegments","slice","alias","length","unshift","arrayElements","createJSONQuery","createConstraint","jsonQuery","treatRootAsArray","includes"],"mappings":"AAAA,SAASA,0BAA0B,QAAQ,kCAAiC;AAC5E,SAASC,qBAAqB,QAAQ,6BAA4B;AAElE,MAAMC,cAAc;IAClBC,UAAU;IACVC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
@@ -1,8 +1,8 @@
|
|
1
1
|
import type { SQL } from 'drizzle-orm';
|
2
2
|
import type { PgTableWithColumns } from 'drizzle-orm/pg-core';
|
3
|
-
import type { Field, FieldAffectingData, TabAsField } from 'payload
|
3
|
+
import type { Field, FieldAffectingData, TabAsField } from 'payload';
|
4
4
|
import type { GenericColumn, GenericTable, PostgresAdapter } from '../types.js';
|
5
|
-
import type { BuildQueryJoinAliases
|
5
|
+
import type { BuildQueryJoinAliases } from './buildQuery.js';
|
6
6
|
type Constraint = {
|
7
7
|
columnName: string;
|
8
8
|
table: GenericTable | PgTableWithColumns<any>;
|
@@ -25,8 +25,7 @@ type Args = {
|
|
25
25
|
constraintPath?: string;
|
26
26
|
constraints?: Constraint[];
|
27
27
|
fields: (Field | TabAsField)[];
|
28
|
-
|
29
|
-
joins: BuildQueryJoins;
|
28
|
+
joins: BuildQueryJoinAliases;
|
30
29
|
locale?: string;
|
31
30
|
pathSegments: string[];
|
32
31
|
rootTableName?: string;
|
@@ -46,6 +45,6 @@ type Args = {
|
|
46
45
|
* Adds tables to `join`
|
47
46
|
* @returns TableColumn
|
48
47
|
*/
|
49
|
-
export declare const getTableColumnFromPath: ({ adapter, aliasTable, collectionPath, columnPrefix, constraintPath: incomingConstraintPath, constraints, fields,
|
48
|
+
export declare const getTableColumnFromPath: ({ adapter, aliasTable, collectionPath, columnPrefix, constraintPath: incomingConstraintPath, constraints, fields, joins, locale: incomingLocale, pathSegments: incomingSegments, rootTableName: incomingRootTableName, selectFields, tableName, tableNameSuffix, value, }: Args) => TableColumn;
|
50
49
|
export {};
|
51
50
|
//# sourceMappingURL=getTableColumnFromPath.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getTableColumnFromPath.d.ts","sourceRoot":"","sources":["../../src/queries/getTableColumnFromPath.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,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