Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions samples/010-TokenExample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ none

Add this plugin as part of any screen.
Add an application as part of the plugin configuration.
Ensure that the application has access to the getSubscriptions API.
If the application has been properly configured, it will return a popup window with the result of the getSubscriptions API
Ensure that the application has access to the resources API.
If the application has been properly configured, it will return a popup window with the list of resources retrieved through the getAllResources API
If the application is missing, it will return an alert indicating that the proxy has not been created.
If the application doesn't have the right permission configured, it will show the response in the popup window.

Expand Down
16 changes: 8 additions & 8 deletions samples/010-TokenExample/assets/js/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
OFSOpenMessage,
OFSCallProcedureResultMessage,
} from "@ofs-users/plugin";
import { OFSSubscriptionResponse } from "@ofs-users/proxy";
import { OFSResponse } from "@ofs-users/proxy";
class OFSCustomOpenMessage extends OFSOpenMessage {
activity: any;
openParams: any;
Expand All @@ -29,23 +29,23 @@ export class CustomPlugin extends OFSPlugin {
console.debug(`${this.tag} : OPEN: ${JSON.stringify(data)}`);
var plugin = this;
if (this.proxy) {
this.getSubscriptions();
this.getResources();
} else {
alert(
"Proxy not available. Review if you have included an application in the plugin configuration and it you have, review the logs for any errors."
);
this.close();
}
}
async getSubscriptions() {
const subscriptions_list: OFSSubscriptionResponse =
await this.proxy.getSubscriptions();
async getResources() {
const resourcesList: OFSResponse =
await this.proxy.getAllResources();
console.debug(
`${this.tag} : Subscriptions: ${JSON.stringify(subscriptions_list)}`
`${this.tag} : Resources: ${JSON.stringify(resourcesList)}`
);
alert(
`Subscriptions captured successfully ${JSON.stringify(
subscriptions_list
`Resources captured successfully ${JSON.stringify(
resourcesList
)}`
);
this.close();
Expand Down
8 changes: 4 additions & 4 deletions samples/010-TokenExample/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion samples/010-TokenExample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"webpack-cli": "^5.0.1"
},
"dependencies": {
"@ofs-users/plugin": "^1.5.0",
"@ofs-users/plugin": "^1.8.0",
"@ofs-users/proxy": "^1.30.0",
"buffer": "^6.0.3"
}
Expand Down
40 changes: 35 additions & 5 deletions samples/020-InitDataLoading/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,42 @@ This pattern is useful when you need to:

1. **Init**: Plugin receives configuration, stores it, and requests a wakeup after a delay
2. **Sleep**: Plugin waits for the configured delay
3. **Wakeup**: Plugin creates an API proxy, fetches resource data, stores it in localStorage
3. **Wakeup**: Plugin requests a scoped access token, creates an API proxy, fetches resource data, stores it in localStorage
4. **Open**: Plugin displays the previously retrieved data to the user

## Configuration via descriptor.json

The plugin is configured using secured parameters in `descriptor.json`.

The wakeup proxy also requires the OFS runtime `environment` object:

| Runtime field | Required | Description |
|---------------|----------|-------------|
| `environment.environmentName` | Yes | Environment name used to build the Fusion token scope |
| `environment.fsUrl` | Yes | OFS REST base URL used by the proxy |

## URL and Scope Selection

This sample invokes Fusion Field Service APIs, also called FusionFS APIs, through `environment.fsUrl`.

| API call | URL source | Token scope |
|----------|------------|-------------|
| `OFS.getResource(resourceId)` | `environment.fsUrl` | `urn:opc:resource:fusion:${environment.environmentName.toLowerCase()}:field-service-common/use` |

For FusionFS / `fsUrl` calls, the access token scope is built from the lowercase environment name:

```text
urn:opc:resource:fusion:${environment.environmentName.toLowerCase()}:field-service-common/use
```

For example, `environment.environmentName = "ETAQ-DEV4"` creates:

```text
urn:opc:resource:fusion:etaq-dev4:field-service-common/use
```

This sample does not call Fusion Applications APIs through `environment.faUrl`.

### descriptor.json Structure

```json
Expand Down Expand Up @@ -166,9 +195,10 @@ Formatted for readability (the actual value must be a single-line escaped JSON s

This configuration will:
1. Wait 10 seconds after initialization
2. Fetch the resource with `resourceId = "my_data_bucket"`
3. Extract properties `PA_DATA_01` and `PA_DATA_02`
4. Store the values in localStorage for display when opened
2. Request an OFS access token using `getAccessTokenByScope`
3. Fetch the resource with `resourceId = "my_data_bucket"`
4. Extract properties `PA_DATA_01` and `PA_DATA_02`
5. Store the values in localStorage for display when opened

## Building the Plugin

Expand All @@ -191,7 +221,7 @@ npm test

## Dependencies

- `@ofs-users/plugin`: ^1.5.2 - OFS plugin base class
- `@ofs-users/plugin`: ^1.8.0 - OFS plugin base class with scoped token support
- `@ofs-users/proxy`: ^1.27.0 - OFS REST API proxy

## License
Expand Down
Loading