drej 0.1.0 → 0.2.1

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/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # drej
2
+
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 5278aa9: Add `DrejError` and `run()` to the Python SDK, matching the TypeScript SDK's interface.
8
+
9
+ ## 0.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - c3fe034: Add `DrejClient.run(code)` method and `SandboxRunResult` type for submitting code to the sandbox execution endpoint.
14
+
15
+ ### Patch Changes
16
+
17
+ - 3316570: Add `DrejError` class with HTTP status code — errors from API calls now throw `DrejError` instead of a generic `Error`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drej",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "main": "./src/index.ts",
5
5
  "types": "./src/index.ts",
6
6
  "scripts": {
package/src/client.ts CHANGED
@@ -1,7 +1,23 @@
1
+ export class DrejError extends Error {
2
+ constructor(
3
+ message: string,
4
+ public readonly status: number,
5
+ ) {
6
+ super(message);
7
+ this.name = "DrejError";
8
+ }
9
+ }
10
+
1
11
  export interface DrejClientOptions {
2
12
  baseUrl?: string;
3
13
  }
4
14
 
15
+ export interface SandboxRunResult {
16
+ id: string;
17
+ code: string;
18
+ status: "queued";
19
+ }
20
+
5
21
  export class DrejClient {
6
22
  private baseUrl: string;
7
23
 
@@ -11,7 +27,17 @@ export class DrejClient {
11
27
 
12
28
  async health(): Promise<{ healthy: boolean }> {
13
29
  const res = await fetch(`${this.baseUrl}/health`);
14
- if (!res.ok) throw new Error(`drej API error: ${res.status}`);
30
+ if (!res.ok) throw new DrejError(`drej API error`, res.status);
31
+ return res.json();
32
+ }
33
+
34
+ async run(code: string): Promise<SandboxRunResult> {
35
+ const res = await fetch(`${this.baseUrl}/sandbox/run`, {
36
+ method: "POST",
37
+ headers: { "Content-Type": "application/json" },
38
+ body: JSON.stringify({ code }),
39
+ });
40
+ if (!res.ok) throw new DrejError(`drej API error`, res.status);
15
41
  return res.json();
16
42
  }
17
43
  }
package/src/index.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { DrejClient } from "./client";
2
- export type { DrejClientOptions } from "./client";
1
+ export { DrejClient, DrejError } from "./client";
2
+ export type { DrejClientOptions, SandboxRunResult } from "./client";
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "noEmit": true,
8
+ "skipLibCheck": true,
9
+ "declaration": true
10
+ },
11
+ "include": ["src"]
12
+ }