@moonbase.sh/storefront-api 3.12.0 → 3.13.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 CHANGED
@@ -66,6 +66,22 @@ const user = await client.identity.get()
66
66
  console.log(user.email)
67
67
  ```
68
68
 
69
+ ### Save a customer's address
70
+
71
+ The signed-in customer's next checkout starts from the address saved here. A
72
+ checkout they have already entered billing details in keeps those.
73
+
74
+ ```ts
75
+ const user = await client.identity.updateAddress({
76
+ countryCode: 'AU',
77
+ streetAddress1: '1 George Street',
78
+ streetAddress2: null,
79
+ locality: 'Sydney',
80
+ region: 'NSW',
81
+ postCode: '2000',
82
+ })
83
+ ```
84
+
69
85
  ### Redeem a voucher
70
86
 
71
87
  ```ts
package/dist/index.cjs CHANGED
@@ -75,34 +75,6 @@ module.exports = __toCommonJS(index_exports);
75
75
  // src/activationRequests/endpoints.ts
76
76
  var import_zod5 = require("zod");
77
77
 
78
- // src/activationRequests/schemas.ts
79
- var schemas_exports3 = {};
80
- __export(schemas_exports3, {
81
- activationRequestSchema: () => activationRequestSchema
82
- });
83
- var import_zod4 = require("zod");
84
-
85
- // src/storefront/schemas.ts
86
- var schemas_exports2 = {};
87
- __export(schemas_exports2, {
88
- offerConditionSchema: () => offerConditionSchema,
89
- offerScopeSchema: () => offerScopeSchema,
90
- storefrontBundleSchema: () => storefrontBundleSchema,
91
- storefrontLicenseUpgradeSchema: () => storefrontLicenseUpgradeSchema,
92
- storefrontOfferSchema: () => storefrontOfferSchema,
93
- storefrontOfferTargetSchema: () => storefrontOfferTargetSchema,
94
- storefrontProductSchema: () => storefrontProductSchema,
95
- storefrontPromotionCtaSchema: () => storefrontPromotionCtaSchema,
96
- storefrontPromotionSchema: () => storefrontPromotionSchema,
97
- storefrontPromotionTargetSchema: () => storefrontPromotionTargetSchema,
98
- storefrontSchema: () => storefrontSchema,
99
- taxEstimateSchema: () => taxEstimateSchema
100
- });
101
- var import_zod3 = require("zod");
102
-
103
- // src/globalSchemas.ts
104
- var import_zod = require("zod");
105
-
106
78
  // src/globalModels.ts
107
79
  var CycleLength = /* @__PURE__ */ ((CycleLength2) => {
108
80
  CycleLength2["Daily"] = "Daily";
@@ -140,7 +112,33 @@ function utmToObject(utm) {
140
112
  }), {});
141
113
  }
142
114
 
115
+ // src/activationRequests/schemas.ts
116
+ var schemas_exports3 = {};
117
+ __export(schemas_exports3, {
118
+ activationRequestSchema: () => activationRequestSchema
119
+ });
120
+ var import_zod4 = require("zod");
121
+
122
+ // src/storefront/schemas.ts
123
+ var schemas_exports2 = {};
124
+ __export(schemas_exports2, {
125
+ offerConditionSchema: () => offerConditionSchema,
126
+ offerScopeSchema: () => offerScopeSchema,
127
+ storefrontBundleSchema: () => storefrontBundleSchema,
128
+ storefrontLicenseUpgradeSchema: () => storefrontLicenseUpgradeSchema,
129
+ storefrontOfferSchema: () => storefrontOfferSchema,
130
+ storefrontOfferTargetSchema: () => storefrontOfferTargetSchema,
131
+ storefrontProductSchema: () => storefrontProductSchema,
132
+ storefrontPromotionCtaSchema: () => storefrontPromotionCtaSchema,
133
+ storefrontPromotionSchema: () => storefrontPromotionSchema,
134
+ storefrontPromotionTargetSchema: () => storefrontPromotionTargetSchema,
135
+ storefrontSchema: () => storefrontSchema,
136
+ taxEstimateSchema: () => taxEstimateSchema
137
+ });
138
+ var import_zod3 = require("zod");
139
+
143
140
  // src/globalSchemas.ts
141
+ var import_zod = require("zod");
144
142
  var priceCollectionSchema = import_zod.z.record(import_zod.z.number());
145
143
  var discountPromotionFields = {
146
144
  promotionId: import_zod.z.string().optional(),
@@ -574,8 +572,14 @@ var ActivationRequestEndpoints = class {
574
572
  const response = await this.api.authenticatedFetch(`/api/customer/activations/${requestId}/license`, activationRequestSchema, { method: "POST" });
575
573
  return response.data;
576
574
  }
577
- async fulfillTrial(requestId) {
578
- const response = await this.api.fetch(`/api/customer/activations/${requestId}/trial`, activationRequestSchema, { method: "POST" });
575
+ /**
576
+ * Starts the trial the request's app asked for. `utm` is the tracking the visitor arrived with, which the
577
+ * trial is put down to, as a sign-up or an order is, so trials can be told apart by the marketing that
578
+ * brought them.
579
+ */
580
+ async fulfillTrial(requestId, utm) {
581
+ const query = new URLSearchParams(utmToObject(utm)).toString();
582
+ const response = await this.api.fetch(`/api/customer/activations/${requestId}/trial${query ? `?${query}` : ""}`, activationRequestSchema, { method: "POST" });
579
583
  return response.data;
580
584
  }
581
585
  async cancel(requestId) {
@@ -1058,6 +1062,20 @@ var IdentityEndpoints = class {
1058
1062
  user: response.data
1059
1063
  };
1060
1064
  }
1065
+ /**
1066
+ * Saves the signed-in customer's address, which their next checkout starts from. A checkout
1067
+ * they have already entered billing details in keeps those. Rejects with a `MoonbaseError` for
1068
+ * an address the store can't use: it needs a known country, a street address, a city or a
1069
+ * region, and in the US a postal code.
1070
+ */
1071
+ async updateAddress(address) {
1072
+ const response = await this.api.authenticatedFetch("/api/customer/identity", userSchema, {
1073
+ method: "PATCH",
1074
+ body: { address }
1075
+ });
1076
+ this.tokenStore.setUser(response.data);
1077
+ return response.data;
1078
+ }
1061
1079
  async setPassword(currentPassword, newPassword) {
1062
1080
  await this.api.authenticatedFetch(`/api/customer/identity/set-password`, null, {
1063
1081
  method: "POST",
@@ -1303,7 +1321,7 @@ var ProductEndpoints = class {
1303
1321
  var import_zod15 = require("zod");
1304
1322
 
1305
1323
  // package.json
1306
- var version = "3.12.0";
1324
+ var version = "3.13.0";
1307
1325
 
1308
1326
  // src/utils/client.ts
1309
1327
  function buildClientHeader(sdk) {