From 6a783d050a7bc62ca34ab000c49368a9a47d0cab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emanuel=20Tesa=C5=99?= Date: Sat, 18 Nov 2023 18:34:35 +0100 Subject: [PATCH 1/8] Document processing v2 --- .vscode/settings.json | 5 +- docs/reference/ois/next/processing.md | 84 ++++++++++++++++-- docs/reference/ois/next/specification.md | 103 +++++++++++++++++------ 3 files changed, 162 insertions(+), 30 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index ee4e98e3..89ddf7e2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -75,5 +75,8 @@ ], "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true, - "search.useIgnoreFiles": false + "search.useIgnoreFiles": false, + "editor.rulers": [ + 80 + ] } diff --git a/docs/reference/ois/next/processing.md b/docs/reference/ois/next/processing.md index eef56484..7c7f7f26 100644 --- a/docs/reference/ois/next/processing.md +++ b/docs/reference/ois/next/processing.md @@ -19,6 +19,22 @@ tags: # {{$frontmatter.title}} +Processing allows Airnode operators to define custom logic that executes before +or after an API call. This feature is useful for multiple use cases, including: + +- Authentication +- Data transformation +- Data aggregation +- Data validation + +## Processing versions + +OIS specification has two versions of pre/post processing. Both versions serve +the same use cases, but the second version is more flexible and convenient. +Users are encouraged to use the second version. + +### v1 + The processing schema accepts an array of processing snippets (user defined code) which are chained. The first snippet receives parameters submitted as part of a template or on-chain request. The output of this snippet is passed to the @@ -51,7 +67,7 @@ Snippets for both specifications follow this schema: Try the [Post processing](/guides/airnode/post-processing/) guide to further understand pre/post processing. -## Input and Output +#### Input and Output The processing snippet receives an `input` value which is either the initial value or the output value from the previous processing snippet. The snippet must @@ -61,7 +77,7 @@ source code of Airnode to understand how processing works and what modules are made available to the snippet code. Modules cannot be imported directly in cloud environments. -## Accessing endpoint parameters +#### Accessing endpoint parameters Endpoint parameters, with the exception of reserved parameters, are accessible within pre-processing and post-processing via the immutable `endpointParameters` @@ -77,6 +93,61 @@ post-processing. ::: +### v2 + +The processing snippet receives parameters submitted as part of a template or +on-chain request. + +Airnode executes snippets for `preProcessingSpecificationV2` and +`postProcessingSpecificationV2` during its run cycle. The following describes +the work flow Airnode uses: + +1. Run `preProcessingSpecificationV2` +2. Airnode calls requested OIS endpoint +3. Run `postProcessingSpecificationV2` +4. Airnode encodes the response values defined by reservedParameters + +The processing schema is the same for both +[`preProcessingSpecificationV2`](/reference/ois/next/specification.md#_5-11-preprocessingspecificationv2) +and +[`postProcessingSpecificationV2`](/reference/ois/next/specification.md#_5-12-postprocessingspecificationv2). +Snippets for both specifications follow this schema: + +- `environment` - Currently only possible value is `Node`. This options + interprets the code as JavaScript and execute in Node.js. The function can be + also asynchronous (async/await is supported as well). The processing + implementation will wait for the function to resolve. +- `value` - The processing code written as a string. +- `timeoutMs` - The maximum timeout that this snippet can run. In case the + timeout is exceeded an error is thrown. + +Try the [Post processing](/guides/airnode/post-processing/) guide to further +understand pre/post processing. + +#### Input and Output + +The processing snippet is a function which receives payload as an argument. The +return value of the function is treated as a processing result. Apart from the +payload argument, you can use most Node.js built-in modules. + +The payload argument for pre-processing is an object with the following +properties: + +- `apiCallParameters` - The API call parameters with the exception of reserved + parameters. For example, if there was a parameter named `myParameter` defined + in the `endpoints[n].parameters` array, its value could be accessed using + `endpointParameters.myParameter` within pre-processing snippet. + + +The payload argument for post-processing is an object with the following +properties: + +- `apiCallResponse` - The API call response. +- `endpointParameters` - The API call parameters with the exception of reserved + parameters. For example, if there was a parameter named `myParameter` defined + in the `endpoints[n].parameters` array, its value could be accessed using + `endpointParameters.myParameter` within pre-processing snippet. + ## Interpolation Note, that config.json supports interpolation of secrets via the JavaScript @@ -84,7 +155,8 @@ string interpolation pattern (e.g `${SECRET_NAME}`). This syntax conflicts with the string interpolation inside the processing snippets. In order to use the interpolation in snippets, you need to escape the interpolation. -For example, the following code: +For example, the following code (using the v1 processing snippet, but the +concept is the same for v2): ```js console.log(`Received input ${input}`); @@ -125,8 +197,10 @@ Airnode to place on-chain. Instead of calling an API, Airnode uses the output of `preProcessingSpecifications`, `postProcessingSpecifications`, or both. The field `operation` must be undefined, `fixedOperationParameters` must be an empty -array and one of `preProcessingSpecifications` or `postProcessingSpecifications` -must be defined and not be an empty array. +array and some processing specification needs to be defined. This means that one +of `preProcessingSpecifications` or `postProcessingSpecifications` must be +defined and not be an empty array or `preProcessingSpecificationV2` or +`postProcessingSpecificationV2` must be defined. ### Use case: random number diff --git a/docs/reference/ois/next/specification.md b/docs/reference/ois/next/specification.md index a1000ba4..7393dee5 100644 --- a/docs/reference/ois/next/specification.md +++ b/docs/reference/ois/next/specification.md @@ -327,6 +327,10 @@ node. [preProcessingSpecifications](/reference/ois/next/specification.md#_5-9-preprocessingspecifications) - 5.10. [postProcessingSpecifications](/reference/ois/next/specification.md#_5-10-postprocessingspecifications) +- 5.11. + [preProcessingSpecificationV2](/reference/ois/next/specification.md#_5-11-preprocessingspecificationv2) +- 5.12. + [postProcessingSpecificationV2](/reference/ois/next/specification.md#_5-12-postprocessingspecificationv2) ```json // endpoints @@ -375,25 +379,16 @@ node. } } ], - "preProcessingSpecifications": [ - { - "environment": "Node", - "value": "const output = {...input, from: \"eth\"};", - "timeoutMs": "5000" - }, - { - "environment": "Node", - "value": "const output = {...input, from: input.from.toUpperCase()};", - "timeoutMs": "5000" - } - ], - "postProcessingSpecifications": [ - { - "environment": "Node", - "value": "const output = Math.round(input.price * 1000);", - "timeoutMs": "5000" - } - ] + "preProcessingSpecificationV2": { + "environment": "Node", + "value": "({ apiCallParameters }) => { return { apiCallParameters: {...apiCallParameters, from: 'ETH'} }; }", + "timeoutMs": 5000 + }, + "postProcessingSpecificationV2": { + "environment": "Node", + "value": "({ apiCallResponse }) => { return { apiCallResponse: parseInt(apiCallResponse.price) * 1000 }; }", + "timeoutMs": 5000 + } } ] ``` @@ -594,8 +589,16 @@ corresponding operation parameter.--> ### 5.9. `preProcessingSpecifications` \* -(Optional) Defines the preprocessing code that can be used to modify the -endpoint parameter before making the API request defined by an Airnode endpoint. +::: deprecation warning + +The `preProcessingSpecifications` field is deprecated. Use +`preProcessingSpecificationV2` instead. + +::: + +(Optional) Defines the pre-processing code that can be used to modify the +endpoint parameters before making the API request defined by an Airnode +endpoint. See the [Pre/Post Processing](/reference/ois/next/processing.md) doc for additional details. @@ -610,7 +613,7 @@ additional details. // Define a new "from" parameter with value "eth" "value": "const output = {...input, from: \"eth\"};", // Run for 5 seconds maximum - "timeoutMs": "5000" + "timeoutMs": 5000 }, { // Execute synchronously in Node.js @@ -618,13 +621,20 @@ additional details. // Uppercase the "from" parameter defined by the previous snippet "value": "const output = {...input, from: input.from.toUpperCase()};", // Run for 5 seconds maximum - "timeoutMs": "5000" + "timeoutMs": 5000 } ] ``` ### 5.10. `postProcessingSpecifications` \* +::: deprecation warning + +The `postProcessingSpecifications` field is deprecated. Use +`postProcessingSpecificationV2` instead. + +::: + (Optional) Defines the post-processing code that can be used to modify the API response from the request defined by an Airnode endpoint. @@ -641,7 +651,52 @@ additional details. // Multiply the API return value by 1000 and round it to an integer "value": "const output = Math.round(input.price * 1000);", // Run for 5 seconds maximum - "timeoutMs": "5000" + "timeoutMs": 5000 + } +] +``` + +### 5.11. `preProcessingSpecificationV2` \* + +(Optional) Defines the pre-processing code that can be used to modify the +endpoint parameters before making the API request defined by an Airnode +endpoint. + +See the [Pre/Post Processing](/reference/ois/next/processing.md) doc for +additional details. + +#### Example + +```json +"preProcessingSpecificationV2": { + // Execute in Node.js. The v2 specification supports both synchronous and asynchronous code + "environment": "Node", + // Define a new "from" parameter with value "ETH" + "value": "({ apiCallParameters }) => { return { apiCallParameters: {...apiCallParameters, from: 'ETH'} }; }", + // Run for 5 seconds maximum + "timeoutMs": 5000 +} +``` + +### 5.12. `postProcessingSpecificationV2` \* + +(Optional) Defines the post-processing code that can be used to modify the API +response from the request defined by an Airnode endpoint. + +See the [Pre/Post Processing](/reference/ois/next/processing.md) doc for +additional details. + +#### Example + +```json +"postProcessingSpecificationV2": [ + { + // Execute in Node.js. The v2 specification supports both synchronous and asynchronous code + "environment": "Node", + // Multiply the API return value by 1000 and round it to an integer + "value": "({ apiCallResponse }) => { return { apiCallResponse: parseInt(apiCallResponse.price * 1000) }; }", + // Run for 5 seconds maximum + "timeoutMs": 5000 } ] ``` From 12ef904f39900009106dd1395fac58f3a23c400e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emanuel=20Tesa=C5=99?= Date: Sat, 18 Nov 2023 18:46:17 +0100 Subject: [PATCH 2/8] Document processing response format --- docs/reference/ois/next/processing.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/reference/ois/next/processing.md b/docs/reference/ois/next/processing.md index 7c7f7f26..b9fa8782 100644 --- a/docs/reference/ois/next/processing.md +++ b/docs/reference/ois/next/processing.md @@ -138,6 +138,10 @@ properties: in the `endpoints[n].parameters` array, its value could be accessed using `endpointParameters.myParameter` within pre-processing snippet. +The output of the pre-processing snippet is an object with the following fields: + +- `apiCallParameters` - The pre-processed API call parameters. These are used to + make the API call. The payload argument for post-processing is an object with the following properties: @@ -148,6 +152,16 @@ properties: in the `endpoints[n].parameters` array, its value could be accessed using `endpointParameters.myParameter` within pre-processing snippet. +The output of the post-processing snippet is an object with the following +fields: + +- `apiCallResponse` - The post-processed API call response. This is used to + encode the response values defined by reservedParameters. +- `timestamp` - (Optional) The timestamp of the API call response. Use this if + you want Airnode to use a specific timestamp (instead of a current time at + request processing) when using the [signed data + gateway](https://docs.api3.org/reference/airnode/latest/understand/http-gateways.html#http-signed-data-gateway). + ## Interpolation Note, that config.json supports interpolation of secrets via the JavaScript From b4313116d2e63e80eed7c0b2ed13bf949aaec34a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emanuel=20Tesa=C5=99?= Date: Sat, 18 Nov 2023 19:10:30 +0100 Subject: [PATCH 3/8] Add example how to specify timestamp using post-processing --- docs/reference/ois/next/processing.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/reference/ois/next/processing.md b/docs/reference/ois/next/processing.md index b9fa8782..9af4a795 100644 --- a/docs/reference/ois/next/processing.md +++ b/docs/reference/ois/next/processing.md @@ -333,4 +333,24 @@ endpoints: [ ] ``` +## Example #3 + +One of the possible use cases for post-processing would be to use override the +timestamp used by [signed data +gateway](https://docs.api3.org/reference/airnode/latest/understand/http-gateways.html#http-signed-data-gateway). +By default the signed data gateway uses the timestamp of the request processing. +However, sometimes the API itself returns the timestamp. Modifying timestamp is +only supported with the v2 of the processing. + +```json +{ + "postProcessingSpecificationV2": { + "environment": "Node", + // Reuses the timestamp from the API call response. + "value": "async ({ apiCallResponse }) => { return { apiCallResponse, timestamp: apiCallResponse.timestamp }; }", + "timeoutMs": 5000, + } +} +``` + From f566dbc3467b959b06c39df488e1d502f2916bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emanuel=20Tesa=C5=99?= Date: Tue, 21 Nov 2023 06:15:59 +0100 Subject: [PATCH 4/8] Apply interface changes --- docs/reference/ois/next/processing.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/reference/ois/next/processing.md b/docs/reference/ois/next/processing.md index 9af4a795..c5e4cb25 100644 --- a/docs/reference/ois/next/processing.md +++ b/docs/reference/ois/next/processing.md @@ -133,21 +133,21 @@ payload argument, you can use most Node.js built-in modules. The payload argument for pre-processing is an object with the following properties: -- `apiCallParameters` - The API call parameters with the exception of reserved +- `endpointParameters` - The endpoint parameters with the exception of reserved parameters. For example, if there was a parameter named `myParameter` defined in the `endpoints[n].parameters` array, its value could be accessed using `endpointParameters.myParameter` within pre-processing snippet. The output of the pre-processing snippet is an object with the following fields: -- `apiCallParameters` - The pre-processed API call parameters. These are used to - make the API call. +- `endpointParameters` - The pre-processed endpoint parameters parameters. These + are used to make the API call. The payload argument for post-processing is an object with the following properties: -- `apiCallResponse` - The API call response. -- `endpointParameters` - The API call parameters with the exception of reserved +- `apiCallResponse` - The response of the underlying data provider API call. +- `endpointParameters` - The endpoint parameters with the exception of reserved parameters. For example, if there was a parameter named `myParameter` defined in the `endpoints[n].parameters` array, its value could be accessed using `endpointParameters.myParameter` within pre-processing snippet. @@ -156,7 +156,7 @@ The output of the post-processing snippet is an object with the following fields: - `apiCallResponse` - The post-processed API call response. This is used to - encode the response values defined by reservedParameters. + encode the response values defined by reserved parameters. - `timestamp` - (Optional) The timestamp of the API call response. Use this if you want Airnode to use a specific timestamp (instead of a current time at request processing) when using the [signed data From 13244d51c3da8f8988abf8bedc989ca363a9d067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emanuel=20Tesa=C5=99?= Date: Tue, 21 Nov 2023 12:17:11 +0100 Subject: [PATCH 5/8] Fix wording and warning container --- docs/reference/ois/next/processing.md | 7 ++++--- docs/reference/ois/next/specification.md | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/reference/ois/next/processing.md b/docs/reference/ois/next/processing.md index c5e4cb25..2639b625 100644 --- a/docs/reference/ois/next/processing.md +++ b/docs/reference/ois/next/processing.md @@ -131,14 +131,15 @@ return value of the function is treated as a processing result. Apart from the payload argument, you can use most Node.js built-in modules. The payload argument for pre-processing is an object with the following -properties: +property: - `endpointParameters` - The endpoint parameters with the exception of reserved parameters. For example, if there was a parameter named `myParameter` defined in the `endpoints[n].parameters` array, its value could be accessed using `endpointParameters.myParameter` within pre-processing snippet. -The output of the pre-processing snippet is an object with the following fields: +The output of the pre-processing snippet is an object with the following +property: - `endpointParameters` - The pre-processed endpoint parameters parameters. These are used to make the API call. @@ -153,7 +154,7 @@ properties: `endpointParameters.myParameter` within pre-processing snippet. The output of the post-processing snippet is an object with the following -fields: +properties: - `apiCallResponse` - The post-processed API call response. This is used to encode the response values defined by reserved parameters. diff --git a/docs/reference/ois/next/specification.md b/docs/reference/ois/next/specification.md index 7393dee5..2a16f1f8 100644 --- a/docs/reference/ois/next/specification.md +++ b/docs/reference/ois/next/specification.md @@ -589,7 +589,7 @@ corresponding operation parameter.--> ### 5.9. `preProcessingSpecifications` \* -::: deprecation warning +::: warning Deprecation The `preProcessingSpecifications` field is deprecated. Use `preProcessingSpecificationV2` instead. @@ -628,7 +628,7 @@ additional details. ### 5.10. `postProcessingSpecifications` \* -::: deprecation warning +::: warning Deprecation The `postProcessingSpecifications` field is deprecated. Use `postProcessingSpecificationV2` instead. From 51f82ef851a6feaa426dfdeeabb97d8610e35adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emanuel=20Tesa=C5=99?= Date: Thu, 23 Nov 2023 10:44:24 +0100 Subject: [PATCH 6/8] Apply naming suggestions --- docs/reference/ois/next/processing.md | 20 ++++++++++++-------- docs/reference/ois/next/specification.md | 8 ++++---- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/docs/reference/ois/next/processing.md b/docs/reference/ois/next/processing.md index 2639b625..4d785246 100644 --- a/docs/reference/ois/next/processing.md +++ b/docs/reference/ois/next/processing.md @@ -147,17 +147,21 @@ property: The payload argument for post-processing is an object with the following properties: -- `apiCallResponse` - The response of the underlying data provider API call. -- `endpointParameters` - The endpoint parameters with the exception of reserved - parameters. For example, if there was a parameter named `myParameter` defined - in the `endpoints[n].parameters` array, its value could be accessed using - `endpointParameters.myParameter` within pre-processing snippet. +- `response` - The response of the underlying data provider API call. In case of + Airnode skipping API call, the `response` contains the output of + pre-processing snippet. +- `endpointParameters` - The raw (not pre-processed) endpoint parameters with + the exception of reserved parameters. For example, if there was a parameter + named `myParameter` defined in the `endpoints[n].parameters` array, its value + could be accessed using `endpointParameters.myParameter` within pre-processing + snippet. The output of the post-processing snippet is an object with the following properties: -- `apiCallResponse` - The post-processed API call response. This is used to - encode the response values defined by reserved parameters. +- `response` - The post-processed API call response (or post-processed result of + pre-processing in case of skipping an API call). This is used to encode the + response values defined by reserved parameters. - `timestamp` - (Optional) The timestamp of the API call response. Use this if you want Airnode to use a specific timestamp (instead of a current time at request processing) when using the [signed data @@ -348,7 +352,7 @@ only supported with the v2 of the processing. "postProcessingSpecificationV2": { "environment": "Node", // Reuses the timestamp from the API call response. - "value": "async ({ apiCallResponse }) => { return { apiCallResponse, timestamp: apiCallResponse.timestamp }; }", + "value": "async ({ response }) => { return { response, timestamp: response.timestamp }; }", "timeoutMs": 5000, } } diff --git a/docs/reference/ois/next/specification.md b/docs/reference/ois/next/specification.md index 2a16f1f8..56cc7d68 100644 --- a/docs/reference/ois/next/specification.md +++ b/docs/reference/ois/next/specification.md @@ -381,12 +381,12 @@ node. ], "preProcessingSpecificationV2": { "environment": "Node", - "value": "({ apiCallParameters }) => { return { apiCallParameters: {...apiCallParameters, from: 'ETH'} }; }", + "value": "({ endpointParameters }) => { return { endpointParameters: {...endpointParameters, from: 'ETH'} }; }", "timeoutMs": 5000 }, "postProcessingSpecificationV2": { "environment": "Node", - "value": "({ apiCallResponse }) => { return { apiCallResponse: parseInt(apiCallResponse.price) * 1000 }; }", + "value": "({ response }) => { return { response: parseInt(response.price) * 1000 }; }", "timeoutMs": 5000 } } @@ -672,7 +672,7 @@ additional details. // Execute in Node.js. The v2 specification supports both synchronous and asynchronous code "environment": "Node", // Define a new "from" parameter with value "ETH" - "value": "({ apiCallParameters }) => { return { apiCallParameters: {...apiCallParameters, from: 'ETH'} }; }", + "value": "({ endpointParameters }) => { return { endpointParameters: {...endpointParameters, from: 'ETH'} }; }", // Run for 5 seconds maximum "timeoutMs": 5000 } @@ -694,7 +694,7 @@ additional details. // Execute in Node.js. The v2 specification supports both synchronous and asynchronous code "environment": "Node", // Multiply the API return value by 1000 and round it to an integer - "value": "({ apiCallResponse }) => { return { apiCallResponse: parseInt(apiCallResponse.price * 1000) }; }", + "value": "({ response }) => { return { response: parseInt(response.price * 1000) }; }", // Run for 5 seconds maximum "timeoutMs": 5000 } From 6a32eeeb74ea555fc18564effa1ed50c2f82dbf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emanuel=20Tesa=C5=99?= Date: Thu, 23 Nov 2023 11:11:01 +0100 Subject: [PATCH 7/8] Self review --- docs/reference/ois/next/processing.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/reference/ois/next/processing.md b/docs/reference/ois/next/processing.md index 4d785246..388b4b25 100644 --- a/docs/reference/ois/next/processing.md +++ b/docs/reference/ois/next/processing.md @@ -26,6 +26,7 @@ or after an API call. This feature is useful for multiple use cases, including: - Data transformation - Data aggregation - Data validation +- Skipping an API call ## Processing versions @@ -45,9 +46,9 @@ Airnode executes snippets for `preProcessingSpecifications` and work flow Airnode uses: 1. Run `preProcessingSpecifications` -2. Airnode calls requested OIS endpoint +2. Airnode calls requested OIS endpoint (unless the API call is skipped) 3. Run `postProcessingSpecifications` -4. Airnode encodes the response values defined by reservedParameters +4. Airnode encodes the response values defined by `reservedParameters` The processing schema is the same for both [`preProcessingSpecifications`](/reference/ois/next/specification.md#_5-9-preprocessingspecifications) @@ -103,9 +104,9 @@ Airnode executes snippets for `preProcessingSpecificationV2` and the work flow Airnode uses: 1. Run `preProcessingSpecificationV2` -2. Airnode calls requested OIS endpoint +2. Airnode calls requested OIS endpoint (unless the API call is skipped) 3. Run `postProcessingSpecificationV2` -4. Airnode encodes the response values defined by reservedParameters +4. Airnode encodes the response values defined by `reservedParameters` The processing schema is the same for both [`preProcessingSpecificationV2`](/reference/ois/next/specification.md#_5-11-preprocessingspecificationv2) @@ -114,8 +115,8 @@ and Snippets for both specifications follow this schema: - `environment` - Currently only possible value is `Node`. This options - interprets the code as JavaScript and execute in Node.js. The function can be - also asynchronous (async/await is supported as well). The processing + interprets the code as JavaScript and executes it in Node.js. The function can + be also asynchronous (async/await is supported as well). The processing implementation will wait for the function to resolve. - `value` - The processing code written as a string. - `timeoutMs` - The maximum timeout that this snippet can run. In case the @@ -148,7 +149,7 @@ The payload argument for post-processing is an object with the following properties: - `response` - The response of the underlying data provider API call. In case of - Airnode skipping API call, the `response` contains the output of + Airnode skipping the API call, the `response` contains the output of pre-processing snippet. - `endpointParameters` - The raw (not pre-processed) endpoint parameters with the exception of reserved parameters. For example, if there was a parameter @@ -160,8 +161,8 @@ The output of the post-processing snippet is an object with the following properties: - `response` - The post-processed API call response (or post-processed result of - pre-processing in case of skipping an API call). This is used to encode the - response values defined by reserved parameters. + pre-processing snippet in case of skipping an API call). This is used to + encode the response values defined by reserved parameters. - `timestamp` - (Optional) The timestamp of the API call response. Use this if you want Airnode to use a specific timestamp (instead of a current time at request processing) when using the [signed data From 288d0147dd1ee915f35143d9dc8a3ae88afee119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emanuel=20Tesa=C5=99?= Date: Mon, 27 Nov 2023 09:09:12 +0100 Subject: [PATCH 8/8] Apply minor wording/link suggestions --- docs/reference/ois/2.0/processing.md | 2 +- docs/reference/ois/2.1/processing.md | 2 +- docs/reference/ois/latest/processing.md | 2 +- docs/reference/ois/next/processing.md | 14 +++++++------- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/reference/ois/2.0/processing.md b/docs/reference/ois/2.0/processing.md index 9fb62b27..b8dcfcc3 100644 --- a/docs/reference/ois/2.0/processing.md +++ b/docs/reference/ois/2.0/processing.md @@ -45,7 +45,7 @@ Snippets for both specifications follow this schema: with the output value as an argument. Airnode will use the resolved value as the input to subsequent snippets (if defined). - `value` - The processing code written as a string. -- `timeoutMs` - The maximum timeout that this snippet can run. In case the +- `timeoutMs` - The maximum duration that this snippet can run. In case the timeout is exceeded an error is thrown. Try the [Post processing](/guides/airnode/post-processing/) guide to further diff --git a/docs/reference/ois/2.1/processing.md b/docs/reference/ois/2.1/processing.md index 177d190f..7a7c729b 100644 --- a/docs/reference/ois/2.1/processing.md +++ b/docs/reference/ois/2.1/processing.md @@ -45,7 +45,7 @@ Snippets for both specifications follow this schema: with the output value as an argument. Airnode will use the resolved value as the input to subsequent snippets (if defined). - `value` - The processing code written as a string. -- `timeoutMs` - The maximum timeout that this snippet can run. In case the +- `timeoutMs` - The maximum duration that this snippet can run. In case the timeout is exceeded an error is thrown. Try the [Post processing](/guides/airnode/post-processing/) guide to further diff --git a/docs/reference/ois/latest/processing.md b/docs/reference/ois/latest/processing.md index a920793a..81e074ba 100644 --- a/docs/reference/ois/latest/processing.md +++ b/docs/reference/ois/latest/processing.md @@ -45,7 +45,7 @@ Snippets for both specifications follow this schema: with the output value as an argument. Airnode will use the resolved value as the input to subsequent snippets (if defined). - `value` - The processing code written as a string. -- `timeoutMs` - The maximum timeout that this snippet can run. In case the +- `timeoutMs` - The maximum duration that this snippet can run. In case the timeout is exceeded an error is thrown. Try the [Post processing](/guides/airnode/post-processing/) guide to further diff --git a/docs/reference/ois/next/processing.md b/docs/reference/ois/next/processing.md index 388b4b25..3f273ca4 100644 --- a/docs/reference/ois/next/processing.md +++ b/docs/reference/ois/next/processing.md @@ -62,7 +62,7 @@ Snippets for both specifications follow this schema: with the output value as an argument. Airnode will use the resolved value as the input to subsequent snippets (if defined). - `value` - The processing code written as a string. -- `timeoutMs` - The maximum timeout that this snippet can run. In case the +- `timeoutMs` - The maximum duration that this snippet can run. In case the timeout is exceeded an error is thrown. Try the [Post processing](/guides/airnode/post-processing/) guide to further @@ -119,7 +119,7 @@ Snippets for both specifications follow this schema: be also asynchronous (async/await is supported as well). The processing implementation will wait for the function to resolve. - `value` - The processing code written as a string. -- `timeoutMs` - The maximum timeout that this snippet can run. In case the +- `timeoutMs` - The maximum duration that this snippet can run. In case the timeout is exceeded an error is thrown. Try the [Post processing](/guides/airnode/post-processing/) guide to further @@ -127,9 +127,9 @@ understand pre/post processing. #### Input and Output -The processing snippet is a function which receives payload as an argument. The -return value of the function is treated as a processing result. Apart from the -payload argument, you can use most Node.js built-in modules. +The processing snippet is a function which receives a payload as an argument. +The return value of the function is treated as a processing result. Apart from +the payload argument, you can use most Node.js built-in modules. The payload argument for pre-processing is an object with the following property: @@ -166,7 +166,7 @@ properties: - `timestamp` - (Optional) The timestamp of the API call response. Use this if you want Airnode to use a specific timestamp (instead of a current time at request processing) when using the [signed data - gateway](https://docs.api3.org/reference/airnode/latest/understand/http-gateways.html#http-signed-data-gateway). + gateway](/reference/airnode/latest/understand/http-gateways.md#http-signed-data-gateway). ## Interpolation @@ -343,7 +343,7 @@ endpoints: [ One of the possible use cases for post-processing would be to use override the timestamp used by [signed data -gateway](https://docs.api3.org/reference/airnode/latest/understand/http-gateways.html#http-signed-data-gateway). +gateway](/reference/airnode/latest/understand/http-gateways.md#http-signed-data-gateway). By default the signed data gateway uses the timestamp of the request processing. However, sometimes the API itself returns the timestamp. Modifying timestamp is only supported with the v2 of the processing.