@skopon-cool/form-sdk 0.1.3 → 0.1.5
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 +2 -0
- package/dist/adapter/a2uiAdapter.d.ts +0 -1
- package/dist/adapter/a2uiAdapter.d.ts.map +1 -1
- package/dist/adapter/formSchema.d.ts.map +1 -1
- package/dist/blocks/case_multiselect/adapter.d.ts +10 -0
- package/dist/blocks/case_multiselect/adapter.d.ts.map +1 -0
- package/dist/blocks/case_multiselect/index.d.ts +3 -0
- package/dist/blocks/case_multiselect/index.d.ts.map +1 -0
- package/dist/blocks/case_singleselect/catalog.d.ts +2 -0
- package/dist/blocks/case_singleselect/catalog.d.ts.map +1 -0
- package/dist/blocks/registry.d.ts +8 -0
- package/dist/blocks/registry.d.ts.map +1 -0
- package/dist/blocks/resume_multiselect/adapter.d.ts +10 -0
- package/dist/blocks/resume_multiselect/adapter.d.ts.map +1 -0
- package/dist/blocks/resume_multiselect/catalog.d.ts +2 -0
- package/dist/blocks/resume_multiselect/catalog.d.ts.map +1 -0
- package/dist/blocks/resume_multiselect/index.d.ts +3 -0
- package/dist/blocks/resume_multiselect/index.d.ts.map +1 -0
- package/dist/blocks/types.d.ts +27 -0
- package/dist/blocks/types.d.ts.map +1 -0
- package/dist/catalog/a2uiCustomCatalog.d.ts.map +1 -1
- package/dist/catalog/caseSearchContext.d.ts +28 -0
- package/dist/catalog/caseSearchContext.d.ts.map +1 -0
- package/dist/catalog/resumeSearchContext.d.ts +39 -0
- package/dist/catalog/resumeSearchContext.d.ts.map +1 -0
- package/dist/catalog/skoponCaseSelect.d.ts +2 -0
- package/dist/catalog/skoponCaseSelect.d.ts.map +1 -0
- package/dist/catalog/skoponResumeSelect.d.ts +2 -0
- package/dist/catalog/skoponResumeSelect.d.ts.map +1 -0
- package/dist/components/AskUserFormCard.d.ts +7 -1
- package/dist/components/AskUserFormCard.d.ts.map +1 -1
- package/dist/components/SkoponA2uiStreamRenderer.d.ts +7 -1
- package/dist/components/SkoponA2uiStreamRenderer.d.ts.map +1 -1
- package/dist/components/SkoponFormRenderer.d.ts +6 -0
- package/dist/components/SkoponFormRenderer.d.ts.map +1 -1
- package/dist/form-sdk.css +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1374 -889
- package/dist/submit/buildCurlStatement.d.ts +1 -1
- package/dist/submit/buildCurlStatement.d.ts.map +1 -1
- package/dist/submit/intersectPayloadBlocksWithForm.d.ts.map +1 -1
- package/dist/types/index.d.ts +33 -2
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/adapter/a2uiAdapter.test.ts +71 -0
- package/src/adapter/a2uiAdapter.ts +41 -4
- package/src/adapter/formSchema.ts +102 -19
- package/src/blocks/case_multiselect/adapter.ts +90 -0
- package/src/blocks/case_multiselect/index.ts +14 -0
- package/src/blocks/case_singleselect/catalog.ts +1 -0
- package/src/blocks/registry.ts +34 -0
- package/src/blocks/resume_multiselect/adapter.ts +57 -0
- package/src/blocks/resume_multiselect/catalog.ts +1 -0
- package/src/blocks/resume_multiselect/index.ts +14 -0
- package/src/blocks/types.ts +34 -0
- package/src/catalog/a2uiCustomCatalog.tsx +6 -0
- package/src/catalog/caseSearchContext.tsx +46 -0
- package/src/catalog/resumeSearchContext.tsx +58 -0
- package/src/catalog/skoponCaseSelect.tsx +240 -0
- package/src/catalog/skoponResumeSelect.tsx +293 -0
- package/src/components/AskUserFormCard.tsx +13 -1
- package/src/components/SkoponA2uiStreamRenderer.test.ts +18 -2
- package/src/components/SkoponA2uiStreamRenderer.test.tsx +26 -2
- package/src/components/SkoponA2uiStreamRenderer.tsx +71 -27
- package/src/components/SkoponFormRenderer.tsx +32 -10
- package/src/index.ts +23 -0
- package/src/styles/a2ui-preview.css +4 -4
- package/src/styles/index.css +191 -0
- package/src/submit/buildCurlStatement.ts +2 -23
- package/src/submit/intersectPayloadBlocksWithForm.ts +14 -2
- package/src/submit/submit.test.ts +34 -3
- package/src/types/index.ts +37 -0
|
@@ -127,7 +127,12 @@ function blockValueFromDefault(block: FormBlock): unknown {
|
|
|
127
127
|
const { type, defaultValue } = block
|
|
128
128
|
if (defaultValue !== undefined) {
|
|
129
129
|
if (type === 'toggle') return defaultValue === true || defaultValue === 'true'
|
|
130
|
-
if (
|
|
130
|
+
if (
|
|
131
|
+
type === 'multiselect' ||
|
|
132
|
+
type === 'checkbox' ||
|
|
133
|
+
type === 'resume_multiselect' ||
|
|
134
|
+
type === 'case_multiselect'
|
|
135
|
+
) {
|
|
131
136
|
if (Array.isArray(defaultValue)) return defaultValue.map(String)
|
|
132
137
|
if (typeof defaultValue === 'string' && defaultValue) return [defaultValue]
|
|
133
138
|
return []
|
|
@@ -135,7 +140,14 @@ function blockValueFromDefault(block: FormBlock): unknown {
|
|
|
135
140
|
return defaultValue
|
|
136
141
|
}
|
|
137
142
|
if (type === 'toggle') return false
|
|
138
|
-
if (
|
|
143
|
+
if (
|
|
144
|
+
type === 'multiselect' ||
|
|
145
|
+
type === 'checkbox' ||
|
|
146
|
+
type === 'resume_multiselect' ||
|
|
147
|
+
type === 'case_multiselect'
|
|
148
|
+
) {
|
|
149
|
+
return []
|
|
150
|
+
}
|
|
139
151
|
if (type === 'number') return null
|
|
140
152
|
return ''
|
|
141
153
|
}
|
|
@@ -31,21 +31,26 @@ describe('buildCurlStatement', () => {
|
|
|
31
31
|
})
|
|
32
32
|
|
|
33
33
|
describe('buildAskUserCurlStatement', () => {
|
|
34
|
-
it('
|
|
34
|
+
it('merges card and extra values into valid JSON', () => {
|
|
35
35
|
const body = buildAskUserCurlBodyJson(
|
|
36
36
|
{ video_title: 'hello' },
|
|
37
37
|
{ agent_hint: '请尽快确认' },
|
|
38
38
|
)
|
|
39
39
|
expect(body).toContain('"video_title": "hello"')
|
|
40
|
-
expect(body).toContain('// 额外字段(未在卡片展示)')
|
|
41
40
|
expect(body).toContain('"agent_hint": "请尽快确认"')
|
|
41
|
+
expect(body).not.toContain('// 额外字段')
|
|
42
|
+
expect(JSON.parse(body)).toEqual({
|
|
43
|
+
video_title: 'hello',
|
|
44
|
+
agent_hint: '请尽快确认',
|
|
45
|
+
})
|
|
42
46
|
|
|
43
47
|
const curl = buildAskUserCurlStatement({
|
|
44
48
|
cardValues: { video_title: 'hello' },
|
|
45
49
|
extraValues: { agent_hint: '请尽快确认' },
|
|
46
50
|
callbackUrl: 'https://example.com/hook',
|
|
47
51
|
})
|
|
48
|
-
expect(curl).toContain('
|
|
52
|
+
expect(curl).toContain('"agent_hint": "请尽快确认"')
|
|
53
|
+
expect(curl).not.toContain('// 额外字段')
|
|
49
54
|
})
|
|
50
55
|
})
|
|
51
56
|
|
|
@@ -96,6 +101,18 @@ describe('intersectPayloadBlocksWithForm', () => {
|
|
|
96
101
|
expect(extractExtraBlockValues(result.extraBlocks)).toEqual({ agent_hint: 'hint' })
|
|
97
102
|
})
|
|
98
103
|
|
|
104
|
+
it('defaults resume_multiselect extra blocks to empty array', () => {
|
|
105
|
+
const extraBlocks = [
|
|
106
|
+
{
|
|
107
|
+
id: '1',
|
|
108
|
+
type: 'resume_multiselect' as const,
|
|
109
|
+
name: 'resumes',
|
|
110
|
+
label: 'Resumes',
|
|
111
|
+
},
|
|
112
|
+
]
|
|
113
|
+
expect(extractExtraBlockValues(extraBlocks)).toEqual({ resumes: [] })
|
|
114
|
+
})
|
|
115
|
+
|
|
99
116
|
it('keeps form block type and schema when payload type differs', () => {
|
|
100
117
|
const selectForm: FormSchema = {
|
|
101
118
|
title: 'Form',
|
|
@@ -195,6 +212,20 @@ describe('payload fallback helpers', () => {
|
|
|
195
212
|
expect(payloadHasInputBlocks(surveyPayload)).toBe(true)
|
|
196
213
|
expect(getPayloadRenderableBlocks(surveyPayload).length).toBeGreaterThan(0)
|
|
197
214
|
})
|
|
215
|
+
|
|
216
|
+
it('prefers payload fallback blocks when intersection only has layout blocks', () => {
|
|
217
|
+
const result = intersectPayloadBlocksWithForm(surveyPayload, undefined)
|
|
218
|
+
const usePayloadFallback =
|
|
219
|
+
payloadHasInputBlocks(surveyPayload) && result.matchedBlocks.length === 0
|
|
220
|
+
expect(usePayloadFallback).toBe(true)
|
|
221
|
+
expect(result.renderBlocks.map((b) => b.type)).toEqual(['heading'])
|
|
222
|
+
|
|
223
|
+
const renderBlocks = usePayloadFallback
|
|
224
|
+
? getPayloadRenderableBlocks(surveyPayload)
|
|
225
|
+
: result.renderBlocks
|
|
226
|
+
expect(renderBlocks.map((b) => b.id)).toEqual(['title', 'q1'])
|
|
227
|
+
expect(getPayloadInputFieldNames(surveyPayload)).toEqual(['occupation'])
|
|
228
|
+
})
|
|
198
229
|
})
|
|
199
230
|
|
|
200
231
|
describe('submitFormJson', () => {
|
package/src/types/index.ts
CHANGED
|
@@ -17,6 +17,8 @@ export type A2uiComponentName =
|
|
|
17
17
|
| 'FileUpload'
|
|
18
18
|
| 'SkoponMedia'
|
|
19
19
|
| 'SkoponSelect'
|
|
20
|
+
| 'SkoponResumeSelect'
|
|
21
|
+
| 'SkoponCaseSelect'
|
|
20
22
|
|
|
21
23
|
export interface A2uiComponentNode {
|
|
22
24
|
id: string
|
|
@@ -53,6 +55,10 @@ export type FormBlockType =
|
|
|
53
55
|
| 'datetime'
|
|
54
56
|
| 'time'
|
|
55
57
|
| 'file'
|
|
58
|
+
| 'resume_multiselect'
|
|
59
|
+
| 'case_multiselect'
|
|
60
|
+
/** @deprecated 加载时自动迁移为 case_multiselect */
|
|
61
|
+
| 'case_singleselect'
|
|
56
62
|
| 'image'
|
|
57
63
|
| 'video'
|
|
58
64
|
| 'audio'
|
|
@@ -80,6 +86,29 @@ export interface FormBlockOption {
|
|
|
80
86
|
label: string
|
|
81
87
|
}
|
|
82
88
|
|
|
89
|
+
/** 简历多选组件:渲染时用于 /univ/resume/search 的筛选条件 */
|
|
90
|
+
export interface FormResumeFilter {
|
|
91
|
+
names?: string[]
|
|
92
|
+
agentUniqueIds?: string[]
|
|
93
|
+
resumeUniqueIds?: string[]
|
|
94
|
+
pageSize?: number
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** 案例多选组件:渲染时用于 /univ/case/list 的筛选条件 */
|
|
98
|
+
export interface FormCaseFilter {
|
|
99
|
+
/** Agent 类型(编辑器辅助,运行时不用) */
|
|
100
|
+
agentKind?: string
|
|
101
|
+
/** Agent unique_id(运行时用于限定所属 Agent) */
|
|
102
|
+
agentUniqueId?: string
|
|
103
|
+
/** 流类型 unique_id */
|
|
104
|
+
flowType?: string
|
|
105
|
+
/** 流类别 unique_id */
|
|
106
|
+
category?: string
|
|
107
|
+
/** 流程编号(flow_unique_id)多选 */
|
|
108
|
+
flowUniqueIds?: string[]
|
|
109
|
+
pageSize?: number
|
|
110
|
+
}
|
|
111
|
+
|
|
83
112
|
export interface FormBlock {
|
|
84
113
|
id: string
|
|
85
114
|
type: FormBlockType
|
|
@@ -98,6 +127,14 @@ export interface FormBlock {
|
|
|
98
127
|
fileMinCount?: number
|
|
99
128
|
fileMaxCount?: number
|
|
100
129
|
defaultValue?: string | string[] | boolean
|
|
130
|
+
/** 简历多选:是否显示「换一批」 */
|
|
131
|
+
resumeEnableRefresh?: boolean
|
|
132
|
+
/** 简历多选:列表筛选条件(持久化进 block json) */
|
|
133
|
+
resumeFilter?: FormResumeFilter
|
|
134
|
+
/** 案例单选:是否显示「换一批」 */
|
|
135
|
+
caseEnableRefresh?: boolean
|
|
136
|
+
/** 案例单选:列表筛选条件(持久化进 block json) */
|
|
137
|
+
caseFilter?: FormCaseFilter
|
|
101
138
|
}
|
|
102
139
|
|
|
103
140
|
export interface FormSchema {
|