code-share-types 0.7.0 → 0.8.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.
@@ -1,10 +1,16 @@
1
1
  import { z } from '@hono/zod-openapi';
2
- declare const CodeExecutionResultSchema: z.ZodObject<{
3
- code: z.ZodNullable<z.ZodNumber>;
4
- signal: z.ZodNullable<z.ZodString>;
5
- stdout: z.ZodString;
6
- stderr: z.ZodString;
7
- }, z.core.$strip>;
2
+ declare const CodeExecutionResultSchema: z.ZodUnion<readonly [z.ZodObject<{
3
+ status: z.ZodLiteral<"SUCCESS">;
4
+ result: z.ZodObject<{
5
+ code: z.ZodNullable<z.ZodNumber>;
6
+ signal: z.ZodNullable<z.ZodString>;
7
+ stdout: z.ZodString;
8
+ stderr: z.ZodString;
9
+ }, z.core.$strip>;
10
+ }, z.core.$strip>, z.ZodObject<{
11
+ status: z.ZodLiteral<"TIMEOUT">;
12
+ result: z.ZodUndefined;
13
+ }, z.core.$strip>]>;
8
14
  type CodeExecutionResult = z.infer<typeof CodeExecutionResultSchema>;
9
15
  export type { CodeExecutionResult };
10
16
  export { CodeExecutionResultSchema };
@@ -1,10 +1,16 @@
1
1
  import { z } from '@hono/zod-openapi';
2
- const CodeExecutionResultSchema = z.object({
3
- code: z.number().nullable(),
4
- signal: z.string().nullable(),
5
- stdout: z.string(),
6
- stderr: z.string(),
7
- }).openapi({
8
- example: { code: 0, signal: null, stdout: 'Hello World\n', stderr: '' }
2
+ import { ExecutorCodeResultSchema } from '../socket/executor';
3
+ const CodeExecutionResultSchema = z.union([
4
+ z.object({
5
+ status: z.literal("SUCCESS"), result: ExecutorCodeResultSchema,
6
+ }),
7
+ z.object({
8
+ status: z.literal("TIMEOUT"), result: z.undefined(),
9
+ }),
10
+ ]).openapi({
11
+ example: {
12
+ status: "SUCCESS",
13
+ result: { code: 0, signal: null, stdout: 'Hello World\n', stderr: '' },
14
+ }
9
15
  });
10
16
  export { CodeExecutionResultSchema };
@@ -1,9 +1,9 @@
1
1
  import { z } from 'zod';
2
2
  declare const ExecutorCodeResultSchema: z.ZodObject<{
3
- signal: z.ZodNullable<z.ZodAny>;
3
+ code: z.ZodNullable<z.ZodNumber>;
4
+ signal: z.ZodNullable<z.ZodString>;
4
5
  stdout: z.ZodString;
5
6
  stderr: z.ZodString;
6
- code: z.ZodNullable<z.ZodNumber>;
7
7
  }, z.core.$strip>;
8
8
  type ExecutorCodeResult = z.infer<typeof ExecutorCodeResultSchema>;
9
9
  export type { ExecutorCodeResult };
@@ -1,9 +1,9 @@
1
1
  import { z } from 'zod';
2
2
  const ExecutorCodeResultSchema = z.object({
3
- signal: z.any().nullable(),
3
+ code: z.number().nullable(),
4
+ signal: z.string().nullable(),
4
5
  stdout: z.string(),
5
6
  stderr: z.string(),
6
- code: z.number().nullable(),
7
7
  // message: string | null
8
8
  // status: any | null
9
9
  // output: string
@@ -8,11 +8,11 @@ interface SocketData {
8
8
  export type ExecutorClientToServerEvents = {
9
9
  "packageInstallProgress": (pkg: Package, status: PackageInstallStatus) => void;
10
10
  "installedPackages": (packages: Package[]) => void;
11
- "executorCodeResult": (uuid: string, code: ExecutorCodeResult) => void;
11
+ "executorCodeResult": (uuid: string, result: ExecutorCodeResult | undefined) => void;
12
12
  };
13
13
  export type ExecutorServerToClientEvents = {
14
14
  "wantedPackages": (packages: Package[]) => void;
15
- "executorCodeExec": (uuid: string, code: ExecutorCodeRequest) => void;
15
+ "executorCodeExec": (uuid: string, request: ExecutorCodeRequest) => void;
16
16
  };
17
17
  export type ExecutorSocketNamespace = Namespace<ExecutorClientToServerEvents, ExecutorServerToClientEvents, InterServerEvents, SocketData>;
18
18
  export type ExecutorSocketClient = Socket<ExecutorClientToServerEvents, ExecutorServerToClientEvents, InterServerEvents, SocketData>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-share-types",
3
- "version": "0.7.0",
3
+ "version": "0.8.1",
4
4
  "files": [
5
5
  "/dist"
6
6
  ],