@lasterp/shared 1.0.0-alpha.7 → 1.0.0-alpha.9

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.
@@ -41,6 +41,15 @@ interface FrappeConfig {
41
41
  enableSocket?: boolean;
42
42
  socketPort?: string;
43
43
  }
44
+ interface FrappeError {
45
+ httpStatus: number;
46
+ httpStatusText: string;
47
+ message: string;
48
+ exception: string;
49
+ exc_type?: string;
50
+ traceback?: string;
51
+ _server_messages?: string;
52
+ }
44
53
  interface TokenParams {
45
54
  /** Whether to use token for API calls */
46
55
  useToken: boolean;
@@ -119,11 +128,19 @@ declare const useFrappeGetCall: <T = any>(method: string, params?: Record<string
119
128
  retry?: boolean | number;
120
129
  }, type?: "GET" | "POST") => {
121
130
  data: T | undefined;
122
- error: Error | null;
131
+ error: FrappeError | null;
123
132
  isLoading: boolean;
124
133
  isFetching: boolean;
125
134
  refetch: () => void;
126
135
  };
136
+ interface FrappeMutationResult<T = any> {
137
+ call: (params: Record<string, any>) => Promise<T>;
138
+ result: T | null;
139
+ loading: boolean;
140
+ error: FrappeError | null;
141
+ isCompleted: boolean;
142
+ reset: () => void;
143
+ }
127
144
  /**
128
145
  *
129
146
  * @param method - name of the method to call (POST request) (will be dotted path e.g. "frappe.client.set_value")
@@ -138,7 +155,7 @@ declare const useFrappeGetCall: <T = any>(method: string, params?: Record<string
138
155
  * }
139
156
  *
140
157
  */
141
- declare const useFrappePostCall: unknown;
158
+ declare const useFrappePostCall: <T = any>(method: string) => FrappeMutationResult<T>;
142
159
  /**
143
160
  *
144
161
  * @param method - name of the method to call (PUT request) (will be dotted path e.g. "frappe.client.set_value")
@@ -152,7 +169,7 @@ declare const useFrappePostCall: unknown;
152
169
  * const message = await call({ doctype: "User", docname: "test@example.com", fieldname: "full_name", value: "John Doe" })
153
170
  * }
154
171
  */
155
- declare const useFrappePutCall: unknown;
172
+ declare const useFrappePutCall: <T = any>(method: string) => FrappeMutationResult<T>;
156
173
  /**
157
174
  *
158
175
  * @param method - name of the method to call (DELETE request) (will be dotted path e.g. "frappe.client.delete")
@@ -166,7 +183,7 @@ declare const useFrappePutCall: unknown;
166
183
  * const message = await call({ doctype: "User", docname: "test@example.com" })
167
184
  * }
168
185
  */
169
- declare const useFrappeDeleteCall: unknown;
186
+ declare const useFrappeDeleteCall: <T = any>(method: string) => FrappeMutationResult<T>;
170
187
  import { Filter } from "frappe-js-sdk/lib/db/types";
171
188
  /**
172
189
  * Hook to fetch number of documents from the database
@@ -188,7 +205,7 @@ declare const useFrappeGetDocCount: <T = any>(doctype: string, filters?: Filter<
188
205
  retry?: boolean | number;
189
206
  }) => {
190
207
  data: number | undefined;
191
- error: Error | null;
208
+ error: FrappeError | null;
192
209
  isLoading: boolean;
193
210
  isFetching: boolean;
194
211
  refetch: () => void;
@@ -209,7 +226,7 @@ import { FrappeDoc } from "frappe-js-sdk/lib/db/types";
209
226
  declare const useFrappeCreateDoc: <T = any>() => {
210
227
  createDoc: (doctype: string, doc: T) => Promise<FrappeDoc<T>>;
211
228
  loading: boolean;
212
- error: Error | null | undefined;
229
+ error: FrappeError | null;
213
230
  isCompleted: boolean;
214
231
  reset: () => void;
215
232
  };
@@ -230,7 +247,7 @@ declare const useFrappeDeleteDoc: <T = any>() => {
230
247
  message: string;
231
248
  }>;
232
249
  loading: boolean;
233
- error: Error | null | undefined;
250
+ error: FrappeError | null;
234
251
  isCompleted: boolean;
235
252
  reset: () => void;
236
253
  };
@@ -382,7 +399,7 @@ declare const useFrappeGetDoc: <T = any>(doctype: string, name?: string, options
382
399
  retry?: boolean | number;
383
400
  }) => {
384
401
  data: FrappeDoc2<T> | undefined;
385
- error: Error | null;
402
+ error: FrappeError | null;
386
403
  isLoading: boolean;
387
404
  isFetching: boolean;
388
405
  refetch: () => void;
@@ -421,7 +438,7 @@ declare const useFrappeGetDocList: <
421
438
  retry?: boolean | number;
422
439
  }) => {
423
440
  data: T[] | undefined;
424
- error: Error | null;
441
+ error: FrappeError | null;
425
442
  isLoading: boolean;
426
443
  isFetching: boolean;
427
444
  refetch: () => void;
@@ -471,7 +488,7 @@ declare const useSearch: (doctype: string, text: string, filters?: Filter2[], li
471
488
  data: {
472
489
  message: SearchResult[];
473
490
  } | undefined;
474
- error: Error | null;
491
+ error: FrappeError | null;
475
492
  isLoading: boolean;
476
493
  isFetching: boolean;
477
494
  refetch: () => void;
@@ -492,7 +509,7 @@ import { FrappeDoc as FrappeDoc4 } from "frappe-js-sdk/lib/db/types";
492
509
  declare const useFrappeUpdateDoc: <T = any>() => {
493
510
  updateDoc: (doctype: string, docname: string | null, doc: Partial<T>) => Promise<FrappeDoc4<T>>;
494
511
  loading: boolean;
495
- error: Error | null | undefined;
512
+ error: FrappeError | null;
496
513
  isCompleted: boolean;
497
514
  reset: () => void;
498
515
  };
@@ -571,4 +588,4 @@ interface Page {
571
588
  }
572
589
  import { camelize, decamelize, camelizeKeys, decamelizeKeys } from "humps";
573
590
  declare function equalsIgnoreCase(str1: string, str2: string): boolean;
574
- export { useSearch, useFrappeUpdateDoc, useFrappePutCall, useFrappePrefetchDoc, useFrappePostCall, useFrappeGetDocList, useFrappeGetDocCount, useFrappeGetDoc, useFrappeGetCall, useFrappeFileUpload, useFrappeEventListener, useFrappeDocumentEventListener, useFrappeDocTypeEventListener, useFrappeDeleteDoc, useFrappeDeleteCall, useFrappeCreateDoc, useFrappeAuth, equalsIgnoreCase, decamelizeKeys, decamelize, camelizeKeys, camelize, ViewerEventData, UseFrappeFileUploadReturnType, TopbarItem, Topbar, TokenParams, SearchResult, Page, NavbarSubItemGroup, NavbarSubItem, NavbarItem, Model, ItemVariant, Item, Hero, Header, Globals, FrappeProviderProps, FrappeProvider, FrappeFileUploadResponse, FrappeContext, FrappeConfig, FooterItemGroup, FooterItem, Footer, DocumentUpdateEventData, DocTypeListUpdateEventData, Colour, Brand, Block };
591
+ export { useSearch, useFrappeUpdateDoc, useFrappePutCall, useFrappePrefetchDoc, useFrappePostCall, useFrappeGetDocList, useFrappeGetDocCount, useFrappeGetDoc, useFrappeGetCall, useFrappeFileUpload, useFrappeEventListener, useFrappeDocumentEventListener, useFrappeDocTypeEventListener, useFrappeDeleteDoc, useFrappeDeleteCall, useFrappeCreateDoc, useFrappeAuth, equalsIgnoreCase, decamelizeKeys, decamelize, camelizeKeys, camelize, ViewerEventData, UseFrappeFileUploadReturnType, TopbarItem, Topbar, TokenParams, SearchResult, Page, NavbarSubItemGroup, NavbarSubItem, NavbarItem, Model, ItemVariant, Item, Hero, Header, Globals, FrappeProviderProps, FrappeProvider, FrappeMutationResult, FrappeFileUploadResponse, FrappeError, FrappeContext, FrappeConfig, FooterItemGroup, FooterItem, Footer, DocumentUpdateEventData, DocTypeListUpdateEventData, Colour, Brand, Block };
@@ -41,6 +41,15 @@ interface FrappeConfig {
41
41
  enableSocket?: boolean;
42
42
  socketPort?: string;
43
43
  }
44
+ interface FrappeError {
45
+ httpStatus: number;
46
+ httpStatusText: string;
47
+ message: string;
48
+ exception: string;
49
+ exc_type?: string;
50
+ traceback?: string;
51
+ _server_messages?: string;
52
+ }
44
53
  interface TokenParams {
45
54
  /** Whether to use token for API calls */
46
55
  useToken: boolean;
@@ -119,11 +128,19 @@ declare const useFrappeGetCall: <T = any>(method: string, params?: Record<string
119
128
  retry?: boolean | number;
120
129
  }, type?: "GET" | "POST") => {
121
130
  data: T | undefined;
122
- error: Error | null;
131
+ error: FrappeError | null;
123
132
  isLoading: boolean;
124
133
  isFetching: boolean;
125
134
  refetch: () => void;
126
135
  };
136
+ interface FrappeMutationResult<T = any> {
137
+ call: (params: Record<string, any>) => Promise<T>;
138
+ result: T | null;
139
+ loading: boolean;
140
+ error: FrappeError | null;
141
+ isCompleted: boolean;
142
+ reset: () => void;
143
+ }
127
144
  /**
128
145
  *
129
146
  * @param method - name of the method to call (POST request) (will be dotted path e.g. "frappe.client.set_value")
@@ -138,7 +155,7 @@ declare const useFrappeGetCall: <T = any>(method: string, params?: Record<string
138
155
  * }
139
156
  *
140
157
  */
141
- declare const useFrappePostCall: unknown;
158
+ declare const useFrappePostCall: <T = any>(method: string) => FrappeMutationResult<T>;
142
159
  /**
143
160
  *
144
161
  * @param method - name of the method to call (PUT request) (will be dotted path e.g. "frappe.client.set_value")
@@ -152,7 +169,7 @@ declare const useFrappePostCall: unknown;
152
169
  * const message = await call({ doctype: "User", docname: "test@example.com", fieldname: "full_name", value: "John Doe" })
153
170
  * }
154
171
  */
155
- declare const useFrappePutCall: unknown;
172
+ declare const useFrappePutCall: <T = any>(method: string) => FrappeMutationResult<T>;
156
173
  /**
157
174
  *
158
175
  * @param method - name of the method to call (DELETE request) (will be dotted path e.g. "frappe.client.delete")
@@ -166,7 +183,7 @@ declare const useFrappePutCall: unknown;
166
183
  * const message = await call({ doctype: "User", docname: "test@example.com" })
167
184
  * }
168
185
  */
169
- declare const useFrappeDeleteCall: unknown;
186
+ declare const useFrappeDeleteCall: <T = any>(method: string) => FrappeMutationResult<T>;
170
187
  import { Filter } from "frappe-js-sdk/lib/db/types";
171
188
  /**
172
189
  * Hook to fetch number of documents from the database
@@ -188,7 +205,7 @@ declare const useFrappeGetDocCount: <T = any>(doctype: string, filters?: Filter<
188
205
  retry?: boolean | number;
189
206
  }) => {
190
207
  data: number | undefined;
191
- error: Error | null;
208
+ error: FrappeError | null;
192
209
  isLoading: boolean;
193
210
  isFetching: boolean;
194
211
  refetch: () => void;
@@ -209,7 +226,7 @@ import { FrappeDoc } from "frappe-js-sdk/lib/db/types";
209
226
  declare const useFrappeCreateDoc: <T = any>() => {
210
227
  createDoc: (doctype: string, doc: T) => Promise<FrappeDoc<T>>;
211
228
  loading: boolean;
212
- error: Error | null | undefined;
229
+ error: FrappeError | null;
213
230
  isCompleted: boolean;
214
231
  reset: () => void;
215
232
  };
@@ -230,7 +247,7 @@ declare const useFrappeDeleteDoc: <T = any>() => {
230
247
  message: string;
231
248
  }>;
232
249
  loading: boolean;
233
- error: Error | null | undefined;
250
+ error: FrappeError | null;
234
251
  isCompleted: boolean;
235
252
  reset: () => void;
236
253
  };
@@ -382,7 +399,7 @@ declare const useFrappeGetDoc: <T = any>(doctype: string, name?: string, options
382
399
  retry?: boolean | number;
383
400
  }) => {
384
401
  data: FrappeDoc2<T> | undefined;
385
- error: Error | null;
402
+ error: FrappeError | null;
386
403
  isLoading: boolean;
387
404
  isFetching: boolean;
388
405
  refetch: () => void;
@@ -421,7 +438,7 @@ declare const useFrappeGetDocList: <
421
438
  retry?: boolean | number;
422
439
  }) => {
423
440
  data: T[] | undefined;
424
- error: Error | null;
441
+ error: FrappeError | null;
425
442
  isLoading: boolean;
426
443
  isFetching: boolean;
427
444
  refetch: () => void;
@@ -471,7 +488,7 @@ declare const useSearch: (doctype: string, text: string, filters?: Filter2[], li
471
488
  data: {
472
489
  message: SearchResult[];
473
490
  } | undefined;
474
- error: Error | null;
491
+ error: FrappeError | null;
475
492
  isLoading: boolean;
476
493
  isFetching: boolean;
477
494
  refetch: () => void;
@@ -492,7 +509,7 @@ import { FrappeDoc as FrappeDoc4 } from "frappe-js-sdk/lib/db/types";
492
509
  declare const useFrappeUpdateDoc: <T = any>() => {
493
510
  updateDoc: (doctype: string, docname: string | null, doc: Partial<T>) => Promise<FrappeDoc4<T>>;
494
511
  loading: boolean;
495
- error: Error | null | undefined;
512
+ error: FrappeError | null;
496
513
  isCompleted: boolean;
497
514
  reset: () => void;
498
515
  };
@@ -571,4 +588,4 @@ interface Page {
571
588
  }
572
589
  import { camelize, decamelize, camelizeKeys, decamelizeKeys } from "humps";
573
590
  declare function equalsIgnoreCase(str1: string, str2: string): boolean;
574
- export { useSearch, useFrappeUpdateDoc, useFrappePutCall, useFrappePrefetchDoc, useFrappePostCall, useFrappeGetDocList, useFrappeGetDocCount, useFrappeGetDoc, useFrappeGetCall, useFrappeFileUpload, useFrappeEventListener, useFrappeDocumentEventListener, useFrappeDocTypeEventListener, useFrappeDeleteDoc, useFrappeDeleteCall, useFrappeCreateDoc, useFrappeAuth, equalsIgnoreCase, decamelizeKeys, decamelize, camelizeKeys, camelize, ViewerEventData, UseFrappeFileUploadReturnType, TopbarItem, Topbar, TokenParams, SearchResult, Page, NavbarSubItemGroup, NavbarSubItem, NavbarItem, Model, ItemVariant, Item, Hero, Header, Globals, FrappeProviderProps, FrappeProvider, FrappeFileUploadResponse, FrappeContext, FrappeConfig, FooterItemGroup, FooterItem, Footer, DocumentUpdateEventData, DocTypeListUpdateEventData, Colour, Brand, Block };
591
+ export { useSearch, useFrappeUpdateDoc, useFrappePutCall, useFrappePrefetchDoc, useFrappePostCall, useFrappeGetDocList, useFrappeGetDocCount, useFrappeGetDoc, useFrappeGetCall, useFrappeFileUpload, useFrappeEventListener, useFrappeDocumentEventListener, useFrappeDocTypeEventListener, useFrappeDeleteDoc, useFrappeDeleteCall, useFrappeCreateDoc, useFrappeAuth, equalsIgnoreCase, decamelizeKeys, decamelize, camelizeKeys, camelize, ViewerEventData, UseFrappeFileUploadReturnType, TopbarItem, Topbar, TokenParams, SearchResult, Page, NavbarSubItemGroup, NavbarSubItem, NavbarItem, Model, ItemVariant, Item, Hero, Header, Globals, FrappeProviderProps, FrappeProvider, FrappeMutationResult, FrappeFileUploadResponse, FrappeError, FrappeContext, FrappeConfig, FooterItemGroup, FooterItem, Footer, DocumentUpdateEventData, DocTypeListUpdateEventData, Colour, Brand, Block };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lasterp/shared",
3
- "version": "1.0.0-alpha.7",
3
+ "version": "1.0.0-alpha.9",
4
4
  "description": "Shared repo for webapp and native app",
5
5
  "license": "MIT",
6
6
  "files": [