@thefittingroom/sdk 1.4.3 → 1.5.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.
@@ -19,6 +19,7 @@ export declare class TfrShop {
19
19
  private getColorwaySizeAssets;
20
20
  getStyle(styleId: number): Promise<types.FirestoreStyleCategory>;
21
21
  getMeasurementLocationName(location: string): string;
22
+ getMeasurementLocationSortOrder(location: string): number;
22
23
  private getGetTaxonomy;
23
24
  private getMeasurementLocations;
24
25
  private fetchMeasurementLocations;
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * thefittingroom v1.4.3 (2024-08-27T23:39:34.070Z)
2
+ * thefittingroom v1.5.0 (2024-09-01T16:52:25.366Z)
3
3
  * Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
4
4
  */
5
5
  // Code generated by tygo. DO NOT EDIT.
@@ -25428,9 +25428,14 @@ class TfrShop {
25428
25428
  const filteredLocations = !filledLocations.length
25429
25429
  ? taxonomy.measurement_locations.female
25430
25430
  : taxonomy.measurement_locations.female.filter((location) => filledLocations.includes(location));
25431
- return filteredLocations.map((location) => {
25432
- return this.measurementLocations.has(location) ? this.measurementLocations.get(location) : location;
25431
+ const locationsWithSortOrder = filteredLocations.map((location) => {
25432
+ return this.measurementLocations.has(location)
25433
+ ? this.measurementLocations.get(location)
25434
+ : { name: location, sort_order: Infinity };
25433
25435
  });
25436
+ return locationsWithSortOrder
25437
+ .sort((a, b) => (a.sort_order < b.sort_order ? -1 : 0))
25438
+ .map((location) => location.name);
25434
25439
  }
25435
25440
  async getMeasurementLocationsFromBrandStyleId(brandStyleId, filledLocations = []) {
25436
25441
  const asset = await this.getColorwaySizeAssetFromBrandStyleId(brandStyleId);
@@ -25445,9 +25450,14 @@ class TfrShop {
25445
25450
  const filteredLocations = !filledLocations.length
25446
25451
  ? taxonomy.measurement_locations.female
25447
25452
  : taxonomy.measurement_locations.female.filter((location) => filledLocations.includes(location));
25448
- return filteredLocations.map((location) => {
25449
- return this.measurementLocations.has(location) ? this.measurementLocations.get(location) : location;
25453
+ const locationsWithSortOrder = filteredLocations.map((location) => {
25454
+ return this.measurementLocations.has(location)
25455
+ ? this.measurementLocations.get(location)
25456
+ : { name: location, sort_order: Infinity };
25450
25457
  });
25458
+ return locationsWithSortOrder
25459
+ .sort((a, b) => (a.sort_order < b.sort_order ? -1 : 0))
25460
+ .map((location) => location.name);
25451
25461
  }
25452
25462
  async getStyleByBrandStyleId(brandStyleId) {
25453
25463
  var _a, _b;
@@ -25490,7 +25500,10 @@ class TfrShop {
25490
25500
  }
25491
25501
  }
25492
25502
  getMeasurementLocationName(location) {
25493
- return this.measurementLocations.has(location) ? this.measurementLocations.get(location) : location;
25503
+ return this.measurementLocations.has(location) ? this.measurementLocations.get(location).name : location;
25504
+ }
25505
+ getMeasurementLocationSortOrder(location) {
25506
+ return this.measurementLocations.has(location) ? this.measurementLocations.get(location).sort_order : Infinity;
25494
25507
  }
25495
25508
  async getGetTaxonomy(styleId) {
25496
25509
  try {
@@ -25504,7 +25517,7 @@ class TfrShop {
25504
25517
  async getMeasurementLocations() {
25505
25518
  const locations = await this.fetchMeasurementLocations();
25506
25519
  locations.forEach((location) => {
25507
- this.measurementLocations.set(location.name, location.garment_label);
25520
+ this.measurementLocations.set(location.name, { name: location.garment_label, sort_order: location.sort_order });
25508
25521
  });
25509
25522
  }
25510
25523
  async fetchMeasurementLocations() {