@codize/sdk 0.0.2 → 0.1.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/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # @codize/sdk
2
+
3
+ [![NPM Version](https://img.shields.io/npm/v/@codize/sdk)](https://www.npmjs.com/package/@codize/sdk)
4
+ [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/codize-dev/sdk/ci-typescript.yml)](https://github.com/codize-dev/sdk/actions/workflows/ci-typescript.yml)
5
+ [![GitHub License](https://img.shields.io/github/license/codize-dev/sdk)](../LICENSE)
6
+
7
+ Official TypeScript SDK for the Codize API.
8
+
9
+ ## Installation
10
+
11
+ ```console
12
+ $ npm install @codize/sdk
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```typescript
18
+ import { CodizeClient } from "@codize/sdk";
19
+
20
+ // Get your API key from the Codize: https://codize.dev/settings/api-keys
21
+ const apiKey = "cdz_****";
22
+
23
+ const client = new CodizeClient({ apiKey });
24
+
25
+ const result = await client.sandbox.execute({
26
+ language: "typescript",
27
+ files: [
28
+ {
29
+ name: "index.ts",
30
+ content: `console.log("Hello, World!");`,
31
+ },
32
+ ],
33
+ });
34
+
35
+ console.log(result.data);
36
+ // => {
37
+ // compile: {
38
+ // stdout: "",
39
+ // stderr: "",
40
+ // output: "",
41
+ // exit_code: 0,
42
+ // },
43
+ // run: {
44
+ // stdout: "Hello, World!\n",
45
+ // stderr: "",
46
+ // output: "Hello, World!\n",
47
+ // exit_code: 0,
48
+ // },
49
+ // }
50
+ ```
51
+
52
+ ## License
53
+
54
+ [MIT](../LICENSE)
package/dist/index.mjs CHANGED
@@ -57,6 +57,17 @@ var CodizeApiError = class extends Error {
57
57
  //#endregion
58
58
  //#region src/client.ts
59
59
  /**
60
+ * Maps a raw API stage result to the SDK's camelCase format.
61
+ */
62
+ function mapStageResult(raw) {
63
+ return {
64
+ stdout: raw.stdout,
65
+ stderr: raw.stderr,
66
+ output: raw.output,
67
+ exitCode: raw.exit_code
68
+ };
69
+ }
70
+ /**
60
71
  * API client for Codize.
61
72
  */
62
73
  var CodizeClient = class {
@@ -97,8 +108,8 @@ var CodizeClient = class {
97
108
  return {
98
109
  headers: response.headers,
99
110
  data: {
100
- compile: data.compile,
101
- run: data.run
111
+ compile: data.compile ? mapStageResult(data.compile) : null,
112
+ run: mapStageResult(data.run)
102
113
  }
103
114
  };
104
115
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codize/sdk",
3
- "version": "0.0.2",
3
+ "version": "0.1.1",
4
4
  "description": "Official TypeScript SDK for the Codize API",
5
5
  "homepage": "https://github.com/codize-dev/sdk",
6
6
  "repository": {
@@ -22,12 +22,14 @@
22
22
  ],
23
23
  "scripts": {
24
24
  "build": "tsdown",
25
- "prepublishOnly": "bun run build"
25
+ "prepublishOnly": "bun run build",
26
+ "test": "vitest run"
26
27
  },
27
28
  "devDependencies": {
28
29
  "@types/bun": "1.3.9",
29
30
  "tsdown": "0.21.0-beta.2",
30
- "typescript": "5.9.3"
31
+ "typescript": "5.9.3",
32
+ "vitest": "4.0.18"
31
33
  },
32
34
  "dependencies": {
33
35
  "valibot": "1.2.0"