atmx-react 0.43.0 → 0.47.0

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.
@@ -0,0 +1,135 @@
1
+ import * as atmx_web from 'atmx-web';
2
+ import { AxiomError, AtmxConfig } from 'atmx-web';
3
+ export { AtmxConfig, AxiomError, AxiomResponse, clearAuthToken, setAuthToken } from 'atmx-web';
4
+ import * as React$1 from 'react';
5
+ import React__default, { ReactNode } from 'react';
6
+ import * as react_jsx_runtime from 'react/jsx-runtime';
7
+
8
+ interface AxiomQueryDef<T> {
9
+ namespace: string;
10
+ name: string;
11
+ endpointId: number;
12
+ method: string;
13
+ path: string;
14
+ payload?: any;
15
+ decoder: (json: any) => T;
16
+ serializer?: (payload: any) => any;
17
+ args: Record<string, any>;
18
+ isStream?: boolean;
19
+ headers?: Record<string, string>;
20
+ }
21
+ type AxiomStatus = "idle" | "loading" | "success" | "error";
22
+ interface AxiomState<T> {
23
+ status: AxiomStatus;
24
+ data: T | null;
25
+ error: AxiomError | null;
26
+ isFetching: boolean;
27
+ isMutating: boolean;
28
+ source: "cache" | "network" | null;
29
+ }
30
+
31
+ interface AxiomContextState {
32
+ isReady: boolean;
33
+ error: Error | null;
34
+ config: AtmxConfig | null;
35
+ }
36
+ declare const AxiomContext: React__default.Context<AxiomContextState | undefined>;
37
+ interface AxiomProviderProps {
38
+ configUrl?: string;
39
+ config?: AtmxConfig;
40
+ children: ReactNode;
41
+ fallback?: ReactNode;
42
+ }
43
+ declare const AxiomProvider: React__default.FC<AxiomProviderProps>;
44
+
45
+ declare const AxiomDataContext: React$1.Context<AxiomState<any> | null>;
46
+ /**
47
+ * Throwing version: Use this when you absolutely expect to be inside a scope.
48
+ */
49
+ declare function useAxiomContext<T>(): AxiomState<T>;
50
+ /**
51
+ * Safe version: Returns T or an empty object.
52
+ * Used for Context Inheritance ($data access).
53
+ */
54
+ declare function useAxiomData<T>(): T;
55
+
56
+ interface AxQueryProps<T> {
57
+ call: AxiomQueryDef<T>;
58
+ children: ReactNode | ((props: {
59
+ data: T | null;
60
+ state: AxiomState<T>;
61
+ refetch: () => void;
62
+ }) => ReactNode);
63
+ enabled?: boolean;
64
+ }
65
+ declare function AxQuery<T>({ call, children, enabled, }: AxQueryProps<T>): react_jsx_runtime.JSX.Element;
66
+
67
+ interface AxWhenProps {
68
+ /** Explicit state object from a hook (e.g. sdk.users.useGetUser) */
69
+ value?: {
70
+ status: string;
71
+ data?: any;
72
+ isFetching?: boolean;
73
+ isMutating?: boolean;
74
+ };
75
+ /** Comma-separated states: "idle, loading, mutating, data, success, error" */
76
+ is: string;
77
+ children: ReactNode;
78
+ }
79
+ declare function AxWhen({ value, is, children }: AxWhenProps): react_jsx_runtime.JSX.Element | null;
80
+
81
+ interface AxTriggerProps {
82
+ onTrigger: () => void;
83
+ once?: boolean;
84
+ children?: ReactNode;
85
+ }
86
+ declare const AxTrigger: React.FC<AxTriggerProps>;
87
+
88
+ declare const useAxiom: () => AxiomContextState;
89
+
90
+ declare function useAxiomQuery<T>(queryDef: AxiomQueryDef<T>, options?: {
91
+ enabled?: boolean;
92
+ }): {
93
+ data: T | null;
94
+ isLoading: boolean;
95
+ isFetching: boolean;
96
+ source: "cache" | "network" | null;
97
+ error: atmx_web.AxiomError | null;
98
+ state: AxiomState<T>;
99
+ refetch: () => void;
100
+ };
101
+
102
+ declare function useAxiomMutation<T, A>(mutationFn: (args: A) => AxiomQueryDef<T>): {
103
+ execute: (args: A, options?: {
104
+ headers?: Record<string, string>;
105
+ }) => Promise<void>;
106
+ state: AxiomState<T>;
107
+ data: T | null;
108
+ isMutating: boolean;
109
+ error: atmx_web.AxiomError | null;
110
+ getFieldError: (fieldName: string) => string | null;
111
+ };
112
+
113
+ type Listener<T> = (state: AxiomState<T>) => void;
114
+ declare class ActiveQuery<T> {
115
+ queryKey: string;
116
+ def: AxiomQueryDef<T>;
117
+ private state;
118
+ private listeners;
119
+ private currentReqId;
120
+ constructor(queryKey: string, def: AxiomQueryDef<T>);
121
+ getState(): AxiomState<T>;
122
+ subscribe(listener: Listener<T>): () => void;
123
+ private updateState;
124
+ fetch(force?: boolean, debug?: boolean): void;
125
+ }
126
+
127
+ declare class QueryManager {
128
+ private queries;
129
+ private buildKey;
130
+ getQuery<T>(def: AxiomQueryDef<T>): ActiveQuery<T>;
131
+ invalidate(namespace: string, endpointId: number, args: Record<string, any>): void;
132
+ }
133
+ declare const axiomQueryManager: QueryManager;
134
+
135
+ export { AxQuery, AxTrigger, AxWhen, AxiomContext, AxiomDataContext, AxiomProvider, type AxiomQueryDef, type AxiomState, type AxiomStatus, axiomQueryManager, useAxiom, useAxiomContext, useAxiomData, useAxiomMutation, useAxiomQuery };
@@ -0,0 +1,135 @@
1
+ import * as atmx_web from 'atmx-web';
2
+ import { AxiomError, AtmxConfig } from 'atmx-web';
3
+ export { AtmxConfig, AxiomError, AxiomResponse, clearAuthToken, setAuthToken } from 'atmx-web';
4
+ import * as React$1 from 'react';
5
+ import React__default, { ReactNode } from 'react';
6
+ import * as react_jsx_runtime from 'react/jsx-runtime';
7
+
8
+ interface AxiomQueryDef<T> {
9
+ namespace: string;
10
+ name: string;
11
+ endpointId: number;
12
+ method: string;
13
+ path: string;
14
+ payload?: any;
15
+ decoder: (json: any) => T;
16
+ serializer?: (payload: any) => any;
17
+ args: Record<string, any>;
18
+ isStream?: boolean;
19
+ headers?: Record<string, string>;
20
+ }
21
+ type AxiomStatus = "idle" | "loading" | "success" | "error";
22
+ interface AxiomState<T> {
23
+ status: AxiomStatus;
24
+ data: T | null;
25
+ error: AxiomError | null;
26
+ isFetching: boolean;
27
+ isMutating: boolean;
28
+ source: "cache" | "network" | null;
29
+ }
30
+
31
+ interface AxiomContextState {
32
+ isReady: boolean;
33
+ error: Error | null;
34
+ config: AtmxConfig | null;
35
+ }
36
+ declare const AxiomContext: React__default.Context<AxiomContextState | undefined>;
37
+ interface AxiomProviderProps {
38
+ configUrl?: string;
39
+ config?: AtmxConfig;
40
+ children: ReactNode;
41
+ fallback?: ReactNode;
42
+ }
43
+ declare const AxiomProvider: React__default.FC<AxiomProviderProps>;
44
+
45
+ declare const AxiomDataContext: React$1.Context<AxiomState<any> | null>;
46
+ /**
47
+ * Throwing version: Use this when you absolutely expect to be inside a scope.
48
+ */
49
+ declare function useAxiomContext<T>(): AxiomState<T>;
50
+ /**
51
+ * Safe version: Returns T or an empty object.
52
+ * Used for Context Inheritance ($data access).
53
+ */
54
+ declare function useAxiomData<T>(): T;
55
+
56
+ interface AxQueryProps<T> {
57
+ call: AxiomQueryDef<T>;
58
+ children: ReactNode | ((props: {
59
+ data: T | null;
60
+ state: AxiomState<T>;
61
+ refetch: () => void;
62
+ }) => ReactNode);
63
+ enabled?: boolean;
64
+ }
65
+ declare function AxQuery<T>({ call, children, enabled, }: AxQueryProps<T>): react_jsx_runtime.JSX.Element;
66
+
67
+ interface AxWhenProps {
68
+ /** Explicit state object from a hook (e.g. sdk.users.useGetUser) */
69
+ value?: {
70
+ status: string;
71
+ data?: any;
72
+ isFetching?: boolean;
73
+ isMutating?: boolean;
74
+ };
75
+ /** Comma-separated states: "idle, loading, mutating, data, success, error" */
76
+ is: string;
77
+ children: ReactNode;
78
+ }
79
+ declare function AxWhen({ value, is, children }: AxWhenProps): react_jsx_runtime.JSX.Element | null;
80
+
81
+ interface AxTriggerProps {
82
+ onTrigger: () => void;
83
+ once?: boolean;
84
+ children?: ReactNode;
85
+ }
86
+ declare const AxTrigger: React.FC<AxTriggerProps>;
87
+
88
+ declare const useAxiom: () => AxiomContextState;
89
+
90
+ declare function useAxiomQuery<T>(queryDef: AxiomQueryDef<T>, options?: {
91
+ enabled?: boolean;
92
+ }): {
93
+ data: T | null;
94
+ isLoading: boolean;
95
+ isFetching: boolean;
96
+ source: "cache" | "network" | null;
97
+ error: atmx_web.AxiomError | null;
98
+ state: AxiomState<T>;
99
+ refetch: () => void;
100
+ };
101
+
102
+ declare function useAxiomMutation<T, A>(mutationFn: (args: A) => AxiomQueryDef<T>): {
103
+ execute: (args: A, options?: {
104
+ headers?: Record<string, string>;
105
+ }) => Promise<void>;
106
+ state: AxiomState<T>;
107
+ data: T | null;
108
+ isMutating: boolean;
109
+ error: atmx_web.AxiomError | null;
110
+ getFieldError: (fieldName: string) => string | null;
111
+ };
112
+
113
+ type Listener<T> = (state: AxiomState<T>) => void;
114
+ declare class ActiveQuery<T> {
115
+ queryKey: string;
116
+ def: AxiomQueryDef<T>;
117
+ private state;
118
+ private listeners;
119
+ private currentReqId;
120
+ constructor(queryKey: string, def: AxiomQueryDef<T>);
121
+ getState(): AxiomState<T>;
122
+ subscribe(listener: Listener<T>): () => void;
123
+ private updateState;
124
+ fetch(force?: boolean, debug?: boolean): void;
125
+ }
126
+
127
+ declare class QueryManager {
128
+ private queries;
129
+ private buildKey;
130
+ getQuery<T>(def: AxiomQueryDef<T>): ActiveQuery<T>;
131
+ invalidate(namespace: string, endpointId: number, args: Record<string, any>): void;
132
+ }
133
+ declare const axiomQueryManager: QueryManager;
134
+
135
+ export { AxQuery, AxTrigger, AxWhen, AxiomContext, AxiomDataContext, AxiomProvider, type AxiomQueryDef, type AxiomState, type AxiomStatus, axiomQueryManager, useAxiom, useAxiomContext, useAxiomData, useAxiomMutation, useAxiomQuery };