Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert removing Message and PresenceMessage from public API #1004

Merged
merged 4 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/common/lib/client/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { ErrnoException, IHttp, RequestParams } from '../../types/http';
import ClientOptions, { DeprecatedClientOptions, NormalisedClientOptions } from '../../types/ClientOptions';

import Platform from '../../platform';
import Message from '../types/message';
import PresenceMessage from '../types/presencemessage';

const noop = function () {};
class Rest {
Expand Down Expand Up @@ -236,6 +238,8 @@ class Rest {
static Callbacks = Rest;
static Platform = Platform;
static Crypto?: typeof Platform.Crypto;
static Message?: typeof Message;
static PresenceMessage?: typeof PresenceMessage;
}

class Channels {
Expand Down
8 changes: 8 additions & 0 deletions src/platform/nativescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ 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';
import PresenceMessage from 'common/lib/types/presencemessage';

Platform.Crypto = Crypto;
Platform.BufferUtils = BufferUtils;
Expand All @@ -30,6 +32,12 @@ Platform.WebStorage = WebStorage;
Rest.Crypto = Crypto;
Realtime.Crypto = Crypto;

Rest.Message = Message;
Realtime.Message = Message;

Rest.PresenceMessage = PresenceMessage;
Realtime.PresenceMessage = PresenceMessage;

Realtime.ConnectionManager = ConnectionManager;

Logger.initLogHandlers();
Expand Down
8 changes: 8 additions & 0 deletions src/platform/nodejs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ 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';
import PresenceMessage from 'common/lib/types/presencemessage';

Platform.Crypto = Crypto;
Platform.BufferUtils = BufferUtils;
Expand All @@ -26,6 +28,12 @@ Platform.WebStorage = null;
Rest.Crypto = Crypto;
Realtime.Crypto = Crypto;

Rest.Message = Message;
Realtime.Message = Message;

Rest.PresenceMessage = PresenceMessage;
Realtime.PresenceMessage = PresenceMessage;

Realtime.ConnectionManager = ConnectionManager;

Logger.initLogHandlers();
Expand Down
8 changes: 8 additions & 0 deletions src/platform/react-native/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ 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';
import PresenceMessage from 'common/lib/types/presencemessage';

Platform.Crypto = Crypto;
Platform.BufferUtils = BufferUtils;
Expand All @@ -28,6 +30,12 @@ Platform.WebStorage = WebStorage;
Rest.Crypto = Crypto;
Realtime.Crypto = Crypto;

Rest.Message = Message;
Realtime.Message = Message;

Rest.PresenceMessage = PresenceMessage;
Realtime.PresenceMessage = PresenceMessage;

Realtime.ConnectionManager = ConnectionManager;

Logger.initLogHandlers();
Expand Down
8 changes: 8 additions & 0 deletions src/platform/web-noencryption/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ 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';
import PresenceMessage from 'common/lib/types/presencemessage';

Platform.Crypto = null;
Platform.BufferUtils = BufferUtils;
Expand All @@ -27,6 +29,12 @@ Platform.WebStorage = WebStorage;
Rest.Crypto = Crypto;
Realtime.Crypto = Crypto;

Rest.Message = Message;
Realtime.Message = Message;

Rest.PresenceMessage = PresenceMessage;
Realtime.PresenceMessage = PresenceMessage;

Realtime.ConnectionManager = ConnectionManager;

Logger.initLogHandlers();
Expand Down
8 changes: 8 additions & 0 deletions src/platform/web/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ 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';
import PresenceMessage from 'common/lib/types/presencemessage';

Platform.Crypto = Crypto;
Platform.BufferUtils = BufferUtils;
Expand All @@ -28,6 +30,12 @@ Platform.WebStorage = WebStorage;
Rest.Crypto = Crypto;
Realtime.Crypto = Crypto;

Rest.Message = Message;
Realtime.Message = Message;

Rest.PresenceMessage = PresenceMessage;
Realtime.PresenceMessage = PresenceMessage;

Realtime.ConnectionManager = ConnectionManager;

Logger.initLogHandlers();
Expand Down
32 changes: 32 additions & 0 deletions test/realtime/api.test.js
Original file line number Diff line number Diff line change
@@ -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');
});
});
});
32 changes: 32 additions & 0 deletions test/rest/api.test.js
Original file line number Diff line number Diff line change
@@ -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');
});
});
});