import { ReferenceKind } from '@mikro-orm/core';
import { prepareMetadataContext } from '../utils.js';
function createDecorator(options, serialized) {
  return function (value, context) {
    const meta = prepareMetadataContext(context, ReferenceKind.SCALAR);
    const key = serialized ? 'serializedPrimaryKey' : 'primary';
    options[key] = true;
    meta.properties[context.name] = {
      name: context.name,
      kind: ReferenceKind.SCALAR,
      ...options,
    };
  };
}
/** Marks a property as the primary key of an entity (TC39 decorator). */
export function PrimaryKey(options = {}) {
  return createDecorator(options, false);
}
/** Marks a property as the serialized form of the primary key, e.g. for MongoDB ObjectId (TC39 decorator). */
export function SerializedPrimaryKey(options = {}) {
  return createDecorator(options, true);
}
