@cabrapi/sdk 1.0.0-alpha.2 → 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.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +12 -3
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';function ye(o,e){return /^https?:\/\//.test(e)?e:`${o.replace(/\/$/,"")}/${e.replace(/^\//,"")}`}function Ce(o){if(!o)return "";let e=encodeURIComponent,t=Object.entries(o).filter(([,r])=>r!=null).map(([r,i])=>`${e(r)}=${e(String(i))}`).join("&");return t?`?${t}`:""}function S(o={}){let e=o.baseURL??"https://api.cabrapi.com.br",t=o.timeout??3e4,r=[],i=[];async function p(s){let n={...s};for(let a of r)try{n=await a.fulfilled(n);}catch(c){throw a.rejected&&a.rejected(c),c}let u=ye(e,n.url??"")+Ce(n.params),g={"Content-Type":"application/json",...n.headers||{}};o.apiKey&&(g.Authorization=`${o.apiKey}`);let l=new AbortController,le=n.timeout??t,k=setTimeout(()=>l.abort(),le),A={method:s.method.toUpperCase(),headers:g,signal:l.signal};n.data!==void 0&&s.method.toLowerCase()!=="get"&&(A.body=typeof n.data=="string"?n.data:JSON.stringify(n.data));let d;try{d=await fetch(u,A),clearTimeout(k);}catch(a){throw clearTimeout(k),a}let x=await d.text(),I=null;try{I=x?JSON.parse(x):null;}catch{I=x;}let m={data:I,status:d.status,statusText:d.statusText,headers:Object.fromEntries(d.headers.entries()),config:n};for(let a of i)try{await a.fulfilled(m);}catch(c){throw a.rejected&&a.rejected(c),c}if(!d.ok)throw (typeof m.data=="object"&&m.data!==null&&"error"in m.data?m.data.error:void 0)??m.data??{status:d.status};return m}return {interceptors:{request:{use(s,n){r.push({fulfilled:s,rejected:n});}},response:{use(s,n){i.push({fulfilled:s,rejected:n});}}},async get(s,n={}){return p({...n,url:s,method:"get"})},async post(s,n,u={}){return p({...u,url:s,data:n,method:"post"})},async put(s,n,u={}){return p({...u,url:s,data:n,method:"put"})},async delete(s,n={}){return p({...n,url:s,method:"delete"})},async request(s){return p(s)}}}var fe=typeof window<"u"&&typeof document<"u",y=class{constructor(e){if(this.mode=e.type,this.isBrowser=fe,this.mode==="private"&&!e.config?.key&&!this.isBrowser)throw new Error("API key \xE9 obrigat\xF3ria no modo 'private'.");let t=!this.isBrowser&&this.mode==="private"?e.config?.key:void 0;this.http=S({baseURL:e.config?.baseURL,apiKey:t}),this.isBrowser&&this.mode==="private"&&console.warn("[caBRAPI] Modo 'private' detectado no navegador. API key ignorada.");}isPrivate(){return !this.isBrowser&&this.mode==="private"}isPublic(){return this.isBrowser||this.mode==="public"}assertPrivate(){if(!this.isPrivate())throw new Error("Este m\xE9todo \xE9 privado e n\xE3o pode ser usado no navegador.")}};async function E(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.delete(`/stores/${e}/categories/${t}`);return r}async function G(o,e,t={}){let{data:r}=await o.http.get(`/stores/${e}/categories`,{params:{page:t.page,limit:t.limit}});return r}async function D(o,e,t){let{data:r}=await o.http.get(`/stores/${e}/categories/${t}`);return r}async function U(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.post(`/stores/${e}/categories`,t);return r}async function B(o,e,t,r){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:i}=await o.http.put(`/stores/${e}/categories/${t}`,r);return i}async function T(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.put(`/stores/${e}/categories/reorder`,{categoryIds:t});return r}var C=class{constructor(e){this.core=e;}get(e,t={}){return G(this.core,e,t)}getById(e,t){return D(this.core,e,t)}post(e,t){return U(this.core,e,t)}put(e,t,r){return B(this.core,e,t,r)}delete(e,t){return E(this.core,e,t)}reorder(e,t){return T(this.core,e,t)}};async function $(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.delete(`/stores/${e}/coupons/${t}`);return r}async function M(o,e,t={}){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.get(`/stores/${e}/coupons`,{params:{page:t.page,limit:t.limit}});return r}async function O(o,e,t){let{data:r}=await o.http.get(`/stores/${e}/coupons/${t}`);return r}async function W(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.get(`/stores/${e}/coupons/uuid/${t}`);return r}async function L(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.post(`/stores/${e}/coupons`,t);return r}async function q(o,e,t,r){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:i}=await o.http.put(`/stores/${e}/coupons/${t}`,r);return i}async function F(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.put(`/stores/${e}/coupons/reorder`,{couponIds:t});return r}var f=class{constructor(e){this.core=e;}get(e,t={}){return M(this.core,e,t)}getByCode(e,t){return O(this.core,e,t)}getById(e,t){return W(this.core,e,t)}post(e,t){return L(this.core,e,t)}put(e,t,r){return q(this.core,e,t,r)}delete(e,t){return $(this.core,e,t)}reorder(e,t){return F(this.core,e,t)}};async function N(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.delete(`/pages/${e}`);return t}async function _(o,e){let{data:t}=await o.http.get(`/pages/${e}`);if(!t?.data)throw new Error(`Page not found: ${e}`);return {status:t.status,data:t.data}}async function V(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.put(`/pages/${e.domain}`,{html:e.html,template:e.template});return t}var P=class{constructor(e){this.core=e;}get(e){return _(this.core,e)}upsert(e){return V(this.core,e)}delete(e){return N(this.core,e)}};async function K(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.delete(`/stores/${e}/payments/${t}`);return r}async function j(o,e,t={}){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.get(`/stores/${e}/payments/filter`,{params:{id:t.id,uuid:t.uuid,status:t.status,name:t.name,email:t.email,cpf:t.cpf,price:t.price,minPrice:t.minPrice,maxPrice:t.maxPrice,coupon:t.coupon,gateway:t.gateway,shipment:t.shipment,createdAtFrom:t.createdAtFrom,createdAtTo:t.createdAtTo,updatedAtFrom:t.updatedAtFrom,updatedAtTo:t.updatedAtTo,productId:t.productId,metadataKey:t.metadataKey,metadataValue:t.metadataValue,sortBy:t.sortBy,sortOrder:t.sortOrder,page:t.page,limit:t.limit}});return r}async function H(o,e,t={}){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.get(`/stores/${e}/payments`,{params:{page:t.page,limit:t.limit}});return r}async function J(o,e,t){let{data:r}=await o.http.post(`/stores/${e}/payments`,t);return r}async function Y(o,e,t,r){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:i}=await o.http.put(`/stores/${e}/payments/${t}`,r);return i}var R=class{constructor(e){this.core=e;}get(e,t={}){return H(this.core,e,t)}filter(e,t={}){return j(this.core,e,t)}post(e,t){return J(this.core,e,t)}put(e,t,r){return Y(this.core,e,t,r)}delete(e,t){return K(this.core,e,t)}};async function Q(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.delete(`/stores/${e}/products/${t}`);return r}async function X(o,e,t={}){let{data:r}=await o.http.get(`/stores/${e}/products`,{params:{page:t.page,limit:t.limit}});return r}async function z(o,e,t){let{data:r}=await o.http.get(`/stores/${e}/products/${t}`);return r}async function Z(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.post(`/stores/${e}/products`,t);return r}async function ee(o,e,t,r){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:i}=await o.http.put(`/stores/${e}/products/${t}`,r);return i}async function te(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.put(`/stores/${e}/products/reorder`,{productIds:t});return r}var b=class{constructor(e){this.core=e;}get(e,t={}){return X(this.core,e,t)}getById(e,t){return z(this.core,e,t)}post(e,t){return Z(this.core,e,t)}put(e,t,r){return ee(this.core,e,t,r)}delete(e,t){return Q(this.core,e,t)}reorder(e,t){return te(this.core,e,t)}};async function oe(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.delete(`/stores/${e}`);return t}async function re(o,e={}){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.get("/stores",{params:{page:e.page,limit:e.limit}});return t}async function ne(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.get(`/stores/${e}`);return t}async function se(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.post("/stores",e);return t}async function ie(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.put(`/stores/${e}`,t);return r}async function ae(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.put("/stores/reorder",{storeIds:e});return t}var h=class{constructor(e){this.core=e;}get(e={}){return re(this.core,e)}getById(e){return ne(this.core,e)}post(e){return se(this.core,e)}put(e,t){return ie(this.core,e,t)}delete(e){return oe(this.core,e)}reorder(e){return ae(this.core,e)}};async function pe(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.delete(`/stores/${e}/webhooks`,{data:t});return r}async function ue(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.get(`/stores/${e}/webhooks`);return t}async function de(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.post(`/stores/${e}/webhooks`,t);return r}var w=class{constructor(e){this.core=e;}get(e){return ue(this.core,e)}post(e,t){return de(this.core,e,t)}delete(e,t){return pe(this.core,e,t)}async decrypty(e,t){if(!e)throw new Error("SECRET_KEY_REQUIRED");if(!t||typeof t!="string")throw new Error("INVALID_PAYLOAD_FORMAT");let[r,i]=t.split(":");if(!r||!i)throw new Error("INVALID_PAYLOAD_FORMAT");let p=me(r),v=me(i),s=new TextEncoder().encode(e),n=await globalThis.crypto.subtle.digest("SHA-256",s),u=await globalThis.crypto.subtle.importKey("raw",n,{name:"AES-CBC"},false,["decrypt"]),g=await globalThis.crypto.subtle.decrypt({name:"AES-CBC",iv:ce(p)},u,ce(v)),l=new TextDecoder().decode(g);return JSON.parse(l)}async decrypt(e,t){return this.decrypty(e,t)}async parseSubscriptionPayload(e,t){return this.decrypty(t,e)}};function me(o){let e=atob(o),t=new Uint8Array(e.length);for(let r=0;r<e.length;r+=1)t[r]=e.charCodeAt(r);return t}function ce(o){return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}var ge=class{constructor(e){let t=new y(e);this.categories=new C(t),this.coupons=new f(t),this.payments=new R(t),this.pages=new P(t),this.products=new b(t),this.stores=new h(t),this.webhooks=new w(t);}};
|
|
2
|
-
exports.caBRAPI=
|
|
1
|
+
'use strict';function Ce(o,e){return /^https?:\/\//.test(e)?e:`${o.replace(/\/$/,"")}/${e.replace(/^\//,"")}`}function fe(o){if(!o)return "";let e=encodeURIComponent,t=Object.entries(o).filter(([,r])=>r!=null).map(([r,i])=>`${e(r)}=${e(String(i))}`).join("&");return t?`?${t}`:""}function S(o={}){let e=o.baseURL??"https://api.cabrapi.com.br",t=o.timeout??3e4,r=[],i=[];async function p(s){let n={...s};for(let a of r)try{n=await a.fulfilled(n);}catch(c){throw a.rejected&&a.rejected(c),c}let u=Ce(e,n.url??"")+fe(n.params),g={"Content-Type":"application/json",...n.headers||{}};o.apiKey&&(g.Authorization=`${o.apiKey}`);let l=new AbortController,ye=n.timeout??t,k=setTimeout(()=>l.abort(),ye),A={method:s.method.toUpperCase(),headers:g,signal:l.signal};n.data!==void 0&&s.method.toLowerCase()!=="get"&&(A.body=typeof n.data=="string"?n.data:JSON.stringify(n.data));let d;try{d=await fetch(u,A),clearTimeout(k);}catch(a){throw clearTimeout(k),a}let w=await d.text(),I=null;try{I=w?JSON.parse(w):null;}catch{I=w;}let m={data:I,status:d.status,statusText:d.statusText,headers:Object.fromEntries(d.headers.entries()),config:n};for(let a of i)try{await a.fulfilled(m);}catch(c){throw a.rejected&&a.rejected(c),c}if(!d.ok)throw (typeof m.data=="object"&&m.data!==null&&"error"in m.data?m.data.error:void 0)??m.data??{status:d.status};return m}return {interceptors:{request:{use(s,n){r.push({fulfilled:s,rejected:n});}},response:{use(s,n){i.push({fulfilled:s,rejected:n});}}},async get(s,n={}){return p({...n,url:s,method:"get"})},async post(s,n,u={}){return p({...u,url:s,data:n,method:"post"})},async put(s,n,u={}){return p({...u,url:s,data:n,method:"put"})},async delete(s,n={}){return p({...n,url:s,method:"delete"})},async request(s){return p(s)}}}var Pe=typeof window<"u"&&typeof document<"u",y=class{constructor(e){if(this.mode=e.type,this.isBrowser=Pe,this.mode==="private"&&!e.config?.key&&!this.isBrowser)throw new Error("API key \xE9 obrigat\xF3ria no modo 'private'.");let t=!this.isBrowser&&this.mode==="private"?e.config?.key:void 0;this.http=S({baseURL:e.config?.baseURL,apiKey:t}),this.isBrowser&&this.mode==="private"&&console.warn("[caBRAPI] Modo 'private' detectado no navegador. API key ignorada.");}isPrivate(){return !this.isBrowser&&this.mode==="private"}isPublic(){return this.isBrowser||this.mode==="public"}assertPrivate(){if(!this.isPrivate())throw new Error("Este m\xE9todo \xE9 privado e n\xE3o pode ser usado no navegador.")}};async function G(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.delete(`/stores/${e}/categories/${t}`);return r}async function E(o,e,t={}){let{data:r}=await o.http.get(`/stores/${e}/categories`,{params:{page:t.page,limit:t.limit}});return r}async function D(o,e,t){let{data:r}=await o.http.get(`/stores/${e}/categories/${t}`);return r}async function B(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.post(`/stores/${e}/categories`,t);return r}async function U(o,e,t,r){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:i}=await o.http.put(`/stores/${e}/categories/${t}`,r);return i}async function T(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.put(`/stores/${e}/categories/reorder`,{categoryIds:t});return r}var C=class{constructor(e){this.core=e;}get(e,t={}){return E(this.core,e,t)}getById(e,t){return D(this.core,e,t)}post(e,t){return B(this.core,e,t)}put(e,t,r){return U(this.core,e,t,r)}delete(e,t){return G(this.core,e,t)}reorder(e,t){return T(this.core,e,t)}};async function $(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.delete(`/stores/${e}/coupons/${t}`);return r}async function M(o,e,t={}){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.get(`/stores/${e}/coupons`,{params:{page:t.page,limit:t.limit}});return r}async function O(o,e,t){let{data:r}=await o.http.get(`/stores/${e}/coupons/${t}`);return r}async function W(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.get(`/stores/${e}/coupons/uuid/${t}`);return r}async function L(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.post(`/stores/${e}/coupons`,t);return r}async function q(o,e,t,r){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:i}=await o.http.put(`/stores/${e}/coupons/${t}`,r);return i}async function F(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.put(`/stores/${e}/coupons/reorder`,{couponIds:t});return r}var f=class{constructor(e){this.core=e;}get(e,t={}){return M(this.core,e,t)}getByCode(e,t){return O(this.core,e,t)}getById(e,t){return W(this.core,e,t)}post(e,t){return L(this.core,e,t)}put(e,t,r){return q(this.core,e,t,r)}delete(e,t){return $(this.core,e,t)}reorder(e,t){return F(this.core,e,t)}};async function N(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.delete(`/pages/${e}`);return t}async function _(o,e){let{data:t}=await o.http.get(`/pages/${e}`);if(!t?.data)throw new Error(`Page not found: ${e}`);return {status:t.status,data:t.data}}async function V(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.put(`/pages/${e.domain}`,{html:e.html,template:e.template});return t}var P=class{constructor(e){this.core=e;}get(e){return _(this.core,e)}upsert(e){return V(this.core,e)}delete(e){return N(this.core,e)}};async function K(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.delete(`/stores/${e}/payments/${t}`);return r}async function j(o,e,t={}){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.get(`/stores/${e}/payments/filter`,{params:{id:t.id,uuid:t.uuid,status:t.status,name:t.name,email:t.email,cpf:t.cpf,price:t.price,minPrice:t.minPrice,maxPrice:t.maxPrice,coupon:t.coupon,gateway:t.gateway,shipment:t.shipment,createdAtFrom:t.createdAtFrom,createdAtTo:t.createdAtTo,updatedAtFrom:t.updatedAtFrom,updatedAtTo:t.updatedAtTo,productId:t.productId,metadataKey:t.metadataKey,metadataValue:t.metadataValue,sortBy:t.sortBy,sortOrder:t.sortOrder,page:t.page,limit:t.limit}});return r}async function H(o,e,t={}){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.get(`/stores/${e}/payments`,{params:{page:t.page,limit:t.limit}});return r}async function J(o,e,t){let{data:r}=await o.http.post(`/stores/${e}/payments`,t);return r}async function Y(o,e,t,r){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:i}=await o.http.put(`/stores/${e}/payments/${t}`,r);return i}var R=class{constructor(e){this.core=e;}get(e,t={}){return H(this.core,e,t)}filter(e,t={}){return j(this.core,e,t)}post(e,t){return J(this.core,e,t)}put(e,t,r){return Y(this.core,e,t,r)}delete(e,t){return K(this.core,e,t)}};async function Q(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.delete(`/stores/${e}/products/${t}`);return r}async function X(o,e,t={}){let{data:r}=await o.http.get(`/stores/${e}/products`,{params:{page:t.page,limit:t.limit}});return r}async function z(o,e,t,r={}){let{data:i}=await o.http.get(`/stores/${e}/categories/${t}/products`,{params:{page:r.page,limit:r.limit}});return i}async function Z(o,e,t){let{data:r}=await o.http.get(`/stores/${e}/products/${t}`);return r}async function ee(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.post(`/stores/${e}/products`,t);return r}async function te(o,e,t,r){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:i}=await o.http.put(`/stores/${e}/products/${t}`,r);return i}async function oe(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.put(`/stores/${e}/products/reorder`,{productIds:t});return r}var b=class{constructor(e){this.core=e;}get(e,t={}){return X(this.core,e,t)}getByCategory(e,t,r={}){return z(this.core,e,t,r)}getById(e,t){return Z(this.core,e,t)}post(e,t){return ee(this.core,e,t)}put(e,t,r){return te(this.core,e,t,r)}delete(e,t){return Q(this.core,e,t)}reorder(e,t){return oe(this.core,e,t)}};async function re(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.delete(`/stores/${e}`);return t}async function ne(o,e={}){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.get("/stores",{params:{page:e.page,limit:e.limit}});return t}async function se(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.get(`/stores/${e}`);return t}async function ie(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.post("/stores",e);return t}async function ae(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.put(`/stores/${e}`,t);return r}async function pe(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.put("/stores/reorder",{storeIds:e});return t}var h=class{constructor(e){this.core=e;}get(e={}){return ne(this.core,e)}getById(e){return se(this.core,e)}post(e){return ie(this.core,e)}put(e,t){return ae(this.core,e,t)}delete(e){return re(this.core,e)}reorder(e){return pe(this.core,e)}};async function ue(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.delete(`/stores/${e}/webhooks`,{data:t});return r}async function de(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.get(`/stores/${e}/webhooks`);return t}async function me(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.post(`/stores/${e}/webhooks`,t);return r}var x=class{constructor(e){this.core=e;}get(e){return de(this.core,e)}post(e,t){return me(this.core,e,t)}delete(e,t){return ue(this.core,e,t)}async decrypty(e,t){if(!e)throw new Error("SECRET_KEY_REQUIRED");if(!t||typeof t!="string")throw new Error("INVALID_PAYLOAD_FORMAT");let[r,i]=t.split(":");if(!r||!i)throw new Error("INVALID_PAYLOAD_FORMAT");let p=ce(r),v=ce(i),s=new TextEncoder().encode(e),n=await globalThis.crypto.subtle.digest("SHA-256",s),u=await globalThis.crypto.subtle.importKey("raw",n,{name:"AES-CBC"},false,["decrypt"]),g=await globalThis.crypto.subtle.decrypt({name:"AES-CBC",iv:ge(p)},u,ge(v)),l=new TextDecoder().decode(g);return JSON.parse(l)}async decrypt(e,t){return this.decrypty(e,t)}async parseSubscriptionPayload(e,t){return this.decrypty(t,e)}};function ce(o){let e=atob(o),t=new Uint8Array(e.length);for(let r=0;r<e.length;r+=1)t[r]=e.charCodeAt(r);return t}function ge(o){return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}var le=class{constructor(e){let t=new y(e);this.categories=new C(t),this.coupons=new f(t),this.payments=new R(t),this.pages=new P(t),this.products=new b(t),this.stores=new h(t),this.webhooks=new x(t);}};
|
|
2
|
+
exports.caBRAPI=le;//# sourceMappingURL=index.cjs.map
|
|
3
3
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/http.ts","../src/core/client.ts","../src/core/module/categories/http/delete.ts","../src/core/module/categories/http/get.ts","../src/core/module/categories/http/get-by-id.ts","../src/core/module/categories/http/post.ts","../src/core/module/categories/http/put.ts","../src/core/module/categories/http/reorder.ts","../src/core/module/categories/index.ts","../src/core/module/coupons/http/delete.ts","../src/core/module/coupons/http/get.ts","../src/core/module/coupons/http/get-by-code.ts","../src/core/module/coupons/http/get-by-id.ts","../src/core/module/coupons/http/post.ts","../src/core/module/coupons/http/put.ts","../src/core/module/coupons/http/reorder.ts","../src/core/module/coupons/index.ts","../src/core/module/pages/http/delete.ts","../src/core/module/pages/http/get.ts","../src/core/module/pages/http/upsert.ts","../src/core/module/pages/index.ts","../src/core/module/payments/http/delete.ts","../src/core/module/payments/http/filter.ts","../src/core/module/payments/http/get.ts","../src/core/module/payments/http/post.ts","../src/core/module/payments/http/put.ts","../src/core/module/payments/index.ts","../src/core/module/products/http/delete.ts","../src/core/module/products/http/get.ts","../src/core/module/products/http/get-by-id.ts","../src/core/module/products/http/post.ts","../src/core/module/products/http/put.ts","../src/core/module/products/http/reorder.ts","../src/core/module/products/index.ts","../src/core/module/stores/http/delete.ts","../src/core/module/stores/http/get.ts","../src/core/module/stores/http/get-by-id.ts","../src/core/module/stores/http/post.ts","../src/core/module/stores/http/put.ts","../src/core/module/stores/http/reorder.ts","../src/core/module/stores/index.ts","../src/core/module/webhooks/http/delete.ts","../src/core/module/webhooks/http/get.ts","../src/core/module/webhooks/http/post.ts","../src/core/module/webhooks/index.ts","../src/index.ts"],"names":["buildURL","base","path","buildQuery","params","esc","query","v","k","createAxios","cfg","baseURL","timeout","requestInterceptors","responseInterceptors","runRequest","config","conf","i","e","url","headers","controller","to","timer","opts","raw","err","text","data","res","fulfilled","rejected","options","isBrowser","CoreClient","apiKey","deleteCategory","core","storeId","categoryId","getCategories","input","getCategoryById","createCategory","updateCategory","reorderCategories","categoryIds","Categories","deleteCoupon","couponId","getCoupons","getCouponByCode","code","getCouponById","createCoupon","updateCoupon","reorderCoupons","couponIds","Coupons","deletePage","domain","getPage","upsertPage","Pages","deletePayment","paymentId","filterPayments","getPayments","createPayment","updatePayment","Payments","deleteProduct","productId","getProducts","getProductById","createProduct","updateProduct","reorderProducts","productIds","Products","deleteStore","getStores","getStoreById","createStore","updateStore","reorderStores","storeIds","Stores","deleteWebhook","getWebhooks","createWebhook","Webhooks","secret","payload","ivB64","encrypted","iv","base64ToBytes","encryptedBytes","secretBytes","keyHash","cryptoKey","decryptedBuffer","toArrayBuffer","decrypted","base64","binary","bytes","caBRAPI"],"mappings":"aA+BA,SAASA,GAASC,CAAAA,CAAcC,CAAAA,CAAc,CAC5C,OAAI,eAAe,IAAA,CAAKA,CAAI,CAAA,CAAUA,CAAAA,CAC/B,GAAGD,CAAAA,CAAK,OAAA,CAAQ,KAAA,CAAO,EAAE,CAAC,CAAA,CAAA,EAAIC,CAAAA,CAAK,OAAA,CAAQ,KAAA,CAAO,EAAE,CAAC,CAAA,CAC9D,CAEA,SAASC,GAAWC,CAAAA,CAAkC,CACpD,GAAI,CAACA,EAAQ,OAAO,EAAA,CACpB,IAAMC,CAAAA,CAAM,mBACNC,CAAAA,CAAQ,MAAA,CAAO,OAAA,CAAQF,CAAM,EAChC,MAAA,CAAO,CAAC,EAAGG,CAAC,CAAA,GAAyBA,CAAAA,EAAM,IAAI,CAAA,CAC/C,IAAI,CAAC,CAACC,CAAAA,CAAGD,CAAC,IAAM,CAAA,EAAGF,CAAAA,CAAIG,CAAC,CAAC,IAAIH,CAAAA,CAAI,MAAA,CAAOE,CAAC,CAAC,CAAC,CAAA,CAAE,CAAA,CAC7C,IAAA,CAAK,GAAG,EACX,OAAOD,CAAAA,CAAQ,IAAIA,CAAK,CAAA,CAAA,CAAK,EAC/B,CAEO,SAASG,CAAAA,CAAYC,CAAAA,CAAmB,EAAC,CAAG,CACjD,IAAMC,CAAAA,CAAUD,EAAI,OAAA,EAAW,4BAAA,CACzBE,CAAAA,CAAUF,CAAAA,CAAI,SAAW,GAAA,CAEzBG,CAAAA,CAAyD,EAAC,CAC1DC,EAAqD,EAAC,CAE5D,eAAeC,CAAAA,CACbC,EAC2B,CAC3B,IAAIC,CAAAA,CAA2B,CAAE,GAAGD,CAAO,CAAA,CAE3C,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AIe,CAAAA,CAAWV,CAAI,EACrC,IAAA,CAAK,OAAA,CAAU,IAAIqB,CAAAA,CAAQrB,CAAI,CAAA,CAC/B,IAAA,CAAK,QAAA,CAAW,IAAIiC,EAASjC,CAAI,CAAA,CACjC,IAAA,CAAK,KAAA,CAAQ,IAAI0B,CAAAA,CAAM1B,CAAI,CAAA,CAC3B,IAAA,CAAK,SAAW,IAAI0C,CAAAA,CAAS1C,CAAI,CAAA,CACjC,KAAK,MAAA,CAAS,IAAIkD,CAAAA,CAAOlD,CAAI,EAC7B,IAAA,CAAK,QAAA,CAAW,IAAIsD,CAAAA,CAAStD,CAAI,EACnC,CACF","file":"index.cjs","sourcesContent":["/**\n * Adapter HTTP simples usando fetch (nativo).\n * Exporta `createAxios` para compatibilidade com restante do código.\n */\nexport type AxiosConfig = {\n baseURL?: string;\n apiKey?: string;\n timeout?: number;\n};\n\nexport type AxiosRequestConfig = {\n url?: string;\n params?: Record<string, unknown>;\n headers?: Record<string, string>;\n data?: unknown;\n timeout?: number;\n};\n\nexport type AxiosResponse<T = unknown> = {\n data: T;\n status: number;\n statusText: string;\n headers: Record<string, string>;\n config?: AxiosRequestConfig;\n};\n\ntype Interceptor<V> = {\n fulfilled: (v: V) => V | Promise<V>;\n rejected?: (err: unknown) => unknown;\n};\n\nfunction buildURL(base: string, path: string) {\n if (/^https?:\\/\\//.test(path)) return path;\n return `${base.replace(/\\/$/, \"\")}/${path.replace(/^\\//, \"\")}`;\n}\n\nfunction buildQuery(params?: Record<string, unknown>) {\n if (!params) return \"\";\n const esc = encodeURIComponent;\n const query = Object.entries(params)\n .filter(([, v]) => v !== undefined && v !== null)\n .map(([k, v]) => `${esc(k)}=${esc(String(v))}`)\n .join(\"&\");\n return query ? `?${query}` : \"\";\n}\n\nexport function createAxios(cfg: AxiosConfig = {}) {\n const baseURL = cfg.baseURL ?? \"https://api.cabrapi.com.br\";\n const timeout = cfg.timeout ?? 30000;\n\n const requestInterceptors: Interceptor<AxiosRequestConfig>[] = [];\n const responseInterceptors: Interceptor<AxiosResponse>[] = [];\n\n async function runRequest<T = unknown>(\n config: AxiosRequestConfig & { method: string },\n ): Promise<AxiosResponse<T>> {\n let conf: AxiosRequestConfig = { ...config };\n\n for (const i of requestInterceptors) {\n try {\n // allow interceptor to modify config\n conf = await i.fulfilled(conf);\n } catch (e) {\n if (i.rejected) i.rejected(e);\n throw e;\n }\n }\n\n const url =\n buildURL(baseURL, conf.url ?? \"\") +\n buildQuery(conf.params as Record<string, unknown> | undefined);\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...(conf.headers || {}),\n };\n\n if (cfg.apiKey) headers.Authorization = `${cfg.apiKey}`;\n\n const controller = new AbortController();\n const to = conf.timeout ?? timeout;\n const timer = setTimeout(() => controller.abort(), to);\n\n const opts: RequestInit = {\n method: config.method.toUpperCase(),\n headers,\n signal: controller.signal,\n };\n\n if (conf.data !== undefined && config.method.toLowerCase() !== \"get\") {\n opts.body =\n typeof conf.data === \"string\" ? conf.data : JSON.stringify(conf.data);\n }\n\n let raw: Response;\n try {\n raw = await fetch(url, opts);\n clearTimeout(timer);\n } catch (err: unknown) {\n clearTimeout(timer);\n if (err && typeof err === \"object\") {\n // pass to caller\n }\n throw err;\n }\n\n const text = await raw.text();\n let data: unknown = null;\n try {\n data = text ? JSON.parse(text) : null;\n } catch {\n data = text;\n }\n\n const res: AxiosResponse<T> = {\n data: data as T,\n status: raw.status,\n statusText: raw.statusText,\n headers: Object.fromEntries(raw.headers.entries()),\n config: conf,\n };\n\n for (const i of responseInterceptors) {\n try {\n // allow interceptor to transform response\n // eslint-disable-next-line no-await-in-loop\n await i.fulfilled(res);\n } catch (e) {\n if (i.rejected) i.rejected(e);\n throw e;\n }\n }\n\n if (!raw.ok) {\n const maybeError =\n typeof res.data === \"object\" &&\n res.data !== null &&\n \"error\" in (res.data as Record<string, unknown>)\n ? (res.data as Record<string, unknown>).error\n : undefined;\n const err = maybeError ?? res.data ?? { status: raw.status };\n throw err as unknown;\n }\n\n return res;\n }\n\n const instance = {\n interceptors: {\n request: {\n use(\n fulfilled: (\n c: AxiosRequestConfig,\n ) => AxiosRequestConfig | Promise<AxiosRequestConfig>,\n rejected?: (e: unknown) => unknown,\n ) {\n requestInterceptors.push({ fulfilled, rejected });\n },\n },\n response: {\n use(\n fulfilled: (\n r: AxiosResponse,\n ) => AxiosResponse | Promise<AxiosResponse>,\n rejected?: (e: unknown) => unknown,\n ) {\n responseInterceptors.push({ fulfilled, rejected });\n },\n },\n },\n\n async get<T = unknown>(\n url: string,\n options: AxiosRequestConfig = {},\n ): Promise<AxiosResponse<T>> {\n return runRequest<T>({ ...options, url, method: \"get\" });\n },\n\n async post<T = unknown>(\n url: string,\n data?: unknown,\n options: AxiosRequestConfig = {},\n ): Promise<AxiosResponse<T>> {\n return runRequest<T>({ ...options, url, data, method: \"post\" });\n },\n\n async put<T = unknown>(\n url: string,\n data?: unknown,\n options: AxiosRequestConfig = {},\n ): Promise<AxiosResponse<T>> {\n return runRequest<T>({ ...options, url, data, method: \"put\" });\n },\n\n async delete<T = unknown>(\n url: string,\n options: AxiosRequestConfig = {},\n ): Promise<AxiosResponse<T>> {\n return runRequest<T>({ ...options, url, method: \"delete\" });\n },\n\n // compatibility: allow calling instance(config)\n async request<T = unknown>(\n options: AxiosRequestConfig & { method: string },\n ): Promise<AxiosResponse<T>> {\n return runRequest<T>(options);\n },\n };\n\n return instance;\n}\n","import { createAxios } from \"./http\";\n\n/**\n * Tipo derivado da instância do Axios\n * (evita problemas no build de types)\n */\ntype AxiosInstance = ReturnType<typeof createAxios>;\n\n/**\n * Modos disponíveis\n */\nexport type ClientMode = \"public\" | \"private\";\n\n/**\n * Opções do cliente\n */\nexport type ClientOptions = {\n type: ClientMode;\n config?: {\n key?: string;\n baseURL?: string;\n };\n};\n\n/**\n * Detecta ambiente\n */\nconst isBrowser =\n typeof window !== \"undefined\" && typeof document !== \"undefined\";\n\n/**\n * Cliente base da caBRAPI\n */\nexport class CoreClient {\n public http: AxiosInstance;\n public mode: ClientMode;\n public isBrowser: boolean;\n\n constructor(options: ClientOptions) {\n this.mode = options.type;\n this.isBrowser = isBrowser;\n\n // 🔒 validação backend\n if (this.mode === \"private\" && !options.config?.key && !this.isBrowser) {\n throw new Error(\"API key é obrigatória no modo 'private'.\");\n }\n\n // 🔐 só backend usa key\n const apiKey =\n !this.isBrowser && this.mode === \"private\"\n ? options.config?.key\n : undefined;\n\n this.http = createAxios({ baseURL: options.config?.baseURL, apiKey });\n\n // ⚠️ aviso dev\n if (this.isBrowser && this.mode === \"private\") {\n console.warn(\n \"[caBRAPI] Modo 'private' detectado no navegador. API key ignorada.\",\n );\n }\n }\n\n /**\n * Está em modo privado (backend)\n */\n public isPrivate(): boolean {\n return !this.isBrowser && this.mode === \"private\";\n }\n\n /**\n * Está em modo público\n */\n public isPublic(): boolean {\n return this.isBrowser || this.mode === \"public\";\n }\n\n /**\n * Garante execução no backend\n */\n public assertPrivate(): void {\n if (!this.isPrivate()) {\n throw new Error(\n \"Este método é privado e não pode ser usado no navegador.\",\n );\n }\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeleteCategoryResponse } from \"../index\";\n\nexport async function deleteCategory(\n core: CoreClient,\n storeId: string,\n categoryId: string,\n): Promise<DeleteCategoryResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeleteCategoryResponse>(\n `/stores/${storeId}/categories/${categoryId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetCategoriesInput, GetCategoriesResponse } from \"../index\";\n\nexport async function getCategories(\n core: CoreClient,\n storeId: string,\n input: GetCategoriesInput = {},\n): Promise<GetCategoriesResponse> {\n const { data } = await core.http.get<GetCategoriesResponse>(\n `/stores/${storeId}/categories`,\n {\n params: {\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetCategoryByIdResponse } from \"../index\";\n\nexport async function getCategoryById(\n core: CoreClient,\n storeId: string,\n categoryId: string,\n): Promise<GetCategoryByIdResponse> {\n const { data } = await core.http.get<GetCategoryByIdResponse>(\n `/stores/${storeId}/categories/${categoryId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreateCategoryInput, CreateCategoryResponse } from \"../index\";\n\nexport async function createCategory(\n core: CoreClient,\n storeId: string,\n input: CreateCategoryInput,\n): Promise<CreateCategoryResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.post<CreateCategoryResponse>(\n `/stores/${storeId}/categories`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { UpdateCategoryInput, UpdateCategoryResponse } from \"../index\";\n\nexport async function updateCategory(\n core: CoreClient,\n storeId: string,\n categoryId: string,\n input: UpdateCategoryInput,\n): Promise<UpdateCategoryResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<UpdateCategoryResponse>(\n `/stores/${storeId}/categories/${categoryId}`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { ReorderCategoriesResponse } from \"../index\";\n\nexport async function reorderCategories(\n core: CoreClient,\n storeId: string,\n categoryIds: string[],\n): Promise<ReorderCategoriesResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<ReorderCategoriesResponse>(\n `/stores/${storeId}/categories/reorder`,\n { categoryIds },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deleteCategory } from \"./http/delete\";\nimport { getCategories } from \"./http/get\";\nimport { getCategoryById } from \"./http/get-by-id\";\nimport { createCategory } from \"./http/post\";\nimport { updateCategory } from \"./http/put\";\nimport { reorderCategories } from \"./http/reorder\";\n\nexport type Category = {\n id: string;\n name: string;\n description: string | null;\n image: string | null;\n metadata: Record<string, unknown> | null;\n position: number;\n storeId: string;\n createdAt: string;\n updatedAt: string;\n};\n\nexport type CategoryDetails = Category & {\n products?: unknown[];\n coupons?: unknown[];\n};\n\nexport type Pagination = {\n page: number;\n limit: number;\n total: number;\n totalPages: number;\n};\n\nexport type GetCategoriesInput = {\n page?: number;\n limit?: number;\n};\n\nexport type CreateCategoryInput = {\n name?: string;\n description?: string | null;\n image?: string | null;\n metadata?: Record<string, unknown> | null;\n};\n\nexport type UpdateCategoryInput = {\n name?: string;\n description?: string | null;\n image?: string | null;\n metadata?: Record<string, unknown> | null;\n position?: number;\n};\n\nexport type GetCategoriesResponse = {\n status: boolean;\n code: string;\n categories: Category[];\n pagination: Pagination;\n};\n\nexport type GetCategoryByIdResponse = {\n status: boolean;\n code: string;\n category: CategoryDetails;\n};\n\nexport type CreateCategoryResponse = {\n status: boolean;\n code?: string;\n category: Category;\n};\n\nexport type UpdateCategoryResponse = {\n status: boolean;\n code: string;\n category: Category;\n};\n\nexport type DeleteCategoryResponse = {\n status: boolean;\n code: string;\n};\n\nexport type ReorderCategoriesResponse = {\n status: boolean;\n code: string;\n};\n\nexport class Categories {\n constructor(private core: CoreClient) {}\n\n get(storeId: string, input: GetCategoriesInput = {}) {\n return getCategories(this.core, storeId, input);\n }\n\n getById(storeId: string, categoryId: string) {\n return getCategoryById(this.core, storeId, categoryId);\n }\n\n post(storeId: string, input: CreateCategoryInput) {\n return createCategory(this.core, storeId, input);\n }\n\n put(storeId: string, categoryId: string, input: UpdateCategoryInput) {\n return updateCategory(this.core, storeId, categoryId, input);\n }\n\n delete(storeId: string, categoryId: string) {\n return deleteCategory(this.core, storeId, categoryId);\n }\n\n reorder(storeId: string, categoryIds: string[]) {\n return reorderCategories(this.core, storeId, categoryIds);\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeleteCouponResponse } from \"../index\";\n\nexport async function deleteCoupon(\n core: CoreClient,\n storeId: string,\n couponId: string,\n): Promise<DeleteCouponResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeleteCouponResponse>(\n `/stores/${storeId}/coupons/${couponId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetCouponsInput, GetCouponsResponse } from \"../index\";\n\nexport async function getCoupons(\n core: CoreClient,\n storeId: string,\n input: GetCouponsInput = {},\n): Promise<GetCouponsResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetCouponsResponse>(\n `/stores/${storeId}/coupons`,\n {\n params: {\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetCouponByCodeResponse } from \"../index\";\n\nexport async function getCouponByCode(\n core: CoreClient,\n storeId: string,\n code: string,\n): Promise<GetCouponByCodeResponse> {\n const { data } = await core.http.get<GetCouponByCodeResponse>(\n `/stores/${storeId}/coupons/${code}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetCouponByIdResponse } from \"../index\";\n\nexport async function getCouponById(\n core: CoreClient,\n storeId: string,\n couponId: string,\n): Promise<GetCouponByIdResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetCouponByIdResponse>(\n `/stores/${storeId}/coupons/uuid/${couponId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreateCouponInput, CreateCouponResponse } from \"../index\";\n\nexport async function createCoupon(\n core: CoreClient,\n storeId: string,\n input: CreateCouponInput,\n): Promise<CreateCouponResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.post<CreateCouponResponse>(\n `/stores/${storeId}/coupons`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { UpdateCouponInput, UpdateCouponResponse } from \"../index\";\n\nexport async function updateCoupon(\n core: CoreClient,\n storeId: string,\n couponId: string,\n input: UpdateCouponInput,\n): Promise<UpdateCouponResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<UpdateCouponResponse>(\n `/stores/${storeId}/coupons/${couponId}`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { ReorderCouponsResponse } from \"../index\";\n\nexport async function reorderCoupons(\n core: CoreClient,\n storeId: string,\n couponIds: string[],\n): Promise<ReorderCouponsResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<ReorderCouponsResponse>(\n `/stores/${storeId}/coupons/reorder`,\n { couponIds },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deleteCoupon } from \"./http/delete\";\nimport { getCoupons } from \"./http/get\";\nimport { getCouponByCode } from \"./http/get-by-code\";\nimport { getCouponById } from \"./http/get-by-id\";\nimport { createCoupon } from \"./http/post\";\nimport { updateCoupon } from \"./http/put\";\nimport { reorderCoupons } from \"./http/reorder\";\n\nexport type CouponRelationRef = {\n id: string;\n name: string;\n};\n\nexport type Coupon = {\n id: string;\n code: string;\n position: number;\n discount: number;\n useLimit: number;\n expiredAt: string | null;\n storeId?: string;\n products: CouponRelationRef[];\n categories: CouponRelationRef[];\n createdAt?: string;\n updatedAt?: string;\n};\n\nexport type Pagination = {\n page: number;\n limit: number;\n total: number;\n totalPages: number;\n};\n\nexport type GetCouponsInput = {\n page?: number;\n limit?: number;\n};\n\nexport type CreateCouponInput = {\n code: string;\n discount: number;\n useLimit?: number | null;\n expiredAt?: string | null;\n productIds?: string[];\n categoryIds?: string[];\n};\n\nexport type UpdateCouponInput = {\n code?: string;\n discount?: number;\n position?: number;\n useLimit?: number | null;\n expiredAt?: string | null;\n productIds?: string[];\n categoryIds?: string[];\n};\n\nexport type GetCouponsResponse = {\n status: boolean;\n code: string;\n coupons: Coupon[];\n pagination: Pagination;\n};\n\nexport type GetCouponByCodeResponse = {\n status: boolean;\n code: string;\n coupon: Coupon;\n};\n\nexport type GetCouponByIdResponse = {\n status: boolean;\n code: string;\n coupon: Coupon;\n};\n\nexport type CreateCouponResponse = {\n status: boolean;\n code: string;\n coupon: Coupon;\n};\n\nexport type UpdateCouponResponse = {\n status: boolean;\n code: string;\n coupon: Coupon;\n};\n\nexport type DeleteCouponResponse = {\n status: boolean;\n code: string;\n};\n\nexport type ReorderCouponsResponse = {\n status: boolean;\n code: string;\n};\n\nexport class Coupons {\n constructor(private core: CoreClient) {}\n\n get(storeId: string, input: GetCouponsInput = {}) {\n return getCoupons(this.core, storeId, input);\n }\n\n getByCode(storeId: string, code: string) {\n return getCouponByCode(this.core, storeId, code);\n }\n\n getById(storeId: string, couponId: string) {\n return getCouponById(this.core, storeId, couponId);\n }\n\n post(storeId: string, input: CreateCouponInput) {\n return createCoupon(this.core, storeId, input);\n }\n\n put(storeId: string, couponId: string, input: UpdateCouponInput) {\n return updateCoupon(this.core, storeId, couponId, input);\n }\n\n delete(storeId: string, couponId: string) {\n return deleteCoupon(this.core, storeId, couponId);\n }\n\n reorder(storeId: string, couponIds: string[]) {\n return reorderCoupons(this.core, storeId, couponIds);\n }\n}\n","import type { CoreClient } from \"../../../client\";\n\n/**\n * Resposta do endpoint de exclusão de página.\n */\ntype DeletePageResponse = {\n status: boolean;\n code: string;\n};\n\n/**\n * Remove a página publicada referente ao `domain` informado.\n *\n * Executa uma requisição `DELETE /pages/:domain`. Este endpoint é privado e\n * exige que o `CoreClient` esteja configurado em modo privado (backend).\n *\n * @param core - Instância do `CoreClient` (deve ser private).\n * @param domain - Domínio da página a remover (ex.: \"minhaloja.com.br\").\n * @returns Promise que resolve com `{ status, code }` retornado pela API.\n *\n * @throws {Error} Se `core.isPrivate()` for falso (tentativa de uso no navegador)\n * ou se a API retornar erro/HTTP failure.\n *\n * @example\n * ```ts\n * await deletePage(coreClient, \"loja.exemplo.com\");\n * ```\n */\nexport async function deletePage(\n core: CoreClient,\n domain: string,\n): Promise<{ status: boolean; code: string }> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeletePageResponse>(\n `/pages/${domain}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\n\n/**\n * Modelo de página retornado pela API de páginas.\n *\n * Observações:\n * - Campos `createdAt` e `updatedAt` são timestamps em ISO 8601.\n * - `version` pode ser usada pelo servidor para controle de versão do conteúdo.\n * - `store` é metadado opcional com informações da loja proprietária.\n */\nexport type Page = {\n html: string;\n template?: string;\n version?: string;\n createdAt?: string;\n updatedAt?: string;\n store?: {\n ownerId: string;\n id: string;\n };\n};\n\n/**\n * Estrutura padrão da resposta da API para operações de página.\n */\ntype PageResponse = {\n status: boolean;\n data: Page;\n};\n\n/**\n * Recupera a `Page` publicada para o `domain` informado.\n *\n * Faz uma chamada `GET /pages/:domain` usando o `CoreClient` fornecido.\n *\n * @param core - Instância de `CoreClient` que executa requisições HTTP.\n * @param domain - Domínio da página a ser recuperada (ex.: \"minha-loja.com\").\n * @returns Promise que resolve com um objeto contendo `status` e `data` (`Page`).\n *\n * @throws {Error} Se a resposta não contiver `data` (página não encontrada) ou se\n * houver erro de rede/HTTP lançado pelo `core.http`.\n *\n * @example\n * ```ts\n * const page = await getPage(coreClient, \"loja.exemplo.com\");\n * console.log(page.data.html);\n * ```\n */\nexport async function getPage(\n core: CoreClient,\n domain: string,\n): Promise<{ status: boolean; data: Page }> {\n const { data } = await core.http.get<PageResponse>(`/pages/${domain}`);\n\n if (!data?.data) {\n throw new Error(`Page not found: ${domain}`);\n }\n\n return {\n status: data.status,\n data: data.data,\n };\n}\n","import type { CoreClient } from \"../../../client\";\n\n/**\n * Dados necessários para criar ou atualizar uma página.\n */\nexport type PageUpsertInput = {\n domain: string;\n html: string;\n template?: string;\n};\n\n/**\n * Resposta do endpoint de upsert.\n */\ntype PageUpsertResponse = {\n status: boolean;\n code: string;\n};\n\n/**\n * Cria ou atualiza a página pública associada ao `input.domain`.\n *\n * Realiza uma requisição `PUT /pages/:domain` com o corpo contendo `html` e\n * `template` (se fornecido). Este endpoint é marcado como privado — deve ser\n * usado apenas por código backend que possua credenciais privadas.\n *\n * @param core - `CoreClient` configurado (deve estar em modo privado).\n * @param input - Dados da página a persistir: `domain`, `html`, `template?`.\n * @returns Promise que resolve com o objeto de resposta `{ status, code }`.\n *\n * @throws {Error} Se `core.isPrivate()` for falso (uso no navegador) ou se a\n * requisição HTTP falhar.\n *\n * @example\n * ```ts\n * await upsertPage(coreClient, {\n * domain: \"loja.exemplo.com\",\n * html: \"<html>...\",\n * template: \"landing-v2\",\n * });\n * ```\n */\nexport async function upsertPage(\n core: CoreClient,\n input: PageUpsertInput,\n): Promise<{ status: boolean; code: string }> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<PageUpsertResponse>(\n `/pages/${input.domain}`,\n {\n html: input.html,\n template: input.template,\n },\n );\n\n return data;\n}\n","/**\n * Módulo `Pages` — cliente de operação para páginas estáticas.\n *\n * Fornece wrappers de alto nível para recuperar, criar/atualizar e remover\n * representações HTML de páginas hospedadas em um domínio específico. Cada\n * operação delega a chamada HTTP para funções em `./http/*` e propaga erros\n * retornados pelo cliente HTTP subjacente.\n *\n */\nimport type { CoreClient } from \"../../client\";\nimport { deletePage } from \"./http/delete\";\nimport { getPage } from \"./http/get\";\nimport { upsertPage } from \"./http/upsert\";\n\n/**\n * Representa uma página\n */\n/**\n * Representa uma página estática gerida pela API.\n *\n * Propriedades:\n * - `domain`: Identificador único da página. Geralmente host ou host+path.\n * - `html`: Conteúdo HTML completo que será servido para esse domínio.\n * - `template`: (opcional) nome do template ou layout que o servidor pode aplicar.\n *\n * ```\n */\nexport type Page = {\n domain: string;\n html: string;\n template?: string;\n};\n\n/**\n * Client de alto nível para operações relacionadas a `Page`.\n *\n * Instancie com um `CoreClient` já autenticado/configurado. Os métodos desta\n * classe são pequenos wrappers que delegam a execução para as funções HTTP\n * específicas em `./http/*`, mantendo a assinatura orientada ao domínio.\n */\nexport class Pages {\n /**\n * Construtor.\n * @param core - Instância de `CoreClient` usada para efetuar chamadas HTTP.\n */\n constructor(private core: CoreClient) {}\n\n /**\n * Recupera a página associada ao `domain` informado.\n *\n * @param domain - Identificador da página a recuperar (ex.: \"exemplo.com\").\n * @returns Uma promise que resolve com o objeto `Page` caso exista.\n * @throws Erros de rede/HTTP ou erro retornado pela API se a página não existir.\n *\n */\n get(domain: string) {\n return getPage(this.core, domain);\n }\n\n /**\n * Cria ou atualiza uma página.\n *\n * Se a página para o `domain` já existir, o servidor realizará um update;\n * caso contrário, criará uma nova entrada.\n *\n * @param input - Objeto com os dados da página:\n * - `domain`: chave única da página.\n * - `html`: conteúdo HTML completo.\n * - `template` (opcional): nome do template a aplicar.\n * @returns Uma promise que resolve com o `Page` criado/atualizado ou com metadados retornados pela API.\n * @throws Erros de validação, rede ou HTTP conforme a resposta da API.\n *\n */\n upsert(input: { domain: string; html: string; template?: string }) {\n return upsertPage(this.core, input);\n }\n\n /**\n * Remove a página associada ao `domain`.\n *\n * @param domain - Identificador da página a remover.\n * @returns Uma promise que resolve quando a exclusão for confirmada pelo servidor.\n * @throws Erro se a operação falhar (por exemplo, página não encontrada ou erro de permissão).\n *\n */\n delete(domain: string) {\n return deletePage(this.core, domain);\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeletePaymentResponse } from \"../index\";\n\nexport async function deletePayment(\n core: CoreClient,\n storeId: string,\n paymentId: string,\n): Promise<DeletePaymentResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeletePaymentResponse>(\n `/stores/${storeId}/payments/${paymentId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { FilterPaymentsInput, FilterPaymentsResponse } from \"../index\";\n\nexport async function filterPayments(\n core: CoreClient,\n storeId: string,\n input: FilterPaymentsInput = {},\n): Promise<FilterPaymentsResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<FilterPaymentsResponse>(\n `/stores/${storeId}/payments/filter`,\n {\n params: {\n id: input.id,\n uuid: input.uuid,\n status: input.status,\n name: input.name,\n email: input.email,\n cpf: input.cpf,\n price: input.price,\n minPrice: input.minPrice,\n maxPrice: input.maxPrice,\n coupon: input.coupon,\n gateway: input.gateway,\n shipment: input.shipment,\n createdAtFrom: input.createdAtFrom,\n createdAtTo: input.createdAtTo,\n updatedAtFrom: input.updatedAtFrom,\n updatedAtTo: input.updatedAtTo,\n productId: input.productId,\n metadataKey: input.metadataKey,\n metadataValue: input.metadataValue,\n sortBy: input.sortBy,\n sortOrder: input.sortOrder,\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetPaymentsInput, GetPaymentsResponse } from \"../index\";\n\nexport async function getPayments(\n core: CoreClient,\n storeId: string,\n input: GetPaymentsInput = {},\n): Promise<GetPaymentsResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetPaymentsResponse>(\n `/stores/${storeId}/payments`,\n {\n params: {\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreatePaymentInput, CreatePaymentResponse } from \"../index\";\n\nexport async function createPayment(\n core: CoreClient,\n storeId: string,\n input: CreatePaymentInput,\n): Promise<CreatePaymentResponse> {\n const { data } = await core.http.post<CreatePaymentResponse>(\n `/stores/${storeId}/payments`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { UpdatePaymentInput, UpdatePaymentResponse } from \"../index\";\n\nexport async function updatePayment(\n core: CoreClient,\n storeId: string,\n paymentId: string,\n input: UpdatePaymentInput,\n): Promise<UpdatePaymentResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<UpdatePaymentResponse>(\n `/stores/${storeId}/payments/${paymentId}`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deletePayment } from \"./http/delete\";\nimport { filterPayments } from \"./http/filter\";\nimport { getPayments } from \"./http/get\";\nimport { createPayment } from \"./http/post\";\nimport { updatePayment } from \"./http/put\";\n\nexport type PaymentStatus =\n | \"PENDING\"\n | \"APPROVED\"\n | \"REJECTED\"\n | \"CANCELLED\"\n | \"REFUNDED\"\n | \"CHARGED_BACK\"\n | \"EXPIRED\";\n\nexport type PaymentGateway = \"MERCADOPAGO\" | \"EFI_BANK\";\nexport type PaymentCreateGateway =\n | \"MERCADOPAGO_SERVICE_PIX\"\n | \"MERCADOPAGO_SERVICE_CARD\";\n\nexport type PaymentShipmentStatus =\n | \"PENDING\"\n | \"PREPARING\"\n | \"SHIPPED\"\n | \"DELIVERED\"\n | \"RETURNED\"\n | \"CANCELLED\";\n\nexport type PaymentSortBy =\n | \"createdAt\"\n | \"updatedAt\"\n | \"price\"\n | \"name\"\n | \"email\";\nexport type PaymentSortOrder = \"asc\" | \"desc\";\n\nexport type Payment = {\n id: string;\n uuid: string;\n status: PaymentStatus;\n name?: string;\n email?: string;\n cpf?: string | null;\n price?: number;\n gateway?: PaymentGateway;\n shipment?: PaymentShipmentStatus;\n storeId: string;\n metadata?: Record<string, unknown> | null;\n};\n\nexport type Pagination = {\n page: number;\n limit: number;\n total: number;\n totalPages: number;\n};\n\nexport type FilterPaymentsInput = {\n id?: string;\n uuid?: string;\n status?: PaymentStatus;\n name?: string;\n email?: string;\n cpf?: string;\n price?: number;\n minPrice?: number;\n maxPrice?: number;\n coupon?: boolean;\n gateway?: PaymentGateway;\n shipment?: PaymentShipmentStatus;\n createdAtFrom?: string;\n createdAtTo?: string;\n updatedAtFrom?: string;\n updatedAtTo?: string;\n productId?: string;\n metadataKey?: string;\n metadataValue?: string;\n sortBy?: PaymentSortBy;\n sortOrder?: PaymentSortOrder;\n page?: number;\n limit?: number;\n};\n\nexport type FilterPaymentsResponse = {\n status: boolean;\n code: string;\n payments: Payment[];\n pagination: Pagination;\n};\n\nexport type GetPaymentsInput = {\n page?: number;\n limit?: number;\n};\n\nexport type GetPaymentsResponse = {\n status: boolean;\n code: string;\n payments: Payment[];\n pagination: Pagination;\n};\n\nexport type CreatePaymentItemInput = {\n productId: string;\n quantity: number;\n};\n\nexport type CreatePaymentInput = {\n name: string;\n email: string;\n cpf?: string;\n gateway: PaymentCreateGateway;\n coupon?: string | null;\n metadata?: Record<string, unknown>;\n items: CreatePaymentItemInput[];\n};\n\nexport type CreatePaymentResponse = {\n status: boolean;\n data: {\n service: {\n type: string;\n method: string;\n payment: string;\n };\n payment: {\n uuid: string;\n url?: string;\n qr_code?: {\n image: string;\n base_64: string;\n };\n };\n };\n};\n\nexport type UpdatePaymentInput = {\n shipment?: PaymentShipmentStatus;\n metadata?: Record<string, unknown>;\n};\n\nexport type UpdatePaymentResponse = {\n status: boolean;\n code: string;\n payment: {\n id: string;\n status: PaymentStatus;\n shipment?: PaymentShipmentStatus;\n metadata?: Record<string, unknown> | null;\n };\n};\n\nexport type DeletePaymentResponse = {\n status: boolean;\n code: string;\n message: string;\n};\n\nexport class Payments {\n constructor(private core: CoreClient) {}\n\n get(storeId: string, input: GetPaymentsInput = {}) {\n return getPayments(this.core, storeId, input);\n }\n\n filter(storeId: string, input: FilterPaymentsInput = {}) {\n return filterPayments(this.core, storeId, input);\n }\n\n post(storeId: string, input: CreatePaymentInput) {\n return createPayment(this.core, storeId, input);\n }\n\n put(storeId: string, paymentId: string, input: UpdatePaymentInput) {\n return updatePayment(this.core, storeId, paymentId, input);\n }\n\n delete(storeId: string, paymentId: string) {\n return deletePayment(this.core, storeId, paymentId);\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeleteProductResponse } from \"../index\";\n\nexport async function deleteProduct(\n core: CoreClient,\n storeId: string,\n productId: string,\n): Promise<DeleteProductResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeleteProductResponse>(\n `/stores/${storeId}/products/${productId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetProductsInput, GetProductsResponse } from \"../index\";\n\nexport async function getProducts(\n core: CoreClient,\n storeId: string,\n input: GetProductsInput = {},\n): Promise<GetProductsResponse> {\n const { data } = await core.http.get<GetProductsResponse>(\n `/stores/${storeId}/products`,\n {\n params: {\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetProductByIdResponse } from \"../index\";\n\nexport async function getProductById(\n core: CoreClient,\n storeId: string,\n productId: string,\n): Promise<GetProductByIdResponse> {\n const { data } = await core.http.get<GetProductByIdResponse>(\n `/stores/${storeId}/products/${productId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreateProductInput, CreateProductResponse } from \"../index\";\n\nexport async function createProduct(\n core: CoreClient,\n storeId: string,\n input: CreateProductInput,\n): Promise<CreateProductResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.post<CreateProductResponse>(\n `/stores/${storeId}/products`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { UpdateProductInput, UpdateProductResponse } from \"../index\";\n\nexport async function updateProduct(\n core: CoreClient,\n storeId: string,\n productId: string,\n input: UpdateProductInput,\n): Promise<UpdateProductResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<UpdateProductResponse>(\n `/stores/${storeId}/products/${productId}`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { ReorderProductsResponse } from \"../index\";\n\nexport async function reorderProducts(\n core: CoreClient,\n storeId: string,\n productIds: string[],\n): Promise<ReorderProductsResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<ReorderProductsResponse>(\n `/stores/${storeId}/products/reorder`,\n { productIds },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deleteProduct } from \"./http/delete\";\nimport { getProducts } from \"./http/get\";\nimport { getProductById } from \"./http/get-by-id\";\nimport { createProduct } from \"./http/post\";\nimport { updateProduct } from \"./http/put\";\nimport { reorderProducts } from \"./http/reorder\";\n\nexport type ProductDelivery = \"DIGITAL\" | \"PHYSICAL\";\n\nexport type ProductCategoryRef = {\n id: string;\n name: string;\n};\n\nexport type Product = {\n id: string;\n name: string;\n disabled: boolean;\n position: number;\n description: string | null;\n price: number;\n image: string | null;\n delivery: ProductDelivery;\n stock: number;\n sold: number;\n storeId: string;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n categories?: ProductCategoryRef[];\n};\n\nexport type Pagination = {\n page: number;\n limit: number;\n total: number;\n totalPages: number;\n};\n\nexport type GetProductsInput = {\n page?: number;\n limit?: number;\n};\n\nexport type CreateProductInput = {\n name: string;\n image?: string | null;\n description?: string | null;\n categoryIds?: string[];\n delivery: ProductDelivery;\n price: number;\n stock?: number;\n disabled?: boolean;\n metadata?: Record<string, unknown> | null;\n};\n\nexport type UpdateProductInput = {\n name?: string;\n image?: string | null;\n description?: string | null;\n categoryIds?: string[];\n delivery?: ProductDelivery;\n price?: number;\n stock?: number;\n disabled?: boolean;\n position?: number;\n metadata?: Record<string, unknown> | null;\n};\n\nexport type GetProductsResponse = {\n status: boolean;\n code: string;\n products: Product[];\n pagination: Pagination;\n};\n\nexport type GetProductByIdResponse = {\n status: boolean;\n code: string;\n product: Product;\n};\n\nexport type CreateProductResponse = {\n status: boolean;\n code: string;\n product: Product;\n};\n\nexport type UpdateProductResponse = {\n status: boolean;\n code: string;\n product: Product;\n};\n\nexport type DeleteProductResponse = {\n status: boolean;\n code: string;\n};\n\nexport type ReorderProductsResponse = {\n status: boolean;\n code: string;\n};\n\nexport class Products {\n constructor(private core: CoreClient) {}\n\n get(storeId: string, input: GetProductsInput = {}) {\n return getProducts(this.core, storeId, input);\n }\n\n getById(storeId: string, productId: string) {\n return getProductById(this.core, storeId, productId);\n }\n\n post(storeId: string, input: CreateProductInput) {\n return createProduct(this.core, storeId, input);\n }\n\n put(storeId: string, productId: string, input: UpdateProductInput) {\n return updateProduct(this.core, storeId, productId, input);\n }\n\n delete(storeId: string, productId: string) {\n return deleteProduct(this.core, storeId, productId);\n }\n\n reorder(storeId: string, productIds: string[]) {\n return reorderProducts(this.core, storeId, productIds);\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeleteStoreResponse } from \"../index\";\n\nexport async function deleteStore(\n core: CoreClient,\n storeId: string,\n): Promise<DeleteStoreResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeleteStoreResponse>(\n `/stores/${storeId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetStoresInput, GetStoresResponse } from \"../index\";\n\nexport async function getStores(\n core: CoreClient,\n input: GetStoresInput = {},\n): Promise<GetStoresResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetStoresResponse>(\"/stores\", {\n params: {\n page: input.page,\n limit: input.limit,\n },\n });\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetStoreByIdResponse } from \"../index\";\n\nexport async function getStoreById(\n core: CoreClient,\n storeId: string,\n): Promise<GetStoreByIdResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetStoreByIdResponse>(\n `/stores/${storeId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreateStoreInput, CreateStoreResponse } from \"../index\";\n\nexport async function createStore(\n core: CoreClient,\n input: CreateStoreInput,\n): Promise<CreateStoreResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.post<CreateStoreResponse>(\"/stores\", input);\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { UpdateStoreInput, UpdateStoreResponse } from \"../index\";\n\nexport async function updateStore(\n core: CoreClient,\n storeId: string,\n input: UpdateStoreInput,\n): Promise<UpdateStoreResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<UpdateStoreResponse>(\n `/stores/${storeId}`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { ReorderStoresResponse } from \"../index\";\n\nexport async function reorderStores(\n core: CoreClient,\n storeIds: string[],\n): Promise<ReorderStoresResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<ReorderStoresResponse>(\n \"/stores/reorder\",\n { storeIds },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deleteStore } from \"./http/delete\";\nimport { getStores } from \"./http/get\";\nimport { getStoreById } from \"./http/get-by-id\";\nimport { createStore } from \"./http/post\";\nimport { updateStore } from \"./http/put\";\nimport { reorderStores } from \"./http/reorder\";\n\n/**\n * Templates válidos para loja.\n */\nexport type StoreTemplate = \"PERSONALIZADO\" | \"N/A\";\n\n/**\n * Tipo do domínio informado no payload da loja.\n */\nexport type StoreDomainType = \"CUSTOM\" | \"DEFAULT\";\n\n/**\n * Estrutura de domínio para criação/atualização.\n */\nexport type StoreDomainInput = {\n type: StoreDomainType;\n value: string;\n};\n\n/**\n * Modelo base de loja retornado nos endpoints de listagem e upsert.\n */\nexport type Store = {\n id: string;\n name: string;\n position: number;\n description: string | null;\n image: string | null;\n domain: string;\n template: StoreTemplate;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n};\n\n/**\n * Modelo detalhado retornado por `GET /stores/:storeId`.\n */\nexport type StoreDetails = Store & {\n ownerId?: string;\n deletedAt?: string | null;\n categories?: unknown[];\n products?: unknown[];\n coupons?: unknown[];\n payment?: unknown[];\n};\n\n/**\n * Metadados de paginação padrão da API.\n */\nexport type Pagination = {\n page: number;\n limit: number;\n total: number;\n totalPages: number;\n};\n\n/**\n * Query params de listagem de lojas.\n */\nexport type GetStoresInput = {\n page?: number;\n limit?: number;\n};\n\n/**\n * Payload para criação de loja (`POST /stores`).\n */\nexport type CreateStoreInput = {\n template: StoreTemplate;\n name?: string;\n description?: string | null;\n image?: string | null;\n metadata?: Record<string, unknown> | null;\n domain?: StoreDomainInput | null;\n position?: number;\n};\n\n/**\n * Payload para atualização de loja (`PUT /stores/:storeId`).\n *\n * Observação: no endpoint de update, todos os campos são opcionais,\n * mas a API exige ao menos 1 campo no body.\n */\nexport type UpdateStoreInput = {\n template?: StoreTemplate;\n name?: string;\n description?: string | null;\n image?: string | null;\n metadata?: Record<string, unknown> | null;\n domain?: StoreDomainInput | null;\n position?: number;\n};\n\n/**\n * Resposta de listagem de lojas.\n */\nexport type GetStoresResponse = {\n status: boolean;\n code: string;\n stores: Store[];\n pagination: Pagination;\n};\n\n/**\n * Resposta de consulta por ID.\n */\nexport type GetStoreByIdResponse = {\n status: boolean;\n code: string;\n store: StoreDetails;\n};\n\n/**\n * Resposta de criação.\n */\nexport type CreateStoreResponse = {\n status: boolean;\n code: string;\n store: Store;\n};\n\n/**\n * Resposta de atualização.\n */\nexport type UpdateStoreResponse = {\n status: boolean;\n code: string;\n store: Store;\n};\n\n/**\n * Resposta de exclusão.\n */\nexport type DeleteStoreResponse = {\n status: boolean;\n code: string;\n};\n\n/**\n * Resposta de reordenação.\n */\nexport type ReorderStoresResponse = {\n status: boolean;\n code: string;\n};\n\n/**\n * Cliente de alto nível para operações do módulo de lojas.\n */\nexport class Stores {\n /**\n * @param core Cliente base da SDK.\n */\n constructor(private core: CoreClient) {}\n\n /**\n * Lista lojas da conta com suporte a paginação.\n */\n get(input: GetStoresInput = {}) {\n return getStores(this.core, input);\n }\n\n /**\n * Busca uma loja pelo ID.\n */\n getById(storeId: string) {\n return getStoreById(this.core, storeId);\n }\n\n /**\n * Cria uma nova loja.\n */\n post(input: CreateStoreInput) {\n return createStore(this.core, input);\n }\n\n /**\n * Atualiza uma loja existente.\n */\n put(storeId: string, input: UpdateStoreInput) {\n return updateStore(this.core, storeId, input);\n }\n\n /**\n * Exclui uma loja pelo ID.\n */\n delete(storeId: string) {\n return deleteStore(this.core, storeId);\n }\n\n /**\n * Reordena lojas pelo array final de IDs.\n */\n reorder(storeIds: string[]) {\n return reorderStores(this.core, storeIds);\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeleteWebhookInput, DeleteWebhookResponse } from \"../index\";\n\nexport async function deleteWebhook(\n core: CoreClient,\n storeId: string,\n input: DeleteWebhookInput,\n): Promise<DeleteWebhookResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeleteWebhookResponse>(\n `/stores/${storeId}/webhooks`,\n {\n data: input,\n },\n );\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetWebhooksResponse } from \"../index\";\n\nexport async function getWebhooks(\n core: CoreClient,\n storeId: string,\n): Promise<GetWebhooksResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetWebhooksResponse>(\n `/stores/${storeId}/webhooks`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreateWebhookInput, CreateWebhookResponse } from \"../index\";\n\nexport async function createWebhook(\n core: CoreClient,\n storeId: string,\n input: CreateWebhookInput,\n): Promise<CreateWebhookResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.post<CreateWebhookResponse>(\n `/stores/${storeId}/webhooks`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deleteWebhook } from \"./http/delete\";\nimport { getWebhooks } from \"./http/get\";\nimport { createWebhook } from \"./http/post\";\n\n/**\n * Resposta de listagem de webhooks por loja.\n */\nexport type GetWebhooksResponse = {\n webhooks: string[];\n max: number;\n};\n\n/**\n * Payload para criar webhook em uma loja.\n */\nexport type CreateWebhookInput = {\n url: string;\n};\n\n/**\n * Resposta de criação de webhook.\n */\nexport type CreateWebhookResponse = {\n status: boolean;\n code: string;\n webhook: string;\n};\n\n/**\n * Payload para remover webhook de uma loja.\n */\nexport type DeleteWebhookInput = {\n url: string;\n};\n\n/**\n * Resposta de remoção de webhook.\n */\nexport type DeleteWebhookResponse = {\n status: boolean;\n code: string;\n};\n\n/**\n * Cliente de alto nível para operações de webhooks da loja.\n */\nexport class Webhooks {\n /**\n * @param core Cliente base da SDK.\n */\n constructor(private core: CoreClient) {}\n\n /**\n * Lista os webhooks cadastrados para uma loja.\n */\n get(storeId: string) {\n return getWebhooks(this.core, storeId);\n }\n\n /**\n * Adiciona um webhook em uma loja.\n */\n post(storeId: string, input: CreateWebhookInput) {\n return createWebhook(this.core, storeId, input);\n }\n\n /**\n * Remove um webhook de uma loja.\n */\n delete(storeId: string, input: DeleteWebhookInput) {\n return deleteWebhook(this.core, storeId, input);\n }\n\n /**\n * Descriptografa e valida o payload recebido no webhook de assinatura.\n *\n * Espera um payload no formato `iv:encrypted` (ambos em base64), criptografado\n * com AES-256-CBC usando a chave informada.\n */\n async decrypty(\n secret: string,\n payload: string,\n ): Promise<Record<string, unknown>> {\n if (!secret) {\n throw new Error(\"SECRET_KEY_REQUIRED\");\n }\n\n if (!payload || typeof payload !== \"string\") {\n throw new Error(\"INVALID_PAYLOAD_FORMAT\");\n }\n\n const [ivB64, encrypted] = payload.split(\":\");\n if (!ivB64 || !encrypted) {\n throw new Error(\"INVALID_PAYLOAD_FORMAT\");\n }\n\n const iv = base64ToBytes(ivB64);\n const encryptedBytes = base64ToBytes(encrypted);\n const secretBytes = new TextEncoder().encode(secret);\n\n const keyHash = await globalThis.crypto.subtle.digest(\n \"SHA-256\",\n secretBytes,\n );\n const cryptoKey = await globalThis.crypto.subtle.importKey(\n \"raw\",\n keyHash,\n { name: \"AES-CBC\" },\n false,\n [\"decrypt\"],\n );\n const decryptedBuffer = await globalThis.crypto.subtle.decrypt(\n { name: \"AES-CBC\", iv: toArrayBuffer(iv) },\n cryptoKey,\n toArrayBuffer(encryptedBytes),\n );\n const decrypted = new TextDecoder().decode(decryptedBuffer);\n\n return JSON.parse(decrypted) as Record<string, unknown>;\n }\n\n /**\n * Alias com nome corrigido para descriptografar payload de webhook.\n */\n async decrypt(\n secret: string,\n payload: string,\n ): Promise<Record<string, unknown>> {\n return this.decrypty(secret, payload);\n }\n\n /**\n * Alias retrocompatível para quem já usa `parseSubscriptionPayload`.\n */\n async parseSubscriptionPayload(\n payload: string,\n secret: string,\n ): Promise<Record<string, unknown>> {\n return this.decrypty(secret, payload);\n }\n}\n\nfunction base64ToBytes(base64: string): Uint8Array {\n const binary = atob(base64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i += 1) {\n bytes[i] = binary.charCodeAt(i);\n }\n return bytes;\n}\n\nfunction toArrayBuffer(bytes: Uint8Array): ArrayBuffer {\n return bytes.buffer.slice(\n bytes.byteOffset,\n bytes.byteOffset + bytes.byteLength,\n ) as ArrayBuffer;\n}\n","import { type ClientOptions, CoreClient } from \"./core/client\";\nimport { Categories } from \"./core/module/categories/index\";\nimport { Coupons } from \"./core/module/coupons/index\";\nimport { Pages } from \"./core/module/pages/index\";\nimport { Payments } from \"./core/module/payments/index\";\nimport { Products } from \"./core/module/products/index\";\nimport { Stores } from \"./core/module/stores/index\";\nimport { Webhooks } from \"./core/module/webhooks/index\";\n\n/**\n * SDK principal da caBRAPI\n */\nexport class caBRAPI {\n public categories: Categories;\n public coupons: Coupons;\n public payments: Payments;\n public pages: Pages;\n public products: Products;\n public stores: Stores;\n public webhooks: Webhooks;\n\n constructor(options: ClientOptions) {\n const core = new CoreClient(options);\n\n this.categories = new Categories(core);\n this.coupons = new Coupons(core);\n this.payments = new Payments(core);\n this.pages = new Pages(core);\n this.products = new Products(core);\n this.stores = new Stores(core);\n this.webhooks = new Webhooks(core);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/core/http.ts","../src/core/client.ts","../src/core/module/categories/http/delete.ts","../src/core/module/categories/http/get.ts","../src/core/module/categories/http/get-by-id.ts","../src/core/module/categories/http/post.ts","../src/core/module/categories/http/put.ts","../src/core/module/categories/http/reorder.ts","../src/core/module/categories/index.ts","../src/core/module/coupons/http/delete.ts","../src/core/module/coupons/http/get.ts","../src/core/module/coupons/http/get-by-code.ts","../src/core/module/coupons/http/get-by-id.ts","../src/core/module/coupons/http/post.ts","../src/core/module/coupons/http/put.ts","../src/core/module/coupons/http/reorder.ts","../src/core/module/coupons/index.ts","../src/core/module/pages/http/delete.ts","../src/core/module/pages/http/get.ts","../src/core/module/pages/http/upsert.ts","../src/core/module/pages/index.ts","../src/core/module/payments/http/delete.ts","../src/core/module/payments/http/filter.ts","../src/core/module/payments/http/get.ts","../src/core/module/payments/http/post.ts","../src/core/module/payments/http/put.ts","../src/core/module/payments/index.ts","../src/core/module/products/http/delete.ts","../src/core/module/products/http/get.ts","../src/core/module/products/http/get-by-category.ts","../src/core/module/products/http/get-by-id.ts","../src/core/module/products/http/post.ts","../src/core/module/products/http/put.ts","../src/core/module/products/http/reorder.ts","../src/core/module/products/index.ts","../src/core/module/stores/http/delete.ts","../src/core/module/stores/http/get.ts","../src/core/module/stores/http/get-by-id.ts","../src/core/module/stores/http/post.ts","../src/core/module/stores/http/put.ts","../src/core/module/stores/http/reorder.ts","../src/core/module/stores/index.ts","../src/core/module/webhooks/http/delete.ts","../src/core/module/webhooks/http/get.ts","../src/core/module/webhooks/http/post.ts","../src/core/module/webhooks/index.ts","../src/index.ts"],"names":["buildURL","base","path","buildQuery","params","esc","query","v","k","createAxios","cfg","baseURL","timeout","requestInterceptors","responseInterceptors","runRequest","config","conf","i","e","url","headers","controller","to","timer","opts","raw","err","text","data","res","fulfilled","rejected","options","isBrowser","CoreClient","apiKey","deleteCategory","core","storeId","categoryId","getCategories","input","getCategoryById","createCategory","updateCategory","reorderCategories","categoryIds","Categories","deleteCoupon","couponId","getCoupons","getCouponByCode","code","getCouponById","createCoupon","updateCoupon","reorderCoupons","couponIds","Coupons","deletePage","domain","getPage","upsertPage","Pages","deletePayment","paymentId","filterPayments","getPayments","createPayment","updatePayment","Payments","deleteProduct","productId","getProducts","getProductsByCategory","getProductById","createProduct","updateProduct","reorderProducts","productIds","Products","deleteStore","getStores","getStoreById","createStore","updateStore","reorderStores","storeIds","Stores","deleteWebhook","getWebhooks","createWebhook","Webhooks","secret","payload","ivB64","encrypted","iv","base64ToBytes","encryptedBytes","secretBytes","keyHash","cryptoKey","decryptedBuffer","toArrayBuffer","decrypted","base64","binary","bytes","caBRAPI"],"mappings":"aA+BA,SAASA,GAASC,CAAAA,CAAcC,CAAAA,CAAc,CAC5C,OAAI,eAAe,IAAA,CAAKA,CAAI,CAAA,CAAUA,CAAAA,CAC/B,GAAGD,CAAAA,CAAK,OAAA,CAAQ,KAAA,CAAO,EAAE,CAAC,CAAA,CAAA,EAAIC,CAAAA,CAAK,OAAA,CAAQ,KAAA,CAAO,EAAE,CAAC,CAAA,CAC9D,CAEA,SAASC,GAAWC,CAAAA,CAAkC,CACpD,GAAI,CAACA,EAAQ,OAAO,EAAA,CACpB,IAAMC,CAAAA,CAAM,kBAAA,CACNC,EAAQ,MAAA,CAAO,OAAA,CAAQF,CAAM,CAAA,CAChC,OAAO,CAAC,EAAGG,CAAC,IAAyBA,CAAAA,EAAM,IAAI,CAAA,CAC/C,GAAA,CAAI,CAAC,CAACC,CAAAA,CAAGD,CAAC,CAAA,GAAM,CAAA,EAAGF,E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,CAAI,EAC7B,IAAA,CAAK,QAAA,CAAW,IAAIuD,CAAAA,CAASvD,CAAI,EACnC,CACF","file":"index.cjs","sourcesContent":["/**\n * Adapter HTTP simples usando fetch (nativo).\n * Exporta `createAxios` para compatibilidade com restante do código.\n */\nexport type AxiosConfig = {\n baseURL?: string;\n apiKey?: string;\n timeout?: number;\n};\n\nexport type AxiosRequestConfig = {\n url?: string;\n params?: Record<string, unknown>;\n headers?: Record<string, string>;\n data?: unknown;\n timeout?: number;\n};\n\nexport type AxiosResponse<T = unknown> = {\n data: T;\n status: number;\n statusText: string;\n headers: Record<string, string>;\n config?: AxiosRequestConfig;\n};\n\ntype Interceptor<V> = {\n fulfilled: (v: V) => V | Promise<V>;\n rejected?: (err: unknown) => unknown;\n};\n\nfunction buildURL(base: string, path: string) {\n if (/^https?:\\/\\//.test(path)) return path;\n return `${base.replace(/\\/$/, \"\")}/${path.replace(/^\\//, \"\")}`;\n}\n\nfunction buildQuery(params?: Record<string, unknown>) {\n if (!params) return \"\";\n const esc = encodeURIComponent;\n const query = Object.entries(params)\n .filter(([, v]) => v !== undefined && v !== null)\n .map(([k, v]) => `${esc(k)}=${esc(String(v))}`)\n .join(\"&\");\n return query ? `?${query}` : \"\";\n}\n\nexport function createAxios(cfg: AxiosConfig = {}) {\n const baseURL = cfg.baseURL ?? \"https://api.cabrapi.com.br\";\n const timeout = cfg.timeout ?? 30000;\n\n const requestInterceptors: Interceptor<AxiosRequestConfig>[] = [];\n const responseInterceptors: Interceptor<AxiosResponse>[] = [];\n\n async function runRequest<T = unknown>(\n config: AxiosRequestConfig & { method: string },\n ): Promise<AxiosResponse<T>> {\n let conf: AxiosRequestConfig = { ...config };\n\n for (const i of requestInterceptors) {\n try {\n // allow interceptor to modify config\n conf = await i.fulfilled(conf);\n } catch (e) {\n if (i.rejected) i.rejected(e);\n throw e;\n }\n }\n\n const url =\n buildURL(baseURL, conf.url ?? \"\") +\n buildQuery(conf.params as Record<string, unknown> | undefined);\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...(conf.headers || {}),\n };\n\n if (cfg.apiKey) headers.Authorization = `${cfg.apiKey}`;\n\n const controller = new AbortController();\n const to = conf.timeout ?? timeout;\n const timer = setTimeout(() => controller.abort(), to);\n\n const opts: RequestInit = {\n method: config.method.toUpperCase(),\n headers,\n signal: controller.signal,\n };\n\n if (conf.data !== undefined && config.method.toLowerCase() !== \"get\") {\n opts.body =\n typeof conf.data === \"string\" ? conf.data : JSON.stringify(conf.data);\n }\n\n let raw: Response;\n try {\n raw = await fetch(url, opts);\n clearTimeout(timer);\n } catch (err: unknown) {\n clearTimeout(timer);\n if (err && typeof err === \"object\") {\n // pass to caller\n }\n throw err;\n }\n\n const text = await raw.text();\n let data: unknown = null;\n try {\n data = text ? JSON.parse(text) : null;\n } catch {\n data = text;\n }\n\n const res: AxiosResponse<T> = {\n data: data as T,\n status: raw.status,\n statusText: raw.statusText,\n headers: Object.fromEntries(raw.headers.entries()),\n config: conf,\n };\n\n for (const i of responseInterceptors) {\n try {\n // allow interceptor to transform response\n // eslint-disable-next-line no-await-in-loop\n await i.fulfilled(res);\n } catch (e) {\n if (i.rejected) i.rejected(e);\n throw e;\n }\n }\n\n if (!raw.ok) {\n const maybeError =\n typeof res.data === \"object\" &&\n res.data !== null &&\n \"error\" in (res.data as Record<string, unknown>)\n ? (res.data as Record<string, unknown>).error\n : undefined;\n const err = maybeError ?? res.data ?? { status: raw.status };\n throw err as unknown;\n }\n\n return res;\n }\n\n const instance = {\n interceptors: {\n request: {\n use(\n fulfilled: (\n c: AxiosRequestConfig,\n ) => AxiosRequestConfig | Promise<AxiosRequestConfig>,\n rejected?: (e: unknown) => unknown,\n ) {\n requestInterceptors.push({ fulfilled, rejected });\n },\n },\n response: {\n use(\n fulfilled: (\n r: AxiosResponse,\n ) => AxiosResponse | Promise<AxiosResponse>,\n rejected?: (e: unknown) => unknown,\n ) {\n responseInterceptors.push({ fulfilled, rejected });\n },\n },\n },\n\n async get<T = unknown>(\n url: string,\n options: AxiosRequestConfig = {},\n ): Promise<AxiosResponse<T>> {\n return runRequest<T>({ ...options, url, method: \"get\" });\n },\n\n async post<T = unknown>(\n url: string,\n data?: unknown,\n options: AxiosRequestConfig = {},\n ): Promise<AxiosResponse<T>> {\n return runRequest<T>({ ...options, url, data, method: \"post\" });\n },\n\n async put<T = unknown>(\n url: string,\n data?: unknown,\n options: AxiosRequestConfig = {},\n ): Promise<AxiosResponse<T>> {\n return runRequest<T>({ ...options, url, data, method: \"put\" });\n },\n\n async delete<T = unknown>(\n url: string,\n options: AxiosRequestConfig = {},\n ): Promise<AxiosResponse<T>> {\n return runRequest<T>({ ...options, url, method: \"delete\" });\n },\n\n // compatibility: allow calling instance(config)\n async request<T = unknown>(\n options: AxiosRequestConfig & { method: string },\n ): Promise<AxiosResponse<T>> {\n return runRequest<T>(options);\n },\n };\n\n return instance;\n}\n","import { createAxios } from \"./http\";\n\n/**\n * Tipo derivado da instância do Axios\n * (evita problemas no build de types)\n */\ntype AxiosInstance = ReturnType<typeof createAxios>;\n\n/**\n * Modos disponíveis\n */\nexport type ClientMode = \"public\" | \"private\";\n\n/**\n * Opções do cliente\n */\nexport type ClientOptions = {\n type: ClientMode;\n config?: {\n key?: string;\n baseURL?: string;\n };\n};\n\n/**\n * Detecta ambiente\n */\nconst isBrowser =\n typeof window !== \"undefined\" && typeof document !== \"undefined\";\n\n/**\n * Cliente base da caBRAPI\n */\nexport class CoreClient {\n public http: AxiosInstance;\n public mode: ClientMode;\n public isBrowser: boolean;\n\n constructor(options: ClientOptions) {\n this.mode = options.type;\n this.isBrowser = isBrowser;\n\n // 🔒 validação backend\n if (this.mode === \"private\" && !options.config?.key && !this.isBrowser) {\n throw new Error(\"API key é obrigatória no modo 'private'.\");\n }\n\n // 🔐 só backend usa key\n const apiKey =\n !this.isBrowser && this.mode === \"private\"\n ? options.config?.key\n : undefined;\n\n this.http = createAxios({ baseURL: options.config?.baseURL, apiKey });\n\n // ⚠️ aviso dev\n if (this.isBrowser && this.mode === \"private\") {\n console.warn(\n \"[caBRAPI] Modo 'private' detectado no navegador. API key ignorada.\",\n );\n }\n }\n\n /**\n * Está em modo privado (backend)\n */\n public isPrivate(): boolean {\n return !this.isBrowser && this.mode === \"private\";\n }\n\n /**\n * Está em modo público\n */\n public isPublic(): boolean {\n return this.isBrowser || this.mode === \"public\";\n }\n\n /**\n * Garante execução no backend\n */\n public assertPrivate(): void {\n if (!this.isPrivate()) {\n throw new Error(\n \"Este método é privado e não pode ser usado no navegador.\",\n );\n }\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeleteCategoryResponse } from \"../index\";\n\nexport async function deleteCategory(\n core: CoreClient,\n storeId: string,\n categoryId: string,\n): Promise<DeleteCategoryResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeleteCategoryResponse>(\n `/stores/${storeId}/categories/${categoryId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetCategoriesInput, GetCategoriesResponse } from \"../index\";\n\nexport async function getCategories(\n core: CoreClient,\n storeId: string,\n input: GetCategoriesInput = {},\n): Promise<GetCategoriesResponse> {\n const { data } = await core.http.get<GetCategoriesResponse>(\n `/stores/${storeId}/categories`,\n {\n params: {\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetCategoryByIdResponse } from \"../index\";\n\nexport async function getCategoryById(\n core: CoreClient,\n storeId: string,\n categoryId: string,\n): Promise<GetCategoryByIdResponse> {\n const { data } = await core.http.get<GetCategoryByIdResponse>(\n `/stores/${storeId}/categories/${categoryId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreateCategoryInput, CreateCategoryResponse } from \"../index\";\n\nexport async function createCategory(\n core: CoreClient,\n storeId: string,\n input: CreateCategoryInput,\n): Promise<CreateCategoryResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.post<CreateCategoryResponse>(\n `/stores/${storeId}/categories`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { UpdateCategoryInput, UpdateCategoryResponse } from \"../index\";\n\nexport async function updateCategory(\n core: CoreClient,\n storeId: string,\n categoryId: string,\n input: UpdateCategoryInput,\n): Promise<UpdateCategoryResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<UpdateCategoryResponse>(\n `/stores/${storeId}/categories/${categoryId}`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { ReorderCategoriesResponse } from \"../index\";\n\nexport async function reorderCategories(\n core: CoreClient,\n storeId: string,\n categoryIds: string[],\n): Promise<ReorderCategoriesResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<ReorderCategoriesResponse>(\n `/stores/${storeId}/categories/reorder`,\n { categoryIds },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deleteCategory } from \"./http/delete\";\nimport { getCategories } from \"./http/get\";\nimport { getCategoryById } from \"./http/get-by-id\";\nimport { createCategory } from \"./http/post\";\nimport { updateCategory } from \"./http/put\";\nimport { reorderCategories } from \"./http/reorder\";\n\nexport type Category = {\n id: string;\n name: string;\n description: string | null;\n image: string | null;\n metadata: Record<string, unknown> | null;\n position: number;\n storeId: string;\n createdAt: string;\n updatedAt: string;\n};\n\nexport type CategoryDetails = Category & {\n products?: unknown[];\n coupons?: unknown[];\n};\n\nexport type Pagination = {\n page: number;\n limit: number;\n total: number;\n totalPages: number;\n};\n\nexport type GetCategoriesInput = {\n page?: number;\n limit?: number;\n};\n\nexport type CreateCategoryInput = {\n name?: string;\n description?: string | null;\n image?: string | null;\n metadata?: Record<string, unknown> | null;\n};\n\nexport type UpdateCategoryInput = {\n name?: string;\n description?: string | null;\n image?: string | null;\n metadata?: Record<string, unknown> | null;\n position?: number;\n};\n\nexport type GetCategoriesResponse = {\n status: boolean;\n code: string;\n categories: Category[];\n pagination: Pagination;\n};\n\nexport type GetCategoryByIdResponse = {\n status: boolean;\n code: string;\n category: CategoryDetails;\n};\n\nexport type CreateCategoryResponse = {\n status: boolean;\n code?: string;\n category: Category;\n};\n\nexport type UpdateCategoryResponse = {\n status: boolean;\n code: string;\n category: Category;\n};\n\nexport type DeleteCategoryResponse = {\n status: boolean;\n code: string;\n};\n\nexport type ReorderCategoriesResponse = {\n status: boolean;\n code: string;\n};\n\nexport class Categories {\n constructor(private core: CoreClient) {}\n\n get(storeId: string, input: GetCategoriesInput = {}) {\n return getCategories(this.core, storeId, input);\n }\n\n getById(storeId: string, categoryId: string) {\n return getCategoryById(this.core, storeId, categoryId);\n }\n\n post(storeId: string, input: CreateCategoryInput) {\n return createCategory(this.core, storeId, input);\n }\n\n put(storeId: string, categoryId: string, input: UpdateCategoryInput) {\n return updateCategory(this.core, storeId, categoryId, input);\n }\n\n delete(storeId: string, categoryId: string) {\n return deleteCategory(this.core, storeId, categoryId);\n }\n\n reorder(storeId: string, categoryIds: string[]) {\n return reorderCategories(this.core, storeId, categoryIds);\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeleteCouponResponse } from \"../index\";\n\nexport async function deleteCoupon(\n core: CoreClient,\n storeId: string,\n couponId: string,\n): Promise<DeleteCouponResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeleteCouponResponse>(\n `/stores/${storeId}/coupons/${couponId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetCouponsInput, GetCouponsResponse } from \"../index\";\n\nexport async function getCoupons(\n core: CoreClient,\n storeId: string,\n input: GetCouponsInput = {},\n): Promise<GetCouponsResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetCouponsResponse>(\n `/stores/${storeId}/coupons`,\n {\n params: {\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetCouponByCodeResponse } from \"../index\";\n\nexport async function getCouponByCode(\n core: CoreClient,\n storeId: string,\n code: string,\n): Promise<GetCouponByCodeResponse> {\n const { data } = await core.http.get<GetCouponByCodeResponse>(\n `/stores/${storeId}/coupons/${code}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetCouponByIdResponse } from \"../index\";\n\nexport async function getCouponById(\n core: CoreClient,\n storeId: string,\n couponId: string,\n): Promise<GetCouponByIdResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetCouponByIdResponse>(\n `/stores/${storeId}/coupons/uuid/${couponId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreateCouponInput, CreateCouponResponse } from \"../index\";\n\nexport async function createCoupon(\n core: CoreClient,\n storeId: string,\n input: CreateCouponInput,\n): Promise<CreateCouponResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.post<CreateCouponResponse>(\n `/stores/${storeId}/coupons`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { UpdateCouponInput, UpdateCouponResponse } from \"../index\";\n\nexport async function updateCoupon(\n core: CoreClient,\n storeId: string,\n couponId: string,\n input: UpdateCouponInput,\n): Promise<UpdateCouponResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<UpdateCouponResponse>(\n `/stores/${storeId}/coupons/${couponId}`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { ReorderCouponsResponse } from \"../index\";\n\nexport async function reorderCoupons(\n core: CoreClient,\n storeId: string,\n couponIds: string[],\n): Promise<ReorderCouponsResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<ReorderCouponsResponse>(\n `/stores/${storeId}/coupons/reorder`,\n { couponIds },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deleteCoupon } from \"./http/delete\";\nimport { getCoupons } from \"./http/get\";\nimport { getCouponByCode } from \"./http/get-by-code\";\nimport { getCouponById } from \"./http/get-by-id\";\nimport { createCoupon } from \"./http/post\";\nimport { updateCoupon } from \"./http/put\";\nimport { reorderCoupons } from \"./http/reorder\";\n\nexport type CouponRelationRef = {\n id: string;\n name: string;\n};\n\nexport type Coupon = {\n id: string;\n code: string;\n position: number;\n discount: number;\n useLimit: number;\n expiredAt: string | null;\n storeId?: string;\n products: CouponRelationRef[];\n categories: CouponRelationRef[];\n createdAt?: string;\n updatedAt?: string;\n};\n\nexport type Pagination = {\n page: number;\n limit: number;\n total: number;\n totalPages: number;\n};\n\nexport type GetCouponsInput = {\n page?: number;\n limit?: number;\n};\n\nexport type CreateCouponInput = {\n code: string;\n discount: number;\n useLimit?: number | null;\n expiredAt?: string | null;\n productIds?: string[];\n categoryIds?: string[];\n};\n\nexport type UpdateCouponInput = {\n code?: string;\n discount?: number;\n position?: number;\n useLimit?: number | null;\n expiredAt?: string | null;\n productIds?: string[];\n categoryIds?: string[];\n};\n\nexport type GetCouponsResponse = {\n status: boolean;\n code: string;\n coupons: Coupon[];\n pagination: Pagination;\n};\n\nexport type GetCouponByCodeResponse = {\n status: boolean;\n code: string;\n coupon: Coupon;\n};\n\nexport type GetCouponByIdResponse = {\n status: boolean;\n code: string;\n coupon: Coupon;\n};\n\nexport type CreateCouponResponse = {\n status: boolean;\n code: string;\n coupon: Coupon;\n};\n\nexport type UpdateCouponResponse = {\n status: boolean;\n code: string;\n coupon: Coupon;\n};\n\nexport type DeleteCouponResponse = {\n status: boolean;\n code: string;\n};\n\nexport type ReorderCouponsResponse = {\n status: boolean;\n code: string;\n};\n\nexport class Coupons {\n constructor(private core: CoreClient) {}\n\n get(storeId: string, input: GetCouponsInput = {}) {\n return getCoupons(this.core, storeId, input);\n }\n\n getByCode(storeId: string, code: string) {\n return getCouponByCode(this.core, storeId, code);\n }\n\n getById(storeId: string, couponId: string) {\n return getCouponById(this.core, storeId, couponId);\n }\n\n post(storeId: string, input: CreateCouponInput) {\n return createCoupon(this.core, storeId, input);\n }\n\n put(storeId: string, couponId: string, input: UpdateCouponInput) {\n return updateCoupon(this.core, storeId, couponId, input);\n }\n\n delete(storeId: string, couponId: string) {\n return deleteCoupon(this.core, storeId, couponId);\n }\n\n reorder(storeId: string, couponIds: string[]) {\n return reorderCoupons(this.core, storeId, couponIds);\n }\n}\n","import type { CoreClient } from \"../../../client\";\n\n/**\n * Resposta do endpoint de exclusão de página.\n */\ntype DeletePageResponse = {\n status: boolean;\n code: string;\n};\n\n/**\n * Remove a página publicada referente ao `domain` informado.\n *\n * Executa uma requisição `DELETE /pages/:domain`. Este endpoint é privado e\n * exige que o `CoreClient` esteja configurado em modo privado (backend).\n *\n * @param core - Instância do `CoreClient` (deve ser private).\n * @param domain - Domínio da página a remover (ex.: \"minhaloja.com.br\").\n * @returns Promise que resolve com `{ status, code }` retornado pela API.\n *\n * @throws {Error} Se `core.isPrivate()` for falso (tentativa de uso no navegador)\n * ou se a API retornar erro/HTTP failure.\n *\n * @example\n * ```ts\n * await deletePage(coreClient, \"loja.exemplo.com\");\n * ```\n */\nexport async function deletePage(\n core: CoreClient,\n domain: string,\n): Promise<{ status: boolean; code: string }> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeletePageResponse>(\n `/pages/${domain}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\n\n/**\n * Modelo de página retornado pela API de páginas.\n *\n * Observações:\n * - Campos `createdAt` e `updatedAt` são timestamps em ISO 8601.\n * - `version` pode ser usada pelo servidor para controle de versão do conteúdo.\n * - `store` é metadado opcional com informações da loja proprietária.\n */\nexport type Page = {\n html: string;\n template?: string;\n version?: string;\n createdAt?: string;\n updatedAt?: string;\n store?: {\n ownerId: string;\n id: string;\n };\n};\n\n/**\n * Estrutura padrão da resposta da API para operações de página.\n */\ntype PageResponse = {\n status: boolean;\n data: Page;\n};\n\n/**\n * Recupera a `Page` publicada para o `domain` informado.\n *\n * Faz uma chamada `GET /pages/:domain` usando o `CoreClient` fornecido.\n *\n * @param core - Instância de `CoreClient` que executa requisições HTTP.\n * @param domain - Domínio da página a ser recuperada (ex.: \"minha-loja.com\").\n * @returns Promise que resolve com um objeto contendo `status` e `data` (`Page`).\n *\n * @throws {Error} Se a resposta não contiver `data` (página não encontrada) ou se\n * houver erro de rede/HTTP lançado pelo `core.http`.\n *\n * @example\n * ```ts\n * const page = await getPage(coreClient, \"loja.exemplo.com\");\n * console.log(page.data.html);\n * ```\n */\nexport async function getPage(\n core: CoreClient,\n domain: string,\n): Promise<{ status: boolean; data: Page }> {\n const { data } = await core.http.get<PageResponse>(`/pages/${domain}`);\n\n if (!data?.data) {\n throw new Error(`Page not found: ${domain}`);\n }\n\n return {\n status: data.status,\n data: data.data,\n };\n}\n","import type { CoreClient } from \"../../../client\";\n\n/**\n * Dados necessários para criar ou atualizar uma página.\n */\nexport type PageUpsertInput = {\n domain: string;\n html: string;\n template?: string;\n};\n\n/**\n * Resposta do endpoint de upsert.\n */\ntype PageUpsertResponse = {\n status: boolean;\n code: string;\n};\n\n/**\n * Cria ou atualiza a página pública associada ao `input.domain`.\n *\n * Realiza uma requisição `PUT /pages/:domain` com o corpo contendo `html` e\n * `template` (se fornecido). Este endpoint é marcado como privado — deve ser\n * usado apenas por código backend que possua credenciais privadas.\n *\n * @param core - `CoreClient` configurado (deve estar em modo privado).\n * @param input - Dados da página a persistir: `domain`, `html`, `template?`.\n * @returns Promise que resolve com o objeto de resposta `{ status, code }`.\n *\n * @throws {Error} Se `core.isPrivate()` for falso (uso no navegador) ou se a\n * requisição HTTP falhar.\n *\n * @example\n * ```ts\n * await upsertPage(coreClient, {\n * domain: \"loja.exemplo.com\",\n * html: \"<html>...\",\n * template: \"landing-v2\",\n * });\n * ```\n */\nexport async function upsertPage(\n core: CoreClient,\n input: PageUpsertInput,\n): Promise<{ status: boolean; code: string }> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<PageUpsertResponse>(\n `/pages/${input.domain}`,\n {\n html: input.html,\n template: input.template,\n },\n );\n\n return data;\n}\n","/**\n * Módulo `Pages` — cliente de operação para páginas estáticas.\n *\n * Fornece wrappers de alto nível para recuperar, criar/atualizar e remover\n * representações HTML de páginas hospedadas em um domínio específico. Cada\n * operação delega a chamada HTTP para funções em `./http/*` e propaga erros\n * retornados pelo cliente HTTP subjacente.\n *\n */\nimport type { CoreClient } from \"../../client\";\nimport { deletePage } from \"./http/delete\";\nimport { getPage } from \"./http/get\";\nimport { upsertPage } from \"./http/upsert\";\n\n/**\n * Representa uma página\n */\n/**\n * Representa uma página estática gerida pela API.\n *\n * Propriedades:\n * - `domain`: Identificador único da página. Geralmente host ou host+path.\n * - `html`: Conteúdo HTML completo que será servido para esse domínio.\n * - `template`: (opcional) nome do template ou layout que o servidor pode aplicar.\n *\n * ```\n */\nexport type Page = {\n domain: string;\n html: string;\n template?: string;\n};\n\n/**\n * Client de alto nível para operações relacionadas a `Page`.\n *\n * Instancie com um `CoreClient` já autenticado/configurado. Os métodos desta\n * classe são pequenos wrappers que delegam a execução para as funções HTTP\n * específicas em `./http/*`, mantendo a assinatura orientada ao domínio.\n */\nexport class Pages {\n /**\n * Construtor.\n * @param core - Instância de `CoreClient` usada para efetuar chamadas HTTP.\n */\n constructor(private core: CoreClient) {}\n\n /**\n * Recupera a página associada ao `domain` informado.\n *\n * @param domain - Identificador da página a recuperar (ex.: \"exemplo.com\").\n * @returns Uma promise que resolve com o objeto `Page` caso exista.\n * @throws Erros de rede/HTTP ou erro retornado pela API se a página não existir.\n *\n */\n get(domain: string) {\n return getPage(this.core, domain);\n }\n\n /**\n * Cria ou atualiza uma página.\n *\n * Se a página para o `domain` já existir, o servidor realizará um update;\n * caso contrário, criará uma nova entrada.\n *\n * @param input - Objeto com os dados da página:\n * - `domain`: chave única da página.\n * - `html`: conteúdo HTML completo.\n * - `template` (opcional): nome do template a aplicar.\n * @returns Uma promise que resolve com o `Page` criado/atualizado ou com metadados retornados pela API.\n * @throws Erros de validação, rede ou HTTP conforme a resposta da API.\n *\n */\n upsert(input: { domain: string; html: string; template?: string }) {\n return upsertPage(this.core, input);\n }\n\n /**\n * Remove a página associada ao `domain`.\n *\n * @param domain - Identificador da página a remover.\n * @returns Uma promise que resolve quando a exclusão for confirmada pelo servidor.\n * @throws Erro se a operação falhar (por exemplo, página não encontrada ou erro de permissão).\n *\n */\n delete(domain: string) {\n return deletePage(this.core, domain);\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeletePaymentResponse } from \"../index\";\n\nexport async function deletePayment(\n core: CoreClient,\n storeId: string,\n paymentId: string,\n): Promise<DeletePaymentResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeletePaymentResponse>(\n `/stores/${storeId}/payments/${paymentId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { FilterPaymentsInput, FilterPaymentsResponse } from \"../index\";\n\nexport async function filterPayments(\n core: CoreClient,\n storeId: string,\n input: FilterPaymentsInput = {},\n): Promise<FilterPaymentsResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<FilterPaymentsResponse>(\n `/stores/${storeId}/payments/filter`,\n {\n params: {\n id: input.id,\n uuid: input.uuid,\n status: input.status,\n name: input.name,\n email: input.email,\n cpf: input.cpf,\n price: input.price,\n minPrice: input.minPrice,\n maxPrice: input.maxPrice,\n coupon: input.coupon,\n gateway: input.gateway,\n shipment: input.shipment,\n createdAtFrom: input.createdAtFrom,\n createdAtTo: input.createdAtTo,\n updatedAtFrom: input.updatedAtFrom,\n updatedAtTo: input.updatedAtTo,\n productId: input.productId,\n metadataKey: input.metadataKey,\n metadataValue: input.metadataValue,\n sortBy: input.sortBy,\n sortOrder: input.sortOrder,\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetPaymentsInput, GetPaymentsResponse } from \"../index\";\n\nexport async function getPayments(\n core: CoreClient,\n storeId: string,\n input: GetPaymentsInput = {},\n): Promise<GetPaymentsResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetPaymentsResponse>(\n `/stores/${storeId}/payments`,\n {\n params: {\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreatePaymentInput, CreatePaymentResponse } from \"../index\";\n\nexport async function createPayment(\n core: CoreClient,\n storeId: string,\n input: CreatePaymentInput,\n): Promise<CreatePaymentResponse> {\n const { data } = await core.http.post<CreatePaymentResponse>(\n `/stores/${storeId}/payments`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { UpdatePaymentInput, UpdatePaymentResponse } from \"../index\";\n\nexport async function updatePayment(\n core: CoreClient,\n storeId: string,\n paymentId: string,\n input: UpdatePaymentInput,\n): Promise<UpdatePaymentResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<UpdatePaymentResponse>(\n `/stores/${storeId}/payments/${paymentId}`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deletePayment } from \"./http/delete\";\nimport { filterPayments } from \"./http/filter\";\nimport { getPayments } from \"./http/get\";\nimport { createPayment } from \"./http/post\";\nimport { updatePayment } from \"./http/put\";\n\nexport type PaymentStatus =\n | \"PENDING\"\n | \"APPROVED\"\n | \"REJECTED\"\n | \"CANCELLED\"\n | \"REFUNDED\"\n | \"CHARGED_BACK\"\n | \"EXPIRED\";\n\nexport type PaymentGateway = \"MERCADOPAGO\" | \"EFI_BANK\";\nexport type PaymentCreateGateway =\n | \"MERCADOPAGO_SERVICE_PIX\"\n | \"MERCADOPAGO_SERVICE_CARD\";\n\nexport type PaymentShipmentStatus =\n | \"PENDING\"\n | \"PREPARING\"\n | \"SHIPPED\"\n | \"DELIVERED\"\n | \"RETURNED\"\n | \"CANCELLED\";\n\nexport type PaymentSortBy =\n | \"createdAt\"\n | \"updatedAt\"\n | \"price\"\n | \"name\"\n | \"email\";\nexport type PaymentSortOrder = \"asc\" | \"desc\";\n\nexport type Payment = {\n id: string;\n uuid: string;\n status: PaymentStatus;\n name?: string;\n email?: string;\n cpf?: string | null;\n price?: number;\n gateway?: PaymentGateway;\n shipment?: PaymentShipmentStatus;\n storeId: string;\n metadata?: Record<string, unknown> | null;\n};\n\nexport type Pagination = {\n page: number;\n limit: number;\n total: number;\n totalPages: number;\n};\n\nexport type FilterPaymentsInput = {\n id?: string;\n uuid?: string;\n status?: PaymentStatus;\n name?: string;\n email?: string;\n cpf?: string;\n price?: number;\n minPrice?: number;\n maxPrice?: number;\n coupon?: boolean;\n gateway?: PaymentGateway;\n shipment?: PaymentShipmentStatus;\n createdAtFrom?: string;\n createdAtTo?: string;\n updatedAtFrom?: string;\n updatedAtTo?: string;\n productId?: string;\n metadataKey?: string;\n metadataValue?: string;\n sortBy?: PaymentSortBy;\n sortOrder?: PaymentSortOrder;\n page?: number;\n limit?: number;\n};\n\nexport type FilterPaymentsResponse = {\n status: boolean;\n code: string;\n payments: Payment[];\n pagination: Pagination;\n};\n\nexport type GetPaymentsInput = {\n page?: number;\n limit?: number;\n};\n\nexport type GetPaymentsResponse = {\n status: boolean;\n code: string;\n payments: Payment[];\n pagination: Pagination;\n};\n\nexport type CreatePaymentItemInput = {\n productId: string;\n quantity: number;\n};\n\nexport type CreatePaymentInput = {\n name: string;\n email: string;\n cpf?: string;\n gateway: PaymentCreateGateway;\n coupon?: string | null;\n metadata?: Record<string, unknown>;\n items: CreatePaymentItemInput[];\n};\n\nexport type CreatePaymentResponse = {\n status: boolean;\n data: {\n service: {\n type: string;\n method: string;\n payment: string;\n };\n payment: {\n uuid: string;\n url?: string;\n qr_code?: {\n image: string;\n base_64: string;\n };\n };\n };\n};\n\nexport type UpdatePaymentInput = {\n shipment?: PaymentShipmentStatus;\n metadata?: Record<string, unknown>;\n};\n\nexport type UpdatePaymentResponse = {\n status: boolean;\n code: string;\n payment: {\n id: string;\n status: PaymentStatus;\n shipment?: PaymentShipmentStatus;\n metadata?: Record<string, unknown> | null;\n };\n};\n\nexport type DeletePaymentResponse = {\n status: boolean;\n code: string;\n message: string;\n};\n\nexport class Payments {\n constructor(private core: CoreClient) {}\n\n get(storeId: string, input: GetPaymentsInput = {}) {\n return getPayments(this.core, storeId, input);\n }\n\n filter(storeId: string, input: FilterPaymentsInput = {}) {\n return filterPayments(this.core, storeId, input);\n }\n\n post(storeId: string, input: CreatePaymentInput) {\n return createPayment(this.core, storeId, input);\n }\n\n put(storeId: string, paymentId: string, input: UpdatePaymentInput) {\n return updatePayment(this.core, storeId, paymentId, input);\n }\n\n delete(storeId: string, paymentId: string) {\n return deletePayment(this.core, storeId, paymentId);\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeleteProductResponse } from \"../index\";\n\nexport async function deleteProduct(\n core: CoreClient,\n storeId: string,\n productId: string,\n): Promise<DeleteProductResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeleteProductResponse>(\n `/stores/${storeId}/products/${productId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetProductsInput, GetProductsResponse } from \"../index\";\n\nexport async function getProducts(\n core: CoreClient,\n storeId: string,\n input: GetProductsInput = {},\n): Promise<GetProductsResponse> {\n const { data } = await core.http.get<GetProductsResponse>(\n `/stores/${storeId}/products`,\n {\n params: {\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetProductsInput, GetProductsResponse } from \"../index\";\n\nexport async function getProductsByCategory(\n core: CoreClient,\n storeId: string,\n categoryId: string,\n input: GetProductsInput = {},\n): Promise<GetProductsResponse> {\n const { data } = await core.http.get<GetProductsResponse>(\n `/stores/${storeId}/categories/${categoryId}/products`,\n {\n params: {\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetProductByIdResponse } from \"../index\";\n\nexport async function getProductById(\n core: CoreClient,\n storeId: string,\n productId: string,\n): Promise<GetProductByIdResponse> {\n const { data } = await core.http.get<GetProductByIdResponse>(\n `/stores/${storeId}/products/${productId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreateProductInput, CreateProductResponse } from \"../index\";\n\nexport async function createProduct(\n core: CoreClient,\n storeId: string,\n input: CreateProductInput,\n): Promise<CreateProductResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.post<CreateProductResponse>(\n `/stores/${storeId}/products`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { UpdateProductInput, UpdateProductResponse } from \"../index\";\n\nexport async function updateProduct(\n core: CoreClient,\n storeId: string,\n productId: string,\n input: UpdateProductInput,\n): Promise<UpdateProductResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<UpdateProductResponse>(\n `/stores/${storeId}/products/${productId}`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { ReorderProductsResponse } from \"../index\";\n\nexport async function reorderProducts(\n core: CoreClient,\n storeId: string,\n productIds: string[],\n): Promise<ReorderProductsResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<ReorderProductsResponse>(\n `/stores/${storeId}/products/reorder`,\n { productIds },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deleteProduct } from \"./http/delete\";\nimport { getProducts } from \"./http/get\";\nimport { getProductsByCategory } from \"./http/get-by-category\";\nimport { getProductById } from \"./http/get-by-id\";\nimport { createProduct } from \"./http/post\";\nimport { updateProduct } from \"./http/put\";\nimport { reorderProducts } from \"./http/reorder\";\n\nexport type ProductDelivery = \"DIGITAL\" | \"PHYSICAL\";\n\nexport type ProductCategoryRef = {\n id: string;\n name: string;\n};\n\nexport type Product = {\n id: string;\n name: string;\n disabled: boolean;\n position: number;\n description: string | null;\n price: number;\n image: string | null;\n delivery: ProductDelivery;\n stock: number;\n sold: number;\n storeId: string;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n categories?: ProductCategoryRef[];\n};\n\nexport type Pagination = {\n page: number;\n limit: number;\n total: number;\n totalPages: number;\n};\n\nexport type GetProductsInput = {\n page?: number;\n limit?: number;\n};\n\nexport type CreateProductInput = {\n name: string;\n image?: string | null;\n description?: string | null;\n categoryIds?: string[];\n delivery: ProductDelivery;\n price: number;\n stock?: number;\n disabled?: boolean;\n metadata?: Record<string, unknown> | null;\n};\n\nexport type UpdateProductInput = {\n name?: string;\n image?: string | null;\n description?: string | null;\n categoryIds?: string[];\n delivery?: ProductDelivery;\n price?: number;\n stock?: number;\n disabled?: boolean;\n position?: number;\n metadata?: Record<string, unknown> | null;\n};\n\nexport type GetProductsResponse = {\n status: boolean;\n code: string;\n products: Product[];\n pagination: Pagination;\n};\n\nexport type GetProductByIdResponse = {\n status: boolean;\n code: string;\n product: Product;\n};\n\nexport type CreateProductResponse = {\n status: boolean;\n code: string;\n product: Product;\n};\n\nexport type UpdateProductResponse = {\n status: boolean;\n code: string;\n product: Product;\n};\n\nexport type DeleteProductResponse = {\n status: boolean;\n code: string;\n};\n\nexport type ReorderProductsResponse = {\n status: boolean;\n code: string;\n};\n\nexport class Products {\n constructor(private core: CoreClient) {}\n\n get(storeId: string, input: GetProductsInput = {}) {\n return getProducts(this.core, storeId, input);\n }\n\n getByCategory(\n storeId: string,\n categoryId: string,\n input: GetProductsInput = {},\n ) {\n return getProductsByCategory(this.core, storeId, categoryId, input);\n }\n\n getById(storeId: string, productId: string) {\n return getProductById(this.core, storeId, productId);\n }\n\n post(storeId: string, input: CreateProductInput) {\n return createProduct(this.core, storeId, input);\n }\n\n put(storeId: string, productId: string, input: UpdateProductInput) {\n return updateProduct(this.core, storeId, productId, input);\n }\n\n delete(storeId: string, productId: string) {\n return deleteProduct(this.core, storeId, productId);\n }\n\n reorder(storeId: string, productIds: string[]) {\n return reorderProducts(this.core, storeId, productIds);\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeleteStoreResponse } from \"../index\";\n\nexport async function deleteStore(\n core: CoreClient,\n storeId: string,\n): Promise<DeleteStoreResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeleteStoreResponse>(\n `/stores/${storeId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetStoresInput, GetStoresResponse } from \"../index\";\n\nexport async function getStores(\n core: CoreClient,\n input: GetStoresInput = {},\n): Promise<GetStoresResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetStoresResponse>(\"/stores\", {\n params: {\n page: input.page,\n limit: input.limit,\n },\n });\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetStoreByIdResponse } from \"../index\";\n\nexport async function getStoreById(\n core: CoreClient,\n storeId: string,\n): Promise<GetStoreByIdResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetStoreByIdResponse>(\n `/stores/${storeId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreateStoreInput, CreateStoreResponse } from \"../index\";\n\nexport async function createStore(\n core: CoreClient,\n input: CreateStoreInput,\n): Promise<CreateStoreResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.post<CreateStoreResponse>(\"/stores\", input);\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { UpdateStoreInput, UpdateStoreResponse } from \"../index\";\n\nexport async function updateStore(\n core: CoreClient,\n storeId: string,\n input: UpdateStoreInput,\n): Promise<UpdateStoreResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<UpdateStoreResponse>(\n `/stores/${storeId}`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { ReorderStoresResponse } from \"../index\";\n\nexport async function reorderStores(\n core: CoreClient,\n storeIds: string[],\n): Promise<ReorderStoresResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<ReorderStoresResponse>(\n \"/stores/reorder\",\n { storeIds },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deleteStore } from \"./http/delete\";\nimport { getStores } from \"./http/get\";\nimport { getStoreById } from \"./http/get-by-id\";\nimport { createStore } from \"./http/post\";\nimport { updateStore } from \"./http/put\";\nimport { reorderStores } from \"./http/reorder\";\n\n/**\n * Templates válidos para loja.\n */\nexport type StoreTemplate = \"PERSONALIZADO\" | \"N/A\";\n\n/**\n * Tipo do domínio informado no payload da loja.\n */\nexport type StoreDomainType = \"CUSTOM\" | \"DEFAULT\";\n\n/**\n * Estrutura de domínio para criação/atualização.\n */\nexport type StoreDomainInput = {\n type: StoreDomainType;\n value: string;\n};\n\n/**\n * Modelo base de loja retornado nos endpoints de listagem e upsert.\n */\nexport type Store = {\n id: string;\n name: string;\n position: number;\n description: string | null;\n image: string | null;\n domain: string;\n template: StoreTemplate;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n};\n\n/**\n * Modelo detalhado retornado por `GET /stores/:storeId`.\n */\nexport type StoreDetails = Store & {\n ownerId?: string;\n deletedAt?: string | null;\n categories?: unknown[];\n products?: unknown[];\n coupons?: unknown[];\n payment?: unknown[];\n};\n\n/**\n * Metadados de paginação padrão da API.\n */\nexport type Pagination = {\n page: number;\n limit: number;\n total: number;\n totalPages: number;\n};\n\n/**\n * Query params de listagem de lojas.\n */\nexport type GetStoresInput = {\n page?: number;\n limit?: number;\n};\n\n/**\n * Payload para criação de loja (`POST /stores`).\n */\nexport type CreateStoreInput = {\n template: StoreTemplate;\n name?: string;\n description?: string | null;\n image?: string | null;\n metadata?: Record<string, unknown> | null;\n domain?: StoreDomainInput | null;\n position?: number;\n};\n\n/**\n * Payload para atualização de loja (`PUT /stores/:storeId`).\n *\n * Observação: no endpoint de update, todos os campos são opcionais,\n * mas a API exige ao menos 1 campo no body.\n */\nexport type UpdateStoreInput = {\n template?: StoreTemplate;\n name?: string;\n description?: string | null;\n image?: string | null;\n metadata?: Record<string, unknown> | null;\n domain?: StoreDomainInput | null;\n position?: number;\n};\n\n/**\n * Resposta de listagem de lojas.\n */\nexport type GetStoresResponse = {\n status: boolean;\n code: string;\n stores: Store[];\n pagination: Pagination;\n};\n\n/**\n * Resposta de consulta por ID.\n */\nexport type GetStoreByIdResponse = {\n status: boolean;\n code: string;\n store: StoreDetails;\n};\n\n/**\n * Resposta de criação.\n */\nexport type CreateStoreResponse = {\n status: boolean;\n code: string;\n store: Store;\n};\n\n/**\n * Resposta de atualização.\n */\nexport type UpdateStoreResponse = {\n status: boolean;\n code: string;\n store: Store;\n};\n\n/**\n * Resposta de exclusão.\n */\nexport type DeleteStoreResponse = {\n status: boolean;\n code: string;\n};\n\n/**\n * Resposta de reordenação.\n */\nexport type ReorderStoresResponse = {\n status: boolean;\n code: string;\n};\n\n/**\n * Cliente de alto nível para operações do módulo de lojas.\n */\nexport class Stores {\n /**\n * @param core Cliente base da SDK.\n */\n constructor(private core: CoreClient) {}\n\n /**\n * Lista lojas da conta com suporte a paginação.\n */\n get(input: GetStoresInput = {}) {\n return getStores(this.core, input);\n }\n\n /**\n * Busca uma loja pelo ID.\n */\n getById(storeId: string) {\n return getStoreById(this.core, storeId);\n }\n\n /**\n * Cria uma nova loja.\n */\n post(input: CreateStoreInput) {\n return createStore(this.core, input);\n }\n\n /**\n * Atualiza uma loja existente.\n */\n put(storeId: string, input: UpdateStoreInput) {\n return updateStore(this.core, storeId, input);\n }\n\n /**\n * Exclui uma loja pelo ID.\n */\n delete(storeId: string) {\n return deleteStore(this.core, storeId);\n }\n\n /**\n * Reordena lojas pelo array final de IDs.\n */\n reorder(storeIds: string[]) {\n return reorderStores(this.core, storeIds);\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeleteWebhookInput, DeleteWebhookResponse } from \"../index\";\n\nexport async function deleteWebhook(\n core: CoreClient,\n storeId: string,\n input: DeleteWebhookInput,\n): Promise<DeleteWebhookResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeleteWebhookResponse>(\n `/stores/${storeId}/webhooks`,\n {\n data: input,\n },\n );\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetWebhooksResponse } from \"../index\";\n\nexport async function getWebhooks(\n core: CoreClient,\n storeId: string,\n): Promise<GetWebhooksResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetWebhooksResponse>(\n `/stores/${storeId}/webhooks`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreateWebhookInput, CreateWebhookResponse } from \"../index\";\n\nexport async function createWebhook(\n core: CoreClient,\n storeId: string,\n input: CreateWebhookInput,\n): Promise<CreateWebhookResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.post<CreateWebhookResponse>(\n `/stores/${storeId}/webhooks`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deleteWebhook } from \"./http/delete\";\nimport { getWebhooks } from \"./http/get\";\nimport { createWebhook } from \"./http/post\";\n\n/**\n * Resposta de listagem de webhooks por loja.\n */\nexport type GetWebhooksResponse = {\n webhooks: string[];\n max: number;\n};\n\n/**\n * Payload para criar webhook em uma loja.\n */\nexport type CreateWebhookInput = {\n url: string;\n};\n\n/**\n * Resposta de criação de webhook.\n */\nexport type CreateWebhookResponse = {\n status: boolean;\n code: string;\n webhook: string;\n};\n\n/**\n * Payload para remover webhook de uma loja.\n */\nexport type DeleteWebhookInput = {\n url: string;\n};\n\n/**\n * Resposta de remoção de webhook.\n */\nexport type DeleteWebhookResponse = {\n status: boolean;\n code: string;\n};\n\n/**\n * Cliente de alto nível para operações de webhooks da loja.\n */\nexport class Webhooks {\n /**\n * @param core Cliente base da SDK.\n */\n constructor(private core: CoreClient) {}\n\n /**\n * Lista os webhooks cadastrados para uma loja.\n */\n get(storeId: string) {\n return getWebhooks(this.core, storeId);\n }\n\n /**\n * Adiciona um webhook em uma loja.\n */\n post(storeId: string, input: CreateWebhookInput) {\n return createWebhook(this.core, storeId, input);\n }\n\n /**\n * Remove um webhook de uma loja.\n */\n delete(storeId: string, input: DeleteWebhookInput) {\n return deleteWebhook(this.core, storeId, input);\n }\n\n /**\n * Descriptografa e valida o payload recebido no webhook de assinatura.\n *\n * Espera um payload no formato `iv:encrypted` (ambos em base64), criptografado\n * com AES-256-CBC usando a chave informada.\n */\n async decrypty(\n secret: string,\n payload: string,\n ): Promise<Record<string, unknown>> {\n if (!secret) {\n throw new Error(\"SECRET_KEY_REQUIRED\");\n }\n\n if (!payload || typeof payload !== \"string\") {\n throw new Error(\"INVALID_PAYLOAD_FORMAT\");\n }\n\n const [ivB64, encrypted] = payload.split(\":\");\n if (!ivB64 || !encrypted) {\n throw new Error(\"INVALID_PAYLOAD_FORMAT\");\n }\n\n const iv = base64ToBytes(ivB64);\n const encryptedBytes = base64ToBytes(encrypted);\n const secretBytes = new TextEncoder().encode(secret);\n\n const keyHash = await globalThis.crypto.subtle.digest(\n \"SHA-256\",\n secretBytes,\n );\n const cryptoKey = await globalThis.crypto.subtle.importKey(\n \"raw\",\n keyHash,\n { name: \"AES-CBC\" },\n false,\n [\"decrypt\"],\n );\n const decryptedBuffer = await globalThis.crypto.subtle.decrypt(\n { name: \"AES-CBC\", iv: toArrayBuffer(iv) },\n cryptoKey,\n toArrayBuffer(encryptedBytes),\n );\n const decrypted = new TextDecoder().decode(decryptedBuffer);\n\n return JSON.parse(decrypted) as Record<string, unknown>;\n }\n\n /**\n * Alias com nome corrigido para descriptografar payload de webhook.\n */\n async decrypt(\n secret: string,\n payload: string,\n ): Promise<Record<string, unknown>> {\n return this.decrypty(secret, payload);\n }\n\n /**\n * Alias retrocompatível para quem já usa `parseSubscriptionPayload`.\n */\n async parseSubscriptionPayload(\n payload: string,\n secret: string,\n ): Promise<Record<string, unknown>> {\n return this.decrypty(secret, payload);\n }\n}\n\nfunction base64ToBytes(base64: string): Uint8Array {\n const binary = atob(base64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i += 1) {\n bytes[i] = binary.charCodeAt(i);\n }\n return bytes;\n}\n\nfunction toArrayBuffer(bytes: Uint8Array): ArrayBuffer {\n return bytes.buffer.slice(\n bytes.byteOffset,\n bytes.byteOffset + bytes.byteLength,\n ) as ArrayBuffer;\n}\n","import { type ClientOptions, CoreClient } from \"./core/client\";\nimport { Categories } from \"./core/module/categories/index\";\nimport { Coupons } from \"./core/module/coupons/index\";\nimport { Pages } from \"./core/module/pages/index\";\nimport { Payments } from \"./core/module/payments/index\";\nimport { Products } from \"./core/module/products/index\";\nimport { Stores } from \"./core/module/stores/index\";\nimport { Webhooks } from \"./core/module/webhooks/index\";\n\n/**\n * SDK principal da caBRAPI\n */\nexport class caBRAPI {\n public categories: Categories;\n public coupons: Coupons;\n public payments: Payments;\n public pages: Pages;\n public products: Products;\n public stores: Stores;\n public webhooks: Webhooks;\n\n constructor(options: ClientOptions) {\n const core = new CoreClient(options);\n\n this.categories = new Categories(core);\n this.coupons = new Coupons(core);\n this.payments = new Payments(core);\n this.pages = new Pages(core);\n this.products = new Products(core);\n this.stores = new Stores(core);\n this.webhooks = new Webhooks(core);\n }\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -544,6 +544,7 @@ declare class Products {
|
|
|
544
544
|
private core;
|
|
545
545
|
constructor(core: CoreClient);
|
|
546
546
|
get(storeId: string, input?: GetProductsInput): Promise<GetProductsResponse>;
|
|
547
|
+
getByCategory(storeId: string, categoryId: string, input?: GetProductsInput): Promise<GetProductsResponse>;
|
|
547
548
|
getById(storeId: string, productId: string): Promise<GetProductByIdResponse>;
|
|
548
549
|
post(storeId: string, input: CreateProductInput): Promise<CreateProductResponse>;
|
|
549
550
|
put(storeId: string, productId: string, input: UpdateProductInput): Promise<UpdateProductResponse>;
|
package/dist/index.d.ts
CHANGED
|
@@ -544,6 +544,7 @@ declare class Products {
|
|
|
544
544
|
private core;
|
|
545
545
|
constructor(core: CoreClient);
|
|
546
546
|
get(storeId: string, input?: GetProductsInput): Promise<GetProductsResponse>;
|
|
547
|
+
getByCategory(storeId: string, categoryId: string, input?: GetProductsInput): Promise<GetProductsResponse>;
|
|
547
548
|
getById(storeId: string, productId: string): Promise<GetProductByIdResponse>;
|
|
548
549
|
post(storeId: string, input: CreateProductInput): Promise<CreateProductResponse>;
|
|
549
550
|
put(storeId: string, productId: string, input: UpdateProductInput): Promise<UpdateProductResponse>;
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
function ye(o,e){return /^https?:\/\//.test(e)?e:`${o.replace(/\/$/,"")}/${e.replace(/^\//,"")}`}function Ce(o){if(!o)return "";let e=encodeURIComponent,t=Object.entries(o).filter(([,r])=>r!=null).map(([r,i])=>`${e(r)}=${e(String(i))}`).join("&");return t?`?${t}`:""}function S(o={}){let e=o.baseURL??"https://api.cabrapi.com.br",t=o.timeout??3e4,r=[],i=[];async function p(s){let n={...s};for(let a of r)try{n=await a.fulfilled(n);}catch(c){throw a.rejected&&a.rejected(c),c}let u=ye(e,n.url??"")+Ce(n.params),g={"Content-Type":"application/json",...n.headers||{}};o.apiKey&&(g.Authorization=`${o.apiKey}`);let l=new AbortController,le=n.timeout??t,k=setTimeout(()=>l.abort(),le),A={method:s.method.toUpperCase(),headers:g,signal:l.signal};n.data!==void 0&&s.method.toLowerCase()!=="get"&&(A.body=typeof n.data=="string"?n.data:JSON.stringify(n.data));let d;try{d=await fetch(u,A),clearTimeout(k);}catch(a){throw clearTimeout(k),a}let x=await d.text(),I=null;try{I=x?JSON.parse(x):null;}catch{I=x;}let m={data:I,status:d.status,statusText:d.statusText,headers:Object.fromEntries(d.headers.entries()),config:n};for(let a of i)try{await a.fulfilled(m);}catch(c){throw a.rejected&&a.rejected(c),c}if(!d.ok)throw (typeof m.data=="object"&&m.data!==null&&"error"in m.data?m.data.error:void 0)??m.data??{status:d.status};return m}return {interceptors:{request:{use(s,n){r.push({fulfilled:s,rejected:n});}},response:{use(s,n){i.push({fulfilled:s,rejected:n});}}},async get(s,n={}){return p({...n,url:s,method:"get"})},async post(s,n,u={}){return p({...u,url:s,data:n,method:"post"})},async put(s,n,u={}){return p({...u,url:s,data:n,method:"put"})},async delete(s,n={}){return p({...n,url:s,method:"delete"})},async request(s){return p(s)}}}var fe=typeof window<"u"&&typeof document<"u",y=class{constructor(e){if(this.mode=e.type,this.isBrowser=fe,this.mode==="private"&&!e.config?.key&&!this.isBrowser)throw new Error("API key \xE9 obrigat\xF3ria no modo 'private'.");let t=!this.isBrowser&&this.mode==="private"?e.config?.key:void 0;this.http=S({baseURL:e.config?.baseURL,apiKey:t}),this.isBrowser&&this.mode==="private"&&console.warn("[caBRAPI] Modo 'private' detectado no navegador. API key ignorada.");}isPrivate(){return !this.isBrowser&&this.mode==="private"}isPublic(){return this.isBrowser||this.mode==="public"}assertPrivate(){if(!this.isPrivate())throw new Error("Este m\xE9todo \xE9 privado e n\xE3o pode ser usado no navegador.")}};async function E(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.delete(`/stores/${e}/categories/${t}`);return r}async function G(o,e,t={}){let{data:r}=await o.http.get(`/stores/${e}/categories`,{params:{page:t.page,limit:t.limit}});return r}async function D(o,e,t){let{data:r}=await o.http.get(`/stores/${e}/categories/${t}`);return r}async function U(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.post(`/stores/${e}/categories`,t);return r}async function B(o,e,t,r){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:i}=await o.http.put(`/stores/${e}/categories/${t}`,r);return i}async function T(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.put(`/stores/${e}/categories/reorder`,{categoryIds:t});return r}var C=class{constructor(e){this.core=e;}get(e,t={}){return G(this.core,e,t)}getById(e,t){return D(this.core,e,t)}post(e,t){return U(this.core,e,t)}put(e,t,r){return B(this.core,e,t,r)}delete(e,t){return E(this.core,e,t)}reorder(e,t){return T(this.core,e,t)}};async function $(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.delete(`/stores/${e}/coupons/${t}`);return r}async function M(o,e,t={}){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.get(`/stores/${e}/coupons`,{params:{page:t.page,limit:t.limit}});return r}async function O(o,e,t){let{data:r}=await o.http.get(`/stores/${e}/coupons/${t}`);return r}async function W(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.get(`/stores/${e}/coupons/uuid/${t}`);return r}async function L(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.post(`/stores/${e}/coupons`,t);return r}async function q(o,e,t,r){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:i}=await o.http.put(`/stores/${e}/coupons/${t}`,r);return i}async function F(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.put(`/stores/${e}/coupons/reorder`,{couponIds:t});return r}var f=class{constructor(e){this.core=e;}get(e,t={}){return M(this.core,e,t)}getByCode(e,t){return O(this.core,e,t)}getById(e,t){return W(this.core,e,t)}post(e,t){return L(this.core,e,t)}put(e,t,r){return q(this.core,e,t,r)}delete(e,t){return $(this.core,e,t)}reorder(e,t){return F(this.core,e,t)}};async function N(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.delete(`/pages/${e}`);return t}async function _(o,e){let{data:t}=await o.http.get(`/pages/${e}`);if(!t?.data)throw new Error(`Page not found: ${e}`);return {status:t.status,data:t.data}}async function V(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.put(`/pages/${e.domain}`,{html:e.html,template:e.template});return t}var P=class{constructor(e){this.core=e;}get(e){return _(this.core,e)}upsert(e){return V(this.core,e)}delete(e){return N(this.core,e)}};async function K(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.delete(`/stores/${e}/payments/${t}`);return r}async function j(o,e,t={}){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.get(`/stores/${e}/payments/filter`,{params:{id:t.id,uuid:t.uuid,status:t.status,name:t.name,email:t.email,cpf:t.cpf,price:t.price,minPrice:t.minPrice,maxPrice:t.maxPrice,coupon:t.coupon,gateway:t.gateway,shipment:t.shipment,createdAtFrom:t.createdAtFrom,createdAtTo:t.createdAtTo,updatedAtFrom:t.updatedAtFrom,updatedAtTo:t.updatedAtTo,productId:t.productId,metadataKey:t.metadataKey,metadataValue:t.metadataValue,sortBy:t.sortBy,sortOrder:t.sortOrder,page:t.page,limit:t.limit}});return r}async function H(o,e,t={}){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.get(`/stores/${e}/payments`,{params:{page:t.page,limit:t.limit}});return r}async function J(o,e,t){let{data:r}=await o.http.post(`/stores/${e}/payments`,t);return r}async function Y(o,e,t,r){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:i}=await o.http.put(`/stores/${e}/payments/${t}`,r);return i}var R=class{constructor(e){this.core=e;}get(e,t={}){return H(this.core,e,t)}filter(e,t={}){return j(this.core,e,t)}post(e,t){return J(this.core,e,t)}put(e,t,r){return Y(this.core,e,t,r)}delete(e,t){return K(this.core,e,t)}};async function Q(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.delete(`/stores/${e}/products/${t}`);return r}async function X(o,e,t={}){let{data:r}=await o.http.get(`/stores/${e}/products`,{params:{page:t.page,limit:t.limit}});return r}async function z(o,e,t){let{data:r}=await o.http.get(`/stores/${e}/products/${t}`);return r}async function Z(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.post(`/stores/${e}/products`,t);return r}async function ee(o,e,t,r){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:i}=await o.http.put(`/stores/${e}/products/${t}`,r);return i}async function te(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.put(`/stores/${e}/products/reorder`,{productIds:t});return r}var b=class{constructor(e){this.core=e;}get(e,t={}){return X(this.core,e,t)}getById(e,t){return z(this.core,e,t)}post(e,t){return Z(this.core,e,t)}put(e,t,r){return ee(this.core,e,t,r)}delete(e,t){return Q(this.core,e,t)}reorder(e,t){return te(this.core,e,t)}};async function oe(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.delete(`/stores/${e}`);return t}async function re(o,e={}){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.get("/stores",{params:{page:e.page,limit:e.limit}});return t}async function ne(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.get(`/stores/${e}`);return t}async function se(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.post("/stores",e);return t}async function ie(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.put(`/stores/${e}`,t);return r}async function ae(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.put("/stores/reorder",{storeIds:e});return t}var h=class{constructor(e){this.core=e;}get(e={}){return re(this.core,e)}getById(e){return ne(this.core,e)}post(e){return se(this.core,e)}put(e,t){return ie(this.core,e,t)}delete(e){return oe(this.core,e)}reorder(e){return ae(this.core,e)}};async function pe(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.delete(`/stores/${e}/webhooks`,{data:t});return r}async function ue(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.get(`/stores/${e}/webhooks`);return t}async function de(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.post(`/stores/${e}/webhooks`,t);return r}var w=class{constructor(e){this.core=e;}get(e){return ue(this.core,e)}post(e,t){return de(this.core,e,t)}delete(e,t){return pe(this.core,e,t)}async decrypty(e,t){if(!e)throw new Error("SECRET_KEY_REQUIRED");if(!t||typeof t!="string")throw new Error("INVALID_PAYLOAD_FORMAT");let[r,i]=t.split(":");if(!r||!i)throw new Error("INVALID_PAYLOAD_FORMAT");let p=me(r),v=me(i),s=new TextEncoder().encode(e),n=await globalThis.crypto.subtle.digest("SHA-256",s),u=await globalThis.crypto.subtle.importKey("raw",n,{name:"AES-CBC"},false,["decrypt"]),g=await globalThis.crypto.subtle.decrypt({name:"AES-CBC",iv:ce(p)},u,ce(v)),l=new TextDecoder().decode(g);return JSON.parse(l)}async decrypt(e,t){return this.decrypty(e,t)}async parseSubscriptionPayload(e,t){return this.decrypty(t,e)}};function me(o){let e=atob(o),t=new Uint8Array(e.length);for(let r=0;r<e.length;r+=1)t[r]=e.charCodeAt(r);return t}function ce(o){return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}var ge=class{constructor(e){let t=new y(e);this.categories=new C(t),this.coupons=new f(t),this.payments=new R(t),this.pages=new P(t),this.products=new b(t),this.stores=new h(t),this.webhooks=new w(t);}};
|
|
2
|
-
export{
|
|
1
|
+
function Ce(o,e){return /^https?:\/\//.test(e)?e:`${o.replace(/\/$/,"")}/${e.replace(/^\//,"")}`}function fe(o){if(!o)return "";let e=encodeURIComponent,t=Object.entries(o).filter(([,r])=>r!=null).map(([r,i])=>`${e(r)}=${e(String(i))}`).join("&");return t?`?${t}`:""}function S(o={}){let e=o.baseURL??"https://api.cabrapi.com.br",t=o.timeout??3e4,r=[],i=[];async function p(s){let n={...s};for(let a of r)try{n=await a.fulfilled(n);}catch(c){throw a.rejected&&a.rejected(c),c}let u=Ce(e,n.url??"")+fe(n.params),g={"Content-Type":"application/json",...n.headers||{}};o.apiKey&&(g.Authorization=`${o.apiKey}`);let l=new AbortController,ye=n.timeout??t,k=setTimeout(()=>l.abort(),ye),A={method:s.method.toUpperCase(),headers:g,signal:l.signal};n.data!==void 0&&s.method.toLowerCase()!=="get"&&(A.body=typeof n.data=="string"?n.data:JSON.stringify(n.data));let d;try{d=await fetch(u,A),clearTimeout(k);}catch(a){throw clearTimeout(k),a}let w=await d.text(),I=null;try{I=w?JSON.parse(w):null;}catch{I=w;}let m={data:I,status:d.status,statusText:d.statusText,headers:Object.fromEntries(d.headers.entries()),config:n};for(let a of i)try{await a.fulfilled(m);}catch(c){throw a.rejected&&a.rejected(c),c}if(!d.ok)throw (typeof m.data=="object"&&m.data!==null&&"error"in m.data?m.data.error:void 0)??m.data??{status:d.status};return m}return {interceptors:{request:{use(s,n){r.push({fulfilled:s,rejected:n});}},response:{use(s,n){i.push({fulfilled:s,rejected:n});}}},async get(s,n={}){return p({...n,url:s,method:"get"})},async post(s,n,u={}){return p({...u,url:s,data:n,method:"post"})},async put(s,n,u={}){return p({...u,url:s,data:n,method:"put"})},async delete(s,n={}){return p({...n,url:s,method:"delete"})},async request(s){return p(s)}}}var Pe=typeof window<"u"&&typeof document<"u",y=class{constructor(e){if(this.mode=e.type,this.isBrowser=Pe,this.mode==="private"&&!e.config?.key&&!this.isBrowser)throw new Error("API key \xE9 obrigat\xF3ria no modo 'private'.");let t=!this.isBrowser&&this.mode==="private"?e.config?.key:void 0;this.http=S({baseURL:e.config?.baseURL,apiKey:t}),this.isBrowser&&this.mode==="private"&&console.warn("[caBRAPI] Modo 'private' detectado no navegador. API key ignorada.");}isPrivate(){return !this.isBrowser&&this.mode==="private"}isPublic(){return this.isBrowser||this.mode==="public"}assertPrivate(){if(!this.isPrivate())throw new Error("Este m\xE9todo \xE9 privado e n\xE3o pode ser usado no navegador.")}};async function G(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.delete(`/stores/${e}/categories/${t}`);return r}async function E(o,e,t={}){let{data:r}=await o.http.get(`/stores/${e}/categories`,{params:{page:t.page,limit:t.limit}});return r}async function D(o,e,t){let{data:r}=await o.http.get(`/stores/${e}/categories/${t}`);return r}async function B(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.post(`/stores/${e}/categories`,t);return r}async function U(o,e,t,r){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:i}=await o.http.put(`/stores/${e}/categories/${t}`,r);return i}async function T(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.put(`/stores/${e}/categories/reorder`,{categoryIds:t});return r}var C=class{constructor(e){this.core=e;}get(e,t={}){return E(this.core,e,t)}getById(e,t){return D(this.core,e,t)}post(e,t){return B(this.core,e,t)}put(e,t,r){return U(this.core,e,t,r)}delete(e,t){return G(this.core,e,t)}reorder(e,t){return T(this.core,e,t)}};async function $(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.delete(`/stores/${e}/coupons/${t}`);return r}async function M(o,e,t={}){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.get(`/stores/${e}/coupons`,{params:{page:t.page,limit:t.limit}});return r}async function O(o,e,t){let{data:r}=await o.http.get(`/stores/${e}/coupons/${t}`);return r}async function W(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.get(`/stores/${e}/coupons/uuid/${t}`);return r}async function L(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.post(`/stores/${e}/coupons`,t);return r}async function q(o,e,t,r){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:i}=await o.http.put(`/stores/${e}/coupons/${t}`,r);return i}async function F(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.put(`/stores/${e}/coupons/reorder`,{couponIds:t});return r}var f=class{constructor(e){this.core=e;}get(e,t={}){return M(this.core,e,t)}getByCode(e,t){return O(this.core,e,t)}getById(e,t){return W(this.core,e,t)}post(e,t){return L(this.core,e,t)}put(e,t,r){return q(this.core,e,t,r)}delete(e,t){return $(this.core,e,t)}reorder(e,t){return F(this.core,e,t)}};async function N(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.delete(`/pages/${e}`);return t}async function _(o,e){let{data:t}=await o.http.get(`/pages/${e}`);if(!t?.data)throw new Error(`Page not found: ${e}`);return {status:t.status,data:t.data}}async function V(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.put(`/pages/${e.domain}`,{html:e.html,template:e.template});return t}var P=class{constructor(e){this.core=e;}get(e){return _(this.core,e)}upsert(e){return V(this.core,e)}delete(e){return N(this.core,e)}};async function K(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.delete(`/stores/${e}/payments/${t}`);return r}async function j(o,e,t={}){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.get(`/stores/${e}/payments/filter`,{params:{id:t.id,uuid:t.uuid,status:t.status,name:t.name,email:t.email,cpf:t.cpf,price:t.price,minPrice:t.minPrice,maxPrice:t.maxPrice,coupon:t.coupon,gateway:t.gateway,shipment:t.shipment,createdAtFrom:t.createdAtFrom,createdAtTo:t.createdAtTo,updatedAtFrom:t.updatedAtFrom,updatedAtTo:t.updatedAtTo,productId:t.productId,metadataKey:t.metadataKey,metadataValue:t.metadataValue,sortBy:t.sortBy,sortOrder:t.sortOrder,page:t.page,limit:t.limit}});return r}async function H(o,e,t={}){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.get(`/stores/${e}/payments`,{params:{page:t.page,limit:t.limit}});return r}async function J(o,e,t){let{data:r}=await o.http.post(`/stores/${e}/payments`,t);return r}async function Y(o,e,t,r){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:i}=await o.http.put(`/stores/${e}/payments/${t}`,r);return i}var R=class{constructor(e){this.core=e;}get(e,t={}){return H(this.core,e,t)}filter(e,t={}){return j(this.core,e,t)}post(e,t){return J(this.core,e,t)}put(e,t,r){return Y(this.core,e,t,r)}delete(e,t){return K(this.core,e,t)}};async function Q(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.delete(`/stores/${e}/products/${t}`);return r}async function X(o,e,t={}){let{data:r}=await o.http.get(`/stores/${e}/products`,{params:{page:t.page,limit:t.limit}});return r}async function z(o,e,t,r={}){let{data:i}=await o.http.get(`/stores/${e}/categories/${t}/products`,{params:{page:r.page,limit:r.limit}});return i}async function Z(o,e,t){let{data:r}=await o.http.get(`/stores/${e}/products/${t}`);return r}async function ee(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.post(`/stores/${e}/products`,t);return r}async function te(o,e,t,r){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:i}=await o.http.put(`/stores/${e}/products/${t}`,r);return i}async function oe(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.put(`/stores/${e}/products/reorder`,{productIds:t});return r}var b=class{constructor(e){this.core=e;}get(e,t={}){return X(this.core,e,t)}getByCategory(e,t,r={}){return z(this.core,e,t,r)}getById(e,t){return Z(this.core,e,t)}post(e,t){return ee(this.core,e,t)}put(e,t,r){return te(this.core,e,t,r)}delete(e,t){return Q(this.core,e,t)}reorder(e,t){return oe(this.core,e,t)}};async function re(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.delete(`/stores/${e}`);return t}async function ne(o,e={}){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.get("/stores",{params:{page:e.page,limit:e.limit}});return t}async function se(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.get(`/stores/${e}`);return t}async function ie(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.post("/stores",e);return t}async function ae(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.put(`/stores/${e}`,t);return r}async function pe(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.put("/stores/reorder",{storeIds:e});return t}var h=class{constructor(e){this.core=e;}get(e={}){return ne(this.core,e)}getById(e){return se(this.core,e)}post(e){return ie(this.core,e)}put(e,t){return ae(this.core,e,t)}delete(e){return re(this.core,e)}reorder(e){return pe(this.core,e)}};async function ue(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.delete(`/stores/${e}/webhooks`,{data:t});return r}async function de(o,e){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:t}=await o.http.get(`/stores/${e}/webhooks`);return t}async function me(o,e,t){if(!o.isPrivate())throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");let{data:r}=await o.http.post(`/stores/${e}/webhooks`,t);return r}var x=class{constructor(e){this.core=e;}get(e){return de(this.core,e)}post(e,t){return me(this.core,e,t)}delete(e,t){return ue(this.core,e,t)}async decrypty(e,t){if(!e)throw new Error("SECRET_KEY_REQUIRED");if(!t||typeof t!="string")throw new Error("INVALID_PAYLOAD_FORMAT");let[r,i]=t.split(":");if(!r||!i)throw new Error("INVALID_PAYLOAD_FORMAT");let p=ce(r),v=ce(i),s=new TextEncoder().encode(e),n=await globalThis.crypto.subtle.digest("SHA-256",s),u=await globalThis.crypto.subtle.importKey("raw",n,{name:"AES-CBC"},false,["decrypt"]),g=await globalThis.crypto.subtle.decrypt({name:"AES-CBC",iv:ge(p)},u,ge(v)),l=new TextDecoder().decode(g);return JSON.parse(l)}async decrypt(e,t){return this.decrypty(e,t)}async parseSubscriptionPayload(e,t){return this.decrypty(t,e)}};function ce(o){let e=atob(o),t=new Uint8Array(e.length);for(let r=0;r<e.length;r+=1)t[r]=e.charCodeAt(r);return t}function ge(o){return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}var le=class{constructor(e){let t=new y(e);this.categories=new C(t),this.coupons=new f(t),this.payments=new R(t),this.pages=new P(t),this.products=new b(t),this.stores=new h(t),this.webhooks=new x(t);}};
|
|
2
|
+
export{le as caBRAPI};//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/http.ts","../src/core/client.ts","../src/core/module/categories/http/delete.ts","../src/core/module/categories/http/get.ts","../src/core/module/categories/http/get-by-id.ts","../src/core/module/categories/http/post.ts","../src/core/module/categories/http/put.ts","../src/core/module/categories/http/reorder.ts","../src/core/module/categories/index.ts","../src/core/module/coupons/http/delete.ts","../src/core/module/coupons/http/get.ts","../src/core/module/coupons/http/get-by-code.ts","../src/core/module/coupons/http/get-by-id.ts","../src/core/module/coupons/http/post.ts","../src/core/module/coupons/http/put.ts","../src/core/module/coupons/http/reorder.ts","../src/core/module/coupons/index.ts","../src/core/module/pages/http/delete.ts","../src/core/module/pages/http/get.ts","../src/core/module/pages/http/upsert.ts","../src/core/module/pages/index.ts","../src/core/module/payments/http/delete.ts","../src/core/module/payments/http/filter.ts","../src/core/module/payments/http/get.ts","../src/core/module/payments/http/post.ts","../src/core/module/payments/http/put.ts","../src/core/module/payments/index.ts","../src/core/module/products/http/delete.ts","../src/core/module/products/http/get.ts","../src/core/module/products/http/get-by-id.ts","../src/core/module/products/http/post.ts","../src/core/module/products/http/put.ts","../src/core/module/products/http/reorder.ts","../src/core/module/products/index.ts","../src/core/module/stores/http/delete.ts","../src/core/module/stores/http/get.ts","../src/core/module/stores/http/get-by-id.ts","../src/core/module/stores/http/post.ts","../src/core/module/stores/http/put.ts","../src/core/module/stores/http/reorder.ts","../src/core/module/stores/index.ts","../src/core/module/webhooks/http/delete.ts","../src/core/module/webhooks/http/get.ts","../src/core/module/webhooks/http/post.ts","../src/core/module/webhooks/index.ts","../src/index.ts"],"names":["buildURL","base","path","buildQuery","params","esc","query","v","k","createAxios","cfg","baseURL","timeout","requestInterceptors","responseInterceptors","runRequest","config","conf","i","e","url","headers","controller","to","timer","opts","raw","err","text","data","res","fulfilled","rejected","options","isBrowser","CoreClient","apiKey","deleteCategory","core","storeId","categoryId","getCategories","input","getCategoryById","createCategory","updateCategory","reorderCategories","categoryIds","Categories","deleteCoupon","couponId","getCoupons","getCouponByCode","code","getCouponById","createCoupon","updateCoupon","reorderCoupons","couponIds","Coupons","deletePage","domain","getPage","upsertPage","Pages","deletePayment","paymentId","filterPayments","getPayments","createPayment","updatePayment","Payments","deleteProduct","productId","getProducts","getProductById","createProduct","updateProduct","reorderProducts","productIds","Products","deleteStore","getStores","getStoreById","createStore","updateStore","reorderStores","storeIds","Stores","deleteWebhook","getWebhooks","createWebhook","Webhooks","secret","payload","ivB64","encrypted","iv","base64ToBytes","encryptedBytes","secretBytes","keyHash","cryptoKey","decryptedBuffer","toArrayBuffer","decrypted","base64","binary","bytes","caBRAPI"],"mappings":"AA+BA,SAASA,GAASC,CAAAA,CAAcC,CAAAA,CAAc,CAC5C,OAAI,eAAe,IAAA,CAAKA,CAAI,CAAA,CAAUA,CAAAA,CAC/B,GAAGD,CAAAA,CAAK,OAAA,CAAQ,KAAA,CAAO,EAAE,CAAC,CAAA,CAAA,EAAIC,CAAAA,CAAK,OAAA,CAAQ,KAAA,CAAO,EAAE,C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TP simples usando fetch (nativo).\n * Exporta `createAxios` para compatibilidade com restante do código.\n */\nexport type AxiosConfig = {\n baseURL?: string;\n apiKey?: string;\n timeout?: number;\n};\n\nexport type AxiosRequestConfig = {\n url?: string;\n params?: Record<string, unknown>;\n headers?: Record<string, string>;\n data?: unknown;\n timeout?: number;\n};\n\nexport type AxiosResponse<T = unknown> = {\n data: T;\n status: number;\n statusText: string;\n headers: Record<string, string>;\n config?: AxiosRequestConfig;\n};\n\ntype Interceptor<V> = {\n fulfilled: (v: V) => V | Promise<V>;\n rejected?: (err: unknown) => unknown;\n};\n\nfunction buildURL(base: string, path: string) {\n if (/^https?:\\/\\//.test(path)) return path;\n return `${base.replace(/\\/$/, \"\")}/${path.replace(/^\\//, \"\")}`;\n}\n\nfunction buildQuery(params?: Record<string, unknown>) {\n if (!params) return \"\";\n const esc = encodeURIComponent;\n const query = Object.entries(params)\n .filter(([, v]) => v !== undefined && v !== null)\n .map(([k, v]) => `${esc(k)}=${esc(String(v))}`)\n .join(\"&\");\n return query ? `?${query}` : \"\";\n}\n\nexport function createAxios(cfg: AxiosConfig = {}) {\n const baseURL = cfg.baseURL ?? \"https://api.cabrapi.com.br\";\n const timeout = cfg.timeout ?? 30000;\n\n const requestInterceptors: Interceptor<AxiosRequestConfig>[] = [];\n const responseInterceptors: Interceptor<AxiosResponse>[] = [];\n\n async function runRequest<T = unknown>(\n config: AxiosRequestConfig & { method: string },\n ): Promise<AxiosResponse<T>> {\n let conf: AxiosRequestConfig = { ...config };\n\n for (const i of requestInterceptors) {\n try {\n // allow interceptor to modify config\n conf = await i.fulfilled(conf);\n } catch (e) {\n if (i.rejected) i.rejected(e);\n throw e;\n }\n }\n\n const url =\n buildURL(baseURL, conf.url ?? \"\") +\n buildQuery(conf.params as Record<string, unknown> | undefined);\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...(conf.headers || {}),\n };\n\n if (cfg.apiKey) headers.Authorization = `${cfg.apiKey}`;\n\n const controller = new AbortController();\n const to = conf.timeout ?? timeout;\n const timer = setTimeout(() => controller.abort(), to);\n\n const opts: RequestInit = {\n method: config.method.toUpperCase(),\n headers,\n signal: controller.signal,\n };\n\n if (conf.data !== undefined && config.method.toLowerCase() !== \"get\") {\n opts.body =\n typeof conf.data === \"string\" ? conf.data : JSON.stringify(conf.data);\n }\n\n let raw: Response;\n try {\n raw = await fetch(url, opts);\n clearTimeout(timer);\n } catch (err: unknown) {\n clearTimeout(timer);\n if (err && typeof err === \"object\") {\n // pass to caller\n }\n throw err;\n }\n\n const text = await raw.text();\n let data: unknown = null;\n try {\n data = text ? JSON.parse(text) : null;\n } catch {\n data = text;\n }\n\n const res: AxiosResponse<T> = {\n data: data as T,\n status: raw.status,\n statusText: raw.statusText,\n headers: Object.fromEntries(raw.headers.entries()),\n config: conf,\n };\n\n for (const i of responseInterceptors) {\n try {\n // allow interceptor to transform response\n // eslint-disable-next-line no-await-in-loop\n await i.fulfilled(res);\n } catch (e) {\n if (i.rejected) i.rejected(e);\n throw e;\n }\n }\n\n if (!raw.ok) {\n const maybeError =\n typeof res.data === \"object\" &&\n res.data !== null &&\n \"error\" in (res.data as Record<string, unknown>)\n ? (res.data as Record<string, unknown>).error\n : undefined;\n const err = maybeError ?? res.data ?? { status: raw.status };\n throw err as unknown;\n }\n\n return res;\n }\n\n const instance = {\n interceptors: {\n request: {\n use(\n fulfilled: (\n c: AxiosRequestConfig,\n ) => AxiosRequestConfig | Promise<AxiosRequestConfig>,\n rejected?: (e: unknown) => unknown,\n ) {\n requestInterceptors.push({ fulfilled, rejected });\n },\n },\n response: {\n use(\n fulfilled: (\n r: AxiosResponse,\n ) => AxiosResponse | Promise<AxiosResponse>,\n rejected?: (e: unknown) => unknown,\n ) {\n responseInterceptors.push({ fulfilled, rejected });\n },\n },\n },\n\n async get<T = unknown>(\n url: string,\n options: AxiosRequestConfig = {},\n ): Promise<AxiosResponse<T>> {\n return runRequest<T>({ ...options, url, method: \"get\" });\n },\n\n async post<T = unknown>(\n url: string,\n data?: unknown,\n options: AxiosRequestConfig = {},\n ): Promise<AxiosResponse<T>> {\n return runRequest<T>({ ...options, url, data, method: \"post\" });\n },\n\n async put<T = unknown>(\n url: string,\n data?: unknown,\n options: AxiosRequestConfig = {},\n ): Promise<AxiosResponse<T>> {\n return runRequest<T>({ ...options, url, data, method: \"put\" });\n },\n\n async delete<T = unknown>(\n url: string,\n options: AxiosRequestConfig = {},\n ): Promise<AxiosResponse<T>> {\n return runRequest<T>({ ...options, url, method: \"delete\" });\n },\n\n // compatibility: allow calling instance(config)\n async request<T = unknown>(\n options: AxiosRequestConfig & { method: string },\n ): Promise<AxiosResponse<T>> {\n return runRequest<T>(options);\n },\n };\n\n return instance;\n}\n","import { createAxios } from \"./http\";\n\n/**\n * Tipo derivado da instância do Axios\n * (evita problemas no build de types)\n */\ntype AxiosInstance = ReturnType<typeof createAxios>;\n\n/**\n * Modos disponíveis\n */\nexport type ClientMode = \"public\" | \"private\";\n\n/**\n * Opções do cliente\n */\nexport type ClientOptions = {\n type: ClientMode;\n config?: {\n key?: string;\n baseURL?: string;\n };\n};\n\n/**\n * Detecta ambiente\n */\nconst isBrowser =\n typeof window !== \"undefined\" && typeof document !== \"undefined\";\n\n/**\n * Cliente base da caBRAPI\n */\nexport class CoreClient {\n public http: AxiosInstance;\n public mode: ClientMode;\n public isBrowser: boolean;\n\n constructor(options: ClientOptions) {\n this.mode = options.type;\n this.isBrowser = isBrowser;\n\n // 🔒 validação backend\n if (this.mode === \"private\" && !options.config?.key && !this.isBrowser) {\n throw new Error(\"API key é obrigatória no modo 'private'.\");\n }\n\n // 🔐 só backend usa key\n const apiKey =\n !this.isBrowser && this.mode === \"private\"\n ? options.config?.key\n : undefined;\n\n this.http = createAxios({ baseURL: options.config?.baseURL, apiKey });\n\n // ⚠️ aviso dev\n if (this.isBrowser && this.mode === \"private\") {\n console.warn(\n \"[caBRAPI] Modo 'private' detectado no navegador. API key ignorada.\",\n );\n }\n }\n\n /**\n * Está em modo privado (backend)\n */\n public isPrivate(): boolean {\n return !this.isBrowser && this.mode === \"private\";\n }\n\n /**\n * Está em modo público\n */\n public isPublic(): boolean {\n return this.isBrowser || this.mode === \"public\";\n }\n\n /**\n * Garante execução no backend\n */\n public assertPrivate(): void {\n if (!this.isPrivate()) {\n throw new Error(\n \"Este método é privado e não pode ser usado no navegador.\",\n );\n }\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeleteCategoryResponse } from \"../index\";\n\nexport async function deleteCategory(\n core: CoreClient,\n storeId: string,\n categoryId: string,\n): Promise<DeleteCategoryResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeleteCategoryResponse>(\n `/stores/${storeId}/categories/${categoryId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetCategoriesInput, GetCategoriesResponse } from \"../index\";\n\nexport async function getCategories(\n core: CoreClient,\n storeId: string,\n input: GetCategoriesInput = {},\n): Promise<GetCategoriesResponse> {\n const { data } = await core.http.get<GetCategoriesResponse>(\n `/stores/${storeId}/categories`,\n {\n params: {\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetCategoryByIdResponse } from \"../index\";\n\nexport async function getCategoryById(\n core: CoreClient,\n storeId: string,\n categoryId: string,\n): Promise<GetCategoryByIdResponse> {\n const { data } = await core.http.get<GetCategoryByIdResponse>(\n `/stores/${storeId}/categories/${categoryId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreateCategoryInput, CreateCategoryResponse } from \"../index\";\n\nexport async function createCategory(\n core: CoreClient,\n storeId: string,\n input: CreateCategoryInput,\n): Promise<CreateCategoryResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.post<CreateCategoryResponse>(\n `/stores/${storeId}/categories`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { UpdateCategoryInput, UpdateCategoryResponse } from \"../index\";\n\nexport async function updateCategory(\n core: CoreClient,\n storeId: string,\n categoryId: string,\n input: UpdateCategoryInput,\n): Promise<UpdateCategoryResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<UpdateCategoryResponse>(\n `/stores/${storeId}/categories/${categoryId}`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { ReorderCategoriesResponse } from \"../index\";\n\nexport async function reorderCategories(\n core: CoreClient,\n storeId: string,\n categoryIds: string[],\n): Promise<ReorderCategoriesResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<ReorderCategoriesResponse>(\n `/stores/${storeId}/categories/reorder`,\n { categoryIds },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deleteCategory } from \"./http/delete\";\nimport { getCategories } from \"./http/get\";\nimport { getCategoryById } from \"./http/get-by-id\";\nimport { createCategory } from \"./http/post\";\nimport { updateCategory } from \"./http/put\";\nimport { reorderCategories } from \"./http/reorder\";\n\nexport type Category = {\n id: string;\n name: string;\n description: string | null;\n image: string | null;\n metadata: Record<string, unknown> | null;\n position: number;\n storeId: string;\n createdAt: string;\n updatedAt: string;\n};\n\nexport type CategoryDetails = Category & {\n products?: unknown[];\n coupons?: unknown[];\n};\n\nexport type Pagination = {\n page: number;\n limit: number;\n total: number;\n totalPages: number;\n};\n\nexport type GetCategoriesInput = {\n page?: number;\n limit?: number;\n};\n\nexport type CreateCategoryInput = {\n name?: string;\n description?: string | null;\n image?: string | null;\n metadata?: Record<string, unknown> | null;\n};\n\nexport type UpdateCategoryInput = {\n name?: string;\n description?: string | null;\n image?: string | null;\n metadata?: Record<string, unknown> | null;\n position?: number;\n};\n\nexport type GetCategoriesResponse = {\n status: boolean;\n code: string;\n categories: Category[];\n pagination: Pagination;\n};\n\nexport type GetCategoryByIdResponse = {\n status: boolean;\n code: string;\n category: CategoryDetails;\n};\n\nexport type CreateCategoryResponse = {\n status: boolean;\n code?: string;\n category: Category;\n};\n\nexport type UpdateCategoryResponse = {\n status: boolean;\n code: string;\n category: Category;\n};\n\nexport type DeleteCategoryResponse = {\n status: boolean;\n code: string;\n};\n\nexport type ReorderCategoriesResponse = {\n status: boolean;\n code: string;\n};\n\nexport class Categories {\n constructor(private core: CoreClient) {}\n\n get(storeId: string, input: GetCategoriesInput = {}) {\n return getCategories(this.core, storeId, input);\n }\n\n getById(storeId: string, categoryId: string) {\n return getCategoryById(this.core, storeId, categoryId);\n }\n\n post(storeId: string, input: CreateCategoryInput) {\n return createCategory(this.core, storeId, input);\n }\n\n put(storeId: string, categoryId: string, input: UpdateCategoryInput) {\n return updateCategory(this.core, storeId, categoryId, input);\n }\n\n delete(storeId: string, categoryId: string) {\n return deleteCategory(this.core, storeId, categoryId);\n }\n\n reorder(storeId: string, categoryIds: string[]) {\n return reorderCategories(this.core, storeId, categoryIds);\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeleteCouponResponse } from \"../index\";\n\nexport async function deleteCoupon(\n core: CoreClient,\n storeId: string,\n couponId: string,\n): Promise<DeleteCouponResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeleteCouponResponse>(\n `/stores/${storeId}/coupons/${couponId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetCouponsInput, GetCouponsResponse } from \"../index\";\n\nexport async function getCoupons(\n core: CoreClient,\n storeId: string,\n input: GetCouponsInput = {},\n): Promise<GetCouponsResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetCouponsResponse>(\n `/stores/${storeId}/coupons`,\n {\n params: {\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetCouponByCodeResponse } from \"../index\";\n\nexport async function getCouponByCode(\n core: CoreClient,\n storeId: string,\n code: string,\n): Promise<GetCouponByCodeResponse> {\n const { data } = await core.http.get<GetCouponByCodeResponse>(\n `/stores/${storeId}/coupons/${code}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetCouponByIdResponse } from \"../index\";\n\nexport async function getCouponById(\n core: CoreClient,\n storeId: string,\n couponId: string,\n): Promise<GetCouponByIdResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetCouponByIdResponse>(\n `/stores/${storeId}/coupons/uuid/${couponId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreateCouponInput, CreateCouponResponse } from \"../index\";\n\nexport async function createCoupon(\n core: CoreClient,\n storeId: string,\n input: CreateCouponInput,\n): Promise<CreateCouponResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.post<CreateCouponResponse>(\n `/stores/${storeId}/coupons`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { UpdateCouponInput, UpdateCouponResponse } from \"../index\";\n\nexport async function updateCoupon(\n core: CoreClient,\n storeId: string,\n couponId: string,\n input: UpdateCouponInput,\n): Promise<UpdateCouponResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<UpdateCouponResponse>(\n `/stores/${storeId}/coupons/${couponId}`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { ReorderCouponsResponse } from \"../index\";\n\nexport async function reorderCoupons(\n core: CoreClient,\n storeId: string,\n couponIds: string[],\n): Promise<ReorderCouponsResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<ReorderCouponsResponse>(\n `/stores/${storeId}/coupons/reorder`,\n { couponIds },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deleteCoupon } from \"./http/delete\";\nimport { getCoupons } from \"./http/get\";\nimport { getCouponByCode } from \"./http/get-by-code\";\nimport { getCouponById } from \"./http/get-by-id\";\nimport { createCoupon } from \"./http/post\";\nimport { updateCoupon } from \"./http/put\";\nimport { reorderCoupons } from \"./http/reorder\";\n\nexport type CouponRelationRef = {\n id: string;\n name: string;\n};\n\nexport type Coupon = {\n id: string;\n code: string;\n position: number;\n discount: number;\n useLimit: number;\n expiredAt: string | null;\n storeId?: string;\n products: CouponRelationRef[];\n categories: CouponRelationRef[];\n createdAt?: string;\n updatedAt?: string;\n};\n\nexport type Pagination = {\n page: number;\n limit: number;\n total: number;\n totalPages: number;\n};\n\nexport type GetCouponsInput = {\n page?: number;\n limit?: number;\n};\n\nexport type CreateCouponInput = {\n code: string;\n discount: number;\n useLimit?: number | null;\n expiredAt?: string | null;\n productIds?: string[];\n categoryIds?: string[];\n};\n\nexport type UpdateCouponInput = {\n code?: string;\n discount?: number;\n position?: number;\n useLimit?: number | null;\n expiredAt?: string | null;\n productIds?: string[];\n categoryIds?: string[];\n};\n\nexport type GetCouponsResponse = {\n status: boolean;\n code: string;\n coupons: Coupon[];\n pagination: Pagination;\n};\n\nexport type GetCouponByCodeResponse = {\n status: boolean;\n code: string;\n coupon: Coupon;\n};\n\nexport type GetCouponByIdResponse = {\n status: boolean;\n code: string;\n coupon: Coupon;\n};\n\nexport type CreateCouponResponse = {\n status: boolean;\n code: string;\n coupon: Coupon;\n};\n\nexport type UpdateCouponResponse = {\n status: boolean;\n code: string;\n coupon: Coupon;\n};\n\nexport type DeleteCouponResponse = {\n status: boolean;\n code: string;\n};\n\nexport type ReorderCouponsResponse = {\n status: boolean;\n code: string;\n};\n\nexport class Coupons {\n constructor(private core: CoreClient) {}\n\n get(storeId: string, input: GetCouponsInput = {}) {\n return getCoupons(this.core, storeId, input);\n }\n\n getByCode(storeId: string, code: string) {\n return getCouponByCode(this.core, storeId, code);\n }\n\n getById(storeId: string, couponId: string) {\n return getCouponById(this.core, storeId, couponId);\n }\n\n post(storeId: string, input: CreateCouponInput) {\n return createCoupon(this.core, storeId, input);\n }\n\n put(storeId: string, couponId: string, input: UpdateCouponInput) {\n return updateCoupon(this.core, storeId, couponId, input);\n }\n\n delete(storeId: string, couponId: string) {\n return deleteCoupon(this.core, storeId, couponId);\n }\n\n reorder(storeId: string, couponIds: string[]) {\n return reorderCoupons(this.core, storeId, couponIds);\n }\n}\n","import type { CoreClient } from \"../../../client\";\n\n/**\n * Resposta do endpoint de exclusão de página.\n */\ntype DeletePageResponse = {\n status: boolean;\n code: string;\n};\n\n/**\n * Remove a página publicada referente ao `domain` informado.\n *\n * Executa uma requisição `DELETE /pages/:domain`. Este endpoint é privado e\n * exige que o `CoreClient` esteja configurado em modo privado (backend).\n *\n * @param core - Instância do `CoreClient` (deve ser private).\n * @param domain - Domínio da página a remover (ex.: \"minhaloja.com.br\").\n * @returns Promise que resolve com `{ status, code }` retornado pela API.\n *\n * @throws {Error} Se `core.isPrivate()` for falso (tentativa de uso no navegador)\n * ou se a API retornar erro/HTTP failure.\n *\n * @example\n * ```ts\n * await deletePage(coreClient, \"loja.exemplo.com\");\n * ```\n */\nexport async function deletePage(\n core: CoreClient,\n domain: string,\n): Promise<{ status: boolean; code: string }> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeletePageResponse>(\n `/pages/${domain}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\n\n/**\n * Modelo de página retornado pela API de páginas.\n *\n * Observações:\n * - Campos `createdAt` e `updatedAt` são timestamps em ISO 8601.\n * - `version` pode ser usada pelo servidor para controle de versão do conteúdo.\n * - `store` é metadado opcional com informações da loja proprietária.\n */\nexport type Page = {\n html: string;\n template?: string;\n version?: string;\n createdAt?: string;\n updatedAt?: string;\n store?: {\n ownerId: string;\n id: string;\n };\n};\n\n/**\n * Estrutura padrão da resposta da API para operações de página.\n */\ntype PageResponse = {\n status: boolean;\n data: Page;\n};\n\n/**\n * Recupera a `Page` publicada para o `domain` informado.\n *\n * Faz uma chamada `GET /pages/:domain` usando o `CoreClient` fornecido.\n *\n * @param core - Instância de `CoreClient` que executa requisições HTTP.\n * @param domain - Domínio da página a ser recuperada (ex.: \"minha-loja.com\").\n * @returns Promise que resolve com um objeto contendo `status` e `data` (`Page`).\n *\n * @throws {Error} Se a resposta não contiver `data` (página não encontrada) ou se\n * houver erro de rede/HTTP lançado pelo `core.http`.\n *\n * @example\n * ```ts\n * const page = await getPage(coreClient, \"loja.exemplo.com\");\n * console.log(page.data.html);\n * ```\n */\nexport async function getPage(\n core: CoreClient,\n domain: string,\n): Promise<{ status: boolean; data: Page }> {\n const { data } = await core.http.get<PageResponse>(`/pages/${domain}`);\n\n if (!data?.data) {\n throw new Error(`Page not found: ${domain}`);\n }\n\n return {\n status: data.status,\n data: data.data,\n };\n}\n","import type { CoreClient } from \"../../../client\";\n\n/**\n * Dados necessários para criar ou atualizar uma página.\n */\nexport type PageUpsertInput = {\n domain: string;\n html: string;\n template?: string;\n};\n\n/**\n * Resposta do endpoint de upsert.\n */\ntype PageUpsertResponse = {\n status: boolean;\n code: string;\n};\n\n/**\n * Cria ou atualiza a página pública associada ao `input.domain`.\n *\n * Realiza uma requisição `PUT /pages/:domain` com o corpo contendo `html` e\n * `template` (se fornecido). Este endpoint é marcado como privado — deve ser\n * usado apenas por código backend que possua credenciais privadas.\n *\n * @param core - `CoreClient` configurado (deve estar em modo privado).\n * @param input - Dados da página a persistir: `domain`, `html`, `template?`.\n * @returns Promise que resolve com o objeto de resposta `{ status, code }`.\n *\n * @throws {Error} Se `core.isPrivate()` for falso (uso no navegador) ou se a\n * requisição HTTP falhar.\n *\n * @example\n * ```ts\n * await upsertPage(coreClient, {\n * domain: \"loja.exemplo.com\",\n * html: \"<html>...\",\n * template: \"landing-v2\",\n * });\n * ```\n */\nexport async function upsertPage(\n core: CoreClient,\n input: PageUpsertInput,\n): Promise<{ status: boolean; code: string }> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<PageUpsertResponse>(\n `/pages/${input.domain}`,\n {\n html: input.html,\n template: input.template,\n },\n );\n\n return data;\n}\n","/**\n * Módulo `Pages` — cliente de operação para páginas estáticas.\n *\n * Fornece wrappers de alto nível para recuperar, criar/atualizar e remover\n * representações HTML de páginas hospedadas em um domínio específico. Cada\n * operação delega a chamada HTTP para funções em `./http/*` e propaga erros\n * retornados pelo cliente HTTP subjacente.\n *\n */\nimport type { CoreClient } from \"../../client\";\nimport { deletePage } from \"./http/delete\";\nimport { getPage } from \"./http/get\";\nimport { upsertPage } from \"./http/upsert\";\n\n/**\n * Representa uma página\n */\n/**\n * Representa uma página estática gerida pela API.\n *\n * Propriedades:\n * - `domain`: Identificador único da página. Geralmente host ou host+path.\n * - `html`: Conteúdo HTML completo que será servido para esse domínio.\n * - `template`: (opcional) nome do template ou layout que o servidor pode aplicar.\n *\n * ```\n */\nexport type Page = {\n domain: string;\n html: string;\n template?: string;\n};\n\n/**\n * Client de alto nível para operações relacionadas a `Page`.\n *\n * Instancie com um `CoreClient` já autenticado/configurado. Os métodos desta\n * classe são pequenos wrappers que delegam a execução para as funções HTTP\n * específicas em `./http/*`, mantendo a assinatura orientada ao domínio.\n */\nexport class Pages {\n /**\n * Construtor.\n * @param core - Instância de `CoreClient` usada para efetuar chamadas HTTP.\n */\n constructor(private core: CoreClient) {}\n\n /**\n * Recupera a página associada ao `domain` informado.\n *\n * @param domain - Identificador da página a recuperar (ex.: \"exemplo.com\").\n * @returns Uma promise que resolve com o objeto `Page` caso exista.\n * @throws Erros de rede/HTTP ou erro retornado pela API se a página não existir.\n *\n */\n get(domain: string) {\n return getPage(this.core, domain);\n }\n\n /**\n * Cria ou atualiza uma página.\n *\n * Se a página para o `domain` já existir, o servidor realizará um update;\n * caso contrário, criará uma nova entrada.\n *\n * @param input - Objeto com os dados da página:\n * - `domain`: chave única da página.\n * - `html`: conteúdo HTML completo.\n * - `template` (opcional): nome do template a aplicar.\n * @returns Uma promise que resolve com o `Page` criado/atualizado ou com metadados retornados pela API.\n * @throws Erros de validação, rede ou HTTP conforme a resposta da API.\n *\n */\n upsert(input: { domain: string; html: string; template?: string }) {\n return upsertPage(this.core, input);\n }\n\n /**\n * Remove a página associada ao `domain`.\n *\n * @param domain - Identificador da página a remover.\n * @returns Uma promise que resolve quando a exclusão for confirmada pelo servidor.\n * @throws Erro se a operação falhar (por exemplo, página não encontrada ou erro de permissão).\n *\n */\n delete(domain: string) {\n return deletePage(this.core, domain);\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeletePaymentResponse } from \"../index\";\n\nexport async function deletePayment(\n core: CoreClient,\n storeId: string,\n paymentId: string,\n): Promise<DeletePaymentResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeletePaymentResponse>(\n `/stores/${storeId}/payments/${paymentId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { FilterPaymentsInput, FilterPaymentsResponse } from \"../index\";\n\nexport async function filterPayments(\n core: CoreClient,\n storeId: string,\n input: FilterPaymentsInput = {},\n): Promise<FilterPaymentsResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<FilterPaymentsResponse>(\n `/stores/${storeId}/payments/filter`,\n {\n params: {\n id: input.id,\n uuid: input.uuid,\n status: input.status,\n name: input.name,\n email: input.email,\n cpf: input.cpf,\n price: input.price,\n minPrice: input.minPrice,\n maxPrice: input.maxPrice,\n coupon: input.coupon,\n gateway: input.gateway,\n shipment: input.shipment,\n createdAtFrom: input.createdAtFrom,\n createdAtTo: input.createdAtTo,\n updatedAtFrom: input.updatedAtFrom,\n updatedAtTo: input.updatedAtTo,\n productId: input.productId,\n metadataKey: input.metadataKey,\n metadataValue: input.metadataValue,\n sortBy: input.sortBy,\n sortOrder: input.sortOrder,\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetPaymentsInput, GetPaymentsResponse } from \"../index\";\n\nexport async function getPayments(\n core: CoreClient,\n storeId: string,\n input: GetPaymentsInput = {},\n): Promise<GetPaymentsResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetPaymentsResponse>(\n `/stores/${storeId}/payments`,\n {\n params: {\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreatePaymentInput, CreatePaymentResponse } from \"../index\";\n\nexport async function createPayment(\n core: CoreClient,\n storeId: string,\n input: CreatePaymentInput,\n): Promise<CreatePaymentResponse> {\n const { data } = await core.http.post<CreatePaymentResponse>(\n `/stores/${storeId}/payments`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { UpdatePaymentInput, UpdatePaymentResponse } from \"../index\";\n\nexport async function updatePayment(\n core: CoreClient,\n storeId: string,\n paymentId: string,\n input: UpdatePaymentInput,\n): Promise<UpdatePaymentResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<UpdatePaymentResponse>(\n `/stores/${storeId}/payments/${paymentId}`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deletePayment } from \"./http/delete\";\nimport { filterPayments } from \"./http/filter\";\nimport { getPayments } from \"./http/get\";\nimport { createPayment } from \"./http/post\";\nimport { updatePayment } from \"./http/put\";\n\nexport type PaymentStatus =\n | \"PENDING\"\n | \"APPROVED\"\n | \"REJECTED\"\n | \"CANCELLED\"\n | \"REFUNDED\"\n | \"CHARGED_BACK\"\n | \"EXPIRED\";\n\nexport type PaymentGateway = \"MERCADOPAGO\" | \"EFI_BANK\";\nexport type PaymentCreateGateway =\n | \"MERCADOPAGO_SERVICE_PIX\"\n | \"MERCADOPAGO_SERVICE_CARD\";\n\nexport type PaymentShipmentStatus =\n | \"PENDING\"\n | \"PREPARING\"\n | \"SHIPPED\"\n | \"DELIVERED\"\n | \"RETURNED\"\n | \"CANCELLED\";\n\nexport type PaymentSortBy =\n | \"createdAt\"\n | \"updatedAt\"\n | \"price\"\n | \"name\"\n | \"email\";\nexport type PaymentSortOrder = \"asc\" | \"desc\";\n\nexport type Payment = {\n id: string;\n uuid: string;\n status: PaymentStatus;\n name?: string;\n email?: string;\n cpf?: string | null;\n price?: number;\n gateway?: PaymentGateway;\n shipment?: PaymentShipmentStatus;\n storeId: string;\n metadata?: Record<string, unknown> | null;\n};\n\nexport type Pagination = {\n page: number;\n limit: number;\n total: number;\n totalPages: number;\n};\n\nexport type FilterPaymentsInput = {\n id?: string;\n uuid?: string;\n status?: PaymentStatus;\n name?: string;\n email?: string;\n cpf?: string;\n price?: number;\n minPrice?: number;\n maxPrice?: number;\n coupon?: boolean;\n gateway?: PaymentGateway;\n shipment?: PaymentShipmentStatus;\n createdAtFrom?: string;\n createdAtTo?: string;\n updatedAtFrom?: string;\n updatedAtTo?: string;\n productId?: string;\n metadataKey?: string;\n metadataValue?: string;\n sortBy?: PaymentSortBy;\n sortOrder?: PaymentSortOrder;\n page?: number;\n limit?: number;\n};\n\nexport type FilterPaymentsResponse = {\n status: boolean;\n code: string;\n payments: Payment[];\n pagination: Pagination;\n};\n\nexport type GetPaymentsInput = {\n page?: number;\n limit?: number;\n};\n\nexport type GetPaymentsResponse = {\n status: boolean;\n code: string;\n payments: Payment[];\n pagination: Pagination;\n};\n\nexport type CreatePaymentItemInput = {\n productId: string;\n quantity: number;\n};\n\nexport type CreatePaymentInput = {\n name: string;\n email: string;\n cpf?: string;\n gateway: PaymentCreateGateway;\n coupon?: string | null;\n metadata?: Record<string, unknown>;\n items: CreatePaymentItemInput[];\n};\n\nexport type CreatePaymentResponse = {\n status: boolean;\n data: {\n service: {\n type: string;\n method: string;\n payment: string;\n };\n payment: {\n uuid: string;\n url?: string;\n qr_code?: {\n image: string;\n base_64: string;\n };\n };\n };\n};\n\nexport type UpdatePaymentInput = {\n shipment?: PaymentShipmentStatus;\n metadata?: Record<string, unknown>;\n};\n\nexport type UpdatePaymentResponse = {\n status: boolean;\n code: string;\n payment: {\n id: string;\n status: PaymentStatus;\n shipment?: PaymentShipmentStatus;\n metadata?: Record<string, unknown> | null;\n };\n};\n\nexport type DeletePaymentResponse = {\n status: boolean;\n code: string;\n message: string;\n};\n\nexport class Payments {\n constructor(private core: CoreClient) {}\n\n get(storeId: string, input: GetPaymentsInput = {}) {\n return getPayments(this.core, storeId, input);\n }\n\n filter(storeId: string, input: FilterPaymentsInput = {}) {\n return filterPayments(this.core, storeId, input);\n }\n\n post(storeId: string, input: CreatePaymentInput) {\n return createPayment(this.core, storeId, input);\n }\n\n put(storeId: string, paymentId: string, input: UpdatePaymentInput) {\n return updatePayment(this.core, storeId, paymentId, input);\n }\n\n delete(storeId: string, paymentId: string) {\n return deletePayment(this.core, storeId, paymentId);\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeleteProductResponse } from \"../index\";\n\nexport async function deleteProduct(\n core: CoreClient,\n storeId: string,\n productId: string,\n): Promise<DeleteProductResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeleteProductResponse>(\n `/stores/${storeId}/products/${productId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetProductsInput, GetProductsResponse } from \"../index\";\n\nexport async function getProducts(\n core: CoreClient,\n storeId: string,\n input: GetProductsInput = {},\n): Promise<GetProductsResponse> {\n const { data } = await core.http.get<GetProductsResponse>(\n `/stores/${storeId}/products`,\n {\n params: {\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetProductByIdResponse } from \"../index\";\n\nexport async function getProductById(\n core: CoreClient,\n storeId: string,\n productId: string,\n): Promise<GetProductByIdResponse> {\n const { data } = await core.http.get<GetProductByIdResponse>(\n `/stores/${storeId}/products/${productId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreateProductInput, CreateProductResponse } from \"../index\";\n\nexport async function createProduct(\n core: CoreClient,\n storeId: string,\n input: CreateProductInput,\n): Promise<CreateProductResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.post<CreateProductResponse>(\n `/stores/${storeId}/products`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { UpdateProductInput, UpdateProductResponse } from \"../index\";\n\nexport async function updateProduct(\n core: CoreClient,\n storeId: string,\n productId: string,\n input: UpdateProductInput,\n): Promise<UpdateProductResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<UpdateProductResponse>(\n `/stores/${storeId}/products/${productId}`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { ReorderProductsResponse } from \"../index\";\n\nexport async function reorderProducts(\n core: CoreClient,\n storeId: string,\n productIds: string[],\n): Promise<ReorderProductsResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<ReorderProductsResponse>(\n `/stores/${storeId}/products/reorder`,\n { productIds },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deleteProduct } from \"./http/delete\";\nimport { getProducts } from \"./http/get\";\nimport { getProductById } from \"./http/get-by-id\";\nimport { createProduct } from \"./http/post\";\nimport { updateProduct } from \"./http/put\";\nimport { reorderProducts } from \"./http/reorder\";\n\nexport type ProductDelivery = \"DIGITAL\" | \"PHYSICAL\";\n\nexport type ProductCategoryRef = {\n id: string;\n name: string;\n};\n\nexport type Product = {\n id: string;\n name: string;\n disabled: boolean;\n position: number;\n description: string | null;\n price: number;\n image: string | null;\n delivery: ProductDelivery;\n stock: number;\n sold: number;\n storeId: string;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n categories?: ProductCategoryRef[];\n};\n\nexport type Pagination = {\n page: number;\n limit: number;\n total: number;\n totalPages: number;\n};\n\nexport type GetProductsInput = {\n page?: number;\n limit?: number;\n};\n\nexport type CreateProductInput = {\n name: string;\n image?: string | null;\n description?: string | null;\n categoryIds?: string[];\n delivery: ProductDelivery;\n price: number;\n stock?: number;\n disabled?: boolean;\n metadata?: Record<string, unknown> | null;\n};\n\nexport type UpdateProductInput = {\n name?: string;\n image?: string | null;\n description?: string | null;\n categoryIds?: string[];\n delivery?: ProductDelivery;\n price?: number;\n stock?: number;\n disabled?: boolean;\n position?: number;\n metadata?: Record<string, unknown> | null;\n};\n\nexport type GetProductsResponse = {\n status: boolean;\n code: string;\n products: Product[];\n pagination: Pagination;\n};\n\nexport type GetProductByIdResponse = {\n status: boolean;\n code: string;\n product: Product;\n};\n\nexport type CreateProductResponse = {\n status: boolean;\n code: string;\n product: Product;\n};\n\nexport type UpdateProductResponse = {\n status: boolean;\n code: string;\n product: Product;\n};\n\nexport type DeleteProductResponse = {\n status: boolean;\n code: string;\n};\n\nexport type ReorderProductsResponse = {\n status: boolean;\n code: string;\n};\n\nexport class Products {\n constructor(private core: CoreClient) {}\n\n get(storeId: string, input: GetProductsInput = {}) {\n return getProducts(this.core, storeId, input);\n }\n\n getById(storeId: string, productId: string) {\n return getProductById(this.core, storeId, productId);\n }\n\n post(storeId: string, input: CreateProductInput) {\n return createProduct(this.core, storeId, input);\n }\n\n put(storeId: string, productId: string, input: UpdateProductInput) {\n return updateProduct(this.core, storeId, productId, input);\n }\n\n delete(storeId: string, productId: string) {\n return deleteProduct(this.core, storeId, productId);\n }\n\n reorder(storeId: string, productIds: string[]) {\n return reorderProducts(this.core, storeId, productIds);\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeleteStoreResponse } from \"../index\";\n\nexport async function deleteStore(\n core: CoreClient,\n storeId: string,\n): Promise<DeleteStoreResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeleteStoreResponse>(\n `/stores/${storeId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetStoresInput, GetStoresResponse } from \"../index\";\n\nexport async function getStores(\n core: CoreClient,\n input: GetStoresInput = {},\n): Promise<GetStoresResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetStoresResponse>(\"/stores\", {\n params: {\n page: input.page,\n limit: input.limit,\n },\n });\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetStoreByIdResponse } from \"../index\";\n\nexport async function getStoreById(\n core: CoreClient,\n storeId: string,\n): Promise<GetStoreByIdResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetStoreByIdResponse>(\n `/stores/${storeId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreateStoreInput, CreateStoreResponse } from \"../index\";\n\nexport async function createStore(\n core: CoreClient,\n input: CreateStoreInput,\n): Promise<CreateStoreResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.post<CreateStoreResponse>(\"/stores\", input);\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { UpdateStoreInput, UpdateStoreResponse } from \"../index\";\n\nexport async function updateStore(\n core: CoreClient,\n storeId: string,\n input: UpdateStoreInput,\n): Promise<UpdateStoreResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<UpdateStoreResponse>(\n `/stores/${storeId}`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { ReorderStoresResponse } from \"../index\";\n\nexport async function reorderStores(\n core: CoreClient,\n storeIds: string[],\n): Promise<ReorderStoresResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<ReorderStoresResponse>(\n \"/stores/reorder\",\n { storeIds },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deleteStore } from \"./http/delete\";\nimport { getStores } from \"./http/get\";\nimport { getStoreById } from \"./http/get-by-id\";\nimport { createStore } from \"./http/post\";\nimport { updateStore } from \"./http/put\";\nimport { reorderStores } from \"./http/reorder\";\n\n/**\n * Templates válidos para loja.\n */\nexport type StoreTemplate = \"PERSONALIZADO\" | \"N/A\";\n\n/**\n * Tipo do domínio informado no payload da loja.\n */\nexport type StoreDomainType = \"CUSTOM\" | \"DEFAULT\";\n\n/**\n * Estrutura de domínio para criação/atualização.\n */\nexport type StoreDomainInput = {\n type: StoreDomainType;\n value: string;\n};\n\n/**\n * Modelo base de loja retornado nos endpoints de listagem e upsert.\n */\nexport type Store = {\n id: string;\n name: string;\n position: number;\n description: string | null;\n image: string | null;\n domain: string;\n template: StoreTemplate;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n};\n\n/**\n * Modelo detalhado retornado por `GET /stores/:storeId`.\n */\nexport type StoreDetails = Store & {\n ownerId?: string;\n deletedAt?: string | null;\n categories?: unknown[];\n products?: unknown[];\n coupons?: unknown[];\n payment?: unknown[];\n};\n\n/**\n * Metadados de paginação padrão da API.\n */\nexport type Pagination = {\n page: number;\n limit: number;\n total: number;\n totalPages: number;\n};\n\n/**\n * Query params de listagem de lojas.\n */\nexport type GetStoresInput = {\n page?: number;\n limit?: number;\n};\n\n/**\n * Payload para criação de loja (`POST /stores`).\n */\nexport type CreateStoreInput = {\n template: StoreTemplate;\n name?: string;\n description?: string | null;\n image?: string | null;\n metadata?: Record<string, unknown> | null;\n domain?: StoreDomainInput | null;\n position?: number;\n};\n\n/**\n * Payload para atualização de loja (`PUT /stores/:storeId`).\n *\n * Observação: no endpoint de update, todos os campos são opcionais,\n * mas a API exige ao menos 1 campo no body.\n */\nexport type UpdateStoreInput = {\n template?: StoreTemplate;\n name?: string;\n description?: string | null;\n image?: string | null;\n metadata?: Record<string, unknown> | null;\n domain?: StoreDomainInput | null;\n position?: number;\n};\n\n/**\n * Resposta de listagem de lojas.\n */\nexport type GetStoresResponse = {\n status: boolean;\n code: string;\n stores: Store[];\n pagination: Pagination;\n};\n\n/**\n * Resposta de consulta por ID.\n */\nexport type GetStoreByIdResponse = {\n status: boolean;\n code: string;\n store: StoreDetails;\n};\n\n/**\n * Resposta de criação.\n */\nexport type CreateStoreResponse = {\n status: boolean;\n code: string;\n store: Store;\n};\n\n/**\n * Resposta de atualização.\n */\nexport type UpdateStoreResponse = {\n status: boolean;\n code: string;\n store: Store;\n};\n\n/**\n * Resposta de exclusão.\n */\nexport type DeleteStoreResponse = {\n status: boolean;\n code: string;\n};\n\n/**\n * Resposta de reordenação.\n */\nexport type ReorderStoresResponse = {\n status: boolean;\n code: string;\n};\n\n/**\n * Cliente de alto nível para operações do módulo de lojas.\n */\nexport class Stores {\n /**\n * @param core Cliente base da SDK.\n */\n constructor(private core: CoreClient) {}\n\n /**\n * Lista lojas da conta com suporte a paginação.\n */\n get(input: GetStoresInput = {}) {\n return getStores(this.core, input);\n }\n\n /**\n * Busca uma loja pelo ID.\n */\n getById(storeId: string) {\n return getStoreById(this.core, storeId);\n }\n\n /**\n * Cria uma nova loja.\n */\n post(input: CreateStoreInput) {\n return createStore(this.core, input);\n }\n\n /**\n * Atualiza uma loja existente.\n */\n put(storeId: string, input: UpdateStoreInput) {\n return updateStore(this.core, storeId, input);\n }\n\n /**\n * Exclui uma loja pelo ID.\n */\n delete(storeId: string) {\n return deleteStore(this.core, storeId);\n }\n\n /**\n * Reordena lojas pelo array final de IDs.\n */\n reorder(storeIds: string[]) {\n return reorderStores(this.core, storeIds);\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeleteWebhookInput, DeleteWebhookResponse } from \"../index\";\n\nexport async function deleteWebhook(\n core: CoreClient,\n storeId: string,\n input: DeleteWebhookInput,\n): Promise<DeleteWebhookResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeleteWebhookResponse>(\n `/stores/${storeId}/webhooks`,\n {\n data: input,\n },\n );\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetWebhooksResponse } from \"../index\";\n\nexport async function getWebhooks(\n core: CoreClient,\n storeId: string,\n): Promise<GetWebhooksResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetWebhooksResponse>(\n `/stores/${storeId}/webhooks`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreateWebhookInput, CreateWebhookResponse } from \"../index\";\n\nexport async function createWebhook(\n core: CoreClient,\n storeId: string,\n input: CreateWebhookInput,\n): Promise<CreateWebhookResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.post<CreateWebhookResponse>(\n `/stores/${storeId}/webhooks`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deleteWebhook } from \"./http/delete\";\nimport { getWebhooks } from \"./http/get\";\nimport { createWebhook } from \"./http/post\";\n\n/**\n * Resposta de listagem de webhooks por loja.\n */\nexport type GetWebhooksResponse = {\n webhooks: string[];\n max: number;\n};\n\n/**\n * Payload para criar webhook em uma loja.\n */\nexport type CreateWebhookInput = {\n url: string;\n};\n\n/**\n * Resposta de criação de webhook.\n */\nexport type CreateWebhookResponse = {\n status: boolean;\n code: string;\n webhook: string;\n};\n\n/**\n * Payload para remover webhook de uma loja.\n */\nexport type DeleteWebhookInput = {\n url: string;\n};\n\n/**\n * Resposta de remoção de webhook.\n */\nexport type DeleteWebhookResponse = {\n status: boolean;\n code: string;\n};\n\n/**\n * Cliente de alto nível para operações de webhooks da loja.\n */\nexport class Webhooks {\n /**\n * @param core Cliente base da SDK.\n */\n constructor(private core: CoreClient) {}\n\n /**\n * Lista os webhooks cadastrados para uma loja.\n */\n get(storeId: string) {\n return getWebhooks(this.core, storeId);\n }\n\n /**\n * Adiciona um webhook em uma loja.\n */\n post(storeId: string, input: CreateWebhookInput) {\n return createWebhook(this.core, storeId, input);\n }\n\n /**\n * Remove um webhook de uma loja.\n */\n delete(storeId: string, input: DeleteWebhookInput) {\n return deleteWebhook(this.core, storeId, input);\n }\n\n /**\n * Descriptografa e valida o payload recebido no webhook de assinatura.\n *\n * Espera um payload no formato `iv:encrypted` (ambos em base64), criptografado\n * com AES-256-CBC usando a chave informada.\n */\n async decrypty(\n secret: string,\n payload: string,\n ): Promise<Record<string, unknown>> {\n if (!secret) {\n throw new Error(\"SECRET_KEY_REQUIRED\");\n }\n\n if (!payload || typeof payload !== \"string\") {\n throw new Error(\"INVALID_PAYLOAD_FORMAT\");\n }\n\n const [ivB64, encrypted] = payload.split(\":\");\n if (!ivB64 || !encrypted) {\n throw new Error(\"INVALID_PAYLOAD_FORMAT\");\n }\n\n const iv = base64ToBytes(ivB64);\n const encryptedBytes = base64ToBytes(encrypted);\n const secretBytes = new TextEncoder().encode(secret);\n\n const keyHash = await globalThis.crypto.subtle.digest(\n \"SHA-256\",\n secretBytes,\n );\n const cryptoKey = await globalThis.crypto.subtle.importKey(\n \"raw\",\n keyHash,\n { name: \"AES-CBC\" },\n false,\n [\"decrypt\"],\n );\n const decryptedBuffer = await globalThis.crypto.subtle.decrypt(\n { name: \"AES-CBC\", iv: toArrayBuffer(iv) },\n cryptoKey,\n toArrayBuffer(encryptedBytes),\n );\n const decrypted = new TextDecoder().decode(decryptedBuffer);\n\n return JSON.parse(decrypted) as Record<string, unknown>;\n }\n\n /**\n * Alias com nome corrigido para descriptografar payload de webhook.\n */\n async decrypt(\n secret: string,\n payload: string,\n ): Promise<Record<string, unknown>> {\n return this.decrypty(secret, payload);\n }\n\n /**\n * Alias retrocompatível para quem já usa `parseSubscriptionPayload`.\n */\n async parseSubscriptionPayload(\n payload: string,\n secret: string,\n ): Promise<Record<string, unknown>> {\n return this.decrypty(secret, payload);\n }\n}\n\nfunction base64ToBytes(base64: string): Uint8Array {\n const binary = atob(base64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i += 1) {\n bytes[i] = binary.charCodeAt(i);\n }\n return bytes;\n}\n\nfunction toArrayBuffer(bytes: Uint8Array): ArrayBuffer {\n return bytes.buffer.slice(\n bytes.byteOffset,\n bytes.byteOffset + bytes.byteLength,\n ) as ArrayBuffer;\n}\n","import { type ClientOptions, CoreClient } from \"./core/client\";\nimport { Categories } from \"./core/module/categories/index\";\nimport { Coupons } from \"./core/module/coupons/index\";\nimport { Pages } from \"./core/module/pages/index\";\nimport { Payments } from \"./core/module/payments/index\";\nimport { Products } from \"./core/module/products/index\";\nimport { Stores } from \"./core/module/stores/index\";\nimport { Webhooks } from \"./core/module/webhooks/index\";\n\n/**\n * SDK principal da caBRAPI\n */\nexport class caBRAPI {\n public categories: Categories;\n public coupons: Coupons;\n public payments: Payments;\n public pages: Pages;\n public products: Products;\n public stores: Stores;\n public webhooks: Webhooks;\n\n constructor(options: ClientOptions) {\n const core = new CoreClient(options);\n\n this.categories = new Categories(core);\n this.coupons = new Coupons(core);\n this.payments = new Payments(core);\n this.pages = new Pages(core);\n this.products = new Products(core);\n this.stores = new Stores(core);\n this.webhooks = new Webhooks(core);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/core/http.ts","../src/core/client.ts","../src/core/module/categories/http/delete.ts","../src/core/module/categories/http/get.ts","../src/core/module/categories/http/get-by-id.ts","../src/core/module/categories/http/post.ts","../src/core/module/categories/http/put.ts","../src/core/module/categories/http/reorder.ts","../src/core/module/categories/index.ts","../src/core/module/coupons/http/delete.ts","../src/core/module/coupons/http/get.ts","../src/core/module/coupons/http/get-by-code.ts","../src/core/module/coupons/http/get-by-id.ts","../src/core/module/coupons/http/post.ts","../src/core/module/coupons/http/put.ts","../src/core/module/coupons/http/reorder.ts","../src/core/module/coupons/index.ts","../src/core/module/pages/http/delete.ts","../src/core/module/pages/http/get.ts","../src/core/module/pages/http/upsert.ts","../src/core/module/pages/index.ts","../src/core/module/payments/http/delete.ts","../src/core/module/payments/http/filter.ts","../src/core/module/payments/http/get.ts","../src/core/module/payments/http/post.ts","../src/core/module/payments/http/put.ts","../src/core/module/payments/index.ts","../src/core/module/products/http/delete.ts","../src/core/module/products/http/get.ts","../src/core/module/products/http/get-by-category.ts","../src/core/module/products/http/get-by-id.ts","../src/core/module/products/http/post.ts","../src/core/module/products/http/put.ts","../src/core/module/products/http/reorder.ts","../src/core/module/products/index.ts","../src/core/module/stores/http/delete.ts","../src/core/module/stores/http/get.ts","../src/core/module/stores/http/get-by-id.ts","../src/core/module/stores/http/post.ts","../src/core/module/stores/http/put.ts","../src/core/module/stores/http/reorder.ts","../src/core/module/stores/index.ts","../src/core/module/webhooks/http/delete.ts","../src/core/module/webhooks/http/get.ts","../src/core/module/webhooks/http/post.ts","../src/core/module/webhooks/index.ts","../src/index.ts"],"names":["buildURL","base","path","buildQuery","params","esc","query","v","k","createAxios","cfg","baseURL","timeout","requestInterceptors","responseInterceptors","runRequest","config","conf","i","e","url","headers","controller","to","timer","opts","raw","err","text","data","res","fulfilled","rejected","options","isBrowser","CoreClient","apiKey","deleteCategory","core","storeId","categoryId","getCategories","input","getCategoryById","createCategory","updateCategory","reorderCategories","categoryIds","Categories","deleteCoupon","couponId","getCoupons","getCouponByCode","code","getCouponById","createCoupon","updateCoupon","reorderCoupons","couponIds","Coupons","deletePage","domain","getPage","upsertPage","Pages","deletePayment","paymentId","filterPayments","getPayments","createPayment","updatePayment","Payments","deleteProduct","productId","getProducts","getProductsByCategory","getProductById","createProduct","updateProduct","reorderProducts","productIds","Products","deleteStore","getStores","getStoreById","createStore","updateStore","reorderStores","storeIds","Stores","deleteWebhook","getWebhooks","createWebhook","Webhooks","secret","payload","ivB64","encrypted","iv","base64ToBytes","encryptedBytes","secretBytes","keyHash","cryptoKey","decryptedBuffer","toArrayBuffer","decrypted","base64","binary","bytes","caBRAPI"],"mappings":"AA+BA,SAASA,GAASC,CAAAA,CAAcC,CAAAA,CAAc,CAC5C,OAAI,eAAe,IAAA,CAAKA,CAAI,CAAA,CAAUA,CAAAA,CAC/B,GAAGD,CAAAA,CAAK,OAAA,CAAQ,KAAA,CAAO,EAAE,CAAC,CAAA,CAAA,EAAIC,CAAAA,CAAK,OAAA,CAAQ,KAAA,CAAO,EAAE,CAAC,CAAA,CAC9D,CAEA,SAASC,GAAWC,CAAAA,CAAkC,CACpD,GAAI,CAACA,EAAQ,OAAO,EAAA,CACpB,IAAMC,CAAAA,CAAM,kBAAA,CACNC,EAAQ,MAAA,CAAO,OAAA,CAAQF,CAAM,CAAA,CAChC,OAAO,CAAC,EAAGG,CAAC,IAAyBA,CAAAA,EAAM,IAAI,CAAA,CAC/C,GAAA,CAAI,CAAC,CAACC,CAAAA,CAAGD,CAAC,CAAA,GAAM,CAAA,EAAGF,EAAIG,CAAC,CAAC,CAAA,CAAA,EAAIH,CAAAA,CAAI,OAAOE,CAAC,CAAC,CAAC,CAAA,CAAE,EAC7C,IAAA,CAAK,GAAG,CAAA,CACX,OAAOD,EAAQ,CAAA,CAAA,EAAIA,CAAK,GAAK,EAC/B,CAEO,SAASG,CAAAA,CAAYC,CAAAA,CAAmB,EAAC,CAAG,CACjD,IAAMC,CAAAA,CAAUD,CAAAA,CAAI,OAAA,EAAW,6BACzBE,CAAAA,CAAUF,CAAAA,CAAI,OAAA,EAAW,GAAA,CAEzBG,EAAyD,EAAC,CAC1DC,EAAqD,EAAC,CAE5D,eAAeC,CAAAA,CACbC,CAAAA,CAC2B,CAC3B,IAAIC,E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,CAAA,CAAGA,CAAAA,CAAI0F,EAAO,MAAA,CAAQ1F,CAAAA,EAAK,CAAA,CACtC2F,CAAAA,CAAM3F,CAAC,CAAA,CAAI0F,CAAAA,CAAO,UAAA,CAAW1F,CAAC,EAEhC,OAAO2F,CACT,CAEA,SAASJ,GAAcI,CAAAA,CAAgC,CACrD,OAAOA,CAAAA,CAAM,MAAA,CAAO,MAClBA,CAAAA,CAAM,UAAA,CACNA,CAAAA,CAAM,UAAA,CAAaA,EAAM,UAC3B,CACF,CCjJO,IAAMC,GAAN,KAAc,CASnB,WAAA,CAAY7E,CAAAA,CAAwB,CAClC,IAAMK,CAAAA,CAAO,IAAIH,CAAAA,CAAWF,CAAO,EAEnC,IAAA,CAAK,UAAA,CAAa,IAAIe,CAAAA,CAAWV,CAAI,CAAA,CACrC,IAAA,CAAK,OAAA,CAAU,IAAIqB,EAAQrB,CAAI,CAAA,CAC/B,IAAA,CAAK,QAAA,CAAW,IAAIiC,CAAAA,CAASjC,CAAI,EACjC,IAAA,CAAK,KAAA,CAAQ,IAAI0B,CAAAA,CAAM1B,CAAI,CAAA,CAC3B,IAAA,CAAK,SAAW,IAAI2C,CAAAA,CAAS3C,CAAI,CAAA,CACjC,KAAK,MAAA,CAAS,IAAImD,CAAAA,CAAOnD,CAAI,EAC7B,IAAA,CAAK,QAAA,CAAW,IAAIuD,CAAAA,CAASvD,CAAI,EACnC,CACF","file":"index.js","sourcesContent":["/**\n * Adapter HTTP simples usando fetch (nativo).\n * Exporta `createAxios` para compatibilidade com restante do código.\n */\nexport type AxiosConfig = {\n baseURL?: string;\n apiKey?: string;\n timeout?: number;\n};\n\nexport type AxiosRequestConfig = {\n url?: string;\n params?: Record<string, unknown>;\n headers?: Record<string, string>;\n data?: unknown;\n timeout?: number;\n};\n\nexport type AxiosResponse<T = unknown> = {\n data: T;\n status: number;\n statusText: string;\n headers: Record<string, string>;\n config?: AxiosRequestConfig;\n};\n\ntype Interceptor<V> = {\n fulfilled: (v: V) => V | Promise<V>;\n rejected?: (err: unknown) => unknown;\n};\n\nfunction buildURL(base: string, path: string) {\n if (/^https?:\\/\\//.test(path)) return path;\n return `${base.replace(/\\/$/, \"\")}/${path.replace(/^\\//, \"\")}`;\n}\n\nfunction buildQuery(params?: Record<string, unknown>) {\n if (!params) return \"\";\n const esc = encodeURIComponent;\n const query = Object.entries(params)\n .filter(([, v]) => v !== undefined && v !== null)\n .map(([k, v]) => `${esc(k)}=${esc(String(v))}`)\n .join(\"&\");\n return query ? `?${query}` : \"\";\n}\n\nexport function createAxios(cfg: AxiosConfig = {}) {\n const baseURL = cfg.baseURL ?? \"https://api.cabrapi.com.br\";\n const timeout = cfg.timeout ?? 30000;\n\n const requestInterceptors: Interceptor<AxiosRequestConfig>[] = [];\n const responseInterceptors: Interceptor<AxiosResponse>[] = [];\n\n async function runRequest<T = unknown>(\n config: AxiosRequestConfig & { method: string },\n ): Promise<AxiosResponse<T>> {\n let conf: AxiosRequestConfig = { ...config };\n\n for (const i of requestInterceptors) {\n try {\n // allow interceptor to modify config\n conf = await i.fulfilled(conf);\n } catch (e) {\n if (i.rejected) i.rejected(e);\n throw e;\n }\n }\n\n const url =\n buildURL(baseURL, conf.url ?? \"\") +\n buildQuery(conf.params as Record<string, unknown> | undefined);\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...(conf.headers || {}),\n };\n\n if (cfg.apiKey) headers.Authorization = `${cfg.apiKey}`;\n\n const controller = new AbortController();\n const to = conf.timeout ?? timeout;\n const timer = setTimeout(() => controller.abort(), to);\n\n const opts: RequestInit = {\n method: config.method.toUpperCase(),\n headers,\n signal: controller.signal,\n };\n\n if (conf.data !== undefined && config.method.toLowerCase() !== \"get\") {\n opts.body =\n typeof conf.data === \"string\" ? conf.data : JSON.stringify(conf.data);\n }\n\n let raw: Response;\n try {\n raw = await fetch(url, opts);\n clearTimeout(timer);\n } catch (err: unknown) {\n clearTimeout(timer);\n if (err && typeof err === \"object\") {\n // pass to caller\n }\n throw err;\n }\n\n const text = await raw.text();\n let data: unknown = null;\n try {\n data = text ? JSON.parse(text) : null;\n } catch {\n data = text;\n }\n\n const res: AxiosResponse<T> = {\n data: data as T,\n status: raw.status,\n statusText: raw.statusText,\n headers: Object.fromEntries(raw.headers.entries()),\n config: conf,\n };\n\n for (const i of responseInterceptors) {\n try {\n // allow interceptor to transform response\n // eslint-disable-next-line no-await-in-loop\n await i.fulfilled(res);\n } catch (e) {\n if (i.rejected) i.rejected(e);\n throw e;\n }\n }\n\n if (!raw.ok) {\n const maybeError =\n typeof res.data === \"object\" &&\n res.data !== null &&\n \"error\" in (res.data as Record<string, unknown>)\n ? (res.data as Record<string, unknown>).error\n : undefined;\n const err = maybeError ?? res.data ?? { status: raw.status };\n throw err as unknown;\n }\n\n return res;\n }\n\n const instance = {\n interceptors: {\n request: {\n use(\n fulfilled: (\n c: AxiosRequestConfig,\n ) => AxiosRequestConfig | Promise<AxiosRequestConfig>,\n rejected?: (e: unknown) => unknown,\n ) {\n requestInterceptors.push({ fulfilled, rejected });\n },\n },\n response: {\n use(\n fulfilled: (\n r: AxiosResponse,\n ) => AxiosResponse | Promise<AxiosResponse>,\n rejected?: (e: unknown) => unknown,\n ) {\n responseInterceptors.push({ fulfilled, rejected });\n },\n },\n },\n\n async get<T = unknown>(\n url: string,\n options: AxiosRequestConfig = {},\n ): Promise<AxiosResponse<T>> {\n return runRequest<T>({ ...options, url, method: \"get\" });\n },\n\n async post<T = unknown>(\n url: string,\n data?: unknown,\n options: AxiosRequestConfig = {},\n ): Promise<AxiosResponse<T>> {\n return runRequest<T>({ ...options, url, data, method: \"post\" });\n },\n\n async put<T = unknown>(\n url: string,\n data?: unknown,\n options: AxiosRequestConfig = {},\n ): Promise<AxiosResponse<T>> {\n return runRequest<T>({ ...options, url, data, method: \"put\" });\n },\n\n async delete<T = unknown>(\n url: string,\n options: AxiosRequestConfig = {},\n ): Promise<AxiosResponse<T>> {\n return runRequest<T>({ ...options, url, method: \"delete\" });\n },\n\n // compatibility: allow calling instance(config)\n async request<T = unknown>(\n options: AxiosRequestConfig & { method: string },\n ): Promise<AxiosResponse<T>> {\n return runRequest<T>(options);\n },\n };\n\n return instance;\n}\n","import { createAxios } from \"./http\";\n\n/**\n * Tipo derivado da instância do Axios\n * (evita problemas no build de types)\n */\ntype AxiosInstance = ReturnType<typeof createAxios>;\n\n/**\n * Modos disponíveis\n */\nexport type ClientMode = \"public\" | \"private\";\n\n/**\n * Opções do cliente\n */\nexport type ClientOptions = {\n type: ClientMode;\n config?: {\n key?: string;\n baseURL?: string;\n };\n};\n\n/**\n * Detecta ambiente\n */\nconst isBrowser =\n typeof window !== \"undefined\" && typeof document !== \"undefined\";\n\n/**\n * Cliente base da caBRAPI\n */\nexport class CoreClient {\n public http: AxiosInstance;\n public mode: ClientMode;\n public isBrowser: boolean;\n\n constructor(options: ClientOptions) {\n this.mode = options.type;\n this.isBrowser = isBrowser;\n\n // 🔒 validação backend\n if (this.mode === \"private\" && !options.config?.key && !this.isBrowser) {\n throw new Error(\"API key é obrigatória no modo 'private'.\");\n }\n\n // 🔐 só backend usa key\n const apiKey =\n !this.isBrowser && this.mode === \"private\"\n ? options.config?.key\n : undefined;\n\n this.http = createAxios({ baseURL: options.config?.baseURL, apiKey });\n\n // ⚠️ aviso dev\n if (this.isBrowser && this.mode === \"private\") {\n console.warn(\n \"[caBRAPI] Modo 'private' detectado no navegador. API key ignorada.\",\n );\n }\n }\n\n /**\n * Está em modo privado (backend)\n */\n public isPrivate(): boolean {\n return !this.isBrowser && this.mode === \"private\";\n }\n\n /**\n * Está em modo público\n */\n public isPublic(): boolean {\n return this.isBrowser || this.mode === \"public\";\n }\n\n /**\n * Garante execução no backend\n */\n public assertPrivate(): void {\n if (!this.isPrivate()) {\n throw new Error(\n \"Este método é privado e não pode ser usado no navegador.\",\n );\n }\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeleteCategoryResponse } from \"../index\";\n\nexport async function deleteCategory(\n core: CoreClient,\n storeId: string,\n categoryId: string,\n): Promise<DeleteCategoryResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeleteCategoryResponse>(\n `/stores/${storeId}/categories/${categoryId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetCategoriesInput, GetCategoriesResponse } from \"../index\";\n\nexport async function getCategories(\n core: CoreClient,\n storeId: string,\n input: GetCategoriesInput = {},\n): Promise<GetCategoriesResponse> {\n const { data } = await core.http.get<GetCategoriesResponse>(\n `/stores/${storeId}/categories`,\n {\n params: {\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetCategoryByIdResponse } from \"../index\";\n\nexport async function getCategoryById(\n core: CoreClient,\n storeId: string,\n categoryId: string,\n): Promise<GetCategoryByIdResponse> {\n const { data } = await core.http.get<GetCategoryByIdResponse>(\n `/stores/${storeId}/categories/${categoryId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreateCategoryInput, CreateCategoryResponse } from \"../index\";\n\nexport async function createCategory(\n core: CoreClient,\n storeId: string,\n input: CreateCategoryInput,\n): Promise<CreateCategoryResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.post<CreateCategoryResponse>(\n `/stores/${storeId}/categories`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { UpdateCategoryInput, UpdateCategoryResponse } from \"../index\";\n\nexport async function updateCategory(\n core: CoreClient,\n storeId: string,\n categoryId: string,\n input: UpdateCategoryInput,\n): Promise<UpdateCategoryResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<UpdateCategoryResponse>(\n `/stores/${storeId}/categories/${categoryId}`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { ReorderCategoriesResponse } from \"../index\";\n\nexport async function reorderCategories(\n core: CoreClient,\n storeId: string,\n categoryIds: string[],\n): Promise<ReorderCategoriesResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<ReorderCategoriesResponse>(\n `/stores/${storeId}/categories/reorder`,\n { categoryIds },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deleteCategory } from \"./http/delete\";\nimport { getCategories } from \"./http/get\";\nimport { getCategoryById } from \"./http/get-by-id\";\nimport { createCategory } from \"./http/post\";\nimport { updateCategory } from \"./http/put\";\nimport { reorderCategories } from \"./http/reorder\";\n\nexport type Category = {\n id: string;\n name: string;\n description: string | null;\n image: string | null;\n metadata: Record<string, unknown> | null;\n position: number;\n storeId: string;\n createdAt: string;\n updatedAt: string;\n};\n\nexport type CategoryDetails = Category & {\n products?: unknown[];\n coupons?: unknown[];\n};\n\nexport type Pagination = {\n page: number;\n limit: number;\n total: number;\n totalPages: number;\n};\n\nexport type GetCategoriesInput = {\n page?: number;\n limit?: number;\n};\n\nexport type CreateCategoryInput = {\n name?: string;\n description?: string | null;\n image?: string | null;\n metadata?: Record<string, unknown> | null;\n};\n\nexport type UpdateCategoryInput = {\n name?: string;\n description?: string | null;\n image?: string | null;\n metadata?: Record<string, unknown> | null;\n position?: number;\n};\n\nexport type GetCategoriesResponse = {\n status: boolean;\n code: string;\n categories: Category[];\n pagination: Pagination;\n};\n\nexport type GetCategoryByIdResponse = {\n status: boolean;\n code: string;\n category: CategoryDetails;\n};\n\nexport type CreateCategoryResponse = {\n status: boolean;\n code?: string;\n category: Category;\n};\n\nexport type UpdateCategoryResponse = {\n status: boolean;\n code: string;\n category: Category;\n};\n\nexport type DeleteCategoryResponse = {\n status: boolean;\n code: string;\n};\n\nexport type ReorderCategoriesResponse = {\n status: boolean;\n code: string;\n};\n\nexport class Categories {\n constructor(private core: CoreClient) {}\n\n get(storeId: string, input: GetCategoriesInput = {}) {\n return getCategories(this.core, storeId, input);\n }\n\n getById(storeId: string, categoryId: string) {\n return getCategoryById(this.core, storeId, categoryId);\n }\n\n post(storeId: string, input: CreateCategoryInput) {\n return createCategory(this.core, storeId, input);\n }\n\n put(storeId: string, categoryId: string, input: UpdateCategoryInput) {\n return updateCategory(this.core, storeId, categoryId, input);\n }\n\n delete(storeId: string, categoryId: string) {\n return deleteCategory(this.core, storeId, categoryId);\n }\n\n reorder(storeId: string, categoryIds: string[]) {\n return reorderCategories(this.core, storeId, categoryIds);\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeleteCouponResponse } from \"../index\";\n\nexport async function deleteCoupon(\n core: CoreClient,\n storeId: string,\n couponId: string,\n): Promise<DeleteCouponResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeleteCouponResponse>(\n `/stores/${storeId}/coupons/${couponId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetCouponsInput, GetCouponsResponse } from \"../index\";\n\nexport async function getCoupons(\n core: CoreClient,\n storeId: string,\n input: GetCouponsInput = {},\n): Promise<GetCouponsResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetCouponsResponse>(\n `/stores/${storeId}/coupons`,\n {\n params: {\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetCouponByCodeResponse } from \"../index\";\n\nexport async function getCouponByCode(\n core: CoreClient,\n storeId: string,\n code: string,\n): Promise<GetCouponByCodeResponse> {\n const { data } = await core.http.get<GetCouponByCodeResponse>(\n `/stores/${storeId}/coupons/${code}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetCouponByIdResponse } from \"../index\";\n\nexport async function getCouponById(\n core: CoreClient,\n storeId: string,\n couponId: string,\n): Promise<GetCouponByIdResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetCouponByIdResponse>(\n `/stores/${storeId}/coupons/uuid/${couponId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreateCouponInput, CreateCouponResponse } from \"../index\";\n\nexport async function createCoupon(\n core: CoreClient,\n storeId: string,\n input: CreateCouponInput,\n): Promise<CreateCouponResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.post<CreateCouponResponse>(\n `/stores/${storeId}/coupons`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { UpdateCouponInput, UpdateCouponResponse } from \"../index\";\n\nexport async function updateCoupon(\n core: CoreClient,\n storeId: string,\n couponId: string,\n input: UpdateCouponInput,\n): Promise<UpdateCouponResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<UpdateCouponResponse>(\n `/stores/${storeId}/coupons/${couponId}`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { ReorderCouponsResponse } from \"../index\";\n\nexport async function reorderCoupons(\n core: CoreClient,\n storeId: string,\n couponIds: string[],\n): Promise<ReorderCouponsResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<ReorderCouponsResponse>(\n `/stores/${storeId}/coupons/reorder`,\n { couponIds },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deleteCoupon } from \"./http/delete\";\nimport { getCoupons } from \"./http/get\";\nimport { getCouponByCode } from \"./http/get-by-code\";\nimport { getCouponById } from \"./http/get-by-id\";\nimport { createCoupon } from \"./http/post\";\nimport { updateCoupon } from \"./http/put\";\nimport { reorderCoupons } from \"./http/reorder\";\n\nexport type CouponRelationRef = {\n id: string;\n name: string;\n};\n\nexport type Coupon = {\n id: string;\n code: string;\n position: number;\n discount: number;\n useLimit: number;\n expiredAt: string | null;\n storeId?: string;\n products: CouponRelationRef[];\n categories: CouponRelationRef[];\n createdAt?: string;\n updatedAt?: string;\n};\n\nexport type Pagination = {\n page: number;\n limit: number;\n total: number;\n totalPages: number;\n};\n\nexport type GetCouponsInput = {\n page?: number;\n limit?: number;\n};\n\nexport type CreateCouponInput = {\n code: string;\n discount: number;\n useLimit?: number | null;\n expiredAt?: string | null;\n productIds?: string[];\n categoryIds?: string[];\n};\n\nexport type UpdateCouponInput = {\n code?: string;\n discount?: number;\n position?: number;\n useLimit?: number | null;\n expiredAt?: string | null;\n productIds?: string[];\n categoryIds?: string[];\n};\n\nexport type GetCouponsResponse = {\n status: boolean;\n code: string;\n coupons: Coupon[];\n pagination: Pagination;\n};\n\nexport type GetCouponByCodeResponse = {\n status: boolean;\n code: string;\n coupon: Coupon;\n};\n\nexport type GetCouponByIdResponse = {\n status: boolean;\n code: string;\n coupon: Coupon;\n};\n\nexport type CreateCouponResponse = {\n status: boolean;\n code: string;\n coupon: Coupon;\n};\n\nexport type UpdateCouponResponse = {\n status: boolean;\n code: string;\n coupon: Coupon;\n};\n\nexport type DeleteCouponResponse = {\n status: boolean;\n code: string;\n};\n\nexport type ReorderCouponsResponse = {\n status: boolean;\n code: string;\n};\n\nexport class Coupons {\n constructor(private core: CoreClient) {}\n\n get(storeId: string, input: GetCouponsInput = {}) {\n return getCoupons(this.core, storeId, input);\n }\n\n getByCode(storeId: string, code: string) {\n return getCouponByCode(this.core, storeId, code);\n }\n\n getById(storeId: string, couponId: string) {\n return getCouponById(this.core, storeId, couponId);\n }\n\n post(storeId: string, input: CreateCouponInput) {\n return createCoupon(this.core, storeId, input);\n }\n\n put(storeId: string, couponId: string, input: UpdateCouponInput) {\n return updateCoupon(this.core, storeId, couponId, input);\n }\n\n delete(storeId: string, couponId: string) {\n return deleteCoupon(this.core, storeId, couponId);\n }\n\n reorder(storeId: string, couponIds: string[]) {\n return reorderCoupons(this.core, storeId, couponIds);\n }\n}\n","import type { CoreClient } from \"../../../client\";\n\n/**\n * Resposta do endpoint de exclusão de página.\n */\ntype DeletePageResponse = {\n status: boolean;\n code: string;\n};\n\n/**\n * Remove a página publicada referente ao `domain` informado.\n *\n * Executa uma requisição `DELETE /pages/:domain`. Este endpoint é privado e\n * exige que o `CoreClient` esteja configurado em modo privado (backend).\n *\n * @param core - Instância do `CoreClient` (deve ser private).\n * @param domain - Domínio da página a remover (ex.: \"minhaloja.com.br\").\n * @returns Promise que resolve com `{ status, code }` retornado pela API.\n *\n * @throws {Error} Se `core.isPrivate()` for falso (tentativa de uso no navegador)\n * ou se a API retornar erro/HTTP failure.\n *\n * @example\n * ```ts\n * await deletePage(coreClient, \"loja.exemplo.com\");\n * ```\n */\nexport async function deletePage(\n core: CoreClient,\n domain: string,\n): Promise<{ status: boolean; code: string }> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeletePageResponse>(\n `/pages/${domain}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\n\n/**\n * Modelo de página retornado pela API de páginas.\n *\n * Observações:\n * - Campos `createdAt` e `updatedAt` são timestamps em ISO 8601.\n * - `version` pode ser usada pelo servidor para controle de versão do conteúdo.\n * - `store` é metadado opcional com informações da loja proprietária.\n */\nexport type Page = {\n html: string;\n template?: string;\n version?: string;\n createdAt?: string;\n updatedAt?: string;\n store?: {\n ownerId: string;\n id: string;\n };\n};\n\n/**\n * Estrutura padrão da resposta da API para operações de página.\n */\ntype PageResponse = {\n status: boolean;\n data: Page;\n};\n\n/**\n * Recupera a `Page` publicada para o `domain` informado.\n *\n * Faz uma chamada `GET /pages/:domain` usando o `CoreClient` fornecido.\n *\n * @param core - Instância de `CoreClient` que executa requisições HTTP.\n * @param domain - Domínio da página a ser recuperada (ex.: \"minha-loja.com\").\n * @returns Promise que resolve com um objeto contendo `status` e `data` (`Page`).\n *\n * @throws {Error} Se a resposta não contiver `data` (página não encontrada) ou se\n * houver erro de rede/HTTP lançado pelo `core.http`.\n *\n * @example\n * ```ts\n * const page = await getPage(coreClient, \"loja.exemplo.com\");\n * console.log(page.data.html);\n * ```\n */\nexport async function getPage(\n core: CoreClient,\n domain: string,\n): Promise<{ status: boolean; data: Page }> {\n const { data } = await core.http.get<PageResponse>(`/pages/${domain}`);\n\n if (!data?.data) {\n throw new Error(`Page not found: ${domain}`);\n }\n\n return {\n status: data.status,\n data: data.data,\n };\n}\n","import type { CoreClient } from \"../../../client\";\n\n/**\n * Dados necessários para criar ou atualizar uma página.\n */\nexport type PageUpsertInput = {\n domain: string;\n html: string;\n template?: string;\n};\n\n/**\n * Resposta do endpoint de upsert.\n */\ntype PageUpsertResponse = {\n status: boolean;\n code: string;\n};\n\n/**\n * Cria ou atualiza a página pública associada ao `input.domain`.\n *\n * Realiza uma requisição `PUT /pages/:domain` com o corpo contendo `html` e\n * `template` (se fornecido). Este endpoint é marcado como privado — deve ser\n * usado apenas por código backend que possua credenciais privadas.\n *\n * @param core - `CoreClient` configurado (deve estar em modo privado).\n * @param input - Dados da página a persistir: `domain`, `html`, `template?`.\n * @returns Promise que resolve com o objeto de resposta `{ status, code }`.\n *\n * @throws {Error} Se `core.isPrivate()` for falso (uso no navegador) ou se a\n * requisição HTTP falhar.\n *\n * @example\n * ```ts\n * await upsertPage(coreClient, {\n * domain: \"loja.exemplo.com\",\n * html: \"<html>...\",\n * template: \"landing-v2\",\n * });\n * ```\n */\nexport async function upsertPage(\n core: CoreClient,\n input: PageUpsertInput,\n): Promise<{ status: boolean; code: string }> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<PageUpsertResponse>(\n `/pages/${input.domain}`,\n {\n html: input.html,\n template: input.template,\n },\n );\n\n return data;\n}\n","/**\n * Módulo `Pages` — cliente de operação para páginas estáticas.\n *\n * Fornece wrappers de alto nível para recuperar, criar/atualizar e remover\n * representações HTML de páginas hospedadas em um domínio específico. Cada\n * operação delega a chamada HTTP para funções em `./http/*` e propaga erros\n * retornados pelo cliente HTTP subjacente.\n *\n */\nimport type { CoreClient } from \"../../client\";\nimport { deletePage } from \"./http/delete\";\nimport { getPage } from \"./http/get\";\nimport { upsertPage } from \"./http/upsert\";\n\n/**\n * Representa uma página\n */\n/**\n * Representa uma página estática gerida pela API.\n *\n * Propriedades:\n * - `domain`: Identificador único da página. Geralmente host ou host+path.\n * - `html`: Conteúdo HTML completo que será servido para esse domínio.\n * - `template`: (opcional) nome do template ou layout que o servidor pode aplicar.\n *\n * ```\n */\nexport type Page = {\n domain: string;\n html: string;\n template?: string;\n};\n\n/**\n * Client de alto nível para operações relacionadas a `Page`.\n *\n * Instancie com um `CoreClient` já autenticado/configurado. Os métodos desta\n * classe são pequenos wrappers que delegam a execução para as funções HTTP\n * específicas em `./http/*`, mantendo a assinatura orientada ao domínio.\n */\nexport class Pages {\n /**\n * Construtor.\n * @param core - Instância de `CoreClient` usada para efetuar chamadas HTTP.\n */\n constructor(private core: CoreClient) {}\n\n /**\n * Recupera a página associada ao `domain` informado.\n *\n * @param domain - Identificador da página a recuperar (ex.: \"exemplo.com\").\n * @returns Uma promise que resolve com o objeto `Page` caso exista.\n * @throws Erros de rede/HTTP ou erro retornado pela API se a página não existir.\n *\n */\n get(domain: string) {\n return getPage(this.core, domain);\n }\n\n /**\n * Cria ou atualiza uma página.\n *\n * Se a página para o `domain` já existir, o servidor realizará um update;\n * caso contrário, criará uma nova entrada.\n *\n * @param input - Objeto com os dados da página:\n * - `domain`: chave única da página.\n * - `html`: conteúdo HTML completo.\n * - `template` (opcional): nome do template a aplicar.\n * @returns Uma promise que resolve com o `Page` criado/atualizado ou com metadados retornados pela API.\n * @throws Erros de validação, rede ou HTTP conforme a resposta da API.\n *\n */\n upsert(input: { domain: string; html: string; template?: string }) {\n return upsertPage(this.core, input);\n }\n\n /**\n * Remove a página associada ao `domain`.\n *\n * @param domain - Identificador da página a remover.\n * @returns Uma promise que resolve quando a exclusão for confirmada pelo servidor.\n * @throws Erro se a operação falhar (por exemplo, página não encontrada ou erro de permissão).\n *\n */\n delete(domain: string) {\n return deletePage(this.core, domain);\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeletePaymentResponse } from \"../index\";\n\nexport async function deletePayment(\n core: CoreClient,\n storeId: string,\n paymentId: string,\n): Promise<DeletePaymentResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeletePaymentResponse>(\n `/stores/${storeId}/payments/${paymentId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { FilterPaymentsInput, FilterPaymentsResponse } from \"../index\";\n\nexport async function filterPayments(\n core: CoreClient,\n storeId: string,\n input: FilterPaymentsInput = {},\n): Promise<FilterPaymentsResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<FilterPaymentsResponse>(\n `/stores/${storeId}/payments/filter`,\n {\n params: {\n id: input.id,\n uuid: input.uuid,\n status: input.status,\n name: input.name,\n email: input.email,\n cpf: input.cpf,\n price: input.price,\n minPrice: input.minPrice,\n maxPrice: input.maxPrice,\n coupon: input.coupon,\n gateway: input.gateway,\n shipment: input.shipment,\n createdAtFrom: input.createdAtFrom,\n createdAtTo: input.createdAtTo,\n updatedAtFrom: input.updatedAtFrom,\n updatedAtTo: input.updatedAtTo,\n productId: input.productId,\n metadataKey: input.metadataKey,\n metadataValue: input.metadataValue,\n sortBy: input.sortBy,\n sortOrder: input.sortOrder,\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetPaymentsInput, GetPaymentsResponse } from \"../index\";\n\nexport async function getPayments(\n core: CoreClient,\n storeId: string,\n input: GetPaymentsInput = {},\n): Promise<GetPaymentsResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetPaymentsResponse>(\n `/stores/${storeId}/payments`,\n {\n params: {\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreatePaymentInput, CreatePaymentResponse } from \"../index\";\n\nexport async function createPayment(\n core: CoreClient,\n storeId: string,\n input: CreatePaymentInput,\n): Promise<CreatePaymentResponse> {\n const { data } = await core.http.post<CreatePaymentResponse>(\n `/stores/${storeId}/payments`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { UpdatePaymentInput, UpdatePaymentResponse } from \"../index\";\n\nexport async function updatePayment(\n core: CoreClient,\n storeId: string,\n paymentId: string,\n input: UpdatePaymentInput,\n): Promise<UpdatePaymentResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<UpdatePaymentResponse>(\n `/stores/${storeId}/payments/${paymentId}`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deletePayment } from \"./http/delete\";\nimport { filterPayments } from \"./http/filter\";\nimport { getPayments } from \"./http/get\";\nimport { createPayment } from \"./http/post\";\nimport { updatePayment } from \"./http/put\";\n\nexport type PaymentStatus =\n | \"PENDING\"\n | \"APPROVED\"\n | \"REJECTED\"\n | \"CANCELLED\"\n | \"REFUNDED\"\n | \"CHARGED_BACK\"\n | \"EXPIRED\";\n\nexport type PaymentGateway = \"MERCADOPAGO\" | \"EFI_BANK\";\nexport type PaymentCreateGateway =\n | \"MERCADOPAGO_SERVICE_PIX\"\n | \"MERCADOPAGO_SERVICE_CARD\";\n\nexport type PaymentShipmentStatus =\n | \"PENDING\"\n | \"PREPARING\"\n | \"SHIPPED\"\n | \"DELIVERED\"\n | \"RETURNED\"\n | \"CANCELLED\";\n\nexport type PaymentSortBy =\n | \"createdAt\"\n | \"updatedAt\"\n | \"price\"\n | \"name\"\n | \"email\";\nexport type PaymentSortOrder = \"asc\" | \"desc\";\n\nexport type Payment = {\n id: string;\n uuid: string;\n status: PaymentStatus;\n name?: string;\n email?: string;\n cpf?: string | null;\n price?: number;\n gateway?: PaymentGateway;\n shipment?: PaymentShipmentStatus;\n storeId: string;\n metadata?: Record<string, unknown> | null;\n};\n\nexport type Pagination = {\n page: number;\n limit: number;\n total: number;\n totalPages: number;\n};\n\nexport type FilterPaymentsInput = {\n id?: string;\n uuid?: string;\n status?: PaymentStatus;\n name?: string;\n email?: string;\n cpf?: string;\n price?: number;\n minPrice?: number;\n maxPrice?: number;\n coupon?: boolean;\n gateway?: PaymentGateway;\n shipment?: PaymentShipmentStatus;\n createdAtFrom?: string;\n createdAtTo?: string;\n updatedAtFrom?: string;\n updatedAtTo?: string;\n productId?: string;\n metadataKey?: string;\n metadataValue?: string;\n sortBy?: PaymentSortBy;\n sortOrder?: PaymentSortOrder;\n page?: number;\n limit?: number;\n};\n\nexport type FilterPaymentsResponse = {\n status: boolean;\n code: string;\n payments: Payment[];\n pagination: Pagination;\n};\n\nexport type GetPaymentsInput = {\n page?: number;\n limit?: number;\n};\n\nexport type GetPaymentsResponse = {\n status: boolean;\n code: string;\n payments: Payment[];\n pagination: Pagination;\n};\n\nexport type CreatePaymentItemInput = {\n productId: string;\n quantity: number;\n};\n\nexport type CreatePaymentInput = {\n name: string;\n email: string;\n cpf?: string;\n gateway: PaymentCreateGateway;\n coupon?: string | null;\n metadata?: Record<string, unknown>;\n items: CreatePaymentItemInput[];\n};\n\nexport type CreatePaymentResponse = {\n status: boolean;\n data: {\n service: {\n type: string;\n method: string;\n payment: string;\n };\n payment: {\n uuid: string;\n url?: string;\n qr_code?: {\n image: string;\n base_64: string;\n };\n };\n };\n};\n\nexport type UpdatePaymentInput = {\n shipment?: PaymentShipmentStatus;\n metadata?: Record<string, unknown>;\n};\n\nexport type UpdatePaymentResponse = {\n status: boolean;\n code: string;\n payment: {\n id: string;\n status: PaymentStatus;\n shipment?: PaymentShipmentStatus;\n metadata?: Record<string, unknown> | null;\n };\n};\n\nexport type DeletePaymentResponse = {\n status: boolean;\n code: string;\n message: string;\n};\n\nexport class Payments {\n constructor(private core: CoreClient) {}\n\n get(storeId: string, input: GetPaymentsInput = {}) {\n return getPayments(this.core, storeId, input);\n }\n\n filter(storeId: string, input: FilterPaymentsInput = {}) {\n return filterPayments(this.core, storeId, input);\n }\n\n post(storeId: string, input: CreatePaymentInput) {\n return createPayment(this.core, storeId, input);\n }\n\n put(storeId: string, paymentId: string, input: UpdatePaymentInput) {\n return updatePayment(this.core, storeId, paymentId, input);\n }\n\n delete(storeId: string, paymentId: string) {\n return deletePayment(this.core, storeId, paymentId);\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeleteProductResponse } from \"../index\";\n\nexport async function deleteProduct(\n core: CoreClient,\n storeId: string,\n productId: string,\n): Promise<DeleteProductResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeleteProductResponse>(\n `/stores/${storeId}/products/${productId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetProductsInput, GetProductsResponse } from \"../index\";\n\nexport async function getProducts(\n core: CoreClient,\n storeId: string,\n input: GetProductsInput = {},\n): Promise<GetProductsResponse> {\n const { data } = await core.http.get<GetProductsResponse>(\n `/stores/${storeId}/products`,\n {\n params: {\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetProductsInput, GetProductsResponse } from \"../index\";\n\nexport async function getProductsByCategory(\n core: CoreClient,\n storeId: string,\n categoryId: string,\n input: GetProductsInput = {},\n): Promise<GetProductsResponse> {\n const { data } = await core.http.get<GetProductsResponse>(\n `/stores/${storeId}/categories/${categoryId}/products`,\n {\n params: {\n page: input.page,\n limit: input.limit,\n },\n },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetProductByIdResponse } from \"../index\";\n\nexport async function getProductById(\n core: CoreClient,\n storeId: string,\n productId: string,\n): Promise<GetProductByIdResponse> {\n const { data } = await core.http.get<GetProductByIdResponse>(\n `/stores/${storeId}/products/${productId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreateProductInput, CreateProductResponse } from \"../index\";\n\nexport async function createProduct(\n core: CoreClient,\n storeId: string,\n input: CreateProductInput,\n): Promise<CreateProductResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.post<CreateProductResponse>(\n `/stores/${storeId}/products`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { UpdateProductInput, UpdateProductResponse } from \"../index\";\n\nexport async function updateProduct(\n core: CoreClient,\n storeId: string,\n productId: string,\n input: UpdateProductInput,\n): Promise<UpdateProductResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<UpdateProductResponse>(\n `/stores/${storeId}/products/${productId}`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { ReorderProductsResponse } from \"../index\";\n\nexport async function reorderProducts(\n core: CoreClient,\n storeId: string,\n productIds: string[],\n): Promise<ReorderProductsResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<ReorderProductsResponse>(\n `/stores/${storeId}/products/reorder`,\n { productIds },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deleteProduct } from \"./http/delete\";\nimport { getProducts } from \"./http/get\";\nimport { getProductsByCategory } from \"./http/get-by-category\";\nimport { getProductById } from \"./http/get-by-id\";\nimport { createProduct } from \"./http/post\";\nimport { updateProduct } from \"./http/put\";\nimport { reorderProducts } from \"./http/reorder\";\n\nexport type ProductDelivery = \"DIGITAL\" | \"PHYSICAL\";\n\nexport type ProductCategoryRef = {\n id: string;\n name: string;\n};\n\nexport type Product = {\n id: string;\n name: string;\n disabled: boolean;\n position: number;\n description: string | null;\n price: number;\n image: string | null;\n delivery: ProductDelivery;\n stock: number;\n sold: number;\n storeId: string;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n categories?: ProductCategoryRef[];\n};\n\nexport type Pagination = {\n page: number;\n limit: number;\n total: number;\n totalPages: number;\n};\n\nexport type GetProductsInput = {\n page?: number;\n limit?: number;\n};\n\nexport type CreateProductInput = {\n name: string;\n image?: string | null;\n description?: string | null;\n categoryIds?: string[];\n delivery: ProductDelivery;\n price: number;\n stock?: number;\n disabled?: boolean;\n metadata?: Record<string, unknown> | null;\n};\n\nexport type UpdateProductInput = {\n name?: string;\n image?: string | null;\n description?: string | null;\n categoryIds?: string[];\n delivery?: ProductDelivery;\n price?: number;\n stock?: number;\n disabled?: boolean;\n position?: number;\n metadata?: Record<string, unknown> | null;\n};\n\nexport type GetProductsResponse = {\n status: boolean;\n code: string;\n products: Product[];\n pagination: Pagination;\n};\n\nexport type GetProductByIdResponse = {\n status: boolean;\n code: string;\n product: Product;\n};\n\nexport type CreateProductResponse = {\n status: boolean;\n code: string;\n product: Product;\n};\n\nexport type UpdateProductResponse = {\n status: boolean;\n code: string;\n product: Product;\n};\n\nexport type DeleteProductResponse = {\n status: boolean;\n code: string;\n};\n\nexport type ReorderProductsResponse = {\n status: boolean;\n code: string;\n};\n\nexport class Products {\n constructor(private core: CoreClient) {}\n\n get(storeId: string, input: GetProductsInput = {}) {\n return getProducts(this.core, storeId, input);\n }\n\n getByCategory(\n storeId: string,\n categoryId: string,\n input: GetProductsInput = {},\n ) {\n return getProductsByCategory(this.core, storeId, categoryId, input);\n }\n\n getById(storeId: string, productId: string) {\n return getProductById(this.core, storeId, productId);\n }\n\n post(storeId: string, input: CreateProductInput) {\n return createProduct(this.core, storeId, input);\n }\n\n put(storeId: string, productId: string, input: UpdateProductInput) {\n return updateProduct(this.core, storeId, productId, input);\n }\n\n delete(storeId: string, productId: string) {\n return deleteProduct(this.core, storeId, productId);\n }\n\n reorder(storeId: string, productIds: string[]) {\n return reorderProducts(this.core, storeId, productIds);\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeleteStoreResponse } from \"../index\";\n\nexport async function deleteStore(\n core: CoreClient,\n storeId: string,\n): Promise<DeleteStoreResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeleteStoreResponse>(\n `/stores/${storeId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetStoresInput, GetStoresResponse } from \"../index\";\n\nexport async function getStores(\n core: CoreClient,\n input: GetStoresInput = {},\n): Promise<GetStoresResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetStoresResponse>(\"/stores\", {\n params: {\n page: input.page,\n limit: input.limit,\n },\n });\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetStoreByIdResponse } from \"../index\";\n\nexport async function getStoreById(\n core: CoreClient,\n storeId: string,\n): Promise<GetStoreByIdResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetStoreByIdResponse>(\n `/stores/${storeId}`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreateStoreInput, CreateStoreResponse } from \"../index\";\n\nexport async function createStore(\n core: CoreClient,\n input: CreateStoreInput,\n): Promise<CreateStoreResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.post<CreateStoreResponse>(\"/stores\", input);\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { UpdateStoreInput, UpdateStoreResponse } from \"../index\";\n\nexport async function updateStore(\n core: CoreClient,\n storeId: string,\n input: UpdateStoreInput,\n): Promise<UpdateStoreResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<UpdateStoreResponse>(\n `/stores/${storeId}`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { ReorderStoresResponse } from \"../index\";\n\nexport async function reorderStores(\n core: CoreClient,\n storeIds: string[],\n): Promise<ReorderStoresResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.put<ReorderStoresResponse>(\n \"/stores/reorder\",\n { storeIds },\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deleteStore } from \"./http/delete\";\nimport { getStores } from \"./http/get\";\nimport { getStoreById } from \"./http/get-by-id\";\nimport { createStore } from \"./http/post\";\nimport { updateStore } from \"./http/put\";\nimport { reorderStores } from \"./http/reorder\";\n\n/**\n * Templates válidos para loja.\n */\nexport type StoreTemplate = \"PERSONALIZADO\" | \"N/A\";\n\n/**\n * Tipo do domínio informado no payload da loja.\n */\nexport type StoreDomainType = \"CUSTOM\" | \"DEFAULT\";\n\n/**\n * Estrutura de domínio para criação/atualização.\n */\nexport type StoreDomainInput = {\n type: StoreDomainType;\n value: string;\n};\n\n/**\n * Modelo base de loja retornado nos endpoints de listagem e upsert.\n */\nexport type Store = {\n id: string;\n name: string;\n position: number;\n description: string | null;\n image: string | null;\n domain: string;\n template: StoreTemplate;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n};\n\n/**\n * Modelo detalhado retornado por `GET /stores/:storeId`.\n */\nexport type StoreDetails = Store & {\n ownerId?: string;\n deletedAt?: string | null;\n categories?: unknown[];\n products?: unknown[];\n coupons?: unknown[];\n payment?: unknown[];\n};\n\n/**\n * Metadados de paginação padrão da API.\n */\nexport type Pagination = {\n page: number;\n limit: number;\n total: number;\n totalPages: number;\n};\n\n/**\n * Query params de listagem de lojas.\n */\nexport type GetStoresInput = {\n page?: number;\n limit?: number;\n};\n\n/**\n * Payload para criação de loja (`POST /stores`).\n */\nexport type CreateStoreInput = {\n template: StoreTemplate;\n name?: string;\n description?: string | null;\n image?: string | null;\n metadata?: Record<string, unknown> | null;\n domain?: StoreDomainInput | null;\n position?: number;\n};\n\n/**\n * Payload para atualização de loja (`PUT /stores/:storeId`).\n *\n * Observação: no endpoint de update, todos os campos são opcionais,\n * mas a API exige ao menos 1 campo no body.\n */\nexport type UpdateStoreInput = {\n template?: StoreTemplate;\n name?: string;\n description?: string | null;\n image?: string | null;\n metadata?: Record<string, unknown> | null;\n domain?: StoreDomainInput | null;\n position?: number;\n};\n\n/**\n * Resposta de listagem de lojas.\n */\nexport type GetStoresResponse = {\n status: boolean;\n code: string;\n stores: Store[];\n pagination: Pagination;\n};\n\n/**\n * Resposta de consulta por ID.\n */\nexport type GetStoreByIdResponse = {\n status: boolean;\n code: string;\n store: StoreDetails;\n};\n\n/**\n * Resposta de criação.\n */\nexport type CreateStoreResponse = {\n status: boolean;\n code: string;\n store: Store;\n};\n\n/**\n * Resposta de atualização.\n */\nexport type UpdateStoreResponse = {\n status: boolean;\n code: string;\n store: Store;\n};\n\n/**\n * Resposta de exclusão.\n */\nexport type DeleteStoreResponse = {\n status: boolean;\n code: string;\n};\n\n/**\n * Resposta de reordenação.\n */\nexport type ReorderStoresResponse = {\n status: boolean;\n code: string;\n};\n\n/**\n * Cliente de alto nível para operações do módulo de lojas.\n */\nexport class Stores {\n /**\n * @param core Cliente base da SDK.\n */\n constructor(private core: CoreClient) {}\n\n /**\n * Lista lojas da conta com suporte a paginação.\n */\n get(input: GetStoresInput = {}) {\n return getStores(this.core, input);\n }\n\n /**\n * Busca uma loja pelo ID.\n */\n getById(storeId: string) {\n return getStoreById(this.core, storeId);\n }\n\n /**\n * Cria uma nova loja.\n */\n post(input: CreateStoreInput) {\n return createStore(this.core, input);\n }\n\n /**\n * Atualiza uma loja existente.\n */\n put(storeId: string, input: UpdateStoreInput) {\n return updateStore(this.core, storeId, input);\n }\n\n /**\n * Exclui uma loja pelo ID.\n */\n delete(storeId: string) {\n return deleteStore(this.core, storeId);\n }\n\n /**\n * Reordena lojas pelo array final de IDs.\n */\n reorder(storeIds: string[]) {\n return reorderStores(this.core, storeIds);\n }\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { DeleteWebhookInput, DeleteWebhookResponse } from \"../index\";\n\nexport async function deleteWebhook(\n core: CoreClient,\n storeId: string,\n input: DeleteWebhookInput,\n): Promise<DeleteWebhookResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.delete<DeleteWebhookResponse>(\n `/stores/${storeId}/webhooks`,\n {\n data: input,\n },\n );\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { GetWebhooksResponse } from \"../index\";\n\nexport async function getWebhooks(\n core: CoreClient,\n storeId: string,\n): Promise<GetWebhooksResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.get<GetWebhooksResponse>(\n `/stores/${storeId}/webhooks`,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../../client\";\nimport type { CreateWebhookInput, CreateWebhookResponse } from \"../index\";\n\nexport async function createWebhook(\n core: CoreClient,\n storeId: string,\n input: CreateWebhookInput,\n): Promise<CreateWebhookResponse> {\n if (!core.isPrivate()) {\n throw new Error(\"Método privado disponível apenas no backend.\");\n }\n\n const { data } = await core.http.post<CreateWebhookResponse>(\n `/stores/${storeId}/webhooks`,\n input,\n );\n\n return data;\n}\n","import type { CoreClient } from \"../../client\";\nimport { deleteWebhook } from \"./http/delete\";\nimport { getWebhooks } from \"./http/get\";\nimport { createWebhook } from \"./http/post\";\n\n/**\n * Resposta de listagem de webhooks por loja.\n */\nexport type GetWebhooksResponse = {\n webhooks: string[];\n max: number;\n};\n\n/**\n * Payload para criar webhook em uma loja.\n */\nexport type CreateWebhookInput = {\n url: string;\n};\n\n/**\n * Resposta de criação de webhook.\n */\nexport type CreateWebhookResponse = {\n status: boolean;\n code: string;\n webhook: string;\n};\n\n/**\n * Payload para remover webhook de uma loja.\n */\nexport type DeleteWebhookInput = {\n url: string;\n};\n\n/**\n * Resposta de remoção de webhook.\n */\nexport type DeleteWebhookResponse = {\n status: boolean;\n code: string;\n};\n\n/**\n * Cliente de alto nível para operações de webhooks da loja.\n */\nexport class Webhooks {\n /**\n * @param core Cliente base da SDK.\n */\n constructor(private core: CoreClient) {}\n\n /**\n * Lista os webhooks cadastrados para uma loja.\n */\n get(storeId: string) {\n return getWebhooks(this.core, storeId);\n }\n\n /**\n * Adiciona um webhook em uma loja.\n */\n post(storeId: string, input: CreateWebhookInput) {\n return createWebhook(this.core, storeId, input);\n }\n\n /**\n * Remove um webhook de uma loja.\n */\n delete(storeId: string, input: DeleteWebhookInput) {\n return deleteWebhook(this.core, storeId, input);\n }\n\n /**\n * Descriptografa e valida o payload recebido no webhook de assinatura.\n *\n * Espera um payload no formato `iv:encrypted` (ambos em base64), criptografado\n * com AES-256-CBC usando a chave informada.\n */\n async decrypty(\n secret: string,\n payload: string,\n ): Promise<Record<string, unknown>> {\n if (!secret) {\n throw new Error(\"SECRET_KEY_REQUIRED\");\n }\n\n if (!payload || typeof payload !== \"string\") {\n throw new Error(\"INVALID_PAYLOAD_FORMAT\");\n }\n\n const [ivB64, encrypted] = payload.split(\":\");\n if (!ivB64 || !encrypted) {\n throw new Error(\"INVALID_PAYLOAD_FORMAT\");\n }\n\n const iv = base64ToBytes(ivB64);\n const encryptedBytes = base64ToBytes(encrypted);\n const secretBytes = new TextEncoder().encode(secret);\n\n const keyHash = await globalThis.crypto.subtle.digest(\n \"SHA-256\",\n secretBytes,\n );\n const cryptoKey = await globalThis.crypto.subtle.importKey(\n \"raw\",\n keyHash,\n { name: \"AES-CBC\" },\n false,\n [\"decrypt\"],\n );\n const decryptedBuffer = await globalThis.crypto.subtle.decrypt(\n { name: \"AES-CBC\", iv: toArrayBuffer(iv) },\n cryptoKey,\n toArrayBuffer(encryptedBytes),\n );\n const decrypted = new TextDecoder().decode(decryptedBuffer);\n\n return JSON.parse(decrypted) as Record<string, unknown>;\n }\n\n /**\n * Alias com nome corrigido para descriptografar payload de webhook.\n */\n async decrypt(\n secret: string,\n payload: string,\n ): Promise<Record<string, unknown>> {\n return this.decrypty(secret, payload);\n }\n\n /**\n * Alias retrocompatível para quem já usa `parseSubscriptionPayload`.\n */\n async parseSubscriptionPayload(\n payload: string,\n secret: string,\n ): Promise<Record<string, unknown>> {\n return this.decrypty(secret, payload);\n }\n}\n\nfunction base64ToBytes(base64: string): Uint8Array {\n const binary = atob(base64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i += 1) {\n bytes[i] = binary.charCodeAt(i);\n }\n return bytes;\n}\n\nfunction toArrayBuffer(bytes: Uint8Array): ArrayBuffer {\n return bytes.buffer.slice(\n bytes.byteOffset,\n bytes.byteOffset + bytes.byteLength,\n ) as ArrayBuffer;\n}\n","import { type ClientOptions, CoreClient } from \"./core/client\";\nimport { Categories } from \"./core/module/categories/index\";\nimport { Coupons } from \"./core/module/coupons/index\";\nimport { Pages } from \"./core/module/pages/index\";\nimport { Payments } from \"./core/module/payments/index\";\nimport { Products } from \"./core/module/products/index\";\nimport { Stores } from \"./core/module/stores/index\";\nimport { Webhooks } from \"./core/module/webhooks/index\";\n\n/**\n * SDK principal da caBRAPI\n */\nexport class caBRAPI {\n public categories: Categories;\n public coupons: Coupons;\n public payments: Payments;\n public pages: Pages;\n public products: Products;\n public stores: Stores;\n public webhooks: Webhooks;\n\n constructor(options: ClientOptions) {\n const core = new CoreClient(options);\n\n this.categories = new Categories(core);\n this.coupons = new Coupons(core);\n this.payments = new Payments(core);\n this.pages = new Pages(core);\n this.products = new Products(core);\n this.stores = new Stores(core);\n this.webhooks = new Webhooks(core);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cabrapi/sdk",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "SDK oficial da caBRAPI para Node.js e Browser",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "SDK oficial da caBRAPI para Node.js, Bun e Browser",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"author": "Sebastian Jn <sebastianjnuwu@gmail.com>",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"cabrapi",
|
|
13
|
+
"sdk",
|
|
14
|
+
"node",
|
|
15
|
+
"browser",
|
|
16
|
+
"bun",
|
|
17
|
+
"api",
|
|
18
|
+
"client"
|
|
19
|
+
],
|
|
11
20
|
"exports": {
|
|
12
21
|
".": {
|
|
13
22
|
"types": "./dist/index.d.ts",
|
|
@@ -35,7 +44,7 @@
|
|
|
35
44
|
},
|
|
36
45
|
"repository": {
|
|
37
46
|
"type": "git",
|
|
38
|
-
"url": "https://github.com/caBRAPI/sdk-node-browser"
|
|
47
|
+
"url": "https://github.com/caBRAPI/sdk-node-bun-browser"
|
|
39
48
|
},
|
|
40
49
|
"engines": {
|
|
41
50
|
"node": ">=18"
|