@managesales/storefront 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/LICENSE +201 -0
- package/README.md +77 -0
- package/dist/index.cjs +280 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +316 -0
- package/dist/index.d.ts +316 -0
- package/dist/index.js +277 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var StorefrontError = class extends Error {
|
|
3
|
+
constructor(status, code, message, details) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "StorefrontError";
|
|
6
|
+
this.status = status;
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.details = details;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
function createStorefrontClient(config) {
|
|
12
|
+
const apiUrl = (config.apiUrl ?? "https://managesales-backend-phase1test.up.railway.app/api/v1").replace(/\/$/, "");
|
|
13
|
+
const fetchFn = config.customFetch ?? globalThis.fetch.bind(globalThis);
|
|
14
|
+
let accessToken = null;
|
|
15
|
+
let refreshToken = null;
|
|
16
|
+
async function request(method, path, options) {
|
|
17
|
+
const url = new URL(`${apiUrl}${path}`);
|
|
18
|
+
if (options?.params) {
|
|
19
|
+
for (const [k, v] of Object.entries(options.params)) {
|
|
20
|
+
if (v !== void 0 && v !== null) url.searchParams.set(k, String(v));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const headers = {
|
|
24
|
+
"X-Workspace-Id": config.workspaceId
|
|
25
|
+
};
|
|
26
|
+
if (options?.auth && accessToken) {
|
|
27
|
+
headers["Authorization"] = `Bearer ${accessToken}`;
|
|
28
|
+
}
|
|
29
|
+
if (options?.body) {
|
|
30
|
+
headers["Content-Type"] = "application/json";
|
|
31
|
+
}
|
|
32
|
+
const res = await fetchFn(url.toString(), {
|
|
33
|
+
method,
|
|
34
|
+
headers,
|
|
35
|
+
body: options?.body ? JSON.stringify(options.body) : void 0
|
|
36
|
+
});
|
|
37
|
+
if (res.status === 401 && options?.auth && refreshToken) {
|
|
38
|
+
const refreshed = await refreshSession();
|
|
39
|
+
if (refreshed) {
|
|
40
|
+
headers["Authorization"] = `Bearer ${accessToken}`;
|
|
41
|
+
const retry = await fetchFn(url.toString(), {
|
|
42
|
+
method,
|
|
43
|
+
headers,
|
|
44
|
+
body: options?.body ? JSON.stringify(options.body) : void 0
|
|
45
|
+
});
|
|
46
|
+
if (!retry.ok) throw await parseError(retry);
|
|
47
|
+
return retry.status === 204 ? void 0 : retry.json();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (!res.ok) throw await parseError(res);
|
|
51
|
+
return res.status === 204 ? void 0 : res.json();
|
|
52
|
+
}
|
|
53
|
+
async function parseError(res) {
|
|
54
|
+
try {
|
|
55
|
+
const body = await res.json();
|
|
56
|
+
return new StorefrontError(
|
|
57
|
+
res.status,
|
|
58
|
+
body.code ?? body.error ?? "UNKNOWN",
|
|
59
|
+
body.message ?? res.statusText,
|
|
60
|
+
body
|
|
61
|
+
);
|
|
62
|
+
} catch {
|
|
63
|
+
return new StorefrontError(res.status, "UNKNOWN", res.statusText);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async function refreshSession() {
|
|
67
|
+
if (!refreshToken) return false;
|
|
68
|
+
try {
|
|
69
|
+
const res = await fetchFn(`${apiUrl}/storefront/auth/refresh`, {
|
|
70
|
+
method: "POST",
|
|
71
|
+
headers: {
|
|
72
|
+
"Content-Type": "application/json",
|
|
73
|
+
"X-Workspace-Id": config.workspaceId
|
|
74
|
+
},
|
|
75
|
+
body: JSON.stringify({ refreshToken })
|
|
76
|
+
});
|
|
77
|
+
if (!res.ok) {
|
|
78
|
+
accessToken = null;
|
|
79
|
+
refreshToken = null;
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
const data = await res.json();
|
|
83
|
+
accessToken = data.accessToken;
|
|
84
|
+
refreshToken = data.refreshToken;
|
|
85
|
+
return true;
|
|
86
|
+
} catch {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const store = {
|
|
91
|
+
/** Resolve store config by workspace (returns theme, branding, currency) */
|
|
92
|
+
async resolve() {
|
|
93
|
+
return request("GET", "/storefront-api/resolve");
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const products = {
|
|
97
|
+
/** List published products with pagination and filters */
|
|
98
|
+
async list(params) {
|
|
99
|
+
return request("GET", "/storefront-api/products", { params });
|
|
100
|
+
},
|
|
101
|
+
/** Get a single product by ID or slug */
|
|
102
|
+
async get(idOrSlug) {
|
|
103
|
+
return request("GET", `/storefront-api/products/${idOrSlug}`);
|
|
104
|
+
},
|
|
105
|
+
/** Search products (shorthand for list with search param) */
|
|
106
|
+
async search(query, params) {
|
|
107
|
+
return request("GET", "/storefront-api/search", { params: { ...params, q: query } });
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const collections = {
|
|
111
|
+
/** List published collections */
|
|
112
|
+
async list(params) {
|
|
113
|
+
return request("GET", "/storefront-api/collections", { params });
|
|
114
|
+
},
|
|
115
|
+
/** Get a collection with its products */
|
|
116
|
+
async get(idOrSlug) {
|
|
117
|
+
return request("GET", `/storefront-api/collections/${idOrSlug}`);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const checkout = {
|
|
121
|
+
/** Create a checkout session from cart items */
|
|
122
|
+
async create(items) {
|
|
123
|
+
return request("POST", "/checkout", { body: { items } });
|
|
124
|
+
},
|
|
125
|
+
/** Retrieve an existing checkout session */
|
|
126
|
+
async get(checkoutId) {
|
|
127
|
+
return request("GET", `/checkout/${checkoutId}`);
|
|
128
|
+
},
|
|
129
|
+
/** Apply a coupon or discount code */
|
|
130
|
+
async applyCoupon(checkoutId, couponCode) {
|
|
131
|
+
return request("POST", `/checkout/${checkoutId}/coupon`, { body: { couponCode } });
|
|
132
|
+
},
|
|
133
|
+
/** Complete checkout — process payment and create order */
|
|
134
|
+
async complete(checkoutId, payment) {
|
|
135
|
+
return request("POST", `/checkout/${checkoutId}/complete`, { body: payment });
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const auth = {
|
|
139
|
+
/** Register a new customer account */
|
|
140
|
+
async register(data) {
|
|
141
|
+
const session = await request("POST", "/storefront/auth/register", { body: data });
|
|
142
|
+
accessToken = session.accessToken;
|
|
143
|
+
refreshToken = session.refreshToken;
|
|
144
|
+
return session;
|
|
145
|
+
},
|
|
146
|
+
/** Log in with email + password */
|
|
147
|
+
async login(email, password) {
|
|
148
|
+
const session = await request("POST", "/storefront/auth/login", {
|
|
149
|
+
body: { email, password }
|
|
150
|
+
});
|
|
151
|
+
accessToken = session.accessToken;
|
|
152
|
+
refreshToken = session.refreshToken;
|
|
153
|
+
return session;
|
|
154
|
+
},
|
|
155
|
+
/** Log in with Google ID token */
|
|
156
|
+
async loginWithGoogle(idToken) {
|
|
157
|
+
const session = await request("POST", "/storefront/auth/google", {
|
|
158
|
+
body: { idToken }
|
|
159
|
+
});
|
|
160
|
+
accessToken = session.accessToken;
|
|
161
|
+
refreshToken = session.refreshToken;
|
|
162
|
+
return session;
|
|
163
|
+
},
|
|
164
|
+
/** Log out and clear local session */
|
|
165
|
+
async logout() {
|
|
166
|
+
if (accessToken) {
|
|
167
|
+
try {
|
|
168
|
+
await request("POST", "/storefront/auth/logout", { auth: true });
|
|
169
|
+
} catch {
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
accessToken = null;
|
|
173
|
+
refreshToken = null;
|
|
174
|
+
},
|
|
175
|
+
/** Refresh the access token */
|
|
176
|
+
async refresh() {
|
|
177
|
+
return refreshSession();
|
|
178
|
+
},
|
|
179
|
+
/** Check if client has a valid session */
|
|
180
|
+
isAuthenticated() {
|
|
181
|
+
return accessToken !== null;
|
|
182
|
+
},
|
|
183
|
+
/** Manually set tokens (e.g., from SSR or cookie restoration) */
|
|
184
|
+
setTokens(access, refresh) {
|
|
185
|
+
accessToken = access;
|
|
186
|
+
refreshToken = refresh;
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
const customer = {
|
|
190
|
+
/** Get current customer profile */
|
|
191
|
+
async me() {
|
|
192
|
+
return request("GET", "/storefront/auth/me", { auth: true });
|
|
193
|
+
},
|
|
194
|
+
/** Get customer's order history */
|
|
195
|
+
async orders(params) {
|
|
196
|
+
const me = await request("GET", "/storefront/auth/me", { auth: true });
|
|
197
|
+
return request("GET", `/storefront-api/customer/${me.id}/orders`, { params, auth: true });
|
|
198
|
+
},
|
|
199
|
+
/** Get customer's saved addresses */
|
|
200
|
+
async addresses() {
|
|
201
|
+
const me = await request("GET", "/storefront/auth/me", { auth: true });
|
|
202
|
+
return request("GET", `/storefront-api/customer/${me.id}/addresses`, { auth: true });
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
const blog = {
|
|
206
|
+
/** List published blog posts */
|
|
207
|
+
async list(params) {
|
|
208
|
+
return request("GET", "/storefront-api/blog/posts", { params });
|
|
209
|
+
},
|
|
210
|
+
/** Get a blog post by slug */
|
|
211
|
+
async get(slug) {
|
|
212
|
+
return request("GET", `/storefront-api/blog/posts/${slug}`);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
const bookings = {
|
|
216
|
+
/** List bookable services */
|
|
217
|
+
async services() {
|
|
218
|
+
return request("GET", "/bookings-public/services");
|
|
219
|
+
},
|
|
220
|
+
/** List bookable staff */
|
|
221
|
+
async staff() {
|
|
222
|
+
return request("GET", "/bookings-public/staff");
|
|
223
|
+
},
|
|
224
|
+
/** Check available time slots */
|
|
225
|
+
async availability(params) {
|
|
226
|
+
return request("GET", "/bookings-public/availability", { params });
|
|
227
|
+
},
|
|
228
|
+
/** Create a booking */
|
|
229
|
+
async book(data) {
|
|
230
|
+
return request("POST", "/bookings-public/book", { body: data });
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
const forms = {
|
|
234
|
+
/** Get a published form by ID or slug */
|
|
235
|
+
async get(idOrSlug) {
|
|
236
|
+
return request("GET", `/public/forms/${idOrSlug}`);
|
|
237
|
+
},
|
|
238
|
+
/** Submit form response */
|
|
239
|
+
async submit(formId, data) {
|
|
240
|
+
return request("POST", `/public/forms/${formId}/submit`, { body: data });
|
|
241
|
+
},
|
|
242
|
+
/** Upload file for a form file field */
|
|
243
|
+
async uploadFile(formId, file) {
|
|
244
|
+
const formData = new FormData();
|
|
245
|
+
formData.append("file", file);
|
|
246
|
+
const res = await fetchFn(`${apiUrl}/public/forms/${formId}/upload`, {
|
|
247
|
+
method: "POST",
|
|
248
|
+
headers: { "X-Workspace-Id": config.workspaceId },
|
|
249
|
+
body: formData
|
|
250
|
+
});
|
|
251
|
+
if (!res.ok) throw await parseError(res);
|
|
252
|
+
return res.json();
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
const cart = {
|
|
256
|
+
/** Recover an abandoned cart by recovery token */
|
|
257
|
+
async recover(token) {
|
|
258
|
+
return request("GET", `/abandoned-carts/recover/${token}`);
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
return {
|
|
262
|
+
store,
|
|
263
|
+
products,
|
|
264
|
+
collections,
|
|
265
|
+
checkout,
|
|
266
|
+
auth,
|
|
267
|
+
customer,
|
|
268
|
+
blog,
|
|
269
|
+
bookings,
|
|
270
|
+
forms,
|
|
271
|
+
cart
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export { StorefrontError, createStorefrontClient };
|
|
276
|
+
//# sourceMappingURL=index.js.map
|
|
277
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";AAmOO,IAAM,eAAA,GAAN,cAA8B,KAAA,CAAM;AAAA,EAKzC,WAAA,CAAY,MAAA,EAAgB,IAAA,EAAc,OAAA,EAAiB,OAAA,EAAmB;AAC5E,IAAA,KAAA,CAAM,O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AAA;AAAA;AAAA,IAEA,MAAM,MAAA,CAAO,MAAA,EAAgB,IAAA,EAAwD;AACnF,MAAA,OAAO,OAAA,CAAQ,QAAQ,CAAA,cAAA,EAAiB,MAAM,WAAW,EAAE,IAAA,EAAM,MAAM,CAAA;AAAA,IACzE,CAAA;AAAA;AAAA,IAEA,MAAM,UAAA,CAAW,MAAA,EAAgB,IAAA,EAAsC;AACrE,MAAA,MAAM,QAAA,GAAW,IAAI,QAAA,EAAS;AAC9B,MAAA,QAAA,CAAS,MAAA,CAAO,QAAQ,IAAI,CAAA;AAC5B,MAAA,MAAM,MAAM,MAAM,OAAA,CAAQ,GAAG,MAAM,CAAA,cAAA,EAAiB,MAAM,CAAA,OAAA,CAAA,EAAW;AAAA,QACnE,MAAA,EAAQ,MAAA;AAAA,QACR,OAAA,EAAS,EAAE,gBAAA,EAAkB,MAAA,CAAO,WAAA,EAAY;AAAA,QAChD,IAAA,EAAM;AAAA,OACP,CAAA;AACD,MAAA,IAAI,CAAC,GAAA,CAAI,EAAA,EAAI,MAAM,MAAM,WAAW,GAAG,CAAA;AACvC,MAAA,OAAO,IAAI,IAAA,EAAK;AAAA,IAClB;AAAA,GACF;AAEA,EAAA,MAAM,IAAA,GAAO;AAAA;AAAA,IAEX,MAAM,QAAQ,KAAA,EAAyC;AACrD,MAAA,OAAO,OAAA,CAAQ,KAAA,EAAO,CAAA,yBAAA,EAA4B,KAAK,CAAA,CAAE,CAAA;AAAA,IAC3D;AAAA,GACF;AAIA,EAAA,OAAO;AAAA,IACL,KAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,KAAA;AAAA,IACA;AAAA,GACF;AACF","file":"index.js","sourcesContent":["/**\n * ManageSales Storefront SDK\n * --------------------------\n * Resource-based client for building online storefronts.\n * Works with any framework: Next.js, Remix, Nuxt, Astro, plain HTML.\n *\n * Usage:\n * import { createStorefrontClient } from \"./managesales-storefront\";\n * const client = createStorefrontClient({ workspaceId: \"<workspace_id>\" });\n * const products = await client.products.list();\n */\n\n// ── Types ──────────────────────────────────────────────────────────\n\nexport interface StorefrontConfig {\n /** Your workspace ID (required) */\n workspaceId: string;\n /** API base URL — defaults to production */\n apiUrl?: string;\n /** Custom fetch implementation (for SSR / edge) */\n customFetch?: typeof fetch;\n /** Default locale for content */\n locale?: string;\n}\n\nexport interface ListParams {\n page?: number;\n limit?: number;\n search?: string;\n sort?: string;\n order?: \"asc\" | \"desc\";\n [key: string]: unknown;\n}\n\nexport interface PaginatedResponse<T> {\n data: T[];\n total: number;\n page: number;\n limit: number;\n totalPages: number;\n}\n\n// ── Product types ──\n\nexport interface Product {\n id: string;\n name: string;\n slug: string;\n description: string;\n status: string;\n price: number;\n compareAtPrice?: number;\n currency: string;\n images: ProductImage[];\n variants: ProductVariant[];\n category?: { id: string; name: string };\n brand?: { id: string; name: string };\n tags: string[];\n metadata: Record<string, unknown>;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface ProductImage {\n id: string;\n url: string;\n alt: string;\n position: number;\n}\n\nexport interface ProductVariant {\n id: string;\n name: string;\n sku: string;\n price: number;\n compareAtPrice?: number;\n inventory: number;\n options: Record<string, string>;\n}\n\n// ── Collection types ──\n\nexport interface Collection {\n id: string;\n name: string;\n slug: string;\n description: string;\n image?: string;\n productCount: number;\n}\n\n// ── Cart & Checkout types ──\n\nexport interface CheckoutLineItem {\n productId: string;\n variantId?: string;\n quantity: number;\n}\n\nexport interface CheckoutSession {\n id: string;\n status: \"open\" | \"completed\" | \"expired\";\n items: CheckoutLineItem[];\n subtotal: number;\n tax: number;\n shipping: number;\n discount: number;\n total: number;\n currency: string;\n couponCode?: string;\n}\n\nexport interface Order {\n id: string;\n orderNumber: string;\n status: string;\n total: number;\n currency: string;\n items: OrderItem[];\n createdAt: string;\n}\n\nexport interface OrderItem {\n productId: string;\n name: string;\n quantity: number;\n price: number;\n}\n\n// ── Customer types ──\n\nexport interface Customer {\n id: string;\n email: string;\n name: string;\n phone?: string;\n createdAt: string;\n}\n\nexport interface AuthSession {\n customer: Customer;\n accessToken: string;\n refreshToken: string;\n}\n\nexport interface Address {\n id: string;\n label?: string;\n line1: string;\n line2?: string;\n city: string;\n state: string;\n postalCode: string;\n country: string;\n isDefault: boolean;\n}\n\n// ── Blog types ──\n\nexport interface BlogPost {\n id: string;\n title: string;\n slug: string;\n excerpt: string;\n content: string;\n coverImage?: string;\n tags: string[];\n publishedAt: string;\n}\n\n// ── Booking types ──\n\nexport interface BookableService {\n id: string;\n name: string;\n duration: number;\n price: number;\n description: string;\n}\n\nexport interface TimeSlot {\n start: string;\n end: string;\n available: boolean;\n}\n\nexport interface Booking {\n id: string;\n serviceId: string;\n date: string;\n startTime: string;\n endTime: string;\n status: string;\n customer: { name: string; email: string };\n}\n\n// ── Form types ──\n\nexport interface FormDefinition {\n id: string;\n title: string;\n description: string;\n fields: FormField[];\n}\n\nexport interface FormField {\n id: string;\n type: string;\n label: string;\n required: boolean;\n options?: string[];\n placeholder?: string;\n}\n\n// ── Store config ──\n\nexport interface StoreConfig {\n name: string;\n slug: string;\n logo?: string;\n theme: Record<string, unknown>;\n currency: string;\n locale: string;\n}\n\n// ── SDK Error ──\n\nexport class StorefrontError extends Error {\n status: number;\n code: string;\n details?: unknown;\n\n constructor(status: number, code: string, message: string, details?: unknown) {\n super(message);\n this.name = \"StorefrontError\";\n this.status = status;\n this.code = code;\n this.details = details;\n }\n}\n\n// ── Core client ────────────────────────────────────────────────────\n\nexport function createStorefrontClient(config: StorefrontConfig) {\n const apiUrl = (config.apiUrl ?? \"https://managesales-backend-phase1test.up.railway.app/api/v1\").replace(/\\/$/, \"\");\n const fetchFn = config.customFetch ?? globalThis.fetch.bind(globalThis);\n let accessToken: string | null = null;\n let refreshToken: string | null = null;\n\n // ── Internal helpers ──\n\n async function request<T>(\n method: string,\n path: string,\n options?: {\n body?: unknown;\n params?: Record<string, unknown>;\n auth?: boolean;\n },\n ): Promise<T> {\n const url = new URL(`${apiUrl}${path}`);\n if (options?.params) {\n for (const [k, v] of Object.entries(options.params)) {\n if (v !== undefined && v !== null) url.searchParams.set(k, String(v));\n }\n }\n\n const headers: Record<string, string> = {\n \"X-Workspace-Id\": config.workspaceId,\n };\n\n if (options?.auth && accessToken) {\n headers[\"Authorization\"] = `Bearer ${accessToken}`;\n }\n\n if (options?.body) {\n headers[\"Content-Type\"] = \"application/json\";\n }\n\n const res = await fetchFn(url.toString(), {\n method,\n headers,\n body: options?.body ? JSON.stringify(options.body) : undefined,\n });\n\n // Auto-refresh on 401\n if (res.status === 401 && options?.auth && refreshToken) {\n const refreshed = await refreshSession();\n if (refreshed) {\n headers[\"Authorization\"] = `Bearer ${accessToken}`;\n const retry = await fetchFn(url.toString(), {\n method,\n headers,\n body: options?.body ? JSON.stringify(options.body) : undefined,\n });\n if (!retry.ok) throw await parseError(retry);\n return retry.status === 204 ? (undefined as T) : retry.json();\n }\n }\n\n if (!res.ok) throw await parseError(res);\n return res.status === 204 ? (undefined as T) : res.json();\n }\n\n async function parseError(res: Response): Promise<StorefrontError> {\n try {\n const body = await res.json();\n return new StorefrontError(\n res.status,\n body.code ?? body.error ?? \"UNKNOWN\",\n body.message ?? res.statusText,\n body,\n );\n } catch {\n return new StorefrontError(res.status, \"UNKNOWN\", res.statusText);\n }\n }\n\n async function refreshSession(): Promise<boolean> {\n if (!refreshToken) return false;\n try {\n const res = await fetchFn(`${apiUrl}/storefront/auth/refresh`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-Workspace-Id\": config.workspaceId,\n },\n body: JSON.stringify({ refreshToken }),\n });\n if (!res.ok) {\n accessToken = null;\n refreshToken = null;\n return false;\n }\n const data = await res.json();\n accessToken = data.accessToken;\n refreshToken = data.refreshToken;\n return true;\n } catch {\n return false;\n }\n }\n\n // ── Resource namespaces ──────────────────────────────────────────\n\n const store = {\n /** Resolve store config by workspace (returns theme, branding, currency) */\n async resolve(): Promise<StoreConfig> {\n return request(\"GET\", \"/storefront-api/resolve\");\n },\n };\n\n const products = {\n /** List published products with pagination and filters */\n async list(params?: ListParams): Promise<PaginatedResponse<Product>> {\n return request(\"GET\", \"/storefront-api/products\", { params });\n },\n /** Get a single product by ID or slug */\n async get(idOrSlug: string): Promise<Product> {\n return request(\"GET\", `/storefront-api/products/${idOrSlug}`);\n },\n /** Search products (shorthand for list with search param) */\n async search(query: string, params?: ListParams): Promise<PaginatedResponse<Product>> {\n return request(\"GET\", \"/storefront-api/search\", { params: { ...params, q: query } });\n },\n };\n\n const collections = {\n /** List published collections */\n async list(params?: ListParams): Promise<PaginatedResponse<Collection>> {\n return request(\"GET\", \"/storefront-api/collections\", { params });\n },\n /** Get a collection with its products */\n async get(idOrSlug: string): Promise<Collection & { products: Product[] }> {\n return request(\"GET\", `/storefront-api/collections/${idOrSlug}`);\n },\n };\n\n const checkout = {\n /** Create a checkout session from cart items */\n async create(items: CheckoutLineItem[]): Promise<CheckoutSession> {\n return request(\"POST\", \"/checkout\", { body: { items } });\n },\n /** Retrieve an existing checkout session */\n async get(checkoutId: string): Promise<CheckoutSession> {\n return request(\"GET\", `/checkout/${checkoutId}`);\n },\n /** Apply a coupon or discount code */\n async applyCoupon(checkoutId: string, couponCode: string): Promise<CheckoutSession> {\n return request(\"POST\", `/checkout/${checkoutId}/coupon`, { body: { couponCode } });\n },\n /** Complete checkout — process payment and create order */\n async complete(checkoutId: string, payment?: Record<string, unknown>): Promise<Order> {\n return request(\"POST\", `/checkout/${checkoutId}/complete`, { body: payment });\n },\n };\n\n const auth = {\n /** Register a new customer account */\n async register(data: {\n email: string;\n password: string;\n name: string;\n phone?: string;\n }): Promise<AuthSession> {\n const session = await request<AuthSession>(\"POST\", \"/storefront/auth/register\", { body: data });\n accessToken = session.accessToken;\n refreshToken = session.refreshToken;\n return session;\n },\n /** Log in with email + password */\n async login(email: string, password: string): Promise<AuthSession> {\n const session = await request<AuthSession>(\"POST\", \"/storefront/auth/login\", {\n body: { email, password },\n });\n accessToken = session.accessToken;\n refreshToken = session.refreshToken;\n return session;\n },\n /** Log in with Google ID token */\n async loginWithGoogle(idToken: string): Promise<AuthSession> {\n const session = await request<AuthSession>(\"POST\", \"/storefront/auth/google\", {\n body: { idToken },\n });\n accessToken = session.accessToken;\n refreshToken = session.refreshToken;\n return session;\n },\n /** Log out and clear local session */\n async logout(): Promise<void> {\n if (accessToken) {\n try {\n await request(\"POST\", \"/storefront/auth/logout\", { auth: true });\n } catch { /* ignore logout errors */ }\n }\n accessToken = null;\n refreshToken = null;\n },\n /** Refresh the access token */\n async refresh(): Promise<boolean> {\n return refreshSession();\n },\n /** Check if client has a valid session */\n isAuthenticated(): boolean {\n return accessToken !== null;\n },\n /** Manually set tokens (e.g., from SSR or cookie restoration) */\n setTokens(access: string, refresh: string): void {\n accessToken = access;\n refreshToken = refresh;\n },\n };\n\n const customer = {\n /** Get current customer profile */\n async me(): Promise<Customer> {\n return request(\"GET\", \"/storefront/auth/me\", { auth: true });\n },\n /** Get customer's order history */\n async orders(params?: ListParams): Promise<PaginatedResponse<Order>> {\n const me = await request<Customer>(\"GET\", \"/storefront/auth/me\", { auth: true });\n return request(\"GET\", `/storefront-api/customer/${me.id}/orders`, { params, auth: true });\n },\n /** Get customer's saved addresses */\n async addresses(): Promise<Address[]> {\n const me = await request<Customer>(\"GET\", \"/storefront/auth/me\", { auth: true });\n return request(\"GET\", `/storefront-api/customer/${me.id}/addresses`, { auth: true });\n },\n };\n\n const blog = {\n /** List published blog posts */\n async list(params?: ListParams & { tags?: string }): Promise<PaginatedResponse<BlogPost>> {\n return request(\"GET\", \"/storefront-api/blog/posts\", { params });\n },\n /** Get a blog post by slug */\n async get(slug: string): Promise<BlogPost> {\n return request(\"GET\", `/storefront-api/blog/posts/${slug}`);\n },\n };\n\n const bookings = {\n /** List bookable services */\n async services(): Promise<BookableService[]> {\n return request(\"GET\", \"/bookings-public/services\");\n },\n /** List bookable staff */\n async staff(): Promise<Array<{ id: string; name: string; avatar?: string }>> {\n return request(\"GET\", \"/bookings-public/staff\");\n },\n /** Check available time slots */\n async availability(params: {\n serviceId: string;\n date: string;\n staffId?: string;\n }): Promise<TimeSlot[]> {\n return request(\"GET\", \"/bookings-public/availability\", { params });\n },\n /** Create a booking */\n async book(data: {\n serviceId: string;\n date: string;\n startTime: string;\n staffId?: string;\n customer: { name: string; email: string; phone?: string };\n }): Promise<Booking> {\n return request(\"POST\", \"/bookings-public/book\", { body: data });\n },\n };\n\n const forms = {\n /** Get a published form by ID or slug */\n async get(idOrSlug: string): Promise<FormDefinition> {\n return request(\"GET\", `/public/forms/${idOrSlug}`);\n },\n /** Submit form response */\n async submit(formId: string, data: Record<string, unknown>): Promise<{ id: string }> {\n return request(\"POST\", `/public/forms/${formId}/submit`, { body: data });\n },\n /** Upload file for a form file field */\n async uploadFile(formId: string, file: File): Promise<{ url: string }> {\n const formData = new FormData();\n formData.append(\"file\", file);\n const res = await fetchFn(`${apiUrl}/public/forms/${formId}/upload`, {\n method: \"POST\",\n headers: { \"X-Workspace-Id\": config.workspaceId },\n body: formData,\n });\n if (!res.ok) throw await parseError(res);\n return res.json();\n },\n };\n\n const cart = {\n /** Recover an abandoned cart by recovery token */\n async recover(token: string): Promise<CheckoutSession> {\n return request(\"GET\", `/abandoned-carts/recover/${token}`);\n },\n };\n\n // ── Public API ───────────────────────────────────────────────────\n\n return {\n store,\n products,\n collections,\n checkout,\n auth,\n customer,\n blog,\n bookings,\n forms,\n cart,\n };\n}\n\n// ── Type export for TypeScript users ──\n\nexport type StorefrontClient = ReturnType<typeof createStorefrontClient>;\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@managesales/storefront",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Resource-based TypeScript client for building storefronts on the ManageSales Storefront API. Zero runtime dependencies, built-in auth and token refresh.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"scripts": {
|
|
23
|
+
"generate": "tsx scripts/generate.ts",
|
|
24
|
+
"build": "npm run generate && tsup",
|
|
25
|
+
"prepublishOnly": "npm run build",
|
|
26
|
+
"clean": "rm -rf dist src/index.ts"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"managesales",
|
|
30
|
+
"storefront",
|
|
31
|
+
"sdk",
|
|
32
|
+
"ecommerce",
|
|
33
|
+
"api-client",
|
|
34
|
+
"typescript"
|
|
35
|
+
],
|
|
36
|
+
"license": "Apache-2.0",
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=18"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"tsup": "^8.0.2",
|
|
45
|
+
"tsx": "^4.7.1",
|
|
46
|
+
"typescript": "^5.4.5"
|
|
47
|
+
}
|
|
48
|
+
}
|