@ram_28/kf-ai-sdk 1.0.10 → 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 +23 -13
- 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 +79 -70
- 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 +76 -49
- 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 +85 -75
- package/sdk/components/hooks/useForm/useForm.ts +160 -40
- 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 -6327
package/dist/auth/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* User details returned from the session endpoint
|
|
3
3
|
*/
|
|
4
|
-
export interface
|
|
4
|
+
export interface UserDetailsType {
|
|
5
5
|
_id: string;
|
|
6
6
|
_name: string;
|
|
7
7
|
Role: string;
|
|
@@ -10,23 +10,23 @@ export interface UserDetails {
|
|
|
10
10
|
/**
|
|
11
11
|
* Session response from /api/id endpoint
|
|
12
12
|
*/
|
|
13
|
-
export interface
|
|
14
|
-
userDetails:
|
|
13
|
+
export interface SessionResponseType {
|
|
14
|
+
userDetails: UserDetailsType;
|
|
15
15
|
staticBaseUrl: string;
|
|
16
16
|
buildId: string;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Authentication status
|
|
20
20
|
*/
|
|
21
|
-
export type
|
|
21
|
+
export type AuthStatusType = "loading" | "authenticated" | "unauthenticated";
|
|
22
22
|
/**
|
|
23
23
|
* Authentication provider type (extensible for multiple OAuth providers)
|
|
24
24
|
*/
|
|
25
|
-
export type
|
|
25
|
+
export type AuthProviderNameType = "google" | "microsoft" | "github" | "custom";
|
|
26
26
|
/**
|
|
27
27
|
* Auth endpoint configuration for a specific provider
|
|
28
28
|
*/
|
|
29
|
-
export interface
|
|
29
|
+
export interface AuthEndpointConfigType {
|
|
30
30
|
/** Login endpoint path (e.g., "/api/auth/google/login") */
|
|
31
31
|
loginPath: string;
|
|
32
32
|
/** Optional logout endpoint path */
|
|
@@ -37,15 +37,15 @@ export interface AuthEndpointConfig {
|
|
|
37
37
|
/**
|
|
38
38
|
* Global authentication configuration
|
|
39
39
|
*/
|
|
40
|
-
export interface
|
|
40
|
+
export interface AuthConfigType {
|
|
41
41
|
/** Base URL for auth endpoints (defaults to apiBaseUrl) */
|
|
42
42
|
baseUrl?: string;
|
|
43
43
|
/** Session check endpoint (default: "/api/id") */
|
|
44
44
|
sessionEndpoint: string;
|
|
45
45
|
/** Auth provider configurations */
|
|
46
|
-
providers: Partial<Record<
|
|
46
|
+
providers: Partial<Record<AuthProviderNameType, AuthEndpointConfigType>>;
|
|
47
47
|
/** Default provider to use for login */
|
|
48
|
-
defaultProvider:
|
|
48
|
+
defaultProvider: AuthProviderNameType;
|
|
49
49
|
/** Auto-redirect to login when unauthenticated */
|
|
50
50
|
autoRedirect: boolean;
|
|
51
51
|
/** Custom redirect URL (if not using provider's login path) */
|
|
@@ -69,12 +69,12 @@ export interface AuthConfig {
|
|
|
69
69
|
/**
|
|
70
70
|
* AuthProvider component props
|
|
71
71
|
*/
|
|
72
|
-
export interface
|
|
72
|
+
export interface AuthProviderPropsType {
|
|
73
73
|
children: React.ReactNode;
|
|
74
74
|
/** Override global config for this provider instance */
|
|
75
|
-
config?: Partial<
|
|
75
|
+
config?: Partial<AuthConfigType>;
|
|
76
76
|
/** Callback when authentication status changes */
|
|
77
|
-
onAuthChange?: (status:
|
|
77
|
+
onAuthChange?: (status: AuthStatusType, user: UserDetailsType | null) => void;
|
|
78
78
|
/** Callback on authentication error */
|
|
79
79
|
onError?: (error: Error) => void;
|
|
80
80
|
/** Custom loading component */
|
|
@@ -87,7 +87,7 @@ export interface AuthProviderProps {
|
|
|
87
87
|
/**
|
|
88
88
|
* Options for login operation
|
|
89
89
|
*/
|
|
90
|
-
export interface
|
|
90
|
+
export interface LoginOptionsType {
|
|
91
91
|
/** URL to redirect after successful login */
|
|
92
92
|
callbackUrl?: string;
|
|
93
93
|
/** Additional query parameters for login URL */
|
|
@@ -96,7 +96,7 @@ export interface LoginOptions {
|
|
|
96
96
|
/**
|
|
97
97
|
* Options for logout operation
|
|
98
98
|
*/
|
|
99
|
-
export interface
|
|
99
|
+
export interface LogoutOptionsType {
|
|
100
100
|
/** URL to redirect after logout */
|
|
101
101
|
redirectUrl?: string;
|
|
102
102
|
/** Whether to call logout endpoint (default: true) */
|
|
@@ -105,15 +105,15 @@ export interface LogoutOptions {
|
|
|
105
105
|
/**
|
|
106
106
|
* Return type for useAuth hook
|
|
107
107
|
*/
|
|
108
|
-
export interface
|
|
108
|
+
export interface UseAuthReturnType {
|
|
109
109
|
/** Current authenticated user (null if not authenticated) */
|
|
110
|
-
user:
|
|
110
|
+
user: UserDetailsType | null;
|
|
111
111
|
/** Static base URL from session */
|
|
112
112
|
staticBaseUrl: string | null;
|
|
113
113
|
/** Build ID from session */
|
|
114
114
|
buildId: string | null;
|
|
115
115
|
/** Current authentication status */
|
|
116
|
-
status:
|
|
116
|
+
status: AuthStatusType;
|
|
117
117
|
/** Convenience boolean for authenticated state */
|
|
118
118
|
isAuthenticated: boolean;
|
|
119
119
|
/** Convenience boolean for loading state */
|
|
@@ -123,16 +123,16 @@ export interface UseAuthReturn {
|
|
|
123
123
|
* @param provider - Auth provider to use (defaults to configured default)
|
|
124
124
|
* @param options - Additional options for login
|
|
125
125
|
*/
|
|
126
|
-
login: (provider?:
|
|
126
|
+
login: (provider?: AuthProviderNameType, options?: LoginOptionsType) => void;
|
|
127
127
|
/**
|
|
128
128
|
* Logout the current user
|
|
129
129
|
* @param options - Additional options for logout
|
|
130
130
|
*/
|
|
131
|
-
logout: (options?:
|
|
131
|
+
logout: (options?: LogoutOptionsType) => Promise<void>;
|
|
132
132
|
/**
|
|
133
133
|
* Manually refresh the session
|
|
134
134
|
*/
|
|
135
|
-
refreshSession: () => Promise<
|
|
135
|
+
refreshSession: () => Promise<SessionResponseType | null>;
|
|
136
136
|
/**
|
|
137
137
|
* Check if user has a specific role
|
|
138
138
|
*/
|
|
@@ -149,7 +149,7 @@ export interface UseAuthReturn {
|
|
|
149
149
|
/**
|
|
150
150
|
* Auth context value (internal)
|
|
151
151
|
*/
|
|
152
|
-
export interface
|
|
152
|
+
export interface AuthContextValueType extends UseAuthReturnType {
|
|
153
153
|
/** Internal: force re-check session */
|
|
154
154
|
_forceCheck: () => void;
|
|
155
155
|
}
|
package/dist/auth/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../sdk/auth/types.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../sdk/auth/types.ts"],"names":[],"mappings":"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"}
|
package/dist/auth/useAuth.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { UseAuthReturnType } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* Hook to access authentication state and operations
|
|
4
4
|
*
|
|
@@ -23,5 +23,5 @@ import type { UseAuthReturn } from "./types";
|
|
|
23
23
|
* }
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
|
-
export declare function useAuth():
|
|
26
|
+
export declare function useAuth(): UseAuthReturnType;
|
|
27
27
|
//# sourceMappingURL=useAuth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../sdk/auth/useAuth.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../sdk/auth/useAuth.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGjD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,OAAO,IAAI,iBAAiB,CAmC3C"}
|
package/dist/auth.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var z=Object.defineProperty;var J=(e,t,n)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var M=(e,t,n)=>J(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("./jsx-runtime-BYECrxsp.cjs"),r=require("react"),K=require("@tanstack/react-query"),L=require("./client-C15j4O5B.cjs"),H={sessionEndpoint:"/api/id",providers:{google:{loginPath:"/api/auth/google/login",logoutPath:"/api/auth/logout"}},defaultProvider:"google",autoRedirect:!1,sessionCheckInterval:0,retry:{count:3,delay:1e3},staleTime:5*60*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!0};let h={...H};function N(e){h={...h,...e,providers:{...h.providers,...e.providers},retry:{...h.retry,...e.retry}}}function X(e,t){h.providers[e]=t}function R(){return{...h}}function x(){return h.baseUrl||L.getApiBaseUrl()||(typeof window<"u"?window.location.origin:"")}function Y(e){return h.providers[e]}function Z(){h={...H}}class P extends Error{constructor(n,s){super(n);M(this,"statusCode");this.name="AuthenticationError",this.statusCode=s}}async function D(){const e=R(),t=x(),n=L.getDefaultHeaders(),s=await fetch(`${t}${e.sessionEndpoint}`,{method:"GET",headers:n,credentials:"include"});if(!s.ok)throw s.status===401||s.status===403?new P("Not authenticated",s.status):new P(`Session check failed: ${s.statusText}`,s.status);return await s.json()}function W(e,t){return new Promise(()=>{const n=R(),s=x();if(!s)throw new Error('Auth base URL is not configured. Call setApiBaseUrl("https://...") or configureAuth({ baseUrl: "https://..." }) first.');const u=e||n.defaultProvider,c=Y(u);if(!c){const w=Object.keys(n.providers||{}).join(", ")||"none";throw new Error(`Auth provider "${u}" is not configured. Available providers: ${w}`)}if(!c.loginPath)throw new Error(`Login path not configured for provider "${u}". Configure it with: configureAuth({ providers: { ${u}: { loginPath: '/api/auth/...' } } })`);let f;try{f=new URL(`${s}${c.loginPath}`)}catch{throw new Error(`Failed to construct login URL. Base URL: "${s}", Login path: "${c.loginPath}". Ensure baseUrl is a valid URL (e.g., "https://example.com").`)}(t!=null&&t.callbackUrl||n.callbackUrl)&&f.searchParams.set("callbackUrl",(t==null?void 0:t.callbackUrl)||n.callbackUrl||window.location.href),t!=null&&t.params&&Object.entries(t.params).forEach(([w,b])=>{f.searchParams.set(w,b)}),window.location.href=f.toString()})}async function ee(e){const t=R(),n=x(),s=L.getDefaultHeaders(),u=Y(t.defaultProvider),c=u==null?void 0:u.logoutPath;if(c&&(e==null?void 0:e.callLogoutEndpoint)!==!1)try{await fetch(`${n}${c}`,{method:"POST",headers:s,credentials:"include"})}catch(f){console.warn("Logout endpoint call failed:",f)}e!=null&&e.redirectUrl?window.location.href=e.redirectUrl:t.loginRedirectUrl&&(window.location.href=t.loginRedirectUrl)}const G=r.createContext(null),_=["auth","session"];function te({children:e,config:t,onAuthChange:n,onError:s,loadingComponent:u,unauthenticatedComponent:c,skipInitialCheck:f=!1}){const w=r.useRef(!1);t&&!w.current&&(N(t),w.current=!0);const b=K.useQueryClient(),l=R(),{data:i,isLoading:g,error:v,refetch:U,isFetching:E}=K.useQuery({queryKey:_,queryFn:D,enabled:!f,retry:(o,y)=>y instanceof P&&(y.statusCode===401||y.statusCode===403)?!1:o<l.retry.count,retryDelay:l.retry.delay,staleTime:l.staleTime,gcTime:l.staleTime*2,refetchOnWindowFocus:l.refetchOnWindowFocus??!0,refetchOnReconnect:l.refetchOnReconnect??!0,refetchInterval:l.sessionCheckInterval||!1}),[j,k]=r.useState(null),d=r.useMemo(()=>g||E?"loading":i!=null&&i.userDetails?"authenticated":"unauthenticated",[g,E,i]),a=(i==null?void 0:i.userDetails)||null,p=(i==null?void 0:i.staticBaseUrl)||null,S=(i==null?void 0:i.buildId)||null,$=d==="authenticated",m=r.useRef(n);m.current=n;const C=r.useRef(s);C.current=s,r.useEffect(()=>{var o;g||(o=m.current)==null||o.call(m,d,a)},[d,a,g]),r.useEffect(()=>{var o;v&&(k(v),(o=C.current)==null||o.call(C,v))},[v]),r.useEffect(()=>{d==="unauthenticated"&&l.autoRedirect&&!g&&W()},[d,g,l.autoRedirect]);const B=r.useCallback((o,y)=>{W(o,y)},[]),O=r.useCallback(async o=>{b.removeQueries({queryKey:_}),await ee(o)},[b]),q=r.useCallback(async()=>{if(E)return i||null;try{return(await U()).data||null}catch(o){return k(o),null}},[U,E,i]),I=r.useCallback(o=>(a==null?void 0:a.Role)===o,[a]),T=r.useCallback(o=>o.includes((a==null?void 0:a.Role)||""),[a]),F=r.useCallback(()=>{k(null)},[]),Q=r.useCallback(()=>{U()},[U]),V=r.useMemo(()=>({user:a,staticBaseUrl:p,buildId:S,status:d,isAuthenticated:$,isLoading:g,login:B,logout:O,refreshSession:q,hasRole:I,hasAnyRole:T,error:j,clearError:F,_forceCheck:Q}),[a,p,S,d,$,g,B,O,q,I,T,j,F,Q]);return d==="loading"&&u?A.jsxRuntimeExports.jsx(A.jsxRuntimeExports.Fragment,{children:u}):d==="unauthenticated"&&!l.autoRedirect&&c?A.jsxRuntimeExports.jsx(A.jsxRuntimeExports.Fragment,{children:c}):A.jsxRuntimeExports.jsx(G.Provider,{value:V,children:e})}function re(){const e=r.useContext(G);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}function ne(){const e=re();return r.useMemo(()=>({user:e.user,staticBaseUrl:e.staticBaseUrl,buildId:e.buildId,status:e.status,isAuthenticated:e.isAuthenticated,isLoading:e.isLoading,login:e.login,logout:e.logout,refreshSession:e.refreshSession,hasRole:e.hasRole,hasAnyRole:e.hasAnyRole,error:e.error,clearError:e.clearError}),[e.user,e.staticBaseUrl,e.buildId,e.status,e.isAuthenticated,e.isLoading,e.login,e.logout,e.refreshSession,e.hasRole,e.hasAnyRole,e.error,e.clearError])}exports.AuthProvider=te;exports.AuthenticationError=P;exports.configureAuth=N;exports.getAuthBaseUrl=x;exports.getAuthConfig=R;exports.resetAuthConfig=Z;exports.setAuthProvider=X;exports.useAuth=ne;
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { AuthProvider } from './auth/AuthProvider';
|
|
2
|
+
export { useAuth } from './auth/useAuth';
|
|
3
|
+
export { AuthenticationError } from './auth/authClient';
|
|
4
|
+
export { configureAuth, getAuthConfig, setAuthProvider, getAuthBaseUrl, resetAuthConfig, } from './auth/authConfig';
|
|
5
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../sdk/auth.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,EACL,aAAa,EACb,aAAa,EACb,eAAe,EACf,cAAc,EACd,eAAe,GAChB,MAAM,mBAAmB,CAAC"}
|
package/dist/auth.mjs
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
var J = Object.defineProperty;
|
|
2
|
+
var X = (e, t, r) => t in e ? J(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var _ = (e, t, r) => X(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { j as U } from "./jsx-runtime-DGlMoOmv.js";
|
|
5
|
+
import { useRef as x, useState as Z, useMemo as p, useEffect as L, useCallback as g, createContext as D, useContext as ee } from "react";
|
|
6
|
+
import { useQueryClient as te, useQuery as re } from "@tanstack/react-query";
|
|
7
|
+
import { c as ne, g as G } from "./client-CfvLiGfP.js";
|
|
8
|
+
const H = {
|
|
9
|
+
sessionEndpoint: "/api/id",
|
|
10
|
+
providers: {
|
|
11
|
+
google: {
|
|
12
|
+
loginPath: "/api/auth/google/login",
|
|
13
|
+
logoutPath: "/api/auth/logout"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
defaultProvider: "google",
|
|
17
|
+
autoRedirect: !1,
|
|
18
|
+
sessionCheckInterval: 0,
|
|
19
|
+
retry: {
|
|
20
|
+
count: 3,
|
|
21
|
+
delay: 1e3
|
|
22
|
+
},
|
|
23
|
+
staleTime: 5 * 60 * 1e3,
|
|
24
|
+
refetchOnWindowFocus: !1,
|
|
25
|
+
refetchOnReconnect: !0
|
|
26
|
+
};
|
|
27
|
+
let d = { ...H };
|
|
28
|
+
function oe(e) {
|
|
29
|
+
d = {
|
|
30
|
+
...d,
|
|
31
|
+
...e,
|
|
32
|
+
providers: {
|
|
33
|
+
...d.providers,
|
|
34
|
+
...e.providers
|
|
35
|
+
},
|
|
36
|
+
retry: {
|
|
37
|
+
...d.retry,
|
|
38
|
+
...e.retry
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function fe(e, t) {
|
|
43
|
+
d.providers[e] = t;
|
|
44
|
+
}
|
|
45
|
+
function P() {
|
|
46
|
+
return { ...d };
|
|
47
|
+
}
|
|
48
|
+
function k() {
|
|
49
|
+
return d.baseUrl || ne() || (typeof window < "u" ? window.location.origin : "");
|
|
50
|
+
}
|
|
51
|
+
function M(e) {
|
|
52
|
+
return d.providers[e];
|
|
53
|
+
}
|
|
54
|
+
function ge() {
|
|
55
|
+
d = { ...H };
|
|
56
|
+
}
|
|
57
|
+
class $ extends Error {
|
|
58
|
+
constructor(r, n) {
|
|
59
|
+
super(r);
|
|
60
|
+
_(this, "statusCode");
|
|
61
|
+
this.name = "AuthenticationError", this.statusCode = n;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async function ie() {
|
|
65
|
+
const e = P(), t = k(), r = G(), n = await fetch(`${t}${e.sessionEndpoint}`, {
|
|
66
|
+
method: "GET",
|
|
67
|
+
headers: r,
|
|
68
|
+
credentials: "include"
|
|
69
|
+
});
|
|
70
|
+
if (!n.ok)
|
|
71
|
+
throw n.status === 401 || n.status === 403 ? new $("Not authenticated", n.status) : new $(
|
|
72
|
+
`Session check failed: ${n.statusText}`,
|
|
73
|
+
n.status
|
|
74
|
+
);
|
|
75
|
+
return await n.json();
|
|
76
|
+
}
|
|
77
|
+
function N(e, t) {
|
|
78
|
+
return new Promise(() => {
|
|
79
|
+
const r = P(), n = k();
|
|
80
|
+
if (!n)
|
|
81
|
+
throw new Error(
|
|
82
|
+
'Auth base URL is not configured. Call setApiBaseUrl("https://...") or configureAuth({ baseUrl: "https://..." }) first.'
|
|
83
|
+
);
|
|
84
|
+
const s = e || r.defaultProvider, c = M(s);
|
|
85
|
+
if (!c) {
|
|
86
|
+
const w = Object.keys(r.providers || {}).join(", ") || "none";
|
|
87
|
+
throw new Error(
|
|
88
|
+
`Auth provider "${s}" is not configured. Available providers: ${w}`
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
if (!c.loginPath)
|
|
92
|
+
throw new Error(
|
|
93
|
+
`Login path not configured for provider "${s}". Configure it with: configureAuth({ providers: { ${s}: { loginPath: '/api/auth/...' } } })`
|
|
94
|
+
);
|
|
95
|
+
let h;
|
|
96
|
+
try {
|
|
97
|
+
h = new URL(`${n}${c.loginPath}`);
|
|
98
|
+
} catch {
|
|
99
|
+
throw new Error(
|
|
100
|
+
`Failed to construct login URL. Base URL: "${n}", Login path: "${c.loginPath}". Ensure baseUrl is a valid URL (e.g., "https://example.com").`
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
(t != null && t.callbackUrl || r.callbackUrl) && h.searchParams.set(
|
|
104
|
+
"callbackUrl",
|
|
105
|
+
(t == null ? void 0 : t.callbackUrl) || r.callbackUrl || window.location.href
|
|
106
|
+
), t != null && t.params && Object.entries(t.params).forEach(([w, m]) => {
|
|
107
|
+
h.searchParams.set(w, m);
|
|
108
|
+
}), window.location.href = h.toString();
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
async function se(e) {
|
|
112
|
+
const t = P(), r = k(), n = G(), s = M(t.defaultProvider), c = s == null ? void 0 : s.logoutPath;
|
|
113
|
+
if (c && (e == null ? void 0 : e.callLogoutEndpoint) !== !1)
|
|
114
|
+
try {
|
|
115
|
+
await fetch(`${r}${c}`, {
|
|
116
|
+
method: "POST",
|
|
117
|
+
headers: n,
|
|
118
|
+
credentials: "include"
|
|
119
|
+
});
|
|
120
|
+
} catch (h) {
|
|
121
|
+
console.warn("Logout endpoint call failed:", h);
|
|
122
|
+
}
|
|
123
|
+
e != null && e.redirectUrl ? window.location.href = e.redirectUrl : t.loginRedirectUrl && (window.location.href = t.loginRedirectUrl);
|
|
124
|
+
}
|
|
125
|
+
const V = D(null), Y = ["auth", "session"];
|
|
126
|
+
function we({
|
|
127
|
+
children: e,
|
|
128
|
+
config: t,
|
|
129
|
+
onAuthChange: r,
|
|
130
|
+
onError: n,
|
|
131
|
+
loadingComponent: s,
|
|
132
|
+
unauthenticatedComponent: c,
|
|
133
|
+
skipInitialCheck: h = !1
|
|
134
|
+
}) {
|
|
135
|
+
const w = x(!1);
|
|
136
|
+
t && !w.current && (oe(t), w.current = !0);
|
|
137
|
+
const m = te(), u = P(), {
|
|
138
|
+
data: i,
|
|
139
|
+
isLoading: f,
|
|
140
|
+
error: v,
|
|
141
|
+
refetch: A,
|
|
142
|
+
isFetching: R
|
|
143
|
+
} = re({
|
|
144
|
+
queryKey: Y,
|
|
145
|
+
queryFn: ie,
|
|
146
|
+
enabled: !h,
|
|
147
|
+
retry: (o, y) => y instanceof $ && (y.statusCode === 401 || y.statusCode === 403) ? !1 : o < u.retry.count,
|
|
148
|
+
retryDelay: u.retry.delay,
|
|
149
|
+
staleTime: u.staleTime,
|
|
150
|
+
gcTime: u.staleTime * 2,
|
|
151
|
+
refetchOnWindowFocus: u.refetchOnWindowFocus ?? !0,
|
|
152
|
+
refetchOnReconnect: u.refetchOnReconnect ?? !0,
|
|
153
|
+
refetchInterval: u.sessionCheckInterval || !1
|
|
154
|
+
}), [S, C] = Z(null), l = p(() => f || R ? "loading" : i != null && i.userDetails ? "authenticated" : "unauthenticated", [f, R, i]), a = (i == null ? void 0 : i.userDetails) || null, j = (i == null ? void 0 : i.staticBaseUrl) || null, B = (i == null ? void 0 : i.buildId) || null, I = l === "authenticated", b = x(r);
|
|
155
|
+
b.current = r;
|
|
156
|
+
const E = x(n);
|
|
157
|
+
E.current = n, L(() => {
|
|
158
|
+
var o;
|
|
159
|
+
f || (o = b.current) == null || o.call(b, l, a);
|
|
160
|
+
}, [l, a, f]), L(() => {
|
|
161
|
+
var o;
|
|
162
|
+
v && (C(v), (o = E.current) == null || o.call(E, v));
|
|
163
|
+
}, [v]), L(() => {
|
|
164
|
+
l === "unauthenticated" && u.autoRedirect && !f && N();
|
|
165
|
+
}, [l, f, u.autoRedirect]);
|
|
166
|
+
const O = g(
|
|
167
|
+
(o, y) => {
|
|
168
|
+
N(o, y);
|
|
169
|
+
},
|
|
170
|
+
[]
|
|
171
|
+
), F = g(
|
|
172
|
+
async (o) => {
|
|
173
|
+
m.removeQueries({ queryKey: Y }), await se(o);
|
|
174
|
+
},
|
|
175
|
+
[m]
|
|
176
|
+
), T = g(async () => {
|
|
177
|
+
if (R)
|
|
178
|
+
return i || null;
|
|
179
|
+
try {
|
|
180
|
+
return (await A()).data || null;
|
|
181
|
+
} catch (o) {
|
|
182
|
+
return C(o), null;
|
|
183
|
+
}
|
|
184
|
+
}, [A, R, i]), q = g(
|
|
185
|
+
(o) => (a == null ? void 0 : a.Role) === o,
|
|
186
|
+
[a]
|
|
187
|
+
), Q = g(
|
|
188
|
+
(o) => o.includes((a == null ? void 0 : a.Role) || ""),
|
|
189
|
+
[a]
|
|
190
|
+
), K = g(() => {
|
|
191
|
+
C(null);
|
|
192
|
+
}, []), W = g(() => {
|
|
193
|
+
A();
|
|
194
|
+
}, [A]), z = p(
|
|
195
|
+
() => ({
|
|
196
|
+
user: a,
|
|
197
|
+
staticBaseUrl: j,
|
|
198
|
+
buildId: B,
|
|
199
|
+
status: l,
|
|
200
|
+
isAuthenticated: I,
|
|
201
|
+
isLoading: f,
|
|
202
|
+
login: O,
|
|
203
|
+
logout: F,
|
|
204
|
+
refreshSession: T,
|
|
205
|
+
hasRole: q,
|
|
206
|
+
hasAnyRole: Q,
|
|
207
|
+
error: S,
|
|
208
|
+
clearError: K,
|
|
209
|
+
_forceCheck: W
|
|
210
|
+
}),
|
|
211
|
+
[
|
|
212
|
+
a,
|
|
213
|
+
j,
|
|
214
|
+
B,
|
|
215
|
+
l,
|
|
216
|
+
I,
|
|
217
|
+
f,
|
|
218
|
+
O,
|
|
219
|
+
F,
|
|
220
|
+
T,
|
|
221
|
+
q,
|
|
222
|
+
Q,
|
|
223
|
+
S,
|
|
224
|
+
K,
|
|
225
|
+
W
|
|
226
|
+
]
|
|
227
|
+
);
|
|
228
|
+
return l === "loading" && s ? /* @__PURE__ */ U.jsx(U.Fragment, { children: s }) : l === "unauthenticated" && !u.autoRedirect && c ? /* @__PURE__ */ U.jsx(U.Fragment, { children: c }) : /* @__PURE__ */ U.jsx(V.Provider, { value: z, children: e });
|
|
229
|
+
}
|
|
230
|
+
function ae() {
|
|
231
|
+
const e = ee(V);
|
|
232
|
+
if (!e)
|
|
233
|
+
throw new Error("useAuth must be used within an AuthProvider");
|
|
234
|
+
return e;
|
|
235
|
+
}
|
|
236
|
+
function ye() {
|
|
237
|
+
const e = ae();
|
|
238
|
+
return p(
|
|
239
|
+
() => ({
|
|
240
|
+
user: e.user,
|
|
241
|
+
staticBaseUrl: e.staticBaseUrl,
|
|
242
|
+
buildId: e.buildId,
|
|
243
|
+
status: e.status,
|
|
244
|
+
isAuthenticated: e.isAuthenticated,
|
|
245
|
+
isLoading: e.isLoading,
|
|
246
|
+
login: e.login,
|
|
247
|
+
logout: e.logout,
|
|
248
|
+
refreshSession: e.refreshSession,
|
|
249
|
+
hasRole: e.hasRole,
|
|
250
|
+
hasAnyRole: e.hasAnyRole,
|
|
251
|
+
error: e.error,
|
|
252
|
+
clearError: e.clearError
|
|
253
|
+
}),
|
|
254
|
+
[
|
|
255
|
+
e.user,
|
|
256
|
+
e.staticBaseUrl,
|
|
257
|
+
e.buildId,
|
|
258
|
+
e.status,
|
|
259
|
+
e.isAuthenticated,
|
|
260
|
+
e.isLoading,
|
|
261
|
+
e.login,
|
|
262
|
+
e.logout,
|
|
263
|
+
e.refreshSession,
|
|
264
|
+
e.hasRole,
|
|
265
|
+
e.hasAnyRole,
|
|
266
|
+
e.error,
|
|
267
|
+
e.clearError
|
|
268
|
+
]
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
export {
|
|
272
|
+
we as AuthProvider,
|
|
273
|
+
$ as AuthenticationError,
|
|
274
|
+
oe as configureAuth,
|
|
275
|
+
k as getAuthBaseUrl,
|
|
276
|
+
P as getAuthConfig,
|
|
277
|
+
ge as resetAuthConfig,
|
|
278
|
+
fe as setAuthProvider,
|
|
279
|
+
ye as useAuth
|
|
280
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.types.d.ts","sourceRoot":"","sources":["../sdk/auth.types.ts"],"names":[],"mappings":"AAKA,YAAY,EAEV,iBAAiB,EAGjB,eAAe,EACf,mBAAmB,EAGnB,cAAc,EAGd,qBAAqB,EACrB,oBAAoB,EAGpB,cAAc,EACd,sBAAsB,EAGtB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type { IdFieldType, StringFieldType, TextAreaFieldType, NumberFieldType, LongFieldType, BooleanFieldType, DateFieldType, DateTimeFieldType, CurrencyFieldType, CurrencyValueType, JSONFieldType, ReferenceFieldType, JSONValueType, JSONObjectType, JSONArrayType, SelectFieldType, LookupFieldType, ArrayFieldType, ObjectFieldType, OptionalFieldType, ExtractFieldTypeType, } from './types/base-fields';
|
|
2
|
+
//# sourceMappingURL=base-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-types.d.ts","sourceRoot":"","sources":["../sdk/base-types.ts"],"names":[],"mappings":"AAKA,YAAY,EAEV,WAAW,EACX,eAAe,EACf,iBAAiB,EAGjB,eAAe,EACf,aAAa,EAGb,gBAAgB,EAGhB,aAAa,EACb,iBAAiB,EAGjB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAGlB,aAAa,EACb,cAAc,EACd,aAAa,EAGb,eAAe,EACf,eAAe,EAGf,cAAc,EACd,eAAe,EACf,iBAAiB,EAGjB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";let o={baseUrl:"",headers:{"Content-Type":"application/json"}};function u(e){o.baseUrl=e}function h(e){o.headers={...o.headers,...e}}function d(){return{...o.headers}}function l(){return o.baseUrl||""}function i(e){if(e==null)return e;if(Array.isArray(e))return e.map(s=>i(s));if(typeof e=="object"){if("$__dt__"in e)return new Date(e.$__dt__*1e3);if("$__d__"in e)return new Date(e.$__d__);const s={};for(const[n,t]of Object.entries(e))s[n]=i(t);return s}return e}function y(e){const s=o.baseUrl,n=o.headers;return{async get(t){const r=await fetch(`${s}/api/app/${e}/${t}/read`,{method:"GET",headers:n});if(!r.ok)throw new Error(`Failed to get ${e} ${t}: ${r.statusText}`);const a=await r.json();return i(a.Data)},async create(t){const r=await fetch(`${s}/api/app/${e}/create`,{method:"POST",headers:n,body:JSON.stringify(t)});if(!r.ok)throw new Error(`Failed to create ${e}: ${r.statusText}`);return r.json()},async update(t,r){const a=await fetch(`${s}/api/app/${e}/${t}/update`,{method:"POST",headers:n,body:JSON.stringify(r)});if(!a.ok)throw new Error(`Failed to update ${e} ${t}: ${a.statusText}`);return a.json()},async delete(t){const r=await fetch(`${s}/api/app/${e}/${t}/delete`,{method:"DELETE",headers:n});if(!r.ok)throw new Error(`Failed to delete ${e} ${t}: ${r.statusText}`);return r.json()},async list(t){const r={Type:"List",...t},a=await fetch(`${s}/api/app/${e}/list`,{method:"POST",headers:n,body:JSON.stringify(r)});if(!a.ok)throw new Error(`Failed to list ${e}: ${a.statusText}`);return{Data:(await a.json()).Data.map(f=>i(f))}},async count(t){var p,$;const r={Type:"Metric",GroupBy:[],Metric:[{Field:"_id",Type:"Count"}],...(t==null?void 0:t.Filter)&&{Filter:t.Filter}},a=await fetch(`${s}/api/app/${e}/metric`,{method:"POST",headers:n,body:JSON.stringify(r)});if(!a.ok)throw new Error(`Failed to count ${e}: ${a.statusText}`);return{Count:(($=(p=(await a.json()).Data)==null?void 0:p[0])==null?void 0:$.count__id)??0}},async draft(t){const r=await fetch(`${s}/api/app/${e}/draft`,{method:"POST",headers:n,body:JSON.stringify(t)});if(!r.ok)throw new Error(`Failed to create draft for ${e}: ${r.statusText}`);return r.json()},async draftUpdate(t,r){const a=await fetch(`${s}/api/app/${e}/${t}/draft`,{method:"POST",headers:n,body:JSON.stringify(r)});if(!a.ok)throw new Error(`Failed to update draft for ${e} ${t}: ${a.statusText}`);return a.json()},async draftPatch(t,r){const a=await fetch(`${s}/api/app/${e}/${t}/draft`,{method:"PATCH",headers:n,body:JSON.stringify(r)});if(!a.ok)throw new Error(`Failed to patch draft for ${e} ${t}: ${a.statusText}`);return a.json()},async draftInteraction(t){const r=await fetch(`${s}/api/app/${e}/draft`,{method:"PATCH",headers:n,body:JSON.stringify(t)});if(!r.ok)throw new Error(`Failed to create interactive draft for ${e}: ${r.statusText}`);return r.json()},async metric(t){const r={Type:"Metric",...t},a=await fetch(`${s}/api/app/${e}/metric`,{method:"POST",headers:n,body:JSON.stringify(r)});if(!a.ok)throw new Error(`Failed to get metrics for ${e}: ${a.statusText}`);return a.json()},async pivot(t){const r={Type:"Pivot",...t},a=await fetch(`${s}/api/app/${e}/pivot`,{method:"POST",headers:n,body:JSON.stringify(r)});if(!a.ok)throw new Error(`Failed to get pivot data for ${e}: ${a.statusText}`);return a.json()},async fields(){const t=await fetch(`${s}/api/app/${e}/fields`,{method:"GET",headers:n});if(!t.ok)throw new Error(`Failed to get fields for ${e}: ${t.statusText}`);return t.json()},async fetchField(t,r){const a=await fetch(`${s}/api/app/${e}/${t}/field/${r}/fetch`,{method:"GET",headers:n});if(!a.ok)throw new Error(`Failed to fetch field ${r} for ${e}: ${a.statusText}`);return(await a.json()).Data}}}exports.api=y;exports.getApiBaseUrl=l;exports.getDefaultHeaders=d;exports.setApiBaseUrl=u;exports.setDefaultHeaders=h;
|