@moonbase.sh/storefront-api 0.3.21 → 0.3.23

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 CHANGED
@@ -35,7 +35,9 @@ __export(index_exports, {
35
35
  ActivationRequestStatus: () => ActivationRequestStatus,
36
36
  ActivationStatus: () => ActivationStatus,
37
37
  CycleLength: () => CycleLength,
38
+ InMemoryStore: () => InMemoryStore,
38
39
  LicenseStatus: () => LicenseStatus,
40
+ LocalStorageStore: () => LocalStorageStore,
39
41
  MoonbaseApi: () => MoonbaseApi,
40
42
  MoonbaseClient: () => MoonbaseClient,
41
43
  MoonbaseError: () => MoonbaseError,
@@ -1033,6 +1035,32 @@ var LocalStorageStore = class {
1033
1035
  }
1034
1036
  }
1035
1037
  };
1038
+ var InMemoryStore = class {
1039
+ constructor() {
1040
+ this.store = {};
1041
+ this.listeners = {};
1042
+ }
1043
+ get(key) {
1044
+ var _a;
1045
+ return (_a = this.store[key]) != null ? _a : null;
1046
+ }
1047
+ set(key, item) {
1048
+ this.store[key] = item;
1049
+ for (const listener of this.listeners[key] || []) {
1050
+ listener(item);
1051
+ }
1052
+ }
1053
+ remove(key) {
1054
+ delete this.store[key];
1055
+ for (const listener of this.listeners[key] || []) {
1056
+ listener(null);
1057
+ }
1058
+ }
1059
+ listen(key, callback) {
1060
+ if (!this.listeners[key]) this.listeners[key] = [];
1061
+ this.listeners[key].push(callback);
1062
+ }
1063
+ };
1036
1064
 
1037
1065
  // src/utils/tokenStore.ts
1038
1066
  var _TokenStore = class _TokenStore {
@@ -1042,7 +1070,7 @@ var _TokenStore = class _TokenStore {
1042
1070
  this.refreshTimeoutId = null;
1043
1071
  this.refreshPromise = null;
1044
1072
  var _a;
1045
- this.store = (_a = configuration.store) != null ? _a : new LocalStorageStore();
1073
+ this.store = ((_a = configuration.store) != null ? _a : localStorage) ? new LocalStorageStore() : new InMemoryStore();
1046
1074
  const storedToken = this.store.get(_TokenStore.storageKey);
1047
1075
  if (storedToken) {
1048
1076
  this.tokens = {
@@ -1212,7 +1240,9 @@ var MoonbaseClient = class {
1212
1240
  ActivationRequestStatus,
1213
1241
  ActivationStatus,
1214
1242
  CycleLength,
1243
+ InMemoryStore,
1215
1244
  LicenseStatus,
1245
+ LocalStorageStore,
1216
1246
  MoonbaseApi,
1217
1247
  MoonbaseClient,
1218
1248
  MoonbaseError,
package/dist/index.d.cts CHANGED
@@ -18545,6 +18545,20 @@ interface IStore {
18545
18545
  remove(key: string): void;
18546
18546
  listen<TItem>(key: string, callback: (item: TItem | null) => void): void;
18547
18547
  }
18548
+ declare class LocalStorageStore implements IStore {
18549
+ get<TItem>(key: string): TItem | null;
18550
+ set<TItem>(key: string, item: TItem): void;
18551
+ remove(key: string): void;
18552
+ listen<TItem>(key: string, callback: (item: TItem | null) => void): void;
18553
+ }
18554
+ declare class InMemoryStore implements IStore {
18555
+ private readonly store;
18556
+ private readonly listeners;
18557
+ get<TItem>(key: string): TItem | null;
18558
+ set<TItem>(key: string, item: TItem): void;
18559
+ remove(key: string): void;
18560
+ listen<TItem>(key: string, callback: (item: TItem | null) => void): void;
18561
+ }
18548
18562
 
18549
18563
  declare namespace schemas {
18550
18564
  export { schemas$2 as identity, schemas$1 as orders };
@@ -22663,4 +22677,4 @@ declare class MoonbaseClient {
22663
22677
  orders: OrderEndpoints;
22664
22678
  }
22665
22679
 
22666
- export { type Activation, ActivationMethod, type ActivationRequest, ActivationRequestFulfillmentType, ActivationRequestStatus, ActivationStatus, type Address, type BundleLineItem, type CommunicationPreferences, type CompletedOrder, CycleLength, type Discount, type Download, type DownloadManifest, type IRecurrence, type ITokenStore, type License, LicenseStatus, type LineItem, type Money, MoonbaseApi, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type OpenOrder, type Order, OrderStatus, type OwnedProduct, type Page, Platform, type PricingTier, type PricingVariation, type ProblemDetails, type ProductLineItem, type Quantifiable, type Storefront, type StorefrontBundle, type StorefrontProduct, type Subscription, SubscriptionStatus, TokenStore, type UrchinTrackingModule, type User, type UserAccountConfirmed, type Vendor, type Voucher, problemDetailsSchema, schemas, utmToObject };
22680
+ export { type Activation, ActivationMethod, type ActivationRequest, ActivationRequestFulfillmentType, ActivationRequestStatus, ActivationStatus, type Address, type BundleLineItem, type CommunicationPreferences, type CompletedOrder, CycleLength, type Discount, type Download, type DownloadManifest, type IRecurrence, type IStore, type ITokenStore, InMemoryStore, type License, LicenseStatus, type LineItem, LocalStorageStore, type Money, MoonbaseApi, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type OpenOrder, type Order, OrderStatus, type OwnedProduct, type Page, Platform, type PricingTier, type PricingVariation, type ProblemDetails, type ProductLineItem, type Quantifiable, type Storefront, type StorefrontBundle, type StorefrontProduct, type Subscription, SubscriptionStatus, TokenStore, type UrchinTrackingModule, type User, type UserAccountConfirmed, type Vendor, type Voucher, problemDetailsSchema, schemas, utmToObject };
package/dist/index.d.ts CHANGED
@@ -18545,6 +18545,20 @@ interface IStore {
18545
18545
  remove(key: string): void;
18546
18546
  listen<TItem>(key: string, callback: (item: TItem | null) => void): void;
18547
18547
  }
18548
+ declare class LocalStorageStore implements IStore {
18549
+ get<TItem>(key: string): TItem | null;
18550
+ set<TItem>(key: string, item: TItem): void;
18551
+ remove(key: string): void;
18552
+ listen<TItem>(key: string, callback: (item: TItem | null) => void): void;
18553
+ }
18554
+ declare class InMemoryStore implements IStore {
18555
+ private readonly store;
18556
+ private readonly listeners;
18557
+ get<TItem>(key: string): TItem | null;
18558
+ set<TItem>(key: string, item: TItem): void;
18559
+ remove(key: string): void;
18560
+ listen<TItem>(key: string, callback: (item: TItem | null) => void): void;
18561
+ }
18548
18562
 
18549
18563
  declare namespace schemas {
18550
18564
  export { schemas$2 as identity, schemas$1 as orders };
@@ -22663,4 +22677,4 @@ declare class MoonbaseClient {
22663
22677
  orders: OrderEndpoints;
22664
22678
  }
22665
22679
 
22666
- export { type Activation, ActivationMethod, type ActivationRequest, ActivationRequestFulfillmentType, ActivationRequestStatus, ActivationStatus, type Address, type BundleLineItem, type CommunicationPreferences, type CompletedOrder, CycleLength, type Discount, type Download, type DownloadManifest, type IRecurrence, type ITokenStore, type License, LicenseStatus, type LineItem, type Money, MoonbaseApi, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type OpenOrder, type Order, OrderStatus, type OwnedProduct, type Page, Platform, type PricingTier, type PricingVariation, type ProblemDetails, type ProductLineItem, type Quantifiable, type Storefront, type StorefrontBundle, type StorefrontProduct, type Subscription, SubscriptionStatus, TokenStore, type UrchinTrackingModule, type User, type UserAccountConfirmed, type Vendor, type Voucher, problemDetailsSchema, schemas, utmToObject };
22680
+ export { type Activation, ActivationMethod, type ActivationRequest, ActivationRequestFulfillmentType, ActivationRequestStatus, ActivationStatus, type Address, type BundleLineItem, type CommunicationPreferences, type CompletedOrder, CycleLength, type Discount, type Download, type DownloadManifest, type IRecurrence, type IStore, type ITokenStore, InMemoryStore, type License, LicenseStatus, type LineItem, LocalStorageStore, type Money, MoonbaseApi, MoonbaseClient, type MoonbaseConfiguration, MoonbaseError, NotAuthenticatedError, NotAuthorizedError, NotFoundError, type OpenOrder, type Order, OrderStatus, type OwnedProduct, type Page, Platform, type PricingTier, type PricingVariation, type ProblemDetails, type ProductLineItem, type Quantifiable, type Storefront, type StorefrontBundle, type StorefrontProduct, type Subscription, SubscriptionStatus, TokenStore, type UrchinTrackingModule, type User, type UserAccountConfirmed, type Vendor, type Voucher, problemDetailsSchema, schemas, utmToObject };
package/dist/index.js CHANGED
@@ -985,6 +985,32 @@ var LocalStorageStore = class {
985
985
  }
986
986
  }
987
987
  };
988
+ var InMemoryStore = class {
989
+ constructor() {
990
+ this.store = {};
991
+ this.listeners = {};
992
+ }
993
+ get(key) {
994
+ var _a;
995
+ return (_a = this.store[key]) != null ? _a : null;
996
+ }
997
+ set(key, item) {
998
+ this.store[key] = item;
999
+ for (const listener of this.listeners[key] || []) {
1000
+ listener(item);
1001
+ }
1002
+ }
1003
+ remove(key) {
1004
+ delete this.store[key];
1005
+ for (const listener of this.listeners[key] || []) {
1006
+ listener(null);
1007
+ }
1008
+ }
1009
+ listen(key, callback) {
1010
+ if (!this.listeners[key]) this.listeners[key] = [];
1011
+ this.listeners[key].push(callback);
1012
+ }
1013
+ };
988
1014
 
989
1015
  // src/utils/tokenStore.ts
990
1016
  var _TokenStore = class _TokenStore {
@@ -994,7 +1020,7 @@ var _TokenStore = class _TokenStore {
994
1020
  this.refreshTimeoutId = null;
995
1021
  this.refreshPromise = null;
996
1022
  var _a;
997
- this.store = (_a = configuration.store) != null ? _a : new LocalStorageStore();
1023
+ this.store = ((_a = configuration.store) != null ? _a : localStorage) ? new LocalStorageStore() : new InMemoryStore();
998
1024
  const storedToken = this.store.get(_TokenStore.storageKey);
999
1025
  if (storedToken) {
1000
1026
  this.tokens = {
@@ -1163,7 +1189,9 @@ export {
1163
1189
  ActivationRequestStatus,
1164
1190
  ActivationStatus,
1165
1191
  CycleLength,
1192
+ InMemoryStore,
1166
1193
  LicenseStatus,
1194
+ LocalStorageStore,
1167
1195
  MoonbaseApi,
1168
1196
  MoonbaseClient,
1169
1197
  MoonbaseError,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moonbase.sh/storefront-api",
3
3
  "type": "module",
4
- "version": "0.3.21",
4
+ "version": "0.3.23",
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",