/** * Maps generated gRPC service IDs to network endpoints. * * Use {@link Basic}, {@link Single}, or {@link Prefix} for endpoint overrides. * Use {@link Chain} to give overrides a priority order. The SDK normally adds * {@link Conventional} and {@link TemplateExpander} itself, so applications do * not need to reproduce its default resolver chain. * * @packageDocumentation */ import { custom, customJson } from './util/logging.js'; /** * Reports that a resolver has no address for a service ID. * * A {@link Chain} catches this error and tries its next resolver. Other errors * stop the chain. */ export declare class UnknownServiceError extends Error { /** Creates a new unknown service error. */ constructor(id: string); } /** * Resolves a generated gRPC service name to an endpoint. * * SDK users normally pass a resolver in * {@link https://nebius.github.io/js-sdk/interfaces/sdk.SDKOptions.html#resolver | SDKOptions.resolver} * only when a service must use a custom endpoint. The SDK places that resolver * before its conventional Nebius resolver. */ export interface Resolver { /** * Resolves a service ID to an address. * * @param serviceId Sets the service ID, such as `nebius.compute.v1.InstanceService`. * @param apiServiceName Overrides the service-name segment when the generated * service has an API annotation. * @returns A gRPC target such as `compute.example.test:443`. The address may * contain a `{domain}` placeholder when a {@link TemplateExpander} will * process it. * @throws {@link UnknownServiceError} when the resolver cannot resolve the ID. */ resolve(serviceId: string, apiServiceName?: string): string; } /** * Resolves one exact service ID or one service-ID prefix. * * A trailing `*` in `id` selects prefix matching. Any other `*` is treated as * normal text. * * @example * ```ts * import { SDK } from '@nebius/js-sdk'; * import { Basic } from '@nebius/js-sdk/runtime/resolver'; * * const sdk = new SDK({ * resolver: new Basic('nebius.compute.v1.*', 'localhost:8443'), * userAgentPrefix: 'example-application/1.0', * }); * ``` */ export declare class Basic implements Resolver { [custom]: () => string; private parent; /** * Creates a resolver for one exact ID or ID prefix. * * @param id A full service ID, or a prefix that ends with `*`. * @param address The gRPC target returned for a match. */ constructor(id: string, address: string); /** Returns a JSON-safe value for logs. */ [customJson](): object; /** Resolves a service ID to an address. */ resolve(serviceId: string, apiServiceName?: string): string; } /** * Returns one endpoint for every service. * * This resolver is useful for a local proxy or a test server that exposes all * services through one address. */ export declare class Constant implements Resolver { [custom]: () => string; private address; /** Creates a resolver that always returns one address. */ constructor(address: string); /** Returns a JSON-safe value for logs. */ [customJson](): object; /** Returns the configured address. */ resolve(_serviceId: string, _apiServiceName?: string): string; } /** Resolves one exact, fully qualified service ID. */ export declare class Single implements Resolver { [custom]: () => string; private id; private address; /** Creates a resolver for one exact service ID. */ constructor(id: string, address: string); /** Returns a JSON-safe value for logs. */ [customJson](): object; /** Resolves the configured service ID to an address. */ resolve(serviceId: string, _apiServiceName?: string): string; } /** * Resolves every service ID that starts with a fixed prefix. * * Unlike {@link Basic}, this constructor accepts the prefix without a trailing * `*`. */ export declare class Prefix implements Resolver { [custom]: () => string; private prefix; private address; /** Creates a resolver for one service ID prefix. */ constructor(prefix: string, address: string); /** Returns a JSON-safe value for logs. */ [customJson](): object; /** Resolves a matching service ID to an address. */ resolve(serviceId: string, _apiServiceName?: string): string; } /** * Applies the standard Nebius service-address convention. * * For example, `nebius.compute.v1.InstanceService` becomes * `compute.{domain}`. The SDK later replaces `{domain}` with its configured * API domain. The resolver rejects names outside the `nebius` namespace and * names that do not end with `Service`. */ export declare class Conventional implements Resolver { [custom]: () => string; /** * Resolves a service ID with the standard Nebius address convention. * * This runtime cannot read protobuf API annotations from descriptors. * `apiServiceName` supplies the annotated service name when generated code * has one. A non-empty value replaces the second segment of `serviceId`. */ resolve(serviceId: string, apiServiceName?: string): string; /** Returns a JSON-safe value for logs. */ [customJson](): object; } /** * Tries resolvers in order until one returns an address. * * Only {@link UnknownServiceError} means “try the next resolver.” Any other * error is returned to the caller. * * @example * ```ts * import { * Chain, * Conventional, * Single, * } from '@nebius/js-sdk/runtime/resolver'; * * const resolver = new Chain( * new Single('nebius.compute.v1.InstanceService', 'localhost:8443'), * new Conventional(), * ); * ``` */ export declare class Chain implements Resolver { [custom]: () => string; private resolvers; /** Creates a chain. Earlier resolvers have higher priority. */ constructor(...resolvers: Resolver[]); /** Returns a JSON-safe value for logs. */ [customJson](): object; /** Returns the first address that the resolver chain finds. */ resolve(serviceId: string, apiServiceName?: string): string; } /** * Caches successful results from another resolver. * * The cache key contains both resolver arguments. Failed resolutions are not * cached. Entries stay for the lifetime of this object and cannot be cleared. * Use a new instance when endpoint mappings change. */ export declare class Cached implements Resolver { [custom]: () => string; private cache; private next; /** Creates a resolver that caches results from another resolver. */ constructor(next: Resolver); /** Returns a JSON-safe value for logs. */ [customJson](): object; /** Resolves a service ID and caches the address. */ resolve(serviceId: string, apiServiceName?: string): string; } /** * Replaces literal placeholders in addresses from another resolver. * * Each replacement applies to every occurrence. Replacements run in object * insertion order, so a replacement value can be changed by a later entry. * * @example * ```ts * import { * Conventional, * TemplateExpander, * } from '@nebius/js-sdk/runtime/resolver'; * * const resolver = new TemplateExpander( * { '{domain}': 'api.nebius.cloud:443' }, * new Conventional(), * ); * resolver.resolve('nebius.compute.v1.InstanceService'); * // "compute.api.nebius.cloud:443" * ``` */ export declare class TemplateExpander implements Resolver { [custom]: () => string; private substitutions; private next; /** * Creates a template expander. * * The constructor keeps the substitutions object by reference. Do not * mutate it while requests are being resolved. */ constructor(substitutions: Record, next: Resolver); /** Returns a JSON-safe value for logs. */ [customJson](): object; /** Resolves a service ID and expands address placeholders. */ resolve(serviceId: string, apiServiceName?: string): string; } //# sourceMappingURL=resolver.d.ts.map