diff --git a/package-lock.json b/package-lock.json
index 5a807cb..33b9226 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -18,6 +18,7 @@
"@globus/sdk": "^4.3.1",
"@monaco-editor/react": "^4.6.0",
"framer-motion": "^11.11.7",
+ "idb-keyval": "^6.2.1",
"lodash": "^4.17.21",
"lz-string": "^1.5.0",
"next": "14.2.15",
@@ -30,6 +31,7 @@
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
+ "@types/wicg-file-system-access": "^2023.10.5",
"eslint": "^8",
"eslint-config-next": "14.2.13",
"eslint-config-prettier": "^9.1.0",
@@ -2553,6 +2555,12 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/@types/wicg-file-system-access": {
+ "version": "2023.10.5",
+ "resolved": "https://registry.npmjs.org/@types/wicg-file-system-access/-/wicg-file-system-access-2023.10.5.tgz",
+ "integrity": "sha512-e9kZO9kCdLqT2h9Tw38oGv9UNzBBWaR1MzuAavxPcsV/7FJ3tWbU6RI3uB+yKIDPGLkGVbplS52ub0AcRLvrhA==",
+ "dev": true
+ },
"node_modules/@typescript-eslint/eslint-plugin": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.2.0.tgz",
@@ -4563,6 +4571,11 @@
"react-is": "^16.7.0"
}
},
+ "node_modules/idb-keyval": {
+ "version": "6.2.1",
+ "resolved": "https://registry.npmjs.org/idb-keyval/-/idb-keyval-6.2.1.tgz",
+ "integrity": "sha512-8Sb3veuYCyrZL+VBt9LJfZjLUPWVvqn8tG28VqYNFCo43KHcKuq+b4EiXGeuaLAQWL2YmyDgMp2aSpH9JHsEQg=="
+ },
"node_modules/ignore": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.0.tgz",
diff --git a/package.json b/package.json
index f4237a4..6c820e4 100644
--- a/package.json
+++ b/package.json
@@ -19,6 +19,7 @@
"@globus/sdk": "^4.3.1",
"@monaco-editor/react": "^4.6.0",
"framer-motion": "^11.11.7",
+ "idb-keyval": "^6.2.1",
"lodash": "^4.17.21",
"lz-string": "^1.5.0",
"next": "14.2.15",
@@ -31,6 +32,7 @@
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
+ "@types/wicg-file-system-access": "^2023.10.5",
"eslint": "^8",
"eslint-config-next": "14.2.13",
"eslint-config-prettier": "^9.1.0",
diff --git a/public/schemas/input_schema_schema.json b/public/schemas/input_schema_schema.json
new file mode 100644
index 0000000..4e2623a
--- /dev/null
+++ b/public/schemas/input_schema_schema.json
@@ -0,0 +1,246 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "$id": "http://json-schema.org/draft-07/schema#",
+ "title": "Core schema meta-schema",
+ "definitions": {
+ "schemaArray": {
+ "type": "array",
+ "minItems": 1,
+ "items": {
+ "$ref": "#"
+ }
+ },
+ "nonNegativeInteger": {
+ "type": "integer",
+ "minimum": 0
+ },
+ "nonNegativeIntegerDefault0": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/nonNegativeInteger"
+ },
+ {
+ "default": 0
+ }
+ ]
+ },
+ "simpleTypes": {
+ "enum": [
+ "array",
+ "boolean",
+ "integer",
+ "null",
+ "number",
+ "object",
+ "string"
+ ]
+ },
+ "stringArray": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "uniqueItems": true,
+ "default": []
+ }
+ },
+ "type": ["object", "boolean"],
+ "properties": {
+ "$id": {
+ "type": "string",
+ "format": "uri-reference"
+ },
+ "$schema": {
+ "type": "string",
+ "format": "uri"
+ },
+ "$ref": {
+ "type": "string",
+ "format": "uri-reference"
+ },
+ "$comment": {
+ "type": "string"
+ },
+ "title": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "default": true,
+ "readOnly": {
+ "type": "boolean",
+ "default": false
+ },
+ "writeOnly": {
+ "type": "boolean",
+ "default": false
+ },
+ "examples": {
+ "type": "array",
+ "items": true
+ },
+ "multipleOf": {
+ "type": "number",
+ "exclusiveMinimum": 0
+ },
+ "maximum": {
+ "type": "number"
+ },
+ "exclusiveMaximum": {
+ "type": "number"
+ },
+ "minimum": {
+ "type": "number"
+ },
+ "exclusiveMinimum": {
+ "type": "number"
+ },
+ "maxLength": {
+ "$ref": "#/definitions/nonNegativeInteger"
+ },
+ "minLength": {
+ "$ref": "#/definitions/nonNegativeIntegerDefault0"
+ },
+ "pattern": {
+ "type": "string",
+ "format": "regex"
+ },
+ "additionalItems": {
+ "$ref": "#"
+ },
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#"
+ },
+ {
+ "$ref": "#/definitions/schemaArray"
+ }
+ ],
+ "default": true
+ },
+ "maxItems": {
+ "$ref": "#/definitions/nonNegativeInteger"
+ },
+ "minItems": {
+ "$ref": "#/definitions/nonNegativeIntegerDefault0"
+ },
+ "uniqueItems": {
+ "type": "boolean",
+ "default": false
+ },
+ "contains": {
+ "$ref": "#"
+ },
+ "maxProperties": {
+ "$ref": "#/definitions/nonNegativeInteger"
+ },
+ "minProperties": {
+ "$ref": "#/definitions/nonNegativeIntegerDefault0"
+ },
+ "required": {
+ "$ref": "#/definitions/stringArray"
+ },
+ "additionalProperties": {
+ "$ref": "#"
+ },
+ "definitions": {
+ "type": "object",
+ "additionalProperties": {
+ "$ref": "#"
+ },
+ "default": {}
+ },
+ "properties": {
+ "type": "object",
+ "additionalProperties": {
+ "$ref": "#"
+ },
+ "default": {}
+ },
+ "patternProperties": {
+ "type": "object",
+ "additionalProperties": {
+ "$ref": "#"
+ },
+ "propertyNames": {
+ "format": "regex"
+ },
+ "default": {}
+ },
+ "dependencies": {
+ "type": "object",
+ "additionalProperties": {
+ "anyOf": [
+ {
+ "$ref": "#"
+ },
+ {
+ "$ref": "#/definitions/stringArray"
+ }
+ ]
+ }
+ },
+ "propertyNames": {
+ "$ref": "#"
+ },
+ "const": true,
+ "enum": {
+ "type": "array",
+ "items": true,
+ "minItems": 1,
+ "uniqueItems": true
+ },
+ "type": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/simpleTypes"
+ },
+ {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/simpleTypes"
+ },
+ "minItems": 1,
+ "uniqueItems": true
+ }
+ ]
+ },
+ "format": {
+ "type": "string"
+ },
+ "contentMediaType": {
+ "type": "string"
+ },
+ "contentEncoding": {
+ "type": "string"
+ },
+ "if": {
+ "$ref": "#"
+ },
+ "then": {
+ "$ref": "#"
+ },
+ "else": {
+ "$ref": "#"
+ },
+ "allOf": {
+ "$ref": "#/definitions/schemaArray"
+ },
+ "anyOf": {
+ "$ref": "#/definitions/schemaArray"
+ },
+ "oneOf": {
+ "$ref": "#/definitions/schemaArray"
+ },
+ "not": {
+ "$ref": "#"
+ },
+ "propertyOrder": {
+ "$ref": "#/definitions/stringArray"
+ }
+ },
+ "default": true,
+ "additionalProperties": false
+}
diff --git a/src/components/Editor.tsx b/src/components/Editor.tsx
index 7bc06bf..2d41642 100644
--- a/src/components/Editor.tsx
+++ b/src/components/Editor.tsx
@@ -6,9 +6,22 @@ import MonacoEditor, {
} from "@monaco-editor/react";
import { ValidateButton } from "./Validate";
import { Box } from "@chakra-ui/react";
+import { useEditorStore } from "@/stores/editor";
+
+export const MODES = {
+ DEFINITION: "DEFINITION",
+ INPUT_SCHEMA: "INPUT_SCHEMA",
+} as const;
+
+export type SupportedModes = keyof typeof MODES;
+
+function isDefinitionMode(settings?: InteralSettings) {
+ return settings?.mode === MODES.DEFINITION || !settings?.mode;
+}
type InteralSettings = {
- enableExperimentalValidation: boolean;
+ mode?: SupportedModes;
+ enableExperimentalValidation?: boolean;
};
function configureEditor(
@@ -17,6 +30,7 @@ function configureEditor(
enableExperimentalValidation: true,
},
) {
+ console.log("Configuring editor with settings", settings);
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
enableSchemaRequest: true,
validate: true,
@@ -26,7 +40,11 @@ function configureEditor(
schemas: [
{
uri: `${window.location.origin}${process.env.NEXT_PUBLIC_BASE_PATH}/schemas/flow_definition_schema.json`,
- fileMatch: ["*"],
+ fileMatch: ["definition.json"],
+ },
+ {
+ uri: `${window.location.origin}${process.env.NEXT_PUBLIC_BASE_PATH}/schemas/input_schema_schema.json`,
+ fileMatch: ["input-schema.json"],
},
],
});
@@ -35,6 +53,13 @@ function configureEditor(
export default function Editor(
props: { settings?: InteralSettings } & EditorProps,
) {
+ const editoreStore = useEditorStore();
+ const settings = {
+ ...props.settings,
+ mode: isDefinitionMode(props.settings)
+ ? MODES.DEFINITION
+ : MODES.INPUT_SCHEMA,
+ };
return (
<>