@qwanyx/stack 0.2.2 → 0.2.3
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/dist/api/client.d.ts +53 -0
- package/dist/auth/index.d.ts +34 -0
- package/dist/client/GraphClient.d.ts +86 -0
- package/dist/client/MailClient.d.ts +69 -0
- package/dist/components/AnimatedCardFlip.d.ts +19 -0
- package/dist/components/Card.d.ts +13 -0
- package/dist/components/Detail.d.ts +15 -0
- package/dist/components/Mail.d.ts +51 -0
- package/dist/components/Stack.d.ts +38 -0
- package/dist/hooks/useMutation.d.ts +16 -0
- package/dist/hooks/useQuery.d.ts +18 -0
- package/dist/index.d.ts +28 -0
- package/dist/operations/index.d.ts +51 -0
- package/dist/types/index.d.ts +225 -0
- package/package.json +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ApiConfig, QueryParams } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Generic API Client
|
|
4
|
+
* Framework-agnostic HTTP client for any API
|
|
5
|
+
*/
|
|
6
|
+
export declare class ApiClient {
|
|
7
|
+
private config;
|
|
8
|
+
constructor(config: ApiConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Build query string from params
|
|
11
|
+
*/
|
|
12
|
+
private buildQueryString;
|
|
13
|
+
/**
|
|
14
|
+
* Make HTTP request
|
|
15
|
+
*/
|
|
16
|
+
private request;
|
|
17
|
+
/**
|
|
18
|
+
* GET request
|
|
19
|
+
*/
|
|
20
|
+
get<T = any>(endpoint: string, params?: QueryParams): Promise<T>;
|
|
21
|
+
/**
|
|
22
|
+
* POST request
|
|
23
|
+
*/
|
|
24
|
+
post<T = any>(endpoint: string, body?: any, params?: QueryParams): Promise<T>;
|
|
25
|
+
/**
|
|
26
|
+
* PUT request
|
|
27
|
+
*/
|
|
28
|
+
put<T = any>(endpoint: string, body?: any, params?: QueryParams): Promise<T>;
|
|
29
|
+
/**
|
|
30
|
+
* PATCH request
|
|
31
|
+
*/
|
|
32
|
+
patch<T = any>(endpoint: string, body?: any, params?: QueryParams): Promise<T>;
|
|
33
|
+
/**
|
|
34
|
+
* DELETE request
|
|
35
|
+
*/
|
|
36
|
+
delete<T = any>(endpoint: string, params?: QueryParams): Promise<T>;
|
|
37
|
+
/**
|
|
38
|
+
* Update base URL
|
|
39
|
+
*/
|
|
40
|
+
setBaseUrl(baseUrl: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Get current base URL
|
|
43
|
+
*/
|
|
44
|
+
getBaseUrl(): string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Initialize the API client
|
|
48
|
+
*/
|
|
49
|
+
export declare function initializeApiClient(config: ApiConfig): ApiClient;
|
|
50
|
+
/**
|
|
51
|
+
* Get the API client instance
|
|
52
|
+
*/
|
|
53
|
+
export declare function getApiClient(): ApiClient;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic authentication manager
|
|
3
|
+
* Handles token storage and retrieval
|
|
4
|
+
*/
|
|
5
|
+
export declare class AuthManager {
|
|
6
|
+
/**
|
|
7
|
+
* Store authentication token
|
|
8
|
+
*/
|
|
9
|
+
static setToken(token: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* Get authentication token
|
|
12
|
+
*/
|
|
13
|
+
static getToken(): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Remove authentication token
|
|
16
|
+
*/
|
|
17
|
+
static clearToken(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Store refresh token
|
|
20
|
+
*/
|
|
21
|
+
static setRefreshToken(token: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Get refresh token
|
|
24
|
+
*/
|
|
25
|
+
static getRefreshToken(): string | null;
|
|
26
|
+
/**
|
|
27
|
+
* Check if user is authenticated
|
|
28
|
+
*/
|
|
29
|
+
static isAuthenticated(): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Get authorization header
|
|
32
|
+
*/
|
|
33
|
+
static getAuthHeader(): Record<string, string>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GraphClient - Backend Communication Layer
|
|
3
|
+
*
|
|
4
|
+
* Provides a type-safe interface to the qwanyx-brain SPU backend.
|
|
5
|
+
* All operations communicate through the unified `/spu/invoke` endpoint.
|
|
6
|
+
*/
|
|
7
|
+
import type { GraphNode, GraphEdge, GraphClientConfig } from '../types';
|
|
8
|
+
export declare class GraphClient {
|
|
9
|
+
private config;
|
|
10
|
+
constructor(config: GraphClientConfig);
|
|
11
|
+
/**
|
|
12
|
+
* Call the Graph coprocessor
|
|
13
|
+
*/
|
|
14
|
+
private callGraph;
|
|
15
|
+
/**
|
|
16
|
+
* Get auth token from localStorage (browser) or return empty string
|
|
17
|
+
*/
|
|
18
|
+
private getToken;
|
|
19
|
+
/**
|
|
20
|
+
* Get children nodes
|
|
21
|
+
*/
|
|
22
|
+
getChildren(parentId?: string): Promise<GraphNode[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Get a specific node by ID
|
|
25
|
+
*/
|
|
26
|
+
getNode(nodeId: string): Promise<GraphNode | null>;
|
|
27
|
+
/**
|
|
28
|
+
* Add a new node
|
|
29
|
+
*/
|
|
30
|
+
addNode(node: Partial<GraphNode> & {
|
|
31
|
+
p?: string;
|
|
32
|
+
type: string;
|
|
33
|
+
}): Promise<GraphNode>;
|
|
34
|
+
/**
|
|
35
|
+
* Update an existing node
|
|
36
|
+
*/
|
|
37
|
+
updateNode(nodeId: string, updates: Partial<GraphNode>): Promise<GraphNode>;
|
|
38
|
+
/**
|
|
39
|
+
* Delete a node
|
|
40
|
+
*/
|
|
41
|
+
deleteNode(nodeId: string, cascade?: boolean): Promise<boolean>;
|
|
42
|
+
/**
|
|
43
|
+
* Get children with edges (supports different display modes)
|
|
44
|
+
*/
|
|
45
|
+
getChildrenWithEdges(nodeId?: string, displayMode?: 'children' | 'edges' | 'both', edgeType?: string, nodeType?: string): Promise<GraphNode[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Add an edge between two nodes
|
|
48
|
+
*/
|
|
49
|
+
addEdge(sourceId: string | null, targetId: string, edgeType?: string, data?: Record<string, any>): Promise<{
|
|
50
|
+
success: boolean;
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* Delete an edge
|
|
54
|
+
*/
|
|
55
|
+
deleteEdge(sourceId: string | null, targetId: string, edgeType?: string): Promise<{
|
|
56
|
+
deleted: boolean;
|
|
57
|
+
count: number;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Get edges from a source node
|
|
61
|
+
* @param sourceId - Source node ID (null for edges without source)
|
|
62
|
+
* @param edgeType - Optional edge type filter
|
|
63
|
+
* @param targetId - Optional target node ID for reverse lookups
|
|
64
|
+
*/
|
|
65
|
+
getEdges(sourceId: string | null, edgeType?: string, targetId?: string): Promise<GraphEdge[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Get ancestors of a node (path from root to node)
|
|
68
|
+
*/
|
|
69
|
+
getAncestors(nodeId: string): Promise<GraphNode[]>;
|
|
70
|
+
/**
|
|
71
|
+
* Get tree structure starting from a root
|
|
72
|
+
*/
|
|
73
|
+
getTree(rootId?: string, maxDepth?: number): Promise<any>;
|
|
74
|
+
/**
|
|
75
|
+
* Move a node to a new parent
|
|
76
|
+
*/
|
|
77
|
+
moveNode(nodeId: string, newParentId?: string): Promise<GraphNode>;
|
|
78
|
+
/**
|
|
79
|
+
* Search nodes by query
|
|
80
|
+
*/
|
|
81
|
+
searchNodes(query: string, type?: string): Promise<GraphNode[]>;
|
|
82
|
+
/**
|
|
83
|
+
* Get all nodes of a specific type
|
|
84
|
+
*/
|
|
85
|
+
getNodesByType(type: string): Promise<GraphNode[]>;
|
|
86
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MailClient - Email Communication Layer
|
|
3
|
+
*
|
|
4
|
+
* Provides a type-safe interface to the mail coprocessor in qwanyx-brain.
|
|
5
|
+
* Handles email settings (with encrypted passwords) and IMAP operations.
|
|
6
|
+
*/
|
|
7
|
+
import type { MailClientConfig, MailAccount, MailListResult, ImapResponse, FolderInfo } from '../types';
|
|
8
|
+
export declare class MailClient {
|
|
9
|
+
private config;
|
|
10
|
+
constructor(config: MailClientConfig);
|
|
11
|
+
/**
|
|
12
|
+
* Call the Mail coprocessor
|
|
13
|
+
*/
|
|
14
|
+
private callMail;
|
|
15
|
+
/**
|
|
16
|
+
* Get auth token from localStorage (browser) or return empty string
|
|
17
|
+
*/
|
|
18
|
+
private getToken;
|
|
19
|
+
/**
|
|
20
|
+
* Get email settings with decrypted passwords
|
|
21
|
+
*/
|
|
22
|
+
getSettings(): Promise<{
|
|
23
|
+
accounts: MailAccount[];
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Save email settings (passwords encrypted server-side)
|
|
27
|
+
*/
|
|
28
|
+
saveSettings(accounts: MailAccount[]): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* List emails from IMAP inbox
|
|
31
|
+
*/
|
|
32
|
+
listEmails(accountId?: string, limit?: number): Promise<MailListResult>;
|
|
33
|
+
/**
|
|
34
|
+
* Delete emails by UID
|
|
35
|
+
*/
|
|
36
|
+
deleteEmails(accountId: string, uids: number[], expunge?: boolean): Promise<{
|
|
37
|
+
success: boolean;
|
|
38
|
+
deleted: number;
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Execute raw IMAP commands - thin proxy for stack-side logic
|
|
42
|
+
* Commands are strings like: "SELECT INBOX", "UID STORE 123 +FLAGS (\\Deleted)", "EXPUNGE"
|
|
43
|
+
*/
|
|
44
|
+
imapExec(accountId: string, commands: string[]): Promise<{
|
|
45
|
+
success: boolean;
|
|
46
|
+
responses: ImapResponse[];
|
|
47
|
+
}>;
|
|
48
|
+
/**
|
|
49
|
+
* Move emails to trash (soft delete)
|
|
50
|
+
*/
|
|
51
|
+
trashEmails(accountId: string, uids: number[]): Promise<{
|
|
52
|
+
success: boolean;
|
|
53
|
+
moved: number;
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* Archive emails (remove from inbox, keep in All Mail)
|
|
57
|
+
*/
|
|
58
|
+
archiveEmails(accountId: string, uids: number[]): Promise<{
|
|
59
|
+
success: boolean;
|
|
60
|
+
archived: number;
|
|
61
|
+
}>;
|
|
62
|
+
/**
|
|
63
|
+
* List available folders
|
|
64
|
+
*/
|
|
65
|
+
listFolders(accountId: string): Promise<{
|
|
66
|
+
success: boolean;
|
|
67
|
+
folders: FolderInfo[];
|
|
68
|
+
}>;
|
|
69
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface AnimatedCardFlipNode {
|
|
2
|
+
_id: string;
|
|
3
|
+
type: string;
|
|
4
|
+
title: string;
|
|
5
|
+
data: {
|
|
6
|
+
name: string;
|
|
7
|
+
image: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface AnimatedCardFlipProps {
|
|
11
|
+
nodes: AnimatedCardFlipNode[];
|
|
12
|
+
cardCount?: number;
|
|
13
|
+
minInterval?: number;
|
|
14
|
+
maxInterval?: number;
|
|
15
|
+
onCardClick?: (node: AnimatedCardFlipNode) => void;
|
|
16
|
+
cardSize?: 'small' | 'medium' | 'large';
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function AnimatedCardFlip({ nodes, cardCount, minInterval, maxInterval, onCardClick, cardSize, className }: AnimatedCardFlipProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Card Component for Stack list items
|
|
3
|
+
* Generic design that works with any data type
|
|
4
|
+
*/
|
|
5
|
+
export interface CardProps<T = any> {
|
|
6
|
+
item: T;
|
|
7
|
+
onClick?: () => void;
|
|
8
|
+
title?: (item: T) => string;
|
|
9
|
+
subtitle?: (item: T) => string;
|
|
10
|
+
image?: (item: T) => string | undefined;
|
|
11
|
+
badge?: (item: T) => string | undefined;
|
|
12
|
+
}
|
|
13
|
+
export declare function Card<T = any>({ item, onClick, title, subtitle, image, badge, }: CardProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Detail View Component
|
|
3
|
+
* Generic detail view for any item
|
|
4
|
+
*/
|
|
5
|
+
export interface DetailProps<T = any> {
|
|
6
|
+
item: T | null;
|
|
7
|
+
onClose?: () => void;
|
|
8
|
+
title?: (item: T) => string;
|
|
9
|
+
image?: (item: T) => string | undefined;
|
|
10
|
+
fields?: Array<{
|
|
11
|
+
label: string;
|
|
12
|
+
value: (item: T) => any;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
export declare function Detail<T = any>({ item, onClose, title, image, fields, }: DetailProps<T>): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mail Component
|
|
3
|
+
* Smart email list with selection, actions, and detail view
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
export interface EmailMessage {
|
|
7
|
+
uid: number;
|
|
8
|
+
subject: string;
|
|
9
|
+
from: string;
|
|
10
|
+
date: string;
|
|
11
|
+
seen: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface MailProps {
|
|
14
|
+
baseUrl: string;
|
|
15
|
+
systemId: string;
|
|
16
|
+
accountId: string;
|
|
17
|
+
limit?: number;
|
|
18
|
+
selectable?: boolean;
|
|
19
|
+
showDetail?: boolean;
|
|
20
|
+
emptyMessage?: string;
|
|
21
|
+
autoLoad?: boolean;
|
|
22
|
+
onSelect?: (email: EmailMessage) => void;
|
|
23
|
+
onSelectionChange?: (uids: number[]) => void;
|
|
24
|
+
onDelete?: (uids: number[]) => void;
|
|
25
|
+
onError?: (error: Error) => void;
|
|
26
|
+
renderItem?: (email: EmailMessage, selected: boolean) => React.ReactNode;
|
|
27
|
+
renderDetail?: (email: EmailMessage) => React.ReactNode;
|
|
28
|
+
renderActions?: (selectedUids: number[], actions: MailActions) => React.ReactNode;
|
|
29
|
+
renderEmpty?: () => React.ReactNode;
|
|
30
|
+
renderLoading?: () => React.ReactNode;
|
|
31
|
+
theme?: MailTheme;
|
|
32
|
+
}
|
|
33
|
+
export interface MailTheme {
|
|
34
|
+
background?: string;
|
|
35
|
+
cardBackground?: string;
|
|
36
|
+
selectedBackground?: string;
|
|
37
|
+
unreadBackground?: string;
|
|
38
|
+
text?: string;
|
|
39
|
+
textSecondary?: string;
|
|
40
|
+
border?: string;
|
|
41
|
+
primary?: string;
|
|
42
|
+
danger?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface MailActions {
|
|
45
|
+
delete: () => Promise<void>;
|
|
46
|
+
archive: () => Promise<void>;
|
|
47
|
+
refresh: () => Promise<void>;
|
|
48
|
+
selectAll: () => void;
|
|
49
|
+
clearSelection: () => void;
|
|
50
|
+
}
|
|
51
|
+
export declare function Mail({ baseUrl, systemId, accountId, limit, selectable, showDetail, emptyMessage, autoLoad, onSelect, onSelectionChange, onDelete, onError, renderItem, renderDetail, renderActions, renderEmpty, renderLoading, theme: themeProp, }: MailProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stack Component
|
|
3
|
+
* Apple/Superhuman inspired clean design
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import type { QueryParams } from '../types';
|
|
7
|
+
export interface StackProps<T = any> {
|
|
8
|
+
endpoint: string;
|
|
9
|
+
params?: QueryParams;
|
|
10
|
+
layout?: 'list' | 'grid' | 'masonry';
|
|
11
|
+
title?: string;
|
|
12
|
+
emptyMessage?: string;
|
|
13
|
+
renderItem?: (item: T, index: number) => React.ReactNode;
|
|
14
|
+
keyExtractor?: (item: T, index: number) => string;
|
|
15
|
+
searchable?: boolean;
|
|
16
|
+
searchFields?: (keyof T)[];
|
|
17
|
+
searchPlaceholder?: string;
|
|
18
|
+
filters?: Array<{
|
|
19
|
+
field: keyof T;
|
|
20
|
+
label: string;
|
|
21
|
+
options?: Array<{
|
|
22
|
+
value: any;
|
|
23
|
+
label: string;
|
|
24
|
+
}>;
|
|
25
|
+
}>;
|
|
26
|
+
pageSize?: number;
|
|
27
|
+
onItemClick?: (item: T) => void;
|
|
28
|
+
onRefresh?: () => void;
|
|
29
|
+
theme?: {
|
|
30
|
+
background?: string;
|
|
31
|
+
cardBackground?: string;
|
|
32
|
+
text?: string;
|
|
33
|
+
textSecondary?: string;
|
|
34
|
+
border?: string;
|
|
35
|
+
primary?: string;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export declare function Stack<T = any>({ endpoint, params, layout, title, emptyMessage, renderItem, keyExtractor, searchable, searchFields, searchPlaceholder, filters, pageSize, onItemClick, onRefresh, theme, }: StackProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HttpMethod } from '../types';
|
|
2
|
+
export interface UseMutationOptions<TData, TVariables> {
|
|
3
|
+
onSuccess?: (data: TData, variables: TVariables) => void;
|
|
4
|
+
onError?: (error: Error, variables: TVariables) => void;
|
|
5
|
+
}
|
|
6
|
+
export interface UseMutationResult<TData, TVariables> {
|
|
7
|
+
data: TData | null;
|
|
8
|
+
loading: boolean;
|
|
9
|
+
error: Error | null;
|
|
10
|
+
mutate: (variables: TVariables) => Promise<TData | null>;
|
|
11
|
+
reset: () => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Generic hook for mutations (POST, PUT, PATCH, DELETE)
|
|
15
|
+
*/
|
|
16
|
+
export declare function useMutation<TData = any, TVariables = any>(endpoint: string, method?: HttpMethod, options?: UseMutationOptions<TData, TVariables>): UseMutationResult<TData, TVariables>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { QueryParams } from '../types';
|
|
2
|
+
export interface UseQueryOptions<T> {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
refetchOnMount?: boolean;
|
|
5
|
+
onSuccess?: (data: T) => void;
|
|
6
|
+
onError?: (error: Error) => void;
|
|
7
|
+
}
|
|
8
|
+
export interface UseQueryResult<T> {
|
|
9
|
+
data: T | null;
|
|
10
|
+
loading: boolean;
|
|
11
|
+
error: Error | null;
|
|
12
|
+
refetch: () => Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Generic hook for fetching data
|
|
16
|
+
* Similar to React Query but simpler
|
|
17
|
+
*/
|
|
18
|
+
export declare function useQuery<T = any>(endpoint: string, params?: QueryParams, options?: UseQueryOptions<T>): UseQueryResult<T>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @qwanyx/stack
|
|
3
|
+
*
|
|
4
|
+
* All-in-one data management system for React applications
|
|
5
|
+
* Combines Graph API + REST API + UI components
|
|
6
|
+
*
|
|
7
|
+
* Like HyperCard, but with React instead of HyperTalk
|
|
8
|
+
*/
|
|
9
|
+
export { GraphClient } from './client/GraphClient';
|
|
10
|
+
export { MailClient } from './client/MailClient';
|
|
11
|
+
export { ApiClient, initializeApiClient, getApiClient } from './api/client';
|
|
12
|
+
export { AuthManager } from './auth';
|
|
13
|
+
export { useQuery } from './hooks/useQuery';
|
|
14
|
+
export type { UseQueryOptions, UseQueryResult } from './hooks/useQuery';
|
|
15
|
+
export { useMutation } from './hooks/useMutation';
|
|
16
|
+
export type { UseMutationOptions, UseMutationResult } from './hooks/useMutation';
|
|
17
|
+
export type { GraphNode, GraphEdge, GraphClientConfig, StackItem, StackConfig, StackContainerProps, StackContext, ViewContext, CardRenderer, ViewRenderer, Editor, EditorProps, StackTheme, LayoutMode, ApiConfig, ApiResponse, PaginationParams, SortParams, FilterParams, QueryParams, PaginatedResponse, HttpMethod, RequestOptions, MailClientConfig, MailServer, MailAccount, EmailMessage, MailListResult, ImapResponse, FolderInfo, APIResponse, } from './types';
|
|
18
|
+
export { Stack } from './components/Stack';
|
|
19
|
+
export type { StackProps } from './components/Stack';
|
|
20
|
+
export { Card } from './components/Card';
|
|
21
|
+
export type { CardProps } from './components/Card';
|
|
22
|
+
export { Detail } from './components/Detail';
|
|
23
|
+
export type { DetailProps } from './components/Detail';
|
|
24
|
+
export { AnimatedCardFlip } from './components/AnimatedCardFlip';
|
|
25
|
+
export type { AnimatedCardFlipProps, AnimatedCardFlipNode } from './components/AnimatedCardFlip';
|
|
26
|
+
export { Mail } from './components/Mail';
|
|
27
|
+
export type { MailProps, MailTheme, MailActions } from './components/Mail';
|
|
28
|
+
export { DataOperations } from './operations';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operations Layer
|
|
3
|
+
* Client-side data manipulation utilities
|
|
4
|
+
*/
|
|
5
|
+
export declare class DataOperations {
|
|
6
|
+
/**
|
|
7
|
+
* Filter array by predicate function
|
|
8
|
+
*/
|
|
9
|
+
static filter<T>(items: T[], predicate: (item: T) => boolean): T[];
|
|
10
|
+
/**
|
|
11
|
+
* Filter by field value
|
|
12
|
+
*/
|
|
13
|
+
static filterBy<T>(items: T[], field: keyof T, value: any): T[];
|
|
14
|
+
/**
|
|
15
|
+
* Filter by multiple fields
|
|
16
|
+
*/
|
|
17
|
+
static filterByFields<T>(items: T[], filters: Partial<T>): T[];
|
|
18
|
+
/**
|
|
19
|
+
* Sort array by field
|
|
20
|
+
*/
|
|
21
|
+
static sort<T>(items: T[], field: keyof T, order?: 'asc' | 'desc'): T[];
|
|
22
|
+
/**
|
|
23
|
+
* Search items by query string in specified fields
|
|
24
|
+
*/
|
|
25
|
+
static search<T>(items: T[], query: string, fields: (keyof T)[]): T[];
|
|
26
|
+
/**
|
|
27
|
+
* Paginate array
|
|
28
|
+
*/
|
|
29
|
+
static paginate<T>(items: T[], page: number, limit: number): {
|
|
30
|
+
data: T[];
|
|
31
|
+
total: number;
|
|
32
|
+
page: number;
|
|
33
|
+
totalPages: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Group items by field value
|
|
37
|
+
*/
|
|
38
|
+
static groupBy<T>(items: T[], field: keyof T): Record<string, T[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Get unique values for a field
|
|
41
|
+
*/
|
|
42
|
+
static unique<T>(items: T[], field: keyof T): any[];
|
|
43
|
+
/**
|
|
44
|
+
* Count items by field value
|
|
45
|
+
*/
|
|
46
|
+
static countBy<T>(items: T[], field: keyof T): Record<string, number>;
|
|
47
|
+
/**
|
|
48
|
+
* Apply multiple operations in sequence
|
|
49
|
+
*/
|
|
50
|
+
static pipe<T>(items: T[], operations: Array<(items: T[]) => T[]>): T[];
|
|
51
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript type definitions for Qwanyx Stack
|
|
3
|
+
*/
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
export interface GraphNode {
|
|
6
|
+
_id: string;
|
|
7
|
+
p?: string | null;
|
|
8
|
+
type: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
icon?: string;
|
|
12
|
+
editor?: string;
|
|
13
|
+
hidden?: boolean;
|
|
14
|
+
archive?: boolean;
|
|
15
|
+
data?: Record<string, any>;
|
|
16
|
+
created?: string;
|
|
17
|
+
modified?: string;
|
|
18
|
+
creator?: string;
|
|
19
|
+
owner?: string;
|
|
20
|
+
owner_group?: string | null;
|
|
21
|
+
permissions?: number;
|
|
22
|
+
acl?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface GraphEdge {
|
|
25
|
+
source_id: string | null;
|
|
26
|
+
target_id: string;
|
|
27
|
+
edge_type: string;
|
|
28
|
+
data?: Record<string, any>;
|
|
29
|
+
created: number;
|
|
30
|
+
modified?: number;
|
|
31
|
+
}
|
|
32
|
+
export type StackItem = GraphNode;
|
|
33
|
+
export interface StackContext {
|
|
34
|
+
apiUrl?: string;
|
|
35
|
+
systemId?: string;
|
|
36
|
+
onNavigate?: (item: StackItem) => void;
|
|
37
|
+
}
|
|
38
|
+
export interface ViewContext {
|
|
39
|
+
onBack?: () => void;
|
|
40
|
+
onEdit?: () => void;
|
|
41
|
+
onDelete?: () => void;
|
|
42
|
+
onOpenChat?: (nodeId: string) => void;
|
|
43
|
+
apiUrl?: string;
|
|
44
|
+
userId?: string;
|
|
45
|
+
graphClient?: any;
|
|
46
|
+
}
|
|
47
|
+
export type CardRenderer = (item: StackItem, context?: StackContext) => ReactNode;
|
|
48
|
+
export type ViewRenderer = (item: StackItem, context?: ViewContext) => ReactNode;
|
|
49
|
+
export interface EditorProps {
|
|
50
|
+
item?: StackItem;
|
|
51
|
+
graphClient: any;
|
|
52
|
+
onSave: (item: StackItem) => void;
|
|
53
|
+
onCancel: () => void;
|
|
54
|
+
onDelete?: () => void;
|
|
55
|
+
apiUrl?: string;
|
|
56
|
+
systemId?: string;
|
|
57
|
+
}
|
|
58
|
+
export type Editor = React.ComponentType<EditorProps>;
|
|
59
|
+
export interface StackConfig {
|
|
60
|
+
id: string;
|
|
61
|
+
name?: string;
|
|
62
|
+
system_id: string;
|
|
63
|
+
parentId?: string;
|
|
64
|
+
displayMode?: 'children' | 'edges' | 'both';
|
|
65
|
+
maxWidth?: string;
|
|
66
|
+
minWidth?: string;
|
|
67
|
+
cardRenderer?: CardRenderer;
|
|
68
|
+
viewRenderer?: ViewRenderer;
|
|
69
|
+
items?: StackItem[];
|
|
70
|
+
loadItems?: () => Promise<StackItem[]>;
|
|
71
|
+
metadata?: {
|
|
72
|
+
hidden?: boolean;
|
|
73
|
+
archive?: boolean;
|
|
74
|
+
originalNode?: any;
|
|
75
|
+
isSelected?: boolean;
|
|
76
|
+
};
|
|
77
|
+
onNavigate?: (item: StackItem) => void;
|
|
78
|
+
onAdd?: () => void;
|
|
79
|
+
onAddRequest?: (data: any) => Promise<void>;
|
|
80
|
+
systemMessage?: {
|
|
81
|
+
type: 'error' | 'warning' | 'info' | 'success';
|
|
82
|
+
message: string;
|
|
83
|
+
details?: string;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export interface StackProps {
|
|
87
|
+
config: StackConfig;
|
|
88
|
+
onItemClick?: (item: StackItem) => void;
|
|
89
|
+
onClose?: () => void;
|
|
90
|
+
onClick?: (event: React.MouseEvent) => void;
|
|
91
|
+
style?: React.CSSProperties;
|
|
92
|
+
currentView?: StackItem | null;
|
|
93
|
+
viewNode?: any;
|
|
94
|
+
onCloseView?: () => void;
|
|
95
|
+
onAdd?: () => void;
|
|
96
|
+
theme?: StackTheme;
|
|
97
|
+
apiUrl?: string;
|
|
98
|
+
userId?: string;
|
|
99
|
+
onCreateColumn?: (item: StackItem, direction: 'left' | 'right') => void;
|
|
100
|
+
}
|
|
101
|
+
export interface StackTheme {
|
|
102
|
+
primary?: string;
|
|
103
|
+
surface?: string;
|
|
104
|
+
surfaceHover?: string;
|
|
105
|
+
muted?: string;
|
|
106
|
+
text?: string;
|
|
107
|
+
textMuted?: string;
|
|
108
|
+
success?: string;
|
|
109
|
+
error?: string;
|
|
110
|
+
}
|
|
111
|
+
export interface StackContainerProps {
|
|
112
|
+
stacks: StackConfig[];
|
|
113
|
+
defaultViewMode?: 'side' | 'fullscreen' | 'modal';
|
|
114
|
+
maxStacks?: number;
|
|
115
|
+
stackSpacing?: string;
|
|
116
|
+
containerPadding?: string;
|
|
117
|
+
onStackClose?: (stackId: string) => void;
|
|
118
|
+
onStackOpen?: (config: StackConfig) => void;
|
|
119
|
+
style?: React.CSSProperties;
|
|
120
|
+
}
|
|
121
|
+
export type LayoutMode = 'list' | 'grid' | 'masonry';
|
|
122
|
+
export interface GraphClientConfig {
|
|
123
|
+
baseUrl: string;
|
|
124
|
+
system_id: string;
|
|
125
|
+
}
|
|
126
|
+
export interface APIResponse<T = any> {
|
|
127
|
+
success: boolean;
|
|
128
|
+
data?: T;
|
|
129
|
+
result?: T;
|
|
130
|
+
error?: string;
|
|
131
|
+
}
|
|
132
|
+
export interface ApiConfig {
|
|
133
|
+
baseUrl: string;
|
|
134
|
+
timeout?: number;
|
|
135
|
+
headers?: Record<string, string>;
|
|
136
|
+
}
|
|
137
|
+
export interface ApiResponse<T = any> {
|
|
138
|
+
data: T;
|
|
139
|
+
success: boolean;
|
|
140
|
+
message?: string;
|
|
141
|
+
error?: string;
|
|
142
|
+
}
|
|
143
|
+
export interface PaginationParams {
|
|
144
|
+
page?: number;
|
|
145
|
+
limit?: number;
|
|
146
|
+
offset?: number;
|
|
147
|
+
}
|
|
148
|
+
export interface SortParams {
|
|
149
|
+
sortBy?: string;
|
|
150
|
+
sortOrder?: 'asc' | 'desc';
|
|
151
|
+
}
|
|
152
|
+
export interface FilterParams {
|
|
153
|
+
[key: string]: any;
|
|
154
|
+
}
|
|
155
|
+
export interface QueryParams extends PaginationParams, SortParams, FilterParams {
|
|
156
|
+
}
|
|
157
|
+
export interface PaginatedResponse<T = any> {
|
|
158
|
+
data: T[];
|
|
159
|
+
total: number;
|
|
160
|
+
page: number;
|
|
161
|
+
limit: number;
|
|
162
|
+
totalPages: number;
|
|
163
|
+
}
|
|
164
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
165
|
+
export interface RequestOptions {
|
|
166
|
+
method?: HttpMethod;
|
|
167
|
+
headers?: Record<string, string>;
|
|
168
|
+
body?: any;
|
|
169
|
+
params?: QueryParams;
|
|
170
|
+
}
|
|
171
|
+
export interface MailClientConfig {
|
|
172
|
+
baseUrl: string;
|
|
173
|
+
system_id: string;
|
|
174
|
+
}
|
|
175
|
+
export interface MailServer {
|
|
176
|
+
host: string;
|
|
177
|
+
port: string;
|
|
178
|
+
user: string;
|
|
179
|
+
password: string;
|
|
180
|
+
}
|
|
181
|
+
export interface MailAccount {
|
|
182
|
+
id: string;
|
|
183
|
+
label: string;
|
|
184
|
+
firstName: string;
|
|
185
|
+
lastName: string;
|
|
186
|
+
email: string;
|
|
187
|
+
signature?: string;
|
|
188
|
+
imap: MailServer;
|
|
189
|
+
smtp: MailServer;
|
|
190
|
+
}
|
|
191
|
+
export interface EmailMessage {
|
|
192
|
+
uid: number;
|
|
193
|
+
subject: string;
|
|
194
|
+
from: string;
|
|
195
|
+
date: string;
|
|
196
|
+
seen: boolean;
|
|
197
|
+
}
|
|
198
|
+
export interface MailListResult {
|
|
199
|
+
account: {
|
|
200
|
+
id: string;
|
|
201
|
+
label: string;
|
|
202
|
+
email: string;
|
|
203
|
+
};
|
|
204
|
+
mailbox: {
|
|
205
|
+
name: string;
|
|
206
|
+
total: number;
|
|
207
|
+
};
|
|
208
|
+
messages: EmailMessage[];
|
|
209
|
+
}
|
|
210
|
+
export interface ImapResponse {
|
|
211
|
+
ok: boolean;
|
|
212
|
+
command: string;
|
|
213
|
+
error?: string;
|
|
214
|
+
mailbox?: string;
|
|
215
|
+
exists?: number;
|
|
216
|
+
recent?: number;
|
|
217
|
+
unseen?: number;
|
|
218
|
+
folders?: FolderInfo[];
|
|
219
|
+
uid?: string;
|
|
220
|
+
}
|
|
221
|
+
export interface FolderInfo {
|
|
222
|
+
name: string;
|
|
223
|
+
delimiter: string | null;
|
|
224
|
+
attributes: string;
|
|
225
|
+
}
|
package/package.json
CHANGED