@baishuyun/coze-provider 2.0.34 → 2.1.0-alpha.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.
- package/.turbo/turbo-build.log +11 -11
- package/CHANGELOG.md +449 -439
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1300 -290
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1286 -286
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -5
- package/src/const.ts +1 -1
- package/src/coze-language-model.ts +246 -246
- package/src/coze-provider.ts +99 -99
- package/src/evt-sample.ts +28 -28
- package/src/index.ts +4 -4
- package/src/stream-trasnformer/fields-json-transform-stream.ts +110 -110
- package/src/stream-trasnformer/llm-chunk-injector-transform-stream.ts +60 -60
- package/src/stream-trasnformer/llm-part-transform-stream.ts +30 -30
- package/src/stream-trasnformer/mcp-chunk-filter-transform-stream.ts +47 -47
- package/src/stream-trasnformer/suggestion-transform-stream.ts +35 -35
- package/src/types.ts +49 -49
- package/src/utils/accumulate-sse-response.ts +83 -83
- package/src/utils/build-generate-result-by-chat-res.ts +71 -71
- package/src/utils/create-coze-non-streaming-chat.ts +54 -54
- package/src/utils/create-error-stream.ts +32 -32
- package/src/utils/enqueue-text-info.ts +45 -45
- package/src/utils/excel2json.ts +58 -58
- package/src/utils/get-coze-chat-msg-detail.ts +19 -19
- package/src/utils/mcp-to-llm-chunk.ts +109 -109
- package/src/utils/parse-multi-modal-message.ts +36 -36
- package/src/utils/prompt-to-model-msg.ts +91 -91
- package/tsconfig.json +14 -14
- package/tsup.config.ts +16 -16
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -29,62 +39,95 @@ module.exports = __toCommonJS(index_exports);
|
|
|
29
39
|
|
|
30
40
|
// src/coze-provider.ts
|
|
31
41
|
var import_provider = require("@ai-sdk/provider");
|
|
32
|
-
var
|
|
42
|
+
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
33
43
|
|
|
34
44
|
// src/const.ts
|
|
35
45
|
var VERSION = "0.0.1";
|
|
36
46
|
|
|
37
47
|
// src/coze-language-model.ts
|
|
38
|
-
var
|
|
39
|
-
var
|
|
48
|
+
var import_parse_sse = require("parse-sse");
|
|
49
|
+
var import_web = require("stream/web");
|
|
40
50
|
|
|
41
51
|
// src/utils/prompt-to-model-msg.ts
|
|
42
52
|
var import_api = require("@coze/api");
|
|
53
|
+
|
|
54
|
+
// src/utils/excel2json.ts
|
|
55
|
+
var import_xlsx = __toESM(require("xlsx"));
|
|
56
|
+
var excel2json = (file) => {
|
|
57
|
+
const workbook = import_xlsx.default.read(file, {
|
|
58
|
+
type: "array",
|
|
59
|
+
// 或 'buffer'
|
|
60
|
+
cellStyles: true,
|
|
61
|
+
cellFormula: true,
|
|
62
|
+
cellDates: true,
|
|
63
|
+
cellNF: true,
|
|
64
|
+
sheetStubs: true,
|
|
65
|
+
bookVBA: true
|
|
66
|
+
});
|
|
67
|
+
const result = {
|
|
68
|
+
sheets: []
|
|
69
|
+
};
|
|
70
|
+
workbook.SheetNames.forEach((sheetName) => {
|
|
71
|
+
const worksheet = workbook.Sheets[sheetName];
|
|
72
|
+
const data = import_xlsx.default.utils.sheet_to_json(worksheet, {
|
|
73
|
+
header: 1,
|
|
74
|
+
// 使用数组格式
|
|
75
|
+
defval: null,
|
|
76
|
+
// 空单元格默认值
|
|
77
|
+
raw: false,
|
|
78
|
+
// 格式化值
|
|
79
|
+
dateNF: "yyyy-mm-dd"
|
|
80
|
+
// 日期格式
|
|
81
|
+
});
|
|
82
|
+
result.sheets.push({
|
|
83
|
+
name: sheetName,
|
|
84
|
+
data,
|
|
85
|
+
range: worksheet["!ref"],
|
|
86
|
+
merges: worksheet["!merges"] || []
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
return JSON.stringify(result);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// src/utils/prompt-to-model-msg.ts
|
|
43
93
|
var decoder = new TextDecoder("utf-8");
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
return "text";
|
|
47
|
-
}
|
|
48
|
-
const isImg = part.mediaType?.startsWith("image/");
|
|
49
|
-
if (isImg) {
|
|
50
|
-
return "image";
|
|
51
|
-
}
|
|
52
|
-
const isAudio = part.mediaType?.startsWith("audio/");
|
|
53
|
-
if (isAudio) {
|
|
54
|
-
return "audio";
|
|
55
|
-
}
|
|
56
|
-
return "file";
|
|
94
|
+
var data2csvText = (data) => {
|
|
95
|
+
return decoder.decode(data);
|
|
57
96
|
};
|
|
58
|
-
var parseMessageContent = (message,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
97
|
+
var parseMessageContent = (message, isMultiModalMsg) => {
|
|
98
|
+
const result = message.content.map((part) => {
|
|
99
|
+
if (part.type === "text") {
|
|
100
|
+
return part.text;
|
|
101
|
+
}
|
|
102
|
+
const isCsv = part.mediaType === "text/csv";
|
|
103
|
+
const isTxt = part.mediaType === "text/plain";
|
|
104
|
+
const isImg = part.mediaType?.startsWith("image/");
|
|
105
|
+
const isExcel = part.mediaType === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
106
|
+
if (isImg) {
|
|
64
107
|
const meta = part.providerOptions?.uploadMetadata;
|
|
65
|
-
|
|
66
|
-
return
|
|
67
|
-
type: getPartType(part),
|
|
68
|
-
text: part.type === "text" ? part.text : "",
|
|
69
|
-
file_id: meta?.file_id,
|
|
70
|
-
name: meta?.name,
|
|
71
|
-
// 附件地址:模型需要在「附件上传」标准动作中引用(IAttachment.attachmentUrl)
|
|
72
|
-
url
|
|
73
|
-
};
|
|
108
|
+
console.log("img meta", meta);
|
|
109
|
+
return meta?.parsedData;
|
|
74
110
|
}
|
|
75
|
-
|
|
76
|
-
|
|
111
|
+
if (isExcel) {
|
|
112
|
+
return excel2json(part.data);
|
|
113
|
+
}
|
|
114
|
+
if (isCsv || isTxt) {
|
|
115
|
+
return data2csvText(part.data);
|
|
116
|
+
}
|
|
117
|
+
return "";
|
|
118
|
+
}).join("");
|
|
119
|
+
return result;
|
|
77
120
|
};
|
|
78
|
-
var isTextOnlyMsg = (message) => message.content.every((part) => part.type === "text");
|
|
79
121
|
var convertPromptToMessages = (messages) => {
|
|
80
122
|
return messages.map((message) => {
|
|
81
|
-
const isTextOnly = isTextOnlyMsg(message);
|
|
82
123
|
switch (message.role) {
|
|
83
124
|
case "user":
|
|
84
125
|
return {
|
|
85
126
|
role: import_api.RoleType.User,
|
|
86
|
-
content: parseMessageContent(message,
|
|
87
|
-
content_type:
|
|
127
|
+
// content: parseMessageContent(message, multiModal) || "",
|
|
128
|
+
// content_type: multiModal ? "object_string" : "text",
|
|
129
|
+
content: parseMessageContent(message) || "",
|
|
130
|
+
content_type: "text"
|
|
88
131
|
};
|
|
89
132
|
break;
|
|
90
133
|
case "assistant":
|
|
@@ -98,89 +141,6 @@ var convertPromptToMessages = (messages) => {
|
|
|
98
141
|
});
|
|
99
142
|
};
|
|
100
143
|
|
|
101
|
-
// src/utils/accumulate-sse-response.ts
|
|
102
|
-
var import_parse_sse = require("parse-sse");
|
|
103
|
-
var import_web = require("stream/web");
|
|
104
|
-
async function accumulateSSEResponse(body) {
|
|
105
|
-
const sseStream = body.pipeThrough(
|
|
106
|
-
new import_web.TextDecoderStream()
|
|
107
|
-
).pipeThrough(new import_parse_sse.ServerSentEventTransformStream());
|
|
108
|
-
let textContent = "";
|
|
109
|
-
let reasoningContent = "";
|
|
110
|
-
let finishReason = "stop";
|
|
111
|
-
let usage = { inputTokens: 0, outputTokens: 0, totalTokens: 0 };
|
|
112
|
-
const reader = sseStream.getReader();
|
|
113
|
-
try {
|
|
114
|
-
while (true) {
|
|
115
|
-
const { done, value: evt } = await reader.read();
|
|
116
|
-
if (done) break;
|
|
117
|
-
if (!evt) continue;
|
|
118
|
-
let evtData;
|
|
119
|
-
try {
|
|
120
|
-
evtData = JSON.parse(evt.data);
|
|
121
|
-
} catch {
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
const event = evt.type;
|
|
125
|
-
if (event === "conversation.message.delta") {
|
|
126
|
-
if (evtData.reasoning_content) {
|
|
127
|
-
reasoningContent += evtData.reasoning_content;
|
|
128
|
-
} else if (evtData.content) {
|
|
129
|
-
textContent += evtData.content;
|
|
130
|
-
}
|
|
131
|
-
} else if (event === "conversation.chat.completed" || event === "done") {
|
|
132
|
-
finishReason = "stop";
|
|
133
|
-
if (evtData.usage) {
|
|
134
|
-
usage = {
|
|
135
|
-
inputTokens: evtData.usage.input_count || 0,
|
|
136
|
-
outputTokens: evtData.usage.output_count || 0,
|
|
137
|
-
totalTokens: evtData.usage.total_count || 0
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
} else if (event === "error") {
|
|
141
|
-
finishReason = "error";
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
} finally {
|
|
145
|
-
reader.releaseLock();
|
|
146
|
-
}
|
|
147
|
-
const content = [];
|
|
148
|
-
if (reasoningContent) {
|
|
149
|
-
content.push({ type: "reasoning", text: reasoningContent });
|
|
150
|
-
}
|
|
151
|
-
if (textContent) {
|
|
152
|
-
content.push({ type: "text", text: textContent });
|
|
153
|
-
}
|
|
154
|
-
return { content, finishReason, usage };
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// src/utils/create-error-stream.ts
|
|
158
|
-
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
159
|
-
var createErrorStream = (error) => {
|
|
160
|
-
return new ReadableStream({
|
|
161
|
-
start(controller) {
|
|
162
|
-
const id = (0, import_provider_utils.generateId)();
|
|
163
|
-
controller.enqueue({
|
|
164
|
-
id,
|
|
165
|
-
type: "text-start"
|
|
166
|
-
});
|
|
167
|
-
controller.enqueue({
|
|
168
|
-
id,
|
|
169
|
-
type: "text-delta",
|
|
170
|
-
providerMetadata: {
|
|
171
|
-
raw: { data: { type: "agent-error", error } }
|
|
172
|
-
},
|
|
173
|
-
delta: error
|
|
174
|
-
});
|
|
175
|
-
controller.enqueue({
|
|
176
|
-
type: "text-end",
|
|
177
|
-
id
|
|
178
|
-
});
|
|
179
|
-
controller.close();
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
};
|
|
183
|
-
|
|
184
144
|
// src/evt-sample.ts
|
|
185
145
|
var EvtSample = class {
|
|
186
146
|
_evtSampleMap = /* @__PURE__ */ new Map();
|
|
@@ -252,6 +212,7 @@ var MCPChunkFilterTransformStream = class extends TransformStream {
|
|
|
252
212
|
super({
|
|
253
213
|
transform: (evt, controller) => {
|
|
254
214
|
if (!evt) return;
|
|
215
|
+
console.log("origin event", evt);
|
|
255
216
|
const part = {
|
|
256
217
|
event: evt.type,
|
|
257
218
|
data: JSON.parse(evt.data) || {}
|
|
@@ -303,17 +264,11 @@ var mcp2llmChunk = (part) => {
|
|
|
303
264
|
rawValue: part.data
|
|
304
265
|
};
|
|
305
266
|
}
|
|
306
|
-
if (part.status === "completed") {
|
|
307
|
-
return {
|
|
308
|
-
type: "text-end",
|
|
309
|
-
id: part.data.conversation_id,
|
|
310
|
-
// delta: part.data.content || part.data.reasoning_content || "",
|
|
311
|
-
providerMetadata: {}
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
267
|
return {
|
|
315
|
-
type: "
|
|
316
|
-
|
|
268
|
+
type: "text-end",
|
|
269
|
+
id: part.data.conversation_id,
|
|
270
|
+
// delta: part.data.content || part.data.reasoning_content || "",
|
|
271
|
+
providerMetadata: {}
|
|
317
272
|
};
|
|
318
273
|
break;
|
|
319
274
|
case import_api3.ChatEventType.CONVERSATION_CHAT_COMPLETED:
|
|
@@ -342,7 +297,7 @@ var mcp2llmChunk = (part) => {
|
|
|
342
297
|
console.error("[ERROR]", part.data);
|
|
343
298
|
return {
|
|
344
299
|
type: "error",
|
|
345
|
-
error: part.data
|
|
300
|
+
error: new Error(`Coze streaming error: ${JSON.stringify(part.data)}`)
|
|
346
301
|
};
|
|
347
302
|
default:
|
|
348
303
|
console.warn("Unknown event type:", part.event);
|
|
@@ -380,33 +335,7 @@ var LLMPartTrasnformStream = class extends TransformStream {
|
|
|
380
335
|
}
|
|
381
336
|
};
|
|
382
337
|
|
|
383
|
-
// src/utils/build-generate-result-by-chat-res.ts
|
|
384
|
-
var BuildWarningGenerateResult = (message) => {
|
|
385
|
-
return {
|
|
386
|
-
content: [],
|
|
387
|
-
finishReason: "error",
|
|
388
|
-
request: {
|
|
389
|
-
body: null
|
|
390
|
-
},
|
|
391
|
-
usage: {
|
|
392
|
-
inputTokens: 0,
|
|
393
|
-
outputTokens: 0,
|
|
394
|
-
totalTokens: 0
|
|
395
|
-
},
|
|
396
|
-
response: {
|
|
397
|
-
body: null
|
|
398
|
-
},
|
|
399
|
-
warnings: [
|
|
400
|
-
{
|
|
401
|
-
type: "other",
|
|
402
|
-
message
|
|
403
|
-
}
|
|
404
|
-
]
|
|
405
|
-
};
|
|
406
|
-
};
|
|
407
|
-
|
|
408
338
|
// src/coze-language-model.ts
|
|
409
|
-
var import_ai_feat_utils = require("@baishuyun/ai-feat-utils");
|
|
410
339
|
var CozeLanguageModel = class {
|
|
411
340
|
specificationVersion = "v2";
|
|
412
341
|
provider;
|
|
@@ -419,59 +348,8 @@ var CozeLanguageModel = class {
|
|
|
419
348
|
this.supportedUrls = config.supportedUrls?.() || {};
|
|
420
349
|
this.config = config;
|
|
421
350
|
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
const warnings = [];
|
|
425
|
-
const url = this.config.url({ path: "/chat" });
|
|
426
|
-
const user_id = options.headers ? options.headers["x-user-id"] : "";
|
|
427
|
-
const user_var = options.headers ? options.headers["x-user-var"] : "";
|
|
428
|
-
let customVar;
|
|
429
|
-
if (user_var) {
|
|
430
|
-
try {
|
|
431
|
-
customVar = JSON.parse(user_var);
|
|
432
|
-
} catch (e) {
|
|
433
|
-
console.warn("x-user-var parse error", e);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
const body = {
|
|
437
|
-
bot_id: this.config.botId,
|
|
438
|
-
auto_save_history: false,
|
|
439
|
-
user_id: user_id || "7543191937730215936",
|
|
440
|
-
stream: true,
|
|
441
|
-
additional_messages: messages
|
|
442
|
-
};
|
|
443
|
-
if (customVar) {
|
|
444
|
-
body.custom_variables = customVar;
|
|
445
|
-
}
|
|
446
|
-
const headers = this.config.headers();
|
|
447
|
-
const abortSignal = options.abortSignal;
|
|
448
|
-
const response = await fetch(url, {
|
|
449
|
-
method: "POST",
|
|
450
|
-
headers,
|
|
451
|
-
credentials: "include",
|
|
452
|
-
body: JSON.stringify(body),
|
|
453
|
-
signal: abortSignal
|
|
454
|
-
});
|
|
455
|
-
if (!response.ok || !response.body) {
|
|
456
|
-
const rawError = await response.text();
|
|
457
|
-
let errorDetail;
|
|
458
|
-
try {
|
|
459
|
-
errorDetail = JSON.parse(rawError);
|
|
460
|
-
} catch {
|
|
461
|
-
errorDetail = rawError;
|
|
462
|
-
}
|
|
463
|
-
const errorMessage = typeof errorDetail === "object" && errorDetail?.msg ? errorDetail.msg : `Coze API error: ${response.status} ${response.statusText}`;
|
|
464
|
-
return BuildWarningGenerateResult(errorMessage);
|
|
465
|
-
}
|
|
466
|
-
const { content, finishReason, usage } = await accumulateSSEResponse(response.body);
|
|
467
|
-
return {
|
|
468
|
-
content,
|
|
469
|
-
finishReason,
|
|
470
|
-
usage,
|
|
471
|
-
request: { body },
|
|
472
|
-
response: { body: null },
|
|
473
|
-
warnings
|
|
474
|
-
};
|
|
351
|
+
doGenerate(options) {
|
|
352
|
+
throw new Error("Method not implemented.");
|
|
475
353
|
}
|
|
476
354
|
isVisibleMsgPart(evtData) {
|
|
477
355
|
if (evtData.type === "knowledge" && evtData.role === "assistant") {
|
|
@@ -480,41 +358,26 @@ var CozeLanguageModel = class {
|
|
|
480
358
|
return true;
|
|
481
359
|
}
|
|
482
360
|
async doStream(options) {
|
|
483
|
-
const
|
|
484
|
-
const
|
|
485
|
-
const messages = convertPromptToMessages(prompt);
|
|
486
|
-
const queryStr = conversation_id ? `?conversation_id=${conversation_id}` : "";
|
|
361
|
+
const messages = convertPromptToMessages(options.prompt);
|
|
362
|
+
const warnings = [];
|
|
487
363
|
const url = this.config.url({
|
|
488
|
-
path:
|
|
364
|
+
path: "/chat"
|
|
489
365
|
});
|
|
490
366
|
const user_id = options.headers ? options.headers["x-user-id"] : "";
|
|
491
|
-
const user_var = options.headers ? options.headers["x-user-var"] : "";
|
|
492
|
-
const user_param = (options.headers ? options.headers["x-user-param"] : "") ?? "";
|
|
493
|
-
const params = user_param ? (0, import_ai_feat_utils.safeParseJson)(user_param) : {};
|
|
494
|
-
console.log("params 2 workflow", params);
|
|
495
|
-
console.log("conversation id 2 workflow", conversation_id);
|
|
496
367
|
const body = {
|
|
497
368
|
bot_id: this.config.botId,
|
|
498
|
-
auto_save_history:
|
|
499
|
-
user_id: user_id || "
|
|
369
|
+
auto_save_history: false,
|
|
370
|
+
user_id: user_id || "123456",
|
|
500
371
|
stream: true,
|
|
501
|
-
additional_messages: messages
|
|
502
|
-
parameters: params,
|
|
503
|
-
custom_variables: user_var ? (0, import_ai_feat_utils.safeParseJson)(user_var) : {},
|
|
504
|
-
extra_params: {
|
|
505
|
-
"remark": (0, import_ai_feat_utils.getChatCtxForHuman)(options?.providerOptions?.chatCtx)
|
|
506
|
-
}
|
|
372
|
+
additional_messages: messages
|
|
507
373
|
};
|
|
374
|
+
console.log("messages", messages);
|
|
508
375
|
const headers = this.config.headers();
|
|
509
|
-
const abortSignal = options.abortSignal;
|
|
510
|
-
console.log("url", url);
|
|
511
|
-
console.log("body", JSON.stringify(body, null, 2));
|
|
512
376
|
const response = await fetch(url, {
|
|
513
377
|
method: "POST",
|
|
514
378
|
headers,
|
|
515
379
|
credentials: "include",
|
|
516
|
-
body: JSON.stringify(body)
|
|
517
|
-
signal: abortSignal
|
|
380
|
+
body: JSON.stringify(body)
|
|
518
381
|
});
|
|
519
382
|
if (!response.ok || !response.body) {
|
|
520
383
|
const rawError = await response.text();
|
|
@@ -524,21 +387,19 @@ var CozeLanguageModel = class {
|
|
|
524
387
|
} catch {
|
|
525
388
|
errorDetail = rawError;
|
|
526
389
|
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
stream: createErrorStream("\u4F1A\u8BDD\u5F02\u5E38\uFF0C\u8BF7\u91CD\u8BD5")
|
|
531
|
-
};
|
|
390
|
+
throw new Error(
|
|
391
|
+
`Coze API error: ${response.status} ${response.statusText}`
|
|
392
|
+
);
|
|
532
393
|
}
|
|
533
|
-
let externalTransformers =
|
|
534
|
-
(factory) => factory()
|
|
535
|
-
);
|
|
394
|
+
let externalTransformers = this.config.extraStreamTransformers || [];
|
|
536
395
|
const stage = options.headers ? options.headers["x-user-stage"] : "";
|
|
537
396
|
const isBuildStage = stage === "build";
|
|
538
397
|
const isFillStage = stage === "fill";
|
|
539
398
|
const result = response.body.pipeThrough(
|
|
540
|
-
new
|
|
541
|
-
).pipeThrough(new
|
|
399
|
+
new import_web.TextDecoderStream()
|
|
400
|
+
).pipeThrough(new import_parse_sse.ServerSentEventTransformStream()).pipeThrough(
|
|
401
|
+
new MCPChunkFilterTransformStream(isBuildStage || isFillStage)
|
|
402
|
+
).pipeThrough(new LLMChunkInjectorTransformStream()).pipeThrough(new LLMPartTrasnformStream());
|
|
542
403
|
let finalResult = result;
|
|
543
404
|
if (externalTransformers.length > 0) {
|
|
544
405
|
finalResult = externalTransformers.reduce(
|
|
@@ -552,22 +413,17 @@ var CozeLanguageModel = class {
|
|
|
552
413
|
};
|
|
553
414
|
}
|
|
554
415
|
};
|
|
555
|
-
function keepOnlyLastUserMessage(prompt) {
|
|
556
|
-
for (let i = prompt.length - 1; i >= 0; i--) {
|
|
557
|
-
if (prompt[i].role === "user") {
|
|
558
|
-
return [prompt[i]];
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
return prompt;
|
|
562
|
-
}
|
|
563
416
|
|
|
564
417
|
// src/coze-provider.ts
|
|
565
418
|
function createCoze(options = {
|
|
566
419
|
botId: ""
|
|
567
420
|
}) {
|
|
568
|
-
const baseURL = (0,
|
|
569
|
-
const agentPartHeader = (0,
|
|
570
|
-
|
|
421
|
+
const baseURL = (0, import_provider_utils.withoutTrailingSlash)(options.baseURL);
|
|
422
|
+
const agentPartHeader = (0, import_provider_utils.withUserAgentSuffix)(
|
|
423
|
+
options.headers || {},
|
|
424
|
+
`ai-sdk/coze/${VERSION}`
|
|
425
|
+
);
|
|
426
|
+
const authorizationHeader = `Bearer ${(0, import_provider_utils.loadApiKey)({
|
|
571
427
|
apiKey: options.apiKey,
|
|
572
428
|
environmentVariableName: "COZE_API_KEY",
|
|
573
429
|
description: ""
|
|
@@ -607,44 +463,1203 @@ function createCoze(options = {
|
|
|
607
463
|
var import_json = require("@streamparser/json");
|
|
608
464
|
|
|
609
465
|
// src/utils/enqueue-text-info.ts
|
|
610
|
-
var
|
|
611
|
-
var createTextInfoEnqueuer = (controller) => (textInfo, metaPayload, id = (0,
|
|
612
|
-
|
|
613
|
-
const startPart = {
|
|
466
|
+
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
467
|
+
var createTextInfoEnqueuer = (controller) => (textInfo, metaPayload, id = (0, import_provider_utils2.generateId)()) => {
|
|
468
|
+
controller.enqueue({
|
|
614
469
|
type: "text-start",
|
|
615
|
-
id
|
|
616
|
-
};
|
|
617
|
-
const
|
|
470
|
+
id
|
|
471
|
+
});
|
|
472
|
+
const chunk = {
|
|
618
473
|
type: "text-delta",
|
|
619
|
-
id
|
|
474
|
+
id,
|
|
620
475
|
delta: textInfo,
|
|
621
476
|
providerMetadata: metaPayload ? {
|
|
622
477
|
raw: { data: metaPayload }
|
|
623
478
|
} : void 0
|
|
624
479
|
};
|
|
625
|
-
|
|
480
|
+
controller.enqueue(chunk);
|
|
481
|
+
controller.enqueue({
|
|
626
482
|
type: "text-end",
|
|
627
|
-
id
|
|
483
|
+
id
|
|
484
|
+
});
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
// src/utils/fields-json-rebuild/rebuild-text.ts
|
|
488
|
+
var REG_EX_MAP = {
|
|
489
|
+
\u624B\u673A\u53F7\u7801: "^((\\(\\d{2,3}\\))|(\\d{3}\\-))?1\\d{10}$",
|
|
490
|
+
\u7535\u8BDD\u53F7\u7801: "^(0[0-9]{2,3}\\-)?([2-9][0-9]{6,7})+(\\-[0-9]{1,4})?$",
|
|
491
|
+
\u90AE\u653F\u7F16\u7801: "^\\d{6}$",
|
|
492
|
+
\u8EAB\u4EFD\u8BC1\u53F7\u7801: "(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)",
|
|
493
|
+
\u90AE\u7BB1: "^([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,4})+$",
|
|
494
|
+
\u65F6\u5206: "(^[0-1]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$|^[2]{1}[0-3]{1}:[0-5]{1}[0-9]{1}$|^[0-9]{1}:[0-5]{1}[0-9]{1}$)",
|
|
495
|
+
\u65F6\u5206\u79D2: "(^[0-1]{1}[0-9]{1}:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$|^[2]{1}[0-3]{1}:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$|^[0-9]{1}:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$)",
|
|
496
|
+
\u56FE\u7247\u94FE\u63A5: "imageurl",
|
|
497
|
+
\u4E8C\u7EF4\u7801\u56FE\u7247: "qrcode",
|
|
498
|
+
\u6761\u5F62\u7801\u56FE\u7247: "barcode",
|
|
499
|
+
\u81EA\u5B9A\u4E49: "custom"
|
|
500
|
+
};
|
|
501
|
+
var rebuildText = (truncatedJson) => {
|
|
502
|
+
const { widget, labelStyle, label, ...rest } = truncatedJson || {};
|
|
503
|
+
const regex = REG_EX_MAP[labelStyle] || "";
|
|
504
|
+
return {
|
|
505
|
+
widget: {
|
|
506
|
+
widgetName: `_widget_${Date.now()}`,
|
|
507
|
+
widgetNameAlias: "",
|
|
508
|
+
// triggerEvent: 0,
|
|
509
|
+
customCls: null,
|
|
510
|
+
height: 34,
|
|
511
|
+
width: 350,
|
|
512
|
+
text: null,
|
|
513
|
+
value: "",
|
|
514
|
+
//默认值 没有默认值的话 整个value不存在
|
|
515
|
+
enable: true,
|
|
516
|
+
visible: true,
|
|
517
|
+
// hint: placeholder,
|
|
518
|
+
allowBlank: true,
|
|
519
|
+
rely: null,
|
|
520
|
+
libs: [],
|
|
521
|
+
extendSet: {
|
|
522
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
523
|
+
status: true,
|
|
524
|
+
triggerField: "",
|
|
525
|
+
triggerFieldMode: "none",
|
|
526
|
+
version: 1
|
|
527
|
+
},
|
|
528
|
+
// regex, //格式 ^((\(\d{2,3}\))|(\d{3}\-))?1\d{10}$ 手机号码 ^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$ 电话号码 ^\d{6}$ 邮政编码 (^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$) 身份证号码 ^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$ 邮箱 (^[0-1]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$|^[2]{1}[0-3]{1}:[0-5]{1}[0-9]{1}$|^[0-9]{1}:[0-5]{1}[0-9]{1}$) 时分 (^[0-1]{1}[0-9]{1}:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$|^[2]{1}[0-3]{1}:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$|^[0-9]{1}:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$) 时分秒 imageurl 图片链接 qrcode 二维码图片 barcode 条形码图片 custom 自定义
|
|
529
|
+
noRepeat: true,
|
|
530
|
+
scan: null,
|
|
531
|
+
// textMode,
|
|
532
|
+
generateQR: false,
|
|
533
|
+
eventAlert: true,
|
|
534
|
+
alertinfo: {
|
|
535
|
+
icon: "error"
|
|
536
|
+
// tip: placeholder,
|
|
537
|
+
// msg: placeholder,
|
|
538
|
+
},
|
|
539
|
+
enterClearText: true,
|
|
540
|
+
...widget,
|
|
541
|
+
regex,
|
|
542
|
+
type: "text",
|
|
543
|
+
labelStyle: label
|
|
544
|
+
},
|
|
545
|
+
// description,
|
|
546
|
+
label,
|
|
547
|
+
lineWidth: 6,
|
|
548
|
+
tab: null,
|
|
549
|
+
...rest
|
|
550
|
+
};
|
|
551
|
+
};
|
|
552
|
+
|
|
553
|
+
// src/utils/build-widget-name.ts
|
|
554
|
+
var buildWidgetName = (prefix = "_widget", index) => {
|
|
555
|
+
const baseName = `${prefix}_${Date.now()}`;
|
|
556
|
+
if (index === void 0) {
|
|
557
|
+
return baseName;
|
|
558
|
+
}
|
|
559
|
+
const idxLength = index.toString().length;
|
|
560
|
+
const slicedBaseName = baseName.slice(0, -idxLength);
|
|
561
|
+
return `${slicedBaseName}${index}`;
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
// src/utils/fields-json-rebuild/rebuild-number.ts
|
|
565
|
+
var rebuildNumber = (value) => {
|
|
566
|
+
const { widget, label, ...rest } = value || {};
|
|
567
|
+
return {
|
|
568
|
+
widget: {
|
|
569
|
+
type: "number",
|
|
570
|
+
widgetName: buildWidgetName(),
|
|
571
|
+
widgetNameAlias: "",
|
|
572
|
+
triggerEvent: false,
|
|
573
|
+
customCls: null,
|
|
574
|
+
height: 34,
|
|
575
|
+
width: 350,
|
|
576
|
+
enable: true,
|
|
577
|
+
visible: true,
|
|
578
|
+
allowBlank: true,
|
|
579
|
+
funMode: "module",
|
|
580
|
+
module: null,
|
|
581
|
+
libs: [],
|
|
582
|
+
extendSet: {
|
|
583
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
584
|
+
status: true,
|
|
585
|
+
triggerField: "",
|
|
586
|
+
triggerFieldMode: "none",
|
|
587
|
+
version: 1
|
|
588
|
+
},
|
|
589
|
+
// regex,
|
|
590
|
+
// hint: placeholder,
|
|
591
|
+
noRepeat: false,
|
|
592
|
+
alertinfo: {
|
|
593
|
+
icon: "success",
|
|
594
|
+
tip: "\u8BF7\u8BBE\u7F6E\u63D0\u793A\u5185\u5BB9"
|
|
595
|
+
},
|
|
596
|
+
allowDecimals: true,
|
|
597
|
+
//允许小数,默认值 true,已废弃
|
|
598
|
+
allowNegative: true,
|
|
599
|
+
//允许负数,默认值 true ,已废弃
|
|
600
|
+
// maxNumber: max, //限定数值范围 最大值
|
|
601
|
+
// minNumber: min, //限定数值范围 最小值
|
|
602
|
+
displayMode: "percent",
|
|
603
|
+
// 新的格式, percent 百分比 number 数值
|
|
604
|
+
precision: null,
|
|
605
|
+
//保留小数位数
|
|
606
|
+
thousandsSeparator: false,
|
|
607
|
+
//显示千分符
|
|
608
|
+
notround: true,
|
|
609
|
+
//不四舍五入
|
|
610
|
+
format: "",
|
|
611
|
+
//旧的格式,新的由多个属性来控制,前端代码会用其他几个参数拼接出正确的这个值。 其中结尾有% 代表百分比 ,没有%代表数字 ,然后小数点后面的0的个数代表 保留的小数位数,如果小数点后面没有0代表(如0.%),代表没有设置 保留小数位数,保留用户输入的所有小数
|
|
612
|
+
afterSuffix: {
|
|
613
|
+
//单位
|
|
614
|
+
zh_cn: "",
|
|
615
|
+
//中文的
|
|
616
|
+
en_us: "",
|
|
617
|
+
//英文的
|
|
618
|
+
zh_tw: ""
|
|
619
|
+
//繁体的
|
|
620
|
+
},
|
|
621
|
+
...widget,
|
|
622
|
+
labelStyle: label
|
|
623
|
+
},
|
|
624
|
+
// description,
|
|
625
|
+
label,
|
|
626
|
+
lineWidth: 6,
|
|
627
|
+
tab: null,
|
|
628
|
+
...rest
|
|
629
|
+
};
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
// src/utils/fields-json-rebuild/rebuild-select.ts
|
|
633
|
+
var rebuildSelect = (truncatedJson) => {
|
|
634
|
+
const { widget, label, ...rest } = truncatedJson || {};
|
|
635
|
+
return {
|
|
636
|
+
widget: {
|
|
637
|
+
type: "combo",
|
|
638
|
+
height: 34,
|
|
639
|
+
width: 350,
|
|
640
|
+
enable: true,
|
|
641
|
+
visible: true,
|
|
642
|
+
allowBlank: true,
|
|
643
|
+
mode: 1,
|
|
644
|
+
allowAddLinkData: false,
|
|
645
|
+
// items: options,
|
|
646
|
+
widgetName: `_widget_${Date.now()}`,
|
|
647
|
+
widgetNameAlias: "",
|
|
648
|
+
customCls: null,
|
|
649
|
+
funMode: "module",
|
|
650
|
+
module: null,
|
|
651
|
+
libs: [],
|
|
652
|
+
extendSet: {
|
|
653
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
654
|
+
status: true,
|
|
655
|
+
triggerField: "",
|
|
656
|
+
triggerFieldMode: "none",
|
|
657
|
+
version: 1
|
|
658
|
+
},
|
|
659
|
+
colorEnable: true,
|
|
660
|
+
//颜色 是否开启颜色
|
|
661
|
+
...widget,
|
|
662
|
+
labelStyle: label
|
|
663
|
+
},
|
|
664
|
+
// description,
|
|
665
|
+
label,
|
|
666
|
+
lineWidth: 6,
|
|
667
|
+
tab: null,
|
|
668
|
+
...rest
|
|
669
|
+
};
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
// src/utils/fields-json-rebuild/rebuild-radio-group.ts
|
|
673
|
+
var rebuildRadioGroup = (truncatedJson) => {
|
|
674
|
+
const { widget, label, ...rest } = truncatedJson || {};
|
|
675
|
+
return {
|
|
676
|
+
widget: {
|
|
677
|
+
enable: true,
|
|
678
|
+
visible: true,
|
|
679
|
+
allowBlank: true,
|
|
680
|
+
funMode: "module",
|
|
681
|
+
module: null,
|
|
682
|
+
libs: [],
|
|
683
|
+
// items: options,
|
|
684
|
+
layout: "vertical",
|
|
685
|
+
stopCancel: false,
|
|
686
|
+
widgetName: `_widget_${Date.now()}`,
|
|
687
|
+
widgetNameAlias: "",
|
|
688
|
+
customCls: null,
|
|
689
|
+
value: null,
|
|
690
|
+
extendSet: {
|
|
691
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
692
|
+
status: true,
|
|
693
|
+
triggerField: "",
|
|
694
|
+
triggerFieldMode: "none",
|
|
695
|
+
version: 1
|
|
696
|
+
},
|
|
697
|
+
colorEnable: true,
|
|
698
|
+
//颜色 是否开启颜色
|
|
699
|
+
...widget,
|
|
700
|
+
type: "radiogroup"
|
|
701
|
+
},
|
|
702
|
+
// description,
|
|
703
|
+
label,
|
|
704
|
+
lineWidth: 6,
|
|
705
|
+
tab: null,
|
|
706
|
+
...rest,
|
|
707
|
+
labelStyle: label
|
|
708
|
+
};
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
// src/utils/fields-json-rebuild/rebuild-date-time.ts
|
|
712
|
+
var rebuildDatetime = (truncatedJson) => {
|
|
713
|
+
const { widget, label, ...rest } = truncatedJson || {};
|
|
714
|
+
return {
|
|
715
|
+
widget: {
|
|
716
|
+
type: "datetime",
|
|
717
|
+
height: 34,
|
|
718
|
+
width: 350,
|
|
719
|
+
enable: true,
|
|
720
|
+
visible: true,
|
|
721
|
+
allowBlank: true,
|
|
722
|
+
funMode: "module",
|
|
723
|
+
widgetName: `_widget_${Date.now()}`,
|
|
724
|
+
widgetNameAlias: "",
|
|
725
|
+
customCls: null,
|
|
726
|
+
value: "today",
|
|
727
|
+
//默认值, today 填写当前时间 ,如果是数字,如 1762957800000 ,是自定义的时间,为所选时间的时间戳的毫秒级,
|
|
728
|
+
rely: null,
|
|
729
|
+
module: null,
|
|
730
|
+
libs: [],
|
|
731
|
+
extendSet: {
|
|
732
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
733
|
+
status: true,
|
|
734
|
+
triggerField: "",
|
|
735
|
+
triggerFieldMode: "none",
|
|
736
|
+
version: 1
|
|
737
|
+
},
|
|
738
|
+
hint: "",
|
|
739
|
+
dateLimit: {
|
|
740
|
+
//日期范围
|
|
741
|
+
week: {
|
|
742
|
+
//可选择星期
|
|
743
|
+
enable: false,
|
|
744
|
+
//是否开启可选择星期
|
|
745
|
+
value: [
|
|
746
|
+
//星期 星期一到天,用1-7代表
|
|
747
|
+
1,
|
|
748
|
+
2,
|
|
749
|
+
6
|
|
750
|
+
]
|
|
751
|
+
},
|
|
752
|
+
start: {
|
|
753
|
+
//最早可选时间
|
|
754
|
+
enable: false,
|
|
755
|
+
//是否开启最早可选时间
|
|
756
|
+
mode: "dynamic",
|
|
757
|
+
//模式: dynamic 动态 static 固定值 fieldValue 字段值
|
|
758
|
+
value: "yesterday"
|
|
759
|
+
//限定的值: today 今天 yesterday 昨天 tomorrow 明天 7day_before 七天前 7day_after 七天后 30day_before 30天前 30day_after 30天后
|
|
760
|
+
},
|
|
761
|
+
end: {
|
|
762
|
+
//最晚可选时间
|
|
763
|
+
enable: false,
|
|
764
|
+
//是否开启最晚可选时间
|
|
765
|
+
mode: "static",
|
|
766
|
+
//模式: dynamic 动态 static 固定值 fieldValue 字段值
|
|
767
|
+
value: 17620938e5
|
|
768
|
+
//限定的值:这种数字的为 选择的固定值,时间的时间戳,毫秒级别 ,如果为 _widget_1762154537014 这种,为字段的值,这个字段需要也是日期字段,和当前这个字段是同一个 format的
|
|
769
|
+
}
|
|
770
|
+
},
|
|
771
|
+
...widget,
|
|
772
|
+
labelStyle: label
|
|
773
|
+
},
|
|
774
|
+
label,
|
|
775
|
+
lineWidth: 6,
|
|
776
|
+
tab: null,
|
|
777
|
+
...rest
|
|
628
778
|
};
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
779
|
+
};
|
|
780
|
+
|
|
781
|
+
// src/utils/fields-json-rebuild/default-builder.ts
|
|
782
|
+
var defaultBuilder = (truncatedJson) => {
|
|
783
|
+
return truncatedJson;
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
// src/utils/fields-json-rebuild/rebuild-dept-group.ts
|
|
787
|
+
var rebuildDeptGroup = (truncatedJson) => {
|
|
788
|
+
const { widget, label, ...rest } = truncatedJson || {};
|
|
789
|
+
return {
|
|
790
|
+
widget: {
|
|
791
|
+
type: "deptgroup",
|
|
792
|
+
widgetName: buildWidgetName(),
|
|
793
|
+
widgetNameAlias: "",
|
|
794
|
+
customCls: null,
|
|
795
|
+
height: "34",
|
|
796
|
+
width: 350,
|
|
797
|
+
enable: true,
|
|
798
|
+
visible: true,
|
|
799
|
+
allowBlank: true,
|
|
800
|
+
funMode: "module",
|
|
801
|
+
module: null,
|
|
802
|
+
libs: [],
|
|
803
|
+
extendSet: {
|
|
804
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
805
|
+
status: true,
|
|
806
|
+
triggerField: "",
|
|
807
|
+
triggerFieldMode: "none",
|
|
808
|
+
version: 1
|
|
809
|
+
},
|
|
810
|
+
noRepeat: false,
|
|
811
|
+
limit: {},
|
|
812
|
+
valueOption: 0,
|
|
813
|
+
...widget,
|
|
814
|
+
labelStyle: label
|
|
815
|
+
},
|
|
816
|
+
label,
|
|
817
|
+
lineWidth: 6,
|
|
818
|
+
tab: null,
|
|
819
|
+
...rest
|
|
820
|
+
};
|
|
821
|
+
};
|
|
822
|
+
|
|
823
|
+
// src/utils/fields-json-rebuild/rebuild-sn.ts
|
|
824
|
+
var rebuildSn = (truncatedJson) => {
|
|
825
|
+
const { widget, label, ...rest } = truncatedJson || {};
|
|
826
|
+
return {
|
|
827
|
+
widget: {
|
|
828
|
+
type: "sn",
|
|
829
|
+
widgetName: buildWidgetName(),
|
|
830
|
+
widgetNameAlias: "",
|
|
831
|
+
triggerEvent: 0,
|
|
832
|
+
customCls: null,
|
|
833
|
+
width: 350,
|
|
834
|
+
enable: true,
|
|
835
|
+
visible: true,
|
|
836
|
+
// rules: rules,
|
|
837
|
+
importMode: 1,
|
|
838
|
+
//导入模式 1 excel末尾递增 2 excel最大值递增 3 excel/表单最大值比较递增
|
|
839
|
+
...widget,
|
|
840
|
+
labelStyle: label
|
|
841
|
+
},
|
|
842
|
+
// description,
|
|
843
|
+
label,
|
|
844
|
+
lineWidth: 6,
|
|
845
|
+
tab: null,
|
|
846
|
+
...rest
|
|
847
|
+
};
|
|
848
|
+
};
|
|
849
|
+
|
|
850
|
+
// src/utils/fields-json-rebuild/rebuild-dept.ts
|
|
851
|
+
var rebuildDept = (truncatedJson) => {
|
|
852
|
+
const { widget, label, ...rest } = truncatedJson || {};
|
|
853
|
+
return {
|
|
854
|
+
widget: {
|
|
855
|
+
type: "dept",
|
|
856
|
+
widgetName: buildWidgetName(),
|
|
857
|
+
widgetNameAlias: "",
|
|
858
|
+
customCls: null,
|
|
859
|
+
height: "34",
|
|
860
|
+
width: 350,
|
|
861
|
+
enable: true,
|
|
862
|
+
visible: true,
|
|
863
|
+
allowBlank: true,
|
|
864
|
+
funMode: "module",
|
|
865
|
+
module: null,
|
|
866
|
+
libs: [],
|
|
867
|
+
extendSet: {
|
|
868
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
869
|
+
status: true,
|
|
870
|
+
triggerField: "",
|
|
871
|
+
triggerFieldMode: "none",
|
|
872
|
+
version: 1
|
|
873
|
+
},
|
|
874
|
+
noRepeat: false,
|
|
875
|
+
limit: {},
|
|
876
|
+
valueOption: 0,
|
|
877
|
+
...widget,
|
|
878
|
+
labelStyle: label
|
|
879
|
+
},
|
|
880
|
+
label,
|
|
881
|
+
lineWidth: 6,
|
|
882
|
+
tab: null,
|
|
883
|
+
...rest
|
|
884
|
+
};
|
|
885
|
+
};
|
|
886
|
+
|
|
887
|
+
// src/utils/fields-json-rebuild/rebuild-user-group.ts
|
|
888
|
+
var rebuildUserGroup = (truncatedJson) => {
|
|
889
|
+
const { widget, label, ...rest } = truncatedJson || {};
|
|
890
|
+
return {
|
|
891
|
+
widget: {
|
|
892
|
+
type: "usergroup",
|
|
893
|
+
widgetName: buildWidgetName(),
|
|
894
|
+
widgetNameAlias: "",
|
|
895
|
+
customCls: null,
|
|
896
|
+
height: "34",
|
|
897
|
+
width: 350,
|
|
898
|
+
enable: true,
|
|
899
|
+
visible: true,
|
|
900
|
+
allowBlank: true,
|
|
901
|
+
funMode: "module",
|
|
902
|
+
module: null,
|
|
903
|
+
libs: [],
|
|
904
|
+
extendSet: {
|
|
905
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
906
|
+
status: true,
|
|
907
|
+
triggerField: "",
|
|
908
|
+
triggerFieldMode: "none",
|
|
909
|
+
version: 1
|
|
910
|
+
},
|
|
911
|
+
noRepeat: false,
|
|
912
|
+
limit: {},
|
|
913
|
+
limitWidget: null,
|
|
914
|
+
//可选范围 由部门字段确定,如果有值 是 _widget_1762226067008 这种,另一个部门字段的id。和limit互斥,limit将为[]
|
|
915
|
+
valueOption: 0,
|
|
916
|
+
...widget,
|
|
917
|
+
labelStyle: label
|
|
918
|
+
},
|
|
919
|
+
// description,
|
|
920
|
+
label,
|
|
921
|
+
lineWidth: 6,
|
|
922
|
+
tab: null,
|
|
923
|
+
...rest
|
|
924
|
+
};
|
|
925
|
+
};
|
|
926
|
+
|
|
927
|
+
// src/utils/fields-json-rebuild/rebuild-data-linker.ts
|
|
928
|
+
var rebuildDataLinker = (truncatedJson) => {
|
|
929
|
+
const { widget, label, ...rest } = truncatedJson || {};
|
|
930
|
+
return {
|
|
931
|
+
widget: {
|
|
932
|
+
widgetName: buildWidgetName(),
|
|
933
|
+
widgetNameAlias: "",
|
|
934
|
+
customCls: null,
|
|
935
|
+
enable: true,
|
|
936
|
+
visible: true,
|
|
937
|
+
allowBlank: true,
|
|
938
|
+
rely: {
|
|
939
|
+
widgets: []
|
|
940
|
+
},
|
|
941
|
+
linkFilter: {},
|
|
942
|
+
allowAdd: true,
|
|
943
|
+
//允许新增关联表数据
|
|
944
|
+
refType: "form",
|
|
945
|
+
//关联表的类型,只能是form
|
|
946
|
+
...widget,
|
|
947
|
+
linkFields: [],
|
|
948
|
+
labelStyle: label,
|
|
949
|
+
type: "linkdata"
|
|
950
|
+
},
|
|
951
|
+
label,
|
|
952
|
+
lineWidth: 6,
|
|
953
|
+
tab: null,
|
|
954
|
+
...rest
|
|
955
|
+
};
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
// src/utils/fields-json-rebuild/rebuild-data-loader.ts
|
|
959
|
+
var tmpMapFields2Fields = (mapFieldsFromTruncatedJson) => {
|
|
960
|
+
if (!mapFieldsFromTruncatedJson || !mapFieldsFromTruncatedJson.length) {
|
|
961
|
+
return mapFieldsFromTruncatedJson;
|
|
962
|
+
}
|
|
963
|
+
return mapFieldsFromTruncatedJson.map((mf, index) => {
|
|
964
|
+
return {
|
|
965
|
+
id: index,
|
|
966
|
+
// name: "_widget_1761976674767",
|
|
967
|
+
// form: "a2f34ef882158a3e97da4ef7",
|
|
968
|
+
// tag: buildWidgetName("f_", index),
|
|
969
|
+
title: mf.field,
|
|
970
|
+
text: mf.field,
|
|
971
|
+
icon: `icon-widget-${mf.type}`,
|
|
972
|
+
type: mf.type,
|
|
973
|
+
isEditable: true,
|
|
974
|
+
group: "dimension,filter,select",
|
|
975
|
+
formula: ""
|
|
976
|
+
};
|
|
977
|
+
});
|
|
978
|
+
};
|
|
979
|
+
var tmpMapFields2MapFields = (mapFieldsFromTruncatedJson) => {
|
|
980
|
+
if (!mapFieldsFromTruncatedJson || !mapFieldsFromTruncatedJson.length) {
|
|
981
|
+
return mapFieldsFromTruncatedJson;
|
|
632
982
|
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
983
|
+
return mapFieldsFromTruncatedJson.map((mf) => {
|
|
984
|
+
return {
|
|
985
|
+
mode: "depend",
|
|
986
|
+
...mf
|
|
987
|
+
};
|
|
988
|
+
});
|
|
989
|
+
};
|
|
990
|
+
var rebuildDataLoader = (truncatedJson) => {
|
|
991
|
+
const { widget, label, ...rest } = truncatedJson || {};
|
|
992
|
+
return {
|
|
993
|
+
widget: {
|
|
994
|
+
type: "dataload",
|
|
995
|
+
widgetName: buildWidgetName(),
|
|
996
|
+
widgetNameAlias: "",
|
|
997
|
+
customCls: null,
|
|
998
|
+
width: 350,
|
|
999
|
+
text: label,
|
|
1000
|
+
enable: true,
|
|
1001
|
+
visible: true,
|
|
1002
|
+
allowBlank: true,
|
|
1003
|
+
allowAddData: true,
|
|
1004
|
+
// 允许新增数据源数据
|
|
1005
|
+
...widget,
|
|
1006
|
+
mode: "list",
|
|
1007
|
+
//一直是 list 应该是废弃的
|
|
1008
|
+
loaddataconfig: {
|
|
1009
|
+
extendSet: {
|
|
1010
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
1011
|
+
status: true,
|
|
1012
|
+
triggerField: "",
|
|
1013
|
+
triggerFieldMode: "none"
|
|
1014
|
+
},
|
|
1015
|
+
dataloadmode: ["add", "cover"],
|
|
1016
|
+
filter: {
|
|
1017
|
+
cond: [],
|
|
1018
|
+
rel: "and"
|
|
1019
|
+
},
|
|
1020
|
+
defaultSort: [],
|
|
1021
|
+
treeFields: {},
|
|
1022
|
+
mode: "list",
|
|
1023
|
+
selectFields: [],
|
|
1024
|
+
triggerControl: null,
|
|
1025
|
+
triggerWidget: null,
|
|
1026
|
+
triggerFieldMode: "none",
|
|
1027
|
+
triggerField: null,
|
|
1028
|
+
forms: widget?.loaddataconfig?.forms,
|
|
1029
|
+
selectArg: [],
|
|
1030
|
+
selectRel: "and",
|
|
1031
|
+
fields: tmpMapFields2Fields(widget?.loaddataconfig?.mapFields),
|
|
1032
|
+
mapFields: tmpMapFields2MapFields(widget?.loaddataconfig?.mapFields)
|
|
1033
|
+
},
|
|
1034
|
+
labelStyle: label
|
|
1035
|
+
},
|
|
1036
|
+
label,
|
|
1037
|
+
lineWidth: 6,
|
|
1038
|
+
tab: null,
|
|
1039
|
+
...rest
|
|
1040
|
+
};
|
|
1041
|
+
};
|
|
1042
|
+
|
|
1043
|
+
// src/utils/fields-json-rebuild/rebuild-user.ts
|
|
1044
|
+
var rebuildUser = (truncatedJson) => {
|
|
1045
|
+
const { widget, label, ...rest } = truncatedJson || {};
|
|
1046
|
+
return {
|
|
1047
|
+
widget: {
|
|
1048
|
+
type: "user",
|
|
1049
|
+
widgetName: buildWidgetName(),
|
|
1050
|
+
widgetNameAlias: "",
|
|
1051
|
+
customCls: null,
|
|
1052
|
+
height: "34",
|
|
1053
|
+
width: 350,
|
|
1054
|
+
enable: true,
|
|
1055
|
+
visible: true,
|
|
1056
|
+
allowBlank: true,
|
|
1057
|
+
funMode: "module",
|
|
1058
|
+
module: null,
|
|
1059
|
+
libs: [],
|
|
1060
|
+
extendSet: {
|
|
1061
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
1062
|
+
status: true,
|
|
1063
|
+
triggerField: "",
|
|
1064
|
+
triggerFieldMode: "none",
|
|
1065
|
+
version: 1
|
|
1066
|
+
},
|
|
1067
|
+
noRepeat: false,
|
|
1068
|
+
limit: {},
|
|
1069
|
+
limitWidget: null,
|
|
1070
|
+
//可选范围 由部门字段确定,如果有值 是 _widget_1762226067008 这种,另一个部门字段的id。和limit互斥,limit将为[]
|
|
1071
|
+
valueOption: 0,
|
|
1072
|
+
...widget,
|
|
1073
|
+
labelStyle: label
|
|
1074
|
+
},
|
|
1075
|
+
// description,
|
|
1076
|
+
label,
|
|
1077
|
+
lineWidth: 6,
|
|
1078
|
+
tab: null,
|
|
1079
|
+
...rest
|
|
1080
|
+
};
|
|
1081
|
+
};
|
|
1082
|
+
|
|
1083
|
+
// src/utils/fields-json-rebuild/rebuild-signature.ts
|
|
1084
|
+
var rebuildSignature = (truncatedJson) => {
|
|
1085
|
+
const { widget, label, ...rest } = truncatedJson || {};
|
|
1086
|
+
return {
|
|
1087
|
+
widget: {
|
|
1088
|
+
type: "signature",
|
|
1089
|
+
widgetName: buildWidgetName(),
|
|
1090
|
+
widgetNameAlias: "",
|
|
1091
|
+
customCls: null,
|
|
1092
|
+
height: 34,
|
|
1093
|
+
width: 350,
|
|
1094
|
+
enable: true,
|
|
1095
|
+
visible: true,
|
|
1096
|
+
allowBlank: true,
|
|
1097
|
+
rely: null,
|
|
1098
|
+
...widget,
|
|
1099
|
+
labelStyle: label
|
|
1100
|
+
},
|
|
1101
|
+
description: null,
|
|
1102
|
+
label,
|
|
1103
|
+
lineWidth: 6,
|
|
1104
|
+
tab: null,
|
|
1105
|
+
...rest
|
|
1106
|
+
};
|
|
1107
|
+
};
|
|
1108
|
+
|
|
1109
|
+
// src/utils/fields-json-rebuild/rebuild-image.ts
|
|
1110
|
+
var rebuildImage = (truncatedJson) => {
|
|
1111
|
+
const { widget, label, ...rest } = truncatedJson || {};
|
|
1112
|
+
return {
|
|
1113
|
+
widget: {
|
|
1114
|
+
type: "image",
|
|
1115
|
+
widgetName: buildWidgetName(),
|
|
1116
|
+
widgetNameAlias: "",
|
|
1117
|
+
customCls: null,
|
|
1118
|
+
height: 100,
|
|
1119
|
+
enable: true,
|
|
1120
|
+
visible: true,
|
|
1121
|
+
allowBlank: true,
|
|
1122
|
+
funMode: "module",
|
|
1123
|
+
module: null,
|
|
1124
|
+
libs: [],
|
|
1125
|
+
extendSet: {
|
|
1126
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
1127
|
+
status: true,
|
|
1128
|
+
triggerField: "",
|
|
1129
|
+
triggerFieldMode: "none",
|
|
1130
|
+
version: 1
|
|
1131
|
+
},
|
|
1132
|
+
download: true,
|
|
1133
|
+
//打包下载
|
|
1134
|
+
is_file_down: true,
|
|
1135
|
+
//操作权限 可下载
|
|
1136
|
+
check_image_exif: true,
|
|
1137
|
+
//照片支持查看EXIF扩展信息
|
|
1138
|
+
online_edit: false,
|
|
1139
|
+
online_edit_record: false,
|
|
1140
|
+
fileType: [
|
|
1141
|
+
//支持上传的类型,默认,不可以设置
|
|
1142
|
+
"jpg",
|
|
1143
|
+
"jpeg",
|
|
1144
|
+
"png",
|
|
1145
|
+
"gif",
|
|
1146
|
+
"bmp",
|
|
1147
|
+
"tif"
|
|
1148
|
+
],
|
|
1149
|
+
compressed: true,
|
|
1150
|
+
//三方图片压缩
|
|
1151
|
+
wxOriginalComponent: true,
|
|
1152
|
+
//微信/企业微信原生拍照模式
|
|
1153
|
+
onlyCamera: false,
|
|
1154
|
+
//仅允许拍照上传
|
|
1155
|
+
preview: true,
|
|
1156
|
+
//是否可以预览 默认 不可以设置
|
|
1157
|
+
watermarkSwitch: true,
|
|
1158
|
+
//水印属性
|
|
1159
|
+
watermarkPosition: "center",
|
|
1160
|
+
//水印位置
|
|
1161
|
+
watermarkFieldTitle: true,
|
|
1162
|
+
//是否显示水印字段标题
|
|
1163
|
+
watermarkSize: "14",
|
|
1164
|
+
//水印字体大小 不可以设置
|
|
1165
|
+
watermarkFixedField: {},
|
|
1166
|
+
previewWidth: 450,
|
|
1167
|
+
//预览的宽 默认 不可以设置
|
|
1168
|
+
previewHeight: 450,
|
|
1169
|
+
//预览的高 默认 不可以设置
|
|
1170
|
+
browserCompress: true,
|
|
1171
|
+
//浏览器图片压缩
|
|
1172
|
+
quality: 0.7,
|
|
1173
|
+
//压缩图片比例,开启 浏览器图片压缩 后才能设置
|
|
1174
|
+
...widget,
|
|
1175
|
+
labelStyle: label
|
|
1176
|
+
},
|
|
1177
|
+
label,
|
|
1178
|
+
lineWidth: 6,
|
|
1179
|
+
tab: null,
|
|
1180
|
+
...rest
|
|
1181
|
+
};
|
|
1182
|
+
};
|
|
1183
|
+
|
|
1184
|
+
// src/utils/fields-json-rebuild/rebuild-upload.ts
|
|
1185
|
+
var rebuildUploader = (truncatedJson) => {
|
|
1186
|
+
const { widget, label, ...rest } = truncatedJson || {};
|
|
1187
|
+
return {
|
|
1188
|
+
widget: {
|
|
1189
|
+
type: "upload",
|
|
1190
|
+
widgetName: buildWidgetName(),
|
|
1191
|
+
widgetNameAlias: "",
|
|
1192
|
+
customCls: null,
|
|
1193
|
+
enable: true,
|
|
1194
|
+
visible: true,
|
|
1195
|
+
allowBlank: true,
|
|
1196
|
+
maxFileCount: 50,
|
|
1197
|
+
//允许多文件上传 1为不可以 50为可以
|
|
1198
|
+
download: true,
|
|
1199
|
+
//打包下载
|
|
1200
|
+
is_file_down: true,
|
|
1201
|
+
//操作权限 可下载
|
|
1202
|
+
check_image_exif: true,
|
|
1203
|
+
//照片支持查看EXIF扩展信息
|
|
1204
|
+
online_edit: true,
|
|
1205
|
+
//允许文档在线编辑
|
|
1206
|
+
online_edit_record: true,
|
|
1207
|
+
//是否查看协作记录
|
|
1208
|
+
fileSizeLimit: 10485760,
|
|
1209
|
+
//设置单个文件大小上限,单位是字节,范围 1M-20M
|
|
1210
|
+
// fileType,
|
|
1211
|
+
...widget,
|
|
1212
|
+
labelStyle: label
|
|
1213
|
+
},
|
|
1214
|
+
// description,
|
|
1215
|
+
label,
|
|
1216
|
+
lineWidth: 6,
|
|
1217
|
+
tab: null,
|
|
1218
|
+
...rest
|
|
1219
|
+
};
|
|
1220
|
+
};
|
|
1221
|
+
|
|
1222
|
+
// src/utils/fields-json-rebuild/rebuild-checkbox-group.ts
|
|
1223
|
+
var rebuildCheckboxGroup = (truncatedJson) => {
|
|
1224
|
+
const { widget, label, ...rest } = truncatedJson || {};
|
|
1225
|
+
return {
|
|
1226
|
+
widget: {
|
|
1227
|
+
type: "checkboxgroup",
|
|
1228
|
+
widgetName: buildWidgetName(),
|
|
1229
|
+
widgetNameAlias: "",
|
|
1230
|
+
customCls: null,
|
|
1231
|
+
enable: true,
|
|
1232
|
+
visible: true,
|
|
1233
|
+
allowBlank: true,
|
|
1234
|
+
funMode: "module",
|
|
1235
|
+
module: null,
|
|
1236
|
+
libs: [],
|
|
1237
|
+
extendSet: {
|
|
1238
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
1239
|
+
status: true,
|
|
1240
|
+
triggerField: "",
|
|
1241
|
+
triggerFieldMode: "none",
|
|
1242
|
+
version: 1
|
|
1243
|
+
},
|
|
1244
|
+
colorEnable: true,
|
|
1245
|
+
//颜色 是否开启颜色
|
|
1246
|
+
layout: "vertical",
|
|
1247
|
+
allowAddOptions: false,
|
|
1248
|
+
//允许成员填写时添加新选项
|
|
1249
|
+
...widget,
|
|
1250
|
+
labelStyle: label
|
|
1251
|
+
},
|
|
1252
|
+
label,
|
|
1253
|
+
lineWidth: 6,
|
|
1254
|
+
tab: null,
|
|
1255
|
+
...rest
|
|
1256
|
+
};
|
|
1257
|
+
};
|
|
1258
|
+
|
|
1259
|
+
// src/utils/fields-json-rebuild/rebuild-line.ts
|
|
1260
|
+
var rebuildLine = (truncatedJson) => {
|
|
1261
|
+
const { widget, label, ...rest } = truncatedJson || {};
|
|
1262
|
+
return {
|
|
1263
|
+
widget: {
|
|
1264
|
+
type: "separator",
|
|
1265
|
+
widgetName: buildWidgetName(),
|
|
1266
|
+
widgetNameAlias: "",
|
|
1267
|
+
customCls: null,
|
|
1268
|
+
enable: true,
|
|
1269
|
+
visible: true,
|
|
1270
|
+
allowBlank: true,
|
|
1271
|
+
...widget,
|
|
1272
|
+
labelStyle: label
|
|
1273
|
+
},
|
|
1274
|
+
label,
|
|
1275
|
+
lineWidth: 12,
|
|
1276
|
+
tab: null,
|
|
1277
|
+
...rest
|
|
1278
|
+
};
|
|
1279
|
+
};
|
|
1280
|
+
|
|
1281
|
+
// src/utils/fields-json-rebuild/rebuild-combo-checker.ts
|
|
1282
|
+
var rebuildComboChecker = (truncatedJson) => {
|
|
1283
|
+
const { widget, label, ...rest } = truncatedJson || {};
|
|
1284
|
+
return {
|
|
1285
|
+
widget: {
|
|
1286
|
+
type: "combocheck",
|
|
1287
|
+
widgetName: buildWidgetName(),
|
|
1288
|
+
widgetNameAlias: "",
|
|
1289
|
+
customCls: null,
|
|
1290
|
+
height: 34,
|
|
1291
|
+
width: 350,
|
|
1292
|
+
enable: true,
|
|
1293
|
+
visible: true,
|
|
1294
|
+
allowBlank: true,
|
|
1295
|
+
funMode: "module",
|
|
1296
|
+
module: null,
|
|
1297
|
+
libs: [],
|
|
1298
|
+
extendSet: {
|
|
1299
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
1300
|
+
status: true,
|
|
1301
|
+
triggerField: "",
|
|
1302
|
+
triggerFieldMode: "none",
|
|
1303
|
+
version: 1
|
|
1304
|
+
},
|
|
1305
|
+
colorEnable: true,
|
|
1306
|
+
//颜色 是否开启颜色
|
|
1307
|
+
mode: "",
|
|
1308
|
+
allowAddOptions: false,
|
|
1309
|
+
//允许成员填写时添加新选项
|
|
1310
|
+
allowAddLinkData: false,
|
|
1311
|
+
...widget,
|
|
1312
|
+
labelStyle: label
|
|
1313
|
+
},
|
|
1314
|
+
label,
|
|
1315
|
+
lineWidth: 6,
|
|
1316
|
+
tab: null,
|
|
1317
|
+
...rest
|
|
1318
|
+
};
|
|
1319
|
+
};
|
|
1320
|
+
|
|
1321
|
+
// src/utils/fields-json-rebuild/rebuild-location.ts
|
|
1322
|
+
var rebuildLocation = (truncatedJson) => {
|
|
1323
|
+
const { widget, label, ...rest } = truncatedJson || {};
|
|
1324
|
+
return {
|
|
1325
|
+
widget: {
|
|
1326
|
+
type: "location",
|
|
1327
|
+
widgetName: buildWidgetName(),
|
|
1328
|
+
widgetNameAlias: "",
|
|
1329
|
+
customCls: null,
|
|
1330
|
+
enable: true,
|
|
1331
|
+
visible: true,
|
|
1332
|
+
allowBlank: true,
|
|
1333
|
+
funMode: "module",
|
|
1334
|
+
module: null,
|
|
1335
|
+
libs: [],
|
|
1336
|
+
extendSet: {
|
|
1337
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
1338
|
+
status: true,
|
|
1339
|
+
triggerField: "",
|
|
1340
|
+
triggerFieldMode: "none",
|
|
1341
|
+
version: 1
|
|
1342
|
+
},
|
|
1343
|
+
adjustable: true,
|
|
1344
|
+
//允许移动端微调
|
|
1345
|
+
lnglatVisible: true,
|
|
1346
|
+
//显示经纬度坐标
|
|
1347
|
+
autoLocation: true,
|
|
1348
|
+
//移动端自动触发定位
|
|
1349
|
+
enablePcLocation: true,
|
|
1350
|
+
//允许PC端定位并选择位置
|
|
1351
|
+
...widget,
|
|
1352
|
+
labelStyle: label
|
|
1353
|
+
},
|
|
1354
|
+
label,
|
|
1355
|
+
lineWidth: 6,
|
|
1356
|
+
tab: null,
|
|
1357
|
+
...rest
|
|
1358
|
+
};
|
|
1359
|
+
};
|
|
1360
|
+
|
|
1361
|
+
// src/utils/fields-json-rebuild/rebuild-textarea.ts
|
|
1362
|
+
var rebuildTextarea = (truncatedJson) => {
|
|
1363
|
+
const { widget, label, ...rest } = truncatedJson || {};
|
|
1364
|
+
return {
|
|
1365
|
+
widget: {
|
|
1366
|
+
type: "textarea",
|
|
1367
|
+
widgetName: buildWidgetName(),
|
|
1368
|
+
widgetNameAlias: "",
|
|
1369
|
+
triggerEvent: false,
|
|
1370
|
+
customCls: null,
|
|
1371
|
+
height: 140,
|
|
1372
|
+
width: 734,
|
|
1373
|
+
value: "",
|
|
1374
|
+
enable: true,
|
|
1375
|
+
visible: true,
|
|
1376
|
+
allowBlank: true,
|
|
1377
|
+
funMode: "module",
|
|
1378
|
+
module: null,
|
|
1379
|
+
libs: [],
|
|
1380
|
+
extendSet: {
|
|
1381
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
1382
|
+
status: true,
|
|
1383
|
+
triggerField: "",
|
|
1384
|
+
triggerFieldMode: "none",
|
|
1385
|
+
version: 1
|
|
1386
|
+
},
|
|
1387
|
+
noRepeat: false,
|
|
1388
|
+
alertinfo: {
|
|
1389
|
+
icon: "success",
|
|
1390
|
+
tip: "\u8BF7\u8BBE\u7F6E\u63D0\u793A\u5185\u5BB9"
|
|
1391
|
+
},
|
|
1392
|
+
autoHeight: true,
|
|
1393
|
+
//根据内容自适应高度
|
|
1394
|
+
maxLength: 5e3,
|
|
1395
|
+
//限制输入最大字符数 不限制的话,整个maxLength不存在
|
|
1396
|
+
...widget,
|
|
1397
|
+
labelStyle: label
|
|
1398
|
+
},
|
|
1399
|
+
// description,
|
|
1400
|
+
label,
|
|
1401
|
+
lineWidth: 6,
|
|
1402
|
+
tab: null,
|
|
1403
|
+
...rest
|
|
1404
|
+
};
|
|
1405
|
+
};
|
|
1406
|
+
|
|
1407
|
+
// src/utils/fields-json-rebuild/rebuild-button.ts
|
|
1408
|
+
var rebuildButton = (truncatedJson = {}) => {
|
|
1409
|
+
const { widget, label, ...rest } = truncatedJson;
|
|
1410
|
+
return {
|
|
1411
|
+
widget: {
|
|
1412
|
+
type: "button",
|
|
1413
|
+
widgetName: buildWidgetName(),
|
|
1414
|
+
widgetNameAlias: "",
|
|
1415
|
+
triggerEvent: 0,
|
|
1416
|
+
customCls: null,
|
|
1417
|
+
height: 36,
|
|
1418
|
+
width: 350,
|
|
1419
|
+
enable: true,
|
|
1420
|
+
visible: true,
|
|
1421
|
+
allowBlank: false,
|
|
1422
|
+
extendSet: {
|
|
1423
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
1424
|
+
status: true,
|
|
1425
|
+
triggerField: "",
|
|
1426
|
+
triggerFieldMode: "none",
|
|
1427
|
+
funMode: "popupreport"
|
|
1428
|
+
},
|
|
1429
|
+
background: {
|
|
1430
|
+
//颜色
|
|
1431
|
+
mode: "color",
|
|
1432
|
+
position: "center"
|
|
1433
|
+
},
|
|
1434
|
+
mode: "all",
|
|
1435
|
+
//模式 all 扩展 popupreport 弹出报表 popupform 弹出表单 print 页面打印 popuppage 弹出外部网页
|
|
1436
|
+
theme: "default",
|
|
1437
|
+
//风格 default 默认,有边框有底色 style1 有边框无底色 none 无边框无底色
|
|
1438
|
+
eventAlert: false,
|
|
1439
|
+
//是否显示提醒框
|
|
1440
|
+
alertinfo: {
|
|
1441
|
+
icon: "success",
|
|
1442
|
+
tip: "\u8BF7\u8BBE\u7F6E\u63D0\u793A\u5185\u5BB9"
|
|
1443
|
+
},
|
|
1444
|
+
...widget,
|
|
1445
|
+
labelStyle: label
|
|
1446
|
+
},
|
|
1447
|
+
label,
|
|
1448
|
+
lineWidth: 6,
|
|
1449
|
+
tab: null,
|
|
1450
|
+
...rest
|
|
1451
|
+
};
|
|
1452
|
+
};
|
|
1453
|
+
|
|
1454
|
+
// src/utils/fields-json-rebuild/rebuild-address.ts
|
|
1455
|
+
var rebuildAddress = (truncatedJson = {}) => {
|
|
1456
|
+
const { widget, label, ...rest } = truncatedJson;
|
|
1457
|
+
return {
|
|
1458
|
+
widget: {
|
|
1459
|
+
type: "address",
|
|
1460
|
+
widgetName: buildWidgetName(),
|
|
1461
|
+
widgetNameAlias: "",
|
|
1462
|
+
customCls: null,
|
|
1463
|
+
width: 720,
|
|
1464
|
+
enable: true,
|
|
1465
|
+
visible: true,
|
|
1466
|
+
funMode: "module",
|
|
1467
|
+
module: null,
|
|
1468
|
+
libs: [],
|
|
1469
|
+
extendSet: {
|
|
1470
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
1471
|
+
status: true,
|
|
1472
|
+
triggerField: "",
|
|
1473
|
+
triggerFieldMode: "none",
|
|
1474
|
+
version: 1
|
|
1475
|
+
},
|
|
1476
|
+
needDetail: true,
|
|
1477
|
+
eventMode: 1,
|
|
1478
|
+
//公式联动触发模式 1 默认,省市县/详细地址内容改变都触发 2 只有省市县改变才触发 3 只有详细地址改变才触发
|
|
1479
|
+
seleceMapAddress: true,
|
|
1480
|
+
//开启经纬度定位
|
|
1481
|
+
...widget,
|
|
1482
|
+
labelStyle: label
|
|
1483
|
+
},
|
|
1484
|
+
label,
|
|
1485
|
+
lineWidth: 6,
|
|
1486
|
+
tab: null,
|
|
1487
|
+
...rest
|
|
1488
|
+
};
|
|
1489
|
+
};
|
|
1490
|
+
|
|
1491
|
+
// src/utils/fields-json-rebuild/rebuild-subform.ts
|
|
1492
|
+
var rebuildSubform = (originObj = {}) => {
|
|
1493
|
+
const { widget, label, ...rest } = originObj;
|
|
1494
|
+
return {
|
|
1495
|
+
widget: {
|
|
1496
|
+
type: "subform",
|
|
1497
|
+
widgetName: buildWidgetName(),
|
|
1498
|
+
widgetNameAlias: "",
|
|
1499
|
+
customCls: null,
|
|
1500
|
+
enable: true,
|
|
1501
|
+
visible: true,
|
|
1502
|
+
allowBlank: true,
|
|
1503
|
+
labelStyle: label,
|
|
1504
|
+
extendSet: {
|
|
1505
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
1506
|
+
status: true,
|
|
1507
|
+
triggerField: "",
|
|
1508
|
+
triggerFieldMode: "none",
|
|
1509
|
+
version: 1
|
|
1510
|
+
},
|
|
1511
|
+
items: (widget.items || []).map((item, index) => {
|
|
1512
|
+
const result = rebuildFieldsJsonStructure(item, true);
|
|
1513
|
+
result.widget.widgetName = buildWidgetName("_widget", index);
|
|
1514
|
+
return result;
|
|
1515
|
+
}),
|
|
1516
|
+
sortable: true,
|
|
1517
|
+
//启用子表单数据排序
|
|
1518
|
+
allowImportV2: false,
|
|
1519
|
+
//从excel导入数据
|
|
1520
|
+
sticky_column: {
|
|
1521
|
+
//PC端冻结前 n 列
|
|
1522
|
+
limit: 2,
|
|
1523
|
+
//多少列 范围 1-3
|
|
1524
|
+
enable: true
|
|
1525
|
+
//是否开启
|
|
1526
|
+
},
|
|
1527
|
+
sticky_column_mobile: {
|
|
1528
|
+
//移动端冻结前 n 列
|
|
1529
|
+
limit: 1,
|
|
1530
|
+
//多少列 范围 1-3
|
|
1531
|
+
enable: true
|
|
1532
|
+
//是否开启
|
|
1533
|
+
},
|
|
1534
|
+
mobileStyle: "table",
|
|
1535
|
+
//移动端显示样式 list 纵向展开 table 横向表格
|
|
1536
|
+
subform_create: true,
|
|
1537
|
+
//可新增记录
|
|
1538
|
+
subform_insert: true,
|
|
1539
|
+
//可插入记录
|
|
1540
|
+
subform_edit: true,
|
|
1541
|
+
//可编辑已有记录
|
|
1542
|
+
subform_delete: true,
|
|
1543
|
+
//可删除已有记录
|
|
1544
|
+
subform_fill: true,
|
|
1545
|
+
//允许填报数据
|
|
1546
|
+
subform_import: true,
|
|
1547
|
+
//允许导入数据
|
|
1548
|
+
subform_dataload: true,
|
|
1549
|
+
//允许数据加载
|
|
1550
|
+
loaddataconfig: {
|
|
1551
|
+
//数据加载设置
|
|
1552
|
+
mode: "tree",
|
|
1553
|
+
extendSet: {
|
|
1554
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
1555
|
+
status: true,
|
|
1556
|
+
triggerField: "",
|
|
1557
|
+
triggerFieldMode: "none"
|
|
1558
|
+
}
|
|
1559
|
+
},
|
|
1560
|
+
allowLoadData: false,
|
|
1561
|
+
//是否开启数据加载
|
|
1562
|
+
allowAddData: true,
|
|
1563
|
+
//允许新增数据源数据
|
|
1564
|
+
subformloaddataTitle: "\u6570\u636E\u52A0\u8F7D",
|
|
1565
|
+
//数据加载显示的标题
|
|
1566
|
+
subFieldShowRules: [],
|
|
1567
|
+
//子字段显隐规则
|
|
1568
|
+
quick_fill: true
|
|
1569
|
+
//从excel填报数据
|
|
1570
|
+
},
|
|
1571
|
+
description: null,
|
|
1572
|
+
label,
|
|
1573
|
+
lineWidth: 12,
|
|
1574
|
+
tab: null
|
|
1575
|
+
};
|
|
1576
|
+
};
|
|
1577
|
+
|
|
1578
|
+
// src/utils/fields-json-rebuild/rebuild-data-query.ts
|
|
1579
|
+
var rebuildDataQuery = (truncatedJson) => {
|
|
1580
|
+
const { widget, label, ...rest } = truncatedJson || {};
|
|
1581
|
+
return {
|
|
1582
|
+
widget: {
|
|
1583
|
+
widgetName: buildWidgetName(),
|
|
1584
|
+
widgetNameAlias: "",
|
|
1585
|
+
customCls: null,
|
|
1586
|
+
enable: true,
|
|
1587
|
+
visible: true,
|
|
1588
|
+
allowBlank: true,
|
|
1589
|
+
linkFilter: {},
|
|
1590
|
+
rely: {
|
|
1591
|
+
widgets: []
|
|
1592
|
+
},
|
|
1593
|
+
showMode: "one",
|
|
1594
|
+
//显示数据条数 one 一条 many 多条
|
|
1595
|
+
allowAdd: true,
|
|
1596
|
+
//允许新增关联表数据,只有 refType 为 form才可以选择true
|
|
1597
|
+
refType: "form",
|
|
1598
|
+
//关联表的类型,根据 linkForm 表的类型决定的。 form 表单 etl_table 视图 aggregate_table 聚合表
|
|
1599
|
+
showType: "none",
|
|
1600
|
+
//数据显示模式 none 默认 label 标题
|
|
1601
|
+
addExtendSet: [],
|
|
1602
|
+
...widget,
|
|
1603
|
+
linkFields: [],
|
|
1604
|
+
labelStyle: label,
|
|
1605
|
+
type: "linkquery"
|
|
1606
|
+
},
|
|
1607
|
+
description: null,
|
|
1608
|
+
label,
|
|
1609
|
+
lineWidth: 6,
|
|
1610
|
+
tab: null,
|
|
1611
|
+
...rest
|
|
1612
|
+
};
|
|
1613
|
+
};
|
|
1614
|
+
|
|
1615
|
+
// src/utils/fields-json-rebuild/index.ts
|
|
1616
|
+
var RebuilderMap = {
|
|
1617
|
+
address: rebuildAddress,
|
|
1618
|
+
button: rebuildButton,
|
|
1619
|
+
textarea: rebuildTextarea,
|
|
1620
|
+
datetime: rebuildDatetime,
|
|
1621
|
+
text: rebuildText,
|
|
1622
|
+
password: rebuildText,
|
|
1623
|
+
location: rebuildLocation,
|
|
1624
|
+
radiogroup: rebuildRadioGroup,
|
|
1625
|
+
radio: rebuildRadioGroup,
|
|
1626
|
+
combo: rebuildSelect,
|
|
1627
|
+
combocheck: rebuildComboChecker,
|
|
1628
|
+
separator: rebuildLine,
|
|
1629
|
+
checkboxgroup: rebuildCheckboxGroup,
|
|
1630
|
+
upload: rebuildUploader,
|
|
1631
|
+
number: rebuildNumber,
|
|
1632
|
+
image: rebuildImage,
|
|
1633
|
+
signature: rebuildSignature,
|
|
1634
|
+
user: rebuildUser,
|
|
1635
|
+
dataload: rebuildDataLoader,
|
|
1636
|
+
linkdata: rebuildDataLinker,
|
|
1637
|
+
linkquery: rebuildDataQuery,
|
|
1638
|
+
usergroup: rebuildUserGroup,
|
|
1639
|
+
subform: rebuildSubform,
|
|
1640
|
+
dept: rebuildDept,
|
|
1641
|
+
sn: rebuildSn,
|
|
1642
|
+
deptgroup: rebuildDeptGroup,
|
|
1643
|
+
unknown: defaultBuilder
|
|
1644
|
+
};
|
|
1645
|
+
var rebuildFieldsJsonStructure = (truncatedJson, subItemsOnly = false) => {
|
|
1646
|
+
if (!truncatedJson || !truncatedJson.widget || !truncatedJson.widget.type) {
|
|
1647
|
+
return truncatedJson;
|
|
1648
|
+
}
|
|
1649
|
+
const fieldType = truncatedJson.widget.type || "unknown";
|
|
1650
|
+
if (subItemsOnly && fieldType === "subform") {
|
|
1651
|
+
return defaultBuilder(truncatedJson);
|
|
1652
|
+
}
|
|
1653
|
+
const rebuilder = RebuilderMap[fieldType] || defaultBuilder;
|
|
1654
|
+
return rebuilder(truncatedJson);
|
|
636
1655
|
};
|
|
637
1656
|
|
|
638
1657
|
// src/stream-trasnformer/fields-json-transform-stream.ts
|
|
639
|
-
var import_ai_feat_utils2 = require("@baishuyun/ai-feat-utils");
|
|
640
1658
|
var createFieldsJsonTransformStream = (enableJsonParser) => {
|
|
641
1659
|
let parser;
|
|
642
|
-
let enqueueTextDelta;
|
|
643
1660
|
let id;
|
|
644
|
-
let isFirstChunk = true;
|
|
645
|
-
let passthroughMode = false;
|
|
646
1661
|
const chunkGuard = (chunk) => {
|
|
647
|
-
if (!enableJsonParser
|
|
1662
|
+
if (!enableJsonParser) {
|
|
648
1663
|
return false;
|
|
649
1664
|
}
|
|
650
1665
|
if (chunk.type !== "text-delta" || !("delta" in chunk)) {
|
|
@@ -661,28 +1676,20 @@ var createFieldsJsonTransformStream = (enableJsonParser) => {
|
|
|
661
1676
|
}
|
|
662
1677
|
},
|
|
663
1678
|
transform: (chunk, controller) => {
|
|
664
|
-
if (!parser
|
|
1679
|
+
if (!parser) {
|
|
1680
|
+
console.log("parser not init");
|
|
665
1681
|
return;
|
|
666
1682
|
}
|
|
667
1683
|
try {
|
|
668
1684
|
if (chunkGuard(chunk)) {
|
|
669
1685
|
if ("id" in chunk && "delta" in chunk) {
|
|
670
1686
|
id = chunk.id;
|
|
671
|
-
|
|
672
|
-
if (isFirstChunk) {
|
|
673
|
-
delta = delta.replace(/^\uFEFF/, "");
|
|
674
|
-
isFirstChunk = false;
|
|
675
|
-
}
|
|
676
|
-
parser.write(delta);
|
|
677
|
-
} else {
|
|
678
|
-
console.warn("Unexpected chunk format for JSON parsing:", chunk);
|
|
679
|
-
controller.enqueue(chunk);
|
|
1687
|
+
parser.write(chunk.delta);
|
|
680
1688
|
}
|
|
681
1689
|
} else {
|
|
682
1690
|
controller.enqueue(chunk);
|
|
683
1691
|
}
|
|
684
1692
|
} catch (e) {
|
|
685
|
-
console.log("write or enqueue error", e);
|
|
686
1693
|
controller.error(e);
|
|
687
1694
|
}
|
|
688
1695
|
},
|
|
@@ -690,7 +1697,7 @@ var createFieldsJsonTransformStream = (enableJsonParser) => {
|
|
|
690
1697
|
parser = new import_json.JSONParser({
|
|
691
1698
|
paths: ["$.*"]
|
|
692
1699
|
});
|
|
693
|
-
enqueueTextDelta = enableJsonParser ? createTextInfoEnqueuer(controller) : (content) => {
|
|
1700
|
+
const enqueueTextDelta = enableJsonParser ? createTextInfoEnqueuer(controller) : (content) => {
|
|
694
1701
|
};
|
|
695
1702
|
parser.onValue = (parsedInfo) => {
|
|
696
1703
|
const value = parsedInfo.value;
|
|
@@ -701,14 +1708,17 @@ var createFieldsJsonTransformStream = (enableJsonParser) => {
|
|
|
701
1708
|
JSON.stringify(value),
|
|
702
1709
|
JSON.stringify({
|
|
703
1710
|
type: "mcp-fields-json",
|
|
704
|
-
field:
|
|
1711
|
+
field: rebuildFieldsJsonStructure(value)
|
|
705
1712
|
}),
|
|
706
1713
|
id
|
|
707
1714
|
);
|
|
708
1715
|
};
|
|
1716
|
+
let errorLogged = false;
|
|
709
1717
|
parser.onError = (err) => {
|
|
710
|
-
|
|
711
|
-
|
|
1718
|
+
if (!errorLogged) {
|
|
1719
|
+
console.error("JsonWidgetStream: JSON Parsing Error:", err);
|
|
1720
|
+
errorLogged = true;
|
|
1721
|
+
}
|
|
712
1722
|
};
|
|
713
1723
|
parser.onEnd = () => {
|
|
714
1724
|
enqueueTextDelta(
|