/** * Builds, parses, and changes the extended field masks used by SDK runtime * features. * * Start with {@link Mask.parse} or {@link parseFieldMask} when you have mask * text. Use {@link FieldPath} when code must build one path segment by segment. * These helpers support grouped paths and wildcards in addition to standard * protobuf field-mask paths. * * This is a low-level runtime module. Generated request methods normally * handle update and reset masks for application code. * * @packageDocumentation */ import { custom, customJson } from './util/logging.js'; /** Reports that a field-mask key cannot be read from its text form. */ export declare class MarshalError extends Error { } /** * Stores one segment of a {@link FieldPath}. * * A simple key, such as `spec`, appears without quotes in a mask. A key that * contains punctuation or spaces uses JSON string syntax. */ export declare class FieldKey { [custom]: () => string; /** Contains the unquoted field name. */ readonly value: string; /** Creates a key from an unquoted field name. */ constructor(value: string); /** Returns the unquoted field name. */ toString(): string; /** * Reads one key from field-mask text. * * @throws {@link MarshalError} if the input is neither a simple key nor a * valid JSON string. */ static unmarshal(marshaled: string): FieldKey; /** * Returns the key in field-mask syntax. * * The method adds JSON quotes only when the key needs them. * * @example * ```ts * import { FieldKey } from '@nebius/js-sdk/runtime/fieldmask'; * * new FieldKey('spec').marshal(); // "spec" * new FieldKey('display-name').marshal(); // "\"display-name\"" * ``` */ marshal(): string; /** Returns a JSON-safe value for logs. */ [customJson](): string; } /** * Stores an ordered path through message fields. * * {@link FieldPath.append | append} and * {@link FieldPath.appendMany | appendMany} change this instance. Use * {@link FieldPath.copy | copy} or {@link FieldPath.concat | concat} when the * original path must stay unchanged. * * @example * ```ts * import { FieldPath } from '@nebius/js-sdk/runtime/fieldmask'; * * const path = FieldPath.from('spec', 'resources', 'memory'); * path.marshal(); // "spec.resources.memory" * ``` */ export declare class FieldPath { [custom]: () => string; /** Contains the path segments in traversal order. */ readonly parts: FieldKey[]; /** Creates a path and copies its input segments into a new array. */ constructor(base?: Iterable | null); /** Creates a path from separate key arguments. */ static from(...parts: (FieldKey | string)[]): FieldPath; /** Iterates over the path segments in traversal order. */ [Symbol.iterator](): Iterator; /** Returns the number of path parts. */ get length(): number; /** Returns the segment at the specified zero-based index. */ at(i: number): FieldKey | undefined; /** Appends one key to this path and returns this instance. */ append(v: FieldKey | string): this; /** Appends all supplied keys to this path and returns this instance. */ appendMany(iter: Iterable): this; /** Returns a new path with the supplied keys appended. */ concat(iter: Iterable): FieldPath; /** Returns a new path without the last segment, or `null` for an empty path. */ parent(): FieldPath | null; /** Returns an independent copy of this field path. */ copy(): FieldPath; /** Returns whether two field paths contain the same parts. */ equals(other: FieldPath): boolean; /** * Returns whether this path is a strict prefix of another path. * * Equal paths are not prefixes for this method. */ isPrefixOf(other: FieldPath): boolean; /** Returns a new mask that contains only this path. */ toMask(): Mask; /** Returns this path in field-mask syntax. */ marshal(): string; /** Converts the value to string. */ toString(): string; /** Returns a JSON-safe value for logs. */ [customJson](): string; } /** * Stores a field mask as a tree of named and wildcard paths. * * Use {@link Mask.parse} for text such as `metadata,spec.resources.*`. A * wildcard matches one field at its current path level. Most modifying * methods return this instance so that calls can be chained. * * @example * ```ts * import { Mask } from '@nebius/js-sdk/runtime/fieldmask'; * * const mask = Mask.parse('metadata,spec.(resources,cloud_init)'); * mask.subMask('spec')?.marshal(); // "cloud_init,resources" * mask.addPath(['status']); * mask.marshal(); // "metadata,spec.(cloud_init,resources),status" * ``` */ export declare class Mask { [custom]: () => string; /** Contains the branch for a `*` segment, or `null` when no wildcard exists. */ any: Mask | null; /** Maps each named segment to the mask below that segment. */ fieldParts: Map; /** * Creates a mask from tree branches. * * The constructor keeps the supplied branch objects. Use {@link copy} when * the caller and the mask must not share mutable state. */ constructor(any?: Mask | null, fieldParts?: Map); /** Returns whether the mask has no paths. */ isEmpty(): boolean; /** Returns an independent copy of this mask. */ copy(): Mask; /** Returns whether two masks contain the same paths. */ equals(other: Mask): boolean; /** * Returns the single linear path in this mask. * * Returns `null` when the mask contains a wildcard or more than one path. * An empty mask becomes an empty {@link FieldPath}. */ toFieldPath(): FieldPath | null; /** Returns whether this mask contains one linear path and no wildcard. */ isFieldPath(): boolean; /** * Returns the mask below one key. * * A named branch has priority over the wildcard branch. The returned value * is part of this mask, so changing it also changes this mask. */ getSubMask(key: FieldKey | string): Mask | null; /** * Returns the mask below a path. * * Returns `null` when a segment has no named or wildcard branch. */ getSubMaskByPath(path: FieldPath): Mask | null; /** Returns the mutable mask below a path or one key. */ subMask(path: FieldPath | FieldKey | string): Mask | null; /** * Adds a path to this mask and returns this instance. * * Use the string `'*'` for a wildcard segment. An empty path makes no * change. */ addPath(path: (FieldKey | string | '*')[]): this; /** * Adds all paths from another mask and returns this instance. * * New branches are copied. Later changes to `other` do not change this * mask. */ merge(other: Mask | null | undefined): this; /** * Parses field-mask text, including grouped paths and wildcards. * * @throws `Error` if the text does not follow field-mask syntax. */ static parse(source: string): Mask; /** Compatibility alias for {@link Mask.parse}. */ static Parse(source: string): Mask; private marshalRec; /** * Returns a stable, sorted field-mask string. * * The method groups shared path prefixes when this makes the output shorter. * It throws if the tree is more than 1,000 levels deep. */ marshal(): string; /** Returns a JSON-safe value for logs. */ [customJson](): string; /** Converts the value to string. */ toString(): string; private intersectRMRecursive; /** * Returns paths that this mask and a reset mask share. * * Wildcard branches match named branches. This method does not change * either input mask. */ intersectResetMask(other: Mask | null | undefined): Mask | null; private intersectDumbRecursive; /** * Returns paths that both masks contain at the same tree positions. * * This variant only matches `*` with `*`. It does not expand wildcards. */ intersectDumb(other: Mask | null | undefined): Mask | null; private subtractDumbRecursive; /** * Removes matching paths from this mask and returns this instance. * * This variant only matches `*` with `*`. It does not expand wildcards. */ subtractDumb(other: Mask | null | undefined): this; private subtractResetRecursive; /** * Removes paths selected by a reset mask and returns this instance. * * Wildcard branches in `other` also remove matching named branches. */ subtractResetMask(other: Mask | null | undefined): this; /** * Creates a mask from the leaf paths in a JavaScript value. * * Object keys become named segments. Array elements add a wildcard segment. * Empty objects and arrays become leaf paths. * * @example * ```ts * import { Mask } from '@nebius/js-sdk/runtime/fieldmask'; * * Mask.fromObject({ spec: { disks: [{ size: true }] } }).marshal(); * // "spec.disks.*.size" * ``` */ static fromObject(obj: unknown): Mask; /** * Creates a mask from a JSON string or an already parsed JavaScript value. * * @throws `SyntaxError` if a string contains invalid JSON. */ static parseJSON(source: string | unknown): Mask; /** * Converts the mask tree to a JSON-safe object. * * Leaf paths have the value `true`. Wildcard branches use the `*` key. * Named keys are stored in their marshaled form. A key that needs JSON quotes * therefore includes those quote characters in the returned object. * * Do not use {@link Mask.fromObject} or {@link Mask.parseJSON} to round-trip * this output when a key needs quotes. Those functions treat the marshaled * key as a new literal key. */ toObject(): unknown; /** * Returns the same JSON-safe tree as {@link Mask.toObject}. * * Keys that need quotes stay in marshaled form, including their quote * characters. Such keys do not round-trip through {@link Mask.parseJSON}. */ toJSON(): unknown; } /** Parses field-mask text. This function is an alias for {@link Mask.parse}. */ export declare function parseFieldMask(source: string): Mask; //# sourceMappingURL=fieldmask.d.ts.map