channeltypes

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package channeltypes renders Nimbu channel schemas as TypeScript types that plug into the nimbu-js-sdk typings.

Every channel becomes an object type alias whose members use the SDK helper types (ReferenceTo, Select, NimbuFile, ...). Type aliases are used instead of interfaces on purpose: the SDK constrains attribute maps with ChannelConfig, which has a string index signature, and only type aliases get an implicit index signature. A plain interface would fail `NimbuObject<T>` with TS2344.

Index

Constants

View Source
const (
	// SDKModule is the module the helper types are imported from.
	SDKModule = "nimbu-js-sdk"
	// CloudModule is the opt-in cloud code typings entry that owns NimbuChannels.
	CloudModule = "nimbu-js-sdk/cloud"
)

Variables

This section is empty.

Functions

func Interface

func Interface(detail api.ChannelDetail) string

Interface renders one channel as a standalone snippet: the helper import followed by the exported type. References to other channels fall back to the untyped SDK helpers because their types are not part of the snippet; self references stay typed.

func Module

func Module(channels []api.ChannelDetail, opts ModuleOptions) string

Module renders one TypeScript module for all given channels. It exports a type per channel and augments NimbuChannels in nimbu-js-sdk/cloud so cloud code callbacks resolve entries by channel slug. Channels are ordered by slug so the output is deterministic.

func TypeName

func TypeName(slug string) string

TypeName returns the exported TypeScript type name for a channel slug when it is rendered on its own.

Types

type ModuleOptions

type ModuleOptions struct {
	// Site is echoed in the header comment.
	Site string
	// StrictChannels marks the module as covering every channel of the site,
	// so nimbu-js-sdk/cloud rejects channel slugs that are not in it.
	StrictChannels bool
}

ModuleOptions configures Module.

Jump to

Keyboard shortcuts

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