-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
1,753 additions
and
771 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2025, Command Line Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"log" | ||
"os" | ||
|
||
"github.com/invopop/jsonschema" | ||
"github.com/wavetermdev/waveterm/pkg/util/utilfn" | ||
"github.com/wavetermdev/waveterm/pkg/wconfig" | ||
) | ||
|
||
const WaveSchemaSettingsFileName = "schema/settings.json" | ||
|
||
func main() { | ||
settingsSchema := jsonschema.Reflect(&wconfig.SettingsType{}) | ||
|
||
jsonSettingsSchema, err := json.MarshalIndent(settingsSchema, "", " ") | ||
if err != nil { | ||
log.Fatalf("failed to parse local schema: %v", err) | ||
} | ||
/* | ||
err = os.MkdirAll(WaveSchemaSettingsFileName, 0755) | ||
if err != nil { | ||
log.Fatalf("failed to create schema dir: %v", err) | ||
} | ||
*/ | ||
written, err := utilfn.WriteFileIfDifferent(WaveSchemaSettingsFileName, jsonSettingsSchema) | ||
if !written { | ||
fmt.Fprintf(os.Stderr, "no changes to %s\n", WaveSchemaSettingsFileName) | ||
} | ||
if err != nil { | ||
log.Fatalf("failed to write local schema: %v", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2025, Command Line Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { getApi } from "@/app/store/global"; | ||
import { getWebServerEndpoint } from "@/util/endpoints"; | ||
|
||
type EndpointInfo = { | ||
uri: string; | ||
fileMatch: Array<string>; | ||
schema: object; | ||
}; | ||
|
||
const allFilepaths: Map<string, Array<string>> = new Map(); | ||
allFilepaths.set(`${getWebServerEndpoint()}/schema/settings.json`, [`${getApi().getConfigDir()}/settings.json`]); | ||
|
||
async function getSchemaEndpointInfo(endpoint: string): Promise<EndpointInfo> { | ||
let schema: Object; | ||
try { | ||
const data = await fetch(endpoint); | ||
const fullSchema: object = await data.json(); | ||
const schemaRef: string = fullSchema?.["$ref"]; | ||
schema = fullSchema?.[schemaRef]; | ||
} catch (e) { | ||
console.log("cannot find schema:", e); | ||
schema = {}; | ||
} | ||
const fileMatch = allFilepaths.get(endpoint) ?? []; | ||
|
||
return { | ||
uri: endpoint, | ||
fileMatch, | ||
schema, | ||
}; | ||
} | ||
|
||
const SchemaEndpoints = Array.from(allFilepaths.keys()); | ||
|
||
export { getSchemaEndpointInfo, SchemaEndpoints }; |
Oops, something went wrong.