sdk-sapi-promarketing 0.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/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # sdk-sapi2-promarketing
2
+
3
+ Cliente TypeScript para consumir la API SAPI (skins, jugador, pagos, bonos, etc.). Se publica en npm como paquete dual **CommonJS + ESM** con tipos incluidos.
4
+
5
+ ## Requisitos
6
+
7
+ - **Node.js** 18 o superior (`fetch` global).
8
+ - Proyecto TypeScript recomendado (el paquete incluye `.d.ts`).
9
+
10
+ ## Instalación
11
+
12
+ ```bash
13
+ npm install sdk-sapi2-promarketing
14
+ ```
15
+
16
+ Con yarn o pnpm:
17
+
18
+ ```bash
19
+ yarn add sdk-sapi2-promarketing
20
+ pnpm add sdk-sapi2-promarketing
21
+ ```
22
+
23
+ ## Uso rápido
24
+
25
+ La clase principal es **`SdkSAPI`**. Debes construir un objeto **`SdkSapiContext`** con la URL base, proxy, skin y callbacks que necesites.
26
+
27
+ ### ESM (`import`)
28
+
29
+ ```typescript
30
+ import { SdkSAPI, type SdkSapiContext } from "sdk-sapi2-promarketing";
31
+
32
+ const context: SdkSapiContext = {
33
+ url: "https://api.ejemplo.com",
34
+ proxy: "/api/proxy",
35
+ skin: "mi-skin",
36
+ skinContent: "contenido-skin",
37
+ onlyServer: false,
38
+ token: () => "Bearer-token-desde-tu-auth",
39
+ callback401: async () => {
40
+ // Renovar sesión o redirigir login
41
+ },
42
+ };
43
+
44
+ const client = new SdkSAPI(context);
45
+
46
+ // Los métodos vienen de los servicios mezclados (p. ej. GameService, PlayerService).
47
+ // Consulta el tipado de SdkSAPI en tu IDE o el código fuente de `services/`.
48
+ ```
49
+
50
+ ### CommonJS (`require`)
51
+
52
+ ```javascript
53
+ const { SdkSAPI } = require("sdk-sapi2-promarketing");
54
+
55
+ const client = new SdkSAPI({
56
+ url: "https://api.ejemplo.com",
57
+ proxy: "/api/proxy",
58
+ skin: "mi-skin",
59
+ skinContent: "contenido-skin",
60
+ onlyServer: false,
61
+ });
62
+ ```
63
+
64
+ ### Tipos (interfaces)
65
+
66
+ Los tipos de dominio se reexportan desde la raíz del paquete:
67
+
68
+ ```typescript
69
+ import type { QueryType, PlayerType } from "sdk-sapi2-promarketing";
70
+ ```
71
+
72
+ ## Contexto (`SdkSapiContext`)
73
+
74
+ | Campo | Descripción |
75
+ |--------|-------------|
76
+ | `url` | URL base del servicio (opcional según cómo montes el `fetch`). |
77
+ | `proxy` | Prefijo o ruta proxy usada por las peticiones relativas. |
78
+ | `skin` | Identificador de skin. |
79
+ | `skinContent` | Identificador de contenido de skin. |
80
+ | `onlyServer` | Si es `true`, las peticiones usan `url` directamente; si es `false` o se omite, usan la ruta relativa con `proxy`. |
81
+ | `valueToken` / `token` | Token Bearer en caché y/o función que lo devuelve (requerida cuando el endpoint pide autenticación). |
82
+ | `callback401` | Opcional: lógica ante respuesta 401. |
83
+
84
+ Ajusta valores según el entorno (desarrollo / producción).
85
+
86
+ ## Desarrollo del paquete (mantenedores)
87
+
88
+ Clonar el repositorio, instalar dependencias y compilar:
89
+
90
+ ```bash
91
+ npm install
92
+ npm run build
93
+ ```
94
+
95
+ Simular el contenido que se publicará en npm:
96
+
97
+ ```bash
98
+ npm pack --dry-run
99
+ ```
100
+
101
+ La salida va a `dist/` (JS, MJS y declaraciones TypeScript).
102
+
103
+ ## Enlaces
104
+
105
+ - **Repositorio:** [Bitbucket — skin2-sdk-sapi](https://bitbucket.org/promarketing/skin2-sdk-sapi)
106
+ - **Issues:** ver `package.json` → `bugs.url`
107
+
108
+ ## Licencia
109
+
110
+ `UNLICENSED` — uso restringido según política interna de Promarketing. Para términos exactos, consulta con el equipo legal o el propietario del paquete en npm.