@praxisui/table 8.0.0-beta.3 → 8.0.0-beta.31
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.
- package/README.md +190 -11
- package/docs/DSL-Extensions-Guide.md +23 -0
- package/docs/adr/2026-03-dynamic-filter-cross-lib-coupling.md +107 -0
- package/docs/adr/2026-03-filter-drawer-adapter-light-entrypoint.md +105 -0
- package/docs/adr/2026-03-table-editor-idfield-decision.md +85 -0
- package/docs/column-resize-reorder-implementation-plan.md +338 -0
- package/docs/column-resize-reorder-review-prompt.md +34 -0
- package/docs/dynamic-filter-architecture-overview.md +207 -0
- package/docs/dynamic-filter-backend-contract-cheatsheet.md +167 -0
- package/docs/dynamic-filter-editor-settings-guide.md +229 -0
- package/docs/dynamic-filter-host-integration-guide.md +266 -0
- package/docs/dynamic-filter-payload-contract.md +331 -0
- package/docs/dynamic-filter-range-filters-guide.md +296 -0
- package/docs/dynamic-filter-troubleshooting-guide.md +257 -0
- package/docs/dynamic-inline-filter-catalog.md +147 -0
- package/docs/e2e-column-drag-playwright.md +62 -0
- package/docs/expandable-rows-enterprise-big-leagues-plan.md +1080 -0
- package/docs/json-logic-operators-and-helpers.md +57 -0
- package/docs/local-data-mode-precedence.md +12 -0
- package/docs/local-data-pre-implementation-baseline.md +22 -0
- package/docs/local-data-preimplementation-go-no-go.md +39 -0
- package/docs/local-data-support-implementation-plan.md +524 -0
- package/docs/local-data-support-pr-package.md +66 -0
- package/docs/localization-persistence-merge.md +22 -0
- package/docs/performance-hardening-v2-implementation-plan.md +479 -0
- package/docs/playground-scenario-curation-plan.md +482 -0
- package/docs/playground-scenario-second-opinion-prompt.md +121 -0
- package/docs/playground-scenario-second-opinion-review.md +234 -0
- package/docs/release-notes-p1-hardening.md +76 -0
- package/docs/table-authoring-document-completeness-checklist.md +120 -0
- package/docs/table-editor-capability-review-prompt.md +349 -0
- package/docs/visual-rules-editor-transition.md +29 -0
- package/fesm2022/{praxisui-table-filter-form-dialog-host.component-Dm2f0muy.mjs → praxisui-table-filter-form-dialog-host.component-CN9JWFoa.mjs} +69 -14
- package/fesm2022/praxisui-table-praxisui-table-qO5EkftZ.mjs +57821 -0
- package/fesm2022/praxisui-table-table-agentic-authoring-turn-flow-CretQI6Z.mjs +847 -0
- package/fesm2022/praxisui-table-table-ai.adapter-DkMHa90r.mjs +2795 -0
- package/fesm2022/praxisui-table.mjs +1 -51444
- package/index.d.ts +410 -115
- package/package.json +15 -9
- package/src/lib/praxis-table.json-api.md +1326 -0
- package/fesm2022/praxisui-table-table-agentic-authoring-turn-flow-tu7jtTwV.mjs +0 -280
- package/fesm2022/praxisui-table-table-ai.adapter-DxjDaQqy.mjs +0 -895
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
import { firstValueFrom } from 'rxjs';
|
|
2
|
-
|
|
3
|
-
class TableAgenticAuthoringTurnFlow {
|
|
4
|
-
adapter;
|
|
5
|
-
aiApi;
|
|
6
|
-
mode = 'config';
|
|
7
|
-
constructor(adapter, aiApi) {
|
|
8
|
-
this.adapter = adapter;
|
|
9
|
-
this.aiApi = aiApi;
|
|
10
|
-
}
|
|
11
|
-
async submit(request) {
|
|
12
|
-
const prompt = (request.prompt ?? '').trim();
|
|
13
|
-
if (!prompt) {
|
|
14
|
-
return {
|
|
15
|
-
state: 'listening',
|
|
16
|
-
phase: 'capture',
|
|
17
|
-
statusText: '',
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
const componentId = this.adapter.componentId || request.componentId || 'praxis-table';
|
|
21
|
-
const componentType = this.adapter.componentType || request.componentType || 'table';
|
|
22
|
-
const currentState = this.toAiJsonObject(this.adapter.getCurrentConfig());
|
|
23
|
-
const dataProfile = this.optionalJsonObject(this.adapter.getDataProfile?.());
|
|
24
|
-
const runtimeState = this.optionalJsonObject(this.adapter.getRuntimeState?.());
|
|
25
|
-
const schemaFields = this.adapter.getSchemaFields?.()
|
|
26
|
-
?.map((field) => this.toAiJsonObject(field))
|
|
27
|
-
.filter((field) => Object.keys(field).length > 0);
|
|
28
|
-
const contextHints = this.optionalJsonObject(this.adapter.getAuthoringContext?.());
|
|
29
|
-
const response = await firstValueFrom(this.aiApi.getPatch({
|
|
30
|
-
componentId,
|
|
31
|
-
componentType,
|
|
32
|
-
userPrompt: prompt,
|
|
33
|
-
sessionId: request.sessionId,
|
|
34
|
-
clientTurnId: request.clientTurnId,
|
|
35
|
-
messages: this.toChatMessages(request.messages, prompt),
|
|
36
|
-
currentState,
|
|
37
|
-
currentStateDigest: this.buildCurrentStateDigest(currentState, dataProfile),
|
|
38
|
-
uiContextRef: {
|
|
39
|
-
componentId,
|
|
40
|
-
componentType,
|
|
41
|
-
},
|
|
42
|
-
...(dataProfile ? { dataProfile } : {}),
|
|
43
|
-
...(runtimeState ? { runtimeState } : {}),
|
|
44
|
-
...(schemaFields?.length ? { schemaFields } : {}),
|
|
45
|
-
...(contextHints ? { contextHints } : {}),
|
|
46
|
-
}));
|
|
47
|
-
return this.toTurnResult(this.compileAdapterResponse(response), request);
|
|
48
|
-
}
|
|
49
|
-
async apply(request) {
|
|
50
|
-
const patch = this.toRecord(request.pendingPatch);
|
|
51
|
-
if (!patch) {
|
|
52
|
-
return {
|
|
53
|
-
state: 'error',
|
|
54
|
-
phase: 'apply',
|
|
55
|
-
assistantMessage: 'Nao ha alteracao de tabela pronta para aplicar.',
|
|
56
|
-
errorText: 'Nao ha alteracao de tabela pronta para aplicar.',
|
|
57
|
-
canApply: false,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
const result = await this.adapter.applyPatch(patch, request.prompt);
|
|
61
|
-
if (!result.success) {
|
|
62
|
-
return {
|
|
63
|
-
state: 'error',
|
|
64
|
-
phase: 'apply',
|
|
65
|
-
assistantMessage: result.error || 'Nao foi possivel aplicar as alteracoes na tabela.',
|
|
66
|
-
errorText: result.error || 'Nao foi possivel aplicar as alteracoes na tabela.',
|
|
67
|
-
canApply: true,
|
|
68
|
-
pendingPatch: patch,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
state: 'success',
|
|
73
|
-
phase: 'summarize',
|
|
74
|
-
assistantMessage: 'Alteracoes aplicadas na tabela.',
|
|
75
|
-
statusText: 'Alteracoes aplicadas na tabela.',
|
|
76
|
-
canApply: false,
|
|
77
|
-
pendingPatch: null,
|
|
78
|
-
diagnostics: result.warnings?.length ? { warnings: result.warnings } : undefined,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
cancel() {
|
|
82
|
-
return Promise.resolve({
|
|
83
|
-
state: 'listening',
|
|
84
|
-
phase: 'capture',
|
|
85
|
-
assistantMessage: 'Solicitacao cancelada.',
|
|
86
|
-
statusText: '',
|
|
87
|
-
canApply: false,
|
|
88
|
-
pendingPatch: null,
|
|
89
|
-
pendingClarification: null,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
retry(request) {
|
|
93
|
-
const lastPrompt = [...(request.messages ?? [])].reverse()
|
|
94
|
-
.find((message) => message.role === 'user')?.text;
|
|
95
|
-
return this.submit({
|
|
96
|
-
...request,
|
|
97
|
-
prompt: lastPrompt ?? request.prompt,
|
|
98
|
-
action: { kind: 'retry' },
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
toTurnResult(response, request) {
|
|
102
|
-
if (!response) {
|
|
103
|
-
return {
|
|
104
|
-
state: 'error',
|
|
105
|
-
phase: 'capture',
|
|
106
|
-
assistantMessage: 'Resposta vazia da IA.',
|
|
107
|
-
errorText: 'Resposta vazia da IA.',
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
if (response.sessionId && response.sessionId !== request.sessionId) {
|
|
111
|
-
request = { ...request, sessionId: response.sessionId };
|
|
112
|
-
}
|
|
113
|
-
if (response.type === 'clarification') {
|
|
114
|
-
const questions = this.toClarificationQuestions(response);
|
|
115
|
-
return {
|
|
116
|
-
state: 'clarification',
|
|
117
|
-
phase: 'clarify',
|
|
118
|
-
sessionId: response.sessionId ?? request.sessionId,
|
|
119
|
-
assistantMessage: response.message || 'Preciso de mais detalhes para continuar.',
|
|
120
|
-
clarificationQuestions: questions,
|
|
121
|
-
quickReplies: this.toQuickReplies(response),
|
|
122
|
-
canApply: false,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
if (response.type === 'info') {
|
|
126
|
-
const message = response.message || response.explanation || 'Informacao gerada.';
|
|
127
|
-
return {
|
|
128
|
-
state: 'success',
|
|
129
|
-
phase: 'summarize',
|
|
130
|
-
sessionId: response.sessionId ?? request.sessionId,
|
|
131
|
-
assistantMessage: message,
|
|
132
|
-
statusText: message,
|
|
133
|
-
canApply: false,
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
if (response.type === 'error') {
|
|
137
|
-
const message = response.message || 'Falha ao gerar alteracao de tabela.';
|
|
138
|
-
return {
|
|
139
|
-
state: 'error',
|
|
140
|
-
phase: 'capture',
|
|
141
|
-
sessionId: response.sessionId ?? request.sessionId,
|
|
142
|
-
assistantMessage: message,
|
|
143
|
-
errorText: message,
|
|
144
|
-
diagnostics: response.warnings?.length ? { warnings: response.warnings } : undefined,
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
if (response.patch && Object.keys(response.patch).length > 0) {
|
|
148
|
-
const warnings = response.warnings?.filter(Boolean) ?? [];
|
|
149
|
-
const suffix = warnings.length ? ` Avisos: ${warnings.join('; ')}` : '';
|
|
150
|
-
return {
|
|
151
|
-
state: 'review',
|
|
152
|
-
phase: 'review',
|
|
153
|
-
sessionId: response.sessionId ?? request.sessionId,
|
|
154
|
-
assistantMessage: `${response.explanation || 'Proposta de alteracao pronta para revisar.'}${suffix}`,
|
|
155
|
-
statusText: 'Revise a proposta antes de aplicar.',
|
|
156
|
-
canApply: true,
|
|
157
|
-
pendingPatch: response.patch,
|
|
158
|
-
preview: {
|
|
159
|
-
kind: 'table-config-patch',
|
|
160
|
-
diff: response.diff ?? [],
|
|
161
|
-
},
|
|
162
|
-
diagnostics: warnings.length ? { warnings } : undefined,
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
return {
|
|
166
|
-
state: 'success',
|
|
167
|
-
phase: 'summarize',
|
|
168
|
-
sessionId: response.sessionId ?? request.sessionId,
|
|
169
|
-
assistantMessage: response.message || response.explanation || 'Nenhuma alteracao necessaria.',
|
|
170
|
-
statusText: response.message || response.explanation || 'Nenhuma alteracao necessaria.',
|
|
171
|
-
canApply: false,
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
compileAdapterResponse(response) {
|
|
175
|
-
const compiled = this.adapter.compileAiResponse?.(response);
|
|
176
|
-
if (!compiled) {
|
|
177
|
-
return response;
|
|
178
|
-
}
|
|
179
|
-
const warnings = [
|
|
180
|
-
...(response.warnings ?? []),
|
|
181
|
-
...(compiled.warnings ?? []),
|
|
182
|
-
];
|
|
183
|
-
return {
|
|
184
|
-
...response,
|
|
185
|
-
...compiled,
|
|
186
|
-
warnings: warnings.length ? warnings : undefined,
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
toChatMessages(messages, prompt) {
|
|
190
|
-
const supported = (messages ?? [])
|
|
191
|
-
.filter((message) => message.role === 'user' || message.role === 'assistant' || message.role === 'system')
|
|
192
|
-
.map((message) => ({
|
|
193
|
-
role: message.role,
|
|
194
|
-
content: message.text,
|
|
195
|
-
}))
|
|
196
|
-
.filter((message) => message.content.trim().length > 0);
|
|
197
|
-
return supported.length ? supported : [{ role: 'user', content: prompt }];
|
|
198
|
-
}
|
|
199
|
-
toClarificationQuestions(response) {
|
|
200
|
-
const labels = response.questions?.length
|
|
201
|
-
? response.questions
|
|
202
|
-
: response.message
|
|
203
|
-
? [response.message]
|
|
204
|
-
: ['Qual ajuste voce quer aplicar na tabela?'];
|
|
205
|
-
const options = this.toQuickReplies(response).map((reply) => ({
|
|
206
|
-
id: reply.id,
|
|
207
|
-
label: reply.label,
|
|
208
|
-
value: reply.prompt,
|
|
209
|
-
}));
|
|
210
|
-
return labels.map((label, index) => ({
|
|
211
|
-
id: `table-clarification-${index + 1}`,
|
|
212
|
-
type: options.length ? 'single-choice' : 'text',
|
|
213
|
-
label,
|
|
214
|
-
allowCustom: true,
|
|
215
|
-
options,
|
|
216
|
-
}));
|
|
217
|
-
}
|
|
218
|
-
toQuickReplies(response) {
|
|
219
|
-
const payloads = response.optionPayloads ?? [];
|
|
220
|
-
if (payloads.length) {
|
|
221
|
-
return payloads
|
|
222
|
-
.map((option, index) => {
|
|
223
|
-
const label = option.label?.trim() || option.value?.trim() || `Opcao ${index + 1}`;
|
|
224
|
-
const prompt = option.example?.trim() || option.value?.trim() || label;
|
|
225
|
-
return {
|
|
226
|
-
id: `option-${index + 1}`,
|
|
227
|
-
label,
|
|
228
|
-
prompt,
|
|
229
|
-
kind: 'clarification-option',
|
|
230
|
-
};
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
return (response.options ?? [])
|
|
234
|
-
.filter((option) => !!option?.trim())
|
|
235
|
-
.map((option, index) => ({
|
|
236
|
-
id: `option-${index + 1}`,
|
|
237
|
-
label: option.trim(),
|
|
238
|
-
prompt: option.trim(),
|
|
239
|
-
kind: 'clarification-option',
|
|
240
|
-
}));
|
|
241
|
-
}
|
|
242
|
-
buildCurrentStateDigest(currentState, dataProfile) {
|
|
243
|
-
const columns = Array.isArray(currentState['columns'])
|
|
244
|
-
? currentState['columns']
|
|
245
|
-
.map((column) => this.toRecord(column)?.['field'])
|
|
246
|
-
.filter((field) => typeof field === 'string' && field.length > 0)
|
|
247
|
-
: undefined;
|
|
248
|
-
const rowCount = typeof dataProfile?.['rowCount'] === 'number' ? dataProfile['rowCount'] : undefined;
|
|
249
|
-
return {
|
|
250
|
-
...(columns?.length ? { columns } : {}),
|
|
251
|
-
...(rowCount !== undefined ? { rowCount } : {}),
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
optionalJsonObject(value) {
|
|
255
|
-
if (value === undefined || value === null) {
|
|
256
|
-
return undefined;
|
|
257
|
-
}
|
|
258
|
-
const object = this.toAiJsonObject(value);
|
|
259
|
-
return Object.keys(object).length ? object : undefined;
|
|
260
|
-
}
|
|
261
|
-
toAiJsonObject(value) {
|
|
262
|
-
const record = this.toRecord(value);
|
|
263
|
-
if (!record) {
|
|
264
|
-
return {};
|
|
265
|
-
}
|
|
266
|
-
try {
|
|
267
|
-
return JSON.parse(JSON.stringify(record));
|
|
268
|
-
}
|
|
269
|
-
catch {
|
|
270
|
-
return {};
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
toRecord(value) {
|
|
274
|
-
return value && typeof value === 'object' && !Array.isArray(value)
|
|
275
|
-
? value
|
|
276
|
-
: null;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
export { TableAgenticAuthoringTurnFlow };
|