code-share-types 0.13.0 → 1.0.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,7 +1,9 @@
1
1
  import { z } from '@hono/zod-openapi';
2
2
  declare const ServerStatisticsSchema: z.ZodObject<{
3
- connected_users: z.ZodNumber;
4
- connected_executors: z.ZodNumber;
3
+ connected_users: z.ZodInt;
4
+ connected_executors: z.ZodInt;
5
+ total_languages_supported: z.ZodInt;
6
+ total_snippets_created: z.ZodInt;
5
7
  }, z.core.$strip>;
6
8
  type ServerStatistics = z.infer<typeof ServerStatisticsSchema>;
7
9
  export type { ServerStatistics };
@@ -1,8 +1,10 @@
1
1
  import { z } from '@hono/zod-openapi';
2
2
  const ServerStatisticsSchema = z.object({
3
- connected_users: z.number(),
4
- connected_executors: z.number(),
3
+ connected_users: z.int().gte(0),
4
+ connected_executors: z.int().gte(0),
5
+ total_languages_supported: z.int().gte(0),
6
+ total_snippets_created: z.int().gte(0),
5
7
  }).openapi({
6
- example: { connected_users: 12, connected_executors: 3 }
8
+ example: { connected_users: 12, connected_executors: 3, total_languages_supported: 8, total_snippets_created: 10, },
7
9
  });
8
10
  export { ServerStatisticsSchema };
@@ -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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-share-types",
3
- "version": "0.13.0",
3
+ "version": "1.0.0",
4
4
  "files": [
5
5
  "/dist"
6
6
  ],