import { importShared } from './__federation_fn_import-B0FfK6vm.js';
import { f as fileCategoryEntityType } from './plugin-definition-OkLTrrL5.js';

const {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
      }),
      categoryRef: ctx.withRef({
        type: fileCategoryEntityType,
        onDelete: "RESTRICT"
      }),
      type: z.literal("file")
    }),
    {
      type: modelTransformerEntityType,
      parentSlot: modelSlot,
      getNameResolver: (entity) => createDefinitionEntityNameResolver({
        idsToResolve: { fileRelation: entity.fileRelationRef },
        resolveName: (entityNames) => entityNames.fileRelation
      })
    }
  )
);

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

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