@cabrapi/sdk 1.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,97 @@
1
+
2
+ # 🚀 @cabrapi/sdk
3
+
4
+ ## 📋 Visão geral
5
+
6
+ O `@cabrapi/sdk` fornece uma interface unificada e tipada para comunicação com os serviços da caBRAPI, suportando dois modos de autenticação:
7
+
8
+ | Modo | Ambiente | Emoji |
9
+ |------|----------|-------|
10
+ | **Público** (`public`) | Cliente (navegador) | 🌐 |
11
+ | **Privado** (`private`) | Servidor (Node.js) | 🔒 |
12
+
13
+ ## 📦 Instalação
14
+
15
+ ```bash
16
+ npm install @cabrapi/sdk
17
+ ```
18
+
19
+ ## 🎯 Modos de uso
20
+
21
+ ### 🌐 Modo público (client-side)
22
+
23
+ > Ideal para SPAs, React, Vue, Angular e qualquer aplicação que rode no navegador.
24
+
25
+ ```typescript
26
+ import { caBRAPI } from '@cabrapi/sdk';
27
+
28
+ const client = new caBRAPI({
29
+ type: 'public',
30
+ config: {} // Configuração vazia para modo público
31
+ });
32
+ ```
33
+
34
+ ### 🔒 Modo privado (server-side)
35
+
36
+ > Para operações seguras no backend com chave de API.
37
+
38
+ ```typescript
39
+ import { caBRAPI } from '@cabrapi/sdk';
40
+
41
+ const client = new caBRAPI({
42
+ type: 'private',
43
+ config: {
44
+ key: 'SUA_API_KEY' // 🔑 Sua chave de acesso
45
+ }
46
+ });
47
+ ```
48
+
49
+ ### ☁️ CDN
50
+
51
+ > Use diretamente no navegador sem ferramentas de build.
52
+
53
+ ```html
54
+ <script type="module">
55
+ import { caBRAPI } from 'https://cdn.jsdelivr.net/npm/@cabrapi/sdk/dist/index.js';
56
+
57
+ const client = new caBRAPI({
58
+ type: 'public',
59
+ config: {}
60
+ });
61
+ </script>
62
+ ```
63
+
64
+ ## ⚙️ Configuração
65
+
66
+ ### Opções do cliente
67
+
68
+ | Propriedade | Tipo | Obrigatório | Descrição |
69
+ |-------------|------|-------------|-----------|
70
+ | `type` | `'public' \| 'private'` | ✅ | Modo de autenticação |
71
+ | `config` | `PublicConfig \| PrivateConfig` | ✅ | Configurações específicas |
72
+
73
+ ### 📂 Configuração pública (`public`)
74
+
75
+ | Propriedade | Tipo | Descrição |
76
+ |-------------|------|-------------|
77
+ | - | - | Nenhuma configuração necessária |
78
+
79
+ ### 🔐 Configuração privada (`private`)
80
+
81
+ | Propriedade | Tipo | Descrição |
82
+ |-------------|------|-------------|
83
+ | `key` | `string` | 🔑 Chave da API para autenticação |
84
+
85
+ ## 📌 Requisitos
86
+
87
+ | Ambiente | Versão |
88
+ |----------|--------|
89
+ | **Node.js** (modo privado) | `>= 18.x` |
90
+ | **Browsers** (modo público) | ES2020+ |
91
+ | **TypeScript** | Suporte nativo ✅ |
92
+
93
+ ## 📞 Suporte
94
+
95
+ • 📚 Documentação: https://docs.cabrapi.com.br
96
+
97
+ • 🐛 Issues: https://github.com/cabrapi/sdk-node-browser/issues
package/dist/index.cjs ADDED
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ caBRAPI: () => caBRAPI
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+
37
+ // src/core/http.ts
38
+ var import_axios = __toESM(require("axios"), 1);
39
+ function createAxios(config = {}) {
40
+ const instance = import_axios.default.create({
41
+ baseURL: config.baseURL ?? "https://api.cabrapi.com.br",
42
+ timeout: 3e4,
43
+ headers: {
44
+ "Content-Type": "application/json"
45
+ }
46
+ });
47
+ instance.interceptors.request.use((req) => {
48
+ const r = req ?? {};
49
+ if (config.apiKey) {
50
+ if (!r.headers) r.headers = {};
51
+ const headers = r.headers;
52
+ headers.Authorization = `Bearer ${config.apiKey}`;
53
+ }
54
+ return r;
55
+ });
56
+ instance.interceptors.response.use(
57
+ (res) => res,
58
+ (err) => {
59
+ let message = "Unknown error";
60
+ if (err && typeof err === "object") {
61
+ const ae = err;
62
+ if (typeof ae.message === "string") {
63
+ message = ae.message;
64
+ }
65
+ if (ae.response && typeof ae.response === "object") {
66
+ const data = ae.response.data;
67
+ if (data && typeof data === "object") {
68
+ const d = data;
69
+ const maybeMsg = d.message ?? d.code;
70
+ if (typeof maybeMsg === "string") message = maybeMsg;
71
+ }
72
+ }
73
+ } else if (typeof err === "string") {
74
+ message = err;
75
+ }
76
+ return Promise.reject(new Error(message));
77
+ }
78
+ );
79
+ return instance;
80
+ }
81
+
82
+ // src/core/client.ts
83
+ var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
84
+ var CoreClient = class {
85
+ constructor(options) {
86
+ this.mode = options.type;
87
+ this.isBrowser = isBrowser;
88
+ if (this.mode === "private" && !options.config?.key && !this.isBrowser) {
89
+ throw new Error("API key \xE9 obrigat\xF3ria no modo 'private'.");
90
+ }
91
+ const apiKey = !this.isBrowser && this.mode === "private" ? options.config?.key : void 0;
92
+ this.http = createAxios({ apiKey });
93
+ if (this.isBrowser && this.mode === "private") {
94
+ console.warn(
95
+ "[caBRAPI] Modo 'private' detectado no navegador. API key ignorada."
96
+ );
97
+ }
98
+ }
99
+ /**
100
+ * Está em modo privado (backend)
101
+ */
102
+ isPrivate() {
103
+ return !this.isBrowser && this.mode === "private";
104
+ }
105
+ /**
106
+ * Está em modo público
107
+ */
108
+ isPublic() {
109
+ return this.isBrowser || this.mode === "public";
110
+ }
111
+ /**
112
+ * Garante execução no backend
113
+ */
114
+ assertPrivate() {
115
+ if (!this.isPrivate()) {
116
+ throw new Error(
117
+ "Este m\xE9todo \xE9 privado e n\xE3o pode ser usado no navegador."
118
+ );
119
+ }
120
+ }
121
+ };
122
+
123
+ // src/core/module/pages/http/delete.ts
124
+ async function deletePage(core, domain) {
125
+ if (!core.isPrivate()) {
126
+ throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");
127
+ }
128
+ const { data } = await core.http.delete(
129
+ `/pages/${domain}`
130
+ );
131
+ return data.status;
132
+ }
133
+
134
+ // src/core/module/pages/http/get.ts
135
+ async function getPage(core, domain) {
136
+ const { data } = await core.http.get(`/pages/${domain}`);
137
+ if (!data?.data) {
138
+ throw new Error(`Page not found: ${domain}`);
139
+ }
140
+ return data.data;
141
+ }
142
+
143
+ // src/core/module/pages/http/upsert.ts
144
+ async function upsertPage(core, input) {
145
+ if (!core.isPrivate()) {
146
+ throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");
147
+ }
148
+ const { data } = await core.http.put(
149
+ `/pages/${input.domain}`,
150
+ {
151
+ html: input.html,
152
+ template: input.template
153
+ }
154
+ );
155
+ return data.status;
156
+ }
157
+
158
+ // src/core/module/pages/index.ts
159
+ var Pages = class {
160
+ constructor(core) {
161
+ this.core = core;
162
+ }
163
+ get(domain) {
164
+ return getPage(this.core, domain);
165
+ }
166
+ upsert(input) {
167
+ return upsertPage(this.core, input);
168
+ }
169
+ delete(domain) {
170
+ return deletePage(this.core, domain);
171
+ }
172
+ };
173
+
174
+ // src/index.ts
175
+ var caBRAPI = class {
176
+ constructor(options) {
177
+ const core = new CoreClient(options);
178
+ this.pages = new Pages(core);
179
+ }
180
+ };
181
+ // Annotate the CommonJS export names for ESM import in node:
182
+ 0 && (module.exports = {
183
+ caBRAPI
184
+ });
185
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/core/http.ts","../src/core/client.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"],"sourcesContent":["import { type ClientOptions, CoreClient } from \"./core/client\";\nimport { Pages } from \"./core/module/pages/index\";\n\n/**\n * SDK principal da caBRAPI\n */\nexport class caBRAPI {\n public pages: Pages;\n\n constructor(options: ClientOptions) {\n const core = new CoreClient(options);\n\n this.pages = new Pages(core);\n }\n}\n","import axios, {\n type AxiosInstance,\n type AxiosRequestConfig,\n type AxiosResponse,\n} from \"axios\";\n\n/**\n * Configurações para criação da instância Axios.\n */\nexport type AxiosConfig = {\n /**\n * URL base da API.\n * @default \"https://api.cabrapi.com.br\"\n */\n baseURL?: string;\n\n /**\n * Chave da API (modo privado).\n */\n apiKey?: string;\n};\n\n/**\n * Cria uma instância HTTP configurada para a caBRAPI.\n */\nexport function createAxios(config: AxiosConfig = {}): AxiosInstance {\n const instance = axios.create({\n baseURL: config.baseURL ?? \"https://api.cabrapi.com.br\",\n timeout: 30000,\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n\n // 🔐 Request interceptor\n instance.interceptors.request.use((req?: AxiosRequestConfig) => {\n const r: AxiosRequestConfig = req ?? {};\n if (config.apiKey) {\n if (!r.headers) r.headers = {};\n const headers = r.headers as Record<string, string | number | boolean>;\n headers.Authorization = `Bearer ${config.apiKey}`;\n }\n return r;\n });\n\n // ⚠️ Response interceptor\n instance.interceptors.response.use(\n (res: AxiosResponse) => res,\n (err: unknown) => {\n let message = \"Unknown error\";\n\n type MaybeAxiosLike = {\n message?: unknown;\n response?: { data?: unknown };\n };\n if (err && typeof err === \"object\") {\n const ae = err as MaybeAxiosLike;\n if (typeof ae.message === \"string\") {\n message = ae.message;\n }\n\n if (ae.response && typeof ae.response === \"object\") {\n const data = ae.response.data;\n if (data && typeof data === \"object\") {\n const d = data as Record<string, unknown>;\n const maybeMsg = d.message ?? d.code;\n if (typeof maybeMsg === \"string\") message = maybeMsg;\n }\n }\n } else if (typeof err === \"string\") {\n message = err;\n }\n\n return Promise.reject(new Error(message));\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 };\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({ 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\";\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 * DELETE /pages/:domain\n *\n * Remove a página publicada de uma loja pelo domínio.\n *\n * 🔒 Endpoint privado (somente backend)\n *\n * @param core - Instância do CoreClient (modo private)\n * @param domain - Domínio da página (ex: \"minhaloja.com.br\")\n *\n * @returns `true` se a exclusão foi bem-sucedida\n *\n * @throws Error se usado no navegador ou se a API retornar erro\n */\nexport async function deletePage(\n core: CoreClient,\n domain: string,\n): Promise<boolean> {\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.status;\n}\n","import type { CoreClient } from \"../../../client\";\n\n/**\n * Representa a página retornada pela API\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 };\n};\n\n/**\n * Estrutura padrão da resposta da API\n */\ntype PageResponse = {\n status: boolean;\n data: Page;\n};\n\n/**\n * GET /pages/:domain\n *\n * Busca a página pública de uma loja pelo domínio.\n *\n * 🔓 Endpoint público (pode ser usado no navegador ou backend)\n *\n * @param core - Instância do CoreClient já configurada\n * @param domain - Domínio da loja (ex: \"minhaloja.com.br\")\n *\n * @returns Dados da página renderizada (HTML + metadados)\n *\n * @throws Error quando a página não existe ou a API retorna erro\n */\nexport async function getPage(core: CoreClient, domain: string): Promise<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 data.data;\n}\n","import type { CoreClient } from \"../../../client\";\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 * PUT /pages/:domain\n *\n * Cria ou atualiza a página de uma loja.\n *\n * 🔒 Endpoint privado (somente backend)\n *\n * @param core - Instância do CoreClient (modo private)\n * @param input - Dados da página\n *\n * @returns `true` se operação foi bem-sucedida\n *\n * @throws Error se usado no navegador ou se a API retornar erro\n */\nexport async function upsertPage(\n core: CoreClient,\n input: PageUpsertInput,\n): Promise<boolean> {\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.status;\n}\n","import 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 */\nexport type Page = {\n domain: string;\n html: string;\n template?: string;\n};\n\nexport class Pages {\n constructor(private core: CoreClient) {}\n\n get(domain: string) {\n return getPage(this.core, domain);\n }\n\n upsert(input: { domain: string; html: string; template?: string }) {\n return upsertPage(this.core, input);\n }\n\n delete(domain: string) {\n return deletePage(this.core, domain);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAIO;AAqBA,SAAS,YAAY,SAAsB,CAAC,GAAkB;AACnE,QAAM,WAAW,aAAAA,QAAM,OAAO;AAAA,IAC5B,SAAS,OAAO,WAAW;AAAA,IAC3B,SAAS;AAAA,IACT,SAAS;AAAA,MACP,gBAAgB;AAAA,IAClB;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AoB,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAEvC,IAAI,QAAgB;AAClB,WAAO,QAAQ,KAAK,MAAM,MAAM;AAAA,EAClC;AAAA,EAEA,OAAO,OAA4D;AACjE,WAAO,WAAW,KAAK,MAAM,KAAK;AAAA,EACpC;AAAA,EAEA,OAAO,QAAgB;AACrB,WAAO,WAAW,KAAK,MAAM,MAAM;AAAA,EACrC;AACF;;;ANtBO,IAAM,UAAN,MAAc;AAAA,EAGnB,YAAY,SAAwB;AAClC,UAAM,OAAO,IAAI,WAAW,OAAO;AAEnC,SAAK,QAAQ,IAAI,MAAM,IAAI;AAAA,EAC7B;AACF;","names":["axios"]}
@@ -0,0 +1,96 @@
1
+ import { AxiosInstance as AxiosInstance$1 } from 'axios';
2
+
3
+ /**
4
+ * Configurações para criação da instância Axios.
5
+ */
6
+ type AxiosConfig = {
7
+ /**
8
+ * URL base da API.
9
+ * @default "https://api.cabrapi.com.br"
10
+ */
11
+ baseURL?: string;
12
+ /**
13
+ * Chave da API (modo privado).
14
+ */
15
+ apiKey?: string;
16
+ };
17
+ /**
18
+ * Cria uma instância HTTP configurada para a caBRAPI.
19
+ */
20
+ declare function createAxios(config?: AxiosConfig): AxiosInstance$1;
21
+
22
+ /**
23
+ * Tipo derivado da instância do Axios
24
+ * (evita problemas no build de types)
25
+ */
26
+ type AxiosInstance = ReturnType<typeof createAxios>;
27
+ /**
28
+ * Modos disponíveis
29
+ */
30
+ type ClientMode = "public" | "private";
31
+ /**
32
+ * Opções do cliente
33
+ */
34
+ type ClientOptions = {
35
+ type: ClientMode;
36
+ config?: {
37
+ key?: string;
38
+ };
39
+ };
40
+ /**
41
+ * Cliente base da caBRAPI
42
+ */
43
+ declare class CoreClient {
44
+ http: AxiosInstance;
45
+ mode: ClientMode;
46
+ isBrowser: boolean;
47
+ constructor(options: ClientOptions);
48
+ /**
49
+ * Está em modo privado (backend)
50
+ */
51
+ isPrivate(): boolean;
52
+ /**
53
+ * Está em modo público
54
+ */
55
+ isPublic(): boolean;
56
+ /**
57
+ * Garante execução no backend
58
+ */
59
+ assertPrivate(): void;
60
+ }
61
+
62
+ /**
63
+ * Representa a página retornada pela API
64
+ */
65
+ type Page = {
66
+ html: string;
67
+ template?: string;
68
+ version?: string;
69
+ createdAt?: string;
70
+ updatedAt?: string;
71
+ store?: {
72
+ ownerId: string;
73
+ };
74
+ };
75
+
76
+ declare class Pages {
77
+ private core;
78
+ constructor(core: CoreClient);
79
+ get(domain: string): Promise<Page>;
80
+ upsert(input: {
81
+ domain: string;
82
+ html: string;
83
+ template?: string;
84
+ }): Promise<boolean>;
85
+ delete(domain: string): Promise<boolean>;
86
+ }
87
+
88
+ /**
89
+ * SDK principal da caBRAPI
90
+ */
91
+ declare class caBRAPI {
92
+ pages: Pages;
93
+ constructor(options: ClientOptions);
94
+ }
95
+
96
+ export { caBRAPI };
@@ -0,0 +1,96 @@
1
+ import { AxiosInstance as AxiosInstance$1 } from 'axios';
2
+
3
+ /**
4
+ * Configurações para criação da instância Axios.
5
+ */
6
+ type AxiosConfig = {
7
+ /**
8
+ * URL base da API.
9
+ * @default "https://api.cabrapi.com.br"
10
+ */
11
+ baseURL?: string;
12
+ /**
13
+ * Chave da API (modo privado).
14
+ */
15
+ apiKey?: string;
16
+ };
17
+ /**
18
+ * Cria uma instância HTTP configurada para a caBRAPI.
19
+ */
20
+ declare function createAxios(config?: AxiosConfig): AxiosInstance$1;
21
+
22
+ /**
23
+ * Tipo derivado da instância do Axios
24
+ * (evita problemas no build de types)
25
+ */
26
+ type AxiosInstance = ReturnType<typeof createAxios>;
27
+ /**
28
+ * Modos disponíveis
29
+ */
30
+ type ClientMode = "public" | "private";
31
+ /**
32
+ * Opções do cliente
33
+ */
34
+ type ClientOptions = {
35
+ type: ClientMode;
36
+ config?: {
37
+ key?: string;
38
+ };
39
+ };
40
+ /**
41
+ * Cliente base da caBRAPI
42
+ */
43
+ declare class CoreClient {
44
+ http: AxiosInstance;
45
+ mode: ClientMode;
46
+ isBrowser: boolean;
47
+ constructor(options: ClientOptions);
48
+ /**
49
+ * Está em modo privado (backend)
50
+ */
51
+ isPrivate(): boolean;
52
+ /**
53
+ * Está em modo público
54
+ */
55
+ isPublic(): boolean;
56
+ /**
57
+ * Garante execução no backend
58
+ */
59
+ assertPrivate(): void;
60
+ }
61
+
62
+ /**
63
+ * Representa a página retornada pela API
64
+ */
65
+ type Page = {
66
+ html: string;
67
+ template?: string;
68
+ version?: string;
69
+ createdAt?: string;
70
+ updatedAt?: string;
71
+ store?: {
72
+ ownerId: string;
73
+ };
74
+ };
75
+
76
+ declare class Pages {
77
+ private core;
78
+ constructor(core: CoreClient);
79
+ get(domain: string): Promise<Page>;
80
+ upsert(input: {
81
+ domain: string;
82
+ html: string;
83
+ template?: string;
84
+ }): Promise<boolean>;
85
+ delete(domain: string): Promise<boolean>;
86
+ }
87
+
88
+ /**
89
+ * SDK principal da caBRAPI
90
+ */
91
+ declare class caBRAPI {
92
+ pages: Pages;
93
+ constructor(options: ClientOptions);
94
+ }
95
+
96
+ export { caBRAPI };
package/dist/index.js ADDED
@@ -0,0 +1,148 @@
1
+ // src/core/http.ts
2
+ import axios from "axios";
3
+ function createAxios(config = {}) {
4
+ const instance = axios.create({
5
+ baseURL: config.baseURL ?? "https://api.cabrapi.com.br",
6
+ timeout: 3e4,
7
+ headers: {
8
+ "Content-Type": "application/json"
9
+ }
10
+ });
11
+ instance.interceptors.request.use((req) => {
12
+ const r = req ?? {};
13
+ if (config.apiKey) {
14
+ if (!r.headers) r.headers = {};
15
+ const headers = r.headers;
16
+ headers.Authorization = `Bearer ${config.apiKey}`;
17
+ }
18
+ return r;
19
+ });
20
+ instance.interceptors.response.use(
21
+ (res) => res,
22
+ (err) => {
23
+ let message = "Unknown error";
24
+ if (err && typeof err === "object") {
25
+ const ae = err;
26
+ if (typeof ae.message === "string") {
27
+ message = ae.message;
28
+ }
29
+ if (ae.response && typeof ae.response === "object") {
30
+ const data = ae.response.data;
31
+ if (data && typeof data === "object") {
32
+ const d = data;
33
+ const maybeMsg = d.message ?? d.code;
34
+ if (typeof maybeMsg === "string") message = maybeMsg;
35
+ }
36
+ }
37
+ } else if (typeof err === "string") {
38
+ message = err;
39
+ }
40
+ return Promise.reject(new Error(message));
41
+ }
42
+ );
43
+ return instance;
44
+ }
45
+
46
+ // src/core/client.ts
47
+ var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
48
+ var CoreClient = class {
49
+ constructor(options) {
50
+ this.mode = options.type;
51
+ this.isBrowser = isBrowser;
52
+ if (this.mode === "private" && !options.config?.key && !this.isBrowser) {
53
+ throw new Error("API key \xE9 obrigat\xF3ria no modo 'private'.");
54
+ }
55
+ const apiKey = !this.isBrowser && this.mode === "private" ? options.config?.key : void 0;
56
+ this.http = createAxios({ apiKey });
57
+ if (this.isBrowser && this.mode === "private") {
58
+ console.warn(
59
+ "[caBRAPI] Modo 'private' detectado no navegador. API key ignorada."
60
+ );
61
+ }
62
+ }
63
+ /**
64
+ * Está em modo privado (backend)
65
+ */
66
+ isPrivate() {
67
+ return !this.isBrowser && this.mode === "private";
68
+ }
69
+ /**
70
+ * Está em modo público
71
+ */
72
+ isPublic() {
73
+ return this.isBrowser || this.mode === "public";
74
+ }
75
+ /**
76
+ * Garante execução no backend
77
+ */
78
+ assertPrivate() {
79
+ if (!this.isPrivate()) {
80
+ throw new Error(
81
+ "Este m\xE9todo \xE9 privado e n\xE3o pode ser usado no navegador."
82
+ );
83
+ }
84
+ }
85
+ };
86
+
87
+ // src/core/module/pages/http/delete.ts
88
+ async function deletePage(core, domain) {
89
+ if (!core.isPrivate()) {
90
+ throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");
91
+ }
92
+ const { data } = await core.http.delete(
93
+ `/pages/${domain}`
94
+ );
95
+ return data.status;
96
+ }
97
+
98
+ // src/core/module/pages/http/get.ts
99
+ async function getPage(core, domain) {
100
+ const { data } = await core.http.get(`/pages/${domain}`);
101
+ if (!data?.data) {
102
+ throw new Error(`Page not found: ${domain}`);
103
+ }
104
+ return data.data;
105
+ }
106
+
107
+ // src/core/module/pages/http/upsert.ts
108
+ async function upsertPage(core, input) {
109
+ if (!core.isPrivate()) {
110
+ throw new Error("M\xE9todo privado dispon\xEDvel apenas no backend.");
111
+ }
112
+ const { data } = await core.http.put(
113
+ `/pages/${input.domain}`,
114
+ {
115
+ html: input.html,
116
+ template: input.template
117
+ }
118
+ );
119
+ return data.status;
120
+ }
121
+
122
+ // src/core/module/pages/index.ts
123
+ var Pages = class {
124
+ constructor(core) {
125
+ this.core = core;
126
+ }
127
+ get(domain) {
128
+ return getPage(this.core, domain);
129
+ }
130
+ upsert(input) {
131
+ return upsertPage(this.core, input);
132
+ }
133
+ delete(domain) {
134
+ return deletePage(this.core, domain);
135
+ }
136
+ };
137
+
138
+ // src/index.ts
139
+ var caBRAPI = class {
140
+ constructor(options) {
141
+ const core = new CoreClient(options);
142
+ this.pages = new Pages(core);
143
+ }
144
+ };
145
+ export {
146
+ caBRAPI
147
+ };
148
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/http.ts","../src/core/client.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/index.ts"],"sourcesContent":["import axios, {\n type AxiosInstance,\n type AxiosRequestConfig,\n type AxiosResponse,\n} from \"axios\";\n\n/**\n * Configurações para criação da instância Axios.\n */\nexport type AxiosConfig = {\n /**\n * URL base da API.\n * @default \"https://api.cabrapi.com.br\"\n */\n baseURL?: string;\n\n /**\n * Chave da API (modo privado).\n */\n apiKey?: string;\n};\n\n/**\n * Cria uma instância HTTP configurada para a caBRAPI.\n */\nexport function createAxios(config: AxiosConfig = {}): AxiosInstance {\n const instance = axios.create({\n baseURL: config.baseURL ?? \"https://api.cabrapi.com.br\",\n timeout: 30000,\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n\n // 🔐 Request interceptor\n instance.interceptors.request.use((req?: AxiosRequestConfig) => {\n const r: AxiosRequestConfig = req ?? {};\n if (config.apiKey) {\n if (!r.headers) r.headers = {};\n const headers = r.headers as Record<string, string | number | boolean>;\n headers.Authorization = `Bearer ${config.apiKey}`;\n }\n return r;\n });\n\n // ⚠️ Response interceptor\n instance.interceptors.response.use(\n (res: AxiosResponse) => res,\n (err: unknown) => {\n let message = \"Unknown error\";\n\n type MaybeAxiosLike = {\n message?: unknown;\n response?: { data?: unknown };\n };\n if (err && typeof err === \"object\") {\n const ae = err as MaybeAxiosLike;\n if (typeof ae.message === \"string\") {\n message = ae.message;\n }\n\n if (ae.response && typeof ae.response === \"object\") {\n const data = ae.response.data;\n if (data && typeof data === \"object\") {\n const d = data as Record<string, unknown>;\n const maybeMsg = d.message ?? d.code;\n if (typeof maybeMsg === \"string\") message = maybeMsg;\n }\n }\n } else if (typeof err === \"string\") {\n message = err;\n }\n\n return Promise.reject(new Error(message));\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 };\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({ 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\";\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 * DELETE /pages/:domain\n *\n * Remove a página publicada de uma loja pelo domínio.\n *\n * 🔒 Endpoint privado (somente backend)\n *\n * @param core - Instância do CoreClient (modo private)\n * @param domain - Domínio da página (ex: \"minhaloja.com.br\")\n *\n * @returns `true` se a exclusão foi bem-sucedida\n *\n * @throws Error se usado no navegador ou se a API retornar erro\n */\nexport async function deletePage(\n core: CoreClient,\n domain: string,\n): Promise<boolean> {\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.status;\n}\n","import type { CoreClient } from \"../../../client\";\n\n/**\n * Representa a página retornada pela API\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 };\n};\n\n/**\n * Estrutura padrão da resposta da API\n */\ntype PageResponse = {\n status: boolean;\n data: Page;\n};\n\n/**\n * GET /pages/:domain\n *\n * Busca a página pública de uma loja pelo domínio.\n *\n * 🔓 Endpoint público (pode ser usado no navegador ou backend)\n *\n * @param core - Instância do CoreClient já configurada\n * @param domain - Domínio da loja (ex: \"minhaloja.com.br\")\n *\n * @returns Dados da página renderizada (HTML + metadados)\n *\n * @throws Error quando a página não existe ou a API retorna erro\n */\nexport async function getPage(core: CoreClient, domain: string): Promise<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 data.data;\n}\n","import type { CoreClient } from \"../../../client\";\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 * PUT /pages/:domain\n *\n * Cria ou atualiza a página de uma loja.\n *\n * 🔒 Endpoint privado (somente backend)\n *\n * @param core - Instância do CoreClient (modo private)\n * @param input - Dados da página\n *\n * @returns `true` se operação foi bem-sucedida\n *\n * @throws Error se usado no navegador ou se a API retornar erro\n */\nexport async function upsertPage(\n core: CoreClient,\n input: PageUpsertInput,\n): Promise<boolean> {\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.status;\n}\n","import 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 */\nexport type Page = {\n domain: string;\n html: string;\n template?: string;\n};\n\nexport class Pages {\n constructor(private core: CoreClient) {}\n\n get(domain: string) {\n return getPage(this.core, domain);\n }\n\n upsert(input: { domain: string; html: string; template?: string }) {\n return upsertPage(this.core, input);\n }\n\n delete(domain: string) {\n return deletePage(this.core, domain);\n }\n}\n","import { type ClientOptions, CoreClient } from \"./core/client\";\nimport { Pages } from \"./core/module/pages/index\";\n\n/**\n * SDK principal da caBRAPI\n */\nexport class caBRAPI {\n public pages: Pages;\n\n constructor(options: ClientOptions) {\n const core = new CoreClient(options);\n\n this.pages = new Pages(core);\n }\n}\n"],"mappings":";AAAA,OA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AAAA,IAC/B,UAAU,MAAM,MAAM;AAAA,IACtB;AAAA,MACE,MAAM,MAAM;AAAA,MACZ,UAAU,MAAM;AAAA,IAClB;AAAA,EACF;AAEA,SAAO,KAAK;AACd;;;ACjCO,IAAM,QAAN,MAAY;AAAA,EACjB,YAAoB,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAEvC,IAAI,QAAgB;AAClB,WAAO,QAAQ,KAAK,MAAM,MAAM;AAAA,EAClC;AAAA,EAEA,OAAO,OAA4D;AACjE,WAAO,WAAW,KAAK,MAAM,KAAK;AAAA,EACpC;AAAA,EAEA,OAAO,QAAgB;AACrB,WAAO,WAAW,KAAK,MAAM,MAAM;AAAA,EACrC;AACF;;;ACtBO,IAAM,UAAN,MAAc;AAAA,EAGnB,YAAY,SAAwB;AAClC,UAAM,OAAO,IAAI,WAAW,OAAO;AAEnC,SAAK,QAAQ,IAAI,MAAM,IAAI;AAAA,EAC7B;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@cabrapi/sdk",
3
+ "version": "1.0.0-alpha.0",
4
+ "description": "SDK oficial da caBRAPI para Node.js e Browser",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsup",
21
+ "dev": "tsup --watch",
22
+ "check": "npx @biomejs/biome check --write",
23
+ "prepublishOnly": "npm run build",
24
+ "lint": "npx @biomejs/biome lint --write",
25
+ "format": "npx @biomejs/biome format --write"
26
+ },
27
+ "dependencies": {
28
+ "axios": "^1.6.0"
29
+ },
30
+ "devDependencies": {
31
+ "tsup": "^8.0.0",
32
+ "typescript": "^5.0.0"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public"
36
+ }
37
+ }