@praxisui/dynamic-form 8.0.0-beta.32 → 8.0.0-beta.34
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/fesm2022/{praxisui-dynamic-form-dynamic-form-agentic-authoring-turn-flow-IcmiP6u5.mjs → praxisui-dynamic-form-dynamic-form-agentic-authoring-turn-flow-CmFfx-VR.mjs} +23 -2
- package/fesm2022/praxisui-dynamic-form.mjs +62 -6
- package/package.json +8 -8
- package/types/praxisui-dynamic-form.d.ts +3 -0
|
@@ -21,7 +21,7 @@ class DynamicFormAgenticAuthoringTurnFlow {
|
|
|
21
21
|
const componentType = this.adapter.componentType || request.componentType || 'form';
|
|
22
22
|
const currentState = this.toAiJsonObject(this.adapter.getCurrentConfig());
|
|
23
23
|
const runtimeState = this.optionalJsonObject(this.adapter.getRuntimeState?.());
|
|
24
|
-
const contextHints = this.optionalJsonObject(this.adapter.getAuthoringContext?.());
|
|
24
|
+
const contextHints = this.mergeJsonObjects(this.optionalJsonObject(this.adapter.getAuthoringContext?.()), this.optionalJsonObject(request.action?.contextHints));
|
|
25
25
|
if (this.shouldRestrictToInlineHelp(contextHints)) {
|
|
26
26
|
return this.toInlineHelpOnlyResult(prompt, request, contextHints);
|
|
27
27
|
}
|
|
@@ -121,6 +121,7 @@ class DynamicFormAgenticAuthoringTurnFlow {
|
|
|
121
121
|
state: 'clarification',
|
|
122
122
|
phase: 'clarify',
|
|
123
123
|
sessionId: response.sessionId ?? request.sessionId,
|
|
124
|
+
observationId: response.observationId ?? request.observationId ?? null,
|
|
124
125
|
assistantMessage: response.message || 'Preciso de mais detalhes para continuar.',
|
|
125
126
|
clarificationQuestions: questions,
|
|
126
127
|
quickReplies: this.toQuickReplies(response),
|
|
@@ -133,6 +134,7 @@ class DynamicFormAgenticAuthoringTurnFlow {
|
|
|
133
134
|
state: 'success',
|
|
134
135
|
phase: 'summarize',
|
|
135
136
|
sessionId: response.sessionId ?? request.sessionId,
|
|
137
|
+
observationId: response.observationId ?? request.observationId ?? null,
|
|
136
138
|
assistantMessage: message,
|
|
137
139
|
statusText: message,
|
|
138
140
|
canApply: false,
|
|
@@ -144,6 +146,7 @@ class DynamicFormAgenticAuthoringTurnFlow {
|
|
|
144
146
|
state: 'error',
|
|
145
147
|
phase: 'capture',
|
|
146
148
|
sessionId: response.sessionId ?? request.sessionId,
|
|
149
|
+
observationId: response.observationId ?? request.observationId ?? null,
|
|
147
150
|
assistantMessage: message,
|
|
148
151
|
errorText: message,
|
|
149
152
|
diagnostics: response.warnings?.length ? { warnings: response.warnings } : undefined,
|
|
@@ -156,6 +159,7 @@ class DynamicFormAgenticAuthoringTurnFlow {
|
|
|
156
159
|
state: 'review',
|
|
157
160
|
phase: 'review',
|
|
158
161
|
sessionId: response.sessionId ?? request.sessionId,
|
|
162
|
+
observationId: response.observationId ?? request.observationId ?? null,
|
|
159
163
|
assistantMessage: `${response.explanation || 'Proposta de alteracao pronta para revisar.'}${suffix}`,
|
|
160
164
|
statusText: 'Revise a proposta antes de aplicar.',
|
|
161
165
|
canApply: true,
|
|
@@ -171,6 +175,7 @@ class DynamicFormAgenticAuthoringTurnFlow {
|
|
|
171
175
|
state: 'success',
|
|
172
176
|
phase: 'summarize',
|
|
173
177
|
sessionId: response.sessionId ?? request.sessionId,
|
|
178
|
+
observationId: response.observationId ?? request.observationId ?? null,
|
|
174
179
|
assistantMessage: response.message || response.explanation || 'Nenhuma alteracao necessaria.',
|
|
175
180
|
statusText: response.message || response.explanation || 'Nenhuma alteracao necessaria.',
|
|
176
181
|
canApply: false,
|
|
@@ -229,6 +234,8 @@ class DynamicFormAgenticAuthoringTurnFlow {
|
|
|
229
234
|
id: reply.id,
|
|
230
235
|
label: reply.label,
|
|
231
236
|
value: reply.prompt,
|
|
237
|
+
description: reply.description ?? undefined,
|
|
238
|
+
contextHints: reply.contextHints ? { ...reply.contextHints } : undefined,
|
|
232
239
|
}));
|
|
233
240
|
return labels.map((label, index) => ({
|
|
234
241
|
id: `dynamic-form-clarification-${index + 1}`,
|
|
@@ -244,12 +251,14 @@ class DynamicFormAgenticAuthoringTurnFlow {
|
|
|
244
251
|
return payloads
|
|
245
252
|
.map((option, index) => {
|
|
246
253
|
const label = option.label?.trim() || option.value?.trim() || `Opcao ${index + 1}`;
|
|
247
|
-
const prompt = option.
|
|
254
|
+
const prompt = option.value?.trim() || option.example?.trim() || label;
|
|
248
255
|
return {
|
|
249
256
|
id: `option-${index + 1}`,
|
|
250
257
|
label,
|
|
251
258
|
prompt,
|
|
252
259
|
kind: 'clarification-option',
|
|
260
|
+
description: option.example?.trim() || undefined,
|
|
261
|
+
contextHints: this.optionalJsonObject(option.contextHints),
|
|
253
262
|
};
|
|
254
263
|
});
|
|
255
264
|
}
|
|
@@ -260,6 +269,8 @@ class DynamicFormAgenticAuthoringTurnFlow {
|
|
|
260
269
|
label: option.trim(),
|
|
261
270
|
prompt: option.trim(),
|
|
262
271
|
kind: 'clarification-option',
|
|
272
|
+
description: undefined,
|
|
273
|
+
contextHints: undefined,
|
|
263
274
|
}));
|
|
264
275
|
}
|
|
265
276
|
buildCurrentStateDigest(currentState, runtimeState) {
|
|
@@ -313,6 +324,16 @@ class DynamicFormAgenticAuthoringTurnFlow {
|
|
|
313
324
|
const object = this.toAiJsonObject(value);
|
|
314
325
|
return Object.keys(object).length ? object : undefined;
|
|
315
326
|
}
|
|
327
|
+
mergeJsonObjects(base, overlay) {
|
|
328
|
+
if (!base)
|
|
329
|
+
return overlay;
|
|
330
|
+
if (!overlay)
|
|
331
|
+
return base;
|
|
332
|
+
return {
|
|
333
|
+
...base,
|
|
334
|
+
...overlay,
|
|
335
|
+
};
|
|
336
|
+
}
|
|
316
337
|
toAiJsonObject(value) {
|
|
317
338
|
const record = this.toRecord(value);
|
|
318
339
|
if (!record) {
|
|
@@ -199,6 +199,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
199
199
|
* Non-date arrays and other values are returned untouched.
|
|
200
200
|
*/
|
|
201
201
|
function normalizeDateArrays(data) {
|
|
202
|
+
if (data instanceof Date) {
|
|
203
|
+
return data;
|
|
204
|
+
}
|
|
202
205
|
if (Array.isArray(data)) {
|
|
203
206
|
if (isDateArray(data)) {
|
|
204
207
|
return formatDateArray(data);
|
|
@@ -10861,7 +10864,7 @@ class PraxisDynamicForm {
|
|
|
10861
10864
|
if (this.loadedEntityId === this.pendingEntityId) {
|
|
10862
10865
|
if (this.loadedEntityData && Object.keys(this.form.controls).length) {
|
|
10863
10866
|
this.entityHydrationPending = false;
|
|
10864
|
-
this.form.patchValue(this.loadedEntityData);
|
|
10867
|
+
this.form.patchValue(this.normalizeFormPatchValue(this.loadedEntityData));
|
|
10865
10868
|
this.hydratedEntityId = this.pendingEntityId;
|
|
10866
10869
|
this.debugLog('[PDF] loadEntity:repatch', { id: this.pendingEntityId });
|
|
10867
10870
|
}
|
|
@@ -10883,7 +10886,7 @@ class PraxisDynamicForm {
|
|
|
10883
10886
|
next: (data) => {
|
|
10884
10887
|
this.entityHydrationPending = false;
|
|
10885
10888
|
if (data && typeof data === 'object') {
|
|
10886
|
-
const normalized =
|
|
10889
|
+
const normalized = this.normalizeFormPatchValue(data);
|
|
10887
10890
|
this.loadedEntityData = normalized;
|
|
10888
10891
|
if (Object.keys(this.form.controls).length) {
|
|
10889
10892
|
this.form.patchValue(normalized);
|
|
@@ -11229,7 +11232,7 @@ class PraxisDynamicForm {
|
|
|
11229
11232
|
: null;
|
|
11230
11233
|
const valueToRestore = snapshotValue ?? fallbackEntityValue ?? fallbackInitialValue;
|
|
11231
11234
|
if (valueToRestore) {
|
|
11232
|
-
this.form.patchValue(valueToRestore, { emitEvent: false });
|
|
11235
|
+
this.form.patchValue(this.normalizeFormPatchValue(valueToRestore), { emitEvent: false });
|
|
11233
11236
|
}
|
|
11234
11237
|
if (!previousState ||
|
|
11235
11238
|
!options.preserveInteractionState ||
|
|
@@ -11247,9 +11250,53 @@ class PraxisDynamicForm {
|
|
|
11247
11250
|
if (!this.initialValue || typeof this.initialValue !== 'object') {
|
|
11248
11251
|
return null;
|
|
11249
11252
|
}
|
|
11250
|
-
const normalized =
|
|
11253
|
+
const normalized = this.normalizeFormPatchValue(this.initialValue);
|
|
11251
11254
|
return Object.keys(normalized || {}).length ? normalized : null;
|
|
11252
11255
|
}
|
|
11256
|
+
normalizeFormPatchValue(value) {
|
|
11257
|
+
const normalized = normalizeDateArrays(value);
|
|
11258
|
+
if (!normalized || typeof normalized !== 'object' || Array.isArray(normalized)) {
|
|
11259
|
+
return normalized;
|
|
11260
|
+
}
|
|
11261
|
+
const fieldMetadata = this.config?.fieldMetadata || [];
|
|
11262
|
+
if (!fieldMetadata.length) {
|
|
11263
|
+
return normalized;
|
|
11264
|
+
}
|
|
11265
|
+
const result = { ...normalized };
|
|
11266
|
+
for (const field of fieldMetadata) {
|
|
11267
|
+
if (!field?.name || !this.isDateControlMetadata(field) || !(field.name in result)) {
|
|
11268
|
+
continue;
|
|
11269
|
+
}
|
|
11270
|
+
result[field.name] = this.coerceDateControlValue(result[field.name]);
|
|
11271
|
+
}
|
|
11272
|
+
return result;
|
|
11273
|
+
}
|
|
11274
|
+
isDateControlMetadata(field) {
|
|
11275
|
+
const controlType = normalizeControlTypeKey(field?.controlType);
|
|
11276
|
+
return controlType === 'DATE_PICKER' || controlType === 'DATE' || controlType === 'DATE_INPUT';
|
|
11277
|
+
}
|
|
11278
|
+
coerceDateControlValue(value) {
|
|
11279
|
+
if (value == null || value === '') {
|
|
11280
|
+
return value;
|
|
11281
|
+
}
|
|
11282
|
+
if (value instanceof Date) {
|
|
11283
|
+
return Number.isNaN(value.getTime()) ? null : value;
|
|
11284
|
+
}
|
|
11285
|
+
if (typeof value !== 'string') {
|
|
11286
|
+
return value;
|
|
11287
|
+
}
|
|
11288
|
+
const trimmed = value.trim();
|
|
11289
|
+
if (!trimmed) {
|
|
11290
|
+
return value;
|
|
11291
|
+
}
|
|
11292
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(trimmed)) {
|
|
11293
|
+
const [year, month, day] = trimmed.split('-').map(Number);
|
|
11294
|
+
const date = new Date(year, month - 1, day);
|
|
11295
|
+
return Number.isNaN(date.getTime()) ? value : date;
|
|
11296
|
+
}
|
|
11297
|
+
const parsed = new Date(trimmed);
|
|
11298
|
+
return Number.isNaN(parsed.getTime()) ? value : parsed;
|
|
11299
|
+
}
|
|
11253
11300
|
/**
|
|
11254
11301
|
* Backward-compatible required validation for DATE_RANGE controls.
|
|
11255
11302
|
* Some core builds do not enforce required start/end for dateRange fields.
|
|
@@ -13375,12 +13422,21 @@ class PraxisDynamicForm {
|
|
|
13375
13422
|
if (!controller)
|
|
13376
13423
|
return;
|
|
13377
13424
|
const state = controller.snapshot();
|
|
13425
|
+
const contextHints = reply.contextHints ? { ...reply.contextHints } : undefined;
|
|
13378
13426
|
const next$ = state.state === 'clarification'
|
|
13379
|
-
? controller.answerClarification(
|
|
13427
|
+
? controller.answerClarification({
|
|
13428
|
+
id: reply.id,
|
|
13429
|
+
label: reply.label,
|
|
13430
|
+
value: reply.prompt,
|
|
13431
|
+
description: reply.description ?? undefined,
|
|
13432
|
+
contextHints,
|
|
13433
|
+
})
|
|
13380
13434
|
: controller.submitPrompt(reply.prompt, {
|
|
13381
13435
|
kind: reply.kind || 'quick-reply',
|
|
13382
13436
|
id: reply.id,
|
|
13383
13437
|
value: reply.prompt,
|
|
13438
|
+
displayPrompt: reply.label,
|
|
13439
|
+
contextHints,
|
|
13384
13440
|
});
|
|
13385
13441
|
next$.subscribe((nextState) => {
|
|
13386
13442
|
this.aiAssistantPrompt = '';
|
|
@@ -13411,7 +13467,7 @@ class PraxisDynamicForm {
|
|
|
13411
13467
|
initializeAiAssistantController() {
|
|
13412
13468
|
if (this.aiAssistantController)
|
|
13413
13469
|
return;
|
|
13414
|
-
import('./praxisui-dynamic-form-dynamic-form-agentic-authoring-turn-flow-
|
|
13470
|
+
import('./praxisui-dynamic-form-dynamic-form-agentic-authoring-turn-flow-CmFfx-VR.mjs')
|
|
13415
13471
|
.then(({ DynamicFormAgenticAuthoringTurnFlow }) => {
|
|
13416
13472
|
if (this.aiAssistantController)
|
|
13417
13473
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@praxisui/dynamic-form",
|
|
3
|
-
"version": "8.0.0-beta.
|
|
3
|
+
"version": "8.0.0-beta.34",
|
|
4
4
|
"description": "Angular dynamic form engine for Praxis UI: metadata-driven forms, hooks, and services integrating @praxisui/* packages.",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@angular/common": "^21.0.0",
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
"@angular/forms": "^21.0.0",
|
|
10
10
|
"@angular/material": "^21.0.0",
|
|
11
11
|
"@angular/router": "^21.0.0",
|
|
12
|
-
"@praxisui/ai": "^8.0.0-beta.
|
|
13
|
-
"@praxisui/dynamic-fields": "^8.0.0-beta.
|
|
14
|
-
"@praxisui/metadata-editor": "^8.0.0-beta.
|
|
15
|
-
"@praxisui/rich-content": "^8.0.0-beta.
|
|
16
|
-
"@praxisui/settings-panel": "^8.0.0-beta.
|
|
17
|
-
"@praxisui/visual-builder": "^8.0.0-beta.
|
|
18
|
-
"@praxisui/core": "^8.0.0-beta.
|
|
12
|
+
"@praxisui/ai": "^8.0.0-beta.34",
|
|
13
|
+
"@praxisui/dynamic-fields": "^8.0.0-beta.34",
|
|
14
|
+
"@praxisui/metadata-editor": "^8.0.0-beta.34",
|
|
15
|
+
"@praxisui/rich-content": "^8.0.0-beta.34",
|
|
16
|
+
"@praxisui/settings-panel": "^8.0.0-beta.34",
|
|
17
|
+
"@praxisui/visual-builder": "^8.0.0-beta.34",
|
|
18
|
+
"@praxisui/core": "^8.0.0-beta.34",
|
|
19
19
|
"rxjs": "^7.8.0"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
@@ -999,6 +999,9 @@ declare class PraxisDynamicForm implements OnInit, OnChanges, OnDestroy {
|
|
|
999
999
|
private isCompatibleRuntimeStateContext;
|
|
1000
1000
|
private restoreFormRuntimeState;
|
|
1001
1001
|
private getNormalizedInitialValue;
|
|
1002
|
+
private normalizeFormPatchValue;
|
|
1003
|
+
private isDateControlMetadata;
|
|
1004
|
+
private coerceDateControlValue;
|
|
1002
1005
|
/**
|
|
1003
1006
|
* Backward-compatible required validation for DATE_RANGE controls.
|
|
1004
1007
|
* Some core builds do not enforce required start/end for dateRange fields.
|