@genesislcap/ai-assistant 15.71.0-FUI-2650.1 → 15.71.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 (139) hide show
  1. package/dist/ai-assistant.api.json +0 -97
  2. package/dist/ai-assistant.d.ts +0 -65
  3. package/dist/chat-driver.cjs +0 -18031
  4. package/dist/chat-driver.cjs.map +4 -4
  5. package/dist/chat-driver.mjs +0 -18024
  6. package/dist/chat-driver.mjs.map +4 -4
  7. package/dist/custom-elements.json +6856 -9696
  8. package/dist/dts/chat-driver-node.d.ts +0 -2
  9. package/dist/dts/chat-driver-node.d.ts.map +1 -1
  10. package/dist/dts/index.d.ts +0 -1
  11. package/dist/dts/index.d.ts.map +1 -1
  12. package/dist/dts/react.d.ts +0 -10
  13. package/dist/esm/chat-driver-node.js +0 -6
  14. package/dist/esm/index.js +0 -3
  15. package/dist/react.cjs +0 -7
  16. package/dist/react.mjs +0 -6
  17. package/package.json +17 -24
  18. package/scripts/smoke-chat-driver-node.mjs +0 -15
  19. package/dist/dts/code-review/code-review.types.d.ts +0 -76
  20. package/dist/dts/code-review/code-review.types.d.ts.map +0 -1
  21. package/dist/dts/code-review/code-reviewer.agent.d.ts +0 -77
  22. package/dist/dts/code-review/code-reviewer.agent.d.ts.map +0 -1
  23. package/dist/dts/code-review/code-reviewer.prompt.d.ts +0 -23
  24. package/dist/dts/code-review/code-reviewer.prompt.d.ts.map +0 -1
  25. package/dist/dts/code-review/gate.d.ts +0 -44
  26. package/dist/dts/code-review/gate.d.ts.map +0 -1
  27. package/dist/dts/code-review/index.d.ts +0 -27
  28. package/dist/dts/code-review/index.d.ts.map +0 -1
  29. package/dist/dts/code-review/review-changes.d.ts +0 -70
  30. package/dist/dts/code-review/review-changes.d.ts.map +0 -1
  31. package/dist/dts/code-review/rules/context-trigger-map.d.ts +0 -6
  32. package/dist/dts/code-review/rules/context-trigger-map.d.ts.map +0 -1
  33. package/dist/dts/code-review/rules/context.registry.d.ts +0 -123
  34. package/dist/dts/code-review/rules/context.registry.d.ts.map +0 -1
  35. package/dist/dts/code-review/rules/fui-ai-extensions.d.ts +0 -13
  36. package/dist/dts/code-review/rules/fui-ai-extensions.d.ts.map +0 -1
  37. package/dist/dts/code-review/rules/fui-blotter.d.ts +0 -16
  38. package/dist/dts/code-review/rules/fui-blotter.d.ts.map +0 -1
  39. package/dist/dts/code-review/rules/fui-chart.d.ts +0 -20
  40. package/dist/dts/code-review/rules/fui-chart.d.ts.map +0 -1
  41. package/dist/dts/code-review/rules/fui-column-defs.d.ts +0 -21
  42. package/dist/dts/code-review/rules/fui-column-defs.d.ts.map +0 -1
  43. package/dist/dts/code-review/rules/fui-components.d.ts +0 -9
  44. package/dist/dts/code-review/rules/fui-components.d.ts.map +0 -1
  45. package/dist/dts/code-review/rules/fui-criteria.d.ts +0 -32
  46. package/dist/dts/code-review/rules/fui-criteria.d.ts.map +0 -1
  47. package/dist/dts/code-review/rules/fui-custom-renderer.d.ts +0 -15
  48. package/dist/dts/code-review/rules/fui-custom-renderer.d.ts.map +0 -1
  49. package/dist/dts/code-review/rules/fui-dashboard.d.ts +0 -19
  50. package/dist/dts/code-review/rules/fui-dashboard.d.ts.map +0 -1
  51. package/dist/dts/code-review/rules/fui-dialogs.d.ts +0 -19
  52. package/dist/dts/code-review/rules/fui-dialogs.d.ts.map +0 -1
  53. package/dist/dts/code-review/rules/fui-entity-management.d.ts +0 -19
  54. package/dist/dts/code-review/rules/fui-entity-management.d.ts.map +0 -1
  55. package/dist/dts/code-review/rules/fui-error-boundary.d.ts +0 -9
  56. package/dist/dts/code-review/rules/fui-error-boundary.d.ts.map +0 -1
  57. package/dist/dts/code-review/rules/fui-eventing.d.ts +0 -8
  58. package/dist/dts/code-review/rules/fui-eventing.d.ts.map +0 -1
  59. package/dist/dts/code-review/rules/fui-flexlayout.d.ts +0 -17
  60. package/dist/dts/code-review/rules/fui-flexlayout.d.ts.map +0 -1
  61. package/dist/dts/code-review/rules/fui-flyout-panel.d.ts +0 -10
  62. package/dist/dts/code-review/rules/fui-flyout-panel.d.ts.map +0 -1
  63. package/dist/dts/code-review/rules/fui-form-component.d.ts +0 -9
  64. package/dist/dts/code-review/rules/fui-form-component.d.ts.map +0 -1
  65. package/dist/dts/code-review/rules/fui-formatters.d.ts +0 -12
  66. package/dist/dts/code-review/rules/fui-formatters.d.ts.map +0 -1
  67. package/dist/dts/code-review/rules/fui-foundation-comms.d.ts +0 -10
  68. package/dist/dts/code-review/rules/fui-foundation-comms.d.ts.map +0 -1
  69. package/dist/dts/code-review/rules/fui-global-filters.d.ts +0 -33
  70. package/dist/dts/code-review/rules/fui-global-filters.d.ts.map +0 -1
  71. package/dist/dts/code-review/rules/fui-import-surface.d.ts +0 -37
  72. package/dist/dts/code-review/rules/fui-import-surface.d.ts.map +0 -1
  73. package/dist/dts/code-review/rules/fui-inline-editing.d.ts +0 -10
  74. package/dist/dts/code-review/rules/fui-inline-editing.d.ts.map +0 -1
  75. package/dist/dts/code-review/rules/fui-layout.d.ts +0 -7
  76. package/dist/dts/code-review/rules/fui-layout.d.ts.map +0 -1
  77. package/dist/dts/code-review/rules/fui-notifications.d.ts +0 -12
  78. package/dist/dts/code-review/rules/fui-notifications.d.ts.map +0 -1
  79. package/dist/dts/code-review/rules/fui-primitives.d.ts +0 -26
  80. package/dist/dts/code-review/rules/fui-primitives.d.ts.map +0 -1
  81. package/dist/dts/code-review/rules/fui-rapid-grid-pro.d.ts +0 -18
  82. package/dist/dts/code-review/rules/fui-rapid-grid-pro.d.ts.map +0 -1
  83. package/dist/dts/code-review/rules/fui-redux-store.d.ts +0 -8
  84. package/dist/dts/code-review/rules/fui-redux-store.d.ts.map +0 -1
  85. package/dist/dts/code-review/rules/fui-reporting.d.ts +0 -19
  86. package/dist/dts/code-review/rules/fui-reporting.d.ts.map +0 -1
  87. package/dist/dts/code-review/rules/fui-styling.d.ts +0 -15
  88. package/dist/dts/code-review/rules/fui-styling.d.ts.map +0 -1
  89. package/dist/dts/code-review/rules/fui-trade-form.d.ts +0 -13
  90. package/dist/dts/code-review/rules/fui-trade-form.d.ts.map +0 -1
  91. package/dist/dts/code-review/submit-code-review.tool.d.ts +0 -12
  92. package/dist/dts/code-review/submit-code-review.tool.d.ts.map +0 -1
  93. package/dist/dts/code-review/unified-diff.d.ts +0 -7
  94. package/dist/dts/code-review/unified-diff.d.ts.map +0 -1
  95. package/dist/dts/code-review/verdict.d.ts +0 -23
  96. package/dist/dts/code-review/verdict.d.ts.map +0 -1
  97. package/dist/dts/components/code-review-result/code-review-result.d.ts +0 -26
  98. package/dist/dts/components/code-review-result/code-review-result.d.ts.map +0 -1
  99. package/dist/esm/code-review/code-review.types.js +0 -6
  100. package/dist/esm/code-review/code-reviewer.agent.js +0 -167
  101. package/dist/esm/code-review/code-reviewer.prompt.js +0 -103
  102. package/dist/esm/code-review/gate.js +0 -93
  103. package/dist/esm/code-review/index.js +0 -28
  104. package/dist/esm/code-review/review-changes.js +0 -123
  105. package/dist/esm/code-review/rules/context-trigger-map.js +0 -20
  106. package/dist/esm/code-review/rules/context.registry.js +0 -772
  107. package/dist/esm/code-review/rules/fui-ai-extensions.js +0 -306
  108. package/dist/esm/code-review/rules/fui-blotter.js +0 -596
  109. package/dist/esm/code-review/rules/fui-chart.js +0 -669
  110. package/dist/esm/code-review/rules/fui-column-defs.js +0 -862
  111. package/dist/esm/code-review/rules/fui-components.js +0 -245
  112. package/dist/esm/code-review/rules/fui-criteria.js +0 -538
  113. package/dist/esm/code-review/rules/fui-custom-renderer.js +0 -612
  114. package/dist/esm/code-review/rules/fui-dashboard.js +0 -604
  115. package/dist/esm/code-review/rules/fui-dialogs.js +0 -588
  116. package/dist/esm/code-review/rules/fui-entity-management.js +0 -1014
  117. package/dist/esm/code-review/rules/fui-error-boundary.js +0 -244
  118. package/dist/esm/code-review/rules/fui-eventing.js +0 -628
  119. package/dist/esm/code-review/rules/fui-flexlayout.js +0 -860
  120. package/dist/esm/code-review/rules/fui-flyout-panel.js +0 -432
  121. package/dist/esm/code-review/rules/fui-form-component.js +0 -898
  122. package/dist/esm/code-review/rules/fui-formatters.js +0 -415
  123. package/dist/esm/code-review/rules/fui-foundation-comms.js +0 -518
  124. package/dist/esm/code-review/rules/fui-global-filters.js +0 -778
  125. package/dist/esm/code-review/rules/fui-import-surface.js +0 -452
  126. package/dist/esm/code-review/rules/fui-inline-editing.js +0 -445
  127. package/dist/esm/code-review/rules/fui-layout.js +0 -431
  128. package/dist/esm/code-review/rules/fui-notifications.js +0 -439
  129. package/dist/esm/code-review/rules/fui-primitives.js +0 -1216
  130. package/dist/esm/code-review/rules/fui-rapid-grid-pro.js +0 -650
  131. package/dist/esm/code-review/rules/fui-redux-store.js +0 -522
  132. package/dist/esm/code-review/rules/fui-reporting.js +0 -506
  133. package/dist/esm/code-review/rules/fui-styling.js +0 -1229
  134. package/dist/esm/code-review/rules/fui-trade-form.js +0 -618
  135. package/dist/esm/code-review/submit-code-review.tool.js +0 -43
  136. package/dist/esm/code-review/unified-diff.js +0 -96
  137. package/dist/esm/code-review/verdict.js +0 -24
  138. package/dist/esm/components/code-review-result/code-review-result.js +0 -89
  139. package/docs/code-review.md +0 -137
@@ -1,618 +0,0 @@
1
- /**
2
- * Context injected into the UI Builder system prompt.
3
- * Covers trade ticket / order entry form composition patterns —
4
- * the QTE/FTE (Quick Ticket Entry / Full Ticket Entry) style used in sales-trader-hub,
5
- * including the CHANGE_HANDLERS map, deepMerge patching, dynamic UISchema, and
6
- * cross-leg synchronisation for multi-section forms.
7
- *
8
- * Depends on fui-form-component for the FoundationForm prop/event reference.
9
- */
10
- export const FUI_TRADE_FORM_TAGS = [
11
- 'trade entry',
12
- 'trade form',
13
- 'trade ticket',
14
- 'order entry',
15
- 'order form',
16
- 'quick ticket',
17
- 'full ticket',
18
- 'QTE',
19
- 'FTE',
20
- 'RFQ',
21
- 'rfq form',
22
- 'rfq panel',
23
- 'change handler',
24
- 'change handlers',
25
- 'CHANGE_HANDLERS',
26
- 'field change',
27
- 'field dependency',
28
- 'field interdependency',
29
- 'form patch',
30
- 'deepMerge',
31
- 'onDataChange',
32
- 'dynamic schema',
33
- 'dynamic ui schema',
34
- 'conditional schema',
35
- 'uiSchema rebuild',
36
- 'nested form',
37
- 'multi-section form',
38
- 'MAIN.',
39
- 'FLOAT.',
40
- 'FIXED.',
41
- 'PREMIUM.',
42
- 'form sections',
43
- 'multi-leg form',
44
- 'cross-field sync',
45
- 'bps calculation',
46
- 'notional calculation',
47
- 'premium calculation',
48
- 'premium amount',
49
- 'trade submit',
50
- 'commitEvent trade',
51
- 'resolveHandlerByPath',
52
- 'QTE_CHANGE_HANDLERS',
53
- 'FTE_CHANGE_HANDLERS',
54
- ];
55
- export const FUI_TRADE_FORM_DEPS = ['fui-form-component'];
56
- export const FUI_TRADE_FORM_CONTEXT = `
57
- ## TRADE TICKET / ORDER ENTRY FORM (QTE-FTE Pattern)
58
-
59
- This module documents the **change-handler pattern** for complex trade entry forms built with
60
- \`FoundationForm\` (from \`@genesislcap/foundation-forms/react\`). It is directly extracted from
61
- the sales-trader-hub QTE/FTE implementation.
62
-
63
- **For FoundationForm props, events, and UiSchema rules — see \`fui-form-component\` context.**
64
-
65
- ---
66
-
67
- ### Core architecture
68
-
69
- \`\`\`
70
- User changes a field
71
- → FoundationForm fires onDataChange
72
- → extract { data, path } from e.detail
73
- → look up handler: CHANGE_HANDLERS[path] (flat) or FTE_CHANGE_HANDLERS[section][field] (nested)
74
- → handler(formData) returns Partial<FormData> patch (sync or async)
75
- → deepMerge patch into the full formData
76
- → setFormData(merged) — FoundationForm is controlled; always pass data back
77
- \`\`\`
78
-
79
- ---
80
-
81
- ### Import paths (verified from sales-trader-hub)
82
-
83
- \`\`\`ts
84
- // FoundationForm React wrapper
85
- import { Form as FoundationForm } from '@genesislcap/foundation-forms/react';
86
-
87
- // Default renderer list (FAST-only); for React-node renderers use renderersWithReact instead
88
- import { renderers } from '@genesislcap/foundation-forms';
89
- // Alternative: renderer list that supports React nodes in UiSchema options.render (FTE pattern)
90
- import { renderersWithReact } from '@genesislcap/foundation-forms/react-extras';
91
-
92
- // Types — import from base package root, NOT /react
93
- import type { UiSchema } from '@genesislcap/foundation-forms';
94
-
95
- // deepMerge — ALWAYS use @genesislcap/foundation-utils in this app.
96
- // (sales-trader-hub used lodash merge, but this app has no @types/lodash —
97
- // \`import { merge } from 'lodash'\` fails the strict typecheck.)
98
- // deepMerge(target, source) is non-mutating; nested objects merge, arrays are REPLACED.
99
- import { deepMerge } from '@genesislcap/foundation-utils';
100
-
101
- // Number formatters for trade display
102
- import { getNumberFormatter } from '@genesislcap/foundation-utils';
103
-
104
- // Primitives used alongside trade forms
105
- import { Button, NumberField, Switch, TextField } from '@genesislcap/rapid-design-system/react';
106
-
107
- // Server submit
108
- import { getConnect } from '@genesislcap/foundation-comms';
109
- \`\`\`
110
-
111
- ---
112
-
113
- ### Example 1 — Flat QTE form with CHANGE_HANDLERS (real sales-trader-hub pattern)
114
-
115
- \`\`\`tsx
116
- import React, { useCallback, useEffect, useState } from 'react';
117
- import { Form as FoundationForm } from '@genesislcap/foundation-forms/react';
118
- import { renderers } from '@genesislcap/foundation-forms';
119
- import type { UiSchema } from '@genesislcap/foundation-forms';
120
-
121
- // --- Types ---
122
- type QteFormState = {
123
- INSTRUMENT: string;
124
- CCY: string;
125
- NOTIONAL: number;
126
- PREMIUM_BPS: number | null;
127
- PREMIUM_AMOUNT: number | null;
128
- COUNTERPARTY_ID: string | null;
129
- };
130
-
131
- // --- Change handlers ---
132
- // Each handler receives the FULL current formData and returns a PARTIAL patch.
133
- // The patch is merged (deepMerge) into formData — do NOT return the full form state.
134
-
135
- const handleNotionalOrPremiumBpsChanged = (formData: QteFormState): Partial<QteFormState> => {
136
- const { NOTIONAL, PREMIUM_BPS, PREMIUM_AMOUNT } = formData;
137
- if (PREMIUM_AMOUNT && !PREMIUM_BPS) {
138
- const bps = NOTIONAL ? Number(((PREMIUM_AMOUNT * 10000) / NOTIONAL).toFixed(2)) : undefined;
139
- return bps != null ? { PREMIUM_BPS: bps } : {};
140
- }
141
- const amount = NOTIONAL && PREMIUM_BPS
142
- ? Number(((NOTIONAL * PREMIUM_BPS) / 10000).toFixed(2))
143
- : undefined;
144
- return amount != null ? { PREMIUM_AMOUNT: amount } : {};
145
- };
146
-
147
- const handleCurrencyChanged = (formData: QteFormState): Partial<QteFormState> => {
148
- // e.g. swap INDEX to CCY-appropriate default when CCY changes
149
- return {};
150
- };
151
-
152
- const QTE_CHANGE_HANDLERS: Record<string, (f: QteFormState) => Partial<QteFormState> | Promise<Partial<QteFormState>>> = {
153
- NOTIONAL: handleNotionalOrPremiumBpsChanged,
154
- PREMIUM_BPS: handleNotionalOrPremiumBpsChanged,
155
- PREMIUM_AMOUNT: (f) => {
156
- const bps = f.NOTIONAL && f.PREMIUM_AMOUNT
157
- ? Number(((f.PREMIUM_AMOUNT * 10000) / f.NOTIONAL).toFixed(2))
158
- : undefined;
159
- return bps != null ? { PREMIUM_BPS: bps } : {};
160
- },
161
- CCY: handleCurrencyChanged,
162
- };
163
-
164
- // Rebuild UISchema when instrument or counterparty changes
165
- const QTE_UI_SCHEMA_REBUILD_PATHS = new Set<string>(['INSTRUMENT', 'COUNTERPARTY_ID']);
166
-
167
- function buildUiSchema(formData: Partial<QteFormState>): UiSchema {
168
- return {
169
- type: 'VerticalLayout',
170
- elements: [
171
- { type: 'Control', scope: '#/properties/INSTRUMENT', label: 'Instrument' },
172
- { type: 'Control', scope: '#/properties/CCY', label: 'Currency' },
173
- { type: 'Control', scope: '#/properties/NOTIONAL', label: 'Notional' },
174
- { type: 'Control', scope: '#/properties/PREMIUM_BPS', label: 'Premium (bps)' },
175
- { type: 'Control', scope: '#/properties/PREMIUM_AMOUNT', label: 'Premium Amount' },
176
- { type: 'Control', scope: '#/properties/COUNTERPARTY_ID', label: 'Counterparty' },
177
- ],
178
- };
179
- }
180
-
181
- // --- Component ---
182
- export function QTEForm() {
183
- const [formData, setFormData] = useState<QteFormState>({
184
- INSTRUMENT: 'IRG', CCY: 'EUR', NOTIONAL: 0, PREMIUM_BPS: null, PREMIUM_AMOUNT: null, COUNTERPARTY_ID: null,
185
- });
186
- const [uiSchema, setUiSchema] = useState(() => buildUiSchema({}));
187
-
188
- const handleDataChange = useCallback(async (e: CustomEvent) => {
189
- const { data, path } = e.detail as { data: QteFormState; path: keyof QteFormState };
190
-
191
- // Guard: skip no-op fires on mount (form syncing data prop)
192
- if (path && formData && formData[path] === data[path]) return;
193
-
194
- // Rebuild UISchema when structural fields change
195
- if (path && QTE_UI_SCHEMA_REBUILD_PATHS.has(path as string)) {
196
- setUiSchema(buildUiSchema(data));
197
- }
198
-
199
- const handler = QTE_CHANGE_HANDLERS[path as string];
200
- if (handler) {
201
- const patch = await handler(data);
202
- setFormData(prev => ({ ...prev, ...data, ...patch }));
203
- } else {
204
- setFormData(data);
205
- }
206
- }, [formData]);
207
-
208
- const handleSubmitSuccess = useCallback((e: CustomEvent) => {
209
- const { payload, response } = e.detail;
210
- const generated = response?.GENERATED?.[0];
211
- console.log('Trade submitted. Generated ID:', generated?.RFQ_ID);
212
- }, []);
213
-
214
- return (
215
- <FoundationForm
216
- prefix="rapid"
217
- resourceName="EVENT_CREATE_RFQ"
218
- data={formData}
219
- uischema={uiSchema}
220
- renderers={renderers}
221
- onDataChange={handleDataChange}
222
- onSubmitSuccess={handleSubmitSuccess}
223
- onSubmitFailure={(e: CustomEvent) => {
224
- const detail = e.detail.errors?.map((err: any) => err.TEXT).filter(Boolean).join('; ') ?? 'Unknown error';
225
- console.error('Submit failed:', detail);
226
- }}
227
- showReset
228
- />
229
- );
230
- }
231
- \`\`\`
232
-
233
- ---
234
-
235
- ### Example 2 — Nested FTE form (MAIN / FLOAT / FIXED / PREMIUM sections)
236
-
237
- The FTE form splits data into top-level sections. The \`onDataChange\` \`path\` is dot-separated
238
- (e.g. \`"MAIN.NOTIONAL"\`, \`"FLOAT.PAYOFF_TYPE"\`). Handlers live in a nested map keyed by
239
- \`[section][field]\`. Patches span multiple sections (e.g. changing \`MAIN.BUY_SELL\` also patches
240
- \`FLOAT.PAYOFF_TYPE\` and \`PREMIUM.DIRECTION\`).
241
-
242
- \`\`\`tsx
243
- import { deepMerge } from '@genesislcap/foundation-utils';
244
- import type { UiSchema } from '@genesislcap/foundation-forms';
245
-
246
- // Shape of FTE form data (one object per leg/section)
247
- type FteFormData = {
248
- MAIN: { NOTIONAL: number; BUY_SELL: string; CCY: string; INSTRUMENT: string; [k: string]: unknown };
249
- FLOAT: { PAYOFF_TYPE: string; [k: string]: unknown };
250
- FIXED?: { PAYOFF_TYPE?: string; [k: string]: unknown };
251
- PREMIUM: { DIRECTION: string; PREMIUM_BPS?: number; PREMIUM_AMOUNT?: number; [k: string]: unknown };
252
- FEES?: Array<{ RFQ_ID?: string; FEE_CALC?: string; [k: string]: unknown }>;
253
- OPTION?: { OPTION_TYPE?: string; [k: string]: unknown };
254
- };
255
-
256
- // Handler type — receives full formData, returns a partial nested patch
257
- type FteChangeHandler = (formData: FteFormData) => Record<string, unknown> | undefined;
258
-
259
- // Handler map: { [section]: { [field]: handler } | handler }
260
- const FTE_CHANGE_HANDLERS: { [S in keyof FteFormData]?: Record<string, FteChangeHandler> | FteChangeHandler } = {
261
- MAIN: {
262
- NOTIONAL: (fd) => {
263
- const { NOTIONAL } = fd.MAIN;
264
- const prem = fd.PREMIUM;
265
- const amount = prem?.PREMIUM_BPS != null
266
- ? Number(((NOTIONAL * prem.PREMIUM_BPS) / 10000).toFixed(2))
267
- : undefined;
268
- return amount != null ? { PREMIUM: { PREMIUM_AMOUNT: amount } } : {};
269
- },
270
- BUY_SELL: (fd) => {
271
- const buySell = fd.MAIN.BUY_SELL;
272
- if (buySell === 'LONG') {
273
- return {
274
- PREMIUM: { DIRECTION: 'PAY' },
275
- FLOAT: { ...fd.FLOAT, PAYOFF_TYPE: 'CLIENT_RECEIVES' },
276
- };
277
- }
278
- if (buySell === 'SHORT') {
279
- return {
280
- PREMIUM: { DIRECTION: 'RECEIVE' },
281
- FLOAT: { ...fd.FLOAT, PAYOFF_TYPE: 'CLIENT_PAYS' },
282
- };
283
- }
284
- return undefined;
285
- },
286
- },
287
- PREMIUM: {
288
- PREMIUM_BPS: (fd) => {
289
- const bps = fd.PREMIUM?.PREMIUM_BPS;
290
- const notional = fd.MAIN?.NOTIONAL;
291
- const amount = bps != null && notional ? Number(((notional * bps) / 10000).toFixed(2)) : undefined;
292
- return amount != null ? { PREMIUM: { PREMIUM_AMOUNT: amount } } : {};
293
- },
294
- },
295
- };
296
-
297
- /**
298
- * resolveHandlerByPath — find the correct handler from a dot-path like "MAIN.NOTIONAL".
299
- * Numeric path segments (array indices) are skipped.
300
- */
301
- function resolveHandlerByPath(
302
- path: string,
303
- handlers: typeof FTE_CHANGE_HANDLERS,
304
- ): FteChangeHandler | undefined {
305
- const parts = path.split('.').filter(s => !/^d+$/.test(s));
306
- if (parts.length < 2) return undefined;
307
- const [section, field] = parts;
308
- const sectionHandlers = handlers[section as keyof FteFormData];
309
- if (!sectionHandlers) return undefined;
310
- if (typeof sectionHandlers === 'function') return sectionHandlers;
311
- return (sectionHandlers as Record<string, FteChangeHandler>)[field];
312
- }
313
-
314
- // Declare this helper in your own schema module:
315
- // export function buildFteUiSchema(formData: Partial<FteFormData>): UiSchema { ... }
316
-
317
- export function FTEFormComponent({ initialData, onAccept }: { initialData: FteFormData; onAccept: () => void }) {
318
- const [formData, setFormData] = useState<FteFormData>(initialData);
319
- // Rebuild UISchema only on structural field changes (instrument, counterparty)
320
- const [uiSchema, setUiSchema] = useState<UiSchema>(() => buildFteUiSchema(initialData));
321
-
322
- const FTE_UI_SCHEMA_REBUILD_PATHS = new Set<string>(['MAIN.INSTRUMENT', 'MAIN.COUNTERPARTY_ID']);
323
-
324
- const handleDataChange = useCallback(async (e: CustomEvent) => {
325
- const { data, path } = e.detail as { data: FteFormData; path: string };
326
-
327
- if (path && FTE_UI_SCHEMA_REBUILD_PATHS.has(path)) {
328
- setUiSchema(buildFteUiSchema(data));
329
- }
330
-
331
- const handler = resolveHandlerByPath(path, FTE_CHANGE_HANDLERS);
332
- if (handler) {
333
- const patch = await handler(data);
334
- // deep-merge: prev ← data ← patch (deepMerge is non-mutating, 2-arg — chain it)
335
- setFormData(prev => deepMerge(deepMerge(prev, data), (patch ?? {}) as Partial<FteFormData>));
336
- } else {
337
- setFormData(data);
338
- }
339
- }, []);
340
-
341
- return (
342
- <FoundationForm
343
- prefix="rapid"
344
- resourceName="EVENT_EXECUTE_RFQ"
345
- data={formData}
346
- uischema={uiSchema}
347
- renderers={renderers}
348
- onDataChange={handleDataChange}
349
- onSubmitSuccess={onAccept}
350
- hideSubmit
351
- />
352
- );
353
- }
354
- \`\`\`
355
-
356
- ---
357
-
358
- ### Example 3 — Manual trade ticket with primitives (IrVolTradingForm pattern)
359
-
360
- When the form is NOT backed by FoundationForm (e.g. a bespoke price-entry grid), build it with
361
- \`NumberField\`, \`Button\`, and \`Switch\` directly. This is the pattern used in \`IrVolTradingForm.tsx\`.
362
-
363
- \`\`\`tsx
364
- import React, { useState } from 'react';
365
- import { Button, NumberField, Switch } from '@genesislcap/rapid-design-system/react';
366
- import { getNumberFormatter } from '@genesislcap/foundation-utils';
367
-
368
- const fmtAmount = getNumberFormatter('0,0', 'en-gb');
369
-
370
- type PriceRow = { id: string; label: string; bps: number; amount: number };
371
-
372
- export function ManualPriceTicket() {
373
- const [rows, setRows] = useState<PriceRow[]>([
374
- { id: 'xva', label: 'xVA', bps: 2, amount: 115_000 },
375
- { id: 'frq', label: 'Frq', bps: 15, amount: 1_150 },
376
- ]);
377
-
378
- const totalBps = rows.reduce((s, r) => s + r.bps, 0);
379
- const totalAmount = rows.reduce((s, r) => s + r.amount, 0);
380
-
381
- const updateBps = (id: string, raw: string) => {
382
- const val = parseFloat(raw);
383
- if (!isNaN(val)) setRows(prev => prev.map(r => r.id === id ? { ...r, bps: val } : r));
384
- };
385
-
386
- return (
387
- <div>
388
- {rows.map(row => (
389
- <div key={row.id} style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
390
- <span style={{ width: 120 }}>{row.label}</span>
391
- <NumberField
392
- value={String(row.bps)}
393
- step={0.5}
394
- min={0}
395
- hideStep
396
- onChange={(e: any) => updateBps(row.id, e.target.value)}
397
- />
398
- <span>{fmtAmount({ value: row.amount })}</span>
399
- </div>
400
- ))}
401
- <div><strong>Total: {totalBps.toFixed(2)} bps / {fmtAmount({ value: totalAmount })}</strong></div>
402
- <Button onClick={() => console.log('Send quote', rows)}>Send</Button>
403
- </div>
404
- );
405
- }
406
- \`\`\`
407
-
408
- ---
409
-
410
- ### Example 4 — RFQ flyout panel (QTE → FTE two-step flow)
411
-
412
- \`\`\`tsx
413
- import { useCallback, useLayoutEffect, useRef, useState } from 'react';
414
- import { Flyout } from '@genesislcap/rapid-design-system/react';
415
-
416
- export function RFQPanel({ open, onClose }: { open: boolean; onClose: () => void }) {
417
- const [activeForm, setActiveForm] = useState<'qte' | 'fte' | null>(null);
418
- const [crossFormPayload, setCrossFormPayload] = useState<FteFormData | null>(null);
419
-
420
- // Reset to QTE whenever the panel opens (useLayoutEffect avoids stale prefill flash)
421
- useLayoutEffect(() => {
422
- if (open) {
423
- setActiveForm('qte');
424
- setCrossFormPayload(null);
425
- }
426
- }, [open]);
427
-
428
- const handleQteComplete = useCallback(async (rfqId: string) => {
429
- // Fetch FTE composite data for the created RFQ, then switch forms
430
- const composite = await fetchFteComposite(rfqId);
431
- setCrossFormPayload(composite);
432
- setActiveForm('fte');
433
- }, []);
434
-
435
- const handleBackToQte = useCallback(() => {
436
- setActiveForm('qte');
437
- }, []);
438
-
439
- return (
440
- <Flyout
441
- position="right"
442
- closed={!open}
443
- flyoutWidth={activeForm === 'fte' ? 'min(960px, calc(100vw - 24px))' : '300px'}
444
- onClosed={onClose}
445
- >
446
- <div slot="title">{activeForm === 'qte' ? 'Quick Entry' : 'Full Ticket'}</div>
447
- <div>
448
- {activeForm === 'qte' && <QTEForm onComplete={handleQteComplete} />}
449
- {activeForm === 'fte' && crossFormPayload && (
450
- <FTEFormComponent initialData={crossFormPayload} onAccept={onClose} />
451
- )}
452
- </div>
453
- </Flyout>
454
- );
455
- }
456
- \`\`\`
457
-
458
- ---
459
-
460
- ### Key rules (verified from sales-trader-hub)
461
-
462
- - **FoundationForm is controlled** — always pass \`data={formData}\` and update it on every \`onDataChange\`.
463
- - **Handlers receive full formData, return a partial patch** — never mutate, always return \`{}\` for no-op.
464
- - **deepMerge for patches** — \`{ ...prev, ...patch }\` at the top level drops sibling sections in nested FTE forms. Use \`deepMerge(deepMerge(prev, data), patch)\` from \`@genesislcap/foundation-utils\` (non-mutating; arrays are replaced, not merged). Do NOT import lodash — no \`@types/lodash\` in this app, the strict typecheck fails.
465
- - **Guard no-op mount fires** — on mount FoundationForm fires \`onDataChange\` for every field as it syncs with \`data\`. Skip these: \`if (formData?.[path] === data[path]) return;\`
466
- - **Async handlers** — \`onDataChange\` callback can be \`async\`; \`await\` the patch before \`setFormData\`.
467
- - **UISchema rebuild only on structural fields** — rebuilding on every change causes flicker; use a \`Set\` of paths that need rebuilding (e.g. \`INSTRUMENT\`, \`COUNTERPARTY_ID\`).
468
- - **resolveHandlerByPath strips numeric segments** — dot-paths like \`FEES.0.FEE_CALC\` have array indices; strip digits before looking up handlers.
469
- - **\`renderers\` prop vs \`additionalRenderers\`** — omitting \`renderers\` uses the built-in list; \`additionalRenderers\` APPENDS to it (the form merges both). Pass \`renderers={renderersWithReact}\` only when a UiSchema uses \`options.render\`.
470
- - **Server submit** — use \`resourceName\` on the Form for server-driven submit; or, with \`hideSubmit\`, wire a custom submit button that commits the event manually. For the manual path, **prefer the typed generated event class** when \`generated/genesis-event-types.ts\` is listed in \`vfs_list\` and exports a class for the event; otherwise use the plain form. Never create or edit the generated file. See \`fui-foundation-comms\` (typed form) for the full ACK/NACK handling.
471
-
472
- \`\`\`tsx
473
- import { getConnect, commitGenesisEvent } from '@genesislcap/foundation-comms';
474
- import { EventCreateRfq } from '../generated/genesis-event-types'; // typed DETAILS — PREFER when listed (depth like store imports — e.g. ../../ from a route page)
475
-
476
- // custom submit button (Form has hideSubmit) — typed commit, DETAILS type-checked
477
- const response = await commitGenesisEvent(getConnect(), new EventCreateRfq(formData));
478
- if (response.MESSAGE_TYPE !== 'EVENT_ACK') { /* response.MESSAGE_TYPE === 'EVENT_NACK' */ }
479
- // Fallback (generated file absent or event not in the map):
480
- // await getConnect().commitEvent('EVENT_CREATE_RFQ', { DETAILS: formData });
481
- \`\`\`
482
-
483
- ---
484
-
485
- ### DANGEROUS PATTERNS
486
-
487
- #### DP-1: Spreading at top level for nested (multi-section) form data
488
-
489
- \`\`\`tsx
490
- // WRONG — top-level spread drops sibling sections (FLOAT, PREMIUM, etc.):
491
- const handleDataChange = async (e: CustomEvent) => {
492
- const { data, path } = e.detail;
493
- const patch = await handler(data);
494
- setFormData(prev => ({ ...prev, ...patch })); // ← WRONG for nested form data
495
- };
496
-
497
- // ALSO WRONG — import { merge } from 'lodash': no @types/lodash here, typecheck fails.
498
-
499
- // CORRECT — deep merge preserves all sibling sections:
500
- import { deepMerge } from '@genesislcap/foundation-utils';
501
- const handleDataChange = async (e: CustomEvent) => {
502
- const { data, path } = e.detail;
503
- const patch = await handler(data);
504
- setFormData(prev => deepMerge(deepMerge(prev, data), patch as Partial<FteFormData>));
505
- };
506
- \`\`\`
507
-
508
- #### DP-2: Returning full formData from a change handler (instead of a patch)
509
-
510
- \`\`\`tsx
511
- // WRONG — handler returns the entire form state; stale data can overwrite concurrent changes:
512
- const handleNotionalChanged = (formData: FteFormData): FteFormData => {
513
- return { ...formData, PREMIUM: { ...formData.PREMIUM, PREMIUM_AMOUNT: calculated } }; // ← WRONG
514
- };
515
-
516
- // CORRECT — return only the fields that need updating:
517
- const handleNotionalChanged = (formData: FteFormData): Record<string, unknown> => {
518
- return { PREMIUM: { PREMIUM_AMOUNT: calculated } }; // ← only the changed fields
519
- };
520
- \`\`\`
521
-
522
- #### DP-3: Missing no-op guard causes infinite loop or stale overwrites
523
-
524
- \`\`\`tsx
525
- // WRONG — every setFormData call triggers a new onDataChange, which calls handler, which calls
526
- // setFormData again. Without a guard this loops.
527
- const handleDataChange = async (e: CustomEvent) => {
528
- const { data, path } = e.detail;
529
- const patch = await handler(data);
530
- setFormData(prev => deepMerge(deepMerge(prev, data), patch)); // ← fires onDataChange again
531
- };
532
-
533
- // CORRECT — guard against no-op fires (field value unchanged):
534
- const handleDataChange = useCallback(async (e: CustomEvent) => {
535
- const { data, path } = e.detail as { data: FormData; path: keyof FormData };
536
- if (path && formData && formData[path] === data[path]) return; // ← skip no-op
537
- const handler = CHANGE_HANDLERS[path as string];
538
- if (handler) {
539
- const patch = await handler(data);
540
- setFormData(prev => deepMerge(deepMerge(prev, data), patch));
541
- } else {
542
- setFormData(data);
543
- }
544
- }, [formData]);
545
- \`\`\`
546
-
547
- #### DP-4: Looking up handlers by full dot-path instead of field segment
548
-
549
- \`\`\`tsx
550
- // WRONG — path is "MAIN.NOTIONAL"; CHANGE_HANDLERS["MAIN.NOTIONAL"] is undefined:
551
- const handler = CHANGE_HANDLERS[path]; // ← undefined for nested paths
552
-
553
- // CORRECT for flat forms — use the last segment:
554
- const field = path.split('.').pop() as keyof FormData;
555
- const handler = CHANGE_HANDLERS[field];
556
-
557
- // CORRECT for nested FTE forms — strip numeric indices, walk the handler tree:
558
- function resolveHandlerByPath(path: string, handlers: FteChangeHandlerMap) {
559
- const parts = path.split('.').filter(s => !/^d+$/.test(s));
560
- const [section, field] = parts;
561
- const sectionHandlers = handlers[section as keyof FteFormData];
562
- if (!sectionHandlers) return undefined;
563
- if (typeof sectionHandlers === 'function') return sectionHandlers;
564
- return (sectionHandlers as Record<string, FteChangeHandler>)[field];
565
- }
566
- \`\`\`
567
-
568
- #### DP-5: Not passing formData back to the Form after a handler
569
-
570
- \`\`\`tsx
571
- // WRONG — formData state is updated in React but the Form still shows the old data prop:
572
- const handleDataChange = async (e: CustomEvent) => {
573
- const { data } = e.detail;
574
- const patch = await handler(data);
575
- // forgot to call setFormData — Form stays controlled by old state
576
- };
577
-
578
- // CORRECT — always call setFormData:
579
- const handleDataChange = async (e: CustomEvent) => {
580
- const { data, path } = e.detail;
581
- const patch = await handler(data);
582
- setFormData(prev => deepMerge(deepMerge(prev, data), patch));
583
- };
584
- \`\`\`
585
-
586
- #### DP-6: Rebuilding UISchema on every onDataChange
587
-
588
- \`\`\`tsx
589
- // WRONG — rebuilding on every field change causes the form to remount all renderers on every keystroke:
590
- const handleDataChange = async (e: CustomEvent) => {
591
- const { data } = e.detail;
592
- setUiSchema(buildUiSchema(data)); // ← runs on every field change
593
- setFormData(data);
594
- };
595
-
596
- // CORRECT — rebuild only for paths that structurally change the form (instrument, product type, etc.):
597
- const UI_SCHEMA_REBUILD_PATHS = new Set(['INSTRUMENT', 'COUNTERPARTY_ID']);
598
- const handleDataChange = async (e: CustomEvent) => {
599
- const { data, path } = e.detail;
600
- if (path && UI_SCHEMA_REBUILD_PATHS.has(path)) {
601
- setUiSchema(buildUiSchema(data)); // ← only on structural field changes
602
- }
603
- setFormData(data);
604
- };
605
- \`\`\`
606
-
607
- ---
608
-
609
- ### Related contexts
610
-
611
- | Context | When needed |
612
- |---|---|
613
- | \`fui-form-component\` | FoundationForm props, events, UiSchema renderer catalog, DANGEROUS PATTERNS |
614
- | \`fui-flyout-panel\` | Flyout panel wiring for the RFQ/trade panel |
615
- | \`fui-foundation-comms\` | \`getConnect().commitEvent()\` for manual trade submit |
616
- | \`fui-primitives\` | NumberField, Button, Switch for bespoke price-entry UIs |
617
- | \`fui-custom-renderer\` | Custom renderers (counterparty picker, date-field pair, ccy/notional pair) |
618
- `.trim();
@@ -1,43 +0,0 @@
1
- import { __awaiter } from "tslib";
2
- /**
3
- * The reviewer's one terminal tool. Moved from genesis-create's judge tools unchanged (FUI-2650).
4
- * @beta
5
- */
6
- export const submitCodeReviewToolDefinition = {
7
- name: 'submit_code_review',
8
- description: 'Submit the final code review verdict. Call this exactly once after reading all provided files and loading all relevant context modules. ' +
9
- 'approved=true: code is compliant, changes will proceed. ' +
10
- 'approved=false, severity="blocking": code has issues that cause runtime failures or violate mandatory patterns — changes are rejected and the primary agent must fix them before retrying. Choose this only if at least one issue in `feedback` is one you still assert after checking it; a review that talked itself out of every candidate is approved=true, not blocking. ' +
11
- 'approved=false, severity="advisory": code works but has non-critical issues — changes proceed and the primary agent receives the feedback.',
12
- parameters: {
13
- type: 'object',
14
- required: ['approved'],
15
- properties: {
16
- approved: {
17
- type: 'boolean',
18
- description: 'true if the code passes all checks; false if any issues were found.',
19
- },
20
- severity: {
21
- type: 'string',
22
- enum: ['blocking', 'advisory'],
23
- description: 'Required when approved=false. "blocking" rejects the changes; "advisory" lets them through with feedback attached.',
24
- },
25
- feedback: {
26
- type: 'string',
27
- description: 'Required when approved=false. Numbered list of specific issues — include the file path, the exact code or line where the violation occurs, the rule that was violated (referencing the loaded context), and what the correct pattern is. This field is the VERDICT, not your working-out: list only issues you still stand behind after checking them. If you drafted candidates and then cleared them against the loaded context, do not submit them with the retraction attached — drop them. And if NOTHING survives that check, the verdict is approved=true; if what survives is only nits, it is severity="advisory". MEASURED: a review that enumerated seven "[BLOCKING]" candidates, retracted every one and wrote "unable to substantiate a genuine blocking defect — downgrading" still submitted severity="blocking", and the change was reported to the user as unverified on the strength of a verdict the reviewer itself had withdrawn.',
28
- },
29
- },
30
- },
31
- };
32
- /**
33
- * Completes the reviewer sub-agent with the verdict.
34
- * @beta
35
- */
36
- export const submitCodeReviewHandler = (args, context) => __awaiter(void 0, void 0, void 0, function* () {
37
- var _a;
38
- const { approved, severity = 'advisory', feedback = '' } = args;
39
- (_a = context.completeSubAgent) === null || _a === void 0 ? void 0 : _a.call(context, { approved, severity, feedback });
40
- if (approved)
41
- return 'Code review passed — no issues found.';
42
- return `Code review ${severity === 'blocking' ? 'REJECTED (blocking)' : 'flagged (advisory)'}: ${feedback}`;
43
- });