@payloadcms/db-postgres 3.0.0-canary.ee0375f → 3.0.0-canary.ef0a8d0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +4 -6
- package/dist/connect.js.map +1 -1
- package/dist/countDistinct.d.ts +3 -0
- package/dist/countDistinct.d.ts.map +1 -0
- package/dist/countDistinct.js +26 -0
- package/dist/countDistinct.js.map +1 -0
- package/dist/createJSONQuery/convertPathToJSONTraversal.d.ts.map +1 -0
- package/dist/createJSONQuery/convertPathToJSONTraversal.js.map +1 -0
- package/dist/createJSONQuery/formatJSONPathSegment.d.ts.map +1 -0
- package/dist/createJSONQuery/formatJSONPathSegment.js.map +1 -0
- package/dist/createJSONQuery/index.d.ts.map +1 -0
- package/dist/createJSONQuery/index.js.map +1 -0
- package/dist/createMigration.d.ts.map +1 -1
- package/dist/createMigration.js +7 -29
- package/dist/createMigration.js.map +1 -1
- package/dist/defaultSnapshot.d.ts +3 -0
- package/dist/defaultSnapshot.d.ts.map +1 -0
- package/dist/defaultSnapshot.js +16 -0
- package/dist/defaultSnapshot.js.map +1 -0
- package/dist/deleteWhere.d.ts +3 -0
- package/dist/deleteWhere.d.ts.map +1 -0
- package/dist/deleteWhere.js +7 -0
- package/dist/deleteWhere.js.map +1 -0
- package/dist/dropDatabase.d.ts +3 -0
- package/dist/dropDatabase.d.ts.map +1 -0
- package/dist/dropDatabase.js +9 -0
- package/dist/dropDatabase.js.map +1 -0
- package/dist/execute.d.ts +3 -0
- package/dist/execute.d.ts.map +1 -0
- package/dist/execute.js +13 -0
- package/dist/execute.js.map +1 -0
- package/dist/exports/migration-utils.js.map +1 -1
- package/dist/generateDrizzleJSON.d.ts +3 -0
- package/dist/generateDrizzleJSON.d.ts.map +1 -0
- package/dist/generateDrizzleJSON.js +8 -0
- package/dist/generateDrizzleJSON.js.map +1 -0
- package/dist/generateMigration.d.ts +3 -0
- package/dist/generateMigration.d.ts.map +1 -0
- package/dist/generateMigration.js +8 -0
- package/dist/generateMigration.js.map +1 -0
- package/dist/getMigrationTemplate.d.ts +3 -0
- package/dist/getMigrationTemplate.d.ts.map +1 -0
- package/dist/getMigrationTemplate.js +12 -0
- package/dist/getMigrationTemplate.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -62
- package/dist/index.js.map +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/insert.d.ts +3 -0
- package/dist/insert.d.ts.map +1 -0
- package/dist/insert.js +13 -0
- package/dist/insert.js.map +1 -0
- package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +5 -4
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +5 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/index.d.ts +2 -2
- package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/index.js +7 -1
- package/dist/predefinedMigrations/v2-v3/index.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +5 -4
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.js +1 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +3 -2
- package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/types.js.map +1 -1
- package/dist/requireDrizzleKit.d.ts +3 -0
- package/dist/requireDrizzleKit.d.ts.map +1 -0
- package/dist/requireDrizzleKit.js +5 -0
- package/dist/requireDrizzleKit.js.map +1 -0
- package/dist/schema/build.d.ts.map +1 -1
- package/dist/schema/build.js +2 -2
- package/dist/schema/build.js.map +1 -1
- package/dist/schema/createIndex.js.map +1 -1
- package/dist/schema/idToUUID.js.map +1 -1
- package/dist/schema/parentIDColumnMap.js.map +1 -1
- package/dist/schema/setColumnID.js.map +1 -1
- package/dist/schema/traverseFields.d.ts.map +1 -1
- package/dist/schema/traverseFields.js +2 -4
- package/dist/schema/traverseFields.js.map +1 -1
- package/dist/types.d.ts +72 -29
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +9 -9
- package/dist/count.d.ts +0 -3
- package/dist/count.d.ts.map +0 -1
- package/dist/count.js +0 -41
- package/dist/count.js.map +0 -1
- package/dist/create.d.ts +0 -3
- package/dist/create.d.ts.map +0 -1
- package/dist/create.js +0 -19
- package/dist/create.js.map +0 -1
- package/dist/createGlobal.d.ts +0 -4
- package/dist/createGlobal.d.ts.map +0 -1
- package/dist/createGlobal.js +0 -19
- package/dist/createGlobal.js.map +0 -1
- package/dist/createGlobalVersion.d.ts +0 -5
- package/dist/createGlobalVersion.d.ts.map +0 -1
- package/dist/createGlobalVersion.js +0 -33
- package/dist/createGlobalVersion.js.map +0 -1
- package/dist/createVersion.d.ts +0 -4
- package/dist/createVersion.d.ts.map +0 -1
- package/dist/createVersion.js +0 -40
- package/dist/createVersion.js.map +0 -1
- package/dist/deleteMany.d.ts +0 -3
- package/dist/deleteMany.d.ts.map +0 -1
- package/dist/deleteMany.js +0 -28
- package/dist/deleteMany.js.map +0 -1
- package/dist/deleteOne.d.ts +0 -3
- package/dist/deleteOne.d.ts.map +0 -1
- package/dist/deleteOne.js +0 -59
- package/dist/deleteOne.js.map +0 -1
- package/dist/deleteVersions.d.ts +0 -3
- package/dist/deleteVersions.d.ts.map +0 -1
- package/dist/deleteVersions.js +0 -31
- package/dist/deleteVersions.js.map +0 -1
- package/dist/destroy.d.ts +0 -3
- package/dist/destroy.d.ts.map +0 -1
- package/dist/destroy.js +0 -15
- package/dist/destroy.js.map +0 -1
- package/dist/find/buildFindManyArgs.d.ts +0 -17
- package/dist/find/buildFindManyArgs.d.ts.map +0 -1
- package/dist/find/buildFindManyArgs.js +0 -65
- package/dist/find/buildFindManyArgs.js.map +0 -1
- package/dist/find/chainMethods.d.ts +0 -16
- package/dist/find/chainMethods.d.ts.map +0 -1
- package/dist/find/chainMethods.js +0 -12
- package/dist/find/chainMethods.js.map +0 -1
- package/dist/find/findMany.d.ts +0 -21
- package/dist/find/findMany.d.ts.map +0 -1
- package/dist/find/findMany.js +0 -152
- package/dist/find/findMany.js.map +0 -1
- package/dist/find/traverseFields.d.ts +0 -17
- package/dist/find/traverseFields.d.ts.map +0 -1
- package/dist/find/traverseFields.js +0 -156
- package/dist/find/traverseFields.js.map +0 -1
- package/dist/find.d.ts +0 -3
- package/dist/find.d.ts.map +0 -1
- package/dist/find.js +0 -21
- package/dist/find.js.map +0 -1
- package/dist/findGlobal.d.ts +0 -3
- package/dist/findGlobal.d.ts.map +0 -1
- package/dist/findGlobal.js +0 -23
- package/dist/findGlobal.js.map +0 -1
- package/dist/findGlobalVersions.d.ts +0 -3
- package/dist/findGlobalVersions.d.ts.map +0 -1
- package/dist/findGlobalVersions.js +0 -24
- package/dist/findGlobalVersions.js.map +0 -1
- package/dist/findOne.d.ts +0 -4
- package/dist/findOne.d.ts.map +0 -1
- package/dist/findOne.js +0 -21
- package/dist/findOne.js.map +0 -1
- package/dist/findVersions.d.ts +0 -3
- package/dist/findVersions.d.ts.map +0 -1
- package/dist/findVersions.js +0 -24
- package/dist/findVersions.js.map +0 -1
- package/dist/migrate.d.ts +0 -3
- package/dist/migrate.d.ts.map +0 -1
- package/dist/migrate.js +0 -99
- package/dist/migrate.js.map +0 -1
- package/dist/migrateDown.d.ts +0 -3
- package/dist/migrateDown.d.ts.map +0 -1
- package/dist/migrateDown.js +0 -63
- package/dist/migrateDown.js.map +0 -1
- package/dist/migrateFresh.d.ts +0 -8
- package/dist/migrateFresh.d.ts.map +0 -1
- package/dist/migrateFresh.js +0 -72
- package/dist/migrateFresh.js.map +0 -1
- package/dist/migrateRefresh.d.ts +0 -6
- package/dist/migrateRefresh.d.ts.map +0 -1
- package/dist/migrateRefresh.js +0 -102
- package/dist/migrateRefresh.js.map +0 -1
- package/dist/migrateReset.d.ts +0 -6
- package/dist/migrateReset.d.ts.map +0 -1
- package/dist/migrateReset.js +0 -82
- package/dist/migrateReset.js.map +0 -1
- package/dist/migrateStatus.d.ts +0 -3
- package/dist/migrateStatus.d.ts.map +0 -1
- package/dist/migrateStatus.js +0 -44
- package/dist/migrateStatus.js.map +0 -1
- package/dist/queries/buildAndOrConditions.d.ts +0 -16
- package/dist/queries/buildAndOrConditions.d.ts.map +0 -1
- package/dist/queries/buildAndOrConditions.js +0 -28
- package/dist/queries/buildAndOrConditions.js.map +0 -1
- package/dist/queries/buildQuery.d.ts +0 -30
- package/dist/queries/buildQuery.d.ts.map +0 -1
- package/dist/queries/buildQuery.js +0 -72
- package/dist/queries/buildQuery.js.map +0 -1
- package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts.map +0 -1
- package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
- package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
- package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +0 -1
- package/dist/queries/createJSONQuery/index.d.ts.map +0 -1
- package/dist/queries/createJSONQuery/index.js.map +0 -1
- package/dist/queries/getTableColumnFromPath.d.ts +0 -50
- package/dist/queries/getTableColumnFromPath.d.ts.map +0 -1
- package/dist/queries/getTableColumnFromPath.js +0 -516
- package/dist/queries/getTableColumnFromPath.js.map +0 -1
- package/dist/queries/operatorMap.d.ts +0 -18
- package/dist/queries/operatorMap.d.ts.map +0 -1
- package/dist/queries/operatorMap.js +0 -24
- package/dist/queries/operatorMap.js.map +0 -1
- package/dist/queries/parseParams.d.ts +0 -16
- package/dist/queries/parseParams.d.ts.map +0 -1
- package/dist/queries/parseParams.js +0 -183
- package/dist/queries/parseParams.js.map +0 -1
- package/dist/queries/sanitizeQueryValue.d.ts +0 -15
- package/dist/queries/sanitizeQueryValue.d.ts.map +0 -1
- package/dist/queries/sanitizeQueryValue.js +0 -89
- package/dist/queries/sanitizeQueryValue.js.map +0 -1
- package/dist/queries/selectDistinct.d.ts +0 -22
- package/dist/queries/selectDistinct.d.ts.map +0 -1
- package/dist/queries/selectDistinct.js +0 -30
- package/dist/queries/selectDistinct.js.map +0 -1
- package/dist/queryDrafts.d.ts +0 -3
- package/dist/queryDrafts.d.ts.map +0 -1
- package/dist/queryDrafts.js +0 -40
- package/dist/queryDrafts.js.map +0 -1
- package/dist/schema/createTableName.d.ts +0 -30
- package/dist/schema/createTableName.d.ts.map +0 -1
- package/dist/schema/createTableName.js +0 -31
- package/dist/schema/createTableName.js.map +0 -1
- package/dist/schema/validateExistingBlockIsIdentical.d.ts +0 -12
- package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +0 -1
- package/dist/schema/validateExistingBlockIsIdentical.js +0 -76
- package/dist/schema/validateExistingBlockIsIdentical.js.map +0 -1
- package/dist/transactions/beginTransaction.d.ts +0 -3
- package/dist/transactions/beginTransaction.d.ts.map +0 -1
- package/dist/transactions/beginTransaction.js +0 -51
- package/dist/transactions/beginTransaction.js.map +0 -1
- package/dist/transactions/commitTransaction.d.ts +0 -3
- package/dist/transactions/commitTransaction.d.ts.map +0 -1
- package/dist/transactions/commitTransaction.js +0 -14
- package/dist/transactions/commitTransaction.js.map +0 -1
- package/dist/transactions/rollbackTransaction.d.ts +0 -3
- package/dist/transactions/rollbackTransaction.d.ts.map +0 -1
- package/dist/transactions/rollbackTransaction.js +0 -13
- package/dist/transactions/rollbackTransaction.js.map +0 -1
- package/dist/transform/read/hasManyNumber.d.ts +0 -10
- package/dist/transform/read/hasManyNumber.d.ts.map +0 -1
- package/dist/transform/read/hasManyNumber.js +0 -10
- package/dist/transform/read/hasManyNumber.js.map +0 -1
- package/dist/transform/read/hasManyText.d.ts +0 -10
- package/dist/transform/read/hasManyText.d.ts.map +0 -1
- package/dist/transform/read/hasManyText.js +0 -10
- package/dist/transform/read/hasManyText.js.map +0 -1
- package/dist/transform/read/index.d.ts +0 -13
- package/dist/transform/read/index.d.ts.map +0 -1
- package/dist/transform/read/index.js +0 -44
- package/dist/transform/read/index.js.map +0 -1
- package/dist/transform/read/relationship.d.ts +0 -10
- package/dist/transform/read/relationship.d.ts.map +0 -1
- package/dist/transform/read/relationship.js +0 -60
- package/dist/transform/read/relationship.js.map +0 -1
- package/dist/transform/read/traverseFields.d.ts +0 -57
- package/dist/transform/read/traverseFields.d.ts.map +0 -1
- package/dist/transform/read/traverseFields.js +0 -435
- package/dist/transform/read/traverseFields.js.map +0 -1
- package/dist/transform/write/array.d.ts +0 -26
- package/dist/transform/write/array.d.ts.map +0 -1
- package/dist/transform/write/array.js +0 -58
- package/dist/transform/write/array.js.map +0 -1
- package/dist/transform/write/blocks.d.ts +0 -25
- package/dist/transform/write/blocks.d.ts.map +0 -1
- package/dist/transform/write/blocks.js +0 -54
- package/dist/transform/write/blocks.js.map +0 -1
- package/dist/transform/write/index.d.ts +0 -13
- package/dist/transform/write/index.d.ts.map +0 -1
- package/dist/transform/write/index.js +0 -41
- package/dist/transform/write/index.js.map +0 -1
- package/dist/transform/write/numbers.d.ts +0 -8
- package/dist/transform/write/numbers.d.ts.map +0 -1
- package/dist/transform/write/numbers.js +0 -11
- package/dist/transform/write/numbers.js.map +0 -1
- package/dist/transform/write/relationships.d.ts +0 -10
- package/dist/transform/write/relationships.d.ts.map +0 -1
- package/dist/transform/write/relationships.js +0 -23
- package/dist/transform/write/relationships.js.map +0 -1
- package/dist/transform/write/selects.d.ts +0 -8
- package/dist/transform/write/selects.d.ts.map +0 -1
- package/dist/transform/write/selects.js +0 -20
- package/dist/transform/write/selects.js.map +0 -1
- package/dist/transform/write/texts.d.ts +0 -8
- package/dist/transform/write/texts.d.ts.map +0 -1
- package/dist/transform/write/texts.js +0 -11
- package/dist/transform/write/texts.js.map +0 -1
- package/dist/transform/write/traverseFields.d.ts +0 -50
- package/dist/transform/write/traverseFields.d.ts.map +0 -1
- package/dist/transform/write/traverseFields.js +0 -445
- package/dist/transform/write/traverseFields.js.map +0 -1
- package/dist/transform/write/types.d.ts +0 -43
- package/dist/transform/write/types.d.ts.map +0 -1
- package/dist/transform/write/types.js +0 -3
- package/dist/transform/write/types.js.map +0 -1
- package/dist/update.d.ts +0 -3
- package/dist/update.d.ts.map +0 -1
- package/dist/update.js +0 -54
- package/dist/update.js.map +0 -1
- package/dist/updateGlobal.d.ts +0 -4
- package/dist/updateGlobal.d.ts.map +0 -1
- package/dist/updateGlobal.js +0 -25
- package/dist/updateGlobal.js.map +0 -1
- package/dist/updateGlobalVersion.d.ts +0 -4
- package/dist/updateGlobalVersion.d.ts.map +0 -1
- package/dist/updateGlobalVersion.js +0 -36
- package/dist/updateGlobalVersion.js.map +0 -1
- package/dist/updateVersion.d.ts +0 -4
- package/dist/updateVersion.d.ts.map +0 -1
- package/dist/updateVersion.js +0 -36
- package/dist/updateVersion.js.map +0 -1
- package/dist/upsertRow/deleteExistingArrayRows.d.ts +0 -10
- package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +0 -1
- package/dist/upsertRow/deleteExistingArrayRows.js +0 -10
- package/dist/upsertRow/deleteExistingArrayRows.js.map +0 -1
- package/dist/upsertRow/deleteExistingRowsByPath.d.ts +0 -14
- package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +0 -1
- package/dist/upsertRow/deleteExistingRowsByPath.js +0 -33
- package/dist/upsertRow/deleteExistingRowsByPath.js.map +0 -1
- package/dist/upsertRow/index.d.ts +0 -4
- package/dist/upsertRow/index.d.ts.map +0 -1
- package/dist/upsertRow/index.js +0 -279
- package/dist/upsertRow/index.js.map +0 -1
- package/dist/upsertRow/insertArrays.d.ts +0 -13
- package/dist/upsertRow/insertArrays.d.ts.map +0 -1
- package/dist/upsertRow/insertArrays.js +0 -68
- package/dist/upsertRow/insertArrays.js.map +0 -1
- package/dist/upsertRow/types.d.ts +0 -32
- package/dist/upsertRow/types.d.ts.map +0 -1
- package/dist/upsertRow/types.js +0 -3
- package/dist/upsertRow/types.js.map +0 -1
- package/dist/utilities/appendPrefixToKeys.d.ts +0 -2
- package/dist/utilities/appendPrefixToKeys.d.ts.map +0 -1
- package/dist/utilities/appendPrefixToKeys.js +0 -6
- package/dist/utilities/appendPrefixToKeys.js.map +0 -1
- package/dist/utilities/createBlocksMap.d.ts +0 -5
- package/dist/utilities/createBlocksMap.d.ts.map +0 -1
- package/dist/utilities/createBlocksMap.js +0 -29
- package/dist/utilities/createBlocksMap.js.map +0 -1
- package/dist/utilities/createMigrationTable.d.ts +0 -3
- package/dist/utilities/createMigrationTable.d.ts.map +0 -1
- package/dist/utilities/createMigrationTable.js +0 -13
- package/dist/utilities/createMigrationTable.js.map +0 -1
- package/dist/utilities/createRelationshipMap.d.ts +0 -2
- package/dist/utilities/createRelationshipMap.d.ts.map +0 -1
- package/dist/utilities/createRelationshipMap.js +0 -19
- package/dist/utilities/createRelationshipMap.js.map +0 -1
- package/dist/utilities/hasLocalesTable.d.ts +0 -3
- package/dist/utilities/hasLocalesTable.d.ts.map +0 -1
- package/dist/utilities/hasLocalesTable.js +0 -11
- package/dist/utilities/hasLocalesTable.js.map +0 -1
- package/dist/utilities/isArrayOfRows.d.ts +0 -2
- package/dist/utilities/isArrayOfRows.d.ts.map +0 -1
- package/dist/utilities/isArrayOfRows.js +0 -5
- package/dist/utilities/isArrayOfRows.js.map +0 -1
- package/dist/utilities/migrationTableExists.d.ts +0 -3
- package/dist/utilities/migrationTableExists.d.ts.map +0 -1
- package/dist/utilities/migrationTableExists.js +0 -9
- package/dist/utilities/migrationTableExists.js.map +0 -1
- package/dist/utilities/parseError.d.ts +0 -5
- package/dist/utilities/parseError.d.ts.map +0 -1
- package/dist/utilities/parseError.js +0 -17
- package/dist/utilities/parseError.js.map +0 -1
- package/dist/utilities/pushDevSchema.d.ts +0 -9
- package/dist/utilities/pushDevSchema.d.ts.map +0 -1
- package/dist/utilities/pushDevSchema.js +0 -58
- package/dist/utilities/pushDevSchema.js.map +0 -1
- /package/dist/{queries/createJSONQuery → createJSONQuery}/convertPathToJSONTraversal.d.ts +0 -0
- /package/dist/{queries/createJSONQuery → createJSONQuery}/convertPathToJSONTraversal.js +0 -0
- /package/dist/{queries/createJSONQuery → createJSONQuery}/formatJSONPathSegment.d.ts +0 -0
- /package/dist/{queries/createJSONQuery → createJSONQuery}/formatJSONPathSegment.js +0 -0
- /package/dist/{queries/createJSONQuery → createJSONQuery}/index.d.ts +0 -0
- /package/dist/{queries/createJSONQuery → createJSONQuery}/index.js +0 -0
@@ -1,16 +0,0 @@
|
|
1
|
-
import type { SQL } from 'drizzle-orm';
|
2
|
-
import type { Field, Where } from 'payload';
|
3
|
-
import type { GenericColumn, PostgresAdapter } from '../types.js';
|
4
|
-
import type { BuildQueryJoinAliases } from './buildQuery.js';
|
5
|
-
type Args = {
|
6
|
-
adapter: PostgresAdapter;
|
7
|
-
fields: Field[];
|
8
|
-
joins: BuildQueryJoinAliases;
|
9
|
-
locale: string;
|
10
|
-
selectFields: Record<string, GenericColumn>;
|
11
|
-
tableName: string;
|
12
|
-
where: Where;
|
13
|
-
};
|
14
|
-
export declare function parseParams({ adapter, fields, joins, locale, selectFields, tableName, where, }: Args): Promise<SQL>;
|
15
|
-
export {};
|
16
|
-
//# sourceMappingURL=parseParams.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"parseParams.d.ts","sourceRoot":"","sources":["../../src/queries/parseParams.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EAAE,KAAK,EAAY,KAAK,EAAE,MAAM,SAAS,CAAA;AAMrD,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAS5D,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,KAAK,EAAE,qBAAqB,CAAA;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC3C,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED,wBAAsB,WAAW,CAAC,EAChC,OAAO,EACP,MAAM,EACN,KAAK,EACL,MAAM,EACN,YAAY,EACZ,SAAS,EACT,KAAK,GACN,EAAE,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CA6MrB"}
|
@@ -1,183 +0,0 @@
|
|
1
|
-
/* eslint-disable no-await-in-loop */ import { and, ilike, isNotNull, isNull, ne, notInArray, or, sql } from 'drizzle-orm';
|
2
|
-
import { QueryError } from 'payload';
|
3
|
-
import { validOperators } from 'payload/shared';
|
4
|
-
import { buildAndOrConditions } from './buildAndOrConditions.js';
|
5
|
-
import { convertPathToJSONTraversal } from './createJSONQuery/convertPathToJSONTraversal.js';
|
6
|
-
import { createJSONQuery } from './createJSONQuery/index.js';
|
7
|
-
import { getTableColumnFromPath } from './getTableColumnFromPath.js';
|
8
|
-
import { operatorMap } from './operatorMap.js';
|
9
|
-
import { sanitizeQueryValue } from './sanitizeQueryValue.js';
|
10
|
-
export async function parseParams({ adapter, fields, joins, locale, selectFields, tableName, where }) {
|
11
|
-
let result;
|
12
|
-
const constraints = [];
|
13
|
-
if (typeof where === 'object' && Object.keys(where).length > 0) {
|
14
|
-
// We need to determine if the whereKey is an AND, OR, or a schema path
|
15
|
-
for (const relationOrPath of Object.keys(where)){
|
16
|
-
if (relationOrPath) {
|
17
|
-
const condition = where[relationOrPath];
|
18
|
-
let conditionOperator;
|
19
|
-
if (relationOrPath.toLowerCase() === 'and') {
|
20
|
-
conditionOperator = 'and';
|
21
|
-
} else if (relationOrPath.toLowerCase() === 'or') {
|
22
|
-
conditionOperator = 'or';
|
23
|
-
}
|
24
|
-
if (Array.isArray(condition)) {
|
25
|
-
const builtConditions = await buildAndOrConditions({
|
26
|
-
adapter,
|
27
|
-
fields,
|
28
|
-
joins,
|
29
|
-
locale,
|
30
|
-
selectFields,
|
31
|
-
tableName,
|
32
|
-
where: condition
|
33
|
-
});
|
34
|
-
if (builtConditions.length > 0) {
|
35
|
-
result = operatorMap[conditionOperator](...builtConditions);
|
36
|
-
}
|
37
|
-
} else {
|
38
|
-
// It's a path - and there can be multiple comparisons on a single path.
|
39
|
-
// For example - title like 'test' and title not equal to 'tester'
|
40
|
-
// So we need to loop on keys again here to handle each operator independently
|
41
|
-
const pathOperators = where[relationOrPath];
|
42
|
-
if (typeof pathOperators === 'object') {
|
43
|
-
for (let operator of Object.keys(pathOperators)){
|
44
|
-
if (validOperators.includes(operator)) {
|
45
|
-
const val = where[relationOrPath][operator];
|
46
|
-
const { columnName, constraints: queryConstraints, field, getNotNullColumnByValue, pathSegments, rawColumn, table } = getTableColumnFromPath({
|
47
|
-
adapter,
|
48
|
-
collectionPath: relationOrPath,
|
49
|
-
fields,
|
50
|
-
joins,
|
51
|
-
locale,
|
52
|
-
pathSegments: relationOrPath.replace(/__/g, '.').split('.'),
|
53
|
-
selectFields,
|
54
|
-
tableName,
|
55
|
-
value: val
|
56
|
-
});
|
57
|
-
queryConstraints.forEach(({ columnName: col, table: constraintTable, value })=>{
|
58
|
-
if (typeof value === 'string' && value.indexOf('%') > -1) {
|
59
|
-
constraints.push(operatorMap.like(constraintTable[col], value));
|
60
|
-
} else {
|
61
|
-
constraints.push(operatorMap.equals(constraintTable[col], value));
|
62
|
-
}
|
63
|
-
});
|
64
|
-
if ([
|
65
|
-
'json',
|
66
|
-
'richText'
|
67
|
-
].includes(field.type) && Array.isArray(pathSegments) && pathSegments.length > 1) {
|
68
|
-
const segments = pathSegments.slice(1);
|
69
|
-
segments.unshift(table[columnName].name);
|
70
|
-
if (field.type === 'richText') {
|
71
|
-
const jsonQuery = createJSONQuery({
|
72
|
-
operator,
|
73
|
-
pathSegments: segments,
|
74
|
-
treatAsArray: [
|
75
|
-
'children'
|
76
|
-
],
|
77
|
-
treatRootAsArray: true,
|
78
|
-
value: val
|
79
|
-
});
|
80
|
-
constraints.push(sql.raw(jsonQuery));
|
81
|
-
break;
|
82
|
-
}
|
83
|
-
const jsonQuery = convertPathToJSONTraversal(pathSegments);
|
84
|
-
const operatorKeys = {
|
85
|
-
contains: {
|
86
|
-
operator: 'ilike',
|
87
|
-
wildcard: '%'
|
88
|
-
},
|
89
|
-
equals: {
|
90
|
-
operator: '=',
|
91
|
-
wildcard: ''
|
92
|
-
},
|
93
|
-
exists: {
|
94
|
-
operator: val === true ? 'is not null' : 'is null'
|
95
|
-
},
|
96
|
-
like: {
|
97
|
-
operator: 'like',
|
98
|
-
wildcard: '%'
|
99
|
-
},
|
100
|
-
not_equals: {
|
101
|
-
operator: '<>',
|
102
|
-
wildcard: ''
|
103
|
-
}
|
104
|
-
};
|
105
|
-
let formattedValue = `'${operatorKeys[operator].wildcard}${val}${operatorKeys[operator].wildcard}'`;
|
106
|
-
if (operator === 'exists') {
|
107
|
-
formattedValue = '';
|
108
|
-
}
|
109
|
-
constraints.push(sql.raw(`${table[columnName].name}${jsonQuery} ${operatorKeys[operator].operator} ${formattedValue}`));
|
110
|
-
break;
|
111
|
-
}
|
112
|
-
if (getNotNullColumnByValue) {
|
113
|
-
const columnName = getNotNullColumnByValue(val);
|
114
|
-
if (columnName) {
|
115
|
-
constraints.push(isNotNull(table[columnName]));
|
116
|
-
} else {
|
117
|
-
throw new QueryError([
|
118
|
-
{
|
119
|
-
path: relationOrPath
|
120
|
-
}
|
121
|
-
]);
|
122
|
-
}
|
123
|
-
break;
|
124
|
-
}
|
125
|
-
if (operator === 'like' && (field.type === 'number' || table[columnName].columnType === 'PgUUID')) {
|
126
|
-
operator = 'equals';
|
127
|
-
}
|
128
|
-
if (operator === 'like') {
|
129
|
-
constraints.push(and(...val.split(' ').map((word)=>ilike(table[columnName], `%${word}%`))));
|
130
|
-
break;
|
131
|
-
}
|
132
|
-
const sanitizedQueryValue = sanitizeQueryValue({
|
133
|
-
adapter,
|
134
|
-
field,
|
135
|
-
operator,
|
136
|
-
relationOrPath,
|
137
|
-
val
|
138
|
-
});
|
139
|
-
if (sanitizedQueryValue === null) {
|
140
|
-
break;
|
141
|
-
}
|
142
|
-
const { operator: queryOperator, value: queryValue } = sanitizedQueryValue;
|
143
|
-
if (queryOperator === 'not_equals' && queryValue !== null) {
|
144
|
-
constraints.push(or(isNull(rawColumn || table[columnName]), /* eslint-disable @typescript-eslint/no-explicit-any */ ne(rawColumn || table[columnName], queryValue)));
|
145
|
-
break;
|
146
|
-
}
|
147
|
-
if ((field.type === 'relationship' || field.type === 'upload') && Array.isArray(queryValue) && operator === 'not_in') {
|
148
|
-
constraints.push(sql`(${notInArray(table[columnName], queryValue)} OR
|
149
|
-
${table[columnName]}
|
150
|
-
IS
|
151
|
-
NULL)`);
|
152
|
-
break;
|
153
|
-
}
|
154
|
-
if (operator === 'equals' && queryValue === null) {
|
155
|
-
constraints.push(isNull(rawColumn || table[columnName]));
|
156
|
-
break;
|
157
|
-
}
|
158
|
-
if (operator === 'not_equals' && queryValue === null) {
|
159
|
-
constraints.push(isNotNull(rawColumn || table[columnName]));
|
160
|
-
break;
|
161
|
-
}
|
162
|
-
constraints.push(operatorMap[queryOperator](rawColumn || table[columnName], queryValue));
|
163
|
-
}
|
164
|
-
}
|
165
|
-
}
|
166
|
-
}
|
167
|
-
}
|
168
|
-
}
|
169
|
-
}
|
170
|
-
if (constraints.length > 0) {
|
171
|
-
if (result) {
|
172
|
-
result = and(result, ...constraints);
|
173
|
-
} else {
|
174
|
-
result = and(...constraints);
|
175
|
-
}
|
176
|
-
}
|
177
|
-
if (constraints.length === 1 && !result) {
|
178
|
-
[result] = constraints;
|
179
|
-
}
|
180
|
-
return result;
|
181
|
-
}
|
182
|
-
|
183
|
-
//# sourceMappingURL=parseParams.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/queries/parseParams.ts"],"sourcesContent":["/* eslint-disable no-await-in-loop */\nimport type { SQL } from 'drizzle-orm'\nimport type { Field, Operator, Where } from 'payload'\n\nimport { and, ilike, isNotNull, isNull, ne, notInArray, or, sql } from 'drizzle-orm'\nimport { QueryError } from 'payload'\nimport { validOperators } from 'payload/shared'\n\nimport type { GenericColumn, PostgresAdapter } from '../types.js'\nimport type { BuildQueryJoinAliases } from './buildQuery.js'\n\nimport { buildAndOrConditions } from './buildAndOrConditions.js'\nimport { convertPathToJSONTraversal } from './createJSONQuery/convertPathToJSONTraversal.js'\nimport { createJSONQuery } from './createJSONQuery/index.js'\nimport { getTableColumnFromPath } from './getTableColumnFromPath.js'\nimport { operatorMap } from './operatorMap.js'\nimport { sanitizeQueryValue } from './sanitizeQueryValue.js'\n\ntype Args = {\n adapter: PostgresAdapter\n fields: Field[]\n joins: BuildQueryJoinAliases\n locale: string\n selectFields: Record<string, GenericColumn>\n tableName: string\n where: Where\n}\n\nexport async function parseParams({\n adapter,\n fields,\n joins,\n locale,\n selectFields,\n tableName,\n where,\n}: Args): Promise<SQL> {\n let result: SQL\n const constraints: SQL[] = []\n\n if (typeof where === 'object' && Object.keys(where).length > 0) {\n // We need to determine if the whereKey is an AND, OR, or a schema path\n for (const relationOrPath of Object.keys(where)) {\n if (relationOrPath) {\n const condition = where[relationOrPath]\n let conditionOperator: 'and' | 'or'\n if (relationOrPath.toLowerCase() === 'and') {\n conditionOperator = 'and'\n } else if (relationOrPath.toLowerCase() === 'or') {\n conditionOperator = 'or'\n }\n if (Array.isArray(condition)) {\n const builtConditions = await buildAndOrConditions({\n adapter,\n fields,\n joins,\n locale,\n selectFields,\n tableName,\n where: condition,\n })\n if (builtConditions.length > 0) {\n result = operatorMap[conditionOperator](...builtConditions)\n }\n } else {\n // It's a path - and there can be multiple comparisons on a single path.\n // For example - title like 'test' and title not equal to 'tester'\n // So we need to loop on keys again here to handle each operator independently\n const pathOperators = where[relationOrPath]\n if (typeof pathOperators === 'object') {\n for (let operator of Object.keys(pathOperators)) {\n if (validOperators.includes(operator as Operator)) {\n const val = where[relationOrPath][operator]\n const {\n columnName,\n constraints: queryConstraints,\n field,\n getNotNullColumnByValue,\n pathSegments,\n rawColumn,\n table,\n } = getTableColumnFromPath({\n adapter,\n collectionPath: relationOrPath,\n fields,\n joins,\n locale,\n pathSegments: relationOrPath.replace(/__/g, '.').split('.'),\n selectFields,\n tableName,\n value: val,\n })\n\n queryConstraints.forEach(({ columnName: col, table: constraintTable, value }) => {\n if (typeof value === 'string' && value.indexOf('%') > -1) {\n constraints.push(operatorMap.like(constraintTable[col], value))\n } else {\n constraints.push(operatorMap.equals(constraintTable[col], value))\n }\n })\n\n if (\n ['json', 'richText'].includes(field.type) &&\n Array.isArray(pathSegments) &&\n pathSegments.length > 1\n ) {\n const segments = pathSegments.slice(1)\n segments.unshift(table[columnName].name)\n\n if (field.type === 'richText') {\n const jsonQuery = createJSONQuery({\n operator,\n pathSegments: segments,\n treatAsArray: ['children'],\n treatRootAsArray: true,\n value: val,\n })\n\n constraints.push(sql.raw(jsonQuery))\n break\n }\n\n const jsonQuery = convertPathToJSONTraversal(pathSegments)\n const operatorKeys = {\n contains: { operator: 'ilike', wildcard: '%' },\n equals: { operator: '=', wildcard: '' },\n exists: { operator: val === true ? 'is not null' : 'is null' },\n like: { operator: 'like', wildcard: '%' },\n not_equals: { operator: '<>', wildcard: '' },\n }\n let formattedValue = `'${operatorKeys[operator].wildcard}${val}${operatorKeys[operator].wildcard}'`\n\n if (operator === 'exists') {\n formattedValue = ''\n }\n\n constraints.push(\n sql.raw(\n `${table[columnName].name}${jsonQuery} ${operatorKeys[operator].operator} ${formattedValue}`,\n ),\n )\n\n break\n }\n\n if (getNotNullColumnByValue) {\n const columnName = getNotNullColumnByValue(val)\n if (columnName) {\n constraints.push(isNotNull(table[columnName]))\n } else {\n throw new QueryError([{ path: relationOrPath }])\n }\n break\n }\n\n if (\n operator === 'like' &&\n (field.type === 'number' || table[columnName].columnType === 'PgUUID')\n ) {\n operator = 'equals'\n }\n\n if (operator === 'like') {\n constraints.push(\n and(...val.split(' ').map((word) => ilike(table[columnName], `%${word}%`))),\n )\n break\n }\n\n const sanitizedQueryValue = sanitizeQueryValue({\n adapter,\n field,\n operator,\n relationOrPath,\n val,\n })\n\n if (sanitizedQueryValue === null) {\n break\n }\n\n const { operator: queryOperator, value: queryValue } = sanitizedQueryValue\n\n if (queryOperator === 'not_equals' && queryValue !== null) {\n constraints.push(\n or(\n isNull(rawColumn || table[columnName]),\n /* eslint-disable @typescript-eslint/no-explicit-any */\n ne<any>(rawColumn || table[columnName], queryValue),\n ),\n )\n break\n }\n\n if (\n (field.type === 'relationship' || field.type === 'upload') &&\n Array.isArray(queryValue) &&\n operator === 'not_in'\n ) {\n constraints.push(\n sql`(${notInArray(table[columnName], queryValue)} OR\n ${table[columnName]}\n IS\n NULL)`,\n )\n\n break\n }\n\n if (operator === 'equals' && queryValue === null) {\n constraints.push(isNull(rawColumn || table[columnName]))\n break\n }\n\n if (operator === 'not_equals' && queryValue === null) {\n constraints.push(isNotNull(rawColumn || table[columnName]))\n break\n }\n\n constraints.push(\n operatorMap[queryOperator](rawColumn || table[columnName], queryValue),\n )\n }\n }\n }\n }\n }\n }\n }\n if (constraints.length > 0) {\n if (result) {\n result = and(result, ...constraints)\n } else {\n result = and(...constraints)\n }\n }\n if (constraints.length === 1 && !result) {\n ;[result] = constraints\n }\n\n return result\n}\n"],"names":["and","ilike","isNotNull","isNull","ne","notInArray","or","sql","QueryError","validOperators","buildAndOrConditions","convertPathToJSONTraversal","createJSONQuery","getTableColumnFromPath","operatorMap","sanitizeQueryValue","parseParams","adapter","fields","joins","locale","selectFields","tableName","where","result","constraints","Object","keys","length","relationOrPath","condition","conditionOperator","toLowerCase","Array","isArray","builtConditions","pathOperators","operator","includes","val","columnName","queryConstraints","field","getNotNullColumnByValue","pathSegments","rawColumn","table","collectionPath","replace","split","value","forEach","col","constraintTable","indexOf","push","like","equals","type","segments","slice","unshift","name","jsonQuery","treatAsArray","treatRootAsArray","raw","operatorKeys","contains","wildcard","exists","not_equals","formattedValue","path","columnType","map","word","sanitizedQueryValue","queryOperator","queryValue"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,mCAAmC,GAInC,SAASA,GAAG,EAAEC,KAAK,EAAEC,SAAS,EAAEC,MAAM,EAAEC,EAAE,EAAEC,UAAU,EAAEC,EAAE,EAAEC,GAAG,QAAQ,cAAa;AACpF,SAASC,UAAU,QAAQ,UAAS;AACpC,SAASC,cAAc,QAAQ,iBAAgB;AAK/C,SAASC,oBAAoB,QAAQ,4BAA2B;AAChE,SAASC,0BAA0B,QAAQ,kDAAiD;AAC5F,SAASC,eAAe,QAAQ,6BAA4B;AAC5D,SAASC,sBAAsB,QAAQ,8BAA6B;AACpE,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,kBAAkB,QAAQ,0BAAyB;AAY5D,OAAO,eAAeC,YAAY,EAChCC,OAAO,EACPC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,YAAY,EACZC,SAAS,EACTC,KAAK,EACA;IACL,IAAIC;IACJ,MAAMC,cAAqB,EAAE;IAE7B,IAAI,OAAOF,UAAU,YAAYG,OAAOC,IAAI,CAACJ,OAAOK,MAAM,GAAG,GAAG;QAC9D,uEAAuE;QACvE,KAAK,MA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OAAO,CAAC6C,eACd1C,aAAa,UACb;oCACAZ,YAAY8B,IAAI,CACdhD,GAAG,CAAC,CAAC,EAAEF,WAAWyC,KAAK,CAACN,WAAW,EAAEuC,YAAY;oBACjD,EAAEjC,KAAK,CAACN,WAAW,CAAC;;yBAEf,CAAC;oCAGR;gCACF;gCAEA,IAAIH,aAAa,YAAY0C,eAAe,MAAM;oCAChDtD,YAAY8B,IAAI,CAACpD,OAAO0C,aAAaC,KAAK,CAACN,WAAW;oCACtD;gCACF;gCAEA,IAAIH,aAAa,gBAAgB0C,eAAe,MAAM;oCACpDtD,YAAY8B,IAAI,CAACrD,UAAU2C,aAAaC,KAAK,CAACN,WAAW;oCACzD;gCACF;gCAEAf,YAAY8B,IAAI,CACdzC,WAAW,CAACgE,cAAc,CAACjC,aAAaC,KAAK,CAACN,WAAW,EAAEuC;4BAE/D;wBACF;oBACF;gBACF;YACF;QACF;IACF;IACA,IAAItD,YAAYG,MAAM,GAAG,GAAG;QAC1B,IAAIJ,QAAQ;YACVA,SAASxB,IAAIwB,WAAWC;QAC1B,OAAO;YACLD,SAASxB,OAAOyB;QAClB;IACF;IACA,IAAIA,YAAYG,MAAM,KAAK,KAAK,CAACJ,QAAQ;QACtC,CAACA,OAAO,GAAGC;IACd;IAEA,OAAOD;AACT"}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import { type Field, type TabAsField } from 'payload';
|
2
|
-
import type { PostgresAdapter } from '../types.js';
|
3
|
-
type SanitizeQueryValueArgs = {
|
4
|
-
adapter: PostgresAdapter;
|
5
|
-
field: Field | TabAsField;
|
6
|
-
operator: string;
|
7
|
-
relationOrPath: string;
|
8
|
-
val: any;
|
9
|
-
};
|
10
|
-
export declare const sanitizeQueryValue: ({ adapter, field, operator: operatorArg, relationOrPath, val, }: SanitizeQueryValueArgs) => {
|
11
|
-
operator: string;
|
12
|
-
value: unknown;
|
13
|
-
};
|
14
|
-
export {};
|
15
|
-
//# sourceMappingURL=sanitizeQueryValue.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"sanitizeQueryValue.d.ts","sourceRoot":"","sources":["../../src/queries/sanitizeQueryValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,KAAK,EAAE,KAAK,UAAU,EAAkC,MAAM,SAAS,CAAA;AAG/F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,KAAK,sBAAsB,GAAG;IAC5B,OAAO,EAAE,eAAe,CAAA;IACxB,KAAK,EAAE,KAAK,GAAG,UAAU,CAAA;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,MAAM,CAAA;IACtB,GAAG,EAAE,GAAG,CAAA;CACT,CAAA;AAED,eAAO,MAAM,kBAAkB,oEAM5B,sBAAsB,KAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAyF7D,CAAA"}
|
@@ -1,89 +0,0 @@
|
|
1
|
-
import { APIError, createArrayFromCommaDelineated } from 'payload';
|
2
|
-
import { fieldAffectsData } from 'payload/shared';
|
3
|
-
export const sanitizeQueryValue = ({ adapter, field, operator: operatorArg, relationOrPath, val })=>{
|
4
|
-
let operator = operatorArg;
|
5
|
-
let formattedValue = val;
|
6
|
-
if (!fieldAffectsData(field)) return {
|
7
|
-
operator,
|
8
|
-
value: formattedValue
|
9
|
-
};
|
10
|
-
if ((field.type === 'relationship' || field.type === 'upload') && !relationOrPath.endsWith('relationTo') && Array.isArray(formattedValue)) {
|
11
|
-
const allPossibleIDTypes = [];
|
12
|
-
formattedValue.forEach((val)=>{
|
13
|
-
if (adapter.idType !== 'uuid' && typeof val === 'string') {
|
14
|
-
allPossibleIDTypes.push(val, parseInt(val));
|
15
|
-
} else if (typeof val === 'string') {
|
16
|
-
allPossibleIDTypes.push(val);
|
17
|
-
} else {
|
18
|
-
allPossibleIDTypes.push(val, String(val));
|
19
|
-
}
|
20
|
-
});
|
21
|
-
formattedValue = allPossibleIDTypes;
|
22
|
-
}
|
23
|
-
// Cast incoming values as proper searchable types
|
24
|
-
if (field.type === 'checkbox' && typeof val === 'string') {
|
25
|
-
if (val.toLowerCase() === 'true') formattedValue = true;
|
26
|
-
if (val.toLowerCase() === 'false') formattedValue = false;
|
27
|
-
}
|
28
|
-
if ([
|
29
|
-
'all',
|
30
|
-
'in',
|
31
|
-
'not_in'
|
32
|
-
].includes(operator)) {
|
33
|
-
if (typeof formattedValue === 'string') {
|
34
|
-
formattedValue = createArrayFromCommaDelineated(formattedValue);
|
35
|
-
if (field.type === 'number') {
|
36
|
-
formattedValue = formattedValue.map((arrayVal)=>parseFloat(arrayVal));
|
37
|
-
}
|
38
|
-
}
|
39
|
-
if (!Array.isArray(formattedValue) || formattedValue.length === 0) {
|
40
|
-
return null;
|
41
|
-
}
|
42
|
-
}
|
43
|
-
if (field.type === 'number' && typeof formattedValue === 'string') {
|
44
|
-
formattedValue = Number(val);
|
45
|
-
}
|
46
|
-
if (field.type === 'date' && operator !== 'exists') {
|
47
|
-
if (typeof val === 'string') {
|
48
|
-
formattedValue = new Date(val);
|
49
|
-
if (Number.isNaN(Date.parse(formattedValue))) {
|
50
|
-
return {
|
51
|
-
operator,
|
52
|
-
value: undefined
|
53
|
-
};
|
54
|
-
}
|
55
|
-
}
|
56
|
-
if (typeof val === 'number') {
|
57
|
-
formattedValue = new Date(val);
|
58
|
-
}
|
59
|
-
}
|
60
|
-
if ([
|
61
|
-
'relationship',
|
62
|
-
'upload'
|
63
|
-
].includes(field.type)) {
|
64
|
-
if (val === 'null') {
|
65
|
-
formattedValue = null;
|
66
|
-
}
|
67
|
-
}
|
68
|
-
if ('hasMany' in field && field.hasMany && operator === 'contains') {
|
69
|
-
operator = 'equals';
|
70
|
-
}
|
71
|
-
if (operator === 'near' || operator === 'within' || operator === 'intersects') {
|
72
|
-
throw new APIError(`Querying with '${operator}' is not supported with the postgres database adapter.`);
|
73
|
-
}
|
74
|
-
if (operator === 'contains') {
|
75
|
-
formattedValue = `%${formattedValue}%`;
|
76
|
-
}
|
77
|
-
if (operator === 'exists') {
|
78
|
-
formattedValue = formattedValue === 'true' || formattedValue === true;
|
79
|
-
if (formattedValue === false) {
|
80
|
-
operator = 'isNull';
|
81
|
-
}
|
82
|
-
}
|
83
|
-
return {
|
84
|
-
operator,
|
85
|
-
value: formattedValue
|
86
|
-
};
|
87
|
-
};
|
88
|
-
|
89
|
-
//# sourceMappingURL=sanitizeQueryValue.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/queries/sanitizeQueryValue.ts"],"sourcesContent":["import { APIError, type Field, type TabAsField, createArrayFromCommaDelineated } from 'payload'\nimport { fieldAffectsData } from 'payload/shared'\n\nimport type { PostgresAdapter } from '../types.js'\n\ntype SanitizeQueryValueArgs = {\n adapter: PostgresAdapter\n field: Field | TabAsField\n operator: string\n relationOrPath: string\n val: any\n}\n\nexport const sanitizeQueryValue = ({\n adapter,\n field,\n operator: operatorArg,\n relationOrPath,\n val,\n}: SanitizeQueryValueArgs): { operator: string; value: unknown } => {\n let operator = operatorArg\n let formattedValue = val\n\n if (!fieldAffectsData(field)) return { operator, value: formattedValue }\n\n if (\n (field.type === 'relationship' || field.type === 'upload') &&\n !relationOrPath.endsWith('relationTo') &&\n Array.isArray(formattedValue)\n ) {\n const allPossibleIDTypes: (number | string)[] = []\n formattedValue.forEach((val) => {\n if (adapter.idType !== 'uuid' && typeof val === 'string') {\n allPossibleIDTypes.push(val, parseInt(val))\n } else if (typeof val === 'string') {\n allPossibleIDTypes.push(val)\n } else {\n allPossibleIDTypes.push(val, String(val))\n }\n })\n formattedValue = allPossibleIDTypes\n }\n\n // Cast incoming values as proper searchable types\n if (field.type === 'checkbox' && typeof val === 'string') {\n if (val.toLowerCase() === 'true') formattedValue = true\n if (val.toLowerCase() === 'false') formattedValue = false\n }\n\n if (['all', 'in', 'not_in'].includes(operator)) {\n if (typeof formattedValue === 'string') {\n formattedValue = createArrayFromCommaDelineated(formattedValue)\n\n if (field.type === 'number') {\n formattedValue = formattedValue.map((arrayVal) => parseFloat(arrayVal))\n }\n }\n\n if (!Array.isArray(formattedValue) || formattedValue.length === 0) {\n return null\n }\n }\n\n if (field.type === 'number' && typeof formattedValue === 'string') {\n formattedValue = Number(val)\n }\n\n if (field.type === 'date' && operator !== 'exists') {\n if (typeof val === 'string') {\n formattedValue = new Date(val)\n if (Number.isNaN(Date.parse(formattedValue))) {\n return { operator, value: undefined }\n }\n }\n\n if (typeof val === 'number') {\n formattedValue = new Date(val)\n }\n }\n\n if (['relationship', 'upload'].includes(field.type)) {\n if (val === 'null') {\n formattedValue = null\n }\n }\n\n if ('hasMany' in field && field.hasMany && operator === 'contains') {\n operator = 'equals'\n }\n\n if (operator === 'near' || operator === 'within' || operator === 'intersects') {\n throw new APIError(\n `Querying with '${operator}' is not supported with the postgres database adapter.`,\n )\n }\n\n if (operator === 'contains') {\n formattedValue = `%${formattedValue}%`\n }\n\n if (operator === 'exists') {\n formattedValue = formattedValue === 'true' || formattedValue === true\n if (formattedValue === false) {\n operator = 'isNull'\n }\n }\n\n return { operator, value: formattedValue }\n}\n"],"names":["APIError","createArrayFromCommaDelineated","fieldAffectsData","sanitizeQueryValue","adapter","field","operator","operatorArg","relationOrPath","val","formattedValue","value","type","endsWith","Array","isArray","allPossibleIDTypes","forEach","idType","push","parseInt","String","toLowerCase","includes","map","arrayVal","parseFloat","length","Number","Date","isNaN","parse","undefined","hasMany"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,QAAQ,EAA+BC,8BAA8B,QAAQ,UAAS;AAC/F,SAASC,gBAAgB,QAAQ,iBAAgB;AAYjD,OAAO,MAAMC,qBAAqB,CAAC,EACjCC,OAAO,EACPC,KAAK,EACLC,UAAUC,WAAW,EACrBC,cAAc,EACdC,GAAG,EACoB;IACvB,IAAIH,WA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QAAQ,UAAU;YAC3BC,iBAAiB,IAAImB,KAAKpB;YAC1B,IAAImB,OAAOE,KAAK,CAACD,KAAKE,KAAK,CAACrB,kBAAkB;gBAC5C,OAAO;oBAAEJ;oBAAUK,OAAOqB;gBAAU;YACtC;QACF;QAEA,IAAI,OAAOvB,QAAQ,UAAU;YAC3BC,iBAAiB,IAAImB,KAAKpB;QAC5B;IACF;IAEA,IAAI;QAAC;QAAgB;KAAS,CAACc,QAAQ,CAAClB,MAAMO,IAAI,GAAG;QACnD,IAAIH,QAAQ,QAAQ;YAClBC,iBAAiB;QACnB;IACF;IAEA,IAAI,aAAaL,SAASA,MAAM4B,OAAO,IAAI3B,aAAa,YAAY;QAClEA,WAAW;IACb;IAEA,IAAIA,aAAa,UAAUA,aAAa,YAAYA,aAAa,cAAc;QAC7E,MAAM,IAAIN,SACR,CAAC,eAAe,EAAEM,SAAS,sDAAsD,CAAC;IAEtF;IAEA,IAAIA,aAAa,YAAY;QAC3BI,iBAAiB,CAAC,CAAC,EAAEA,eAAe,CAAC,CAAC;IACxC;IAEA,IAAIJ,aAAa,UAAU;QACzBI,iBAAiBA,mBAAmB,UAAUA,mBAAmB;QACjE,IAAIA,mBAAmB,OAAO;YAC5BJ,WAAW;QACb;IACF;IAEA,OAAO;QAAEA;QAAUK,OAAOD;IAAe;AAC3C,EAAC"}
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import type { QueryPromise, SQL } from 'drizzle-orm';
|
2
|
-
import type { ChainedMethods } from '../find/chainMethods.js';
|
3
|
-
import type { DrizzleDB, PostgresAdapter } from '../types.js';
|
4
|
-
import type { BuildQueryJoinAliases } from './buildQuery.js';
|
5
|
-
import { type GenericColumn } from '../types.js';
|
6
|
-
type Args = {
|
7
|
-
adapter: PostgresAdapter;
|
8
|
-
chainedMethods?: ChainedMethods;
|
9
|
-
db: DrizzleDB;
|
10
|
-
joins: BuildQueryJoinAliases;
|
11
|
-
selectFields: Record<string, GenericColumn>;
|
12
|
-
tableName: string;
|
13
|
-
where: SQL;
|
14
|
-
};
|
15
|
-
/**
|
16
|
-
* Selects distinct records from a table only if there are joins that need to be used, otherwise return null
|
17
|
-
*/
|
18
|
-
export declare const selectDistinct: ({ adapter, chainedMethods, db, joins, selectFields, tableName, where, }: Args) => QueryPromise<Record<string, GenericColumn> & {
|
19
|
-
id: number | string;
|
20
|
-
}[]>;
|
21
|
-
export {};
|
22
|
-
//# sourceMappingURL=selectDistinct.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"selectDistinct.d.ts","sourceRoot":"","sources":["../../src/queries/selectDistinct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAG5D,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,EAAE,EAAE,SAAS,CAAA;IACb,KAAK,EAAE,qBAAqB,CAAA;IAC5B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC3C,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,GAAG,CAAA;CACX,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,4EAQxB,IAAI,KAAG,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EAAE,CAkB/E,CAAA"}
|
@@ -1,30 +0,0 @@
|
|
1
|
-
import { chainMethods } from '../find/chainMethods.js';
|
2
|
-
/**
|
3
|
-
* Selects distinct records from a table only if there are joins that need to be used, otherwise return null
|
4
|
-
*/ export const selectDistinct = ({ adapter, chainedMethods = [], db, joins, selectFields, tableName, where })=>{
|
5
|
-
if (Object.keys(joins).length > 0) {
|
6
|
-
if (where) {
|
7
|
-
chainedMethods.push({
|
8
|
-
args: [
|
9
|
-
where
|
10
|
-
],
|
11
|
-
method: 'where'
|
12
|
-
});
|
13
|
-
}
|
14
|
-
joins.forEach(({ condition, table })=>{
|
15
|
-
chainedMethods.push({
|
16
|
-
args: [
|
17
|
-
table,
|
18
|
-
condition
|
19
|
-
],
|
20
|
-
method: 'leftJoin'
|
21
|
-
});
|
22
|
-
});
|
23
|
-
return chainMethods({
|
24
|
-
methods: chainedMethods,
|
25
|
-
query: db.selectDistinct(selectFields).from(adapter.tables[tableName])
|
26
|
-
});
|
27
|
-
}
|
28
|
-
};
|
29
|
-
|
30
|
-
//# sourceMappingURL=selectDistinct.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/queries/selectDistinct.ts"],"sourcesContent":["import type { QueryPromise, SQL } from 'drizzle-orm'\n\nimport type { ChainedMethods } from '../find/chainMethods.js'\nimport type { DrizzleDB, PostgresAdapter } from '../types.js'\nimport type { BuildQueryJoinAliases } from './buildQuery.js'\n\nimport { chainMethods } from '../find/chainMethods.js'\nimport { type GenericColumn } from '../types.js'\n\ntype Args = {\n adapter: PostgresAdapter\n chainedMethods?: ChainedMethods\n db: DrizzleDB\n joins: BuildQueryJoinAliases\n selectFields: Record<string, GenericColumn>\n tableName: string\n where: SQL\n}\n\n/**\n * Selects distinct records from a table only if there are joins that need to be used, otherwise return null\n */\nexport const selectDistinct = ({\n adapter,\n chainedMethods = [],\n db,\n joins,\n selectFields,\n tableName,\n where,\n}: Args): QueryPromise<Record<string, GenericColumn> & { id: number | string }[]> => {\n if (Object.keys(joins).length > 0) {\n if (where) {\n chainedMethods.push({ args: [where], method: 'where' })\n }\n\n joins.forEach(({ condition, table }) => {\n chainedMethods.push({\n args: [table, condition],\n method: 'leftJoin',\n })\n })\n\n return chainMethods({\n methods: chainedMethods,\n query: db.selectDistinct(selectFields).from(adapter.tables[tableName]),\n })\n }\n}\n"],"names":["chainMethods","selectDistinct","adapter","chainedMethods","db","joins","selectFields","tableName","where","Object","keys","length","push","args","method","forEach","condition","table","methods","query","from","tables"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAMA,SAASA,YAAY,QAAQ,0BAAyB;AAatD;;CAEC,GACD,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,OAAO,EACPC,iBAAiB,EAAE,EACnBC,EAAE,EACFC,KAAK,EACLC,YAAY,EACZC,SAAS,EACTC,KAAK,EACA;IACL,IAAIC,OAAOC,IAAI,CAACL,OAAOM,MAAM,GAAG,GAAG;QACjC,IAAIH,OAAO;YACTL,eAAeS,IAAI,CAAC;gBAAEC,MAAM;oBAACL;iBAAM;gBAAEM,QAAQ;YAAQ;QACvD;QAEAT,MAAMU,OAAO,CAAC,CAAC,EAAEC,SAAS,EAAEC,KAAK,EAAE;YACjCd,eAAeS,IAAI,CAAC;gBAClBC,MAAM;oBAACI;oBAAOD;iBAAU;gBACxBF,QAAQ;YACV;QACF;QAEA,OAAOd,aAAa;YAClBkB,SAASf;YACTgB,OAAOf,GAAGH,cAAc,CAACK,cAAcc,IAAI,CAAClB,QAAQmB,MAAM,CAACd,UAAU;QACvE;IACF;AACF,EAAC"}
|
package/dist/queryDrafts.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"queryDrafts.d.ts","sourceRoot":"","sources":["../src/queryDrafts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,WAAW,EAAgD,MAAM,SAAS,CAAA;AAOxF,eAAO,MAAM,WAAW,EAAE,WAgDzB,CAAA"}
|
package/dist/queryDrafts.js
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
import { buildVersionCollectionFields, combineQueries } from 'payload';
|
2
|
-
import toSnakeCase from 'to-snake-case';
|
3
|
-
import { findMany } from './find/findMany.js';
|
4
|
-
export const queryDrafts = async function queryDrafts({ collection, limit, locale, page = 1, pagination, req = {}, sort, where }) {
|
5
|
-
const collectionConfig = this.payload.collections[collection].config;
|
6
|
-
const tableName = this.tableNameMap.get(`_${toSnakeCase(collectionConfig.slug)}${this.versionsSuffix}`);
|
7
|
-
const fields = buildVersionCollectionFields(collectionConfig);
|
8
|
-
const combinedWhere = combineQueries({
|
9
|
-
latest: {
|
10
|
-
equals: true
|
11
|
-
}
|
12
|
-
}, where);
|
13
|
-
const result = await findMany({
|
14
|
-
adapter: this,
|
15
|
-
fields,
|
16
|
-
limit,
|
17
|
-
locale,
|
18
|
-
page,
|
19
|
-
pagination,
|
20
|
-
req,
|
21
|
-
sort,
|
22
|
-
tableName,
|
23
|
-
where: combinedWhere
|
24
|
-
});
|
25
|
-
return {
|
26
|
-
...result,
|
27
|
-
docs: result.docs.map((doc)=>{
|
28
|
-
// eslint-disable-next-line no-param-reassign
|
29
|
-
doc = {
|
30
|
-
id: doc.parent,
|
31
|
-
...doc.version,
|
32
|
-
createdAt: doc.createdAt,
|
33
|
-
updatedAt: doc.updatedAt
|
34
|
-
};
|
35
|
-
return doc;
|
36
|
-
})
|
37
|
-
};
|
38
|
-
};
|
39
|
-
|
40
|
-
//# sourceMappingURL=queryDrafts.js.map
|
package/dist/queryDrafts.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/queryDrafts.ts"],"sourcesContent":["import type { PayloadRequestWithData, SanitizedCollectionConfig } from 'payload'\n\nimport { type QueryDrafts, buildVersionCollectionFields, combineQueries } 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 queryDrafts: QueryDrafts = async function queryDrafts(\n this: PostgresAdapter,\n {\n collection,\n limit,\n locale,\n page = 1,\n pagination,\n req = {} as PayloadRequestWithData,\n sort,\n where,\n },\n) {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n const tableName = this.tableNameMap.get(\n `_${toSnakeCase(collectionConfig.slug)}${this.versionsSuffix}`,\n )\n const fields = buildVersionCollectionFields(collectionConfig)\n\n const combinedWhere = combineQueries({ latest: { equals: true } }, where)\n\n const result = await findMany({\n adapter: this,\n fields,\n limit,\n locale,\n page,\n pagination,\n req,\n sort,\n tableName,\n where: combinedWhere,\n })\n\n return {\n ...result,\n docs: result.docs.map((doc) => {\n // eslint-disable-next-line no-param-reassign\n doc = {\n id: doc.parent,\n ...doc.version,\n createdAt: doc.createdAt,\n updatedAt: doc.updatedAt,\n }\n\n return doc\n }),\n }\n}\n"],"names":["buildVersionCollectionFields","combineQueries","toSnakeCase","findMany","queryDrafts","collection","limit","locale","page","pagination","req","sort","where","collectionConfig","payload","collections","config","tableName","tableNameMap","get","slug","versionsSuffix","fields","combinedWhere","latest","equals","result","adapter","docs","map","doc","id","parent","version","createdAt","updatedAt"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAA2BA,4BAA4B,EAAEC,cAAc,QAAQ,UAAS;AACxF,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,MAAMC,cAA2B,eAAeA,YAErD,EACEC,UAAU,EACVC,KAAK,EACLC,MAAM,EACNC,OAAO,CAAC,EACRC,UAAU,EACVC,MAAM,CAAC,CAA2B,EAClCC,IAAI,EACJC,KAAK,EACN;IAED,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACV,WAAW,CAACW,MAAM;IAC/F,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CACrC,CAAC,CAAC,EAAEjB,YAAYW,iBAAiBO,IAAI,EAAE,EAAE,IAAI,CAACC,cAAc,CAAC,CAAC;IAEhE,MAAMC,SAAStB,6BAA6Ba;IAE5C,MAAMU,gBAAgBtB,eAAe;QAAEuB,QAAQ;YAAEC,QAAQ;QAAK;IAAE,GAAGb;IAEnE,MAAMc,SAAS,MAAMvB,SAAS;QAC5BwB,SAAS,IAAI;QACbL;QACAhB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAM;QACAL,OAAOW;IACT;IAEA,OAAO;QACL,GAAGG,MAAM;QACTE,MAAMF,OAAOE,IAAI,CAACC,GAAG,CAAC,CAACC;YACrB,6CAA6C;YAC7CA,MAAM;gBACJC,IAAID,IAAIE,MAAM;gBACd,GAAGF,IAAIG,OAAO;gBACdC,WAAWJ,IAAII,SAAS;gBACxBC,WAAWL,IAAIK,SAAS;YAC1B;YAEA,OAAOL;QACT;IACF;AACF,EAAC"}
|
@@ -1,30 +0,0 @@
|
|
1
|
-
import type { DBIdentifierName } from 'payload';
|
2
|
-
import type { PostgresAdapter } from '../types.js';
|
3
|
-
type Args = {
|
4
|
-
adapter: PostgresAdapter;
|
5
|
-
/** The collection, global or field config **/
|
6
|
-
config: {
|
7
|
-
dbName?: DBIdentifierName;
|
8
|
-
enumName?: DBIdentifierName;
|
9
|
-
name?: string;
|
10
|
-
slug?: string;
|
11
|
-
};
|
12
|
-
/** For nested tables passed for the user custom dbName functions to handle their own iterations */
|
13
|
-
parentTableName?: string;
|
14
|
-
/** For sub tables (array for example) this needs to include the parentTableName */
|
15
|
-
prefix?: string;
|
16
|
-
/** For tables based on fields that could have both enumName and dbName (ie: select with hasMany), default: 'dbName' */
|
17
|
-
target?: 'dbName' | 'enumName';
|
18
|
-
throwValidationError?: boolean;
|
19
|
-
/** Adds the versions suffix to the default table name - should only be used on the base collection to avoid duplicate suffixing */
|
20
|
-
versions?: boolean;
|
21
|
-
/** Adds the versions suffix to custom dbName only - this is used while creating blocks / selects / arrays / etc */
|
22
|
-
versionsCustomName?: boolean;
|
23
|
-
};
|
24
|
-
/**
|
25
|
-
* Used to name database enums and tables
|
26
|
-
* Returns the table or enum name for a given entity
|
27
|
-
*/
|
28
|
-
export declare const createTableName: ({ adapter, config: { name, slug }, config, parentTableName, prefix, target, throwValidationError, versions, versionsCustomName, }: Args) => string;
|
29
|
-
export {};
|
30
|
-
//# sourceMappingURL=createTableName.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"createTableName.d.ts","sourceRoot":"","sources":["../../src/schema/createTableName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAK/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,8CAA8C;IAC9C,MAAM,EAAE;QACN,MAAM,CAAC,EAAE,gBAAgB,CAAA;QACzB,QAAQ,CAAC,EAAE,gBAAgB,CAAA;QAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,CAAA;IACD,mGAAmG;IACnG,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,mFAAmF;IACnF,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,uHAAuH;IACvH,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAA;IAC9B,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,mIAAmI;IACnI,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,mHAAmH;IACnH,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,sIAUzB,IAAI,KAAG,MAsCT,CAAA"}
|
@@ -1,31 +0,0 @@
|
|
1
|
-
import { APIError } from 'payload';
|
2
|
-
import toSnakeCase from 'to-snake-case';
|
3
|
-
/**
|
4
|
-
* Used to name database enums and tables
|
5
|
-
* Returns the table or enum name for a given entity
|
6
|
-
*/ export const createTableName = ({ adapter, config: { name, slug }, config, parentTableName, prefix = '', target = 'dbName', throwValidationError = false, versions = false, versionsCustomName = false })=>{
|
7
|
-
let customNameDefinition = config[target];
|
8
|
-
let defaultTableName = `${prefix}${toSnakeCase(name ?? slug)}`;
|
9
|
-
if (versions) defaultTableName = `_${defaultTableName}${adapter.versionsSuffix}`;
|
10
|
-
let customTableNameResult;
|
11
|
-
if (!customNameDefinition && target === 'enumName') {
|
12
|
-
customNameDefinition = config['dbName'];
|
13
|
-
}
|
14
|
-
if (customNameDefinition) {
|
15
|
-
customTableNameResult = typeof customNameDefinition === 'function' ? customNameDefinition({
|
16
|
-
tableName: parentTableName
|
17
|
-
}) : customNameDefinition;
|
18
|
-
if (versionsCustomName) customTableNameResult = `_${customTableNameResult}${adapter.versionsSuffix}`;
|
19
|
-
}
|
20
|
-
const result = customTableNameResult || defaultTableName;
|
21
|
-
adapter.tableNameMap.set(defaultTableName, result);
|
22
|
-
if (!throwValidationError) {
|
23
|
-
return result;
|
24
|
-
}
|
25
|
-
if (result.length > 63) {
|
26
|
-
throw new APIError(`Exceeded max identifier length for table or enum name of 63 characters. Invalid name: ${result}`);
|
27
|
-
}
|
28
|
-
return result;
|
29
|
-
};
|
30
|
-
|
31
|
-
//# sourceMappingURL=createTableName.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/schema/createTableName.ts"],"sourcesContent":["import type { DBIdentifierName } from 'payload'\n\nimport { APIError } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from '../types.js'\n\ntype Args = {\n adapter: PostgresAdapter\n /** The collection, global or field config **/\n config: {\n dbName?: DBIdentifierName\n enumName?: DBIdentifierName\n name?: string\n slug?: string\n }\n /** For nested tables passed for the user custom dbName functions to handle their own iterations */\n parentTableName?: string\n /** For sub tables (array for example) this needs to include the parentTableName */\n prefix?: string\n /** For tables based on fields that could have both enumName and dbName (ie: select with hasMany), default: 'dbName' */\n target?: 'dbName' | 'enumName'\n throwValidationError?: boolean\n /** Adds the versions suffix to the default table name - should only be used on the base collection to avoid duplicate suffixing */\n versions?: boolean\n /** Adds the versions suffix to custom dbName only - this is used while creating blocks / selects / arrays / etc */\n versionsCustomName?: boolean\n}\n\n/**\n * Used to name database enums and tables\n * Returns the table or enum name for a given entity\n */\nexport const createTableName = ({\n adapter,\n config: { name, slug },\n config,\n parentTableName,\n prefix = '',\n target = 'dbName',\n throwValidationError = false,\n versions = false,\n versionsCustomName = false,\n}: Args): string => {\n let customNameDefinition = config[target]\n\n let defaultTableName = `${prefix}${toSnakeCase(name ?? slug)}`\n\n if (versions) defaultTableName = `_${defaultTableName}${adapter.versionsSuffix}`\n\n let customTableNameResult: string\n\n if (!customNameDefinition && target === 'enumName') {\n customNameDefinition = config['dbName']\n }\n\n if (customNameDefinition) {\n customTableNameResult =\n typeof customNameDefinition === 'function'\n ? customNameDefinition({ tableName: parentTableName })\n : customNameDefinition\n\n if (versionsCustomName)\n customTableNameResult = `_${customTableNameResult}${adapter.versionsSuffix}`\n }\n\n const result = customTableNameResult || defaultTableName\n\n adapter.tableNameMap.set(defaultTableName, result)\n\n if (!throwValidationError) {\n return result\n }\n\n if (result.length > 63) {\n throw new APIError(\n `Exceeded max identifier length for table or enum name of 63 characters. Invalid name: ${result}`,\n )\n }\n\n return result\n}\n"],"names":["APIError","toSnakeCase","createTableName","adapter","config","name","slug","parentTableName","prefix","target","throwValidationError","versions","versionsCustomName","customNameDefinition","defaultTableName","versionsSuffix","customTableNameResult","tableName","result","tableNameMap","set","length"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,QAAQ,QAAQ,UAAS;AAClC,OAAOC,iBAAiB,gBAAe;AA0BvC;;;CAGC,GACD,OAAO,MAAMC,kBAAkB,CAAC,EAC9BC,OAAO,EACPC,QAAQ,EAAEC,IAAI,EAAEC,IAAI,EAAE,EACtBF,MAAM,EACNG,eAAe,EACfC,SAAS,EAAE,EACXC,SAAS,QAAQ,EACjBC,uBAAuB,KAAK,EAC5BC,WAAW,KAAK,EAChBC,qBAAqB,KAAK,EACrB;IACL,IAAIC,uBAAuBT,MAAM,CAACK,OAAO;IAEzC,IAAIK,mBAAmB,CAAC,EAAEN,OAAO,EAAEP,YAAYI,QAAQC,MAAM,CAAC;IAE9D,IAAIK,UAAUG,mBAAmB,CAAC,CAAC,EAAEA,iBAAiB,EAAEX,QAAQY,cAAc,CAAC,CAAC;IAEhF,IAAIC;IAEJ,IAAI,CAACH,wBAAwBJ,WAAW,YAAY;QAClDI,uBAAuBT,MAAM,CAAC,SAAS;IACzC;IAEA,IAAIS,sBAAsB;QACxBG,wBACE,OAAOH,yBAAyB,aAC5BA,qBAAqB;YAAEI,WAAWV;QAAgB,KAClDM;QAEN,IAAID,oBACFI,wBAAwB,CAAC,CAAC,EAAEA,sBAAsB,EAAEb,QAAQY,cAAc,CAAC,CAAC;IAChF;IAEA,MAAMG,SAASF,yBAAyBF;IAExCX,QAAQgB,YAAY,CAACC,GAAG,CAACN,kBAAkBI;IAE3C,IAAI,CAACR,sBAAsB;QACzB,OAAOQ;IACT;IAEA,IAAIA,OAAOG,MAAM,GAAG,IAAI;QACtB,MAAM,IAAIrB,SACR,CAAC,sFAAsF,EAAEkB,OAAO,CAAC;IAErG;IAEA,OAAOA;AACT,EAAC"}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import type { Block } from 'payload';
|
2
|
-
import type { GenericTable } from '../types.js';
|
3
|
-
type Args = {
|
4
|
-
block: Block;
|
5
|
-
localized: boolean;
|
6
|
-
rootTableName: string;
|
7
|
-
table: GenericTable;
|
8
|
-
tableLocales?: GenericTable;
|
9
|
-
};
|
10
|
-
export declare const validateExistingBlockIsIdentical: ({ block, localized, rootTableName, table, tableLocales, }: Args) => void;
|
11
|
-
export {};
|
12
|
-
//# sourceMappingURL=validateExistingBlockIsIdentical.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"validateExistingBlockIsIdentical.d.ts","sourceRoot":"","sources":["../../src/schema/validateExistingBlockIsIdentical.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAS,MAAM,SAAS,CAAA;AAK3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,KAAK,CAAA;IACZ,SAAS,EAAE,OAAO,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,YAAY,CAAA;IACnB,YAAY,CAAC,EAAE,YAAY,CAAA;CAC5B,CAAA;AAkDD,eAAO,MAAM,gCAAgC,8DAM1C,IAAI,KAAG,IA+BT,CAAA"}
|