@skopon-cool/form-sdk 0.4.7 → 0.4.8
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/package.json
CHANGED
|
@@ -14,6 +14,20 @@ function readString(value: unknown): string {
|
|
|
14
14
|
return typeof value === 'string' ? value : ''
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/** 与 formSchema.normalizeFlowUniqueIds 对齐:兼容数组 / JSON 数组字符串。 */
|
|
18
|
+
function readFlowUniqueIds(raw: unknown): string[] {
|
|
19
|
+
if (Array.isArray(raw)) return raw.map(String).filter(Boolean)
|
|
20
|
+
if (typeof raw === 'string' && raw.trim()) {
|
|
21
|
+
try {
|
|
22
|
+
const parsed: unknown = JSON.parse(raw)
|
|
23
|
+
if (Array.isArray(parsed)) return parsed.map(String).filter(Boolean)
|
|
24
|
+
} catch {
|
|
25
|
+
/* ignore */
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return []
|
|
29
|
+
}
|
|
30
|
+
|
|
17
31
|
function readCaseFilter(raw: unknown): FormCaseFilter {
|
|
18
32
|
if (!raw || typeof raw !== 'object') {
|
|
19
33
|
return { flowUniqueIds: [], pageSize: 20 }
|
|
@@ -40,9 +54,7 @@ function readCaseFilter(raw: unknown): FormCaseFilter {
|
|
|
40
54
|
typeof rec.category === 'string' && rec.category.trim()
|
|
41
55
|
? rec.category.trim()
|
|
42
56
|
: undefined
|
|
43
|
-
const flowUniqueIds =
|
|
44
|
-
? rec.flowUniqueIds.map(String).filter(Boolean)
|
|
45
|
-
: []
|
|
57
|
+
const flowUniqueIds = readFlowUniqueIds(rec.flowUniqueIds)
|
|
46
58
|
return { agentKind, agentUniqueId, flowType, category, flowUniqueIds, pageSize }
|
|
47
59
|
}
|
|
48
60
|
|
|
@@ -355,10 +355,20 @@ function AskUserFormCardBody({
|
|
|
355
355
|
return
|
|
356
356
|
}
|
|
357
357
|
|
|
358
|
+
// form 必须是交集后的有效 schema(含 ask 动态 caseFilter),
|
|
359
|
+
// 不能传 vt_forms 原始 formDef,否则 flowUniqueIds 等会被编辑器默认冲掉。
|
|
360
|
+
const effectiveForm =
|
|
361
|
+
renderBlocks.length > 0
|
|
362
|
+
? {
|
|
363
|
+
title: surfaceTitle,
|
|
364
|
+
description: surfaceDescription,
|
|
365
|
+
blocks: renderBlocks,
|
|
366
|
+
}
|
|
367
|
+
: (payloadDef ?? undefined)
|
|
358
368
|
const body = buildAnswerAgentBody({
|
|
359
369
|
context: resolvedAnswerAgentContext,
|
|
360
370
|
payload,
|
|
361
|
-
form:
|
|
371
|
+
form: effectiveForm,
|
|
362
372
|
answer,
|
|
363
373
|
})
|
|
364
374
|
const agentError = validateAnswerAgentBody(body)
|
|
@@ -388,6 +398,8 @@ function AskUserFormCardBody({
|
|
|
388
398
|
submitting,
|
|
389
399
|
fieldNames,
|
|
390
400
|
renderBlocks,
|
|
401
|
+
surfaceTitle,
|
|
402
|
+
surfaceDescription,
|
|
391
403
|
extraValues,
|
|
392
404
|
reportSnapshot,
|
|
393
405
|
runtime,
|
|
@@ -396,7 +408,6 @@ function AskUserFormCardBody({
|
|
|
396
408
|
resolvedSubmitHeaders,
|
|
397
409
|
resolvedAnswerAgentContext,
|
|
398
410
|
payload,
|
|
399
|
-
formDef,
|
|
400
411
|
payloadDef,
|
|
401
412
|
])
|
|
402
413
|
|