diff --git a/.gitignore b/.gitignore index b273edf..df32e44 100755 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,8 @@ # Dependencies -# Dependencies .medusa node_modules/ package-lock.json .yarn/ -yarn.lock .yalc yalc.lock diff --git a/AGENTS.md b/AGENTS.md index f6d66a0..fd5a1ea 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -182,9 +182,10 @@ Project skills are in `.ai/skills/` (symlinked to `.cursor/skills/` and `.codex/ ## Rules for Agents -1. Always run `yarn format` before committing. -2. Follow the branch model: feature work from `develop`, PRs to `develop`. -3. Add a changeset (`yarn changeset`) for any user-facing change. -4. Use consistent terminology: `system`, `db`, `external`, `blocks`, `mpn-builder`, `workflow`. -5. When changing docs, follow the `docs` skill. -6. Do not commit `.env`, `node_modules`, `.medusa/`, or build artifacts. +1. Never run `yarn install`, `yarn dev`, `medusa develop`, or other long-running/dependency-install commands on the user's behalf, in this repo or in sibling repos (`vending-plugin`, `app/apps/venloop`, `storefront`) — the user runs these themselves to save tokens. Tell them what to run and what to check instead. +2. Always run `yarn format` before committing. +3. Follow the branch model: feature work from `develop`, PRs to `develop`. +4. Add a changeset (`yarn changeset`) for any user-facing change. +5. Use consistent terminology: `system`, `db`, `external`, `blocks`, `mpn-builder`, `workflow`. +6. When changing docs, follow the `docs` skill. +7. Do not commit `.env`, `node_modules`, `.medusa/`, or build artifacts. diff --git a/CHANGELOG.md b/CHANGELOG.md index 689917a..64c9924 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # @codee-sh/medusa-plugin-notification-emails +## 1.0.4 + +### Patch Changes + +- Support registering external templates via a directly-imported module object (`template.module`), not just a resolvable file path (`template.path`). Lets host apps register a template that lives locally (not published as its own package) by statically importing it and passing the module in `extend.services[].templates[].module`. + ## 1.0.2 ### Patch Changes diff --git a/package.json b/package.json index a369b18..6f89e8b 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@codee-sh/medusa-plugin-notification-emails", - "version": "1.0.2", + "version": "1.0.4", "description": "Medusa plugin for notifications emails.", "author": "Codee Team (https://codee.dev)", "license": "MIT", diff --git a/src/modules/mpn-builder/service.ts b/src/modules/mpn-builder/service.ts index b3ee7f9..599792e 100644 --- a/src/modules/mpn-builder/service.ts +++ b/src/modules/mpn-builder/service.ts @@ -112,19 +112,25 @@ class MpnBuilderService extends MedusaService({ async (template: any) => { const templateName = template.name const templateValue = template.path + const templateModule_ = template.module let renderer = templateValue try { - const templateModule = await import( - templateValue - ) - renderer = - templateModule?.default || templateModule + let rawModule: any + + if (templateModule_) { + rawModule = templateModule_ + } else { + const imported = await import(templateValue) + rawModule = imported?.default || imported + } + + renderer = rawModule if (!renderer) { this.logger_.warn( - `Template module from "${templateValue}" does not export a default function or expected named export` + `Template module from "${templateValue ?? "module"}" does not export a default function or expected named export` ) return } @@ -136,7 +142,7 @@ class MpnBuilderService extends MedusaService({ ) } catch (error: any) { this.logger_.warn( - `Failed to load template from "${templateValue}": ${error?.message || "Unknown error"}` + `Failed to load template from "${templateValue ?? "module"}": ${error?.message || "Unknown error"}` ) return } diff --git a/src/modules/mpn-builder/types/types.ts b/src/modules/mpn-builder/types/types.ts index 285499f..e745555 100644 --- a/src/modules/mpn-builder/types/types.ts +++ b/src/modules/mpn-builder/types/types.ts @@ -56,7 +56,8 @@ export type ModuleOptions = { id: string templates?: Array<{ name: string - path: string + path?: string + module?: Record }> }> }