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:
Jeremy Wharton 2023-03-08 01:33:58 -06:00 committed by Storj Robot
parent 4d823e8166
commit c4f8695e8a
2 changed files with 106 additions and 0 deletions

View 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;
}

View 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)
}
}