@thefittingroom/sdk 2.0.0 → 2.0.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/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/fetcher.d.ts +12 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/fetcher.js +49 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/fetcher.js.map +1 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/requests.d.ts +155 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/requests.js +3 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/requests.js.map +1 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/responses.d.ts +130 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/responses.js +2 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/responses.js.map +1 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/shop.d.ts +33 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/shop.js +261 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/shop.js.map +1 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/utils.d.ts +1 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/utils.js +9 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/utils.js.map +1 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/firebase/firebase-error.d.ts +2 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/firebase/firebase-error.js +10 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/firebase/firebase-error.js.map +1 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/firebase/firebase-user.d.ts +26 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/firebase/firebase-user.js +122 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/firebase/firebase-user.js.map +1 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/firebase/firebase.d.ts +15 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/firebase/firebase.js +40 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/firebase/firebase.js.map +1 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/async.d.ts +2 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/async.js +3 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/async.js.map +1 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/config.d.ts +22 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/config.js +70 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/config.js.map +1 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/date.d.ts +6 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/date.js +5 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/date.js.map +1 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/errors.d.ts +32 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/errors.js +47 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/errors.js.map +1 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/index.d.ts +8 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/index.js +6 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/index.js.map +1 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/types/index.d.ts +89 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/types/index.js +8 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/types/index.js.map +1 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/types/measurement.d.ts +292 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/types/measurement.js +377 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/types/measurement.js.map +1 -0
- package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/tsconfig.tsbuildinfo +1 -0
- package/LICENSE +373 -0
- package/README.md +67 -73
- package/dist/esm/firebase/firebase.d.ts +2 -2
- package/dist/esm/index.js +23044 -23183
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +366 -265
- package/dist/esm/index.min.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +17 -24
package/README.md
CHANGED
|
@@ -1,110 +1,104 @@
|
|
|
1
|
-
# The Fitting Room
|
|
1
|
+
# The Fitting Room – Shop SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Modern ESM SDK for integrating **The Fitting Room** into Shopify storefronts.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
* **Production-ready** bundle published to npm and the `unpkg` CDN.
|
|
6
|
+
* **Type-safe** API (written in TypeScript).
|
|
7
|
+
* Supports both **development** and **production** environments.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## ✨ Quick Start
|
|
10
12
|
|
|
11
13
|
```bash
|
|
12
|
-
|
|
14
|
+
# Stable / production build
|
|
15
|
+
npm install @thefittingroom/sdk
|
|
16
|
+
|
|
17
|
+
# Next / development build
|
|
18
|
+
npm install @thefittingroom/sdk@next
|
|
13
19
|
```
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
```ts
|
|
22
|
+
import { initShop } from "@thefittingroom/sdk"
|
|
16
23
|
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
const brandId = 9001
|
|
25
|
+
// env = "prod" | "dev"
|
|
26
|
+
const shop = initShop(brandId, "prod")
|
|
19
27
|
```
|
|
20
28
|
|
|
21
|
-
|
|
29
|
+
### Via CDN
|
|
22
30
|
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
|
|
31
|
+
```html
|
|
32
|
+
<!-- Latest production build -->
|
|
33
|
+
<script type="module" src="https://unpkg.com/@thefittingroom/sdk@latest/dist/index.mjs"></script>
|
|
26
34
|
|
|
27
|
-
|
|
35
|
+
<!-- Specific version (recommended) -->
|
|
36
|
+
<script type="module" src="https://unpkg.com/@thefittingroom/sdk@1.2.3/dist/index.mjs"></script>
|
|
28
37
|
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
<!-- Development build -->
|
|
39
|
+
<script type="module" src="https://unpkg.com/@thefittingroom/sdk@next/dist/index.mjs"></script>
|
|
31
40
|
```
|
|
32
41
|
|
|
33
|
-
|
|
42
|
+
---
|
|
34
43
|
|
|
35
|
-
|
|
36
|
-
yarn watch
|
|
37
|
-
```
|
|
44
|
+
## 🔖 Semantic Versioning & Release Channels
|
|
38
45
|
|
|
39
|
-
|
|
46
|
+
This package follows [SemVer 2.0.0](https://semver.org/): **MAJOR.MINOR.PATCH**
|
|
40
47
|
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
* **MAJOR** – Breaking changes. Partners must opt-in to upgrade.
|
|
49
|
+
* **MINOR** – Back-compatible feature additions.
|
|
50
|
+
* **PATCH** – Back-compatible bug fixes.
|
|
43
51
|
|
|
44
|
-
|
|
45
|
-
const brandId = 9001
|
|
52
|
+
### Automated release pipeline (GitHub Actions)
|
|
46
53
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
| Trigger | Workflow | Result |
|
|
55
|
+
|---------|----------|--------|
|
|
56
|
+
| Pull request → `main` | `PR Label Guard` | PR must carry `patch`, `minor`, or `major` label – otherwise CI fails and merge is blocked. |
|
|
57
|
+
| Merge → `main` | `Deploy to dev` | CI bumps version (according to PR label), publishes build to npm with `next` tag, and uploads assets to dev S3 bucket. |
|
|
58
|
+
| GitHub Release | `Production Release` | Tag (e.g. `v2.3.0`) is published to npm with `latest` tag and assets uploaded to prod S3 bucket. |
|
|
59
|
+
|
|
60
|
+
Guidelines for consumers:
|
|
51
61
|
|
|
52
|
-
|
|
62
|
+
```text
|
|
63
|
+
^1.x → always safe (only minor/patches)
|
|
64
|
+
~1.2.0 → locks to patch updates only
|
|
65
|
+
1.2.3 → locks to a specific publish
|
|
66
|
+
```
|
|
53
67
|
|
|
54
|
-
|
|
68
|
+
## 🛠️ Scripts
|
|
55
69
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
70
|
+
| Command | Description |
|
|
71
|
+
|---------|-------------|
|
|
72
|
+
| `npm run build` | Create production bundle in `dist/` |
|
|
73
|
+
| `npm run watch` | Re-build on change (development) |
|
|
59
74
|
|
|
60
|
-
|
|
61
|
-
shop.user.login(email, password)
|
|
75
|
+
---
|
|
62
76
|
|
|
63
|
-
|
|
64
|
-
shop.user.logout()
|
|
77
|
+
## 📚 API Overview
|
|
65
78
|
|
|
66
|
-
|
|
67
|
-
// This is a required field for requesting a VTO
|
|
68
|
-
// string | number
|
|
69
|
-
shop.user.setBrandUserId(brandUserId)
|
|
79
|
+
### Authentication
|
|
70
80
|
|
|
71
|
-
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
shop.
|
|
81
|
+
```ts
|
|
82
|
+
await shop.onInit() // isLoggedIn: boolean
|
|
83
|
+
shop.user.login(email, password) // start session
|
|
84
|
+
shop.user.logout() // end session
|
|
85
|
+
shop.user.setBrandUserId(id) // required for VTO
|
|
86
|
+
shop.submitTelephoneNumber('+18005551234')
|
|
75
87
|
```
|
|
76
88
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
89
|
-
// A good first step would be to ensure your style and size exists in the fitting room system before executing any of the
|
|
90
|
-
// following functions. You'll get back some data about the style, such as the ID of the style, which you can use
|
|
91
|
-
// for the getRecommendedSizes function below.
|
|
92
|
-
// sku: string
|
|
93
|
-
// returns: FirestoreColorwaySizeAsset
|
|
94
|
-
const colorwaySizeAsset = await shop.getColorwaySizeAssetFromSku(sku)
|
|
95
|
-
|
|
96
|
-
// get recommended sizes for a particular style
|
|
97
|
-
// The styleId can be extracted from the previous getColorwaySizeAssetFromSku function call.
|
|
98
|
-
// styleId: string
|
|
99
|
-
// returns: SizeRecommendation
|
|
89
|
+
### Shop helpers
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
const locations = await shop.getMeasurementLocationsFromSku(sku)
|
|
93
|
+
const colorwaySizeAsset = await shop.getColorwaySizeAssetFromSku(sku)
|
|
100
94
|
const sizeRecommendation = shop.getRecommendedSizes(styleId)
|
|
101
95
|
```
|
|
102
96
|
|
|
103
|
-
[
|
|
97
|
+
Full type definitions live in [`src/types`](./src/types/index.ts).
|
|
104
98
|
|
|
105
|
-
|
|
99
|
+
### Error classes
|
|
106
100
|
|
|
107
|
-
```
|
|
101
|
+
```ts
|
|
108
102
|
AvatarNotCreatedError
|
|
109
103
|
UserNotLoggedInError
|
|
110
104
|
NoColorwaySizeAssetsFoundError
|
|
@@ -6,10 +6,10 @@ export declare class Firebase {
|
|
|
6
6
|
constructor();
|
|
7
7
|
onInit(brandId: number): Promise<boolean>;
|
|
8
8
|
query(collectionName: string, constraint: QueryFieldFilterConstraint, unsubscribeWhenData?: boolean): {
|
|
9
|
-
promise: Promise<QuerySnapshot<DocumentData>>;
|
|
9
|
+
promise: Promise<QuerySnapshot<DocumentData, DocumentData>>;
|
|
10
10
|
unsubscribe: () => void;
|
|
11
11
|
};
|
|
12
|
-
getDocs(collectionName: string, constraints: QueryFieldFilterConstraint[]): Promise<QuerySnapshot<DocumentData>>;
|
|
12
|
+
getDocs(collectionName: string, constraints: QueryFieldFilterConstraint[]): Promise<QuerySnapshot<DocumentData, DocumentData>>;
|
|
13
13
|
getDoc(collectionName: string, id: string): Promise<DocumentData>;
|
|
14
14
|
private promisefyOnSnapshot;
|
|
15
15
|
}
|