@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,59 @@
|
|
|
1
|
+
import { v4 as uuid } from 'uuid';
|
|
2
|
+
export const beginTransaction = async function beginTransaction(options) {
|
|
3
|
+
let id;
|
|
4
|
+
try {
|
|
5
|
+
id = uuid();
|
|
6
|
+
let reject;
|
|
7
|
+
let resolve;
|
|
8
|
+
let transaction;
|
|
9
|
+
let transactionReady;
|
|
10
|
+
let transactionFailed;
|
|
11
|
+
// Await initialization here
|
|
12
|
+
// Prevent race conditions where the adapter may be
|
|
13
|
+
// re-initializing, and `this.drizzle` is potentially undefined
|
|
14
|
+
await this.initializing;
|
|
15
|
+
// Drizzle only exposes a transactions API that is sufficient if you
|
|
16
|
+
// can directly pass around the `tx` argument. But our operations are spread
|
|
17
|
+
// over many files and we don't want to pass the `tx` around like that,
|
|
18
|
+
// so instead, we "lift" up the `resolve` and `reject` methods
|
|
19
|
+
// and will call them in our respective transaction methods
|
|
20
|
+
const done = this.drizzle.transaction(async (tx)=>{
|
|
21
|
+
transaction = tx;
|
|
22
|
+
await new Promise((res, rej)=>{
|
|
23
|
+
resolve = ()=>{
|
|
24
|
+
res();
|
|
25
|
+
return done;
|
|
26
|
+
};
|
|
27
|
+
reject = ()=>{
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
|
|
29
|
+
rej();
|
|
30
|
+
return done;
|
|
31
|
+
};
|
|
32
|
+
transactionReady();
|
|
33
|
+
});
|
|
34
|
+
}, options || this.transactionOptions).catch((err)=>{
|
|
35
|
+
// Connection failed before callback ran - reject instead of hanging forever
|
|
36
|
+
transactionFailed(err);
|
|
37
|
+
});
|
|
38
|
+
// Need to wait until the transaction is ready
|
|
39
|
+
// before binding its `resolve` and `reject` methods below
|
|
40
|
+
await new Promise((res, rej)=>{
|
|
41
|
+
transactionReady = res;
|
|
42
|
+
transactionFailed = rej;
|
|
43
|
+
});
|
|
44
|
+
this.sessions[id] = {
|
|
45
|
+
db: transaction,
|
|
46
|
+
reject,
|
|
47
|
+
resolve
|
|
48
|
+
};
|
|
49
|
+
} catch (err) {
|
|
50
|
+
this.cms.logger.error({
|
|
51
|
+
err,
|
|
52
|
+
msg: `Error: cannot begin transaction: ${err.message}`
|
|
53
|
+
});
|
|
54
|
+
throw new Error(`Error: cannot begin transaction: ${err.message}`);
|
|
55
|
+
}
|
|
56
|
+
return id;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=beginTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/transactions/beginTransaction.ts"],"sourcesContent":["import type { BeginTransaction } from '@hanzo/cms'\n\nimport { v4 as uuid } from 'uuid'\n\nimport type { DrizzleAdapter, DrizzleTransaction } from '../types.js'\n\nexport const beginTransaction: BeginTransaction = async function beginTransaction(\n this: DrizzleAdapter,\n options: DrizzleAdapter['transactionOptions'],\n) {\n let id\n try {\n id = uuid()\n\n let reject: () => Promise<void>\n let resolve: () => Promise<void>\n let transaction: DrizzleTransaction\n\n let transactionReady: () => void\n let transactionFailed: (err: unknown) => void\n\n // Await initialization here\n // Prevent race conditions where the adapter may be\n // re-initializing, and `this.drizzle` is potentially undefined\n await this.initializing\n\n // Drizzle only exposes a transactions API that is sufficient if you\n // can directly pass around the `tx` argument. But our operations are spread\n // over many files and we don't want to pass the `tx` around like that,\n // so instead, we \"lift\" up the `resolve` and `reject` methods\n // and will call them in our respective transaction methods\n const done = this.drizzle\n .transaction(async (tx) => {\n transaction = tx\n await new Promise<void>((res, rej) => {\n resolve = () => {\n res()\n return done\n }\n reject = () => {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n rej()\n return done\n }\n transactionReady()\n })\n }, options || this.transactionOptions)\n .catch((err) => {\n // Connection failed before callback ran - reject instead of hanging forever\n transactionFailed(err)\n })\n\n // Need to wait until the transaction is ready\n // before binding its `resolve` and `reject` methods below\n await new Promise<void>((res, rej) => {\n transactionReady = res\n transactionFailed = rej\n })\n\n this.sessions[id] = {\n db: transaction,\n reject,\n resolve,\n }\n } catch (err) {\n this.cms.logger.error({ err, msg: `Error: cannot begin transaction: ${err.message}` })\n throw new Error(`Error: cannot begin transaction: ${err.message}`)\n }\n\n return id\n}\n"],"names":["v4","uuid","beginTransaction","options","id","reject","resolve","transaction","transactionReady","transactionFailed","initializing","done","drizzle","tx","Promise","res","rej","transactionOptions","catch","err","sessions","db","cms","logger","error","msg","message","Error"],"mappings":"AAEA,SAASA,MAAMC,IAAI,QAAQ,OAAM;AAIjC,OAAO,MAAMC,mBAAqC,eAAeA,iBAE/DC,OAA6C;IAE7C,IAAIC;IACJ,IAAI;QACFA,KAAKH;QAEL,IAAII;QACJ,IAAIC;QACJ,IAAIC;QAEJ,IAAIC;QACJ,IAAIC;QAEJ,4BAA4B;QAC5B,mDAAmD;QACnD,+DAA+D;QAC/D,MAAM,IAAI,CAACC,YAAY;QAEvB,oEAAoE;QACpE,4EAA4E;QAC5E,uEAAuE;QACvE,8DAA8D;QAC9D,2DAA2D;QAC3D,MAAMC,OAAO,IAAI,CAACC,OAAO,CACtBL,WAAW,CAAC,OAAOM;YAClBN,cAAcM;YACd,MAAM,IAAIC,QAAc,CAACC,KAAKC;gBAC5BV,UAAU;oBACRS;oBACA,OAAOJ;gBACT;gBACAN,SAAS;oBACP,2EAA2E;oBAC3EW;oBACA,OAAOL;gBACT;gBACAH;YACF;QACF,GAAGL,WAAW,IAAI,CAACc,kBAAkB,EACpCC,KAAK,CAAC,CAACC;YACN,4EAA4E;YAC5EV,kBAAkBU;QACpB;QAEF,8CAA8C;QAC9C,0DAA0D;QAC1D,MAAM,IAAIL,QAAc,CAACC,KAAKC;YAC5BR,mBAAmBO;YACnBN,oBAAoBO;QACtB;QAEA,IAAI,CAACI,QAAQ,CAAChB,GAAG,GAAG;YAClBiB,IAAId;YACJF;YACAC;QACF;IACF,EAAE,OAAOa,KAAK;QACZ,IAAI,CAACG,GAAG,CAACC,MAAM,CAACC,KAAK,CAAC;YAAEL;YAAKM,KAAK,CAAC,iCAAiC,EAAEN,IAAIO,OAAO,EAAE;QAAC;QACpF,MAAM,IAAIC,MAAM,CAAC,iCAAiC,EAAER,IAAIO,OAAO,EAAE;IACnE;IAEA,OAAOtB;AACT,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commitTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/commitTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD,eAAO,MAAM,iBAAiB,EAAE,iBAqB/B,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const commitTransaction = async function commitTransaction(incomingID = '') {
|
|
2
|
+
const transactionID = incomingID instanceof Promise ? await incomingID : incomingID;
|
|
3
|
+
// if the session was deleted it has already been aborted
|
|
4
|
+
if (!this.sessions[transactionID]) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const session = this.sessions[transactionID];
|
|
8
|
+
// Delete from registry FIRST to prevent race conditions
|
|
9
|
+
// This ensures other operations can't retrieve this session while we're ending it
|
|
10
|
+
delete this.sessions[transactionID];
|
|
11
|
+
try {
|
|
12
|
+
await session.resolve();
|
|
13
|
+
} catch (_) {
|
|
14
|
+
await session.reject();
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=commitTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/transactions/commitTransaction.ts"],"sourcesContent":["import type { CommitTransaction } from '@hanzo/cms'\n\nexport const commitTransaction: CommitTransaction = async function commitTransaction(\n incomingID = '',\n) {\n const transactionID = incomingID instanceof Promise ? await incomingID : incomingID\n\n // if the session was deleted it has already been aborted\n if (!this.sessions[transactionID]) {\n return\n }\n\n const session = this.sessions[transactionID]\n\n // Delete from registry FIRST to prevent race conditions\n // This ensures other operations can't retrieve this session while we're ending it\n delete this.sessions[transactionID]\n\n try {\n await session.resolve()\n } catch (_) {\n await session.reject()\n }\n}\n"],"names":["commitTransaction","incomingID","transactionID","Promise","sessions","session","resolve","_","reject"],"mappings":"AAEA,OAAO,MAAMA,oBAAuC,eAAeA,kBACjEC,aAAa,EAAE;IAEf,MAAMC,gBAAgBD,sBAAsBE,UAAU,MAAMF,aAAaA;IAEzE,yDAAyD;IACzD,IAAI,CAAC,IAAI,CAACG,QAAQ,CAACF,cAAc,EAAE;QACjC;IACF;IAEA,MAAMG,UAAU,IAAI,CAACD,QAAQ,CAACF,cAAc;IAE5C,wDAAwD;IACxD,kFAAkF;IAClF,OAAO,IAAI,CAACE,QAAQ,CAACF,cAAc;IAEnC,IAAI;QACF,MAAMG,QAAQC,OAAO;IACvB,EAAE,OAAOC,GAAG;QACV,MAAMF,QAAQG,MAAM;IACtB;AACF,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rollbackTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/rollbackTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAErD,eAAO,MAAM,mBAAmB,EAAE,mBAmBjC,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const rollbackTransaction = async function rollbackTransaction(incomingID = '') {
|
|
2
|
+
const transactionID = incomingID instanceof Promise ? await incomingID : incomingID;
|
|
3
|
+
// if multiple operations are using the same transaction, the first will flow through and delete the session.
|
|
4
|
+
// subsequent calls should be ignored.
|
|
5
|
+
if (!this.sessions[transactionID]) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const session = this.sessions[transactionID];
|
|
9
|
+
// Delete from registry FIRST to prevent race conditions
|
|
10
|
+
// This ensures other operations can't retrieve this session while we're ending it
|
|
11
|
+
delete this.sessions[transactionID];
|
|
12
|
+
// end the session promise in failure by calling reject
|
|
13
|
+
await session.reject();
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=rollbackTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/transactions/rollbackTransaction.ts"],"sourcesContent":["import type { RollbackTransaction } from '@hanzo/cms'\n\nexport const rollbackTransaction: RollbackTransaction = async function rollbackTransaction(\n incomingID = '',\n) {\n const transactionID = incomingID instanceof Promise ? await incomingID : incomingID\n\n // if multiple operations are using the same transaction, the first will flow through and delete the session.\n // subsequent calls should be ignored.\n if (!this.sessions[transactionID]) {\n return\n }\n\n const session = this.sessions[transactionID]\n\n // Delete from registry FIRST to prevent race conditions\n // This ensures other operations can't retrieve this session while we're ending it\n delete this.sessions[transactionID]\n\n // end the session promise in failure by calling reject\n await session.reject()\n}\n"],"names":["rollbackTransaction","incomingID","transactionID","Promise","sessions","session","reject"],"mappings":"AAEA,OAAO,MAAMA,sBAA2C,eAAeA,oBACrEC,aAAa,EAAE;IAEf,MAAMC,gBAAgBD,sBAAsBE,UAAU,MAAMF,aAAaA;IAEzE,6GAA6G;IAC7G,sCAAsC;IACtC,IAAI,CAAC,IAAI,CAACG,QAAQ,CAACF,cAAc,EAAE;QACjC;IACF;IAEA,MAAMG,UAAU,IAAI,CAACD,QAAQ,CAACF,cAAc;IAE5C,wDAAwD;IACxD,kFAAkF;IAClF,OAAO,IAAI,CAACE,QAAQ,CAACF,cAAc;IAEnC,uDAAuD;IACvD,MAAMG,QAAQC,MAAM;AACtB,EAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { NumberField } from '@hanzo/cms';
|
|
2
|
+
type Args = {
|
|
3
|
+
field: NumberField;
|
|
4
|
+
locale?: string;
|
|
5
|
+
numberRows: Record<string, unknown>[];
|
|
6
|
+
ref: Record<string, unknown>;
|
|
7
|
+
withinArrayOrBlockLocale?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const transformHasManyNumber: ({ field, locale, numberRows, ref, withinArrayOrBlockLocale, }: Args) => void;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=hasManyNumber.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hasManyNumber.d.ts","sourceRoot":"","sources":["../../../src/transform/read/hasManyNumber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,WAAW,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IACrC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5B,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAClC,CAAA;AAED,eAAO,MAAM,sBAAsB,kEAMhC,IAAI,SA4BN,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const transformHasManyNumber = ({ field, locale, numberRows, ref, withinArrayOrBlockLocale })=>{
|
|
2
|
+
let result;
|
|
3
|
+
if (withinArrayOrBlockLocale) {
|
|
4
|
+
result = numberRows.reduce((acc, { locale, number })=>{
|
|
5
|
+
if (locale === withinArrayOrBlockLocale) {
|
|
6
|
+
if (typeof number === 'string') {
|
|
7
|
+
number = Number(number);
|
|
8
|
+
}
|
|
9
|
+
acc.push(number);
|
|
10
|
+
}
|
|
11
|
+
return acc;
|
|
12
|
+
}, []);
|
|
13
|
+
} else {
|
|
14
|
+
result = numberRows.map(({ number })=>{
|
|
15
|
+
if (typeof number === 'string') {
|
|
16
|
+
number = Number(number);
|
|
17
|
+
}
|
|
18
|
+
return number;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
if (locale) {
|
|
22
|
+
ref[field.name][locale] = result;
|
|
23
|
+
} else {
|
|
24
|
+
ref[field.name] = result;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=hasManyNumber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transform/read/hasManyNumber.ts"],"sourcesContent":["import type { NumberField } from '@hanzo/cms'\n\ntype Args = {\n field: NumberField\n locale?: string\n numberRows: Record<string, unknown>[]\n ref: Record<string, unknown>\n withinArrayOrBlockLocale?: string\n}\n\nexport const transformHasManyNumber = ({\n field,\n locale,\n numberRows,\n ref,\n withinArrayOrBlockLocale,\n}: Args) => {\n let result: unknown[]\n\n if (withinArrayOrBlockLocale) {\n result = numberRows.reduce((acc, { locale, number }) => {\n if (locale === withinArrayOrBlockLocale) {\n if (typeof number === 'string') {\n number = Number(number)\n }\n acc.push(number)\n }\n\n return acc\n }, [])\n } else {\n result = numberRows.map(({ number }) => {\n if (typeof number === 'string') {\n number = Number(number)\n }\n return number\n })\n }\n\n if (locale) {\n ref[field.name][locale] = result\n } else {\n ref[field.name] = result\n }\n}\n"],"names":["transformHasManyNumber","field","locale","numberRows","ref","withinArrayOrBlockLocale","result","reduce","acc","number","Number","push","map","name"],"mappings":"AAUA,OAAO,MAAMA,yBAAyB,CAAC,EACrCC,KAAK,EACLC,MAAM,EACNC,UAAU,EACVC,GAAG,EACHC,wBAAwB,EACnB;IACL,IAAIC;IAEJ,IAAID,0BAA0B;QAC5BC,SAASH,WAAWI,MAAM,CAAC,CAACC,KAAK,EAAEN,MAAM,EAAEO,MAAM,EAAE;YACjD,IAAIP,WAAWG,0BAA0B;gBACvC,IAAI,OAAOI,WAAW,UAAU;oBAC9BA,SAASC,OAAOD;gBAClB;gBACAD,IAAIG,IAAI,CAACF;YACX;YAEA,OAAOD;QACT,GAAG,EAAE;IACP,OAAO;QACLF,SAASH,WAAWS,GAAG,CAAC,CAAC,EAAEH,MAAM,EAAE;YACjC,IAAI,OAAOA,WAAW,UAAU;gBAC9BA,SAASC,OAAOD;YAClB;YACA,OAAOA;QACT;IACF;IAEA,IAAIP,QAAQ;QACVE,GAAG,CAACH,MAAMY,IAAI,CAAC,CAACX,OAAO,GAAGI;IAC5B,OAAO;QACLF,GAAG,CAACH,MAAMY,IAAI,CAAC,GAAGP;IACpB;AACF,EAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TextField } from '@hanzo/cms';
|
|
2
|
+
type Args = {
|
|
3
|
+
field: TextField;
|
|
4
|
+
locale?: string;
|
|
5
|
+
ref: Record<string, unknown>;
|
|
6
|
+
textRows: Record<string, unknown>[];
|
|
7
|
+
withinArrayOrBlockLocale?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const transformHasManyText: ({ field, locale, ref, textRows, withinArrayOrBlockLocale, }: Args) => void;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=hasManyText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hasManyText.d.ts","sourceRoot":"","sources":["../../../src/transform/read/hasManyText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3C,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,SAAS,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IACnC,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAClC,CAAA;AAED,eAAO,MAAM,oBAAoB,gEAM9B,IAAI,SAoBN,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const transformHasManyText = ({ field, locale, ref, textRows, withinArrayOrBlockLocale })=>{
|
|
2
|
+
let result;
|
|
3
|
+
if (withinArrayOrBlockLocale) {
|
|
4
|
+
result = textRows.reduce((acc, { locale, text })=>{
|
|
5
|
+
if (locale === withinArrayOrBlockLocale) {
|
|
6
|
+
acc.push(text);
|
|
7
|
+
}
|
|
8
|
+
return acc;
|
|
9
|
+
}, []);
|
|
10
|
+
} else {
|
|
11
|
+
result = textRows.map(({ text })=>text);
|
|
12
|
+
}
|
|
13
|
+
if (locale) {
|
|
14
|
+
ref[field.name][locale] = result;
|
|
15
|
+
} else {
|
|
16
|
+
ref[field.name] = result;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=hasManyText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transform/read/hasManyText.ts"],"sourcesContent":["import type { TextField } from '@hanzo/cms'\n\ntype Args = {\n field: TextField\n locale?: string\n ref: Record<string, unknown>\n textRows: Record<string, unknown>[]\n withinArrayOrBlockLocale?: string\n}\n\nexport const transformHasManyText = ({\n field,\n locale,\n ref,\n textRows,\n withinArrayOrBlockLocale,\n}: Args) => {\n let result: unknown[]\n\n if (withinArrayOrBlockLocale) {\n result = textRows.reduce((acc, { locale, text }) => {\n if (locale === withinArrayOrBlockLocale) {\n acc.push(text)\n }\n\n return acc\n }, [])\n } else {\n result = textRows.map(({ text }) => text)\n }\n\n if (locale) {\n ref[field.name][locale] = result\n } else {\n ref[field.name] = result\n }\n}\n"],"names":["transformHasManyText","field","locale","ref","textRows","withinArrayOrBlockLocale","result","reduce","acc","text","push","map","name"],"mappings":"AAUA,OAAO,MAAMA,uBAAuB,CAAC,EACnCC,KAAK,EACLC,MAAM,EACNC,GAAG,EACHC,QAAQ,EACRC,wBAAwB,EACnB;IACL,IAAIC;IAEJ,IAAID,0BAA0B;QAC5BC,SAASF,SAASG,MAAM,CAAC,CAACC,KAAK,EAAEN,MAAM,EAAEO,IAAI,EAAE;YAC7C,IAAIP,WAAWG,0BAA0B;gBACvCG,IAAIE,IAAI,CAACD;YACX;YAEA,OAAOD;QACT,GAAG,EAAE;IACP,OAAO;QACLF,SAASF,SAASO,GAAG,CAAC,CAAC,EAAEF,IAAI,EAAE,GAAKA;IACtC;IAEA,IAAIP,QAAQ;QACVC,GAAG,CAACF,MAAMW,IAAI,CAAC,CAACV,OAAO,GAAGI;IAC5B,OAAO;QACLH,GAAG,CAACF,MAAMW,IAAI,CAAC,GAAGN;IACpB;AACF,EAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FlattenedField, JoinQuery, SanitizedConfig, TypeWithID } from '@hanzo/cms';
|
|
2
|
+
import type { DrizzleAdapter } from '../../types.js';
|
|
3
|
+
type TransformArgs = {
|
|
4
|
+
adapter: DrizzleAdapter;
|
|
5
|
+
config: SanitizedConfig;
|
|
6
|
+
data: Record<string, unknown>;
|
|
7
|
+
fallbackLocale?: false | string;
|
|
8
|
+
fields: FlattenedField[];
|
|
9
|
+
joinQuery?: JoinQuery;
|
|
10
|
+
locale?: string;
|
|
11
|
+
parentIsLocalized?: boolean;
|
|
12
|
+
tableName: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const transform: <T extends Record<string, unknown> | TypeWithID>({ adapter, config, data, fields, joinQuery, parentIsLocalized, tableName, }: TransformArgs) => T;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transform/read/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAExF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAMpD,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,cAAc,CAAA;IACvB,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;IAC/B,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAID,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,+EAQrE,aAAa,KAAG,CAiDlB,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { createBlocksMap } from '../../utilities/createBlocksMap.js';
|
|
2
|
+
import { createPathMap } from '../../utilities/createRelationshipMap.js';
|
|
3
|
+
import { traverseFields } from './traverseFields.js';
|
|
4
|
+
// This is the entry point to transform Drizzle output data
|
|
5
|
+
// into the shape CMS expects based on field schema
|
|
6
|
+
export const transform = ({ adapter, config, data, fields, joinQuery, parentIsLocalized, tableName })=>{
|
|
7
|
+
let relationships = {};
|
|
8
|
+
let texts = {};
|
|
9
|
+
let numbers = {};
|
|
10
|
+
if ('_rels' in data) {
|
|
11
|
+
relationships = createPathMap(data._rels);
|
|
12
|
+
delete data._rels;
|
|
13
|
+
}
|
|
14
|
+
if ('_texts' in data) {
|
|
15
|
+
texts = createPathMap(data._texts);
|
|
16
|
+
delete data._texts;
|
|
17
|
+
}
|
|
18
|
+
if ('_numbers' in data) {
|
|
19
|
+
numbers = createPathMap(data._numbers);
|
|
20
|
+
delete data._numbers;
|
|
21
|
+
}
|
|
22
|
+
const blocks = createBlocksMap(data);
|
|
23
|
+
const deletions = [];
|
|
24
|
+
const result = traverseFields({
|
|
25
|
+
adapter,
|
|
26
|
+
blocks,
|
|
27
|
+
config,
|
|
28
|
+
currentTableName: tableName,
|
|
29
|
+
dataRef: {
|
|
30
|
+
id: data.id
|
|
31
|
+
},
|
|
32
|
+
deletions,
|
|
33
|
+
fieldPrefix: '',
|
|
34
|
+
fields,
|
|
35
|
+
joinQuery,
|
|
36
|
+
numbers,
|
|
37
|
+
parentIsLocalized,
|
|
38
|
+
path: '',
|
|
39
|
+
relationships,
|
|
40
|
+
table: data,
|
|
41
|
+
tablePath: '',
|
|
42
|
+
texts,
|
|
43
|
+
topLevelTableName: tableName
|
|
44
|
+
});
|
|
45
|
+
deletions.forEach((deletion)=>deletion());
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transform/read/index.ts"],"sourcesContent":["import type { FlattenedField, JoinQuery, SanitizedConfig, TypeWithID } from '@hanzo/cms'\n\nimport type { DrizzleAdapter } from '../../types.js'\n\nimport { createBlocksMap } from '../../utilities/createBlocksMap.js'\nimport { createPathMap } from '../../utilities/createRelationshipMap.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype TransformArgs = {\n adapter: DrizzleAdapter\n config: SanitizedConfig\n data: Record<string, unknown>\n fallbackLocale?: false | string\n fields: FlattenedField[]\n joinQuery?: JoinQuery\n locale?: string\n parentIsLocalized?: boolean\n tableName: string\n}\n\n// This is the entry point to transform Drizzle output data\n// into the shape CMS expects based on field schema\nexport const transform = <T extends Record<string, unknown> | TypeWithID>({\n adapter,\n config,\n data,\n fields,\n joinQuery,\n parentIsLocalized,\n tableName,\n}: TransformArgs): T => {\n let relationships: Record<string, Record<string, unknown>[]> = {}\n let texts: Record<string, Record<string, unknown>[]> = {}\n let numbers: Record<string, Record<string, unknown>[]> = {}\n\n if ('_rels' in data) {\n relationships = createPathMap(data._rels)\n delete data._rels\n }\n\n if ('_texts' in data) {\n texts = createPathMap(data._texts)\n delete data._texts\n }\n\n if ('_numbers' in data) {\n numbers = createPathMap(data._numbers)\n delete data._numbers\n }\n\n const blocks = createBlocksMap(data)\n\n const deletions = []\n\n const result = traverseFields<T>({\n adapter,\n blocks,\n config,\n currentTableName: tableName,\n dataRef: {\n id: data.id,\n },\n deletions,\n fieldPrefix: '',\n fields,\n joinQuery,\n numbers,\n parentIsLocalized,\n path: '',\n relationships,\n table: data,\n tablePath: '',\n texts,\n topLevelTableName: tableName,\n })\n\n deletions.forEach((deletion) => deletion())\n\n return result\n}\n"],"names":["createBlocksMap","createPathMap","traverseFields","transform","adapter","config","data","fields","joinQuery","parentIsLocalized","tableName","relationships","texts","numbers","_rels","_texts","_numbers","blocks","deletions","result","currentTableName","dataRef","id","fieldPrefix","path","table","tablePath","topLevelTableName","forEach","deletion"],"mappings":"AAIA,SAASA,eAAe,QAAQ,qCAAoC;AACpE,SAASC,aAAa,QAAQ,2CAA0C;AACxE,SAASC,cAAc,QAAQ,sBAAqB;AAcpD,2DAA2D;AAC3D,mDAAmD;AACnD,OAAO,MAAMC,YAAY,CAAiD,EACxEC,OAAO,EACPC,MAAM,EACNC,IAAI,EACJC,MAAM,EACNC,SAAS,EACTC,iBAAiB,EACjBC,SAAS,EACK;IACd,IAAIC,gBAA2D,CAAC;IAChE,IAAIC,QAAmD,CAAC;IACxD,IAAIC,UAAqD,CAAC;IAE1D,IAAI,WAAWP,MAAM;QACnBK,gBAAgBV,cAAcK,KAAKQ,KAAK;QACxC,OAAOR,KAAKQ,KAAK;IACnB;IAEA,IAAI,YAAYR,MAAM;QACpBM,QAAQX,cAAcK,KAAKS,MAAM;QACjC,OAAOT,KAAKS,MAAM;IACpB;IAEA,IAAI,cAAcT,MAAM;QACtBO,UAAUZ,cAAcK,KAAKU,QAAQ;QACrC,OAAOV,KAAKU,QAAQ;IACtB;IAEA,MAAMC,SAASjB,gBAAgBM;IAE/B,MAAMY,YAAY,EAAE;IAEpB,MAAMC,SAASjB,eAAkB;QAC/BE;QACAa;QACAZ;QACAe,kBAAkBV;QAClBW,SAAS;YACPC,IAAIhB,KAAKgB,EAAE;QACb;QACAJ;QACAK,aAAa;QACbhB;QACAC;QACAK;QACAJ;QACAe,MAAM;QACNb;QACAc,OAAOnB;QACPoB,WAAW;QACXd;QACAe,mBAAmBjB;IACrB;IAEAQ,UAAUU,OAAO,CAAC,CAACC,WAAaA;IAEhC,OAAOV;AACT,EAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RelationshipField, UploadField } from '@hanzo/cms';
|
|
2
|
+
type Args = {
|
|
3
|
+
field: RelationshipField | UploadField;
|
|
4
|
+
locale?: string;
|
|
5
|
+
ref: Record<string, unknown>;
|
|
6
|
+
relations: Record<string, unknown>[];
|
|
7
|
+
withinArrayOrBlockLocale?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const transformRelationship: ({ field, locale, ref, relations, withinArrayOrBlockLocale, }: Args) => void;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=relationship.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relationship.d.ts","sourceRoot":"","sources":["../../../src/transform/read/relationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAEhE,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,iBAAiB,GAAG,WAAW,CAAA;IACtC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IACpC,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAClC,CAAA;AAED,eAAO,MAAM,qBAAqB,iEAM/B,IAAI,SAwEN,CAAA"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export const transformRelationship = ({ field, locale, ref, relations, withinArrayOrBlockLocale })=>{
|
|
2
|
+
let result;
|
|
3
|
+
if (!('hasMany' in field) || field.hasMany === false) {
|
|
4
|
+
let relation = relations[0];
|
|
5
|
+
if (withinArrayOrBlockLocale) {
|
|
6
|
+
relation = relations.find((rel)=>rel.locale === withinArrayOrBlockLocale);
|
|
7
|
+
}
|
|
8
|
+
if (relation) {
|
|
9
|
+
// Handle hasOne Poly
|
|
10
|
+
if (Array.isArray(field.relationTo)) {
|
|
11
|
+
const matchedRelation = Object.entries(relation).find(([key, val])=>{
|
|
12
|
+
return val !== null && ![
|
|
13
|
+
'id',
|
|
14
|
+
'locale',
|
|
15
|
+
'order',
|
|
16
|
+
'parent',
|
|
17
|
+
'path'
|
|
18
|
+
].includes(key);
|
|
19
|
+
});
|
|
20
|
+
if (matchedRelation) {
|
|
21
|
+
const relationTo = matchedRelation[0].replace('ID', '');
|
|
22
|
+
result = {
|
|
23
|
+
relationTo,
|
|
24
|
+
value: matchedRelation[1]
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
const transformedRelations = [];
|
|
31
|
+
relations.forEach((relation)=>{
|
|
32
|
+
let matchedLocale = true;
|
|
33
|
+
if (withinArrayOrBlockLocale) {
|
|
34
|
+
matchedLocale = relation.locale === withinArrayOrBlockLocale;
|
|
35
|
+
}
|
|
36
|
+
// Handle hasMany
|
|
37
|
+
if (!Array.isArray(field.relationTo)) {
|
|
38
|
+
const relatedData = relation[`${field.relationTo}ID`];
|
|
39
|
+
if (relatedData && matchedLocale) {
|
|
40
|
+
transformedRelations.push(relatedData);
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
// Handle hasMany Poly
|
|
44
|
+
const matchedRelation = Object.entries(relation).find(([key, val])=>val !== null && ![
|
|
45
|
+
'id',
|
|
46
|
+
'locale',
|
|
47
|
+
'order',
|
|
48
|
+
'parent',
|
|
49
|
+
'path'
|
|
50
|
+
].includes(key) && matchedLocale);
|
|
51
|
+
if (matchedRelation) {
|
|
52
|
+
const relationTo = matchedRelation[0].replace('ID', '');
|
|
53
|
+
transformedRelations.push({
|
|
54
|
+
relationTo,
|
|
55
|
+
value: matchedRelation[1]
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
result = transformedRelations;
|
|
61
|
+
}
|
|
62
|
+
if (locale) {
|
|
63
|
+
ref[field.name][locale] = result;
|
|
64
|
+
} else {
|
|
65
|
+
ref[field.name] = result;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=relationship.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transform/read/relationship.ts"],"sourcesContent":["import type { RelationshipField, UploadField } from '@hanzo/cms'\n\ntype Args = {\n field: RelationshipField | UploadField\n locale?: string\n ref: Record<string, unknown>\n relations: Record<string, unknown>[]\n withinArrayOrBlockLocale?: string\n}\n\nexport const transformRelationship = ({\n field,\n locale,\n ref,\n relations,\n withinArrayOrBlockLocale,\n}: Args) => {\n let result: unknown\n\n if (!('hasMany' in field) || field.hasMany === false) {\n let relation = relations[0]\n\n if (withinArrayOrBlockLocale) {\n relation = relations.find((rel) => rel.locale === withinArrayOrBlockLocale)\n }\n\n if (relation) {\n // Handle hasOne Poly\n if (Array.isArray(field.relationTo)) {\n const matchedRelation = Object.entries(relation).find(([key, val]) => {\n return val !== null && !['id', 'locale', 'order', 'parent', 'path'].includes(key)\n })\n\n if (matchedRelation) {\n const relationTo = matchedRelation[0].replace('ID', '')\n\n result = {\n relationTo,\n value: matchedRelation[1],\n }\n }\n }\n }\n } else {\n const transformedRelations = []\n\n relations.forEach((relation) => {\n let matchedLocale = true\n\n if (withinArrayOrBlockLocale) {\n matchedLocale = relation.locale === withinArrayOrBlockLocale\n }\n\n // Handle hasMany\n if (!Array.isArray(field.relationTo)) {\n const relatedData = relation[`${field.relationTo}ID`]\n\n if (relatedData && matchedLocale) {\n transformedRelations.push(relatedData)\n }\n } else {\n // Handle hasMany Poly\n const matchedRelation = Object.entries(relation).find(\n ([key, val]) =>\n val !== null &&\n !['id', 'locale', 'order', 'parent', 'path'].includes(key) &&\n matchedLocale,\n )\n\n if (matchedRelation) {\n const relationTo = matchedRelation[0].replace('ID', '')\n\n transformedRelations.push({\n relationTo,\n value: matchedRelation[1],\n })\n }\n }\n })\n\n result = transformedRelations\n }\n\n if (locale) {\n ref[field.name][locale] = result\n } else {\n ref[field.name] = result\n }\n}\n"],"names":["transformRelationship","field","locale","ref","relations","withinArrayOrBlockLocale","result","hasMany","relation","find","rel","Array","isArray","relationTo","matchedRelation","Object","entries","key","val","includes","replace","value","transformedRelations","forEach","matchedLocale","relatedData","push","name"],"mappings":"AAUA,OAAO,MAAMA,wBAAwB,CAAC,EACpCC,KAAK,EACLC,MAAM,EACNC,GAAG,EACHC,SAAS,EACTC,wBAAwB,EACnB;IACL,IAAIC;IAEJ,IAAI,CAAE,CAAA,aAAaL,KAAI,KAAMA,MAAMM,OAAO,KAAK,OAAO;QACpD,IAAIC,WAAWJ,SAAS,CAAC,EAAE;QAE3B,IAAIC,0BAA0B;YAC5BG,WAAWJ,UAAUK,IAAI,CAAC,CAACC,MAAQA,IAAIR,MAAM,KAAKG;QACpD;QAEA,IAAIG,UAAU;YACZ,qBAAqB;YACrB,IAAIG,MAAMC,OAAO,CAACX,MAAMY,UAAU,GAAG;gBACnC,MAAMC,kBAAkBC,OAAOC,OAAO,CAACR,UAAUC,IAAI,CAAC,CAAC,CAACQ,KAAKC,IAAI;oBAC/D,OAAOA,QAAQ,QAAQ,CAAC;wBAAC;wBAAM;wBAAU;wBAAS;wBAAU;qBAAO,CAACC,QAAQ,CAACF;gBAC/E;gBAEA,IAAIH,iBAAiB;oBACnB,MAAMD,aAAaC,eAAe,CAAC,EAAE,CAACM,OAAO,CAAC,MAAM;oBAEpDd,SAAS;wBACPO;wBACAQ,OAAOP,eAAe,CAAC,EAAE;oBAC3B;gBACF;YACF;QACF;IACF,OAAO;QACL,MAAMQ,uBAAuB,EAAE;QAE/BlB,UAAUmB,OAAO,CAAC,CAACf;YACjB,IAAIgB,gBAAgB;YAEpB,IAAInB,0BAA0B;gBAC5BmB,gBAAgBhB,SAASN,MAAM,KAAKG;YACtC;YAEA,iBAAiB;YACjB,IAAI,CAACM,MAAMC,OAAO,CAACX,MAAMY,UAAU,GAAG;gBACpC,MAAMY,cAAcjB,QAAQ,CAAC,GAAGP,MAAMY,UAAU,CAAC,EAAE,CAAC,CAAC;gBAErD,IAAIY,eAAeD,eAAe;oBAChCF,qBAAqBI,IAAI,CAACD;gBAC5B;YACF,OAAO;gBACL,sBAAsB;gBACtB,MAAMX,kBAAkBC,OAAOC,OAAO,CAACR,UAAUC,IAAI,CACnD,CAAC,CAACQ,KAAKC,IAAI,GACTA,QAAQ,QACR,CAAC;wBAAC;wBAAM;wBAAU;wBAAS;wBAAU;qBAAO,CAACC,QAAQ,CAACF,QACtDO;gBAGJ,IAAIV,iBAAiB;oBACnB,MAAMD,aAAaC,eAAe,CAAC,EAAE,CAACM,OAAO,CAAC,MAAM;oBAEpDE,qBAAqBI,IAAI,CAAC;wBACxBb;wBACAQ,OAAOP,eAAe,CAAC,EAAE;oBAC3B;gBACF;YACF;QACF;QAEAR,SAASgB;IACX;IAEA,IAAIpB,QAAQ;QACVC,GAAG,CAACF,MAAM0B,IAAI,CAAC,CAACzB,OAAO,GAAGI;IAC5B,OAAO;QACLH,GAAG,CAACF,MAAM0B,IAAI,CAAC,GAAGrB;IACpB;AACF,EAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { FlattenedField, JoinQuery, SanitizedConfig } from '@hanzo/cms';
|
|
2
|
+
import type { DrizzleAdapter } from '../../types.js';
|
|
3
|
+
import type { BlocksMap } from '../../utilities/createBlocksMap.js';
|
|
4
|
+
type TraverseFieldsArgs = {
|
|
5
|
+
/**
|
|
6
|
+
* The DB adapter
|
|
7
|
+
*/
|
|
8
|
+
adapter: DrizzleAdapter;
|
|
9
|
+
/**
|
|
10
|
+
* Pre-formatted blocks map
|
|
11
|
+
*/
|
|
12
|
+
blocks: BlocksMap;
|
|
13
|
+
/**
|
|
14
|
+
* The full CMS config
|
|
15
|
+
*/
|
|
16
|
+
config: SanitizedConfig;
|
|
17
|
+
currentTableName: string;
|
|
18
|
+
/**
|
|
19
|
+
* The data reference to be mutated within this recursive function
|
|
20
|
+
*/
|
|
21
|
+
dataRef: Record<string, unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* Data that needs to be removed from the result after all fields have populated
|
|
24
|
+
*/
|
|
25
|
+
deletions: (() => void)[];
|
|
26
|
+
/**
|
|
27
|
+
* Column prefix can be built up by group and named tab fields
|
|
28
|
+
*/
|
|
29
|
+
fieldPrefix: string;
|
|
30
|
+
/**
|
|
31
|
+
* An array of CMS fields to traverse
|
|
32
|
+
*/
|
|
33
|
+
fields: FlattenedField[];
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
joinQuery?: JoinQuery;
|
|
38
|
+
/**
|
|
39
|
+
* All hasMany number fields, as returned by Drizzle, keyed on an object by field path
|
|
40
|
+
*/
|
|
41
|
+
numbers: Record<string, Record<string, unknown>[]>;
|
|
42
|
+
parentIsLocalized: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The current field path (in dot notation), used to merge in relationships
|
|
45
|
+
*/
|
|
46
|
+
path: string;
|
|
47
|
+
/**
|
|
48
|
+
* All related documents, as returned by Drizzle, keyed on an object by field path
|
|
49
|
+
*/
|
|
50
|
+
relationships: Record<string, Record<string, unknown>[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Data structure representing the nearest table from db
|
|
53
|
+
*/
|
|
54
|
+
table: Record<string, unknown>;
|
|
55
|
+
tablePath: string;
|
|
56
|
+
/**
|
|
57
|
+
* All hasMany text fields, as returned by Drizzle, keyed on an object by field path
|
|
58
|
+
*/
|
|
59
|
+
texts: Record<string, Record<string, unknown>[]>;
|
|
60
|
+
topLevelTableName: string;
|
|
61
|
+
/**
|
|
62
|
+
* Set to a locale if this group of fields is within a localized array or block.
|
|
63
|
+
*/
|
|
64
|
+
withinArrayOrBlockLocale?: string;
|
|
65
|
+
};
|
|
66
|
+
export declare const traverseFields: <T extends Record<string, unknown>>({ adapter, blocks, config, currentTableName, dataRef, deletions, fieldPrefix, fields, joinQuery, numbers, parentIsLocalized, path, relationships, table, tablePath, texts, topLevelTableName, withinArrayOrBlockLocale, }: TraverseFieldsArgs) => T;
|
|
67
|
+
export {};
|
|
68
|
+
//# sourceMappingURL=traverseFields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../src/transform/read/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,cAAc,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAK5F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAA;AAQnE,KAAK,kBAAkB,GAAG;IACxB;;OAEG;IACH,OAAO,EAAE,cAAc,CAAA;IACvB;;OAEG;IACH,MAAM,EAAE,SAAS,CAAA;IACjB;;OAEG;IACH,MAAM,EAAE,eAAe,CAAA;IACvB,gBAAgB,EAAE,MAAM,CAAA;IACxB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC;;OAEG;IACH,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,CAAA;IACzB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;IAClD,iBAAiB,EAAE,OAAO,CAAA;IAC1B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;IACxD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;IAChD,iBAAiB,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAClC,CAAA;AAID,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,6NAmB7D,kBAAkB,KAAG,CAwnBvB,CAAA"}
|