@axsdk/core 0.1.1

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 ADDED
@@ -0,0 +1 @@
1
+ # axsdk-core
@@ -0,0 +1,58 @@
1
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
2
+ export interface ApiRequestOptions {
3
+ headers?: Record<string, string>;
4
+ params?: Record<string, string | number | boolean>;
5
+ signal?: AbortSignal;
6
+ timeout?: number;
7
+ }
8
+ export declare class ApiError extends Error {
9
+ readonly status: number;
10
+ readonly statusText: string;
11
+ readonly response?: unknown;
12
+ constructor(message: string, status: number, statusText: string, response?: unknown);
13
+ isClientError(): boolean;
14
+ isServerError(): boolean;
15
+ isNetworkError(): boolean;
16
+ }
17
+ export type RequestInterceptor = (url: string, options: RequestInit) => RequestInit | Promise<RequestInit>;
18
+ export type ResponseInterceptor = (response: Response, data: unknown) => unknown | Promise<unknown>;
19
+ export type ErrorInterceptor = (error: ApiError) => ApiError | Promise<ApiError>;
20
+ export interface ApiClientConfig {
21
+ baseURL?: string;
22
+ basePath?: string;
23
+ defaultHeaders?: Record<string, string>;
24
+ timeout?: number;
25
+ requestInterceptors?: RequestInterceptor[];
26
+ responseInterceptors?: ResponseInterceptor[];
27
+ errorInterceptors?: ErrorInterceptor[];
28
+ }
29
+ export declare class ApiClient {
30
+ private baseURL;
31
+ private basePath;
32
+ private defaultHeaders;
33
+ private timeout;
34
+ private requestInterceptors;
35
+ private responseInterceptors;
36
+ private errorInterceptors;
37
+ constructor(config?: ApiClientConfig);
38
+ private buildUrl;
39
+ private buildHeaders;
40
+ private applyRequestInterceptors;
41
+ private applyResponseInterceptors;
42
+ private applyErrorInterceptors;
43
+ private createAbortController;
44
+ private handleResponse;
45
+ private request;
46
+ get<T>(endpoint: string, options?: ApiRequestOptions): Promise<T>;
47
+ post<T>(endpoint: string, body?: unknown, options?: ApiRequestOptions): Promise<T>;
48
+ put<T>(endpoint: string, body?: unknown, options?: ApiRequestOptions): Promise<T>;
49
+ patch<T>(endpoint: string, body?: unknown, options?: ApiRequestOptions): Promise<T>;
50
+ delete<T>(endpoint: string, options?: ApiRequestOptions): Promise<T>;
51
+ setHeader(key: string, value: string): void;
52
+ removeHeader(key: string): void;
53
+ setAuthToken(token: string, type?: 'Bearer' | 'Basic'): void;
54
+ clearAuthToken(): void;
55
+ addRequestInterceptor(interceptor: RequestInterceptor): void;
56
+ addResponseInterceptor(interceptor: ResponseInterceptor): void;
57
+ addErrorInterceptor(interceptor: ErrorInterceptor): void;
58
+ }
@@ -0,0 +1,9 @@
1
+ import { ApiClient, type RequestInterceptor } from "./apiclient";
2
+ export declare const api: ApiClient;
3
+ export declare function init(ri: RequestInterceptor): void;
4
+ export declare function health(): Promise<unknown>;
5
+ export declare function createSession(): Promise<unknown>;
6
+ export declare function getMessages(): Promise<unknown>;
7
+ export declare function postMessage(text: string, images: string[]): Promise<unknown>;
8
+ export declare function getPendingCalls(): Promise<unknown>;
9
+ export declare function updateCall(callID: string, status: string, result: string): Promise<unknown>;
@@ -0,0 +1,3 @@
1
+ export declare function handleAXSDKCall(properties: unknown): Promise<void>;
2
+ export declare function start(): Promise<void>;
3
+ export declare function stop(): Promise<void>;
@@ -0,0 +1,2 @@
1
+ export declare function start(): Promise<void>;
2
+ export declare function stop(): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function processAXHandler(command: string, args: Record<string, unknown>): Promise<string>;
@@ -0,0 +1,25 @@
1
+ import EventEmitter from "eventemitter3";
2
+ import { type StoreApi } from 'zustand/vanilla';
3
+ import type { AXSDKConfig, AXHandler } from "./types";
4
+ export type * from "./types";
5
+ import { type AppState, type ChatState } from "./store";
6
+ declare class AxSdk extends EventEmitter {
7
+ config: AXSDKConfig | undefined;
8
+ constructor();
9
+ init(config: AXSDKConfig): Promise<void>;
10
+ destroy(): Promise<void>;
11
+ axHandler(): AXHandler | undefined;
12
+ eventBus(): EventEmitter<string | symbol, any>;
13
+ headers(): Record<string, string> | undefined;
14
+ getAppStore(): StoreApi<AppState>;
15
+ setAppAuthToken(appAuthToken: string | undefined): void;
16
+ getLanguage(): string;
17
+ t(id: string): string;
18
+ getChatStore(): StoreApi<ChatState>;
19
+ getChatState(): ChatState;
20
+ resetSession(): void;
21
+ sendMessage(text: string): void;
22
+ private requestInterceptor;
23
+ }
24
+ export declare const AXSDK: AxSdk;
25
+ export default AXSDK;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Options for screenshot capture functions.
3
+ */
4
+ export interface ScreenshotOptions {
5
+ /** The DOM element to capture. Defaults to `document.documentElement`. */
6
+ element?: HTMLElement;
7
+ /** MIME type for the output image. Defaults to `'image/png'`. */
8
+ type?: 'image/png' | 'image/jpeg' | 'image/webp';
9
+ /** Image quality (0–1) for lossy formats like jpeg/webp. Defaults to `0.92`. */
10
+ quality?: number;
11
+ /** Device pixel ratio scale factor. Defaults to `window.devicePixelRatio` or `1`. */
12
+ scale?: number;
13
+ }
14
+ /**
15
+ * Captures the current browser viewport (or a specified element) as a
16
+ * base64-encoded data URL string.
17
+ *
18
+ * @param options - Optional screenshot configuration.
19
+ * @returns A `Promise<string>` that resolves to a base64 data URL (e.g. `data:image/png;base64,...`).
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * const dataUrl = await captureScreenshot();
24
+ * // dataUrl === 'data:image/png;base64,...'
25
+ * ```
26
+ */
27
+ export declare function captureScreenshot(options?: ScreenshotOptions): Promise<string>;
28
+ /**
29
+ * Captures the current browser viewport (or a specified element) as a `Blob`.
30
+ *
31
+ * @param options - Optional screenshot configuration.
32
+ * @returns A `Promise<Blob>` containing the image data.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * const blob = await captureScreenshotBlob({ type: 'image/jpeg', quality: 0.8 });
37
+ * const url = URL.createObjectURL(blob);
38
+ * ```
39
+ */
40
+ export declare function captureScreenshotBlob(options?: ScreenshotOptions): Promise<Blob>;
@@ -0,0 +1,6 @@
1
+ export declare function updateFromMessages(payload: unknown): Promise<void>;
2
+ export declare function updateFromSessionStatus(payload: unknown): Promise<string | undefined>;
3
+ export declare function updateFromSessionUpdate(payload: unknown): Promise<void>;
4
+ export declare function updateFromMessageUpdate(payload: unknown): Promise<void>;
5
+ export declare function updateFromMessagePartUpdate(payload: unknown): Promise<void>;
6
+ export declare function updateFromMessagePartDelta(payload: unknown): Promise<void>;
@@ -0,0 +1,3 @@
1
+ export declare const Config: {
2
+ baseURL: string;
3
+ };
@@ -0,0 +1,2 @@
1
+ import EventEmitter from "eventemitter3";
2
+ export declare const EventBus: EventEmitter<string | symbol, any>;
@@ -0,0 +1 @@
1
+ export * from './axtools';