@ram_28/kf-ai-sdk 1.0.11 → 1.0.13

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 (195) hide show
  1. package/README.md +55 -48
  2. package/dist/api/client.d.ts +14 -14
  3. package/dist/api/client.d.ts.map +1 -1
  4. package/dist/api/datetime.d.ts +5 -5
  5. package/dist/api/datetime.d.ts.map +1 -1
  6. package/dist/api/index.d.ts +1 -1
  7. package/dist/api/index.d.ts.map +1 -1
  8. package/dist/api/metadata.d.ts +2 -2
  9. package/dist/api/metadata.d.ts.map +1 -1
  10. package/dist/api.cjs +1 -0
  11. package/dist/api.d.ts +4 -0
  12. package/dist/api.d.ts.map +1 -0
  13. package/dist/api.mjs +27 -0
  14. package/dist/api.types.cjs +1 -0
  15. package/dist/api.types.d.ts +4 -0
  16. package/dist/api.types.d.ts.map +1 -0
  17. package/dist/api.types.mjs +1 -0
  18. package/dist/auth/AuthProvider.d.ts +3 -3
  19. package/dist/auth/AuthProvider.d.ts.map +1 -1
  20. package/dist/auth/authClient.d.ts +4 -4
  21. package/dist/auth/authClient.d.ts.map +1 -1
  22. package/dist/auth/authConfig.d.ts +5 -5
  23. package/dist/auth/authConfig.d.ts.map +1 -1
  24. package/dist/auth/index.d.ts +1 -1
  25. package/dist/auth/index.d.ts.map +1 -1
  26. package/dist/auth/types.d.ts +21 -21
  27. package/dist/auth/types.d.ts.map +1 -1
  28. package/dist/auth/useAuth.d.ts +2 -2
  29. package/dist/auth/useAuth.d.ts.map +1 -1
  30. package/dist/auth.cjs +1 -0
  31. package/dist/auth.d.ts +5 -0
  32. package/dist/auth.d.ts.map +1 -0
  33. package/dist/auth.mjs +280 -0
  34. package/dist/auth.types.cjs +1 -0
  35. package/dist/auth.types.d.ts +2 -0
  36. package/dist/auth.types.d.ts.map +1 -0
  37. package/dist/auth.types.mjs +1 -0
  38. package/dist/base-types.d.ts +2 -0
  39. package/dist/base-types.d.ts.map +1 -0
  40. package/dist/client-C15j4O5B.cjs +1 -0
  41. package/dist/client-CfvLiGfP.js +233 -0
  42. package/dist/cn-Dr87sK3i.js +2775 -0
  43. package/dist/cn-mXUIg4vp.cjs +1 -0
  44. package/dist/components/hooks/index.d.ts +3 -3
  45. package/dist/components/hooks/index.d.ts.map +1 -1
  46. package/dist/components/hooks/useFilter/index.d.ts +2 -2
  47. package/dist/components/hooks/useFilter/index.d.ts.map +1 -1
  48. package/dist/components/hooks/useFilter/types.d.ts +19 -31
  49. package/dist/components/hooks/useFilter/types.d.ts.map +1 -1
  50. package/dist/components/hooks/useFilter/useFilter.d.ts +2 -2
  51. package/dist/components/hooks/useFilter/useFilter.d.ts.map +1 -1
  52. package/dist/components/hooks/useForm/apiClient.d.ts +6 -6
  53. package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -1
  54. package/dist/components/hooks/useForm/expressionValidator.utils.d.ts +7 -7
  55. package/dist/components/hooks/useForm/expressionValidator.utils.d.ts.map +1 -1
  56. package/dist/components/hooks/useForm/index.d.ts +5 -5
  57. package/dist/components/hooks/useForm/index.d.ts.map +1 -1
  58. package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts +10 -10
  59. package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts.map +1 -1
  60. package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts +7 -12
  61. package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts.map +1 -1
  62. package/dist/components/hooks/useForm/schemaParser.utils.d.ts +7 -7
  63. package/dist/components/hooks/useForm/schemaParser.utils.d.ts.map +1 -1
  64. package/dist/components/hooks/useForm/types.d.ts +67 -76
  65. package/dist/components/hooks/useForm/types.d.ts.map +1 -1
  66. package/dist/components/hooks/useForm/useForm.d.ts +2 -2
  67. package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
  68. package/dist/components/hooks/useKanban/apiClient.d.ts +16 -16
  69. package/dist/components/hooks/useKanban/apiClient.d.ts.map +1 -1
  70. package/dist/components/hooks/useKanban/context.d.ts +3 -3
  71. package/dist/components/hooks/useKanban/context.d.ts.map +1 -1
  72. package/dist/components/hooks/useKanban/dragDropManager.d.ts +7 -7
  73. package/dist/components/hooks/useKanban/dragDropManager.d.ts.map +1 -1
  74. package/dist/components/hooks/useKanban/index.d.ts +1 -1
  75. package/dist/components/hooks/useKanban/index.d.ts.map +1 -1
  76. package/dist/components/hooks/useKanban/types.d.ts +65 -67
  77. package/dist/components/hooks/useKanban/types.d.ts.map +1 -1
  78. package/dist/components/hooks/useKanban/useKanban.d.ts +2 -2
  79. package/dist/components/hooks/useKanban/useKanban.d.ts.map +1 -1
  80. package/dist/components/hooks/useTable/index.d.ts +1 -1
  81. package/dist/components/hooks/useTable/index.d.ts.map +1 -1
  82. package/dist/components/hooks/useTable/types.d.ts +10 -10
  83. package/dist/components/hooks/useTable/types.d.ts.map +1 -1
  84. package/dist/components/hooks/useTable/useTable.d.ts +2 -2
  85. package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
  86. package/dist/filter.cjs +1 -0
  87. package/dist/filter.d.ts +3 -0
  88. package/dist/filter.d.ts.map +1 -0
  89. package/dist/filter.mjs +6 -0
  90. package/dist/filter.types.cjs +1 -0
  91. package/dist/filter.types.d.ts +2 -0
  92. package/dist/filter.types.d.ts.map +1 -0
  93. package/dist/filter.types.mjs +1 -0
  94. package/dist/form.cjs +1 -0
  95. package/dist/form.d.ts +3 -0
  96. package/dist/form.d.ts.map +1 -0
  97. package/dist/form.mjs +2355 -0
  98. package/dist/form.types.cjs +1 -0
  99. package/dist/form.types.d.ts +2 -0
  100. package/dist/form.types.d.ts.map +1 -0
  101. package/dist/form.types.mjs +1 -0
  102. package/dist/jsx-runtime-BYECrxsp.cjs +30 -0
  103. package/dist/jsx-runtime-DGlMoOmv.js +630 -0
  104. package/dist/kanban.cjs +13 -0
  105. package/dist/kanban.d.ts +5 -0
  106. package/dist/kanban.d.ts.map +1 -0
  107. package/dist/kanban.mjs +1060 -0
  108. package/dist/kanban.types.cjs +1 -0
  109. package/dist/kanban.types.d.ts +2 -0
  110. package/dist/kanban.types.d.ts.map +1 -0
  111. package/dist/kanban.types.mjs +1 -0
  112. package/dist/kanban.ui.cjs +1 -0
  113. package/dist/kanban.ui.d.ts +2 -0
  114. package/dist/kanban.ui.d.ts.map +1 -0
  115. package/dist/kanban.ui.mjs +104 -0
  116. package/dist/metadata-2FLBsFcf.cjs +1 -0
  117. package/dist/metadata-DBcoDth-.js +43 -0
  118. package/dist/table.cjs +1 -0
  119. package/dist/table.d.ts +2 -0
  120. package/dist/table.d.ts.map +1 -0
  121. package/dist/table.mjs +148 -0
  122. package/dist/table.types.cjs +1 -0
  123. package/dist/table.types.d.ts +2 -0
  124. package/dist/table.types.d.ts.map +1 -0
  125. package/dist/table.types.mjs +1 -0
  126. package/dist/types/base-fields.d.ts +45 -45
  127. package/dist/types/base-fields.d.ts.map +1 -1
  128. package/dist/types/common.d.ts +45 -61
  129. package/dist/types/common.d.ts.map +1 -1
  130. package/dist/types.cjs +1 -0
  131. package/dist/types.mjs +1 -0
  132. package/dist/useFilter-CXFqEHyI.js +129 -0
  133. package/dist/useFilter-D-bCDo6Z.cjs +1 -0
  134. package/dist/useQuery-BScHEo7x.cjs +1 -0
  135. package/dist/useQuery-KpZFg80c.js +748 -0
  136. package/dist/utils/formatting.d.ts +4 -4
  137. package/dist/utils/formatting.d.ts.map +1 -1
  138. package/dist/utils.cjs +4 -0
  139. package/dist/utils.d.ts +3 -0
  140. package/dist/utils.d.ts.map +1 -0
  141. package/dist/utils.mjs +105 -0
  142. package/package.json +147 -9
  143. package/sdk/api/client.ts +51 -51
  144. package/sdk/api/datetime.ts +5 -5
  145. package/sdk/api/index.ts +28 -33
  146. package/sdk/api/metadata.ts +4 -4
  147. package/sdk/api.ts +24 -0
  148. package/sdk/api.types.ts +58 -0
  149. package/sdk/auth/AuthProvider.tsx +18 -18
  150. package/sdk/auth/authClient.ts +9 -9
  151. package/sdk/auth/authConfig.ts +9 -9
  152. package/sdk/auth/index.ts +5 -5
  153. package/sdk/auth/types.ts +21 -21
  154. package/sdk/auth/useAuth.ts +2 -2
  155. package/sdk/auth.ts +22 -0
  156. package/sdk/auth.types.ts +28 -0
  157. package/sdk/base-types.ts +45 -0
  158. package/sdk/components/hooks/index.ts +22 -22
  159. package/sdk/components/hooks/useFilter/index.ts +8 -14
  160. package/sdk/components/hooks/useFilter/types.ts +29 -58
  161. package/sdk/components/hooks/useFilter/useFilter.ts +41 -44
  162. package/sdk/components/hooks/useForm/apiClient.ts +8 -8
  163. package/sdk/components/hooks/useForm/expressionValidator.utils.ts +18 -18
  164. package/sdk/components/hooks/useForm/index.ts +24 -24
  165. package/sdk/components/hooks/useForm/optimizedExpressionValidator.utils.ts +22 -22
  166. package/sdk/components/hooks/useForm/ruleClassifier.utils.ts +26 -62
  167. package/sdk/components/hooks/useForm/schemaParser.utils.ts +24 -24
  168. package/sdk/components/hooks/useForm/types.ts +66 -82
  169. package/sdk/components/hooks/useForm/useForm.ts +15 -21
  170. package/sdk/components/hooks/useKanban/apiClient.ts +54 -54
  171. package/sdk/components/hooks/useKanban/context.ts +3 -3
  172. package/sdk/components/hooks/useKanban/dragDropManager.ts +19 -19
  173. package/sdk/components/hooks/useKanban/index.ts +26 -26
  174. package/sdk/components/hooks/useKanban/types.ts +69 -71
  175. package/sdk/components/hooks/useKanban/useKanban.ts +43 -51
  176. package/sdk/components/hooks/useKanban/useKanbanSimple.ts +4 -4
  177. package/sdk/components/hooks/useTable/index.ts +5 -1
  178. package/sdk/components/hooks/useTable/types.ts +10 -10
  179. package/sdk/components/hooks/useTable/useTable.ts +10 -10
  180. package/sdk/filter.ts +13 -0
  181. package/sdk/filter.types.ts +17 -0
  182. package/sdk/form.ts +15 -0
  183. package/sdk/form.types.ts +46 -0
  184. package/sdk/kanban.ts +23 -0
  185. package/sdk/kanban.types.ts +50 -0
  186. package/sdk/kanban.ui.ts +16 -0
  187. package/sdk/table.ts +7 -0
  188. package/sdk/table.types.ts +13 -0
  189. package/sdk/types/base-fields.ts +47 -47
  190. package/sdk/types/common.ts +47 -71
  191. package/sdk/types/index.ts +1 -1
  192. package/sdk/utils/formatting.ts +4 -4
  193. package/sdk/utils.ts +10 -0
  194. package/dist/index.cjs +0 -45
  195. package/dist/index.mjs +0 -6387
package/sdk/api/index.ts CHANGED
@@ -23,43 +23,38 @@ export type { BackendSchema, MetadataItem, FieldMetadata } from "./metadata";
23
23
  // Re-export common types for convenience
24
24
  export type {
25
25
  // Sort types
26
- SortDirection,
27
- SortOption,
28
- Sort,
29
- // Filter types (new names)
30
- Condition,
31
- ConditionGroup,
32
- ConditionGroupOperator,
33
- Filter,
34
- FilterRHSType,
35
- ConditionOperator,
36
- // Filter types (legacy - deprecated)
37
- FilterCondition,
38
- FilterOperator,
39
- FilterLogical,
40
- FilterNode,
26
+ SortDirectionType,
27
+ SortOptionType,
28
+ SortType,
29
+ // Filter types
30
+ ConditionType,
31
+ ConditionGroupType,
32
+ ConditionGroupOperatorType,
33
+ FilterType,
34
+ FilterRHSTypeType,
35
+ ConditionOperatorType,
41
36
  // List types
42
- ListOptions,
43
- ListResponse,
44
- ReadResponse,
45
- CreateUpdateResponse,
46
- DeleteResponse,
47
- CountResponse,
37
+ ListOptionsType,
38
+ ListResponseType,
39
+ ReadResponseType,
40
+ CreateUpdateResponseType,
41
+ DeleteResponseType,
42
+ CountResponseType,
48
43
  // DateTime types
49
- DateTimeEncoded,
50
- DateEncoded,
44
+ DateTimeEncodedType,
45
+ DateEncodedType,
51
46
  // Metric types
52
- MetricType,
53
- MetricField,
54
- MetricOptions,
55
- MetricResponse,
47
+ MetricTypeType,
48
+ MetricFieldType,
49
+ MetricOptionsType,
50
+ MetricResponseType,
56
51
  // Pivot types
57
- PivotHeaderItem,
58
- PivotResponseData,
59
- PivotOptions,
60
- PivotResponse,
52
+ PivotHeaderItemType,
53
+ PivotResponseDataType,
54
+ PivotOptionsType,
55
+ PivotResponseType,
61
56
  // Draft types
62
- DraftResponse,
57
+ DraftResponseType,
63
58
  // Fields types
64
- FieldsResponse,
59
+ FieldsResponseType,
65
60
  } from "../types/common";
@@ -3,7 +3,7 @@
3
3
  // ============================================================
4
4
  // Handles metadata/schema fetching operations for Business Objects
5
5
 
6
- import type { ListOptions, ListResponse } from "../types/common";
6
+ import type { ListOptionsType, ListResponseType } from "../types/common";
7
7
  import { getApiBaseUrl, getDefaultHeaders } from "./client";
8
8
 
9
9
  // ============================================================
@@ -97,8 +97,8 @@ export interface MetadataItem {
97
97
  * ```
98
98
  */
99
99
  export async function listMetadata(
100
- options?: ListOptions
101
- ): Promise<ListResponse<MetadataItem>> {
100
+ options?: ListOptionsType
101
+ ): Promise<ListResponseType<MetadataItem>> {
102
102
  try {
103
103
  const baseUrl = getApiBaseUrl();
104
104
  const headers = getDefaultHeaders();
@@ -121,7 +121,7 @@ export async function listMetadata(
121
121
 
122
122
  const result = await response.json();
123
123
 
124
- return result as ListResponse<MetadataItem>;
124
+ return result as ListResponseType<MetadataItem>;
125
125
  } catch (error) {
126
126
  console.error("Metadata list error:", error);
127
127
  throw new Error(
package/sdk/api.ts ADDED
@@ -0,0 +1,24 @@
1
+ // ============================================================
2
+ // API MODULE - Main Entry Point
3
+ // @ram_28/kf-ai-sdk/api
4
+ // ============================================================
5
+
6
+ // Main API client
7
+ export {
8
+ api,
9
+ setApiBaseUrl,
10
+ setDefaultHeaders,
11
+ getDefaultHeaders,
12
+ getApiBaseUrl,
13
+ } from './api/client';
14
+
15
+ // DateTime utilities
16
+ export {
17
+ encodeDatetime,
18
+ decodeDatetime,
19
+ encodeDate,
20
+ decodeDate,
21
+ } from './api/datetime';
22
+
23
+ // Metadata API client
24
+ export { getBdoSchema, listMetadata } from './api/metadata';
@@ -0,0 +1,58 @@
1
+ // ============================================================
2
+ // API MODULE - Type Exports
3
+ // @ram_28/kf-ai-sdk/api/types
4
+ // ============================================================
5
+
6
+ // Resource client type
7
+ export type { ResourceClient } from './api/client';
8
+
9
+ // Metadata types
10
+ export type { BackendSchema, MetadataItem, FieldMetadata } from './api/metadata';
11
+
12
+ // Common API types
13
+ export type {
14
+ // Sort types
15
+ SortDirectionType,
16
+ SortOptionType,
17
+ SortType,
18
+
19
+ // Filter types
20
+ ConditionType,
21
+ ConditionGroupType,
22
+ ConditionGroupOperatorType,
23
+ ConditionOperatorType,
24
+ FilterType,
25
+ FilterRHSTypeType,
26
+
27
+ // List types
28
+ ListOptionsType,
29
+ ListResponseType,
30
+ ReadResponseType,
31
+ CreateUpdateResponseType,
32
+ DeleteResponseType,
33
+ CountResponseType,
34
+
35
+ // DateTime types
36
+ DateTimeEncodedType,
37
+ DateEncodedType,
38
+
39
+ // Metric types
40
+ MetricTypeType,
41
+ MetricFieldType,
42
+ MetricOptionsType,
43
+ MetricResponseType,
44
+
45
+ // Pivot types
46
+ PivotHeaderItemType,
47
+ PivotResponseDataType,
48
+ PivotOptionsType,
49
+ PivotResponseType,
50
+
51
+ // Draft types
52
+ DraftResponseType,
53
+
54
+ // Fields types
55
+ FieldsResponseType,
56
+ FetchFieldOptionType,
57
+ FetchFieldResponseType,
58
+ } from './types/common';
@@ -15,14 +15,14 @@ import React, {
15
15
  import { useQuery, useQueryClient } from "@tanstack/react-query";
16
16
 
17
17
  import type {
18
- AuthContextValue,
19
- AuthProviderProps,
20
- AuthStatus,
21
- UserDetails,
22
- SessionResponse,
23
- AuthProviderName,
24
- LoginOptions,
25
- LogoutOptions,
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<AuthContextValue | null>(null);
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
- }: AuthProviderProps): React.ReactElement {
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<SessionResponse, Error>({
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: AuthStatus = useMemo(() => {
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: UserDetails | null = sessionData?.userDetails || null;
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?: AuthProviderName, options?: LoginOptions) => {
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?: LogoutOptions) => {
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<SessionResponse | null> => {
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: AuthContextValue = useMemo(
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(): AuthContextValue {
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");
@@ -4,10 +4,10 @@
4
4
  // Low-level functions for authentication API calls
5
5
 
6
6
  import type {
7
- SessionResponse,
8
- AuthProviderName,
9
- LoginOptions,
10
- LogoutOptions,
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<SessionResponse> {
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: SessionResponse = await response.json();
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?: AuthProviderName,
85
- options?: LoginOptions
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?: LogoutOptions): Promise<void> {
150
+ export async function performLogout(options?: LogoutOptionsType): Promise<void> {
151
151
  const config = getAuthConfig();
152
152
  const baseUrl = getAuthBaseUrl();
153
153
  const headers = getDefaultHeaders();
@@ -3,13 +3,13 @@
3
3
  // ============================================================
4
4
  // Global auth configuration following the setApiBaseUrl pattern
5
5
 
6
- import type { AuthConfig, AuthProviderName, AuthEndpointConfig } from "./types";
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: AuthConfig = {
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: AuthConfig = { ...defaultAuthConfig };
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<AuthConfig>): void {
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: AuthProviderName,
71
- config: AuthEndpointConfig
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<AuthConfig> {
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: AuthProviderName
96
- ): AuthEndpointConfig | undefined {
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
- UserDetails,
17
- SessionResponse,
18
- AuthStatus,
19
- AuthProviderProps,
20
- UseAuthReturn,
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 UserDetails {
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 SessionResponse {
19
- userDetails: 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 AuthStatus = "loading" | "authenticated" | "unauthenticated";
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 AuthProviderName = "google" | "microsoft" | "github" | "custom";
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 AuthEndpointConfig {
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 AuthConfig {
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<AuthProviderName, AuthEndpointConfig>>;
57
+ providers: Partial<Record<AuthProviderNameType, AuthEndpointConfigType>>;
58
58
 
59
59
  /** Default provider to use for login */
60
- defaultProvider: AuthProviderName;
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 AuthProviderProps {
93
+ export interface AuthProviderPropsType {
94
94
  children: React.ReactNode;
95
95
 
96
96
  /** Override global config for this provider instance */
97
- config?: Partial<AuthConfig>;
97
+ config?: Partial<AuthConfigType>;
98
98
 
99
99
  /** Callback when authentication status changes */
100
- onAuthChange?: (status: AuthStatus, user: UserDetails | null) => void;
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 LoginOptions {
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 LogoutOptions {
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 UseAuthReturn {
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: UserDetails | null;
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: AuthStatus;
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?: AuthProviderName, options?: LoginOptions) => void;
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?: LogoutOptions) => Promise<void>;
176
+ logout: (options?: LogoutOptionsType) => Promise<void>;
177
177
 
178
178
  /**
179
179
  * Manually refresh the session
180
180
  */
181
- refreshSession: () => Promise<SessionResponse | null>;
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 AuthContextValue extends UseAuthReturn {
207
+ export interface AuthContextValueType extends UseAuthReturnType {
208
208
  /** Internal: force re-check session */
209
209
  _forceCheck: () => void;
210
210
  }
@@ -4,7 +4,7 @@
4
4
  // Main hook for consuming authentication state
5
5
 
6
6
  import { useMemo } from "react";
7
- import type { UseAuthReturn } from "./types";
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(): UseAuthReturn {
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';