@moonbase.sh/storefront-api
Advanced tools
Comparing version 0.2.41 to 0.2.42
@@ -187,3 +187,2 @@ var __defProp = Object.defineProperty; | ||
import fetch from "cross-fetch"; | ||
import { z as z8 } from "zod"; | ||
@@ -354,3 +353,3 @@ // src/utils/problemHandler.ts | ||
async update(name, email, emailConfirmationToken, communicationPreferences) { | ||
const response = await this.api.authenticatedFetch("/api/customer/identity", z8.null(), { | ||
const response = await this.api.authenticatedFetch("/api/customer/identity", null, { | ||
method: "PATCH", | ||
@@ -369,3 +368,3 @@ body: { | ||
async setPassword(currentPassword, newPassword) { | ||
await this.api.authenticatedFetch(`/api/customer/identity/set-password`, z8.null(), { | ||
await this.api.authenticatedFetch(`/api/customer/identity/set-password`, null, { | ||
method: "POST", | ||
@@ -379,3 +378,3 @@ body: { | ||
async forgotPassword(email) { | ||
await this.api.fetch(`/api/customer/identity/forgot-password?email=${encodeURIComponent(email)}`, z8.null(), { method: "POST" }); | ||
await this.api.fetch(`/api/customer/identity/forgot-password?email=${encodeURIComponent(email)}`, null, { method: "POST" }); | ||
} | ||
@@ -405,6 +404,6 @@ async resetPassword(email, newPassword, code) { | ||
async confirmEmail(email, code) { | ||
await this.api.fetch(`/api/customer/identity/confirm-email?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`, z8.null(), { method: "POST" }); | ||
await this.api.fetch(`/api/customer/identity/confirm-email?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`, null, { method: "POST" }); | ||
} | ||
async confirmEmailChange(email, code) { | ||
await this.api.authenticatedFetch(`/api/customer/identity/confirm-email-change?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`, z8.null(), { method: "POST" }); | ||
await this.api.authenticatedFetch(`/api/customer/identity/confirm-email-change?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`, null, { method: "POST" }); | ||
} | ||
@@ -423,3 +422,3 @@ }; | ||
}); | ||
import { z as z9 } from "zod"; | ||
import { z as z8 } from "zod"; | ||
@@ -436,19 +435,19 @@ // src/orders/models.ts | ||
// src/orders/schemas.ts | ||
var couponSchema = z9.object({ | ||
code: z9.string(), | ||
name: z9.string(), | ||
description: z9.string() | ||
var couponSchema = z8.object({ | ||
code: z8.string(), | ||
name: z8.string(), | ||
description: z8.string() | ||
}); | ||
var lineItemProductSchema = z9.object({ | ||
id: z9.string(), | ||
name: z9.string(), | ||
tagline: z9.string(), | ||
iconUrl: z9.string().nullable() | ||
var lineItemProductSchema = z8.object({ | ||
id: z8.string(), | ||
name: z8.string(), | ||
tagline: z8.string(), | ||
iconUrl: z8.string().nullable() | ||
}); | ||
var openProductLineItem = z9.object({ | ||
id: z9.string(), | ||
type: z9.literal("Product"), | ||
productId: z9.string(), | ||
quantity: z9.number(), | ||
variationId: z9.string(), | ||
var openProductLineItem = z8.object({ | ||
id: z8.string(), | ||
type: z8.literal("Product"), | ||
productId: z8.string(), | ||
quantity: z8.number(), | ||
variationId: z8.string(), | ||
price: priceCollectionSchema.optional(), | ||
@@ -459,18 +458,18 @@ variation: pricingVariationSchema.optional(), | ||
}); | ||
var lineItemBundleSchema = z9.object({ | ||
id: z9.string(), | ||
name: z9.string(), | ||
tagline: z9.string(), | ||
iconUrl: z9.string().nullable(), | ||
partial: z9.boolean(), | ||
products: lineItemProductSchema.and(z9.object({ | ||
included: z9.boolean().optional() | ||
var lineItemBundleSchema = z8.object({ | ||
id: z8.string(), | ||
name: z8.string(), | ||
tagline: z8.string(), | ||
iconUrl: z8.string().nullable(), | ||
partial: z8.boolean(), | ||
products: lineItemProductSchema.and(z8.object({ | ||
included: z8.boolean().optional() | ||
})).array() | ||
}); | ||
var openBundleLineItem = z9.object({ | ||
id: z9.string(), | ||
type: z9.literal("Bundle"), | ||
bundleId: z9.string(), | ||
quantity: z9.number(), | ||
variationId: z9.string(), | ||
var openBundleLineItem = z8.object({ | ||
id: z8.string(), | ||
type: z8.literal("Bundle"), | ||
bundleId: z8.string(), | ||
quantity: z8.number(), | ||
variationId: z8.string(), | ||
price: priceCollectionSchema.optional(), | ||
@@ -481,20 +480,20 @@ variation: pricingVariationSchema.optional(), | ||
}); | ||
var openOrderLineItem = z9.discriminatedUnion("type", [ | ||
var openOrderLineItem = z8.discriminatedUnion("type", [ | ||
openProductLineItem, | ||
openBundleLineItem | ||
]); | ||
var openOrderSchema = z9.object({ | ||
id: z9.string(), | ||
status: z9.literal("Open" /* Open */), | ||
currency: z9.string(), | ||
var openOrderSchema = z8.object({ | ||
id: z8.string(), | ||
status: z8.literal("Open" /* Open */), | ||
currency: z8.string(), | ||
items: openOrderLineItem.array(), | ||
couponsApplied: couponSchema.array(), | ||
checkoutUrl: z9.string().optional(), | ||
embeddedCheckoutUrl: z9.string().optional() | ||
checkoutUrl: z8.string().optional(), | ||
embeddedCheckoutUrl: z8.string().optional() | ||
}); | ||
var moneySchema = z9.object({ | ||
currency: z9.string(), | ||
amount: z9.number() | ||
var moneySchema = z8.object({ | ||
currency: z8.string(), | ||
amount: z8.number() | ||
}); | ||
var orderTotalSchema = z9.object({ | ||
var orderTotalSchema = z8.object({ | ||
original: moneySchema, | ||
@@ -506,13 +505,13 @@ discount: moneySchema, | ||
}); | ||
var customerSnapshotSchema = z9.object({ | ||
name: z9.string().nullable(), | ||
businessName: z9.string().nullable(), | ||
taxId: z9.string().nullable(), | ||
email: z9.string().nullable(), | ||
var customerSnapshotSchema = z8.object({ | ||
name: z8.string().nullable(), | ||
businessName: z8.string().nullable(), | ||
taxId: z8.string().nullable(), | ||
email: z8.string().nullable(), | ||
address: addressSchema.nullable() | ||
}); | ||
var completedOrderSchema = z9.object({ | ||
id: z9.string(), | ||
status: z9.literal("Completed" /* Completed */), | ||
currency: z9.string(), | ||
var completedOrderSchema = z8.object({ | ||
id: z8.string(), | ||
status: z8.literal("Completed" /* Completed */), | ||
currency: z8.string(), | ||
customer: customerSnapshotSchema, | ||
@@ -523,3 +522,3 @@ total: orderTotalSchema, | ||
}); | ||
var orderSchema = z9.discriminatedUnion("status", [ | ||
var orderSchema = z8.discriminatedUnion("status", [ | ||
openOrderSchema, | ||
@@ -590,3 +589,2 @@ completedOrderSchema | ||
import fetch2 from "cross-fetch"; | ||
import { ZodNull } from "zod"; | ||
var MoonbaseApi = class { | ||
@@ -623,5 +621,5 @@ constructor(baseUrl, tokenStore) { | ||
try { | ||
json = await response.json(); | ||
json = schema ? await response.json() : null; | ||
return { | ||
data: schema instanceof ZodNull ? null : schema.parse(json), | ||
data: schema ? schema.parse(json) : null, | ||
headers: Object.fromEntries(response.headers.entries()), | ||
@@ -633,2 +631,3 @@ status: response.status | ||
status: response.status, | ||
path, | ||
content: json || (response.bodyUsed ? "unknown" : await response.text()), | ||
@@ -750,9 +749,9 @@ headers: Object.fromEntries(response.headers.entries()), | ||
// src/vouchers/schemas.ts | ||
import { z as z10 } from "zod"; | ||
var voucherSchema = z10.object({ | ||
id: z10.string(), | ||
name: z10.string(), | ||
description: z10.string(), | ||
code: z10.string(), | ||
redeemed: z10.boolean(), | ||
import { z as z9 } from "zod"; | ||
var voucherSchema = z9.object({ | ||
id: z9.string(), | ||
name: z9.string(), | ||
description: z9.string(), | ||
code: z9.string(), | ||
redeemed: z9.boolean(), | ||
redeemsProducts: quantifiable(storefrontProductSchema).array(), | ||
@@ -784,6 +783,6 @@ redeemsBundles: quantifiable(storefrontBundleSchema).array() | ||
// src/inventory/activation/endpoints.ts | ||
import { z as z12 } from "zod"; | ||
import { z as z11 } from "zod"; | ||
// src/inventory/licenses/schemas.ts | ||
import { z as z11 } from "zod"; | ||
import { z as z10 } from "zod"; | ||
@@ -808,17 +807,17 @@ // src/inventory/licenses/models.ts | ||
// src/inventory/licenses/schemas.ts | ||
var licenseSchema = z11.object({ | ||
id: z11.string(), | ||
status: z11.nativeEnum(LicenseStatus), | ||
var licenseSchema = z10.object({ | ||
id: z10.string(), | ||
status: z10.nativeEnum(LicenseStatus), | ||
product: productSummarySchema, | ||
activeNumberOfActivations: z11.number(), | ||
maxNumberOfActivations: z11.number(), | ||
createdAt: z11.coerce.date() | ||
activeNumberOfActivations: z10.number(), | ||
maxNumberOfActivations: z10.number(), | ||
createdAt: z10.coerce.date() | ||
}); | ||
var activationSchema = z11.object({ | ||
id: z11.string(), | ||
licenseId: z11.string(), | ||
name: z11.string(), | ||
status: z11.nativeEnum(ActivationStatus), | ||
activationMethod: z11.nativeEnum(ActivationMethod), | ||
lastValidatedAt: z11.coerce.date().nullable() | ||
var activationSchema = z10.object({ | ||
id: z10.string(), | ||
licenseId: z10.string(), | ||
name: z10.string(), | ||
status: z10.nativeEnum(ActivationStatus), | ||
activationMethod: z10.nativeEnum(ActivationMethod), | ||
lastValidatedAt: z10.coerce.date().nullable() | ||
}); | ||
@@ -839,3 +838,3 @@ | ||
license: response.data, | ||
url: z12.string().parse(response.headers.location) | ||
url: z11.string().parse(response.headers.location) | ||
}; | ||
@@ -846,3 +845,2 @@ } | ||
// src/inventory/licenses/endpoints.ts | ||
import { z as z13 } from "zod"; | ||
var LicenseEndpoints = class { | ||
@@ -864,3 +862,3 @@ constructor(api) { | ||
async revokeActivation(licenseId, activationId) { | ||
await this.api.authenticatedFetch(`/api/customer/inventory/licenses/${licenseId}/activations/${activationId}/revoke`, z13.null(), { method: "POST" }); | ||
await this.api.authenticatedFetch(`/api/customer/inventory/licenses/${licenseId}/activations/${activationId}/revoke`, null, { method: "POST" }); | ||
} | ||
@@ -870,3 +868,3 @@ }; | ||
// src/inventory/products/endpoints.ts | ||
import { z as z14 } from "zod"; | ||
import { z as z12 } from "zod"; | ||
var ProductEndpoints = class { | ||
@@ -895,4 +893,4 @@ constructor(api) { | ||
url.searchParams.append("redirect", "false"); | ||
const response = await this.api.fetch(url.pathname + url.search, z14.object({ | ||
location: z14.string() | ||
const response = await this.api.fetch(url.pathname + url.search, z12.object({ | ||
location: z12.string() | ||
})); | ||
@@ -899,0 +897,0 @@ return response.data.location; |
{ | ||
"name": "@moonbase.sh/storefront-api", | ||
"type": "module", | ||
"version": "0.2.41", | ||
"version": "0.2.42", | ||
"description": "Package to let you build storefronts with Moonbase.sh as payment and delivery provider", | ||
@@ -6,0 +6,0 @@ "author": "Tobias Lønnerød Madsen <m@dsen.tv>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
845243
12542