INNER CODE UNIT · TypeScript

createOperationRegistry

prisma/prisma · packages/1-framework/1-core/operations/src/index.ts:43

export function createOperationRegistry<
  T extends OperationEntry = OperationEntry,
>(): OperationRegistry<T> {
  const operations: Record<string, T> = Object.create(null);

  return {
    register(name: string, descriptor: OperationDescriptor<T>) {
      if (name in operations) {
        throw contractError(
          'CONTRACT.PACK_CONTRIBUTION_INVALID',
          `Operation "${name}" is already registered`,
          { meta: { operation: name } },
        );
      }
      if (descriptor.self) {
        const hasCodecId = descriptor.self.codecId !== undefined;
        const hasTraits = descriptor.self.traits !== undefined && descriptor.self.traits.length > 0;
        const targetsMany = descriptor.self.many === true;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…