@hanzo/cms-drizzle 3.85.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +22 -0
- package/README.md +3 -0
- package/dist/count.d.ts +3 -0
- package/dist/count.d.ts.map +1 -0
- package/dist/count.js +26 -0
- package/dist/count.js.map +1 -0
- package/dist/countGlobalVersions.d.ts +3 -0
- package/dist/countGlobalVersions.d.ts.map +1 -0
- package/dist/countGlobalVersions.js +28 -0
- package/dist/countGlobalVersions.js.map +1 -0
- package/dist/countVersions.d.ts +3 -0
- package/dist/countVersions.d.ts.map +1 -0
- package/dist/countVersions.js +28 -0
- package/dist/countVersions.js.map +1 -0
- package/dist/create.d.ts +3 -0
- package/dist/create.d.ts.map +1 -0
- package/dist/create.js +28 -0
- package/dist/create.js.map +1 -0
- package/dist/createGlobal.d.ts +4 -0
- package/dist/createGlobal.d.ts.map +1 -0
- package/dist/createGlobal.js +28 -0
- package/dist/createGlobal.js.map +1 -0
- package/dist/createGlobalVersion.d.ts +4 -0
- package/dist/createGlobalVersion.d.ts.map +1 -0
- package/dist/createGlobalVersion.js +49 -0
- package/dist/createGlobalVersion.js.map +1 -0
- package/dist/createTableName.d.ts +31 -0
- package/dist/createTableName.d.ts.map +1 -0
- package/dist/createTableName.js +37 -0
- package/dist/createTableName.js.map +1 -0
- package/dist/createVersion.d.ts +4 -0
- package/dist/createVersion.d.ts.map +1 -0
- package/dist/createVersion.js +65 -0
- package/dist/createVersion.js.map +1 -0
- package/dist/deleteMany.d.ts +3 -0
- package/dist/deleteMany.d.ts.map +1 -0
- package/dist/deleteMany.js +51 -0
- package/dist/deleteMany.js.map +1 -0
- package/dist/deleteOne.d.ts +3 -0
- package/dist/deleteOne.d.ts.map +1 -0
- package/dist/deleteOne.js +67 -0
- package/dist/deleteOne.js.map +1 -0
- package/dist/deleteVersions.d.ts +3 -0
- package/dist/deleteVersions.d.ts.map +1 -0
- package/dist/deleteVersions.js +52 -0
- package/dist/deleteVersions.js.map +1 -0
- package/dist/destroy.d.ts +3 -0
- package/dist/destroy.d.ts.map +1 -0
- package/dist/destroy.js +17 -0
- package/dist/destroy.js.map +1 -0
- package/dist/exports/postgres.d.ts +16 -0
- package/dist/exports/postgres.d.ts.map +1 -0
- package/dist/exports/postgres.js +17 -0
- package/dist/exports/postgres.js.map +1 -0
- package/dist/exports/sqlite.d.ts +13 -0
- package/dist/exports/sqlite.d.ts.map +1 -0
- package/dist/exports/sqlite.js +14 -0
- package/dist/exports/sqlite.js.map +1 -0
- package/dist/exports/types-deprecated.d.ts +150 -0
- package/dist/exports/types-deprecated.d.ts.map +1 -0
- package/dist/exports/types-deprecated.js +5 -0
- package/dist/exports/types-deprecated.js.map +1 -0
- package/dist/find/buildFindManyArgs.d.ts +27 -0
- package/dist/find/buildFindManyArgs.d.ts.map +1 -0
- package/dist/find/buildFindManyArgs.js +96 -0
- package/dist/find/buildFindManyArgs.js.map +1 -0
- package/dist/find/chainMethods.d.ts +20 -0
- package/dist/find/chainMethods.d.ts.map +1 -0
- package/dist/find/chainMethods.js +16 -0
- package/dist/find/chainMethods.js.map +1 -0
- package/dist/find/findMany.d.ts +23 -0
- package/dist/find/findMany.d.ts.map +1 -0
- package/dist/find/findMany.js +173 -0
- package/dist/find/findMany.js.map +1 -0
- package/dist/find/traverseFields.d.ts +34 -0
- package/dist/find/traverseFields.d.ts.map +1 -0
- package/dist/find/traverseFields.js +653 -0
- package/dist/find/traverseFields.js.map +1 -0
- package/dist/find.d.ts +3 -0
- package/dist/find.d.ts.map +1 -0
- package/dist/find.js +25 -0
- package/dist/find.js.map +1 -0
- package/dist/findDistinct.d.ts +3 -0
- package/dist/findDistinct.d.ts.map +1 -0
- package/dist/findDistinct.js +135 -0
- package/dist/findDistinct.js.map +1 -0
- package/dist/findGlobal.d.ts +3 -0
- package/dist/findGlobal.d.ts.map +1 -0
- package/dist/findGlobal.js +24 -0
- package/dist/findGlobal.js.map +1 -0
- package/dist/findGlobalVersions.d.ts +3 -0
- package/dist/findGlobalVersions.d.ts.map +1 -0
- package/dist/findGlobalVersions.js +24 -0
- package/dist/findGlobalVersions.js.map +1 -0
- package/dist/findOne.d.ts +4 -0
- package/dist/findOne.d.ts.map +1 -0
- package/dist/findOne.js +25 -0
- package/dist/findOne.js.map +1 -0
- package/dist/findVersions.d.ts +3 -0
- package/dist/findVersions.d.ts.map +1 -0
- package/dist/findVersions.js +25 -0
- package/dist/findVersions.js.map +1 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/dist/migrate.d.ts +3 -0
- package/dist/migrate.d.ts.map +1 -0
- package/dist/migrate.js +98 -0
- package/dist/migrate.js.map +1 -0
- package/dist/migrateDown.d.ts +3 -0
- package/dist/migrateDown.d.ts.map +1 -0
- package/dist/migrateDown.js +64 -0
- package/dist/migrateDown.js.map +1 -0
- package/dist/migrateFresh.d.ts +8 -0
- package/dist/migrateFresh.d.ts.map +1 -0
- package/dist/migrateFresh.js +77 -0
- package/dist/migrateFresh.js.map +1 -0
- package/dist/migrateRefresh.d.ts +6 -0
- package/dist/migrateRefresh.d.ts.map +1 -0
- package/dist/migrateRefresh.js +104 -0
- package/dist/migrateRefresh.js.map +1 -0
- package/dist/migrateReset.d.ts +6 -0
- package/dist/migrateReset.d.ts.map +1 -0
- package/dist/migrateReset.js +86 -0
- package/dist/migrateReset.js.map +1 -0
- package/dist/migrateStatus.d.ts +3 -0
- package/dist/migrateStatus.d.ts.map +1 -0
- package/dist/migrateStatus.js +44 -0
- package/dist/migrateStatus.js.map +1 -0
- package/dist/postgres/columnToCodeConverter.d.ts +3 -0
- package/dist/postgres/columnToCodeConverter.d.ts.map +1 -0
- package/dist/postgres/columnToCodeConverter.js +93 -0
- package/dist/postgres/columnToCodeConverter.js.map +1 -0
- package/dist/postgres/countDistinct.d.ts +3 -0
- package/dist/postgres/countDistinct.d.ts.map +1 -0
- package/dist/postgres/countDistinct.js +24 -0
- package/dist/postgres/countDistinct.js.map +1 -0
- package/dist/postgres/createDatabase.d.ts +14 -0
- package/dist/postgres/createDatabase.d.ts.map +1 -0
- package/dist/postgres/createDatabase.js +76 -0
- package/dist/postgres/createDatabase.js.map +1 -0
- package/dist/postgres/createExtensions.d.ts +3 -0
- package/dist/postgres/createExtensions.d.ts.map +1 -0
- package/dist/postgres/createExtensions.js +16 -0
- package/dist/postgres/createExtensions.js.map +1 -0
- package/dist/postgres/createJSONQuery/index.d.ts +3 -0
- package/dist/postgres/createJSONQuery/index.d.ts.map +1 -0
- package/dist/postgres/createJSONQuery/index.js +67 -0
- package/dist/postgres/createJSONQuery/index.js.map +1 -0
- package/dist/postgres/defaultSnapshot.d.ts +3 -0
- package/dist/postgres/defaultSnapshot.d.ts.map +1 -0
- package/dist/postgres/defaultSnapshot.js +20 -0
- package/dist/postgres/defaultSnapshot.js.map +1 -0
- package/dist/postgres/deleteWhere.d.ts +3 -0
- package/dist/postgres/deleteWhere.d.ts.map +1 -0
- package/dist/postgres/deleteWhere.js +6 -0
- package/dist/postgres/deleteWhere.js.map +1 -0
- package/dist/postgres/dropDatabase.d.ts +3 -0
- package/dist/postgres/dropDatabase.d.ts.map +1 -0
- package/dist/postgres/dropDatabase.js +9 -0
- package/dist/postgres/dropDatabase.js.map +1 -0
- package/dist/postgres/execute.d.ts +3 -0
- package/dist/postgres/execute.d.ts.map +1 -0
- package/dist/postgres/execute.js +11 -0
- package/dist/postgres/execute.js.map +1 -0
- package/dist/postgres/init.d.ts +3 -0
- package/dist/postgres/init.d.ts.map +1 -0
- package/dist/postgres/init.js +41 -0
- package/dist/postgres/init.js.map +1 -0
- package/dist/postgres/insert.d.ts +3 -0
- package/dist/postgres/insert.d.ts.map +1 -0
- package/dist/postgres/insert.js +12 -0
- package/dist/postgres/insert.js.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +19 -0
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/index.js +173 -0
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts +11 -0
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +151 -0
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts +3 -0
- package/dist/postgres/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/groupUpSQLStatements.js +114 -0
- package/dist/postgres/predefinedMigrations/v2-v3/groupUpSQLStatements.js.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/index.d.ts +23 -0
- package/dist/postgres/predefinedMigrations/v2-v3/index.d.ts.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/index.js +275 -0
- package/dist/postgres/predefinedMigrations/v2-v3/index.js.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/migrateRelationships.d.ts +19 -0
- package/dist/postgres/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/migrateRelationships.js +64 -0
- package/dist/postgres/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/traverseFields.d.ts +22 -0
- package/dist/postgres/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/traverseFields.js +64 -0
- package/dist/postgres/predefinedMigrations/v2-v3/traverseFields.js.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/types.d.ts +9 -0
- package/dist/postgres/predefinedMigrations/v2-v3/types.d.ts.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/types.js +6 -0
- package/dist/postgres/predefinedMigrations/v2-v3/types.js.map +1 -0
- package/dist/postgres/requireDrizzleKit.d.ts +3 -0
- package/dist/postgres/requireDrizzleKit.d.ts.map +1 -0
- package/dist/postgres/requireDrizzleKit.js +13 -0
- package/dist/postgres/requireDrizzleKit.js.map +1 -0
- package/dist/postgres/schema/buildDrizzleTable.d.ts +7 -0
- package/dist/postgres/schema/buildDrizzleTable.d.ts.map +1 -0
- package/dist/postgres/schema/buildDrizzleTable.js +157 -0
- package/dist/postgres/schema/buildDrizzleTable.js.map +1 -0
- package/dist/postgres/schema/geometryColumn.d.ts +11 -0
- package/dist/postgres/schema/geometryColumn.d.ts.map +1 -0
- package/dist/postgres/schema/geometryColumn.js +18 -0
- package/dist/postgres/schema/geometryColumn.js.map +1 -0
- package/dist/postgres/schema/setColumnID.d.ts +3 -0
- package/dist/postgres/schema/setColumnID.d.ts.map +1 -0
- package/dist/postgres/schema/setColumnID.js +47 -0
- package/dist/postgres/schema/setColumnID.js.map +1 -0
- package/dist/postgres/types.d.ts +199 -0
- package/dist/postgres/types.d.ts.map +1 -0
- package/dist/postgres/types.js +3 -0
- package/dist/postgres/types.js.map +1 -0
- package/dist/queries/addJoinTable.d.ts +13 -0
- package/dist/queries/addJoinTable.d.ts.map +1 -0
- package/dist/queries/addJoinTable.js +15 -0
- package/dist/queries/addJoinTable.js.map +1 -0
- package/dist/queries/buildAndOrConditions.d.ts +21 -0
- package/dist/queries/buildAndOrConditions.d.ts.map +1 -0
- package/dist/queries/buildAndOrConditions.js +30 -0
- package/dist/queries/buildAndOrConditions.js.map +1 -0
- package/dist/queries/buildOrderBy.d.ts +22 -0
- package/dist/queries/buildOrderBy.d.ts.map +1 -0
- package/dist/queries/buildOrderBy.js +71 -0
- package/dist/queries/buildOrderBy.js.map +1 -0
- package/dist/queries/buildQuery.d.ts +35 -0
- package/dist/queries/buildQuery.d.ts.map +1 -0
- package/dist/queries/buildQuery.js +46 -0
- package/dist/queries/buildQuery.js.map +1 -0
- package/dist/queries/getTableAlias.d.ts +13 -0
- package/dist/queries/getTableAlias.d.ts.map +1 -0
- package/dist/queries/getTableAlias.js +20 -0
- package/dist/queries/getTableAlias.js.map +1 -0
- package/dist/queries/getTableColumnFromPath.d.ts +58 -0
- package/dist/queries/getTableColumnFromPath.d.ts.map +1 -0
- package/dist/queries/getTableColumnFromPath.js +793 -0
- package/dist/queries/getTableColumnFromPath.js.map +1 -0
- package/dist/queries/operatorMap.d.ts +6 -0
- package/dist/queries/operatorMap.d.ts.map +1 -0
- package/dist/queries/operatorMap.js +22 -0
- package/dist/queries/operatorMap.js.map +1 -0
- package/dist/queries/parseParams.d.ts +24 -0
- package/dist/queries/parseParams.d.ts.map +1 -0
- package/dist/queries/parseParams.js +356 -0
- package/dist/queries/parseParams.js.map +1 -0
- package/dist/queries/sanitizeQueryValue.d.ts +26 -0
- package/dist/queries/sanitizeQueryValue.d.ts.map +1 -0
- package/dist/queries/sanitizeQueryValue.js +246 -0
- package/dist/queries/sanitizeQueryValue.js.map +1 -0
- package/dist/queries/selectDistinct.d.ts +25 -0
- package/dist/queries/selectDistinct.d.ts.map +1 -0
- package/dist/queries/selectDistinct.js +29 -0
- package/dist/queries/selectDistinct.js.map +1 -0
- package/dist/queryDrafts.d.ts +3 -0
- package/dist/queryDrafts.d.ts.map +1 -0
- package/dist/queryDrafts.js +41 -0
- package/dist/queryDrafts.js.map +1 -0
- package/dist/schema/build.d.ts +50 -0
- package/dist/schema/build.d.ts.map +1 -0
- package/dist/schema/build.js +705 -0
- package/dist/schema/build.js.map +1 -0
- package/dist/schema/buildDrizzleRelations.d.ts +5 -0
- package/dist/schema/buildDrizzleRelations.d.ts.map +1 -0
- package/dist/schema/buildDrizzleRelations.js +28 -0
- package/dist/schema/buildDrizzleRelations.js.map +1 -0
- package/dist/schema/buildRawSchema.d.ts +9 -0
- package/dist/schema/buildRawSchema.d.ts.map +1 -0
- package/dist/schema/buildRawSchema.js +117 -0
- package/dist/schema/buildRawSchema.js.map +1 -0
- package/dist/schema/idToUUID.d.ts +3 -0
- package/dist/schema/idToUUID.d.ts.map +1 -0
- package/dist/schema/idToUUID.js +11 -0
- package/dist/schema/idToUUID.js.map +1 -0
- package/dist/schema/traverseFields.d.ts +44 -0
- package/dist/schema/traverseFields.d.ts.map +1 -0
- package/dist/schema/traverseFields.js +810 -0
- package/dist/schema/traverseFields.js.map +1 -0
- package/dist/schema/withDefault.d.ts +4 -0
- package/dist/schema/withDefault.d.ts.map +1 -0
- package/dist/schema/withDefault.js +11 -0
- package/dist/schema/withDefault.js.map +1 -0
- package/dist/sqlite/columnToCodeConverter.d.ts +3 -0
- package/dist/sqlite/columnToCodeConverter.d.ts.map +1 -0
- package/dist/sqlite/columnToCodeConverter.js +116 -0
- package/dist/sqlite/columnToCodeConverter.js.map +1 -0
- package/dist/sqlite/countDistinct.d.ts +3 -0
- package/dist/sqlite/countDistinct.d.ts.map +1 -0
- package/dist/sqlite/countDistinct.js +24 -0
- package/dist/sqlite/countDistinct.js.map +1 -0
- package/dist/sqlite/createJSONQuery/convertPathToJSONTraversal.d.ts +2 -0
- package/dist/sqlite/createJSONQuery/convertPathToJSONTraversal.d.ts.map +1 -0
- package/dist/sqlite/createJSONQuery/convertPathToJSONTraversal.js +14 -0
- package/dist/sqlite/createJSONQuery/convertPathToJSONTraversal.js.map +1 -0
- package/dist/sqlite/createJSONQuery/index.d.ts +3 -0
- package/dist/sqlite/createJSONQuery/index.d.ts.map +1 -0
- package/dist/sqlite/createJSONQuery/index.js +109 -0
- package/dist/sqlite/createJSONQuery/index.js.map +1 -0
- package/dist/sqlite/defaultSnapshot.d.ts +3 -0
- package/dist/sqlite/defaultSnapshot.d.ts.map +1 -0
- package/dist/sqlite/defaultSnapshot.js +15 -0
- package/dist/sqlite/defaultSnapshot.js.map +1 -0
- package/dist/sqlite/deleteWhere.d.ts +3 -0
- package/dist/sqlite/deleteWhere.d.ts.map +1 -0
- package/dist/sqlite/deleteWhere.js +6 -0
- package/dist/sqlite/deleteWhere.js.map +1 -0
- package/dist/sqlite/dropDatabase.d.ts +3 -0
- package/dist/sqlite/dropDatabase.d.ts.map +1 -0
- package/dist/sqlite/dropDatabase.js +19 -0
- package/dist/sqlite/dropDatabase.js.map +1 -0
- package/dist/sqlite/execute.d.ts +3 -0
- package/dist/sqlite/execute.d.ts.map +1 -0
- package/dist/sqlite/execute.js +13 -0
- package/dist/sqlite/execute.js.map +1 -0
- package/dist/sqlite/init.d.ts +3 -0
- package/dist/sqlite/init.d.ts.map +1 -0
- package/dist/sqlite/init.js +42 -0
- package/dist/sqlite/init.js.map +1 -0
- package/dist/sqlite/insert.d.ts +3 -0
- package/dist/sqlite/insert.d.ts.map +1 -0
- package/dist/sqlite/insert.js +21 -0
- package/dist/sqlite/insert.js.map +1 -0
- package/dist/sqlite/requireDrizzleKit.d.ts +3 -0
- package/dist/sqlite/requireDrizzleKit.d.ts.map +1 -0
- package/dist/sqlite/requireDrizzleKit.js +12 -0
- package/dist/sqlite/requireDrizzleKit.js.map +1 -0
- package/dist/sqlite/schema/buildDrizzleTable.d.ts +3 -0
- package/dist/sqlite/schema/buildDrizzleTable.d.ts.map +1 -0
- package/dist/sqlite/schema/buildDrizzleTable.js +153 -0
- package/dist/sqlite/schema/buildDrizzleTable.js.map +1 -0
- package/dist/sqlite/schema/setColumnID.d.ts +3 -0
- package/dist/sqlite/schema/setColumnID.d.ts.map +1 -0
- package/dist/sqlite/schema/setColumnID.js +48 -0
- package/dist/sqlite/schema/setColumnID.js.map +1 -0
- package/dist/sqlite/types.d.ts +214 -0
- package/dist/sqlite/types.d.ts.map +1 -0
- package/dist/sqlite/types.js +3 -0
- package/dist/sqlite/types.js.map +1 -0
- package/dist/transactions/beginTransaction.d.ts +3 -0
- package/dist/transactions/beginTransaction.d.ts.map +1 -0
- package/dist/transactions/beginTransaction.js +59 -0
- package/dist/transactions/beginTransaction.js.map +1 -0
- package/dist/transactions/commitTransaction.d.ts +3 -0
- package/dist/transactions/commitTransaction.d.ts.map +1 -0
- package/dist/transactions/commitTransaction.js +18 -0
- package/dist/transactions/commitTransaction.js.map +1 -0
- package/dist/transactions/rollbackTransaction.d.ts +3 -0
- package/dist/transactions/rollbackTransaction.d.ts.map +1 -0
- package/dist/transactions/rollbackTransaction.js +16 -0
- package/dist/transactions/rollbackTransaction.js.map +1 -0
- package/dist/transform/read/hasManyNumber.d.ts +11 -0
- package/dist/transform/read/hasManyNumber.d.ts.map +1 -0
- package/dist/transform/read/hasManyNumber.js +28 -0
- package/dist/transform/read/hasManyNumber.js.map +1 -0
- package/dist/transform/read/hasManyText.d.ts +11 -0
- package/dist/transform/read/hasManyText.d.ts.map +1 -0
- package/dist/transform/read/hasManyText.js +20 -0
- package/dist/transform/read/hasManyText.js.map +1 -0
- package/dist/transform/read/index.d.ts +16 -0
- package/dist/transform/read/index.d.ts.map +1 -0
- package/dist/transform/read/index.js +49 -0
- package/dist/transform/read/index.js.map +1 -0
- package/dist/transform/read/relationship.d.ts +11 -0
- package/dist/transform/read/relationship.d.ts.map +1 -0
- package/dist/transform/read/relationship.js +69 -0
- package/dist/transform/read/relationship.js.map +1 -0
- package/dist/transform/read/traverseFields.d.ts +68 -0
- package/dist/transform/read/traverseFields.d.ts.map +1 -0
- package/dist/transform/read/traverseFields.js +542 -0
- package/dist/transform/read/traverseFields.js.map +1 -0
- package/dist/transform/write/array.d.ts +34 -0
- package/dist/transform/write/array.d.ts.map +1 -0
- package/dist/transform/write/array.js +73 -0
- package/dist/transform/write/array.js.map +1 -0
- package/dist/transform/write/blocks.d.ts +33 -0
- package/dist/transform/write/blocks.d.ts.map +1 -0
- package/dist/transform/write/blocks.js +78 -0
- package/dist/transform/write/blocks.js.map +1 -0
- package/dist/transform/write/index.d.ts +15 -0
- package/dist/transform/write/index.d.ts.map +1 -0
- package/dist/transform/write/index.js +51 -0
- package/dist/transform/write/index.js.map +1 -0
- package/dist/transform/write/numbers.d.ts +8 -0
- package/dist/transform/write/numbers.d.ts.map +1 -0
- package/dist/transform/write/numbers.js +11 -0
- package/dist/transform/write/numbers.js.map +1 -0
- package/dist/transform/write/relationships.d.ts +10 -0
- package/dist/transform/write/relationships.d.ts.map +1 -0
- package/dist/transform/write/relationships.js +27 -0
- package/dist/transform/write/relationships.js.map +1 -0
- package/dist/transform/write/selects.d.ts +8 -0
- package/dist/transform/write/selects.d.ts.map +1 -0
- package/dist/transform/write/selects.js +20 -0
- package/dist/transform/write/selects.js.map +1 -0
- package/dist/transform/write/texts.d.ts +8 -0
- package/dist/transform/write/texts.d.ts.map +1 -0
- package/dist/transform/write/texts.js +11 -0
- package/dist/transform/write/texts.js.map +1 -0
- package/dist/transform/write/traverseFields.d.ts +68 -0
- package/dist/transform/write/traverseFields.d.ts.map +1 -0
- package/dist/transform/write/traverseFields.js +661 -0
- package/dist/transform/write/traverseFields.js.map +1 -0
- package/dist/transform/write/types.d.ts +71 -0
- package/dist/transform/write/types.d.ts.map +1 -0
- package/dist/transform/write/types.js +3 -0
- package/dist/transform/write/types.js.map +1 -0
- package/dist/types.d.ts +355 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/updateGlobal.d.ts +4 -0
- package/dist/updateGlobal.d.ts.map +1 -0
- package/dist/updateGlobal.js +34 -0
- package/dist/updateGlobal.js.map +1 -0
- package/dist/updateGlobalVersion.d.ts +4 -0
- package/dist/updateGlobalVersion.d.ts.map +1 -0
- package/dist/updateGlobalVersion.js +44 -0
- package/dist/updateGlobalVersion.js.map +1 -0
- package/dist/updateJobs.d.ts +3 -0
- package/dist/updateJobs.d.ts.map +1 -0
- package/dist/updateJobs.js +84 -0
- package/dist/updateJobs.js.map +1 -0
- package/dist/updateMany.d.ts +3 -0
- package/dist/updateMany.d.ts.map +1 -0
- package/dist/updateMany.js +76 -0
- package/dist/updateMany.js.map +1 -0
- package/dist/updateOne.d.ts +3 -0
- package/dist/updateOne.d.ts.map +1 -0
- package/dist/updateOne.js +69 -0
- package/dist/updateOne.js.map +1 -0
- package/dist/updateVersion.d.ts +4 -0
- package/dist/updateVersion.d.ts.map +1 -0
- package/dist/updateVersion.js +45 -0
- package/dist/updateVersion.js.map +1 -0
- package/dist/upsert.d.ts +3 -0
- package/dist/upsert.d.ts.map +1 -0
- package/dist/upsert.js +17 -0
- package/dist/upsert.js.map +1 -0
- package/dist/upsertRow/deleteExistingArrayRows.d.ts +10 -0
- package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +1 -0
- package/dist/upsertRow/deleteExistingArrayRows.js +14 -0
- package/dist/upsertRow/deleteExistingArrayRows.js.map +1 -0
- package/dist/upsertRow/deleteExistingRowsByPath.d.ts +14 -0
- package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +1 -0
- package/dist/upsertRow/deleteExistingRowsByPath.js +45 -0
- package/dist/upsertRow/deleteExistingRowsByPath.js.map +1 -0
- package/dist/upsertRow/handleUpsertError.d.ts +19 -0
- package/dist/upsertRow/handleUpsertError.d.ts.map +1 -0
- package/dist/upsertRow/handleUpsertError.js +66 -0
- package/dist/upsertRow/handleUpsertError.js.map +1 -0
- package/dist/upsertRow/handleUpsertError.spec.js +42 -0
- package/dist/upsertRow/handleUpsertError.spec.js.map +1 -0
- package/dist/upsertRow/index.d.ts +11 -0
- package/dist/upsertRow/index.d.ts.map +1 -0
- package/dist/upsertRow/index.js +668 -0
- package/dist/upsertRow/index.js.map +1 -0
- package/dist/upsertRow/insertArrays.d.ts +14 -0
- package/dist/upsertRow/insertArrays.d.ts.map +1 -0
- package/dist/upsertRow/insertArrays.js +87 -0
- package/dist/upsertRow/insertArrays.js.map +1 -0
- package/dist/upsertRow/shouldUseOptimizedUpsertRow.d.ts +10 -0
- package/dist/upsertRow/shouldUseOptimizedUpsertRow.d.ts.map +1 -0
- package/dist/upsertRow/shouldUseOptimizedUpsertRow.js +63 -0
- package/dist/upsertRow/shouldUseOptimizedUpsertRow.js.map +1 -0
- package/dist/upsertRow/types.d.ts +47 -0
- package/dist/upsertRow/types.d.ts.map +1 -0
- package/dist/upsertRow/types.js +3 -0
- package/dist/upsertRow/types.js.map +1 -0
- package/dist/utilities/appendPrefixToKeys.d.ts +2 -0
- package/dist/utilities/appendPrefixToKeys.d.ts.map +1 -0
- package/dist/utilities/appendPrefixToKeys.js +6 -0
- package/dist/utilities/appendPrefixToKeys.js.map +1 -0
- package/dist/utilities/blocksToJsonMigrator.d.ts +15 -0
- package/dist/utilities/blocksToJsonMigrator.d.ts.map +1 -0
- package/dist/utilities/blocksToJsonMigrator.js +587 -0
- package/dist/utilities/blocksToJsonMigrator.js.map +1 -0
- package/dist/utilities/buildCreateMigration.d.ts +10 -0
- package/dist/utilities/buildCreateMigration.d.ts.map +1 -0
- package/dist/utilities/buildCreateMigration.js +121 -0
- package/dist/utilities/buildCreateMigration.js.map +1 -0
- package/dist/utilities/buildForeignKeyName.d.ts +7 -0
- package/dist/utilities/buildForeignKeyName.d.ts.map +1 -0
- package/dist/utilities/buildForeignKeyName.js +18 -0
- package/dist/utilities/buildForeignKeyName.js.map +1 -0
- package/dist/utilities/buildIndexName.d.ts +8 -0
- package/dist/utilities/buildIndexName.d.ts.map +1 -0
- package/dist/utilities/buildIndexName.js +19 -0
- package/dist/utilities/buildIndexName.js.map +1 -0
- package/dist/utilities/createBlocksMap.d.ts +5 -0
- package/dist/utilities/createBlocksMap.d.ts.map +1 -0
- package/dist/utilities/createBlocksMap.js +35 -0
- package/dist/utilities/createBlocksMap.js.map +1 -0
- package/dist/utilities/createRelationshipMap.d.ts +2 -0
- package/dist/utilities/createRelationshipMap.d.ts.map +1 -0
- package/dist/utilities/createRelationshipMap.js +21 -0
- package/dist/utilities/createRelationshipMap.js.map +1 -0
- package/dist/utilities/createSchemaGenerator.d.ts +11 -0
- package/dist/utilities/createSchemaGenerator.d.ts.map +1 -0
- package/dist/utilities/createSchemaGenerator.js +257 -0
- package/dist/utilities/createSchemaGenerator.js.map +1 -0
- package/dist/utilities/escapeSQLValue.d.ts +3 -0
- package/dist/utilities/escapeSQLValue.d.ts.map +1 -0
- package/dist/utilities/escapeSQLValue.js +20 -0
- package/dist/utilities/escapeSQLValue.js.map +1 -0
- package/dist/utilities/executeSchemaHooks.d.ts +24 -0
- package/dist/utilities/executeSchemaHooks.d.ts.map +1 -0
- package/dist/utilities/executeSchemaHooks.js +21 -0
- package/dist/utilities/executeSchemaHooks.js.map +1 -0
- package/dist/utilities/extendDrizzleTable.d.ts +19 -0
- package/dist/utilities/extendDrizzleTable.d.ts.map +1 -0
- package/dist/utilities/extendDrizzleTable.js +38 -0
- package/dist/utilities/extendDrizzleTable.js.map +1 -0
- package/dist/utilities/getArrayRelationName.d.ts +7 -0
- package/dist/utilities/getArrayRelationName.d.ts.map +1 -0
- package/dist/utilities/getArrayRelationName.js +8 -0
- package/dist/utilities/getArrayRelationName.js.map +1 -0
- package/dist/utilities/getCollectionIdType.d.ts +7 -0
- package/dist/utilities/getCollectionIdType.d.ts.map +1 -0
- package/dist/utilities/getCollectionIdType.js +12 -0
- package/dist/utilities/getCollectionIdType.js.map +1 -0
- package/dist/utilities/getMigrationTemplate.d.ts +4 -0
- package/dist/utilities/getMigrationTemplate.d.ts.map +1 -0
- package/dist/utilities/getMigrationTemplate.js +13 -0
- package/dist/utilities/getMigrationTemplate.js.map +1 -0
- package/dist/utilities/getNameFromDrizzleTable.d.ts +3 -0
- package/dist/utilities/getNameFromDrizzleTable.d.ts.map +1 -0
- package/dist/utilities/getNameFromDrizzleTable.js +6 -0
- package/dist/utilities/getNameFromDrizzleTable.js.map +1 -0
- package/dist/utilities/getPrimaryDb.d.ts +6 -0
- package/dist/utilities/getPrimaryDb.d.ts.map +1 -0
- package/dist/utilities/getPrimaryDb.js +10 -0
- package/dist/utilities/getPrimaryDb.js.map +1 -0
- package/dist/utilities/getTransaction.d.ts +13 -0
- package/dist/utilities/getTransaction.d.ts.map +1 -0
- package/dist/utilities/getTransaction.js +20 -0
- package/dist/utilities/getTransaction.js.map +1 -0
- package/dist/utilities/hasLocalesTable.d.ts +9 -0
- package/dist/utilities/hasLocalesTable.d.ts.map +1 -0
- package/dist/utilities/hasLocalesTable.js +30 -0
- package/dist/utilities/hasLocalesTable.js.map +1 -0
- package/dist/utilities/isArrayOfRows.d.ts +2 -0
- package/dist/utilities/isArrayOfRows.d.ts.map +1 -0
- package/dist/utilities/isArrayOfRows.js +5 -0
- package/dist/utilities/isArrayOfRows.js.map +1 -0
- package/dist/utilities/isPolymorphicRelationship.d.ts +6 -0
- package/dist/utilities/isPolymorphicRelationship.d.ts.map +1 -0
- package/dist/utilities/isPolymorphicRelationship.js +5 -0
- package/dist/utilities/isPolymorphicRelationship.js.map +1 -0
- package/dist/utilities/isUUIDType.d.ts +2 -0
- package/dist/utilities/isUUIDType.d.ts.map +1 -0
- package/dist/utilities/isUUIDType.js +3 -0
- package/dist/utilities/isUUIDType.js.map +1 -0
- package/dist/utilities/isValidStringID.d.ts +2 -0
- package/dist/utilities/isValidStringID.d.ts.map +1 -0
- package/dist/utilities/isValidStringID.js +5 -0
- package/dist/utilities/isValidStringID.js.map +1 -0
- package/dist/utilities/isValidStringID.spec.js +15 -0
- package/dist/utilities/isValidStringID.spec.js.map +1 -0
- package/dist/utilities/json.d.ts +9 -0
- package/dist/utilities/json.d.ts.map +1 -0
- package/dist/utilities/json.js +33 -0
- package/dist/utilities/json.js.map +1 -0
- package/dist/utilities/migrationTableExists.d.ts +4 -0
- package/dist/utilities/migrationTableExists.d.ts.map +1 -0
- package/dist/utilities/migrationTableExists.js +25 -0
- package/dist/utilities/migrationTableExists.js.map +1 -0
- package/dist/utilities/parseError.d.ts +5 -0
- package/dist/utilities/parseError.d.ts.map +1 -0
- package/dist/utilities/parseError.js +15 -0
- package/dist/utilities/parseError.js.map +1 -0
- package/dist/utilities/pushDevSchema.d.ts +9 -0
- package/dist/utilities/pushDevSchema.d.ts.map +1 -0
- package/dist/utilities/pushDevSchema.js +83 -0
- package/dist/utilities/pushDevSchema.js.map +1 -0
- package/dist/utilities/rawConstraint.d.ts +10 -0
- package/dist/utilities/rawConstraint.d.ts.map +1 -0
- package/dist/utilities/rawConstraint.js +13 -0
- package/dist/utilities/rawConstraint.js.map +1 -0
- package/dist/utilities/readAfterWrite.d.ts +17 -0
- package/dist/utilities/readAfterWrite.d.ts.map +1 -0
- package/dist/utilities/readAfterWrite.js +21 -0
- package/dist/utilities/readAfterWrite.js.map +1 -0
- package/dist/utilities/sanitizePathSegment.d.ts +2 -0
- package/dist/utilities/sanitizePathSegment.d.ts.map +1 -0
- package/dist/utilities/sanitizePathSegment.js +14 -0
- package/dist/utilities/sanitizePathSegment.js.map +1 -0
- package/dist/utilities/validateExistingBlockIsIdentical.d.ts +22 -0
- package/dist/utilities/validateExistingBlockIsIdentical.d.ts.map +1 -0
- package/dist/utilities/validateExistingBlockIsIdentical.js +100 -0
- package/dist/utilities/validateExistingBlockIsIdentical.js.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,653 @@
|
|
|
1
|
+
import { and, asc, count, desc, eq, getTableName, or, sql } from 'drizzle-orm';
|
|
2
|
+
import { appendVersionToQueryKey, buildVersionCollectionFields, combineQueries, getFieldByPath, getQueryDraftsSort } from '@hanzo/cms';
|
|
3
|
+
import { fieldIsVirtual, fieldShouldBeLocalized, hasDraftsEnabled } from '@hanzo/cms/shared';
|
|
4
|
+
import toSnakeCase from 'to-snake-case';
|
|
5
|
+
import { buildQuery } from '../queries/buildQuery.js';
|
|
6
|
+
import { getTableAlias } from '../queries/getTableAlias.js';
|
|
7
|
+
import { operatorMap } from '../queries/operatorMap.js';
|
|
8
|
+
import { getArrayRelationName } from '../utilities/getArrayRelationName.js';
|
|
9
|
+
import { getNameFromDrizzleTable } from '../utilities/getNameFromDrizzleTable.js';
|
|
10
|
+
import { jsonAggBuildObject } from '../utilities/json.js';
|
|
11
|
+
import { rawConstraint } from '../utilities/rawConstraint.js';
|
|
12
|
+
import { sanitizePathSegment } from '../utilities/sanitizePathSegment.js';
|
|
13
|
+
import { InternalBlockTableNameIndex, resolveBlockTableName } from '../utilities/validateExistingBlockIsIdentical.js';
|
|
14
|
+
const flattenAllWherePaths = (where, paths)=>{
|
|
15
|
+
for(const k in where){
|
|
16
|
+
if ([
|
|
17
|
+
'AND',
|
|
18
|
+
'OR'
|
|
19
|
+
].includes(k.toUpperCase())) {
|
|
20
|
+
if (Array.isArray(where[k])) {
|
|
21
|
+
for (const whereField of where[k]){
|
|
22
|
+
flattenAllWherePaths(whereField, paths);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
// TODO: explore how to support arrays/relationship querying.
|
|
27
|
+
paths.push({
|
|
28
|
+
path: k.split('.').join('_'),
|
|
29
|
+
ref: where
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const buildSQLWhere = (where, alias)=>{
|
|
35
|
+
for(const k in where){
|
|
36
|
+
if ([
|
|
37
|
+
'AND',
|
|
38
|
+
'OR'
|
|
39
|
+
].includes(k.toUpperCase())) {
|
|
40
|
+
if (Array.isArray(where[k])) {
|
|
41
|
+
const op = 'AND' === k.toUpperCase() ? and : or;
|
|
42
|
+
const accumulated = [];
|
|
43
|
+
for (const whereField of where[k]){
|
|
44
|
+
accumulated.push(buildSQLWhere(whereField, alias));
|
|
45
|
+
}
|
|
46
|
+
return op(...accumulated);
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
let cmsOperator = Object.keys(where[k])[0];
|
|
50
|
+
const value = where[k][cmsOperator];
|
|
51
|
+
if (cmsOperator === '$raw') {
|
|
52
|
+
if (typeof value !== 'string') {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
return sql.raw(value);
|
|
56
|
+
}
|
|
57
|
+
// Handle exists: false -> use isNull instead of isNotNull
|
|
58
|
+
// This logic is duplicated from sanitizeQueryValue.ts because buildSQLWhere
|
|
59
|
+
// is a simplified WHERE builder for polymorphic joins that doesn't have access
|
|
60
|
+
// to field definitions needed by sanitizeQueryValue
|
|
61
|
+
if (cmsOperator === 'exists' && value === false) {
|
|
62
|
+
cmsOperator = 'isNull';
|
|
63
|
+
}
|
|
64
|
+
if (!(cmsOperator in operatorMap)) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
const sanitizedColumnName = k.split('.').map((s)=>sanitizePathSegment(s)).join('_');
|
|
68
|
+
return operatorMap[cmsOperator](sql.raw(`"${alias}"."${sanitizedColumnName}"`), value);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
export const traverseFields = ({ _locales, adapter, collectionSlug, currentArgs, currentTableName, depth, draftsEnabled, fields, forceWithFields, joinQuery = {}, joins, locale, parentIsLocalized = false, path, select, selectAllOnCurrentLevel = false, selectMode, tablePath, topLevelArgs, topLevelTableName, versions, withTabledFields })=>{
|
|
73
|
+
fields.forEach((field)=>{
|
|
74
|
+
if (fieldIsVirtual(field)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const isFieldLocalized = fieldShouldBeLocalized({
|
|
78
|
+
field,
|
|
79
|
+
parentIsLocalized
|
|
80
|
+
});
|
|
81
|
+
// handle simple relationship
|
|
82
|
+
if (depth > 0 && (field.type === 'upload' || field.type === 'relationship') && !field.hasMany && typeof field.relationTo === 'string') {
|
|
83
|
+
if (isFieldLocalized) {
|
|
84
|
+
_locales.with[`${path}${field.name}`] = true;
|
|
85
|
+
} else {
|
|
86
|
+
currentArgs.with[`${path}${field.name}`] = true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
switch(field.type){
|
|
90
|
+
case 'array':
|
|
91
|
+
{
|
|
92
|
+
const arraySelect = selectAllOnCurrentLevel ? true : select?.[field.name];
|
|
93
|
+
if (select) {
|
|
94
|
+
if (selectMode === 'include' && typeof arraySelect === 'undefined' || selectMode === 'exclude' && arraySelect === false) {
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const withArray = {
|
|
99
|
+
columns: typeof arraySelect === 'object' ? {
|
|
100
|
+
id: true,
|
|
101
|
+
_order: true
|
|
102
|
+
} : {
|
|
103
|
+
_parentID: false
|
|
104
|
+
},
|
|
105
|
+
orderBy: ({ _order }, { asc })=>[
|
|
106
|
+
asc(_order)
|
|
107
|
+
],
|
|
108
|
+
with: {}
|
|
109
|
+
};
|
|
110
|
+
const arrayTableName = adapter.tableNameMap.get(`${currentTableName}_${tablePath}${toSnakeCase(field.name)}`);
|
|
111
|
+
if (typeof arraySelect === 'object') {
|
|
112
|
+
if (adapter.tables[arrayTableName]._locale) {
|
|
113
|
+
withArray.columns._locale = true;
|
|
114
|
+
}
|
|
115
|
+
if (adapter.tables[arrayTableName]._uuid) {
|
|
116
|
+
withArray.columns._uuid = true;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const arrayTableNameWithLocales = `${arrayTableName}${adapter.localesSuffix}`;
|
|
120
|
+
if (adapter.tables[arrayTableNameWithLocales]) {
|
|
121
|
+
withArray.with._locales = {
|
|
122
|
+
columns: typeof arraySelect === 'object' ? {
|
|
123
|
+
_locale: true
|
|
124
|
+
} : {
|
|
125
|
+
id: false,
|
|
126
|
+
_parentID: false
|
|
127
|
+
},
|
|
128
|
+
with: {}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
const relationName = getArrayRelationName({
|
|
132
|
+
field,
|
|
133
|
+
path: `${path}${field.name}`,
|
|
134
|
+
tableName: arrayTableName
|
|
135
|
+
});
|
|
136
|
+
currentArgs.with[relationName] = withArray;
|
|
137
|
+
traverseFields({
|
|
138
|
+
_locales: withArray.with._locales,
|
|
139
|
+
adapter,
|
|
140
|
+
currentArgs: withArray,
|
|
141
|
+
currentTableName: arrayTableName,
|
|
142
|
+
depth,
|
|
143
|
+
draftsEnabled,
|
|
144
|
+
fields: field.flattenedFields,
|
|
145
|
+
forceWithFields,
|
|
146
|
+
joinQuery,
|
|
147
|
+
locale,
|
|
148
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
149
|
+
path: '',
|
|
150
|
+
select: typeof arraySelect === 'object' ? arraySelect : undefined,
|
|
151
|
+
selectMode,
|
|
152
|
+
tablePath: '',
|
|
153
|
+
topLevelArgs,
|
|
154
|
+
topLevelTableName,
|
|
155
|
+
withTabledFields
|
|
156
|
+
});
|
|
157
|
+
if (typeof arraySelect === 'object' && withArray.with._locales && Object.keys(withArray.with._locales).length === 1) {
|
|
158
|
+
delete withArray.with._locales;
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case 'blocks':
|
|
163
|
+
{
|
|
164
|
+
const blocksSelect = selectAllOnCurrentLevel ? true : select?.[field.name];
|
|
165
|
+
if (select) {
|
|
166
|
+
if (selectMode === 'include' && !blocksSelect || selectMode === 'exclude' && blocksSelect === false) {
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (adapter.blocksAsJSON) {
|
|
171
|
+
if (select || selectAllOnCurrentLevel) {
|
|
172
|
+
const fieldPath = `${path}${field.name}`;
|
|
173
|
+
if ((isFieldLocalized || parentIsLocalized) && _locales) {
|
|
174
|
+
_locales.columns[fieldPath] = true;
|
|
175
|
+
} else if (adapter.tables[currentTableName]?.[fieldPath]) {
|
|
176
|
+
currentArgs.columns[fieldPath] = true;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
;
|
|
182
|
+
(field.blockReferences ?? field.blocks).forEach((_block)=>{
|
|
183
|
+
const block = typeof _block === 'string' ? adapter.cms.blocks[_block] : _block;
|
|
184
|
+
const blockKey = `_blocks_${block.slug}${!block[InternalBlockTableNameIndex] ? '' : `_${block[InternalBlockTableNameIndex]}`}`;
|
|
185
|
+
let blockSelect;
|
|
186
|
+
let blockSelectMode = selectMode;
|
|
187
|
+
if (selectMode === 'include' && blocksSelect === true) {
|
|
188
|
+
blockSelect = true;
|
|
189
|
+
}
|
|
190
|
+
if (typeof blocksSelect === 'object') {
|
|
191
|
+
if (typeof blocksSelect[block.slug] === 'object') {
|
|
192
|
+
blockSelect = blocksSelect[block.slug];
|
|
193
|
+
} else if (selectMode === 'include' && typeof blocksSelect[block.slug] === 'undefined' || selectMode === 'exclude' && blocksSelect[block.slug] === false) {
|
|
194
|
+
blockSelect = {};
|
|
195
|
+
blockSelectMode = 'include';
|
|
196
|
+
} else if (selectMode === 'include' && Boolean(blocksSelect[block.slug])) {
|
|
197
|
+
blockSelect = true;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (!topLevelArgs[blockKey]) {
|
|
201
|
+
const withBlock = {
|
|
202
|
+
columns: typeof blockSelect === 'object' ? {
|
|
203
|
+
id: true,
|
|
204
|
+
_order: true,
|
|
205
|
+
_path: true
|
|
206
|
+
} : {
|
|
207
|
+
_parentID: false
|
|
208
|
+
},
|
|
209
|
+
orderBy: ({ _order }, { asc })=>[
|
|
210
|
+
asc(_order)
|
|
211
|
+
],
|
|
212
|
+
with: {}
|
|
213
|
+
};
|
|
214
|
+
const tableName = resolveBlockTableName(block, adapter.tableNameMap.get(`${topLevelTableName}_blocks_${toSnakeCase(block.slug)}`));
|
|
215
|
+
if (typeof blockSelect === 'object') {
|
|
216
|
+
if (adapter.tables[tableName]._locale) {
|
|
217
|
+
withBlock.columns._locale = true;
|
|
218
|
+
}
|
|
219
|
+
if (adapter.tables[tableName]._uuid) {
|
|
220
|
+
withBlock.columns._uuid = true;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (adapter.tables[`${tableName}${adapter.localesSuffix}`]) {
|
|
224
|
+
withBlock.with._locales = {
|
|
225
|
+
with: {}
|
|
226
|
+
};
|
|
227
|
+
if (typeof blockSelect === 'object') {
|
|
228
|
+
withBlock.with._locales.columns = {
|
|
229
|
+
_locale: true
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
topLevelArgs.with[blockKey] = withBlock;
|
|
234
|
+
traverseFields({
|
|
235
|
+
_locales: withBlock.with._locales,
|
|
236
|
+
adapter,
|
|
237
|
+
currentArgs: withBlock,
|
|
238
|
+
currentTableName: tableName,
|
|
239
|
+
depth,
|
|
240
|
+
draftsEnabled,
|
|
241
|
+
fields: block.flattenedFields,
|
|
242
|
+
forceWithFields: blockSelect === true,
|
|
243
|
+
joinQuery,
|
|
244
|
+
locale,
|
|
245
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
246
|
+
path: '',
|
|
247
|
+
select: typeof blockSelect === 'object' ? blockSelect : undefined,
|
|
248
|
+
selectMode: blockSelectMode,
|
|
249
|
+
tablePath: '',
|
|
250
|
+
topLevelArgs,
|
|
251
|
+
topLevelTableName,
|
|
252
|
+
withTabledFields
|
|
253
|
+
});
|
|
254
|
+
if (typeof blockSelect === 'object' && withBlock.with._locales && Object.keys(withBlock.with._locales.columns).length === 1) {
|
|
255
|
+
delete withBlock.with._locales;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
case 'group':
|
|
262
|
+
case 'tab':
|
|
263
|
+
{
|
|
264
|
+
const fieldSelect = select?.[field.name];
|
|
265
|
+
if (fieldSelect === false) {
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
traverseFields({
|
|
269
|
+
_locales,
|
|
270
|
+
adapter,
|
|
271
|
+
collectionSlug,
|
|
272
|
+
currentArgs,
|
|
273
|
+
currentTableName,
|
|
274
|
+
depth,
|
|
275
|
+
draftsEnabled,
|
|
276
|
+
fields: field.flattenedFields,
|
|
277
|
+
forceWithFields,
|
|
278
|
+
joinQuery,
|
|
279
|
+
joins,
|
|
280
|
+
locale,
|
|
281
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
282
|
+
path: `${path}${field.name}_`,
|
|
283
|
+
select: typeof fieldSelect === 'object' ? fieldSelect : undefined,
|
|
284
|
+
selectAllOnCurrentLevel: selectAllOnCurrentLevel || fieldSelect === true || selectMode === 'exclude' && typeof fieldSelect === 'undefined',
|
|
285
|
+
selectMode,
|
|
286
|
+
tablePath: `${tablePath}${toSnakeCase(field.name)}_`,
|
|
287
|
+
topLevelArgs,
|
|
288
|
+
topLevelTableName,
|
|
289
|
+
versions,
|
|
290
|
+
withTabledFields
|
|
291
|
+
});
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
case 'join':
|
|
295
|
+
{
|
|
296
|
+
// when `joinsQuery` is false, do not join
|
|
297
|
+
if (joinQuery === false) {
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
if (select && selectMode === 'include' && !select[field.name] || selectMode === 'exclude' && select[field.name] === false) {
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
const joinSchemaPath = `${path.replaceAll('_', '.')}${field.name}`;
|
|
304
|
+
if (joinQuery[joinSchemaPath] === false) {
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
const { count: shouldCount = false, limit: limitArg = field.defaultLimit ?? 10, page, sort = field.defaultSort, where } = joinQuery[joinSchemaPath] || {};
|
|
308
|
+
let limit = limitArg;
|
|
309
|
+
if (limit !== 0) {
|
|
310
|
+
// get an additional document and slice it later to determine if there is a next page
|
|
311
|
+
limit += 1;
|
|
312
|
+
}
|
|
313
|
+
const columnName = `${path.replaceAll('.', '_')}${field.name}`;
|
|
314
|
+
const db = adapter.drizzle;
|
|
315
|
+
if (Array.isArray(field.collection)) {
|
|
316
|
+
let currentQuery = null;
|
|
317
|
+
const onPath = field.on.split('.').join('_');
|
|
318
|
+
if (Array.isArray(sort)) {
|
|
319
|
+
throw new Error('Not implemented');
|
|
320
|
+
}
|
|
321
|
+
let sanitizedSort = sort;
|
|
322
|
+
if (!sanitizedSort) {
|
|
323
|
+
if (field.collection.some((collection)=>adapter.cms.collections[collection].config.fields.some((f)=>f.type === 'date' && f.name === 'createdAt'))) {
|
|
324
|
+
sanitizedSort = '-createdAt';
|
|
325
|
+
} else {
|
|
326
|
+
sanitizedSort = 'id';
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
const sortOrder = sanitizedSort.startsWith('-') ? desc : asc;
|
|
330
|
+
sanitizedSort = sanitizedSort.replace('-', '');
|
|
331
|
+
const sortPath = sanitizedSort.split('.').join('_');
|
|
332
|
+
const wherePaths = [];
|
|
333
|
+
if (where) {
|
|
334
|
+
flattenAllWherePaths(where, wherePaths);
|
|
335
|
+
}
|
|
336
|
+
for (const collection of field.collection){
|
|
337
|
+
const joinCollectionTableName = adapter.tableNameMap.get(toSnakeCase(collection));
|
|
338
|
+
const table = adapter.tables[joinCollectionTableName];
|
|
339
|
+
const sortColumn = table[sortPath];
|
|
340
|
+
const selectFields = {
|
|
341
|
+
id: adapter.tables[joinCollectionTableName].id,
|
|
342
|
+
parent: sql`${adapter.tables[joinCollectionTableName][onPath]}`.as(onPath),
|
|
343
|
+
relationTo: sql`${collection}`.as('relationTo'),
|
|
344
|
+
sortPath: sql`${sortColumn ? sortColumn : null}`.as('sortPath')
|
|
345
|
+
};
|
|
346
|
+
const collectionQueryWhere = [];
|
|
347
|
+
// Select for WHERE and Fallback NULL
|
|
348
|
+
for (const { path, ref } of wherePaths){
|
|
349
|
+
const collectioConfig = adapter.cms.collections[collection].config;
|
|
350
|
+
const field = getFieldByPath({
|
|
351
|
+
fields: collectioConfig.flattenedFields,
|
|
352
|
+
path
|
|
353
|
+
});
|
|
354
|
+
if (field && field.field.type === 'select' && field.field.hasMany) {
|
|
355
|
+
let tableName = adapter.tableNameMap.get(`${toSnakeCase(collection)}_${toSnakeCase(path)}`);
|
|
356
|
+
let parentTable = getTableName(table);
|
|
357
|
+
if (adapter.schemaName) {
|
|
358
|
+
tableName = `"${adapter.schemaName}"."${tableName}"`;
|
|
359
|
+
parentTable = `"${adapter.schemaName}"."${parentTable}"`;
|
|
360
|
+
}
|
|
361
|
+
if (adapter.name === 'postgres') {
|
|
362
|
+
selectFields[path] = sql.raw(`(select jsonb_agg(${tableName}.value) from ${tableName} where ${tableName}.parent_id = ${parentTable}.id)`).as(path);
|
|
363
|
+
} else {
|
|
364
|
+
selectFields[path] = sql.raw(`(select json_group_array(${tableName}.value) from ${tableName} where ${tableName}.parent_id = ${parentTable}.id)`).as(path);
|
|
365
|
+
}
|
|
366
|
+
const constraint = ref[path];
|
|
367
|
+
const operator = Object.keys(constraint)[0];
|
|
368
|
+
const value = Object.values(constraint)[0];
|
|
369
|
+
const query = adapter.createJSONQuery({
|
|
370
|
+
column: `"${path}"`,
|
|
371
|
+
operator,
|
|
372
|
+
pathSegments: [
|
|
373
|
+
field.field.name
|
|
374
|
+
],
|
|
375
|
+
table: parentTable,
|
|
376
|
+
value
|
|
377
|
+
});
|
|
378
|
+
ref[path] = {
|
|
379
|
+
$raw: query
|
|
380
|
+
};
|
|
381
|
+
} else if (adapter.tables[joinCollectionTableName][path]) {
|
|
382
|
+
selectFields[path] = sql`${adapter.tables[joinCollectionTableName][path]}`.as(path);
|
|
383
|
+
// Allow to filter by collectionSlug
|
|
384
|
+
} else if (path !== 'relationTo') {
|
|
385
|
+
// For timestamp fields like deletedAt, we need to cast to timestamp in Postgres
|
|
386
|
+
// SQLite doesn't require explicit type casting for UNION queries
|
|
387
|
+
if (path === 'deletedAt' && adapter.name === 'postgres') {
|
|
388
|
+
selectFields[path] = sql`null::timestamp with time zone`.as(path);
|
|
389
|
+
} else {
|
|
390
|
+
selectFields[path] = sql`null`.as(path);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
let query = db.select(selectFields).from(adapter.tables[joinCollectionTableName]);
|
|
395
|
+
if (collectionQueryWhere.length) {
|
|
396
|
+
query = query.where(and(...collectionQueryWhere));
|
|
397
|
+
}
|
|
398
|
+
if (currentQuery === null) {
|
|
399
|
+
currentQuery = query;
|
|
400
|
+
} else {
|
|
401
|
+
currentQuery = currentQuery.unionAll(query);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
const subQueryAlias = `${columnName}_subquery`;
|
|
405
|
+
let sqlWhere = eq(sql.raw(`"${currentTableName}"."id"`), sql.raw(`"${subQueryAlias}"."${onPath}"`));
|
|
406
|
+
if (where && Object.keys(where).length > 0) {
|
|
407
|
+
sqlWhere = and(sqlWhere, buildSQLWhere(where, subQueryAlias));
|
|
408
|
+
}
|
|
409
|
+
if (shouldCount) {
|
|
410
|
+
currentArgs.extras[`${columnName}_count`] = sql`${db.select({
|
|
411
|
+
count: count()
|
|
412
|
+
}).from(sql`${currentQuery.as(subQueryAlias)}`).where(sqlWhere)}`.as(`${columnName}_count`);
|
|
413
|
+
}
|
|
414
|
+
currentQuery = currentQuery.orderBy(sortOrder(sql`"sortPath"`));
|
|
415
|
+
const sortedUnionAlias = `${columnName}_sorted`;
|
|
416
|
+
let limitOffsetSQL = sql.empty();
|
|
417
|
+
if (limit) {
|
|
418
|
+
limitOffsetSQL = sql` LIMIT ${limit}`;
|
|
419
|
+
}
|
|
420
|
+
if (page && limit !== 0) {
|
|
421
|
+
const offset = (page - 1) * limit;
|
|
422
|
+
if (offset > 0) {
|
|
423
|
+
limitOffsetSQL = sql`${limitOffsetSQL} OFFSET ${offset}`;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
// Correlate to parent row + apply any join where filters
|
|
427
|
+
let innerWhere = sql.raw(`"${sortedUnionAlias}"."${onPath}" = "${currentTableName}"."id"`);
|
|
428
|
+
if (where && Object.keys(where).length > 0) {
|
|
429
|
+
const additionalWhere = buildSQLWhere(where, sortedUnionAlias);
|
|
430
|
+
innerWhere = sql`${innerWhere} AND ${additionalWhere}`;
|
|
431
|
+
}
|
|
432
|
+
// IMPORTANT: For polymorphic joins, LIMIT must be applied AFTER correlating to the parent row.
|
|
433
|
+
// Otherwise, the limit applies globally across ALL parents, not per-parent.
|
|
434
|
+
currentArgs.extras[columnName] = sql`(
|
|
435
|
+
SELECT ${jsonAggBuildObject(adapter, {
|
|
436
|
+
id: sql.raw(`"${subQueryAlias}"."id"`),
|
|
437
|
+
relationTo: sql.raw(`"${subQueryAlias}"."relationTo"`)
|
|
438
|
+
})}
|
|
439
|
+
FROM (
|
|
440
|
+
SELECT * FROM ${sql`${currentQuery.as(sortedUnionAlias)}`}
|
|
441
|
+
WHERE ${innerWhere}${limitOffsetSQL}
|
|
442
|
+
) AS ${sql.raw(`"${subQueryAlias}"`)}
|
|
443
|
+
)`.as(columnName);
|
|
444
|
+
} else {
|
|
445
|
+
const useDrafts = (versions || draftsEnabled) && hasDraftsEnabled(adapter.cms.collections[field.collection].config);
|
|
446
|
+
const fields = useDrafts ? buildVersionCollectionFields(adapter.cms.config, adapter.cms.collections[field.collection].config, true) : adapter.cms.collections[field.collection].config.flattenedFields;
|
|
447
|
+
const joinCollectionTableName = adapter.tableNameMap.get(useDrafts ? `_${toSnakeCase(field.collection)}${adapter.versionsSuffix}` : toSnakeCase(field.collection));
|
|
448
|
+
const joins = [];
|
|
449
|
+
const currentIDColumn = versions ? adapter.tables[currentTableName].parent : adapter.tables[currentTableName].id;
|
|
450
|
+
let joinQueryWhere;
|
|
451
|
+
const currentIDRaw = sql.raw(`"${getNameFromDrizzleTable(currentIDColumn.table)}"."${currentIDColumn.name}"`);
|
|
452
|
+
if (Array.isArray(field.targetField.relationTo)) {
|
|
453
|
+
joinQueryWhere = {
|
|
454
|
+
[field.on]: {
|
|
455
|
+
equals: {
|
|
456
|
+
relationTo: collectionSlug,
|
|
457
|
+
value: rawConstraint(currentIDRaw)
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
} else {
|
|
462
|
+
joinQueryWhere = {
|
|
463
|
+
[field.on]: {
|
|
464
|
+
equals: rawConstraint(currentIDRaw)
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
if (where && Object.keys(where).length) {
|
|
469
|
+
joinQueryWhere = {
|
|
470
|
+
and: [
|
|
471
|
+
joinQueryWhere,
|
|
472
|
+
where
|
|
473
|
+
]
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
if (useDrafts) {
|
|
477
|
+
joinQueryWhere = combineQueries(appendVersionToQueryKey(joinQueryWhere), {
|
|
478
|
+
latest: {
|
|
479
|
+
equals: true
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
const columnName = `${path.replaceAll('.', '_')}${field.name}`;
|
|
484
|
+
const subQueryAlias = `${columnName}_alias`;
|
|
485
|
+
const { newAliasTable } = getTableAlias({
|
|
486
|
+
adapter,
|
|
487
|
+
tableName: joinCollectionTableName
|
|
488
|
+
});
|
|
489
|
+
const { orderBy, selectFields, where: subQueryWhere } = buildQuery({
|
|
490
|
+
adapter,
|
|
491
|
+
aliasTable: newAliasTable,
|
|
492
|
+
fields,
|
|
493
|
+
joins,
|
|
494
|
+
locale,
|
|
495
|
+
parentIsLocalized,
|
|
496
|
+
selectLocale: true,
|
|
497
|
+
sort: useDrafts ? getQueryDraftsSort({
|
|
498
|
+
collectionConfig: adapter.cms.collections[field.collection].config,
|
|
499
|
+
sort
|
|
500
|
+
}) : sort,
|
|
501
|
+
tableName: joinCollectionTableName,
|
|
502
|
+
where: joinQueryWhere
|
|
503
|
+
});
|
|
504
|
+
for(let key in selectFields){
|
|
505
|
+
const val = selectFields[key];
|
|
506
|
+
if (val.table && getNameFromDrizzleTable(val.table) === joinCollectionTableName) {
|
|
507
|
+
delete selectFields[key];
|
|
508
|
+
key = key.split('.').pop();
|
|
509
|
+
selectFields[key] = newAliasTable[key];
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
if (useDrafts) {
|
|
513
|
+
selectFields.parent = newAliasTable.parent;
|
|
514
|
+
}
|
|
515
|
+
let query = db.select(selectFields).from(newAliasTable).where(subQueryWhere).orderBy(()=>orderBy.map(({ column, order })=>order(column))).$dynamic();
|
|
516
|
+
joins.forEach(({ type, condition, table })=>{
|
|
517
|
+
query = query[type ?? 'leftJoin'](table, condition);
|
|
518
|
+
});
|
|
519
|
+
if (page && limit !== 0) {
|
|
520
|
+
const offset = (page - 1) * limit - 1;
|
|
521
|
+
if (offset > 0) {
|
|
522
|
+
query = query.offset(offset);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
if (limit !== 0) {
|
|
526
|
+
query = query.limit(limit);
|
|
527
|
+
}
|
|
528
|
+
const subQuery = query.as(subQueryAlias);
|
|
529
|
+
if (shouldCount) {
|
|
530
|
+
let countSubquery = db.select(selectFields).from(newAliasTable).where(subQueryWhere).$dynamic();
|
|
531
|
+
joins.forEach(({ type, condition, table })=>{
|
|
532
|
+
countSubquery = countSubquery[type ?? 'leftJoin'](table, condition);
|
|
533
|
+
});
|
|
534
|
+
currentArgs.extras[`${columnName}_count`] = sql`${db.select({
|
|
535
|
+
count: count()
|
|
536
|
+
}).from(sql`${countSubquery.as(`${subQueryAlias}_count_subquery`)}`)}`.as(`${subQueryAlias}_count`);
|
|
537
|
+
}
|
|
538
|
+
currentArgs.extras[columnName] = sql`${db.select({
|
|
539
|
+
result: jsonAggBuildObject(adapter, {
|
|
540
|
+
id: sql.raw(`"${subQueryAlias}".${useDrafts ? 'parent_id' : 'id'}`),
|
|
541
|
+
...selectFields._locale && {
|
|
542
|
+
locale: sql.raw(`"${subQueryAlias}".${selectFields._locale.name}`)
|
|
543
|
+
}
|
|
544
|
+
})
|
|
545
|
+
}).from(sql`${subQuery}`)}`.as(subQueryAlias);
|
|
546
|
+
}
|
|
547
|
+
break;
|
|
548
|
+
}
|
|
549
|
+
case 'point':
|
|
550
|
+
{
|
|
551
|
+
if (adapter.name === 'sqlite') {
|
|
552
|
+
break;
|
|
553
|
+
}
|
|
554
|
+
const args = isFieldLocalized ? _locales : currentArgs;
|
|
555
|
+
if (!args.columns) {
|
|
556
|
+
args.columns = {};
|
|
557
|
+
}
|
|
558
|
+
if (!args.extras) {
|
|
559
|
+
args.extras = {};
|
|
560
|
+
}
|
|
561
|
+
const name = `${path}${field.name}`;
|
|
562
|
+
// Drizzle handles that poorly. See https://github.com/drizzle-team/drizzle-orm/issues/2526
|
|
563
|
+
// Additionally, this way we format the column value straight in the database using ST_AsGeoJSON
|
|
564
|
+
args.columns[name] = false;
|
|
565
|
+
let shouldSelect = false;
|
|
566
|
+
if (select || selectAllOnCurrentLevel) {
|
|
567
|
+
if (selectAllOnCurrentLevel || selectMode === 'include' && Boolean(select[field.name]) || selectMode === 'exclude' && typeof select[field.name] === 'undefined') {
|
|
568
|
+
shouldSelect = true;
|
|
569
|
+
}
|
|
570
|
+
} else {
|
|
571
|
+
shouldSelect = true;
|
|
572
|
+
}
|
|
573
|
+
const tableName = fieldShouldBeLocalized({
|
|
574
|
+
field,
|
|
575
|
+
parentIsLocalized
|
|
576
|
+
}) ? `${currentTableName}${adapter.localesSuffix}` : currentTableName;
|
|
577
|
+
if (shouldSelect) {
|
|
578
|
+
args.extras[name] = sql.raw(`ST_AsGeoJSON("${adapter.tables[tableName][name].name}")::jsonb`).as(name);
|
|
579
|
+
}
|
|
580
|
+
break;
|
|
581
|
+
}
|
|
582
|
+
case 'select':
|
|
583
|
+
{
|
|
584
|
+
if (select && !selectAllOnCurrentLevel) {
|
|
585
|
+
if (selectMode === 'include' && !select[field.name] || selectMode === 'exclude' && select[field.name] === false) {
|
|
586
|
+
break;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
if (field.hasMany) {
|
|
590
|
+
const withSelect = {
|
|
591
|
+
columns: {
|
|
592
|
+
id: false,
|
|
593
|
+
order: false,
|
|
594
|
+
parent: false
|
|
595
|
+
},
|
|
596
|
+
orderBy: ({ order }, { asc })=>[
|
|
597
|
+
asc(order)
|
|
598
|
+
]
|
|
599
|
+
};
|
|
600
|
+
currentArgs.with[`${path}${field.name}`] = withSelect;
|
|
601
|
+
break;
|
|
602
|
+
}
|
|
603
|
+
if (select || selectAllOnCurrentLevel) {
|
|
604
|
+
const fieldPath = `${path}${field.name}`;
|
|
605
|
+
if ((isFieldLocalized || parentIsLocalized) && _locales) {
|
|
606
|
+
_locales.columns[fieldPath] = true;
|
|
607
|
+
} else if (adapter.tables[currentTableName]?.[fieldPath]) {
|
|
608
|
+
currentArgs.columns[fieldPath] = true;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
break;
|
|
612
|
+
}
|
|
613
|
+
default:
|
|
614
|
+
{
|
|
615
|
+
if (forceWithFields) {
|
|
616
|
+
if ((field.type === 'relationship' || field.type === 'upload') && (field.hasMany || Array.isArray(field.relationTo))) {
|
|
617
|
+
withTabledFields.rels = true;
|
|
618
|
+
}
|
|
619
|
+
if (field.type === 'number' && field.hasMany) {
|
|
620
|
+
withTabledFields.numbers = true;
|
|
621
|
+
}
|
|
622
|
+
if (field.type === 'text' && field.hasMany) {
|
|
623
|
+
withTabledFields.texts = true;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
if (!select && !selectAllOnCurrentLevel) {
|
|
627
|
+
break;
|
|
628
|
+
}
|
|
629
|
+
if (selectAllOnCurrentLevel || selectMode === 'include' && Boolean(select[field.name]) || selectMode === 'exclude' && typeof select[field.name] === 'undefined') {
|
|
630
|
+
const fieldPath = `${path}${field.name}`;
|
|
631
|
+
if ((isFieldLocalized || parentIsLocalized) && _locales) {
|
|
632
|
+
_locales.columns[fieldPath] = true;
|
|
633
|
+
} else if (adapter.tables[currentTableName]?.[fieldPath]) {
|
|
634
|
+
currentArgs.columns[fieldPath] = true;
|
|
635
|
+
}
|
|
636
|
+
if (!withTabledFields.rels && (field.type === 'relationship' || field.type === 'upload') && (field.hasMany || Array.isArray(field.relationTo))) {
|
|
637
|
+
withTabledFields.rels = true;
|
|
638
|
+
}
|
|
639
|
+
if (!withTabledFields.numbers && field.type === 'number' && field.hasMany) {
|
|
640
|
+
withTabledFields.numbers = true;
|
|
641
|
+
}
|
|
642
|
+
if (!withTabledFields.texts && field.type === 'text' && field.hasMany) {
|
|
643
|
+
withTabledFields.texts = true;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
break;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
return topLevelArgs;
|
|
651
|
+
};
|
|
652
|
+
|
|
653
|
+
//# sourceMappingURL=traverseFields.js.map
|