From ce21f999bb51c9dbc256bb79c199c4bd495a9a46 Mon Sep 17 00:00:00 2001 From: Owen Pearson Date: Fri, 10 Jun 2022 15:51:42 +0100 Subject: [PATCH 1/4] Revert removing Message from public API --- src/common/lib/client/rest.ts | 2 ++ src/platform/nativescript/index.ts | 4 ++++ src/platform/nodejs/index.ts | 4 ++++ src/platform/react-native/index.ts | 4 ++++ src/platform/web-noencryption/index.ts | 4 ++++ src/platform/web/index.ts | 4 ++++ 6 files changed, 22 insertions(+) diff --git a/src/common/lib/client/rest.ts b/src/common/lib/client/rest.ts index f575c2d192..9d30ce75d9 100644 --- a/src/common/lib/client/rest.ts +++ b/src/common/lib/client/rest.ts @@ -14,6 +14,7 @@ import { ErrnoException, IHttp, RequestParams } from '../../types/http'; import ClientOptions, { DeprecatedClientOptions, NormalisedClientOptions } from '../../types/ClientOptions'; import Platform from '../../platform'; +import Message from '../types/message'; const noop = function () {}; class Rest { @@ -236,6 +237,7 @@ class Rest { static Callbacks = Rest; static Platform = Platform; static Crypto?: typeof Platform.Crypto; + static Message?: typeof Message; } class Channels { diff --git a/src/platform/nativescript/index.ts b/src/platform/nativescript/index.ts index 0ae045b01c..50e5ac659b 100644 --- a/src/platform/nativescript/index.ts +++ b/src/platform/nativescript/index.ts @@ -19,6 +19,7 @@ import ConnectionManager from '../../common/lib/transport/connectionmanager'; import WebStorage from './lib/util/webstorage'; import PlatformDefaults from '../web/lib/util/defaults'; import msgpack from '../web/lib/util/msgpack'; +import Message from 'common/lib/types/message'; Platform.Crypto = Crypto; Platform.BufferUtils = BufferUtils; @@ -30,6 +31,9 @@ Platform.WebStorage = WebStorage; Rest.Crypto = Crypto; Realtime.Crypto = Crypto; +Rest.Message = Message; +Realtime.Message = Message; + Realtime.ConnectionManager = ConnectionManager; Logger.initLogHandlers(); diff --git a/src/platform/nodejs/index.ts b/src/platform/nodejs/index.ts index c14fb4bce6..66f33ab120 100644 --- a/src/platform/nodejs/index.ts +++ b/src/platform/nodejs/index.ts @@ -15,6 +15,7 @@ import Logger from '../../common/lib/util/logger'; import { getDefaults } from '../../common/lib/util/defaults'; import ConnectionManager from '../../common/lib/transport/connectionmanager'; import PlatformDefaults from './lib/util/defaults'; +import Message from 'common/lib/types/message'; Platform.Crypto = Crypto; Platform.BufferUtils = BufferUtils; @@ -26,6 +27,9 @@ Platform.WebStorage = null; Rest.Crypto = Crypto; Realtime.Crypto = Crypto; +Rest.Message = Message; +Realtime.Message = Message; + Realtime.ConnectionManager = ConnectionManager; Logger.initLogHandlers(); diff --git a/src/platform/react-native/index.ts b/src/platform/react-native/index.ts index 4f9a5ab1e0..7fdd3dcb5c 100644 --- a/src/platform/react-native/index.ts +++ b/src/platform/react-native/index.ts @@ -17,6 +17,7 @@ import ConnectionManager from '../../common/lib/transport/connectionmanager'; import WebStorage from '../web/lib/util/webstorage'; import PlatformDefaults from '../web/lib/util/defaults'; import msgpack from '../web/lib/util/msgpack'; +import Message from 'common/lib/types/message'; Platform.Crypto = Crypto; Platform.BufferUtils = BufferUtils; @@ -28,6 +29,9 @@ Platform.WebStorage = WebStorage; Rest.Crypto = Crypto; Realtime.Crypto = Crypto; +Rest.Message = Message; +Realtime.Message = Message; + Realtime.ConnectionManager = ConnectionManager; Logger.initLogHandlers(); diff --git a/src/platform/web-noencryption/index.ts b/src/platform/web-noencryption/index.ts index 397f7d564c..63d6af3ab6 100644 --- a/src/platform/web-noencryption/index.ts +++ b/src/platform/web-noencryption/index.ts @@ -16,6 +16,7 @@ import ConnectionManager from '../../common/lib/transport/connectionmanager'; import WebStorage from '../web/lib/util/webstorage'; import PlatformDefaults from '../web/lib/util/defaults'; import msgpack from '../web/lib/util/msgpack'; +import Message from 'common/lib/types/message'; Platform.Crypto = null; Platform.BufferUtils = BufferUtils; @@ -27,6 +28,9 @@ Platform.WebStorage = WebStorage; Rest.Crypto = Crypto; Realtime.Crypto = Crypto; +Rest.Message = Message; +Realtime.Message = Message; + Realtime.ConnectionManager = ConnectionManager; Logger.initLogHandlers(); diff --git a/src/platform/web/index.ts b/src/platform/web/index.ts index 06f4b756f4..021d7621fc 100644 --- a/src/platform/web/index.ts +++ b/src/platform/web/index.ts @@ -17,6 +17,7 @@ import ConnectionManager from '../../common/lib/transport/connectionmanager'; import WebStorage from './lib/util/webstorage'; import PlatformDefaults from './lib/util/defaults'; import msgpack from './lib/util/msgpack'; +import Message from 'common/lib/types/message'; Platform.Crypto = Crypto; Platform.BufferUtils = BufferUtils; @@ -28,6 +29,9 @@ Platform.WebStorage = WebStorage; Rest.Crypto = Crypto; Realtime.Crypto = Crypto; +Rest.Message = Message; +Realtime.Message = Message; + Realtime.ConnectionManager = ConnectionManager; Logger.initLogHandlers(); From 99e7782edbe094edda31d834f7b99077f19f01a3 Mon Sep 17 00:00:00 2001 From: Owen Pearson Date: Fri, 10 Jun 2022 15:53:53 +0100 Subject: [PATCH 2/4] Revert removing PresenceMessage from public API --- src/common/lib/client/rest.ts | 2 ++ src/platform/nativescript/index.ts | 4 ++++ src/platform/nodejs/index.ts | 4 ++++ src/platform/react-native/index.ts | 4 ++++ src/platform/web-noencryption/index.ts | 4 ++++ src/platform/web/index.ts | 4 ++++ 6 files changed, 22 insertions(+) diff --git a/src/common/lib/client/rest.ts b/src/common/lib/client/rest.ts index 9d30ce75d9..8da4a24c16 100644 --- a/src/common/lib/client/rest.ts +++ b/src/common/lib/client/rest.ts @@ -15,6 +15,7 @@ import ClientOptions, { DeprecatedClientOptions, NormalisedClientOptions } from import Platform from '../../platform'; import Message from '../types/message'; +import PresenceMessage from '../types/presencemessage'; const noop = function () {}; class Rest { @@ -238,6 +239,7 @@ class Rest { static Platform = Platform; static Crypto?: typeof Platform.Crypto; static Message?: typeof Message; + static PresenceMessage?: typeof PresenceMessage; } class Channels { diff --git a/src/platform/nativescript/index.ts b/src/platform/nativescript/index.ts index 50e5ac659b..5e915842b8 100644 --- a/src/platform/nativescript/index.ts +++ b/src/platform/nativescript/index.ts @@ -20,6 +20,7 @@ import WebStorage from './lib/util/webstorage'; import PlatformDefaults from '../web/lib/util/defaults'; import msgpack from '../web/lib/util/msgpack'; import Message from 'common/lib/types/message'; +import PresenceMessage from 'common/lib/types/presencemessage'; Platform.Crypto = Crypto; Platform.BufferUtils = BufferUtils; @@ -34,6 +35,9 @@ Realtime.Crypto = Crypto; Rest.Message = Message; Realtime.Message = Message; +Rest.PresenceMessage = PresenceMessage; +Realtime.PresenceMessage = PresenceMessage; + Realtime.ConnectionManager = ConnectionManager; Logger.initLogHandlers(); diff --git a/src/platform/nodejs/index.ts b/src/platform/nodejs/index.ts index 66f33ab120..606d5bf8f9 100644 --- a/src/platform/nodejs/index.ts +++ b/src/platform/nodejs/index.ts @@ -16,6 +16,7 @@ import { getDefaults } from '../../common/lib/util/defaults'; import ConnectionManager from '../../common/lib/transport/connectionmanager'; import PlatformDefaults from './lib/util/defaults'; import Message from 'common/lib/types/message'; +import PresenceMessage from 'common/lib/types/presencemessage'; Platform.Crypto = Crypto; Platform.BufferUtils = BufferUtils; @@ -30,6 +31,9 @@ Realtime.Crypto = Crypto; Rest.Message = Message; Realtime.Message = Message; +Rest.PresenceMessage = PresenceMessage; +Realtime.PresenceMessage = PresenceMessage; + Realtime.ConnectionManager = ConnectionManager; Logger.initLogHandlers(); diff --git a/src/platform/react-native/index.ts b/src/platform/react-native/index.ts index 7fdd3dcb5c..dcc50b9632 100644 --- a/src/platform/react-native/index.ts +++ b/src/platform/react-native/index.ts @@ -18,6 +18,7 @@ import WebStorage from '../web/lib/util/webstorage'; import PlatformDefaults from '../web/lib/util/defaults'; import msgpack from '../web/lib/util/msgpack'; import Message from 'common/lib/types/message'; +import PresenceMessage from 'common/lib/types/presencemessage'; Platform.Crypto = Crypto; Platform.BufferUtils = BufferUtils; @@ -32,6 +33,9 @@ Realtime.Crypto = Crypto; Rest.Message = Message; Realtime.Message = Message; +Rest.PresenceMessage = PresenceMessage; +Realtime.PresenceMessage = PresenceMessage; + Realtime.ConnectionManager = ConnectionManager; Logger.initLogHandlers(); diff --git a/src/platform/web-noencryption/index.ts b/src/platform/web-noencryption/index.ts index 63d6af3ab6..90a34f0233 100644 --- a/src/platform/web-noencryption/index.ts +++ b/src/platform/web-noencryption/index.ts @@ -17,6 +17,7 @@ import WebStorage from '../web/lib/util/webstorage'; import PlatformDefaults from '../web/lib/util/defaults'; import msgpack from '../web/lib/util/msgpack'; import Message from 'common/lib/types/message'; +import PresenceMessage from 'common/lib/types/presencemessage'; Platform.Crypto = null; Platform.BufferUtils = BufferUtils; @@ -31,6 +32,9 @@ Realtime.Crypto = Crypto; Rest.Message = Message; Realtime.Message = Message; +Rest.PresenceMessage = PresenceMessage; +Realtime.PresenceMessage = PresenceMessage; + Realtime.ConnectionManager = ConnectionManager; Logger.initLogHandlers(); diff --git a/src/platform/web/index.ts b/src/platform/web/index.ts index 021d7621fc..b15939d654 100644 --- a/src/platform/web/index.ts +++ b/src/platform/web/index.ts @@ -18,6 +18,7 @@ import WebStorage from './lib/util/webstorage'; import PlatformDefaults from './lib/util/defaults'; import msgpack from './lib/util/msgpack'; import Message from 'common/lib/types/message'; +import PresenceMessage from 'common/lib/types/presencemessage'; Platform.Crypto = Crypto; Platform.BufferUtils = BufferUtils; @@ -32,6 +33,9 @@ Realtime.Crypto = Crypto; Rest.Message = Message; Realtime.Message = Message; +Rest.PresenceMessage = PresenceMessage; +Realtime.PresenceMessage = PresenceMessage; + Realtime.ConnectionManager = ConnectionManager; Logger.initLogHandlers(); From 0ef07f50dbdbf2084095d9dc6c8bd0ba372f3c2f Mon Sep 17 00:00:00 2001 From: Owen Pearson Date: Fri, 10 Jun 2022 15:58:54 +0100 Subject: [PATCH 3/4] Add initial REST API tests --- test/rest/api.test.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/rest/api.test.js diff --git a/test/rest/api.test.js b/test/rest/api.test.js new file mode 100644 index 0000000000..dd3610c982 --- /dev/null +++ b/test/rest/api.test.js @@ -0,0 +1,32 @@ +'use strict'; + +define(['ably', 'chai'], function (Ably, chai) { + var expect = chai.expect; + + describe('rest/api', function () { + it('Client constructors', function () { + expect(typeof Ably.Rest).to.equal('function'); + expect(typeof Ably.Rest.Promise).to.equal('function'); + expect(typeof Ably.Rest.Callbacks).to.equal('function'); + expect(Ably.Rest.Callbacks).to.equal(Ably.Rest); + }); + + it('Crypto', function () { + expect(typeof Ably.Rest.Crypto).to.equal('function'); + expect(typeof Ably.Rest.Crypto.getDefaultParams).to.equal('function'); + expect(typeof Ably.Rest.Crypto.generateRandomKey).to.equal('function'); + }); + + it('Message', function () { + expect(typeof Ably.Rest.Message).to.equal('function'); + expect(typeof Ably.Rest.Message.fromEncoded).to.equal('function'); + expect(typeof Ably.Rest.Message.fromEncodedArray).to.equal('function'); + }); + + it('PresenceMessage', function () { + expect(typeof Ably.Rest.PresenceMessage).to.equal('function'); + expect(typeof Ably.Rest.PresenceMessage.fromEncoded).to.equal('function'); + expect(typeof Ably.Rest.PresenceMessage.fromEncodedArray).to.equal('function'); + }); + }); +}); From 37204a84cd8ad743609f9823cfb4794f8c82a721 Mon Sep 17 00:00:00 2001 From: Owen Pearson Date: Fri, 10 Jun 2022 15:59:07 +0100 Subject: [PATCH 4/4] Add initial realtime API tests --- test/realtime/api.test.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/realtime/api.test.js diff --git a/test/realtime/api.test.js b/test/realtime/api.test.js new file mode 100644 index 0000000000..1a4dae77be --- /dev/null +++ b/test/realtime/api.test.js @@ -0,0 +1,32 @@ +'use strict'; + +define(['ably', 'chai'], function (Ably, chai) { + var expect = chai.expect; + + describe('realtime/api', function () { + it('Client constructors', function () { + expect(typeof Ably.Realtime).to.equal('function'); + expect(typeof Ably.Realtime.Promise).to.equal('function'); + expect(typeof Ably.Realtime.Callbacks).to.equal('function'); + expect(Ably.Realtime.Callbacks).to.equal(Ably.Realtime); + }); + + it('Crypto', function () { + expect(typeof Ably.Realtime.Crypto).to.equal('function'); + expect(typeof Ably.Realtime.Crypto.getDefaultParams).to.equal('function'); + expect(typeof Ably.Realtime.Crypto.generateRandomKey).to.equal('function'); + }); + + it('Message', function () { + expect(typeof Ably.Realtime.Message).to.equal('function'); + expect(typeof Ably.Realtime.Message.fromEncoded).to.equal('function'); + expect(typeof Ably.Realtime.Message.fromEncodedArray).to.equal('function'); + }); + + it('PresenceMessage', function () { + expect(typeof Ably.Realtime.PresenceMessage).to.equal('function'); + expect(typeof Ably.Realtime.PresenceMessage.fromEncoded).to.equal('function'); + expect(typeof Ably.Realtime.PresenceMessage.fromEncodedArray).to.equal('function'); + }); + }); +});