Skip to content

Commit bdb0cb1

Browse files
committed
fix: Adds missing properties to sandbox
1 parent 6547316 commit bdb0cb1

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @taskless/loader
22

3+
## 0.0.35
4+
5+
### Patch Changes
6+
7+
- Adds additional properties to the sandbox
8+
39
## 0.0.34
410

511
### Patch Changes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@taskless/loader",
33
"description": "Taskless Loader - Take control of your third party APIs",
4-
"version": "0.0.34",
4+
"version": "0.0.35",
55
"author": "Taskless",
66
"license": "Apache-2.0",
77
"repository": "taskless/loader-js",

src/lib/lifecycle/helpers.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import process from "node:process";
2-
import { type Pack } from "@~/types.js";
2+
import { type PluginInput, type Pack } from "@~/types.js";
33

44
/**
55
* Creates a JSON-friendly sandbox payload
@@ -42,12 +42,16 @@ export const createSandbox = async (
4242
url: info.request.url,
4343
domain: new URL(info.request.url).hostname,
4444
path: new URL(info.request.url).pathname,
45+
method: info.request.method,
4546
headers: [...info.request.headers.entries()],
4647
body: pack.permissions?.body
4748
? await extractBody(info.request)
4849
: undefined,
4950
},
50-
chunk: info.chunk ? Buffer.from(info.chunk).toString("base64") : undefined,
51+
chunk:
52+
pack.permissions?.body && info.chunk
53+
? Buffer.from(info.chunk).toString("base64")
54+
: undefined,
5155
response: info.response
5256
? {
5357
status: info.response.status,
@@ -57,6 +61,6 @@ export const createSandbox = async (
5761
: undefined,
5862
}
5963
: undefined,
60-
environment: env,
61-
};
64+
environment: pack.permissions?.environment ? env : undefined,
65+
} satisfies PluginInput;
6266
};

src/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,10 @@ export type PluginInput<
171171
headers?: Array<[string, string]>;
172172
body?: TResponseBody;
173173
};
174+
chunk?: string; // base64 encoded chunk
175+
requestId: string;
174176
context: TContext;
177+
environment: Record<string, string | undefined> | undefined;
175178
} & Pick<Pack, "configuration">;
176179

177180
export type PluginOutput<TContext = unknown> = {

0 commit comments

Comments
 (0)