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

[ECO-4868] Upgrade to ably-js v2 #325

Merged
merged 10 commits into from
Jul 17, 2024
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: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ To instantiate the Spaces SDK, create an [Ably client](https://ably.com/docs/get
import Spaces from '@ably/spaces';
import { Realtime } from 'ably';

const client = new Realtime.Promise({ key: "<API-key>", clientId: "<client-ID>" });
const client = new Realtime({ key: "<API-key>", clientId: "<client-ID>" });
const spaces = new Spaces(client);
```
You can use [basic authentication](https://ably.com/docs/auth/basic) i.e. the API Key directly for testing purposes, however it is strongly recommended that you use [token authentication](https://ably.com/docs/auth/token) in production environments.
Expand All @@ -95,7 +95,7 @@ You can also use Spaces with a CDN, such as [unpkg](https://www.unpkg.com/):
After this, instantiate the SDK in the same way as in the NPM option above:

```ts
const client = new Ably.Realtime.Promise({ key: "<API-key>", clientId: "<client-ID>" });
const client = new Ably.Realtime({ key: "<API-key>", clientId: "<client-ID>" });
const spaces = new Spaces(client);
```

Expand Down
10 changes: 6 additions & 4 deletions __mocks__/ably/promises/index.ts → __mocks__/ably/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Ably, { Types } from 'ably/promises';
import { PresenceMessage, Rest, ErrorInfo } from 'ably';

const MOCK_CLIENT_ID = 'MOCK_CLIENT_ID';

Expand All @@ -7,7 +7,7 @@ const methodReturningVoidPromise = () => mockPromisify<void>((() => {})());

function createMockPresence() {
return {
get: () => mockPromisify<Types.PresenceMessage[]>([]),
get: () => mockPromisify<PresenceMessage[]>([]),
update: () => mockPromisify<void>(undefined),
enter: methodReturningVoidPromise,
leave: methodReturningVoidPromise,
Expand Down Expand Up @@ -91,8 +91,10 @@ class MockRealtime {
}
}

class MockErrorInfo extends ErrorInfo {}

// maintain the PresenceMessage class so tests can initialise it directly using
// PresenceMessage.fromValues.
MockRealtime.PresenceMessage = Ably.Rest.PresenceMessage;
MockRealtime.PresenceMessage = Rest.PresenceMessage;

export { MockRealtime as Realtime };
export { MockRealtime as Realtime, MockErrorInfo as ErrorInfo };
2 changes: 1 addition & 1 deletion demo/api/ably-token-request/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as dotenv from 'dotenv';
import * as Ably from 'ably/promises';
import * as Ably from 'ably';
import { HandlerEvent } from '@netlify/functions';

dotenv.config();
Expand Down
106 changes: 72 additions & 34 deletions demo/api/ably-token-request/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion demo/api/ably-token-request/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@netlify/functions": "^1.4.0",
"@types/node": "^18.3.0",
"ably": "^1.2.36",
"ably": "^2.3.0",
"dotenv": "^16.0.3",
"typescript": "^4.9.5"
}
Expand Down
Loading
Loading