{"factsVersion":1,"extractor":{"engine":"@open-mercato/cli@0.9.0 extractModuleFacts","factsContractVersion":2,"catalog":"om-modules rentgen 5","durationMs":81},"package":{"locator":"npm:@dainamite/cpq-billing-connector","name":"@dainamite/cpq-billing-connector","version":"5.4.0","integrity":"sha512-TjXeLqJPqrK1YEEbKLJhUI88FCM9huo/sIteOj/YGdxVDvRUveAFEzaFkAC/38VaEx28nokeO/f65daz2KUPbQ==","source":"npm-tarball","gitRef":"87cdd1bfd110a9df42d399817622e9545be465a9"},"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`), one UI (the\n**Billing** tab on the CPQ order detail page, see below) and two notification\ntypes for what billing could not take (refused charge, status not recorded).\nEverything else is event glue. Engines: **Node ≥ 24**.\n\nThe connector subscribes to eight 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 Billing Items that run to the old term end; end the Items of removed subscription items the day before the new term; 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| `cpq.subscription_item.status_changed` | Pause / suspend / grace → a billing line status period on every recurring Billing Item of the affected items (also future-dated: CPQ sends it when the action is taken); resume → the period in force on `fromDate` ends the day before; `cancelledScheduled` → those scheduled periods are removed first (other later periods untouched) |\n| `cpq.subscription.terminated` | End the Billing Items like `cancelled`: `wholeSubscription: true` (decided by CPQ at emit time) → every Billing Item of the subscription; `false` / absent → only the listed items and their devices. CPQ's current status is never read, so a replayed item-level terminate cannot end the other items |\n\n### Line period, price phases and line status (contract C3)\n\nSpecs: [line period and status](../../.ai/specs/2026-11-26-billing-line-period-and-status.md) and\n[price phases](../../.ai/specs/2026-11-26-billing-price-phases-ramp-deals.md), Phase 3.\nMapping in `lib/chargeMapper.ts`; full contract in `.ai/runs/2026-11-26-billing-cpq-flex/PLAN.md`.\n\n- **Own billing period.** A recurring charge's `billingPeriod` becomes the item's\n  period: absent or every 1 month → none (follows the account cycle, as before);\n  `{month, N}` → `monthly` / N; `{year, N}` → `annually` / N. A month count above\n  billing's 24-month cap that is whole years (e.g. 36) goes out as `annually` / 3.\n- **sourceRef.** The every-1-month charge keeps `cpq-<sub>-<item>-recurring`\n  byte for byte (idempotency of earlier events); other periods append the period\n  key: `…-recurring-1y`, `…-recurring-3m`. ARC re-rates use\n  `…-recurring-rerate-<order>` plus the same suffix. The rule applies to\n  activation, ARC `addedItems` and `changedItems`; a changed item split per\n  period gets one new Billing Item per period, and all its old recurring items end.\n- **Price phases.** `charges[].phases` (CPQ's merged schedule) are sent in the\n  same create write as billing phases: `durationUnit: 'month'`,\n  `durationCount: months`, `priceType: 'fixed'`, `value` per","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":19}},{"event":"cpq.subscription.amended","src":{"file":"src/modules/cpq_billing_connector/subscribers/cpq-subscription-amended.ts","line":17}},{"event":"cpq.subscription.cancelled","src":{"file":"src/modules/cpq_billing_connector/subscribers/cpq-subscription-cancelled.ts","line":7}},{"event":"cpq.subscription_item.status_changed","src":{"file":"src/modules/cpq_billing_connector/subscribers/cpq-subscription-item-status-changed.ts","line":16}},{"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":18}},{"event":"cpq.subscription.superseded","src":{"file":"src/modules/cpq_billing_connector/subscribers/cpq-subscription-superseded.ts","line":7}},{"event":"cpq.subscription.terminated","src":{"file":"src/modules/cpq_billing_connector/subscribers/cpq-subscription-terminated.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_item.status_changed"},{"kind":"subscriber","target":"cpq.subscription.merged"},{"kind":"subscriber","target":"cpq.subscription.renewed"},{"kind":"subscriber","target":"cpq.subscription.superseded"},{"kind":"subscriber","target":"cpq.subscription.terminated"},{"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"],"modules/notifications/lib/notificationService":["(dynamic)"]},"@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":["(dynamic)","resolveTranslations"],"lib/openapi":["OpenApiRouteDoc"],"modules/entities":["CustomEntitySpec"],"modules/notifications/types":["NotificationTypeDefinition"],"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":"2212003","lint":[{"code":"no-agents-md","severity":"info","message":"No AGENTS.md in the package.","anchor":"g3 §3","src":null},{"code":"peer-range-behind","severity":"info","message":"Built for ^0.9.0 does not include Open Mercato 0.10.1.","anchor":"w4 §4.2","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.4.0.","anchor":null,"src":{"file":"src/modules/cpq_billing_connector/index.ts","line":4}}]}],"coverage":{"routesAuthResolved":1,"integrationTs":"absent"},"diagnostics":[]}
