@thefittingroom/sdk 0.0.13 → 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
12
  submitTelephoneNumber(tel: string): Promise<void>;
22
13
  getColorwaySizeAssetFromSku(colorwaySizeAssetSku: string): Promise<types.FirestoreColorwaySizeAsset>;
23
- _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.11 (2023-11-21T18:22:57.333Z)
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,7 +22919,268 @@ const getFirebaseError = (e) => {
22902
22919
  }
22903
22920
  };
22904
22921
 
22905
- const asyncTry = (promise) => promise.then((data) => [null, data]).catch((error) => [error]);
22922
+ var MeasurementLocation;
22923
+ (function (MeasurementLocation) {
22924
+ MeasurementLocation["ACROSS_BACK"] = "across_back";
22925
+ MeasurementLocation["ACROSS_FRONT"] = "across_front";
22926
+ MeasurementLocation["ACROSS_SHOULDER"] = "across_shoulder";
22927
+ MeasurementLocation["ANKLE"] = "ankle";
22928
+ MeasurementLocation["ARMEYE"] = "arm_eye";
22929
+ MeasurementLocation["ARM_LENGTH_FROM_SHOULDER"] = "arm_length_from_shoulder";
22930
+ MeasurementLocation["BACK_CROTCH_LENGTH"] = "back_crotch_length";
22931
+ MeasurementLocation["BACK_NECK_TO_EBLOW"] = "back_neck_to_elbow";
22932
+ MeasurementLocation["BELOW_KNEE"] = "below_knee";
22933
+ MeasurementLocation["BICEP"] = "bicep";
22934
+ MeasurementLocation["BUST"] = "bust";
22935
+ MeasurementLocation["BUST_POINT_TO_BUST_POINT"] = "bust_point_to_bust_point";
22936
+ MeasurementLocation["CALF"] = "calf";
22937
+ MeasurementLocation["CB_NECK_TO_WAIST"] = "cb_neck_to_waist";
22938
+ MeasurementLocation["CB_NECK_TO_WRIST"] = "cb_neck_to_wrist";
22939
+ MeasurementLocation["CF_NECK_TO_WAIST"] = "cf_neck_to_waist";
22940
+ MeasurementLocation["ELBOW"] = "elbow";
22941
+ MeasurementLocation["FOREARM"] = "forearm";
22942
+ MeasurementLocation["FRONT_CROTCH_LENGTH"] = "front_crotch_length";
22943
+ MeasurementLocation["HIGH_HIP_PLACEMENT_FROM_WAIST"] = "high_hip_placement";
22944
+ MeasurementLocation["HIGH_HIP"] = "high_hip";
22945
+ MeasurementLocation["HSP_TO_ACROSS_BACK"] = "hsp_to_across_back";
22946
+ MeasurementLocation["HSP_TO_ACROSS_FRONT"] = "hsp_to_across_front";
22947
+ MeasurementLocation["HSP_TO_BUST_POINT"] = "hsp_to_bust_point";
22948
+ MeasurementLocation["HSP_TO_LOW_HIP_POSITION"] = "hsp_to_low_hip_position";
22949
+ MeasurementLocation["HSP_TO_WAIST_POSITION"] = "hsp_to_waist_position";
22950
+ MeasurementLocation["INSEAM"] = "inseam";
22951
+ MeasurementLocation["KNEE"] = "knee";
22952
+ MeasurementLocation["LOW_HIP"] = "low_hip";
22953
+ MeasurementLocation["LOW_HIP_PLACEMENT_FROM_WAIST"] = "low_hip_placement";
22954
+ MeasurementLocation["MID_NECK"] = "mid_neck";
22955
+ MeasurementLocation["NECK_AT_BASE"] = "neck_base";
22956
+ MeasurementLocation["SHOULDER_DROP"] = "shoulder_drop";
22957
+ MeasurementLocation["SHOULDER_TO_SHOULDER"] = "shoulder_to_shoulder";
22958
+ MeasurementLocation["SIDE_WAIST_TO_FLOOR"] = "side_waist_to_floor";
22959
+ MeasurementLocation["SIDE_WAIST_TO_KNEE"] = "side_waist_to_knee";
22960
+ MeasurementLocation["THIGH"] = "thigh";
22961
+ MeasurementLocation["TOTAL_RISE_LENGTH"] = "total_rise_length";
22962
+ MeasurementLocation["UNDER_BUST"] = "under_bust";
22963
+ MeasurementLocation["VERTICAL_TRUNK"] = "vertical_trunk";
22964
+ MeasurementLocation["WAIST"] = "waist";
22965
+ MeasurementLocation["WRIST"] = "wrist";
22966
+ })(MeasurementLocation || (MeasurementLocation = {}));
22967
+ const MeasurementLocationName = {
22968
+ [MeasurementLocation.ACROSS_BACK]: 'Across back',
22969
+ [MeasurementLocation.ACROSS_FRONT]: 'Across front',
22970
+ [MeasurementLocation.ACROSS_SHOULDER]: 'Across shoulder',
22971
+ [MeasurementLocation.ANKLE]: 'Ankle',
22972
+ [MeasurementLocation.ARMEYE]: 'Armeye',
22973
+ [MeasurementLocation.ARM_LENGTH_FROM_SHOULDER]: 'Arm length from shoulder',
22974
+ [MeasurementLocation.BACK_CROTCH_LENGTH]: 'Back crotch length',
22975
+ [MeasurementLocation.BACK_NECK_TO_EBLOW]: 'Back neck to eblow',
22976
+ [MeasurementLocation.BELOW_KNEE]: 'Below knee',
22977
+ [MeasurementLocation.BICEP]: 'Bicep',
22978
+ [MeasurementLocation.BUST]: 'Chest/Bust',
22979
+ [MeasurementLocation.BUST_POINT_TO_BUST_POINT]: 'Bust point to bust point',
22980
+ [MeasurementLocation.CALF]: 'Calf',
22981
+ [MeasurementLocation.CB_NECK_TO_WAIST]: 'Cb neck to waist',
22982
+ [MeasurementLocation.CB_NECK_TO_WRIST]: 'Cb neck to wrist',
22983
+ [MeasurementLocation.CF_NECK_TO_WAIST]: 'Cf neck to waist',
22984
+ [MeasurementLocation.ELBOW]: 'Elbow',
22985
+ [MeasurementLocation.FOREARM]: 'Forearm',
22986
+ [MeasurementLocation.FRONT_CROTCH_LENGTH]: 'Front crotch length',
22987
+ [MeasurementLocation.HIGH_HIP_PLACEMENT_FROM_WAIST]: 'High hip placement from waist',
22988
+ [MeasurementLocation.HIGH_HIP]: 'High hip',
22989
+ [MeasurementLocation.HSP_TO_ACROSS_BACK]: 'Hsp to across back',
22990
+ [MeasurementLocation.HSP_TO_ACROSS_FRONT]: 'Hsp to across front',
22991
+ [MeasurementLocation.HSP_TO_BUST_POINT]: 'Hsp to bust point',
22992
+ [MeasurementLocation.HSP_TO_LOW_HIP_POSITION]: 'Hsp to low hip position',
22993
+ [MeasurementLocation.HSP_TO_WAIST_POSITION]: 'Hsp to waist position',
22994
+ [MeasurementLocation.INSEAM]: 'Inseam',
22995
+ [MeasurementLocation.KNEE]: 'Knee',
22996
+ [MeasurementLocation.LOW_HIP]: 'Low hip',
22997
+ [MeasurementLocation.LOW_HIP_PLACEMENT_FROM_WAIST]: 'Low hip placement from waist',
22998
+ [MeasurementLocation.MID_NECK]: 'Mid neck',
22999
+ [MeasurementLocation.NECK_AT_BASE]: 'Neck at base',
23000
+ [MeasurementLocation.SHOULDER_DROP]: 'Shoulder drop',
23001
+ [MeasurementLocation.SHOULDER_TO_SHOULDER]: 'Shoulder to shoulder',
23002
+ [MeasurementLocation.SIDE_WAIST_TO_FLOOR]: 'Side waist to floor',
23003
+ [MeasurementLocation.SIDE_WAIST_TO_KNEE]: 'Side waist to knee',
23004
+ [MeasurementLocation.THIGH]: 'Thigh',
23005
+ [MeasurementLocation.TOTAL_RISE_LENGTH]: 'Total rise length',
23006
+ [MeasurementLocation.UNDER_BUST]: 'Under bust',
23007
+ [MeasurementLocation.VERTICAL_TRUNK]: 'Vertical trunk',
23008
+ [MeasurementLocation.WAIST]: 'Waist',
23009
+ [MeasurementLocation.WRIST]: 'Wrist',
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
+ };
22906
23184
 
22907
23185
  class Fetcher {
22908
23186
  static get endpoint() {
@@ -22952,22 +23230,11 @@ class Fetcher {
22952
23230
  }
22953
23231
  }
22954
23232
 
22955
- const testImage = (url) => {
22956
- const img = new Image();
22957
- img.src = url;
22958
- return new Promise((resolve) => {
22959
- img.onerror = () => resolve(false);
22960
- img.onload = () => resolve(true);
22961
- });
22962
- };
22963
-
22964
23233
  class TfrShop {
22965
23234
  constructor(brandId, firebase) {
22966
23235
  this.brandId = brandId;
22967
23236
  this.firebase = firebase;
22968
- const config = Config.getInstance().config;
22969
- TfrShop.avatarTimeout = config.avatarTimeout ? Number(config.avatarTimeout) : 120000;
22970
- TfrShop.vtoTimeout = config.vtoTimeout ? Number(config.vtoTimeout) : 120000;
23237
+ Config.getInstance().config;
22971
23238
  }
22972
23239
  get user() {
22973
23240
  return this.firebase.user;
@@ -22978,32 +23245,6 @@ class TfrShop {
22978
23245
  onInit() {
22979
23246
  return this.firebase.onInit();
22980
23247
  }
22981
- async tryOn(colorwaySizeAssetSku) {
22982
- if (!this.isLoggedIn)
22983
- throw new UserNotLoggedInError();
22984
- try {
22985
- const frames = await this.getColorwaySizeAssetFrames(colorwaySizeAssetSku);
22986
- return frames;
22987
- }
22988
- catch (error) {
22989
- if (!(error instanceof NoFramesFoundError))
22990
- throw error;
22991
- return this.requestThenGetColorwaySizeAssetFrames(colorwaySizeAssetSku);
22992
- }
22993
- }
22994
- async awaitAvatarCreated() {
22995
- if (!this.isLoggedIn)
22996
- throw new UserNotLoggedInError();
22997
- const { promise, unsubscribe } = this.firebase.query('users', rl(Eh(), '==', this.user.id));
22998
- const cancel = setTimeout(() => {
22999
- unsubscribe();
23000
- throw new RequestTimeoutError();
23001
- }, TfrShop.avatarTimeout);
23002
- const snapshot = await promise;
23003
- clearTimeout(cancel);
23004
- const userProfile = snapshot.docs[0].data();
23005
- return userProfile.avatar_status === 'CREATED';
23006
- }
23007
23248
  async getRecommendedSizes(styleId) {
23008
23249
  if (!this.isLoggedIn)
23009
23250
  throw new UserNotLoggedInError();
@@ -23018,31 +23259,6 @@ class TfrShop {
23018
23259
  throw error;
23019
23260
  }
23020
23261
  }
23021
- async getRecommendedSizesLabels(styleId) {
23022
- const sizeRecommendation = await this.getRecommendedSizes(styleId);
23023
- const recommendedSizeLabel = sizeRecommendation.recommended_sizes.label || sizeRecommendation.recommended_sizes.size_value.size;
23024
- const availableSizeLabels = sizeRecommendation.available_sizes.map((size) => size.label || size.size_value.size);
23025
- return { recommendedSizeLabel, availableSizeLabels };
23026
- }
23027
- async getStyles(ids, skus) {
23028
- const constraints = [rl('brand_id', '==', this.brandId)];
23029
- if ((ids === null || ids === void 0 ? void 0 : ids.length) > 0)
23030
- constraints.push(rl('id', 'in', ids));
23031
- if ((skus === null || skus === void 0 ? void 0 : skus.length) > 0)
23032
- constraints.push(rl('brand_style_id', 'in', skus));
23033
- try {
23034
- const querySnapshot = await this.firebase.getDocs('styles', constraints);
23035
- const styles = new Map();
23036
- querySnapshot.forEach((doc) => {
23037
- const FirestoreStyle = doc.data();
23038
- styles.set(FirestoreStyle.id, FirestoreStyle);
23039
- });
23040
- return styles;
23041
- }
23042
- catch (error) {
23043
- return getFirebaseError(error);
23044
- }
23045
- }
23046
23262
  async submitTelephoneNumber(tel) {
23047
23263
  const sanitizedTel = tel.replace(/[^\+0-9]/g, '');
23048
23264
  const res = await Fetcher.Post(this.user, '/ios-app-link', { phone_number: sanitizedTel }, false);
@@ -23054,54 +23270,14 @@ class TfrShop {
23054
23270
  throw new NoColorwaySizeAssetsFoundError();
23055
23271
  return Array.from(assets.values())[0];
23056
23272
  }
23057
- async _getColorwaySizeAssetFromSku(colorwaySizeAssetSku) {
23058
- const assets = await this.getColorwaySizeAssets(null, [colorwaySizeAssetSku]);
23059
- if (!(assets === null || assets === void 0 ? void 0 : assets.size))
23060
- throw new NoColorwaySizeAssetsFoundError();
23061
- return Array.from(assets.values());
23062
- }
23063
- async awaitColorwaySizeAssetFrames(colorwaySizeAssetSKU) {
23064
- var _a, _b, _c, _d;
23065
- if (!this.isLoggedIn)
23066
- throw new UserNotLoggedInError();
23067
- const predicate = async (data) => {
23068
- var _a, _b, _c, _d;
23069
- 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;
23070
- if (!(frames === null || frames === void 0 ? void 0 : frames.length))
23071
- return false;
23072
- return testImage(frames[0]);
23073
- };
23074
- const userProfile = (await this.user.watchUserProfileForChanges(predicate, TfrShop.vtoTimeout));
23075
- 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))
23076
- throw new NoFramesFoundError();
23077
- return userProfile.vto[this.brandId][colorwaySizeAssetSKU].frames;
23078
- }
23079
- async requestThenGetColorwaySizeAssetFrames(colorwaySizeAssetSku) {
23080
- var _a, _b;
23081
- const [error, colorwaySizeAsset] = await asyncTry(this.getColorwaySizeAssetFromSku(colorwaySizeAssetSku));
23082
- if (error)
23083
- throw error;
23084
- try {
23085
- await this.requestColorwaySizeAssetFrames(colorwaySizeAsset.id);
23086
- return this.awaitColorwaySizeAssetFrames(colorwaySizeAssetSku);
23087
- }
23088
- catch (error) {
23089
- if ((error === null || error === void 0 ? void 0 : error.error) === AvatarNotCreated)
23090
- throw new AvatarNotCreatedError();
23091
- if (!error.recommended_size_id)
23092
- throw new Error(error);
23093
- const errorOutsideRecommended = error;
23094
- const styles = await this.getStyles([colorwaySizeAsset.style_id], null);
23095
- const style = styles.get(colorwaySizeAsset.style_id);
23096
- if (!(style === null || style === void 0 ? void 0 : style.sizes))
23097
- throw new NoStylesFoundError();
23098
- const recommendedSize = ((_a = style.sizes[errorOutsideRecommended.recommended_size_id]) === null || _a === void 0 ? void 0 : _a.label) ||
23099
- ((_b = style.sizes[errorOutsideRecommended.recommended_size_id]) === null || _b === void 0 ? void 0 : _b.size);
23100
- const availableSizes = errorOutsideRecommended.available_size_ids
23101
- .filter((id) => { var _a; return ((_a = style.sizes[id]) === null || _a === void 0 ? void 0 : _a.size) !== recommendedSize; })
23102
- .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); });
23103
- throw new RecommendedAvailableSizesError(recommendedSize, availableSizes);
23104
- }
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;
23105
23281
  }
23106
23282
  async getColorwaySizeAssets(styleId, skus) {
23107
23283
  const constraints = [rl('brand_id', '==', this.brandId)];
@@ -23122,29 +23298,16 @@ class TfrShop {
23122
23298
  return getFirebaseError(error);
23123
23299
  }
23124
23300
  }
23125
- async requestColorwaySizeAssetFrames(colorwaySizeAssetId) {
23126
- if (!this.isLoggedIn)
23127
- throw new UserNotLoggedInError();
23128
- if (!this.user.brandUserId)
23129
- throw new BrandUserIdNotSetError();
23130
- await Fetcher.Post(this.user, `/colorway-size-assets/${colorwaySizeAssetId}/frames`, {
23131
- brand_user_id: String(this.user.brandUserId),
23132
- });
23133
- }
23134
- async getColorwaySizeAssetFrames(colorwaySizeAssetSKU) {
23135
- var _a, _b, _c;
23136
- const userProfile = await this.user.getUserProfile();
23137
- 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) || [];
23138
- if (!frames.length)
23139
- throw new NoFramesFoundError();
23140
- const testedImage = await testImage(frames[0]);
23141
- if (!testedImage)
23142
- throw new NoFramesFoundError();
23143
- 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
+ }
23144
23309
  }
23145
23310
  }
23146
- TfrShop.avatarTimeout = 120000;
23147
- TfrShop.vtoTimeout = 120000;
23148
23311
  const initShop = (brandId, env = 'dev') => {
23149
23312
  if (env === 'dev' || env === 'development')
23150
23313
  console.warn('TfrShop is in development mode');
@@ -23152,18 +23315,6 @@ const initShop = (brandId, env = 'dev') => {
23152
23315
  return new TfrShop(brandId, new Firebase());
23153
23316
  };
23154
23317
 
23155
- // Code generated by tygo. DO NOT EDIT.
23156
-
23157
- var requests = /*#__PURE__*/Object.freeze({
23158
- __proto__: null
23159
- });
23160
-
23161
- // Code generated by tygo. DO NOT EDIT.
23162
-
23163
- var responses = /*#__PURE__*/Object.freeze({
23164
- __proto__: null
23165
- });
23166
-
23167
23318
  var AvatarState;
23168
23319
  (function (AvatarState) {
23169
23320
  AvatarState["NOT_CREATED"] = "NOT_CREATED";
@@ -23176,7 +23327,5 @@ var index = /*#__PURE__*/Object.freeze({
23176
23327
  get AvatarState () { return AvatarState; }
23177
23328
  });
23178
23329
 
23179
- const VTO_TIMEOUT_MS = TfrShop.vtoTimeout;
23180
-
23181
- export { errors as Errors, VTO_TIMEOUT_MS, initShop, requests, responses, index as types };
23330
+ export { errors as Errors, initShop, requests, responses, index as types };
23182
23331
  //# sourceMappingURL=index.js.map