openxiangda 1.0.84 → 1.0.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/lib/cli.js +305 -10
- package/openxiangda-skills/SKILL.md +4 -1
- package/openxiangda-skills/references/architecture-design.md +38 -4
- package/openxiangda-skills/references/connector-resources.md +3 -0
- package/openxiangda-skills/references/pages/page-sdk.md +39 -0
- package/openxiangda-skills/references/resource-manifest-cheatsheet.md +81 -0
- package/package.json +2 -1
- package/packages/sdk/dist/openxiangdaProvider-CaXMpsnK.d.mts +328 -0
- package/packages/sdk/dist/openxiangdaProvider-CaXMpsnK.d.ts +328 -0
- package/packages/sdk/dist/runtime/index.cjs +4250 -3641
- package/packages/sdk/dist/runtime/index.cjs.map +1 -1
- package/packages/sdk/dist/runtime/index.d.mts +1 -1
- package/packages/sdk/dist/runtime/index.d.ts +1 -1
- package/packages/sdk/dist/runtime/index.mjs +3845 -3219
- package/packages/sdk/dist/runtime/index.mjs.map +1 -1
- package/packages/sdk/dist/runtime/react.cjs +645 -38
- package/packages/sdk/dist/runtime/react.cjs.map +1 -1
- package/packages/sdk/dist/runtime/react.d.mts +2 -162
- package/packages/sdk/dist/runtime/react.d.ts +2 -162
- package/packages/sdk/dist/runtime/react.mjs +667 -39
- package/packages/sdk/dist/runtime/react.mjs.map +1 -1
- package/templates/openxiangda-react-spa/src/app/router.tsx +2 -1
|
@@ -14,6 +14,7 @@ Guidelines:
|
|
|
14
14
|
- Use `sdk.function.invoke(code, { input })` for reusable backend business logic declared under `src/resources/functions/` and `src/functions/`. Do not implement multi-form orchestration, connector fan-out, notification orchestration, or permission-sensitive backend rules directly in a page component.
|
|
15
15
|
- Use `sdk.connector.invoke`, `sdk.connector.call("connector.api")`, or `sdk.connector.download` for external services. The SDK calls the platform runtime connector endpoint; it must not call third-party domains directly.
|
|
16
16
|
- Use `sdk.notification.sendByType` and `batchSendByType` for reusable business messages. Custom notification types must be declared in `src/resources/notifications/` and published with `openxiangda resource publish`.
|
|
17
|
+
- Use `createAuthClient` from `openxiangda/runtime` or `LoginPage` / `useAuth` from `openxiangda/runtime/react` for application login pages. Auth provider App Functions return identity assertions only; platform auth owns create/bind/reject/token decisions.
|
|
17
18
|
- For the current user's department hierarchy, use `sdk.department.getCurrentUserParentDepartments()`; do not hardcode `GET /department/:id/parentDepartments` in page code.
|
|
18
19
|
- Use `sdk.auth.logoutAndRedirect({ loginUrl })` for user logout when the page should return after login. It calls the platform logout endpoint, appends the current page URL as `callback`, and redirects to the login URL. Use `sdk.auth.logout()` only when the page wants to handle redirect itself.
|
|
19
20
|
- Use `sdk.role.getMyRoles()`, `sdk.role.getCurrentRole()`, and `sdk.role.switchAppRole()` for current-user app role switching. Pass `roleId: ""` to switch back to all app roles.
|
|
@@ -102,6 +103,44 @@ const result = await sdk.function.invoke("reservation_reminder_summary", {
|
|
|
102
103
|
|
|
103
104
|
Use App Functions when the logic must run server-side and be reusable by pages, automations, or workflows. Current runtime invocation requires the caller to have app automation management permission; ordinary page users should normally consume function-backed data through a permission-aware page or a narrower backend resource.
|
|
104
105
|
|
|
106
|
+
Application auth:
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
import { LoginPage, useAuth, useLoginMethods } from "openxiangda/runtime/react";
|
|
110
|
+
|
|
111
|
+
export function DefaultLogin() {
|
|
112
|
+
return <LoginPage />;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function CustomPhoneLogin() {
|
|
116
|
+
const auth = useAuth();
|
|
117
|
+
const methods = useLoginMethods();
|
|
118
|
+
|
|
119
|
+
async function submit(phone: string, code: string, challengeId: string) {
|
|
120
|
+
await auth.phoneCodeLogin({ phone, code, challengeId });
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Standalone client:
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
import { createAuthClient } from "openxiangda/runtime";
|
|
131
|
+
|
|
132
|
+
const auth = createAuthClient({ appType, servicePrefix: "/service" });
|
|
133
|
+
const methods = await auth.getMethods();
|
|
134
|
+
const sent = await auth.sendPhoneCode({ phone, purpose: "login" });
|
|
135
|
+
const result = await auth.phoneCodeLogin({
|
|
136
|
+
phone,
|
|
137
|
+
code,
|
|
138
|
+
challengeId: sent.challengeId,
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
For phone-code auth, the App Function provider receives `event`, `appType`, `method`, `credential`, `requestId`, `request`, and `challenge`. It may return `{ ok, providerState }` for send and `{ ok, identity }` for verify. It must not return `token`, `accessToken`, `refreshToken`, cookies, or mutate platform account tables.
|
|
143
|
+
|
|
105
144
|
Logout and current-user role switching:
|
|
106
145
|
|
|
107
146
|
```ts
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
- **平台 ID 由 CLI 解析**:`openxiangda resource publish --profile <name>` 把 code 解析成当前 profile 的真实 ID 并写回 `.openxiangda/state.json`。
|
|
10
10
|
- **永远不写密钥**:第三方 API key、token、secret、password、authorization、headers 等绝不出现在 `src/resources/`,平台管理员在后台配置。
|
|
11
11
|
- **多 profile 不共享 ID**:`dev` / `prod` 各自维护一份资源 ID 映射,复制 manifest 即可复用,不要复制平台 ID。
|
|
12
|
+
- **Auth provider 只返回身份声明**:登录 provider App Function 不能发 token、写 cookie、直接改用户表或绑定表;平台按策略创建/绑定/拒绝。
|
|
12
13
|
|
|
13
14
|
## 命令
|
|
14
15
|
|
|
@@ -20,6 +21,86 @@ openxiangda resource publish --profile <name> --prune # 删除 manifest 未声
|
|
|
20
21
|
openxiangda resource pull --profile <name> # 拉取平台资源回写到本地(用于初次同步)
|
|
21
22
|
```
|
|
22
23
|
|
|
24
|
+
## 0. Auth — `src/resources/auth/<code>.json`
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"code": "default",
|
|
29
|
+
"name": "Default App Login",
|
|
30
|
+
"status": "active",
|
|
31
|
+
"configJson": {
|
|
32
|
+
"methods": [
|
|
33
|
+
{ "type": "password", "enabled": true, "label": "账号密码" },
|
|
34
|
+
{ "type": "dingtalk", "enabled": true, "label": "钉钉免登" },
|
|
35
|
+
{ "type": "sso", "enabled": true, "label": "CAS", "protocol": "cas" },
|
|
36
|
+
{
|
|
37
|
+
"type": "phone_code",
|
|
38
|
+
"enabled": true,
|
|
39
|
+
"label": "手机号验证码",
|
|
40
|
+
"ttlSeconds": 300,
|
|
41
|
+
"sendFrequencySeconds": 60,
|
|
42
|
+
"maxAttempts": 5,
|
|
43
|
+
"provider": { "functionCode": "auth_phone_code" }
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"registration": { "mode": "reject" },
|
|
47
|
+
"binding": { "mode": "auto" },
|
|
48
|
+
"matching": {
|
|
49
|
+
"keys": ["phone", "email", "externalId", "unionId", "jobNumber", "username"]
|
|
50
|
+
},
|
|
51
|
+
"defaultRoleCodes": []
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Provider function:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
export default async function authPhoneCodeProvider(ctx, input) {
|
|
60
|
+
if (input.event === "phone_code.send") {
|
|
61
|
+
return { ok: true, providerState: { nonce: "vendor-message-id" } };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (input.event === "phone_code.verify") {
|
|
65
|
+
if (input.credential.code !== "123456") {
|
|
66
|
+
return { ok: false, message: "验证码错误" };
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
ok: true,
|
|
70
|
+
identity: {
|
|
71
|
+
phone: input.credential.phone,
|
|
72
|
+
externalId: `phone:${input.credential.phone}`
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return { ok: false, message: "不支持的认证事件" };
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
React 默认页:
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import { LoginPage } from "openxiangda/runtime/react";
|
|
85
|
+
|
|
86
|
+
export default function AppLogin() {
|
|
87
|
+
return <LoginPage />;
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
自定义登录页:
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
import { createAuthClient } from "openxiangda/runtime";
|
|
95
|
+
|
|
96
|
+
const auth = createAuthClient({ appType, servicePrefix: "/service" });
|
|
97
|
+
const methods = await auth.getMethods();
|
|
98
|
+
const sent = await auth.sendPhoneCode({ phone, purpose: "login" });
|
|
99
|
+
await auth.phoneCodeLogin({ phone, code, challengeId: sent.challengeId });
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
设计前必须确认启用方式、注册策略、身份匹配键、provider 边界、默认权限、安全参数、第三方配置归属。
|
|
103
|
+
|
|
23
104
|
## 1. Connector — `src/resources/connectors/<code>.json`
|
|
24
105
|
|
|
25
106
|
```json
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openxiangda",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.86",
|
|
4
4
|
"description": "OpenXiangda CLI, workspace build tools, runtime SDK, and form components.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"bin": {
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"prepack": "npm run build:sdk",
|
|
66
66
|
"test:profile-isolation": "bash scripts/profile-isolation-smoke.sh",
|
|
67
67
|
"test:resource-plan": "node scripts/resource-plan-smoke.mjs",
|
|
68
|
+
"test:app-function-fallback": "node scripts/app-function-source-fallback-smoke.mjs",
|
|
68
69
|
"test:runtime-deploy": "node scripts/runtime-deploy-smoke.mjs",
|
|
69
70
|
"test:skill-install": "bash scripts/skill-install-smoke.sh",
|
|
70
71
|
"test:workspace-init": "bash scripts/workspace-init-smoke.sh"
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import React__default, { CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
type AuthMethodType = "password" | "dingtalk" | "sso" | "guest" | "phone_code" | string;
|
|
4
|
+
interface AuthMethod {
|
|
5
|
+
type: AuthMethodType;
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
label?: string;
|
|
8
|
+
protocol?: string;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
interface LoginMethodsResult {
|
|
12
|
+
appType: string;
|
|
13
|
+
configCode?: string;
|
|
14
|
+
methods: AuthMethod[];
|
|
15
|
+
registration?: {
|
|
16
|
+
mode?: string;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
};
|
|
19
|
+
security?: {
|
|
20
|
+
hideFailureReason?: boolean;
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
};
|
|
23
|
+
defaultRedirectUrl?: string;
|
|
24
|
+
}
|
|
25
|
+
interface AuthUser {
|
|
26
|
+
id: string;
|
|
27
|
+
username?: string;
|
|
28
|
+
name?: string;
|
|
29
|
+
phone?: string | null;
|
|
30
|
+
email?: string | null;
|
|
31
|
+
avatar?: string | null;
|
|
32
|
+
jobNumber?: string | null;
|
|
33
|
+
departments?: Array<Record<string, unknown>>;
|
|
34
|
+
affiliatedDepartmentId?: string | null;
|
|
35
|
+
affiliatedDepartment?: Record<string, unknown> | null;
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
}
|
|
38
|
+
interface AuthTokenData {
|
|
39
|
+
accessToken: string;
|
|
40
|
+
refreshToken: string;
|
|
41
|
+
token?: string;
|
|
42
|
+
accessTokenExpiresAt?: number;
|
|
43
|
+
refreshTokenExpiresAt?: number;
|
|
44
|
+
user?: AuthUser;
|
|
45
|
+
guestUser?: AuthUser;
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
}
|
|
48
|
+
interface PhoneCodeSendResult {
|
|
49
|
+
challengeId: string;
|
|
50
|
+
expiresAt?: string | Date;
|
|
51
|
+
ttlSeconds?: number;
|
|
52
|
+
message?: string;
|
|
53
|
+
}
|
|
54
|
+
interface SsoLoginUrlResult {
|
|
55
|
+
loginUrl: string;
|
|
56
|
+
protocol?: string;
|
|
57
|
+
}
|
|
58
|
+
interface AuthClientOptions {
|
|
59
|
+
appType: string;
|
|
60
|
+
servicePrefix?: string;
|
|
61
|
+
fetchImpl?: typeof fetch;
|
|
62
|
+
}
|
|
63
|
+
interface PasswordLoginInput {
|
|
64
|
+
username: string;
|
|
65
|
+
password: string;
|
|
66
|
+
clientFingerprint?: string;
|
|
67
|
+
challengeId?: string;
|
|
68
|
+
challengeAnswer?: string;
|
|
69
|
+
}
|
|
70
|
+
interface DingTalkLoginInput {
|
|
71
|
+
code: string;
|
|
72
|
+
corpId?: string;
|
|
73
|
+
}
|
|
74
|
+
interface GuestLoginInput {
|
|
75
|
+
guestIdentifier?: string;
|
|
76
|
+
domain?: string;
|
|
77
|
+
ipAddress?: string;
|
|
78
|
+
userAgent?: string;
|
|
79
|
+
formUuid?: string;
|
|
80
|
+
}
|
|
81
|
+
interface PhoneCodeInput {
|
|
82
|
+
phone: string;
|
|
83
|
+
purpose?: "login" | "register" | string;
|
|
84
|
+
}
|
|
85
|
+
interface PhoneCodeLoginInput {
|
|
86
|
+
phone: string;
|
|
87
|
+
code: string;
|
|
88
|
+
challengeId?: string;
|
|
89
|
+
}
|
|
90
|
+
interface PhoneCodeRegisterInput extends PhoneCodeLoginInput {
|
|
91
|
+
name?: string;
|
|
92
|
+
email?: string;
|
|
93
|
+
}
|
|
94
|
+
interface SsoLoginUrlInput {
|
|
95
|
+
protocol?: string;
|
|
96
|
+
redirectUri?: string;
|
|
97
|
+
}
|
|
98
|
+
interface RefreshInput {
|
|
99
|
+
refreshToken?: string;
|
|
100
|
+
}
|
|
101
|
+
interface ResolveLoginUrlInput {
|
|
102
|
+
callbackUrl?: string;
|
|
103
|
+
callbackParamName?: string;
|
|
104
|
+
loginUrl?: string;
|
|
105
|
+
}
|
|
106
|
+
interface AppAuthClient {
|
|
107
|
+
appType: string;
|
|
108
|
+
servicePrefix: string;
|
|
109
|
+
getMethods: () => Promise<LoginMethodsResult>;
|
|
110
|
+
passwordLogin: (input: PasswordLoginInput) => Promise<AuthTokenData>;
|
|
111
|
+
dingtalkLogin: (input: DingTalkLoginInput) => Promise<AuthTokenData>;
|
|
112
|
+
guestLogin: (input?: GuestLoginInput) => Promise<AuthTokenData>;
|
|
113
|
+
sendPhoneCode: (input: PhoneCodeInput) => Promise<PhoneCodeSendResult>;
|
|
114
|
+
phoneCodeLogin: (input: PhoneCodeLoginInput) => Promise<AuthTokenData>;
|
|
115
|
+
registerWithPhoneCode: (input: PhoneCodeRegisterInput) => Promise<AuthTokenData>;
|
|
116
|
+
getSsoLoginUrl: (input?: SsoLoginUrlInput) => Promise<SsoLoginUrlResult>;
|
|
117
|
+
refresh: (input?: RefreshInput) => Promise<AuthTokenData>;
|
|
118
|
+
logout: () => Promise<void>;
|
|
119
|
+
resolveLoginUrl: (input?: ResolveLoginUrlInput) => string;
|
|
120
|
+
}
|
|
121
|
+
declare class AuthClientError extends Error {
|
|
122
|
+
status?: number;
|
|
123
|
+
code?: number | string;
|
|
124
|
+
payload?: unknown;
|
|
125
|
+
constructor(message: string, options?: {
|
|
126
|
+
status?: number;
|
|
127
|
+
code?: number | string;
|
|
128
|
+
payload?: unknown;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
declare const createAuthClient: ({ appType, servicePrefix, fetchImpl, }: AuthClientOptions) => AppAuthClient;
|
|
132
|
+
|
|
133
|
+
interface UseAuthOptions extends Partial<AuthClientOptions> {
|
|
134
|
+
}
|
|
135
|
+
interface UseLoginMethodsState {
|
|
136
|
+
data: LoginMethodsResult | null;
|
|
137
|
+
methods: AuthMethod[];
|
|
138
|
+
loading: boolean;
|
|
139
|
+
error: Error | null;
|
|
140
|
+
reload: () => Promise<void>;
|
|
141
|
+
}
|
|
142
|
+
interface LoginPageProps extends UseAuthOptions {
|
|
143
|
+
title?: React__default.ReactNode;
|
|
144
|
+
subtitle?: React__default.ReactNode;
|
|
145
|
+
className?: string;
|
|
146
|
+
style?: CSSProperties;
|
|
147
|
+
defaultMethod?: "password" | "phone_code";
|
|
148
|
+
redirectUrl?: string;
|
|
149
|
+
redirectOnSuccess?: boolean;
|
|
150
|
+
onSuccess?: (data: AuthTokenData) => void | Promise<void>;
|
|
151
|
+
}
|
|
152
|
+
declare const useAuth: (options?: UseAuthOptions) => {
|
|
153
|
+
client: AppAuthClient;
|
|
154
|
+
getMethods: () => Promise<LoginMethodsResult>;
|
|
155
|
+
passwordLogin: (input: PasswordLoginInput) => Promise<AuthTokenData>;
|
|
156
|
+
dingtalkLogin: (input: DingTalkLoginInput) => Promise<AuthTokenData>;
|
|
157
|
+
guestLogin: (input?: GuestLoginInput) => Promise<AuthTokenData>;
|
|
158
|
+
sendPhoneCode: (input: PhoneCodeInput) => Promise<PhoneCodeSendResult>;
|
|
159
|
+
phoneCodeLogin: (input: PhoneCodeLoginInput) => Promise<AuthTokenData>;
|
|
160
|
+
registerWithPhoneCode: (input: PhoneCodeRegisterInput) => Promise<AuthTokenData>;
|
|
161
|
+
getSsoLoginUrl: (input?: SsoLoginUrlInput) => Promise<SsoLoginUrlResult>;
|
|
162
|
+
refresh: (input?: RefreshInput) => Promise<AuthTokenData>;
|
|
163
|
+
logout: () => Promise<void>;
|
|
164
|
+
resolveLoginUrl: (input?: ResolveLoginUrlInput) => string;
|
|
165
|
+
};
|
|
166
|
+
declare const useLoginMethods: (options?: UseAuthOptions) => UseLoginMethodsState;
|
|
167
|
+
declare const LoginPage: React__default.FC<LoginPageProps>;
|
|
168
|
+
|
|
169
|
+
type RuntimeErrorType = "unauthenticated" | "forbidden" | "network" | "unknown";
|
|
170
|
+
type RuntimeRequestError = Error & {
|
|
171
|
+
type?: RuntimeErrorType;
|
|
172
|
+
status?: number;
|
|
173
|
+
code?: number | string;
|
|
174
|
+
payload?: unknown;
|
|
175
|
+
};
|
|
176
|
+
interface RuntimeErrorSnapshot {
|
|
177
|
+
type: RuntimeErrorType;
|
|
178
|
+
status?: number;
|
|
179
|
+
code?: number | string;
|
|
180
|
+
message: string;
|
|
181
|
+
payload?: unknown;
|
|
182
|
+
}
|
|
183
|
+
declare class RuntimeHttpError extends Error {
|
|
184
|
+
type: RuntimeErrorType;
|
|
185
|
+
status?: number;
|
|
186
|
+
code?: number | string;
|
|
187
|
+
payload?: unknown;
|
|
188
|
+
constructor(snapshot: RuntimeErrorSnapshot);
|
|
189
|
+
}
|
|
190
|
+
interface RuntimeMenuItem {
|
|
191
|
+
id: string;
|
|
192
|
+
name: string;
|
|
193
|
+
resourceCode?: string | null;
|
|
194
|
+
routeCode?: string | null;
|
|
195
|
+
path?: string | null;
|
|
196
|
+
type?: string;
|
|
197
|
+
formUuid?: string | null;
|
|
198
|
+
pageId?: string | null;
|
|
199
|
+
parentId?: string | null;
|
|
200
|
+
sortOrder?: number;
|
|
201
|
+
isHidden?: boolean;
|
|
202
|
+
icon?: string | null;
|
|
203
|
+
children?: RuntimeMenuItem[];
|
|
204
|
+
[key: string]: unknown;
|
|
205
|
+
}
|
|
206
|
+
interface RuntimePagePermissions {
|
|
207
|
+
appType: string;
|
|
208
|
+
hasFullAccess: boolean;
|
|
209
|
+
roleCodes: string[];
|
|
210
|
+
roleSource?: string;
|
|
211
|
+
menuFormUuids: string[];
|
|
212
|
+
menuCodes: string[];
|
|
213
|
+
routeCodes: string[];
|
|
214
|
+
pathPatterns: string[];
|
|
215
|
+
}
|
|
216
|
+
interface RuntimeBootstrap {
|
|
217
|
+
appType: string;
|
|
218
|
+
app?: Record<string, unknown> | null;
|
|
219
|
+
user?: Record<string, unknown> | null;
|
|
220
|
+
runtime?: {
|
|
221
|
+
mode?: "legacy" | "react-spa" | string;
|
|
222
|
+
settings?: Record<string, unknown>;
|
|
223
|
+
activeReleaseId?: string | null;
|
|
224
|
+
activeBuildId?: string | null;
|
|
225
|
+
indexUrl?: string | null;
|
|
226
|
+
assetBaseUrl?: string | null;
|
|
227
|
+
};
|
|
228
|
+
permissions?: RuntimePagePermissions;
|
|
229
|
+
menus?: RuntimeMenuItem[];
|
|
230
|
+
servicePrefix?: string;
|
|
231
|
+
}
|
|
232
|
+
interface RouteAccessResult {
|
|
233
|
+
appType: string;
|
|
234
|
+
canAccess: boolean;
|
|
235
|
+
routeCode?: string;
|
|
236
|
+
menuCode?: string;
|
|
237
|
+
path?: string;
|
|
238
|
+
status?: number;
|
|
239
|
+
code?: number | string;
|
|
240
|
+
message?: string;
|
|
241
|
+
errorType?: RuntimeErrorType;
|
|
242
|
+
payload?: unknown;
|
|
243
|
+
permissions?: RuntimePagePermissions;
|
|
244
|
+
}
|
|
245
|
+
interface RuntimeRequestState<T> {
|
|
246
|
+
data: T | null;
|
|
247
|
+
loading: boolean;
|
|
248
|
+
error: RuntimeRequestError | null;
|
|
249
|
+
}
|
|
250
|
+
interface OpenXiangdaProviderProps {
|
|
251
|
+
appType?: string;
|
|
252
|
+
servicePrefix?: string;
|
|
253
|
+
fetchImpl?: typeof fetch;
|
|
254
|
+
children: React__default.ReactNode;
|
|
255
|
+
}
|
|
256
|
+
interface OpenXiangdaRuntimeStore extends RuntimeRequestState<RuntimeBootstrap> {
|
|
257
|
+
appType: string;
|
|
258
|
+
servicePrefix: string;
|
|
259
|
+
fetchImpl: typeof fetch;
|
|
260
|
+
reload: () => Promise<void>;
|
|
261
|
+
}
|
|
262
|
+
declare const OpenXiangdaProvider: React__default.FC<OpenXiangdaProviderProps>;
|
|
263
|
+
declare const useOpenXiangda: () => OpenXiangdaRuntimeStore;
|
|
264
|
+
declare const useRuntimeBootstrap: () => OpenXiangdaRuntimeStore;
|
|
265
|
+
declare const useAppMenus: () => {
|
|
266
|
+
data: RuntimeMenuItem[];
|
|
267
|
+
appType: string;
|
|
268
|
+
servicePrefix: string;
|
|
269
|
+
fetchImpl: typeof fetch;
|
|
270
|
+
reload: () => Promise<void>;
|
|
271
|
+
loading: boolean;
|
|
272
|
+
error: RuntimeRequestError | null;
|
|
273
|
+
};
|
|
274
|
+
declare const usePermission: () => {
|
|
275
|
+
data: RuntimePagePermissions | null;
|
|
276
|
+
appType: string;
|
|
277
|
+
servicePrefix: string;
|
|
278
|
+
fetchImpl: typeof fetch;
|
|
279
|
+
reload: () => Promise<void>;
|
|
280
|
+
loading: boolean;
|
|
281
|
+
error: RuntimeRequestError | null;
|
|
282
|
+
};
|
|
283
|
+
interface UseCanAccessRouteInput {
|
|
284
|
+
routeCode?: string;
|
|
285
|
+
menuCode?: string;
|
|
286
|
+
path?: string;
|
|
287
|
+
}
|
|
288
|
+
declare const useCanAccessRoute: (input: UseCanAccessRouteInput) => {
|
|
289
|
+
canAccess: boolean;
|
|
290
|
+
data: RouteAccessResult | null;
|
|
291
|
+
loading: boolean;
|
|
292
|
+
error: RuntimeRequestError | null;
|
|
293
|
+
};
|
|
294
|
+
interface PermissionBoundaryProps extends UseCanAccessRouteInput {
|
|
295
|
+
children: React__default.ReactNode;
|
|
296
|
+
fallback?: React__default.ReactNode | PermissionBoundaryFallback;
|
|
297
|
+
loadingFallback?: React__default.ReactNode | PermissionBoundaryFallback;
|
|
298
|
+
}
|
|
299
|
+
interface PermissionBoundaryFallbackState {
|
|
300
|
+
access: ReturnType<typeof useCanAccessRoute>;
|
|
301
|
+
runtime: ReturnType<typeof useOpenXiangda>;
|
|
302
|
+
error: RuntimeRequestError | null;
|
|
303
|
+
errorType: RuntimeErrorType;
|
|
304
|
+
status?: number;
|
|
305
|
+
code?: number | string;
|
|
306
|
+
message: string;
|
|
307
|
+
}
|
|
308
|
+
type PermissionBoundaryFallback = (state: PermissionBoundaryFallbackState) => React__default.ReactNode;
|
|
309
|
+
declare const PermissionBoundary: React__default.FC<PermissionBoundaryProps>;
|
|
310
|
+
interface RuntimeResolveLoginOptions {
|
|
311
|
+
redirectUri?: string;
|
|
312
|
+
loginUrl?: string;
|
|
313
|
+
domain?: string;
|
|
314
|
+
}
|
|
315
|
+
interface RuntimeRedirectLoginOptions extends RuntimeResolveLoginOptions {
|
|
316
|
+
replace?: boolean;
|
|
317
|
+
}
|
|
318
|
+
interface RuntimeLogoutOptions extends RuntimeRedirectLoginOptions {
|
|
319
|
+
continueOnError?: boolean;
|
|
320
|
+
}
|
|
321
|
+
declare const useRuntimeAuth: () => {
|
|
322
|
+
logout: () => Promise<any>;
|
|
323
|
+
logoutAndRedirect: (options?: RuntimeLogoutOptions) => Promise<string>;
|
|
324
|
+
redirectToLogin: (options?: RuntimeRedirectLoginOptions) => Promise<string>;
|
|
325
|
+
resolveLoginUrl: (options?: RuntimeResolveLoginOptions) => Promise<string>;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
export { type AppAuthClient as A, type RuntimeRedirectLoginOptions as B, type RuntimeRequestError as C, type DingTalkLoginInput as D, type RuntimeRequestState as E, type RuntimeResolveLoginOptions as F, type GuestLoginInput as G, type SsoLoginUrlResult as H, type UseCanAccessRouteInput as I, type UseLoginMethodsState as J, createAuthClient as K, type LoginMethodsResult as L, useAppMenus as M, useAuth as N, OpenXiangdaProvider as O, type PasswordLoginInput as P, useCanAccessRoute as Q, type RefreshInput as R, type SsoLoginUrlInput as S, useLoginMethods as T, type UseAuthOptions as U, useOpenXiangda as V, usePermission as W, useRuntimeAuth as X, useRuntimeBootstrap as Y, AuthClientError as a, type AuthClientOptions as b, type AuthMethod as c, type AuthMethodType as d, type AuthTokenData as e, type AuthUser as f, LoginPage as g, type LoginPageProps as h, type OpenXiangdaProviderProps as i, PermissionBoundary as j, type PermissionBoundaryFallback as k, type PermissionBoundaryFallbackState as l, type PermissionBoundaryProps as m, type PhoneCodeInput as n, type PhoneCodeLoginInput as o, type PhoneCodeRegisterInput as p, type PhoneCodeSendResult as q, type ResolveLoginUrlInput as r, type RouteAccessResult as s, type RuntimeBootstrap as t, type RuntimeErrorSnapshot as u, type RuntimeErrorType as v, RuntimeHttpError as w, type RuntimeLogoutOptions as x, type RuntimeMenuItem as y, type RuntimePagePermissions as z };
|