@qwanyx/stack 0.2.3 → 0.2.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qwanyx/stack",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Modern HyperCard for React - All-in-one data management (REST + Graph API + Auth + Hooks + UI)",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -1,53 +0,0 @@
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;
@@ -1,34 +0,0 @@
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
- }
@@ -1,86 +0,0 @@
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
- }
@@ -1,69 +0,0 @@
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
- }
@@ -1,19 +0,0 @@
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;
@@ -1,13 +0,0 @@
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;
@@ -1,15 +0,0 @@
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;
@@ -1,51 +0,0 @@
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;
@@ -1,38 +0,0 @@
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;
@@ -1,16 +0,0 @@
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>;
@@ -1,18 +0,0 @@
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 DELETED
@@ -1,28 +0,0 @@
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';
@@ -1,51 +0,0 @@
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
- }