import { importShared } from './__federation_fn_import-BY6M5C84.js';
import { s as storageAdapterEntityType } from './plugin-definition-pEIqIxzw.js';
import { C as CASE_VALIDATORS } from './case-validators-ZpavR8D3.js';

const {authRoleEntityType,baseTransformerFields,createDefinitionEntityNameResolver,definitionSchemaWithSlots,modelEntityType,modelLocalRelationEntityType,modelTransformerEntityType} = await importShared('@baseplate-dev/project-builder-lib');
const {z} = await importShared('zod');
const createFileTransformerSchema = definitionSchemaWithSlots(
  { modelSlot: modelEntityType },
  (ctx, { modelSlot }) => ctx.withEnt(
    z.object({
      ...baseTransformerFields,
      fileRelationRef: ctx.withRef({
        type: modelLocalRelationEntityType,
        onDelete: "DELETE_PARENT",
        parentSlot: modelSlot
      }),
      category: z.object({
        name: CASE_VALIDATORS.CONSTANT_CASE,
        maxFileSizeMb: z.int().positive(),
        authorize: z.object({
          uploadRoles: z.array(
            ctx.withRef({
              type: authRoleEntityType,
              onDelete: "RESTRICT"
            })
          )
        }),
        adapterRef: ctx.withRef({
          type: storageAdapterEntityType,
          onDelete: "RESTRICT"
        })
      }),
      type: z.literal("file")
    }),
    {
      type: modelTransformerEntityType,
      parentSlot: modelSlot,
      getNameResolver: (entity) => createDefinitionEntityNameResolver({
        idsToResolve: { fileRelation: entity.fileRelationRef },
        resolveName: (entityNames) => entityNames.fileRelation
      })
    }
  )
);

const {createPlatformPluginExport,modelTransformerSpec} = await importShared('@baseplate-dev/project-builder-lib');
const common = createPlatformPluginExport({
  dependencies: {
    transformer: modelTransformerSpec
  },
  exports: {},
  initialize: ({ transformer }) => {
    transformer.registerModelTransformer({
      name: "file",
      createSchema: createFileTransformerSchema,
      getName(definitionContainer, definition) {
        return definitionContainer.nameFromId(definition.fileRelationRef);
      }
    });
    return {};
  }
});

export { common as default };
//# sourceMappingURL=__federation_expose_storageTransformersCommon-BEdhOo8D.js.map
