@thefittingroom/sdk 0.0.14 → 1.0.1
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/esm/api/responses.d.ts +11 -1
- package/dist/esm/api/shop.d.ts +2 -14
- package/dist/esm/firebase/firebase.d.ts +1 -0
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.js +230 -153
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +189 -188
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/types/index.d.ts +5 -0
- package/dist/esm/types/measurement.d.ts +192 -0
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Fit, MeasurementLocation } from '../types/measurement';
|
|
1
2
|
export interface BodyMeasurement {
|
|
2
3
|
id: number;
|
|
3
4
|
position: number;
|
|
@@ -65,9 +66,18 @@ export interface SizeRecommendationIDs {
|
|
|
65
66
|
recommended_size_id: number;
|
|
66
67
|
available_size_ids: number[];
|
|
67
68
|
}
|
|
69
|
+
export interface MeasurementLocationFits {
|
|
70
|
+
measurement_location: MeasurementLocation;
|
|
71
|
+
fit: Fit[];
|
|
72
|
+
}
|
|
73
|
+
export interface Fits {
|
|
74
|
+
size_id: number;
|
|
75
|
+
measurement_location_fits: MeasurementLocationFits[];
|
|
76
|
+
}
|
|
68
77
|
export interface SizeRecommendation {
|
|
69
|
-
|
|
78
|
+
recommended_size: Size;
|
|
70
79
|
available_sizes: Size[];
|
|
80
|
+
fits: Fits[];
|
|
71
81
|
}
|
|
72
82
|
export interface GarmentMeasurement {
|
|
73
83
|
id: number;
|
package/dist/esm/api/shop.d.ts
CHANGED
|
@@ -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
|
-
|
|
25
|
-
private requestThenGetColorwaySizeAssetFrames;
|
|
14
|
+
getMeasurementLocationsFromSku(sku: string): Promise<any>;
|
|
26
15
|
private getColorwaySizeAssets;
|
|
27
|
-
private
|
|
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
|
}
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* thefittingroom
|
|
2
|
+
* thefittingroom v1.0.1 (2024-02-16T14:45:03.763Z)
|
|
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
|
+
var responses = /*#__PURE__*/Object.freeze({
|
|
12
|
+
__proto__: null
|
|
13
|
+
});
|
|
14
|
+
|
|
5
15
|
/**
|
|
6
16
|
* @license
|
|
7
17
|
* Copyright 2017 Google LLC
|
|
@@ -22891,6 +22901,11 @@ class Firebase {
|
|
|
22891
22901
|
const q = sl(Ta(this.firestore, collectionName), ...constraints);
|
|
22892
22902
|
return Bl(q);
|
|
22893
22903
|
}
|
|
22904
|
+
async getDoc(collectionName, id) {
|
|
22905
|
+
const docRef = Aa(this.firestore, collectionName, id);
|
|
22906
|
+
const docSnap = await Ol(docRef);
|
|
22907
|
+
return docSnap.exists() ? docSnap.data() : null;
|
|
22908
|
+
}
|
|
22894
22909
|
}
|
|
22895
22910
|
|
|
22896
22911
|
const getFirebaseError = (e) => {
|
|
@@ -22902,8 +22917,6 @@ const getFirebaseError = (e) => {
|
|
|
22902
22917
|
}
|
|
22903
22918
|
};
|
|
22904
22919
|
|
|
22905
|
-
const asyncTry = (promise) => promise.then((data) => [null, data]).catch((error) => [error]);
|
|
22906
|
-
|
|
22907
22920
|
var MeasurementLocation;
|
|
22908
22921
|
(function (MeasurementLocation) {
|
|
22909
22922
|
MeasurementLocation["ACROSS_BACK"] = "across_back";
|
|
@@ -22993,6 +23006,198 @@ const MeasurementLocationName = {
|
|
|
22993
23006
|
[MeasurementLocation.WAIST]: 'Waist',
|
|
22994
23007
|
[MeasurementLocation.WRIST]: 'Wrist',
|
|
22995
23008
|
};
|
|
23009
|
+
var Classification;
|
|
23010
|
+
(function (Classification) {
|
|
23011
|
+
Classification["BLOUSES"] = "blouses";
|
|
23012
|
+
Classification["COATS"] = "coats";
|
|
23013
|
+
Classification["DRESSES"] = "dresses";
|
|
23014
|
+
Classification["JACKETS"] = "jackets";
|
|
23015
|
+
Classification["PANTS"] = "pants";
|
|
23016
|
+
Classification["PUFFERS_AND_PARKAS"] = "puffer_and_parkas";
|
|
23017
|
+
Classification["SHORTS"] = "shorts";
|
|
23018
|
+
Classification["SKIRTS"] = "skirts";
|
|
23019
|
+
Classification["SWEATERS"] = "sweaters";
|
|
23020
|
+
Classification["T_SHIRTS_AND_TANKS"] = "t_shirts_and_tanks";
|
|
23021
|
+
})(Classification || (Classification = {}));
|
|
23022
|
+
const ClassificationLocations = {
|
|
23023
|
+
[Classification.BLOUSES]: [
|
|
23024
|
+
MeasurementLocation.BUST,
|
|
23025
|
+
MeasurementLocation.ACROSS_SHOULDER,
|
|
23026
|
+
MeasurementLocation.WAIST,
|
|
23027
|
+
MeasurementLocation.LOW_HIP,
|
|
23028
|
+
MeasurementLocation.HIGH_HIP,
|
|
23029
|
+
],
|
|
23030
|
+
// prettier-ignore
|
|
23031
|
+
[Classification.COATS]: [
|
|
23032
|
+
MeasurementLocation.BUST,
|
|
23033
|
+
MeasurementLocation.ACROSS_SHOULDER,
|
|
23034
|
+
MeasurementLocation.WAIST,
|
|
23035
|
+
MeasurementLocation.LOW_HIP,
|
|
23036
|
+
MeasurementLocation.HIGH_HIP
|
|
23037
|
+
],
|
|
23038
|
+
[Classification.DRESSES]: [
|
|
23039
|
+
MeasurementLocation.LOW_HIP,
|
|
23040
|
+
MeasurementLocation.BUST,
|
|
23041
|
+
MeasurementLocation.ACROSS_SHOULDER,
|
|
23042
|
+
MeasurementLocation.WAIST,
|
|
23043
|
+
],
|
|
23044
|
+
[Classification.JACKETS]: [
|
|
23045
|
+
MeasurementLocation.BUST,
|
|
23046
|
+
MeasurementLocation.ACROSS_SHOULDER,
|
|
23047
|
+
MeasurementLocation.WAIST,
|
|
23048
|
+
MeasurementLocation.LOW_HIP,
|
|
23049
|
+
MeasurementLocation.HIGH_HIP,
|
|
23050
|
+
],
|
|
23051
|
+
[Classification.PANTS]: [
|
|
23052
|
+
MeasurementLocation.LOW_HIP,
|
|
23053
|
+
MeasurementLocation.WAIST,
|
|
23054
|
+
MeasurementLocation.THIGH,
|
|
23055
|
+
MeasurementLocation.INSEAM,
|
|
23056
|
+
],
|
|
23057
|
+
[Classification.PUFFERS_AND_PARKAS]: [
|
|
23058
|
+
MeasurementLocation.BUST,
|
|
23059
|
+
MeasurementLocation.ACROSS_SHOULDER,
|
|
23060
|
+
MeasurementLocation.WAIST,
|
|
23061
|
+
MeasurementLocation.LOW_HIP,
|
|
23062
|
+
MeasurementLocation.HIGH_HIP,
|
|
23063
|
+
],
|
|
23064
|
+
[Classification.SHORTS]: [
|
|
23065
|
+
MeasurementLocation.LOW_HIP,
|
|
23066
|
+
MeasurementLocation.WAIST,
|
|
23067
|
+
MeasurementLocation.THIGH,
|
|
23068
|
+
MeasurementLocation.INSEAM,
|
|
23069
|
+
],
|
|
23070
|
+
// prettier-ignore
|
|
23071
|
+
[Classification.SKIRTS]: [
|
|
23072
|
+
MeasurementLocation.LOW_HIP,
|
|
23073
|
+
MeasurementLocation.WAIST
|
|
23074
|
+
],
|
|
23075
|
+
// prettier-ignore
|
|
23076
|
+
[Classification.SWEATERS]: [
|
|
23077
|
+
MeasurementLocation.BUST,
|
|
23078
|
+
MeasurementLocation.ACROSS_SHOULDER,
|
|
23079
|
+
MeasurementLocation.WAIST,
|
|
23080
|
+
MeasurementLocation.LOW_HIP,
|
|
23081
|
+
MeasurementLocation.HIGH_HIP
|
|
23082
|
+
],
|
|
23083
|
+
// prettier-ignore
|
|
23084
|
+
[Classification.T_SHIRTS_AND_TANKS]: [
|
|
23085
|
+
MeasurementLocation.BUST,
|
|
23086
|
+
MeasurementLocation.ACROSS_SHOULDER,
|
|
23087
|
+
MeasurementLocation.WAIST,
|
|
23088
|
+
MeasurementLocation.LOW_HIP,
|
|
23089
|
+
MeasurementLocation.HIGH_HIP
|
|
23090
|
+
],
|
|
23091
|
+
};
|
|
23092
|
+
const Taxonomy = {
|
|
23093
|
+
["activewear" /* Category.ACTIVEWEAR */]: {
|
|
23094
|
+
["leggings" /* Subcategory.LEGGINGS */]: Classification.PANTS,
|
|
23095
|
+
["joggers" /* Subcategory.JOGGERS */]: Classification.PANTS,
|
|
23096
|
+
["sweatshirts" /* Subcategory.SWEATSHIRTS */]: Classification.SWEATERS,
|
|
23097
|
+
},
|
|
23098
|
+
["dresses" /* Category.DRESSES */]: {
|
|
23099
|
+
["a_line" /* Subcategory.A_LINE */]: Classification.DRESSES,
|
|
23100
|
+
["bodycon" /* Subcategory.BODYCON */]: Classification.DRESSES,
|
|
23101
|
+
["fit_and_flare" /* Subcategory.FIT_AND_FLARE */]: Classification.DRESSES,
|
|
23102
|
+
["knit" /* Subcategory.KNIT */]: Classification.DRESSES,
|
|
23103
|
+
["shirt" /* Subcategory.SHIRT */]: Classification.DRESSES,
|
|
23104
|
+
["slip" /* Subcategory.SLIP */]: Classification.DRESSES,
|
|
23105
|
+
["straight" /* Subcategory.STRAIGHT */]: Classification.DRESSES,
|
|
23106
|
+
["wrap" /* Subcategory.WRAP */]: Classification.DRESSES,
|
|
23107
|
+
},
|
|
23108
|
+
["jackets_and_coats" /* Category.JACKETS_AND_COATS */]: {
|
|
23109
|
+
["denim_jackets" /* Subcategory.DENIM_JACKETS */]: Classification.JACKETS,
|
|
23110
|
+
["parkas" /* Subcategory.PARKAS */]: Classification.PUFFERS_AND_PARKAS,
|
|
23111
|
+
["peacoats" /* Subcategory.PEACOATS */]: Classification.COATS,
|
|
23112
|
+
["puffer_jackets" /* Subcategory.PUFFER_JACKETS */]: Classification.PUFFERS_AND_PARKAS,
|
|
23113
|
+
["raincoats" /* Subcategory.RAINCOATS */]: Classification.COATS,
|
|
23114
|
+
["rompers" /* Subcategory.ROMPERS */]: Classification.COATS,
|
|
23115
|
+
["shackets" /* Subcategory.SHACKETS */]: Classification.JACKETS,
|
|
23116
|
+
["trench_coats" /* Subcategory.TRENCH_COATS */]: Classification.COATS,
|
|
23117
|
+
},
|
|
23118
|
+
["jeans" /* Category.JEANS */]: {
|
|
23119
|
+
["bootcut" /* Subcategory.BOOTCUT */]: Classification.PANTS,
|
|
23120
|
+
["flared" /* Subcategory.FLARED */]: Classification.PANTS,
|
|
23121
|
+
["mom" /* Subcategory.MOM */]: Classification.PANTS,
|
|
23122
|
+
["relaxed" /* Subcategory.RELAXED */]: Classification.PANTS,
|
|
23123
|
+
["skinny" /* Subcategory.SKINNY */]: Classification.PANTS,
|
|
23124
|
+
["slim" /* Subcategory.SLIM */]: Classification.PANTS,
|
|
23125
|
+
["straight" /* Subcategory.STRAIGHT */]: Classification.PANTS,
|
|
23126
|
+
["tapered" /* Subcategory.TAPERED */]: Classification.PANTS,
|
|
23127
|
+
["wide_leg" /* Subcategory.WIDE_LEG */]: Classification.PANTS,
|
|
23128
|
+
},
|
|
23129
|
+
["jumpsuits_and_rompers" /* Category.JUMPSUITS_AND_ROMPERS */]: {
|
|
23130
|
+
["boiler_suits" /* Subcategory.BOILER_SUITS */]: Classification.DRESSES,
|
|
23131
|
+
["denim" /* Subcategory.DENIM */]: Classification.DRESSES,
|
|
23132
|
+
["jumpsuits" /* Subcategory.JUMPSUITS */]: Classification.DRESSES,
|
|
23133
|
+
["overalls" /* Subcategory.OVERALLS */]: Classification.DRESSES,
|
|
23134
|
+
["rompers" /* Subcategory.ROMPERS */]: Classification.DRESSES,
|
|
23135
|
+
["unitards" /* Subcategory.UNITARDS */]: Classification.DRESSES,
|
|
23136
|
+
},
|
|
23137
|
+
["pants_and_shorts" /* Category.PANTS_AND_SHORTS */]: {
|
|
23138
|
+
["cigarette" /* Subcategory.CIGARETTE */]: Classification.PANTS,
|
|
23139
|
+
["culottes" /* Subcategory.CULOTTES */]: Classification.SHORTS,
|
|
23140
|
+
["denim_shorts" /* Subcategory.DENIM_SHORTS */]: Classification.SHORTS,
|
|
23141
|
+
["flared" /* Subcategory.FLARED */]: Classification.PANTS,
|
|
23142
|
+
["joggers" /* Subcategory.JOGGERS */]: Classification.PANTS,
|
|
23143
|
+
["leggings" /* Subcategory.LEGGINGS */]: Classification.PANTS,
|
|
23144
|
+
["skinny" /* Subcategory.SKINNY */]: Classification.PANTS,
|
|
23145
|
+
["wide_leg" /* Subcategory.WIDE_LEG */]: Classification.PANTS,
|
|
23146
|
+
},
|
|
23147
|
+
["skirts" /* Category.SKIRTS */]: {
|
|
23148
|
+
["a_line_flared" /* Subcategory.A_LINE_FLARED */]: Classification.SKIRTS,
|
|
23149
|
+
["denim" /* Subcategory.DENIM */]: Classification.SKIRTS,
|
|
23150
|
+
["knit" /* Subcategory.KNIT */]: Classification.SKIRTS,
|
|
23151
|
+
["pencil" /* Subcategory.PENCIL */]: Classification.SKIRTS,
|
|
23152
|
+
["pleated" /* Subcategory.PLEATED */]: Classification.SKIRTS,
|
|
23153
|
+
["skater" /* Subcategory.SKATER */]: Classification.SKIRTS,
|
|
23154
|
+
["slip" /* Subcategory.SLIP */]: Classification.SKIRTS,
|
|
23155
|
+
["wrap" /* Subcategory.WRAP */]: Classification.SKIRTS,
|
|
23156
|
+
},
|
|
23157
|
+
["suits_and_tailoring" /* Category.SUITS_AND_TAILORING */]: {
|
|
23158
|
+
["blazers" /* Subcategory.BLAZERS */]: Classification.JACKETS,
|
|
23159
|
+
["suit_jackets" /* Subcategory.SUIT_JACKETS */]: Classification.JACKETS,
|
|
23160
|
+
["suit_skirts" /* Subcategory.SUIT_SKIRTS */]: Classification.SKIRTS,
|
|
23161
|
+
["suit_trousers" /* Subcategory.SUIT_TROUSERS */]: Classification.PANTS,
|
|
23162
|
+
["suit_vests" /* Subcategory.SUIT_VESTS */]: Classification.SWEATERS,
|
|
23163
|
+
["trousers" /* Subcategory.TROUSERS */]: Classification.PANTS,
|
|
23164
|
+
},
|
|
23165
|
+
["sweaters" /* Category.SWEATERS */]: {
|
|
23166
|
+
["cardigans" /* Subcategory.CARDIGANS */]: Classification.SWEATERS,
|
|
23167
|
+
["crewnecks" /* Subcategory.CREWNECKS */]: Classification.SWEATERS,
|
|
23168
|
+
["hoodies_and_zipups" /* Subcategory.HOODIES_AND_ZIPUPS */]: Classification.SWEATERS,
|
|
23169
|
+
["sweatshirts" /* Subcategory.SWEATSHIRTS */]: Classification.SWEATERS,
|
|
23170
|
+
["turtlenecks" /* Subcategory.TURTLENECKS */]: Classification.SWEATERS,
|
|
23171
|
+
["v_necks" /* Subcategory.V_NECKS */]: Classification.SWEATERS,
|
|
23172
|
+
},
|
|
23173
|
+
["tops" /* Category.TOPS */]: {
|
|
23174
|
+
["bodysuits" /* Subcategory.BODYSUITS */]: Classification.BLOUSES,
|
|
23175
|
+
["corsets_and_bustiers" /* Subcategory.CORSETS_AND_BUSTIERS */]: Classification.BLOUSES,
|
|
23176
|
+
["polos" /* Subcategory.POLOS */]: Classification.T_SHIRTS_AND_TANKS,
|
|
23177
|
+
["shirts_and_blouses" /* Subcategory.SHIRTS_AND_BLOUSES */]: Classification.BLOUSES,
|
|
23178
|
+
["t_shirts" /* Subcategory.T_SHIRTS */]: Classification.T_SHIRTS_AND_TANKS,
|
|
23179
|
+
["tank_tops_and_camisoles" /* Subcategory.TANK_TOPS_AND_CAMISOLES */]: Classification.T_SHIRTS_AND_TANKS,
|
|
23180
|
+
},
|
|
23181
|
+
};
|
|
23182
|
+
var Fit;
|
|
23183
|
+
(function (Fit) {
|
|
23184
|
+
Fit["TOO_TIGHT"] = "too_tight";
|
|
23185
|
+
Fit["TIGHT"] = "tight";
|
|
23186
|
+
Fit["SLIGHTLY_TIGHT"] = "slightly_tight";
|
|
23187
|
+
Fit["PERFECT_FIT"] = "perfect_fit";
|
|
23188
|
+
Fit["SLIGHTLY_LOOSE"] = "slightly_loose";
|
|
23189
|
+
Fit["LOOSE"] = "loose";
|
|
23190
|
+
Fit["OVERSIZED"] = "oversized";
|
|
23191
|
+
})(Fit || (Fit = {}));
|
|
23192
|
+
({
|
|
23193
|
+
[Fit.TOO_TIGHT]: 'Too Tight',
|
|
23194
|
+
[Fit.TIGHT]: 'Tight',
|
|
23195
|
+
[Fit.SLIGHTLY_TIGHT]: 'Slightly Tight',
|
|
23196
|
+
[Fit.PERFECT_FIT]: 'Perfect Fit',
|
|
23197
|
+
[Fit.SLIGHTLY_LOOSE]: 'Slightly Loose',
|
|
23198
|
+
[Fit.LOOSE]: 'Loose',
|
|
23199
|
+
[Fit.OVERSIZED]: 'Oversized',
|
|
23200
|
+
});
|
|
22996
23201
|
|
|
22997
23202
|
class Fetcher {
|
|
22998
23203
|
static get endpoint() {
|
|
@@ -23042,22 +23247,10 @@ class Fetcher {
|
|
|
23042
23247
|
}
|
|
23043
23248
|
}
|
|
23044
23249
|
|
|
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
23250
|
class TfrShop {
|
|
23055
23251
|
constructor(brandId, firebase) {
|
|
23056
23252
|
this.brandId = brandId;
|
|
23057
23253
|
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;
|
|
23061
23254
|
}
|
|
23062
23255
|
get user() {
|
|
23063
23256
|
return this.firebase.user;
|
|
@@ -23068,39 +23261,16 @@ class TfrShop {
|
|
|
23068
23261
|
onInit() {
|
|
23069
23262
|
return this.firebase.onInit();
|
|
23070
23263
|
}
|
|
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
23264
|
async getRecommendedSizes(styleId) {
|
|
23265
|
+
var _a, _b;
|
|
23098
23266
|
if (!this.isLoggedIn)
|
|
23099
23267
|
throw new UserNotLoggedInError();
|
|
23100
23268
|
try {
|
|
23101
23269
|
const res = await Fetcher.Get(this.user, `/styles/${styleId}/recommendation`);
|
|
23102
|
-
const
|
|
23103
|
-
|
|
23270
|
+
const data = (await res.json());
|
|
23271
|
+
if (!((_a = data === null || data === void 0 ? void 0 : data.fits) === null || _a === void 0 ? void 0 : _a.length) || !((_b = data === null || data === void 0 ? void 0 : data.recommended_size) === null || _b === void 0 ? void 0 : _b.id))
|
|
23272
|
+
return null;
|
|
23273
|
+
return data;
|
|
23104
23274
|
}
|
|
23105
23275
|
catch (error) {
|
|
23106
23276
|
if ((error === null || error === void 0 ? void 0 : error.error) === AvatarNotCreated)
|
|
@@ -23108,38 +23278,6 @@ class TfrShop {
|
|
|
23108
23278
|
throw error;
|
|
23109
23279
|
}
|
|
23110
23280
|
}
|
|
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
23281
|
async submitTelephoneNumber(tel) {
|
|
23144
23282
|
const sanitizedTel = tel.replace(/[^\+0-9]/g, '');
|
|
23145
23283
|
const res = await Fetcher.Post(this.user, '/ios-app-link', { phone_number: sanitizedTel }, false);
|
|
@@ -23151,48 +23289,14 @@ class TfrShop {
|
|
|
23151
23289
|
throw new NoColorwaySizeAssetsFoundError();
|
|
23152
23290
|
return Array.from(assets.values())[0];
|
|
23153
23291
|
}
|
|
23154
|
-
async
|
|
23155
|
-
var _a
|
|
23156
|
-
|
|
23157
|
-
|
|
23158
|
-
const
|
|
23159
|
-
|
|
23160
|
-
|
|
23161
|
-
|
|
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
|
-
}
|
|
23292
|
+
async getMeasurementLocationsFromSku(sku) {
|
|
23293
|
+
var _a;
|
|
23294
|
+
const asset = await this.getColorwaySizeAssetFromSku(sku);
|
|
23295
|
+
const styleCategory = await this.getStyleCategory(asset.style_id);
|
|
23296
|
+
const classificationLocation = ((_a = Taxonomy[styleCategory.category]) === null || _a === void 0 ? void 0 : _a[styleCategory.sub_category]) || null;
|
|
23297
|
+
return classificationLocation
|
|
23298
|
+
? ClassificationLocations[classificationLocation].map((location) => MeasurementLocationName[location])
|
|
23299
|
+
: null;
|
|
23196
23300
|
}
|
|
23197
23301
|
async getColorwaySizeAssets(styleId, skus) {
|
|
23198
23302
|
const constraints = [rl('brand_id', '==', this.brandId)];
|
|
@@ -23213,29 +23317,16 @@ class TfrShop {
|
|
|
23213
23317
|
return getFirebaseError(error);
|
|
23214
23318
|
}
|
|
23215
23319
|
}
|
|
23216
|
-
async
|
|
23217
|
-
|
|
23218
|
-
|
|
23219
|
-
|
|
23220
|
-
|
|
23221
|
-
|
|
23222
|
-
|
|
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;
|
|
23320
|
+
async getStyleCategory(styleId) {
|
|
23321
|
+
try {
|
|
23322
|
+
const doc = await this.firebase.getDoc('style_categories', String(styleId));
|
|
23323
|
+
return doc;
|
|
23324
|
+
}
|
|
23325
|
+
catch (error) {
|
|
23326
|
+
return getFirebaseError(error);
|
|
23327
|
+
}
|
|
23235
23328
|
}
|
|
23236
23329
|
}
|
|
23237
|
-
TfrShop.avatarTimeout = 120000;
|
|
23238
|
-
TfrShop.vtoTimeout = 120000;
|
|
23239
23330
|
const initShop = (brandId, env = 'dev') => {
|
|
23240
23331
|
if (env === 'dev' || env === 'development')
|
|
23241
23332
|
console.warn('TfrShop is in development mode');
|
|
@@ -23243,18 +23334,6 @@ const initShop = (brandId, env = 'dev') => {
|
|
|
23243
23334
|
return new TfrShop(brandId, new Firebase());
|
|
23244
23335
|
};
|
|
23245
23336
|
|
|
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
23337
|
var AvatarState;
|
|
23259
23338
|
(function (AvatarState) {
|
|
23260
23339
|
AvatarState["NOT_CREATED"] = "NOT_CREATED";
|
|
@@ -23267,7 +23346,5 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
23267
23346
|
get AvatarState () { return AvatarState; }
|
|
23268
23347
|
});
|
|
23269
23348
|
|
|
23270
|
-
|
|
23271
|
-
|
|
23272
|
-
export { errors as Errors, VTO_TIMEOUT_MS, initShop, requests, responses, index as types };
|
|
23349
|
+
export { errors as Errors, initShop, requests, responses, index as types };
|
|
23273
23350
|
//# sourceMappingURL=index.js.map
|