@openfin/cloud-api 0.0.1-alpha.fbe4f15 → 0.0.1-alpha.fffeb9a
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.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +148 -7
- package/dist/index.d.ts +148 -7
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +19 -18
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var o="@openfin/cloud-api";
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var v=Object.defineProperty;var E=(n,o)=>{for(var e in o)v(n,e,{get:o[e],enumerable:!0})};var t="@openfin/cloud-api";async function r(){try{return await window.fin.View.getCurrentSync().getInfo(),!0}catch (e2){return!1}}function y(n){if(n.name.startsWith("internal-generated"))throw new Error("Cannot extract app UUID from identity");return/\/[\d,a-z-]{36}$/.test(n.name)?n.name.split("/")[0]||"":n.name}var c="@openfin/cloud-api";function F(){return`${window.fin.me.uuid}-cloud-api-notifications`}var d=null;async function U(){return d||(d=P()),d}async function P(){if(!window.fin)throw new Error(`\`${c}\`: \`getNotificationsClient\` cannot be used in a non-OpenFin environment`);if(await r()===!1)throw new Error(`${c}: \`getNotificationsClient\` cannot be used in a non-OpenFin environment`);y(window.fin.me);let n=await S();console.log(n),n.register("openfin-cloud-event",e=>{for(let i of _nullishCoalesce(o.get(e.type), () => ([])))typeof e.payload.timestamp=="string"&&(e.payload.timestamp=new Date(e.payload.timestamp)),i(e.payload)});let o=new Map;return{addEventListener:(e,i)=>{let a=o.get(e)||new Set;a.add(i),o.set(e,a)},removeEventListener:(e,i)=>{let a=o.get(e);if(!a){console.warn(`\`${c}\`: Listener was not found for event. Did you pass a function directly instead of a reference or forget to add the listener?`,e);return}a.delete(i)===!1&&console.warn(`\`${c}\`: Listener was not found for event. Did you pass a function directly instead of a reference?`,e)},update:async e=>(await n.dispatch("openfin-cloud-update-notification",{version:1,payload:{notification:e}})).payload.response,clear:async e=>(await n.dispatch("openfin-cloud-clear-notification",{version:1,payload:{notificationId:e}})).payload.response,createNotification:async e=>(e.id&&console.warn(`\`${c}\`: The \`id\` property is not supported and will be ignored. If you need to use the \`id\` property, you should use the \`id\` property of the returned notification object.`),(await n.dispatch("openfin-cloud-create-notification",{version:1,payload:{notification:{...e,id:void 0}}})).payload.response)}}var u=null;async function S(){return u||(u=$()),u}async function $(){let n=await window.fin.InterApplicationBus.Channel.connect(F());return n.onDisconnection(o=>{console.warn(`\`${c}\`: Channel Disconnected from`,o,"Reconnecting..."),u=null}),n}var f;function b(){return`${window.fin.me.uuid}-client-api`}async function s(){return f||(f=window.fin.InterApplicationBus.Channel.connect(b())),f}async function q(){if(!window.fin)throw new Error(`\`${t}\`: \`getAppSettings\` cannot be used in a non-OpenFin environment`);if(await r()===!1)throw new Error(`${t}: \`getAppSettings\` cannot be used in a non-OpenFin environment`);return(await s()).dispatch("get-settings")}async function D(){if(!window.fin)throw new Error(`\`${t}\`: \`getAppUserSettings\` cannot be used in a non-OpenFin environment`);if(await r()===!1)throw new Error(`${t}: \`getAppUserSettings\` cannot be used in a non-OpenFin environment`);return(await s()).dispatch("get-user-settings")}async function V(n){if(!window.fin)throw new Error(`\`${t}\`: \`setAppUserSettings\` cannot be used in a non-OpenFin environment`);if(await r()===!1)throw new Error(`${t}: \`setAppUserSettings\` cannot be used in a non-OpenFin environment`);return(await s()).dispatch("set-user-settings",n)}async function B(){if(!window.fin)throw new Error(`\`${t}\`: \`getAppUserPermissions\` cannot be used in a non-OpenFin environment`);if(await r()===!1)throw new Error(`${t}: \`getAppUserPermissions\` cannot be used in a non-OpenFin environment`);return(await s()).dispatch("get-user-permissions")}async function G(n,o){if(!window.fin)throw new Error(`\`${t}\`: \`launchContent\` cannot be used in a non-OpenFin environment`);if(await r()===!1)throw new Error(`${t}: \`launchContent\` cannot be used in a outside of an OpenFin View context`);let e=await s();try{await e.dispatch("launch-content",{id:n,options:o})}catch(i){switch(i instanceof Error?i.message:String(i)){case"UnableToLookup":throw new Error(`${t}: \`launchContent\` was unable to lookup content with id: ${n}`);case"UnableToLaunch":throw new Error(`${t}: \`launchContent\` was unable to launch content with id: ${n}`);case"NoContentFound":throw new Error(`${t}: \`launchContent\` did not find content with id: ${n}`);default:throw new Error(`${t}: \`launchContent\` was unable to look up or launch content with id: ${n} or the content did not exist.`)}}}async function K(n){if(!window.fin)throw new Error(`\`${t}\`: \`launchSupertab\` cannot be used in a non-OpenFin environment`);if(await r()===!1)throw new Error(`${t}: \`launchSupertab\` cannot be used in a outside of an OpenFin View context`);let o=await s();try{await o.dispatch("launch-supertab",{id:n})}catch(e){switch(e instanceof Error?e.message:String(e)){case"UnableToLookup":throw new Error(`${t}: \`launchSupertab\` was unable to lookup content with id: ${n}`);case"UnableToLaunch":throw new Error(`${t}: \`launchSupertab\` was unable to launch content with id: ${n}`);case"NoContentFound":throw new Error(`${t}: \`launchSupertab\` did not find content with id: ${n}`);default:throw new Error(`${t}: \`launchSupertab\` was unable to look up or launch content with id: ${n} or the content did not exist.`)}}}async function j(n){if(!window.fin)throw new Error(`\`${t}\`: \`launchWorkspace\` cannot be used in a non-OpenFin environment`);if(await r()===!1)throw new Error(`${t}: \`launchWorkspace\` cannot be used in a outside of an OpenFin View context`);let o=await s();try{await o.dispatch("launch-workspace",{id:n})}catch(e){switch(e instanceof Error?e.message:String(e)){case"UnableToLookup":throw new Error(`${t}: \`launchWorkspace\` was unable to lookup content with id: ${n}`);case"UnableToLaunch":throw new Error(`${t}: \`launchWorkspace\` was unable to launch content with id: ${n}`);case"NoContentFound":throw new Error(`${t}: \`launchWorkspace\` did not find content with id: ${n}`);default:throw new Error(`${t}: \`launchWorkspace\` was unable to look up or launch content with id: ${n} or the content did not exist.`)}}}var g={};E(g,{register:()=>k});var A="get-results",R="handle-action",T={id:"",onClose:function(n){console.warn("Function not implemented.")},removeListener:function(n){console.warn("Function not implemented.")},query:""},O={open:function(){console.warn("Function not implemented.")},close:function(){console.warn("Function not implemented.")},respond:function(n){console.warn("Function not implemented.")},revoke:function(...n){console.warn("Function not implemented.")},updateContext:function(n){console.warn("Function not implemented.")}},k=async n=>{let o=await window.fin.me.getOptions(),{configuration:e,id:i,name:a}=o.customData,w=`search-provider-${o.customData.id}`;console.debug(`creating channel ${w}`);let h=await window.fin.InterApplicationBus.Channel.create(w);return h.register(R,async l=>{let{searchResult:p,actionId:m,viewIdentity:C}=l,N={action:{name:m,trigger:"user-action"},dispatcherIdentity:C,key:"",title:p.title,actions:[],data:p};return await n.onAction(N)}),h.register(A,async l=>{let p=Object.assign({},T,l);return(await n.onSearch(p,O)).results}),{configData:e,hideWindow:async function(){console.warn("Function not implemented.")},id:i,isReady:async function(l){console.warn("Function not implemented.")},name:a,showWindow:async function(){console.warn("Function not implemented.")}}};exports.Search = g; exports.getAppSettings = q; exports.getAppUserPermissions = B; exports.getAppUserSettings = D; exports.getNotificationsClient = U; exports.launchContent = G; exports.launchSupertab = K; exports.launchWorkspace = j; exports.setAppUserSettings = V;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["PACKAGE_NAME","getChannelName","isInViewContext","extractAppUuidFromIdentity","identity","notificationsClientPromise","getNotificationsClient","getNotificationsClientInternal","channelPromise","getChannelClient","message","listener","eventListeners","eventName","listeners","options","notificationId","channelClientPromise","getChannelClientInternal","channel"],"mappings":"AAMA,IAAMA,EAAe,qBAmBrB,SAASC,GAAiB,CACtB,MAAO,GAAG,OAAO,IAAI,GAAG,IAAI,0BAChC,CAEA,eAAeC,GAAoC,CAC/C,G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a,CACJ,EACA,MACJ,CAEIC,EAAU,OAAOH,CAAmC,IAAM,IAC1D,QAAQ,KAAK,KAAKX,CAAY,iGAAkGa,CAAS,CAEjJ,EACA,OAAQ,MAAOE,IACM,MAAMP,EAAe,SAAS,oCAAqC,CAChF,QAAS,EACT,QAAS,CACL,aAAcO,CAClB,CACJ,CAAC,GACe,QAAQ,SAE5B,MAAO,MAAOC,IACO,MAAMR,EAAe,SAAS,mCAAoC,CAC/E,QAAS,EACT,QAAS,CACL,eAAAQ,CACJ,CACJ,CAAC,GACe,QAAQ,SAE5B,mBAAoB,MAChBD,IAEIA,EAAQ,IACR,QAAQ,KACJ,KAAKf,CAAY,+KACrB,GAEa,MAAMQ,EAAe,SAAS,oCAAqC,CAChF,QAAS,EACT,QAAS,CACL,aAAc,CAAE,GAAGO,EAAS,GAAI,MAAU,CAC9C,CACJ,CAAC,GACe,QAAQ,SAEhC,CACJ,CAEA,IAAIE,EAA6D,KAEjE,eAAeR,GAAkD,CAC7D,OAAKQ,IACDA,EAAuBC,EAAyB,GAG7CD,CACX,CAEA,eAAeC,GAA0D,CACrE,IAAMC,EAAW,MAAM,OAAO,IAAI,oBAAoB,QAAQ,QAAQlB,EAAe,CAAC,EAEtF,OAAAkB,EAAQ,gBAAiBf,GAAa,CAClC,QAAQ,KAAK,KAAKJ,CAAY,gCAAiCI,EAAU,iBAAiB,EAC1Fa,EAAuB,IAC3B,CAAC,EAEME,CACX","sourcesContent":["// eslint-disable-next-line check-file/no-index\nimport type OpenFin from '@openfin/core';\nimport type * as NotificationsTypes from 'openfin-notifications';\n\nimport type { FlannelChannelClient, NotificationEventsMap, NotificationsClient } from './types';\n\nconst PACKAGE_NAME = '@openfin/cloud-api';\n\nexport type {\n FlannelChannelProvider as __INTERNAL_FlannelChannelProvider,\n FlannelCreateNotificationRequest as __INTERNAL_FlannelCreateNotificationRequest,\n FlannelCreateNotificationResponse as __INTERNAL_FlannelCreateNotificationResponse,\n FlannelUpdateNotificationRequest as __INTERNAL_FlannelUpdateNotificationRequest,\n FlannelUpdateNotificationResponse as __INTERNAL_FlannelUpdateNotificationResponse,\n FlannelClearNotificationRequest as __INTERNAL_FlannelClearNotificationRequest,\n FlannelClearNotificationResponse as __INTERNAL_FlannelClearNotificationResponse,\n} from './types';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface Window {\n fin: typeof import('@openfin/core').fin;\n }\n}\n\nfunction getChannelName() {\n return `${window.fin.me.uuid}-cloud-api-notifications`;\n}\n\nasync function isInViewContext(): Promise<boolean> {\n try {\n await window.fin.View.getCurrentSync().getInfo();\n return true;\n } catch {\n return false;\n }\n}\n\nfunction extractAppUuidFromIdentity(identity: OpenFin.Identity): string {\n if (identity.name.startsWith('internal-generated')) {\n throw new Error('Cannot extract app UUID from identity');\n }\n // <uuid>/<name>\n if (/\\/[\\d,a-z-]{36}$/.test(identity.name)) {\n return identity.name.split('/')[0] || '';\n }\n\n return identity.name;\n}\n\nlet notificationsClientPromise: Promise<NotificationsClient> | null = null;\n\n/**\n * @returns A client for interacting with the OpenFin Notifications service\n *\n * @throws {Error} If the function is called outside of an OpenFin environment\n * @throws {Error} If the function is called outside of an OpenFin View context\n * @throws {Error} If the app UUID cannot be extracted from the current context\n *\n * @example **Basic Usage** Creating a notification, updating it and then clearing it\n * ```ts\n * const notificationsClient = await getNotificationsClient();\n *\n * const notification = await notificationsClient.createNotification({\n * title: 'Hello, World!',\n * body: 'This is a notification from the OpenFin Cloud API',\n * });\n *\n * // Use the `id` from the returned notification to interact with it\n * console.log(notification.id);\n *\n * // Update the notification\n * await notificationsClient.update({\n * id: notification.id,\n * body: 'This is a notification from the OpenFin Cloud API, that has been updated!',\n * })\n *\n * // Clear the notification\n * await notificationsClient.clear(notification.id);\n * ```\n *\n * @example **Advanced Usage** Listening for events\n * ```ts\n * const notificationsClient = await getNotificationsClient();\n *\n * // create the notification\n * const notification = await notificationsClient.createNotification({\n * title: `${window.fin.me.identity.name} Hello, World!`,\n * body: `This is a notification from the cloud API example created at ${new Date().toLocaleTimeString()}`,\n * buttons: [\n * {\n * title: 'Acknowledge',\n * },\n * ],\n * });\n *\n * notificationsClient.addEventListener('notification-action', (event) => {\n * console.log('Notification action:', event);\n * });\n * ```\n */\nasync function getNotificationsClient(): Promise<NotificationsClient> {\n if (!notificationsClientPromise) {\n notificationsClientPromise = getNotificationsClientInternal();\n }\n\n return notificationsClientPromise;\n}\n\nasync function getNotificationsClientInternal(): Promise<NotificationsClient> {\n if (!window.fin) {\n throw new Error(`\\`${PACKAGE_NAME}\\`: \\`getNotificationsClient\\` cannot be used in a non-OpenFin environment`);\n }\n\n if ((await isInViewContext()) === false) {\n throw new Error(`${PACKAGE_NAME}: \\`getNotificationsClient\\` cannot be used in a non-OpenFin environment`);\n }\n\n extractAppUuidFromIdentity(window.fin.me);\n\n const channelPromise = await getChannelClient();\n console.log(channelPromise);\n\n channelPromise.register('openfin-cloud-event', (message) => {\n for (const listener of eventListeners.get(message.type) ?? []) {\n // `Date` is serialized as a string, so we need to convert it back\n if (typeof message.payload.timestamp === 'string') {\n message.payload.timestamp = new Date(message.payload.timestamp);\n }\n\n listener(message.payload as never);\n }\n });\n\n const eventListeners = new Map<keyof NotificationEventsMap, Set<NotificationEventsMap[keyof NotificationEventsMap]>>();\n\n return {\n addEventListener: <T extends keyof NotificationEventsMap>(eventName: T, listener: NotificationEventsMap[T]) => {\n const listeners = eventListeners.get(eventName) || new Set();\n listeners.add(listener);\n eventListeners.set(eventName, listeners);\n },\n removeEventListener: <T extends keyof NotificationEventsMap>(eventName: T, listener: NotificationEventsMap[T]) => {\n const listeners = eventListeners.get(eventName);\n if (!listeners) {\n console.warn(\n `\\`${PACKAGE_NAME}\\`: Listener was not found for event. Did you pass a function directly instead of a reference or forget to add the listener?`,\n eventName,\n );\n return;\n }\n\n if (listeners.delete(listener as (args: unknown) => void) === false) {\n console.warn(`\\`${PACKAGE_NAME}\\`: Listener was not found for event. Did you pass a function directly instead of a reference?`, eventName);\n }\n },\n update: async (options: Parameters<typeof NotificationsTypes.update>[0]): ReturnType<typeof NotificationsTypes.update> => {\n const response = await channelPromise.dispatch('openfin-cloud-update-notification', {\n version: 1,\n payload: {\n notification: options,\n },\n });\n return response.payload.response;\n },\n clear: async (notificationId: Parameters<typeof NotificationsTypes.clear>[0]): ReturnType<typeof NotificationsTypes.clear> => {\n const response = await channelPromise.dispatch('openfin-cloud-clear-notification', {\n version: 1,\n payload: {\n notificationId,\n },\n });\n return response.payload.response;\n },\n createNotification: async (\n options: NotificationsTypes.NotificationOptions,\n ): Promise<NotificationsTypes.Notification<NotificationsTypes.NotificationOptions>> => {\n if (options.id) {\n console.warn(\n `\\`${PACKAGE_NAME}\\`: The \\`id\\` property is not supported and will be ignored. If you need to use the \\`id\\` property, you should use the \\`id\\` property of the returned notification object.`,\n );\n }\n const response = await channelPromise.dispatch('openfin-cloud-create-notification', {\n version: 1,\n payload: {\n notification: { ...options, id: undefined },\n },\n });\n return response.payload.response;\n },\n };\n}\n\nlet channelClientPromise: Promise<FlannelChannelClient> | null = null;\n\nasync function getChannelClient(): Promise<FlannelChannelClient> {\n if (!channelClientPromise) {\n channelClientPromise = getChannelClientInternal();\n }\n\n return channelClientPromise;\n}\n\nasync function getChannelClientInternal(): Promise<FlannelChannelClient> {\n const channel = (await window.fin.InterApplicationBus.Channel.connect(getChannelName())) as FlannelChannelClient;\n\n channel.onDisconnection((identity) => {\n console.warn(`\\`${PACKAGE_NAME}\\`: Channel Disconnected from`, identity, 'Reconnecting...');\n channelClientPromise = null;\n });\n\n return channel;\n}\n\nexport { getNotificationsClient };\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/openfin-direct/openfin-direct/packages/cloud-api/dist/index.cjs","../src/utils.ts","../src/notifications.ts"],"names":["PACKAGE_NAME","isInViewContext","extractAppUuidFromIdentity","identity","getChannelName"],"mappings":"AAAA,iLAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CCElF,IAAMA,CAAAA,CAAe,oBAAA,CAE5B,MAAA,SAAsBC,CAAAA,CAAAA,CAAoC,CACtD,GAAI,CACA,OAAA,MAAM,MAAA,CAAO,GAAA,CAAI,IAAA,CAAK,cAAA,CAAe,CAAA,CAAE,OAAA,CAAQ,CAAA,CACxC,CAAA,CACX,CAAA,UAAQ,CACJ,MAAO,CAAA,CACX,CACJ,CAEO,SAASC,CAAAA,CAA2BC,CAAAA,CAAoC,CAC3E,EAAA,CAAIA,CAAAA,CAAS,IAAA,CAAK,UAAA,CAAW,oBAAoB,CAAA,CAC7C,MAAM,IAAI,KAAA,CAAM,uCAAuC,CAAA,CAG3D,MAAI,kBAAA,CAAmB,IAAA,CAAKA,CAAAA,CAAS,IAAI,CAAA,CAC9BA,CAAAA,CAAS,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,CAAA,EAAK,EAAA,CAGnCA,CAAAA,CAAS,IACpB,CCjBA,IAAMH,CAAAA,CAAe,oBAAA,CAYrB,SAASI,CAAAA,CAAAA,CAAiB,CACtB,MAAO,CAAA,EAAA","file":"/home/runner/work/openfin-direct/openfin-direct/packages/cloud-api/dist/index.cjs","sourcesContent":[null,"import type OpenFin from '@openfin/core';\n\nexport const PACKAGE_NAME = '@openfin/cloud-api';\n\nexport async function isInViewContext(): Promise<boolean> {\n try {\n await window.fin.View.getCurrentSync().getInfo();\n return true;\n } catch {\n return false;\n }\n}\n\nexport function extractAppUuidFromIdentity(identity: OpenFin.Identity): string {\n if (identity.name.startsWith('internal-generated')) {\n throw new Error('Cannot extract app UUID from identity');\n }\n // <uuid>/<name>\n if (/\\/[\\d,a-z-]{36}$/.test(identity.name)) {\n return identity.name.split('/')[0] || '';\n }\n\n return identity.name;\n}\n","// eslint-disable-next-line check-file/no-index\nimport type * as NotificationsTypes from '@openfin/workspace/notifications';\n\nimport type { FlannelChannelClient, NotificationEventsMap, NotificationsClient } from './types';\nimport { extractAppUuidFromIdentity, isInViewContext } from './utils';\n\nconst PACKAGE_NAME = '@openfin/cloud-api';\n\nexport type {\n FlannelChannelProvider as __INTERNAL_FlannelChannelProvider,\n FlannelCreateNotificationRequest as __INTERNAL_FlannelCreateNotificationRequest,\n FlannelCreateNotificationResponse as __INTERNAL_FlannelCreateNotificationResponse,\n FlannelUpdateNotificationRequest as __INTERNAL_FlannelUpdateNotificationRequest,\n FlannelUpdateNotificationResponse as __INTERNAL_FlannelUpdateNotificationResponse,\n FlannelClearNotificationRequest as __INTERNAL_FlannelClearNotificationRequest,\n FlannelClearNotificationResponse as __INTERNAL_FlannelClearNotificationResponse,\n} from './types';\n\nfunction getChannelName() {\n return `${window.fin.me.uuid}-cloud-api-notifications`;\n}\n\nlet notificationsClientPromise: Promise<NotificationsClient> | null = null;\n\n/**\n * @returns A client for interacting with the OpenFin Notifications service\n *\n * @throws {Error} If the function is called outside of an OpenFin environment\n * @throws {Error} If the function is called outside of an OpenFin View context\n * @throws {Error} If the app UUID cannot be extracted from the current context\n *\n * @example **Basic Usage** Creating a notification, updating it and then clearing it\n * ```ts\n * const notificationsClient = await getNotificationsClient();\n *\n * const notification = await notificationsClient.createNotification({\n * title: 'Hello, World!',\n * body: 'This is a notification from the OpenFin Cloud API',\n * });\n *\n * // Use the `id` from the returned notification to interact with it\n * console.log(notification.id);\n *\n * // Update the notification\n * await notificationsClient.update({\n * id: notification.id,\n * body: 'This is a notification from the OpenFin Cloud API, that has been updated!',\n * })\n *\n * // Clear the notification\n * await notificationsClient.clear(notification.id);\n * ```\n *\n * @example **Advanced Usage** Listening for events\n * ```ts\n * const notificationsClient = await getNotificationsClient();\n *\n * // create the notification\n * const notification = await notificationsClient.createNotification({\n * title: `${window.fin.me.identity.name} Hello, World!`,\n * body: `This is a notification from the cloud API example created at ${new Date().toLocaleTimeString()}`,\n * buttons: [\n * {\n * title: 'Acknowledge',\n * },\n * ],\n * });\n *\n * notificationsClient.addEventListener('notification-action', (event) => {\n * console.log('Notification action:', event);\n * });\n * ```\n */\nasync function getNotificationsClient(): Promise<NotificationsClient> {\n if (!notificationsClientPromise) {\n notificationsClientPromise = getNotificationsClientInternal();\n }\n\n return notificationsClientPromise;\n}\n\nasync function getNotificationsClientInternal(): Promise<NotificationsClient> {\n if (!window.fin) {\n throw new Error(`\\`${PACKAGE_NAME}\\`: \\`getNotificationsClient\\` cannot be used in a non-OpenFin environment`);\n }\n\n if ((await isInViewContext()) === false) {\n throw new Error(`${PACKAGE_NAME}: \\`getNotificationsClient\\` cannot be used in a non-OpenFin environment`);\n }\n\n extractAppUuidFromIdentity(window.fin.me);\n\n const channelPromise = await getChannelClient();\n console.log(channelPromise);\n\n channelPromise.register('openfin-cloud-event', (message) => {\n for (const listener of eventListeners.get(message.type) ?? []) {\n // `Date` is serialized as a string, so we need to convert it back\n if (typeof message.payload.timestamp === 'string') {\n message.payload.timestamp = new Date(message.payload.timestamp);\n }\n\n listener(message.payload as never);\n }\n });\n\n const eventListeners = new Map<keyof NotificationEventsMap, Set<NotificationEventsMap[keyof NotificationEventsMap]>>();\n\n return {\n addEventListener: <T extends keyof NotificationEventsMap>(eventName: T, listener: NotificationEventsMap[T]) => {\n const listeners = eventListeners.get(eventName) || new Set();\n listeners.add(listener);\n eventListeners.set(eventName, listeners);\n },\n removeEventListener: <T extends keyof NotificationEventsMap>(eventName: T, listener: NotificationEventsMap[T]) => {\n const listeners = eventListeners.get(eventName);\n if (!listeners) {\n console.warn(\n `\\`${PACKAGE_NAME}\\`: Listener was not found for event. Did you pass a function directly instead of a reference or forget to add the listener?`,\n eventName,\n );\n return;\n }\n\n if (listeners.delete(listener as (args: unknown) => void) === false) {\n console.warn(`\\`${PACKAGE_NAME}\\`: Listener was not found for event. Did you pass a function directly instead of a reference?`, eventName);\n }\n },\n update: async (options: Parameters<typeof NotificationsTypes.update>[0]): ReturnType<typeof NotificationsTypes.update> => {\n const response = await channelPromise.dispatch('openfin-cloud-update-notification', {\n version: 1,\n payload: {\n notification: options,\n },\n });\n return response.payload.response;\n },\n clear: async (notificationId: Parameters<typeof NotificationsTypes.clear>[0]): ReturnType<typeof NotificationsTypes.clear> => {\n const response = await channelPromise.dispatch('openfin-cloud-clear-notification', {\n version: 1,\n payload: {\n notificationId,\n },\n });\n return response.payload.response;\n },\n createNotification: async (\n options: NotificationsTypes.NotificationOptions,\n ): Promise<NotificationsTypes.Notification<NotificationsTypes.NotificationOptions>> => {\n if (options.id) {\n console.warn(\n `\\`${PACKAGE_NAME}\\`: The \\`id\\` property is not supported and will be ignored. If you need to use the \\`id\\` property, you should use the \\`id\\` property of the returned notification object.`,\n );\n }\n const response = await channelPromise.dispatch('openfin-cloud-create-notification', {\n version: 1,\n payload: {\n notification: { ...options, id: undefined },\n },\n });\n return response.payload.response;\n },\n };\n}\n\nlet channelClientPromise: Promise<FlannelChannelClient> | null = null;\n\nasync function getChannelClient(): Promise<FlannelChannelClient> {\n if (!channelClientPromise) {\n channelClientPromise = getChannelClientInternal();\n }\n\n return channelClientPromise;\n}\n\nasync function getChannelClientInternal(): Promise<FlannelChannelClient> {\n const channel = (await window.fin.InterApplicationBus.Channel.connect(getChannelName())) as FlannelChannelClient;\n\n channel.onDisconnection((identity) => {\n console.warn(`\\`${PACKAGE_NAME}\\`: Channel Disconnected from`, identity, 'Reconnecting...');\n channelClientPromise = null;\n });\n\n return channel;\n}\n\nexport { getNotificationsClient };\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as OpenFin from '@openfin/core';
|
|
2
2
|
import OpenFin__default from '@openfin/core';
|
|
3
|
-
import * as NotificationsTypes from 'openfin
|
|
3
|
+
import * as NotificationsTypes from '@openfin/workspace/notifications';
|
|
4
|
+
import { CLIDispatchedSearchResult, CLISearchListenerRequest, CLISearchListenerResponse, CLISearchResponse, SearchResult as SearchResult$1 } from '@openfin/workspace';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* NotificationsClient is a client for accessing and interacting with the Notifications your application has created.
|
|
@@ -152,11 +153,6 @@ type FlannelChannelProvider = {
|
|
|
152
153
|
register: <T extends keyof FlannelProvider>(action: T, handler: (payload: Parameters<FlannelProvider[T]>[0], id: OpenFin__default.ProviderIdentity | OpenFin__default.ClientIdentity) => ReturnType<FlannelProvider[T]>) => boolean;
|
|
153
154
|
} & Omit<OpenFin__default.ChannelProvider, 'dispatch' | 'register'>;
|
|
154
155
|
|
|
155
|
-
declare global {
|
|
156
|
-
interface Window {
|
|
157
|
-
fin: typeof OpenFin.fin;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
156
|
/**
|
|
161
157
|
* @returns A client for interacting with the OpenFin Notifications service
|
|
162
158
|
*
|
|
@@ -208,4 +204,149 @@ declare global {
|
|
|
208
204
|
*/
|
|
209
205
|
declare function getNotificationsClient(): Promise<NotificationsClient>;
|
|
210
206
|
|
|
211
|
-
|
|
207
|
+
/**
|
|
208
|
+
* Represents a collection of returned app permissions
|
|
209
|
+
*/
|
|
210
|
+
type AppPermissions = {
|
|
211
|
+
permissions: {
|
|
212
|
+
/**
|
|
213
|
+
* The name of the permission
|
|
214
|
+
*/
|
|
215
|
+
name: string;
|
|
216
|
+
/**
|
|
217
|
+
* The ID of the permission
|
|
218
|
+
*/
|
|
219
|
+
id: string;
|
|
220
|
+
}[];
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* @returns The app settings that have been set against the current app
|
|
224
|
+
*
|
|
225
|
+
* @throws {Error} If the function is called outside of an OpenFin environment
|
|
226
|
+
* @throws {Error} If the function is called outside of an OpenFin View context
|
|
227
|
+
*/
|
|
228
|
+
declare function getAppSettings(): Promise<unknown>;
|
|
229
|
+
/**
|
|
230
|
+
* @returns The app settings that have been set against the current app for the current user
|
|
231
|
+
*
|
|
232
|
+
* @throws {Error} If the function is called outside of an OpenFin environment
|
|
233
|
+
* @throws {Error} If the function is called outside of an OpenFin View context
|
|
234
|
+
*/
|
|
235
|
+
declare function getAppUserSettings(): Promise<unknown>;
|
|
236
|
+
/**
|
|
237
|
+
* Assigns a set of user specific settings to the current app
|
|
238
|
+
*
|
|
239
|
+
* @returns The app settings that have been set against the current app for the current user
|
|
240
|
+
*
|
|
241
|
+
* @throws {Error} If the function is called outside of an OpenFin environment
|
|
242
|
+
* @throws {Error} If the function is called outside of an OpenFin View context
|
|
243
|
+
*/
|
|
244
|
+
declare function setAppUserSettings(settings: unknown): Promise<unknown>;
|
|
245
|
+
/**
|
|
246
|
+
* @returns The permissions that have been set against the current app for the current user
|
|
247
|
+
*
|
|
248
|
+
* @throws {Error} If the function is called outside of an OpenFin environment
|
|
249
|
+
* @throws {Error} If the function is called outside of an OpenFin View context
|
|
250
|
+
*/
|
|
251
|
+
declare function getAppUserPermissions(): Promise<AppPermissions>;
|
|
252
|
+
type LaunchContentOptions = {
|
|
253
|
+
/** Object containing query param values to be appended to content's URL */
|
|
254
|
+
queryParams?: Record<string, string>;
|
|
255
|
+
/** Defines behavior when instance of content is already running.
|
|
256
|
+
* If 'multi', copy of the content will be created.
|
|
257
|
+
* If 'single', the existing instance of content will be focused. */
|
|
258
|
+
instanceMode?: 'single' | 'multi';
|
|
259
|
+
} & ({
|
|
260
|
+
targetType?: 'new-window';
|
|
261
|
+
/** Defines the bounds of the window in which content will open */
|
|
262
|
+
bounds?: Partial<OpenFin__default.Bounds>;
|
|
263
|
+
} | {
|
|
264
|
+
targetType: 'window' | 'view';
|
|
265
|
+
targetIdentity: OpenFin__default.Identity;
|
|
266
|
+
});
|
|
267
|
+
/**
|
|
268
|
+
* A function allowing the easy launching of content
|
|
269
|
+
* @param id The id of the content to launch
|
|
270
|
+
* @returns nothing
|
|
271
|
+
*
|
|
272
|
+
* @throws {Error} If the function is called outside of an OpenFin environment
|
|
273
|
+
* @throws {Error} If the function is called outside of an OpenFin View context
|
|
274
|
+
* @throws {Error} If the function has been unable to look up or launch the content
|
|
275
|
+
* @throws {Error} If the function is unable to find content with the provided id.
|
|
276
|
+
*/
|
|
277
|
+
declare function launchContent(id: string, options: LaunchContentOptions): Promise<void>;
|
|
278
|
+
/**
|
|
279
|
+
* A function allowing the easy launching of Supertabs
|
|
280
|
+
* @param id The id of supertab
|
|
281
|
+
* @returns nothing
|
|
282
|
+
*
|
|
283
|
+
* @throws {Error} If the function is called outside of an OpenFin environment
|
|
284
|
+
* @throws {Error} If the function is called outside of an OpenFin View context
|
|
285
|
+
* @throws {Error} If the function has been unable to look up or launch the supertab
|
|
286
|
+
* @throws {Error} If the function is unable to find supertab with the provided id.
|
|
287
|
+
*/
|
|
288
|
+
declare function launchSupertab(id: string): Promise<void>;
|
|
289
|
+
/**
|
|
290
|
+
* A function allowing the easy launching of Workspaces
|
|
291
|
+
* @param id The id of workspace
|
|
292
|
+
* @returns nothing
|
|
293
|
+
*
|
|
294
|
+
* @throws {Error} If the function is called outside of an OpenFin environment
|
|
295
|
+
* @throws {Error} If the function is called outside of an OpenFin View context
|
|
296
|
+
* @throws {Error} If the function has been unable to look up or launch the workspace
|
|
297
|
+
* @throws {Error} If the function is unable to find workspace with the provided id.
|
|
298
|
+
*/
|
|
299
|
+
declare function launchWorkspace(id: string): Promise<void>;
|
|
300
|
+
|
|
301
|
+
type ActionedSearchResult = CLIDispatchedSearchResult;
|
|
302
|
+
type SearchActionResponse = {
|
|
303
|
+
url: string;
|
|
304
|
+
};
|
|
305
|
+
type SearchListenerRequest = CLISearchListenerRequest;
|
|
306
|
+
type SearchListenerResponse = CLISearchListenerResponse;
|
|
307
|
+
type SearchProvider = {
|
|
308
|
+
readonly configData: unknown;
|
|
309
|
+
hideWindow: () => Promise<void>;
|
|
310
|
+
readonly id: string;
|
|
311
|
+
isReady: (ready?: boolean) => Promise<void>;
|
|
312
|
+
readonly name: string;
|
|
313
|
+
showWindow: (options?: ShowWindowOptions) => Promise<void>;
|
|
314
|
+
};
|
|
315
|
+
type SearchProviderRegistrationConfig = {
|
|
316
|
+
onAction(result: ActionedSearchResult): Promise<SearchActionResponse | undefined>;
|
|
317
|
+
onSearch(request: SearchListenerRequest, response: SearchListenerResponse): Promise<SearchResponse>;
|
|
318
|
+
};
|
|
319
|
+
type SearchResponse = CLISearchResponse;
|
|
320
|
+
type SearchResult = SearchResult$1;
|
|
321
|
+
type ShowWindowOptions = {
|
|
322
|
+
center?: boolean;
|
|
323
|
+
height?: number;
|
|
324
|
+
left?: number;
|
|
325
|
+
resizable?: boolean;
|
|
326
|
+
top?: number;
|
|
327
|
+
width?: number;
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
declare const register: (config: SearchProviderRegistrationConfig) => Promise<SearchProvider>;
|
|
331
|
+
|
|
332
|
+
type search_ActionedSearchResult = ActionedSearchResult;
|
|
333
|
+
type search_SearchActionResponse = SearchActionResponse;
|
|
334
|
+
type search_SearchListenerRequest = SearchListenerRequest;
|
|
335
|
+
type search_SearchListenerResponse = SearchListenerResponse;
|
|
336
|
+
type search_SearchProvider = SearchProvider;
|
|
337
|
+
type search_SearchProviderRegistrationConfig = SearchProviderRegistrationConfig;
|
|
338
|
+
type search_SearchResponse = SearchResponse;
|
|
339
|
+
type search_SearchResult = SearchResult;
|
|
340
|
+
type search_ShowWindowOptions = ShowWindowOptions;
|
|
341
|
+
declare const search_register: typeof register;
|
|
342
|
+
declare namespace search {
|
|
343
|
+
export { type search_ActionedSearchResult as ActionedSearchResult, type search_SearchActionResponse as SearchActionResponse, type search_SearchListenerRequest as SearchListenerRequest, type search_SearchListenerResponse as SearchListenerResponse, type search_SearchProvider as SearchProvider, type search_SearchProviderRegistrationConfig as SearchProviderRegistrationConfig, type search_SearchResponse as SearchResponse, type search_SearchResult as SearchResult, type search_ShowWindowOptions as ShowWindowOptions, search_register as register };
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
declare global {
|
|
347
|
+
interface Window {
|
|
348
|
+
fin: typeof OpenFin.fin;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export { type AppPermissions, type LaunchContentOptions, search as Search, type FlannelChannelProvider as __INTERNAL_FlannelChannelProvider, type FlannelClearNotificationRequest as __INTERNAL_FlannelClearNotificationRequest, type FlannelClearNotificationResponse as __INTERNAL_FlannelClearNotificationResponse, type FlannelCreateNotificationRequest as __INTERNAL_FlannelCreateNotificationRequest, type FlannelCreateNotificationResponse as __INTERNAL_FlannelCreateNotificationResponse, type FlannelUpdateNotificationRequest as __INTERNAL_FlannelUpdateNotificationRequest, type FlannelUpdateNotificationResponse as __INTERNAL_FlannelUpdateNotificationResponse, getAppSettings, getAppUserPermissions, getAppUserSettings, getNotificationsClient, launchContent, launchSupertab, launchWorkspace, setAppUserSettings };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as OpenFin from '@openfin/core';
|
|
2
2
|
import OpenFin__default from '@openfin/core';
|
|
3
|
-
import * as NotificationsTypes from 'openfin
|
|
3
|
+
import * as NotificationsTypes from '@openfin/workspace/notifications';
|
|
4
|
+
import { CLIDispatchedSearchResult, CLISearchListenerRequest, CLISearchListenerResponse, CLISearchResponse, SearchResult as SearchResult$1 } from '@openfin/workspace';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* NotificationsClient is a client for accessing and interacting with the Notifications your application has created.
|
|
@@ -152,11 +153,6 @@ type FlannelChannelProvider = {
|
|
|
152
153
|
register: <T extends keyof FlannelProvider>(action: T, handler: (payload: Parameters<FlannelProvider[T]>[0], id: OpenFin__default.ProviderIdentity | OpenFin__default.ClientIdentity) => ReturnType<FlannelProvider[T]>) => boolean;
|
|
153
154
|
} & Omit<OpenFin__default.ChannelProvider, 'dispatch' | 'register'>;
|
|
154
155
|
|
|
155
|
-
declare global {
|
|
156
|
-
interface Window {
|
|
157
|
-
fin: typeof OpenFin.fin;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
156
|
/**
|
|
161
157
|
* @returns A client for interacting with the OpenFin Notifications service
|
|
162
158
|
*
|
|
@@ -208,4 +204,149 @@ declare global {
|
|
|
208
204
|
*/
|
|
209
205
|
declare function getNotificationsClient(): Promise<NotificationsClient>;
|
|
210
206
|
|
|
211
|
-
|
|
207
|
+
/**
|
|
208
|
+
* Represents a collection of returned app permissions
|
|
209
|
+
*/
|
|
210
|
+
type AppPermissions = {
|
|
211
|
+
permissions: {
|
|
212
|
+
/**
|
|
213
|
+
* The name of the permission
|
|
214
|
+
*/
|
|
215
|
+
name: string;
|
|
216
|
+
/**
|
|
217
|
+
* The ID of the permission
|
|
218
|
+
*/
|
|
219
|
+
id: string;
|
|
220
|
+
}[];
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* @returns The app settings that have been set against the current app
|
|
224
|
+
*
|
|
225
|
+
* @throws {Error} If the function is called outside of an OpenFin environment
|
|
226
|
+
* @throws {Error} If the function is called outside of an OpenFin View context
|
|
227
|
+
*/
|
|
228
|
+
declare function getAppSettings(): Promise<unknown>;
|
|
229
|
+
/**
|
|
230
|
+
* @returns The app settings that have been set against the current app for the current user
|
|
231
|
+
*
|
|
232
|
+
* @throws {Error} If the function is called outside of an OpenFin environment
|
|
233
|
+
* @throws {Error} If the function is called outside of an OpenFin View context
|
|
234
|
+
*/
|
|
235
|
+
declare function getAppUserSettings(): Promise<unknown>;
|
|
236
|
+
/**
|
|
237
|
+
* Assigns a set of user specific settings to the current app
|
|
238
|
+
*
|
|
239
|
+
* @returns The app settings that have been set against the current app for the current user
|
|
240
|
+
*
|
|
241
|
+
* @throws {Error} If the function is called outside of an OpenFin environment
|
|
242
|
+
* @throws {Error} If the function is called outside of an OpenFin View context
|
|
243
|
+
*/
|
|
244
|
+
declare function setAppUserSettings(settings: unknown): Promise<unknown>;
|
|
245
|
+
/**
|
|
246
|
+
* @returns The permissions that have been set against the current app for the current user
|
|
247
|
+
*
|
|
248
|
+
* @throws {Error} If the function is called outside of an OpenFin environment
|
|
249
|
+
* @throws {Error} If the function is called outside of an OpenFin View context
|
|
250
|
+
*/
|
|
251
|
+
declare function getAppUserPermissions(): Promise<AppPermissions>;
|
|
252
|
+
type LaunchContentOptions = {
|
|
253
|
+
/** Object containing query param values to be appended to content's URL */
|
|
254
|
+
queryParams?: Record<string, string>;
|
|
255
|
+
/** Defines behavior when instance of content is already running.
|
|
256
|
+
* If 'multi', copy of the content will be created.
|
|
257
|
+
* If 'single', the existing instance of content will be focused. */
|
|
258
|
+
instanceMode?: 'single' | 'multi';
|
|
259
|
+
} & ({
|
|
260
|
+
targetType?: 'new-window';
|
|
261
|
+
/** Defines the bounds of the window in which content will open */
|
|
262
|
+
bounds?: Partial<OpenFin__default.Bounds>;
|
|
263
|
+
} | {
|
|
264
|
+
targetType: 'window' | 'view';
|
|
265
|
+
targetIdentity: OpenFin__default.Identity;
|
|
266
|
+
});
|
|
267
|
+
/**
|
|
268
|
+
* A function allowing the easy launching of content
|
|
269
|
+
* @param id The id of the content to launch
|
|
270
|
+
* @returns nothing
|
|
271
|
+
*
|
|
272
|
+
* @throws {Error} If the function is called outside of an OpenFin environment
|
|
273
|
+
* @throws {Error} If the function is called outside of an OpenFin View context
|
|
274
|
+
* @throws {Error} If the function has been unable to look up or launch the content
|
|
275
|
+
* @throws {Error} If the function is unable to find content with the provided id.
|
|
276
|
+
*/
|
|
277
|
+
declare function launchContent(id: string, options: LaunchContentOptions): Promise<void>;
|
|
278
|
+
/**
|
|
279
|
+
* A function allowing the easy launching of Supertabs
|
|
280
|
+
* @param id The id of supertab
|
|
281
|
+
* @returns nothing
|
|
282
|
+
*
|
|
283
|
+
* @throws {Error} If the function is called outside of an OpenFin environment
|
|
284
|
+
* @throws {Error} If the function is called outside of an OpenFin View context
|
|
285
|
+
* @throws {Error} If the function has been unable to look up or launch the supertab
|
|
286
|
+
* @throws {Error} If the function is unable to find supertab with the provided id.
|
|
287
|
+
*/
|
|
288
|
+
declare function launchSupertab(id: string): Promise<void>;
|
|
289
|
+
/**
|
|
290
|
+
* A function allowing the easy launching of Workspaces
|
|
291
|
+
* @param id The id of workspace
|
|
292
|
+
* @returns nothing
|
|
293
|
+
*
|
|
294
|
+
* @throws {Error} If the function is called outside of an OpenFin environment
|
|
295
|
+
* @throws {Error} If the function is called outside of an OpenFin View context
|
|
296
|
+
* @throws {Error} If the function has been unable to look up or launch the workspace
|
|
297
|
+
* @throws {Error} If the function is unable to find workspace with the provided id.
|
|
298
|
+
*/
|
|
299
|
+
declare function launchWorkspace(id: string): Promise<void>;
|
|
300
|
+
|
|
301
|
+
type ActionedSearchResult = CLIDispatchedSearchResult;
|
|
302
|
+
type SearchActionResponse = {
|
|
303
|
+
url: string;
|
|
304
|
+
};
|
|
305
|
+
type SearchListenerRequest = CLISearchListenerRequest;
|
|
306
|
+
type SearchListenerResponse = CLISearchListenerResponse;
|
|
307
|
+
type SearchProvider = {
|
|
308
|
+
readonly configData: unknown;
|
|
309
|
+
hideWindow: () => Promise<void>;
|
|
310
|
+
readonly id: string;
|
|
311
|
+
isReady: (ready?: boolean) => Promise<void>;
|
|
312
|
+
readonly name: string;
|
|
313
|
+
showWindow: (options?: ShowWindowOptions) => Promise<void>;
|
|
314
|
+
};
|
|
315
|
+
type SearchProviderRegistrationConfig = {
|
|
316
|
+
onAction(result: ActionedSearchResult): Promise<SearchActionResponse | undefined>;
|
|
317
|
+
onSearch(request: SearchListenerRequest, response: SearchListenerResponse): Promise<SearchResponse>;
|
|
318
|
+
};
|
|
319
|
+
type SearchResponse = CLISearchResponse;
|
|
320
|
+
type SearchResult = SearchResult$1;
|
|
321
|
+
type ShowWindowOptions = {
|
|
322
|
+
center?: boolean;
|
|
323
|
+
height?: number;
|
|
324
|
+
left?: number;
|
|
325
|
+
resizable?: boolean;
|
|
326
|
+
top?: number;
|
|
327
|
+
width?: number;
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
declare const register: (config: SearchProviderRegistrationConfig) => Promise<SearchProvider>;
|
|
331
|
+
|
|
332
|
+
type search_ActionedSearchResult = ActionedSearchResult;
|
|
333
|
+
type search_SearchActionResponse = SearchActionResponse;
|
|
334
|
+
type search_SearchListenerRequest = SearchListenerRequest;
|
|
335
|
+
type search_SearchListenerResponse = SearchListenerResponse;
|
|
336
|
+
type search_SearchProvider = SearchProvider;
|
|
337
|
+
type search_SearchProviderRegistrationConfig = SearchProviderRegistrationConfig;
|
|
338
|
+
type search_SearchResponse = SearchResponse;
|
|
339
|
+
type search_SearchResult = SearchResult;
|
|
340
|
+
type search_ShowWindowOptions = ShowWindowOptions;
|
|
341
|
+
declare const search_register: typeof register;
|
|
342
|
+
declare namespace search {
|
|
343
|
+
export { type search_ActionedSearchResult as ActionedSearchResult, type search_SearchActionResponse as SearchActionResponse, type search_SearchListenerRequest as SearchListenerRequest, type search_SearchListenerResponse as SearchListenerResponse, type search_SearchProvider as SearchProvider, type search_SearchProviderRegistrationConfig as SearchProviderRegistrationConfig, type search_SearchResponse as SearchResponse, type search_SearchResult as SearchResult, type search_ShowWindowOptions as ShowWindowOptions, search_register as register };
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
declare global {
|
|
347
|
+
interface Window {
|
|
348
|
+
fin: typeof OpenFin.fin;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export { type AppPermissions, type LaunchContentOptions, search as Search, type FlannelChannelProvider as __INTERNAL_FlannelChannelProvider, type FlannelClearNotificationRequest as __INTERNAL_FlannelClearNotificationRequest, type FlannelClearNotificationResponse as __INTERNAL_FlannelClearNotificationResponse, type FlannelCreateNotificationRequest as __INTERNAL_FlannelCreateNotificationRequest, type FlannelCreateNotificationResponse as __INTERNAL_FlannelCreateNotificationResponse, type FlannelUpdateNotificationRequest as __INTERNAL_FlannelUpdateNotificationRequest, type FlannelUpdateNotificationResponse as __INTERNAL_FlannelUpdateNotificationResponse, getAppSettings, getAppUserPermissions, getAppUserSettings, getNotificationsClient, launchContent, launchSupertab, launchWorkspace, setAppUserSettings };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var o="@openfin/cloud-api";
|
|
1
|
+
var v=Object.defineProperty;var E=(n,o)=>{for(var e in o)v(n,e,{get:o[e],enumerable:!0})};var t="@openfin/cloud-api";async function r(){try{return await window.fin.View.getCurrentSync().getInfo(),!0}catch{return!1}}function y(n){if(n.name.startsWith("internal-generated"))throw new Error("Cannot extract app UUID from identity");return/\/[\d,a-z-]{36}$/.test(n.name)?n.name.split("/")[0]||"":n.name}var c="@openfin/cloud-api";function F(){return`${window.fin.me.uuid}-cloud-api-notifications`}var d=null;async function U(){return d||(d=P()),d}async function P(){if(!window.fin)throw new Error(`\`${c}\`: \`getNotificationsClient\` cannot be used in a non-OpenFin environment`);if(await r()===!1)throw new Error(`${c}: \`getNotificationsClient\` cannot be used in a non-OpenFin environment`);y(window.fin.me);let n=await S();console.log(n),n.register("openfin-cloud-event",e=>{for(let i of o.get(e.type)??[])typeof e.payload.timestamp=="string"&&(e.payload.timestamp=new Date(e.payload.timestamp)),i(e.payload)});let o=new Map;return{addEventListener:(e,i)=>{let a=o.get(e)||new Set;a.add(i),o.set(e,a)},removeEventListener:(e,i)=>{let a=o.get(e);if(!a){console.warn(`\`${c}\`: Listener was not found for event. Did you pass a function directly instead of a reference or forget to add the listener?`,e);return}a.delete(i)===!1&&console.warn(`\`${c}\`: Listener was not found for event. Did you pass a function directly instead of a reference?`,e)},update:async e=>(await n.dispatch("openfin-cloud-update-notification",{version:1,payload:{notification:e}})).payload.response,clear:async e=>(await n.dispatch("openfin-cloud-clear-notification",{version:1,payload:{notificationId:e}})).payload.response,createNotification:async e=>(e.id&&console.warn(`\`${c}\`: The \`id\` property is not supported and will be ignored. If you need to use the \`id\` property, you should use the \`id\` property of the returned notification object.`),(await n.dispatch("openfin-cloud-create-notification",{version:1,payload:{notification:{...e,id:void 0}}})).payload.response)}}var u=null;async function S(){return u||(u=$()),u}async function $(){let n=await window.fin.InterApplicationBus.Channel.connect(F());return n.onDisconnection(o=>{console.warn(`\`${c}\`: Channel Disconnected from`,o,"Reconnecting..."),u=null}),n}var f;function b(){return`${window.fin.me.uuid}-client-api`}async function s(){return f||(f=window.fin.InterApplicationBus.Channel.connect(b())),f}async function q(){if(!window.fin)throw new Error(`\`${t}\`: \`getAppSettings\` cannot be used in a non-OpenFin environment`);if(await r()===!1)throw new Error(`${t}: \`getAppSettings\` cannot be used in a non-OpenFin environment`);return(await s()).dispatch("get-settings")}async function D(){if(!window.fin)throw new Error(`\`${t}\`: \`getAppUserSettings\` cannot be used in a non-OpenFin environment`);if(await r()===!1)throw new Error(`${t}: \`getAppUserSettings\` cannot be used in a non-OpenFin environment`);return(await s()).dispatch("get-user-settings")}async function V(n){if(!window.fin)throw new Error(`\`${t}\`: \`setAppUserSettings\` cannot be used in a non-OpenFin environment`);if(await r()===!1)throw new Error(`${t}: \`setAppUserSettings\` cannot be used in a non-OpenFin environment`);return(await s()).dispatch("set-user-settings",n)}async function B(){if(!window.fin)throw new Error(`\`${t}\`: \`getAppUserPermissions\` cannot be used in a non-OpenFin environment`);if(await r()===!1)throw new Error(`${t}: \`getAppUserPermissions\` cannot be used in a non-OpenFin environment`);return(await s()).dispatch("get-user-permissions")}async function G(n,o){if(!window.fin)throw new Error(`\`${t}\`: \`launchContent\` cannot be used in a non-OpenFin environment`);if(await r()===!1)throw new Error(`${t}: \`launchContent\` cannot be used in a outside of an OpenFin View context`);let e=await s();try{await e.dispatch("launch-content",{id:n,options:o})}catch(i){switch(i instanceof Error?i.message:String(i)){case"UnableToLookup":throw new Error(`${t}: \`launchContent\` was unable to lookup content with id: ${n}`);case"UnableToLaunch":throw new Error(`${t}: \`launchContent\` was unable to launch content with id: ${n}`);case"NoContentFound":throw new Error(`${t}: \`launchContent\` did not find content with id: ${n}`);default:throw new Error(`${t}: \`launchContent\` was unable to look up or launch content with id: ${n} or the content did not exist.`)}}}async function K(n){if(!window.fin)throw new Error(`\`${t}\`: \`launchSupertab\` cannot be used in a non-OpenFin environment`);if(await r()===!1)throw new Error(`${t}: \`launchSupertab\` cannot be used in a outside of an OpenFin View context`);let o=await s();try{await o.dispatch("launch-supertab",{id:n})}catch(e){switch(e instanceof Error?e.message:String(e)){case"UnableToLookup":throw new Error(`${t}: \`launchSupertab\` was unable to lookup content with id: ${n}`);case"UnableToLaunch":throw new Error(`${t}: \`launchSupertab\` was unable to launch content with id: ${n}`);case"NoContentFound":throw new Error(`${t}: \`launchSupertab\` did not find content with id: ${n}`);default:throw new Error(`${t}: \`launchSupertab\` was unable to look up or launch content with id: ${n} or the content did not exist.`)}}}async function j(n){if(!window.fin)throw new Error(`\`${t}\`: \`launchWorkspace\` cannot be used in a non-OpenFin environment`);if(await r()===!1)throw new Error(`${t}: \`launchWorkspace\` cannot be used in a outside of an OpenFin View context`);let o=await s();try{await o.dispatch("launch-workspace",{id:n})}catch(e){switch(e instanceof Error?e.message:String(e)){case"UnableToLookup":throw new Error(`${t}: \`launchWorkspace\` was unable to lookup content with id: ${n}`);case"UnableToLaunch":throw new Error(`${t}: \`launchWorkspace\` was unable to launch content with id: ${n}`);case"NoContentFound":throw new Error(`${t}: \`launchWorkspace\` did not find content with id: ${n}`);default:throw new Error(`${t}: \`launchWorkspace\` was unable to look up or launch content with id: ${n} or the content did not exist.`)}}}var g={};E(g,{register:()=>k});var A="get-results",R="handle-action",T={id:"",onClose:function(n){console.warn("Function not implemented.")},removeListener:function(n){console.warn("Function not implemented.")},query:""},O={open:function(){console.warn("Function not implemented.")},close:function(){console.warn("Function not implemented.")},respond:function(n){console.warn("Function not implemented.")},revoke:function(...n){console.warn("Function not implemented.")},updateContext:function(n){console.warn("Function not implemented.")}},k=async n=>{let o=await window.fin.me.getOptions(),{configuration:e,id:i,name:a}=o.customData,w=`search-provider-${o.customData.id}`;console.debug(`creating channel ${w}`);let h=await window.fin.InterApplicationBus.Channel.create(w);return h.register(R,async l=>{let{searchResult:p,actionId:m,viewIdentity:C}=l,N={action:{name:m,trigger:"user-action"},dispatcherIdentity:C,key:"",title:p.title,actions:[],data:p};return await n.onAction(N)}),h.register(A,async l=>{let p=Object.assign({},T,l);return(await n.onSearch(p,O)).results}),{configData:e,hideWindow:async function(){console.warn("Function not implemented.")},id:i,isReady:async function(l){console.warn("Function not implemented.")},name:a,showWindow:async function(){console.warn("Function not implemented.")}}};export{g as Search,q as getAppSettings,B as getAppUserPermissions,D as getAppUserSettings,U as getNotificationsClient,G as launchContent,K as launchSupertab,j as launchWorkspace,V as setAppUserSettings};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// eslint-disable-next-line check-file/no-index\nimport type OpenFin from '@openfin/core';\nimport type * as NotificationsTypes from 'openfin-notifications';\n\nimport type { FlannelChannelClient, NotificationEventsMap, NotificationsClient } from './types';\n\nconst PACKAGE_NAME = '@openfin/cloud-api';\n\nexport type {\n FlannelChannelProvider as __INTERNAL_FlannelChannelProvider,\n FlannelCreateNotificationRequest as __INTERNAL_FlannelCreateNotificationRequest,\n FlannelCreateNotificationResponse as __INTERNAL_FlannelCreateNotificationResponse,\n FlannelUpdateNotificationRequest as __INTERNAL_FlannelUpdateNotificationRequest,\n FlannelUpdateNotificationResponse as __INTERNAL_FlannelUpdateNotificationResponse,\n FlannelClearNotificationRequest as __INTERNAL_FlannelClearNotificationRequest,\n FlannelClearNotificationResponse as __INTERNAL_FlannelClearNotificationResponse,\n} from './types';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface Window {\n fin: typeof import('@openfin/core').fin;\n }\n}\n\nfunction getChannelName() {\n return `${window.fin.me.uuid}-cloud-api-notifications`;\n}\n\nasync function isInViewContext(): Promise<boolean> {\n try {\n await window.fin.View.getCurrentSync().getInfo();\n return true;\n } catch {\n return false;\n }\n}\n\nfunction extractAppUuidFromIdentity(identity: OpenFin.Identity): string {\n if (identity.name.startsWith('internal-generated')) {\n throw new Error('Cannot extract app UUID from identity');\n }\n // <uuid>/<name>\n if (/\\/[\\d,a-z-]{36}$/.test(identity.name)) {\n return identity.name.split('/')[0] || '';\n }\n\n return identity.name;\n}\n\nlet notificationsClientPromise: Promise<NotificationsClient> | null = null;\n\n/**\n * @returns A client for interacting with the OpenFin Notifications service\n *\n * @throws {Error} If the function is called outside of an OpenFin environment\n * @throws {Error} If the function is called outside of an OpenFin View context\n * @throws {Error} If the app UUID cannot be extracted from the current context\n *\n * @example **Basic Usage** Creating a notification, updating it and then clearing it\n * ```ts\n * const notificationsClient = await getNotificationsClient();\n *\n * const notification = await notificationsClient.createNotification({\n * title: 'Hello, World!',\n * body: 'This is a notification from the OpenFin Cloud API',\n * });\n *\n * // Use the `id` from the returned notification to interact with it\n * console.log(notification.id);\n *\n * // Update the notification\n * await notificationsClient.update({\n * id: notification.id,\n * body: 'This is a notification from the OpenFin Cloud API, that has been updated!',\n * })\n *\n * // Clear the notification\n * await notificationsClient.clear(notification.id);\n * ```\n *\n * @example **Advanced Usage** Listening for events\n * ```ts\n * const notificationsClient = await getNotificationsClient();\n *\n * // create the notification\n * const notification = await notificationsClient.createNotification({\n * title: `${window.fin.me.identity.name} Hello, World!`,\n * body: `This is a notification from the cloud API example created at ${new Date().toLocaleTimeString()}`,\n * buttons: [\n * {\n * title: 'Acknowledge',\n * },\n * ],\n * });\n *\n * notificationsClient.addEventListener('notification-action', (event) => {\n * console.log('Notification action:', event);\n * });\n * ```\n */\nasync function getNotificationsClient(): Promise<NotificationsClient> {\n if (!notificationsClientPromise) {\n notificationsClientPromise = getNotificationsClientInternal();\n }\n\n return notificationsClientPromise;\n}\n\nasync function getNotificationsClientInternal(): Promise<NotificationsClient> {\n if (!window.fin) {\n throw new Error(`\\`${PACKAGE_NAME}\\`: \\`getNotificationsClient\\` cannot be used in a non-OpenFin environment`);\n }\n\n if ((await isInViewContext()) === false) {\n throw new Error(`${PACKAGE_NAME}: \\`getNotificationsClient\\` cannot be used in a non-OpenFin environment`);\n }\n\n extractAppUuidFromIdentity(window.fin.me);\n\n const channelPromise = await getChannelClient();\n console.log(channelPromise);\n\n channelPromise.register('openfin-cloud-event', (message) => {\n for (const listener of eventListeners.get(message.type) ?? []) {\n // `Date` is serialized as a string, so we need to convert it back\n if (typeof message.payload.timestamp === 'string') {\n message.payload.timestamp = new Date(message.payload.timestamp);\n }\n\n listener(message.payload as never);\n }\n });\n\n const eventListeners = new Map<keyof NotificationEventsMap, Set<NotificationEventsMap[keyof NotificationEventsMap]>>();\n\n return {\n addEventListener: <T extends keyof NotificationEventsMap>(eventName: T, listener: NotificationEventsMap[T]) => {\n const listeners = eventListeners.get(eventName) || new Set();\n listeners.add(listener);\n eventListeners.set(eventName, listeners);\n },\n removeEventListener: <T extends keyof NotificationEventsMap>(eventName: T, listener: NotificationEventsMap[T]) => {\n const listeners = eventListeners.get(eventName);\n if (!listeners) {\n console.warn(\n `\\`${PACKAGE_NAME}\\`: Listener was not found for event. Did you pass a function directly instead of a reference or forget to add the listener?`,\n eventName,\n );\n return;\n }\n\n if (listeners.delete(listener as (args: unknown) => void) === false) {\n console.warn(`\\`${PACKAGE_NAME}\\`: Listener was not found for event. Did you pass a function directly instead of a reference?`, eventName);\n }\n },\n update: async (options: Parameters<typeof NotificationsTypes.update>[0]): ReturnType<typeof NotificationsTypes.update> => {\n const response = await channelPromise.dispatch('openfin-cloud-update-notification', {\n version: 1,\n payload: {\n notification: options,\n },\n });\n return response.payload.response;\n },\n clear: async (notificationId: Parameters<typeof NotificationsTypes.clear>[0]): ReturnType<typeof NotificationsTypes.clear> => {\n const response = await channelPromise.dispatch('openfin-cloud-clear-notification', {\n version: 1,\n payload: {\n notificationId,\n },\n });\n return response.payload.response;\n },\n createNotification: async (\n options: NotificationsTypes.NotificationOptions,\n ): Promise<NotificationsTypes.Notification<NotificationsTypes.NotificationOptions>> => {\n if (options.id) {\n console.warn(\n `\\`${PACKAGE_NAME}\\`: The \\`id\\` property is not supported and will be ignored. If you need to use the \\`id\\` property, you should use the \\`id\\` property of the returned notification object.`,\n );\n }\n const response = await channelPromise.dispatch('openfin-cloud-create-notification', {\n version: 1,\n payload: {\n notification: { ...options, id: undefined },\n },\n });\n return response.payload.response;\n },\n };\n}\n\nlet channelClientPromise: Promise<FlannelChannelClient> | null = null;\n\nasync function getChannelClient(): Promise<FlannelChannelClient> {\n if (!channelClientPromise) {\n channelClientPromise = getChannelClientInternal();\n }\n\n return channelClientPromise;\n}\n\nasync function getChannelClientInternal(): Promise<FlannelChannelClient> {\n const channel = (await window.fin.InterApplicationBus.Channel.connect(getChannelName())) as FlannelChannelClient;\n\n channel.onDisconnection((identity) => {\n console.warn(`\\`${PACKAGE_NAME}\\`: Channel Disconnected from`, identity, 'Reconnecting...');\n channelClientPromise = null;\n });\n\n return channel;\n}\n\nexport { getNotificationsClient };\n"],"mappings":"AAMA,IAAMA,EAAe,qBAmBrB,SAASC,GAAiB,CACtB,MAAO,GAAG,OAAO,IAAI,GAAG,IAAI,0BAChC,CAEA,eAAeC,GAAoC,CAC/C,GAAI,CACA,aAAM,OAAO,IAAI,KAAK,eAAe,EAAE,QAAQ,EACxC,EACX,MAAQ,CACJ,MAAO,EACX,CACJ,CAEA,SAASC,EAA2BC,EAAoC,CACpE,GAAIA,EAAS,KAAK,WAAW,oBAAoB,EAC7C,MAAM,IAAI,MAAM,uCAAuC,EAG3D,MAAI,mBAAmB,KAAKA,EAAS,IAAI,EAC9BA,EAAS,KAAK,MAAM,GAAG,EAAE,CAAC,GAAK,GAGnCA,EAAS,IACpB,CAEA,IAAIC,EAAkE,KAmDtE,eAAeC,GAAuD,CAClE,OAAKD,IACDA,EAA6BE,EAA+B,GAGzDF,CACX,CAEA,eAAeE,GAA+D,CAC1E,GAAI,CAAC,OAAO,IACR,MAAM,IAAI,MAAM,KAAKP,CAAY,4EAA4E,EAGjH,GAAK,MAAME,EAAgB,IAAO,GAC9B,MAAM,IAAI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AC,GACe,QAAQ,SAEhC,CACJ,CAEA,IAAIE,EAA6D,KAEjE,eAAeR,GAAkD,CAC7D,OAAKQ,IACDA,EAAuBC,EAAyB,GAG7CD,CACX,CAEA,eAAeC,GAA0D,CACrE,IAAMC,EAAW,MAAM,OAAO,IAAI,oBAAoB,QAAQ,QAAQlB,EAAe,CAAC,EAEtF,OAAAkB,EAAQ,gBAAiBf,GAAa,CAClC,QAAQ,KAAK,KAAKJ,CAAY,gCAAiCI,EAAU,iBAAiB,EAC1Fa,EAAuB,IAC3B,CAAC,EAEME,CACX","names":["PACKAGE_NAME","getChannelName","isInViewContext","extractAppUuidFromIdentity","identity","notificationsClientPromise","getNotificationsClient","getNotificationsClientInternal","channelPromise","getChannelClient","message","listener","eventListeners","eventName","listeners","options","notificationId","channelClientPromise","getChannelClientInternal","channel"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils.ts","../src/notifications.ts","../src/client-api.ts","../src/search/search.ts"],"sourcesContent":["import type OpenFin from '@openfin/core';\n\nexport const PACKAGE_NAME = '@openfin/cloud-api';\n\nexport async function isInViewContext(): Promise<boolean> {\n try {\n await window.fin.View.getCurrentSync().getInfo();\n return true;\n } catch {\n return false;\n }\n}\n\nexport function extractAppUuidFromIdentity(identity: OpenFin.Identity): string {\n if (identity.name.startsWith('internal-generated')) {\n throw new Error('Cannot extract app UUID from identity');\n }\n // <uuid>/<name>\n if (/\\/[\\d,a-z-]{36}$/.test(identity.name)) {\n return identity.name.split('/')[0] || '';\n }\n\n return identity.name;\n}\n","// eslint-disable-next-line check-file/no-index\nimport type * as NotificationsTypes from '@openfin/workspace/notifications';\n\nimport type { FlannelChannelClient, NotificationEventsMap, NotificationsClient } from './types';\nimport { extractAppUuidFromIdentity, isInViewContext } from './utils';\n\nconst PACKAGE_NAME = '@openfin/cloud-api';\n\nexport type {\n FlannelChannelProvider as __INTERNAL_FlannelChannelProvider,\n FlannelCreateNotificationRequest as __INTERNAL_FlannelCreateNotificationRequest,\n FlannelCreateNotificationResponse as __INTERNAL_FlannelCreateNotificationResponse,\n FlannelUpdateNotificationRequest as __INTERNAL_FlannelUpdateNotificationRequest,\n FlannelUpdateNotificationResponse as __INTERNAL_FlannelUpdateNotificationResponse,\n FlannelClearNotificationRequest as __INTERNAL_FlannelClearNotificationRequest,\n FlannelClearNotificationResponse as __INTERNAL_FlannelClearNotificationResponse,\n} from './types';\n\nfunction getChannelName() {\n return `${window.fin.me.uuid}-cloud-api-notifications`;\n}\n\nlet notificationsClientPromise: Promise<NotificationsClient> | null = null;\n\n/**\n * @returns A client for interacting with the OpenFin Notifications service\n *\n * @throws {Error} If the function is called outside of an OpenFin environment\n * @throws {Error} If the function is called outside of an OpenFin View context\n * @throws {Error} If the app UUID cannot be extracted from the current context\n *\n * @example **Basic Usage** Creating a notification, updating it and then clearing it\n * ```ts\n * const notificationsClient = await getNotificationsClient();\n *\n * const notification = await notificationsClient.createNotification({\n * title: 'Hello, World!',\n * body: 'This is a notification from the OpenFin Cloud API',\n * });\n *\n * // Use the `id` from the returned notification to interact with it\n * console.log(notification.id);\n *\n * // Update the notification\n * await notificationsClient.update({\n * id: notification.id,\n * body: 'This is a notification from the OpenFin Cloud API, that has been updated!',\n * })\n *\n * // Clear the notification\n * await notificationsClient.clear(notification.id);\n * ```\n *\n * @example **Advanced Usage** Listening for events\n * ```ts\n * const notificationsClient = await getNotificationsClient();\n *\n * // create the notification\n * const notification = await notificationsClient.createNotification({\n * title: `${window.fin.me.identity.name} Hello, World!`,\n * body: `This is a notification from the cloud API example created at ${new Date().toLocaleTimeString()}`,\n * buttons: [\n * {\n * title: 'Acknowledge',\n * },\n * ],\n * });\n *\n * notificationsClient.addEventListener('notification-action', (event) => {\n * console.log('Notification action:', event);\n * });\n * ```\n */\nasync function getNotificationsClient(): Promise<NotificationsClient> {\n if (!notificationsClientPromise) {\n notificationsClientPromise = getNotificationsClientInternal();\n }\n\n return notificationsClientPromise;\n}\n\nasync function getNotificationsClientInternal(): Promise<NotificationsClient> {\n if (!window.fin) {\n throw new Error(`\\`${PACKAGE_NAME}\\`: \\`getNotificationsClient\\` cannot be used in a non-OpenFin environment`);\n }\n\n if ((await isInViewContext()) === false) {\n throw new Error(`${PACKAGE_NAME}: \\`getNotificationsClient\\` cannot be used in a non-OpenFin environment`);\n }\n\n extractAppUuidFromIdentity(window.fin.me);\n\n const channelPromise = await getChannelClient();\n console.log(channelPromise);\n\n channelPromise.register('openfin-cloud-event', (message) => {\n for (const listener of eventListeners.get(message.type) ?? []) {\n // `Date` is serialized as a string, so we need to convert it back\n if (typeof message.payload.timestamp === 'string') {\n message.payload.timestamp = new Date(message.payload.timestamp);\n }\n\n listener(message.payload as never);\n }\n });\n\n const eventListeners = new Map<keyof NotificationEventsMap, Set<NotificationEventsMap[keyof NotificationEventsMap]>>();\n\n return {\n addEventListener: <T extends keyof NotificationEventsMap>(eventName: T, listener: NotificationEventsMap[T]) => {\n const listeners = eventListeners.get(eventName) || new Set();\n listeners.add(listener);\n eventListeners.set(eventName, listeners);\n },\n removeEventListener: <T extends keyof NotificationEventsMap>(eventName: T, listener: NotificationEventsMap[T]) => {\n const listeners = eventListeners.get(eventName);\n if (!listeners) {\n console.warn(\n `\\`${PACKAGE_NAME}\\`: Listener was not found for event. Did you pass a function directly instead of a reference or forget to add the listener?`,\n eventName,\n );\n return;\n }\n\n if (listeners.delete(listener as (args: unknown) => void) === false) {\n console.warn(`\\`${PACKAGE_NAME}\\`: Listener was not found for event. Did you pass a function directly instead of a reference?`, eventName);\n }\n },\n update: async (options: Parameters<typeof NotificationsTypes.update>[0]): ReturnType<typeof NotificationsTypes.update> => {\n const response = await channelPromise.dispatch('openfin-cloud-update-notification', {\n version: 1,\n payload: {\n notification: options,\n },\n });\n return response.payload.response;\n },\n clear: async (notificationId: Parameters<typeof NotificationsTypes.clear>[0]): ReturnType<typeof NotificationsTypes.clear> => {\n const response = await channelPromise.dispatch('openfin-cloud-clear-notification', {\n version: 1,\n payload: {\n notificationId,\n },\n });\n return response.payload.response;\n },\n createNotification: async (\n options: NotificationsTypes.NotificationOptions,\n ): Promise<NotificationsTypes.Notification<NotificationsTypes.NotificationOptions>> => {\n if (options.id) {\n console.warn(\n `\\`${PACKAGE_NAME}\\`: The \\`id\\` property is not supported and will be ignored. If you need to use the \\`id\\` property, you should use the \\`id\\` property of the returned notification object.`,\n );\n }\n const response = await channelPromise.dispatch('openfin-cloud-create-notification', {\n version: 1,\n payload: {\n notification: { ...options, id: undefined },\n },\n });\n return response.payload.response;\n },\n };\n}\n\nlet channelClientPromise: Promise<FlannelChannelClient> | null = null;\n\nasync function getChannelClient(): Promise<FlannelChannelClient> {\n if (!channelClientPromise) {\n channelClientPromise = getChannelClientInternal();\n }\n\n return channelClientPromise;\n}\n\nasync function getChannelClientInternal(): Promise<FlannelChannelClient> {\n const channel = (await window.fin.InterApplicationBus.Channel.connect(getChannelName())) as FlannelChannelClient;\n\n channel.onDisconnection((identity) => {\n console.warn(`\\`${PACKAGE_NAME}\\`: Channel Disconnected from`, identity, 'Reconnecting...');\n channelClientPromise = null;\n });\n\n return channel;\n}\n\nexport { getNotificationsClient };\n","import type OpenFin from '@openfin/core';\n\nimport { isInViewContext, PACKAGE_NAME } from './utils';\n\nlet apiChannelClientPromise: Promise<OpenFin.ChannelClient>;\n\n/**\n * Represents a collection of returned app permissions\n */\nexport type AppPermissions = {\n permissions: {\n /**\n * The name of the permission\n */\n name: string;\n /**\n * The ID of the permission\n */\n id: string;\n }[];\n};\n\nfunction getApiChannelName() {\n return `${window.fin.me.uuid}-client-api`;\n}\n\nasync function getApiChannelClient(): Promise<OpenFin.ChannelClient> {\n if (!apiChannelClientPromise) {\n apiChannelClientPromise = window.fin.InterApplicationBus.Channel.connect(getApiChannelName());\n }\n\n return apiChannelClientPromise;\n}\n\n/**\n * @returns The app settings that have been set against the current app\n *\n * @throws {Error} If the function is called outside of an OpenFin environment\n * @throws {Error} If the function is called outside of an OpenFin View context\n */\nasync function getAppSettings(): Promise<unknown> {\n if (!window.fin) {\n throw new Error(`\\`${PACKAGE_NAME}\\`: \\`getAppSettings\\` cannot be used in a non-OpenFin environment`);\n }\n\n if ((await isInViewContext()) === false) {\n throw new Error(`${PACKAGE_NAME}: \\`getAppSettings\\` cannot be used in a non-OpenFin environment`);\n }\n\n const channel = await getApiChannelClient();\n\n return channel.dispatch('get-settings');\n}\n\n/**\n * @returns The app settings that have been set against the current app for the current user\n *\n * @throws {Error} If the function is called outside of an OpenFin environment\n * @throws {Error} If the function is called outside of an OpenFin View context\n */\nasync function getAppUserSettings(): Promise<unknown> {\n if (!window.fin) {\n throw new Error(`\\`${PACKAGE_NAME}\\`: \\`getAppUserSettings\\` cannot be used in a non-OpenFin environment`);\n }\n\n if ((await isInViewContext()) === false) {\n throw new Error(`${PACKAGE_NAME}: \\`getAppUserSettings\\` cannot be used in a non-OpenFin environment`);\n }\n\n const channel = await getApiChannelClient();\n\n return channel.dispatch('get-user-settings');\n}\n\n/**\n * Assigns a set of user specific settings to the current app\n *\n * @returns The app settings that have been set against the current app for the current user\n *\n * @throws {Error} If the function is called outside of an OpenFin environment\n * @throws {Error} If the function is called outside of an OpenFin View context\n */\nasync function setAppUserSettings(settings: unknown): Promise<unknown> {\n if (!window.fin) {\n throw new Error(`\\`${PACKAGE_NAME}\\`: \\`setAppUserSettings\\` cannot be used in a non-OpenFin environment`);\n }\n\n if ((await isInViewContext()) === false) {\n throw new Error(`${PACKAGE_NAME}: \\`setAppUserSettings\\` cannot be used in a non-OpenFin environment`);\n }\n\n const channel = await getApiChannelClient();\n\n return channel.dispatch('set-user-settings', settings);\n}\n\n/**\n * @returns The permissions that have been set against the current app for the current user\n *\n * @throws {Error} If the function is called outside of an OpenFin environment\n * @throws {Error} If the function is called outside of an OpenFin View context\n */\nasync function getAppUserPermissions(): Promise<AppPermissions> {\n if (!window.fin) {\n throw new Error(`\\`${PACKAGE_NAME}\\`: \\`getAppUserPermissions\\` cannot be used in a non-OpenFin environment`);\n }\n\n if ((await isInViewContext()) === false) {\n throw new Error(`${PACKAGE_NAME}: \\`getAppUserPermissions\\` cannot be used in a non-OpenFin environment`);\n }\n\n const channel = await getApiChannelClient();\n\n return channel.dispatch('get-user-permissions');\n}\n\nexport type LaunchContentOptions = {\n /** Object containing query param values to be appended to content's URL */\n queryParams?: Record<string, string>;\n /** Defines behavior when instance of content is already running.\n * If 'multi', copy of the content will be created.\n * If 'single', the existing instance of content will be focused. */\n instanceMode?: 'single' | 'multi';\n} & (\n | {\n targetType?: 'new-window';\n /** Defines the bounds of the window in which content will open */\n bounds?: Partial<OpenFin.Bounds>;\n }\n | {\n targetType: 'window' | 'view';\n targetIdentity: OpenFin.Identity;\n }\n);\n/**\n * A function allowing the easy launching of content\n * @param id The id of the content to launch\n * @returns nothing\n *\n * @throws {Error} If the function is called outside of an OpenFin environment\n * @throws {Error} If the function is called outside of an OpenFin View context\n * @throws {Error} If the function has been unable to look up or launch the content\n * @throws {Error} If the function is unable to find content with the provided id.\n */\nasync function launchContent(id: string, options: LaunchContentOptions): Promise<void> {\n if (!window.fin) {\n throw new Error(`\\`${PACKAGE_NAME}\\`: \\`launchContent\\` cannot be used in a non-OpenFin environment`);\n }\n\n if ((await isInViewContext()) === false) {\n throw new Error(`${PACKAGE_NAME}: \\`launchContent\\` cannot be used in a outside of an OpenFin View context`);\n }\n\n const channel = await getApiChannelClient();\n\n try {\n await channel.dispatch('launch-content', { id, options });\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n switch (errorMessage) {\n case 'UnableToLookup': {\n throw new Error(`${PACKAGE_NAME}: \\`launchContent\\` was unable to lookup content with id: ${id}`);\n }\n case 'UnableToLaunch': {\n throw new Error(`${PACKAGE_NAME}: \\`launchContent\\` was unable to launch content with id: ${id}`);\n }\n case 'NoContentFound': {\n throw new Error(`${PACKAGE_NAME}: \\`launchContent\\` did not find content with id: ${id}`);\n }\n default: {\n throw new Error(`${PACKAGE_NAME}: \\`launchContent\\` was unable to look up or launch content with id: ${id} or the content did not exist.`);\n }\n }\n }\n}\n\n/**\n * A function allowing the easy launching of Supertabs\n * @param id The id of supertab\n * @returns nothing\n *\n * @throws {Error} If the function is called outside of an OpenFin environment\n * @throws {Error} If the function is called outside of an OpenFin View context\n * @throws {Error} If the function has been unable to look up or launch the supertab\n * @throws {Error} If the function is unable to find supertab with the provided id.\n */\nasync function launchSupertab(id: string): Promise<void> {\n if (!window.fin) {\n throw new Error(`\\`${PACKAGE_NAME}\\`: \\`launchSupertab\\` cannot be used in a non-OpenFin environment`);\n }\n\n if ((await isInViewContext()) === false) {\n throw new Error(`${PACKAGE_NAME}: \\`launchSupertab\\` cannot be used in a outside of an OpenFin View context`);\n }\n\n const channel = await getApiChannelClient();\n\n try {\n await channel.dispatch('launch-supertab', { id });\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n switch (errorMessage) {\n case 'UnableToLookup': {\n throw new Error(`${PACKAGE_NAME}: \\`launchSupertab\\` was unable to lookup content with id: ${id}`);\n }\n case 'UnableToLaunch': {\n throw new Error(`${PACKAGE_NAME}: \\`launchSupertab\\` was unable to launch content with id: ${id}`);\n }\n case 'NoContentFound': {\n throw new Error(`${PACKAGE_NAME}: \\`launchSupertab\\` did not find content with id: ${id}`);\n }\n default: {\n throw new Error(`${PACKAGE_NAME}: \\`launchSupertab\\` was unable to look up or launch content with id: ${id} or the content did not exist.`);\n }\n }\n }\n}\n\n/**\n * A function allowing the easy launching of Workspaces\n * @param id The id of workspace\n * @returns nothing\n *\n * @throws {Error} If the function is called outside of an OpenFin environment\n * @throws {Error} If the function is called outside of an OpenFin View context\n * @throws {Error} If the function has been unable to look up or launch the workspace\n * @throws {Error} If the function is unable to find workspace with the provided id.\n */\nasync function launchWorkspace(id: string): Promise<void> {\n if (!window.fin) {\n throw new Error(`\\`${PACKAGE_NAME}\\`: \\`launchWorkspace\\` cannot be used in a non-OpenFin environment`);\n }\n\n if ((await isInViewContext()) === false) {\n throw new Error(`${PACKAGE_NAME}: \\`launchWorkspace\\` cannot be used in a outside of an OpenFin View context`);\n }\n\n const channel = await getApiChannelClient();\n\n try {\n await channel.dispatch('launch-workspace', { id });\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n switch (errorMessage) {\n case 'UnableToLookup': {\n throw new Error(`${PACKAGE_NAME}: \\`launchWorkspace\\` was unable to lookup content with id: ${id}`);\n }\n case 'UnableToLaunch': {\n throw new Error(`${PACKAGE_NAME}: \\`launchWorkspace\\` was unable to launch content with id: ${id}`);\n }\n case 'NoContentFound': {\n throw new Error(`${PACKAGE_NAME}: \\`launchWorkspace\\` did not find content with id: ${id}`);\n }\n default: {\n throw new Error(`${PACKAGE_NAME}: \\`launchWorkspace\\` was unable to look up or launch content with id: ${id} or the content did not exist.`);\n }\n }\n }\n}\n\nexport { getAppSettings, getAppUserSettings, setAppUserSettings, getAppUserPermissions, launchContent, launchSupertab, launchWorkspace };\n","/* eslint-disable @typescript-eslint/no-unused-vars */\n\nimport type { ActionTrigger, DispatchedSearchResult, SearchListenerRequest, SearchListenerResponse, SearchResult } from '@openfin/workspace';\n\nimport type { SearchProvider, SearchProviderProxyPayloadInternal, SearchProviderRegistrationConfig, SearchProviderWindowCreationOptions } from './search.types';\n\nconst TOPIC_NAME_GET_RESULTS = 'get-results';\nconst TOPIC_NAME_HANDLE_ACTION = 'handle-action';\n\nconst searchListenerRequest: SearchListenerRequest = {\n id: '',\n onClose: function (listener: () => void): void {\n console.warn('Function not implemented.');\n },\n removeListener: function (listener: () => void): void {\n console.warn('Function not implemented.');\n },\n query: '',\n};\n\nconst searchListenerResponse: SearchListenerResponse = {\n open: function (): void {\n console.warn('Function not implemented.');\n },\n close: function (): void {\n console.warn('Function not implemented.');\n },\n respond: function (results: SearchResult[]): void {\n console.warn('Function not implemented.');\n },\n revoke: function (...resultKeys: string[]): void {\n console.warn('Function not implemented.');\n },\n updateContext: function (context: unknown): void {\n console.warn('Function not implemented.');\n },\n};\n\nexport const register = async (config: SearchProviderRegistrationConfig): Promise<SearchProvider> => {\n // TODO: Update this to use @openfin/search-api\n const windowOptions = await window.fin.me.getOptions();\n const { configuration, id, name } = windowOptions.customData as SearchProviderWindowCreationOptions;\n const channelName = `search-provider-${windowOptions.customData.id}`;\n console.debug(`creating channel ${channelName}`);\n const channelProvider = await window.fin.InterApplicationBus.Channel.create(channelName);\n channelProvider.register(TOPIC_NAME_HANDLE_ACTION, async (payload: unknown) => {\n const { searchResult, actionId, viewIdentity } = payload as SearchProviderProxyPayloadInternal;\n const result: DispatchedSearchResult = {\n action: { name: actionId, trigger: 'user-action' as typeof ActionTrigger.UserAction },\n dispatcherIdentity: viewIdentity,\n key: '',\n title: searchResult.title,\n actions: [],\n data: searchResult,\n };\n const response = await config.onAction(result);\n return response;\n });\n channelProvider.register(TOPIC_NAME_GET_RESULTS, async (payload) => {\n const request = Object.assign({}, searchListenerRequest, payload);\n const response = await config.onSearch(request, searchListenerResponse);\n return response.results;\n });\n\n return {\n configData: configuration,\n hideWindow: async function (): Promise<void> {\n console.warn('Function not implemented.');\n },\n id,\n isReady: async function (ready?: boolean): Promise<void> {\n console.warn('Function not implemented.');\n },\n name,\n showWindow: async function (): Promise<void> {\n console.warn('Function not implemented.');\n },\n };\n};\n\nexport type {\n ActionedSearchResult,\n SearchActionResponse,\n SearchListenerRequest,\n SearchListenerResponse,\n SearchProvider,\n SearchProviderRegistrationConfig,\n SearchResponse,\n SearchResult,\n ShowWindowOptions,\n} from './search.types';\n"],"mappings":"0FAEO,IAAMA,EAAe,qBAE5B,eAAsBC,GAAoC,CACtD,GAAI,CACA,aAAM,OAAO,IAAI,KAAK,eAAe,EAAE,QAAQ,EACxC,EACX,MAAQ,CACJ,MAAO,EACX,CACJ,CAEO,SAASC,EAA2BC,EAAoC,CAC3E,GAAIA,EAAS,KAAK,WAAW,oBAAoB,EAC7C,MAAM,IAAI,MAAM,uCAAuC,EAG3D,MAAI,mBAAmB,KAAKA,EAAS,IAAI,EAC9BA,EAAS,KAAK,MAAM,GAAG,EAAE,CAAC,GAAK,GAGnCA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,EACV,KAAMA,CACV,EAEA,OADiB,MAAMR,EAAO,SAASW,CAAM,CAEjD,CAAC,EACDL,EAAgB,SAASd,EAAwB,MAAOe,GAAY,CAChE,IAAMK,EAAU,OAAO,OAAO,CAAC,EAAGlB,EAAuBa,CAAO,EAEhE,OADiB,MAAMP,EAAO,SAASY,EAAShB,CAAsB,GACtD,OACpB,CAAC,EAEM,CACH,WAAYM,EACZ,WAAY,gBAAiC,CACzC,QAAQ,KAAK,2BAA2B,CAC5C,EACA,GAAAC,EACA,QAAS,eAAgBU,EAAgC,CACrD,QAAQ,KAAK,2BAA2B,CAC5C,EACA,KAAAT,EACA,WAAY,gBAAiC,CACzC,QAAQ,KAAK,2BAA2B,CAC5C,CACJ,CACJ","names":["PACKAGE_NAME","isInViewContext","extractAppUuidFromIdentity","identity","PACKAGE_NAME","getChannelName","notificationsClientPromise","getNotificationsClient","getNotificationsClientInternal","isInViewContext","extractAppUuidFromIdentity","channelPromise","getChannelClient","message","listener","eventListeners","eventName","listeners","options","notificationId","channelClientPromise","getChannelClientInternal","channel","identity","apiChannelClientPromise","getApiChannelName","getApiChannelClient","getAppSettings","PACKAGE_NAME","isInViewContext","getAppUserSettings","setAppUserSettings","settings","getAppUserPermissions","launchContent","id","options","channel","error","launchSupertab","launchWorkspace","search_exports","__export","register","TOPIC_NAME_GET_RESULTS","TOPIC_NAME_HANDLE_ACTION","searchListenerRequest","listener","searchListenerResponse","results","resultKeys","context","config","windowOptions","configuration","id","name","channelName","channelProvider","payload","searchResult","actionId","viewIdentity","result","request","ready"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfin/cloud-api",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.fffeb9a",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"exports": {
|
|
@@ -14,28 +14,31 @@
|
|
|
14
14
|
"module": "./dist/index.js",
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "tsup --config ./tsup.config.ts",
|
|
17
|
-
"
|
|
17
|
+
"dev": "tsup --watch --config ./tsup.config.ts",
|
|
18
|
+
"typecheck": "tsc --noEmit",
|
|
19
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
20
|
+
"lint": "eslint . --max-warnings 0",
|
|
21
|
+
"lint:fix": "eslint . --fix --max-warnings 0"
|
|
18
22
|
},
|
|
19
23
|
"files": [
|
|
20
24
|
"dist"
|
|
21
25
|
],
|
|
22
26
|
"dependencies": {
|
|
23
|
-
"@openfin/core": "
|
|
24
|
-
"openfin-notifications": "^2.3.2"
|
|
27
|
+
"@openfin/core": "38.83.84"
|
|
25
28
|
},
|
|
26
29
|
"devDependencies": {
|
|
27
|
-
"@
|
|
28
|
-
"@typescript-eslint/
|
|
29
|
-
"eslint": "^
|
|
30
|
-
"eslint
|
|
30
|
+
"@openfin/workspace": "19.3.9",
|
|
31
|
+
"@typescript-eslint/eslint-plugin": "^7.5.0",
|
|
32
|
+
"@typescript-eslint/parser": "^7.15.0",
|
|
33
|
+
"eslint": "^8.57.0",
|
|
31
34
|
"eslint-config-prettier": "^9.1.0",
|
|
32
|
-
"eslint-plugin-check-file": "^2.
|
|
33
|
-
"eslint-plugin-prettier": "^5.1
|
|
34
|
-
"eslint-plugin-simple-import-sort": "^
|
|
35
|
-
"eslint-plugin-unicorn": "^
|
|
36
|
-
"prettier": "^3.
|
|
37
|
-
"tsup": "^8.0
|
|
38
|
-
"typescript": "^5.
|
|
35
|
+
"eslint-plugin-check-file": "^2.8.0",
|
|
36
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
37
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
38
|
+
"eslint-plugin-unicorn": "^55.0.0",
|
|
39
|
+
"prettier": "^3.3.3",
|
|
40
|
+
"tsup": "^8.3.0",
|
|
41
|
+
"typescript": "^5.6.3"
|
|
39
42
|
},
|
|
40
43
|
"eslintConfig": {
|
|
41
44
|
"env": {
|
|
@@ -179,9 +182,7 @@
|
|
|
179
182
|
"varsIgnorePattern": "^_"
|
|
180
183
|
}
|
|
181
184
|
],
|
|
182
|
-
"@typescript-eslint/no-explicit-any":
|
|
183
|
-
"warn"
|
|
184
|
-
]
|
|
185
|
+
"@typescript-eslint/no-explicit-any": 1
|
|
185
186
|
},
|
|
186
187
|
"ignorePatterns": [
|
|
187
188
|
"node_modules",
|