/** * S2 SDK Types * * All public SDK types are defined here. Types use camelCase field names * for idiomatic JavaScript/TypeScript usage. * * Generated types (snake_case, matching API wire format) are available * from "./generated/types.gen.js" as the `API` namespace. */ import type * as API from "./generated/types.gen.js"; import type { EncryptionAlgorithm } from "./lib/encryption.js"; import type { ListAllArgs } from "./lib/paginate.js"; export type { EncryptionAlgorithm, EncryptionKeyInput, } from "./lib/encryption.js"; export { EncryptionKey, EncryptionKeyLengthError } from "./lib/encryption.js"; /** * Position of a record in a stream. */ export interface StreamPosition { /** Sequence number assigned by the service. */ readonly seqNum: number; /** Timestamp of the record. */ readonly timestamp: Date; } /** * Append record with string body and string headers. * Use `AppendRecord.string()` to construct instances. */ export interface StringAppendRecord { readonly body: string; readonly headers?: ReadonlyArray; /** Optional timestamp (Date or milliseconds since Unix epoch). */ readonly timestamp?: number | Date; /** Pre-calculated metered size in bytes. */ readonly meteredBytes: number; } /** * Append record with binary body and binary headers. * Use `AppendRecord.bytes()` to construct instances. */ export interface BytesAppendRecord { readonly body: Uint8Array; readonly headers?: ReadonlyArray; /** Optional timestamp (Date or milliseconds since Unix epoch). */ readonly timestamp?: number | Date; /** Pre-calculated metered size in bytes. */ readonly meteredBytes: number; } /** * Record to be appended to a stream. * Can be either string format (text) or bytes format (binary). */ export type AppendRecord = StringAppendRecord | BytesAppendRecord; /** * Factory functions for creating AppendRecord instances. */ export declare namespace AppendRecord { /** * Create a string-format append record with pre-calculated metered size. */ function string(params: { readonly body: string; readonly headers?: ReadonlyArray; readonly timestamp?: number | Date; }): StringAppendRecord; /** * Create a bytes-format append record with pre-calculated metered size. */ function bytes(params: { readonly body: Uint8Array; readonly headers?: ReadonlyArray; readonly timestamp?: number | Date; }): BytesAppendRecord; /** * Create a fence command record. */ function fence(fencingToken: string, timestamp?: number | Date): StringAppendRecord; /** * Create a trim command record. */ function trim(seqNum: number, timestamp?: number | Date): BytesAppendRecord; } /** * Record read from a stream. * The Format type parameter controls whether body and headers are decoded as strings or kept as binary. */ export interface ReadRecord { readonly seqNum: number; readonly body: Format extends "string" ? string : Uint8Array; readonly headers: Format extends "string" ? ReadonlyArray : ReadonlyArray; /** Timestamp of the record. */ readonly timestamp: Date; } /** Maximum number of records in a single append batch. */ export declare const MAX_APPEND_RECORDS = 1000; /** Maximum total metered bytes for records in a single append batch (1 MiB). */ export declare const MAX_APPEND_BYTES: number; /** * Input for append operations. * Use `AppendInput.create()` to construct with validation. */ export interface AppendInput { readonly records: ReadonlyArray; readonly matchSeqNum?: number; readonly fencingToken?: string; /** Pre-calculated total metered size in bytes. */ readonly meteredBytes: number; } /** * Factory functions for creating AppendInput instances. */ export declare namespace AppendInput { /** * Create an AppendInput with validation. * * @throws {S2Error} If validation fails (empty, too many records, or too large) */ function create(records: ReadonlyArray, options?: { readonly matchSeqNum?: number; readonly fencingToken?: string; }): AppendInput; } /** * Starting position for reading from a stream. */ export type ReadFrom = { readonly seqNum: number; } | { readonly timestamp: number | Date; } | { readonly tailOffset: number; }; /** * Where to start reading. */ export interface ReadStart { readonly from?: ReadFrom; /** Start from tail if requested position is beyond it. */ readonly clamp?: boolean; } /** * Limits on how much to read. */ export interface ReadLimits { readonly count?: number; readonly bytes?: number; } /** * When to stop reading. */ export interface ReadStop { readonly limits?: ReadLimits; /** * Timestamp at which to stop (exclusive). * Accepts a `Date` or milliseconds since Unix epoch. */ readonly untilTimestamp?: number | Date; /** * Duration in seconds to wait for new records before stopping. * Non-integer values are floored when sent to the API. */ readonly waitSecs?: number; } /** * Input for read operations. */ export interface ReadInput { readonly start?: ReadStart; readonly stop?: ReadStop; readonly ignoreCommandRecords?: boolean; } /** * Success response to an append request. */ export interface AppendAck { readonly start: StreamPosition; readonly end: StreamPosition; readonly tail: StreamPosition; } /** * Batch of records read from a stream. */ export interface ReadBatch { readonly records: ReadonlyArray>; readonly tail?: StreamPosition; } /** * Response from checking the tail of a stream. */ export interface TailResponse { readonly tail: StreamPosition; } /** * Options for append sessions (backpressure control). */ export interface AppendSessionOptions { /** Max in-flight bytes before backpressure (default: 3 MiB). */ readonly maxInflightBytes?: number; /** Max in-flight batches before backpressure. */ readonly maxInflightBatches?: number; } /** * Input for listing streams. */ export interface ListStreamsInput { /** Filter to streams whose name begins with this prefix. */ prefix?: string; /** Filter to streams whose name lexicographically starts after this string. */ startAfter?: string; /** Number of results, up to a maximum of 1000. */ limit?: number; } export type ListAllStreamsInput = ListAllArgs; /** * Result of provisioning a resource. */ export type ProvisionResult = "created" | "updated" | "noop"; /** * Input for creating a stream. */ export interface CreateStreamInput { /** * Stream name that is unique to the basin. * It can be between 1 and 512 bytes in length. */ stream: string; /** Stream configuration. */ config?: StreamConfig | null; } /** * Input for getting stream configuration. */ export interface GetStreamConfigInput { /** Stream name. */ stream: string; } /** * Input for deleting a stream. */ export interface DeleteStreamInput { /** Stream name. */ stream: string; } /** * Input for ensuring a stream. */ export interface EnsureStreamInput { /** Stream name. */ stream: string; /** * Desired stream configuration before basin defaults are applied. * * Missing fields are filled from the current basin default stream configuration and then * global defaults before comparing or writing. If omitted, the stream is ensured using those * defaults. */ config?: StreamConfig | null; } /** * Input for reconfiguring a stream. */ export interface ReconfigureStreamInput { /** Stream name. */ stream: string; /** Delete-on-empty configuration. */ deleteOnEmpty?: DeleteOnEmptyConfig | null; /** Retention policy. */ retentionPolicy?: RetentionPolicy | null; /** Storage class. */ storageClass?: API.StorageClass | null; /** Timestamping configuration. */ timestamping?: TimestampingConfig | null; } /** * Information about a stream. */ export interface StreamInfo { /** Stream name. */ name: string; /** Creation time. */ createdAt: Date; /** Deletion time, if the stream is being deleted. */ deletedAt?: Date | null; /** Encryption algorithm for this stream, if encryption is enabled. */ cipher?: EncryptionAlgorithm | null; } /** * Delete-on-empty configuration. */ export interface DeleteOnEmptyConfig { /** * Minimum age in seconds before an empty stream can be deleted. * Set to 0 (default) to disable delete-on-empty. */ minAgeSecs?: number; } /** * Timestamping configuration. */ export interface TimestampingConfig { /** Timestamping mode. */ mode?: API.TimestampingMode | null; /** * Allow client-specified timestamps to exceed the arrival time. * If false or not set, client timestamps will be capped at the arrival time. */ uncapped?: boolean | null; } /** * Retention policy for automatic trimming. * * Either specify `ageSecs` for time-based retention, or `infinite` for unlimited retention. */ export type RetentionPolicy = { /** Age in seconds for automatic trimming of records older than this threshold. Must be > 0. */ ageSecs: number; } | { /** Retain records unless explicitly trimmed. */ infinite: API.InfiniteRetention; }; /** * Stream configuration. */ export interface StreamConfig { /** Delete-on-empty configuration. */ deleteOnEmpty?: DeleteOnEmptyConfig | null; /** Retention policy. */ retentionPolicy?: RetentionPolicy | null; /** Storage class. */ storageClass?: API.StorageClass | null; /** Timestamping configuration. */ timestamping?: TimestampingConfig | null; } /** * Response from listing streams. */ export interface ListStreamsResponse { /** List of streams. */ streams: StreamInfo[]; /** Whether there are more results. */ hasMore: boolean; } /** * Response from creating a stream. */ export interface CreateStreamResponse { /** Stream configuration. */ config: StreamConfig; } /** * Response from ensuring a stream. */ export interface EnsureStreamResponse { /** * Provisioning outcome. */ result: ProvisionResult; /** Current stream state. */ stream: StreamInfo; } export type ReconfigureStreamResponse = StreamConfig; /** * Information about a location. */ export interface LocationInfo { /** Location name. */ name: API.LocationName; /** Whether the location represents a private placement limited by account. */ isPrivate: boolean; } /** * Response from listing locations. */ export type ListLocationsResponse = LocationInfo[]; /** * Response from getting the default location. */ export type GetDefaultLocationResponse = LocationInfo; /** * Input for setting the default location. */ export interface SetDefaultLocationInput { /** Location name. */ location: API.LocationName; } /** * Response from setting the default location. */ export type SetDefaultLocationResponse = LocationInfo; /** * Input for listing basins. */ export interface ListBasinsInput { /** Filter to basins whose names begin with this prefix. */ prefix?: string; /** Filter to basins whose names lexicographically start after this string. */ startAfter?: string; /** Number of results, up to a maximum of 1000. */ limit?: number; } export type ListAllBasinsInput = ListAllArgs; /** * Input for creating a basin. */ export interface CreateBasinInput { /** * Basin name which must be globally unique. * It can be between 8 and 48 characters in length, and comprise lowercase letters, numbers and hyphens. * It cannot begin or end with a hyphen. */ basin: string; /** Basin configuration. */ config?: BasinConfig | null; /** Basin location. */ location?: API.LocationName | null; } /** * Input for getting basin configuration. */ export interface GetBasinConfigInput { /** Basin name. */ basin: string; } /** * Input for deleting a basin. */ export interface DeleteBasinInput { /** Basin name. */ basin: string; } /** * Input for ensuring a basin. */ export interface EnsureBasinInput { /** Basin name. */ basin: string; /** * Desired configuration for the basin. * * If omitted, the basin is ensured with the default configuration. */ config?: BasinConfig | null; /** * Basin location. * * If omitted when creating, uses the default location for the service. Cannot be changed once set. */ location?: API.LocationName | null; } /** * Input for reconfiguring a basin. */ export interface ReconfigureBasinInput { /** Basin name. */ basin: string; /** Create a stream on append. */ createStreamOnAppend?: boolean | null; /** Create a stream on read. */ createStreamOnRead?: boolean | null; /** Default stream configuration updates. */ defaultStreamConfig?: StreamConfig | null; /** Encryption algorithm to apply to newly created streams in this basin. */ streamCipher?: EncryptionAlgorithm | null; } /** * Information about a basin. */ export interface BasinInfo { /** Basin name. */ name: string; /** Basin location. */ location?: API.LocationName | null; /** Creation time. */ createdAt: Date; /** Deletion time if the basin is being deleted. */ deletedAt?: Date | null; } /** * Basin configuration. */ export interface BasinConfig { /** Create stream on append if it doesn't exist. */ createStreamOnAppend?: boolean; /** Create stream on read if it doesn't exist. */ createStreamOnRead?: boolean; /** Default stream configuration. */ defaultStreamConfig?: StreamConfig | null; /** Encryption algorithm to apply to newly created streams in this basin. */ streamCipher?: EncryptionAlgorithm | null; } /** * Response from listing basins. */ export interface ListBasinsResponse { /** List of basins. */ basins: BasinInfo[]; /** Whether there are more results. */ hasMore: boolean; } /** * Response from creating a basin. */ export type CreateBasinResponse = BasinInfo; /** * Response from ensuring a basin. */ export interface EnsureBasinResponse { /** * Provisioning outcome. */ result: ProvisionResult; /** Current basin info. */ basin: BasinInfo; } export type ReconfigureBasinResponse = BasinConfig; /** * Input for listing access tokens. */ export interface ListAccessTokensInput { /** Filter to access tokens whose ID begins with this prefix. */ prefix?: string; /** Filter to access tokens whose ID lexicographically starts after this string. */ startAfter?: string; /** Number of results, up to a maximum of 1000. */ limit?: number; } export type ListAllAccessTokensInput = ListAllArgs; /** * Scope for an access token. */ export interface AccessTokenScope { /** Resource set for access tokens. */ accessTokens?: API.ResourceSet | null; /** Resource set for basins. */ basins?: API.ResourceSet | null; /** Permitted operation groups. */ opGroups?: API.PermittedOperationGroups | null; /** Operations allowed for the token. */ ops?: API.Operation[] | null; /** Resource set for streams. */ streams?: API.ResourceSet | null; } /** * Input for issuing an access token. */ export interface IssueAccessTokenInput { /** * Access token ID. * It must be unique to the account and between 1 and 96 bytes in length. */ id: string; /** Access token scope. */ scope: AccessTokenScope; /** * Namespace streams based on the configured stream-level scope, which must be a prefix. * Stream name arguments will be automatically prefixed, and the prefix will be stripped when listing streams. */ autoPrefixStreams?: boolean; /** * Expiration time (Date, milliseconds since Unix epoch, or RFC 3339 string). * If not set, the expiration will be set to that of the requestor's token. */ expiresAt?: Date | number | string | null; } /** * Input for revoking an access token. */ export interface RevokeAccessTokenInput { /** Access token ID. */ id: string; } /** * Information about an access token. */ export interface AccessTokenInfo { /** Access token ID. */ id: string; /** Access token scope. */ scope: AccessTokenScope; /** Whether streams are auto-prefixed. */ autoPrefixStreams?: boolean; /** Expiration time. */ expiresAt?: Date | null; } /** * Response from listing access tokens. */ export interface ListAccessTokensResponse { /** List of access tokens. */ accessTokens: AccessTokenInfo[]; /** Whether there are more results. */ hasMore: boolean; } /** * Response from issuing an access token. */ export interface IssueAccessTokenResponse { /** The created access token. */ accessToken: string; } /** * Input for account-level metrics. */ export interface AccountMetricsInput { /** Metric set to return. */ set: API.AccountMetricSet; /** Start timestamp (Date, or milliseconds since Unix epoch), if applicable for the metric set. */ start?: number | Date; /** End timestamp (Date, or milliseconds since Unix epoch), if applicable for the metric set. */ end?: number | Date; /** Interval to aggregate over for timeseries metric sets. */ interval?: API.TimeseriesInterval; } /** * Input for basin-level metrics. */ export interface BasinMetricsInput { /** Basin name. */ basin: string; /** Metric set to return. */ set: API.BasinMetricSet; /** Start timestamp (Date, or milliseconds since Unix epoch), if applicable for the metric set. */ start?: number | Date; /** End timestamp (Date, or milliseconds since Unix epoch), if applicable for the metric set. */ end?: number | Date; /** Interval to aggregate over for timeseries metric sets. */ interval?: API.TimeseriesInterval; } /** * Input for stream-level metrics. */ export interface StreamMetricsInput { /** Basin name. */ basin: string; /** Stream name. */ stream: string; /** Metric set to return. */ set: API.StreamMetricSet; /** Start timestamp (Date, or milliseconds since Unix epoch), if applicable for the metric set. */ start?: number | Date; /** End timestamp (Date, or milliseconds since Unix epoch), if applicable for the metric set. */ end?: number | Date; /** Interval to aggregate over for timeseries metric sets. */ interval?: API.TimeseriesInterval; } /** * A scalar metric with a single value. */ export interface ScalarMetric { /** Metric name. */ name: string; /** Unit of the metric. */ unit: API.MetricUnit; /** Metric value. */ value: number; } /** * An accumulation metric with timeseries values aggregated over an interval. */ export interface AccumulationMetric { /** The interval at which data points are accumulated. */ interval: API.TimeseriesInterval; /** Timeseries name. */ name: string; /** Unit of the metric. */ unit: API.MetricUnit; /** * Timeseries values. * Each element is a pair `[timestamp, value]`. */ values: Array<[Date, number]>; } /** * A gauge metric with instantaneous values at timestamps. */ export interface GaugeMetric { /** Timeseries name. */ name: string; /** Unit of the metric. */ unit: API.MetricUnit; /** * Timeseries values. * Each element is a pair `[timestamp, value]`. * The value represents the measurement at the instant of the timestamp. */ values: Array<[Date, number]>; } /** * A label metric with string values. */ export interface LabelMetric { /** Label name. */ name: string; /** Label values. */ values: Array; } /** * A metric in a metric set response. * Can be a scalar, accumulation, gauge, or label metric. */ export type Metric = { scalar: ScalarMetric; } | { accumulation: AccumulationMetric; } | { gauge: GaugeMetric; } | { label: LabelMetric; }; /** * Response from a metrics query. */ export interface MetricSetResponse { /** Metrics comprising the set. */ values: Array; } //# sourceMappingURL=types.d.ts.map