@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 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/upsertRow/index.ts"],"sourcesContent":["import type { LibSQLDatabase } from 'drizzle-orm/libsql'\nimport type { SelectedFields } from 'drizzle-orm/sqlite-core'\nimport type { TypeWithID } from '@hanzo/cms'\n\nimport { and, desc, eq, isNull, or } from 'drizzle-orm'\n\nimport type { BlockRowToInsert } from '../transform/write/types.js'\nimport type { Args } from './types.js'\n\ntype RelationshipRow = {\n [key: string]: number | string | undefined // For relationship ID columns like categoriesID, moviesID, etc.\n id?: number | string\n locale?: string\n order: number\n parent: number | string // Drizzle table uses 'parent' key\n path: string\n}\n\nimport { buildFindManyArgs } from '../find/buildFindManyArgs.js'\nimport { transform } from '../transform/read/index.js'\nimport { transformForWrite } from '../transform/write/index.js'\nimport { markWrite } from '../utilities/readAfterWrite.js'\nimport { deleteExistingArrayRows } from './deleteExistingArrayRows.js'\nimport { deleteExistingRowsByPath } from './deleteExistingRowsByPath.js'\nimport { handleUpsertError } from './handleUpsertError.js'\nimport { insertArrays } from './insertArrays.js'\nimport { shouldUseOptimizedUpsertRow } from './shouldUseOptimizedUpsertRow.js'\n\n/**\n * If `id` is provided, it will update the row with that ID.\n * If `where` is provided, it will update the row that matches the `where`\n * If neither `id` nor `where` is provided, it will create a new row.\n *\n * adapter function replaces the entire row and does not support partial updates.\n */\nexport const upsertRow = async <T extends Record<string, unknown> | TypeWithID>({\n id,\n adapter,\n collectionSlug,\n data,\n db,\n fields,\n globalSlug,\n ignoreResult,\n // TODO:\n // When we support joins for write operations (create/update) - pass collectionSlug to the buildFindManyArgs\n // Make a new argument in upsertRow.ts and pass the slug from every operation.\n customID,\n joinQuery: _joinQuery,\n operation,\n path = '',\n req,\n select,\n tableName,\n upsertTarget,\n where,\n}: Args): Promise<T> => {\n if (operation === 'create' && !data.createdAt) {\n data.createdAt = new Date().toISOString()\n }\n\n markWrite(adapter)\n\n let insertedRow: Record<string, unknown> = { id }\n if (id && shouldUseOptimizedUpsertRow({ data, fields })) {\n try {\n const transformedForWrite = transformForWrite({\n adapter,\n data,\n enableAtomicWrites: true,\n fields,\n tableName,\n })\n const { row } = transformedForWrite\n const { arraysToPush } = transformedForWrite\n\n const drizzle = db as LibSQLDatabase\n\n // First, handle $push arrays\n\n if (arraysToPush && Object.keys(arraysToPush)?.length) {\n await insertArrays({\n adapter,\n arrays: [arraysToPush],\n db,\n parentRows: [insertedRow],\n uuidMap: {},\n })\n }\n\n // If row.updatedAt is not set, delete it to avoid triggering hasDataToUpdate. `updatedAt` may be explicitly set to null to\n // disable triggering hasDataToUpdate.\n if (typeof row.updatedAt === 'undefined' || row.updatedAt === null) {\n delete row.updatedAt\n }\n\n const hasDataToUpdate = row && Object.keys(row)?.length\n\n // Then, handle regular row update\n if (ignoreResult) {\n if (hasDataToUpdate) {\n // Only update row if there is something to update.\n // Example: if the data only consists of a single $push, calling insertArrays is enough - we don't need to update the row.\n await drizzle\n .update(adapter.tables[tableName])\n .set(row)\n .where(eq(adapter.tables[tableName].id, id))\n }\n return ignoreResult === 'idOnly' ? ({ id } as T) : null\n }\n\n const findManyArgs = buildFindManyArgs({\n adapter,\n depth: 0,\n fields,\n joinQuery: false,\n select,\n tableName,\n })\n\n const findManyKeysLength = Object.keys(findManyArgs).length\n const hasOnlyColumns = Object.keys(findManyArgs.columns || {}).length > 0\n\n if (!hasDataToUpdate) {\n // Nothing to update => just fetch current row and return\n findManyArgs.where = eq(adapter.tables[tableName].id, insertedRow.id)\n\n const doc = await db.query[tableName].findFirst(findManyArgs)\n\n return transform<T>({\n adapter,\n config: adapter.cms.config,\n data: doc,\n fields,\n joinQuery: false,\n tableName,\n })\n }\n\n if (findManyKeysLength === 0 || hasOnlyColumns) {\n // Optimization - No need for joins => can simply use returning(). This is optimal for very simple collections\n // without complex fields that live in separate tables like blocks, arrays, relationships, etc.\n\n const selectedFields: SelectedFields = {}\n if (hasOnlyColumns) {\n for (const [column, enabled] of Object.entries(findManyArgs.columns)) {\n if (enabled) {\n selectedFields[column] = adapter.tables[tableName][column]\n }\n }\n }\n\n const docs = await drizzle\n .update(adapter.tables[tableName])\n .set(row)\n .where(eq(adapter.tables[tableName].id, id))\n .returning(Object.keys(selectedFields).length ? selectedFields : undefined)\n\n return transform<T>({\n adapter,\n config: adapter.cms.config,\n data: docs[0],\n fields,\n joinQuery: false,\n tableName,\n })\n }\n\n // DB Update that needs the result, potentially with joins => need to update first, then find. returning() does not work with joins.\n\n await drizzle\n .update(adapter.tables[tableName])\n .set(row)\n .where(eq(adapter.tables[tableName].id, id))\n\n findManyArgs.where = eq(adapter.tables[tableName].id, insertedRow.id)\n\n const doc = await db.query[tableName].findFirst(findManyArgs)\n\n return transform<T>({\n adapter,\n config: adapter.cms.config,\n data: doc,\n fields,\n joinQuery: false,\n tableName,\n })\n } catch (error) {\n handleUpsertError({ id, adapter, collectionSlug, error, globalSlug, req, tableName })\n }\n }\n // Split out the incoming data into the corresponding:\n // base row, locales, relationships, blocks, and arrays\n const rowToInsert = transformForWrite({\n adapter,\n data,\n enableAtomicWrites: false,\n fields,\n path,\n tableName,\n })\n\n if (customID) {\n rowToInsert.row.id = customID\n }\n\n // First, we insert the main row\n try {\n if (operation === 'update') {\n const target = upsertTarget || adapter.tables[tableName].id\n\n // Check if we only have relationship operations and no main row data to update\n // Exclude timestamp-only updates when we only have relationship operations\n const rowKeys = Object.keys(rowToInsert.row)\n const hasMainRowData =\n rowKeys.length > 0 && !rowKeys.every((key) => key === 'updatedAt' || key === 'createdAt')\n\n if (hasMainRowData) {\n if (id) {\n rowToInsert.row.id = id\n ;[insertedRow] = await adapter.insert({\n db,\n onConflictDoUpdate: { set: rowToInsert.row, target },\n tableName,\n values: rowToInsert.row,\n })\n } else {\n ;[insertedRow] = await adapter.insert({\n db,\n onConflictDoUpdate: { set: rowToInsert.row, target, where },\n tableName,\n values: rowToInsert.row,\n })\n }\n } else {\n // No main row data to update, just use the existing ID\n insertedRow = { id }\n }\n } else {\n if (adapter.allowIDOnCreate && data.id) {\n rowToInsert.row.id = data.id\n }\n ;[insertedRow] = await adapter.insert({\n db,\n tableName,\n values: rowToInsert.row,\n })\n }\n\n const localesToInsert: Record<string, unknown>[] = []\n const relationsToInsert: Record<string, unknown>[] = []\n const textsToInsert: Record<string, unknown>[] = []\n const numbersToInsert: Record<string, unknown>[] = []\n const blocksToInsert: { [blockType: string]: BlockRowToInsert[] } = {}\n const selectsToInsert: { [selectTableName: string]: Record<string, unknown>[] } = {}\n\n // If there are locale rows with data, add the parent and locale to each\n if (Object.keys(rowToInsert.locales).length > 0) {\n Object.entries(rowToInsert.locales).forEach(([locale, localeRow]) => {\n localeRow._parentID = insertedRow.id\n localeRow._locale = locale\n localesToInsert.push(localeRow)\n })\n }\n\n // If there are relationships, add parent to each\n if (rowToInsert.relationships.length > 0) {\n rowToInsert.relationships.forEach((relation) => {\n relation.parent = insertedRow.id\n relationsToInsert.push(relation)\n })\n }\n\n // If there are texts, add parent to each\n if (rowToInsert.texts.length > 0) {\n rowToInsert.texts.forEach((textRow) => {\n textRow.parent = insertedRow.id\n textsToInsert.push(textRow)\n })\n }\n\n // If there are numbers, add parent to each\n if (rowToInsert.numbers.length > 0) {\n rowToInsert.numbers.forEach((numberRow) => {\n numberRow.parent = insertedRow.id\n numbersToInsert.push(numberRow)\n })\n }\n\n // If there are selects, add parent to each, and then\n // store by table name and rows\n if (Object.keys(rowToInsert.selects).length > 0) {\n Object.entries(rowToInsert.selects).forEach(([selectTableName, selectRows]) => {\n selectsToInsert[selectTableName] = []\n\n selectRows.forEach((row) => {\n if (typeof row.parent === 'undefined') {\n row.parent = insertedRow.id\n }\n\n selectsToInsert[selectTableName].push(row)\n })\n })\n }\n\n // If there are blocks, add parent to each, and then\n // store by table name and rows\n Object.keys(rowToInsert.blocks).forEach((tableName) => {\n rowToInsert.blocks[tableName].forEach((blockRow) => {\n blockRow.row._parentID = insertedRow.id\n if (!blocksToInsert[tableName]) {\n blocksToInsert[tableName] = []\n }\n if (blockRow.row.uuid) {\n delete blockRow.row.uuid\n }\n blocksToInsert[tableName].push(blockRow)\n })\n })\n\n // //////////////////////////////////\n // INSERT LOCALES\n // //////////////////////////////////\n\n if (localesToInsert.length > 0) {\n const localeTableName = `${tableName}${adapter.localesSuffix}`\n const localeTable = adapter.tables[`${tableName}${adapter.localesSuffix}`]\n\n if (operation === 'update') {\n await adapter.deleteWhere({\n db,\n tableName: localeTableName,\n where: eq(localeTable._parentID, insertedRow.id),\n })\n }\n\n await adapter.insert({\n db,\n tableName: localeTableName,\n values: localesToInsert,\n })\n }\n\n // //////////////////////////////////\n // INSERT RELATIONSHIPS\n // //////////////////////////////////\n\n const relationshipsTableName = `${tableName}${adapter.relationshipsSuffix}`\n\n if (operation === 'update') {\n // Filter out specific item deletions (those with itemToRemove) from general path deletions\n const generalRelationshipDeletes = rowToInsert.relationshipsToDelete.filter(\n (rel) => !('itemToRemove' in rel),\n )\n\n await deleteExistingRowsByPath({\n adapter,\n db,\n localeColumnName: 'locale',\n parentColumnName: 'parent',\n parentID: insertedRow.id,\n pathColumnName: 'path',\n rows: [...relationsToInsert, ...generalRelationshipDeletes],\n tableName: relationshipsTableName,\n })\n }\n\n if (relationsToInsert.length > 0) {\n await adapter.insert({\n db,\n tableName: relationshipsTableName,\n values: relationsToInsert,\n })\n }\n\n // //////////////////////////////////\n // HANDLE RELATIONSHIP $push OPERATIONS\n // //////////////////////////////////\n\n if (rowToInsert.relationshipsToAppend.length > 0) {\n // Prepare all relationships for batch insert (order will be set after max query)\n const relationshipsToInsert = rowToInsert.relationshipsToAppend.map((rel) => {\n const parentId = id || insertedRow.id\n const row: Record<string, unknown> = {\n parent: parentId as number | string, // Use 'parent' key for Drizzle table\n path: rel.path,\n }\n\n // Only add locale if this relationship table has a locale column\n const relationshipTable = adapter.rawTables[relationshipsTableName]\n if (rel.locale && relationshipTable && relationshipTable.columns.locale) {\n row.locale = rel.locale\n }\n\n if (rel.relationTo) {\n // Use camelCase key for Drizzle table (e.g., categoriesID not categories_id)\n row[`${rel.relationTo}ID`] = rel.value\n }\n\n return row\n })\n\n if (relationshipsToInsert.length > 0) {\n // Check for potential duplicates\n const relationshipTable = adapter.tables[relationshipsTableName]\n\n if (relationshipTable) {\n // Build conditions only if we have relationships to check\n if (relationshipsToInsert.length === 0) {\n return // No relationships to insert\n }\n\n const conditions = relationshipsToInsert.map((row: RelationshipRow) => {\n const parts = [\n eq(relationshipTable.parent, row.parent),\n eq(relationshipTable.path, row.path),\n ]\n\n // Add locale condition\n if (row.locale !== undefined && relationshipTable.locale) {\n parts.push(eq(relationshipTable.locale, row.locale))\n } else if (relationshipTable.locale) {\n parts.push(isNull(relationshipTable.locale))\n }\n\n // Add all relationship ID matches using schema fields\n for (const [key, value] of Object.entries(row)) {\n if (key.endsWith('ID') && value != null) {\n const column = relationshipTable[key]\n if (column && typeof column === 'object') {\n parts.push(eq(column, value))\n }\n }\n }\n\n return and(...parts)\n })\n\n // Get both existing relationships AND max order in a single query\n let existingRels: Record<string, unknown>[] = []\n let maxOrder = 0\n\n if (conditions.length > 0) {\n // Query for existing relationships\n existingRels = await (db as any)\n .select()\n .from(relationshipTable)\n .where(or(...conditions))\n }\n\n // Get max order for this parent across all paths in a single query\n const parentId = id || insertedRow.id\n const maxOrderResult = await (db as any)\n .select({ maxOrder: relationshipTable.order })\n .from(relationshipTable)\n .where(eq(relationshipTable.parent, parentId))\n .orderBy(desc(relationshipTable.order))\n .limit(1)\n\n if (maxOrderResult.length > 0 && maxOrderResult[0].maxOrder) {\n maxOrder = maxOrderResult[0].maxOrder\n }\n\n // Set order values for all relationships based on max order\n relationshipsToInsert.forEach((row, index) => {\n row.order = maxOrder + index + 1\n })\n\n // Filter out relationships that already exist\n const relationshipsToActuallyInsert = relationshipsToInsert.filter((newRow) => {\n return !existingRels.some((existingRow: Record<string, unknown>) => {\n // Check if this relationship already exists\n let matches = existingRow.parent === newRow.parent && existingRow.path === newRow.path\n\n if (newRow.locale !== undefined) {\n matches = matches && existingRow.locale === newRow.locale\n }\n\n // Check relationship value matches - convert to camelCase for comparison\n for (const key of Object.keys(newRow)) {\n if (key.endsWith('ID')) {\n // Now using camelCase keys\n matches = matches && existingRow[key] === newRow[key]\n }\n }\n\n return matches\n })\n })\n\n // Insert only non-duplicate relationships\n if (relationshipsToActuallyInsert.length > 0) {\n await adapter.insert({\n db,\n tableName: relationshipsTableName,\n values: relationshipsToActuallyInsert,\n })\n }\n }\n }\n }\n\n // //////////////////////////////////\n // HANDLE RELATIONSHIP $remove OPERATIONS\n // //////////////////////////////////\n\n if (rowToInsert.relationshipsToDelete.some((rel) => 'itemToRemove' in rel)) {\n const relationshipTable = adapter.tables[relationshipsTableName]\n\n if (relationshipTable) {\n for (const relToDelete of rowToInsert.relationshipsToDelete) {\n if ('itemToRemove' in relToDelete && relToDelete.itemToRemove) {\n const item = relToDelete.itemToRemove\n const parentId = (id || insertedRow.id) as number | string\n\n const conditions = [\n eq(relationshipTable.parent, parentId),\n eq(relationshipTable.path, relToDelete.path),\n ]\n\n // Add locale condition if this relationship table has a locale column\n if (adapter.rawTables[relationshipsTableName]?.columns.locale) {\n if (relToDelete.locale) {\n conditions.push(eq(relationshipTable.locale, relToDelete.locale))\n } else {\n conditions.push(isNull(relationshipTable.locale))\n }\n }\n\n // Handle polymorphic vs simple relationships\n if (typeof item === 'object' && 'relationTo' in item) {\n // Polymorphic relationship - convert to camelCase key\n const camelKey = `${item.relationTo}ID`\n if (relationshipTable[camelKey]) {\n conditions.push(eq(relationshipTable[camelKey], item.value))\n }\n } else if (relToDelete.relationTo) {\n // Simple relationship - convert to camelCase key\n const camelKey = `${relToDelete.relationTo}ID`\n if (relationshipTable[camelKey]) {\n conditions.push(eq(relationshipTable[camelKey], item))\n }\n }\n\n // Execute DELETE using Drizzle query builder\n await adapter.deleteWhere({\n db,\n tableName: relationshipsTableName,\n where: and(...conditions),\n })\n }\n }\n }\n }\n\n // //////////////////////////////////\n // INSERT hasMany TEXTS\n // //////////////////////////////////\n\n const textsTableName = `${tableName}_texts`\n\n if (operation === 'update') {\n await deleteExistingRowsByPath({\n adapter,\n db,\n localeColumnName: 'locale',\n parentColumnName: 'parent',\n parentID: insertedRow.id,\n pathColumnName: 'path',\n rows: [...textsToInsert, ...rowToInsert.textsToDelete],\n tableName: textsTableName,\n })\n }\n\n if (textsToInsert.length > 0) {\n await adapter.insert({\n db,\n tableName: textsTableName,\n values: textsToInsert,\n })\n }\n\n // //////////////////////////////////\n // INSERT hasMany NUMBERS\n // //////////////////////////////////\n\n const numbersTableName = `${tableName}_numbers`\n\n if (operation === 'update') {\n await deleteExistingRowsByPath({\n adapter,\n db,\n localeColumnName: 'locale',\n parentColumnName: 'parent',\n parentID: insertedRow.id,\n pathColumnName: 'path',\n rows: [...numbersToInsert, ...rowToInsert.numbersToDelete],\n tableName: numbersTableName,\n })\n }\n\n if (numbersToInsert.length > 0) {\n await adapter.insert({\n db,\n tableName: numbersTableName,\n values: numbersToInsert,\n })\n }\n\n // //////////////////////////////////\n // INSERT BLOCKS\n // //////////////////////////////////\n\n const insertedBlockRows: Record<string, Record<string, unknown>[]> = {}\n\n if (operation === 'update') {\n for (const tableName of rowToInsert.blocksToDelete) {\n const blockTable = adapter.tables[tableName]\n await adapter.deleteWhere({\n db,\n tableName,\n where: eq(blockTable._parentID, insertedRow.id),\n })\n }\n }\n\n // When versions are enabled, adapter is used to track mapping between blocks/arrays ObjectID to their numeric generated representation, then we use it for nested to arrays/blocks select hasMany in versions.\n const arraysBlocksUUIDMap: Record<string, number | string> = {}\n\n for (const [tableName, blockRows] of Object.entries(blocksToInsert)) {\n insertedBlockRows[tableName] = await adapter.insert({\n db,\n tableName,\n values: blockRows.map(({ row }) => row),\n })\n\n insertedBlockRows[tableName].forEach((row, i) => {\n blockRows[i].row = row\n if (\n typeof row._uuid === 'string' &&\n (typeof row.id === 'string' || typeof row.id === 'number')\n ) {\n arraysBlocksUUIDMap[row._uuid] = row.id\n }\n })\n\n const blockLocaleIndexMap: number[] = []\n\n const blockLocaleRowsToInsert = blockRows.reduce((acc, blockRow, i) => {\n if (Object.entries(blockRow.locales).length > 0) {\n Object.entries(blockRow.locales).forEach(([blockLocale, blockLocaleData]) => {\n if (Object.keys(blockLocaleData).length > 0) {\n blockLocaleData._parentID = blockRow.row.id\n blockLocaleData._locale = blockLocale\n acc.push(blockLocaleData)\n blockLocaleIndexMap.push(i)\n }\n })\n }\n\n return acc\n }, [])\n\n if (blockLocaleRowsToInsert.length > 0) {\n await adapter.insert({\n db,\n tableName: `${tableName}${adapter.localesSuffix}`,\n values: blockLocaleRowsToInsert,\n })\n }\n\n await insertArrays({\n adapter,\n arrays: blockRows.map(({ arrays }) => arrays),\n db,\n parentRows: insertedBlockRows[tableName],\n uuidMap: arraysBlocksUUIDMap,\n })\n }\n\n // //////////////////////////////////\n // INSERT ARRAYS RECURSIVELY\n // //////////////////////////////////\n\n if (operation === 'update') {\n for (const arrayTableName of Object.keys(rowToInsert.arrays)) {\n await deleteExistingArrayRows({\n adapter,\n db,\n parentID: insertedRow.id,\n tableName: arrayTableName,\n })\n }\n }\n\n await insertArrays({\n adapter,\n arrays: [rowToInsert.arrays, rowToInsert.arraysToPush],\n db,\n parentRows: [insertedRow, insertedRow],\n uuidMap: arraysBlocksUUIDMap,\n })\n\n // //////////////////////////////////\n // INSERT hasMany SELECTS\n // //////////////////////////////////\n\n for (const [selectTableName, tableRows] of Object.entries(selectsToInsert)) {\n const selectTable = adapter.tables[selectTableName]\n if (operation === 'update') {\n await adapter.deleteWhere({\n db,\n tableName: selectTableName,\n where: eq(selectTable.parent, insertedRow.id),\n })\n }\n\n if (Object.keys(arraysBlocksUUIDMap).length > 0) {\n tableRows.forEach((row: RelationshipRow) => {\n if (row.parent in arraysBlocksUUIDMap) {\n row.parent = arraysBlocksUUIDMap[row.parent]\n }\n })\n }\n\n if (tableRows.length) {\n await adapter.insert({\n db,\n tableName: selectTableName,\n values: tableRows,\n })\n }\n }\n } catch (error) {\n handleUpsertError({ id, adapter, collectionSlug, error, globalSlug, req, tableName })\n }\n\n if (ignoreResult === 'idOnly') {\n return { id: insertedRow.id } as T\n }\n\n if (ignoreResult) {\n return data as T\n }\n\n // //////////////////////////////////\n // RETRIEVE NEWLY UPDATED ROW\n // //////////////////////////////////\n\n const findManyArgs = buildFindManyArgs({\n adapter,\n depth: 0,\n fields,\n joinQuery: false,\n select,\n tableName,\n })\n\n findManyArgs.where = eq(adapter.tables[tableName].id, insertedRow.id)\n\n const doc = await db.query[tableName].findFirst(findManyArgs)\n\n // //////////////////////////////////\n // TRANSFORM DATA\n // //////////////////////////////////\n\n const result = transform<T>({\n adapter,\n config: adapter.cms.config,\n data: doc,\n fields,\n joinQuery: false,\n tableName,\n })\n\n return result\n}\n"],"names":["and","desc","eq","isNull","or","buildFindManyArgs","transform","transformForWrite","markWrite","deleteExistingArrayRows","deleteExistingRowsByPath","handleUpsertError","insertArrays","shouldUseOptimizedUpsertRow","upsertRow","id","adapter","collectionSlug","data","db","fields","globalSlug","ignoreResult","customID","joinQuery","_joinQuery","operation","path","req","select","tableName","upsertTarget","where","createdAt","Date","toISOString","insertedRow","transformedForWrite","enableAtomicWrites","row","arraysToPush","drizzle","Object","keys","length","arrays","parentRows","uuidMap","updatedAt","hasDataToUpdate","update","tables","set","findManyArgs","depth","findManyKeysLength","hasOnlyColumns","columns","doc","query","findFirst","config","cms","selectedFields","column","enabled","entries","docs","returning","undefined","error","rowToInsert","target","rowKeys","hasMainRowData","every","key","insert","onConflictDoUpdate","values","allowIDOnCreate","localesToInsert","relationsToInsert","textsToInsert","numbersToInsert","blocksToInsert","selectsToInsert","locales","forEach","locale","localeRow","_parentID","_locale","push","relationships","relation","parent","texts","textRow","numbers","numberRow","selects","selectTableName","selectRows","blocks","blockRow","uuid","localeTableName","localesSuffix","localeTable","deleteWhere","relationshipsTableName","relationshipsSuffix","generalRelationshipDeletes","relationshipsToDelete","filter","rel","localeColumnName","parentColumnName","parentID","pathColumnName","rows","relationshipsToAppend","relationshipsToInsert","map","parentId","relationshipTable","rawTables","relationTo","value","conditions","parts","endsWith","existingRels","maxOrder","from","maxOrderResult","order","orderBy","limit","index","relationshipsToActuallyInsert","newRow","some","existingRow","matches","relToDelete","itemToRemove","item","camelKey","textsTableName","textsToDelete","numbersTableName","numbersToDelete","insertedBlockRows","blocksToDelete","blockTable","arraysBlocksUUIDMap","blockRows","i","_uuid","blockLocaleIndexMap","blockLocaleRowsToInsert","reduce","acc","blockLocale","blockLocaleData","arrayTableName","tableRows","selectTable","result"],"mappings":"AAIA,SAASA,GAAG,EAAEC,IAAI,EAAEC,EAAE,EAAEC,MAAM,EAAEC,EAAE,QAAQ,cAAa;AAcvD,SAASC,iBAAiB,QAAQ,+BAA8B;AAChE,SAASC,SAAS,QAAQ,6BAA4B;AACtD,SAASC,iBAAiB,QAAQ,8BAA6B;AAC/D,SAASC,SAAS,QAAQ,iCAAgC;AAC1D,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,wBAAwB,QAAQ,gCAA+B;AACxE,SAASC,iBAAiB,QAAQ,yBAAwB;AAC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,CAACkH,qBAAqBjH,MAAM,GAAG,GAAG;gBAC/C4H,UAAUhF,OAAO,CAAC,CAACjD;oBACjB,IAAIA,IAAIyD,MAAM,IAAI6D,qBAAqB;wBACrCtH,IAAIyD,MAAM,GAAG6D,mBAAmB,CAACtH,IAAIyD,MAAM,CAAC;oBAC9C;gBACF;YACF;YAEA,IAAIwE,UAAU5H,MAAM,EAAE;gBACpB,MAAM5B,QAAQ6D,MAAM,CAAC;oBACnB1D;oBACAW,WAAWwE;oBACXvB,QAAQyF;gBACV;YACF;QACF;IACF,EAAE,OAAOlG,OAAO;QACd3D,kBAAkB;YAAEI;YAAIC;YAASC;YAAgBqD;YAAOjD;YAAYO;YAAKE;QAAU;IACrF;IAEA,IAAIR,iBAAiB,UAAU;QAC7B,OAAO;YAAEP,IAAIqB,YAAYrB,EAAE;QAAC;IAC9B;IAEA,IAAIO,cAAc;QAChB,OAAOJ;IACT;IAEA,qCAAqC;IACrC,6BAA6B;IAC7B,qCAAqC;IAErC,MAAMmC,eAAehD,kBAAkB;QACrCW;QACAsC,OAAO;QACPlC;QACAI,WAAW;QACXK;QACAC;IACF;IAEAuB,aAAarB,KAAK,GAAG9B,GAAGc,QAAQmC,MAAM,CAACrB,UAAU,CAACf,EAAE,EAAEqB,YAAYrB,EAAE;IAEpE,MAAM2C,MAAM,MAAMvC,GAAGwC,KAAK,CAAC7B,UAAU,CAAC8B,SAAS,CAACP;IAEhD,qCAAqC;IACrC,iBAAiB;IACjB,qCAAqC;IAErC,MAAMqH,SAASpK,UAAa;QAC1BU;QACA6C,QAAQ7C,QAAQ8C,GAAG,CAACD,MAAM;QAC1B3C,MAAMwC;QACNtC;QACAI,WAAW;QACXM;IACF;IAEA,OAAO4I;AACT,EAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ArrayRowToInsert } from '../transform/write/types.js';
|
|
2
|
+
import type { DrizzleAdapter, DrizzleTransaction } from '../types.js';
|
|
3
|
+
type Args = {
|
|
4
|
+
adapter: DrizzleAdapter;
|
|
5
|
+
arrays: {
|
|
6
|
+
[tableName: string]: ArrayRowToInsert[];
|
|
7
|
+
}[];
|
|
8
|
+
db: DrizzleAdapter['drizzle'] | DrizzleTransaction;
|
|
9
|
+
parentRows: Record<string, unknown>[];
|
|
10
|
+
uuidMap?: Record<string, number | string>;
|
|
11
|
+
};
|
|
12
|
+
export declare const insertArrays: ({ adapter, arrays, db, parentRows, uuidMap, }: Args) => Promise<void>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=insertArrays.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insertArrays.d.ts","sourceRoot":"","sources":["../../src/upsertRow/insertArrays.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErE,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,cAAc,CAAA;IACvB,MAAM,EAAE;QACN,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;KACxC,EAAE,CAAA;IACH,EAAE,EAAE,cAAc,CAAC,SAAS,CAAC,GAAG,kBAAkB,CAAA;IAClD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;CAC1C,CAAA;AAYD,eAAO,MAAM,YAAY,kDAMtB,IAAI,KAAG,OAAO,CAAC,IAAI,CAgGrB,CAAA"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export const insertArrays = async ({ adapter, arrays, db, parentRows, uuidMap = {} })=>{
|
|
2
|
+
// Maintain a map of flattened rows by table
|
|
3
|
+
const rowsByTable = {};
|
|
4
|
+
arrays.forEach((arraysByTable, parentRowIndex)=>{
|
|
5
|
+
if (!arraysByTable || Object.keys(arraysByTable).length === 0) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
Object.entries(arraysByTable).forEach(([tableName, arrayRows])=>{
|
|
9
|
+
// If the table doesn't exist in map, initialize it
|
|
10
|
+
if (!rowsByTable[tableName]) {
|
|
11
|
+
rowsByTable[tableName] = {
|
|
12
|
+
arrays: [],
|
|
13
|
+
locales: [],
|
|
14
|
+
rows: []
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const parentID = parentRows[parentRowIndex].id;
|
|
18
|
+
// Add any sub arrays that need to be created
|
|
19
|
+
// We will call this recursively below
|
|
20
|
+
arrayRows.forEach((arrayRow)=>{
|
|
21
|
+
if (Object.keys(arrayRow.arrays).length > 0) {
|
|
22
|
+
rowsByTable[tableName].arrays.push(arrayRow.arrays);
|
|
23
|
+
}
|
|
24
|
+
// Set up parent IDs for both row and locale row
|
|
25
|
+
arrayRow.row._parentID = parentID;
|
|
26
|
+
rowsByTable[tableName].rows.push(arrayRow.row);
|
|
27
|
+
Object.entries(arrayRow.locales).forEach(([arrayRowLocale, arrayRowLocaleData])=>{
|
|
28
|
+
arrayRowLocaleData._parentID = arrayRow.row.id;
|
|
29
|
+
arrayRowLocaleData._locale = arrayRowLocale;
|
|
30
|
+
rowsByTable[tableName].locales.push(arrayRowLocaleData);
|
|
31
|
+
if (!arrayRow.row.id) {
|
|
32
|
+
arrayRowLocaleData._getParentID = (rows)=>{
|
|
33
|
+
const { id } = rows.find((each)=>each._uuid === arrayRow.row._uuid);
|
|
34
|
+
return id;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
// Insert all corresponding arrays
|
|
42
|
+
// (one insert per array table)
|
|
43
|
+
for (const [tableName, row] of Object.entries(rowsByTable)){
|
|
44
|
+
// the nested arrays need the ID for the parentID foreign key
|
|
45
|
+
let insertedRows;
|
|
46
|
+
if (row.rows.length > 0) {
|
|
47
|
+
insertedRows = await adapter.insert({
|
|
48
|
+
db,
|
|
49
|
+
tableName,
|
|
50
|
+
values: row.rows
|
|
51
|
+
});
|
|
52
|
+
insertedRows.forEach((row)=>{
|
|
53
|
+
if (typeof row._uuid === 'string' && (typeof row.id === 'string' || typeof row.id === 'number')) {
|
|
54
|
+
uuidMap[row._uuid] = row.id;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
// Insert locale rows
|
|
59
|
+
if (adapter.tables[`${tableName}${adapter.localesSuffix}`] && row.locales.length > 0) {
|
|
60
|
+
if (!row.locales[0]._parentID) {
|
|
61
|
+
row.locales = row.locales.map((localeRow)=>{
|
|
62
|
+
if (typeof localeRow._getParentID === 'function') {
|
|
63
|
+
localeRow._parentID = localeRow._getParentID(insertedRows);
|
|
64
|
+
delete localeRow._getParentID;
|
|
65
|
+
}
|
|
66
|
+
return localeRow;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
await adapter.insert({
|
|
70
|
+
db,
|
|
71
|
+
tableName: `${tableName}${adapter.localesSuffix}`,
|
|
72
|
+
values: row.locales
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
// If there are sub arrays, call this function recursively
|
|
76
|
+
if (row.arrays.length > 0) {
|
|
77
|
+
await insertArrays({
|
|
78
|
+
adapter,
|
|
79
|
+
arrays: row.arrays,
|
|
80
|
+
db,
|
|
81
|
+
parentRows: insertedRows
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=insertArrays.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/upsertRow/insertArrays.ts"],"sourcesContent":["import type { ArrayRowToInsert } from '../transform/write/types.js'\nimport type { DrizzleAdapter, DrizzleTransaction } from '../types.js'\n\ntype Args = {\n adapter: DrizzleAdapter\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }[]\n db: DrizzleAdapter['drizzle'] | DrizzleTransaction\n parentRows: Record<string, unknown>[]\n uuidMap?: Record<string, number | string>\n}\n\ntype RowsByTable = {\n [tableName: string]: {\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }[]\n locales: Record<string, unknown>[]\n rows: Record<string, unknown>[]\n }\n}\n\nexport const insertArrays = async ({\n adapter,\n arrays,\n db,\n parentRows,\n uuidMap = {},\n}: Args): Promise<void> => {\n // Maintain a map of flattened rows by table\n const rowsByTable: RowsByTable = {}\n\n arrays.forEach((arraysByTable, parentRowIndex) => {\n if (!arraysByTable || Object.keys(arraysByTable).length === 0) {\n return\n }\n Object.entries(arraysByTable).forEach(([tableName, arrayRows]) => {\n // If the table doesn't exist in map, initialize it\n if (!rowsByTable[tableName]) {\n rowsByTable[tableName] = {\n arrays: [],\n locales: [],\n rows: [],\n }\n }\n\n const parentID = parentRows[parentRowIndex].id\n\n // Add any sub arrays that need to be created\n // We will call this recursively below\n arrayRows.forEach((arrayRow) => {\n if (Object.keys(arrayRow.arrays).length > 0) {\n rowsByTable[tableName].arrays.push(arrayRow.arrays)\n }\n\n // Set up parent IDs for both row and locale row\n arrayRow.row._parentID = parentID\n rowsByTable[tableName].rows.push(arrayRow.row)\n\n Object.entries(arrayRow.locales).forEach(([arrayRowLocale, arrayRowLocaleData]) => {\n arrayRowLocaleData._parentID = arrayRow.row.id\n arrayRowLocaleData._locale = arrayRowLocale\n rowsByTable[tableName].locales.push(arrayRowLocaleData)\n if (!arrayRow.row.id) {\n arrayRowLocaleData._getParentID = (rows: { _uuid: string; id: number }[]) => {\n const { id } = rows.find((each) => each._uuid === arrayRow.row._uuid)\n return id\n }\n }\n })\n })\n })\n })\n\n // Insert all corresponding arrays\n // (one insert per array table)\n for (const [tableName, row] of Object.entries(rowsByTable)) {\n // the nested arrays need the ID for the parentID foreign key\n let insertedRows: Args['parentRows']\n if (row.rows.length > 0) {\n insertedRows = await adapter.insert({\n db,\n tableName,\n values: row.rows,\n })\n\n insertedRows.forEach((row) => {\n if (\n typeof row._uuid === 'string' &&\n (typeof row.id === 'string' || typeof row.id === 'number')\n ) {\n uuidMap[row._uuid] = row.id\n }\n })\n }\n\n // Insert locale rows\n if (adapter.tables[`${tableName}${adapter.localesSuffix}`] && row.locales.length > 0) {\n if (!row.locales[0]._parentID) {\n row.locales = row.locales.map((localeRow) => {\n if (typeof localeRow._getParentID === 'function') {\n localeRow._parentID = localeRow._getParentID(insertedRows)\n delete localeRow._getParentID\n }\n return localeRow\n })\n }\n await adapter.insert({\n db,\n tableName: `${tableName}${adapter.localesSuffix}`,\n values: row.locales,\n })\n }\n\n // If there are sub arrays, call this function recursively\n if (row.arrays.length > 0) {\n await insertArrays({\n adapter,\n arrays: row.arrays,\n db,\n parentRows: insertedRows,\n })\n }\n }\n}\n"],"names":["insertArrays","adapter","arrays","db","parentRows","uuidMap","rowsByTable","forEach","arraysByTable","parentRowIndex","Object","keys","length","entries","tableName","arrayRows","locales","rows","parentID","id","arrayRow","push","row","_parentID","arrayRowLocale","arrayRowLocaleData","_locale","_getParentID","find","each","_uuid","insertedRows","insert","values","tables","localesSuffix","map","localeRow"],"mappings":"AAuBA,OAAO,MAAMA,eAAe,OAAO,EACjCC,OAAO,EACPC,MAAM,EACNC,EAAE,EACFC,UAAU,EACVC,UAAU,CAAC,CAAC,EACP;IACL,4CAA4C;IAC5C,MAAMC,cAA2B,CAAC;IAElCJ,OAAOK,OAAO,CAAC,CAACC,eAAeC;QAC7B,IAAI,CAACD,iBAAiBE,OAAOC,IAAI,CAACH,eAAeI,MAAM,KAAK,GAAG;YAC7D;QACF;QACAF,OAAOG,OAAO,CAACL,eAAeD,OAAO,CAAC,CAAC,CAACO,WAAWC,UAAU;YAC3D,mDAAmD;YACnD,IAAI,CAACT,WAAW,CAACQ,UAAU,EAAE;gBAC3BR,WAAW,CAACQ,UAAU,GAAG;oBACvBZ,QAAQ,EAAE;oBACVc,SAAS,EAAE;oBACXC,MAAM,EAAE;gBACV;YAC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KAAK,KAAK,YACpB,CAAA,OAAOR,IAAIH,EAAE,KAAK,YAAY,OAAOG,IAAIH,EAAE,KAAK,QAAO,GACxD;oBACAd,OAAO,CAACiB,IAAIQ,KAAK,CAAC,GAAGR,IAAIH,EAAE;gBAC7B;YACF;QACF;QAEA,qBAAqB;QACrB,IAAIlB,QAAQiC,MAAM,CAAC,GAAGpB,YAAYb,QAAQkC,aAAa,EAAE,CAAC,IAAIb,IAAIN,OAAO,CAACJ,MAAM,GAAG,GAAG;YACpF,IAAI,CAACU,IAAIN,OAAO,CAAC,EAAE,CAACO,SAAS,EAAE;gBAC7BD,IAAIN,OAAO,GAAGM,IAAIN,OAAO,CAACoB,GAAG,CAAC,CAACC;oBAC7B,IAAI,OAAOA,UAAUV,YAAY,KAAK,YAAY;wBAChDU,UAAUd,SAAS,GAAGc,UAAUV,YAAY,CAACI;wBAC7C,OAAOM,UAAUV,YAAY;oBAC/B;oBACA,OAAOU;gBACT;YACF;YACA,MAAMpC,QAAQ+B,MAAM,CAAC;gBACnB7B;gBACAW,WAAW,GAAGA,YAAYb,QAAQkC,aAAa,EAAE;gBACjDF,QAAQX,IAAIN,OAAO;YACrB;QACF;QAEA,0DAA0D;QAC1D,IAAIM,IAAIpB,MAAM,CAACU,MAAM,GAAG,GAAG;YACzB,MAAMZ,aAAa;gBACjBC;gBACAC,QAAQoB,IAAIpB,MAAM;gBAClBC;gBACAC,YAAY2B;YACd;QACF;IACF;AACF,EAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FlattenedField } from '@hanzo/cms';
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether we should use the upsertRow function for the passed data and otherwise use a simple SQL SET call.
|
|
4
|
+
* We need to use upsertRow only when the data has arrays, blocks, hasMany select/text/number, localized fields, complex relationships.
|
|
5
|
+
*/
|
|
6
|
+
export declare const shouldUseOptimizedUpsertRow: ({ data, fields, }: {
|
|
7
|
+
data: Record<string, unknown>;
|
|
8
|
+
fields: FlattenedField[];
|
|
9
|
+
}) => any;
|
|
10
|
+
//# sourceMappingURL=shouldUseOptimizedUpsertRow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shouldUseOptimizedUpsertRow.d.ts","sourceRoot":"","sources":["../../src/upsertRow/shouldUseOptimizedUpsertRow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD;;;GAGG;AACH,eAAO,MAAM,2BAA2B,sBAGrC;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,MAAM,EAAE,cAAc,EAAE,CAAA;CACzB,QA8EA,CAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether we should use the upsertRow function for the passed data and otherwise use a simple SQL SET call.
|
|
3
|
+
* We need to use upsertRow only when the data has arrays, blocks, hasMany select/text/number, localized fields, complex relationships.
|
|
4
|
+
*/ export const shouldUseOptimizedUpsertRow = ({ data, fields })=>{
|
|
5
|
+
let fieldsMatched = false;
|
|
6
|
+
for(const key in data){
|
|
7
|
+
const value = data[key];
|
|
8
|
+
const field = fields.find((each)=>each.name === key);
|
|
9
|
+
if (!field) {
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
fieldsMatched = true;
|
|
13
|
+
if (field.type === 'blocks' || (field.type === 'text' || field.type === 'relationship' || field.type === 'upload' || field.type === 'select' || field.type === 'number') && field.hasMany || (field.type === 'relationship' || field.type === 'upload') && Array.isArray(field.relationTo) || field.localized) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (field.type === 'array') {
|
|
17
|
+
if (typeof value === 'object' && '$push' in value && value.$push) {
|
|
18
|
+
return shouldUseOptimizedUpsertRow({
|
|
19
|
+
// Only check first row - this function cares about field definitions. Each array row will have the same field definitions.
|
|
20
|
+
data: Array.isArray(value.$push) ? value.$push?.[0] : value.$push,
|
|
21
|
+
fields: field.flattenedFields
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
// Handle relationship $push and $remove operations
|
|
27
|
+
if ((field.type === 'relationship' || field.type === 'upload') && field.hasMany) {
|
|
28
|
+
if (typeof value === 'object' && ('$push' in value || '$remove' in value)) {
|
|
29
|
+
return false // Use full upsertRow for relationship operations
|
|
30
|
+
;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if ((field.type === 'group' || field.type === 'tab') && value && typeof value === 'object' && !shouldUseOptimizedUpsertRow({
|
|
34
|
+
data: value,
|
|
35
|
+
fields: field.flattenedFields
|
|
36
|
+
})) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Handle dot-notation paths when no fields matched
|
|
41
|
+
if (!fieldsMatched) {
|
|
42
|
+
for(const key in data){
|
|
43
|
+
if (key.includes('.')) {
|
|
44
|
+
// Split on first dot only
|
|
45
|
+
const firstDotIndex = key.indexOf('.');
|
|
46
|
+
const fieldName = key.substring(0, firstDotIndex);
|
|
47
|
+
const remainingPath = key.substring(firstDotIndex + 1);
|
|
48
|
+
const nestedData = {
|
|
49
|
+
[fieldName]: {
|
|
50
|
+
[remainingPath]: data[key]
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return shouldUseOptimizedUpsertRow({
|
|
54
|
+
data: nestedData,
|
|
55
|
+
fields
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=shouldUseOptimizedUpsertRow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/upsertRow/shouldUseOptimizedUpsertRow.ts"],"sourcesContent":["import type { FlattenedField } from '@hanzo/cms'\n\n/**\n * Checks whether we should use the upsertRow function for the passed data and otherwise use a simple SQL SET call.\n * We need to use upsertRow only when the data has arrays, blocks, hasMany select/text/number, localized fields, complex relationships.\n */\nexport const shouldUseOptimizedUpsertRow = ({\n data,\n fields,\n}: {\n data: Record<string, unknown>\n fields: FlattenedField[]\n}) => {\n let fieldsMatched = false\n\n for (const key in data) {\n const value = data[key]\n const field = fields.find((each) => each.name === key)\n\n if (!field) {\n continue\n }\n\n fieldsMatched = true\n\n if (\n field.type === 'blocks' ||\n ((field.type === 'text' ||\n field.type === 'relationship' ||\n field.type === 'upload' ||\n field.type === 'select' ||\n field.type === 'number') &&\n field.hasMany) ||\n ((field.type === 'relationship' || field.type === 'upload') &&\n Array.isArray(field.relationTo)) ||\n field.localized\n ) {\n return false\n }\n\n if (field.type === 'array') {\n if (typeof value === 'object' && '$push' in value && value.$push) {\n return shouldUseOptimizedUpsertRow({\n // Only check first row - this function cares about field definitions. Each array row will have the same field definitions.\n data: Array.isArray(value.$push) ? value.$push?.[0] : value.$push,\n fields: field.flattenedFields,\n })\n }\n return false\n }\n\n // Handle relationship $push and $remove operations\n if ((field.type === 'relationship' || field.type === 'upload') && field.hasMany) {\n if (typeof value === 'object' && ('$push' in value || '$remove' in value)) {\n return false // Use full upsertRow for relationship operations\n }\n }\n\n if (\n (field.type === 'group' || field.type === 'tab') &&\n value &&\n typeof value === 'object' &&\n !shouldUseOptimizedUpsertRow({\n data: value as Record<string, unknown>,\n fields: field.flattenedFields,\n })\n ) {\n return false\n }\n }\n\n // Handle dot-notation paths when no fields matched\n if (!fieldsMatched) {\n for (const key in data) {\n if (key.includes('.')) {\n // Split on first dot only\n const firstDotIndex = key.indexOf('.')\n const fieldName = key.substring(0, firstDotIndex)\n const remainingPath = key.substring(firstDotIndex + 1)\n\n const nestedData = { [fieldName]: { [remainingPath]: data[key] } }\n return shouldUseOptimizedUpsertRow({\n data: nestedData,\n fields,\n })\n }\n }\n }\n\n return true\n}\n"],"names":["shouldUseOptimizedUpsertRow","data","fields","fieldsMatched","key","value","field","find","each","name","type","hasMany","Array","isArray","relationTo","localized","$push","flattenedFields","includes","firstDotIndex","indexOf","fieldName","substring","remainingPath","nestedData"],"mappings":"AAEA;;;CAGC,GACD,OAAO,MAAMA,8BAA8B,CAAC,EAC1CC,IAAI,EACJC,MAAM,EAIP;IACC,IAAIC,gBAAgB;IAEpB,IAAK,MAAMC,OAAOH,KAAM;QACtB,MAAMI,QAAQJ,IAAI,CAACG,IAAI;QACvB,MAAME,QAAQJ,OAAOK,IAAI,CAAC,CAACC,OAASA,KAAKC,IAAI,KAAKL;QAElD,IAAI,CAACE,OAAO;YACV;QACF;QAEAH,gBAAgB;QAEhB,IACEG,MAAMI,IAAI,KAAK,YACd,AAACJ,CAAAA,MAAMI,IAAI,KAAK,UACfJ,MAAMI,IAAI,KAAK,kBACfJ,MAAMI,IAAI,KAAK,YACfJ,MAAMI,IAAI,KAAK,YACfJ,MAAMI,IAAI,KAAK,QAAO,KACtBJ,MAAMK,OAAO,IACd,AAACL,CAAAA,MAAMI,IAAI,KAAK,kBAAkBJ,MAAMI,IAAI,KAAK,QAAO,KACvDE,MAAMC,OAAO,CAACP,MAAMQ,UAAU,KAChCR,MAAMS,SAAS,EACf;YACA,OAAO;QACT;QAEA,IAAIT,MAAMI,IAAI,KAAK,SAAS;YAC1B,IAAI,OAAOL,UAAU,YAAY,WAAWA,SAASA,MAAMW,KAAK,EAAE;gBAChE,OAAOhB,4BAA4B;oBACjC,2HAA2H;oBAC3HC,MAAMW,MAAMC,OAAO,CAACR,MAAMW,KAAK,IAAIX,MAAMW,KAAK,EAAE,CAAC,EAAE,GAAGX,MAAMW,KAAK;oBACjEd,QAAQI,MAAMW,eAAe;gBAC/B;YACF;YACA,OAAO;QACT;QAEA,mDAAmD;QACnD,IAAI,AAACX,CAAAA,MAAMI,IAAI,KAAK,kBAAkBJ,MAAMI,IAAI,KAAK,QAAO,KAAMJ,MAAMK,OAAO,EAAE;YAC/E,IAAI,OAAON,UAAU,YAAa,CAAA,WAAWA,SAAS,aAAaA,KAAI,GAAI;gBACzE,OAAO,MAAM,iDAAiD;;YAChE;QACF;QAEA,IACE,AAACC,CAAAA,MAAMI,IAAI,KAAK,WAAWJ,MAAMI,IAAI,KAAK,KAAI,KAC9CL,SACA,OAAOA,UAAU,YACjB,CAACL,4BAA4B;YAC3BC,MAAMI;YACNH,QAAQI,MAAMW,eAAe;QAC/B,IACA;YACA,OAAO;QACT;IACF;IAEA,mDAAmD;IACnD,IAAI,CAACd,eAAe;QAClB,IAAK,MAAMC,OAAOH,KAAM;YACtB,IAAIG,IAAIc,QAAQ,CAAC,MAAM;gBACrB,0BAA0B;gBAC1B,MAAMC,gBAAgBf,IAAIgB,OAAO,CAAC;gBAClC,MAAMC,YAAYjB,IAAIkB,SAAS,CAAC,GAAGH;gBACnC,MAAMI,gBAAgBnB,IAAIkB,SAAS,CAACH,gBAAgB;gBAEpD,MAAMK,aAAa;oBAAE,CAACH,UAAU,EAAE;wBAAE,CAACE,cAAc,EAAEtB,IAAI,CAACG,IAAI;oBAAC;gBAAE;gBACjE,OAAOJ,4BAA4B;oBACjCC,MAAMuB;oBACNtB;gBACF;YACF;QACF;IACF;IAEA,OAAO;AACT,EAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { SQL } from 'drizzle-orm';
|
|
2
|
+
import type { FlattenedField, JoinQuery, CMSRequest, SelectType } from '@hanzo/cms';
|
|
3
|
+
import type { DrizzleAdapter, DrizzleTransaction, GenericColumn } from '../types.js';
|
|
4
|
+
type BaseArgs = {
|
|
5
|
+
adapter: DrizzleAdapter;
|
|
6
|
+
/**
|
|
7
|
+
* Collection slug for error reporting
|
|
8
|
+
*/
|
|
9
|
+
collectionSlug?: string;
|
|
10
|
+
data: Record<string, unknown>;
|
|
11
|
+
db: DrizzleAdapter['drizzle'] | DrizzleTransaction;
|
|
12
|
+
fields: FlattenedField[];
|
|
13
|
+
/**
|
|
14
|
+
* Collection slug for error reporting
|
|
15
|
+
*/
|
|
16
|
+
globalSlug?: string;
|
|
17
|
+
/**
|
|
18
|
+
* When true, skips reading the data back from the database and returns the input data
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
ignoreResult?: 'idOnly' | boolean;
|
|
22
|
+
joinQuery?: JoinQuery;
|
|
23
|
+
path?: string;
|
|
24
|
+
req?: Partial<CMSRequest>;
|
|
25
|
+
tableName: string;
|
|
26
|
+
};
|
|
27
|
+
type CreateArgs = {
|
|
28
|
+
customID?: number | string;
|
|
29
|
+
id?: never;
|
|
30
|
+
joinQuery?: never;
|
|
31
|
+
operation: 'create';
|
|
32
|
+
select?: SelectType;
|
|
33
|
+
upsertTarget?: never;
|
|
34
|
+
where?: never;
|
|
35
|
+
} & BaseArgs;
|
|
36
|
+
type UpdateArgs = {
|
|
37
|
+
customID?: never;
|
|
38
|
+
id?: number | string;
|
|
39
|
+
joinQuery?: JoinQuery;
|
|
40
|
+
operation: 'update';
|
|
41
|
+
select?: SelectType;
|
|
42
|
+
upsertTarget?: GenericColumn;
|
|
43
|
+
where?: SQL<unknown>;
|
|
44
|
+
} & BaseArgs;
|
|
45
|
+
export type Args = CreateArgs | UpdateArgs;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/upsertRow/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEnF,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEpF,KAAK,QAAQ,GAAG;IACd,OAAO,EAAE,cAAc,CAAA;IACvB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,EAAE,EAAE,cAAc,CAAC,SAAS,CAAC,GAAG,kBAAkB,CAAA;IAClD,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAA;IACjC,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAA;IACzB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,KAAK,UAAU,GAAG;IAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC1B,EAAE,CAAC,EAAE,KAAK,CAAA;IACV,SAAS,CAAC,EAAE,KAAK,CAAA;IACjB,SAAS,EAAE,QAAQ,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,YAAY,CAAC,EAAE,KAAK,CAAA;IACpB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,GAAG,QAAQ,CAAA;AAEZ,KAAK,UAAU,GAAG;IAChB,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,SAAS,EAAE,QAAQ,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,YAAY,CAAC,EAAE,aAAa,CAAA;IAC5B,KAAK,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;CACrB,GAAG,QAAQ,CAAA;AAEZ,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG,UAAU,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/upsertRow/types.ts"],"sourcesContent":["import type { SQL } from 'drizzle-orm'\nimport type { FlattenedField, JoinQuery, CMSRequest, SelectType } from '@hanzo/cms'\n\nimport type { DrizzleAdapter, DrizzleTransaction, GenericColumn } from '../types.js'\n\ntype BaseArgs = {\n adapter: DrizzleAdapter\n /**\n * Collection slug for error reporting\n */\n collectionSlug?: string\n data: Record<string, unknown>\n db: DrizzleAdapter['drizzle'] | DrizzleTransaction\n fields: FlattenedField[]\n /**\n * Collection slug for error reporting\n */\n globalSlug?: string\n /**\n * When true, skips reading the data back from the database and returns the input data\n * @default false\n */\n ignoreResult?: 'idOnly' | boolean\n joinQuery?: JoinQuery\n path?: string\n req?: Partial<CMSRequest>\n tableName: string\n}\n\ntype CreateArgs = {\n customID?: number | string\n id?: never\n joinQuery?: never\n operation: 'create'\n select?: SelectType\n upsertTarget?: never\n where?: never\n} & BaseArgs\n\ntype UpdateArgs = {\n customID?: never\n id?: number | string\n joinQuery?: JoinQuery\n operation: 'update'\n select?: SelectType\n upsertTarget?: GenericColumn\n where?: SQL<unknown>\n} & BaseArgs\n\nexport type Args = CreateArgs | UpdateArgs\n"],"names":[],"mappings":"AAiDA,WAA0C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appendPrefixToKeys.d.ts","sourceRoot":"","sources":["../../src/utilities/appendPrefixToKeys.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,GAAI,CAAC,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,MAAM,KAAG,CAI9E,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/appendPrefixToKeys.ts"],"sourcesContent":["export const appendPrefixToObjectKeys = <T>(obj: Record<string, unknown>, prefix: string): T =>\n Object.entries(obj).reduce((res, [key, val]) => {\n res[`${prefix}_${key}`] = val\n return res\n }, {} as T)\n"],"names":["appendPrefixToObjectKeys","obj","prefix","Object","entries","reduce","res","key","val"],"mappings":"AAAA,OAAO,MAAMA,2BAA2B,CAAIC,KAA8BC,SACxEC,OAAOC,OAAO,CAACH,KAAKI,MAAM,CAAC,CAACC,KAAK,CAACC,KAAKC,IAAI;QACzCF,GAAG,CAAC,GAAGJ,OAAO,CAAC,EAAEK,KAAK,CAAC,GAAGC;QAC1B,OAAOF;IACT,GAAG,CAAC,GAAO"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DynamicMigrationTemplate, CMS } from '@hanzo/cms';
|
|
2
|
+
import type { BlocksToJsonMigrator, DrizzleAdapter } from '../types.js';
|
|
3
|
+
export declare const createBlocksToJsonMigrator: ({ adapter, executeMethod, sanitizeStatements, }: {
|
|
4
|
+
adapter: DrizzleAdapter;
|
|
5
|
+
executeMethod: string;
|
|
6
|
+
sanitizeStatements: (args: {
|
|
7
|
+
sqlExecute: string;
|
|
8
|
+
statements: string[];
|
|
9
|
+
}) => string;
|
|
10
|
+
}) => BlocksToJsonMigrator;
|
|
11
|
+
export declare const getBlocksToJsonMigrator: (cms: CMS) => BlocksToJsonMigrator;
|
|
12
|
+
export declare const buildDynamicPredefinedBlocksToJsonMigration: ({ packageName, }: {
|
|
13
|
+
packageName: string;
|
|
14
|
+
}) => DynamicMigrationTemplate;
|
|
15
|
+
//# sourceMappingURL=blocksToJsonMigrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocksToJsonMigrator.d.ts","sourceRoot":"","sources":["../../src/utilities/blocksToJsonMigrator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EAExB,GAAG,EAGJ,MAAM,YAAY,CAAA;AAcnB,OAAO,KAAK,EAGV,oBAAoB,EACpB,cAAc,EACf,MAAM,aAAa,CAAA;AA8rBpB,eAAO,MAAM,0BAA0B,oDAIpC;IACD,OAAO,EAAE,cAAc,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,kBAAkB,EAAE,CAAC,IAAI,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,EAAE,CAAA;KAAE,KAAK,MAAM,CAAA;CACnF,KAAG,oBAEH,CAAA;AAED,eAAO,MAAM,uBAAuB,QAAS,GAAG,KAAG,oBAQlD,CAAA;AAED,eAAO,MAAM,2CAA2C,qBAErD;IACD,WAAW,EAAE,MAAM,CAAA;CACpB,KAAG,wBAoCH,CAAA"}
|