code-share-types 0.14.0 → 1.1.0

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,14 +1,4 @@
1
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
2
  declare const LanguageExecutorDefinitionSchema: z.ZodObject<{
13
3
  runtime: z.ZodString;
14
4
  language: z.ZodString;
@@ -44,20 +34,3 @@ declare const LanguageExecutorDefinitionTestStatusMapSchema: z.ZodArray<z.ZodTup
44
34
  type LanguageExecutorDefinitionTestStatusMap = z.infer<typeof LanguageExecutorDefinitionTestStatusMapSchema>;
45
35
  export type { LanguageExecutorDefinitionTestStatusMap };
46
36
  export { LanguageExecutorDefinitionTestStatusMapSchema };
47
- export declare class Language {
48
- private static readonly LANGUAGES_METADATA;
49
- static get(language: LanguageID): Language;
50
- static all(): Language[];
51
- private readonly _languageId;
52
- private constructor();
53
- private get metadata();
54
- get languageId(): "javascript" | "typescript" | "java" | "python" | "c";
55
- get displayName(): string;
56
- get defaultCode(): string;
57
- get monacoEditorLanguage(): string;
58
- get executorDefinition(): {
59
- runtime: string;
60
- language: string;
61
- version: string;
62
- };
63
- }
package/dist/Language.js CHANGED
@@ -1,15 +1,4 @@
1
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
2
  const LanguageExecutorDefinitionSchema = z.object({
14
3
  runtime: z.string(),
15
4
  language: z.string(),
@@ -26,72 +15,3 @@ const LanguageExecutorDefinitionTestStatusSchema = z.enum(Object.values(LANGUAGE
26
15
  export { LANGUAGE_EXECUTOR_DEFINITION_TEST_STATUS, LanguageExecutorDefinitionTestStatusSchema };
27
16
  const LanguageExecutorDefinitionTestStatusMapSchema = z.array(z.tuple([LanguageExecutorDefinitionSchema, LanguageExecutorDefinitionTestStatusSchema]));
28
17
  export { LanguageExecutorDefinitionTestStatusMapSchema };
29
- export class Language {
30
- static get(language) {
31
- LanguageIDSchema.parse(language); // will throw error if invalid
32
- return new Language(language);
33
- }
34
- static all() {
35
- return AVAILABLE_LANGUAGE_IDS.map(id => new Language(id));
36
- }
37
- constructor(languageId) {
38
- this._languageId = languageId;
39
- }
40
- get metadata() {
41
- return Language.LANGUAGES_METADATA[this._languageId];
42
- }
43
- get languageId() {
44
- return this._languageId;
45
- }
46
- get displayName() {
47
- return this.metadata.displayName;
48
- }
49
- get defaultCode() {
50
- return this.metadata.defaultCode;
51
- }
52
- get monacoEditorLanguage() {
53
- return this.metadata.monacoEditorLanguage;
54
- }
55
- get executorDefinition() {
56
- return this.metadata.executorDefinition;
57
- }
58
- }
59
- Language.LANGUAGES_METADATA = {
60
- "javascript": {
61
- displayName: "JavaScript",
62
- monacoEditorLanguage: "javascript",
63
- executorDefinition: { runtime: "node", language: "javascript", version: "20.11.1" },
64
- defaultCode: `console.log("Hello World!");`,
65
- },
66
- "typescript": {
67
- displayName: "TypeScript",
68
- monacoEditorLanguage: "typescript",
69
- executorDefinition: { runtime: "typescript", language: "typescript", version: "5.0.3", },
70
- defaultCode: `console.log("Hello World!");`,
71
- },
72
- "java": {
73
- displayName: "Java",
74
- monacoEditorLanguage: "java",
75
- executorDefinition: { runtime: "java", language: "java", version: "15", },
76
- defaultCode: `class Main {
77
- public static void main(String[] args) {
78
- System.out.println("Hello World!");
79
- }
80
- }`,
81
- },
82
- "python": {
83
- displayName: "Python",
84
- monacoEditorLanguage: "python",
85
- executorDefinition: { runtime: "python", language: "python", version: "3.9.4", },
86
- defaultCode: `print("Hello World!")`,
87
- },
88
- "c": {
89
- displayName: "C",
90
- monacoEditorLanguage: "c",
91
- executorDefinition: { runtime: "gcc", language: "gcc", version: "10.2.0", },
92
- defaultCode: `int main() {
93
- printf("Hello World!");
94
- return 0;
95
- }`,
96
- },
97
- };
@@ -1,12 +1,16 @@
1
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<{
2
+ declare const AvailableLanguageSchema: z.ZodObject<{
9
3
  displayName: z.ZodString;
4
+ defaultCode: z.ZodString;
5
+ monacoEditorLanguage: z.ZodString;
6
+ }, z.core.$strip>;
7
+ type AvailableLanguage = z.infer<typeof AvailableLanguageSchema>;
8
+ export type { AvailableLanguage };
9
+ export { AvailableLanguageSchema };
10
+ declare const AvailableLanguagesSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
11
+ displayName: z.ZodString;
12
+ defaultCode: z.ZodString;
13
+ monacoEditorLanguage: z.ZodString;
10
14
  }, z.core.$strip>>;
11
15
  type AvailableLanguages = z.infer<typeof AvailableLanguagesSchema>;
12
16
  export type { AvailableLanguages };
@@ -1,6 +1,9 @@
1
1
  import { z } from '@hono/zod-openapi';
2
- import { LanguageIDSchema } from '../Language';
3
- const AvailableLanguagesSchema = z.record(LanguageIDSchema, z.object({
2
+ const AvailableLanguageSchema = z.object({
4
3
  displayName: z.string(),
5
- }));
4
+ defaultCode: z.string(),
5
+ monacoEditorLanguage: z.string(),
6
+ });
7
+ export { AvailableLanguageSchema };
8
+ const AvailableLanguagesSchema = z.record(z.string(), AvailableLanguageSchema);
6
9
  export { AvailableLanguagesSchema };
@@ -1,12 +1,6 @@
1
1
  import { z } from '@hono/zod-openapi';
2
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
- }>;
3
+ language_id: z.ZodString;
10
4
  content: z.ZodString;
11
5
  }, z.core.$strip>;
12
6
  type CodeExecutionRequest = z.infer<typeof CodeExecutionRequestSchema>;
@@ -1,7 +1,6 @@
1
1
  import { z } from '@hono/zod-openapi';
2
- import { LanguageIDSchema } from '../Language';
3
2
  const CodeExecutionRequestSchema = z.object({
4
- language_id: LanguageIDSchema.clone(),
3
+ language_id: z.string(),
5
4
  content: z.string(),
6
5
  }).openapi({
7
6
  example: { language_id: 'javascript', content: `console.log('Hello World');` }
@@ -1,12 +1,6 @@
1
1
  import { z } from '@hono/zod-openapi';
2
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
- }>;
3
+ language_id: z.ZodString;
10
4
  content: z.ZodString;
11
5
  }, z.core.$strip>;
12
6
  type CodeSnippet = z.infer<typeof CodeSnippetSchema>;
@@ -1,7 +1,6 @@
1
1
  import { z } from '@hono/zod-openapi';
2
- import { LanguageIDSchema } from '../Language';
3
2
  const CodeSnippetSchema = z.object({
4
- language_id: LanguageIDSchema.clone(),
3
+ language_id: z.string(),
5
4
  content: z.string(),
6
5
  }).openapi({
7
6
  example: { language_id: 'javascript', content: `console.log('Hello World');` }
@@ -1,8 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  declare const ExecutorCodeRequestSchema: z.ZodObject<{
3
- language: z.ZodEnum<{
4
- [x: string]: string;
5
- }>;
3
+ language: z.ZodString;
6
4
  version: z.ZodString;
7
5
  content: z.ZodString;
8
6
  }, z.core.$strip>;
@@ -1,9 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { Language } from '../../Language';
3
- const executorLanguages = Language.all()
4
- .map(language => language.executorDefinition.language);
5
2
  const ExecutorCodeRequestSchema = z.object({
6
- language: z.enum(executorLanguages),
3
+ language: z.string(),
7
4
  version: z.string(),
8
5
  content: z.string(),
9
6
  });
@@ -9,6 +9,7 @@ type CodeExecutionStatistics = z.infer<typeof CodeExecutionStatisticsSchema>;
9
9
  export type { CodeExecutionStatistics };
10
10
  export { CodeExecutionStatisticsSchema };
11
11
  declare const EXECUTOR_STATUS: {
12
+ readonly versions_incompatible: "VERSIONS_INCOMPATIBLE";
12
13
  readonly install_waiting: "INSTALL_UNINITIALISED";
13
14
  readonly install_failed: "INSTALL_FAILED";
14
15
  readonly install_inprogress: "INSTALL_INPROGRESS";
@@ -18,9 +19,11 @@ declare const EXECUTOR_STATUS: {
18
19
  readonly tests_inprogress: "TESTS_INPROGRESS";
19
20
  readonly tests_pending: "TESTS_PENDING";
20
21
  readonly tests_passed: "TESTS_PASSED";
22
+ readonly unknown_failure: "UNKNOWN_FAILURE";
21
23
  readonly unknown: "UNKNOWN";
22
24
  };
23
25
  declare const ExecutorStatusSchema: z.ZodEnum<{
26
+ VERSIONS_INCOMPATIBLE: "VERSIONS_INCOMPATIBLE";
24
27
  INSTALL_UNINITIALISED: "INSTALL_UNINITIALISED";
25
28
  INSTALL_FAILED: "INSTALL_FAILED";
26
29
  INSTALL_INPROGRESS: "INSTALL_INPROGRESS";
@@ -30,6 +33,7 @@ declare const ExecutorStatusSchema: z.ZodEnum<{
30
33
  TESTS_INPROGRESS: "TESTS_INPROGRESS";
31
34
  TESTS_PENDING: "TESTS_PENDING";
32
35
  TESTS_PASSED: "TESTS_PASSED";
36
+ UNKNOWN_FAILURE: "UNKNOWN_FAILURE";
33
37
  UNKNOWN: "UNKNOWN";
34
38
  }>;
35
39
  type ExecutorStatus = z.infer<typeof ExecutorStatusSchema>;
@@ -46,6 +50,7 @@ export { ExecutorTypesVersionCompatabilitySchema };
46
50
  declare const ExecutorInformationSchema: z.ZodObject<{
47
51
  socket_id: z.ZodString;
48
52
  status: z.ZodEnum<{
53
+ VERSIONS_INCOMPATIBLE: "VERSIONS_INCOMPATIBLE";
49
54
  INSTALL_UNINITIALISED: "INSTALL_UNINITIALISED";
50
55
  INSTALL_FAILED: "INSTALL_FAILED";
51
56
  INSTALL_INPROGRESS: "INSTALL_INPROGRESS";
@@ -55,6 +60,7 @@ declare const ExecutorInformationSchema: z.ZodObject<{
55
60
  TESTS_INPROGRESS: "TESTS_INPROGRESS";
56
61
  TESTS_PENDING: "TESTS_PENDING";
57
62
  TESTS_PASSED: "TESTS_PASSED";
63
+ UNKNOWN_FAILURE: "UNKNOWN_FAILURE";
58
64
  UNKNOWN: "UNKNOWN";
59
65
  }>;
60
66
  ready: z.ZodBoolean;
@@ -104,6 +110,7 @@ export { ExecutorInformationSchema };
104
110
  declare const ExecutorInformationListSchema: z.ZodArray<z.ZodObject<{
105
111
  socket_id: z.ZodString;
106
112
  status: z.ZodEnum<{
113
+ VERSIONS_INCOMPATIBLE: "VERSIONS_INCOMPATIBLE";
107
114
  INSTALL_UNINITIALISED: "INSTALL_UNINITIALISED";
108
115
  INSTALL_FAILED: "INSTALL_FAILED";
109
116
  INSTALL_INPROGRESS: "INSTALL_INPROGRESS";
@@ -113,6 +120,7 @@ declare const ExecutorInformationListSchema: z.ZodArray<z.ZodObject<{
113
120
  TESTS_INPROGRESS: "TESTS_INPROGRESS";
114
121
  TESTS_PENDING: "TESTS_PENDING";
115
122
  TESTS_PASSED: "TESTS_PASSED";
123
+ UNKNOWN_FAILURE: "UNKNOWN_FAILURE";
116
124
  UNKNOWN: "UNKNOWN";
117
125
  }>;
118
126
  ready: z.ZodBoolean;
@@ -9,6 +9,7 @@ const CodeExecutionStatisticsSchema = z.object({
9
9
  });
10
10
  export { CodeExecutionStatisticsSchema };
11
11
  const EXECUTOR_STATUS = {
12
+ versions_incompatible: 'VERSIONS_INCOMPATIBLE',
12
13
  install_waiting: 'INSTALL_UNINITIALISED',
13
14
  install_failed: 'INSTALL_FAILED',
14
15
  install_inprogress: 'INSTALL_INPROGRESS',
@@ -18,6 +19,7 @@ const EXECUTOR_STATUS = {
18
19
  tests_inprogress: 'TESTS_INPROGRESS',
19
20
  tests_pending: 'TESTS_PENDING',
20
21
  tests_passed: 'TESTS_PASSED',
22
+ unknown_failure: 'UNKNOWN_FAILURE',
21
23
  unknown: 'UNKNOWN',
22
24
  };
23
25
  const ExecutorStatusSchema = z.enum(Object.values(EXECUTOR_STATUS));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-share-types",
3
- "version": "0.14.0",
3
+ "version": "1.1.0",
4
4
  "files": [
5
5
  "/dist"
6
6
  ],