frappe-nextjs 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 (98) hide show
  1. package/README.md +90 -0
  2. package/dist/bin/cli.d.ts +3 -0
  3. package/dist/bin/cli.d.ts.map +1 -0
  4. package/dist/bin/cli.js +156 -0
  5. package/dist/bin/cli.js.map +1 -0
  6. package/dist/build/boilerplates.d.ts +12 -0
  7. package/dist/build/boilerplates.d.ts.map +1 -0
  8. package/dist/build/boilerplates.js +261 -0
  9. package/dist/build/boilerplates.js.map +1 -0
  10. package/dist/build/build.d.ts +27 -0
  11. package/dist/build/build.d.ts.map +1 -0
  12. package/dist/build/build.js +172 -0
  13. package/dist/build/build.js.map +1 -0
  14. package/dist/build/context-generator.d.ts +13 -0
  15. package/dist/build/context-generator.d.ts.map +1 -0
  16. package/dist/build/context-generator.js +76 -0
  17. package/dist/build/context-generator.js.map +1 -0
  18. package/dist/build/hooks-patcher.d.ts +11 -0
  19. package/dist/build/hooks-patcher.d.ts.map +1 -0
  20. package/dist/build/hooks-patcher.js +78 -0
  21. package/dist/build/hooks-patcher.js.map +1 -0
  22. package/dist/build/index.d.ts +8 -0
  23. package/dist/build/index.d.ts.map +1 -0
  24. package/dist/build/index.js +33 -0
  25. package/dist/build/index.js.map +1 -0
  26. package/dist/build/init.d.ts +27 -0
  27. package/dist/build/init.d.ts.map +1 -0
  28. package/dist/build/init.js +175 -0
  29. package/dist/build/init.js.map +1 -0
  30. package/dist/build/nginx-generator.d.ts +22 -0
  31. package/dist/build/nginx-generator.d.ts.map +1 -0
  32. package/dist/build/nginx-generator.js +114 -0
  33. package/dist/build/nginx-generator.js.map +1 -0
  34. package/dist/build/supervisor-generator.d.ts +31 -0
  35. package/dist/build/supervisor-generator.d.ts.map +1 -0
  36. package/dist/build/supervisor-generator.js +105 -0
  37. package/dist/build/supervisor-generator.js.map +1 -0
  38. package/dist/client/FrappeClient.d.ts +143 -0
  39. package/dist/client/FrappeClient.d.ts.map +1 -0
  40. package/dist/client/FrappeClient.js +446 -0
  41. package/dist/client/FrappeClient.js.map +1 -0
  42. package/dist/client/index.d.ts +3 -0
  43. package/dist/client/index.d.ts.map +1 -0
  44. package/dist/client/index.js +21 -0
  45. package/dist/client/index.js.map +1 -0
  46. package/dist/client/types.d.ts +140 -0
  47. package/dist/client/types.d.ts.map +1 -0
  48. package/dist/client/types.js +17 -0
  49. package/dist/client/types.js.map +1 -0
  50. package/dist/hooks/FrappeProvider.d.ts +41 -0
  51. package/dist/hooks/FrappeProvider.d.ts.map +1 -0
  52. package/dist/hooks/FrappeProvider.js +48 -0
  53. package/dist/hooks/FrappeProvider.js.map +1 -0
  54. package/dist/hooks/index.d.ts +8 -0
  55. package/dist/hooks/index.d.ts.map +1 -0
  56. package/dist/hooks/index.js +17 -0
  57. package/dist/hooks/index.js.map +1 -0
  58. package/dist/hooks/useFrappeAuth.d.ts +37 -0
  59. package/dist/hooks/useFrappeAuth.d.ts.map +1 -0
  60. package/dist/hooks/useFrappeAuth.js +111 -0
  61. package/dist/hooks/useFrappeAuth.js.map +1 -0
  62. package/dist/hooks/useFrappeCall.d.ts +26 -0
  63. package/dist/hooks/useFrappeCall.d.ts.map +1 -0
  64. package/dist/hooks/useFrappeCall.js +47 -0
  65. package/dist/hooks/useFrappeCall.js.map +1 -0
  66. package/dist/hooks/useFrappeDoc.d.ts +37 -0
  67. package/dist/hooks/useFrappeDoc.d.ts.map +1 -0
  68. package/dist/hooks/useFrappeDoc.js +79 -0
  69. package/dist/hooks/useFrappeDoc.js.map +1 -0
  70. package/dist/hooks/useFrappeDocList.d.ts +37 -0
  71. package/dist/hooks/useFrappeDocList.d.ts.map +1 -0
  72. package/dist/hooks/useFrappeDocList.js +65 -0
  73. package/dist/hooks/useFrappeDocList.js.map +1 -0
  74. package/dist/hooks/useFrappeFileUpload.d.ts +40 -0
  75. package/dist/hooks/useFrappeFileUpload.d.ts.map +1 -0
  76. package/dist/hooks/useFrappeFileUpload.js +68 -0
  77. package/dist/hooks/useFrappeFileUpload.js.map +1 -0
  78. package/dist/index.d.ts +10 -0
  79. package/dist/index.d.ts.map +1 -0
  80. package/dist/index.js +24 -0
  81. package/dist/index.js.map +1 -0
  82. package/dist/ssr/index.d.ts +4 -0
  83. package/dist/ssr/index.d.ts.map +1 -0
  84. package/dist/ssr/index.js +13 -0
  85. package/dist/ssr/index.js.map +1 -0
  86. package/dist/ssr/middleware.d.ts +18 -0
  87. package/dist/ssr/middleware.d.ts.map +1 -0
  88. package/dist/ssr/middleware.js +132 -0
  89. package/dist/ssr/middleware.js.map +1 -0
  90. package/dist/ssr/proxy-config.d.ts +33 -0
  91. package/dist/ssr/proxy-config.d.ts.map +1 -0
  92. package/dist/ssr/proxy-config.js +133 -0
  93. package/dist/ssr/proxy-config.js.map +1 -0
  94. package/dist/ssr/server-client.d.ts +73 -0
  95. package/dist/ssr/server-client.d.ts.map +1 -0
  96. package/dist/ssr/server-client.js +94 -0
  97. package/dist/ssr/server-client.js.map +1 -0
  98. package/package.json +79 -0
@@ -0,0 +1,41 @@
1
+ import React from "react";
2
+ import { FrappeClient } from "../client/FrappeClient";
3
+ import { FrappeClientConfig } from "../client/types";
4
+ /**
5
+ * Props for the FrappeProvider component.
6
+ */
7
+ export interface FrappeProviderProps {
8
+ /** Configuration for the Frappe client */
9
+ config?: FrappeClientConfig;
10
+ /** Child components */
11
+ children: React.ReactNode;
12
+ }
13
+ /**
14
+ * React context provider that makes a FrappeClient instance available to all
15
+ * child components via hooks.
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * // app/layout.tsx
20
+ * import { FrappeProvider } from 'frappe-nextjs';
21
+ *
22
+ * export default function RootLayout({ children }) {
23
+ * return (
24
+ * <html>
25
+ * <body>
26
+ * <FrappeProvider config={{ baseUrl: '' }}>
27
+ * {children}
28
+ * </FrappeProvider>
29
+ * </body>
30
+ * </html>
31
+ * );
32
+ * }
33
+ * ```
34
+ */
35
+ export declare function FrappeProvider({ config, children }: FrappeProviderProps): import("react/jsx-runtime").JSX.Element;
36
+ /**
37
+ * Hook to access the FrappeClient instance from context.
38
+ * Must be used within a FrappeProvider.
39
+ */
40
+ export declare function useFrappeClient(): FrappeClient;
41
+ //# sourceMappingURL=FrappeProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FrappeProvider.d.ts","sourceRoot":"","sources":["../../src/hooks/FrappeProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAIrD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,0CAA0C;IAC1C,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,uBAAuB;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,CAAC,EAAE,MAAW,EAAE,QAAQ,EAAE,EAAE,mBAAmB,2CAS5E;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAS9C"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ "use client";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.FrappeProvider = FrappeProvider;
5
+ exports.useFrappeClient = useFrappeClient;
6
+ const jsx_runtime_1 = require("react/jsx-runtime");
7
+ const react_1 = require("react");
8
+ const FrappeClient_1 = require("../client/FrappeClient");
9
+ const FrappeContext = (0, react_1.createContext)(null);
10
+ /**
11
+ * React context provider that makes a FrappeClient instance available to all
12
+ * child components via hooks.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * // app/layout.tsx
17
+ * import { FrappeProvider } from 'frappe-nextjs';
18
+ *
19
+ * export default function RootLayout({ children }) {
20
+ * return (
21
+ * <html>
22
+ * <body>
23
+ * <FrappeProvider config={{ baseUrl: '' }}>
24
+ * {children}
25
+ * </FrappeProvider>
26
+ * </body>
27
+ * </html>
28
+ * );
29
+ * }
30
+ * ```
31
+ */
32
+ function FrappeProvider({ config = {}, children }) {
33
+ const client = (0, react_1.useMemo)(() => new FrappeClient_1.FrappeClient(config), [config.baseUrl, config.token?.apiKey, config.token?.apiSecret]);
34
+ return ((0, jsx_runtime_1.jsx)(FrappeContext.Provider, { value: client, children: children }));
35
+ }
36
+ /**
37
+ * Hook to access the FrappeClient instance from context.
38
+ * Must be used within a FrappeProvider.
39
+ */
40
+ function useFrappeClient() {
41
+ const client = (0, react_1.useContext)(FrappeContext);
42
+ if (!client) {
43
+ throw new Error("useFrappeClient must be used within a <FrappeProvider>. " +
44
+ "Wrap your component tree with <FrappeProvider config={{ ... }}>.");
45
+ }
46
+ return client;
47
+ }
48
+ //# sourceMappingURL=FrappeProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FrappeProvider.js","sourceRoot":"","sources":["../../src/hooks/FrappeProvider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAwCb,wCASC;AAMD,0CASC;;AA9DD,iCAAkE;AAClE,yDAAsD;AAGtD,MAAM,aAAa,GAAG,IAAA,qBAAa,EAAsB,IAAI,CAAC,CAAC;AAY/D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,cAAc,CAAC,EAAE,MAAM,GAAG,EAAE,EAAE,QAAQ,EAAuB;IAC3E,MAAM,MAAM,GAAG,IAAA,eAAO,EACpB,GAAG,EAAE,CAAC,IAAI,2BAAY,CAAC,MAAM,CAAC,EAC9B,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAChE,CAAC;IAEF,OAAO,CACL,uBAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,YAAG,QAAQ,GAA0B,CAC3E,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,eAAe;IAC7B,MAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,aAAa,CAAC,CAAC;IACzC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,0DAA0D;YACxD,kEAAkE,CACrE,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,8 @@
1
+ export { FrappeProvider, useFrappeClient } from './FrappeProvider';
2
+ export type { FrappeProviderProps } from './FrappeProvider';
3
+ export { useFrappeCall } from './useFrappeCall';
4
+ export { useFrappeDocList } from './useFrappeDocList';
5
+ export { useFrappeDoc } from './useFrappeDoc';
6
+ export { useFrappeAuth } from './useFrappeAuth';
7
+ export { useFrappeFileUpload } from './useFrappeFileUpload';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnE,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useFrappeFileUpload = exports.useFrappeAuth = exports.useFrappeDoc = exports.useFrappeDocList = exports.useFrappeCall = exports.useFrappeClient = exports.FrappeProvider = void 0;
4
+ var FrappeProvider_1 = require("./FrappeProvider");
5
+ Object.defineProperty(exports, "FrappeProvider", { enumerable: true, get: function () { return FrappeProvider_1.FrappeProvider; } });
6
+ Object.defineProperty(exports, "useFrappeClient", { enumerable: true, get: function () { return FrappeProvider_1.useFrappeClient; } });
7
+ var useFrappeCall_1 = require("./useFrappeCall");
8
+ Object.defineProperty(exports, "useFrappeCall", { enumerable: true, get: function () { return useFrappeCall_1.useFrappeCall; } });
9
+ var useFrappeDocList_1 = require("./useFrappeDocList");
10
+ Object.defineProperty(exports, "useFrappeDocList", { enumerable: true, get: function () { return useFrappeDocList_1.useFrappeDocList; } });
11
+ var useFrappeDoc_1 = require("./useFrappeDoc");
12
+ Object.defineProperty(exports, "useFrappeDoc", { enumerable: true, get: function () { return useFrappeDoc_1.useFrappeDoc; } });
13
+ var useFrappeAuth_1 = require("./useFrappeAuth");
14
+ Object.defineProperty(exports, "useFrappeAuth", { enumerable: true, get: function () { return useFrappeAuth_1.useFrappeAuth; } });
15
+ var useFrappeFileUpload_1 = require("./useFrappeFileUpload");
16
+ Object.defineProperty(exports, "useFrappeFileUpload", { enumerable: true, get: function () { return useFrappeFileUpload_1.useFrappeFileUpload; } });
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":";;;AAAA,mDAAmE;AAA1D,gHAAA,cAAc,OAAA;AAAE,iHAAA,eAAe,OAAA;AAExC,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Hook to manage Frappe authentication state.
3
+ *
4
+ * @example
5
+ * ```tsx
6
+ * function AuthBar() {
7
+ * const { isLoggedIn, user, login, logout, isLoading } = useFrappeAuth();
8
+ *
9
+ * if (isLoading) return <p>Checking auth...</p>;
10
+ *
11
+ * if (isLoggedIn) {
12
+ * return (
13
+ * <div>
14
+ * <span>Welcome, {user}</span>
15
+ * <button onClick={logout}>Logout</button>
16
+ * </div>
17
+ * );
18
+ * }
19
+ *
20
+ * return (
21
+ * <button onClick={() => login('admin@example.com', 'password')}>
22
+ * Login
23
+ * </button>
24
+ * );
25
+ * }
26
+ * ```
27
+ */
28
+ export declare function useFrappeAuth(): {
29
+ isLoading: boolean;
30
+ error: Error | null;
31
+ login: (username: string, password: string) => Promise<boolean>;
32
+ logout: () => Promise<void>;
33
+ isLoggedIn: boolean;
34
+ user: string | null;
35
+ userImage: string | null;
36
+ };
37
+ //# sourceMappingURL=useFrappeAuth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFrappeAuth.d.ts","sourceRoot":"","sources":["../../src/hooks/useFrappeAuth.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,aAAa;;;sBA8BR,MAAM,YAAY,MAAM;;;;;EAqC5C"}
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ 'use client';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useFrappeAuth = useFrappeAuth;
5
+ const react_1 = require("react");
6
+ const FrappeProvider_1 = require("./FrappeProvider");
7
+ /**
8
+ * Parse cookies from document.cookie string.
9
+ */
10
+ function parseCookies() {
11
+ if (typeof document === 'undefined')
12
+ return {};
13
+ return Object.fromEntries(document.cookie
14
+ .split('; ')
15
+ .filter(Boolean)
16
+ .map((part) => {
17
+ const [key, ...rest] = part.split('=');
18
+ return [key, decodeURIComponent(rest.join('='))];
19
+ }));
20
+ }
21
+ /**
22
+ * Hook to manage Frappe authentication state.
23
+ *
24
+ * @example
25
+ * ```tsx
26
+ * function AuthBar() {
27
+ * const { isLoggedIn, user, login, logout, isLoading } = useFrappeAuth();
28
+ *
29
+ * if (isLoading) return <p>Checking auth...</p>;
30
+ *
31
+ * if (isLoggedIn) {
32
+ * return (
33
+ * <div>
34
+ * <span>Welcome, {user}</span>
35
+ * <button onClick={logout}>Logout</button>
36
+ * </div>
37
+ * );
38
+ * }
39
+ *
40
+ * return (
41
+ * <button onClick={() => login('admin@example.com', 'password')}>
42
+ * Login
43
+ * </button>
44
+ * );
45
+ * }
46
+ * ```
47
+ */
48
+ function useFrappeAuth() {
49
+ const client = (0, FrappeProvider_1.useFrappeClient)();
50
+ const [authState, setAuthState] = (0, react_1.useState)(() => {
51
+ const cookies = parseCookies();
52
+ return {
53
+ isLoggedIn: !!cookies.user_id && cookies.user_id !== 'Guest',
54
+ user: cookies.user_id && cookies.user_id !== 'Guest' ? cookies.user_id : null,
55
+ userImage: null,
56
+ };
57
+ });
58
+ const [isLoading, setIsLoading] = (0, react_1.useState)(false);
59
+ const [error, setError] = (0, react_1.useState)(null);
60
+ // Verify auth state with server on mount
61
+ (0, react_1.useEffect)(() => {
62
+ if (authState.isLoggedIn) {
63
+ client
64
+ .getLoggedUser()
65
+ .then((user) => {
66
+ setAuthState((prev) => ({ ...prev, user, isLoggedIn: true }));
67
+ })
68
+ .catch(() => {
69
+ setAuthState({ isLoggedIn: false, user: null, userImage: null });
70
+ });
71
+ }
72
+ }, []);
73
+ const login = (0, react_1.useCallback)(async (username, password) => {
74
+ setIsLoading(true);
75
+ setError(null);
76
+ try {
77
+ await client.login(username, password);
78
+ const user = await client.getLoggedUser();
79
+ setAuthState({ isLoggedIn: true, user, userImage: null });
80
+ return true;
81
+ }
82
+ catch (err) {
83
+ setError(err);
84
+ return false;
85
+ }
86
+ finally {
87
+ setIsLoading(false);
88
+ }
89
+ }, [client]);
90
+ const logout = (0, react_1.useCallback)(async () => {
91
+ setIsLoading(true);
92
+ try {
93
+ await client.logout();
94
+ setAuthState({ isLoggedIn: false, user: null, userImage: null });
95
+ }
96
+ catch (err) {
97
+ setError(err);
98
+ }
99
+ finally {
100
+ setIsLoading(false);
101
+ }
102
+ }, [client]);
103
+ return {
104
+ ...authState,
105
+ isLoading,
106
+ error,
107
+ login,
108
+ logout,
109
+ };
110
+ }
111
+ //# sourceMappingURL=useFrappeAuth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFrappeAuth.js","sourceRoot":"","sources":["../../src/hooks/useFrappeAuth.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,26 @@
1
+ import { SWRConfiguration } from 'swr';
2
+ import { CallParams } from '../client/types';
3
+ /**
4
+ * Hook to call a whitelisted Frappe backend method.
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * function PingTest() {
9
+ * const { data, error, isLoading, mutate } = useFrappeCall({
10
+ * method: 'frappe.ping',
11
+ * });
12
+ *
13
+ * if (isLoading) return <p>Loading...</p>;
14
+ * if (error) return <p>Error: {error.message}</p>;
15
+ * return <p>Response: {JSON.stringify(data)}</p>;
16
+ * }
17
+ * ```
18
+ */
19
+ export declare function useFrappeCall<T = unknown>(params: CallParams | null, swrConfig?: SWRConfiguration): {
20
+ data: T | undefined;
21
+ error: Error | undefined;
22
+ isLoading: boolean;
23
+ isValidating: boolean;
24
+ mutate: import("swr").KeyedMutator<T>;
25
+ };
26
+ //# sourceMappingURL=useFrappeCall.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFrappeCall.d.ts","sourceRoot":"","sources":["../../src/hooks/useFrappeCall.ts"],"names":[],"mappings":"AAEA,OAAe,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,CAAC,GAAG,OAAO,EACvC,MAAM,EAAE,UAAU,GAAG,IAAI,EACzB,SAAS,CAAC,EAAE,gBAAgB;;WAsBV,KAAK,GAAG,SAAS;;;;EAKpC"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ 'use client';
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.useFrappeCall = useFrappeCall;
8
+ const swr_1 = __importDefault(require("swr"));
9
+ const FrappeProvider_1 = require("./FrappeProvider");
10
+ /**
11
+ * Hook to call a whitelisted Frappe backend method.
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * function PingTest() {
16
+ * const { data, error, isLoading, mutate } = useFrappeCall({
17
+ * method: 'frappe.ping',
18
+ * });
19
+ *
20
+ * if (isLoading) return <p>Loading...</p>;
21
+ * if (error) return <p>Error: {error.message}</p>;
22
+ * return <p>Response: {JSON.stringify(data)}</p>;
23
+ * }
24
+ * ```
25
+ */
26
+ function useFrappeCall(params, swrConfig) {
27
+ const client = (0, FrappeProvider_1.useFrappeClient)();
28
+ const key = params
29
+ ? `frappe-call:${params.method}:${JSON.stringify(params.args || {})}`
30
+ : null;
31
+ const { data, error, isLoading, isValidating, mutate } = (0, swr_1.default)(key, async () => {
32
+ if (!params)
33
+ throw new Error('No params provided');
34
+ return client.call(params);
35
+ }, {
36
+ revalidateOnFocus: false,
37
+ ...swrConfig,
38
+ });
39
+ return {
40
+ data,
41
+ error: error,
42
+ isLoading,
43
+ isValidating,
44
+ mutate,
45
+ };
46
+ }
47
+ //# sourceMappingURL=useFrappeCall.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFrappeCall.js","sourceRoot":"","sources":["../../src/hooks/useFrappeCall.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;AAsBb,sCA6BC;AAjDD,8CAA+C;AAC/C,qDAAmD;AAGnD;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,aAAa,CAC3B,MAAyB,EACzB,SAA4B;IAE5B,MAAM,MAAM,GAAG,IAAA,gCAAe,GAAE,CAAC;IAEjC,MAAM,GAAG,GAAG,MAAM;QAChB,CAAC,CAAC,eAAe,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE;QACrE,CAAC,CAAC,IAAI,CAAC;IAET,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,IAAA,aAAM,EAC7D,GAAG,EACH,KAAK,IAAI,EAAE;QACT,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACnD,OAAO,MAAM,CAAC,IAAI,CAAI,MAAM,CAAC,CAAC;IAChC,CAAC,EACD;QACE,iBAAiB,EAAE,KAAK;QACxB,GAAG,SAAS;KACb,CACF,CAAC;IAEF,OAAO;QACL,IAAI;QACJ,KAAK,EAAE,KAA0B;QACjC,SAAS;QACT,YAAY;QACZ,MAAM;KACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { SWRConfiguration } from 'swr';
2
+ import { FrappeDoc } from '../client/types';
3
+ /**
4
+ * Hook to fetch a single document and optionally update it.
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * function TodoDetail({ name }: { name: string }) {
9
+ * const { data, error, isLoading, updateDoc } = useFrappeDoc<{ description: string; status: string }>(
10
+ * 'ToDo',
11
+ * name
12
+ * );
13
+ *
14
+ * if (isLoading) return <p>Loading...</p>;
15
+ * if (error) return <p>Error: {error.message}</p>;
16
+ *
17
+ * return (
18
+ * <div>
19
+ * <p>{data?.description}</p>
20
+ * <button onClick={() => updateDoc({ status: 'Closed' })}>
21
+ * Close
22
+ * </button>
23
+ * </div>
24
+ * );
25
+ * }
26
+ * ```
27
+ */
28
+ export declare function useFrappeDoc<T extends Record<string, unknown> = Record<string, unknown>>(doctype: string | null, name: string | null, swrConfig?: SWRConfiguration): {
29
+ data: FrappeDoc<T> | undefined;
30
+ error: Error | undefined;
31
+ isLoading: boolean;
32
+ isValidating: boolean;
33
+ mutate: import("swr").KeyedMutator<FrappeDoc<T>>;
34
+ updateDoc: (updates: Partial<T>) => Promise<FrappeDoc<T>>;
35
+ deleteDoc: () => Promise<void>;
36
+ };
37
+ //# sourceMappingURL=useFrappeDoc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFrappeDoc.d.ts","sourceRoot":"","sources":["../../src/hooks/useFrappeDoc.ts"],"names":[],"mappings":"AAEA,OAAe,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACtF,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,SAAS,CAAC,EAAE,gBAAgB;;WA2CV,KAAK,GAAG,SAAS;;;;yBAtBD,OAAO,CAAC,CAAC,CAAC;;EA6B7C"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ 'use client';
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.useFrappeDoc = useFrappeDoc;
8
+ const swr_1 = __importDefault(require("swr"));
9
+ const FrappeProvider_1 = require("./FrappeProvider");
10
+ /**
11
+ * Hook to fetch a single document and optionally update it.
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * function TodoDetail({ name }: { name: string }) {
16
+ * const { data, error, isLoading, updateDoc } = useFrappeDoc<{ description: string; status: string }>(
17
+ * 'ToDo',
18
+ * name
19
+ * );
20
+ *
21
+ * if (isLoading) return <p>Loading...</p>;
22
+ * if (error) return <p>Error: {error.message}</p>;
23
+ *
24
+ * return (
25
+ * <div>
26
+ * <p>{data?.description}</p>
27
+ * <button onClick={() => updateDoc({ status: 'Closed' })}>
28
+ * Close
29
+ * </button>
30
+ * </div>
31
+ * );
32
+ * }
33
+ * ```
34
+ */
35
+ function useFrappeDoc(doctype, name, swrConfig) {
36
+ const client = (0, FrappeProvider_1.useFrappeClient)();
37
+ const key = doctype && name ? `frappe-doc:${doctype}:${name}` : null;
38
+ const { data, error, isLoading, isValidating, mutate } = (0, swr_1.default)(key, async () => {
39
+ if (!doctype || !name)
40
+ throw new Error('Doctype and name are required');
41
+ return client.getDoc({ doctype, name });
42
+ }, {
43
+ revalidateOnFocus: false,
44
+ ...swrConfig,
45
+ });
46
+ /**
47
+ * Update the current document and revalidate the cache.
48
+ */
49
+ const updateDoc = async (updates) => {
50
+ if (!doctype || !name)
51
+ throw new Error('Doctype and name are required');
52
+ const updated = await client.updateDoc({
53
+ doctype,
54
+ name,
55
+ data: updates,
56
+ });
57
+ mutate(updated, { revalidate: false });
58
+ return updated;
59
+ };
60
+ /**
61
+ * Delete the current document.
62
+ */
63
+ const deleteDoc = async () => {
64
+ if (!doctype || !name)
65
+ throw new Error('Doctype and name are required');
66
+ await client.deleteDoc(doctype, name);
67
+ mutate(undefined, { revalidate: false });
68
+ };
69
+ return {
70
+ data,
71
+ error: error,
72
+ isLoading,
73
+ isValidating,
74
+ mutate,
75
+ updateDoc,
76
+ deleteDoc,
77
+ };
78
+ }
79
+ //# sourceMappingURL=useFrappeDoc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFrappeDoc.js","sourceRoot":"","sources":["../../src/hooks/useFrappeDoc.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;AA+Bb,oCAqDC;AAlFD,8CAA+C;AAC/C,qDAAmD;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAgB,YAAY,CAC1B,OAAsB,EACtB,IAAmB,EACnB,SAA4B;IAE5B,MAAM,MAAM,GAAG,IAAA,gCAAe,GAAE,CAAC;IAEjC,MAAM,GAAG,GAAG,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,cAAc,OAAO,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAErE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,IAAA,aAAM,EAC7D,GAAG,EACH,KAAK,IAAI,EAAE;QACT,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACxE,OAAO,MAAM,CAAC,MAAM,CAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC,EACD;QACE,iBAAiB,EAAE,KAAK;QACxB,GAAG,SAAS;KACb,CACF,CAAC;IAEF;;OAEG;IACH,MAAM,SAAS,GAAG,KAAK,EAAE,OAAmB,EAAE,EAAE;QAC9C,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACxE,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,SAAS,CAAI;YACxC,OAAO;YACP,IAAI;YACJ,IAAI,EAAE,OAAkC;SACzC,CAAC,CAAC;QACH,MAAM,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QACvC,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;IAEF;;OAEG;IACH,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;QAC3B,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACxE,MAAM,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACtC,MAAM,CAAC,SAAS,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3C,CAAC,CAAC;IAEF,OAAO;QACL,IAAI;QACJ,KAAK,EAAE,KAA0B;QACjC,SAAS;QACT,YAAY;QACZ,MAAM;QACN,SAAS;QACT,SAAS;KACV,CAAC;AACJ,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { SWRConfiguration } from 'swr';
2
+ import { FrappeDoc, GetDocListParams } from '../client/types';
3
+ /**
4
+ * Hook to fetch a list of documents from Frappe.
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * function TodoList() {
9
+ * const { data, error, isLoading } = useFrappeDocList<{ description: string; status: string }>({
10
+ * doctype: 'ToDo',
11
+ * fields: ['name', 'description', 'status'],
12
+ * filters: [['status', '=', 'Open']],
13
+ * orderBy: { field: 'creation', order: 'desc' },
14
+ * limit: 20,
15
+ * });
16
+ *
17
+ * if (isLoading) return <p>Loading...</p>;
18
+ * if (error) return <p>Error: {error.message}</p>;
19
+ *
20
+ * return (
21
+ * <ul>
22
+ * {data?.map((todo) => (
23
+ * <li key={todo.name}>{todo.description} — {todo.status}</li>
24
+ * ))}
25
+ * </ul>
26
+ * );
27
+ * }
28
+ * ```
29
+ */
30
+ export declare function useFrappeDocList<T extends Record<string, unknown> = Record<string, unknown>>(params: GetDocListParams | null, swrConfig?: SWRConfiguration): {
31
+ data: FrappeDoc<T>[] | undefined;
32
+ error: Error | undefined;
33
+ isLoading: boolean;
34
+ isValidating: boolean;
35
+ mutate: import("swr").KeyedMutator<FrappeDoc<T>[]>;
36
+ };
37
+ //# sourceMappingURL=useFrappeDocList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFrappeDocList.d.ts","sourceRoot":"","sources":["../../src/hooks/useFrappeDocList.ts"],"names":[],"mappings":"AAEA,OAAe,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1F,MAAM,EAAE,gBAAgB,GAAG,IAAI,EAC/B,SAAS,CAAC,EAAE,gBAAgB;;WA6BV,KAAK,GAAG,SAAS;;;;EAKpC"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ 'use client';
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.useFrappeDocList = useFrappeDocList;
8
+ const swr_1 = __importDefault(require("swr"));
9
+ const FrappeProvider_1 = require("./FrappeProvider");
10
+ /**
11
+ * Hook to fetch a list of documents from Frappe.
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * function TodoList() {
16
+ * const { data, error, isLoading } = useFrappeDocList<{ description: string; status: string }>({
17
+ * doctype: 'ToDo',
18
+ * fields: ['name', 'description', 'status'],
19
+ * filters: [['status', '=', 'Open']],
20
+ * orderBy: { field: 'creation', order: 'desc' },
21
+ * limit: 20,
22
+ * });
23
+ *
24
+ * if (isLoading) return <p>Loading...</p>;
25
+ * if (error) return <p>Error: {error.message}</p>;
26
+ *
27
+ * return (
28
+ * <ul>
29
+ * {data?.map((todo) => (
30
+ * <li key={todo.name}>{todo.description} — {todo.status}</li>
31
+ * ))}
32
+ * </ul>
33
+ * );
34
+ * }
35
+ * ```
36
+ */
37
+ function useFrappeDocList(params, swrConfig) {
38
+ const client = (0, FrappeProvider_1.useFrappeClient)();
39
+ const key = params
40
+ ? `frappe-doclist:${params.doctype}:${JSON.stringify({
41
+ fields: params.fields,
42
+ filters: params.filters,
43
+ orderBy: params.orderBy,
44
+ limit: params.limit,
45
+ offset: params.offset,
46
+ groupBy: params.groupBy,
47
+ })}`
48
+ : null;
49
+ const { data, error, isLoading, isValidating, mutate } = (0, swr_1.default)(key, async () => {
50
+ if (!params)
51
+ throw new Error('No params provided');
52
+ return client.getDocList(params);
53
+ }, {
54
+ revalidateOnFocus: false,
55
+ ...swrConfig,
56
+ });
57
+ return {
58
+ data,
59
+ error: error,
60
+ isLoading,
61
+ isValidating,
62
+ mutate,
63
+ };
64
+ }
65
+ //# sourceMappingURL=useFrappeDocList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFrappeDocList.js","sourceRoot":"","sources":["../../src/hooks/useFrappeDocList.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;AAiCb,4CAoCC;AAnED,8CAA+C;AAC/C,qDAAmD;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,gBAAgB,CAC9B,MAA+B,EAC/B,SAA4B;IAE5B,MAAM,MAAM,GAAG,IAAA,gCAAe,GAAE,CAAC;IAEjC,MAAM,GAAG,GAAG,MAAM;QAChB,CAAC,CAAC,kBAAkB,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC;YACjD,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC,EAAE;QACN,CAAC,CAAC,IAAI,CAAC;IAET,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,IAAA,aAAM,EAC7D,GAAG,EACH,KAAK,IAAI,EAAE;QACT,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACnD,OAAO,MAAM,CAAC,UAAU,CAAI,MAAM,CAAC,CAAC;IACtC,CAAC,EACD;QACE,iBAAiB,EAAE,KAAK;QACxB,GAAG,SAAS;KACb,CACF,CAAC;IAEF,OAAO;QACL,IAAI;QACJ,KAAK,EAAE,KAA0B;QACjC,SAAS;QACT,YAAY;QACZ,MAAM;KACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { FileUploadOptions, FileUploadResponse } from '../client/types';
2
+ /**
3
+ * Hook to upload files to Frappe with progress tracking.
4
+ *
5
+ * @example
6
+ * ```tsx
7
+ * function FileUploader({ doctype, docname }: { doctype: string; docname: string }) {
8
+ * const { upload, isUploading, progress, result, error, reset } = useFrappeFileUpload();
9
+ *
10
+ * const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
11
+ * const file = e.target.files?.[0];
12
+ * if (file) {
13
+ * upload({ file, doctype, docname, isPrivate: true });
14
+ * }
15
+ * };
16
+ *
17
+ * return (
18
+ * <div>
19
+ * <input type="file" onChange={handleChange} disabled={isUploading} />
20
+ * {isUploading && <progress value={progress} max={100} />}
21
+ * {result && <a href={result.file_url}>Uploaded: {result.file_name}</a>}
22
+ * {error && <p>Error: {error.message}</p>}
23
+ * </div>
24
+ * );
25
+ * }
26
+ * ```
27
+ */
28
+ export declare function useFrappeFileUpload(): {
29
+ /** Whether an upload is in progress */
30
+ isUploading: boolean;
31
+ /** Upload progress percentage (0-100) */
32
+ progress: number;
33
+ /** Upload error, if any */
34
+ error: Error | null;
35
+ /** Last successful upload result */
36
+ result: FileUploadResponse | null;
37
+ upload: (options: Omit<FileUploadOptions, "onProgress">) => Promise<FileUploadResponse>;
38
+ reset: () => void;
39
+ };
40
+ //# sourceMappingURL=useFrappeFileUpload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFrappeFileUpload.d.ts","sourceRoot":"","sources":["../../src/hooks/useFrappeFileUpload.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAaxE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,mBAAmB;IApCjC,uCAAuC;iBAC1B,OAAO;IACpB,yCAAyC;cAC/B,MAAM;IAChB,2BAA2B;WACpB,KAAK,GAAG,IAAI;IACnB,oCAAoC;YAC5B,kBAAkB,GAAG,IAAI;sBAwCf,IAAI,CAAC,iBAAiB,EAAE,YAAY,CAAC;;EA+BxD"}