@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.
Files changed (55) hide show
  1. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/fetcher.d.ts +12 -0
  2. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/fetcher.js +49 -0
  3. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/fetcher.js.map +1 -0
  4. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/requests.d.ts +155 -0
  5. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/requests.js +3 -0
  6. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/requests.js.map +1 -0
  7. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/responses.d.ts +130 -0
  8. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/responses.js +2 -0
  9. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/responses.js.map +1 -0
  10. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/shop.d.ts +33 -0
  11. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/shop.js +261 -0
  12. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/shop.js.map +1 -0
  13. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/utils.d.ts +1 -0
  14. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/utils.js +9 -0
  15. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/api/utils.js.map +1 -0
  16. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/firebase/firebase-error.d.ts +2 -0
  17. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/firebase/firebase-error.js +10 -0
  18. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/firebase/firebase-error.js.map +1 -0
  19. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/firebase/firebase-user.d.ts +26 -0
  20. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/firebase/firebase-user.js +122 -0
  21. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/firebase/firebase-user.js.map +1 -0
  22. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/firebase/firebase.d.ts +15 -0
  23. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/firebase/firebase.js +40 -0
  24. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/firebase/firebase.js.map +1 -0
  25. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/async.d.ts +2 -0
  26. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/async.js +3 -0
  27. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/async.js.map +1 -0
  28. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/config.d.ts +22 -0
  29. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/config.js +70 -0
  30. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/config.js.map +1 -0
  31. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/date.d.ts +6 -0
  32. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/date.js +5 -0
  33. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/date.js.map +1 -0
  34. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/errors.d.ts +32 -0
  35. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/errors.js +47 -0
  36. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/helpers/errors.js.map +1 -0
  37. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/index.d.ts +8 -0
  38. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/index.js +6 -0
  39. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/index.js.map +1 -0
  40. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/types/index.d.ts +89 -0
  41. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/types/index.js +8 -0
  42. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/types/index.js.map +1 -0
  43. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/types/measurement.d.ts +292 -0
  44. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/types/measurement.js +377 -0
  45. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/esm/types/measurement.js.map +1 -0
  46. package/.rollup.cache/home/codeliger/code/thefittingroom/shop-sdk/dist/tsconfig.tsbuildinfo +1 -0
  47. package/LICENSE +373 -0
  48. package/README.md +67 -73
  49. package/dist/esm/firebase/firebase.d.ts +2 -2
  50. package/dist/esm/index.js +23044 -23183
  51. package/dist/esm/index.js.map +1 -1
  52. package/dist/esm/index.min.js +366 -265
  53. package/dist/esm/index.min.js.map +1 -1
  54. package/dist/tsconfig.tsbuildinfo +1 -0
  55. package/package.json +17 -24
package/README.md CHANGED
@@ -1,110 +1,104 @@
1
- # The Fitting Room - Shop SDK
1
+ # The Fitting Room Shop SDK
2
2
 
3
- ### Installation
3
+ Modern ESM SDK for integrating **The Fitting Room** into Shopify storefronts.
4
4
 
5
- ```bash
6
- npm i @thefittingroom/shop-sdk
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
- or
9
+ ---
10
+
11
+ ## ✨ Quick Start
10
12
 
11
13
  ```bash
12
- yarn @thefittingroom/shop-sdk
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
- ### Build
21
+ ```ts
22
+ import { initShop } from "@thefittingroom/sdk"
16
23
 
17
- ```bash
18
- npm run build
24
+ const brandId = 9001
25
+ // env = "prod" | "dev"
26
+ const shop = initShop(brandId, "prod")
19
27
  ```
20
28
 
21
- or
29
+ ### Via CDN
22
30
 
23
- ```bash
24
- yarn build
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
- ### Development
35
+ <!-- Specific version (recommended) -->
36
+ <script type="module" src="https://unpkg.com/@thefittingroom/sdk@1.2.3/dist/index.mjs"></script>
28
37
 
29
- ```bash
30
- npm run watch
38
+ <!-- Development build -->
39
+ <script type="module" src="https://unpkg.com/@thefittingroom/sdk@next/dist/index.mjs"></script>
31
40
  ```
32
41
 
33
- or
42
+ ---
34
43
 
35
- ```bash
36
- yarn watch
37
- ```
44
+ ## 🔖 Semantic Versioning & Release Channels
38
45
 
39
- ## Usage
46
+ This package follows [SemVer 2.0.0](https://semver.org/): **MAJOR.MINOR.PATCH**
40
47
 
41
- ```typescript
42
- import { initShop } from '@thefittingroom/sdk'
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
- // Your brandId: Number
45
- const brandId = 9001
52
+ ### Automated release pipeline (GitHub Actions)
46
53
 
47
- // The environment: 'development', 'dev', 'production', 'prod'
48
- const env = 'dev'
49
- const shop = initShop(brandId, env)
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
- ### Shop API
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
- #### Auth
68
+ ## 🛠️ Scripts
55
69
 
56
- ```typescript
57
- // Hook used to check authentication, return isLoggedIn Promise<boolean>
58
- await shop.onInit()
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
- // Login user with session
61
- shop.user.login(email, password)
75
+ ---
62
76
 
63
- // Logout current user
64
- shop.user.logout()
77
+ ## 📚 API Overview
65
78
 
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)
79
+ ### Authentication
70
80
 
71
- // In order for the user to create an avatar, they'll need to download the mobile application.
72
- // This will send an SMS to the given phone number with a link to the iOS app
73
- // No spaces and must include country code e.g. +18005551234
74
- shop.submitTelephoneNumber(tel)
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
- #### Shop
78
-
79
- We'll make references to `sku` several times here. This is the unique identifier that matches a styles particular size
80
- from your inventory to our system.
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
- [Types Reference](https://github.com/TheFittingRoom/shop-sdk/blob/main/src/types/index.ts)
97
+ Full type definitions live in [`src/types`](./src/types/index.ts).
104
98
 
105
- #### Errors
99
+ ### Error classes
106
100
 
107
- ```typescript
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
  }