@fayz-ai/sdk 0.1.2 → 0.1.4

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 (45) hide show
  1. package/README.md +20 -1
  2. package/dist/chunk-3VVLBMKG.cjs +442 -0
  3. package/dist/chunk-3VVLBMKG.cjs.map +1 -0
  4. package/dist/chunk-7FF2FLPG.js +45 -0
  5. package/dist/chunk-7FF2FLPG.js.map +1 -0
  6. package/dist/chunk-JBQDG2GN.js +439 -0
  7. package/dist/chunk-JBQDG2GN.js.map +1 -0
  8. package/dist/chunk-JXXIKYP3.cjs +50 -0
  9. package/dist/chunk-JXXIKYP3.cjs.map +1 -0
  10. package/dist/{chunk-REGBJXXB.cjs → chunk-MCB2L25R.cjs} +60 -2
  11. package/dist/chunk-MCB2L25R.cjs.map +1 -0
  12. package/dist/{chunk-O6XSRB3Q.js → chunk-R4XVCBFG.js} +60 -2
  13. package/dist/chunk-R4XVCBFG.js.map +1 -0
  14. package/dist/client.cjs +4 -4
  15. package/dist/client.d.ts +54 -0
  16. package/dist/client.d.ts.map +1 -1
  17. package/dist/client.js +1 -1
  18. package/dist/index.cjs +30 -4
  19. package/dist/index.d.ts +5 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +3 -1
  22. package/dist/release-channels.cjs +24 -0
  23. package/dist/release-channels.cjs.map +1 -0
  24. package/dist/release-channels.d.ts +10 -0
  25. package/dist/release-channels.d.ts.map +1 -0
  26. package/dist/release-channels.js +3 -0
  27. package/dist/release-channels.js.map +1 -0
  28. package/dist/shop.cjs +16 -0
  29. package/dist/shop.cjs.map +1 -0
  30. package/dist/shop.d.ts +391 -0
  31. package/dist/shop.d.ts.map +1 -0
  32. package/dist/shop.js +3 -0
  33. package/dist/shop.js.map +1 -0
  34. package/package.json +15 -2
  35. package/src/client.test.ts +135 -0
  36. package/src/client.ts +126 -0
  37. package/src/index.ts +36 -1
  38. package/src/release-channels.json +13 -0
  39. package/src/release-channels.test.ts +42 -0
  40. package/src/release-channels.ts +41 -0
  41. package/src/runtime.test.ts +4 -4
  42. package/src/shop.test.ts +83 -0
  43. package/src/shop.ts +660 -0
  44. package/dist/chunk-O6XSRB3Q.js.map +0 -1
  45. package/dist/chunk-REGBJXXB.cjs.map +0 -1
package/src/shop.ts ADDED
@@ -0,0 +1,660 @@
1
+ export interface FayzShopProviderOptions {
2
+ supabaseUrl: string
3
+ publishableKey: string
4
+ storeId: string
5
+ productMetadata?: FayzShopProductMetadataOverlay[]
6
+ fetcher?: typeof fetch
7
+ }
8
+
9
+ export interface FayzShopProductMetadataOverlay {
10
+ sku?: string | null
11
+ slug?: string | null
12
+ metadata: Record<string, unknown>
13
+ }
14
+
15
+ export type FayzShopProductStatus = 'draft' | 'active' | 'archived'
16
+ export type FayzShopOrderStatus = 'open' | 'archived' | 'cancelled'
17
+ export type FayzShopFinancialStatus = 'pending' | 'paid' | 'partially_paid' | 'refunded' | 'partially_refunded' | 'voided'
18
+ export type FayzShopFulfillmentStatus = 'unfulfilled' | 'partially_fulfilled' | 'fulfilled'
19
+
20
+ export interface FayzShopListProductsOptions {
21
+ status?: FayzShopProductStatus
22
+ categoryId?: string
23
+ search?: string
24
+ slug?: string
25
+ limit?: number
26
+ offset?: number
27
+ orderBy?: 'name' | 'price' | 'created_at' | 'sort_order'
28
+ order?: 'asc' | 'desc'
29
+ }
30
+
31
+ export interface FayzShopListOrdersOptions {
32
+ status?: FayzShopOrderStatus
33
+ financialStatus?: FayzShopFinancialStatus
34
+ fulfillmentStatus?: FayzShopFulfillmentStatus
35
+ customerId?: string
36
+ customerEmail?: string
37
+ search?: string
38
+ limit?: number
39
+ offset?: number
40
+ }
41
+
42
+ export interface FayzShopListCustomersOptions {
43
+ search?: string
44
+ limit?: number
45
+ offset?: number
46
+ }
47
+
48
+ export interface FayzShopListDiscountsOptions {
49
+ status?: string
50
+ type?: string
51
+ search?: string
52
+ limit?: number
53
+ offset?: number
54
+ }
55
+
56
+ interface ProductImageRow {
57
+ id: string
58
+ product_id: string
59
+ url: string
60
+ alt_text?: string | null
61
+ sort_order?: number | null
62
+ is_primary?: boolean | null
63
+ created_at?: string | null
64
+ }
65
+
66
+ interface ProductRow {
67
+ id: string
68
+ tenant_id: string
69
+ name: string
70
+ slug?: string | null
71
+ description?: string | null
72
+ price?: number | null
73
+ compare_at_price?: number | null
74
+ currency?: string | null
75
+ status?: FayzShopProductStatus | null
76
+ inventory_count?: number | null
77
+ sku?: string | null
78
+ sort_order?: number | null
79
+ metadata?: Record<string, unknown> | null
80
+ images?: ProductImageRow[] | null
81
+ category_id?: string | null
82
+ category?: { name?: string | null } | null
83
+ is_physical?: boolean | null
84
+ weight?: number | null
85
+ weight_unit?: string | null
86
+ created_at?: string | null
87
+ updated_at?: string | null
88
+ }
89
+
90
+ interface StoreCategoryMetadata {
91
+ id?: string | null
92
+ name?: string | null
93
+ slug?: string | null
94
+ description?: string | null
95
+ imageUrl?: string | null
96
+ sortOrder?: number | null
97
+ }
98
+
99
+ interface CategoryRow {
100
+ id: string
101
+ tenant_id?: string | null
102
+ name: string
103
+ slug?: string | null
104
+ description?: string | null
105
+ parent_id?: string | null
106
+ sort_order?: number | null
107
+ image_url?: string | null
108
+ created_at?: string | null
109
+ }
110
+
111
+ interface OrderItemRow {
112
+ id: string
113
+ order_id: string
114
+ product_id?: string | null
115
+ name: string
116
+ sku?: string | null
117
+ quantity?: number | null
118
+ unit_price?: number | null
119
+ total?: number | null
120
+ image_url?: string | null
121
+ }
122
+
123
+ interface OrderRow {
124
+ id: string
125
+ tenant_id: string
126
+ order_number?: number | null
127
+ status?: FayzShopOrderStatus | null
128
+ financial_status?: FayzShopFinancialStatus | null
129
+ fulfillment_status?: FayzShopFulfillmentStatus | null
130
+ currency?: string | null
131
+ subtotal?: number | null
132
+ tax_total?: number | null
133
+ discount_total?: number | null
134
+ shipping_total?: number | null
135
+ total?: number | null
136
+ customer_id?: string | null
137
+ customer_name?: string | null
138
+ customer_email?: string | null
139
+ discount_code?: string | null
140
+ notes?: string | null
141
+ items?: OrderItemRow[] | null
142
+ created_at?: string | null
143
+ updated_at?: string | null
144
+ }
145
+
146
+ interface CustomerRow {
147
+ id: string
148
+ tenant_id: string
149
+ first_name: string
150
+ last_name?: string | null
151
+ email?: string | null
152
+ phone?: string | null
153
+ notes?: string | null
154
+ orders_count?: number | null
155
+ total_spent?: number | null
156
+ created_at?: string | null
157
+ updated_at?: string | null
158
+ }
159
+
160
+ interface DiscountRow {
161
+ id: string
162
+ tenant_id: string
163
+ title: string
164
+ code?: string | null
165
+ type: string
166
+ method?: string | null
167
+ value?: number | null
168
+ usage_limit?: number | null
169
+ once_per_customer?: boolean | null
170
+ starts_at?: string | null
171
+ ends_at?: string | null
172
+ status?: string | null
173
+ times_used?: number | null
174
+ created_at?: string | null
175
+ updated_at?: string | null
176
+ }
177
+
178
+ export class FayzShopError extends Error {
179
+ constructor(
180
+ message: string,
181
+ readonly status: number,
182
+ readonly responseBody?: unknown,
183
+ ) {
184
+ super(message)
185
+ this.name = 'FayzShopError'
186
+ }
187
+ }
188
+
189
+ function normalizeBaseUrl(url: string): string {
190
+ return url.replace(/\/+$/, '')
191
+ }
192
+
193
+ function slugify(name: string): string {
194
+ return name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '')
195
+ }
196
+
197
+ function nowIso(): string {
198
+ return new Date().toISOString()
199
+ }
200
+
201
+ function present<T>(value: T | null | undefined, fallback: T): T {
202
+ return value == null ? fallback : value
203
+ }
204
+
205
+ function productMetadataKey(kind: 'sku' | 'slug', value: string): string {
206
+ return `${kind}:${value.toLowerCase()}`
207
+ }
208
+
209
+ function buildProductMetadataOverlay(overlays: FayzShopProductMetadataOverlay[] | undefined) {
210
+ const map = new Map<string, Record<string, unknown>>()
211
+ for (const overlay of overlays ?? []) {
212
+ if (overlay.sku) map.set(productMetadataKey('sku', overlay.sku), overlay.metadata)
213
+ if (overlay.slug) map.set(productMetadataKey('slug', overlay.slug), overlay.metadata)
214
+ }
215
+ return map
216
+ }
217
+
218
+ function asUuid(value: string | null | undefined): string | null {
219
+ if (!value) return null
220
+ return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value)
221
+ ? value
222
+ : null
223
+ }
224
+
225
+ function rowToImage(row: ProductImageRow) {
226
+ return {
227
+ id: row.id,
228
+ productId: row.product_id,
229
+ url: row.url,
230
+ altText: row.alt_text ?? null,
231
+ sortOrder: row.sort_order ?? 0,
232
+ isPrimary: row.is_primary ?? false,
233
+ createdAt: row.created_at ?? nowIso(),
234
+ }
235
+ }
236
+
237
+ function getProductMetadata(row: ProductRow, overlay?: Map<string, Record<string, unknown>>): Record<string, unknown> {
238
+ const metadata = row.metadata ?? {}
239
+ const bySlug = overlay?.get(productMetadataKey('slug', row.slug ?? slugify(row.name)))
240
+ const bySku = row.sku ? overlay?.get(productMetadataKey('sku', row.sku)) : undefined
241
+ return { ...(bySlug ?? {}), ...(bySku ?? {}), ...metadata }
242
+ }
243
+
244
+ function getStoreCategory(row: ProductRow, overlay?: Map<string, Record<string, unknown>>): StoreCategoryMetadata | null {
245
+ const raw = getProductMetadata(row, overlay).fayzStoreCategory
246
+ return raw && typeof raw === 'object' ? raw as StoreCategoryMetadata : null
247
+ }
248
+
249
+ function rowToProduct(row: ProductRow, overlay?: Map<string, Record<string, unknown>>) {
250
+ const metadata = getProductMetadata(row, overlay)
251
+ const storeCategory = getStoreCategory(row, overlay)
252
+ return {
253
+ id: row.id,
254
+ tenantId: row.tenant_id,
255
+ name: row.name,
256
+ slug: row.slug ?? slugify(row.name),
257
+ description: row.description ?? null,
258
+ price: row.price ?? 0,
259
+ compareAtPrice: row.compare_at_price ?? null,
260
+ currency: row.currency ?? 'BRL',
261
+ status: row.status ?? 'active',
262
+ inventoryCount: row.inventory_count ?? 0,
263
+ sku: row.sku ?? null,
264
+ sortOrder: row.sort_order ?? 0,
265
+ metadata,
266
+ images: Array.isArray(row.images) ? row.images.map(rowToImage) : [],
267
+ categoryId: storeCategory?.id ?? row.category_id ?? null,
268
+ categoryName: storeCategory?.name ?? row.category?.name ?? null,
269
+ isPhysical: row.is_physical ?? true,
270
+ weight: row.weight ?? null,
271
+ weightUnit: row.weight_unit ?? 'kg',
272
+ createdAt: row.created_at ?? nowIso(),
273
+ updatedAt: row.updated_at ?? row.created_at ?? nowIso(),
274
+ }
275
+ }
276
+
277
+ function rowToCategory(row: CategoryRow) {
278
+ return {
279
+ id: row.id,
280
+ tenantId: row.tenant_id ?? 'global',
281
+ name: row.name,
282
+ slug: row.slug ?? slugify(row.name),
283
+ description: row.description ?? null,
284
+ parentId: row.parent_id ?? null,
285
+ sortOrder: row.sort_order ?? 0,
286
+ imageUrl: row.image_url ?? null,
287
+ createdAt: row.created_at ?? nowIso(),
288
+ }
289
+ }
290
+
291
+ function storeCategoryToCategory(category: StoreCategoryMetadata, tenantId: string) {
292
+ const name = category.name ?? 'Category'
293
+ return {
294
+ id: category.id ?? slugify(name),
295
+ tenantId,
296
+ name,
297
+ slug: category.slug ?? slugify(name),
298
+ description: category.description ?? null,
299
+ parentId: null,
300
+ sortOrder: category.sortOrder ?? 0,
301
+ imageUrl: category.imageUrl ?? null,
302
+ createdAt: nowIso(),
303
+ }
304
+ }
305
+
306
+ function deriveStoreCategories(products: ProductRow[], tenantId: string) {
307
+ const categories = new Map<string, ReturnType<typeof storeCategoryToCategory>>()
308
+ for (const product of products) {
309
+ const category = getStoreCategory(product)
310
+ if (!category?.name && !category?.id) continue
311
+ const mapped = storeCategoryToCategory(category, tenantId)
312
+ categories.set(mapped.id, mapped)
313
+ }
314
+ return [...categories.values()].sort((a, b) => a.sortOrder - b.sortOrder || a.name.localeCompare(b.name))
315
+ }
316
+
317
+ function rowToOrder(row: OrderRow) {
318
+ return {
319
+ id: row.id,
320
+ tenantId: row.tenant_id,
321
+ orderNumber: row.order_number ?? 0,
322
+ status: row.status ?? 'open',
323
+ financialStatus: row.financial_status ?? 'pending',
324
+ fulfillmentStatus: row.fulfillment_status ?? 'unfulfilled',
325
+ currency: row.currency ?? 'BRL',
326
+ subtotal: row.subtotal ?? 0,
327
+ taxTotal: row.tax_total ?? 0,
328
+ discountTotal: row.discount_total ?? 0,
329
+ shippingTotal: row.shipping_total ?? 0,
330
+ total: row.total ?? 0,
331
+ customerId: row.customer_id ?? null,
332
+ customerName: row.customer_name ?? null,
333
+ customerEmail: row.customer_email ?? null,
334
+ discountCode: row.discount_code ?? null,
335
+ notes: row.notes ?? null,
336
+ items: Array.isArray(row.items) ? row.items.map(rowToOrderItem) : [],
337
+ createdAt: row.created_at ?? nowIso(),
338
+ updatedAt: row.updated_at ?? row.created_at ?? nowIso(),
339
+ }
340
+ }
341
+
342
+ function rowToOrderItem(row: OrderItemRow) {
343
+ return {
344
+ id: row.id,
345
+ orderId: row.order_id,
346
+ productId: row.product_id ?? null,
347
+ name: row.name,
348
+ sku: row.sku ?? null,
349
+ quantity: row.quantity ?? 0,
350
+ unitPrice: row.unit_price ?? 0,
351
+ total: row.total ?? 0,
352
+ imageUrl: row.image_url ?? null,
353
+ }
354
+ }
355
+
356
+ function rowToCustomer(row: CustomerRow) {
357
+ return {
358
+ id: row.id,
359
+ tenantId: row.tenant_id,
360
+ firstName: row.first_name,
361
+ lastName: row.last_name ?? '',
362
+ email: row.email ?? null,
363
+ phone: row.phone ?? null,
364
+ notes: row.notes ?? null,
365
+ ordersCount: row.orders_count ?? 0,
366
+ totalSpent: row.total_spent ?? 0,
367
+ createdAt: row.created_at ?? nowIso(),
368
+ updatedAt: row.updated_at ?? row.created_at ?? nowIso(),
369
+ }
370
+ }
371
+
372
+ function rowToDiscount(row: DiscountRow) {
373
+ return {
374
+ id: row.id,
375
+ tenantId: row.tenant_id,
376
+ title: row.title,
377
+ code: row.code ?? null,
378
+ type: row.type,
379
+ method: row.method ?? 'code',
380
+ value: row.value ?? 0,
381
+ usageLimit: row.usage_limit ?? null,
382
+ oncePerCustomer: row.once_per_customer ?? false,
383
+ startsAt: row.starts_at ?? nowIso(),
384
+ endsAt: row.ends_at ?? null,
385
+ status: row.status ?? 'active',
386
+ timesUsed: row.times_used ?? 0,
387
+ createdAt: row.created_at ?? nowIso(),
388
+ updatedAt: row.updated_at ?? row.created_at ?? nowIso(),
389
+ }
390
+ }
391
+
392
+ function updateOrderPayload(input: {
393
+ status?: FayzShopOrderStatus
394
+ financialStatus?: FayzShopFinancialStatus
395
+ fulfillmentStatus?: FayzShopFulfillmentStatus
396
+ notes?: string
397
+ }) {
398
+ const updates: Record<string, unknown> = {}
399
+ if (input.status !== undefined) updates.status = input.status
400
+ if (input.financialStatus !== undefined) updates.financial_status = input.financialStatus
401
+ if (input.fulfillmentStatus !== undefined) updates.fulfillment_status = input.fulfillmentStatus
402
+ if (input.notes !== undefined) updates.notes = input.notes
403
+ return updates
404
+ }
405
+
406
+ export function createFayzShopProvider(options: FayzShopProviderOptions) {
407
+ const baseUrl = `${normalizeBaseUrl(options.supabaseUrl)}/rest/v1`
408
+ const fetcher = options.fetcher ?? fetch
409
+ const key = options.publishableKey
410
+ const storeId = options.storeId
411
+ const productMetadataOverlay = buildProductMetadataOverlay(options.productMetadata)
412
+
413
+ async function request<T>(table: string, init: RequestInit & { query?: URLSearchParams } = {}): Promise<T> {
414
+ const query = init.query?.toString()
415
+ const response = await fetcher(`${baseUrl}/${table}${query ? `?${query}` : ''}`, {
416
+ ...init,
417
+ headers: {
418
+ apikey: key,
419
+ Authorization: `Bearer ${key}`,
420
+ ...(init.body ? { 'Content-Type': 'application/json', Prefer: 'return=representation' } : {}),
421
+ ...init.headers,
422
+ },
423
+ })
424
+ const text = await response.text()
425
+ let body: unknown
426
+ try {
427
+ body = text ? JSON.parse(text) : undefined
428
+ } catch {
429
+ body = text
430
+ }
431
+ if (!response.ok) {
432
+ const message = typeof body === 'object' && body
433
+ ? String((body as { message?: unknown; error?: unknown }).message ?? (body as { error?: unknown }).error ?? `Fayz Shop request failed with status ${response.status}`)
434
+ : `Fayz Shop request failed with status ${response.status}`
435
+ throw new FayzShopError(message, response.status, body)
436
+ }
437
+ return body as T
438
+ }
439
+
440
+ const tenantQuery = () => {
441
+ const query = new URLSearchParams()
442
+ query.set('tenant_id', `eq.${storeId}`)
443
+ return query
444
+ }
445
+
446
+ const singleById = (id: string) => {
447
+ const query = tenantQuery()
448
+ query.set('id', `eq.${id}`)
449
+ query.set('limit', '1')
450
+ return query
451
+ }
452
+
453
+ return {
454
+ async listProducts(options?: FayzShopListProductsOptions) {
455
+ const query = tenantQuery()
456
+ query.set('select', '*,images:product_images(*),category:categories(name)')
457
+ if (options?.status) query.set('status', `eq.${options.status}`)
458
+ if (options?.slug) query.set('slug', `eq.${options.slug}`)
459
+ if (options?.search) query.set('name', `ilike.*${options.search}*`)
460
+ query.set('order', `${options?.orderBy ?? 'sort_order'}.${options?.order ?? 'asc'}`)
461
+ if (options?.limit) query.set('limit', String(options.limit))
462
+ if (options?.offset) query.set('offset', String(options.offset))
463
+ const products = (await request<ProductRow[]>('products', { query })).map((row) => rowToProduct(row, productMetadataOverlay))
464
+ return options?.categoryId ? products.filter((product) => product.categoryId === options.categoryId) : products
465
+ },
466
+ async getProduct(id: string) {
467
+ const query = singleById(id)
468
+ query.set('select', '*,images:product_images(*),category:categories(name)')
469
+ const rows = await request<ProductRow[]>('products', { query })
470
+ return rows[0] ? rowToProduct(rows[0], productMetadataOverlay) : null
471
+ },
472
+ async createProduct() {
473
+ throw new FayzShopError('Product writes require the Fayz admin/broker API.', 501)
474
+ },
475
+ async updateProduct() {
476
+ throw new FayzShopError('Product writes require the Fayz admin/broker API.', 501)
477
+ },
478
+ async deleteProduct() {
479
+ throw new FayzShopError('Product writes require the Fayz admin/broker API.', 501)
480
+ },
481
+ async uploadProductImage() {
482
+ throw new FayzShopError('Product image uploads require the Fayz admin/broker API.', 501)
483
+ },
484
+ async deleteProductImage() {
485
+ throw new FayzShopError('Product image deletes require the Fayz admin/broker API.', 501)
486
+ },
487
+ async listCategories() {
488
+ const productQuery = tenantQuery()
489
+ productQuery.set('select', 'metadata')
490
+ productQuery.set('order', 'sort_order.asc')
491
+ const products = await request<ProductRow[]>('products', { query: productQuery })
492
+ const storeCategories = deriveStoreCategories(products, storeId)
493
+ if (storeCategories.length > 0) return storeCategories
494
+
495
+ const query = new URLSearchParams()
496
+ query.set('select', '*')
497
+ query.set('order', 'sort_order.asc')
498
+ return (await request<CategoryRow[]>('categories', { query })).map(rowToCategory)
499
+ },
500
+ async createCategory() {
501
+ throw new FayzShopError('Category writes require the Fayz admin/broker API.', 501)
502
+ },
503
+ async updateCategory() {
504
+ throw new FayzShopError('Category writes require the Fayz admin/broker API.', 501)
505
+ },
506
+ async deleteCategory() {
507
+ throw new FayzShopError('Category deletes require the Fayz admin/broker API.', 501)
508
+ },
509
+ async listOrders(options?: FayzShopListOrdersOptions) {
510
+ const query = tenantQuery()
511
+ query.set('select', '*,items:order_items(*)')
512
+ if (options?.status) query.set('status', `eq.${options.status}`)
513
+ if (options?.financialStatus) query.set('financial_status', `eq.${options.financialStatus}`)
514
+ if (options?.fulfillmentStatus) query.set('fulfillment_status', `eq.${options.fulfillmentStatus}`)
515
+ if (options?.customerId) query.set('customer_id', `eq.${options.customerId}`)
516
+ if (options?.customerEmail) query.set('customer_email', `eq.${options.customerEmail}`)
517
+ if (options?.search) query.set('or', `(customer_name.ilike.*${options.search}*,customer_email.ilike.*${options.search}*)`)
518
+ query.set('order', 'created_at.desc')
519
+ if (options?.limit) query.set('limit', String(options.limit))
520
+ if (options?.offset) query.set('offset', String(options.offset))
521
+ return (await request<OrderRow[]>('orders', { query })).map(rowToOrder)
522
+ },
523
+ async getOrder(id: string) {
524
+ const query = singleById(id)
525
+ query.set('select', '*,items:order_items(*)')
526
+ const rows = await request<OrderRow[]>('orders', { query })
527
+ return rows[0] ? rowToOrder(rows[0]) : null
528
+ },
529
+ async createOrder(input: {
530
+ customerId?: string
531
+ customerName?: string
532
+ customerEmail?: string
533
+ currency?: string
534
+ notes?: string
535
+ discountCode?: string
536
+ discountTotal?: number
537
+ shippingTotal?: number
538
+ items: Array<{ productId?: string; name: string; sku?: string; quantity: number; unitPrice: number; imageUrl?: string }>
539
+ }) {
540
+ const subtotal = input.items.reduce((sum, item) => sum + item.quantity * item.unitPrice, 0)
541
+ const discountTotal = input.discountTotal ?? 0
542
+ const shippingTotal = input.shippingTotal ?? 0
543
+ const total = Math.round((subtotal - discountTotal + shippingTotal) * 100) / 100
544
+ const [order] = await request<OrderRow[]>('orders', {
545
+ method: 'POST',
546
+ body: JSON.stringify({
547
+ tenant_id: storeId,
548
+ customer_id: input.customerId ?? null,
549
+ customer_name: input.customerName ?? null,
550
+ customer_email: input.customerEmail ?? null,
551
+ currency: input.currency ?? 'BRL',
552
+ notes: input.notes ?? null,
553
+ subtotal,
554
+ discount_total: discountTotal,
555
+ shipping_total: shippingTotal,
556
+ discount_code: input.discountCode ?? null,
557
+ total,
558
+ status: 'open',
559
+ financial_status: 'pending',
560
+ fulfillment_status: 'unfulfilled',
561
+ }),
562
+ })
563
+ if (!order) throw new FayzShopError('Order insert did not return a row.', 500)
564
+ if (input.items.length) {
565
+ await request<OrderItemRow[]>('order_items', {
566
+ method: 'POST',
567
+ body: JSON.stringify(input.items.map((item) => ({
568
+ order_id: order.id,
569
+ product_id: asUuid(item.productId),
570
+ name: item.name,
571
+ sku: item.sku ?? null,
572
+ quantity: item.quantity,
573
+ unit_price: item.unitPrice,
574
+ total: item.quantity * item.unitPrice,
575
+ image_url: item.imageUrl ?? null,
576
+ }))),
577
+ })
578
+ }
579
+ return this.getOrder(order.id)
580
+ },
581
+ async updateOrder(id: string, input: Parameters<typeof updateOrderPayload>[0]) {
582
+ await request<OrderRow[]>('orders', {
583
+ method: 'PATCH',
584
+ query: singleById(id),
585
+ body: JSON.stringify(updateOrderPayload(input)),
586
+ })
587
+ return this.getOrder(id)
588
+ },
589
+ async listCustomers(options?: FayzShopListCustomersOptions) {
590
+ const query = tenantQuery()
591
+ query.set('select', '*')
592
+ query.set('order', 'first_name.asc')
593
+ if (options?.search) query.set('or', `(first_name.ilike.*${options.search}*,last_name.ilike.*${options.search}*,email.ilike.*${options.search}*)`)
594
+ if (options?.limit) query.set('limit', String(options.limit))
595
+ if (options?.offset) query.set('offset', String(options.offset))
596
+ return (await request<CustomerRow[]>('customers', { query })).map(rowToCustomer)
597
+ },
598
+ async getCustomer(id: string) {
599
+ const rows = await request<CustomerRow[]>('customers', { query: singleById(id) })
600
+ return rows[0] ? rowToCustomer(rows[0]) : null
601
+ },
602
+ async createCustomer(input: { firstName: string; lastName?: string; email?: string; phone?: string; notes?: string }) {
603
+ const [customer] = await request<CustomerRow[]>('customers', {
604
+ method: 'POST',
605
+ body: JSON.stringify({
606
+ tenant_id: storeId,
607
+ first_name: input.firstName,
608
+ last_name: input.lastName ?? '',
609
+ email: input.email ?? null,
610
+ phone: input.phone ?? null,
611
+ notes: input.notes ?? null,
612
+ }),
613
+ })
614
+ if (!customer) throw new FayzShopError('Customer insert did not return a row.', 500)
615
+ return rowToCustomer(customer)
616
+ },
617
+ async updateCustomer(id: string, input: { firstName?: string; lastName?: string; email?: string | null; phone?: string | null; notes?: string | null }) {
618
+ const updates: Record<string, unknown> = {}
619
+ if (input.firstName !== undefined) updates.first_name = input.firstName
620
+ if (input.lastName !== undefined) updates.last_name = input.lastName
621
+ if (input.email !== undefined) updates.email = input.email
622
+ if (input.phone !== undefined) updates.phone = input.phone
623
+ if (input.notes !== undefined) updates.notes = input.notes
624
+ const [customer] = await request<CustomerRow[]>('customers', {
625
+ method: 'PATCH',
626
+ query: singleById(id),
627
+ body: JSON.stringify(updates),
628
+ })
629
+ if (!customer) throw new FayzShopError('Customer update did not return a row.', 500)
630
+ return rowToCustomer(customer)
631
+ },
632
+ async deleteCustomer(id: string) {
633
+ await request<unknown>('customers', { method: 'DELETE', query: singleById(id) })
634
+ },
635
+ async listDiscounts(options?: FayzShopListDiscountsOptions) {
636
+ const query = tenantQuery()
637
+ query.set('select', '*')
638
+ query.set('order', 'created_at.desc')
639
+ if (options?.status) query.set('status', `eq.${options.status}`)
640
+ if (options?.type) query.set('type', `eq.${options.type}`)
641
+ if (options?.search) query.set('title', `ilike.*${options.search}*`)
642
+ if (options?.limit) query.set('limit', String(options.limit))
643
+ if (options?.offset) query.set('offset', String(options.offset))
644
+ return (await request<DiscountRow[]>('discounts', { query })).map(rowToDiscount)
645
+ },
646
+ async getDiscount(id: string) {
647
+ const rows = await request<DiscountRow[]>('discounts', { query: singleById(id) })
648
+ return rows[0] ? rowToDiscount(rows[0]) : null
649
+ },
650
+ async createDiscount() {
651
+ throw new FayzShopError('Discount writes require the Fayz admin/broker API.', 501)
652
+ },
653
+ async updateDiscount() {
654
+ throw new FayzShopError('Discount writes require the Fayz admin/broker API.', 501)
655
+ },
656
+ async deleteDiscount() {
657
+ throw new FayzShopError('Discount deletes require the Fayz admin/broker API.', 501)
658
+ },
659
+ }
660
+ }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/client.ts"],"names":[],"mappings":";;;;AAgBO,IAAM,YAAA,GAAN,cAA2B,KAAA,CAAM;AAAA,EACtC,WAAA,CACE,OAAA,EACS,MAAA,EACA,YAAA,EACT;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAHJ,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AACA,IAAA,IAAA,CAAA,YAAA,GAAA,YAAA;AAGT,IAAA,IAAA,CAAK,IAAA,GAAO,cAAA;AAAA,EACd;AACF;AAEA,SAAS,iBAAiB,OAAA,EAAyB;AACjD,EAAA,OAAO,OAAA,CAAQ,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA;AACnC;AAEA,SAAS,QAAQ,IAAA,EAAsB;AACrC,EAAA,IAAI,cAAA,CAAe,IAAA,CAAK,IAAI,CAAA,EAAG,OAAO,IAAA;AACtC,EAAA,MAAM,aAAa,IAAA,CAAK,UAAA,CAAW,GAAG,CAAA,GAAI,IAAA,GAAO,IAAI,IAAI,CAAA,CAAA;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zAuthMeResponse, FayzUser } from './types'\n\nexport interface FayzClientOptions {\n baseUrl?: string\n token?: string | (() => string | undefined | Promise<string | undefined>)\n appId?: string\n fetcher?: typeof fetch\n}\n\nexport interface FayzRequestOptions extends Omit<RequestInit, 'headers'> {\n headers?: Record<string, string>\n token?: string\n}\n\nexport class FayzApiError extends Error {\n constructor(\n message: string,\n readonly status: number,\n readonly responseBody?: unknown,\n ) {\n super(message)\n this.name = 'FayzApiError'\n }\n}\n\nfunction normalizeBaseUrl(baseUrl: string): string {\n return baseUrl.replace(/\\/+$/, '')\n}\n\nfunction apiPath(path: string): string {\n if (/^https?:\\/\\//.test(path)) return path\n const normalized = path.startsWith('/') ? path : `/${path}`\n return normalized.startsWith('/api/') ? normalized : `/api${normalized}`\n}\n\nasync function parseResponse<T>(response: Response): Promise<T> {\n if (response.status === 204) return undefined as T\n\n const text = await response.text()\n let body: unknown\n try {\n body = text ? JSON.parse(text) : undefined\n } catch {\n body = text\n }\n\n if (!response.ok) {\n const message = typeof body === 'object' && body\n ? String((body as { message?: unknown; error?: unknown }).message ?? (body as { error?: unknown }).error ?? `Fayz API request failed with status ${response.status}`)\n : `Fayz API request failed with status ${response.status}`\n throw new FayzApiError(message, response.status, body)\n }\n\n return body as T\n}\n\nasync function resolveToken(token: FayzClientOptions['token']): Promise<string | undefined> {\n return typeof token === 'function' ? token() : token\n}\n\nfunction unwrapUser(body: FayzUser | FayzAuthMeResponse): FayzUser {\n return typeof body === 'object' && body && 'user' in body\n ? (body as FayzAuthMeResponse).user\n : body as FayzUser\n}\n\nexport function createFayzClient(options: FayzClientOptions = {}) {\n const baseUrl = normalizeBaseUrl(options.baseUrl ?? appParams.apiBaseUrl)\n const fetcher = options.fetcher ?? fetch\n const appId = options.appId ?? appParams.appId\n const token = options.token ?? appParams.token\n\n async function request<T>(path: string, init: FayzRequestOptions = {}): Promise<T> {\n const requestToken = init.token ?? await resolveToken(token)\n const headers: Record<string, string> = {\n ...(init.body ? { 'Content-Type': 'application/json' } : {}),\n ...(appId ? { 'X-App-Id': appId } : {}),\n ...init.headers,\n ...(requestToken ? { Authorization: `Bearer ${requestToken}` } : {}),\n }\n const response = await fetcher(`${baseUrl}${apiPath(path)}`, {\n ...init,\n headers,\n })\n return parseResponse<T>(response)\n }\n\n return {\n request,\n auth: {\n async me(): Promise<FayzUser> {\n return unwrapUser(await request<FayzUser | FayzAuthMeResponse>('/auth/me'))\n },\n },\n runtime: {\n createClient: createFayzRuntimeClient,\n },\n }\n}\n\nexport const fayz = createFayzClient()\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/client.ts"],"names":["appParams","createFayzRuntimeClient"],"mappings":";;;;;;AAgBO,IAAM,YAAA,GAAN,cAA2B,KAAA,CAAM;AAAA,EACtC,WAAA,CACE,OAAA,EACS,MAAA,EACA,YAAA,EACT;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAHJ,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AACA,IAAA,IAAA,CAAA,YAAA,GAAA,YAAA;AAGT,IAAA,IAAA,CAAK,IAAA,GAAO,cAAA;AAAA,EACd;AACF;AAEA,SAAS,iBAAiB,OAAA,EAAyB;AACjD,EAAA,OAAO,OAAA,CAAQ,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA;AACnC;AAEA,SAAS,QAAQ,IAAA,EAAsB;AACrC,EAAA,IAAI,cAAA,CAAe,IAAA,CAAK,IAAI,CAAA,EAAG,OAAO,IAAA;AACtC,EAAA,MAAM,aAAa,IAAA,CAAK,UAAA,CAAW,GAAG,CAAA,GAAI,IAAA,GAAO,IAAI,IAAI,CAAA,CAAA;AACzD,EAAA,OAAO,WAAW,UAAA,CAAW,OAAO,CAAA,GAAI,UAAA,GAAa,OAAO,UAAU,CAAA,CAAA;AACxE;AAEA,eAAe,cAAiB,QAAA,EAAgC;AAC9D,EAAA,IAAI,QAAA,CAAS,MAAA,KAAW,GAAA,EAAK,OAAO,MAAA;AAEpC,EAAA,MAAM,IAAA,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Ae,OAAA,CAAW,IAAA,EAAc,IAAA,GAA2B,EAAC,EAAe;AACjF,IAAA,MAAM,YAAA,GAAe,IAAA,CAAK,KAAA,IAAS,MAAM,aAAa,KAAK,CAAA;AAC3D,IAAA,MAAM,OAAA,GAAkC;AAAA,MACtC,GAAI,IAAA,CAAK,IAAA,GAAO,EAAE,cAAA,EAAgB,kBAAA,KAAuB,EAAC;AAAA,MAC1D,GAAI,KAAA,GAAQ,EAAE,UAAA,EAAY,KAAA,KAAU,EAAC;AAAA,MACrC,GAAG,IAAA,CAAK,OAAA;AAAA,MACR,GAAI,eAAe,EAAE,aAAA,EAAe,UAAU,YAAY,CAAA,CAAA,KAAO;AAAC,KACpE;AACA,IAAA,MAAM,QAAA,GAAW,MAAM,OAAA,CAAQ,CAAA,EAAG,OAAO,CAAA,EAAG,OAAA,CAAQ,IAAI,CAAC,CAAA,CAAA,EAAI;AAAA,MAC3D,GAAG,IAAA;AAAA,MACH;AAAA,KACD,CAAA;AACD,IAAA,OAAO,cAAiB,QAAQ,CAAA;AAAA,EAClC;AAEA,EAAA,OAAO;AAAA,IACL,OAAA;AAAA,IACA,IAAA,EAAM;AAAA,MACJ,MAAM,EAAA,GAAwB;AAC5B,QAAA,OAAO,UAAA,CAAW,MAAM,OAAA,CAAuC,UAAU,CAAC,CAAA;AAAA,MAC5E;AAAA,KACF;AAAA,IACA,OAAA,EAAS;AAAA,MACP,YAAA,EAAcC;AAAA;AAChB,GACF;AACF;AAEO,IAAM,OAAO,gBAAA","file":"chunk-REGBJXXB.cjs","sourcesContent":["import { appParams } from './app-params'\nimport { createFayzRuntimeClient } from './runtime'\nimport type { FayzAuthMeResponse, FayzUser } from './types'\n\nexport interface FayzClientOptions {\n baseUrl?: string\n token?: string | (() => string | undefined | Promise<string | undefined>)\n appId?: string\n fetcher?: typeof fetch\n}\n\nexport interface FayzRequestOptions extends Omit<RequestInit, 'headers'> {\n headers?: Record<string, string>\n token?: string\n}\n\nexport class FayzApiError extends Error {\n constructor(\n message: string,\n readonly status: number,\n readonly responseBody?: unknown,\n ) {\n super(message)\n this.name = 'FayzApiError'\n }\n}\n\nfunction normalizeBaseUrl(baseUrl: string): string {\n return baseUrl.replace(/\\/+$/, '')\n}\n\nfunction apiPath(path: string): string {\n if (/^https?:\\/\\//.test(path)) return path\n const normalized = path.startsWith('/') ? path : `/${path}`\n return normalized.startsWith('/api/') ? normalized : `/api${normalized}`\n}\n\nasync function parseResponse<T>(response: Response): Promise<T> {\n if (response.status === 204) return undefined as T\n\n const text = await response.text()\n let body: unknown\n try {\n body = text ? JSON.parse(text) : undefined\n } catch {\n body = text\n }\n\n if (!response.ok) {\n const message = typeof body === 'object' && body\n ? String((body as { message?: unknown; error?: unknown }).message ?? (body as { error?: unknown }).error ?? `Fayz API request failed with status ${response.status}`)\n : `Fayz API request failed with status ${response.status}`\n throw new FayzApiError(message, response.status, body)\n }\n\n return body as T\n}\n\nasync function resolveToken(token: FayzClientOptions['token']): Promise<string | undefined> {\n return typeof token === 'function' ? token() : token\n}\n\nfunction unwrapUser(body: FayzUser | FayzAuthMeResponse): FayzUser {\n return typeof body === 'object' && body && 'user' in body\n ? (body as FayzAuthMeResponse).user\n : body as FayzUser\n}\n\nexport function createFayzClient(options: FayzClientOptions = {}) {\n const baseUrl = normalizeBaseUrl(options.baseUrl ?? appParams.apiBaseUrl)\n const fetcher = options.fetcher ?? fetch\n const appId = options.appId ?? appParams.appId\n const token = options.token ?? appParams.token\n\n async function request<T>(path: string, init: FayzRequestOptions = {}): Promise<T> {\n const requestToken = init.token ?? await resolveToken(token)\n const headers: Record<string, string> = {\n ...(init.body ? { 'Content-Type': 'application/json' } : {}),\n ...(appId ? { 'X-App-Id': appId } : {}),\n ...init.headers,\n ...(requestToken ? { Authorization: `Bearer ${requestToken}` } : {}),\n }\n const response = await fetcher(`${baseUrl}${apiPath(path)}`, {\n ...init,\n headers,\n })\n return parseResponse<T>(response)\n }\n\n return {\n request,\n auth: {\n async me(): Promise<FayzUser> {\n return unwrapUser(await request<FayzUser | FayzAuthMeResponse>('/auth/me'))\n },\n },\n runtime: {\n createClient: createFayzRuntimeClient,\n },\n }\n}\n\nexport const fayz = createFayzClient()\n"]}