@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
package/dist/index.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export { count } from './count.js';
|
|
2
|
+
export { countGlobalVersions } from './countGlobalVersions.js';
|
|
3
|
+
export { countVersions } from './countVersions.js';
|
|
4
|
+
export { create } from './create.js';
|
|
5
|
+
export { createGlobal } from './createGlobal.js';
|
|
6
|
+
export { createGlobalVersion } from './createGlobalVersion.js';
|
|
7
|
+
export { createTableName } from './createTableName.js';
|
|
8
|
+
export { createVersion } from './createVersion.js';
|
|
9
|
+
export { deleteMany } from './deleteMany.js';
|
|
10
|
+
export { deleteOne } from './deleteOne.js';
|
|
11
|
+
export { deleteVersions } from './deleteVersions.js';
|
|
12
|
+
export { destroy } from './destroy.js';
|
|
13
|
+
export { find } from './find.js';
|
|
14
|
+
export { chainMethods } from './find/chainMethods.js';
|
|
15
|
+
export { findDistinct } from './findDistinct.js';
|
|
16
|
+
export { findGlobal } from './findGlobal.js';
|
|
17
|
+
export { findGlobalVersions } from './findGlobalVersions.js';
|
|
18
|
+
export { findOne } from './findOne.js';
|
|
19
|
+
export { findVersions } from './findVersions.js';
|
|
20
|
+
export { migrate } from './migrate.js';
|
|
21
|
+
export { migrateDown } from './migrateDown.js';
|
|
22
|
+
export { migrateFresh } from './migrateFresh.js';
|
|
23
|
+
export { migrateRefresh } from './migrateRefresh.js';
|
|
24
|
+
export { migrateReset } from './migrateReset.js';
|
|
25
|
+
export { migrateStatus } from './migrateStatus.js';
|
|
26
|
+
export { buildQuery } from './queries/buildQuery.js';
|
|
27
|
+
export { operatorMap } from './queries/operatorMap.js';
|
|
28
|
+
export { parseParams } from './queries/parseParams.js';
|
|
29
|
+
export { queryDrafts } from './queryDrafts.js';
|
|
30
|
+
export { buildDrizzleRelations } from './schema/buildDrizzleRelations.js';
|
|
31
|
+
export { buildRawSchema } from './schema/buildRawSchema.js';
|
|
32
|
+
export { beginTransaction } from './transactions/beginTransaction.js';
|
|
33
|
+
export { commitTransaction } from './transactions/commitTransaction.js';
|
|
34
|
+
export { rollbackTransaction } from './transactions/rollbackTransaction.js';
|
|
35
|
+
export { updateGlobal } from './updateGlobal.js';
|
|
36
|
+
export { updateGlobalVersion } from './updateGlobalVersion.js';
|
|
37
|
+
export { updateJobs } from './updateJobs.js';
|
|
38
|
+
export { updateMany } from './updateMany.js';
|
|
39
|
+
export { updateOne } from './updateOne.js';
|
|
40
|
+
export { updateVersion } from './updateVersion.js';
|
|
41
|
+
export { upsert } from './upsert.js';
|
|
42
|
+
export { upsertRow } from './upsertRow/index.js';
|
|
43
|
+
export { buildDynamicPredefinedBlocksToJsonMigration, createBlocksToJsonMigrator, getBlocksToJsonMigrator } from './utilities/blocksToJsonMigrator.js';
|
|
44
|
+
export { buildCreateMigration } from './utilities/buildCreateMigration.js';
|
|
45
|
+
export { buildIndexName } from './utilities/buildIndexName.js';
|
|
46
|
+
export { createSchemaGenerator } from './utilities/createSchemaGenerator.js';
|
|
47
|
+
export { executeSchemaHooks } from './utilities/executeSchemaHooks.js';
|
|
48
|
+
export { extendDrizzleTable } from './utilities/extendDrizzleTable.js';
|
|
49
|
+
export { hasLocalesTable } from './utilities/hasLocalesTable.js';
|
|
50
|
+
export { pushDevSchema } from './utilities/pushDevSchema.js';
|
|
51
|
+
export { validateExistingBlockIsIdentical } from './utilities/validateExistingBlockIsIdentical.js';
|
|
52
|
+
import { findMigrationDir as cmsFindMigrationDir } from '@hanzo/cms';
|
|
53
|
+
/**
|
|
54
|
+
* @deprecated remove in 4.0
|
|
55
|
+
* use
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { findMigrationDir } from '@hanzo/cms'
|
|
58
|
+
* ```
|
|
59
|
+
*/ export const findMigrationDir = cmsFindMigrationDir;
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { count } from './count.js'\nexport { countGlobalVersions } from './countGlobalVersions.js'\nexport { countVersions } from './countVersions.js'\nexport { create } from './create.js'\nexport { createGlobal } from './createGlobal.js'\nexport { createGlobalVersion } from './createGlobalVersion.js'\nexport { createTableName } from './createTableName.js'\nexport { createVersion } from './createVersion.js'\nexport { deleteMany } from './deleteMany.js'\nexport { deleteOne } from './deleteOne.js'\nexport { deleteVersions } from './deleteVersions.js'\nexport { destroy } from './destroy.js'\nexport { find } from './find.js'\nexport { chainMethods } from './find/chainMethods.js'\nexport { findDistinct } from './findDistinct.js'\nexport { findGlobal } from './findGlobal.js'\nexport { findGlobalVersions } from './findGlobalVersions.js'\nexport { findOne } from './findOne.js'\nexport { findVersions } from './findVersions.js'\nexport { migrate } from './migrate.js'\nexport { migrateDown } from './migrateDown.js'\nexport { migrateFresh } from './migrateFresh.js'\nexport { migrateRefresh } from './migrateRefresh.js'\nexport { migrateReset } from './migrateReset.js'\nexport { migrateStatus } from './migrateStatus.js'\nexport { buildQuery } from './queries/buildQuery.js'\nexport { operatorMap } from './queries/operatorMap.js'\nexport type { Operators } from './queries/operatorMap.js'\nexport { parseParams } from './queries/parseParams.js'\nexport { queryDrafts } from './queryDrafts.js'\nexport { buildDrizzleRelations } from './schema/buildDrizzleRelations.js'\nexport { buildRawSchema } from './schema/buildRawSchema.js'\nexport { beginTransaction } from './transactions/beginTransaction.js'\nexport { commitTransaction } from './transactions/commitTransaction.js'\nexport { rollbackTransaction } from './transactions/rollbackTransaction.js'\nexport type {\n BaseRawColumn,\n BlocksToJsonMigrator,\n BuildDrizzleTable,\n BuildQueryJoinAliases,\n ChainedMethods,\n ColumnToCodeConverter,\n CountDistinct,\n CreateJSONQueryArgs,\n DeleteWhere,\n DrizzleAdapter,\n DrizzleTransaction,\n DropDatabase,\n EnumRawColumn,\n Execute,\n GenericColumn,\n GenericColumns,\n GenericPgColumn,\n GenericRelation,\n GenericTable,\n IDType,\n Insert,\n IntegerRawColumn,\n Migration,\n PostgresDB,\n RawColumn,\n RawForeignKey,\n RawIndex,\n RawRelation,\n RawTable,\n RelationMap,\n RequireDrizzleKit,\n SetColumnID,\n SQLiteDB,\n TimestampRawColumn,\n TransactionPg,\n TransactionSQLite,\n UUIDRawColumn,\n VectorRawColumn,\n} from './types.js'\nexport { updateGlobal } from './updateGlobal.js'\nexport { updateGlobalVersion } from './updateGlobalVersion.js'\nexport { updateJobs } from './updateJobs.js'\nexport { updateMany } from './updateMany.js'\nexport { updateOne } from './updateOne.js'\nexport { updateVersion } from './updateVersion.js'\nexport { upsert } from './upsert.js'\nexport { upsertRow } from './upsertRow/index.js'\nexport {\n buildDynamicPredefinedBlocksToJsonMigration,\n createBlocksToJsonMigrator,\n getBlocksToJsonMigrator,\n} from './utilities/blocksToJsonMigrator.js'\nexport { buildCreateMigration } from './utilities/buildCreateMigration.js'\nexport { buildIndexName } from './utilities/buildIndexName.js'\nexport { createSchemaGenerator } from './utilities/createSchemaGenerator.js'\nexport { executeSchemaHooks } from './utilities/executeSchemaHooks.js'\nexport { extendDrizzleTable } from './utilities/extendDrizzleTable.js'\nexport { hasLocalesTable } from './utilities/hasLocalesTable.js'\nexport { pushDevSchema } from './utilities/pushDevSchema.js'\nexport { validateExistingBlockIsIdentical } from './utilities/validateExistingBlockIsIdentical.js'\nimport { findMigrationDir as cmsFindMigrationDir } from '@hanzo/cms'\n\n/**\n * @deprecated remove in 4.0\n * use\n * ```ts\n * import { findMigrationDir } from '@hanzo/cms'\n * ```\n */\nexport const findMigrationDir = cmsFindMigrationDir\n"],"names":["count","countGlobalVersions","countVersions","create","createGlobal","createGlobalVersion","createTableName","createVersion","deleteMany","deleteOne","deleteVersions","destroy","find","chainMethods","findDistinct","findGlobal","findGlobalVersions","findOne","findVersions","migrate","migrateDown","migrateFresh","migrateRefresh","migrateReset","migrateStatus","buildQuery","operatorMap","parseParams","queryDrafts","buildDrizzleRelations","buildRawSchema","beginTransaction","commitTransaction","rollbackTransaction","updateGlobal","updateGlobalVersion","updateJobs","updateMany","updateOne","updateVersion","upsert","upsertRow","buildDynamicPredefinedBlocksToJsonMigration","createBlocksToJsonMigrator","getBlocksToJsonMigrator","buildCreateMigration","buildIndexName","createSchemaGenerator","executeSchemaHooks","extendDrizzleTable","hasLocalesTable","pushDevSchema","validateExistingBlockIsIdentical","findMigrationDir","cmsFindMigrationDir"],"mappings":"AAAA,SAASA,KAAK,QAAQ,aAAY;AAClC,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,MAAM,QAAQ,cAAa;AACpC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,IAAI,QAAQ,YAAW;AAChC,SAASC,YAAY,QAAQ,yBAAwB;AACrD,SAASC,YA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gC;AAChE,SAASC,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,gCAAgC,QAAQ,kDAAiD;AAClG,SAASC,oBAAoBC,mBAAmB,QAAQ,aAAY;AAEpE;;;;;;CAMC,GACD,OAAO,MAAMD,mBAAmBC,oBAAmB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,YAAY,CAAA;AAM3D,eAAO,MAAM,OAAO,EAAE,cAAc,CAAC,SAAS,CAsE7C,CAAA"}
|
package/dist/migrate.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { commitTransaction, createLocalReq, initTransaction, killTransaction, readMigrationFiles } from '@hanzo/cms';
|
|
2
|
+
import prompts from 'prompts';
|
|
3
|
+
import { getTransaction } from './utilities/getTransaction.js';
|
|
4
|
+
import { migrationTableExists } from './utilities/migrationTableExists.js';
|
|
5
|
+
import { parseError } from './utilities/parseError.js';
|
|
6
|
+
export const migrate = async function migrate(args) {
|
|
7
|
+
const { cms } = this;
|
|
8
|
+
const migrationFiles = args?.migrations || await readMigrationFiles({
|
|
9
|
+
cms
|
|
10
|
+
});
|
|
11
|
+
if (!migrationFiles.length) {
|
|
12
|
+
cms.logger.info({
|
|
13
|
+
msg: 'No migrations to run.'
|
|
14
|
+
});
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if ('createExtensions' in this && typeof this.createExtensions === 'function') {
|
|
18
|
+
await this.createExtensions();
|
|
19
|
+
}
|
|
20
|
+
let latestBatch = 0;
|
|
21
|
+
let migrationsInDB = [];
|
|
22
|
+
const hasMigrationTable = await migrationTableExists(this);
|
|
23
|
+
if (hasMigrationTable) {
|
|
24
|
+
;
|
|
25
|
+
({ docs: migrationsInDB } = await cms.find({
|
|
26
|
+
collection: 'cms-migrations',
|
|
27
|
+
limit: 0,
|
|
28
|
+
sort: '-name'
|
|
29
|
+
}));
|
|
30
|
+
if (migrationsInDB.find((m)=>m.batch === -1)) {
|
|
31
|
+
const { confirm: runMigrations } = await prompts({
|
|
32
|
+
name: 'confirm',
|
|
33
|
+
type: 'confirm',
|
|
34
|
+
initial: false,
|
|
35
|
+
message: "It looks like you've run CMS in dev mode, meaning you've dynamically pushed changes to your database.\n\n" + "If you'd like to run migrations, data loss will occur. Would you like to proceed?"
|
|
36
|
+
}, {
|
|
37
|
+
onCancel: ()=>{
|
|
38
|
+
process.exit(0);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
if (!runMigrations) {
|
|
42
|
+
process.exit(0);
|
|
43
|
+
}
|
|
44
|
+
// ignore the dev migration so that the latest batch number increments correctly
|
|
45
|
+
migrationsInDB = migrationsInDB.filter((m)=>m.batch !== -1);
|
|
46
|
+
}
|
|
47
|
+
if (Number(migrationsInDB?.[0]?.batch) > 0) {
|
|
48
|
+
latestBatch = Number(migrationsInDB[0]?.batch);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const newBatch = latestBatch + 1;
|
|
52
|
+
// Execute 'up' function for each migration sequentially
|
|
53
|
+
for (const migration of migrationFiles){
|
|
54
|
+
const alreadyRan = migrationsInDB.find((existing)=>existing.name === migration.name);
|
|
55
|
+
// If already ran, skip
|
|
56
|
+
if (alreadyRan) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
await runMigrationFile(cms, migration, newBatch);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
async function runMigrationFile(cms, migration, batch) {
|
|
63
|
+
const start = Date.now();
|
|
64
|
+
const req = await createLocalReq({}, cms);
|
|
65
|
+
cms.logger.info({
|
|
66
|
+
msg: `Migrating: ${migration.name}`
|
|
67
|
+
});
|
|
68
|
+
try {
|
|
69
|
+
await initTransaction(req);
|
|
70
|
+
const db = await getTransaction(cms.db, req);
|
|
71
|
+
await migration.up({
|
|
72
|
+
db,
|
|
73
|
+
cms,
|
|
74
|
+
req
|
|
75
|
+
});
|
|
76
|
+
cms.logger.info({
|
|
77
|
+
msg: `Migrated: ${migration.name} (${Date.now() - start}ms)`
|
|
78
|
+
});
|
|
79
|
+
await cms.create({
|
|
80
|
+
collection: 'cms-migrations',
|
|
81
|
+
data: {
|
|
82
|
+
name: migration.name,
|
|
83
|
+
batch
|
|
84
|
+
},
|
|
85
|
+
req
|
|
86
|
+
});
|
|
87
|
+
await commitTransaction(req);
|
|
88
|
+
} catch (err) {
|
|
89
|
+
await killTransaction(req);
|
|
90
|
+
cms.logger.error({
|
|
91
|
+
err,
|
|
92
|
+
msg: parseError(err, `Error running migration ${migration.name}`)
|
|
93
|
+
});
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
//# sourceMappingURL=migrate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/migrate.ts"],"sourcesContent":["import type { CMS } from '@hanzo/cms'\n\nimport {\n commitTransaction,\n createLocalReq,\n initTransaction,\n killTransaction,\n readMigrationFiles,\n} from '@hanzo/cms'\nimport prompts from 'prompts'\n\nimport type { DrizzleAdapter, Migration } from './types.js'\n\nimport { getTransaction } from './utilities/getTransaction.js'\nimport { migrationTableExists } from './utilities/migrationTableExists.js'\nimport { parseError } from './utilities/parseError.js'\n\nexport const migrate: DrizzleAdapter['migrate'] = async function migrate(\n this: DrizzleAdapter,\n args,\n): Promise<void> {\n const { cms } = this\n const migrationFiles = args?.migrations || (await readMigrationFiles({ cms }))\n\n if (!migrationFiles.length) {\n cms.logger.info({ msg: 'No migrations to run.' })\n return\n }\n\n if ('createExtensions' in this && typeof this.createExtensions === 'function') {\n await this.createExtensions()\n }\n\n let latestBatch = 0\n let migrationsInDB = []\n\n const hasMigrationTable = await migrationTableExists(this)\n\n if (hasMigrationTable) {\n ;({ docs: migrationsInDB } = await cms.find({\n collection: 'cms-migrations',\n limit: 0,\n sort: '-name',\n }))\n\n if (migrationsInDB.find((m) => m.batch === -1)) {\n const { confirm: runMigrations } = await prompts(\n {\n name: 'confirm',\n type: 'confirm',\n initial: false,\n message:\n \"It looks like you've run CMS in dev mode, meaning you've dynamically pushed changes to your database.\\n\\n\" +\n \"If you'd like to run migrations, data loss will occur. Would you like to proceed?\",\n },\n {\n onCancel: () => {\n process.exit(0)\n },\n },\n )\n\n if (!runMigrations) {\n process.exit(0)\n }\n // ignore the dev migration so that the latest batch number increments correctly\n migrationsInDB = migrationsInDB.filter((m) => m.batch !== -1)\n }\n\n if (Number(migrationsInDB?.[0]?.batch) > 0) {\n latestBatch = Number(migrationsInDB[0]?.batch)\n }\n }\n\n const newBatch = latestBatch + 1\n\n // Execute 'up' function for each migration sequentially\n for (const migration of migrationFiles) {\n const alreadyRan = migrationsInDB.find((existing) => existing.name === migration.name)\n\n // If already ran, skip\n if (alreadyRan) {\n continue\n }\n\n await runMigrationFile(cms, migration, newBatch)\n }\n}\n\nasync function runMigrationFile(cms: CMS, migration: Migration, batch: number) {\n const start = Date.now()\n const req = await createLocalReq({}, cms)\n\n cms.logger.info({ msg: `Migrating: ${migration.name}` })\n\n try {\n await initTransaction(req)\n const db = await getTransaction(cms.db as DrizzleAdapter, req)\n await migration.up({ db, cms, req })\n cms.logger.info({ msg: `Migrated: ${migration.name} (${Date.now() - start}ms)` })\n await cms.create({\n collection: 'cms-migrations',\n data: {\n name: migration.name,\n batch,\n },\n req,\n })\n await commitTransaction(req)\n } catch (err: unknown) {\n await killTransaction(req)\n cms.logger.error({\n err,\n msg: parseError(err, `Error running migration ${migration.name}`),\n })\n process.exit(1)\n }\n}\n"],"names":["commitTransaction","createLocalReq","initTransaction","killTransaction","readMigrationFiles","prompts","getTransaction","migrationTableExists","parseError","migrate","args","cms","migrationFiles","migrations","length","logger","info","msg","createExtensions","latestBatch","migrationsInDB","hasMigrationTable","docs","find","collection","limit","sort","m","batch","confirm","runMigrations","name","type","initial","message","onCancel","process","exit","filter","Number","newBatch","migration","alreadyRan","existing","runMigrationFile","start","Date","now","req","db","up","create","data","err","error"],"mappings":"AAEA,SACEA,iBAAiB,EACjBC,cAAc,EACdC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QACb,aAAY;AACnB,OAAOC,aAAa,UAAS;AAI7B,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,UAAU,QAAQ,4BAA2B;AAEtD,OAAO,MAAMC,UAAqC,eAAeA,QAE/DC,IAAI;IAEJ,MAAM,EAAEC,GAAG,EAAE,GAAG,IAAI;IACpB,MAAMC,iBAAiBF,MAAMG,cAAe,MAAMT,mBAAmB;QAAEO;IAAI;IAE3E,IAAI,CAACC,eAAeE,MAAM,EAAE;QAC1BH,IAAII,MAAM,CAACC,IAAI,CAAC;YAAEC,KAAK;QAAwB;QAC/C;IACF;IAEA,IAAI,sBAAsB,IAAI,IAAI,OAAO,IAAI,CAACC,gBAAgB,KAAK,YAAY;QAC7E,MAAM,IAAI,CAACA,gBAAgB;IAC7B;IAEA,IAAIC,cAAc;IAClB,IAAIC,iBAAiB,EAAE;IAEvB,MAAMC,oBAAoB,MAAMd,qBAAqB,IAAI;IAEzD,IAAIc,mBAAmB;;QACnB,CAAA,EAAEC,MAAMF,cAAc,EAAE,GAAG,MAAMT,IAAIY,IAAI,CAAC;YAC1CC,YAAY;YACZC,OAAO;YACPC,MAAM;QACR,EAAC;QAED,IAAIN,eAAeG,IAAI,CAAC,CAACI,IAAMA,EAAEC,KAAK,KAAK,CAAC,IAAI;YAC9C,MAAM,EAAEC,SAASC,aAAa,EAAE,GAAG,MAAMzB,QACvC;gBACE0B,MAAM;gBACNC,MAAM;gBACNC,SAAS;gBACTC,SACE,8GACA;YACJ,GACA;gBACEC,UAAU;oBACRC,QAAQC,IAAI,CAAC;gBACf;YACF;YAGF,IAAI,CAACP,eAAe;gBAClBM,QAAQC,IAAI,CAAC;YACf;YACA,gFAAgF;YAChFjB,iBAAiBA,eAAekB,MAAM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C,KAAKT,WAAW6C,KAAK,CAAC,wBAAwB,EAAEZ,UAAUV,IAAI,EAAE;QAClE;QACAK,QAAQC,IAAI,CAAC;IACf;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrateDown.d.ts","sourceRoot":"","sources":["../src/migrateDown.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAMhD,wBAAsB,WAAW,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA0DrE"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { commitTransaction, createLocalReq, getMigrations, initTransaction, killTransaction, readMigrationFiles } from '@hanzo/cms';
|
|
2
|
+
import { getTransaction } from './utilities/getTransaction.js';
|
|
3
|
+
import { migrationTableExists } from './utilities/migrationTableExists.js';
|
|
4
|
+
import { parseError } from './utilities/parseError.js';
|
|
5
|
+
export async function migrateDown() {
|
|
6
|
+
const { cms } = this;
|
|
7
|
+
const migrationFiles = await readMigrationFiles({
|
|
8
|
+
cms
|
|
9
|
+
});
|
|
10
|
+
const { existingMigrations, latestBatch } = await getMigrations({
|
|
11
|
+
cms
|
|
12
|
+
});
|
|
13
|
+
if (!existingMigrations?.length) {
|
|
14
|
+
cms.logger.info({
|
|
15
|
+
msg: 'No migrations to rollback.'
|
|
16
|
+
});
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
cms.logger.info({
|
|
20
|
+
msg: `Rolling back batch ${latestBatch} consisting of ${existingMigrations.length} migration(s).`
|
|
21
|
+
});
|
|
22
|
+
const latestBatchMigrations = existingMigrations.filter(({ batch })=>batch === latestBatch);
|
|
23
|
+
for (const migration of latestBatchMigrations){
|
|
24
|
+
const migrationFile = migrationFiles.find((m)=>m.name === migration.name);
|
|
25
|
+
if (!migrationFile) {
|
|
26
|
+
throw new Error(`Migration ${migration.name} not found locally.`);
|
|
27
|
+
}
|
|
28
|
+
const start = Date.now();
|
|
29
|
+
const req = await createLocalReq({}, cms);
|
|
30
|
+
try {
|
|
31
|
+
cms.logger.info({
|
|
32
|
+
msg: `Migrating down: ${migrationFile.name}`
|
|
33
|
+
});
|
|
34
|
+
await initTransaction(req);
|
|
35
|
+
const db = await getTransaction(this, req);
|
|
36
|
+
await migrationFile.down({
|
|
37
|
+
db,
|
|
38
|
+
cms,
|
|
39
|
+
req
|
|
40
|
+
});
|
|
41
|
+
cms.logger.info({
|
|
42
|
+
msg: `Migrated down: ${migrationFile.name} (${Date.now() - start}ms)`
|
|
43
|
+
});
|
|
44
|
+
const tableExists = await migrationTableExists(this, db);
|
|
45
|
+
if (tableExists) {
|
|
46
|
+
await cms.delete({
|
|
47
|
+
id: migration.id,
|
|
48
|
+
collection: 'cms-migrations',
|
|
49
|
+
req
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
await commitTransaction(req);
|
|
53
|
+
} catch (err) {
|
|
54
|
+
await killTransaction(req);
|
|
55
|
+
cms.logger.error({
|
|
56
|
+
err,
|
|
57
|
+
msg: parseError(err, `Error migrating down ${migrationFile.name}. Rolling back.`)
|
|
58
|
+
});
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=migrateDown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/migrateDown.ts"],"sourcesContent":["import {\n commitTransaction,\n createLocalReq,\n getMigrations,\n initTransaction,\n killTransaction,\n readMigrationFiles,\n} from '@hanzo/cms'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { getTransaction } from './utilities/getTransaction.js'\nimport { migrationTableExists } from './utilities/migrationTableExists.js'\nimport { parseError } from './utilities/parseError.js'\n\nexport async function migrateDown(this: DrizzleAdapter): Promise<void> {\n const { cms } = this\n const migrationFiles = await readMigrationFiles({ cms })\n\n const { existingMigrations, latestBatch } = await getMigrations({\n cms,\n })\n\n if (!existingMigrations?.length) {\n cms.logger.info({ msg: 'No migrations to rollback.' })\n return\n }\n\n cms.logger.info({\n msg: `Rolling back batch ${latestBatch} consisting of ${existingMigrations.length} migration(s).`,\n })\n\n const latestBatchMigrations = existingMigrations.filter(({ batch }) => batch === latestBatch)\n\n for (const migration of latestBatchMigrations) {\n const migrationFile = migrationFiles.find((m) => m.name === migration.name)\n if (!migrationFile) {\n throw new Error(`Migration ${migration.name} not found locally.`)\n }\n\n const start = Date.now()\n const req = await createLocalReq({}, cms)\n\n try {\n cms.logger.info({ msg: `Migrating down: ${migrationFile.name}` })\n await initTransaction(req)\n const db = await getTransaction(this, req)\n await migrationFile.down({ db, cms, req })\n cms.logger.info({\n msg: `Migrated down: ${migrationFile.name} (${Date.now() - start}ms)`,\n })\n\n const tableExists = await migrationTableExists(this, db)\n\n if (tableExists) {\n await cms.delete({\n id: migration.id,\n collection: 'cms-migrations',\n req,\n })\n }\n\n await commitTransaction(req)\n } catch (err: unknown) {\n await killTransaction(req)\n\n cms.logger.error({\n err,\n msg: parseError(err, `Error migrating down ${migrationFile.name}. Rolling back.`),\n })\n process.exit(1)\n }\n }\n}\n"],"names":["commitTransaction","createLocalReq","getMigrations","initTransaction","killTransaction","readMigrationFiles","getTransaction","migrationTableExists","parseError","migrateDown","cms","migrationFiles","existingMigrations","latestBatch","length","logger","info","msg","latestBatchMigrations","filter","batch","migration","migrationFile","find","m","name","Error","start","Date","now","req","db","down","tableExists","delete","id","collection","err","error","process","exit"],"mappings":"AAAA,SACEA,iBAAiB,EACjBC,cAAc,EACdC,aAAa,EACbC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QACb,aAAY;AAInB,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,UAAU,QAAQ,4BAA2B;AAEtD,OAAO,eAAeC;IACpB,MAAM,EAAEC,GAAG,EAAE,GAAG,IAAI;IACpB,MAAMC,iBAAiB,MAAMN,mBAAmB;Q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,CAAC;oBACfC,IAAId,UAAUc,EAAE;oBAChBC,YAAY;oBACZN;gBACF;YACF;YAEA,MAAM9B,kBAAkB8B;QAC1B,EAAE,OAAOO,KAAc;YACrB,MAAMjC,gBAAgB0B;YAEtBpB,IAAIK,MAAM,CAACuB,KAAK,CAAC;gBACfD;gBACApB,KAAKT,WAAW6B,KAAK,CAAC,qBAAqB,EAAEf,cAAcG,IAAI,CAAC,eAAe,CAAC;YAClF;YACAc,QAAQC,IAAI,CAAC;QACf;IACF;AACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DrizzleAdapter } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Drop the current database and run all migrate up functions
|
|
4
|
+
*/
|
|
5
|
+
export declare function migrateFresh(this: DrizzleAdapter, { forceAcceptWarning }: {
|
|
6
|
+
forceAcceptWarning?: boolean;
|
|
7
|
+
}): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=migrateFresh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrateFresh.d.ts","sourceRoot":"","sources":["../src/migrateFresh.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD;;GAEG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,cAAc,EACpB,EAAE,kBAA0B,EAAE;;CAAA,GAC7B,OAAO,CAAC,IAAI,CAAC,CAoEf"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { commitTransaction, createLocalReq, initTransaction, killTransaction, readMigrationFiles } from '@hanzo/cms';
|
|
2
|
+
import prompts from 'prompts';
|
|
3
|
+
import { getTransaction } from './utilities/getTransaction.js';
|
|
4
|
+
import { parseError } from './utilities/parseError.js';
|
|
5
|
+
/**
|
|
6
|
+
* Drop the current database and run all migrate up functions
|
|
7
|
+
*/ export async function migrateFresh({ forceAcceptWarning = false }) {
|
|
8
|
+
const { cms } = this;
|
|
9
|
+
if (forceAcceptWarning === false) {
|
|
10
|
+
const { confirm: acceptWarning } = await prompts({
|
|
11
|
+
name: 'confirm',
|
|
12
|
+
type: 'confirm',
|
|
13
|
+
initial: false,
|
|
14
|
+
message: `WARNING: This will drop your database and run all migrations. Are you sure you want to proceed?`
|
|
15
|
+
}, {
|
|
16
|
+
onCancel: ()=>{
|
|
17
|
+
process.exit(0);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
if (!acceptWarning) {
|
|
21
|
+
process.exit(0);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
cms.logger.info({
|
|
25
|
+
msg: `Dropping database.`
|
|
26
|
+
});
|
|
27
|
+
await this.dropDatabase({
|
|
28
|
+
adapter: this
|
|
29
|
+
});
|
|
30
|
+
const migrationFiles = await readMigrationFiles({
|
|
31
|
+
cms
|
|
32
|
+
});
|
|
33
|
+
cms.logger.debug({
|
|
34
|
+
msg: `Found ${migrationFiles.length} migration files.`
|
|
35
|
+
});
|
|
36
|
+
const req = await createLocalReq({}, cms);
|
|
37
|
+
if ('createExtensions' in this && typeof this.createExtensions === 'function') {
|
|
38
|
+
await this.createExtensions();
|
|
39
|
+
}
|
|
40
|
+
// Run all migrate up
|
|
41
|
+
for (const migration of migrationFiles){
|
|
42
|
+
cms.logger.info({
|
|
43
|
+
msg: `Migrating: ${migration.name}`
|
|
44
|
+
});
|
|
45
|
+
try {
|
|
46
|
+
const start = Date.now();
|
|
47
|
+
await initTransaction(req);
|
|
48
|
+
const db = await getTransaction(this, req);
|
|
49
|
+
await migration.up({
|
|
50
|
+
db,
|
|
51
|
+
cms,
|
|
52
|
+
req
|
|
53
|
+
});
|
|
54
|
+
await cms.create({
|
|
55
|
+
collection: 'cms-migrations',
|
|
56
|
+
data: {
|
|
57
|
+
name: migration.name,
|
|
58
|
+
batch: 1
|
|
59
|
+
},
|
|
60
|
+
req
|
|
61
|
+
});
|
|
62
|
+
await commitTransaction(req);
|
|
63
|
+
cms.logger.info({
|
|
64
|
+
msg: `Migrated: ${migration.name} (${Date.now() - start}ms)`
|
|
65
|
+
});
|
|
66
|
+
} catch (err) {
|
|
67
|
+
await killTransaction(req);
|
|
68
|
+
cms.logger.error({
|
|
69
|
+
err,
|
|
70
|
+
msg: parseError(err, `Error running migration ${migration.name}. Rolling back`)
|
|
71
|
+
});
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=migrateFresh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/migrateFresh.ts"],"sourcesContent":["import {\n commitTransaction,\n createLocalReq,\n initTransaction,\n killTransaction,\n readMigrationFiles,\n} from '@hanzo/cms'\nimport prompts from 'prompts'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { getTransaction } from './utilities/getTransaction.js'\nimport { parseError } from './utilities/parseError.js'\n\n/**\n * Drop the current database and run all migrate up functions\n */\nexport async function migrateFresh(\n this: DrizzleAdapter,\n { forceAcceptWarning = false },\n): Promise<void> {\n const { cms } = this\n\n if (forceAcceptWarning === false) {\n const { confirm: acceptWarning } = await prompts(\n {\n name: 'confirm',\n type: 'confirm',\n initial: false,\n message: `WARNING: This will drop your database and run all migrations. Are you sure you want to proceed?`,\n },\n {\n onCancel: () => {\n process.exit(0)\n },\n },\n )\n\n if (!acceptWarning) {\n process.exit(0)\n }\n }\n\n cms.logger.info({\n msg: `Dropping database.`,\n })\n\n await this.dropDatabase({ adapter: this })\n\n const migrationFiles = await readMigrationFiles({ cms })\n cms.logger.debug({\n msg: `Found ${migrationFiles.length} migration files.`,\n })\n\n const req = await createLocalReq({}, cms)\n\n if ('createExtensions' in this && typeof this.createExtensions === 'function') {\n await this.createExtensions()\n }\n\n // Run all migrate up\n for (const migration of migrationFiles) {\n cms.logger.info({ msg: `Migrating: ${migration.name}` })\n try {\n const start = Date.now()\n await initTransaction(req)\n const db = await getTransaction(this, req)\n await migration.up({ db, cms, req })\n await cms.create({\n collection: 'cms-migrations',\n data: {\n name: migration.name,\n batch: 1,\n },\n req,\n })\n await commitTransaction(req)\n\n cms.logger.info({ msg: `Migrated: ${migration.name} (${Date.now() - start}ms)` })\n } catch (err: unknown) {\n await killTransaction(req)\n cms.logger.error({\n err,\n msg: parseError(err, `Error running migration ${migration.name}. Rolling back`),\n })\n process.exit(1)\n }\n }\n}\n"],"names":["commitTransaction","createLocalReq","initTransaction","killTransaction","readMigrationFiles","prompts","getTransaction","parseError","migrateFresh","forceAcceptWarning","cms","confirm","acceptWarning","name","type","initial","message","onCancel","process","exit","logger","info","msg","dropDatabase","adapter","migrationFiles","debug","length","req","createExtensions","migration","start","Date","now","db","up","create","collection","data","batch","err","error"],"mappings":"AAAA,SACEA,iBAAiB,EACjBC,cAAc,EACdC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QACb,aAAY;AACnB,OAAOC,aAAa,UAAS;AAI7B,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,UAAU,QAAQ,4BAA2B;AAEtD;;CAEC,GACD,OAAO,eAAeC,aAEpB,EAAEC,qBAAqB,KAAK,EAAE;IAE9B,MAAM,EAAEC,GAAG,EAAE,GAAG,IAAI;IAEpB,IAAID,uBAAuB,OAAO;QAChC,MAAM,EAAEE,SAASC,aAAa,EAAE,GAAG,MAAMP,QACvC;YACEQ,MAAM;YACNC,MAAM;YACNC,SAAS;YACTC,SAAS,CAAC,+FAA+F,CAAC;QAC5G,GACA;YACEC,UAAU;gBACRC,QAAQC,IAAI,CAAC;YACf;QACF;QAGF,IAAI,CAACP,eAAe;YAClBM,QAAQC,IAAI,CAAC;QACf;IACF;IAEAT,IAAIU,MAAM,CAACC,IAAI,CAAC;QACdC,KAAK,CAAC,kBAAkB,CAAC;IAC3B;IAEA,MAAM,IAAI,CAACC,YAAY,CAAC;QAAEC,SAAS,IAAI;IAAC;IAExC,MAAMC,iBAAiB,MAAMrB,mBAAmB;QAAEM;IAAI;IACtDA,IAAIU,MAA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OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAMhD;;GAEG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,cAAc,iBAwFxD"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { commitTransaction, createLocalReq, getMigrations, initTransaction, killTransaction, readMigrationFiles } from '@hanzo/cms';
|
|
2
|
+
import { getTransaction } from './utilities/getTransaction.js';
|
|
3
|
+
import { migrationTableExists } from './utilities/migrationTableExists.js';
|
|
4
|
+
import { parseError } from './utilities/parseError.js';
|
|
5
|
+
/**
|
|
6
|
+
* Run all migration down functions before running up
|
|
7
|
+
*/ export async function migrateRefresh() {
|
|
8
|
+
const { cms } = this;
|
|
9
|
+
const migrationFiles = await readMigrationFiles({
|
|
10
|
+
cms
|
|
11
|
+
});
|
|
12
|
+
const { existingMigrations, latestBatch } = await getMigrations({
|
|
13
|
+
cms
|
|
14
|
+
});
|
|
15
|
+
if (!existingMigrations?.length) {
|
|
16
|
+
cms.logger.info({
|
|
17
|
+
msg: 'No migrations to rollback.'
|
|
18
|
+
});
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
cms.logger.info({
|
|
22
|
+
msg: `Rolling back batch ${latestBatch} consisting of ${existingMigrations.length} migration(s).`
|
|
23
|
+
});
|
|
24
|
+
const req = await createLocalReq({}, cms);
|
|
25
|
+
// Reverse order of migrations to rollback
|
|
26
|
+
existingMigrations.reverse();
|
|
27
|
+
for (const migration of existingMigrations){
|
|
28
|
+
try {
|
|
29
|
+
const migrationFile = migrationFiles.find((m)=>m.name === migration.name);
|
|
30
|
+
if (!migrationFile) {
|
|
31
|
+
throw new Error(`Migration ${migration.name} not found locally.`);
|
|
32
|
+
}
|
|
33
|
+
cms.logger.info({
|
|
34
|
+
msg: `Migrating down: ${migration.name}`
|
|
35
|
+
});
|
|
36
|
+
const start = Date.now();
|
|
37
|
+
await initTransaction(req);
|
|
38
|
+
const db = await getTransaction(this, req);
|
|
39
|
+
await migrationFile.down({
|
|
40
|
+
db,
|
|
41
|
+
cms,
|
|
42
|
+
req
|
|
43
|
+
});
|
|
44
|
+
cms.logger.info({
|
|
45
|
+
msg: `Migrated down: ${migration.name} (${Date.now() - start}ms)`
|
|
46
|
+
});
|
|
47
|
+
const tableExists = await migrationTableExists(this, db);
|
|
48
|
+
if (tableExists) {
|
|
49
|
+
await cms.delete({
|
|
50
|
+
collection: 'cms-migrations',
|
|
51
|
+
req,
|
|
52
|
+
where: {
|
|
53
|
+
name: {
|
|
54
|
+
equals: migration.name
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
await commitTransaction(req);
|
|
60
|
+
} catch (err) {
|
|
61
|
+
await killTransaction(req);
|
|
62
|
+
cms.logger.error({
|
|
63
|
+
err,
|
|
64
|
+
msg: parseError(err, `Error running migration ${migration.name}. Rolling back.`)
|
|
65
|
+
});
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Run all migrate up
|
|
70
|
+
for (const migration of migrationFiles){
|
|
71
|
+
cms.logger.info({
|
|
72
|
+
msg: `Migrating: ${migration.name}`
|
|
73
|
+
});
|
|
74
|
+
try {
|
|
75
|
+
const start = Date.now();
|
|
76
|
+
await initTransaction(req);
|
|
77
|
+
await migration.up({
|
|
78
|
+
cms,
|
|
79
|
+
req
|
|
80
|
+
});
|
|
81
|
+
await cms.create({
|
|
82
|
+
collection: 'cms-migrations',
|
|
83
|
+
data: {
|
|
84
|
+
name: migration.name,
|
|
85
|
+
executed: true
|
|
86
|
+
},
|
|
87
|
+
req
|
|
88
|
+
});
|
|
89
|
+
await commitTransaction(req);
|
|
90
|
+
cms.logger.info({
|
|
91
|
+
msg: `Migrated: ${migration.name} (${Date.now() - start}ms)`
|
|
92
|
+
});
|
|
93
|
+
} catch (err) {
|
|
94
|
+
await killTransaction(req);
|
|
95
|
+
cms.logger.error({
|
|
96
|
+
err,
|
|
97
|
+
msg: parseError(err, `Error running migration ${migration.name}. Rolling back.`)
|
|
98
|
+
});
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//# sourceMappingURL=migrateRefresh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/migrateRefresh.ts"],"sourcesContent":["import {\n commitTransaction,\n createLocalReq,\n getMigrations,\n initTransaction,\n killTransaction,\n readMigrationFiles,\n} from '@hanzo/cms'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { getTransaction } from './utilities/getTransaction.js'\nimport { migrationTableExists } from './utilities/migrationTableExists.js'\nimport { parseError } from './utilities/parseError.js'\n\n/**\n * Run all migration down functions before running up\n */\nexport async function migrateRefresh(this: DrizzleAdapter) {\n const { cms } = this\n const migrationFiles = await readMigrationFiles({ cms })\n\n const { existingMigrations, latestBatch } = await getMigrations({\n cms,\n })\n\n if (!existingMigrations?.length) {\n cms.logger.info({ msg: 'No migrations to rollback.' })\n return\n }\n\n cms.logger.info({\n msg: `Rolling back batch ${latestBatch} consisting of ${existingMigrations.length} migration(s).`,\n })\n\n const req = await createLocalReq({}, cms)\n\n // Reverse order of migrations to rollback\n existingMigrations.reverse()\n\n for (const migration of existingMigrations) {\n try {\n const migrationFile = migrationFiles.find((m) => m.name === migration.name)\n if (!migrationFile) {\n throw new Error(`Migration ${migration.name} not found locally.`)\n }\n\n cms.logger.info({ msg: `Migrating down: ${migration.name}` })\n const start = Date.now()\n await initTransaction(req)\n const db = await getTransaction(this, req)\n await migrationFile.down({ db, cms, req })\n cms.logger.info({\n msg: `Migrated down: ${migration.name} (${Date.now() - start}ms)`,\n })\n\n const tableExists = await migrationTableExists(this, db)\n if (tableExists) {\n await cms.delete({\n collection: 'cms-migrations',\n req,\n where: {\n name: {\n equals: migration.name,\n },\n },\n })\n }\n await commitTransaction(req)\n } catch (err: unknown) {\n await killTransaction(req)\n cms.logger.error({\n err,\n msg: parseError(err, `Error running migration ${migration.name}. Rolling back.`),\n })\n process.exit(1)\n }\n }\n\n // Run all migrate up\n for (const migration of migrationFiles) {\n cms.logger.info({ msg: `Migrating: ${migration.name}` })\n try {\n const start = Date.now()\n await initTransaction(req)\n await migration.up({ cms, req })\n await cms.create({\n collection: 'cms-migrations',\n data: {\n name: migration.name,\n executed: true,\n },\n req,\n })\n await commitTransaction(req)\n\n cms.logger.info({ msg: `Migrated: ${migration.name} (${Date.now() - start}ms)` })\n } catch (err: unknown) {\n await killTransaction(req)\n cms.logger.error({\n err,\n msg: parseError(err, `Error running migration ${migration.name}. Rolling back.`),\n })\n process.exit(1)\n }\n }\n}\n"],"names":["commitTransaction","createLocalReq","getMigrations","initTransaction","killTransaction","readMigrationFiles","getTransaction","migrationTableExists","parseError","migrateRefresh","cms","migrationFiles","existingMigrations","latestBatch","length","logger","info","msg","req","reverse","migration","migrationFile","find","m","name","Error","start","Date","now","db","down","tableExists","delete","collection","where","equals","err","error","process","exit","up","create","data","executed"],"mappings":"AAAA,SACEA,iBAAiB,EACjBC,cAAc,EACdC,aAAa,EACbC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QACb,aAAY;AAInB,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,UAAU,QAAQ,4BAA2B;AAEtD;;CAEC,GACD,OAAO,eAAeC;IACpB,MAAM,EAAEC,GAAG,EAAE,GAAG,IAAI;IACpB,MAAMC,iBAAiB,MAAMN,mBAAmB;QAAEK;IAAI;IAEtD,MAAM,EAAEE,kBAAkB,EAAEC,WAAW,EAAE,GAAG,MAAMX,cAAc;QAC9DQ;IACF;IAEA,IAAI,CAACE,oBAAoBE,QAAQ;QAC/BJ,IAAIK,MAAM,CAACC,IAAI,CAAC;YAAEC,KAAK;QAA6B;QACpD;IACF;IAEAP,IAAIK,MAAM,CAACC,IAAI,CAAC;QACdC,KAAK,CAAC,mBAAmB,EAAEJ,YAAY,eA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IAAI,CAAC;QACf;IACF;IAEA,qBAAqB;IACrB,KAAK,MAAMnB,aAAaT,eAAgB;QACtCD,IAAIK,MAAM,CAACC,IAAI,CAAC;YAAEC,KAAK,CAAC,WAAW,EAAEG,UAAUI,IAAI,EAAE;QAAC;QACtD,IAAI;YACF,MAAME,QAAQC,KAAKC,GAAG;YACtB,MAAMzB,gBAAgBe;YACtB,MAAME,UAAUoB,EAAE,CAAC;gBAAE9B;gBAAKQ;YAAI;YAC9B,MAAMR,IAAI+B,MAAM,CAAC;gBACfR,YAAY;gBACZS,MAAM;oBACJlB,MAAMJ,UAAUI,IAAI;oBACpBmB,UAAU;gBACZ;gBACAzB;YACF;YACA,MAAMlB,kBAAkBkB;YAExBR,IAAIK,MAAM,CAACC,IAAI,CAAC;gBAAEC,KAAK,CAAC,WAAW,EAAEG,UAAUI,IAAI,CAAC,EAAE,EAAEG,KAAKC,GAAG,KAAKF,MAAM,GAAG,CAAC;YAAC;QAClF,EAAE,OAAOU,KAAc;YACrB,MAAMhC,gBAAgBc;YACtBR,IAAIK,MAAM,CAACsB,KAAK,CAAC;gBACfD;gBACAnB,KAAKT,WAAW4B,KAAK,CAAC,wBAAwB,EAAEhB,UAAUI,IAAI,CAAC,eAAe,CAAC;YACjF;YACAc,QAAQC,IAAI,CAAC;QACf;IACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrateReset.d.ts","sourceRoot":"","sources":["../src/migrateReset.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD;;GAEG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA2EtE"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { commitTransaction, createLocalReq, getMigrations, initTransaction, killTransaction, readMigrationFiles } from '@hanzo/cms';
|
|
2
|
+
import { getTransaction } from './utilities/getTransaction.js';
|
|
3
|
+
import { migrationTableExists } from './utilities/migrationTableExists.js';
|
|
4
|
+
/**
|
|
5
|
+
* Run all migrate down functions
|
|
6
|
+
*/ export async function migrateReset() {
|
|
7
|
+
const { cms } = this;
|
|
8
|
+
const migrationFiles = await readMigrationFiles({
|
|
9
|
+
cms
|
|
10
|
+
});
|
|
11
|
+
const { existingMigrations } = await getMigrations({
|
|
12
|
+
cms
|
|
13
|
+
});
|
|
14
|
+
if (!existingMigrations?.length) {
|
|
15
|
+
cms.logger.info({
|
|
16
|
+
msg: 'No migrations to reset.'
|
|
17
|
+
});
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const req = await createLocalReq({}, cms);
|
|
21
|
+
existingMigrations.reverse();
|
|
22
|
+
// Rollback all migrations in order
|
|
23
|
+
for (const migration of existingMigrations){
|
|
24
|
+
const migrationFile = migrationFiles.find((m)=>m.name === migration.name);
|
|
25
|
+
try {
|
|
26
|
+
if (!migrationFile) {
|
|
27
|
+
throw new Error(`Migration ${migration.name} not found locally.`);
|
|
28
|
+
}
|
|
29
|
+
const start = Date.now();
|
|
30
|
+
cms.logger.info({
|
|
31
|
+
msg: `Migrating down: ${migrationFile.name}`
|
|
32
|
+
});
|
|
33
|
+
await initTransaction(req);
|
|
34
|
+
const db = await getTransaction(this, req);
|
|
35
|
+
await migrationFile.down({
|
|
36
|
+
db,
|
|
37
|
+
cms,
|
|
38
|
+
req
|
|
39
|
+
});
|
|
40
|
+
cms.logger.info({
|
|
41
|
+
msg: `Migrated down: ${migrationFile.name} (${Date.now() - start}ms)`
|
|
42
|
+
});
|
|
43
|
+
const tableExists = await migrationTableExists(this, db);
|
|
44
|
+
if (tableExists) {
|
|
45
|
+
await cms.delete({
|
|
46
|
+
id: migration.id,
|
|
47
|
+
collection: 'cms-migrations',
|
|
48
|
+
req
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
await commitTransaction(req);
|
|
52
|
+
} catch (err) {
|
|
53
|
+
let msg = `Error running migration ${migrationFile.name}.`;
|
|
54
|
+
if (err instanceof Error) {
|
|
55
|
+
msg += ` ${err.message}`;
|
|
56
|
+
}
|
|
57
|
+
await killTransaction(req);
|
|
58
|
+
cms.logger.error({
|
|
59
|
+
err,
|
|
60
|
+
msg
|
|
61
|
+
});
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Delete dev migration
|
|
66
|
+
const tableExists = await migrationTableExists(this);
|
|
67
|
+
if (tableExists) {
|
|
68
|
+
try {
|
|
69
|
+
await cms.delete({
|
|
70
|
+
collection: 'cms-migrations',
|
|
71
|
+
where: {
|
|
72
|
+
batch: {
|
|
73
|
+
equals: -1
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
} catch (err) {
|
|
78
|
+
cms.logger.error({
|
|
79
|
+
err,
|
|
80
|
+
msg: 'Error deleting dev migration'
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=migrateReset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/migrateReset.ts"],"sourcesContent":["import {\n commitTransaction,\n createLocalReq,\n getMigrations,\n initTransaction,\n killTransaction,\n readMigrationFiles,\n} from '@hanzo/cms'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { getTransaction } from './utilities/getTransaction.js'\nimport { migrationTableExists } from './utilities/migrationTableExists.js'\n\n/**\n * Run all migrate down functions\n */\nexport async function migrateReset(this: DrizzleAdapter): Promise<void> {\n const { cms } = this\n const migrationFiles = await readMigrationFiles({ cms })\n\n const { existingMigrations } = await getMigrations({ cms })\n\n if (!existingMigrations?.length) {\n cms.logger.info({ msg: 'No migrations to reset.' })\n return\n }\n\n const req = await createLocalReq({}, cms)\n\n existingMigrations.reverse()\n\n // Rollback all migrations in order\n for (const migration of existingMigrations) {\n const migrationFile = migrationFiles.find((m) => m.name === migration.name)\n try {\n if (!migrationFile) {\n throw new Error(`Migration ${migration.name} not found locally.`)\n }\n\n const start = Date.now()\n cms.logger.info({ msg: `Migrating down: ${migrationFile.name}` })\n await initTransaction(req)\n const db = await getTransaction(this, req)\n await migrationFile.down({ db, cms, req })\n cms.logger.info({\n msg: `Migrated down: ${migrationFile.name} (${Date.now() - start}ms)`,\n })\n\n const tableExists = await migrationTableExists(this, db)\n if (tableExists) {\n await cms.delete({\n id: migration.id,\n collection: 'cms-migrations',\n req,\n })\n }\n\n await commitTransaction(req)\n } catch (err: unknown) {\n let msg = `Error running migration ${migrationFile.name}.`\n\n if (err instanceof Error) {\n msg += ` ${err.message}`\n }\n\n await killTransaction(req)\n cms.logger.error({\n err,\n msg,\n })\n process.exit(1)\n }\n }\n\n // Delete dev migration\n\n const tableExists = await migrationTableExists(this)\n if (tableExists) {\n try {\n await cms.delete({\n collection: 'cms-migrations',\n where: {\n batch: {\n equals: -1,\n },\n },\n })\n } catch (err: unknown) {\n cms.logger.error({ err, msg: 'Error deleting dev migration' })\n }\n }\n}\n"],"names":["commitTransaction","createLocalReq","getMigrations","initTransaction","killTransaction","readMigrationFiles","getTransaction","migrationTableExists","migrateReset","cms","migrationFiles","existingMigrations","length","logger","info","msg","req","reverse","migration","migrationFile","find","m","name","Error","start","Date","now","db","down","tableExists","delete","id","collection","err","message","error","process","exit","where","batch","equals"],"mappings":"AAAA,SACEA,iBAAiB,EACjBC,cAAc,EACdC,aAAa,EACbC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QACb,aAAY;AAInB,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,oBAAoB,QAAQ,sCAAqC;AAE1E;;CAEC,GACD,OAAO,eAAeC;IACpB,MAAM,EAAEC,GAAG,EAAE,GAAG,IAAI;IACpB,MAAMC,iBAAiB,MAAML,mBAAmB;QAAEI;IAAI;IAEtD,MAAM,EAAEE,kBAAkB,EAAE,GAAG,MAAMT,cAAc;QAAEO;IAAI;IAEzD,IAAI,CAACE,oBAAoBC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