@pcreative/commerce-contract 1.3.5 → 1.3.6
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/package.json +1 -1
- package/src/adapters/api.js +12 -0
- package/src/index.d.ts +38 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pcreative/commerce-contract",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.6",
|
|
4
4
|
"description": "Commerce data contract: the types a theme consumes and the adapters that resolve them. No dependencies and no backend SDK.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|
package/src/adapters/api.js
CHANGED
|
@@ -532,6 +532,18 @@ export function createCommerce({
|
|
|
532
532
|
const { orders = [] } = await api("/tienda/cuenta/pedidos", { token })
|
|
533
533
|
return orders
|
|
534
534
|
},
|
|
535
|
+
async licenses(token) {
|
|
536
|
+
const { licencias = [] } = await api("/tienda/cuenta/licencias", { token })
|
|
537
|
+
return licencias
|
|
538
|
+
},
|
|
539
|
+
async releaseSite(token, licenseKey, instance) {
|
|
540
|
+
const r = await api("/tienda/cuenta/licencias/soltar", {
|
|
541
|
+
method: "POST",
|
|
542
|
+
token,
|
|
543
|
+
body: { clave: licenseKey, instancia: instance },
|
|
544
|
+
})
|
|
545
|
+
return { released: Boolean(r.soltado), site: r.sitio ?? "" }
|
|
546
|
+
},
|
|
535
547
|
async confirmEmail(sessionToken, token) {
|
|
536
548
|
try {
|
|
537
549
|
const r = await api("/tienda/cuenta/confirmar", { method: "POST", token: sessionToken, body: { token } })
|
package/src/index.d.ts
CHANGED
|
@@ -121,6 +121,33 @@ export interface License {
|
|
|
121
121
|
supportedUntil: string | null
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
/** Un sitio donde una licencia esta puesta ahora mismo. */
|
|
125
|
+
export interface LicenseSite {
|
|
126
|
+
/** Lo que identifica esa instalacion: es lo que se manda para desactivarla. */
|
|
127
|
+
instance: string
|
|
128
|
+
/** El dominio, ya normalizado (sin esquema, sin www, sin puerto). */
|
|
129
|
+
site: string
|
|
130
|
+
/** Nombre que le puso la instalacion, si lo mando. */
|
|
131
|
+
label: string | null
|
|
132
|
+
activatedAt: string | null
|
|
133
|
+
/** Ultima vez que esa instalacion comprobo la licencia. */
|
|
134
|
+
lastSeenAt: string | null
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Una licencia vista desde la cuenta de quien la compro: lo mismo que
|
|
139
|
+
* `License` mas los sitios, porque desde aqui se desactivan.
|
|
140
|
+
*/
|
|
141
|
+
export interface OwnedLicense {
|
|
142
|
+
key: string
|
|
143
|
+
status: "activa" | "caducada" | "anulada"
|
|
144
|
+
title: string | null
|
|
145
|
+
orderId: string
|
|
146
|
+
limit: number
|
|
147
|
+
supportedUntil: string | null
|
|
148
|
+
sites: LicenseSite[]
|
|
149
|
+
}
|
|
150
|
+
|
|
124
151
|
export interface ProductCode {
|
|
125
152
|
id: string
|
|
126
153
|
lineId: string
|
|
@@ -787,6 +814,17 @@ export interface CommerceClient {
|
|
|
787
814
|
me(token: string): Promise<Customer | null>
|
|
788
815
|
orders(token: string): Promise<Order[]>
|
|
789
816
|
confirmEmail?(sessionToken: string, token: string): Promise<{ adopted: number } | null>
|
|
817
|
+
/**
|
|
818
|
+
* Opcional: las licencias que ha comprado, con los sitios donde están
|
|
819
|
+
* puestas ahora mismo. Vacio si el adaptador no vende licencias.
|
|
820
|
+
*/
|
|
821
|
+
licenses?(token: string): Promise<OwnedLicense[]>
|
|
822
|
+
/**
|
|
823
|
+
* Opcional: desactiva uno de SUS sitios, que es lo que hace quien se muda
|
|
824
|
+
* de dominio. Rechaza con `status` 400 si ese sitio ya no esta activo o la
|
|
825
|
+
* licencia no es suya, y 429 si se ha pasado del tope.
|
|
826
|
+
*/
|
|
827
|
+
releaseSite?(token: string, licenseKey: string, instance: string): Promise<{ released: boolean; site: string }>
|
|
790
828
|
}
|
|
791
829
|
|
|
792
830
|
/** Opcional: nombre y datos legales de la tienda, tal y como los tiene el panel. */
|