local

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// app configs
	NameRealmConfig = "realm_config"
	NameConfig      = "config"
	NameStitch      = "stitch"

	// environments
	NameEnvironments = "environments"

	// auth
	NameAuth           = "auth"
	NameAuthProviders  = "auth_providers"
	NameCustomUserData = "custom_user_data"
	NameProviders      = "providers"

	// functions
	NameFunctions = "functions"

	NameSource = "source"

	// graphql
	NameGraphQL         = "graphql"
	NameCustomResolvers = "custom_resolvers"

	// hosting
	NameHosting  = "hosting"
	NameFiles    = "files"
	NameMetadata = "metadata"

	// services
	NameDataSources      = "data_sources"
	NameHTTPEndpoints    = "http_endpoints"
	NameIncomingWebhooks = "incoming_webhooks"
	NameRules            = "rules"
	NameSchema           = "schema"
	NameServices         = "services"
	NameRelationships    = "relationships"

	// triggers
	NameTriggers = "triggers"

	// sync
	NameSync = "sync"

	// values
	NameSecrets = "secrets"
	NameValues  = "values"
)

set of supported local names

Variables

View Source
var (
	// app configs
	FileRealmConfig = File{NameRealmConfig, extJSON}
	FileConfig      = File{NameConfig, extJSON}
	FileStitch      = File{NameStitch, extJSON}

	// auth
	FileCustomUserData = File{NameCustomUserData, extJSON}
	FileProviders      = File{NameProviders, extJSON}

	// data sources
	FileRules         = File{NameRules, extJSON}
	FileSchema        = File{NameSchema, extJSON}
	FileRelationships = File{NameRelationships, extJSON}

	// functions
	FileSource = File{NameSource, extJS}

	// values
	FileSecrets = File{NameSecrets, extJSON}
)

set of supported local files

Functions

func AddAuthProvider

func AddAuthProvider(appData AppData, name string, config map[string]interface{})

AddAuthProvider adds an auth provider to the provided app data

func AddDataSource

func AddDataSource(appData AppData, config map[string]interface{})

AddDataSource adds a data source to the app data

func MarshalJSON

func MarshalJSON(o interface{}) ([]byte, error)

MarshalJSON returns the json representation of the passed in interface

func PrepareDependencies

func PrepareDependencies(app App, ui terminal.UI) (string, error)

PrepareDependencies finds and prepares an app's dependencies upload package by creating a .zip file, while using the ui spinner during the transpiling containing the specified archive's transpiled file contents in a tempmorary directory and returns that file path

func WriteFile

func WriteFile(path string, perm os.FileMode, r io.Reader) error

WriteFile writes the file to the specified path with the specified permissions

func WriteHostingAssets

func WriteHostingAssets(assetClient HostingAssetClient, rootDir, groupID, appID string, appAssets []realm.HostingAsset) error

WriteHostingAssets writes the hosting assets to disk

func WriteZip

func WriteZip(wd string, zipPkg *zip.Reader) error

WriteZip writes the zip contents to the specified filepath

Types

type App

type App struct {
	RootDir string
	Config  File
	AppData
}

App is the Realm app data represented on the local filesystem

func AsApp

func AsApp(rootDir string, app realm.App, configVersion realm.AppConfigVersion) App

AsApp converts the realm.App into a local app

func FindApp

func FindApp(path string) (App, bool, error)

FindApp searches upwards for the root of a Realm app project and returns the local app structure, a boolean indicating if the current working directory is part of a Realm app project, and any error that occurs

func LoadApp

func LoadApp(path string) (App, error)

LoadApp will load the local app data

func LoadAppConfig

func LoadAppConfig(path string) (App, error)

LoadAppConfig will load the local app config

func NewApp

func NewApp(rootDir, clientAppID, name string, location realm.Location, deploymentModel realm.DeploymentModel, environment realm.Environment, configVersion realm.AppConfigVersion) App

NewApp returns a new local app

func (*App) Load

func (a *App) Load() error

Load will load the entire local app's data

func (*App) LoadConfig

func (a *App) LoadConfig() error

LoadConfig will load the local app's config

func (App) Option

func (a App) Option() string

Option returns the Realm app data displayed as a selectable option

func (App) Write

func (a App) Write() error

Write writes the app data to disk

func (App) WriteConfig

func (a App) WriteConfig() error

WriteConfig writes the app config file to disk

type AppConfigJSON

type AppConfigJSON struct {
	AppDataV1
}

AppConfigJSON is the app config.json data

func NewAppConfigJSON

func NewAppConfigJSON(name string, meta realm.AppMeta) AppConfigJSON

NewAppConfigJSON returns app config.json data

type AppData

type AppData interface {
	ConfigData() ([]byte, error)
	ConfigVersion() realm.AppConfigVersion
	ID() string
	Name() string
	Location() realm.Location
	DeploymentModel() realm.DeploymentModel
	Environment() realm.Environment
	LoadData(rootDir string) error
	WriteData(rootDir string) error
}

AppData is the Realm app data

type AppDataV1

type AppDataV1 struct {
	AppStructureV1
}

AppDataV1 is the v1 local Realm app data

func (AppDataV1) ConfigData

func (a AppDataV1) ConfigData() ([]byte, error)

ConfigData marshals the config data out to JSON

func (AppDataV1) ConfigVersion

func (a AppDataV1) ConfigVersion() realm.AppConfigVersion

ConfigVersion returns the local Realm app config version

func (AppDataV1) DeploymentModel

func (a AppDataV1) DeploymentModel() realm.DeploymentModel

DeploymentModel returns the local Realm app deployment model

func (AppDataV1) Environment

func (a AppDataV1) Environment() realm.Environment

Environment returns the local Realm app environment

func (AppDataV1) ID

func (a AppDataV1) ID() string

ID returns the local Realm app id

func (*AppDataV1) LoadData

func (a *AppDataV1) LoadData(rootDir string) error

LoadData will load the local Realm app data

func (AppDataV1) Location

func (a AppDataV1) Location() realm.Location

Location returns the local Realm app location

func (AppDataV1) Name

func (a AppDataV1) Name() string

Name returns the local Realm app name

func (*AppDataV1) WriteData

func (a *AppDataV1) WriteData(rootDir string) error

WriteData will write the local Realm app data to disk

type AppDataV2

type AppDataV2 struct {
	AppStructureV2
}

AppDataV2 is the v2 local Realm app data

func (AppDataV2) ConfigData

func (a AppDataV2) ConfigData() ([]byte, error)

ConfigData marshals the config data out to JSON

func (AppDataV2) ConfigVersion

func (a AppDataV2) ConfigVersion() realm.AppConfigVersion

ConfigVersion returns the local Realm app config version

func (AppDataV2) DeploymentModel

func (a AppDataV2) DeploymentModel() realm.DeploymentModel

DeploymentModel returns the local Realm app deployment model

func (AppDataV2) Environment

func (a AppDataV2) Environment() realm.Environment

Environment returns the local Realm app environment

func (AppDataV2) ID

func (a AppDataV2) ID() string

ID returns the local Realm app id

func (*AppDataV2) LoadData

func (a *AppDataV2) LoadData(rootDir string) error

LoadData will load the local Realm app data

func (AppDataV2) Location

func (a AppDataV2) Location() realm.Location

Location returns the local Realm app location

func (AppDataV2) Name

func (a AppDataV2) Name() string

Name returns the local Realm app name

func (AppDataV2) WriteData

func (a AppDataV2) WriteData(rootDir string) error

WriteData will write the local Realm app data to disk

type AppRealmConfigJSON

type AppRealmConfigJSON struct {
	AppDataV2
}

AppRealmConfigJSON is the app realm_config.json data

func NewAppRealmConfigJSON

func NewAppRealmConfigJSON(name string, meta realm.AppMeta) AppRealmConfigJSON

NewAppRealmConfigJSON returns app realm_config.json data

type AppStitchJSON

type AppStitchJSON struct {
	AppDataV1
}

AppStitchJSON is the app stitch.json data

func NewAppStitchJSON

func NewAppStitchJSON(name string, meta realm.AppMeta) AppStitchJSON

NewAppStitchJSON returns app stitch.json data

type AppStructureV1

type AppStructureV1 struct {
	ConfigVersion        realm.AppConfigVersion            `json:"config_version"`
	ID                   string                            `json:"app_id,omitempty"`
	Name                 string                            `json:"name"`
	Location             realm.Location                    `json:"location"`
	DeploymentModel      realm.DeploymentModel             `json:"deployment_model"`
	Environment          realm.Environment                 `json:"environment,omitempty"`
	Environments         map[string]map[string]interface{} `json:"environments,omitempty"`
	Security             map[string]interface{}            `json:"security"`
	Hosting              map[string]interface{}            `json:"hosting,omitempty"`
	CustomUserDataConfig map[string]interface{}            `json:"custom_user_data_config"`
	Sync                 map[string]interface{}            `json:"sync"`
	Secrets              SecretsStructure                  `json:"secrets,omitempty"`
	AuthProviders        []map[string]interface{}          `json:"auth_providers,omitempty"`
	Functions            []map[string]interface{}          `json:"functions,omitempty"`
	Triggers             []map[string]interface{}          `json:"triggers,omitempty"`
	GraphQL              GraphQLStructure                  `json:"graphql,omitempty"`
	Services             []ServiceStructure                `json:"services,omitempty"`
	Values               []map[string]interface{}          `json:"values,omitempty"`
}

AppStructureV1 represents the v1 Realm app structure

type AppStructureV2

type AppStructureV2 struct {
	ConfigVersion         realm.AppConfigVersion            `json:"config_version"`
	ID                    string                            `json:"app_id,omitempty"`
	Name                  string                            `json:"name,omitempty"`
	Location              realm.Location                    `json:"location,omitempty"`
	DeploymentModel       realm.DeploymentModel             `json:"deployment_model,omitempty"`
	Environment           realm.Environment                 `json:"environment,omitempty"`
	Environments          map[string]map[string]interface{} `json:"environments,omitempty"`
	AllowedRequestOrigins []string                          `json:"allowed_request_origins,omitempty"`
	Values                []map[string]interface{}          `json:"values,omitempty"`
	Auth                  AuthStructure                     `json:"auth,omitempty"`
	Functions             FunctionsStructure                `json:"functions,omitempty"`
	Triggers              []map[string]interface{}          `json:"triggers,omitempty"`
	DataSources           []DataSourceStructure             `json:"data_sources,omitempty"`
	HTTPEndpoints         []HTTPEndpointStructure           `json:"http_endpoints,omitempty"`
	Services              []ServiceStructure                `json:"services,omitempty"`
	GraphQL               GraphQLStructure                  `json:"graphql,omitempty"`
	Hosting               map[string]interface{}            `json:"hosting,omitempty"`
	Sync                  SyncStructure                     `json:"sync,omitempty"`
	Secrets               SecretsStructure                  `json:"secrets,omitempty"`
}

AppStructureV2 represents the v2 Realm app structure

type ArchiveReader

type ArchiveReader interface {
	Next() (FileHeader, error)
	Read(b []byte) (int, error)
}

ArchiveReader provides sequential access to the contents of the supported archive formats

type AuthStructure

type AuthStructure struct {
	CustomUserData map[string]interface{} `json:"custom_user_data,omitempty"`
	Providers      map[string]interface{} `json:"providers,omitempty"`
}

AuthStructure represents the v2 Realm app auth structure

type DataSourceStructure

type DataSourceStructure struct {
	Config map[string]interface{}   `json:"config,omitempty"`
	Rules  []map[string]interface{} `json:"rules,omitempty"`
}

DataSourceStructure represents the v2 Realm app data source structure

type Dependencies

type Dependencies struct {
	RootDir     string
	ArchivePath string
}

Dependencies holds the data related to a local Realm app's dependencies

func FindAppDependencies

func FindAppDependencies(path string) (Dependencies, error)

FindAppDependencies finds the Realm app dependencies archive

func (Dependencies) PrepareUpload

func (d Dependencies) PrepareUpload() (string, error)

PrepareUpload prepares a dependencies upload package by creating a .zip file containing the specified archive's transpiled file contents in a tempmorary directory and returns that file path

type File

type File struct {
	Name string
	Ext  string
}

File is a local Realm app file

func (File) String

func (f File) String() string

type FileHeader

type FileHeader struct {
	Path string
	Info os.FileInfo
}

FileHeader holds the path and file information

type FunctionsStructure

type FunctionsStructure struct {
	Configs []map[string]interface{} `json:"config,omitempty"`
	Sources map[string]string        `json:"sources,omitempty"`
}

FunctionsStructure represents the v2 Realm app functions structure

type GraphQLStructure

type GraphQLStructure struct {
	Config          map[string]interface{}   `json:"config,omitempty"`
	CustomResolvers []map[string]interface{} `json:"custom_resolvers,omitempty"`
}

GraphQLStructure represents the Realm app graphql structure

type HTTPEndpointStructure

type HTTPEndpointStructure struct {
	Config           map[string]interface{}   `json:"config,omitempty"`
	IncomingWebhooks []map[string]interface{} `json:"incoming_webhooks,omitempty"`
	Rules            []map[string]interface{} `json:"rules,omitempty"`
}

HTTPEndpointStructure represents the v2 Realm app http endpoint structure

type Hosting

type Hosting struct {
	RootDir string
}

Hosting is the local Realm app hosting

func FindAppHosting

func FindAppHosting(path string) (Hosting, error)

FindAppHosting finds the local Realm app hosting files

func (Hosting) Diffs

func (h Hosting) Diffs(cachePath, appID string, appAssets []realm.HostingAsset) (HostingDiffs, error)

Diffs returns the local Realm app's hosting asset differences with the provided remote Realm app's hosting assets

func (Hosting) UploadHostingAssets

func (h Hosting) UploadHostingAssets(realmClient realm.Client, groupID, appID string, hostingDiffs HostingDiffs, errHandler func(err error)) error

UploadHostingAssets uploads the hosting assets based on the diff of that file

type HostingAssetClient

type HostingAssetClient interface {
	Get(url string) (*http.Response, error)
}

HostingAssetClient is the hosting asset client

type HostingDiffs

type HostingDiffs struct {
	Added    []realm.HostingAsset
	Deleted  []realm.HostingAsset
	Modified []ModifiedHostingAsset
}

HostingDiffs are the hosting asset differences between a local and remote Realm app

func (HostingDiffs) Cap

func (d HostingDiffs) Cap() int

Cap returns the hosting diffs' total capacity

func (HostingDiffs) Size

func (d HostingDiffs) Size() int

Size returns the total number of diffs

func (HostingDiffs) Strings

func (d HostingDiffs) Strings() []string

Strings returns the hosting diffs' formatted output

type ModifiedHostingAsset

type ModifiedHostingAsset struct {
	realm.HostingAsset
	BodyModified  bool
	AttrsModified bool
}

ModifiedHostingAsset is a Realm hosting asset with information about its local file changes

type SecretsStructure

type SecretsStructure struct {
	AuthProviders map[string]map[string]string `json:"auth_providers,omitempty"`
	Services      map[string]map[string]string `json:"services,omitempty"`
}

SecretsStructure represents the Realm app secrets

type ServiceStructure

type ServiceStructure struct {
	Config           map[string]interface{}   `json:"config,omitempty"`
	IncomingWebhooks []map[string]interface{} `json:"incoming_webhooks"`
	Rules            []map[string]interface{} `json:"rules"`
}

ServiceStructure represents the Realm app service structure

type SyncStructure

type SyncStructure struct {
	Config map[string]interface{} `json:"config,omitempty"`
}

SyncStructure represents the v2 Realm app sync structure

type Transpiler

type Transpiler interface {
	Transpile(ctx context.Context, sources ...string) ([]string, error)
}

Transpiler is a transpiler

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL