@stackone/hub 0.1.0

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 (48) hide show
  1. package/.github/workflows/node-ci.yml +20 -0
  2. package/.github/workflows/release-please.yml +37 -0
  3. package/.github/workflows/semantic-pull-request.yml +31 -0
  4. package/.nvmrc +1 -0
  5. package/.release-please-manifest.json +1 -0
  6. package/.yalc/@stackone/malachite/README.md +1 -0
  7. package/.yalc/@stackone/malachite/package.json +37 -0
  8. package/.yalc/@stackone/malachite/yalc.sig +1 -0
  9. package/CHANGELOG.md +30 -0
  10. package/README.md +225 -0
  11. package/biome.json +77 -0
  12. package/dev/index.html +11 -0
  13. package/dev/main.css +80 -0
  14. package/dev/main.tsx +96 -0
  15. package/dev/vite-env.d.ts +15 -0
  16. package/index.html +14 -0
  17. package/package.json +44 -0
  18. package/release-please-config.json +5 -0
  19. package/rollup.config.mjs +72 -0
  20. package/src/StackOneHub.tsx +99 -0
  21. package/src/WebComponentWrapper.tsx +14 -0
  22. package/src/index.ts +1 -0
  23. package/src/modules/csv-importer.tsx/CsvImporter.tsx +35 -0
  24. package/src/modules/integration-picker/IntegrationPicker.tsx +89 -0
  25. package/src/modules/integration-picker/components/IntegrationFields.tsx +115 -0
  26. package/src/modules/integration-picker/components/IntegrationList.tsx +71 -0
  27. package/src/modules/integration-picker/components/IntegrationPickerContent.tsx +107 -0
  28. package/src/modules/integration-picker/components/cardFooter.tsx +88 -0
  29. package/src/modules/integration-picker/components/cardTitle.tsx +51 -0
  30. package/src/modules/integration-picker/components/views/ErrorView.tsx +9 -0
  31. package/src/modules/integration-picker/components/views/IntegrationFormView.tsx +22 -0
  32. package/src/modules/integration-picker/components/views/IntegrationListView.tsx +19 -0
  33. package/src/modules/integration-picker/components/views/LoadingView.tsx +11 -0
  34. package/src/modules/integration-picker/components/views/SuccessView.tsx +10 -0
  35. package/src/modules/integration-picker/components/views/index.ts +5 -0
  36. package/src/modules/integration-picker/hooks/useIntegrationPicker.ts +221 -0
  37. package/src/modules/integration-picker/queries.ts +78 -0
  38. package/src/modules/integration-picker/types.ts +60 -0
  39. package/src/shared/categories.ts +55 -0
  40. package/src/shared/components/error.tsx +33 -0
  41. package/src/shared/components/errorBoundary.tsx +31 -0
  42. package/src/shared/components/loading.tsx +30 -0
  43. package/src/shared/components/success.tsx +33 -0
  44. package/src/shared/httpClient.ts +79 -0
  45. package/src/types/types.ts +1 -0
  46. package/tsconfig.json +19 -0
  47. package/vite.config.ts +11 -0
  48. package/yalc.lock +9 -0
@@ -0,0 +1,20 @@
1
+ name: Node.js CI
2
+
3
+ on: [pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v4
10
+ - name: Use Node.js
11
+ uses: actions/setup-node@v4
12
+ with:
13
+ node-version: '22.14.x'
14
+ cache: 'npm'
15
+ - name: Install dependencies
16
+ run: npm ci
17
+ - name: Build
18
+ run: npm run build
19
+ - name: Lint
20
+ run: npm run lint
@@ -0,0 +1,37 @@
1
+ on:
2
+ push:
3
+ branches:
4
+ - main
5
+
6
+ name: release-please
7
+ jobs:
8
+ release-please:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: googleapis/release-please-action@v4
12
+ id: release
13
+ with:
14
+ token: ${{ secrets.REPO_GH_PAT }}
15
+ config-file: release-please-config.json
16
+ manifest-file: .release-please-manifest.json
17
+
18
+ - name: Checkout Repository
19
+ uses: actions/checkout@v4
20
+ if: steps.release.outputs.paths_released != '[]'
21
+ - name: Setup Node
22
+ uses: actions/setup-node@v4
23
+ if: steps.release.outputs.paths_released != '[]'
24
+ with:
25
+ node-version: '22.14.x'
26
+ registry-url: 'https://registry.npmjs.org'
27
+ - name: Build
28
+ if: steps.release.outputs.paths_released != '[]'
29
+ run: |
30
+ npm install
31
+ npm run build
32
+ - name: Publish
33
+ if: steps.release.outputs.paths_released != '[]'
34
+ run: |
35
+ npm run publish-release
36
+ env:
37
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,31 @@
1
+ name: "Check PR title"
2
+
3
+ on:
4
+ pull_request_target:
5
+ types:
6
+ - opened
7
+ - reopened
8
+ - edited
9
+ - synchronize
10
+
11
+ permissions:
12
+ pull-requests: read
13
+
14
+ jobs:
15
+ main:
16
+ name: Validate PR title
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: amannn/action-semantic-pull-request@v5
20
+ env:
21
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22
+ with:
23
+ scopes: |
24
+ ENG-\d+
25
+ deps
26
+ deps-dev
27
+ workflow
28
+ requireScope: false
29
+ ignoreLabels: |
30
+ autorelease: pending
31
+ dependencies
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ v22.14.0
@@ -0,0 +1 @@
1
+ {".":"0.1.0"}
@@ -0,0 +1 @@
1
+ Coming soon
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@stackone/malachite",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "module": "dist/index.js",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "README.md",
11
+ "LICENSE"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "require": "./dist/index.js",
17
+ "default": "./dist/index.js"
18
+ },
19
+ "./style.css": "./dist/style.css"
20
+ },
21
+ "scripts": {
22
+ "dev": "vite",
23
+ "build": "tsc -b ./tsconfig.app.json && vite build",
24
+ "build:watch": "vite build --watch",
25
+ "build:hot": "concurrently \"tsc -b ./tsconfig.app.json --watch\" \"vite build --watch\"",
26
+ "lint:check": "biome lint",
27
+ "lint:fix": "biome lint --fix",
28
+ "preview": "vite preview",
29
+ "storybook": "storybook dev -p 6006",
30
+ "build-storybook": "storybook build"
31
+ },
32
+ "peerDependencies": {
33
+ "react": "^18.0.0",
34
+ "react-dom": "^18.1.0"
35
+ },
36
+ "yalcSig": "b3621bd0c8195b6fd4451f514c72a618"
37
+ }
@@ -0,0 +1 @@
1
+ b3621bd0c8195b6fd4451f514c72a618
package/CHANGELOG.md ADDED
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ ## [0.1.0](https://github.com/StackOneHQ/hub/compare/hub-v0.0.1...hub-v0.1.0) (2025-07-11)
4
+
5
+
6
+ ### Features
7
+
8
+ * account editing flow ([0cf3a54](https://github.com/StackOneHQ/hub/commit/0cf3a545d5b85d5422f02e4a0b990239979066c4))
9
+ * add error boundary ([2f5e457](https://github.com/StackOneHQ/hub/commit/2f5e457743674307bf201606c136109c3bba6ff8))
10
+ * add events ([0ac44e3](https://github.com/StackOneHQ/hub/commit/0ac44e39bc1a30c3897838ee4fa82a62fe1ed5d8))
11
+ * add hub modes ([d74c6f7](https://github.com/StackOneHQ/hub/commit/d74c6f78ac597842034e52022ae958331bc15a28))
12
+ * add suppor for new props in webcomponent ([cd718d8](https://github.com/StackOneHQ/hub/commit/cd718d8392feb47180d38846f426f87e16240e69))
13
+ * back to antd ([6921d6d](https://github.com/StackOneHQ/hub/commit/6921d6dacec9f692e4145e061f7b5a51dabefe89))
14
+ * error handling and better rendering ([2aec2a3](https://github.com/StackOneHQ/hub/commit/2aec2a3e75b53ac0b814eee63eac73c2169befba))
15
+ * fetch integration list ([50d3226](https://github.com/StackOneHQ/hub/commit/50d3226435e84f8e000decaed52ce3fdb728e481))
16
+ * handle expired tokens ([2dc60c8](https://github.com/StackOneHQ/hub/commit/2dc60c857b9612f886193a5efb748ab2b2cc56ed))
17
+ * initialise repo with react and webcomponent build ([1e719ae](https://github.com/StackOneHQ/hub/commit/1e719aef846582699d01a06e01c5a3c2e4e8ed91))
18
+ * loading states ([21e1ad5](https://github.com/StackOneHQ/hub/commit/21e1ad5e0f8f91ff75e90a9a01e385ddb3cf854a))
19
+ * more design updates ([0293dfe](https://github.com/StackOneHQ/hub/commit/0293dfe92a8decfbe263c87aa274b811b7c5710b))
20
+ * react query and better components ([ce2d084](https://github.com/StackOneHQ/hub/commit/ce2d08477d02c92da1fb4f5d2fa05bdbe286371b))
21
+ * rudimentary account linking ([56a27a4](https://github.com/StackOneHQ/hub/commit/56a27a440992751a584de2c7fb3a4c7adf946190))
22
+ * use malachite components locally ([b362c65](https://github.com/StackOneHQ/hub/commit/b362c657aed377cf4b5913e3ebe3794cea8498eb))
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * hub form ([d4c9898](https://github.com/StackOneHQ/hub/commit/d4c989810ce25ea79368f22f0cfd5df8140abec2))
28
+ * lint ([110eb98](https://github.com/StackOneHQ/hub/commit/110eb98e5ab6442b6c1000a2f72c07a84b3e1512))
29
+ * release please ([e11cd2c](https://github.com/StackOneHQ/hub/commit/e11cd2c8f1f5ba1c2bcbbc661b9a3f3fd0866e10))
30
+ * release please and package dependency ([d2a57bc](https://github.com/StackOneHQ/hub/commit/d2a57bcc7db27c7b4348db253d816141ccc99d03))
package/README.md ADDED
@@ -0,0 +1,225 @@
1
+ # StackOne HUB
2
+
3
+ > ⚠️ **ALPHA SOFTWARE** ⚠️
4
+ > This project is currently in **alpha stage**. Features are incomplete, and may break without notice. Use in production environments is not recommended.
5
+
6
+ ![License](https://img.shields.io/badge/license-MIT-blue.svg)
7
+ ![Status](https://img.shields.io/badge/status-alpha-orange.svg)
8
+ ![Node Version](https://img.shields.io/badge/node-%3E%3D22.14.0-brightgreen.svg)
9
+
10
+ StackOne HUB is a React-based integration component library that provides a web component wrapper for seamless integration into any web application. It enables developers to easily embed StackOne's integrations hub.
11
+
12
+ ## 📋 Table of Contents
13
+
14
+ - [StackOne HUB](#stackone-hub)
15
+ - [📋 Table of Contents](#-table-of-contents)
16
+ - [⚠️ Alpha Notice](#️-alpha-notice)
17
+ - [🚀 Quick Start](#-quick-start)
18
+ - [📦 Installation](#-installation)
19
+ - [Prerequisites](#prerequisites)
20
+ - [Setup](#setup)
21
+ - [🛠️ Development](#️-development)
22
+ - [Environment Setup](#environment-setup)
23
+ - [🏗️ Build](#️-build)
24
+ - [Build Output](#build-output)
25
+ - [📖 Usage](#-usage)
26
+ - [🌐 Web Component Integration](#-web-component-integration)
27
+ - [⚛️ React Component Integration](#️-react-component-integration)
28
+ - [💻 Local Development Usage](#-local-development-usage)
29
+ - [Web Component (Local)](#web-component-local)
30
+ - [React Component (Local)](#react-component-local)
31
+ - [🔧 Environment Variables](#-environment-variables)
32
+ - [Example `.env` file:](#example-env-file)
33
+ - [🤝 Contributing](#-contributing)
34
+ - [Getting Started](#getting-started)
35
+ - [📄 License](#-license)
36
+
37
+ ## ⚠️ Alpha Notice
38
+
39
+ **This software is in active development and should be considered alpha quality.**
40
+
41
+ - 🚧 **Breaking changes** may occur in any release
42
+ - 🐛 **Bugs and incomplete features** are expected
43
+ - 📚 **Documentation** may be outdated or incomplete
44
+ - 🔄 **APIs are subject to change** without prior notice
45
+ - ❌ **Not recommended for production use**
46
+
47
+ Please report issues and provide feedback to help us improve!
48
+
49
+ ## 🚀 Quick Start
50
+
51
+ ```bash
52
+ # Clone and setup
53
+ git clone <repository-url>
54
+ cd hub
55
+ npm install
56
+ npm run build
57
+
58
+ # Start development
59
+ npm run dev
60
+ ```
61
+
62
+ ## 📦 Installation
63
+
64
+ ### Prerequisites
65
+
66
+ - [Node.js](https://nodejs.org/) v22.14.0 or higher
67
+ - [npm](https://www.npmjs.com/) (comes with Node.js)
68
+
69
+ ### Setup
70
+
71
+ 1. **Clone the repository:**
72
+ ```bash
73
+ git clone <repository-url>
74
+ cd hub
75
+ ```
76
+
77
+ 2. **Install dependencies:**
78
+ ```bash
79
+ npm install
80
+ ```
81
+
82
+ 3. **Build the project:**
83
+ ```bash
84
+ npm run build
85
+ ```
86
+
87
+ ## 🛠️ Development
88
+
89
+ ### Environment Setup
90
+
91
+ 1. **Create environment file:**
92
+ ```bash
93
+ cp .env.example .env
94
+ ```
95
+
96
+ 2. **Configure your environment variables** (see [Environment Variables](#-environment-variables) section)
97
+
98
+ 3. **Start the development server:**
99
+ ```bash
100
+ npm run dev
101
+ ```
102
+
103
+ The development server will start at [http://localhost:3000](http://localhost:3000) (default port).
104
+
105
+ ## 🏗️ Build
106
+
107
+ To build the project for production:
108
+
109
+ ```bash
110
+ npm run build
111
+ ```
112
+
113
+ ### Build Output
114
+
115
+ The build generates multiple bundles in the `dist/` directory:
116
+
117
+ | File | Description | Use Case |
118
+ |------|-------------|----------|
119
+ | `StackOneHub.esm.js` | ES module bundle | Modern React applications |
120
+ | `StackOneHub.cjs.js` | CommonJS module | Node.js/legacy environments |
121
+ | `StackOneHub.web.js` | Web component bundle | Vanilla HTML/JS integration |
122
+
123
+ ## 📖 Usage
124
+
125
+ ### 🌐 Web Component Integration
126
+
127
+ For vanilla HTML/JavaScript applications:
128
+
129
+ ```html
130
+ <!DOCTYPE html>
131
+ <html>
132
+ <head>
133
+ <title>StackOne HUB Integration</title>
134
+ </head>
135
+ <body>
136
+ <script src="<TBD>/StackOneHub.web.js"></script>
137
+ <my-component></my-component>
138
+ </body>
139
+ </html>
140
+ ```
141
+
142
+ ### ⚛️ React Component Integration
143
+
144
+ For React applications:
145
+
146
+ ```tsx
147
+ import StackOneHub from "@stackone/StackOneHub";
148
+
149
+ function App() {
150
+ return (
151
+ <div className="app">
152
+ <h1>My Application</h1>
153
+ <StackOneHub />
154
+ </div>
155
+ );
156
+ }
157
+
158
+ export default App;
159
+ ```
160
+
161
+ ### 💻 Local Development Usage
162
+
163
+ #### Web Component (Local)
164
+ ```html
165
+ <script src="dist/StackOneHub.web.js"></script>
166
+ <my-component></my-component>
167
+ ```
168
+
169
+ #### React Component (Local)
170
+ ```tsx
171
+ import StackOneHub from "dist/StackOneHub.esm";
172
+
173
+ function App() {
174
+ return <StackOneHub />;
175
+ }
176
+ ```
177
+
178
+ ## 🔧 Environment Variables
179
+
180
+ Create a `.env` file in the `dev` directory with the following variables:
181
+
182
+ | Variable | Description | Required |
183
+ |----------|-------------|----------|
184
+ | `STACKONE_API_KEY` | Your StackOne API key | ✅ |
185
+ | `ORIGIN_OWNER_ID` | The origin owner identifier | ✅ |
186
+ | `ORIGIN_OWNER_NAME` | Display name for the owner | ✅ |
187
+ | `ORIGIN_USERNAME` | Username for authentication | ✅ |
188
+ | `API_URL` | Backend API endpoint URL | ✅ |
189
+ | `DASHBOARD_URL` | Dashboard application URL | ✅ |
190
+
191
+ ### Example `.env` file:
192
+ ```bash
193
+ STACKONE_API_KEY=your_api_key_here
194
+ ORIGIN_OWNER_ID=your_owner_id
195
+ ORIGIN_OWNER_NAME=Your Company Name
196
+ ORIGIN_USERNAME=your_username
197
+ API_URL=https://api.stackone.com
198
+ DASHBOARD_URL=https://dashboard.stackone.com
199
+ ```
200
+
201
+ ## 🤝 Contributing
202
+
203
+ Since this project is in alpha, we welcome contributions and feedback! However, please keep in mind:
204
+
205
+ - 🔄 **Frequent changes**: The codebase may change rapidly
206
+ - 📋 **No formal process yet**: Contribution guidelines are still being established
207
+ - 💬 **Communication is key**: Please open an issue before submitting large changes
208
+
209
+ ### Getting Started
210
+ 1. Fork the repository
211
+ 2. Create a feature branch
212
+ 3. Make your changes
213
+ 4. Test thoroughly
214
+ 5. Submit a pull request
215
+
216
+ ## 📄 License
217
+
218
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
219
+
220
+ ---
221
+
222
+ <div align="center">
223
+ <p><strong>⚠️ Remember: This is alpha software - use at your own risk! ⚠️</strong></p>
224
+ <p>For questions or support, please open an issue on GitHub.</p>
225
+ </div>
package/biome.json ADDED
@@ -0,0 +1,77 @@
1
+ {
2
+ "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3
+ "vcs": {
4
+ "enabled": false,
5
+ "clientKind": "git",
6
+ "useIgnoreFile": false
7
+ },
8
+ "files": {
9
+ "ignoreUnknown": false,
10
+ "ignore": ["**/node_modules/**", "**/dist/**"]
11
+ },
12
+ "formatter": {
13
+ "enabled": true,
14
+ "useEditorconfig": true,
15
+ "formatWithErrors": false,
16
+ "indentStyle": "space",
17
+ "indentWidth": 4,
18
+ "lineEnding": "lf",
19
+ "lineWidth": 100,
20
+ "attributePosition": "auto",
21
+ "bracketSpacing": false
22
+ },
23
+ "organizeImports": {
24
+ "enabled": true
25
+ },
26
+ "linter": {
27
+ "enabled": true,
28
+ "rules": {
29
+ "recommended": false,
30
+ "complexity": {
31
+ "noBannedTypes": "error",
32
+ "noUselessThisAlias": "error",
33
+ "noUselessTypeConstraint": "error",
34
+ "useArrowFunction": "off"
35
+ },
36
+ "correctness": {
37
+ "noConstAssign": "error",
38
+ "noPrecisionLoss": "error",
39
+ "noUnusedVariables": "warn",
40
+ "useArrayLiterals": "off",
41
+ "useExhaustiveDependencies": "warn",
42
+ "useHookAtTopLevel": "error"
43
+ },
44
+ "style": {
45
+ "noInferrableTypes": "error",
46
+ "noNamespace": "error",
47
+ "noNonNullAssertion": "warn",
48
+ "useAsConstAssertion": "error",
49
+ "useBlockStatements": "off"
50
+ },
51
+ "suspicious": {
52
+ "noEmptyBlockStatements": "error",
53
+ "noEmptyInterface": "error",
54
+ "noExplicitAny": "error",
55
+ "noExtraNonNullAssertion": "error",
56
+ "noMisleadingInstantiator": "error",
57
+ "useNamespaceKeyword": "error"
58
+ },
59
+ "nursery": {
60
+ "useComponentExportOnlyModules": "off"
61
+ }
62
+ }
63
+ },
64
+ "javascript": {
65
+ "formatter": {
66
+ "jsxQuoteStyle": "double",
67
+ "quoteProperties": "asNeeded",
68
+ "trailingCommas": "all",
69
+ "semicolons": "always",
70
+ "arrowParentheses": "always",
71
+ "bracketSameLine": false,
72
+ "quoteStyle": "single",
73
+ "attributePosition": "auto",
74
+ "bracketSpacing": true
75
+ }
76
+ }
77
+ }
package/dev/index.html ADDED
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <title>Dev Preview</title>
6
+ </head>
7
+ <body>
8
+ <div id="root"></div>
9
+ <script type="module" src="main.tsx"></script>
10
+ </body>
11
+ </html>
package/dev/main.css ADDED
@@ -0,0 +1,80 @@
1
+ body {
2
+ font-family: "Segoe UI", Arial, sans-serif;
3
+ background: #fafbfc;
4
+ margin: 0;
5
+ padding: 0;
6
+ }
7
+
8
+ .hub-container {
9
+ max-width: 600px;
10
+ margin: 40px auto;
11
+ background: #fff;
12
+ border-radius: 12px;
13
+ box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
14
+ padding: 32px 40px 40px 40px;
15
+ }
16
+
17
+ h1 {
18
+ font-size: 2.6rem;
19
+ margin-top: 32px;
20
+ margin-bottom: 24px;
21
+ font-weight: 700;
22
+ letter-spacing: -1px;
23
+ }
24
+
25
+ p {
26
+ font-size: 1.1rem;
27
+ margin-bottom: 12px;
28
+ }
29
+
30
+ .token-display {
31
+ word-break: break-all;
32
+ background: #f4f6f8;
33
+ border-radius: 6px;
34
+ padding: 8px 12px;
35
+ font-family: "Fira Mono", monospace;
36
+ font-size: 0.98rem;
37
+ margin-bottom: 18px;
38
+ }
39
+
40
+ .button-row {
41
+ display: flex;
42
+ gap: 12px;
43
+ margin-bottom: 28px;
44
+ }
45
+
46
+ button {
47
+ background: #2d72d9;
48
+ color: #fff;
49
+ border: none;
50
+ border-radius: 5px;
51
+ padding: 8px 18px;
52
+ font-size: 1rem;
53
+ cursor: pointer;
54
+ transition: background 0.18s;
55
+ }
56
+ button:hover {
57
+ background: #1b4e91;
58
+ }
59
+
60
+ @media (max-width: 600px) {
61
+ .hub-container {
62
+ padding: 16px 6px;
63
+ }
64
+ h1 {
65
+ font-size: 2rem;
66
+ }
67
+ }
68
+
69
+ .hub-container.dark {
70
+ background: #121212;
71
+ color: #fff;
72
+ .token-display {
73
+ background: #333;
74
+ color: #fff;
75
+ }
76
+ }
77
+
78
+ body {
79
+ background: goldenrod;
80
+ }
package/dev/main.tsx ADDED
@@ -0,0 +1,96 @@
1
+ import './main.css';
2
+ import React, { useCallback, useEffect, useState } from 'react';
3
+ import ReactDOM from 'react-dom/client';
4
+ import { StackOneHub } from '../src/StackOneHub';
5
+ import { request } from '../src/shared/httpClient';
6
+ import { HubModes } from '../src/types/types';
7
+
8
+ const HubWrapper: React.FC = () => {
9
+ const [mode, setMode] = useState<HubModes | undefined>(undefined);
10
+ const [loading, setLoading] = useState<boolean>(false);
11
+ const [error, setError] = useState<string>();
12
+ const [token, setToken] = useState<string>();
13
+ const apiUrl = import.meta.env.VITE_API_URL ?? 'https://api.stackone.com';
14
+ const [theme, setTheme] = useState<'light' | 'dark'>('light');
15
+ const [accountId, setAccountId] = useState<string>('46071458593115456017');
16
+
17
+ const fetchToken = useCallback(async () => {
18
+ try {
19
+ setLoading(true);
20
+ const apiKey = import.meta.env.VITE_STACKONE_API_KEY;
21
+ const encodedApiKey = btoa(apiKey ?? '');
22
+
23
+ const response = await request<{ token: string }>({
24
+ url: `${apiUrl}/connect_sessions`,
25
+ method: 'POST',
26
+ headers: {
27
+ 'Content-Type': 'application/json',
28
+ Authorization: `Basic ${encodedApiKey}`,
29
+ },
30
+ body: {
31
+ metadata: { source: 'hub' },
32
+ origin_owner_id: import.meta.env.VITE_ORIGIN_OWNER_ID ?? 'dummy_customer_id',
33
+ origin_owner_name:
34
+ import.meta.env.VITE_ORIGIN_OWNER_NAME ?? 'dummy_customer_name',
35
+ origin_username: import.meta.env.VITE_ORIGIN_USERNAME ?? 'dummy_username',
36
+ account_id: accountId !== '' && accountId != null ? accountId : undefined,
37
+ },
38
+ });
39
+ if (!response) {
40
+ throw new Error('Failed to fetch token');
41
+ }
42
+
43
+ setToken(response.token);
44
+ } catch (error) {
45
+ console.error('Error fetching token:', error);
46
+ setError(error.message as string);
47
+ } finally {
48
+ setLoading(false);
49
+ }
50
+ }, [accountId]);
51
+
52
+ useEffect(() => {
53
+ fetchToken();
54
+ }, [fetchToken]);
55
+
56
+ return (
57
+ <div className={`hub-container ${theme}`}>
58
+ {loading && <p> Loading token...</p>}
59
+ {error && <p>Error loading token: {error}</p>}
60
+ {token && <p className="token-display">Token: {token}</p>}
61
+ <p>Current mode: {mode || 'No mode selected'}</p>
62
+ <div className="button-row">
63
+ <button onClick={fetchToken}>Get new token</button>
64
+ <button onClick={() => setMode('integration-picker')}>
65
+ Set Integration Picker mode
66
+ </button>
67
+ <button onClick={() => setMode('csv-importer')}>Set CSV Importer mode</button>
68
+ <button onClick={() => setTheme((theme) => (theme === 'light' ? 'dark' : 'light'))}>
69
+ {theme === 'light' ? '🌞' : '🌚'}
70
+ </button>
71
+ </div>
72
+ <input type="text" value={accountId} onChange={(e) => setAccountId(e.target.value)} />
73
+ <h1>StackOneHub Demo</h1>
74
+ <StackOneHub
75
+ mode={mode}
76
+ token={token}
77
+ baseUrl={apiUrl}
78
+ theme={theme}
79
+ onSuccess={() => {
80
+ console.log('success');
81
+ setMode(undefined);
82
+ }}
83
+ accountId={accountId}
84
+ />
85
+ </div>
86
+ );
87
+ };
88
+
89
+ const rootElement = document.getElementById('root');
90
+ if (rootElement) {
91
+ ReactDOM.createRoot(rootElement).render(
92
+ <React.StrictMode>
93
+ <HubWrapper />
94
+ </React.StrictMode>,
95
+ );
96
+ }
@@ -0,0 +1,15 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ interface ImportMetaEnv {
4
+ readonly VITE_APP_TITLE: string;
5
+ readonly VITE_STACKONE_API_KEY: string;
6
+ readonly VITE_ORIGIN_OWNER_ID: string;
7
+ readonly VITE_ORIGIN_OWNER_NAME: string;
8
+ readonly VITE_ORIGIN_USERNAME: string;
9
+ readonly VITE_API_URL: string;
10
+ readonly VITE_DASHBOARD_URL: string;
11
+ }
12
+
13
+ export interface ImportMeta {
14
+ readonly env: ImportMetaEnv;
15
+ }