-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b0abd8d
commit e43150d
Showing
7 changed files
with
169 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Client } from 'aidbox-sdk' | ||
import { io } from 'socket.io-client' | ||
|
||
import config from './config.json' | ||
|
||
export const aidboxClient = new Client(config.aidbox_url, { | ||
username: config.aidbox_client, | ||
password: config.aidbox_secret | ||
}) | ||
|
||
export const socketIo = io(config.app_url, { | ||
auth: { | ||
token: 'json-web-token' | ||
} | ||
}) | ||
|
||
socketIo.on('start_task', function (data) { | ||
setTimeout(() => getTasks(data), 1000) | ||
}) | ||
|
||
socketIo.on('sent_email', function () { | ||
setTimeout(() => setEmailSent(true), 1700) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { Client } from 'aidbox-sdk' | ||
import { createEffect, createEvent, createStore, sample } from 'effector' | ||
import { Socket } from 'socket.io-client' | ||
|
||
export const green = '#17C964' | ||
export const gray = '#889096' | ||
export interface Task { | ||
id: string; | ||
params: { | ||
event?: string; | ||
until?: string; | ||
}; | ||
status: | ||
| 'created' | ||
| 'ready' | ||
| 'requested' | ||
| 'in-progress' | ||
| 'done' | ||
| 'waiting'; | ||
requester: { | ||
id: string; | ||
resourceType: 'AidboxWorkflow'; | ||
}; | ||
definition: | ||
| 'awf.workflow/decision-task' | ||
| 'awf.task/wait' | ||
| 'notification/send-email'; | ||
'workflow-definition': 'notification/appointment-created'; | ||
} | ||
|
||
export interface TaskData { | ||
title: 'workflow-init' | 'wait' | 'send-email'; | ||
color: typeof green | typeof gray; | ||
body: any; | ||
id?: string; | ||
params?: Task['params']; | ||
} | ||
|
||
interface Workflow { | ||
params: { | ||
id: string; | ||
}; | ||
status: 'created' | 'in-progress' | 'done'; | ||
definition: 'notification/appointment-created'; | ||
id: string; | ||
resourceType: 'AidboxWorkflow'; | ||
meta: { | ||
lastUpdated: string; | ||
createdAt: string; | ||
versionId: string; | ||
}; | ||
} | ||
|
||
export const $tasks = createStore<TaskData[]>([]) | ||
export const $workflow = createStore<Workflow | null>(null) | ||
|
||
export const emailSent = createEvent() | ||
export const $emailSent = createStore<boolean>(false).on(emailSent, () => true) | ||
// export const $client = createStore<Client | null>(null) | ||
// export const $socketIo = createStore<Socket | null>(null) | ||
|
||
const getTasksFx = createEffect<string, TaskData[]>((workflowId) => { | ||
console.log(workflowId) | ||
return [] | ||
}) | ||
|
||
export const getTasks = createEvent<string>() | ||
|
||
sample({ clock: getTasks, target: getTasksFx }) | ||
|
||
sample({ clock: getTasksFx.doneData, target: $tasks }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.