@thefittingroom/sdk 0.0.14 → 1.0.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.
@@ -4,27 +4,15 @@ import { SizeRecommendation } from './responses';
4
4
  export declare class TfrShop {
5
5
  private readonly brandId;
6
6
  private readonly firebase;
7
- private static avatarTimeout;
8
- static vtoTimeout: number;
9
7
  constructor(brandId: number, firebase: Firebase);
10
8
  get user(): import("..").FirebaseUser;
11
9
  get isLoggedIn(): boolean;
12
10
  onInit(): Promise<boolean>;
13
- tryOn(colorwaySizeAssetSku: string): Promise<types.TryOnFrames>;
14
- awaitAvatarCreated(): Promise<boolean>;
15
11
  getRecommendedSizes(styleId: string): Promise<SizeRecommendation>;
16
- getRecommendedSizesLabels(styleId: string): Promise<{
17
- recommendedSizeLabel: string;
18
- availableSizeLabels: string[];
19
- }>;
20
- getStyles(ids: number[], skus: string[]): Promise<Map<number, types.FirestoreStyle>>;
21
- getMeasurementLocationsByStyleId(styleId: number): Promise<any[]>;
22
12
  submitTelephoneNumber(tel: string): Promise<void>;
23
13
  getColorwaySizeAssetFromSku(colorwaySizeAssetSku: string): Promise<types.FirestoreColorwaySizeAsset>;
24
- private awaitColorwaySizeAssetFrames;
25
- private requestThenGetColorwaySizeAssetFrames;
14
+ getMeasurementLocationsFromSku(sku: string): Promise<any>;
26
15
  private getColorwaySizeAssets;
27
- private requestColorwaySizeAssetFrames;
28
- private getColorwaySizeAssetFrames;
16
+ private getStyleCategory;
29
17
  }
30
18
  export declare const initShop: (brandId: number, env?: string) => TfrShop;
@@ -10,5 +10,6 @@ export declare class Firebase {
10
10
  unsubscribe: () => void;
11
11
  };
12
12
  getDocs(collectionName: string, constraints: QueryFieldFilterConstraint[]): Promise<QuerySnapshot<DocumentData>>;
13
+ getDoc(collectionName: string, id: string): Promise<DocumentData>;
13
14
  private promisefyOnSnapshot;
14
15
  }
@@ -6,4 +6,3 @@ export type { Firebase } from './firebase/firebase';
6
6
  export type { FirebaseUser } from './firebase/firebase-user';
7
7
  export * as Errors from './helpers/errors';
8
8
  export * as types from './types';
9
- export declare const VTO_TIMEOUT_MS: number;
package/dist/esm/index.js CHANGED
@@ -1,7 +1,19 @@
1
1
  /*!
2
- * thefittingroom v0.0.14 (2024-02-15T17:46:47.656Z)
2
+ * thefittingroom v0.0.14 (2024-02-15T22:20:33.087Z)
3
3
  * Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
4
4
  */
5
+ // Code generated by tygo. DO NOT EDIT.
6
+
7
+ var requests = /*#__PURE__*/Object.freeze({
8
+ __proto__: null
9
+ });
10
+
11
+ // Code generated by tygo. DO NOT EDIT.
12
+
13
+ var responses = /*#__PURE__*/Object.freeze({
14
+ __proto__: null
15
+ });
16
+
5
17
  /**
6
18
  * @license
7
19
  * Copyright 2017 Google LLC
@@ -22891,6 +22903,11 @@ class Firebase {
22891
22903
  const q = sl(Ta(this.firestore, collectionName), ...constraints);
22892
22904
  return Bl(q);
22893
22905
  }
22906
+ async getDoc(collectionName, id) {
22907
+ const docRef = Aa(this.firestore, collectionName, id);
22908
+ const docSnap = await Ol(docRef);
22909
+ return docSnap.exists() ? docSnap.data() : null;
22910
+ }
22894
22911
  }
22895
22912
 
22896
22913
  const getFirebaseError = (e) => {
@@ -22902,8 +22919,6 @@ const getFirebaseError = (e) => {
22902
22919
  }
22903
22920
  };
22904
22921
 
22905
- const asyncTry = (promise) => promise.then((data) => [null, data]).catch((error) => [error]);
22906
-
22907
22922
  var MeasurementLocation;
22908
22923
  (function (MeasurementLocation) {
22909
22924
  MeasurementLocation["ACROSS_BACK"] = "across_back";
@@ -22993,6 +23008,179 @@ const MeasurementLocationName = {
22993
23008
  [MeasurementLocation.WAIST]: 'Waist',
22994
23009
  [MeasurementLocation.WRIST]: 'Wrist',
22995
23010
  };
23011
+ var Classification;
23012
+ (function (Classification) {
23013
+ Classification["BLOUSES"] = "blouses";
23014
+ Classification["COATS"] = "coats";
23015
+ Classification["DRESSES"] = "dresses";
23016
+ Classification["JACKETS"] = "jackets";
23017
+ Classification["PANTS"] = "pants";
23018
+ Classification["PUFFERS_AND_PARKAS"] = "puffer_and_parkas";
23019
+ Classification["SHORTS"] = "shorts";
23020
+ Classification["SKIRTS"] = "skirts";
23021
+ Classification["SWEATERS"] = "sweaters";
23022
+ Classification["T_SHIRTS_AND_TANKS"] = "t_shirts_and_tanks";
23023
+ })(Classification || (Classification = {}));
23024
+ const ClassificationLocations = {
23025
+ [Classification.BLOUSES]: [
23026
+ MeasurementLocation.BUST,
23027
+ MeasurementLocation.ACROSS_SHOULDER,
23028
+ MeasurementLocation.WAIST,
23029
+ MeasurementLocation.LOW_HIP,
23030
+ MeasurementLocation.HIGH_HIP,
23031
+ ],
23032
+ // prettier-ignore
23033
+ [Classification.COATS]: [
23034
+ MeasurementLocation.BUST,
23035
+ MeasurementLocation.ACROSS_SHOULDER,
23036
+ MeasurementLocation.WAIST,
23037
+ MeasurementLocation.LOW_HIP,
23038
+ MeasurementLocation.HIGH_HIP
23039
+ ],
23040
+ [Classification.DRESSES]: [
23041
+ MeasurementLocation.LOW_HIP,
23042
+ MeasurementLocation.BUST,
23043
+ MeasurementLocation.ACROSS_SHOULDER,
23044
+ MeasurementLocation.WAIST,
23045
+ ],
23046
+ [Classification.JACKETS]: [
23047
+ MeasurementLocation.BUST,
23048
+ MeasurementLocation.ACROSS_SHOULDER,
23049
+ MeasurementLocation.WAIST,
23050
+ MeasurementLocation.LOW_HIP,
23051
+ MeasurementLocation.HIGH_HIP,
23052
+ ],
23053
+ [Classification.PANTS]: [
23054
+ MeasurementLocation.LOW_HIP,
23055
+ MeasurementLocation.WAIST,
23056
+ MeasurementLocation.THIGH,
23057
+ MeasurementLocation.INSEAM,
23058
+ ],
23059
+ [Classification.PUFFERS_AND_PARKAS]: [
23060
+ MeasurementLocation.BUST,
23061
+ MeasurementLocation.ACROSS_SHOULDER,
23062
+ MeasurementLocation.WAIST,
23063
+ MeasurementLocation.LOW_HIP,
23064
+ MeasurementLocation.HIGH_HIP,
23065
+ ],
23066
+ [Classification.SHORTS]: [
23067
+ MeasurementLocation.LOW_HIP,
23068
+ MeasurementLocation.WAIST,
23069
+ MeasurementLocation.THIGH,
23070
+ MeasurementLocation.INSEAM,
23071
+ ],
23072
+ // prettier-ignore
23073
+ [Classification.SKIRTS]: [
23074
+ MeasurementLocation.LOW_HIP,
23075
+ MeasurementLocation.WAIST
23076
+ ],
23077
+ // prettier-ignore
23078
+ [Classification.SWEATERS]: [
23079
+ MeasurementLocation.BUST,
23080
+ MeasurementLocation.ACROSS_SHOULDER,
23081
+ MeasurementLocation.WAIST,
23082
+ MeasurementLocation.LOW_HIP,
23083
+ MeasurementLocation.HIGH_HIP
23084
+ ],
23085
+ // prettier-ignore
23086
+ [Classification.T_SHIRTS_AND_TANKS]: [
23087
+ MeasurementLocation.BUST,
23088
+ MeasurementLocation.ACROSS_SHOULDER,
23089
+ MeasurementLocation.WAIST,
23090
+ MeasurementLocation.LOW_HIP,
23091
+ MeasurementLocation.HIGH_HIP
23092
+ ],
23093
+ };
23094
+ const Taxonomy = {
23095
+ ["activewear" /* Category.ACTIVEWEAR */]: {
23096
+ ["leggings" /* Subcategory.LEGGINGS */]: Classification.PANTS,
23097
+ ["joggers" /* Subcategory.JOGGERS */]: Classification.PANTS,
23098
+ ["sweatshirts" /* Subcategory.SWEATSHIRTS */]: Classification.SWEATERS,
23099
+ },
23100
+ ["dresses" /* Category.DRESSES */]: {
23101
+ ["a_line" /* Subcategory.A_LINE */]: Classification.DRESSES,
23102
+ ["bodycon" /* Subcategory.BODYCON */]: Classification.DRESSES,
23103
+ ["fit_and_flare" /* Subcategory.FIT_AND_FLARE */]: Classification.DRESSES,
23104
+ ["knit" /* Subcategory.KNIT */]: Classification.DRESSES,
23105
+ ["shirt" /* Subcategory.SHIRT */]: Classification.DRESSES,
23106
+ ["slip" /* Subcategory.SLIP */]: Classification.DRESSES,
23107
+ ["straight" /* Subcategory.STRAIGHT */]: Classification.DRESSES,
23108
+ ["wrap" /* Subcategory.WRAP */]: Classification.DRESSES,
23109
+ },
23110
+ ["jackets_and_coats" /* Category.JACKETS_AND_COATS */]: {
23111
+ ["denim_jackets" /* Subcategory.DENIM_JACKETS */]: Classification.JACKETS,
23112
+ ["parkas" /* Subcategory.PARKAS */]: Classification.PUFFERS_AND_PARKAS,
23113
+ ["peacoats" /* Subcategory.PEACOATS */]: Classification.COATS,
23114
+ ["puffer_jackets" /* Subcategory.PUFFER_JACKETS */]: Classification.PUFFERS_AND_PARKAS,
23115
+ ["raincoats" /* Subcategory.RAINCOATS */]: Classification.COATS,
23116
+ ["rompers" /* Subcategory.ROMPERS */]: Classification.COATS,
23117
+ ["shackets" /* Subcategory.SHACKETS */]: Classification.JACKETS,
23118
+ ["trench_coats" /* Subcategory.TRENCH_COATS */]: Classification.COATS,
23119
+ },
23120
+ ["jeans" /* Category.JEANS */]: {
23121
+ ["bootcut" /* Subcategory.BOOTCUT */]: Classification.PANTS,
23122
+ ["flared" /* Subcategory.FLARED */]: Classification.PANTS,
23123
+ ["mom" /* Subcategory.MOM */]: Classification.PANTS,
23124
+ ["relaxed" /* Subcategory.RELAXED */]: Classification.PANTS,
23125
+ ["skinny" /* Subcategory.SKINNY */]: Classification.PANTS,
23126
+ ["slim" /* Subcategory.SLIM */]: Classification.PANTS,
23127
+ ["straight" /* Subcategory.STRAIGHT */]: Classification.PANTS,
23128
+ ["tapered" /* Subcategory.TAPERED */]: Classification.PANTS,
23129
+ ["wide_leg" /* Subcategory.WIDE_LEG */]: Classification.PANTS,
23130
+ },
23131
+ ["jumpsuits_and_rompers" /* Category.JUMPSUITS_AND_ROMPERS */]: {
23132
+ ["boiler_suits" /* Subcategory.BOILER_SUITS */]: Classification.DRESSES,
23133
+ ["denim" /* Subcategory.DENIM */]: Classification.DRESSES,
23134
+ ["jumpsuits" /* Subcategory.JUMPSUITS */]: Classification.DRESSES,
23135
+ ["overalls" /* Subcategory.OVERALLS */]: Classification.DRESSES,
23136
+ ["rompers" /* Subcategory.ROMPERS */]: Classification.DRESSES,
23137
+ ["unitards" /* Subcategory.UNITARDS */]: Classification.DRESSES,
23138
+ },
23139
+ ["pants_and_shorts" /* Category.PANTS_AND_SHORTS */]: {
23140
+ ["cigarette" /* Subcategory.CIGARETTE */]: Classification.PANTS,
23141
+ ["culottes" /* Subcategory.CULOTTES */]: Classification.SHORTS,
23142
+ ["denim_shorts" /* Subcategory.DENIM_SHORTS */]: Classification.SHORTS,
23143
+ ["flared" /* Subcategory.FLARED */]: Classification.PANTS,
23144
+ ["joggers" /* Subcategory.JOGGERS */]: Classification.PANTS,
23145
+ ["leggings" /* Subcategory.LEGGINGS */]: Classification.PANTS,
23146
+ ["skinny" /* Subcategory.SKINNY */]: Classification.PANTS,
23147
+ ["wide_leg" /* Subcategory.WIDE_LEG */]: Classification.PANTS,
23148
+ },
23149
+ ["skirts" /* Category.SKIRTS */]: {
23150
+ ["a_line_flared" /* Subcategory.A_LINE_FLARED */]: Classification.SKIRTS,
23151
+ ["denim" /* Subcategory.DENIM */]: Classification.SKIRTS,
23152
+ ["knit" /* Subcategory.KNIT */]: Classification.SKIRTS,
23153
+ ["pencil" /* Subcategory.PENCIL */]: Classification.SKIRTS,
23154
+ ["pleated" /* Subcategory.PLEATED */]: Classification.SKIRTS,
23155
+ ["skater" /* Subcategory.SKATER */]: Classification.SKIRTS,
23156
+ ["slip" /* Subcategory.SLIP */]: Classification.SKIRTS,
23157
+ ["wrap" /* Subcategory.WRAP */]: Classification.SKIRTS,
23158
+ },
23159
+ ["suits_and_tailoring" /* Category.SUITS_AND_TAILORING */]: {
23160
+ ["blazers" /* Subcategory.BLAZERS */]: Classification.JACKETS,
23161
+ ["suit_jackets" /* Subcategory.SUIT_JACKETS */]: Classification.JACKETS,
23162
+ ["suit_skirts" /* Subcategory.SUIT_SKIRTS */]: Classification.SKIRTS,
23163
+ ["suit_trousers" /* Subcategory.SUIT_TROUSERS */]: Classification.PANTS,
23164
+ ["suit_vests" /* Subcategory.SUIT_VESTS */]: Classification.SWEATERS,
23165
+ ["trousers" /* Subcategory.TROUSERS */]: Classification.PANTS,
23166
+ },
23167
+ ["sweaters" /* Category.SWEATERS */]: {
23168
+ ["cardigans" /* Subcategory.CARDIGANS */]: Classification.SWEATERS,
23169
+ ["crewnecks" /* Subcategory.CREWNECKS */]: Classification.SWEATERS,
23170
+ ["hoodies_and_zipups" /* Subcategory.HOODIES_AND_ZIPUPS */]: Classification.SWEATERS,
23171
+ ["sweatshirts" /* Subcategory.SWEATSHIRTS */]: Classification.SWEATERS,
23172
+ ["turtlenecks" /* Subcategory.TURTLENECKS */]: Classification.SWEATERS,
23173
+ ["v_necks" /* Subcategory.V_NECKS */]: Classification.SWEATERS,
23174
+ },
23175
+ ["tops" /* Category.TOPS */]: {
23176
+ ["bodysuits" /* Subcategory.BODYSUITS */]: Classification.BLOUSES,
23177
+ ["corsets_and_bustiers" /* Subcategory.CORSETS_AND_BUSTIERS */]: Classification.BLOUSES,
23178
+ ["polos" /* Subcategory.POLOS */]: Classification.T_SHIRTS_AND_TANKS,
23179
+ ["shirts_and_blouses" /* Subcategory.SHIRTS_AND_BLOUSES */]: Classification.BLOUSES,
23180
+ ["t_shirts" /* Subcategory.T_SHIRTS */]: Classification.T_SHIRTS_AND_TANKS,
23181
+ ["tank_tops_and_camisoles" /* Subcategory.TANK_TOPS_AND_CAMISOLES */]: Classification.T_SHIRTS_AND_TANKS,
23182
+ },
23183
+ };
22996
23184
 
22997
23185
  class Fetcher {
22998
23186
  static get endpoint() {
@@ -23042,22 +23230,11 @@ class Fetcher {
23042
23230
  }
23043
23231
  }
23044
23232
 
23045
- const testImage = (url) => {
23046
- const img = new Image();
23047
- img.src = url;
23048
- return new Promise((resolve) => {
23049
- img.onerror = () => resolve(false);
23050
- img.onload = () => resolve(true);
23051
- });
23052
- };
23053
-
23054
23233
  class TfrShop {
23055
23234
  constructor(brandId, firebase) {
23056
23235
  this.brandId = brandId;
23057
23236
  this.firebase = firebase;
23058
- const config = Config.getInstance().config;
23059
- TfrShop.avatarTimeout = config.avatarTimeout ? Number(config.avatarTimeout) : 120000;
23060
- TfrShop.vtoTimeout = config.vtoTimeout ? Number(config.vtoTimeout) : 120000;
23237
+ Config.getInstance().config;
23061
23238
  }
23062
23239
  get user() {
23063
23240
  return this.firebase.user;
@@ -23068,32 +23245,6 @@ class TfrShop {
23068
23245
  onInit() {
23069
23246
  return this.firebase.onInit();
23070
23247
  }
23071
- async tryOn(colorwaySizeAssetSku) {
23072
- if (!this.isLoggedIn)
23073
- throw new UserNotLoggedInError();
23074
- try {
23075
- const frames = await this.getColorwaySizeAssetFrames(colorwaySizeAssetSku);
23076
- return frames;
23077
- }
23078
- catch (error) {
23079
- if (!(error instanceof NoFramesFoundError))
23080
- throw error;
23081
- return this.requestThenGetColorwaySizeAssetFrames(colorwaySizeAssetSku);
23082
- }
23083
- }
23084
- async awaitAvatarCreated() {
23085
- if (!this.isLoggedIn)
23086
- throw new UserNotLoggedInError();
23087
- const { promise, unsubscribe } = this.firebase.query('users', rl(Eh(), '==', this.user.id));
23088
- const cancel = setTimeout(() => {
23089
- unsubscribe();
23090
- throw new RequestTimeoutError();
23091
- }, TfrShop.avatarTimeout);
23092
- const snapshot = await promise;
23093
- clearTimeout(cancel);
23094
- const userProfile = snapshot.docs[0].data();
23095
- return userProfile.avatar_status === 'CREATED';
23096
- }
23097
23248
  async getRecommendedSizes(styleId) {
23098
23249
  if (!this.isLoggedIn)
23099
23250
  throw new UserNotLoggedInError();
@@ -23108,38 +23259,6 @@ class TfrShop {
23108
23259
  throw error;
23109
23260
  }
23110
23261
  }
23111
- async getRecommendedSizesLabels(styleId) {
23112
- const sizeRecommendation = await this.getRecommendedSizes(styleId);
23113
- const recommendedSizeLabel = sizeRecommendation.recommended_sizes.label || sizeRecommendation.recommended_sizes.size_value.size;
23114
- const availableSizeLabels = sizeRecommendation.available_sizes.map((size) => size.label || size.size_value.size);
23115
- return { recommendedSizeLabel, availableSizeLabels };
23116
- }
23117
- async getStyles(ids, skus) {
23118
- const constraints = [rl('brand_id', '==', this.brandId)];
23119
- if ((ids === null || ids === void 0 ? void 0 : ids.length) > 0)
23120
- constraints.push(rl('id', 'in', ids));
23121
- if ((skus === null || skus === void 0 ? void 0 : skus.length) > 0)
23122
- constraints.push(rl('brand_style_id', 'in', skus));
23123
- try {
23124
- const querySnapshot = await this.firebase.getDocs('styles', constraints);
23125
- const styles = new Map();
23126
- querySnapshot.forEach((doc) => {
23127
- const FirestoreStyle = doc.data();
23128
- styles.set(FirestoreStyle.id, FirestoreStyle);
23129
- });
23130
- return styles;
23131
- }
23132
- catch (error) {
23133
- return getFirebaseError(error);
23134
- }
23135
- }
23136
- async getMeasurementLocationsByStyleId(styleId) {
23137
- const styles = await this.getStyles([styleId], []);
23138
- const style = styles.get(styleId);
23139
- if (!(style === null || style === void 0 ? void 0 : style.sizes.length))
23140
- return [];
23141
- return style.sizes[0].garment_measurements.map((measurement) => MeasurementLocationName[measurement.garment_measurement_location]);
23142
- }
23143
23262
  async submitTelephoneNumber(tel) {
23144
23263
  const sanitizedTel = tel.replace(/[^\+0-9]/g, '');
23145
23264
  const res = await Fetcher.Post(this.user, '/ios-app-link', { phone_number: sanitizedTel }, false);
@@ -23151,48 +23270,14 @@ class TfrShop {
23151
23270
  throw new NoColorwaySizeAssetsFoundError();
23152
23271
  return Array.from(assets.values())[0];
23153
23272
  }
23154
- async awaitColorwaySizeAssetFrames(colorwaySizeAssetSKU) {
23155
- var _a, _b, _c, _d;
23156
- if (!this.isLoggedIn)
23157
- throw new UserNotLoggedInError();
23158
- const predicate = async (data) => {
23159
- var _a, _b, _c, _d;
23160
- const frames = (_d = (_c = (_b = (_a = data.docs[0].data()) === null || _a === void 0 ? void 0 : _a.vto) === null || _b === void 0 ? void 0 : _b[this.brandId]) === null || _c === void 0 ? void 0 : _c[colorwaySizeAssetSKU]) === null || _d === void 0 ? void 0 : _d.frames;
23161
- if (!(frames === null || frames === void 0 ? void 0 : frames.length))
23162
- return false;
23163
- return testImage(frames[0]);
23164
- };
23165
- const userProfile = (await this.user.watchUserProfileForChanges(predicate, TfrShop.vtoTimeout));
23166
- if (!((_d = (_c = (_b = (_a = userProfile === null || userProfile === void 0 ? void 0 : userProfile.vto) === null || _a === void 0 ? void 0 : _a[this.brandId]) === null || _b === void 0 ? void 0 : _b[colorwaySizeAssetSKU]) === null || _c === void 0 ? void 0 : _c.frames) === null || _d === void 0 ? void 0 : _d.length))
23167
- throw new NoFramesFoundError();
23168
- return userProfile.vto[this.brandId][colorwaySizeAssetSKU].frames;
23169
- }
23170
- async requestThenGetColorwaySizeAssetFrames(colorwaySizeAssetSku) {
23171
- var _a, _b;
23172
- const [error, colorwaySizeAsset] = await asyncTry(this.getColorwaySizeAssetFromSku(colorwaySizeAssetSku));
23173
- if (error)
23174
- throw error;
23175
- try {
23176
- await this.requestColorwaySizeAssetFrames(colorwaySizeAsset.id);
23177
- return this.awaitColorwaySizeAssetFrames(colorwaySizeAssetSku);
23178
- }
23179
- catch (error) {
23180
- if ((error === null || error === void 0 ? void 0 : error.error) === AvatarNotCreated)
23181
- throw new AvatarNotCreatedError();
23182
- if (!error.recommended_size_id)
23183
- throw new Error(error);
23184
- const errorOutsideRecommended = error;
23185
- const styles = await this.getStyles([colorwaySizeAsset.style_id], null);
23186
- const style = styles.get(colorwaySizeAsset.style_id);
23187
- if (!(style === null || style === void 0 ? void 0 : style.sizes))
23188
- throw new NoStylesFoundError();
23189
- const recommendedSize = ((_a = style.sizes[errorOutsideRecommended.recommended_size_id]) === null || _a === void 0 ? void 0 : _a.label) ||
23190
- ((_b = style.sizes[errorOutsideRecommended.recommended_size_id]) === null || _b === void 0 ? void 0 : _b.size);
23191
- const availableSizes = errorOutsideRecommended.available_size_ids
23192
- .filter((id) => { var _a; return ((_a = style.sizes[id]) === null || _a === void 0 ? void 0 : _a.size) !== recommendedSize; })
23193
- .map((id) => { var _a, _b; return ((_a = style.sizes[id]) === null || _a === void 0 ? void 0 : _a.label) || ((_b = style.sizes[id]) === null || _b === void 0 ? void 0 : _b.size); });
23194
- throw new RecommendedAvailableSizesError(recommendedSize, availableSizes);
23195
- }
23273
+ async getMeasurementLocationsFromSku(sku) {
23274
+ var _a;
23275
+ const asset = await this.getColorwaySizeAssetFromSku(sku);
23276
+ const styleCategory = await this.getStyleCategory(asset.style_id);
23277
+ const classificationLocation = ((_a = Taxonomy[styleCategory.category]) === null || _a === void 0 ? void 0 : _a[styleCategory.sub_category]) || null;
23278
+ return classificationLocation
23279
+ ? ClassificationLocations[classificationLocation].map((location) => MeasurementLocationName[location])
23280
+ : null;
23196
23281
  }
23197
23282
  async getColorwaySizeAssets(styleId, skus) {
23198
23283
  const constraints = [rl('brand_id', '==', this.brandId)];
@@ -23213,29 +23298,16 @@ class TfrShop {
23213
23298
  return getFirebaseError(error);
23214
23299
  }
23215
23300
  }
23216
- async requestColorwaySizeAssetFrames(colorwaySizeAssetId) {
23217
- if (!this.isLoggedIn)
23218
- throw new UserNotLoggedInError();
23219
- if (!this.user.brandUserId)
23220
- throw new BrandUserIdNotSetError();
23221
- await Fetcher.Post(this.user, `/colorway-size-assets/${colorwaySizeAssetId}/frames`, {
23222
- brand_user_id: String(this.user.brandUserId),
23223
- });
23224
- }
23225
- async getColorwaySizeAssetFrames(colorwaySizeAssetSKU) {
23226
- var _a, _b, _c;
23227
- const userProfile = await this.user.getUserProfile();
23228
- const frames = ((_c = (_b = (_a = userProfile === null || userProfile === void 0 ? void 0 : userProfile.vto) === null || _a === void 0 ? void 0 : _a[this.brandId]) === null || _b === void 0 ? void 0 : _b[colorwaySizeAssetSKU]) === null || _c === void 0 ? void 0 : _c.frames) || [];
23229
- if (!frames.length)
23230
- throw new NoFramesFoundError();
23231
- const testedImage = await testImage(frames[0]);
23232
- if (!testedImage)
23233
- throw new NoFramesFoundError();
23234
- return frames;
23301
+ async getStyleCategory(styleId) {
23302
+ try {
23303
+ const doc = await this.firebase.getDoc('style_categories', String(styleId));
23304
+ return doc;
23305
+ }
23306
+ catch (error) {
23307
+ return getFirebaseError(error);
23308
+ }
23235
23309
  }
23236
23310
  }
23237
- TfrShop.avatarTimeout = 120000;
23238
- TfrShop.vtoTimeout = 120000;
23239
23311
  const initShop = (brandId, env = 'dev') => {
23240
23312
  if (env === 'dev' || env === 'development')
23241
23313
  console.warn('TfrShop is in development mode');
@@ -23243,18 +23315,6 @@ const initShop = (brandId, env = 'dev') => {
23243
23315
  return new TfrShop(brandId, new Firebase());
23244
23316
  };
23245
23317
 
23246
- // Code generated by tygo. DO NOT EDIT.
23247
-
23248
- var requests = /*#__PURE__*/Object.freeze({
23249
- __proto__: null
23250
- });
23251
-
23252
- // Code generated by tygo. DO NOT EDIT.
23253
-
23254
- var responses = /*#__PURE__*/Object.freeze({
23255
- __proto__: null
23256
- });
23257
-
23258
23318
  var AvatarState;
23259
23319
  (function (AvatarState) {
23260
23320
  AvatarState["NOT_CREATED"] = "NOT_CREATED";
@@ -23267,7 +23327,5 @@ var index = /*#__PURE__*/Object.freeze({
23267
23327
  get AvatarState () { return AvatarState; }
23268
23328
  });
23269
23329
 
23270
- const VTO_TIMEOUT_MS = TfrShop.vtoTimeout;
23271
-
23272
- export { errors as Errors, VTO_TIMEOUT_MS, initShop, requests, responses, index as types };
23330
+ export { errors as Errors, initShop, requests, responses, index as types };
23273
23331
  //# sourceMappingURL=index.js.map