Skip to content

Commit 4712b4c

Browse files
committed
Merge pull request #6 from feat/optional-return-payload
Make return values of Graphic methods optionally be undefined
2 parents 68710c1 + 458acd9 commit 4712b4c

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ The log below details the changes during development of this version:
1717
* 2025-05-16: Add `renderRequirements` property to Graphics manifest
1818
* 2025-05-16: Add `data` argument to the `load` method.
1919
Before, the `data`-payload was only sent using the `updateData()` method. Now it must be sent on `load()` as well.
20+
* 2025-05-16: Change return values of Graphic methods to optionally be `undefined`.
21+
(An `undefined` value should be treated as `{ code: 200 }`)

v1-draft-0/specification/docs/Specification.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,11 @@ Depending on the rendering capabilities (defined in the Manifest file), a Graphi
175175
To describe the functions in this document, the Typescript interface notation is used. For simplicity, we omit the indication
176176
that vendor-specific fields can be included in both request and response payloads.
177177
For the 'action' methods (`playAction()`, `stopAction()`, `updateAction()` and `customAction()`), a Promise MUST be returned that
178-
resolves to an `ReturnPayload` object containing the following fields:
178+
resolves to `undefined` or to an `ReturnPayload` object containing the following fields:
179179
* `code`: a number that corresponds to an HTTP status code (2xx indicates a successful result, 4xx and 5xx indicate an error).
180180
* `message`: an optional human-readable message that corresponds to the `code`.
181181
* `result`: an optional Graphics-specific response object.
182+
If the returned Promise resolves to `undefined`, it should be treated as a `{ code: 200 }`.
182183

183184
Similarly, for simplicity reasons, we omit these three fields in the description of the functions below.
184185
In [Typescript interface](#typescript-interface-for-graphic), the full interface is provided.

v1-draft-0/typescript-definitions/src/apis/graphicsAPI.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface Graphic {
3737
/** A set of characteristics / capabilities of the Renderer, that affects how the Graphic will be rendered. */
3838
renderCharacteristics: RenderCharacteristics;
3939
} & VendorExtend
40-
) => Promise<ReturnPayload>;
40+
) => Promise<ReturnPayload | undefined>;
4141

4242
/**
4343
* Called by the Renderer to force the Graphic to terminate/dispose/clear any loaded resources.
@@ -51,7 +51,7 @@ export interface Graphic {
5151
/** The data send here is defined in the manifest "schema". Note: This data MUST HAVE the same type as the `data` argument in the load method. */
5252
data: unknown;
5353
} & VendorExtend
54-
) => Promise<ReturnPayload>;
54+
) => Promise<ReturnPayload | undefined>;
5555

5656
/** This is called when user calls the "play" action. */
5757
playAction: (
@@ -68,21 +68,23 @@ export interface Graphic {
6868
/** This is called when user calls the "stop" action. */
6969
stopAction: (
7070
params: { skipAnimation: boolean } & VendorExtend
71-
) => Promise<ReturnPayload>;
71+
) => Promise<ReturnPayload | undefined>;
7272

7373
/**
7474
* Called by the Renderer to invoke an Action on the Graphic
7575
* @returns The return value of the invoked method (vendor-specific)
7676
*/
77-
customAction: (params: ActionInvokeParams) => Promise<ReturnPayload>;
77+
customAction: (
78+
params: ActionInvokeParams
79+
) => Promise<ReturnPayload | undefined>;
7880

7981
/**
8082
* If the Graphic supports non-realtime rendering, this is called to make the graphic jump to a certain point in time.
8183
* @returns A Promise that resolves when the Graphic has finished rendering the requested frame.
8284
*/
8385
goToTime: (
8486
params: { timestamp: number } & VendorExtend
85-
) => Promise<ReturnPayload>;
87+
) => Promise<ReturnPayload | undefined>;
8688

8789
/**
8890
* If the Graphic supports non-realtime rendering, this is called to schedule actions to be invoked at a certain point in time.
@@ -116,6 +118,5 @@ export interface Graphic {
116118
} & VendorExtend);
117119
}[];
118120
} & VendorExtend
119-
) => Promise<EmptyPayload>;
121+
) => Promise<EmptyPayload | undefined>;
120122
}
121-

v1-draft-0/typescript-definitions/src/definitions/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export type ActionInvokeParams = {
4242
payload: unknown;
4343
} & VendorExtend;
4444

45-
export type PlayActionReturnPayload = ReturnPayload & {
45+
export type PlayActionReturnPayload = (ReturnPayload | {}) & {
4646
/** The resulting step from a PlayAction */
47-
currentStep: number
48-
}
47+
currentStep: number;
48+
};

0 commit comments

Comments
 (0)