@moonbase.sh/storefront-api 0.1.94 → 0.1.96
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/dist/index.cjs +31 -6
- package/dist/index.d.cts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +29 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -40,7 +40,8 @@ __export(src_exports, {
|
|
|
40
40
|
NotAuthorizedError: () => NotAuthorizedError,
|
|
41
41
|
NotFoundError: () => NotFoundError,
|
|
42
42
|
OrderStatus: () => OrderStatus,
|
|
43
|
-
Platform: () => Platform
|
|
43
|
+
Platform: () => Platform,
|
|
44
|
+
utmToObject: () => utmToObject
|
|
44
45
|
});
|
|
45
46
|
module.exports = __toCommonJS(src_exports);
|
|
46
47
|
|
|
@@ -518,9 +519,16 @@ var OrderEndpoints = class {
|
|
|
518
519
|
const response = await this.api.fetch(`/api/customer/orders/${orderId}`);
|
|
519
520
|
return orderSchema.parse(response.data);
|
|
520
521
|
}
|
|
521
|
-
async pushContent(order, checkout) {
|
|
522
|
+
async pushContent(order, checkout, utm) {
|
|
523
|
+
const query = {
|
|
524
|
+
...utmToObject(utm)
|
|
525
|
+
};
|
|
526
|
+
if (checkout) {
|
|
527
|
+
query.checkout = "true";
|
|
528
|
+
query.returnUrl = checkout.returnUrl;
|
|
529
|
+
}
|
|
522
530
|
const response = await this.api.fetch(
|
|
523
|
-
`/api/customer/orders/${order.id}
|
|
531
|
+
`/api/customer/orders/${order.id}?${new URLSearchParams(query).toString()}`,
|
|
524
532
|
"PATCH",
|
|
525
533
|
{
|
|
526
534
|
currency: order.currency,
|
|
@@ -558,13 +566,29 @@ var ProductEndpoints = class {
|
|
|
558
566
|
}
|
|
559
567
|
};
|
|
560
568
|
|
|
569
|
+
// src/globalModels.ts
|
|
570
|
+
function utmToObject(utm) {
|
|
571
|
+
return Object.entries({
|
|
572
|
+
utm_source: utm == null ? void 0 : utm.source,
|
|
573
|
+
utm_medium: utm == null ? void 0 : utm.medium,
|
|
574
|
+
utm_campaign: utm == null ? void 0 : utm.campaign,
|
|
575
|
+
utm_term: utm == null ? void 0 : utm.term,
|
|
576
|
+
utm_content: utm == null ? void 0 : utm.content,
|
|
577
|
+
utm_referrer: utm == null ? void 0 : utm.referrer
|
|
578
|
+
}).filter(([_, value]) => value !== void 0).reduce((obj, [key, value]) => ({
|
|
579
|
+
...obj,
|
|
580
|
+
[key]: value
|
|
581
|
+
}), {});
|
|
582
|
+
}
|
|
583
|
+
|
|
561
584
|
// src/storefront/endpoints.ts
|
|
562
585
|
var StorefrontEndpoints = class {
|
|
563
586
|
constructor(api) {
|
|
564
587
|
this.api = api;
|
|
565
588
|
}
|
|
566
|
-
async get() {
|
|
567
|
-
const
|
|
589
|
+
async get(utm) {
|
|
590
|
+
const query = new URLSearchParams(utmToObject(utm));
|
|
591
|
+
const response = await this.api.fetch(`/api/customer/storefront?${query.toString()}`);
|
|
568
592
|
return storefrontSchema.parse(response.data);
|
|
569
593
|
}
|
|
570
594
|
};
|
|
@@ -764,5 +788,6 @@ var MoonbaseClient = class {
|
|
|
764
788
|
NotAuthorizedError,
|
|
765
789
|
NotFoundError,
|
|
766
790
|
OrderStatus,
|
|
767
|
-
Platform
|
|
791
|
+
Platform,
|
|
792
|
+
utmToObject
|
|
768
793
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -783,6 +783,15 @@ interface Quantifiable<T> {
|
|
|
783
783
|
value: T;
|
|
784
784
|
quantity: number;
|
|
785
785
|
}
|
|
786
|
+
interface UrchinTrackingModule {
|
|
787
|
+
source?: string;
|
|
788
|
+
medium?: string;
|
|
789
|
+
campaign?: string;
|
|
790
|
+
term?: string;
|
|
791
|
+
content?: string;
|
|
792
|
+
referrer?: string;
|
|
793
|
+
}
|
|
794
|
+
declare function utmToObject(utm?: UrchinTrackingModule): Record<string, string>;
|
|
786
795
|
|
|
787
796
|
declare const licenseSchema: z.ZodObject<{
|
|
788
797
|
id: z.ZodString;
|
|
@@ -8952,7 +8961,7 @@ declare class OrderEndpoints {
|
|
|
8952
8961
|
}>;
|
|
8953
8962
|
pushContent(order: Order, checkout?: {
|
|
8954
8963
|
returnUrl: string;
|
|
8955
|
-
}): Promise<OpenOrder>;
|
|
8964
|
+
}, utm?: UrchinTrackingModule): Promise<OpenOrder>;
|
|
8956
8965
|
}
|
|
8957
8966
|
|
|
8958
8967
|
declare const downloadSchema: z.ZodObject<{
|
|
@@ -9072,7 +9081,7 @@ declare class ProductEndpoints {
|
|
|
9072
9081
|
declare class StorefrontEndpoints {
|
|
9073
9082
|
private api;
|
|
9074
9083
|
constructor(api: MoonbaseApi);
|
|
9075
|
-
get(): Promise<{
|
|
9084
|
+
get(utm?: UrchinTrackingModule): Promise<{
|
|
9076
9085
|
products: {
|
|
9077
9086
|
type: "product";
|
|
9078
9087
|
id: string;
|
|
@@ -13122,4 +13131,4 @@ declare class MoonbaseClient {
|
|
|
13122
13131
|
orders: OrderEndpoints;
|
|
13123
13132
|
}
|
|
13124
13133
|
|
|
13125
|
-
export { type Activation, ActivationMethod, type ActivationRequest, ActivationRequestStatus, ActivationStatus, type Address, type BundleLineItem, type CommunicationPreferences, type Download, type License, LicenseStatus, type LineItem, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type OpenOrder, type Order, OrderStatus, type OwnedProduct, type Page, Platform, type PricingVariation, type ProductLineItem, type Quantifiable, type Storefront, type StorefrontBundle, type StorefrontProduct, type User, type Voucher };
|
|
13134
|
+
export { type Activation, ActivationMethod, type ActivationRequest, ActivationRequestStatus, ActivationStatus, type Address, type BundleLineItem, type CommunicationPreferences, type Download, type License, LicenseStatus, type LineItem, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type OpenOrder, type Order, OrderStatus, type OwnedProduct, type Page, Platform, type PricingVariation, type ProductLineItem, type Quantifiable, type Storefront, type StorefrontBundle, type StorefrontProduct, type UrchinTrackingModule, type User, type Voucher, utmToObject };
|
package/dist/index.d.ts
CHANGED
|
@@ -783,6 +783,15 @@ interface Quantifiable<T> {
|
|
|
783
783
|
value: T;
|
|
784
784
|
quantity: number;
|
|
785
785
|
}
|
|
786
|
+
interface UrchinTrackingModule {
|
|
787
|
+
source?: string;
|
|
788
|
+
medium?: string;
|
|
789
|
+
campaign?: string;
|
|
790
|
+
term?: string;
|
|
791
|
+
content?: string;
|
|
792
|
+
referrer?: string;
|
|
793
|
+
}
|
|
794
|
+
declare function utmToObject(utm?: UrchinTrackingModule): Record<string, string>;
|
|
786
795
|
|
|
787
796
|
declare const licenseSchema: z.ZodObject<{
|
|
788
797
|
id: z.ZodString;
|
|
@@ -8952,7 +8961,7 @@ declare class OrderEndpoints {
|
|
|
8952
8961
|
}>;
|
|
8953
8962
|
pushContent(order: Order, checkout?: {
|
|
8954
8963
|
returnUrl: string;
|
|
8955
|
-
}): Promise<OpenOrder>;
|
|
8964
|
+
}, utm?: UrchinTrackingModule): Promise<OpenOrder>;
|
|
8956
8965
|
}
|
|
8957
8966
|
|
|
8958
8967
|
declare const downloadSchema: z.ZodObject<{
|
|
@@ -9072,7 +9081,7 @@ declare class ProductEndpoints {
|
|
|
9072
9081
|
declare class StorefrontEndpoints {
|
|
9073
9082
|
private api;
|
|
9074
9083
|
constructor(api: MoonbaseApi);
|
|
9075
|
-
get(): Promise<{
|
|
9084
|
+
get(utm?: UrchinTrackingModule): Promise<{
|
|
9076
9085
|
products: {
|
|
9077
9086
|
type: "product";
|
|
9078
9087
|
id: string;
|
|
@@ -13122,4 +13131,4 @@ declare class MoonbaseClient {
|
|
|
13122
13131
|
orders: OrderEndpoints;
|
|
13123
13132
|
}
|
|
13124
13133
|
|
|
13125
|
-
export { type Activation, ActivationMethod, type ActivationRequest, ActivationRequestStatus, ActivationStatus, type Address, type BundleLineItem, type CommunicationPreferences, type Download, type License, LicenseStatus, type LineItem, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type OpenOrder, type Order, OrderStatus, type OwnedProduct, type Page, Platform, type PricingVariation, type ProductLineItem, type Quantifiable, type Storefront, type StorefrontBundle, type StorefrontProduct, type User, type Voucher };
|
|
13134
|
+
export { type Activation, ActivationMethod, type ActivationRequest, ActivationRequestStatus, ActivationStatus, type Address, type BundleLineItem, type CommunicationPreferences, type Download, type License, LicenseStatus, type LineItem, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type OpenOrder, type Order, OrderStatus, type OwnedProduct, type Page, Platform, type PricingVariation, type ProductLineItem, type Quantifiable, type Storefront, type StorefrontBundle, type StorefrontProduct, type UrchinTrackingModule, type User, type Voucher, utmToObject };
|
package/dist/index.js
CHANGED
|
@@ -472,9 +472,16 @@ var OrderEndpoints = class {
|
|
|
472
472
|
const response = await this.api.fetch(`/api/customer/orders/${orderId}`);
|
|
473
473
|
return orderSchema.parse(response.data);
|
|
474
474
|
}
|
|
475
|
-
async pushContent(order, checkout) {
|
|
475
|
+
async pushContent(order, checkout, utm) {
|
|
476
|
+
const query = {
|
|
477
|
+
...utmToObject(utm)
|
|
478
|
+
};
|
|
479
|
+
if (checkout) {
|
|
480
|
+
query.checkout = "true";
|
|
481
|
+
query.returnUrl = checkout.returnUrl;
|
|
482
|
+
}
|
|
476
483
|
const response = await this.api.fetch(
|
|
477
|
-
`/api/customer/orders/${order.id}
|
|
484
|
+
`/api/customer/orders/${order.id}?${new URLSearchParams(query).toString()}`,
|
|
478
485
|
"PATCH",
|
|
479
486
|
{
|
|
480
487
|
currency: order.currency,
|
|
@@ -512,13 +519,29 @@ var ProductEndpoints = class {
|
|
|
512
519
|
}
|
|
513
520
|
};
|
|
514
521
|
|
|
522
|
+
// src/globalModels.ts
|
|
523
|
+
function utmToObject(utm) {
|
|
524
|
+
return Object.entries({
|
|
525
|
+
utm_source: utm == null ? void 0 : utm.source,
|
|
526
|
+
utm_medium: utm == null ? void 0 : utm.medium,
|
|
527
|
+
utm_campaign: utm == null ? void 0 : utm.campaign,
|
|
528
|
+
utm_term: utm == null ? void 0 : utm.term,
|
|
529
|
+
utm_content: utm == null ? void 0 : utm.content,
|
|
530
|
+
utm_referrer: utm == null ? void 0 : utm.referrer
|
|
531
|
+
}).filter(([_, value]) => value !== void 0).reduce((obj, [key, value]) => ({
|
|
532
|
+
...obj,
|
|
533
|
+
[key]: value
|
|
534
|
+
}), {});
|
|
535
|
+
}
|
|
536
|
+
|
|
515
537
|
// src/storefront/endpoints.ts
|
|
516
538
|
var StorefrontEndpoints = class {
|
|
517
539
|
constructor(api) {
|
|
518
540
|
this.api = api;
|
|
519
541
|
}
|
|
520
|
-
async get() {
|
|
521
|
-
const
|
|
542
|
+
async get(utm) {
|
|
543
|
+
const query = new URLSearchParams(utmToObject(utm));
|
|
544
|
+
const response = await this.api.fetch(`/api/customer/storefront?${query.toString()}`);
|
|
522
545
|
return storefrontSchema.parse(response.data);
|
|
523
546
|
}
|
|
524
547
|
};
|
|
@@ -717,5 +740,6 @@ export {
|
|
|
717
740
|
NotAuthorizedError,
|
|
718
741
|
NotFoundError,
|
|
719
742
|
OrderStatus,
|
|
720
|
-
Platform
|
|
743
|
+
Platform,
|
|
744
|
+
utmToObject
|
|
721
745
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonbase.sh/storefront-api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.96",
|
|
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",
|