npm.io
0.0.1 • Published 2d ago

multivendor-prescription

Licence
MIT
Version
0.0.1
Deps
0
Size
2.4 MB
Vulns
0
Weekly
0

multivendor-prescription

Wallet-style prescription plugin for multi-vendor marketplaces:

  • Customer upload → admin approve/reject → cart lines
  • TypeORM entities + migration (1801000000000-CreatePrescriptionRequestTables)
  • HTTP controllers (routing-controllers)
  • Host ports for cart / product / file / customer / email

Port error contract

Port Failure
Cart write (approve) Fatal → roll back txn
Product resolve (approve) Fatal → roll back txn
File upload/read Fatal for create/file
Customer lookup Fatal
Email Non-fatal — never undo approval

Reject is usually single-table; if it writes more than prescription_request, use the same EntityManager rule as approve.

Two-phase host rollout

  1. Phase 1: Package + PRESCRIPTION_PLUGIN dual HTTP path; one entity class (package only).
  2. Phase 2: Delete legacy host controllers/service after staging verify.

Host wiring

import {
  registerPrescriptionPlugin,
  getPrescriptionOrmMetadata,
  PRESCRIPTION_PLUGIN_TOKEN,
} from 'multivendor-prescription';

// connectionOptions: merge getPrescriptionOrmMetadata().entities/migrations
// prescriptionLoader: registerPrescriptionPlugin({ dataSource, flags, ports, logger })
// Container.set(PRESCRIPTION_PLUGIN_TOKEN, plugin)

Follow-ups

  • Metrics counters (approve latency, email skip rate) — tracked in host issue #4.
  • Phase 2 cutover: after staging with PRESCRIPTION_PLUGIN=true, delete legacy host controllers/service/repos/DTO wrappers and remove the dual-path flag.

Keywords