@yoamigo.com/core 0.4.7 → 1.0.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/cart-storage-DFdGPcwm.d.ts +176 -0
- package/dist/index.d.ts +1198 -39
- package/dist/index.js +2410 -468
- package/dist/lib.d.ts +93 -2
- package/dist/lib.js +337 -4
- package/dist/prod.d.ts +2 -2
- package/dist/prod.js +74 -1
- package/dist/router.d.ts +80 -2
- package/dist/router.js +74 -1
- package/package.json +1 -1
- package/dist/builder-selection-CYP91nRu.d.ts +0 -6
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
type EditMode = 'read-only' | 'inline-edit';
|
|
5
|
+
type ChangeSource = 'user' | 'ai' | 'initial';
|
|
6
|
+
interface PageInfo {
|
|
7
|
+
path: string;
|
|
8
|
+
label: string;
|
|
9
|
+
}
|
|
10
|
+
interface ActiveFieldCallbacks {
|
|
11
|
+
close: () => void;
|
|
12
|
+
}
|
|
13
|
+
interface ContentStore {
|
|
14
|
+
getValue: (fieldId: string) => string;
|
|
15
|
+
setValue: (fieldId: string, value: string, source?: ChangeSource) => void;
|
|
16
|
+
getChangeSource: (fieldId: string) => ChangeSource;
|
|
17
|
+
clearChangeSource: (fieldId: string) => void;
|
|
18
|
+
mode: EditMode;
|
|
19
|
+
setMode: (mode: EditMode) => void;
|
|
20
|
+
subscribe: (listener: () => void) => () => void;
|
|
21
|
+
saveToWorker?: (fieldId: string, value: string) => Promise<void>;
|
|
22
|
+
activeFieldId: string | null;
|
|
23
|
+
setActiveField: (fieldId: string, callbacks: ActiveFieldCallbacks) => void;
|
|
24
|
+
clearActiveField: () => void;
|
|
25
|
+
getPages: () => PageInfo[];
|
|
26
|
+
}
|
|
27
|
+
type ContentStoreContextType = ContentStore;
|
|
28
|
+
type ContentStoreMode = EditMode;
|
|
29
|
+
declare function useContentStore(): ContentStoreContextType;
|
|
30
|
+
interface ContentStoreProviderProps {
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
initialContent?: Record<string, string>;
|
|
33
|
+
initialMode?: EditMode;
|
|
34
|
+
pages?: PageInfo[];
|
|
35
|
+
}
|
|
36
|
+
declare function ContentStoreProvider({ children, initialContent, initialMode, pages, }: ContentStoreProviderProps): react_jsx_runtime.JSX.Element;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Collection Client
|
|
40
|
+
*
|
|
41
|
+
* Handles communication with the backend API for collection data.
|
|
42
|
+
* Used for fetching collection records on published sites and builder preview.
|
|
43
|
+
*/
|
|
44
|
+
interface QueryFilter {
|
|
45
|
+
field: string;
|
|
46
|
+
operator: 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'nin' | 'contains' | 'startsWith' | 'endsWith' | 'isNull' | 'isNotNull';
|
|
47
|
+
value: unknown;
|
|
48
|
+
}
|
|
49
|
+
interface CollectionRecord<T = Record<string, unknown>> {
|
|
50
|
+
id: string;
|
|
51
|
+
appId: string;
|
|
52
|
+
collectionId: string;
|
|
53
|
+
ownerId: string | null;
|
|
54
|
+
data: T;
|
|
55
|
+
createdAt: string;
|
|
56
|
+
updatedAt: string;
|
|
57
|
+
}
|
|
58
|
+
interface ListOptions {
|
|
59
|
+
filters?: QueryFilter[];
|
|
60
|
+
limit?: number;
|
|
61
|
+
offset?: number;
|
|
62
|
+
orderBy?: string;
|
|
63
|
+
orderDir?: 'asc' | 'desc';
|
|
64
|
+
}
|
|
65
|
+
interface ListResponse<T> {
|
|
66
|
+
success: boolean;
|
|
67
|
+
data?: CollectionRecord<T>[];
|
|
68
|
+
totalCount?: number;
|
|
69
|
+
error?: string;
|
|
70
|
+
errorCode?: string;
|
|
71
|
+
}
|
|
72
|
+
interface SingleResponse<T> {
|
|
73
|
+
success: boolean;
|
|
74
|
+
data?: CollectionRecord<T>;
|
|
75
|
+
error?: string;
|
|
76
|
+
errorCode?: string;
|
|
77
|
+
}
|
|
78
|
+
interface CollectionClientConfig {
|
|
79
|
+
apiUrl: string;
|
|
80
|
+
appId: string;
|
|
81
|
+
}
|
|
82
|
+
declare class CollectionClient {
|
|
83
|
+
private apiUrl;
|
|
84
|
+
private appId;
|
|
85
|
+
constructor(config: CollectionClientConfig);
|
|
86
|
+
/**
|
|
87
|
+
* List records from a collection with optional filtering, pagination, and sorting.
|
|
88
|
+
*/
|
|
89
|
+
list<T = Record<string, unknown>>(collection: string, options?: ListOptions): Promise<ListResponse<T>>;
|
|
90
|
+
/**
|
|
91
|
+
* Get a single record by its ID.
|
|
92
|
+
*/
|
|
93
|
+
getById<T = Record<string, unknown>>(collection: string, id: string): Promise<SingleResponse<T>>;
|
|
94
|
+
/**
|
|
95
|
+
* Get a single record by a slug field value.
|
|
96
|
+
* Convenience method that uses list with a filter.
|
|
97
|
+
*/
|
|
98
|
+
getBySlug<T = Record<string, unknown>>(collection: string, slugField: string, slugValue: string): Promise<SingleResponse<T>>;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get the global CollectionClient instance.
|
|
102
|
+
* Uses window.YOAMIGO_CONFIG for configuration.
|
|
103
|
+
*/
|
|
104
|
+
declare function getCollectionClient(): CollectionClient;
|
|
105
|
+
/**
|
|
106
|
+
* Reset the cached client (useful for testing or when config changes).
|
|
107
|
+
*/
|
|
108
|
+
declare function resetCollectionClient(): void;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Initialize builder selection when running in iframe
|
|
112
|
+
*/
|
|
113
|
+
declare function initBuilderSelection(): void;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Cart Storage Helpers
|
|
117
|
+
*
|
|
118
|
+
* Handles localStorage persistence for guest carts and session management.
|
|
119
|
+
* Used for fallback when user is not logged in.
|
|
120
|
+
*/
|
|
121
|
+
interface CartItem {
|
|
122
|
+
id: string;
|
|
123
|
+
productId: string;
|
|
124
|
+
collectionSlug: string;
|
|
125
|
+
quantity: number;
|
|
126
|
+
variantId?: string;
|
|
127
|
+
addedAt: string;
|
|
128
|
+
data?: Record<string, unknown>;
|
|
129
|
+
}
|
|
130
|
+
interface LocalCart {
|
|
131
|
+
sessionId: string;
|
|
132
|
+
items: CartItem[];
|
|
133
|
+
updatedAt: string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Get or create a session ID for the current browser.
|
|
137
|
+
*/
|
|
138
|
+
declare function getSessionId(): string;
|
|
139
|
+
/**
|
|
140
|
+
* Clear the current session ID (e.g., after successful cart merge).
|
|
141
|
+
*/
|
|
142
|
+
declare function clearSessionId(): void;
|
|
143
|
+
/**
|
|
144
|
+
* Get the local cart from localStorage.
|
|
145
|
+
*/
|
|
146
|
+
declare function getLocalCart(appId: string): LocalCart | null;
|
|
147
|
+
/**
|
|
148
|
+
* Save cart to localStorage.
|
|
149
|
+
*/
|
|
150
|
+
declare function saveLocalCart(appId: string, items: CartItem[]): void;
|
|
151
|
+
/**
|
|
152
|
+
* Clear the local cart.
|
|
153
|
+
*/
|
|
154
|
+
declare function clearLocalCart(appId: string): void;
|
|
155
|
+
/**
|
|
156
|
+
* Get items from local cart.
|
|
157
|
+
*/
|
|
158
|
+
declare function getLocalCartItems(appId: string): CartItem[];
|
|
159
|
+
/**
|
|
160
|
+
* Add item to local cart.
|
|
161
|
+
*/
|
|
162
|
+
declare function addLocalCartItem(appId: string, productId: string, collectionSlug: string, quantity?: number, variantId?: string, data?: Record<string, unknown>): CartItem[];
|
|
163
|
+
/**
|
|
164
|
+
* Update item quantity in local cart.
|
|
165
|
+
*/
|
|
166
|
+
declare function updateLocalCartItem(appId: string, itemId: string, quantity: number): CartItem[];
|
|
167
|
+
/**
|
|
168
|
+
* Remove item from local cart.
|
|
169
|
+
*/
|
|
170
|
+
declare function removeLocalCartItem(appId: string, itemId: string): CartItem[];
|
|
171
|
+
/**
|
|
172
|
+
* Get cart item count.
|
|
173
|
+
*/
|
|
174
|
+
declare function getLocalCartItemCount(appId: string): number;
|
|
175
|
+
|
|
176
|
+
export { type ChangeSource as C, type EditMode as E, type ListOptions as L, type QueryFilter as Q, type SingleResponse as S, CollectionClient as a, type CollectionRecord as b, type ListResponse as c, type CollectionClientConfig as d, getSessionId as e, clearSessionId as f, getCollectionClient as g, getLocalCart as h, initBuilderSelection as i, clearLocalCart as j, getLocalCartItems as k, addLocalCartItem as l, removeLocalCartItem as m, getLocalCartItemCount as n, type CartItem as o, ContentStoreProvider as p, useContentStore as q, resetCollectionClient as r, saveLocalCart as s, type ContentStoreContextType as t, updateLocalCartItem as u, type ContentStoreMode as v };
|