web/satellite: generate TypeScript for frontend config
A package has been written to generate a TypeScript file containing classes corresponding to the frontend config. These classes will be used across the frontend once we no longer reference meta tag values for configuration. References #5494 Change-Id: If425035892773167ac6d9fbfae8140cab79fbb70
This commit is contained in:
parent
4d823e8166
commit
c4f8695e8a
61
web/satellite/src/utils/config.gen.ts
Normal file
61
web/satellite/src/utils/config.gen.ts
Normal file
@ -0,0 +1,61 @@
|
||||
// AUTOGENERATED BY configgen.go
|
||||
// DO NOT EDIT.
|
||||
|
||||
import { MemorySize } from '@/types/common';
|
||||
|
||||
export class CaptchaConfig {
|
||||
login: MultiCaptchaConfig;
|
||||
registration: MultiCaptchaConfig;
|
||||
}
|
||||
|
||||
export class FrontendConfig {
|
||||
externalAddress: string;
|
||||
satelliteName: string;
|
||||
satelliteNodeURL: string;
|
||||
stripePublicKey: string;
|
||||
partneredSatellites: PartneredSatellite[];
|
||||
defaultProjectLimit: number;
|
||||
generalRequestURL: string;
|
||||
projectLimitsIncreaseRequestURL: string;
|
||||
gatewayCredentialsRequestURL: string;
|
||||
isBetaSatellite: boolean;
|
||||
betaSatelliteFeedbackURL: string;
|
||||
betaSatelliteSupportURL: string;
|
||||
documentationURL: string;
|
||||
couponCodeBillingUIEnabled: boolean;
|
||||
couponCodeSignupUIEnabled: boolean;
|
||||
fileBrowserFlowDisabled: boolean;
|
||||
linksharingURL: string;
|
||||
pathwayOverviewEnabled: boolean;
|
||||
captcha: CaptchaConfig;
|
||||
allProjectsDashboard: boolean;
|
||||
defaultPaidStorageLimit: MemorySize;
|
||||
defaultPaidBandwidthLimit: MemorySize;
|
||||
newBillingScreen: boolean;
|
||||
newAccessGrantFlow: boolean;
|
||||
inactivityTimerEnabled: boolean;
|
||||
inactivityTimerDuration: number;
|
||||
inactivityTimerViewerEnabled: boolean;
|
||||
optionalSignupSuccessURL: string;
|
||||
homepageURL: string;
|
||||
nativeTokenPaymentsEnabled: boolean;
|
||||
passwordMinimumLength: number;
|
||||
passwordMaximumLength: number;
|
||||
abTestingEnabled: boolean;
|
||||
pricingPackagesEnabled: boolean;
|
||||
}
|
||||
|
||||
export class MultiCaptchaConfig {
|
||||
recaptcha: SingleCaptchaConfig;
|
||||
hcaptcha: SingleCaptchaConfig;
|
||||
}
|
||||
|
||||
export class PartneredSatellite {
|
||||
name: string;
|
||||
address: string;
|
||||
}
|
||||
|
||||
export class SingleCaptchaConfig {
|
||||
enabled: boolean;
|
||||
siteKey: string;
|
||||
}
|
45
web/satellite/src/utils/configgen.go
Normal file
45
web/satellite/src/utils/configgen.go
Normal file
@ -0,0 +1,45 @@
|
||||
// Copyright (C) 2023 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
package main
|
||||
|
||||
//go:generate go run $GOFILE -o=config.gen.ts
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"storj.io/storj/private/apigen"
|
||||
"storj.io/storj/satellite/console/consoleweb"
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.CommandLine = flag.NewFlagSet("configgen", flag.ExitOnError)
|
||||
outPath := flag.String("o", "", "path to the output file")
|
||||
flag.Parse()
|
||||
|
||||
if *outPath == "" {
|
||||
fmt.Fprintln(os.Stderr, "missing required argument -o")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
var result apigen.StringBuilder
|
||||
pf := result.Writelnf
|
||||
|
||||
pf("// AUTOGENERATED BY configgen.go")
|
||||
pf("// DO NOT EDIT.")
|
||||
pf("")
|
||||
|
||||
types := apigen.NewTypes()
|
||||
types.Register(reflect.TypeOf(consoleweb.FrontendConfig{}))
|
||||
result.WriteString(types.GenerateTypescriptDefinitions())
|
||||
|
||||
content := strings.ReplaceAll(result.String(), "\t", " ")
|
||||
err := os.WriteFile("config.gen.ts", []byte(content), 0644)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user