@ram_28/kf-ai-sdk 1.0.11 → 1.0.12
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 +55 -48
- package/dist/api/client.d.ts +14 -14
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/datetime.d.ts +5 -5
- package/dist/api/datetime.d.ts.map +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/metadata.d.ts +2 -2
- package/dist/api/metadata.d.ts.map +1 -1
- package/dist/api.cjs +1 -0
- package/dist/api.d.ts +4 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.mjs +27 -0
- package/dist/api.types.cjs +1 -0
- package/dist/api.types.d.ts +4 -0
- package/dist/api.types.d.ts.map +1 -0
- package/dist/api.types.mjs +1 -0
- package/dist/auth/AuthProvider.d.ts +3 -3
- package/dist/auth/AuthProvider.d.ts.map +1 -1
- package/dist/auth/authClient.d.ts +4 -4
- package/dist/auth/authClient.d.ts.map +1 -1
- package/dist/auth/authConfig.d.ts +5 -5
- package/dist/auth/authConfig.d.ts.map +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/types.d.ts +21 -21
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/useAuth.d.ts +2 -2
- package/dist/auth/useAuth.d.ts.map +1 -1
- package/dist/auth.cjs +1 -0
- package/dist/auth.d.ts +5 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.mjs +280 -0
- package/dist/auth.types.cjs +1 -0
- package/dist/auth.types.d.ts +2 -0
- package/dist/auth.types.d.ts.map +1 -0
- package/dist/auth.types.mjs +1 -0
- package/dist/base-types.d.ts +2 -0
- package/dist/base-types.d.ts.map +1 -0
- package/dist/client-C15j4O5B.cjs +1 -0
- package/dist/client-CfvLiGfP.js +233 -0
- package/dist/cn-Dr87sK3i.js +2775 -0
- package/dist/cn-mXUIg4vp.cjs +1 -0
- package/dist/components/hooks/index.d.ts +3 -3
- package/dist/components/hooks/index.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/index.d.ts +2 -2
- package/dist/components/hooks/useFilter/index.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/types.d.ts +19 -31
- package/dist/components/hooks/useFilter/types.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/useFilter.d.ts +2 -2
- package/dist/components/hooks/useFilter/useFilter.d.ts.map +1 -1
- package/dist/components/hooks/useForm/apiClient.d.ts +6 -6
- package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -1
- package/dist/components/hooks/useForm/expressionValidator.utils.d.ts +7 -7
- package/dist/components/hooks/useForm/expressionValidator.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/index.d.ts +5 -5
- package/dist/components/hooks/useForm/index.d.ts.map +1 -1
- package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts +10 -10
- package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts +7 -12
- package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/schemaParser.utils.d.ts +7 -7
- package/dist/components/hooks/useForm/schemaParser.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/types.d.ts +67 -76
- package/dist/components/hooks/useForm/types.d.ts.map +1 -1
- package/dist/components/hooks/useForm/useForm.d.ts +2 -2
- package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/apiClient.d.ts +16 -16
- package/dist/components/hooks/useKanban/apiClient.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/context.d.ts +3 -3
- package/dist/components/hooks/useKanban/context.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/dragDropManager.d.ts +7 -7
- package/dist/components/hooks/useKanban/dragDropManager.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/index.d.ts +1 -1
- package/dist/components/hooks/useKanban/index.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/types.d.ts +65 -67
- package/dist/components/hooks/useKanban/types.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/useKanban.d.ts +2 -2
- package/dist/components/hooks/useKanban/useKanban.d.ts.map +1 -1
- package/dist/components/hooks/useTable/index.d.ts +1 -1
- package/dist/components/hooks/useTable/index.d.ts.map +1 -1
- package/dist/components/hooks/useTable/types.d.ts +10 -10
- package/dist/components/hooks/useTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useTable/useTable.d.ts +2 -2
- package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
- package/dist/filter.cjs +1 -0
- package/dist/filter.d.ts +3 -0
- package/dist/filter.d.ts.map +1 -0
- package/dist/filter.mjs +6 -0
- package/dist/filter.types.cjs +1 -0
- package/dist/filter.types.d.ts +2 -0
- package/dist/filter.types.d.ts.map +1 -0
- package/dist/filter.types.mjs +1 -0
- package/dist/form.cjs +1 -0
- package/dist/form.d.ts +3 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.mjs +1346 -0
- package/dist/form.types.cjs +1 -0
- package/dist/form.types.d.ts +2 -0
- package/dist/form.types.d.ts.map +1 -0
- package/dist/form.types.mjs +1 -0
- package/dist/jsx-runtime-BYECrxsp.cjs +30 -0
- package/dist/jsx-runtime-DGlMoOmv.js +630 -0
- package/dist/kanban.cjs +13 -0
- package/dist/kanban.d.ts +5 -0
- package/dist/kanban.d.ts.map +1 -0
- package/dist/kanban.mjs +694 -0
- package/dist/kanban.types.cjs +1 -0
- package/dist/kanban.types.d.ts +2 -0
- package/dist/kanban.types.d.ts.map +1 -0
- package/dist/kanban.types.mjs +1 -0
- package/dist/kanban.ui.cjs +1 -0
- package/dist/kanban.ui.d.ts +2 -0
- package/dist/kanban.ui.d.ts.map +1 -0
- package/dist/kanban.ui.mjs +104 -0
- package/dist/metadata-2FLBsFcf.cjs +1 -0
- package/dist/metadata-DBcoDth-.js +43 -0
- package/dist/table.cjs +1 -0
- package/dist/table.d.ts +2 -0
- package/dist/table.d.ts.map +1 -0
- package/dist/table.mjs +148 -0
- package/dist/table.types.cjs +1 -0
- package/dist/table.types.d.ts +2 -0
- package/dist/table.types.d.ts.map +1 -0
- package/dist/table.types.mjs +1 -0
- package/dist/types/base-fields.d.ts +45 -45
- package/dist/types/base-fields.d.ts.map +1 -1
- package/dist/types/common.d.ts +45 -61
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types.cjs +1 -0
- package/dist/types.mjs +1 -0
- package/dist/useFilter-CXFqEHyI.js +129 -0
- package/dist/useFilter-D-bCDo6Z.cjs +1 -0
- package/dist/utils/formatting.d.ts +4 -4
- package/dist/utils/formatting.d.ts.map +1 -1
- package/dist/utils.cjs +4 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.mjs +105 -0
- package/package.json +147 -9
- package/sdk/api/client.ts +51 -51
- package/sdk/api/datetime.ts +5 -5
- package/sdk/api/index.ts +28 -33
- package/sdk/api/metadata.ts +4 -4
- package/sdk/api.ts +24 -0
- package/sdk/api.types.ts +58 -0
- package/sdk/auth/AuthProvider.tsx +18 -18
- package/sdk/auth/authClient.ts +9 -9
- package/sdk/auth/authConfig.ts +9 -9
- package/sdk/auth/index.ts +5 -5
- package/sdk/auth/types.ts +21 -21
- package/sdk/auth/useAuth.ts +2 -2
- package/sdk/auth.ts +22 -0
- package/sdk/auth.types.ts +28 -0
- package/sdk/base-types.ts +45 -0
- package/sdk/components/hooks/index.ts +22 -22
- package/sdk/components/hooks/useFilter/index.ts +8 -14
- package/sdk/components/hooks/useFilter/types.ts +29 -58
- package/sdk/components/hooks/useFilter/useFilter.ts +41 -44
- package/sdk/components/hooks/useForm/apiClient.ts +8 -8
- package/sdk/components/hooks/useForm/expressionValidator.utils.ts +18 -18
- package/sdk/components/hooks/useForm/index.ts +24 -24
- package/sdk/components/hooks/useForm/optimizedExpressionValidator.utils.ts +22 -22
- package/sdk/components/hooks/useForm/ruleClassifier.utils.ts +26 -62
- package/sdk/components/hooks/useForm/schemaParser.utils.ts +24 -24
- package/sdk/components/hooks/useForm/types.ts +66 -82
- package/sdk/components/hooks/useForm/useForm.ts +15 -21
- package/sdk/components/hooks/useKanban/apiClient.ts +54 -54
- package/sdk/components/hooks/useKanban/context.ts +3 -3
- package/sdk/components/hooks/useKanban/dragDropManager.ts +19 -19
- package/sdk/components/hooks/useKanban/index.ts +26 -26
- package/sdk/components/hooks/useKanban/types.ts +69 -71
- package/sdk/components/hooks/useKanban/useKanban.ts +43 -51
- package/sdk/components/hooks/useKanban/useKanbanSimple.ts +4 -4
- package/sdk/components/hooks/useTable/index.ts +5 -1
- package/sdk/components/hooks/useTable/types.ts +10 -10
- package/sdk/components/hooks/useTable/useTable.ts +10 -10
- package/sdk/filter.ts +13 -0
- package/sdk/filter.types.ts +17 -0
- package/sdk/form.ts +15 -0
- package/sdk/form.types.ts +46 -0
- package/sdk/kanban.ts +23 -0
- package/sdk/kanban.types.ts +50 -0
- package/sdk/kanban.ui.ts +16 -0
- package/sdk/table.ts +7 -0
- package/sdk/table.types.ts +13 -0
- package/sdk/types/base-fields.ts +47 -47
- package/sdk/types/common.ts +47 -71
- package/sdk/types/index.ts +1 -1
- package/sdk/utils/formatting.ts +4 -4
- package/sdk/utils.ts +10 -0
- package/dist/index.cjs +0 -45
- package/dist/index.mjs +0 -6387
|
@@ -15,14 +15,14 @@ import React, {
|
|
|
15
15
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
16
16
|
|
|
17
17
|
import type {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
AuthContextValueType,
|
|
19
|
+
AuthProviderPropsType,
|
|
20
|
+
AuthStatusType,
|
|
21
|
+
UserDetailsType,
|
|
22
|
+
SessionResponseType,
|
|
23
|
+
AuthProviderNameType,
|
|
24
|
+
LoginOptionsType,
|
|
25
|
+
LogoutOptionsType,
|
|
26
26
|
} from "./types";
|
|
27
27
|
|
|
28
28
|
import {
|
|
@@ -37,7 +37,7 @@ import { getAuthConfig, configureAuth } from "./authConfig";
|
|
|
37
37
|
// CONTEXT
|
|
38
38
|
// ============================================================
|
|
39
39
|
|
|
40
|
-
const AuthContext = createContext<
|
|
40
|
+
const AuthContext = createContext<AuthContextValueType | null>(null);
|
|
41
41
|
|
|
42
42
|
const SESSION_QUERY_KEY = ["auth", "session"] as const;
|
|
43
43
|
|
|
@@ -53,7 +53,7 @@ export function AuthProvider({
|
|
|
53
53
|
loadingComponent,
|
|
54
54
|
unauthenticatedComponent,
|
|
55
55
|
skipInitialCheck = false,
|
|
56
|
-
}:
|
|
56
|
+
}: AuthProviderPropsType): React.ReactElement {
|
|
57
57
|
const configApplied = useRef(false);
|
|
58
58
|
|
|
59
59
|
if (configOverride && !configApplied.current) {
|
|
@@ -74,7 +74,7 @@ export function AuthProvider({
|
|
|
74
74
|
error: queryError,
|
|
75
75
|
refetch,
|
|
76
76
|
isFetching,
|
|
77
|
-
} = useQuery<
|
|
77
|
+
} = useQuery<SessionResponseType, Error>({
|
|
78
78
|
queryKey: SESSION_QUERY_KEY,
|
|
79
79
|
queryFn: fetchSession,
|
|
80
80
|
enabled: !skipInitialCheck,
|
|
@@ -100,13 +100,13 @@ export function AuthProvider({
|
|
|
100
100
|
|
|
101
101
|
const [error, setError] = useState<Error | null>(null);
|
|
102
102
|
|
|
103
|
-
const status:
|
|
103
|
+
const status: AuthStatusType = useMemo(() => {
|
|
104
104
|
if (isLoading || isFetching) return "loading";
|
|
105
105
|
if (sessionData?.userDetails) return "authenticated";
|
|
106
106
|
return "unauthenticated";
|
|
107
107
|
}, [isLoading, isFetching, sessionData]);
|
|
108
108
|
|
|
109
|
-
const user:
|
|
109
|
+
const user: UserDetailsType | null = sessionData?.userDetails || null;
|
|
110
110
|
const staticBaseUrl: string | null = sessionData?.staticBaseUrl || null;
|
|
111
111
|
const buildId: string | null = sessionData?.buildId || null;
|
|
112
112
|
const isAuthenticated = status === "authenticated";
|
|
@@ -153,21 +153,21 @@ export function AuthProvider({
|
|
|
153
153
|
// ============================================================
|
|
154
154
|
|
|
155
155
|
const login = useCallback(
|
|
156
|
-
(provider?:
|
|
156
|
+
(provider?: AuthProviderNameType, options?: LoginOptionsType) => {
|
|
157
157
|
initiateLogin(provider, options);
|
|
158
158
|
},
|
|
159
159
|
[]
|
|
160
160
|
);
|
|
161
161
|
|
|
162
162
|
const logout = useCallback(
|
|
163
|
-
async (options?:
|
|
163
|
+
async (options?: LogoutOptionsType) => {
|
|
164
164
|
queryClient.removeQueries({ queryKey: SESSION_QUERY_KEY });
|
|
165
165
|
await performLogout(options);
|
|
166
166
|
},
|
|
167
167
|
[queryClient]
|
|
168
168
|
);
|
|
169
169
|
|
|
170
|
-
const refreshSession = useCallback(async (): Promise<
|
|
170
|
+
const refreshSession = useCallback(async (): Promise<SessionResponseType | null> => {
|
|
171
171
|
// Prevent concurrent refreshes - return existing data if already fetching
|
|
172
172
|
if (isFetching) {
|
|
173
173
|
return sessionData || null;
|
|
@@ -208,7 +208,7 @@ export function AuthProvider({
|
|
|
208
208
|
// CONTEXT VALUE
|
|
209
209
|
// ============================================================
|
|
210
210
|
|
|
211
|
-
const contextValue:
|
|
211
|
+
const contextValue: AuthContextValueType = useMemo(
|
|
212
212
|
() => ({
|
|
213
213
|
user,
|
|
214
214
|
staticBaseUrl,
|
|
@@ -268,7 +268,7 @@ export function AuthProvider({
|
|
|
268
268
|
// CONTEXT HOOK (internal)
|
|
269
269
|
// ============================================================
|
|
270
270
|
|
|
271
|
-
export function useAuthContext():
|
|
271
|
+
export function useAuthContext(): AuthContextValueType {
|
|
272
272
|
const context = useContext(AuthContext);
|
|
273
273
|
if (!context) {
|
|
274
274
|
throw new Error("useAuth must be used within an AuthProvider");
|
package/sdk/auth/authClient.ts
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
// Low-level functions for authentication API calls
|
|
5
5
|
|
|
6
6
|
import type {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
SessionResponseType,
|
|
8
|
+
AuthProviderNameType,
|
|
9
|
+
LoginOptionsType,
|
|
10
|
+
LogoutOptionsType,
|
|
11
11
|
} from "./types";
|
|
12
12
|
import {
|
|
13
13
|
getAuthBaseUrl,
|
|
@@ -35,7 +35,7 @@ export class AuthenticationError extends Error {
|
|
|
35
35
|
*
|
|
36
36
|
* @throws AuthenticationError if session check fails or user is not authenticated
|
|
37
37
|
*/
|
|
38
|
-
export async function fetchSession(): Promise<
|
|
38
|
+
export async function fetchSession(): Promise<SessionResponseType> {
|
|
39
39
|
const config = getAuthConfig();
|
|
40
40
|
const baseUrl = getAuthBaseUrl();
|
|
41
41
|
const headers = getDefaultHeaders();
|
|
@@ -56,7 +56,7 @@ export async function fetchSession(): Promise<SessionResponse> {
|
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
const data:
|
|
59
|
+
const data: SessionResponseType = await response.json();
|
|
60
60
|
return data;
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -81,8 +81,8 @@ export async function fetchSession(): Promise<SessionResponse> {
|
|
|
81
81
|
* ```
|
|
82
82
|
*/
|
|
83
83
|
export function initiateLogin(
|
|
84
|
-
provider?:
|
|
85
|
-
options?:
|
|
84
|
+
provider?: AuthProviderNameType,
|
|
85
|
+
options?: LoginOptionsType
|
|
86
86
|
): Promise<never> {
|
|
87
87
|
return new Promise(() => {
|
|
88
88
|
const config = getAuthConfig();
|
|
@@ -147,7 +147,7 @@ export function initiateLogin(
|
|
|
147
147
|
* Logout the current user
|
|
148
148
|
* Optionally calls the logout endpoint before clearing client state
|
|
149
149
|
*/
|
|
150
|
-
export async function performLogout(options?:
|
|
150
|
+
export async function performLogout(options?: LogoutOptionsType): Promise<void> {
|
|
151
151
|
const config = getAuthConfig();
|
|
152
152
|
const baseUrl = getAuthBaseUrl();
|
|
153
153
|
const headers = getDefaultHeaders();
|
package/sdk/auth/authConfig.ts
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
// ============================================================
|
|
4
4
|
// Global auth configuration following the setApiBaseUrl pattern
|
|
5
5
|
|
|
6
|
-
import type {
|
|
6
|
+
import type { AuthConfigType, AuthProviderNameType, AuthEndpointConfigType } from "./types";
|
|
7
7
|
import { getApiBaseUrl } from "../api/client";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Default auth configuration
|
|
11
11
|
*/
|
|
12
|
-
const defaultAuthConfig:
|
|
12
|
+
const defaultAuthConfig: AuthConfigType = {
|
|
13
13
|
sessionEndpoint: "/api/id",
|
|
14
14
|
providers: {
|
|
15
15
|
google: {
|
|
@@ -32,7 +32,7 @@ const defaultAuthConfig: AuthConfig = {
|
|
|
32
32
|
/**
|
|
33
33
|
* Current auth configuration (mutable)
|
|
34
34
|
*/
|
|
35
|
-
let authConfig:
|
|
35
|
+
let authConfig: AuthConfigType = { ...defaultAuthConfig };
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Configure authentication settings globally
|
|
@@ -48,7 +48,7 @@ let authConfig: AuthConfig = { ...defaultAuthConfig };
|
|
|
48
48
|
* });
|
|
49
49
|
* ```
|
|
50
50
|
*/
|
|
51
|
-
export function configureAuth(config: Partial<
|
|
51
|
+
export function configureAuth(config: Partial<AuthConfigType>): void {
|
|
52
52
|
authConfig = {
|
|
53
53
|
...authConfig,
|
|
54
54
|
...config,
|
|
@@ -67,8 +67,8 @@ export function configureAuth(config: Partial<AuthConfig>): void {
|
|
|
67
67
|
* Add or update an auth provider configuration
|
|
68
68
|
*/
|
|
69
69
|
export function setAuthProvider(
|
|
70
|
-
provider:
|
|
71
|
-
config:
|
|
70
|
+
provider: AuthProviderNameType,
|
|
71
|
+
config: AuthEndpointConfigType
|
|
72
72
|
): void {
|
|
73
73
|
authConfig.providers[provider] = config;
|
|
74
74
|
}
|
|
@@ -76,7 +76,7 @@ export function setAuthProvider(
|
|
|
76
76
|
/**
|
|
77
77
|
* Get current auth configuration
|
|
78
78
|
*/
|
|
79
|
-
export function getAuthConfig(): Readonly<
|
|
79
|
+
export function getAuthConfig(): Readonly<AuthConfigType> {
|
|
80
80
|
return { ...authConfig };
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -92,8 +92,8 @@ export function getAuthBaseUrl(): string {
|
|
|
92
92
|
* Get endpoint configuration for a specific provider
|
|
93
93
|
*/
|
|
94
94
|
export function getProviderConfig(
|
|
95
|
-
provider:
|
|
96
|
-
):
|
|
95
|
+
provider: AuthProviderNameType
|
|
96
|
+
): AuthEndpointConfigType | undefined {
|
|
97
97
|
return authConfig.providers[provider];
|
|
98
98
|
}
|
|
99
99
|
|
package/sdk/auth/index.ts
CHANGED
|
@@ -13,9 +13,9 @@ export { AuthenticationError } from "./authClient";
|
|
|
13
13
|
|
|
14
14
|
// Type exports
|
|
15
15
|
export type {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
UserDetailsType,
|
|
17
|
+
SessionResponseType,
|
|
18
|
+
AuthStatusType,
|
|
19
|
+
AuthProviderPropsType,
|
|
20
|
+
UseAuthReturnType,
|
|
21
21
|
} from "./types";
|
package/sdk/auth/types.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* User details returned from the session endpoint
|
|
7
7
|
*/
|
|
8
|
-
export interface
|
|
8
|
+
export interface UserDetailsType {
|
|
9
9
|
_id: string;
|
|
10
10
|
_name: string;
|
|
11
11
|
Role: string;
|
|
@@ -15,8 +15,8 @@ export interface UserDetails {
|
|
|
15
15
|
/**
|
|
16
16
|
* Session response from /api/id endpoint
|
|
17
17
|
*/
|
|
18
|
-
export interface
|
|
19
|
-
userDetails:
|
|
18
|
+
export interface SessionResponseType {
|
|
19
|
+
userDetails: UserDetailsType;
|
|
20
20
|
staticBaseUrl: string;
|
|
21
21
|
buildId: string;
|
|
22
22
|
}
|
|
@@ -24,17 +24,17 @@ export interface SessionResponse {
|
|
|
24
24
|
/**
|
|
25
25
|
* Authentication status
|
|
26
26
|
*/
|
|
27
|
-
export type
|
|
27
|
+
export type AuthStatusType = "loading" | "authenticated" | "unauthenticated";
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Authentication provider type (extensible for multiple OAuth providers)
|
|
31
31
|
*/
|
|
32
|
-
export type
|
|
32
|
+
export type AuthProviderNameType = "google" | "microsoft" | "github" | "custom";
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Auth endpoint configuration for a specific provider
|
|
36
36
|
*/
|
|
37
|
-
export interface
|
|
37
|
+
export interface AuthEndpointConfigType {
|
|
38
38
|
/** Login endpoint path (e.g., "/api/auth/google/login") */
|
|
39
39
|
loginPath: string;
|
|
40
40
|
/** Optional logout endpoint path */
|
|
@@ -46,7 +46,7 @@ export interface AuthEndpointConfig {
|
|
|
46
46
|
/**
|
|
47
47
|
* Global authentication configuration
|
|
48
48
|
*/
|
|
49
|
-
export interface
|
|
49
|
+
export interface AuthConfigType {
|
|
50
50
|
/** Base URL for auth endpoints (defaults to apiBaseUrl) */
|
|
51
51
|
baseUrl?: string;
|
|
52
52
|
|
|
@@ -54,10 +54,10 @@ export interface AuthConfig {
|
|
|
54
54
|
sessionEndpoint: string;
|
|
55
55
|
|
|
56
56
|
/** Auth provider configurations */
|
|
57
|
-
providers: Partial<Record<
|
|
57
|
+
providers: Partial<Record<AuthProviderNameType, AuthEndpointConfigType>>;
|
|
58
58
|
|
|
59
59
|
/** Default provider to use for login */
|
|
60
|
-
defaultProvider:
|
|
60
|
+
defaultProvider: AuthProviderNameType;
|
|
61
61
|
|
|
62
62
|
/** Auto-redirect to login when unauthenticated */
|
|
63
63
|
autoRedirect: boolean;
|
|
@@ -90,14 +90,14 @@ export interface AuthConfig {
|
|
|
90
90
|
/**
|
|
91
91
|
* AuthProvider component props
|
|
92
92
|
*/
|
|
93
|
-
export interface
|
|
93
|
+
export interface AuthProviderPropsType {
|
|
94
94
|
children: React.ReactNode;
|
|
95
95
|
|
|
96
96
|
/** Override global config for this provider instance */
|
|
97
|
-
config?: Partial<
|
|
97
|
+
config?: Partial<AuthConfigType>;
|
|
98
98
|
|
|
99
99
|
/** Callback when authentication status changes */
|
|
100
|
-
onAuthChange?: (status:
|
|
100
|
+
onAuthChange?: (status: AuthStatusType, user: UserDetailsType | null) => void;
|
|
101
101
|
|
|
102
102
|
/** Callback on authentication error */
|
|
103
103
|
onError?: (error: Error) => void;
|
|
@@ -115,7 +115,7 @@ export interface AuthProviderProps {
|
|
|
115
115
|
/**
|
|
116
116
|
* Options for login operation
|
|
117
117
|
*/
|
|
118
|
-
export interface
|
|
118
|
+
export interface LoginOptionsType {
|
|
119
119
|
/** URL to redirect after successful login */
|
|
120
120
|
callbackUrl?: string;
|
|
121
121
|
/** Additional query parameters for login URL */
|
|
@@ -125,7 +125,7 @@ export interface LoginOptions {
|
|
|
125
125
|
/**
|
|
126
126
|
* Options for logout operation
|
|
127
127
|
*/
|
|
128
|
-
export interface
|
|
128
|
+
export interface LogoutOptionsType {
|
|
129
129
|
/** URL to redirect after logout */
|
|
130
130
|
redirectUrl?: string;
|
|
131
131
|
/** Whether to call logout endpoint (default: true) */
|
|
@@ -135,13 +135,13 @@ export interface LogoutOptions {
|
|
|
135
135
|
/**
|
|
136
136
|
* Return type for useAuth hook
|
|
137
137
|
*/
|
|
138
|
-
export interface
|
|
138
|
+
export interface UseAuthReturnType {
|
|
139
139
|
// ============================================================
|
|
140
140
|
// USER STATE
|
|
141
141
|
// ============================================================
|
|
142
142
|
|
|
143
143
|
/** Current authenticated user (null if not authenticated) */
|
|
144
|
-
user:
|
|
144
|
+
user: UserDetailsType | null;
|
|
145
145
|
|
|
146
146
|
/** Static base URL from session */
|
|
147
147
|
staticBaseUrl: string | null;
|
|
@@ -150,7 +150,7 @@ export interface UseAuthReturn {
|
|
|
150
150
|
buildId: string | null;
|
|
151
151
|
|
|
152
152
|
/** Current authentication status */
|
|
153
|
-
status:
|
|
153
|
+
status: AuthStatusType;
|
|
154
154
|
|
|
155
155
|
/** Convenience boolean for authenticated state */
|
|
156
156
|
isAuthenticated: boolean;
|
|
@@ -167,18 +167,18 @@ export interface UseAuthReturn {
|
|
|
167
167
|
* @param provider - Auth provider to use (defaults to configured default)
|
|
168
168
|
* @param options - Additional options for login
|
|
169
169
|
*/
|
|
170
|
-
login: (provider?:
|
|
170
|
+
login: (provider?: AuthProviderNameType, options?: LoginOptionsType) => void;
|
|
171
171
|
|
|
172
172
|
/**
|
|
173
173
|
* Logout the current user
|
|
174
174
|
* @param options - Additional options for logout
|
|
175
175
|
*/
|
|
176
|
-
logout: (options?:
|
|
176
|
+
logout: (options?: LogoutOptionsType) => Promise<void>;
|
|
177
177
|
|
|
178
178
|
/**
|
|
179
179
|
* Manually refresh the session
|
|
180
180
|
*/
|
|
181
|
-
refreshSession: () => Promise<
|
|
181
|
+
refreshSession: () => Promise<SessionResponseType | null>;
|
|
182
182
|
|
|
183
183
|
/**
|
|
184
184
|
* Check if user has a specific role
|
|
@@ -204,7 +204,7 @@ export interface UseAuthReturn {
|
|
|
204
204
|
/**
|
|
205
205
|
* Auth context value (internal)
|
|
206
206
|
*/
|
|
207
|
-
export interface
|
|
207
|
+
export interface AuthContextValueType extends UseAuthReturnType {
|
|
208
208
|
/** Internal: force re-check session */
|
|
209
209
|
_forceCheck: () => void;
|
|
210
210
|
}
|
package/sdk/auth/useAuth.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// Main hook for consuming authentication state
|
|
5
5
|
|
|
6
6
|
import { useMemo } from "react";
|
|
7
|
-
import type {
|
|
7
|
+
import type { UseAuthReturnType } from "./types";
|
|
8
8
|
import { useAuthContext } from "./AuthProvider";
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -31,7 +31,7 @@ import { useAuthContext } from "./AuthProvider";
|
|
|
31
31
|
* }
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
|
-
export function useAuth():
|
|
34
|
+
export function useAuth(): UseAuthReturnType {
|
|
35
35
|
const context = useAuthContext();
|
|
36
36
|
|
|
37
37
|
return useMemo(
|
package/sdk/auth.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// AUTH MODULE - Main Entry Point
|
|
3
|
+
// @ram_28/kf-ai-sdk/auth
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
// Provider component
|
|
7
|
+
export { AuthProvider } from './auth/AuthProvider';
|
|
8
|
+
|
|
9
|
+
// Main hook
|
|
10
|
+
export { useAuth } from './auth/useAuth';
|
|
11
|
+
|
|
12
|
+
// Error class
|
|
13
|
+
export { AuthenticationError } from './auth/authClient';
|
|
14
|
+
|
|
15
|
+
// Configuration
|
|
16
|
+
export {
|
|
17
|
+
configureAuth,
|
|
18
|
+
getAuthConfig,
|
|
19
|
+
setAuthProvider,
|
|
20
|
+
getAuthBaseUrl,
|
|
21
|
+
resetAuthConfig,
|
|
22
|
+
} from './auth/authConfig';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// AUTH MODULE - Type Exports
|
|
3
|
+
// @ram_28/kf-ai-sdk/auth/types
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
export type {
|
|
7
|
+
// Core hook types
|
|
8
|
+
UseAuthReturnType,
|
|
9
|
+
|
|
10
|
+
// User and session
|
|
11
|
+
UserDetailsType,
|
|
12
|
+
SessionResponseType,
|
|
13
|
+
|
|
14
|
+
// Auth status
|
|
15
|
+
AuthStatusType,
|
|
16
|
+
|
|
17
|
+
// Provider types
|
|
18
|
+
AuthProviderPropsType,
|
|
19
|
+
AuthProviderNameType,
|
|
20
|
+
|
|
21
|
+
// Configuration
|
|
22
|
+
AuthConfigType,
|
|
23
|
+
AuthEndpointConfigType,
|
|
24
|
+
|
|
25
|
+
// Operation options
|
|
26
|
+
LoginOptionsType,
|
|
27
|
+
LogoutOptionsType,
|
|
28
|
+
} from './auth/types';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// BASE TYPES MODULE - Field Type Exports
|
|
3
|
+
// @ram_28/kf-ai-sdk/types
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
export type {
|
|
7
|
+
// ID and String fields
|
|
8
|
+
IdFieldType,
|
|
9
|
+
StringFieldType,
|
|
10
|
+
TextAreaFieldType,
|
|
11
|
+
|
|
12
|
+
// Numeric fields
|
|
13
|
+
NumberFieldType,
|
|
14
|
+
LongFieldType,
|
|
15
|
+
|
|
16
|
+
// Boolean field
|
|
17
|
+
BooleanFieldType,
|
|
18
|
+
|
|
19
|
+
// Date/Time fields
|
|
20
|
+
DateFieldType,
|
|
21
|
+
DateTimeFieldType,
|
|
22
|
+
|
|
23
|
+
// Complex fields
|
|
24
|
+
CurrencyFieldType,
|
|
25
|
+
CurrencyValueType,
|
|
26
|
+
JSONFieldType,
|
|
27
|
+
ReferenceFieldType,
|
|
28
|
+
|
|
29
|
+
// JSON types
|
|
30
|
+
JSONValueType,
|
|
31
|
+
JSONObjectType,
|
|
32
|
+
JSONArrayType,
|
|
33
|
+
|
|
34
|
+
// Select/Lookup fields
|
|
35
|
+
SelectFieldType,
|
|
36
|
+
LookupFieldType,
|
|
37
|
+
|
|
38
|
+
// Container types
|
|
39
|
+
ArrayFieldType,
|
|
40
|
+
ObjectFieldType,
|
|
41
|
+
OptionalFieldType,
|
|
42
|
+
|
|
43
|
+
// Utility types
|
|
44
|
+
ExtractFieldTypeType,
|
|
45
|
+
} from './types/base-fields';
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
// Table hook
|
|
2
2
|
export { useTable } from "./useTable";
|
|
3
3
|
export type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
UseTableOptionsType,
|
|
5
|
+
UseTableReturnType,
|
|
6
|
+
ColumnDefinitionType,
|
|
7
7
|
} from "./useTable";
|
|
8
8
|
|
|
9
9
|
// Form hook
|
|
10
10
|
export { useForm } from "./useForm";
|
|
11
11
|
export type {
|
|
12
12
|
// Core types
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
UseFormOptionsType,
|
|
14
|
+
UseFormReturnType,
|
|
15
|
+
FormOperationType,
|
|
16
|
+
FormModeType,
|
|
17
17
|
|
|
18
18
|
// Form field configuration
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
FormFieldConfigType,
|
|
20
|
+
FormSchemaConfigType,
|
|
21
|
+
FormFieldTypeType,
|
|
22
|
+
SelectOptionType,
|
|
23
|
+
FieldPermissionType,
|
|
24
24
|
|
|
25
25
|
// Result types
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
FieldValidationResultType,
|
|
27
|
+
SubmissionResultType,
|
|
28
28
|
|
|
29
29
|
// BDO Schema types (advanced)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
BDOSchemaType,
|
|
31
|
+
BDOFieldDefinitionType,
|
|
32
|
+
SchemaValidationRuleType,
|
|
33
33
|
} from "./useForm";
|
|
34
34
|
|
|
35
35
|
// Error utilities
|
|
@@ -43,11 +43,11 @@ export {
|
|
|
43
43
|
// Kanban hook
|
|
44
44
|
export { useKanban } from "./useKanban";
|
|
45
45
|
export type {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
UseKanbanOptionsType,
|
|
47
|
+
UseKanbanReturnType,
|
|
48
|
+
KanbanCardType,
|
|
49
|
+
KanbanColumnType,
|
|
50
|
+
ColumnConfigType,
|
|
51
51
|
} from "./useKanban";
|
|
52
52
|
|
|
53
53
|
// Filter hook
|
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
// Main hook export
|
|
2
2
|
export { useFilter } from "./useFilter";
|
|
3
3
|
|
|
4
|
-
// Type exports
|
|
4
|
+
// Type exports
|
|
5
5
|
export type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// Legacy type exports
|
|
14
|
-
FilterCondition,
|
|
15
|
-
FilterOperator,
|
|
6
|
+
ConditionType,
|
|
7
|
+
ConditionGroupType,
|
|
8
|
+
ConditionGroupOperatorType,
|
|
9
|
+
FilterType,
|
|
10
|
+
FilterRHSTypeType,
|
|
11
|
+
UseFilterOptionsType,
|
|
12
|
+
UseFilterReturnType,
|
|
16
13
|
} from "./types";
|
|
17
14
|
|
|
18
15
|
// Type guard exports
|
|
19
16
|
export {
|
|
20
17
|
isCondition,
|
|
21
18
|
isConditionGroup,
|
|
22
|
-
// Legacy type guard exports
|
|
23
|
-
isFilterCondition,
|
|
24
|
-
isFilterLogical,
|
|
25
19
|
} from "./types";
|