@pubflow/react 0.1.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.
Files changed (38) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +539 -0
  3. package/dist/index.d.ts +1908 -0
  4. package/dist/index.esm.js +9922 -0
  5. package/dist/index.esm.js.map +1 -0
  6. package/dist/index.js +9954 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/types/components/AdvancedFilter.d.ts +113 -0
  9. package/dist/types/components/BridgeForm/index.d.ts +6 -0
  10. package/dist/types/components/BridgeForm/styles.d.ts +62 -0
  11. package/dist/types/components/BridgeForm/types.d.ts +128 -0
  12. package/dist/types/components/BridgeForm/utils.d.ts +60 -0
  13. package/dist/types/components/BridgeList.d.ts +157 -0
  14. package/dist/types/components/BridgeTable.d.ts +110 -0
  15. package/dist/types/components/BridgeView.d.ts +39 -0
  16. package/dist/types/components/OfflineIndicator.d.ts +58 -0
  17. package/dist/types/components/auth/AccountCreationForm.d.ts +60 -0
  18. package/dist/types/components/auth/LoginForm.d.ts +76 -0
  19. package/dist/types/components/auth/PasswordResetForm.d.ts +60 -0
  20. package/dist/types/components/auth/index.d.ts +8 -0
  21. package/dist/types/components/theme/ThemeProvider.d.ts +255 -0
  22. package/dist/types/components/theme/index.d.ts +6 -0
  23. package/dist/types/context/PubflowProvider.d.ts +100 -0
  24. package/dist/types/hooks/useAuth.d.ts +32 -0
  25. package/dist/types/hooks/useBridgeApi.d.ts +14 -0
  26. package/dist/types/hooks/useBridgeApiRaw.d.ts +91 -0
  27. package/dist/types/hooks/useBridgeCrud.d.ts +193 -0
  28. package/dist/types/hooks/useBridgeMutation.d.ts +69 -0
  29. package/dist/types/hooks/useBridgeQuery.d.ts +44 -0
  30. package/dist/types/hooks/useSearchQueryBuilder.d.ts +152 -0
  31. package/dist/types/hooks/useServerAuth.d.ts +45 -0
  32. package/dist/types/index.d.ts +26 -0
  33. package/dist/types/storage/BrowserStorageAdapter.d.ts +112 -0
  34. package/dist/types/test/setup.d.ts +4 -0
  35. package/dist/types/utils/auth-utils.d.ts +37 -0
  36. package/dist/types/utils/index.d.ts +5 -0
  37. package/dist/types/utils/persistent-cache.d.ts +57 -0
  38. package/package.json +70 -0
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Browser Storage Adapter for React
3
+ *
4
+ * Provides a storage adapter for React applications using localStorage
5
+ */
6
+ import { StorageAdapter } from '@pubflow/core';
7
+ /**
8
+ * Options for the browser storage adapter
9
+ */
10
+ export interface BrowserStorageOptions {
11
+ /**
12
+ * Prefix for storage keys
13
+ */
14
+ prefix?: string;
15
+ /**
16
+ * Whether to use sessionStorage instead of localStorage
17
+ */
18
+ useSessionStorage?: boolean;
19
+ /**
20
+ * Whether to use cookies as fallback when localStorage/sessionStorage is not available
21
+ */
22
+ useCookieFallback?: boolean;
23
+ /**
24
+ * Cookie options when using cookie fallback
25
+ */
26
+ cookieOptions?: {
27
+ /**
28
+ * Cookie expiration in days
29
+ */
30
+ maxAge?: number;
31
+ /**
32
+ * Cookie path
33
+ */
34
+ path?: string;
35
+ /**
36
+ * Whether the cookie should be secure
37
+ */
38
+ secure?: boolean;
39
+ /**
40
+ * Whether the cookie should be HTTP only
41
+ */
42
+ httpOnly?: boolean;
43
+ /**
44
+ * SameSite attribute for the cookie
45
+ */
46
+ sameSite?: 'strict' | 'lax' | 'none';
47
+ };
48
+ }
49
+ /**
50
+ * Browser storage adapter for React
51
+ * Uses localStorage or sessionStorage with cookie fallback
52
+ */
53
+ export declare class BrowserStorageAdapter implements StorageAdapter {
54
+ private prefix;
55
+ private useSessionStorage;
56
+ private useCookieFallback;
57
+ private cookieOptions;
58
+ /**
59
+ * Create a new browser storage adapter
60
+ *
61
+ * @param options Storage options
62
+ */
63
+ constructor(options?: BrowserStorageOptions);
64
+ /**
65
+ * Get a value from storage
66
+ *
67
+ * @param key Storage key
68
+ * @returns Stored value or null
69
+ */
70
+ getItem(key: string): Promise<string | null>;
71
+ /**
72
+ * Save a value to storage
73
+ *
74
+ * @param key Storage key
75
+ * @param value Value to store
76
+ */
77
+ setItem(key: string, value: string): Promise<void>;
78
+ /**
79
+ * Remove a value from storage
80
+ *
81
+ * @param key Storage key
82
+ */
83
+ removeItem(key: string): Promise<void>;
84
+ /**
85
+ * Clear all values with the current prefix
86
+ */
87
+ clear(): Promise<void>;
88
+ /**
89
+ * Get a cookie value
90
+ *
91
+ * @param key Cookie key
92
+ * @returns Cookie value or null
93
+ */
94
+ private getCookie;
95
+ /**
96
+ * Set a cookie value
97
+ *
98
+ * @param key Cookie key
99
+ * @param value Cookie value
100
+ */
101
+ private setCookie;
102
+ /**
103
+ * Remove a cookie
104
+ *
105
+ * @param key Cookie key
106
+ */
107
+ private removeCookie;
108
+ /**
109
+ * Clear all cookies with the current prefix
110
+ */
111
+ private clearCookies;
112
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Test Setup for Pubflow React Package
3
+ */
4
+ import '@testing-library/jest-dom';
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Authentication Utilities for React
3
+ *
4
+ * Provides utilities for authentication in React applications
5
+ */
6
+ /**
7
+ * Options for the useRequireAuth hook
8
+ */
9
+ export interface UseRequireAuthOptions {
10
+ /**
11
+ * User types allowed to access the route
12
+ */
13
+ allowedTypes?: string | string[];
14
+ /**
15
+ * Redirect function
16
+ */
17
+ redirectFn?: (path: string) => void;
18
+ /**
19
+ * Redirect path when not authenticated
20
+ */
21
+ redirectTo?: string;
22
+ /**
23
+ * Pubflow instance ID
24
+ */
25
+ instanceId?: string;
26
+ }
27
+ /**
28
+ * Hook for requiring authentication
29
+ *
30
+ * @param options Authentication options
31
+ * @returns Authentication result
32
+ */
33
+ export declare function useRequireAuth(options?: UseRequireAuthOptions): {
34
+ user: import("@pubflow/core").User | null;
35
+ isAuthenticated: boolean;
36
+ isLoading: boolean;
37
+ };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Utility exports for React adapter
3
+ */
4
+ export * from './auth-utils';
5
+ export * from './persistent-cache';
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Persistent Cache Utility for React
3
+ *
4
+ * Provides a way to persist SWR cache between page refreshes and browser sessions
5
+ */
6
+ import { Cache } from 'swr';
7
+ /**
8
+ * Options for persistent cache
9
+ */
10
+ export interface PersistentCacheOptions {
11
+ /**
12
+ * Prefix for storage keys
13
+ */
14
+ prefix?: string;
15
+ /**
16
+ * Time to live in milliseconds
17
+ * Default: 24 hours
18
+ */
19
+ ttl?: number;
20
+ /**
21
+ * Maximum size of a cache item in bytes
22
+ * Default: 2MB
23
+ */
24
+ maxItemSize?: number;
25
+ /**
26
+ * Whether to compress cache data to save space
27
+ * Default: false
28
+ */
29
+ compress?: boolean;
30
+ /**
31
+ * Custom serialization function
32
+ * Default: JSON.stringify
33
+ */
34
+ serialize?: (data: any) => string;
35
+ /**
36
+ * Custom deserialization function
37
+ * Default: JSON.parse
38
+ */
39
+ deserialize?: (text: string) => any;
40
+ /**
41
+ * Whether to log cache operations
42
+ * Default: false
43
+ */
44
+ debug?: boolean;
45
+ /**
46
+ * Storage mechanism to use
47
+ * Default: 'localStorage'
48
+ */
49
+ storage?: 'localStorage' | 'sessionStorage';
50
+ }
51
+ /**
52
+ * Creates a persistent cache provider for SWR
53
+ *
54
+ * @param options Cache options
55
+ * @returns SWR cache provider
56
+ */
57
+ export declare function createPersistentCache(options?: PersistentCacheOptions): () => Cache;
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@pubflow/react",
3
+ "version": "0.1.0",
4
+ "description": "React adapter for Pubflow framework with support for TanStack Router and SWR",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.esm.js",
7
+ "types": "dist/index.d.ts",
8
+ "type": "module",
9
+ "files": [
10
+ "dist",
11
+ "README.md"
12
+ ],
13
+ "scripts": {
14
+ "build": "rollup -c",
15
+ "dev": "rollup -c -w",
16
+ "test": "vitest",
17
+ "test:ui": "vitest --ui",
18
+ "test:coverage": "vitest --coverage",
19
+ "test:watch": "vitest --watch",
20
+ "lint": "eslint src --ext .ts,.tsx",
21
+ "clean": "rimraf dist"
22
+ },
23
+ "keywords": [
24
+ "pubflow",
25
+ "react",
26
+ "remix",
27
+ "react-framework",
28
+ "swr",
29
+ "api",
30
+ "bridge",
31
+ "authentication"
32
+ ],
33
+ "author": "Pubflow, Inc.",
34
+ "license": "AGPL-3.0-or-later",
35
+ "dependencies": {
36
+ "@pubflow/core": "^0.2.0",
37
+ "@hookform/resolvers": "^3.3.2",
38
+ "react-hook-form": "^7.48.2",
39
+ "swr": "^2.2.4"
40
+ },
41
+ "peerDependencies": {
42
+ "react": ">=17.0.0",
43
+ "react-dom": ">=17.0.0"
44
+ },
45
+ "optionalDependencies": {},
46
+ "devDependencies": {
47
+ "@rollup/plugin-commonjs": "^25.0.0",
48
+ "@rollup/plugin-node-resolve": "^15.0.0",
49
+ "@rollup/plugin-typescript": "^11.0.0",
50
+ "@testing-library/jest-dom": "^6.1.0",
51
+ "@testing-library/react": "^14.0.0",
52
+ "@testing-library/user-event": "^14.5.0",
53
+ "@types/node": "^20.0.0",
54
+ "@types/react": "^18.0.0",
55
+ "@types/react-dom": "^18.0.0",
56
+ "@vitejs/plugin-react": "^4.1.0",
57
+ "@vitest/ui": "^1.0.0",
58
+ "eslint": "^8.0.0",
59
+ "jsdom": "^23.0.0",
60
+ "react": "^18.0.0",
61
+ "react-dom": "^18.0.0",
62
+ "rimraf": "^5.0.0",
63
+ "rollup": "^3.0.0",
64
+ "rollup-plugin-dts": "^5.0.0",
65
+ "rollup-plugin-peer-deps-external": "^2.0.0",
66
+ "tslib": "^2.8.1",
67
+ "typescript": "^5.0.0",
68
+ "vitest": "^1.0.0"
69
+ }
70
+ }