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