@teamkeel/functions-runtime 0.249.0 → 0.250.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamkeel/functions-runtime",
3
- "version": "0.249.0",
3
+ "version": "0.250.0",
4
4
  "description": "Internal package used by @teamkeel/sdk",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -21,9 +21,12 @@ async function handleRequest(request, config) {
21
21
  }
22
22
 
23
23
  try {
24
+ // headers reference passed to custom function where object data can be modified
25
+ const headers = new Headers();
26
+
24
27
  const result = await functions[request.method](
25
28
  request.params,
26
- createFunctionAPI(),
29
+ createFunctionAPI(headers),
27
30
  createContextAPI(request.meta)
28
31
  );
29
32
 
@@ -36,7 +39,15 @@ async function handleRequest(request, config) {
36
39
  );
37
40
  }
38
41
 
39
- return createJSONRPCSuccessResponse(request.id, result);
42
+ const response = createJSONRPCSuccessResponse(request.id, result);
43
+
44
+ const responseHeaders = {};
45
+ for (const pair of headers.entries()) {
46
+ responseHeaders[pair[0]] = pair[1].split(", ");
47
+ }
48
+ response.meta = { headers: responseHeaders };
49
+
50
+ return response;
40
51
  } catch (e) {
41
52
  if (e instanceof Error) {
42
53
  return errorToJSONRPCResponse(request, e);
@@ -25,6 +25,9 @@ test("when the custom function returns expected value", async () => {
25
25
  expect(await handleRequest(rpcReq, config)).toEqual({
26
26
  id: "123",
27
27
  jsonrpc: "2.0",
28
+ meta: {
29
+ headers: {},
30
+ },
28
31
  result: {
29
32
  title: "a post",
30
33
  id: "abcde",