Skip to main content

@baeta/generator-sdk

Enumerations

GeneratorPluginVersion

Enumeration Members

Enumeration MemberValue

V1

"v1"

Classes

File

Extended by

Constructors

new File()

new File(filename, content, tag, options?): File

Parameters
ParameterType

filename

string

content

string

tag

string

options?

FileOptions

Returns

File

Properties

PropertyModifierTypeDefault value

content

public

string

undefined

filename

public

string

undefined

persisted

public

boolean

false

tag

public

string

undefined

Methods

buildContent()

protected buildContent(): Promise<string>

Returns

Promise<string>

buildHeader()

protected buildHeader(): string

Returns

string

createComment()

protected createComment(comment): string

Parameters
ParameterType

comment

string

Returns

string

unlink(): Promise<void>

Returns

Promise<void>

write()

write(): Promise<void>

Returns

Promise<void>


FileBlock

Extends

Constructors

new FileBlock()

new FileBlock(filename, content, start, end, tag, options?): FileBlock

Parameters
ParameterType

filename

string

content

string

start

string

end

string

tag

string

options?

FileOptions

Returns

FileBlock

Overrides

File.constructor

Properties

PropertyModifierTypeDefault valueInherited from

content

public

string

undefined

File.content

end

public

string

undefined

filename

public

string

undefined

File.filename

persisted

public

boolean

false

File.persisted

start

public

string

undefined

tag

public

string

undefined

File.tag

Methods

addBlockToContent()

protected addBlockToContent(existingContent): string

Parameters
ParameterType

existingContent

string

Returns

string

buildContent()

protected buildContent(): Promise<string>

Returns

Promise<string>

Inherited from

File.buildContent

buildHeader()

protected buildHeader(): string

Returns

string

Inherited from

File.buildHeader

buildPadding()

protected buildPadding(existingContent): "" | "\n" | "\n\n"

Parameters
ParameterType

existingContent

string

Returns

"" | "\n" | "\n\n"

createComment()

protected createComment(comment): string

Parameters
ParameterType

comment

string

Returns

string

Inherited from

File.createComment

getExistingContent()

protected getExistingContent(): Promise<readonly [string, FileHandle] | readonly ["", null]>

Returns

Promise<readonly [string, FileHandle] | readonly ["", null]>

getSlices()

protected getSlices(existingContent): readonly [string, "", false] | readonly [string, string, true]

Parameters
ParameterType

existingContent

string

Returns

readonly [string, "", false] | readonly [string, string, true]

unlink(): Promise<void>

Returns

Promise<void>

Overrides

File.unlink

write()

write(): Promise<void>

Returns

Promise<void>

Overrides

File.write


FileManager

Constructors

new FileManager()

new FileManager(fileOptions?): FileManager

Parameters
ParameterType

fileOptions?

FileOptions

Returns

FileManager

Properties

PropertyModifierTypeDefault value

files

public

File[]

[]

fileOptions?

public

FileOptions

undefined

Methods

add()

add(...file): void

Parameters
ParameterType

...file

File[]

Returns

void

createAndAdd()

createAndAdd(filename, content, tag): File

Parameters
ParameterType

filename

string

content

string

tag

string

Returns

File

get()

get(filename): undefined | File

Parameters
ParameterType

filename

string

Returns

undefined | File

getAll()

getAll(): File[]

Returns

File[]

getByTag()

getByTag(tag): File[]

Parameters
ParameterType

tag

string

Returns

File[]

getPersistedFiles()

getPersistedFiles(): File[]

Returns

File[]

remove()

remove(filename): void

Parameters
ParameterType

filename

string

Returns

void

removeAll()

removeAll(): void

Returns

void

removeByTag()

removeByTag(tag): void

Parameters
ParameterType

tag

string

Returns

void

unlinkAll()

unlinkAll(): Promise<void>

Returns

Promise<void>

writeAll()

writeAll(): Promise<void[]>

Returns

Promise<void[]>

writeByTag()

writeByTag(tag): Promise<void[]>

Parameters
ParameterType

tag

string

Returns

Promise<void[]>


Watcher

Constructors

new Watcher()

new Watcher(cwd, options?): Watcher

Parameters
ParameterType

cwd

string

options?

Options

Returns

Watcher

Methods

close()

close(): Promise<void>

Returns

Promise<void>

createSubscription()

createSubscription(): object

Returns

object

NameType
unsubscribe() => Promise<void>
ignore()

ignore(pattern): void

Parameters
ParameterType

pattern

MatchPattern

Returns

void

off()

off(event, listener): void

Parameters
ParameterType

event

EventType

listener

WatcherListener

Returns

void

on()

on(event, listener): void

Parameters
ParameterType

event

EventType

listener

WatcherListener

Returns

void

onEvents()

onEvents(err, events): void

Parameters
ParameterType

err

null | Error

events

Event[]

Returns

void

unignore()

unignore(pattern): void

Parameters
ParameterType

pattern

MatchPattern

Returns

void


WatcherIgnore

Constructors

new WatcherIgnore()

new WatcherIgnore(cwd): WatcherIgnore

Parameters
ParameterType

cwd

string

Returns

WatcherIgnore

Methods

ignore()

ignore(pattern): void

Parameters
ParameterType

pattern

MatchPattern

Returns

void

isIgnored()

isIgnored(path): boolean

Parameters
ParameterType

path

string

Returns

boolean

isMicromatch()

isMicromatch(pattern): boolean

Parameters
ParameterType

pattern

string

Returns

boolean

resolveFile()

resolveFile(file): string

Parameters
ParameterType

file

string

Returns

string

unignore()

unignore(pattern): void

Parameters
ParameterType

pattern

MatchPattern

Returns

void

Interfaces

FileOptions

Options for generated files.

Properties

PropertyTypeDefault valueDescription

addEslintDisableHeader?

boolean

true;

Add eslint-disable comment at the beginning of the file.

addGenerationNoticeHeader?

boolean

true;

Add generation notice at the beginning of the file.

addHeader?

(name: string, content: string, tag: string) => string

undefined

Add custom header at the beginning of the file.

transformContent?

(name: string, content: string, tag: string) => string | Promise<string>

undefined

Edit the content of the file before writing it.


GeneratorOptions

Options for the Baeta Generator.

Properties

PropertyTypeDefault valueDescription

schemas

string[]

["src/∗∗/∗.gql", "src/∗∗/∗.graphql"];

Glob pattern(s) to locate GraphQL schema files.

baseTypesPath?

string

`${modulesDir}/../__generated__/types.ts`;

Output path for the generated base types file.

contextType?

string

undefined;

Path to the context type definition. Supports both named and default exports.

Examples

contextType: "src/types/context.ts#Context"; // for named export
contextType: "src/types/context.ts"; // for default export

cwd?

string

process.cwd();

Current working directory for resolving relative paths.

extensions?

string

undefined;

Path to Baeta Extensions (ex. auth-extension). Only default export is supported.

Example

extensions: "src/extensions.ts";

fileOptions?

FileOptions

undefined

Configuration options for generated files.

importExtension?

false | ".js" | ".ts"

".ts";

File extension to use in generated import statements. Set to false to omit extensions.

loaders?

Loader<any>[]

undefined

Custom schema loaders for processing schema files.

moduleDefinitionName?

string

"typedef.ts";

Filename for the generated module definition file. Contains type definitions and the GraphQL AST.

modulesDir?

string

"src/modules";

Root directory where GraphQL modules are defined.

scalars?

Record<string, string>

undefined;

Custom scalar type mappings. Maps GraphQL scalar types to TypeScript types. Supports global types and imports.

Example

{ DateTime: 'Date', JSON: 'Record<string, unknown>' }	 *

GeneratorPluginV1<Store>

Type Parameters

Type ParameterDefault type

Store

unknown

Properties

PropertyType

actionName

string

end

GeneratorPluginV1Fn<Store>

generate

GeneratorPluginV1Fn<Store>

name

string

setup

GeneratorPluginV1Fn<Store>

type

Generator

version

V1

watch

GeneratorPluginV1WatchOptions


Loader<TOptions>

Interface for custom schema loaders.

Type Parameters

Type ParameterDefault type

TOptions

any

Methods

load()

load(pointer, options?): Promise<null | any[]>

Parameters
ParameterType

pointer

string

options?

TOptions

Returns

Promise<null | any[]>

loadSync()?

optional loadSync(pointer, options?): null | any[]

Parameters
ParameterType

pointer

string

options?

TOptions

Returns

null | any[]


NormalizedGeneratorOptions

Properties

PropertyType

baseTypesPath

string

cwd

string

moduleDefinitionName

string

modulesDir

string

schemas

string[]

contextType?

string

extensions?

string

fileOptions?

FileOptions

importExtension?

".js" | ".ts"

loaders?

Loader<any>[]

scalars?

Record<string, string>


WatcherFile

Properties

PropertyType

path

string

relativePath

string

type

EventType

Type Aliases

Ctx<T>

Ctx<T>: object & T

Type declaration

NameType

didEnd

string[]

didGenerate

string[]

didSetup

string[]

fileManager

FileManager

generatorOptions

NormalizedGeneratorOptions

pluginNames

string[]

watching

boolean

changedFile?

WatcherFile

Type Parameters

Type ParameterDefault type

T

unknown


GeneratorPluginV1Factory<Store>

GeneratorPluginV1Factory<Store>: object

Type Parameters

Type ParameterDefault type

Store

unknown

Type declaration

NameType

actionName

string

name

string

end?

GeneratorPluginV1Fn<Store>

generate?

GeneratorPluginV1Fn<Store>

setup?

GeneratorPluginV1Fn<Store>

watch?

GeneratorPluginV1WatchOptions


GeneratorPluginV1Fn()<Store>

GeneratorPluginV1Fn<Store>: (ctx, next) => Promise<void>

Type Parameters

Type ParameterDefault type

Store

unknown

Parameters

ParameterType

ctx

Ctx<Store>

next

() => Promise<void>

Returns

Promise<void>


GeneratorPluginV1ReloadFn()

GeneratorPluginV1ReloadFn: (file) => void

Parameters

ParameterType

file

WatcherFile

Returns

void


GeneratorPluginV1WatchOptions()

GeneratorPluginV1WatchOptions: (options, watcher, reload) => void

Parameters

ParameterType

options

NormalizedGeneratorOptions

watcher

Watcher

reload

GeneratorPluginV1ReloadFn

Returns

void


MatchFn()

MatchFn: (testString) => boolean

Parameters

ParameterType

testString

string

Returns

boolean


MatchPattern

MatchPattern: string | RegExp | MatchFn


WatcherListener()

WatcherListener: (path) => void

Parameters

ParameterType

path

WatcherFile

Returns

void

Functions

createPluginV1()

createPluginV1<Store>(options): GeneratorPluginV1<Store>

Type Parameters

Type ParameterDefault type

Store

unknown

Parameters

ParameterType

options

GeneratorPluginV1Factory<Store>

Returns

GeneratorPluginV1<Store>


getGeneratorPlugins()

getGeneratorPlugins(plugins?): GeneratorPluginV1<unknown>[]

Parameters

ParameterType

plugins?

object[]

Returns

GeneratorPluginV1<unknown>[]


getModuleCreateName()

getModuleCreateName(name): string

Parameters

ParameterType

name

string

Returns

string


getModuleGetName()

getModuleGetName(name): string

Parameters

ParameterType

name

string

Returns

string


getModuleVariableName()

getModuleVariableName(name): string

Parameters

ParameterType

name

string

Returns

string


isGeneratorPlugin()

isGeneratorPlugin(plugin): plugin is GeneratorPluginV1<unknown>

Parameters

ParameterType

plugin

{ type: PluginType; }

plugin.type

PluginType

Returns

plugin is GeneratorPluginV1<unknown>


isMatch()

isMatch(string, pattern, options?): boolean

Returns true if the specified string matches the given glob pattern.

Parameters

ParameterTypeDescription

string

string

String to match

pattern

string | readonly string[]

Glob pattern to use for matching.

options?

Options

See available options for changing how matches are performed

Returns

boolean

Returns true if the string matches the glob pattern.

Example

var mm = require('micromatch');
mm.isMatch(string, pattern[, options]);

console.log(mm.isMatch('a.a', '*.a'));
//=> true
console.log(mm.isMatch('a.b', '*.a'));
//=> false

loadOptions()

loadOptions(options): NormalizedGeneratorOptions

Parameters

ParameterType

options

GeneratorOptions

Returns

NormalizedGeneratorOptions


micromatch()

micromatch(list, patterns, options?): string[]

The main function takes a list of strings and one or more glob patterns to use for matching.

Parameters

ParameterTypeDescription

list

readonly string[]

A list of strings to match

patterns

string | readonly string[]

One or more glob patterns to use for matching.

options?

Options

See available options for changing how matches are performed

Returns

string[]

Returns an array of matches

Example

var mm = require('micromatch');
mm(list, patterns[, options]);

console.log(mm(['a.js', 'a.txt'], ['*.js']));
//=> [ 'a.js' ]

Namespaces