@cabrapi/sdk 1.0.0-alpha.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,23 +1,43 @@
1
- import { AxiosInstance as AxiosInstance$1 } from 'axios';
2
-
3
1
  /**
4
- * Configurações para criação da instância Axios.
2
+ * Adapter HTTP simples usando fetch (nativo).
3
+ * Exporta `createAxios` para compatibilidade com restante do código.
5
4
  */
6
5
  type AxiosConfig = {
7
- /**
8
- * URL base da API.
9
- * @default "https://api.cabrapi.com.br"
10
- */
11
6
  baseURL?: string;
12
- /**
13
- * Chave da API (modo privado).
14
- */
15
7
  apiKey?: string;
8
+ timeout?: number;
9
+ };
10
+ type AxiosRequestConfig = {
11
+ url?: string;
12
+ params?: Record<string, unknown>;
13
+ headers?: Record<string, string>;
14
+ data?: unknown;
15
+ timeout?: number;
16
+ };
17
+ type AxiosResponse<T = unknown> = {
18
+ data: T;
19
+ status: number;
20
+ statusText: string;
21
+ headers: Record<string, string>;
22
+ config?: AxiosRequestConfig;
23
+ };
24
+ declare function createAxios(cfg?: AxiosConfig): {
25
+ interceptors: {
26
+ request: {
27
+ use(fulfilled: (c: AxiosRequestConfig) => AxiosRequestConfig | Promise<AxiosRequestConfig>, rejected?: (e: unknown) => unknown): void;
28
+ };
29
+ response: {
30
+ use(fulfilled: (r: AxiosResponse) => AxiosResponse | Promise<AxiosResponse>, rejected?: (e: unknown) => unknown): void;
31
+ };
32
+ };
33
+ get<T = unknown>(url: string, options?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
34
+ post<T = unknown>(url: string, data?: unknown, options?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
35
+ put<T = unknown>(url: string, data?: unknown, options?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
36
+ delete<T = unknown>(url: string, options?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
37
+ request<T = unknown>(options: AxiosRequestConfig & {
38
+ method: string;
39
+ }): Promise<AxiosResponse<T>>;
16
40
  };
17
- /**
18
- * Cria uma instância HTTP configurada para a caBRAPI.
19
- */
20
- declare function createAxios(config?: AxiosConfig): AxiosInstance$1;
21
41
 
22
42
  /**
23
43
  * Tipo derivado da instância do Axios
@@ -35,6 +55,7 @@ type ClientOptions = {
35
55
  type: ClientMode;
36
56
  config?: {
37
57
  key?: string;
58
+ baseURL?: string;
38
59
  };
39
60
  };
40
61
  /**
@@ -59,8 +80,181 @@ declare class CoreClient {
59
80
  assertPrivate(): void;
60
81
  }
61
82
 
83
+ type Category = {
84
+ id: string;
85
+ name: string;
86
+ description: string | null;
87
+ image: string | null;
88
+ metadata: Record<string, unknown> | null;
89
+ position: number;
90
+ storeId: string;
91
+ createdAt: string;
92
+ updatedAt: string;
93
+ };
94
+ type CategoryDetails = Category & {
95
+ products?: unknown[];
96
+ coupons?: unknown[];
97
+ };
98
+ type Pagination$4 = {
99
+ page: number;
100
+ limit: number;
101
+ total: number;
102
+ totalPages: number;
103
+ };
104
+ type GetCategoriesInput = {
105
+ page?: number;
106
+ limit?: number;
107
+ };
108
+ type CreateCategoryInput = {
109
+ name?: string;
110
+ description?: string | null;
111
+ image?: string | null;
112
+ metadata?: Record<string, unknown> | null;
113
+ };
114
+ type UpdateCategoryInput = {
115
+ name?: string;
116
+ description?: string | null;
117
+ image?: string | null;
118
+ metadata?: Record<string, unknown> | null;
119
+ position?: number;
120
+ };
121
+ type GetCategoriesResponse = {
122
+ status: boolean;
123
+ code: string;
124
+ categories: Category[];
125
+ pagination: Pagination$4;
126
+ };
127
+ type GetCategoryByIdResponse = {
128
+ status: boolean;
129
+ code: string;
130
+ category: CategoryDetails;
131
+ };
132
+ type CreateCategoryResponse = {
133
+ status: boolean;
134
+ code?: string;
135
+ category: Category;
136
+ };
137
+ type UpdateCategoryResponse = {
138
+ status: boolean;
139
+ code: string;
140
+ category: Category;
141
+ };
142
+ type DeleteCategoryResponse = {
143
+ status: boolean;
144
+ code: string;
145
+ };
146
+ type ReorderCategoriesResponse = {
147
+ status: boolean;
148
+ code: string;
149
+ };
150
+ declare class Categories {
151
+ private core;
152
+ constructor(core: CoreClient);
153
+ get(storeId: string, input?: GetCategoriesInput): Promise<GetCategoriesResponse>;
154
+ getById(storeId: string, categoryId: string): Promise<GetCategoryByIdResponse>;
155
+ post(storeId: string, input: CreateCategoryInput): Promise<CreateCategoryResponse>;
156
+ put(storeId: string, categoryId: string, input: UpdateCategoryInput): Promise<UpdateCategoryResponse>;
157
+ delete(storeId: string, categoryId: string): Promise<DeleteCategoryResponse>;
158
+ reorder(storeId: string, categoryIds: string[]): Promise<ReorderCategoriesResponse>;
159
+ }
160
+
161
+ type CouponRelationRef = {
162
+ id: string;
163
+ name: string;
164
+ };
165
+ type Coupon = {
166
+ id: string;
167
+ code: string;
168
+ position: number;
169
+ discount: number;
170
+ useLimit: number;
171
+ expiredAt: string | null;
172
+ storeId?: string;
173
+ products: CouponRelationRef[];
174
+ categories: CouponRelationRef[];
175
+ createdAt?: string;
176
+ updatedAt?: string;
177
+ };
178
+ type Pagination$3 = {
179
+ page: number;
180
+ limit: number;
181
+ total: number;
182
+ totalPages: number;
183
+ };
184
+ type GetCouponsInput = {
185
+ page?: number;
186
+ limit?: number;
187
+ };
188
+ type CreateCouponInput = {
189
+ code: string;
190
+ discount: number;
191
+ useLimit?: number | null;
192
+ expiredAt?: string | null;
193
+ productIds?: string[];
194
+ categoryIds?: string[];
195
+ };
196
+ type UpdateCouponInput = {
197
+ code?: string;
198
+ discount?: number;
199
+ position?: number;
200
+ useLimit?: number | null;
201
+ expiredAt?: string | null;
202
+ productIds?: string[];
203
+ categoryIds?: string[];
204
+ };
205
+ type GetCouponsResponse = {
206
+ status: boolean;
207
+ code: string;
208
+ coupons: Coupon[];
209
+ pagination: Pagination$3;
210
+ };
211
+ type GetCouponByCodeResponse = {
212
+ status: boolean;
213
+ code: string;
214
+ coupon: Coupon;
215
+ };
216
+ type GetCouponByIdResponse = {
217
+ status: boolean;
218
+ code: string;
219
+ coupon: Coupon;
220
+ };
221
+ type CreateCouponResponse = {
222
+ status: boolean;
223
+ code: string;
224
+ coupon: Coupon;
225
+ };
226
+ type UpdateCouponResponse = {
227
+ status: boolean;
228
+ code: string;
229
+ coupon: Coupon;
230
+ };
231
+ type DeleteCouponResponse = {
232
+ status: boolean;
233
+ code: string;
234
+ };
235
+ type ReorderCouponsResponse = {
236
+ status: boolean;
237
+ code: string;
238
+ };
239
+ declare class Coupons {
240
+ private core;
241
+ constructor(core: CoreClient);
242
+ get(storeId: string, input?: GetCouponsInput): Promise<GetCouponsResponse>;
243
+ getByCode(storeId: string, code: string): Promise<GetCouponByCodeResponse>;
244
+ getById(storeId: string, couponId: string): Promise<GetCouponByIdResponse>;
245
+ post(storeId: string, input: CreateCouponInput): Promise<CreateCouponResponse>;
246
+ put(storeId: string, couponId: string, input: UpdateCouponInput): Promise<UpdateCouponResponse>;
247
+ delete(storeId: string, couponId: string): Promise<DeleteCouponResponse>;
248
+ reorder(storeId: string, couponIds: string[]): Promise<ReorderCouponsResponse>;
249
+ }
250
+
62
251
  /**
63
- * Representa a página retornada pela API
252
+ * Modelo de página retornado pela API de páginas.
253
+ *
254
+ * Observações:
255
+ * - Campos `createdAt` e `updatedAt` são timestamps em ISO 8601.
256
+ * - `version` pode ser usada pelo servidor para controle de versão do conteúdo.
257
+ * - `store` é metadado opcional com informações da loja proprietária.
64
258
  */
65
259
  type Page = {
66
260
  html: string;
@@ -70,26 +264,543 @@ type Page = {
70
264
  updatedAt?: string;
71
265
  store?: {
72
266
  ownerId: string;
267
+ id: string;
73
268
  };
74
269
  };
75
270
 
271
+ /**
272
+ * Client de alto nível para operações relacionadas a `Page`.
273
+ *
274
+ * Instancie com um `CoreClient` já autenticado/configurado. Os métodos desta
275
+ * classe são pequenos wrappers que delegam a execução para as funções HTTP
276
+ * específicas em `./http/*`, mantendo a assinatura orientada ao domínio.
277
+ */
76
278
  declare class Pages {
77
279
  private core;
280
+ /**
281
+ * Construtor.
282
+ * @param core - Instância de `CoreClient` usada para efetuar chamadas HTTP.
283
+ */
78
284
  constructor(core: CoreClient);
79
- get(domain: string): Promise<Page>;
285
+ /**
286
+ * Recupera a página associada ao `domain` informado.
287
+ *
288
+ * @param domain - Identificador da página a recuperar (ex.: "exemplo.com").
289
+ * @returns Uma promise que resolve com o objeto `Page` caso exista.
290
+ * @throws Erros de rede/HTTP ou erro retornado pela API se a página não existir.
291
+ *
292
+ */
293
+ get(domain: string): Promise<{
294
+ status: boolean;
295
+ data: Page;
296
+ }>;
297
+ /**
298
+ * Cria ou atualiza uma página.
299
+ *
300
+ * Se a página para o `domain` já existir, o servidor realizará um update;
301
+ * caso contrário, criará uma nova entrada.
302
+ *
303
+ * @param input - Objeto com os dados da página:
304
+ * - `domain`: chave única da página.
305
+ * - `html`: conteúdo HTML completo.
306
+ * - `template` (opcional): nome do template a aplicar.
307
+ * @returns Uma promise que resolve com o `Page` criado/atualizado ou com metadados retornados pela API.
308
+ * @throws Erros de validação, rede ou HTTP conforme a resposta da API.
309
+ *
310
+ */
80
311
  upsert(input: {
81
312
  domain: string;
82
313
  html: string;
83
314
  template?: string;
84
- }): Promise<boolean>;
85
- delete(domain: string): Promise<boolean>;
315
+ }): Promise<{
316
+ status: boolean;
317
+ code: string;
318
+ }>;
319
+ /**
320
+ * Remove a página associada ao `domain`.
321
+ *
322
+ * @param domain - Identificador da página a remover.
323
+ * @returns Uma promise que resolve quando a exclusão for confirmada pelo servidor.
324
+ * @throws Erro se a operação falhar (por exemplo, página não encontrada ou erro de permissão).
325
+ *
326
+ */
327
+ delete(domain: string): Promise<{
328
+ status: boolean;
329
+ code: string;
330
+ }>;
331
+ }
332
+
333
+ type PaymentStatus = "PENDING" | "APPROVED" | "REJECTED" | "CANCELLED" | "REFUNDED" | "CHARGED_BACK" | "EXPIRED";
334
+ type PaymentGateway = "MERCADOPAGO" | "EFI_BANK";
335
+ type PaymentCreateGateway = "MERCADOPAGO_SERVICE_PIX" | "MERCADOPAGO_SERVICE_CARD";
336
+ type PaymentShipmentStatus = "PENDING" | "PREPARING" | "SHIPPED" | "DELIVERED" | "RETURNED" | "CANCELLED";
337
+ type PaymentSortBy = "createdAt" | "updatedAt" | "price" | "name" | "email";
338
+ type PaymentSortOrder = "asc" | "desc";
339
+ type Payment = {
340
+ id: string;
341
+ uuid: string;
342
+ status: PaymentStatus;
343
+ name?: string;
344
+ email?: string;
345
+ cpf?: string | null;
346
+ price?: number;
347
+ gateway?: PaymentGateway;
348
+ shipment?: PaymentShipmentStatus;
349
+ storeId: string;
350
+ metadata?: Record<string, unknown> | null;
351
+ };
352
+ type Pagination$2 = {
353
+ page: number;
354
+ limit: number;
355
+ total: number;
356
+ totalPages: number;
357
+ };
358
+ type FilterPaymentsInput = {
359
+ id?: string;
360
+ uuid?: string;
361
+ status?: PaymentStatus;
362
+ name?: string;
363
+ email?: string;
364
+ cpf?: string;
365
+ price?: number;
366
+ minPrice?: number;
367
+ maxPrice?: number;
368
+ coupon?: boolean;
369
+ gateway?: PaymentGateway;
370
+ shipment?: PaymentShipmentStatus;
371
+ createdAtFrom?: string;
372
+ createdAtTo?: string;
373
+ updatedAtFrom?: string;
374
+ updatedAtTo?: string;
375
+ productId?: string;
376
+ metadataKey?: string;
377
+ metadataValue?: string;
378
+ sortBy?: PaymentSortBy;
379
+ sortOrder?: PaymentSortOrder;
380
+ page?: number;
381
+ limit?: number;
382
+ };
383
+ type FilterPaymentsResponse = {
384
+ status: boolean;
385
+ code: string;
386
+ payments: Payment[];
387
+ pagination: Pagination$2;
388
+ };
389
+ type GetPaymentsInput = {
390
+ page?: number;
391
+ limit?: number;
392
+ };
393
+ type GetPaymentsResponse = {
394
+ status: boolean;
395
+ code: string;
396
+ payments: Payment[];
397
+ pagination: Pagination$2;
398
+ };
399
+ type CreatePaymentItemInput = {
400
+ productId: string;
401
+ quantity: number;
402
+ };
403
+ type CreatePaymentInput = {
404
+ name: string;
405
+ email: string;
406
+ cpf?: string;
407
+ gateway: PaymentCreateGateway;
408
+ coupon?: string | null;
409
+ metadata?: Record<string, unknown>;
410
+ items: CreatePaymentItemInput[];
411
+ };
412
+ type CreatePaymentResponse = {
413
+ status: boolean;
414
+ data: {
415
+ service: {
416
+ type: string;
417
+ method: string;
418
+ payment: string;
419
+ };
420
+ payment: {
421
+ uuid: string;
422
+ url?: string;
423
+ qr_code?: {
424
+ image: string;
425
+ base_64: string;
426
+ };
427
+ };
428
+ };
429
+ };
430
+ type UpdatePaymentInput = {
431
+ shipment?: PaymentShipmentStatus;
432
+ metadata?: Record<string, unknown>;
433
+ };
434
+ type UpdatePaymentResponse = {
435
+ status: boolean;
436
+ code: string;
437
+ payment: {
438
+ id: string;
439
+ status: PaymentStatus;
440
+ shipment?: PaymentShipmentStatus;
441
+ metadata?: Record<string, unknown> | null;
442
+ };
443
+ };
444
+ type DeletePaymentResponse = {
445
+ status: boolean;
446
+ code: string;
447
+ message: string;
448
+ };
449
+ declare class Payments {
450
+ private core;
451
+ constructor(core: CoreClient);
452
+ get(storeId: string, input?: GetPaymentsInput): Promise<GetPaymentsResponse>;
453
+ filter(storeId: string, input?: FilterPaymentsInput): Promise<FilterPaymentsResponse>;
454
+ post(storeId: string, input: CreatePaymentInput): Promise<CreatePaymentResponse>;
455
+ put(storeId: string, paymentId: string, input: UpdatePaymentInput): Promise<UpdatePaymentResponse>;
456
+ delete(storeId: string, paymentId: string): Promise<DeletePaymentResponse>;
457
+ }
458
+
459
+ type ProductDelivery = "DIGITAL" | "PHYSICAL";
460
+ type ProductCategoryRef = {
461
+ id: string;
462
+ name: string;
463
+ };
464
+ type Product = {
465
+ id: string;
466
+ name: string;
467
+ disabled: boolean;
468
+ position: number;
469
+ description: string | null;
470
+ price: number;
471
+ image: string | null;
472
+ delivery: ProductDelivery;
473
+ stock: number;
474
+ sold: number;
475
+ storeId: string;
476
+ metadata: Record<string, unknown> | null;
477
+ createdAt: string;
478
+ updatedAt: string;
479
+ categories?: ProductCategoryRef[];
480
+ };
481
+ type Pagination$1 = {
482
+ page: number;
483
+ limit: number;
484
+ total: number;
485
+ totalPages: number;
486
+ };
487
+ type GetProductsInput = {
488
+ page?: number;
489
+ limit?: number;
490
+ };
491
+ type CreateProductInput = {
492
+ name: string;
493
+ image?: string | null;
494
+ description?: string | null;
495
+ categoryIds?: string[];
496
+ delivery: ProductDelivery;
497
+ price: number;
498
+ stock?: number;
499
+ disabled?: boolean;
500
+ metadata?: Record<string, unknown> | null;
501
+ };
502
+ type UpdateProductInput = {
503
+ name?: string;
504
+ image?: string | null;
505
+ description?: string | null;
506
+ categoryIds?: string[];
507
+ delivery?: ProductDelivery;
508
+ price?: number;
509
+ stock?: number;
510
+ disabled?: boolean;
511
+ position?: number;
512
+ metadata?: Record<string, unknown> | null;
513
+ };
514
+ type GetProductsResponse = {
515
+ status: boolean;
516
+ code: string;
517
+ products: Product[];
518
+ pagination: Pagination$1;
519
+ };
520
+ type GetProductByIdResponse = {
521
+ status: boolean;
522
+ code: string;
523
+ product: Product;
524
+ };
525
+ type CreateProductResponse = {
526
+ status: boolean;
527
+ code: string;
528
+ product: Product;
529
+ };
530
+ type UpdateProductResponse = {
531
+ status: boolean;
532
+ code: string;
533
+ product: Product;
534
+ };
535
+ type DeleteProductResponse = {
536
+ status: boolean;
537
+ code: string;
538
+ };
539
+ type ReorderProductsResponse = {
540
+ status: boolean;
541
+ code: string;
542
+ };
543
+ declare class Products {
544
+ private core;
545
+ constructor(core: CoreClient);
546
+ get(storeId: string, input?: GetProductsInput): Promise<GetProductsResponse>;
547
+ getByCategory(storeId: string, categoryId: string, input?: GetProductsInput): Promise<GetProductsResponse>;
548
+ getById(storeId: string, productId: string): Promise<GetProductByIdResponse>;
549
+ post(storeId: string, input: CreateProductInput): Promise<CreateProductResponse>;
550
+ put(storeId: string, productId: string, input: UpdateProductInput): Promise<UpdateProductResponse>;
551
+ delete(storeId: string, productId: string): Promise<DeleteProductResponse>;
552
+ reorder(storeId: string, productIds: string[]): Promise<ReorderProductsResponse>;
553
+ }
554
+
555
+ /**
556
+ * Templates válidos para loja.
557
+ */
558
+ type StoreTemplate = "PERSONALIZADO" | "N/A";
559
+ /**
560
+ * Tipo do domínio informado no payload da loja.
561
+ */
562
+ type StoreDomainType = "CUSTOM" | "DEFAULT";
563
+ /**
564
+ * Estrutura de domínio para criação/atualização.
565
+ */
566
+ type StoreDomainInput = {
567
+ type: StoreDomainType;
568
+ value: string;
569
+ };
570
+ /**
571
+ * Modelo base de loja retornado nos endpoints de listagem e upsert.
572
+ */
573
+ type Store = {
574
+ id: string;
575
+ name: string;
576
+ position: number;
577
+ description: string | null;
578
+ image: string | null;
579
+ domain: string;
580
+ template: StoreTemplate;
581
+ metadata: Record<string, unknown> | null;
582
+ createdAt: string;
583
+ updatedAt: string;
584
+ };
585
+ /**
586
+ * Modelo detalhado retornado por `GET /stores/:storeId`.
587
+ */
588
+ type StoreDetails = Store & {
589
+ ownerId?: string;
590
+ deletedAt?: string | null;
591
+ categories?: unknown[];
592
+ products?: unknown[];
593
+ coupons?: unknown[];
594
+ payment?: unknown[];
595
+ };
596
+ /**
597
+ * Metadados de paginação padrão da API.
598
+ */
599
+ type Pagination = {
600
+ page: number;
601
+ limit: number;
602
+ total: number;
603
+ totalPages: number;
604
+ };
605
+ /**
606
+ * Query params de listagem de lojas.
607
+ */
608
+ type GetStoresInput = {
609
+ page?: number;
610
+ limit?: number;
611
+ };
612
+ /**
613
+ * Payload para criação de loja (`POST /stores`).
614
+ */
615
+ type CreateStoreInput = {
616
+ template: StoreTemplate;
617
+ name?: string;
618
+ description?: string | null;
619
+ image?: string | null;
620
+ metadata?: Record<string, unknown> | null;
621
+ domain?: StoreDomainInput | null;
622
+ position?: number;
623
+ };
624
+ /**
625
+ * Payload para atualização de loja (`PUT /stores/:storeId`).
626
+ *
627
+ * Observação: no endpoint de update, todos os campos são opcionais,
628
+ * mas a API exige ao menos 1 campo no body.
629
+ */
630
+ type UpdateStoreInput = {
631
+ template?: StoreTemplate;
632
+ name?: string;
633
+ description?: string | null;
634
+ image?: string | null;
635
+ metadata?: Record<string, unknown> | null;
636
+ domain?: StoreDomainInput | null;
637
+ position?: number;
638
+ };
639
+ /**
640
+ * Resposta de listagem de lojas.
641
+ */
642
+ type GetStoresResponse = {
643
+ status: boolean;
644
+ code: string;
645
+ stores: Store[];
646
+ pagination: Pagination;
647
+ };
648
+ /**
649
+ * Resposta de consulta por ID.
650
+ */
651
+ type GetStoreByIdResponse = {
652
+ status: boolean;
653
+ code: string;
654
+ store: StoreDetails;
655
+ };
656
+ /**
657
+ * Resposta de criação.
658
+ */
659
+ type CreateStoreResponse = {
660
+ status: boolean;
661
+ code: string;
662
+ store: Store;
663
+ };
664
+ /**
665
+ * Resposta de atualização.
666
+ */
667
+ type UpdateStoreResponse = {
668
+ status: boolean;
669
+ code: string;
670
+ store: Store;
671
+ };
672
+ /**
673
+ * Resposta de exclusão.
674
+ */
675
+ type DeleteStoreResponse = {
676
+ status: boolean;
677
+ code: string;
678
+ };
679
+ /**
680
+ * Resposta de reordenação.
681
+ */
682
+ type ReorderStoresResponse = {
683
+ status: boolean;
684
+ code: string;
685
+ };
686
+ /**
687
+ * Cliente de alto nível para operações do módulo de lojas.
688
+ */
689
+ declare class Stores {
690
+ private core;
691
+ /**
692
+ * @param core Cliente base da SDK.
693
+ */
694
+ constructor(core: CoreClient);
695
+ /**
696
+ * Lista lojas da conta com suporte a paginação.
697
+ */
698
+ get(input?: GetStoresInput): Promise<GetStoresResponse>;
699
+ /**
700
+ * Busca uma loja pelo ID.
701
+ */
702
+ getById(storeId: string): Promise<GetStoreByIdResponse>;
703
+ /**
704
+ * Cria uma nova loja.
705
+ */
706
+ post(input: CreateStoreInput): Promise<CreateStoreResponse>;
707
+ /**
708
+ * Atualiza uma loja existente.
709
+ */
710
+ put(storeId: string, input: UpdateStoreInput): Promise<UpdateStoreResponse>;
711
+ /**
712
+ * Exclui uma loja pelo ID.
713
+ */
714
+ delete(storeId: string): Promise<DeleteStoreResponse>;
715
+ /**
716
+ * Reordena lojas pelo array final de IDs.
717
+ */
718
+ reorder(storeIds: string[]): Promise<ReorderStoresResponse>;
719
+ }
720
+
721
+ /**
722
+ * Resposta de listagem de webhooks por loja.
723
+ */
724
+ type GetWebhooksResponse = {
725
+ webhooks: string[];
726
+ max: number;
727
+ };
728
+ /**
729
+ * Payload para criar webhook em uma loja.
730
+ */
731
+ type CreateWebhookInput = {
732
+ url: string;
733
+ };
734
+ /**
735
+ * Resposta de criação de webhook.
736
+ */
737
+ type CreateWebhookResponse = {
738
+ status: boolean;
739
+ code: string;
740
+ webhook: string;
741
+ };
742
+ /**
743
+ * Payload para remover webhook de uma loja.
744
+ */
745
+ type DeleteWebhookInput = {
746
+ url: string;
747
+ };
748
+ /**
749
+ * Resposta de remoção de webhook.
750
+ */
751
+ type DeleteWebhookResponse = {
752
+ status: boolean;
753
+ code: string;
754
+ };
755
+ /**
756
+ * Cliente de alto nível para operações de webhooks da loja.
757
+ */
758
+ declare class Webhooks {
759
+ private core;
760
+ /**
761
+ * @param core Cliente base da SDK.
762
+ */
763
+ constructor(core: CoreClient);
764
+ /**
765
+ * Lista os webhooks cadastrados para uma loja.
766
+ */
767
+ get(storeId: string): Promise<GetWebhooksResponse>;
768
+ /**
769
+ * Adiciona um webhook em uma loja.
770
+ */
771
+ post(storeId: string, input: CreateWebhookInput): Promise<CreateWebhookResponse>;
772
+ /**
773
+ * Remove um webhook de uma loja.
774
+ */
775
+ delete(storeId: string, input: DeleteWebhookInput): Promise<DeleteWebhookResponse>;
776
+ /**
777
+ * Descriptografa e valida o payload recebido no webhook de assinatura.
778
+ *
779
+ * Espera um payload no formato `iv:encrypted` (ambos em base64), criptografado
780
+ * com AES-256-CBC usando a chave informada.
781
+ */
782
+ decrypty(secret: string, payload: string): Promise<Record<string, unknown>>;
783
+ /**
784
+ * Alias com nome corrigido para descriptografar payload de webhook.
785
+ */
786
+ decrypt(secret: string, payload: string): Promise<Record<string, unknown>>;
787
+ /**
788
+ * Alias retrocompatível para quem já usa `parseSubscriptionPayload`.
789
+ */
790
+ parseSubscriptionPayload(payload: string, secret: string): Promise<Record<string, unknown>>;
86
791
  }
87
792
 
88
793
  /**
89
794
  * SDK principal da caBRAPI
90
795
  */
91
796
  declare class caBRAPI {
797
+ categories: Categories;
798
+ coupons: Coupons;
799
+ payments: Payments;
92
800
  pages: Pages;
801
+ products: Products;
802
+ stores: Stores;
803
+ webhooks: Webhooks;
93
804
  constructor(options: ClientOptions);
94
805
  }
95
806