npm.io
2.22.7 • Published 4d ago

@medusajs/utils

Licence
SEE LICENSE IN LICENSE
Version
2.22.7
Deps
14
Size
2.1 MB
Vulns
0
Weekly
0
Stars
37.0K

Medusa logo

@medusajs/utils

Documentation | Website

Building blocks for digital commerce

Medusa is released under the MIT license. PRs welcome! Discord Chat Follow @medusajs

@medusajs/utils is Medusa's shared utilities library: configuration helpers, module and data model builders, error classes, container keys, and helpers used across Medusa core, modules, and providers. Applications, plugins, and modules should import it through @medusajs/framework/utils, which re-exports this package; import @medusajs/utils directly only when you can't depend on @medusajs/framework.

At a glance

Package @medusajs/utils
Type Core library
Import from @medusajs/framework/utils

Features

  • Configuration: defineConfig for medusa-config.ts and loadEnv for loading .env files.
  • Modules: Module, ModuleProvider, MedusaService, the Modules enum of module keys, and defineLink for module links.
  • Data models: the model builder (DML) for defining data models.
  • Errors and container: MedusaError and ContainerRegistrationKeys.
  • Domain helpers: utilities and enums for products, pricing, orders, payments, fulfillment, promotions, totals (BigNumber), and more.

Usage

import { model } from "@medusajs/framework/utils"

const Post = model.define("post", {
  id: model.id().primaryKey(),
  title: model.text(),
})

export default Post

Resources