드롭시핑 공급사: 규칙 가격으로 상품 가져오기, 원가·재고 동기화, 결제 주문 전달, 배송 추적, 예외 처리
설치
genpm add @core/suppliers포함 내용
- src/lib/suppliers/에 소스 코드, 파일 9개. (62.2kB)
- src/lib/suppliers/AGENTS.md에 AI 규칙, 그리고 IDE 규칙 파일.
- .env.example에 추가되는 환경 변수: SUPPLIER_COST_ALERT_PCT, CJ_API_KEY, CJ_QPS.
- @core/catalog, @core/contracts, @core/db, @core/email, @core/jobs, @core/media, @core/money, @core/orders, @core/pricing, @core/rich-text을(를) 자동으로 해결합니다.
README
@core/suppliers
Dropshipping suppliers: import products priced by rules, sync cost and stock, forward paid orders, tracking and exceptions
A GenPM module: source code + AI rules + MCP config, injected into your project instead of hidden in node_modules. The code lands in src/lib/suppliers, pinned to a verified commit, and you own it.
Install
genpm add @core/suppliersNo genpm yet? curl -fsSL https://genpm.net/install.sh | sh (macOS/Linux), irm https://genpm.net/install.ps1 | iex (Windows), or one-off with npx @genpm-net/cli add @core/suppliers.
Or let your AI agent do it: run genpm mcp setup once, then ask "add @core/suppliers with genpm" in Claude Code, Cursor, VS Code, Windsurf, Codex or Gemini CLI. It shows you a dry-run plan before writing anything.
What it does
Dropshipping operations behind a SupplierAdapter contract: import supplier products into @core/catalog as drafts
(price from @core/pricing rules, images copied to @core/media, plain-text description), map variants to supplier
SKUs with cost and delivery days, sync cost and stock (reprice; pause products that would sell at a loss), turn paid
orders into supplier orders (approval by default, or automatic), forward them with retries, record tracking on the
order and keep an exceptions queue. Ships the manual adapter (CSV import, orders emailed to the supplier) and the
cj adapter (CJdropshipping API v2: search, import, cost/stock sync, orders and tracking).
Setup
After genpm add, follow these steps (your AI agent finds the same steps in src/lib/suppliers/AGENTS.md and can do them for you):
- Install @core/pricing and create at least one price rule. Migrations as in
src/lib/db/AGENTS.md; the @core/jobs cron must run. - Import this module at startup (registers the manual adapter and the
paidorder handler). - Create a supplier in the admin: adapter
manual,config.orderEmail, currency. API adapters read credentials from env, never fromconfig. CJdropshipping: adaptercj, currencyUSD, envCJ_API_KEY(CJ → Apps → install "API" → Add API, type "API Key"). Config:logisticName(required, a CJ shipping method such asCJPacket Ordinary),fromCountryCode(defaultCN),payWithBalance: "true"to pay each order from the CJ balance (otherwise orders wait unpaid in CJ), andsandbox: "true"while testing (no charge, no shipment). CJ allows 1 request/s on free accounts: raiseCJ_QPSonly if your CJ level allows it. Import withgetAdapter('cj').getProduct(supplier, pid)→importProduct. - Import:
importProduct(supplierId, parseSupplierCsv(csv, currency)[0], { slug, categories })(or the supplier's "Import products from CSV" admin action) → review the draft, then publish. CSV header (one row per variant):product_id,title,description,image_urls,option1_name,option1_value,option2_name,option2_value,variant_id,cost,stock,weight_grams,ship_min_days,ship_max_days(image_urlsseparated by|, https only;costdecimal in the supplier currency). Images are copied only from allowed hosts: add the supplier's image domains to itsconfig.imageHosts(cdn.supplier.com,.img.supplier.com); skipped images open animages_skippedexception. - Schedule
syncAllJob(e.g. every 6 h) andpollTrackingJob(every 12 h) with @core/jobsschedule. Suppliers in another currency need exchange rates for the scheduled sync:setFxRatesProvider(async () => ({ base, rates }))at startup, or envSUPPLIER_FX_RATES='{"base":"EUR","rates":{"USD":1.08}}'. Without them, products whose cost changed are paused with anfx_rates_missingexception. A failing supplier gets async_failedexception; the rest still sync. - Product pages: show
deliveryEstimate(variantId)before purchase. - Add
...suppliersAdminResources()tosrc/genpm/admin.ts; check open exceptions daily.
What's inside
Paths are relative to src/lib/suppliers.
index.ts— public API:upsertSupplier,parseSupplierCsv,importProduct,syncSupplier,setFxRatesProvider,approveSupplierOrder,forwardSupplierOrder,recordSupplierShipment,deliveryEstimate,registerAdapter,suppliersAdminResources.suppliers.ts— flows and jobs (suppliers.forward,suppliers.sync,suppliers.tracking).adapter.ts— contract.adapters/manual.ts— manual adapter and CSV parser.adapters/cj.ts— CJdropshipping adapter (cjAdapter,CjApiError).admin.ts— suppliers, supplier orders, exceptions.
At a glance
- GenPM dependencies (installed with it): @core/catalog, @core/orders, @core/pricing, @core/jobs, @core/media, @core/email, @core/money, @core/rich-text, @core/db, @core/contracts
- npm dependencies (proposed, never installed without asking):
zod - Environment variables (added to
.env.example):SUPPLIER_COST_ALERT_PCT,CJ_API_KEY,CJ_QPS - AI rules:
AGENTS.md, loaded by your agent only when it works insrc/lib/suppliers
Security
GenPM installs a 40-character commit SHA (never a branch), verifies an Ed25519-signed manifest, never runs install scripts and scans AI rules for prompt injection. Details: genpm.net/docs/security.
License
이것이 AI가 src/lib/suppliers에서 작업할 때 읽는 내용 그대로입니다. 그 외에는 컨텍스트에 아무것도 추가되지 않습니다.
@core/suppliers — rules for AI agents
Purpose
Dropshipping operations behind a SupplierAdapter contract: import supplier products into @core/catalog as drafts
(price from @core/pricing rules, images copied to @core/media, plain-text description), map variants to supplier
SKUs with cost and delivery days, sync cost and stock (reprice; pause products that would sell at a loss), turn paid
orders into supplier orders (approval by default, or automatic), forward them with retries, record tracking on the
order and keep an exceptions queue. Ships the manual adapter (CSV import, orders emailed to the supplier) and the
cj adapter (CJdropshipping API v2: search, import, cost/stock sync, orders and tracking).
Map
index.ts— public API:upsertSupplier,parseSupplierCsv,importProduct,syncSupplier,setFxRatesProvider,approveSupplierOrder,forwardSupplierOrder,recordSupplierShipment,deliveryEstimate,registerAdapter,suppliersAdminResources.suppliers.ts— flows and jobs (suppliers.forward,suppliers.sync,suppliers.tracking).adapter.ts— contract.adapters/manual.ts— manual adapter and CSV parser.adapters/cj.ts— CJdropshipping adapter (cjAdapter,CjApiError).admin.ts— suppliers, supplier orders, exceptions.
Integration
- Install @core/pricing and create at least one price rule. Migrations as in
src/lib/db/AGENTS.md; the @core/jobs cron must run. - Import this module at startup (registers the manual adapter and the
paidorder handler). - Create a supplier in the admin: adapter
manual,config.orderEmail, currency. API adapters read credentials from env, never fromconfig. CJdropshipping: adaptercj, currencyUSD, envCJ_API_KEY(CJ → Apps → install "API" → Add API, type "API Key"). Config:logisticName(required, a CJ shipping method such asCJPacket Ordinary),fromCountryCode(defaultCN),payWithBalance: "true"to pay each order from the CJ balance (otherwise orders wait unpaid in CJ), andsandbox: "true"while testing (no charge, no shipment). CJ allows 1 request/s on free accounts: raiseCJ_QPSonly if your CJ level allows it. Import withgetAdapter('cj').getProduct(supplier, pid)→importProduct. - Import:
importProduct(supplierId, parseSupplierCsv(csv, currency)[0], { slug, categories })(or the supplier's "Import products from CSV" admin action) → review the draft, then publish. CSV header (one row per variant):product_id,title,description,image_urls,option1_name,option1_value,option2_name,option2_value,variant_id,cost,stock,weight_grams,ship_min_days,ship_max_days(image_urlsseparated by|, https only;costdecimal in the supplier currency). Images are copied only from allowed hosts: add the supplier's image domains to itsconfig.imageHosts(cdn.supplier.com,.img.supplier.com); skipped images open animages_skippedexception. - Schedule
syncAllJob(e.g. every 6 h) andpollTrackingJob(every 12 h) with @core/jobsschedule. Suppliers in another currency need exchange rates for the scheduled sync:setFxRatesProvider(async () => ({ base, rates }))at startup, or envSUPPLIER_FX_RATES='{"base":"EUR","rates":{"USD":1.08}}'. Without them, products whose cost changed are paused with anfx_rates_missingexception. A failing supplier gets async_failedexception; the rest still sync. - Product pages: show
deliveryEstimate(variantId)before purchase. - Add
...suppliersAdminResources()tosrc/genpm/admin.ts; check open exceptions daily.
Conventions
- New adapters implement
SupplierAdapterin their own file and callregisterAdapter; list their image hosts. - Supplier orders start in
pending_approvalunless the supplier hasautoForward; failures retry, then open an exception. - Forwarding is at most once: the row is claimed (
queued → sending) beforeplaceOrder. A timeout or a row found insendingmeans the outcome is unknown: it goes tofailedwith aforward_failedexception and is never re-sent automatically — check with the supplier before approving it again. Only non-refunded units are forwarded. - Adapters:
placeOrderthrows only when the order was NOT created, usesorder.referenceas idempotency key when the API allows it, and passesopts.signaltofetch.syncVariantsreturnscost: nullwhen the supplier no longer knows the variant (removed): the stored cost is kept and stock goes to 0. - Costs may be in another currency: pass exchange
rates(and store them) when importing or syncing.
Don't
- Don't scrape supplier websites or bypass their terms; use official APIs or the manual adapter.
- Don't forward unpaid, cancelled or refunded orders, and don't sell below cost (sync pauses those products).
- Don't hotlink supplier images or copy descriptions claiming features/certifications you can't verify.
# @core/suppliers — rules for AI agents
## Purpose
Dropshipping operations behind a `SupplierAdapter` contract: import supplier products into @core/catalog as drafts
(price from @core/pricing rules, images copied to @core/media, plain-text description), map variants to supplier
SKUs with cost and delivery days, sync cost and stock (reprice; pause products that would sell at a loss), turn paid
orders into supplier orders (approval by default, or automatic), forward them with retries, record tracking on the
order and keep an exceptions queue. Ships the `manual` adapter (CSV import, orders emailed to the supplier) and the
`cj` adapter (CJdropshipping API v2: search, import, cost/stock sync, orders and tracking).
## Map
- `index.ts` — public API: `upsertSupplier`, `parseSupplierCsv`, `importProduct`, `syncSupplier`, `setFxRatesProvider`, `approveSupplierOrder`, `forwardSupplierOrder`, `recordSupplierShipment`, `deliveryEstimate`, `registerAdapter`, `suppliersAdminResources`.
- `suppliers.ts` — flows and jobs (`suppliers.forward`, `suppliers.sync`, `suppliers.tracking`). `adapter.ts` — contract.
- `adapters/manual.ts` — manual adapter and CSV parser. `adapters/cj.ts` — CJdropshipping adapter (`cjAdapter`, `CjApiError`).
- `admin.ts` — suppliers, supplier orders, exceptions.
## Integration
1. Install @core/pricing and create at least one price rule. Migrations as in `src/lib/db/AGENTS.md`; the @core/jobs cron must run.
2. Import this module at startup (registers the manual adapter and the `paid` order handler).
3. Create a supplier in the admin: adapter `manual`, `config.orderEmail`, currency. API adapters read credentials from env, never from `config`.
CJdropshipping: adapter `cj`, currency `USD`, env `CJ_API_KEY` (CJ → Apps → install "API" → Add API, type "API Key").
Config: `logisticName` (required, a CJ shipping method such as `CJPacket Ordinary`), `fromCountryCode` (default `CN`),
`payWithBalance: "true"` to pay each order from the CJ balance (otherwise orders wait unpaid in CJ), and
`sandbox: "true"` while testing (no charge, no shipment). CJ allows 1 request/s on free accounts: raise `CJ_QPS`
only if your CJ level allows it. Import with `getAdapter('cj').getProduct(supplier, pid)` → `importProduct`.
4. Import: `importProduct(supplierId, parseSupplierCsv(csv, currency)[0], { slug, categories })` (or the supplier's
"Import products from CSV" admin action) → review the draft, then publish. CSV header (one row per variant):
`product_id,title,description,image_urls,option1_name,option1_value,option2_name,option2_value,variant_id,cost,stock,weight_grams,ship_min_days,ship_max_days`
(`image_urls` separated by `|`, https only; `cost` decimal in the supplier currency). Images are copied only from
allowed hosts: add the supplier's image domains to its `config.imageHosts` (`cdn.supplier.com,.img.supplier.com`);
skipped images open an `images_skipped` exception.
5. Schedule `syncAllJob` (e.g. every 6 h) and `pollTrackingJob` (every 12 h) with @core/jobs `schedule`. Suppliers
in another currency need exchange rates for the scheduled sync: `setFxRatesProvider(async () => ({ base, rates }))`
at startup, or env `SUPPLIER_FX_RATES='{"base":"EUR","rates":{"USD":1.08}}'`. Without them, products whose cost
changed are paused with an `fx_rates_missing` exception. A failing supplier gets a `sync_failed` exception; the rest still sync.
6. Product pages: show `deliveryEstimate(variantId)` before purchase.
7. Add `...suppliersAdminResources()` to `src/genpm/admin.ts`; check open exceptions daily.
## Conventions
- New adapters implement `SupplierAdapter` in their own file and call `registerAdapter`; list their image hosts.
- Supplier orders start in `pending_approval` unless the supplier has `autoForward`; failures retry, then open an exception.
- Forwarding is at most once: the row is claimed (`queued → sending`) before `placeOrder`. A timeout or a row found
in `sending` means the outcome is unknown: it goes to `failed` with a `forward_failed` exception and is never
re-sent automatically — check with the supplier before approving it again. Only non-refunded units are forwarded.
- Adapters: `placeOrder` throws only when the order was NOT created, uses `order.reference` as idempotency key when
the API allows it, and passes `opts.signal` to `fetch`. `syncVariants` returns `cost: null` when the supplier no
longer knows the variant (removed): the stored cost is kept and stock goes to 0.
- Costs may be in another currency: pass exchange `rates` (and store them) when importing or syncing.
## Don't
- Don't scrape supplier websites or bypass their terms; use official APIs or the manual adapter.
- Don't forward unpaid, cancelled or refunded orders, and don't sell below cost (sync pauses those products).
- Don't hotlink supplier images or copy descriptions claiming features/certifications you can't verify.
.genpmignore 적용 후 주입될 정확한 트리입니다. 고정 대상:
// @core/suppliers — API pública. Al importarlo registra los adaptadores (manual y cj) y el reenvío de
// pedidos pagados.
import './adapters/manual.ts';
import './adapters/cj.ts';
export {
type ExternalProduct,
type ExternalVariant,
getAdapter,
registerAdapter,
type SupplierAdapter,
type SupplierOrderRequest,
type TrackingInfo,
} from './adapter.ts';
export { CjApiError, cjAdapter } from './adapters/cj.ts';
export { manualAdapter, parseCsv, parseSupplierCsv } from './adapters/manual.ts';
export { supplierExceptionsAdminResource, supplierOrdersAdminResource, suppliersAdminResource, suppliersAdminResources } from './admin.ts';
export {
type Supplier,
type SupplierException,
type SupplierOrder,
supplierExceptions,
supplierOrders,
supplierProducts,
suppliers,
} from './schema.ts';
export {
approveSupplierOrder,
createSupplierOrders,
currentFxRates,
deliveryEstimate,
exception,
type FxRates,
forwardJob,
forwardSupplierOrder,
importProduct,
MAX_FORWARD_ATTEMPTS,
pollTrackingJob,
recordSupplierShipment,
registerSuppliers,
resolveException,
setFxRatesProvider,
STALLED_DAYS,
SupplierError,
SupplierInput,
syncAllJob,
syncSupplier,
upsertSupplier,
} from './suppliers.ts';
이 패키지는 MCP 서버를 선언하지 않습니다.
- genpm
- @core/catalog ^1.0.0@core/contracts ^1.0.0@core/db ^1.0.0@core/email ^1.0.1@core/jobs ^1.0.0@core/media ^1.0.0@core/money ^1.0.0@core/orders ^1.0.0@core/pricing ^1.0.0@core/rich-text ^1.0.0
- npm
- zod ^4.0.0
- 제안됨
- GenPM은 npm 명령을 제안하고, 동의한 경우에만 실행합니다.
- 사용하는 패키지 (1)
- @core/kit-dropshipping ^1.0.0
- 검사
- 검사 통과 · 문제 0건
- 커밋
- v1.2.2 → 3f1fd04d96fb13e33e46e281d2b53e25a65b9d15 · 가져온 뒤 검증됨
- 스크립트
- 없음. GenPM은 패키지 코드를 절대 실행하지 않습니다.
- 라이선스
- MIT
- 품질
- 100/100
- 인정된 라이선스충족
- AGENTS.md에 목적 설명충족
- AGENTS.md에 통합 단계충족
- AGENTS.md에 규칙 또는 금지 사항충족
- 테스트 포함충족
- 보안 검사 통과충족
- 최근 6개월 내 게시충족
- 인증된 게시자충족
- 요약과 키워드충족
- 신고
- 문제가 있나요?