@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,542 @@
|
|
|
1
|
+
import { fieldIsVirtual, fieldShouldBeLocalized } from '@hanzo/cms/shared';
|
|
2
|
+
import toSnakeCase from 'to-snake-case';
|
|
3
|
+
import { getArrayRelationName } from '../../utilities/getArrayRelationName.js';
|
|
4
|
+
import { resolveBlockTableName } from '../../utilities/validateExistingBlockIsIdentical.js';
|
|
5
|
+
import { transformHasManyNumber } from './hasManyNumber.js';
|
|
6
|
+
import { transformHasManyText } from './hasManyText.js';
|
|
7
|
+
import { transformRelationship } from './relationship.js';
|
|
8
|
+
// Traverse fields recursively, transforming data
|
|
9
|
+
// for each field type into required CMS shape
|
|
10
|
+
export const traverseFields = ({ adapter, blocks, config, currentTableName, dataRef, deletions, fieldPrefix, fields, joinQuery, numbers, parentIsLocalized, path, relationships, table, tablePath, texts, topLevelTableName, withinArrayOrBlockLocale })=>{
|
|
11
|
+
const sanitizedPath = path ? `${path}.` : path;
|
|
12
|
+
const localeCodes = adapter.cms.config.localization && adapter.cms.config.localization.localeCodes;
|
|
13
|
+
const formatted = fields.reduce((result, field)=>{
|
|
14
|
+
if (fieldIsVirtual(field)) {
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
const fieldName = `${fieldPrefix || ''}${field.name}`;
|
|
18
|
+
let fieldData = table[fieldName];
|
|
19
|
+
const localizedFieldData = {};
|
|
20
|
+
const valuesToTransform = [];
|
|
21
|
+
if (fieldPrefix) {
|
|
22
|
+
deletions.push(()=>delete table[fieldName]);
|
|
23
|
+
}
|
|
24
|
+
const isLocalized = fieldShouldBeLocalized({
|
|
25
|
+
field,
|
|
26
|
+
parentIsLocalized
|
|
27
|
+
});
|
|
28
|
+
if (field.type === 'array') {
|
|
29
|
+
const arrayTableName = adapter.tableNameMap.get(`${currentTableName}_${tablePath}${toSnakeCase(field.name)}`);
|
|
30
|
+
fieldData = table[getArrayRelationName({
|
|
31
|
+
field,
|
|
32
|
+
path: fieldName,
|
|
33
|
+
tableName: arrayTableName
|
|
34
|
+
})];
|
|
35
|
+
if (Array.isArray(fieldData)) {
|
|
36
|
+
if (isLocalized) {
|
|
37
|
+
result[field.name] = fieldData.reduce((arrayResult, row)=>{
|
|
38
|
+
if (typeof row._locale === 'string') {
|
|
39
|
+
if (!arrayResult[row._locale]) {
|
|
40
|
+
arrayResult[row._locale] = [];
|
|
41
|
+
}
|
|
42
|
+
const locale = row._locale;
|
|
43
|
+
const data = {};
|
|
44
|
+
delete row._locale;
|
|
45
|
+
if (row._uuid) {
|
|
46
|
+
row.id = row._uuid;
|
|
47
|
+
delete row._uuid;
|
|
48
|
+
}
|
|
49
|
+
const rowResult = traverseFields({
|
|
50
|
+
adapter,
|
|
51
|
+
blocks,
|
|
52
|
+
config,
|
|
53
|
+
currentTableName: arrayTableName,
|
|
54
|
+
dataRef: data,
|
|
55
|
+
deletions,
|
|
56
|
+
fieldPrefix: '',
|
|
57
|
+
fields: field.flattenedFields,
|
|
58
|
+
numbers,
|
|
59
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
60
|
+
path: `${sanitizedPath}${field.name}.${row._order - 1}`,
|
|
61
|
+
relationships,
|
|
62
|
+
table: row,
|
|
63
|
+
tablePath: '',
|
|
64
|
+
texts,
|
|
65
|
+
topLevelTableName,
|
|
66
|
+
withinArrayOrBlockLocale: locale
|
|
67
|
+
});
|
|
68
|
+
if ('_order' in rowResult) {
|
|
69
|
+
delete rowResult._order;
|
|
70
|
+
}
|
|
71
|
+
arrayResult[locale].push(rowResult);
|
|
72
|
+
}
|
|
73
|
+
return arrayResult;
|
|
74
|
+
}, {});
|
|
75
|
+
} else {
|
|
76
|
+
result[field.name] = fieldData.reduce((acc, row, i)=>{
|
|
77
|
+
if (row._uuid) {
|
|
78
|
+
row.id = row._uuid;
|
|
79
|
+
delete row._uuid;
|
|
80
|
+
}
|
|
81
|
+
if ('_order' in row) {
|
|
82
|
+
delete row._order;
|
|
83
|
+
}
|
|
84
|
+
if (!withinArrayOrBlockLocale || withinArrayOrBlockLocale && withinArrayOrBlockLocale === row._locale) {
|
|
85
|
+
if (row._locale) {
|
|
86
|
+
delete row._locale;
|
|
87
|
+
}
|
|
88
|
+
acc.push(traverseFields({
|
|
89
|
+
adapter,
|
|
90
|
+
blocks,
|
|
91
|
+
config,
|
|
92
|
+
currentTableName: arrayTableName,
|
|
93
|
+
dataRef: row,
|
|
94
|
+
deletions,
|
|
95
|
+
fieldPrefix: '',
|
|
96
|
+
fields: field.flattenedFields,
|
|
97
|
+
numbers,
|
|
98
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
99
|
+
path: `${sanitizedPath}${field.name}.${i}`,
|
|
100
|
+
relationships,
|
|
101
|
+
table: row,
|
|
102
|
+
tablePath: '',
|
|
103
|
+
texts,
|
|
104
|
+
topLevelTableName,
|
|
105
|
+
withinArrayOrBlockLocale
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
return acc;
|
|
109
|
+
}, []);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
if (field.type === 'blocks' && !adapter.blocksAsJSON) {
|
|
115
|
+
const blockFieldPath = `${sanitizedPath}${field.name}`;
|
|
116
|
+
const blocksByPath = blocks[blockFieldPath];
|
|
117
|
+
if (Array.isArray(blocksByPath)) {
|
|
118
|
+
if (isLocalized) {
|
|
119
|
+
result[field.name] = {};
|
|
120
|
+
blocksByPath.forEach((row)=>{
|
|
121
|
+
if (row._uuid) {
|
|
122
|
+
row.id = row._uuid;
|
|
123
|
+
delete row._uuid;
|
|
124
|
+
}
|
|
125
|
+
if (typeof row._locale === 'string') {
|
|
126
|
+
if (!result[field.name][row._locale]) {
|
|
127
|
+
result[field.name][row._locale] = [];
|
|
128
|
+
}
|
|
129
|
+
result[field.name][row._locale].push(row);
|
|
130
|
+
delete row._locale;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
Object.entries(result[field.name]).forEach(([locale, localizedBlocks])=>{
|
|
134
|
+
result[field.name][locale] = localizedBlocks.map((row)=>{
|
|
135
|
+
const block = adapter.cms.blocks[row.blockType] ?? (field.blockReferences ?? field.blocks).find((block)=>typeof block !== 'string' && block.slug === row.blockType);
|
|
136
|
+
const tableName = resolveBlockTableName(block, adapter.tableNameMap.get(`${topLevelTableName}_blocks_${toSnakeCase(block.slug)}`));
|
|
137
|
+
if (block) {
|
|
138
|
+
const blockResult = traverseFields({
|
|
139
|
+
adapter,
|
|
140
|
+
blocks,
|
|
141
|
+
config,
|
|
142
|
+
currentTableName: tableName,
|
|
143
|
+
dataRef: row,
|
|
144
|
+
deletions,
|
|
145
|
+
fieldPrefix: '',
|
|
146
|
+
fields: block.flattenedFields,
|
|
147
|
+
numbers,
|
|
148
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
149
|
+
path: `${blockFieldPath}.${row._order - 1}`,
|
|
150
|
+
relationships,
|
|
151
|
+
table: row,
|
|
152
|
+
tablePath: '',
|
|
153
|
+
texts,
|
|
154
|
+
topLevelTableName,
|
|
155
|
+
withinArrayOrBlockLocale: locale
|
|
156
|
+
});
|
|
157
|
+
delete blockResult._order;
|
|
158
|
+
return blockResult;
|
|
159
|
+
}
|
|
160
|
+
return {};
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
} else {
|
|
164
|
+
// Add locale-specific index to have a proper blockFieldPath for current locale
|
|
165
|
+
// because blocks can be in the same array for different locales!
|
|
166
|
+
if (withinArrayOrBlockLocale && config.localization) {
|
|
167
|
+
for (const locale of config.localization.localeCodes){
|
|
168
|
+
let localeIndex = 0;
|
|
169
|
+
for(let i = 0; i < blocksByPath.length; i++){
|
|
170
|
+
const row = blocksByPath[i];
|
|
171
|
+
if (row._locale === locale) {
|
|
172
|
+
row._index = localeIndex;
|
|
173
|
+
localeIndex++;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
result[field.name] = blocksByPath.reduce((acc, row, i)=>{
|
|
179
|
+
delete row._order;
|
|
180
|
+
if (row._uuid) {
|
|
181
|
+
row.id = row._uuid;
|
|
182
|
+
delete row._uuid;
|
|
183
|
+
}
|
|
184
|
+
if (typeof row.blockType !== 'string') {
|
|
185
|
+
return acc;
|
|
186
|
+
}
|
|
187
|
+
const block = adapter.cms.blocks[row.blockType] ?? (field.blockReferences ?? field.blocks).find((block)=>typeof block !== 'string' && block.slug === row.blockType);
|
|
188
|
+
if (block) {
|
|
189
|
+
if (!withinArrayOrBlockLocale || withinArrayOrBlockLocale && withinArrayOrBlockLocale === row._locale) {
|
|
190
|
+
if (row._locale) {
|
|
191
|
+
delete row._locale;
|
|
192
|
+
}
|
|
193
|
+
if (typeof row._index === 'number') {
|
|
194
|
+
i = row._index;
|
|
195
|
+
delete row._index;
|
|
196
|
+
}
|
|
197
|
+
const tableName = resolveBlockTableName(block, adapter.tableNameMap.get(`${topLevelTableName}_blocks_${toSnakeCase(block.slug)}`));
|
|
198
|
+
acc.push(traverseFields({
|
|
199
|
+
adapter,
|
|
200
|
+
blocks,
|
|
201
|
+
config,
|
|
202
|
+
currentTableName: tableName,
|
|
203
|
+
dataRef: row,
|
|
204
|
+
deletions,
|
|
205
|
+
fieldPrefix: '',
|
|
206
|
+
fields: block.flattenedFields,
|
|
207
|
+
numbers,
|
|
208
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
209
|
+
path: `${blockFieldPath}.${i}`,
|
|
210
|
+
relationships,
|
|
211
|
+
table: row,
|
|
212
|
+
tablePath: '',
|
|
213
|
+
texts,
|
|
214
|
+
topLevelTableName,
|
|
215
|
+
withinArrayOrBlockLocale
|
|
216
|
+
}));
|
|
217
|
+
return acc;
|
|
218
|
+
}
|
|
219
|
+
} else {
|
|
220
|
+
acc.push({});
|
|
221
|
+
}
|
|
222
|
+
return acc;
|
|
223
|
+
}, []);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return result;
|
|
227
|
+
}
|
|
228
|
+
if ((field.type === 'relationship' || field.type === 'upload') && (Array.isArray(field.relationTo) || field.hasMany)) {
|
|
229
|
+
const relationPathMatch = relationships[`${sanitizedPath}${field.name}`];
|
|
230
|
+
if (!relationPathMatch) {
|
|
231
|
+
if ('hasMany' in field && field.hasMany) {
|
|
232
|
+
if (isLocalized && config.localization && config.localization.locales) {
|
|
233
|
+
result[field.name] = {
|
|
234
|
+
[config.localization.defaultLocale]: []
|
|
235
|
+
};
|
|
236
|
+
} else {
|
|
237
|
+
result[field.name] = [];
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return result;
|
|
241
|
+
}
|
|
242
|
+
if (isLocalized) {
|
|
243
|
+
result[field.name] = {};
|
|
244
|
+
const relationsByLocale = {};
|
|
245
|
+
relationPathMatch.forEach((row)=>{
|
|
246
|
+
if (typeof row.locale === 'string') {
|
|
247
|
+
if (!relationsByLocale[row.locale]) {
|
|
248
|
+
relationsByLocale[row.locale] = [];
|
|
249
|
+
}
|
|
250
|
+
relationsByLocale[row.locale].push(row);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
Object.entries(relationsByLocale).forEach(([locale, relations])=>{
|
|
254
|
+
transformRelationship({
|
|
255
|
+
field,
|
|
256
|
+
locale,
|
|
257
|
+
ref: result,
|
|
258
|
+
relations
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
} else {
|
|
262
|
+
transformRelationship({
|
|
263
|
+
field,
|
|
264
|
+
ref: result,
|
|
265
|
+
relations: relationPathMatch,
|
|
266
|
+
withinArrayOrBlockLocale
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
return result;
|
|
270
|
+
}
|
|
271
|
+
if (field.type === 'join') {
|
|
272
|
+
const { count, limit = field.defaultLimit ?? 10 } = joinQuery?.[`${fieldPrefix.replaceAll('_', '.')}${field.name}`] || {};
|
|
273
|
+
// raw hasMany results from SQLite
|
|
274
|
+
if (typeof fieldData === 'string') {
|
|
275
|
+
fieldData = JSON.parse(fieldData);
|
|
276
|
+
}
|
|
277
|
+
let fieldResult;
|
|
278
|
+
if (Array.isArray(fieldData)) {
|
|
279
|
+
if (isLocalized && adapter.cms.config.localization) {
|
|
280
|
+
fieldResult = fieldData.reduce((joinResult, row)=>{
|
|
281
|
+
if (typeof row.locale === 'string') {
|
|
282
|
+
joinResult[row.locale].docs.push(row.id);
|
|
283
|
+
}
|
|
284
|
+
return joinResult;
|
|
285
|
+
}, // initialize with defaults so empty won't be undefined
|
|
286
|
+
adapter.cms.config.localization.localeCodes.reduce((acc, code)=>{
|
|
287
|
+
acc[code] = {
|
|
288
|
+
docs: [],
|
|
289
|
+
hasNextPage: false
|
|
290
|
+
};
|
|
291
|
+
return acc;
|
|
292
|
+
}, {}));
|
|
293
|
+
Object.keys(fieldResult).forEach((locale)=>{
|
|
294
|
+
fieldResult[locale].hasNextPage = fieldResult[locale].docs.length > limit;
|
|
295
|
+
fieldResult[locale].docs = fieldResult[locale].docs.slice(0, limit);
|
|
296
|
+
});
|
|
297
|
+
} else {
|
|
298
|
+
const hasNextPage = limit !== 0 && fieldData.length > limit;
|
|
299
|
+
fieldResult = {
|
|
300
|
+
docs: (hasNextPage ? fieldData.slice(0, limit) : fieldData).map(({ id, relationTo })=>{
|
|
301
|
+
if (relationTo) {
|
|
302
|
+
return {
|
|
303
|
+
relationTo,
|
|
304
|
+
value: id
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
return {
|
|
308
|
+
id
|
|
309
|
+
};
|
|
310
|
+
}),
|
|
311
|
+
hasNextPage
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (count) {
|
|
316
|
+
const countPath = `${fieldName}_count`;
|
|
317
|
+
if (typeof table[countPath] !== 'undefined') {
|
|
318
|
+
let value = Number(table[countPath]);
|
|
319
|
+
if (Number.isNaN(value)) {
|
|
320
|
+
value = 0;
|
|
321
|
+
}
|
|
322
|
+
fieldResult.totalDocs = value;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
result[field.name] = fieldResult;
|
|
326
|
+
return result;
|
|
327
|
+
}
|
|
328
|
+
if (field.type === 'text' && field?.hasMany) {
|
|
329
|
+
const textPathMatch = texts[`${sanitizedPath}${field.name}`];
|
|
330
|
+
if (!textPathMatch) {
|
|
331
|
+
result[field.name] = isLocalized && localeCodes ? Object.fromEntries(localeCodes.map((locale)=>[
|
|
332
|
+
locale,
|
|
333
|
+
[]
|
|
334
|
+
])) : [];
|
|
335
|
+
return result;
|
|
336
|
+
}
|
|
337
|
+
if (isLocalized) {
|
|
338
|
+
result[field.name] = {};
|
|
339
|
+
const textsByLocale = {};
|
|
340
|
+
textPathMatch.forEach((row)=>{
|
|
341
|
+
if (typeof row.locale === 'string') {
|
|
342
|
+
if (!textsByLocale[row.locale]) {
|
|
343
|
+
textsByLocale[row.locale] = [];
|
|
344
|
+
}
|
|
345
|
+
textsByLocale[row.locale].push(row);
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
Object.entries(textsByLocale).forEach(([locale, texts])=>{
|
|
349
|
+
transformHasManyText({
|
|
350
|
+
field,
|
|
351
|
+
locale,
|
|
352
|
+
ref: result,
|
|
353
|
+
textRows: texts
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
} else {
|
|
357
|
+
transformHasManyText({
|
|
358
|
+
field,
|
|
359
|
+
ref: result,
|
|
360
|
+
textRows: textPathMatch,
|
|
361
|
+
withinArrayOrBlockLocale
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
return result;
|
|
365
|
+
}
|
|
366
|
+
if (field.type === 'number' && field.hasMany) {
|
|
367
|
+
const numberPathMatch = numbers[`${sanitizedPath}${field.name}`];
|
|
368
|
+
if (!numberPathMatch) {
|
|
369
|
+
result[field.name] = isLocalized && localeCodes ? Object.fromEntries(localeCodes.map((locale)=>[
|
|
370
|
+
locale,
|
|
371
|
+
[]
|
|
372
|
+
])) : [];
|
|
373
|
+
return result;
|
|
374
|
+
}
|
|
375
|
+
if (isLocalized) {
|
|
376
|
+
result[field.name] = {};
|
|
377
|
+
const numbersByLocale = {};
|
|
378
|
+
numberPathMatch.forEach((row)=>{
|
|
379
|
+
if (typeof row.locale === 'string') {
|
|
380
|
+
if (!numbersByLocale[row.locale]) {
|
|
381
|
+
numbersByLocale[row.locale] = [];
|
|
382
|
+
}
|
|
383
|
+
numbersByLocale[row.locale].push(row);
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
Object.entries(numbersByLocale).forEach(([locale, numbers])=>{
|
|
387
|
+
transformHasManyNumber({
|
|
388
|
+
field,
|
|
389
|
+
locale,
|
|
390
|
+
numberRows: numbers,
|
|
391
|
+
ref: result
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
} else {
|
|
395
|
+
transformHasManyNumber({
|
|
396
|
+
field,
|
|
397
|
+
numberRows: numberPathMatch,
|
|
398
|
+
ref: result,
|
|
399
|
+
withinArrayOrBlockLocale
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
return result;
|
|
403
|
+
}
|
|
404
|
+
if (field.type === 'select' && field.hasMany) {
|
|
405
|
+
if (Array.isArray(fieldData)) {
|
|
406
|
+
if (isLocalized) {
|
|
407
|
+
result[field.name] = fieldData.reduce((selectResult, row)=>{
|
|
408
|
+
if (typeof row.locale === 'string') {
|
|
409
|
+
if (!selectResult[row.locale]) {
|
|
410
|
+
selectResult[row.locale] = [];
|
|
411
|
+
}
|
|
412
|
+
selectResult[row.locale].push(row.value);
|
|
413
|
+
}
|
|
414
|
+
return selectResult;
|
|
415
|
+
}, {});
|
|
416
|
+
} else {
|
|
417
|
+
let selectData = fieldData;
|
|
418
|
+
if (withinArrayOrBlockLocale) {
|
|
419
|
+
selectData = selectData.filter(({ locale })=>locale === withinArrayOrBlockLocale);
|
|
420
|
+
}
|
|
421
|
+
result[field.name] = selectData.map(({ value })=>value);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return result;
|
|
425
|
+
}
|
|
426
|
+
if (isLocalized && Array.isArray(table._locales)) {
|
|
427
|
+
if (!table._locales.length && localeCodes) {
|
|
428
|
+
localeCodes.forEach((_locale)=>table._locales.push({
|
|
429
|
+
_locale
|
|
430
|
+
}));
|
|
431
|
+
}
|
|
432
|
+
table._locales.forEach((localeRow)=>{
|
|
433
|
+
valuesToTransform.push({
|
|
434
|
+
ref: localizedFieldData,
|
|
435
|
+
table: {
|
|
436
|
+
...table,
|
|
437
|
+
...localeRow
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
});
|
|
441
|
+
} else {
|
|
442
|
+
valuesToTransform.push({
|
|
443
|
+
ref: result,
|
|
444
|
+
table
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
valuesToTransform.forEach(({ ref, table })=>{
|
|
448
|
+
const fieldData = table[`${fieldPrefix || ''}${field.name}`];
|
|
449
|
+
const locale = table?._locale;
|
|
450
|
+
let val = fieldData;
|
|
451
|
+
switch(field.type){
|
|
452
|
+
case 'date':
|
|
453
|
+
{
|
|
454
|
+
if (typeof fieldData === 'string') {
|
|
455
|
+
val = new Date(fieldData).toISOString();
|
|
456
|
+
}
|
|
457
|
+
break;
|
|
458
|
+
}
|
|
459
|
+
case 'group':
|
|
460
|
+
case 'tab':
|
|
461
|
+
{
|
|
462
|
+
const groupFieldPrefix = `${fieldPrefix || ''}${field.name}_`;
|
|
463
|
+
const groupData = {};
|
|
464
|
+
const locale = table._locale;
|
|
465
|
+
const refKey = isLocalized && locale ? locale : field.name;
|
|
466
|
+
if (isLocalized && locale) {
|
|
467
|
+
delete table._locale;
|
|
468
|
+
}
|
|
469
|
+
ref[refKey] = traverseFields({
|
|
470
|
+
adapter,
|
|
471
|
+
blocks,
|
|
472
|
+
config,
|
|
473
|
+
currentTableName,
|
|
474
|
+
dataRef: groupData,
|
|
475
|
+
deletions,
|
|
476
|
+
fieldPrefix: groupFieldPrefix,
|
|
477
|
+
fields: field.flattenedFields,
|
|
478
|
+
joinQuery,
|
|
479
|
+
numbers,
|
|
480
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
481
|
+
path: `${sanitizedPath}${field.name}`,
|
|
482
|
+
relationships,
|
|
483
|
+
table,
|
|
484
|
+
tablePath: `${tablePath}${toSnakeCase(field.name)}_`,
|
|
485
|
+
texts,
|
|
486
|
+
topLevelTableName,
|
|
487
|
+
withinArrayOrBlockLocale: locale || withinArrayOrBlockLocale
|
|
488
|
+
});
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
case 'number':
|
|
492
|
+
{
|
|
493
|
+
if (typeof fieldData === 'string') {
|
|
494
|
+
val = Number.parseFloat(fieldData);
|
|
495
|
+
}
|
|
496
|
+
break;
|
|
497
|
+
}
|
|
498
|
+
case 'point':
|
|
499
|
+
{
|
|
500
|
+
if (typeof fieldData === 'string') {
|
|
501
|
+
val = JSON.parse(fieldData);
|
|
502
|
+
}
|
|
503
|
+
break;
|
|
504
|
+
}
|
|
505
|
+
case 'relationship':
|
|
506
|
+
case 'upload':
|
|
507
|
+
{
|
|
508
|
+
if (val && typeof field.relationTo === 'string' && adapter.cms.collections[field.relationTo].customIDType === 'number') {
|
|
509
|
+
val = Number(val);
|
|
510
|
+
}
|
|
511
|
+
break;
|
|
512
|
+
}
|
|
513
|
+
case 'text':
|
|
514
|
+
{
|
|
515
|
+
if (typeof fieldData === 'string') {
|
|
516
|
+
val = String(fieldData);
|
|
517
|
+
}
|
|
518
|
+
break;
|
|
519
|
+
}
|
|
520
|
+
default:
|
|
521
|
+
{
|
|
522
|
+
break;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
if (typeof locale === 'string') {
|
|
526
|
+
ref[locale] = val;
|
|
527
|
+
} else {
|
|
528
|
+
result[field.name] = val;
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
if (Object.keys(localizedFieldData).length > 0) {
|
|
532
|
+
result[field.name] = localizedFieldData;
|
|
533
|
+
}
|
|
534
|
+
return result;
|
|
535
|
+
}, dataRef);
|
|
536
|
+
if (Array.isArray(table._locales)) {
|
|
537
|
+
deletions.push(()=>delete table._locales);
|
|
538
|
+
}
|
|
539
|
+
return formatted;
|
|
540
|
+
};
|
|
541
|
+
|
|
542
|
+
//# sourceMappingURL=traverseFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transform/read/traverseFields.ts"],"sourcesContent":["import type { FlattenedBlock, FlattenedField, JoinQuery, SanitizedConfig } from '@hanzo/cms'\n\nimport { fieldIsVirtual, fieldShouldBeLocalized } from '@hanzo/cms/shared'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from '../../types.js'\nimport type { BlocksMap } from '../../utilities/createBlocksMap.js'\n\nimport { getArrayRelationName } from '../../utilities/getArrayRelationName.js'\nimport { resolveBlockTableName } from '../../utilities/validateExistingBlockIsIdentical.js'\nimport { transformHasManyNumber } from './hasManyNumber.js'\nimport { transformHasManyText } from './hasManyText.js'\nimport { transformRelationship } from './relationship.js'\n\ntype TraverseFieldsArgs = {\n /**\n * The DB adapter\n */\n adapter: DrizzleAdapter\n /**\n * Pre-formatted blocks map\n */\n blocks: BlocksMap\n /**\n * The full CMS config\n */\n config: SanitizedConfig\n currentTableName: string\n /**\n * The data reference to be mutated within this recursive function\n */\n dataRef: Record<string, unknown>\n /**\n * Data that needs to be removed from the result after all fields have populated\n */\n deletions: (() => void)[]\n /**\n * Column prefix can be built up by group and named tab fields\n */\n fieldPrefix: string\n /**\n * An array of CMS fields to traverse\n */\n fields: FlattenedField[]\n /**\n *\n */\n joinQuery?: JoinQuery\n /**\n * All hasMany number fields, as returned by Drizzle, keyed on an object by field path\n */\n numbers: Record<string, Record<string, unknown>[]>\n parentIsLocalized: boolean\n /**\n * The current field path (in dot notation), used to merge in relationships\n */\n path: string\n /**\n * All related documents, as returned by Drizzle, keyed on an object by field path\n */\n relationships: Record<string, Record<string, unknown>[]>\n /**\n * Data structure representing the nearest table from db\n */\n table: Record<string, unknown>\n tablePath: string\n /**\n * All hasMany text fields, as returned by Drizzle, keyed on an object by field path\n */\n texts: Record<string, Record<string, unknown>[]>\n topLevelTableName: string\n /**\n * Set to a locale if this group of fields is within a localized array or block.\n */\n withinArrayOrBlockLocale?: string\n}\n\n// Traverse fields recursively, transforming data\n// for each field type into required CMS shape\nexport const traverseFields = <T extends Record<string, unknown>>({\n adapter,\n blocks,\n config,\n currentTableName,\n dataRef,\n deletions,\n fieldPrefix,\n fields,\n joinQuery,\n numbers,\n parentIsLocalized,\n path,\n relationships,\n table,\n tablePath,\n texts,\n topLevelTableName,\n withinArrayOrBlockLocale,\n}: TraverseFieldsArgs): T => {\n const sanitizedPath = path ? `${path}.` : path\n const localeCodes =\n adapter.cms.config.localization && adapter.cms.config.localization.localeCodes\n\n const formatted = fields.reduce((result, field) => {\n if (fieldIsVirtual(field)) {\n return result\n }\n\n const fieldName = `${fieldPrefix || ''}${field.name}`\n let fieldData = table[fieldName]\n const localizedFieldData = {}\n const valuesToTransform: {\n ref: Record<string, unknown>\n table: Record<string, unknown>\n }[] = []\n\n if (fieldPrefix) {\n deletions.push(() => delete table[fieldName])\n }\n\n const isLocalized = fieldShouldBeLocalized({ field, parentIsLocalized })\n\n if (field.type === 'array') {\n const arrayTableName = adapter.tableNameMap.get(\n `${currentTableName}_${tablePath}${toSnakeCase(field.name)}`,\n )\n\n fieldData = table[getArrayRelationName({ field, path: fieldName, tableName: arrayTableName })]\n\n if (Array.isArray(fieldData)) {\n if (isLocalized) {\n result[field.name] = fieldData.reduce((arrayResult, row) => {\n if (typeof row._locale === 'string') {\n if (!arrayResult[row._locale]) {\n arrayResult[row._locale] = []\n }\n const locale = row._locale\n const data = {}\n delete row._locale\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n\n const rowResult = traverseFields<T>({\n adapter,\n blocks,\n config,\n currentTableName: arrayTableName,\n dataRef: data,\n deletions,\n fieldPrefix: '',\n fields: field.flattenedFields,\n numbers,\n parentIsLocalized: parentIsLocalized || field.localized,\n path: `${sanitizedPath}${field.name}.${row._order - 1}`,\n relationships,\n table: row,\n tablePath: '',\n texts,\n topLevelTableName,\n withinArrayOrBlockLocale: locale,\n })\n\n if ('_order' in rowResult) {\n delete rowResult._order\n }\n\n arrayResult[locale].push(rowResult)\n }\n\n return arrayResult\n }, {})\n } else {\n result[field.name] = fieldData.reduce((acc, row, i) => {\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n\n if ('_order' in row) {\n delete row._order\n }\n\n if (\n !withinArrayOrBlockLocale ||\n (withinArrayOrBlockLocale && withinArrayOrBlockLocale === row._locale)\n ) {\n if (row._locale) {\n delete row._locale\n }\n\n acc.push(\n traverseFields<T>({\n adapter,\n blocks,\n config,\n currentTableName: arrayTableName,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: field.flattenedFields,\n numbers,\n parentIsLocalized: parentIsLocalized || field.localized,\n path: `${sanitizedPath}${field.name}.${i}`,\n relationships,\n table: row,\n tablePath: '',\n texts,\n topLevelTableName,\n withinArrayOrBlockLocale,\n }),\n )\n }\n\n return acc\n }, [])\n }\n }\n\n return result\n }\n\n if (field.type === 'blocks' && !adapter.blocksAsJSON) {\n const blockFieldPath = `${sanitizedPath}${field.name}`\n const blocksByPath = blocks[blockFieldPath]\n\n if (Array.isArray(blocksByPath)) {\n if (isLocalized) {\n result[field.name] = {}\n\n blocksByPath.forEach((row) => {\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n if (typeof row._locale === 'string') {\n if (!result[field.name][row._locale]) {\n result[field.name][row._locale] = []\n }\n result[field.name][row._locale].push(row)\n delete row._locale\n }\n })\n\n Object.entries(result[field.name]).forEach(([locale, localizedBlocks]) => {\n result[field.name][locale] = localizedBlocks.map((row) => {\n const block =\n adapter.cms.blocks[row.blockType] ??\n ((field.blockReferences ?? field.blocks).find(\n (block) => typeof block !== 'string' && block.slug === row.blockType,\n ) as FlattenedBlock | undefined)\n\n const tableName = resolveBlockTableName(\n block,\n adapter.tableNameMap.get(`${topLevelTableName}_blocks_${toSnakeCase(block.slug)}`),\n )\n\n if (block) {\n const blockResult = traverseFields<T>({\n adapter,\n blocks,\n config,\n currentTableName: tableName,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: block.flattenedFields,\n numbers,\n parentIsLocalized: parentIsLocalized || field.localized,\n path: `${blockFieldPath}.${row._order - 1}`,\n relationships,\n table: row,\n tablePath: '',\n texts,\n topLevelTableName,\n withinArrayOrBlockLocale: locale,\n })\n\n delete blockResult._order\n return blockResult\n }\n\n return {}\n })\n })\n } else {\n // Add locale-specific index to have a proper blockFieldPath for current locale\n // because blocks can be in the same array for different locales!\n if (withinArrayOrBlockLocale && config.localization) {\n for (const locale of config.localization.localeCodes) {\n let localeIndex = 0\n\n for (let i = 0; i < blocksByPath.length; i++) {\n const row = blocksByPath[i]\n if (row._locale === locale) {\n row._index = localeIndex\n localeIndex++\n }\n }\n }\n }\n\n result[field.name] = blocksByPath.reduce((acc, row, i) => {\n delete row._order\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n\n if (typeof row.blockType !== 'string') {\n return acc\n }\n\n const block =\n adapter.cms.blocks[row.blockType] ??\n ((field.blockReferences ?? field.blocks).find(\n (block) => typeof block !== 'string' && block.slug === row.blockType,\n ) as FlattenedBlock | undefined)\n\n if (block) {\n if (\n !withinArrayOrBlockLocale ||\n (withinArrayOrBlockLocale && withinArrayOrBlockLocale === row._locale)\n ) {\n if (row._locale) {\n delete row._locale\n }\n if (typeof row._index === 'number') {\n i = row._index\n delete row._index\n }\n\n const tableName = resolveBlockTableName(\n block,\n adapter.tableNameMap.get(\n `${topLevelTableName}_blocks_${toSnakeCase(block.slug)}`,\n ),\n )\n\n acc.push(\n traverseFields<T>({\n adapter,\n blocks,\n config,\n currentTableName: tableName,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: block.flattenedFields,\n numbers,\n parentIsLocalized: parentIsLocalized || field.localized,\n path: `${blockFieldPath}.${i}`,\n relationships,\n table: row,\n tablePath: '',\n texts,\n topLevelTableName,\n withinArrayOrBlockLocale,\n }),\n )\n\n return acc\n }\n } else {\n acc.push({})\n }\n\n return acc\n }, [])\n }\n }\n\n return result\n }\n\n if (\n (field.type === 'relationship' || field.type === 'upload') &&\n (Array.isArray(field.relationTo) || field.hasMany)\n ) {\n const relationPathMatch = relationships[`${sanitizedPath}${field.name}`]\n\n if (!relationPathMatch) {\n if ('hasMany' in field && field.hasMany) {\n if (isLocalized && config.localization && config.localization.locales) {\n result[field.name] = {\n [config.localization.defaultLocale]: [],\n }\n } else {\n result[field.name] = []\n }\n }\n\n return result\n }\n\n if (isLocalized) {\n result[field.name] = {}\n const relationsByLocale: Record<string, Record<string, unknown>[]> = {}\n\n relationPathMatch.forEach((row) => {\n if (typeof row.locale === 'string') {\n if (!relationsByLocale[row.locale]) {\n relationsByLocale[row.locale] = []\n }\n relationsByLocale[row.locale].push(row)\n }\n })\n\n Object.entries(relationsByLocale).forEach(([locale, relations]) => {\n transformRelationship({\n field,\n locale,\n ref: result,\n relations,\n })\n })\n } else {\n transformRelationship({\n field,\n ref: result,\n relations: relationPathMatch,\n withinArrayOrBlockLocale,\n })\n }\n return result\n }\n\n if (field.type === 'join') {\n const { count, limit = field.defaultLimit ?? 10 } =\n joinQuery?.[`${fieldPrefix.replaceAll('_', '.')}${field.name}`] || {}\n\n // raw hasMany results from SQLite\n if (typeof fieldData === 'string') {\n fieldData = JSON.parse(fieldData)\n }\n\n let fieldResult:\n | { docs: unknown[]; hasNextPage: boolean; totalDocs?: number }\n | Record<string, { docs: unknown[]; hasNextPage: boolean; totalDocs?: number }>\n if (Array.isArray(fieldData)) {\n if (isLocalized && adapter.cms.config.localization) {\n fieldResult = fieldData.reduce(\n (joinResult, row) => {\n if (typeof row.locale === 'string') {\n joinResult[row.locale].docs.push(row.id)\n }\n\n return joinResult\n },\n\n // initialize with defaults so empty won't be undefined\n adapter.cms.config.localization.localeCodes.reduce((acc, code) => {\n acc[code] = {\n docs: [],\n hasNextPage: false,\n }\n return acc\n }, {}),\n )\n Object.keys(fieldResult).forEach((locale) => {\n fieldResult[locale].hasNextPage = fieldResult[locale].docs.length > limit\n fieldResult[locale].docs = fieldResult[locale].docs.slice(0, limit)\n })\n } else {\n const hasNextPage = limit !== 0 && fieldData.length > limit\n fieldResult = {\n docs: (hasNextPage ? fieldData.slice(0, limit) : fieldData).map(\n ({ id, relationTo }) => {\n if (relationTo) {\n return { relationTo, value: id }\n }\n return { id }\n },\n ),\n hasNextPage,\n }\n }\n }\n\n if (count) {\n const countPath = `${fieldName}_count`\n if (typeof table[countPath] !== 'undefined') {\n let value = Number(table[countPath])\n if (Number.isNaN(value)) {\n value = 0\n }\n fieldResult.totalDocs = value\n }\n }\n\n result[field.name] = fieldResult\n return result\n }\n\n if (field.type === 'text' && field?.hasMany) {\n const textPathMatch = texts[`${sanitizedPath}${field.name}`]\n if (!textPathMatch) {\n result[field.name] =\n isLocalized && localeCodes\n ? Object.fromEntries(localeCodes.map((locale) => [locale, []]))\n : []\n return result\n }\n\n if (isLocalized) {\n result[field.name] = {}\n const textsByLocale: Record<string, Record<string, unknown>[]> = {}\n\n textPathMatch.forEach((row) => {\n if (typeof row.locale === 'string') {\n if (!textsByLocale[row.locale]) {\n textsByLocale[row.locale] = []\n }\n textsByLocale[row.locale].push(row)\n }\n })\n\n Object.entries(textsByLocale).forEach(([locale, texts]) => {\n transformHasManyText({\n field,\n locale,\n ref: result,\n textRows: texts,\n })\n })\n } else {\n transformHasManyText({\n field,\n ref: result,\n textRows: textPathMatch,\n withinArrayOrBlockLocale,\n })\n }\n\n return result\n }\n\n if (field.type === 'number' && field.hasMany) {\n const numberPathMatch = numbers[`${sanitizedPath}${field.name}`]\n if (!numberPathMatch) {\n result[field.name] =\n isLocalized && localeCodes\n ? Object.fromEntries(localeCodes.map((locale) => [locale, []]))\n : []\n return result\n }\n\n if (isLocalized) {\n result[field.name] = {}\n const numbersByLocale: Record<string, Record<string, unknown>[]> = {}\n\n numberPathMatch.forEach((row) => {\n if (typeof row.locale === 'string') {\n if (!numbersByLocale[row.locale]) {\n numbersByLocale[row.locale] = []\n }\n numbersByLocale[row.locale].push(row)\n }\n })\n\n Object.entries(numbersByLocale).forEach(([locale, numbers]) => {\n transformHasManyNumber({\n field,\n locale,\n numberRows: numbers,\n ref: result,\n })\n })\n } else {\n transformHasManyNumber({\n field,\n numberRows: numberPathMatch,\n ref: result,\n withinArrayOrBlockLocale,\n })\n }\n\n return result\n }\n\n if (field.type === 'select' && field.hasMany) {\n if (Array.isArray(fieldData)) {\n if (isLocalized) {\n result[field.name] = fieldData.reduce((selectResult, row) => {\n if (typeof row.locale === 'string') {\n if (!selectResult[row.locale]) {\n selectResult[row.locale] = []\n }\n selectResult[row.locale].push(row.value)\n }\n\n return selectResult\n }, {})\n } else {\n let selectData = fieldData\n if (withinArrayOrBlockLocale) {\n selectData = selectData.filter(({ locale }) => locale === withinArrayOrBlockLocale)\n }\n result[field.name] = selectData.map(({ value }) => value)\n }\n }\n return result\n }\n\n if (isLocalized && Array.isArray(table._locales)) {\n if (!table._locales.length && localeCodes) {\n localeCodes.forEach((_locale) => (table._locales as unknown[]).push({ _locale }))\n }\n\n table._locales.forEach((localeRow) => {\n valuesToTransform.push({\n ref: localizedFieldData,\n table: {\n ...table,\n ...localeRow,\n },\n })\n })\n } else {\n valuesToTransform.push({ ref: result, table })\n }\n\n valuesToTransform.forEach(({ ref, table }) => {\n const fieldData = table[`${fieldPrefix || ''}${field.name}`]\n const locale = table?._locale\n let val = fieldData\n\n switch (field.type) {\n case 'date': {\n if (typeof fieldData === 'string') {\n val = new Date(fieldData).toISOString()\n }\n\n break\n }\n\n case 'group':\n case 'tab': {\n const groupFieldPrefix = `${fieldPrefix || ''}${field.name}_`\n const groupData = {}\n const locale = table._locale as string\n const refKey = isLocalized && locale ? locale : field.name\n\n if (isLocalized && locale) {\n delete table._locale\n }\n ref[refKey] = traverseFields<Record<string, unknown>>({\n adapter,\n blocks,\n config,\n currentTableName,\n dataRef: groupData as Record<string, unknown>,\n deletions,\n fieldPrefix: groupFieldPrefix,\n fields: field.flattenedFields,\n joinQuery,\n numbers,\n parentIsLocalized: parentIsLocalized || field.localized,\n path: `${sanitizedPath}${field.name}`,\n relationships,\n table,\n tablePath: `${tablePath}${toSnakeCase(field.name)}_`,\n texts,\n topLevelTableName,\n withinArrayOrBlockLocale: locale || withinArrayOrBlockLocale,\n })\n\n return\n }\n\n case 'number': {\n if (typeof fieldData === 'string') {\n val = Number.parseFloat(fieldData)\n }\n\n break\n }\n\n case 'point': {\n if (typeof fieldData === 'string') {\n val = JSON.parse(fieldData)\n }\n\n break\n }\n\n case 'relationship':\n case 'upload': {\n if (\n val &&\n typeof field.relationTo === 'string' &&\n adapter.cms.collections[field.relationTo].customIDType === 'number'\n ) {\n val = Number(val)\n }\n\n break\n }\n case 'text': {\n if (typeof fieldData === 'string') {\n val = String(fieldData)\n }\n\n break\n }\n\n default: {\n break\n }\n }\n if (typeof locale === 'string') {\n ref[locale] = val\n } else {\n result[field.name] = val\n }\n })\n\n if (Object.keys(localizedFieldData).length > 0) {\n result[field.name] = localizedFieldData\n }\n\n return result\n }, dataRef)\n\n if (Array.isArray(table._locales)) {\n deletions.push(() => delete table._locales)\n }\n\n return formatted as T\n}\n"],"names":["fieldIsVirtual","fieldShouldBeLocalized","toSnakeCase","getArrayRelationName","resolveBlockTableName","transformHasManyNumber","transformHasManyText","transformRelationship","traverseFields","adapter","blocks","config","currentTableName","dataRef","deletions","fieldPrefix","fields","joinQuery","numbers","parentIsLocalized","path","relationships","table","tablePath","texts","topLevelTableName","withinArrayOrBlockLocale","sanitizedPath","localeCodes","cms","localization","formatted","reduce","result","field","fieldName","name","fieldData","localizedFieldData","valuesToTransform","push","isLocalized","type","arrayTableName","tableNameMap","get","tableName","Array","isArray","arrayResult","row","_locale","locale","data","_uuid","id","rowResult","flattenedFields","localized","_order","acc","i","blocksAsJSON","blockFieldPath","blocksByPath","forEach","Object","entries","localizedBlocks","map","block","blockType","blockReferences","find","slug","blockResult","localeIndex","length","_index","relationTo","hasMany","relationPathMatch","locales","defaultLocale","relationsByLocale","relations","ref","count","limit","defaultLimit","replaceAll","JSON","parse","fieldResult","joinResult","docs","code","hasNextPage","keys","slice","value","countPath","Number","isNaN","totalDocs","textPathMatch","fromEntries","textsByLocale","textRows","numberPathMatch","numbersByLocale","numberRows","selectResult","selectData","filter","_locales","localeRow","val","Date","toISOString","groupFieldPrefix","groupData","refKey","parseFloat","collections","customIDType","String"],"mappings":"AAEA,SAASA,cAAc,EAAEC,sBAAsB,QAAQ,oBAAmB;AAC1E,OAAOC,iBAAiB,gBAAe;AAKvC,SAASC,oBAAoB,QAAQ,0CAAyC;AAC9E,SAASC,qBAAqB,QAAQ,sDAAqD;AAC3F,SAASC,sBAAsB,QAAQ,qBAAoB;AAC3D,SAASC,oBAAoB,QAAQ,mBAAkB;AACvD,SAASC,qBAAqB,QAAQ,oBAAmB;AAiEzD,iDAAiD;AACjD,8CAA8C;AAC9C,OAAO,MAAMC,iBAAiB,CAAoC,EAChEC,OAAO,EACPC,MAAM,EACNC,MAA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@
|
|
|
1
|
+
import type { FlattenedArrayField } from '@hanzo/cms';
|
|
2
|
+
import type { DrizzleAdapter } from '../../types.js';
|
|
3
|
+
import type { ArrayRowToInsert, BlockRowToInsert, NumberToDelete, RelationshipToDelete, TextToDelete } from './types.js';
|
|
4
|
+
type Args = {
|
|
5
|
+
adapter: DrizzleAdapter;
|
|
6
|
+
arrayTableName: string;
|
|
7
|
+
baseTableName: string;
|
|
8
|
+
blocks: {
|
|
9
|
+
[blockType: string]: BlockRowToInsert[];
|
|
10
|
+
};
|
|
11
|
+
blocksToDelete: Set<string>;
|
|
12
|
+
data: unknown;
|
|
13
|
+
field: FlattenedArrayField;
|
|
14
|
+
locale?: string;
|
|
15
|
+
numbers: Record<string, unknown>[];
|
|
16
|
+
numbersToDelete: NumberToDelete[];
|
|
17
|
+
parentIsLocalized: boolean;
|
|
18
|
+
path: string;
|
|
19
|
+
relationships: Record<string, unknown>[];
|
|
20
|
+
relationshipsToDelete: RelationshipToDelete[];
|
|
21
|
+
selects: {
|
|
22
|
+
[tableName: string]: Record<string, unknown>[];
|
|
23
|
+
};
|
|
24
|
+
texts: Record<string, unknown>[];
|
|
25
|
+
textsToDelete: TextToDelete[];
|
|
26
|
+
/**
|
|
27
|
+
* Set to a locale code if this set of fields is traversed within a
|
|
28
|
+
* localized array or block field
|
|
29
|
+
*/
|
|
30
|
+
withinArrayOrBlockLocale?: string;
|
|
31
|
+
};
|
|
32
|
+
export declare const transformArray: ({ adapter, arrayTableName, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, numbersToDelete, parentIsLocalized, path, relationships, relationshipsToDelete, selects, texts, textsToDelete, withinArrayOrBlockLocale, }: Args) => ArrayRowToInsert[];
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=array.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/transform/write/array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,m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