@contractspec/example.crm-pipeline 1.46.1 → 1.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/.turbo/turbo-build$colon$bundle.log +106 -31
  2. package/.turbo/turbo-build.log +109 -34
  3. package/CHANGELOG.md +44 -0
  4. package/dist/crm-pipeline.feature.d.ts +2 -2
  5. package/dist/crm-pipeline.feature.d.ts.map +1 -1
  6. package/dist/crm-pipeline.feature.js +9 -2
  7. package/dist/crm-pipeline.feature.js.map +1 -1
  8. package/dist/deal/deal.operation.d.ts +6 -6
  9. package/dist/deal/deal.test-spec.d.ts +8 -0
  10. package/dist/deal/deal.test-spec.d.ts.map +1 -0
  11. package/dist/deal/deal.test-spec.js +65 -0
  12. package/dist/deal/deal.test-spec.js.map +1 -0
  13. package/dist/entities/company.entity.d.ts +28 -28
  14. package/dist/entities/contact.entity.d.ts +32 -32
  15. package/dist/entities/index.js.map +1 -1
  16. package/dist/entities/task.entity.d.ts +43 -43
  17. package/dist/events/contact.event.d.ts +8 -8
  18. package/dist/events/contact.event.js +1 -1
  19. package/dist/events/deal.event.d.ts +5 -5
  20. package/dist/events/deal.event.js +1 -1
  21. package/dist/events/task.event.d.ts +2 -2
  22. package/dist/events/task.event.d.ts.map +1 -1
  23. package/dist/events/task.event.js +1 -1
  24. package/dist/example.d.ts +2 -2
  25. package/dist/example.d.ts.map +1 -1
  26. package/dist/example.js +4 -2
  27. package/dist/example.js.map +1 -1
  28. package/dist/handlers/crm.handlers.d.ts +89 -0
  29. package/dist/handlers/crm.handlers.d.ts.map +1 -0
  30. package/dist/handlers/crm.handlers.js +172 -0
  31. package/dist/handlers/crm.handlers.js.map +1 -0
  32. package/dist/handlers/deal.handlers.js.map +1 -1
  33. package/dist/handlers/index.d.ts +2 -1
  34. package/dist/handlers/index.js +2 -1
  35. package/dist/handlers/mock-data.js.map +1 -1
  36. package/dist/index.d.ts +14 -1
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +14 -1
  39. package/dist/index.js.map +1 -1
  40. package/dist/presentations/dashboard.presentation.d.ts +3 -4
  41. package/dist/presentations/dashboard.presentation.d.ts.map +1 -1
  42. package/dist/presentations/dashboard.presentation.js +8 -5
  43. package/dist/presentations/dashboard.presentation.js.map +1 -1
  44. package/dist/presentations/pipeline.presentation.d.ts +5 -6
  45. package/dist/presentations/pipeline.presentation.d.ts.map +1 -1
  46. package/dist/presentations/pipeline.presentation.js +12 -9
  47. package/dist/presentations/pipeline.presentation.js.map +1 -1
  48. package/dist/seeders/index.d.ts +10 -0
  49. package/dist/seeders/index.d.ts.map +1 -0
  50. package/dist/seeders/index.js +47 -0
  51. package/dist/seeders/index.js.map +1 -0
  52. package/dist/shared/overlay-types.d.ts +34 -0
  53. package/dist/shared/overlay-types.d.ts.map +1 -0
  54. package/dist/shared/overlay-types.js +0 -0
  55. package/dist/ui/CrmDashboard.d.ts +7 -0
  56. package/dist/ui/CrmDashboard.d.ts.map +1 -0
  57. package/dist/ui/CrmDashboard.js +304 -0
  58. package/dist/ui/CrmDashboard.js.map +1 -0
  59. package/dist/ui/CrmDealCard.d.ts +15 -0
  60. package/dist/ui/CrmDealCard.d.ts.map +1 -0
  61. package/dist/ui/CrmDealCard.js +49 -0
  62. package/dist/ui/CrmDealCard.js.map +1 -0
  63. package/dist/ui/CrmPipelineBoard.d.ts +23 -0
  64. package/dist/ui/CrmPipelineBoard.d.ts.map +1 -0
  65. package/dist/ui/CrmPipelineBoard.js +98 -0
  66. package/dist/ui/CrmPipelineBoard.js.map +1 -0
  67. package/dist/ui/hooks/index.d.ts +3 -0
  68. package/dist/ui/hooks/index.js +6 -0
  69. package/dist/ui/hooks/useDealList.d.ts +35 -0
  70. package/dist/ui/hooks/useDealList.d.ts.map +1 -0
  71. package/dist/ui/hooks/useDealList.js +94 -0
  72. package/dist/ui/hooks/useDealList.js.map +1 -0
  73. package/dist/ui/hooks/useDealMutations.d.ts +26 -0
  74. package/dist/ui/hooks/useDealMutations.d.ts.map +1 -0
  75. package/dist/ui/hooks/useDealMutations.js +159 -0
  76. package/dist/ui/hooks/useDealMutations.js.map +1 -0
  77. package/dist/ui/index.d.ts +14 -0
  78. package/dist/ui/index.js +15 -0
  79. package/dist/ui/modals/CreateDealModal.d.ts +33 -0
  80. package/dist/ui/modals/CreateDealModal.d.ts.map +1 -0
  81. package/dist/ui/modals/CreateDealModal.js +183 -0
  82. package/dist/ui/modals/CreateDealModal.js.map +1 -0
  83. package/dist/ui/modals/DealActionsModal.d.ts +51 -0
  84. package/dist/ui/modals/DealActionsModal.d.ts.map +1 -0
  85. package/dist/ui/modals/DealActionsModal.js +372 -0
  86. package/dist/ui/modals/DealActionsModal.js.map +1 -0
  87. package/dist/ui/modals/index.d.ts +3 -0
  88. package/dist/ui/modals/index.js +4 -0
  89. package/dist/ui/overlays/demo-overlays.d.ts +19 -0
  90. package/dist/ui/overlays/demo-overlays.d.ts.map +1 -0
  91. package/dist/ui/overlays/demo-overlays.js +68 -0
  92. package/dist/ui/overlays/demo-overlays.js.map +1 -0
  93. package/dist/ui/overlays/index.d.ts +2 -0
  94. package/dist/ui/overlays/index.js +3 -0
  95. package/dist/ui/renderers/index.d.ts +3 -0
  96. package/dist/ui/renderers/index.js +4 -0
  97. package/dist/ui/renderers/pipeline.markdown.d.ts +23 -0
  98. package/dist/ui/renderers/pipeline.markdown.d.ts.map +1 -0
  99. package/dist/ui/renderers/pipeline.markdown.js +118 -0
  100. package/dist/ui/renderers/pipeline.markdown.js.map +1 -0
  101. package/dist/ui/renderers/pipeline.renderer.d.ts +9 -0
  102. package/dist/ui/renderers/pipeline.renderer.d.ts.map +1 -0
  103. package/dist/ui/renderers/pipeline.renderer.js +28 -0
  104. package/dist/ui/renderers/pipeline.renderer.js.map +1 -0
  105. package/package.json +38 -13
  106. package/src/crm-pipeline.feature.ts +3 -3
  107. package/src/deal/deal.test-spec.ts +55 -0
  108. package/src/example.ts +3 -3
  109. package/src/handlers/crm.handlers.ts +415 -0
  110. package/src/handlers/index.ts +3 -0
  111. package/src/index.ts +1 -0
  112. package/src/presentations/dashboard.presentation.ts +5 -6
  113. package/src/presentations/pipeline.presentation.ts +9 -10
  114. package/src/seeders/index.ts +35 -0
  115. package/src/shared/overlay-types.ts +39 -0
  116. package/src/ui/CrmDashboard.tsx +311 -0
  117. package/src/ui/CrmDealCard.tsx +83 -0
  118. package/src/ui/CrmPipelineBoard.tsx +136 -0
  119. package/src/ui/hooks/index.ts +10 -0
  120. package/src/ui/hooks/useDealList.ts +113 -0
  121. package/src/ui/hooks/useDealMutations.ts +174 -0
  122. package/src/ui/index.ts +18 -0
  123. package/src/ui/modals/CreateDealModal.tsx +239 -0
  124. package/src/ui/modals/DealActionsModal.tsx +424 -0
  125. package/src/ui/modals/index.ts +2 -0
  126. package/src/ui/overlays/demo-overlays.ts +68 -0
  127. package/src/ui/overlays/index.ts +1 -0
  128. package/src/ui/renderers/index.ts +6 -0
  129. package/src/ui/renderers/pipeline.markdown.ts +198 -0
  130. package/src/ui/renderers/pipeline.renderer.tsx +35 -0
  131. package/tsconfig.json +1 -1
  132. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DealActionsModal.js","names":[],"sources":["../../../src/ui/modals/DealActionsModal.tsx"],"sourcesContent":["'use client';\n\n/**\n * DealActionsModal - Actions for a specific deal (Win, Lose, Move)\n *\n * Wires to WinDealContract, LoseDealContract, MoveDealContract\n * via useDealMutations hook.\n */\nimport { useState } from 'react';\nimport { Button } from '@contractspec/lib.design-system';\n\n// Local type definitions for modal props\nexport interface Deal {\n id: string;\n name: string;\n value: number;\n currency: string;\n stageId: string;\n status: 'OPEN' | 'WON' | 'LOST' | 'STALE';\n}\n\nexport interface WinDealInput {\n dealId: string;\n wonSource?: string;\n notes?: string;\n}\n\nexport interface LoseDealInput {\n dealId: string;\n lostReason: string;\n notes?: string;\n}\n\nexport interface MoveDealInput {\n dealId: string;\n stageId: string;\n}\n\ntype ActionMode = 'menu' | 'win' | 'lose' | 'move';\n\ninterface DealActionsModalProps {\n isOpen: boolean;\n deal: Deal | null;\n stages: { id: string; name: string }[];\n onClose: () => void;\n onWin: (input: WinDealInput) => Promise<void>;\n onLose: (input: LoseDealInput) => Promise<void>;\n onMove: (input: MoveDealInput) => Promise<void>;\n isLoading?: boolean;\n}\n\nfunction formatCurrency(value: number, currency: string): string {\n return new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency,\n minimumFractionDigits: 0,\n maximumFractionDigits: 0,\n }).format(value);\n}\n\nexport function DealActionsModal({\n isOpen,\n deal,\n stages,\n onClose,\n onWin,\n onLose,\n onMove,\n isLoading = false,\n}: DealActionsModalProps) {\n const [mode, setMode] = useState<ActionMode>('menu');\n const [wonSource, setWonSource] = useState('');\n const [lostReason, setLostReason] = useState('');\n const [notes, setNotes] = useState('');\n const [selectedStageId, setSelectedStageId] = useState('');\n const [error, setError] = useState<string | null>(null);\n\n const resetForm = () => {\n setMode('menu');\n setWonSource('');\n setLostReason('');\n setNotes('');\n setSelectedStageId('');\n setError(null);\n };\n\n const handleClose = () => {\n resetForm();\n onClose();\n };\n\n const handleWin = async () => {\n if (!deal) return;\n setError(null);\n\n try {\n await onWin({\n dealId: deal.id,\n wonSource: wonSource.trim() || undefined,\n notes: notes.trim() || undefined,\n });\n handleClose();\n } catch (err) {\n setError(\n err instanceof Error ? err.message : 'Failed to mark deal as won'\n );\n }\n };\n\n const handleLose = async () => {\n if (!deal) return;\n setError(null);\n\n if (!lostReason.trim()) {\n setError('Please provide a reason for losing the deal');\n return;\n }\n\n try {\n await onLose({\n dealId: deal.id,\n lostReason: lostReason.trim(),\n notes: notes.trim() || undefined,\n });\n handleClose();\n } catch (err) {\n setError(\n err instanceof Error ? err.message : 'Failed to mark deal as lost'\n );\n }\n };\n\n const handleMove = async () => {\n if (!deal) return;\n setError(null);\n\n if (!selectedStageId) {\n setError('Please select a stage');\n return;\n }\n\n if (selectedStageId === deal.stageId) {\n setError('Deal is already in this stage');\n return;\n }\n\n try {\n await onMove({\n dealId: deal.id,\n stageId: selectedStageId,\n });\n handleClose();\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to move deal');\n }\n };\n\n if (!isOpen || !deal) return null;\n\n return (\n <div className=\"fixed inset-0 z-50 flex items-center justify-center\">\n {/* Backdrop */}\n <div\n className=\"bg-background/80 absolute inset-0 backdrop-blur-sm\"\n onClick={handleClose}\n role=\"button\"\n tabIndex={0}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') handleClose();\n }}\n aria-label=\"Close modal\"\n />\n\n {/* Modal */}\n <div className=\"bg-card border-border relative z-10 w-full max-w-md rounded-xl border p-6 shadow-xl\">\n {/* Deal Header */}\n <div className=\"border-border mb-4 border-b pb-4\">\n <h2 className=\"text-xl font-semibold\">{deal.name}</h2>\n <p className=\"text-primary text-lg font-medium\">\n {formatCurrency(deal.value, deal.currency)}\n </p>\n <span\n className={`mt-2 inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${\n deal.status === 'WON'\n ? 'bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400'\n : deal.status === 'LOST'\n ? 'bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400'\n : 'bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400'\n }`}\n >\n {deal.status}\n </span>\n </div>\n\n {/* Main Menu */}\n {mode === 'menu' && (\n <div className=\"space-y-3\">\n {deal.status === 'OPEN' && (\n <>\n <Button\n className=\"w-full justify-start\"\n variant=\"ghost\"\n onPress={() => setMode('win')}\n >\n <span className=\"mr-2\">🏆</span> Mark as Won\n </Button>\n <Button\n className=\"w-full justify-start\"\n variant=\"ghost\"\n onPress={() => setMode('lose')}\n >\n <span className=\"mr-2\">❌</span> Mark as Lost\n </Button>\n <Button\n className=\"w-full justify-start\"\n variant=\"ghost\"\n onPress={() => {\n setSelectedStageId(deal.stageId);\n setMode('move');\n }}\n >\n <span className=\"mr-2\">➡️</span> Move to Stage\n </Button>\n </>\n )}\n {deal.status !== 'OPEN' && (\n <p className=\"text-muted-foreground py-4 text-center\">\n This deal is already {deal.status.toLowerCase()}. No actions\n available.\n </p>\n )}\n <div className=\"border-border border-t pt-3\">\n <Button\n className=\"w-full\"\n variant=\"outline\"\n onPress={handleClose}\n >\n Close\n </Button>\n </div>\n </div>\n )}\n\n {/* Win Form */}\n {mode === 'win' && (\n <div className=\"space-y-4\">\n <div>\n <label\n htmlFor=\"won-source\"\n className=\"text-muted-foreground mb-1 block text-sm font-medium\"\n >\n How did you win this deal?\n </label>\n <select\n id=\"won-source\"\n value={wonSource}\n onChange={(e) => setWonSource(e.target.value)}\n className=\"border-input bg-background focus:ring-ring h-10 w-full rounded-md border px-3 py-2 text-sm focus:ring-2 focus:outline-none\"\n >\n <option value=\"\">Select a source...</option>\n <option value=\"referral\">Referral</option>\n <option value=\"cold_outreach\">Cold Outreach</option>\n <option value=\"inbound\">Inbound Lead</option>\n <option value=\"upsell\">Upsell</option>\n <option value=\"other\">Other</option>\n </select>\n </div>\n\n <div>\n <label\n htmlFor=\"win-notes\"\n className=\"text-muted-foreground mb-1 block text-sm font-medium\"\n >\n Notes (optional)\n </label>\n <textarea\n id=\"win-notes\"\n value={notes}\n onChange={(e) => setNotes(e.target.value)}\n placeholder=\"Any additional notes about the win...\"\n rows={3}\n className=\"border-input bg-background focus:ring-ring w-full rounded-md border px-3 py-2 text-sm focus:ring-2 focus:outline-none\"\n />\n </div>\n\n {error && (\n <div className=\"bg-destructive/10 text-destructive rounded-md p-3 text-sm\">\n {error}\n </div>\n )}\n\n <div className=\"flex justify-end gap-3 pt-2\">\n <Button\n variant=\"ghost\"\n onPress={() => setMode('menu')}\n disabled={isLoading}\n >\n Back\n </Button>\n <Button onPress={handleWin} disabled={isLoading}>\n {isLoading ? 'Processing...' : '🏆 Confirm Win'}\n </Button>\n </div>\n </div>\n )}\n\n {/* Lose Form */}\n {mode === 'lose' && (\n <div className=\"space-y-4\">\n <div>\n <label\n htmlFor=\"lost-reason\"\n className=\"text-muted-foreground mb-1 block text-sm font-medium\"\n >\n Why was this deal lost? *\n </label>\n <select\n id=\"lost-reason\"\n value={lostReason}\n onChange={(e) => setLostReason(e.target.value)}\n className=\"border-input bg-background focus:ring-ring h-10 w-full rounded-md border px-3 py-2 text-sm focus:ring-2 focus:outline-none\"\n >\n <option value=\"\">Select a reason...</option>\n <option value=\"price\">Price too high</option>\n <option value=\"competitor\">Lost to competitor</option>\n <option value=\"no_budget\">No budget</option>\n <option value=\"no_decision\">No decision made</option>\n <option value=\"timing\">Bad timing</option>\n <option value=\"product_fit\">Product not a fit</option>\n <option value=\"other\">Other</option>\n </select>\n </div>\n\n <div>\n <label\n htmlFor=\"lose-notes\"\n className=\"text-muted-foreground mb-1 block text-sm font-medium\"\n >\n Notes (optional)\n </label>\n <textarea\n id=\"lose-notes\"\n value={notes}\n onChange={(e) => setNotes(e.target.value)}\n placeholder=\"Any additional details...\"\n rows={3}\n className=\"border-input bg-background focus:ring-ring w-full rounded-md border px-3 py-2 text-sm focus:ring-2 focus:outline-none\"\n />\n </div>\n\n {error && (\n <div className=\"bg-destructive/10 text-destructive rounded-md p-3 text-sm\">\n {error}\n </div>\n )}\n\n <div className=\"flex justify-end gap-3 pt-2\">\n <Button\n variant=\"ghost\"\n onPress={() => setMode('menu')}\n disabled={isLoading}\n >\n Back\n </Button>\n <Button\n variant=\"destructive\"\n onPress={handleLose}\n disabled={isLoading}\n >\n {isLoading ? 'Processing...' : '❌ Confirm Loss'}\n </Button>\n </div>\n </div>\n )}\n\n {/* Move Form */}\n {mode === 'move' && (\n <div className=\"space-y-4\">\n <div>\n <label\n htmlFor=\"move-stage\"\n className=\"text-muted-foreground mb-1 block text-sm font-medium\"\n >\n Move to Stage\n </label>\n <select\n id=\"move-stage\"\n value={selectedStageId}\n onChange={(e) => setSelectedStageId(e.target.value)}\n className=\"border-input bg-background focus:ring-ring h-10 w-full rounded-md border px-3 py-2 text-sm focus:ring-2 focus:outline-none\"\n >\n {stages.map((stage) => (\n <option key={stage.id} value={stage.id}>\n {stage.name}\n {stage.id === deal.stageId ? ' (current)' : ''}\n </option>\n ))}\n </select>\n </div>\n\n {error && (\n <div className=\"bg-destructive/10 text-destructive rounded-md p-3 text-sm\">\n {error}\n </div>\n )}\n\n <div className=\"flex justify-end gap-3 pt-2\">\n <Button\n variant=\"ghost\"\n onPress={() => setMode('menu')}\n disabled={isLoading}\n >\n Back\n </Button>\n <Button onPress={handleMove} disabled={isLoading}>\n {isLoading ? 'Moving...' : '➡️ Move Deal'}\n </Button>\n </div>\n </div>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAmDA,SAAS,eAAe,OAAe,UAA0B;AAC/D,QAAO,IAAI,KAAK,aAAa,SAAS;EACpC,OAAO;EACP;EACA,uBAAuB;EACvB,uBAAuB;EACxB,CAAC,CAAC,OAAO,MAAM;;AAGlB,SAAgB,iBAAiB,EAC/B,QACA,MACA,QACA,SACA,OACA,QACA,QACA,YAAY,SACY;CACxB,MAAM,CAAC,MAAM,WAAW,SAAqB,OAAO;CACpD,MAAM,CAAC,WAAW,gBAAgB,SAAS,GAAG;CAC9C,MAAM,CAAC,YAAY,iBAAiB,SAAS,GAAG;CAChD,MAAM,CAAC,OAAO,YAAY,SAAS,GAAG;CACtC,MAAM,CAAC,iBAAiB,sBAAsB,SAAS,GAAG;CAC1D,MAAM,CAAC,OAAO,YAAY,SAAwB,KAAK;CAEvD,MAAM,kBAAkB;AACtB,UAAQ,OAAO;AACf,eAAa,GAAG;AAChB,gBAAc,GAAG;AACjB,WAAS,GAAG;AACZ,qBAAmB,GAAG;AACtB,WAAS,KAAK;;CAGhB,MAAM,oBAAoB;AACxB,aAAW;AACX,WAAS;;CAGX,MAAM,YAAY,YAAY;AAC5B,MAAI,CAAC,KAAM;AACX,WAAS,KAAK;AAEd,MAAI;AACF,SAAM,MAAM;IACV,QAAQ,KAAK;IACb,WAAW,UAAU,MAAM,I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AU;iBACX;QAEO,EACR,oBAAC;OACC,IAAG;OACH,OAAO;OACP,WAAW,MAAM,mBAAmB,EAAE,OAAO,MAAM;OACnD,WAAU;iBAET,OAAO,KAAK,UACX,qBAAC;QAAsB,OAAO,MAAM;mBACjC,MAAM,MACN,MAAM,OAAO,KAAK,UAAU,eAAe;UAFjC,MAAM,GAGV,CACT;QACK,IACL;MAEL,SACC,oBAAC;OAAI,WAAU;iBACZ;QACG;MAGR,qBAAC;OAAI,WAAU;kBACb,oBAAC;QACC,SAAQ;QACR,eAAe,QAAQ,OAAO;QAC9B,UAAU;kBACX;SAEQ,EACT,oBAAC;QAAO,SAAS;QAAY,UAAU;kBACpC,YAAY,cAAc;SACpB;QACL;;MACF;;IAEJ;GACF"}
@@ -0,0 +1,3 @@
1
+ import { CreateDealModal } from "./CreateDealModal.js";
2
+ import { DealActionsModal } from "./DealActionsModal.js";
3
+ export { CreateDealModal, DealActionsModal };
@@ -0,0 +1,4 @@
1
+ import { CreateDealModal } from "./CreateDealModal.js";
2
+ import { DealActionsModal } from "./DealActionsModal.js";
3
+
4
+ export { CreateDealModal, DealActionsModal };
@@ -0,0 +1,19 @@
1
+ import { OverlayDefinition } from "../../shared/overlay-types.js";
2
+
3
+ //#region src/ui/overlays/demo-overlays.d.ts
4
+
5
+ /**
6
+ * Demo user overlay - sample data mode
7
+ */
8
+ declare const crmDemoOverlay: OverlayDefinition;
9
+ /**
10
+ * Sales rep overlay - focused view for sales
11
+ */
12
+ declare const crmSalesRepOverlay: OverlayDefinition;
13
+ /**
14
+ * All overlays for crm-pipeline
15
+ */
16
+ declare const crmOverlays: OverlayDefinition[];
17
+ //#endregion
18
+ export { crmDemoOverlay, crmOverlays, crmSalesRepOverlay };
19
+ //# sourceMappingURL=demo-overlays.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"demo-overlays.d.ts","names":[],"sources":["../../../src/ui/overlays/demo-overlays.ts"],"sourcesContent":[],"mappings":";;;;;;;cAWa,gBAAgB;;;;cA+BhB,oBAAoB;;;;cAsBpB,aAAa"}
@@ -0,0 +1,68 @@
1
+ //#region src/ui/overlays/demo-overlays.ts
2
+ /**
3
+ * Demo user overlay - sample data mode
4
+ */
5
+ const crmDemoOverlay = {
6
+ overlayId: "crm-pipeline.demo-user",
7
+ version: "1.0.0",
8
+ description: "Demo mode with sample data",
9
+ appliesTo: {
10
+ feature: "crm-pipeline",
11
+ role: "demo"
12
+ },
13
+ modifications: [
14
+ {
15
+ type: "hideField",
16
+ field: "importButton",
17
+ reason: "Not available in demo"
18
+ },
19
+ {
20
+ type: "hideField",
21
+ field: "exportButton",
22
+ reason: "Not available in demo"
23
+ },
24
+ {
25
+ type: "addBadge",
26
+ position: "header",
27
+ label: "Demo Mode",
28
+ variant: "warning"
29
+ }
30
+ ]
31
+ };
32
+ /**
33
+ * Sales rep overlay - focused view for sales
34
+ */
35
+ const crmSalesRepOverlay = {
36
+ overlayId: "crm-pipeline.sales-rep",
37
+ version: "1.0.0",
38
+ description: "Sales rep focused view",
39
+ appliesTo: {
40
+ feature: "crm-pipeline",
41
+ role: "sales-rep"
42
+ },
43
+ modifications: [
44
+ {
45
+ type: "hideField",
46
+ field: "teamMetrics",
47
+ reason: "Team metrics for managers only"
48
+ },
49
+ {
50
+ type: "hideField",
51
+ field: "pipelineSettings",
52
+ reason: "Admin only"
53
+ },
54
+ {
55
+ type: "renameLabel",
56
+ field: "deals",
57
+ newLabel: "My Deals"
58
+ }
59
+ ]
60
+ };
61
+ /**
62
+ * All overlays for crm-pipeline
63
+ */
64
+ const crmOverlays = [crmDemoOverlay, crmSalesRepOverlay];
65
+
66
+ //#endregion
67
+ export { crmDemoOverlay, crmOverlays, crmSalesRepOverlay };
68
+ //# sourceMappingURL=demo-overlays.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"demo-overlays.js","names":[],"sources":["../../../src/ui/overlays/demo-overlays.ts"],"sourcesContent":["/**\n * Demo Overlay Definitions for CRM Pipeline\n *\n * These overlays customize the presentation for different contexts\n * (e.g., demo users, different roles).\n */\nimport type { OverlayDefinition } from '../../shared/overlay-types';\n\n/**\n * Demo user overlay - sample data mode\n */\nexport const crmDemoOverlay: OverlayDefinition = {\n overlayId: 'crm-pipeline.demo-user',\n version: '1.0.0',\n description: 'Demo mode with sample data',\n appliesTo: {\n feature: 'crm-pipeline',\n role: 'demo',\n },\n modifications: [\n {\n type: 'hideField',\n field: 'importButton',\n reason: 'Not available in demo',\n },\n {\n type: 'hideField',\n field: 'exportButton',\n reason: 'Not available in demo',\n },\n {\n type: 'addBadge',\n position: 'header',\n label: 'Demo Mode',\n variant: 'warning',\n },\n ],\n};\n\n/**\n * Sales rep overlay - focused view for sales\n */\nexport const crmSalesRepOverlay: OverlayDefinition = {\n overlayId: 'crm-pipeline.sales-rep',\n version: '1.0.0',\n description: 'Sales rep focused view',\n appliesTo: {\n feature: 'crm-pipeline',\n role: 'sales-rep',\n },\n modifications: [\n {\n type: 'hideField',\n field: 'teamMetrics',\n reason: 'Team metrics for managers only',\n },\n { type: 'hideField', field: 'pipelineSettings', reason: 'Admin only' },\n { type: 'renameLabel', field: 'deals', newLabel: 'My Deals' },\n ],\n};\n\n/**\n * All overlays for crm-pipeline\n */\nexport const crmOverlays: OverlayDefinition[] = [\n crmDemoOverlay,\n crmSalesRepOverlay,\n];\n"],"mappings":";;;;AAWA,MAAa,iBAAoC;CAC/C,WAAW;CACX,SAAS;CACT,aAAa;CACb,WAAW;EACT,SAAS;EACT,MAAM;EACP;CACD,eAAe;EACb;GACE,MAAM;GACN,OAAO;GACP,QAAQ;GACT;EACD;GACE,MAAM;GACN,OAAO;GACP,QAAQ;GACT;EACD;GACE,MAAM;GACN,UAAU;GACV,OAAO;GACP,SAAS;GACV;EACF;CACF;;;;AAKD,MAAa,qBAAwC;CACnD,WAAW;CACX,SAAS;CACT,aAAa;CACb,WAAW;EACT,SAAS;EACT,MAAM;EACP;CACD,eAAe;EACb;GACE,MAAM;GACN,OAAO;GACP,QAAQ;GACT;EACD;GAAE,MAAM;GAAa,OAAO;GAAoB,QAAQ;GAAc;EACtE;GAAE,MAAM;GAAe,OAAO;GAAS,UAAU;GAAY;EAC9D;CACF;;;;AAKD,MAAa,cAAmC,CAC9C,gBACA,mBACD"}
@@ -0,0 +1,2 @@
1
+ import { crmDemoOverlay, crmOverlays, crmSalesRepOverlay } from "./demo-overlays.js";
2
+ export { crmDemoOverlay, crmOverlays, crmSalesRepOverlay };
@@ -0,0 +1,3 @@
1
+ import { crmDemoOverlay, crmOverlays, crmSalesRepOverlay } from "./demo-overlays.js";
2
+
3
+ export { crmDemoOverlay, crmOverlays, crmSalesRepOverlay };
@@ -0,0 +1,3 @@
1
+ import { crmPipelineReactRenderer } from "./pipeline.renderer.js";
2
+ import { crmDashboardMarkdownRenderer, crmPipelineMarkdownRenderer } from "./pipeline.markdown.js";
3
+ export { crmDashboardMarkdownRenderer, crmPipelineMarkdownRenderer, crmPipelineReactRenderer };
@@ -0,0 +1,4 @@
1
+ import { crmPipelineReactRenderer } from "./pipeline.renderer.js";
2
+ import { crmDashboardMarkdownRenderer, crmPipelineMarkdownRenderer } from "./pipeline.markdown.js";
3
+
4
+ export { crmDashboardMarkdownRenderer, crmPipelineMarkdownRenderer, crmPipelineReactRenderer };
@@ -0,0 +1,23 @@
1
+ import { PresentationRenderer } from "@contractspec/lib.contracts";
2
+
3
+ //#region src/ui/renderers/pipeline.markdown.d.ts
4
+
5
+ /**
6
+ * Markdown renderer for CRM Pipeline Kanban view (crm-pipeline.deal.pipeline)
7
+ * Only handles PipelineKanbanView component
8
+ */
9
+ declare const crmPipelineMarkdownRenderer: PresentationRenderer<{
10
+ mimeType: string;
11
+ body: string;
12
+ }>;
13
+ /**
14
+ * Markdown renderer for CRM Dashboard (crm-pipeline.dashboard)
15
+ * Only handles CrmDashboard component
16
+ */
17
+ declare const crmDashboardMarkdownRenderer: PresentationRenderer<{
18
+ mimeType: string;
19
+ body: string;
20
+ }>;
21
+ //#endregion
22
+ export { crmDashboardMarkdownRenderer, crmPipelineMarkdownRenderer };
23
+ //# sourceMappingURL=pipeline.markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.markdown.d.ts","names":[],"sources":["../../../src/ui/renderers/pipeline.markdown.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAsCa,6BAA6B;;;;;;;;cA0E7B,8BAA8B"}
@@ -0,0 +1,118 @@
1
+ import { mockGetPipelineStagesHandler, mockListDealsHandler } from "@contractspec/example.crm-pipeline/handlers";
2
+
3
+ //#region src/ui/renderers/pipeline.markdown.ts
4
+ function formatCurrency(value, currency = "USD") {
5
+ return new Intl.NumberFormat("en-US", {
6
+ style: "currency",
7
+ currency,
8
+ minimumFractionDigits: 0
9
+ }).format(value);
10
+ }
11
+ /**
12
+ * Markdown renderer for CRM Pipeline Kanban view (crm-pipeline.deal.pipeline)
13
+ * Only handles PipelineKanbanView component
14
+ */
15
+ const crmPipelineMarkdownRenderer = {
16
+ target: "markdown",
17
+ render: async (desc, _ctx) => {
18
+ if (desc.source.type !== "component" || desc.source.componentKey !== "PipelineKanbanView") throw new Error("crmPipelineMarkdownRenderer: not PipelineKanbanView");
19
+ const pipelineId = "pipeline-1";
20
+ const [dealsResult, stages] = await Promise.all([mockListDealsHandler({
21
+ pipelineId,
22
+ limit: 50
23
+ }), mockGetPipelineStagesHandler({ pipelineId })]);
24
+ const deals = dealsResult.deals;
25
+ const stageList = stages;
26
+ const dealsByStage = {};
27
+ for (const stage of stageList) dealsByStage[stage.id] = deals.filter((d) => d.stageId === stage.id && d.status === "OPEN");
28
+ const lines = [
29
+ "# CRM Pipeline",
30
+ "",
31
+ `**Total Value**: ${formatCurrency(dealsResult.totalValue)}`,
32
+ `**Total Deals**: ${dealsResult.total}`,
33
+ ""
34
+ ];
35
+ for (const stage of stageList.sort((a, b) => a.position - b.position)) {
36
+ const stageDeals = dealsByStage[stage.id] ?? [];
37
+ const stageValue = stageDeals.reduce((sum, d) => sum + d.value, 0);
38
+ lines.push(`## ${stage.name}`);
39
+ lines.push(`_${stageDeals.length} deals · ${formatCurrency(stageValue)}_`);
40
+ lines.push("");
41
+ if (stageDeals.length === 0) lines.push("_No deals_");
42
+ else for (const deal of stageDeals) lines.push(`- **${deal.name}** - ${formatCurrency(deal.value, deal.currency)}`);
43
+ lines.push("");
44
+ }
45
+ return {
46
+ mimeType: "text/markdown",
47
+ body: lines.join("\n")
48
+ };
49
+ }
50
+ };
51
+ /**
52
+ * Markdown renderer for CRM Dashboard (crm-pipeline.dashboard)
53
+ * Only handles CrmDashboard component
54
+ */
55
+ const crmDashboardMarkdownRenderer = {
56
+ target: "markdown",
57
+ render: async (desc, _ctx) => {
58
+ if (desc.source.type !== "component" || desc.source.componentKey !== "CrmDashboard") throw new Error("crmDashboardMarkdownRenderer: not CrmDashboard");
59
+ const pipelineId = "pipeline-1";
60
+ const [dealsResult, stages] = await Promise.all([mockListDealsHandler({
61
+ pipelineId,
62
+ limit: 100
63
+ }), mockGetPipelineStagesHandler({ pipelineId })]);
64
+ const deals = dealsResult.deals;
65
+ const stageList = stages;
66
+ const openDeals = deals.filter((d) => d.status === "OPEN");
67
+ const wonDeals = deals.filter((d) => d.status === "WON");
68
+ const lostDeals = deals.filter((d) => d.status === "LOST");
69
+ const openValue = openDeals.reduce((sum, d) => sum + d.value, 0);
70
+ const wonValue = wonDeals.reduce((sum, d) => sum + d.value, 0);
71
+ const lines = [
72
+ "# CRM Dashboard",
73
+ "",
74
+ "> Sales pipeline overview and key metrics",
75
+ "",
76
+ "## Summary",
77
+ "",
78
+ "| Metric | Value |",
79
+ "|--------|-------|",
80
+ `| Total Deals | ${dealsResult.total} |`,
81
+ `| Pipeline Value | ${formatCurrency(dealsResult.totalValue)} |`,
82
+ `| Open Deals | ${openDeals.length} (${formatCurrency(openValue)}) |`,
83
+ `| Won Deals | ${wonDeals.length} (${formatCurrency(wonValue)}) |`,
84
+ `| Lost Deals | ${lostDeals.length} |`,
85
+ "",
86
+ "## Pipeline Stages",
87
+ ""
88
+ ];
89
+ lines.push("| Stage | Deals | Value |");
90
+ lines.push("|-------|-------|-------|");
91
+ for (const stage of stageList.sort((a, b) => a.position - b.position)) {
92
+ const stageDeals = openDeals.filter((d) => d.stageId === stage.id);
93
+ const stageValue = stageDeals.reduce((sum, d) => sum + d.value, 0);
94
+ lines.push(`| ${stage.name} | ${stageDeals.length} | ${formatCurrency(stageValue)} |`);
95
+ }
96
+ lines.push("");
97
+ lines.push("## Recent Deals");
98
+ lines.push("");
99
+ const recentDeals = deals.slice(0, 10);
100
+ if (recentDeals.length === 0) lines.push("_No deals yet._");
101
+ else {
102
+ lines.push("| Deal | Value | Stage | Status |");
103
+ lines.push("|------|-------|-------|--------|");
104
+ for (const deal of recentDeals) {
105
+ const stage = stageList.find((s) => s.id === deal.stageId);
106
+ lines.push(`| ${deal.name} | ${formatCurrency(deal.value, deal.currency)} | ${stage?.name ?? "-"} | ${deal.status} |`);
107
+ }
108
+ }
109
+ return {
110
+ mimeType: "text/markdown",
111
+ body: lines.join("\n")
112
+ };
113
+ }
114
+ };
115
+
116
+ //#endregion
117
+ export { crmDashboardMarkdownRenderer, crmPipelineMarkdownRenderer };
118
+ //# sourceMappingURL=pipeline.markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.markdown.js","names":[],"sources":["../../../src/ui/renderers/pipeline.markdown.ts"],"sourcesContent":["/**\n * Markdown renderer for CRM Pipeline presentation\n *\n * Imports handlers from the hooks module to ensure correct build order.\n */\nimport type { PresentationRenderer } from '@contractspec/lib.contracts';\nimport {\n mockListDealsHandler,\n mockGetPipelineStagesHandler,\n} from '@contractspec/example.crm-pipeline/handlers';\n\ninterface DealItem {\n id: string;\n name: string;\n value: number;\n currency: string;\n stageId: string;\n status: string;\n}\n\ninterface StageItem {\n id: string;\n name: string;\n position: number;\n}\n\nfunction formatCurrency(value: number, currency = 'USD'): string {\n return new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency,\n minimumFractionDigits: 0,\n }).format(value);\n}\n\n/**\n * Markdown renderer for CRM Pipeline Kanban view (crm-pipeline.deal.pipeline)\n * Only handles PipelineKanbanView component\n */\nexport const crmPipelineMarkdownRenderer: PresentationRenderer<{\n mimeType: string;\n body: string;\n}> = {\n target: 'markdown',\n render: async (desc, _ctx) => {\n // Only handle PipelineKanbanView\n if (\n desc.source.type !== 'component' ||\n desc.source.componentKey !== 'PipelineKanbanView'\n ) {\n throw new Error('crmPipelineMarkdownRenderer: not PipelineKanbanView');\n }\n\n const pipelineId = 'pipeline-1';\n const [dealsResult, stages] = await Promise.all([\n mockListDealsHandler({ pipelineId, limit: 50 }),\n mockGetPipelineStagesHandler({ pipelineId }),\n ]);\n\n const deals = dealsResult.deals as DealItem[];\n const stageList = stages as StageItem[];\n\n // Group deals by stage\n const dealsByStage: Record<string, DealItem[]> = {};\n for (const stage of stageList) {\n dealsByStage[stage.id] = deals.filter(\n (d) => d.stageId === stage.id && d.status === 'OPEN'\n );\n }\n\n // Build Markdown\n const lines: string[] = [\n '# CRM Pipeline',\n '',\n `**Total Value**: ${formatCurrency(dealsResult.totalValue)}`,\n `**Total Deals**: ${dealsResult.total}`,\n '',\n ];\n\n for (const stage of stageList.sort((a, b) => a.position - b.position)) {\n const stageDeals = dealsByStage[stage.id] ?? [];\n const stageValue = stageDeals.reduce((sum, d) => sum + d.value, 0);\n\n lines.push(`## ${stage.name}`);\n lines.push(\n `_${stageDeals.length} deals · ${formatCurrency(stageValue)}_`\n );\n lines.push('');\n\n if (stageDeals.length === 0) {\n lines.push('_No deals_');\n } else {\n for (const deal of stageDeals) {\n lines.push(\n `- **${deal.name}** - ${formatCurrency(deal.value, deal.currency)}`\n );\n }\n }\n\n lines.push('');\n }\n\n return {\n mimeType: 'text/markdown',\n body: lines.join('\\n'),\n };\n },\n};\n\n/**\n * Markdown renderer for CRM Dashboard (crm-pipeline.dashboard)\n * Only handles CrmDashboard component\n */\nexport const crmDashboardMarkdownRenderer: PresentationRenderer<{\n mimeType: string;\n body: string;\n}> = {\n target: 'markdown',\n render: async (desc, _ctx) => {\n // Only handle CrmDashboard\n if (\n desc.source.type !== 'component' ||\n desc.source.componentKey !== 'CrmDashboard'\n ) {\n throw new Error('crmDashboardMarkdownRenderer: not CrmDashboard');\n }\n\n const pipelineId = 'pipeline-1';\n const [dealsResult, stages] = await Promise.all([\n mockListDealsHandler({ pipelineId, limit: 100 }),\n mockGetPipelineStagesHandler({ pipelineId }),\n ]);\n\n const deals = dealsResult.deals as DealItem[];\n const stageList = stages as StageItem[];\n\n // Calculate stats\n const openDeals = deals.filter((d) => d.status === 'OPEN');\n const wonDeals = deals.filter((d) => d.status === 'WON');\n const lostDeals = deals.filter((d) => d.status === 'LOST');\n const openValue = openDeals.reduce((sum, d) => sum + d.value, 0);\n const wonValue = wonDeals.reduce((sum, d) => sum + d.value, 0);\n\n // Build dashboard markdown\n const lines: string[] = [\n '# CRM Dashboard',\n '',\n '> Sales pipeline overview and key metrics',\n '',\n '## Summary',\n '',\n '| Metric | Value |',\n '|--------|-------|',\n `| Total Deals | ${dealsResult.total} |`,\n `| Pipeline Value | ${formatCurrency(dealsResult.totalValue)} |`,\n `| Open Deals | ${openDeals.length} (${formatCurrency(openValue)}) |`,\n `| Won Deals | ${wonDeals.length} (${formatCurrency(wonValue)}) |`,\n `| Lost Deals | ${lostDeals.length} |`,\n '',\n '## Pipeline Stages',\n '',\n ];\n\n // Stage summary table\n lines.push('| Stage | Deals | Value |');\n lines.push('|-------|-------|-------|');\n for (const stage of stageList.sort((a, b) => a.position - b.position)) {\n const stageDeals = openDeals.filter((d) => d.stageId === stage.id);\n const stageValue = stageDeals.reduce((sum, d) => sum + d.value, 0);\n lines.push(\n `| ${stage.name} | ${stageDeals.length} | ${formatCurrency(stageValue)} |`\n );\n }\n\n lines.push('');\n lines.push('## Recent Deals');\n lines.push('');\n\n // Top 10 recent deals\n const recentDeals = deals.slice(0, 10);\n if (recentDeals.length === 0) {\n lines.push('_No deals yet._');\n } else {\n lines.push('| Deal | Value | Stage | Status |');\n lines.push('|------|-------|-------|--------|');\n for (const deal of recentDeals) {\n const stage = stageList.find((s) => s.id === deal.stageId);\n lines.push(\n `| ${deal.name} | ${formatCurrency(deal.value, deal.currency)} | ${stage?.name ?? '-'} | ${deal.status} |`\n );\n }\n }\n\n return {\n mimeType: 'text/markdown',\n body: lines.join('\\n'),\n };\n },\n};\n"],"mappings":";;;AA0BA,SAAS,eAAe,OAAe,WAAW,OAAe;AAC/D,QAAO,IAAI,KAAK,aAAa,SAAS;EACpC,OAAO;EACP;EACA,uBAAuB;EACxB,CAAC,CAAC,OAAO,MAAM;;;;;;AAOlB,MAAa,8BAGR;CACH,QAAQ;CACR,QAAQ,OAAO,MAAM,SAAS;AAE5B,MACE,KAAK,OAAO,SAAS,eACrB,KAAK,OAAO,iBAAiB,qBAE7B,OAAM,IAAI,MAAM,sDAAsD;EAGxE,MAAM,aAAa;EACnB,MAAM,CAAC,aAAa,UAAU,MAAM,QAAQ,IAAI,CAC9C,qBAAqB;GAAE;GAAY,OAAO;GAAI,CAAC,EAC/C,6BAA6B,EAAE,YAAY,CAAC,CAC7C,CAAC;EAEF,MAAM,QAAQ,YAAY;EAC1B,MAAM,YAAY;EAGlB,MAAM,eAA2C,EAAE;AACnD,OAAK,MAAM,SAAS,UAClB,cAAa,MAAM,MAAM,MAAM,QAC5B,MAAM,EAAE,YAAY,MAAM,MAAM,EAAE,WAAW,OAC/C;EAIH,MAAM,QAAkB;GACtB;GACA;GACA,oBAAoB,eAAe,YAAY,WAAW;GAC1D,oBAAoB,YAAY;GAChC;GACD;AAED,OAAK,MAAM,SAAS,UAAU,MAAM,GAAG,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE;GACrE,MAAM,aAAa,aAAa,MAAM,OAAO,EAAE;GAC/C,MAAM,aAAa,WAAW,QAAQ,KAAK,MAAM,MAAM,EAAE,OAAO,EAAE;AAElE,SAAM,KAAK,MAAM,MAAM,OAAO;AAC9B,SAAM,KACJ,IAAI,WAAW,OAA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ACA;GACD;AAGD,QAAM,KAAK,4BAA4B;AACvC,QAAM,KAAK,4BAA4B;AACvC,OAAK,MAAM,SAAS,UAAU,MAAM,GAAG,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE;GACrE,MAAM,aAAa,UAAU,QAAQ,MAAM,EAAE,YAAY,MAAM,GAAG;GAClE,MAAM,aAAa,WAAW,QAAQ,KAAK,MAAM,MAAM,EAAE,OAAO,EAAE;AAClE,SAAM,KACJ,KAAK,MAAM,KAAK,KAAK,WAAW,OAAO,KAAK,eAAe,WAAW,CAAC,IACxE;;AAGH,QAAM,KAAK,GAAG;AACd,QAAM,KAAK,kBAAkB;AAC7B,QAAM,KAAK,GAAG;EAGd,MAAM,cAAc,MAAM,MAAM,GAAG,GAAG;AACtC,MAAI,YAAY,WAAW,EACzB,OAAM,KAAK,kBAAkB;OACxB;AACL,SAAM,KAAK,oCAAoC;AAC/C,SAAM,KAAK,oCAAoC;AAC/C,QAAK,MAAM,QAAQ,aAAa;IAC9B,MAAM,QAAQ,UAAU,MAAM,MAAM,EAAE,OAAO,KAAK,QAAQ;AAC1D,UAAM,KACJ,KAAK,KAAK,KAAK,KAAK,eAAe,KAAK,OAAO,KAAK,SAAS,CAAC,KAAK,OAAO,QAAQ,IAAI,KAAK,KAAK,OAAO,IACxG;;;AAIL,SAAO;GACL,UAAU;GACV,MAAM,MAAM,KAAK,KAAK;GACvB;;CAEJ"}
@@ -0,0 +1,9 @@
1
+ import { PresentationRenderer } from "@contractspec/lib.contracts";
2
+ import * as React from "react";
3
+
4
+ //#region src/ui/renderers/pipeline.renderer.d.ts
5
+
6
+ declare const crmPipelineReactRenderer: PresentationRenderer<React.ReactElement>;
7
+ //#endregion
8
+ export { crmPipelineReactRenderer };
9
+ //# sourceMappingURL=pipeline.renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.renderer.d.ts","names":[],"sources":["../../../src/ui/renderers/pipeline.renderer.tsx"],"sourcesContent":[],"mappings":";;;;;cAmBa,0BAA0B,qBAAqB,KAAA,CAAM"}
@@ -0,0 +1,28 @@
1
+ import { useDealList } from "../hooks/useDealList.js";
2
+ import { CrmPipelineBoard } from "../CrmPipelineBoard.js";
3
+ import "react";
4
+ import { jsx } from "react/jsx-runtime";
5
+
6
+ //#region src/ui/renderers/pipeline.renderer.tsx
7
+ /**
8
+ * Wrapper component that provides data to CrmPipelineBoard
9
+ */
10
+ function CrmPipelineBoardWrapper() {
11
+ const { dealsByStage, stages } = useDealList();
12
+ return /* @__PURE__ */ jsx(CrmPipelineBoard, {
13
+ dealsByStage,
14
+ stages
15
+ });
16
+ }
17
+ const crmPipelineReactRenderer = {
18
+ target: "react",
19
+ render: async (desc, _ctx) => {
20
+ if (desc.source.type !== "component") throw new Error("Invalid source type");
21
+ if (desc.source.componentKey !== "CrmPipelineView") throw new Error(`Unknown component: ${desc.source.componentKey}`);
22
+ return /* @__PURE__ */ jsx(CrmPipelineBoardWrapper, {});
23
+ }
24
+ };
25
+
26
+ //#endregion
27
+ export { crmPipelineReactRenderer };
28
+ //# sourceMappingURL=pipeline.renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.renderer.js","names":[],"sources":["../../../src/ui/renderers/pipeline.renderer.tsx"],"sourcesContent":["/**\n * React renderer for CRM Pipeline presentation\n *\n * Renders the CRM pipeline board component.\n * Data is fetched via the CrmPipelineBoard component's internal hooks.\n */\nimport * as React from 'react';\nimport type { PresentationRenderer } from '@contractspec/lib.contracts';\nimport { CrmPipelineBoard } from '../CrmPipelineBoard';\nimport { useDealList } from '../hooks/useDealList';\n\n/**\n * Wrapper component that provides data to CrmPipelineBoard\n */\nfunction CrmPipelineBoardWrapper() {\n const { dealsByStage, stages } = useDealList();\n return <CrmPipelineBoard dealsByStage={dealsByStage} stages={stages} />;\n}\n\nexport const crmPipelineReactRenderer: PresentationRenderer<React.ReactElement> =\n {\n target: 'react',\n render: async (desc, _ctx) => {\n if (desc.source.type !== 'component') {\n throw new Error('Invalid source type');\n }\n\n if (desc.source.componentKey !== 'CrmPipelineView') {\n throw new Error(`Unknown component: ${desc.source.componentKey}`);\n }\n\n // Note: The wrapper component will fetch data internally\n return <CrmPipelineBoardWrapper />;\n },\n };\n"],"mappings":";;;;;;;;;AAcA,SAAS,0BAA0B;CACjC,MAAM,EAAE,cAAc,WAAW,aAAa;AAC9C,QAAO,oBAAC;EAA+B;EAAsB;GAAU;;AAGzE,MAAa,2BACX;CACE,QAAQ;CACR,QAAQ,OAAO,MAAM,SAAS;AAC5B,MAAI,KAAK,OAAO,SAAS,YACvB,OAAM,IAAI,MAAM,sBAAsB;AAGxC,MAAI,KAAK,OAAO,iBAAiB,kBAC/B,OAAM,IAAI,MAAM,sBAAsB,KAAK,OAAO,eAAe;AAInE,SAAO,oBAAC,4BAA0B;;CAErC"}
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "name": "@contractspec/example.crm-pipeline",
3
- "version": "1.46.1",
3
+ "version": "1.47.0",
4
4
  "description": "CRM Pipeline - Contacts, Companies, Deals, Tasks",
5
5
  "type": "module",
6
- "main": "./dist/index.js",
7
6
  "types": "./dist/index.d.ts",
8
7
  "exports": {
9
8
  ".": "./dist/index.js",
@@ -12,6 +11,7 @@
12
11
  "./deal/deal.enum": "./dist/deal/deal.enum.js",
13
12
  "./deal/deal.operation": "./dist/deal/deal.operation.js",
14
13
  "./deal/deal.schema": "./dist/deal/deal.schema.js",
14
+ "./deal/deal.test-spec": "./dist/deal/deal.test-spec.js",
15
15
  "./docs": "./dist/docs/index.js",
16
16
  "./docs/crm-pipeline.docblock": "./dist/docs/crm-pipeline.docblock.js",
17
17
  "./entities": "./dist/entities/index.js",
@@ -25,12 +25,30 @@
25
25
  "./events/task.event": "./dist/events/task.event.js",
26
26
  "./example": "./dist/example.js",
27
27
  "./handlers": "./dist/handlers/index.js",
28
+ "./handlers/crm.handlers": "./dist/handlers/crm.handlers.js",
28
29
  "./handlers/deal.handlers": "./dist/handlers/deal.handlers.js",
29
30
  "./handlers/mock-data": "./dist/handlers/mock-data.js",
30
31
  "./operations": "./dist/operations/index.js",
31
32
  "./presentations": "./dist/presentations/index.js",
32
33
  "./presentations/dashboard.presentation": "./dist/presentations/dashboard.presentation.js",
33
34
  "./presentations/pipeline.presentation": "./dist/presentations/pipeline.presentation.js",
35
+ "./seeders": "./dist/seeders/index.js",
36
+ "./shared/overlay-types": "./dist/shared/overlay-types.js",
37
+ "./ui": "./dist/ui/index.js",
38
+ "./ui/CrmDashboard": "./dist/ui/CrmDashboard.js",
39
+ "./ui/CrmDealCard": "./dist/ui/CrmDealCard.js",
40
+ "./ui/CrmPipelineBoard": "./dist/ui/CrmPipelineBoard.js",
41
+ "./ui/hooks": "./dist/ui/hooks/index.js",
42
+ "./ui/hooks/useDealList": "./dist/ui/hooks/useDealList.js",
43
+ "./ui/hooks/useDealMutations": "./dist/ui/hooks/useDealMutations.js",
44
+ "./ui/modals": "./dist/ui/modals/index.js",
45
+ "./ui/modals/CreateDealModal": "./dist/ui/modals/CreateDealModal.js",
46
+ "./ui/modals/DealActionsModal": "./dist/ui/modals/DealActionsModal.js",
47
+ "./ui/overlays": "./dist/ui/overlays/index.js",
48
+ "./ui/overlays/demo-overlays": "./dist/ui/overlays/demo-overlays.js",
49
+ "./ui/renderers": "./dist/ui/renderers/index.js",
50
+ "./ui/renderers/pipeline.markdown": "./dist/ui/renderers/pipeline.markdown.js",
51
+ "./ui/renderers/pipeline.renderer": "./dist/ui/renderers/pipeline.renderer.js",
34
52
  "./*": "./*"
35
53
  },
36
54
  "scripts": {
@@ -44,22 +62,29 @@
44
62
  "lint": "bun lint:fix",
45
63
  "lint:fix": "eslint src --fix",
46
64
  "lint:check": "eslint src",
47
- "test": "bun run"
65
+ "test": "bun test"
48
66
  },
49
67
  "dependencies": {
50
- "@contractspec/lib.schema": "1.46.1",
51
- "@contractspec/lib.contracts": "1.46.1",
52
- "@contractspec/lib.identity-rbac": "1.46.1",
53
- "@contractspec/module.audit-trail": "1.46.1",
54
- "@contractspec/module.notifications": "1.46.1"
68
+ "@contractspec/lib.contracts": "1.47.0",
69
+ "@contractspec/lib.design-system": "1.47.0",
70
+ "@contractspec/lib.example-shared-ui": "1.1.0",
71
+ "@contractspec/lib.identity-rbac": "1.47.0",
72
+ "@contractspec/lib.runtime-sandbox": "0.2.0",
73
+ "@contractspec/lib.schema": "1.47.0",
74
+ "@contractspec/lib.ui-kit-web": "1.47.0",
75
+ "@contractspec/module.audit-trail": "1.47.0",
76
+ "@contractspec/module.notifications": "1.47.0",
77
+ "react": "19.2.3",
78
+ "react-dom": "19.2.3"
55
79
  },
56
80
  "devDependencies": {
57
- "@contractspec/tool.tsdown": "1.46.1",
58
- "@contractspec/tool.typescript": "1.46.1",
59
- "tsdown": "^0.18.3",
60
- "typescript": "^5.9.3"
81
+ "@contractspec/tool.tsdown": "1.47.0",
82
+ "@contractspec/tool.typescript": "1.47.0",
83
+ "tsdown": "^0.19.0",
84
+ "typescript": "^5.9.3",
85
+ "@types/react": "^19.2.8",
86
+ "@types/react-dom": "^19.2.2"
61
87
  },
62
- "module": "./dist/index.js",
63
88
  "publishConfig": {
64
89
  "exports": {
65
90
  ".": "./dist/index.js",
@@ -3,13 +3,13 @@
3
3
  *
4
4
  * Defines the feature module for CRM and sales pipeline capabilities.
5
5
  */
6
- import type { FeatureModuleSpec } from '@contractspec/lib.contracts';
6
+ import { defineFeature } from '@contractspec/lib.contracts';
7
7
 
8
8
  /**
9
9
  * CRM Pipeline feature module that bundles deal management,
10
10
  * pipeline operations, and contact management into an installable feature.
11
11
  */
12
- export const CrmPipelineFeature: FeatureModuleSpec = {
12
+ export const CrmPipelineFeature = defineFeature({
13
13
  meta: {
14
14
  key: 'crm-pipeline',
15
15
  title: 'CRM Pipeline',
@@ -97,4 +97,4 @@ export const CrmPipelineFeature: FeatureModuleSpec = {
97
97
  { key: 'notifications', version: '1.0.0' },
98
98
  ],
99
99
  },
100
- };
100
+ });
@@ -0,0 +1,55 @@
1
+ import { defineTestSpec } from '@contractspec/lib.contracts';
2
+
3
+ export const dealListTest = defineTestSpec({
4
+ meta: {
5
+ key: 'test.crm.deal.list',
6
+ version: '1.0.0',
7
+ owners: ['@example.crm-pipeline'],
8
+ description: 'Test for listing deals',
9
+ stability: 'stable',
10
+ tags: ['test'],
11
+ },
12
+ target: {
13
+ type: 'operation',
14
+ operation: { key: 'crm.deal.list', version: '1.0.0' },
15
+ },
16
+ scenarios: [
17
+ {
18
+ key: 'success',
19
+ when: { operation: { key: 'crm.deal.list' } },
20
+ then: [{ type: 'expectOutput', match: {} }],
21
+ },
22
+ {
23
+ key: 'error',
24
+ when: { operation: { key: 'crm.deal.list' } },
25
+ then: [{ type: 'expectError' }],
26
+ },
27
+ ],
28
+ });
29
+
30
+ export const dealMoveTest = defineTestSpec({
31
+ meta: {
32
+ key: 'test.crm.deal.move',
33
+ version: '1.0.0',
34
+ owners: ['@example.crm-pipeline'],
35
+ description: 'Test for moving deal',
36
+ stability: 'stable',
37
+ tags: ['test'],
38
+ },
39
+ target: {
40
+ type: 'operation',
41
+ operation: { key: 'crm.deal.move', version: '1.0.0' },
42
+ },
43
+ scenarios: [
44
+ {
45
+ key: 'success',
46
+ when: { operation: { key: 'crm.deal.move' } },
47
+ then: [{ type: 'expectOutput', match: {} }],
48
+ },
49
+ {
50
+ key: 'error',
51
+ when: { operation: { key: 'crm.deal.move' } },
52
+ then: [{ type: 'expectError' }],
53
+ },
54
+ ],
55
+ });
package/src/example.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { ExampleSpec } from '@contractspec/lib.contracts';
1
+ import { defineExample } from '@contractspec/lib.contracts';
2
2
 
3
- const example: ExampleSpec = {
3
+ const example = defineExample({
4
4
  meta: {
5
5
  key: 'crm-pipeline',
6
6
  version: '1.0.0',
@@ -33,6 +33,6 @@ const example: ExampleSpec = {
33
33
  studio: { enabled: true, installable: true },
34
34
  mcp: { enabled: true },
35
35
  },
36
- };
36
+ });
37
37
 
38
38
  export default example;