@moonbase.sh/storefront-api 3.7.0 → 3.8.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 +41 -1
- package/dist/index.cjs +37 -6
- package/dist/index.d.cts +1482 -1335
- package/dist/index.d.ts +1482 -1335
- package/dist/index.js +37 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -56,7 +56,13 @@ function utmToObject(utm) {
|
|
|
56
56
|
utm_campaign: utm == null ? void 0 : utm.campaign,
|
|
57
57
|
utm_term: utm == null ? void 0 : utm.term,
|
|
58
58
|
utm_content: utm == null ? void 0 : utm.content,
|
|
59
|
-
utm_referrer: utm == null ? void 0 : utm.referrer
|
|
59
|
+
utm_referrer: utm == null ? void 0 : utm.referrer,
|
|
60
|
+
gclid: utm == null ? void 0 : utm.gclid,
|
|
61
|
+
gbraid: utm == null ? void 0 : utm.gbraid,
|
|
62
|
+
wbraid: utm == null ? void 0 : utm.wbraid,
|
|
63
|
+
fbclid: utm == null ? void 0 : utm.fbclid,
|
|
64
|
+
msclkid: utm == null ? void 0 : utm.msclkid,
|
|
65
|
+
ttclid: utm == null ? void 0 : utm.ttclid
|
|
60
66
|
}).filter(([_, value]) => value !== void 0).reduce((obj, [key, value]) => ({
|
|
61
67
|
...obj,
|
|
62
68
|
[key]: value
|
|
@@ -148,6 +154,7 @@ var schemas_exports = {};
|
|
|
148
154
|
__export(schemas_exports, {
|
|
149
155
|
downloadSchema: () => downloadSchema,
|
|
150
156
|
manifestSchema: () => manifestSchema,
|
|
157
|
+
productReleaseSchema: () => productReleaseSchema,
|
|
151
158
|
productSummarySchema: () => productSummarySchema
|
|
152
159
|
});
|
|
153
160
|
import { z as z2 } from "zod";
|
|
@@ -210,10 +217,20 @@ var productSummarySchema = z2.object({
|
|
|
210
217
|
downloadsNeedsOwnership: z2.boolean(),
|
|
211
218
|
downloadsNeedsGroupMembership: z2.boolean(),
|
|
212
219
|
// Whether this caller clears every requirement above, including the group membership the client
|
|
213
|
-
// can't see for itself.
|
|
220
|
+
// can't see for itself. False with none of them set means the merchant closed the release to everyone.
|
|
214
221
|
downloadsAllowed: z2.boolean(),
|
|
215
222
|
downloads: z2.array(downloadSchema).optional()
|
|
216
223
|
});
|
|
224
|
+
var productReleaseSchema = z2.object({
|
|
225
|
+
version: z2.string(),
|
|
226
|
+
description: z2.string().nullish(),
|
|
227
|
+
publishedAt: z2.coerce.date(),
|
|
228
|
+
// Whether this caller may download the release, resolved against its own access control: a
|
|
229
|
+
// merchant can keep past releases to owners while the current one is open to anyone.
|
|
230
|
+
downloadsAllowed: z2.boolean(),
|
|
231
|
+
downloads: z2.array(downloadSchema),
|
|
232
|
+
properties: z2.record(rawPropertyValueSchema).nullish()
|
|
233
|
+
});
|
|
217
234
|
|
|
218
235
|
// src/storefront/schemas.ts
|
|
219
236
|
var storefrontProductSchema = z3.object({
|
|
@@ -777,8 +794,12 @@ var IdentityEndpoints = class {
|
|
|
777
794
|
return userSchema.parse(identity);
|
|
778
795
|
}
|
|
779
796
|
async signUp(name, email, password, address, acceptedPrivacyPolicy, acceptedTermsAndConditions, communicationOptIn, options) {
|
|
780
|
-
const
|
|
781
|
-
|
|
797
|
+
const query = new URLSearchParams({
|
|
798
|
+
scheme: "JWT",
|
|
799
|
+
communicationOptIn: communicationOptIn ? "true" : "false",
|
|
800
|
+
...utmToObject(options == null ? void 0 : options.utm)
|
|
801
|
+
});
|
|
802
|
+
const response = await fetch(`${this.api.baseUrl}/api/customer/identity/sign-up?${query.toString()}`, {
|
|
782
803
|
method: "POST",
|
|
783
804
|
headers: {
|
|
784
805
|
"Accept": "application/json",
|
|
@@ -1027,6 +1048,15 @@ var ProductEndpoints = class {
|
|
|
1027
1048
|
const response = await this.api.fetch(`/api/customer/inventory/products/${productId}${version2 ? `?version=${version2}${this.configuration.includeManifests ? "&includeManifests=true" : ""}` : this.configuration.includeManifests ? "?includeManifests=true" : ""}`, productSummarySchema);
|
|
1028
1049
|
return response.data;
|
|
1029
1050
|
}
|
|
1051
|
+
/**
|
|
1052
|
+
* The product's published releases, highest version first, with their release notes and files,
|
|
1053
|
+
* and whether the caller may download each. Open to anyone who can see the product, signed in or
|
|
1054
|
+
* not. A page can hold fewer releases than its size, so keep following `next` while `hasMore` is set.
|
|
1055
|
+
*/
|
|
1056
|
+
async getReleases(productId, nextUrl) {
|
|
1057
|
+
const response = await this.api.fetch(nextUrl || `/api/customer/inventory/products/${productId}/releases${this.configuration.includeManifests ? "?includeManifests=true" : ""}`, paged(productReleaseSchema));
|
|
1058
|
+
return response.data;
|
|
1059
|
+
}
|
|
1030
1060
|
async getOwned(nextUrl) {
|
|
1031
1061
|
const response = await this.api.authenticatedFetch(nextUrl || `/api/customer/inventory/products${this.configuration.includeManifests ? "?includeManifests=true" : ""}`, paged(productSummarySchema));
|
|
1032
1062
|
return response.data;
|
|
@@ -1053,7 +1083,7 @@ var ProductEndpoints = class {
|
|
|
1053
1083
|
import { z as z14 } from "zod";
|
|
1054
1084
|
|
|
1055
1085
|
// package.json
|
|
1056
|
-
var version = "3.
|
|
1086
|
+
var version = "3.8.0";
|
|
1057
1087
|
|
|
1058
1088
|
// src/utils/client.ts
|
|
1059
1089
|
function buildClientHeader(sdk) {
|
|
@@ -2667,7 +2697,8 @@ function parseOffSiteReferrer(rawReferrer, currentOrigin) {
|
|
|
2667
2697
|
}
|
|
2668
2698
|
function resolveUtm(cached, fresh) {
|
|
2669
2699
|
const freshHasUtm = !!(fresh.source || fresh.medium || fresh.campaign || fresh.term || fresh.content);
|
|
2670
|
-
const
|
|
2700
|
+
const freshHasClickId = !!(fresh.gclid || fresh.gbraid || fresh.wbraid || fresh.fbclid || fresh.msclkid || fresh.ttclid);
|
|
2701
|
+
const freshIsExternalArrival = freshHasUtm || freshHasClickId || !!fresh.referrer;
|
|
2671
2702
|
if (freshIsExternalArrival)
|
|
2672
2703
|
return fresh;
|
|
2673
2704
|
return cached != null ? cached : fresh;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonbase.sh/storefront-api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.8.0",
|
|
5
5
|
"description": "Package to let you build storefronts with Moonbase.sh as payment and delivery provider",
|
|
6
6
|
"author": "Tobias Lønnerød Madsen <m@dsen.tv>",
|
|
7
7
|
"license": "MIT",
|