-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Andrei Floricel <andrei.floricel@gmail.com>
- Loading branch information
1 parent
972ff91
commit 17cf9e6
Showing
6 changed files
with
71 additions
and
89 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 was deleted.
Oops, something went wrong.
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,30 @@ | ||
import { StandardContextType } from '../context/ContextType'; | ||
import { exhaustiveStringTuple } from './typeHelpers'; | ||
|
||
const STANDARD_CONTEXT_TYPES = exhaustiveStringTuple<StandardContextType>()( | ||
'fdc3.action', | ||
'fdc3.chart', | ||
'fdc3.chat.initSettings', | ||
'fdc3.chat.message', | ||
'fdc3.chat.room', | ||
'fdc3.chat.searchCriteria', | ||
'fdc3.contact', | ||
'fdc3.contactList', | ||
'fdc3.country', | ||
'fdc3.currency', | ||
'fdc3.email', | ||
'fdc3.instrument', | ||
'fdc3.instrumentList', | ||
'fdc3.interaction', | ||
'fdc3.message', | ||
'fdc3.organization', | ||
'fdc3.portfolio', | ||
'fdc3.position', | ||
'fdc3.nothing', | ||
'fdc3.timerange', | ||
'fdc3.transactionResult', | ||
'fdc3.valuation' | ||
); | ||
|
||
// used internally to check if a given intent/context is a standard one | ||
export const StandardContextsSet = new Set(STANDARD_CONTEXT_TYPES); |
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,26 @@ | ||
import { StandardIntent } from '../intents/Intents'; | ||
import { exhaustiveStringTuple } from './typeHelpers'; | ||
|
||
const STANDARD_INTENTS = exhaustiveStringTuple<StandardIntent>()( | ||
'CreateInteraction', | ||
'SendChatMessage', | ||
'StartCall', | ||
'StartChat', | ||
'StartEmail', | ||
'ViewAnalysis', | ||
'ViewChat', | ||
'ViewChart', | ||
'ViewContact', | ||
'ViewHoldings', | ||
'ViewInstrument', | ||
'ViewInteractions', | ||
'ViewMessages', | ||
'ViewNews', | ||
'ViewOrders', | ||
'ViewProfile', | ||
'ViewQuote', | ||
'ViewResearch' | ||
); | ||
|
||
// used internally to check if a given intent/context is a standard one | ||
export const StandardIntentsSet = new Set(STANDARD_INTENTS); |
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,12 @@ | ||
type AtLeastOne<T> = [T, ...T[]]; | ||
|
||
/** | ||
* Ensures at compile time that the given string tuple is exhaustive on a given union type, i.e. contains ALL possible values of the given UNION_TYPE. | ||
*/ | ||
export const exhaustiveStringTuple = <UNION_TYPE extends string>() => <L extends AtLeastOne<UNION_TYPE>>( | ||
...tuple: L extends any | ||
? Exclude<UNION_TYPE, L[number]> extends never | ||
? L | ||
: Exclude<UNION_TYPE, L[number]>[] | ||
: never | ||
) => tuple; |