@kizlo/woocommerce 1.0.0-alpha.1 → 1.0.0-alpha.3

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.
@@ -0,0 +1,662 @@
1
+ import { createRemoteFetchClient, createSafeClient, ensureProcedureResult, type } from "kizlo";
2
+ import { createClientExtension, createServerExtension, openApiProcedure, procedure, procedureErrors, remoteProcedure } from "kizlo/extensions";
3
+
4
+ //#region src/client.extension.ts
5
+ const woocommerceProcedure = procedure.use(procedure.middleware(({ context, next }) => {
6
+ return next({ context: { woocommerce: new KizloWoocommerce(context.kizlo) } });
7
+ }));
8
+ function woocommerce$1() {
9
+ return createClientExtension({
10
+ type: "router",
11
+ name: "woocommerce",
12
+ init() {
13
+ return woocommerceRouter;
14
+ }
15
+ });
16
+ }
17
+
18
+ //#endregion
19
+ //#region src/cart/client.ts
20
+ var KizloCartItem = class {
21
+ constructor(kizlo) {
22
+ this.kizlo = kizlo;
23
+ }
24
+ async add(input) {
25
+ const response = await this.kizlo._.http.post("/cart/items", {
26
+ auth: true,
27
+ body: input
28
+ });
29
+ if (response.error) return this.kizlo._.http.error(response.error);
30
+ return this.kizlo._.http.success(response.data);
31
+ }
32
+ async update(input) {
33
+ const response = await this.kizlo._.http.put(`/cart/items/${input.key}`, {
34
+ body: input,
35
+ auth: true
36
+ });
37
+ if (response.error) return this.kizlo._.http.error(response.error);
38
+ return this.kizlo._.http.success(response.data);
39
+ }
40
+ async remove(input) {
41
+ const response = await this.kizlo._.http.delete(`/cart/items/${input.key}`, { auth: true });
42
+ if (response.error) return this.kizlo._.http.error(response.error);
43
+ return this.kizlo._.http.success(response.data);
44
+ }
45
+ };
46
+ var KizloCoupon = class {
47
+ constructor(kizlo) {
48
+ this.kizlo = kizlo;
49
+ }
50
+ async apply(input) {
51
+ const response = await this.kizlo._.http.post(`/cart/coupons/${input.code}`, { auth: true });
52
+ if (response.error) return this.kizlo._.http.error(response.error);
53
+ return this.kizlo._.http.success(response.data);
54
+ }
55
+ async remove(input) {
56
+ const response = await this.kizlo._.http.delete(`/cart/coupons/${input.code}`, { auth: true });
57
+ if (response.error) return this.kizlo._.http.error(response.error);
58
+ return this.kizlo._.http.success(response.data);
59
+ }
60
+ };
61
+ var KizloCart = class {
62
+ items;
63
+ coupons;
64
+ constructor(kizlo) {
65
+ this.kizlo = kizlo;
66
+ this.items = new KizloCartItem(this.kizlo);
67
+ this.coupons = new KizloCoupon(this.kizlo);
68
+ }
69
+ async retrieve() {
70
+ const response = await this.kizlo._.http.get("/cart", { auth: true });
71
+ if (response.error) return this.kizlo._.http.error(response.error);
72
+ return this.kizlo._.http.success(response.data);
73
+ }
74
+ async update(input) {
75
+ const response = await this.kizlo._.http.put("/cart", {
76
+ auth: true,
77
+ body: input
78
+ });
79
+ if (response.error) return this.kizlo._.http.error(response.error);
80
+ return this.kizlo._.http.success(response.data);
81
+ }
82
+ };
83
+ const cart = {
84
+ retrieve: woocommerceProcedure.output(type()).errors(procedureErrors()).handler(async ({ context }) => {
85
+ return ensureProcedureResult(await context.woocommerce.cart.retrieve());
86
+ }),
87
+ update: woocommerceProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
88
+ return ensureProcedureResult(await context.woocommerce.cart.update(input));
89
+ }),
90
+ items: {
91
+ add: woocommerceProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
92
+ return ensureProcedureResult(await context.woocommerce.cart.items.add(input));
93
+ }),
94
+ update: woocommerceProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
95
+ return ensureProcedureResult(await context.woocommerce.cart.items.update(input));
96
+ }),
97
+ remove: woocommerceProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
98
+ return ensureProcedureResult(await context.woocommerce.cart.items.remove(input));
99
+ })
100
+ },
101
+ coupons: {
102
+ apply: woocommerceProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
103
+ return ensureProcedureResult(await context.woocommerce.cart.coupons.apply(input));
104
+ }),
105
+ remove: woocommerceProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
106
+ return ensureProcedureResult(await context.woocommerce.cart.coupons.remove(input));
107
+ })
108
+ }
109
+ };
110
+
111
+ //#endregion
112
+ //#region src/customer/client.ts
113
+ var KizloCustomer = class {
114
+ address;
115
+ constructor(kizlo) {
116
+ this.kizlo = kizlo;
117
+ this.address = new KizloAddress(this.kizlo);
118
+ }
119
+ async retrieve() {
120
+ const response = await this.kizlo._.http.get("/customers", { auth: true });
121
+ if (response.error) return this.kizlo._.http.error(response.error);
122
+ return this.kizlo._.http.success(response.data);
123
+ }
124
+ };
125
+ var KizloAddress = class {
126
+ constructor(kizlo) {
127
+ this.kizlo = kizlo;
128
+ }
129
+ async create(input) {
130
+ const response = await this.kizlo._.http.post("/customers/addresses", {
131
+ auth: true,
132
+ body: input
133
+ });
134
+ if (response.error) return this.kizlo._.http.error(response.error);
135
+ return this.kizlo._.http.success(response.data);
136
+ }
137
+ async update(input) {
138
+ const response = await this.kizlo._.http.put(`/customers/addresses/${input.id}`, {
139
+ body: input,
140
+ auth: true
141
+ });
142
+ if (response.error) return this.kizlo._.http.error(response.error);
143
+ return this.kizlo._.http.success(response.data);
144
+ }
145
+ async delete(input) {
146
+ const response = await this.kizlo._.http.delete(`/customers/addresses/${input.id}`, { auth: true });
147
+ if (response.error) return this.kizlo._.http.error(response.error);
148
+ return this.kizlo._.http.success(response.data);
149
+ }
150
+ };
151
+ const customer = {
152
+ retrieve: woocommerceProcedure.output(type()).errors(procedureErrors()).handler(async ({ context }) => {
153
+ return ensureProcedureResult(await context.woocommerce.customer.retrieve());
154
+ }),
155
+ address: {
156
+ create: woocommerceProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
157
+ return ensureProcedureResult(await context.woocommerce.customer.address.create(input));
158
+ }),
159
+ update: woocommerceProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
160
+ return ensureProcedureResult(await context.woocommerce.customer.address.update(input));
161
+ }),
162
+ delete: woocommerceProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
163
+ return ensureProcedureResult(await context.woocommerce.customer.address.delete(input));
164
+ })
165
+ }
166
+ };
167
+
168
+ //#endregion
169
+ //#region src/order/client.ts
170
+ var KizloOrder = class {
171
+ constructor(kizlo) {
172
+ this.kizlo = kizlo;
173
+ }
174
+ async retrieve(input) {
175
+ const response = await this.kizlo._.http.get(`/orders/${input.id}`, { auth: true });
176
+ if (response.error) return this.kizlo._.http.error(response.error);
177
+ return this.kizlo._.http.success(response.data);
178
+ }
179
+ async list(input) {
180
+ const response = await this.kizlo._.http.get("/orders", {
181
+ auth: true,
182
+ query: input
183
+ });
184
+ if (response.error) return this.kizlo._.http.error(response.error);
185
+ return this.kizlo._.http.success(response.data);
186
+ }
187
+ };
188
+ const orders = {
189
+ retrieve: woocommerceProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
190
+ return ensureProcedureResult(await context.woocommerce.orders.retrieve(input));
191
+ }),
192
+ list: woocommerceProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
193
+ return ensureProcedureResult(await context.woocommerce.orders.list(input));
194
+ })
195
+ };
196
+
197
+ //#endregion
198
+ //#region src/generated/contract.server.json
199
+ var contract_server_default = {
200
+ cart: {
201
+ "retrieve": { "~orpc": {
202
+ "errorMap": {},
203
+ "meta": {},
204
+ "route": {}
205
+ } },
206
+ "update": { "~orpc": {
207
+ "errorMap": {},
208
+ "meta": {},
209
+ "route": {}
210
+ } },
211
+ "items": {
212
+ "add": { "~orpc": {
213
+ "errorMap": {},
214
+ "meta": {},
215
+ "route": {}
216
+ } },
217
+ "update": { "~orpc": {
218
+ "errorMap": {},
219
+ "meta": {},
220
+ "route": {}
221
+ } },
222
+ "remove": { "~orpc": {
223
+ "errorMap": {},
224
+ "meta": {},
225
+ "route": {}
226
+ } }
227
+ },
228
+ "coupons": {
229
+ "apply": { "~orpc": {
230
+ "errorMap": {},
231
+ "meta": {},
232
+ "route": {}
233
+ } },
234
+ "remove": { "~orpc": {
235
+ "errorMap": {},
236
+ "meta": {},
237
+ "route": {}
238
+ } }
239
+ }
240
+ },
241
+ orders: {
242
+ "retrieve": { "~orpc": {
243
+ "errorMap": {},
244
+ "meta": {},
245
+ "route": {}
246
+ } },
247
+ "list": { "~orpc": {
248
+ "errorMap": {},
249
+ "meta": {},
250
+ "route": {}
251
+ } }
252
+ },
253
+ customer: {
254
+ "retrieve": { "~orpc": {
255
+ "errorMap": {},
256
+ "meta": {},
257
+ "route": {}
258
+ } },
259
+ "address": {
260
+ "create": { "~orpc": {
261
+ "errorMap": {},
262
+ "meta": {},
263
+ "route": {}
264
+ } },
265
+ "update": { "~orpc": {
266
+ "errorMap": {},
267
+ "meta": {},
268
+ "route": {}
269
+ } },
270
+ "delete": { "~orpc": {
271
+ "errorMap": {},
272
+ "meta": {},
273
+ "route": {}
274
+ } }
275
+ }
276
+ },
277
+ products: {
278
+ "retrieve": { "~orpc": {
279
+ "errorMap": {},
280
+ "meta": {},
281
+ "route": {}
282
+ } },
283
+ "list": { "~orpc": {
284
+ "errorMap": {},
285
+ "meta": {},
286
+ "route": {}
287
+ } },
288
+ "filters": { "~orpc": {
289
+ "errorMap": {},
290
+ "meta": {},
291
+ "route": {}
292
+ } },
293
+ "categories": { "list": { "~orpc": {
294
+ "errorMap": {},
295
+ "meta": {},
296
+ "route": {}
297
+ } } },
298
+ "reviews": {
299
+ "retrieve": { "~orpc": {
300
+ "errorMap": {},
301
+ "meta": {},
302
+ "route": {}
303
+ } },
304
+ "list": { "~orpc": {
305
+ "errorMap": {},
306
+ "meta": {},
307
+ "route": {}
308
+ } },
309
+ "create": { "~orpc": {
310
+ "errorMap": {},
311
+ "meta": {},
312
+ "route": {}
313
+ } }
314
+ }
315
+ },
316
+ payment: {
317
+ "confirm": { "~orpc": {
318
+ "errorMap": {},
319
+ "meta": {},
320
+ "route": {}
321
+ } },
322
+ "update": { "~orpc": {
323
+ "errorMap": {},
324
+ "meta": {},
325
+ "route": {}
326
+ } },
327
+ "methods": { "~orpc": {
328
+ "errorMap": {},
329
+ "meta": {},
330
+ "route": { "method": "GET" }
331
+ } },
332
+ "pay": { "~orpc": {
333
+ "errorMap": {},
334
+ "meta": {},
335
+ "route": {}
336
+ } },
337
+ "webhooks": { "~orpc": {
338
+ "errorMap": {},
339
+ "meta": {},
340
+ "route": {
341
+ "method": "POST",
342
+ "path": "/payment/webhooks/{id}",
343
+ "inputStructure": "detailed"
344
+ }
345
+ } }
346
+ }
347
+ };
348
+
349
+ //#endregion
350
+ //#region src/server.client.ts
351
+ function createWoocommerceServerRouter(options) {
352
+ return {
353
+ ...woocommerceRouter,
354
+ payment: createPaymentServerRouter(options)
355
+ };
356
+ }
357
+
358
+ //#endregion
359
+ //#region src/server.extension.ts
360
+ const woocommerceRemoteProcedure = remoteProcedure.use(remoteProcedure.middleware(({ context, next }) => {
361
+ return next({ context: { woocommerce: new KizloWoocommerce(context.kizlo) } });
362
+ }));
363
+ const woocommerceOpenApiProcedure = openApiProcedure.use(openApiProcedure.middleware(({ context, next }) => {
364
+ return next({ context: { woocommerce: new KizloWoocommerce(context.kizlo) } });
365
+ }));
366
+ function woocommerce(options) {
367
+ return createServerExtension({
368
+ name: "woocommerce",
369
+ init() {
370
+ return createWoocommerceServerRouter(options);
371
+ }
372
+ });
373
+ }
374
+
375
+ //#endregion
376
+ //#region src/payment/client.ts
377
+ var KizloPayment = class {
378
+ admin;
379
+ rpc;
380
+ constructor(kizlo) {
381
+ this.kizlo = kizlo;
382
+ this.admin = new KizloPaymentAdmin(this.kizlo);
383
+ this.rpc = createSafeClient(createRemoteFetchClient(contract_server_default, `${this.kizlo._.serverBaseUrl}/woocommerce`));
384
+ }
385
+ async methods() {
386
+ const { error, data, isDefined } = await this.rpc.payment.methods();
387
+ if (error) {
388
+ if (isDefined) return this.kizlo._.http.error({
389
+ code: error.code,
390
+ message: error.message,
391
+ status: error.status
392
+ });
393
+ throw error;
394
+ }
395
+ return this.kizlo._.http.success(data);
396
+ }
397
+ async pay(input) {
398
+ const { error, data, isDefined } = await this.rpc.payment.pay(input);
399
+ if (error) {
400
+ if (isDefined) return this.kizlo._.http.error({
401
+ code: error.code,
402
+ message: error.message,
403
+ status: error.status
404
+ });
405
+ throw error;
406
+ }
407
+ return this.kizlo._.http.success(data);
408
+ }
409
+ };
410
+ var KizloPaymentAdmin = class {
411
+ constructor(kizlo) {
412
+ this.kizlo = kizlo;
413
+ }
414
+ async confirm(input) {
415
+ const response = await this.kizlo._.http.post("/payment", { body: input });
416
+ if (response.error) return this.kizlo._.http.error(response.error);
417
+ return this.kizlo._.http.success(response.data);
418
+ }
419
+ async update(input) {
420
+ const response = await this.kizlo._.http.put(`/payment/${input.order_id}`, { body: input });
421
+ if (response.error) return this.kizlo._.http.error(response.error);
422
+ return this.kizlo._.http.success(response.data);
423
+ }
424
+ async methods(input) {
425
+ const groups = /* @__PURE__ */ new Map();
426
+ for (const adapter of input.adapters) {
427
+ const config = adapter;
428
+ if (!groups.has(config.type)) groups.set(config.type, []);
429
+ groups.get(config.type)?.push(config);
430
+ }
431
+ const getPrioritizedAdapter = (group) => {
432
+ let best = null;
433
+ for (const adapter of group) if (!best || adapter.priority > best.priority) best = adapter;
434
+ return best;
435
+ };
436
+ const methods = [];
437
+ for (const [, group] of groups) {
438
+ const selectedAdapters = [];
439
+ const combinableAdapters = group.filter((adapter) => adapter.isCombinable);
440
+ if (combinableAdapters.length > 1) for (const adapter of combinableAdapters) selectedAdapters.push(adapter);
441
+ else {
442
+ const bestAdapter = getPrioritizedAdapter(group);
443
+ if (bestAdapter) selectedAdapters.push(bestAdapter);
444
+ }
445
+ for (const adapter of selectedAdapters) {
446
+ const eligibility = await adapter.eligibility?.(input.context);
447
+ if (eligibility?.is_hidden) continue;
448
+ methods.push({
449
+ id: adapter.id,
450
+ type: adapter.type,
451
+ name: eligibility?.name ?? adapter.name,
452
+ is_disabled: eligibility?.is_disabled ?? false,
453
+ description: eligibility?.description ?? adapter.description
454
+ });
455
+ }
456
+ }
457
+ if (new Set(methods.map((method) => method.id)).size !== methods.length) return this.kizlo._.http.error("PAYMENT_DUPLICATE_ADAPTERS");
458
+ return this.kizlo._.http.success(methods);
459
+ }
460
+ async pay(input) {
461
+ const adapter = input.adapters.find((adp) => adp.id === input.payment_method_id);
462
+ if (!adapter) return this.kizlo._.http.error("PAYMENT_ADAPTER_NOT_FOUND");
463
+ const confirmResult = await this.confirm({
464
+ user_id: {},
465
+ payment_method_id: adapter.id,
466
+ payment_method_name: adapter.name,
467
+ payment_method_type: adapter.type
468
+ });
469
+ if (confirmResult.isError) return this.kizlo._.http.error(confirmResult.error);
470
+ if (adapter.type === "online") {
471
+ const intent = await adapter.create({ order: confirmResult.data }, input.context);
472
+ if (!intent || !intent.url) return this.kizlo._.http.error("PAYMENT_ADAPTER_NOT_FOUND");
473
+ const updateResult = await this.update({
474
+ order_id: confirmResult.data.id,
475
+ payment_status: intent.status,
476
+ payment_session_id: intent.id,
477
+ transaction_id: intent.transaction_id,
478
+ payment_url: intent.url
479
+ });
480
+ if (updateResult.isError) return this.kizlo._.http.error(updateResult.error);
481
+ return this.kizlo._.http.success({ redirect_url: intent.url });
482
+ }
483
+ return this.kizlo._.http.success({ redirect_url: "" });
484
+ }
485
+ async handleWebhook(input) {
486
+ const adapter = input.adapters.find((a) => a.id === input.payment_method_id);
487
+ if (!adapter || adapter.type !== "online") return this.kizlo._.http.error("PAYMENT_ADAPTER_NOT_FOUND");
488
+ const data = await adapter.verify(input.context);
489
+ if (!data) return this.kizlo._.http.error("UNAUTHORIZED");
490
+ const updateResult = await this.update({
491
+ order_id: data.order_id,
492
+ payment_status: data.status,
493
+ transaction_id: data.transaction_id
494
+ });
495
+ if (updateResult.error) return this.kizlo._.http.error(updateResult.error);
496
+ return this.kizlo._.http.success({ success: true });
497
+ }
498
+ };
499
+ const paymentRouter = {
500
+ methods: woocommerceProcedure.output(type()).errors(procedureErrors()).handler(async ({ context }) => {
501
+ return ensureProcedureResult(await context.woocommerce.payment.methods());
502
+ }),
503
+ pay: woocommerceProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
504
+ return ensureProcedureResult(await context.woocommerce.payment.pay(input));
505
+ })
506
+ };
507
+ function createPaymentServerRouter(options) {
508
+ return {
509
+ confirm: woocommerceProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
510
+ return ensureProcedureResult(await context.woocommerce.payment.admin.confirm(input));
511
+ }),
512
+ update: woocommerceProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
513
+ return ensureProcedureResult(await context.woocommerce.payment.admin.update(input));
514
+ }),
515
+ methods: woocommerceRemoteProcedure.route({ method: "GET" }).output(type()).errors(procedureErrors()).handler(async ({ context }) => {
516
+ return ensureProcedureResult(await context.woocommerce.payment.admin.methods({
517
+ context,
518
+ adapters: options?.paymentAdapters ?? []
519
+ }));
520
+ }),
521
+ pay: woocommerceRemoteProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
522
+ return ensureProcedureResult(await context.woocommerce.payment.admin.pay({
523
+ context,
524
+ adapters: options?.paymentAdapters ?? [],
525
+ payment_method_id: input.payment_method_id
526
+ }));
527
+ }),
528
+ webhooks: woocommerceOpenApiProcedure.route({
529
+ method: "POST",
530
+ path: "/payment/webhooks/{id}",
531
+ inputStructure: "detailed"
532
+ }).input(type()).handler(async ({ input, context }) => {
533
+ return ensureProcedureResult(context.woocommerce.payment.admin.handleWebhook({
534
+ context,
535
+ payment_method_id: input.params.id,
536
+ adapters: options?.paymentAdapters ?? []
537
+ }));
538
+ })
539
+ };
540
+ }
541
+
542
+ //#endregion
543
+ //#region src/product/category.ts
544
+ var KizloProductCategory = class {
545
+ constructor(kizlo) {
546
+ this.kizlo = kizlo;
547
+ }
548
+ async list(input) {
549
+ const response = await this.kizlo._.http.get("/products/categories", { query: input });
550
+ if (response.error) return this.kizlo._.http.error(response.error);
551
+ return this.kizlo._.http.success(response.data);
552
+ }
553
+ };
554
+ const categories = { list: woocommerceProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
555
+ return ensureProcedureResult(await context.woocommerce.products.categories.list(input));
556
+ }) };
557
+
558
+ //#endregion
559
+ //#region src/product/review.ts
560
+ var KizloProductReview = class {
561
+ constructor(kizlo) {
562
+ this.kizlo = kizlo;
563
+ }
564
+ async retrieve(input) {
565
+ const response = await this.kizlo._.http.get(`/products/reviews/${input.id}`, { query: input });
566
+ if (response.error) return this.kizlo._.http.error(response.error);
567
+ return this.kizlo._.http.success(response.data);
568
+ }
569
+ async list(input) {
570
+ const response = await this.kizlo._.http.get("/products/reviews", { query: input });
571
+ if (response.error) return this.kizlo._.http.error(response.error);
572
+ return this.kizlo._.http.success(response.data);
573
+ }
574
+ async create(input) {
575
+ const response = await this.kizlo._.http.post("/products/reviews", {
576
+ auth: true,
577
+ body: input
578
+ });
579
+ if (response.error) return this.kizlo._.http.error(response.error);
580
+ return this.kizlo._.http.success(response.data);
581
+ }
582
+ };
583
+ const reviews = {
584
+ retrieve: woocommerceProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
585
+ return ensureProcedureResult(await context.woocommerce.products.reviews.retrieve(input));
586
+ }),
587
+ list: woocommerceProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
588
+ return ensureProcedureResult(await context.woocommerce.products.reviews.list(input));
589
+ }),
590
+ create: woocommerceProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
591
+ return ensureProcedureResult(await context.woocommerce.products.reviews.create(input));
592
+ })
593
+ };
594
+
595
+ //#endregion
596
+ //#region src/product/product.ts
597
+ var KizloProduct = class {
598
+ reviews;
599
+ categories;
600
+ constructor(kizlo) {
601
+ this.kizlo = kizlo;
602
+ this.reviews = new KizloProductReview(this.kizlo);
603
+ this.categories = new KizloProductCategory(this.kizlo);
604
+ }
605
+ async retrieve(input) {
606
+ const response = await this.kizlo._.http.get(`/products/${input.identifier}`, { query: { preview_token: input.preview_token } });
607
+ if (response.error) return this.kizlo._.http.error(response.error);
608
+ return this.kizlo._.http.success(response.data);
609
+ }
610
+ async list(input) {
611
+ const response = await this.kizlo._.http.get("/products", { query: input });
612
+ if (response.error) return this.kizlo._.http.error(response.error);
613
+ return this.kizlo._.http.success(response.data);
614
+ }
615
+ async filters(input) {
616
+ const response = await this.kizlo._.http.get("/products/filters", { query: input });
617
+ if (response.error) return this.kizlo._.http.error(response.error);
618
+ return this.kizlo._.http.success(response.data);
619
+ }
620
+ };
621
+ const products = {
622
+ retrieve: woocommerceProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
623
+ return ensureProcedureResult(await context.woocommerce.products.retrieve(input));
624
+ }),
625
+ list: woocommerceProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
626
+ return ensureProcedureResult(await context.woocommerce.products.list(input));
627
+ }),
628
+ filters: woocommerceProcedure.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
629
+ return ensureProcedureResult(await context.woocommerce.products.filters(input));
630
+ }),
631
+ categories,
632
+ reviews
633
+ };
634
+
635
+ //#endregion
636
+ //#region src/client.ts
637
+ var KizloWoocommerce = class {
638
+ cart;
639
+ orders;
640
+ customer;
641
+ products;
642
+ payment;
643
+ constructor(kizlo) {
644
+ this.kizlo = kizlo;
645
+ this.cart = new KizloCart(this.kizlo);
646
+ this.orders = new KizloOrder(this.kizlo);
647
+ this.customer = new KizloCustomer(this.kizlo);
648
+ this.products = new KizloProduct(this.kizlo);
649
+ this.payment = new KizloPayment(this.kizlo);
650
+ }
651
+ };
652
+ const woocommerceRouter = {
653
+ cart,
654
+ orders,
655
+ customer,
656
+ products,
657
+ payment: paymentRouter
658
+ };
659
+
660
+ //#endregion
661
+ export { KizloCartItem as C, woocommerceProcedure as D, woocommerce$1 as E, KizloCart as S, cart as T, KizloOrder as _, KizloProductReview as a, KizloCustomer as b, categories as c, createPaymentServerRouter as d, paymentRouter as f, createWoocommerceServerRouter as g, woocommerceRemoteProcedure as h, products as i, KizloPayment as l, woocommerceOpenApiProcedure as m, woocommerceRouter as n, reviews as o, woocommerce as p, KizloProduct as r, KizloProductCategory as s, KizloWoocommerce as t, KizloPaymentAdmin as u, orders as v, KizloCoupon as w, customer as x, KizloAddress as y };
662
+ //# sourceMappingURL=client-DwegaoKJ.js.map