Skip to content

Commit f4a46c0

Browse files
authored
Merge pull request #1127 from finos/1107-fix-intent-result-type-in-2.0
Correcting IntentResult error in FDC3 2.0 and adding a very minor clarification to 2.1/next
2 parents 29c90c7 + cc68903 commit f4a46c0

7 files changed

Lines changed: 16 additions & 10 deletions

File tree

docs/api/spec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ As an alternative to raising a specific intent, you may also raise an unspecifie
225225

226226
### Intent Results
227227

228-
An optional [`IntentResult`](ref/Types#intentresult) may also be returned as output by an application handling an intent. Results maybe either a single `Context` object, or a `Channel` that may be used to send a stream of responses. The [`PrivateChannel`](ref/PrivateChannel) type is provided to support synchronization of data transmitted over returned channels, by allowing both parties to listen for events denoting subscription and unsubscription from the returned channel. `PrivateChannels` are only retrievable via [raising an intent](ref/DesktopAgent#raiseintent).
228+
An optional [`IntentResult`](ref/Types#intentresult) may also be returned as output by an application handling an intent. Results may be a single `Context` object, a `Channel` that may be used to send a stream of responses, or `void` (no result). The [`PrivateChannel`](ref/PrivateChannel) type is provided to support synchronization of data transmitted over returned channels, by allowing both parties to listen for events denoting subscription and unsubscription from the returned channel. `PrivateChannels` are only retrievable via [raising an intent](ref/DesktopAgent#raiseintent).
229229

230230
For example, an application handling a `CreateOrder` intent might return a context representing the order and including an ID, allowing the application that raised the intent to make further calls using that ID.
231231

website/versioned_docs/version-2.0/api/ref/DesktopAgent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ If you wish to raise an intent without a context, use the `fdc3.nothing` context
642642
643643
Returns an [`IntentResolution`](Metadata#intentresolution) object with details of the app instance that was selected (or started) to respond to the intent.
644644
645-
Issuing apps may optionally wait on the promise that is returned by the `getResult()` member of the IntentResolution. This promise will resolve when the _receiving app's_ intent handler function returns and resolves a promise. The Desktop Agent resolves the issuing app's promise with the Context object or Channel that is provided as resolution by the receiving app. The Desktop Agent MUST reject the issuing app's promise, with a string from the [`ResultError`](Errors#resulterror) enumeration, if: (1) the intent handling function's returned promise rejects, (2) the intent handling function doesn't return a promise, or (3) the returned promise resolves to an invalid type.
645+
Issuing apps may optionally wait on the promise that is returned by the `getResult()` member of the `IntentResolution`. This promise will resolve when the _receiving app's_ intent handler function returns and resolves a promise. The Desktop Agent resolves the issuing app's promise with the Context object, Channel object or void that is provided as resolution within the receiving app. The Desktop Agent MUST reject the issuing app's promise, with a string from the [`ResultError`](Errors#resulterror) enumeration, if: (1) the intent handling function's returned promise rejects, (2) the intent handling function doesn't return a valid response (a promise or void), or (3) the returned promise resolves to an invalid type.
646646
647647
#### Example
648648

website/versioned_docs/version-2.0/api/ref/Errors.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ Contains constants representing the errors that can be encountered when calling
122122

123123
```typescript
124124
enum ResultError {
125-
/** Returned if the `IntentHandler` exited without returning a Promise or that
126-
* Promise was not resolved with a Context or Channel object.
125+
/** Returned if the intent handler exited without returning a valid result
126+
* (a promise resolving to a Context, Channel object or void).
127127
*/
128128
NoResultReturned = 'NoResultReturned',
129129

website/versioned_docs/version-2.0/api/ref/Metadata.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,9 @@ interface IntentResolution {
345345
* receive a stream of data.
346346
*
347347
* If an error occurs (i.e. an error is thrown by the handler function,
348-
* the promise it returns is rejected, or a promise is not returned by the
349-
* handler function) then the Desktop Agent MUST reject the promise returned
350-
* by the `getResult()` function of the `IntentResolution` with a string from
348+
* the promise it returns is rejected, or the promise resolved to an invalid
349+
* type) then the Desktop Agent MUST reject the promise returned by the
350+
* `getResult()` function of the `IntentResolution` with a string from
351351
* the `ResultError` enumeration.
352352
*/
353353
getResult(): Promise<IntentResult>;

website/versioned_docs/version-2.0/api/ref/Types.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,19 @@ Optional metadata about the intent & context message, including the app that ori
104104
## `IntentResult`
105105

106106
```typescript
107-
type IntentResult = Context | Channel;
107+
type IntentResult = Context | Channel | void;
108108
```
109109

110110
Describes results that an Intent handler may optionally return that should be communicated back to the app that raised the intent, via the [`IntentResolution`](Metadata#intentresolution).
111111

112112
Represented as a union type in TypeScript, however, this type may be rendered as an interface in other languages that both the `Context` and `Channel` types implement, allowing either to be returned by an `IntentHandler`.
113113

114+
:::info
115+
116+
The original release of FDC3 2.0 contained an error in the `IntentResult` type, which omitted `void` as a valid return type. It was intended that an `IntentHandler` be able to return either `void` or a Promise that resolves to `void` and, as these are valid results, no error should be thrown by `IntentResolution.getResult()`. This was corrected in FDC3 2.1 and retrospectively corrected in FDC3 2.0.
117+
118+
:::
119+
114120
#### See also
115121

116122
* [`Context`](#context)

website/versioned_docs/version-2.0/api/spec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ As an alternative to raising a specific intent, you may also raise an unspecifie
222222

223223
### Intent Results
224224

225-
An optional [`IntentResult`](ref/Types#intentresult) may also be returned as output by an application handling an intent. Results maybe either a single `Context` object, or a `Channel` that may be used to send a stream of responses. The [`PrivateChannel`](ref/PrivateChannel) type is provided to support synchronization of data transmitted over returned channels, by allowing both parties to listen for events denoting subscription and unsubscription from the returned channel. `PrivateChannels` are only retrievable via [raising an intent](ref/DesktopAgent#raiseintent).
225+
An optional [`IntentResult`](ref/Types#intentresult) may also be returned as output by an application handling an intent. Results may be a single `Context` object, a `Channel` that may be used to send a stream of responses, or `void` (no result). The [`PrivateChannel`](ref/PrivateChannel) type is provided to support synchronization of data transmitted over returned channels, by allowing both parties to listen for events denoting subscription and unsubscription from the returned channel. `PrivateChannels` are only retrievable via [raising an intent](ref/DesktopAgent#raiseintent).
226226

227227
For example, an application handling a `CreateOrder` intent might return a context representing the order and including an ID, allowing the application that raised the intent to make further calls using that ID.
228228

website/versioned_docs/version-2.1/api/spec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ As an alternative to raising a specific intent, you may also raise an unspecifie
225225

226226
### Intent Results
227227

228-
An optional [`IntentResult`](ref/Types#intentresult) may also be returned as output by an application handling an intent. Results maybe either a single `Context` object, or a `Channel` that may be used to send a stream of responses. The [`PrivateChannel`](ref/PrivateChannel) type is provided to support synchronization of data transmitted over returned channels, by allowing both parties to listen for events denoting subscription and unsubscription from the returned channel. `PrivateChannels` are only retrievable via [raising an intent](ref/DesktopAgent#raiseintent).
228+
An optional [`IntentResult`](ref/Types#intentresult) may also be returned as output by an application handling an intent. Results may be a single `Context` object, a `Channel` that may be used to send a stream of responses, or `void` (no result). The [`PrivateChannel`](ref/PrivateChannel) type is provided to support synchronization of data transmitted over returned channels, by allowing both parties to listen for events denoting subscription and unsubscription from the returned channel. `PrivateChannels` are only retrievable via [raising an intent](ref/DesktopAgent#raiseintent).
229229

230230
For example, an application handling a `CreateOrder` intent might return a context representing the order and including an ID, allowing the application that raised the intent to make further calls using that ID.
231231

0 commit comments

Comments
 (0)