@otonoma/paracord-panels-interface 0.17.1-rc.12
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/dist/channel.d.ts +14 -0
- package/dist/channel.d.ts.map +1 -0
- package/dist/channel.js +46 -0
- package/dist/client/abstractClient.d.ts +27 -0
- package/dist/client/abstractClient.d.ts.map +1 -0
- package/dist/client/abstractClient.js +22 -0
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +18 -0
- package/dist/client/managedPncpClient.d.ts +38 -0
- package/dist/client/managedPncpClient.d.ts.map +1 -0
- package/dist/client/managedPncpClient.js +156 -0
- package/dist/client/paracordClient.d.ts +28 -0
- package/dist/client/paracordClient.d.ts.map +1 -0
- package/dist/client/paracordClient.js +97 -0
- package/dist/client/pncpClient.d.ts +34 -0
- package/dist/client/pncpClient.d.ts.map +1 -0
- package/dist/client/pncpClient.js +234 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/interface/index.d.ts +43 -0
- package/dist/interface/index.d.ts.map +1 -0
- package/dist/interface/index.js +3 -0
- package/dist/interface/methods.d.ts +98 -0
- package/dist/interface/methods.d.ts.map +1 -0
- package/dist/interface/methods.js +1 -0
- package/package.json +35 -0
- package/src/channel.ts +58 -0
- package/src/client/abstractClient.ts +63 -0
- package/src/client/index.ts +20 -0
- package/src/client/managedPncpClient.ts +195 -0
- package/src/client/paracordClient.ts +149 -0
- package/src/client/pncpClient.ts +304 -0
- package/src/index.ts +2 -0
- package/src/interface/index.ts +74 -0
- package/src/interface/methods.ts +136 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Interface types for communication between a panel and paracord.
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ObservationCallbackObject,
|
|
5
|
+
PncpMessageCallbackObject,
|
|
6
|
+
PncpRequestCallbackObject,
|
|
7
|
+
} from "@otonoma/paranet-client";
|
|
8
|
+
import { MethodCall, MethodReturn } from "./methods";
|
|
9
|
+
|
|
10
|
+
export * from "./methods";
|
|
11
|
+
|
|
12
|
+
export const PARACORD_PANEL_REVISION: number = 1;
|
|
13
|
+
|
|
14
|
+
// Connection request from a panel.
|
|
15
|
+
export interface PanelConnect {
|
|
16
|
+
apiRevision: number;
|
|
17
|
+
panelId: string;
|
|
18
|
+
type: "panelConnect";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Messages sent through the open channel.
|
|
22
|
+
export interface PanelMessage {
|
|
23
|
+
// Current revision in use. Must always match `PARACORD_PANEL_REVISION` of the current version in use.
|
|
24
|
+
apiRevision: number;
|
|
25
|
+
// Unique id (within the context of a paranet) for the panel issuing the message.
|
|
26
|
+
panelId: string;
|
|
27
|
+
// message ID associated with this message. Only unique within the context of a given stream.
|
|
28
|
+
// This ID is only used for callback association.
|
|
29
|
+
messageId?: number;
|
|
30
|
+
body: MessageBody;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type MessageBody =
|
|
34
|
+
| PanelMethodCall
|
|
35
|
+
| PanelMethodReturnMessage
|
|
36
|
+
| PncpMessageBody
|
|
37
|
+
| PanelParacordError;
|
|
38
|
+
|
|
39
|
+
export interface PanelParacordError {
|
|
40
|
+
type: "paracordError";
|
|
41
|
+
error: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Message sent from a panel to paracord.
|
|
45
|
+
export interface PanelMethodCall {
|
|
46
|
+
type: "call";
|
|
47
|
+
body: MethodCall;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface PanelMethodReturnMessage {
|
|
51
|
+
type: "callReturn";
|
|
52
|
+
body: MethodReturn;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type PncpMessageBody =
|
|
56
|
+
| PncpSkillCallback
|
|
57
|
+
| PncpMessageCallback
|
|
58
|
+
| ObservationCallback;
|
|
59
|
+
|
|
60
|
+
export interface PncpSkillCallback {
|
|
61
|
+
type: "pncpSkillCb";
|
|
62
|
+
body: PncpRequestCallbackObject;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface PncpMessageCallback {
|
|
66
|
+
type: "pncpMessageCb";
|
|
67
|
+
body: PncpMessageCallbackObject;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface ObservationCallback {
|
|
71
|
+
type: "pncpObservationCb";
|
|
72
|
+
body: ObservationCallbackObject;
|
|
73
|
+
callback?: any;
|
|
74
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { ConversationId, DocumentArgs, DocumentInfo, ObservationMessageFilter, PncpMessageObject, SkillRequest } from "@otonoma/paranet-client";
|
|
2
|
+
|
|
3
|
+
// Method calls all must set `method: ""` and `args: ...`.
|
|
4
|
+
export type MethodCall =
|
|
5
|
+
| PncpRequestCall
|
|
6
|
+
| PncpResponseCall
|
|
7
|
+
| PncpMessageCall
|
|
8
|
+
| RegisterSkillCallbackCall
|
|
9
|
+
| RegisterObserverCallbackCall
|
|
10
|
+
| UnregisterObserverCallbackCall
|
|
11
|
+
| UploadDocumentCall
|
|
12
|
+
| FetchDocumentCall
|
|
13
|
+
| GraphqlCall;
|
|
14
|
+
|
|
15
|
+
// Method call returns.
|
|
16
|
+
export type MethodReturn = PncpCallResponse | GraphqlCallResponse | UploadDocumentResponse | FetchDocumentResponse | RegisterObserverResponse | VoidReturn;
|
|
17
|
+
|
|
18
|
+
export type PncpRequestCall = {
|
|
19
|
+
method: "pncpRequest";
|
|
20
|
+
args: SkillRequest;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type PncpResponseCall = {
|
|
24
|
+
method: "pncpResponse";
|
|
25
|
+
args: PncpMessageResponse;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type PncpMessageCall = {
|
|
29
|
+
method: "pncpMessage";
|
|
30
|
+
args: PncpMessageObject;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type RegisterSkillCallbackCall = {
|
|
34
|
+
method: "registerSkillCallback";
|
|
35
|
+
args: RegisterSkillCallback;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type RegisterObserverCallbackCall = {
|
|
39
|
+
method: "registerObserverCallback";
|
|
40
|
+
args: RegisterObserverCallback;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type RegisterObserverResponse = {
|
|
44
|
+
type: "registerObserverCallback";
|
|
45
|
+
args: {
|
|
46
|
+
key: string;
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type UnregisterObserverCallbackCall = {
|
|
51
|
+
method: "unregisterObserverCallback";
|
|
52
|
+
args: {
|
|
53
|
+
key: string;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type UploadDocumentCall = {
|
|
58
|
+
method: "uploadDocumentCall";
|
|
59
|
+
args: UploadDocumentArgs;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export type UploadDocumentArgs = {
|
|
63
|
+
args?: DocumentArgs;
|
|
64
|
+
// `any` is too open, but if we run into specific issues we can deal with it.
|
|
65
|
+
// Files themselves
|
|
66
|
+
body: File | any;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export type UploadDocumentResponse = {
|
|
70
|
+
type: "uploadDocument";
|
|
71
|
+
error?: string;
|
|
72
|
+
body?: DocumentInfo;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export type FetchDocumentCall = {
|
|
76
|
+
method: "fetchDocumentCall";
|
|
77
|
+
args: DocumentArgs;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export type FetchDocumentResponse = {
|
|
81
|
+
type: "fetchDocument";
|
|
82
|
+
stream?: ReadableStream,
|
|
83
|
+
error?: any;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export type GraphqlCall = {
|
|
87
|
+
method: "graphqlCall";
|
|
88
|
+
args: GraphqlCallArgs;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export type GraphqlCallArgs = {
|
|
92
|
+
// This should work to provide `gql""` strings given the `any` input.
|
|
93
|
+
query: string | any;
|
|
94
|
+
variables?: any;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export type RegisterSkillCallback = {
|
|
98
|
+
subject: string;
|
|
99
|
+
action: string;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export type RegisterObserverCallback = {
|
|
103
|
+
subject: string;
|
|
104
|
+
action: string;
|
|
105
|
+
offset?: number;
|
|
106
|
+
callback?: any;
|
|
107
|
+
filters?: ObservationMessageFilter[];
|
|
108
|
+
conversationId?: string;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
// Response returned from the paranet broker.
|
|
113
|
+
export interface PncpCallResponse {
|
|
114
|
+
type: "response";
|
|
115
|
+
conversationId?: ConversationId;
|
|
116
|
+
messageId: string;
|
|
117
|
+
date?: Date;
|
|
118
|
+
actorId?: string;
|
|
119
|
+
actorVersion?: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Sends a response as a PncpMessage.
|
|
123
|
+
export interface PncpMessageResponse {
|
|
124
|
+
conversation: string;
|
|
125
|
+
data: any;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface GraphqlCallResponse {
|
|
129
|
+
type: "graphqlCall";
|
|
130
|
+
data: any;
|
|
131
|
+
error?: any;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface VoidReturn {
|
|
135
|
+
type: "void";
|
|
136
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
// "skipLibCheck": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"allowSyntheticDefaultImports": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"noFallthroughCasesInSwitch": true,
|
|
12
|
+
"module": "esnext",
|
|
13
|
+
"moduleResolution": "node",
|
|
14
|
+
"resolveJsonModule": true,
|
|
15
|
+
"isolatedModules": true,
|
|
16
|
+
"declaration": true,
|
|
17
|
+
"declarationMap": true,
|
|
18
|
+
"outDir": "./dist"
|
|
19
|
+
},
|
|
20
|
+
"include": ["src/**/*"]
|
|
21
|
+
}
|