weaver-work-cli 0.1.29 → 0.1.32

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.
Files changed (185) hide show
  1. package/dist/chunks/archive-UMGX72K6.js +2537 -0
  2. package/dist/chunks/archive-oa-N2IYBLF3.js +1317 -0
  3. package/dist/chunks/asset-GLEGKFG5.js +2109 -0
  4. package/dist/chunks/attachment-content-AQNX5N3S.js +23 -0
  5. package/dist/chunks/blog-E44OTVDA.js +2157 -0
  6. package/dist/chunks/caizhilian-DQUFZXZL.js +10087 -0
  7. package/dist/chunks/calendar-JKPIRKFD.js +1195 -0
  8. package/dist/chunks/chunk-2GA5ZIQL.js +1615 -0
  9. package/dist/chunks/chunk-4YC43QQ4.js +403 -0
  10. package/dist/chunks/chunk-6EFWDL7Y.js +161 -0
  11. package/dist/chunks/chunk-6RKD4DRZ.js +5556 -0
  12. package/dist/chunks/chunk-AJ62BGAW.js +29 -0
  13. package/dist/chunks/chunk-BUSC6UAE.js +43 -0
  14. package/dist/chunks/chunk-C6R3B2ML.js +358 -0
  15. package/dist/chunks/chunk-CVZ2JOSW.js +62 -0
  16. package/dist/chunks/chunk-DW6AUUKS.js +508 -0
  17. package/dist/chunks/chunk-E4Z23GHM.js +6962 -0
  18. package/dist/chunks/chunk-EG6ZU444.js +654 -0
  19. package/dist/chunks/chunk-EZALDOQH.js +383 -0
  20. package/dist/chunks/chunk-FMPJJYYI.js +106 -0
  21. package/dist/chunks/chunk-G2JSIUWF.js +769 -0
  22. package/dist/chunks/chunk-G3QJULO2.js +387 -0
  23. package/dist/chunks/chunk-GCG2NMWR.js +703 -0
  24. package/dist/chunks/chunk-GPMFD4RD.js +75 -0
  25. package/dist/chunks/chunk-H6XSTSLM.js +2357 -0
  26. package/dist/chunks/chunk-H7J4DC5R.js +464 -0
  27. package/dist/chunks/chunk-IURUFGZK.js +477 -0
  28. package/dist/chunks/chunk-LUSPKZKY.js +53 -0
  29. package/dist/chunks/chunk-NIAJ5ZCG.js +73 -0
  30. package/dist/chunks/chunk-NOODWMCL.js +584 -0
  31. package/dist/chunks/chunk-OOUTBLZ4.js +51 -0
  32. package/dist/chunks/chunk-P26ZWSKU.js +73 -0
  33. package/dist/chunks/chunk-QWY6PGL6.js +3472 -0
  34. package/dist/chunks/chunk-WKI2FBIQ.js +15606 -0
  35. package/dist/chunks/chunk-WSKBSQ2U.js +231 -0
  36. package/dist/chunks/chunk-YLCYX7LE.js +371 -0
  37. package/dist/chunks/chunk-YRVDW4WN.js +205 -0
  38. package/dist/chunks/chunk-ZEDWSH32.js +68 -0
  39. package/dist/chunks/continuation-2CKSBLA6.js +11 -0
  40. package/dist/chunks/continuation-HZIZRZBX.js +13 -0
  41. package/dist/chunks/continuation-NLECEJPX.js +11 -0
  42. package/dist/chunks/ebuilder-form-V5FG2EHC.js +2276 -0
  43. package/dist/chunks/ehr-HMFY6VIL.js +5241 -0
  44. package/dist/chunks/employee-SAK2QYXX.js +11 -0
  45. package/dist/chunks/esb-ZYSVB7SG.js +141 -0
  46. package/dist/chunks/fna-B7RKPAZD.js +1444 -0
  47. package/dist/chunks/host-45WED2KK.js +21 -0
  48. package/dist/chunks/host-I4Z6BFYX.js +23 -0
  49. package/dist/chunks/host-KNZ52LJZ.js +17 -0
  50. package/dist/chunks/host-OCH2BCCV.js +19 -0
  51. package/dist/chunks/hrm-2KAZGUHI.js +244 -0
  52. package/dist/chunks/im-ACJJWH4U.js +252 -0
  53. package/dist/chunks/invoice-ZK3WCX2U.js +5179 -0
  54. package/dist/chunks/jiuchuanhui-5PQD3IL2.js +1940 -0
  55. package/dist/chunks/lazy-dispatch-JQXBW3GM.js +28 -0
  56. package/dist/chunks/mail-S2HDDXO2.js +2695 -0
  57. package/dist/chunks/meeting-QVN3I37L.js +504 -0
  58. package/dist/chunks/msg-parse-4GSQ2WTO.js +41 -0
  59. package/dist/chunks/okr-QNG4VC2Q.js +2482 -0
  60. package/dist/chunks/plan-A25EMW6U.js +2025 -0
  61. package/dist/chunks/project-G6XV66DZ.js +1361 -0
  62. package/dist/chunks/registry-2VLUAESA.js +14 -0
  63. package/dist/chunks/registry-7C5UMIPL.js +19 -0
  64. package/dist/chunks/registry-DC6KR3NH.js +18 -0
  65. package/dist/chunks/registry-NYPYMZXG.js +16 -0
  66. package/dist/chunks/registry-TI3CIUXF.js +19 -0
  67. package/dist/chunks/room-recommend-WRTHO6Y2.js +20 -0
  68. package/dist/chunks/schedule-KFIITGSK.js +24 -0
  69. package/dist/chunks/state-Y2XBP6YE.js +15 -0
  70. package/dist/chunks/workflow-DJ7SYWAF.js +245 -0
  71. package/dist/cmd/argv.js +45 -0
  72. package/dist/cmd/docs/index.js +3 -3
  73. package/dist/cmd/lazy-dispatch.js +20 -0
  74. package/dist/cmd/root.js +2 -4
  75. package/dist/cmd/setup/index.js +2 -2
  76. package/dist/cmd/skills/index.js +2 -2
  77. package/dist/core/package-paths.js +61 -0
  78. package/dist/index.js +163 -7
  79. package/dist/internal/e10/auth/xiaoe.js +3 -3
  80. package/dist/internal/e10/request-runtime.js +18 -62
  81. package/dist/internal/skills/detector.js +2 -2
  82. package/dist/shortcuts/contract/data/performance-catalog.js +1306 -0
  83. package/dist/shortcuts/contract/host.js +91 -35
  84. package/dist/shortcuts/contract/index.js +213 -0
  85. package/dist/shortcuts/contract/manifest.js +928 -0
  86. package/dist/shortcuts/contract/ooxml/docx.js +295 -0
  87. package/dist/shortcuts/contract/ooxml/xlsx.js +221 -0
  88. package/dist/shortcuts/contract/ooxml/zip.js +158 -0
  89. package/dist/shortcuts/contract/operations/assistant.js +1156 -0
  90. package/dist/shortcuts/contract/operations/clause-library.js +522 -0
  91. package/dist/shortcuts/contract/operations/compare.js +193 -0
  92. package/dist/shortcuts/contract/operations/credit-page.js +34 -0
  93. package/dist/shortcuts/contract/operations/flow.js +98 -0
  94. package/dist/shortcuts/contract/operations/page.js +66 -0
  95. package/dist/shortcuts/contract/operations/performance.js +733 -0
  96. package/dist/shortcuts/contract/operations/quote.js +557 -0
  97. package/dist/shortcuts/contract/operations/recommend.js +78 -0
  98. package/dist/shortcuts/contract/operations/registry.js +18 -0
  99. package/dist/shortcuts/contract/operations/review.js +83 -0
  100. package/dist/shortcuts/contract/operations/shared.js +37 -0
  101. package/dist/shortcuts/contract/operations/upload.js +108 -0
  102. package/dist/shortcuts/contract/operations/write.js +3 -2
  103. package/dist/shortcuts/index.js +140 -40
  104. package/dist/shortcuts/invoice/manifest.js +34 -11
  105. package/dist/shortcuts/invoice/operations/reim-auto.js +9 -0
  106. package/dist/shortcuts/invoice/operations/reim.js +81 -5
  107. package/dist/shortcuts/invoice/operations/shared.js +12 -5
  108. package/dist/shortcuts/meeting/host.js +45 -3
  109. package/dist/shortcuts/meeting/invitation/docx.js +442 -0
  110. package/dist/shortcuts/meeting/operations/attachment-content.js +418 -0
  111. package/dist/shortcuts/meeting/operations/attachment.js +442 -0
  112. package/dist/shortcuts/meeting/operations/eb/cache.js +57 -0
  113. package/dist/shortcuts/meeting/operations/eb/catalog.js +343 -28
  114. package/dist/shortcuts/meeting/operations/eb/conflict.js +372 -11
  115. package/dist/shortcuts/meeting/operations/eb/create-flow.js +710 -0
  116. package/dist/shortcuts/meeting/operations/eb/decision.js +47 -1
  117. package/dist/shortcuts/meeting/operations/eb/factory.js +129 -11
  118. package/dist/shortcuts/meeting/operations/eb/index.js +122 -2
  119. package/dist/shortcuts/meeting/operations/eb/room-recommend.js +378 -0
  120. package/dist/shortcuts/meeting/operations/eb/room-summary.js +84 -0
  121. package/dist/shortcuts/meeting/operations/eb/schedule.js +450 -0
  122. package/dist/shortcuts/meeting/operations/from-group-chat.js +576 -0
  123. package/dist/shortcuts/meeting/operations/invitation.js +458 -0
  124. package/dist/shortcuts/meeting/operations/minute-content.js +266 -0
  125. package/dist/shortcuts/meeting/operations/pipeline.js +489 -0
  126. package/dist/shortcuts/meeting/operations/qrcode.js +131 -0
  127. package/dist/shortcuts/meeting/operations/receipts.js +1 -1
  128. package/dist/shortcuts/meeting/operations/registry.js +18 -0
  129. package/dist/shortcuts/meeting/operations/summary.js +276 -0
  130. package/dist/shortcuts/meeting/operations/task-notify.js +325 -0
  131. package/dist/shortcuts/meeting/operations.js +42 -1
  132. package/dist/shortcuts/meeting/qr/encoder.js +427 -0
  133. package/dist/shortcuts/meeting/qr/render.js +103 -0
  134. package/dist/shortcuts/workflow/operations/form.js +17 -5
  135. package/docs/contract.md +39 -4
  136. package/docs/invoice.md +5 -5
  137. package/package.json +3 -2
  138. package/scripts/bundle.mjs +63 -0
  139. package/skill-template/business-info.json +25 -4
  140. package/skill-template/domains/jinchengda.md +16 -3
  141. package/skill-template/domains/yepiaotong.md +1 -1
  142. package/skills/weaver-e10-jinchengda/SKILL.md +111 -31
  143. package/skills/weaver-e10-jinchengda/references/contract-agent-entry.md +7 -13
  144. package/skills/weaver-e10-jinchengda/references/contract-ai-assistant.md +150 -0
  145. package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +87 -0
  146. package/skills/weaver-e10-jinchengda/references/contract-clause-library-crud.md +111 -0
  147. package/skills/weaver-e10-jinchengda/references/contract-clause-recommender.md +0 -15
  148. package/skills/weaver-e10-jinchengda/references/contract-clause-reference-save.md +0 -13
  149. package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +50 -0
  150. package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +4 -2
  151. package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +74 -0
  152. package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +84 -0
  153. package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +29 -0
  154. package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +28 -0
  155. package/skills/weaver-e10-jinchengda/references/contract-request-status.md +2 -21
  156. package/skills/weaver-e10-jinchengda/references/contract-request-write.md +0 -24
  157. package/skills/weaver-e10-jinchengda/references/contract-signing-subjects.md +0 -15
  158. package/skills/weaver-e10-jinchengda/references/contract-subject-create.md +0 -17
  159. package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +70 -0
  160. package/skills/weaver-e10-jinchengda/references/contract-template-selector.md +0 -15
  161. package/skills/weaver-e10-jinchengda/references/contract-workflow-discovery.md +0 -15
  162. package/skills/weaver-e10-jinchengda/references/source-manifest.json +1168 -152
  163. package/skills/weaver-e10-meeting/SKILL.md +493 -17
  164. package/skills/weaver-e10-meeting/references/meeting-change.md +4 -4
  165. package/skills/weaver-e10-meeting/references/meeting-create.md +6 -6
  166. package/skills/weaver-e10-meeting/references/meeting-eb.md +503 -27
  167. package/skills/weaver-e10-meeting/references/meeting-invitation.md +113 -0
  168. package/skills/weaver-e10-meeting/references/meeting-lifecycle.md +6 -6
  169. package/skills/weaver-e10-meeting/references/meeting-minute-file.md +425 -0
  170. package/skills/weaver-e10-meeting/references/meeting-queries.md +4 -4
  171. package/skills/weaver-e10-meeting/references/meeting-receipts-signs.md +15 -15
  172. package/skills/weaver-e10-meeting/references/meeting-verification.md +19 -11
  173. package/skills/weaver-e10-meeting.zip +0 -0
  174. package/skills/weaver-e10-yepiaotong/SKILL.md +9 -5
  175. package/skills/weaver-e10-yepiaotong/references/invoice-enterprise-list.md +1 -1
  176. package/skills/weaver-e10-yepiaotong/references/invoice-personal-list.md +6 -5
  177. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +14 -11
  178. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +97 -56
  179. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +84 -60
  180. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +142 -105
  181. package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +53 -194
  182. package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +7 -7
  183. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +164 -72
  184. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +6 -0
  185. package/templates/meeting/invitation.docx +0 -0
@@ -0,0 +1,2276 @@
1
+ import { createRequire as __esbuildCreateRequire } from 'node:module';
2
+ const require = __esbuildCreateRequire(import.meta.url);
3
+ import {
4
+ createE10RequestRuntime,
5
+ requireE10Session
6
+ } from "./chunk-DW6AUUKS.js";
7
+ import {
8
+ getActiveProfile
9
+ } from "./chunk-2GA5ZIQL.js";
10
+ import {
11
+ CliError,
12
+ isCliError,
13
+ toErrorEnvelope
14
+ } from "./chunk-LUSPKZKY.js";
15
+ import "./chunk-BUSC6UAE.js";
16
+
17
+ // src/shortcuts/ebuilder-form/index.ts
18
+ import { readFile as readFile2 } from "node:fs/promises";
19
+
20
+ // src/shortcuts/ebuilder-form/continuation.ts
21
+ import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
22
+ import { existsSync } from "node:fs";
23
+ import { chmod, mkdir, readFile, writeFile } from "node:fs/promises";
24
+ import { homedir } from "node:os";
25
+ import { resolve } from "node:path";
26
+
27
+ // src/shortcuts/ebuilder-form/errors.ts
28
+ var EbuilderFormCliError = class extends CliError {
29
+ type;
30
+ subtype;
31
+ code;
32
+ retryable;
33
+ stage;
34
+ details;
35
+ constructor(type, subtype, message, options = {}) {
36
+ super(message, options.exitCode ?? 5 /* InternalError */);
37
+ this.name = "EbuilderFormCliError";
38
+ this.type = type;
39
+ this.subtype = subtype;
40
+ this.code = options.code;
41
+ this.retryable = options.retryable ?? false;
42
+ this.stage = options.stage;
43
+ this.details = options.details;
44
+ }
45
+ };
46
+ function ebuilderValidationError(subtype, message, details) {
47
+ return new EbuilderFormCliError("validation", subtype, message, {
48
+ details,
49
+ exitCode: 2 /* UsageError */
50
+ });
51
+ }
52
+ function ebuilderAuthError(subtype, message, details) {
53
+ return new EbuilderFormCliError("authentication", subtype, message, {
54
+ details,
55
+ exitCode: 3 /* AuthError */
56
+ });
57
+ }
58
+ function ebuilderBusinessError(subtype, message, options = {}) {
59
+ return new EbuilderFormCliError("api", subtype, message, {
60
+ code: options.code,
61
+ details: options.details,
62
+ retryable: options.retryable ?? false,
63
+ stage: options.stage,
64
+ exitCode: 1 /* GeneralError */
65
+ });
66
+ }
67
+ function ebuilderNetworkError(subtype, message, options = {}) {
68
+ return new EbuilderFormCliError("network", subtype, message, {
69
+ details: options.details,
70
+ retryable: options.retryable ?? true,
71
+ stage: options.stage,
72
+ exitCode: 4 /* NetworkError */
73
+ });
74
+ }
75
+ function ebuilderConfirmationError(action, details) {
76
+ return new EbuilderFormCliError("confirmation", "required", "\u8BE5 eBuilder \u8868\u5355\u5199\u64CD\u4F5C\u9700\u8981\u660E\u786E\u786E\u8BA4", {
77
+ details: { action, ...details },
78
+ exitCode: 10 /* ConfirmationRequired */
79
+ });
80
+ }
81
+
82
+ // src/shortcuts/ebuilder-form/continuation.ts
83
+ function stateRoot(ctx) {
84
+ const configured = ctx?.config?.path();
85
+ if (configured) return resolve(configured, "..");
86
+ return process.env.WEAVER_WORK_CLI_HOME || process.env.WORK_CLI_HOME || resolve(homedir(), ".weaver-work-cli");
87
+ }
88
+ async function loadKey(ctx) {
89
+ const keysDir = resolve(stateRoot(ctx), "keys");
90
+ const filename = resolve(keysDir, "ebuilder-form-continuation.key");
91
+ await mkdir(keysDir, { recursive: true, mode: 448 });
92
+ if (existsSync(filename)) return readFile(filename);
93
+ const key = randomBytes(32);
94
+ try {
95
+ await writeFile(filename, key, { flag: "wx", mode: 384 });
96
+ if (process.platform !== "win32") await chmod(filename, 384).catch(() => void 0);
97
+ return key;
98
+ } catch {
99
+ return readFile(filename);
100
+ }
101
+ }
102
+ function encode(value) {
103
+ return Buffer.from(JSON.stringify(value)).toString("base64url");
104
+ }
105
+ function signature(payload, key) {
106
+ return createHmac("sha256", key).update(payload).digest("base64url");
107
+ }
108
+ function createEbuilderFormContinuationSigner(ctx) {
109
+ return {
110
+ async issue(payload, ttlMs = 10 * 6e4) {
111
+ const issuedAt = Date.now();
112
+ const body = encode({ ...payload, issuedAt, expiresAt: issuedAt + ttlMs });
113
+ const sig = signature(body, await loadKey(ctx));
114
+ return `${body}.${sig}`;
115
+ },
116
+ async verify(token, expectedOperation) {
117
+ if (typeof token !== "string" || !token.includes(".")) {
118
+ throw ebuilderValidationError("continuation_invalid", "continuation \u65E0\u6548");
119
+ }
120
+ const [body, provided] = token.split(".");
121
+ const expected = signature(body, await loadKey(ctx));
122
+ const valid = provided.length === expected.length && timingSafeEqual(Buffer.from(provided), Buffer.from(expected));
123
+ if (!valid) throw ebuilderValidationError("continuation_invalid", "continuation \u7B7E\u540D\u6821\u9A8C\u5931\u8D25");
124
+ let value;
125
+ try {
126
+ value = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
127
+ } catch {
128
+ throw ebuilderValidationError("continuation_invalid", "continuation \u5185\u5BB9\u65E0\u6CD5\u89E3\u6790");
129
+ }
130
+ if (value.operation !== expectedOperation) {
131
+ throw ebuilderValidationError("continuation_mismatch", "continuation \u4E0D\u5C5E\u4E8E\u5F53\u524D\u64CD\u4F5C");
132
+ }
133
+ if (!Number.isSafeInteger(value.expiresAt) || value.expiresAt < Date.now()) {
134
+ throw ebuilderValidationError("continuation_expired", "continuation \u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C prepare");
135
+ }
136
+ return value;
137
+ }
138
+ };
139
+ }
140
+
141
+ // src/shortcuts/ebuilder-form/host.ts
142
+ import { randomUUID } from "node:crypto";
143
+ var PUBLIC_API_PREFIX = "/api/ebuilder";
144
+ var API_PREFIX_PATTERN = /^\/api\/ebuilder(?:\d+)?$/u;
145
+ var SUCCESS_CODES = /* @__PURE__ */ new Set(["0", "200", "true"]);
146
+ var DIRECT_LIST_TYPES = {
147
+ list: { pageType: "SEARCH", listKind: "List" },
148
+ search: { pageType: "SEARCH", listKind: "List" },
149
+ searchlist: { pageType: "SEARCH", listKind: "List" },
150
+ viewport: { pageType: "VIEWPORT", listKind: "NList" },
151
+ nlist: { pageType: "VIEWPORT", listKind: "NList" },
152
+ view: { pageType: "VIEWPORT", listKind: "NList" }
153
+ };
154
+ var OPENAPI_READ_PATHS = {
155
+ detail: "/form/dataset/v2/getDataById",
156
+ query: "/form/dataset/v2/getAllData",
157
+ count: "/form/dataset/v2/getAllDataCount"
158
+ };
159
+ var OPENAPI_WRITE_PATHS = {
160
+ add: "/form/dataset/v2/saveFormData",
161
+ update: "/form/dataset/v2/updateFormData",
162
+ delete: "/form/dataset/v2/deleteData"
163
+ };
164
+ var CUSTOM_READ_PATHS = {
165
+ detail: "/form/formdata/v2/getFormDataByPk",
166
+ query: "/form/formdata/v2/getFormDataList",
167
+ count: "/form/formdata/v2/getFormDataCount"
168
+ };
169
+ var CUSTOM_WRITE_PATHS = {
170
+ add: "/form/formdata/v2/saveFormData",
171
+ update: "/form/formdata/v2/updateFormData",
172
+ delete: "/form/formdata/v2/deleteFormData"
173
+ };
174
+ function resolveApiPrefix(value) {
175
+ const raw = (value || PUBLIC_API_PREFIX).trim();
176
+ if (!API_PREFIX_PATTERN.test(raw)) {
177
+ throw ebuilderValidationError("api_prefix_invalid", "apiPrefix \u5FC5\u987B\u662F /api/ebuilder \u6216 /api/ebuilder{appId}");
178
+ }
179
+ return raw;
180
+ }
181
+ function routeEbuilderPath(apiPrefix, suffix) {
182
+ const prefix = resolveApiPrefix(apiPrefix);
183
+ if (!suffix.startsWith("/") || suffix.startsWith("/api/") || suffix.includes("/../")) {
184
+ throw ebuilderValidationError("path_invalid", "eBuilder API suffix \u5FC5\u987B\u662F\u4EE5 / \u5F00\u5934\u4E14\u4E0D\u542B /api \u524D\u7F00\u7684\u76F8\u5BF9\u8DEF\u5F84");
185
+ }
186
+ const routedPrefix = suffix === "/form" || suffix.startsWith("/form/") ? prefix : PUBLIC_API_PREFIX;
187
+ return routedPrefix + suffix;
188
+ }
189
+ function parseDirectListUrl(value, expectedOrigin) {
190
+ const raw = String(value || "").trim();
191
+ if (!raw) throw ebuilderValidationError("url_required", "\u7F3A\u5C11\u9875\u9762 URL");
192
+ const confirmedOrigin = expectedOrigin ? originOnly(expectedOrigin) : originFromUrl(raw);
193
+ if (!confirmedOrigin) throw ebuilderValidationError("url_origin_required", "\u76F8\u5BF9\u9875\u9762 URL \u8FD8\u9700\u63D0\u4F9B\u5F53\u524D E10 origin");
194
+ const parsed = parseUrl(raw, confirmedOrigin);
195
+ const urlOrigin = parsed.origin === "null" ? "" : parsed.origin;
196
+ if (/^https?:/iu.test(raw) && urlOrigin !== confirmedOrigin) {
197
+ throw ebuilderValidationError("url_cross_origin", "\u9875\u9762 URL \u4E0E\u5F53\u524D origin \u4E0D\u540C\u6E90");
198
+ }
199
+ const entryUrl = /^https?:/iu.test(raw) ? raw : confirmedOrigin + raw;
200
+ const segments = parsed.pathname.split("/").filter(Boolean);
201
+ const pathMarkers = segments.map((item) => item.toLowerCase()).filter((item) => DIRECT_LIST_TYPES[item]);
202
+ if (new Set(pathMarkers.map((item) => DIRECT_LIST_TYPES[item].pageType)).size > 1) {
203
+ throw ebuilderValidationError("url_type_conflict", "\u9875\u9762 URL \u8DEF\u5F84\u540C\u65F6\u5305\u542B\u8868\u683C\u548C\u6570\u636E\u5217\u8868\u7C7B\u578B");
204
+ }
205
+ let pathType = "";
206
+ let pathId = "";
207
+ let pathAppId = "";
208
+ let pathMenuId = "";
209
+ if (segments.length >= 2) {
210
+ const marker2 = segments[segments.length - 2].toLowerCase();
211
+ const candidate = segments[segments.length - 1];
212
+ if (DIRECT_LIST_TYPES[marker2]) {
213
+ if (/^\d+$/u.test(candidate)) {
214
+ pathType = marker2;
215
+ pathId = candidate;
216
+ } else {
217
+ const combined = /^(\d+)_(\d+)$/u.exec(candidate);
218
+ const menu = /^(\d+)-(\d+)$/u.exec(candidate);
219
+ if (combined) {
220
+ pathType = marker2;
221
+ pathAppId = combined[1];
222
+ pathId = combined[2];
223
+ } else if (menu && segments.length >= 4 && ["view", "detail"].includes(segments[segments.length - 4].toLowerCase()) && /^\d+$/u.test(segments[segments.length - 3])) {
224
+ pathType = marker2;
225
+ pathAppId = segments[segments.length - 3];
226
+ pathId = menu[1];
227
+ pathMenuId = menu[2];
228
+ }
229
+ }
230
+ }
231
+ }
232
+ const lowerParams = lowerSearchParams(parsed);
233
+ const queryTypes = ["pagetype", "listkind", "viewtype"].flatMap((key) => lowerParams.get(key) || []).map((item) => item.trim().toLowerCase()).filter((item) => DIRECT_LIST_TYPES[item]);
234
+ let queryType = "";
235
+ if (queryTypes.length > 0) {
236
+ if (new Set(queryTypes.map((item) => DIRECT_LIST_TYPES[item].pageType)).size !== 1) {
237
+ throw ebuilderValidationError("url_type_conflict", "\u9875\u9762 URL \u7684\u5217\u8868\u7C7B\u578B\u53C2\u6570\u4E92\u76F8\u51B2\u7A81");
238
+ }
239
+ queryType = queryTypes[0];
240
+ }
241
+ if (pathType && queryType && DIRECT_LIST_TYPES[pathType].pageType !== DIRECT_LIST_TYPES[queryType].pageType) {
242
+ throw ebuilderValidationError("url_type_conflict", "\u9875\u9762 URL \u7684\u8DEF\u5F84\u4E0E pageType/listKind \u7C7B\u578B\u51B2\u7A81");
243
+ }
244
+ const marker = pathType || queryType;
245
+ if (!marker) throw ebuilderValidationError("url_type_missing", "\u65E0\u6CD5\u4ECE\u9875\u9762 URL \u8BC6\u522B\u5217\u8868\u7C7B\u578B\uFF1B\u9700\u8981 list/search \u6216 viewport/VIEWPORT");
246
+ const queryIds = ["pageid", "listid"].flatMap((key) => lowerParams.get(key) || []).filter(Boolean);
247
+ if (new Set(queryIds).size > 1) throw ebuilderValidationError("url_id_conflict", "\u9875\u9762 URL \u4E2D\u7684 pageId/listId \u4E92\u76F8\u51B2\u7A81");
248
+ const queryId = queryIds[0] || "";
249
+ if (pathId && queryId && pathId !== queryId) throw ebuilderValidationError("url_id_conflict", "\u9875\u9762 URL \u8DEF\u5F84 ID \u4E0E pageId/listId \u53C2\u6570\u4E0D\u4E00\u81F4");
250
+ const pageId = pathId || queryId;
251
+ if (!pageId) throw ebuilderValidationError("url_id_missing", "\u9875\u9762 URL \u7F3A\u5C11\u53EF\u8BC6\u522B\u7684 pageId/listId");
252
+ assertDecimalId(pageId, "URL pageId/listId");
253
+ const appIds = [];
254
+ if (pathAppId) appIds.push(pathAppId);
255
+ appIds.push(...lowerParams.get("appid") || []);
256
+ const appPath = /\/(?:sp\/)?ebdapp\/(?:view|detail)\/(\d+)(?:\/|$)/iu.exec(parsed.pathname);
257
+ if (appPath) appIds.push(appPath[1]);
258
+ if (new Set(appIds.filter(Boolean)).size > 1) throw ebuilderValidationError("url_app_conflict", "\u9875\u9762 URL \u4E2D\u7684 appId \u4E92\u76F8\u51B2\u7A81");
259
+ const menuIds = [];
260
+ if (pathMenuId) menuIds.push(pathMenuId);
261
+ menuIds.push(...["cusmenuid", "menuid"].flatMap((key) => lowerParams.get(key) || []));
262
+ if (new Set(menuIds.filter(Boolean)).size > 1) throw ebuilderValidationError("url_menu_conflict", "\u9875\u9762 URL \u4E2D\u7684 menuId/cusMenuId \u4E92\u76F8\u51B2\u7A81");
263
+ const type = DIRECT_LIST_TYPES[marker];
264
+ return {
265
+ origin: confirmedOrigin,
266
+ entryUrl,
267
+ pageId,
268
+ pageType: type.pageType,
269
+ listKind: type.listKind,
270
+ appId: appIds.find(Boolean) || "",
271
+ menuId: menuIds.find(Boolean) || ""
272
+ };
273
+ }
274
+ function encodeNlistCustomConfig(value) {
275
+ const source = JSON.stringify(value);
276
+ if (!source) return "";
277
+ const dictionary = /* @__PURE__ */ new Map();
278
+ const output = [];
279
+ let nextCode = 1 << 16;
280
+ let current = source[0];
281
+ function codeFor(token) {
282
+ const existing = dictionary.get(token);
283
+ if (existing !== void 0) return existing;
284
+ if (token.length !== 1) throw ebuilderValidationError("custom_config_invalid", `\u65E0\u6CD5\u7F16\u7801 customConfig \u7247\u6BB5: ${token}`);
285
+ const code = token.codePointAt(0);
286
+ dictionary.set(token, code);
287
+ return code;
288
+ }
289
+ for (const char of Array.from(source.slice(1))) {
290
+ const combined = current + char;
291
+ if (dictionary.has(combined)) {
292
+ current = combined;
293
+ continue;
294
+ }
295
+ output.push(codeFor(current));
296
+ dictionary.set(combined, nextCode);
297
+ nextCode += 1;
298
+ current = char;
299
+ }
300
+ output.push(codeFor(current));
301
+ return output.join(",");
302
+ }
303
+ function createEbuilderFormHost(ctx) {
304
+ let e10Session = null;
305
+ let sessionContext = null;
306
+ async function ensureSession() {
307
+ if (!e10Session) {
308
+ e10Session = await requireE10Session(ctx);
309
+ sessionContext = {
310
+ baseUrl: e10Session.getBaseUrl(),
311
+ profile: ctx.getGlobalOptions().profile || getActiveProfile(),
312
+ userId: e10Session.userId
313
+ };
314
+ }
315
+ return e10Session;
316
+ }
317
+ async function getSession() {
318
+ await ensureSession();
319
+ return sessionContext;
320
+ }
321
+ async function runtime() {
322
+ return createE10RequestRuntime(ctx, await ensureSession(), {});
323
+ }
324
+ async function requestJson(options2) {
325
+ assertApiPath(options2.path);
326
+ const response = await (await runtime()).requestJson({
327
+ module: "ebuilder-form",
328
+ operation: options2.operation,
329
+ method: options2.method || "POST",
330
+ path: options2.path,
331
+ query: options2.query,
332
+ body: options2.body,
333
+ form: options2.form,
334
+ formData: options2.formData,
335
+ headers: options2.headers,
336
+ bigIntStrings: options2.bigIntStrings ?? true
337
+ });
338
+ if ([302, 401, 403].includes(response.status)) {
339
+ throw ebuilderAuthError("session_expired", "E10 \u767B\u5F55\u6001\u5DF2\u5931\u6548\u6216\u5F53\u524D\u8D26\u53F7\u65E0\u6743\u8BBF\u95EE\u8BE5 eBuilder \u6570\u636E", { httpStatus: response.status });
340
+ }
341
+ if (response.parseError) {
342
+ throw ebuilderNetworkError("protocol", `\u63A5\u53E3\u8FD4\u56DE\u4E0D\u662F\u5408\u6CD5 JSON\uFF08HTTP ${response.status}\uFF09`, { retryable: false });
343
+ }
344
+ if (response.status < 200 || response.status >= 300) {
345
+ throw ebuilderBusinessError("http_error", `eBuilder \u63A5\u53E3 HTTP ${response.status}`, { code: response.status, details: { message: responseMessage(response.value) } });
346
+ }
347
+ return response.value;
348
+ }
349
+ async function resolveDeployment(appId) {
350
+ const id = assertDecimalId(appId, "appId");
351
+ const payload = await requestJson({
352
+ operation: "ebuilder-form.context.resolve",
353
+ method: "GET",
354
+ path: "/api/ebuilder/form/app/isIndependentDeploy",
355
+ query: { appId: id }
356
+ });
357
+ const data = unwrapWeaData(payload, "\u72EC\u7ACB\u90E8\u7F72\u68C0\u67E5");
358
+ if (typeof data !== "boolean") throw ebuilderBusinessError("deployment_response_invalid", "\u72EC\u7ACB\u90E8\u7F72\u68C0\u67E5 data \u4E0D\u662F\u5E03\u5C14\u503C");
359
+ return data ? `/api/ebuilder${id}` : PUBLIC_API_PREFIX;
360
+ }
361
+ async function searchMenus(keywords) {
362
+ const normalized = keywords.map((item) => item.trim()).filter(Boolean).slice(0, 5);
363
+ if (normalized.length === 0) throw ebuilderValidationError("keywords_required", "menuKeywords \u81F3\u5C11\u5305\u542B\u4E00\u4E2A\u5173\u952E\u8BCD");
364
+ const payload = await requestJson({
365
+ operation: "ebuilder-form.menu.search",
366
+ path: "/api/ebuilder/form/viewlist/searchPermittedEbMenus",
367
+ body: normalized
368
+ });
369
+ const data = unwrapWeaData(payload, "\u83DC\u5355\u641C\u7D22");
370
+ if (!Array.isArray(data)) throw ebuilderBusinessError("menu_response_invalid", "\u83DC\u5355\u641C\u7D22 data \u4E0D\u662F\u6570\u7EC4");
371
+ return data.filter((item) => Boolean(item && typeof item === "object" && !Array.isArray(item))).filter((item) => {
372
+ const type = stringValue(item.pageType).toUpperCase();
373
+ return ["SEARCH", "VIEWPORT"].includes(type) && stringValue(item.pageId) && stringValue(item.appId);
374
+ });
375
+ }
376
+ async function resolveContext(input) {
377
+ if (input.context && typeof input.context === "object" && !Array.isArray(input.context)) {
378
+ return validateContext(input.context);
379
+ }
380
+ if (input.url) return resolveUrlContext(input);
381
+ if (input.menuKeywords || input.menu || input.menuId) return resolveMenuContext(input);
382
+ return resolveDirectContext(input);
383
+ }
384
+ async function resolveMenuContext(input) {
385
+ const keywords = Array.isArray(input.menuKeywords) ? input.menuKeywords.map((item) => String(item)) : Array.isArray(input.menu) ? input.menu.map((item) => String(item)) : [String(input.menuKeywords || input.menu || "")];
386
+ const menuId = stringValue(input.menuId);
387
+ const menus = await searchMenus(keywords);
388
+ const menu = selectMenu(menus, keywords, menuId);
389
+ const appId = assertDecimalId(menu.appId, "menu.appId");
390
+ const pageId = assertDecimalId(menu.pageId, "menu.pageId");
391
+ const pageType = stringValue(menu.pageType).toUpperCase();
392
+ const apiPrefix = await resolveDeployment(appId);
393
+ const target = await resolveListTarget(apiPrefix, appId, pageId, pageType);
394
+ return validateContext({
395
+ origin: (await getSession()).baseUrl,
396
+ appId,
397
+ apiPrefix,
398
+ listId: target.listId,
399
+ hostPageId: pageType === "VIEWPORT" ? pageId : "",
400
+ listKind: pageType === "SEARCH" ? "List" : "NList",
401
+ menuId: stringValue(menu.menuId),
402
+ menuName: stringValue(menu.menuName || menu.refferName),
403
+ menuUrl: stringValue(menu.menuUrl),
404
+ objId: target.objId
405
+ });
406
+ }
407
+ async function resolveUrlContext(input) {
408
+ const target = parseDirectListUrl(input.url, (await getSession()).baseUrl);
409
+ const requestedAppId = stringValue(input.appId);
410
+ if (requestedAppId && target.appId && requestedAppId !== target.appId) {
411
+ throw ebuilderValidationError("app_conflict", "appId \u4E0E\u9875\u9762 URL \u4E2D\u7684 appId \u4E0D\u4E00\u81F4");
412
+ }
413
+ let appId = requestedAppId || target.appId;
414
+ const requestedPrefix = input.apiPrefix ? resolveApiPrefix(String(input.apiPrefix)) : "";
415
+ if (requestedPrefix && requestedPrefix !== PUBLIC_API_PREFIX) {
416
+ const prefixAppId = requestedPrefix.replace(PUBLIC_API_PREFIX, "");
417
+ if (appId && appId !== prefixAppId) throw ebuilderValidationError("api_prefix_conflict", "apiPrefix \u4E0E\u9875\u9762 URL/\u8F93\u5165 appId \u4E0D\u4E00\u81F4");
418
+ appId = prefixAppId;
419
+ }
420
+ let apiPrefix = requestedPrefix;
421
+ let listId = target.pageId;
422
+ let objId = "";
423
+ if (appId) {
424
+ apiPrefix = apiPrefix || await resolveDeployment(appId);
425
+ const resolved = await resolveListTarget(apiPrefix, appId, target.pageId, target.pageType);
426
+ listId = resolved.listId;
427
+ objId = resolved.objId;
428
+ } else if (target.pageType === "SEARCH") {
429
+ const list = await listInit(PUBLIC_API_PREFIX, target.pageId, "");
430
+ appId = list.appId;
431
+ objId = list.objId;
432
+ apiPrefix = apiPrefix || await resolveDeployment(appId);
433
+ } else {
434
+ const page = await viewPageInfo(PUBLIC_API_PREFIX, target.pageId, "ebuilder-form.context.resolve");
435
+ const parsed = parseNlistContext(page, "");
436
+ appId = parsed.appId;
437
+ listId = parsed.listId;
438
+ objId = parsed.objId;
439
+ apiPrefix = apiPrefix || await resolveDeployment(appId);
440
+ }
441
+ return validateContext({
442
+ origin: target.origin,
443
+ appId,
444
+ apiPrefix,
445
+ hostPageId: target.pageType === "VIEWPORT" ? target.pageId : "",
446
+ listId,
447
+ listKind: target.listKind,
448
+ menuId: target.menuId,
449
+ entryUrl: target.entryUrl,
450
+ objId
451
+ });
452
+ }
453
+ async function resolveDirectContext(input) {
454
+ const appId = stringValue(input.appId);
455
+ const apiPrefix = input.apiPrefix ? resolveApiPrefix(String(input.apiPrefix)) : appId ? await resolveDeployment(appId) : PUBLIC_API_PREFIX;
456
+ const context = {
457
+ origin: (await getSession()).baseUrl,
458
+ appId,
459
+ apiPrefix,
460
+ objId: stringValue(input.objId),
461
+ listId: stringValue(input.listId),
462
+ hostPageId: stringValue(input.hostPageId),
463
+ listKind: stringValue(input.listKind),
464
+ menuUrl: stringValue(input.menuUrl),
465
+ entryUrl: stringValue(input.entryUrl),
466
+ menuId: stringValue(input.menuId),
467
+ menuName: stringValue(input.menuName)
468
+ };
469
+ if (!context.objId && context.listId && context.appId && context.listKind === "List") {
470
+ const list = await listInit(context.apiPrefix, context.listId, context.appId);
471
+ context.objId = list.objId;
472
+ }
473
+ if ((!context.objId || !context.listId) && context.hostPageId && context.appId && context.listKind === "NList") {
474
+ const page = await viewPageInfo(context.apiPrefix, context.hostPageId, "ebuilder-form.context.resolve");
475
+ const parsed = parseNlistContext(page, context.appId);
476
+ context.listId = parsed.listId;
477
+ context.objId = parsed.objId;
478
+ }
479
+ return validateContext(context);
480
+ }
481
+ function validateContext(raw) {
482
+ const apiPrefix = resolveApiPrefix(stringValue(raw.apiPrefix) || PUBLIC_API_PREFIX);
483
+ const appId = stringValue(raw.appId);
484
+ if (apiPrefix !== PUBLIC_API_PREFIX) {
485
+ const prefixAppId = apiPrefix.replace(PUBLIC_API_PREFIX, "");
486
+ if (appId && prefixAppId !== appId) throw ebuilderValidationError("context_conflict", "apiPrefix \u4E2D\u7684 appId \u4E0E context.appId \u4E0D\u4E00\u81F4");
487
+ }
488
+ const objId = stringValue(raw.objId);
489
+ if (!objId) throw ebuilderValidationError("obj_id_required", "context.objId \u5FC5\u586B");
490
+ return {
491
+ origin: stringValue(raw.origin) || sessionContext?.baseUrl || "",
492
+ appId,
493
+ apiPrefix,
494
+ objId: assertDecimalId(objId, "objId"),
495
+ listId: optionalDecimalId(raw.listId, "listId"),
496
+ hostPageId: optionalDecimalId(raw.hostPageId, "hostPageId"),
497
+ listKind: normalizeListKind(raw.listKind),
498
+ menuId: optionalDecimalId(raw.menuId, "menuId"),
499
+ menuName: stringValue(raw.menuName),
500
+ menuUrl: stringValue(raw.menuUrl),
501
+ entryUrl: stringValue(raw.entryUrl)
502
+ };
503
+ }
504
+ async function resolveListTarget(apiPrefix, appId, pageId, pageType) {
505
+ if (pageType === "SEARCH") {
506
+ const list = await listInit(apiPrefix, pageId, appId);
507
+ return { listId: pageId, objId: list.objId };
508
+ }
509
+ if (pageType !== "VIEWPORT") throw ebuilderValidationError("page_type_invalid", `\u4E0D\u652F\u6301\u7684 pageType: ${pageType}`);
510
+ const page = await viewPageInfo(apiPrefix, pageId, "ebuilder-form.context.resolve");
511
+ const parsed = parseNlistContext(page, appId);
512
+ return { listId: parsed.listId, objId: parsed.objId };
513
+ }
514
+ async function listInit(apiPrefix, listId, expectedAppId) {
515
+ const payload = await requestJson({
516
+ operation: "ebuilder-form.context.resolve",
517
+ path: routeEbuilderPath(apiPrefix, "/form/list/listInit"),
518
+ body: { listId }
519
+ });
520
+ const data = unwrapWeaData(payload, "\u8868\u683C\u4E0A\u4E0B\u6587");
521
+ const recordData = record(data);
522
+ const appId = stringValue(recordData.appId);
523
+ if (expectedAppId && appId && appId !== expectedAppId) throw ebuilderValidationError("app_conflict", "\u8868\u683C\u4E0A\u4E0B\u6587 appId \u4E0E\u5DF2\u786E\u8BA4 appId \u4E0D\u4E00\u81F4");
524
+ const objId = stringValue(recordData.objid || recordData.objId);
525
+ if (!objId) throw ebuilderBusinessError("list_context_invalid", "\u8868\u683C\u4E0A\u4E0B\u6587\u7F3A\u5C11 objId");
526
+ return { appId: appId || expectedAppId, objId, data: recordData };
527
+ }
528
+ async function viewPageInfo(apiPrefix, pageId, operation) {
529
+ return requestJson({
530
+ operation,
531
+ method: "GET",
532
+ path: routeEbuilderPath(apiPrefix, "/form/viewdesigner/viewPageInfo"),
533
+ query: { pageId, terminalType: "PC", entranceType: "RUN", runType: "" }
534
+ });
535
+ }
536
+ function parseNlistContext(payload, expectedAppId) {
537
+ unwrapWeaData(payload, "\u6570\u636E\u5217\u8868\u4E0A\u4E0B\u6587");
538
+ const page = unwrapPage(payload);
539
+ const { component, config } = selectPrimaryNlistComponent(page);
540
+ const appId = stringValue(page.appId || page.appid);
541
+ if (expectedAppId && appId && appId !== expectedAppId) throw ebuilderValidationError("app_conflict", "\u6570\u636E\u5217\u8868\u4E0A\u4E0B\u6587 appId \u4E0E\u5DF2\u786E\u8BA4 appId \u4E0D\u4E00\u81F4");
542
+ const listId = stringValue(config.ebListId);
543
+ const objId = stringValue(config.objId);
544
+ if (!listId || !objId) throw ebuilderBusinessError("nlist_context_invalid", "data.page.comps[1].config \u7F3A\u5C11 ebListId \u6216 objId");
545
+ return { appId: appId || expectedAppId, listId, objId, page, component, config };
546
+ }
547
+ async function formViews(input) {
548
+ const context = await resolveContext(input);
549
+ const payload = await requestJson({
550
+ operation: "ebuilder-form.views.list",
551
+ method: "GET",
552
+ path: routeEbuilderPath(context.apiPrefix, `/form/viewlist/getViewlist/${context.objId}`),
553
+ query: { objId: context.objId }
554
+ });
555
+ const data = unwrapWeaData(payload, "\u8868\u5355\u89C6\u56FE");
556
+ const views = Array.isArray(data) ? data : [];
557
+ return {
558
+ context,
559
+ views: views.filter((item) => {
560
+ const type = stringValue(item?.viewType || item?.type || item?.pageType).toLowerCase();
561
+ return type === "list" || type === "nlist";
562
+ }),
563
+ raw: data
564
+ };
565
+ }
566
+ async function listConfig(context, operation) {
567
+ if (!context.listId) throw ebuilderValidationError("list_id_required", "List \u914D\u7F6E\u9700\u8981 listId");
568
+ const list = await listInit(context.apiPrefix, context.listId, context.appId);
569
+ const common = { apid: context.appId || list.appId, tpaid: context.listId, objId: context.objId };
570
+ const conditionId = stringValue(list.data.conditionId);
571
+ const [baseInfo, listFields, order, search, statistics, condition] = await Promise.all([
572
+ requestJson({ operation, method: "GET", path: routeEbuilderPath(context.apiPrefix, `/form/list/getBaseInfo/${context.listId}`), query: common }),
573
+ requestJson({ operation, method: "GET", path: routeEbuilderPath(context.apiPrefix, `/form/list/getListFields/${context.listId}`), query: { ...common, clientType: "PC", isVirtualForm: "false" } }),
574
+ requestJson({ operation, method: "GET", path: routeEbuilderPath(context.apiPrefix, "/form/viewlist/getViewOrder"), query: { ...common, viewType: "tableView", viewId: context.listId, isVirtualForm: "false" } }),
575
+ requestJson({ operation, method: "GET", path: routeEbuilderPath(context.apiPrefix, `/form/listFilter/getSearchFilters/${context.listId}`), query: { ...common, viewType: "tableView", isVirtualForm: "false" } }),
576
+ requestJson({ operation, method: "GET", path: routeEbuilderPath(context.apiPrefix, `/form/listStatistics/getStatisticsList/${context.listId}`), query: { ...common, isVirtualForm: "false" } }),
577
+ conditionId ? requestJson({ operation, method: "GET", path: routeEbuilderPath(context.apiPrefix, "/form/plugin/conditionEditor/getById"), query: { ...common, id: conditionId, type: "search" } }) : Promise.resolve(null)
578
+ ]);
579
+ return {
580
+ context,
581
+ init: list.data,
582
+ config: {
583
+ basicSettings: dataOrRaw(baseInfo),
584
+ displayColumns: dataOrRaw(listFields),
585
+ sorting: dataOrRaw(order),
586
+ search: dataOrRaw(search),
587
+ statistics: dataOrRaw(statistics),
588
+ conditions: condition ? { configured: Boolean(dataOrRaw(condition)), rootData: dataOrRaw(condition) } : { configured: false }
589
+ }
590
+ };
591
+ }
592
+ async function nlistConfig(context, operation) {
593
+ if (!context.hostPageId) throw ebuilderValidationError("host_page_id_required", "NList \u914D\u7F6E\u9700\u8981 hostPageId");
594
+ const payload = await viewPageInfo(context.apiPrefix, context.hostPageId, operation);
595
+ const parsed = parseNlistContext(payload, context.appId);
596
+ return {
597
+ context: { ...context, listId: parsed.listId, objId: parsed.objId },
598
+ page: parsed.page,
599
+ component: parsed.component,
600
+ config: parsed.config
601
+ };
602
+ }
603
+ async function listQuery(input, operation) {
604
+ const context = await resolveContext({ ...input, listKind: input.listKind || input.context?.listKind || "List" });
605
+ if (!context.listId) throw ebuilderValidationError("list_id_required", "List \u5206\u9875\u67E5\u8BE2\u9700\u8981 listId");
606
+ const list = await listInit(context.apiPrefix, context.listId, context.appId);
607
+ const pageNo = positiveInt(input.pageNo, "pageNo", 1);
608
+ const configuredSize = positiveInt(list.data.pageSize, "listInit.pageSize", 20, 200);
609
+ const pageSize = pageSizeInt(input.pageSize, configuredSize, 200);
610
+ const allPages = input.allPages === true;
611
+ const tableuid = stringValue(input.tableuid) || randomUUID().replace(/-/gu, "");
612
+ const searchParamData = nonEmptyRecord(input.searchParamData) || { searchType: "2", type: "and", groupFields: {} };
613
+ const filterCondition = nonEmptyRecord(input.filterCondition) || {};
614
+ const passid = stringValue(input.passid) || context.objId;
615
+ const cid = stringValue(input.cid) || context.objId;
616
+ const body = {
617
+ current: pageNo,
618
+ pageSize,
619
+ requiredMatch: 1,
620
+ tableuid,
621
+ listId: context.listId,
622
+ searchParamData,
623
+ isFollow: 0,
624
+ isShareToMe: 0,
625
+ filterCondition,
626
+ terminal: "PC",
627
+ ...Array.isArray(input.orderParams) ? { orderParams: input.orderParams } : {}
628
+ };
629
+ const query = { passid, cid };
630
+ const firstPage = await requestJson({ operation, path: routeEbuilderPath(context.apiPrefix, "/form/list/getListDatas"), query, body });
631
+ const totalPayload = await requestJson({ operation, path: routeEbuilderPath(context.apiPrefix, "/form/list/getListDataCount"), query, body });
632
+ const total = extractListTotal(totalPayload);
633
+ const pageCount = Math.ceil(total / pageSize);
634
+ if (allPages && pageCount >= 100) {
635
+ throw ebuilderValidationError("too_many_pages", "\u9884\u8BA1\u9700\u8981 100 \u9875\u6216\u66F4\u591A\uFF0C\u8BF7\u589E\u52A0\u7B5B\u9009\u6761\u4EF6\u6216\u7F29\u5C0F\u8303\u56F4", { total, pageSize, pageCount });
636
+ }
637
+ const pages = [listPageResult(pageNo, firstPage)];
638
+ if (allPages) {
639
+ for (let next = 1; next <= pageCount; next += 1) {
640
+ if (next === pageNo) continue;
641
+ const page = await requestJson({
642
+ operation,
643
+ path: routeEbuilderPath(context.apiPrefix, "/form/list/getListDatas"),
644
+ query,
645
+ body: { ...body, current: next }
646
+ });
647
+ pages.push(listPageResult(next, page));
648
+ }
649
+ pages.sort((a, b) => a.pageNo - b.pageNo);
650
+ }
651
+ const rows = pages.flatMap((page) => page.rows);
652
+ return {
653
+ context,
654
+ listUrl: buildListUrl(context),
655
+ tableuid,
656
+ columns: pages[0]?.columns || [],
657
+ pages,
658
+ rows,
659
+ pagination: {
660
+ mainRecordTotal: total,
661
+ mainPageCount: pageCount,
662
+ returnedRowCount: rows.length,
663
+ distinctStableIdCount: new Set(rows.map(stableRowId).filter(Boolean)).size
664
+ }
665
+ };
666
+ }
667
+ async function nlistQuery(input, operation) {
668
+ const context = await resolveContext({ ...input, listKind: input.listKind || input.context?.listKind || "NList" });
669
+ if (!context.hostPageId) throw ebuilderValidationError("host_page_id_required", "NList \u5206\u9875\u67E5\u8BE2\u9700\u8981 hostPageId");
670
+ const configResult = await nlistConfig(context, operation);
671
+ const page = record(configResult.page);
672
+ const component = record(configResult.component);
673
+ const config = record(configResult.config);
674
+ const compId = stringValue(input.compId) || stringValue(component.id || component.compId);
675
+ if (!compId) throw ebuilderBusinessError("nlist_context_invalid", "NList \u7EC4\u4EF6\u7F3A\u5C11 compId");
676
+ const pageSize = pageSizeInt(input.pageSize, Number(config.pageSize || config.detailPageSize || 10), 200);
677
+ const pageNo = positiveInt(input.pageNo, "pageNo", 1);
678
+ const tableuid = stringValue(input.tableuid) || randomUUID().replace(/-/gu, "");
679
+ const filter = input.filter === void 0 ? [baseNlistFilter(compId)] : input.filter;
680
+ const fieldFilter = input.fieldFilter === void 0 ? {} : input.fieldFilter;
681
+ const pageFilter = input.pageFilter === void 0 ? { filter: {}, filterIsNull: true, esbFilter: [] } : input.pageFilter;
682
+ const customConfig = nonEmptyRecord(input.customConfig) || { superiorField: { enable: false } };
683
+ const refPluginPackageId = stringValue(input.refPluginPackageId || config.refPluginPackageId || component.refPluginPackageId) || "933846626099339271";
684
+ const pageAppId = stringValue(page.appId || page.appid || context.appId);
685
+ const commonFields = {
686
+ pageAppId,
687
+ pageId: context.hostPageId,
688
+ compId,
689
+ pageSize,
690
+ tableuid,
691
+ filter: JSON.stringify(filter),
692
+ fieldFilter: JSON.stringify(fieldFilter),
693
+ pageFilter: JSON.stringify(pageFilter),
694
+ refPluginPackageId,
695
+ customConfig: encodeNlistCustomConfig(customConfig)
696
+ };
697
+ const firstPage = await requestJson({
698
+ operation,
699
+ path: routeEbuilderPath(context.apiPrefix, "/form/eblist/getData"),
700
+ form: new URLSearchParams({ ...stringifyForm(commonFields), pageNo: String(pageNo) })
701
+ });
702
+ const totalPayload = await requestJson({
703
+ operation,
704
+ path: routeEbuilderPath(context.apiPrefix, "/form/eblist/getCount"),
705
+ query: { passid: context.objId },
706
+ form: new URLSearchParams({ tableuid, pageId: context.hostPageId, compId, refPluginPackageId })
707
+ });
708
+ const total = extractNlistTotal(totalPayload);
709
+ const pageCount = Math.ceil(total / pageSize);
710
+ if (input.allPages === true && pageCount >= 100) {
711
+ throw ebuilderValidationError("too_many_pages", "\u9884\u8BA1\u9700\u8981 100 \u9875\u6216\u66F4\u591A\uFF0C\u8BF7\u589E\u52A0\u7B5B\u9009\u6761\u4EF6\u6216\u7F29\u5C0F\u8303\u56F4", { total, pageSize, pageCount });
712
+ }
713
+ const pages = [nlistPageResult(pageNo, firstPage)];
714
+ if (input.allPages === true) {
715
+ for (let next = 1; next <= pageCount; next += 1) {
716
+ if (next === pageNo) continue;
717
+ const pagePayload = await requestJson({
718
+ operation,
719
+ path: routeEbuilderPath(context.apiPrefix, "/form/eblist/getData"),
720
+ form: new URLSearchParams({ ...stringifyForm(commonFields), pageNo: String(next) })
721
+ });
722
+ pages.push(nlistPageResult(next, pagePayload));
723
+ }
724
+ pages.sort((a, b) => a.pageNo - b.pageNo);
725
+ }
726
+ const rows = pages.flatMap((pageItem) => pageItem.rows);
727
+ return {
728
+ context: { ...context, listId: stringValue(config.ebListId), objId: stringValue(config.objId) },
729
+ listUrl: buildListUrl(context),
730
+ tableuid,
731
+ pages,
732
+ rows,
733
+ pagination: {
734
+ mainRecordTotal: total,
735
+ mainPageCount: pageCount,
736
+ returnedRowCount: rows.length,
737
+ distinctStableIdCount: new Set(rows.map(stableRowId).filter(Boolean)).size
738
+ }
739
+ };
740
+ }
741
+ async function fields(input, operation) {
742
+ const context = await resolveContext(input);
743
+ const form = new FormData();
744
+ form.set("groupId", stringValue(input.groupId) || context.appId);
745
+ form.set("sourceId", stringValue(input.sourceId) || context.objId);
746
+ form.set("sourceType", stringValue(input.sourceType) || "FORM");
747
+ form.set("detailFieldsGroup", String(input.detailFieldsGroup ?? "true"));
748
+ form.set("enableMerge", String(input.enableMerge ?? "true"));
749
+ form.set("customParam", typeof input.customParam === "string" ? input.customParam : JSON.stringify(input.customParam ?? { terminal: "" }));
750
+ form.set("params", typeof input.params === "string" ? input.params : JSON.stringify(input.params ?? []));
751
+ return requestJson({
752
+ operation,
753
+ path: routeEbuilderPath(context.apiPrefix, "/common/ds/fields"),
754
+ formData: form,
755
+ bigIntStrings: true
756
+ });
757
+ }
758
+ async function options(input, operation) {
759
+ const context = await resolveContext(input);
760
+ return requestJson({
761
+ operation,
762
+ method: "GET",
763
+ path: routeEbuilderPath(context.apiPrefix, "/common/ds/options"),
764
+ query: {
765
+ fieldName: assertDecimalId(input.fieldName || input.fieldId, "fieldName"),
766
+ objId: stringValue(input.objId) || context.objId,
767
+ sourceType: stringValue(input.sourceType) || "FORM",
768
+ groupId: stringValue(input.groupId) || context.appId,
769
+ optionLevel: input.optionLevel ?? "1"
770
+ }
771
+ });
772
+ }
773
+ async function mapping(input, operation) {
774
+ const context = await resolveContext(input);
775
+ return requestJson({
776
+ operation,
777
+ method: "GET",
778
+ path: routeEbuilderPath(context.apiPrefix, "/form/dataset/v1/getTableMapping"),
779
+ query: { objId: context.objId, reverse: input.reverse === true ? "true" : "false" }
780
+ });
781
+ }
782
+ async function browserResolve(input, operation) {
783
+ const moduleName = cleanPathSegment(input.module, "module");
784
+ const browserType = cleanPathSegment(input.browserType, "browserType");
785
+ const query = stringValue(input.query);
786
+ if (!query) throw ebuilderValidationError("query_required", "query \u5FC5\u586B");
787
+ const payload = {
788
+ browserMultiple: input.multiple === true,
789
+ keyword: query,
790
+ pageNo: 1,
791
+ pageSize: input.limit ? Math.min(Number(input.limit), 50) : 20,
792
+ ...input.extra && typeof input.extra === "object" && !Array.isArray(input.extra) ? input.extra : {}
793
+ };
794
+ const result = await requestJson({
795
+ operation,
796
+ path: `/api/${moduleName}/common/browser/complete/${browserType}`,
797
+ body: payload,
798
+ headers: { langtype: "zh_CN" }
799
+ });
800
+ const matches = normalizeBrowserMatches(result, Number(input.limit || 20));
801
+ const exact = matches.filter((item) => stringValue(item.name).toLowerCase() === query.toLowerCase());
802
+ const selected = exact.length > 0 ? exact : matches;
803
+ return {
804
+ query,
805
+ browser: { module: moduleName, type: browserType },
806
+ matchCount: selected.length,
807
+ unique: selected.length === 1,
808
+ ambiguous: selected.length > 1,
809
+ matches: selected
810
+ };
811
+ }
812
+ async function openapiRead(endpoint, input, operation) {
813
+ const context = await resolveContext(input);
814
+ const datajson = openapiReadDatajson(endpoint, context.objId, input);
815
+ const payload = await requestJson({
816
+ operation,
817
+ path: routeEbuilderPath(context.apiPrefix, OPENAPI_READ_PATHS[endpoint]),
818
+ body: { datajson }
819
+ });
820
+ return { context, result: parseOpenapiPayload(payload, endpoint) };
821
+ }
822
+ async function openapiWrite(endpoint, datajson, operation) {
823
+ const context = await resolveContext(datajson.__context && typeof datajson.__context === "object" ? { context: datajson.__context } : datajson);
824
+ const payload = stripInternalKeys(datajson);
825
+ const result = await requestJson({
826
+ operation,
827
+ path: routeEbuilderPath(context.apiPrefix, OPENAPI_WRITE_PATHS[endpoint]),
828
+ body: { datajson: payload }
829
+ });
830
+ return { context, result: parseOpenapiPayload(result, endpoint) };
831
+ }
832
+ async function customRead(endpoint, input, operation) {
833
+ const context = await resolveContext(input);
834
+ const interfacePk = stringValue(input.interfacePk);
835
+ if (!interfacePk) throw ebuilderValidationError("interface_pk_required", "interfacePk \u5FC5\u586B");
836
+ const datajson = customReadDatajson(endpoint, input, (await getSession()).userId);
837
+ const payload = await requestJson({
838
+ operation,
839
+ path: `${routeEbuilderPath(context.apiPrefix, CUSTOM_READ_PATHS[endpoint])}/${encodeURIComponent(interfacePk)}`,
840
+ body: { datajson }
841
+ });
842
+ return { context, result: parseCustomPayload(payload, endpoint) };
843
+ }
844
+ async function customWrite(endpoint, interfacePk, datajson, operation) {
845
+ const context = await resolveContext(datajson.__context && typeof datajson.__context === "object" ? { context: datajson.__context } : datajson);
846
+ const payload = stripInternalKeys(datajson);
847
+ const actualInterfacePk = stringValue(interfacePk || datajson.interfacePk);
848
+ if (!actualInterfacePk) throw ebuilderValidationError("interface_pk_required", "interfacePk \u5FC5\u586B");
849
+ const result = await requestJson({
850
+ operation,
851
+ path: `${routeEbuilderPath(context.apiPrefix, CUSTOM_WRITE_PATHS[endpoint])}/${encodeURIComponent(actualInterfacePk)}`,
852
+ body: { datajson: payload }
853
+ });
854
+ return { context, result: parseCustomPayload(result, endpoint) };
855
+ }
856
+ function buildDataUrl(context, dataId, deleted = false) {
857
+ const base = `${(sessionContext?.baseUrl || context.origin).replace(/\/+$/u, "")}/sp/ebdfpage/card/0/${context.objId}/${dataId}`;
858
+ return deleted ? `${base}?fromRecycle=1` : base;
859
+ }
860
+ function buildListUrl(context) {
861
+ const origin = (sessionContext?.baseUrl || context.origin).replace(/\/+$/u, "");
862
+ if (context.entryUrl) {
863
+ try {
864
+ return parseDirectListUrl(context.entryUrl, origin).entryUrl;
865
+ } catch {
866
+ return context.entryUrl;
867
+ }
868
+ }
869
+ if (context.menuUrl) {
870
+ try {
871
+ const parsed = new URL(context.menuUrl, origin);
872
+ if (parsed.origin === origin) return parsed.href;
873
+ } catch {
874
+ if (context.menuUrl.startsWith("/") && !context.menuUrl.startsWith("//")) return origin + context.menuUrl;
875
+ }
876
+ }
877
+ if (!context.listId || !context.listKind) return null;
878
+ return context.listKind === "NList" ? `${origin}/sp/ebdfpage/viewport/${context.listId}` : `${origin}/sp/ebdfpage/list/${context.listId}`;
879
+ }
880
+ return {
881
+ getSession,
882
+ requestJson,
883
+ resolveDeployment,
884
+ searchMenus,
885
+ resolveContext,
886
+ formViews,
887
+ listConfig,
888
+ nlistConfig,
889
+ listQuery,
890
+ nlistQuery,
891
+ fields,
892
+ options,
893
+ mapping,
894
+ browserResolve,
895
+ openapiRead,
896
+ openapiWrite,
897
+ customRead,
898
+ customWrite,
899
+ buildDataUrl,
900
+ buildListUrl
901
+ };
902
+ }
903
+ function originOnly(raw) {
904
+ const url = new URL(raw);
905
+ if (!["http:", "https:"].includes(url.protocol) || !url.host || url.username || url.password) {
906
+ throw ebuilderValidationError("origin_invalid", "E10 origin \u5FC5\u987B\u662F\u5B8C\u6574 http/https \u5730\u5740\uFF0C\u4E14\u4E0D\u80FD\u5305\u542B\u7528\u6237\u4FE1\u606F");
907
+ }
908
+ return `${url.protocol}//${url.host}`;
909
+ }
910
+ function originFromUrl(raw) {
911
+ if (!/^https?:/iu.test(raw)) return "";
912
+ return originOnly(raw);
913
+ }
914
+ function parseUrl(raw, base) {
915
+ try {
916
+ return /^https?:/iu.test(raw) ? new URL(raw) : new URL(raw, base);
917
+ } catch {
918
+ throw ebuilderValidationError("url_invalid", "\u9875\u9762 URL \u683C\u5F0F\u4E0D\u5408\u6CD5");
919
+ }
920
+ }
921
+ function lowerSearchParams(url) {
922
+ const map = /* @__PURE__ */ new Map();
923
+ for (const [key, value] of url.searchParams.entries()) {
924
+ const lower = key.toLowerCase();
925
+ const list = map.get(lower) || [];
926
+ list.push(value);
927
+ map.set(lower, list);
928
+ }
929
+ return map;
930
+ }
931
+ function assertApiPath(path) {
932
+ if (!path.startsWith("/api/") || path.startsWith("//") || path.includes("/../") || /^https?:/iu.test(path)) {
933
+ throw ebuilderValidationError("path_invalid", "E10 API \u53EA\u80FD\u8C03\u7528 /api/ \u540C\u6E90\u76F8\u5BF9\u8DEF\u5F84");
934
+ }
935
+ if (path.startsWith("/api/bs/")) {
936
+ throw ebuilderValidationError("path_forbidden", "eBuilder \u8868\u5355\u6A21\u5757\u7981\u6B62\u8C03\u7528 /api/bs/ \u63A5\u53E3");
937
+ }
938
+ }
939
+ function assertDecimalId(value, field) {
940
+ const text = stringValue(value);
941
+ if (!/^\d+$/u.test(text)) throw ebuilderValidationError("field_invalid", `${field} \u5FC5\u987B\u662F\u6570\u5B57 ID \u5B57\u7B26\u4E32`);
942
+ return text;
943
+ }
944
+ function optionalDecimalId(value, field) {
945
+ const text = stringValue(value);
946
+ if (!text) return void 0;
947
+ return assertDecimalId(text, field);
948
+ }
949
+ function stringValue(value) {
950
+ if (value === void 0 || value === null) return "";
951
+ if (typeof value === "object") return "";
952
+ return String(value).trim();
953
+ }
954
+ function normalizeListKind(value) {
955
+ const text = stringValue(value).toLowerCase();
956
+ if (!text) return "";
957
+ if (text === "list") return "List";
958
+ if (text === "nlist") return "NList";
959
+ throw ebuilderValidationError("list_kind_invalid", "listKind \u53EA\u80FD\u662F List \u6216 NList");
960
+ }
961
+ function record(value) {
962
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
963
+ }
964
+ function nonEmptyRecord(value) {
965
+ const next = record(value);
966
+ return Object.keys(next).length > 0 ? next : void 0;
967
+ }
968
+ function responseMessage(payload) {
969
+ const root = record(payload);
970
+ const message = record(root.message);
971
+ const datajson = record(record(root.data).datajson);
972
+ for (const value of [root.msg, root.message, message.msg, message.message, datajson.message, datajson.msg]) {
973
+ if (typeof value === "string" && value.trim()) return value.trim().slice(0, 500);
974
+ }
975
+ return "";
976
+ }
977
+ function isSuccessCode(value) {
978
+ if (value === void 0 || value === null) return true;
979
+ if (value === true || value === 0 || value === 200) return true;
980
+ return SUCCESS_CODES.has(String(value).trim().toLowerCase());
981
+ }
982
+ function unwrapWeaData(payload, label) {
983
+ const root = record(payload);
984
+ const message = record(root.message);
985
+ const code = root.code ?? message.code;
986
+ if (!isSuccessCode(code)) {
987
+ throw ebuilderBusinessError("business_error", `${label} \u4E1A\u52A1\u5931\u8D25\uFF1A${responseMessage(payload) || String(code)}`, { code: String(code), details: { result: payload } });
988
+ }
989
+ if (root.status === false || root.fail === true) {
990
+ throw ebuilderBusinessError("business_error", `${label} \u4E1A\u52A1\u5931\u8D25\uFF1A${responseMessage(payload) || "status=false"}`, { details: { result: payload } });
991
+ }
992
+ if (!("data" in root)) throw ebuilderBusinessError("response_invalid", `${label} \u54CD\u5E94\u7F3A\u5C11 data`, { details: { result: payload } });
993
+ return root.data;
994
+ }
995
+ function dataOrRaw(payload) {
996
+ try {
997
+ return unwrapWeaData(payload, "\u914D\u7F6E");
998
+ } catch {
999
+ return payload;
1000
+ }
1001
+ }
1002
+ function selectMenu(menus, keywords, menuId) {
1003
+ if (menuId) {
1004
+ const matches = menus.filter((menu) => stringValue(menu.menuId) === menuId);
1005
+ if (matches.length !== 1) throw ebuilderValidationError("menu_not_unique", `menuId=${menuId} \u672A\u552F\u4E00\u547D\u4E2D eBuilder \u83DC\u5355`, { candidates: menus.slice(0, 20).map(menuSummary) });
1006
+ return matches[0];
1007
+ }
1008
+ const scored = menus.map((menu) => ({ menu, score: menuScore(menu, keywords) })).filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
1009
+ if (scored.length === 0) throw ebuilderValidationError("menu_not_found", "\u6CA1\u6709\u627E\u5230\u5408\u9002\u7684\u8868\u683C\u6216\u6570\u636E\u5217\u8868\u83DC\u5355", { candidates: menus.slice(0, 20).map(menuSummary) });
1010
+ const best = scored[0].score;
1011
+ const winners = scored.filter((item) => item.score === best);
1012
+ if (winners.length !== 1) {
1013
+ throw ebuilderValidationError("menu_ambiguous", "\u83DC\u5355\u641C\u7D22\u7ED3\u679C\u4E0D\u552F\u4E00\uFF0C\u8BF7\u4F20 menuId \u6D88\u6B67", { candidates: winners.slice(0, 20).map((item) => menuSummary(item.menu)) });
1014
+ }
1015
+ return winners[0].menu;
1016
+ }
1017
+ function menuScore(menu, keywords) {
1018
+ const labels = [menu.menuName, menu.refferName, menu.menuUrl, menu.pageType].map((item) => stringValue(item).toLowerCase()).filter(Boolean);
1019
+ return keywords.reduce((score, keyword) => {
1020
+ const needle = keyword.toLowerCase();
1021
+ if (!needle) return score;
1022
+ if (labels.some((label) => label === needle)) return score + 4;
1023
+ if (labels.some((label) => label.includes(needle))) return score + 2;
1024
+ return score;
1025
+ }, 0);
1026
+ }
1027
+ function menuSummary(menu) {
1028
+ return {
1029
+ menuId: stringValue(menu.menuId),
1030
+ menuName: stringValue(menu.menuName),
1031
+ refferName: stringValue(menu.refferName),
1032
+ pageType: stringValue(menu.pageType),
1033
+ pageId: stringValue(menu.pageId),
1034
+ appId: stringValue(menu.appId)
1035
+ };
1036
+ }
1037
+ function unwrapPage(payload) {
1038
+ let current = unwrapWeaData(payload, "\u9875\u9762\u914D\u7F6E");
1039
+ for (let index = 0; index < 4; index += 1) {
1040
+ const rec = record(current);
1041
+ if (rec.page && typeof rec.page === "object") return record(rec.page);
1042
+ if (!rec.data || typeof rec.data !== "object") break;
1043
+ current = rec.data;
1044
+ }
1045
+ throw ebuilderBusinessError("page_response_invalid", "viewPageInfo \u54CD\u5E94\u7F3A\u5C11 data.page");
1046
+ }
1047
+ function selectPrimaryNlistComponent(page) {
1048
+ const comps = Array.isArray(page.comps) ? page.comps : [];
1049
+ const component = record(comps[1]);
1050
+ if (!Object.keys(component).length) throw ebuilderBusinessError("nlist_component_missing", "data.page.comps[1] \u7F3A\u5931");
1051
+ let config = component.config;
1052
+ if (typeof config === "string") {
1053
+ try {
1054
+ config = JSON.parse(config);
1055
+ } catch {
1056
+ throw ebuilderBusinessError("nlist_config_invalid", "data.page.comps[1].config \u4E0D\u662F\u5408\u6CD5 JSON");
1057
+ }
1058
+ }
1059
+ const recordConfig = record(config);
1060
+ if (!Object.keys(recordConfig).length) throw ebuilderBusinessError("nlist_config_missing", "data.page.comps[1].config \u7F3A\u5931");
1061
+ return { component, config: recordConfig };
1062
+ }
1063
+ function positiveInt(value, field, fallback, max) {
1064
+ const raw = value === void 0 || value === null || value === "" ? fallback : value;
1065
+ const numeric = Number(raw);
1066
+ if (!Number.isInteger(numeric) || numeric < 1) throw ebuilderValidationError("field_invalid", `${field} \u5FC5\u987B\u662F\u6B63\u6574\u6570`);
1067
+ if (max !== void 0 && numeric > max) return max;
1068
+ return numeric;
1069
+ }
1070
+ function pageSizeInt(value, fallback, max) {
1071
+ const numeric = positiveInt(value, "pageSize", fallback || 10);
1072
+ if (numeric > max) throw ebuilderValidationError("page_size_too_large", `pageSize \u6700\u5927\u4E3A ${max}`);
1073
+ return numeric;
1074
+ }
1075
+ function extractListTotal(payload) {
1076
+ const data = record(unwrapWeaData(payload, "List \u603B\u6570"));
1077
+ const value = data.total ?? record(data.data).total;
1078
+ const total = Number(value);
1079
+ if (!Number.isInteger(total) || total < 0) throw ebuilderBusinessError("count_invalid", "getListDataCount.data.total \u4E0D\u662F\u6574\u6570");
1080
+ return total;
1081
+ }
1082
+ function listPageResult(pageNo, payload) {
1083
+ const data = record(unwrapWeaData(payload, "List \u5206\u9875"));
1084
+ const displayData = data.displayData;
1085
+ if (Array.isArray(displayData)) return { pageNo, rows: displayData, columns: Array.isArray(data.columns) ? data.columns : [] };
1086
+ if (displayData && typeof displayData === "object") return { pageNo, rows: [], columns: Array.isArray(data.columns) ? data.columns : [], groupedDisplayData: displayData };
1087
+ return { pageNo, rows: [], columns: Array.isArray(data.columns) ? data.columns : [] };
1088
+ }
1089
+ function extractNlistTotal(payload) {
1090
+ const data = record(unwrapWeaData(payload, "NList \u603B\u6570"));
1091
+ const total = Number(data.total);
1092
+ if (!Number.isInteger(total) || total < 0) throw ebuilderBusinessError("count_invalid", "getCount.data.total \u4E0D\u662F\u6574\u6570");
1093
+ return total;
1094
+ }
1095
+ function nlistPageResult(pageNo, payload) {
1096
+ const data = record(unwrapWeaData(payload, "NList \u5206\u9875"));
1097
+ if (!Array.isArray(data.list)) throw ebuilderBusinessError("rows_invalid", "getData.data.list \u4E0D\u662F\u6570\u7EC4");
1098
+ return { pageNo, rows: data.list };
1099
+ }
1100
+ function stableRowId(row) {
1101
+ const rec = record(row);
1102
+ return stringValue(rec.id || rec.form_data_id || rec.ebrecord_rowkey || rec.rowKey);
1103
+ }
1104
+ function baseNlistFilter(compId) {
1105
+ return {
1106
+ conditionComId: `${compId}_filter_EXCLUDECACHE`,
1107
+ conditionType: "and",
1108
+ dataType: "classification",
1109
+ id: randomUUID().replace(/-/gu, ""),
1110
+ useConfig: true
1111
+ };
1112
+ }
1113
+ function stringifyForm(value) {
1114
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, item === void 0 || item === null ? "" : String(item)]));
1115
+ }
1116
+ function normalizeBrowserMatches(payload, limit) {
1117
+ const root = record(payload);
1118
+ const candidates = [
1119
+ root.data,
1120
+ record(root.data).data,
1121
+ record(root.data).list,
1122
+ record(root.result).data,
1123
+ root.result
1124
+ ];
1125
+ const rows = candidates.find(Array.isArray);
1126
+ if (!rows) return [];
1127
+ return rows.filter((item) => Boolean(item && typeof item === "object" && !Array.isArray(item))).slice(0, limit).map((item) => {
1128
+ const id = stringValue(item.id || item.optionId || item.key || item.value);
1129
+ const name = stringValue(item.name || item.content || item.title || item.label);
1130
+ return {
1131
+ id,
1132
+ name,
1133
+ dataOption: { optionId: id, content: name },
1134
+ details: {
1135
+ no: stringValue(item.no || item.code || item.workCode),
1136
+ department: stringValue(item.department || item.departmentName || item.orgName),
1137
+ path: stringValue(item.path || item.fullName || item.fullPath)
1138
+ }
1139
+ };
1140
+ }).filter((item) => item.id || item.name);
1141
+ }
1142
+ function openapiReadDatajson(endpoint, objId, input) {
1143
+ if (endpoint === "detail") {
1144
+ return {
1145
+ header: { objId },
1146
+ mainTable: { id: assertDecimalId(input.dataId || record(input.mainTable).id, "dataId") },
1147
+ operationinfo: {
1148
+ isReturnDetail: input.isReturnDetail ?? "y",
1149
+ fieldNoFindIgnore: input.fieldNoFindIgnore ?? "false"
1150
+ }
1151
+ };
1152
+ }
1153
+ if (endpoint === "query") {
1154
+ return {
1155
+ header: { objId },
1156
+ mainTable: record(input.mainTable),
1157
+ pageInfo: {
1158
+ pageNo: positiveInt(input.pageNo, "pageNo", 1, 1e3),
1159
+ pageSize: pageSizeInt(input.pageSize, 10, 1e3)
1160
+ },
1161
+ operationinfo: {
1162
+ isReturnDetail: input.isReturnDetail ?? "n",
1163
+ fieldNoFindIgnore: input.fieldNoFindIgnore ?? "false"
1164
+ }
1165
+ };
1166
+ }
1167
+ return {
1168
+ header: { objId },
1169
+ mainTable: record(input.mainTable),
1170
+ operationinfo: { fieldNoFindIgnore: input.fieldNoFindIgnore ?? "false" }
1171
+ };
1172
+ }
1173
+ function customReadDatajson(endpoint, input, operator) {
1174
+ if (endpoint === "detail") {
1175
+ return {
1176
+ mainTable: { id: assertDecimalId(input.dataId || record(input.mainTable).id, "dataId") },
1177
+ header: { operator }
1178
+ };
1179
+ }
1180
+ if (endpoint === "query") {
1181
+ return {
1182
+ mainTable: record(input.mainTable),
1183
+ pageInfo: {
1184
+ pageNo: String(positiveInt(input.pageNo, "pageNo", 1)),
1185
+ pageSize: String(pageSizeInt(input.pageSize, 10, 1e3))
1186
+ },
1187
+ header: { operator }
1188
+ };
1189
+ }
1190
+ return { mainTable: record(input.mainTable), header: { operator } };
1191
+ }
1192
+ function parseOpenapiPayload(payload, label) {
1193
+ const root = record(payload);
1194
+ const message = record(root.message);
1195
+ if (!isSuccessCode(message.code)) {
1196
+ throw ebuilderBusinessError("business_error", responseMessage(payload) || `OpenAPI ${label} \u5931\u8D25`, { code: stringValue(message.code), details: { result: payload } });
1197
+ }
1198
+ const datajson = record(record(root.data).datajson);
1199
+ if (!Object.keys(datajson).length) throw ebuilderBusinessError("response_invalid", `OpenAPI ${label} \u54CD\u5E94\u7F3A\u5C11 data.datajson`, { details: { result: payload } });
1200
+ if (datajson.status === false) {
1201
+ throw ebuilderBusinessError("business_error", responseMessage(payload) || `OpenAPI ${label} status=false`, { details: { result: payload } });
1202
+ }
1203
+ return {
1204
+ status: datajson.status !== false,
1205
+ message: responseMessage(payload) || "success",
1206
+ dataIds: normalizeDataIds(datajson.dataIds),
1207
+ datas: datajson.datas,
1208
+ raw: payload
1209
+ };
1210
+ }
1211
+ function parseCustomPayload(payload, label) {
1212
+ const root = record(payload);
1213
+ const datajson = record(root.datajson || record(root.data).datajson);
1214
+ if (!Object.keys(datajson).length && !("datajson" in root)) {
1215
+ throw ebuilderBusinessError("response_invalid", `\u81EA\u5B9A\u4E49\u63A5\u53E3 ${label} \u54CD\u5E94\u7F3A\u5C11 datajson`, { details: { result: payload } });
1216
+ }
1217
+ return {
1218
+ status: true,
1219
+ message: responseMessage(payload) || "success",
1220
+ dataIds: normalizeDataIds(datajson.dataIds),
1221
+ datas: datajson.datas,
1222
+ raw: payload
1223
+ };
1224
+ }
1225
+ function normalizeDataIds(value) {
1226
+ if (value === void 0 || value === null) return [];
1227
+ if (Array.isArray(value)) return value.map((item) => stringValue(item)).filter(Boolean);
1228
+ return String(value).split(",").map((item) => item.trim()).filter(Boolean);
1229
+ }
1230
+ function stripInternalKeys(value) {
1231
+ const next = { ...value };
1232
+ delete next.__context;
1233
+ delete next.context;
1234
+ delete next.apiPrefix;
1235
+ delete next.appId;
1236
+ delete next.objId;
1237
+ delete next.listId;
1238
+ delete next.hostPageId;
1239
+ delete next.listKind;
1240
+ delete next.menuId;
1241
+ delete next.menuName;
1242
+ delete next.menuUrl;
1243
+ delete next.entryUrl;
1244
+ delete next.url;
1245
+ delete next.menu;
1246
+ delete next.menuKeywords;
1247
+ delete next.interfacePk;
1248
+ delete next.dataId;
1249
+ return next;
1250
+ }
1251
+ function cleanPathSegment(value, field) {
1252
+ const text = stringValue(value).replace(/^\/+|\/+$/gu, "");
1253
+ if (!/^[A-Za-z0-9_/-]+$/u.test(text) || text.includes("..") || text === "") {
1254
+ throw ebuilderValidationError("field_invalid", `${field} \u4E0D\u662F\u5408\u6CD5\u63A5\u53E3\u8DEF\u5F84\u7247\u6BB5`);
1255
+ }
1256
+ return text;
1257
+ }
1258
+
1259
+ // src/shortcuts/ebuilder-form/manifest.ts
1260
+ var contextProperties = {
1261
+ context: { type: "object", description: "\u5DF2\u89E3\u6790\u7684 eBuilder \u4E0A\u4E0B\u6587\uFF0C\u53EF\u7531 ebuilder-form.context.resolve \u8FD4\u56DE" },
1262
+ menuKeywords: { type: "array", items: { type: "string" }, minItems: 1, maxItems: 5 },
1263
+ menu: { type: "string" },
1264
+ menuId: { type: "string", pattern: "^\\d+$" },
1265
+ url: { type: "string", description: "E10 \u5217\u8868\u9875\u9762 URL\uFF1B\u652F\u6301 /sp/ebdfpage/list\u3001viewport \u548C /ebdapp/view" },
1266
+ appId: { type: "string", pattern: "^\\d+$" },
1267
+ apiPrefix: { type: "string", pattern: "^/api/ebuilder\\d*$" },
1268
+ objId: { type: "string", pattern: "^\\d+$" },
1269
+ listId: { type: "string", pattern: "^\\d+$" },
1270
+ hostPageId: { type: "string", pattern: "^\\d+$" },
1271
+ listKind: { type: "string", enum: ["List", "NList"] },
1272
+ menuUrl: { type: "string" },
1273
+ entryUrl: { type: "string" }
1274
+ };
1275
+ var preparedWriteProperties = {
1276
+ confirm: { const: true },
1277
+ continuation: { type: "string", minLength: 1 }
1278
+ };
1279
+ function schema(properties, options = {}) {
1280
+ return {
1281
+ type: "object",
1282
+ additionalProperties: false,
1283
+ properties,
1284
+ ...options.required?.length ? { required: options.required } : {},
1285
+ ...options.anyOf ? { anyOf: options.anyOf } : {},
1286
+ ...options.oneOf ? { oneOf: options.oneOf } : {},
1287
+ ...options.description ? { description: options.description } : {}
1288
+ };
1289
+ }
1290
+ var ebuilderFormOperations = [
1291
+ {
1292
+ name: "ebuilder-form.menu.search",
1293
+ summary: "\u6309\u4E1A\u52A1\u5173\u952E\u8BCD\u67E5\u8BE2\u5F53\u524D\u8D26\u53F7\u6709\u6743\u9650\u8BBF\u95EE\u7684 eBuilder \u8868\u683C/\u6570\u636E\u5217\u8868\u83DC\u5355",
1294
+ risk: "read",
1295
+ inputSchema: schema({
1296
+ menuKeywords: { type: "array", items: { type: "string" }, minItems: 1, maxItems: 5 }
1297
+ }, { required: ["menuKeywords"] })
1298
+ },
1299
+ {
1300
+ name: "ebuilder-form.context.resolve",
1301
+ summary: "\u4ECE\u83DC\u5355\u5173\u952E\u8BCD\u3001\u9875\u9762 URL\u3001objId \u6216\u73B0\u6709 context \u89E3\u6790 appId\u3001apiPrefix\u3001listId\u3001objId \u548C\u9875\u9762\u5730\u5740\u4E0A\u4E0B\u6587",
1302
+ risk: "read",
1303
+ inputSchema: schema(contextProperties, {
1304
+ anyOf: [
1305
+ { required: ["context"] },
1306
+ { required: ["url"] },
1307
+ { required: ["menuKeywords"] },
1308
+ { required: ["menu"] },
1309
+ { required: ["objId"] },
1310
+ { required: ["listId", "appId", "listKind"] }
1311
+ ]
1312
+ })
1313
+ },
1314
+ {
1315
+ name: "ebuilder-form.views.list",
1316
+ summary: "\u679A\u4E3E\u67D0\u4E2A\u8868\u5355\u5BF9\u8C61\u4E0B\u7684 List/NList \u89C6\u56FE",
1317
+ risk: "read",
1318
+ inputSchema: schema(contextProperties, { required: ["objId"] })
1319
+ },
1320
+ {
1321
+ name: "ebuilder-form.list.config",
1322
+ summary: "\u8BFB\u53D6\u4F20\u7EDF\u8868\u683C List \u7684\u57FA\u7840\u8BBE\u7F6E\u3001\u663E\u793A\u5217\u3001\u6392\u5E8F\u3001\u641C\u7D22\u3001\u7EDF\u8BA1\u548C\u56FA\u5B9A\u6761\u4EF6\u914D\u7F6E",
1323
+ risk: "read",
1324
+ inputSchema: schema(contextProperties, {
1325
+ anyOf: [{ required: ["context"] }, { required: ["listId", "appId"] }, { required: ["menuKeywords"] }, { required: ["url"] }]
1326
+ })
1327
+ },
1328
+ {
1329
+ name: "ebuilder-form.list.query",
1330
+ summary: "\u6309 List \u8FD0\u884C\u65F6\u63A5\u53E3\u67E5\u8BE2\u5206\u9875\u6570\u636E\u548C\u771F\u5B9E\u603B\u6570\uFF0C\u4FDD\u7559\u660E\u7EC6\u5C55\u5F00\u91CD\u590D\u884C",
1331
+ risk: "read",
1332
+ inputSchema: schema({
1333
+ ...contextProperties,
1334
+ pageNo: { type: "integer", minimum: 1, default: 1 },
1335
+ pageSize: { type: "integer", minimum: 1, maximum: 200 },
1336
+ allPages: { type: "boolean", default: false },
1337
+ tableuid: { type: "string" },
1338
+ searchParamData: { type: "object" },
1339
+ filterCondition: { type: "object" },
1340
+ orderParams: { type: "array" },
1341
+ passid: { type: "string" },
1342
+ cid: { type: "string" }
1343
+ })
1344
+ },
1345
+ {
1346
+ name: "ebuilder-form.nlist.config",
1347
+ summary: "\u8BFB\u53D6\u6570\u636E\u5217\u8868 NList \u7684\u9875\u9762\u3001\u7EC4\u4EF6\u4E0E comps[1].config \u8FD0\u884C\u65F6\u914D\u7F6E",
1348
+ risk: "read",
1349
+ inputSchema: schema(contextProperties, {
1350
+ anyOf: [{ required: ["context"] }, { required: ["hostPageId", "appId"] }, { required: ["menuKeywords"] }, { required: ["url"] }]
1351
+ })
1352
+ },
1353
+ {
1354
+ name: "ebuilder-form.nlist.query",
1355
+ summary: "\u6309 NList eblist \u8FD0\u884C\u65F6\u63A5\u53E3\u67E5\u8BE2\u5206\u9875\u6570\u636E\u548C\u771F\u5B9E\u603B\u6570\uFF0C\u4F7F\u7528 customConfig LZW \u6570\u5B57\u4E32\u7F16\u7801",
1356
+ risk: "read",
1357
+ inputSchema: schema({
1358
+ ...contextProperties,
1359
+ pageNo: { type: "integer", minimum: 1, default: 1 },
1360
+ pageSize: { type: "integer", minimum: 1, maximum: 200 },
1361
+ allPages: { type: "boolean", default: false },
1362
+ compId: { type: "string" },
1363
+ tableuid: { type: "string" },
1364
+ filter: {},
1365
+ fieldFilter: {},
1366
+ pageFilter: {},
1367
+ customConfig: { type: "object" },
1368
+ refPluginPackageId: { type: "string" }
1369
+ })
1370
+ },
1371
+ {
1372
+ name: "ebuilder-form.fields.get",
1373
+ summary: "\u8BFB\u53D6 eBuilder \u5B57\u6BB5\u5B9A\u4E49\uFF0C\u8FD4\u56DE\u4E3B\u8868\u4E0E\u660E\u7EC6\u8868\u5B57\u6BB5\u3001config.dataKey\u3001browserParams \u548C\u7EC4\u4EF6\u7C7B\u578B",
1374
+ risk: "read",
1375
+ fixed: { path: "/api/ebuilder/common/ds/fields" },
1376
+ inputSchema: schema({
1377
+ ...contextProperties,
1378
+ groupId: { type: "string" },
1379
+ sourceId: { type: "string" },
1380
+ sourceType: { type: "string", default: "FORM" },
1381
+ detailFieldsGroup: { type: ["boolean", "string"], default: true },
1382
+ enableMerge: { type: ["boolean", "string"], default: true },
1383
+ customParam: {},
1384
+ params: {}
1385
+ })
1386
+ },
1387
+ {
1388
+ name: "ebuilder-form.options.get",
1389
+ summary: "\u6309\u5B57\u6BB5\u5143\u6570\u636E ID \u8BFB\u53D6\u9009\u62E9\u7C7B\u5B57\u6BB5\u9009\u9879",
1390
+ risk: "read",
1391
+ fixed: { path: "/api/ebuilder/common/ds/options" },
1392
+ inputSchema: schema({
1393
+ ...contextProperties,
1394
+ fieldName: { type: "string", pattern: "^\\d+$" },
1395
+ fieldId: { type: "string", pattern: "^\\d+$" },
1396
+ sourceType: { type: "string", default: "FORM" },
1397
+ groupId: { type: "string" },
1398
+ optionLevel: { type: ["integer", "string"], default: 1 }
1399
+ }, {
1400
+ anyOf: [{ required: ["fieldName"] }, { required: ["fieldId"] }]
1401
+ })
1402
+ },
1403
+ {
1404
+ name: "ebuilder-form.mapping.get",
1405
+ summary: "\u8BFB\u53D6 objId \u7684 mainTable/detailN \u4E0E\u4E3B\u8868/\u660E\u7EC6\u8868\u6807\u8BC6\u6620\u5C04",
1406
+ risk: "read",
1407
+ fixed: { path: "/api/ebuilder/form/dataset/v1/getTableMapping" },
1408
+ inputSchema: schema({
1409
+ ...contextProperties,
1410
+ reverse: { type: "boolean", default: false }
1411
+ }, { required: ["objId"] })
1412
+ },
1413
+ {
1414
+ name: "ebuilder-form.browser.resolve",
1415
+ summary: "\u8C03\u7528\u5B57\u6BB5\u914D\u7F6E\u6216\u5DF2\u77E5\u6A21\u5757\u5BF9\u5E94\u7684\u901A\u7528\u6D4F\u89C8 complete \u63A5\u53E3\uFF0C\u5C06\u540D\u79F0\u89E3\u6790\u4E3A\u53EF\u9009\u9879 ID",
1416
+ risk: "read",
1417
+ inputSchema: schema({
1418
+ module: { type: "string", description: "\u6D4F\u89C8\u63A5\u53E3\u6A21\u5757\uFF0C\u4F8B\u5982 hrm\u3001workflow/core\u3001doc\u3001task" },
1419
+ browserType: { type: "string", description: "\u6D4F\u89C8\u7C7B\u578B\uFF0C\u4F8B\u5982 resource\u3001department\u3001wfcRequest" },
1420
+ query: { type: "string", minLength: 1 },
1421
+ multiple: { type: "boolean", default: false },
1422
+ limit: { type: "integer", minimum: 1, maximum: 50, default: 20 },
1423
+ extra: { type: "object" }
1424
+ }, { required: ["module", "browserType", "query"] })
1425
+ },
1426
+ {
1427
+ name: "ebuilder-form.openapi.detail",
1428
+ summary: "OpenAPI getDataById \u83B7\u53D6\u5355\u6761\u8868\u5355\u6570\u636E\u8BE6\u60C5",
1429
+ risk: "read",
1430
+ fixed: { path: "/api/ebuilder/form/dataset/v2/getDataById" },
1431
+ inputSchema: schema({
1432
+ ...contextProperties,
1433
+ dataId: { type: "string", pattern: "^\\d+$" },
1434
+ isReturnDetail: { type: ["boolean", "string"], default: "y" },
1435
+ fieldNoFindIgnore: { type: ["boolean", "string"], default: "false" }
1436
+ }, { required: ["objId", "dataId"] })
1437
+ },
1438
+ {
1439
+ name: "ebuilder-form.openapi.query",
1440
+ summary: "OpenAPI getAllData \u8868\u5355\u7EA7\u5206\u9875\u67E5\u8BE2",
1441
+ risk: "read",
1442
+ fixed: { path: "/api/ebuilder/form/dataset/v2/getAllData" },
1443
+ inputSchema: schema({
1444
+ ...contextProperties,
1445
+ mainTable: { type: "object" },
1446
+ pageNo: { type: "integer", minimum: 1, default: 1 },
1447
+ pageSize: { type: "integer", minimum: 1, maximum: 1e3, default: 10 },
1448
+ isReturnDetail: { type: ["boolean", "string"], default: "n" },
1449
+ fieldNoFindIgnore: { type: ["boolean", "string"], default: "false" }
1450
+ }, { required: ["objId"] })
1451
+ },
1452
+ {
1453
+ name: "ebuilder-form.openapi.count",
1454
+ summary: "OpenAPI getAllDataCount \u8868\u5355\u7EA7\u603B\u6570\u67E5\u8BE2",
1455
+ risk: "read",
1456
+ fixed: { path: "/api/ebuilder/form/dataset/v2/getAllDataCount" },
1457
+ inputSchema: schema({
1458
+ ...contextProperties,
1459
+ mainTable: { type: "object" },
1460
+ fieldNoFindIgnore: { type: ["boolean", "string"], default: "false" }
1461
+ }, { required: ["objId"] })
1462
+ },
1463
+ {
1464
+ name: "ebuilder-form.openapi.add.prepare",
1465
+ summary: "\u51C6\u5907 OpenAPI saveFormData \u65B0\u589E\u8BF7\u6C42\uFF0C\u7B7E\u53D1 continuation\uFF0C\u4E0D\u5199\u5165",
1466
+ risk: "read-before-write",
1467
+ inputSchema: schema({
1468
+ ...contextProperties,
1469
+ datas: { type: "array", minItems: 1 },
1470
+ operationinfo: { type: "object" }
1471
+ }, { required: ["objId", "datas"] })
1472
+ },
1473
+ {
1474
+ name: "ebuilder-form.openapi.add.apply",
1475
+ summary: "\u786E\u8BA4\u540E\u6267\u884C OpenAPI saveFormData \u65B0\u589E\u8BF7\u6C42",
1476
+ risk: "high-risk-write",
1477
+ inputSchema: schema(preparedWriteProperties, { required: ["confirm", "continuation"] })
1478
+ },
1479
+ {
1480
+ name: "ebuilder-form.openapi.update.prepare",
1481
+ summary: "\u51C6\u5907 OpenAPI updateFormData \u4FEE\u6539\u8BF7\u6C42\uFF0C\u7B7E\u53D1 continuation\uFF0C\u4E0D\u5199\u5165",
1482
+ risk: "read-before-write",
1483
+ inputSchema: schema({
1484
+ ...contextProperties,
1485
+ datas: { type: "array", minItems: 1 },
1486
+ operationinfo: { type: "object" }
1487
+ }, { required: ["objId", "datas"] })
1488
+ },
1489
+ {
1490
+ name: "ebuilder-form.openapi.update.apply",
1491
+ summary: "\u786E\u8BA4\u540E\u6267\u884C OpenAPI updateFormData \u4FEE\u6539\u8BF7\u6C42",
1492
+ risk: "high-risk-write",
1493
+ inputSchema: schema(preparedWriteProperties, { required: ["confirm", "continuation"] })
1494
+ },
1495
+ {
1496
+ name: "ebuilder-form.openapi.delete.prepare",
1497
+ summary: "\u51C6\u5907 OpenAPI deleteData \u5220\u9664\u8BF7\u6C42\uFF0C\u7B7E\u53D1 continuation\uFF0C\u4E0D\u5199\u5165",
1498
+ risk: "read-before-write",
1499
+ inputSchema: schema({
1500
+ ...contextProperties,
1501
+ mainTable: { type: "object", description: '\u5220\u9664\u6761\u4EF6\uFF1B\u6309\u6570\u636E ID \u5220\u9664\u65F6\u4F20 {"id":"..."}' },
1502
+ dataId: { type: "string", pattern: "^\\d+$" },
1503
+ operationinfo: { type: "object" }
1504
+ }, {
1505
+ required: ["objId"],
1506
+ anyOf: [{ required: ["dataId"] }, { required: ["mainTable"] }]
1507
+ })
1508
+ },
1509
+ {
1510
+ name: "ebuilder-form.openapi.delete.apply",
1511
+ summary: "\u786E\u8BA4\u540E\u6267\u884C OpenAPI deleteData \u5220\u9664\u8BF7\u6C42",
1512
+ risk: "high-risk-write",
1513
+ inputSchema: schema(preparedWriteProperties, { required: ["confirm", "continuation"] })
1514
+ },
1515
+ {
1516
+ name: "ebuilder-form.custom.detail",
1517
+ summary: "\u5DF2\u53D1\u5E03\u81EA\u5B9A\u4E49\u63A5\u53E3 getFormDataByPk \u6839\u636E\u4E3B\u952E\u67E5\u8BE2\u8BE6\u60C5",
1518
+ risk: "read",
1519
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataByPk/{interfacePk}" },
1520
+ inputSchema: schema({
1521
+ ...contextProperties,
1522
+ interfacePk: { type: "string", minLength: 1 },
1523
+ dataId: { type: "string", pattern: "^\\d+$" }
1524
+ }, { required: ["interfacePk", "dataId"] })
1525
+ },
1526
+ {
1527
+ name: "ebuilder-form.custom.query",
1528
+ summary: "\u5DF2\u53D1\u5E03\u81EA\u5B9A\u4E49\u63A5\u53E3 getFormDataList \u5206\u9875\u67E5\u8BE2",
1529
+ risk: "read",
1530
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataList/{interfacePk}" },
1531
+ inputSchema: schema({
1532
+ ...contextProperties,
1533
+ interfacePk: { type: "string", minLength: 1 },
1534
+ mainTable: { type: "object" },
1535
+ pageNo: { type: "integer", minimum: 1, default: 1 },
1536
+ pageSize: { type: "integer", minimum: 1, maximum: 1e3, default: 10 }
1537
+ }, { required: ["interfacePk"] })
1538
+ },
1539
+ {
1540
+ name: "ebuilder-form.custom.count",
1541
+ summary: "\u5DF2\u53D1\u5E03\u81EA\u5B9A\u4E49\u63A5\u53E3 getFormDataCount \u67E5\u8BE2\u603B\u6570",
1542
+ risk: "read",
1543
+ fixed: { path: "/api/ebuilder/form/formdata/v2/getFormDataCount/{interfacePk}" },
1544
+ inputSchema: schema({
1545
+ ...contextProperties,
1546
+ interfacePk: { type: "string", minLength: 1 },
1547
+ mainTable: { type: "object" }
1548
+ }, { required: ["interfacePk"] })
1549
+ },
1550
+ {
1551
+ name: "ebuilder-form.custom.add.prepare",
1552
+ summary: "\u51C6\u5907\u5DF2\u53D1\u5E03\u81EA\u5B9A\u4E49\u63A5\u53E3 saveFormData \u65B0\u589E\u8BF7\u6C42\uFF0C\u7B7E\u53D1 continuation",
1553
+ risk: "read-before-write",
1554
+ inputSchema: schema({
1555
+ ...contextProperties,
1556
+ interfacePk: { type: "string", minLength: 1 },
1557
+ datas: { type: "array", minItems: 1 },
1558
+ operationinfo: { type: "object" }
1559
+ }, { required: ["interfacePk", "datas"] })
1560
+ },
1561
+ {
1562
+ name: "ebuilder-form.custom.add.apply",
1563
+ summary: "\u786E\u8BA4\u540E\u6267\u884C\u5DF2\u53D1\u5E03\u81EA\u5B9A\u4E49\u63A5\u53E3 saveFormData \u65B0\u589E\u8BF7\u6C42",
1564
+ risk: "high-risk-write",
1565
+ inputSchema: schema(preparedWriteProperties, { required: ["confirm", "continuation"] })
1566
+ },
1567
+ {
1568
+ name: "ebuilder-form.custom.update.prepare",
1569
+ summary: "\u51C6\u5907\u5DF2\u53D1\u5E03\u81EA\u5B9A\u4E49\u63A5\u53E3 updateFormData \u4FEE\u6539\u8BF7\u6C42\uFF0C\u7B7E\u53D1 continuation",
1570
+ risk: "read-before-write",
1571
+ inputSchema: schema({
1572
+ ...contextProperties,
1573
+ interfacePk: { type: "string", minLength: 1 },
1574
+ datas: { type: "array", minItems: 1 },
1575
+ operationinfo: { type: "object" }
1576
+ }, { required: ["interfacePk", "datas"] })
1577
+ },
1578
+ {
1579
+ name: "ebuilder-form.custom.update.apply",
1580
+ summary: "\u786E\u8BA4\u540E\u6267\u884C\u5DF2\u53D1\u5E03\u81EA\u5B9A\u4E49\u63A5\u53E3 updateFormData \u4FEE\u6539\u8BF7\u6C42",
1581
+ risk: "high-risk-write",
1582
+ inputSchema: schema(preparedWriteProperties, { required: ["confirm", "continuation"] })
1583
+ },
1584
+ {
1585
+ name: "ebuilder-form.custom.delete.prepare",
1586
+ summary: "\u51C6\u5907\u5DF2\u53D1\u5E03\u81EA\u5B9A\u4E49\u63A5\u53E3 deleteFormData \u5220\u9664\u8BF7\u6C42\uFF0C\u7B7E\u53D1 continuation",
1587
+ risk: "read-before-write",
1588
+ inputSchema: schema({
1589
+ ...contextProperties,
1590
+ interfacePk: { type: "string", minLength: 1 },
1591
+ dataIds: { type: "array", items: { type: "string", pattern: "^\\d+$" }, minItems: 1 },
1592
+ operationinfo: { type: "object" }
1593
+ }, { required: ["interfacePk", "dataIds"] })
1594
+ },
1595
+ {
1596
+ name: "ebuilder-form.custom.delete.apply",
1597
+ summary: "\u786E\u8BA4\u540E\u6267\u884C\u5DF2\u53D1\u5E03\u81EA\u5B9A\u4E49\u63A5\u53E3 deleteFormData \u5220\u9664\u8BF7\u6C42",
1598
+ risk: "high-risk-write",
1599
+ inputSchema: schema(preparedWriteProperties, { required: ["confirm", "continuation"] })
1600
+ }
1601
+ ];
1602
+ var ebuilderFormManifest = {
1603
+ module: "ebuilder-form",
1604
+ version: 1,
1605
+ operations: ebuilderFormOperations
1606
+ };
1607
+
1608
+ // src/shortcuts/ebuilder-form/operations/types.ts
1609
+ function ebuilderSuccess(action, data, meta, warnings = []) {
1610
+ const payload = { ok: true, action, data };
1611
+ if (meta && Object.keys(meta).length > 0) payload.meta = meta;
1612
+ if (warnings.length > 0) payload.warnings = warnings;
1613
+ return payload;
1614
+ }
1615
+
1616
+ // src/shortcuts/ebuilder-form/operations/shared.ts
1617
+ var FORBIDDEN_KEYS = /* @__PURE__ */ new Set([
1618
+ "__proto__",
1619
+ "constructor",
1620
+ "prototype",
1621
+ "access_token",
1622
+ "app_key",
1623
+ "app_secret",
1624
+ "authorization",
1625
+ "cookie",
1626
+ "eteamsid",
1627
+ "sedit",
1628
+ "token"
1629
+ ]);
1630
+ function asObject(value, field = "input") {
1631
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
1632
+ throw ebuilderValidationError("input_not_object", `${field} \u5FC5\u987B\u662F JSON \u5BF9\u8C61`);
1633
+ }
1634
+ return value;
1635
+ }
1636
+ function optionalObject(value, field) {
1637
+ if (value === void 0 || value === null) return void 0;
1638
+ return asObject(value, field);
1639
+ }
1640
+ function requiredArray(value, field) {
1641
+ if (!Array.isArray(value)) throw ebuilderValidationError("field_invalid", `${field} \u5FC5\u987B\u662F\u6570\u7EC4`);
1642
+ return value;
1643
+ }
1644
+ function optionalArray(value, field) {
1645
+ if (value === void 0 || value === null) return void 0;
1646
+ return requiredArray(value, field);
1647
+ }
1648
+ function requiredString(value, field) {
1649
+ if (value === void 0 || value === null || value === "") {
1650
+ throw ebuilderValidationError("field_required", `${field} \u5FC5\u586B`);
1651
+ }
1652
+ if (typeof value === "object") throw ebuilderValidationError("field_invalid", `${field} \u5FC5\u987B\u662F\u5B57\u7B26\u4E32`);
1653
+ return String(value);
1654
+ }
1655
+ function optionalString(value, field) {
1656
+ if (value === void 0 || value === null || value === "") return void 0;
1657
+ if (typeof value === "object") throw ebuilderValidationError("field_invalid", `${field} \u5FC5\u987B\u662F\u5B57\u7B26\u4E32`);
1658
+ return String(value);
1659
+ }
1660
+ function assertKnownKeys(input, allowed, operation) {
1661
+ const unknown = Object.keys(input).filter((key) => !allowed.includes(key));
1662
+ if (unknown.length > 0) {
1663
+ throw ebuilderValidationError("unknown_field", `${operation} \u4E0D\u652F\u6301\u5B57\u6BB5\uFF1A${unknown.join("\u3001")}`, { unknown });
1664
+ }
1665
+ }
1666
+ function assertNoForbiddenKeys(value, location = "input") {
1667
+ if (!value || typeof value !== "object") return;
1668
+ if (Array.isArray(value)) {
1669
+ value.forEach((item, index) => assertNoForbiddenKeys(item, `${location}[${index}]`));
1670
+ return;
1671
+ }
1672
+ for (const [key, child] of Object.entries(value)) {
1673
+ if (FORBIDDEN_KEYS.has(key) || FORBIDDEN_KEYS.has(key.toLowerCase())) {
1674
+ throw ebuilderValidationError("field_forbidden", `\u7981\u6B62\u4E1A\u52A1\u8F93\u5165\u5B57\u6BB5\uFF1A${location}.${key}`);
1675
+ }
1676
+ assertNoForbiddenKeys(child, `${location}.${key}`);
1677
+ }
1678
+ }
1679
+ function compactJson(value) {
1680
+ return JSON.stringify(value);
1681
+ }
1682
+ function sha256VisibleFingerprint(value) {
1683
+ const json = compactJson(value);
1684
+ let hash = 0;
1685
+ for (let index = 0; index < json.length; index += 1) {
1686
+ hash = (hash << 5) - hash + json.charCodeAt(index) | 0;
1687
+ }
1688
+ return `len:${json.length}:h:${(hash >>> 0).toString(16)}`;
1689
+ }
1690
+
1691
+ // src/shortcuts/ebuilder-form/operations/read.ts
1692
+ var CONTEXT_KEYS = [
1693
+ "context",
1694
+ "menuKeywords",
1695
+ "menu",
1696
+ "menuId",
1697
+ "url",
1698
+ "appId",
1699
+ "apiPrefix",
1700
+ "objId",
1701
+ "listId",
1702
+ "hostPageId",
1703
+ "listKind",
1704
+ "menuUrl",
1705
+ "entryUrl"
1706
+ ];
1707
+ var EbuilderMenuSearchOperation = class {
1708
+ name = "ebuilder-form.menu.search";
1709
+ async execute(input, { host }) {
1710
+ assertKnownKeys(input, ["menuKeywords"], this.name);
1711
+ const keywords = requiredArray(input.menuKeywords, "menuKeywords").map((item) => String(item));
1712
+ const menus = await host.searchMenus(keywords);
1713
+ return ebuilderSuccess(this.name, { menus, count: menus.length }, { status: "COMPLETE" });
1714
+ }
1715
+ };
1716
+ var EbuilderContextResolveOperation = class {
1717
+ name = "ebuilder-form.context.resolve";
1718
+ async execute(input, { host }) {
1719
+ const context = await host.resolveContext(input);
1720
+ return ebuilderSuccess(this.name, {
1721
+ context,
1722
+ listUrl: host.buildListUrl(context)
1723
+ }, { status: "COMPLETE" });
1724
+ }
1725
+ };
1726
+ var EbuilderViewsListOperation = class {
1727
+ name = "ebuilder-form.views.list";
1728
+ async execute(input, { host }) {
1729
+ const result = await host.formViews(input);
1730
+ return ebuilderSuccess(this.name, result, { status: "COMPLETE" });
1731
+ }
1732
+ };
1733
+ var EbuilderListConfigOperation = class {
1734
+ name = "ebuilder-form.list.config";
1735
+ async execute(input, { host }) {
1736
+ const context = await host.resolveContext({ ...input, listKind: input.listKind || input.context?.listKind || "List" });
1737
+ const result = await host.listConfig(context, this.name);
1738
+ return ebuilderSuccess(this.name, result, { status: "COMPLETE" });
1739
+ }
1740
+ };
1741
+ var EbuilderListQueryOperation = class {
1742
+ name = "ebuilder-form.list.query";
1743
+ async execute(input, { host }) {
1744
+ const result = await host.listQuery(input, this.name);
1745
+ return ebuilderSuccess(this.name, result, { status: "COMPLETE" });
1746
+ }
1747
+ };
1748
+ var EbuilderNlistConfigOperation = class {
1749
+ name = "ebuilder-form.nlist.config";
1750
+ async execute(input, { host }) {
1751
+ const context = await host.resolveContext({ ...input, listKind: input.listKind || input.context?.listKind || "NList" });
1752
+ const result = await host.nlistConfig(context, this.name);
1753
+ return ebuilderSuccess(this.name, result, { status: "COMPLETE" });
1754
+ }
1755
+ };
1756
+ var EbuilderNlistQueryOperation = class {
1757
+ name = "ebuilder-form.nlist.query";
1758
+ async execute(input, { host }) {
1759
+ const result = await host.nlistQuery(input, this.name);
1760
+ return ebuilderSuccess(this.name, result, { status: "COMPLETE" });
1761
+ }
1762
+ };
1763
+ var EbuilderFieldsGetOperation = class {
1764
+ name = "ebuilder-form.fields.get";
1765
+ async execute(input, { host }) {
1766
+ const result = await host.fields(input, this.name);
1767
+ return ebuilderSuccess(this.name, { result }, { status: "COMPLETE" });
1768
+ }
1769
+ };
1770
+ var EbuilderOptionsGetOperation = class {
1771
+ name = "ebuilder-form.options.get";
1772
+ async execute(input, { host }) {
1773
+ const result = await host.options(input, this.name);
1774
+ return ebuilderSuccess(this.name, { result }, { status: "COMPLETE" });
1775
+ }
1776
+ };
1777
+ var EbuilderMappingGetOperation = class {
1778
+ name = "ebuilder-form.mapping.get";
1779
+ async execute(input, { host }) {
1780
+ const result = await host.mapping(input, this.name);
1781
+ return ebuilderSuccess(this.name, { result }, { status: "COMPLETE" });
1782
+ }
1783
+ };
1784
+ var EbuilderBrowserResolveOperation = class {
1785
+ name = "ebuilder-form.browser.resolve";
1786
+ async execute(input, { host }) {
1787
+ assertKnownKeys(input, ["module", "browserType", "query", "multiple", "limit", "extra"], this.name);
1788
+ const result = await host.browserResolve(input, this.name);
1789
+ return ebuilderSuccess(this.name, result, { status: "COMPLETE" });
1790
+ }
1791
+ };
1792
+ var EbuilderOpenapiReadOperation = class {
1793
+ constructor(endpoint) {
1794
+ this.endpoint = endpoint;
1795
+ this.name = `ebuilder-form.openapi.${endpoint}`;
1796
+ }
1797
+ endpoint;
1798
+ name;
1799
+ async execute(input, { host }) {
1800
+ const allowed = [
1801
+ ...CONTEXT_KEYS,
1802
+ "dataId",
1803
+ "mainTable",
1804
+ "pageNo",
1805
+ "pageSize",
1806
+ "isReturnDetail",
1807
+ "fieldNoFindIgnore"
1808
+ ];
1809
+ assertKnownKeys(input, allowed, this.name);
1810
+ const result = await host.openapiRead(this.endpoint, input, this.name);
1811
+ const data = addLinks(result, host, this.endpoint === "detail" ? optionalString(input.dataId, "dataId") : void 0);
1812
+ return ebuilderSuccess(this.name, data, { status: "COMPLETE" });
1813
+ }
1814
+ };
1815
+ var EbuilderCustomReadOperation = class {
1816
+ constructor(endpoint) {
1817
+ this.endpoint = endpoint;
1818
+ this.name = `ebuilder-form.custom.${endpoint}`;
1819
+ }
1820
+ endpoint;
1821
+ name;
1822
+ async execute(input, { host }) {
1823
+ const allowed = [
1824
+ ...CONTEXT_KEYS,
1825
+ "interfacePk",
1826
+ "dataId",
1827
+ "mainTable",
1828
+ "pageNo",
1829
+ "pageSize"
1830
+ ];
1831
+ assertKnownKeys(input, allowed, this.name);
1832
+ const result = await host.customRead(this.endpoint, input, this.name);
1833
+ const data = addLinks(result, host, this.endpoint === "detail" ? optionalString(input.dataId, "dataId") : void 0);
1834
+ return ebuilderSuccess(this.name, data, { status: "COMPLETE" });
1835
+ }
1836
+ };
1837
+ function addLinks(result, host, dataId) {
1838
+ const context = asObject(result.context || {}, "context");
1839
+ const payload = asObject(result.result || {}, "result");
1840
+ return {
1841
+ context,
1842
+ result: payload,
1843
+ ...dataId ? { dataUrl: host.buildDataUrl(context, dataId) } : {},
1844
+ listUrl: host.buildListUrl(context)
1845
+ };
1846
+ }
1847
+
1848
+ // src/shortcuts/ebuilder-form/operations/write.ts
1849
+ var CONTEXT_KEYS2 = [
1850
+ "context",
1851
+ "menuKeywords",
1852
+ "menu",
1853
+ "menuId",
1854
+ "url",
1855
+ "appId",
1856
+ "apiPrefix",
1857
+ "objId",
1858
+ "listId",
1859
+ "hostPageId",
1860
+ "listKind",
1861
+ "menuUrl",
1862
+ "entryUrl"
1863
+ ];
1864
+ var EbuilderOpenapiPrepareOperation = class {
1865
+ constructor(endpoint) {
1866
+ this.endpoint = endpoint;
1867
+ this.name = `ebuilder-form.openapi.${endpoint}.prepare`;
1868
+ this.applyName = `ebuilder-form.openapi.${endpoint}.apply`;
1869
+ }
1870
+ endpoint;
1871
+ name;
1872
+ applyName;
1873
+ async execute(input, env) {
1874
+ const allowed = [
1875
+ ...CONTEXT_KEYS2,
1876
+ "dataId",
1877
+ "mainTable",
1878
+ "datas",
1879
+ "operationinfo"
1880
+ ];
1881
+ assertKnownKeys(input, allowed, this.name);
1882
+ assertNoForbiddenKeys(input);
1883
+ const prepared = await prepareOpenapi(this.endpoint, input, env.host);
1884
+ const session = await env.host.getSession();
1885
+ const continuation = await env.continuation.issue({
1886
+ operation: this.applyName,
1887
+ actor: { userId: session.userId, baseUrl: session.baseUrl, profile: session.profile },
1888
+ kind: "openapi",
1889
+ endpoint: this.endpoint,
1890
+ datajson: { ...prepared.datajson, __context: prepared.context },
1891
+ target: prepared.target,
1892
+ fingerprint: sha256VisibleFingerprint(prepared.datajson)
1893
+ });
1894
+ return ebuilderSuccess(this.name, {
1895
+ context: prepared.context,
1896
+ target: prepared.target,
1897
+ requestPreview: { datajson: prepared.datajson },
1898
+ continuation,
1899
+ expiresInSeconds: 600
1900
+ }, { status: "PREPARED" }, prepared.warnings);
1901
+ }
1902
+ };
1903
+ var EbuilderOpenapiApplyOperation = class {
1904
+ constructor(endpoint) {
1905
+ this.endpoint = endpoint;
1906
+ this.name = `ebuilder-form.openapi.${endpoint}.apply`;
1907
+ }
1908
+ endpoint;
1909
+ name;
1910
+ async execute(input, env) {
1911
+ assertKnownKeys(input, ["confirm", "continuation"], this.name);
1912
+ if (input.confirm !== true) throw ebuilderConfirmationError(this.name);
1913
+ const record2 = await env.continuation.verify(requiredString(input.continuation, "continuation"), this.name);
1914
+ assertContinuation(record2, await env.host.getSession(), "openapi", this.endpoint);
1915
+ const datajson = asObject(record2.datajson, "continuation.datajson");
1916
+ const result = await env.host.openapiWrite(this.endpoint, datajson, this.name);
1917
+ return ebuilderSuccess(this.name, summarizeWriteResult(result, env.host, this.endpoint === "delete"), { status: "COMPLETE" });
1918
+ }
1919
+ };
1920
+ var EbuilderCustomPrepareOperation = class {
1921
+ constructor(endpoint) {
1922
+ this.endpoint = endpoint;
1923
+ this.name = `ebuilder-form.custom.${endpoint}.prepare`;
1924
+ this.applyName = `ebuilder-form.custom.${endpoint}.apply`;
1925
+ }
1926
+ endpoint;
1927
+ name;
1928
+ applyName;
1929
+ async execute(input, env) {
1930
+ const allowed = [
1931
+ ...CONTEXT_KEYS2,
1932
+ "interfacePk",
1933
+ "dataIds",
1934
+ "datas",
1935
+ "operationinfo"
1936
+ ];
1937
+ assertKnownKeys(input, allowed, this.name);
1938
+ assertNoForbiddenKeys(input);
1939
+ const prepared = await prepareCustom(this.endpoint, input, env.host);
1940
+ const session = await env.host.getSession();
1941
+ const continuation = await env.continuation.issue({
1942
+ operation: this.applyName,
1943
+ actor: { userId: session.userId, baseUrl: session.baseUrl, profile: session.profile },
1944
+ kind: "custom",
1945
+ endpoint: this.endpoint,
1946
+ interfacePk: prepared.interfacePk,
1947
+ datajson: { ...prepared.datajson, __context: prepared.context },
1948
+ target: prepared.target,
1949
+ fingerprint: sha256VisibleFingerprint(prepared.datajson)
1950
+ });
1951
+ return ebuilderSuccess(this.name, {
1952
+ context: prepared.context,
1953
+ interfacePk: prepared.interfacePk,
1954
+ target: prepared.target,
1955
+ requestPreview: { datajson: prepared.datajson },
1956
+ continuation,
1957
+ expiresInSeconds: 600
1958
+ }, { status: "PREPARED" }, prepared.warnings);
1959
+ }
1960
+ };
1961
+ var EbuilderCustomApplyOperation = class {
1962
+ constructor(endpoint) {
1963
+ this.endpoint = endpoint;
1964
+ this.name = `ebuilder-form.custom.${endpoint}.apply`;
1965
+ }
1966
+ endpoint;
1967
+ name;
1968
+ async execute(input, env) {
1969
+ assertKnownKeys(input, ["confirm", "continuation"], this.name);
1970
+ if (input.confirm !== true) throw ebuilderConfirmationError(this.name);
1971
+ const record2 = await env.continuation.verify(requiredString(input.continuation, "continuation"), this.name);
1972
+ assertContinuation(record2, await env.host.getSession(), "custom", this.endpoint);
1973
+ const datajson = asObject(record2.datajson, "continuation.datajson");
1974
+ const interfacePk = requiredString(record2.interfacePk, "continuation.interfacePk");
1975
+ const result = await env.host.customWrite(this.endpoint, interfacePk, datajson, this.name);
1976
+ return ebuilderSuccess(this.name, summarizeWriteResult(result, env.host, this.endpoint === "delete"), { status: "COMPLETE" });
1977
+ }
1978
+ };
1979
+ async function prepareOpenapi(endpoint, input, host) {
1980
+ const context = await host.resolveContext(input);
1981
+ const operationinfo = optionalObject(input.operationinfo, "operationinfo") || {};
1982
+ if (endpoint === "add") {
1983
+ const datas = requiredArray(input.datas, "datas");
1984
+ return {
1985
+ context,
1986
+ datajson: {
1987
+ datas,
1988
+ header: { objId: context.objId },
1989
+ operationinfo: {
1990
+ fieldNoFindIgnore: "false",
1991
+ checkRight: "true",
1992
+ doAction: "false",
1993
+ printCost: "true",
1994
+ ...operationinfo
1995
+ }
1996
+ },
1997
+ target: { endpoint, objId: context.objId, count: datas.length },
1998
+ warnings: fieldKeyWarnings(datas)
1999
+ };
2000
+ }
2001
+ if (endpoint === "update") {
2002
+ const datas = requiredArray(input.datas, "datas");
2003
+ return {
2004
+ context,
2005
+ datajson: {
2006
+ datas,
2007
+ header: { objId: context.objId },
2008
+ operationinfo: {
2009
+ updateType: "ids",
2010
+ needAdd: "false",
2011
+ fieldNoFindIgnore: "false",
2012
+ checkRight: "true",
2013
+ doAction: "false",
2014
+ printCost: "true",
2015
+ ...operationinfo
2016
+ }
2017
+ },
2018
+ target: { endpoint, objId: context.objId, dataIds: collectDataIds(datas) },
2019
+ warnings: fieldKeyWarnings(datas)
2020
+ };
2021
+ }
2022
+ const mainTable = {
2023
+ ...optionalObject(input.mainTable, "mainTable") || {},
2024
+ ...input.dataId ? { id: requiredString(input.dataId, "dataId") } : {}
2025
+ };
2026
+ if (Object.keys(mainTable).length === 0) {
2027
+ throw ebuilderValidationError("delete_target_required", "\u5220\u9664\u5FC5\u987B\u63D0\u4F9B dataId \u6216 mainTable \u6761\u4EF6");
2028
+ }
2029
+ return {
2030
+ context,
2031
+ datajson: {
2032
+ header: { objId: context.objId },
2033
+ mainTable,
2034
+ operationinfo: {
2035
+ fieldNoFindIgnore: "false",
2036
+ checkRight: "true",
2037
+ doAction: "false",
2038
+ printCost: "true",
2039
+ ...operationinfo
2040
+ }
2041
+ },
2042
+ target: { endpoint, objId: context.objId, mainTable },
2043
+ warnings: ["\u5220\u9664\u4E0D\u53EF\u9006\uFF1Bapply \u524D\u5FC5\u987B\u786E\u8BA4 objId\u3001\u5220\u9664\u6761\u4EF6\u548C\u5F53\u524D\u64CD\u4F5C\u4EBA\u5747\u6B63\u786E"]
2044
+ };
2045
+ }
2046
+ async function prepareCustom(endpoint, input, host) {
2047
+ const context = await host.resolveContext(input);
2048
+ const interfacePk = requiredString(input.interfacePk, "interfacePk");
2049
+ const operationinfo = {
2050
+ printCost: false,
2051
+ asyncPostProcess: false,
2052
+ asyncMark: false,
2053
+ ...optionalObject(input.operationinfo, "operationinfo") || {}
2054
+ };
2055
+ const session = await host.getSession();
2056
+ if (endpoint === "delete") {
2057
+ const dataIds = requiredArray(input.dataIds, "dataIds").map((item) => requiredString(item, "dataIds[]"));
2058
+ return {
2059
+ context,
2060
+ interfacePk,
2061
+ datajson: {
2062
+ datas: dataIds.map((id) => ({ mainTable: { id } })),
2063
+ header: { operator: session.userId }
2064
+ },
2065
+ target: { endpoint, interfacePk, dataIds },
2066
+ warnings: ["\u5220\u9664\u4E0D\u53EF\u9006\uFF1Bapply \u524D\u5FC5\u987B\u786E\u8BA4 interfacePk\u3001\u76EE\u6807 dataId \u548C\u5F53\u524D\u64CD\u4F5C\u4EBA\u5747\u6B63\u786E"]
2067
+ };
2068
+ }
2069
+ const datas = requiredArray(input.datas, "datas");
2070
+ return {
2071
+ context,
2072
+ interfacePk,
2073
+ datajson: {
2074
+ operationinfo,
2075
+ datas,
2076
+ header: { operator: session.userId }
2077
+ },
2078
+ target: { endpoint, interfacePk, count: datas.length, dataIds: collectDataIds(datas) },
2079
+ warnings: fieldKeyWarnings(datas)
2080
+ };
2081
+ }
2082
+ function assertContinuation(record2, session, kind, endpoint) {
2083
+ if (record2.kind !== kind || record2.endpoint !== endpoint) {
2084
+ throw ebuilderValidationError("continuation_mismatch", "continuation \u7684\u63A5\u53E3\u65CF\u6216 operation \u4E0E\u5F53\u524D apply \u4E0D\u4E00\u81F4");
2085
+ }
2086
+ const actor = asObject(record2.actor, "continuation.actor");
2087
+ if (actor.userId !== session.userId || actor.baseUrl !== session.baseUrl) {
2088
+ throw ebuilderValidationError("continuation_actor_changed", "continuation \u7B7E\u53D1\u65F6\u7684\u767B\u5F55\u73AF\u5883\u6216\u7528\u6237\u4E0E\u5F53\u524D\u4F1A\u8BDD\u4E0D\u4E00\u81F4\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C prepare");
2089
+ }
2090
+ }
2091
+ function summarizeWriteResult(result, host, deleted) {
2092
+ const context = asObject(result.context || {}, "context");
2093
+ const payload = asObject(result.result || {}, "result");
2094
+ const dataIds = Array.isArray(payload.dataIds) ? payload.dataIds : [];
2095
+ return {
2096
+ context,
2097
+ result: payload,
2098
+ records: dataIds.map((dataId) => ({
2099
+ dataId,
2100
+ url: host.buildDataUrl(context, dataId, deleted)
2101
+ })),
2102
+ listUrl: host.buildListUrl(context)
2103
+ };
2104
+ }
2105
+ function collectDataIds(datas) {
2106
+ return datas.map((item) => optionalString(asObject(item, "datas[]").mainTable?.id, "mainTable.id")).filter((item) => Boolean(item));
2107
+ }
2108
+ function fieldKeyWarnings(datas) {
2109
+ const warnings = [];
2110
+ const text = JSON.stringify(datas);
2111
+ if (/"\d{16,}"/u.test(text)) {
2112
+ warnings.push("\u68C0\u6D4B\u5230\u957F\u6570\u5B57\u5B57\u6BB5\u952E\uFF1B\u5982\u679C\u5B57\u6BB5\u5B9A\u4E49\u4E2D name \u7B49\u4E8E id\uFF0C\u8BF7\u786E\u8BA4\u5199\u5165\u952E\u5DF2\u6539\u7528 config.dataKey\uFF0C\u5426\u5219 eBuilder \u53EF\u80FD\u8FD4\u56DE\u6210\u529F\u4F46\u5B57\u6BB5\u503C\u4E3A\u7A7A");
2113
+ }
2114
+ if (optionalArray(datas, "datas")?.some((item) => JSON.stringify(item).includes('"fieldNoFindIgnore"'))) {
2115
+ warnings.push("fieldNoFindIgnore \u5E94\u653E\u5728 operationinfo\uFF1B\u5B57\u6BB5\u540D\u9519\u8BEF\u4E0D\u80FD\u901A\u8FC7\u5FFD\u7565\u5B57\u6BB5\u7ED5\u8FC7");
2116
+ }
2117
+ return warnings;
2118
+ }
2119
+
2120
+ // src/shortcuts/ebuilder-form/operations/registry.ts
2121
+ function buildRegistry() {
2122
+ const handlers = [
2123
+ new EbuilderMenuSearchOperation(),
2124
+ new EbuilderContextResolveOperation(),
2125
+ new EbuilderViewsListOperation(),
2126
+ new EbuilderListConfigOperation(),
2127
+ new EbuilderListQueryOperation(),
2128
+ new EbuilderNlistConfigOperation(),
2129
+ new EbuilderNlistQueryOperation(),
2130
+ new EbuilderFieldsGetOperation(),
2131
+ new EbuilderOptionsGetOperation(),
2132
+ new EbuilderMappingGetOperation(),
2133
+ new EbuilderBrowserResolveOperation(),
2134
+ new EbuilderOpenapiReadOperation("detail"),
2135
+ new EbuilderOpenapiReadOperation("query"),
2136
+ new EbuilderOpenapiReadOperation("count"),
2137
+ new EbuilderOpenapiPrepareOperation("add"),
2138
+ new EbuilderOpenapiApplyOperation("add"),
2139
+ new EbuilderOpenapiPrepareOperation("update"),
2140
+ new EbuilderOpenapiApplyOperation("update"),
2141
+ new EbuilderOpenapiPrepareOperation("delete"),
2142
+ new EbuilderOpenapiApplyOperation("delete"),
2143
+ new EbuilderCustomReadOperation("detail"),
2144
+ new EbuilderCustomReadOperation("query"),
2145
+ new EbuilderCustomReadOperation("count"),
2146
+ new EbuilderCustomPrepareOperation("add"),
2147
+ new EbuilderCustomApplyOperation("add"),
2148
+ new EbuilderCustomPrepareOperation("update"),
2149
+ new EbuilderCustomApplyOperation("update"),
2150
+ new EbuilderCustomPrepareOperation("delete"),
2151
+ new EbuilderCustomApplyOperation("delete")
2152
+ ];
2153
+ const registry2 = /* @__PURE__ */ new Map();
2154
+ for (const handler of handlers) {
2155
+ if (registry2.has(handler.name)) throw new Error(`duplicate ebuilder-form operation handler: ${handler.name}`);
2156
+ registry2.set(handler.name, handler);
2157
+ }
2158
+ for (const contract of ebuilderFormOperations) {
2159
+ if (!registry2.has(contract.name)) throw new Error(`missing ebuilder-form operation handler: ${contract.name}`);
2160
+ }
2161
+ return registry2;
2162
+ }
2163
+ var registry = buildRegistry();
2164
+ function getEbuilderFormOperation(operation) {
2165
+ const handler = registry.get(operation);
2166
+ if (!handler) {
2167
+ throw ebuilderValidationError("operation_unknown", `eBuilder \u8868\u5355\u4E0D\u652F\u6301\u64CD\u4F5C\uFF1A${operation}`);
2168
+ }
2169
+ return handler;
2170
+ }
2171
+
2172
+ // src/shortcuts/ebuilder-form/operations.ts
2173
+ async function executeEbuilderFormOperation(operation, rawInput, context) {
2174
+ const handler = getEbuilderFormOperation(operation);
2175
+ const input = asObject(rawInput);
2176
+ assertNoForbiddenKeys(input);
2177
+ return handler.execute(input, context);
2178
+ }
2179
+
2180
+ // src/shortcuts/ebuilder-form/index.ts
2181
+ function asOptions(value) {
2182
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
2183
+ }
2184
+ async function readStdin() {
2185
+ const chunks = [];
2186
+ for await (const chunk of process.stdin) {
2187
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
2188
+ }
2189
+ return Buffer.concat(chunks).toString("utf8");
2190
+ }
2191
+ function stripBom(value) {
2192
+ return value.replace(/^\uFEFF+/u, "");
2193
+ }
2194
+ function parseJsonInput(raw, label) {
2195
+ try {
2196
+ const parsed = JSON.parse(stripBom(raw));
2197
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
2198
+ throw new Error("input must be an object");
2199
+ }
2200
+ return parsed;
2201
+ } catch {
2202
+ throw ebuilderValidationError("input_invalid", `${label} \u4E0D\u662F\u5408\u6CD5 JSON \u5BF9\u8C61`);
2203
+ }
2204
+ }
2205
+ async function inputFrom(options, extra = {}) {
2206
+ const opts = asOptions(options);
2207
+ let input = {};
2208
+ if (opts.input && opts.inputJson) {
2209
+ throw ebuilderValidationError("input_conflict", "\u4E0D\u80FD\u540C\u65F6\u4F20 --input \u548C --input-json");
2210
+ }
2211
+ if (opts.inputJson) {
2212
+ input = parseJsonInput(String(opts.inputJson), "--input-json");
2213
+ }
2214
+ if (opts.input) {
2215
+ let raw;
2216
+ try {
2217
+ raw = stripBom(opts.input === "-" ? await readStdin() : await readFile2(String(opts.input), "utf8"));
2218
+ } catch {
2219
+ throw ebuilderValidationError("input_unreadable", `\u65E0\u6CD5\u8BFB\u53D6 --input\uFF1A${String(opts.input)}`);
2220
+ }
2221
+ input = parseJsonInput(raw, "--input");
2222
+ }
2223
+ return {
2224
+ ...input,
2225
+ ...Object.fromEntries(Object.entries(extra).filter(([, value]) => value !== void 0 && value !== ""))
2226
+ };
2227
+ }
2228
+ function successEnvelope(operation, result) {
2229
+ return {
2230
+ schemaVersion: 1,
2231
+ ok: true,
2232
+ operation,
2233
+ data: result.data === void 0 ? null : result.data,
2234
+ ...result.meta ? { meta: result.meta } : {},
2235
+ warnings: result.warnings ?? []
2236
+ };
2237
+ }
2238
+ function failureEnvelope(error) {
2239
+ return {
2240
+ schemaVersion: 1,
2241
+ ok: false,
2242
+ error: toErrorEnvelope(error)
2243
+ };
2244
+ }
2245
+ async function executeAndPrint(ctx, operation, input) {
2246
+ try {
2247
+ const result = await executeEbuilderFormOperation(operation, input, {
2248
+ ctx,
2249
+ host: createEbuilderFormHost(ctx),
2250
+ continuation: createEbuilderFormContinuationSigner(ctx)
2251
+ });
2252
+ ctx.output.write(successEnvelope(operation, result), { json: true });
2253
+ } catch (error) {
2254
+ console.error(JSON.stringify(failureEnvelope(error), null, 2));
2255
+ process.exitCode = isCliError(error) ? error.exitCode : 1 /* GeneralError */;
2256
+ }
2257
+ }
2258
+ var ebuilderFormShortcut = {
2259
+ name: "ebuilder-form",
2260
+ description: "\u6CDB\u5FAEE10 eBuilder \u8868\u5355\u83DC\u5355\u3001\u5217\u8868\u548C\u8868\u5355\u6570\u636E CLI",
2261
+ category: "shortcut",
2262
+ register({ program, action }) {
2263
+ const ebuilder = program.command("ebuilder-form").description("\u6CDB\u5FAEE10 eBuilder \u8868\u5355\u83DC\u5355\u3001List/NList\u3001OpenAPI \u4E0E\u81EA\u5B9A\u4E49\u63A5\u53E3\u80FD\u529B");
2264
+ ebuilder.command("schema").description("Print ebuilder-form operation manifest for agents").action(action((ctx) => {
2265
+ ctx.output.write(ebuilderFormManifest, { json: true });
2266
+ }));
2267
+ ebuilder.command("run").description("Run an ebuilder-form operation with JSON input").argument("<operation>", "operation name, e.g. ebuilder-form.context.resolve").option("--input <path>", "JSON input file, or - for stdin").option("--input-json <json>", "inline JSON input object").action(action(async (ctx, operation, options) => {
2268
+ await executeAndPrint(ctx, String(operation), await inputFrom(options));
2269
+ }));
2270
+ }
2271
+ };
2272
+ export {
2273
+ ebuilderFormShortcut,
2274
+ inputFrom,
2275
+ successEnvelope
2276
+ };