Classes

@system-inc/base-foundation · 515c140 · 4 symbols

Helper class for instantiating a type lazily via a container.

Members

View source ↗

Similar to a tsyringe FactoryFunction, but wrapped in a class. This allows the Provider annotation to automically create the instance when the token is resolved.

Members

  • createInstance(container: DependencyContainer): T

View source ↗

Base class for typed bindings to string-named external resources (Cloudflare Durable Object namespaces, queues, R2 buckets, KV namespaces, RPC service bindings, etc.).

A binding identifies an external resource by name and carries enough type information for typed inject decorators (@InjectDurableObjectProvider, @InjectWorkerQueue, etc.) to express their resolution contract via TypedParameterDecorator<TResolved>.

Concrete subclasses each carry a unique phantom brand so TypeScript distinguishes them structurally — passing a DurableObjectBinding to @InjectWorkerQueue is a compile error, not a runtime surprise.

Bindings are typically defined as static members of a *Injections class:

export class StripeInjections {
    static readonly WebhookEventQueue =
        new WorkerQueueBinding<StripeWebhookEvent>('Stripe.WebhookEventQueue');
}

Members

  • name: string

  • toString(): string

View source ↗

Typed wrapper for an injection token. Carries the type that the token resolves to so @Inject(...) parameter types can be statically verified to match the registered type.

Use as a static member of an *Injections class:

export class GridInjections {
    static readonly AccessKeySecret =
        new TypedInjectionKey<Secret<string>>(
            'GridInjections.AccessKeySecret',
        );
}

// Provider
@Provider(GridInjections.AccessKeySecret)
static getAccessKeySecret(): Secret<string> { ... }

// Consumer
constructor(
    @Inject(GridInjections.AccessKeySecret)
    private readonly secret: Secret<string>, // ← type checked by lint
) {}

At runtime, instances are valid tsyringe tokens — tsyringe's container uses reference equality for token lookup, so the same TypedInjectionKey instance must be passed at both registration and injection sites.

Members

  • name: string

  • toString(): string

View source ↗