{
  "$schema": "https://registry.mercurjs.com/registry-item.json",
  "name": "block-2",
  "description": "A block with a sample module, product-sample link, workflow, and API route.",
  "dependencies": [],
  "registryDependencies": [],
  "docs": "## Sample Block Configuration\n\nAdd the sample module to your `medusa-config.ts`:\n\n```ts\nmodules: [\n  {\n    resolve: './modules/sample',\n    options: {\n      apiKey: process.env.SAMPLE_API_KEY,\n    },\n  },\n]\n```\n\n## Environment Variables\n\nAdd the following to your `.env` file:\n\n```\nSAMPLE_API_KEY=your-api-key\n```",
  "categories": [
    "sample",
    "workflow"
  ],
  "files": [
    {
      "path": "block-2/modules/sample/index.ts",
      "content": "import { Module } from \"@medusajs/framework/utils\"\nimport SampleModuleService from \"./service\"\n\nexport const SAMPLE_MODULE = \"sample\"\n\nexport default Module(SAMPLE_MODULE, {\n  service: SampleModuleService,\n})\n",
      "type": "registry:api"
    },
    {
      "path": "block-2/modules/sample/service.ts",
      "content": "import { MedusaService } from \"@medusajs/framework/utils\"\nimport Sample from \"./models/sample\"\n\nclass SampleModuleService extends MedusaService({\n  Sample,\n}) {}\n\nexport default SampleModuleService\n",
      "type": "registry:api"
    },
    {
      "path": "block-2/modules/sample/models/sample.ts",
      "content": "import { model } from \"@medusajs/framework/utils\"\n\nconst Sample = model.define(\"sample\", {\n  id: model.id().primaryKey(),\n  name: model.text(),\n})\n\nexport default Sample\n",
      "type": "registry:api"
    },
    {
      "path": "block-2/links/product-sample.ts",
      "content": "import { defineLink } from \"@medusajs/framework/utils\"\nimport ProductModule from \"@medusajs/medusa/product\"\nimport SampleModule from \"../modules/sample\"\n\nexport default defineLink(\n  ProductModule.linkable.product,\n  SampleModule.linkable.sample\n)\n",
      "type": "registry:api"
    },
    {
      "path": "block-2/workflows/hello-world/hello-world.ts",
      "content": "import {\n  createStep,\n  createWorkflow,\n  WorkflowResponse,\n  StepResponse,\n} from \"@medusajs/framework/workflows-sdk\"\n\nconst step1 = createStep(\"step-1\", async () => {\n  return new StepResponse(`Hello from step one!`)\n})\n\ntype WorkflowInput = {\n  name: string\n}\n\nconst step2 = createStep(\n  \"step-2\",\n  async ({ name }: WorkflowInput) => {\n    return new StepResponse(`Hello ${name} from step two!`)\n  }\n)\n\ntype WorkflowOutput = {\n  message1: string\n  message2: string\n}\n\nconst helloWorldWorkflow = createWorkflow(\n  \"hello-world\",\n  (input: WorkflowInput) => {\n    const greeting1 = step1()\n    const greeting2 = step2(input)\n\n    return new WorkflowResponse({\n      message1: greeting1,\n      message2: greeting2,\n    })\n  }\n)\n\nexport default helloWorldWorkflow\n",
      "type": "registry:api"
    },
    {
      "path": "block-2/api/hello/workflow/route.ts",
      "content": "import type { MedusaRequest, MedusaResponse } from \"@medusajs/framework/http\"\nimport helloWorldWorkflow from \"../../../workflows/hello-world/hello-world\"\n\nexport const GET = async (req: MedusaRequest, res: MedusaResponse) => {\n  const { result } = await helloWorldWorkflow(req.scope).run({\n    input: {\n      name: (req.query.name as string) || \"World\",\n    },\n  })\n\n  res.json(result)\n}\n",
      "type": "registry:api"
    }
  ]
}