{"factsVersion":1,"extractor":{"engine":"@open-mercato/cli@0.9.0 extractModuleFacts","factsContractVersion":2,"catalog":"om-modules rentgen 5","durationMs":62},"package":{"locator":"npm:@dainamite/cpq-billing-connector","name":"@dainamite/cpq-billing-connector","version":"5.2.0","integrity":"sha512-ZcD5bdnEw0GEc1gflIBgT/RlBZQABkkWylJ4VWql7OhOyXX8/GpgZ902P96EfRsD57B4/eun9gutAZYY52ie9Q==","source":"npm-tarball","gitRef":"66eb48da62c461d5e5be370e0eebfabdd09ee39c"},"gate":{"installable":true,"needsModuleFlag":false,"reason":null,"modules":[{"id":"cpq_billing_connector","src":true,"dist":true}]},"kind":"module","license":{"value":"MIT","kind":"osi","mismatch":false,"sources":{"packageJson":"MIT","licenseFile":"MIT","moduleInfo":"MIT","integrationTs":null}},"omPeers":{"@open-mercato/ai-assistant":"^0.9.0","@open-mercato/core":"^0.9.0","@open-mercato/events":"^0.9.0","@open-mercato/shared":"^0.9.0","@open-mercato/ui":"^0.9.0"},"dependencies":{},"agentsMd":false,"readmeExcerpt":"# @dainamite/cpq-billing-connector\n\nPre-built integration that wires `@dainamite/cpq` subscription lifecycle\nevents to `@dainamite/billing` API calls.\n\nIt depends on both `@dainamite/cpq` and `@dainamite/billing` (as peers) and\n**must be registered after both** so their services are resolvable when its\nsubscribers fire:\n\n```typescript\n// src/modules.ts — order matters\n{ id: 'cpq', from: '@dainamite/cpq' }\n{ id: 'billing', from: '@dainamite/billing' }\n{ id: 'cpq_billing_connector', from: '@dainamite/cpq-billing-connector' }\n```\n\n```bash\nyarn generate\nyarn mercato db migrate\n```\n\nIt ships one table (`cpq_billing_connector_order_setups`) and one UI: the\n**Billing** tab on the CPQ order detail page (see below). Everything else is\nevent glue. Engines: **Node ≥ 24**.\n\nThe connector subscribes to six CPQ lifecycle events and translates each\nto the billing API contract:\n\n| CPQ event | Connector action |\n|---|---|\n| `cpq.subscription.activated` | Resolve the Billing Account from the order billing setup (or reuse / create one); create Billing Items per charge (one-time + recurring split) with the per-line bill start |\n| `cpq.subscription.amended` | Create new Billing Items for added subscription items on the subscription's own account (billing prorates); set `bill_end_date` on removed items |\n| `cpq.subscription.renewed` | Extend `bill_end_date` on existing Billing Items; create new Items for any added subscription items |\n| `cpq.subscription.cancelled` | Set `bill_end_date` on all Billing Items for the subscription |\n| `cpq.subscription.merged` | Move Billing Items from source subscriptions to the merged subscription (update `subscription_id`) |\n| `cpq.subscription.superseded` | Set `bill_end_date` on all Billing Items for the superseded subscription |\n\n## Order billing setup (Billing tab)\n\nSpec: [`.ai/specs/2026-11-15-cpq-billing-connector-order-billing-setup.md`](../../.ai/specs/2026-11-15-cpq-billing-connector-order-billing-setup.md).\n\nCPQ exposes a neutral injection spot, `cpq.order.detail:tabs`. The connector\nfills it with a **Billing** tab, editable while a new-sale order is `draft` /\n`pending_activation`:\n\n- **Billing account.** *Use existing* lists only active accounts of the\n  customer in the order's currency (one candidate is preselected). *Create new*\n  is prefilled from the sales order's customer snapshot; only the fields the\n  operator changes are stored as overrides.\n- **Bill start.** One default for the order (empty = activation date) plus an\n  optional date per line. Effective bill start of a line: line override → CPQ\n  service start → order default → activation date.\n\n**Amend / renew orders** show only the bill start of the lines they add\n(empty = the effective date for amend, the new term start for renew); those\nlines always bill to the subscription's existing account. Multi-subscription\n(merge) renewals are not covered.\n\nSaving is optional — without a saved setup, activation uses the customer's\ndata, reuses the newest matching account, and bills from the activation date.\nActivation records the account it used (`applied_at`), which makes the setup\nread-only and keeps a re-fired event on the same account.\n\n| | |\n|---|---|\n| API | `GET` / `PUT /api/cpq_billing_connector/order-setups/:orderId` |\n| Command | `cpq_billing_connector.order_setup.save` (undoable) |\n| ACL | `cpq_billing_connector.order_setup.view`, `cpq_billing_connector.order_setup.manage` |\n| DI | `cpqBillingOrderSetupService` |\n\nWithout the connector, CPQ's spot stays empty and the order page looks as it\nalways did — CPQ never references billing.\n\n## Status\n\n**Built — publishing soon** (alongside `@dainamite/billing`; not yet on npm).\nAll six subscribers are wired end-to-end — `@dainamite/cpq` emits the\nmatching events (`cpq.subscription.activated` on new-sale activation,\nthe ARC events on amend / renew / cancel / merge). Proration math lives\nin this package: the `amended` subscriber derives the bill cycle from\nthe billing account via billing's `cycleContai","modules":[{"id":"cpq_billing_connector","title":"CPQ → Billing Connector","description":null,"requires":[{"raw":"cpq","resolvesTo":null},{"raw":"billing","resolvesTo":null},{"raw":"auth","resolvesTo":"core:auth"},{"raw":"directory","resolvesTo":"core:directory"}],"ejectable":false,"data":{"entities":[{"id":"cpq_billing_connector:cpq_billing_order_setup","table":"cpq_billing_connector_order_setups","src":{"file":"src/modules/cpq_billing_connector/data/entities.ts","line":31}}],"migrations":{"count":1,"first":"2026-11-15","last":"2026-11-15"},"customEntities":0},"http":{"routes":[{"method":"GET","path":"/api/cpq_billing_connector/order-setups/[orderId]","requireAuth":true,"requireFeatures":["cpq_billing_connector.order_setup.view"],"hasOpenApi":true,"src":{"file":"src/modules/cpq_billing_connector/api/order-setups/[orderId]/route.ts","line":79}},{"method":"PUT","path":"/api/cpq_billing_connector/order-setups/[orderId]","requireAuth":true,"requireFeatures":["cpq_billing_connector.order_setup.manage"],"hasOpenApi":true,"src":{"file":"src/modules/cpq_billing_connector/api/order-setups/[orderId]/route.ts","line":96}}],"legacyRouteFiles":0,"authResolved":1},"security":{"aclFeatures":["cpq_billing_connector.order_setup.view","cpq_billing_connector.order_setup.manage"],"setupDefaultRoleFeatures":true},"events":{"emits":[],"subscribes":[{"event":"cpq.subscription.activated","src":{"file":"src/modules/cpq_billing_connector/subscribers/cpq-subscription-activated.ts","line":18}},{"event":"cpq.subscription.amended","src":{"file":"src/modules/cpq_billing_connector/subscribers/cpq-subscription-amended.ts","line":13}},{"event":"cpq.subscription.cancelled","src":{"file":"src/modules/cpq_billing_connector/subscribers/cpq-subscription-cancelled.ts","line":7}},{"event":"cpq.subscription.merged","src":{"file":"src/modules/cpq_billing_connector/subscribers/cpq-subscription-merged.ts","line":5}},{"event":"cpq.subscription.renewed","src":{"file":"src/modules/cpq_billing_connector/subscribers/cpq-subscription-renewed.ts","line":11}},{"event":"cpq.subscription.superseded","src":{"file":"src/modules/cpq_billing_connector/subscribers/cpq-subscription-superseded.ts","line":7}}]},"ui":{"backendPages":[],"frontendPages":[],"widgets":1,"extensionHosts":1},"background":{"workers":[],"cli":[]},"ai":{"tools":[],"agents":[]},"config":{"credentials":[],"env":[]},"network":{"hosts":[],"undeclared":[]},"extends":[{"kind":"mutation-guard","target":"cpq.order"},{"kind":"subscriber","target":"cpq.subscription.activated"},{"kind":"subscriber","target":"cpq.subscription.amended"},{"kind":"subscriber","target":"cpq.subscription.cancelled"},{"kind":"subscriber","target":"cpq.subscription.merged"},{"kind":"subscriber","target":"cpq.subscription.renewed"},{"kind":"subscriber","target":"cpq.subscription.superseded"},{"kind":"widget","target":"cpq.order.detail:tabs"}],"omImports":{"@open-mercato/ai-assistant":{"modules/ai_assistant/lib/ai-agent-definition":["AiAgentDefinition","AiAgentExtension"],"modules/ai_assistant/lib/ai-api-operation-runner":["(dynamic)"],"modules/ai_assistant/lib/types":["AiToolDefinition"]},"@open-mercato/core":{"modules/directory/utils/organizationScope":["resolveFeatureCheckContext"]},"@open-mercato/shared":{"lib/auth/server":["getAuthFromRequest"],"lib/commands":["CommandBus","CommandHandler","CommandRuntimeContext","registerCommand"],"lib/commands/command-bus":["CommandBus"],"lib/commands/operationMetadata":["serializeOperationMetadata"],"lib/commands/scope":["ensureOrganizationScope","ensureTenantScope"],"lib/commands/undo":["extractUndoPayload"],"lib/crud/mutation-guard-registry":["MutationGuard","MutationGuardInput","MutationGuardResult"],"lib/crud/route-mutation-guard":["runRouteMutationGuards"],"lib/di/container":["AppContainer","createRequestContainer"],"lib/i18n/context":["useLocale","useT"],"lib/i18n/server":["resolveTranslations"],"lib/openapi":["OpenApiRouteDoc"],"modules/entities":["CustomEntitySpec"],"modules/registry":["ModuleInfo"],"modules/setup":["ModuleSetupConfig"],"modules/widgets/injection":["InjectionWidgetComponentProps","InjectionWidgetModule","ModuleInjectionTable"]},"@open-mercato/ui":{"backend/FlashMessages":["flash"],"backend/detail":["ErrorMessage","LoadingMessage"],"backend/injection/useGuardedMutation":["useGuardedMutation"],"backend/utils/apiCall":["apiCall","apiCallOrThrow"],"primitives/alert":["Alert","AlertDescription"],"primitives/button":["Button"],"primitives/input":["Input"],"primitives/label":["Label"],"primitives/radio":["Radio","RadioGroup"],"primitives/select":["Select","SelectContent","SelectItem","SelectTrigger","SelectValue"]}},"collisionKeys":{"moduleId":"cpq_billing_connector","tables":["cpq_billing_connector_order_setups"],"aclFeatures":["cpq_billing_connector.order_setup.view","cpq_billing_connector.order_setup.manage"],"eventIds":[],"backendRoutes":[]},"publicRoutes":0,"glyph":"2212002","lint":[{"code":"no-agents-md","severity":"info","message":"No AGENTS.md in the package.","anchor":"g3 §3","src":null},{"code":"ships-tests","severity":"info","message":"The tarball ships test files.","anchor":null,"src":null},{"code":"version-drift","severity":"info","message":"ModuleInfo says 0.1.0, package.json says 5.2.0.","anchor":null,"src":{"file":"src/modules/cpq_billing_connector/index.ts","line":4}}]}],"coverage":{"routesAuthResolved":1,"integrationTs":"absent"},"diagnostics":[]}
