openxiangda 1.0.85 → 1.0.87

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 (31) hide show
  1. package/README.md +28 -0
  2. package/lib/cli.js +482 -10
  3. package/openxiangda-skills/SKILL.md +5 -1
  4. package/openxiangda-skills/references/architecture-design.md +29 -0
  5. package/openxiangda-skills/references/openxiangda-api.md +105 -3
  6. package/openxiangda-skills/references/pages/page-sdk.md +35 -0
  7. package/openxiangda-skills/references/permissions-settings.md +39 -2
  8. package/openxiangda-skills/references/resource-manifest-cheatsheet.md +70 -4
  9. package/package.json +2 -1
  10. package/packages/sdk/dist/runtime/index.cjs +3590 -3388
  11. package/packages/sdk/dist/runtime/index.cjs.map +1 -1
  12. package/packages/sdk/dist/runtime/index.d.mts +4 -1001
  13. package/packages/sdk/dist/runtime/index.d.ts +4 -1001
  14. package/packages/sdk/dist/runtime/index.mjs +3049 -2849
  15. package/packages/sdk/dist/runtime/index.mjs.map +1 -1
  16. package/packages/sdk/dist/runtime/react.cjs +2793 -116
  17. package/packages/sdk/dist/runtime/react.cjs.map +1 -1
  18. package/packages/sdk/dist/runtime/react.d.mts +1394 -2
  19. package/packages/sdk/dist/runtime/react.d.ts +1394 -2
  20. package/packages/sdk/dist/runtime/react.mjs +2749 -84
  21. package/packages/sdk/dist/runtime/react.mjs.map +1 -1
  22. package/templates/openxiangda-react-spa/AGENTS.md +29 -0
  23. package/templates/openxiangda-react-spa/src/app/router.tsx +21 -1
  24. package/templates/openxiangda-react-spa/src/pages/public/PublicRegisterPage.tsx +15 -0
  25. package/templates/openxiangda-react-spa/src/resources/permissions/page-groups/public-visitor.json +8 -0
  26. package/templates/openxiangda-react-spa/src/resources/public-access/public-register.json +14 -0
  27. package/templates/openxiangda-react-spa/src/resources/routes/public-register.json +8 -0
  28. package/templates/openxiangda-react-spa/tsconfig.app.json +1 -1
  29. package/templates/openxiangda-react-spa/vite.config.ts +1 -1
  30. package/packages/sdk/dist/openxiangdaProvider-CaXMpsnK.d.mts +0 -328
  31. package/packages/sdk/dist/openxiangdaProvider-CaXMpsnK.d.ts +0 -328
@@ -1,11 +1,2462 @@
1
+ // packages/sdk/src/runtime/react/createReactPage.tsx
2
+ import { StyleProvider } from "@ant-design/cssinjs";
3
+ import { App as AntdApp, ConfigProvider, message } from "antd";
4
+ import zhCN from "antd/locale/zh_CN.js";
5
+ import dayjs3 from "dayjs";
6
+
7
+ // node_modules/dayjs/esm/constant.js
8
+ var SECONDS_A_MINUTE = 60;
9
+ var SECONDS_A_HOUR = SECONDS_A_MINUTE * 60;
10
+ var SECONDS_A_DAY = SECONDS_A_HOUR * 24;
11
+ var SECONDS_A_WEEK = SECONDS_A_DAY * 7;
12
+ var MILLISECONDS_A_SECOND = 1e3;
13
+ var MILLISECONDS_A_MINUTE = SECONDS_A_MINUTE * MILLISECONDS_A_SECOND;
14
+ var MILLISECONDS_A_HOUR = SECONDS_A_HOUR * MILLISECONDS_A_SECOND;
15
+ var MILLISECONDS_A_DAY = SECONDS_A_DAY * MILLISECONDS_A_SECOND;
16
+ var MILLISECONDS_A_WEEK = SECONDS_A_WEEK * MILLISECONDS_A_SECOND;
17
+ var MS = "millisecond";
18
+ var S = "second";
19
+ var MIN = "minute";
20
+ var H = "hour";
21
+ var D = "day";
22
+ var W = "week";
23
+ var M = "month";
24
+ var Q = "quarter";
25
+ var Y = "year";
26
+ var DATE = "date";
27
+ var FORMAT_DEFAULT = "YYYY-MM-DDTHH:mm:ssZ";
28
+ var INVALID_DATE_STRING = "Invalid Date";
29
+ var REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/;
30
+ var REGEX_FORMAT = /\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;
31
+
32
+ // node_modules/dayjs/esm/locale/en.js
33
+ var en_default = {
34
+ name: "en",
35
+ weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
36
+ months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
37
+ ordinal: function ordinal(n) {
38
+ var s = ["th", "st", "nd", "rd"];
39
+ var v = n % 100;
40
+ return "[" + n + (s[(v - 20) % 10] || s[v] || s[0]) + "]";
41
+ }
42
+ };
43
+
44
+ // node_modules/dayjs/esm/utils.js
45
+ var padStart = function padStart2(string, length, pad) {
46
+ var s = String(string);
47
+ if (!s || s.length >= length) return string;
48
+ return "" + Array(length + 1 - s.length).join(pad) + string;
49
+ };
50
+ var padZoneStr = function padZoneStr2(instance) {
51
+ var negMinutes = -instance.utcOffset();
52
+ var minutes = Math.abs(negMinutes);
53
+ var hourOffset = Math.floor(minutes / 60);
54
+ var minuteOffset = minutes % 60;
55
+ return (negMinutes <= 0 ? "+" : "-") + padStart(hourOffset, 2, "0") + ":" + padStart(minuteOffset, 2, "0");
56
+ };
57
+ var monthDiff = function monthDiff2(a, b) {
58
+ if (a.date() < b.date()) return -monthDiff2(b, a);
59
+ var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month());
60
+ var anchor = a.clone().add(wholeMonthDiff, M);
61
+ var c = b - anchor < 0;
62
+ var anchor2 = a.clone().add(wholeMonthDiff + (c ? -1 : 1), M);
63
+ return +(-(wholeMonthDiff + (b - anchor) / (c ? anchor - anchor2 : anchor2 - anchor)) || 0);
64
+ };
65
+ var absFloor = function absFloor2(n) {
66
+ return n < 0 ? Math.ceil(n) || 0 : Math.floor(n);
67
+ };
68
+ var prettyUnit = function prettyUnit2(u) {
69
+ var special = {
70
+ M,
71
+ y: Y,
72
+ w: W,
73
+ d: D,
74
+ D: DATE,
75
+ h: H,
76
+ m: MIN,
77
+ s: S,
78
+ ms: MS,
79
+ Q
80
+ };
81
+ return special[u] || String(u || "").toLowerCase().replace(/s$/, "");
82
+ };
83
+ var isUndefined = function isUndefined2(s) {
84
+ return s === void 0;
85
+ };
86
+ var utils_default = {
87
+ s: padStart,
88
+ z: padZoneStr,
89
+ m: monthDiff,
90
+ a: absFloor,
91
+ p: prettyUnit,
92
+ u: isUndefined
93
+ };
94
+
95
+ // node_modules/dayjs/esm/index.js
96
+ var L = "en";
97
+ var Ls = {};
98
+ Ls[L] = en_default;
99
+ var IS_DAYJS = "$isDayjsObject";
100
+ var isDayjs = function isDayjs2(d) {
101
+ return d instanceof Dayjs || !!(d && d[IS_DAYJS]);
102
+ };
103
+ var parseLocale = function parseLocale2(preset, object, isLocal) {
104
+ var l;
105
+ if (!preset) return L;
106
+ if (typeof preset === "string") {
107
+ var presetLower = preset.toLowerCase();
108
+ if (Ls[presetLower]) {
109
+ l = presetLower;
110
+ }
111
+ if (object) {
112
+ Ls[presetLower] = object;
113
+ l = presetLower;
114
+ }
115
+ var presetSplit = preset.split("-");
116
+ if (!l && presetSplit.length > 1) {
117
+ return parseLocale2(presetSplit[0]);
118
+ }
119
+ } else {
120
+ var name = preset.name;
121
+ Ls[name] = preset;
122
+ l = name;
123
+ }
124
+ if (!isLocal && l) L = l;
125
+ return l || !isLocal && L;
126
+ };
127
+ var dayjs = function dayjs2(date, c) {
128
+ if (isDayjs(date)) {
129
+ return date.clone();
130
+ }
131
+ var cfg = typeof c === "object" ? c : {};
132
+ cfg.date = date;
133
+ cfg.args = arguments;
134
+ return new Dayjs(cfg);
135
+ };
136
+ var wrapper = function wrapper2(date, instance) {
137
+ return dayjs(date, {
138
+ locale: instance.$L,
139
+ utc: instance.$u,
140
+ x: instance.$x,
141
+ $offset: instance.$offset
142
+ // todo: refactor; do not use this.$offset in you code
143
+ });
144
+ };
145
+ var Utils = utils_default;
146
+ Utils.l = parseLocale;
147
+ Utils.i = isDayjs;
148
+ Utils.w = wrapper;
149
+ var parseDate = function parseDate2(cfg) {
150
+ var date = cfg.date, utc = cfg.utc;
151
+ if (date === null) return /* @__PURE__ */ new Date(NaN);
152
+ if (Utils.u(date)) return /* @__PURE__ */ new Date();
153
+ if (date instanceof Date) return new Date(date);
154
+ if (typeof date === "string" && !/Z$/i.test(date)) {
155
+ var d = date.match(REGEX_PARSE);
156
+ if (d) {
157
+ var m = d[2] - 1 || 0;
158
+ var ms = (d[7] || "0").substring(0, 3);
159
+ if (utc) {
160
+ return new Date(Date.UTC(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms));
161
+ }
162
+ return new Date(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms);
163
+ }
164
+ }
165
+ return new Date(date);
166
+ };
167
+ var Dayjs = /* @__PURE__ */ (function() {
168
+ function Dayjs2(cfg) {
169
+ this.$L = parseLocale(cfg.locale, null, true);
170
+ this.parse(cfg);
171
+ this.$x = this.$x || cfg.x || {};
172
+ this[IS_DAYJS] = true;
173
+ }
174
+ var _proto = Dayjs2.prototype;
175
+ _proto.parse = function parse(cfg) {
176
+ this.$d = parseDate(cfg);
177
+ this.init();
178
+ };
179
+ _proto.init = function init() {
180
+ var $d = this.$d;
181
+ this.$y = $d.getFullYear();
182
+ this.$M = $d.getMonth();
183
+ this.$D = $d.getDate();
184
+ this.$W = $d.getDay();
185
+ this.$H = $d.getHours();
186
+ this.$m = $d.getMinutes();
187
+ this.$s = $d.getSeconds();
188
+ this.$ms = $d.getMilliseconds();
189
+ };
190
+ _proto.$utils = function $utils() {
191
+ return Utils;
192
+ };
193
+ _proto.isValid = function isValid() {
194
+ return !(this.$d.toString() === INVALID_DATE_STRING);
195
+ };
196
+ _proto.isSame = function isSame(that, units) {
197
+ var other = dayjs(that);
198
+ return this.startOf(units) <= other && other <= this.endOf(units);
199
+ };
200
+ _proto.isAfter = function isAfter(that, units) {
201
+ return dayjs(that) < this.startOf(units);
202
+ };
203
+ _proto.isBefore = function isBefore(that, units) {
204
+ return this.endOf(units) < dayjs(that);
205
+ };
206
+ _proto.$g = function $g(input, get, set) {
207
+ if (Utils.u(input)) return this[get];
208
+ return this.set(set, input);
209
+ };
210
+ _proto.unix = function unix() {
211
+ return Math.floor(this.valueOf() / 1e3);
212
+ };
213
+ _proto.valueOf = function valueOf() {
214
+ return this.$d.getTime();
215
+ };
216
+ _proto.startOf = function startOf(units, _startOf) {
217
+ var _this = this;
218
+ var isStartOf = !Utils.u(_startOf) ? _startOf : true;
219
+ var unit = Utils.p(units);
220
+ var instanceFactory = function instanceFactory2(d, m) {
221
+ var ins = Utils.w(_this.$u ? Date.UTC(_this.$y, m, d) : new Date(_this.$y, m, d), _this);
222
+ return isStartOf ? ins : ins.endOf(D);
223
+ };
224
+ var instanceFactorySet = function instanceFactorySet2(method, slice) {
225
+ var argumentStart = [0, 0, 0, 0];
226
+ var argumentEnd = [23, 59, 59, 999];
227
+ return Utils.w(_this.toDate()[method].apply(
228
+ // eslint-disable-line prefer-spread
229
+ _this.toDate("s"),
230
+ (isStartOf ? argumentStart : argumentEnd).slice(slice)
231
+ ), _this);
232
+ };
233
+ var $W = this.$W, $M = this.$M, $D = this.$D;
234
+ var utcPad = "set" + (this.$u ? "UTC" : "");
235
+ switch (unit) {
236
+ case Y:
237
+ return isStartOf ? instanceFactory(1, 0) : instanceFactory(31, 11);
238
+ case M:
239
+ return isStartOf ? instanceFactory(1, $M) : instanceFactory(0, $M + 1);
240
+ case W: {
241
+ var weekStart = this.$locale().weekStart || 0;
242
+ var gap = ($W < weekStart ? $W + 7 : $W) - weekStart;
243
+ return instanceFactory(isStartOf ? $D - gap : $D + (6 - gap), $M);
244
+ }
245
+ case D:
246
+ case DATE:
247
+ return instanceFactorySet(utcPad + "Hours", 0);
248
+ case H:
249
+ return instanceFactorySet(utcPad + "Minutes", 1);
250
+ case MIN:
251
+ return instanceFactorySet(utcPad + "Seconds", 2);
252
+ case S:
253
+ return instanceFactorySet(utcPad + "Milliseconds", 3);
254
+ default:
255
+ return this.clone();
256
+ }
257
+ };
258
+ _proto.endOf = function endOf(arg) {
259
+ return this.startOf(arg, false);
260
+ };
261
+ _proto.$set = function $set(units, _int) {
262
+ var _C$D$C$DATE$C$M$C$Y$C;
263
+ var unit = Utils.p(units);
264
+ var utcPad = "set" + (this.$u ? "UTC" : "");
265
+ var name = (_C$D$C$DATE$C$M$C$Y$C = {}, _C$D$C$DATE$C$M$C$Y$C[D] = utcPad + "Date", _C$D$C$DATE$C$M$C$Y$C[DATE] = utcPad + "Date", _C$D$C$DATE$C$M$C$Y$C[M] = utcPad + "Month", _C$D$C$DATE$C$M$C$Y$C[Y] = utcPad + "FullYear", _C$D$C$DATE$C$M$C$Y$C[H] = utcPad + "Hours", _C$D$C$DATE$C$M$C$Y$C[MIN] = utcPad + "Minutes", _C$D$C$DATE$C$M$C$Y$C[S] = utcPad + "Seconds", _C$D$C$DATE$C$M$C$Y$C[MS] = utcPad + "Milliseconds", _C$D$C$DATE$C$M$C$Y$C)[unit];
266
+ var arg = unit === D ? this.$D + (_int - this.$W) : _int;
267
+ if (unit === M || unit === Y) {
268
+ var date = this.clone().set(DATE, 1);
269
+ date.$d[name](arg);
270
+ date.init();
271
+ this.$d = date.set(DATE, Math.min(this.$D, date.daysInMonth())).$d;
272
+ } else if (name) this.$d[name](arg);
273
+ this.init();
274
+ return this;
275
+ };
276
+ _proto.set = function set(string, _int2) {
277
+ return this.clone().$set(string, _int2);
278
+ };
279
+ _proto.get = function get(unit) {
280
+ return this[Utils.p(unit)]();
281
+ };
282
+ _proto.add = function add(number, units) {
283
+ var _this2 = this, _C$MIN$C$H$C$S$unit;
284
+ number = Number(number);
285
+ var unit = Utils.p(units);
286
+ var instanceFactorySet = function instanceFactorySet2(n) {
287
+ var d = dayjs(_this2);
288
+ return Utils.w(d.date(d.date() + Math.round(n * number)), _this2);
289
+ };
290
+ if (unit === M) {
291
+ return this.set(M, this.$M + number);
292
+ }
293
+ if (unit === Y) {
294
+ return this.set(Y, this.$y + number);
295
+ }
296
+ if (unit === D) {
297
+ return instanceFactorySet(1);
298
+ }
299
+ if (unit === W) {
300
+ return instanceFactorySet(7);
301
+ }
302
+ var step = (_C$MIN$C$H$C$S$unit = {}, _C$MIN$C$H$C$S$unit[MIN] = MILLISECONDS_A_MINUTE, _C$MIN$C$H$C$S$unit[H] = MILLISECONDS_A_HOUR, _C$MIN$C$H$C$S$unit[S] = MILLISECONDS_A_SECOND, _C$MIN$C$H$C$S$unit)[unit] || 1;
303
+ var nextTimeStamp = this.$d.getTime() + number * step;
304
+ return Utils.w(nextTimeStamp, this);
305
+ };
306
+ _proto.subtract = function subtract(number, string) {
307
+ return this.add(number * -1, string);
308
+ };
309
+ _proto.format = function format(formatStr) {
310
+ var _this3 = this;
311
+ var locale2 = this.$locale();
312
+ if (!this.isValid()) return locale2.invalidDate || INVALID_DATE_STRING;
313
+ var str = formatStr || FORMAT_DEFAULT;
314
+ var zoneStr = Utils.z(this);
315
+ var $H = this.$H, $m = this.$m, $M = this.$M;
316
+ var weekdays = locale2.weekdays, months = locale2.months, meridiem2 = locale2.meridiem;
317
+ var getShort = function getShort2(arr, index, full, length) {
318
+ return arr && (arr[index] || arr(_this3, str)) || full[index].slice(0, length);
319
+ };
320
+ var get$H = function get$H2(num) {
321
+ return Utils.s($H % 12 || 12, num, "0");
322
+ };
323
+ var meridiemFunc = meridiem2 || function(hour, minute, isLowercase) {
324
+ var m = hour < 12 ? "AM" : "PM";
325
+ return isLowercase ? m.toLowerCase() : m;
326
+ };
327
+ var matches = function matches2(match) {
328
+ switch (match) {
329
+ case "YY":
330
+ return String(_this3.$y).slice(-2);
331
+ case "YYYY":
332
+ return Utils.s(_this3.$y, 4, "0");
333
+ case "M":
334
+ return $M + 1;
335
+ case "MM":
336
+ return Utils.s($M + 1, 2, "0");
337
+ case "MMM":
338
+ return getShort(locale2.monthsShort, $M, months, 3);
339
+ case "MMMM":
340
+ return getShort(months, $M);
341
+ case "D":
342
+ return _this3.$D;
343
+ case "DD":
344
+ return Utils.s(_this3.$D, 2, "0");
345
+ case "d":
346
+ return String(_this3.$W);
347
+ case "dd":
348
+ return getShort(locale2.weekdaysMin, _this3.$W, weekdays, 2);
349
+ case "ddd":
350
+ return getShort(locale2.weekdaysShort, _this3.$W, weekdays, 3);
351
+ case "dddd":
352
+ return weekdays[_this3.$W];
353
+ case "H":
354
+ return String($H);
355
+ case "HH":
356
+ return Utils.s($H, 2, "0");
357
+ case "h":
358
+ return get$H(1);
359
+ case "hh":
360
+ return get$H(2);
361
+ case "a":
362
+ return meridiemFunc($H, $m, true);
363
+ case "A":
364
+ return meridiemFunc($H, $m, false);
365
+ case "m":
366
+ return String($m);
367
+ case "mm":
368
+ return Utils.s($m, 2, "0");
369
+ case "s":
370
+ return String(_this3.$s);
371
+ case "ss":
372
+ return Utils.s(_this3.$s, 2, "0");
373
+ case "SSS":
374
+ return Utils.s(_this3.$ms, 3, "0");
375
+ case "Z":
376
+ return zoneStr;
377
+ // 'ZZ' logic below
378
+ default:
379
+ break;
380
+ }
381
+ return null;
382
+ };
383
+ return str.replace(REGEX_FORMAT, function(match, $1) {
384
+ return $1 || matches(match) || zoneStr.replace(":", "");
385
+ });
386
+ };
387
+ _proto.utcOffset = function utcOffset() {
388
+ return -Math.round(this.$d.getTimezoneOffset() / 15) * 15;
389
+ };
390
+ _proto.diff = function diff(input, units, _float) {
391
+ var _this4 = this;
392
+ var unit = Utils.p(units);
393
+ var that = dayjs(input);
394
+ var zoneDelta = (that.utcOffset() - this.utcOffset()) * MILLISECONDS_A_MINUTE;
395
+ var diff2 = this - that;
396
+ var getMonth = function getMonth2() {
397
+ return Utils.m(_this4, that);
398
+ };
399
+ var result;
400
+ switch (unit) {
401
+ case Y:
402
+ result = getMonth() / 12;
403
+ break;
404
+ case M:
405
+ result = getMonth();
406
+ break;
407
+ case Q:
408
+ result = getMonth() / 3;
409
+ break;
410
+ case W:
411
+ result = (diff2 - zoneDelta) / MILLISECONDS_A_WEEK;
412
+ break;
413
+ case D:
414
+ result = (diff2 - zoneDelta) / MILLISECONDS_A_DAY;
415
+ break;
416
+ case H:
417
+ result = diff2 / MILLISECONDS_A_HOUR;
418
+ break;
419
+ case MIN:
420
+ result = diff2 / MILLISECONDS_A_MINUTE;
421
+ break;
422
+ case S:
423
+ result = diff2 / MILLISECONDS_A_SECOND;
424
+ break;
425
+ default:
426
+ result = diff2;
427
+ break;
428
+ }
429
+ return _float ? result : Utils.a(result);
430
+ };
431
+ _proto.daysInMonth = function daysInMonth() {
432
+ return this.endOf(M).$D;
433
+ };
434
+ _proto.$locale = function $locale() {
435
+ return Ls[this.$L];
436
+ };
437
+ _proto.locale = function locale2(preset, object) {
438
+ if (!preset) return this.$L;
439
+ var that = this.clone();
440
+ var nextLocaleName = parseLocale(preset, object, true);
441
+ if (nextLocaleName) that.$L = nextLocaleName;
442
+ return that;
443
+ };
444
+ _proto.clone = function clone() {
445
+ return Utils.w(this.$d, this);
446
+ };
447
+ _proto.toDate = function toDate() {
448
+ return new Date(this.valueOf());
449
+ };
450
+ _proto.toJSON = function toJSON() {
451
+ return this.isValid() ? this.toISOString() : null;
452
+ };
453
+ _proto.toISOString = function toISOString() {
454
+ return this.$d.toISOString();
455
+ };
456
+ _proto.toString = function toString() {
457
+ return this.$d.toUTCString();
458
+ };
459
+ return Dayjs2;
460
+ })();
461
+ var proto = Dayjs.prototype;
462
+ dayjs.prototype = proto;
463
+ [["$ms", MS], ["$s", S], ["$m", MIN], ["$H", H], ["$W", D], ["$M", M], ["$y", Y], ["$D", DATE]].forEach(function(g) {
464
+ proto[g[1]] = function(input) {
465
+ return this.$g(input, g[0], g[1]);
466
+ };
467
+ });
468
+ dayjs.extend = function(plugin, option) {
469
+ if (!plugin.$i) {
470
+ plugin(option, Dayjs, dayjs);
471
+ plugin.$i = true;
472
+ }
473
+ return dayjs;
474
+ };
475
+ dayjs.locale = parseLocale;
476
+ dayjs.isDayjs = isDayjs;
477
+ dayjs.unix = function(timestamp) {
478
+ return dayjs(timestamp * 1e3);
479
+ };
480
+ dayjs.en = Ls[L];
481
+ dayjs.Ls = Ls;
482
+ dayjs.p = {};
483
+ var esm_default = dayjs;
484
+
485
+ // node_modules/dayjs/esm/locale/zh-cn.js
486
+ var locale = {
487
+ name: "zh-cn",
488
+ weekdays: "\u661F\u671F\u65E5_\u661F\u671F\u4E00_\u661F\u671F\u4E8C_\u661F\u671F\u4E09_\u661F\u671F\u56DB_\u661F\u671F\u4E94_\u661F\u671F\u516D".split("_"),
489
+ weekdaysShort: "\u5468\u65E5_\u5468\u4E00_\u5468\u4E8C_\u5468\u4E09_\u5468\u56DB_\u5468\u4E94_\u5468\u516D".split("_"),
490
+ weekdaysMin: "\u65E5_\u4E00_\u4E8C_\u4E09_\u56DB_\u4E94_\u516D".split("_"),
491
+ months: "\u4E00\u6708_\u4E8C\u6708_\u4E09\u6708_\u56DB\u6708_\u4E94\u6708_\u516D\u6708_\u4E03\u6708_\u516B\u6708_\u4E5D\u6708_\u5341\u6708_\u5341\u4E00\u6708_\u5341\u4E8C\u6708".split("_"),
492
+ monthsShort: "1\u6708_2\u6708_3\u6708_4\u6708_5\u6708_6\u6708_7\u6708_8\u6708_9\u6708_10\u6708_11\u6708_12\u6708".split("_"),
493
+ ordinal: function ordinal2(number, period) {
494
+ switch (period) {
495
+ case "W":
496
+ return number + "\u5468";
497
+ default:
498
+ return number + "\u65E5";
499
+ }
500
+ },
501
+ weekStart: 1,
502
+ yearStart: 4,
503
+ formats: {
504
+ LT: "HH:mm",
505
+ LTS: "HH:mm:ss",
506
+ L: "YYYY/MM/DD",
507
+ LL: "YYYY\u5E74M\u6708D\u65E5",
508
+ LLL: "YYYY\u5E74M\u6708D\u65E5Ah\u70B9mm\u5206",
509
+ LLLL: "YYYY\u5E74M\u6708D\u65E5ddddAh\u70B9mm\u5206",
510
+ l: "YYYY/M/D",
511
+ ll: "YYYY\u5E74M\u6708D\u65E5",
512
+ lll: "YYYY\u5E74M\u6708D\u65E5 HH:mm",
513
+ llll: "YYYY\u5E74M\u6708D\u65E5dddd HH:mm"
514
+ },
515
+ relativeTime: {
516
+ future: "%s\u5185",
517
+ past: "%s\u524D",
518
+ s: "\u51E0\u79D2",
519
+ m: "1 \u5206\u949F",
520
+ mm: "%d \u5206\u949F",
521
+ h: "1 \u5C0F\u65F6",
522
+ hh: "%d \u5C0F\u65F6",
523
+ d: "1 \u5929",
524
+ dd: "%d \u5929",
525
+ M: "1 \u4E2A\u6708",
526
+ MM: "%d \u4E2A\u6708",
527
+ y: "1 \u5E74",
528
+ yy: "%d \u5E74"
529
+ },
530
+ meridiem: function meridiem(hour, minute) {
531
+ var hm = hour * 100 + minute;
532
+ if (hm < 600) {
533
+ return "\u51CC\u6668";
534
+ } else if (hm < 900) {
535
+ return "\u65E9\u4E0A";
536
+ } else if (hm < 1100) {
537
+ return "\u4E0A\u5348";
538
+ } else if (hm < 1300) {
539
+ return "\u4E2D\u5348";
540
+ } else if (hm < 1800) {
541
+ return "\u4E0B\u5348";
542
+ }
543
+ return "\u665A\u4E0A";
544
+ }
545
+ };
546
+ esm_default.locale(locale, null, true);
547
+
548
+ // packages/sdk/src/runtime/react/createReactPage.tsx
549
+ import React2 from "react";
550
+ import { createRoot } from "react-dom/client";
551
+
552
+ // packages/sdk/src/runtime/react/provider.tsx
553
+ import { useMemo } from "react";
554
+
555
+ // packages/sdk/src/runtime/react/store.ts
556
+ import { createContext, useContext } from "react";
557
+ var ReactPageContext = createContext(null);
558
+ var usePageSdkStore = () => {
559
+ const store = useContext(ReactPageContext);
560
+ if (!store) {
561
+ throw new Error("usePageSdkStore \u5FC5\u987B\u5728 PageProvider \u5185\u4F7F\u7528");
562
+ }
563
+ return store;
564
+ };
565
+
566
+ // packages/sdk/src/runtime/core/client.ts
567
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
568
+ var isSearchRuleLike = (value) => isRecord(value) && typeof value.key === "string" && (value.componentName === void 0 || typeof value.componentName === "string");
569
+ var isBlobLike = (value) => typeof Blob !== "undefined" && value instanceof Blob;
570
+ var normalizeMethod = (value) => {
571
+ const method = String(value || "get").toLowerCase();
572
+ if (method === "get" || method === "post" || method === "put" || method === "delete" || method === "patch") {
573
+ return method;
574
+ }
575
+ return "get";
576
+ };
577
+ var resolveAppType = (context, explicitAppType) => {
578
+ const appType = String(explicitAppType || context.app.appType || "").trim();
579
+ if (!appType) {
580
+ throw new Error("appType \u4E0D\u80FD\u4E3A\u7A7A");
581
+ }
582
+ return appType;
583
+ };
584
+ var buildAppPath = (context, explicitAppType, suffix) => `/${resolveAppType(context, explicitAppType)}${suffix}`;
585
+ var buildOpenXiangdaAppPath = (context, explicitAppType, suffix) => `/openxiangda-api/v1/apps/${encodePathSegment(
586
+ resolveAppType(context, explicitAppType)
587
+ )}${suffix}`;
588
+ var encodePathSegment = (value) => encodeURIComponent(String(value));
589
+ var getHeaderValue = (headers, name) => {
590
+ if (!headers) {
591
+ return void 0;
592
+ }
593
+ const target = name.toLowerCase();
594
+ const entry = Object.entries(headers).find(
595
+ ([key]) => key.toLowerCase() === target
596
+ );
597
+ return entry ? String(entry[1]) : void 0;
598
+ };
599
+ var parseContentDispositionFileName = (contentDisposition) => {
600
+ if (!contentDisposition) {
601
+ return void 0;
602
+ }
603
+ const utf8Match = contentDisposition.match(/filename\*=UTF-8''([^;]+)/i);
604
+ if (utf8Match?.[1]) {
605
+ try {
606
+ return decodeURIComponent(utf8Match[1]);
607
+ } catch {
608
+ return utf8Match[1];
609
+ }
610
+ }
611
+ const quotedMatch = contentDisposition.match(/filename="([^"]+)"/i);
612
+ if (quotedMatch?.[1]) {
613
+ return quotedMatch[1];
614
+ }
615
+ const plainMatch = contentDisposition.match(/filename=([^;]+)/i);
616
+ if (plainMatch?.[1]) {
617
+ return plainMatch[1].trim();
618
+ }
619
+ return void 0;
620
+ };
621
+ var parseConnectorCallName = (name) => {
622
+ const value = String(name || "").trim();
623
+ const separatorIndex = value.indexOf(".");
624
+ if (separatorIndex <= 0 || separatorIndex === value.length - 1) {
625
+ throw new Error("\u8FDE\u63A5\u5668\u8C03\u7528\u540D\u5FC5\u987B\u662F connector.api \u683C\u5F0F");
626
+ }
627
+ return {
628
+ connector: value.slice(0, separatorIndex),
629
+ api: value.slice(separatorIndex + 1)
630
+ };
631
+ };
632
+ var serializeQuery = (query) => {
633
+ if (!query) {
634
+ return void 0;
635
+ }
636
+ const params = new URLSearchParams();
637
+ const appendValue = (key, value) => {
638
+ if (value === void 0 || value === null || value === "") {
639
+ return;
640
+ }
641
+ if (Array.isArray(value)) {
642
+ value.forEach((item) => appendValue(key, item));
643
+ return;
644
+ }
645
+ if (value instanceof Date) {
646
+ params.append(key, value.toISOString());
647
+ return;
648
+ }
649
+ params.append(key, String(value));
650
+ };
651
+ Object.entries(query).forEach(([key, value]) => {
652
+ appendValue(key, value);
653
+ });
654
+ const serialized = params.toString();
655
+ return serialized || void 0;
656
+ };
657
+ var toLegacyRules = (value) => Object.entries(value).flatMap(([key, itemValue]) => {
658
+ if (itemValue === void 0) {
659
+ return [];
660
+ }
661
+ return [
662
+ {
663
+ key,
664
+ operator: Array.isArray(itemValue) ? "IN" : "EQ",
665
+ value: itemValue
666
+ }
667
+ ];
668
+ });
669
+ var toSearchGroup = (value) => {
670
+ if (value === void 0 || value === null || value === "") {
671
+ return void 0;
672
+ }
673
+ if (typeof value === "string") {
674
+ try {
675
+ return toSearchGroup(JSON.parse(value));
676
+ } catch {
677
+ return void 0;
678
+ }
679
+ }
680
+ if (Array.isArray(value)) {
681
+ const rules = [];
682
+ const conditions = [];
683
+ value.forEach((item) => {
684
+ const group = toSearchGroup(item);
685
+ if (group) {
686
+ if (group.rules?.length) {
687
+ rules.push(...group.rules);
688
+ }
689
+ if (group.conditions?.length) {
690
+ conditions.push(...group.conditions);
691
+ }
692
+ return;
693
+ }
694
+ if (isSearchRuleLike(item)) {
695
+ rules.push(item);
696
+ return;
697
+ }
698
+ if (isRecord(item)) {
699
+ rules.push(...toLegacyRules(item));
700
+ }
701
+ });
702
+ if (rules.length === 0 && conditions.length === 0) {
703
+ return void 0;
704
+ }
705
+ return {
706
+ logic: "AND",
707
+ ...rules.length > 0 ? { rules } : {},
708
+ ...conditions.length > 0 ? { conditions } : {}
709
+ };
710
+ }
711
+ if (isRecord(value)) {
712
+ if (isSearchRuleLike(value)) {
713
+ return {
714
+ logic: "AND",
715
+ rules: [value]
716
+ };
717
+ }
718
+ if ("rules" in value || "conditions" in value || "logic" in value) {
719
+ const nextGroup = {
720
+ logic: value.logic === "OR" || value.logic === "AND" ? value.logic : "AND"
721
+ };
722
+ if (Array.isArray(value.rules)) {
723
+ nextGroup.rules = value.rules.filter(isSearchRuleLike);
724
+ }
725
+ if (Array.isArray(value.conditions)) {
726
+ nextGroup.conditions = value.conditions.map((item) => toSearchGroup(item)).filter((item) => Boolean(item));
727
+ }
728
+ if (!nextGroup.rules?.length && !nextGroup.conditions?.length) {
729
+ return void 0;
730
+ }
731
+ return nextGroup;
732
+ }
733
+ const rules = toLegacyRules(value);
734
+ if (rules.length === 0) {
735
+ return void 0;
736
+ }
737
+ return {
738
+ logic: "AND",
739
+ rules
740
+ };
741
+ }
742
+ return void 0;
743
+ };
744
+ var mergeSearchExpressions = (base, extra) => {
745
+ const baseGroup = toSearchGroup(base);
746
+ const extraGroup = toSearchGroup(extra);
747
+ if (!baseGroup) {
748
+ return extraGroup;
749
+ }
750
+ if (!extraGroup) {
751
+ return baseGroup;
752
+ }
753
+ return {
754
+ logic: "AND",
755
+ conditions: [baseGroup, extraGroup]
756
+ };
757
+ };
758
+ var serializeSearchExpression = (value) => {
759
+ if (value === void 0 || value === null || value === "") {
760
+ return void 0;
761
+ }
762
+ if (typeof value === "string") {
763
+ return value;
764
+ }
765
+ const group = toSearchGroup(value);
766
+ return group ? JSON.stringify(group) : void 0;
767
+ };
768
+ var normalizeAdvancedOrder = (value) => {
769
+ if (!value) {
770
+ return void 0;
771
+ }
772
+ const nextValue = Array.isArray(value) ? value : [value];
773
+ return JSON.stringify(nextValue);
774
+ };
775
+ var normalizeDynamicOrder = (value) => {
776
+ if (!value) {
777
+ return void 0;
778
+ }
779
+ if (typeof value === "string") {
780
+ return value;
781
+ }
782
+ return `${value.id}:${value.isAsc === "n" ? "-" : "+"}`;
783
+ };
784
+ var normalizeJsonResponse = (rawResponse) => {
785
+ const topLevelCode = Number(rawResponse?.code);
786
+ const nestedCode = Number(
787
+ rawResponse?.data?.code
788
+ );
789
+ const code = Number.isFinite(topLevelCode) ? topLevelCode : Number.isFinite(nestedCode) ? nestedCode : 200;
790
+ const topLevelResult = isRecord(rawResponse) && "result" in rawResponse ? rawResponse.result : void 0;
791
+ const nestedResult = isRecord(rawResponse?.data) && "result" in (rawResponse.data || {}) ? rawResponse.data?.result : void 0;
792
+ const topLevelData = isRecord(rawResponse) && "data" in rawResponse ? rawResponse.data : void 0;
793
+ const result = topLevelResult !== void 0 ? topLevelResult : nestedResult !== void 0 ? nestedResult : topLevelData !== void 0 ? topLevelData : isRecord(rawResponse) ? rawResponse : null;
794
+ const nestedSuccess = typeof rawResponse?.data?.success === "boolean" ? rawResponse.data?.success : void 0;
795
+ const success = typeof rawResponse?.success === "boolean" ? Boolean(rawResponse.success) : typeof nestedSuccess === "boolean" ? Boolean(nestedSuccess) : code >= 200 && code < 300;
796
+ return {
797
+ code,
798
+ success,
799
+ message: typeof rawResponse?.message === "string" ? rawResponse.message : typeof rawResponse?.data?.message === "string" ? rawResponse.data?.message : void 0,
800
+ result,
801
+ data: topLevelData !== void 0 ? topLevelData : topLevelResult !== void 0 ? topLevelResult : void 0,
802
+ raw: rawResponse
803
+ };
804
+ };
805
+ var normalizeBinaryResponse = (rawResponse) => {
806
+ if (isRecord(rawResponse) && isBlobLike(rawResponse.blob)) {
807
+ return rawResponse;
808
+ }
809
+ if (isBlobLike(rawResponse)) {
810
+ return {
811
+ blob: rawResponse,
812
+ raw: rawResponse
813
+ };
814
+ }
815
+ const responseData = rawResponse?.data;
816
+ const responseHeaders = isRecord(
817
+ rawResponse?.headers
818
+ ) ? rawResponse.headers : void 0;
819
+ if (!isBlobLike(responseData)) {
820
+ throw new Error("transport.download \u672A\u8FD4\u56DE Blob \u6570\u636E");
821
+ }
822
+ const contentDisposition = getHeaderValue(
823
+ responseHeaders,
824
+ "content-disposition"
825
+ );
826
+ return {
827
+ blob: responseData,
828
+ fileName: parseContentDispositionFileName(contentDisposition),
829
+ contentType: getHeaderValue(responseHeaders, "content-type") || responseData.type,
830
+ headers: responseHeaders ? Object.fromEntries(
831
+ Object.entries(responseHeaders).map(([key, value]) => [
832
+ key,
833
+ value === void 0 ? void 0 : String(value)
834
+ ])
835
+ ) : void 0,
836
+ raw: rawResponse
837
+ };
838
+ };
839
+ var toSdkError = (input, payload) => {
840
+ const normalizedResponse = isRecord(input) ? normalizeJsonResponse(input) : void 0;
841
+ const nextError = input instanceof Error ? input : new Error(
842
+ normalizedResponse?.message || `\u8BF7\u6C42\u5931\u8D25: ${String(payload.method).toUpperCase()} ${payload.path}`
843
+ );
844
+ const sdkError = nextError;
845
+ sdkError.method = String(payload.method).toUpperCase();
846
+ sdkError.path = payload.path;
847
+ sdkError.response = normalizedResponse;
848
+ sdkError.raw = input;
849
+ return sdkError;
850
+ };
851
+ var ensureSuccess = (response, payload) => {
852
+ if (!response.success) {
853
+ throw toSdkError(response, payload);
854
+ }
855
+ return response;
856
+ };
857
+ var resolveFormInstanceId = (params) => {
858
+ const formInstanceId = String(
859
+ params.formInstId || params.formInstanceId || ""
860
+ ).trim();
861
+ if (!formInstanceId) {
862
+ throw new Error("formInstanceId \u4E0D\u80FD\u4E3A\u7A7A");
863
+ }
864
+ return formInstanceId;
865
+ };
866
+ var withDefaultAppType = (context, params) => {
867
+ if (!params) {
868
+ return params;
869
+ }
870
+ if (params.appType) {
871
+ return params;
872
+ }
873
+ if (params.scope === "app") {
874
+ return {
875
+ ...params,
876
+ appType: context.app.appType
877
+ };
878
+ }
879
+ return params;
880
+ };
881
+ var AUTH_LOGIN_URL_ENV_KEYS = [
882
+ "loginUrl",
883
+ "authLoginUrl",
884
+ "bathAuthUrl",
885
+ "REACT_APP_VITE_BATH_AUTH_URL",
886
+ "VITE_BATH_AUTH_URL",
887
+ "BATH_AUTH_URL"
888
+ ];
889
+ var DEFAULT_PLATFORM_LOGIN_URL = "/platform/login";
890
+ var normalizeOptionalString = (value) => {
891
+ const text = typeof value === "string" ? value.trim() : "";
892
+ return text || void 0;
893
+ };
894
+ var getCurrentHref = () => {
895
+ if (typeof window === "undefined") {
896
+ return "";
897
+ }
898
+ return window.location?.href || "";
899
+ };
900
+ var resolveAuthLoginUrl = (context, options) => {
901
+ const explicitLoginUrl = normalizeOptionalString(options.loginUrl);
902
+ if (explicitLoginUrl) {
903
+ return explicitLoginUrl;
904
+ }
905
+ for (const key of AUTH_LOGIN_URL_ENV_KEYS) {
906
+ const loginUrl = normalizeOptionalString(context.env?.[key]);
907
+ if (loginUrl) {
908
+ return loginUrl;
909
+ }
910
+ }
911
+ return void 0;
912
+ };
913
+ var buildAuthRedirectUrl = (loginUrl, callbackUrl, callbackParamName) => {
914
+ const paramName = normalizeOptionalString(callbackParamName) || "callback";
915
+ const normalizedCallbackUrl = normalizeOptionalString(callbackUrl);
916
+ if (!normalizedCallbackUrl) {
917
+ return loginUrl;
918
+ }
919
+ const baseHref = getCurrentHref() || "http://localhost/";
920
+ const isAbsoluteUrl = /^[a-z][a-z\d+.-]*:/i.test(loginUrl);
921
+ const isProtocolRelativeUrl = loginUrl.startsWith("//");
922
+ const isRootRelativeUrl = loginUrl.startsWith("/");
923
+ try {
924
+ const url = new URL(loginUrl, baseHref);
925
+ url.searchParams.set(paramName, normalizedCallbackUrl);
926
+ if (isAbsoluteUrl || isProtocolRelativeUrl) {
927
+ return url.toString();
928
+ }
929
+ const path = `${url.pathname}${url.search}${url.hash}`;
930
+ return isRootRelativeUrl ? path : path.replace(/^\//, "");
931
+ } catch {
932
+ const hashIndex = loginUrl.indexOf("#");
933
+ const pathAndQuery = hashIndex >= 0 ? loginUrl.slice(0, hashIndex) : loginUrl;
934
+ const hash = hashIndex >= 0 ? loginUrl.slice(hashIndex) : "";
935
+ const separator = pathAndQuery.includes("?") ? "&" : "?";
936
+ return `${pathAndQuery}${separator}${encodeURIComponent(
937
+ paramName
938
+ )}=${encodeURIComponent(normalizedCallbackUrl)}${hash}`;
939
+ }
940
+ };
941
+ var performRedirect = (url, options) => {
942
+ if (options.redirect) {
943
+ options.redirect(url);
944
+ return;
945
+ }
946
+ if (typeof window === "undefined" || !window.location) {
947
+ return;
948
+ }
949
+ if (options.replace && typeof window.location.replace === "function") {
950
+ window.location.replace(url);
951
+ return;
952
+ }
953
+ window.location.href = url;
954
+ };
955
+ var reloadCurrentPage = () => {
956
+ if (typeof window === "undefined" || !window.location || typeof window.location.reload !== "function") {
957
+ return;
958
+ }
959
+ window.location.reload();
960
+ };
961
+ var redirectAfterLogout = (context, options) => {
962
+ const loginUrl = resolveAuthLoginUrl(context, options);
963
+ const callbackUrl = normalizeOptionalString(options.callbackUrl) || getCurrentHref();
964
+ if (loginUrl) {
965
+ performRedirect(
966
+ buildAuthRedirectUrl(loginUrl, callbackUrl, options.callbackParamName),
967
+ options
968
+ );
969
+ return;
970
+ }
971
+ if (options.fallback === "none") {
972
+ return;
973
+ }
974
+ if (options.fallback === "reload") {
975
+ reloadCurrentPage();
976
+ return;
977
+ }
978
+ const redirectLoginUrl = DEFAULT_PLATFORM_LOGIN_URL;
979
+ performRedirect(
980
+ buildAuthRedirectUrl(redirectLoginUrl, callbackUrl, options.callbackParamName),
981
+ options
982
+ );
983
+ };
984
+ var createPageSdk = (context) => {
985
+ const request = async (options) => {
986
+ const payload = {
987
+ path: options.path,
988
+ method: normalizeMethod(options.method),
989
+ query: serializeQuery(options.query),
990
+ body: options.body,
991
+ headers: options.headers
992
+ };
993
+ try {
994
+ const rawResponse = await context.bridge.invoke(
995
+ "transport.request",
996
+ payload
997
+ );
998
+ return ensureSuccess(
999
+ normalizeJsonResponse(rawResponse),
1000
+ payload
1001
+ );
1002
+ } catch (error) {
1003
+ throw toSdkError(error, payload);
1004
+ }
1005
+ };
1006
+ const download = async (options) => {
1007
+ const payload = {
1008
+ path: options.path,
1009
+ method: normalizeMethod(options.method),
1010
+ query: serializeQuery(options.query),
1011
+ body: options.body,
1012
+ headers: options.headers
1013
+ };
1014
+ try {
1015
+ const rawResponse = await context.bridge.invoke(
1016
+ "transport.download",
1017
+ payload
1018
+ );
1019
+ return normalizeBinaryResponse(rawResponse);
1020
+ } catch (error) {
1021
+ throw toSdkError(error, payload);
1022
+ }
1023
+ };
1024
+ const logout = () => request({
1025
+ path: "/api/auth/logout",
1026
+ method: "post"
1027
+ });
1028
+ const auth = {
1029
+ logout,
1030
+ logoutAndRedirect: async (options = {}) => {
1031
+ try {
1032
+ const response = await logout();
1033
+ redirectAfterLogout(context, options);
1034
+ return response;
1035
+ } catch (error) {
1036
+ if (options.continueOnLogoutError === false) {
1037
+ throw error;
1038
+ }
1039
+ redirectAfterLogout(context, options);
1040
+ return null;
1041
+ }
1042
+ }
1043
+ };
1044
+ const connector = {
1045
+ invoke: (params) => request({
1046
+ path: buildAppPath(
1047
+ context,
1048
+ params.appType,
1049
+ "/v1/connectors/actions/invoke"
1050
+ ),
1051
+ method: "post",
1052
+ body: {
1053
+ connector: params.connector,
1054
+ api: params.api,
1055
+ pathParams: params.pathParams,
1056
+ query: params.query,
1057
+ body: params.body,
1058
+ headers: params.headers,
1059
+ requestBodyType: params.requestBodyType,
1060
+ responseType: params.responseType
1061
+ }
1062
+ }),
1063
+ call: (name, params = {}) => {
1064
+ const target = parseConnectorCallName(name);
1065
+ return connector.invoke({
1066
+ ...params,
1067
+ connector: target.connector,
1068
+ api: target.api
1069
+ });
1070
+ },
1071
+ download: (params) => download({
1072
+ path: buildAppPath(
1073
+ context,
1074
+ params.appType,
1075
+ "/v1/connectors/actions/download"
1076
+ ),
1077
+ method: "post",
1078
+ body: {
1079
+ connector: params.connector,
1080
+ api: params.api,
1081
+ pathParams: params.pathParams,
1082
+ query: params.query,
1083
+ body: params.body,
1084
+ headers: params.headers,
1085
+ requestBodyType: params.requestBodyType,
1086
+ responseType: "binary"
1087
+ }
1088
+ })
1089
+ };
1090
+ const form = {
1091
+ getDetail: (params) => request({
1092
+ path: buildAppPath(
1093
+ context,
1094
+ params.appType,
1095
+ "/v1/form/getFormDataById.json"
1096
+ ),
1097
+ method: "get",
1098
+ query: {
1099
+ formUuid: params.formUuid,
1100
+ formInstId: resolveFormInstanceId(params)
1101
+ }
1102
+ }),
1103
+ create: (params) => request({
1104
+ path: buildAppPath(
1105
+ context,
1106
+ params.appType,
1107
+ "/v1/form/saveFormData.json"
1108
+ ),
1109
+ method: "post",
1110
+ body: {
1111
+ formUuid: params.formUuid,
1112
+ formDataJson: JSON.stringify(params.data || {})
1113
+ }
1114
+ }),
1115
+ update: (params) => request({
1116
+ path: buildAppPath(
1117
+ context,
1118
+ params.appType,
1119
+ "/v1/form/updateFormData.json"
1120
+ ),
1121
+ method: "post",
1122
+ body: {
1123
+ formUuid: params.formUuid,
1124
+ formInstId: resolveFormInstanceId(params),
1125
+ updateFormDataJson: params.updateFormDataJson || JSON.stringify(params.data || {})
1126
+ }
1127
+ }),
1128
+ remove: (params) => request({
1129
+ path: buildAppPath(
1130
+ context,
1131
+ params.appType,
1132
+ "/v1/form/deleteFormData.json"
1133
+ ),
1134
+ method: "post",
1135
+ body: {
1136
+ formUuid: params.formUuid,
1137
+ formInstId: resolveFormInstanceId(params)
1138
+ }
1139
+ }),
1140
+ getChangeRecords: (params) => request({
1141
+ path: buildAppPath(
1142
+ context,
1143
+ params.appType,
1144
+ "/v1/form/getFormDataChangeRecords.json"
1145
+ ),
1146
+ method: "get",
1147
+ query: {
1148
+ formUuid: params.formUuid,
1149
+ formInstId: resolveFormInstanceId(params),
1150
+ page: params.page,
1151
+ pageSize: params.pageSize
1152
+ }
1153
+ }),
1154
+ search: (params) => request({
1155
+ path: buildAppPath(
1156
+ context,
1157
+ params.appType,
1158
+ "/v1/form/searchFormDatas.json"
1159
+ ),
1160
+ method: "get",
1161
+ query: {
1162
+ formUuid: params.formUuid,
1163
+ searchFieldJson: serializeSearchExpression(params.search),
1164
+ currentPage: params.currentPage,
1165
+ pageSize: params.pageSize,
1166
+ originatorId: params.originatorId,
1167
+ createFrom: params.createFrom,
1168
+ createTo: params.createTo,
1169
+ modifiedFrom: params.modifiedFrom,
1170
+ modifiedTo: params.modifiedTo,
1171
+ dynamicOrder: normalizeDynamicOrder(params.dynamicOrder),
1172
+ instanceStatus: params.instanceStatus
1173
+ }
1174
+ }),
1175
+ searchIds: (params) => request({
1176
+ path: buildAppPath(
1177
+ context,
1178
+ params.appType,
1179
+ "/v1/form/searchFormDataIds.json"
1180
+ ),
1181
+ method: "get",
1182
+ query: {
1183
+ formUuid: params.formUuid,
1184
+ searchFieldJson: serializeSearchExpression(params.search),
1185
+ currentPage: params.currentPage,
1186
+ pageSize: params.pageSize,
1187
+ originatorId: params.originatorId,
1188
+ createFrom: params.createFrom,
1189
+ createTo: params.createTo,
1190
+ modifiedFrom: params.modifiedFrom,
1191
+ modifiedTo: params.modifiedTo,
1192
+ dynamicOrder: normalizeDynamicOrder(params.dynamicOrder),
1193
+ instanceStatus: params.instanceStatus
1194
+ }
1195
+ }),
1196
+ advancedSearch: (params) => request({
1197
+ path: buildAppPath(
1198
+ context,
1199
+ params.appType,
1200
+ "/v1/form/advancedSearch.json"
1201
+ ),
1202
+ method: "get",
1203
+ query: {
1204
+ formUuid: params.formUuid,
1205
+ filters: serializeSearchExpression(params.filters),
1206
+ conditionType: params.conditionType,
1207
+ searchKeyWord: params.searchKeyWord,
1208
+ currentPage: params.currentPage,
1209
+ pageSize: params.pageSize,
1210
+ order: normalizeAdvancedOrder(params.order),
1211
+ instanceStatus: params.instanceStatus
1212
+ }
1213
+ }),
1214
+ advancedExport: (params) => download({
1215
+ path: buildAppPath(
1216
+ context,
1217
+ params.appType,
1218
+ "/v1/form/advancedExport.xlsx"
1219
+ ),
1220
+ method: "get",
1221
+ query: {
1222
+ formUuid: params.formUuid,
1223
+ filters: serializeSearchExpression(params.filters),
1224
+ conditionType: params.conditionType,
1225
+ searchKeyWord: params.searchKeyWord,
1226
+ currentPage: params.currentPage,
1227
+ pageSize: params.pageSize,
1228
+ order: normalizeAdvancedOrder(params.order),
1229
+ instanceStatus: params.instanceStatus,
1230
+ exportAll: params.exportAll,
1231
+ embedImages: params.embedImages,
1232
+ exportFields: params.exportFields?.join(",")
1233
+ }
1234
+ }),
1235
+ downloadImportTemplate: (params) => download({
1236
+ path: buildAppPath(
1237
+ context,
1238
+ params.appType,
1239
+ "/v1/form/advancedExportTemplate.xlsx"
1240
+ ),
1241
+ method: "get",
1242
+ query: {
1243
+ formUuid: params.formUuid
1244
+ }
1245
+ }),
1246
+ importPreview: (params) => request({
1247
+ path: buildAppPath(
1248
+ context,
1249
+ params.appType,
1250
+ "/v1/form/importPreview.xlsx"
1251
+ ),
1252
+ method: "post",
1253
+ body: {
1254
+ formUuid: params.formUuid,
1255
+ fileBase64: params.fileBase64,
1256
+ fileName: params.fileName
1257
+ }
1258
+ }),
1259
+ importExcel: (params) => request({
1260
+ path: buildAppPath(context, params.appType, "/v1/form/import.xlsx"),
1261
+ method: "post",
1262
+ body: {
1263
+ formUuid: params.formUuid,
1264
+ fileBase64: params.fileBase64,
1265
+ fileName: params.fileName
1266
+ }
1267
+ }),
1268
+ getImportRecords: (params) => request({
1269
+ path: buildAppPath(
1270
+ context,
1271
+ params.appType,
1272
+ "/v1/form/importRecords.json"
1273
+ ),
1274
+ method: "get",
1275
+ query: {
1276
+ formUuid: params.formUuid,
1277
+ currentPage: params.currentPage,
1278
+ pageSize: params.pageSize
1279
+ }
1280
+ }),
1281
+ getExportRecords: (params) => request({
1282
+ path: buildAppPath(
1283
+ context,
1284
+ params.appType,
1285
+ "/v1/form/exportRecords.json"
1286
+ ),
1287
+ method: "get",
1288
+ query: {
1289
+ formUuid: params.formUuid,
1290
+ currentPage: params.currentPage,
1291
+ pageSize: params.pageSize
1292
+ }
1293
+ }),
1294
+ downloadImportSource: (params) => download({
1295
+ path: buildAppPath(
1296
+ context,
1297
+ params.appType,
1298
+ "/v1/form/importRecord/downloadSource.xlsx"
1299
+ ),
1300
+ method: "get",
1301
+ query: {
1302
+ recordId: params.recordId
1303
+ }
1304
+ }),
1305
+ downloadImportFailed: (params) => download({
1306
+ path: buildAppPath(
1307
+ context,
1308
+ params.appType,
1309
+ "/v1/form/importRecord/downloadFailed.xlsx"
1310
+ ),
1311
+ method: "get",
1312
+ query: {
1313
+ recordId: params.recordId
1314
+ }
1315
+ }),
1316
+ downloadExportRecord: (params) => download({
1317
+ path: buildAppPath(
1318
+ context,
1319
+ params.appType,
1320
+ "/v1/form/exportRecord/download.xlsx"
1321
+ ),
1322
+ method: "get",
1323
+ query: {
1324
+ recordId: params.recordId
1325
+ }
1326
+ }),
1327
+ getDataManagementConfig: (params) => request({
1328
+ path: buildAppPath(
1329
+ context,
1330
+ params.appType,
1331
+ "/v1/form/dataManagement/config/get.json"
1332
+ ),
1333
+ method: "get",
1334
+ query: {
1335
+ formUuid: params.formUuid
1336
+ }
1337
+ }),
1338
+ saveDataManagementConfig: (params) => request({
1339
+ path: buildAppPath(
1340
+ context,
1341
+ params.appType,
1342
+ "/v1/form/dataManagement/config/save.json"
1343
+ ),
1344
+ method: "post",
1345
+ body: {
1346
+ formUuid: params.formUuid,
1347
+ config: params.config
1348
+ }
1349
+ })
1350
+ };
1351
+ const user = {
1352
+ create: (params) => request({
1353
+ path: "/user/create",
1354
+ method: "post",
1355
+ body: params
1356
+ }),
1357
+ update: (params) => request({
1358
+ path: "/user/update",
1359
+ method: "put",
1360
+ body: params
1361
+ }),
1362
+ remove: (id) => request({
1363
+ path: `/user/${encodePathSegment(id)}`,
1364
+ method: "delete"
1365
+ }),
1366
+ get: (id = "current") => request({
1367
+ path: `/user/${encodePathSegment(id)}`,
1368
+ method: "get"
1369
+ }),
1370
+ getCurrent: () => request({
1371
+ path: "/user/current",
1372
+ method: "get"
1373
+ }),
1374
+ getByUsername: (username) => request({
1375
+ path: `/user/username/${encodePathSegment(username)}`,
1376
+ method: "get"
1377
+ }),
1378
+ list: (params) => request({
1379
+ path: "/user/list",
1380
+ method: "get",
1381
+ query: {
1382
+ ids: params?.ids,
1383
+ departmentIds: params?.departmentIds,
1384
+ name: params?.name,
1385
+ username: params?.username,
1386
+ phone: params?.phone,
1387
+ email: params?.email,
1388
+ page: params?.page,
1389
+ pageSize: params?.pageSize
1390
+ }
1391
+ }),
1392
+ search: (keyword) => request({
1393
+ path: "/user/search",
1394
+ method: "get",
1395
+ query: {
1396
+ keyword
1397
+ }
1398
+ }),
1399
+ listAll: () => request({
1400
+ path: "/user/all",
1401
+ method: "get"
1402
+ }),
1403
+ listByDepartment: (departmentId) => request({
1404
+ path: `/user/department/${encodePathSegment(departmentId)}`,
1405
+ method: "get"
1406
+ }),
1407
+ validate: (params) => request({
1408
+ path: "/user/validate",
1409
+ method: "post",
1410
+ body: params
1411
+ })
1412
+ };
1413
+ const getParentDepartments = (departmentId, options = {}) => request({
1414
+ path: `/department/${encodePathSegment(departmentId)}/parentDepartments`,
1415
+ method: "get",
1416
+ query: {
1417
+ includeSelf: options.includeSelf ?? true
1418
+ }
1419
+ });
1420
+ const department = {
1421
+ getParentDepartments,
1422
+ getCurrentUserParentDepartments: async (options = {}) => {
1423
+ const departments = (context.user.departments || []).filter(
1424
+ (item) => typeof item.id === "string" && item.id.trim()
1425
+ );
1426
+ return Promise.all(
1427
+ departments.map(async (item) => {
1428
+ const response = await getParentDepartments(item.id || "", {
1429
+ includeSelf: options.includeSelf
1430
+ });
1431
+ return {
1432
+ department: item,
1433
+ parents: response.result || []
1434
+ };
1435
+ })
1436
+ );
1437
+ }
1438
+ };
1439
+ const role = {
1440
+ create: (params) => request({
1441
+ path: "/role/",
1442
+ method: "post",
1443
+ body: params
1444
+ }),
1445
+ update: (id, params) => request({
1446
+ path: `/role/${encodePathSegment(id)}`,
1447
+ method: "put",
1448
+ body: params
1449
+ }),
1450
+ remove: (id) => request({
1451
+ path: `/role/${encodePathSegment(id)}`,
1452
+ method: "delete"
1453
+ }),
1454
+ get: (id) => request({
1455
+ path: `/role/${encodePathSegment(id)}`,
1456
+ method: "get"
1457
+ }),
1458
+ list: (params) => request({
1459
+ path: "/role/",
1460
+ method: "get",
1461
+ query: withDefaultAppType(context, params)
1462
+ }),
1463
+ listUsers: (roleId, params) => request({
1464
+ path: `/role/${encodePathSegment(roleId)}/users`,
1465
+ method: "get",
1466
+ query: params
1467
+ }),
1468
+ assignRoles: (params) => request({
1469
+ path: "/role/assign",
1470
+ method: "post",
1471
+ body: params
1472
+ }),
1473
+ addUserRole: (params) => request({
1474
+ path: "/role/add",
1475
+ method: "post",
1476
+ body: params
1477
+ }),
1478
+ removeUserRole: (params) => request({
1479
+ path: "/role/remove",
1480
+ method: "post",
1481
+ body: params
1482
+ }),
1483
+ batchAddUsers: (params) => request({
1484
+ path: "/role/batch-add-users",
1485
+ method: "post",
1486
+ body: params
1487
+ }),
1488
+ getMyRoles: (params) => request({
1489
+ path: "/role/my/roles",
1490
+ method: "get",
1491
+ query: withDefaultAppType(context, params)
1492
+ }),
1493
+ getCurrentRole: (params) => request({
1494
+ path: "/role/my/current",
1495
+ method: "get",
1496
+ query: withDefaultAppType(context, params)
1497
+ }),
1498
+ switchPlatformRole: (params) => request({
1499
+ path: "/role/switch/platform",
1500
+ method: "post",
1501
+ body: params
1502
+ }),
1503
+ switchAppRole: (params) => request({
1504
+ path: "/role/switch/app",
1505
+ method: "post",
1506
+ body: {
1507
+ ...params,
1508
+ appType: resolveAppType(context, params.appType)
1509
+ }
1510
+ })
1511
+ };
1512
+ const permission = {
1513
+ formGroup: {
1514
+ create: (params) => request({
1515
+ path: "/permission/form-group/",
1516
+ method: "post",
1517
+ body: {
1518
+ ...params,
1519
+ appType: resolveAppType(context, params.appType)
1520
+ }
1521
+ }),
1522
+ update: (id, params) => request({
1523
+ path: `/permission/form-group/${encodePathSegment(id)}`,
1524
+ method: "put",
1525
+ body: {
1526
+ ...params,
1527
+ ...params.appType ? { appType: resolveAppType(context, params.appType) } : {}
1528
+ }
1529
+ }),
1530
+ remove: (id) => request({
1531
+ path: `/permission/form-group/${encodePathSegment(id)}`,
1532
+ method: "delete"
1533
+ }),
1534
+ get: (id) => request({
1535
+ path: `/permission/form-group/${encodePathSegment(id)}`,
1536
+ method: "get"
1537
+ }),
1538
+ list: (params) => request({
1539
+ path: "/permission/form-group/",
1540
+ method: "get",
1541
+ query: {
1542
+ ...params,
1543
+ appType: resolveAppType(context, params?.appType)
1544
+ }
1545
+ }),
1546
+ getViewFieldPermissions: (params) => request({
1547
+ path: "/permission/form-group/field-permissions",
1548
+ method: "get",
1549
+ query: {
1550
+ appType: resolveAppType(context, params.appType),
1551
+ formUuid: params.formUuid
1552
+ }
1553
+ }),
1554
+ getViewPermissionSummary: (params) => request({
1555
+ path: "/permission/form-group/view-permissions",
1556
+ method: "get",
1557
+ query: {
1558
+ appType: resolveAppType(context, params.appType),
1559
+ formUuid: params.formUuid
1560
+ }
1561
+ })
1562
+ },
1563
+ pageGroup: {
1564
+ create: (params) => request({
1565
+ path: "/permission/page-group/",
1566
+ method: "post",
1567
+ body: {
1568
+ ...params,
1569
+ appType: resolveAppType(context, params.appType)
1570
+ }
1571
+ }),
1572
+ update: (id, params) => request({
1573
+ path: `/permission/page-group/${encodePathSegment(id)}`,
1574
+ method: "put",
1575
+ body: {
1576
+ ...params,
1577
+ ...params.appType ? { appType: resolveAppType(context, params.appType) } : {}
1578
+ }
1579
+ }),
1580
+ remove: (id) => request({
1581
+ path: `/permission/page-group/${encodePathSegment(id)}`,
1582
+ method: "delete"
1583
+ }),
1584
+ get: (id) => request({
1585
+ path: `/permission/page-group/${encodePathSegment(id)}`,
1586
+ method: "get"
1587
+ }),
1588
+ list: (params) => request({
1589
+ path: "/permission/page-group/",
1590
+ method: "get",
1591
+ query: {
1592
+ ...params,
1593
+ appType: resolveAppType(context, params?.appType)
1594
+ }
1595
+ }),
1596
+ getUserMenuPermissions: (appType) => request({
1597
+ path: "/permission/page-group/user-menu-permissions",
1598
+ method: "get",
1599
+ query: {
1600
+ appType: resolveAppType(context, appType)
1601
+ }
1602
+ })
1603
+ },
1604
+ api: {
1605
+ create: (params) => request({
1606
+ path: "/permission/api",
1607
+ method: "post",
1608
+ body: params
1609
+ }),
1610
+ update: (id, params) => request({
1611
+ path: `/permission/api/${encodePathSegment(id)}`,
1612
+ method: "put",
1613
+ body: params
1614
+ }),
1615
+ remove: (id) => request({
1616
+ path: `/permission/api/${encodePathSegment(id)}`,
1617
+ method: "delete"
1618
+ }),
1619
+ list: (params) => request({
1620
+ path: "/permission/api",
1621
+ method: "get",
1622
+ query: withDefaultAppType(context, params)
1623
+ }),
1624
+ assign: (params) => request({
1625
+ path: "/permission/api/assign",
1626
+ method: "post",
1627
+ body: params
1628
+ }),
1629
+ getByRole: (roleId) => request({
1630
+ path: `/permission/api/role/${encodePathSegment(roleId)}`,
1631
+ method: "get"
1632
+ }),
1633
+ getRolesByPermission: (permissionId) => request({
1634
+ path: `/permission/api/${encodePathSegment(permissionId)}/roles`,
1635
+ method: "get"
1636
+ })
1637
+ },
1638
+ ui: {
1639
+ create: (params) => request({
1640
+ path: "/permission/api/ui",
1641
+ method: "post",
1642
+ body: params
1643
+ }),
1644
+ update: (id, params) => request({
1645
+ path: `/permission/api/ui/${encodePathSegment(id)}`,
1646
+ method: "put",
1647
+ body: params
1648
+ }),
1649
+ remove: (id) => request({
1650
+ path: `/permission/api/ui/${encodePathSegment(id)}`,
1651
+ method: "delete"
1652
+ }),
1653
+ list: (params) => request({
1654
+ path: "/permission/api/ui",
1655
+ method: "get",
1656
+ query: withDefaultAppType(context, params)
1657
+ }),
1658
+ assign: (params) => request({
1659
+ path: "/permission/api/ui/assign",
1660
+ method: "post",
1661
+ body: params
1662
+ }),
1663
+ getMyPlatform: () => request({
1664
+ path: "/permission/api/ui/me/platform",
1665
+ method: "get"
1666
+ }),
1667
+ getMyApp: (appType) => request({
1668
+ path: "/permission/api/ui/me/app",
1669
+ method: "get",
1670
+ query: {
1671
+ appType: resolveAppType(context, appType)
1672
+ }
1673
+ })
1674
+ }
1675
+ };
1676
+ const process2 = {
1677
+ getInstance: (params) => request({
1678
+ path: buildAppPath(context, params.appType, "/v1/process/instance"),
1679
+ method: "get",
1680
+ query: {
1681
+ instanceId: params.instanceId
1682
+ }
1683
+ }),
1684
+ terminateInstance: (params) => request({
1685
+ path: buildAppPath(
1686
+ context,
1687
+ params.appType,
1688
+ "/v1/process/terminateInstance.json"
1689
+ ),
1690
+ method: "post",
1691
+ body: {
1692
+ processInstanceId: params.processInstanceId,
1693
+ reason: params.reason
1694
+ }
1695
+ }),
1696
+ approveTask: (params) => request({
1697
+ path: buildAppPath(
1698
+ context,
1699
+ params.appType,
1700
+ "/v1/process/approveTask.json"
1701
+ ),
1702
+ method: "post",
1703
+ body: {
1704
+ ...params,
1705
+ appType: resolveAppType(context, params.appType)
1706
+ }
1707
+ }),
1708
+ triggerCallbackTask: (params) => request({
1709
+ path: buildAppPath(
1710
+ context,
1711
+ params.appType,
1712
+ "/v1/process/triggerCallback.json"
1713
+ ),
1714
+ method: "post",
1715
+ body: {
1716
+ taskId: params.taskId,
1717
+ payload: params.payload
1718
+ }
1719
+ })
1720
+ };
1721
+ const dataView = {
1722
+ query: (code, params = {}) => {
1723
+ const dataViewCode = String(code || "").trim();
1724
+ if (!dataViewCode) {
1725
+ throw new Error("\u6570\u636E\u89C6\u56FE code \u4E0D\u80FD\u4E3A\u7A7A");
1726
+ }
1727
+ return request({
1728
+ path: buildAppPath(
1729
+ context,
1730
+ params.appType,
1731
+ `/v1/data-views/${encodePathSegment(dataViewCode)}/query.json`
1732
+ ),
1733
+ method: "post",
1734
+ body: {
1735
+ fields: params.fields,
1736
+ filters: serializeSearchExpression(params.filters),
1737
+ conditionType: params.conditionType,
1738
+ searchKeyWord: params.searchKeyWord,
1739
+ currentPage: params.currentPage,
1740
+ pageSize: params.pageSize,
1741
+ order: Array.isArray(params.order) ? params.order : params.order ? [params.order] : void 0
1742
+ }
1743
+ });
1744
+ },
1745
+ stats: (code, params = {}) => {
1746
+ const dataViewCode = String(code || "").trim();
1747
+ if (!dataViewCode) {
1748
+ throw new Error("\u6570\u636E\u89C6\u56FE code \u4E0D\u80FD\u4E3A\u7A7A");
1749
+ }
1750
+ return request({
1751
+ path: buildAppPath(
1752
+ context,
1753
+ params.appType,
1754
+ `/v1/data-views/${encodePathSegment(dataViewCode)}/stats.json`
1755
+ ),
1756
+ method: "post",
1757
+ body: {
1758
+ fields: params.fields,
1759
+ filters: serializeSearchExpression(params.filters),
1760
+ having: serializeSearchExpression(params.having),
1761
+ conditionType: params.conditionType,
1762
+ searchKeyWord: params.searchKeyWord,
1763
+ currentPage: params.currentPage,
1764
+ pageSize: params.pageSize,
1765
+ order: Array.isArray(params.order) ? params.order : params.order ? [params.order] : void 0
1766
+ }
1767
+ });
1768
+ }
1769
+ };
1770
+ const appFunction = {
1771
+ invoke: (code, params = {}) => {
1772
+ const functionCode = String(code || "").trim();
1773
+ if (!functionCode) {
1774
+ throw new Error("\u5E94\u7528\u51FD\u6570 code \u4E0D\u80FD\u4E3A\u7A7A");
1775
+ }
1776
+ return request({
1777
+ path: buildAppPath(
1778
+ context,
1779
+ params.appType,
1780
+ `/v1/functions/${encodePathSegment(functionCode)}/invoke.json`
1781
+ ),
1782
+ method: "post",
1783
+ body: {
1784
+ input: params.input
1785
+ }
1786
+ });
1787
+ }
1788
+ };
1789
+ const notification = {
1790
+ sendByType: (params) => request({
1791
+ path: buildOpenXiangdaAppPath(
1792
+ context,
1793
+ params.appType,
1794
+ "/notifications/send-by-type"
1795
+ ),
1796
+ method: "post",
1797
+ body: {
1798
+ ...params,
1799
+ appType: resolveAppType(context, params.appType)
1800
+ }
1801
+ }),
1802
+ batchSendByType: (params) => request({
1803
+ path: buildOpenXiangdaAppPath(
1804
+ context,
1805
+ params.appType,
1806
+ "/notifications/batch-send-by-type"
1807
+ ),
1808
+ method: "post",
1809
+ body: {
1810
+ ...params,
1811
+ appType: resolveAppType(context, params.appType)
1812
+ }
1813
+ }),
1814
+ findConfig: (notificationType, params = {}) => request({
1815
+ path: buildOpenXiangdaAppPath(
1816
+ context,
1817
+ params.appType,
1818
+ `/notifications/type-configs/${encodePathSegment(notificationType)}`
1819
+ ),
1820
+ method: "get",
1821
+ query: params.formUuid ? { formUuid: params.formUuid } : void 0
1822
+ }),
1823
+ previewTemplate: (params) => request({
1824
+ path: buildOpenXiangdaAppPath(
1825
+ context,
1826
+ params.appType,
1827
+ "/notifications/templates/preview"
1828
+ ),
1829
+ method: "post",
1830
+ body: {
1831
+ ...params,
1832
+ appType: resolveAppType(context, params.appType)
1833
+ }
1834
+ })
1835
+ };
1836
+ const sdk = {
1837
+ context,
1838
+ request,
1839
+ download,
1840
+ transport: {
1841
+ request,
1842
+ download
1843
+ },
1844
+ auth,
1845
+ connector,
1846
+ form,
1847
+ user,
1848
+ department,
1849
+ role,
1850
+ permission,
1851
+ process: process2,
1852
+ notification,
1853
+ dataView,
1854
+ function: appFunction,
1855
+ dataSource: {
1856
+ run: async (name, params = {}) => {
1857
+ const descriptor = (context.page.dataSources || []).find(
1858
+ (item) => item.key === name
1859
+ );
1860
+ if (!descriptor) {
1861
+ throw new Error(`\u672A\u627E\u5230\u6570\u636E\u6E90: ${String(name || "")}`);
1862
+ }
1863
+ const runtimeParams = params;
1864
+ const resolvedFormUuid = String(
1865
+ runtimeParams.formUuid || descriptor.formUuid || ""
1866
+ ).trim();
1867
+ switch (descriptor.type) {
1868
+ case "dataView.query":
1869
+ case "dataView.stats": {
1870
+ const dataViewCode = String(
1871
+ runtimeParams.code || runtimeParams.dataViewCode || descriptor.code || descriptor.dataViewCode || descriptor.viewCode || descriptor.key || ""
1872
+ ).trim();
1873
+ const queryParams = {
1874
+ ...descriptor.params && typeof descriptor.params === "object" ? descriptor.params : {},
1875
+ ...runtimeParams,
1876
+ fields: runtimeParams.fields || descriptor.fields,
1877
+ filters: mergeSearchExpressions(
1878
+ descriptor.defaultFilter,
1879
+ runtimeParams.filters
1880
+ ),
1881
+ having: mergeSearchExpressions(
1882
+ descriptor.defaultHaving || descriptor.having,
1883
+ runtimeParams.having
1884
+ )
1885
+ };
1886
+ delete queryParams.code;
1887
+ delete queryParams.dataViewCode;
1888
+ delete queryParams.viewCode;
1889
+ if (descriptor.type === "dataView.stats") {
1890
+ return dataView.stats(
1891
+ dataViewCode,
1892
+ queryParams
1893
+ );
1894
+ }
1895
+ delete queryParams.having;
1896
+ return dataView.query(
1897
+ dataViewCode,
1898
+ queryParams
1899
+ );
1900
+ }
1901
+ case "form.list":
1902
+ return form.advancedSearch({
1903
+ ...runtimeParams,
1904
+ formUuid: resolvedFormUuid,
1905
+ filters: mergeSearchExpressions(
1906
+ descriptor.defaultFilter,
1907
+ runtimeParams.filters
1908
+ )
1909
+ });
1910
+ case "form.detail":
1911
+ return form.getDetail({
1912
+ ...runtimeParams,
1913
+ formUuid: resolvedFormUuid
1914
+ });
1915
+ case "form.create":
1916
+ return form.create({
1917
+ ...runtimeParams,
1918
+ formUuid: resolvedFormUuid
1919
+ });
1920
+ case "form.update":
1921
+ return form.update({
1922
+ ...runtimeParams,
1923
+ formUuid: resolvedFormUuid
1924
+ });
1925
+ case "form.delete":
1926
+ return form.remove({
1927
+ ...runtimeParams,
1928
+ formUuid: resolvedFormUuid
1929
+ });
1930
+ default:
1931
+ throw new Error(`\u6682\u4E0D\u652F\u6301\u7684\u6570\u636E\u6E90\u7C7B\u578B: ${String(descriptor.type)}`);
1932
+ }
1933
+ }
1934
+ },
1935
+ navigation: context.navigation,
1936
+ ui: context.ui
1937
+ };
1938
+ return sdk;
1939
+ };
1940
+
1941
+ // packages/sdk/src/runtime/react/provider.tsx
1942
+ import { jsx } from "react/jsx-runtime";
1943
+ var PageProvider = ({
1944
+ context,
1945
+ children
1946
+ }) => {
1947
+ const value = useMemo(
1948
+ () => ({
1949
+ context,
1950
+ sdk: createPageSdk(context)
1951
+ }),
1952
+ [context]
1953
+ );
1954
+ return /* @__PURE__ */ jsx(ReactPageContext.Provider, { value, children });
1955
+ };
1956
+
1957
+ // packages/sdk/src/styles/antd-theme.ts
1958
+ var baseTheme = {
1959
+ hashed: false,
1960
+ token: {
1961
+ colorPrimary: "#1677ff",
1962
+ colorInfo: "#1677ff",
1963
+ colorSuccess: "#52c41a",
1964
+ colorWarning: "#faad14",
1965
+ colorError: "#ff4d4f",
1966
+ colorText: "rgba(0,0,0,0.88)",
1967
+ colorTextSecondary: "rgba(0,0,0,0.65)",
1968
+ colorTextTertiary: "rgba(0,0,0,0.45)",
1969
+ colorTextDisabled: "rgba(0,0,0,0.25)",
1970
+ colorBgContainer: "#ffffff",
1971
+ colorBgLayout: "#f5f5f5",
1972
+ colorBgElevated: "#ffffff",
1973
+ colorBorder: "#d9d9d9",
1974
+ colorBorderSecondary: "#f0f0f0",
1975
+ borderRadius: 6,
1976
+ borderRadiusSM: 4,
1977
+ borderRadiusLG: 8,
1978
+ fontSize: 14,
1979
+ controlHeight: 32
1980
+ },
1981
+ components: {
1982
+ Form: { itemMarginBottom: 16 },
1983
+ Card: { paddingLG: 24 }
1984
+ }
1985
+ };
1986
+ var antdTheme = {
1987
+ ...baseTheme,
1988
+ cssVar: { prefix: "ant" }
1989
+ };
1990
+ var legacyAntdTheme = {
1991
+ ...baseTheme,
1992
+ cssVar: { prefix: "sy-ant" }
1993
+ };
1994
+
1995
+ // packages/sdk/src/runtime/react/createReactPage.tsx
1996
+ import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
1997
+ dayjs3.locale("zh-cn");
1998
+ var NAMESPACE_ROOT_CLASS = "sy-app-workspace";
1999
+ var RUNTIME_PORTAL_ATTR = "data-sy-runtime-portal";
2000
+ var PORTAL_CONTAINER_STACK_GLOBAL = "__OPENXIANGDA_PORTAL_CONTAINER_STACK__";
2001
+ var PORTAL_CONTAINER_RESOLVER_GLOBAL = "__OPENXIANGDA_GET_PORTAL_CONTAINER__";
2002
+ var MESSAGE_PROXY_GLOBAL = "__OPENXIANGDA_ANTD_MESSAGE_PROXY__";
2003
+ var MESSAGE_METHODS = [
2004
+ "open",
2005
+ "success",
2006
+ "info",
2007
+ "warning",
2008
+ "error",
2009
+ "loading",
2010
+ "destroy"
2011
+ ];
2012
+ var createRuntimeRoot = (el) => {
2013
+ return createRoot(el);
2014
+ };
2015
+ var normalizeCssIsolation = (value) => {
2016
+ if (value === "namespace" || value === "shadow") return value;
2017
+ return "none";
2018
+ };
2019
+ var usesLegacyCssIsolation = (cssIsolation) => cssIsolation === "namespace" || cssIsolation === "shadow";
2020
+ var getRuntimeCssIsolation = (context) => normalizeCssIsolation(context.page?.capabilities?.cssIsolation);
2021
+ var getAntdRuntimeOptions = (cssIsolation) => {
2022
+ const legacy = usesLegacyCssIsolation(cssIsolation);
2023
+ return {
2024
+ prefixCls: legacy ? "sy-ant" : "ant",
2025
+ iconPrefixCls: legacy ? "sy-anticon" : "anticon",
2026
+ messagePrefixCls: legacy ? "sy-ant-message" : "ant-message",
2027
+ theme: legacy ? legacyAntdTheme : antdTheme
2028
+ };
2029
+ };
2030
+ var isShadowRoot = (rootNode) => typeof ShadowRoot !== "undefined" && rootNode instanceof ShadowRoot;
2031
+ var getStyleContainer = (el) => {
2032
+ const rootNode = el.getRootNode?.();
2033
+ if (isShadowRoot(rootNode)) {
2034
+ return rootNode;
2035
+ }
2036
+ return document.head;
2037
+ };
2038
+ var getRuntimeRoot = (el, triggerNode) => {
2039
+ const rootNode = el.getRootNode?.();
2040
+ if (isShadowRoot(rootNode)) return el;
2041
+ const triggerRoot = triggerNode?.closest?.(
2042
+ `.${NAMESPACE_ROOT_CLASS}`
2043
+ );
2044
+ return triggerRoot || el.closest(`.${NAMESPACE_ROOT_CLASS}`) || el.querySelector(`.${NAMESPACE_ROOT_CLASS}`) || el;
2045
+ };
2046
+ var getRuntimeOverlayContainer = (el, portalContainer) => {
2047
+ const getOverlayRoot = (triggerNode) => {
2048
+ if (portalContainer?.isConnected) return portalContainer;
2049
+ return getRuntimeRoot(el, triggerNode);
2050
+ };
2051
+ return {
2052
+ getPopupContainer: (triggerNode) => {
2053
+ return getOverlayRoot(triggerNode);
2054
+ },
2055
+ getTargetContainer: () => getRuntimeRoot(el)
2056
+ };
2057
+ };
2058
+ var createAntdConfig = (overlayContainer, cssIsolation) => {
2059
+ const antdOptions = getAntdRuntimeOptions(cssIsolation);
2060
+ return {
2061
+ locale: zhCN,
2062
+ prefixCls: antdOptions.prefixCls,
2063
+ iconPrefixCls: antdOptions.iconPrefixCls,
2064
+ theme: antdOptions.theme,
2065
+ ...usesLegacyCssIsolation(cssIsolation) ? {
2066
+ getPopupContainer: overlayContainer.getPopupContainer,
2067
+ getTargetContainer: overlayContainer.getTargetContainer
2068
+ } : {}
2069
+ };
2070
+ };
2071
+ var createPortalContainer = (el) => {
2072
+ const rootNode = el.getRootNode?.();
2073
+ const parent = isShadowRoot(rootNode) ? rootNode : el.ownerDocument?.body || document.body;
2074
+ const portalContainer = el.ownerDocument.createElement("div");
2075
+ portalContainer.setAttribute(RUNTIME_PORTAL_ATTR, "");
2076
+ portalContainer.classList.add(NAMESPACE_ROOT_CLASS);
2077
+ parent.appendChild(portalContainer);
2078
+ return portalContainer;
2079
+ };
2080
+ var getAntdMessageProxyState = () => {
2081
+ const globalScope = globalThis;
2082
+ if (!globalScope[MESSAGE_PROXY_GLOBAL]) {
2083
+ globalScope[MESSAGE_PROXY_GLOBAL] = {
2084
+ apiStack: [],
2085
+ installed: false,
2086
+ originalMethods: {}
2087
+ };
2088
+ }
2089
+ return globalScope[MESSAGE_PROXY_GLOBAL];
2090
+ };
2091
+ var installAntdMessageProxy = () => {
2092
+ const state = getAntdMessageProxyState();
2093
+ if (state.installed) return state;
2094
+ MESSAGE_METHODS.forEach((method) => {
2095
+ const originalMethod = message[method];
2096
+ if (typeof originalMethod !== "function") return;
2097
+ state.originalMethods[method] = originalMethod.bind(message);
2098
+ message[method] = (...args) => {
2099
+ const api = state.apiStack.at(-1);
2100
+ const apiMethod = api?.[method];
2101
+ if (typeof apiMethod === "function") {
2102
+ return apiMethod(...args);
2103
+ }
2104
+ return state.originalMethods[method]?.(...args);
2105
+ };
2106
+ });
2107
+ state.installed = true;
2108
+ return state;
2109
+ };
2110
+ var registerAntdMessageApi = (api) => {
2111
+ const state = installAntdMessageProxy();
2112
+ state.apiStack.push(api);
2113
+ return () => {
2114
+ const position = state.apiStack.lastIndexOf(api);
2115
+ if (position >= 0) {
2116
+ state.apiStack.splice(position, 1);
2117
+ }
2118
+ };
2119
+ };
2120
+ var installRuntimePortalContainer = (el, cssIsolation) => {
2121
+ const globalScope = globalThis;
2122
+ const portalContainer = usesLegacyCssIsolation(cssIsolation) ? createPortalContainer(el) : null;
2123
+ const stack = Array.isArray(globalScope[PORTAL_CONTAINER_STACK_GLOBAL]) ? globalScope[PORTAL_CONTAINER_STACK_GLOBAL] : [];
2124
+ const stackTarget = portalContainer ?? el.ownerDocument?.body ?? document.body;
2125
+ stack.push(stackTarget);
2126
+ globalScope[PORTAL_CONTAINER_STACK_GLOBAL] = stack;
2127
+ globalScope[PORTAL_CONTAINER_RESOLVER_GLOBAL] = () => {
2128
+ for (let index = stack.length - 1; index >= 0; index -= 1) {
2129
+ const candidate = stack[index];
2130
+ if (candidate?.isConnected) {
2131
+ return candidate;
2132
+ }
2133
+ }
2134
+ return document.querySelector(`[${RUNTIME_PORTAL_ATTR}]`) || document.querySelector(`.${NAMESPACE_ROOT_CLASS}`) || document.body;
2135
+ };
2136
+ return {
2137
+ container: portalContainer,
2138
+ release: () => {
2139
+ const position = stack.lastIndexOf(stackTarget);
2140
+ if (position >= 0) {
2141
+ stack.splice(position, 1);
2142
+ }
2143
+ portalContainer?.remove();
2144
+ }
2145
+ };
2146
+ };
2147
+ var installAntdStaticHolder = (el, portalContainer, cssIsolation) => {
2148
+ installAntdMessageProxy();
2149
+ const antdOptions = getAntdRuntimeOptions(cssIsolation);
2150
+ const getMessageContainer = () => {
2151
+ if (portalContainer?.isConnected) return portalContainer;
2152
+ return usesLegacyCssIsolation(cssIsolation) ? getRuntimeRoot(el) : document.body;
2153
+ };
2154
+ ConfigProvider.config({
2155
+ prefixCls: antdOptions.prefixCls,
2156
+ iconPrefixCls: antdOptions.iconPrefixCls,
2157
+ theme: antdOptions.theme,
2158
+ holderRender: (children) => {
2159
+ if (!el.isConnected) {
2160
+ return /* @__PURE__ */ jsx2(
2161
+ ConfigProvider,
2162
+ {
2163
+ locale: zhCN,
2164
+ prefixCls: antdOptions.prefixCls,
2165
+ iconPrefixCls: antdOptions.iconPrefixCls,
2166
+ theme: antdOptions.theme,
2167
+ children
2168
+ }
2169
+ );
2170
+ }
2171
+ const overlayContainer = getRuntimeOverlayContainer(el, portalContainer);
2172
+ return /* @__PURE__ */ jsx2(StyleProvider, { hashPriority: "high", container: getStyleContainer(el), children: /* @__PURE__ */ jsx2(ConfigProvider, { ...createAntdConfig(overlayContainer, cssIsolation), children }) });
2173
+ }
2174
+ });
2175
+ message.config({
2176
+ prefixCls: antdOptions.messagePrefixCls,
2177
+ getContainer: getMessageContainer
2178
+ });
2179
+ };
2180
+ var RuntimeMessageBridge = ({ children }) => {
2181
+ const appContext = AntdApp.useApp();
2182
+ React2.useLayoutEffect(() => {
2183
+ return registerAntdMessageApi(
2184
+ appContext.message
2185
+ );
2186
+ }, [appContext.message]);
2187
+ return /* @__PURE__ */ jsx2(Fragment, { children });
2188
+ };
2189
+ var createReactPage = (AppComponent) => {
2190
+ let root = null;
2191
+ let currentContainer = null;
2192
+ let releasePortalContainer = null;
2193
+ let portalContainer = null;
2194
+ let currentCssIsolation = null;
2195
+ const render = (el, context) => {
2196
+ const cssIsolation = getRuntimeCssIsolation(context);
2197
+ if (usesLegacyCssIsolation(cssIsolation)) {
2198
+ el.classList.add(NAMESPACE_ROOT_CLASS);
2199
+ } else {
2200
+ el.classList.remove(NAMESPACE_ROOT_CLASS);
2201
+ }
2202
+ if (!root || currentContainer !== el || currentCssIsolation !== cssIsolation || usesLegacyCssIsolation(cssIsolation) && !portalContainer?.isConnected) {
2203
+ root?.unmount();
2204
+ releasePortalContainer?.();
2205
+ root = createRuntimeRoot(el);
2206
+ currentContainer = el;
2207
+ currentCssIsolation = cssIsolation;
2208
+ const portalHandle = installRuntimePortalContainer(el, cssIsolation);
2209
+ portalContainer = portalHandle.container;
2210
+ releasePortalContainer = portalHandle.release;
2211
+ }
2212
+ const overlayContainer = getRuntimeOverlayContainer(el, portalContainer);
2213
+ installAntdStaticHolder(el, portalContainer, cssIsolation);
2214
+ const antdConfig = createAntdConfig(overlayContainer, cssIsolation);
2215
+ root.render(
2216
+ /* @__PURE__ */ jsx2(StyleProvider, { hashPriority: "high", container: getStyleContainer(el), children: /* @__PURE__ */ jsx2(ConfigProvider, { ...antdConfig, children: /* @__PURE__ */ jsx2(AntdApp, { children: /* @__PURE__ */ jsx2(RuntimeMessageBridge, { children: /* @__PURE__ */ jsx2(PageProvider, { context, children: /* @__PURE__ */ jsx2(AppComponent, {}) }) }) }) }) })
2217
+ );
2218
+ };
2219
+ return {
2220
+ mount: (el, context) => {
2221
+ render(el, context);
2222
+ },
2223
+ update: (el, context) => {
2224
+ render(el, context);
2225
+ },
2226
+ unmount: () => {
2227
+ root?.unmount();
2228
+ releasePortalContainer?.();
2229
+ root = null;
2230
+ currentContainer = null;
2231
+ releasePortalContainer = null;
2232
+ portalContainer = null;
2233
+ currentCssIsolation = null;
2234
+ }
2235
+ };
2236
+ };
2237
+
2238
+ // packages/sdk/src/runtime/react/hooks/useCurrentUser.ts
2239
+ import { useMemo as useMemo2 } from "react";
2240
+
2241
+ // packages/sdk/src/runtime/react/hooks/usePageContext.ts
2242
+ var usePageContext = () => {
2243
+ return usePageSdkStore().context;
2244
+ };
2245
+
2246
+ // packages/sdk/src/runtime/react/hooks/useCurrentUser.ts
2247
+ var useCurrentUser = () => {
2248
+ const { user } = usePageContext();
2249
+ return useMemo2(() => {
2250
+ const userType = user.userType === "guest" || user.isGuest ? "guest" : "normal";
2251
+ const isGuest = userType === "guest";
2252
+ return {
2253
+ user: {
2254
+ ...user,
2255
+ isGuest,
2256
+ userType
2257
+ },
2258
+ isGuest,
2259
+ isInternalUser: !isGuest,
2260
+ displayName: user.name || user.username || user.id,
2261
+ primaryDepartment: user.departments?.[0] || null,
2262
+ affiliatedDepartment: user.affiliatedDepartment || null
2263
+ };
2264
+ }, [user]);
2265
+ };
2266
+
2267
+ // packages/sdk/src/runtime/react/hooks/useDataSource.ts
2268
+ import { useCallback, useEffect, useRef, useState } from "react";
2269
+
2270
+ // packages/sdk/src/runtime/react/hooks/usePageSdk.ts
2271
+ var usePageSdk = () => {
2272
+ return usePageSdkStore().sdk;
2273
+ };
2274
+
2275
+ // packages/sdk/src/runtime/react/hooks/useDataSource.ts
2276
+ var createParamsSignature = (value) => {
2277
+ try {
2278
+ return JSON.stringify(value || {});
2279
+ } catch {
2280
+ return "";
2281
+ }
2282
+ };
2283
+ var useDataSource = (name, options = {}) => {
2284
+ const sdk = usePageSdk();
2285
+ const { params, immediate = true, transform } = options;
2286
+ const paramsRef = useRef(params);
2287
+ const transformRef = useRef(transform);
2288
+ const paramsSignature = createParamsSignature(params);
2289
+ const [response, setResponse] = useState(
2290
+ null
2291
+ );
2292
+ const [result, setResult] = useState(null);
2293
+ const [data, setData] = useState(null);
2294
+ const [loading, setLoading] = useState(false);
2295
+ const [error, setError] = useState(null);
2296
+ paramsRef.current = params;
2297
+ transformRef.current = transform;
2298
+ const run = useCallback(
2299
+ async (overrideParams) => {
2300
+ setLoading(true);
2301
+ setError(null);
2302
+ try {
2303
+ const response2 = await sdk.dataSource.run(
2304
+ name,
2305
+ overrideParams || paramsRef.current || {}
2306
+ );
2307
+ setResponse(response2);
2308
+ setResult(response2.result);
2309
+ const activeTransform = transformRef.current;
2310
+ const nextData = activeTransform ? activeTransform(response2.result, response2) : response2.result ?? null;
2311
+ setData(nextData);
2312
+ return response2;
2313
+ } catch (runtimeError) {
2314
+ const nextError = runtimeError instanceof Error ? runtimeError : new Error(String(runtimeError));
2315
+ setError(nextError);
2316
+ setResponse(null);
2317
+ setResult(null);
2318
+ return null;
2319
+ } finally {
2320
+ setLoading(false);
2321
+ }
2322
+ },
2323
+ [name, sdk.dataSource]
2324
+ );
2325
+ useEffect(() => {
2326
+ if (!immediate) {
2327
+ return;
2328
+ }
2329
+ void run();
2330
+ }, [immediate, paramsSignature, run]);
2331
+ return {
2332
+ response,
2333
+ result,
2334
+ data,
2335
+ loading,
2336
+ error,
2337
+ refresh: run,
2338
+ run,
2339
+ setResponse,
2340
+ setResult,
2341
+ setData
2342
+ };
2343
+ };
2344
+
2345
+ // packages/sdk/src/runtime/react/hooks/useFormViewPermissions.ts
2346
+ import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo3, useState as useState2 } from "react";
2347
+ var EMPTY_SUMMARY = {
2348
+ fieldPermissions: {},
2349
+ operations: []
2350
+ };
2351
+ var toError = (error) => {
2352
+ if (error instanceof Error) {
2353
+ return error;
2354
+ }
2355
+ if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
2356
+ return new Error(error.message);
2357
+ }
2358
+ return new Error(String(error || "\u83B7\u53D6\u67E5\u770B\u6001\u6743\u9650\u5931\u8D25"));
2359
+ };
2360
+ var useFormViewPermissions = (formUuid, options = {}) => {
2361
+ const sdk = usePageSdk();
2362
+ const [summary, setSummary] = useState2(EMPTY_SUMMARY);
2363
+ const [response, setResponse] = useState2(null);
2364
+ const [loading, setLoading] = useState2(false);
2365
+ const [error, setError] = useState2(null);
2366
+ const immediate = options.immediate ?? true;
2367
+ const refresh = useCallback2(async () => {
2368
+ const normalizedFormUuid = String(formUuid || "").trim();
2369
+ if (!normalizedFormUuid) {
2370
+ setSummary(EMPTY_SUMMARY);
2371
+ setResponse(null);
2372
+ return null;
2373
+ }
2374
+ setLoading(true);
2375
+ setError(null);
2376
+ try {
2377
+ const nextResponse = await sdk.permission.formGroup.getViewPermissionSummary({
2378
+ appType: options.appType,
2379
+ formUuid: normalizedFormUuid
2380
+ });
2381
+ const nextSummary = nextResponse.result || EMPTY_SUMMARY;
2382
+ setResponse(nextResponse);
2383
+ setSummary({
2384
+ fieldPermissions: nextSummary.fieldPermissions || {},
2385
+ operations: nextSummary.operations || []
2386
+ });
2387
+ return nextResponse;
2388
+ } catch (requestError) {
2389
+ const nextError = toError(requestError);
2390
+ setError(nextError);
2391
+ setResponse(null);
2392
+ setSummary(EMPTY_SUMMARY);
2393
+ return null;
2394
+ } finally {
2395
+ setLoading(false);
2396
+ }
2397
+ }, [formUuid, options.appType, sdk]);
2398
+ useEffect2(() => {
2399
+ if (!immediate) {
2400
+ return;
2401
+ }
2402
+ void refresh();
2403
+ }, [immediate, refresh]);
2404
+ const operationSet = useMemo3(
2405
+ () => new Set(summary.operations),
2406
+ [summary.operations]
2407
+ );
2408
+ const can = useCallback2(
2409
+ (operation) => operationSet.has(operation),
2410
+ [operationSet]
2411
+ );
2412
+ const getFieldPermission = useCallback2(
2413
+ (fieldName) => summary.fieldPermissions[fieldName] || null,
2414
+ [summary.fieldPermissions]
2415
+ );
2416
+ return {
2417
+ summary,
2418
+ response,
2419
+ loading,
2420
+ error,
2421
+ refresh,
2422
+ can,
2423
+ getFieldPermission
2424
+ };
2425
+ };
2426
+
2427
+ // packages/sdk/src/runtime/react/hooks/useMessage.ts
2428
+ var useMessage = () => {
2429
+ return usePageContext().ui.message;
2430
+ };
2431
+
2432
+ // packages/sdk/src/runtime/react/hooks/useModal.ts
2433
+ var useModal = () => {
2434
+ return usePageContext().ui.modal;
2435
+ };
2436
+
2437
+ // packages/sdk/src/runtime/react/hooks/useNavigation.ts
2438
+ var useNavigation = () => {
2439
+ return usePageContext().navigation;
2440
+ };
2441
+
2442
+ // packages/sdk/src/runtime/react/hooks/usePageProps.ts
2443
+ var usePageProps = () => {
2444
+ return usePageContext().page.props;
2445
+ };
2446
+
2447
+ // packages/sdk/src/runtime/react/hooks/usePageRoute.ts
2448
+ var usePageRoute = () => {
2449
+ return usePageContext().route;
2450
+ };
2451
+
1
2452
  // packages/sdk/src/runtime/react/openxiangdaProvider.tsx
2
2453
  import {
3
- createContext,
4
- useCallback as useCallback2,
5
- useContext,
6
- useEffect as useEffect2,
7
- useMemo as useMemo2,
8
- useState as useState2
2454
+ createContext as createContext2,
2455
+ useCallback as useCallback4,
2456
+ useContext as useContext2,
2457
+ useEffect as useEffect4,
2458
+ useMemo as useMemo5,
2459
+ useState as useState4
9
2460
  } from "react";
10
2461
 
11
2462
  // packages/sdk/src/runtime/core/fetch.ts
@@ -16,10 +2467,10 @@ var createBoundFetch = (fetchImpl) => {
16
2467
 
17
2468
  // packages/sdk/src/runtime/react/auth.tsx
18
2469
  import {
19
- useCallback,
20
- useEffect,
21
- useMemo,
22
- useState
2470
+ useCallback as useCallback3,
2471
+ useEffect as useEffect3,
2472
+ useMemo as useMemo4,
2473
+ useState as useState3
23
2474
  } from "react";
24
2475
  import {
25
2476
  Alert,
@@ -42,8 +2493,8 @@ import {
42
2493
 
43
2494
  // packages/sdk/src/runtime/core/auth.ts
44
2495
  var AuthClientError = class extends Error {
45
- constructor(message, options = {}) {
46
- super(message);
2496
+ constructor(message2, options = {}) {
2497
+ super(message2);
47
2498
  this.name = "AuthClientError";
48
2499
  this.status = options.status;
49
2500
  this.code = options.code;
@@ -126,7 +2577,7 @@ var getRecordValue = (value, key) => {
126
2577
  return value[key];
127
2578
  };
128
2579
  var resolveLoginUrl = (appType, {
129
- callbackUrl = getCurrentHref(),
2580
+ callbackUrl = getCurrentHref2(),
130
2581
  callbackParamName = "callback",
131
2582
  loginUrl
132
2583
  }) => {
@@ -147,13 +2598,13 @@ var resolveLoginUrl = (appType, {
147
2598
  return `${target}${separator}${callbackParamName}=${encodeURIComponent(callbackUrl)}`;
148
2599
  }
149
2600
  };
150
- var getCurrentHref = () => typeof window === "undefined" ? "" : window.location.href;
2601
+ var getCurrentHref2 = () => typeof window === "undefined" ? "" : window.location.href;
151
2602
 
152
2603
  // packages/sdk/src/runtime/react/auth.tsx
153
- import { jsx, jsxs } from "react/jsx-runtime";
2604
+ import { jsx as jsx3, jsxs } from "react/jsx-runtime";
154
2605
  var useAuth = (options = {}) => {
155
2606
  const runtime = useOpenXiangda();
156
- const client = useMemo(
2607
+ const client = useMemo4(
157
2608
  () => createAuthClient({
158
2609
  appType: options.appType || runtime.appType,
159
2610
  servicePrefix: options.servicePrefix || runtime.servicePrefix,
@@ -168,7 +2619,7 @@ var useAuth = (options = {}) => {
168
2619
  runtime.servicePrefix
169
2620
  ]
170
2621
  );
171
- return useMemo(
2622
+ return useMemo4(
172
2623
  () => ({
173
2624
  client,
174
2625
  getMethods: client.getMethods,
@@ -188,12 +2639,12 @@ var useAuth = (options = {}) => {
188
2639
  };
189
2640
  var useLoginMethods = (options = {}) => {
190
2641
  const auth = useAuth(options);
191
- const [state, setState] = useState({
2642
+ const [state, setState] = useState3({
192
2643
  data: null,
193
2644
  loading: true,
194
2645
  error: null
195
2646
  });
196
- const reload = useCallback(async () => {
2647
+ const reload = useCallback3(async () => {
197
2648
  setState((prev) => ({ ...prev, loading: true, error: null }));
198
2649
  try {
199
2650
  const data = await auth.getMethods();
@@ -206,7 +2657,7 @@ var useLoginMethods = (options = {}) => {
206
2657
  });
207
2658
  }
208
2659
  }, [auth]);
209
- useEffect(() => {
2660
+ useEffect3(() => {
210
2661
  let disposed = false;
211
2662
  const run = async () => {
212
2663
  setState((prev) => ({ ...prev, loading: true, error: null }));
@@ -250,16 +2701,16 @@ var LoginPage = ({
250
2701
  const methodsState = useLoginMethods(authOptions);
251
2702
  const [passwordForm] = Form.useForm();
252
2703
  const [phoneForm] = Form.useForm();
253
- const [activeMethod, setActiveMethod] = useState(
2704
+ const [activeMethod, setActiveMethod] = useState3(
254
2705
  defaultMethod || "password"
255
2706
  );
256
- const [phonePurpose, setPhonePurpose] = useState(
2707
+ const [phonePurpose, setPhonePurpose] = useState3(
257
2708
  "login"
258
2709
  );
259
- const [phoneChallengeId, setPhoneChallengeId] = useState("");
260
- const [submitting, setSubmitting] = useState(false);
261
- const [sendingCode, setSendingCode] = useState(false);
262
- const [error, setError] = useState(null);
2710
+ const [phoneChallengeId, setPhoneChallengeId] = useState3("");
2711
+ const [submitting, setSubmitting] = useState3(false);
2712
+ const [sendingCode, setSendingCode] = useState3(false);
2713
+ const [error, setError] = useState3(null);
263
2714
  const methods = methodsState.methods.filter((method) => method.enabled !== false);
264
2715
  const passwordMethod = findMethod(methods, "password");
265
2716
  const phoneMethod = findMethod(methods, "phone_code");
@@ -267,16 +2718,16 @@ var LoginPage = ({
267
2718
  const ssoMethod = findMethod(methods, "sso");
268
2719
  const guestMethod = findMethod(methods, "guest");
269
2720
  const allowRegister = methodsState.data?.registration?.mode !== "reject";
270
- const tabItems = useMemo(() => {
2721
+ const tabItems = useMemo4(() => {
271
2722
  const items = [];
272
2723
  if (passwordMethod) {
273
2724
  items.push({
274
2725
  key: "password",
275
2726
  label: /* @__PURE__ */ jsxs(Space, { size: 6, children: [
276
- /* @__PURE__ */ jsx(UserOutlined, {}),
277
- /* @__PURE__ */ jsx("span", { children: passwordMethod.label || "\u8D26\u53F7\u5BC6\u7801" })
2727
+ /* @__PURE__ */ jsx3(UserOutlined, {}),
2728
+ /* @__PURE__ */ jsx3("span", { children: passwordMethod.label || "\u8D26\u53F7\u5BC6\u7801" })
278
2729
  ] }),
279
- children: /* @__PURE__ */ jsx(
2730
+ children: /* @__PURE__ */ jsx3(
280
2731
  PasswordLoginForm,
281
2732
  {
282
2733
  form: passwordForm,
@@ -305,10 +2756,10 @@ var LoginPage = ({
305
2756
  items.push({
306
2757
  key: "phone_code",
307
2758
  label: /* @__PURE__ */ jsxs(Space, { size: 6, children: [
308
- /* @__PURE__ */ jsx(MobileOutlined, {}),
309
- /* @__PURE__ */ jsx("span", { children: phoneMethod.label || "\u624B\u673A\u53F7" })
2759
+ /* @__PURE__ */ jsx3(MobileOutlined, {}),
2760
+ /* @__PURE__ */ jsx3("span", { children: phoneMethod.label || "\u624B\u673A\u53F7" })
310
2761
  ] }),
311
- children: /* @__PURE__ */ jsx(
2762
+ children: /* @__PURE__ */ jsx3(
312
2763
  PhoneCodeLoginForm,
313
2764
  {
314
2765
  allowRegister,
@@ -371,7 +2822,7 @@ var LoginPage = ({
371
2822
  sendingCode,
372
2823
  submitting
373
2824
  ]);
374
- useEffect(() => {
2825
+ useEffect3(() => {
375
2826
  const firstKey = tabItems[0]?.key;
376
2827
  if (firstKey && !tabItems.some((item) => item.key === activeMethod)) {
377
2828
  setActiveMethod(firstKey);
@@ -398,7 +2849,7 @@ var LoginPage = ({
398
2849
  setSubmitting(true);
399
2850
  setError(null);
400
2851
  try {
401
- const redirectUri = getCurrentHref2();
2852
+ const redirectUri = getCurrentHref3();
402
2853
  const result = await auth.getSsoLoginUrl({
403
2854
  protocol: getString(ssoMethod, "protocol") || "cas",
404
2855
  redirectUri
@@ -434,7 +2885,7 @@ var LoginPage = ({
434
2885
  );
435
2886
  }
436
2887
  }
437
- return /* @__PURE__ */ jsx(
2888
+ return /* @__PURE__ */ jsx3(
438
2889
  "div",
439
2890
  {
440
2891
  className,
@@ -446,7 +2897,7 @@ var LoginPage = ({
446
2897
  background: "#f6f8fb",
447
2898
  ...style
448
2899
  },
449
- children: /* @__PURE__ */ jsx(
2900
+ children: /* @__PURE__ */ jsx3(
450
2901
  Card,
451
2902
  {
452
2903
  style: {
@@ -457,10 +2908,10 @@ var LoginPage = ({
457
2908
  styles: { body: { padding: 28 } },
458
2909
  children: /* @__PURE__ */ jsxs(Space, { direction: "vertical", size: 20, style: { width: "100%" }, children: [
459
2910
  /* @__PURE__ */ jsxs("div", { children: [
460
- /* @__PURE__ */ jsx(Typography.Title, { level: 3, style: { margin: 0 }, children: title || "\u5E94\u7528\u767B\u5F55" }),
461
- subtitle ? /* @__PURE__ */ jsx(Typography.Text, { type: "secondary", children: subtitle }) : null
2911
+ /* @__PURE__ */ jsx3(Typography.Title, { level: 3, style: { margin: 0 }, children: title || "\u5E94\u7528\u767B\u5F55" }),
2912
+ subtitle ? /* @__PURE__ */ jsx3(Typography.Text, { type: "secondary", children: subtitle }) : null
462
2913
  ] }),
463
- methodsState.error ? /* @__PURE__ */ jsx(
2914
+ methodsState.error ? /* @__PURE__ */ jsx3(
464
2915
  Alert,
465
2916
  {
466
2917
  showIcon: true,
@@ -468,41 +2919,41 @@ var LoginPage = ({
468
2919
  message: methodsState.error.message
469
2920
  }
470
2921
  ) : null,
471
- error ? /* @__PURE__ */ jsx(Alert, { showIcon: true, type: "error", message: error }) : null,
472
- methodsState.loading ? /* @__PURE__ */ jsx(Button, { block: true, loading: true, children: "\u52A0\u8F7D\u4E2D" }) : tabItems.length > 0 ? /* @__PURE__ */ jsx(
2922
+ error ? /* @__PURE__ */ jsx3(Alert, { showIcon: true, type: "error", message: error }) : null,
2923
+ methodsState.loading ? /* @__PURE__ */ jsx3(Button, { block: true, loading: true, children: "\u52A0\u8F7D\u4E2D" }) : tabItems.length > 0 ? /* @__PURE__ */ jsx3(
473
2924
  Tabs,
474
2925
  {
475
2926
  activeKey: activeMethod,
476
2927
  items: tabItems,
477
2928
  onChange: setActiveMethod
478
2929
  }
479
- ) : /* @__PURE__ */ jsx(Empty, { description: "\u672A\u542F\u7528\u767B\u5F55\u65B9\u5F0F" }),
2930
+ ) : /* @__PURE__ */ jsx3(Empty, { description: "\u672A\u542F\u7528\u767B\u5F55\u65B9\u5F0F" }),
480
2931
  /* @__PURE__ */ jsxs(Space, { direction: "vertical", size: 10, style: { width: "100%" }, children: [
481
- dingtalkMethod ? /* @__PURE__ */ jsx(
2932
+ dingtalkMethod ? /* @__PURE__ */ jsx3(
482
2933
  Button,
483
2934
  {
484
2935
  block: true,
485
- icon: /* @__PURE__ */ jsx(QrcodeOutlined, {}),
2936
+ icon: /* @__PURE__ */ jsx3(QrcodeOutlined, {}),
486
2937
  loading: submitting,
487
2938
  onClick: handleDingTalkLogin,
488
2939
  children: dingtalkMethod.label || "\u9489\u9489\u514D\u767B"
489
2940
  }
490
2941
  ) : null,
491
- ssoMethod ? /* @__PURE__ */ jsx(
2942
+ ssoMethod ? /* @__PURE__ */ jsx3(
492
2943
  Button,
493
2944
  {
494
2945
  block: true,
495
- icon: /* @__PURE__ */ jsx(SafetyCertificateOutlined, {}),
2946
+ icon: /* @__PURE__ */ jsx3(SafetyCertificateOutlined, {}),
496
2947
  loading: submitting,
497
2948
  onClick: handleSsoLogin,
498
2949
  children: ssoMethod.label || "SSO \u767B\u5F55"
499
2950
  }
500
2951
  ) : null,
501
- guestMethod ? /* @__PURE__ */ jsx(
2952
+ guestMethod ? /* @__PURE__ */ jsx3(
502
2953
  Button,
503
2954
  {
504
2955
  block: true,
505
- icon: /* @__PURE__ */ jsx(LoginOutlined, {}),
2956
+ icon: /* @__PURE__ */ jsx3(LoginOutlined, {}),
506
2957
  loading: submitting,
507
2958
  onClick: handleGuestLogin,
508
2959
  children: guestMethod.label || "\u8BBF\u5BA2\u8BBF\u95EE"
@@ -516,25 +2967,25 @@ var LoginPage = ({
516
2967
  );
517
2968
  };
518
2969
  var PasswordLoginForm = ({ form, loading, onFinish }) => /* @__PURE__ */ jsxs(Form, { form, layout: "vertical", requiredMark: false, onFinish, children: [
519
- /* @__PURE__ */ jsx(
2970
+ /* @__PURE__ */ jsx3(
520
2971
  Form.Item,
521
2972
  {
522
2973
  label: "\u8D26\u53F7",
523
2974
  name: "username",
524
2975
  rules: [{ required: true, message: "\u8BF7\u8F93\u5165\u8D26\u53F7" }],
525
- children: /* @__PURE__ */ jsx(Input, { autoComplete: "username" })
2976
+ children: /* @__PURE__ */ jsx3(Input, { autoComplete: "username" })
526
2977
  }
527
2978
  ),
528
- /* @__PURE__ */ jsx(
2979
+ /* @__PURE__ */ jsx3(
529
2980
  Form.Item,
530
2981
  {
531
2982
  label: "\u5BC6\u7801",
532
2983
  name: "password",
533
2984
  rules: [{ required: true, message: "\u8BF7\u8F93\u5165\u5BC6\u7801" }],
534
- children: /* @__PURE__ */ jsx(Input.Password, { autoComplete: "current-password" })
2985
+ children: /* @__PURE__ */ jsx3(Input.Password, { autoComplete: "current-password" })
535
2986
  }
536
2987
  ),
537
- /* @__PURE__ */ jsx(Button, { block: true, htmlType: "submit", icon: /* @__PURE__ */ jsx(LoginOutlined, {}), loading, type: "primary", children: "\u767B\u5F55" })
2988
+ /* @__PURE__ */ jsx3(Button, { block: true, htmlType: "submit", icon: /* @__PURE__ */ jsx3(LoginOutlined, {}), loading, type: "primary", children: "\u767B\u5F55" })
538
2989
  ] });
539
2990
  var PhoneCodeLoginForm = ({
540
2991
  allowRegister,
@@ -546,7 +2997,7 @@ var PhoneCodeLoginForm = ({
546
2997
  onSendCode,
547
2998
  onFinish
548
2999
  }) => /* @__PURE__ */ jsxs(Form, { form, layout: "vertical", requiredMark: false, onFinish, children: [
549
- allowRegister ? /* @__PURE__ */ jsx(Form.Item, { style: { marginBottom: 12 }, children: /* @__PURE__ */ jsx(
3000
+ allowRegister ? /* @__PURE__ */ jsx3(Form.Item, { style: { marginBottom: 12 }, children: /* @__PURE__ */ jsx3(
550
3001
  Tabs,
551
3002
  {
552
3003
  activeKey: phonePurpose,
@@ -558,25 +3009,25 @@ var PhoneCodeLoginForm = ({
558
3009
  size: "small"
559
3010
  }
560
3011
  ) }) : null,
561
- /* @__PURE__ */ jsx(
3012
+ /* @__PURE__ */ jsx3(
562
3013
  Form.Item,
563
3014
  {
564
3015
  label: "\u624B\u673A\u53F7",
565
3016
  name: "phone",
566
3017
  rules: [{ required: true, message: "\u8BF7\u8F93\u5165\u624B\u673A\u53F7" }],
567
- children: /* @__PURE__ */ jsx(Input, { autoComplete: "tel" })
3018
+ children: /* @__PURE__ */ jsx3(Input, { autoComplete: "tel" })
568
3019
  }
569
3020
  ),
570
- /* @__PURE__ */ jsx(
3021
+ /* @__PURE__ */ jsx3(
571
3022
  Form.Item,
572
3023
  {
573
3024
  label: "\u9A8C\u8BC1\u7801",
574
3025
  name: "code",
575
3026
  rules: [{ required: true, message: "\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801" }],
576
- children: /* @__PURE__ */ jsx(
3027
+ children: /* @__PURE__ */ jsx3(
577
3028
  Input,
578
3029
  {
579
- addonAfter: /* @__PURE__ */ jsx(
3030
+ addonAfter: /* @__PURE__ */ jsx3(
580
3031
  Button,
581
3032
  {
582
3033
  loading: sendingCode,
@@ -591,7 +3042,7 @@ var PhoneCodeLoginForm = ({
591
3042
  )
592
3043
  }
593
3044
  ),
594
- /* @__PURE__ */ jsx(Button, { block: true, htmlType: "submit", icon: /* @__PURE__ */ jsx(MobileOutlined, {}), loading, type: "primary", children: phonePurpose === "register" ? "\u6CE8\u518C" : "\u767B\u5F55" })
3045
+ /* @__PURE__ */ jsx3(Button, { block: true, htmlType: "submit", icon: /* @__PURE__ */ jsx3(MobileOutlined, {}), loading, type: "primary", children: phonePurpose === "register" ? "\u6CE8\u518C" : "\u767B\u5F55" })
595
3046
  ] });
596
3047
  var findMethod = (methods, type) => methods.find((method) => method.type === type);
597
3048
  var normalizeError = (error) => error instanceof Error ? error : new Error(String(error || "\u8BF7\u6C42\u5931\u8D25"));
@@ -629,7 +3080,7 @@ var getOrCreateGuestIdentifier = (client) => {
629
3080
  return next;
630
3081
  };
631
3082
  var createGuestIdentifier = () => `guest_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
632
- var getCurrentHref2 = () => typeof window === "undefined" ? "" : window.location.href;
3083
+ var getCurrentHref3 = () => typeof window === "undefined" ? "" : window.location.href;
633
3084
  var getCurrentHostname = () => typeof window === "undefined" ? "" : window.location.hostname;
634
3085
  var getCallbackUrl = () => {
635
3086
  if (typeof window === "undefined") return "";
@@ -638,7 +3089,7 @@ var getCallbackUrl = () => {
638
3089
  };
639
3090
 
640
3091
  // packages/sdk/src/runtime/react/openxiangdaProvider.tsx
641
- import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
3092
+ import { Fragment as Fragment2, jsx as jsx4 } from "react/jsx-runtime";
642
3093
  var RuntimeHttpError = class extends Error {
643
3094
  constructor(snapshot) {
644
3095
  super(snapshot.message);
@@ -649,24 +3100,24 @@ var RuntimeHttpError = class extends Error {
649
3100
  this.payload = snapshot.payload;
650
3101
  }
651
3102
  };
652
- var OpenXiangdaRuntimeContext = createContext(null);
3103
+ var OpenXiangdaRuntimeContext = createContext2(null);
653
3104
  var OpenXiangdaProvider = ({
654
3105
  appType,
655
3106
  servicePrefix = "/service",
656
3107
  fetchImpl,
657
3108
  children
658
3109
  }) => {
659
- const resolvedFetch = useMemo2(() => createBoundFetch(fetchImpl), [fetchImpl]);
660
- const resolvedAppType = useMemo2(
3110
+ const resolvedFetch = useMemo5(() => createBoundFetch(fetchImpl), [fetchImpl]);
3111
+ const resolvedAppType = useMemo5(
661
3112
  () => appType || resolveAppTypeFromLocation(),
662
3113
  [appType]
663
3114
  );
664
- const [state, setState] = useState2({
3115
+ const [state, setState] = useState4({
665
3116
  data: null,
666
3117
  loading: true,
667
3118
  error: null
668
3119
  });
669
- const reload = useCallback2(async () => {
3120
+ const reload = useCallback4(async () => {
670
3121
  if (!resolvedAppType) {
671
3122
  setState({
672
3123
  data: null,
@@ -713,10 +3164,10 @@ var OpenXiangdaProvider = ({
713
3164
  });
714
3165
  }
715
3166
  }, [resolvedAppType, resolvedFetch, servicePrefix]);
716
- useEffect2(() => {
3167
+ useEffect4(() => {
717
3168
  void reload();
718
3169
  }, [reload]);
719
- const value = useMemo2(
3170
+ const value = useMemo5(
720
3171
  () => ({
721
3172
  ...state,
722
3173
  appType: resolvedAppType,
@@ -726,10 +3177,10 @@ var OpenXiangdaProvider = ({
726
3177
  }),
727
3178
  [reload, resolvedAppType, resolvedFetch, servicePrefix, state]
728
3179
  );
729
- return /* @__PURE__ */ jsx2(OpenXiangdaRuntimeContext.Provider, { value, children });
3180
+ return /* @__PURE__ */ jsx4(OpenXiangdaRuntimeContext.Provider, { value, children });
730
3181
  };
731
3182
  var useOpenXiangda = () => {
732
- const context = useContext(OpenXiangdaRuntimeContext);
3183
+ const context = useContext2(OpenXiangdaRuntimeContext);
733
3184
  if (!context) {
734
3185
  throw new Error("useOpenXiangda must be used inside OpenXiangdaProvider");
735
3186
  }
@@ -752,12 +3203,12 @@ var usePermission = () => {
752
3203
  };
753
3204
  var useCanAccessRoute = (input) => {
754
3205
  const runtime = useOpenXiangda();
755
- const [state, setState] = useState2({
3206
+ const [state, setState] = useState4({
756
3207
  data: null,
757
3208
  loading: true,
758
3209
  error: null
759
3210
  });
760
- useEffect2(() => {
3211
+ useEffect4(() => {
761
3212
  let disposed = false;
762
3213
  const check = async () => {
763
3214
  const permissions = runtime.data?.permissions;
@@ -879,18 +3330,18 @@ var PermissionBoundary = ({
879
3330
  const access = useCanAccessRoute({ routeCode, menuCode, path });
880
3331
  const fallbackState = createPermissionFallbackState(access, runtime);
881
3332
  if (access.loading) {
882
- return /* @__PURE__ */ jsx2(Fragment, { children: renderBoundaryFallback(loadingFallback, fallbackState) });
3333
+ return /* @__PURE__ */ jsx4(Fragment2, { children: renderBoundaryFallback(loadingFallback, fallbackState) });
883
3334
  }
884
3335
  if (!access.canAccess) {
885
- return /* @__PURE__ */ jsx2(Fragment, { children: renderBoundaryFallback(fallback, fallbackState) });
3336
+ return /* @__PURE__ */ jsx4(Fragment2, { children: renderBoundaryFallback(fallback, fallbackState) });
886
3337
  }
887
- return /* @__PURE__ */ jsx2(Fragment, { children });
3338
+ return /* @__PURE__ */ jsx4(Fragment2, { children });
888
3339
  };
889
3340
  var useRuntimeAuth = () => {
890
3341
  const runtime = useOpenXiangda();
891
- const resolveLoginUrl2 = useCallback2(
3342
+ const resolveLoginUrl2 = useCallback4(
892
3343
  async (options = {}) => {
893
- const redirectUri = options.redirectUri || getCurrentHref3();
3344
+ const redirectUri = options.redirectUri || getCurrentHref4();
894
3345
  const domain = options.domain || getCurrentHostname2();
895
3346
  const appTenantId = getRecordString(runtime.data?.app, "tenantId");
896
3347
  try {
@@ -935,7 +3386,7 @@ var useRuntimeAuth = () => {
935
3386
  },
936
3387
  [runtime.data?.app, runtime.fetchImpl, runtime.servicePrefix]
937
3388
  );
938
- const redirectToLogin = useCallback2(
3389
+ const redirectToLogin = useCallback4(
939
3390
  async (options = {}) => {
940
3391
  const loginUrl = await resolveLoginUrl2(options);
941
3392
  if (typeof window !== "undefined") {
@@ -949,7 +3400,7 @@ var useRuntimeAuth = () => {
949
3400
  },
950
3401
  [resolveLoginUrl2]
951
3402
  );
952
- const logout = useCallback2(async () => {
3403
+ const logout = useCallback4(async () => {
953
3404
  const response = await runtime.fetchImpl(
954
3405
  buildServiceUrl2(runtime.servicePrefix, "/api/auth/logout"),
955
3406
  {
@@ -968,7 +3419,7 @@ var useRuntimeAuth = () => {
968
3419
  }
969
3420
  return payload;
970
3421
  }, [runtime.fetchImpl, runtime.servicePrefix]);
971
- const logoutAndRedirect = useCallback2(
3422
+ const logoutAndRedirect = useCallback4(
972
3423
  async (options = {}) => {
973
3424
  try {
974
3425
  await logout();
@@ -1081,7 +3532,7 @@ var attachCallback = (loginUrl, callback) => {
1081
3532
  return `${loginUrl}${separator}callback=${encodeURIComponent(callback)}`;
1082
3533
  }
1083
3534
  };
1084
- var getCurrentHref3 = () => typeof window === "undefined" ? "" : window.location.href;
3535
+ var getCurrentHref4 = () => typeof window === "undefined" ? "" : window.location.href;
1085
3536
  var getCurrentHostname2 = () => typeof window === "undefined" ? "" : window.location.hostname;
1086
3537
  var getRuntimeEnv = (key) => {
1087
3538
  const env = typeof process !== "undefined" ? process.env : void 0;
@@ -1103,19 +3554,233 @@ var resolveAppTypeFromLocation = () => {
1103
3554
  if (segments[viewIndex] === "preview") return segments[viewIndex + 1] || "";
1104
3555
  return segments[viewIndex] || "";
1105
3556
  };
3557
+
3558
+ // packages/sdk/src/runtime/react/publicAccess.tsx
3559
+ import { useCallback as useCallback5, useEffect as useEffect5, useMemo as useMemo6, useState as useState5 } from "react";
3560
+
3561
+ // packages/sdk/src/runtime/core/publicAccess.ts
3562
+ var PublicAccessClientError = class extends Error {
3563
+ constructor(message2, options = {}) {
3564
+ super(message2);
3565
+ this.name = "PublicAccessClientError";
3566
+ this.status = options.status;
3567
+ this.code = options.code;
3568
+ this.payload = options.payload;
3569
+ }
3570
+ };
3571
+ var createPublicAccessClient = ({
3572
+ appType,
3573
+ servicePrefix = "/service",
3574
+ fetchImpl
3575
+ }) => {
3576
+ const normalizedAppType = String(appType || "").trim();
3577
+ if (!normalizedAppType) {
3578
+ throw new Error("appType \u4E0D\u80FD\u4E3A\u7A7A");
3579
+ }
3580
+ const boundFetch = createBoundFetch(fetchImpl);
3581
+ const request = async (input = {}) => {
3582
+ const body = {
3583
+ ...input,
3584
+ path: input.path || getCurrentPathname(),
3585
+ domain: input.domain || getCurrentDomain(),
3586
+ userAgent: input.userAgent || getCurrentUserAgent(),
3587
+ guestIdentifier: input.guestIdentifier || getOrCreatePublicGuestIdentifier(normalizedAppType)
3588
+ };
3589
+ const response = await boundFetch(
3590
+ buildServiceUrl3(
3591
+ servicePrefix,
3592
+ `/openxiangda-api/v1/apps/${encodeURIComponent(
3593
+ normalizedAppType
3594
+ )}/public/session`
3595
+ ),
3596
+ {
3597
+ method: "POST",
3598
+ credentials: "include",
3599
+ headers: {
3600
+ accept: "application/json",
3601
+ "content-type": "application/json"
3602
+ },
3603
+ body: JSON.stringify(body)
3604
+ }
3605
+ );
3606
+ const payload = await readPayload2(response);
3607
+ const code = getRecordValue3(payload, "code");
3608
+ if (!response.ok || typeof code === "number" && code >= 400) {
3609
+ throw new PublicAccessClientError(
3610
+ String(
3611
+ getRecordValue3(payload, "message") || `Public access session failed: ${response.status}`
3612
+ ),
3613
+ { status: response.status, code, payload }
3614
+ );
3615
+ }
3616
+ const data = getRecordValue3(payload, "data");
3617
+ const extra = getRecordValue3(payload, "extra");
3618
+ return {
3619
+ ...data,
3620
+ publicAccess: extra?.publicAccess || null,
3621
+ raw: payload
3622
+ };
3623
+ };
3624
+ return {
3625
+ appType: normalizedAppType,
3626
+ servicePrefix,
3627
+ startSession: request
3628
+ };
3629
+ };
3630
+ var buildServiceUrl3 = (servicePrefix, path) => {
3631
+ const prefix = servicePrefix.endsWith("/") ? servicePrefix.slice(0, -1) : servicePrefix;
3632
+ const suffix = path.startsWith("/") ? path : `/${path}`;
3633
+ return `${prefix}${suffix}`;
3634
+ };
3635
+ var readPayload2 = async (response) => {
3636
+ try {
3637
+ return await response.json();
3638
+ } catch {
3639
+ return null;
3640
+ }
3641
+ };
3642
+ var getRecordValue3 = (value, key) => {
3643
+ if (!value || typeof value !== "object") return void 0;
3644
+ return value[key];
3645
+ };
3646
+ var getCurrentPathname = () => typeof window === "undefined" ? void 0 : window.location.pathname;
3647
+ var getCurrentDomain = () => typeof window === "undefined" ? void 0 : window.location.host;
3648
+ var getCurrentUserAgent = () => typeof navigator === "undefined" ? void 0 : navigator.userAgent;
3649
+ var getOrCreatePublicGuestIdentifier = (appType) => {
3650
+ const key = `openxiangda:public:guest:${appType}`;
3651
+ try {
3652
+ if (typeof window !== "undefined" && window.localStorage) {
3653
+ const existing = window.localStorage.getItem(key);
3654
+ if (existing) return existing;
3655
+ const next = createRandomIdentifier(appType);
3656
+ window.localStorage.setItem(key, next);
3657
+ return next;
3658
+ }
3659
+ } catch {
3660
+ }
3661
+ return createRandomIdentifier(appType);
3662
+ };
3663
+ var createRandomIdentifier = (appType) => {
3664
+ const random = typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : Math.random().toString(36).slice(2);
3665
+ return `public:${appType}:${random}`;
3666
+ };
3667
+
3668
+ // packages/sdk/src/runtime/react/publicAccess.tsx
3669
+ import { Fragment as Fragment3, jsx as jsx5 } from "react/jsx-runtime";
3670
+ var usePublicAccess = (options = {}) => {
3671
+ const runtime = useOpenXiangda();
3672
+ const {
3673
+ appType: runtimeAppType,
3674
+ servicePrefix: runtimeServicePrefix,
3675
+ fetchImpl: runtimeFetchImpl,
3676
+ reload: reloadRuntime
3677
+ } = runtime;
3678
+ const {
3679
+ appType = runtimeAppType,
3680
+ servicePrefix = runtimeServicePrefix,
3681
+ fetchImpl = runtimeFetchImpl,
3682
+ autoStart = true,
3683
+ ...sessionInput
3684
+ } = options;
3685
+ const [session, setSession] = useState5(null);
3686
+ const [error, setError] = useState5(null);
3687
+ const [loading, setLoading] = useState5(Boolean(autoStart));
3688
+ const sessionInputKey = JSON.stringify(sessionInput);
3689
+ const stableSessionInput = useMemo6(() => sessionInput, [sessionInputKey]);
3690
+ const client = useMemo6(
3691
+ () => createPublicAccessClient({
3692
+ appType,
3693
+ servicePrefix,
3694
+ fetchImpl
3695
+ }),
3696
+ [appType, fetchImpl, servicePrefix]
3697
+ );
3698
+ const startSession = useCallback5(
3699
+ async (input = {}) => {
3700
+ setLoading(true);
3701
+ setError(null);
3702
+ try {
3703
+ const data = await client.startSession({
3704
+ ...stableSessionInput,
3705
+ ...input,
3706
+ ticket: input.ticket || stableSessionInput.ticket || readTicketFromLocation(),
3707
+ path: input.path || stableSessionInput.path || readPathFromLocation()
3708
+ });
3709
+ setSession(data);
3710
+ await reloadRuntime();
3711
+ setLoading(false);
3712
+ return data;
3713
+ } catch (caught) {
3714
+ const nextError = caught instanceof PublicAccessClientError ? caught : new PublicAccessClientError(
3715
+ caught instanceof Error ? caught.message : "\u516C\u5F00\u8BBF\u95EE\u4F1A\u8BDD\u521B\u5EFA\u5931\u8D25",
3716
+ { payload: caught }
3717
+ );
3718
+ setError(nextError);
3719
+ setLoading(false);
3720
+ throw nextError;
3721
+ }
3722
+ },
3723
+ [client, reloadRuntime, stableSessionInput]
3724
+ );
3725
+ useEffect5(() => {
3726
+ if (!autoStart) return;
3727
+ void startSession().catch(() => void 0);
3728
+ }, [autoStart, startSession]);
3729
+ return {
3730
+ loading,
3731
+ error,
3732
+ session,
3733
+ publicAccess: session?.publicAccess || null,
3734
+ startSession
3735
+ };
3736
+ };
3737
+ var PublicAccessGate = ({
3738
+ children,
3739
+ fallback = null,
3740
+ errorFallback = null,
3741
+ ...options
3742
+ }) => {
3743
+ const state = usePublicAccess(options);
3744
+ if (state.loading) return /* @__PURE__ */ jsx5(Fragment3, { children: fallback });
3745
+ if (state.error) {
3746
+ return /* @__PURE__ */ jsx5(Fragment3, { children: typeof errorFallback === "function" ? errorFallback(state.error) : errorFallback });
3747
+ }
3748
+ return /* @__PURE__ */ jsx5(Fragment3, { children });
3749
+ };
3750
+ var readTicketFromLocation = () => {
3751
+ if (typeof window === "undefined") return void 0;
3752
+ return new URLSearchParams(window.location.search).get("ticket") || void 0;
3753
+ };
3754
+ var readPathFromLocation = () => typeof window === "undefined" ? void 0 : window.location.pathname;
1106
3755
  export {
1107
3756
  AuthClientError,
1108
3757
  LoginPage,
1109
3758
  OpenXiangdaProvider,
3759
+ PageProvider,
1110
3760
  PermissionBoundary,
1111
- RuntimeHttpError,
3761
+ PublicAccessClientError,
3762
+ PublicAccessGate,
1112
3763
  createAuthClient,
3764
+ createPageSdk,
3765
+ createPublicAccessClient,
3766
+ createReactPage,
1113
3767
  useAppMenus,
1114
3768
  useAuth,
1115
3769
  useCanAccessRoute,
3770
+ useCurrentUser,
3771
+ useDataSource,
3772
+ useFormViewPermissions,
1116
3773
  useLoginMethods,
3774
+ useMessage,
3775
+ useModal,
3776
+ useNavigation,
1117
3777
  useOpenXiangda,
3778
+ usePageContext,
3779
+ usePageProps,
3780
+ usePageRoute,
3781
+ usePageSdk,
1118
3782
  usePermission,
3783
+ usePublicAccess,
1119
3784
  useRuntimeAuth,
1120
3785
  useRuntimeBootstrap
1121
3786
  };