{"version":3,"file":"get-current-collection-migration-id.mjs","names":[],"sources":["../../../../src/libs/collection/migration/get-current-collection-migration-id.ts"],"sourcesContent":["import type { ServiceFn } from \"../../../utils/services/types.js\";\nimport { copy } from \"../../i18n/index.js\";\nimport { CollectionMigrationsRepository } from \"../../repositories/index.js\";\n\nconst getCurrentCollectionMigrationId: ServiceFn<[string], number> = async (\n\tcontext,\n\tcollectionKey,\n) => {\n\tconst CollectionMigrations = new CollectionMigrationsRepository(\n\t\tcontext.db.client,\n\t\tcontext.config.db,\n\t);\n\tconst latestMigrationRes =\n\t\tawait CollectionMigrations.selectLatestByCollectionKey({\n\t\t\tcollectionKey,\n\t\t});\n\tif (latestMigrationRes.error) return latestMigrationRes;\n\n\tif (!latestMigrationRes.data) {\n\t\treturn {\n\t\t\tdata: undefined,\n\t\t\terror: {\n\t\t\t\ttype: \"basic\",\n\t\t\t\tname: copy(\"server:core.error.schema.migration.required.name\"),\n\t\t\t\tmessage: copy(\"server:core.error.schema.migration.required.message\"),\n\t\t\t\tstatus: 400,\n\t\t\t},\n\t\t};\n\t}\n\n\treturn {\n\t\tdata: latestMigrationRes.data.id,\n\t\terror: undefined,\n\t};\n};\n\nexport default getCurrentCollectionMigrationId;\n"],"mappings":"uGAIA,MAAM,EAA+D,MACpE,EACA,IACI,CAKJ,IAAM,EACL,MAAM,IAL0B,EAChC,EAAQ,GAAG,OACX,EAAQ,OAAO,EAGU,CAAC,CAAC,4BAA4B,CACtD,eACD,CAAC,EAeF,OAdI,EAAmB,MAAc,EAEhC,EAAmB,KAYjB,CACN,KAAM,EAAmB,KAAK,GAC9B,MAAO,IAAA,EACR,EAdQ,CACN,KAAM,IAAA,GACN,MAAO,CACN,KAAM,QACN,KAAM,EAAK,kDAAkD,EAC7D,QAAS,EAAK,qDAAqD,EACnE,OAAQ,GACT,CACD,CAOF"}