@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,19 @@
|
|
|
1
|
+
import type { CMSRequest } from '@hanzo/cms';
|
|
2
|
+
import type { DrizzleAdapter } from '../types.js';
|
|
3
|
+
type HandleUpsertErrorArgs = {
|
|
4
|
+
adapter: DrizzleAdapter;
|
|
5
|
+
collectionSlug?: string;
|
|
6
|
+
error: unknown;
|
|
7
|
+
globalSlug?: string;
|
|
8
|
+
id?: number | string;
|
|
9
|
+
req?: Partial<CMSRequest>;
|
|
10
|
+
tableName: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Handles unique constraint violation errors from PostgreSQL and SQLite,
|
|
14
|
+
* converting them to CMS ValidationErrors.
|
|
15
|
+
* Re-throws non-constraint errors unchanged.
|
|
16
|
+
*/
|
|
17
|
+
export declare const handleUpsertError: ({ id, adapter, collectionSlug, error: caughtError, globalSlug, req, tableName, }: HandleUpsertErrorArgs) => never;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=handleUpsertError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleUpsertError.d.ts","sourceRoot":"","sources":["../../src/upsertRow/handleUpsertError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAI5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,KAAK,qBAAqB,GAAG;IAC3B,OAAO,EAAE,cAAc,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,KAAK,EAAE,OAAO,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,GAAG,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAA;IACzB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,qFAQ3B,qBAAqB,KAAG,KAkE1B,CAAA"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ValidationError } from '@hanzo/cms';
|
|
2
|
+
/**
|
|
3
|
+
* Handles unique constraint violation errors from PostgreSQL and SQLite,
|
|
4
|
+
* converting them to CMS ValidationErrors.
|
|
5
|
+
* Re-throws non-constraint errors unchanged.
|
|
6
|
+
*/ export const handleUpsertError = ({ id, adapter, collectionSlug, error: caughtError, globalSlug, req, tableName })=>{
|
|
7
|
+
let error = caughtError;
|
|
8
|
+
if (typeof caughtError === 'object' && caughtError !== null && 'cause' in caughtError) {
|
|
9
|
+
error = caughtError.cause;
|
|
10
|
+
}
|
|
11
|
+
// PostgreSQL: 23505, SQLite: SQLITE_CONSTRAINT_UNIQUE
|
|
12
|
+
if (error?.code === '23505' || error?.code === 'SQLITE_CONSTRAINT_UNIQUE') {
|
|
13
|
+
let fieldName = null;
|
|
14
|
+
if (error.code === '23505') {
|
|
15
|
+
// PostgreSQL - extract field name from constraint
|
|
16
|
+
if (adapter.fieldConstraints?.[tableName]?.[error.constraint]) {
|
|
17
|
+
fieldName = adapter.fieldConstraints[tableName][error.constraint];
|
|
18
|
+
} else {
|
|
19
|
+
const replacement = `${tableName}_`;
|
|
20
|
+
if (error.constraint?.includes(replacement)) {
|
|
21
|
+
const replacedConstraint = error.constraint.replace(replacement, '');
|
|
22
|
+
if (replacedConstraint && adapter.fieldConstraints[tableName]?.[replacedConstraint]) {
|
|
23
|
+
fieldName = adapter.fieldConstraints[tableName][replacedConstraint];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (!fieldName && error.detail) {
|
|
28
|
+
// Extract from detail: "Key (field)=(value) already exists."
|
|
29
|
+
const regex = /Key \(([^)]+)\)=\(([^)]+)\)/;
|
|
30
|
+
const match = error.detail.match(regex);
|
|
31
|
+
if (match && match[1]) {
|
|
32
|
+
fieldName = match[1];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
} else if (error.code === 'SQLITE_CONSTRAINT_UNIQUE') {
|
|
36
|
+
// SQLite - extract from message: "UNIQUE constraint failed: table.field[, table.field2, ...]"
|
|
37
|
+
const regex = /UNIQUE constraint failed: ([^.]+)\.([^.,]+)/;
|
|
38
|
+
const match = error.message?.match(regex);
|
|
39
|
+
if (match && match[2]) {
|
|
40
|
+
if (adapter.fieldConstraints[tableName]) {
|
|
41
|
+
fieldName = adapter.fieldConstraints[tableName][`${match[2]}_idx`];
|
|
42
|
+
}
|
|
43
|
+
if (!fieldName) {
|
|
44
|
+
fieldName = match[2];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
throw new ValidationError({
|
|
49
|
+
id,
|
|
50
|
+
collection: collectionSlug,
|
|
51
|
+
errors: [
|
|
52
|
+
{
|
|
53
|
+
message: req?.t ? req.t('error:valueMustBeUnique') : 'Value must be unique',
|
|
54
|
+
path: fieldName,
|
|
55
|
+
tableName
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
global: globalSlug,
|
|
59
|
+
req
|
|
60
|
+
}, req?.t);
|
|
61
|
+
}
|
|
62
|
+
// Re-throw non-constraint errors
|
|
63
|
+
throw caughtError;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=handleUpsertError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/upsertRow/handleUpsertError.ts"],"sourcesContent":["import type { CMSRequest } from '@hanzo/cms'\n\nimport { ValidationError } from '@hanzo/cms'\n\nimport type { DrizzleAdapter } from '../types.js'\n\ntype HandleUpsertErrorArgs = {\n adapter: DrizzleAdapter\n collectionSlug?: string\n error: unknown\n globalSlug?: string\n id?: number | string\n req?: Partial<CMSRequest>\n tableName: string\n}\n\n/**\n * Handles unique constraint violation errors from PostgreSQL and SQLite,\n * converting them to CMS ValidationErrors.\n * Re-throws non-constraint errors unchanged.\n */\nexport const handleUpsertError = ({\n id,\n adapter,\n collectionSlug,\n error: caughtError,\n globalSlug,\n req,\n tableName,\n}: HandleUpsertErrorArgs): never => {\n let error: any = caughtError\n if (typeof caughtError === 'object' && caughtError !== null && 'cause' in caughtError) {\n error = caughtError.cause\n }\n\n // PostgreSQL: 23505, SQLite: SQLITE_CONSTRAINT_UNIQUE\n if (error?.code === '23505' || error?.code === 'SQLITE_CONSTRAINT_UNIQUE') {\n let fieldName: null | string = null\n\n if (error.code === '23505') {\n // PostgreSQL - extract field name from constraint\n if (adapter.fieldConstraints?.[tableName]?.[error.constraint]) {\n fieldName = adapter.fieldConstraints[tableName][error.constraint]\n } else {\n const replacement = `${tableName}_`\n if (error.constraint?.includes(replacement)) {\n const replacedConstraint = error.constraint.replace(replacement, '')\n if (replacedConstraint && adapter.fieldConstraints[tableName]?.[replacedConstraint]) {\n fieldName = adapter.fieldConstraints[tableName][replacedConstraint]\n }\n }\n }\n\n if (!fieldName && error.detail) {\n // Extract from detail: \"Key (field)=(value) already exists.\"\n const regex = /Key \\(([^)]+)\\)=\\(([^)]+)\\)/\n const match: string[] = error.detail.match(regex)\n if (match && match[1]) {\n fieldName = match[1]\n }\n }\n } else if (error.code === 'SQLITE_CONSTRAINT_UNIQUE') {\n // SQLite - extract from message: \"UNIQUE constraint failed: table.field[, table.field2, ...]\"\n const regex = /UNIQUE constraint failed: ([^.]+)\\.([^.,]+)/\n const match: string[] = error.message?.match(regex)\n if (match && match[2]) {\n if (adapter.fieldConstraints[tableName]) {\n fieldName = adapter.fieldConstraints[tableName][`${match[2]}_idx`]\n }\n if (!fieldName) {\n fieldName = match[2]\n }\n }\n }\n\n throw new ValidationError(\n {\n id,\n collection: collectionSlug,\n errors: [\n {\n message: req?.t ? req.t('error:valueMustBeUnique') : 'Value must be unique',\n path: fieldName,\n tableName,\n },\n ],\n global: globalSlug,\n req,\n },\n req?.t,\n )\n }\n\n // Re-throw non-constraint errors\n throw caughtError\n}\n"],"names":["ValidationError","handleUpsertError","id","adapter","collectionSlug","error","caughtError","globalSlug","req","tableName","cause","code","fieldName","fieldConstraints","constraint","replacement","includes","replacedConstraint","replace","detail","regex","match","message","collection","errors","t","path","global"],"mappings":"AAEA,SAASA,eAAe,QAAQ,aAAY;AAc5C;;;;CAIC,GACD,OAAO,MAAMC,oBAAoB,CAAC,EAChCC,EAAE,EACFC,OAAO,EACPC,cAAc,EACdC,OAAOC,WAAW,EAClBC,UAAU,EACVC,GAAG,EACHC,SAAS,EACa;IACtB,IAAIJ,QAAaC;IACjB,IAAI,OAAOA,gBAAgB,YAAYA,gBAAgB,QAAQ,WAAWA,aAAa;QACrFD,QAAQC,YAAYI,KAAK;IAC3B;IAEA,sDAAsD;IACtD,IAAIL,OAAOM,SAAS,WAAWN,OAAOM,SAAS,4BAA4B;QACzE,IAAIC,YAA2B;QAE/B,IAAIP,MAAMM,IAAI,KAAK,SAAS;YAC1B,kDAAkD;YAClD,IAAIR,QAAQU,gBAAgB,EAAE,CAACJ,UAAU,EAAE,CAACJ,MAAMS,UAAU,CAAC,EAAE;gBAC7DF,YAAYT,QAAQU,gBAAgB,CAACJ,UAAU,CAACJ,MAAMS,UAAU,CAAC;YACnE,OAAO;gBACL,MAAMC,cAAc,GAAGN,UAAU,CAAC,CAAC;gBACnC,IAAIJ,MAAMS,UAAU,EAAEE,SAASD,cAAc;oBAC3C,MAAME,qBAAqBZ,MAAMS,UAAU,CAACI,OAAO,CAACH,aAAa;oBACjE,IAAIE,sBAAsBd,QAAQU,gBAAgB,CAACJ,UAAU,EAAE,CAACQ,mBAAmB,EAAE;wBACnFL,YAAYT,QAAQU,gBAAgB,CAACJ,UAAU,CAACQ,mBAAmB;oBACrE;gBACF;YACF;YAEA,IAAI,CAACL,aAAaP,MAAMc,MAAM,EAAE;gBAC9B,6DAA6D;gBAC7D,MAAMC,QAAQ;gBACd,MAAMC,QAAkBhB,MAAMc,MAAM,CAACE,KAAK,CAACD;gBAC3C,IAAIC,SAASA,KAAK,CAAC,EAAE,EAAE;oBACrBT,YAAYS,KAAK,CAAC,EAAE;gBACtB;YACF;QACF,OAAO,IAAIhB,MAAMM,IAAI,KAAK,4BAA4B;YACpD,8FAA8F;YAC9F,MAAMS,QAAQ;YACd,MAAMC,QAAkBhB,MAAMiB,OAAO,EAAED,MAAMD;YAC7C,IAAIC,SAASA,KAAK,CAAC,EAAE,EAAE;gBACrB,IAAIlB,QAAQU,gBAAgB,CAACJ,UAAU,EAAE;oBACvCG,YAAYT,QAAQU,gBAAgB,CAACJ,UAAU,CAAC,GAAGY,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;gBACpE;gBACA,IAAI,CAACT,WAAW;oBACdA,YAAYS,KAAK,CAAC,EAAE;gBACtB;YACF;QACF;QAEA,MAAM,IAAIrB,gBACR;YACEE;YACAqB,YAAYnB;YACZoB,QAAQ;gBACN;oBACEF,SAASd,KAAKiB,IAAIjB,IAAIiB,CAAC,CAAC,6BAA6B;oBACrDC,MAAMd;oBACNH;gBACF;aACD;YACDkB,QAAQpB;YACRC;QACF,GACAA,KAAKiB;IAET;IAEA,iCAAiC;IACjC,MAAMnB;AACR,EAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ValidationError } from '@hanzo/cms';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { handleUpsertError } from './handleUpsertError.js';
|
|
4
|
+
const adapter = {
|
|
5
|
+
fieldConstraints: {}
|
|
6
|
+
};
|
|
7
|
+
describe('handleUpsertError', ()=>{
|
|
8
|
+
it('preserves the failing sub-table name on the ValidationError', ()=>{
|
|
9
|
+
const pgError = {
|
|
10
|
+
code: '23505',
|
|
11
|
+
constraint: 'ultrasonic_avail_country_pkey',
|
|
12
|
+
detail: 'Key (id)=(6a27e2a63f4b64567370f595) already exists.'
|
|
13
|
+
};
|
|
14
|
+
let thrown;
|
|
15
|
+
try {
|
|
16
|
+
handleUpsertError({
|
|
17
|
+
adapter,
|
|
18
|
+
collectionSlug: 'ultrasonic',
|
|
19
|
+
error: pgError,
|
|
20
|
+
tableName: 'ultrasonic_avail_country'
|
|
21
|
+
});
|
|
22
|
+
} catch (error) {
|
|
23
|
+
thrown = error;
|
|
24
|
+
}
|
|
25
|
+
expect(thrown).toBeInstanceOf(ValidationError);
|
|
26
|
+
const validationError = thrown;
|
|
27
|
+
const fieldError = validationError.data.errors[0];
|
|
28
|
+
expect(fieldError.path).toBe('id');
|
|
29
|
+
expect(fieldError.tableName).toBe('ultrasonic_avail_country');
|
|
30
|
+
});
|
|
31
|
+
it('re-throws non unique-constraint errors unchanged', ()=>{
|
|
32
|
+
const otherError = new Error('some other db error');
|
|
33
|
+
expect(()=>handleUpsertError({
|
|
34
|
+
adapter,
|
|
35
|
+
collectionSlug: 'ultrasonic',
|
|
36
|
+
error: otherError,
|
|
37
|
+
tableName: 'ultrasonic_avail_country'
|
|
38
|
+
})).toThrow(otherError);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=handleUpsertError.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/upsertRow/handleUpsertError.spec.ts"],"sourcesContent":["import { ValidationError } from '@hanzo/cms'\nimport { describe, expect, it } from 'vitest'\n\nimport type { DrizzleAdapter } from '../types.js'\n\nimport { handleUpsertError } from './handleUpsertError.js'\n\nconst adapter = { fieldConstraints: {} } as unknown as DrizzleAdapter\n\ndescribe('handleUpsertError', () => {\n it('preserves the failing sub-table name on the ValidationError', () => {\n const pgError = {\n code: '23505',\n constraint: 'ultrasonic_avail_country_pkey',\n detail: 'Key (id)=(6a27e2a63f4b64567370f595) already exists.',\n }\n\n let thrown: unknown\n try {\n handleUpsertError({\n adapter,\n collectionSlug: 'ultrasonic',\n error: pgError,\n tableName: 'ultrasonic_avail_country',\n })\n } catch (error) {\n thrown = error\n }\n\n expect(thrown).toBeInstanceOf(ValidationError)\n const validationError = thrown as ValidationError\n const fieldError = validationError.data.errors[0]!\n expect(fieldError.path).toBe('id')\n expect(fieldError.tableName).toBe('ultrasonic_avail_country')\n })\n\n it('re-throws non unique-constraint errors unchanged', () => {\n const otherError = new Error('some other db error')\n\n expect(() =>\n handleUpsertError({\n adapter,\n collectionSlug: 'ultrasonic',\n error: otherError,\n tableName: 'ultrasonic_avail_country',\n }),\n ).toThrow(otherError)\n })\n})\n"],"names":["ValidationError","describe","expect","it","handleUpsertError","adapter","fieldConstraints","pgError","code","constraint","detail","thrown","collectionSlug","error","tableName","toBeInstanceOf","validationError","fieldError","data","errors","path","toBe","otherError","Error","toThrow"],"mappings":"AAAA,SAASA,eAAe,QAAQ,aAAY;AAC5C,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAI7C,SAASC,iBAAiB,QAAQ,yBAAwB;AAE1D,MAAMC,UAAU;IAAEC,kBAAkB,CAAC;AAAE;AAEvCL,SAAS,qBAAqB;IAC5BE,GAAG,+DAA+D;QAChE,MAAMI,UAAU;YACdC,MAAM;YACNC,YAAY;YACZC,QAAQ;QACV;QAEA,IAAIC;QACJ,IAAI;YACFP,kBAAkB;gBAChBC;gBACAO,gBAAgB;gBAChBC,OAAON;gBACPO,WAAW;YACb;QACF,EAAE,OAAOD,OAAO;YACdF,SAASE;QACX;QAEAX,OAAOS,QAAQI,cAAc,CAACf;QAC9B,MAAMgB,kBAAkBL;QACxB,MAAMM,aAAaD,gBAAgBE,IAAI,CAACC,MAAM,CAAC,EAAE;QACjDjB,OAAOe,WAAWG,IAAI,EAAEC,IAAI,CAAC;QAC7BnB,OAAOe,WAAWH,SAAS,EAAEO,IAAI,CAAC;IACpC;IAEAlB,GAAG,oDAAoD;QACrD,MAAMmB,aAAa,IAAIC,MAAM;QAE7BrB,OAAO,IACLE,kBAAkB;gBAChBC;gBACAO,gBAAgB;gBAChBC,OAAOS;gBACPR,WAAW;YACb,IACAU,OAAO,CAACF;IACZ;AACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TypeWithID } from '@hanzo/cms';
|
|
2
|
+
import type { Args } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* If `id` is provided, it will update the row with that ID.
|
|
5
|
+
* If `where` is provided, it will update the row that matches the `where`
|
|
6
|
+
* If neither `id` nor `where` is provided, it will create a new row.
|
|
7
|
+
*
|
|
8
|
+
* adapter function replaces the entire row and does not support partial updates.
|
|
9
|
+
*/
|
|
10
|
+
export declare const upsertRow: <T extends Record<string, unknown> | TypeWithID>({ id, adapter, collectionSlug, data, db, fields, globalSlug, ignoreResult, customID, joinQuery: _joinQuery, operation, path, req, select, tableName, upsertTarget, where, }: Args) => Promise<T>;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/upsertRow/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAK5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAqBtC;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAU,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,+KAqB3E,IAAI,KAAG,OAAO,CAAC,CAAC,CAgtBlB,CAAA"}
|