@samveys/core
Container, inject(), provider, plugin, hook, siklus hidup, config, env, logger, error, hashing dan enkripsi
Daftar ini dibaca dari versi 1.0.2; jalankan pnpm sync untuk memperbaruinya.
import { config, createApp, createConfigRepository, createContainer, createEncrypter, createExtensionRegistry, … } from '@samveys/core'
Fungsi (34)
config
Fungsi
Typed read of the current application's config. A wrong path is a compile error.
function config<P extends ConfigPath>(path: P): PathValue<Config, P>;
Diekspor dari packages/core/src/config.ts
createApp
Fungsi
Creates an application. Nothing runs until `register()` (or `run()`) is called. Lifecycle: register → boot → start → ready → shutdown, each allowed once, in order (SVS_E026).
function createApp(options?: CreateAppOptions): Application;
Diekspor dari packages/core/src/application.ts
createConfigRepository
Fungsi
Creates a read-only repository over a deep-merged, deeply frozen copy of `tree`.
function createConfigRepository(tree: Readonly<Record<string, unknown>>): ConfigRepository;
Diekspor dari packages/core/src/config.ts
createContainer
Fungsi
Creates an empty dependency-injection container.
function createContainer(): Container;
Diekspor dari packages/core/src/container.ts
createEncrypter
Fungsi
AES-256-GCM encrypter. Keys are `base64:<32 bytes>`; decrypt tries `key`, then each of `previousKeys`.
function createEncrypter(options: {
Diekspor dari packages/core/src/crypto.ts
createExtensionRegistry
Fungsi
Creates the registry behind `extend.*`. `bind(owner)` returns a `Proxy` rather than an object with one method per point. Extension points are open: packages add their own through `declare module '@samveys/core'`, so core cannot list them at runtime, and any `extend.<point>(...)` call must be accepted.
function createExtensionRegistry(): ExtensionRegistry;
Diekspor dari packages/core/src/extensions.ts
createHasher
Fungsi
Argon2id password hasher producing PHC strings; defaults follow the OWASP minimum.
function createHasher(options?: Partial<HashOptions>): Hasher;
Diekspor dari packages/core/src/crypto.ts
createHookRegistry
Fungsi
Creates a hook registry. Listeners run sequentially, in registration order, and are awaited.
function createHookRegistry(): HookRegistry;
Diekspor dari packages/core/src/hooks.ts
createLogger
Fungsi
Creates a JSON-lines logger: one object per line with `level`, `time`, `msg`, bindings and fields.
function createLogger(options?: LoggerOptions): Logger;
Diekspor dari packages/core/src/logger.ts
createRequestContext
Fungsi
Creates a request context (and marks it request-bound for the captured-request warning).
function createRequestContext(init?: {
Diekspor dari packages/core/src/context.ts
currentContext
Fungsi
The context of the request being handled, or `undefined` outside a request.
function currentContext(): RequestContext | undefined;
Diekspor dari packages/core/src/context.ts
defineConfig
Fungsi
Identity helper that types `samveys.config.ts`.
function defineConfig(config: SamveysConfig): SamveysConfig;
Diekspor dari packages/core/src/config.ts
defineEnv
Fungsi
Declares the env variables an app needs; pass the result to `loadEnv()` or `createApp({ env })`.
function defineEnv<const S extends EnvShape>(shape: S): EnvDefinition<S>;
Diekspor dari packages/core/src/env.ts
definePlugin
Fungsi
Declares a plugin. Nothing is validated here: the config schema runs when the app registers the plugin, and a factory that is never listed in `samveys.config.ts` does nothing.
function definePlugin<Input = undefined, C = Input>(definition: PluginDefinition<Input, C>): PluginFactory<Input, C>;
Diekspor dari packages/core/src/plugins.ts
defineProvider
Fungsi
Declares a provider: an app-level plugin that receives the `AppContext`.
function defineProvider(definition: ProviderDefinition): Provider;
Diekspor dari packages/core/src/plugins.ts
deprecate
Fungsi
Emits the deprecation warning the first time it is called in this process; later calls do nothing. Returns true when a warning was emitted.
function deprecate(info: DeprecationInfo): boolean;
Diekspor dari packages/core/src/deprecation.ts
deprecated
Fungsi
Wraps a function so its first call warns. `fn.name` and arity are kept for stack traces and introspection.
function deprecated<A extends unknown[], R>(info: DeprecationInfo, fn: (...args: A) => R): (...args: A) => R;
Diekspor dari packages/core/src/deprecation.ts
env
Fungsi
Typed read of a validated env value from the environment loaded by the current application.
function env<K extends keyof EnvValues & string>(key: K): EnvValues[K];
Diekspor dari packages/core/src/env.ts
explain
Fungsi
The `ERROR_CODES` entry for `svs explain <code>`, or `undefined` for an unknown code.
function explain(code: string): ErrorCodeInfo | undefined;
Diekspor dari packages/core/src/errors.ts
inject
Fungsi
Resolves a service. Works in class field initializers while the container constructs a service, and anywhere inside `container.run()` (also across `await`).
function inject<K extends BindingKey>(key: K): ContainerBindings[K];
Diekspor dari packages/core/src/container.ts
isSamveysError
Fungsi
True for errors created by the framework.
function isSamveysError(value: unknown): value is SamveysError;
Diekspor dari packages/core/src/errors.ts
loadConfigDir
Fungsi
Imports every `config/*.ts` file of `rootDir` (sorted); each default export lands under the file's base name.
function loadConfigDir(rootDir: string): Promise<Tree>;
Diekspor dari packages/core/src/config.ts
loadEnv
Fungsi
Reads `.env`, then `.env.[APP_ENV]` (later wins), lets the process environment win over both, and validates every key of the definition. All failures are reported in one SVS_E010.
function loadEnv<S extends EnvShape>(definition: EnvDefinition<S>, options: LoadEnvOptions): Readonly<InferEnv<S>>;
Diekspor dari packages/core/src/env.ts
markRequestBound
Fungsi
Marks an object as living only for one request, so storing it on a singleton can be flagged.
function markRequestBound<T extends object>(value: T): T;
Diekspor dari packages/core/src/context.ts
mergeConfig
Fungsi
Deep-merges config trees (later wins; arrays are replaced). Keys named `__proto__`, `constructor` or `prototype` are rejected with SVS_E011. The result is prototype-less.
function mergeConfig(...sources: readonly Readonly<Record<string, unknown>>[]): Tree;
Diekspor dari packages/core/src/config.ts
pluginError
Fungsi
Wraps a failure of a plugin or provider stage as `SVS_E025`: `[name] <stage> failed: <cause>`.
function pluginError(name: string, stage: string, cause: unknown): SamveysError;
Diekspor dari packages/core/src/errors.ts
redact
Fungsi
Returns a copy of `value` that is safe to log or print: sensitive keys (see the list above) and the dotted paths in `extraPaths` become `[REDACTED]`, URL passwords are masked, errors are serialized and cycles are cut. Pure: the input is never modified.
function redact(value: unknown, extraPaths?: readonly string[]): unknown;
Diekspor dari packages/core/src/logger.ts
requireContext
Fungsi
Like `currentContext()` but throws SVS_E005 when no request is active.
function requireContext(): RequestContext;
Diekspor dari packages/core/src/context.ts
resolvePluginOrder
Fungsi
Filters plugins by `env`, checks names, `requires.samveys` and `requires.plugins`, and returns them in load order: dependencies first, otherwise registration order. Every error starts with `[plugin-name] `.
function resolvePluginOrder(entries: readonly PluginEntry[], options: {
Diekspor dari packages/core/src/plugins.ts
runWithContext
Fungsi
Runs `fn` with `ctx` as the current request context; it survives `await`, timers and queued work.
function runWithContext<R>(ctx: RequestContext, fn: () => R): R;
Diekspor dari packages/core/src/context.ts
satisfiesRange
Fungsi
True when `version` is inside `range`. Supports `^x.y(.z)`, `~x.y(.z)`, `>=x.y.z`, `x.y.z`, `x.x`, `*`, and space-separated AND. Returns `undefined` when the range cannot be parsed.
function satisfiesRange(version: string, range: string): boolean | undefined;
Diekspor dari packages/core/src/plugins.ts
toProblemDetails
Fungsi
Problem Details for any thrown value. Unknown errors become a 500 `SVS_E049`; their message is included only when `debug` is true.
function toProblemDetails(error: unknown, options?: {
Diekspor dari packages/core/src/errors.ts
traceAsync
Fungsi
Runs `fn` inside a tracing span: subscribers receive `start`, `end`, `asyncStart`, `asyncEnd` and `error` (on rejection). With no subscriber, `fn` runs untouched.
function traceAsync<T>(channelName: TracingChannelName, context: object, fn: () => Promise<T>): Promise<T>;
Diekspor dari packages/core/src/tracing.ts
warnIfCaptured
Fungsi
logs one warning (outside production) when `value`, or one of its own fields, is a request-bound object held by the singleton `owner`. Returns true when it warned.
function warnIfCaptured(owner: string, value: unknown, logger: Logger, options?: {
Diekspor dari packages/core/src/context.ts
Nilai (11)
ConfigToken
Nilai
Tidak ada komentar dokumentasi.
const ConfigToken: InjectionToken<ConfigRepository>;
Diekspor dari packages/core/src/application.ts
EncrypterToken
Nilai
Tidak ada komentar dokumentasi.
const EncrypterToken: InjectionToken<Encrypter>;
Diekspor dari packages/core/src/application.ts
Env
Nilai
Rule builders for `defineEnv()`. A rule with `optional: true` types as `T | undefined`.
const Env: {
string: typeof stringRule;
number: typeof numberRule;
boolean: typeof booleanRule;
url: typeof urlRule;
/** A string that never appears in error messages or `svs env:check` output. */
secret: typeof secretRule;
enum: typeof enumRule;
};
Diekspor dari packages/core/src/env.ts
ERROR_CODES
Nilai
Tidak ada komentar dokumentasi.
const ERROR_CODES: {
readonly SVS_E001: {
readonly title: 'Dependency cycle';
readonly status: 500;
readonly description: 'The container found a dependency cycle while resolving a service. The message shows the full path, e.g. A → B → C → A.';
readonly fix: 'Break the cycle: move the shared logic into a third service, or resolve one side lazily inside a method instead of a field. There is no forwardRef().';
};
readonly SVS_E002: {
readonly title: 'Captive dependency';
readonly status: 500;
…
Tampilkan seluruh deklarasi (60 baris)
const ERROR_CODES: {
readonly SVS_E001: {
readonly title: 'Dependency cycle';
readonly status: 500;
readonly description: 'The container found a dependency cycle while resolving a service. The message shows the full path, e.g. A → B → C → A.';
readonly fix: 'Break the cycle: move the shared logic into a third service, or resolve one side lazily inside a method instead of a field. There is no forwardRef().';
};
readonly SVS_E002: {
readonly title: 'Captive dependency';
readonly status: 500;
…const ERROR_CODES: {
readonly SVS_E001: {
readonly title: 'Dependency cycle';
readonly status: 500;
readonly description: 'The container found a dependency cycle while resolving a service. The message shows the full path, e.g. A → B → C → A.';
readonly fix: 'Break the cycle: move the shared logic into a third service, or resolve one side lazily inside a method instead of a field. There is no forwardRef().';
};
readonly SVS_E002: {
readonly title: 'Captive dependency';
readonly status: 500;
readonly description: 'A singleton holds a transient service that has dispose() or [Symbol.asyncDispose]; the transient would live as long as the singleton and never be disposed on time.';
readonly fix: 'Make the dependency a singleton, or create it inside the method that uses it and dispose it there.';
};
readonly SVS_E003: {
readonly title: 'Unresolvable service';
readonly status: 500;
readonly description: 'The container has no binding for the requested token and cannot construct it (abstract class, InjectionToken, binding key, or a constructor that needs arguments).';
readonly fix: 'Register a binding with container.singleton(), container.transient() or container.instance() in a provider or plugin register().';
};
readonly SVS_E004: {
readonly title: 'Resolve during register';
readonly status: 500;
readonly description: 'A service was resolved while providers and plugins were still registering, before every binding existed.';
readonly fix: 'Only bind services in register(); resolve them in boot() or later.';
};
readonly SVS_E005: {
readonly title: 'inject() outside a container context';
readonly status: 500;
readonly description: 'inject() was called outside a class field initializer resolved by the container and outside a request or container.run() scope.';
readonly fix: 'Call inject() in a field of a class resolved by the container, in a route handler, or wrap the call in container.run().';
};
readonly SVS_E010: {
readonly title: 'Invalid environment';
readonly status: 500;
readonly description: 'One or more environment variables are missing or malformed. Every failing variable is listed.';
readonly fix: 'Fix the listed variables in .env, .env.[APP_ENV] or the process environment; see start/env.ts for the rules.';
};
readonly SVS_E011: {
readonly title: 'Invalid config';
readonly status: 500;
readonly description: 'A config file exports a forbidden key (__proto__, constructor, prototype) or a value that cannot be merged.';
readonly fix: 'Rename the key; config objects must be plain data.';
};
readonly SVS_E020: {
readonly title: 'Missing required plugin';
readonly status: 500;
readonly description: 'A plugin lists another plugin in requires.plugins that is not registered in samveys.config.ts for this environment.';
readonly fix: 'Install the missing plugin with `svs add <name>` or register it in samveys.config.ts.';
};
readonly SVS_E021: {
readonly title: 'Plugin dependency cycle';
readonly status: 500;
readonly description: 'Plugins require each other in a cycle, so no load order exists.';
readonly fix: 'Remove one of the requires.plugins entries in the cycle shown in the message.';
};
readonly SVS_E022: {
readonly title: 'Incompatible Samveys version';
readonly status: 500;
// … 405 more lines
}
Diekspor dari packages/core/src/contracts.ts
EventsToken
Nilai
Tidak ada komentar dokumentasi.
const EventsToken: InjectionToken<Emitter>;
Diekspor dari packages/core/src/application.ts
HasherToken
Nilai
Tidak ada komentar dokumentasi.
const HasherToken: InjectionToken<Hasher>;
Diekspor dari packages/core/src/application.ts
HooksToken
Nilai
Tidak ada komentar dokumentasi.
const HooksToken: InjectionToken<HookRegistry>;
Diekspor dari packages/core/src/application.ts
LoggerToken
Nilai
Container tokens for the services bound by core.
const LoggerToken: InjectionToken<Logger>;
Diekspor dari packages/core/src/application.ts
SAMVEYS_API_VERSION
Nilai
Version of the plugin API checked against `requires.samveys` (covered by the compatibility promise).
const SAMVEYS_API_VERSION = "1.0.0";
Diekspor dari packages/core/src/contracts.ts
TRACING_CHANNELS
Nilai
Names of the `node:diagnostics_channel` TracingChannels published by Samveys.
const TRACING_CHANNELS: {
readonly httpRequest: 'samveys:http.request';
readonly dbQuery: 'samveys:db.query';
readonly viewRender: 'samveys:view.render';
readonly jobProcess: 'samveys:job.process';
readonly commandRun: 'samveys:command.run';
};
Diekspor dari packages/core/src/contracts.ts
tracingChannels
Nilai
The `TracingChannel`s published by Samveys. APM tools can subscribe through `node:diagnostics_channel` alone, without importing Samveys.
const tracingChannels: {
readonly [K in keyof typeof TRACING_CHANNELS]: TracingChannel;
};
Diekspor dari packages/core/src/tracing.ts
Class (3)
EventEmitter
Class
Typed in-process event emitter. Listeners run sequentially and are awaited.
class EventEmitter implements Emitter {
#private;
on<K extends EventName>(event: K, listener: EventListener<K>): Unsubscribe;
once<K extends EventName>(event: K, listener: EventListener<K>): Unsubscribe;
off<K extends EventName>(event: K, listener: EventListener<K>): void;
/** Calls every listener in order; rejects with the first error only after all of them ran. */
emit<K extends EventName>(event: K, payload: Events[K]): Promise<void>;
listenerCount(event: EventName): number;
clear(event?: EventName): void;
}
Diekspor dari packages/core/src/events.ts
InjectionToken
Class
A token for interfaces and values that have no class.
class InjectionToken<T> implements InjectionTokenLike<T> {
readonly description: string;
/** Phantom; never set at runtime. */
readonly __type?: T;
constructor(description: string);
toString(): string;
}
Diekspor dari packages/core/src/container.ts
SamveysError
Class
Every error thrown by the framework. Carries a stable `SVS_E*` code from `ERROR_CODES`.
class SamveysError extends Error {
readonly code: ErrorCode;
readonly status: number;
readonly issues: readonly ValidationIssue[];
readonly meta: Readonly<Record<string, unknown>>;
readonly expose: boolean;
constructor(code: ErrorCode, message: string, options?: SamveysErrorOptions);
/** RFC 9457 Problem Details. `detail` is included only when it is safe to show a client. */
toProblem(requestId?: string): ProblemDetails;
}
Diekspor dari packages/core/src/errors.ts
Interface (65)
AppContext
Interface
What providers receive, and what `svs` commands see.
interface AppContext extends AppInfo {
readonly container: Container;
readonly hooks: HookRegistry;
readonly config: ConfigRepository;
readonly logger: Logger;
readonly events: Emitter;
readonly extensions: ExtensionRegistry;
readonly state: AppState;
readonly plugins: readonly LoadedPluginInfo[];
}
Diekspor dari packages/core/src/contracts.ts
AppInfo
Interface
Tidak ada komentar dokumentasi.
interface AppInfo {
readonly name: string;
readonly env: AppEnvironment;
readonly debug: boolean;
readonly rootDir: string;
readonly apiVersion: string;
}
Diekspor dari packages/core/src/contracts.ts
Application
Interface
Tidak ada komentar dokumentasi.
interface Application extends AppContext {
/** created → registered. Validates plugins (SVS_E020..24), env and runs every register(). */
register(): Promise<void>;
/** registered → booted. Emits app:booting, runs boot(), validates the container graph, emits app:booted. */
boot(): Promise<void>;
/** booted → started. */
start(): Promise<void>;
/** started → ready. Emits app:ready. */
ready(): Promise<void>;
/** register → boot → start → ready, skipping stages already done. */
…
Tampilkan seluruh deklarasi (19 baris)
interface Application extends AppContext {
/** created → registered. Validates plugins (SVS_E020..24), env and runs every register(). */
register(): Promise<void>;
/** registered → booted. Emits app:booting, runs boot(), validates the container graph, emits app:booted. */
boot(): Promise<void>;
/** booted → started. */
start(): Promise<void>;
/** started → ready. Emits app:ready. */
ready(): Promise<void>;
/** register → boot → start → ready, skipping stages already done. */
…interface Application extends AppContext {
/** created → registered. Validates plugins (SVS_E020..24), env and runs every register(). */
register(): Promise<void>;
/** registered → booted. Emits app:booting, runs boot(), validates the container graph, emits app:booted. */
boot(): Promise<void>;
/** booted → started. */
start(): Promise<void>;
/** started → ready. Emits app:ready. */
ready(): Promise<void>;
/** register → boot → start → ready, skipping stages already done. */
run(): Promise<void>;
/** Emits app:terminating, runs shutdown() in reverse order with the timeout, disposes the container. */
shutdown(reason?: string): Promise<ShutdownResult>;
/** Install SIGTERM/SIGINT handlers that call shutdown() and then exit with its code. */
handleSignals(options?: {
readonly signals?: readonly NodeJS.Signals[];
readonly exit?: boolean;
}): Unsubscribe;
}
Diekspor dari packages/core/src/contracts.ts
BindingInfo
Interface
Tidak ada komentar dokumentasi.
interface BindingInfo {
readonly token: string;
readonly lifetime: Lifetime;
/** Plugin or provider that registered it; `undefined` for implicit singletons and core bindings. */
readonly owner: string | undefined;
readonly swapped: boolean;
}
Diekspor dari packages/core/src/contracts.ts
BooleanOptions
Interface
Tidak ada komentar dokumentasi.
interface BooleanOptions {
readonly default?: boolean;
}
Diekspor dari packages/core/src/env.ts
CheckContext
Interface
Tidak ada komentar dokumentasi.
interface CheckContext {
readonly app: AppContext;
/** `svs check --deploy`. */
readonly deploy: boolean;
}
Diekspor dari packages/core/src/contracts.ts
CommandInvocation
Interface
What a command emits to `command:before` / `command:after`.
interface CommandInvocation {
readonly name: string;
readonly argv: readonly string[];
}
Diekspor dari packages/core/src/contracts.ts
CommandLike
Interface
Minimal command shape known to core; `@samveys/console` commands satisfy it.
interface CommandLike {
readonly name: string;
readonly description: string;
}
Diekspor dari packages/core/src/contracts.ts
Config
Interface
The app config tree; augment to type `config('path')`.
interface Config {
}
Diekspor dari packages/core/src/contracts.ts
ConfigRepository
Interface
Tidak ada komentar dokumentasi.
interface ConfigRepository {
/** Typed read. A wrong path is a compile error. */
get<P extends ConfigPath>(path: P): PathValue<Config, P>;
/** Untyped read for code that cannot see the app's `Config` augmentation (plugins). */
raw(path: string): unknown;
has(path: string): boolean;
/** Deeply frozen, prototype-less copy of the whole tree. */
all(): Readonly<Record<string, unknown>>;
}
Diekspor dari packages/core/src/contracts.ts
Container
Interface
Tidak ada komentar dokumentasi.
interface Container {
/** Bind a shared instance, created on first resolve. Without a factory, `new Token()` is used. */
singleton<K extends BindingKey>(key: K, factory: Factory<ContainerBindings[K]>): this;
singleton<T>(token: Token<T>, factory?: Factory<T>): this;
/** Bind a service created on every resolve. */
transient<K extends BindingKey>(key: K, factory: Factory<ContainerBindings[K]>): this;
transient<T>(token: Token<T>, factory?: Factory<T>): this;
/** Bind an existing value. Never disposed by the container. */
instance<K extends BindingKey>(key: K, value: ContainerBindings[K]): this;
instance<T>(token: Token<T>, value: T): this;
…
Tampilkan seluruh deklarasi (20 baris)
interface Container {
/** Bind a shared instance, created on first resolve. Without a factory, `new Token()` is used. */
singleton<K extends BindingKey>(key: K, factory: Factory<ContainerBindings[K]>): this;
singleton<T>(token: Token<T>, factory?: Factory<T>): this;
/** Bind a service created on every resolve. */
transient<K extends BindingKey>(key: K, factory: Factory<ContainerBindings[K]>): this;
transient<T>(token: Token<T>, factory?: Factory<T>): this;
/** Bind an existing value. Never disposed by the container. */
instance<K extends BindingKey>(key: K, value: ContainerBindings[K]): this;
instance<T>(token: Token<T>, value: T): this;
…interface Container {
/** Bind a shared instance, created on first resolve. Without a factory, `new Token()` is used. */
singleton<K extends BindingKey>(key: K, factory: Factory<ContainerBindings[K]>): this;
singleton<T>(token: Token<T>, factory?: Factory<T>): this;
/** Bind a service created on every resolve. */
transient<K extends BindingKey>(key: K, factory: Factory<ContainerBindings[K]>): this;
transient<T>(token: Token<T>, factory?: Factory<T>): this;
/** Bind an existing value. Never disposed by the container. */
instance<K extends BindingKey>(key: K, value: ContainerBindings[K]): this;
instance<T>(token: Token<T>, value: T): this;
/** Replace a binding (tests). Drops a cached instance; keeps the original lifetime. */
swap<K extends BindingKey>(key: K, factory: Factory<ContainerBindings[K]>): this;
swap<T>(token: Token<T>, factory: Factory<T>): this;
/** Undo `swap()` for one token, or for all when called without arguments. */
restore(token?: AnyToken): this;
make<K extends BindingKey>(key: K): ContainerBindings[K];
make<T>(token: Token<T>): T;
has(token: AnyToken): boolean;
/** Run `fn` with this container as the `inject()` context (also across `await`). */
run<R>(fn: () => R): R;
Diekspor dari packages/core/src/contracts.ts
ContainerBindings
Interface
String-keyed bindings; augment to type `container.make('key')` and `inject('key')`.
interface ContainerBindings {
}
Diekspor dari packages/core/src/contracts.ts
CreateAppOptions
Interface
Tidak ada komentar dokumentasi.
interface CreateAppOptions extends SamveysConfig {
readonly rootDir?: string;
/** Defaults to env APP_ENV, then `NODE_ENV === 'production' ? 'production' : 'local'`. */
readonly environment?: AppEnvironment;
/** Defaults to env APP_DEBUG, then `environment !== 'production'`. */
readonly debug?: boolean;
readonly processEnv?: Readonly<Record<string, string | undefined>>;
/** A ready logger replaces `logger` options (tests). */
readonly loggerInstance?: Logger;
/** Load `config/*.ts` from rootDir. Default true when rootDir is given. */
readonly loadConfigDir?: boolean;
}
Diekspor dari packages/core/src/contracts.ts
DeprecationInfo
Interface
A registered deprecation: what replaces the API and when it goes away.
interface DeprecationInfo {
/** `SVS_DEP001`, `SVS_DEP002`, … Never reused. */
readonly code: `SVS_DEP${number}`;
/** What is deprecated and what to use instead. */
readonly message: string;
/** The major version that removes it, e.g. `2.0.0`. */
readonly removedIn: string;
}
Diekspor dari packages/core/src/deprecation.ts
Emitter
Interface
Tidak ada komentar dokumentasi.
interface Emitter {
on<K extends EventName>(event: K, listener: EventListener<K>): Unsubscribe;
once<K extends EventName>(event: K, listener: EventListener<K>): Unsubscribe;
off<K extends EventName>(event: K, listener: EventListener<K>): void;
/** Calls listeners sequentially and awaits each; rejects with the first error after all ran. */
emit<K extends EventName>(event: K, payload: Events[K]): Promise<void>;
listenerCount(event: EventName): number;
clear(event?: EventName): void;
}
Diekspor dari packages/core/src/contracts.ts
Encrypter
Interface
Tidak ada komentar dokumentasi.
interface Encrypter {
/** AES-256-GCM with APP_KEY; `purpose` is bound as additional authenticated data. */
encrypt(value: string | Uint8Array, purpose?: string): string;
/** Tries APP_KEY, then each APP_PREVIOUS_KEYS entry; throws SVS_E030. */
decrypt(payload: string, purpose?: string): string;
decryptBytes(payload: string, purpose?: string): Uint8Array;
}
Diekspor dari packages/core/src/contracts.ts
EnvDefinition
Interface
Tidak ada komentar dokumentasi.
interface EnvDefinition<S extends EnvShape = EnvShape> {
readonly shape: S;
}
Diekspor dari packages/core/src/contracts.ts
EnvIssue
Interface
Tidak ada komentar dokumentasi.
interface EnvIssue {
readonly key: string;
readonly message: string;
}
Diekspor dari packages/core/src/contracts.ts
EnvRule
Interface
Tidak ada komentar dokumentasi.
interface EnvRule<T> {
readonly kind: string;
/** Secret values are never printed by `svs env:check` or error messages. */
readonly secret: boolean;
parse(raw: string | undefined, key: string): EnvParseResult<T>;
}
Diekspor dari packages/core/src/contracts.ts
EnvValues
Interface
Validated env values; augment with `InferEnv<typeof envDefinition>` to type `env('KEY')`.
interface EnvValues {
}
Diekspor dari packages/core/src/contracts.ts
ErrorCodeInfo
Interface
Tidak ada komentar dokumentasi.
interface ErrorCodeInfo {
/** Stable, short summary; used as the Problem Details `title`. */
readonly title: string;
/** HTTP status used when the error reaches an HTTP response. */
readonly status: number;
/** What happened. */
readonly description: string;
/** How to fix it. */
readonly fix: string;
}
Diekspor dari packages/core/src/contracts.ts
Events
Interface
Event name → payload. Augment to add app events; an unknown name is a `tsc` error.
interface Events {
}
Diekspor dari packages/core/src/contracts.ts
ExtensionEntry
Interface
Tidak ada komentar dokumentasi.
interface ExtensionEntry<K extends ExtensionPoint> {
readonly owner: string;
readonly args: ExtensionArgs<K>;
}
Diekspor dari packages/core/src/contracts.ts
ExtensionPoints
Interface
Extension point name → registration arguments. Core declares the points it owns; `@samveys/http` adds `middleware`, `router`, `validator`, `httpDriver`, and later packages add `dbDriver`, `cacheStore`, `queueDriver`, `mailTransport`, `storageDisk`, `template`.
interface ExtensionPoints {
/** `extend.context('audit', ctx => audit)` → `ctx.audit`. Evaluated once per request, lazily. */
Diekspor dari packages/core/src/contracts.ts
ExtensionRegistry
Interface
Tidak ada komentar dokumentasi.
interface ExtensionRegistry {
add<K extends ExtensionPoint>(point: K, owner: string, ...args: ExtensionArgs<K>): void;
get<K extends ExtensionPoint>(point: K): readonly ExtensionEntry<K>[];
/** `extend.*` bound to one owner. */
bind(owner: string): Extend;
}
Diekspor dari packages/core/src/contracts.ts
GeneratorLike
Interface
Tidak ada komentar dokumentasi.
interface GeneratorLike {
readonly name: string;
readonly description: string;
}
Diekspor dari packages/core/src/contracts.ts
Hasher
Interface
Tidak ada komentar dokumentasi.
interface Hasher {
/** Argon2id via `crypto.argon2`, returned as a PHC string. */
make(password: string): Promise<string>;
/** Constant-time comparison. */
verify(hash: string, password: string): Promise<boolean>;
needsRehash(hash: string): boolean;
/** `verify`, then rehash when parameters changed (used on login). */
verifyAndRehash(hash: string, password: string): Promise<VerifyResult>;
}
Diekspor dari packages/core/src/contracts.ts
HashOptions
Interface
Tidak ada komentar dokumentasi.
interface HashOptions {
/** KiB. Default 19456 (OWASP Argon2id minimum). */
readonly memory: number;
/** Default 2. */
readonly passes: number;
/** Default 1. */
readonly parallelism: number;
/** Bytes. Default 32. */
readonly tagLength: number;
}
Diekspor dari packages/core/src/contracts.ts
HealthCheck
Interface
Tidak ada komentar dokumentasi.
interface HealthCheck {
readonly name: string;
run(signal: AbortSignal): Promise<{
readonly status: HealthStatus;
readonly detail?: string;
}>;
}
Diekspor dari packages/core/src/contracts.ts
HookEmitter
Interface
Emits hooks. All listeners run sequentially in registration order and are awaited.
interface HookEmitter {
/** Run every `on` listener; return values are ignored. */
emit<K extends HookName>(name: K, ...args: HookArgs<K>): Promise<void>;
/** Pass the first argument through every `filter` listener and return the final value. */
applyFilters<K extends HookName>(name: K, ...args: HookArgs<K>): Promise<HookValue<K>>;
/** Run `intercept` listeners until one returns a value other than `undefined`. */
runInterceptors<K extends HookName>(name: K, ...args: HookArgs<K>): Promise<HookResult<K> | undefined>;
}
Diekspor dari packages/core/src/contracts.ts
HookListenerInfo
Interface
Tidak ada komentar dokumentasi.
interface HookListenerInfo {
readonly hook: string;
readonly kind: HookKind;
/** Plugin or provider that attached it; `undefined` for app code. */
readonly owner: string | undefined;
}
Diekspor dari packages/core/src/contracts.ts
HookRegistry
Interface
Tidak ada komentar dokumentasi.
interface HookRegistry extends HookEmitter {
on<K extends HookName>(name: K, listener: HookListener<K>): Unsubscribe;
filter<K extends HookName>(name: K, listener: HookFilter<K>): Unsubscribe;
intercept<K extends HookName>(name: K, listener: HookInterceptor<K>): Unsubscribe;
listeners(name?: HookName): readonly HookListenerInfo[];
/**
* An emitter that only reaches listeners whose owner passes `allow`. Used for plugins
* limited to a route group: listeners of route-scoped plugins fire only
* for routes in groups that list them.
*/
scoped(allow: (owner: string | undefined) => boolean): HookEmitter;
Diekspor dari packages/core/src/contracts.ts
HookResults
Interface
Hook name → value an `intercept` listener may return to short-circuit the flow.
interface HookResults {
}
Diekspor dari packages/core/src/contracts.ts
Hooks
Interface
Hook name → argument tuple. For `filter` hooks the first argument is the filtered value. Augmented by `@samveys/http` (http:*), and by future packages (db:*, view:*, job:*, ws:*, …).
interface Hooks {
'app:booting': [app: AppContext];
'app:booted': [app: AppContext];
'app:ready': [app: AppContext];
'app:terminating': [app: AppContext, reason: string];
'command:before': [command: CommandInvocation];
'command:after': [command: CommandInvocation, exitCode: number];
}
Diekspor dari packages/core/src/contracts.ts
HttpContext
Interface
The HTTP request context. Base fields live in core so plugins can augment it with `declare module '@samveys/core' { interface HttpContext { audit: AuditLog } }`.
interface HttpContext {
readonly request: Request;
readonly url: URL;
readonly method: string;
readonly headers: Headers;
/** Prototype-less. Narrowed per route by `@samveys/http`. */
readonly params: Readonly<Record<string, string>>;
readonly query: Readonly<Record<string, string | string[]>>;
readonly body: unknown;
/** Aborted on client disconnect or request timeout. */
…
Tampilkan seluruh deklarasi (22 baris)
interface HttpContext {
readonly request: Request;
readonly url: URL;
readonly method: string;
readonly headers: Headers;
/** Prototype-less. Narrowed per route by `@samveys/http`. */
readonly params: Readonly<Record<string, string>>;
readonly query: Readonly<Record<string, string | string[]>>;
readonly body: unknown;
/** Aborted on client disconnect or request timeout. */
…interface HttpContext {
readonly request: Request;
readonly url: URL;
readonly method: string;
readonly headers: Headers;
/** Prototype-less. Narrowed per route by `@samveys/http`. */
readonly params: Readonly<Record<string, string>>;
readonly query: Readonly<Record<string, string | string[]>>;
readonly body: unknown;
/** Aborted on client disconnect or request timeout. */
readonly signal: AbortSignal;
readonly requestId: string;
readonly route: RouteInfo | undefined;
/**
* The client address: the socket peer, or the first `X-Forwarded-For` hop when the peer is a
* trusted proxy (`trustProxy`). `undefined` for in-process requests (`kernel.fetch`). Use it for
* rate limits and audit logs; never trust `X-Forwarded-For` yourself.
*/
readonly clientIp: string | undefined;
/** Prototype-less scratch space for middleware. */
readonly state: Record<string, unknown>;
}
Diekspor dari packages/core/src/contracts.ts
InjectionTokenLike
Interface
A token that is not a class: use for interfaces and values. Implemented in `container.ts`.
interface InjectionTokenLike<T> {
readonly description: string;
/** Phantom; never set at runtime. */
readonly __type?: T;
}
Diekspor dari packages/core/src/contracts.ts
LifecycleHooks
Interface
Tidak ada komentar dokumentasi.
interface LifecycleHooks<Ctx> {
/** Bind services only; resolving throws SVS_E004. */
register?(context: Ctx): void;
boot?(context: Ctx): void | Promise<void>;
start?(context: Ctx): void | Promise<void>;
ready?(context: Ctx): void | Promise<void>;
/** Runs in reverse load order, each with a timeout. */
shutdown?(context: Ctx): void | Promise<void>;
}
Diekspor dari packages/core/src/contracts.ts
LoadedPluginInfo
Interface
Tidak ada komentar dokumentasi.
interface LoadedPluginInfo {
readonly name: string;
readonly kind: 'plugin' | 'provider';
readonly order: number;
readonly scope: PluginScope;
readonly requires: readonly string[];
readonly hooks: readonly HookListenerInfo[];
readonly extensions: readonly {
readonly point: string;
readonly detail: string;
…
Tampilkan seluruh deklarasi (13 baris)
interface LoadedPluginInfo {
readonly name: string;
readonly kind: 'plugin' | 'provider';
readonly order: number;
readonly scope: PluginScope;
readonly requires: readonly string[];
readonly hooks: readonly HookListenerInfo[];
readonly extensions: readonly {
readonly point: string;
readonly detail: string;
…interface LoadedPluginInfo {
readonly name: string;
readonly kind: 'plugin' | 'provider';
readonly order: number;
readonly scope: PluginScope;
readonly requires: readonly string[];
readonly hooks: readonly HookListenerInfo[];
readonly extensions: readonly {
readonly point: string;
readonly detail: string;
}[];
readonly bindings: readonly string[];
}
Diekspor dari packages/core/src/contracts.ts
LoadEnvOptions
Interface
Tidak ada komentar dokumentasi.
interface LoadEnvOptions {
/** Directory holding `.env` and `.env.[APP_ENV]`. */
readonly rootDir: string;
/** Defaults to `processEnv.APP_ENV`, then `'local'`. */
readonly appEnv?: string;
/** Defaults to `process.env`. Real environment variables win over files. */
readonly processEnv?: Readonly<Record<string, string | undefined>>;
/** Read `.env` files. Default true. */
readonly files?: boolean;
}
Diekspor dari packages/core/src/contracts.ts
LogDestination
Interface
Tidak ada komentar dokumentasi.
interface LogDestination {
write(line: string): void;
}
Diekspor dari packages/core/src/contracts.ts
LogFn
Interface
Tidak ada komentar dokumentasi.
interface LogFn {
(message: string, fields?: Readonly<Record<string, unknown>>): void;
(fields: Readonly<Record<string, unknown>>, message?: string): void;
}
Diekspor dari packages/core/src/contracts.ts
Logger
Interface
Tidak ada komentar dokumentasi.
interface Logger {
readonly level: LogLevel | 'silent';
readonly trace: LogFn;
readonly debug: LogFn;
readonly info: LogFn;
readonly warn: LogFn;
readonly error: LogFn;
readonly fatal: LogFn;
isLevelEnabled(level: LogLevel): boolean;
child(bindings: Readonly<Record<string, unknown>>): Logger;
}
Diekspor dari packages/core/src/contracts.ts
LoggerOptions
Interface
Tidak ada komentar dokumentasi.
interface LoggerOptions {
readonly level?: LogLevel | 'silent';
/**
* Extra paths to redact. A bare key (`password`) is redacted at any depth, case-insensitively;
* a dotted path (`user.ssn`) only at that path. Defaults always apply (see logger.ts).
*/
readonly redact?: readonly string[];
/** Defaults to `process.stdout`. One JSON object per line. */
readonly destination?: LogDestination;
readonly bindings?: Readonly<Record<string, unknown>>;
}
Diekspor dari packages/core/src/contracts.ts
NumberOptions
Interface
Tidak ada komentar dokumentasi.
interface NumberOptions {
readonly default?: number;
readonly optional?: boolean;
readonly min?: number;
readonly max?: number;
readonly int?: boolean;
}
Diekspor dari packages/core/src/env.ts
Plugin
Interface
Tidak ada komentar dokumentasi.
interface Plugin<C = unknown> {
readonly kind: 'plugin';
readonly name: string;
readonly requires: Required<PluginRequirements>;
readonly definition: PluginDefinition<unknown, C>;
/** Raw options given to the factory; validated at register time (SVS_E024). */
readonly options: unknown;
}
Diekspor dari packages/core/src/contracts.ts
PluginContext
Interface
Everything a plugin may touch. Never framework internals.
interface PluginContext<C = unknown> {
readonly container: Container;
readonly hooks: HookRegistry;
readonly extend: Extend;
/** Parsed by the plugin's config schema. */
readonly config: C;
/** Child logger whose lines carry `plugin: <name>`. */
readonly logger: Logger;
readonly app: AppInfo;
}
Diekspor dari packages/core/src/contracts.ts
PluginDefinition
Interface
Tidak ada komentar dokumentasi.
interface PluginDefinition<Input = undefined, C = Input> extends LifecycleHooks<PluginContext<C>> {
readonly name: string;
readonly requires?: PluginRequirements;
/** Validates the options passed to the factory; its output becomes `context.config`. */
readonly config?: StandardSchemaV1<Input, C>;
}
Diekspor dari packages/core/src/contracts.ts
PluginEntryOptions
Interface
Tidak ada komentar dokumentasi.
interface PluginEntryOptions {
readonly plugin: Plugin;
/** Load only in these environments. */
readonly env?: readonly AppEnvironment[];
/** `'routes'`: hooks fire only for route groups that list the plugin. Default `'global'`. */
readonly scope?: PluginScope;
}
Diekspor dari packages/core/src/contracts.ts
PluginRequirements
Interface
Tidak ada komentar dokumentasi.
interface PluginRequirements {
/** Semver range checked against SAMVEYS_API_VERSION, e.g. `^1.0`. */
readonly samveys?: string;
readonly plugins?: readonly string[];
}
Diekspor dari packages/core/src/contracts.ts
ProblemDetails
Interface
RFC 9457 Problem Details object sent as `application/problem+json`.
interface ProblemDetails {
/** `urn:samveys:error:<code>` for framework codes, otherwise `about:blank` or an app URI. */
readonly type: string;
readonly title: string;
readonly status: number;
readonly detail?: string;
readonly instance?: string;
/** Extension: stable `SVS_E*` code. */
readonly code?: string;
/** Extension: request id, also present in the logs. */
…
Tampilkan seluruh deklarasi (15 baris)
interface ProblemDetails {
/** `urn:samveys:error:<code>` for framework codes, otherwise `about:blank` or an app URI. */
readonly type: string;
readonly title: string;
readonly status: number;
readonly detail?: string;
readonly instance?: string;
/** Extension: stable `SVS_E*` code. */
readonly code?: string;
/** Extension: request id, also present in the logs. */
…interface ProblemDetails {
/** `urn:samveys:error:<code>` for framework codes, otherwise `about:blank` or an app URI. */
readonly type: string;
readonly title: string;
readonly status: number;
readonly detail?: string;
readonly instance?: string;
/** Extension: stable `SVS_E*` code. */
readonly code?: string;
/** Extension: request id, also present in the logs. */
readonly requestId?: string;
/** Extension: validation failures (422). */
readonly errors?: readonly ValidationIssue[];
readonly [extension: string]: unknown;
}
Diekspor dari packages/core/src/contracts.ts
Provider
Interface
Tidak ada komentar dokumentasi.
interface Provider {
readonly kind: 'provider';
readonly name: string;
readonly definition: ProviderDefinition;
}
Diekspor dari packages/core/src/contracts.ts
ProviderDefinition
Interface
Tidak ada komentar dokumentasi.
interface ProviderDefinition extends LifecycleHooks<AppContext> {
readonly name: string;
}
Diekspor dari packages/core/src/contracts.ts
RequestContext
Interface
Per-request data stored in AsyncLocalStorage; augment with user, tenant, locale.
interface RequestContext {
readonly requestId: string;
readonly startedAt: number;
traceId?: string;
locale?: string;
/** The HTTP context when the request came through `@samveys/http`. */
http?: HttpContext;
/** Free-form per-request storage. */
readonly locals: Map<string | symbol, unknown>;
}
Diekspor dari packages/core/src/contracts.ts
ResolvedPlugin
Interface
Tidak ada komentar dokumentasi.
interface ResolvedPlugin {
readonly plugin: Plugin;
readonly scope: PluginScope;
/** Position in the load order. */
readonly order: number;
}
Diekspor dari packages/core/src/plugins.ts
RouteInfo
Interface
Tidak ada komentar dokumentasi.
interface RouteInfo {
readonly name: string | undefined;
readonly method: string;
readonly pattern: string;
}
Diekspor dari packages/core/src/contracts.ts
SamveysConfig
Interface
`samveys.config.ts` default export.
interface SamveysConfig {
readonly name?: string;
readonly plugins?: readonly PluginEntry[];
readonly providers?: readonly Provider[];
/** App config tree; merged over files loaded from `config/*.ts`. */
readonly config?: Readonly<Record<string, unknown>>;
readonly env?: EnvDefinition;
/** Per shutdown handler, ms. Default 10000. */
readonly shutdownTimeout?: number;
readonly logger?: LoggerOptions;
…
Tampilkan seluruh deklarasi (13 baris)
interface SamveysConfig {
readonly name?: string;
readonly plugins?: readonly PluginEntry[];
readonly providers?: readonly Provider[];
/** App config tree; merged over files loaded from `config/*.ts`. */
readonly config?: Readonly<Record<string, unknown>>;
readonly env?: EnvDefinition;
/** Per shutdown handler, ms. Default 10000. */
readonly shutdownTimeout?: number;
readonly logger?: LoggerOptions;
…interface SamveysConfig {
readonly name?: string;
readonly plugins?: readonly PluginEntry[];
readonly providers?: readonly Provider[];
/** App config tree; merged over files loaded from `config/*.ts`. */
readonly config?: Readonly<Record<string, unknown>>;
readonly env?: EnvDefinition;
/** Per shutdown handler, ms. Default 10000. */
readonly shutdownTimeout?: number;
readonly logger?: LoggerOptions;
/** Server entry run by `svs serve`. Default `bin/server.ts`. */
readonly entry?: string;
}
Diekspor dari packages/core/src/contracts.ts
SamveysErrorOptions
Interface
Tidak ada komentar dokumentasi.
interface SamveysErrorOptions {
readonly cause?: unknown;
/** Overrides the status from ERROR_CODES. */
readonly status?: number;
readonly issues?: readonly ValidationIssue[];
/** Extra, non-sensitive data; included in logs, never in HTTP responses. */
readonly meta?: Readonly<Record<string, unknown>>;
/** When true, `message` is safe to send to clients as Problem Details `detail`. */
readonly expose?: boolean;
}
Diekspor dari packages/core/src/contracts.ts
SecretOptions
Interface
Tidak ada komentar dokumentasi.
interface SecretOptions {
readonly optional?: boolean;
readonly minLength?: number;
}
Diekspor dari packages/core/src/env.ts
ShutdownResult
Interface
Tidak ada komentar dokumentasi.
interface ShutdownResult {
/** 0 when every shutdown handler finished in time without throwing. */
readonly exitCode: 0 | 1;
/** Names of plugins/providers cut off by the timeout. */
readonly timedOut: readonly string[];
readonly errors: readonly {
readonly name: string;
readonly error: unknown;
}[];
}
Diekspor dari packages/core/src/contracts.ts
StandardSchemaV1
Interface
The Standard Schema interface.
interface StandardSchemaV1<Input = unknown, Output = Input> {
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
}
Diekspor dari packages/core/src/contracts.ts
StringOptions
Interface
Tidak ada komentar dokumentasi.
interface StringOptions {
readonly default?: string;
readonly optional?: boolean;
readonly choices?: readonly string[];
}
Diekspor dari packages/core/src/env.ts
SystemCheck
Interface
A system check run by `svs check`. IDs are stable, e.g. `core.app_key`.
interface SystemCheck {
readonly id: string;
readonly title: string;
/** Only runs with `--deploy`. */
readonly deployOnly?: boolean;
run(context: CheckContext): CheckResult | Promise<CheckResult>;
}
Diekspor dari packages/core/src/contracts.ts
UrlOptions
Interface
Tidak ada komentar dokumentasi.
interface UrlOptions {
readonly default?: string;
readonly optional?: boolean;
/** Allowed schemes without the colon, e.g. `['postgres', 'postgresql']`. */
readonly protocols?: readonly string[];
}
Diekspor dari packages/core/src/env.ts
ValidationIssue
Interface
One failing field in a validation problem (RFC 9457 §3 example shape).
interface ValidationIssue {
/** RFC 6901 JSON Pointer in URI-fragment form, prefixed with the input part: `#/body/email`. */
readonly pointer: string;
readonly detail: string;
}
Diekspor dari packages/core/src/contracts.ts
VerifyResult
Interface
Tidak ada komentar dokumentasi.
interface VerifyResult {
readonly valid: boolean;
/** New PHC string when the hash used other parameters and the password was valid. */
readonly rehashed: string | undefined;
}
Diekspor dari packages/core/src/contracts.ts
Tipe (39)
AbstractConstructor
Tipe
A class usable as a token. Concrete zero-argument classes resolve without a binding.
type AbstractConstructor<T = unknown> = abstract new (...args: never) => T;
Diekspor dari packages/core/src/contracts.ts
AnyToken
Tipe
Tidak ada komentar dokumentasi.
type AnyToken = Token<unknown> | BindingKey;
Diekspor dari packages/core/src/contracts.ts
AppEnvironment
Tipe
Tidak ada komentar dokumentasi.
type AppEnvironment = 'local' | 'test' | 'staging' | 'production' | (string & {});
Diekspor dari packages/core/src/contracts.ts
AppState
Tipe
Tidak ada komentar dokumentasi.
type AppState = 'created' | 'registered' | 'booted' | 'started' | 'ready' | 'terminating' | 'terminated';
Diekspor dari packages/core/src/contracts.ts
ArgsOf
Tipe
Turns an augmentable map entry into an argument tuple; `never` when the entry is not a tuple.
type ArgsOf<T> = T extends readonly unknown[] ? T : never;
Diekspor dari packages/core/src/contracts.ts
BindingKey
Tipe
Tidak ada komentar dokumentasi.
type BindingKey = keyof ContainerBindings & string;
Diekspor dari packages/core/src/contracts.ts
CheckResult
Tipe
Tidak ada komentar dokumentasi.
type CheckResult = {
readonly status: 'pass';
readonly message?: string;
} | {
readonly status: 'warn' | 'fail';
readonly message: string;
readonly hint?: string;
};
Diekspor dari packages/core/src/contracts.ts
ConfigPath
Tipe
Tidak ada komentar dokumentasi.
type ConfigPath = Paths<Config>;
Diekspor dari packages/core/src/contracts.ts
EnvParseResult
Tipe
Tidak ada komentar dokumentasi.
type EnvParseResult<T> = {
readonly ok: true;
readonly value: T;
} | {
readonly ok: false;
readonly message: string;
};
Diekspor dari packages/core/src/contracts.ts
EnvShape
Tipe
Tidak ada komentar dokumentasi.
type EnvShape = Readonly<Record<string, EnvRule<unknown>>>;
Diekspor dari packages/core/src/contracts.ts
ErrorCode
Tipe
Tidak ada komentar dokumentasi.
type ErrorCode = keyof typeof ERROR_CODES;
Diekspor dari packages/core/src/contracts.ts
EventListener
Tipe
Tidak ada komentar dokumentasi.
type EventListener<K extends EventName> = (payload: Events[K]) => void | Promise<void>;
Diekspor dari packages/core/src/contracts.ts
EventName
Tipe
Tidak ada komentar dokumentasi.
type EventName = keyof Events & string;
Diekspor dari packages/core/src/contracts.ts
Extend
Tipe
`extend.*` as seen by plugins.
type Extend = {
readonly [K in ExtensionPoint]: (...args: ExtensionArgs<K>) => void;
Diekspor dari packages/core/src/contracts.ts
ExtensionArgs
Tipe
Tidak ada komentar dokumentasi.
type ExtensionArgs<K extends ExtensionPoint> = ArgsOf<ExtensionPoints[K]>;
Diekspor dari packages/core/src/contracts.ts
ExtensionPoint
Tipe
Tidak ada komentar dokumentasi.
type ExtensionPoint = keyof ExtensionPoints & string;
Diekspor dari packages/core/src/contracts.ts
Factory
Tipe
Tidak ada komentar dokumentasi.
type Factory<T> = (container: Container) => T;
Diekspor dari packages/core/src/contracts.ts
HealthStatus
Tipe
Tidak ada komentar dokumentasi.
type HealthStatus = 'ok' | 'degraded' | 'down';
Diekspor dari packages/core/src/contracts.ts
HookArgs
Tipe
Tidak ada komentar dokumentasi.
type HookArgs<K extends HookName> = ArgsOf<Hooks[K]>;
Diekspor dari packages/core/src/contracts.ts
HookFilter
Tipe
Tidak ada komentar dokumentasi.
type HookFilter<K extends HookName> = (...args: HookArgs<K>) => HookValue<K> | Promise<HookValue<K>>;
Diekspor dari packages/core/src/contracts.ts
HookInterceptor
Tipe
Tidak ada komentar dokumentasi.
type HookInterceptor<K extends HookName> = (...args: HookArgs<K>) => HookResult<K> | undefined | Promise<HookResult<K> | undefined>;
Diekspor dari packages/core/src/contracts.ts
HookKind
Tipe
Tidak ada komentar dokumentasi.
type HookKind = 'on' | 'filter' | 'intercept';
Diekspor dari packages/core/src/contracts.ts
HookListener
Tipe
Tidak ada komentar dokumentasi.
type HookListener<K extends HookName> = (...args: HookArgs<K>) => void | Promise<void>;
Diekspor dari packages/core/src/contracts.ts
HookName
Tipe
Tidak ada komentar dokumentasi.
type HookName = keyof Hooks & string;
Diekspor dari packages/core/src/contracts.ts
HookResult
Tipe
Tidak ada komentar dokumentasi.
type HookResult<K extends HookName> = K extends keyof HookResults ? HookResults[K] : never;
Diekspor dari packages/core/src/contracts.ts
HookValue
Tipe
Tidak ada komentar dokumentasi.
type HookValue<K extends HookName> = HookArgs<K>[0];
Diekspor dari packages/core/src/contracts.ts
InferEnv
Tipe
Tidak ada komentar dokumentasi.
type InferEnv<S extends EnvShape> = {
readonly [K in keyof S]: S[K] extends EnvRule<infer T> ? T : never;
};
Diekspor dari packages/core/src/contracts.ts
Lazy
Tipe
A value, or a loader returning it (directly, as a promise, or as an ES module default export).
type Lazy<T> = T | (() => T | Promise<T> | Promise<{
readonly default: T;
}>);
Diekspor dari packages/core/src/contracts.ts
Lifetime
Tipe
Tidak ada komentar dokumentasi.
type Lifetime = 'singleton' | 'transient' | 'instance';
Diekspor dari packages/core/src/contracts.ts
LogLevel
Tipe
Tidak ada komentar dokumentasi.
type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
Diekspor dari packages/core/src/contracts.ts
Paths
Tipe
Dotted paths of `T`, up to 6 levels deep.
type Paths<T, Depth extends readonly unknown[] = []> = Depth['length'] extends 6 ? never : T extends ConfigLeaf ? never : {
[K in keyof T & string]: T[K] extends ConfigLeaf ? K : K | `${K}.${Paths<T[K], [...Depth, 1]>}`;
}[keyof T & string];
Diekspor dari packages/core/src/contracts.ts
PathValue
Tipe
Tidak ada komentar dokumentasi.
type PathValue<T, P extends string> = P extends `${infer Head}.${infer Rest}` ? Head extends keyof T ? PathValue<T[Head], Rest> : never : P extends keyof T ? T[P] : never;
Diekspor dari packages/core/src/contracts.ts
PluginEntry
Tipe
Tidak ada komentar dokumentasi.
type PluginEntry = Plugin | PluginEntryOptions;
Diekspor dari packages/core/src/contracts.ts
PluginFactory
Tipe
`definePlugin()` returns this factory: `audit({ table: 'x' })`.
type PluginFactory<Input, C> = ((options?: Input) => Plugin<C>) & {
Diekspor dari packages/core/src/contracts.ts
PluginScope
Tipe
Tidak ada komentar dokumentasi.
type PluginScope = 'global' | 'routes';
Diekspor dari packages/core/src/contracts.ts
Token
Tipe
Tidak ada komentar dokumentasi.
type Token<T = unknown> = AbstractConstructor<T> | InjectionTokenLike<T>;
Diekspor dari packages/core/src/contracts.ts
TokenValue
Tipe
Tidak ada komentar dokumentasi.
type TokenValue<K> = K extends BindingKey ? ContainerBindings[K] : K extends Token<infer T> ? T : never;
Diekspor dari packages/core/src/contracts.ts
TracingChannelName
Tipe
Tidak ada komentar dokumentasi.
type TracingChannelName = (typeof TRACING_CHANNELS)[keyof typeof TRACING_CHANNELS];
Diekspor dari packages/core/src/contracts.ts
Unsubscribe
Tipe
Removes a registration (listener, hook, subscription). Idempotent.
type Unsubscribe = () => void;
Diekspor dari packages/core/src/contracts.ts