@commercengine/storefront-sdk 0.14.0 → 0.14.2

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.mjs CHANGED
@@ -506,7 +506,11 @@ function attachSessionAuth(client, sessionManager) {
506
506
  }
507
507
  /**
508
508
  * Storefront API client that extends the generic BaseAPIClient
509
- * Adds Commerce Engine specific authentication and token management
509
+ * Adds Commerce Engine specific authentication and token management.
510
+ *
511
+ * Session-only domain clients can extend this directly. Shared public/session
512
+ * read clients may instead extend a shared base class and call
513
+ * `attachSessionAuth()` explicitly in their concrete session wrapper.
510
514
  */
511
515
  var SessionStorefrontAPIClient = class extends StorefrontAPIClientBase {
512
516
  config;
@@ -1202,12 +1206,39 @@ var BaseCatalogClient = class extends StorefrontAPIClientBase {
1202
1206
  }
1203
1207
  };
1204
1208
 
1209
+ //#endregion
1210
+ //#region src/lib/public/client.ts
1211
+ /**
1212
+ * Storefront API client that always authenticates with `X-Api-Key`.
1213
+ *
1214
+ * This class is kept as the advanced public transport client. Concrete public
1215
+ * domain clients can either extend this directly or extend a shared base class
1216
+ * and attach the same auth behavior via `attachPublicAuth()`.
1217
+ */
1218
+ var PublicStorefrontAPIClient = class extends StorefrontAPIClientBase {
1219
+ constructor(config) {
1220
+ super(config);
1221
+ attachPublicAuth(this);
1222
+ }
1223
+ };
1224
+ function attachPublicAuth(client) {
1225
+ client.useMiddleware({ onRequest: async ({ request }) => {
1226
+ if (client.apiKey) request.headers.set("X-Api-Key", client.apiKey);
1227
+ return request;
1228
+ } });
1229
+ }
1230
+
1205
1231
  //#endregion
1206
1232
  //#region src/lib/public/catalog.ts
1207
1233
  /**
1208
1234
  * Client for interacting with catalog endpoints
1209
1235
  */
1210
- var PublicCatalogClient = class extends BaseCatalogClient {};
1236
+ var PublicCatalogClient = class extends BaseCatalogClient {
1237
+ constructor(config) {
1238
+ super(config);
1239
+ attachPublicAuth(this);
1240
+ }
1241
+ };
1211
1242
 
1212
1243
  //#endregion
1213
1244
  //#region src/lib/catalog.ts
@@ -3237,7 +3268,12 @@ var BaseHelpersClient = class extends StorefrontAPIClientBase {
3237
3268
  /**
3238
3269
  * Client for interacting with helper endpoints
3239
3270
  */
3240
- var PublicHelpersClient = class extends BaseHelpersClient {};
3271
+ var PublicHelpersClient = class extends BaseHelpersClient {
3272
+ constructor(config) {
3273
+ super(config);
3274
+ attachPublicAuth(this);
3275
+ }
3276
+ };
3241
3277
 
3242
3278
  //#endregion
3243
3279
  //#region src/lib/helper.ts
@@ -3381,7 +3417,12 @@ var BaseStoreConfigClient = class extends StorefrontAPIClientBase {
3381
3417
  /**
3382
3418
  * Client for interacting with store config endpoints
3383
3419
  */
3384
- var PublicStoreConfigClient = class extends BaseStoreConfigClient {};
3420
+ var PublicStoreConfigClient = class extends BaseStoreConfigClient {
3421
+ constructor(config) {
3422
+ super(config);
3423
+ attachPublicAuth(this);
3424
+ }
3425
+ };
3385
3426
 
3386
3427
  //#endregion
3387
3428
  //#region src/lib/store-config.ts
@@ -4113,27 +4154,6 @@ var StorefrontSessionManager = class {
4113
4154
  }
4114
4155
  };
4115
4156
 
4116
- //#endregion
4117
- //#region src/lib/public/client.ts
4118
- /**
4119
- * Storefront API client that always authenticates with `X-Api-Key`.
4120
- *
4121
- * This client is used by the public storefront surface where no session or
4122
- * token lifecycle should be involved.
4123
- */
4124
- var PublicStorefrontAPIClient = class extends StorefrontAPIClientBase {
4125
- constructor(config) {
4126
- super(config);
4127
- this.setupPublicAuth();
4128
- }
4129
- setupPublicAuth() {
4130
- this.client.use({ onRequest: async ({ request }) => {
4131
- if (this.apiKey) request.headers.set("X-Api-Key", this.apiKey);
4132
- return request;
4133
- } });
4134
- }
4135
- };
4136
-
4137
4157
  //#endregion
4138
4158
  //#region src/index.ts
4139
4159
  /**