@thefittingroom/sdk 1.1.0 → 1.1.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/README.md +17 -28
- package/dist/esm/api/shop.d.ts +2 -1
- package/dist/esm/helpers/errors.d.ts +0 -22
- package/dist/esm/index.js +13 -40
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +30 -30
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/types/index.d.ts +1 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -72,10 +72,6 @@ shop.user.setBrandUserId(brandUserId)
|
|
|
72
72
|
// This will send an SMS to the given phone number with a link to the iOS app
|
|
73
73
|
// No spaces and must include country code e.g. +18005551234
|
|
74
74
|
shop.submitTelephoneNumber(tel)
|
|
75
|
-
|
|
76
|
-
// await for the avatar creation
|
|
77
|
-
// Returns boolean on whether the avatar is created or not after the configured `avatarTimeout` period
|
|
78
|
-
shop.awaitAvatarCreated()
|
|
79
75
|
```
|
|
80
76
|
|
|
81
77
|
#### Shop
|
|
@@ -84,39 +80,32 @@ We'll make references to `sku` several times here. This is the unique identifier
|
|
|
84
80
|
from your inventory to our system.
|
|
85
81
|
|
|
86
82
|
```typescript
|
|
83
|
+
// get the garment measurement locations for a particular style
|
|
84
|
+
// This is used to pre-populate the size recommendation table with data before the user is logged into The Fitting Room
|
|
85
|
+
// sku: string
|
|
86
|
+
// returns: string[]
|
|
87
|
+
const locations = await shop.getMeasurementLocationsFromSku(sku)
|
|
88
|
+
|
|
87
89
|
// A good first step would be to ensure your style and size exists in the fitting room system before executing any of the
|
|
88
|
-
// following functions. You'll get back some data about the style
|
|
90
|
+
// following functions. You'll get back some data about the style, such as the ID of the style, which you can use
|
|
89
91
|
// for the getRecommendedSizes function below.
|
|
90
|
-
//
|
|
91
|
-
//
|
|
92
|
-
shop.
|
|
92
|
+
// sku: string
|
|
93
|
+
// returns: FirestoreColorwaySizeAsset
|
|
94
|
+
const colorwaySizeAsset = await shop.getColorwaySizeAssetFromSku(sku)
|
|
93
95
|
|
|
94
96
|
// get recommended sizes for a particular style
|
|
95
|
-
// The
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
// returns: { recommendedSizeLabel, availableSizeLabels }
|
|
100
|
-
// recommendedSizeLabel: string
|
|
101
|
-
// availableSizeLabels: string[]
|
|
102
|
-
const { recommendedSizeLabel, availableSizeLabels } = shop.getRecommendedSizesLabels(styleID)
|
|
103
|
-
|
|
104
|
-
// Once the user has downloaded the mobile application and has created an avatar, they may now virtually try on a size.
|
|
105
|
-
// The size they try on must be one of the recommended sizes from the previous function call. or an error will get returned.
|
|
106
|
-
// returns frames: types.TryOnFrames
|
|
107
|
-
// These `frames` are images that can be used to cycle through the VTO 360 degrees.
|
|
108
|
-
// NOTE: this process can take a minute or two
|
|
109
|
-
const frames = await this.shop.tryOn(sku)
|
|
97
|
+
// The styleId can be extracted from the previous getColorwaySizeAssetFromSku function call.
|
|
98
|
+
// styleId: string
|
|
99
|
+
// returns: SizeRecommendation
|
|
100
|
+
const sizeRecommendation = shop.getRecommendedSizes(styleId)
|
|
110
101
|
```
|
|
111
102
|
|
|
103
|
+
[Types Reference](https://github.com/TheFittingRoom/shop-sdk/blob/main/src/types/index.ts)
|
|
104
|
+
|
|
112
105
|
#### Errors
|
|
113
106
|
|
|
114
107
|
```typescript
|
|
115
|
-
|
|
116
|
-
RequestTimeoutError
|
|
108
|
+
AvatarNotCreatedError
|
|
117
109
|
UserNotLoggedInError
|
|
118
110
|
NoColorwaySizeAssetsFoundError
|
|
119
|
-
NoStylesFoundError
|
|
120
|
-
RecommendedAvailableSizesError
|
|
121
|
-
BrandUserIdNotSetError
|
|
122
111
|
```
|
package/dist/esm/api/shop.d.ts
CHANGED
|
@@ -11,8 +11,9 @@ export declare class TfrShop {
|
|
|
11
11
|
getRecommendedSizes(styleId: string): Promise<SizeRecommendation>;
|
|
12
12
|
submitTelephoneNumber(tel: string): Promise<void>;
|
|
13
13
|
getColorwaySizeAssetFromSku(colorwaySizeAssetSku: string): Promise<types.FirestoreColorwaySizeAsset>;
|
|
14
|
-
getMeasurementLocationsFromSku(sku: string): Promise<
|
|
14
|
+
getMeasurementLocationsFromSku(sku: string): Promise<string[]>;
|
|
15
15
|
private getColorwaySizeAssets;
|
|
16
16
|
private getStyleCategory;
|
|
17
|
+
private getGetTaxonomy;
|
|
17
18
|
}
|
|
18
19
|
export declare const initShop: (brandId: number, env?: string) => TfrShop;
|
|
@@ -1,35 +1,13 @@
|
|
|
1
1
|
export interface ErrorResponse {
|
|
2
2
|
error: string;
|
|
3
3
|
}
|
|
4
|
-
export interface ErrorOutsideRecommendedSizes {
|
|
5
|
-
error: string;
|
|
6
|
-
recommended_size_id: number;
|
|
7
|
-
available_size_ids: number[];
|
|
8
|
-
}
|
|
9
4
|
export declare class AvatarNotCreatedError extends Error {
|
|
10
5
|
constructor();
|
|
11
6
|
}
|
|
12
|
-
export declare class NoFramesFoundError extends Error {
|
|
13
|
-
constructor();
|
|
14
|
-
}
|
|
15
|
-
export declare class RequestTimeoutError extends Error {
|
|
16
|
-
constructor();
|
|
17
|
-
}
|
|
18
7
|
export declare class UserNotLoggedInError extends Error {
|
|
19
8
|
constructor();
|
|
20
9
|
}
|
|
21
10
|
export declare class NoColorwaySizeAssetsFoundError extends Error {
|
|
22
11
|
constructor();
|
|
23
12
|
}
|
|
24
|
-
export declare class NoStylesFoundError extends Error {
|
|
25
|
-
constructor();
|
|
26
|
-
}
|
|
27
|
-
export declare class RecommendedAvailableSizesError extends Error {
|
|
28
|
-
recommended_size: string;
|
|
29
|
-
available_sizes: string[];
|
|
30
|
-
constructor(recommended_size: string, available_sizes: string[]);
|
|
31
|
-
}
|
|
32
|
-
export declare class BrandUserIdNotSetError extends Error {
|
|
33
|
-
constructor();
|
|
34
|
-
}
|
|
35
13
|
export declare const AvatarNotCreated = "avatar not created";
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* thefittingroom v1.1.
|
|
2
|
+
* thefittingroom v1.1.1 (2024-04-05T19:08:13.350Z)
|
|
3
3
|
* Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
// Code generated by tygo. DO NOT EDIT.
|
|
@@ -22740,18 +22740,6 @@ class AvatarNotCreatedError extends Error {
|
|
|
22740
22740
|
this.name = 'AvatarNotCreatedError';
|
|
22741
22741
|
}
|
|
22742
22742
|
}
|
|
22743
|
-
class NoFramesFoundError extends Error {
|
|
22744
|
-
constructor() {
|
|
22745
|
-
super('no frames found');
|
|
22746
|
-
this.name = 'NoFramesFoundError';
|
|
22747
|
-
}
|
|
22748
|
-
}
|
|
22749
|
-
class RequestTimeoutError extends Error {
|
|
22750
|
-
constructor() {
|
|
22751
|
-
super('request timeout');
|
|
22752
|
-
this.name = 'RequestTimeoutError';
|
|
22753
|
-
}
|
|
22754
|
-
}
|
|
22755
22743
|
class UserNotLoggedInError extends Error {
|
|
22756
22744
|
constructor() {
|
|
22757
22745
|
super('user not logged in');
|
|
@@ -22764,39 +22752,14 @@ class NoColorwaySizeAssetsFoundError extends Error {
|
|
|
22764
22752
|
this.name = 'NoColorwaySizeAssetsFoundError';
|
|
22765
22753
|
}
|
|
22766
22754
|
}
|
|
22767
|
-
class NoStylesFoundError extends Error {
|
|
22768
|
-
constructor() {
|
|
22769
|
-
super('no styles found');
|
|
22770
|
-
this.name = 'NoStylesFoundError';
|
|
22771
|
-
}
|
|
22772
|
-
}
|
|
22773
|
-
class RecommendedAvailableSizesError extends Error {
|
|
22774
|
-
constructor(recommended_size, available_sizes) {
|
|
22775
|
-
super('recommended available sizes error');
|
|
22776
|
-
this.name = 'RecommendedAvailableSizesError';
|
|
22777
|
-
this.recommended_size = recommended_size;
|
|
22778
|
-
this.available_sizes = available_sizes;
|
|
22779
|
-
}
|
|
22780
|
-
}
|
|
22781
|
-
class BrandUserIdNotSetError extends Error {
|
|
22782
|
-
constructor() {
|
|
22783
|
-
super('brand user id not set');
|
|
22784
|
-
this.name = 'BrandUserIdNotSetError';
|
|
22785
|
-
}
|
|
22786
|
-
}
|
|
22787
22755
|
// Backend responses
|
|
22788
22756
|
const AvatarNotCreated = 'avatar not created';
|
|
22789
22757
|
|
|
22790
22758
|
var errors = /*#__PURE__*/Object.freeze({
|
|
22791
22759
|
__proto__: null,
|
|
22792
22760
|
AvatarNotCreatedError: AvatarNotCreatedError,
|
|
22793
|
-
NoFramesFoundError: NoFramesFoundError,
|
|
22794
|
-
RequestTimeoutError: RequestTimeoutError,
|
|
22795
22761
|
UserNotLoggedInError: UserNotLoggedInError,
|
|
22796
22762
|
NoColorwaySizeAssetsFoundError: NoColorwaySizeAssetsFoundError,
|
|
22797
|
-
NoStylesFoundError: NoStylesFoundError,
|
|
22798
|
-
RecommendedAvailableSizesError: RecommendedAvailableSizesError,
|
|
22799
|
-
BrandUserIdNotSetError: BrandUserIdNotSetError,
|
|
22800
22763
|
AvatarNotCreated: AvatarNotCreated
|
|
22801
22764
|
});
|
|
22802
22765
|
|
|
@@ -23368,7 +23331,8 @@ class TfrShop {
|
|
|
23368
23331
|
var _a;
|
|
23369
23332
|
const asset = await this.getColorwaySizeAssetFromSku(sku);
|
|
23370
23333
|
const styleCategory = await this.getStyleCategory(asset.style_id);
|
|
23371
|
-
const
|
|
23334
|
+
const taxonomy = await this.getGetTaxonomy(styleCategory.style_garment_category_id);
|
|
23335
|
+
const classificationLocation = ((_a = Taxonomy[taxonomy.style_category]) === null || _a === void 0 ? void 0 : _a[taxonomy.garment_category]) || null;
|
|
23372
23336
|
return classificationLocation
|
|
23373
23337
|
? ClassificationLocations[classificationLocation].map((location) => MeasurementLocationName[location])
|
|
23374
23338
|
: null;
|
|
@@ -23394,7 +23358,16 @@ class TfrShop {
|
|
|
23394
23358
|
}
|
|
23395
23359
|
async getStyleCategory(styleId) {
|
|
23396
23360
|
try {
|
|
23397
|
-
const doc = await this.firebase.getDoc('
|
|
23361
|
+
const doc = await this.firebase.getDoc('styles', String(styleId));
|
|
23362
|
+
return doc;
|
|
23363
|
+
}
|
|
23364
|
+
catch (error) {
|
|
23365
|
+
return getFirebaseError(error);
|
|
23366
|
+
}
|
|
23367
|
+
}
|
|
23368
|
+
async getGetTaxonomy(styleId) {
|
|
23369
|
+
try {
|
|
23370
|
+
const doc = await this.firebase.getDoc('style_garment_categories', String(styleId));
|
|
23398
23371
|
return doc;
|
|
23399
23372
|
}
|
|
23400
23373
|
catch (error) {
|