@lasterp/shared 1.0.0-alpha.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.
- package/dist/index.cjs +387 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +298 -0
- package/dist/index.d.ts +298 -0
- package/dist/index.js +339 -0
- package/dist/index.js.map +1 -0
- package/package.json +50 -0
- package/src/client/context.tsx +74 -0
- package/src/client/core.ts +261 -0
- package/src/client/hooks.tsx +57 -0
- package/src/client/index.ts +21 -0
- package/src/client/storage.ts +76 -0
- package/src/client/types.ts +24 -0
- package/src/common/index.ts +1 -0
- package/src/common/types.ts +15 -0
- package/src/design/block/types.ts +8 -0
- package/src/design/globals/footer.ts +20 -0
- package/src/design/globals/header.ts +43 -0
- package/src/design/globals/types.ts +7 -0
- package/src/design/index.ts +8 -0
- package/src/design/page/api.ts +11 -0
- package/src/design/page/types.ts +15 -0
- package/src/index.ts +5 -0
- package/src/lasterp/catalog/types.ts +24 -0
- package/src/lasterp/index.ts +5 -0
- package/src/lasterp/shop/api.ts +32 -0
- package/src/lasterp/shop/hooks.tsx +42 -0
- package/src/lasterp/shop/types.ts +42 -0
- package/src/utils/catalog.ts +8 -0
- package/src/utils/index.ts +10 -0
- package/src/utils/types.ts +3 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export { decamelize as camelToSnake, decamelizeKeys as objectCamelToSnake, camelizeKeys as objectSnakeToCamel, camelize as snakeToCamel } from 'humps';
|
|
4
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
5
|
+
import { UseQueryOptions } from '@tanstack/react-query';
|
|
6
|
+
|
|
7
|
+
interface FrappeDoc {
|
|
8
|
+
name: string;
|
|
9
|
+
creation?: string;
|
|
10
|
+
modified?: string;
|
|
11
|
+
modifiedBy?: string;
|
|
12
|
+
owner?: string;
|
|
13
|
+
docStatus?: number;
|
|
14
|
+
idx?: number;
|
|
15
|
+
}
|
|
16
|
+
interface FrappeChildDoc extends FrappeDoc {
|
|
17
|
+
parent: string;
|
|
18
|
+
parentType: string;
|
|
19
|
+
parentField: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface FrappeResponse<T = any> {
|
|
23
|
+
message?: T;
|
|
24
|
+
docs?: T[];
|
|
25
|
+
exc?: string;
|
|
26
|
+
exc_type?: string;
|
|
27
|
+
_server_messages?: string;
|
|
28
|
+
_error_message?: string;
|
|
29
|
+
}
|
|
30
|
+
interface FrappeError {
|
|
31
|
+
message: string;
|
|
32
|
+
statusCode?: number;
|
|
33
|
+
exc?: string;
|
|
34
|
+
excType?: string;
|
|
35
|
+
serverMessages?: string;
|
|
36
|
+
}
|
|
37
|
+
interface AuthOptions {
|
|
38
|
+
token?: string;
|
|
39
|
+
apiKey?: {
|
|
40
|
+
key: string;
|
|
41
|
+
secret: string;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare function frappeCall<T = any>(baseUrl: string, method: string, args?: Record<string, any>, auth?: AuthOptions): Promise<T>;
|
|
46
|
+
declare function frappeCallGet<T = any>(baseUrl: string, method: string, args?: Record<string, any>, auth?: AuthOptions): Promise<T>;
|
|
47
|
+
declare function getList<T = any>(baseUrl: string, params: {
|
|
48
|
+
doctype: string;
|
|
49
|
+
fields?: string[];
|
|
50
|
+
filters?: Record<string, any>;
|
|
51
|
+
orderBy?: string;
|
|
52
|
+
limitStart?: number;
|
|
53
|
+
limitPageLength?: number;
|
|
54
|
+
}, auth?: AuthOptions): Promise<T[]>;
|
|
55
|
+
declare function getDoc<T = any>(baseUrl: string, doctype: string, name: string, auth?: AuthOptions): Promise<T>;
|
|
56
|
+
declare function createDoc<T = any>(baseUrl: string, doctype: string, doc: Record<string, any>, auth?: AuthOptions): Promise<T>;
|
|
57
|
+
declare function updateDoc<T = any>(baseUrl: string, doctype: string, name: string, doc: Record<string, any>, auth?: AuthOptions): Promise<T>;
|
|
58
|
+
declare function deleteDoc(baseUrl: string, doctype: string, name: string, auth?: AuthOptions): Promise<void>;
|
|
59
|
+
declare function getValue<T = any>(baseUrl: string, doctype: string, name: string, fieldname: string, auth?: AuthOptions): Promise<T>;
|
|
60
|
+
declare function setValue<T = any>(baseUrl: string, doctype: string, name: string, fieldname: string, value: any, auth?: AuthOptions): Promise<T>;
|
|
61
|
+
declare function getCount(baseUrl: string, doctype: string, filters?: Record<string, any>, auth?: AuthOptions): Promise<number>;
|
|
62
|
+
declare function getCurrentUser(baseUrl: string, auth?: AuthOptions): Promise<any>;
|
|
63
|
+
|
|
64
|
+
interface FrappeContextValue {
|
|
65
|
+
baseUrl: string;
|
|
66
|
+
token?: string;
|
|
67
|
+
apiKey?: {
|
|
68
|
+
key: string;
|
|
69
|
+
secret: string;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
interface FrappeProviderProps {
|
|
73
|
+
baseUrl: string;
|
|
74
|
+
token?: string;
|
|
75
|
+
apiKey?: {
|
|
76
|
+
key: string;
|
|
77
|
+
secret: string;
|
|
78
|
+
};
|
|
79
|
+
autoLoadAuth?: boolean;
|
|
80
|
+
onLoadAuth?: () => Promise<{
|
|
81
|
+
token?: string;
|
|
82
|
+
apiKey?: {
|
|
83
|
+
key: string;
|
|
84
|
+
secret: string;
|
|
85
|
+
};
|
|
86
|
+
}> | {
|
|
87
|
+
token?: string;
|
|
88
|
+
apiKey?: {
|
|
89
|
+
key: string;
|
|
90
|
+
secret: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
children: ReactNode;
|
|
94
|
+
}
|
|
95
|
+
declare function FrappeProvider({ baseUrl, token: initialToken, apiKey: initialApiKey, autoLoadAuth, onLoadAuth, children, }: FrappeProviderProps): react_jsx_runtime.JSX.Element;
|
|
96
|
+
declare function useFrappeConfig(): FrappeContextValue;
|
|
97
|
+
|
|
98
|
+
declare function useFrappe(): {
|
|
99
|
+
call: <T = any>(method: string, args?: Record<string, any>) => Promise<T>;
|
|
100
|
+
callGet: <T = any>(method: string, args?: Record<string, any>) => Promise<T>;
|
|
101
|
+
getList: <T = any>(params: {
|
|
102
|
+
doctype: string;
|
|
103
|
+
fields?: string[];
|
|
104
|
+
filters?: Record<string, any>;
|
|
105
|
+
orderBy?: string;
|
|
106
|
+
limitStart?: number;
|
|
107
|
+
limitPageLength?: number;
|
|
108
|
+
}) => Promise<T[]>;
|
|
109
|
+
getDoc: <T = any>(doctype: string, name: string) => Promise<T>;
|
|
110
|
+
createDoc: <T = any>(doctype: string, doc: Record<string, any>) => Promise<T>;
|
|
111
|
+
updateDoc: <T = any>(doctype: string, name: string, doc: Record<string, any>) => Promise<T>;
|
|
112
|
+
deleteDoc: (doctype: string, name: string) => Promise<void>;
|
|
113
|
+
baseUrl: string;
|
|
114
|
+
auth: AuthOptions;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
interface StorageAdapter {
|
|
118
|
+
getItem(key: string): string | null | Promise<string | null>;
|
|
119
|
+
setItem(key: string, value: string): void | Promise<void>;
|
|
120
|
+
removeItem(key: string): void | Promise<void>;
|
|
121
|
+
}
|
|
122
|
+
declare const webStorageAdapter: StorageAdapter;
|
|
123
|
+
declare function setStorageAdapter(adapter: StorageAdapter): void;
|
|
124
|
+
declare function getStorageAdapter(): StorageAdapter;
|
|
125
|
+
declare function getToken(): string | null | Promise<string | null>;
|
|
126
|
+
declare function setToken(token: string): void | Promise<void>;
|
|
127
|
+
declare function clearToken(): void | Promise<void>;
|
|
128
|
+
declare function getApiKey(): Promise<{
|
|
129
|
+
key: string;
|
|
130
|
+
secret: string;
|
|
131
|
+
} | null>;
|
|
132
|
+
declare function setApiKey(key: string, secret: string): Promise<void>;
|
|
133
|
+
declare function clearApiKey(): Promise<void>;
|
|
134
|
+
declare function clearAuth(): Promise<void>;
|
|
135
|
+
declare function isAuthenticated(): Promise<boolean>;
|
|
136
|
+
|
|
137
|
+
interface Brand {
|
|
138
|
+
brandImage?: string;
|
|
139
|
+
}
|
|
140
|
+
interface NavbarItem {
|
|
141
|
+
label: string;
|
|
142
|
+
enableDropdown: boolean;
|
|
143
|
+
enableLink: boolean;
|
|
144
|
+
link?: string;
|
|
145
|
+
dropdownDescription?: string;
|
|
146
|
+
dropdownCta?: string;
|
|
147
|
+
groups?: NavbarSubItemGroup[];
|
|
148
|
+
}
|
|
149
|
+
interface NavbarSubItemGroup {
|
|
150
|
+
title?: string;
|
|
151
|
+
items: NavbarSubItem[];
|
|
152
|
+
}
|
|
153
|
+
interface NavbarSubItem {
|
|
154
|
+
label: string;
|
|
155
|
+
description?: string;
|
|
156
|
+
image?: string;
|
|
157
|
+
link?: string;
|
|
158
|
+
}
|
|
159
|
+
interface Topbar {
|
|
160
|
+
topbarEnabled?: boolean;
|
|
161
|
+
items: TopbarItem[];
|
|
162
|
+
}
|
|
163
|
+
interface TopbarItem {
|
|
164
|
+
icon?: string;
|
|
165
|
+
label: string;
|
|
166
|
+
link?: string;
|
|
167
|
+
}
|
|
168
|
+
interface Header {
|
|
169
|
+
brand: Brand;
|
|
170
|
+
headerType?: string;
|
|
171
|
+
tabs: NavbarItem[];
|
|
172
|
+
topbar: Topbar;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
interface FooterItemGroup {
|
|
176
|
+
title: string;
|
|
177
|
+
items: FooterItem[];
|
|
178
|
+
}
|
|
179
|
+
interface FooterItem {
|
|
180
|
+
label: string;
|
|
181
|
+
link?: string;
|
|
182
|
+
}
|
|
183
|
+
interface Footer {
|
|
184
|
+
footerType?: string;
|
|
185
|
+
groups: FooterItemGroup[];
|
|
186
|
+
copyright?: string;
|
|
187
|
+
address?: string;
|
|
188
|
+
country?: string;
|
|
189
|
+
phone?: string;
|
|
190
|
+
email?: string;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
interface Globals {
|
|
194
|
+
header: Header;
|
|
195
|
+
footer: Footer;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
interface Hero {
|
|
199
|
+
type: string;
|
|
200
|
+
data: Record<string, unknown>;
|
|
201
|
+
}
|
|
202
|
+
interface Block {
|
|
203
|
+
type: string;
|
|
204
|
+
data?: Record<string, unknown>;
|
|
205
|
+
}
|
|
206
|
+
interface Page {
|
|
207
|
+
slug: string;
|
|
208
|
+
hero?: Hero;
|
|
209
|
+
blocks: Block[];
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
declare function getPage(baseUrl: string, slug: string, auth?: AuthOptions): Promise<Page>;
|
|
213
|
+
|
|
214
|
+
interface AaveFeatureSlidesData {
|
|
215
|
+
feature1Title: string;
|
|
216
|
+
feature1Description: string;
|
|
217
|
+
feature1Cta?: string;
|
|
218
|
+
feature2Title: string;
|
|
219
|
+
feature2Description: string;
|
|
220
|
+
feature2Cta?: string;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
interface Item {
|
|
224
|
+
itemCode: string;
|
|
225
|
+
region: string;
|
|
226
|
+
grade: string;
|
|
227
|
+
gradeIssuer: string;
|
|
228
|
+
color: string;
|
|
229
|
+
storage: string;
|
|
230
|
+
memory: string;
|
|
231
|
+
network: string;
|
|
232
|
+
}
|
|
233
|
+
interface ItemVariant extends Item {
|
|
234
|
+
itemVariant: string;
|
|
235
|
+
}
|
|
236
|
+
interface ModelNumber {
|
|
237
|
+
modelNumber: string;
|
|
238
|
+
simCardType: string;
|
|
239
|
+
}
|
|
240
|
+
interface Colour {
|
|
241
|
+
name: string;
|
|
242
|
+
color: string;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
interface Category {
|
|
246
|
+
name: string;
|
|
247
|
+
categoryName: string;
|
|
248
|
+
sequenceId: number;
|
|
249
|
+
itemCode: string[];
|
|
250
|
+
itemGroup: string[];
|
|
251
|
+
brand: string[];
|
|
252
|
+
os: string[];
|
|
253
|
+
}
|
|
254
|
+
interface Product extends Item {
|
|
255
|
+
name: string;
|
|
256
|
+
image: string;
|
|
257
|
+
}
|
|
258
|
+
interface ProductVariant extends ItemVariant {
|
|
259
|
+
id: string;
|
|
260
|
+
specs: Record<string, string>;
|
|
261
|
+
price: number;
|
|
262
|
+
stock: number;
|
|
263
|
+
}
|
|
264
|
+
interface ShopContext {
|
|
265
|
+
title?: string;
|
|
266
|
+
categories?: Category[];
|
|
267
|
+
selectedCategory?: Category;
|
|
268
|
+
grades?: string[];
|
|
269
|
+
selectedGrade?: string;
|
|
270
|
+
products: Product[];
|
|
271
|
+
}
|
|
272
|
+
interface ProductContext {
|
|
273
|
+
currency: string;
|
|
274
|
+
product: Product;
|
|
275
|
+
specs: Record<string, string[]>;
|
|
276
|
+
variants: ProductVariant[];
|
|
277
|
+
modelNumbers: Record<string, ModelNumber>;
|
|
278
|
+
colours: Record<string, Colour>;
|
|
279
|
+
variantImages: Record<string, string[]>;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
declare function getShopContext(baseUrl: string, params?: {
|
|
283
|
+
categoryName?: string;
|
|
284
|
+
gradeName?: string;
|
|
285
|
+
}, auth?: AuthOptions): Promise<ShopContext>;
|
|
286
|
+
declare function getProductContext(baseUrl: string, productName: string, auth?: AuthOptions): Promise<ProductContext>;
|
|
287
|
+
|
|
288
|
+
declare function useShopContext(params?: {
|
|
289
|
+
categoryName?: string;
|
|
290
|
+
gradeName?: string;
|
|
291
|
+
}, options?: Omit<UseQueryOptions<ShopContext, Error>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<ShopContext, Error>;
|
|
292
|
+
declare function useProductContext(productName: string, options?: Omit<UseQueryOptions<ProductContext, Error>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<ProductContext, Error>;
|
|
293
|
+
|
|
294
|
+
declare function toDescription(modelNumber: ModelNumber): string | null;
|
|
295
|
+
|
|
296
|
+
declare function equalsIgnoreCase(str1: string, str2: string): boolean;
|
|
297
|
+
|
|
298
|
+
export { type AaveFeatureSlidesData, type AuthOptions, type Block, type Brand, type Category, type Colour, type Footer, type FooterItem, type FooterItemGroup, type FrappeChildDoc, type FrappeContextValue, type FrappeDoc, type FrappeError, FrappeProvider, type FrappeProviderProps, type FrappeResponse, type Globals, type Header, type Hero, type Item, type ItemVariant, type ModelNumber, type NavbarItem, type NavbarSubItem, type NavbarSubItemGroup, type Page, type Product, type ProductContext, type ProductVariant, type ShopContext, type StorageAdapter, type Topbar, type TopbarItem, clearApiKey, clearAuth, clearToken, createDoc, deleteDoc, equalsIgnoreCase, frappeCall, frappeCallGet, getApiKey, getCount, getCurrentUser, getDoc, getList, getPage, getProductContext, getShopContext, getStorageAdapter, getToken, getValue, isAuthenticated, setApiKey, setStorageAdapter, setToken, setValue, toDescription, updateDoc, useFrappe, useFrappeConfig, useProductContext, useShopContext, webStorageAdapter };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export { decamelize as camelToSnake, decamelizeKeys as objectCamelToSnake, camelizeKeys as objectSnakeToCamel, camelize as snakeToCamel } from 'humps';
|
|
4
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
5
|
+
import { UseQueryOptions } from '@tanstack/react-query';
|
|
6
|
+
|
|
7
|
+
interface FrappeDoc {
|
|
8
|
+
name: string;
|
|
9
|
+
creation?: string;
|
|
10
|
+
modified?: string;
|
|
11
|
+
modifiedBy?: string;
|
|
12
|
+
owner?: string;
|
|
13
|
+
docStatus?: number;
|
|
14
|
+
idx?: number;
|
|
15
|
+
}
|
|
16
|
+
interface FrappeChildDoc extends FrappeDoc {
|
|
17
|
+
parent: string;
|
|
18
|
+
parentType: string;
|
|
19
|
+
parentField: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface FrappeResponse<T = any> {
|
|
23
|
+
message?: T;
|
|
24
|
+
docs?: T[];
|
|
25
|
+
exc?: string;
|
|
26
|
+
exc_type?: string;
|
|
27
|
+
_server_messages?: string;
|
|
28
|
+
_error_message?: string;
|
|
29
|
+
}
|
|
30
|
+
interface FrappeError {
|
|
31
|
+
message: string;
|
|
32
|
+
statusCode?: number;
|
|
33
|
+
exc?: string;
|
|
34
|
+
excType?: string;
|
|
35
|
+
serverMessages?: string;
|
|
36
|
+
}
|
|
37
|
+
interface AuthOptions {
|
|
38
|
+
token?: string;
|
|
39
|
+
apiKey?: {
|
|
40
|
+
key: string;
|
|
41
|
+
secret: string;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare function frappeCall<T = any>(baseUrl: string, method: string, args?: Record<string, any>, auth?: AuthOptions): Promise<T>;
|
|
46
|
+
declare function frappeCallGet<T = any>(baseUrl: string, method: string, args?: Record<string, any>, auth?: AuthOptions): Promise<T>;
|
|
47
|
+
declare function getList<T = any>(baseUrl: string, params: {
|
|
48
|
+
doctype: string;
|
|
49
|
+
fields?: string[];
|
|
50
|
+
filters?: Record<string, any>;
|
|
51
|
+
orderBy?: string;
|
|
52
|
+
limitStart?: number;
|
|
53
|
+
limitPageLength?: number;
|
|
54
|
+
}, auth?: AuthOptions): Promise<T[]>;
|
|
55
|
+
declare function getDoc<T = any>(baseUrl: string, doctype: string, name: string, auth?: AuthOptions): Promise<T>;
|
|
56
|
+
declare function createDoc<T = any>(baseUrl: string, doctype: string, doc: Record<string, any>, auth?: AuthOptions): Promise<T>;
|
|
57
|
+
declare function updateDoc<T = any>(baseUrl: string, doctype: string, name: string, doc: Record<string, any>, auth?: AuthOptions): Promise<T>;
|
|
58
|
+
declare function deleteDoc(baseUrl: string, doctype: string, name: string, auth?: AuthOptions): Promise<void>;
|
|
59
|
+
declare function getValue<T = any>(baseUrl: string, doctype: string, name: string, fieldname: string, auth?: AuthOptions): Promise<T>;
|
|
60
|
+
declare function setValue<T = any>(baseUrl: string, doctype: string, name: string, fieldname: string, value: any, auth?: AuthOptions): Promise<T>;
|
|
61
|
+
declare function getCount(baseUrl: string, doctype: string, filters?: Record<string, any>, auth?: AuthOptions): Promise<number>;
|
|
62
|
+
declare function getCurrentUser(baseUrl: string, auth?: AuthOptions): Promise<any>;
|
|
63
|
+
|
|
64
|
+
interface FrappeContextValue {
|
|
65
|
+
baseUrl: string;
|
|
66
|
+
token?: string;
|
|
67
|
+
apiKey?: {
|
|
68
|
+
key: string;
|
|
69
|
+
secret: string;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
interface FrappeProviderProps {
|
|
73
|
+
baseUrl: string;
|
|
74
|
+
token?: string;
|
|
75
|
+
apiKey?: {
|
|
76
|
+
key: string;
|
|
77
|
+
secret: string;
|
|
78
|
+
};
|
|
79
|
+
autoLoadAuth?: boolean;
|
|
80
|
+
onLoadAuth?: () => Promise<{
|
|
81
|
+
token?: string;
|
|
82
|
+
apiKey?: {
|
|
83
|
+
key: string;
|
|
84
|
+
secret: string;
|
|
85
|
+
};
|
|
86
|
+
}> | {
|
|
87
|
+
token?: string;
|
|
88
|
+
apiKey?: {
|
|
89
|
+
key: string;
|
|
90
|
+
secret: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
children: ReactNode;
|
|
94
|
+
}
|
|
95
|
+
declare function FrappeProvider({ baseUrl, token: initialToken, apiKey: initialApiKey, autoLoadAuth, onLoadAuth, children, }: FrappeProviderProps): react_jsx_runtime.JSX.Element;
|
|
96
|
+
declare function useFrappeConfig(): FrappeContextValue;
|
|
97
|
+
|
|
98
|
+
declare function useFrappe(): {
|
|
99
|
+
call: <T = any>(method: string, args?: Record<string, any>) => Promise<T>;
|
|
100
|
+
callGet: <T = any>(method: string, args?: Record<string, any>) => Promise<T>;
|
|
101
|
+
getList: <T = any>(params: {
|
|
102
|
+
doctype: string;
|
|
103
|
+
fields?: string[];
|
|
104
|
+
filters?: Record<string, any>;
|
|
105
|
+
orderBy?: string;
|
|
106
|
+
limitStart?: number;
|
|
107
|
+
limitPageLength?: number;
|
|
108
|
+
}) => Promise<T[]>;
|
|
109
|
+
getDoc: <T = any>(doctype: string, name: string) => Promise<T>;
|
|
110
|
+
createDoc: <T = any>(doctype: string, doc: Record<string, any>) => Promise<T>;
|
|
111
|
+
updateDoc: <T = any>(doctype: string, name: string, doc: Record<string, any>) => Promise<T>;
|
|
112
|
+
deleteDoc: (doctype: string, name: string) => Promise<void>;
|
|
113
|
+
baseUrl: string;
|
|
114
|
+
auth: AuthOptions;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
interface StorageAdapter {
|
|
118
|
+
getItem(key: string): string | null | Promise<string | null>;
|
|
119
|
+
setItem(key: string, value: string): void | Promise<void>;
|
|
120
|
+
removeItem(key: string): void | Promise<void>;
|
|
121
|
+
}
|
|
122
|
+
declare const webStorageAdapter: StorageAdapter;
|
|
123
|
+
declare function setStorageAdapter(adapter: StorageAdapter): void;
|
|
124
|
+
declare function getStorageAdapter(): StorageAdapter;
|
|
125
|
+
declare function getToken(): string | null | Promise<string | null>;
|
|
126
|
+
declare function setToken(token: string): void | Promise<void>;
|
|
127
|
+
declare function clearToken(): void | Promise<void>;
|
|
128
|
+
declare function getApiKey(): Promise<{
|
|
129
|
+
key: string;
|
|
130
|
+
secret: string;
|
|
131
|
+
} | null>;
|
|
132
|
+
declare function setApiKey(key: string, secret: string): Promise<void>;
|
|
133
|
+
declare function clearApiKey(): Promise<void>;
|
|
134
|
+
declare function clearAuth(): Promise<void>;
|
|
135
|
+
declare function isAuthenticated(): Promise<boolean>;
|
|
136
|
+
|
|
137
|
+
interface Brand {
|
|
138
|
+
brandImage?: string;
|
|
139
|
+
}
|
|
140
|
+
interface NavbarItem {
|
|
141
|
+
label: string;
|
|
142
|
+
enableDropdown: boolean;
|
|
143
|
+
enableLink: boolean;
|
|
144
|
+
link?: string;
|
|
145
|
+
dropdownDescription?: string;
|
|
146
|
+
dropdownCta?: string;
|
|
147
|
+
groups?: NavbarSubItemGroup[];
|
|
148
|
+
}
|
|
149
|
+
interface NavbarSubItemGroup {
|
|
150
|
+
title?: string;
|
|
151
|
+
items: NavbarSubItem[];
|
|
152
|
+
}
|
|
153
|
+
interface NavbarSubItem {
|
|
154
|
+
label: string;
|
|
155
|
+
description?: string;
|
|
156
|
+
image?: string;
|
|
157
|
+
link?: string;
|
|
158
|
+
}
|
|
159
|
+
interface Topbar {
|
|
160
|
+
topbarEnabled?: boolean;
|
|
161
|
+
items: TopbarItem[];
|
|
162
|
+
}
|
|
163
|
+
interface TopbarItem {
|
|
164
|
+
icon?: string;
|
|
165
|
+
label: string;
|
|
166
|
+
link?: string;
|
|
167
|
+
}
|
|
168
|
+
interface Header {
|
|
169
|
+
brand: Brand;
|
|
170
|
+
headerType?: string;
|
|
171
|
+
tabs: NavbarItem[];
|
|
172
|
+
topbar: Topbar;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
interface FooterItemGroup {
|
|
176
|
+
title: string;
|
|
177
|
+
items: FooterItem[];
|
|
178
|
+
}
|
|
179
|
+
interface FooterItem {
|
|
180
|
+
label: string;
|
|
181
|
+
link?: string;
|
|
182
|
+
}
|
|
183
|
+
interface Footer {
|
|
184
|
+
footerType?: string;
|
|
185
|
+
groups: FooterItemGroup[];
|
|
186
|
+
copyright?: string;
|
|
187
|
+
address?: string;
|
|
188
|
+
country?: string;
|
|
189
|
+
phone?: string;
|
|
190
|
+
email?: string;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
interface Globals {
|
|
194
|
+
header: Header;
|
|
195
|
+
footer: Footer;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
interface Hero {
|
|
199
|
+
type: string;
|
|
200
|
+
data: Record<string, unknown>;
|
|
201
|
+
}
|
|
202
|
+
interface Block {
|
|
203
|
+
type: string;
|
|
204
|
+
data?: Record<string, unknown>;
|
|
205
|
+
}
|
|
206
|
+
interface Page {
|
|
207
|
+
slug: string;
|
|
208
|
+
hero?: Hero;
|
|
209
|
+
blocks: Block[];
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
declare function getPage(baseUrl: string, slug: string, auth?: AuthOptions): Promise<Page>;
|
|
213
|
+
|
|
214
|
+
interface AaveFeatureSlidesData {
|
|
215
|
+
feature1Title: string;
|
|
216
|
+
feature1Description: string;
|
|
217
|
+
feature1Cta?: string;
|
|
218
|
+
feature2Title: string;
|
|
219
|
+
feature2Description: string;
|
|
220
|
+
feature2Cta?: string;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
interface Item {
|
|
224
|
+
itemCode: string;
|
|
225
|
+
region: string;
|
|
226
|
+
grade: string;
|
|
227
|
+
gradeIssuer: string;
|
|
228
|
+
color: string;
|
|
229
|
+
storage: string;
|
|
230
|
+
memory: string;
|
|
231
|
+
network: string;
|
|
232
|
+
}
|
|
233
|
+
interface ItemVariant extends Item {
|
|
234
|
+
itemVariant: string;
|
|
235
|
+
}
|
|
236
|
+
interface ModelNumber {
|
|
237
|
+
modelNumber: string;
|
|
238
|
+
simCardType: string;
|
|
239
|
+
}
|
|
240
|
+
interface Colour {
|
|
241
|
+
name: string;
|
|
242
|
+
color: string;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
interface Category {
|
|
246
|
+
name: string;
|
|
247
|
+
categoryName: string;
|
|
248
|
+
sequenceId: number;
|
|
249
|
+
itemCode: string[];
|
|
250
|
+
itemGroup: string[];
|
|
251
|
+
brand: string[];
|
|
252
|
+
os: string[];
|
|
253
|
+
}
|
|
254
|
+
interface Product extends Item {
|
|
255
|
+
name: string;
|
|
256
|
+
image: string;
|
|
257
|
+
}
|
|
258
|
+
interface ProductVariant extends ItemVariant {
|
|
259
|
+
id: string;
|
|
260
|
+
specs: Record<string, string>;
|
|
261
|
+
price: number;
|
|
262
|
+
stock: number;
|
|
263
|
+
}
|
|
264
|
+
interface ShopContext {
|
|
265
|
+
title?: string;
|
|
266
|
+
categories?: Category[];
|
|
267
|
+
selectedCategory?: Category;
|
|
268
|
+
grades?: string[];
|
|
269
|
+
selectedGrade?: string;
|
|
270
|
+
products: Product[];
|
|
271
|
+
}
|
|
272
|
+
interface ProductContext {
|
|
273
|
+
currency: string;
|
|
274
|
+
product: Product;
|
|
275
|
+
specs: Record<string, string[]>;
|
|
276
|
+
variants: ProductVariant[];
|
|
277
|
+
modelNumbers: Record<string, ModelNumber>;
|
|
278
|
+
colours: Record<string, Colour>;
|
|
279
|
+
variantImages: Record<string, string[]>;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
declare function getShopContext(baseUrl: string, params?: {
|
|
283
|
+
categoryName?: string;
|
|
284
|
+
gradeName?: string;
|
|
285
|
+
}, auth?: AuthOptions): Promise<ShopContext>;
|
|
286
|
+
declare function getProductContext(baseUrl: string, productName: string, auth?: AuthOptions): Promise<ProductContext>;
|
|
287
|
+
|
|
288
|
+
declare function useShopContext(params?: {
|
|
289
|
+
categoryName?: string;
|
|
290
|
+
gradeName?: string;
|
|
291
|
+
}, options?: Omit<UseQueryOptions<ShopContext, Error>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<ShopContext, Error>;
|
|
292
|
+
declare function useProductContext(productName: string, options?: Omit<UseQueryOptions<ProductContext, Error>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<ProductContext, Error>;
|
|
293
|
+
|
|
294
|
+
declare function toDescription(modelNumber: ModelNumber): string | null;
|
|
295
|
+
|
|
296
|
+
declare function equalsIgnoreCase(str1: string, str2: string): boolean;
|
|
297
|
+
|
|
298
|
+
export { type AaveFeatureSlidesData, type AuthOptions, type Block, type Brand, type Category, type Colour, type Footer, type FooterItem, type FooterItemGroup, type FrappeChildDoc, type FrappeContextValue, type FrappeDoc, type FrappeError, FrappeProvider, type FrappeProviderProps, type FrappeResponse, type Globals, type Header, type Hero, type Item, type ItemVariant, type ModelNumber, type NavbarItem, type NavbarSubItem, type NavbarSubItemGroup, type Page, type Product, type ProductContext, type ProductVariant, type ShopContext, type StorageAdapter, type Topbar, type TopbarItem, clearApiKey, clearAuth, clearToken, createDoc, deleteDoc, equalsIgnoreCase, frappeCall, frappeCallGet, getApiKey, getCount, getCurrentUser, getDoc, getList, getPage, getProductContext, getShopContext, getStorageAdapter, getToken, getValue, isAuthenticated, setApiKey, setStorageAdapter, setToken, setValue, toDescription, updateDoc, useFrappe, useFrappeConfig, useProductContext, useShopContext, webStorageAdapter };
|