@inploi/plugin-chatbot 1.0.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.
- package/.env.example +3 -0
- package/.eslintrc.cjs +10 -0
- package/CHANGELOG.md +17 -0
- package/bunfig.toml +2 -0
- package/happydom.ts +10 -0
- package/index.html +28 -0
- package/package.json +58 -0
- package/postcss.config.cjs +7 -0
- package/public/mockServiceWorker.js +292 -0
- package/src/chatbot.api.ts +46 -0
- package/src/chatbot.constants.ts +6 -0
- package/src/chatbot.css +100 -0
- package/src/chatbot.dom.ts +27 -0
- package/src/chatbot.state.ts +180 -0
- package/src/chatbot.ts +77 -0
- package/src/chatbot.utils.ts +38 -0
- package/src/index.cdn.ts +12 -0
- package/src/index.dev.ts +32 -0
- package/src/index.ts +1 -0
- package/src/interpreter/interpreter.test.ts +69 -0
- package/src/interpreter/interpreter.ts +241 -0
- package/src/mocks/browser.ts +5 -0
- package/src/mocks/example.flows.ts +763 -0
- package/src/mocks/handlers.ts +28 -0
- package/src/ui/chat-bubble.tsx +36 -0
- package/src/ui/chat-input/chat-input.boolean.tsx +57 -0
- package/src/ui/chat-input/chat-input.file.tsx +211 -0
- package/src/ui/chat-input/chat-input.multiple-choice.tsx +92 -0
- package/src/ui/chat-input/chat-input.text.tsx +105 -0
- package/src/ui/chat-input/chat-input.tsx +57 -0
- package/src/ui/chatbot-header.tsx +89 -0
- package/src/ui/chatbot.tsx +53 -0
- package/src/ui/input-error.tsx +39 -0
- package/src/ui/job-application-content.tsx +122 -0
- package/src/ui/job-application-messages.tsx +56 -0
- package/src/ui/loading-indicator.tsx +37 -0
- package/src/ui/send-button.tsx +27 -0
- package/src/ui/transition.tsx +1 -0
- package/src/ui/typing-indicator.tsx +12 -0
- package/src/ui/useChatService.ts +82 -0
- package/src/vite-env.d.ts +1 -0
- package/tailwind.config.ts +119 -0
- package/tsconfig.json +33 -0
- package/tsconfig.node.json +10 -0
- package/types.d.ts +2 -0
- package/vite.config.ts +18 -0
package/.env.example
ADDED
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*eslint-env node */
|
|
2
|
+
/** @type {import('eslint').Linter.Config} */
|
|
3
|
+
module.exports = {
|
|
4
|
+
root: true,
|
|
5
|
+
// This tells ESLint to load the config from the package `eslint-config-custom`
|
|
6
|
+
extends: ['custom', 'plugin:react-hooks/recommended'],
|
|
7
|
+
plugins: ['react-hooks'],
|
|
8
|
+
env: { browser: true, es2020: true },
|
|
9
|
+
parserOptions: { project: ['./packages/plugin-chatbot/tsconfig.json'] },
|
|
10
|
+
};
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @inploi/plugin-chatbot
|
|
2
|
+
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d8a904e: Split SDK plugins into their own packages
|
|
8
|
+
- Updated dependencies [5a34b5a]
|
|
9
|
+
- Updated dependencies [5d1e92b]
|
|
10
|
+
- Updated dependencies [5d1e92b]
|
|
11
|
+
- Updated dependencies [df4f06d]
|
|
12
|
+
- Updated dependencies [d5caf7e]
|
|
13
|
+
- Updated dependencies [a582965]
|
|
14
|
+
- Updated dependencies [d8a904e]
|
|
15
|
+
- Updated dependencies [553e630]
|
|
16
|
+
- @inploi/core@1.4.0
|
|
17
|
+
- @inploi/sdk@1.0.0
|
package/bunfig.toml
ADDED
package/happydom.ts
ADDED
package/index.html
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Vite + Preact + TS</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body
|
|
10
|
+
style="
|
|
11
|
+
font-family: 'Courier New', Courier, monospace;
|
|
12
|
+
height: 100vh;
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
"
|
|
17
|
+
>
|
|
18
|
+
<div>
|
|
19
|
+
<h1 style="font-size: 2rem; letter-spacing: -0.02em; text-align: center">Super legit careers hub</h1>
|
|
20
|
+
<p>Welcome, start applying by clicking on one of the buttons below</p>
|
|
21
|
+
|
|
22
|
+
<button onclick="chatbot.startApplication({ jobId: '1' })">Apply for Wagamama job</button>
|
|
23
|
+
<button onclick="chatbot.startApplication({ jobId: '2' })">Apply for job Test flow</button>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<script type="module" src="/src/index.dev.ts"></script>
|
|
27
|
+
</body>
|
|
28
|
+
</html>
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@inploi/plugin-chatbot",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@hookform/resolvers": "^3.3.2",
|
|
7
|
+
"class-variance-authority": "^0.7.0",
|
|
8
|
+
"clsx": "^2.0.0",
|
|
9
|
+
"idb-keyval": "^6.2.1",
|
|
10
|
+
"immer": "^10.0.3",
|
|
11
|
+
"preact": "^10.16.0",
|
|
12
|
+
"react": "npm:@preact/compat",
|
|
13
|
+
"react-dom": "npm:@preact/compat",
|
|
14
|
+
"react-hook-form": "^7.48.2",
|
|
15
|
+
"react-transition-group": "^4.4.5",
|
|
16
|
+
"swr": "^2.2.4",
|
|
17
|
+
"tailwindcss-touch": "^1.0.1",
|
|
18
|
+
"ts-pattern": "^5.0.5",
|
|
19
|
+
"vaul": "^0.7.8",
|
|
20
|
+
"zod": "^3.22.0",
|
|
21
|
+
"zustand": "^4.4.4",
|
|
22
|
+
"@inploi/core": "1.4.0"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@inploi/sdk": "*"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@happy-dom/global-registrator": "^12.6.0",
|
|
29
|
+
"@preact/preset-vite": "^2.5.0",
|
|
30
|
+
"@total-typescript/ts-reset": "^0.5.1",
|
|
31
|
+
"@types/react-transition-group": "^4.4.9",
|
|
32
|
+
"autoprefixer": "^10.4.16",
|
|
33
|
+
"eslint": "^7.32.0",
|
|
34
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
35
|
+
"happy-dom": "^12.6.0",
|
|
36
|
+
"msw": "^2.0.5",
|
|
37
|
+
"postcss": "^8.4.31",
|
|
38
|
+
"postcss-nesting": "^12.0.1",
|
|
39
|
+
"rollup-plugin-visualizer": "^5.9.2",
|
|
40
|
+
"tailwindcss": "^3.3.5",
|
|
41
|
+
"ts-toolbelt": "^9.6.0",
|
|
42
|
+
"typescript": "^5.1.6",
|
|
43
|
+
"vite": "^4.4.5",
|
|
44
|
+
"vite-tsconfig-paths": "^4.2.1",
|
|
45
|
+
"@inploi/sdk": "1.0.0",
|
|
46
|
+
"eslint-config-custom": "0.1.0",
|
|
47
|
+
"tsconfig": "0.1.0"
|
|
48
|
+
},
|
|
49
|
+
"msw": {
|
|
50
|
+
"workerDirectory": "public"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"dev": "vite",
|
|
54
|
+
"build": "tsc && vite build",
|
|
55
|
+
"setup-local": "cp -n .env.example .env || true",
|
|
56
|
+
"preview": "vite preview"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mock Service Worker (2.0.5).
|
|
6
|
+
* @see https://github.com/mswjs/msw
|
|
7
|
+
* - Please do NOT modify this file.
|
|
8
|
+
* - Please do NOT serve this file on production.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const INTEGRITY_CHECKSUM = '0877fcdc026242810f5bfde0d7178db4'
|
|
12
|
+
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
|
|
13
|
+
const activeClientIds = new Set()
|
|
14
|
+
|
|
15
|
+
self.addEventListener('install', function () {
|
|
16
|
+
self.skipWaiting()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
self.addEventListener('activate', function (event) {
|
|
20
|
+
event.waitUntil(self.clients.claim())
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
self.addEventListener('message', async function (event) {
|
|
24
|
+
const clientId = event.source.id
|
|
25
|
+
|
|
26
|
+
if (!clientId || !self.clients) {
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const client = await self.clients.get(clientId)
|
|
31
|
+
|
|
32
|
+
if (!client) {
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const allClients = await self.clients.matchAll({
|
|
37
|
+
type: 'window',
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
switch (event.data) {
|
|
41
|
+
case 'KEEPALIVE_REQUEST': {
|
|
42
|
+
sendToClient(client, {
|
|
43
|
+
type: 'KEEPALIVE_RESPONSE',
|
|
44
|
+
})
|
|
45
|
+
break
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
case 'INTEGRITY_CHECK_REQUEST': {
|
|
49
|
+
sendToClient(client, {
|
|
50
|
+
type: 'INTEGRITY_CHECK_RESPONSE',
|
|
51
|
+
payload: INTEGRITY_CHECKSUM,
|
|
52
|
+
})
|
|
53
|
+
break
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
case 'MOCK_ACTIVATE': {
|
|
57
|
+
activeClientIds.add(clientId)
|
|
58
|
+
|
|
59
|
+
sendToClient(client, {
|
|
60
|
+
type: 'MOCKING_ENABLED',
|
|
61
|
+
payload: true,
|
|
62
|
+
})
|
|
63
|
+
break
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
case 'MOCK_DEACTIVATE': {
|
|
67
|
+
activeClientIds.delete(clientId)
|
|
68
|
+
break
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
case 'CLIENT_CLOSED': {
|
|
72
|
+
activeClientIds.delete(clientId)
|
|
73
|
+
|
|
74
|
+
const remainingClients = allClients.filter((client) => {
|
|
75
|
+
return client.id !== clientId
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
// Unregister itself when there are no more clients
|
|
79
|
+
if (remainingClients.length === 0) {
|
|
80
|
+
self.registration.unregister()
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
break
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
self.addEventListener('fetch', function (event) {
|
|
89
|
+
const { request } = event
|
|
90
|
+
|
|
91
|
+
// Bypass navigation requests.
|
|
92
|
+
if (request.mode === 'navigate') {
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Opening the DevTools triggers the "only-if-cached" request
|
|
97
|
+
// that cannot be handled by the worker. Bypass such requests.
|
|
98
|
+
if (request.cache === 'only-if-cached' && request.mode !== 'same-origin') {
|
|
99
|
+
return
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Bypass all requests when there are no active clients.
|
|
103
|
+
// Prevents the self-unregistered worked from handling requests
|
|
104
|
+
// after it's been deleted (still remains active until the next reload).
|
|
105
|
+
if (activeClientIds.size === 0) {
|
|
106
|
+
return
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Generate unique request ID.
|
|
110
|
+
const requestId = crypto.randomUUID()
|
|
111
|
+
event.respondWith(handleRequest(event, requestId))
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
async function handleRequest(event, requestId) {
|
|
115
|
+
const client = await resolveMainClient(event)
|
|
116
|
+
const response = await getResponse(event, client, requestId)
|
|
117
|
+
|
|
118
|
+
// Send back the response clone for the "response:*" life-cycle events.
|
|
119
|
+
// Ensure MSW is active and ready to handle the message, otherwise
|
|
120
|
+
// this message will pend indefinitely.
|
|
121
|
+
if (client && activeClientIds.has(client.id)) {
|
|
122
|
+
;(async function () {
|
|
123
|
+
const responseClone = response.clone()
|
|
124
|
+
// When performing original requests, response body will
|
|
125
|
+
// always be a ReadableStream, even for 204 responses.
|
|
126
|
+
// But when creating a new Response instance on the client,
|
|
127
|
+
// the body for a 204 response must be null.
|
|
128
|
+
const responseBody = response.status === 204 ? null : responseClone.body
|
|
129
|
+
|
|
130
|
+
sendToClient(
|
|
131
|
+
client,
|
|
132
|
+
{
|
|
133
|
+
type: 'RESPONSE',
|
|
134
|
+
payload: {
|
|
135
|
+
requestId,
|
|
136
|
+
isMockedResponse: IS_MOCKED_RESPONSE in response,
|
|
137
|
+
type: responseClone.type,
|
|
138
|
+
status: responseClone.status,
|
|
139
|
+
statusText: responseClone.statusText,
|
|
140
|
+
body: responseBody,
|
|
141
|
+
headers: Object.fromEntries(responseClone.headers.entries()),
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
[responseBody],
|
|
145
|
+
)
|
|
146
|
+
})()
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return response
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Resolve the main client for the given event.
|
|
153
|
+
// Client that issues a request doesn't necessarily equal the client
|
|
154
|
+
// that registered the worker. It's with the latter the worker should
|
|
155
|
+
// communicate with during the response resolving phase.
|
|
156
|
+
async function resolveMainClient(event) {
|
|
157
|
+
const client = await self.clients.get(event.clientId)
|
|
158
|
+
|
|
159
|
+
if (client?.frameType === 'top-level') {
|
|
160
|
+
return client
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const allClients = await self.clients.matchAll({
|
|
164
|
+
type: 'window',
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
return allClients
|
|
168
|
+
.filter((client) => {
|
|
169
|
+
// Get only those clients that are currently visible.
|
|
170
|
+
return client.visibilityState === 'visible'
|
|
171
|
+
})
|
|
172
|
+
.find((client) => {
|
|
173
|
+
// Find the client ID that's recorded in the
|
|
174
|
+
// set of clients that have registered the worker.
|
|
175
|
+
return activeClientIds.has(client.id)
|
|
176
|
+
})
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
async function getResponse(event, client, requestId) {
|
|
180
|
+
const { request } = event
|
|
181
|
+
|
|
182
|
+
// Clone the request because it might've been already used
|
|
183
|
+
// (i.e. its body has been read and sent to the client).
|
|
184
|
+
const requestClone = request.clone()
|
|
185
|
+
|
|
186
|
+
function passthrough() {
|
|
187
|
+
const headers = Object.fromEntries(requestClone.headers.entries())
|
|
188
|
+
|
|
189
|
+
// Remove internal MSW request header so the passthrough request
|
|
190
|
+
// complies with any potential CORS preflight checks on the server.
|
|
191
|
+
// Some servers forbid unknown request headers.
|
|
192
|
+
delete headers['x-msw-intention']
|
|
193
|
+
|
|
194
|
+
return fetch(requestClone, { headers })
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Bypass mocking when the client is not active.
|
|
198
|
+
if (!client) {
|
|
199
|
+
return passthrough()
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Bypass initial page load requests (i.e. static assets).
|
|
203
|
+
// The absence of the immediate/parent client in the map of the active clients
|
|
204
|
+
// means that MSW hasn't dispatched the "MOCK_ACTIVATE" event yet
|
|
205
|
+
// and is not ready to handle requests.
|
|
206
|
+
if (!activeClientIds.has(client.id)) {
|
|
207
|
+
return passthrough()
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Bypass requests with the explicit bypass header.
|
|
211
|
+
// Such requests can be issued by "ctx.fetch()".
|
|
212
|
+
const mswIntention = request.headers.get('x-msw-intention')
|
|
213
|
+
if (['bypass', 'passthrough'].includes(mswIntention)) {
|
|
214
|
+
return passthrough()
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Notify the client that a request has been intercepted.
|
|
218
|
+
const requestBuffer = await request.arrayBuffer()
|
|
219
|
+
const clientMessage = await sendToClient(
|
|
220
|
+
client,
|
|
221
|
+
{
|
|
222
|
+
type: 'REQUEST',
|
|
223
|
+
payload: {
|
|
224
|
+
id: requestId,
|
|
225
|
+
url: request.url,
|
|
226
|
+
mode: request.mode,
|
|
227
|
+
method: request.method,
|
|
228
|
+
headers: Object.fromEntries(request.headers.entries()),
|
|
229
|
+
cache: request.cache,
|
|
230
|
+
credentials: request.credentials,
|
|
231
|
+
destination: request.destination,
|
|
232
|
+
integrity: request.integrity,
|
|
233
|
+
redirect: request.redirect,
|
|
234
|
+
referrer: request.referrer,
|
|
235
|
+
referrerPolicy: request.referrerPolicy,
|
|
236
|
+
body: requestBuffer,
|
|
237
|
+
keepalive: request.keepalive,
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
[requestBuffer],
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
switch (clientMessage.type) {
|
|
244
|
+
case 'MOCK_RESPONSE': {
|
|
245
|
+
return respondWithMock(clientMessage.data)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
case 'MOCK_NOT_FOUND': {
|
|
249
|
+
return passthrough()
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return passthrough()
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function sendToClient(client, message, transferrables = []) {
|
|
257
|
+
return new Promise((resolve, reject) => {
|
|
258
|
+
const channel = new MessageChannel()
|
|
259
|
+
|
|
260
|
+
channel.port1.onmessage = (event) => {
|
|
261
|
+
if (event.data && event.data.error) {
|
|
262
|
+
return reject(event.data.error)
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
resolve(event.data)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
client.postMessage(
|
|
269
|
+
message,
|
|
270
|
+
[channel.port2].concat(transferrables.filter(Boolean)),
|
|
271
|
+
)
|
|
272
|
+
})
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
async function respondWithMock(response) {
|
|
276
|
+
// Setting response status code to 0 is a no-op.
|
|
277
|
+
// However, when responding with a "Response.error()", the produced Response
|
|
278
|
+
// instance will have status code set to 0. Since it's not possible to create
|
|
279
|
+
// a Response instance with status code 0, handle that use-case separately.
|
|
280
|
+
if (response.status === 0) {
|
|
281
|
+
return Response.error()
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const mockedResponse = new Response(response.body, response)
|
|
285
|
+
|
|
286
|
+
Reflect.defineProperty(mockedResponse, IS_MOCKED_RESPONSE, {
|
|
287
|
+
value: true,
|
|
288
|
+
enumerable: true,
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
return mockedResponse
|
|
292
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { FlowNode, FlowNodeSchema } from '@inploi/core/flows';
|
|
2
|
+
import { ApiClient } from '@inploi/sdk';
|
|
3
|
+
import z from 'zod';
|
|
4
|
+
|
|
5
|
+
export type JobApplication = {
|
|
6
|
+
job: {
|
|
7
|
+
id: string; // internal inploi job id
|
|
8
|
+
title: string; //job title
|
|
9
|
+
};
|
|
10
|
+
company: {
|
|
11
|
+
name: string; // company name
|
|
12
|
+
logo?: string; // company logo
|
|
13
|
+
};
|
|
14
|
+
flow: {
|
|
15
|
+
id: string; // flow id
|
|
16
|
+
version: number; // hardcode the version as 0 until we have versioning
|
|
17
|
+
nodes: FlowNode[]; // new jsonb flow nodes, no need for the legacy parser to run
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const ApplicationFlowSchema = z.object({
|
|
22
|
+
job: z.object({
|
|
23
|
+
id: z.coerce.string(),
|
|
24
|
+
title: z.string(),
|
|
25
|
+
}),
|
|
26
|
+
company: z.object({
|
|
27
|
+
name: z.string(),
|
|
28
|
+
logo: z.string().optional(),
|
|
29
|
+
}),
|
|
30
|
+
flow: z.object({
|
|
31
|
+
id: z.coerce.string(),
|
|
32
|
+
nodes: z.array(FlowNodeSchema),
|
|
33
|
+
version: z.number(),
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export async function getApplicationData({
|
|
38
|
+
jobId,
|
|
39
|
+
apiClient,
|
|
40
|
+
}: {
|
|
41
|
+
jobId: string;
|
|
42
|
+
apiClient: ApiClient;
|
|
43
|
+
}): Promise<JobApplication> {
|
|
44
|
+
const rawData = await apiClient.fetch(`/flow/job/${jobId}`);
|
|
45
|
+
return ApplicationFlowSchema.parse(rawData);
|
|
46
|
+
}
|
package/src/chatbot.css
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#isdk {
|
|
2
|
+
font-size: 16px;
|
|
3
|
+
font-family: sans-serif;
|
|
4
|
+
|
|
5
|
+
/* Lowest colour */
|
|
6
|
+
--i-lowest: 0 0% 100%;
|
|
7
|
+
|
|
8
|
+
/* Neutral colors */
|
|
9
|
+
--i-n-1: 206 30% 98.8%;
|
|
10
|
+
--i-n-2: 210 16.7% 97.6%;
|
|
11
|
+
--i-n-3: 209 13.3% 95.3%;
|
|
12
|
+
--i-n-4: 209 12.2% 93.2%;
|
|
13
|
+
--i-n-5: 208 11.7% 91.1%;
|
|
14
|
+
--i-n-6: 208 11.3% 88.9%;
|
|
15
|
+
--i-n-7: 207 11.1% 85.9%;
|
|
16
|
+
--i-n-8: 205 10.7% 78%;
|
|
17
|
+
--i-n-9: 206 6% 56.1%;
|
|
18
|
+
--i-n-10: 206 5.8% 52.3%;
|
|
19
|
+
--i-n-11: 206 6% 43.5%;
|
|
20
|
+
--i-n-12: 206 24% 9%;
|
|
21
|
+
|
|
22
|
+
/* Accent colors */
|
|
23
|
+
--i-a-1: 240 33% 99%;
|
|
24
|
+
--i-a-2: 225 100% 98%;
|
|
25
|
+
--i-a-3: 222 89% 96%;
|
|
26
|
+
--i-a-4: 224 100% 94%;
|
|
27
|
+
--i-a-5: 224 100% 91%;
|
|
28
|
+
--i-a-6: 225 100% 88%;
|
|
29
|
+
--i-a-7: 226 87% 82%;
|
|
30
|
+
--i-a-8: 226 75% 75%;
|
|
31
|
+
--i-a-9: 226 70% 55%;
|
|
32
|
+
--i-a-10: 226 65% 52%;
|
|
33
|
+
--i-a-11: 226 56% 50%;
|
|
34
|
+
--i-a-12: 226 50% 24%;
|
|
35
|
+
|
|
36
|
+
/** Error colours */
|
|
37
|
+
--i-e-1: 340 100% 99%;
|
|
38
|
+
--i-e-2: 353 100% 98%;
|
|
39
|
+
--i-e-3: 351 91% 96%;
|
|
40
|
+
--i-e-4: 351 100% 93%;
|
|
41
|
+
--i-e-5: 350 100% 90%;
|
|
42
|
+
--i-e-6: 351 80% 86%;
|
|
43
|
+
--i-e-7: 349 68% 81%;
|
|
44
|
+
--i-e-8: 348 61% 74%;
|
|
45
|
+
--i-e-9: 348 75% 59%;
|
|
46
|
+
--i-e-10: 347 70% 55%;
|
|
47
|
+
--i-e-11: 345 70% 47%;
|
|
48
|
+
--i-e-12: 344 63% 24%;
|
|
49
|
+
|
|
50
|
+
@tailwind base;
|
|
51
|
+
@tailwind components;
|
|
52
|
+
@tailwind utilities;
|
|
53
|
+
@tailwind variants;
|
|
54
|
+
|
|
55
|
+
@layer base {
|
|
56
|
+
--tw-content: '';
|
|
57
|
+
font-family:
|
|
58
|
+
system-ui,
|
|
59
|
+
-apple-system,
|
|
60
|
+
BlinkMacSystemFont,
|
|
61
|
+
Segoe UI,
|
|
62
|
+
Roboto,
|
|
63
|
+
Oxygen,
|
|
64
|
+
Ubuntu,
|
|
65
|
+
Cantarell,
|
|
66
|
+
Open Sans,
|
|
67
|
+
Helvetica Neue,
|
|
68
|
+
sans-serif;
|
|
69
|
+
|
|
70
|
+
* {
|
|
71
|
+
box-sizing: border-box;
|
|
72
|
+
border-style: solid;
|
|
73
|
+
border-width: 0;
|
|
74
|
+
-webkit-tap-highlight-color: transparent;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
::before,
|
|
78
|
+
::after {
|
|
79
|
+
box-sizing: border-box;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
:is(ul) {
|
|
83
|
+
list-style: none;
|
|
84
|
+
padding: 0;
|
|
85
|
+
margin: 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
:is(p) {
|
|
89
|
+
margin: 0;
|
|
90
|
+
padding: 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
:is(button) {
|
|
94
|
+
margin: 0;
|
|
95
|
+
padding: 0;
|
|
96
|
+
border: unset;
|
|
97
|
+
background: unset;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CHATBOT_ELEMENT_ID } from './chatbot.constants';
|
|
2
|
+
|
|
3
|
+
function assertElementExists(chatbotElement: HTMLDivElement | null): asserts chatbotElement is HTMLDivElement {
|
|
4
|
+
if (!chatbotElement) throw new Error('Chatbot element not found');
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const overlayClassNames =
|
|
8
|
+
'data-[transition=entering]:opacity-0 data-[transition=exiting]:opacity-0 ease-expo-out duration-500 transition-opacity bg-neutral-12/60 fixed inset-0';
|
|
9
|
+
|
|
10
|
+
export const createChatbotDomManager = () => {
|
|
11
|
+
let chatbotElement: HTMLDivElement | null = null;
|
|
12
|
+
return {
|
|
13
|
+
getOrCreateChatbotElement: () => {
|
|
14
|
+
if (chatbotElement) return chatbotElement;
|
|
15
|
+
|
|
16
|
+
const newElement = document.createElement('div');
|
|
17
|
+
document.body.appendChild(newElement);
|
|
18
|
+
newElement.id = CHATBOT_ELEMENT_ID;
|
|
19
|
+
chatbotElement = newElement;
|
|
20
|
+
return newElement;
|
|
21
|
+
},
|
|
22
|
+
renderLoading: (element: HTMLElement) => {
|
|
23
|
+
element.innerHTML = `<div class="${overlayClassNames}" />`;
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export type ChatbotDomManager = ReturnType<typeof createChatbotDomManager>;
|