diff --git a/src/common/lib/types/stats.ts b/src/common/lib/types/stats.ts index 8905a8a7ba..e9811f4d45 100644 --- a/src/common/lib/types/stats.ts +++ b/src/common/lib/types/stats.ts @@ -1,304 +1,24 @@ -import * as Utils from '../util/utils'; - -type MessageValues = { - count?: number; - data?: number; - uncompressedData?: number; - failed?: number; - refused?: number; - category?: Record; -}; - -type ResourceValues = { - peak?: number; - min?: number; - mean?: number; - opened?: number; - refused?: number; -}; - -type RequestValues = { - succeeded?: number; - failed?: number; - refused?: number; -}; - -type ConnectionTypesValues = { - plain?: ResourceValues; - tls?: ResourceValues; - all?: ResourceValues; -}; - -type MessageTypesValues = { - messages?: MessageValues; - presence?: MessageValues; - all?: MessageValues; -}; - -type MessageTrafficValues = { - realtime?: MessageTypesValues; - rest?: MessageTypesValues; - webhook?: MessageTypesValues; - sharedQueue?: MessageTypesValues; - externalQueue?: MessageTypesValues; - httpEvent?: MessageTypesValues; - push?: MessageTypesValues; - all?: MessageTypesValues; -}; - -type MessageDirectionsValues = { - all?: MessageTypesValues; - inbound?: MessageTrafficValues; - outbound?: MessageTrafficValues; -}; - -type XchgMessagesValues = { - all?: MessageTypesValues; - producerPaid?: MessageDirectionsValues; - consumerPaid?: MessageDirectionsValues; -}; - -type NotificationsValues = { - invalid?: number; - attempted?: number; - successful?: number; - failed?: number; -}; - -type PushValues = { - messages?: number; - notifications?: NotificationsValues; - directPublishes?: number; -}; - -type ProcessedCountValues = { - succeeded?: number; - skipped?: number; - failed?: number; -}; - -type ProcessedMessagesValues = { - delta?: Record; -}; - type StatsValues = { - all?: MessageTypesValues; - inbound?: MessageTrafficValues; - outbound?: MessageTrafficValues; - persisted?: MessageTypesValues; - connections?: ConnectionTypesValues; - channels?: ResourceValues; - apiRequests?: RequestValues; - tokenRequests?: RequestValues; - xchgProducer?: XchgMessagesValues; - xchgConsumer?: XchgMessagesValues; - pushStats?: PushValues; - processed?: ProcessedMessagesValues; + entries?: Partial>; + schema?: string; + appId?: string; inProgress?: never; unit?: never; intervalId?: never; }; -class MessageCount { - count?: number; - data?: number; - uncompressedData?: number; - failed?: number; - refused?: number; - - constructor(values?: MessageValues) { - this.count = (values && values.count) || 0; - this.data = (values && values.data) || 0; - this.uncompressedData = (values && values.uncompressedData) || 0; - this.failed = (values && values.failed) || 0; - this.refused = (values && values.refused) || 0; - } -} - -class MessageCategory extends MessageCount { - category?: Record; - constructor(values?: MessageValues) { - super(values); - if (values && values.category) { - this.category = {}; - Utils.forInOwnNonNullProperties(values.category, (prop: string) => { - (this.category as Record)[prop] = new MessageCount( - (values.category as Record)[prop] - ); - }); - } - } -} - -class ResourceCount { - peak?: number; - min?: number; - mean?: number; - opened?: number; - refused?: number; - - constructor(values?: ResourceValues) { - this.peak = (values && values.peak) || 0; - this.min = (values && values.min) || 0; - this.mean = (values && values.mean) || 0; - this.opened = (values && values.opened) || 0; - this.refused = (values && values.refused) || 0; - } -} - -class RequestCount { - succeeded?: number; - failed?: number; - refused?: number; - - constructor(values?: RequestValues) { - this.succeeded = (values && values.succeeded) || 0; - this.failed = (values && values.failed) || 0; - this.refused = (values && values.refused) || 0; - } -} - -class ConnectionTypes { - plain?: ResourceCount; - tls?: ResourceCount; - all?: ResourceCount; - - constructor(values?: ConnectionTypesValues) { - this.plain = new ResourceCount(values && values.plain); - this.tls = new ResourceCount(values && values.tls); - this.all = new ResourceCount(values && values.all); - } -} - -class MessageTypes { - messages?: MessageCategory; - presence?: MessageCategory; - all?: MessageCategory; - - constructor(values?: MessageTypesValues) { - this.messages = new MessageCategory(values && values.messages); - this.presence = new MessageCategory(values && values.presence); - this.all = new MessageCategory(values && values.all); - } -} - -class MessageTraffic { - realtime?: MessageTypes; - rest?: MessageTypes; - webhook?: MessageTypes; - sharedQueue?: MessageTypes; - externalQueue?: MessageTypes; - httpEvent?: MessageTypes; - push?: MessageTypes; - all?: MessageTypes; - - constructor(values?: MessageTrafficValues) { - this.realtime = new MessageTypes(values && values.realtime); - this.rest = new MessageTypes(values && values.rest); - this.webhook = new MessageTypes(values && values.webhook); - this.sharedQueue = new MessageTypes(values && values.sharedQueue); - this.externalQueue = new MessageTypes(values && values.externalQueue); - this.httpEvent = new MessageTypes(values && values.httpEvent); - this.push = new MessageTypes(values && values.push); - this.all = new MessageTypes(values && values.all); - } -} - -class MessageDirections { - all?: MessageTypes; - inbound?: MessageTraffic; - outbound?: MessageTraffic; - - constructor(values?: MessageDirectionsValues) { - this.all = new MessageTypes(values && values.all); - this.inbound = new MessageTraffic(values && values.inbound); - this.outbound = new MessageTraffic(values && values.outbound); - } -} - -class XchgMessages { - all?: MessageTypes; - producerPaid?: MessageDirections; - consumerPaid?: MessageDirections; - - constructor(values?: XchgMessagesValues) { - this.all = new MessageTypes(values && values.all); - this.producerPaid = new MessageDirections(values && values.producerPaid); - this.consumerPaid = new MessageDirections(values && values.consumerPaid); - } -} - -class PushStats { - messages?: number; - notifications?: NotificationsValues; - directPublishes?: number; - - constructor(values?: PushValues) { - this.messages = (values && values.messages) || 0; - const notifications = values && values.notifications; - this.notifications = { - invalid: (notifications && notifications.invalid) || 0, - attempted: (notifications && notifications.attempted) || 0, - successful: (notifications && notifications.successful) || 0, - failed: (notifications && notifications.failed) || 0, - }; - this.directPublishes = (values && values.directPublishes) || 0; - } -} - -class ProcessedCount { - succeeded?: number; - skipped?: number; - failed?: number; - - constructor(values: ProcessedCountValues) { - this.succeeded = (values && values.succeeded) || 0; - this.skipped = (values && values.skipped) || 0; - this.failed = (values && values.failed) || 0; - } -} - -class ProcessedMessages { - delta?: Record; - - constructor(values?: ProcessedMessagesValues) { - this.delta = undefined; - if (values && values.delta) { - this.delta = {}; - Utils.forInOwnNonNullProperties(values.delta, (prop: string) => { - (this.delta as Record)[prop] = new ProcessedCount( - (values.delta as Record)[prop] - ); - }); - } - } -} - -class Stats extends MessageDirections { - persisted?: MessageTypes; - connections?: ConnectionTypes; - channels?: ResourceCount; - apiRequests?: RequestCount; - tokenRequests?: RequestCount; - xchgProducer?: XchgMessages; - xchgConsumer?: XchgMessages; - push?: PushStats; - processed?: ProcessedMessages; +class Stats { + entries?: Partial>; + schema?: string; + appId?: string; inProgress?: never; unit?: never; intervalId?: never; constructor(values?: StatsValues) { - super(values as MessageDirectionsValues); - this.persisted = new MessageTypes(values && values.persisted); - this.connections = new ConnectionTypes(values && values.connections); - this.channels = new ResourceCount(values && values.channels); - this.apiRequests = new RequestCount(values && values.apiRequests); - this.tokenRequests = new RequestCount(values && values.tokenRequests); - this.xchgProducer = new XchgMessages(values && values.xchgProducer); - this.xchgConsumer = new XchgMessages(values && values.xchgConsumer); - this.push = new PushStats(values && values.pushStats); - this.processed = new ProcessedMessages(values && values.processed); + this.entries = (values && values.entries) || undefined; + this.schema = (values && values.schema) || undefined; + this.appId = (values && values.appId) || undefined; this.inProgress = (values && values.inProgress) || undefined; this.unit = (values && values.unit) || undefined; this.intervalId = (values && values.intervalId) || undefined; diff --git a/src/common/lib/util/defaults.ts b/src/common/lib/util/defaults.ts index 489d651307..2be603152a 100644 --- a/src/common/lib/util/defaults.ts +++ b/src/common/lib/util/defaults.ts @@ -81,7 +81,7 @@ const Defaults = { maxMessageSize: 65536, version, - protocolVersion: 2, + protocolVersion: 3, agent, getHost, getPort, diff --git a/test/realtime/init.test.js b/test/realtime/init.test.js index f617628641..9b056eb6eb 100644 --- a/test/realtime/init.test.js +++ b/test/realtime/init.test.js @@ -35,7 +35,7 @@ define(['ably', 'shared_helper', 'chai'], function (Ably, helper, chai) { var transport = realtime.connection.connectionManager.activeProtocol.transport; var connectUri = helper.isWebsocket(transport) ? transport.uri : transport.recvRequest.uri; try { - expect(connectUri.indexOf('v=2') > -1, 'Check uri includes v=2').to.be.ok; + expect(connectUri.indexOf('v=3') > -1, 'Check uri includes v=3').to.be.ok; } catch (err) { closeAndFinish(done, realtime, err); return; diff --git a/test/rest/http.test.js b/test/rest/http.test.js index dcd7ee8262..f02ed488de 100644 --- a/test/rest/http.test.js +++ b/test/rest/http.test.js @@ -31,7 +31,7 @@ define(['ably', 'shared_helper', 'chai'], function (Ably, helper, chai) { // This test should not directly validate version against Defaults.version, as // ultimately the version header has been derived from that value. - expect(headers['X-Ably-Version']).to.equal('2', 'Verify current version number'); + expect(headers['X-Ably-Version']).to.equal('3', 'Verify current version number'); expect(headers['Ably-Agent'].indexOf('ably-js/' + Defaults.version) > -1, 'Verify agent').to.be.ok; expect(headers['Ably-Agent'].indexOf('custom-agent/0.1.2') > -1, 'Verify custom agent').to.be.ok; diff --git a/test/rest/request.test.js b/test/rest/request.test.js index c123e94606..cfeb081b33 100644 --- a/test/rest/request.test.js +++ b/test/rest/request.test.js @@ -125,7 +125,7 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async restTestOnJsonMsgpack('request_batch_api_success', async function (rest, name) { var body = { channels: [name + '1', name + '2'], messages: { data: 'foo' } }; - const res = await rest.request('POST', '/messages', Defaults.protocolVersion, {}, body, {}); + const res = await rest.request('POST', '/messages', 2, {}, body, {}); expect(res.success).to.equal(true, 'Check res.success is true for a success'); expect(res.statusCode).to.equal(201, 'Check res.statusCode is 201 for a success'); expect(res.errorCode).to.equal(null, 'Check res.errorCode is null for a success'); @@ -145,7 +145,7 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async restTestOnJsonMsgpack.skip('request_batch_api_partial_success', async function (rest, name) { var body = { channels: [name, '[invalid', ''], messages: { data: 'foo' } }; - var res = await rest.request('POST', '/messages', Defaults.protocolVersion, {}, body, {}); + var res = await rest.request('POST', '/messages', 2, {}, body, {}); expect(res.success).to.equal(false, 'Check res.success is false for a partial failure'); expect(res.statusCode).to.equal(400, 'Check HPR.statusCode is 400 for a partial failure'); expect(res.errorCode).to.equal(40020, 'Check HPR.errorCode is 40020 for a partial failure'); diff --git a/test/rest/stats.test.js b/test/rest/stats.test.js index bda82edfb5..d4b3ed164f 100644 --- a/test/rest/stats.test.js +++ b/test/rest/stats.test.js @@ -75,6 +75,27 @@ define(['shared_helper', 'chai'], function (helper, chai) { }); }); + it('contains expected fields', async () => { + // To provoke a non-undefined `inProgress` in the response, we publish a message and fetch stats for the current hour. (I wasn’t able to provoke a non-undefined `inProgress` using stats API fixtures.) + const now = new Date(await rest.time()); + // If the hour is about to turn, wait for it to turn (with a 5-second extra wait to hopefully account for clock differences between Ably servers). + if (now.getUTCMinutes() === 59 && now.getUTCSeconds() > 45) { + await new Promise((resolve) => setTimeout(resolve, 1000 * (5 + (60 - now.getUTCSeconds())))); + } + await rest.channels.get('channel').publish('message', 'data'); + // ably.com documentation says "The most recent statistics are delayed by up to six seconds." + await new Promise((resolve) => setTimeout(resolve, 6000)); + + const stats = (await rest.stats({ end: Date.now(), unit: 'hour' })).items[0]; + + expect(stats.entries).to.be.a('object'); + expect(stats.schema).to.be.a('string'); + expect(stats.appId).to.be.a('string'); + expect(stats.inProgress).to.be.a('string'); + expect(stats.unit).to.be.a('string'); + expect(stats.intervalId).to.be.a('string'); + }); + /** * Using an interval ID string format, check minute-level inbound and outbound stats match fixture data (forwards) * @spec : (RSC6b4) @@ -91,8 +112,8 @@ define(['shared_helper', 'chai'], function (helper, chai) { var totalInbound = 0, totalOutbound = 0; for (var i = 0; i < stats.length; i++) { - totalInbound += stats[i].inbound.all.messages.count; - totalOutbound += stats[i].outbound.all.messages.count; + totalInbound += stats[i].entries['messages.inbound.all.messages.count']; + totalOutbound += stats[i].entries['messages.outbound.all.messages.count']; } expect(totalInbound).to.equal(50 + 60 + 70, 'Verify all inbound messages found'); @@ -115,8 +136,8 @@ define(['shared_helper', 'chai'], function (helper, chai) { var totalInbound = 0, totalOutbound = 0; for (var i = 0; i < stats.length; i++) { - totalInbound += stats[i].inbound.all.messages.count; - totalOutbound += stats[i].outbound.all.messages.count; + totalInbound += stats[i].entries['messages.inbound.all.messages.count']; + totalOutbound += stats[i].entries['messages.outbound.all.messages.count']; } expect(totalInbound).to.equal(50 + 60 + 70, 'Verify all inbound messages found'); @@ -140,8 +161,8 @@ define(['shared_helper', 'chai'], function (helper, chai) { var totalInbound = 0, totalOutbound = 0; for (var i = 0; i < stats.length; i++) { - totalInbound += stats[i].inbound.all.messages.count; - totalOutbound += stats[i].outbound.all.messages.count; + totalInbound += stats[i].entries['messages.inbound.all.messages.count']; + totalOutbound += stats[i].entries['messages.outbound.all.messages.count']; } expect(totalInbound).to.equal(50 + 60 + 70, 'Verify all inbound messages found'); @@ -164,8 +185,8 @@ define(['shared_helper', 'chai'], function (helper, chai) { var totalInbound = 0, totalOutbound = 0; for (var i = 0; i < stats.length; i++) { - totalInbound += stats[i].inbound.all.messages.count; - totalOutbound += stats[i].outbound.all.messages.count; + totalInbound += stats[i].entries['messages.inbound.all.messages.count']; + totalOutbound += stats[i].entries['messages.outbound.all.messages.count']; } expect(totalInbound).to.equal(50 + 60 + 70, 'Verify all inbound messages found'); @@ -188,8 +209,8 @@ define(['shared_helper', 'chai'], function (helper, chai) { var totalInbound = 0, totalOutbound = 0; for (var i = 0; i < stats.length; i++) { - totalInbound += stats[i].inbound.all.messages.count; - totalOutbound += stats[i].outbound.all.messages.count; + totalInbound += stats[i].entries['messages.inbound.all.messages.count']; + totalOutbound += stats[i].entries['messages.outbound.all.messages.count']; } expect(totalInbound).to.equal(50 + 60 + 70, 'Verify all inbound messages found'); @@ -212,8 +233,8 @@ define(['shared_helper', 'chai'], function (helper, chai) { var totalInbound = 0, totalOutbound = 0; for (var i = 0; i < stats.length; i++) { - totalInbound += stats[i].inbound.all.messages.count; - totalOutbound += stats[i].outbound.all.messages.count; + totalInbound += stats[i].entries['messages.inbound.all.messages.count']; + totalOutbound += stats[i].entries['messages.outbound.all.messages.count']; } expect(totalInbound).to.equal(60, 'Verify all inbound messages found'); @@ -236,8 +257,8 @@ define(['shared_helper', 'chai'], function (helper, chai) { var totalInbound = 0, totalOutbound = 0; for (var i = 0; i < stats.length; i++) { - totalInbound += stats[i].inbound.all.messages.count; - totalOutbound += stats[i].outbound.all.messages.count; + totalInbound += stats[i].entries['messages.inbound.all.messages.count']; + totalOutbound += stats[i].entries['messages.outbound.all.messages.count']; } expect(totalInbound).to.equal(50, 'Verify all inbound messages found'); @@ -257,7 +278,7 @@ define(['shared_helper', 'chai'], function (helper, chai) { var stats = page.items; expect(stats.length == 1, 'Verify exactly one stats record found').to.be.ok; var totalData = 0; - for (var i = 0; i < stats.length; i++) totalData += stats[i].inbound.all.messages.data; + for (var i = 0; i < stats.length; i++) totalData += stats[i].entries['messages.inbound.all.messages.data']; expect(totalData).to.equal(7000, 'Verify all published message data found'); /* get next page */ @@ -266,7 +287,7 @@ define(['shared_helper', 'chai'], function (helper, chai) { var stats = page.items; expect(stats.length == 1, 'Verify exactly one stats record found').to.be.ok; var totalData = 0; - for (var i = 0; i < stats.length; i++) totalData += stats[i].inbound.all.messages.data; + for (var i = 0; i < stats.length; i++) totalData += stats[i].entries['messages.inbound.all.messages.data']; expect(totalData).to.equal(6000, 'Verify all published message data found'); /* get next page */ @@ -275,7 +296,7 @@ define(['shared_helper', 'chai'], function (helper, chai) { var stats = page.items; expect(stats.length == 1, 'Verify exactly one stats record found').to.be.ok; var totalData = 0; - for (var i = 0; i < stats.length; i++) totalData += stats[i].inbound.all.messages.data; + for (var i = 0; i < stats.length; i++) totalData += stats[i].entries['messages.inbound.all.messages.data']; expect(totalData).to.equal(5000, 'Verify all published message data found'); /* verify no further pages */ @@ -284,7 +305,7 @@ define(['shared_helper', 'chai'], function (helper, chai) { var page = await page.first(); var totalData = 0; var stats = page.items; - for (var i = 0; i < stats.length; i++) totalData += stats[i].inbound.all.messages.data; + for (var i = 0; i < stats.length; i++) totalData += stats[i].entries['messages.inbound.all.messages.data']; expect(totalData).to.equal(7000, 'Verify all published message data found'); }); @@ -301,7 +322,7 @@ define(['shared_helper', 'chai'], function (helper, chai) { var stats = page.items; expect(stats.length == 1, 'Verify exactly one stats record found').to.be.ok; var totalData = 0; - for (var i = 0; i < stats.length; i++) totalData += stats[i].inbound.all.messages.data; + for (var i = 0; i < stats.length; i++) totalData += stats[i].entries['messages.inbound.all.messages.data']; expect(totalData).to.equal(5000, 'Verify all published message data found'); /* get next page */ @@ -310,7 +331,7 @@ define(['shared_helper', 'chai'], function (helper, chai) { var stats = page.items; expect(stats.length == 1, 'Verify exactly one stats record found').to.be.ok; var totalData = 0; - for (var i = 0; i < stats.length; i++) totalData += stats[i].inbound.all.messages.data; + for (var i = 0; i < stats.length; i++) totalData += stats[i].entries['messages.inbound.all.messages.data']; expect(totalData).to.equal(6000, 'Verify all published message data found'); /* get next page */ @@ -319,7 +340,7 @@ define(['shared_helper', 'chai'], function (helper, chai) { var stats = page.items; expect(stats.length == 1, 'Verify exactly one stats record found').to.be.ok; var totalData = 0; - for (var i = 0; i < stats.length; i++) totalData += stats[i].inbound.all.messages.data; + for (var i = 0; i < stats.length; i++) totalData += stats[i].entries['messages.inbound.all.messages.data']; expect(totalData).to.equal(7000, 'Verify all published message data found'); /* verify no further pages */ @@ -328,7 +349,7 @@ define(['shared_helper', 'chai'], function (helper, chai) { var page = await page.first(); var totalData = 0; var stats = page.items; - for (var i = 0; i < stats.length; i++) totalData += stats[i].inbound.all.messages.data; + for (var i = 0; i < stats.length; i++) totalData += stats[i].entries['messages.inbound.all.messages.data']; expect(totalData).to.equal(5000, 'Verify all published message data found'); }); @@ -344,7 +365,7 @@ define(['shared_helper', 'chai'], function (helper, chai) { var stats = page.items; expect(stats.length == 1, 'Verify exactly one stats record found').to.be.ok; var totalData = 0; - for (var i = 0; i < stats.length; i++) totalData += stats[i].inbound.all.messages.data; + for (var i = 0; i < stats.length; i++) totalData += stats[i].entries['messages.inbound.all.messages.data']; expect(totalData).to.equal(7000, 'Verify all published message data found'); /* get next page */ @@ -353,7 +374,7 @@ define(['shared_helper', 'chai'], function (helper, chai) { var stats = page.items; expect(stats.length == 1, 'Verify exactly one stats record found').to.be.ok; var totalData = 0; - for (var i = 0; i < stats.length; i++) totalData += stats[i].inbound.all.messages.data; + for (var i = 0; i < stats.length; i++) totalData += stats[i].entries['messages.inbound.all.messages.data']; expect(totalData).to.equal(6000, 'Verify all published message data found'); /* get next page */ @@ -362,7 +383,7 @@ define(['shared_helper', 'chai'], function (helper, chai) { var stats = page.items; expect(stats.length == 1, 'Verify exactly one stats record found').to.be.ok; var totalData = 0; - for (var i = 0; i < stats.length; i++) totalData += stats[i].inbound.all.messages.data; + for (var i = 0; i < stats.length; i++) totalData += stats[i].entries['messages.inbound.all.messages.data']; expect(totalData).to.equal(5000, 'Verify all published message data found'); /* verify no further pages */ @@ -371,7 +392,7 @@ define(['shared_helper', 'chai'], function (helper, chai) { var page = await page.first(); var totalData = 0; var stats = page.items; - for (var i = 0; i < stats.length; i++) totalData += stats[i].inbound.all.messages.data; + for (var i = 0; i < stats.length; i++) totalData += stats[i].entries['messages.inbound.all.messages.data']; expect(totalData).to.equal(7000, 'Verify all published message data found'); }); }); diff --git a/types.d.ts b/types.d.ts index ad0c1c9b1c..2734a33ce7 100644 --- a/types.d.ts +++ b/types.d.ts @@ -719,122 +719,6 @@ export interface CipherParams { mode: string; } -/** - * Contains the aggregate counts for messages and data transferred. - */ -export interface StatsMessageCount { - /** - * The count of all messages. - */ - count: number; - /** - * The total number of bytes transferred for all messages. - */ - data: number; -} - -/** - * Contains a breakdown of summary stats data for different (channel vs presence) message types. - */ -export interface StatsMessageTypes { - /** - * A {@link StatsMessageCount} object containing the count and byte value of messages and presence messages. - */ - all: StatsMessageCount; - /** - * A {@link StatsMessageCount} object containing the count and byte value of messages. - */ - messages: StatsMessageCount; - /** - * A {@link StatsMessageCount} object containing the count and byte value of presence messages. - */ - presence: StatsMessageCount; -} - -/** - * Contains the aggregate counts for requests made. - */ -export interface StatsRequestCount { - /** - * The number of requests that failed. - */ - failed: number; - /** - * The number of requests that were refused, typically as a result of permissions or a limit being exceeded. - */ - refused: number; - /** - * The number of requests that succeeded. - */ - succeeded: number; -} - -/** - * Contains the aggregate data for usage of a resource in a specific scope. - */ -export interface StatsResourceCount { - /** - * The average number of resources of this type used for this period. - */ - mean: number; - /** - * The minimum total resources of this type used for this period. - */ - min: number; - /** - * The total number of resources opened of this type. - */ - opened: number; - /** - * The peak number of resources of this type used for this period. - */ - peak: number; - /** - * The number of resource requests refused within this period. - */ - refused: number; -} - -/** - * Contains a breakdown of summary stats data for different (TLS vs non-TLS) connection types. - */ -export interface StatsConnectionTypes { - /** - * A {@link StatsResourceCount} object containing a breakdown of usage by scope over TLS connections (both TLS and non-TLS). - */ - all: StatsResourceCount; - /** - * A {@link StatsResourceCount} object containing a breakdown of usage by scope over non-TLS connections. - */ - plain: StatsResourceCount; - /** - * A {@link StatsResourceCount} object containing a breakdown of usage by scope over TLS connections. - */ - tls: StatsResourceCount; -} - -/** - * Contains a breakdown of summary stats data for traffic over various transport types. - */ -export interface StatsMessageTraffic { - /** - * A {@link StatsMessageTypes} object containing a breakdown of usage by message type for all messages (includes `realtime`, `rest` and `webhook` messages). - */ - all: StatsMessageTypes; - /** - * A {@link StatsMessageTypes} object containing a breakdown of usage by message type for messages transferred over a realtime transport such as WebSocket. - */ - realtime: StatsMessageTypes; - /** - * A {@link StatsMessageTypes} object containing a breakdown of usage by message type for messages transferred over a rest transport such as WebSocket. - */ - rest: StatsMessageTypes; - /** - * A {@link StatsMessageTypes} object containing a breakdown of usage by message type for messages delivered using webhooks. - */ - webhook: StatsMessageTypes; -} - /** * Contains an Ably Token and its associated metadata. */ @@ -2532,42 +2416,26 @@ export declare class Connection extends EventEmitter>; /** - * A {@link StatsMessageTypes} object containing the aggregate count of persisted message stats. + * The URL of a [JSON Schema](https://json-schema.org/) which describes the structure of this `Stats` object. */ - persisted: StatsMessageTypes; + schema: string; /** - * A {@link StatsRequestCount} object containing a breakdown of Ably Token requests. + * The ID of the Ably application the statistics are for. */ - tokenRequests: StatsRequestCount; + appId: string; } /**