@atlaskit/rovo-triggers 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/CHANGELOG.md +9 -0
- package/LICENSE.md +11 -0
- package/README.md +172 -0
- package/dist/cjs/common/utils/params/constants.js +8 -0
- package/dist/cjs/common/utils/params/index.js +153 -0
- package/dist/cjs/common/utils/params/types.js +1 -0
- package/dist/cjs/index.js +67 -0
- package/dist/cjs/main.js +169 -0
- package/dist/cjs/types.js +15 -0
- package/dist/es2019/common/utils/params/constants.js +2 -0
- package/dist/es2019/common/utils/params/index.js +121 -0
- package/dist/es2019/common/utils/params/types.js +0 -0
- package/dist/es2019/index.js +2 -0
- package/dist/es2019/main.js +159 -0
- package/dist/es2019/types.js +9 -0
- package/dist/esm/common/utils/params/constants.js +2 -0
- package/dist/esm/common/utils/params/index.js +146 -0
- package/dist/esm/common/utils/params/types.js +0 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/main.js +162 -0
- package/dist/esm/types.js +9 -0
- package/dist/types/common/utils/params/constants.d.ts +3 -0
- package/dist/types/common/utils/params/index.d.ts +15 -0
- package/dist/types/common/utils/params/types.d.ts +20 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/main.d.ts +15 -0
- package/dist/types/types.d.ts +79 -0
- package/dist/types-ts4.5/common/utils/params/constants.d.ts +3 -0
- package/dist/types-ts4.5/common/utils/params/index.d.ts +15 -0
- package/dist/types-ts4.5/common/utils/params/types.d.ts +20 -0
- package/dist/types-ts4.5/index.d.ts +4 -0
- package/dist/types-ts4.5/main.d.ts +15 -0
- package/dist/types-ts4.5/types.d.ts +79 -0
- package/package.json +90 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Callback, Payload, Topic } from './types';
|
|
2
|
+
interface SubscribeOptions {
|
|
3
|
+
topic: Topic;
|
|
4
|
+
triggerLatest?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const useSubscribe: ({ topic, triggerLatest }: SubscribeOptions, callback: Callback) => void;
|
|
7
|
+
export declare const useSubscribeAll: (callback: Callback) => void;
|
|
8
|
+
export declare const usePublish: (topic: Topic) => (payload: Payload) => void;
|
|
9
|
+
export declare const Subscriber: ({ topic, triggerLatest, onEvent, flushQueueOnUnmount, }: {
|
|
10
|
+
topic: Topic;
|
|
11
|
+
triggerLatest?: boolean | undefined;
|
|
12
|
+
onEvent: Callback;
|
|
13
|
+
flushQueueOnUnmount?: boolean | undefined;
|
|
14
|
+
}) => null;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export declare const Topics: {
|
|
2
|
+
readonly AI_MATE: "ai-mate";
|
|
3
|
+
};
|
|
4
|
+
export type Topic = (typeof Topics)[keyof typeof Topics];
|
|
5
|
+
export type PayloadCore<TKey extends string, TData = void> = {
|
|
6
|
+
type: TKey;
|
|
7
|
+
source: string;
|
|
8
|
+
openChat?: boolean;
|
|
9
|
+
product?: string;
|
|
10
|
+
interactionSource?: string;
|
|
11
|
+
} & (TData extends void ? {} : {
|
|
12
|
+
data: TData;
|
|
13
|
+
});
|
|
14
|
+
export type MessageSendPayload = PayloadCore<'message-send', {
|
|
15
|
+
prompt: string;
|
|
16
|
+
}>;
|
|
17
|
+
export type ChatNewPayload = PayloadCore<'chat-new', {
|
|
18
|
+
name: string;
|
|
19
|
+
dialogues: Array<{
|
|
20
|
+
human_message: {
|
|
21
|
+
content: string;
|
|
22
|
+
};
|
|
23
|
+
agent_message: {
|
|
24
|
+
content: string;
|
|
25
|
+
};
|
|
26
|
+
}>;
|
|
27
|
+
prompt?: string;
|
|
28
|
+
sourceId?: string;
|
|
29
|
+
agentId?: string;
|
|
30
|
+
}>;
|
|
31
|
+
export type EditorContextPayloadData = {
|
|
32
|
+
document: {
|
|
33
|
+
type: 'text/markdown' | 'text/adf';
|
|
34
|
+
content: string;
|
|
35
|
+
};
|
|
36
|
+
selection: {
|
|
37
|
+
type: 'text/markdown' | 'text/plain';
|
|
38
|
+
content: string;
|
|
39
|
+
};
|
|
40
|
+
} | undefined;
|
|
41
|
+
export type BrowserContextPayloadData = {
|
|
42
|
+
context: {
|
|
43
|
+
browserUrl: string;
|
|
44
|
+
htmlBody?: string;
|
|
45
|
+
canvasText?: string;
|
|
46
|
+
} | undefined;
|
|
47
|
+
};
|
|
48
|
+
export type EditorContextPayload = PayloadCore<'editor-context-payload'> & {
|
|
49
|
+
data: EditorContextPayloadData;
|
|
50
|
+
};
|
|
51
|
+
export type BrowserContextPayload = PayloadCore<'browser-context-payload'> & {
|
|
52
|
+
data: BrowserContextPayloadData;
|
|
53
|
+
};
|
|
54
|
+
export type ChatDraftPayload = PayloadCore<'chat-draft'>;
|
|
55
|
+
export type OpenBrowseAgentPayload = PayloadCore<'open-browse-agent-modal'>;
|
|
56
|
+
export type EditorSuggestionPayload = PayloadCore<'editor-suggestion', {
|
|
57
|
+
mode: 'insert' | 'replace';
|
|
58
|
+
content: string;
|
|
59
|
+
agentId?: string;
|
|
60
|
+
}>;
|
|
61
|
+
export type ChatOpenPayload = PayloadCore<'chat-open', {
|
|
62
|
+
channelId: string;
|
|
63
|
+
agentId?: string;
|
|
64
|
+
}>;
|
|
65
|
+
export type ForgeAppAuthSuccess = PayloadCore<'forge-auth-success'>;
|
|
66
|
+
export type ForgeAppAuthFailure = PayloadCore<'forge-auth-failure', {
|
|
67
|
+
errorMessage: string | undefined;
|
|
68
|
+
}>;
|
|
69
|
+
export type Payload = MessageSendPayload | ChatNewPayload | ChatDraftPayload | EditorContextPayload | ChatOpenPayload | OpenBrowseAgentPayload | EditorSuggestionPayload | BrowserContextPayload | ForgeAppAuthSuccess | ForgeAppAuthFailure;
|
|
70
|
+
export type Callback = (payload: Payload) => void;
|
|
71
|
+
export type TopicEvents = {
|
|
72
|
+
[key in Topic]?: Array<{
|
|
73
|
+
id: string;
|
|
74
|
+
callback: Callback;
|
|
75
|
+
}>;
|
|
76
|
+
};
|
|
77
|
+
export type TopicEventQueue = {
|
|
78
|
+
[key in Topic]?: Payload;
|
|
79
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type RovoChatParams, type ValidParam } from './types';
|
|
2
|
+
export declare const firstCharUpper: (str: string) => string;
|
|
3
|
+
export declare const firstCharLower: (str: string) => string;
|
|
4
|
+
export declare const addPrefix: (param: ValidParam) => string;
|
|
5
|
+
export declare const removePrefix: (param: string) => string;
|
|
6
|
+
export declare const getRovoParams: (url?: string) => RovoChatParams;
|
|
7
|
+
export declare const updatePageRovoParams: (params: RovoChatParams) => void;
|
|
8
|
+
export declare const addRovoParamsToUrl: (url: string, params: RovoChatParams) => string;
|
|
9
|
+
export declare const encodeRovoParams: (params: RovoChatParams, encodeAsObject?: boolean) => string | {
|
|
10
|
+
[key: string]: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const assertOnlySpecificFieldsDefined: (params: RovoChatParams, fields: (keyof RovoChatParams)[]) => boolean;
|
|
13
|
+
export declare const getListOfRovoParams: ({ resourceRouterQuery }?: {
|
|
14
|
+
resourceRouterQuery?: boolean | undefined;
|
|
15
|
+
}) => string[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type RovoChatPathway = 'chat' | 'agents-browse' | 'agents-create';
|
|
2
|
+
export interface BaseRovoChatParams {
|
|
3
|
+
pathway: RovoChatPathway;
|
|
4
|
+
agentId: string;
|
|
5
|
+
conversationId: string;
|
|
6
|
+
prompt: string;
|
|
7
|
+
cloudId: string;
|
|
8
|
+
triggerOpen: boolean;
|
|
9
|
+
}
|
|
10
|
+
export type ValidPrefix = 'rovoChat';
|
|
11
|
+
export type ValidParam = keyof BaseRovoChatParams;
|
|
12
|
+
export type ValidPrefixedParam = `${ValidPrefix}${ValidParam}`;
|
|
13
|
+
type RovoParams<T extends RovoChatPathway, P = object> = BaseRovoChatParams & {
|
|
14
|
+
pathway: T;
|
|
15
|
+
} & P;
|
|
16
|
+
type ChatParams = RovoParams<'chat'>;
|
|
17
|
+
type AgentBrowseParams = RovoParams<'agents-browse'>;
|
|
18
|
+
type AgentCreateParams = RovoParams<'agents-create'>;
|
|
19
|
+
export type RovoChatParams = Partial<ChatParams | AgentCreateParams | AgentBrowseParams>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { usePublish, useSubscribe, useSubscribeAll, Subscriber } from './main';
|
|
2
|
+
export type { Payload, Callback, Topic, EditorContextPayloadData, BrowserContextPayloadData, } from './types';
|
|
3
|
+
export { getRovoParams, updatePageRovoParams, addRovoParamsToUrl, assertOnlySpecificFieldsDefined, encodeRovoParams, getListOfRovoParams, } from './common/utils/params';
|
|
4
|
+
export type { RovoChatParams, RovoChatPathway } from './common/utils/params/types';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Callback, Payload, Topic } from './types';
|
|
2
|
+
interface SubscribeOptions {
|
|
3
|
+
topic: Topic;
|
|
4
|
+
triggerLatest?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const useSubscribe: ({ topic, triggerLatest }: SubscribeOptions, callback: Callback) => void;
|
|
7
|
+
export declare const useSubscribeAll: (callback: Callback) => void;
|
|
8
|
+
export declare const usePublish: (topic: Topic) => (payload: Payload) => void;
|
|
9
|
+
export declare const Subscriber: ({ topic, triggerLatest, onEvent, flushQueueOnUnmount, }: {
|
|
10
|
+
topic: Topic;
|
|
11
|
+
triggerLatest?: boolean | undefined;
|
|
12
|
+
onEvent: Callback;
|
|
13
|
+
flushQueueOnUnmount?: boolean | undefined;
|
|
14
|
+
}) => null;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export declare const Topics: {
|
|
2
|
+
readonly AI_MATE: "ai-mate";
|
|
3
|
+
};
|
|
4
|
+
export type Topic = (typeof Topics)[keyof typeof Topics];
|
|
5
|
+
export type PayloadCore<TKey extends string, TData = void> = {
|
|
6
|
+
type: TKey;
|
|
7
|
+
source: string;
|
|
8
|
+
openChat?: boolean;
|
|
9
|
+
product?: string;
|
|
10
|
+
interactionSource?: string;
|
|
11
|
+
} & (TData extends void ? {} : {
|
|
12
|
+
data: TData;
|
|
13
|
+
});
|
|
14
|
+
export type MessageSendPayload = PayloadCore<'message-send', {
|
|
15
|
+
prompt: string;
|
|
16
|
+
}>;
|
|
17
|
+
export type ChatNewPayload = PayloadCore<'chat-new', {
|
|
18
|
+
name: string;
|
|
19
|
+
dialogues: Array<{
|
|
20
|
+
human_message: {
|
|
21
|
+
content: string;
|
|
22
|
+
};
|
|
23
|
+
agent_message: {
|
|
24
|
+
content: string;
|
|
25
|
+
};
|
|
26
|
+
}>;
|
|
27
|
+
prompt?: string;
|
|
28
|
+
sourceId?: string;
|
|
29
|
+
agentId?: string;
|
|
30
|
+
}>;
|
|
31
|
+
export type EditorContextPayloadData = {
|
|
32
|
+
document: {
|
|
33
|
+
type: 'text/markdown' | 'text/adf';
|
|
34
|
+
content: string;
|
|
35
|
+
};
|
|
36
|
+
selection: {
|
|
37
|
+
type: 'text/markdown' | 'text/plain';
|
|
38
|
+
content: string;
|
|
39
|
+
};
|
|
40
|
+
} | undefined;
|
|
41
|
+
export type BrowserContextPayloadData = {
|
|
42
|
+
context: {
|
|
43
|
+
browserUrl: string;
|
|
44
|
+
htmlBody?: string;
|
|
45
|
+
canvasText?: string;
|
|
46
|
+
} | undefined;
|
|
47
|
+
};
|
|
48
|
+
export type EditorContextPayload = PayloadCore<'editor-context-payload'> & {
|
|
49
|
+
data: EditorContextPayloadData;
|
|
50
|
+
};
|
|
51
|
+
export type BrowserContextPayload = PayloadCore<'browser-context-payload'> & {
|
|
52
|
+
data: BrowserContextPayloadData;
|
|
53
|
+
};
|
|
54
|
+
export type ChatDraftPayload = PayloadCore<'chat-draft'>;
|
|
55
|
+
export type OpenBrowseAgentPayload = PayloadCore<'open-browse-agent-modal'>;
|
|
56
|
+
export type EditorSuggestionPayload = PayloadCore<'editor-suggestion', {
|
|
57
|
+
mode: 'insert' | 'replace';
|
|
58
|
+
content: string;
|
|
59
|
+
agentId?: string;
|
|
60
|
+
}>;
|
|
61
|
+
export type ChatOpenPayload = PayloadCore<'chat-open', {
|
|
62
|
+
channelId: string;
|
|
63
|
+
agentId?: string;
|
|
64
|
+
}>;
|
|
65
|
+
export type ForgeAppAuthSuccess = PayloadCore<'forge-auth-success'>;
|
|
66
|
+
export type ForgeAppAuthFailure = PayloadCore<'forge-auth-failure', {
|
|
67
|
+
errorMessage: string | undefined;
|
|
68
|
+
}>;
|
|
69
|
+
export type Payload = MessageSendPayload | ChatNewPayload | ChatDraftPayload | EditorContextPayload | ChatOpenPayload | OpenBrowseAgentPayload | EditorSuggestionPayload | BrowserContextPayload | ForgeAppAuthSuccess | ForgeAppAuthFailure;
|
|
70
|
+
export type Callback = (payload: Payload) => void;
|
|
71
|
+
export type TopicEvents = {
|
|
72
|
+
[key in Topic]?: Array<{
|
|
73
|
+
id: string;
|
|
74
|
+
callback: Callback;
|
|
75
|
+
}>;
|
|
76
|
+
};
|
|
77
|
+
export type TopicEventQueue = {
|
|
78
|
+
[key in Topic]?: Payload;
|
|
79
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/rovo-triggers",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Provides various trigger events to drive Rovo Chat functionality, such as a publish-subscribe and URL parameter hooks",
|
|
5
|
+
"author": "Atlassian Pty Ltd",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"registry": "https://registry.npmjs.org/"
|
|
8
|
+
},
|
|
9
|
+
"atlassian": {
|
|
10
|
+
"team": "AI Mate"
|
|
11
|
+
},
|
|
12
|
+
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
13
|
+
"license": "Apache-2.0",
|
|
14
|
+
"main": "dist/cjs/index.js",
|
|
15
|
+
"module": "dist/esm/index.js",
|
|
16
|
+
"module:es2019": "dist/es2019/index.js",
|
|
17
|
+
"types": "dist/types/index.d.ts",
|
|
18
|
+
"typesVersions": {
|
|
19
|
+
">=4.5 <4.9": {
|
|
20
|
+
"*": [
|
|
21
|
+
"dist/types-ts4.5/*",
|
|
22
|
+
"dist/types-ts4.5/index.d.ts"
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"sideEffects": [
|
|
27
|
+
"*.compiled.css"
|
|
28
|
+
],
|
|
29
|
+
"atlaskit:src": "src/index.ts",
|
|
30
|
+
"af:exports": {
|
|
31
|
+
".": "./src/index.ts"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@babel/runtime": "^7.0.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"react": "^16.8.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@af/integration-testing": "*",
|
|
41
|
+
"@af/visual-regression": "*",
|
|
42
|
+
"@atlaskit/primitives": "*",
|
|
43
|
+
"@atlaskit/ssr": "*",
|
|
44
|
+
"@atlaskit/visual-regression": "*",
|
|
45
|
+
"@atlassian/feature-flags-test-utils": "0.2.3",
|
|
46
|
+
"@testing-library/react": "^12.1.5",
|
|
47
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
48
|
+
"react-dom": "^16.8.0",
|
|
49
|
+
"typescript": "~5.4.2",
|
|
50
|
+
"wait-for-expect": "^1.2.0"
|
|
51
|
+
},
|
|
52
|
+
"techstack": {
|
|
53
|
+
"@atlassian/frontend": {
|
|
54
|
+
"code-structure": [
|
|
55
|
+
"tangerine-next"
|
|
56
|
+
],
|
|
57
|
+
"import-structure": [
|
|
58
|
+
"atlassian-conventions"
|
|
59
|
+
],
|
|
60
|
+
"circular-dependencies": [
|
|
61
|
+
"file-and-folder-level"
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
"@repo/internal": {
|
|
65
|
+
"dom-events": "use-bind-event-listener",
|
|
66
|
+
"analytics": [
|
|
67
|
+
"analytics-next"
|
|
68
|
+
],
|
|
69
|
+
"design-tokens": [
|
|
70
|
+
"color"
|
|
71
|
+
],
|
|
72
|
+
"theming": [
|
|
73
|
+
"react-context"
|
|
74
|
+
],
|
|
75
|
+
"ui-components": [
|
|
76
|
+
"lite-mode"
|
|
77
|
+
],
|
|
78
|
+
"deprecation": [
|
|
79
|
+
"no-deprecated-imports"
|
|
80
|
+
],
|
|
81
|
+
"styling": [
|
|
82
|
+
"static",
|
|
83
|
+
"compiled"
|
|
84
|
+
],
|
|
85
|
+
"imports": [
|
|
86
|
+
"import-no-extraneous-disable-for-examples-and-docs"
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|