@teamkeel/functions-runtime 0.372.0 → 0.373.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 +1 -1
- package/src/handleRequest.js +4 -1
- package/src/handleRequest.test.js +49 -7
- package/src/index.d.ts +3 -5
package/package.json
CHANGED
package/src/handleRequest.js
CHANGED
|
@@ -88,7 +88,10 @@ async function handleRequest(request, config) {
|
|
|
88
88
|
for (const pair of headers.entries()) {
|
|
89
89
|
responseHeaders[pair[0]] = pair[1].split(", ");
|
|
90
90
|
}
|
|
91
|
-
response.meta = {
|
|
91
|
+
response.meta = {
|
|
92
|
+
headers: responseHeaders,
|
|
93
|
+
status: ctx.response.status,
|
|
94
|
+
};
|
|
92
95
|
|
|
93
96
|
return response;
|
|
94
97
|
} catch (e) {
|
|
@@ -23,7 +23,13 @@ test("when the custom function returns expected value", async () => {
|
|
|
23
23
|
actionTypes: {
|
|
24
24
|
createPost: PROTO_ACTION_TYPES.CREATE,
|
|
25
25
|
},
|
|
26
|
-
createContextAPI: () => {
|
|
26
|
+
createContextAPI: () => {
|
|
27
|
+
return {
|
|
28
|
+
response: {
|
|
29
|
+
headers: new Headers(),
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
},
|
|
27
33
|
};
|
|
28
34
|
|
|
29
35
|
const rpcReq = createJSONRPCRequest("123", "createPost", { title: "a post" });
|
|
@@ -52,7 +58,13 @@ test("when the custom function doesnt return a value", async () => {
|
|
|
52
58
|
actionTypes: {
|
|
53
59
|
createPost: PROTO_ACTION_TYPES.CREATE,
|
|
54
60
|
},
|
|
55
|
-
createContextAPI: () => {
|
|
61
|
+
createContextAPI: () => {
|
|
62
|
+
return {
|
|
63
|
+
response: {
|
|
64
|
+
headers: new Headers(),
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
},
|
|
56
68
|
};
|
|
57
69
|
|
|
58
70
|
const rpcReq = createJSONRPCRequest("123", "createPost", { title: "a post" });
|
|
@@ -75,7 +87,13 @@ test("when there is no matching function for the path", async () => {
|
|
|
75
87
|
actionTypes: {
|
|
76
88
|
createPost: PROTO_ACTION_TYPES.CREATE,
|
|
77
89
|
},
|
|
78
|
-
createContextAPI: () => {
|
|
90
|
+
createContextAPI: () => {
|
|
91
|
+
return {
|
|
92
|
+
response: {
|
|
93
|
+
headers: new Headers(),
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
},
|
|
79
97
|
};
|
|
80
98
|
|
|
81
99
|
const rpcReq = createJSONRPCRequest("123", "unknown", { title: "a post" });
|
|
@@ -100,7 +118,13 @@ test("when there is an unexpected error in the custom function", async () => {
|
|
|
100
118
|
actionTypes: {
|
|
101
119
|
createPost: PROTO_ACTION_TYPES.CREATE,
|
|
102
120
|
},
|
|
103
|
-
createContextAPI: () => {
|
|
121
|
+
createContextAPI: () => {
|
|
122
|
+
return {
|
|
123
|
+
response: {
|
|
124
|
+
headers: new Headers(),
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
},
|
|
104
128
|
};
|
|
105
129
|
|
|
106
130
|
const rpcReq = createJSONRPCRequest("123", "createPost", { title: "a post" });
|
|
@@ -128,7 +152,13 @@ test("when a role based permission has already been granted by the main runtime"
|
|
|
128
152
|
createPost: PROTO_ACTION_TYPES.CREATE,
|
|
129
153
|
},
|
|
130
154
|
createModelAPI: () => {},
|
|
131
|
-
createContextAPI: () => {
|
|
155
|
+
createContextAPI: () => {
|
|
156
|
+
return {
|
|
157
|
+
response: {
|
|
158
|
+
headers: new Headers(),
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
},
|
|
132
162
|
};
|
|
133
163
|
|
|
134
164
|
let rpcReq = createJSONRPCRequest("123", "createPost", { title: "a post" });
|
|
@@ -159,7 +189,13 @@ test("when there is an unexpected object thrown in the custom function", async (
|
|
|
159
189
|
actionTypes: {
|
|
160
190
|
createPost: PROTO_ACTION_TYPES.CREATE,
|
|
161
191
|
},
|
|
162
|
-
createContextAPI: () => {
|
|
192
|
+
createContextAPI: () => {
|
|
193
|
+
return {
|
|
194
|
+
response: {
|
|
195
|
+
headers: new Headers(),
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
},
|
|
163
199
|
};
|
|
164
200
|
|
|
165
201
|
const rpcReq = createJSONRPCRequest("123", "createPost", { title: "a post" });
|
|
@@ -244,7 +280,13 @@ describe("ModelAPI error handling", () => {
|
|
|
244
280
|
return deleted;
|
|
245
281
|
},
|
|
246
282
|
},
|
|
247
|
-
createContextAPI: () =>
|
|
283
|
+
createContextAPI: () => {
|
|
284
|
+
return {
|
|
285
|
+
response: {
|
|
286
|
+
headers: new Headers(),
|
|
287
|
+
},
|
|
288
|
+
};
|
|
289
|
+
},
|
|
248
290
|
};
|
|
249
291
|
});
|
|
250
292
|
|
package/src/index.d.ts
CHANGED
|
@@ -59,6 +59,7 @@ export type ContextAPI = {
|
|
|
59
59
|
|
|
60
60
|
export type Response = {
|
|
61
61
|
headers: Headers;
|
|
62
|
+
status?: number;
|
|
62
63
|
};
|
|
63
64
|
|
|
64
65
|
export type PageInfo = {
|
|
@@ -69,11 +70,8 @@ export type PageInfo = {
|
|
|
69
70
|
count: number;
|
|
70
71
|
};
|
|
71
72
|
|
|
72
|
-
// Request headers
|
|
73
|
-
export type RequestHeaders =
|
|
74
|
-
get(name: string): string;
|
|
75
|
-
has(name: string): boolean;
|
|
76
|
-
};
|
|
73
|
+
// Request headers cannot be mutated, so remove any methods that mutate
|
|
74
|
+
export type RequestHeaders = Omit<Headers, "append" | "delete" | "set">;
|
|
77
75
|
|
|
78
76
|
export declare class Permissions {
|
|
79
77
|
constructor();
|