@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.
- package/README.md +20 -1
- package/dist/chunk-3VVLBMKG.cjs +442 -0
- package/dist/chunk-3VVLBMKG.cjs.map +1 -0
- package/dist/chunk-7FF2FLPG.js +45 -0
- package/dist/chunk-7FF2FLPG.js.map +1 -0
- package/dist/chunk-JBQDG2GN.js +439 -0
- package/dist/chunk-JBQDG2GN.js.map +1 -0
- package/dist/chunk-JXXIKYP3.cjs +50 -0
- package/dist/chunk-JXXIKYP3.cjs.map +1 -0
- package/dist/{chunk-REGBJXXB.cjs → chunk-MCB2L25R.cjs} +60 -2
- package/dist/chunk-MCB2L25R.cjs.map +1 -0
- package/dist/{chunk-O6XSRB3Q.js → chunk-R4XVCBFG.js} +60 -2
- package/dist/chunk-R4XVCBFG.js.map +1 -0
- package/dist/client.cjs +4 -4
- package/dist/client.d.ts +54 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -1
- package/dist/index.cjs +30 -4
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/release-channels.cjs +24 -0
- package/dist/release-channels.cjs.map +1 -0
- package/dist/release-channels.d.ts +10 -0
- package/dist/release-channels.d.ts.map +1 -0
- package/dist/release-channels.js +3 -0
- package/dist/release-channels.js.map +1 -0
- package/dist/shop.cjs +16 -0
- package/dist/shop.cjs.map +1 -0
- package/dist/shop.d.ts +391 -0
- package/dist/shop.d.ts.map +1 -0
- package/dist/shop.js +3 -0
- package/dist/shop.js.map +1 -0
- package/package.json +15 -2
- package/src/client.test.ts +135 -0
- package/src/client.ts +126 -0
- package/src/index.ts +36 -1
- package/src/release-channels.json +13 -0
- package/src/release-channels.test.ts +42 -0
- package/src/release-channels.ts +41 -0
- package/src/runtime.test.ts +4 -4
- package/src/shop.test.ts +83 -0
- package/src/shop.ts +660 -0
- package/dist/chunk-O6XSRB3Q.js.map +0 -1
- package/dist/chunk-REGBJXXB.cjs.map +0 -1
package/dist/shop.d.ts
ADDED
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
export interface FayzShopProviderOptions {
|
|
2
|
+
supabaseUrl: string;
|
|
3
|
+
publishableKey: string;
|
|
4
|
+
storeId: string;
|
|
5
|
+
productMetadata?: FayzShopProductMetadataOverlay[];
|
|
6
|
+
fetcher?: typeof fetch;
|
|
7
|
+
}
|
|
8
|
+
export interface FayzShopProductMetadataOverlay {
|
|
9
|
+
sku?: string | null;
|
|
10
|
+
slug?: string | null;
|
|
11
|
+
metadata: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
export type FayzShopProductStatus = 'draft' | 'active' | 'archived';
|
|
14
|
+
export type FayzShopOrderStatus = 'open' | 'archived' | 'cancelled';
|
|
15
|
+
export type FayzShopFinancialStatus = 'pending' | 'paid' | 'partially_paid' | 'refunded' | 'partially_refunded' | 'voided';
|
|
16
|
+
export type FayzShopFulfillmentStatus = 'unfulfilled' | 'partially_fulfilled' | 'fulfilled';
|
|
17
|
+
export interface FayzShopListProductsOptions {
|
|
18
|
+
status?: FayzShopProductStatus;
|
|
19
|
+
categoryId?: string;
|
|
20
|
+
search?: string;
|
|
21
|
+
slug?: string;
|
|
22
|
+
limit?: number;
|
|
23
|
+
offset?: number;
|
|
24
|
+
orderBy?: 'name' | 'price' | 'created_at' | 'sort_order';
|
|
25
|
+
order?: 'asc' | 'desc';
|
|
26
|
+
}
|
|
27
|
+
export interface FayzShopListOrdersOptions {
|
|
28
|
+
status?: FayzShopOrderStatus;
|
|
29
|
+
financialStatus?: FayzShopFinancialStatus;
|
|
30
|
+
fulfillmentStatus?: FayzShopFulfillmentStatus;
|
|
31
|
+
customerId?: string;
|
|
32
|
+
customerEmail?: string;
|
|
33
|
+
search?: string;
|
|
34
|
+
limit?: number;
|
|
35
|
+
offset?: number;
|
|
36
|
+
}
|
|
37
|
+
export interface FayzShopListCustomersOptions {
|
|
38
|
+
search?: string;
|
|
39
|
+
limit?: number;
|
|
40
|
+
offset?: number;
|
|
41
|
+
}
|
|
42
|
+
export interface FayzShopListDiscountsOptions {
|
|
43
|
+
status?: string;
|
|
44
|
+
type?: string;
|
|
45
|
+
search?: string;
|
|
46
|
+
limit?: number;
|
|
47
|
+
offset?: number;
|
|
48
|
+
}
|
|
49
|
+
export declare class FayzShopError extends Error {
|
|
50
|
+
readonly status: number;
|
|
51
|
+
readonly responseBody?: unknown | undefined;
|
|
52
|
+
constructor(message: string, status: number, responseBody?: unknown | undefined);
|
|
53
|
+
}
|
|
54
|
+
declare function updateOrderPayload(input: {
|
|
55
|
+
status?: FayzShopOrderStatus;
|
|
56
|
+
financialStatus?: FayzShopFinancialStatus;
|
|
57
|
+
fulfillmentStatus?: FayzShopFulfillmentStatus;
|
|
58
|
+
notes?: string;
|
|
59
|
+
}): Record<string, unknown>;
|
|
60
|
+
export declare function createFayzShopProvider(options: FayzShopProviderOptions): {
|
|
61
|
+
listProducts(options?: FayzShopListProductsOptions): Promise<{
|
|
62
|
+
id: string;
|
|
63
|
+
tenantId: string;
|
|
64
|
+
name: string;
|
|
65
|
+
slug: string;
|
|
66
|
+
description: string | null;
|
|
67
|
+
price: number;
|
|
68
|
+
compareAtPrice: number | null;
|
|
69
|
+
currency: string;
|
|
70
|
+
status: FayzShopProductStatus;
|
|
71
|
+
inventoryCount: number;
|
|
72
|
+
sku: string | null;
|
|
73
|
+
sortOrder: number;
|
|
74
|
+
metadata: Record<string, unknown>;
|
|
75
|
+
images: {
|
|
76
|
+
id: string;
|
|
77
|
+
productId: string;
|
|
78
|
+
url: string;
|
|
79
|
+
altText: string | null;
|
|
80
|
+
sortOrder: number;
|
|
81
|
+
isPrimary: boolean;
|
|
82
|
+
createdAt: string;
|
|
83
|
+
}[];
|
|
84
|
+
categoryId: string | null;
|
|
85
|
+
categoryName: string | null;
|
|
86
|
+
isPhysical: boolean;
|
|
87
|
+
weight: number | null;
|
|
88
|
+
weightUnit: string;
|
|
89
|
+
createdAt: string;
|
|
90
|
+
updatedAt: string;
|
|
91
|
+
}[]>;
|
|
92
|
+
getProduct(id: string): Promise<{
|
|
93
|
+
id: string;
|
|
94
|
+
tenantId: string;
|
|
95
|
+
name: string;
|
|
96
|
+
slug: string;
|
|
97
|
+
description: string | null;
|
|
98
|
+
price: number;
|
|
99
|
+
compareAtPrice: number | null;
|
|
100
|
+
currency: string;
|
|
101
|
+
status: FayzShopProductStatus;
|
|
102
|
+
inventoryCount: number;
|
|
103
|
+
sku: string | null;
|
|
104
|
+
sortOrder: number;
|
|
105
|
+
metadata: Record<string, unknown>;
|
|
106
|
+
images: {
|
|
107
|
+
id: string;
|
|
108
|
+
productId: string;
|
|
109
|
+
url: string;
|
|
110
|
+
altText: string | null;
|
|
111
|
+
sortOrder: number;
|
|
112
|
+
isPrimary: boolean;
|
|
113
|
+
createdAt: string;
|
|
114
|
+
}[];
|
|
115
|
+
categoryId: string | null;
|
|
116
|
+
categoryName: string | null;
|
|
117
|
+
isPhysical: boolean;
|
|
118
|
+
weight: number | null;
|
|
119
|
+
weightUnit: string;
|
|
120
|
+
createdAt: string;
|
|
121
|
+
updatedAt: string;
|
|
122
|
+
} | null>;
|
|
123
|
+
createProduct(): Promise<never>;
|
|
124
|
+
updateProduct(): Promise<never>;
|
|
125
|
+
deleteProduct(): Promise<never>;
|
|
126
|
+
uploadProductImage(): Promise<never>;
|
|
127
|
+
deleteProductImage(): Promise<never>;
|
|
128
|
+
listCategories(): Promise<{
|
|
129
|
+
id: string;
|
|
130
|
+
tenantId: string;
|
|
131
|
+
name: string;
|
|
132
|
+
slug: string;
|
|
133
|
+
description: string | null;
|
|
134
|
+
parentId: string | null;
|
|
135
|
+
sortOrder: number;
|
|
136
|
+
imageUrl: string | null;
|
|
137
|
+
createdAt: string;
|
|
138
|
+
}[]>;
|
|
139
|
+
createCategory(): Promise<never>;
|
|
140
|
+
updateCategory(): Promise<never>;
|
|
141
|
+
deleteCategory(): Promise<never>;
|
|
142
|
+
listOrders(options?: FayzShopListOrdersOptions): Promise<{
|
|
143
|
+
id: string;
|
|
144
|
+
tenantId: string;
|
|
145
|
+
orderNumber: number;
|
|
146
|
+
status: FayzShopOrderStatus;
|
|
147
|
+
financialStatus: FayzShopFinancialStatus;
|
|
148
|
+
fulfillmentStatus: FayzShopFulfillmentStatus;
|
|
149
|
+
currency: string;
|
|
150
|
+
subtotal: number;
|
|
151
|
+
taxTotal: number;
|
|
152
|
+
discountTotal: number;
|
|
153
|
+
shippingTotal: number;
|
|
154
|
+
total: number;
|
|
155
|
+
customerId: string | null;
|
|
156
|
+
customerName: string | null;
|
|
157
|
+
customerEmail: string | null;
|
|
158
|
+
discountCode: string | null;
|
|
159
|
+
notes: string | null;
|
|
160
|
+
items: {
|
|
161
|
+
id: string;
|
|
162
|
+
orderId: string;
|
|
163
|
+
productId: string | null;
|
|
164
|
+
name: string;
|
|
165
|
+
sku: string | null;
|
|
166
|
+
quantity: number;
|
|
167
|
+
unitPrice: number;
|
|
168
|
+
total: number;
|
|
169
|
+
imageUrl: string | null;
|
|
170
|
+
}[];
|
|
171
|
+
createdAt: string;
|
|
172
|
+
updatedAt: string;
|
|
173
|
+
}[]>;
|
|
174
|
+
getOrder(id: string): Promise<{
|
|
175
|
+
id: string;
|
|
176
|
+
tenantId: string;
|
|
177
|
+
orderNumber: number;
|
|
178
|
+
status: FayzShopOrderStatus;
|
|
179
|
+
financialStatus: FayzShopFinancialStatus;
|
|
180
|
+
fulfillmentStatus: FayzShopFulfillmentStatus;
|
|
181
|
+
currency: string;
|
|
182
|
+
subtotal: number;
|
|
183
|
+
taxTotal: number;
|
|
184
|
+
discountTotal: number;
|
|
185
|
+
shippingTotal: number;
|
|
186
|
+
total: number;
|
|
187
|
+
customerId: string | null;
|
|
188
|
+
customerName: string | null;
|
|
189
|
+
customerEmail: string | null;
|
|
190
|
+
discountCode: string | null;
|
|
191
|
+
notes: string | null;
|
|
192
|
+
items: {
|
|
193
|
+
id: string;
|
|
194
|
+
orderId: string;
|
|
195
|
+
productId: string | null;
|
|
196
|
+
name: string;
|
|
197
|
+
sku: string | null;
|
|
198
|
+
quantity: number;
|
|
199
|
+
unitPrice: number;
|
|
200
|
+
total: number;
|
|
201
|
+
imageUrl: string | null;
|
|
202
|
+
}[];
|
|
203
|
+
createdAt: string;
|
|
204
|
+
updatedAt: string;
|
|
205
|
+
} | null>;
|
|
206
|
+
createOrder(input: {
|
|
207
|
+
customerId?: string;
|
|
208
|
+
customerName?: string;
|
|
209
|
+
customerEmail?: string;
|
|
210
|
+
currency?: string;
|
|
211
|
+
notes?: string;
|
|
212
|
+
discountCode?: string;
|
|
213
|
+
discountTotal?: number;
|
|
214
|
+
shippingTotal?: number;
|
|
215
|
+
items: Array<{
|
|
216
|
+
productId?: string;
|
|
217
|
+
name: string;
|
|
218
|
+
sku?: string;
|
|
219
|
+
quantity: number;
|
|
220
|
+
unitPrice: number;
|
|
221
|
+
imageUrl?: string;
|
|
222
|
+
}>;
|
|
223
|
+
}): Promise<{
|
|
224
|
+
id: string;
|
|
225
|
+
tenantId: string;
|
|
226
|
+
orderNumber: number;
|
|
227
|
+
status: FayzShopOrderStatus;
|
|
228
|
+
financialStatus: FayzShopFinancialStatus;
|
|
229
|
+
fulfillmentStatus: FayzShopFulfillmentStatus;
|
|
230
|
+
currency: string;
|
|
231
|
+
subtotal: number;
|
|
232
|
+
taxTotal: number;
|
|
233
|
+
discountTotal: number;
|
|
234
|
+
shippingTotal: number;
|
|
235
|
+
total: number;
|
|
236
|
+
customerId: string | null;
|
|
237
|
+
customerName: string | null;
|
|
238
|
+
customerEmail: string | null;
|
|
239
|
+
discountCode: string | null;
|
|
240
|
+
notes: string | null;
|
|
241
|
+
items: {
|
|
242
|
+
id: string;
|
|
243
|
+
orderId: string;
|
|
244
|
+
productId: string | null;
|
|
245
|
+
name: string;
|
|
246
|
+
sku: string | null;
|
|
247
|
+
quantity: number;
|
|
248
|
+
unitPrice: number;
|
|
249
|
+
total: number;
|
|
250
|
+
imageUrl: string | null;
|
|
251
|
+
}[];
|
|
252
|
+
createdAt: string;
|
|
253
|
+
updatedAt: string;
|
|
254
|
+
} | null>;
|
|
255
|
+
updateOrder(id: string, input: Parameters<typeof updateOrderPayload>[0]): Promise<{
|
|
256
|
+
id: string;
|
|
257
|
+
tenantId: string;
|
|
258
|
+
orderNumber: number;
|
|
259
|
+
status: FayzShopOrderStatus;
|
|
260
|
+
financialStatus: FayzShopFinancialStatus;
|
|
261
|
+
fulfillmentStatus: FayzShopFulfillmentStatus;
|
|
262
|
+
currency: string;
|
|
263
|
+
subtotal: number;
|
|
264
|
+
taxTotal: number;
|
|
265
|
+
discountTotal: number;
|
|
266
|
+
shippingTotal: number;
|
|
267
|
+
total: number;
|
|
268
|
+
customerId: string | null;
|
|
269
|
+
customerName: string | null;
|
|
270
|
+
customerEmail: string | null;
|
|
271
|
+
discountCode: string | null;
|
|
272
|
+
notes: string | null;
|
|
273
|
+
items: {
|
|
274
|
+
id: string;
|
|
275
|
+
orderId: string;
|
|
276
|
+
productId: string | null;
|
|
277
|
+
name: string;
|
|
278
|
+
sku: string | null;
|
|
279
|
+
quantity: number;
|
|
280
|
+
unitPrice: number;
|
|
281
|
+
total: number;
|
|
282
|
+
imageUrl: string | null;
|
|
283
|
+
}[];
|
|
284
|
+
createdAt: string;
|
|
285
|
+
updatedAt: string;
|
|
286
|
+
} | null>;
|
|
287
|
+
listCustomers(options?: FayzShopListCustomersOptions): Promise<{
|
|
288
|
+
id: string;
|
|
289
|
+
tenantId: string;
|
|
290
|
+
firstName: string;
|
|
291
|
+
lastName: string;
|
|
292
|
+
email: string | null;
|
|
293
|
+
phone: string | null;
|
|
294
|
+
notes: string | null;
|
|
295
|
+
ordersCount: number;
|
|
296
|
+
totalSpent: number;
|
|
297
|
+
createdAt: string;
|
|
298
|
+
updatedAt: string;
|
|
299
|
+
}[]>;
|
|
300
|
+
getCustomer(id: string): Promise<{
|
|
301
|
+
id: string;
|
|
302
|
+
tenantId: string;
|
|
303
|
+
firstName: string;
|
|
304
|
+
lastName: string;
|
|
305
|
+
email: string | null;
|
|
306
|
+
phone: string | null;
|
|
307
|
+
notes: string | null;
|
|
308
|
+
ordersCount: number;
|
|
309
|
+
totalSpent: number;
|
|
310
|
+
createdAt: string;
|
|
311
|
+
updatedAt: string;
|
|
312
|
+
} | null>;
|
|
313
|
+
createCustomer(input: {
|
|
314
|
+
firstName: string;
|
|
315
|
+
lastName?: string;
|
|
316
|
+
email?: string;
|
|
317
|
+
phone?: string;
|
|
318
|
+
notes?: string;
|
|
319
|
+
}): Promise<{
|
|
320
|
+
id: string;
|
|
321
|
+
tenantId: string;
|
|
322
|
+
firstName: string;
|
|
323
|
+
lastName: string;
|
|
324
|
+
email: string | null;
|
|
325
|
+
phone: string | null;
|
|
326
|
+
notes: string | null;
|
|
327
|
+
ordersCount: number;
|
|
328
|
+
totalSpent: number;
|
|
329
|
+
createdAt: string;
|
|
330
|
+
updatedAt: string;
|
|
331
|
+
}>;
|
|
332
|
+
updateCustomer(id: string, input: {
|
|
333
|
+
firstName?: string;
|
|
334
|
+
lastName?: string;
|
|
335
|
+
email?: string | null;
|
|
336
|
+
phone?: string | null;
|
|
337
|
+
notes?: string | null;
|
|
338
|
+
}): Promise<{
|
|
339
|
+
id: string;
|
|
340
|
+
tenantId: string;
|
|
341
|
+
firstName: string;
|
|
342
|
+
lastName: string;
|
|
343
|
+
email: string | null;
|
|
344
|
+
phone: string | null;
|
|
345
|
+
notes: string | null;
|
|
346
|
+
ordersCount: number;
|
|
347
|
+
totalSpent: number;
|
|
348
|
+
createdAt: string;
|
|
349
|
+
updatedAt: string;
|
|
350
|
+
}>;
|
|
351
|
+
deleteCustomer(id: string): Promise<void>;
|
|
352
|
+
listDiscounts(options?: FayzShopListDiscountsOptions): Promise<{
|
|
353
|
+
id: string;
|
|
354
|
+
tenantId: string;
|
|
355
|
+
title: string;
|
|
356
|
+
code: string | null;
|
|
357
|
+
type: string;
|
|
358
|
+
method: string;
|
|
359
|
+
value: number;
|
|
360
|
+
usageLimit: number | null;
|
|
361
|
+
oncePerCustomer: boolean;
|
|
362
|
+
startsAt: string;
|
|
363
|
+
endsAt: string | null;
|
|
364
|
+
status: string;
|
|
365
|
+
timesUsed: number;
|
|
366
|
+
createdAt: string;
|
|
367
|
+
updatedAt: string;
|
|
368
|
+
}[]>;
|
|
369
|
+
getDiscount(id: string): Promise<{
|
|
370
|
+
id: string;
|
|
371
|
+
tenantId: string;
|
|
372
|
+
title: string;
|
|
373
|
+
code: string | null;
|
|
374
|
+
type: string;
|
|
375
|
+
method: string;
|
|
376
|
+
value: number;
|
|
377
|
+
usageLimit: number | null;
|
|
378
|
+
oncePerCustomer: boolean;
|
|
379
|
+
startsAt: string;
|
|
380
|
+
endsAt: string | null;
|
|
381
|
+
status: string;
|
|
382
|
+
timesUsed: number;
|
|
383
|
+
createdAt: string;
|
|
384
|
+
updatedAt: string;
|
|
385
|
+
} | null>;
|
|
386
|
+
createDiscount(): Promise<never>;
|
|
387
|
+
updateDiscount(): Promise<never>;
|
|
388
|
+
deleteDiscount(): Promise<never>;
|
|
389
|
+
};
|
|
390
|
+
export {};
|
|
391
|
+
//# sourceMappingURL=shop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shop.d.ts","sourceRoot":"","sources":["../src/shop.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,CAAC,EAAE,8BAA8B,EAAE,CAAA;IAClD,OAAO,CAAC,EAAE,OAAO,KAAK,CAAA;CACvB;AAED,MAAM,WAAW,8BAA8B;IAC7C,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAA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,EAAE,MAAM,CAAC;YAAC,GAAG,CAAC,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KACzH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBA0CqB,MAAM,SAAS,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAQ/C,4BAA4B;;;;;;;;;;;;;oBASpC,MAAM;;;;;;;;;;;;;0BAIA;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;;;uBAe3F,MAAM,SAAS;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE;;;;;;;;;;;;;uBAe7H,MAAM;4BAGD,4BAA4B;;;;;;;;;;;;;;;;;oBAWpC,MAAM;;;;;;;;;;;;;;;;;;;;EAc/B"}
|
package/dist/shop.js
ADDED
package/dist/shop.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"shop.js"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fayz-ai/sdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Fayz SDK —
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "Fayz SDK — API client, app params, runtime broker helpers, and shared types for generated Fayz projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -25,6 +25,19 @@
|
|
|
25
25
|
"import": "./dist/client.js",
|
|
26
26
|
"require": "./dist/client.cjs"
|
|
27
27
|
},
|
|
28
|
+
"./shop": {
|
|
29
|
+
"source": "./src/shop.ts",
|
|
30
|
+
"types": "./dist/shop.d.ts",
|
|
31
|
+
"import": "./dist/shop.js",
|
|
32
|
+
"require": "./dist/shop.cjs"
|
|
33
|
+
},
|
|
34
|
+
"./release-channels": {
|
|
35
|
+
"source": "./src/release-channels.ts",
|
|
36
|
+
"types": "./dist/release-channels.d.ts",
|
|
37
|
+
"import": "./dist/release-channels.js",
|
|
38
|
+
"require": "./dist/release-channels.cjs"
|
|
39
|
+
},
|
|
40
|
+
"./release-channels.json": "./src/release-channels.json",
|
|
28
41
|
"./runtime": {
|
|
29
42
|
"source": "./src/runtime.ts",
|
|
30
43
|
"types": "./dist/runtime.d.ts",
|
package/src/client.test.ts
CHANGED
|
@@ -38,4 +38,139 @@ describe('createFayzClient', () => {
|
|
|
38
38
|
|
|
39
39
|
await expect(client.auth.me()).resolves.toEqual({ id: 'user-2' })
|
|
40
40
|
})
|
|
41
|
+
|
|
42
|
+
it('lists project table rows through the Fayz data API', async () => {
|
|
43
|
+
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(jsonResponse({
|
|
44
|
+
rows: [{ id: 'booking-1' }],
|
|
45
|
+
total: 12,
|
|
46
|
+
}))
|
|
47
|
+
const client = createFayzClient({
|
|
48
|
+
baseUrl: 'https://api.fayz.ai',
|
|
49
|
+
appId: 'app-1',
|
|
50
|
+
token: async () => 'runtime-token',
|
|
51
|
+
fetcher,
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const result = await client.data.listRows<{ id: string }>({
|
|
55
|
+
projectId: 'project 1',
|
|
56
|
+
table: 'v_bookings',
|
|
57
|
+
filters: [
|
|
58
|
+
{ column: 'starts_at', operator: 'gte', value: '2026-06-14T00:00:00.000Z' },
|
|
59
|
+
{ column: 'status', operator: 'neq', value: 'cancelled' },
|
|
60
|
+
],
|
|
61
|
+
sortColumn: 'starts_at',
|
|
62
|
+
sortDirection: 'asc',
|
|
63
|
+
limit: 20,
|
|
64
|
+
runtime: true,
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
expect(result.rows[0]?.id).toBe('booking-1')
|
|
68
|
+
expect(result.total).toBe(12)
|
|
69
|
+
|
|
70
|
+
const [url, init] = fetcher.mock.calls[0] ?? []
|
|
71
|
+
expect(url).toContain('https://api.fayz.ai/api/v1/runtime/projects/project%201/database/tables/v_bookings/rows?')
|
|
72
|
+
expect(url).toContain('filters=')
|
|
73
|
+
expect(url).toContain('sortColumn=starts_at')
|
|
74
|
+
expect(url).toContain('sortDirection=asc')
|
|
75
|
+
expect(url).toContain('limit=20')
|
|
76
|
+
expect(init).toEqual(expect.objectContaining({
|
|
77
|
+
headers: expect.objectContaining({
|
|
78
|
+
'X-App-Id': 'app-1',
|
|
79
|
+
Authorization: 'Bearer runtime-token',
|
|
80
|
+
}),
|
|
81
|
+
}))
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('counts table rows using the Fayz data API total', async () => {
|
|
85
|
+
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(jsonResponse({
|
|
86
|
+
rows: [],
|
|
87
|
+
total: 7,
|
|
88
|
+
}))
|
|
89
|
+
const client = createFayzClient({ baseUrl: 'https://api.fayz.ai', fetcher })
|
|
90
|
+
|
|
91
|
+
await expect(client.data.countRows({
|
|
92
|
+
projectId: 'project-1',
|
|
93
|
+
table: 'clients',
|
|
94
|
+
filters: [{ column: 'active', operator: 'eq', value: true }],
|
|
95
|
+
})).resolves.toBe(7)
|
|
96
|
+
|
|
97
|
+
const [url] = fetcher.mock.calls[0] ?? []
|
|
98
|
+
expect(url).toContain('/api/projects/project-1/database/tables/clients/rows?')
|
|
99
|
+
expect(url).toContain('page=1')
|
|
100
|
+
expect(url).toContain('limit=1')
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('creates table rows through the Fayz data API', async () => {
|
|
104
|
+
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(jsonResponse({ id: 'menu-1', name: 'Burger' }, 201))
|
|
105
|
+
const client = createFayzClient({
|
|
106
|
+
baseUrl: 'https://api.fayz.ai',
|
|
107
|
+
appId: 'app-1',
|
|
108
|
+
token: 'runtime-token',
|
|
109
|
+
fetcher,
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
const row = await client.data.createRow<{ id: string; name: string }>({
|
|
113
|
+
projectId: 'project-1',
|
|
114
|
+
table: 'menu_items',
|
|
115
|
+
schema: 'public',
|
|
116
|
+
runtime: true,
|
|
117
|
+
row: { name: 'Burger' },
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
expect(row).toEqual({ id: 'menu-1', name: 'Burger' })
|
|
121
|
+
|
|
122
|
+
const [url, init] = fetcher.mock.calls[0] ?? []
|
|
123
|
+
expect(url).toBe('https://api.fayz.ai/api/v1/runtime/projects/project-1/database/tables/menu_items/rows?schema=public')
|
|
124
|
+
expect(init).toEqual(expect.objectContaining({
|
|
125
|
+
method: 'POST',
|
|
126
|
+
body: JSON.stringify({ name: 'Burger' }),
|
|
127
|
+
headers: expect.objectContaining({
|
|
128
|
+
'Content-Type': 'application/json',
|
|
129
|
+
'X-App-Id': 'app-1',
|
|
130
|
+
Authorization: 'Bearer runtime-token',
|
|
131
|
+
}),
|
|
132
|
+
}))
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
it('updates table rows by primary key through the Fayz data API', async () => {
|
|
136
|
+
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(jsonResponse({ id: 'table-1', status: 'occupied' }))
|
|
137
|
+
const client = createFayzClient({ baseUrl: 'https://api.fayz.ai', fetcher })
|
|
138
|
+
|
|
139
|
+
const row = await client.data.updateRow<{ id: string; status: string }>({
|
|
140
|
+
projectId: 'project-1',
|
|
141
|
+
table: 'restaurant_tables',
|
|
142
|
+
primaryKeys: { id: 'table-1' },
|
|
143
|
+
row: { status: 'occupied' },
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
expect(row.status).toBe('occupied')
|
|
147
|
+
|
|
148
|
+
const [url, init] = fetcher.mock.calls[0] ?? []
|
|
149
|
+
expect(url).toBe('https://api.fayz.ai/api/projects/project-1/database/tables/restaurant_tables/rows')
|
|
150
|
+
expect(init).toEqual(expect.objectContaining({
|
|
151
|
+
method: 'PATCH',
|
|
152
|
+
body: JSON.stringify({
|
|
153
|
+
primaryKeys: { id: 'table-1' },
|
|
154
|
+
data: { status: 'occupied' },
|
|
155
|
+
}),
|
|
156
|
+
}))
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
it('deletes table rows through the Fayz data API', async () => {
|
|
160
|
+
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(jsonResponse({ deletedCount: 1 }))
|
|
161
|
+
const client = createFayzClient({ baseUrl: 'https://api.fayz.ai', fetcher })
|
|
162
|
+
|
|
163
|
+
await expect(client.data.deleteRows({
|
|
164
|
+
projectId: 'project-1',
|
|
165
|
+
table: 'restaurant_tables',
|
|
166
|
+
rows: [{ id: 'table-1' }],
|
|
167
|
+
})).resolves.toEqual({ deletedCount: 1 })
|
|
168
|
+
|
|
169
|
+
const [url, init] = fetcher.mock.calls[0] ?? []
|
|
170
|
+
expect(url).toBe('https://api.fayz.ai/api/projects/project-1/database/tables/restaurant_tables/rows')
|
|
171
|
+
expect(init).toEqual(expect.objectContaining({
|
|
172
|
+
method: 'DELETE',
|
|
173
|
+
body: JSON.stringify({ rows: [{ id: 'table-1' }] }),
|
|
174
|
+
}))
|
|
175
|
+
})
|
|
41
176
|
})
|