diff --git a/core/deno.json b/core/deno.json index 088ea819..763bb9c8 100644 --- a/core/deno.json +++ b/core/deno.json @@ -1,6 +1,6 @@ { "name": "@nats-io/nats-core", - "version": "3.0.0-46", + "version": "3.0.0-47", "exports": { ".": "./src/mod.ts", "./internal": "./src/internal_mod.ts" diff --git a/core/package.json b/core/package.json index ffa375db..9c181358 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@nats-io/nats-core", - "version": "3.0.0-46", + "version": "3.0.0-47", "files": [ "lib/", "LICENSE", diff --git a/core/src/internal_mod.ts b/core/src/internal_mod.ts index f92f3d73..e984a84c 100644 --- a/core/src/internal_mod.ts +++ b/core/src/internal_mod.ts @@ -26,9 +26,11 @@ export type { Delay, ErrorResult, Perf, + Prettify, Result, Timeout, ValueResult, + WithRequired, } from "./util.ts"; export { backoff, diff --git a/core/src/util.ts b/core/src/util.ts index f2ea0786..0040c3d6 100644 --- a/core/src/util.ts +++ b/core/src/util.ts @@ -17,6 +17,18 @@ import { TD } from "./encoders.ts"; import type { Nanos } from "./core.ts"; import { TimeoutError } from "./errors.ts"; +/** + * Allows derived type structures to show through + */ +export type Prettify = { + [K in keyof T]: T[K]; +}; + +/** + * WithRequired is a utility Type allows a type to specify required fields + */ +export type WithRequired = T & { [P in K]-?: T[P] }; + export type ValueResult = { isError: false; value: T; diff --git a/core/src/version.ts b/core/src/version.ts index d6e1f155..9b2bb76f 100644 --- a/core/src/version.ts +++ b/core/src/version.ts @@ -1,2 +1,2 @@ // This file is generated - do not edit -export const version = "3.0.0-46"; +export const version = "3.0.0-47"; diff --git a/jetstream/deno.json b/jetstream/deno.json index 2e2231e8..fa7f22f9 100644 --- a/jetstream/deno.json +++ b/jetstream/deno.json @@ -1,6 +1,6 @@ { "name": "@nats-io/jetstream", - "version": "3.0.0-33", + "version": "3.0.0-34", "exports": { ".": "./src/mod.ts", "./internal": "./src/internal_mod.ts" @@ -33,6 +33,6 @@ "test": "deno test -A --parallel --reload --trace-leaks --quiet tests/ --import-map=import_map.json" }, "imports": { - "@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-46" + "@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-47" } } diff --git a/jetstream/import_map.json b/jetstream/import_map.json index d7be82d2..e17bbb64 100644 --- a/jetstream/import_map.json +++ b/jetstream/import_map.json @@ -2,8 +2,8 @@ "imports": { "@nats-io/nkeys": "jsr:@nats-io/nkeys@~2.0.0-3", "@nats-io/nuid": "jsr:@nats-io/nuid@~2.0.1-2", - "@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-46", - "@nats-io/nats-core/internal": "jsr:@nats-io/nats-core@~3.0.0-46/internal", + "@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-47", + "@nats-io/nats-core/internal": "jsr:@nats-io/nats-core@~3.0.0-47/internal", "test_helpers": "../test_helpers/mod.ts", "@std/io": "jsr:@std/io@0.224.0" } diff --git a/jetstream/package.json b/jetstream/package.json index eb113b89..55a1c324 100644 --- a/jetstream/package.json +++ b/jetstream/package.json @@ -1,6 +1,6 @@ { "name": "@nats-io/jetstream", - "version": "3.0.0-33", + "version": "3.0.0-34", "files": [ "lib/", "LICENSE", @@ -34,7 +34,7 @@ }, "description": "jetstream library - this library implements all the base functionality for NATS JetStream for javascript clients", "dependencies": { - "@nats-io/nats-core": "3.0.0-46" + "@nats-io/nats-core": "3.0.0-47" }, "devDependencies": { "@types/node": "^22.7.6", diff --git a/jetstream/src/jsapi_types.ts b/jetstream/src/jsapi_types.ts index 42c17094..e0f6cd88 100644 --- a/jetstream/src/jsapi_types.ts +++ b/jetstream/src/jsapi_types.ts @@ -17,22 +17,22 @@ import type { Nanos } from "@nats-io/nats-core"; import { nanos } from "@nats-io/nats-core"; import type { StoredMsg } from "./types.ts"; -export interface ApiPaged { +export type ApiPaged = { total: number; offset: number; limit: number; -} +}; -export interface ApiPagedRequest { +export type ApiPagedRequest = { offset: number; -} +}; -export interface ApiResponse { +export type ApiResponse = { type: string; error?: ApiError; -} +}; -export interface ApiError { +export type ApiError = { /** * HTTP like error code in the 300 to 500 range */ @@ -45,12 +45,12 @@ export interface ApiError { * The NATS error code unique to each kind of error */ err_code: number; -} +}; /** * An alternate location to read mirrored data */ -export interface StreamAlternate { +export type StreamAlternate = { /** * The mirror Stream name */ @@ -64,12 +64,12 @@ export interface StreamAlternate { * The domain holding the Stream */ domain: string; -} +}; /** * Stream configuration info */ -export interface StreamInfo extends ApiPaged { +export type StreamInfo = ApiPaged & { /** * The active configuration for the Stream */ @@ -105,9 +105,9 @@ export interface StreamInfo extends ApiPaged { * on servers 2.10.x or better */ "ts"?: string; -} +}; -export interface SubjectTransformConfig { +export type SubjectTransformConfig = { /** * The source pattern */ @@ -116,14 +116,14 @@ export interface SubjectTransformConfig { * The destination pattern */ dest: string; -} +}; /** * Sets default consumer limits for inactive_threshold and max_ack_pending * to consumers of this stream that don't specify specific values. * This functionality requires a server 2.10.x or better. */ -export interface StreamConsumerLimits { +export type StreamConsumerLimits = { /** * The default `inactive_threshold` applied to consumers. * This value is specified in nanoseconds. Please use the `nanos()` @@ -135,9 +135,9 @@ export interface StreamConsumerLimits { * The default `max_ack_pending` applied to consumers of the stream. */ "max_ack_pending"?: number; -} +}; -export interface StreamConfig extends StreamUpdateConfig { +export type StreamConfig = StreamUpdateConfig & { /** * A unique name for the Stream */ @@ -172,12 +172,12 @@ export interface StreamConfig extends StreamUpdateConfig { * as it may disrupt the synchronization logic. */ "first_seq": number; -} +}; /** * Stream options that can be updated */ -export interface StreamUpdateConfig { +export type StreamUpdateConfig = { /** * A list of subjects to consume, supports wildcards. Must be empty when a mirror is configured. May be empty when sources are configured. */ @@ -286,9 +286,9 @@ export interface StreamUpdateConfig { * become an upper bound for all clients. */ "consumer_limits"?: StreamConsumerLimits; -} +}; -export interface Republish { +export type Republish = { /** * The source subject to republish */ @@ -301,7 +301,7 @@ export interface Republish { * Only send message headers, no bodies */ "headers_only"?: boolean; -} +}; export type ExternalStream = { /** @@ -315,7 +315,7 @@ export type ExternalStream = { deliver?: string; }; -export interface StreamSource { +export type StreamSource = { /** * Name of the stream source */ @@ -349,9 +349,9 @@ export interface StreamSource { * This feature only supported on 2.10.x and better. */ subject_transforms?: SubjectTransformConfig[]; -} +}; -export interface Placement { +export type Placement = { /** * The cluster to place the stream on */ @@ -360,7 +360,7 @@ export interface Placement { * Tags matching server configuration */ tags: string[]; -} +}; export enum RetentionPolicy { /** @@ -529,7 +529,7 @@ export type DirectLastFor = { up_to_seq?: number; } & DirectBatchLimits; -export interface StreamState { +export type StreamState = { /** * Number of messages stored in the Stream */ @@ -580,12 +580,12 @@ export interface StreamState { * Subjects and their message counts when a {@link StreamInfoRequestOptions | subjects_filter} was set */ subjects?: Record; -} +}; /** * Records messages that were damaged and unrecoverable */ -export interface LostStreamData { +export type LostStreamData = { /** * The messages that were lost */ @@ -594,9 +594,9 @@ export interface LostStreamData { * The number of bytes that were lost */ bytes: number; -} +}; -export interface ClusterInfo { +export type ClusterInfo = { /** * The cluster name */ @@ -609,9 +609,9 @@ export interface ClusterInfo { * The members of the RAFT cluster */ replicas?: PeerInfo[]; -} +}; -export interface PeerInfo { +export type PeerInfo = { /** * The server name of the peer */ @@ -632,12 +632,12 @@ export interface PeerInfo { * How many uncommitted operations this peer is behind the leader */ lag: number; -} +}; /** * Information about an upstream stream source in a mirror */ -export interface StreamSourceInfo { +export type StreamSourceInfo = { /** * The name of the Stream being replicated */ @@ -659,7 +659,7 @@ export interface StreamSourceInfo { * This feature only supported on 2.10.x and better. */ subject_transforms?: SubjectTransformConfig[]; -} +}; export type PurgeOpts = PurgeBySeq | PurgeTrimOpts | PurgeBySubject; export type PurgeBySeq = { @@ -689,12 +689,12 @@ export type PurgeBySubject = { filter: string; }; -export interface PurgeResponse extends Success { +export type PurgeResponse = Success & { /** * Number of messages purged from the Stream */ purged: number; -} +}; export enum ConsumerApiAction { CreateOrUpdate = "", @@ -702,13 +702,13 @@ export enum ConsumerApiAction { Create = "create", } -export interface CreateConsumerRequest { +export type CreateConsumerRequest = { "stream_name": string; config: Partial; action?: ConsumerApiAction; -} +}; -export interface StreamMsgResponse extends ApiResponse { +export type StreamMsgResponse = ApiResponse & { message: { subject: string; seq: number; @@ -716,15 +716,15 @@ export interface StreamMsgResponse extends ApiResponse { hdrs: string; time: string; }; -} +}; -export interface SequenceInfo { +export type SequenceInfo = { "consumer_seq": number; "stream_seq": number; "last_active": Nanos; -} +}; -export interface ConsumerInfo { +export type ConsumerInfo = { /** * The stream hosting the consumer */ @@ -792,22 +792,22 @@ export interface ConsumerInfo { * is only available on servers 2.11.x or better */ "pause_remaining": Nanos; -} +}; -export interface ConsumerListResponse extends ApiResponse, ApiPaged { +export type ConsumerListResponse = ApiResponse & ApiPaged & { consumers: ConsumerInfo[]; -} +}; -export interface StreamListResponse extends ApiResponse, ApiPaged { +export type StreamListResponse = ApiResponse & ApiPaged & { streams: StreamInfo[]; -} +}; -export interface Success { +export type Success = { /** * True if the operation succeeded */ success: boolean; -} +}; export type SuccessResponse = ApiResponse & Success; @@ -819,7 +819,7 @@ export type MsgDeleteRequest = SeqMsgRequest & { "no_erase"?: boolean; }; -export interface AccountLimits { +export type AccountLimits = { /** * The maximum amount of Memory storage Stream Messages may consume */ @@ -852,9 +852,9 @@ export interface AccountLimits { * Indicates if Streams created in this account requires the max_bytes property set */ "max_bytes_required": number; -} +}; -export interface JetStreamUsage { +export type JetStreamUsage = { /** * Memory Storage being used for Stream Message storage */ @@ -871,22 +871,22 @@ export interface JetStreamUsage { * "Number of active Consumers */ consumers: number; -} +}; -export interface JetStreamUsageAccountLimits extends JetStreamUsage { +export type JetStreamUsageAccountLimits = JetStreamUsage & { limits: AccountLimits; -} +}; -export interface JetStreamAccountStats extends JetStreamUsageAccountLimits { +export type JetStreamAccountStats = JetStreamUsageAccountLimits & { api: JetStreamApiStats; domain?: string; tiers?: { R1?: JetStreamUsageAccountLimits; R3?: JetStreamUsageAccountLimits; }; -} +}; -export interface JetStreamApiStats { +export type JetStreamApiStats = { /** * Total number of API requests received for this account */ @@ -895,10 +895,9 @@ export interface JetStreamApiStats { * "API requests that resulted in an error response" */ errors: number; -} +}; -export interface AccountInfoResponse - extends ApiResponse, JetStreamAccountStats {} +export type AccountInfoResponse = ApiResponse & JetStreamAccountStats; export type PriorityGroups = { priority_groups?: string[]; @@ -1140,7 +1139,7 @@ export type PullOptions = Partial & { "idle_heartbeat": number; }; -export interface DeliveryInfo { +export type DeliveryInfo = { /** * JetStream domain of the message if applicable. */ @@ -1182,7 +1181,7 @@ export interface DeliveryInfo { * True if the message has been redelivered. */ redelivered: boolean; -} +}; export enum PubHeaders { MsgIdHdr = "Nats-Msg-Id", diff --git a/jetstream/src/jsbaseclient_api.ts b/jetstream/src/jsbaseclient_api.ts index 8ccb5b19..1217402b 100644 --- a/jetstream/src/jsbaseclient_api.ts +++ b/jetstream/src/jsbaseclient_api.ts @@ -49,13 +49,13 @@ export function defaultJsOptions(opts?: JetStreamOptions): JetStreamOptions { return extend({ apiPrefix: defaultPrefix, timeout: defaultTimeout }, opts); } -export interface StreamNames { +export type StreamNames = { streams: string[]; -} +}; -export interface StreamNameBySubject { +export type StreamNameBySubject = { subject: string; -} +}; export class BaseApiClientImpl { nc: NatsConnectionImpl; diff --git a/jetstream/src/jsmsg.ts b/jetstream/src/jsmsg.ts index c4cadcbd..d0601785 100644 --- a/jetstream/src/jsmsg.ts +++ b/jetstream/src/jsmsg.ts @@ -39,7 +39,7 @@ const SPACE = Uint8Array.of(32); /** * Represents a message stored in JetStream */ -export interface JsMsg { +export type JsMsg = { /** * True if the message was redelivered */ @@ -143,7 +143,7 @@ export interface JsMsg { * may throw an exception if there's a conversion error */ string(): string; -} +}; export function toJsMsg(m: Msg, ackTimeout = 5000): JsMsg { return new JsMsgImpl(m, ackTimeout); diff --git a/jetstream/src/jsmstream_api.ts b/jetstream/src/jsmstream_api.ts index 36e3ed57..9af49134 100644 --- a/jetstream/src/jsmstream_api.ts +++ b/jetstream/src/jsmstream_api.ts @@ -19,6 +19,7 @@ import type { NatsConnection, NatsConnectionImpl, ReviverFn, + WithRequired, } from "@nats-io/nats-core/internal"; import { createInbox, @@ -457,7 +458,9 @@ export class StreamAPIImpl extends BaseApiClientImpl implements StreamAPI { } } - async add(cfg = {} as Partial): Promise { + async add( + cfg: WithRequired, "name">, + ): Promise { this.checkStreamConfigVersions(cfg); validateStreamName(cfg.name); cfg.mirror = convertStreamSourceDomain(cfg.mirror); diff --git a/jetstream/src/types.ts b/jetstream/src/types.ts index 36c2da83..3515bf0a 100644 --- a/jetstream/src/types.ts +++ b/jetstream/src/types.ts @@ -19,6 +19,7 @@ import type { Payload, QueuedIterator, ReviverFn, + WithRequired, } from "@nats-io/nats-core/internal"; import type { @@ -47,7 +48,7 @@ import type { } from "./jsapi_types.ts"; import type { JsMsg } from "./jsmsg.ts"; -export interface JetStreamOptions { +export type JetStreamOptions = { /** * Prefix required to interact with JetStream. Must match * server configuration. @@ -64,20 +65,20 @@ export interface JetStreamOptions { * the default JetStream apiPrefix. */ domain?: string; -} +}; -export interface JetStreamManagerOptions extends JetStreamOptions { +export type JetStreamManagerOptions = JetStreamOptions & { /** * Allows disabling a check on the account for JetStream enablement see * {@link JetStreamManager.getAccountInfo()}. */ checkAPI?: boolean; -} +}; /** * The response returned by the JetStream server when a message is added to a stream. */ -export interface PubAck { +export type PubAck = { /** * The name of the stream */ @@ -94,12 +95,12 @@ export interface PubAck { * True if the message is a duplicate */ duplicate: boolean; -} +}; /** * Options for messages published to JetStream */ -export interface JetStreamPublishOptions { +export type JetStreamPublishOptions = { /** * A string identifier used to detect duplicate published messages. * If the msgID is reused within the stream's `duplicate_window`, @@ -140,39 +141,39 @@ export interface JetStreamPublishOptions { */ lastSubjectSequence: number; }>; -} +}; /** - * An interface that reports via a promise when an object such as a connection + * A type that reports via a promise when an object such as a connection * or subscription closes. */ -export interface Closed { +export type Closed = { /** * A promise that when resolves, indicates that the object is closed. */ closed: Promise; -} +}; -export interface Destroyable { +export type Destroyable = { /** * Destroys a resource on the server. Returns a promise that resolves to true * whene the operation has been completed */ destroy(): Promise; -} +}; /** - * An interface for listing. Returns a promise with typed list. + * An type for listing. Returns a promise with typed list. */ -export interface Lister { +export type Lister = { [Symbol.asyncIterator](): AsyncIterator; next(): Promise; -} +}; export type ListerFieldFilter = (v: unknown) => T[]; -export interface StreamAPI { +export type StreamAPI = { /** * Returns the information about the specified stream * @param stream @@ -187,7 +188,7 @@ export interface StreamAPI { * Adds a new stream with the specified stream configuration. * @param cfg */ - add(cfg: Partial): Promise; + add(cfg: WithRequired, "name">): Promise; /** * Updates the stream configuration for the specified stream. @@ -249,9 +250,9 @@ export interface StreamAPI { * @param name */ get(name: string): Promise; -} +}; -export interface ConsumerAPI { +export type ConsumerAPI = { /** * Returns the ConsumerInfo for the specified consumer in the specified stream. * @param stream @@ -302,12 +303,12 @@ export interface ConsumerAPI { stream: string, name: string, ): Promise<{ paused: boolean; pause_until?: string }>; -} +}; /** * The API for interacting with JetStream resources */ -export interface JetStreamManager { +export type JetStreamManager = { /** * JetStream API to interact with Consumers */ @@ -338,7 +339,7 @@ export interface JetStreamManager { * options as this JetStreamManager */ jetstream(): JetStreamClient; -} +}; export type Ordered = { ordered: true; @@ -604,107 +605,21 @@ export type Heartbeat = { export type FlowControl = { type: "flow_control"; }; -// -// /** -// * ConsumerEvents are informational notifications emitted by ConsumerMessages -// * that may be of interest to a client. -// */ -// export enum ConsumerEvents { -// /** -// * Notification that heartbeats were missed. This notification is informational. -// * The `data` portion of the status, is a number indicating the number of missed heartbeats. -// * Note that when a client disconnects, heartbeat tracking is paused while -// * the client is disconnected. -// */ -// HeartbeatsMissed = "heartbeats_missed", -// /** -// * Notification that the consumer was not found. Consumers that were accessible at -// * least once, will be retried for more messages regardless of the not being found -// * or timeouts etc. This notification includes a count of consecutive attempts to -// * find the consumer. Note that if you get this notification possibly your code should -// * attempt to recreate the consumer. Note that this notification is only informational -// * for ordered consumers, as the consumer will be created in those cases automatically. -// */ -// ConsumerNotFound = "consumer_not_found", -// -// /** -// * Notification that the stream was not found. Consumers were accessible at least once, -// * will be retried for more messages regardless of the not being found -// * or timeouts etc. This notification includes a count of consecutive attempts to -// * find the consumer. Note that if you get this notification possibly your code should -// * attempt to recreate the consumer. Note that this notification is only informational -// * for ordered consumers, as the consumer will be created in those cases automatically. -// */ -// StreamNotFound = "stream_not_found", -// -// /** -// * Notification that the consumer was deleted. This notification -// * means the consumer will not get messages unless it is recreated. The client -// * will continue to attempt to pull messages. Ordered consumer will recreate it. -// */ -// ConsumerDeleted = "consumer_deleted", -// -// /** -// * This notification is specific of ordered consumers and will be notified whenever -// * the consumer is recreated. The argument is the name of the newly created consumer. -// */ -// OrderedConsumerRecreated = "ordered_consumer_recreated", -// -// /** -// * This notification is specific to pull consumers and will be notified whenever -// * the pull request exceeds some limit such as maxwaiting, maxrequestbatch, etc. -// * The data component has the code (409) and the message from the server. -// */ -// ExceededLimit = "limit_exceeded", -// } -// -// /** -// * These events represent informational notifications emitted by ConsumerMessages -// * that can be safely ignored by clients. -// */ -// export enum ConsumerDebugEvents { -// /** -// * Requests for messages can be terminated by the server, these notifications -// * provide information on the number of messages and/or bytes that couldn't -// * be satisfied by the consumer request. The `data` portion of the status will -// * have the format of `{msgsLeft: number, bytesLeft: number}`. -// */ -// Discard = "discard", -// /** -// * Notifies that the current consumer will be reset -// */ -// Reset = "reset", -// /** -// * Notifies whenever there's a request for additional messages from the server. -// * This notification telegraphs the request options, which should be treated as -// * read-only. This notification is only useful for debugging. Data is PullOptions. -// */ -// Next = "next", -// -// /** -// * Notifies that the client received a server-side heartbeat. The payload the data -// * portion has the format `{natsLastConsumer: number, natsLastStream: number}`; -// */ -// Heartbeat = "heartbeat", -// -// /** -// * Notifies that the client received a server-side flow control message. -// * The data is null. -// */ -// FlowControl = "flow_control", -// } - -export interface PushConsumer - extends InfoableConsumer, DeleteableConsumer, ConsumerKind { - consume(opts?: PushConsumerOptions): Promise; -} -export interface ConsumerKind { +export type PushConsumer = + & InfoableConsumer + & DeleteableConsumer + & ConsumerKind + & { + consume(opts?: PushConsumerOptions): Promise; + }; + +export type ConsumerKind = { isPullConsumer(): boolean; isPushConsumer(): boolean; -} +}; -export interface ExportedConsumer extends ConsumerKind { +export type ExportedConsumer = ConsumerKind & { next( opts?: NextOptions, ): Promise; @@ -716,29 +631,27 @@ export interface ExportedConsumer extends ConsumerKind { consume( opts?: ConsumeOptions, ): Promise; -} +}; -export interface InfoableConsumer { +export type InfoableConsumer = { info(cached?: boolean): Promise; -} +}; -export interface DeleteableConsumer { +export type DeleteableConsumer = { delete(): Promise; -} +}; -export interface Consumer - extends ExportedConsumer, InfoableConsumer, DeleteableConsumer { -} +export type Consumer = ExportedConsumer & InfoableConsumer & DeleteableConsumer; -export interface Close { +export type Close = { close(): Promise; closed(): Promise; -} +}; -export interface ConsumerMessages extends QueuedIterator, Close { +export type ConsumerMessages = QueuedIterator & Close & { status(): AsyncIterable; -} +}; /** * These options are a subset of {@link ConsumerConfig} and @@ -788,9 +701,9 @@ export function isPushConsumer(v: PushConsumer | Consumer): v is PushConsumer { } /** - * Interface for interacting with JetStream data + * A type for interacting data stored in JetStream */ -export interface JetStreamClient { +export type JetStreamClient = { /** * Publishes a message to a stream. If not stream is configured to store the message, the * request will fail with RequestError error with a nested NoRespondersError. @@ -811,14 +724,14 @@ export interface JetStreamClient { apiPrefix: string; /** - * Returns the interface for accessing {@link Consumers}. Consumers + * Returns an object for accessing {@link Consumers}. Consumers * allow you to process messages stored in a stream. To create a * consumer use {@link JetStreamManager}. */ consumers: Consumers; /** - * Returns the interface for accessing {@link Streams}. + * Returns an object for accessing {@link Streams}. */ streams: Streams; @@ -829,11 +742,11 @@ export interface JetStreamClient { jetstreamManager(checkAPI?: boolean): Promise; getOptions(): JetStreamOptions; -} +}; -export interface Streams { +export type Streams = { get(stream: string): Promise; -} +}; export function isBoundPushConsumerOptions( v: unknown, @@ -869,7 +782,7 @@ export type BoundPushConsumerOptions = ConsumeCallback & { idle_heartbeat?: Nanos; }; -export interface Consumers { +export type Consumers = { /** * Returns the Consumer configured for the specified stream having the specified name. * Consumers are typically created with {@link JetStreamManager}. If no name is specified, @@ -900,19 +813,18 @@ export interface Consumers { ): Promise; getBoundPushConsumer(opts: BoundPushConsumerOptions): Promise; - // getOrderedPushConsumer( // stream: string, // opts?: Partial, // ): Promise; -} +}; /** * The Direct stream API is a bit more performant for retrieving messages, * but requires the stream to have enabled direct access. * See {@link StreamConfig.allow_direct}. */ -export interface DirectStreamAPI { +export type DirectStreamAPI = { /** * Retrieves the message matching the specified query. Messages can be * retrieved by sequence number or by last sequence matching a subject, or @@ -948,12 +860,12 @@ export interface DirectStreamAPI { stream: string, opts: DirectLastFor, ): Promise>; -} +}; /** - * An interface representing a message that retrieved directly from JetStream. + * A type representing a message that retrieved directly from JetStream. */ -export interface StoredMsg { +export type StoredMsg = { /** * The subject the message was originally received on */ @@ -992,9 +904,9 @@ export interface StoredMsg { * may throw an exception if there's a conversion error */ string(): string; -} +}; -export interface DirectMsg extends StoredMsg { +export type DirectMsg = StoredMsg & { /** * The name of the Stream storing message */ @@ -1004,12 +916,12 @@ export interface DirectMsg extends StoredMsg { * Previous sequence delivered to the client */ lastSequence: number; -} +}; /** * An advisory is an interesting event in the JetStream server */ -export interface Advisory { +export type Advisory = { /** * The type of the advisory */ @@ -1018,7 +930,7 @@ export interface Advisory { * Payload associated with the advisory */ data: unknown; -} +}; /** * The different kinds of Advisories @@ -1040,7 +952,7 @@ export enum AdvisoryKind { ConsumerQuorumLost = "consumer_quorum_lost", } -export interface Stream { +export type Stream = { name: string; info( @@ -1073,7 +985,7 @@ export interface Stream { getMessage(query: MsgRequest): Promise; deleteMessage(seq: number, erase?: boolean): Promise; -} +}; export enum JsHeaders { /** diff --git a/jetstream/tests/jsm_test.ts b/jetstream/tests/jsm_test.ts index 11e86588..2d32d949 100644 --- a/jetstream/tests/jsm_test.ts +++ b/jetstream/tests/jsm_test.ts @@ -80,6 +80,7 @@ import { import type { JetStreamManagerImpl } from "../src/jsclient.ts"; import { stripNatsMetadata } from "./util.ts"; import { jserrors } from "../src/jserrors.ts"; +import type { WithRequired } from "../../core/src/util.ts"; const StreamNameRequired = "stream name required"; const ConsumerNameRequired = "durable name required"; @@ -1625,7 +1626,7 @@ Deno.test("jsm - list filter", async () => { }), ); - const spec: Partial[] = [ + const spec: WithRequired, "name">[] = [ { name: "s1", subjects: ["foo"] }, { name: "s2", subjects: ["bar"] }, { name: "s3", subjects: ["foo.*", "bar.*"] }, diff --git a/kv/deno.json b/kv/deno.json index e300c4a1..0d7ff095 100644 --- a/kv/deno.json +++ b/kv/deno.json @@ -1,6 +1,6 @@ { "name": "@nats-io/kv", - "version": "3.0.0-26", + "version": "3.0.0-27", "exports": { ".": "./src/mod.ts", "./internal": "./src/internal_mod.ts" @@ -33,7 +33,7 @@ "test": "deno test -A --parallel --reload --quiet tests/ --import-map=import_map.json" }, "imports": { - "@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-46", - "@nats-io/jetstream": "jsr:@nats-io/jetstream@~3.0.0-33" + "@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-47", + "@nats-io/jetstream": "jsr:@nats-io/jetstream@~3.0.0-34" } } diff --git a/kv/import_map.json b/kv/import_map.json index 2550d0ae..dd32484f 100644 --- a/kv/import_map.json +++ b/kv/import_map.json @@ -1,9 +1,9 @@ { "imports": { - "@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-46", - "@nats-io/nats-core/internal": "jsr:@nats-io/nats-core@~3.0.0-46/internal", - "@nats-io/jetstream": "jsr:@nats-io/jetstream@~3.0.0-33", - "@nats-io/jetstream/internal": "jsr:@nats-io/jetstream@~3.0.0-33/internal", + "@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-47", + "@nats-io/nats-core/internal": "jsr:@nats-io/nats-core@~3.0.0-47/internal", + "@nats-io/jetstream": "jsr:@nats-io/jetstream@~3.0.0-34", + "@nats-io/jetstream/internal": "jsr:@nats-io/jetstream@~3.0.0-34/internal", "test_helpers": "../test_helpers/mod.ts", "@nats-io/nkeys": "jsr:@nats-io/nkeys@~2.0.0-3", "@nats-io/nuid": "jsr:@nats-io/nuid@~2.0.1-2", diff --git a/kv/package.json b/kv/package.json index b0d56b88..425e0a52 100644 --- a/kv/package.json +++ b/kv/package.json @@ -1,6 +1,6 @@ { "name": "@nats-io/kv", - "version": "3.0.0-26", + "version": "3.0.0-27", "files": [ "lib/", "LICENSE", @@ -34,8 +34,8 @@ }, "description": "kv library - this library implements all the base functionality for NATS KV javascript clients", "dependencies": { - "@nats-io/jetstream": "3.0.0-33", - "@nats-io/nats-core": "3.0.0-46" + "@nats-io/jetstream": "3.0.0-34", + "@nats-io/nats-core": "3.0.0-47" }, "devDependencies": { "@types/node": "^22.7.6", diff --git a/obj/deno.json b/obj/deno.json index 7596b5ed..2873a069 100644 --- a/obj/deno.json +++ b/obj/deno.json @@ -1,6 +1,6 @@ { "name": "@nats-io/obj", - "version": "3.0.0-28", + "version": "3.0.0-29", "exports": { ".": "./src/mod.ts", "./internal": "./src/internal_mod.ts" @@ -33,7 +33,7 @@ "test": "deno test -A --parallel --reload --quiet tests/ --import-map=import_map.json" }, "imports": { - "@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-46", - "@nats-io/jetstream": "jsr:@nats-io/jetstream@~3.0.0-33" + "@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-47", + "@nats-io/jetstream": "jsr:@nats-io/jetstream@~3.0.0-34" } } diff --git a/obj/import_map.json b/obj/import_map.json index 2550d0ae..dd32484f 100644 --- a/obj/import_map.json +++ b/obj/import_map.json @@ -1,9 +1,9 @@ { "imports": { - "@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-46", - "@nats-io/nats-core/internal": "jsr:@nats-io/nats-core@~3.0.0-46/internal", - "@nats-io/jetstream": "jsr:@nats-io/jetstream@~3.0.0-33", - "@nats-io/jetstream/internal": "jsr:@nats-io/jetstream@~3.0.0-33/internal", + "@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-47", + "@nats-io/nats-core/internal": "jsr:@nats-io/nats-core@~3.0.0-47/internal", + "@nats-io/jetstream": "jsr:@nats-io/jetstream@~3.0.0-34", + "@nats-io/jetstream/internal": "jsr:@nats-io/jetstream@~3.0.0-34/internal", "test_helpers": "../test_helpers/mod.ts", "@nats-io/nkeys": "jsr:@nats-io/nkeys@~2.0.0-3", "@nats-io/nuid": "jsr:@nats-io/nuid@~2.0.1-2", diff --git a/obj/package.json b/obj/package.json index 44de5fe7..8698467e 100644 --- a/obj/package.json +++ b/obj/package.json @@ -1,6 +1,6 @@ { "name": "@nats-io/obj", - "version": "3.0.0-28", + "version": "3.0.0-29", "files": [ "lib/", "LICENSE", @@ -34,8 +34,8 @@ }, "description": "obj library - this library implements all the base functionality for NATS objectstore for javascript clients", "dependencies": { - "@nats-io/jetstream": "3.0.0-33", - "@nats-io/nats-core": "3.0.0-46" + "@nats-io/jetstream": "3.0.0-34", + "@nats-io/nats-core": "3.0.0-47" }, "devDependencies": { "@types/node": "^22.7.6", diff --git a/services/deno.json b/services/deno.json index b4ad4514..10d7883f 100644 --- a/services/deno.json +++ b/services/deno.json @@ -1,6 +1,6 @@ { "name": "@nats-io/services", - "version": "3.0.0-20", + "version": "3.0.0-21", "exports": { ".": "./src/mod.ts", "./internal": "./src/internal_mod.ts" @@ -33,6 +33,6 @@ "test": "deno test -A --parallel --reload --quiet tests/ --import-map=import_map.json" }, "imports": { - "@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-46" + "@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-47" } } diff --git a/services/import_map.json b/services/import_map.json index 78be4928..477b9fa1 100644 --- a/services/import_map.json +++ b/services/import_map.json @@ -1,7 +1,7 @@ { "imports": { - "@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-46", - "@nats-io/nats-core/internal": "jsr:@nats-io/nats-core@~3.0.0-46/internal", + "@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-47", + "@nats-io/nats-core/internal": "jsr:@nats-io/nats-core@~3.0.0-47/internal", "test_helpers": "../test_helpers/mod.ts", "@nats-io/nkeys": "jsr:@nats-io/nkeys@~2.0.0-3", "@nats-io/nuid": "jsr:@nats-io/nuid@~2.0.1-2", diff --git a/services/package.json b/services/package.json index a870fe8a..34badc12 100644 --- a/services/package.json +++ b/services/package.json @@ -1,6 +1,6 @@ { "name": "@nats-io/services", - "version": "3.0.0-20", + "version": "3.0.0-21", "files": [ "lib/", "LICENSE", @@ -34,7 +34,7 @@ }, "description": "services library - this library implements all the base functionality for NATS services for javascript clients", "dependencies": { - "@nats-io/nats-core": "3.0.0-46" + "@nats-io/nats-core": "3.0.0-47" }, "devDependencies": { "@types/node": "^22.7.6", diff --git a/transport-deno/deno.json b/transport-deno/deno.json index dcb3cdef..2adfcddd 100644 --- a/transport-deno/deno.json +++ b/transport-deno/deno.json @@ -1,6 +1,6 @@ { "name": "@nats-io/transport-deno", - "version": "3.0.0-18", + "version": "3.0.0-19", "exports": { ".": "./src/mod.ts" }, @@ -20,7 +20,7 @@ }, "imports": { "@std/io": "jsr:@std/io@0.225.0", - "@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-46", + "@nats-io/nats-core": "jsr:@nats-io/nats-core@~3.0.0-47", "@nats-io/nkeys": "jsr:@nats-io/nkeys@~2.0.0-3", "@nats-io/nuid": "jsr:@nats-io/nuid@~2.0.1-2" } diff --git a/transport-deno/src/version.ts b/transport-deno/src/version.ts index 35419336..327f3fe4 100644 --- a/transport-deno/src/version.ts +++ b/transport-deno/src/version.ts @@ -1,2 +1,2 @@ // This file is generated - do not edit -export const version = "3.0.0-18"; +export const version = "3.0.0-19"; diff --git a/transport-node/package-lock.json b/transport-node/package-lock.json index f68840b9..30928fbd 100644 --- a/transport-node/package-lock.json +++ b/transport-node/package-lock.json @@ -1,12 +1,12 @@ { "name": "@nats-io/transport-node", - "version": "3.0.0-29", + "version": "3.0.0-32", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@nats-io/transport-node", - "version": "3.0.0-29", + "version": "3.0.0-32", "license": "Apache-2.0", "dependencies": { "@nats-io/nats-core": "~3.0.0-20", diff --git a/transport-node/package.json b/transport-node/package.json index 31c4d0c6..a3fa3afb 100644 --- a/transport-node/package.json +++ b/transport-node/package.json @@ -1,6 +1,6 @@ { "name": "@nats-io/transport-node", - "version": "3.0.0-31", + "version": "3.0.0-32", "description": "Node.js client for NATS, a lightweight, high-performance cloud native messaging system", "keywords": [ "nats", @@ -54,7 +54,7 @@ "node": ">= 18.0.0" }, "dependencies": { - "@nats-io/nats-core": "3.0.0-46", + "@nats-io/nats-core": "3.0.0-47", "@nats-io/nkeys": "2.0.0-3", "@nats-io/nuid": "2.0.1-2" }, @@ -63,8 +63,8 @@ "minimist": "^1.2.8", "shx": "^0.3.3", "typescript": "5.6.3", - "@nats-io/jetstream": "3.0.0-33", - "@nats-io/kv": "3.0.0-26", - "@nats-io/obj": "3.0.0-28" + "@nats-io/jetstream": "3.0.0-34", + "@nats-io/kv": "3.0.0-27", + "@nats-io/obj": "3.0.0-29" } } diff --git a/transport-node/src/version.ts b/transport-node/src/version.ts index 99c9f13d..5e489324 100644 --- a/transport-node/src/version.ts +++ b/transport-node/src/version.ts @@ -1,2 +1,2 @@ // This file is generated - do not edit -export const version = "3.0.0-31"; +export const version = "3.0.0-32";