ai-publish-sdk 1.3.0 → 1.4.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/README.md +10 -0
- package/index.d.ts +2 -2
- package/index.js +1 -1
- package/index.mjs +12 -8
- package/lib/functions.d.ts +2 -1
- package/lib/types.d.ts +5 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -76,6 +76,16 @@ interface GenerateMessageOptions {
|
|
|
76
76
|
}
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
+
### getBrandingAssets()
|
|
80
|
+
|
|
81
|
+
Get tenant branding assets for white-label styling.
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
getBrandingAssets(): Promise<BrandingAssets | null>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Returns `BrandingAssets` with fields: `logoUrl`, `darkLogoUrl`, `brandColor` (all `string | null`).
|
|
88
|
+
|
|
79
89
|
### executeScript(code)
|
|
80
90
|
|
|
81
91
|
Execute JavaScript on the host page.
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { generateMessage, getToken, getUserInfo } from './lib/functions';
|
|
1
|
+
export { generateMessage, getBrandingAssets, getToken, getUserInfo } from './lib/functions';
|
|
2
2
|
export { tcp } from './lib/tcp-socket';
|
|
3
3
|
export type { TcpSocket } from './lib/tcp-socket';
|
|
4
4
|
export { setGlobalTimeout, withTimeout } from './lib/rpc-bridge';
|
|
5
|
-
export type { GenerateMessageOptions, GetTokenOptions, GetTokenResult, IntegrationAppName, UserInfo } from './lib/types';
|
|
5
|
+
export type { BrandingAssets, GenerateMessageOptions, GetTokenOptions, GetTokenResult, IntegrationAppName, UserInfo } from './lib/types';
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let u=15e3;const c=new Map;let a=!1;function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let u=15e3;const c=new Map;let a=!1;function d(e){u=e}let i;function m(e,t){i=t;try{return e()}finally{i=void 0}}function f(){a||(a=!0,window.addEventListener("message",e=>{const t=e.data;if(!t?.messageId||!("name"in t))return;const n=c.get(t.messageId);n&&(clearTimeout(n.timer),c.delete(t.messageId),t.error?n.reject(new Error(t.error.message??"RPC error")):n.resolve(t.data))}))}function r(e,t){return f(),new Promise((n,s)=>{const o=crypto.randomUUID(),l=setTimeout(()=>{c.delete(o),s(new Error(`RPC timeout: ${e}`))},i??u);c.set(o,{resolve:n,reject:s,timer:l});const g={action:e,params:t,messageId:o};window.parent.postMessage(g,"*")})}async function y(e,t){return r("generateMessage",[e,t])}async function p(e,t){return r("getToken",[e,t])}async function w(){return r("getUserInfo",[])}async function T(){return r("getBrandingAssets",[])}async function v(e){return r("tcpConnect",[e])}async function I(e,t){return r("tcpSend",[e,t])}async function C(e,t){return r("tcpReceive",[e,t])}async function b(e){return r("tcpClose",[e])}const M={async connect(e,t){const n=await v({host:e,port:t});return n===null?null:{send:async s=>(await I(n,{dataBase64:s}))?.bytesSent??null,receive:async()=>(await C(n))?.data??null,close:()=>b(n)}}};exports.generateMessage=y;exports.getBrandingAssets=T;exports.getToken=p;exports.getUserInfo=w;exports.setGlobalTimeout=d;exports.tcp=M;exports.withTimeout=m;
|
package/index.mjs
CHANGED
|
@@ -13,7 +13,7 @@ function v(e, t) {
|
|
|
13
13
|
a = void 0;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function d() {
|
|
17
17
|
i || (i = !0, window.addEventListener("message", (e) => {
|
|
18
18
|
const t = e.data;
|
|
19
19
|
if (!t?.messageId || !("name" in t)) return;
|
|
@@ -22,7 +22,7 @@ function m() {
|
|
|
22
22
|
}));
|
|
23
23
|
}
|
|
24
24
|
function r(e, t) {
|
|
25
|
-
return
|
|
25
|
+
return d(), new Promise((n, s) => {
|
|
26
26
|
const o = crypto.randomUUID(), l = setTimeout(() => {
|
|
27
27
|
c.delete(o), s(new Error(`RPC timeout: ${e}`));
|
|
28
28
|
}, a ?? u);
|
|
@@ -31,8 +31,8 @@ function r(e, t) {
|
|
|
31
31
|
reject: s,
|
|
32
32
|
timer: l
|
|
33
33
|
});
|
|
34
|
-
const
|
|
35
|
-
window.parent.postMessage(
|
|
34
|
+
const g = { action: e, params: t, messageId: o };
|
|
35
|
+
window.parent.postMessage(g, "*");
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
async function C(e, t) {
|
|
@@ -44,10 +44,13 @@ async function I(e, t) {
|
|
|
44
44
|
async function M() {
|
|
45
45
|
return r("getUserInfo", []);
|
|
46
46
|
}
|
|
47
|
+
async function R() {
|
|
48
|
+
return r("getBrandingAssets", []);
|
|
49
|
+
}
|
|
47
50
|
async function f(e) {
|
|
48
51
|
return r("tcpConnect", [e]);
|
|
49
52
|
}
|
|
50
|
-
async function
|
|
53
|
+
async function m(e, t) {
|
|
51
54
|
return r("tcpSend", [e, t]);
|
|
52
55
|
}
|
|
53
56
|
async function p(e, t) {
|
|
@@ -56,7 +59,7 @@ async function p(e, t) {
|
|
|
56
59
|
async function y(e) {
|
|
57
60
|
return r("tcpClose", [e]);
|
|
58
61
|
}
|
|
59
|
-
const
|
|
62
|
+
const U = {
|
|
60
63
|
/**
|
|
61
64
|
* Opens a TCP connection and returns a `TcpSocket` wrapper.
|
|
62
65
|
*
|
|
@@ -68,7 +71,7 @@ const R = {
|
|
|
68
71
|
async connect(e, t) {
|
|
69
72
|
const n = await f({ host: e, port: t });
|
|
70
73
|
return n === null ? null : {
|
|
71
|
-
send: async (s) => (await
|
|
74
|
+
send: async (s) => (await m(n, { dataBase64: s }))?.bytesSent ?? null,
|
|
72
75
|
receive: async () => (await p(n))?.data ?? null,
|
|
73
76
|
close: () => y(n)
|
|
74
77
|
};
|
|
@@ -76,9 +79,10 @@ const R = {
|
|
|
76
79
|
};
|
|
77
80
|
export {
|
|
78
81
|
C as generateMessage,
|
|
82
|
+
R as getBrandingAssets,
|
|
79
83
|
I as getToken,
|
|
80
84
|
M as getUserInfo,
|
|
81
85
|
T as setGlobalTimeout,
|
|
82
|
-
|
|
86
|
+
U as tcp,
|
|
83
87
|
v as withTimeout
|
|
84
88
|
};
|
package/lib/functions.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { GenerateMessageOptions, GetTokenOptions, GetTokenResult, IntegrationAppName, TcpConnectOptions, TcpConnectionSettings, TcpReceiveOptions, TcpReceiveResult, TcpSendMessage, TcpSendResult, UserInfo } from './types';
|
|
1
|
+
import { BrandingAssets, GenerateMessageOptions, GetTokenOptions, GetTokenResult, IntegrationAppName, TcpConnectOptions, TcpConnectionSettings, TcpReceiveOptions, TcpReceiveResult, TcpSendMessage, TcpSendResult, UserInfo } from './types';
|
|
2
2
|
export declare function generateMessage(prompt: string, options: GenerateMessageOptions): Promise<string | null>;
|
|
3
3
|
export declare function getToken(appName: IntegrationAppName, options?: GetTokenOptions): Promise<GetTokenResult | null>;
|
|
4
4
|
export declare function getUserInfo(): Promise<UserInfo | null>;
|
|
5
|
+
export declare function getBrandingAssets(): Promise<BrandingAssets | null>;
|
|
5
6
|
export declare function executeScript(code: string): Promise<void>;
|
|
6
7
|
export declare function tcpConnect(options: TcpConnectOptions): Promise<TcpConnectionSettings | null>;
|
|
7
8
|
export declare function tcpSend(connection: TcpConnectionSettings, message: TcpSendMessage): Promise<TcpSendResult | null>;
|
package/lib/types.d.ts
CHANGED
|
@@ -21,6 +21,11 @@ export interface UserInfo {
|
|
|
21
21
|
email?: string;
|
|
22
22
|
picture?: string;
|
|
23
23
|
}
|
|
24
|
+
export interface BrandingAssets {
|
|
25
|
+
logoUrl: string | null;
|
|
26
|
+
darkLogoUrl: string | null;
|
|
27
|
+
brandColor: string | null;
|
|
28
|
+
}
|
|
24
29
|
export interface TcpConnectOptions {
|
|
25
30
|
host: string;
|
|
26
31
|
port: number;
|