@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,661 @@
|
|
|
1
|
+
import { sql } from 'drizzle-orm';
|
|
2
|
+
import { APIError } from '@hanzo/cms';
|
|
3
|
+
import { fieldIsVirtual, fieldShouldBeLocalized } from '@hanzo/cms/shared';
|
|
4
|
+
import toSnakeCase from 'to-snake-case';
|
|
5
|
+
import { isArrayOfRows } from '../../utilities/isArrayOfRows.js';
|
|
6
|
+
import { resolveBlockTableName } from '../../utilities/validateExistingBlockIsIdentical.js';
|
|
7
|
+
import { transformArray } from './array.js';
|
|
8
|
+
import { transformBlocks } from './blocks.js';
|
|
9
|
+
import { transformNumbers } from './numbers.js';
|
|
10
|
+
import { transformRelationship } from './relationships.js';
|
|
11
|
+
import { transformSelects } from './selects.js';
|
|
12
|
+
import { transformTexts } from './texts.js';
|
|
13
|
+
export const traverseFields = ({ adapter, arrays, arraysToPush, baseTableName, blocks, blocksToDelete, columnPrefix, data, enableAtomicWrites, existingLocales, fieldPrefix, fields, forcedLocale, insideArrayOrBlock = false, locales, numbers, numbersToDelete, parentIsLocalized, parentTableName, path, relationships, relationshipsToAppend, relationshipsToDelete, row, selects, texts, textsToDelete, withinArrayOrBlockLocale })=>{
|
|
14
|
+
let fieldsMatched = false;
|
|
15
|
+
if (row._uuid) {
|
|
16
|
+
data._uuid = row._uuid;
|
|
17
|
+
}
|
|
18
|
+
fields.forEach((field)=>{
|
|
19
|
+
let columnName = '';
|
|
20
|
+
let fieldName = '';
|
|
21
|
+
let fieldData;
|
|
22
|
+
if (fieldIsVirtual(field)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
// Mark that we found a matching field
|
|
26
|
+
if (data[field.name] !== undefined) {
|
|
27
|
+
fieldsMatched = true;
|
|
28
|
+
}
|
|
29
|
+
columnName = `${columnPrefix || ''}${toSnakeCase(field.name)}`;
|
|
30
|
+
fieldName = `${fieldPrefix || ''}${field.name}`;
|
|
31
|
+
fieldData = data[field.name];
|
|
32
|
+
const isLocalized = fieldShouldBeLocalized({
|
|
33
|
+
field,
|
|
34
|
+
parentIsLocalized
|
|
35
|
+
});
|
|
36
|
+
if (field.type === 'array') {
|
|
37
|
+
const arrayTableName = adapter.tableNameMap.get(`${parentTableName}_${columnName}`);
|
|
38
|
+
if (isLocalized) {
|
|
39
|
+
const value = data[field.name];
|
|
40
|
+
if (typeof value === 'object' && value !== null) {
|
|
41
|
+
Object.entries(value).forEach(([localeKey, localeValue])=>{
|
|
42
|
+
let localeData = localeValue;
|
|
43
|
+
let push = false;
|
|
44
|
+
if (localeValue && typeof localeValue === 'object' && '$push' in localeValue) {
|
|
45
|
+
localeData = localeValue.$push;
|
|
46
|
+
push = true;
|
|
47
|
+
if (!Array.isArray(localeData)) {
|
|
48
|
+
localeData = [
|
|
49
|
+
localeData
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (Array.isArray(localeData)) {
|
|
54
|
+
const newRows = transformArray({
|
|
55
|
+
adapter,
|
|
56
|
+
arrayTableName,
|
|
57
|
+
baseTableName,
|
|
58
|
+
blocks,
|
|
59
|
+
blocksToDelete,
|
|
60
|
+
data: localeData,
|
|
61
|
+
field,
|
|
62
|
+
locale: localeKey,
|
|
63
|
+
numbers,
|
|
64
|
+
numbersToDelete,
|
|
65
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
66
|
+
path,
|
|
67
|
+
relationships,
|
|
68
|
+
relationshipsToDelete,
|
|
69
|
+
selects,
|
|
70
|
+
texts,
|
|
71
|
+
textsToDelete,
|
|
72
|
+
withinArrayOrBlockLocale: localeKey
|
|
73
|
+
});
|
|
74
|
+
if (push) {
|
|
75
|
+
if (!arraysToPush[arrayTableName]) {
|
|
76
|
+
arraysToPush[arrayTableName] = [];
|
|
77
|
+
}
|
|
78
|
+
arraysToPush[arrayTableName] = arraysToPush[arrayTableName].concat(newRows);
|
|
79
|
+
} else {
|
|
80
|
+
if (!arrays[arrayTableName]) {
|
|
81
|
+
arrays[arrayTableName] = [];
|
|
82
|
+
}
|
|
83
|
+
arrays[arrayTableName] = arrays[arrayTableName].concat(newRows);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
let value = data[field.name];
|
|
90
|
+
let push = false;
|
|
91
|
+
if (typeof value === 'object' && '$push' in value) {
|
|
92
|
+
value = Array.isArray(value.$push) ? value.$push : [
|
|
93
|
+
value.$push
|
|
94
|
+
];
|
|
95
|
+
push = true;
|
|
96
|
+
}
|
|
97
|
+
const newRows = transformArray({
|
|
98
|
+
adapter,
|
|
99
|
+
arrayTableName,
|
|
100
|
+
baseTableName,
|
|
101
|
+
blocks,
|
|
102
|
+
blocksToDelete,
|
|
103
|
+
data: value,
|
|
104
|
+
field,
|
|
105
|
+
numbers,
|
|
106
|
+
numbersToDelete,
|
|
107
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
108
|
+
path,
|
|
109
|
+
relationships,
|
|
110
|
+
relationshipsToDelete,
|
|
111
|
+
selects,
|
|
112
|
+
texts,
|
|
113
|
+
textsToDelete,
|
|
114
|
+
withinArrayOrBlockLocale
|
|
115
|
+
});
|
|
116
|
+
if (push) {
|
|
117
|
+
if (!arraysToPush[arrayTableName]) {
|
|
118
|
+
arraysToPush[arrayTableName] = [];
|
|
119
|
+
}
|
|
120
|
+
arraysToPush[arrayTableName] = arraysToPush[arrayTableName].concat(newRows);
|
|
121
|
+
} else {
|
|
122
|
+
if (!arrays[arrayTableName]) {
|
|
123
|
+
arrays[arrayTableName] = [];
|
|
124
|
+
}
|
|
125
|
+
arrays[arrayTableName] = arrays[arrayTableName].concat(newRows);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (field.type === 'blocks' && !adapter.blocksAsJSON) {
|
|
131
|
+
;
|
|
132
|
+
(field.blockReferences ?? field.blocks).forEach((block)=>{
|
|
133
|
+
const matchedBlock = typeof block === 'string' ? adapter.cms.config.blocks.find((each)=>each.slug === block) : block;
|
|
134
|
+
blocksToDelete.add(resolveBlockTableName(matchedBlock, adapter.tableNameMap.get(`${baseTableName}_blocks_${toSnakeCase(matchedBlock.slug)}`)));
|
|
135
|
+
});
|
|
136
|
+
if (isLocalized) {
|
|
137
|
+
if (typeof data[field.name] === 'object' && data[field.name] !== null) {
|
|
138
|
+
Object.entries(data[field.name]).forEach(([localeKey, localeData])=>{
|
|
139
|
+
if (Array.isArray(localeData)) {
|
|
140
|
+
transformBlocks({
|
|
141
|
+
adapter,
|
|
142
|
+
baseTableName,
|
|
143
|
+
blocks,
|
|
144
|
+
blocksToDelete,
|
|
145
|
+
data: localeData,
|
|
146
|
+
field,
|
|
147
|
+
locale: localeKey,
|
|
148
|
+
numbers,
|
|
149
|
+
numbersToDelete,
|
|
150
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
151
|
+
path,
|
|
152
|
+
relationships,
|
|
153
|
+
relationshipsToDelete,
|
|
154
|
+
selects,
|
|
155
|
+
texts,
|
|
156
|
+
textsToDelete,
|
|
157
|
+
withinArrayOrBlockLocale: localeKey
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
} else if (isArrayOfRows(fieldData)) {
|
|
163
|
+
transformBlocks({
|
|
164
|
+
adapter,
|
|
165
|
+
baseTableName,
|
|
166
|
+
blocks,
|
|
167
|
+
blocksToDelete,
|
|
168
|
+
data: fieldData,
|
|
169
|
+
field,
|
|
170
|
+
numbers,
|
|
171
|
+
numbersToDelete,
|
|
172
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
173
|
+
path,
|
|
174
|
+
relationships,
|
|
175
|
+
relationshipsToDelete,
|
|
176
|
+
selects,
|
|
177
|
+
texts,
|
|
178
|
+
textsToDelete,
|
|
179
|
+
withinArrayOrBlockLocale
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (field.type === 'group' || field.type === 'tab') {
|
|
185
|
+
if (typeof data[field.name] === 'object' && data[field.name] !== null) {
|
|
186
|
+
if (isLocalized) {
|
|
187
|
+
Object.entries(data[field.name]).forEach(([localeKey, localeData])=>{
|
|
188
|
+
// preserve array ID if there is
|
|
189
|
+
localeData._uuid = data.id || data._uuid;
|
|
190
|
+
traverseFields({
|
|
191
|
+
adapter,
|
|
192
|
+
arrays,
|
|
193
|
+
arraysToPush,
|
|
194
|
+
baseTableName,
|
|
195
|
+
blocks,
|
|
196
|
+
blocksToDelete,
|
|
197
|
+
columnPrefix: `${columnName}_`,
|
|
198
|
+
data: localeData,
|
|
199
|
+
enableAtomicWrites,
|
|
200
|
+
existingLocales,
|
|
201
|
+
fieldPrefix: `${fieldName}_`,
|
|
202
|
+
fields: field.flattenedFields,
|
|
203
|
+
forcedLocale: localeKey,
|
|
204
|
+
insideArrayOrBlock,
|
|
205
|
+
locales,
|
|
206
|
+
numbers,
|
|
207
|
+
numbersToDelete,
|
|
208
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
209
|
+
parentTableName,
|
|
210
|
+
path: `${path || ''}${field.name}.`,
|
|
211
|
+
relationships,
|
|
212
|
+
relationshipsToAppend,
|
|
213
|
+
relationshipsToDelete,
|
|
214
|
+
row,
|
|
215
|
+
selects,
|
|
216
|
+
texts,
|
|
217
|
+
textsToDelete,
|
|
218
|
+
withinArrayOrBlockLocale: localeKey
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
} else {
|
|
222
|
+
// preserve array ID if there is
|
|
223
|
+
const groupData = data[field.name];
|
|
224
|
+
groupData._uuid = data.id || data._uuid;
|
|
225
|
+
traverseFields({
|
|
226
|
+
adapter,
|
|
227
|
+
arrays,
|
|
228
|
+
arraysToPush,
|
|
229
|
+
baseTableName,
|
|
230
|
+
blocks,
|
|
231
|
+
blocksToDelete,
|
|
232
|
+
columnPrefix: `${columnName}_`,
|
|
233
|
+
data: groupData,
|
|
234
|
+
enableAtomicWrites,
|
|
235
|
+
existingLocales,
|
|
236
|
+
fieldPrefix: `${fieldName}_`,
|
|
237
|
+
fields: field.flattenedFields,
|
|
238
|
+
forcedLocale,
|
|
239
|
+
insideArrayOrBlock,
|
|
240
|
+
locales,
|
|
241
|
+
numbers,
|
|
242
|
+
numbersToDelete,
|
|
243
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
244
|
+
parentTableName,
|
|
245
|
+
path: `${path || ''}${field.name}.`,
|
|
246
|
+
relationships,
|
|
247
|
+
relationshipsToAppend,
|
|
248
|
+
relationshipsToDelete,
|
|
249
|
+
row,
|
|
250
|
+
selects,
|
|
251
|
+
texts,
|
|
252
|
+
textsToDelete,
|
|
253
|
+
withinArrayOrBlockLocale
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
if (field.type === 'relationship' || field.type === 'upload') {
|
|
260
|
+
const relationshipPath = `${path || ''}${field.name}`;
|
|
261
|
+
// Handle $push operation for relationship fields
|
|
262
|
+
if (fieldData && typeof fieldData === 'object' && 'hasMany' in field && field.hasMany && ('$push' in fieldData || field.localized && Object.values(fieldData).some((localeValue)=>localeValue && typeof localeValue === 'object' && '$push' in localeValue))) {
|
|
263
|
+
let itemsToAppend;
|
|
264
|
+
if (field.localized) {
|
|
265
|
+
let hasLocaleOperations = false;
|
|
266
|
+
Object.entries(fieldData).forEach(([localeKey, localeValue])=>{
|
|
267
|
+
if (localeValue && typeof localeValue === 'object' && '$push' in localeValue) {
|
|
268
|
+
hasLocaleOperations = true;
|
|
269
|
+
const push = localeValue.$push;
|
|
270
|
+
const localeItems = Array.isArray(push) ? push : [
|
|
271
|
+
push
|
|
272
|
+
];
|
|
273
|
+
localeItems.forEach((item)=>{
|
|
274
|
+
const relationshipToAppend = {
|
|
275
|
+
locale: localeKey,
|
|
276
|
+
path: relationshipPath,
|
|
277
|
+
value: item
|
|
278
|
+
};
|
|
279
|
+
// Handle polymorphic relationships
|
|
280
|
+
if (Array.isArray(field.relationTo) && item && typeof item === 'object' && 'relationTo' in item) {
|
|
281
|
+
relationshipToAppend.relationTo = item.relationTo;
|
|
282
|
+
relationshipToAppend.value = item.value;
|
|
283
|
+
} else if (typeof field.relationTo === 'string') {
|
|
284
|
+
// Simple relationship
|
|
285
|
+
relationshipToAppend.relationTo = field.relationTo;
|
|
286
|
+
relationshipToAppend.value = item;
|
|
287
|
+
}
|
|
288
|
+
relationshipsToAppend.push(relationshipToAppend);
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
if (hasLocaleOperations) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
} else {
|
|
296
|
+
// Handle non-localized fields: { field: { $push: data } }
|
|
297
|
+
itemsToAppend = Array.isArray(fieldData.$push) ? fieldData.$push : [
|
|
298
|
+
fieldData.$push
|
|
299
|
+
];
|
|
300
|
+
itemsToAppend.forEach((item)=>{
|
|
301
|
+
const relationshipToAppend = {
|
|
302
|
+
locale: isLocalized ? withinArrayOrBlockLocale : undefined,
|
|
303
|
+
path: relationshipPath,
|
|
304
|
+
value: item
|
|
305
|
+
};
|
|
306
|
+
// Handle polymorphic relationships
|
|
307
|
+
if (Array.isArray(field.relationTo) && item && typeof item === 'object' && 'relationTo' in item && 'value' in item) {
|
|
308
|
+
relationshipToAppend.relationTo = item.relationTo;
|
|
309
|
+
relationshipToAppend.value = item.value;
|
|
310
|
+
} else if (typeof field.relationTo === 'string') {
|
|
311
|
+
// Simple relationship
|
|
312
|
+
relationshipToAppend.relationTo = field.relationTo;
|
|
313
|
+
relationshipToAppend.value = item;
|
|
314
|
+
}
|
|
315
|
+
relationshipsToAppend.push(relationshipToAppend);
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
// Handle $remove operation for relationship fields
|
|
321
|
+
if (fieldData && typeof fieldData === 'object' && 'hasMany' in field && field.hasMany && ('$remove' in fieldData || field.localized && Object.values(fieldData).some((localeValue)=>localeValue && typeof localeValue === 'object' && '$remove' in localeValue))) {
|
|
322
|
+
// Check for new locale-first syntax: { field: { locale: { $remove: data } } }
|
|
323
|
+
if (field.localized) {
|
|
324
|
+
let hasLocaleOperations = false;
|
|
325
|
+
Object.entries(fieldData).forEach(([localeKey, localeValue])=>{
|
|
326
|
+
if (localeValue && typeof localeValue === 'object' && '$remove' in localeValue) {
|
|
327
|
+
hasLocaleOperations = true;
|
|
328
|
+
const remove = localeValue.$remove;
|
|
329
|
+
const localeItems = Array.isArray(remove) ? remove : [
|
|
330
|
+
remove
|
|
331
|
+
];
|
|
332
|
+
localeItems.forEach((item)=>{
|
|
333
|
+
const relationshipToDelete = {
|
|
334
|
+
itemToRemove: item,
|
|
335
|
+
locale: localeKey,
|
|
336
|
+
path: relationshipPath
|
|
337
|
+
};
|
|
338
|
+
// Store relationTo for simple relationships
|
|
339
|
+
if (typeof field.relationTo === 'string') {
|
|
340
|
+
relationshipToDelete.relationTo = field.relationTo;
|
|
341
|
+
}
|
|
342
|
+
relationshipsToDelete.push(relationshipToDelete);
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
if (hasLocaleOperations) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
} else {
|
|
350
|
+
// Handle non-localized fields: { field: { $remove: data } }
|
|
351
|
+
const itemsToRemove = Array.isArray(fieldData.$remove) ? fieldData.$remove : [
|
|
352
|
+
fieldData.$remove
|
|
353
|
+
];
|
|
354
|
+
itemsToRemove.forEach((item)=>{
|
|
355
|
+
const relationshipToDelete = {
|
|
356
|
+
itemToRemove: item,
|
|
357
|
+
locale: isLocalized ? withinArrayOrBlockLocale : undefined,
|
|
358
|
+
path: relationshipPath
|
|
359
|
+
};
|
|
360
|
+
// Store relationTo for simple relationships
|
|
361
|
+
if (typeof field.relationTo === 'string') {
|
|
362
|
+
relationshipToDelete.relationTo = field.relationTo;
|
|
363
|
+
}
|
|
364
|
+
relationshipsToDelete.push(relationshipToDelete);
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
if (isLocalized && (Array.isArray(field.relationTo) || 'hasMany' in field && field.hasMany)) {
|
|
370
|
+
if (typeof fieldData === 'object') {
|
|
371
|
+
Object.entries(fieldData).forEach(([localeKey, localeData])=>{
|
|
372
|
+
if (localeData === null) {
|
|
373
|
+
relationshipsToDelete.push({
|
|
374
|
+
locale: localeKey,
|
|
375
|
+
path: relationshipPath
|
|
376
|
+
});
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
transformRelationship({
|
|
380
|
+
baseRow: {
|
|
381
|
+
locale: localeKey,
|
|
382
|
+
path: relationshipPath
|
|
383
|
+
},
|
|
384
|
+
data: localeData,
|
|
385
|
+
field,
|
|
386
|
+
relationships
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
return;
|
|
391
|
+
} else if (Array.isArray(field.relationTo) || 'hasMany' in field && field.hasMany) {
|
|
392
|
+
if (fieldData === null || Array.isArray(fieldData) && fieldData.length === 0) {
|
|
393
|
+
relationshipsToDelete.push({
|
|
394
|
+
path: relationshipPath
|
|
395
|
+
});
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
transformRelationship({
|
|
399
|
+
baseRow: {
|
|
400
|
+
locale: withinArrayOrBlockLocale,
|
|
401
|
+
path: relationshipPath
|
|
402
|
+
},
|
|
403
|
+
data: fieldData,
|
|
404
|
+
field,
|
|
405
|
+
relationships
|
|
406
|
+
});
|
|
407
|
+
return;
|
|
408
|
+
} else {
|
|
409
|
+
if (!isLocalized && fieldData && typeof fieldData === 'object' && 'id' in fieldData && fieldData?.id) {
|
|
410
|
+
fieldData = fieldData.id;
|
|
411
|
+
} else if (isLocalized) {
|
|
412
|
+
if (typeof fieldData === 'object') {
|
|
413
|
+
Object.entries(fieldData).forEach(([localeKey, localeData])=>{
|
|
414
|
+
if (typeof localeData === 'object') {
|
|
415
|
+
if (localeData && 'id' in localeData && localeData?.id) {
|
|
416
|
+
fieldData[localeKey] = localeData.id;
|
|
417
|
+
}
|
|
418
|
+
} else {
|
|
419
|
+
fieldData[localeKey] = localeData;
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
if (field.type === 'text' && field.hasMany) {
|
|
427
|
+
const textPath = `${path || ''}${field.name}`;
|
|
428
|
+
if (isLocalized) {
|
|
429
|
+
if (typeof fieldData === 'object') {
|
|
430
|
+
Object.entries(fieldData).forEach(([localeKey, localeData])=>{
|
|
431
|
+
if (Array.isArray(localeData)) {
|
|
432
|
+
if (!localeData.length) {
|
|
433
|
+
textsToDelete.push({
|
|
434
|
+
locale: localeKey,
|
|
435
|
+
path: textPath
|
|
436
|
+
});
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
transformTexts({
|
|
440
|
+
baseRow: {
|
|
441
|
+
locale: localeKey,
|
|
442
|
+
path: textPath
|
|
443
|
+
},
|
|
444
|
+
data: localeData,
|
|
445
|
+
texts
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
} else if (Array.isArray(fieldData)) {
|
|
451
|
+
if (!fieldData.length) {
|
|
452
|
+
textsToDelete.push({
|
|
453
|
+
locale: withinArrayOrBlockLocale,
|
|
454
|
+
path: textPath
|
|
455
|
+
});
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
transformTexts({
|
|
459
|
+
baseRow: {
|
|
460
|
+
locale: withinArrayOrBlockLocale,
|
|
461
|
+
path: textPath
|
|
462
|
+
},
|
|
463
|
+
data: fieldData,
|
|
464
|
+
texts
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
if (field.type === 'number' && field.hasMany) {
|
|
470
|
+
const numberPath = `${path || ''}${field.name}`;
|
|
471
|
+
if (isLocalized) {
|
|
472
|
+
if (typeof fieldData === 'object') {
|
|
473
|
+
Object.entries(fieldData).forEach(([localeKey, localeData])=>{
|
|
474
|
+
if (Array.isArray(localeData)) {
|
|
475
|
+
if (!localeData.length) {
|
|
476
|
+
numbersToDelete.push({
|
|
477
|
+
locale: localeKey,
|
|
478
|
+
path: numberPath
|
|
479
|
+
});
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
transformNumbers({
|
|
483
|
+
baseRow: {
|
|
484
|
+
locale: localeKey,
|
|
485
|
+
path: numberPath
|
|
486
|
+
},
|
|
487
|
+
data: localeData,
|
|
488
|
+
numbers
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
} else if (Array.isArray(fieldData)) {
|
|
494
|
+
if (!fieldData.length) {
|
|
495
|
+
numbersToDelete.push({
|
|
496
|
+
locale: withinArrayOrBlockLocale,
|
|
497
|
+
path: numberPath
|
|
498
|
+
});
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
transformNumbers({
|
|
502
|
+
baseRow: {
|
|
503
|
+
locale: withinArrayOrBlockLocale,
|
|
504
|
+
path: numberPath
|
|
505
|
+
},
|
|
506
|
+
data: fieldData,
|
|
507
|
+
numbers
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
if (field.type === 'select' && field.hasMany) {
|
|
513
|
+
const selectTableName = adapter.tableNameMap.get(`${parentTableName}_${columnName}`);
|
|
514
|
+
if (!selects[selectTableName]) {
|
|
515
|
+
selects[selectTableName] = [];
|
|
516
|
+
}
|
|
517
|
+
if (isLocalized) {
|
|
518
|
+
if (typeof data[field.name] === 'object' && data[field.name] !== null) {
|
|
519
|
+
Object.entries(data[field.name]).forEach(([localeKey, localeData])=>{
|
|
520
|
+
if (Array.isArray(localeData)) {
|
|
521
|
+
const newRows = transformSelects({
|
|
522
|
+
id: insideArrayOrBlock ? data._uuid || data.id : undefined,
|
|
523
|
+
data: localeData,
|
|
524
|
+
locale: localeKey
|
|
525
|
+
});
|
|
526
|
+
selects[selectTableName] = selects[selectTableName].concat(newRows);
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
} else if (Array.isArray(data[field.name])) {
|
|
531
|
+
const newRows = transformSelects({
|
|
532
|
+
id: insideArrayOrBlock ? data._uuid || data.id : undefined,
|
|
533
|
+
data: data[field.name],
|
|
534
|
+
locale: withinArrayOrBlockLocale
|
|
535
|
+
});
|
|
536
|
+
selects[selectTableName] = selects[selectTableName].concat(newRows);
|
|
537
|
+
}
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
const valuesToTransform = [];
|
|
541
|
+
if (isLocalized) {
|
|
542
|
+
if (typeof fieldData === 'object' && fieldData !== null) {
|
|
543
|
+
Object.entries(fieldData).forEach(([localeKey, localeData])=>{
|
|
544
|
+
if (!locales[localeKey]) {
|
|
545
|
+
locales[localeKey] = {};
|
|
546
|
+
}
|
|
547
|
+
valuesToTransform.push({
|
|
548
|
+
localeKey,
|
|
549
|
+
ref: locales,
|
|
550
|
+
value: localeData
|
|
551
|
+
});
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
} else {
|
|
555
|
+
let ref = row;
|
|
556
|
+
if (forcedLocale) {
|
|
557
|
+
if (!locales[forcedLocale]) {
|
|
558
|
+
locales[forcedLocale] = {};
|
|
559
|
+
}
|
|
560
|
+
ref = locales[forcedLocale];
|
|
561
|
+
}
|
|
562
|
+
valuesToTransform.push({
|
|
563
|
+
ref,
|
|
564
|
+
value: fieldData
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
valuesToTransform.forEach(({ localeKey, ref, value })=>{
|
|
568
|
+
let formattedValue = value;
|
|
569
|
+
if (field.type === 'date') {
|
|
570
|
+
if (fieldName === 'updatedAt' && formattedValue === null) {
|
|
571
|
+
// If updatedAt is explicitly set to null, skip it entirely - don't add to row
|
|
572
|
+
// This prevents the timestamp from being updated for session-only operations
|
|
573
|
+
return; // Skip this iteration
|
|
574
|
+
} else if (fieldName === 'updatedAt' && typeof formattedValue === 'undefined') {
|
|
575
|
+
// If updatedAt is undefined, set it to current time (normal behavior)
|
|
576
|
+
formattedValue = new Date().toISOString();
|
|
577
|
+
} else {
|
|
578
|
+
if (typeof value === 'number' && !Number.isNaN(value)) {
|
|
579
|
+
formattedValue = new Date(value).toISOString();
|
|
580
|
+
} else if (value instanceof Date) {
|
|
581
|
+
formattedValue = value.toISOString();
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
if (typeof value !== 'undefined') {
|
|
586
|
+
if (value && field.type === 'point' && adapter.name !== 'sqlite') {
|
|
587
|
+
formattedValue = sql`ST_GeomFromGeoJSON(${JSON.stringify(value)})`;
|
|
588
|
+
}
|
|
589
|
+
if (field.type === 'text' && value && typeof value !== 'string') {
|
|
590
|
+
formattedValue = JSON.stringify(value);
|
|
591
|
+
}
|
|
592
|
+
if (field.type === 'number' && value && typeof value === 'object' && '$inc' in value && typeof value.$inc === 'number') {
|
|
593
|
+
if (!enableAtomicWrites) {
|
|
594
|
+
throw new APIError('The passed data must not contain any nested fields for atomic writes');
|
|
595
|
+
}
|
|
596
|
+
formattedValue = sql.raw(`${columnName} + ${value.$inc}`);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
if (typeof formattedValue !== 'undefined') {
|
|
600
|
+
if (localeKey) {
|
|
601
|
+
ref[localeKey][fieldName] = formattedValue;
|
|
602
|
+
} else {
|
|
603
|
+
ref[fieldName] = formattedValue;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
});
|
|
608
|
+
// Handle dot-notation paths when no fields matched
|
|
609
|
+
if (!fieldsMatched) {
|
|
610
|
+
Object.keys(data).forEach((key)=>{
|
|
611
|
+
if (key.includes('.')) {
|
|
612
|
+
// Split on first dot only
|
|
613
|
+
const firstDotIndex = key.indexOf('.');
|
|
614
|
+
const fieldName = key.substring(0, firstDotIndex);
|
|
615
|
+
const remainingPath = key.substring(firstDotIndex + 1);
|
|
616
|
+
// Create nested structure for this field
|
|
617
|
+
if (!data[fieldName]) {
|
|
618
|
+
data[fieldName] = {};
|
|
619
|
+
}
|
|
620
|
+
const nestedData = data[fieldName];
|
|
621
|
+
// Move the value to the nested structure
|
|
622
|
+
nestedData[remainingPath] = data[key];
|
|
623
|
+
delete data[key];
|
|
624
|
+
// Recursively process the newly created nested structure
|
|
625
|
+
// The field traversal will naturally handle it if the field exists in the schema
|
|
626
|
+
traverseFields({
|
|
627
|
+
adapter,
|
|
628
|
+
arrays,
|
|
629
|
+
arraysToPush,
|
|
630
|
+
baseTableName,
|
|
631
|
+
blocks,
|
|
632
|
+
blocksToDelete,
|
|
633
|
+
columnPrefix,
|
|
634
|
+
data,
|
|
635
|
+
enableAtomicWrites,
|
|
636
|
+
existingLocales,
|
|
637
|
+
fieldPrefix,
|
|
638
|
+
fields,
|
|
639
|
+
forcedLocale,
|
|
640
|
+
insideArrayOrBlock,
|
|
641
|
+
locales,
|
|
642
|
+
numbers,
|
|
643
|
+
numbersToDelete,
|
|
644
|
+
parentIsLocalized,
|
|
645
|
+
parentTableName,
|
|
646
|
+
path,
|
|
647
|
+
relationships,
|
|
648
|
+
relationshipsToAppend,
|
|
649
|
+
relationshipsToDelete,
|
|
650
|
+
row,
|
|
651
|
+
selects,
|
|
652
|
+
texts,
|
|
653
|
+
textsToDelete,
|
|
654
|
+
withinArrayOrBlockLocale
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
|
|
661
|
+
//# sourceMappingURL=traverseFields.js.map
|