@thefittingroom/sdk 0.0.10 → 0.0.13
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 +6 -0
- package/dist/esm/api/shop.d.ts +2 -1
- package/dist/esm/firebase/firebase-user.d.ts +3 -0
- package/dist/esm/helpers/errors.d.ts +3 -0
- package/dist/esm/index.js +29 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +43 -43
- package/dist/esm/index.min.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,6 +63,11 @@ shop.user.login(email, password)
|
|
|
63
63
|
// Logout current user
|
|
64
64
|
shop.user.logout()
|
|
65
65
|
|
|
66
|
+
// Set the brand userId, the internal userId used by the shop/brand
|
|
67
|
+
// This is a required field for requesting a VTO
|
|
68
|
+
// string | number
|
|
69
|
+
shop.user.setBrandUserId(brandUserId)
|
|
70
|
+
|
|
66
71
|
// In order for the user to create an avatar, they'll need to download the mobile application.
|
|
67
72
|
// This will send an SMS to the given phone number with a link to the iOS app
|
|
68
73
|
// No spaces and must include country code e.g. +18005551234
|
|
@@ -113,4 +118,5 @@ UserNotLoggedInError
|
|
|
113
118
|
NoColorwaySizeAssetsFoundError
|
|
114
119
|
NoStylesFoundError
|
|
115
120
|
RecommendedAvailableSizesError
|
|
121
|
+
BrandUserIdNotSetError
|
|
116
122
|
```
|
package/dist/esm/api/shop.d.ts
CHANGED
|
@@ -19,9 +19,10 @@ export declare class TfrShop {
|
|
|
19
19
|
}>;
|
|
20
20
|
getStyles(ids: number[], skus: string[]): Promise<Map<number, types.FirestoreStyle>>;
|
|
21
21
|
submitTelephoneNumber(tel: string): Promise<void>;
|
|
22
|
+
getColorwaySizeAssetFromSku(colorwaySizeAssetSku: string): Promise<types.FirestoreColorwaySizeAsset>;
|
|
23
|
+
_getColorwaySizeAssetFromSku(colorwaySizeAssetSku: string): Promise<types.FirestoreColorwaySizeAsset[]>;
|
|
22
24
|
private awaitColorwaySizeAssetFrames;
|
|
23
25
|
private requestThenGetColorwaySizeAssetFrames;
|
|
24
|
-
private getColorwaySizeAssetFromSku;
|
|
25
26
|
private getColorwaySizeAssets;
|
|
26
27
|
private requestColorwaySizeAssetFrames;
|
|
27
28
|
private getColorwaySizeAssetFrames;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import * as firebase from 'firebase/app';
|
|
2
2
|
import * as firebaseAuth from 'firebase/auth';
|
|
3
3
|
import { DocumentData, Firestore, QuerySnapshot } from 'firebase/firestore';
|
|
4
|
+
export type BrandUserId = string | number;
|
|
4
5
|
export declare class FirebaseUser {
|
|
5
6
|
private readonly firestore;
|
|
7
|
+
brandUserId: BrandUserId;
|
|
6
8
|
private user;
|
|
7
9
|
private readonly auth;
|
|
8
10
|
constructor(firestore: Firestore, app: firebase.FirebaseApp);
|
|
9
11
|
get id(): string;
|
|
10
12
|
onInit(): Promise<boolean>;
|
|
11
13
|
setUser(user: firebaseAuth.User): void;
|
|
14
|
+
setBrandUserId(brandUserId: BrandUserId): void;
|
|
12
15
|
getToken(): Promise<string>;
|
|
13
16
|
getUserProfile(): Promise<DocumentData>;
|
|
14
17
|
watchUserProfileForChanges(predicate: (data: QuerySnapshot<DocumentData>) => Promise<boolean>, timeout: number): Promise<DocumentData>;
|
|
@@ -29,4 +29,7 @@ export declare class RecommendedAvailableSizesError extends Error {
|
|
|
29
29
|
available_sizes: string[];
|
|
30
30
|
constructor(recommended_size: string, available_sizes: string[]);
|
|
31
31
|
}
|
|
32
|
+
export declare class BrandUserIdNotSetError extends Error {
|
|
33
|
+
constructor();
|
|
34
|
+
}
|
|
32
35
|
export declare const AvatarNotCreated = "avatar not created";
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* thefittingroom v0.0.
|
|
2
|
+
* thefittingroom v0.0.11 (2023-11-21T18:22:57.333Z)
|
|
3
3
|
* Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
@@ -22768,6 +22768,12 @@ class RecommendedAvailableSizesError extends Error {
|
|
|
22768
22768
|
this.available_sizes = available_sizes;
|
|
22769
22769
|
}
|
|
22770
22770
|
}
|
|
22771
|
+
class BrandUserIdNotSetError extends Error {
|
|
22772
|
+
constructor() {
|
|
22773
|
+
super('brand user id not set');
|
|
22774
|
+
this.name = 'BrandUserIdNotSetError';
|
|
22775
|
+
}
|
|
22776
|
+
}
|
|
22771
22777
|
// Backend responses
|
|
22772
22778
|
const AvatarNotCreated = 'avatar not created';
|
|
22773
22779
|
|
|
@@ -22780,12 +22786,14 @@ var errors = /*#__PURE__*/Object.freeze({
|
|
|
22780
22786
|
NoColorwaySizeAssetsFoundError: NoColorwaySizeAssetsFoundError,
|
|
22781
22787
|
NoStylesFoundError: NoStylesFoundError,
|
|
22782
22788
|
RecommendedAvailableSizesError: RecommendedAvailableSizesError,
|
|
22789
|
+
BrandUserIdNotSetError: BrandUserIdNotSetError,
|
|
22783
22790
|
AvatarNotCreated: AvatarNotCreated
|
|
22784
22791
|
});
|
|
22785
22792
|
|
|
22786
22793
|
class FirebaseUser {
|
|
22787
22794
|
constructor(firestore, app) {
|
|
22788
22795
|
this.firestore = firestore;
|
|
22796
|
+
this.brandUserId = null;
|
|
22789
22797
|
this.auth = getAuth(app);
|
|
22790
22798
|
this.auth.setPersistence(browserLocalPersistence);
|
|
22791
22799
|
}
|
|
@@ -22805,6 +22813,9 @@ class FirebaseUser {
|
|
|
22805
22813
|
setUser(user) {
|
|
22806
22814
|
this.user = user;
|
|
22807
22815
|
}
|
|
22816
|
+
setBrandUserId(brandUserId) {
|
|
22817
|
+
this.brandUserId = brandUserId;
|
|
22818
|
+
}
|
|
22808
22819
|
async getToken() {
|
|
22809
22820
|
var _a;
|
|
22810
22821
|
if (!((_a = this.user) === null || _a === void 0 ? void 0 : _a.uid))
|
|
@@ -23037,6 +23048,18 @@ class TfrShop {
|
|
|
23037
23048
|
const res = await Fetcher.Post(this.user, '/ios-app-link', { phone_number: sanitizedTel }, false);
|
|
23038
23049
|
console.log(res);
|
|
23039
23050
|
}
|
|
23051
|
+
async getColorwaySizeAssetFromSku(colorwaySizeAssetSku) {
|
|
23052
|
+
const assets = await this.getColorwaySizeAssets(null, [colorwaySizeAssetSku]);
|
|
23053
|
+
if (!(assets === null || assets === void 0 ? void 0 : assets.size))
|
|
23054
|
+
throw new NoColorwaySizeAssetsFoundError();
|
|
23055
|
+
return Array.from(assets.values())[0];
|
|
23056
|
+
}
|
|
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
|
+
}
|
|
23040
23063
|
async awaitColorwaySizeAssetFrames(colorwaySizeAssetSKU) {
|
|
23041
23064
|
var _a, _b, _c, _d;
|
|
23042
23065
|
if (!this.isLoggedIn)
|
|
@@ -23080,12 +23103,6 @@ class TfrShop {
|
|
|
23080
23103
|
throw new RecommendedAvailableSizesError(recommendedSize, availableSizes);
|
|
23081
23104
|
}
|
|
23082
23105
|
}
|
|
23083
|
-
async getColorwaySizeAssetFromSku(colorwaySizeAssetSku) {
|
|
23084
|
-
const assets = await this.getColorwaySizeAssets(null, [colorwaySizeAssetSku]);
|
|
23085
|
-
if (!(assets === null || assets === void 0 ? void 0 : assets.size))
|
|
23086
|
-
throw new NoColorwaySizeAssetsFoundError();
|
|
23087
|
-
return Array.from(assets.values())[0];
|
|
23088
|
-
}
|
|
23089
23106
|
async getColorwaySizeAssets(styleId, skus) {
|
|
23090
23107
|
const constraints = [rl('brand_id', '==', this.brandId)];
|
|
23091
23108
|
if (styleId)
|
|
@@ -23108,7 +23125,11 @@ class TfrShop {
|
|
|
23108
23125
|
async requestColorwaySizeAssetFrames(colorwaySizeAssetId) {
|
|
23109
23126
|
if (!this.isLoggedIn)
|
|
23110
23127
|
throw new UserNotLoggedInError();
|
|
23111
|
-
|
|
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
|
+
});
|
|
23112
23133
|
}
|
|
23113
23134
|
async getColorwaySizeAssetFrames(colorwaySizeAssetSKU) {
|
|
23114
23135
|
var _a, _b, _c;
|