@openfin/salesforce-lwc 1.0.1 → 1.1.1
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/LICENSE.md +21 -21
- package/README.md +31 -199
- package/openfin.salesforce-lwc.js +1 -0
- package/package.json +7 -3
- package/preload.js +1 -0
- package/types/index.d.ts +6 -0
- package/types/lwc/lwc.d.ts +23 -0
- package/types/preload.d.ts +1 -0
- package/api.js +0 -1
- package/index.d.ts +0 -1
- package/lwc/lwc.d.ts +0 -14
- package/lwc/lwc.spec.d.ts +0 -1
- package/openfin-salesforce-lwc-v1.0.1.tgz +0 -0
- package/version.txt +0 -1
package/LICENSE.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c)
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 OpenFin Ltd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,199 +1,31 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
OpenFin’s
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
or
|
|
33
|
-
|
|
34
|
-
```
|
|
35
|
-
yarn add @openfin/salesforce-lwc
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Using the API
|
|
39
|
-
|
|
40
|
-
### Create a preload script
|
|
41
|
-
|
|
42
|
-
The OpenFin app that Salesforce will be running in will need to run a preload script that calls the `prepareFinApiInPreload()` function:
|
|
43
|
-
|
|
44
|
-
```ts
|
|
45
|
-
// preload.ts
|
|
46
|
-
|
|
47
|
-
import { prepareFinApiInPreload } from '@openfin/salesforce-lwc';
|
|
48
|
-
|
|
49
|
-
(() => {
|
|
50
|
-
// Prepare OpenFin LWC support
|
|
51
|
-
prepareFinApiInPreload();
|
|
52
|
-
})();
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
Note: Using a bundling tool such as [webpack](https://webpack.js.org/) ensures that required dependencies are included with your compiled preload script.
|
|
56
|
-
|
|
57
|
-
### Add the preload script to your app
|
|
58
|
-
|
|
59
|
-
To ensure the compiled preload script is run before app content is loaded, it must be added to your OpenFin app’s manifest.
|
|
60
|
-
|
|
61
|
-
#### **For platform applications**
|
|
62
|
-
|
|
63
|
-
When using a [platform](https://developers.openfin.co/docs/platform-api) application, preload scripts can be added in three places:
|
|
64
|
-
|
|
65
|
-
- Platform level: add `preloadScripts` to the `platform` property in your config:
|
|
66
|
-
|
|
67
|
-
```jsonc
|
|
68
|
-
{
|
|
69
|
-
"platform": {
|
|
70
|
-
"preloadScripts": [
|
|
71
|
-
{
|
|
72
|
-
"url": "https://path.to/your/preload_script.js"
|
|
73
|
-
}
|
|
74
|
-
]
|
|
75
|
-
}
|
|
76
|
-
// ...
|
|
77
|
-
}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
- Window level: add `preloadScripts` to the `defaultWindowOptions` property in your config:
|
|
81
|
-
|
|
82
|
-
```jsonc
|
|
83
|
-
{
|
|
84
|
-
"platform": {
|
|
85
|
-
"defaultWindowOptions": {
|
|
86
|
-
"preloadScripts": [
|
|
87
|
-
{
|
|
88
|
-
"url": "https://path.to/your/preload_script.js"
|
|
89
|
-
}
|
|
90
|
-
]
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
// ...
|
|
94
|
-
}
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
- View level: add `preloadScripts` to the `defaultViewOptions` property in your config:
|
|
98
|
-
|
|
99
|
-
```jsonc
|
|
100
|
-
{
|
|
101
|
-
"platform": {
|
|
102
|
-
"defaultViewOptions": {
|
|
103
|
-
"preloadScripts": [
|
|
104
|
-
{
|
|
105
|
-
"url": "https://path.to/your/preload_script.js"
|
|
106
|
-
}
|
|
107
|
-
]
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
// ...
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
#### **For non-platform applications**
|
|
115
|
-
|
|
116
|
-
If it is a traditional OpenFin app with a `startup_app` entry, then add `preloadScripts` to the `startup_app` property in your config:
|
|
117
|
-
|
|
118
|
-
```jsonc
|
|
119
|
-
{
|
|
120
|
-
"startup_app": {
|
|
121
|
-
"preloadScripts": [
|
|
122
|
-
{
|
|
123
|
-
"url": "https://path.to/your/preload_script.js"
|
|
124
|
-
}
|
|
125
|
-
]
|
|
126
|
-
}
|
|
127
|
-
// ...
|
|
128
|
-
}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### Add the API to your Salesforce org as a static resource
|
|
132
|
-
|
|
133
|
-
To load this API from within a Salesforce component, you will first need to add it as a [static resource](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_resources.htm) in your Salesforce org.
|
|
134
|
-
|
|
135
|
-
_Note: the compiled API JS file can be found in the `@openfin/salesforce-lwc` folder within your OpenFin app’s `node_modules` folder after installing this package_.
|
|
136
|
-
|
|
137
|
-
1. On the main Setup page for your org, search for "static resources" and click on the relevant result.
|
|
138
|
-
2. Click the "New" button to add a new static resource.
|
|
139
|
-
3. Complete the form as directed:
|
|
140
|
-
- Name: "openfin_salesforce_lwc"
|
|
141
|
-
- Description: "Client library for enabling the use of OpenFin’s Javascript API in Salesforce components."
|
|
142
|
-
- File: "<path_to_app_node_modules>/@openfin/salesforce-lwc/api.js"
|
|
143
|
-
- Cache Control: "Public"
|
|
144
|
-
4. Click "Save" to create the static resource.
|
|
145
|
-
|
|
146
|
-
### Call the API within a custom Salesforce component
|
|
147
|
-
|
|
148
|
-
#### **For Lightning web components**
|
|
149
|
-
|
|
150
|
-
To use the API in a Lightning web component, you must first load the static resource as a [third-party library](https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.js_third_party_library).
|
|
151
|
-
|
|
152
|
-
With the static resource loaded, the API functions are added to `window.fin.salesforce`. Call the `initFinApiInLwc()` function before calling any OpenFin JS API functions in `window.fin`:
|
|
153
|
-
|
|
154
|
-
```ts
|
|
155
|
-
// Initialise window.fin for use
|
|
156
|
-
window.fin.salesforce.initFinApiInLwc();
|
|
157
|
-
|
|
158
|
-
// window.fin is now ready to use
|
|
159
|
-
const runtimeInfo = await window.fin.System.getRuntimeInfo();
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
Here is a complete example of a Lightning web component loading the static resource and using the OpenFin JS API:
|
|
163
|
-
|
|
164
|
-
```ts
|
|
165
|
-
// myComponent.js
|
|
166
|
-
|
|
167
|
-
import api from '@salesforce/resourceUrl/openfin_salesforce_lwc';
|
|
168
|
-
import { loadScript } from 'lightning/platformResourceLoader';
|
|
169
|
-
import { LightningElement } from 'lwc';
|
|
170
|
-
|
|
171
|
-
export default class OpenfinIntegrationTest extends LightningElement {
|
|
172
|
-
async connectedCallback() {
|
|
173
|
-
try {
|
|
174
|
-
await loadScript(this, api);
|
|
175
|
-
} catch (err) {
|
|
176
|
-
console.warn('Failed to load static resource, has it been added in Salesforce org settings?');
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// Initialise window.fin for use
|
|
181
|
-
window.fin.salesforce.initFinApiInLwc();
|
|
182
|
-
|
|
183
|
-
// Output the current OpenFin runtime info to the console
|
|
184
|
-
console.log(await window.fin.System.getRuntimeInfo());
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
#### **For Aura components**
|
|
190
|
-
|
|
191
|
-
To use the API in your Aura component, add a `<ltng:require>` tag to your component and use the [`$Resource`](https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/expr_resource_value_provider.htm) global value provider to reference the static resource:
|
|
192
|
-
|
|
193
|
-
```xml
|
|
194
|
-
<aura:component>
|
|
195
|
-
<ltng:require
|
|
196
|
-
scripts="{!$Resource.openfin_salesforce_lwc}"
|
|
197
|
-
afterScriptsLoaded="{!c.scriptsLoaded}" />
|
|
198
|
-
</aura:component>
|
|
199
|
-
```
|
|
1
|
+
# Salesforce Integration for Lightning Web Components
|
|
2
|
+
|
|
3
|
+
Access OpenFin’s [Container APIs](https://developers.openfin.co/of-docs/docs/container-overview) from custom [Salesforce components](https://developer.salesforce.com/docs/component-library/documentation/en/lwc).
|
|
4
|
+
|
|
5
|
+
_Alternatively, when calling Salesforce’s REST APIs directly from OpenFin apps, use the [@openfin/salesforce](https://www.npmjs.com/package/@openfin/salesforce) package._
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
With npm:
|
|
10
|
+
|
|
11
|
+
> npm -i @openfin/salesforce-lwc
|
|
12
|
+
|
|
13
|
+
With yarn:
|
|
14
|
+
|
|
15
|
+
> yarn add @openfin/salesforce-lwc
|
|
16
|
+
|
|
17
|
+
## Usage and more information
|
|
18
|
+
|
|
19
|
+
- [Developer guide](https://developers.openfin.co/of-docs/docs/salesforce-integration)
|
|
20
|
+
- [API reference](https://cdn.openfin.co/docs/integrations/salesforce)
|
|
21
|
+
|
|
22
|
+
## License
|
|
23
|
+
|
|
24
|
+
Copyright 2021-2022 OpenFin
|
|
25
|
+
|
|
26
|
+
The code in this package is distributed under the MIT license.
|
|
27
|
+
|
|
28
|
+
However, if you run this code, it may call on the OpenFin RVM or OpenFin Runtime, which are covered by OpenFin's Developer, Community, and Enterprise licenses. You can learn more about OpenFin licensing at the links listed below or email us at support@openfin.co with questions.
|
|
29
|
+
|
|
30
|
+
- [Licensing](https://www.openfin.co/licensing/)
|
|
31
|
+
- [Developer agreement](https://openfin.co/developer-agreement/)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("fin",[],n):"object"==typeof exports?exports.fin=n():(e.fin=e.fin||{},e.fin.salesforce=n())}(self,(function(){return(()=>{"use strict";var e={d:(n,o)=>{for(var i in o)e.o(o,i)&&!e.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:o[i]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};e.r(n),e.d(n,{initFinApiInLwc:()=>i,prepareFinApiInPreload:()=>o});const o=()=>{void 0!==window.fin&&(CustomEvent.prototype.fin=window.fin,CustomEvent.prototype.fdc3=window.fdc3)},i=()=>{const e=new CustomEvent(""),n=e.fin;if(void 0===n)return void console.warn("Unable to locate fin API. Ensure Salesforce is running in OpenFin and 'prepareFinApiInPreload' is run in a preload script before attempting to call 'initFinApiInLwc'.");void 0!==window.fin?Object.assign(window.fin,n):window.fin=n;const o=e.fdc3;void 0!==window.fdc3?Object.assign(window.fdc3,o):window.fdc3=o};return n})()}));
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfin/salesforce-lwc",
|
|
3
3
|
"description": "Connect custom Salesforce components with OpenFin Container",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.1",
|
|
5
5
|
"author": "OpenFin Inc.",
|
|
6
6
|
"homepage": "https://www.openfin.co/",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"openfin",
|
|
9
|
+
"salesforce"
|
|
10
|
+
],
|
|
7
11
|
"license": "MIT",
|
|
8
|
-
"main": "
|
|
9
|
-
"types": "index.d.ts"
|
|
12
|
+
"main": "openfin.salesforce-lwc.js",
|
|
13
|
+
"types": "types/index.d.ts"
|
|
10
14
|
}
|
package/preload.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{"use strict";void 0!==window.fin&&(CustomEvent.prototype.fin=window.fin,CustomEvent.prototype.fdc3=window.fdc3)})();
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="openfin" />
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
fdc3: typeof fdc3;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* @hidden
|
|
9
|
+
*/
|
|
10
|
+
export declare type CustomFinEvent = CustomEvent & {
|
|
11
|
+
fin: typeof fin;
|
|
12
|
+
fdc3: typeof fdc3;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Prepares the OpenFin API for use in custom Salesforce components.
|
|
16
|
+
*
|
|
17
|
+
* Note: This function must be run in a preload script before any Salesforce content is loaded.
|
|
18
|
+
*/
|
|
19
|
+
export declare const prepareFinApiInPreload: () => void;
|
|
20
|
+
/**
|
|
21
|
+
* Initializes the OpenFin API for use in custom Salesforce components.
|
|
22
|
+
*/
|
|
23
|
+
export declare const initFinApiInLwc: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/api.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.fin=n():(e.fin=e.fin||{},e.fin.salesforce=n())}(self,function(){return(()=>{"use strict";var t={114:function(e,n,i){var t=this&&this.__createBinding||(Object.create?function(e,n,i,t){void 0===t&&(t=i),Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[i]}})}:function(e,n,i,t){e[t=void 0===t?i:t]=n[i]}),o=this&&this.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(n,"__esModule",{value:!0}),o(i(81),n)},81:(e,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.initFinApiInLwc=n.prepareFinApiInPreload=void 0,n.prepareFinApiInPreload=()=>{void 0!==window.fin&&(CustomEvent.prototype.fin=window.fin)},n.initFinApiInLwc=()=>{var e=new CustomEvent("").fin;if(void 0===e)throw new Error("fin API is undefined. Ensure 'prepareFinApiInPreload' is run in a preload script before attempting to call 'initFinApiInLwc'.");void 0===window.fin?window.fin=e:Object.assign(window.fin,e)}}},o={};return function e(n){var i=o[n];if(void 0!==i)return i.exports;i=o[n]={exports:{}};return t[n].call(i.exports,i,i.exports,e),i.exports}(114)})()});
|
package/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './lwc/lwc';
|
package/lwc/lwc.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/// <reference types="openfin" />
|
|
2
|
-
export declare type CustomFinEvent = CustomEvent & {
|
|
3
|
-
fin: typeof fin;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* Prepares `fin` API to be used in a Lightning Web Component.
|
|
7
|
-
* This function should be run in a preload script before any Salesforce content is loaded.
|
|
8
|
-
*/
|
|
9
|
-
export declare const prepareFinApiInPreload: () => void;
|
|
10
|
-
/**
|
|
11
|
-
* Restores the `fin` API object to `window` in the context of a Lightning Web Component.
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
export declare const initFinApiInLwc: () => void;
|
package/lwc/lwc.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import 'jest';
|
|
Binary file
|
package/version.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1.0.1
|