code-share-types 0.0.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 +0 -0
- package/dist/Language.d.ts +35 -0
- package/dist/Language.js +87 -0
- package/dist/Package.d.ts +8 -0
- package/dist/Package.js +6 -0
- package/dist/SnippetID.d.ts +8 -0
- package/dist/SnippetID.js +6 -0
- package/dist/SocketTypes.d.ts +24 -0
- package/dist/SocketTypes.js +1 -0
- package/dist/Toast.d.ts +12 -0
- package/dist/Toast.js +6 -0
- package/dist/api/AvailableLanguages.d.ts +13 -0
- package/dist/api/AvailableLanguages.js +6 -0
- package/dist/api/CodeExecutionRequest.d.ts +14 -0
- package/dist/api/CodeExecutionRequest.js +9 -0
- package/dist/api/CodeExecutionResult.d.ts +10 -0
- package/dist/api/CodeExecutionResult.js +10 -0
- package/dist/api/CodeSnippet.d.ts +14 -0
- package/dist/api/CodeSnippet.js +7 -0
- package/dist/api/ServerStatistics.d.ts +8 -0
- package/dist/api/ServerStatistics.js +8 -0
- package/dist/api/index.d.ts +5 -0
- package/dist/api/index.js +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/rest-api/AvailableLanguages.d.ts +13 -0
- package/dist/rest-api/AvailableLanguages.js +6 -0
- package/dist/rest-api/CodeExecutionRequest.d.ts +14 -0
- package/dist/rest-api/CodeExecutionRequest.js +9 -0
- package/dist/rest-api/CodeExecutionResult.d.ts +10 -0
- package/dist/rest-api/CodeExecutionResult.js +10 -0
- package/dist/rest-api/CodeSnippet.d.ts +14 -0
- package/dist/rest-api/CodeSnippet.js +9 -0
- package/dist/rest-api/ServerStatistics.d.ts +8 -0
- package/dist/rest-api/ServerStatistics.js +8 -0
- package/dist/rest-api/index.d.ts +5 -0
- package/dist/rest-api/index.js +5 -0
- package/dist/socket/app/SocketTypes.d.ts +12 -0
- package/dist/socket/app/SocketTypes.js +1 -0
- package/dist/socket/app/index.d.ts +1 -0
- package/dist/socket/app/index.js +1 -0
- package/dist/socket/executor/ExecutorCodeRequest.d.ts +11 -0
- package/dist/socket/executor/ExecutorCodeRequest.js +10 -0
- package/dist/socket/executor/ExecutorCodeResult.d.ts +10 -0
- package/dist/socket/executor/ExecutorCodeResult.js +14 -0
- package/dist/socket/executor/SocketTypes.d.ts +18 -0
- package/dist/socket/executor/SocketTypes.js +1 -0
- package/dist/socket/executor/index.d.ts +3 -0
- package/dist/socket/executor/index.js +3 -0
- package/dist/websocket/ExecutorCodeRequest.d.ts +11 -0
- package/dist/websocket/ExecutorCodeRequest.js +10 -0
- package/dist/websocket/ExecutorCodeResult.d.ts +10 -0
- package/dist/websocket/ExecutorCodeResult.js +14 -0
- package/dist/websocket/SocketTypes.d.ts +24 -0
- package/dist/websocket/SocketTypes.js +1 -0
- package/dist/websocket/index.d.ts +2 -0
- package/dist/websocket/index.js +2 -0
- package/package.json +47 -0
package/README.md
ADDED
|
File without changes
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const LanguageIDSchema: z.ZodEnum<{
|
|
3
|
+
javascript: "javascript";
|
|
4
|
+
typescript: "typescript";
|
|
5
|
+
java: "java";
|
|
6
|
+
python: "python";
|
|
7
|
+
c: "c";
|
|
8
|
+
}>;
|
|
9
|
+
type LanguageID = z.infer<typeof LanguageIDSchema>;
|
|
10
|
+
export type { LanguageID };
|
|
11
|
+
export { LanguageIDSchema };
|
|
12
|
+
declare const LanguageExecutorDefinitionSchema: z.ZodObject<{
|
|
13
|
+
runtime: z.ZodString;
|
|
14
|
+
language: z.ZodString;
|
|
15
|
+
version: z.ZodString;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export type LanguageExecutorDefinition = z.infer<typeof LanguageExecutorDefinitionSchema>;
|
|
18
|
+
export { LanguageExecutorDefinitionSchema };
|
|
19
|
+
export declare class Language {
|
|
20
|
+
private static readonly LANGUAGES_METADATA;
|
|
21
|
+
static get(language: LanguageID): Language;
|
|
22
|
+
static all(): Language[];
|
|
23
|
+
private readonly _languageId;
|
|
24
|
+
private constructor();
|
|
25
|
+
private get metadata();
|
|
26
|
+
get languageId(): "javascript" | "typescript" | "java" | "python" | "c";
|
|
27
|
+
get displayName(): string;
|
|
28
|
+
get defaultCode(): string;
|
|
29
|
+
get monacoEditorLanguage(): string;
|
|
30
|
+
get executorDefinition(): {
|
|
31
|
+
runtime: string;
|
|
32
|
+
language: string;
|
|
33
|
+
version: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
package/dist/Language.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// New languages should be added here
|
|
3
|
+
// These IDs should be non-changing
|
|
4
|
+
const AVAILABLE_LANGUAGE_IDS = [
|
|
5
|
+
"javascript",
|
|
6
|
+
"typescript",
|
|
7
|
+
"java",
|
|
8
|
+
"python",
|
|
9
|
+
"c",
|
|
10
|
+
];
|
|
11
|
+
const LanguageIDSchema = z.enum(AVAILABLE_LANGUAGE_IDS);
|
|
12
|
+
export { LanguageIDSchema };
|
|
13
|
+
const LanguageExecutorDefinitionSchema = z.object({
|
|
14
|
+
runtime: z.string(),
|
|
15
|
+
language: z.string(),
|
|
16
|
+
version: z.string(),
|
|
17
|
+
});
|
|
18
|
+
export { LanguageExecutorDefinitionSchema };
|
|
19
|
+
export class Language {
|
|
20
|
+
static get(language) {
|
|
21
|
+
LanguageIDSchema.parse(language); // will throw error if invalid
|
|
22
|
+
return new Language(language);
|
|
23
|
+
}
|
|
24
|
+
static all() {
|
|
25
|
+
return AVAILABLE_LANGUAGE_IDS.map(id => new Language(id));
|
|
26
|
+
}
|
|
27
|
+
constructor(languageId) {
|
|
28
|
+
this._languageId = languageId;
|
|
29
|
+
}
|
|
30
|
+
get metadata() {
|
|
31
|
+
return Language.LANGUAGES_METADATA[this._languageId];
|
|
32
|
+
}
|
|
33
|
+
get languageId() {
|
|
34
|
+
return this._languageId;
|
|
35
|
+
}
|
|
36
|
+
get displayName() {
|
|
37
|
+
return this.metadata.displayName;
|
|
38
|
+
}
|
|
39
|
+
get defaultCode() {
|
|
40
|
+
return this.metadata.defaultCode;
|
|
41
|
+
}
|
|
42
|
+
get monacoEditorLanguage() {
|
|
43
|
+
return this.metadata.monacoEditorLanguage;
|
|
44
|
+
}
|
|
45
|
+
get executorDefinition() {
|
|
46
|
+
return this.metadata.executorDefinition;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
Language.LANGUAGES_METADATA = {
|
|
50
|
+
"javascript": {
|
|
51
|
+
displayName: "JavaScript",
|
|
52
|
+
monacoEditorLanguage: "javascript",
|
|
53
|
+
executorDefinition: { runtime: "node", language: "javascript", version: "20.11.1" },
|
|
54
|
+
defaultCode: `console.log("Hello World!");`,
|
|
55
|
+
},
|
|
56
|
+
"typescript": {
|
|
57
|
+
displayName: "TypeScript",
|
|
58
|
+
monacoEditorLanguage: "typescript",
|
|
59
|
+
executorDefinition: { runtime: "typescript", language: "typescript", version: "5.0.3", },
|
|
60
|
+
defaultCode: `console.log("Hello World!");`,
|
|
61
|
+
},
|
|
62
|
+
"java": {
|
|
63
|
+
displayName: "Java",
|
|
64
|
+
monacoEditorLanguage: "java",
|
|
65
|
+
executorDefinition: { runtime: "java", language: "java", version: "15", },
|
|
66
|
+
defaultCode: `class Main {
|
|
67
|
+
public static void main(String[] args) {
|
|
68
|
+
System.out.println("Hello World!");
|
|
69
|
+
}
|
|
70
|
+
}`,
|
|
71
|
+
},
|
|
72
|
+
"python": {
|
|
73
|
+
displayName: "Python",
|
|
74
|
+
monacoEditorLanguage: "python",
|
|
75
|
+
executorDefinition: { runtime: "python", language: "python", version: "3.9.4", },
|
|
76
|
+
defaultCode: `print("Hello World!")`,
|
|
77
|
+
},
|
|
78
|
+
"c": {
|
|
79
|
+
displayName: "C",
|
|
80
|
+
monacoEditorLanguage: "c",
|
|
81
|
+
executorDefinition: { runtime: "gcc", language: "gcc", version: "10.2.0", },
|
|
82
|
+
defaultCode: `int main() {
|
|
83
|
+
printf("Hello World!");
|
|
84
|
+
return 0;
|
|
85
|
+
}`,
|
|
86
|
+
},
|
|
87
|
+
};
|
package/dist/Package.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const SNIPPET_ID_LENGTH_MIN = 8;
|
|
3
|
+
declare const SNIPPET_ID_LENGTH_MAX = 8;
|
|
4
|
+
export { SNIPPET_ID_LENGTH_MIN, SNIPPET_ID_LENGTH_MAX };
|
|
5
|
+
declare const SnippetIDSchema: z.ZodString;
|
|
6
|
+
type SnippetID = z.infer<typeof SnippetIDSchema>;
|
|
7
|
+
export type { SnippetID };
|
|
8
|
+
export { SnippetIDSchema };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const SNIPPET_ID_LENGTH_MIN = 8;
|
|
3
|
+
const SNIPPET_ID_LENGTH_MAX = 8;
|
|
4
|
+
export { SNIPPET_ID_LENGTH_MIN, SNIPPET_ID_LENGTH_MAX };
|
|
5
|
+
const SnippetIDSchema = z.string().regex(/^[A-Z]+$/).min(SNIPPET_ID_LENGTH_MIN).max(SNIPPET_ID_LENGTH_MAX);
|
|
6
|
+
export { SnippetIDSchema };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Namespace, Server, Socket } from "socket.io";
|
|
2
|
+
import { ExecutorCodeRequest, ExecutorCodeResult } from "./websocket";
|
|
3
|
+
import { Package } from "./Package";
|
|
4
|
+
interface InterServerEvents {
|
|
5
|
+
}
|
|
6
|
+
interface SocketData {
|
|
7
|
+
}
|
|
8
|
+
export type AppClientToServerEvents = {};
|
|
9
|
+
export type AppServerToClientEvents = {
|
|
10
|
+
"executorsConnected": (count: number) => void;
|
|
11
|
+
};
|
|
12
|
+
export type AppSocketServer = Server<AppClientToServerEvents, AppServerToClientEvents, InterServerEvents, SocketData>;
|
|
13
|
+
export type AppSocketClient = Socket<AppClientToServerEvents, AppServerToClientEvents, InterServerEvents, SocketData>;
|
|
14
|
+
export type ExecutorClientToServerEvents = {
|
|
15
|
+
"installedPackages": (packages: Package[]) => void;
|
|
16
|
+
"executorCodeResult": (uuid: string, code: ExecutorCodeResult) => void;
|
|
17
|
+
};
|
|
18
|
+
export type ExecutorServerToClientEvents = {
|
|
19
|
+
"wantedPackages": (packages: Package[]) => void;
|
|
20
|
+
"executorCodeExec": (uuid: string, code: ExecutorCodeRequest) => void;
|
|
21
|
+
};
|
|
22
|
+
export type ExecutorSocketNamespace = Namespace<ExecutorClientToServerEvents, ExecutorServerToClientEvents, InterServerEvents, SocketData>;
|
|
23
|
+
export type ExecutorSocketClient = Socket<ExecutorClientToServerEvents, ExecutorServerToClientEvents, InterServerEvents, SocketData>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/Toast.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Icon } from "react-bootstrap-icons";
|
|
2
|
+
export declare enum ToastColour {
|
|
3
|
+
INFO = "#dddddd",
|
|
4
|
+
SUCCESS = "#ddffdd",
|
|
5
|
+
ERROR = "#ffdddd"
|
|
6
|
+
}
|
|
7
|
+
export interface Toast {
|
|
8
|
+
id: string;
|
|
9
|
+
color: `#${string}` | ToastColour;
|
|
10
|
+
message: string;
|
|
11
|
+
icon?: Icon;
|
|
12
|
+
}
|
package/dist/Toast.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from '@hono/zod-openapi';
|
|
2
|
+
declare const AvailableLanguagesSchema: z.ZodRecord<z.ZodEnum<{
|
|
3
|
+
javascript: "javascript";
|
|
4
|
+
typescript: "typescript";
|
|
5
|
+
java: "java";
|
|
6
|
+
python: "python";
|
|
7
|
+
c: "c";
|
|
8
|
+
}>, z.ZodObject<{
|
|
9
|
+
displayName: z.ZodString;
|
|
10
|
+
}, z.core.$strip>>;
|
|
11
|
+
type AvailableLanguages = z.infer<typeof AvailableLanguagesSchema>;
|
|
12
|
+
export type { AvailableLanguages };
|
|
13
|
+
export { AvailableLanguagesSchema };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from '@hono/zod-openapi';
|
|
2
|
+
declare const CodeExecutionRequestSchema: z.ZodObject<{
|
|
3
|
+
language_id: z.ZodEnum<{
|
|
4
|
+
javascript: "javascript";
|
|
5
|
+
typescript: "typescript";
|
|
6
|
+
java: "java";
|
|
7
|
+
python: "python";
|
|
8
|
+
c: "c";
|
|
9
|
+
}>;
|
|
10
|
+
content: z.ZodString;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
type CodeExecutionRequest = z.infer<typeof CodeExecutionRequestSchema>;
|
|
13
|
+
export type { CodeExecutionRequest };
|
|
14
|
+
export { CodeExecutionRequestSchema };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from '@hono/zod-openapi';
|
|
2
|
+
import { LanguageIDSchema } from '../Language';
|
|
3
|
+
const CodeExecutionRequestSchema = z.object({
|
|
4
|
+
language_id: LanguageIDSchema.clone()
|
|
5
|
+
.openapi({ example: "javascript" }),
|
|
6
|
+
content: z.string()
|
|
7
|
+
.openapi({ example: "console.log('Hello World');" }),
|
|
8
|
+
});
|
|
9
|
+
export { CodeExecutionRequestSchema };
|
|
@@ -0,0 +1,10 @@
|
|
|
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>;
|
|
8
|
+
type CodeExecutionResult = z.infer<typeof CodeExecutionResultSchema>;
|
|
9
|
+
export type { CodeExecutionResult };
|
|
10
|
+
export { CodeExecutionResultSchema };
|
|
@@ -0,0 +1,10 @@
|
|
|
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: '' }
|
|
9
|
+
});
|
|
10
|
+
export { CodeExecutionResultSchema };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from '@hono/zod-openapi';
|
|
2
|
+
declare const CodeSnippetSchema: z.ZodObject<{
|
|
3
|
+
language_id: z.ZodEnum<{
|
|
4
|
+
javascript: "javascript";
|
|
5
|
+
typescript: "typescript";
|
|
6
|
+
java: "java";
|
|
7
|
+
python: "python";
|
|
8
|
+
c: "c";
|
|
9
|
+
}>;
|
|
10
|
+
content: z.ZodString;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
type CodeSnippet = z.infer<typeof CodeSnippetSchema>;
|
|
13
|
+
export type { CodeSnippet };
|
|
14
|
+
export { CodeSnippetSchema };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from '@hono/zod-openapi';
|
|
2
|
+
declare const ServerStatisticsSchema: z.ZodObject<{
|
|
3
|
+
connected_users: z.ZodNumber;
|
|
4
|
+
connected_executors: z.ZodNumber;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
type ServerStatistics = z.infer<typeof ServerStatisticsSchema>;
|
|
7
|
+
export type { ServerStatistics };
|
|
8
|
+
export { ServerStatisticsSchema };
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from '@hono/zod-openapi';
|
|
2
|
+
declare const AvailableLanguagesSchema: z.ZodRecord<z.ZodEnum<{
|
|
3
|
+
javascript: "javascript";
|
|
4
|
+
typescript: "typescript";
|
|
5
|
+
java: "java";
|
|
6
|
+
python: "python";
|
|
7
|
+
c: "c";
|
|
8
|
+
}>, z.ZodObject<{
|
|
9
|
+
displayName: z.ZodString;
|
|
10
|
+
}, z.core.$strip>>;
|
|
11
|
+
type AvailableLanguages = z.infer<typeof AvailableLanguagesSchema>;
|
|
12
|
+
export type { AvailableLanguages };
|
|
13
|
+
export { AvailableLanguagesSchema };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from '@hono/zod-openapi';
|
|
2
|
+
declare const CodeExecutionRequestSchema: z.ZodObject<{
|
|
3
|
+
language_id: z.ZodEnum<{
|
|
4
|
+
javascript: "javascript";
|
|
5
|
+
typescript: "typescript";
|
|
6
|
+
java: "java";
|
|
7
|
+
python: "python";
|
|
8
|
+
c: "c";
|
|
9
|
+
}>;
|
|
10
|
+
content: z.ZodString;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
type CodeExecutionRequest = z.infer<typeof CodeExecutionRequestSchema>;
|
|
13
|
+
export type { CodeExecutionRequest };
|
|
14
|
+
export { CodeExecutionRequestSchema };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from '@hono/zod-openapi';
|
|
2
|
+
import { LanguageIDSchema } from '../Language';
|
|
3
|
+
const CodeExecutionRequestSchema = z.object({
|
|
4
|
+
language_id: LanguageIDSchema.clone(),
|
|
5
|
+
content: z.string(),
|
|
6
|
+
}).openapi({
|
|
7
|
+
example: { language_id: 'javascript', content: `console.log('Hello World');` }
|
|
8
|
+
});
|
|
9
|
+
export { CodeExecutionRequestSchema };
|
|
@@ -0,0 +1,10 @@
|
|
|
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>;
|
|
8
|
+
type CodeExecutionResult = z.infer<typeof CodeExecutionResultSchema>;
|
|
9
|
+
export type { CodeExecutionResult };
|
|
10
|
+
export { CodeExecutionResultSchema };
|
|
@@ -0,0 +1,10 @@
|
|
|
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: '' }
|
|
9
|
+
});
|
|
10
|
+
export { CodeExecutionResultSchema };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from '@hono/zod-openapi';
|
|
2
|
+
declare const CodeSnippetSchema: z.ZodObject<{
|
|
3
|
+
language_id: z.ZodEnum<{
|
|
4
|
+
javascript: "javascript";
|
|
5
|
+
typescript: "typescript";
|
|
6
|
+
java: "java";
|
|
7
|
+
python: "python";
|
|
8
|
+
c: "c";
|
|
9
|
+
}>;
|
|
10
|
+
content: z.ZodString;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
type CodeSnippet = z.infer<typeof CodeSnippetSchema>;
|
|
13
|
+
export type { CodeSnippet };
|
|
14
|
+
export { CodeSnippetSchema };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from '@hono/zod-openapi';
|
|
2
|
+
import { LanguageIDSchema } from '../Language';
|
|
3
|
+
const CodeSnippetSchema = z.object({
|
|
4
|
+
language_id: LanguageIDSchema.clone(),
|
|
5
|
+
content: z.string(),
|
|
6
|
+
}).openapi({
|
|
7
|
+
example: { language_id: 'javascript', content: `console.log('Hello World');` }
|
|
8
|
+
});
|
|
9
|
+
export { CodeSnippetSchema };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from '@hono/zod-openapi';
|
|
2
|
+
declare const ServerStatisticsSchema: z.ZodObject<{
|
|
3
|
+
connected_users: z.ZodNumber;
|
|
4
|
+
connected_executors: z.ZodNumber;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
type ServerStatistics = z.infer<typeof ServerStatisticsSchema>;
|
|
7
|
+
export type { ServerStatistics };
|
|
8
|
+
export { ServerStatisticsSchema };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Server, Socket } from "socket.io";
|
|
2
|
+
interface InterServerEvents {
|
|
3
|
+
}
|
|
4
|
+
interface SocketData {
|
|
5
|
+
}
|
|
6
|
+
export type AppClientToServerEvents = {};
|
|
7
|
+
export type AppServerToClientEvents = {
|
|
8
|
+
"executorsConnected": (count: number) => void;
|
|
9
|
+
};
|
|
10
|
+
export type AppSocketServer = Server<AppClientToServerEvents, AppServerToClientEvents, InterServerEvents, SocketData>;
|
|
11
|
+
export type AppSocketClient = Socket<AppClientToServerEvents, AppServerToClientEvents, InterServerEvents, SocketData>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SocketTypes';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SocketTypes';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const ExecutorCodeRequestSchema: z.ZodObject<{
|
|
3
|
+
language: z.ZodEnum<{
|
|
4
|
+
[x: string]: string;
|
|
5
|
+
}>;
|
|
6
|
+
version: z.ZodString;
|
|
7
|
+
content: z.ZodString;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
type ExecutorCodeRequest = z.infer<typeof ExecutorCodeRequestSchema>;
|
|
10
|
+
export type { ExecutorCodeRequest };
|
|
11
|
+
export { ExecutorCodeRequestSchema };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Language } from '../../Language';
|
|
3
|
+
const executorLanguages = Language.all()
|
|
4
|
+
.map(language => language.executorDefinition.language);
|
|
5
|
+
const ExecutorCodeRequestSchema = z.object({
|
|
6
|
+
language: z.enum(executorLanguages),
|
|
7
|
+
version: z.string(),
|
|
8
|
+
content: z.string(),
|
|
9
|
+
});
|
|
10
|
+
export { ExecutorCodeRequestSchema };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const ExecutorCodeResultSchema: z.ZodObject<{
|
|
3
|
+
signal: z.ZodNullable<z.ZodAny>;
|
|
4
|
+
stdout: z.ZodString;
|
|
5
|
+
stderr: z.ZodString;
|
|
6
|
+
code: z.ZodNullable<z.ZodNumber>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
type ExecutorCodeResult = z.infer<typeof ExecutorCodeResultSchema>;
|
|
9
|
+
export type { ExecutorCodeResult };
|
|
10
|
+
export { ExecutorCodeResultSchema };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const ExecutorCodeResultSchema = z.object({
|
|
3
|
+
signal: z.any().nullable(),
|
|
4
|
+
stdout: z.string(),
|
|
5
|
+
stderr: z.string(),
|
|
6
|
+
code: z.number().nullable(),
|
|
7
|
+
// message: string | null
|
|
8
|
+
// status: any | null
|
|
9
|
+
// output: string
|
|
10
|
+
// memory: number,
|
|
11
|
+
// cpu_time: number,
|
|
12
|
+
// wall_time: number
|
|
13
|
+
});
|
|
14
|
+
export { ExecutorCodeResultSchema };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Namespace, Socket } from "socket.io";
|
|
2
|
+
import { ExecutorCodeRequest, ExecutorCodeResult } from ".";
|
|
3
|
+
import { Package } from "../../Package";
|
|
4
|
+
interface InterServerEvents {
|
|
5
|
+
}
|
|
6
|
+
interface SocketData {
|
|
7
|
+
}
|
|
8
|
+
export type ExecutorClientToServerEvents = {
|
|
9
|
+
"installedPackages": (packages: Package[]) => void;
|
|
10
|
+
"executorCodeResult": (uuid: string, code: ExecutorCodeResult) => void;
|
|
11
|
+
};
|
|
12
|
+
export type ExecutorServerToClientEvents = {
|
|
13
|
+
"wantedPackages": (packages: Package[]) => void;
|
|
14
|
+
"executorCodeExec": (uuid: string, code: ExecutorCodeRequest) => void;
|
|
15
|
+
};
|
|
16
|
+
export type ExecutorSocketNamespace = Namespace<ExecutorClientToServerEvents, ExecutorServerToClientEvents, InterServerEvents, SocketData>;
|
|
17
|
+
export type ExecutorSocketClient = Socket<ExecutorClientToServerEvents, ExecutorServerToClientEvents, InterServerEvents, SocketData>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const ExecutorCodeRequestSchema: z.ZodObject<{
|
|
3
|
+
language: z.ZodEnum<{
|
|
4
|
+
[x: string]: string;
|
|
5
|
+
}>;
|
|
6
|
+
version: z.ZodString;
|
|
7
|
+
content: z.ZodString;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
type ExecutorCodeRequest = z.infer<typeof ExecutorCodeRequestSchema>;
|
|
10
|
+
export type { ExecutorCodeRequest };
|
|
11
|
+
export { ExecutorCodeRequestSchema };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Language } from '../Language';
|
|
3
|
+
const executorLanguages = Language.all()
|
|
4
|
+
.map(language => language.executorDefinition.language);
|
|
5
|
+
const ExecutorCodeRequestSchema = z.object({
|
|
6
|
+
language: z.enum(executorLanguages),
|
|
7
|
+
version: z.string(),
|
|
8
|
+
content: z.string(),
|
|
9
|
+
});
|
|
10
|
+
export { ExecutorCodeRequestSchema };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const ExecutorCodeResultSchema: z.ZodObject<{
|
|
3
|
+
signal: z.ZodNullable<z.ZodAny>;
|
|
4
|
+
stdout: z.ZodString;
|
|
5
|
+
stderr: z.ZodString;
|
|
6
|
+
code: z.ZodNullable<z.ZodNumber>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
type ExecutorCodeResult = z.infer<typeof ExecutorCodeResultSchema>;
|
|
9
|
+
export type { ExecutorCodeResult };
|
|
10
|
+
export { ExecutorCodeResultSchema };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const ExecutorCodeResultSchema = z.object({
|
|
3
|
+
signal: z.any().nullable(),
|
|
4
|
+
stdout: z.string(),
|
|
5
|
+
stderr: z.string(),
|
|
6
|
+
code: z.number().nullable(),
|
|
7
|
+
// message: string | null
|
|
8
|
+
// status: any | null
|
|
9
|
+
// output: string
|
|
10
|
+
// memory: number,
|
|
11
|
+
// cpu_time: number,
|
|
12
|
+
// wall_time: number
|
|
13
|
+
});
|
|
14
|
+
export { ExecutorCodeResultSchema };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Namespace, Server, Socket } from "socket.io";
|
|
2
|
+
import { ExecutorCodeRequest, ExecutorCodeResult } from ".";
|
|
3
|
+
import { Package } from "../Package";
|
|
4
|
+
interface InterServerEvents {
|
|
5
|
+
}
|
|
6
|
+
interface SocketData {
|
|
7
|
+
}
|
|
8
|
+
export type AppClientToServerEvents = {};
|
|
9
|
+
export type AppServerToClientEvents = {
|
|
10
|
+
"executorsConnected": (count: number) => void;
|
|
11
|
+
};
|
|
12
|
+
export type AppSocketServer = Server<AppClientToServerEvents, AppServerToClientEvents, InterServerEvents, SocketData>;
|
|
13
|
+
export type AppSocketClient = Socket<AppClientToServerEvents, AppServerToClientEvents, InterServerEvents, SocketData>;
|
|
14
|
+
export type ExecutorClientToServerEvents = {
|
|
15
|
+
"installedPackages": (packages: Package[]) => void;
|
|
16
|
+
"executorCodeResult": (uuid: string, code: ExecutorCodeResult) => void;
|
|
17
|
+
};
|
|
18
|
+
export type ExecutorServerToClientEvents = {
|
|
19
|
+
"wantedPackages": (packages: Package[]) => void;
|
|
20
|
+
"executorCodeExec": (uuid: string, code: ExecutorCodeRequest) => void;
|
|
21
|
+
};
|
|
22
|
+
export type ExecutorSocketNamespace = Namespace<ExecutorClientToServerEvents, ExecutorServerToClientEvents, InterServerEvents, SocketData>;
|
|
23
|
+
export type ExecutorSocketClient = Socket<ExecutorClientToServerEvents, ExecutorServerToClientEvents, InterServerEvents, SocketData>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "code-share-types",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"files": [
|
|
5
|
+
"/dist"
|
|
6
|
+
],
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"require": "./dist/index.js",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./rest-api": {
|
|
14
|
+
"require": "./dist/rest-api/index.js",
|
|
15
|
+
"import": "./dist/rest-api/index.js",
|
|
16
|
+
"types": "./dist/rest-api/index.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"./socket/app": {
|
|
19
|
+
"require": "./dist/socket/app/index.js",
|
|
20
|
+
"import": "./dist/socket/app/index.js",
|
|
21
|
+
"types": "./dist/socket/app/index.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./socket/executor": {
|
|
24
|
+
"require": "./dist/socket/executor/index.js",
|
|
25
|
+
"import": "./dist/socket/executor/index.js",
|
|
26
|
+
"types": "./dist/socket/executor/index.d.ts"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc",
|
|
31
|
+
"prepublishOnly": "npm run build"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git@git.cs.bham.ac.uk:projects-2025-26/jfh245.git"
|
|
36
|
+
},
|
|
37
|
+
"author": "",
|
|
38
|
+
"license": "ISC",
|
|
39
|
+
"description": "",
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@hono/zod-openapi": "^1.1.4",
|
|
42
|
+
"react-bootstrap-icons": "^1.11.6",
|
|
43
|
+
"socket.io": "^4.8.1",
|
|
44
|
+
"typescript": "^5.9.3",
|
|
45
|
+
"zod": "^4.1.12"
|
|
46
|
+
}
|
|
47
|
+
}
|