@ateam-ai-mobile/core 0.1.16 → 0.1.17
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/index.d.mts +68 -1
- package/dist/index.d.ts +68 -1
- package/dist/index.js +65 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +21 -0
- package/src/notifications/api.ts +161 -0
package/dist/index.mjs
CHANGED
|
@@ -229,6 +229,55 @@ async function setDevMode(on) {
|
|
|
229
229
|
return devModeFromCatalog(out);
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
+
// src/notifications/api.ts
|
|
233
|
+
async function callNotifApi(method, params = {}) {
|
|
234
|
+
if (!getToken()) throw new Error("Not authenticated");
|
|
235
|
+
const data = await mcpToolCall("cp.notif_api", { method, params });
|
|
236
|
+
if (data?.error) throw new Error(data.error.message || "Notif API error");
|
|
237
|
+
const r = data?.result;
|
|
238
|
+
if (r?.structuredContent) return r.structuredContent;
|
|
239
|
+
const out = unwrapMcpResult(r);
|
|
240
|
+
if (out && typeof out === "object" && !Array.isArray(out) && "ok" in out) return out;
|
|
241
|
+
if (typeof out === "string") throw new Error(`Notif API returned unparseable text: ${out.slice(0, 80)}`);
|
|
242
|
+
throw new Error("Notif API returned no result payload");
|
|
243
|
+
}
|
|
244
|
+
async function getPrefs() {
|
|
245
|
+
const res = await callNotifApi("getPrefs");
|
|
246
|
+
if (!res.ok || !res.prefs) throw new Error(res.error || "Failed to load prefs");
|
|
247
|
+
return res.prefs;
|
|
248
|
+
}
|
|
249
|
+
async function setPrefs(prefs) {
|
|
250
|
+
const res = await callNotifApi("setPrefs", { prefs });
|
|
251
|
+
if (!res.ok || !res.prefs) throw new Error(res.error || "Failed to save prefs");
|
|
252
|
+
return res.prefs;
|
|
253
|
+
}
|
|
254
|
+
async function linkTelegram(chatId) {
|
|
255
|
+
const res = await callNotifApi("linkTelegram", { chatId });
|
|
256
|
+
if (!res.ok || !res.prefs) throw new Error(res.error || "Failed to link Telegram");
|
|
257
|
+
return res.prefs;
|
|
258
|
+
}
|
|
259
|
+
async function unlinkChannel(channel) {
|
|
260
|
+
const res = await callNotifApi("unlinkChannel", { channel });
|
|
261
|
+
if (!res.ok || !res.prefs) throw new Error(res.error || "Failed to unlink channel");
|
|
262
|
+
return res.prefs;
|
|
263
|
+
}
|
|
264
|
+
async function recentDispatches(limit = 50) {
|
|
265
|
+
const res = await callNotifApi("recentDispatches", { limit });
|
|
266
|
+
return res.rows || [];
|
|
267
|
+
}
|
|
268
|
+
async function getTelegramBotInfo() {
|
|
269
|
+
const res = await callNotifApi("getTelegramBotInfo");
|
|
270
|
+
return res;
|
|
271
|
+
}
|
|
272
|
+
async function registerDevice(token, platform) {
|
|
273
|
+
const res = await callNotifApi("registerDevice", { token, platform });
|
|
274
|
+
return res;
|
|
275
|
+
}
|
|
276
|
+
async function unregisterDevice(token) {
|
|
277
|
+
const res = await callNotifApi("unregisterDevice", { token });
|
|
278
|
+
if (!res.ok) throw new Error(res.error || "Failed to unregister device");
|
|
279
|
+
}
|
|
280
|
+
|
|
232
281
|
// src/session.ts
|
|
233
282
|
function hostOf(u) {
|
|
234
283
|
if (!u) return "";
|
|
@@ -2147,6 +2196,8 @@ export {
|
|
|
2147
2196
|
getConsumerAuthApiUrl,
|
|
2148
2197
|
getCoreApiUrl,
|
|
2149
2198
|
getCoreWsUrl,
|
|
2199
|
+
getPrefs as getNotifPrefs,
|
|
2200
|
+
getTelegramBotInfo as getNotifTelegramBotInfo,
|
|
2150
2201
|
getSession,
|
|
2151
2202
|
getTenant,
|
|
2152
2203
|
getToken,
|
|
@@ -2159,6 +2210,7 @@ export {
|
|
|
2159
2210
|
joinWithGoogle,
|
|
2160
2211
|
linkChannelStart,
|
|
2161
2212
|
linkChannelVerify,
|
|
2213
|
+
linkTelegram as linkNotifTelegram,
|
|
2162
2214
|
listHomeActions,
|
|
2163
2215
|
listMadeForYou,
|
|
2164
2216
|
listMyTenants,
|
|
@@ -2179,20 +2231,25 @@ export {
|
|
|
2179
2231
|
postCommandResult,
|
|
2180
2232
|
previewInvite,
|
|
2181
2233
|
readDevMode,
|
|
2234
|
+
recentDispatches as recentNotifDispatches,
|
|
2182
2235
|
recordEvent,
|
|
2183
2236
|
refreshToken,
|
|
2237
|
+
registerDevice as registerPushDevice,
|
|
2184
2238
|
resolveAdasPhase,
|
|
2185
2239
|
setAcsCacheStorage,
|
|
2186
2240
|
setAcsReachabilityReporter,
|
|
2187
2241
|
setClientDeclarationProvider,
|
|
2188
2242
|
setDevMode,
|
|
2189
2243
|
setHomeActionOrder,
|
|
2244
|
+
setPrefs as setNotifPrefs,
|
|
2190
2245
|
setOrder,
|
|
2191
2246
|
signInWithApple,
|
|
2192
2247
|
signInWithGoogle,
|
|
2193
2248
|
spacing,
|
|
2194
2249
|
switchTenant,
|
|
2195
2250
|
tenantFromToken,
|
|
2251
|
+
unlinkChannel as unlinkNotifChannel,
|
|
2252
|
+
unregisterDevice as unregisterPushDevice,
|
|
2196
2253
|
unwrapMcpResult,
|
|
2197
2254
|
useCapability,
|
|
2198
2255
|
useChatStore,
|